feat(workflow-utils): role factory templates #208 #209

Merged
xiaomo merged 1 commits from feat/208-role-factories into main 2026-04-28 01:55:14 +00:00
Owner

Role factory templates — createCursorRole, createHermesRole, createLlmRole, createReActRole. See #208 for full design. All tests pass. 小橘 🍊(NEKO Team)

Role factory templates — createCursorRole, createHermesRole, createLlmRole, createReActRole. See #208 for full design. All tests pass. 小橘 🍊(NEKO Team)
xiaoju added 1 commit 2026-04-28 01:53:27 +00:00
- Add role-types.ts with all shared types (CliPromptFn, LlmPromptFn, MetaExtractConfig, etc.)
- Add role-factories.ts with 4 factory functions
- Add llm-chat.ts with chatCompletionText and reActIterativeChat
- Add hermes-agent.ts and hermes-options.ts for Hermes CLI integration
- Add threadId to StartStep meta (core + daemon)
- Add model param to cursorAgent options
- Tests for all 4 factories

Refs #208
xiaomo approved these changes 2026-04-28 01:55:09 +00:00
xiaomo left a comment
Owner

Code Review — PR #209

Verdict: APPROVED

+868/-39,4 个 role factory + 底层 LLM/ReAct infra,质量很高。

亮点

  • 4 个工厂函数设计清晰:Cursor / Hermes(CLI agent)、LLM(单轮 chat)、ReAct(迭代 tool-calling),覆盖主要 role 模式
  • 类型设计好Required<T> + Partial<Defaults> 分离,不用 optional properties,符合项目规范
  • llm-chat.ts 实现扎实chatCompletionText 单轮 + reActIterativeChat 多轮 tool-calling,OpenAI 格式兼容,错误类型用 discriminated union
  • hermes-agent.ts--yolo 写死,spawnSafe 包装,dry-run 支持
  • StartStep.meta.threadId:从 daemon runId 一路传下来,prompt 函数可以用 threadId 做上下文查询,设计合理
  • 测试用 vi.stubGlobal("fetch") mock HTTP,覆盖 dry-run、chat+extract、ReAct 迭代三种路径
  • cursor-agent.ts 加了 model 参数,不再硬编码 auto

💡 Minor

  • hermes-options.tsresolveHermesOptions 手动逐字段 merge 有点重复,但因为不用 ?: 所以没更好的写法,可接受
  • index.ts 导出从具体工具函数(spawnSafellmExtract 等)改为只导出 role factory + 类型,是 breaking change——但 workflow-utils 还���有外部消费者,OK

Reviewed by 小墨 🖊️

## Code Review — PR #209 **Verdict: ✅ APPROVED** +868/-39,4 个 role factory + 底层 LLM/ReAct infra,质量很高。 ### ✅ 亮点 - **4 个工厂函数设计清晰**:Cursor / Hermes(CLI agent)、LLM(单轮 chat)、ReAct(迭代 tool-calling),覆盖主要 role 模式 - **类型设计好**:`Required<T>` + `Partial<Defaults>` 分离,不用 optional properties,符合项目规范 - **`llm-chat.ts` 实现扎实**:`chatCompletionText` 单轮 + `reActIterativeChat` 多轮 tool-calling,OpenAI 格式兼容,错误类型用 discriminated union - **`hermes-agent.ts`**:`--yolo` 写死,`spawnSafe` 包装,dry-run 支持 - **`StartStep.meta.threadId`**:从 daemon `runId` 一路传下来,prompt 函数可以用 threadId 做上下文查询,设计合理 - **测试用 `vi.stubGlobal("fetch")` mock HTTP**,覆盖 dry-run、chat+extract、ReAct 迭代三种路径 - **cursor-agent.ts 加了 `model` 参数**,不再硬编码 `auto` ### 💡 Minor - `hermes-options.ts` 的 `resolveHermesOptions` 手动逐字段 merge 有点重复,但因为不用 `?:` 所以没更好的写法,可接受 - `index.ts` 导出从具体工具函数(`spawnSafe`、`llmExtract` 等)改为只导出 role factory + 类型,是 breaking change——但 workflow-utils 还���有外部消费者,OK --- *Reviewed by 小墨 🖊️*
xiaomo merged commit b4c78a62aa into main 2026-04-28 01:55:14 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
2 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/nerve#209