@tea-agent/loop-agent 0.1.0 → 0.2.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 (100) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +127 -92
  3. package/dist/adapters/index.js +3 -2
  4. package/dist/adapters/loop-agent.js +44 -2
  5. package/dist/application/dag/args.js +420 -0
  6. package/dist/application/dag/generate-task-dag.js +280 -0
  7. package/dist/application/dag/report-dag.js +14 -0
  8. package/dist/application/dag/run-dag.js +93 -0
  9. package/dist/application/dag/validate-dag.js +101 -0
  10. package/dist/application/loop/run-action.js +23 -0
  11. package/dist/cli/catalog.js +2 -237
  12. package/dist/cli/command-definitions.js +571 -0
  13. package/dist/cli/index.js +2 -0
  14. package/dist/cli/program.js +65 -1
  15. package/dist/cli/router.js +13 -0
  16. package/dist/cli-governance/active-residue-check.js +38 -0
  17. package/dist/commands/dag-report.js +6 -107
  18. package/dist/commands/dag-run-task.js +8 -466
  19. package/dist/commands/dag-validate.js +7 -179
  20. package/dist/commands/examples.js +90 -0
  21. package/dist/commands/init.js +1495 -0
  22. package/dist/commands/loop.js +57 -31
  23. package/dist/commands/pi-prompt.js +2 -9
  24. package/dist/commands/run-dag.js +7 -180
  25. package/dist/executors/cursor-executor-artifacts.js +3 -4
  26. package/dist/executors/cursor-worker-client.js +13 -3
  27. package/dist/executors/dag-cursor-executor.js +2 -3
  28. package/dist/executors/dag-pi-executor.js +3 -4
  29. package/dist/executors/dag-static-executor.js +2 -5
  30. package/dist/executors/pi-defaults.js +9 -0
  31. package/dist/executors/shell-executor.js +12 -20
  32. package/dist/governance/manifest-types.js +1 -0
  33. package/dist/infrastructure/harness/active-residue-policy.js +73 -0
  34. package/dist/infrastructure/harness/artifact-store.js +72 -0
  35. package/dist/infrastructure/harness/atomic-write.js +49 -0
  36. package/dist/infrastructure/harness/completed-facts-guard.js +40 -0
  37. package/dist/infrastructure/harness/loop-action-store.js +23 -0
  38. package/dist/infrastructure/harness/loop-store.js +41 -0
  39. package/dist/infrastructure/harness/one-shot-run-store.js +94 -0
  40. package/dist/infrastructure/harness/task-store.js +77 -0
  41. package/dist/records/one-shot-runs.js +26 -61
  42. package/dist/records/promotion.js +3 -4
  43. package/dist/shared/artifacts-core.js +5 -5
  44. package/dist/shared/logger.js +9 -15
  45. package/dist/task/delegate.js +4 -4
  46. package/dist/task/runtime.js +5 -7
  47. package/dist/task/state.js +6 -20
  48. package/dist/workflows/dag/convergence/controller.js +277 -0
  49. package/dist/workflows/dag/dynamic-runtime/condition.js +48 -0
  50. package/dist/workflows/dag/dynamic-runtime/loop-until.js +156 -0
  51. package/dist/workflows/dag/dynamic-runtime/map.js +185 -0
  52. package/dist/workflows/dag/dynamic-runtime/reduction.js +72 -0
  53. package/dist/workflows/dag/dynamic-runtime/shared.js +133 -0
  54. package/dist/workflows/dag/lifecycle.js +6 -5
  55. package/dist/workflows/dag/node-execution.js +262 -0
  56. package/dist/workflows/dag/run-store.js +36 -0
  57. package/dist/workflows/dag/runner.js +82 -1341
  58. package/dist/workflows/dag/scheduler.js +84 -0
  59. package/dist/workflows/dag/upstream-artifacts.js +20 -18
  60. package/dist/workflows/loop/actions/cursor-fix.js +191 -0
  61. package/dist/workflows/loop/actions/dag-action.js +130 -0
  62. package/dist/workflows/loop/actions/pi-review.js +267 -0
  63. package/dist/workflows/loop/actions/shared.js +157 -0
  64. package/dist/workflows/loop/actions/shell-verify.js +82 -0
  65. package/dist/workflows/loop/actions/types.js +1 -0
  66. package/dist/workflows/loop/actions/workflow-action.js +255 -0
  67. package/dist/workflows/loop/actions.js +55 -1212
  68. package/dist/workflows/loop/closeout.js +5 -4
  69. package/dist/workflows/loop/context.js +2 -3
  70. package/dist/workflows/loop/events.js +3 -2
  71. package/dist/workflows/loop/policy/auto-policy.js +104 -0
  72. package/dist/workflows/loop/policy/cursor-fix-policy.js +31 -0
  73. package/dist/workflows/loop/rounds.js +3 -3
  74. package/dist/workflows/loop/signals.js +4 -7
  75. package/dist/workflows/loop/state.js +11 -11
  76. package/docs/README.md +3 -2
  77. package/docs/architecture/runtime-boundaries.md +147 -0
  78. package/docs/exec-plans/active/README.md +4 -0
  79. package/docs/exec-plans/completed/README.md +6 -2
  80. package/package.json +2 -1
  81. package/skills/ai-engineering-context/SKILL.md +21 -21
  82. package/skills/loop-agent/SKILL.md +73 -188
  83. package/skills/loop-agent/references/README.md +6 -2
  84. package/skills/loop-agent/references/harness-policy.md +113 -113
  85. package/skills/loop-agent/references/learned/README.md +13 -13
  86. package/skills/loop-agent/references/long-running-loop.md +59 -0
  87. package/skills/loop-agent/references/pi-subagent-assisted-mode.md +0 -2
  88. package/skills/loop-agent/references/verification-and-failure-handling.md +18 -0
  89. package/skills/requesting-code-review/SKILL.md +40 -40
  90. package/skills/requesting-code-review/code-reviewer.md +4 -4
  91. package/skills/systematic-debugging/CREATION-LOG.md +43 -43
  92. package/skills/systematic-debugging/SKILL.md +113 -113
  93. package/skills/systematic-debugging/condition-based-waiting.md +20 -20
  94. package/skills/systematic-debugging/defense-in-depth.md +27 -27
  95. package/skills/systematic-debugging/root-cause-tracing.md +38 -38
  96. package/skills/systematic-debugging/test-academic.md +6 -6
  97. package/skills/systematic-debugging/test-pressure-1.md +6 -6
  98. package/skills/systematic-debugging/test-pressure-2.md +2 -2
  99. package/skills/systematic-debugging/test-pressure-3.md +6 -6
  100. package/skills/verification-before-completion/SKILL.md +37 -37
