harnessed 4.9.0 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +40 -4
  2. package/bin/harnessed-inject-state.mjs +103 -2
  3. package/dist/cli.mjs +1717 -1418
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/index.mjs +1 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/workflows/auto/SKILL.md +26 -12
  9. package/workflows/auto/SKILL.zh-Hans.md +25 -12
  10. package/workflows/discuss/auto/SKILL.md +12 -8
  11. package/workflows/discuss/auto/SKILL.zh-Hans.md +11 -8
  12. package/workflows/discuss/phase/SKILL.md +12 -8
  13. package/workflows/discuss/phase/SKILL.zh-Hans.md +11 -8
  14. package/workflows/discuss/strategic/SKILL.md +12 -8
  15. package/workflows/discuss/strategic/SKILL.zh-Hans.md +11 -8
  16. package/workflows/discuss/subtask/SKILL.md +12 -8
  17. package/workflows/discuss/subtask/SKILL.zh-Hans.md +11 -8
  18. package/workflows/plan/architecture/SKILL.md +11 -8
  19. package/workflows/plan/architecture/SKILL.zh-Hans.md +10 -8
  20. package/workflows/plan/auto/SKILL.md +26 -11
  21. package/workflows/plan/auto/SKILL.zh-Hans.md +25 -11
  22. package/workflows/plan/phase/SKILL.md +11 -8
  23. package/workflows/plan/phase/SKILL.zh-Hans.md +10 -8
  24. package/workflows/research/SKILL.md +11 -37
  25. package/workflows/research/SKILL.zh-Hans.md +10 -37
  26. package/workflows/retro/SKILL.md +11 -8
  27. package/workflows/retro/SKILL.zh-Hans.md +10 -8
  28. package/workflows/role-prompts.yaml +34 -0
  29. package/workflows/role-prompts.zh-Hans.yaml +33 -0
  30. package/workflows/ship/auto/SKILL.md +29 -0
  31. package/workflows/ship/auto/SKILL.zh-Hans.md +28 -0
  32. package/workflows/ship/preflight/SKILL.md +17 -0
  33. package/workflows/ship/preflight/SKILL.zh-Hans.md +16 -0
  34. package/workflows/task/auto/SKILL.md +26 -11
  35. package/workflows/task/auto/SKILL.zh-Hans.md +27 -13
  36. package/workflows/task/clarify/SKILL.md +12 -8
  37. package/workflows/task/clarify/SKILL.zh-Hans.md +12 -9
  38. package/workflows/task/code/SKILL.md +11 -8
  39. package/workflows/task/code/SKILL.zh-Hans.md +11 -9
  40. package/workflows/task/deliver/SKILL.md +11 -8
  41. package/workflows/task/deliver/SKILL.zh-Hans.md +11 -9
  42. package/workflows/task/test/SKILL.md +11 -8
  43. package/workflows/task/test/SKILL.zh-Hans.md +11 -9
  44. package/workflows/verify/auto/SKILL.md +26 -11
  45. package/workflows/verify/auto/SKILL.zh-Hans.md +25 -11
  46. package/workflows/verify/code-review/SKILL.md +11 -8
  47. package/workflows/verify/code-review/SKILL.zh-Hans.md +10 -8
  48. package/workflows/verify/design/SKILL.md +11 -8
  49. package/workflows/verify/design/SKILL.zh-Hans.md +11 -9
  50. package/workflows/verify/multispec/SKILL.md +11 -8
  51. package/workflows/verify/multispec/SKILL.zh-Hans.md +11 -9
  52. package/workflows/verify/paranoid/SKILL.md +11 -8
  53. package/workflows/verify/paranoid/SKILL.zh-Hans.md +11 -9
  54. package/workflows/verify/progress/SKILL.md +11 -8
  55. package/workflows/verify/progress/SKILL.zh-Hans.md +11 -9
  56. package/workflows/verify/qa/SKILL.md +11 -8
  57. package/workflows/verify/qa/SKILL.zh-Hans.md +11 -9
  58. package/workflows/verify/security/SKILL.md +11 -8
  59. package/workflows/verify/security/SKILL.zh-Hans.md +11 -9
  60. package/workflows/verify/simplify/SKILL.md +11 -8
  61. package/workflows/verify/simplify/SKILL.zh-Hans.md +11 -9
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var package_default = {
3
- version: "4.9.0"};
3
+ version: "4.10.0"};
4
4
 
5
5
  // src/index.ts
6
6
  var VERSION = package_default.version;
