@fitlab-ai/agent-infra 0.9.8 → 0.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/bin/internal-cli.js +6 -1
  4. package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +58 -21
  5. package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +8 -1
  6. package/dist/lib/agent-clients/adapters/codex-lifecycle/capability-store.js +173 -10
  7. package/dist/lib/agent-clients/adapters/codex-lifecycle/controller-context.js +147 -0
  8. package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +14 -0
  9. package/dist/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.js +56 -67
  10. package/dist/lib/git/workflow.js +10 -1
  11. package/dist/lib/internal/codex-lifecycle.js +19 -5
  12. package/dist/lib/internal/codex-sandbox-controller.js +6 -13
  13. package/dist/lib/internal/git-workflow.js +5 -7
  14. package/dist/lib/internal/platform-pr.js +20 -7
  15. package/dist/lib/internal/release-workflow.js +2 -1
  16. package/dist/lib/internal/sandbox-control.js +79 -2
  17. package/dist/lib/internal/task-finalization.js +54 -0
  18. package/dist/lib/internal/task-orchestration.js +156 -291
  19. package/dist/lib/platform/pr-summary.js +48 -10
  20. package/dist/lib/platform/pull-requests.js +205 -41
  21. package/dist/lib/sandbox/commands/rm.js +316 -55
  22. package/dist/lib/sandbox/control/client.js +190 -6
  23. package/dist/lib/sandbox/control/controller-registration.js +273 -0
  24. package/dist/lib/sandbox/control/executor.js +137 -5
  25. package/dist/lib/sandbox/control/lifecycle.js +3 -1
  26. package/dist/lib/sandbox/control/protocol.js +67 -6
  27. package/dist/lib/sandbox/index.js +5 -3
  28. package/dist/lib/sandbox/managed-fs.js +5 -0
  29. package/dist/lib/sandbox/task-resolver.js +50 -6
  30. package/dist/lib/sandbox/workspace-identity.js +27 -0
  31. package/dist/lib/sandbox/worktree-safety.js +215 -2
  32. package/dist/lib/task/codex-orchestration.js +158 -33
  33. package/dist/lib/task/commands/status.js +59 -1
  34. package/dist/lib/task/commit-operation.js +335 -0
  35. package/dist/lib/task/commit-policy.js +18 -0
  36. package/dist/lib/task/delegation-receipts.js +243 -2
  37. package/dist/lib/task/finalization.js +567 -0
  38. package/dist/lib/task/operation-outcome.js +33 -0
  39. package/dist/lib/task/orchestration.js +187 -761
  40. package/dist/lib/task/short-id.js +59 -1
  41. package/dist/lib/task/task-execution-lock.js +6 -1
  42. package/dist/lib/task/verification-engine.js +113 -60
  43. package/dist/lib/task/verification.js +2 -1
  44. package/dist/lib/task/workflow-warning-intents.js +50 -1
  45. package/dist/lifecycle-build-manifest.json +3 -3
  46. package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +61 -19
  47. package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +12 -0
  48. package/lib/agent-clients/adapters/codex-lifecycle/capability-store.ts +276 -12
  49. package/lib/agent-clients/adapters/codex-lifecycle/controller-context.ts +180 -0
  50. package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +19 -0
  51. package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +9 -1
  52. package/lib/agent-clients/adapters/codex-lifecycle/sandbox-controller.ts +83 -91
  53. package/lib/git/workflow.ts +11 -2
  54. package/lib/internal/codex-lifecycle.ts +18 -5
  55. package/lib/internal/codex-sandbox-controller.ts +6 -12
  56. package/lib/internal/git-workflow.ts +5 -6
  57. package/lib/internal/platform-pr.ts +14 -7
  58. package/lib/internal/release-workflow.ts +2 -1
  59. package/lib/internal/sandbox-control.ts +92 -2
  60. package/lib/internal/task-finalization.ts +68 -0
  61. package/lib/internal/task-orchestration.ts +20 -103
  62. package/lib/platform/pr-summary.ts +55 -11
  63. package/lib/platform/pull-requests.ts +211 -41
  64. package/lib/sandbox/commands/rm.ts +413 -61
  65. package/lib/sandbox/control/client.ts +255 -6
  66. package/lib/sandbox/control/controller-registration.ts +347 -0
  67. package/lib/sandbox/control/executor.ts +163 -5
  68. package/lib/sandbox/control/lifecycle.ts +2 -1
  69. package/lib/sandbox/control/protocol.ts +80 -7
  70. package/lib/sandbox/index.ts +5 -3
  71. package/lib/sandbox/managed-fs.ts +5 -0
  72. package/lib/sandbox/task-resolver.ts +58 -7
  73. package/lib/sandbox/workspace-identity.ts +50 -2
  74. package/lib/sandbox/workspace-view.ts +3 -3
  75. package/lib/sandbox/worktree-safety.ts +236 -2
  76. package/lib/task/codex-orchestration.ts +167 -33
  77. package/lib/task/commands/status.ts +78 -1
  78. package/lib/task/commit-operation.ts +430 -0
  79. package/lib/task/commit-policy.ts +30 -0
  80. package/lib/task/delegation-receipts.ts +258 -1
  81. package/lib/task/finalization.ts +719 -0
  82. package/lib/task/operation-outcome.ts +48 -0
  83. package/lib/task/orchestration.ts +217 -982
  84. package/lib/task/short-id.ts +65 -1
  85. package/lib/task/task-execution-lock.ts +10 -1
  86. package/lib/task/verification-engine.ts +118 -63
  87. package/lib/task/verification.ts +3 -2
  88. package/lib/task/workflow-warning-intents.ts +57 -2
  89. package/package.json +2 -2
  90. package/templates/.agents/QUICKSTART.en.md +2 -2
  91. package/templates/.agents/QUICKSTART.zh-CN.md +2 -2
  92. package/templates/.agents/hooks/lifecycle-delegation.js +1 -21
  93. package/templates/.agents/rules/lifecycle-orchestration.en.md +1 -1
  94. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +1 -1
  95. package/templates/.agents/rules/task-management.en.md +2 -2
  96. package/templates/.agents/rules/task-management.zh-CN.md +2 -2
  97. package/templates/.agents/skills/block-task/SKILL.en.md +2 -4
  98. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -4
  99. package/templates/.agents/skills/cancel-task/SKILL.en.md +3 -3
  100. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +3 -3
  101. package/templates/.agents/skills/close-codescan/SKILL.en.md +6 -2
  102. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +6 -2
  103. package/templates/.agents/skills/close-dependabot/SKILL.en.md +6 -2
  104. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +6 -2
  105. package/templates/.agents/skills/commit/SKILL.en.md +41 -125
  106. package/templates/.agents/skills/commit/SKILL.zh-CN.md +52 -123
  107. package/templates/.agents/skills/commit/reference/commit-message.en.md +1 -1
  108. package/templates/.agents/skills/commit/reference/commit-message.zh-CN.md +1 -1
  109. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +14 -43
  110. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +14 -49
  111. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
  112. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
  113. package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -35
  114. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -35
  115. package/templates/.agents/skills/complete-task/SKILL.en.md +31 -38
  116. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +31 -38
  117. package/templates/.agents/skills/complete-task/config/verify.en.json +1 -0
  118. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -0
  119. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +1 -1
  120. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +1 -1
  121. package/templates/.agents/skills/create-pr/SKILL.en.md +6 -4
  122. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +6 -4
  123. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +2 -2
  124. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +2 -2
  125. package/templates/.agents/skills/run-task/SKILL.en.md +5 -5
  126. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -5
  127. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +1 -1
  128. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +1 -1
  129. package/templates/.codex/hooks.json +4 -4
  130. package/dist/lib/task/commit-finalization.js +0 -305
  131. package/dist/lib/task/commit-intent.js +0 -165
  132. package/lib/task/commit-finalization.ts +0 -419
  133. package/lib/task/commit-intent.ts +0 -230