@@ -1,15 +1,15 @@
1
1
  # Shared loop-agent Harness Policy
2
2
 
3
- This file is the canonical shared workflow policy for using `.` across repositories. Repo-local harness docs should only describe local adapters: where the runtime lives, which governance root to use, and which verification commands apply.
3
+ 本文件是跨仓库使用 `.` canonical shared workflow policyRepo-local harness docs 只应描述 local adaptersruntime 位置、governance root、适用的 verification commands
4
4
 
5
5
  ## Canonical stance
6
6
 
7
- - **Agent DAG** is the default implementation workflow for medium/large, multi-file, architecture-sensitive, public-contract, CI/script, or harness-runtime work.
8
- - The historical sequential `run analyze|plan|spec|implement|verify|auto|loop|continue` workflow has been removed. Do not present it as a fallback path.
9
- - **Long-running `loop`** is an outer state/evidence layer above Agent DAG. It records rounds, context compression, signals, and canonical refs; it must not replace DAG writeSet review, Decision Gate, or shell verification for complex work.
10
- - **Main session** orchestrates: choose one work chunk, prepare source materials, review DAG/writeSet, monitor failures, run final verification, and hand off.
11
- - **Executors** implement bounded work: Cursor writes within explicit paths, Pi performs read-only planning/review/diagnosis in DAG nodes, shell produces deterministic verification facts.
12
- - **Shell verification is the completion fact source**. LLM review or advisory output cannot replace command exit codes and archived evidence.
7
+ - **Agent DAG** medium/largemulti-filearchitecture-sensitivepublic-contractCI/script harness-runtime 工作的默认 implementation workflow。
8
+ - 历史顺序式 `run analyze|plan|spec|implement|verify|auto|loop|continue` workflow 已移除。不要将其作为 fallback path 呈现。
9
+ - **Long-running `loop`** Agent DAG 之上的 outer state/evidence layer。它记录 roundscontext compressionsignalscanonical refs;不得替代 complex work DAG writeSet reviewDecision Gate shell verification
10
+ - **Main session** 负责 orchestrate:选一个 work chunk、准备 source materialsreview DAG/writeSetmonitor failures、跑 final verificationhand off
11
+ - **Executors** 实现 bounded work:Pi DAG nodes read-only planning/review/diagnosis,并在节点声明 `toolProfile: "write"` 时做 bounded implementation/repair;Cursor 是显式启用的可选 bounded writer;shell 产出 deterministic verification facts
12
+ - **Shell verification completion fact source**。LLM review advisory output 不能替代 command exit codes archived evidence
13
13
 
