@tea-agent/loop-agent 0.2.0 → 0.3.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 (77) hide show
  1. package/AGENTS.md +43 -24
  2. package/CHANGELOG.md +72 -44
  3. package/README.md +177 -164
  4. package/bin/loop-agent.js +21 -21
  5. package/dist/application/dag/args.js +6 -0
  6. package/dist/application/dag/generate-task-dag.js +5 -3
  7. package/dist/application/dag/run-dag.js +17 -1
  8. package/dist/application/dag/validate-dag.js +41 -0
  9. package/dist/cli/command-definitions.js +2 -2
  10. package/dist/cli/program.js +24 -4
  11. package/dist/commands/init.js +1036 -461
  12. package/dist/workflows/dag/dynamic-runtime/loop-until.js +2 -1
  13. package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
  14. package/dist/workflows/dag/failure-routing.js +82 -0
  15. package/dist/workflows/dag/init-hybrid.js +3 -3
  16. package/dist/workflows/dag/lifecycle.js +95 -3
  17. package/dist/workflows/dag/report.js +73 -1
  18. package/dist/workflows/dag/skills.js +3 -3
  19. package/dist/workflows/dag/types.js +2 -0
  20. package/dist/workflows/dynamic/compile.js +11 -0
  21. package/dist/workflows/dynamic/spec.js +1 -0
  22. package/docs/README.md +50 -45
  23. package/docs/agent-dag-recovery-playbook.md +32 -6
  24. package/docs/agent-dag-runner.md +19 -17
  25. package/docs/architecture/runtime-boundaries.md +1 -1
  26. package/docs/cursor-executor-usage.md +5 -5
  27. package/docs/decisions/README.md +2 -2
  28. package/docs/design/README.md +24 -24
  29. package/docs/development-principles.md +50 -50
  30. package/docs/dynamic-workflow-dag-engine-roadmap.md +6 -6
  31. package/docs/exec-plans/README.md +4 -4
  32. package/docs/exec-plans/active/README.md +7 -9
  33. package/docs/exec-plans/completed/README.md +10 -8
  34. package/docs/feature-workflow.md +111 -109
  35. package/docs/harness-methodology-verification.md +18 -18
  36. package/docs/init-surface.manifest.json +175 -0
  37. package/docs/loop-agent-harness.md +36 -36
  38. package/docs/production-readiness.md +96 -0
  39. package/docs/progress/README.md +2 -2
  40. package/docs/reports/README.md +4 -2
  41. package/docs/skills/README.md +6 -0
  42. package/docs/skills/vetted-skill-registry.md +26 -0
  43. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +1 -1
  44. package/docs/templates/agent-dag-process-supervisor.prompt.md +2 -2
  45. package/docs/templates/agent-dag-report.schema.json +33 -2
  46. package/docs/templates/agent-dag-review-verdict.prompt.md +1 -1
  47. package/docs/templates/agent-dag.base.json +195 -195
  48. package/docs/templates/agent-dag.final-verification.json +190 -190
  49. package/docs/templates/agent-dag.schema.json +17 -17
  50. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  51. package/docs/templates/hybrid-dag.json +193 -193
  52. package/docs/templates/init-evolution-review.md +33 -0
  53. package/docs/templates/production-readiness-checklist.md +57 -0
  54. package/docs/templates/progress-log.md +7 -7
  55. package/docs/templates/project-start-checklist.md +8 -8
  56. package/docs/templates/qa-report.md +17 -11
  57. package/docs/templates/sprint-contract.md +19 -19
  58. package/docs/verification-matrix.md +37 -26
  59. package/examples/example-dag.json +51 -51
  60. package/examples/hybrid-loop-agent-dag.json +194 -194
  61. package/harness.json +10 -8
  62. package/package.json +60 -58
  63. package/skills/code-review-core/SKILL.md +20 -0
  64. package/skills/codebase-scout/SKILL.md +19 -0
  65. package/skills/init-capability-evolution/SKILL.md +69 -0
  66. package/skills/loop-agent/SKILL.md +35 -35
  67. package/skills/loop-agent/references/command-reference.md +125 -65
  68. package/skills/loop-agent/references/harness-policy.md +30 -30
  69. package/skills/loop-agent/references/hybrid-dag.md +30 -30
  70. package/skills/loop-agent/references/model-routing.md +1 -1
  71. package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
  72. package/skills/loop-agent/references/pi-prompt.md +9 -9
  73. package/skills/loop-agent/references/post-implementation-and-patterns.md +7 -7
  74. package/skills/loop-agent/references/task-workflow.md +19 -19
  75. package/skills/loop-agent/references/verification-and-failure-handling.md +36 -0
  76. package/skills/test-driven-development/SKILL.md +20 -0
  77. package/skills/webapp-testing/SKILL.md +19 -0
