@tea-agent/loop-agent 0.1.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 (143) hide show
  1. package/AGENTS.md +62 -45
  2. package/CHANGELOG.md +60 -28
  3. package/README.md +160 -124
  4. package/bin/loop-agent.js +21 -21
  5. package/dist/adapters/index.js +3 -2
  6. package/dist/adapters/loop-agent.js +44 -2
  7. package/dist/application/dag/args.js +420 -0
  8. package/dist/application/dag/generate-task-dag.js +280 -0
  9. package/dist/application/dag/report-dag.js +14 -0
  10. package/dist/application/dag/run-dag.js +106 -0
  11. package/dist/application/dag/validate-dag.js +102 -0
  12. package/dist/application/loop/run-action.js +23 -0
  13. package/dist/cli/catalog.js +2 -237
  14. package/dist/cli/command-definitions.js +571 -0
  15. package/dist/cli/index.js +2 -0
  16. package/dist/cli/program.js +65 -1
  17. package/dist/cli/router.js +13 -0
  18. package/dist/cli-governance/active-residue-check.js +38 -0
  19. package/dist/commands/dag-report.js +6 -107
  20. package/dist/commands/dag-run-task.js +8 -466
  21. package/dist/commands/dag-validate.js +7 -179
  22. package/dist/commands/examples.js +90 -0
  23. package/dist/commands/init.js +1518 -0
  24. package/dist/commands/loop.js +57 -31
  25. package/dist/commands/pi-prompt.js +2 -9
  26. package/dist/commands/run-dag.js +7 -180
  27. package/dist/executors/cursor-executor-artifacts.js +3 -4
  28. package/dist/executors/cursor-worker-client.js +13 -3
  29. package/dist/executors/dag-cursor-executor.js +2 -3
  30. package/dist/executors/dag-pi-executor.js +3 -4
  31. package/dist/executors/dag-static-executor.js +2 -5
  32. package/dist/executors/pi-defaults.js +9 -0
  33. package/dist/executors/shell-executor.js +12 -20
  34. package/dist/governance/manifest-types.js +1 -0
  35. package/dist/infrastructure/harness/active-residue-policy.js +73 -0
  36. package/dist/infrastructure/harness/artifact-store.js +72 -0
  37. package/dist/infrastructure/harness/atomic-write.js +49 -0
  38. package/dist/infrastructure/harness/completed-facts-guard.js +40 -0
  39. package/dist/infrastructure/harness/loop-action-store.js +23 -0
  40. package/dist/infrastructure/harness/loop-store.js +41 -0
  41. package/dist/infrastructure/harness/one-shot-run-store.js +94 -0
  42. package/dist/infrastructure/harness/task-store.js +77 -0
  43. package/dist/records/one-shot-runs.js +26 -61
  44. package/dist/records/promotion.js +3 -4
  45. package/dist/shared/artifacts-core.js +5 -5
  46. package/dist/shared/logger.js +9 -15
  47. package/dist/task/delegate.js +4 -4
  48. package/dist/task/runtime.js +5 -7
  49. package/dist/task/state.js +6 -20
  50. package/dist/workflows/dag/convergence/controller.js +277 -0
  51. package/dist/workflows/dag/dynamic-runtime/condition.js +48 -0
  52. package/dist/workflows/dag/dynamic-runtime/loop-until.js +156 -0
  53. package/dist/workflows/dag/dynamic-runtime/map.js +185 -0
  54. package/dist/workflows/dag/dynamic-runtime/reduction.js +72 -0
  55. package/dist/workflows/dag/dynamic-runtime/shared.js +133 -0
  56. package/dist/workflows/dag/failure-routing.js +82 -0
  57. package/dist/workflows/dag/lifecycle.js +101 -8
  58. package/dist/workflows/dag/node-execution.js +262 -0
  59. package/dist/workflows/dag/report.js +73 -1
  60. package/dist/workflows/dag/run-store.js +36 -0
  61. package/dist/workflows/dag/runner.js +82 -1341
  62. package/dist/workflows/dag/scheduler.js +84 -0
  63. package/dist/workflows/dag/upstream-artifacts.js +20 -18
  64. package/dist/workflows/loop/actions/cursor-fix.js +191 -0
  65. package/dist/workflows/loop/actions/dag-action.js +130 -0
  66. package/dist/workflows/loop/actions/pi-review.js +267 -0
  67. package/dist/workflows/loop/actions/shared.js +157 -0
  68. package/dist/workflows/loop/actions/shell-verify.js +82 -0
  69. package/dist/workflows/loop/actions/types.js +1 -0
  70. package/dist/workflows/loop/actions/workflow-action.js +255 -0
  71. package/dist/workflows/loop/actions.js +55 -1212
  72. package/dist/workflows/loop/closeout.js +5 -4
  73. package/dist/workflows/loop/context.js +2 -3
  74. package/dist/workflows/loop/events.js +3 -2
  75. package/dist/workflows/loop/policy/auto-policy.js +104 -0
  76. package/dist/workflows/loop/policy/cursor-fix-policy.js +31 -0
  77. package/dist/workflows/loop/rounds.js +3 -3
  78. package/dist/workflows/loop/signals.js +4 -7
  79. package/dist/workflows/loop/state.js +11 -11
  80. package/docs/README.md +47 -44
  81. package/docs/agent-dag-recovery-playbook.md +32 -6
  82. package/docs/agent-dag-runner.md +17 -17
  83. package/docs/architecture/runtime-boundaries.md +147 -0
  84. package/docs/cursor-executor-usage.md +5 -5
  85. package/docs/decisions/README.md +2 -2
  86. package/docs/design/README.md +24 -24
  87. package/docs/development-principles.md +50 -50
  88. package/docs/dynamic-workflow-dag-engine-roadmap.md +6 -6
  89. package/docs/exec-plans/README.md +4 -4
  90. package/docs/exec-plans/active/README.md +10 -5
  91. package/docs/exec-plans/completed/README.md +9 -5
  92. package/docs/feature-workflow.md +111 -109
  93. package/docs/harness-methodology-verification.md +18 -18
  94. package/docs/loop-agent-harness.md +36 -36
  95. package/docs/production-readiness.md +96 -0
  96. package/docs/progress/README.md +2 -2
  97. package/docs/reports/README.md +4 -2
  98. package/docs/templates/agent-dag-decision-gate-dogfood-report.md +1 -1
  99. package/docs/templates/agent-dag-process-supervisor.prompt.md +2 -2
  100. package/docs/templates/agent-dag-report.schema.json +33 -2
  101. package/docs/templates/agent-dag-review-verdict.prompt.md +1 -1
  102. package/docs/templates/agent-dag.base.json +195 -195
  103. package/docs/templates/agent-dag.final-verification.json +190 -190
  104. package/docs/templates/agent-dag.schema.json +17 -17
  105. package/docs/templates/agent-dag.supervised-implementation.json +500 -500
  106. package/docs/templates/hybrid-dag.json +193 -193
  107. package/docs/templates/production-readiness-checklist.md +57 -0
  108. package/docs/templates/progress-log.md +7 -7
  109. package/docs/templates/project-start-checklist.md +8 -8
  110. package/docs/templates/qa-report.md +17 -11
  111. package/docs/templates/sprint-contract.md +19 -19
  112. package/docs/verification-matrix.md +37 -26
  113. package/examples/example-dag.json +51 -51
  114. package/examples/hybrid-loop-agent-dag.json +194 -194
  115. package/harness.json +5 -5
  116. package/package.json +62 -61
  117. package/skills/ai-engineering-context/SKILL.md +21 -21
  118. package/skills/loop-agent/SKILL.md +56 -171
  119. package/skills/loop-agent/references/README.md +6 -2
  120. package/skills/loop-agent/references/command-reference.md +107 -65
  121. package/skills/loop-agent/references/harness-policy.md +115 -115
  122. package/skills/loop-agent/references/hybrid-dag.md +30 -30
  123. package/skills/loop-agent/references/learned/README.md +13 -13
  124. package/skills/loop-agent/references/long-running-loop.md +59 -0
  125. package/skills/loop-agent/references/model-routing.md +1 -1
  126. package/skills/loop-agent/references/orchestrator-and-interventions.md +1 -1
  127. package/skills/loop-agent/references/pi-prompt.md +9 -9
  128. package/skills/loop-agent/references/pi-subagent-assisted-mode.md +0 -2
  129. package/skills/loop-agent/references/post-implementation-and-patterns.md +7 -7
  130. package/skills/loop-agent/references/task-workflow.md +19 -19
  131. package/skills/loop-agent/references/verification-and-failure-handling.md +54 -0
  132. package/skills/requesting-code-review/SKILL.md +40 -40
  133. package/skills/requesting-code-review/code-reviewer.md +4 -4
  134. package/skills/systematic-debugging/CREATION-LOG.md +43 -43
  135. package/skills/systematic-debugging/SKILL.md +113 -113
  136. package/skills/systematic-debugging/condition-based-waiting.md +20 -20
  137. package/skills/systematic-debugging/defense-in-depth.md +27 -27
  138. package/skills/systematic-debugging/root-cause-tracing.md +38 -38
  139. package/skills/systematic-debugging/test-academic.md +6 -6
  140. package/skills/systematic-debugging/test-pressure-1.md +6 -6
  141. package/skills/systematic-debugging/test-pressure-2.md +2 -2
  142. package/skills/systematic-debugging/test-pressure-3.md +6 -6
  143. package/skills/verification-before-completion/SKILL.md +37 -37
