@tea-agent/loop-agent 0.2.0 → 0.2.1

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 (58) hide show
  1. package/AGENTS.md +62 -45
  2. package/CHANGELOG.md +59 -43
  3. package/README.md +180 -179
  4. package/bin/loop-agent.js +21 -21
  5. package/dist/application/dag/generate-task-dag.js +3 -3
  6. package/dist/application/dag/run-dag.js +14 -1
  7. package/dist/application/dag/validate-dag.js +1 -0
  8. package/dist/commands/init.js +482 -459
  9. package/dist/workflows/dag/failure-routing.js +82 -0
  10. package/dist/workflows/dag/lifecycle.js +95 -3
  11. package/dist/workflows/dag/report.js +73 -1
  12. package/docs/README.md +47 -45
  13. package/docs/agent-dag-recovery-playbook.md +32 -6
  14. package/docs/agent-dag-runner.md +17 -17
  15. package/docs/architecture/runtime-boundaries.md +1 -1
  16. package/docs/cursor-executor-usage.md +5 -5
  17. package/docs/decisions/README.md +2 -2
  18. package/docs/design/README.md +24 -24
  19. package/docs/development-principles.md +50 -50
  20. package/docs/dynamic-workflow-dag-engine-roadmap.md +6 -6
  21. package/docs/exec-plans/README.md +4 -4
  22. package/docs/exec-plans/active/README.md +10 -9
  23. package/docs/exec-plans/completed/README.md +8 -8
  24. package/docs/feature-workflow.md +111 -109
  25. package/docs/harness-methodology-verification.md +18 -18
  26. package/docs/loop-agent-harness.md +36 -36
  27. package/docs/production-readiness.md +96 -0
  28. package/docs/progress/README.md +2 -2
  29. package/docs/reports/README.md +4 -2
  30. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +1 -1
  31. package/docs/templates/agent-dag-process-supervisor.prompt.md +2 -2
  32. package/docs/templates/agent-dag-report.schema.json +33 -2
  33. package/docs/templates/agent-dag-review-verdict.prompt.md +1 -1
  34. package/docs/templates/agent-dag.base.json +195 -195
  35. package/docs/templates/agent-dag.final-verification.json +190 -190
  36. package/docs/templates/agent-dag.schema.json +17 -17
  37. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  38. package/docs/templates/hybrid-dag.json +193 -193
  39. package/docs/templates/production-readiness-checklist.md +57 -0
  40. package/docs/templates/progress-log.md +7 -7
  41. package/docs/templates/project-start-checklist.md +8 -8
  42. package/docs/templates/qa-report.md +17 -11
  43. package/docs/templates/sprint-contract.md +19 -19
  44. package/docs/verification-matrix.md +37 -26
  45. package/examples/example-dag.json +51 -51
  46. package/examples/hybrid-loop-agent-dag.json +194 -194
  47. package/harness.json +5 -5
  48. package/package.json +62 -62
  49. package/skills/loop-agent/SKILL.md +35 -35
  50. package/skills/loop-agent/references/command-reference.md +107 -65
  51. package/skills/loop-agent/references/harness-policy.md +30 -30
  52. package/skills/loop-agent/references/hybrid-dag.md +30 -30
  53. package/skills/loop-agent/references/model-routing.md +1 -1
  54. package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
  55. package/skills/loop-agent/references/pi-prompt.md +9 -9
  56. package/skills/loop-agent/references/post-implementation-and-patterns.md +7 -7
  57. package/skills/loop-agent/references/task-workflow.md +19 -19
  58. package/skills/loop-agent/references/verification-and-failure-handling.md +36 -0
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
- {
2
- "name": "@tea-agent/loop-agent",
3
- "version": "0.2.0",
4
- "type": "module",
5
- "bin": {
6
- "loop-agent": "bin/loop-agent.js"
7
- },
8
- "files": [
9
- "AGENTS.md",
10
- "bin/",
11
- "dist/",
12
- "docs/*.md",
13
- "docs/architecture/runtime-boundaries.md",
14
- "docs/decisions/README.md",
15
- "docs/design/README.md",
16
- "docs/exec-plans/README.md",
17
- "docs/exec-plans/active/README.md",
18
- "docs/exec-plans/completed/README.md",
19
- "docs/progress/README.md",
20
- "docs/reports/README.md",
21
- "docs/templates/",
22
- "examples/",
23
- "harness.json",
24
- "skills/",
25
- "README.md",
26
- "CHANGELOG.md"
27
- ],
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "scripts": {
32
- "dev": "node --import tsx/esm src/cli.ts",
33
- "cursor": "node --import tsx/esm src/cli.ts cursor-prompt",
34
- "pi-prompt": "node --import tsx/esm src/cli.ts pi-prompt",
35
- "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
36
- "build": "npm run clean && tsc -p tsconfig.build.json",
37
- "prepack": "npm run build",
38
- "prepublishOnly": "npm run typecheck && npm test && npm run build",
39
- "lint": "tsc --noEmit",
40
- "typecheck": "tsc --noEmit",
41
- "test": "vitest run",
42
- "docs:dev": "npm --prefix website start",
43
- "docs:build": "npm --prefix website run build",
44
- "docs:serve": "npm --prefix website run serve",
45
- "smoke:stale-serial": "tsx scripts/smoke-stale-plan-serial.ts"
46
- },
47
- "dependencies": {
48
- "commander": "^12.1.0",
49
- "zod": "^3.25.76"
50
- },
51
- "optionalDependencies": {
52
- "@cursor/sdk": "^1.0.7",
53
- "@earendil-works/pi-coding-agent": "*",
54
- "@earendil-works/pi-ai": "*"
55
- },
56
- "devDependencies": {
57
- "tsx": "^4.20.6",
58
- "typescript": "^5.9.3",
59
- "vitest": "^3.2.4",
60
- "@types/node": "^24.6.0"
61
- }
62
- }
1
+ {
2
+ "name": "@tea-agent/loop-agent",
3
+ "version": "0.2.1",
4
+ "type": "module",
5
+ "bin": {
6
+ "loop-agent": "bin/loop-agent.js"
7
+ },
8
+ "files": [
9
+ "AGENTS.md",
10
+ "bin/",
11
+ "dist/",
12
+ "docs/*.md",
13
+ "docs/architecture/runtime-boundaries.md",
14
+ "docs/decisions/README.md",
15
+ "docs/design/README.md",
16
+ "docs/exec-plans/README.md",
17
+ "docs/exec-plans/active/README.md",
18
+ "docs/exec-plans/completed/README.md",
19
+ "docs/progress/README.md",
20
+ "docs/reports/README.md",
21
+ "docs/templates/",
22
+ "examples/",
23
+ "harness.json",
24
+ "skills/",
25
+ "README.md",
26
+ "CHANGELOG.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "dev": "node --import tsx/esm src/cli.ts",
33
+ "cursor": "node --import tsx/esm src/cli.ts cursor-prompt",
34
+ "pi-prompt": "node --import tsx/esm src/cli.ts pi-prompt",
35
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
36
+ "build": "npm run clean && tsc -p tsconfig.build.json",
37
+ "prepack": "npm run build",
38
+ "prepublishOnly": "npm run typecheck && npm test && npm run build",
39
+ "lint": "tsc --noEmit",
40
+ "typecheck": "tsc --noEmit",
41
+ "test": "vitest run",
42
+ "docs:dev": "npm --prefix website start",
43
+ "docs:build": "npm --prefix website run build",
44
+ "docs:serve": "npm --prefix website run serve",
45
+ "smoke:stale-serial": "tsx scripts/smoke-stale-plan-serial.ts"
46
+ },
47
+ "dependencies": {
48
+ "commander": "^12.1.0",
49
+ "zod": "^3.25.76"
50
+ },
51
+ "optionalDependencies": {
52
+ "@cursor/sdk": "^1.0.7",
53
+ "@earendil-works/pi-coding-agent": "*",
54
+ "@earendil-works/pi-ai": "*"
55
+ },
56
+ "devDependencies": {
57
+ "tsx": "^4.20.6",
58
+ "typescript": "^5.9.3",
59
+ "vitest": "^3.2.4",
60
+ "@types/node": "^24.6.0"
61
+ }
62
+ }
@@ -60,38 +60,38 @@ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
60
60
 