package/package.json CHANGED
@@ -1,62 +1,64 @@
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",
1
+ {
2
+ "name": "@tea-agent/loop-agent",
3
+ "version": "0.3.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
18
  "docs/exec-plans/completed/README.md",
19
+ "docs/init-surface.manifest.json",
19
20
  "docs/progress/README.md",
20
21
  "docs/reports/README.md",
22
+ "docs/skills/",
21
23
  "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
- }
24
+ "examples/",
25
+ "harness.json",
26
+ "skills/",
27
+ "README.md",
28
+ "CHANGELOG.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "dev": "node --import tsx/esm src/cli.ts",
35
+ "cursor": "node --import tsx/esm src/cli.ts cursor-prompt",
36
+ "pi-prompt": "node --import tsx/esm src/cli.ts pi-prompt",
37
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
38
+ "build": "npm run clean && tsc -p tsconfig.build.json",
39
+ "prepack": "npm run build",
40
+ "prepublishOnly": "npm run typecheck && npm test && npm run build",
41
+ "lint": "tsc --noEmit",
42
+ "typecheck": "tsc --noEmit",
43
+ "test": "vitest run",
44
+ "docs:dev": "npm --prefix website start",
45
+ "docs:build": "npm --prefix website run build",
46
+ "docs:serve": "npm --prefix website run serve",
47
+ "smoke:stale-serial": "tsx scripts/smoke-stale-plan-serial.ts"
48
+ },
49
+ "dependencies": {
50
+ "commander": "^12.1.0",
51
+ "zod": "^3.25.76"
52
+ },
53
+ "optionalDependencies": {
54
+ "@cursor/sdk": "^1.0.7",
55
+ "@earendil-works/pi-coding-agent": "*",
56
+ "@earendil-works/pi-ai": "*"
57
+ },
58
+ "devDependencies": {
59
+ "tsx": "^4.20.6",
60
+ "typescript": "^5.9.3",
61
+ "vitest": "^3.2.4",
62
+ "@types/node": "^24.6.0"
63
+ }
64
+ }
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: code-review-core
3
+ description: 用于只读 code review 节点,产出带文件与行号引用的优先级 findings。
4
+ ---
5
+
6
+ # Code Review Core
7
+
8
+ 本 skill 用于 reviewer 节点。
9
+
10
+ ## Review 重点
11
+
12
+ - 优先关注 correctness、行为回归、security、数据丢失与缺失验证。
13
+ - findings 须 grounded 在具体文件与行号。
14
+ - 区分 blocking findings 与次要 maintainability 备注。
15
+ - 检查测试是否证明变更行为,文档是否与面向用户的变更一致。
16
+ - 若无 findings,明确说明,并指出 residual test gap(如有)。
17
+
18
+ ## Output
19
+
20
+ 按 severity 排序列出 findings。仅当无 blocking findings 时,才写 `VERDICT: pass`。
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: codebase-scout
3
+ description: 用于只读 scout 节点,在实现前定位现有代码、测试、文档与集成点。
4
+ ---
5
+
6
+ # Codebase Scout
7
+
8
+ 本 skill 用于 scout 节点。
9
+
10
+ ## 规则
11
+
12
+ - 从 repo 指令、task source 与邻近测试入手。
13
+ - 可用时优先 CodeGraph;否则用 `rg` 与聚焦文件阅读。
14
+ - 在提议新抽象前,识别现有 helper 与 ownership 边界。
15
+ - 只返回事实,不做编辑。
16
+
17
+ ## Output
18
+
19
+ 列出相关文件、现有模式、风险,以及实现所需的最小 write surface。
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: init-capability-evolution
3
+ description: 用于 loop-agent 本仓库的初始化能力演化审查,判断代码、skill、模板、包范围或 DAG 默认能力变化是否需要同步更新目标项目 init surface。
4
+ ---
5
+
6
+ # Init Capability Evolution
7
+
8
+ 本 skill 用于 loop-agent 本仓库。当变更可能影响 `loop-agent init` 初始化其他项目的能力时使用。
9
+
10
+ ## Goal
11
+
12
+ 让模型自行判断并维护初始化能力,而不是依赖人工记忆:
13
+
14
+ - 新能力是否应该进入目标项目。
15
+ - 新增/修改的 skill 是否应随 npm 包和 `init --profile full` 投影。
16
+ - 目标项目的 `AGENTS.md`、README managed block、治理 docs、scripts 或 templates 是否需要更新。
17
+ - `package.json files` 与 `docs/init-surface.manifest.json` 是否仍覆盖真实发布范围。
18
+ - 是否需要目标项目 smoke、init doctor、docs audit 或 package dry-run 证据。
19
+
20
+ ## Trigger Tiers
21
+
22
+ 按 `docs/init-surface.manifest.json` 的 `evolutionReview.tiers` 判断成本:
23
+
24
+ - `advisory`:只记录提示,不阻塞。
25
+ - `surface-check`:运行 `bash scripts/check-init-surface.sh`;通过即可。
26
+ - `model-review`:写一份简短 init evolution review,必要时修改 init surface、包范围、文档、skill 或测试。
27
+
28
+ 不要把小改动升级成重流程。只有当变化可能改变目标项目初始化体验、默认 DAG 行为、skill resolution、发布包边界或 init 生成物时,才进入 model-review。
29
+
30
+ ## Review Questions
31
+
32
+ 审查时逐条回答:
33
+
34
+ 1. 本次变更会改变目标项目执行 `loop-agent init --profile full --merge` 后得到的文件、规则或能力吗?
35
+ 2. 是否新增、删除或重命名了 `skills/**`,并且目标项目需要 repo-local 可审计副本?
36
+ 3. 是否改变了默认 DAG role skills、skill resolution、strict skill audit 或 task prompt 注入?
37
+ 4. 是否新增通用治理模板、script matrix、production readiness 或 operator recovery 文档,需要目标项目初始化后可见?
38
+ 5. `package.json files` 是否包含所有 npm 运行和初始化所需静态资料?
39
+ 6. `docs/init-surface.manifest.json` 是否更新了 package / init / exclude / trigger contract?
40
+ 7. 旧目标项目是否只需 advisory、需要手工复制新增文件,还是需要未来 `init audit/update` 迁移能力?
41
+
42
+ ## Output
43
+
44
+ 轻量审查可以只在 handoff 中说明。高影响审查应写入:
45
+
46
+ ```text
47
+ docs/reports/YYYY-MM-DD-init-evolution-review.md
48
+ ```
49
+
50
+ 报告保持短小,包含:
51
+
52
+ - changed surface
53
+ - decision: no init impact / surface check only / init update required
54
+ - files updated
55
+ - verification commands and results
56
+ - residual risk
57
+
58
+ ## Required Verification
59
+
60
+ 按影响面选择最小命令:
61
+
62
+ ```bash
63
+ bash scripts/check-init-surface.sh
64
+ bash scripts/check-repo.sh
65
+ npm test -- init-command dag-skills dag-validate-command
66
+ npm pack --dry-run --ignore-scripts
67
+ ```
68
+
69
+ 如果没有新鲜验证证据,不要宣称 init evolution 已完成。
@@ -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,53 @@
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
-
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
17
  ```bash
18
18
  npm install -g @tea-agent/loop-agent@latest
19
19
  npm list -g @tea-agent/loop-agent --depth=0
20
+ loop-agent --version
20
21
  loop-agent doctor
21
22
  ```
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
- ## 命令参考
23
+
24
+ 一次自举任务启动后不要中途升级控制器;记录 `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 开发。
25
+
26
+ 发布包入口加载 `dist/cli.js`;开发入口加载 `src/cli.ts`。
27
+
28
+ 发布包携带静态能力资料:`skills/`、`docs/*.md`、`docs/templates/` 和 `examples/`。`docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 的任务正文属于目标仓库运行中生成的事实,不从 npm 包复制;包内只保留这些目录的 README 说明。
29
+
30
+ ## 命令参考
30
31
 
31
32
  ## 默认选择模型
32
33
 
33
34
  选择命令时按以下优先级:
34
35
 
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
36
+ 1. **主路径 DAG**,用于常规 autonomous work:
37
+ ```bash
38
+ loop-agent new-task <task-id> "Task Title"
39
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
40
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
41
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
42
+ ```
43
+ `<temp-dir>` 表示平台原生临时目录;也可以省略 `--output`,再使用命令 JSON 输出里的 `outputPath`。主路径 JSON 输出含稳定 summary:`dag run-task` 的 `message` 为 `DAG draft created`,`dag validate` 的 `message` 为 `DAG validation passed` 且含 `checks.writeSets` / `checks.decisionGates`,`run-dag` 的 `message` 为 `DAG run finished`。
44
+ 2. **Operator 工具**,用于 recovery、诊断与 closeout:
45
+ ```bash
45
46
  loop-agent dag status --run-id <run-id>
46
47
  loop-agent dag doctor
47
48
  loop-agent dag report --latest --markdown
48
49
  loop-agent dag closeout-draft --run-id <run-id>
49
50
  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
51
+ loop-agent dag final-verification <task-id> --output <temp-dir>/<task-id>-final-verification-dag.json
51
52
  loop-agent status <task-id> --json
52
53
  loop-agent instructions task-artifacts --task <task-id> --json
53
54
  loop-agent promote-run <task-id> --run-id <run-id>
@@ -60,12 +61,14 @@ loop-agent doctor
60
61
  ```bash
61
62
  loop-agent delegate <task-id> --executor cursor
62
63
  loop-agent harvest <task-id>
64
+ loop-agent cursor-prompt --cwd <repo-root> --file /tmp/bounded-task.md
63
65
  loop-agent pi-prompt "Reply with exactly OK."
64
66
  ```
65
67
 
66
- ### Setup(首次)
68
+ ### Setup(首次)
67
69
  ```bash
68
70
  npm install -g @tea-agent/loop-agent@latest
71
+ loop-agent --version
69
72
  loop-agent --help
70
73
  ```
71
74
 
@@ -75,10 +78,10 @@ loop-agent inspect # 当前 repo(自
75
78
  loop-agent --repo-root /path/to/target-repo inspect # 指定 repo
76
79
  ```
77
80
 
78
- ### 健康检查
79
- ```bash
80
- loop-agent doctor
81
- ```
81
+ ### 健康检查
82
+ ```bash
83
+ loop-agent doctor
84
+ ```
82
85
 
83
86
  `doctor` 报告当前生效的 Pi backend 及 SDK/CLI 可用性。Pi step 默认 SDK-first 执行:
84
87
 
@@ -87,11 +90,26 @@ export CODE_AGENT_PI_BACKEND=sdk-first # 默认:先试 Pi SDK,允许时 fa
87
90
  export CODE_AGENT_PI_BACKEND=cli-only # 紧急回滚:纯 CLI 路径
88
91
  ```
89
92
 
90
- SDK 回归或 SDK 可选依赖不可用时用 `cli-only` 诊断。CLI fallback 路径须与现有 workflow 行为兼容。
91
-
92
- ### 创建新 task
93
- ```bash
94
- loop-agent new-task <task-id> "Task Title"
93
+ SDK 回归或 SDK 可选依赖不可用时用 `cli-only` 诊断。CLI fallback 路径须与现有 workflow 行为兼容。
94
+
95
+ ### 初始化与旧项目更新
96
+ ```bash
97
+ loop-agent init instructions --repo-root <target-repo>
98
+ loop-agent init --repo-root <target-repo> --profile full --merge
99
+ loop-agent init doctor --repo-root <target-repo>
100
+ loop-agent init check-update --repo-root <target-repo> --json
101
+ loop-agent init check-update --repo-root <target-repo> --markdown
102
+ loop-agent init update --repo-root <target-repo> --bootstrap-surface
103
+ loop-agent init update --repo-root <target-repo> --apply-safe
104
+ ```
105
+
106
+ `init check-update` 是只读升级报告,用于发现目标项目是否落后于当前包内初始化 surface。输出会区分 deterministic actions、model merge tasks、human decisions 和 recommended next。`--markdown` 会渲染可直接交给模型执行的合并指引,包含 `allowedPaths`、`forbiddenPaths`、`mergeRules` 和 `verification`。
107
+
108
+ `init update --bootstrap-surface` 为旧项目写入 `.harness/init-surface.json` 的 `inferred-baseline`,不伪装成历史 recorded baseline。`init update --apply-safe` 只执行确定性安全动作:补缺失文件、创建目录、刷新 managed block;已有但无法确认与当前包一致的文件会进入 model merge tasks,不会被覆盖。
109
+
110
+ ### 创建新 task
111
+ ```bash
112
+ loop-agent new-task <task-id> "Task Title"
95
113
  ```
96
114
 
97
115
  创建 `.harness/tasks/<task-id>/`,含 `source/`、`artifacts/`、`logs/` 及初始 state。
@@ -141,9 +159,9 @@ loop-agent --repo-root /path/to/target-repo study init <task-id> "Title" \
141
159
  --reference-glob "codex-rs/**/goal*.rs"
