@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
@@ -1,6 +1,6 @@
1
1
  # Agent DAG Hybrid Workflow(`run-dag` / `dag init-hybrid`)
2
2
 
3
- 创建或执行 loop-agent 工作的首选 Agent DAG path 时使用本文:Level 2 Agent DAG orchestration、Pi read-only + Pi `toolProfile: "write"` bounded execution、optional Cursor backend、write policy、DAG template、task-to-DAG 生成,或基于 governance-profile 的 template 选择。
3
+ 创建或执行 loop-agent 工作的首选 Agent DAG path 时使用本文:Level 2 Agent DAG orchestration、Pi read-only + Pi `toolProfile: "write"` bounded execution、optional Cursor backend、write policy、DAG template、task-to-DAG 生成,或基于 governance-profile 的 template 选择。
4
4
 
5
5
  ### DAG workflow 优先级
6
6
 
@@ -25,25 +25,25 @@
25
25
 
26
26
  ### Level 2 Agent DAG hybrid(`run-dag`)
27
27
 
28
- ```bash
29
- cp examples/hybrid-loop-agent-dag.json <temp-dir>/hybrid-dag.json
30
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation + ranks;无 dag-runs 副作用
31
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时也失败
32
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning(如 read-only artifact drift)时失败
33
- loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # offline/CI/no-key 显式 no-Cursor;存在 cursor node 时失败
34
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行(若包含 cursor node 则需 CURSOR_API_KEY)
35
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 存在 cursor node 时执行前失败
36
- loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas(无需 CURSOR_API_KEY)
37
- ```
38
-
39
- `<temp-dir>` 表示平台原生临时目录;实际命令中 macOS 与 Windows 都使用本机路径。`/` 只作为 repo refs、JSON/Markdown evidence refs 和 glob 约定的稳定分隔符。
28
+ ```bash
29
+ cp examples/hybrid-loop-agent-dag.json <temp-dir>/hybrid-dag.json
30
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation + ranks;无 dag-runs 副作用
31
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时也失败
32
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning(如 read-only artifact drift)时失败
33
+ loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # offline/CI/no-key 显式 no-Cursor;存在 cursor node 时失败
34
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行(若包含 cursor node 则需 CURSOR_API_KEY)
35
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 存在 cursor node 时执行前失败
36
+ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas(无需 CURSOR_API_KEY)
37
+ ```
38
+
39
+ `<temp-dir>` 表示平台原生临时目录;实际命令中 macOS 与 Windows 都使用本机路径。`/` 只作为 repo refs、JSON/Markdown evidence refs 和 glob 约定的稳定分隔符。
40
40
 
41
41
  完整 schema 与语义:`docs/agent-dag-runner.md`。Workflow 概览:`docs/loop-agent-harness.md`。
42
42
 
43
43
  **v2 字段**(均可选;缺失时行为同 v1):
44
44
 
45
45
  - 顶层:`objective`、`successCriteria`、`globalConstraints`、`defaults`、`skillsByRole`、`executorModels`
46
- - 每 node:`role`、`skills`、`writePolicy`、`writeSet`、`piStep`、`shell`、`outputContract`、`executor`(`cursor` | `pi` | `shell` | `static`);Pi 写入节点额外声明 `toolProfile: "write"`
46
+ - 每 node:`role`、`skills`、`writePolicy`、`writeSet`、`piStep`、`shell`、`outputContract`、`executor`(`cursor` | `pi` | `shell` | `static`);Pi 写入节点额外声明 `toolProfile: "write"`
47
47
 
48
48
  **Model 生成 DAG 的 template 卫生**:
49
49
 
@@ -53,19 +53,19 @@ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <t
53
53
  - 输出独立时优先 same-rank parallel read-only scout(`scout-src`、`scout-tests` 等),而非 serial scout chain。
54
54
  - 仅当 child 真正需要 upstream output 时加 `depends_on`;review 时质疑 single-chain topology。
55
55
  - `exclusive` implementer node 需 narrow、disjoint 的 `writeSet` path;勿用 `**` 或 repo root。
56
- - 默认 no-Cursor DAG 使用 `pi` read-only scouts/reviewers 与 `toolProfile: "write"` exclusive implementer;Cursor 是显式启用的可选 scout / writer backend。
56
+ - 默认 no-Cursor DAG 使用 `pi` read-only scouts/reviewers 与 `toolProfile: "write"` exclusive implementer;Cursor 是显式启用的可选 scout / writer backend。
57
57
  - model routing 用 `executorModels`;勿用 `defaults.model` 或 legacy 顶层 `models`。
58
58
 
59
59
  **运维 warning**:
60
60
 
