agentplane 0.3.14 → 0.3.16

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 (425) hide show
  1. package/assets/policy/incidents.md +7 -0
  2. package/bin/agentplane.js +1 -1
  3. package/bin/framework-dev-contract.js +1 -0
  4. package/dist/.build-manifest.json +508 -323
  5. package/dist/backends/task-backend/load.d.ts.map +1 -1
  6. package/dist/backends/task-backend/load.js +32 -19
  7. package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -1
  8. package/dist/backends/task-backend/local-backend-doc.js +1 -1
  9. package/dist/backends/task-backend/redmine/backend-runtime.d.ts +147 -0
  10. package/dist/backends/task-backend/redmine/backend-runtime.d.ts.map +1 -0
  11. package/dist/backends/task-backend/redmine/backend-runtime.js +258 -0
  12. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts +44 -0
  13. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts.map +1 -0
  14. package/dist/backends/task-backend/redmine/backend-sync/context.js +8 -0
  15. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts +6 -0
  16. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts.map +1 -0
  17. package/dist/backends/task-backend/redmine/backend-sync/ids.js +21 -0
  18. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts +4 -0
  19. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts.map +1 -0
  20. package/dist/backends/task-backend/redmine/backend-sync/migration.js +87 -0
  21. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts +10 -0
  22. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts.map +1 -0
  23. package/dist/backends/task-backend/redmine/backend-sync/status.js +78 -0
  24. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts +12 -0
  25. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts.map +1 -0
  26. package/dist/backends/task-backend/redmine/backend-sync/sync.js +82 -0
  27. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts +5 -0
  28. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts.map +1 -0
  29. package/dist/backends/task-backend/redmine/backend-sync/write.js +100 -0
  30. package/dist/backends/task-backend/redmine/backend-sync.d.ts +6 -66
  31. package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -1
  32. package/dist/backends/task-backend/redmine/backend-sync.js +5 -367
  33. package/dist/backends/task-backend/redmine-backend.d.ts +2 -33
  34. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  35. package/dist/backends/task-backend/redmine-backend.js +26 -241
  36. package/dist/backends/task-backend/shared/errors.d.ts +12 -0
  37. package/dist/backends/task-backend/shared/errors.d.ts.map +1 -1
  38. package/dist/backends/task-backend/shared/errors.js +12 -0
  39. package/dist/cli/archive.d.ts.map +1 -1
  40. package/dist/cli/archive.js +3 -5
  41. package/dist/cli/error-map.d.ts +7 -1
  42. package/dist/cli/error-map.d.ts.map +1 -1
  43. package/dist/cli/error-map.js +231 -19
  44. package/dist/cli/exit-codes.d.ts +14 -2
  45. package/dist/cli/exit-codes.d.ts.map +1 -1
  46. package/dist/cli/exit-codes.js +24 -11
  47. package/dist/cli/output.d.ts +3 -0
  48. package/dist/cli/output.d.ts.map +1 -1
  49. package/dist/cli/output.js +25 -14
  50. package/dist/cli/prompts.d.ts.map +1 -1
  51. package/dist/cli/prompts.js +44 -0
  52. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  53. package/dist/cli/run-cli/command-catalog/core.js +34 -76
  54. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  55. package/dist/cli/run-cli/command-catalog/lifecycle.js +23 -26
  56. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  57. package/dist/cli/run-cli/command-catalog/project.js +39 -54
  58. package/dist/cli/run-cli/command-catalog/shared.d.ts +15 -3
  59. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  60. package/dist/cli/run-cli/command-catalog/shared.js +19 -6
  61. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  62. package/dist/cli/run-cli/command-catalog/task.js +63 -57
  63. package/dist/cli/run-cli/command-loaders.d.ts +174 -0
  64. package/dist/cli/run-cli/command-loaders.d.ts.map +1 -0
  65. package/dist/cli/run-cli/command-loaders.js +128 -0
  66. package/dist/cli/run-cli/commands/init/model.d.ts +42 -0
  67. package/dist/cli/run-cli/commands/init/model.d.ts.map +1 -0
  68. package/dist/cli/run-cli/commands/init/orchestrate.d.ts +9 -0
  69. package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -0
  70. package/dist/cli/run-cli/commands/init/orchestrate.js +321 -0
  71. package/dist/cli/run-cli/commands/init/parsers.d.ts +5 -0
  72. package/dist/cli/run-cli/commands/init/parsers.d.ts.map +1 -0
  73. package/dist/cli/run-cli/commands/init/parsers.js +36 -0
  74. package/dist/cli/run-cli/commands/init/presets.d.ts +15 -0
  75. package/dist/cli/run-cli/commands/init/presets.d.ts.map +1 -0
  76. package/dist/cli/run-cli/commands/init/presets.js +63 -0
  77. package/dist/cli/run-cli/commands/init/spec.d.ts +5 -0
  78. package/dist/cli/run-cli/commands/init/spec.d.ts.map +1 -0
  79. package/dist/cli/run-cli/commands/init/spec.js +212 -0
  80. package/dist/cli/run-cli/commands/init/write-config.d.ts +1 -0
  81. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  82. package/dist/cli/run-cli/commands/init/write-config.js +1 -0
  83. package/dist/cli/run-cli/commands/init/write-gitignore.js +1 -1
  84. package/dist/cli/run-cli/commands/init.d.ts +1 -28
  85. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  86. package/dist/cli/run-cli/commands/init.js +1 -596
  87. package/dist/cli/run-cli/update-warning.d.ts +1 -0
  88. package/dist/cli/run-cli/update-warning.d.ts.map +1 -1
  89. package/dist/cli/run-cli/update-warning.js +10 -2
  90. package/dist/cli/run-cli.d.ts.map +1 -1
  91. package/dist/cli/run-cli.js +1 -2
  92. package/dist/cli/spec/errors.d.ts +13 -1
  93. package/dist/cli/spec/errors.d.ts.map +1 -1
  94. package/dist/cli/spec/errors.js +14 -4
  95. package/dist/commands/backend.d.ts.map +1 -1
  96. package/dist/commands/backend.js +66 -118
  97. package/dist/commands/block.spec.js +1 -1
  98. package/dist/commands/branch/work-start.js +1 -1
  99. package/dist/commands/commit.spec.js +1 -1
  100. package/dist/commands/doctor/branch-pr.js +1 -1
  101. package/dist/commands/doctor/fixes.js +1 -1
  102. package/dist/commands/doctor/runtime.d.ts.map +1 -1
  103. package/dist/commands/doctor/runtime.js +2 -2
  104. package/dist/commands/doctor/workspace.js +1 -1
  105. package/dist/commands/finish.spec.js +1 -1
  106. package/dist/commands/guard/commit.command.js +1 -1
  107. package/dist/commands/guard/impl/clean.d.ts +6 -0
  108. package/dist/commands/guard/impl/clean.d.ts.map +1 -0
  109. package/dist/commands/guard/impl/clean.js +29 -0
  110. package/dist/commands/guard/impl/close-dirt.d.ts +6 -0
  111. package/dist/commands/guard/impl/close-dirt.d.ts.map +1 -0
  112. package/dist/commands/guard/impl/close-dirt.js +56 -0
  113. package/dist/commands/guard/impl/commands.d.ts +4 -36
  114. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  115. package/dist/commands/guard/impl/commands.js +4 -549
  116. package/dist/commands/guard/impl/comment-commit.js +1 -1
  117. package/dist/commands/guard/impl/commit-diagnostics.d.ts +4 -0
  118. package/dist/commands/guard/impl/commit-diagnostics.d.ts.map +1 -0
  119. package/dist/commands/guard/impl/commit-diagnostics.js +150 -0
  120. package/dist/commands/guard/impl/commit.d.ts +25 -0
  121. package/dist/commands/guard/impl/commit.d.ts.map +1 -0
  122. package/dist/commands/guard/impl/commit.js +366 -0
  123. package/dist/commands/guard/impl/guard-commit.d.ts +3 -0
  124. package/dist/commands/guard/impl/guard-commit.d.ts.map +1 -0
  125. package/dist/commands/guard/impl/guard-commit.js +21 -0
  126. package/dist/commands/guard/impl/policy.d.ts +1 -0
  127. package/dist/commands/guard/impl/policy.d.ts.map +1 -1
  128. package/dist/commands/guard/impl/policy.js +9 -2
  129. package/dist/commands/guard/impl/suggest.d.ts +6 -0
  130. package/dist/commands/guard/impl/suggest.d.ts.map +1 -0
  131. package/dist/commands/guard/impl/suggest.js +33 -0
  132. package/dist/commands/hooks/index.d.ts +3 -0
  133. package/dist/commands/hooks/index.d.ts.map +1 -1
  134. package/dist/commands/hooks/index.js +27 -10
  135. package/dist/commands/pr/integrate/cmd.js +1 -1
  136. package/dist/commands/pr/integrate/internal/prepare.js +1 -1
  137. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  138. package/dist/commands/pr/internal/auto-commit.js +2 -5
  139. package/dist/commands/pr/internal/gh-api.d.ts.map +1 -1
  140. package/dist/commands/pr/internal/gh-api.js +15 -8
  141. package/dist/commands/pr/internal/sync-branch.d.ts +0 -1
  142. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -1
  143. package/dist/commands/pr/internal/sync-branch.js +2 -5
  144. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  145. package/dist/commands/pr/internal/sync.js +30 -0
  146. package/dist/commands/pr/open.d.ts.map +1 -1
  147. package/dist/commands/pr/open.js +98 -8
  148. package/dist/commands/recipes/impl/resolver.js +1 -1
  149. package/dist/commands/recipes/impl/version.js +1 -1
  150. package/dist/commands/release/apply.command.js +1 -1
  151. package/dist/commands/release/apply.mutation.d.ts +1 -0
  152. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  153. package/dist/commands/release/apply.mutation.js +5 -1
  154. package/dist/commands/release/apply.pipeline/finalize.d.ts +21 -0
  155. package/dist/commands/release/apply.pipeline/finalize.d.ts.map +1 -0
  156. package/dist/commands/release/apply.pipeline/finalize.js +80 -0
  157. package/dist/commands/release/apply.pipeline/mutation.d.ts +18 -0
  158. package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -0
  159. package/dist/commands/release/apply.pipeline/mutation.js +78 -0
  160. package/dist/commands/release/apply.pipeline/preflight.d.ts +25 -0
  161. package/dist/commands/release/apply.pipeline/preflight.d.ts.map +1 -0
  162. package/dist/commands/release/apply.pipeline/preflight.js +69 -0
  163. package/dist/commands/release/apply.pipeline/shared.d.ts +2 -0
  164. package/dist/commands/release/apply.pipeline/shared.d.ts.map +1 -0
  165. package/dist/commands/release/apply.pipeline/shared.js +5 -0
  166. package/dist/commands/release/apply.pipeline/state.d.ts +25 -0
  167. package/dist/commands/release/apply.pipeline/state.d.ts.map +1 -0
  168. package/dist/commands/release/apply.pipeline/state.js +129 -0
  169. package/dist/commands/release/apply.pipeline.d.ts +1 -1
  170. package/dist/commands/release/apply.pipeline.d.ts.map +1 -1
  171. package/dist/commands/release/apply.pipeline.js +4 -347
  172. package/dist/commands/release/apply.preflight.d.ts +9 -6
  173. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  174. package/dist/commands/release/apply.preflight.js +71 -51
  175. package/dist/commands/runtime.command.d.ts +2 -2
  176. package/dist/commands/runtime.command.d.ts.map +1 -1
  177. package/dist/commands/runtime.command.js +2 -2
  178. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  179. package/dist/commands/scenario/impl/commands.js +52 -39
  180. package/dist/commands/scenario/impl/report.d.ts.map +1 -1
  181. package/dist/commands/scenario/impl/report.js +4 -7
  182. package/dist/commands/shared/allow-prefix-policy.d.ts.map +1 -0
  183. package/dist/{shared → commands/shared}/allow-prefix-policy.js +1 -1
  184. package/dist/commands/shared/comment-format.d.ts.map +1 -0
  185. package/dist/commands/shared/diagnostics.d.ts.map +1 -0
  186. package/dist/commands/shared/git-context.d.ts +1 -27
  187. package/dist/commands/shared/git-context.d.ts.map +1 -1
  188. package/dist/commands/shared/git-context.js +1 -156
  189. package/dist/commands/shared/git-diff.d.ts +1 -10
  190. package/dist/commands/shared/git-diff.d.ts.map +1 -1
  191. package/dist/commands/shared/git-diff.js +1 -49
  192. package/dist/commands/shared/git-ops.d.ts +1 -14
  193. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  194. package/dist/commands/shared/git-ops.js +20 -150
  195. package/dist/commands/shared/git-worktree.d.ts +1 -9
  196. package/dist/commands/shared/git-worktree.d.ts.map +1 -1
  197. package/dist/commands/shared/git-worktree.js +1 -68
  198. package/dist/commands/shared/git.d.ts +1 -3
  199. package/dist/commands/shared/git.d.ts.map +1 -1
  200. package/dist/commands/shared/git.js +1 -14
  201. package/dist/commands/shared/policy-deny.d.ts +1 -1
  202. package/dist/commands/shared/reconcile-check.js +1 -1
  203. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  204. package/dist/commands/shared/task-backend.js +24 -2
  205. package/dist/commands/shared/task-store/intents.d.ts.map +1 -1
  206. package/dist/commands/shared/task-store/intents.js +1 -1
  207. package/dist/commands/start.spec.js +1 -1
  208. package/dist/commands/task/close-tail-state.d.ts +7 -0
  209. package/dist/commands/task/close-tail-state.d.ts.map +1 -0
  210. package/dist/commands/task/close-tail-state.js +18 -0
  211. package/dist/commands/task/derive.js +1 -1
  212. package/dist/commands/task/finish-close.d.ts +22 -0
  213. package/dist/commands/task/finish-close.d.ts.map +1 -0
  214. package/dist/commands/task/finish-close.js +119 -0
  215. package/dist/commands/task/finish-command.d.ts +3 -0
  216. package/dist/commands/task/finish-command.d.ts.map +1 -0
  217. package/dist/commands/task/finish-command.js +56 -0
  218. package/dist/commands/task/finish-execute.d.ts +8 -0
  219. package/dist/commands/task/finish-execute.d.ts.map +1 -0
  220. package/dist/commands/task/finish-execute.js +272 -0
  221. package/dist/commands/task/finish-findings.d.ts +20 -0
  222. package/dist/commands/task/finish-findings.d.ts.map +1 -0
  223. package/dist/commands/task/finish-findings.js +27 -0
  224. package/dist/commands/task/finish-plan.d.ts +7 -0
  225. package/dist/commands/task/finish-plan.d.ts.map +1 -0
  226. package/dist/commands/task/finish-plan.js +157 -0
  227. package/dist/commands/task/finish-types.d.ts +69 -0
  228. package/dist/commands/task/finish-types.d.ts.map +1 -0
  229. package/dist/commands/task/finish.d.ts +1 -42
  230. package/dist/commands/task/finish.d.ts.map +1 -1
  231. package/dist/commands/task/finish.js +1 -527
  232. package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -1
  233. package/dist/commands/task/hosted-close-pr.command.js +29 -4
  234. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  235. package/dist/commands/task/hosted-close.command.js +23 -2
  236. package/dist/commands/task/hosted-merge-sync/builders.d.ts +35 -0
  237. package/dist/commands/task/hosted-merge-sync/builders.d.ts.map +1 -0
  238. package/dist/commands/task/hosted-merge-sync/builders.js +148 -0
  239. package/dist/commands/task/hosted-merge-sync/github.d.ts +10 -0
  240. package/dist/commands/task/hosted-merge-sync/github.d.ts.map +1 -0
  241. package/dist/commands/task/hosted-merge-sync/github.js +113 -0
  242. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts +12 -0
  243. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts.map +1 -0
  244. package/dist/commands/task/hosted-merge-sync/local-branch.js +143 -0
  245. package/dist/commands/task/hosted-merge-sync/model.d.ts +47 -0
  246. package/dist/commands/task/hosted-merge-sync/model.d.ts.map +1 -0
  247. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts +12 -0
  248. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts.map +1 -0
  249. package/dist/commands/task/hosted-merge-sync/pr-meta.js +26 -0
  250. package/dist/commands/task/hosted-merge-sync.d.ts +5 -63
  251. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  252. package/dist/commands/task/hosted-merge-sync.js +10 -444
  253. package/dist/commands/task/new.js +1 -1
  254. package/dist/commands/task/set-status.command.js +1 -1
  255. package/dist/commands/task/shared/direct-work-lock.d.ts.map +1 -0
  256. package/dist/commands/task/shared/git-log.d.ts.map +1 -0
  257. package/dist/commands/task/shared/transitions.d.ts +1 -1
  258. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  259. package/dist/commands/task/shared/transitions.js +4 -6
  260. package/dist/commands/upgrade/apply.js +1 -1
  261. package/dist/commands/workflow-playbook.command.d.ts.map +1 -1
  262. package/dist/commands/workflow-playbook.command.js +8 -7
  263. package/dist/harness/hooks-lifecycle.d.ts.map +1 -1
  264. package/dist/harness/hooks-lifecycle.js +11 -7
  265. package/dist/meta/release.d.ts.map +1 -1
  266. package/dist/meta/release.js +8 -4
  267. package/dist/policy/engine.d.ts +1 -1
  268. package/dist/policy/evaluate.d.ts +1 -1
  269. package/dist/policy/{types.d.ts → model.d.ts} +1 -1
  270. package/dist/policy/{types.d.ts.map → model.d.ts.map} +1 -1
  271. package/dist/policy/result.d.ts +1 -1
  272. package/dist/policy/rules/allowlist.d.ts +1 -1
  273. package/dist/policy/rules/branch-pr-base.d.ts +1 -1
  274. package/dist/policy/rules/clean-tree.d.ts +1 -1
  275. package/dist/policy/rules/commit-subject.d.ts +1 -1
  276. package/dist/policy/rules/protected-paths.d.ts +1 -1
  277. package/dist/runner/adapters/base.d.ts +42 -0
  278. package/dist/runner/adapters/base.d.ts.map +1 -0
  279. package/dist/runner/adapters/base.js +107 -0
  280. package/dist/runner/adapters/codex-preparation.d.ts +7 -0
  281. package/dist/runner/adapters/codex-preparation.d.ts.map +1 -0
  282. package/dist/runner/adapters/codex-preparation.js +86 -0
  283. package/dist/runner/adapters/codex.d.ts.map +1 -1
  284. package/dist/runner/adapters/codex.js +30 -175
  285. package/dist/runner/adapters/custom-preparation.d.ts +9 -0
  286. package/dist/runner/adapters/custom-preparation.d.ts.map +1 -0
  287. package/dist/runner/adapters/custom-preparation.js +191 -0
  288. package/dist/runner/adapters/custom.d.ts.map +1 -1
  289. package/dist/runner/adapters/custom.js +26 -279
  290. package/dist/runner/process-supervision/run.d.ts +30 -0
  291. package/dist/runner/process-supervision/run.d.ts.map +1 -0
  292. package/dist/runner/process-supervision/run.js +349 -0
  293. package/dist/runner/process-supervision/signals.d.ts +16 -0
  294. package/dist/runner/process-supervision/signals.d.ts.map +1 -0
  295. package/dist/runner/process-supervision/signals.js +85 -0
  296. package/dist/runner/process-supervision/state.d.ts +10 -0
  297. package/dist/runner/process-supervision/state.d.ts.map +1 -0
  298. package/dist/runner/process-supervision/state.js +42 -0
  299. package/dist/runner/process-supervision/streams.d.ts +6 -0
  300. package/dist/runner/process-supervision/streams.d.ts.map +1 -0
  301. package/dist/runner/process-supervision/streams.js +23 -0
  302. package/dist/runner/process-supervision.d.ts +5 -47
  303. package/dist/runner/process-supervision.d.ts.map +1 -1
  304. package/dist/runner/process-supervision.js +3 -490
  305. package/dist/runner/usecases/scenario-materialize-task.js +1 -1
  306. package/dist/runtime/approvals/index.d.ts +1 -1
  307. package/dist/runtime/approvals/{types.d.ts → model.d.ts} +1 -1
  308. package/dist/runtime/approvals/{types.d.ts.map → model.d.ts.map} +1 -1
  309. package/dist/runtime/approvals/runtime.d.ts +1 -1
  310. package/dist/runtime/behavior/index.d.ts +1 -1
  311. package/dist/runtime/behavior/{types.d.ts → model.d.ts} +1 -1
  312. package/dist/runtime/behavior/{types.d.ts.map → model.d.ts.map} +1 -1
  313. package/dist/runtime/behavior/resolve.d.ts +1 -1
  314. package/dist/runtime/capabilities/backend.d.ts +1 -1
  315. package/dist/runtime/capabilities/index.d.ts +1 -1
  316. package/dist/runtime/capabilities/{types.d.ts → model.d.ts} +1 -1
  317. package/dist/runtime/capabilities/{types.d.ts.map → model.d.ts.map} +1 -1
  318. package/dist/runtime/capabilities/model.js +1 -0
  319. package/dist/runtime/capabilities/recipe.d.ts +1 -1
  320. package/dist/runtime/capabilities/registry.d.ts +1 -1
  321. package/dist/runtime/capabilities/runner.d.ts +1 -1
  322. package/dist/runtime/execution-context.d.ts.map +1 -1
  323. package/dist/runtime/execution-context.js +16 -0
  324. package/dist/runtime/execution-profile/index.d.ts +1 -1
  325. package/dist/runtime/execution-profile/{types.d.ts → model.d.ts} +1 -1
  326. package/dist/runtime/execution-profile/{types.d.ts.map → model.d.ts.map} +1 -1
  327. package/dist/runtime/execution-profile/model.js +1 -0
  328. package/dist/runtime/execution-profile/resolve.d.ts +1 -1
  329. package/dist/runtime/explain/index.d.ts +1 -1
  330. package/dist/runtime/explain/{types.d.ts → model.d.ts} +1 -1
  331. package/dist/runtime/explain/{types.d.ts.map → model.d.ts.map} +1 -1
  332. package/dist/runtime/explain/model.js +1 -0
  333. package/dist/runtime/explain/resolve.d.ts +1 -1
  334. package/dist/runtime/protocol/index.d.ts +1 -1
  335. package/dist/runtime/protocol/index.js +1 -1
  336. package/dist/runtime/protocol/{types.d.ts → model.d.ts} +1 -1
  337. package/dist/runtime/protocol/{types.d.ts.map → model.d.ts.map} +1 -1
  338. package/dist/runtime/protocol/resolve.d.ts +1 -1
  339. package/dist/runtime/protocol/resolve.js +1 -1
  340. package/dist/runtime/shared/repo-cli-version.d.ts.map +1 -0
  341. package/dist/{shared → runtime/shared}/repo-cli-version.js +1 -1
  342. package/dist/runtime/shared/runtime-artifacts.d.ts.map +1 -0
  343. package/dist/{shared → runtime/shared}/runtime-source.d.ts +1 -1
  344. package/dist/runtime/shared/runtime-source.d.ts.map +1 -0
  345. package/dist/{shared → runtime/shared}/runtime-source.js +1 -1
  346. package/dist/runtime/shared/version-compare.d.ts.map +1 -0
  347. package/dist/runtime/task-intake/resolve.js +1 -1
  348. package/dist/shared/errors.d.ts +52 -2
  349. package/dist/shared/errors.d.ts.map +1 -1
  350. package/dist/shared/errors.js +66 -4
  351. package/dist/shared/trace-events.d.ts +13 -0
  352. package/dist/shared/trace-events.d.ts.map +1 -0
  353. package/dist/shared/trace-events.js +17 -0
  354. package/dist/{shared/task-doc-conflicts.d.ts → task-doc/conflicts.d.ts} +1 -1
  355. package/dist/task-doc/conflicts.d.ts.map +1 -0
  356. package/dist/{shared/task-doc-conflicts.js → task-doc/conflicts.js} +1 -1
  357. package/dist/{shared/task-doc-state.d.ts → task-doc/state.d.ts} +1 -1
  358. package/dist/task-doc/state.d.ts.map +1 -0
  359. package/package.json +8 -8
  360. package/dist/cli/run-cli/error-guidance.d.ts +0 -9
  361. package/dist/cli/run-cli/error-guidance.d.ts.map +0 -1
  362. package/dist/cli/run-cli/error-guidance.js +0 -210
  363. package/dist/cli/run-cli.test-helpers.d.ts +0 -2
  364. package/dist/cli/run-cli.test-helpers.d.ts.map +0 -1
  365. package/dist/cli/run-cli.test-helpers.js +0 -1
  366. package/dist/commands/recipes.test-helpers.d.ts +0 -202
  367. package/dist/commands/recipes.test-helpers.d.ts.map +0 -1
  368. package/dist/commands/recipes.test-helpers.js +0 -483
  369. package/dist/commands/release.test-helpers.d.ts +0 -38
  370. package/dist/commands/release.test-helpers.d.ts.map +0 -1
  371. package/dist/commands/release.test-helpers.js +0 -55
  372. package/dist/commands/task.test-helpers.d.ts +0 -13
  373. package/dist/commands/task.test-helpers.d.ts.map +0 -1
  374. package/dist/commands/task.test-helpers.js +0 -65
  375. package/dist/runner/test-helpers.d.ts +0 -30
  376. package/dist/runner/test-helpers.d.ts.map +0 -1
  377. package/dist/runner/test-helpers.js +0 -97
  378. package/dist/shared/agent-emoji.d.ts +0 -5
  379. package/dist/shared/agent-emoji.d.ts.map +0 -1
  380. package/dist/shared/agent-emoji.js +0 -51
  381. package/dist/shared/allow-prefix-policy.d.ts.map +0 -1
  382. package/dist/shared/comment-format.d.ts.map +0 -1
  383. package/dist/shared/diagnostics.d.ts.map +0 -1
  384. package/dist/shared/direct-work-lock.d.ts.map +0 -1
  385. package/dist/shared/git-log.d.ts.map +0 -1
  386. package/dist/shared/repo-cli-version.d.ts.map +0 -1
  387. package/dist/shared/runtime-artifacts.d.ts.map +0 -1
  388. package/dist/shared/runtime-source.d.ts.map +0 -1
  389. package/dist/shared/task-doc-conflicts.d.ts.map +0 -1
  390. package/dist/shared/task-doc-state.d.ts.map +0 -1
  391. package/dist/shared/version-compare.d.ts.map +0 -1
  392. package/dist/testing/cli-harness/recipe-archives.d.ts +0 -28
  393. package/dist/testing/cli-harness/recipe-archives.d.ts.map +0 -1
  394. package/dist/testing/cli-harness/recipe-archives.js +0 -374
  395. package/dist/testing/cli-harness/stdio.d.ts +0 -26
  396. package/dist/testing/cli-harness/stdio.d.ts.map +0 -1
  397. package/dist/testing/cli-harness/stdio.js +0 -84
  398. package/dist/testing/cli-harness.d.ts +0 -25
  399. package/dist/testing/cli-harness.d.ts.map +0 -1
  400. package/dist/testing/cli-harness.js +0 -313
  401. package/dist/testing/index.d.ts +0 -2
  402. package/dist/testing/index.d.ts.map +0 -1
  403. package/dist/testing/index.js +0 -1
  404. /package/dist/{policy/types.js → cli/run-cli/commands/init/model.js} +0 -0
  405. /package/dist/{shared → commands/shared}/allow-prefix-policy.d.ts +0 -0
  406. /package/dist/{shared → commands/shared}/comment-format.d.ts +0 -0
  407. /package/dist/{shared → commands/shared}/comment-format.js +0 -0
  408. /package/dist/{shared → commands/shared}/diagnostics.d.ts +0 -0
  409. /package/dist/{shared → commands/shared}/diagnostics.js +0 -0
  410. /package/dist/{runtime/approvals/types.js → commands/task/finish-types.js} +0 -0
  411. /package/dist/{runtime/behavior/types.js → commands/task/hosted-merge-sync/model.js} +0 -0
  412. /package/dist/{shared → commands/task/shared}/direct-work-lock.d.ts +0 -0
  413. /package/dist/{shared → commands/task/shared}/direct-work-lock.js +0 -0
  414. /package/dist/{shared → commands/task/shared}/git-log.d.ts +0 -0
  415. /package/dist/{shared → commands/task/shared}/git-log.js +0 -0
  416. /package/dist/{runtime/capabilities/types.js → policy/model.js} +0 -0
  417. /package/dist/runtime/{execution-profile/types.js → approvals/model.js} +0 -0
  418. /package/dist/runtime/{explain/types.js → behavior/model.js} +0 -0
  419. /package/dist/runtime/protocol/{types.js → model.js} +0 -0
  420. /package/dist/{shared → runtime/shared}/repo-cli-version.d.ts +0 -0
  421. /package/dist/{shared → runtime/shared}/runtime-artifacts.d.ts +0 -0
  422. /package/dist/{shared → runtime/shared}/runtime-artifacts.js +0 -0
  423. /package/dist/{shared → runtime/shared}/version-compare.d.ts +0 -0
  424. /package/dist/{shared → runtime/shared}/version-compare.js +0 -0
  425. /package/dist/{shared/task-doc-state.js → task-doc/state.js} +0 -0