@@ -6,44 +6,25 @@ description: >
6
6
  ---
7
7
 
8
8
  # 提交代码
9
- > `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」:标准 AI 短名(`claude`/`codex`/`antigravity`/`opencode`/`cursor`)、长名归一化(`claude-code`→`claude`、`antigravity-cli`→`antigravity`)或人工例外 `human`。
10
9
 
10
+ > `--agent` 取值见 `.agents/rules/task-management.md`「合作者 token 规范」。
11
11
 
12
12
  在不覆盖用户本地工作的前提下创建 Git commit,并在需要时更新关联任务状态。
13
13
 
14
- 更新关联 `task.md` frontmatter 时,先读取 `.agents/rules/version-stamp.md`,并写入或刷新 `agent_infra_version`。
14
+ commit core 只返回一个主结果:`committed`、`no_op`、`committed_with_warnings`、`failed` 或 `blocked`,并附带结构化 `warnings`。push 失败或保护分支策略不会撤销已经创建的本地提交。
15
15
 
16
- 若入口业务操作数包含字面 `--orchestrated`,绑定 `{execution-flag}` = `--orchestrated`;否则绑定为空。不得从 run 文件或环境推断来源。
16
+ ## 任务上下文
17
17
 
18
- 直接调用仍要求用户显式授权。编排调用只有在副作用前通过 commit intent 对 activated receipt 与一次性 `commitAuthorization` 的联合校验后才可继续,其他提交门禁保持不变。
18
+ 入口允许省略 task ref,也接受旧位置 task ref 或 `--task <ref>` / `-t <ref>`。先调用 `agent-infra-internal task-context resolve {task-scope}`。
19
19
 
20
- ## 常见违规借口与反驳
20
+ - 显式 task scope 解析失败时停止。
21
+ - 未显式指定 task scope 时,只有 `TASK_CONTEXT_NOT_FOUND` 可进入 taskless direct;detached HEAD、损坏候选或多匹配必须 fail closed。
22
+ - 入口业务操作数包含字面 `--orchestrated` 时使用 `mode=orchestrated`,否则使用 `mode=direct`;不得从 run 文件或环境推断模式。
23
+ - taskless direct 不读取、创建或完成 task intent、receipt、checkpoint 或 task.md 收尾记录。
24
+ - task-bound direct 不要求 delegation receipt;orchestrated 必须由 core 验证匹配的 activated commit receipt 和 capability。
25
+ - 解析成功后只使用 core 返回的 `taskId`;不得从环境、分支或文件名猜测任务身份。
21
26
 
22
- | 借口 | 反驳 |
23
- |------|------|
24
- | 「测试之前跑过了,不用重跑」 | 暂存内容是最新现实;提交前必须重新核对 `git status`/`git diff`,不能凭记忆。 |
25
- | 「`git add -A` 更省事」 | 禁止 `git add -A`/`git add .`;只暂存明确列出的文件,避免带入无关改动。 |
26
- | 「改了带版权头的文件,年份先不动」 | 改了就更新版权年份(动态取 `date +%Y`),这是提交前的硬性检查。 |
27
-
28
- ## 任务上下文解析
29
-
30
- > 入口允许省略 task ref,也接受旧位置 task ref 或 `--task <ref>` / `-t <ref>`。先从完整参数中分离 task scope 并原样保留其他业务操作数,再调用 `agent-infra-internal task-context resolve {task-scope}`;`{task-scope}` 为空、位置 ref 或 task flag 之一。只读取结构化结果的 `taskId`,后续把 `{task-id}` 绑定为该完整 `TASK-YYYYMMDD-HHMMSS`。解析失败时透传非零退出码,不自行扫描任务。
31
-
32
- 未显式指定 task scope 时,只有 `TASK_CONTEXT_NOT_FOUND` 可继续既有纯提交路径;detached HEAD、损坏候选或多匹配属于歧义,必须失败。显式 task scope 解析失败时一律失败。
33
-
34
- ## 步骤开始:恢复或创建受控 attempt
35
-
36
- 已解析出 `{task-id}` 时,先调用 `agent-infra-internal task-orchestration {task-id} commit-status`:
37
-
38
- - `recoverable`:调用 `commit-recover --agent {standard-agent-token}` 完成收尾,不得重复 commit 或 push。
39
- - `prepared`:调用 `commit-recover --agent {standard-agent-token}` 安全清理 intent,再次查询 status 并复用返回的 `retryable-start` attempt。
40
- - `retryable-start`:调用 `commit-recover --agent {standard-agent-token}` 取得原 attempt,不追加第二条 started。
41
- - `invalid` / `conflict` / `orphaned-start`:输出结构化 code 与状态证据并停止。
42
- - `idle`:调用 `commit-start --agent {standard-agent-token}`,由核心在任务锁内原子写入结构化 started 并返回 attempt/baseline。
43
-
44
- 只从 `commit-start` / `commit-recover` 的结构化输出读取 `{commit-attempt}`;不得手写、复制或猜测 attempt。无任务上下文的纯提交跳过本协议。
45
-
46
- ## 1. 检查本地修改(关键)
27
+ ## 1. 检查本地修改
47
28
 
48
29
  在任何编辑前先检查:
49
30
 
@@ -52,126 +33,74 @@ git status --short
52
33
  git diff
53
34
  ```