@@ -1 +1 @@
1
- {"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EAEE,OAAA,EAAW,OAkGb,CAAA;;;AC/FO,IAAM,UAAU,eAAA,CAAI","file":"index.mjs","sourcesContent":["{\n \"name\": \"harnessed\",\n \"version\": \"4.9.0\",\n \"description\": \"AI coding harness package manager + composition orchestrator\",\n \"type\": \"module\",\n \"license\": \"Apache-2.0\",\n \"author\": \"easyinplay\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/easyinplay/harnessed.git\"\n },\n \"homepage\": \"https://github.com/easyinplay/harnessed#readme\",\n \"bugs\": \"https://github.com/easyinplay/harnessed/issues\",\n \"keywords\": [\n \"claude-code\",\n \"ai-harness\",\n \"package-manager\",\n \"composition\",\n \"skill-pack\",\n \"mcp\",\n \"orchestrator\"\n ],\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"packageManager\": \"pnpm@10.12.0\",\n \"bin\": {\n \"harnessed\": \"./dist/cli.mjs\",\n \"harnessed-inject-state\": \"./bin/harnessed-inject-state.mjs\"\n },\n \"main\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"default\": \"./dist/index.mjs\"\n },\n \"./schemas\": {\n \"types\": \"./dist/schemas/index.d.ts\",\n \"import\": \"./dist/schemas/index.mjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"manifests\",\n \"messages\",\n \"workflows\",\n \"routing\",\n \"config-templates\",\n \"schemas\",\n \"README.md\",\n \"LICENSE\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.md\"\n ],\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"build\": \"tsc --noEmit && tsup\",\n \"build:schema\": \"node ./scripts/build-schema.mjs\",\n \"validate:schema\": \"node ./scripts/validate-schema.mjs\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run --passWithNoTests\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage --passWithNoTests\",\n \"bench\": \"vitest bench --run\",\n \"lint\": \"biome check .\",\n \"lint:fix\": \"biome check --write .\",\n \"format\": \"biome format --write .\"\n },\n \"dependencies\": {\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.142\",\n \"@clack/prompts\": \"^0.10.1\",\n \"@sinclair/typebox\": \"^0.34.49\",\n \"ajv\": \"^8.20.0\",\n \"ajv-errors\": \"^3.0.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^13.0.0\",\n \"diff\": \"^9.0.0\",\n \"expr-eval\": \"^2.0.2\",\n \"picocolors\": \"^1.1.1\",\n \"proper-lockfile\": \"^4.1.2\",\n \"yaml\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.0.0\",\n \"@types/node\": \"^22.10.0\",\n \"@types/proper-lockfile\": \"^4.1.4\",\n \"@vitest/coverage-v8\": \"^4.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^4.0.0\"\n },\n \"pnpm\": {\n \"onlyBuiltDependencies\": [\n \"esbuild\"\n ]\n }\n}\n","// Main library entry — re-exports public APIs.\n// phase 1.1 batch 1: skeleton only; schema validator wired in batch 2 (T3+).\n\nimport pkg from '../package.json' with { type: 'json' }\n\nexport const VERSION = pkg.version\n"]}
1
+ {"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";AAAA,IAAA,eAAA,GAAA;AAAA,EAEE,OAAA,EAAW,QAkGb,CAAA;;;AC/FO,IAAM,UAAU,eAAA,CAAI","file":"index.mjs","sourcesContent":["{\n \"name\": \"harnessed\",\n \"version\": \"4.10.0\",\n \"description\": \"AI coding harness package manager + composition orchestrator\",\n \"type\": \"module\",\n \"license\": \"Apache-2.0\",\n \"author\": \"easyinplay\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/easyinplay/harnessed.git\"\n },\n \"homepage\": \"https://github.com/easyinplay/harnessed#readme\",\n \"bugs\": \"https://github.com/easyinplay/harnessed/issues\",\n \"keywords\": [\n \"claude-code\",\n \"ai-harness\",\n \"package-manager\",\n \"composition\",\n \"skill-pack\",\n \"mcp\",\n \"orchestrator\"\n ],\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"packageManager\": \"pnpm@10.12.0\",\n \"bin\": {\n \"harnessed\": \"./dist/cli.mjs\",\n \"harnessed-inject-state\": \"./bin/harnessed-inject-state.mjs\"\n },\n \"main\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"default\": \"./dist/index.mjs\"\n },\n \"./schemas\": {\n \"types\": \"./dist/schemas/index.d.ts\",\n \"import\": \"./dist/schemas/index.mjs\"\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\",\n \"bin\",\n \"manifests\",\n \"messages\",\n \"workflows\",\n \"routing\",\n \"config-templates\",\n \"schemas\",\n \"README.md\",\n \"LICENSE\",\n \"NOTICE\",\n \"THIRD-PARTY-NOTICES.md\"\n ],\n \"scripts\": {\n \"dev\": \"tsup --watch\",\n \"build\": \"tsc --noEmit && tsup\",\n \"build:schema\": \"node ./scripts/build-schema.mjs\",\n \"validate:schema\": \"node ./scripts/validate-schema.mjs\",\n \"typecheck\": \"tsc --noEmit\",\n \"test\": \"vitest run --passWithNoTests\",\n \"test:watch\": \"vitest\",\n \"test:coverage\": \"vitest run --coverage --passWithNoTests\",\n \"bench\": \"vitest bench --run\",\n \"lint\": \"biome check .\",\n \"lint:fix\": \"biome check --write .\",\n \"format\": \"biome format --write .\"\n },\n \"dependencies\": {\n \"@anthropic-ai/claude-agent-sdk\": \"0.3.142\",\n \"@clack/prompts\": \"^0.10.1\",\n \"@sinclair/typebox\": \"^0.34.49\",\n \"ajv\": \"^8.20.0\",\n \"ajv-errors\": \"^3.0.0\",\n \"ajv-formats\": \"^3.0.1\",\n \"commander\": \"^13.0.0\",\n \"diff\": \"^9.0.0\",\n \"expr-eval\": \"^2.0.2\",\n \"picocolors\": \"^1.1.1\",\n \"proper-lockfile\": \"^4.1.2\",\n \"yaml\": \"^2.9.0\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.0.0\",\n \"@types/node\": \"^22.10.0\",\n \"@types/proper-lockfile\": \"^4.1.4\",\n \"@vitest/coverage-v8\": \"^4.0.0\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.0\",\n \"vitest\": \"^4.0.0\"\n },\n \"pnpm\": {\n \"onlyBuiltDependencies\": [\n \"esbuild\"\n ]\n }\n}\n","// Main library entry — re-exports public APIs.\n// phase 1.1 batch 1: skeleton only; schema validator wired in batch 2 (T3+).\n\nimport pkg from '../package.json' with { type: 'json' }\n\nexport const VERSION = pkg.version\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harnessed",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "AI coding harness package manager + composition orchestrator",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -105,18 +105,32 @@ Sister `workflows/capabilities.yaml`:
105
105
 
106
106
  ## How to invoke
107
107
 
108
- Use the Bash tool to run:
109
-
110
- ```bash
111
- echo "$ARGUMENTS" | harnessed run auto --task-stdin
112
- ```
113
-
114
- If `$ARGUMENTS` is empty, run `harnessed run auto` (no stdin pipe).
115
-
116
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
117
- - For stage-by-stage review, append `--staged` (pauses between stages for user review).
118
-
119
- <!-- harnessed-generated:v3.4.4 -->
108
+ The numbered sequence below **is** the state machine — execute it step by step with Bash.
109
+ Do NOT improvise an equivalent flow from the Overview above: freelancing bypasses the engine
110
+ (no per-sub ledger, no evidence guard, no recovery). harnessed is the orchestration brain
111
+ (`harnessed gates` says which subs fire, `harnessed prompt` gives each spawn-ready prompt,
112
+ `harnessed checkpoint` records the ledger); YOU spawn with CC-native Task / Agent tools.
113
+
114
+ Do NOT pipe to `harnessed run auto` — that is the CI/headless path (in-process SDK spawn
115
+ that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).
116
+
117
+ 1. FIRST run the discuss stage interactively in THIS session (spawned subagents cannot ask the user questions). Evaluate strategic / phase / subtask clarification criteria for "$ARGUMENTS"; dialogue with the user (AskUserQuestion) for each layer that fires, lock decisions, transparent-skip the rest. Produce a locked spec.
118
+ 2. Bash: `harnessed gates auto --task "<locked spec>" --skip-sub clarify` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON.
119
+ 3. Bash: `harnessed checkpoint start auto --plan '<the verbatim gates JSON from step 2>'` → seeds the per-sub ledger so `harnessed status --recover` can re-orient you after compaction.
120
+ 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team (`TeamCreate` → `Agent(name, team_name, …)` per sub with its `harnessed prompt <sub>` prompt → coordinate via `SendMessage` → `SendMessage shutdown_request` + `TeamDelete`). Still checkpoint each sub (`complete` / `fail`) as below.
121
+ 5. Otherwise, for each fired sub in `order` (serial subs sequentially, parallel subs concurrently):
122
+ - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed gates <sub> --task "<spec>" --skip-sub clarify` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
123
+ - **Else (leaf sub):**
124
+ a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → parse `{prompt, max_iterations, model}`.
125
+ b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations).
126
+ c. If the output contains `STATUS: NEEDS_CLARIFICATION` + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
127
+ d. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it, or pass `--force` only to deliberately override.
128
+ e. If the sub cannot reach COMPLETE (max_iterations exhausted / unrecoverable error): Bash `harnessed checkpoint fail <sub> --summary "<why>"`, then STOP and report to the user.
129
+ 6. After all fired subs are `done` (or recorded `failed`), Bash `harnessed status --recover` to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user. Then run the `retro` stage to capture lessons.
130
+
131
+ **If you lose context (compaction / resume):** run `harnessed status --recover` first — it reads the ledger and prints "you are here, this is next" so you resume at the first `pending` sub instead of restarting. If the ledger is empty, re-run steps 2-3.
132
+
133
+ <!-- harnessed-generated:v4.9.3 -->
120
134
 
121
135
  ## References
122
136
 
@@ -104,18 +104,31 @@ Sister `workflows/capabilities.yaml`:
104
104
 
105
105
  ## 如何调用
106
106
 
107
- 使用 Bash 工具运行:
108
-
109
- ```bash
110
- echo "$ARGUMENTS" | harnessed run auto --task-stdin
111
- ```
112
-
113
- 如果 `$ARGUMENTS` 为空,运行 `harnessed run auto`(不带 stdin pipe)。
114
-
115
- 完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一个阶段。根据对话上下文决定是否调用 — 该提示仅供参考,不作强制指引。
116
- - 如需逐 stage 审查,追加 `--staged`(每个 stage 完成后暂停,等待用户 review)。
117
-
118
- <!-- harnessed-generated:v3.4.4 -->
107
+ 下面这套编号序列**就是** state machine —— 逐步用 Bash 执行。**不要**从上方 Overview 自行演绎一套
108
+ 等价流程:freestyle 会旁路引擎(无 per-sub ledger、无 evidence guard、无 recovery)。harnessed 是
109
+ 编排大脑(`harnessed gates` 决定哪些 sub fire,`harnessed prompt` 给出每个 spawn-ready prompt,
110
+ `harnessed checkpoint` 记录 ledger);**你**(主 session)用 CC-native Task / Agent 工具做 spawn。
111
+
112
+ **不要** pipe 到 `harnessed run auto` —— 那是 CI/headless 路径(in-process SDK spawn,会阻塞
113
+ session、绕过 Agent Teams,在 Claude Code 内部调用时会挂死)。
114
+
115
+ 1. 先在**本 session** 交互式跑 discuss 阶段(spawned subagent 无法向用户提问):对 "$ARGUMENTS" 评估 strategic / phase / subtask 澄清判据,对每个 fire 的层用 AskUserQuestion 与用户对话锁决策,其余透明 skip。产出 locked spec。
116
+ 2. Bash: `harnessed gates auto --task "<locked spec>" --skip-sub clarify` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。
117
+ 3. Bash: `harnessed checkpoint start auto --plan '<step 2 的 verbatim gates JSON>'` → seed per-sub ledger,让 `harnessed status --recover` 能在 compaction 后给你重新定位。
118
+ 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动(`TeamCreate` → 每个 sub `Agent(name, team_name, …)` + 其 `harnessed prompt <sub>` prompt → 用 `SendMessage` 协调 → `SendMessage shutdown_request` + `TeamDelete`)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
119
+ 5. 否则,对 `order` 里每个 fired sub(serial 串行、parallel 并发):
120
+ - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed gates <sub> --task "<spec>" --skip-sub clarify` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
121
+ - **否则(leaf sub):**
122
+ a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → 解析 `{prompt, max_iterations, model}`。
123
+ b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。
124
+ c. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn 同一 sub。
125
+ d. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它,或仅在刻意覆盖时传 `--force`。
126
+ e. 若 sub 无法达到 COMPLETE(max_iterations 耗尽 / 不可恢复错误):Bash `harnessed checkpoint fail <sub> --summary "<why>"`,然后 STOP 并向用户报告。
127
+ 6. 所有 fired subs `done`(或记录 `failed`)后,Bash `harnessed status --recover` 确认 ledger,并向用户报告 per-sub fired/skipped/done/failed 摘要。 然后跑 `retro` 阶段沉淀 lessons。
128
+
129
+ **若丢失上下文(compaction / resume):** 先跑 `harnessed status --recover` —— 它读 ledger 并打印「你在这里,下一步是什么」,让你从第一个 `pending` sub 续跑而非重启。若 ledger 为空,重跑 step 2-3。
130
+
131
+ <!-- harnessed-generated:v4.9.3 -->
119
132
 
120
133
  ## 参考文档
121
134
 
@@ -53,17 +53,21 @@ Sister `workflows/capabilities.yaml`:
53
53
 
54
54
  ## How to invoke
55
55
 
56
- Use the Bash tool to run:
56
+ Clarification needs real user dialogue, so run this stage directly in THIS session — do NOT
57
+ spawn it, and do NOT improvise: follow these steps so the locked spec is persisted for the
58
+ execution stages.
57
59
 
58
- ```bash
59
- echo "$ARGUMENTS" | harnessed run discuss --task-stdin
60
- ```
60
+ 1. Evaluate the clarification criteria for "$ARGUMENTS":
61
+ - **Strategic** — new feature / milestone / unclear business scope → gstack `/office-hours` + `/plan-ceo-review`
62
+ - **Phase** — ≥2 open implementation decisions / unclear cross-phase API contract → GSD `/gsd-discuss-phase`
63
+ - **Subtask** — ≥2 distinct approaches / core algorithm / API contract design / high error cost → superpowers brainstorming
64
+ 2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions) and lock every open decision.
65
+ 3. Transparent-skip layers that don't fire — state which were skipped and why.
66
+ 4. Persist the locked decisions to `.planning/` via planning-with-files (`findings.md` / `task_plan.md`).
61
67
 
62
- If `$ARGUMENTS` is empty, run `harnessed run discuss` (no stdin pipe).
68
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
63
69
 
64
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
65
-
66
- <!-- harnessed-generated:v3.4.4 -->
70
+ <!-- harnessed-generated:v4.9.3 -->
67
71
 
68
72
  ## References
69
73
 
@@ -53,17 +53,20 @@ Sister `workflows/capabilities.yaml`:
53
53
 
54
54
  ## 如何调用
55
55
 
56
- 使用 Bash 工具运行:
56
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
57
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
57
58
 
58
- ```bash
59
- echo "$ARGUMENTS" | harnessed run discuss --task-stdin
60
- ```
59
+ 1. 对 "$ARGUMENTS" 评估澄清判据:
60
+ - **战略层** —— 新功能 / 新 milestone / 商业 scope 不清 → gstack `/office-hours` + `/plan-ceo-review`
61
+ - **Phase 层** —— ≥2 个 open implementation decision / 跨 phase API contract 不清 → GSD `/gsd-discuss-phase`
62
+ - **子任务层** —— ≥2 个不同方案 / 核心算法 / API contract 设计 / 高错误成本 → superpowers brainstorming
63
+ 2. 对每个 fire 的层与用户对话(option 型决策用 AskUserQuestion),锁定每个 open decision。
64
+ 3. 不 fire 的层透明 skip —— 说明哪些被 skip 及原因。
65
+ 4. 把 locked 决策持久化到 `.planning/`(planning-with-files 的 `findings.md` / `task_plan.md`)。
61
66
 
62
- 若 `$ARGUMENTS` 为空,运行 `harnessed run discuss`(不带 stdin pipe)。
67
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
63
68
 
64
- 执行完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一个阶段。请根据对话上下文决定是否调用——该提示仅供参考,非强制指令。
65
-
66
- <!-- harnessed-generated:v3.4.4 -->
69
+ <!-- harnessed-generated:v4.9.3 -->
67
70
 
68
71
  ## 参考资料
69
72
 
@@ -53,17 +53,21 @@ Sister `workflows/judgments/phase-gate.yaml`:
53
53
 
54
54
  ## How to invoke
55
55
 
56
- Use the Bash tool to run:
56
+ Clarification needs real user dialogue, so run this stage directly in THIS session — do NOT
57
+ spawn it, and do NOT improvise: follow these steps so the locked spec is persisted for the
58
+ execution stages.
57
59
 
58
- ```bash
59
- echo "$ARGUMENTS" | harnessed run discuss-phase --task-stdin
60
- ```
60
+ 1. Evaluate the clarification criteria for "$ARGUMENTS":
61
+ - **Strategic** — new feature / milestone / unclear business scope → gstack `/office-hours` + `/plan-ceo-review`
62
+ - **Phase** — ≥2 open implementation decisions / unclear cross-phase API contract → GSD `/gsd-discuss-phase`
63
+ - **Subtask** — ≥2 distinct approaches / core algorithm / API contract design / high error cost → superpowers brainstorming
64
+ 2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions) and lock every open decision.
65
+ 3. Transparent-skip layers that don't fire — state which were skipped and why.
66
+ 4. Persist the locked decisions to `.planning/` via planning-with-files (`findings.md` / `task_plan.md`).
61
67
 