package/package.json CHANGED
@@ -1,61 +1,62 @@
1
- {
2
- "name": "@tea-agent/loop-agent",
3
- "version": "0.1.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/decisions/README.md",
14
- "docs/design/README.md",
15
- "docs/exec-plans/README.md",
16
- "docs/exec-plans/active/README.md",
17
- "docs/exec-plans/completed/README.md",
18
- "docs/progress/README.md",
19
- "docs/reports/README.md",
20
- "docs/templates/",
21
- "examples/",
22
- "harness.json",
23
- "skills/",
24
- "README.md",
25
- "CHANGELOG.md"
26
- ],
27
- "publishConfig": {
28
- "access": "public"
29
- },
30
- "scripts": {
31
- "dev": "node --import tsx/esm src/cli.ts",
32
- "cursor": "node --import tsx/esm src/cli.ts cursor-prompt",
33
- "pi-prompt": "node --import tsx/esm src/cli.ts pi-prompt",
34
- "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
35
- "build": "npm run clean && tsc -p tsconfig.build.json",
36
- "prepack": "npm run build",
37
- "prepublishOnly": "npm run typecheck && npm test && npm run build",
38
- "lint": "tsc --noEmit",
39
- "typecheck": "tsc --noEmit",
40
- "test": "vitest run",
41
- "docs:dev": "npm --prefix website start",
42
- "docs:build": "npm --prefix website run build",
43
- "docs:serve": "npm --prefix website run serve",
44
- "smoke:stale-serial": "tsx scripts/smoke-stale-plan-serial.ts"
45
- },
46
- "dependencies": {
47
- "commander": "^12.1.0",
48
- "zod": "^3.25.76"
49
- },
50
- "optionalDependencies": {
51
- "@cursor/sdk": "^1.0.7",
52
- "@earendil-works/pi-coding-agent": "*",
53
- "@earendil-works/pi-ai": "*"
54
- },
55
- "devDependencies": {
56
- "tsx": "^4.20.6",
57
- "typescript": "^5.9.3",
58
- "vitest": "^3.2.4",
59
- "@types/node": "^24.6.0"
60
- }
61
- }
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
+ }
@@ -1,48 +1,48 @@
1
1
  ---