54
35
 
55
- 必须尊重现有用户改动;如果你的计划与之冲突,先停止并征求确认。
36
+ 必须尊重现有用户改动;如果计划与之冲突,按禁言规则停止并记录阻塞原因。
56
37
 
57
38
  ## 2. 更新版权头年份
58
39
 
59
- 动态获取当前年份,只更新已经改动过的文件。
60
-
61
- > 完整版权检查流程见 `reference/copyright-check.md`。修改任何版权头前,先读取 `reference/copyright-check.md`。
40
+ 动态获取当前年份,只更新已经改动过的带版权头文件。完整流程见 `reference/copyright-check.md`。
62
41
 
63
42
  ## 3. 生成提交信息
64
43
 
65
- 检查状态、diff 和最近历史,然后按 Conventional Commits 生成 message,并补齐正确的协作署名。
66
-
67
- > 提交信息规则、示例和多代理署名细节见 `reference/commit-message.md`。写 commit message 前先读取 `reference/commit-message.md`。
68
-
69
- ## 4. 创建提交
70
-
71
- 已解析出 `{task-id}` 时,执行本步骤前先读取 `reference/commit-orchestration.md`,并在任何 Git/平台成功副作用前完成 `commit-begin`;无任务上下文的纯 Git 提交完全跳过 intent 协议。
72
-
73
- 先判断受限 push-only 场景;否则把 message、显式路径、expected HEAD/tree 写入临时 JSON,并调用 `agent-infra-internal git-workflow commit --input {file}`。core 负责范围、敏感文件、暂存树和幂等校验。
74
-
75
- 普通 commit 成功后必须立即按该 reference 执行 committed checkpoint;checkpoint 失败时保留 intent 并停止,不得继续 push 或写成功状态。
76
-
77
- 如果本次提交关联任务且存在 `review-code` 产物,在提交前读取最高轮 `review-code` 产物:
78
- - 若该产物 `总体结论` / `Overall Verdict` 为 Approved,解析 `R`、`F` 与 `审查快照树` / `Reviewed Snapshot Tree`(`T`)
79
- - 暂存明确文件后记录 `pre_head=$(git rev-parse HEAD)`,并以 helper 的 JSON 模式生成当前完整工作区树 `W` 与规范化暂存树 `S`
80
- - 在 `git commit` 前要求 `pre_head == R && W == T && S == T`;分别运行 helper 的 `compare` 模式生成 worktree/staged 的 added、missing、different 路径诊断
81
- - 任一条件不满足时进入 `reference/task-status-update.md` 的“场景 4:提交前快照阻断”,不得执行 `git commit`、push、成功状态更新、PR 摘要同步或完成 gate
82
- - 全部相等并成功提交后,由步骤 6 的 `commit-complete` 核心收尾原子写入 `last_reviewed_commit` 与 Commit done;调用方不得手写
83
- - 不向后扫描更早的 Approved 产物;最高轮 `review-code` 产物是唯一权威来源
84
-
85
- ## 5. 推送到已有 PR(按需)
86
-
87
- 新提交完成或步骤 4 命中 push-only 后,如果当前分支已存在开放的 Pull Request,则把 HEAD 普通推送上去让 PR 自动更新;否则保持现状(首次推送仍由 `create-pr` 负责)。本步骤不创建额外/空 commit,也不在无 PR 时推送;与是否关联任务无关。
88
-
89
- > 检测当前分支是否有开放 PR、以及平台认证,统一按 `.agents/rules/issue-pr-commands.md` 执行;该规则不可用或检测失败时,按下方降级处理。
90
-
91
- a. 按 `.agents/rules/issue-pr-commands.md` 检测当前分支(head)是否存在开放 PR。
44
+ 检查状态、diff 和最近历史,按 Conventional Commits 生成英文祈使句 message,并读取 `reference/commit-message.md` 处理协作署名。
92
45
 