62
- If `$ARGUMENTS` is empty, run `harnessed run discuss-phase` (no stdin pipe).
68
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
63
69
 
64
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
65
-
66
- <!-- harnessed-generated:v3.4.4 -->
70
+ <!-- harnessed-generated:v4.9.3 -->
67
71
 
68
72
  ## References
69
73
 
@@ -53,17 +53,20 @@ Sister `workflows/judgments/phase-gate.yaml`:
53
53
 
54
54
  ## 如何调用
55
55
 
56
- 使用 Bash 工具运行:
56
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
57
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
57
58
 
58
- ```bash
59
- echo "$ARGUMENTS" | harnessed run discuss-phase --task-stdin
60
- ```
59
+ 1. 对 "$ARGUMENTS" 评估澄清判据:
60
+ - **战略层** —— 新功能 / 新 milestone / 商业 scope 不清 → gstack `/office-hours` + `/plan-ceo-review`
61
+ - **Phase 层** —— ≥2 个 open implementation decision / 跨 phase API contract 不清 → GSD `/gsd-discuss-phase`
62
+ - **子任务层** —— ≥2 个不同方案 / 核心算法 / API contract 设计 / 高错误成本 → superpowers brainstorming
63
+ 2. 对每个 fire 的层与用户对话(option 型决策用 AskUserQuestion),锁定每个 open decision。
64
+ 3. 不 fire 的层透明 skip —— 说明哪些被 skip 及原因。
65
+ 4. 把 locked 决策持久化到 `.planning/`(planning-with-files 的 `findings.md` / `task_plan.md`)。
61
66
 