14
14
  ## Command surface tiers
15
15
 
@@ -21,7 +21,7 @@ This file is the canonical shared workflow policy for using `.` across repositor
21
21
  | Escape hatch | Isolated delegation, one-shot diagnosis or bounded repair | `delegate`, `worktree`, `harvest`, `pi-prompt`, `cursor-prompt`, `cursor-worker` |
22
22
  | Experimental | Long-running outer task state | `loop init|status|run|record-round|add-signal|closeout` |
23
23
 
24
- Prompt templates, README snippets, and task instructions should present Primary + Operator first. Compatibility and escape-hatch commands remain available, but must carry their downgrade/fallback meaning.
24
+ Prompt templatesREADME snippetstask instructions 应优先呈现 Primary + OperatorCompatibility escape-hatch commands 仍可用,但须携带其 downgrade/fallback 含义。
25
25
 
26
26
  ## Entry selection decision tree
27
27
 
@@ -33,34 +33,34 @@ Is this only status, diagnosis, recovery, or closeout?
33
33
  yes -> Agent DAG.
34
34
  ```
35
35
 
36
- Use Agent DAG rather than broad one-shot execution when any of these signals apply:
37
-
38
- - loop-agent runtime, DAG schema, run facts, promotion/closeout, scripts/CI, public contract, or shared protocol is touched.
39
- - The change needs multiple files, multiple scouts, review gates, Decision Gate, repair flow, or shell gate.
40
- - `writeSet` is broad, multiple exclusive writers exist, or public interfaces / architecture boundaries change.
41
- - Requirement, architecture, credential, cost, deployment, security, or authority surface is unclear.
42
- - A failure repeats and needs recovery planning rather than blind retry.
36
+ 在以下任一 signal 适用时用 Agent DAG 而非 broad one-shot execution
37
+
38
+ - loop-agent runtime, DAG schema, run facts, promotion/closeout, scripts/CI, public contract, or shared protocol is touched.
39
+ - The change needs multiple files, multiple scouts, review gates, Decision Gate, repair flow, or shell gate.
40
+ - `writeSet` is broad, multiple exclusive writers exist, or public interfaces / architecture boundaries change.
41
+ - Requirement, architecture, credential, cost, deployment, security, or authority surface is unclear.
42
+ - A failure repeats and needs recovery planning rather than blind retry.
43
43
 
44
44
  ## Agent DAG path
45
45
 
46
- Minimum governed path:
46
+ Minimum governed path
47
47
 
48
48
  ```bash
49
49
  loop-agent new-task <task-id> "Task Title" [--repo-root <target-repo>]
50
50
  # write <target-repo>/.harness/tasks/<task-id>/source/需求.md
51
51
  # write <target-repo>/.harness/tasks/<task-id>/source/执行约束.md
52
52
 
53
- loop-agent dag run-task <task-id> \
54
- --profile auto \
55
- --strict-models \
56
- --output <temp-dir>/<task-id>-dag.json \
57
- [--repo-root <target-repo>]
58
-
59
- loop-agent dag validate \
60
- --dag <temp-dir>/<task-id>-dag.json \
61
- --strict-models \
62
- --strict-governance
63
-
53
+ loop-agent dag run-task <task-id> \
54
+ --profile auto \
55
+ --strict-models \
56
+ --output <temp-dir>/<task-id>-dag.json \
57
+ [--repo-root <target-repo>]
58
+
59
+ loop-agent dag validate \
60
+ --dag <temp-dir>/<task-id>-dag.json \
61
+ --strict-models \
62
+ --strict-governance
63
+
64
64
  loop-agent run-dag \
65
65
  --dag <temp-dir>/<task-id>-dag.json \
66
66
  --cwd <target-repo>