61
- - **常规 validation**:`dag validate --dag <path>` 做 schema/topology/ranks。JSON 输出含 `governanceProfile`(确定性 `minimal|standard|reviewed|supervised` 推断,含 `process` / `delivery` / `codeChange` signal 与 `reasons`),及 model-matrix drift、governance lint(如 read-only artifact-boundary drift 或 DAG 内 `check-repo.sh` shell env drift)的 warnings。手写临时 DAG spec 执行前用 `dag validate --dag <path> --strict-models`;governance warning 应 fail fast 时加 `--strict-governance`。no-Cursor 环境用 `dag validate --dag <path> --forbid-executor cursor` 或 `run-dag --no-cursor` 捕获显式 Cursor 节点;默认生成 DAG 应使用 `pi` read-only / Pi write profile / shell。仅当有意在 `.harness/dag-runs/active/` 要 active run snapshot 时用 `run-dag --dry-run`。
61
+ - **常规 validation**:`dag validate --dag <path>` 做 schema/topology/ranks。JSON 输出含 `governanceProfile`(确定性 `minimal|standard|reviewed|supervised` 推断,含 `process` / `delivery` / `codeChange` signal 与 `reasons`),及 model-matrix drift、governance lint(如 read-only artifact-boundary drift 或 DAG 内 `check-repo.sh` shell env drift)的 warnings。手写临时 DAG spec 执行前用 `dag validate --dag <path> --strict-models`;governance warning 应 fail fast 时加 `--strict-governance`。no-Cursor 环境用 `dag validate --dag <path> --forbid-executor cursor` 或 `run-dag --no-cursor` 捕获显式 Cursor 节点;默认生成 DAG 应使用 `pi` read-only / Pi write profile / shell。仅当有意在 `.harness/dag-runs/active/` 要 active run snapshot 时用 `run-dag --dry-run`。
62
62
  - **Governance profile 推断与 routing(code vs skill 分工)**:`./src/workflows/dag/governance-profile.ts` 从 DAG 结构与 write scope 做 **硬确定性推断**。JSON 输出 **报告** `process` / `delivery` / `codeChange` signal 与人类可读 `reasons`;`profile` tier(`minimal|standard|reviewed|supervised`)仅由该模块 code rule 选择(如多个 exclusive writer、repair node、review-gate topology、`loop-agent-runtime-paths`、`scripts-ci-harness-paths`、weak post-implementation shell verification、supervised topology)。baseline `forbiddenPaths`(`.harness/**`、`.harness/dag-runs/**`、`artifacts/**`)是默认 governance,**本身不是** process-risk signal。skill prompt 与本 reference **解释** tier 并摘要 profile 选择原因;不替代 code 推断。`dag run-task` 转发 embedded validate step 的同一 candidate `governanceProfile`。`dag run-task --profile auto` 先将 candidate profile 经 `harness.json.workflowPolicy.dag.profileRouting` 映射,再在 candidate delivery signal 含 `loop-agent-runtime-paths`、`scripts-ci-harness-paths` 或 `public-contract-paths` 时应用 M4 `supervised-quality-gate` promotion;`profileRouting.routingReasons` 记录确定性 reason。无 profile `dag run-task <task-id>` 仍为 standard-compatible;显式 `--profile minimal|standard|reviewed|supervised` 强制对应 template family(当前 policy 下 minimal/standard 路由到 `standard-dag`),高风险 task 应用 `--profile auto` 或显式 `--profile supervised`,而非显式 `--profile reviewed`。
63
- - **Executor model routing**:DAG spec 选 `executor` 与 `complexity`,可通过 `executorModels` 覆盖 `cursor` / `pi` 的 model 名;不选 provider。默认 routing:Cursor 各 complexity 用 `composer-2.5`;Pi read-only 与 Pi write profile 共用 LOW=`wizard-local/gpt-5.3-codex-spark`、MED=`wizard-local/glm-5.2`、HIGH=`wizard-local/gpt-5.5`。`shell` 不用 model,忽略 `executorModels`。
63
+ - **Executor model routing**:DAG spec 选 `executor` 与 `complexity`,可通过 `executorModels` 覆盖 `cursor` / `pi` 的 model 名;不选 provider。默认 routing:Cursor 各 complexity 用 `composer-2.5`;Pi read-only 与 Pi write profile 共用 LOW=`wizard-local/gpt-5.3-codex-spark`、MED=`wizard-local/glm-5.2`、HIGH=`wizard-local/gpt-5.5`。`shell` 不用 model,忽略 `executorModels`。
64
64
  - **Active visibility**:真实 `run-dag` execution 在 run/node 转换时写 active `state.json`,归档前 core runner 暴露 isolated `DagRunObserver` hook 供 derived view。`.harness/dag-runs/completed/<run-id>/` / `paused/<run-id>/` 仍是 source of truth;observer 输出非 canonical。
65
65
  - **可选 Canvas**:传 `--canvas-path <abs-path>` 或 `--canvas <name>` 输出 derived `.canvas.tsx` live view。省略 flag 行为不变。`--init-only` + Canvas 无需 `CURSOR_API_KEY`。
66
66
 
67
67
  - **Shell node**:`executor: "shell"` 串行跑确定性 `shell.commands`,每 command 有 `timeoutMs`;非零 exit / timeout 标 node `ERROR` 并将 command output 归档到 node result 目录。用于 verification fact,非 code repair。
68
- - **Pi node**:`executor: "pi"` 默认仅用 read-only tool(当前 DAG Pi executor 中 `read`、`grep`、`find`、`ls`),返回 Markdown 结论供 downstream node。声明 `toolProfile: "write"` 后同一个 Pi executor 使用 writer tools 并在执行后跑 write guard;必须配合 `writePolicy=exclusive`、`allowedPaths`、`forbiddenPaths`、`writeSet`。
68
+ - **Pi node**:`executor: "pi"` 默认仅用 read-only tool(当前 DAG Pi executor 中 `read`、`grep`、`find`、`ls`),返回 Markdown 结论供 downstream node。声明 `toolProfile: "write"` 后同一个 Pi executor 使用 writer tools 并在执行后跑 write guard;必须配合 `writePolicy=exclusive`、`allowedPaths`、`forbiddenPaths`、`writeSet`。
69
69
  - **Root `artifacts/` boundary**:root `artifacts/修改记录.md` 与 `artifacts/验证结果.md` 是 legacy / explicit-write 摘要,不是 Agent DAG read-only scratchpad,也不是新工作流默认 handoff。read-only DAG node 须在 node output 返回发现;runner-owned node artifacts 于 `.harness/dag-runs/<run-id>/` 是 per-run source of truth。
70
70
  - **Upstream output artifacts**:直接 `depends_on` 上游 stdout 超过 2000 字符时,runner 写 `<runDir>/<node-id>/stdout.md` 并在下游 `<upstream_context>` 提供 preview + artifact pointer map(绝对路径、`chars`、`sha256`)。下游 agent 可读 runner evidence,但 read-only node 仍不得编辑 `.harness/dag-runs/**`。
71
71
  - **`writePolicy=exclusive`** 要求非空 `writeSet`;same-rank exclusive node 的 `writeSet` 条目须 **disjoint**,否则 validation fail fast。v1 DAG 中声明 `writePolicy` 或 `writeSet` 任一即 opt-in write validation。
