harnessed 4.9.1 → 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 +1668 -1400
  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 -10
  10. package/workflows/discuss/auto/SKILL.md +15 -12
  11. package/workflows/discuss/auto/SKILL.zh-Hans.md +12 -8
  12. package/workflows/discuss/phase/SKILL.md +15 -12
  13. package/workflows/discuss/phase/SKILL.zh-Hans.md +12 -8
  14. package/workflows/discuss/strategic/SKILL.md +15 -12
  15. package/workflows/discuss/strategic/SKILL.zh-Hans.md +12 -8
  16. package/workflows/discuss/subtask/SKILL.md +15 -12
  17. package/workflows/discuss/subtask/SKILL.zh-Hans.md +12 -8
  18. package/workflows/plan/architecture/SKILL.md +14 -12
  19. package/workflows/plan/architecture/SKILL.zh-Hans.md +11 -8
  20. package/workflows/plan/auto/SKILL.md +26 -12
  21. package/workflows/plan/auto/SKILL.zh-Hans.md +25 -10
  22. package/workflows/plan/phase/SKILL.md +14 -12
  23. package/workflows/plan/phase/SKILL.zh-Hans.md +11 -8
  24. package/workflows/research/SKILL.md +14 -12
  25. package/workflows/research/SKILL.zh-Hans.md +11 -8
  26. package/workflows/retro/SKILL.md +14 -12
  27. package/workflows/retro/SKILL.zh-Hans.md +11 -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 -12
  35. package/workflows/task/auto/SKILL.zh-Hans.md +25 -10
  36. package/workflows/task/clarify/SKILL.md +15 -12
  37. package/workflows/task/clarify/SKILL.zh-Hans.md +12 -8
  38. package/workflows/task/code/SKILL.md +14 -12
  39. package/workflows/task/code/SKILL.zh-Hans.md +11 -8
  40. package/workflows/task/deliver/SKILL.md +14 -12
  41. package/workflows/task/deliver/SKILL.zh-Hans.md +11 -8
  42. package/workflows/task/test/SKILL.md +14 -12
  43. package/workflows/task/test/SKILL.zh-Hans.md +11 -8
  44. package/workflows/verify/auto/SKILL.md +26 -12
  45. package/workflows/verify/auto/SKILL.zh-Hans.md +25 -10
  46. package/workflows/verify/code-review/SKILL.md +14 -12
  47. package/workflows/verify/code-review/SKILL.zh-Hans.md +11 -8
  48. package/workflows/verify/design/SKILL.md +14 -12
  49. package/workflows/verify/design/SKILL.zh-Hans.md +11 -8
  50. package/workflows/verify/multispec/SKILL.md +14 -12
  51. package/workflows/verify/multispec/SKILL.zh-Hans.md +11 -8
  52. package/workflows/verify/paranoid/SKILL.md +14 -12
  53. package/workflows/verify/paranoid/SKILL.zh-Hans.md +11 -8
  54. package/workflows/verify/progress/SKILL.md +14 -12
  55. package/workflows/verify/progress/SKILL.zh-Hans.md +11 -8
  56. package/workflows/verify/qa/SKILL.md +14 -12
  57. package/workflows/verify/qa/SKILL.zh-Hans.md +11 -8
  58. package/workflows/verify/security/SKILL.md +14 -12
  59. package/workflows/verify/security/SKILL.zh-Hans.md +11 -8
  60. package/workflows/verify/simplify/SKILL.md +14 -12
  61. package/workflows/verify/simplify/SKILL.zh-Hans.md +11 -8
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var package_default = {
3
- version: "4.9.1"};
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.1\",\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.1",
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
- Orchestrated CC-natively. Do NOT pipe to `harnessed run auto` — that is the CI/headless
109
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
110
- invoked from inside a Claude Code session).
111
-
112
- Run the `/auto` slash command instead (generated by `harnessed setup` at
113
- `~/.claude/commands/auto.md`). It drives the stage natively: `harnessed gates` → which
114
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
115
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
116
- full state-machine steps live in `~/.claude/commands/auto.md`; if that file is absent,
117
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
118
-
119
- <!-- harnessed-generated:v4.9.1 -->
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,16 +104,31 @@ Sister `workflows/capabilities.yaml`:
104
104
 