93
- b. 命中开放 PR -> 推送当前分支:
46
+ ## 4. 调用唯一 commit core
94
47
 
95
- 通过 `agent-infra-internal git-workflow push --input {file}` 逐 ref 普通推送并复核,禁止 force push。
48
+ 执行本步骤前读取 `reference/commit-orchestration.md`。
96
49
 
97
- 推送成功并完成远端复核后,必须立即按 `reference/commit-orchestration.md` 执行 pushed checkpoint。
98
-
99
- c. 安全降级(不阻塞已完成的 `git commit`,仅提示用户):
100
- - 平台不可用 / 未认证 / 检测失败 / 未命中开放 PR -> 不推送,继续后续步骤。
101
- - `git push` 失败(如需 `git pull --rebase`、无 upstream、网络异常)-> 保留本地提交,提示用户手动推送。
102
-
103
- 把推送结果(pushed / skipped(no PR) / failed)并入下一步「更新任务状态」的 Activity Log 说明或用户输出。
104
-
105
- ## 6. 按需更新任务状态
106
-
107
- 普通 commit/push checkpoint 完成后,先调用核心收尾;它在同一任务锁内写入审查锚点、Commit done 与 orchestration planned bytes,最后删除 intent:
50
+ 将 message、明确 paths、expected HEAD/tree、task scope、agent、mode 和可选 push policy 写入临时 JSON,然后调用:
108
51
 
109
52
  ```bash
110
- agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
53
+ agent-infra-internal git-workflow commit --input {commit-operation.json}
111
54
  ```
112
55
 
113
- 失败时保留 intent,输出 `commit-status` 后停止;重跑本技能由开头的 status/recover 路由恢复。调用方不得重复追加 Commit done 或修改 `last_reviewed_commit`。
114
-
115
- 获取当前时间:
116
-
117
- ```bash
118
- date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
56
+ 示例:
57
+
58
+ ```json
59
+ {
60
+ "taskRef": "TASK-YYYYMMDD-HHMMSS",
61
+ "agent": "codex",
62
+ "mode": "direct",
63
+ "paths": ["lib/example.ts", "tests/example.test.ts"],
64
+ "message": "fix(core): validate example input",
65
+ "expectedHead": "{HEAD}",
66
+ "expectedTree": "{TREE}",
67
+ "push": {
68
+ "remote": "origin",
69
+ "refs": ["refs/heads/{branch}"],
70
+ "automatic": true
71
+ }
72
+ }
119
73
  ```
120
74
 
121
- > 完整的 5 种状态分支、前置条件检查和多 TUI 下一步命令见 `reference/task-status-update.md`。更新任务状态前,先读取 `reference/task-status-update.md`。
122
-
123
- > 渲染下一步前先读取 `.agents/rules/next-step-output.md`,并按 `reference/task-status-update.md` 的已选场景调用统一 helper。
75
+ taskless direct 省略 `taskRef`;orchestrated 必须显式传 `taskRef`、`agent` 和 `mode: "orchestrated"`。core 统一负责 repository/worktree mutation lock、task lock(仅 task-bound)、路径和敏感文件、staged scope、HEAD/tree、branch/ref、commit、push、保护分支、warning 和幂等校验。
124
76
 
125
- 核心收尾成功后只能选择一个下一步分支:
126
- - 已有开放 PR 且 push 成功 -> `watch-pr {task-ref}`;该分支优先于最终提交的 `prFlow` 路由
127
- - push 失败 -> 保持任务 active,只输出推送/同步诊断,不输出 `watch-pr` 或 `complete-task`
128
- - 最终提交 -> 按 `.agents/.airc.json` 的 `prFlow` 渲染下一步(`disabled` → 单选 `complete-task`;`required` → 单选 `create-pr`;缺省 → 二选一 `create-pr` / `complete-task`),详见 `reference/task-status-update.md` 场景 1
129
- - 还有后续工作 -> 更新 task.md 后停止
130
- - 准备审查 -> `review-code {task-id}`
77
+ - 有明确修改时最多创建一个本地 commit。
78
+ - 无修改但需要交付本地领先的 HEAD 时只执行 push-only,不创建空 commit。
79
+ - `main` / `master` 的自动 push 跳过并返回 `COMMIT_AUTOPUSH_PROTECTED_BRANCH`;本地 commit 保留。
80
+ - 普通 push 失败返回 `COMMIT_PUSH_FAILED` warning;重跑只补当前 push,不重复创建 commit。
81
+ - taskless 成功不写 task.md、review、receipt、checkpoint 或 Activity Log。
131
82
 
132
- ## 7. 同步 Issue 元数据(按需)
83
+ ## 5. 任务收尾与平台同步
133
84
 
134
- 当 `{task-id}` 存在且 task.md 包含有效 `issue_number` 时,同步 `in:` label 和需求复选框到关联 Issue;否则跳过。
85
+ task-bound 操作按 core 返回的 task 结果继续执行任务同步;taskless 操作跳过任务校验和任务平台同步。
135
86
 
136
- > 触发条件与声明式 `platform-issue` 调用见 `reference/issue-metadata-sync.md`。执行前先读取该文件。
137
- >
138
- > 如果本步骤会访问代码托管平台,则先按 `.agents/rules/issue-pr-commands.md` 完成前置检测。
87
+ 当 task 存在且关联 Issue/PR 时,按 `reference/issue-metadata-sync.md`、`reference/pr-summary-sync.md` 和平台规则执行同步;commit 路径调用 summary-sync 时固定传入 `--result no_op`,因为它只同步已有 PR 身份。同步失败只产生 warning,不撤销本地 commit。
139
88
 
140
- 失败处理与「按需更新任务状态」一致:警告但**不**阻塞已完成的 `git commit`。
141
-
142
- ## 8. 同步 PR 摘要(按需)
143
-
144
- 当 `{task-id}` 存在且 task.md 包含有效 `pr_number` 时,刷新 PR 上由 `.agents/rules/pr-sync.md` 中定义的 PR 摘要评论标记对应的摘要评论;否则跳过。
145
-
146
- > 完整的触发条件、聚合规则、PATCH/POST 流程、Shell 安全约束和错误处理见 `reference/pr-summary-sync.md`(其内联引用 `.agents/rules/pr-sync.md`)。执行此步骤前先读取 `reference/pr-summary-sync.md`。
147
- >
148
- > 如果本步骤会访问代码托管平台,则先按 `.agents/rules/issue-pr-commands.md` 完成前置检测,确保 `.agents/rules/pr-sync.md` 所需的运行时上下文已就绪。
149
-
150
- 失败处理与「按需更新任务状态」一致:警告但**不**阻塞已完成的 `git commit`。
151
-
152
- ## 9. 完成校验
153
-
154
- 如果本次操作关联了 `{task-id}`,运行完成校验,确认任务元数据和同步状态符合规范;如果没有任务上下文,跳过本步骤。
89
+ 完成 task-bound 收尾后运行:
155
90
 
156
91
  ```bash
