refactor: simplify ExtractFn to (schema, contentHash) #184

Merged
xingyue merged 3 commits from refactor/180-simplify-extract-fn into main 2026-05-11 08:03:49 +00:00
Owner

What

Simplify ExtractFn from (schema, prompt, ExtractContext) to (schema, contentHash).

Why

  • extractPrompt was redundant — schema already describes what to extract
  • ExtractContext was unnecessary — extractor only needs the CAS content hash
  • workflow-as-agent forced extractPrompt to do DAG traversal business logic

Changes

Phase 1: ExtractFn signature + type cleanup (22 files, -134/+27)

  • workflow-protocol — remove extractPrompt from RoleDefinition, remove ExtractContext, simplify ExtractFn
  • workflow-execute/extract — rewrite createExtract to take (schema, contentHash), read CAS content by hash
  • workflow-runtime/create-workflow — store agent output in CAS first, then call extract(schema, hash)
  • All role definitions — remove extractPrompt
  • Coder schema — move phase hash hint to .describe()
  • CLI init templates + skill output — remove extractPrompt references

Phase 2: workflow-as-agent readable output

  • Output readable summary with child workflow result instead of raw root hash
  • Extract can now work directly without special DAG traversal prompt

Ref

Fixes #180, closes #174, closes #181, closes #182

— 小橘 🍊(NEKO Team)

## What Simplify `ExtractFn` from `(schema, prompt, ExtractContext)` to `(schema, contentHash)`. ## Why - `extractPrompt` was redundant — schema already describes what to extract - `ExtractContext` was unnecessary — extractor only needs the CAS content hash - workflow-as-agent forced extractPrompt to do DAG traversal business logic ## Changes ### Phase 1: ExtractFn signature + type cleanup (22 files, -134/+27) - `workflow-protocol` — remove `extractPrompt` from `RoleDefinition`, remove `ExtractContext`, simplify `ExtractFn` - `workflow-execute/extract` — rewrite `createExtract` to take `(schema, contentHash)`, read CAS content by hash - `workflow-runtime/create-workflow` — store agent output in CAS first, then call `extract(schema, hash)` - All role definitions — remove `extractPrompt` - Coder schema — move phase hash hint to `.describe()` - CLI init templates + skill output — remove `extractPrompt` references ### Phase 2: workflow-as-agent readable output - Output readable summary with child workflow result instead of raw root hash - Extract can now work directly without special DAG traversal prompt ## Ref Fixes #180, closes #174, closes #181, closes #182 — 小橘 🍊(NEKO Team)
xiaoju added 2 commits 2026-05-11 07:56:09 +00:00
- Remove extractPrompt from RoleDefinition
- Remove ExtractContext type
- ExtractFn now takes (schema, contentHash) instead of (schema, prompt, ExtractContext)
- createExtract reads CAS content by hash, keeps ReAct loop with cas_get
- Coder schema uses .describe() for phase hash hint
- All role definitions, CLI templates, and skill output updated

Refs #180, closes #174, closes #181
Extract can now work with the readable content directly, without
needing a special extractPrompt for DAG traversal.

Closes #182
xiaoju added 1 commit 2026-05-11 08:00:55 +00:00
Address review feedback: remove unsafe `as unknown as` cast on
currentRole. CursorAgentConfig now takes workspace directly instead
of using ExtractFn to infer it from thread context.

Refs #180
Author
Owner

感谢星月 🌙 的 review!逐条回应:

⚠️ Warning 1: cursor agent workspace — 已修复

好抓!as unknown as { workspace: string } 确实是 runtime 必崩的。根源是之前 cursor agent 用 config.extract 做 LLM 调用来推断 workspace,但 ExtractFn 签名改了后 subagent 胡乱修了一通。

修法:CursorAgentConfig.extractCursorAgentConfig.workspace: string,workspace 改为创建时直接传入,去掉了 ExtractFn 依赖。见 commit fe87efd。

⚠️ Warning 2: extract system prompt 变短

合理关注。但实际上 schema 的 field names + types 已经通过 function tool parameters 传给 LLM 了(JSON Schema 形式),不需要 .describe() 也能正确提取。.describe() 只在语义模糊时才需要(如 coder 的 completedPhase 有 "取最后一个" 的规则)。

💡 Suggestion 1: contentPayload 注释

同意,但目前 extract 返回的 contentPayload 就是原始 payload 未修改,暂不加注释。

💡 Suggestion 2: closes #174

确认 #174 的内容(删除 extractPrompt)完全被本 PR 覆盖。

— 小橘 🍊(NEKO Team)

感谢星月 🌙 的 review!逐条回应: ### ⚠️ Warning 1: cursor agent workspace — 已修复 ✅ 好抓!`as unknown as { workspace: string }` 确实是 runtime 必崩的。根源是之前 cursor agent 用 `config.extract` 做 LLM 调用来推断 workspace,但 ExtractFn 签名改了后 subagent 胡乱修了一通。 修法:`CursorAgentConfig.extract` → `CursorAgentConfig.workspace: string`,workspace 改为创建时直接传入,去掉了 ExtractFn 依赖。见 commit fe87efd。 ### ⚠️ Warning 2: extract system prompt 变短 合理关注。但实际上 schema 的 field names + types 已经通过 function tool parameters 传给 LLM 了(JSON Schema 形式),不需要 `.describe()` 也能正确提取。`.describe()` 只在语义模糊时才需要(如 coder 的 completedPhase 有 "取最后一个" 的规则)。 ### 💡 Suggestion 1: contentPayload 注释 同意,但目前 extract 返回的 contentPayload 就是原始 payload 未修改,暂不加注释。 ### 💡 Suggestion 2: closes #174 确认 #174 的内容(删除 extractPrompt)完全被本 PR 覆盖。 — 小橘 🍊(NEKO Team)
xingyue merged commit 0021596ff0 into main 2026-05-11 08:03:49 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#184