refactor: extract @uncaged/workflow-util-role from workflow-role-llm #15

Closed
opened 2026-05-06 07:18:59 +00:00 by xiaoju · 0 comments
Owner

背景

@uncaged/workflow-role-llm 包含一些通用的 role 工具(decorators、extract),不是 LLM 特有的。应该拆到 @uncaged/workflow-util-role

命名规范

@uncaged/workflow-util-role     # Role 通用工具
@uncaged/workflow-util-agent    # Agent 通用工具(已有)
@uncaged/workflow-role-xxx      # 具体 Role 实现
@uncaged/workflow-agent-xxx     # 具体 Agent Adapter

需要从 workflow-role-llm 迁移到 workflow-util-role 的

  • decorateRole — role 装饰器组合
  • withDryRun — dry-run decorator
  • onFail — 失败处理 decorator
  • extractMetaOrThrow — 从原始输出提取结构化 meta
  • schema-defaults.ts — zod schema 默认值生成(用于 dry-run)
  • 相关类型:RoleDecorator, WithDryRunOptions, OnFailOptions

留在 workflow-role-llm 的

  • createRole — LLM role 工厂(依赖 util-role)
  • createLlmAdapter — LLM provider 抽象
  • llmExtract / llmExtractWithRetry — LLM 特有的 extract(依赖 util-role 的 extractMetaOrThrow)
  • buildDescriptorFromRoles — descriptor 生成

新包结构

packages/workflow-util-role/
  package.json    # @uncaged/workflow-util-role, dep: @uncaged/workflow workspace:*, zod ^4.0.0
  src/
    decorators.ts        # decorateRole, withDryRun, onFail
    extract-meta.ts      # extractMetaOrThrow
    schema-defaults.ts   # zod schema 默认值
    index.ts

更新依赖链

  • workflow-util-role: dep → @uncaged/workflow, zod
  • workflow-role-llm: dep → @uncaged/workflow, @uncaged/workflow-util-role, zod
  • workflow-role-committer: dep → 如果用了 decorators,改 import 自 util-role
  • workflow-role-reviewer: dep → 同上

验证

  • 通用 role 工具在 util-role 包
  • workflow-role-llm 只保留 LLM 特有逻辑
  • 所有下游包 import 更新
  • bun test 通过
  • bunx biome check . 通过
## 背景 `@uncaged/workflow-role-llm` 包含一些通用的 role 工具(decorators、extract),不是 LLM 特有的。应该拆到 `@uncaged/workflow-util-role`。 ## 命名规范 ``` @uncaged/workflow-util-role # Role 通用工具 @uncaged/workflow-util-agent # Agent 通用工具(已有) @uncaged/workflow-role-xxx # 具体 Role 实现 @uncaged/workflow-agent-xxx # 具体 Agent Adapter ``` ## 需要从 workflow-role-llm 迁移到 workflow-util-role 的 - `decorateRole` — role 装饰器组合 - `withDryRun` — dry-run decorator - `onFail` — 失败处理 decorator - `extractMetaOrThrow` — 从原始输出提取结构化 meta - `schema-defaults.ts` — zod schema 默认值生成(用于 dry-run) - 相关类型:RoleDecorator, WithDryRunOptions, OnFailOptions ## 留在 workflow-role-llm 的 - `createRole` — LLM role 工厂(依赖 util-role) - `createLlmAdapter` — LLM provider 抽象 - `llmExtract` / `llmExtractWithRetry` — LLM 特有的 extract(依赖 util-role 的 extractMetaOrThrow) - `buildDescriptorFromRoles` — descriptor 生成 ## 新包结构 ``` packages/workflow-util-role/ package.json # @uncaged/workflow-util-role, dep: @uncaged/workflow workspace:*, zod ^4.0.0 src/ decorators.ts # decorateRole, withDryRun, onFail extract-meta.ts # extractMetaOrThrow schema-defaults.ts # zod schema 默认值 index.ts ``` ## 更新依赖链 - `workflow-util-role`: dep → @uncaged/workflow, zod - `workflow-role-llm`: dep → @uncaged/workflow, @uncaged/workflow-util-role, zod - `workflow-role-committer`: dep → 如果用了 decorators,改 import 自 util-role - `workflow-role-reviewer`: dep → 同上 ## 验证 - [ ] 通用 role 工具在 util-role 包 - [ ] workflow-role-llm 只保留 LLM 特有逻辑 - [ ] 所有下游包 import 更新 - [ ] bun test 通过 - [ ] bunx biome check . 通过
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#15