92
+ date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
157
93
  agent-infra-internal task-verify {task-id} commit.completed --format text
158
94
  ```
159
95
 
160
- 处理结果:
161
- - 退出码 0(全部通过)-> 继续后续收尾步骤
162
- - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
163
- - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
96
+ 没有当次校验输出,不得声明任务收尾完成。
164
97
 
165
- 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
98
+ ## 6. 输出下一步
166
99
 
167
- 本 gate 只在步骤 6 核心收尾成功后运行;不得把完成校验放在 `commit-complete` 之前。
100
+ 渲染下一步前先读取 `.agents/rules/next-step-output.md`,并根据最新 task/PR 状态只调用一次统一 helper。push 失败时保持任务 active,只输出诊断;最终提交则按 `prFlow` 选择 `create-pr` 或 `complete-task`。
168
101
 
169
102
  ## 注意事项
170
103
 
171
- - 不要提交 `.env`、凭据、密钥等敏感文件
172
- - 协作署名中当前代理必须排在最前面
173
- - 不要使用 `git add -A` 或 `git add .`
174
-
175
- ## 错误处理
176
-
177
- - 如果任务状态更新失败,警告用户,但不要因此阻止提交
104
+ - 不要提交 `.env`、凭据、密钥等敏感文件。
105
+ - 不要使用 `git add -A` 或 `git add .`。
106
+ - 不要手写 task Activity Log、review anchor、receipt 或 checkpoint。
@@ -40,7 +40,7 @@ Build the co-author block with these rules:
40
40
  ## Create the Commit
41
41
 
42
42
  ```bash
43
- agent-infra-internal git-workflow commit --input {commit-intent.json}
43
+ agent-infra-internal git-workflow commit --input {commit-operation.json}
44
44
  ```
45
45
 
46
46
  Important:
@@ -40,7 +40,7 @@ git log --oneline -5
40
40
  ## 创建提交
41
41
 
42
42
  ```bash