62
- 若 `$ARGUMENTS` 为空,运行 `harnessed run discuss-phase`(不带 stdin pipe)。
67
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
63
68
 
64
- 执行完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一个阶段。请根据对话上下文决定是否调用——该提示仅供参考,非强制指令。
65
-
66
- <!-- harnessed-generated:v3.4.4 -->
69
+ <!-- harnessed-generated:v4.9.3 -->
67
70
 
68
71
  ## 参考资料
69
72
 
@@ -57,17 +57,21 @@ Sister `workflows/judgments/strategic-gate.yaml`:
57
57
 
58
58
  ## How to invoke
59
59
 
60
- Use the Bash tool to run:
60
+ Clarification needs real user dialogue, so run this stage directly in THIS session — do NOT
61
+ spawn it, and do NOT improvise: follow these steps so the locked spec is persisted for the
62
+ execution stages.
61
63
 
62
- ```bash
63
- echo "$ARGUMENTS" | harnessed run discuss-strategic --task-stdin
64
- ```
64
+ 1. Evaluate the clarification criteria for "$ARGUMENTS":
65
+ - **Strategic** — new feature / milestone / unclear business scope → gstack `/office-hours` + `/plan-ceo-review`
66
+ - **Phase** — ≥2 open implementation decisions / unclear cross-phase API contract → GSD `/gsd-discuss-phase`
67
+ - **Subtask** — ≥2 distinct approaches / core algorithm / API contract design / high error cost → superpowers brainstorming
68
+ 2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions) and lock every open decision.
69
+ 3. Transparent-skip layers that don't fire — state which were skipped and why.
70
+ 4. Persist the locked decisions to `.planning/` via planning-with-files (`findings.md` / `task_plan.md`).
65
71
 