2
2
  name: ai-engineering-context
3
- description: Use when an AI coding agent starts loop-agent work, prepares DAG or Loop context, delegates role-specific nodes, or decides where requirements, facts, evidence, and handoff notes belong.
3
+ description: AI coding agent 启动 loop-agent 工作、准备 DAG Loop context、委派 role-specific 节点,或决定 requirementsfactsevidencehandoff notes 应落何处时使用。
4
4
  ---
5
5
 
6
6
  # AI Engineering Context
7
7
 
8
- Context is an engineering artifact, not chat residue. Keep requirements, role boundaries, write authority, evidence, and handoff facts explicit.
8
+ Context 是工程 artifact,不是 chat 残留。须显式保留 requirementsrole 边界、write authorityevidence handoff facts
9
9
 
10
10
  ## When to Use
11
11
 
12
- Use when starting a task, DAG, workflow, or Loop round; preparing role prompts; delegating to Cursor/Pi/shell/static executors; or handling stale plans, conflicting requirements, or missing evidence.
12
+ 在启动 taskDAGworkflow Loop round;准备 role prompt;委派给 Cursor/Pi/shell/static executor;或处理 stale plan、冲突 requirements、缺失 evidence 时使用。
13
13
 
14
- Do not use for private platform paths, personal memory, Google Drive rules, or replacing task skills.
14
+ 不要用于 private platform pathspersonal memoryGoogle Drive 规则,或替代 task skills
15
15
 
16
16
  ## Context Priority
17
17
 
18
- Prefer facts in this order: latest user instruction; task source/contract; DAG/Loop artifacts; docs/plans/ADRs; code/tests; chat history as hints only.
18
+ 按以下顺序优先采信 facts:最新 user instructiontask source/contractDAG/Loop artifactsdocs/plans/ADRscode/testschat history 仅作 hint。
19
19
 
20
- If sources conflict, stop and name the conflict.
20
+ sources 冲突,停止并点明冲突。
21
21
 
22
22
  ## Role Boundaries
23
23
 
24
- - Planner: contract, DAG shape, write boundary, verification plan; no implementation edits.
25
- - Scout: code/test/doc/artifact facts; no repo writes.
26
- - Implementer: bounded changes inside writeSet; no scope widening or completion claims.
27
- - Reviewer: bugs, regressions, missing tests, risk; no rewrites unless assigned.
28
- - Verifier: command evidence, reproduction, failure category; model judgment is not proof.
29
- - Supervisor: gates, escalation, repair scope; no write-guard or human-gate bypass.
30
- - Closeout: evidence, risks, next steps; no hidden failures.
24
+ - PlannercontractDAG shapewrite boundaryverification plan;不做 implementation edits
25
+ - Scoutcode/test/doc/artifact facts;不写 repo
26
+ - Implementer:在 writeSet 内做 bounded changes;不扩大 scope 或宣称完成。
27
+ - Reviewerbugsregressionsmissing testsrisk;除非被指派,否则不重写。
28
+ - Verifiercommand evidencereproductionfailure categorymodel judgment 不是 proof
29
+ - Supervisorgatesescalationrepair scope;不绕过 write-guard human-gate
30
+ - Closeoutevidencerisksnext steps;不隐藏 failures
31
31
 
32
32
  ## Prompt Contract
33
33
 