142
160
 
143
161
  # 编辑 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>
162
+ loop-agent --repo-root <target-repo> dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
163
+ loop-agent --repo-root <target-repo> dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
164
+ loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <target-repo>
147
165
  ```
148
166
 
149
167
  目标 repo 需有 `.harness/prompts/feature-study-analyze.md` 与 `feature-study-plan.md`(缺失时从 loop-agent 复制)。
@@ -152,6 +170,13 @@ loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json
152
170
 
153
171
  历史顺序式 `run analyze|plan|spec|implement|verify|retrospective|auto|loop|continue|study` 已移除。新任务不要使用这些命令,也不要在 prompt、skill 或 docs 中把它们描述为 fallback。
154
172
 
173
+ ### Reference helpers(compatibility)
174
+ ```bash
175
+ loop-agent reference index
176
+ ```
177
+
178
+ `reference` 是 compatibility / feature-study 辅助入口,用于维护或检查参考资料索引。常规实现任务不要从 `reference` 起步;按 `new-task` + DAG 路径执行。
179
+
155
180
  ### Task goal lifecycle(compatibility-only / deprecated-candidate)
156
181
  ```bash
157
182
  loop-agent goal set <task-id> "Objective text" [--token-budget <number|null>]
@@ -176,17 +201,18 @@ loop-agent goal clear <task-id>
176
201
 