105
105
  ## 如何调用
106
106
 
107
- CC-native 编排。**不要** pipe 到 `harnessed run auto` —— 那是 CI/headless 路径(in-process
108
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
109
-
110
- 改用 `/auto` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/auto.md`)。
111
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
112
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
113
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/auto.md`;
114
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
115
-
116
- <!-- harnessed-generated:v4.9.1 -->
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 -->
117
132
 
118
133
  ## 参考文档
119
134
 
@@ -53,18 +53,21 @@ Sister `workflows/capabilities.yaml`:
53
53
 
54
54
  ## How to invoke
55
55
 
56
- Orchestrated CC-natively. Do NOT pipe to `harnessed run discuss` — that is the CI/headless
57
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
58
- invoked from inside a Claude Code session).
59
-
60
- Run the `/discuss` slash command instead (generated by `harnessed setup` at
61
- `~/.claude/commands/discuss.md`). It drives the stage natively: `harnessed gates` → which
62
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
63
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
64
- full state-machine steps live in `~/.claude/commands/discuss.md`; if that file is absent,
65
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
66
-
67
- <!-- harnessed-generated:v4.9.1 -->
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.
59
+
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`).
67
+
68
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
69
+
70
+ <!-- harnessed-generated:v4.9.3 -->
68
71
 
69
72
  ## References
70
73
 
@@ -53,16 +53,20 @@ Sister `workflows/capabilities.yaml`:
53
53
 
54
54
  ## 如何调用
55
55
 
56
- CC-native 编排。**不要** pipe 到 `harnessed run discuss` —— 那是 CI/headless 路径(in-process
57
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
56
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
57
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
58
58
 
59
- 改用 `/discuss` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/discuss.md`)。
60
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
61
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
62
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/discuss.md`;
63
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
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`)。
64
66
 
65
- <!-- harnessed-generated:v4.9.1 -->
67
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
68
+
69
+ <!-- harnessed-generated:v4.9.3 -->
66
70
 
67
71
  ## 参考资料
68
72
 
@@ -53,18 +53,21 @@ Sister `workflows/judgments/phase-gate.yaml`:
53
53
 
54
54
  ## How to invoke
55
55
 
56
- Orchestrated CC-natively. Do NOT pipe to `harnessed run discuss-phase` — that is the CI/headless
57
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
58
- invoked from inside a Claude Code session).
59
-
60
- Run the `/discuss-phase` slash command instead (generated by `harnessed setup` at
61
- `~/.claude/commands/discuss-phase.md`). It drives the stage natively: `harnessed gates` → which
62
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
63
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
64
- full state-machine steps live in `~/.claude/commands/discuss-phase.md`; if that file is absent,
65
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
66
-
67
- <!-- harnessed-generated:v4.9.1 -->
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.
59
+
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`).
67
+
68
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
69
+
70
+ <!-- harnessed-generated:v4.9.3 -->
68
71
 
69
72
  ## References
70
73
 
@@ -53,16 +53,20 @@ Sister `workflows/judgments/phase-gate.yaml`:
53
53
 
54
54
  ## 如何调用
55
55
 
56
- CC-native 编排。**不要** pipe 到 `harnessed run discuss-phase` —— 那是 CI/headless 路径(in-process
57
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
56
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
57
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
58
58
 
59
- 改用 `/discuss-phase` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/discuss-phase.md`)。
60
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
61
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
62
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/discuss-phase.md`;
63
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
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`)。
64
66
 
65
- <!-- harnessed-generated:v4.9.1 -->
67
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
68
+
69
+ <!-- harnessed-generated:v4.9.3 -->
66
70
 
67
71
  ## 参考资料
68
72
 
@@ -57,18 +57,21 @@ Sister `workflows/judgments/strategic-gate.yaml`:
57
57
 
58
58
  ## How to invoke
59
59
 