@@ -69,27 +69,27 @@ loop-agent run-dag \
69
69
  `loop-agent` is the preferred global CLI. For self-hosting loop-agent development, the controller must be an installed npm-published package. Use `npm install -g @tea-agent/loop-agent@latest` for first install or intentional upgrades, then treat the installed version as frozen for the current task and record `npm list -g @tea-agent/loop-agent --depth=0`. Do not repeatedly fetch `npx @latest` inside DAG nodes, and do not use the current working tree's `npm link` or `npm run dev` to control tasks that may edit CLI, DAG runtime, executors, package metadata, or build output. Use `npm run dev -- <args>` only for source debugging and focused CLI development.
70
70
 
71
71
  The npm package carries static capability assets: `skills/`, top-level governance docs, `docs/templates/`, `examples/`, `harness.json`, `AGENTS.md`, `README.md`, and `CHANGELOG.md`. Generated or historical task facts under `docs/progress/`, `docs/reports/`, `docs/exec-plans/`, and `docs/decisions/` belong to the target repository; package only their directory README files, not prior run content.
72
-
72
+
73
73
  For arbitrary target repositories, DAG skill instructions must not depend on loop-agent source history being copied into the target repo. Resolve configured, user, or target-local skills when present, then fall back to package-bundled `skills/` as the stable default capability set.
74
74
 
75
75
  `<temp-dir>` means the platform-native temp directory. Use native paths for actual `--output`, `--dag`, and `--cwd` values on macOS and Windows; use `/` only for stable repo refs, JSON/Markdown evidence refs, and glob conventions.
76
76
 
77
- Before execution, review `dag run-task` JSON / `reviewPacket`:
77
+ Execution review `dag run-task` JSON / `reviewPacket`:
78
78
 
79
- - `profileRouting`: requested profile, selected profile/template, routing reasons.
80
- - `governanceProfile`: process, delivery, and code-change signals.
81
- - Writer nodes: `writePolicy`, `writeSet`, `allowedPaths`, `forbiddenPaths`, broad entries, forbidden overlaps.
82
- - Shell gates and verification commands.
83
- - Decision Gate mode (`record-only` vs `pause-on-human`).
84
- - Any placeholder, `**`, or repo-root writeSet that must be narrowed before execution.
79
+ - `profileRouting`:requested profileselected profile/templaterouting reasons
80
+ - `governanceProfile`:processdeliverycode-change signals
81
+ - Writer nodes:`writePolicy`、`writeSet`、`allowedPaths`、`forbiddenPaths`、broad entriesforbidden overlaps
82
+ - Shell gates verification commands
83
+ - Decision Gate mode(`record-only` vs `pause-on-human`)。
84
+ - 执行前须 narrow 的 placeholder、`**` repo-root writeSet
85
85
 
86
- In-flight DAG shell checks should use the repo's active-run override when required (for example `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`). After the DAG is archived, run the repo check again without the in-flight override.
87
-
88
- On Windows, run Bash scripts through Git Bash or a configured compatible Bash. Do not require WSL, `/tmp`, `which`, or other POSIX filesystem assumptions in loop-agent CLI behavior.
86
+ In-flight DAG shell checks 在需要时用 repo active-run override(例如 `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`)。DAG archived 后,再不带 in-flight override 跑 repo check。
87
+
88
+ On Windows, run Bash scripts through Git Bash or a configured compatible Bash. Do not require WSL, `/tmp`, `which`, or other POSIX filesystem assumptions in loop-agent CLI behavior.
89
89
 
90
90
  ## Task source materials
91
91
 
92
- Every handoff-ready task has:
92
+ 每个 handoff-ready task 包含:
93
93
 
94
94
  ```text
95
95
  .harness/tasks/<task-id>/
@@ -99,25 +99,25 @@ Every handoff-ready task has:
99
99
  执行约束.md
100
100
  ```
101
101
 
102
- `需求.md` should state objective, scope, non-goals, acceptance criteria, and links to repo-local specs or plans.
102
+ `需求.md` 应陈述 objectivescopenon-goalsacceptance criteria,并链接 repo-local specs plans
103
103
 
104
- `执行约束.md` should state:
104
+ `执行约束.md` 应陈述:
105
105
 
106
106
  - allowed paths
107
107
  - forbidden paths
108
- - current dirty workspace / protected user changes, if any
109
- - architecture boundaries and invariants
108
+ - 当前 dirty workspace / protected user changes(如有)
109
+ - architecture boundaries invariants
110
110
  - expected verification commands
111
111
  - acceptance criteria / failure conditions
112
- - whether DAG fallback is allowed, and the fallback reason if already known
112
+ - 是否允许 DAG fallback,及若已知时的 fallback reason
113
113
 
