agentplane 0.3.13 → 0.3.15

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 (278) hide show
  1. package/assets/RUNNER.md +1 -1
  2. package/assets/agents/ORCHESTRATOR.json +1 -1
  3. package/assets/agents/SKILL_EXTRACTOR.json +31 -0
  4. package/assets/framework.manifest.json +7 -0
  5. package/assets/policy/incidents.md +5 -3
  6. package/assets/policy/workflow.branch_pr.md +10 -5
  7. package/dist/.build-manifest.json +280 -180
  8. package/dist/cli/output.d.ts +29 -0
  9. package/dist/cli/output.d.ts.map +1 -1
  10. package/dist/cli/output.js +33 -0
  11. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  12. package/dist/cli/run-cli/command-catalog/core.js +29 -87
  13. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  14. package/dist/cli/run-cli/command-catalog/lifecycle.js +4 -12
  15. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  16. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  17. package/dist/cli/run-cli/command-catalog/project.js +16 -38
  18. package/dist/cli/run-cli/command-catalog/shared.d.ts +9 -6
  19. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  20. package/dist/cli/run-cli/command-catalog/shared.js +23 -6
  21. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  22. package/dist/cli/run-cli/command-catalog/task.js +6 -18
  23. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  24. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  25. package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -1
  26. package/dist/cli/run-cli/commands/init/recipes.js +1 -0
  27. package/dist/cli/run-cli.js +1 -1
  28. package/dist/cli/run-cli.test-helpers.d.ts +1 -74
  29. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  30. package/dist/cli/run-cli.test-helpers.js +1 -769
  31. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  32. package/dist/commands/branch/cleanup-merged.js +5 -9
  33. package/dist/commands/branch/work-start.command.d.ts.map +1 -1
  34. package/dist/commands/branch/work-start.command.js +1 -0
  35. package/dist/commands/commit.spec.d.ts.map +1 -1
  36. package/dist/commands/commit.spec.js +2 -0
  37. package/dist/commands/doctor/branch-pr.d.ts +1 -1
  38. package/dist/commands/doctor/branch-pr.d.ts.map +1 -1
  39. package/dist/commands/doctor/branch-pr.js +5 -2
  40. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  41. package/dist/commands/guard/impl/commands.js +4 -1
  42. package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -1
  43. package/dist/commands/guard/impl/comment-commit.js +2 -1
  44. package/dist/commands/guard/impl/env.d.ts +6 -0
  45. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  46. package/dist/commands/guard/impl/env.js +41 -0
  47. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  48. package/dist/commands/pr/internal/auto-commit.js +2 -1
  49. package/dist/commands/pr/internal/sync-branch.d.ts +36 -0
  50. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -0
  51. package/dist/commands/pr/internal/sync-branch.js +113 -0
  52. package/dist/commands/pr/internal/sync-github.d.ts +28 -0
  53. package/dist/commands/pr/internal/sync-github.d.ts.map +1 -0
  54. package/dist/commands/pr/internal/sync-github.js +178 -0
  55. package/dist/commands/pr/internal/sync-model.d.ts +36 -0
  56. package/dist/commands/pr/internal/sync-model.d.ts.map +1 -0
  57. package/dist/commands/pr/internal/sync-model.js +1 -0
  58. package/dist/commands/pr/internal/sync-open-step.d.ts +10 -0
  59. package/dist/commands/pr/internal/sync-open-step.d.ts.map +1 -0
  60. package/dist/commands/pr/internal/sync-open-step.js +128 -0
  61. package/dist/commands/pr/internal/sync-support.d.ts +7 -0
  62. package/dist/commands/pr/internal/sync-support.d.ts.map +1 -0
  63. package/dist/commands/pr/internal/sync-support.js +29 -0
  64. package/dist/commands/pr/internal/sync-update-step.d.ts +6 -0
  65. package/dist/commands/pr/internal/sync-update-step.d.ts.map +1 -0
  66. package/dist/commands/pr/internal/sync-update-step.js +68 -0
  67. package/dist/commands/pr/internal/sync.d.ts +2 -6
  68. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  69. package/dist/commands/pr/internal/sync.js +83 -529
  70. package/dist/commands/pr/open.d.ts.map +1 -1
  71. package/dist/commands/pr/open.js +25 -8
  72. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  73. package/dist/commands/pr/pr.command.js +7 -2
  74. package/dist/commands/recipes/impl/apply.d.ts +1 -1
  75. package/dist/commands/recipes/impl/apply.d.ts.map +1 -1
  76. package/dist/commands/recipes/impl/apply.js +1 -2
  77. package/dist/commands/recipes/impl/commands/active.d.ts.map +1 -1
  78. package/dist/commands/recipes/impl/commands/active.js +6 -5
  79. package/dist/commands/recipes/impl/commands/add.d.ts +1 -0
  80. package/dist/commands/recipes/impl/commands/add.d.ts.map +1 -1
  81. package/dist/commands/recipes/impl/commands/add.js +32 -27
  82. package/dist/commands/recipes/impl/commands/detach.d.ts.map +1 -1
  83. package/dist/commands/recipes/impl/commands/detach.js +35 -21
  84. package/dist/commands/recipes/impl/commands/disable.d.ts.map +1 -1
  85. package/dist/commands/recipes/impl/commands/disable.js +5 -3
  86. package/dist/commands/recipes/impl/commands/enable.d.ts.map +1 -1
  87. package/dist/commands/recipes/impl/commands/enable.js +5 -3
  88. package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -1
  89. package/dist/commands/recipes/impl/commands/explain.js +57 -47
  90. package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -1
  91. package/dist/commands/recipes/impl/commands/info.js +25 -21
  92. package/dist/commands/recipes/impl/commands/install.d.ts +1 -1
  93. package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -1
  94. package/dist/commands/recipes/impl/commands/install.js +3 -13
  95. package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -1
  96. package/dist/commands/recipes/impl/commands/list-remote.js +2 -3
  97. package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -1
  98. package/dist/commands/recipes/impl/commands/list.js +7 -6
  99. package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -1
  100. package/dist/commands/recipes/impl/commands/remove.js +12 -7
  101. package/dist/commands/recipes/impl/commands/update.d.ts.map +1 -1
  102. package/dist/commands/recipes/impl/commands/update.js +38 -24
  103. package/dist/commands/recipes/impl/index.d.ts +1 -1
  104. package/dist/commands/recipes/impl/index.d.ts.map +1 -1
  105. package/dist/commands/recipes/impl/installed-recipes.d.ts +1 -1
  106. package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -1
  107. package/dist/commands/recipes/impl/installed-recipes.js +1 -2
  108. package/dist/commands/recipes/impl/mutation-transaction.d.ts +7 -0
  109. package/dist/commands/recipes/impl/mutation-transaction.d.ts.map +1 -0
  110. package/dist/commands/recipes/impl/mutation-transaction.js +47 -0
  111. package/dist/commands/recipes/impl/overlay-project.d.ts +19 -3
  112. package/dist/commands/recipes/impl/overlay-project.d.ts.map +1 -1
  113. package/dist/commands/recipes/impl/overlay-project.js +76 -38
  114. package/dist/commands/recipes/impl/paths.d.ts +0 -3
  115. package/dist/commands/recipes/impl/paths.d.ts.map +1 -1
  116. package/dist/commands/recipes/impl/paths.js +0 -3
  117. package/dist/commands/recipes/impl/project-installed-recipes.d.ts +4 -1
  118. package/dist/commands/recipes/impl/project-installed-recipes.d.ts.map +1 -1
  119. package/dist/commands/recipes/impl/project-installed-recipes.js +6 -4
  120. package/dist/commands/recipes/impl/project-recipe-state.d.ts +1 -1
  121. package/dist/commands/recipes/impl/project-recipe-state.d.ts.map +1 -1
  122. package/dist/commands/recipes/impl/project-registry.d.ts +5 -1
  123. package/dist/commands/recipes/impl/project-registry.d.ts.map +1 -1
  124. package/dist/commands/recipes/impl/project-registry.js +34 -14
  125. package/dist/commands/recipes/impl/resolver.d.ts +1 -1
  126. package/dist/commands/recipes/impl/resolver.d.ts.map +1 -1
  127. package/dist/commands/recipes/impl/resolver.js +1 -1
  128. package/dist/commands/recipes/impl/types.d.ts +1 -1
  129. package/dist/commands/recipes/impl/types.d.ts.map +1 -1
  130. package/dist/commands/recipes/impl/version.d.ts +5 -0
  131. package/dist/commands/recipes/impl/version.d.ts.map +1 -0
  132. package/dist/commands/recipes/impl/version.js +9 -0
  133. package/dist/commands/recipes.d.ts +5 -4
  134. package/dist/commands/recipes.d.ts.map +1 -1
  135. package/dist/commands/recipes.js +3 -3
  136. package/dist/commands/release/apply.command.d.ts +1 -1
  137. package/dist/commands/release/apply.command.d.ts.map +1 -1
  138. package/dist/commands/release/apply.command.js +15 -379
  139. package/dist/commands/release/apply.mutation.d.ts +1 -0
  140. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  141. package/dist/commands/release/apply.mutation.js +24 -1
  142. package/dist/commands/release/apply.pipeline.d.ts +22 -0
  143. package/dist/commands/release/apply.pipeline.d.ts.map +1 -0
  144. package/dist/commands/release/apply.pipeline.js +371 -0
  145. package/dist/commands/release/apply.preflight.d.ts +2 -0
  146. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  147. package/dist/commands/release/apply.preflight.js +13 -4
  148. package/dist/commands/release/apply.types.d.ts +27 -0
  149. package/dist/commands/release/apply.types.d.ts.map +1 -1
  150. package/dist/commands/release.test-helpers.d.ts +4 -0
  151. package/dist/commands/release.test-helpers.d.ts.map +1 -1
  152. package/dist/commands/release.test-helpers.js +7 -0
  153. package/dist/commands/shared/reconcile-check.d.ts.map +1 -1
  154. package/dist/commands/shared/reconcile-check.js +2 -2
  155. package/dist/commands/shared/task-backend.d.ts +6 -1
  156. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  157. package/dist/commands/shared/task-backend.js +34 -2
  158. package/dist/commands/shared/task-mutation.d.ts.map +1 -1
  159. package/dist/commands/shared/task-mutation.js +4 -4
  160. package/dist/commands/shared/task-store/intents.d.ts +34 -0
  161. package/dist/commands/shared/task-store/intents.d.ts.map +1 -0
  162. package/dist/commands/shared/task-store/intents.js +265 -0
  163. package/dist/commands/shared/task-store/readme.d.ts +28 -0
  164. package/dist/commands/shared/task-store/readme.d.ts.map +1 -0
  165. package/dist/commands/shared/task-store/readme.js +125 -0
  166. package/dist/commands/shared/task-store/store.d.ts +26 -0
  167. package/dist/commands/shared/task-store/store.d.ts.map +1 -0
  168. package/dist/commands/shared/task-store/store.js +105 -0
  169. package/dist/commands/shared/task-store/types.d.ts +94 -0
  170. package/dist/commands/shared/task-store/types.d.ts.map +1 -0
  171. package/dist/commands/shared/task-store/types.js +1 -0
  172. package/dist/commands/shared/task-store.d.ts +3 -109
  173. package/dist/commands/shared/task-store.d.ts.map +1 -1
  174. package/dist/commands/shared/task-store.js +2 -493
  175. package/dist/commands/task/block.d.ts.map +1 -1
  176. package/dist/commands/task/block.js +7 -2
  177. package/dist/commands/task/comment.d.ts.map +1 -1
  178. package/dist/commands/task/comment.js +7 -2
  179. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  180. package/dist/commands/task/finish-shared.js +3 -3
  181. package/dist/commands/task/finish.d.ts.map +1 -1
  182. package/dist/commands/task/finish.js +102 -15
  183. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  184. package/dist/commands/task/hosted-close.command.js +23 -2
  185. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  186. package/dist/commands/task/hosted-merge-sync.js +9 -4
  187. package/dist/commands/task/list.run.d.ts.map +1 -1
  188. package/dist/commands/task/list.run.js +14 -4
  189. package/dist/commands/task/new.command.d.ts.map +1 -1
  190. package/dist/commands/task/new.command.js +16 -2
  191. package/dist/commands/task/new.js +2 -2
  192. package/dist/commands/task/show.d.ts.map +1 -1
  193. package/dist/commands/task/show.js +3 -3
  194. package/dist/commands/task/update.d.ts.map +1 -1
  195. package/dist/commands/task/update.js +11 -3
  196. package/dist/runner/adapters/codex.d.ts.map +1 -1
  197. package/dist/runner/adapters/codex.js +3 -33
  198. package/dist/runner/adapters/custom.d.ts.map +1 -1
  199. package/dist/runner/adapters/custom.js +3 -30
  200. package/dist/runner/adapters/runtime-shared.d.ts +14 -0
  201. package/dist/runner/adapters/runtime-shared.d.ts.map +1 -0
  202. package/dist/runner/adapters/runtime-shared.js +36 -0
  203. package/dist/runner/context/base-prompt-sources.d.ts +30 -0
  204. package/dist/runner/context/base-prompt-sources.d.ts.map +1 -0
  205. package/dist/runner/context/base-prompt-sources.js +144 -0
  206. package/dist/runner/context/base-prompts.d.ts +3 -22
  207. package/dist/runner/context/base-prompts.d.ts.map +1 -1
  208. package/dist/runner/context/base-prompts.js +6 -450
  209. package/dist/runner/context/overlay-prompt-blocks.d.ts +7 -0
  210. package/dist/runner/context/overlay-prompt-blocks.d.ts.map +1 -0
  211. package/dist/runner/context/overlay-prompt-blocks.js +72 -0
  212. package/dist/runner/context/prompt-block-shared.d.ts +54 -0
  213. package/dist/runner/context/prompt-block-shared.d.ts.map +1 -0
  214. package/dist/runner/context/prompt-block-shared.js +106 -0
  215. package/dist/runner/context/recipe-context.d.ts +2 -1
  216. package/dist/runner/context/recipe-context.d.ts.map +1 -1
  217. package/dist/runner/context/recipe-context.js +2 -1
  218. package/dist/runner/context/recipe-prompt-blocks.d.ts +6 -0
  219. package/dist/runner/context/recipe-prompt-blocks.d.ts.map +1 -0
  220. package/dist/runner/context/recipe-prompt-blocks.js +143 -0
  221. package/dist/runner/usecases/scenario-materialize-task.js +2 -2
  222. package/dist/runner/usecases/task-run-inspect.js +2 -2
  223. package/dist/runner/usecases/task-run-lifecycle-shared.js +2 -2
  224. package/dist/runner/usecases/task-run.d.ts.map +1 -1
  225. package/dist/runner/usecases/task-run.js +4 -2
  226. package/dist/runtime/capabilities/recipe.d.ts +1 -1
  227. package/dist/runtime/capabilities/recipe.d.ts.map +1 -1
  228. package/dist/runtime/execution-context.d.ts +63 -0
  229. package/dist/runtime/execution-context.d.ts.map +1 -0
  230. package/dist/{usecases/context/resolve-context.js → runtime/execution-context.js} +23 -26
  231. package/dist/runtime/incidents/advice-strategy.d.ts +15 -0
  232. package/dist/runtime/incidents/advice-strategy.d.ts.map +1 -0
  233. package/dist/runtime/incidents/advice-strategy.js +54 -0
  234. package/dist/runtime/incidents/plan-strategy.d.ts +9 -0
  235. package/dist/runtime/incidents/plan-strategy.d.ts.map +1 -0
  236. package/dist/runtime/incidents/plan-strategy.js +205 -0
  237. package/dist/runtime/incidents/registry-strategy.d.ts +6 -0
  238. package/dist/runtime/incidents/registry-strategy.d.ts.map +1 -0
  239. package/dist/runtime/incidents/registry-strategy.js +280 -0
  240. package/dist/runtime/incidents/resolve.d.ts +3 -25
  241. package/dist/runtime/incidents/resolve.d.ts.map +1 -1
  242. package/dist/runtime/incidents/resolve.js +3 -683
  243. package/dist/runtime/incidents/shared.d.ts +34 -0
  244. package/dist/runtime/incidents/shared.d.ts.map +1 -0
  245. package/dist/runtime/incidents/shared.js +171 -0
  246. package/dist/testing/cli-harness/recipe-archives.d.ts +28 -0
  247. package/dist/testing/cli-harness/recipe-archives.d.ts.map +1 -0
  248. package/dist/testing/cli-harness/recipe-archives.js +374 -0
  249. package/dist/testing/cli-harness/stdio.d.ts +26 -0
  250. package/dist/testing/cli-harness/stdio.d.ts.map +1 -0
  251. package/dist/testing/cli-harness/stdio.js +84 -0
  252. package/dist/testing/cli-harness.d.ts +25 -0
  253. package/dist/testing/cli-harness.d.ts.map +1 -0
  254. package/dist/testing/cli-harness.js +313 -0
  255. package/dist/testing/index.d.ts +2 -0
  256. package/dist/testing/index.d.ts.map +1 -0
  257. package/dist/testing/index.js +1 -0
  258. package/package.json +7 -4
  259. package/dist/commands/recipes/impl/manifest.d.ts +0 -4
  260. package/dist/commands/recipes/impl/manifest.d.ts.map +0 -1
  261. package/dist/commands/recipes/impl/manifest.js +0 -7
  262. package/dist/commands/recipes/impl/normalize.d.ts +0 -8
  263. package/dist/commands/recipes/impl/normalize.d.ts.map +0 -1
  264. package/dist/commands/recipes/impl/normalize.js +0 -54
  265. package/dist/commands/recipes/impl/scenario.d.ts +0 -16
  266. package/dist/commands/recipes/impl/scenario.d.ts.map +0 -1
  267. package/dist/commands/recipes/impl/scenario.js +0 -262
  268. package/dist/recipes/bundled-recipes.d.ts +0 -17
  269. package/dist/recipes/bundled-recipes.d.ts.map +0 -1
  270. package/dist/recipes/bundled-recipes.js +0 -15
  271. package/dist/usecases/context/resolve-context.d.ts +0 -68
  272. package/dist/usecases/context/resolve-context.d.ts.map +0 -1
  273. package/dist/usecases/task/task-list-usecase.d.ts +0 -9
  274. package/dist/usecases/task/task-list-usecase.d.ts.map +0 -1
  275. package/dist/usecases/task/task-list-usecase.js +0 -17
  276. package/dist/usecases/task/task-new-usecase.d.ts +0 -9
  277. package/dist/usecases/task/task-new-usecase.d.ts.map +0 -1
  278. package/dist/usecases/task/task-new-usecase.js +0 -17
