@tea-agent/loop-agent 0.1.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/AGENTS.md +121 -0
- package/CHANGELOG.md +37 -0
- package/README.md +144 -0
- package/bin/loop-agent.js +21 -0
- package/dist/adapters/aimax.js +91 -0
- package/dist/adapters/context.js +32 -0
- package/dist/adapters/index.js +28 -0
- package/dist/adapters/loop-agent.js +98 -0
- package/dist/adapters/types.js +1 -0
- package/dist/cli/catalog.js +259 -0
- package/dist/cli/help.js +55 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/program.js +505 -0
- package/dist/cli.js +12 -0
- package/dist/commands/closeout.js +13 -0
- package/dist/commands/coverage-audit.js +14 -0
- package/dist/commands/cursor-prompt.js +222 -0
- package/dist/commands/cursor-worker.js +43 -0
- package/dist/commands/dag-approve.js +102 -0
- package/dist/commands/dag-final-verification.js +76 -0
- package/dist/commands/dag-init-hybrid.js +56 -0
- package/dist/commands/dag-reconcile-tasks.js +51 -0
- package/dist/commands/dag-reject.js +91 -0
- package/dist/commands/dag-report.js +177 -0
- package/dist/commands/dag-resume.js +34 -0
- package/dist/commands/dag-run-task.js +470 -0
- package/dist/commands/dag-validate.js +186 -0
- package/dist/commands/dag-workflow-compile.js +91 -0
- package/dist/commands/dag-workflow-plan.js +130 -0
- package/dist/commands/dag-workflow-validate.js +66 -0
- package/dist/commands/delegate.js +132 -0
- package/dist/commands/docs-archive.js +5 -0
- package/dist/commands/docs-audit.js +5 -0
- package/dist/commands/doctor.js +50 -0
- package/dist/commands/goal.js +92 -0
- package/dist/commands/handoff-check.js +5 -0
- package/dist/commands/harvest.js +44 -0
- package/dist/commands/inspect.js +11 -0
- package/dist/commands/instructions.js +195 -0
- package/dist/commands/knowledge.js +64 -0
- package/dist/commands/loop-benchmark.js +72 -0
- package/dist/commands/loop.js +241 -0
- package/dist/commands/new-task.js +5 -0
- package/dist/commands/pi-prompt.js +181 -0
- package/dist/commands/pi-reuse-benchmark.js +153 -0
- package/dist/commands/plan-list.js +5 -0
- package/dist/commands/promote-run.js +29 -0
- package/dist/commands/reference-index.js +16 -0
- package/dist/commands/run-dag.js +184 -0
- package/dist/commands/spine.js +38 -0
- package/dist/commands/stats.js +84 -0
- package/dist/commands/status.js +56 -0
- package/dist/commands/study-init.js +192 -0
- package/dist/commands/workflow.js +259 -0
- package/dist/commands/worktree-create.js +31 -0
- package/dist/commands/worktree-list.js +5 -0
- package/dist/commands/worktree-remove.js +26 -0
- package/dist/cursor-worker-entry.js +8 -0
- package/dist/executors/config-core.js +55 -0
- package/dist/executors/config.js +2 -0
- package/dist/executors/cursor-artifacts.js +33 -0
- package/dist/executors/cursor-execution-log.js +81 -0
- package/dist/executors/cursor-executor-artifacts.js +135 -0
- package/dist/executors/cursor-executor.js +468 -0
- package/dist/executors/cursor-run.js +115 -0
- package/dist/executors/cursor-tool.js +94 -0
- package/dist/executors/cursor-worker-client.js +213 -0
- package/dist/executors/cursor-worker-protocol.js +18 -0
- package/dist/executors/cursor-worker-server.js +54 -0
- package/dist/executors/cursor-worker.js +3 -0
- package/dist/executors/cursor.js +6 -0
- package/dist/executors/dag-cursor-executor.js +88 -0
- package/dist/executors/dag-pi-executor.js +322 -0
- package/dist/executors/dag-static-executor.js +45 -0
- package/dist/executors/dag.js +4 -0
- package/dist/executors/index.js +8 -0
- package/dist/executors/model-routing.js +60 -0
- package/dist/executors/pi-event-serializer.js +43 -0
- package/dist/executors/pi-executor.js +606 -0
- package/dist/executors/pi-reuse-benchmark.js +316 -0
- package/dist/executors/pi-runtime-reuse.js +29 -0
- package/dist/executors/pi-sdk-executor.js +255 -0
- package/dist/executors/pi-sdk.js +1 -0
- package/dist/executors/pi.js +3 -0
- package/dist/executors/shell-executor.js +300 -0
- package/dist/executors/shell-presets.js +47 -0
- package/dist/executors/shell-verification.js +251 -0
- package/dist/executors/shell-write-guard.js +126 -0
- package/dist/executors/shell.js +3 -0
- package/dist/executors/static.js +1 -0
- package/dist/governance/checks.js +434 -0
- package/dist/governance/harness.js +9 -0
- package/dist/governance/index.js +3 -0
- package/dist/governance/manifest-types.js +128 -0
- package/dist/governance/manifest.js +2 -0
- package/dist/governance/path-guard.js +69 -0
- package/dist/governance/path-guards.js +2 -0
- package/dist/governance/profiles.js +3 -0
- package/dist/governance/requirement-coverage.js +425 -0
- package/dist/governance/skill-safety.js +135 -0
- package/dist/governance/spine-audit.js +152 -0
- package/dist/records/closeout.js +2 -0
- package/dist/records/harvest.js +236 -0
- package/dist/records/index.js +3 -0
- package/dist/records/one-shot-runs.js +421 -0
- package/dist/records/promotion.js +199 -0
- package/dist/shared/artifacts-core.js +88 -0
- package/dist/shared/artifacts.js +2 -0
- package/dist/shared/context-files.js +32 -0
- package/dist/shared/context.js +2 -0
- package/dist/shared/copy-dir.js +17 -0
- package/dist/shared/git-progress.js +165 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/logger.js +23 -0
- package/dist/shared/one-shot-prompt-args.js +98 -0
- package/dist/shared/path-refs.js +31 -0
- package/dist/shared/prompts.js +26 -0
- package/dist/shared/reference-context.js +238 -0
- package/dist/shared/timeout-policy.js +19 -0
- package/dist/shared/timeout.js +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/task/config-types.js +97 -0
- package/dist/task/config.js +2 -0
- package/dist/task/delegate.js +220 -0
- package/dist/task/goal-audit.js +51 -0
- package/dist/task/goal-policy.js +8 -0
- package/dist/task/goal.js +3 -0
- package/dist/task/ids.js +1 -0
- package/dist/task/index.js +9 -0
- package/dist/task/lifecycle.js +1 -0
- package/dist/task/paths.js +1 -0
- package/dist/task/read-model.js +149 -0
- package/dist/task/runtime.js +699 -0
- package/dist/task/source-state.js +1 -0
- package/dist/task/state.js +55 -0
- package/dist/task/subagent-guidance.js +1 -0
- package/dist/task/workflow-state-types.js +92 -0
- package/dist/task/worktree-cleanup.js +140 -0
- package/dist/task/worktree.js +171 -0
- package/dist/workflows/dag/authoring.js +8 -0
- package/dist/workflows/dag/authority-surface.js +138 -0
- package/dist/workflows/dag/canvas-observer.js +474 -0
- package/dist/workflows/dag/decision-envelope.js +502 -0
- package/dist/workflows/dag/decision-evidence.js +153 -0
- package/dist/workflows/dag/decision-gates.js +1 -0
- package/dist/workflows/dag/executor-registry.js +25 -0
- package/dist/workflows/dag/facts.js +4 -0
- package/dist/workflows/dag/failure-category.js +111 -0
- package/dist/workflows/dag/final-verification.js +180 -0
- package/dist/workflows/dag/governance-constants.js +5 -0
- package/dist/workflows/dag/governance-profile.js +405 -0
- package/dist/workflows/dag/index.js +6 -0
- package/dist/workflows/dag/init-hybrid.js +855 -0
- package/dist/workflows/dag/knowledge-curator.js +162 -0
- package/dist/workflows/dag/lifecycle.js +484 -0
- package/dist/workflows/dag/prompt-source.js +88 -0
- package/dist/workflows/dag/prompt.js +130 -0
- package/dist/workflows/dag/reconcile-tasks.js +404 -0
- package/dist/workflows/dag/recovery-recommendation.js +226 -0
- package/dist/workflows/dag/repair-artifact.js +136 -0
- package/dist/workflows/dag/report.js +1019 -0
- package/dist/workflows/dag/runner.js +1677 -0
- package/dist/workflows/dag/runtime.js +5 -0
- package/dist/workflows/dag/skill-instructions.js +471 -0
- package/dist/workflows/dag/skills.js +41 -0
- package/dist/workflows/dag/spec.js +3 -0
- package/dist/workflows/dag/topo.js +30 -0
- package/dist/workflows/dag/types.js +275 -0
- package/dist/workflows/dag/upstream-artifacts.js +95 -0
- package/dist/workflows/dag/validate.js +527 -0
- package/dist/workflows/dynamic/artifacts.js +65 -0
- package/dist/workflows/dynamic/compile.js +360 -0
- package/dist/workflows/dynamic/compileTypes.js +1 -0
- package/dist/workflows/dynamic/errors.js +5 -0
- package/dist/workflows/dynamic/index.js +7 -0
- package/dist/workflows/dynamic/profiles.js +156 -0
- package/dist/workflows/dynamic/spec.js +114 -0
- package/dist/workflows/dynamic/validate.js +275 -0
- package/dist/workflows/loop/actions.js +1334 -0
- package/dist/workflows/loop/benchmark.js +510 -0
- package/dist/workflows/loop/closeout.js +134 -0
- package/dist/workflows/loop/context.js +48 -0
- package/dist/workflows/loop/events.js +25 -0
- package/dist/workflows/loop/hash.js +32 -0
- package/dist/workflows/loop/index.js +8 -0
- package/dist/workflows/loop/paths.js +17 -0
- package/dist/workflows/loop/rounds.js +81 -0
- package/dist/workflows/loop/signals.js +55 -0
- package/dist/workflows/loop/state.js +116 -0
- package/dist/workflows/loop/templates.js +54 -0
- package/dist/workflows/loop/types.js +28 -0
- package/docs/README.md +62 -0
- package/docs/agent-dag-recovery-playbook.md +158 -0
- package/docs/agent-dag-runner.md +40 -0
- package/docs/cursor-executor-usage.md +25 -0
- package/docs/decisions/README.md +3 -0
- package/docs/design/README.md +36 -0
- package/docs/development-principles.md +71 -0
- package/docs/dynamic-workflow-dag-engine-roadmap.md +1749 -0
- package/docs/exec-plans/README.md +6 -0
- package/docs/exec-plans/active/README.md +5 -0
- package/docs/exec-plans/completed/README.md +5 -0
- package/docs/feature-workflow.md +184 -0
- package/docs/harness-methodology-debugging.md +153 -0
- package/docs/harness-methodology-tdd.md +130 -0
- package/docs/harness-methodology-verification.md +27 -0
- package/docs/loop-agent-harness.md +42 -0
- package/docs/progress/README.md +3 -0
- package/docs/reports/README.md +3 -0
- package/docs/templates/adr.md +60 -0
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -0
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -0
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -0
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -0
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -0
- package/docs/templates/agent-dag-report.schema.json +423 -0
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -0
- package/docs/templates/agent-dag.base.json +195 -0
- package/docs/templates/agent-dag.final-verification.json +190 -0
- package/docs/templates/agent-dag.schema.json +316 -0
- package/docs/templates/agent-dag.supervised-implementation.json +500 -0
- package/docs/templates/exec-plan.md +64 -0
- package/docs/templates/feature-spec.md +53 -0
- package/docs/templates/hybrid-dag.json +193 -0
- package/docs/templates/progress-log.md +17 -0
- package/docs/templates/project-start-checklist.md +9 -0
- package/docs/templates/qa-report.md +42 -0
- package/docs/templates/sprint-contract.md +29 -0
- package/docs/verification-matrix.md +30 -0
- package/examples/decision-gate-agent-dag.json +123 -0
- package/examples/example-dag.json +51 -0
- package/examples/hybrid-loop-agent-dag.json +194 -0
- package/harness.json +92 -0
- package/package.json +61 -0
- package/skills/ai-engineering-context/SKILL.md +48 -0
- package/skills/loop-agent/SKILL.md +260 -0
- package/skills/loop-agent/references/README.md +63 -0
- package/skills/loop-agent/references/command-reference.md +315 -0
- package/skills/loop-agent/references/harness-policy.md +258 -0
- package/skills/loop-agent/references/hybrid-dag.md +216 -0
- package/skills/loop-agent/references/learned/README.md +21 -0
- package/skills/loop-agent/references/model-routing.md +36 -0
- package/skills/loop-agent/references/multi-worktree.md +54 -0
- package/skills/loop-agent/references/one-shot-runs.md +85 -0
- package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -0
- package/skills/loop-agent/references/pi-prompt.md +23 -0
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +83 -0
- package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -0
- package/skills/loop-agent/references/task-workflow.md +84 -0
- package/skills/loop-agent/references/verification-and-failure-handling.md +74 -0
- package/skills/requesting-code-review/SKILL.md +101 -0
- package/skills/requesting-code-review/code-reviewer.md +168 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/verification-before-completion/SKILL.md +154 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# loop-agent Skill References
|
|
2
|
+
|
|
3
|
+
本目录是 `../SKILL.md` 的 progressive-disclosure reference layer。`SKILL.md`
|
|
4
|
+
只负责 trigger、入口选择和硬规则;较长的 command details、operational procedures、
|
|
5
|
+
failure handling 与 workflow 细节放在这里,避免主 skill 变成百科。
|
|
6
|
+
|
|
7
|
+
## 使用方式
|
|
8
|
+
|
|
9
|
+
1. 先读 `../SKILL.md`,确认当前任务是否真的需要 `loop-agent`。
|
|
10
|
+
2. 根据任务类型只打开相关 reference,不要一次加载整个目录。
|
|
11
|
+
3. 执行时遵循 Agent DAG 路径;历史顺序式 `run ...` workflow 已移除。
|
|
12
|
+
4. 如果 reference 与 `harness.json` 或 repo-local `docs/loop-agent-harness.md` / `specs/loop-agent-harness.md` 冲突,以
|
|
13
|
+
`harness.json` 的机器可读 policy 和本目录的 shared policy 为准,并回头修正文档漂移。
|
|
14
|
+
|
|
15
|
+
## 快速路由
|
|
16
|
+
|
|
17
|
+
| 场景 | 优先读取 |
|
|
18
|
+
|---|---|
|
|
19
|
+
| 通用 loop-agent harness workflow policy、跨 repo 共同规则 | `harness-policy.md` |
|
|
20
|
+
| 中大型 autonomous implementation、harness-governed work | `harness-policy.md`、`hybrid-dag.md`、`orchestrator-and-interventions.md`、`verification-and-failure-handling.md` |
|
|
21
|
+
| 需要查精确 CLI 用法、setup、goal、docs helper、stats | `command-reference.md` |
|
|
22
|
+
| 低风险 micro task、旧任务目录兼容、DAG runtime 修复 | `task-workflow.md`、`verification-and-failure-handling.md` |
|
|
23
|
+
| DAG 运行中要判断 main session 是否能手术式补丁、是否需要 sidecar prompt | `orchestrator-and-interventions.md` |
|
|
24
|
+
| 短时 one-shot Pi SDK 调用,不创建 `.harness/tasks/` | `pi-prompt.md` |
|
|
25
|
+
| 解释 `.harness/runs/`、one-shot evidence、active 残留或 promotion | `one-shot-runs.md` |
|
|
26
|
+
| 多 worktree 并行委派、delegate/harvest | `multi-worktree.md` |
|
|
27
|
+
| 模型、provider、profile、fallback routing | `model-routing.md` |
|
|
28
|
+
|
|
29
|
+
## Reference 索引
|
|
30
|
+
|
|
31
|
+
| Reference | 使用场景 |
|
|
32
|
+
|---|---|
|
|
33
|
+
| `harness-policy.md` | 通用 loop-agent harness policy:DAG、命令分层、source materials、loop/sidecar 边界、facts/verification/handoff 规则;repo-local harness docs 应引用它而不是复制规则 |
|
|
34
|
+
| `orchestrator-and-interventions.md` | 协调长时间 autonomous DAG work;判断 main session 是否可以 edit;使用 one-shot Pi/Cursor sidecar;恢复 in-flight workflow |
|
|
35
|
+
| `command-reference.md` | 需要 `.` 的精确 CLI 命令、setup、goal lifecycle、docs helper、stats |
|
|
36
|
+
| `task-workflow.md` | 处理 task source material、task config、repo adapter 或 legacy task 目录布局 |
|
|
37
|
+
| `pi-prompt.md` | 运行短时 one-shot Pi SDK task,且不创建 `.harness/tasks/` |
|
|
38
|
+
| `one-shot-runs.md` | 解释 `.harness/runs/{active,completed,failed}` 的创建条件、生命周期、治理清理与 `promote-run` 关系 |
|
|
39
|
+
| `hybrid-dag.md` | 使用 Agent DAG Level 2 `dag validate` / `run-dag`,Level 3 `dag init-hybrid` / `dag run-task`,或查看 write policy、DAG source-of-truth 规则 |
|
|
40
|
+
| `pi-subagent-assisted-mode.md` | 启用 `piSubagentMode`,或在 Pi step 内配置 read-only scout / planner / reviewer subagent |
|
|
41
|
+
| `model-routing.md` | 查看或修改 model/provider 默认、profile、routing 或 fallback 行为 |
|
|
42
|
+
| `post-implementation-and-patterns.md` | 处理 post-verify handoff、PRD item 拆分、fast bounded task、quick status 或 Pi timeout |
|
|
43
|
+
| `multi-worktree.md` | 用 isolated worktree、`delegate` 与 `harvest` 并发执行互不重叠的 independent task |
|
|
44
|
+
| `verification-and-failure-handling.md` | 选择 verify knob、解释 failure mode、执行 completion audit 与 closeout |
|
|
45
|
+
|
|
46
|
+
## 边界与状态源
|
|
47
|
+
|
|
48
|
+
- `references/harness-policy.md` 是 shared workflow policy source,供多个 repo 的 thin adapter docs 引用。
|
|
49
|
+
- `../SKILL.md` 是 skill trigger 与 routing source,不承载长流程细节。
|
|
50
|
+
- `docs/loop-agent-harness.md` / repo-local `specs/loop-agent-harness.md` 是本仓库或目标仓库的 adapter 文档:只描述 runtime 位置、governance root、验证入口和本地边界。
|
|
51
|
+
- `harness.json` 是 workflowPolicy、script entrypoints、artifacts 目录与 model routing 的机器可读 source of truth。
|
|
52
|
+
- `.harness/tasks/<task-id>/` 是 task 运行态状态;不要把运行态事实写进本目录。
|
|
53
|
+
- `.harness/runs/completed/<run-id>/` 是 one-shot tool run evidence;reference 文档只能解释如何读取和 promotion,不应复制 run facts。
|
|
54
|
+
- `.harness/dag-runs/completed/<run-id>/` 是单次 DAG run 的不可变 facts;reference 文档只能解释如何读取和收口,不应复制 run facts。
|
|
55
|
+
|
|
56
|
+
## 维护规则
|
|
57
|
+
|
|
58
|
+
- 不要把长段落复制回 `SKILL.md`;需要新增细节时,在本目录新增或更新 reference,并在 `SKILL.md` 添加 routing row。
|
|
59
|
+
- 让 `SKILL.md` 保持约 200-300 行以内;reference 文件承担细节。
|
|
60
|
+
- 新 reference 应有清晰标题、触发场景、最小步骤、失败处理和维护边界。
|
|
61
|
+
- 如果某个 reference 变成可独立触发、跨项目通用且不再依赖本仓库上下文,再考虑拆成独立 skill。
|
|
62
|
+
- 更新 command、workflow policy 或 verification 规则时,同步核对 `harness.json`、`references/harness-policy.md`、repo-local harness adapter docs 和 verification matrix。
|
|
63
|
+
- `~/.pi/agent/skills/loop-agent` 是指向本目录的 symlink,所以仓库内 edits 会直接更新 Pi skill。
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# loop-agent 命令参考
|
|
2
|
+
|
|
3
|
+
需要 loop-agent 的精确 CLI 命令、setup 命令、task lifecycle 命令、docs helper、goal 命令或 stats 时使用本文。
|
|
4
|
+
|
|
5
|
+
## loop-agent 入口
|
|
6
|
+
|
|
7
|
+
**优先在目标 repo 目录内执行命令** — loop-agent 通过 `harness.json.project` 自动检测使用哪个 repo adapter。跨目录操作时显式加 `--repo-root <target-repo>`。
|
|
8
|
+
|
|
9
|
+
默认使用全局 CLI:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
loop-agent <command> ...
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
面向自举迭代和日常使用时,全局 CLI 应来自 npm 上已发布的安装包。首次安装或有意升级使用 `@latest`:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @tea-agent/loop-agent@latest
|
|
19
|
+
npm list -g @tea-agent/loop-agent --depth=0
|
|
20
|
+
loop-agent doctor
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
一次自举任务启动后不要中途升级控制器;记录 `npm list -g` 显示的实际版本。不要在 DAG 节点中反复用 `npx @latest` 拉取,也不要使用当前工作区的 `npm link` 或 `npm run dev` 作为控制器去修改 loop-agent 本仓库的 CLI、DAG runtime、executor、package metadata 或 build output。`npm run dev -- <command> ...` 只用于源码调试和聚焦 CLI 开发。
|
|
24
|
+
|
|
25
|
+
发布包入口加载 `dist/cli.js`;开发入口加载 `src/cli.ts`。
|
|
26
|
+
|
|
27
|
+
发布包携带静态能力资料:`skills/`、`docs/*.md`、`docs/templates/` 和 `examples/`。`docs/progress/`、`docs/reports/`、`docs/exec-plans/`、`docs/decisions/` 的任务正文属于目标仓库运行中生成的事实,不从 npm 包复制;包内只保留这些目录的 README 说明。
|
|
28
|
+
|
|
29
|
+
## 命令参考
|
|
30
|
+
|
|
31
|
+
## 默认选择模型
|
|
32
|
+
|
|
33
|
+
选择命令时按以下优先级:
|
|
34
|
+
|
|
35
|
+
1. **主路径 DAG**,用于常规 autonomous work:
|
|
36
|
+
```bash
|
|
37
|
+
loop-agent new-task <task-id> "Task Title"
|
|
38
|
+
loop-agent dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
|
|
39
|
+
loop-agent dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
|
|
40
|
+
loop-agent run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <repo-root>
|
|
41
|
+
```
|
|
42
|
+
`<temp-dir>` 表示平台原生临时目录;也可以省略 `--output`,再使用命令 JSON 输出里的 `outputPath`。
|
|
43
|
+
2. **Operator 工具**,用于 recovery、诊断与 closeout:
|
|
44
|
+
```bash
|
|
45
|
+
loop-agent dag status --run-id <run-id>
|
|
46
|
+
loop-agent dag doctor
|
|
47
|
+
loop-agent dag report --latest --markdown
|
|
48
|
+
loop-agent dag closeout-draft --run-id <run-id>
|
|
49
|
+
loop-agent dag reconcile-tasks --glob '<pattern>' --markdown
|
|
50
|
+
loop-agent dag final-verification <task-id> --output <temp-dir>/<task-id>-final-verification-dag.json
|
|
51
|
+
loop-agent status <task-id> --json
|
|
52
|
+
loop-agent instructions task-artifacts --task <task-id> --json
|
|
53
|
+
loop-agent promote-run <task-id> --run-id <run-id>
|
|
54
|
+
loop-agent closeout task <task-id>
|
|
55
|
+
loop-agent spine audit <task-id> --markdown
|
|
56
|
+
loop-agent knowledge curate --markdown --output docs/reports/<task-id>-learned-proposal.md
|
|
57
|
+
loop-agent loop-benchmark --markdown
|
|
58
|
+
```
|
|
59
|
+
3. **Escape hatch**,仅用于 worktree 隔离委派、executor 调试或 one-shot 诊断:
|
|
60
|
+
```bash
|
|
61
|
+
loop-agent delegate <task-id> --executor cursor
|
|
62
|
+
loop-agent harvest <task-id>
|
|
63
|
+
loop-agent pi-prompt "Reply with exactly OK."
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Setup(首次)
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g @tea-agent/loop-agent@latest
|
|
69
|
+
loop-agent --help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 检查 repo harness
|
|
73
|
+
```bash
|
|
74
|
+
loop-agent inspect # 当前 repo(自动检测)
|
|
75
|
+
loop-agent --repo-root /path/to/target-repo inspect # 指定 repo
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 健康检查
|
|
79
|
+
```bash
|
|
80
|
+
loop-agent doctor
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`doctor` 报告当前生效的 Pi backend 及 SDK/CLI 可用性。Pi step 默认 SDK-first 执行:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
export CODE_AGENT_PI_BACKEND=sdk-first # 默认:先试 Pi SDK,允许时 fallback 到 CLI
|
|
87
|
+
export CODE_AGENT_PI_BACKEND=cli-only # 紧急回滚:纯 CLI 路径
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
SDK 回归或 SDK 可选依赖不可用时用 `cli-only` 诊断。CLI fallback 路径须与现有 workflow 行为兼容。
|
|
91
|
+
|
|
92
|
+
### 创建新 task
|
|
93
|
+
```bash
|
|
94
|
+
loop-agent new-task <task-id> "Task Title"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
创建 `.harness/tasks/<task-id>/`,含 `source/`、`artifacts/`、`logs/` 及初始 state。
|
|
98
|
+
|
|
99
|
+
### Task action context / artifact instructions
|
|
100
|
+
```bash
|
|
101
|
+
loop-agent status <task-id> --json
|
|
102
|
+
loop-agent instructions source --task <task-id> --json
|
|
103
|
+
loop-agent instructions dag-draft --task <task-id> --json
|
|
104
|
+
loop-agent instructions task-artifacts --task <task-id> --json
|
|
105
|
+
loop-agent instructions promotion --task <task-id> --json
|
|
106
|
+
loop-agent instructions closeout --task <task-id> --json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`status` 是 agent 行动上下文入口,返回 `artifactPaths`、`runRefs`、`actionContext` 与 `nextActions`。`instructions` 在写入 source、DAG draft、task artifacts、promotion 或 closeout 前返回目标路径、依赖、模板、写策略与完成标准;blocked artifact 会列出 `missingDependencies`。
|
|
110
|
+
|
|
111
|
+
### Promotion / closeout
|
|
112
|
+
```bash
|
|
113
|
+
loop-agent promote-run <task-id> --run-id <run-id>
|
|
114
|
+
loop-agent closeout task <task-id>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`promote-run` 从 completed DAG facts 或 one-shot completed run evidence 生成 task `修改记录.md` / `验证结果.md`,不调用 LLM、不修改 completed run facts。`closeout task` 从 task artifacts 生成 `docs/progress/YYYY-MM-DD-<slug>.md`,验证证据不足时必须写明剩余风险。
|
|
118
|
+
|
|
119
|
+
one-shot run evidence 位于 `.harness/runs/{active,completed,failed}/<run-id>/`。`cursor-prompt` 与 Pi `cursor` tool 会创建这类 run evidence;当前 `pi-prompt` 不创建 `.harness/runs/`。active 目录只应保留 live one-shot run,残留或 `.DS_Store` 等系统文件应清理。详见 `one-shot-runs.md`。
|
|
120
|
+
|
|
121
|
+
### 运行任何 step 前:准备 source materials
|
|
122
|
+
`new-task` 之后,至少添加 `需求.md`:
|
|
123
|
+
```bash
|
|
124
|
+
mkdir -p <repo-root>/.harness/tasks/<task-id>/source
|
|
125
|
+
cat > <repo-root>/.harness/tasks/<task-id>/source/需求.md
|
|
126
|
+
```
|
|
127
|
+
然后写明需求、目标范围与约束。
|
|
128
|
+
|
|
129
|
+
若 task 有硬约束(仅允许特定文件、禁止改动),另加:
|
|
130
|
+
```bash
|
|
131
|
+
cat > <repo-root>/.harness/tasks/<task-id>/source/执行约束.md
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Feature-study workflow(参考代码 → 轻量实现)
|
|
135
|
+
例如「分析参考仓库的一项功能,并在目标仓库实现轻量版本」:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
loop-agent --repo-root /path/to/target-repo study init <task-id> "Title" \
|
|
139
|
+
--reference-repo codex:/Users/mac/go/src/codex \
|
|
140
|
+
--reference-doc plan:/Users/mac/plans/codex-goal-feature.md \
|
|
141
|
+
--reference-glob "codex-rs/**/goal*.rs"
|
|
142
|
+
|
|
143
|
+
# 编辑 source/需求.md + source/执行约束.md,然后走 DAG 路径:
|
|
144
|
+
loop-agent --repo-root <target-repo> dag run-task <task-id> --profile auto --strict-models --output <temp-dir>/<task-id>-dag.json
|
|
145
|
+
loop-agent --repo-root <target-repo> dag validate --dag <temp-dir>/<task-id>-dag.json --strict-models --strict-governance
|
|
146
|
+
loop-agent --repo-root <target-repo> run-dag --dag <temp-dir>/<task-id>-dag.json --cwd <target-repo>
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
目标 repo 需有 `.harness/prompts/feature-study-analyze.md` 与 `feature-study-plan.md`(缺失时从 loop-agent 复制)。
|
|
150
|
+
|
|
151
|
+
### Removed sequential workflow
|
|
152
|
+
|
|
153
|
+
历史顺序式 `run analyze|plan|spec|implement|verify|retrospective|auto|loop|continue|study` 已移除。新任务不要使用这些命令,也不要在 prompt、skill 或 docs 中把它们描述为 fallback。
|
|
154
|
+
|
|
155
|
+
### Task goal lifecycle(compatibility-only / deprecated-candidate)
|
|
156
|
+
```bash
|
|
157
|
+
loop-agent goal set <task-id> "Objective text" [--token-budget <number|null>]
|
|
158
|
+
loop-agent goal set <task-id> "Replacement objective" --force
|
|
159
|
+
loop-agent goal get <task-id>
|
|
160
|
+
loop-agent goal pause <task-id>
|
|
161
|
+
loop-agent goal resume <task-id>
|
|
162
|
+
loop-agent goal clear <task-id>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- 已有 goal 且 objective 不同时,替换须显式 `--force`。
|
|
166
|
+
- `harness.json` 可用 `features.goals=false` 关闭此 surface。
|
|
167
|
+
- `status` 现含 `goal`(`objective/status/tokenBudget/tokensUsed/timeUsedSeconds/continuationRuns`)、`verifyEnv`、`maxGoalContinuationsPerRun` 及可选 `flowHint`
|
|
168
|
+
- 在 `source/需求.md` 用 `<!-- goal-scope -->` … `<!-- /goal-scope -->` 包裹仅 goal 验收项;范围外 `- [ ]` 不阻塞 goal 完成
|
|
169
|
+
- `task.json`:`verifyEnv=clean`(默认);goal continuation 需 verify 重试时用 `flow=loop`,避免盲目 implement 循环
|
|
170
|
+
- continuation 是 runtime policy,不是普通用户消息:
|
|
171
|
+
- continuation prompts are legacy compatibility metadata under `.harness/prompts/`
|
|
172
|
+
- 触发时叠加 `.harness/prompts/objective_updated.md` 与 `.harness/prompts/budget_limit.md`
|
|
173
|
+
- 将渲染文本注入隐藏 `<goal_context>...</goal_context>` 片段供 step 执行
|
|
174
|
+
- 用于保持 continuation 行为一致,减少聊天式历史噪音
|
|
175
|
+
- preflight 含 state/mode guard + 启动前 goal 一致性复检
|
|
176
|
+
|
|
177
|
+
### Agent DAG validation 与 execution
|
|
178
|
+
```bash
|
|
179
|
+
loop-agent dag validate --dag <temp-dir>/hybrid-dag.json # 常规 validation;无 .harness/dag-runs 副作用
|
|
180
|
+
loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-models # 非 canonical executorModels 时失败
|
|
181
|
+
loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance # governance warning 时失败
|
|
182
|
+
loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --strict-governance --spine-task <task-id> # 同时消费 minimal spec spine audit
|
|
183
|
+
loop-agent dag validate --dag docs/templates/agent-dag.supervised-implementation.json --strict-models --strict-governance # role=supervisor + write-set-gate topology
|
|
184
|
+
cp docs/templates/agent-dag.supervised-implementation.json <temp-dir>/supervised-dag.json
|
|
185
|
+
(npx vitest run test/dag-supervised-template.test.ts test/dag-validate.test.ts test/dag-shell-executor.test.ts --reporter=dot) # supervised template + shell.verdictGate runtime
|
|
186
|
+
loop-agent dag validate --dag <temp-dir>/hybrid-dag.json --forbid-executor cursor # 存在 cursor node 时失败
|
|
187
|
+
loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> # 执行 Agent DAG
|
|
188
|
+
loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --cwd <repo-root> --no-cursor # 执行前若存在 cursor node 则失败
|
|
189
|
+
loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <temp-dir>/hybrid-dag.canvas.tsx # 可选 derived Canvas view
|
|
190
|
+
loop-agent dag init-hybrid <task-id> # 生成可审阅的 DAG draft
|
|
191
|
+
loop-agent dag run-task <task-id> # generate + validate(安全默认;无 dag-runs;standard-compatible)
|
|
192
|
+
loop-agent dag run-task <task-id> --profile auto # 推断 governanceProfile,经 workflowPolicy.dag.profileRouting 路由
|
|
193
|
+
loop-agent dag run-task <task-id> --profile minimal # 强制当前 minimal 路由(standard-dag)
|
|
194
|
+
loop-agent dag run-task <task-id> --profile standard # 强制 standard-dag
|
|
195
|
+
loop-agent dag run-task <task-id> --profile reviewed # 强制 review-gated DAG
|
|
196
|
+
loop-agent dag run-task <task-id> --profile supervised # 强制 supervised implementation DAG
|
|
197
|
+
loop-agent dag run-task <task-id> --execute --cwd <repo-root> # generate + validate + execute(先 narrow writeSet)
|
|
198
|
+
loop-agent dag run-task <task-id> --dry-run --cwd <repo-root> # generate + validate + active dry-run snapshot
|
|
199
|
+
loop-agent dag status --run-id <run-id> # 单次 run JSON 摘要(approvalFlow, healthIssues)
|
|
200
|
+
loop-agent dag doctor # 扫描 active/paused/completed runs;advisoryOnly health report
|
|
201
|
+
loop-agent dag report [--run-id <run-id>] [--lifecycle active|paused|completed|all] [--json|--markdown] [--failed-only] [--latest] [--paused-latest] [--action <recovery-action>] # derived per-node 聚合(只读);JSON 锁定于 docs/templates/agent-dag-report.schema.json;--paused-latest 聚焦最新 paused run;playbook: docs/agent-dag-recovery-playbook.md
|
|
202
|
+
loop-agent dag reconcile-tasks --glob '<pattern>' # 仅报告的 task/run/artifact/verify drift audit
|
|
203
|
+
loop-agent dag final-verification <task-id> # 生成 closeout DAG,closeout artifact 后再 final verify
|
|
204
|
+
loop-agent dag decision inspect --run-id <run-id> [--node-id <node-id>] # dry-run envelope 重解析;除 run 缺失外 exit 0
|
|
205
|
+
loop-agent dag decision validate --run-id <run-id> [--node-id <node-id>] # 同上;envelope 无效时 exit 1
|
|
206
|
+
loop-agent dag approve --run-id <run-id> --option <id> # decision gate 人工 approve
|
|
207
|
+
loop-agent dag reject --run-id <run-id> --reason "..." # reject paused run
|
|
208
|
+
loop-agent dag resume --run-id <run-id> # approve 后继续
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Decision gate(M3–M5)**:Pi node 上 `decisionGate.enabled: true` 启用 envelope 解析(M3 `record-only` 或 M4 `pause-on-human`)。M4 pause 后用 `dag approve/reject/resume/status/doctor` — 仅确定性 artifact,无新 `human`/`decision` executor。用 `dag report --paused-latest` 聚焦最新 paused run;`dag decision inspect|validate` 做 envelope dry-run(永不自动 resume/retry)。`browser` 仍 deferred。
|
|
212
|
+
|
|
213
|
+
**In-flight DAG governance**:shell verify node 内用 `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`;run 归档到 `completed/` 后,在 DAG 外跑裸 `bash scripts/check-repo.sh`。
|
|
214
|
+
|
|
215
|
+
- `dag validate` 做 schema/topology/ranks 检查;审 `warnings` 中的显式 `executorModels` drift 与 governance lint。
|
|
216
|
+
- 手写临时 DAG spec 执行前用 `dag validate --strict-models`,model-matrix drift 应 fail fast。
|
|
217
|
+
- read-only artifact-boundary 或 DAG 内 shell governance warning 应 fail fast 时用 `dag validate --strict-governance`。
|
|
218
|
+
- 人工 handoff 视图用 `dag report --markdown`(summary、node timeline、failures、四段 Recovery Plan、artifacts、建议 next action)。仅 derived、advisory;需保存时重定向到平台临时目录或 `docs/reports/`。
|
|
219
|
+
- operator 聚焦最新 paused run 用 `dag report --paused-latest`(等同 `--lifecycle paused --latest`;勿与显式 `--lifecycle` 并用)。
|
|
220
|
+
- 需 operator 关注的 run 用 `dag report --failed-only`、`--latest`、`--action <recovery-action>` 收窄。category→action 映射见 `docs/agent-dag-recovery-playbook.md`。
|
|
221
|
+
- 只读扫描 `.harness/dag-runs/` 下所有 run 的生命周期 health issue 与建议 action 用 `dag doctor`(`advisoryOnly: true`;不 mutate facts)。
|
|
222
|
+
- approve/resume 前用 `dag status --run-id <id>` 看单次 lifecycle、`approvalFlow`、`hasHumanApproval`。
|
|
223
|
+
- task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>'`。默认仅报告;`--patch` 显式且不能伪造 verification evidence。
|
|
224
|
+
- 大型 PRD closeout 用 `dag final-verification <task-id>` 生成确定性 DAG,final verification 在 closeout artifact 创建之后。
|
|
225
|
+
- 从 run facts dry-run envelope 解析用 `dag decision inspect|validate`;`validate` 在无效 envelope 时 exit 1;永不自动 resume/retry。
|
|
226
|
+
- Decision Gate prompt 可用 `buildDagDecisionGateEvidence()`(`src/workflows/dag/decision-evidence.ts`)做与 `dag report --json`、`docs/templates/agent-dag-report.schema.json` 对齐的只读摘要;不 mutate run state,不执行 retry/resume。
|
|
227
|
+
- 仅当有意在 `.harness/dag-runs/active/` 下要 active run snapshot 时用 `run-dag --dry-run`。
|
|
228
|
+
- task source 应从 `harness.json.workflowPolicy.dag.profileRouting` 与确定性 candidate `governanceProfile` 选 standard / review-gated / supervised template 时用 `dag run-task --profile auto`。无 `--profile` 仅用于旧 standard-compatible 输出;强制 template family 用 `--profile minimal|standard|reviewed|supervised`。
|
|
229
|
+
|
|
230
|
+
### Cursor worker lifecycle
|
|
231
|
+
```bash
|
|
232
|
+
loop-agent cursor-worker status # enabled/running/child/entry path
|
|
233
|
+
loop-agent cursor-worker stop # SIGTERM worker 并清 parent state
|
|
234
|
+
loop-agent cursor-worker ping # 启动 worker 并跑短 execute smoke(之后 stop worker)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- DAG / `executeCursorTask({ useWorker: true })` 保持长驻 Cursor SDK child,避免 CLI exit hang。
|
|
238
|
+
- Parent RPC timeout(`timeoutMs + 5s`)返回 `details.timeoutKind=rpc`,终止 worker(`SIGTERM`),defer SDK cancel(`cancelDeferred=true`,`cancelAttempted=false`);下次 execute 启动新 worker。
|
|
239
|
+
|
|
240
|
+
### 检查 task status
|
|
241
|
+
```bash
|
|
242
|
+
loop-agent status <task-id>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Docs governance helpers
|
|
246
|
+
```bash
|
|
247
|
+
loop-agent docs audit
|
|
248
|
+
loop-agent docs archive docs/exec-plans/active/<plan>.md
|
|
249
|
+
loop-agent plan list
|
|
250
|
+
loop-agent handoff check [task-id]
|
|
251
|
+
loop-agent handoff coverage <task-id> [--json|--markdown]
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
- `docs audit`:扫描文档腐化风险,如 active/completed 漂移、失效链接、host-gap closeout
|
|
255
|
+
- `docs archive`:将 active plan 迁入 completed,并自动重写常见 markdown 引用
|
|
256
|
+
- `plan list`:列出当前 active plans 及其解析状态
|
|
257
|
+
- `handoff check`:检查任务 source / artifacts / auto-commit scope 是否满足交付闭环
|
|
258
|
+
- `handoff coverage`:从 `source/需求.md` 抽取 checklist / numbered / `REQ-*` 项并输出 coverage audit;未覆盖项 exit 1;`explicitly_out_of_scope` 不计为缺口
|
|
259
|
+
|
|
260
|
+
### Pi runtime reuse benchmark / decision(无 live call)
|
|
261
|
+
```bash
|
|
262
|
+
loop-agent pi-reuse-benchmark \
|
|
263
|
+
--report docs/reports/<benchmark-report>.md \
|
|
264
|
+
--json
|
|
265
|
+
|
|
266
|
+
loop-agent pi-reuse-benchmark \
|
|
267
|
+
--report docs/reports/<benchmark-report>.md \
|
|
268
|
+
--off-executor /path/to/off/executor.jsonl \
|
|
269
|
+
--on-executor /path/to/on/executor.jsonl \
|
|
270
|
+
--approval /path/to/approval.json \
|
|
271
|
+
--markdown
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
对已有 benchmark plan/report 文件及可选 `executor.jsonl` evidence 做确定性摘要。**不**跑 live Pi call、不创建 task、不改 `CODE_AGENT_PI_REUSE_RUNTIME`(默认仍为 `off`)。输出 `defer`、`maintain-opt-in` 或 `eligible-for-human-review` — 永不 default-on。
|
|
275
|
+
|
|
276
|
+
### Loop convergence benchmark baseline(无 live call)
|
|
277
|
+
```bash
|
|
278
|
+
loop-agent loop-benchmark --markdown
|
|
279
|
+
loop-agent loop-benchmark --markdown --output docs/reports/2026-06-30-loop-agent-loop-benchmark.md
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
生成 M0 deterministic baseline,对照 `single-repair`、`3-pass-convergence`、`3-pass-convergence+quota`。**不**跑 live Pi/Cursor call、不创建 task、不改 `convergence.enabled` 默认值。live dogfood 证据缺失时输出 `blocked` 并建议保持 opt-in。
|
|
283
|
+
|
|
284
|
+
### Minimal spec spine audit
|
|
285
|
+
```bash
|
|
286
|
+
loop-agent spine audit <task-id> --json
|
|
287
|
+
loop-agent spine audit <task-id> --markdown
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
检查 task 的 `source/需求.md`、`source/执行约束.md`、`task.json.allowedPaths` / `forbiddenPaths`、需求覆盖与 final verification command labels。`medium` / `large` task 的空 `allowedPaths`、allowed/forbidden overlap、未覆盖验收项、无 final verify command 都会让 audit 非零退出。
|
|
291
|
+
|
|
292
|
+
### Knowledge curator proposal
|
|
293
|
+
```bash
|
|
294
|
+
loop-agent knowledge curate --markdown
|
|
295
|
+
loop-agent knowledge curate --markdown --output docs/reports/<task-id>-learned-proposal.md
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
读取 `.harness/knowledge/patterns.jsonl` 中 completed convergence repair pattern,按 `failureClass + fixScope shape + invariant` 去重,生成 human-gated learned guidance proposal。命令只生成 proposal,不直接修改 `./skill/references/learned/*.md`;输出会先通过 skill safety audit。
|
|
299
|
+
|
|
300
|
+
### 查看 duration statistics
|
|
301
|
+
```bash
|
|
302
|
+
loop-agent stats
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Worktree delegate / harvest(escape hatch)
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
loop-agent delegate <task-id> [--executor pi|cursor] [--base <branch>] [--branch <name>] [--no-symlink] [--auto-run] [--no-auto-run]
|
|
309
|
+
loop-agent harvest <task-id> [--squash] [--no-archive] [--keep-worktree]
|
|
310
|
+
loop-agent worktree create|list|remove ...
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
用于 worktree 隔离的 cursor-direct 执行与 merge 收口。常规 autonomous work 应优先 Agent DAG;详见 `multi-worktree.md` 与 `docs/cursor-executor-usage.md`。
|
|
314
|
+
|
|
315
|
+
> **Historical(已移除)**:`subagent list|start|wait|wakeup|attach|stop` 与 `dashboard` 已移除,不再出现在 CLI registry。
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Shared loop-agent Harness Policy
|
|
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.
|
|
4
|
+
|
|
5
|
+
## Canonical stance
|
|
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.
|
|
13
|
+
|
|
14
|
+
## Command surface tiers
|
|
15
|
+
|
|
16
|
+
| Tier | Default purpose | Commands |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| Primary | Normal autonomous implementation | `new-task` -> `dag run-task --profile auto` -> `dag validate --strict-models --strict-governance` -> `run-dag` |
|
|
19
|
+
| Operator | Diagnose, recover, close out, inspect facts | `status`, `instructions`, `dag status`, `dag doctor`, `dag report`, `dag closeout-draft`, `dag reconcile-tasks`, `dag final-verification`, `inspect`, `doctor`, `spine audit`, `knowledge curate`, `docs audit`, `handoff check`, `loop-benchmark` |
|
|
20
|
+
| Compatibility | Legacy task metadata and feature-study helpers | `goal`, `reference`, `study` |
|
|
21
|
+
| Escape hatch | Isolated delegation, one-shot diagnosis or bounded repair | `delegate`, `worktree`, `harvest`, `pi-prompt`, `cursor-prompt`, `cursor-worker` |
|
|
22
|
+
| Experimental | Long-running outer task state | `loop init|status|run|record-round|add-signal|closeout` |
|
|
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.
|
|
25
|
+
|
|
26
|
+
## Entry selection decision tree
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
Is this only status, diagnosis, recovery, or closeout?
|
|
30
|
+
yes -> Operator commands.
|
|
31
|
+
no -> Does it need recoverable, reviewable, verifiable implementation state?
|
|
32
|
+
no -> Use read-only pi-prompt for analysis, or a tiny main-session surgical patch only if obvious and immediately verifiable.
|
|
33
|
+
yes -> Agent DAG.
|
|
34
|
+
```
|
|
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.
|
|
43
|
+
|
|
44
|
+
## Agent DAG path
|
|
45
|
+
|
|
46
|
+
Minimum governed path:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
loop-agent new-task <task-id> "Task Title" [--repo-root <target-repo>]
|
|
50
|
+
# write <target-repo>/.harness/tasks/<task-id>/source/需求.md
|
|
51
|
+
# write <target-repo>/.harness/tasks/<task-id>/source/执行约束.md
|
|
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
|
+
|
|
64
|
+
loop-agent run-dag \
|
|
65
|
+
--dag <temp-dir>/<task-id>-dag.json \
|
|
66
|
+
--cwd <target-repo>
|
|
67
|
+
```
|
|
68
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
77
|
+
Before execution, review `dag run-task` JSON / `reviewPacket`:
|
|
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.
|
|
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.
|
|
89
|
+
|
|
90
|
+
## Task source materials
|
|
91
|
+
|
|
92
|
+
Every handoff-ready task has:
|
|
93
|
+
|
|
94
|
+
```text
|
|
95
|
+
.harness/tasks/<task-id>/
|
|
96
|
+
task.json
|
|
97
|
+
source/
|
|
98
|
+
需求.md
|
|
99
|
+
执行约束.md
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`需求.md` should state objective, scope, non-goals, acceptance criteria, and links to repo-local specs or plans.
|
|
103
|
+
|
|
104
|
+
`执行约束.md` should state:
|
|
105
|
+
|
|
106
|
+
- allowed paths
|
|
107
|
+
- forbidden paths
|
|
108
|
+
- current dirty workspace / protected user changes, if any
|
|
109
|
+
- architecture boundaries and invariants
|
|
110
|
+
- expected verification commands
|
|
111
|
+
- acceptance criteria / failure conditions
|
|
112
|
+
- whether DAG fallback is allowed, and the fallback reason if already known
|
|
113
|
+
|
|
114
|
+
If source materials change after `spec`, `plan`, or DAG generation, regenerate or revalidate the plan/DAG before implementation.
|
|
115
|
+
|
|
116
|
+
## Long-running loop policy
|
|
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.
|
|
119
|
+
|
|
120
|
+
Typical loop path for governed work:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
loop-agent loop init <task-id>
|
|
124
|
+
loop-agent loop run <task-id> --action dag
|
|
125
|
+
# review DAG packet / writeSet / shell gates
|
|
126
|
+
loop-agent loop run <task-id> --action dag --execute
|
|
127
|
+
loop-agent loop run <task-id> --action shell-verify --command "<repo-check>"
|
|
128
|
+
loop-agent loop run <task-id> --action pi-review
|
|
129
|
+
loop-agent loop run <task-id> --auto --max-rounds 3 --allow-cursor-fix
|
|
130
|
+
loop-agent loop closeout <task-id>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Loop action rules:
|
|
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.
|
|
145
|
+
|
|
146
|
+
## Supervised DAG convergence
|
|
147
|
+
|
|
148
|
+
Supervised DAG convergence is optional and task-config driven:
|
|
149
|
+
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"convergence": {
|
|
153
|
+
"enabled": true,
|
|
154
|
+
"maxPasses": 3,
|
|
155
|
+
"stopOnHardVerifyPass": true,
|
|
156
|
+
"pauseOnRegression": true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Rules:
|
|
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
|
|
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
|
+
|
|
178
|
+
## SePO-lite prompt evolution
|
|
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.
|
|
185
|
+
|
|
186
|
+
## Sidecar interventions
|
|
187
|
+
|
|
188
|
+
`pi-prompt` and `cursor-prompt` are sidecar interventions, not workflow state.
|
|
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:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
loop-agent pi-prompt \
|
|
194
|
+
--cwd <repo-root> \
|
|
195
|
+
--tools read,grep,find,ls \
|
|
196
|
+
--timeout 2400000 \
|
|
197
|
+
"Read the task source and diagnose the failure. Do not edit files."
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Use `cursor-prompt` for bounded multi-file diagnosis or small repair only when the prompt includes:
|
|
201
|
+
|
|
202
|
+
- task id
|
|
203
|
+
- exact objective
|
|
204
|
+
- allowed paths
|
|
205
|
+
- forbidden paths
|
|
206
|
+
- hard constraints
|
|
207
|
+
- expected verification
|
|
208
|
+
- instruction to preserve unrelated files
|
|
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.
|
|
211
|
+
|
|
212
|
+
## Model and executor boundaries
|
|
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.
|
|
221
|
+
|
|
222
|
+
## Artifacts and facts boundary
|
|
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.
|
|
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.
|
|
232
|
+
|
|
233
|
+
## Baseline, dirty workspace, and verification
|
|
234
|
+
|
|
235
|
+
Before complex implementation:
|
|
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.
|
|
244
|
+
|
|
245
|
+
Verification should be selected from the target repo's verification matrix. For cross-repo documentation refactors, run checks in each affected repo.
|
|
246
|
+
|
|
247
|
+
## Handoff requirements
|
|
248
|
+
|
|
249
|
+
Every task handoff should answer:
|
|
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.
|