177
202
  ### Agent DAG validation 与 execution
178
203
  ```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
204
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation;无 .harness/dag-runs 副作用
205
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时失败
206
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning 时失败
207
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-skills # missing/error/truncated skill unresolved reference 时失败
208
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance --spine-task <task-id> # 同时消费 minimal spec spine audit
209
+ loop-agent dag validate --dag docs/templates/agent-dag.supervised-implementation.json --strict-models --strict-governance # role=supervisor + write-set-gate topology
210
+ cp docs/templates/agent-dag.supervised-implementation.json <temp-dir>/supervised-dag.json
211
+ (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
212
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # 存在 cursor node 时失败
213
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行 Agent DAG
214
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 执行前若存在 cursor node 则失败
215
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas view
190
216
  loop-agent dag init-hybrid <task-id> # 生成可审阅的 DAG draft
191
217
  loop-agent dag run-task <task-id> # generate + validate(安全默认;无 dag-runs;standard-compatible)
192
218
  loop-agent dag run-task <task-id> --profile auto # 推断 governanceProfile,经 workflowPolicy.dag.profileRouting 路由
@@ -213,9 +239,9 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
213
239
  **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
240
 
215
241
  - `dag validate` 做 schema/topology/ranks 检查;审 `warnings` 中的显式 `executorModels` drift 与 governance lint。
216
- - 手写临时 DAG spec 执行前用 `dag validate --strict-models`,model-matrix drift 应 fail fast。
242
+ - 手写临时 DAG spec 执行前用 `dag validate --strict-models`,model-matrix drift 应 fail fast。
217
243
  - 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/`。