61
61
  短时规划、审查、失败归因可使用 full-capability `pi-prompt`,默认模型是 `glm-5.2`:
62
62
 
63
- - 只读 sidecar 必须显式传 `--tools read,grep,find,ls`,并在 prompt 中写明不编辑文件。
64
- - 高复杂度 one-shot 诊断可显式加 `--model gpt-5.5`。
65
- - 输出是 advisory,不能替代 deterministic verification;发现必须写回 task source、report、progress 或 exec plan。
66
-
67
- ## Bounded Write Execution
68
-
69
- 需要写代码时,默认使用 DAG `pi` executor 的 write tool profile。Pi writer 节点必须包含 task id、目标、allowed paths、forbidden paths、writeSet、硬约束和预期验证,并在执行后由主会话独立运行 shell verification。
70
-
71
- Cursor 只作为显式启用的可选 bounded write backend。调用示例与细节见 `references/pi-prompt.md`、`references/harness-policy.md` 和 `references/verification-and-failure-handling.md`。
72
-
73
- Pi writer prompt 与 Cursor prompt 都必须包含:
63
+ - 只读 sidecar 必须显式传 `--tools read,grep,find,ls`,并在 prompt 中写明不编辑文件。
64
+ - 高复杂度 one-shot 诊断可显式加 `--model gpt-5.5`。
65
+ - 输出是 advisory,不能替代 deterministic verification;发现必须写回 task source、report、progress 或 exec plan。
66
+
67
+ ## Bounded Write Execution
68
+
69
+ 需要写代码时,默认使用 DAG `pi` executor 的 write tool profile。Pi writer 节点必须包含 task id、目标、allowed paths、forbidden paths、writeSet、硬约束和预期验证,并在执行后由主会话独立运行 shell verification。
70
+
71
+ Cursor 只作为显式启用的可选 bounded write backend。调用示例与细节见 `references/pi-prompt.md`、`references/harness-policy.md` 和 `references/verification-and-failure-handling.md`。
72
+
73
+ Pi writer prompt 与 Cursor prompt 都必须包含:
74
74
 