@@ -74,7 +74,7 @@ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <t
74
74
  - **Defaults caveat**:`defaults.skills` / `defaults.writePolicy` 生效。对 `cursor` / `pi` node,resolved skill 名亦由 DAG runner 映射为有界 inline `SKILL.md` instruction,审计于 `<node>/skills.json`;Pi 仍以 `noSkills` / `--no-skills` 运行,故非 Pi ResourceLoader loading。`defaults.executor`、`defaults.model`、`defaults.piBackend`、`defaults.contextProfile` 接受/保留但尚非 runtime default。runtime execution 用 node `executor` + node `complexity`;各 executor 内部自选 model。live contract 已移除 `models`;executor-specific routing 用 `executorModels`。
75
75
  - **默认无**跨 node Pi runtime reuse;各 Pi node 是独立 `executePiStep()` call。
76
76
  - **Prompt source**:每个 task 仅用一种 prompt source。v1-compatible DAG 用 inline `subtask_prompt`;markdown-backed prompt 用 canonical `subtask_prompt_markdown`。同时提供两字段、皆不提供、或用连字符 alias `subtask_prompt-markdown` 均 fail fast。
77
- - **勿宣称 live smoke 已通过**,除非真实 `run-dag` execution 中 Pi read-only、Pi writer、显式 Cursor 或 shell node 均按 DAG 完成。
77
+ - **勿宣称 live smoke 已通过**,除非真实 `run-dag` execution 中 Pi read-only、Pi writer、显式 Cursor 或 shell node 均按 DAG 完成。
78
78
 
79
79
  可复用 template:`docs/templates/agent-dag.base.json`(model 生成 DAG 的首选 base template)、`docs/templates/agent-dag.schema.json`(JSON Schema)、`docs/templates/agent-dag.supervised-implementation.json`(supervised implementation:writeSet audit、soft/hard verify、process supervisor、repair、review verdict gate)、`docs/templates/agent-dag-process-supervisor.prompt.md`、`docs/templates/agent-dag-review-verdict.prompt.md`、`docs/templates/agent-dag-authority-surface-audit.prompt.md`(可选 authority surface verifier;authority signal 或显式 enablement 匹配时由 `dag init-hybrid` 插入)、`examples/hybrid-loop-agent-dag.json`、`docs/templates/hybrid-dag.json`。
80
80
 
@@ -87,9 +87,9 @@ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <t
87
87
  **Supervised topology**(执行前替换所有 `REPLACE/WITH/...` placeholder):
88
88
 
89
89
  ```text
90
- contract-pi → scout-src ∥ scout-tests → plan-pi → write-set-audit-pi
91
- → write-set-gate-shell → implement-pi → soft-verify-shell → process-supervisor-pi → process-gate-shell
92
- → repair-pi → hard-verify-shell
90
+ contract-pi → scout-src ∥ scout-tests → plan-pi → write-set-audit-pi
91
+ → write-set-gate-shell → implement-pi → soft-verify-shell → process-supervisor-pi → process-gate-shell
92
+ → repair-pi → hard-verify-shell
93
93
  → [authority-surface-audit-pi → authority-surface-gate-shell] # 可选
94
94
  → review-pi → review-gate-shell → decision-pi → closeout-pi
95
95
  ```
@@ -101,7 +101,7 @@ contract-pi → scout-src ∥ scout-tests → plan-pi → write-set-audit-pi
101
101
  | `soft-verify-shell` | supervision 前归档 focused test exit code |
102
102
  | `process-supervisor-pi` | read-only audit coverage、boundary drift、verify gap、repair scope;应 prominently 输出 `VERDICT: pass` 或 `VERDICT: request-revision` |
103
103
  | `process-gate-shell` | supervisor node JSON 上 runtime `shell.verdictGate`(仅 `pass` 或 `request-revision`) |
104
- | `repair-pi` / optional `repair-cursor` | supervisor 请求 revision 时在 repair `writeSet` 内 bounded exclusive fix |
104
+ | `repair-pi` / optional `repair-cursor` | supervisor 请求 revision 时在 repair `writeSet` 内 bounded exclusive fix |
105
105
  | `hard-verify-shell` | lint/typecheck + `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 check-repo.sh` fact |
106
106
  | `authority-surface-audit-pi` + `authority-surface-gate-shell` | 可选 permission/state/tool-exposure audit;仅 authority signal 或显式 `authority-surface-audit` marker 时插入;gate 仅接受 `VERDICT: pass` |
107
107
  | `review-pi` + `review-gate-shell` | Critical/Important → `request-revision`;node JSON 上 `shell.verdictGate` block,除非 extracted verdict 行为 `VERDICT: pass` |