34
- Every delegated node prompt should include objective, task id, role, executor, allowed paths, forbidden paths, writeSet, upstream artifact refs, concise excerpts, output contract, expected evidence, non-goals, and stop conditions.
34
+ 每个 delegated node prompt 应包含:objectivetask idroleexecutorallowed pathsforbidden pathswriteSetupstream artifact refsconcise excerptsoutput contractexpected evidencenon-goalsstop conditions
35
35
 
36
- Read-only nodes must return findings in node output only. They must not create scratch files in the repo.
36
+ read-only node 只能在 node output 返回 findings。不得在 repo 中创建 scratch files
37
37
 
38
38
  ## Persistence Rules
39
39
 
40
- Requirements and constraints go in task `source/`. Execution state and node artifacts go in `.harness/`. Durable plans, reports, decisions go in `docs/`. Reusable process guidance goes in `skills/`. Chat is transient only.
40
+ Requirements constraints 写入 task `source/`。Execution state node artifacts 写入 `.harness/`。Durable plansreportsdecisions 写入 `docs/`。可复用 process guidance 写入 `skills/`。Chat transient
41
41
 
42
42
  ## Failure Handling
43
43
 
44
- - Missing context: run scout or read the durable source.
45
- - Ambiguous requirement: update the contract before implementation.
46
- - Verification failure: diagnose cause before changing code.
47
- - Missing skill instructions: treat as context defect; do not assume hidden behavior.
48
- - Missing fresh verification: do not close out.
44
+ - Missing context:运行 scout 或读取 durable source
45
+ - Ambiguous requirement:implementation 前更新 contract
46
+ - Verification failure:改 code 前先 diagnose cause
47
+ - Missing skill instructions:视为 context defect;不要假设 hidden behavior
48
+ - Missing fresh verification:不要 close out
@@ -2,41 +2,50 @@
2
2
  name: loop-agent
3
3
  description: >-
4
4
  Use when implementing features, processing PRDs or requirements, running structured loop-agent workflows, creating harness tasks, using Agent DAG, run-dag, pi-prompt planning/review, or Cursor bounded implementation in loop-agent. Triggers: loop-agent, workflow, structured development, harness task, Agent DAG, 结构化开发, 工作流, 需求实现, PRD 实现.
5
+ references:
6
+ - path: references/harness-policy.md
7
+ required: true
8
+ - path: references/hybrid-dag.md
9
+ required: true
10
+ - path: references/verification-and-failure-handling.md
11
+ required: true
12
+ - path: references/command-reference.md
13
+ required: true
5
14
  ---
6
15
 
7
16
  # loop-agent Workflow
8
17
 
9
- 这是 `loop-agent` 的入口文档。它只描述当前推荐入口,不再保留旧入口作为可选主路径。
18
+ 这是 `loop-agent` 的入口文档,只负责 trigger、routing 和硬规则。较长的 command details、workflow 细节与失败处理放在 `references/`,按需加载。
10
19
 
11
20
  ## Canonical Harness Policy
12
21
 
13
- Shared loop-agent harness workflow rules live in `references/harness-policy.md`. Repo-local `docs/loop-agent-harness.md` / `specs/loop-agent-harness.md` files should stay thin adapters for local runtime path, governance root, and verification commands.
22
+ Shared loop-agent harness workflow 规则见 `references/harness-policy.md`。Repo-local `docs/loop-agent-harness.md` / `specs/loop-agent-harness.md` 应保持为 local runtime pathgovernance root、verification commands thin adapters。
14
23
 
15
24
  ## 默认立场
16
25
 
17
26
  - 主入口是 **Agent DAG**。
18
27
  - 主会话负责编排、审 writeSet、复核验证与 handoff。
19
- - DAG `pi` executor 默认用于 read-only planning / review / diagnosis;当节点声明 `toolProfile: "write"` 时用于 bounded implementation / repair;Pi 模型矩阵保持 LOW=`gpt-5.3-codex-spark`、MED=`glm-5.2`、HIGH=`gpt-5.5`。
28
+ - DAG `pi` executor 默认用于 read-only planning / review / diagnosis;当节点声明 `toolProfile: "write"` 时用于 bounded implementation / repair;Pi 模型矩阵保持 LOW=`gpt-5.3-codex-spark`、MED=`glm-5.2`、HIGH=`gpt-5.5`。
20
29
  - `pi-prompt` 与 `cursor-prompt` 都是一次性 full-capability helper;用作 sidecar 时必须在 prompt 和 tool/model 参数里显式收窄。
21
- - Cursor 是显式启用的可选 bounded write backend;默认 no-Cursor DAG 使用 `executor: "pi"` + `toolProfile: "write"`,必须给出 allowed / forbidden paths。
30
+ - Cursor 是显式启用的可选 bounded write backend;默认 no-Cursor DAG 使用 `executor: "pi"` + `toolProfile: "write"`,必须给出 allowed / forbidden paths。
22
31
  - Shell verification 是事实源;任何完成声明都必须有本轮命令输出。
23
32
  - 长期结论写回 `docs/exec-plans/`、`docs/reports/`、`docs/progress/` 或 `./skill/`。
24
33
 
25
34
  ## 唯一推荐执行路径
26
35
 