75
75
  - task id
76
76
  - exact objective
77
77
  - allowed paths
78
78
  - forbidden paths
79
- - hard constraints
80
- - expected verification
81
- - instruction to preserve unrelated files
82
-
83
- bounded writer 完成后,主会话必须独立复核;命令清单见 `references/verification-and-failure-handling.md` 的 "Cursor bounded write 后的独立复核"。
79
+ - hard constraints
80
+ - expected verification
81
+ - instruction to preserve unrelated files
82
+
83
+ bounded writer 完成后,主会话必须独立复核;命令清单见 `references/verification-and-failure-handling.md` 的 "Cursor bounded write 后的独立复核"。
84
84
 
85
85
  ## 进阶主题路由
86
86
 
87
- 以下主题只在 references 中维护细节,不在本文展开:
88
-
89
- | 主题 | Reference |
90
- |---|---|
91
- | Long-Running Loop(`loop` init/status/run/record-round/add-signal/closeout、auto mode、signals) | `references/long-running-loop.md` |
92
- | Three-Pass Convergence、repair artifact、spine audit、knowledge curate、SePO-lite prompt evolution | `references/harness-policy.md` |
93
- | Operator commands(status/doctor/report/closeout/promote/inspect/spine/knowledge/docs/handoff) | `references/command-reference.md` |
94
- | Post-Cursor 独立验证、verify knobs、failure handling、closeout | `references/verification-and-failure-handling.md` |
87
+ 以下主题只在 references 中维护细节,不在本文展开:
88
+
89
+ | 主题 | Reference |
90
+ |---|---|
91
+ | Long-Running Loop(`loop` init/status/run/record-round/add-signal/closeout、auto mode、signals) | `references/long-running-loop.md` |
92
+ | Three-Pass Convergence、repair artifact、spine audit、knowledge curate、SePO-lite prompt evolution | `references/harness-policy.md` |
93
+ | Operator commands(status/doctor/report/closeout/promote/inspect/spine/knowledge/docs/handoff) | `references/command-reference.md` |
94
+ | Post-Cursor 独立验证、verify knobs、failure handling、closeout | `references/verification-and-failure-handling.md` |
95
95
 
96
96
  ## Source Layout
97
97
 