244
+ - 人工 handoff 视图用 `dag report --markdown`(summary、node timeline、failures、四段 Recovery Plan、artifacts、建议 next action)。仅 derived、advisory;需保存时重定向到平台临时目录或 `docs/reports/`。
219
245
  - operator 聚焦最新 paused run 用 `dag report --paused-latest`(等同 `--lifecycle paused --latest`;勿与显式 `--lifecycle` 并用)。
220
246
  - 需 operator 关注的 run 用 `dag report --failed-only`、`--latest`、`--action <recovery-action>` 收窄。category→action 映射见 `docs/agent-dag-recovery-playbook.md`。
221
247
  - 只读扫描 `.harness/dag-runs/` 下所有 run 的生命周期 health issue 与建议 action 用 `dag doctor`(`advisoryOnly: true`;不 mutate facts)。
@@ -227,6 +253,18 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
227
253
  - 仅当有意在 `.harness/dag-runs/active/` 下要 active run snapshot 时用 `run-dag --dry-run`。
228
254
  - 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
255
 
256
+ ### Saved Dynamic Workflow operator UX
257
+ ```bash
258
+ loop-agent workflow list
259
+ loop-agent workflow inspect <name>
260
+ loop-agent workflow save --from /tmp/<task-id>.workflow.json --name <name>
261
+ loop-agent workflow run <name-or-path> --cwd <repo-root>
262
+ loop-agent workflow diff <name> --against /tmp/<task-id>.workflow.json
263
+ loop-agent workflow replay <run-id>
264
+ ```
265
+
266
+ `workflow` 是 Dynamic Workflow 的 saved/operator surface。它读取 `WorkflowSpec`,编译为 DAG,再进入同一套 `run-dag` runtime;不会新增 executor 能力或绕过 DAG governance。真实写入任务仍应检查 compiled DAG 的 executor、writeSet、shell gates 和 completed facts 边界。
267
+
230
268
  ### Cursor worker lifecycle