66
- If `$ARGUMENTS` is empty, run `harnessed run discuss-strategic` (no stdin pipe).
72
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
67
73
 
68
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
69
-
70
- <!-- harnessed-generated:v3.4.4 -->
74
+ <!-- harnessed-generated:v4.9.3 -->
71
75
 
72
76
  ## References
73
77
 
@@ -57,17 +57,20 @@ Sister `workflows/judgments/strategic-gate.yaml`:
57
57
 
58
58
  ## 如何调用
59
59
 
60
- 使用 Bash 工具运行:
60
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
61
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
61
62
 
62
- ```bash
63
- echo "$ARGUMENTS" | harnessed run discuss-strategic --task-stdin
64
- ```
63
+ 1. 对 "$ARGUMENTS" 评估澄清判据:
64
+ - **战略层** —— 新功能 / 新 milestone / 商业 scope 不清 → gstack `/office-hours` + `/plan-ceo-review`
65
+ - **Phase 层** —— ≥2 个 open implementation decision / 跨 phase API contract 不清 → GSD `/gsd-discuss-phase`
66
+ - **子任务层** —— ≥2 个不同方案 / 核心算法 / API contract 设计 / 高错误成本 → superpowers brainstorming
67
+ 2. 对每个 fire 的层与用户对话(option 型决策用 AskUserQuestion),锁定每个 open decision。
68
+ 3. 不 fire 的层透明 skip —— 说明哪些被 skip 及原因。
69
+ 4. 把 locked 决策持久化到 `.planning/`(planning-with-files 的 `findings.md` / `task_plan.md`)。
65
70
 
66
- 若 `$ARGUMENTS` 为空,运行 `harnessed run discuss-strategic`(不带 stdin pipe)。
71
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
67
72
 
68
- 执行完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一个阶段。请根据对话上下文决定是否调用——该提示仅供参考,非强制指令。
69
-
70
- <!-- harnessed-generated:v3.4.4 -->
73
+ <!-- harnessed-generated:v4.9.3 -->
71
74
 
72
75
  ## 参考资料
73
76
 
@@ -58,17 +58,21 @@ Sister `workflows/judgments/subtask-gate.yaml`:
58
58
 
59
59
  ## How to invoke
60
60
 
61
- Use the Bash tool to run:
61
+ Clarification needs real user dialogue, so run this stage directly in THIS session — do NOT
62
+ spawn it, and do NOT improvise: follow these steps so the locked spec is persisted for the
63
+ execution stages.
62
64
 
63
- ```bash
64
- echo "$ARGUMENTS" | harnessed run discuss-subtask --task-stdin
65
- ```
65
+ 1. Evaluate the clarification criteria for "$ARGUMENTS":
66
+ - **Strategic** — new feature / milestone / unclear business scope → gstack `/office-hours` + `/plan-ceo-review`
67
+ - **Phase** — ≥2 open implementation decisions / unclear cross-phase API contract → GSD `/gsd-discuss-phase`
68
+ - **Subtask** — ≥2 distinct approaches / core algorithm / API contract design / high error cost → superpowers brainstorming
69
+ 2. For each layer that fires, hold the dialogue with the user (use AskUserQuestion for option-style decisions) and lock every open decision.
70
+ 3. Transparent-skip layers that don't fire — state which were skipped and why.
71
+ 4. Persist the locked decisions to `.planning/` via planning-with-files (`findings.md` / `task_plan.md`).
66
72
 