@@ -111,17 +111,17 @@ bounded writer 完成后,主会话必须独立复核;命令清单见 `refere
111
111
 
112
112
  不要新增平行兼容入口。CLI public export 的唯一入口是 `src/cli/index.ts`;commander command tree 和 help 实现在 `src/cli/program.ts`。
113
113
 
114
- ## Hard Rules
115
-
116
- 1. One task = one bounded work chunk.
117
- 2. Source materials are mandatory: `source/需求.md` and `source/执行约束.md`.
118
- 3. Agent DAG is the implementation workflow.
119
- 4. DAG `pi` executor stays read-only unless the node sets `toolProfile: "write"`; `pi-prompt` / `cursor-prompt` are full-capability one-shot helpers and must be bounded per call.
120
- 5. Pi writer nodes and optional Cursor write execution must be bounded by explicit allowed / forbidden paths.
121
- 6. Completed DAG and one-shot run facts are read-only.
122
- 7. Do not write root `artifacts/` from read-only DAG or sidecar steps.
123
- 8. Do not keep hidden workflow state in chat only; write durable conclusions to repo artifacts.
124
- 9. Verify before completion.
114
+ ## Hard Rules
115
+
116
+ 1. One task = one bounded work chunk.
117
+ 2. Source materials are mandatory: `source/需求.md` and `source/执行约束.md`.
118
+ 3. Agent DAG is the implementation workflow.
119
+ 4. DAG `pi` executor stays read-only unless the node sets `toolProfile: "write"`; `pi-prompt` / `cursor-prompt` are full-capability one-shot helpers and must be bounded per call.
120
+ 5. Pi writer nodes and optional Cursor write execution must be bounded by explicit allowed / forbidden paths.
121
+ 6. Completed DAG and one-shot run facts are read-only.
122
+ 7. Do not write root `artifacts/` from read-only DAG or sidecar steps.
123
+ 8. Do not keep hidden workflow state in chat only; write durable conclusions to repo artifacts.
124
+ 9. Verify before completion.
125
125
 
126
126
  ## References
127
127
 
@@ -2,52 +2,52 @@
2
2
 
3
3
  需要 loop-agent 的精确 CLI 命令、setup 命令、task lifecycle 命令、docs helper、goal 命令或 stats 时使用本文。
4
4
 
5
- ## loop-agent 入口
6
-
7
- **优先在目标 repo 目录内执行命令** — loop-agent 通过 `harness.json.project` 自动检测使用哪个 repo adapter。跨目录操作时显式加 `--repo-root <target-repo>`。
8
-
9
- 默认使用全局 CLI:
10
-
11
- ```bash
12
- loop-agent <command> ...
13
- ```
14
-
15
- 面向自举迭代和日常使用时,全局 CLI 应来自 npm 上已发布的安装包。首次安装或有意升级使用 `@latest`:
16
-
17
- ```bash
18
- npm install -g @tea-agent/loop-agent@latest
19
- npm list -g @tea-agent/loop-agent --depth=0
20
- loop-agent doctor
21
- ```
22
-
23
- 一次自举任务启动后不要中途升级控制器;记录 `npm list -g` 显示的实际版本。不要在 DAG 节点中反复用 `npx @latest` 拉取,也不要使用当前工作区的 `npm link` 或 `npm run dev` 作为控制器去修改 loop-agent 本仓库的 CLI、DAG runtime、executor、package metadata 或 build output。`npm run dev -- <command> ...` 只用于源码调试和聚焦 CLI 开发。
24
-
25
- 发布包入口加载 `dist/cli.js`;开发入口加载 `src/cli.ts`。
26
-
27
- 发布包携带静态能力资料:`skills/`、`docs/*.md`、`docs/templates/` 和 `examples/`。`docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 的任务正文属于目标仓库运行中生成的事实,不从 npm 包复制;包内只保留这些目录的 README 说明。
28
-
29
- ## 命令参考
5
+ ## loop-agent 入口
6
+
7
+ **优先在目标 repo 目录内执行命令** — loop-agent 通过 `harness.json.project` 自动检测使用哪个 repo adapter。跨目录操作时显式加 `--repo-root <target-repo>`。
8
+
9
+ 默认使用全局 CLI:
10
+
11
+ ```bash
12
+ loop-agent <command> ...
13
+ ```
14
+
15
+ 面向自举迭代和日常使用时,全局 CLI 应来自 npm 上已发布的安装包。首次安装或有意升级使用 `@latest`:
16
+
17
+ ```bash
18
+ npm install -g @tea-agent/loop-agent@latest
19
+ npm list -g @tea-agent/loop-agent --depth=0
20
+ loop-agent doctor
21
+ ```
22
+
23
+ 一次自举任务启动后不要中途升级控制器;记录 `npm list -g` 显示的实际版本。不要在 DAG 节点中反复用 `npx @latest` 拉取,也不要使用当前工作区的 `npm link` 或 `npm run dev` 作为控制器去修改 loop-agent 本仓库的 CLI、DAG runtime、executor、package metadata 或 build output。`npm run dev -- <command> ...` 只用于源码调试和聚焦 CLI 开发。
24
+
25
+ 发布包入口加载 `dist/cli.js`;开发入口加载 `src/cli.ts`。
26
+
27
+ 发布包携带静态能力资料:`skills/`、`docs/*.md`、`docs/templates/` 和 `examples/`。`docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 的任务正文属于目标仓库运行中生成的事实,不从 npm 包复制;包内只保留这些目录的 README 说明。
28
+
29
+ ## 命令参考
30
30
 
31
31
  ## 默认选择模型
32
32
 
33
33
  选择命令时按以下优先级:
34
34
 
35
- 1. **主路径 DAG**,用于常规 autonomous work:
36
- ```bash
37
- loop-agent new-task <task-id> "Task Title"
38
- loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
39
- loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
40
- loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
41
- ```
42
- `<temp-dir>` 表示平台原生临时目录;也可以省略 `--output`,再使用命令 JSON 输出里的 `outputPath`。
43
- 2. **Operator 工具**,用于 recovery、诊断与 closeout:
44
- ```bash
35
+ 1. **主路径 DAG**,用于常规 autonomous work:
36
+ ```bash
37
+ loop-agent new-task <task-id> "Task Title"
38
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
39
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
40
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
41
+ ```
42
+ `<temp-dir>` 表示平台原生临时目录;也可以省略 `--output`,再使用命令 JSON 输出里的 `outputPath`。
43
+ 2. **Operator 工具**,用于 recovery、诊断与 closeout:
44
+ ```bash
45
45
  loop-agent dag status --run-id <run-id>
46
46
  loop-agent dag doctor
47
47
  loop-agent dag report --latest --markdown
48
48
  loop-agent dag closeout-draft --run-id <run-id>
49
49
  loop-agent dag reconcile-tasks --glob '<pattern>' --markdown
50
- loop-agent dag final-verification <task-id> --output <temp-dir>/<task-id>-final-verification-dag.json
50
+ loop-agent dag final-verification <task-id> --output <temp-dir>/<task-id>-final-verification-dag.json
51
51
  loop-agent status <task-id> --json
52
52
  loop-agent instructions task-artifacts --task <task-id> --json
53
53
  loop-agent promote-run <task-id> --run-id <run-id>
@@ -60,14 +60,15 @@ loop-agent doctor
60
60
  ```bash
61
61
  loop-agent delegate <task-id> --executor cursor
62
62
  loop-agent harvest <task-id>
63
+ loop-agent cursor-prompt --cwd <repo-root> --file /tmp/bounded-task.md
63
64
  loop-agent pi-prompt "Reply with exactly OK."
64
65
  ```
65
66
 
66
- ### Setup(首次)
67
- ```bash
68
- npm install -g @tea-agent/loop-agent@latest
69
- loop-agent --help
70
- ```
67
+ ### Setup(首次)
68
+ ```bash
69
+ npm install -g @tea-agent/loop-agent@latest
70
+ loop-agent --help
71
+ ```
71
72
 
72
73
  ### 检查 repo harness
73
74
  ```bash
@@ -141,9 +142,9 @@ loop-agent --repo-root /path/to/target-repo study init <task-id> "Title" \
141
142
  --reference-glob "codex-rs/**/goal*.rs"