231
269
  ```bash
232
270
  loop-agent cursor-worker status # enabled/running/child/entry path
@@ -259,14 +297,14 @@ loop-agent handoff coverage <task-id> [--json|--markdown]
259
297
 
260
298
  ### Pi runtime reuse benchmark / decision(无 live call)
261
299
  ```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 \
300
+ loop-agent pi-reuse-benchmark \
301
+ --report docs/reports/<benchmark-report>.md \
302
+ --json
303
+
304
+ loop-agent pi-reuse-benchmark \
305
+ --report docs/reports/<benchmark-report>.md \
306
+ --off-executor /path/to/off/executor.jsonl \
307
+ --on-executor /path/to/on/executor.jsonl \
270
308
  --approval /path/to/approval.json \
271
309
  --markdown
272
310
  ```
@@ -281,6 +319,19 @@ loop-agent loop-benchmark --markdown --output docs/reports/2026-06-30-loop-agent
281
319
 
282
320
  生成 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
321
 
322
+ ### Long-running loop outer state(experimental)
323
+ ```bash
324
+ loop-agent loop init <task-id>
325
+ loop-agent loop status <task-id>
326
+ loop-agent loop run <task-id> --action dag
327
+ loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
328
+ loop-agent loop record-round <task-id> --decision continue --summary "..."
329
+ loop-agent loop add-signal <task-id> --kind note --message "..."
330
+ loop-agent loop closeout <task-id>
331
+ ```
332
+
333
+ `loop` 是 Agent DAG 之上的长程状态和 evidence layer,记录 rounds、signals、verification summaries 和 closeout draft。它不是替代 `dag run-task` / `run-dag` 的实现路径;medium/large work 仍需要 DAG evidence 或明确 fallback reason。
334
+
284
335
  ### Minimal spec spine audit
285
336
  ```bash
286
337
  loop-agent spine audit <task-id> --json
@@ -312,4 +363,13 @@ loop-agent worktree create|list|remove ...
312
363
 
313
364
  用于 worktree 隔离的 cursor-direct 执行与 merge 收口。常规 autonomous work 应优先 Agent DAG;详见 `multi-worktree.md` 与 `docs/cursor-executor-usage.md`。
314
365
 
366
+ ### One-shot Cursor sidecar(escape hatch)
367
+ ```bash
368
+ loop-agent cursor-prompt --cwd <repo-root> "Review this task without editing files."
369
+ loop-agent cursor-prompt --cwd <repo-root> --file /tmp/bounded-cursor-task.md
370
+ loop-agent cursor-prompt --cwd <repo-root> --model composer-2.5 --timeout 1800000 --file /tmp/bounded-cursor-task.md
371
+ ```
372
+
373
+ `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。
374
+
315
375
  > **Historical(已移除)**:`subagent list|start|wait|wakeup|attach|stop` 与 `dashboard` 已移除,不再出现在 CLI registry。