27
36
  ```bash
28
- loop-agent new-task <task-id> "Task Title"
29
- # write <repo-root>/.harness/tasks/<task-id>/source/需求.md
30
- # write <repo-root>/.harness/tasks/<task-id>/source/执行约束.md
31
-
32
- loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
33
- loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
34
- loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
35
- ```
36
-
37
- `loop-agent` 默认指 npm 上已发布的全局 CLI。自举迭代 loop-agent 本仓库时,首次安装或有意升级可用 `npm install -g @tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制可能改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务。`npm run dev -- <args>` 只用于源码调试和聚焦 CLI 开发。
38
-
39
- `<temp-dir>` 表示平台原生临时目录。macOS 和 Windows 都应使用实际平台路径;`/` 只用于 repo refs、JSON/Markdown 证据 refs 和 glob 约定。
37
+ loop-agent new-task <task-id> "Task Title"
38
+ # write <repo-root>/.harness/tasks/<task-id>/source/需求.md
39
+ # write <repo-root>/.harness/tasks/<task-id>/source/执行约束.md
40
+
41
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
42
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
43
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
44
+ ```
45
+
46
+ `loop-agent` 默认指 npm 上已发布的全局 CLI。自举迭代 loop-agent 本仓库时,首次安装或有意升级可用 `npm install -g @tea-agent/loop-agent@latest`,但一次自举任务启动后不要中途升级控制器,并记录 `npm list -g @tea-agent/loop-agent --depth=0` 显示的实际版本。不要用当前工作区的 `npm link` 或 `npm run dev` 控制可能改动 CLI、DAG runtime、executor、package metadata 或 build output 的任务。`npm run dev -- <args>` 只用于源码调试和聚焦 CLI 开发。
47
+
48
+ `<temp-dir>` 表示平台原生临时目录。macOS 和 Windows 都应使用实际平台路径;`/` 只用于 repo refs、JSON/Markdown 证据 refs 和 glob 约定。
40
49
 
41
50
  执行前必须审阅:
42
51
 
@@ -47,42 +56,21 @@ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
47
56
  - shell verification commands
48
57
  - decision gate mode
49
58
 
50
- ## Pi Sidecar
51
-
52
- 短时规划、审查、失败归因可使用 full-capability `pi-prompt`,默认模型是 `glm-5.2`。作为只读 sidecar 时必须显式传只读 tools:
59
+ ## Pi Sidecar 入口规则
53
60
 
54
- ```bash
55
- loop-agent pi-prompt \
56
- --cwd ~/go/src/loop-agent \
57
- --provider wizard-local \
58
- --model glm-5.2 \
59
- --tools read,grep,find,ls \
60
- --timeout 2400000 \
61
- "Read the task source and provide a concise implementation plan. Do not edit files."
62
- ```
63
-
64
- 规则:
61
+ 短时规划、审查、失败归因可使用 full-capability `pi-prompt`,默认模型是 `glm-5.2`:
65
62
 
66
- - `pi-prompt` 本身具备完整能力;只读 sidecar 必须使用 `--tools read,grep,find,ls` 并在 prompt 中写明不编辑文件。
63
+ - 只读 sidecar 必须显式传 `--tools read,grep,find,ls`,并在 prompt 中写明不编辑文件。
67
64
  - 高复杂度 one-shot 诊断可显式加 `--model gpt-5.5`。
68
- - 输出是 advisory,不能替代 deterministic verification。
69
- - 发现必须写回 task source、report、progress 或 exec plan。
65
+ - 输出是 advisory,不能替代 deterministic verification;发现必须写回 task source、report、progress 或 exec plan
70
66
 
71
67
  ## Bounded Write Execution
72
68
 
73
- 需要写代码时,默认使用 DAG `pi` executor 的 write tool profile。Pi writer 节点必须包含 task id、目标、allowed paths、forbidden paths、writeSet、硬约束和预期验证,并在执行后由主会话独立运行 shell verification。
69
+ 需要写代码时,默认使用 DAG `pi` executor 的 write tool profile。Pi writer 节点必须包含 task id、目标、allowed paths、forbidden paths、writeSet、硬约束和预期验证,并在执行后由主会话独立运行 shell verification。
74
70
 
75
- Cursor 只作为显式启用的可选 bounded write backend。需要使用 Cursor 时:
71
+ Cursor 只作为显式启用的可选 bounded write backend。调用示例与细节见 `references/pi-prompt.md`、`references/harness-policy.md` 和 `references/verification-and-failure-handling.md`。
76
72
 
77
- ```bash
78
- loop-agent cursor-prompt \
79
- --cwd ~/go/src/loop-agent \
80
- --timeout 1800000 \
81
- --model composer-2.5 \
82
- "<bounded task prompt with allowedPaths and forbiddenPaths>"
83
- ```
84
-
85
- Cursor prompt 与 Pi writer prompt 都必须包含:
73
+ Pi writer prompt 与 Cursor prompt 都必须包含:
86
74
 
87
75
  - task id
88
76
  - exact objective
@@ -92,136 +80,27 @@ Cursor prompt 与 Pi writer prompt 都必须包含:
92
80
  - expected verification