142
143
 
143
144
  # 编辑 source/需求.md + source/执行约束.md,然后走 DAG 路径:
144
- loop-agent --repo-root <target-repo> dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
145
- loop-agent --repo-root <target-repo> dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
146
- loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <target-repo>
145
+ loop-agent --repo-root <target-repo> dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
146
+ loop-agent --repo-root <target-repo> dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
147
+ loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <target-repo>
147
148
  ```
148
149
 
149
150
  目标 repo 需有 `.harness/prompts/feature-study-analyze.md` 与 `feature-study-plan.md`(缺失时从 loop-agent 复制)。
@@ -152,6 +153,13 @@ loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json
152
153
 
153
154
  历史顺序式 `run analyze|plan|spec|implement|verify|retrospective|auto|loop|continue|study` 已移除。新任务不要使用这些命令,也不要在 prompt、skill 或 docs 中把它们描述为 fallback。
154
155
 
156
+ ### Reference helpers(compatibility)
157
+ ```bash
158
+ loop-agent reference index
159
+ ```
160
+
161
+ `reference` 是 compatibility / feature-study 辅助入口,用于维护或检查参考资料索引。常规实现任务不要从 `reference` 起步;按 `new-task` + DAG 路径执行。
162
+
155
163
  ### Task goal lifecycle(compatibility-only / deprecated-candidate)
156
164
  ```bash
157
165
  loop-agent goal set <task-id> "Objective text" [--token-budget <number|null>]
@@ -176,17 +184,17 @@ loop-agent goal clear <task-id>
176
184
 
177
185
  ### Agent DAG validation 与 execution
178
186
  ```bash
179
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation;无 .harness/dag-runs 副作用
180
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时失败
181
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning 时失败
182
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance --spine-task <task-id> # 同时消费 minimal spec spine audit
183
- loop-agent dag validate --dag docs/templates/agent-dag.supervised-implementation.json --strict-models --strict-governance # role=supervisor + write-set-gate topology
184
- cp docs/templates/agent-dag.supervised-implementation.json <temp-dir>/supervised-dag.json
185
- (npx vitest run test/dag-supervised-template.test.ts test/dag-validate.test.ts test/dag-shell-executor.test.ts --reporter=dot) # supervised template + shell.verdictGate runtime
186
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # 存在 cursor node 时失败
187
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行 Agent DAG
188
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 执行前若存在 cursor node 则失败
189
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas view
187
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation;无 .harness/dag-runs 副作用
188
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时失败
189
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning 时失败
190
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance --spine-task <task-id> # 同时消费 minimal spec spine audit
191
+ loop-agent dag validate --dag docs/templates/agent-dag.supervised-implementation.json --strict-models --strict-governance # role=supervisor + write-set-gate topology
192
+ cp docs/templates/agent-dag.supervised-implementation.json <temp-dir>/supervised-dag.json
193
+ (npx vitest run test/dag-supervised-template.test.ts test/dag-validate.test.ts test/dag-shell-executor.test.ts --reporter=dot) # supervised template + shell.verdictGate runtime
194
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # 存在 cursor node 时失败
195
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行 Agent DAG
196
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 执行前若存在 cursor node 则失败
197
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas view
190
198
  loop-agent dag init-hybrid <task-id> # 生成可审阅的 DAG draft
191
199
  loop-agent dag run-task <task-id> # generate + validate(安全默认;无 dag-runs;standard-compatible)
192
200
  loop-agent dag run-task <task-id> --profile auto # 推断 governanceProfile,经 workflowPolicy.dag.profileRouting 路由
@@ -213,9 +221,9 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
213
221
  **In-flight DAG governance**:shell verify node 内用 `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`;run 归档到 `completed/` 后,在 DAG 外跑裸 `bash scripts/check-repo.sh`。
214
222
 
215
223
  - `dag validate` 做 schema/topology/ranks 检查;审 `warnings` 中的显式 `executorModels` drift 与 governance lint。
216
- - 手写临时 DAG spec 执行前用 `dag validate --strict-models`,model-matrix drift 应 fail fast。
224
+ - 手写临时 DAG spec 执行前用 `dag validate --strict-models`,model-matrix drift 应 fail fast。
217
225
  - read-only artifact-boundary 或 DAG 内 shell governance warning 应 fail fast 时用 `dag validate --strict-governance`。
218
- - 人工 handoff 视图用 `dag report --markdown`(summary、node timeline、failures、四段 Recovery Plan、artifacts、建议 next action)。仅 derived、advisory;需保存时重定向到平台临时目录或 `docs/reports/`。
226
+ - 人工 handoff 视图用 `dag report --markdown`(summary、node timeline、failures、四段 Recovery Plan、artifacts、建议 next action)。仅 derived、advisory;需保存时重定向到平台临时目录或 `docs/reports/`。
219
227
  - operator 聚焦最新 paused run 用 `dag report --paused-latest`(等同 `--lifecycle paused --latest`;勿与显式 `--lifecycle` 并用)。
220
228
  - 需 operator 关注的 run 用 `dag report --failed-only`、`--latest`、`--action <recovery-action>` 收窄。category→action 映射见 `docs/agent-dag-recovery-playbook.md`。
221
229
  - 只读扫描 `.harness/dag-runs/` 下所有 run 的生命周期 health issue 与建议 action 用 `dag doctor`(`advisoryOnly: true`;不 mutate facts)。
@@ -227,6 +235,18 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
227
235
  - 仅当有意在 `.harness/dag-runs/active/` 下要 active run snapshot 时用 `run-dag --dry-run`。
228
236
  - task source 应从 `harness.json.workflowPolicy.dag.profileRouting` 与确定性 candidate `governanceProfile` 选 standard / review-gated / supervised template 时用 `dag run-task --profile auto`。无 `--profile` 仅用于旧 standard-compatible 输出;强制 template family 用 `--profile minimal|standard|reviewed|supervised`。
229
237
 
238
+ ### Saved Dynamic Workflow operator UX
239
+ ```bash
240
+ loop-agent workflow list
241
+ loop-agent workflow inspect <name>
242
+ loop-agent workflow save --from /tmp/<task-id>.workflow.json --name <name>
243
+ loop-agent workflow run <name-or-path> --cwd <repo-root>
244
+ loop-agent workflow diff <name> --against /tmp/<task-id>.workflow.json
245
+ loop-agent workflow replay <run-id>
246
+ ```
247
+
248
+ `workflow` 是 Dynamic Workflow 的 saved/operator surface。它读取 `WorkflowSpec`,编译为 DAG,再进入同一套 `run-dag` runtime;不会新增 executor 能力或绕过 DAG governance。真实写入任务仍应检查 compiled DAG 的 executor、writeSet、shell gates 和 completed facts 边界。
249
+
230
250
  ### Cursor worker lifecycle
231
251
  ```bash