@@ -0,0 +1,150 @@
1
+ import { stripAnsi } from "../../../cli/shared/ansi.js";
2
+ import { withDiagnosticContext } from "../../shared/diagnostics.js";
3
+ import { CliError } from "../../../shared/errors.js";
4
+ const COMMIT_FAILURE_SIGNAL_PATTERNS = [
5
+ /Code style issues found/i,
6
+ /Run Prettier with --write/i,
7
+ /\bESLint\b/i,
8
+ /\b[0-9]+\s+problems?\b/i,
9
+ /\berror\b/i,
10
+ /\bfailed\b/i,
11
+ /✖/,
12
+ ];
13
+ const FORMATTER_SIGNAL_PATTERNS = [
14
+ /Code style issues found/i,
15
+ /Run Prettier with --write/i,
16
+ ];
17
+ const ESLINT_SIGNAL_PATTERNS = [/\bESLint\b/i, /\b[0-9]+\s+problems?\b/i];
18
+ function readText(value) {
19
+ if (typeof value === "string")
20
+ return value;
21
+ if (Buffer.isBuffer(value))
22
+ return value.toString("utf8");
23
+ return "";
24
+ }
25
+ function summarizeOutput(raw) {
26
+ const lines = raw
27
+ .replaceAll("\r\n", "\n")
28
+ .split("\n")
29
+ .map((line) => stripAnsi(line).trimEnd())
30
+ .filter((line) => line.trim().length > 0)
31
+ .map((line) => (line.length > 180 ? `${line.slice(0, 180)} [truncated]` : line));
32
+ if (lines.length <= 12)
33
+ return lines;
34
+ const selected = new Set();
35
+ for (let index = 0; index < Math.min(6, lines.length); index += 1)
36
+ selected.add(index);
37
+ for (let index = Math.max(lines.length - 6, 0); index < lines.length; index += 1) {
38
+ selected.add(index);
39
+ }
40
+ for (const [index, line] of lines.entries()) {
41
+ if (!selected.has(index) &&
42
+ COMMIT_FAILURE_SIGNAL_PATTERNS.some((pattern) => pattern.test(line))) {
43
+ selected.add(index);
44
+ }
45
+ }
46
+ const summary = [];
47
+ let previous = -1;
48
+ for (const index of [...selected].toSorted((a, b) => a - b)) {
49
+ if (previous >= 0 && index - previous > 1) {
50
+ summary.push(`[${index - previous - 1} lines omitted]`);
51
+ }
52
+ summary.push(lines[index] ?? "");
53
+ previous = index;
54
+ }
55
+ return summary;
56
+ }
57
+ function detectCommitFailureSignal(output) {
58
+ if (FORMATTER_SIGNAL_PATTERNS.some((pattern) => pattern.test(output)))
59
+ return "formatter";
60
+ if (ESLINT_SIGNAL_PATTERNS.some((pattern) => pattern.test(output)))
61
+ return "eslint";
62
+ return null;
63
+ }
64
+ function commitFailureDiagnostic(phase, output) {
65
+ const signal = detectCommitFailureSignal(output);
66
+ if (signal === "formatter") {
67
+ return {
68
+ state: phase === "close_commit"
69
+ ? "git rejected the generated close commit"
70
+ : "git rejected the requested task-scoped commit",
71
+ likelyCause: phase === "close_commit"
72
+ ? "a formatting check in the pre-commit path rejected the deterministic close commit after the task README was staged"
73
+ : "a formatting check in the pre-commit path rejected the staged task-scoped commit",
74
+ nextAction: {
75
+ command: "bun run format",
76
+ reason: "apply formatter fixes before retrying the commit flow",
77
+ reasonCode: "git_pre_commit_format",
78
+ },
79
+ };
80
+ }
81
+ if (signal === "eslint") {
82
+ return {
83
+ state: phase === "close_commit"
84
+ ? "git rejected the generated close commit"
85
+ : "git rejected the requested task-scoped commit",
86
+ likelyCause: phase === "close_commit"
87
+ ? "a lint check in the pre-commit path rejected the deterministic close commit after the task README was staged"
88
+ : "a lint check in the pre-commit path rejected the staged task-scoped commit",
89
+ nextAction: {
90
+ command: "bun run lint:core",
91
+ reason: "rerun lint and fix the reported error before retrying the commit flow",
92
+ reasonCode: "git_pre_commit_lint",
93
+ },
94
+ };
95
+ }
96
+ if (phase === "close_commit") {
97
+ return {
98
+ state: "git rejected the generated close commit",
99
+ likelyCause: "a hook or commit policy blocked the deterministic task close commit after the task README was staged",
100
+ nextAction: {
101
+ command: "git status --short --untracked-files=no",
102
+ reason: "inspect the staged close-commit payload before fixing the hook or policy failure",
103
+ reasonCode: "git_close_commit_blocked",
104
+ },
105
+ };
106
+ }
107
+ return {
108
+ state: "git rejected the requested task-scoped commit",
109
+ likelyCause: "a hook or commit policy blocked the staged changes after guard validation passed",
110
+ nextAction: {
111
+ command: "git status --short --untracked-files=no",
112
+ reason: "inspect the staged task-scoped payload before fixing the hook or policy failure",
113
+ reasonCode: "git_task_commit_blocked",
114
+ },
115
+ };
116
+ }
117
+ export function asCommitFailure(err, phase) {
118
+ if (!(err instanceof Error))
119
+ return null;
120
+ const e = err;
121
+ const shortMessage = typeof e.shortMessage === "string" ? e.shortMessage : "";
122
+ const message = typeof e.message === "string" ? e.message : "";
123
+ const extractedCommand = typeof e.cmd === "string"
124
+ ? e.cmd
125
+ : typeof e.escapedCommand === "string"
126
+ ? e.escapedCommand
127
+ : (/^Command failed(?: with exit code \d+)?: ([^\n]+)$/m.exec(shortMessage)?.[1] ??
128
+ /^Command failed(?: with exit code \d+)?: ([^\n]+)$/m.exec(message)?.[1] ??
129
+ "");
130
+ const cmd = extractedCommand.trim();
131
+ if (!cmd.startsWith("git commit"))
132
+ return null;
133
+ const output = [readText(e.stderr), readText(e.stdout)]
134
+ .filter((part) => part.length > 0)
135
+ .join("\n");
136
+ const summary = summarizeOutput(output);
137
+ const code = typeof e.code === "number" ? e.code : null;
138
+ const lines = ["git commit failed (hook or commit policy).", `command: ${cmd}`];
139
+ if (typeof code === "number")
140
+ lines.push(`exit_code: ${code}`);
141
+ if (summary.length > 0)
142
+ lines.push("output_summary:");
143
+ lines.push(...summary.map((line) => ` ${line}`));
144
+ return new CliError({
145
+ exitCode: 5,
146
+ code: "E_GIT",
147
+ message: lines.join("\n"),
148
+ context: withDiagnosticContext({ command: "commit" }, commitFailureDiagnostic(phase, output)),
149
+ });
150
+ }
@@ -0,0 +1,25 @@
1
+ import { type CommandContext } from "../../shared/task-backend.js";
2
+ export declare function cmdCommit(opts: {
3
+ ctx?: CommandContext;
4
+ cwd: string;
5
+ rootOverride?: string;
6
+ baseBranchOverride?: string | null;
7
+ taskId: string;
8
+ message: string;
9
+ close: boolean;
10
+ allow: string[];
11
+ autoAllow: boolean;
12
+ allowTasks: boolean;
13
+ allowBase: boolean;
14
+ allowPolicy: boolean;
15
+ allowConfig: boolean;
16
+ allowHooks: boolean;
17
+ allowCI: boolean;
18
+ requireClean: boolean;
19
+ quiet: boolean;
20
+ closeUnstageOthers: boolean;
21
+ closeCheckOnly: boolean;
22
+ closeStageTaskArtifacts?: boolean;
23
+ closeRefreshTaskArtifacts?: boolean;
24
+ }): Promise<number>;
25
+ //# sourceMappingURL=commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/commit.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAgKtC,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CA2HlB"}
@@ -0,0 +1,366 @@
1
+ import { mkdir, rm, writeFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { buildTaskArtifactRefreshCommitSubject } from "@agentplaneorg/core";
4
+ import { resolveTaskIndexPath } from "../../../backends/task-index.js";
5
+ import { mapCoreError } from "../../../cli/error-map.js";
6
+ import { infoMessage, successMessage } from "../../../cli/output.js";
7
+ import { withDiagnosticContext } from "../../shared/diagnostics.js";
8
+ import { CliError } from "../../../shared/errors.js";
9
+ import { protectedPathKindForFile } from "../../../shared/protected-paths.js";
10
+ import { refreshBranchPrArtifactsAfterTaskCommit } from "../../shared/post-commit-pr-artifacts.js";
11
+ import { isTaskLocalAdvancePath } from "../../shared/task-local-freshness.js";
12
+ import { loadCommandContext, loadTaskFromContext, } from "../../shared/task-backend.js";
13
+ import { execFileAsync, gitEnv } from "../../shared/git.js";
14
+ import { ensureReconciledBeforeMutation } from "../../shared/reconcile-check.js";
15
+ import { stageAllowlist } from "./allow.js";
16
+ import { resolveIgnoredDirectCloseDirtyPaths } from "./close-dirt.js";
17
+ import { buildCloseCommitMessage, taskReadmePathForTask } from "./close-message.js";
18
+ import { asCommitFailure } from "./commit-diagnostics.js";
19
+ import { buildGitCommitEnv, resolveCanonicalGitIdentity } from "./env.js";
20
+ import { guardCommitCheck } from "./policy.js";
21
+ async function resetRebuildableTaskIndexCache(ctx) {
22
+ const gitRoot = path.resolve(ctx.resolvedProject.gitRoot);
23
+ const workflowDirAbs = path.resolve(gitRoot, ctx.config.paths.workflow_dir);
24
+ const cachePath = path.resolve(resolveTaskIndexPath(workflowDirAbs));
25
+ const relativeCachePath = path.relative(gitRoot, cachePath);
26
+ if (!relativeCachePath || relativeCachePath.startsWith(".."))
27
+ return;
28
+ try {
29
+ await execFileAsync("git", ["ls-files", "--error-unmatch", "--", relativeCachePath], {
30
+ cwd: gitRoot,
31
+ env: gitEnv(),
32
+ });
33
+ const gitPath = relativeCachePath.split(path.sep).join("/");
34
+ const cacheBlob = await execFileAsync("git", ["show", `HEAD:${gitPath}`], {
35
+ cwd: gitRoot,
36
+ env: gitEnv(),
37
+ });
38
+ await mkdir(path.dirname(cachePath), { recursive: true });
39
+ await writeFile(cachePath, cacheBlob.stdout, "utf8");
40
+ await execFileAsync("git", ["restore", "--staged", "--", relativeCachePath], {
41
+ cwd: gitRoot,
42
+ env: gitEnv(),
43
+ });
44
+ }
45
+ catch {
46
+ await rm(cachePath, { force: true });
47
+ }
48
+ ctx.git.invalidateStatus();
49
+ }
50
+ async function stageCloseCommitPaths(opts) {
51
+ const stagePaths = new Set([opts.readmeRel]);
52
+ if (opts.allowPolicy) {
53
+ const changedPaths = await opts.ctx.git.statusChangedPaths();
54
+ for (const relPath of changedPaths) {
55
+ if (protectedPathKindForFile({
56
+ filePath: relPath,
57
+ tasksPath: opts.ctx.config.paths.tasks_path,
58
+ workflowDir: opts.ctx.config.paths.workflow_dir,
59
+ taskId: opts.taskId,
60
+ }) === "policy") {
61
+ stagePaths.add(relPath);
62
+ }
63
+ }
64
+ }
65
+ await opts.ctx.git.stage([...stagePaths].toSorted((a, b) => a.localeCompare(b)));
66
+ }
67
+ async function commitRefreshedTaskArtifacts(opts) {
68
+ const changedPaths = await opts.ctx.git.statusChangedPaths();
69
+ const taskArtifactPaths = changedPaths.filter((relPath) => isTaskLocalAdvancePath({
70
+ workflowDir: opts.ctx.config.paths.workflow_dir,
71
+ taskId: opts.taskId,
72
+ tasksPath: opts.ctx.config.paths.tasks_path,
73
+ relPath,
74
+ }));
75
+ if (taskArtifactPaths.length === 0)
76
+ return null;
77
+ await stageAllowlist({
78
+ ctx: opts.ctx,
79
+ allow: [],
80
+ allowTasks: true,
81
+ allowPolicy: false,
82
+ allowConfig: false,
83
+ allowHooks: false,
84
+ allowCI: false,
85
+ tasksPath: opts.ctx.config.paths.tasks_path,
86
+ workflowDir: opts.ctx.config.paths.workflow_dir,
87
+ taskId: opts.taskId,
88
+ allowTaskOnly: true,
89
+ emptyAllowMessage: "PR artifact refresh produced no task-local files to stage for the follow-up commit.",
90
+ noMatchMessage: "PR artifact refresh produced changes outside the active task artifact scope; inspect the working tree before retrying the commit flow.",
91
+ });
92
+ const message = buildTaskArtifactRefreshCommitSubject({
93
+ taskId: opts.taskId,
94
+ baseSubject: opts.sourceMessage,
95
+ });
96
+ await guardCommitCheck({
97
+ ctx: opts.ctx,
98
+ cwd: opts.cwd,
99
+ rootOverride: opts.rootOverride,
100
+ baseBranchOverride: null,
101
+ taskId: opts.taskId,
102
+ message,
103
+ allow: [],
104
+ allowBase: false,
105
+ allowTasks: true,
106
+ allowPolicy: false,
107
+ allowConfig: false,
108
+ allowHooks: false,
109
+ allowCI: false,
110
+ requireClean: true,
111
+ quiet: opts.quiet,
112
+ });
113
+ const env = buildGitCommitEnv({
114
+ taskId: opts.taskId,
115
+ allowTasks: true,
116
+ allowBase: false,
117
+ allowPolicy: false,
118
+ allowConfig: false,
119
+ allowHooks: false,
120
+ allowCI: false,
121
+ gitIdentity: await resolveCanonicalGitIdentity(),
122
+ });
123
+ await opts.ctx.git.commit({ message, env });
124
+ return await opts.ctx.git.headHashSubject();
125
+ }
126
+ function hasExplicitCommitScope(opts) {
127
+ return (opts.allow.some((prefix) => prefix.trim().length > 0) ||
128
+ opts.allowTasks ||
129
+ opts.allowPolicy ||
130
+ opts.allowConfig ||
131
+ opts.allowHooks ||
132
+ opts.allowCI);
133
+ }
134
+ function formatCommitRef(commit) {
135
+ if (!commit)
136
+ return "";
137
+ return `${commit.hash?.slice(0, 12) ?? ""} ${commit.subject ?? ""}`.trim();
138
+ }
139
+ export async function cmdCommit(opts) {
140
+ try {
141
+ const ctx = opts.ctx ??
142
+ (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
143
+ if (opts.close) {
144
+ return await cmdCloseCommit({ ...opts, ctx });
145
+ }
146
+ if (opts.autoAllow) {
147
+ throw new CliError({
148
+ exitCode: 2,
149
+ code: "E_USAGE",
150
+ message: "--auto-allow is disabled; pass explicit --allow <path-prefix>.",
151
+ });
152
+ }
153
+ await ensureReconciledBeforeMutation({ ctx, command: "commit" });
154
+ let autoStaged = [];
155
+ const staged = await ctx.git.statusStagedPaths();
156
+ if (staged.length === 0) {
157
+ if (!hasExplicitCommitScope(opts)) {
158
+ throw new CliError({
159
+ exitCode: 2,
160
+ code: "E_USAGE",
161
+ message: "No staged files and no commit allowlist. Pass --allow <path-prefix>, use --allow-tasks for active task artifacts, or stage files manually.",
162
+ });
163
+ }
164
+ autoStaged = await stageAllowlist({
165
+ ctx,
166
+ allow: opts.allow,
167
+ allowTasks: opts.allowTasks,
168
+ allowPolicy: opts.allowPolicy,
169
+ allowConfig: opts.allowConfig,
170
+ allowHooks: opts.allowHooks,
171
+ allowCI: opts.allowCI,
172
+ tasksPath: ctx.config.paths.tasks_path,
173
+ workflowDir: ctx.config.paths.workflow_dir,
174
+ taskId: opts.taskId,
175
+ allowTaskOnly: true,
176
+ emptyAllowMessage: "No staged files and no commit allowlist. Pass --allow <path-prefix>, use --allow-tasks for active task artifacts, or stage files manually.",
177
+ noMatchMessage: "No changed files matched the commit allowlist (adjust --allow, protected allow flags, or --allow-tasks; otherwise stage files manually).",
178
+ });
179
+ if (!opts.quiet) {
180
+ process.stdout.write(`${infoMessage(`commit auto-staged ${autoStaged.length} path(s) from allowlist`)}\n`);
181
+ }
182
+ }
183
+ await guardCommitCheck({
184
+ ctx,
185
+ cwd: opts.cwd,
186
+ rootOverride: opts.rootOverride,
187
+ baseBranchOverride: opts.baseBranchOverride ?? null,
188
+ taskId: opts.taskId,
189
+ message: opts.message,
190
+ allow: opts.allow,
191
+ allowBase: opts.allowBase,
192
+ allowTasks: opts.allowTasks,
193
+ allowPolicy: opts.allowPolicy,
194
+ allowConfig: opts.allowConfig,
195
+ allowHooks: opts.allowHooks,
196
+ allowCI: opts.allowCI,
197
+ requireClean: opts.requireClean,
198
+ quiet: opts.quiet,
199
+ });
200
+ const env = buildGitCommitEnv({
201
+ taskId: opts.taskId,
202
+ allowTasks: opts.allowTasks,
203
+ allowBase: opts.allowBase,
204
+ allowPolicy: opts.allowPolicy,
205
+ allowConfig: opts.allowConfig,
206
+ allowHooks: opts.allowHooks,
207
+ allowCI: opts.allowCI,
208
+ gitIdentity: await resolveCanonicalGitIdentity(),
209
+ });
210
+ await ctx.git.commit({ message: opts.message, env });
211
+ const primaryCommit = await ctx.git.headHashSubject();
212
+ await refreshBranchPrArtifactsAfterTaskCommit({
213
+ ctx,
214
+ cwd: opts.cwd,
215
+ rootOverride: opts.rootOverride,
216
+ taskId: opts.taskId,
217
+ quiet: opts.quiet,
218
+ });
219
+ ctx.git.invalidateStatus();
220
+ const refreshCommit = await commitRefreshedTaskArtifacts({
221
+ ctx,
222
+ cwd: opts.cwd,
223
+ rootOverride: opts.rootOverride,
224
+ taskId: opts.taskId,
225
+ sourceMessage: opts.message,
226
+ quiet: opts.quiet,
227
+ });
228
+ if (!opts.quiet) {
229
+ process.stdout.write(`${successMessage("committed", formatCommitRef(primaryCommit), [
230
+ autoStaged.length > 0 ? `staged=${autoStaged.join(", ")}` : null,
231
+ refreshCommit ? `refresh=${formatCommitRef(refreshCommit)}` : null,
232
+ ]
233
+ .filter(Boolean)
234
+ .join("; ") || undefined)}\n`);
235
+ }
236
+ return 0;
237
+ }
238
+ catch (err) {
239
+ if (err instanceof CliError)
240
+ throw err;
241
+ const commitFailure = asCommitFailure(err, opts.close ? "close_commit" : "task_commit");
242
+ if (commitFailure)
243
+ throw commitFailure;
244
+ throw mapCoreError(err, { command: "commit", root: opts.rootOverride ?? null });
245
+ }
246
+ }
247
+ async function cmdCloseCommit(opts) {
248
+ if (!opts.closeCheckOnly) {
249
+ await ensureReconciledBeforeMutation({ ctx: opts.ctx, command: "commit" });
250
+ await resetRebuildableTaskIndexCache(opts.ctx);
251
+ }
252
+ let staged = await opts.ctx.git.statusStagedPaths();
253
+ if (staged.length > 0 && opts.closeUnstageOthers) {
254
+ if (!opts.closeCheckOnly) {
255
+ await execFileAsync("git", ["restore", "--staged", "--", "."], {
256
+ cwd: opts.ctx.resolvedProject.gitRoot,
257
+ env: gitEnv(),
258
+ });
259
+ }
260
+ staged = opts.closeCheckOnly ? staged : await opts.ctx.git.statusStagedPaths();
261
+ }
262
+ if (staged.length > 0 && !opts.closeUnstageOthers) {
263
+ throw new CliError({
264
+ exitCode: 5,
265
+ code: "E_GIT",
266
+ message: "Staged files exist (close commit requires an empty index; rerun with --unstage-others to auto-unstage).",
267
+ context: withDiagnosticContext({ command: "commit" }, {
268
+ state: "close commit cannot run with a non-empty git index",
269
+ likelyCause: "deterministic close commits only stage the active task artifact scope, but other staged files are already in the index",
270
+ nextAction: {
271
+ command: "git restore --staged -- .",
272
+ reason: "clear the current index before rerunning the close commit flow",
273
+ reasonCode: "git_close_commit_dirty_index",
274
+ },
275
+ }),
276
+ });
277
+ }
278
+ const task = await loadTaskFromContext({ ctx: opts.ctx, taskId: opts.taskId });
279
+ const msg = await buildCloseCommitMessage({ gitRoot: opts.ctx.resolvedProject.gitRoot, task });
280
+ const readmeAbs = taskReadmePathForTask({
281
+ gitRoot: opts.ctx.resolvedProject.gitRoot,
282
+ workflowDir: opts.ctx.config.paths.workflow_dir,
283
+ taskId: opts.taskId,
284
+ });
285
+ const readmeRel = readmeAbs.startsWith(opts.ctx.resolvedProject.gitRoot)
286
+ ? readmeAbs.slice(opts.ctx.resolvedProject.gitRoot.length + 1)
287
+ : readmeAbs;
288
+ if (opts.closeCheckOnly) {
289
+ if (!opts.quiet) {
290
+ const stagedCount = staged.length;
291
+ const suffix = stagedCount > 0 && opts.closeUnstageOthers ? `; would unstage ${stagedCount} path(s)` : "";
292
+ process.stdout.write(`${successMessage("close preflight", opts.taskId, `subject=${msg.subject}${suffix}`)}\n`);
293
+ }
294
+ return 0;
295
+ }
296
+ if (opts.closeStageTaskArtifacts === true) {
297
+ if (opts.closeRefreshTaskArtifacts !== false) {
298
+ await refreshBranchPrArtifactsAfterTaskCommit({
299
+ ctx: opts.ctx,
300
+ cwd: opts.cwd,
301
+ rootOverride: opts.rootOverride,
302
+ taskId: opts.taskId,
303
+ quiet: opts.quiet,
304
+ });
305
+ }
306
+ opts.ctx.git.invalidateStatus();
307
+ }
308
+ await (opts.closeStageTaskArtifacts === true
309
+ ? stageAllowlist({
310
+ ctx: opts.ctx,
311
+ allow: [],
312
+ allowTasks: true,
313
+ allowPolicy: opts.allowPolicy,
314
+ tasksPath: opts.ctx.config.paths.tasks_path,
315
+ workflowDir: opts.ctx.config.paths.workflow_dir,
316
+ taskId: opts.taskId,
317
+ allowTaskOnly: true,
318
+ emptyAllowMessage: "No changed task artifacts to stage for the deterministic close commit.",
319
+ noMatchMessage: "No changed files matched the active task artifact scope for the deterministic close commit.",
320
+ })
321
+ : stageCloseCommitPaths({
322
+ ctx: opts.ctx,
323
+ readmeRel,
324
+ taskId: opts.taskId,
325
+ allowPolicy: opts.allowPolicy,
326
+ }));
327
+ const ignoredUnstagedTrackedPaths = await resolveIgnoredDirectCloseDirtyPaths({
328
+ ctx: opts.ctx,
329
+ taskId: opts.taskId,
330
+ });
331
+ await guardCommitCheck({
332
+ ctx: opts.ctx,
333
+ cwd: opts.cwd,
334
+ rootOverride: opts.rootOverride,
335
+ baseBranchOverride: opts.baseBranchOverride ?? null,
336
+ taskId: opts.taskId,
337
+ message: msg.subject,
338
+ allow: [],
339
+ allowBase: opts.allowBase,
340
+ allowTasks: true,
341
+ allowPolicy: opts.allowPolicy,
342
+ allowConfig: false,
343
+ allowHooks: false,
344
+ allowCI: false,
345
+ requireClean: true,
346
+ ignoredUnstagedTrackedPaths,
347
+ quiet: opts.quiet,
348
+ });
349
+ const env = buildGitCommitEnv({
350
+ taskId: opts.taskId,
351
+ allowTasks: true,
352
+ allowBase: opts.allowBase,
353
+ allowPolicy: opts.allowPolicy,
354
+ allowConfig: false,
355
+ allowHooks: false,
356
+ allowCI: false,
357
+ allowStaleDist: true,
358
+ gitIdentity: await resolveCanonicalGitIdentity(),
359
+ });
360
+ await opts.ctx.git.commit({ message: msg.subject, body: msg.body, env });
361
+ if (!opts.quiet) {
362
+ const { hash, subject } = await opts.ctx.git.headHashSubject();
363
+ process.stdout.write(`${successMessage("committed", `${hash?.slice(0, 12) ?? ""} ${subject ?? ""}`.trim())}\n`);
364
+ }
365
+ return 0;
366
+ }
@@ -0,0 +1,3 @@
1
+ import { type GuardCommitOptions } from "./policy.js";
2
+ export declare function cmdGuardCommit(opts: GuardCommitOptions): Promise<number>;
3
+ //# sourceMappingURL=guard-commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guard-commit.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/guard-commit.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa9E"}
@@ -0,0 +1,21 @@
1
+ import { mapCoreError } from "../../../cli/error-map.js";
2
+ import { CliError } from "../../../shared/errors.js";
3
+ import { loadCommandContext } from "../../shared/task-backend.js";
4
+ import { ensureReconciledBeforeMutation } from "../../shared/reconcile-check.js";
5
+ import { guardCommitCheck } from "./policy.js";
6
+ export async function cmdGuardCommit(opts) {
7
+ try {
8
+ const ctx = opts.ctx ??
9
+ (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
10
+ await ensureReconciledBeforeMutation({ ctx, command: "guard commit" });
11
+ await guardCommitCheck({ ...opts, ctx });
12
+ if (!opts.quiet)
13
+ process.stdout.write("OK\n");
14
+ return 0;
15
+ }
16
+ catch (err) {
17
+ if (err instanceof CliError)
18
+ throw err;
19
+ throw mapCoreError(err, { command: "guard commit", root: opts.rootOverride ?? null });
20
+ }
21
+ }
@@ -14,6 +14,7 @@ export type GuardCommitOptions = {
14
14
  allowHooks: boolean;
15
15
  allowCI: boolean;
16
16
  requireClean: boolean;
17
+ ignoredUnstagedTrackedPaths?: string[];
17
18
  quiet: boolean;
18
19
  };
19
20
  export declare function guardCommitCheck(opts: GuardCommitOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/policy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEvF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+C9E"}
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/policy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEvF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,2BAA2B,CAAC,EAAE,MAAM,EAAE,CAAC;IACvC,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwD9E"}
@@ -4,10 +4,17 @@ import { gitCurrentBranch } from "../../shared/git-ops.js";
4
4
  import { throwIfPolicyDenied } from "../../shared/policy-deny.js";
5
5
  import { loadCommandContext } from "../../shared/task-backend.js";
6
6
  export async function guardCommitCheck(opts) {
7
- const ctx = opts.ctx ??
7
+ const loadedContext = opts.ctx ??
8
8
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
9
+ const ctx = loadedContext;
9
10
  const staged = await ctx.git.statusStagedPaths();
10
- const unstagedTrackedPaths = opts.requireClean ? await ctx.git.statusUnstagedTrackedPaths() : [];
11
+ const ignoredUnstagedTrackedPaths = new Set((opts.ignoredUnstagedTrackedPaths ?? []).map((value) => value.trim()).filter(Boolean));
12
+ const rawUnstagedTrackedPaths = opts.requireClean
13
+ ? await ctx.git.statusUnstagedTrackedPaths()
14
+ : [];
15
+ const unstagedTrackedPaths = opts.requireClean
16
+ ? rawUnstagedTrackedPaths.filter((relPath) => !ignoredUnstagedTrackedPaths.has(relPath))
17
+ : [];
11
18
  const inBranchPr = ctx.config.workflow_mode === "branch_pr";
12
19
  const explicitBaseBranch = opts.baseBranchOverride?.trim();
13
20
  const baseBranch = inBranchPr
@@ -0,0 +1,6 @@
1
+ export declare function cmdGuardSuggestAllow(opts: {
2
+ cwd: string;
3
+ rootOverride?: string;
4
+ format: "lines" | "args";
5
+ }): Promise<number>;
6
+ //# sourceMappingURL=suggest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../../../../src/commands/guard/impl/suggest.ts"],"names":[],"mappings":"AAKA,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlB"}
@@ -0,0 +1,33 @@
1
+ import { mapCoreError } from "../../../cli/error-map.js";
2
+ import { CliError } from "../../../shared/errors.js";
3
+ import { loadCommandContext } from "../../shared/task-backend.js";
4
+ import { suggestAllowPrefixes } from "./allow.js";
5
+ export async function cmdGuardSuggestAllow(opts) {
6
+ try {
7
+ const ctx = await loadCommandContext({
8
+ cwd: opts.cwd,
9
+ rootOverride: opts.rootOverride ?? null,
10
+ });
11
+ const staged = await ctx.git.statusStagedPaths();
12
+ if (staged.length === 0) {
13
+ throw new CliError({
14
+ exitCode: 2,
15
+ code: "E_USAGE",
16
+ message: "No staged files (git index empty)",
17
+ });
18
+ }
19
+ const prefixes = suggestAllowPrefixes(staged);
20
+ if (opts.format === "args") {
21
+ const args = prefixes.map((p) => `--allow ${p}`).join(" ");
22
+ process.stdout.write(`${args}\n`);
23
+ }
24
+ else {
25
+ for (const prefix of prefixes)
26
+ process.stdout.write(`${prefix}\n`);
27
+ }
28
+ return 0;
29
+ }
30
+ catch (err) {
31
+ throw mapCoreError(err, { command: "guard suggest-allow", root: opts.rootOverride ?? null });
32
+ }
33
+ }
@@ -1,4 +1,7 @@
1
1
  export declare const HOOK_NAMES: readonly ["commit-msg", "pre-commit", "pre-push", "post-merge"];
2
+ export declare function resolvePrePushHookScriptPath(gitRoot: string, opts?: {
3
+ bundledScriptPath?: string;
4
+ }): Promise<string | null>;
2
5
  export declare function cmdHooksInstall(opts: {
3
6
  cwd: string;
4
7
  rootOverride?: string;