@fitlab-ai/agent-infra 0.9.10 → 0.9.12

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 (375) hide show
  1. package/README.md +19 -9
  2. package/README.zh-CN.md +19 -9
  3. package/bin/cli.ts +17 -4
  4. package/dist/bin/cli.js +19 -4
  5. package/dist/bin/internal-cli.js +55 -4
  6. package/dist/lib/agent-client.js +0 -1
  7. package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +71 -10
  8. package/dist/lib/agent-clients/adapters/opencode-sandbox.js +0 -4
  9. package/dist/lib/agent-clients/adapters/traecli.js +7 -8
  10. package/dist/lib/agent-clients/config.js +14 -99
  11. package/dist/lib/agent-clients/reconcile.js +1 -11
  12. package/dist/lib/agent-clients/schema.js +5 -4
  13. package/dist/lib/agent-clients/tokens.js +5 -15
  14. package/dist/lib/decide.js +14 -30
  15. package/dist/lib/defaults.json +8 -0
  16. package/dist/lib/git/workflow.js +43 -1
  17. package/dist/lib/init.js +3 -2
  18. package/dist/lib/internal/git-workflow.js +8 -1
  19. package/dist/lib/internal/platform-pr.js +8 -2
  20. package/dist/lib/internal/release-workflow.js +0 -1
  21. package/dist/lib/internal/task-delivery.js +59 -0
  22. package/dist/lib/internal/task-finalization.js +19 -9
  23. package/dist/lib/internal/task-ledger.js +8 -2
  24. package/dist/lib/internal/task-lifecycle.js +17 -93
  25. package/dist/lib/internal/task-orchestration.js +30 -216
  26. package/dist/lib/internal/task-validate.js +2 -1
  27. package/dist/lib/merge.js +205 -103
  28. package/dist/lib/platform/github-client.js +7 -1
  29. package/dist/lib/platform/pr-checks.js +8 -5
  30. package/dist/lib/platform/pr-summary.js +12 -8
  31. package/dist/lib/platform/pull-requests.js +393 -91
  32. package/dist/lib/platform/verification-required.js +13 -2
  33. package/dist/lib/platform/verification-sync.js +9 -4
  34. package/dist/lib/pr-review/evidence-grading.js +12 -4
  35. package/dist/lib/process-data/normalize.js +2 -9
  36. package/dist/lib/run/host.js +46 -16
  37. package/dist/lib/sandbox/agent-client-reconciler.js +4 -12
  38. package/dist/lib/sandbox/commands/create.js +3 -3
  39. package/dist/lib/sandbox/commands/enter.js +18 -4
  40. package/dist/lib/sandbox/config.js +8 -12
  41. package/dist/lib/sandbox/control/executor.js +131 -39
  42. package/dist/lib/sandbox/control/lifecycle.js +55 -24
  43. package/dist/lib/sandbox/control/server.js +18 -16
  44. package/dist/lib/sandbox/mounts.js +3 -2
  45. package/dist/lib/sandbox/recovery.js +123 -22
  46. package/dist/lib/sandbox/workspace-identity.js +14 -0
  47. package/dist/lib/sandbox/workspace-view.js +8 -9
  48. package/dist/lib/self-update.js +278 -0
  49. package/dist/lib/server/process-state.js +2 -2
  50. package/dist/lib/server/protocol.js +5 -5
  51. package/dist/lib/task/activity-log.js +4 -1
  52. package/dist/lib/task/artifact-lifecycle.js +6 -4
  53. package/dist/lib/task/codex-orchestration.js +1 -1
  54. package/dist/lib/task/command-options.js +1 -3
  55. package/dist/lib/task/commands/cat.js +0 -5
  56. package/dist/lib/task/commands/decisions.js +76 -92
  57. package/dist/lib/task/commands/files.js +6 -6
  58. package/dist/lib/task/commands/grep.js +25 -61
  59. package/dist/lib/task/commands/issue-body.js +6 -6
  60. package/dist/lib/task/commands/log.js +25 -10
  61. package/dist/lib/task/commands/show.js +5 -6
  62. package/dist/lib/task/commands/status.js +8 -8
  63. package/dist/lib/task/commit-intent.js +100 -0
  64. package/dist/lib/task/commit-operation.js +181 -91
  65. package/dist/lib/task/commit-policy.js +1 -1
  66. package/dist/lib/task/control-authority.js +431 -0
  67. package/dist/lib/task/create.js +39 -8
  68. package/dist/lib/task/current-contract.js +35 -0
  69. package/dist/lib/task/decision-details.js +218 -0
  70. package/dist/lib/task/decision-intents.js +5 -2
  71. package/dist/lib/task/delivery-target.js +97 -0
  72. package/dist/lib/task/delivery.js +153 -0
  73. package/dist/lib/task/events.js +11 -5
  74. package/dist/lib/task/human-override.js +5 -2
  75. package/dist/lib/task/index.js +19 -20
  76. package/dist/lib/task/ledger-intents.js +8 -9
  77. package/dist/lib/task/ledger.js +13 -6
  78. package/dist/lib/task/lifecycle.js +122 -9
  79. package/dist/lib/task/orchestration.js +105 -75
  80. package/dist/lib/task/pr-delivery-fact.js +182 -0
  81. package/dist/lib/task/review-artifacts.js +31 -12
  82. package/dist/lib/task/review-finalization.js +13 -4
  83. package/dist/lib/task/review-fingerprint.js +8 -0
  84. package/dist/lib/task/verification-engine.js +86 -39
  85. package/dist/lib/task/verification-review.js +2 -2
  86. package/dist/lib/task/workspace-snapshot.js +5 -11
  87. package/dist/lib/task/write.js +11 -1
  88. package/dist/lib/update.js +13 -35
  89. package/dist/lib/version.js +5 -1
  90. package/dist/lifecycle-build-manifest.json +3 -3
  91. package/lib/agent-client.ts +0 -1
  92. package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +105 -10
  93. package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +12 -1
  94. package/lib/agent-clients/adapters/opencode-sandbox.ts +0 -5
  95. package/lib/agent-clients/adapters/traecli.ts +7 -8
  96. package/lib/agent-clients/config.ts +14 -144
  97. package/lib/agent-clients/reconcile.ts +1 -12
  98. package/lib/agent-clients/schema.ts +5 -4
  99. package/lib/agent-clients/tokens.ts +5 -18
  100. package/lib/decide.ts +12 -22
  101. package/lib/defaults.json +8 -0
  102. package/lib/git/workflow.ts +38 -1
  103. package/lib/init.ts +5 -2
  104. package/lib/internal/git-workflow.ts +7 -1
  105. package/lib/internal/platform-pr.ts +8 -1
  106. package/lib/internal/release-workflow.ts +0 -1
  107. package/lib/internal/task-delivery.ts +53 -0
  108. package/lib/internal/task-finalization.ts +27 -13
  109. package/lib/internal/task-ledger.ts +8 -2
  110. package/lib/internal/task-lifecycle.ts +33 -76
  111. package/lib/internal/task-orchestration.ts +33 -190
  112. package/lib/internal/task-validate.ts +3 -2
  113. package/lib/merge.ts +236 -120
  114. package/lib/platform/github-client.ts +8 -1
  115. package/lib/platform/pr-checks.ts +7 -5
  116. package/lib/platform/pr-summary.ts +10 -7
  117. package/lib/platform/pull-requests.ts +425 -87
  118. package/lib/platform/verification-required.ts +12 -2
  119. package/lib/platform/verification-sync.ts +9 -4
  120. package/lib/pr-review/evidence-grading.ts +7 -4
  121. package/lib/process-data/normalize.ts +2 -8
  122. package/lib/run/host.ts +63 -14
  123. package/lib/sandbox/agent-client-reconciler.ts +5 -15
  124. package/lib/sandbox/commands/create.ts +4 -4
  125. package/lib/sandbox/commands/enter.ts +24 -4
  126. package/lib/sandbox/config.ts +9 -14
  127. package/lib/sandbox/control/container-identity.ts +2 -2
  128. package/lib/sandbox/control/executor.ts +148 -51
  129. package/lib/sandbox/control/lifecycle.ts +59 -31
  130. package/lib/sandbox/control/protocol.ts +1 -3
  131. package/lib/sandbox/control/server.ts +15 -12
  132. package/lib/sandbox/control/state.ts +7 -7
  133. package/lib/sandbox/mounts.ts +4 -3
  134. package/lib/sandbox/recovery.ts +162 -34
  135. package/lib/sandbox/tools.ts +1 -1
  136. package/lib/sandbox/workspace-identity.ts +28 -0
  137. package/lib/sandbox/workspace-view.ts +14 -10
  138. package/lib/self-update.ts +341 -0
  139. package/lib/server/process-state.ts +2 -2
  140. package/lib/server/protocol.ts +5 -5
  141. package/lib/task/activity-log.ts +6 -1
  142. package/lib/task/artifact-lifecycle.ts +7 -5
  143. package/lib/task/codex-orchestration.ts +2 -1
  144. package/lib/task/command-options.ts +1 -2
  145. package/lib/task/commands/cat.ts +0 -4
  146. package/lib/task/commands/decisions.ts +80 -75
  147. package/lib/task/commands/files.ts +6 -6
  148. package/lib/task/commands/grep.ts +23 -51
  149. package/lib/task/commands/issue-body.ts +6 -6
  150. package/lib/task/commands/log.ts +22 -10
  151. package/lib/task/commands/show.ts +5 -6
  152. package/lib/task/commands/status.ts +8 -8
  153. package/lib/task/commit-intent.ts +137 -0
  154. package/lib/task/commit-operation.ts +161 -79
  155. package/lib/task/commit-policy.ts +1 -2
  156. package/lib/task/control-authority.ts +563 -0
  157. package/lib/task/create.ts +40 -10
  158. package/lib/task/current-contract.ts +49 -0
  159. package/lib/task/decision-details.ts +280 -0
  160. package/lib/task/decision-intents.ts +7 -2
  161. package/lib/task/delivery-target.ts +130 -0
  162. package/lib/task/delivery.ts +160 -0
  163. package/lib/task/events.ts +10 -5
  164. package/lib/task/human-override.ts +5 -2
  165. package/lib/task/index.ts +19 -20
  166. package/lib/task/ledger-intents.ts +6 -8
  167. package/lib/task/ledger.ts +17 -7
  168. package/lib/task/lifecycle.ts +113 -4
  169. package/lib/task/orchestration.ts +102 -80
  170. package/lib/task/pr-delivery-fact.ts +254 -0
  171. package/lib/task/review-artifacts.ts +53 -15
  172. package/lib/task/review-finalization.ts +21 -5
  173. package/lib/task/review-fingerprint.ts +10 -0
  174. package/lib/task/verification-engine.ts +78 -46
  175. package/lib/task/verification-review.ts +3 -1
  176. package/lib/task/workspace-snapshot.ts +4 -13
  177. package/lib/task/write.ts +20 -1
  178. package/lib/update.ts +14 -38
  179. package/lib/version.ts +6 -1
  180. package/package.json +1 -1
  181. package/templates/.agents/README.en.md +5 -3
  182. package/templates/.agents/README.zh-CN.md +5 -3
  183. package/templates/.agents/rules/README.en.md +4 -2
  184. package/templates/.agents/rules/README.zh-CN.md +4 -2
  185. package/templates/.agents/rules/compatibility-policy.en.md +5 -4
  186. package/templates/.agents/rules/compatibility-policy.zh-CN.md +5 -4
  187. package/templates/.agents/rules/create-issue.en.md +11 -2
  188. package/templates/.agents/rules/create-issue.zh-CN.md +24 -2
  189. package/templates/.agents/rules/human-decision-context.en.md +9 -7
  190. package/templates/.agents/rules/human-decision-context.zh-CN.md +9 -7
  191. package/templates/.agents/rules/{issue-fields.github.en.md → issue-fields.en.md} +1 -1
  192. package/templates/.agents/rules/{issue-fields.github.zh-CN.md → issue-fields.zh-CN.md} +1 -1
  193. package/templates/.agents/rules/issue-pr-commands.en.md +5 -18
  194. package/templates/.agents/rules/issue-pr-commands.zh-CN.md +1 -1
  195. package/templates/.agents/rules/issue-sync.en.md +26 -5
  196. package/templates/.agents/rules/issue-sync.zh-CN.md +62 -5
  197. package/templates/.agents/rules/label-milestone-setup.en.md +15 -2
  198. package/templates/.agents/rules/label-milestone-setup.zh-CN.md +15 -2
  199. package/templates/.agents/rules/local-artifact-repair.en.md +46 -0
  200. package/templates/.agents/rules/local-artifact-repair.zh-CN.md +46 -0
  201. package/templates/.agents/rules/milestone-inference.en.md +12 -2
  202. package/templates/.agents/rules/milestone-inference.zh-CN.md +25 -3
  203. package/templates/.agents/rules/next-step-output.en.md +3 -3
  204. package/templates/.agents/rules/next-step-output.zh-CN.md +3 -3
  205. package/templates/.agents/rules/no-mid-flow-questions.en.md +1 -1
  206. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +1 -1
  207. package/templates/.agents/rules/pr-sync.en.md +23 -14
  208. package/templates/.agents/rules/pr-sync.zh-CN.md +23 -2
  209. package/templates/.agents/rules/release-commands.en.md +42 -3
  210. package/templates/.agents/rules/release-commands.zh-CN.md +42 -3
  211. package/templates/.agents/rules/review-handshake.en.md +1 -1
  212. package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
  213. package/templates/.agents/rules/security-alerts.en.md +17 -2
  214. package/templates/.agents/rules/security-alerts.zh-CN.md +17 -2
  215. package/templates/.agents/rules/sync-content-generation.en.md +8 -0
  216. package/templates/.agents/rules/sync-content-generation.zh-CN.md +8 -0
  217. package/templates/.agents/rules/task-management.en.md +2 -3
  218. package/templates/.agents/rules/task-management.zh-CN.md +2 -3
  219. package/templates/.agents/scripts/security-alerts.github.sh +151 -0
  220. package/templates/.agents/scripts/security-alerts.sh +31 -0
  221. package/templates/.agents/skills/analyze-task/SKILL.en.md +4 -3
  222. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +4 -3
  223. package/templates/.agents/skills/block-task/SKILL.en.md +2 -2
  224. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +2 -2
  225. package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
  226. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
  227. package/templates/.agents/skills/check-task/SKILL.en.md +2 -2
  228. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +2 -2
  229. package/templates/.agents/skills/close-codescan/SKILL.en.md +3 -3
  230. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +3 -3
  231. package/templates/.agents/skills/close-dependabot/SKILL.en.md +3 -3
  232. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +3 -3
  233. package/templates/.agents/skills/code-task/SKILL.en.md +8 -5
  234. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +9 -6
  235. package/templates/.agents/skills/commit/SKILL.en.md +30 -10
  236. package/templates/.agents/skills/commit/SKILL.zh-CN.md +6 -7
  237. package/templates/.agents/skills/commit/config/verify.json +1 -1
  238. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +3 -3
  239. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +3 -3
  240. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
  241. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
  242. package/templates/.agents/skills/commit/reference/task-status-update.en.md +2 -2
  243. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +2 -2
  244. package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +7 -6
  245. package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +7 -6
  246. package/templates/.agents/skills/complete-manual-validation/config/verify.en.json +1 -1
  247. package/templates/.agents/skills/complete-manual-validation/config/verify.zh-CN.json +1 -1
  248. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +1 -1
  249. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +1 -1
  250. package/templates/.agents/skills/complete-task/SKILL.en.md +13 -13
  251. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +13 -13
  252. package/templates/.agents/skills/complete-task/reference/external-delivery.en.md +2 -2
  253. package/templates/.agents/skills/complete-task/reference/external-delivery.zh-CN.md +2 -2
  254. package/templates/.agents/skills/create-pr/SKILL.en.md +9 -11
  255. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +9 -11
  256. package/templates/.agents/skills/create-pr/reference/change-report.en.md +9 -4
  257. package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +9 -4
  258. package/templates/.agents/skills/create-pr/scripts/change-report.mjs +203 -0
  259. package/templates/.agents/skills/create-release-note/SKILL.en.md +5 -6
  260. package/templates/.agents/skills/create-release-note/SKILL.zh-CN.md +5 -6
  261. package/templates/.agents/skills/create-task/SKILL.en.md +2 -1
  262. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +2 -1
  263. package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
  264. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
  265. package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
  266. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
  267. package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
  268. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
  269. package/templates/.agents/skills/init-labels/SKILL.en.md +9 -10
  270. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +9 -10
  271. package/templates/.agents/skills/init-labels/scripts/init-labels.github.sh +57 -1
  272. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +27 -1
  273. package/templates/.agents/skills/init-milestones/SKILL.en.md +3 -5
  274. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +3 -5
  275. package/templates/.agents/skills/plan-task/SKILL.en.md +4 -3
  276. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +4 -3
  277. package/templates/.agents/skills/restore-task/SKILL.en.md +1 -1
  278. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +1 -1
  279. package/templates/.agents/skills/review-analysis/SKILL.en.md +8 -5
  280. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +8 -5
  281. package/templates/.agents/skills/review-analysis/config/verify.en.json +1 -0
  282. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +1 -0
  283. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +18 -0
  284. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +18 -0
  285. package/templates/.agents/skills/review-code/SKILL.en.md +11 -8
  286. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -8
  287. package/templates/.agents/skills/review-code/config/verify.en.json +1 -0
  288. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -0
  289. package/templates/.agents/skills/review-code/reference/migration-risks.en.md +2 -1
  290. package/templates/.agents/skills/review-code/reference/migration-risks.zh-CN.md +2 -1
  291. package/templates/.agents/skills/review-code/reference/output-templates.en.md +19 -1
  292. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +19 -1
  293. package/templates/.agents/skills/review-code/reference/report-template.en.md +4 -2
  294. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +4 -2
  295. package/templates/.agents/skills/review-plan/SKILL.en.md +8 -5
  296. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +8 -5
  297. package/templates/.agents/skills/review-plan/config/verify.en.json +1 -0
  298. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +1 -0
  299. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +18 -0
  300. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +18 -0
  301. package/templates/.agents/skills/review-pr/SKILL.en.md +1 -0
  302. package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +1 -0
  303. package/templates/.agents/skills/review-pr/reference/evidence-grading.en.md +2 -2
  304. package/templates/.agents/skills/review-pr/reference/evidence-grading.zh-CN.md +2 -2
  305. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +5 -0
  306. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +5 -0
  307. package/templates/.agents/skills/run-task/SKILL.en.md +5 -1
  308. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +5 -1
  309. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +2 -2
  310. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +2 -2
  311. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +144 -109
  312. package/templates/.agents/skills/watch-pr/SKILL.en.md +5 -5
  313. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +5 -5
  314. package/templates/.agents/templates/task.en.md +6 -2
  315. package/templates/.agents/templates/task.zh-CN.md +6 -2
  316. package/templates/.agents/workflows/bug-fix.en.yaml +9 -8
  317. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +9 -8
  318. package/templates/.agents/workflows/feature-development.en.yaml +9 -8
  319. package/templates/.agents/workflows/feature-development.zh-CN.yaml +9 -8
  320. package/templates/.agents/workflows/refactoring.en.yaml +9 -8
  321. package/templates/.agents/workflows/refactoring.zh-CN.yaml +9 -8
  322. package/templates/.claude/commands/analyze-task.en.md +1 -1
  323. package/templates/.claude/commands/analyze-task.zh-CN.md +1 -1
  324. package/templates/.claude/commands/block-task.en.md +1 -1
  325. package/templates/.claude/commands/block-task.zh-CN.md +1 -1
  326. package/templates/.claude/commands/cancel-task.en.md +1 -1
  327. package/templates/.claude/commands/cancel-task.zh-CN.md +1 -1
  328. package/templates/.claude/commands/check-task.en.md +1 -1
  329. package/templates/.claude/commands/check-task.zh-CN.md +1 -1
  330. package/templates/.claude/commands/code-task.en.md +1 -1
  331. package/templates/.claude/commands/code-task.zh-CN.md +1 -1
  332. package/templates/.claude/commands/commit.en.md +1 -1
  333. package/templates/.claude/commands/commit.zh-CN.md +1 -1
  334. package/templates/.claude/commands/complete-manual-validation.en.md +1 -1
  335. package/templates/.claude/commands/complete-manual-validation.zh-CN.md +1 -1
  336. package/templates/.claude/commands/complete-task.en.md +1 -1
  337. package/templates/.claude/commands/complete-task.zh-CN.md +1 -1
  338. package/templates/.claude/commands/create-pr.en.md +1 -1
  339. package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
  340. package/templates/.claude/commands/plan-task.en.md +1 -1
  341. package/templates/.claude/commands/plan-task.zh-CN.md +1 -1
  342. package/templates/.claude/commands/review-analysis.en.md +1 -1
  343. package/templates/.claude/commands/review-analysis.zh-CN.md +1 -1
  344. package/templates/.claude/commands/review-code.en.md +1 -1
  345. package/templates/.claude/commands/review-code.zh-CN.md +1 -1
  346. package/templates/.claude/commands/review-plan.en.md +1 -1
  347. package/templates/.claude/commands/review-plan.zh-CN.md +1 -1
  348. package/templates/.claude/commands/run-manual-validation.en.md +1 -1
  349. package/templates/.claude/commands/run-manual-validation.zh-CN.md +1 -1
  350. package/templates/.claude/commands/run-task.en.md +1 -1
  351. package/templates/.claude/commands/run-task.zh-CN.md +1 -1
  352. package/templates/.claude/commands/watch-pr.en.md +1 -1
  353. package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
  354. package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.en.md +0 -1
  355. package/templates/{.trae/skills → .traecli/commands}/update-agent-infra.zh-CN.md +0 -1
  356. package/dist/lib/builtin-tuis.js +0 -40
  357. package/lib/builtin-tuis.ts +0 -56
  358. package/templates/.agents/rules/create-issue.github.en.md +0 -14
  359. package/templates/.agents/rules/create-issue.github.zh-CN.md +0 -27
  360. package/templates/.agents/rules/issue-pr-commands.github.en.md +0 -34
  361. package/templates/.agents/rules/issue-pr-commands.github.zh-CN.md +0 -49
  362. package/templates/.agents/rules/issue-sync.github.en.md +0 -40
  363. package/templates/.agents/rules/issue-sync.github.zh-CN.md +0 -76
  364. package/templates/.agents/rules/label-milestone-setup.github.en.md +0 -60
  365. package/templates/.agents/rules/label-milestone-setup.github.zh-CN.md +0 -60
  366. package/templates/.agents/rules/milestone-inference.github.en.md +0 -15
  367. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +0 -27
  368. package/templates/.agents/rules/pr-checks-commands.github.en.md +0 -18
  369. package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +0 -34
  370. package/templates/.agents/rules/pr-sync.github.en.md +0 -43
  371. package/templates/.agents/rules/pr-sync.github.zh-CN.md +0 -69
  372. package/templates/.agents/rules/release-commands.github.en.md +0 -38
  373. package/templates/.agents/rules/release-commands.github.zh-CN.md +0 -38
  374. package/templates/.agents/rules/security-alerts.github.en.md +0 -43
  375. package/templates/.agents/rules/security-alerts.github.zh-CN.md +0 -43