60
- Orchestrated CC-natively. Do NOT pipe to `harnessed run discuss-strategic` — that is the CI/headless
61
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
62
- invoked from inside a Claude Code session).
63
-
64
- Run the `/discuss-strategic` slash command instead (generated by `harnessed setup` at
65
- `~/.claude/commands/discuss-strategic.md`). It drives the stage natively: `harnessed gates` → which
66
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
67
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
68
- full state-machine steps live in `~/.claude/commands/discuss-strategic.md`; if that file is absent,
69
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
70
-
71
- <!-- harnessed-generated:v4.9.1 -->
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.
63
+
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`).
71
+
72
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
73
+
74
+ <!-- harnessed-generated:v4.9.3 -->
72
75
 
73
76
  ## References
74
77
 
@@ -57,16 +57,20 @@ Sister `workflows/judgments/strategic-gate.yaml`:
57
57
 
58
58
  ## 如何调用
59
59
 
60
- CC-native 编排。**不要** pipe 到 `harnessed run discuss-strategic` —— 那是 CI/headless 路径(in-process
61
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
60
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
61
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
62
62
 
63
- 改用 `/discuss-strategic` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/discuss-strategic.md`)。
64
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
65
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
66
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/discuss-strategic.md`;
67
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
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`)。
68
70
 
69
- <!-- harnessed-generated:v4.9.1 -->
71
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
72
+
73
+ <!-- harnessed-generated:v4.9.3 -->
70
74
 
71
75
  ## 参考资料
72
76
 
@@ -58,18 +58,21 @@ Sister `workflows/judgments/subtask-gate.yaml`:
58
58
 
59
59
  ## How to invoke
60
60
 
61
- Orchestrated CC-natively. Do NOT pipe to `harnessed run discuss-subtask` — that is the CI/headless
62
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
63
- invoked from inside a Claude Code session).
64
-
65
- Run the `/discuss-subtask` slash command instead (generated by `harnessed setup` at
66
- `~/.claude/commands/discuss-subtask.md`). It drives the stage natively: `harnessed gates` → which
67
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
68
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
69
- full state-machine steps live in `~/.claude/commands/discuss-subtask.md`; if that file is absent,
70
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
71
-
72
- <!-- harnessed-generated:v4.9.1 -->
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.
64
+
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`).
72
+
73
+ Output: a locked spec the execution stages (`/plan` → `/task` → `/verify`) consume without further user input.
74
+
75
+ <!-- harnessed-generated:v4.9.3 -->
73
76
 
74
77
  ## References
75
78
 
@@ -58,16 +58,20 @@ Sister `workflows/judgments/subtask-gate.yaml`:
58
58
 
59
59
  ## 如何调用
60
60
 
61
- CC-native 编排。**不要** pipe 到 `harnessed run discuss-subtask` —— 那是 CI/headless 路径(in-process
62
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
61
+ 澄清需要真实用户对话,所以本阶段直接在**本 session** 跑 —— **不要** spawn,也**不要**自行演绎:
62
+ 按以下步骤走,把 locked spec 持久化给执行阶段。
63
63
 
64
- 改用 `/discuss-subtask` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/discuss-subtask.md`)。
65
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
66
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
67
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/discuss-subtask.md`;
68
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
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`)。
69
71
 
70
- <!-- harnessed-generated:v4.9.1 -->
72
+ 产出:一份 locked spec,执行阶段(`/plan` → `/task` → `/verify`)无需再问用户即可消费。
73
+
74
+ <!-- harnessed-generated:v4.9.3 -->
71
75
 
72
76
  ## 参考资料
73
77
 
@@ -54,18 +54,20 @@ trigger `is-complex-architecture` 重构 ref。
54
54
 
55
55
  ## How to invoke
56
56
 