43
- agent-infra-internal git-workflow commit --input {commit-intent.json}
43
+ agent-infra-internal git-workflow commit --input {commit-operation.json}
44
44
  ```
45
45
 
46
46
  重要约束:
@@ -1,50 +1,21 @@
1
- # Commit Orchestration Coordination
1
+ # Commit core boundary
2
2
 
3
- This protocol applies only when `{task-id}` was resolved. A taskless Git-only commit must not read, create, or complete a commit intent.
3
+ Commit, push, result mapping, and task finalization use one `commit-operation.execute`. The entry point only resolves task scope, explicit agent, and the literal `--orchestrated`; it never infers the source from state files.
4
4
 
5
- ## Execution source
5
+ ## Entry modes
6
6
 
7
- - Bind `{execution-flag}` to `--orchestrated` only when that literal flag appears in the entry business operands.
8
- - Every other invocation is standalone. Never infer the source from `orchestration.json`, environment variables, or activity history.
7
+ - `mode=direct`: explicit user invocation is the authorization. Task-bound direct may read task facts but does not require a delegation receipt; taskless direct is allowed only for `TASK_CONTEXT_NOT_FOUND` and skips task facts, review, task lock, checkpoint, and task.md finalization.
8
+ - `mode=orchestrated`: an explicit task is required. Before the first Git write, the core validates the matching activated commit receipt, agent, stage, round, artifact, role, and unconsumed capability. Missing evidence returns `blocked` without writing Git.
9
9
 
10
- ## Begin before side effects
10
+ ## Shared order
11
11
 
12
- Call `commit-status` whenever the commit skill starts. Use `commit-recover --agent {standard-agent-token}` for `recoverable` / `prepared` / `retryable-start`; use `commit-start --agent {standard-agent-token}` for `idle`; fail closed for every other state. Read `commit_attempt` only from `finalization.attempt.attempt` in start/recover output.
12
+ 1. Acquire the repository/worktree mutation lock; task-bound execution also acquires the task lock.
13
+ 2. Validate the repository, current branch, explicit paths, sensitive paths, staged scope, expected HEAD/tree, remote, and full heads ref.
14
+ 3. Validate the authorization for the selected mode.
15
+ 4. Create at most one local commit; with no changes, allow push-only and never create an empty commit.
16
+ 5. Return `COMMIT_AUTOPUSH_PROTECTED_BRANCH` on protected automatic push, or `COMMIT_PUSH_FAILED` on ordinary push failure, while retaining local facts.
17
+ 6. Return one primary result: `committed`, `no_op`, `committed_with_warnings`, `failed`, or `blocked`.
13
18
 
14
- After read-only preparation of status, copyright, message, review snapshot, and push routing, record `baseline_head=$(git rev-parse HEAD)` and run this before any commit, push, success log, or platform success sync:
19
+ ## Retry boundary
15
20
 
16
- ```bash
17
- commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
18
- commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
19
- ```
20
-
21
- Set `commit_intent_token` from the one-use `token` in structured output and keep it only in the current process. A failed begin forbids all later side effects.
22
-
23
- ## Side-effect checkpoints
24
-
25
- Immediately after a normal commit succeeds, record its new HEAD:
26
-
27
- ```bash
28
- agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind committed --head "$new_head"
29
- ```
30
-
31
- Immediately after a push succeeds and remote verification completes, record the verified remote/ref/HEAD:
32
-
33
- ```bash
34
- agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind pushed --head "$pushed_head" --remote "$remote" --ref "$ref"
35
- ```
36
-
37
- A push-only path skips the committed checkpoint; its pushed HEAD must equal the begin baseline.
38
-
39
- ## Completion and recovery
40
-
41
- After the committed/pushed checkpoint and before task synchronization or `task-verify commit.completed`, run:
42
-
43
- ```bash
44
- agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
45
- ```
46
-
47
- - If an intent exists but no side effect occurred, use `commit-abort --token ... --expected-head ...` while HEAD still equals baseline; when abandoning the attempt, then close it with `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>`.
48
- - If begin failed before intent creation, retain the attempt for retry or terminate it only while HEAD is unchanged.
49
- - After a commit or push, never abort. Retain the intent and use `commit-status` / `commit-recover` for cross-session recovery.
50
- - Stop when `commit-complete` fails. Do not repeat commit/push or mark a run complete without its full receipt lifecycle.
21
+ Retries reread current HEAD, worktree, branch, and remote facts. A local commit that already exists is push-only and cannot produce a second commit. Taskless retries create no task record. Orchestration owns stage completion, sealing, and consumption of receipts; direct mode never fabricates them.
@@ -1,56 +1,21 @@
1
- # Commit 编排协调
1
+ # Commit Core 边界
2
2
 
3
- 本规则仅适用于已解析出 `{task-id}` 的提交。无任务上下文的纯 Git 提交不得读取、创建或完成 commit intent。
3
+ commit、push、结果映射和任务收尾使用同一个 `commit-operation.execute`。入口只负责解析 task scope、显式 agent 和字面 `--orchestrated`,不得从状态文件推断执行来源。
4
4
 
5
- ## 执行来源
5
+ ## 入口模式
6
6
 
7
- - 只有入口业务操作数中字面出现 `--orchestrated` 时,`{execution-flag}` 才绑定为 `--orchestrated`。
8
- - 其他调用一律为 standalone;不得从 `orchestration.json`、环境变量或历史活动日志推断来源。
7
+ - `mode=direct`:用户显式调用授权。task-bound direct 可读取 task facts,但不要求 delegation receipt;taskless direct 只在 `TASK_CONTEXT_NOT_FOUND` 时允许,并跳过 task facts、review、task lock、checkpoint 和 task.md 收尾。
8
+ - `mode=orchestrated`:必须绑定明确 task,且 core 在第一个 Git 写入前验证匹配的 activated commit receipt、agent、stage、round、artifact、role 和未消费 capability。缺少任一项都返回 `blocked`,不写 Git。
9
9
 
10
- ## 副作用前 begin
10
+ ## 共享执行顺序
11
11
 
12
- 每次进入 commit 技能先调用 `commit-status`。`recoverable` / `prepared` / `retryable-start` 调用以下无 token 恢复入口,`idle` 调用 `commit-start --agent {standard-agent-token}`;其他状态 fail closed:
12
+ 1. 获取 repository/worktree mutation lock;task-bound 额外获取 task lock。
13
+ 2. 验证 repository、当前 branch、明确 paths、敏感路径、staged scope、expected HEAD/tree、remote 和 full heads ref。
14
+ 3. 完成模式对应的授权校验。
15
+ 4. 最多创建一个本地 commit;无修改时只允许 push-only,不创建空 commit。
16
+ 5. `main` / `master` 自动 push 返回 `COMMIT_AUTOPUSH_PROTECTED_BRANCH` warning;普通 push 失败返回 `COMMIT_PUSH_FAILED` warning,并保留本地事实。
17
+ 6. 返回唯一主结果:`committed`、`no_op`、`committed_with_warnings`、`failed` 或 `blocked`。
13
18
 
14
- ```bash
15
- agent-infra-internal task-orchestration {task-id} commit-recover --agent {standard-agent-token}
16
- ```
19
+ ## 重试边界
17
20
 
18
- 恢复入口只接受 `--agent`;不得传 token、head 或 `--orchestrated`。从 start/recover 结构化输出读取 `finalization.attempt.attempt` 为 `commit_attempt`,不得手写 attempt。
19
-
20
- 完成状态、版权、提交信息、review snapshot 和 push 场景的只读准备后,记录 `baseline_head=$(git rev-parse HEAD)`,并在任何 commit、push、任务成功日志或平台成功同步之前调用:
21
-
22
- ```bash
23
- commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
24
- commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
25
- ```
26
-
27
- `commit_intent_token` 只从结构化输出读取一次性 `token`,并仅保存在当前进程内。begin 失败时不得执行后续副作用。
28
-
29
- ## 副作用 checkpoint
30
-
31
- 普通 commit 成功后立即记录新 HEAD:
32
-
33
- ```bash
34
- agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind committed --head "$new_head"
35
- ```
36
-
37
- push 成功并完成远端复核后立即记录已验证的 remote/ref/HEAD:
38
-
39
- ```bash
40
- agent-infra-internal task-orchestration {task-id} commit-checkpoint --token "$commit_intent_token" --kind pushed --head "$pushed_head" --remote "$remote" --ref "$ref"
41
- ```
42
-
43
- push-only 路径跳过 committed checkpoint,pushed HEAD 必须等于 begin 时的 baseline HEAD。
44
-
45
- ## 完成与恢复
46
-
47
- committed/pushed checkpoint 完成后、任务同步与 `task-verify commit.completed` 之前调用:
48
-
49
- ```bash
50
- agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
51
- ```
52
-
53
- - begin 已创建 intent、但第一个副作用前失败时,先在 HEAD 仍等于 baseline 时调用 `commit-abort --token ... --expected-head ...`;若本轮明确放弃,再调用 `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>` 闭合 started。
54
- - begin 在 intent 创建前失败时可保留 attempt 供下次复用;明确放弃时仅可在 HEAD 未漂移时调用 `commit-terminate`。
55
- - commit 或 push 发生后失败时不得 abort;保留 intent,并调用 `commit-status` 输出不含 token/digest 的恢复证据。跨会话重跑通过 `commit-recover` 收尾。
56
- - `commit-complete` 失败时停止。不得重复执行 commit/push,也不得把缺少完整 receipt 生命周期的 run 标记为完成。
21
+ 重跑重新读取当前 HEAD、worktree、branch 和 remote 事实。已有本地 commit 时只补 push,不创建第二个 commit;taskless 重跑不创建任何任务记录。orchestrated receipt 的 stage completion、seal 和 consume 由 orchestration core 负责,不由 direct 路径伪造。
@@ -4,6 +4,6 @@ Run only when `{task-id}` is valid and task.md has a valid `pr_number`.
4
4
 
5
5
  1. Run `agent-infra-internal platform-pr summary-context {task-id}`.
6
6
  2. Generate the plain summary body per `.agents/rules/pr-sync.md` and write it to a temporary file.
7
- 3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file}`.
7
+ 3. Run `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --result no_op`. The commit path only synchronizes an existing PR summary and neither creates nor reuses a PR, so `no_op` explicitly represents the unchanged PR identity.
8
8
 
