@tea-agent/loop-agent 0.9.0 → 0.10.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 +42 -11
- package/README.md +20 -0
- package/dist/cli/command-definitions.js +7 -0
- package/dist/cli/program.js +6 -1
- package/dist/commands/dag-reconcile-run.js +118 -0
- package/dist/commands/init.js +12 -3
- package/dist/governance/manifest-types.js +4 -0
- package/dist/worker/cli.js +216 -0
- package/dist/worker/closeout/apply.js +73 -0
- package/dist/worker/closeout/preview.js +30 -0
- package/dist/worker/delivery/final-verification.js +158 -0
- package/dist/worker/delivery/git-transaction.js +354 -0
- package/dist/worker/delivery/package.js +449 -0
- package/dist/worker/feature/decision-loader.js +68 -0
- package/dist/worker/feature/discover.js +14 -0
- package/dist/worker/feature/next-action.js +74 -0
- package/dist/worker/feature/reducer.js +133 -0
- package/dist/worker/feature/review.js +502 -0
- package/dist/worker/feature/run.js +313 -0
- package/dist/worker/feature/types.js +1 -0
- package/dist/worker/follow-up/approve.js +270 -0
- package/dist/worker/follow-up/factory.js +234 -0
- package/dist/worker/follow-up/paths.js +25 -0
- package/dist/worker/follow-up/policy.js +26 -0
- package/dist/worker/follow-up/schema.js +93 -0
- package/dist/worker/follow-up/store.js +96 -0
- package/dist/worker/metrics/projector.js +139 -0
- package/dist/worker/observability/read-model.js +256 -15
- package/dist/worker/observe/paths.js +17 -5
- package/dist/worker/observe/static/app.js +443 -61
- package/dist/worker/observe/static/index.html +3 -1
- package/dist/worker/observe/static/styles.css +86 -19
- package/dist/worker/pool/run-store.js +14 -2
- package/dist/worker/pool/validation.js +59 -0
- package/dist/worker/report/morning-report.js +41 -6
- package/dist/worker/run-task/run-task.js +1 -1
- package/dist/worker/runner/run-ready.js +19 -5
- package/dist/workflows/dag/init-hybrid.js +3 -1
- package/dist/workflows/dag/lifecycle.js +146 -0
- package/dist/workflows/dag/node-execution.js +3 -0
- package/dist/workflows/dag/prompt.js +16 -0
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/runner.js +133 -104
- package/dist/workflows/dag/types.js +3 -0
- package/docs/README.md +17 -0
- package/docs/agent-dag-recovery-playbook.md +1 -1
- package/docs/architecture/runtime-boundaries.md +3 -2
- package/docs/design/README.md +11 -5
- package/docs/exec-plans/active/README.md +1 -1
- package/docs/exec-plans/completed/README.md +8 -1
- package/docs/loop-agent-harness.md +45 -2
- package/docs/progress/README.md +2 -0
- package/docs/reports/README.md +10 -0
- package/docs/templates/agent-dag-report.schema.json +5 -3
- package/docs/templates/harness.schema.json +7 -2
- package/docs/templates/init-evolution-review.md +4 -2
- package/docs/verification-matrix.md +7 -0
- package/harness.json +4 -3
- package/package.json +4 -2
- package/scripts/check-product-line-docs.sh +7 -3
- package/skills/init-capability-evolution/SKILL.md +1 -0
- package/skills/loop-agent/references/command-reference.md +21 -0
- package/skills/loop-agent/references/hybrid-dag.md +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
这里记录每个版本对使用者有影响的变化。命令名和配置字段保持原样,其余内容尽量用日常语言说明。
|
|
4
4
|
|
|
5
|
-
## [Unreleased]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
|
|
9
|
+
- 严格初始化演化检查现在接受 `Head` 为当前 `HEAD` 可解析祖先提交的报告:只要 `Base` 精确匹配 `--base`、`Head` 是 `HEAD` 或其祖先,且 `reportHead..HEAD` 区间没有新的 `model-review` 高影响路径即可通过。仅 `advisory` 或 `surface-check` 的后续变化不会让已完成的高影响审查失效;`working tree` 等不可解析 Head 与无关历史报告仍被拒绝。
|
|
10
|
+
|
|
11
|
+
- 新增只读的 `agent-worker feature review`。用户无需翻查原始日志,即可查看 Feature 当前状态、主要阻塞、required AC 覆盖、证据位置和下一条建议命令;`--json` 可供脚本稳定消费。
|
|
12
|
+
- 新增 `agent-worker feature run`。它会先校验 Feature 和目标仓库,再复用现有 Worker pipeline 推进一个 Ready Task,随后刷新晨报、Observe snapshot 和 Feature review;`--dry-run` 可在零写入下预览步骤与产物。
|
|
13
|
+
- 新增 ProductBug Follow-up 人工接续流程。`agent-worker task draft-followup` 生成可审查、可去重的修复草稿;`agent-worker feature approve-followup --dry-run` 可先检查变更计划,批准后再新增 FIX Task、重连下游依赖并进入 Ready,同时保留原失败证据。
|
|
14
|
+
- Follow-up 现已覆盖全部失败分类:可执行类生成严格 TaskSpec,Spec/Risk/Human 类生成行动卡,EnvFailure 只有连续两次失败后才建议环境检查任务;审批事务增加多阶段回滚验证,避免 Packet、Ready state、approval 或 index 半写。
|
|
15
|
+
- `agent-worker feature run --git-mode checkpoint` 新增显式授权的本地 Feature 分支事务。成功任务形成带 Feature/Task/AC/run 信息的 checkpoint commit;失败任务保存 patch 与 untracked 证据后恢复 clean。默认仍不 commit,也不会 push、stash、merge 或创建远程 PR。
|
|
16
|
+
- 新增 `agent-worker feature verify-final`、`feature delivery` 与 Feature Closeout。用户可在 clean Delivery HEAD 上生成 canonical QA/最终验证证据,再从 checkpoint、成功 run 和 required AC 形成带 hash 的 Delivery Package、Acceptance Coverage 与 PR 草稿;Closeout 默认预览,只有显式 `--apply --owner` 才原子写回并保留幂等、stale facts 与回滚保护。
|
|
17
|
+
- Morning report 与 Observe 首页新增共享的 Feature Decision Summary,优先显示状态、下一步、原因、证据和 required AC。新增 `agent-worker report metrics --month YYYY-MM`,同时输出带分母、样本量、时间窗口和缺失数据说明的 JSON/Markdown。
|
|
18
|
+
- Observe 总览新增仓库横幅,显示仓库名与绝对路径;KPI 按主要执行链路排列为“Worker 执行”在前、“DAG 运行”在后,DAG 组明确展示活跃运行、执行中/等待节点、暂停和需处理运行,“活跃 Task”更名为“活跃 Worker Task”,每张卡片新增可键盘聚焦的问号帮助,解释数据来源与统计口径。
|
|
19
|
+
- Observe 总览的 Feature 决策仅在存在“运行中”或“需处理”的 Feature 时显示;只有可执行、待验收、已交付或已关闭记录时不再占用总览空间。
|
|
20
|
+
|
|
21
|
+
### 修改
|
|
22
|
+
|
|
23
|
+
- 根目录 `design/` 已并入 `docs/design/`,视觉参考与产品线设计笔记现在统一从治理文档目录查找,相关索引和引用已同步更新。
|
|
24
|
+
- Agent DAG 的 Pi/Cursor 节点现在默认使用简体中文输出说明、分析、报告和文档;可通过 `workflowPolicy.dag.outputLanguage: "en"` 切换英文,代码、命令、路径、JSON 字段和固定协议 token 不会被翻译。
|
|
25
|
+
- Dashboard 将“运行活性”调整为更直观的“执行器状态”,并明确区分执行器正常、心跳中断、已经退出、其他主机运行以及旧记录没有心跳等情况。
|
|
26
|
+
- 修复 Dashboard 综合 DAG 状态使用中文文案后丢失徽章颜色的问题;完成、失败、暂停、中断和任务已另行完成现在恢复对应的语义颜色。
|
|
27
|
+
- Dashboard 节点耗时达到 60 秒后改为按“分钟 + 秒”显示,例如 `2min 5s`,长任务更容易快速阅读。
|
|
28
|
+
- Dashboard 的 DAG 节点模型列现在会显示 Pi/Cursor 节点实际路由到的模型;历史运行从 `run.json` 模型矩阵推导,新运行会直接把解析后的模型写入节点状态,Shell/Static 节点仍显示 `-`。
|
|
29
|
+
- Dashboard 现在优先展示由生命周期、原始状态和运行活性共同判定的 DAG 当前状态,并单独保留原始记录;新增 `dag reconcile-run`,可在确认执行器已停止后将历史失联 DAG 显式标记为“任务已另行完成”或“已放弃”,同时保存收口前证据。
|
|
30
|
+
- Observe DAG 详情页主信息区精简为单一“状态”,已结束 DAG 不再展示执行器心跳等无意义内部维度,状态一致或不允许恢复/收口时也不再显示“一致”或“否”;不一致、可恢复或可收口的警告与操作能力仍在主视图可见,原始状态、生命周期、活性、状态一致性与恢复资格折叠在“诊断信息”中保留。
|
|
31
|
+
- DAG 运行现在记录本机执行器 PID、主机和持续心跳;`dag status` / `dag doctor` 可区分活跃、节点长时间无活动、心跳停滞、执行器已退出和远端状态未知,Observe 也不会再把已知孤儿或 paused 运行计为活跃 DAG。
|
|
32
|
+
- 节点检查器支持拖动左边缘调整宽度,长 Markdown 表格和输出更容易查看;点击外部空白区域可平滑收起面板。
|
|
33
|
+
- 执行过程改为更清晰的事件轨道:工具调用、AI 回复和 Agent 生命周期更容易区分;没有时间记录时会按采集顺序展示,连续协议事件会自动合并,减少无关噪声。
|
|
34
|
+
- Observe 风险区拆为“需处理 DAG”与“Worker 风险”两个子块;DAG 按运行去重,不会因同一运行同时存在多个异常信号而重复计数,也不会让历史失败记录长期占用当前风险;Snapshot 投影失败不再静默显示为全零健康状态,而是返回安全错误摘要并在总览提示“指标暂不可用”,不含堆栈或敏感信息。
|
|
35
|
+
- 修复旧版(未写 runner 心跳元数据)的运行中 DAG 被 Observe 误判为不活跃的问题:`effectiveStatus=unknown` 只表示活性证据不足,不再覆盖 `lifecycle=active` 且原始 `status` 为 `running`/`pending` 的运行事实,也不再掩盖存在 RUNNING/PENDING 节点的运行。服务端健康计数(活跃运行、执行中节点、等待节点)与前端进行中 DAG 列表现在使用一致的判定语义;`paused`、`terminal`、`stale`、`orphaned` 等明确非活跃事实仍优先于原始 `running`。
|
|
36
|
+
- `npm test` 会先运行可并行的纯测试,再串行运行会启动 CLI 或子进程的集成测试。纯测试会根据机器可用并行度自动选择 1 至 4 个 Worker,低配和高配环境都能在稳定性与速度之间取得更合适的平衡。
|
|
37
|
+
|
|
38
|
+
## [0.9.0] - 2026-07-12
|
|
39
|
+
|
|
40
|
+
### 修复
|
|
10
41
|
|
|
11
42
|
- 修复 Observe 总览误把已结束、但仍保留未执行节点的 DAG 显示为“活跃 DAG”的问题。
|
|
12
43
|
- DAG 详情页中的节点输出、错误输出、依赖图和执行过程会在轮询更新时保留当前查看位置,不再把页面拉回默认位置。
|
|
@@ -18,12 +49,12 @@
|
|
|
18
49
|
- DAG shell 命令和 Worker 调用遇到大量输出时,只在内存中保留最近一段内容并标明截断;完整 stdout/stderr 仍会写入运行产物,避免长日志拖慢本机。
|
|
19
50
|
- 建立 reference index 时会跳过依赖、构建产物、虚拟环境和版本控制目录,并在遍历规模过大时提前停止,减少误扫大型仓库。
|
|
20
51
|
|
|
21
|
-
### 修改
|
|
22
|
-
|
|
23
|
-
- Observe 看板改为暖白运行控制台:总览、批次、Task、DAG 和异常页面使用统一的信息层级;DAG 详情中的依赖图和节点表各自完整展示,选择节点后可从右侧检查器查看输出和执行过程。
|
|
24
|
-
- 统一整理运行看板的总览、批次详情、运行详情、DAG 详情和异常 Task 页面:先展示当前状态和风险,再呈现运行记录、输出与产物,桌面端查看信息更集中。
|
|
25
|
-
- 最近 DAG 运行改为按时间排列的状态时间线,标题过长时不会再挤压状态;DAG 详情仍可从每条记录直接进入。
|
|
26
|
-
- 优化节点表格和宽屏布局:节点 ID、模型、状态、耗时和备注更容易扫读;节点输出支持 Markdown 阅读,完成节点在依赖图中以绿色状态提示。
|
|
52
|
+
### 修改
|
|
53
|
+
|
|
54
|
+
- Observe 看板改为暖白运行控制台:总览、批次、Task、DAG 和异常页面使用统一的信息层级;DAG 详情中的依赖图和节点表各自完整展示,选择节点后可从右侧检查器查看输出和执行过程。
|
|
55
|
+
- 统一整理运行看板的总览、批次详情、运行详情、DAG 详情和异常 Task 页面:先展示当前状态和风险,再呈现运行记录、输出与产物,桌面端查看信息更集中。
|
|
56
|
+
- 最近 DAG 运行改为按时间排列的状态时间线,标题过长时不会再挤压状态;DAG 详情仍可从每条记录直接进入。
|
|
57
|
+
- 优化节点表格和宽屏布局:节点 ID、模型、状态、耗时和备注更容易扫读;节点输出支持 Markdown 阅读,完成节点在依赖图中以绿色状态提示。
|
|
27
58
|
|
|
28
59
|
## [0.8.0] - 2026-07-11
|
|
29
60
|
|
package/README.md
CHANGED
|
@@ -92,9 +92,29 @@ loop-agent pi-prompt --cwd . --tools read,bash,edit,write,grep,find,ls "<包含
|
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
94
|
agent-worker task validate-feature <feature-dir>
|
|
95
|
+
agent-worker feature review --feature-dir <feature-dir> --repo <target-repo>
|
|
96
|
+
agent-worker feature run --feature-dir <feature-dir> --repo <target-repo> --dry-run [--git-mode checkpoint]
|
|
97
|
+
agent-worker feature verify-final --feature-dir <feature-dir> --repo <target-repo> --task-id <qa-execute-id>
|
|
98
|
+
agent-worker feature delivery --feature-dir <feature-dir> --repo <target-repo> --qa-evidence <path> --final-verification <path> [--dry-run]
|
|
99
|
+
agent-worker feature closeout --feature-dir <feature-dir> --repo <target-repo> [--apply --owner <owner>]
|
|
100
|
+
agent-worker report metrics --repo <target-repo> --month <YYYY-MM>
|
|
101
|
+
agent-worker task draft-followup <task-id> --worker-run-id <id> --feature-dir <feature-dir> --repo <target-repo>
|
|
102
|
+
agent-worker feature approve-followup --feature-dir <feature-dir> --followup-id <id> --repo <target-repo> --owner <owner> --dry-run
|
|
95
103
|
bash scripts/worker-nightly.sh <feature-dir> <target-repo> <batch-run-id>
|
|
96
104
|
```
|
|
97
105
|
|
|
106
|
+
`feature review` 是只读的 Feature 级入口。它从 Feature Packet 和现有 Task Pool 事实派生状态、required AC 覆盖、阻塞、证据和唯一主行动;默认输出简洁人类摘要,`--json` 输出稳定的 schemaVersion 1 读模型。它不会写入 Feature Packet 或 Task Pool。
|
|
107
|
+
|
|
108
|
+
`feature verify-final` 在 clean Delivery HEAD 上复用已完成的 `qa-execute` TaskSpec,执行独立、不会 promote/closeout 或移动 HEAD 的最终验证,并原子投影 canonical QA aggregate 与 HEAD-bound final-verification evidence。`feature delivery` 复用 checkpoint transaction,校验 branch/HEAD/clean、commit trailers、changed files、成功 run、QA、最终验证和 required AC 后,在 `.harness/task-pool/` 原子生成 Delivery manifest、Acceptance Coverage 与 `PR.md`;`--dry-run` 零写入。`feature closeout` 默认只预览 gates;显式 `--apply --owner <owner>` 才会在前后校验与整体回滚保护下写入 Feature Closeout,重复相同 facts 会幂等复用。
|
|
109
|
+
|
|
110
|
+
Morning report 和 Observe snapshot/UI 复用同一 Feature reducer,优先展示 Status、Next Action、Why、Evidence。`report metrics` 同时生成 monthly JSON/Markdown,所有比例都包含分子、分母、样本量、UTC 窗口和缺失数据说明。
|
|
111
|
+
|
|
112
|
+
`feature run` 把 validation、目标仓库 preflight、Ready Queue、现有 `run-ready`、晨报、Observe snapshot 和最终 review 串成一次 Feature 意图。默认不写 Git 且每次最多推进一个 Ready 写任务。显式 `--git-mode checkpoint` 才允许创建本地 `agent/<feature-id>` 分支:每个成功任务通过 write-boundary/sensitive-file audit 后提交 checkpoint;失败任务先保存 binary patch、changed/untracked inventory 与内容,再恢复到最近 checkpoint 并验证 clean。它从不授权 push、远程 PR、merge 或 stash。`--keep-failed-diff` 会保留失败 diff、返回 NeedsAction 并立即停止后续任务。
|
|
113
|
+
|
|
114
|
+
如果 Task 产生业务失败,`feature run` 仍会完成晨报、snapshot 和最终 review,但结果为 `needs-action`、进程退出非零,并保留 batch 与失败证据;无 Ready 时正常退出,并通过 `noReadyReason` 区分已关闭、可交付、待 QA、需人工处理、依赖阻塞或空 Feature。
|
|
115
|
+
|
|
116
|
+
失败可通过显式 Follow-up 决策闭环接续:ProductBug、TestBug、FlakyTest、DependencyFailure 会生成可批准 Task 草稿;EnvFailure 最近两次连续失败后才生成 `ENV-CHECK-*`,否则优先给出 retry;SpecUnclear、ContractMismatch、RiskyChange、NeedsHuman、Unknown 只生成人工行动卡,绝不进入 Ready。人工用 `feature approve-followup --dry-run` 复核 baseline、证据 hash、ID 冲突和事务计划,再带 `--owner` 批准。批准后新增 TaskSpec、重连下游依赖并进入 Ready;原失败 run/state/handoff 保持不变,重复 run 的新草稿会 supersede 旧 unresolved 草稿但保留历史。
|
|
117
|
+
|
|
98
118
|
nightly wrapper 按 feature 互斥,保留批次/超时退出码,并输出 morning report、Observe snapshot 和 controller 版本 artifacts。
|
|
99
119
|
|
|
100
120
|
自 0.8.0 起,`.harness/task-pool/` 是唯一受支持的 Task Pool runtime root,其中包含根级 `runs.jsonl`、`events.jsonl`、`states/`、`artifacts/`、`failure-handoffs/`、`observability/` 和 `reports/`。这是 hard cutover:旧路径不读取、不迁移、不合并、不重映射;升级意味着本地 Worker Task Pool 历史重置。
|
|
@@ -29,6 +29,7 @@ import { runDagWorkflowPlan } from "../commands/dag-workflow-plan.js";
|
|
|
29
29
|
import { runDagApprove } from "../commands/dag-approve.js";
|
|
30
30
|
import { runDagReject } from "../commands/dag-reject.js";
|
|
31
31
|
import { runDagReconcileTasks } from "../commands/dag-reconcile-tasks.js";
|
|
32
|
+
import { runDagReconcileRun } from "../commands/dag-reconcile-run.js";
|
|
32
33
|
import { runDagResume } from "../commands/dag-resume.js";
|
|
33
34
|
import { runDagDecisionInspect, runDagDecisionValidate, } from "../workflows/dag/decision-envelope.js";
|
|
34
35
|
import { runDagDoctor, runDagStatus } from "../workflows/dag/lifecycle.js";
|
|
@@ -81,6 +82,7 @@ const DAG_SUBCOMMANDS = [
|
|
|
81
82
|
"doctor",
|
|
82
83
|
"report",
|
|
83
84
|
"closeout-draft",
|
|
85
|
+
"reconcile-run",
|
|
84
86
|
"reconcile-tasks",
|
|
85
87
|
"final-verification",
|
|
86
88
|
"decision",
|
|
@@ -485,6 +487,11 @@ export const COMMAND_DEFINITIONS = [
|
|
|
485
487
|
await runDagCloseoutDraft(repoRoot, closeoutArgs);
|
|
486
488
|
return;
|
|
487
489
|
}
|
|
490
|
+
if (subcommand === "reconcile-run") {
|
|
491
|
+
const reconcileRunArgs = rest.filter((arg) => Boolean(arg));
|
|
492
|
+
await runDagReconcileRun(repoRoot, reconcileRunArgs);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
488
495
|
if (subcommand === "reconcile-tasks") {
|
|
489
496
|
const reconcileArgs = rest.filter((arg) => Boolean(arg));
|
|
490
497
|
await runDagReconcileTasks(repoRoot, reconcileArgs);
|
package/dist/cli/program.js
CHANGED
|
@@ -10,6 +10,7 @@ import { runDagApprove } from "../commands/dag-approve.js";
|
|
|
10
10
|
import { runDagFinalVerification } from "../commands/dag-final-verification.js";
|
|
11
11
|
import { runDagInitHybrid } from "../commands/dag-init-hybrid.js";
|
|
12
12
|
import { runDagReconcileTasks } from "../commands/dag-reconcile-tasks.js";
|
|
13
|
+
import { runDagReconcileRun } from "../commands/dag-reconcile-run.js";
|
|
13
14
|
import { runDagReject } from "../commands/dag-reject.js";
|
|
14
15
|
import { runDagCloseoutDraft, runDagReport } from "../commands/dag-report.js";
|
|
15
16
|
import { runDagResume } from "../commands/dag-resume.js";
|
|
@@ -300,6 +301,9 @@ async function runDagAction(repoRoot, subcommand, rest) {
|
|
|
300
301
|
case "closeout-draft":
|
|
301
302
|
await runDagCloseoutDraft(repoRoot, args);
|
|
302
303
|
return;
|
|
304
|
+
case "reconcile-run":
|
|
305
|
+
await runDagReconcileRun(repoRoot, args);
|
|
306
|
+
return;
|
|
303
307
|
case "reconcile-tasks":
|
|
304
308
|
await runDagReconcileTasks(repoRoot, args);
|
|
305
309
|
return;
|
|
@@ -319,7 +323,7 @@ async function runDagAction(repoRoot, subcommand, rest) {
|
|
|
319
323
|
throw new Error("usage: dag decision <inspect|validate> --run-id <id> [--node-id <node-id>]");
|
|
320
324
|
}
|
|
321
325
|
default:
|
|
322
|
-
throw new Error("usage: dag <init-hybrid|run-task|validate|workflow-plan|workflow-validate|workflow-compile|approve|reject|resume|status|doctor|report|closeout-draft|reconcile-tasks|final-verification|decision> ...");
|
|
326
|
+
throw new Error("usage: dag <init-hybrid|run-task|validate|workflow-plan|workflow-validate|workflow-compile|approve|reject|resume|status|doctor|report|closeout-draft|reconcile-run|reconcile-tasks|final-verification|decision> ...");
|
|
323
327
|
}
|
|
324
328
|
}
|
|
325
329
|
function compactArgs(args) {
|
|
@@ -450,6 +454,7 @@ function addDagCommand(program, defaultRepoRoot) {
|
|
|
450
454
|
"doctor",
|
|
451
455
|
"report",
|
|
452
456
|
"closeout-draft",
|
|
457
|
+
"reconcile-run",
|
|
453
458
|
"reconcile-tasks",
|
|
454
459
|
"final-verification",
|
|
455
460
|
], defaultRepoRoot);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { writeJsonAtomic } from "../infrastructure/harness/atomic-write.js";
|
|
3
|
+
import { assessDagRunLiveness, assessDagRunRecoveryEligibility, assertDagRunTransferTargetAvailable, getDagRunDir, locateDagRun, readDagRunState, transferDagRunDir, writeDagRunState, } from "../workflows/dag/lifecycle.js";
|
|
4
|
+
export function parseDagReconcileRunArgs(args) {
|
|
5
|
+
let runId;
|
|
6
|
+
let action;
|
|
7
|
+
let reason;
|
|
8
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
9
|
+
const arg = args[index];
|
|
10
|
+
if (arg === "--run-id")
|
|
11
|
+
runId = args[++index];
|
|
12
|
+
else if (arg.startsWith("--run-id="))
|
|
13
|
+
runId = arg.slice("--run-id=".length);
|
|
14
|
+
else if (arg === "--action")
|
|
15
|
+
action = parseAction(args[++index]);
|
|
16
|
+
else if (arg.startsWith("--action="))
|
|
17
|
+
action = parseAction(arg.slice("--action=".length));
|
|
18
|
+
else if (arg === "--reason")
|
|
19
|
+
reason = args[++index];
|
|
20
|
+
else if (arg.startsWith("--reason="))
|
|
21
|
+
reason = arg.slice("--reason=".length);
|
|
22
|
+
else if (arg.startsWith("-"))
|
|
23
|
+
throw new Error(`unknown dag reconcile-run flag: ${arg}`);
|
|
24
|
+
else
|
|
25
|
+
throw new Error(`unexpected positional argument: ${arg}`);
|
|
26
|
+
}
|
|
27
|
+
if (!runId)
|
|
28
|
+
throw new Error("dag reconcile-run requires --run-id <id>");
|
|
29
|
+
if (action && !reason?.trim()) {
|
|
30
|
+
throw new Error("dag reconcile-run mutation requires --reason <text>");
|
|
31
|
+
}
|
|
32
|
+
return { runId, action, ...(reason?.trim() ? { reason: reason.trim() } : {}) };
|
|
33
|
+
}
|
|
34
|
+
function parseAction(value) {
|
|
35
|
+
if (value === "supersede" || value === "abandon")
|
|
36
|
+
return value;
|
|
37
|
+
throw new Error("dag reconcile-run --action must be supersede or abandon");
|
|
38
|
+
}
|
|
39
|
+
export async function runDagReconcileRun(repoRoot, rawArgs) {
|
|
40
|
+
const parsed = parseDagReconcileRunArgs(rawArgs);
|
|
41
|
+
const located = await locateDagRun(repoRoot, parsed.runId);
|
|
42
|
+
if (!located)
|
|
43
|
+
throw new Error(`dag run not found: ${parsed.runId}`);
|
|
44
|
+
const state = await readDagRunState(located.runDir);
|
|
45
|
+
const liveness = assessDagRunLiveness({ state });
|
|
46
|
+
const eligibility = assessDagRunRecoveryEligibility({
|
|
47
|
+
lifecycle: located.lifecycle,
|
|
48
|
+
state,
|
|
49
|
+
liveness: liveness.status,
|
|
50
|
+
});
|
|
51
|
+
if (!parsed.action) {
|
|
52
|
+
console.log(JSON.stringify({
|
|
53
|
+
action: "inspect",
|
|
54
|
+
runId: state.runId,
|
|
55
|
+
lifecycle: located.lifecycle,
|
|
56
|
+
status: state.status,
|
|
57
|
+
liveness: liveness.status,
|
|
58
|
+
eligibility,
|
|
59
|
+
nextRecommendedAction: eligibility.canReconcile
|
|
60
|
+
? "Re-run with --action supersede|abandon and --reason <text>."
|
|
61
|
+
: "Do not reconcile this run; inspect runner and lifecycle evidence first.",
|
|
62
|
+
}, null, 2));
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!eligibility.canReconcile || !eligibility.allowedActions.includes(parsed.action)) {
|
|
66
|
+
throw new Error(`dag run ${state.runId} is not eligible for reconciliation: ${eligibility.reasons.join(", ") || "unknown reason"}`);
|
|
67
|
+
}
|
|
68
|
+
const reconciledAt = new Date().toISOString();
|
|
69
|
+
const completedRunDir = getDagRunDir(repoRoot, "completed", state.runId);
|
|
70
|
+
if (located.lifecycle !== "completed") {
|
|
71
|
+
await assertDagRunTransferTargetAvailable(completedRunDir);
|
|
72
|
+
}
|
|
73
|
+
const artifactRelativePath = path.join(".harness", "dag-runs", "completed", state.runId, "reconciliation.json").replace(/\\/g, "/");
|
|
74
|
+
await writeJsonAtomic(path.join(located.runDir, "reconciliation.json"), {
|
|
75
|
+
schemaVersion: 1,
|
|
76
|
+
runId: state.runId,
|
|
77
|
+
action: parsed.action,
|
|
78
|
+
reason: parsed.reason,
|
|
79
|
+
reconciledAt,
|
|
80
|
+
previousLifecycle: located.lifecycle,
|
|
81
|
+
previousStatus: state.status,
|
|
82
|
+
liveness: liveness.status,
|
|
83
|
+
originalState: state,
|
|
84
|
+
});
|
|
85
|
+
const previousStatus = state.status;
|
|
86
|
+
for (const node of Object.values(state.nodes)) {
|
|
87
|
+
if (node.status !== "RUNNING")
|
|
88
|
+
continue;
|
|
89
|
+
node.status = "ERROR";
|
|
90
|
+
node.finishedAt = reconciledAt;
|
|
91
|
+
node.failureCategory = `operator-${parsed.action}`;
|
|
92
|
+
}
|
|
93
|
+
state.status = parsed.action === "supersede" ? "superseded" : "abandoned";
|
|
94
|
+
state.finishedAt = reconciledAt;
|
|
95
|
+
state.failureCategory = `operator-${parsed.action}`;
|
|
96
|
+
state.reconciliation = {
|
|
97
|
+
action: parsed.action,
|
|
98
|
+
reason: parsed.reason,
|
|
99
|
+
reconciledAt,
|
|
100
|
+
previousStatus,
|
|
101
|
+
previousLifecycle: located.lifecycle,
|
|
102
|
+
liveness: liveness.status,
|
|
103
|
+
artifactPath: artifactRelativePath,
|
|
104
|
+
};
|
|
105
|
+
await writeDagRunState(located.runDir, state);
|
|
106
|
+
const runDir = located.lifecycle === "completed"
|
|
107
|
+
? located.runDir
|
|
108
|
+
: await transferDagRunDir(located.runDir, completedRunDir);
|
|
109
|
+
console.log(JSON.stringify({
|
|
110
|
+
action: parsed.action,
|
|
111
|
+
runId: state.runId,
|
|
112
|
+
status: state.status,
|
|
113
|
+
lifecycle: "completed",
|
|
114
|
+
reason: parsed.reason,
|
|
115
|
+
reconciliationArtifactPath: artifactRelativePath,
|
|
116
|
+
runDir,
|
|
117
|
+
}, null, 2));
|
|
118
|
+
}
|
package/dist/commands/init.js
CHANGED
|
@@ -443,11 +443,20 @@ fi
|
|
|
443
443
|
feature_dirs=()
|
|
444
444
|
for root in features product/features dogfood/features; do
|
|
445
445
|
[[ -d "\${root}" ]] || continue
|
|
446
|
-
while IFS= read -r
|
|
447
|
-
|
|
448
|
-
|
|
446
|
+
while IFS= read -r feature_dir; do
|
|
447
|
+
if [[ ! -f "\${feature_dir}/acceptance.yaml" ]]; then
|
|
448
|
+
echo "product-line docs check failed: incomplete feature packet missing acceptance.yaml: \${feature_dir}" >&2
|
|
449
|
+
exit 1
|
|
450
|
+
fi
|
|
451
|
+
feature_dirs+=("\${feature_dir}")
|
|
452
|
+
done < <(find "\${root}" -mindepth 1 -maxdepth 1 -type d | sort)
|
|
449
453
|
done
|
|
450
454
|
|
|
455
|
+
if [[ \${#feature_dirs[@]} -eq 0 ]]; then
|
|
456
|
+
echo "product-line docs check skipped: no feature packets found"
|
|
457
|
+
exit 0
|
|
458
|
+
fi
|
|
459
|
+
|
|
451
460
|
for feature_dir in "\${feature_dirs[@]}"; do
|
|
452
461
|
echo "==> validate product-line feature: \${feature_dir}"
|
|
453
462
|
agent-worker task validate-feature "\${feature_dir}"
|
|
@@ -42,6 +42,7 @@ export const workflowPolicyDagTemplateSchema = z.enum([
|
|
|
42
42
|
"review-gated-dag",
|
|
43
43
|
"supervised-implementation",
|
|
44
44
|
]);
|
|
45
|
+
export const workflowPolicyOutputLanguageSchema = z.enum(["zh-CN", "en"]);
|
|
45
46
|
export const workflowPolicySchema = z
|
|
46
47
|
.object({
|
|
47
48
|
/** Preferred implementation workflow for recoverable loop-agent work. Declarative policy; callers may still require explicit CLI flags. */
|
|
@@ -51,6 +52,9 @@ export const workflowPolicySchema = z
|
|
|
51
52
|
.default("agent-dag"),
|
|
52
53
|
dag: z
|
|
53
54
|
.object({
|
|
55
|
+
outputLanguage: workflowPolicyOutputLanguageSchema
|
|
56
|
+
.optional()
|
|
57
|
+
.default("zh-CN"),
|
|
54
58
|
defaultEntry: z
|
|
55
59
|
.enum(["dag run-task", "run-dag"])
|
|
56
60
|
.optional()
|
package/dist/worker/cli.js
CHANGED
|
@@ -17,6 +17,15 @@ import { getTaskPoolRoot, prepareTaskPoolRetry } from "./pool/run-store.js";
|
|
|
17
17
|
import { taskSpecSchema } from "./task-spec/schema.js";
|
|
18
18
|
import { validateTaskSpec } from "./task-spec/validate.js";
|
|
19
19
|
import { validateFeatureTaskGraph } from "./task-graph/validate.js";
|
|
20
|
+
import { renderFeatureReview, reviewFeature } from "./feature/review.js";
|
|
21
|
+
import { renderFeatureRun, runFeature } from "./feature/run.js";
|
|
22
|
+
import { draftFollowUpDecision } from "./follow-up/factory.js";
|
|
23
|
+
import { approveFollowUp } from "./follow-up/approve.js";
|
|
24
|
+
import { prepareFeatureDelivery } from "./delivery/package.js";
|
|
25
|
+
import { previewFeatureCloseout, renderCloseoutPreview } from "./closeout/preview.js";
|
|
26
|
+
import { applyFeatureCloseout } from "./closeout/apply.js";
|
|
27
|
+
import { projectMonthlyMetrics } from "./metrics/projector.js";
|
|
28
|
+
import { runFeatureFinalVerification } from "./delivery/final-verification.js";
|
|
20
29
|
export function buildAgentWorkerProgram() {
|
|
21
30
|
const program = new Command();
|
|
22
31
|
program
|
|
@@ -28,6 +37,129 @@ export function buildAgentWorkerProgram() {
|
|
|
28
37
|
const batch = program.command("batch").description("Task Pool batch utilities");
|
|
29
38
|
const report = program.command("report").description("Task Pool reporting utilities");
|
|
30
39
|
const observe = program.command("observe").description("Observe UI server and snapshot utilities");
|
|
40
|
+
const feature = program.command("feature").description("Feature-level review and delivery workflow");
|
|
41
|
+
feature
|
|
42
|
+
.command("review")
|
|
43
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
44
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
45
|
+
.option("--json", "Emit stable JSON instead of the human summary")
|
|
46
|
+
.description("Derive Feature status, blockers, acceptance coverage, and next action")
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
const result = await reviewFeature({
|
|
49
|
+
featureDir: path.resolve(options.featureDir),
|
|
50
|
+
repoRoot: path.resolve(options.repo),
|
|
51
|
+
});
|
|
52
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderFeatureReview(result));
|
|
53
|
+
});
|
|
54
|
+
feature
|
|
55
|
+
.command("run")
|
|
56
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
57
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
58
|
+
.option("--dry-run", "Show validation, Ready tasks, steps, and expected artifacts without writes")
|
|
59
|
+
.option("--json", "Emit stable JSON instead of the human summary")
|
|
60
|
+
.option("--limit <count>", "Maximum Ready tasks (without checkpoint mode capped at 1)", "1")
|
|
61
|
+
.option("--git-mode <mode>", "Git mode: none or checkpoint", "none")
|
|
62
|
+
.option("--keep-failed-diff", "Keep a failed task diff and stop instead of restoring")
|
|
63
|
+
.option("--loop-agent-bin <bin>", "loop-agent binary", "loop-agent")
|
|
64
|
+
.option("--batch-run-id <id>", "Batch run id")
|
|
65
|
+
.option("--check-repo", "Run bash scripts/check-repo.sh during target repo preflight")
|
|
66
|
+
.option("--check-repo-command <command...>", "Override the check-repo preflight command")
|
|
67
|
+
.option("--quiet", "Suppress human-readable progress on stderr")
|
|
68
|
+
.option("--pi-model <model>", "Smoke override for pi executor nodes")
|
|
69
|
+
.description("Validate and advance one Ready Feature task through the existing Worker pipeline")
|
|
70
|
+
.action(async (options) => {
|
|
71
|
+
if (options.gitMode !== "none" && options.gitMode !== "checkpoint")
|
|
72
|
+
throw new Error("feature run --git-mode must be none or checkpoint");
|
|
73
|
+
if (options.keepFailedDiff && options.gitMode !== "checkpoint")
|
|
74
|
+
throw new Error("--keep-failed-diff requires --git-mode checkpoint");
|
|
75
|
+
const repoRoot = path.resolve(options.repo);
|
|
76
|
+
const batchRunId = options.batchRunId ?? buildBatchRunId(new Date());
|
|
77
|
+
const client = new LoopAgentClient({
|
|
78
|
+
loopAgentBin: options.loopAgentBin,
|
|
79
|
+
artifactRoot: path.join(getTaskPoolRoot(repoRoot), "artifacts", batchRunId),
|
|
80
|
+
});
|
|
81
|
+
let progress;
|
|
82
|
+
try {
|
|
83
|
+
progress = createCompositeProgressReporter({
|
|
84
|
+
quiet: options.quiet ?? options.dryRun ?? false,
|
|
85
|
+
eventStore: createRoutedWorkerEventStore(repoRoot),
|
|
86
|
+
context: { batchRunId },
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
progress = createProgressReporter({ quiet: options.quiet ?? options.dryRun ?? false });
|
|
91
|
+
}
|
|
92
|
+
const result = await runFeature({
|
|
93
|
+
featureDir: path.resolve(options.featureDir),
|
|
94
|
+
repoRoot,
|
|
95
|
+
client,
|
|
96
|
+
dryRun: options.dryRun ?? false,
|
|
97
|
+
limit: Number.parseInt(options.limit, 10),
|
|
98
|
+
batchRunId,
|
|
99
|
+
runCheckRepo: options.checkRepo ?? false,
|
|
100
|
+
...(options.checkRepoCommand ? { checkRepoCommand: options.checkRepoCommand } : {}),
|
|
101
|
+
progress,
|
|
102
|
+
...(options.piModel ? { piModel: options.piModel } : {}),
|
|
103
|
+
gitMode: options.gitMode === "checkpoint" ? "checkpoint" : "none",
|
|
104
|
+
keepFailedDiff: options.keepFailedDiff ?? false,
|
|
105
|
+
});
|
|
106
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderFeatureRun(result));
|
|
107
|
+
if (result.status === "failed" || result.status === "needs-action")
|
|
108
|
+
process.exitCode = 1;
|
|
109
|
+
});
|
|
110
|
+
feature
|
|
111
|
+
.command("verify-final")
|
|
112
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
113
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
114
|
+
.requiredOption("--task-id <id>", "Completed qa-execute TaskSpec to rerun as dedicated final verification")
|
|
115
|
+
.option("--loop-agent-bin <bin>", "loop-agent binary", "loop-agent")
|
|
116
|
+
.option("--json", "Emit stable JSON")
|
|
117
|
+
.description("Run an independent HEAD-bound final QA verification and project Delivery evidence")
|
|
118
|
+
.action(async (options) => {
|
|
119
|
+
const repoRoot = path.resolve(options.repo);
|
|
120
|
+
const client = new LoopAgentClient({ loopAgentBin: options.loopAgentBin, artifactRoot: path.join(getTaskPoolRoot(repoRoot), "artifacts", `final-verification-${Date.now()}`) });
|
|
121
|
+
const result = await runFeatureFinalVerification({ featureDir: path.resolve(options.featureDir), repoRoot, taskId: options.taskId, client });
|
|
122
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : `Feature: ${result.featureId}\nFinal verification: ${result.workerRunId}\nQA evidence: ${result.qaEvidencePath}\nFinal evidence: ${result.finalVerificationPath}\n`);
|
|
123
|
+
});
|
|
124
|
+
feature
|
|
125
|
+
.command("delivery")
|
|
126
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
127
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
128
|
+
.requiredOption("--qa-evidence <path>", "Repo-local QA pass evidence")
|
|
129
|
+
.requiredOption("--final-verification <path>", "Repo-local fresh final verification evidence")
|
|
130
|
+
.option("--waivers <path>", "Repo-local acceptance waiver decisions JSON")
|
|
131
|
+
.option("--dry-run", "Validate and show the Delivery Package plan without writes")
|
|
132
|
+
.option("--json", "Emit stable JSON")
|
|
133
|
+
.description("Validate checkpointed Feature evidence and prepare a local Delivery Package")
|
|
134
|
+
.action(async (options) => {
|
|
135
|
+
const result = await prepareFeatureDelivery({
|
|
136
|
+
featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo),
|
|
137
|
+
qaEvidencePath: options.qaEvidence, finalVerificationPath: options.finalVerification,
|
|
138
|
+
...(options.waivers ? { waiverPath: options.waivers } : {}), dryRun: options.dryRun ?? false,
|
|
139
|
+
});
|
|
140
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : `Feature: ${result.featureId}\nDelivery: ${result.status}\nArtifacts: ${Object.values(result.artifacts).join(", ")}\nBlockers: ${result.blockers.join("; ") || "none"}\n`);
|
|
141
|
+
if (result.status === "blocked")
|
|
142
|
+
process.exitCode = 1;
|
|
143
|
+
});
|
|
144
|
+
feature
|
|
145
|
+
.command("closeout")
|
|
146
|
+
.requiredOption("--feature-dir <dir>", "Feature directory containing acceptance.yaml and tasks/")
|
|
147
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
148
|
+
.option("--apply", "Apply Feature Closeout (reserved for M2-08)")
|
|
149
|
+
.option("--owner <owner>", "Closeout owner for apply")
|
|
150
|
+
.option("--json", "Emit stable JSON")
|
|
151
|
+
.description("Preview Feature Closeout gates without modifying the Feature Packet")
|
|
152
|
+
.action(async (options) => {
|
|
153
|
+
if (options.apply) {
|
|
154
|
+
const result = await applyFeatureCloseout({ featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo), owner: options.owner ?? "" });
|
|
155
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const result = await previewFeatureCloseout({ featureDir: path.resolve(options.featureDir), repoRoot: path.resolve(options.repo) });
|
|
159
|
+
process.stdout.write(options.json ? `${JSON.stringify(result, null, 2)}\n` : renderCloseoutPreview(result));
|
|
160
|
+
if (result.status === "blocked")
|
|
161
|
+
process.exitCode = 1;
|
|
162
|
+
});
|
|
31
163
|
task
|
|
32
164
|
.command("validate")
|
|
33
165
|
.argument("<task-yaml>", "TaskSpec YAML file")
|
|
@@ -74,6 +206,58 @@ export function buildAgentWorkerProgram() {
|
|
|
74
206
|
});
|
|
75
207
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
76
208
|
});
|
|
209
|
+
task
|
|
210
|
+
.command("draft-followup")
|
|
211
|
+
.argument("<task-id>", "Failed parent Task id")
|
|
212
|
+
.requiredOption("--worker-run-id <id>", "Failed Worker run id")
|
|
213
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
214
|
+
.requiredOption("--feature-dir <dir>", "Feature Packet directory")
|
|
215
|
+
.option("--json", "Emit JSON instead of the human summary")
|
|
216
|
+
.description("Create or reuse a classified Follow-up Task draft or human action card")
|
|
217
|
+
.action(async (taskId, options) => {
|
|
218
|
+
try {
|
|
219
|
+
const result = await draftFollowUpDecision({
|
|
220
|
+
repoRoot: path.resolve(options.repo),
|
|
221
|
+
featureDir: path.resolve(options.featureDir),
|
|
222
|
+
taskId,
|
|
223
|
+
workerRunId: options.workerRunId,
|
|
224
|
+
});
|
|
225
|
+
process.stdout.write(options.json
|
|
226
|
+
? `${JSON.stringify(result, null, 2)}\n`
|
|
227
|
+
: result.kind === "TaskDraft"
|
|
228
|
+
? `Follow-up: ${result.followUpId}\n结果: ${result.created ? "已生成任务草稿" : "复用现有任务草稿"}\n下一步: agent-worker feature approve-followup --feature-dir ${JSON.stringify(path.resolve(options.featureDir))} --followup-id ${result.followUpId} --repo ${JSON.stringify(path.resolve(options.repo))} --owner <owner>\n证据: ${result.draftPath}\n`
|
|
229
|
+
: `Follow-up: ${result.followUpId}\n结果: ${result.created ? "已生成人工行动卡" : "复用现有行动卡"}\n下一步: ${result.actionCard.command ?? result.actionCard.label}\n证据: ${result.draftPath}\n`);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
handleFollowUpCliError(error, options.json ?? false, "draft-followup");
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
feature
|
|
236
|
+
.command("approve-followup")
|
|
237
|
+
.requiredOption("--feature-dir <dir>", "Feature Packet directory")
|
|
238
|
+
.requiredOption("--followup-id <id>", "Follow-up approval id")
|
|
239
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
240
|
+
.requiredOption("--owner <name>", "Human owner approving the Follow-up")
|
|
241
|
+
.option("--dry-run", "Validate baseline and show the transaction plan without writes")
|
|
242
|
+
.option("--json", "Emit JSON instead of the human summary")
|
|
243
|
+
.description("Approve a Follow-up and atomically add its TaskSpec to the Feature")
|
|
244
|
+
.action(async (options) => {
|
|
245
|
+
try {
|
|
246
|
+
const result = await approveFollowUp({
|
|
247
|
+
repoRoot: path.resolve(options.repo),
|
|
248
|
+
featureDir: path.resolve(options.featureDir),
|
|
249
|
+
followUpId: options.followupId,
|
|
250
|
+
owner: options.owner,
|
|
251
|
+
dryRun: options.dryRun ?? false,
|
|
252
|
+
});
|
|
253
|
+
process.stdout.write(options.json
|
|
254
|
+
? `${JSON.stringify(result, null, 2)}\n`
|
|
255
|
+
: `Follow-up: ${result.followUpId}\n结果: ${result.status === "planned" ? "批准事务预览通过" : result.idempotent ? "已批准(幂等复用)" : "已批准并进入 Ready"}\n下一步: agent-worker feature review --feature-dir ${JSON.stringify(path.resolve(options.featureDir))} --repo ${JSON.stringify(path.resolve(options.repo))}\n证据: ${result.approvalPath}\n`);
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
handleFollowUpCliError(error, options.json ?? false, "approve-followup");
|
|
259
|
+
}
|
|
260
|
+
});
|
|
77
261
|
batch
|
|
78
262
|
.command("run-ready")
|
|
79
263
|
.requiredOption("--feature-dir <dir>", "Feature directory containing tasks/task-graph.yaml")
|
|
@@ -169,6 +353,16 @@ export function buildAgentWorkerProgram() {
|
|
|
169
353
|
});
|
|
170
354
|
process.stdout.write(`${JSON.stringify({ ok: true, outputPath }, null, 2)}\n`);
|
|
171
355
|
});
|
|
356
|
+
report
|
|
357
|
+
.command("metrics")
|
|
358
|
+
.requiredOption("--repo <repo-root>", "Target repo root")
|
|
359
|
+
.requiredOption("--month <yyyy-mm>", "UTC reporting month")
|
|
360
|
+
.option("--json", "Emit the metrics JSON on stdout")
|
|
361
|
+
.description("Project monthly Feature delivery metrics to JSON and Markdown")
|
|
362
|
+
.action(async (options) => {
|
|
363
|
+
const result = await projectMonthlyMetrics({ repoRoot: path.resolve(options.repo), month: options.month });
|
|
364
|
+
process.stdout.write(options.json ? `${JSON.stringify(result.metrics, null, 2)}\n` : `${JSON.stringify({ ok: true, jsonPath: result.jsonPath, markdownPath: result.markdownPath }, null, 2)}\n`);
|
|
365
|
+
});
|
|
172
366
|
return program;
|
|
173
367
|
}
|
|
174
368
|
export async function main(argv = process.argv) {
|
|
@@ -177,6 +371,28 @@ export async function main(argv = process.argv) {
|
|
|
177
371
|
async function readTaskYaml(taskSpecPath) {
|
|
178
372
|
return YAML.parse(await readFile(taskSpecPath, "utf-8"));
|
|
179
373
|
}
|
|
374
|
+
function handleFollowUpCliError(error, json, action) {
|
|
375
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
376
|
+
if (!json)
|
|
377
|
+
throw error;
|
|
378
|
+
const code = detail.includes("only supports ProductBug")
|
|
379
|
+
? "unsupported-failure-category"
|
|
380
|
+
: detail.includes("baseline changed")
|
|
381
|
+
? "stale-feature-baseline"
|
|
382
|
+
: detail.includes("already exists") || detail.includes("collision")
|
|
383
|
+
? "follow-up-conflict"
|
|
384
|
+
: detail.includes("evidence") || detail.includes("draft hash")
|
|
385
|
+
? "follow-up-evidence-invalid"
|
|
386
|
+
: "follow-up-failed";
|
|
387
|
+
process.stdout.write(`${JSON.stringify({
|
|
388
|
+
schemaVersion: 1,
|
|
389
|
+
status: "failed",
|
|
390
|
+
action,
|
|
391
|
+
error: { code, message: detail },
|
|
392
|
+
nextAction: action === "draft-followup" ? "Inspect the failed Worker run and failure category." : "Regenerate and review the Follow-up draft before approving.",
|
|
393
|
+
}, null, 2)}\n`);
|
|
394
|
+
process.exitCode = 1;
|
|
395
|
+
}
|
|
180
396
|
function isDirectRun() {
|
|
181
397
|
const entry = process.argv[1];
|
|
182
398
|
if (!entry)
|