67
- If `$ARGUMENTS` is empty, run `harnessed run discuss-subtask` (no stdin pipe).
73
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
68
74
 
69
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
70
-
71
- <!-- harnessed-generated:v3.4.4 -->
75
+ <!-- harnessed-generated:v4.9.3 -->
72
76
 
73
77
  ## References
74
78
 
@@ -58,17 +58,20 @@ Sister `workflows/judgments/subtask-gate.yaml`:
58
58
 
59
59
  ## 如何调用
60
60
 
61
- 使用 Bash 工具运行:
61
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
62
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
62
63
 
63
- ```bash
64
- echo "$ARGUMENTS" | harnessed run discuss-subtask --task-stdin
65
- ```
64
+ 1. 对 "$ARGUMENTS" 评估澄清判据:
65
+ - **战略层** —— 新功能 / 新 milestone / 商业 scope 不清 → gstack `/office-hours` + `/plan-ceo-review`
66
+ - **Phase 层** —— ≥2 个 open implementation decision / 跨 phase API contract 不清 → GSD `/gsd-discuss-phase`
67
+ - **子任务层** —— ≥2 个不同方案 / 核心算法 / API contract 设计 / 高错误成本 → superpowers brainstorming
68
+ 2. 对每个 fire 的层与用户对话(option 型决策用 AskUserQuestion),锁定每个 open decision。
69
+ 3. 不 fire 的层透明 skip —— 说明哪些被 skip 及原因。
70
+ 4. 把 locked 决策持久化到 `.planning/`(planning-with-files 的 `findings.md` / `task_plan.md`)。
66
71
 
67
- 若 `$ARGUMENTS` 为空,运行 `harnessed run discuss-subtask`(不带 stdin pipe)。
72
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
68
73
 
69
- 执行完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一个阶段。请根据对话上下文决定是否调用——该提示仅供参考,非强制指令。
70
-
71
- <!-- harnessed-generated:v3.4.4 -->
74
+ <!-- harnessed-generated:v4.9.3 -->
72
75
 
73
76
  ## 参考资料
74
77
 
@@ -54,17 +54,20 @@ trigger `is-complex-architecture` 重构 ref。
54
54
 
55
55
  ## How to invoke
56
56
 
57
- Use the Bash tool to run:
57
+ The numbered sequence below **is** the state machine — execute it with Bash. Do NOT improvise
58
+ an equivalent flow from the Overview above: freelancing bypasses the engine (no ledger, no
59
+ evidence guard). harnessed gives you the spawn-ready prompt; YOU spawn the subagent with a
60
+ CC-native Task / Agent tool (keeps the session responsive + lets clarification round-trips reach the user).
58
61
 
59
- ```bash
60
- echo "$ARGUMENTS" | harnessed run plan-architecture --task-stdin
61
- ```
62
+ Do NOT pipe to `harnessed run plan-architecture` — that is the CI/headless path (in-process SDK spawn
63
+ that blocks the session inside Claude Code).
62
64
 
63
- If `$ARGUMENTS` is empty, run `harnessed run plan-architecture` (no stdin pipe).
65
+ 1. Bash: `harnessed prompt plan-architecture --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
66
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations).
67
+ 3. If the output contains `STATUS: NEEDS_CLARIFICATION` + a question list: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
68
+ 4. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete plan-architecture --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it before treating the sub as done.
64
69
 
65
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
66
-
67
- <!-- harnessed-generated:v3.4.4 -->
70
+ <!-- harnessed-generated:v4.9.3 -->
68
71
 
69
72
  ## References
70
73
 
@@ -54,17 +54,19 @@ trigger `is-complex-architecture` 重构 ref。
54
54
 
55
55
  ## 如何调用
56
56
 
57
- 使用 Bash 工具运行:
57
+ 下面这套编号序列**就是** state machine —— 用 Bash 执行。**不要**从上方 Overview 自行演绎等价流程:
58
+ freestyle 会旁路引擎(无 ledger、无 evidence guard)。harnessed 给你 spawn-ready prompt;**你**用
59
+ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 round-trip 能回到用户)。
58
60
 
59
- ```bash
60
- echo "$ARGUMENTS" | harnessed run plan-architecture --task-stdin
61
- ```
61
+ **不要** pipe 到 `harnessed run plan-architecture` —— 那是 CI/headless 路径(in-process SDK spawn,在 Claude
62
+ Code 内部会阻塞 session)。
62
63
 
63
- 若 `$ARGUMENTS` 为空,运行 `harnessed run plan-architecture`(不带 stdin pipe)。
64
+ 1. Bash: `harnessed prompt plan-architecture --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
65
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,自循环:spawn → 检查 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。
66
+ 3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
67
+ 4. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete plan-architecture --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它再算 done。
64
68
 
65
- 完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一阶段。是否调用由对话上下文决定——该提示仅供参考,非强制指令。
66
-
67
- <!-- harnessed-generated:v3.4.4 -->
69
+ <!-- harnessed-generated:v4.9.3 -->
68
70
 
69
71
  ## 参考文档
70
72
 
@@ -54,17 +54,32 @@ Sister `workflows/capabilities.yaml`:
54
54
 
55
55
  ## How to invoke
56
56
 