9
9
  Failure records a warning but never blocks or rolls back the completed commit. `no-op` maps to `summary skipped (no diff)`.
@@ -4,6 +4,6 @@
4
4
 
5
5
  1. 调用 `agent-infra-internal platform-pr summary-context {task-id}` 获取 canonical 聚合输入。
6
6
  2. 按 `.agents/rules/pr-sync.md` 生成纯摘要正文并写入临时文件。
7
- 3. 调用 `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file}`。
7
+ 3. 调用 `agent-infra-internal platform-pr summary-sync {task-id} --agent {standard-agent-token} --body-file {summary-body-file} --result no_op`。commit 路径只同步已有 PR 摘要,不创建或复用 PR,因此固定使用 `no_op` 表示 PR 身份未变化。
8
8
 
9
9
  同步失败只记录 warning,不阻塞或回滚已经完成的 commit。`no-op` 回传 `summary skipped (no diff)`。
@@ -12,19 +12,13 @@ Get the current time first:
12
12
  date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
13
13
  ```
14
14
 
15
- The `commit-complete` / `commit-recover` core has already atomically written this Activity Log entry:
15
+ The `commit-operation.execute` core writes this Activity Log entry for task-bound operations:
16
16
 
17
17
  ```text
18
18
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Commit** by {agent} — {commit hash short} {commit subject}
19
19
  ```
20
20
 
21
- When the evidence is satisfied, core also writes or refreshes:
22
-
23
- ```yaml
24
- last_reviewed_commit: {new_head}
25
- ```
26
-
27
- This field is the only baseline for the `complete-task` `post-review-commit` gate. The caller must not append Commit done again or write this field directly.
21
+ Task metadata is best-effort synchronization after the Git primary action: an Activity Log or frontmatter write failure returns a `TASK_STATUS_SYNC_FAILED` warning without undoing the commit or push, and a later no-change retry may repair the record. `review-code`, review anchors, and `last_reviewed_commit` are not commit/push prerequisites. The caller must not append Activity Log entries directly.
28
22
 
29
23
  ### Scenario 5: Existing-PR push wrap-up
30
24
 
@@ -39,33 +33,6 @@ Next step - watch PR checks:
39
33
 
40
34
  If push fails, keep the task active and preserve local HEAD; show diagnostics and manual push guidance only, never `watch-pr` or `complete-task`. This scenario takes precedence over the final `prFlow` route below.
41
35
 
42
- ### Scenario 4: pre-commit snapshot block
43
-
44
- This scenario ends the run before `git commit` and does not enter the successful post-commit scenario selection below. When any of `pre_head != R`, `W != T`, or `S != T` applies:
45
-
46
- - Do not run `git commit`, push, successful state updates, Issue/PR success sync, or the commit completion gate; preserve the current worktree and index.
47
- - Refresh task `updated_at`, `assigned_to`, and `agent_infra_version`, then append a done log with action `Commit`: `Blocked before git commit: reviewed snapshot mismatch (worktree added={a}, missing={m}, different={d}; staged added={a}, missing={m}, different={d})`.
48
- - User output must include `No commit was created.` and show Added/Missing/Different under both `Current worktree vs reviewed snapshot` and `Staged snapshot vs reviewed snapshot`; render an empty set as `- (none)` and list paths only in user output.
49
- - When `pre_head != R` or `W != T`, the only next step is a fresh `review-code`; when only `W == T && S != T`, tell the user to fix staging and rerun `commit` without re-review.
50
-
51
- Full re-review commands:
52
-
53
- Populate `{next-step-commands}` for this scenario by running `agent-infra-internal agent-client next-steps --skill review-code --task-ref {task-ref}`.
54
-
55
- ```text
56
- Next step - re-run code review:
57
- {next-step-commands}
58
- ```
59
-
60
- Full staging-only retry commands:
61
-
62
- Populate `{next-step-commands}` for this scenario by running `agent-infra-internal agent-client next-steps --skill commit --task-ref {task-ref}`.
63
-
64
- ```text
65
- Next step - fix staging and retry commit:
66
- {next-step-commands}
67
- ```
68
-
69
36
  Before selecting the next step, verify:
70
37
  - `current_step` and the latest workflow progress in `task.md`
71
38
  - whether the latest `review-code.md` / `review-code-r{N}.md` passed without findings
@@ -12,19 +12,13 @@
12
12
  date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
13
13
  ```