232
252
  loop-agent cursor-worker status # enabled/running/child/entry path
@@ -259,14 +279,14 @@ loop-agent handoff coverage <task-id> [--json|--markdown]
259
279
 
260
280
  ### Pi runtime reuse benchmark / decision(无 live call)
261
281
  ```bash
262
- loop-agent pi-reuse-benchmark \
263
- --report docs/reports/<benchmark-report>.md \
264
- --json
265
-
266
- loop-agent pi-reuse-benchmark \
267
- --report docs/reports/<benchmark-report>.md \
268
- --off-executor /path/to/off/executor.jsonl \
269
- --on-executor /path/to/on/executor.jsonl \
282
+ loop-agent pi-reuse-benchmark \
283
+ --report docs/reports/<benchmark-report>.md \
284
+ --json
285
+
286
+ loop-agent pi-reuse-benchmark \
287
+ --report docs/reports/<benchmark-report>.md \
288
+ --off-executor /path/to/off/executor.jsonl \
289
+ --on-executor /path/to/on/executor.jsonl \
270
290
  --approval /path/to/approval.json \
271
291
  --markdown
272
292
  ```
@@ -281,6 +301,19 @@ loop-agent loop-benchmark --markdown --output docs/reports/2026-06-30-loop-agent
281
301
 
282
302
  生成 M0 deterministic baseline,对照 `single-repair`、`3-pass-convergence`、`3-pass-convergence+quota`。**不**跑 live Pi/Cursor call、不创建 task、不改 `convergence.enabled` 默认值。live dogfood 证据缺失时输出 `blocked` 并建议保持 opt-in。
283
303
 
304
+ ### Long-running loop outer state(experimental)
305
+ ```bash
306
+ loop-agent loop init <task-id>
307
+ loop-agent loop status <task-id>
308
+ loop-agent loop run <task-id> --action dag
309
+ loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
310
+ loop-agent loop record-round <task-id> --decision continue --summary "..."
311
+ loop-agent loop add-signal <task-id> --kind note --message "..."
312
+ loop-agent loop closeout <task-id>
313
+ ```
314
+
315
+ `loop` 是 Agent DAG 之上的长程状态和 evidence layer,记录 rounds、signals、verification summaries 和 closeout draft。它不是替代 `dag run-task` / `run-dag` 的实现路径;medium/large work 仍需要 DAG evidence 或明确 fallback reason。
316
+
284
317
  ### Minimal spec spine audit