93
81
  - instruction to preserve unrelated files
94
82
 
95
- bounded writer 完成后,主会话必须独立执行:
96
-
97
- ```bash
98
- git status --short
99
- git diff --stat
100
- bash scripts/check-repo.sh
101
- npm run lint
102
- npm test
103
- npm run typecheck
104
- loop-agent inspect
105
- loop-agent docs audit
106
- loop-agent handoff check <task-id>
107
- ```
108
-
109
- ## Operator Commands
110
-
111
- 运行状态、恢复和收口只使用这些 operator 面:
112
-
113
- ```bash
114
- loop-agent dag status --run-id <run-id>
115
- loop-agent dag doctor
116
- loop-agent dag report --latest --markdown
117
- loop-agent dag closeout-draft --run-id <run-id>
118
- loop-agent promote-run <task-id> --run-id <run-id>
119
- loop-agent closeout task <task-id>
120
- loop-agent inspect
121
- loop-agent doctor
122
- loop-agent spine audit <task-id> --markdown
123
- loop-agent knowledge curate --markdown
124
- loop-agent loop-benchmark --markdown
125
- loop-agent docs audit
126
- loop-agent handoff check <task-id>
127
- ```
83
+ bounded writer 完成后,主会话必须独立复核;命令清单见 `references/verification-and-failure-handling.md` 的 "Cursor bounded write 后的独立复核"。
128
84
 
129
- ## Long-Running Loop
85
+ ## 进阶主题路由
130
86
 
131
- `loop` experimental outer workflow state,用于跨多轮记录目标、压缩记忆和 round facts 引用。它不替代 Agent DAG,也不等同于已移除的顺序式 `run loop`。
87
+ 以下主题只在 references 中维护细节,不在本文展开:
132
88
 