@@ -7,9 +7,10 @@ import { readFile, rm } from "node:fs/promises";
7
7
  import path from "node:path";
8
8
  import { ensureActionApproved } from "../shared/approval-requirements.js";
9
9
  import { ensureReconciledBeforeMutation } from "../shared/reconcile-check.js";
10
- import { gitCurrentBranch } from "../shared/git-ops.js";
11
- import { loadCommandContext } from "../shared/task-backend.js";
12
- import { backendIsLocalFileBackend, getTaskStore } from "../shared/task-store.js";
10
+ import { execFileAsync, gitEnv } from "../shared/git.js";
11
+ import { gitBranchExists, gitCurrentBranch } from "../shared/git-ops.js";
12
+ import { backendUsesLocalTaskStore, loadCommandContext, } from "../shared/task-backend.js";
13
+ import { getTaskStore } from "../shared/task-store.js";
13
14
  import { applyTaskMutation } from "../shared/task-mutation.js";
14
15
  import { collectTaskIncidents, renderIncidentCollectionPlanOutcome } from "../incidents/shared.js";
15
16
  import { createTaskCloseCommit, existingCommitInfo, loadTaskForFinish, writeFinishedTasks, } from "./finish-shared.js";
@@ -57,6 +58,68 @@ async function ensureFinishRunsOnBaseBranch(opts) {
57
58
  `(current: ${currentBranch}); integrate first or reconcile from the base checkout.`,
58
59
  });