@@ -3,19 +3,18 @@ import path from 'node:path';
3
3
  import { formatTable } from '../../table.js';
4
4
  import { parseTaskScope } from '../command-options.js';
5
5
  import { resolveTaskContext } from '../resolve-ref.js';
6
- import { isReviewStage, parseLedger } from '../ledger.js';
6
+ import { isReviewStage, parseLedgerDocument } from '../ledger.js';
7
7
  import { listDecisionItems, selectDecisionItem } from '../decision-items.js';
8
- import { extractSubSection } from '../sections.js';
8
+ import { normalizeDecisionDetailForDisplay, parseDecisionEvidence, resolveDecisionDetail } from '../decision-details.js';
9
9
  const USAGE = `Usage: ai task decisions [--task <ref> | -t <ref>] [--item <selector> | -i <selector>] [options]
10
- ai task decisions <ref> [selector] [options]
11
10
 
12
11
  Shows what still needs a maintainer's decision. Without a selector, it lists
13
12
  the choices. With a selector, it shows the explanation and how to respond.
14
13
  Read-only.
15
14
 
16
- Omit <ref> Resolve the unique active task for the current branch.
17
- <ref> Legacy positional task ref.
18
- [selector] Ordinal (1-based) or ledger id (e.g. 'PL-3') to show one item's detail.
15
+ Omit the scope Resolve the unique active task for the current branch.
16
+ --task/-t <ref> Select a task explicitly.
17
+ --item/-i <s> Ordinal (1-based) or ledger id (e.g. 'PL-3') to show one item's detail.
19
18
 
20
19
  Options:
21
20
  -i, --item <s> Select an item when task scope is implicit or flag-based.
@@ -53,15 +52,8 @@ function parseArgs(args) {
53
52
  i += 1;
54
53
  }
55
54
  else if (a.startsWith('--item=')) {
56
- if (out.item !== undefined) {
57
- fail("duplicate option '--item'");
58
- return null;
59
- }
60
- out.item = a.slice('--item='.length);
61
- if (out.item === '') {
62
- fail('--item requires a value');
63
- return null;
64
- }
55
+ fail("--item=... is not supported; use --item <selector> or -i <selector>");
56
+ return null;
65
57
  }
66
58
  else if (a === '--stage') {
67
59
  const v = args[i + 1];
@@ -97,48 +89,26 @@ function parseArgs(args) {
97
89
  }
98
90
  return out;
99
91
  }
100
- // Parse `<file>.md#anchor` evidence into its filename, when present.
101
- function evidenceFile(evidence) {
102
- const m = /([\w.-]+\.md)#/.exec(evidence);
103
- return m ? m[1] : null;
104
- }
105
- function roundOf(file) {
106
- const m = /-r(\d+)\.md$/.exec(file);
107
- return m ? Number.parseInt(m[1], 10) : 1;
108
- }
109
- // Locate the `### {ledger-id}` detail block for a row. Prefer the artifact named by the
110
- // row's evidence anchor; otherwise scan analysis/plan/code artifacts and return
111
- // the block from the highest-round file that contains it. Returns '' when none
112
- // is found (caller degrades gracefully — plan B3).
113
92
  function findDetailBlock(row, taskDir) {
114
- const hinted = evidenceFile(row.evidence);
115
- if (hinted) {
116
- const p = path.join(taskDir, hinted);
117
- if (fs.existsSync(p)) {
118
- const block = extractSubSection(fs.readFileSync(p, 'utf8'), row.id);
119
- if (block)
120
- return block;
121
- }
122
- }
123
- let best = '';
124
- let bestRound = -1;
125
- let entries;
93
+ const evidence = parseDecisionEvidence(row.evidence);
94
+ if (!evidence.ok)
95
+ return { status: 'invalid', reason: `invalid evidence '${row.evidence}'` };
96
+ const artifactPath = path.join(taskDir, evidence.artifact);
97
+ if (!fs.existsSync(artifactPath))
98
+ return { status: 'missing', reason: `artifact '${evidence.artifact}' is missing` };
99
+ let artifactContent;
126
100
  try {
127
- entries = fs.readdirSync(taskDir);
101
+ artifactContent = fs.readFileSync(artifactPath, 'utf8');
128
102
  }
129
103
  catch {
130
- return '';
104
+ return { status: 'missing', reason: `artifact '${evidence.artifact}' cannot be read` };
131
105
  }
132
- for (const file of entries) {
133
- if (!/^(analysis|plan|code)(-r\d+)?\.md$/.test(file))
134
- continue;
135
- const block = extractSubSection(fs.readFileSync(path.join(taskDir, file), 'utf8'), row.id);
136
- if (block && roundOf(file) > bestRound) {
137
- best = block;
138
- bestRound = roundOf(file);
139
- }
140
- }
141
- return best;
106
+ const resolved = resolveDecisionDetail(artifactContent, row.id, evidence.anchor);
107
+ if (resolved.status === 'found')
108
+ return { status: 'found', content: normalizeDecisionDetailForDisplay(resolved.block) };
109
+ if (resolved.status === 'ambiguous')
110
+ return { status: 'ambiguous', reason: resolved.reason };
111
+ return { status: 'missing', reason: resolved.reason };
142
112
  }