@@ -114,16 +114,16 @@ Prompt invariant:`docs/templates/agent-dag-process-supervisor.prompt.md`、`do
114
114
 
115
115
  ### Level 3 task-to-DAG(`dag init-hybrid` / `dag run-task`)
116
116
 
117
- ```bash
118
- loop-agent dag init-hybrid <task-id> [--output <temp-dir>/<task-id>-hybrid-dag.json]
119
- loop-agent dag run-task <task-id> [--output <temp-dir>/<task-id>-hybrid-dag.json] # 安全默认:仅 generate + validate,standard-compatible
117
+ ```bash
118
+ loop-agent dag init-hybrid <task-id> [--output <temp-dir>/<task-id>-hybrid-dag.json]
119
+ loop-agent dag run-task <task-id> [--output <temp-dir>/<task-id>-hybrid-dag.json] # 安全默认:仅 generate + validate,standard-compatible
120
120
  loop-agent dag run-task <task-id> --profile auto # 推断 candidate governanceProfile,再经 workflowPolicy 路由
121
121
  loop-agent dag run-task <task-id> --profile minimal # 强制当前 minimal 路由(standard-dag)
122
122
  loop-agent dag run-task <task-id> --profile standard # 强制 standard-dag
123
123
  loop-agent dag run-task <task-id> --profile reviewed # 强制 review-gated DAG
124
124
  loop-agent dag run-task <task-id> --profile supervised # 强制 supervised implementation DAG
125
125
  loop-agent dag run-task <task-id> --strict-models # 非 canonical executorModels 时失败
126
- loop-agent dag run-task <task-id> --no-cursor # 显式 no-Cursor 校验;generated cursor node 时失败
126
+ loop-agent dag run-task <task-id> --no-cursor # 显式 no-Cursor 校验;generated cursor node 时失败
127
127
  loop-agent dag run-task <task-id> --execute --cwd <repo-root> # 要求 narrowed implement writeSet
128
128
  loop-agent dag run-task <task-id> --dry-run --cwd <repo-root> # active snapshot 于 .harness/dag-runs/active/
129
129
  loop-agent dag run-task <task-id> --init-only --cwd <repo-root> # pending active snapshot,不执行 node
@@ -135,7 +135,7 @@ loop-agent dag run-task <task-id> --init-only --cwd <repo-root>
135
135
 
136
136
  ### DAG 与 artifacts source-of-truth 规则
137
137
 
138
- - 临时 DAG input spec 放平台原生临时目录(例如 `<temp-dir>/<topic>-dag.json`);可复用 template 放 `examples/` 或 `docs/templates/`。
138
+ - 临时 DAG input spec 放平台原生临时目录(例如 `<temp-dir>/<topic>-dag.json`);可复用 template 放 `examples/` 或 `docs/templates/`。
139
139
  - **不要**在 `.harness/dag-runs/active/` root 保留手写 DAG input 副本。
140
140
  - **不要**把 `.harness/dag-runs/` 内容 commit 到 git。
141
141
  - canonical per-run DAG 历史是 `.harness/dag-runs/completed/<run-id>/run.json` 及该 run 目录的 `state.json`、`executor.jsonl`、node artifacts;新建 run directory 使用 `YYYYMMDD-<slug>`。
@@ -161,7 +161,7 @@ loop-agent dag doctor
161
161
  loop-agent dag status --run-id <run-id>
162
162
  loop-agent dag report --paused-latest [--json|--markdown] # 最新 paused run;勿与 --lifecycle 并用
163
163
  loop-agent dag report [--run-id <run-id>] [--lifecycle active|paused|completed|all] [--json|--markdown] [--failed-only] [--latest] [--action <recovery-action>] # derived per-node report(只读);JSON schema: docs/templates/agent-dag-report.schema.json;仅 advisory — 见 docs/agent-dag-recovery-playbook.md
164
- loop-agent dag closeout-draft [--run-id <run-id>] [--output <path>] # M5:从 completed run facts 生成确定性 closeout draft;默认平台临时目录;仅 advisory;不 mutate completed facts
164
+ loop-agent dag closeout-draft [--run-id <run-id>] [--output <path>] # M5:从 completed run facts 生成确定性 closeout draft;默认平台临时目录;仅 advisory;不 mutate completed facts
165
165
  loop-agent promote-run <task-id> --run-id <run-id> # 从 completed DAG/one-shot evidence 汇总 task artifacts;不 mutate completed facts
166
166
  loop-agent closeout task <task-id> # 从 task artifacts 生成 docs/progress closeout
167
167
  loop-agent dag reconcile-tasks --glob '<pattern>' [--json|--markdown] # 仅报告的 task/run/artifact/verify drift audit
@@ -211,6 +211,6 @@ review-heavy DAG 中长 shell stdout 可能掩盖 proof 时,用 **evidence-sum
211
211
  | 10 | writeSet planning | scout 应列出链接的 `./skill/references/**` 为 **writeSet expansion candidates**(P2:遗漏链接 skill ref 迫使 main-session patch) |
212
212
  | 11 | Evidence summary | `evidence-summary-shell` / leading `EVIDENCE:` 行是 **practice convention**,非 runtime executor、schema field 或 parser |
213
213
  | 12 | Featureization | 除非 repeated real-run failure 证明 checklist guidance 不够,勿加 runtime/schema/validator/CLI/executor feature |
214
- | 13 | writeSet / writer backend | `exclusive` node 用 narrow、disjoint path;无 `**`;默认用 Pi write profile,仅在显式启用且 task-fit 时用 Cursor |
214
+ | 13 | writeSet / writer backend | `exclusive` node 用 narrow、disjoint path;无 `**`;默认用 Pi write profile,仅在显式启用且 task-fit 时用 Cursor |
215
215
  | 14 | Placeholders | 执行前将 `REPLACE/WITH/...` 换为具体 path |
216
216
  | 15 | Governance | in-flight shell:`HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`;archive 后:裸 `bash scripts/check-repo.sh` |
@@ -1,21 +1,21 @@
1
1
  # Learned loop-agent Patterns
2
2
 
3
- This directory is the human-gated target for SePO-lite prompt evolution.
3
+ 本目录是 SePO-lite prompt evolution human-gated target
4
4
 
5
5
  Rules:
6
6
 
7
- - Files are Markdown guidance only.
8
- - `retrospective` may propose `.harness/tasks/<task-id>/source/prompt-delta.md`; it must not merge here automatically.
9
- - Do not add shell commands, credential handling, tool permission expansion, or completion-authority bypass rules.
10
- - DAG implementer prompts may load the repo-specific file `<repo>.md` or `default.md` as bounded inline guidance when the node already requests the `loop-agent` skill.
11
- - Keep entries short and pattern-oriented: failure class, fix scope shape, invariant, and verification evidence.
7
+ - Files 仅为 Markdown guidance
8
+ - `retrospective` propose `.harness/tasks/<task-id>/source/prompt-delta.md`;不得自动 merge 到此。
9
+ - 不要添加 shell commandscredential handlingtool permission expansion completion-authority bypass rules
10
+ - DAG implementer prompts node request `loop-agent` skill 时,可将 repo-specific 文件 `<repo>.md` `default.md` 作为 bounded inline guidance 加载。
11
+ - 保持条目 short pattern-orientedfailure classfix scope shapeinvariantverification evidence
12
12
 
13
13
  Acceptance checklist before merging a prompt delta:
14
14
 
15
- - The proposal is Markdown-only process guidance.
16
- - It contains no shell/runtime command lines or fenced command blocks.
17
- - It does not ask to read, print, export, collect, or handle credentials, tokens, passwords, secrets, or API keys.
18
- - It does not expand tool permissions, path allowlists, `allowedPaths`, `forbiddenPaths`, or `writeSet`.
19
- - It does not skip or bypass shell verification, tests, write guards, decision gates, human gates, or completion evidence.
20
- - It does not modify, rewrite, delete, overwrite, or mutate completed DAG / one-shot run facts.
21
- - `loop-agent docs audit` passes after the learned file is edited.
15
+ - Proposal 仅为 Markdown-only process guidance
16
+ - 不含 shell/runtime command lines fenced command blocks
17
+ - Credential material、tokenspasswordssecrets API keys 保持不可触达。
18
+ - Tool permissionspath allowlists、`allowedPaths`、`forbiddenPaths` `writeSet` 保持既有边界。
19
+ - Shell verificationtestswrite guardsdecision gateshuman gates completion evidence 均为保留门禁。
20
+ - Completed DAG one-shot run facts 保持只读。
21
+ - Learned file 编辑后 `loop-agent docs audit` pass。
@@ -0,0 +1,59 @@
1
+ # Long-Running Loop 详细规则
2
+
3
+ 需要跨多轮记录目标、压缩记忆、round facts 引用,或使用 `loop init|status|run|record-round|add-signal|closeout` 时使用本文。`loop` 是 experimental outer workflow state:它不替代 Agent DAG,也不等同于已移除的顺序式 `run loop`。共享 policy 摘要见 `harness-policy.md` 的 "Long-running loop policy" 一节。
4
+
5
+ ## 最小入口
6
+
7
+ ```bash
8
+ loop-agent loop init <task-id>
9
+ loop-agent loop status <task-id>
10
+ loop-agent loop run <task-id> --action shell-verify --command "bash scripts/check-repo.sh"
11
+ loop-agent loop run <task-id> --action pi-review
12
+ loop-agent loop run <task-id> --action cursor-fix --model composer-2.5
13
+ loop-agent loop run <task-id> --action dag
14
+ loop-agent loop run <task-id> --action dag --execute
15
+ loop-agent loop run <task-id> --auto --max-rounds 3
16
+ loop-agent loop run <task-id> --auto --max-rounds 3 --allow-cursor-fix
17
+ loop-agent loop add-signal <task-id> --type human_followup --message "review this boundary before closeout"
18
+ loop-agent loop closeout <task-id>
19
+ loop-agent loop record-round <task-id> \
20
+ --action manual \
21
+ --result "summary" \
22
+ --lesson "what to carry forward" \
23
+ --next "next bounded action" \
24
+ --decision continue \
25
+ --ref ".harness/runs/completed/<run-id>/result.json"
26
+ ```
27
+
28
+ ## 状态源与记忆规则
29
+
30
+ - `loop/objective.md` 与 `loop/context.md` 是运行态投影;exec plan / task source 仍是需求状态源。
31
+ - `rounds.jsonl` 只引用 canonical facts,不复制完整 executor 日志。
32
+ - `context.md` 每轮重写为压缩记忆,不无限 append。
33
+ - `events.jsonl` 只用于 observability,覆盖 loop_start、round_start、action_start、action_finish、context_rewrite、decision、loop_finish;不要把 events 当状态源。
34
+
35
+ ## Action 规则
36
+
37
+ - `loop run --action shell-verify` 是 deterministic action;命令 exit code 决定 verification result,输出摘要写入 `loop/verification/round-N.json`。
38
+ - `loop run --action pi-review` 必须保持 read-only;工具 allowlist 固定为 `read,grep,find,ls`,输出必须包含 `findingSummary`、`failureCategory`、`nextHypothesis`、`recommendedAction`、`fixScope`、`rootCause`,其中 `recommendedAction` 只能是 `implement_fix|replan|pause|done`。
39
+ - `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/`。
40
+ - `cursor-fix` 只表示 bounded write round 已执行;它不会把 loop 标记 complete,下一步必须进入 `shell-verify` 或 review。
41
+ - `loop run --action dag` 默认是 review mode:调用 `dag run-task <task-id> --profile auto --strict-models` 生成 DAG,再用 `dag validate --strict-models --strict-governance` 校验,并记录 review packet。
42
+ - `loop run --action dag --execute` 才会调用 `run-dag`,随后读取 `dag report --json` 作为 round result;paused DAG 会让 loop 进入 `paused`。
43
+
44
+ ## Auto mode 与写入边界
45
+
46
+ - `loop run --auto --max-rounds N` 使用 deterministic policy 选择下一轮 action;默认只会自动选择 shell-verify、pi-review、dag review 或 policy pause/block,不自动触发 Cursor 写入。
47
+ - 自动 `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,不会绕过写入边界。
48
+ - auto mode 遇到同类 failure streak 达阈值会 blocked,避免无限重试。
49
+
50
+ ## Signals
51
+
52
+ - `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。
53
+ - Signals 不直接覆盖 `objective.md`;DAG decision envelope / approve / reject / resume 仍由 DAG action 机制管理,loop 只记录 refs。
54
+
55
+ ## Closeout
56
+
57
+ - `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。
58
+ - 非 complete 状态必须标 partial/paused/blocked,不能修改 completed facts;medium/large loop 若缺少 DAG round 且没有 `dagFallbackReason`,必须把缺失 DAG 证据列为 remaining risk。
59
+ - 完成声明仍必须由 shell verification、review verdict 和 success criteria coverage 证明。
@@ -17,7 +17,7 @@
17
17
 
18
18
  Agent DAG node 的模型来自 DAG JSON 中的 `executorModels`,并由 `dag validate --strict-models` 检查 canonical matrix 漂移。若变更模型配置,须同步更新 `harness.json`、相关测试、repo docs 与本 skill。
19
19
 
20
- `pi-prompt` 是独立 one-shot helper,不使用 `harness.json.models` 或 DAG `executorModels`。当前默认是 `wizard-local/glm-5.2`;高复杂度 one-shot 显式传 `--model gpt-5.5`。Agent DAG `pi` executor 的 canonical matrix 保持;读写 profile 共用同一矩阵:
20
+ `pi-prompt` 是独立 one-shot helper,不使用 `harness.json.models` 或 DAG `executorModels`。当前默认是 `wizard-local/glm-5.2`;高复杂度 one-shot 显式传 `--model gpt-5.5`。Agent DAG `pi` executor 的 canonical matrix 保持;读写 profile 共用同一矩阵:
21
21
 
22
22
  ```json
23
23
  {
@@ -98,7 +98,7 @@ main session 编排;不是默认 implementer。in-flight run 期间:
98
98
  | Inspect status / node artifacts | 始终允许 | progress 或 sidecar output 中的 notes |
99
99
  | Sidecar read-only Pi/Cursor prompt | 诊断、plan critique、log 解读 | resume 前的 findings |
100
100
  | Surgical patch | small、obvious、可 verify;无 active `writeSet` 冲突 | `docs/reports/` 或 exec plan,含 scope + verification |
101
- | DAG/source repair | topology、writeSet 或 prompt contract 错误 | 编辑平台临时目录中的 DAG 或 plan;re-validate;rerun |
101
+ | DAG/source repair | topology、writeSet 或 prompt contract 错误 | 编辑平台临时目录中的 DAG 或 plan;re-validate;rerun |
102
102
  | Approve/reject/resume | Decision Gate `pause-on-human` | 仅 CLI artifacts |
103
103
  | Post-DAG closeout | promotion、report、plan archive、indexes | `promote-run`、`closeout task`、`docs/reports/`、`docs/progress`、exec-plan indexes — 非 root `artifacts/`,除非 explicit narrow writeSet |
104
104
 
@@ -1,22 +1,22 @@
1
1
  # One-shot Pi SDK Prompt Helper(`pi-prompt`)
2
2
 
3
- 短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时使用本文。替代 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt` 的做法。
3
+ 短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时使用本文。替代 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt` 的做法。
4
4
 
5
5
  ### One-shot Pi SDK prompt helper
6
6
 
7
- 短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时,用 `loop-agent pi-prompt`,勿创建 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt`。`pi-prompt` 是一次性 full-capability helper;是否只读由本次调用的 prompt 与 `--tools` 决定。
7
+ 短时 Pi SDK task、不需要完整 `.harness/tasks/<id>` workflow 时,用 `loop-agent pi-prompt`,勿创建 ad-hoc 临时代码脚本导入 `executeSingleSdkAttempt`。`pi-prompt` 是一次性 full-capability helper;是否只读由本次调用的 prompt 与 `--tools` 决定。
8
8
 
9
9
  ```bash
10
- loop-agent pi-prompt "Reply with exactly OK."
11
- loop-agent pi-prompt --stdin < <temp-dir>/task.md
12
- loop-agent pi-prompt --file <temp-dir>/task.md
13
- loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools read,grep,find,ls "Review the current diff. Do not edit files."
10
+ loop-agent pi-prompt "Reply with exactly OK."
11
+ loop-agent pi-prompt --stdin < <temp-dir>/task.md
12
+ loop-agent pi-prompt --file <temp-dir>/task.md
13
+ loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools read,grep,find,ls "Review the current diff. Do not edit files."
14
14
  loop-agent pi-prompt --cwd ~/go/src/loop-agent --tools subagent,read --timeout 2400000 "Use subagent exactly once ..."
15
15
  loop-agent pi-prompt --model gpt-5.5 --cwd ~/go/src/loop-agent "Deeply diagnose this failure."
16
16
  loop-agent pi-prompt "Reply with exactly OK."
17
- ```
18
-
19
- `<temp-dir>` 表示平台原生临时目录;实际命令中使用本机路径。
17
+ ```
18
+
19
+ `<temp-dir>` 表示平台原生临时目录;实际命令中使用本机路径。
20
20
 
21
21
  默认:`--provider wizard-local --model glm-5.2`;高复杂度 one-shot 可显式 `--model gpt-5.5`。按需用 `--provider`、`--model`、`--thinking`、`--tools`、`--timeout` 覆盖。
22
22
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  loop-agent task 启用 `piSubagentMode`、在 analyze/plan/spec/retrospective 内需要 read-only scout/planner/reviewer subagents,或配置 project-local agents/prompts 时使用本文。
4
4
 
5
- ## Pi Subagent Assisted Mode
6
-
7
5
  `task.json` 支持可选字段 `piSubagentMode`,用于 step 级 `subagent` tool delegation:
8
6
 
9
7
  | Mode | analyze | plan | spec | implement | retrospective | verify |
@@ -22,13 +22,13 @@ DAG run、promotion、closeout 和最终验证完成后:
22
22
  ```
23
23
  1. new-task <id>
24
24
  2. 写 source/需求.md + source/执行约束.md
25
- 3. dag run-task <id> --profile auto --strict-models --output <temp-dir>/<id>-dag.json
26
- 4. dag validate --dag <temp-dir>/<id>-dag.json --strict-models --strict-governance
27
- 5. run-dag --dag <temp-dir>/<id>-dag.json --cwd <repo-root>
28
- 6. promote-run / closeout / final verification
29
- ```
30
-
31
- `<temp-dir>` 表示平台原生临时目录;实际命令中使用 macOS/Windows 本机路径。
25
+ 3. dag run-task <id> --profile auto --strict-models --output <temp-dir>/<id>-dag.json
26
+ 4. dag validate --dag <temp-dir>/<id>-dag.json --strict-models --strict-governance
27
+ 5. run-dag --dag <temp-dir>/<id>-dag.json --cwd <repo-root>
28
+ 6. promote-run / closeout / final verification
29
+ ```
30
+
31
+ `<temp-dir>` 表示平台原生临时目录;实际命令中使用 macOS/Windows 本机路径。
32
32
 
33
33
  **关键**:实现 work 由 DAG node 和 executor 执行;main session 负责审 DAG、审 writeSet、跑验证和 handoff。
34
34
 
@@ -6,18 +6,18 @@
6
6
 
7
7
  所有需要可恢复、可验证、可交接的实现工作都走 DAG 路径:
8
8
 
9
- ```bash
10
- loop-agent new-task <task-id> "Task Title"
11
- loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
12
- loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
13
- loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
14
- ```
15
-
16
- `<temp-dir>` 表示平台原生临时目录。实际文件路径必须兼容 macOS 和 Windows;只有 repo refs、JSON/Markdown 证据 refs 和 glob 约定默认使用 `/`。
17
-
18
- 当目标仓库是 loop-agent 本仓库时,`loop-agent` 命令必须来自 npm 上已发布的安装包。首次安装或有意升级可用 `@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 的任务;源码开发和 focused debugging 才使用 `npm run dev -- <args>`。
19
-
20
- 低风险的一行修正文档或配置时,可以由 main session 做 surgical patch,但仍必须记录 scope 并运行对应验证命令。
9
+ ```bash
10
+ loop-agent new-task <task-id> "Task Title"
11
+ loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
12
+ loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
13
+ loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
14
+ ```
15
+
16
+ `<temp-dir>` 表示平台原生临时目录。实际文件路径必须兼容 macOS 和 Windows;只有 repo refs、JSON/Markdown 证据 refs 和 glob 约定默认使用 `/`。
17
+
18
+ 当目标仓库是 loop-agent 本仓库时,`loop-agent` 命令必须来自 npm 上已发布的安装包。首次安装或有意升级可用 `@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 的任务;源码开发和 focused debugging 才使用 `npm run dev -- <args>`。
19
+
20
+ 低风险的一行修正文档或配置时,可以由 main session 做 surgical patch,但仍必须记录 scope 并运行对应验证命令。
21
21
 
22
22
  ## Source Materials
23
23
 
@@ -75,10 +75,10 @@ loop-agent --repo-root /path/to/target-repo <command>
75
75
  完成声明必须来自新鲜验证证据。按目标 repo 的 `docs/verification-matrix.md` 选择最小证明命令;loop-agent 自身常用:
76
76
 
77
77
  ```bash
78
- npm run typecheck
79
- npm test
80
- bash scripts/check-repo.sh
81
- bash scripts/ci.sh
82
- ```
83
-
84
- Windows 上通过 Git Bash 或配置好的兼容 Bash 运行 `scripts/*.sh`;不要把 POSIX 路径假设写入 CLI、模板或 task source。
78
+ npm run typecheck
79
+ npm test
80
+ bash scripts/check-repo.sh
81
+ bash scripts/ci.sh
82
+ ```
83
+
84
+ Windows 上通过 Git Bash 或配置好的兼容 Bash 运行 `scripts/*.sh`;不要把 POSIX 路径假设写入 CLI、模板或 task source。
@@ -4,6 +4,40 @@
4
4
 
5
5
  ## Verify strategy 与 completion audit
6
6
 
7
+ ## Production Readiness v0.1
8
+
9
+ 低/中风险单 repo DAG 任务如果声明 production-ready v0.1,必须按 `docs/production-readiness.md` 和 `docs/templates/production-readiness-checklist.md` 收口。
10
+
11
+ 支持范围:
12
+
13
+ - single repo
14
+ - bounded task
15
+ - explicit task source
16
+ - explicit `allowedPaths` / `forbiddenPaths` / write scope
17
+ - shell verification
18
+ - report / doctor / closeout handoff
19
+
20
+ 非目标:
21
+
22
+ - automatic merge
23
+ - automatic release
24
+ - production secrets
25
+ - production database
26
+ - high-risk migration
27
+ - online Worker Pool
28
+ - writable Dynamic Workflow sharded migration
29
+
30
+ 失败分类是路由字段,不是主状态;不要覆盖 `.harness/dag-runs/completed/**` 的原始事实。报告和 handoff 应保留:
31
+
32
+ ```text
33
+ raw_failure_category
34
+ dag_normalized_failure_category
35
+ product_line_failure_category
36
+ recommended_follow_up
37
+ ```
38
+
39
+ product-line taxonomy 的事实源是 `docs/design/state-and-failure-taxonomy.md`。
40
+
7
41
  ### Verify 始终在本地跑
8
42
  `verify` step 跑确定性命令(check-repo.sh + tests + typecheck)。**不**调用 pi。因此快且可靠。
9
43
 
@@ -56,6 +90,24 @@
56
90
 
57
91
  最佳实践:保持 `allowedPaths` 准确。auto-commit 用 task path 约束,避免把无关 dirty 文件扫进 progress commit。
58
92
 
93
+ ### Cursor bounded write 后的独立复核
94
+
95
+ Cursor bounded execution 完成后,主会话必须独立执行:
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
+ Cursor 自己报告的完成不算 verification fact;以上命令的 exit code 与输出才是完成声明的证据。
110
+
59
111
  ### 失败处理
60
112
 
61
113
  child agent 失败时:
@@ -72,3 +124,5 @@ loop-agent handoff check <task-id>
72
124
  ```
73
125
 
74
126
  active exec plan 实质完成时,用 `docs archive` 归档并更新 active/completed 索引,勿留 stale active status。
127
+
128
+ failed DAG run 不应生成成功式 closeout。它应该生成 failure handoff,至少包含 what failed、evidence、classification、recommended follow-up、safe retry conditions 和 human decision needed。
@@ -1,25 +1,25 @@
1
1
  ---
2
2
  name: requesting-code-review
3
- description: Use when completing tasks, implementing major features, or before merging to verify work meets requirements
3
+ description: 在完成任务、实现 major features,或 merge 前验证 work 是否满足 requirements 时使用
4
4
  ---
5
5
 
6
6
  # Requesting Code Review
7
7
 
8
- Dispatch a code reviewer subagent to catch issues before they cascade. The reviewer gets precisely crafted context for evaluation never your session's history. This keeps the reviewer focused on the work product, not your thought process, and preserves your own context for continued work.
8
+ Dispatch code reviewer subagent,在问题级联前捕获 issue。Reviewer 获得精确 crafted evaluation context — 绝不是你的 session history。这使 reviewer 聚焦 work product,而非你的 thought process,并保留你自己的 context 以继续工作。
9
9
 
10
- **Core principle:** Review early, review often.
10
+ **Core principle:** Review early, review often.
11
11
 
12
12
  ## When to Request Review
13
13
 
14
- **Mandatory:**
15
- - After each task in subagent-driven development
16
- - After completing major feature
17
- - Before merge to main
14
+ **Mandatory:**
15
+ - subagent-driven development 中每个 task 之后
16
+ - 完成 major feature 之后
17
+ - merge main 之前
18
18
 
19
- **Optional but valuable:**
20
- - When stuck (fresh perspective)
21
- - Before refactoring (baseline check)
22
- - After fixing complex bug
19
+ **Optional but valuable:**
20
+ - 卡住时(fresh perspective
21
+ - refactoring 前(baseline check
22
+ - 修复 complex bug 之后
23
23
 
24
24
  ## How to Request
25
25
 
@@ -29,19 +29,19 @@ BASE_SHA=$(git rev-parse HEAD~1) # or origin/main
29
29
  HEAD_SHA=$(git rev-parse HEAD)
30
30
  ```
31
31
 
32
- **2. Use the code reviewer template** (`code-reviewer.md` in this skill directory):
32
+ **2. Use the code reviewer template**(本 skill 目录下的 `code-reviewer.md`):
33
33
 
34
34
  **Placeholders:**
35
- - `{DESCRIPTION}` - Brief summary of what you built
36
- - `{PLAN_OR_REQUIREMENTS}` - What it should do (contract, exec plan, or requirements)
37
- - `{BASE_SHA}` - Starting commit
38
- - `{HEAD_SHA}` - Ending commit
35
+ - `{DESCRIPTION}` 简要 summary of what you built
36
+ - `{PLAN_OR_REQUIREMENTS}` 它应做什么(contractexec plan requirements
37
+ - `{BASE_SHA}` Starting commit
38
+ - `{HEAD_SHA}` Ending commit
39
39
 
40
40
  **3. Act on feedback:**
41
- - Fix Critical issues immediately
42
- - Fix Important issues before proceeding
43
- - Note Minor issues for later
44
- - Push back if reviewer is wrong (with reasoning)
41
+ - Critical issues 立即修复
42
+ - Important issues 在继续前修复
43
+ - Minor issues 稍后处理
44
+ - Reviewer 有误时 push back(附 reasoning
45
45
 
46
46
  ## Example
47
47
 
@@ -72,30 +72,30 @@ You: [Fix progress indicators]
72
72
 
73
73
  ## Integration with Harness Workflow
74
74
 
75
- **After each work chunk (Plan → Contract → Implement → Verify → Handoff):**
76
- - Review after Implement, before Verify
77
- - Catch issues before they compound
78
- - Fix before moving to next task
75
+ **每个 work chunk 之后(Plan → Contract → Implement → Verify → Handoff):**
76
+ - Implement 之后、Verify 之前 review
77
+ - 在问题 compound 前捕获
78
+ - 进入 next task 前修复
79
79
 
80
- **Before merge / Handoff:**
81
- - Review before declaring complete
82
- - Verify against contract acceptance criteria
80
+ **Before merge / Handoff:**
81
+ - 宣称 complete review
82
+ - 对照 contract acceptance criteria 验证
83
83
 
84
- **Ad-Hoc Development:**
85
- - Review before merge
86
- - Review when stuck
84
+ **Ad-Hoc Development:**
85
+ - merge review
86
+ - 卡住时 review
87
87
 
88
88
  ## Red Flags
89
89
 
90
- **Never:**
91
- - Skip review because "it's simple"
92
- - Ignore Critical issues
93
- - Proceed with unfixed Important issues
94
- - Argue with valid technical feedback
90
+ **Never:**
91
+ - "it's simple" 跳过 review
92
+ - 忽略 Critical issues
93
+ - 带着未修复的 Important issues 继续
94
+ - valid technical feedback 争辩
95
95
 
96
- **If reviewer wrong:**
97
- - Push back with technical reasoning
98
- - Show code/tests that prove it works
99
- - Request clarification
96
+ **If reviewer wrong:**
97
+ - technical reasoning push back
98
+ - 展示证明其有效的 code/tests
99
+ - 请求 clarification
100
100
 
101
- See template at: requesting-code-review/code-reviewer.md
101
+ Template 见:requesting-code-review/code-reviewer.md
@@ -1,8 +1,8 @@
1
1
  # Code Reviewer Prompt Template
2
2
 
3
- Use this template when dispatching a code reviewer subagent.
3
+ Dispatch code reviewer subagent 时使用本 template。
4
4
 
5
- **Purpose:** Review completed work against requirements and code quality standards before it cascades into more work.
5
+ **Purpose:** work cascade 成更多工作之前,对照 requirements code quality standards review completed work
6
6
 
7
7
  ```
8
8
  Task tool (general-purpose):
@@ -123,11 +123,11 @@ Task tool (general-purpose):
123
123
 
124
124
  **Placeholders:**
125
125
  - `{DESCRIPTION}` — brief summary of what was built
126
- - `{PLAN_OR_REQUIREMENTS}` — what it should do (plan file path, task text, or requirements)
126
+ - `{PLAN_OR_REQUIREMENTS}` — 它应做什么(plan file pathtask text requirements
127
127
  - `{BASE_SHA}` — starting commit
128
128
  - `{HEAD_SHA}` — ending commit
129
129
 
130
- **Reviewer returns:** Strengths, Issues (Critical / Important / Minor), Recommendations, Assessment
130
+ **Reviewer returns:** StrengthsIssues (Critical / Important / Minor)RecommendationsAssessment
131
131
 
132
132
  ## Example Output
133
133