285
318
  ```bash
286
319
  loop-agent spine audit <task-id> --json
@@ -312,4 +345,13 @@ loop-agent worktree create|list|remove ...
312
345
 
313
346
  用于 worktree 隔离的 cursor-direct 执行与 merge 收口。常规 autonomous work 应优先 Agent DAG;详见 `multi-worktree.md` 与 `docs/cursor-executor-usage.md`。
314
347
 
348
+ ### One-shot Cursor sidecar(escape hatch)
349
+ ```bash
350
+ loop-agent cursor-prompt --cwd <repo-root> "Review this task without editing files."
351
+ loop-agent cursor-prompt --cwd <repo-root> --file /tmp/bounded-cursor-task.md
352
+ loop-agent cursor-prompt --cwd <repo-root> --model composer-2.5 --timeout 1800000 --file /tmp/bounded-cursor-task.md
353
+ ```
354
+
355
+ `cursor-prompt` 是 one-shot Cursor SDK helper。用于 bounded diagnosis、小修复或调试 executor;写入 prompt 必须包含 task id、objective、allowed paths、forbidden paths、verification 和 preserve-unrelated-changes 要求。需要 `CURSOR_API_KEY`。它会创建 one-shot run evidence,但 Cursor 自报成功不替代 shell verification。
356
+
315
357
  > **Historical(已移除)**:`subagent list|start|wait|wakeup|attach|stop` 与 `dashboard` 已移除,不再出现在 CLI registry。
@@ -8,7 +8,7 @@
8
8
  - 历史顺序式 `run analyze|plan|spec|implement|verify|auto|loop|continue` workflow 已移除。不要将其作为 fallback path 呈现。
9
9
  - **Long-running `loop`** 是 Agent DAG 之上的 outer state/evidence layer。它记录 rounds、context compression、signals、canonical refs;不得替代 complex work 的 DAG writeSet review、Decision Gate 或 shell verification。
10
10
  - **Main session** 负责 orchestrate:选一个 work chunk、准备 source materials、review DAG/writeSet、monitor failures、跑 final verification、hand off。
11
- - **Executors** 实现 bounded work:Pi 在 DAG nodes 做 read-only planning/review/diagnosis,并在节点声明 `toolProfile: "write"` 时做 bounded implementation/repair;Cursor 是显式启用的可选 bounded writer;shell 产出 deterministic verification facts。
11
+ - **Executors** 实现 bounded work:Pi 在 DAG nodes 做 read-only planning/review/diagnosis,并在节点声明 `toolProfile: "write"` 时做 bounded implementation/repair;Cursor 是显式启用的可选 bounded writer;shell 产出 deterministic verification facts。
12
12
  - **Shell verification 是 completion fact source**。LLM review 或 advisory output 不能替代 command exit codes 与 archived evidence。
13
13
 
14
14
  ## Command surface tiers
@@ -33,13 +33,13 @@ Is this only status, diagnosis, recovery, or closeout?
33
33
  yes -> Agent DAG.
34
34
  ```
35
35
 
36
- 在以下任一 signal 适用时用 Agent DAG 而非 broad one-shot execution:
37
-
38
- - loop-agent runtime, DAG schema, run facts, promotion/closeout, scripts/CI, public contract, or shared protocol is touched.
39
- - The change needs multiple files, multiple scouts, review gates, Decision Gate, repair flow, or shell gate.
40
- - `writeSet` is broad, multiple exclusive writers exist, or public interfaces / architecture boundaries change.
41
- - Requirement, architecture, credential, cost, deployment, security, or authority surface is unclear.
42
- - A failure repeats and needs recovery planning rather than blind retry.
36
+ 在以下任一 signal 适用时用 Agent DAG 而非 broad one-shot execution:
37
+
38
+ - loop-agent runtime, DAG schema, run facts, promotion/closeout, scripts/CI, public contract, or shared protocol is touched.
39
+ - The change needs multiple files, multiple scouts, review gates, Decision Gate, repair flow, or shell gate.
40
+ - `writeSet` is broad, multiple exclusive writers exist, or public interfaces / architecture boundaries change.
41
+ - Requirement, architecture, credential, cost, deployment, security, or authority surface is unclear.
42
+ - A failure repeats and needs recovery planning rather than blind retry.
43
43
 
44
44
  ## Agent DAG path
45
45
 
@@ -61,18 +61,18 @@ loop-agent dag validate \
61
61
  --strict-models \
62
62
  --strict-governance
63
63
 
64
- loop-agent run-dag \
65
- --dag <temp-dir>/<task-id>-dag.json \
66
- --cwd <target-repo>
67
- ```
68
-
69
- `loop-agent` is the preferred global CLI. For self-hosting loop-agent development, the controller must be an installed npm-published package. Use `npm install -g @tea-agent/loop-agent@latest` for first install or intentional upgrades, then treat the installed version as frozen for the current task and record `npm list -g @tea-agent/loop-agent --depth=0`. Do not repeatedly fetch `npx @latest` inside DAG nodes, and do not use the current working tree's `npm link` or `npm run dev` to control tasks that may edit CLI, DAG runtime, executors, package metadata, or build output. Use `npm run dev -- <args>` only for source debugging and focused CLI development.
70
-
71
- The npm package carries static capability assets: `skills/`, top-level governance docs, `docs/templates/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`. Generated or historical task facts under `docs/progress/`, `docs/reports/`, `docs/exec-plans/`, and `docs/decisions/` belong to the target repository; package only their directory README files, not prior run content.
64
+ loop-agent run-dag \
65
+ --dag <temp-dir>/<task-id>-dag.json \
66
+ --cwd <target-repo>
67
+ ```
68
+
69
+ `loop-agent` is the preferred global CLI. For self-hosting loop-agent development, the controller must be an installed npm-published package. Use `npm install -g @tea-agent/loop-agent@latest` for first install or intentional upgrades, then treat the installed version as frozen for the current task and record `npm list -g @tea-agent/loop-agent --depth=0`. Do not repeatedly fetch `npx @latest` inside DAG nodes, and do not use the current working tree's `npm link` or `npm run dev` to control tasks that may edit CLI, DAG runtime, executors, package metadata, or build output. Use `npm run dev -- <args>` only for source debugging and focused CLI development.
72
70
 