59
60
  }
61
+ async function readHeadCommitHash(gitRoot) {
62
+ const { stdout } = await execFileAsync("git", ["rev-parse", "HEAD"], {
63
+ cwd: gitRoot,
64
+ env: gitEnv(),
65
+ });
66
+ const hash = stdout.trim();
67
+ if (!hash) {
68
+ throw new CliError({
69
+ exitCode: exitCodeForError("E_GIT"),
70
+ code: "E_GIT",
71
+ message: "Failed to resolve HEAD while preparing a branch_pr close tail.",
72
+ });
73
+ }
74
+ return hash;
75
+ }
76
+ function branchPrCloseBranchName(taskId, headCommitHash) {
77
+ return `task-close/${taskId}/${headCommitHash.slice(0, 12)}`;
78
+ }
79
+ async function materializeBranchPrCloseTail(opts) {
80
+ const gitRoot = opts.ctx.resolvedProject.gitRoot;
81
+ const baseBranch = await gitCurrentBranch(gitRoot);
82
+ const headCommitHash = await readHeadCommitHash(gitRoot);
83
+ const closeBranch = branchPrCloseBranchName(opts.taskId, headCommitHash);
84
+ const branchExists = await gitBranchExists(gitRoot, closeBranch);
85
+ await execFileAsync("git", branchExists ? ["checkout", closeBranch] : ["checkout", "-b", closeBranch], {
86
+ cwd: gitRoot,
87
+ env: gitEnv(),
88
+ });
89
+ let checkoutError = null;
90
+ try {
91
+ await createTaskCloseCommit({
92
+ ctx: opts.ctx,
93
+ cwd: opts.cwd,
94
+ rootOverride: opts.rootOverride,
95
+ taskId: opts.taskId,
96
+ baseBranchOverride: opts.baseBranchOverride,
97
+ quiet: opts.quiet,
98
+ closeUnstageOthers: opts.closeUnstageOthers,
99
+ allowPolicy: opts.allowPolicy,
100
+ });
101
+ }
102
+ finally {
103
+ try {
104
+ await execFileAsync("git", ["checkout", baseBranch], {
105
+ cwd: gitRoot,
106
+ env: gitEnv(),
107
+ });
108
+ }
109
+ catch (error) {
110
+ checkoutError = error;
111
+ }
112
+ }
113
+ if (checkoutError) {
114
+ throw new CliError({
115
+ exitCode: exitCodeForError("E_GIT"),
116
+ code: "E_GIT",
117
+ message: `Created ${closeBranch} but failed to return to ${baseBranch}; ` +
118
+ "inspect the local checkout before continuing.",
119
+ });
120
+ }
121
+ return closeBranch;
122
+ }
60
123
  async function appendFinishStructuredFinding(opts) {
61
124
  await applyTaskMutation({
62
125
  ctx: opts.ctx,
@@ -175,7 +238,7 @@ export async function cmdFinish(opts) {
175
238
  message: "--status-commit requires --status-commit-allow <path-prefix>",
176
239
  });
177
240
  }
178
- const useStore = backendIsLocalFileBackend(ctx);
241
+ const useStore = backendUsesLocalTaskStore(ctx);
179
242
  const store = useStore ? getTaskStore(ctx) : null;
180
243
  const backendWritesTaskReadmes = ctx.taskBackend.capabilities.writes_task_readmes === true;
181
244
  const defaultDirectCloseCommit = ctx.config.workflow_mode === "direct" &&
@@ -183,12 +246,18 @@ export async function cmdFinish(opts) {
183
246
  opts.taskIds.length === 1 &&
184
247
  !opts.commitFromComment &&
185
248
  !statusCommitRequested;
249
+ const defaultBranchPrCloseCommit = ctx.config.workflow_mode === "branch_pr" &&
250
+ backendWritesTaskReadmes &&
251
+ opts.taskIds.length === 1 &&
252
+ !opts.commitFromComment &&
253
+ !statusCommitRequested;
186
254
  const statusPathRequiresTrackedTaskCommit = backendWritesTaskReadmes &&
187
255
  opts.taskIds.length === 1 &&
188
256
  (opts.commitFromComment || statusCommitRequested);
189
257
  const shouldCloseCommit = opts.closeCommit === true ||
190
258
  statusPathRequiresTrackedTaskCommit ||
191
- (defaultDirectCloseCommit && opts.noCloseCommit !== true);
259
+ (defaultDirectCloseCommit && opts.noCloseCommit !== true) ||
260
+ (defaultBranchPrCloseCommit && opts.noCloseCommit !== true);
192
261
  const metaTaskId = opts.taskIds.length === 1 ? (opts.taskIds[0] ?? "") : "";
193
262
  const wantMeta = typeof opts.result === "string" || typeof opts.risk === "string" || opts.breaking === true;
194
263
  const resultProvided = typeof opts.result === "string";
@@ -397,16 +466,34 @@ export async function cmdFinish(opts) {
397
466
  if (!opts.quiet) {
398
467
  process.stdout.write(`${infoMessage("task marked DONE; creating deterministic close commit")}\n`);
399
468
  }
400
- await createTaskCloseCommit({
401
- ctx,
402
- cwd: opts.cwd,
403
- rootOverride: opts.rootOverride,
404
- taskId: primaryTaskId,
405
- baseBranchOverride: opts.baseBranchOverride,
406
- quiet: opts.quiet,
407
- closeUnstageOthers: opts.closeCommit === true && opts.closeUnstageOthers === true,
408
- allowPolicy: promotedIncidents > 0,
409
- });
469
+ const closeUnstageOthers = opts.closeCommit === true && opts.closeUnstageOthers === true;
470
+ if (ctx.config.workflow_mode === "branch_pr") {
471
+ const closeBranch = await materializeBranchPrCloseTail({
472
+ ctx,
473
+ cwd: opts.cwd,
474
+ rootOverride: opts.rootOverride,
475
+ taskId: primaryTaskId,
476
+ baseBranchOverride: opts.baseBranchOverride,
477
+ quiet: opts.quiet,
478
+ closeUnstageOthers,
479
+ allowPolicy: promotedIncidents > 0,
480
+ });
481
+ if (!opts.quiet) {
482
+ process.stdout.write(`${infoMessage(`branch_pr close tail ready on ${closeBranch}; push that branch and open it with task hosted-close-pr if hosted automation does not create the closure PR for you.`)}\n`);
483
+ }
484
+ }
485
+ else {
486
+ await createTaskCloseCommit({
487
+ ctx,
488
+ cwd: opts.cwd,
489
+ rootOverride: opts.rootOverride,
490
+ taskId: primaryTaskId,
491
+ baseBranchOverride: opts.baseBranchOverride,
492
+ quiet: opts.quiet,
493
+ closeUnstageOthers,
494
+ allowPolicy: promotedIncidents > 0,
495
+ });
496
+ }
410
497
  }
411
498
  if (ctx.config.workflow_mode === "direct") {
412
499
  await clearDirectWorkLockIfMatches({
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-close.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close.command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAStE,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAOrF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAqClE,CAAC;AAmYF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC9E,KAAK,UAAU,EAAE,QAAQ,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAAC,CA2B/E"}
1
+ {"version":3,"file":"hosted-close.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-close.command.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAStE,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAOrF,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,qBAAqB,CAqClE,CAAC;AAyZF,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IAC9E,KAAK,UAAU,EAAE,QAAQ,qBAAqB,KAAG,OAAO,CAAC,MAAM,CAAC,CA2B/E"}
@@ -243,18 +243,33 @@ async function closeHostedTask(opts) {
243
243
  const gitRoot = opts.ctx.resolvedProject.gitRoot;
244
244
  const taskDirRelative = path.join(opts.ctx.config.paths.workflow_dir, target.taskId);
245
245
  const taskReadmePath = path.join(gitRoot, taskDirRelative, "README.md");
246
+ const existingMetaPath = path.join(gitRoot, taskDirRelative, "pr", "meta.json");
247
+ let existingMeta = null;
248
+ if (await fileExists(existingMetaPath)) {
249
+ existingMeta = parsePrMeta(await readFile(existingMetaPath, "utf8"), target.taskId);
250
+ }
251
+ const existingMergeCommit = existingMeta?.merge_commit?.trim() ?? "";
252
+ const existingMetaAlreadyMerged = existingMeta?.status === "MERGED" &&
253
+ existingMergeCommit.length > 0 &&
254
+ existingMergeCommit === target.mergedPr.mergeCommit.oid;
246
255
  let task;
247
256
  try {
248
257
  task = await loadTaskFromContext({
249
258
  ctx: opts.ctx,
250
259
  taskId: target.taskId,
251
- preferBranchSnapshot: true,
252
- branchSnapshotBranch: target.branch,
260
+ preferBranchSnapshot: !existingMetaAlreadyMerged,
261
+ branchSnapshotBranch: existingMetaAlreadyMerged ? null : target.branch,
253
262
  });
254
263
  }
255
264
  catch (err) {
256
265
  if (!isMissingTaskReadmeError(err, taskReadmePath))
257
266
  throw err;
267
+ if (existingMetaAlreadyMerged) {
268
+ return {
269
+ outcome: "noop",
270
+ detail: `${target.taskId} is already closed for merge ${target.mergedPr.mergeCommit.oid.slice(0, 12)}`,
271
+ };
272
+ }
258
273
  const recovered = await buildHostedTaskFromTrackedPrArtifacts({
259
274
  gitRoot,
260
275
  taskDirRelative,
@@ -286,6 +301,12 @@ async function closeHostedTask(opts) {
286
301
  `${task.commit?.hash} != ${target.mergedPr.mergeCommit.oid}`,
287
302
  });
288
303
  }
304
+ if (alreadyClosed && existingMetaAlreadyMerged) {
305
+ return {
306
+ outcome: "noop",
307
+ detail: `${target.taskId} is already closed for merge ${target.mergedPr.mergeCommit.oid.slice(0, 12)}`,
308
+ };
309
+ }
289
310
  const nextMeta = buildIntegratedPrMeta({
290
311
  meta,
291
312
  branch: target.branch,
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-merge-sync.d.ts","sourceRoot":"","sources":["../../../src/commands/task/hosted-merge-sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8C,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAO/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,GAAG,CAAC,EAAE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;IAC/B,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAuDjC;AAED,wBAAsB,+BAA+B,CAAC,IAAI,EAAE;IAC1D,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAuDxC;AAED,wBAAsB,wCAAwC,CAAC,IAAI,EAAE;IACnE,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA0CpC;AAED,wBAAsB,+BAA+B,CAAC,IAAI,EAAE;IAC1D,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAoBjC;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,GAAG,EAAE,cAAc,CAAC;IACpB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAqDjC"}
@@ -7,6 +7,7 @@ import { execFileAsync } from "../shared/git.js";
7
7
  import { withGhTransportRetry } from "../shared/gh-transport.js";
8
8
  import { parseTaskIdFromBranch } from "../shared/git-worktree.js";
9
9
  import { parsePrMeta } from "../shared/pr-meta.js";
10
+ import { backendUsesLocalTaskStore } from "../shared/task-backend.js";
10
11
  import { ghEnv } from "../pr/internal/gh-api.js";
11
12
  import { appendTaskEvent } from "./shared.js";
12
13
  function normalizeMergedPr(value) {
@@ -346,7 +347,7 @@ function needsHostedMergeSync(opts) {
346
347
  return false;
347
348
  }
348
349
  export async function syncHostedMergedTask(opts) {
349
- if (opts.ctx.backendId !== "local" || opts.ctx.config.workflow_mode !== "branch_pr") {
350
+ if (!backendUsesLocalTaskStore(opts.ctx) || opts.ctx.config.workflow_mode !== "branch_pr") {
350
351
  return { tasks: opts.tasks, synced: 0 };
351
352
  }
352
353
  const task = opts.tasks.find((entry) => entry.id === opts.target.taskId);
@@ -393,7 +394,7 @@ export async function syncHostedMergedTask(opts) {
393
394
  };
394
395
  }
395
396
  export async function findLocallyShippedBranchPrTasks(opts) {
396
- if (opts.ctx.backendId !== "local" || opts.ctx.config.workflow_mode !== "branch_pr") {
397
+ if (!backendUsesLocalTaskStore(opts.ctx) || opts.ctx.config.workflow_mode !== "branch_pr") {
397
398
  return [];
398
399
  }
399
400
  const matches = [];
@@ -446,7 +447,7 @@ export async function findLocallyShippedBranchPrTasks(opts) {
446
447
  return matches;
447
448
  }
448
449
  export async function findDoneBranchPrTasksWithOpenPrArtifacts(opts) {
449
- if (opts.ctx.backendId !== "local" || opts.ctx.config.workflow_mode !== "branch_pr") {
450
+ if (!backendUsesLocalTaskStore(opts.ctx) || opts.ctx.config.workflow_mode !== "branch_pr") {
450
451
  return [];
451
452
  }
452
453
  const matches = [];
@@ -461,6 +462,10 @@ export async function findDoneBranchPrTasksWithOpenPrArtifacts(opts) {
461
462
  const branch = meta.branch?.trim() ?? "";
462
463
  if (!branch)
463
464
  continue;
465
+ const branchStillExists = (await gitRefExists({ cwd: opts.ctx.resolvedProject.gitRoot, ref: branch })) ||
466
+ (await gitRefExists({ cwd: opts.ctx.resolvedProject.gitRoot, ref: `origin/${branch}` }));
467
+ if (!branchStillExists)
468
+ continue;
464
469
  if (isStackedBranchAliasDoneTask({ task, branch }))
465
470
  continue;
466
471
  // Missing implementation commits are handled by a dedicated doctor check, and duplicate/no-op
@@ -504,7 +509,7 @@ export async function syncLocallyShippedBranchPrTasks(opts) {
504
509
  };
505
510
  }
506
511
  export async function syncHostedMergedTasks(opts) {
507
- if (opts.ctx.backendId !== "local" || opts.ctx.config.workflow_mode !== "branch_pr") {
512
+ if (!backendUsesLocalTaskStore(opts.ctx) || opts.ctx.config.workflow_mode !== "branch_pr") {
508
513
  return { tasks: opts.tasks, synced: 0 };
509
514
  }
510
515
  const nextTasks = [];
@@ -1 +1 @@
1
- {"version":3,"file":"list.run.d.ts","sourceRoot":"","sources":["../../../src/commands/task/list.run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACvE,KAAK,UAAU,EAAE,GAAG,cAAc,KAAG,OAAO,CAAC,MAAM,CAAC,CAOnE"}
1
+ {"version":3,"file":"list.run.d.ts","sourceRoot":"","sources":["../../../src/commands/task/list.run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,IACvE,KAAK,UAAU,EAAE,GAAG,cAAc,KAAG,OAAO,CAAC,MAAM,CAAC,CAiBnE"}
@@ -1,9 +1,19 @@
1
- import { taskListUsecase } from "../../usecases/task/task-list-usecase.js";
1
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
2
+ import { cmdTaskList } from "./list.js";
2
3
  export function makeRunTaskListHandler(getCtx) {
3
4
  return async (ctx, p) => {
4
- return await taskListUsecase({
5
- cli: ctx,
6
- command: await getCtx("task list"),
5
+ const command = await getCtx("task list");
6
+ const execution = await makeReadOnlyExecutionContext(command);
7
+ void execution.policy.evaluate({
8
+ action: "task_list",
9
+ config: execution.config,
10
+ taskId: "",
11
+ git: { stagedPaths: [] },
12
+ });
13
+ return await cmdTaskList({
14
+ ctx: execution.command,
15
+ cwd: ctx.cwd,
16
+ rootOverride: ctx.rootOverride,
7
17
  filters: p.filters,
8
18
  });
9
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"new.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/new.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,GAClE,cAAc,CAAC,aAAa,CAAC,CAI/B"}
1
+ {"version":3,"file":"new.command.d.ts","sourceRoot":"","sources":["../../../src/commands/task/new.command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,MAAM,wBAAwB,CAAC;AAGzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,CAAC,sBAAsB,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,GAClE,cAAc,CAAC,aAAa,CAAC,CAkB/B"}
@@ -1,7 +1,21 @@
1
- import { taskNewUsecase } from "../../usecases/task/task-new-usecase.js";
1
+ import { makeExecutionContext } from "../../runtime/execution-context.js";
2
+ import { runTaskNewParsed } from "./new.js";
2
3
  export { taskNewSpec } from "./new.spec.js";
3
4
  export function makeRunTaskNewHandler(getCtx) {
4
5
  return async (ctx, p) => {
5
- return await taskNewUsecase({ cli: ctx, command: await getCtx("task new"), parsed: p });
6
+ const command = await getCtx("task new");
7
+ const execution = await makeExecutionContext(command);
8
+ void execution.policy.evaluate({
9
+ action: "task_new",
10
+ config: execution.config,
11
+ taskId: "",
12
+ git: { stagedPaths: [] },
13
+ });
14
+ return await runTaskNewParsed({
15
+ ctx: execution.command,
16
+ cwd: ctx.cwd,
17
+ rootOverride: ctx.rootOverride,
18
+ parsed: p,
19
+ });
6
20
  };
7
21
  }
@@ -2,9 +2,9 @@ import { setMarkdownSection } from "@agentplaneorg/core";
2
2
  import { mapBackendError } from "../../cli/error-map.js";
3
3
  import { backendNotSupportedMessage, warnMessage } from "../../cli/output.js";
4
4
  import { createClarificationContract, createTaskGraphDraft, createTaskIntakeContext, materializeTaskGraphDraft, } from "../../runtime/task-intake/index.js";
5
+ import { makeReadOnlyExecutionContext } from "../../runtime/execution-context.js";
5
6
  import { CliError } from "../../shared/errors.js";
6
7
  import { buildTaskDocState } from "../../shared/task-doc-state.js";
7
- import { makeReadOnlyUsecaseContext } from "../../usecases/context/resolve-context.js";
8
8
  import { loadCommandContext } from "../shared/task-backend.js";
9
9
  import { ensureTaskDependsOnGraphIsAcyclic, nowIso, requiresVerifyStepsByPrimary, resolvePrimaryTag, warnIfUnknownOwner, } from "./shared.js";
10
10
  import { buildDefaultVerifyStepsSection, defaultTaskDocV3, TASK_DOC_VERSION_V3, } from "./doc-template.js";
@@ -139,7 +139,7 @@ export async function runTaskNewParsed(opts) {
139
139
  });
140
140
  }
141
141
  const taskId = await ctx.taskBackend.generateTaskId({ length: suffixLength, attempts: 1000 });
142
- const executionContext = await makeReadOnlyUsecaseContext(ctx);
142
+ const executionContext = await makeReadOnlyExecutionContext(ctx);
143
143
  const createdAt = nowIso();
144
144
  const docState = buildTaskDocState({
145
145
  doc: defaultTaskDocV3({ title: p.title, description: p.description }),
@@ -1 +1 @@
1
- {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/task/show.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AA4BnC,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsClB"}
1
+ {"version":3,"file":"show.d.ts","sourceRoot":"","sources":["../../../src/commands/task/show.ts"],"names":[],"mappings":"AAOA,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AA4BnC,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAsClB"}
@@ -3,9 +3,9 @@ import { readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { mapBackendError } from "../../cli/error-map.js";
5
5
  import { CliError } from "../../shared/errors.js";
6
- import { loadCommandContext, loadTaskFromContext, taskDataToFrontmatter, } from "../shared/task-backend.js";
6
+ import { backendSupportsTaskBranchSnapshots, loadCommandContext, loadTaskFromContext, taskDataToFrontmatter, } from "../shared/task-backend.js";
7
7
  async function detectLocalTaskMetadataErrors(ctx, taskId) {
8
- if (ctx.backendId !== "local")
8
+ if (!backendSupportsTaskBranchSnapshots(ctx))
9
9
  return null;
10
10
  const readmePath = taskReadmePath(path.join(ctx.resolvedProject.gitRoot, ctx.config.paths.workflow_dir), taskId);
11
11
  try {
@@ -32,7 +32,7 @@ export async function cmdTaskShow(opts) {
32
32
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
33
33
  const task = await loadTaskFromContext({ ctx, taskId: opts.taskId });
34
34
  const frontmatter = taskDataToFrontmatter(task);
35
- if (ctx.backendId === "local") {
35
+ if (backendSupportsTaskBranchSnapshots(ctx)) {
36
36
  const metadataErrors = validateTaskDocMetadata(frontmatter);
37
37
  if (metadataErrors.length > 0) {
38
38
  throw new CliError({
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/task/update.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAWpF,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CA6ElB"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/task/update.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAapF,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,GAAG,CAAC,EAAE,cAAc,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAiFlB"}
@@ -1,8 +1,9 @@
1
1
  import { mapBackendError } from "../../cli/error-map.js";
2
- import { successMessage, unknownEntityMessage, warnMessage } from "../../cli/output.js";
2
+ import { createCliEmitter, emitCommandResult, unknownEntityMessage } from "../../cli/output.js";
3
3
  import { CliError } from "../../shared/errors.js";
4
4
  import { loadCommandContext } from "../shared/task-backend.js";
5
5
  import { dedupeStrings, ensureTaskDependsOnGraphIsAcyclic, requiresVerifyStepsByPrimary, readTaskTagPolicy, resolvePrimaryTag, toStringArray, warnIfUnknownOwner, } from "./shared.js";
6
+ const output = createCliEmitter();
6
7
  export async function cmdTaskUpdate(opts) {
7
8
  try {
8
9
  const ctx = opts.ctx ??
@@ -46,7 +47,10 @@ export async function cmdTaskUpdate(opts) {
46
47
  const hasSpike = mergedTags.some((tag) => tag.trim().toLowerCase() === spikeTag);
47
48
  const hasImplementationTags = requiresVerifyStepsByPrimary(mergedTags, ctx.config);
48
49
  if (hasSpike && hasImplementationTags) {
49
- process.stderr.write(`${warnMessage("spike is combined with a primary tag that requires verify steps; consider splitting spike vs implementation tasks")}\n`);
50
+ emitCommandResult(output, {
51
+ kind: "warn",
52
+ message: "spike is combined with a primary tag that requires verify steps; consider splitting spike vs implementation tasks",
53
+ });
50
54
  }
51
55
  const existingDepends = opts.replaceDependsOn
52
56
  ? []
@@ -62,7 +66,11 @@ export async function cmdTaskUpdate(opts) {
62
66
  const mergedVerify = dedupeStrings([...existingVerify, ...opts.verify]);
63
67
  next.verify = mergedVerify;
64
68
  await ctx.taskBackend.writeTask(next);
65
- process.stdout.write(`${successMessage("updated", opts.taskId)}\n`);
69
+ emitCommandResult(output, {
70
+ kind: "success",
71
+ action: "updated",
72
+ target: opts.taskId,
73
+ });
66
74
  return 0;
67
75
  }
68
76
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../src/runner/adapters/codex.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAkMrB,qBAAa,kBAAmB,YAAW,aAAa;IACtD,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAE/B,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,yBAAyB;IAI7E,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiD/D,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAkN7D"}
1
+ {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../../src/runner/adapters/codex.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAmKrB,qBAAa,kBAAmB,YAAW,aAAa;IACtD,QAAQ,CAAC,EAAE,EAAG,OAAO,CAAU;IAE/B,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,yBAAyB;IAI7E,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiD/D,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAkN7D"}
@@ -3,7 +3,8 @@ import path from "node:path";
3
3
  import { exitCodeForError } from "../../cli/exit-codes.js";
4
4
  import { CliError } from "../../shared/errors.js";
5
5
  import { evolveRunnerRunState } from "../artifacts.js";
6
- import { runnerArtifactsFromSpecs, runnerAdapterCancelledResult, runnerAdapterFailureResult, runnerAdapterSuccessResult, } from "./shared.js";
6
+ import { runnerAdapterCancelledResult, runnerAdapterFailureResult, runnerAdapterSuccessResult, } from "./shared.js";
7
+ import { buildInvocationEventData, buildRunnerExecutionArtifacts, durationMs, } from "./runtime-shared.js";
7
8
  import { exitCodeForSignal, runSupervisedProcess, } from "../process-supervision.js";
8
9
  import { InvalidRunnerResultManifestError, applyRunnerResultManifest, manifestFromRunnerResult, preserveRunnerResultManifestSource, preserveInvalidRunnerResultManifest, readRunnerResultManifest, writeRunnerResultManifest, } from "../result-manifest.js";
9
10
  import { RunnerRunRepository } from "../run-repository.js";
@@ -31,26 +32,6 @@ const CODEX_RUN_PROFILE_CAPABILITIES = {
31
32
  function byteLength(text) {
32
33
  return Buffer.byteLength(text ?? "", "utf8");
33
34
  }
34
- function durationMs(startedAt, endedAt) {
35
- const started = Date.parse(startedAt);
36
- const ended = Date.parse(endedAt);
37
- if (Number.isNaN(started) || Number.isNaN(ended))
38
- return undefined;
39
- return Math.max(0, ended - started);
40
- }
41
- function buildInvocationEventData(invocation) {
42
- return {
43
- executable: invocation.argv[0] ?? null,
44
- argv_count: invocation.argv.length,
45
- cwd: invocation.run_dir,
46
- env_keys: Object.keys(invocation.env).toSorted(),
47
- trace_policy: invocation.trace_policy,
48
- timeout_policy: invocation.timeout_policy,
49
- has_bootstrap_path: typeof invocation.bootstrap_path === "string" && invocation.bootstrap_path.trim().length > 0,
50
- has_output_last_message_path: typeof invocation.output_last_message_path === "string" &&
51
- invocation.output_last_message_path.trim().length > 0,
52
- };
53
- }
54
35
  async function readOptionalText(filePath) {
55
36
  if (!filePath?.trim())
56
37
  return null;
@@ -62,18 +43,7 @@ async function readOptionalText(filePath) {
62
43
  }
63
44
  }
64
45
  function buildCodexArtifacts(opts) {
65
- return (runnerArtifactsFromSpecs([
66
- { path: opts.invocation.bundle_path, label: "bundle" },
67
- { path: opts.invocation.bootstrap_path, label: "bootstrap" },
68
- { path: opts.trace_artifact_path, label: "raw-trace" },
69
- { path: opts.trace_archive_path, label: "raw-trace-gzip" },
70
- { path: opts.stderr_artifact_path, label: "stderr-log" },
71
- { path: opts.stderr_archive_path, label: "stderr-log-gzip" },
72
- { path: opts.source_manifest_path, label: "source-result-manifest" },
73
- { path: opts.invocation.output_last_message_path, label: "assistant-last-message" },
74
- { path: opts.invalid_manifest_path, label: "invalid-result-manifest" },
75
- { path: opts.invocation.result_path, label: "result-manifest" },
76
- ]) ?? []);
46
+ return buildRunnerExecutionArtifacts({ ...opts, include_output_last_message: true });
77
47
  }
78
48
  function assertCodexBundle(bundle) {
79
49
  if (bundle.execution.adapter_id !== "codex") {
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../src/runner/adapters/custom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAEhB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AA+TrB,qBAAa,mBAAoB,YAAW,aAAa;IAG3C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;gBAEH,MAAM,EAAE,kBAAkB,GAAG,SAAS;IAEnE,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,yBAAyB;IAI7E,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmD/D,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAqN7D"}
1
+ {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../src/runner/adapters/custom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAI9D,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,gBAAgB,EAEhB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAoSrB,qBAAa,mBAAoB,YAAW,aAAa;IAG3C,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,QAAQ,CAAC,EAAE,EAAG,QAAQ,CAAU;gBAEH,MAAM,EAAE,kBAAkB,GAAG,SAAS;IAEnE,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,yBAAyB;IAI7E,OAAO,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmD/D,OAAO,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC;CAqN7D"}
@@ -2,7 +2,8 @@ import { readFile } from "node:fs/promises";
2
2
  import { exitCodeForError } from "../../cli/exit-codes.js";
3
3
  import { CliError } from "../../shared/errors.js";
4
4
  import { evolveRunnerRunState } from "../artifacts.js";
5
- import { runnerArtifactsFromSpecs, runnerAdapterCancelledResult, runnerAdapterFailureResult, runnerAdapterSuccessResult, } from "./shared.js";
5
+ import { runnerAdapterCancelledResult, runnerAdapterFailureResult, runnerAdapterSuccessResult, } from "./shared.js";
6
+ import { buildInvocationEventData, buildRunnerExecutionArtifacts, durationMs, } from "./runtime-shared.js";
6
7
  import { exitCodeForSignal, runSupervisedProcess, } from "../process-supervision.js";
7
8
  import { InvalidRunnerResultManifestError, manifestFromRunnerResult, preserveRunnerResultManifestSource, preserveInvalidRunnerResultManifest, readRunnerResultManifest, writeRunnerResultManifest, } from "../result-manifest.js";
8
9
  import { RunnerRunRepository } from "../run-repository.js";
@@ -144,24 +145,6 @@ function buildCustomCommand(opts) {
144
145
  ...opts.command,
145
146
  ];
146
147
  }
147
- function durationMs(startedAt, endedAt) {
148
- const started = Date.parse(startedAt);
149
- const ended = Date.parse(endedAt);
150
- if (Number.isNaN(started) || Number.isNaN(ended))
151
- return undefined;
152
- return Math.max(0, ended - started);
153
- }
154
- function buildInvocationEventData(invocation) {
155
- return {
156
- executable: invocation.argv[0] ?? null,
157
- argv_count: invocation.argv.length,
158
- cwd: invocation.run_dir,
159
- env_keys: Object.keys(invocation.env).toSorted(),
160
- trace_policy: invocation.trace_policy,
161
- timeout_policy: invocation.timeout_policy,
162
- has_bootstrap_path: typeof invocation.bootstrap_path === "string" && invocation.bootstrap_path.trim().length > 0,
163
- };
164
- }
165
148
  function normalizeCustomCommand(value) {
166
149
  return Array.isArray(value)
167
150
  ? value.map((entry) => entry.trim()).filter((entry) => entry.length > 0)
@@ -179,17 +162,7 @@ function assertCustomBundle(bundle) {
179
162
  }
180
163
  }
181
164
  function buildCustomArtifacts(opts) {
182
- return (runnerArtifactsFromSpecs([
183
- { path: opts.invocation.bundle_path, label: "bundle" },
184
- { path: opts.invocation.bootstrap_path, label: "bootstrap" },
185
- { path: opts.trace_artifact_path, label: "raw-trace" },
186
- { path: opts.trace_archive_path, label: "raw-trace-gzip" },
187
- { path: opts.stderr_artifact_path, label: "stderr-log" },
188
- { path: opts.stderr_archive_path, label: "stderr-log-gzip" },
189
- { path: opts.source_manifest_path, label: "source-result-manifest" },
190
- { path: opts.invalid_manifest_path, label: "invalid-result-manifest" },
191
- { path: opts.invocation.result_path, label: "result-manifest" },
192
- ]) ?? []);
165
+ return buildRunnerExecutionArtifacts({ ...opts, include_output_last_message: false });
193
166
  }
194
167
  function mergeRunnerArtifacts(base, extra) {
195
168
  const merged = [];
@@ -0,0 +1,14 @@
1
+ import type { RunnerInvocation, RunnerResult } from "../types.js";
2
+ export declare function durationMs(startedAt: string, endedAt: string): number | undefined;
3
+ export declare function buildInvocationEventData(invocation: RunnerInvocation, extra?: Record<string, unknown>): Record<string, unknown>;
4
+ export declare function buildRunnerExecutionArtifacts(opts: {
5
+ invocation: RunnerInvocation;
6
+ trace_artifact_path?: string | null;
7
+ trace_archive_path?: string | null;
8
+ stderr_artifact_path?: string | null;
9
+ stderr_archive_path?: string | null;
10
+ source_manifest_path?: string | null;
11
+ invalid_manifest_path?: string | null;
12
+ include_output_last_message?: boolean;
13
+ }): NonNullable<RunnerResult["artifacts"]>;
14
+ //# sourceMappingURL=runtime-shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-shared.d.ts","sourceRoot":"","sources":["../../../src/runner/adapters/runtime-shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlE,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKjF;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,gBAAgB,EAC5B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAClC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAYzB;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,UAAU,EAAE,gBAAgB,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC,GAAG,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAiBzC"}
@@ -0,0 +1,36 @@
1
+ import { runnerArtifactsFromSpecs } from "./shared.js";
2
+ export function durationMs(startedAt, endedAt) {
3
+ const started = Date.parse(startedAt);
4
+ const ended = Date.parse(endedAt);
5
+ if (Number.isNaN(started) || Number.isNaN(ended))
6
+ return undefined;
7
+ return Math.max(0, ended - started);
8
+ }
9
+ export function buildInvocationEventData(invocation, extra = {}) {
10
+ return {
11
+ executable: invocation.argv[0] ?? null,
12
+ argv_count: invocation.argv.length,
13
+ cwd: invocation.run_dir,
14
+ env_keys: Object.keys(invocation.env).toSorted(),
15
+ trace_policy: invocation.trace_policy,
16
+ timeout_policy: invocation.timeout_policy,
17
+ has_bootstrap_path: typeof invocation.bootstrap_path === "string" && invocation.bootstrap_path.trim().length > 0,
18
+ ...extra,
19
+ };
20
+ }
21
+ export function buildRunnerExecutionArtifacts(opts) {
22
+ return (runnerArtifactsFromSpecs([
23
+ { path: opts.invocation.bundle_path, label: "bundle" },
24
+ { path: opts.invocation.bootstrap_path, label: "bootstrap" },
25
+ { path: opts.trace_artifact_path, label: "raw-trace" },
26
+ { path: opts.trace_archive_path, label: "raw-trace-gzip" },
27
+ { path: opts.stderr_artifact_path, label: "stderr-log" },
28
+ { path: opts.stderr_archive_path, label: "stderr-log-gzip" },
29
+ { path: opts.source_manifest_path, label: "source-result-manifest" },
30
+ ...(opts.include_output_last_message
31
+ ? [{ path: opts.invocation.output_last_message_path, label: "assistant-last-message" }]
32
+ : []),
33
+ { path: opts.invalid_manifest_path, label: "invalid-result-manifest" },
34
+ { path: opts.invocation.result_path, label: "result-manifest" },
35
+ ]) ?? []);
36
+ }