14
14
 
15
- `commit-complete` / `commit-recover` 核心已原子写入以下 Activity Log:
15
+ `commit-operation.execute` 在 task-bound 模式下负责写入以下 Activity Log:
16
16
 
17
17
  ```text
18
18
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Commit** by {agent} — {commit hash short} {commit subject}
19
19
  ```
20
20
 
21
- 证据满足时核心同时写入或刷新:
22
-
23
- ```yaml
24
- last_reviewed_commit: {new_head}
25
- ```
26
-
27
- 该字段是 `complete-task` 的 `post-review-commit` gate 唯一 baseline。调用方只读取核心结果选择后续路由,不得再次追加 Commit done 或手写/推进该字段。
21
+ 任务记录是 Git 主动作之后的尽力同步:Activity Log 或 frontmatter 写入失败只返回 `TASK_STATUS_SYNC_FAILED` warning,不撤销 commit 或 push;后续无改动重跑可以再次尝试补齐记录。`review-code`、review anchor 和 `last_reviewed_commit` 不再是 commit/push 的前置条件,调用方只读取核心结果选择后续路由,不得手写 Activity Log。
28
22
 
29
23
  ### 场景 5:已有 PR 推送收尾
30
24
 
@@ -39,33 +33,6 @@ last_reviewed_commit: {new_head}
39
33
 
40
34
  push 失败时保留任务 active 与本地 HEAD,只展示诊断和人工推送提示;不得渲染 `watch-pr` 或 `complete-task`。该场景优先于下方 `prFlow` 终态路由。
41
35
 
42
- ### 场景 4:提交前快照阻断
43
-
44
- 此场景在 `git commit` 前终止本轮,不进入下方提交成功后的场景选择。任一 `pre_head != R`、`W != T` 或 `S != T` 命中时:
45
-
46
- - 不执行 `git commit`、push、成功状态更新、Issue/PR 成功同步或 commit 完成 gate;保留当前工作区与暂存区。
47
- - 刷新任务的 `updated_at`、`assigned_to`、`agent_infra_version`,并以 action `Commit` 追加 done 日志:`Blocked before git commit: reviewed snapshot mismatch (worktree added={a}, missing={m}, different={d}; staged added={a}, missing={m}, different={d})`。
48
- - 用户输出必须包含 `No commit was created.`,并分别按 `Current worktree vs reviewed snapshot`、`Staged snapshot vs reviewed snapshot` 展示 Added/Missing/Different;空集合显示 `- (none)`,路径只在用户输出中逐行展示。
49
- - `pre_head != R` 或 `W != T` 时,下一步只指向重新 `review-code`;仅 `W == T && S != T` 时,提示修正暂存后重跑 `commit`,无需重审。
50
-
51
- 重新审查的完整命令:
52
-
53
- 使用 `agent-infra-internal agent-client next-steps --skill review-code --task-ref {task-ref}` 生成本场景的 `{next-step-commands}`。
54
-
55
- ```text
56
- 下一步 - 重新代码审查:
57
- {next-step-commands}
58
- ```
59
-
60
- 仅修正暂存的完整命令:
61
-
62
- 使用 `agent-infra-internal agent-client next-steps --skill commit --task-ref {task-ref}` 生成本场景的 `{next-step-commands}`。
63
-
64
- ```text
65
- 下一步 - 修正暂存后重新提交:
66
- {next-step-commands}
67
- ```
68
-
69
36
  在决定下一步之前,先确认:
70
37
  - `task.md` 中的 `current_step` 和最新工作流进度
71
38
  - 最新的 `review-code.md` / `review-code-r{N}.md` 是否无问题通过