73
- For arbitrary target repositories, DAG skill instructions must not depend on loop-agent source history being copied into the target repo. Resolve configured, user, or target-local skills when present, then fall back to package-bundled `skills/` as the stable default capability set.
74
-
75
- `<temp-dir>` means the platform-native temp directory. Use native paths for actual `--output`, `--dag`, and `--cwd` values on macOS and Windows; use `/` only for stable repo refs, JSON/Markdown evidence refs, and glob conventions.
71
+ The npm package carries static capability assets: `skills/`, top-level governance docs, `docs/templates/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`. Generated or historical task facts under `docs/progress/`, `docs/reports/`, `docs/exec-plans/`, and `docs/decisions/` belong to the target repository; package only their directory README files, not prior run content.
72
+
73
+ For arbitrary target repositories, DAG skill instructions must not depend on loop-agent source history being copied into the target repo. Resolve configured, user, or target-local skills when present, then fall back to package-bundled `skills/` as the stable default capability set.
74
+
75
+ `<temp-dir>` means the platform-native temp directory. Use native paths for actual `--output`, `--dag`, and `--cwd` values on macOS and Windows; use `/` only for stable repo refs, JSON/Markdown evidence refs, and glob conventions.
76
76
 
77
77
  Execution 前 review `dag run-task` JSON / `reviewPacket`:
78
78
 
@@ -168,12 +168,12 @@ Rules:
168
168
  - `dag report --json` 与 markdown 须 expose `convergence.passHistory`。
169
169
  - Final completion authority 仍是 full shell verification;quota/focused commands 仅为 intermediate cost controls。
170
170
 
171
- ## Structured repair, spine audit, and curator gates
172
-
173
- - `shell.repairArtifactGate.fromNodeId` validates the upstream supervisor artifact before repair. Missing/invalid JSON, missing request-revision `fixScope`, or scope outside the downstream repair writer allowedPaths/writeSet fails closed.
174
- - `spine audit <task-id>` is the deterministic minimal spec spine checker for task source, ownership paths, requirement coverage, and final verification commands.
175
- - `dag validate --strict-governance --spine-task <task-id>` may consume the same spine audit as part of strict validation.
176
- - `knowledge curate` reads completed convergence patterns and writes only human-gated proposal Markdown after skill safety preflight.
171
+ ## Structured repair, spine audit, and curator gates
172
+
173
+ - `shell.repairArtifactGate.fromNodeId` validates the upstream supervisor artifact before repair. Missing/invalid JSON, missing request-revision `fixScope`, or scope outside the downstream repair writer allowedPaths/writeSet fails closed.
174
+ - `spine audit <task-id>` is the deterministic minimal spec spine checker for task source, ownership paths, requirement coverage, and final verification commands.
175
+ - `dag validate --strict-governance --spine-task <task-id>` may consume the same spine audit as part of strict validation.
176
+ - `knowledge curate` reads completed convergence patterns and writes only human-gated proposal Markdown after skill safety preflight.
177
177
 
178
178
  ## SePO-lite prompt evolution
179
179
 
@@ -213,11 +213,11 @@ Sidecar output 为 advisory。若须成为 task evidence,通过 loop-agent run
213
213
 
214
214
  - Agent DAG 用 DAG JSON `executorModels` 加 node `executor` / `complexity`;不要从 repo `harness.json.models` 推断 DAG models。
215
215
  - DAG `shell` 与 `static` nodes 不用 models。
216
- - `harness.json.models.<step>` 下 historical step models 是 legacy metadata,不是新 DAG work 的 routing。
217
- - `pi-prompt` / `cursor-prompt` models 来自 CLI flags 或 runtime defaults,须 per intervention 选择。
218
- - Pi DAG nodes 默认 read-only planning/review/diagnosis;声明 `toolProfile: "write"` 时是 bounded writers,须有 explicit write scope。
219
- - Cursor nodes 是显式启用的可选 bounded writers,须有 explicit write scope。
220
- - Shell nodes 产出 deterministic verification facts 与 gates。
216
+ - `harness.json.models.<step>` 下 historical step models 是 legacy metadata,不是新 DAG work 的 routing。
217
+ - `pi-prompt` / `cursor-prompt` models 来自 CLI flags 或 runtime defaults,须 per intervention 选择。
218
+ - Pi DAG nodes 默认 read-only planning/review/diagnosis;声明 `toolProfile: "write"` 时是 bounded writers,须有 explicit write scope。
219
+ - Cursor nodes 是显式启用的可选 bounded writers,须有 explicit write scope。
220
+ - Shell nodes 产出 deterministic verification facts 与 gates。
221
221
 
222
222
  ## Artifacts and facts boundary
223
223