143
113
  // Pull the `## 人工裁决` record lines that mention this ledger id, so a decided item
144
114
  // shows the human's recorded ruling alongside its detail block.
@@ -160,9 +130,9 @@ function findDecisionRecord(id, content) {
160
130
  return out;
161
131
  }
162
132
  function titleOf(row, taskDir) {
163
- const block = findDetailBlock(row, taskDir);
164
- if (block) {
165
- const title = block
133
+ const detail = findDetailBlock(row, taskDir);
134
+ if (detail.status === 'found') {
135
+ const title = detail.content
166
136
  .split('\n')[0]
167
137
  .replace(/^###\s+/, '')
168
138
  .replace(/\s*\[needs-human-decision\]\s*$/, '')
@@ -174,7 +144,7 @@ function titleOf(row, taskDir) {
174
144
  function trackingOf(row) {
175
145
  return `stage=${row.stage} · severity=${row.severity} · status=${row.status} · evidence=${row.evidence}`;
176
146
  }
177
- function renderList(rows, format, taskDir) {
147
+ function renderList(rows, format, taskDir, taskId) {
178
148
  if (rows.length === 0) {
179
149
  process.stdout.write('No pending decisions.\n');
180
150
  return;
@@ -193,10 +163,10 @@ function renderList(rows, format, taskDir) {
193
163
  `| ${sep.join(' | ')} |`,
194
164
  ...data.map((row) => `| ${row.join(' | ')} |`)
195
165
  ];
196
- process.stdout.write(`${md.join('\n')}\n\nView one item: ai task decisions <task-ref> <ordinal|ledger-id>\n`);
166
+ process.stdout.write(`${md.join('\n')}\n\nView one item: ai task decisions --task ${taskId} --item <ordinal|ledger-id>\n`);
197
167
  return;
198
168
  }
199
- process.stdout.write(`${formatTable(headers, data).join('\n')}\n\nView one item: ai task decisions <task-ref> <ordinal|ledger-id>\n`);
169
+ process.stdout.write(`${formatTable(headers, data).join('\n')}\n\nView one item: ai task decisions --task ${taskId} --item <ordinal|ledger-id>\n`);
200
170
  }
201
171
  function renderTracking(row, format) {
202
172
  if (format === 'markdown') {
@@ -216,29 +186,31 @@ function renderTracking(row, format) {
216
186
  `evidence: ${row.evidence}`
217
187
  ];
218
188
  }
219
- function renderDetail(rows, selector, format, taskDir, content) {
189
+ function renderDetail(rows, selector, format, taskDir, content, taskId) {
220
190
  const selected = selectDecisionItem(rows, selector);
221
191
  if (!selected.ok) {
222
192
  fail(selected.message);
223
193
  return;
224
194
  }
225
195
  const r = selected.row;
226
- const block = findDetailBlock(r, taskDir);
227
- const title = titleOf(r, taskDir);
196
+ const detail = findDetailBlock(r, taskDir);
197
+ if (detail.status === 'invalid' || detail.status === 'ambiguous') {
198
+ fail(`cannot resolve ${r.id}: ${detail.reason}`);
199
+ return;
200
+ }
201
+ const block = detail.status === 'found' ? detail.content : '';
202
+ const title = block
203
+ ? block.split('\n')[0].replace(/^###\s+/, '').replace(/\s*\[needs-human-decision\]\s*$/, '').trim()
204
+ .replace(new RegExp(`^${r.id}\\s*[::]\\s*`, 'i'), '').trim()
205
+ : '(explanation unavailable)';
228
206
  const lines = [];
229
207
  const decided = r.status === 'human-decided';
230
208
  if (format === 'markdown') {
231
209
  lines.push(`## ${decided ? 'Decision already recorded' : 'Decision needed'}: ${title}`, '');
232
- if (!decided) {
233
- lines.push('**How to record your choice**', `\`ai decide <task-ref> ${r.id} <your choice and rationale>\``, '');
234
- }
235
210
  lines.push('**Original context**', '');
236
211
  }
237
212
  else {
238
213
  lines.push(`${decided ? 'Decision already recorded' : 'Decision needed'}: ${title}`, '');
239
- if (!decided) {
240
- lines.push('How to record your choice:', `ai decide <task-ref> ${r.id} <your choice and rationale>`, '');
241
- }
242
214
  lines.push('Original context:');
243
215
  }
244
216
  if (block) {
@@ -252,6 +224,15 @@ function renderDetail(rows, selector, format, taskDir, content) {
252
224
  lines.push('', format === 'markdown' ? '**Recorded choice**' : 'Recorded choice:');
253
225
  lines.push(...(record.length ? record : ['No separate ruling record was found.']));
254
226
  }
227
+ if (!decided) {
228
+ lines.push('');
229
+ if (format === 'markdown') {
230
+ lines.push('**How to record your choice**', `\`ai decide --task ${taskId} --item ${r.id} <your choice and rationale>\``);
231
+ }
232
+ else {
233
+ lines.push('How to record your choice:', `ai decide --task ${taskId} --item ${r.id} <your choice and rationale>`);
234
+ }
235
+ }
255
236
  lines.push('', ...renderTracking(r, format));
256
237
  process.stdout.write(`${lines.join('\n')}\n`);
257
238
  }
@@ -279,43 +260,46 @@ function decisions(args = []) {
279
260
  fail(`invalid --format '${parsed.format}' (expected text|markdown)`);
280
261
  return;
281
262
  }
282
- let taskRef = scope.taskRef;
283
- let selector = parsed.item;
284
- if (parsed.item !== undefined) {
285
- if (parsed.positionals.length > 0) {
286
- fail('positional task ref/selector cannot be combined with --item');
287
- return;
288
- }
289
- }
290
- else if (scope.explicit) {
291
- if (parsed.positionals.length > 0) {
292
- fail('positional task ref/selector cannot be combined with --task');
293
- return;
294
- }
295
- }
296
- else {
297
- if (parsed.positionals.length > 2) {
298
- fail('too many positional arguments');
299
- return;
300
- }
301
- taskRef = parsed.positionals[0];
302
- selector = parsed.positionals[1];
263
+ const taskRef = scope.taskRef;
264
+ const selector = parsed.item;
265
+ if (parsed.positionals.length > 0) {
266
+ fail('positional task ref/selector is not supported; use --task <ref> or -t <ref>, and --item <selector> or -i <selector>');
267
+ return;
303
268
  }
304
269
  const resolved = resolveTaskContext(taskRef);
305
270
  if (!resolved.ok) {
306
271
  fail(resolved.message);
307
272
  return;
308
273
  }
309
- const content = fs.readFileSync(resolved.taskMdPath, 'utf8');
310
- const rows = listDecisionItems(parseLedger(content), {
274
+ let content;
275
+ let ledger;
276
+ try {
277
+ content = fs.readFileSync(resolved.taskMdPath, 'utf8');
278
+ ledger = parseLedgerDocument(content);
279
+ }
280
+ catch (error) {
281
+ fail(`ledger unavailable [LEDGER_DOCUMENT_INVALID]: ${error instanceof Error ? error.message : String(error)}`);
282
+ return;
283
+ }
284
+ if (!ledger.present) {
285
+ fail('ledger unavailable [LEDGER_SECTION_MISSING]: review disagreement ledger section is missing');
286
+ return;
287
+ }
288
+ const rows = listDecisionItems(ledger.rows, {
311
289
  includeDecided: parsed.all,
312
290
  stage: parsed.stage
313
291
  });
314
292
  if (selector === undefined) {
315
- renderList(rows, parsed.format, resolved.taskDir);
293
+ renderList(rows, parsed.format, resolved.taskDir, resolved.taskId);
316
294
  }
317
295
  else {
318
- renderDetail(rows, selector, parsed.format, resolved.taskDir, content);
296
+ const selectionRows = /^[A-Za-z]+-\d+$/.test(selector)
297
+ ? listDecisionItems(ledger.rows, {
298
+ includeDecided: true,
299
+ stage: parsed.stage
300
+ })
301
+ : rows;
302
+ renderDetail(selectionRows, selector, parsed.format, resolved.taskDir, content, resolved.taskId);
319
303
  }
320
304
  }
321
305
  export { decisions };
@@ -2,11 +2,11 @@ import { formatTable } from '../../table.js';
2
2
  import { parseTaskScope } from '../command-options.js';
3
3
  import { resolveTaskContext } from '../resolve-ref.js';
4
4
  import { enumerateArtifacts } from '../artifacts.js';
5
- const USAGE = `Usage: ai task files [<N | TASK-id> | --task <ref> | -t <ref>]
5
+ const USAGE = `Usage: ai task files [--task <ref> | -t <ref>]
6
6
 
7
7
  Lists the artifacts in a task directory with stable numbers.
8
- Omit <ref> Resolve the unique active task for the current branch.
9
- <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
8
+ Omit the scope Resolve the unique active task for the current branch.
9
+ --task/-t <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
10
10
 
11
11
  Columns: # (artifact number, usable with 'ai task cat') / NAME / SIZE (bytes) / MTIME
12
12
  `;
@@ -33,12 +33,12 @@ function files(args = []) {
33
33
  process.exitCode = 1;
34
34
  return;
35
35
  }
36
- if (scope.positionals.length > 1 || (scope.explicit && scope.positionals.length > 0)) {
37
- process.stderr.write('ai task files: task ref must be provided once\n');
36
+ if (scope.positionals.length > 0) {
37
+ process.stderr.write('ai task files: positional task ref is not supported; use --task <ref> or -t <ref>\n');
38
38
  process.exitCode = 1;
39
39
  return;
40
40
  }
41
- const resolved = resolveTaskContext(scope.taskRef ?? scope.positionals[0]);
41
+ const resolved = resolveTaskContext(scope.taskRef);
42
42
  if (!resolved.ok) {
43
43
  process.stderr.write(`ai task files: ${resolved.message}\n`);
44
44
  process.exitCode = 1;
@@ -1,24 +1,19 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { resolveTaskContext, resolveTaskRef, detectRepoRoot, enumerateTaskDirs } from '../resolve-ref.js';
3
+ import { resolveTaskContext, resolveTaskRef } from '../resolve-ref.js';
4
4
  import { enumerateArtifacts, resolveArtifact } from '../artifacts.js';
5
5
  import { loadShortIdByTaskId } from '../short-id.js';
6
- const USAGE = `Usage: ai task grep <pattern> [ref] [artifact | N]
7
- ai task grep <pattern> (--current | --task <ref> | -t <ref>) [artifact | N]
6
+ const USAGE = `Usage: ai task grep [--current | --task <ref> | -t <ref>] <pattern> [artifact | N]
8
7
 
9
8
  Literal (non-regex) line search across task artifacts.
10
9
  <pattern> Literal substring to match (NOT a regex). Case-sensitive by default.
11
- [ref] Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
12
- Omit to scan every task under active / blocked / completed
13
- (archive is skipped). With a ref, narrows to that single task
14
- (a TASK-id ref can also resolve an archived task).
15
- [artifact | N] Only valid with <ref>. Artifact filename (with or without '.md')
10
+ --current Limit search to the unique active task for the current branch.
11
+ -t, --task <ref> Limit search to an explicit task (bare short id or TASK-id).
12
+ [artifact | N] Artifact filename (with or without '.md')
16
13
  or the number from 'ai task files'. Narrows to a single artifact.
17
14
 
18
15
  Options:
19
16
  -i, --ignore-case Case-insensitive matching.
20
- --current Limit search to the current task context.
21
- -t, --task <ref> Limit search to an explicit task.
22
17
  -- Treat the rest as positional (use for patterns starting with '-').
23
18
 
24
19
  Output: '{taskId} [#short] {fileStem}:{line}: {matched-line}' (short id only for active tasks).
@@ -92,17 +87,9 @@ function grep(args = []) {
92
87
  continue;
93
88
  }
94
89
  if (!optsEnded && a.startsWith('--task=')) {
95
- if (taskRef !== undefined) {
96
- process.stderr.write("ai task grep: duplicate option '--task'\n");
97
- process.exitCode = 1;
98
- return;
99
- }
100
- taskRef = a.slice('--task='.length);
101
- if (taskRef === '') {
102
- process.stderr.write('ai task grep: --task requires a value\n');
103
- process.exitCode = 1;
104
- return;
105
- }
90
+ process.stderr.write('ai task grep: --task=... is not supported; use --task <ref> or -t <ref>\n');
91
+ process.exitCode = 1;
92
+ return;
106
93
  continue;
107
94
  }
108
95
  if (!optsEnded && a.startsWith('-') && a !== '-') {
@@ -122,63 +109,40 @@ function grep(args = []) {
122
109
  process.exitCode = 1;
123
110
  return;
124
111
  }
125
- if (positional.length > 3 || ((current || taskRef !== undefined) && positional.length > 2)) {
112
+ if (positional.length > 2) {
126
113
  process.stderr.write('ai task grep: too many arguments\n');
127
114
  process.exitCode = 1;
128
115
  return;
129
116
  }
130
- let [pattern, ref, artifactOrN] = positional;
131
- if (current || taskRef !== undefined) {
132
- artifactOrN = ref;
133
- ref = taskRef;
134
- }
117
+ const [pattern, artifactOrN] = positional;
135
118
  const matcher = makeMatcher(pattern, ignoreCase);
136
119
  const chunks = [];
137
120
  const emit = (line) => chunks.push(line);
138
121
  let total = 0;
139
- if (ref === undefined && !current) {
140
- // No ref: full scan across active / blocked / completed (no archive).
141
- let repoRoot;
122
+ const resolved = current || taskRef === undefined
123
+ ? resolveTaskContext()
124
+ : resolveTaskRef(taskRef);
125
+ if (!resolved.ok) {
126
+ process.stderr.write(`ai task grep: ${resolved.message}\n`);
127
+ process.exitCode = 1;
128
+ return;
129
+ }
130
+ const shortToken = loadShortIdByTaskId(resolved.repoRoot).get(resolved.taskId);
131
+ if (artifactOrN !== undefined) {
132
+ let artifactPath;
142
133
  try {
143
- repoRoot = detectRepoRoot();
134
+ artifactPath = resolveArtifact(resolved.taskDir, artifactOrN);
144
135
  }
145
136
  catch (e) {
146
137
  process.stderr.write(`ai task grep: ${e.message}\n`);
147
138
  process.exitCode = 1;
148
139
  return;
149
140
  }
150
- const shortMap = loadShortIdByTaskId(repoRoot);
151
- for (const { taskId, taskDir } of enumerateTaskDirs(repoRoot)) {
152
- const shortToken = shortMap.get(taskId);
153
- for (const a of enumerateArtifacts(taskDir)) {
154
- total += scanArtifact(taskId, shortToken, a.path, matcher, emit);
155
- }
156
- }
141
+ total += scanArtifact(resolved.taskId, shortToken, artifactPath, matcher, emit);
157
142
  }
158
143
  else {
159
- const resolved = current ? resolveTaskContext() : resolveTaskRef(ref);
160
- if (!resolved.ok) {
161
- process.stderr.write(`ai task grep: ${resolved.message}\n`);
162
- process.exitCode = 1;
163
- return;
164
- }
165
- const shortToken = loadShortIdByTaskId(resolved.repoRoot).get(resolved.taskId);
166
- if (artifactOrN !== undefined) {
167
- let artifactPath;
168
- try {
169
- artifactPath = resolveArtifact(resolved.taskDir, artifactOrN);
170
- }
171
- catch (e) {
172
- process.stderr.write(`ai task grep: ${e.message}\n`);
173
- process.exitCode = 1;
174
- return;
175
- }
176
- total += scanArtifact(resolved.taskId, shortToken, artifactPath, matcher, emit);
177
- }
178
- else {
179
- for (const a of enumerateArtifacts(resolved.taskDir)) {
180
- total += scanArtifact(resolved.taskId, shortToken, a.path, matcher, emit);
181
- }
144
+ for (const a of enumerateArtifacts(resolved.taskDir)) {
145
+ total += scanArtifact(resolved.taskId, shortToken, a.path, matcher, emit);
182
146
  }
183
147
  }
184
148
  if (total === 0) {
@@ -4,11 +4,11 @@ import { resolveTaskContext } from '../resolve-ref.js';
4
4
  import { extractTitle } from '../frontmatter.js';
5
5
  import { extractSection, findSectionHeading } from '../sections.js';
6
6
  import { renderTemplateBody, PLACEHOLDER } from '../issue-form.js';
7
- const USAGE = `Usage: ai task issue-body [<ref> | --task <ref> | -t <ref>] [--template <path>]
7
+ const USAGE = `Usage: ai task issue-body [--task <ref> | -t <ref>] [--template <path>]
8
8
 
9
9
  Print a deterministic Issue body extracted from a task's task.md.
10
- Omit <ref> Resolve the unique active task for the current branch.
11
- <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
10
+ Omit the scope Resolve the unique active task for the current branch.
11
+ --task/-t <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
12
12
  --template <path> Render the final body for the given GitHub Issue Form (scenario A);
13
13
  without it, print the default '任务输入 + 描述 + 需求' body (scenario B).
14
14
 
@@ -71,12 +71,12 @@ function issueBody(args = []) {
71
71
  process.exitCode = 1;
72
72
  return;
73
73
  }
74
- if (scope.positionals.length > 1 || (scope.explicit && scope.positionals.length > 0)) {
75
- process.stderr.write('ai task issue-body: task ref must be provided once\n');
74
+ if (scope.positionals.length > 0) {
75
+ process.stderr.write('ai task issue-body: positional task ref is not supported; use --task <ref> or -t <ref>\n');
76
76
  process.exitCode = 1;
77
77
  return;
78
78
  }
79
- const resolved = resolveTaskContext(scope.taskRef ?? scope.positionals[0]);
79
+ const resolved = resolveTaskContext(scope.taskRef);
80
80
  if (!resolved.ok) {
81
81
  process.stderr.write(`ai task issue-body: ${resolved.message}\n`);
82
82
  process.exitCode = 1;
@@ -3,15 +3,15 @@ import { classifyAgent } from '../../agent-clients/tokens.js';
3
3
  import { formatTable } from '../../table.js';
4
4
  import { parseTaskScope } from '../command-options.js';
5
5
  import { resolveTaskContext } from '../resolve-ref.js';
6
- import { isReviewStage, parseLedger } from '../ledger.js';
6
+ import { LEDGER_SECTION_MISSING_CODE, LEDGER_SECTION_MISSING_MESSAGE, isReviewStage, parseLedgerDocument } from '../ledger.js';
7
7
  import { parseActivityLog, pairEntries } from '../activity-log.js';
8
- const USAGE = `Usage: ai task log [<N | TASK-id> | --task <ref> | -t <ref>]
8
+ const USAGE = `Usage: ai task log [--task <ref> | -t <ref>]
9
9
 
10
10
  Renders a task's activity log as a per-step status table. A step's start and
11
11
  completion are paired onto one row: STARTED holds the start time, DONE the
12
12
  completion time (or '(in progress)' while still running).
13
- Omit <ref> Resolve the unique active task for the current branch.
14
- <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
13
+ Omit the scope Resolve the unique active task for the current branch.
14
+ --task/-t <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
15
15
 
16
16
  Columns: # (row) / STEP / AGENT / STARTED / DONE / NOTE
17
17
  A human-executed step shows AGENT as 'human' and, when it has no start marker,
@@ -85,8 +85,8 @@ function isHumanCountField(field) {
85
85
  return fieldNumber(field, 'manual-validation') !== undefined || fieldNumber(field, 'human-decision') !== undefined;
86
86
  }
87
87
  // A step is human-executed when its agent token is not a known AI token.
88
- // Known long names (claude-code -> claude, gemini-cli -> gemini) classify as
89
- // AI; empty or unknown tokens classify as non-AI (human).
88
+ // Known long names classify as AI; empty or unknown tokens classify as non-AI
89
+ // (human).
90
90
  export function isHumanAgent(agent) {
91
91
  return classifyAgent(agent).status !== 'ai';
92
92
  }
@@ -118,12 +118,12 @@ function log(args = []) {
118
118
  process.exitCode = 1;
119
119
  return;
120
120
  }
121
- if (scope.positionals.length > 1 || (scope.explicit && scope.positionals.length > 0)) {
122
- process.stderr.write('ai task log: task ref must be provided once\n');
121
+ if (scope.positionals.length > 0) {
122
+ process.stderr.write('ai task log: positional task ref is not supported; use --task <ref> or -t <ref>\n');
123
123
  process.exitCode = 1;
124
124
  return;
125
125
  }
126
- const resolved = resolveTaskContext(scope.taskRef ?? scope.positionals[0]);
126
+ const resolved = resolveTaskContext(scope.taskRef);
127
127
  if (!resolved.ok) {
128
128
  process.stderr.write(`ai task log: ${resolved.message}\n`);
129
129
  process.exitCode = 1;
@@ -142,7 +142,18 @@ function log(args = []) {
142
142
  return;
143
143
  }
144
144
  const steps = pairEntries(entries);
145
- const humanDecisionCounts = countHumanDecisionsByStage(parseLedger(content));
145
+ let humanDecisionCounts = new Map();
146
+ let ledgerDiagnostic = null;
147
+ try {
148
+ const ledger = parseLedgerDocument(content);
149
+ if (ledger.present)
150
+ humanDecisionCounts = countHumanDecisionsByStage(ledger.rows);
151
+ else
152
+ ledgerDiagnostic = `${LEDGER_SECTION_MISSING_CODE}: ${LEDGER_SECTION_MISSING_MESSAGE}`;
153
+ }
154
+ catch (error) {
155
+ ledgerDiagnostic = `LEDGER_DOCUMENT_INVALID: ${error instanceof Error ? error.message : String(error)}`;
156
+ }
146
157
  const rows = steps.map((s, idx) => {
147
158
  const stage = reviewStageForStep(s.step);
148
159
  const note = stage
@@ -157,6 +168,10 @@ function log(args = []) {
157
168
  for (const line of formatTable(TABLE_HEADERS, rows, { zebra: Boolean(process.stdout.isTTY) })) {
158
169
  process.stdout.write(`${line}\n`);
159
170
  }
171
+ if (ledgerDiagnostic) {
172
+ process.stdout.write(`Ledger: unavailable [${ledgerDiagnostic}]\n`);
173
+ process.exitCode = 1;
174
+ }
160
175
  process.stdout.write(`Total: ${steps.length} steps\n`);
161
176
  }
162
177
  export { log };
@@ -1,12 +1,11 @@
1
1
  import fs from 'node:fs';
2
2
  import { parseTaskScope } from '../command-options.js';
3
3
  import { resolveTaskContext } from '../resolve-ref.js';
4
- const USAGE = `Usage: ai task show [<N | TASK-id> | --task <ref> | -t <ref>]
4
+ const USAGE = `Usage: ai task show [--task <ref> | -t <ref>]
5
5
 
6
6
  Prints the task.md content for the matching task.
7
7
  Omit the ref Resolve the unique active task for the current branch.
8
- N (bare numeric) Recommended; resolves the active short id via the registry.
9
- TASK-YYYYMMDD-HHMMSS Locates a task in active / blocked / completed / archive.
8
+ --task/-t <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
10
9
  `;
11
10
  function show(args = []) {
12
11
  if (args[0] === '--help' || args[0] === '-h') {
@@ -22,12 +21,12 @@ function show(args = []) {
22
21
  process.exitCode = 1;
23
22
  return;
24
23
  }
25
- if (scope.positionals.length > 1 || (scope.explicit && scope.positionals.length > 0)) {
26
- process.stderr.write('ai task show: task ref must be provided once\n');
24
+ if (scope.positionals.length > 0) {
25
+ process.stderr.write('ai task show: positional task ref is not supported; use --task <ref> or -t <ref>\n');
27
26
  process.exitCode = 1;
28
27
  return;
29
28
  }
30
- const resolved = resolveTaskContext(scope.taskRef ?? scope.positionals[0]);
29
+ const resolved = resolveTaskContext(scope.taskRef);
31
30
  if (!resolved.ok) {
32
31
  process.stderr.write(`ai task show: ${resolved.message}\n`);
33
32
  process.exitCode = 1;
@@ -8,15 +8,15 @@ import { enumerateArtifacts } from '../artifacts.js';
8
8
  import { parseTaskFrontmatter, extractTitle } from '../frontmatter.js';
9
9
  import { loadShortIdByTaskId } from '../short-id.js';
10
10
  import { getOpenWorkflowWarnings, formatWorkflowWarningSummary } from '../workflow-warnings.js';
11
- import { parseActivityLog, pairEntries } from '../activity-log.js';
11
+ import { parseActivityLog, pairEntries, startedBackedRows } from '../activity-log.js';
12
12
  import { readRun } from '../orchestration.js';
13
13
  import { statusCard } from '../../server/display.js';
14
- const USAGE = `Usage: ai task status [<N | TASK-id> | --task <ref> | -t <ref>]
14
+ const USAGE = `Usage: ai task status [--task <ref> | -t <ref>]
15
15
 
16
16
  Prints an aggregated "health check" view for a task: header, metadata,
17
17
  artifacts, workflow/runtime execution state, and git branch state.
18
- Omit <ref> Resolve the unique active task for the current branch.
19
- <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
18
+ Omit the scope Resolve the unique active task for the current branch.
19
+ --task/-t <ref> Bare numeric short id, or a full TASK-YYYYMMDD-HHMMSS id.
20
20
 
21
21
  Git rows are best-effort: a failed git call degrades that row to '-' without
22
22
  failing the command.
@@ -155,7 +155,7 @@ function collectWorkflow(content, now = new Date()) {
155
155
  if (!parsed.sectionFound || parsed.entries.length === 0) {
156
156
  return { state: 'unknown', step: DASH, agent: DASH, startedAt: DASH, doneAt: DASH, stale: DASH };
157
157
  }
158
- const rows = pairEntries(parsed.entries);
158
+ const rows = startedBackedRows(pairEntries(parsed.entries));
159
159
  const latest = rows.at(-1);
160
160
  if (!latest) {
161
161
  return { state: 'unknown', step: DASH, agent: DASH, startedAt: DASH, doneAt: DASH, stale: DASH };
@@ -431,10 +431,10 @@ function status(args = []) {
431
431
  let model;
432
432
  try {
433
433
  const scope = parseTaskScope(args);
434
- if (scope.positionals.length > 1 || (scope.explicit && scope.positionals.length > 0)) {
435
- throw new Error('task ref must be provided once');
434
+ if (scope.positionals.length > 0) {
435
+ throw new Error('positional task ref is not supported; use --task <ref> or -t <ref>');
436
436
  }
437
- const resolved = resolveTaskContext(scope.taskRef ?? scope.positionals[0]);
437
+ const resolved = resolveTaskContext(scope.taskRef);
438
438
  if (!resolved.ok)
439
439
  throw new Error(resolved.message);
440
440
  model = buildFromResolved({