133
- 当前已可用的最小入口:
134
-
135
- ```bash
136
- loop-agent loop init <task-id>
137
- loop-agent loop status <task-id>
138
- loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
139
- loop-agent loop run <task-id> --action pi-review
140
- loop-agent loop run <task-id> --action cursor-fix --model composer-2.5
141
- loop-agent loop run <task-id> --action dag
142
- loop-agent loop run <task-id> --action dag --execute
143
- loop-agent loop run <task-id> --auto --max-rounds 3
144
- loop-agent loop run <task-id> --auto --max-rounds 3 --allow-cursor-fix
145
- loop-agent loop add-signal <task-id> --type human_followup --message "review this boundary before closeout"
146
- loop-agent loop closeout <task-id>
147
- loop-agent loop record-round <task-id> \
148
- --action manual \
149
- --result "summary" \
150
- --lesson "what to carry forward" \
151
- --next "next bounded action" \
152
- --decision continue \
153
- --ref ".harness/runs/completed/<run-id>/result.json"
154
- ```
155
-
156
- 规则:
157
-
158
- - `loop/objective.md` 与 `loop/context.md` 是运行态投影;exec plan / task source 仍是需求状态源。
159
- - `rounds.jsonl` 只引用 canonical facts,不复制完整 executor 日志。
160
- - `context.md` 每轮重写为压缩记忆,不无限 append。
161
- - `loop run --action shell-verify` 是 deterministic action;命令 exit code 决定 verification result,输出摘要写入 `loop/verification/round-N.json`。
162
- - `loop run --action pi-review` 必须保持 read-only;工具 allowlist 固定为 `read,grep,find,ls`,输出必须包含 `findingSummary`、`failureCategory`、`nextHypothesis`、`recommendedAction`、`fixScope`、`rootCause`,其中 `recommendedAction` 只能是 `implement_fix|replan|pause|done`。
163
- - `loop run --action cursor-fix` 必须读取 task `allowedPaths` / `forbiddenPaths`,拒绝空 allowedPaths 或 allowed/forbidden overlap;对 `complexity=medium|large` 的任务,还必须已有 loop `dag` round 证据,或在 `task.json.dagFallbackReason` 中写明 DAG runtime fallback 原因。调用现有 Cursor bounded executor,并把 one-shot evidence 归档到 `.harness/runs/completed|failed/`。
164
- - `cursor-fix` 只表示 bounded write round 已执行;它不会把 loop 标记 complete,下一步必须进入 `shell-verify` 或 review。
165
- - `loop run --action dag` 默认是 review mode:调用 `dag run-task <task-id> --profile auto --strict-models` 生成 DAG,再用 `dag validate --strict-models --strict-governance` 校验,并记录 review packet。
166
- - `loop run --action dag --execute` 才会调用 `run-dag`,随后读取 `dag report --json` 作为 round result;paused DAG 会让 loop 进入 `paused`。
167
- - `loop run --auto --max-rounds N` 使用 deterministic policy 选择下一轮 action;默认只会自动选择 shell-verify、pi-review、dag review 或 policy pause/block,不自动触发 Cursor 写入。
168
- - 自动 `cursor-fix` 必须显式 opt-in:`task.json.loopAutoWritePolicy="enabled"`,或 `loopAutoWritePolicy="approval-required"` 加 pending approval signal / `--allow-cursor-fix`。即使 opt-in,也必须通过 `allowedPaths`/`forbiddenPaths`/DAG evidence guard;guard 失败会 pause,不会绕过写入边界。
169
- - `loop add-signal` 写入 durable `signals.jsonl`,支持 `human_followup|approval|scope_changed|review_feedback`;urgent/scope_changed 会 pause,review feedback / human follow-up 先走 read-only Pi review,approval 触发下一轮 DAG review packet。
170
- - Signals 不直接覆盖 `objective.md`;DAG decision envelope / approve / reject / resume 仍由 DAG action 机制管理,loop 只记录 refs。
171
- - `loop closeout` 从 loop state、objective/context、rounds 和 signals 派生 `loop/closeout.md` draft;draft 会标出 workflow path(`dag` / `explicit-fallback` / `missing-dag-evidence` / `micro-or-small`)与 fallback reason。非 complete 状态必须标 partial/paused/blocked,不能修改 completed facts;medium/large loop 若缺少 DAG round 且没有 `dagFallbackReason`,必须把缺失 DAG 证据列为 remaining risk。
172
- - `events.jsonl` 只用于 observability,覆盖 loop_start、round_start、action_start、action_finish、context_rewrite、decision、loop_finish;不要把 events 当状态源。
173
- - auto mode 遇到同类 failure streak 达阈值会 blocked,避免无限重试。
174
- - 完成声明仍必须由 shell verification、review verdict 和 success criteria coverage 证明。
175
-
176
- ## Three-Pass Convergence
177
-
178
- Supervised DAG convergence is opt-in through task config:
179
-
180
- ```json
181
- {
182
- "convergence": {
183
- "enabled": true,
184
- "maxPasses": 3,
185
- "stopOnHardVerifyPass": true,
186
- "pauseOnRegression": true
187
- }
188
- }
189
- ```
190
-
191
- Rules:
192
-
193
- - The feature flag `HARNESS_DAG_CONVERGENCE=off` disables DAG convergence and restores single-repair behavior.
194
- - `process-supervisor-pi` output must include first-line `VERDICT:` plus a `REPAIR_ARTIFACT_JSON` fenced block; `repair-pi` / optional `repair-cursor` should use artifact `failureClass`, `rootCause`, `fixScope`, and `invariant` before raw logs.
195
- - When `hard-verify-shell` fails with a retryable category and `currentPass < maxPasses`, the runner preserves current pass artifacts under `convergence/pass-N/`, resets the supervisor/process-gate/repair/hard-verify segment plus blocked downstream nodes, and re-enters the DAG ranks.
196
- - `write-guard`, timeout, spawn/auth, and human-gate failures do not auto-retry.
197
- - Regression signals such as lower shell success count pause the run as `convergence-regression`.
198
- - `dag report --json` / markdown exposes `convergence.passHistory`.
199
- - Final completion still requires full shell verification; intermediate quota/focused checks are cost controls only.
200
-
201
- ## Repair Artifact / Spine / Knowledge
202
-
203
- - `process-supervisor-pi` output for gated supervised DAGs must include first-line `VERDICT:` plus a `REPAIR_ARTIFACT_JSON` fenced block.
204
- - `process-gate-shell` may set `shell.repairArtifactGate.fromNodeId`; the runner fails closed when the artifact is missing, schema-invalid, or its `fixScope` escapes the downstream repair writer allowedPaths/writeSet.
205
- - `spine audit <task-id>` checks minimal spec spine evidence: source files, path ownership, allowed/forbidden overlap, requirement coverage, and final verification command labels.
206
- - `dag validate --strict-governance --spine-task <task-id>` consumes the same spine audit and fails on error findings.
207
- - `knowledge curate` turns completed convergence patterns into a human-gated learned guidance proposal and runs skill safety preflight; it never edits accepted learned guidance directly.
208
-
209
- ## SePO-Lite Prompt Evolution
210
-
211
- - Learned prompt deltas are human-gated proposals under task source or skill references.
212
- - Prompt deltas must be Markdown-only process guidance; they must not add shell commands, credential handling, tool permission expansion, or completion-authority bypass rules.
213
- - Accepted learned patterns live in `./skill/references/learned/<repo>.md` or `default.md`.
214
- - DAG implementer prompts that already request the `loop-agent` skill may inline up to three learned Markdown sections as bounded guidance.
215
- - Learned guidance is advisory and cannot replace shell verification or write governance.
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` |
216
95
 
217
96
  ## Source Layout
218
97
 
219
98
  新代码优先从这些目录进入:
220
99
 
221
- | Area | Entry |
222
- |---|---|
223
- | CLI command tree / help / commander program | `src/cli/` |
224
- | DAG workflow | `src/workflows/dag/` |
100
+ | Area | Entry |
101
+ |---|---|
102
+ | CLI command tree / help / commander program | `src/cli/` |
103
+ | DAG workflow | `src/workflows/dag/` |
225
104
  | Long-running loop workflow | `src/workflows/loop/` |
226
105
  | Task runtime | `src/task/` |
227
106
  | Executors | `src/executors/` |
@@ -230,15 +109,15 @@ Rules:
230
109
  | Shared helpers | `src/shared/` |
231
110
  | Repo adapters | `src/adapters/` |
232
111
 
233
- 不要新增平行兼容入口。CLI public export 的唯一入口是 `src/cli/index.ts`;commander command tree 和 help 实现在 `src/cli/program.ts`。
112
+ 不要新增平行兼容入口。CLI public export 的唯一入口是 `src/cli/index.ts`;commander command tree 和 help 实现在 `src/cli/program.ts`。
234
113
 
235
114
  ## Hard Rules
236
115
 
237
116
  1. One task = one bounded work chunk.
238
117
  2. Source materials are mandatory: `source/需求.md` and `source/执行约束.md`.
239
118
  3. Agent DAG is the implementation workflow.
240
- 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.
241
- 5. Pi writer nodes and optional Cursor write execution must be bounded by explicit allowed / forbidden paths.
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.
242
121
  6. Completed DAG and one-shot run facts are read-only.
243
122
  7. Do not write root `artifacts/` from read-only DAG or sidecar steps.
244
123
  8. Do not keep hidden workflow state in chat only; write durable conclusions to repo artifacts.
@@ -246,10 +125,17 @@ Rules:
246
125
 
247
126
  ## References
248
127
 
128
+ Required(frontmatter 已声明):
129
+
249
130
  - `references/harness-policy.md`
250
131
  - `references/hybrid-dag.md`
251
- - `references/orchestrator-and-interventions.md`
132
+ - `references/verification-and-failure-handling.md`
252
133
  - `references/command-reference.md`
134
+
135
+ Optional(按需加载):
136
+
137
+ - `references/orchestrator-and-interventions.md`
138
+ - `references/long-running-loop.md`
253
139
  - `references/task-workflow.md`
254
140
  - `references/pi-prompt.md`
255
141
  - `references/one-shot-runs.md`
@@ -257,4 +143,3 @@ Rules:
257
143
  - `references/model-routing.md`
258
144
  - `references/multi-worktree.md`
259
145
  - `references/post-implementation-and-patterns.md`
260
- - `references/verification-and-failure-handling.md`
@@ -25,6 +25,9 @@ failure handling 与 workflow 细节放在这里,避免主 skill 变成百科
25
25
  | 解释 `.harness/runs/`、one-shot evidence、active 残留或 promotion | `one-shot-runs.md` |
26
26
  | 多 worktree 并行委派、delegate/harvest | `multi-worktree.md` |
27
27
  | 模型、provider、profile、fallback routing | `model-routing.md` |
28
+ | Long-running `loop` 命令、action 规则、auto mode、signals、loop closeout | `long-running-loop.md` |
29
+ | Three-pass convergence、repair artifact / spine audit / knowledge curate、SePO-lite prompt evolution | `harness-policy.md` |
30
+ | Cursor bounded write 后的独立复核、verify knobs、failure handling | `verification-and-failure-handling.md` |
28
31
 
29
32
  ## Reference 索引
30
33
 
@@ -41,7 +44,8 @@ failure handling 与 workflow 细节放在这里,避免主 skill 变成百科
41
44
  | `model-routing.md` | 查看或修改 model/provider 默认、profile、routing 或 fallback 行为 |
42
45
  | `post-implementation-and-patterns.md` | 处理 post-verify handoff、PRD item 拆分、fast bounded task、quick status 或 Pi timeout |
43
46
  | `multi-worktree.md` | 用 isolated worktree、`delegate` 与 `harvest` 并发执行互不重叠的 independent task |
44
- | `verification-and-failure-handling.md` | 选择 verify knob、解释 failure mode、执行 completion audit 与 closeout |
47
+ | `verification-and-failure-handling.md` | 选择 verify knob、Cursor bounded write 后的独立复核、解释 failure mode、执行 completion audit 与 closeout |
48
+ | `long-running-loop.md` | 使用 experimental long-running `loop` outer state:命令入口、action 规则、auto mode 写入边界、signals 与 loop closeout |
45
49
 
46
50
  ## 边界与状态源
47
51
 
@@ -56,7 +60,7 @@ failure handling 与 workflow 细节放在这里,避免主 skill 变成百科
56
60
  ## 维护规则
57
61
 
58
62
  - 不要把长段落复制回 `SKILL.md`;需要新增细节时,在本目录新增或更新 reference,并在 `SKILL.md` 添加 routing row。
59
- - 让 `SKILL.md` 保持约 200-300 行以内;reference 文件承担细节。
63
+ - 让 `SKILL.md` 保持 120-180 行以内;reference 文件承担细节。
60
64
  - 新 reference 应有清晰标题、触发场景、最小步骤、失败处理和维护边界。
61
65
  - 如果某个 reference 变成可独立触发、跨项目通用且不再依赖本仓库上下文,再考虑拆成独立 skill。
62
66
  - 更新 command、workflow policy 或 verification 规则时,同步核对 `harness.json`、`references/harness-policy.md`、repo-local harness adapter docs 和 verification matrix。