114
- If source materials change after `spec`, `plan`, or DAG generation, regenerate or revalidate the plan/DAG before implementation.
114
+ `spec`、`plan` DAG generation 后 source materials 变更,implementation 前 regenerate revalidate plan/DAG
115
115
 
116
116
  ## Long-running loop policy
117
117
 
118
- `loop` is for long-running outer task memory: objective/context projection, round records, signals, derived events, verification summaries, and closeout draft. It is not a substitute for Agent DAG.
118
+ `loop` 用于 long-running outer task memoryobjective/context projectionround recordssignalsderived eventsverification summariescloseout draft。它不是 Agent DAG substitute
119
119
 
120
- Typical loop path for governed work:
120
+ Governed work 的典型 loop path
121
121
 
122
122
  ```bash
123
123
  loop-agent loop init <task-id>
@@ -130,22 +130,22 @@ loop-agent loop run <task-id> --auto --max-rounds 3 --allow-cursor-fix
130
130
  loop-agent loop closeout <task-id>
131
131
  ```
132
132
 
133
- Loop action rules:
133
+ Loop action rules
134
134
 
135
- - `shell-verify` is deterministic; exit code determines the verification record.
136
- - `pi-review` is read-only; tools are limited to `read,grep,find,ls` and output is structured advisory evidence. Its structured JSON must include `findingSummary`, `failureCategory`, `nextHypothesis`, `recommendedAction`, `fixScope`, and `rootCause`; `recommendedAction` is exactly `implement_fix|replan|pause|done`.
137
- - `cursor-fix` is bounded write; it must read task `allowedPaths` / `forbiddenPaths`, reject empty `allowedPaths`, reject allowed/forbidden overlap, preserve unrelated files, and be followed by shell verification or review.
138
- - For `task.json.complexity = medium | large`, `cursor-fix` additionally requires either:
139
- - a previous loop `dag` round, or
140
- - an explicit `task.json.dagFallbackReason` explaining why DAG could not be used.
141
- - `loop run --auto` does not write by default. Auto `cursor-fix` requires `task.json.loopAutoWritePolicy="enabled"`, or `loopAutoWritePolicy="approval-required"` plus a pending approval signal or `--allow-cursor-fix`; write guards still fail closed and pause.
142
- - `loop closeout` must report workflow path: `dag`, `explicit-fallback`, `missing-dag-evidence`, or `micro-or-small`.
143
- - Medium/large closeout without DAG evidence and without `dagFallbackReason` must list that as a remaining risk.
144
- - `record-round --decision complete` is only a loop-state candidate; completion still requires shell verification, review verdict, and success-criteria coverage.
135
+ - `shell-verify` deterministicexit code 决定 verification record
136
+ - `pi-review` read-onlytools 限于 `read,grep,find,ls`,output structured advisory evidence。Structured JSON 须含 `findingSummary`、`failureCategory`、`nextHypothesis`、`recommendedAction`、`fixScope`、`rootCause`;`recommendedAction` exactly `implement_fix|replan|pause|done`。
137
+ - `cursor-fix` bounded write;须读 task `allowedPaths` / `forbiddenPaths`,reject empty `allowedPaths`、allowed/forbidden overlappreserve unrelated files,且须 follow shell verification review
138
+ - `task.json.complexity = medium | large`,`cursor-fix` additionally 需要:
139
+ - previous loop `dag` round,或
140
+ - explicit `task.json.dagFallbackReason` 说明为何不能用 DAG
141
+ - `loop run --auto` 默认不 writeAuto `cursor-fix` 需要 `task.json.loopAutoWritePolicy="enabled"`,或 `loopAutoWritePolicy="approval-required"` pending approval signal `--allow-cursor-fix`;write guards fail closed pause
142
+ - `loop closeout` 须报告 workflow path:`dag`、`explicit-fallback`、`missing-dag-evidence` `micro-or-small`。
143
+ - DAG evidence 且无 `dagFallbackReason` medium/large closeout 须将其列为 remaining risk
144
+ - `record-round --decision complete` 仅是 loop-state candidatecompletion 仍须 shell verificationreview verdictsuccess-criteria coverage
145
145
 
146
146
  ## Supervised DAG convergence
147
147
 
148
- Supervised DAG convergence is optional and task-config driven:
148
+ Supervised DAG convergence 可选且由 task-config 驱动:
149
149
 