57
- Orchestrated CC-natively. Do NOT pipe to `harnessed run plan-architecture` — that is the CI/headless
58
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
59
- invoked from inside a Claude Code session).
60
-
61
- Run the `/plan-architecture` slash command instead (generated by `harnessed setup` at
62
- `~/.claude/commands/plan-architecture.md`). It drives the stage natively: `harnessed gates` → which
63
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
64
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
65
- full state-machine steps live in `~/.claude/commands/plan-architecture.md`; if that file is absent,
66
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
67
-
68
- <!-- harnessed-generated:v4.9.1 -->
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).
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).
64
+
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.
69
+
70
+ <!-- harnessed-generated:v4.9.3 -->
69
71
 
70
72
  ## References
71
73
 
@@ -54,16 +54,19 @@ trigger `is-complex-architecture` 重构 ref。
54
54
 
55
55
  ## 如何调用
56
56
 
57
- CC-native 编排。**不要** pipe 到 `harnessed run plan-architecture` —— 那是 CI/headless 路径(in-process
58
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
57
+ 下面这套编号序列**就是** state machine —— 用 Bash 执行。**不要**从上方 Overview 自行演绎等价流程:
58
+ freestyle 会旁路引擎(无 ledger、无 evidence guard)。harnessed 给你 spawn-ready prompt;**你**用
59
+ CC-native Task / Agent 工具 spawn subagent(保持 session 响应 + 让澄清 round-trip 能回到用户)。
59
60
 
60
- 改用 `/plan-architecture` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/plan-architecture.md`)。
61
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
62
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
63
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/plan-architecture.md`;
64
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
61
+ **不要** pipe 到 `harnessed run plan-architecture` —— 那是 CI/headless 路径(in-process SDK spawn,在 Claude
62
+ Code 内部会阻塞 session)。
65
63
 
66
- <!-- harnessed-generated:v4.9.1 -->
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。
68
+
69
+ <!-- harnessed-generated:v4.9.3 -->
67
70
 
68
71
  ## 参考文档
69
72
 
@@ -54,18 +54,32 @@ Sister `workflows/capabilities.yaml`:
54
54
 
55
55
  ## How to invoke
56
56
 
57
- Orchestrated CC-natively. Do NOT pipe to `harnessed run plan` — that is the CI/headless
58
- path (an in-process SDK spawn that blocks the session, bypasses Agent Teams, and hangs when
59
- invoked from inside a Claude Code session).
60
-
61
- Run the `/plan` slash command instead (generated by `harnessed setup` at
62
- `~/.claude/commands/plan.md`). It drives the stage natively: `harnessed gates` → which
63
- subs fire, `harnessed prompt <sub>` → each spawn-ready prompt, then a CC-native subagent
64
- (Task / Agent tool) per fired sub, recording each outcome with `harnessed checkpoint`. The
65
- full state-machine steps live in `~/.claude/commands/plan.md`; if that file is absent,
66
- follow that same gates → prompt → spawn → checkpoint sequence yourself.
67
-
68
- <!-- harnessed-generated:v4.9.1 -->
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 -->
69
83
 
70
84
  ## References
71
85
 
@@ -54,16 +54,31 @@ Sister `workflows/capabilities.yaml`:
54
54
 
55
55
  ## 如何调用
56
56
 
57
- CC-native 编排。**不要** pipe 到 `harnessed run plan` —— 那是 CI/headless 路径(in-process
58
- SDK spawn,会阻塞 session、绕过 Agent Teams,在 Claude Code 内部调用时还会挂死)。
59
-
60
- 改用 `/plan` slash command(由 `harnessed setup` 生成于 `~/.claude/commands/plan.md`)。
61
- 它以 CC-native 方式驱动:`harnessed gates` 决定哪些 sub fire,`harnessed prompt <sub>` 给出每个
62
- spawn-ready prompt,然后用 CC-native subagent(Task / Agent 工具)逐个 spawn 已 fire 的 sub,
63
- 每个结果用 `harnessed checkpoint` 记录。完整 state-machine 步骤见 `~/.claude/commands/plan.md`;
64
- 若该文件不存在,自行按 gates → prompt → spawn → checkpoint 同序执行。
65
-
66
- <!-- harnessed-generated:v4.9.1 -->
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 -->
67
82
 
68
83
  ## 参考文档
69
84