57
- Use the Bash tool to run:
58
-
59
- ```bash
60
- echo "$ARGUMENTS" | harnessed run plan --task-stdin
61
- ```
62
-
63
- If `$ARGUMENTS` is empty, run `harnessed run plan` (no stdin pipe).
64
-
65
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
66
-
67
- <!-- harnessed-generated:v3.4.4 -->
57
+ The numbered sequence below **is** the state machine — execute it step by step with Bash.
58
+ Do NOT improvise an equivalent flow from the Overview above: freelancing bypasses the engine
59
+ (no per-sub ledger, no evidence guard, no recovery). harnessed is the orchestration brain
60
+ (`harnessed gates` says which subs fire, `harnessed prompt` gives each spawn-ready prompt,
61
+ `harnessed checkpoint` records the ledger); YOU spawn with CC-native Task / Agent tools.
62
+
63
+ Do NOT pipe to `harnessed run plan` — that is the CI/headless path (in-process SDK spawn
64
+ that blocks the session, bypasses Agent Teams, and hangs inside Claude Code).
65
+
66
+ 1. If the clarification criteria fire for "$ARGUMENTS" (≥2 approaches / core algorithm / API contract / high error cost), clarify interactively in THIS session first (AskUserQuestion) and lock decisions; otherwise transparent-skip. Produce a locked spec.
67
+ 2. Bash: `harnessed gates plan --task "<locked spec>" --skip-sub clarify` → parse the JSON `{fire, skip, parallelism}`. This is the plan SoT (no spawn). Keep the verbatim JSON.
68
+ 3. Bash: `harnessed checkpoint start plan --plan '<the verbatim gates JSON from step 2>'` → seeds the per-sub ledger so `harnessed status --recover` can re-orient you after compaction.
69
+ 4. If `parallelism.escalate_to_teams === true`: read `~/.claude/rules/agent-teams.md`, then drive the fired subs as an Agent Team (`TeamCreate` → `Agent(name, team_name, …)` per sub with its `harnessed prompt <sub>` prompt → coordinate via `SendMessage` → `SendMessage shutdown_request` + `TeamDelete`). Still checkpoint each sub (`complete` / `fail`) as below.
70
+ 5. Otherwise, for each fired sub in `order` (serial subs sequentially, parallel subs concurrently):
71
+ - **If the entry has `is_master: true`** (a stage master — e.g. `/auto` firing `plan`/`task`/`verify`): do NOT prompt+spawn it. RECURSE: run that master’s own `harnessed gates <sub> --task "<spec>" --skip-sub clarify` → `harnessed checkpoint start <sub> --plan '<json>'` → repeat this loop for ITS fired subs.
72
+ - **Else (leaf sub):**
73
+ a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → parse `{prompt, max_iterations, model}`.
74
+ b. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations).
75
+ c. If the output contains `STATUS: NEEDS_CLARIFICATION` + questions: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
76
+ d. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it, or pass `--force` only to deliberately override.
77
+ e. If the sub cannot reach COMPLETE (max_iterations exhausted / unrecoverable error): Bash `harnessed checkpoint fail <sub> --summary "<why>"`, then STOP and report to the user.
78
+ 6. After all fired subs are `done` (or recorded `failed`), Bash `harnessed status --recover` to confirm the ledger and report a per-sub fired/skipped/done/failed summary to the user.
79
+
80
+ **If you lose context (compaction / resume):** run `harnessed status --recover` first — it reads the ledger and prints "you are here, this is next" so you resume at the first `pending` sub instead of restarting. If the ledger is empty, re-run steps 2-3.
81
+
82
+ <!-- harnessed-generated:v4.9.3 -->
68
83
 
69
84
  ## References
70
85
 
@@ -54,17 +54,31 @@ Sister `workflows/capabilities.yaml`:
54
54
 
55
55
  ## 如何调用
56
56
 
57
- 使用 Bash 工具运行:
58
-
59
- ```bash
60
- echo "$ARGUMENTS" | harnessed run plan --task-stdin
61
- ```
62
-
63
- 若 `$ARGUMENTS` 为空,运行 `harnessed run plan`(不带 stdin pipe)。
64
-
65
- 完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一阶段。是否调用由对话上下文决定——该提示仅供参考,非强制指令。
66
-
67
- <!-- harnessed-generated:v3.4.4 -->
57
+ 下面这套编号序列**就是** state machine —— 逐步用 Bash 执行。**不要**从上方 Overview 自行演绎一套
58
+ 等价流程:freestyle 会旁路引擎(无 per-sub ledger、无 evidence guard、无 recovery)。harnessed 是
59
+ 编排大脑(`harnessed gates` 决定哪些 sub fire,`harnessed prompt` 给出每个 spawn-ready prompt,
60
+ `harnessed checkpoint` 记录 ledger);**你**(主 session)用 CC-native Task / Agent 工具做 spawn。
61
+
62
+ **不要** pipe 到 `harnessed run plan` —— 那是 CI/headless 路径(in-process SDK spawn,会阻塞
63
+ session、绕过 Agent Teams,在 Claude Code 内部调用时会挂死)。
64
+
65
+ 1. 若 "$ARGUMENTS" 触发澄清判据(≥2 方案 / 核心算法 / API contract / 高错误成本),先在**本 session** 交互澄清(AskUserQuestion)并锁决策;否则透明 skip。产出 locked spec。
66
+ 2. Bash: `harnessed gates plan --task "<locked spec>" --skip-sub clarify` → 解析 JSON `{fire, skip, parallelism}`。这是 plan SoT(不 spawn)。保留 verbatim JSON。
67
+ 3. Bash: `harnessed checkpoint start plan --plan '<step 2 的 verbatim gates JSON>'` → seed per-sub ledger,让 `harnessed status --recover` 能在 compaction 后给你重新定位。
68
+ 4. 若 `parallelism.escalate_to_teams === true`:读 `~/.claude/rules/agent-teams.md`,然后把 fired subs 作为 Agent Team 驱动(`TeamCreate` → 每个 sub `Agent(name, team_name, …)` + 其 `harnessed prompt <sub>` prompt → 用 `SendMessage` 协调 → `SendMessage shutdown_request` + `TeamDelete`)。每个 sub 仍按下方 checkpoint(`complete` / `fail`)。
69
+ 5. 否则,对 `order` 里每个 fired sub(serial 串行、parallel 并发):
70
+ - **若该项 `is_master: true`**(本身是 stage master —— 如 `/auto` fire `plan`/`task`/`verify`):**不要**直接 prompt+spawn。RECURSE:跑该 master 自己的 `harnessed gates <sub> --task "<spec>" --skip-sub clarify` → `harnessed checkpoint start <sub> --plan '<json>'` → 对它的 fired subs 重复本循环。
71
+ - **否则(leaf sub):**
72
+ a. Bash: `harnessed prompt <sub> --task "<spec>" --json` → 解析 `{prompt, max_iterations, model}`。
73
+ b. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,自循环:spawn → 检查输出 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。
74
+ c. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn 同一 sub。
75
+ d. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete <sub> --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它,或仅在刻意覆盖时传 `--force`。
76
+ e. 若 sub 无法达到 COMPLETE(max_iterations 耗尽 / 不可恢复错误):Bash `harnessed checkpoint fail <sub> --summary "<why>"`,然后 STOP 并向用户报告。
77
+ 6. 所有 fired subs `done`(或记录 `failed`)后,Bash `harnessed status --recover` 确认 ledger,并向用户报告 per-sub fired/skipped/done/failed 摘要。
78
+
79
+ **若丢失上下文(compaction / resume):** 先跑 `harnessed status --recover` —— 它读 ledger 并打印「你在这里,下一步是什么」,让你从第一个 `pending` sub 续跑而非重启。若 ledger 为空,重跑 step 2-3。
80
+
81
+ <!-- harnessed-generated:v4.9.3 -->
68
82
 