150
150
  ```json
151
151
  {
@@ -160,34 +160,34 @@ Supervised DAG convergence is optional and task-config driven:
160
160
 
161
161
  Rules:
162
162
 
163
- - Default remains single repair unless `convergence.enabled=true`; `HARNESS_DAG_CONVERGENCE=off` is the rollback switch.
164
- - The supervised process supervisor must emit first-line `VERDICT:` and a `REPAIR_ARTIFACT_JSON` fenced block. Repair prompts should consume artifact `failureClass`, `rootCause`, `fixScope`, and `invariant` first; raw logs are fallback evidence only when the artifact allows it.
165
- - On retryable `hard-verify-shell` failure before `maxPasses`, preserve current pass evidence under `convergence/pass-N/`, reset the process-supervisor/process-gate/repair/hard-verify segment plus blocked downstream nodes, and re-enter the existing DAG rank execution loop.
166
- - Do not retry write guards, timeout/spawn/auth failures, or human-gate failures.
167
- - Pause instead of retrying when conservative regression signals appear, such as a lower shell success count.
168
- - `dag report --json` and markdown must expose `convergence.passHistory`.
169
- - Final completion authority remains full shell verification; quota/focused commands are intermediate cost controls only.
170
-
171
- ## Structured repair, spine audit, and curator gates
163
+ - 默认保持 single repair,除非 `convergence.enabled=true`;`HARNESS_DAG_CONVERGENCE=off` rollback switch
164
+ - Supervised process supervisor emit 首行 `VERDICT:` `REPAIR_ARTIFACT_JSON` fenced blockRepair prompts 应先消费 artifact `failureClass`、`rootCause`、`fixScope`、`invariant`;raw logs 仅在 artifact 允许时为 fallback evidence
165
+ - `maxPasses` 前 retryable `hard-verify-shell` failure 时,preserve current pass evidence `convergence/pass-N/`,reset process-supervisor/process-gate/repair/hard-verify segment blocked downstream nodes,再进入现有 DAG rank execution loop
166
+ - 不要 retry write guardstimeout/spawn/auth failures human-gate failures
167
+ - 出现 conservative regression signals(如 lower shell success count)时 pause 而非 retry。
168
+ - `dag report --json` markdown expose `convergence.passHistory`。
169
+ - Final completion authority 仍是 full shell verificationquota/focused commands 仅为 intermediate cost controls
172
170
 
173
- - `shell.repairArtifactGate.fromNodeId` validates the upstream supervisor artifact before repair. Missing/invalid JSON, missing request-revision `fixScope`, or scope outside the downstream repair writer allowedPaths/writeSet fails closed.
174
- - `spine audit <task-id>` is the deterministic minimal spec spine checker for task source, ownership paths, requirement coverage, and final verification commands.
175
- - `dag validate --strict-governance --spine-task <task-id>` may consume the same spine audit as part of strict validation.
176
- - `knowledge curate` reads completed convergence patterns and writes only human-gated proposal Markdown after skill safety preflight.
171
+ ## Structured repair, spine audit, and curator gates
172
+
173
+ - `shell.repairArtifactGate.fromNodeId` validates the upstream supervisor artifact before repair. Missing/invalid JSON, missing request-revision `fixScope`, or scope outside the downstream repair writer allowedPaths/writeSet fails closed.
174
+ - `spine audit <task-id>` is the deterministic minimal spec spine checker for task source, ownership paths, requirement coverage, and final verification commands.
175
+ - `dag validate --strict-governance --spine-task <task-id>` may consume the same spine audit as part of strict validation.
176
+ - `knowledge curate` reads completed convergence patterns and writes only human-gated proposal Markdown after skill safety preflight.
177
177
 
178
178
  ## SePO-lite prompt evolution
179
179
 
180
- - Learned prompt deltas are human-gated proposals; they must be reviewed before becoming reusable guidance.
181
- - Prompt deltas are Markdown-only process guidance; they must not include shell commands, credential handling, tool permission expansion, or completion-authority bypass.
182
- - Accepted learned guidance lives under `./skill/references/learned/<repo>.md` or `default.md`.
183
- - DAG implementer prompts that already request `loop-agent` may inline at most three human-gated learned Markdown sections.
184
- - Learned guidance is advisory and never replaces writeSet governance, Decision Gate policy, or shell verification.
180
+ - Learned prompt deltas human-gated proposals;成为 reusable guidance 前须 review。
181
+ - Prompt deltas Markdown-only process guidance;不得含 shell commandscredential handlingtool permission expansion completion-authority bypass
182
+ - Accepted learned guidance 位于 `./skill/references/learned/<repo>.md` `default.md`。
183
+ - request `loop-agent` DAG implementer prompts inline 最多三个 human-gated learned Markdown sections
184
+ - Learned guidance advisory,永不替代 writeSet governanceDecision Gate policy shell verification
185
185
 
186
186
  ## Sidecar interventions
187
187
 
188
- `pi-prompt` and `cursor-prompt` are sidecar interventions, not workflow state.
188
+ `pi-prompt` `cursor-prompt` sidecar interventions,不是 workflow state
189
189
 
190
- Use `pi-prompt` for short read-only planning, log explanation, or failure diagnosis. When read-only, pass read-only tools and say not to edit files:
190
+ `pi-prompt` 做短时 read-only planninglog explanation failure diagnosis。Read-only 时传 read-only tools 并写明不 edit files
191
191
 
192
192
  ```bash
