@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.
- package/CHANGELOG.md +17 -1
- package/README.md +127 -92
- package/dist/adapters/index.js +3 -2
- package/dist/adapters/loop-agent.js +44 -2
- package/dist/application/dag/args.js +420 -0
- package/dist/application/dag/generate-task-dag.js +280 -0
- package/dist/application/dag/report-dag.js +14 -0
- package/dist/application/dag/run-dag.js +93 -0
- package/dist/application/dag/validate-dag.js +101 -0
- package/dist/application/loop/run-action.js +23 -0
- package/dist/cli/catalog.js +2 -237
- package/dist/cli/command-definitions.js +571 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/program.js +65 -1
- package/dist/cli/router.js +13 -0
- package/dist/cli-governance/active-residue-check.js +38 -0
- package/dist/commands/dag-report.js +6 -107
- package/dist/commands/dag-run-task.js +8 -466
- package/dist/commands/dag-validate.js +7 -179
- package/dist/commands/examples.js +90 -0
- package/dist/commands/init.js +1495 -0
- package/dist/commands/loop.js +57 -31
- package/dist/commands/pi-prompt.js +2 -9
- package/dist/commands/run-dag.js +7 -180
- package/dist/executors/cursor-executor-artifacts.js +3 -4
- package/dist/executors/cursor-worker-client.js +13 -3
- package/dist/executors/dag-cursor-executor.js +2 -3
- package/dist/executors/dag-pi-executor.js +3 -4
- package/dist/executors/dag-static-executor.js +2 -5
- package/dist/executors/pi-defaults.js +9 -0
- package/dist/executors/shell-executor.js +12 -20
- package/dist/governance/manifest-types.js +1 -0
- package/dist/infrastructure/harness/active-residue-policy.js +73 -0
- package/dist/infrastructure/harness/artifact-store.js +72 -0
- package/dist/infrastructure/harness/atomic-write.js +49 -0
- package/dist/infrastructure/harness/completed-facts-guard.js +40 -0
- package/dist/infrastructure/harness/loop-action-store.js +23 -0
- package/dist/infrastructure/harness/loop-store.js +41 -0
- package/dist/infrastructure/harness/one-shot-run-store.js +94 -0
- package/dist/infrastructure/harness/task-store.js +77 -0
- package/dist/records/one-shot-runs.js +26 -61
- package/dist/records/promotion.js +3 -4
- package/dist/shared/artifacts-core.js +5 -5
- package/dist/shared/logger.js +9 -15
- package/dist/task/delegate.js +4 -4
- package/dist/task/runtime.js +5 -7
- package/dist/task/state.js +6 -20
- package/dist/workflows/dag/convergence/controller.js +277 -0
- package/dist/workflows/dag/dynamic-runtime/condition.js +48 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +156 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +185 -0
- package/dist/workflows/dag/dynamic-runtime/reduction.js +72 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +133 -0
- package/dist/workflows/dag/lifecycle.js +6 -5
- package/dist/workflows/dag/node-execution.js +262 -0
- package/dist/workflows/dag/run-store.js +36 -0
- package/dist/workflows/dag/runner.js +82 -1341
- package/dist/workflows/dag/scheduler.js +84 -0
- package/dist/workflows/dag/upstream-artifacts.js +20 -18
- package/dist/workflows/loop/actions/cursor-fix.js +191 -0
- package/dist/workflows/loop/actions/dag-action.js +130 -0
- package/dist/workflows/loop/actions/pi-review.js +267 -0
- package/dist/workflows/loop/actions/shared.js +157 -0
- package/dist/workflows/loop/actions/shell-verify.js +82 -0
- package/dist/workflows/loop/actions/types.js +1 -0
- package/dist/workflows/loop/actions/workflow-action.js +255 -0
- package/dist/workflows/loop/actions.js +55 -1212
- package/dist/workflows/loop/closeout.js +5 -4
- package/dist/workflows/loop/context.js +2 -3
- package/dist/workflows/loop/events.js +3 -2
- package/dist/workflows/loop/policy/auto-policy.js +104 -0
- package/dist/workflows/loop/policy/cursor-fix-policy.js +31 -0
- package/dist/workflows/loop/rounds.js +3 -3
- package/dist/workflows/loop/signals.js +4 -7
- package/dist/workflows/loop/state.js +11 -11
- package/docs/README.md +3 -2
- package/docs/architecture/runtime-boundaries.md +147 -0
- package/docs/exec-plans/active/README.md +4 -0
- package/docs/exec-plans/completed/README.md +6 -2
- package/package.json +2 -1
- package/skills/ai-engineering-context/SKILL.md +21 -21
- package/skills/loop-agent/SKILL.md +73 -188
- package/skills/loop-agent/references/README.md +6 -2
- package/skills/loop-agent/references/harness-policy.md +113 -113
- package/skills/loop-agent/references/learned/README.md +13 -13
- package/skills/loop-agent/references/long-running-loop.md +59 -0
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +0 -2
- package/skills/loop-agent/references/verification-and-failure-handling.md +18 -0
- package/skills/requesting-code-review/SKILL.md +40 -40
- package/skills/requesting-code-review/code-reviewer.md +4 -4
- package/skills/systematic-debugging/CREATION-LOG.md +43 -43
- package/skills/systematic-debugging/SKILL.md +113 -113
- package/skills/systematic-debugging/condition-based-waiting.md +20 -20
- package/skills/systematic-debugging/defense-in-depth.md +27 -27
- package/skills/systematic-debugging/root-cause-tracing.md +38 -38
- package/skills/systematic-debugging/test-academic.md +6 -6
- package/skills/systematic-debugging/test-pressure-1.md +6 -6
- package/skills/systematic-debugging/test-pressure-2.md +2 -2
- package/skills/systematic-debugging/test-pressure-3.md +6 -6
- package/skills/verification-before-completion/SKILL.md +37 -37
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Shared loop-agent Harness Policy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本文件是跨仓库使用 `.` 的 canonical shared workflow policy。Repo-local harness docs 只应描述 local adapters:runtime 位置、governance root、适用的 verification commands。
|
|
4
4
|
|
|
5
5
|
## Canonical stance
|
|
6
6
|
|
|
7
|
-
- **Agent DAG**
|
|
8
|
-
-
|
|
9
|
-
- **Long-running `loop`**
|
|
10
|
-
- **Main session**
|
|
11
|
-
- **Executors**
|
|
12
|
-
- **Shell verification
|
|
7
|
+
- **Agent DAG** 是 medium/large、multi-file、architecture-sensitive、public-contract、CI/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。它记录 rounds、context compression、signals、canonical refs;不得替代 complex work 的 DAG writeSet review、Decision Gate 或 shell verification。
|
|
10
|
+
- **Main session** 负责 orchestrate:选一个 work chunk、准备 source materials、review DAG/writeSet、monitor failures、跑 final verification、hand off。
|
|
11
|
+
- **Executors** 实现 bounded work:Pi 在 DAG nodes 做 read-only planning/review/diagnosis,并在节点声明 `toolProfile: "write"` 时做 bounded implementation/repair;Cursor 是显式启用的可选 bounded writer;shell 产出 deterministic verification facts。
|
|
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
|
|
24
|
+
Prompt templates、README snippets、task instructions 应优先呈现 Primary + Operator。Compatibility 与 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
|
-
|
|
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
|
-
|
|
77
|
+
Execution 前 review `dag run-task` JSON / `reviewPacket`:
|
|
78
78
|
|
|
79
|
-
- `profileRouting
|
|
80
|
-
- `governanceProfile
|
|
81
|
-
- Writer nodes
|
|
82
|
-
- Shell gates
|
|
83
|
-
- Decision Gate mode
|
|
84
|
-
-
|
|
79
|
+
- `profileRouting`:requested profile、selected profile/template、routing reasons。
|
|
80
|
+
- `governanceProfile`:process、delivery、code-change signals。
|
|
81
|
+
- Writer nodes:`writePolicy`、`writeSet`、`allowedPaths`、`forbiddenPaths`、broad entries、forbidden 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
|
|
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
|
-
|
|
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`
|
|
102
|
+
`需求.md` 应陈述 objective、scope、non-goals、acceptance criteria,并链接 repo-local specs 或 plans。
|
|
103
103
|
|
|
104
|
-
`执行约束.md`
|
|
104
|
+
`执行约束.md` 应陈述:
|
|
105
105
|
|
|
106
106
|
- allowed paths
|
|
107
107
|
- forbidden paths
|
|
108
|
-
-
|
|
109
|
-
- architecture boundaries
|
|
108
|
+
- 当前 dirty workspace / protected user changes(如有)
|
|
109
|
+
- architecture boundaries 与 invariants
|
|
110
110
|
- expected verification commands
|
|
111
111
|
- acceptance criteria / failure conditions
|
|
112
|
-
-
|
|
112
|
+
- 是否允许 DAG fallback,及若已知时的 fallback reason
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
若 `spec`、`plan` 或 DAG generation 后 source materials 变更,implementation 前 regenerate 或 revalidate plan/DAG。
|
|
115
115
|
|
|
116
116
|
## Long-running loop policy
|
|
117
117
|
|
|
118
|
-
`loop`
|
|
118
|
+
`loop` 用于 long-running outer task memory:objective/context projection、round records、signals、derived events、verification summaries、closeout draft。它不是 Agent DAG 的 substitute。
|
|
119
119
|
|
|
120
|
-
|
|
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`
|
|
136
|
-
- `pi-review`
|
|
137
|
-
- `cursor-fix`
|
|
138
|
-
-
|
|
139
|
-
-
|
|
140
|
-
-
|
|
141
|
-
- `loop run --auto`
|
|
142
|
-
- `loop closeout`
|
|
143
|
-
-
|
|
144
|
-
- `record-round --decision complete`
|
|
135
|
+
- `shell-verify` 是 deterministic;exit code 决定 verification record。
|
|
136
|
+
- `pi-review` 是 read-only;tools 限于 `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 overlap,preserve 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` 默认不 write。Auto `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 candidate;completion 仍须 shell verification、review verdict、success-criteria coverage。
|
|
145
145
|
|
|
146
146
|
## Supervised DAG convergence
|
|
147
147
|
|
|
148
|
-
Supervised DAG convergence
|
|
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
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
- `dag report --json`
|
|
169
|
-
- Final completion authority
|
|
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 block。Repair 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 guards、timeout/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 verification;quota/focused commands 仅为 intermediate cost controls。
|
|
172
170
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
- `
|
|
176
|
-
- `
|
|
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
|
|
181
|
-
- Prompt deltas
|
|
182
|
-
- Accepted learned guidance
|
|
183
|
-
-
|
|
184
|
-
- Learned guidance
|
|
180
|
+
- Learned prompt deltas 是 human-gated proposals;成为 reusable guidance 前须 review。
|
|
181
|
+
- Prompt deltas 为 Markdown-only process guidance;不得含 shell commands、credential handling、tool 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 governance、Decision Gate policy 或 shell verification。
|
|
185
185
|
|
|
186
186
|
## Sidecar interventions
|
|
187
187
|
|
|
188
|
-
`pi-prompt`
|
|
188
|
+
`pi-prompt` 与 `cursor-prompt` 是 sidecar interventions,不是 workflow state。
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
用 `pi-prompt` 做短时 read-only planning、log 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
|
-
|
|
200
|
+
用 `cursor-prompt` 做 bounded multi-file diagnosis 或 small repair,prompt 须含:
|
|
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
|
|
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
|
|
215
|
-
- DAG `shell`
|
|
216
|
-
-
|
|
217
|
-
- `pi-prompt` / `cursor-prompt` models
|
|
218
|
-
- Pi DAG nodes
|
|
219
|
-
- Cursor nodes
|
|
220
|
-
- Shell nodes
|
|
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>/`
|
|
225
|
-
- `.harness/tasks/<task-id>/loop/`
|
|
226
|
-
- `.harness/dag-runs/{active,paused,completed}/<run-id>/`
|
|
227
|
-
- `.harness/runs/{active,completed,failed}/<run-id>/`
|
|
228
|
-
- Root `artifacts/`
|
|
229
|
-
- Long-term conclusions
|
|
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 storage。Completed facts 为 read-only。
|
|
227
|
+
- `.harness/runs/{active,completed,failed}/<run-id>/` 是 one-shot Pi/Cursor evidence。Completed/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 docs、progress、reports、decisions、tests 或 scripts。
|
|
230
230
|
|
|
231
|
-
|
|
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
|
-
|
|
235
|
+
Complex implementation 前:
|
|
236
236
|
|
|
237
|
-
1. Check current directory
|
|
238
|
-
2. Read repo entrypoints
|
|
239
|
-
3. Capture minimal baseline verification
|
|
240
|
-
4.
|
|
241
|
-
- isolated worktree
|
|
242
|
-
- explicit user confirmation
|
|
243
|
-
5. Record known baseline failures
|
|
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
|
|
245
|
+
Verification 应从 target repo verification matrix 选择。Cross-repo documentation refactors 时在 each affected repo 跑 checks。
|
|
246
246
|
|
|
247
247
|
## Handoff requirements
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
每个 task handoff 应回答:
|
|
250
250
|
|
|
251
|
-
1. What changed and why
|
|
252
|
-
2.
|
|
253
|
-
3.
|
|
254
|
-
4. Executors used
|
|
255
|
-
5. Verification commands run
|
|
256
|
-
6. DAG / one-shot / loop refs
|
|
257
|
-
7. Remaining risks
|
|
258
|
-
8.
|
|
251
|
+
1. What changed and why。
|
|
252
|
+
2. 用了哪条 workflow path:DAG、sidecar 或 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 到 docs、tests、scripts 或 shared skill references。
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Learned loop-agent Patterns
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本目录是 SePO-lite prompt evolution 的 human-gated target。
|
|
4
4
|
|
|
5
5
|
Rules:
|
|
6
6
|
|
|
7
|
-
- Files
|
|
8
|
-
- `retrospective`
|
|
9
|
-
-
|
|
10
|
-
- DAG implementer prompts
|
|
11
|
-
-
|
|
7
|
+
- Files 仅为 Markdown guidance。
|
|
8
|
+
- `retrospective` 可 propose `.harness/tasks/<task-id>/source/prompt-delta.md`;不得自动 merge 到此。
|
|
9
|
+
- 不要添加 shell commands、credential handling、tool 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-oriented:failure class、fix scope shape、invariant、verification evidence。
|
|
12
12
|
|
|
13
13
|
Acceptance checklist before merging a prompt delta:
|
|
14
14
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
- `loop-agent docs audit`
|
|
15
|
+
- Proposal 仅为 Markdown-only process guidance。
|
|
16
|
+
- 不含 shell/runtime command lines 或 fenced command blocks。
|
|
17
|
+
- Credential material、tokens、passwords、secrets 与 API keys 保持不可触达。
|
|
18
|
+
- Tool permissions、path allowlists、`allowedPaths`、`forbiddenPaths` 与 `writeSet` 保持既有边界。
|
|
19
|
+
- Shell verification、tests、write guards、decision gates、human 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:
|
|
3
|
+
description: 在完成任务、实现 major features,或 merge 前验证 work 是否满足 requirements 时使用
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Requesting Code Review
|
|
7
7
|
|
|
8
|
-
Dispatch
|
|
8
|
+
Dispatch code reviewer subagent,在问题级联前捕获 issue。Reviewer 获得精确 crafted 的 evaluation context — 绝不是你的 session history。这使 reviewer 聚焦 work product,而非你的 thought process,并保留你自己的 context 以继续工作。
|
|
9
9
|
|
|
10
|
-
**Core principle
|
|
10
|
+
**Core principle:** Review early, review often.
|
|
11
11
|
|
|
12
12
|
## When to Request Review
|
|
13
13
|
|
|
14
|
-
**Mandatory
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
14
|
+
**Mandatory:**
|
|
15
|
+
- subagent-driven development 中每个 task 之后
|
|
16
|
+
- 完成 major feature 之后
|
|
17
|
+
- merge 到 main 之前
|
|
18
18
|
|
|
19
|
-
**Optional but valuable
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
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
|
|
32
|
+
**2. Use the code reviewer template**(本 skill 目录下的 `code-reviewer.md`):
|
|
33
33
|
|
|
34
34
|
**Placeholders:**
|
|
35
|
-
- `{DESCRIPTION}`
|
|
36
|
-
- `{PLAN_OR_REQUIREMENTS}`
|
|
37
|
-
- `{BASE_SHA}`
|
|
38
|
-
- `{HEAD_SHA}`
|
|
35
|
+
- `{DESCRIPTION}` — 简要 summary of what you built
|
|
36
|
+
- `{PLAN_OR_REQUIREMENTS}` — 它应做什么(contract、exec plan 或 requirements)
|
|
37
|
+
- `{BASE_SHA}` — Starting commit
|
|
38
|
+
- `{HEAD_SHA}` — Ending commit
|
|
39
39
|
|
|
40
40
|
**3. Act on feedback:**
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
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
|
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
75
|
+
**每个 work chunk 之后(Plan → Contract → Implement → Verify → Handoff):**
|
|
76
|
+
- Implement 之后、Verify 之前 review
|
|
77
|
+
- 在问题 compound 前捕获
|
|
78
|
+
- 进入 next task 前修复
|
|
79
79
|
|
|
80
|
-
**Before merge / Handoff
|
|
81
|
-
-
|
|
82
|
-
-
|
|
80
|
+
**Before merge / Handoff:**
|
|
81
|
+
- 宣称 complete 前 review
|
|
82
|
+
- 对照 contract acceptance criteria 验证
|
|
83
83
|
|
|
84
|
-
**Ad-Hoc Development
|
|
85
|
-
-
|
|
86
|
-
-
|
|
84
|
+
**Ad-Hoc Development:**
|
|
85
|
+
- merge 前 review
|
|
86
|
+
- 卡住时 review
|
|
87
87
|
|
|
88
88
|
## Red Flags
|
|
89
89
|
|
|
90
|
-
**Never
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
90
|
+
**Never:**
|
|
91
|
+
- 因 "it's simple" 跳过 review
|
|
92
|
+
- 忽略 Critical issues
|
|
93
|
+
- 带着未修复的 Important issues 继续
|
|
94
|
+
- 与 valid technical feedback 争辩
|
|
95
95
|
|
|
96
|
-
**If reviewer wrong
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
96
|
+
**If reviewer wrong:**
|
|
97
|
+
- 用 technical reasoning push back
|
|
98
|
+
- 展示证明其有效的 code/tests
|
|
99
|
+
- 请求 clarification
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Template 见:requesting-code-review/code-reviewer.md
|