69
83
  ## 参考文档
70
84
 
@@ -56,17 +56,20 @@ reframe)。
56
56
 
57
57
  ## How to invoke
58
58
 
59
- Use the Bash tool to run:
59
+ The numbered sequence below **is** the state machine — execute it with Bash. Do NOT improvise
60
+ an equivalent flow from the Overview above: freelancing bypasses the engine (no ledger, no
61
+ evidence guard). harnessed gives you the spawn-ready prompt; YOU spawn the subagent with a
62
+ CC-native Task / Agent tool (keeps the session responsive + lets clarification round-trips reach the user).
60
63
 
61
- ```bash
62
- echo "$ARGUMENTS" | harnessed run plan-phase --task-stdin
63
- ```
64
+ Do NOT pipe to `harnessed run plan-phase` — that is the CI/headless path (in-process SDK spawn
65
+ that blocks the session inside Claude Code).
64
66
 
65
- If `$ARGUMENTS` is empty, run `harnessed run plan-phase` (no stdin pipe).
67
+ 1. Bash: `harnessed prompt plan-phase --task "$ARGUMENTS" --json` → parse `{prompt, max_iterations, model}`.
68
+ 2. Spawn a CC-native subagent (Task / Agent tool) with that `prompt` + `model`, wrapped in the ralph-loop plugin: `/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`. If the plugin is absent, self-loop: spawn → check output for `<promise>COMPLETE</promise>` → re-spawn with prior output appended (up to max_iterations).
69
+ 3. If the output contains `STATUS: NEEDS_CLARIFICATION` + a question list: STOP, relay them verbatim via AskUserQuestion, append the answers to the spec, then re-spawn the same sub.
70
+ 4. On `<promise>COMPLETE</promise>`: Bash `harnessed checkpoint complete plan-phase --summary "<one-line>"`. The evidence guard runs here (fail-CLOSED): if a declared `artifacts_expected` file is missing it exits non-zero — re-spawn to produce it before treating the sub as done.
66
71
 
67
- After completion, the Bash output prints a `Next:` hint on stderr suggesting the next stage. Decide whether to invoke based on conversation context — the hint is informational, not prescriptive.
68
-
69
- <!-- harnessed-generated:v3.4.4 -->
72
+ <!-- harnessed-generated:v4.9.3 -->
70
73
 
71
74
  ## References
72
75
 
@@ -56,17 +56,19 @@ reframe)。
56
56
 
57
57
  ## 如何调用
58
58
 
59
- 使用 Bash 工具运行:
59
+ 下面这套编号序列**就是** state machine —— 用 Bash 执行。**不要**从上方 Overview 自行演绎等价流程:
60
+ freestyle 会旁路引擎(无 ledger、无 evidence guard)。harnessed 给你 spawn-ready prompt;**你**用
61
+ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 round-trip 能回到用户)。
60
62
 
61
- ```bash
62
- echo "$ARGUMENTS" | harnessed run plan-phase --task-stdin
63
- ```
63
+ **不要** pipe 到 `harnessed run plan-phase` —— 那是 CI/headless 路径(in-process SDK spawn,在 Claude
64
+ Code 内部会阻塞 session)。
64
65
 
65
- 若 `$ARGUMENTS` 为空,运行 `harnessed run plan-phase`(不带 stdin pipe)。
66
+ 1. Bash: `harnessed prompt plan-phase --task "$ARGUMENTS" --json` → 解析 `{prompt, max_iterations, model}`。
67
+ 2. 用 CC-native subagent(Task / Agent 工具)以该 `prompt` + `model` spawn,用 ralph-loop plugin 包裹:`/ralph-loop "<prompt>" --max-iterations <max_iterations> --completion-promise "COMPLETE"`。若 plugin 未装,自循环:spawn → 检查 `<promise>COMPLETE</promise>` → 把上轮输出 append 后重 spawn(至多 max_iterations)。
68
+ 3. 若输出含 `STATUS: NEEDS_CLARIFICATION` + 问题列表:STOP,用 AskUserQuestion 原样转达,把答案 append 进 spec,再重 spawn。
69
+ 4. 命中 `<promise>COMPLETE</promise>`:Bash `harnessed checkpoint complete plan-phase --summary "<one-line>"`。evidence guard 在此运行(fail-CLOSED):若声明的 `artifacts_expected` 文件缺失会 exit 非零 —— 重 spawn 产出它再算 done。
66
70
 
67
- 完成后,Bash 输出会在 stderr 打印 `Next:` 提示,建议下一阶段。是否调用由对话上下文决定——该提示仅供参考,非强制指令。
68
-
69
- <!-- harnessed-generated:v3.4.4 -->
71
+ <!-- harnessed-generated:v4.9.3 -->
70
72
 
71
73
  ## 参考文档
72
74