193
193
  loop-agent pi-prompt \
@@ -197,7 +197,7 @@ loop-agent pi-prompt \
197
197
  "Read the task source and diagnose the failure. Do not edit files."
198
198
  ```
199
199
 
200
- Use `cursor-prompt` for bounded multi-file diagnosis or small repair only when the prompt includes:
200
+ `cursor-prompt` bounded multi-file diagnosis small repairprompt 须含:
201
201
 
202
202
  - task id
203
203
  - exact objective
@@ -207,52 +207,52 @@ Use `cursor-prompt` for bounded multi-file diagnosis or small repair only when t
207
207
  - expected verification
208
208
  - instruction to preserve unrelated files
209
209
 
210
- Sidecar output is advisory. If it must become task evidence, promote or summarize it through loop-agent run/task artifacts; do not manually mutate completed DAG or one-shot run facts.
210
+ Sidecar output advisory。若须成为 task evidence,通过 loop-agent run/task artifacts promote summarize;completed DAG one-shot run facts 保持只读。
211
211
 
212
212
  ## Model and executor boundaries
213
213
 
214
- - Agent DAG uses DAG JSON `executorModels` plus node `executor` / `complexity`; do not infer DAG models from repo `harness.json.models`.
215
- - DAG `shell` and `static` nodes do not use models.
216
- - Historical step models under `harness.json.models.<step>` are legacy metadata, not routing for new DAG work.
217
- - `pi-prompt` / `cursor-prompt` models come from CLI flags or runtime defaults and must be selected per intervention.
218
- - Pi DAG nodes are read-only planning/review/diagnosis by default.
219
- - Cursor nodes are bounded writers and must have explicit write scope.
220
- - Shell nodes produce deterministic verification facts and gates.
214
+ - Agent DAG DAG JSON `executorModels` node `executor` / `complexity`;不要从 repo `harness.json.models` 推断 DAG models。
215
+ - DAG `shell` `static` nodes 不用 models
216
+ - `harness.json.models.<step>` historical step models legacy metadata,不是新 DAG work 的 routing。
217
+ - `pi-prompt` / `cursor-prompt` models 来自 CLI flags runtime defaults,须 per intervention 选择。
218
+ - Pi DAG nodes 默认 read-only planning/review/diagnosis;声明 `toolProfile: "write"` 时是 bounded writers,须有 explicit write scope。
219
+ - Cursor nodes 是显式启用的可选 bounded writers,须有 explicit write scope
220
+ - Shell nodes 产出 deterministic verification facts gates
221
221
 
222
222
  ## Artifacts and facts boundary
223
223
 
224
- - `.harness/tasks/<task-id>/` is task runtime state.
225
- - `.harness/tasks/<task-id>/loop/` is loop runtime projection; it does not replace task source or repo specs.
226
- - `.harness/dag-runs/{active,paused,completed}/<run-id>/` is DAG run fact storage. Completed facts are read-only.
227
- - `.harness/runs/{active,completed,failed}/<run-id>/` is one-shot Pi/Cursor evidence. Completed/failed facts are read-only.
228
- - Root `artifacts/` is legacy/current-work summary space, not a DAG read-only scratchpad and not default handoff for new DAG work.
229
- - Long-term conclusions belong in repo governance docs, progress, reports, decisions, tests, or scripts.
224
+ - `.harness/tasks/<task-id>/` task runtime state
225
+ - `.harness/tasks/<task-id>/loop/` loop runtime projection;不替代 task source repo specs
226
+ - `.harness/dag-runs/{active,paused,completed}/<run-id>/` DAG run fact storageCompleted facts read-only
227
+ - `.harness/runs/{active,completed,failed}/<run-id>/` one-shot Pi/Cursor evidenceCompleted/failed facts read-only
228
+ - Root `artifacts/` legacy/current-work summary space,不是 DAG read-only scratchpad,也不是新 DAG work default handoff
229
+ - Long-term conclusions 属于 repo governance docsprogressreportsdecisionstests scripts
230
230
 
231
- Do not submit runtime histories from `.harness/dag-runs/`, `.harness/runs/`, or `.harness/cache/` unless a task explicitly promotes a trimmed report into repo governance docs.
231
+ 除非 task 显式 promote trimmed report 到 repo governance docs,不要提交 `.harness/dag-runs/`、`.harness/runs/` `.harness/cache/` runtime histories。
232
232
 
233
233
  ## Baseline, dirty workspace, and verification
234
234
 
235
- Before complex implementation:
235
+ Complex implementation 前:
236
236
 
237
- 1. Check current directory and target repo.
238
- 2. Read repo entrypoints (`README`, `AGENTS`, `harness.json`, governance index).
239
- 3. Capture minimal baseline verification for the affected area.
240
- 4. If the workspace is dirty, choose one:
241
- - isolated worktree, or
242
- - explicit user confirmation to work in the current workspace and preserve/possibly include existing changes.
243
- 5. Record known baseline failures with enough detail to distinguish pre-existing failures from task regressions.
237
+ 1. Check current directory target repo
238
+ 2. Read repo entrypoints(`README`、`AGENTS`、`harness.json`、governance index)。
239
+ 3. Capture affected area 的 minimal baseline verification
240
+ 4. workspace dirty,选一:
241
+ - isolated worktree,或
242
+ - explicit user confirmation 在当前 workspace 工作并 preserve/possibly include existing changes
243
+ 5. Record known baseline failures,足以区分 pre-existing failures task regressions
244
244
 
245
- Verification should be selected from the target repo's verification matrix. For cross-repo documentation refactors, run checks in each affected repo.
245
+ Verification 应从 target repo verification matrix 选择。Cross-repo documentation refactors 时在 each affected repo 跑 checks。
246
246
 
247
247
  ## Handoff requirements
248
248
 
249
- Every task handoff should answer:
249
+ 每个 task handoff 应回答:
250
250
 
251
- 1. What changed and why.
252
- 2. Which workflow path was used: DAG, sidecar, or main-session surgical patch.
253
- 3. If downgraded from DAG, the explicit reason and evidence.
254
- 4. Executors used and their boundaries.
255
- 5. Verification commands run and results.
256
- 6. DAG / one-shot / loop refs, if any.
257
- 7. Remaining risks and follow-up tasks.
258
- 8. Whether new rules should be promoted to docs, tests, scripts, or shared skill references.
251
+ 1. What changed and why
252
+ 2. 用了哪条 workflow pathDAGsidecar main-session surgical patch
253
+ 3. 若从 DAG downgrade,explicit reason evidence
254
+ 4. Executors used 及其 boundaries
255
+ 5. Verification commands run results
256
+ 6. DAG / one-shot / loop refs(如有)。
257
+ 7. Remaining risks follow-up tasks
258
+ 8. 是否应将 new rules promote docstestsscripts shared skill references
@@ -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 证明。
@@ -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 |
@@ -56,6 +56,24 @@
56
56
 
57
57
  最佳实践:保持 `allowedPaths` 准确。auto-commit 用 task path 约束,避免把无关 dirty 文件扫进 progress commit。
58
58
 
59
+ ### Cursor bounded write 后的独立复核
60
+
61
+ Cursor bounded execution 完成后,主会话必须独立执行:
62
+
63
+ ```bash
64
+ git status --short
65
+ git diff --stat
66
+ bash scripts/check-repo.sh
67
+ npm run lint
68
+ npm test
69
+ npm run typecheck
70
+ loop-agent inspect
71
+ loop-agent docs audit
72
+ loop-agent handoff check <task-id>
73
+ ```
74
+
75
+ Cursor 自己报告的完成不算 verification fact;以上命令的 exit code 与输出才是完成声明的证据。
76
+
59
77
  ### 失败处理
60
78
 
61
79
  child agent 失败时:
@@ -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