agentplane 0.3.10 → 0.3.11

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 (228) hide show
  1. package/assets/policy/governance.md +3 -4
  2. package/assets/policy/incidents.md +19 -88
  3. package/assets/policy/workflow.branch_pr.md +1 -1
  4. package/assets/policy/workflow.direct.md +2 -2
  5. package/bin/agentplane.js +56 -1
  6. package/bin/runtime-watch.js +1 -0
  7. package/bin/stale-dist-policy.d.ts +1 -1
  8. package/bin/stale-dist-policy.js +13 -0
  9. package/dist/.build-manifest.json +219 -154
  10. package/dist/cli/bootstrap-guide.d.ts.map +1 -1
  11. package/dist/cli/bootstrap-guide.js +3 -2
  12. package/dist/cli/command-guide.d.ts.map +1 -1
  13. package/dist/cli/command-guide.js +2 -1
  14. package/dist/cli/command-invocations.d.ts.map +1 -1
  15. package/dist/cli/command-invocations.js +4 -1
  16. package/dist/cli/run-cli/command-catalog/project.d.ts +1 -1
  17. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  18. package/dist/cli/run-cli/command-catalog/project.js +3 -1
  19. package/dist/cli/run-cli/command-catalog/task.d.ts +1 -1
  20. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  21. package/dist/cli/run-cli/command-catalog/task.js +10 -0
  22. package/dist/cli/run-cli/command-catalog.d.ts +1 -1
  23. package/dist/cli/run-cli/command-catalog.d.ts.map +1 -1
  24. package/dist/cli/run-cli/commands/core/preflight.d.ts.map +1 -1
  25. package/dist/cli/run-cli/commands/core/preflight.js +44 -1
  26. package/dist/cli/run-cli.test-helpers.d.ts.map +1 -1
  27. package/dist/cli/run-cli.test-helpers.js +12 -0
  28. package/dist/commands/branch/cleanup-merged.d.ts +2 -0
  29. package/dist/commands/branch/cleanup-merged.d.ts.map +1 -1
  30. package/dist/commands/branch/cleanup-merged.js +132 -28
  31. package/dist/commands/branch/work-start.d.ts.map +1 -1
  32. package/dist/commands/branch/work-start.js +60 -1
  33. package/dist/commands/cleanup/merged.command.d.ts +2 -0
  34. package/dist/commands/cleanup/merged.command.d.ts.map +1 -1
  35. package/dist/commands/cleanup/merged.command.js +24 -0
  36. package/dist/commands/doctor/branch-pr.d.ts +4 -0
  37. package/dist/commands/doctor/branch-pr.d.ts.map +1 -0
  38. package/dist/commands/doctor/branch-pr.js +96 -0
  39. package/dist/commands/doctor/fixes.d.ts +5 -0
  40. package/dist/commands/doctor/fixes.d.ts.map +1 -1
  41. package/dist/commands/doctor/fixes.js +70 -0
  42. package/dist/commands/doctor.run.d.ts.map +1 -1
  43. package/dist/commands/doctor.run.js +6 -1
  44. package/dist/commands/finish.run.d.ts.map +1 -1
  45. package/dist/commands/finish.run.js +11 -0
  46. package/dist/commands/finish.spec.d.ts +11 -0
  47. package/dist/commands/finish.spec.d.ts.map +1 -1
  48. package/dist/commands/finish.spec.js +51 -0
  49. package/dist/commands/guard/impl/close-message.d.ts.map +1 -1
  50. package/dist/commands/guard/impl/close-message.js +23 -6
  51. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  52. package/dist/commands/guard/impl/commands.js +24 -2
  53. package/dist/commands/guard/impl/env.d.ts +1 -0
  54. package/dist/commands/guard/impl/env.d.ts.map +1 -1
  55. package/dist/commands/guard/impl/env.js +1 -0
  56. package/dist/commands/hooks/index.d.ts.map +1 -1
  57. package/dist/commands/hooks/index.js +98 -1
  58. package/dist/commands/incidents/collect.command.d.ts.map +1 -1
  59. package/dist/commands/incidents/collect.command.js +12 -7
  60. package/dist/commands/incidents/incidents.command.js +1 -1
  61. package/dist/commands/incidents/shared.d.ts +34 -0
  62. package/dist/commands/incidents/shared.d.ts.map +1 -1
  63. package/dist/commands/incidents/shared.js +166 -12
  64. package/dist/commands/pr/check.d.ts.map +1 -1
  65. package/dist/commands/pr/check.js +238 -135
  66. package/dist/commands/pr/close-superseded.d.ts +9 -0
  67. package/dist/commands/pr/close-superseded.d.ts.map +1 -0
  68. package/dist/commands/pr/close-superseded.js +129 -0
  69. package/dist/commands/pr/close.d.ts +11 -0
  70. package/dist/commands/pr/close.d.ts.map +1 -0
  71. package/dist/commands/pr/close.js +116 -0
  72. package/dist/commands/pr/index.d.ts +2 -0
  73. package/dist/commands/pr/index.d.ts.map +1 -1
  74. package/dist/commands/pr/index.js +2 -0
  75. package/dist/commands/pr/integrate/artifacts.d.ts +7 -0
  76. package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -1
  77. package/dist/commands/pr/integrate/artifacts.js +66 -1
  78. package/dist/commands/pr/integrate/cmd.d.ts.map +1 -1
  79. package/dist/commands/pr/integrate/cmd.js +16 -0
  80. package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts +8 -0
  81. package/dist/commands/pr/integrate/internal/bootstrap-guidance.d.ts.map +1 -0
  82. package/dist/commands/pr/integrate/internal/bootstrap-guidance.js +59 -0
  83. package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -1
  84. package/dist/commands/pr/integrate/internal/finalize.js +40 -12
  85. package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -1
  86. package/dist/commands/pr/integrate/internal/merge.js +36 -13
  87. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts +13 -0
  88. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.d.ts.map +1 -0
  89. package/dist/commands/pr/integrate/internal/post-integrate-bootstrap.js +25 -0
  90. package/dist/commands/pr/integrate/internal/prepare.d.ts +3 -2
  91. package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -1
  92. package/dist/commands/pr/integrate/internal/prepare.js +101 -38
  93. package/dist/commands/pr/internal/freshness.d.ts +20 -0
  94. package/dist/commands/pr/internal/freshness.d.ts.map +1 -0
  95. package/dist/commands/pr/internal/freshness.js +50 -0
  96. package/dist/commands/pr/internal/gh-api.d.ts +6 -0
  97. package/dist/commands/pr/internal/gh-api.d.ts.map +1 -0
  98. package/dist/commands/pr/internal/gh-api.js +80 -0
  99. package/dist/commands/pr/internal/pr-paths.d.ts +10 -0
  100. package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -1
  101. package/dist/commands/pr/internal/pr-paths.js +10 -0
  102. package/dist/commands/pr/internal/review-template.d.ts.map +1 -1
  103. package/dist/commands/pr/internal/review-template.js +37 -4
  104. package/dist/commands/pr/internal/sync.d.ts +9 -0
  105. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  106. package/dist/commands/pr/internal/sync.js +462 -122
  107. package/dist/commands/pr/open.d.ts +1 -0
  108. package/dist/commands/pr/open.d.ts.map +1 -1
  109. package/dist/commands/pr/open.js +13 -2
  110. package/dist/commands/pr/pr.command.d.ts +15 -0
  111. package/dist/commands/pr/pr.command.d.ts.map +1 -1
  112. package/dist/commands/pr/pr.command.js +118 -2
  113. package/dist/commands/pr/update.d.ts.map +1 -1
  114. package/dist/commands/pr/update.js +59 -1
  115. package/dist/commands/release/apply.command.d.ts.map +1 -1
  116. package/dist/commands/release/apply.command.js +3 -17
  117. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  118. package/dist/commands/release/apply.preflight.js +1 -1
  119. package/dist/commands/shared/gh-transport.d.ts +16 -0
  120. package/dist/commands/shared/gh-transport.d.ts.map +1 -0
  121. package/dist/commands/shared/gh-transport.js +71 -0
  122. package/dist/commands/shared/git-diff.d.ts +3 -1
  123. package/dist/commands/shared/git-diff.d.ts.map +1 -1
  124. package/dist/commands/shared/git-diff.js +10 -2
  125. package/dist/commands/shared/git-ops.d.ts +1 -0
  126. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  127. package/dist/commands/shared/git-ops.js +15 -0
  128. package/dist/commands/shared/git-worktree.d.ts +2 -0
  129. package/dist/commands/shared/git-worktree.d.ts.map +1 -1
  130. package/dist/commands/shared/git-worktree.js +22 -2
  131. package/dist/commands/shared/post-commit-pr-artifacts.d.ts +9 -0
  132. package/dist/commands/shared/post-commit-pr-artifacts.d.ts.map +1 -0
  133. package/dist/commands/shared/post-commit-pr-artifacts.js +22 -0
  134. package/dist/commands/shared/pr-meta.d.ts +20 -0
  135. package/dist/commands/shared/pr-meta.d.ts.map +1 -1
  136. package/dist/commands/shared/pr-meta.js +125 -0
  137. package/dist/commands/shared/task-backend.d.ts +7 -0
  138. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  139. package/dist/commands/shared/task-backend.js +34 -22
  140. package/dist/commands/task/close-duplicate.d.ts.map +1 -1
  141. package/dist/commands/task/close-duplicate.js +34 -1
  142. package/dist/commands/task/derive.js +1 -1
  143. package/dist/commands/task/doc-template.d.ts.map +1 -1
  144. package/dist/commands/task/doc-template.js +7 -11
  145. package/dist/commands/task/findings-add.command.d.ts +20 -0
  146. package/dist/commands/task/findings-add.command.d.ts.map +1 -0
  147. package/dist/commands/task/findings-add.command.js +165 -0
  148. package/dist/commands/task/findings.command.d.ts +7 -0
  149. package/dist/commands/task/findings.command.d.ts.map +1 -0
  150. package/dist/commands/task/findings.command.js +20 -0
  151. package/dist/commands/task/findings.d.ts +63 -0
  152. package/dist/commands/task/findings.d.ts.map +1 -0
  153. package/dist/commands/task/findings.js +188 -0
  154. package/dist/commands/task/finish-shared.d.ts +1 -0
  155. package/dist/commands/task/finish-shared.d.ts.map +1 -1
  156. package/dist/commands/task/finish-shared.js +55 -1
  157. package/dist/commands/task/finish.d.ts +10 -0
  158. package/dist/commands/task/finish.d.ts.map +1 -1
  159. package/dist/commands/task/finish.js +125 -6
  160. package/dist/commands/task/hosted-close-pr.command.d.ts +11 -0
  161. package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -0
  162. package/dist/commands/task/hosted-close-pr.command.js +414 -0
  163. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  164. package/dist/commands/task/hosted-close.command.js +49 -1
  165. package/dist/commands/task/hosted-merge-sync.d.ts +38 -0
  166. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  167. package/dist/commands/task/hosted-merge-sync.js +249 -17
  168. package/dist/commands/task/index.d.ts +1 -0
  169. package/dist/commands/task/index.d.ts.map +1 -1
  170. package/dist/commands/task/index.js +1 -0
  171. package/dist/commands/task/new.d.ts +1 -0
  172. package/dist/commands/task/new.d.ts.map +1 -1
  173. package/dist/commands/task/new.js +71 -1
  174. package/dist/commands/task/new.spec.d.ts.map +1 -1
  175. package/dist/commands/task/new.spec.js +7 -0
  176. package/dist/commands/task/normalize.command.d.ts +2 -0
  177. package/dist/commands/task/normalize.command.d.ts.map +1 -1
  178. package/dist/commands/task/normalize.command.js +45 -0
  179. package/dist/commands/task/normalize.d.ts +2 -0
  180. package/dist/commands/task/normalize.d.ts.map +1 -1
  181. package/dist/commands/task/normalize.js +85 -8
  182. package/dist/commands/task/plan.d.ts.map +1 -1
  183. package/dist/commands/task/plan.js +7 -10
  184. package/dist/commands/task/shared/docs.d.ts +6 -0
  185. package/dist/commands/task/shared/docs.d.ts.map +1 -1
  186. package/dist/commands/task/shared/docs.js +14 -0
  187. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  188. package/dist/commands/task/shared/transitions.js +11 -1
  189. package/dist/commands/task/shared.d.ts +1 -1
  190. package/dist/commands/task/shared.d.ts.map +1 -1
  191. package/dist/commands/task/shared.js +1 -1
  192. package/dist/commands/task/start-ready.d.ts.map +1 -1
  193. package/dist/commands/task/start-ready.js +86 -0
  194. package/dist/commands/task/start.d.ts.map +1 -1
  195. package/dist/commands/task/start.js +7 -10
  196. package/dist/commands/task/task.command.d.ts.map +1 -1
  197. package/dist/commands/task/task.command.js +4 -0
  198. package/dist/commands/task/verify-command-shared.d.ts +19 -0
  199. package/dist/commands/task/verify-command-shared.d.ts.map +1 -1
  200. package/dist/commands/task/verify-command-shared.js +152 -1
  201. package/dist/commands/task/verify-ok.command.d.ts.map +1 -1
  202. package/dist/commands/task/verify-ok.command.js +15 -2
  203. package/dist/commands/task/verify-record.d.ts +36 -0
  204. package/dist/commands/task/verify-record.d.ts.map +1 -1
  205. package/dist/commands/task/verify-record.js +166 -11
  206. package/dist/commands/task/verify-rework.command.d.ts.map +1 -1
  207. package/dist/commands/task/verify-rework.command.js +15 -2
  208. package/dist/commands/task/verify-show.command.d.ts +1 -1
  209. package/dist/commands/task/verify-show.command.d.ts.map +1 -1
  210. package/dist/commands/task/verify-show.command.js +28 -1
  211. package/dist/commands/verify.run.d.ts.map +1 -1
  212. package/dist/commands/verify.run.js +12 -0
  213. package/dist/commands/verify.spec.d.ts +2 -6
  214. package/dist/commands/verify.spec.d.ts.map +1 -1
  215. package/dist/commands/verify.spec.js +30 -3
  216. package/dist/runtime/incidents/index.d.ts +1 -1
  217. package/dist/runtime/incidents/index.d.ts.map +1 -1
  218. package/dist/runtime/incidents/resolve.d.ts.map +1 -1
  219. package/dist/runtime/incidents/resolve.js +319 -73
  220. package/dist/runtime/incidents/types.d.ts +14 -2
  221. package/dist/runtime/incidents/types.d.ts.map +1 -1
  222. package/dist/shared/env.d.ts +1 -0
  223. package/dist/shared/env.d.ts.map +1 -1
  224. package/dist/shared/env.js +22 -1
  225. package/dist/shared/protected-paths.d.ts +1 -1
  226. package/dist/shared/protected-paths.d.ts.map +1 -1
  227. package/dist/shared/protected-paths.js +4 -0
  228. package/package.json +2 -2
@@ -6,24 +6,20 @@ import { exitCodeForError } from "../../../../cli/exit-codes.js";
6
6
  import { unknownEntityMessage, workflowModeMessage } from "../../../../cli/output.js";
7
7
  import { CliError } from "../../../../shared/errors.js";
8
8
  import { ensureGitClean } from "../../../guard/index.js";
9
- import { gitDiffNames, gitShowFile, toGitPath } from "../../../shared/git-diff.js";
9
+ import { gitDiffNames } from "../../../shared/git-diff.js";
10
10
  import { gitBranchExists, gitCurrentBranch, gitRevParse } from "../../../shared/git-ops.js";
11
- import { loadBackendTask, loadCommandContext, } from "../../../shared/task-backend.js";
11
+ import { findWorktreeForBranch } from "../../../shared/git-worktree.js";
12
+ import { loadCommandContext, loadTaskFromContext, resolveTaskBranchFromContext, } from "../../../shared/task-backend.js";
12
13
  import { ensurePlanApprovedIfRequired, ensureVerificationSatisfiedIfRequired, } from "../../../task/shared.js";
13
- import { resolvePrPaths } from "../../internal/pr-paths.js";
14
- import { readAndValidatePrArtifacts } from "../artifacts.js";
14
+ import { readPrArtifact, resolvePrPaths } from "../../internal/pr-paths.js";
15
+ import { ensurePrArtifactsSynced } from "../../internal/sync.js";
16
+ import { readAndValidatePrArtifacts, ensureCommittedPrArtifactsOnBranch } from "../artifacts.js";
15
17
  import { computeVerifyState } from "../verify.js";
16
- import { parsePrMeta } from "../../../shared/pr-meta.js";
17
- import { isTaskLocalOnlyAdvance } from "../../../shared/task-local-freshness.js";
18
+ import { parsePrMetaForwardCompatible } from "../../../shared/pr-meta.js";
19
+ import { assessPrArtifactFreshness } from "../../internal/freshness.js";
18
20
  export async function prepareIntegrate(opts) {
19
21
  const ctx = opts.ctx ??
20
22
  (await loadCommandContext({ cwd: opts.cwd, rootOverride: opts.rootOverride ?? null }));
21
- const { task } = await loadBackendTask({
22
- ctx,
23
- cwd: opts.cwd,
24
- rootOverride: opts.rootOverride,
25
- taskId: opts.taskId,
26
- });
27
23
  const resolved = ctx.resolvedProject;
28
24
  const loadedConfig = ctx.config;
29
25
  if (loadedConfig.workflow_mode !== "branch_pr") {
@@ -33,8 +29,6 @@ export async function prepareIntegrate(opts) {
33
29
  message: workflowModeMessage(loadedConfig.workflow_mode, "branch_pr"),
34
30
  });
35
31
  }
36
- ensurePlanApprovedIfRequired(task, loadedConfig);
37
- ensureVerificationSatisfiedIfRequired(task, loadedConfig);
38
32
  await ensureGitClean({ cwd: opts.cwd, rootOverride: opts.rootOverride });
39
33
  if (opts.base?.trim().length === 0) {
40
34
  throw new CliError({
@@ -73,10 +67,16 @@ export async function prepareIntegrate(opts) {
73
67
  let meta = null;
74
68
  let branch = (opts.branch ?? "").trim();
75
69
  if (await fileExists(metaPath)) {
76
- meta = parsePrMeta(await readFile(metaPath, "utf8"), task.id);
70
+ meta = parsePrMetaForwardCompatible(await readFile(metaPath, "utf8"), opts.taskId);
77
71
  if (!branch)
78
72
  branch = (meta.branch ?? "").trim();
79
73
  }
74
+ if (!branch) {
75
+ const inferredBranch = await resolveTaskBranchFromContext({ ctx, taskId: opts.taskId });
76
+ if (inferredBranch) {
77
+ branch = inferredBranch;
78
+ }
79
+ }
80
80
  if (!branch) {
81
81
  throw new CliError({
82
82
  exitCode: 2,
@@ -91,8 +91,27 @@ export async function prepareIntegrate(opts) {
91
91
  message: unknownEntityMessage("branch", branch),
92
92
  });
93
93
  }
94
- const metaSource = meta ??
95
- parsePrMeta(await gitShowFile(resolved.gitRoot, branch, toGitPath(path.relative(resolved.gitRoot, metaPath))), task.id);
94
+ await ensureCommittedPrArtifactsOnBranch({
95
+ resolved,
96
+ prDir,
97
+ branch,
98
+ });
99
+ const worktreePath = await findWorktreeForBranch(resolved.gitRoot, branch);
100
+ const metaText = await readPrArtifact({
101
+ resolved,
102
+ prDir,
103
+ fileName: "meta.json",
104
+ branch,
105
+ worktreePath,
106
+ });
107
+ if (!metaText) {
108
+ throw new CliError({
109
+ exitCode: 4,
110
+ code: "E_IO",
111
+ message: `PR artifacts missing: ${path.relative(resolved.gitRoot, metaPath)} (run \`agentplane pr open\`)`,
112
+ });
113
+ }
114
+ let metaSource = parsePrMetaForwardCompatible(metaText, opts.taskId);
96
115
  const baseCandidate = opts.base ?? metaSource.base ?? baseBranch;
97
116
  const base = typeof baseCandidate === "string" && baseCandidate.trim().length > 0
98
117
  ? baseCandidate.trim()
@@ -103,10 +122,16 @@ export async function prepareIntegrate(opts) {
103
122
  prDir,
104
123
  metaPath,
105
124
  branch,
106
- taskId: task.id,
125
+ taskId: opts.taskId,
107
126
  });
108
127
  // readAndValidatePrArtifacts() throws if verify.log is missing; keep this non-null downstream.
109
- const verifyLogText = verifyLogTextMaybe;
128
+ let verifyLogText = verifyLogTextMaybe;
129
+ const task = await loadTaskFromContext({
130
+ ctx,
131
+ taskId: opts.taskId,
132
+ preferBranchSnapshot: true,
133
+ branchSnapshotBranch: branch,
134
+ });
110
135
  const changedPaths = await gitDiffNames(resolved.gitRoot, base, branch);
111
136
  const tasksPath = loadedConfig.paths.tasks_path;
112
137
  if (changedPaths.includes(tasksPath)) {
@@ -117,33 +142,71 @@ export async function prepareIntegrate(opts) {
117
142
  });
118
143
  }
119
144
  const branchHeadSha = await gitRevParse(resolved.gitRoot, [branch]);
120
- const reviewFresh = (metaSource.head_sha ?? null) === branchHeadSha ||
121
- (await isTaskLocalOnlyAdvance({
122
- gitRoot: resolved.gitRoot,
123
- workflowDir: loadedConfig.paths.workflow_dir,
124
- taskId: task.id,
125
- fromRef: metaSource.head_sha ?? null,
126
- toRef: branchHeadSha,
127
- }));
128
- if (!reviewFresh) {
145
+ let freshness = await assessPrArtifactFreshness({
146
+ gitRoot: resolved.gitRoot,
147
+ workflowDir: loadedConfig.paths.workflow_dir,
148
+ taskId: opts.taskId,
149
+ branchHeadSha,
150
+ metaHeadSha: metaSource.head_sha ?? null,
151
+ metaLastVerifiedSha: metaSource.last_verified_sha ?? null,
152
+ metaVerifyStatus: metaSource.verify?.status ?? null,
153
+ taskVerificationState: task.verification?.state ?? null,
154
+ verifyLogText,
155
+ requiresVerify: Boolean(task.verify && task.verify.length > 0),
156
+ });
157
+ if (!freshness.reviewFresh && worktreePath) {
158
+ await ensurePrArtifactsSynced({
159
+ cwd: worktreePath,
160
+ taskId: opts.taskId,
161
+ branch,
162
+ });
163
+ const repairedMetaText = await readPrArtifact({
164
+ resolved,
165
+ prDir,
166
+ fileName: "meta.json",
167
+ branch,
168
+ worktreePath,
169
+ });
170
+ if (repairedMetaText) {
171
+ const repairedMetaSource = parsePrMetaForwardCompatible(repairedMetaText, opts.taskId);
172
+ const repairedArtifacts = await readAndValidatePrArtifacts({
173
+ ctx,
174
+ resolved,
175
+ prDir,
176
+ metaPath,
177
+ branch,
178
+ taskId: opts.taskId,
179
+ });
180
+ verifyLogText = repairedArtifacts.verifyLogText ?? verifyLogText;
181
+ freshness = await assessPrArtifactFreshness({
182
+ gitRoot: resolved.gitRoot,
183
+ workflowDir: loadedConfig.paths.workflow_dir,
184
+ taskId: opts.taskId,
185
+ branchHeadSha,
186
+ metaHeadSha: repairedMetaSource.head_sha ?? null,
187
+ metaLastVerifiedSha: repairedMetaSource.last_verified_sha ?? null,
188
+ metaVerifyStatus: repairedMetaSource.verify?.status ?? null,
189
+ taskVerificationState: task.verification?.state ?? null,
190
+ verifyLogText,
191
+ requiresVerify: Boolean(task.verify && task.verify.length > 0),
192
+ });
193
+ meta = repairedMetaSource;
194
+ metaSource = repairedMetaSource;
195
+ }
196
+ }
197
+ if (!freshness.reviewFresh) {
129
198
  throw new CliError({
130
199
  exitCode: exitCodeForError("E_VALIDATION"),
131
200
  code: "E_VALIDATION",
132
- message: `PR artifacts stale for ${task.id}: meta.head_sha=${metaSource.head_sha ?? "<missing>"} ` +
201
+ message: `PR artifacts stale for ${opts.taskId}: meta.head_sha=${metaSource.head_sha ?? "<missing>"} ` +
133
202
  `current_head=${branchHeadSha} (refresh the task branch artifacts before integrate)`,
134
203
  });
135
204
  }
136
- const verifyFresh = (metaSource.last_verified_sha ?? null) === branchHeadSha ||
137
- (await isTaskLocalOnlyAdvance({
138
- gitRoot: resolved.gitRoot,
139
- workflowDir: loadedConfig.paths.workflow_dir,
140
- taskId: task.id,
141
- fromRef: metaSource.last_verified_sha ?? null,
142
- toRef: branchHeadSha,
143
- }));
205
+ ensurePlanApprovedIfRequired(task, loadedConfig);
206
+ ensureVerificationSatisfiedIfRequired(task, loadedConfig);
144
207
  const initialVerifyState = computeVerifyState({
145
208
  rawVerify: task.verify,
146
- metaLastVerifiedSha: verifyFresh ? branchHeadSha : (metaSource?.last_verified_sha ?? null),
209
+ metaLastVerifiedSha: freshness.effectiveVerifiedSha,
147
210
  verifyLogText,
148
211
  branchHeadSha,
149
212
  runVerify: opts.runVerify,
@@ -0,0 +1,20 @@
1
+ export type PrArtifactFreshness = {
2
+ reviewFresh: boolean;
3
+ verifyFresh: boolean;
4
+ verifySatisfied: boolean;
5
+ verifyLogSha: string | null;
6
+ effectiveVerifiedSha: string | null;
7
+ };
8
+ export declare function assessPrArtifactFreshness(opts: {
9
+ gitRoot: string;
10
+ workflowDir: string;
11
+ taskId: string;
12
+ branchHeadSha: string;
13
+ metaHeadSha: unknown;
14
+ metaLastVerifiedSha: unknown;
15
+ metaVerifyStatus: unknown;
16
+ taskVerificationState: unknown;
17
+ verifyLogText: string | null;
18
+ requiresVerify: boolean;
19
+ }): Promise<PrArtifactFreshness>;
20
+ //# sourceMappingURL=freshness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/freshness.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgD/B"}
@@ -0,0 +1,50 @@
1
+ import { extractLastVerifiedSha } from "../../shared/pr-meta.js";
2
+ import { isTaskLocalOnlyAdvance } from "../../shared/task-local-freshness.js";
3
+ function normalizeSha(value) {
4
+ if (typeof value !== "string")
5
+ return null;
6
+ const trimmed = value.trim();
7
+ return trimmed.length > 0 ? trimmed : null;
8
+ }
9
+ export async function assessPrArtifactFreshness(opts) {
10
+ const metaHeadSha = normalizeSha(opts.metaHeadSha);
11
+ const metaLastVerifiedSha = normalizeSha(opts.metaLastVerifiedSha);
12
+ const verifyLogSha = normalizeSha(extractLastVerifiedSha(opts.verifyLogText ?? ""));
13
+ const metaVerifyPassed = opts.metaVerifyStatus === "pass";
14
+ const reviewFresh = metaHeadSha === opts.branchHeadSha ||
15
+ (await isTaskLocalOnlyAdvance({
16
+ gitRoot: opts.gitRoot,
17
+ workflowDir: opts.workflowDir,
18
+ taskId: opts.taskId,
19
+ fromRef: metaHeadSha,
20
+ toRef: opts.branchHeadSha,
21
+ }));
22
+ if (!opts.requiresVerify) {
23
+ return {
24
+ reviewFresh,
25
+ verifyFresh: true,
26
+ verifySatisfied: true,
27
+ verifyLogSha,
28
+ effectiveVerifiedSha: null,
29
+ };
30
+ }
31
+ const verifiedFromMeta = metaVerifyPassed &&
32
+ (metaLastVerifiedSha === opts.branchHeadSha ||
33
+ (await isTaskLocalOnlyAdvance({
34
+ gitRoot: opts.gitRoot,
35
+ workflowDir: opts.workflowDir,
36
+ taskId: opts.taskId,
37
+ fromRef: metaLastVerifiedSha,
38
+ toRef: opts.branchHeadSha,
39
+ })));
40
+ const verifiedFromLog = verifyLogSha === opts.branchHeadSha;
41
+ const verifiedFromTaskState = opts.taskVerificationState === "ok" && reviewFresh && metaLastVerifiedSha === null;
42
+ const verifySatisfied = verifiedFromMeta || verifiedFromLog || verifiedFromTaskState;
43
+ return {
44
+ reviewFresh,
45
+ verifyFresh: verifySatisfied,
46
+ verifySatisfied,
47
+ verifyLogSha,
48
+ effectiveVerifiedSha: verifySatisfied ? opts.branchHeadSha : metaLastVerifiedSha,
49
+ };
50
+ }
@@ -0,0 +1,6 @@
1
+ export declare function ghEnv(): NodeJS.ProcessEnv;
2
+ export declare function resolveDefaultGithubRepo(cwd: string): Promise<string>;
3
+ export declare function runGhApiJson<T>(cwd: string, args: string[]): Promise<T>;
4
+ export declare function runGhApiNoOutput(cwd: string, args: string[]): Promise<void>;
5
+ export declare function isGhNotFound(err: unknown): boolean;
6
+ //# sourceMappingURL=gh-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gh-api.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/gh-api.ts"],"names":[],"mappings":"AAqBA,wBAAgB,KAAK,IAAI,MAAM,CAAC,UAAU,CAiBzC;AAED,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAe3E;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAa7E;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjF;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
@@ -0,0 +1,80 @@
1
+ import { execFile } from "node:child_process";
2
+ import { promisify } from "node:util";
3
+ import { exitCodeForError } from "../../../cli/exit-codes.js";
4
+ import { CliError } from "../../../shared/errors.js";
5
+ import { isDotEnvLoadedKey } from "../../../shared/env.js";
6
+ import { gitEnv } from "../../shared/git.js";
7
+ import { normalizeGhTransportError, withGhTransportRetry } from "../../shared/gh-transport.js";
8
+ const execFileAsyncRaw = promisify(execFile);
9
+ function parseGithubRepoFromRemoteUrl(remoteUrl) {
10
+ const trimmed = remoteUrl.trim();
11
+ if (!trimmed)
12
+ return null;
13
+ const httpsMatch = /^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(trimmed);
14
+ if (httpsMatch)
15
+ return `${httpsMatch[1]}/${httpsMatch[2]}`;
16
+ const sshMatch = /^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/.exec(trimmed);
17
+ if (sshMatch)
18
+ return `${sshMatch[1]}/${sshMatch[2]}`;
19
+ return null;
20
+ }
21
+ export function ghEnv() {
22
+ const env = gitEnv();
23
+ // Preserve explicit shell/CI auth, but do not let repo-local `.env` tokens override
24
+ // a valid gh keyring session for nested CLI invocations.
25
+ if (isDotEnvLoadedKey("GH_TOKEN"))
26
+ delete env.GH_TOKEN;
27
+ if (isDotEnvLoadedKey("GITHUB_TOKEN"))
28
+ delete env.GITHUB_TOKEN;
29
+ if (typeof process.env.GH_TOKEN === "string" && !isDotEnvLoadedKey("GH_TOKEN")) {
30
+ env.GH_TOKEN = process.env.GH_TOKEN;
31
+ }
32
+ if (typeof process.env.GITHUB_TOKEN === "string" && !isDotEnvLoadedKey("GITHUB_TOKEN")) {
33
+ env.GITHUB_TOKEN = process.env.GITHUB_TOKEN;
34
+ }
35
+ if (typeof process.env.GH_CONFIG_DIR === "string")
36
+ env.GH_CONFIG_DIR = process.env.GH_CONFIG_DIR;
37
+ if (typeof process.env.XDG_CONFIG_HOME === "string")
38
+ env.XDG_CONFIG_HOME = process.env.XDG_CONFIG_HOME;
39
+ if (typeof process.env.HOME === "string")
40
+ env.HOME = process.env.HOME;
41
+ return env;
42
+ }
43
+ export async function resolveDefaultGithubRepo(cwd) {
44
+ const { stdout } = await execFileAsyncRaw("git", ["remote", "get-url", "origin"], {
45
+ cwd,
46
+ env: gitEnv(),
47
+ maxBuffer: 10 * 1024 * 1024,
48
+ });
49
+ const repo = parseGithubRepoFromRemoteUrl(stdout);
50
+ if (!repo) {
51
+ throw new CliError({
52
+ exitCode: exitCodeForError("E_VALIDATION"),
53
+ code: "E_VALIDATION",
54
+ message: "Could not derive GitHub owner/repo from git remote origin.",
55
+ });
56
+ }
57
+ return repo;
58
+ }
59
+ export async function runGhApiJson(cwd, args) {
60
+ const { stdout } = await withGhTransportRetry(() => execFileAsyncRaw("gh", ["api", ...args], {
61
+ cwd,
62
+ env: ghEnv(),
63
+ maxBuffer: 10 * 1024 * 1024,
64
+ }), {
65
+ label: `running gh api ${args[0] ?? ""}`,
66
+ });
67
+ return JSON.parse(stdout);
68
+ }
69
+ export async function runGhApiNoOutput(cwd, args) {
70
+ await withGhTransportRetry(() => execFileAsyncRaw("gh", ["api", ...args], {
71
+ cwd,
72
+ env: ghEnv(),
73
+ maxBuffer: 10 * 1024 * 1024,
74
+ }), {
75
+ label: `running gh api ${args[0] ?? ""}`,
76
+ });
77
+ }
78
+ export function isGhNotFound(err) {
79
+ return /\b404\b/.test(normalizeGhTransportError(err));
80
+ }
@@ -28,5 +28,15 @@ export declare function readPrArtifact(opts: {
28
28
  prDir: string;
29
29
  fileName: string;
30
30
  branch: string;
31
+ worktreePath?: string | null;
32
+ }): Promise<string | null>;
33
+ export declare function readPrArtifactFromBranch(opts: {
34
+ resolved: {
35
+ gitRoot: string;
36
+ };
37
+ prDir: string;
38
+ fileName: string;
39
+ branch: string;
40
+ worktreePath?: string | null;
31
41
  }): Promise<string | null>;
32
42
  //# sourceMappingURL=pr-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pr-paths.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/pr-paths.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAsB,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AC;CAChB,GAAG,OAAO,CAAC,eAAe,CAAC,CAuB3B;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAMzB;AAED,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,QAAQ,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBzB"}
@@ -31,6 +31,16 @@ export async function readPrArtifact(opts) {
31
31
  if (await fileExists(filePath)) {
32
32
  return await readFile(filePath, "utf8");
33
33
  }
34
+ return await readPrArtifactFromBranch(opts);
35
+ }
36
+ export async function readPrArtifactFromBranch(opts) {
37
+ const filePath = path.join(opts.prDir, opts.fileName);
38
+ if (opts.worktreePath) {
39
+ const worktreeFilePath = path.join(opts.worktreePath, path.relative(opts.resolved.gitRoot, filePath));
40
+ if (await fileExists(worktreeFilePath)) {
41
+ return await readFile(worktreeFilePath, "utf8");
42
+ }
43
+ }
34
44
  const rel = toGitPath(path.relative(opts.resolved.gitRoot, filePath));
35
45
  try {
36
46
  return await gitShowFile(opts.resolved.gitRoot, opts.branch, rel);
@@ -1 +1 @@
1
- {"version":3,"file":"review-template.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/review-template.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,m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aAAa,EAAE,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,MAAM,CAST;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAiB7E;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAajF"}
@@ -65,7 +65,7 @@ function renderRiskSummary(task) {
65
65
  rollbackPlan,
66
66
  ].join("\n");
67
67
  }
68
- function renderSharedPrSections(opts) {
68
+ function renderReviewSections(opts) {
69
69
  return [
70
70
  SUMMARY_SECTION,
71
71
  "",
@@ -89,6 +89,40 @@ function renderSharedPrSections(opts) {
89
89
  "",
90
90
  ];
91
91
  }
92
+ function renderGithubVerificationSummary(task) {
93
+ const state = task.verification?.state ?? "pending";
94
+ const note = typeof task.verification?.note === "string" ? task.verification.note.trim() : "";
95
+ const statusLine = state === "ok"
96
+ ? note || "Recorded as passed."
97
+ : state === "needs_rework"
98
+ ? note || "Recorded as needs rework."
99
+ : note || "Not recorded yet.";
100
+ return [
101
+ `- State: ${state}`,
102
+ `- Note: ${statusLine}`,
103
+ "- Full verification checklist lives in local review.md.",
104
+ ].join("\n");
105
+ }
106
+ function renderGithubBodySections(opts) {
107
+ return [
108
+ SUMMARY_SECTION,
109
+ "",
110
+ sectionText(opts.task, "Summary", opts.task.title.trim() || "- Not recorded."),
111
+ "",
112
+ SCOPE_SECTION,
113
+ "",
114
+ sectionText(opts.task, "Scope", "- Not recorded."),
115
+ "",
116
+ VERIFICATION_SECTION,
117
+ "",
118
+ renderGithubVerificationSummary(opts.task),
119
+ "",
120
+ HANDOFF_NOTES_MARKER,
121
+ "",
122
+ ...renderPrHandoffNotes(opts.handoffNotes),
123
+ "",
124
+ ];
125
+ }
92
126
  export function buildGithubPrTitle(task) {
93
127
  const suffix = extractTaskSuffix(task.id);
94
128
  const scope = informativeTags(task).slice(0, 2).join("/");
@@ -160,7 +194,7 @@ export function renderPrReviewDocument(opts) {
160
194
  `Created: ${opts.createdAt || "UNKNOWN"}`,
161
195
  `Branch: ${opts.branch || "UNKNOWN"}`,
162
196
  "",
163
- ...renderSharedPrSections({
197
+ ...renderReviewSections({
164
198
  task: opts.task,
165
199
  handoffNotes: opts.handoffNotes ?? [],
166
200
  }),
@@ -172,7 +206,7 @@ export function renderPrReviewDocument(opts) {
172
206
  }
173
207
  export function renderGithubPrBody(opts) {
174
208
  return [
175
- ...renderSharedPrSections({
209
+ ...renderGithubBodySections({
176
210
  task: opts.task,
177
211
  handoffNotes: opts.handoffNotes ?? [],
178
212
  }),
@@ -204,7 +238,6 @@ export function validateGithubPrBodyContents(body, errors) {
204
238
  SUMMARY_SECTION,
205
239
  SCOPE_SECTION,
206
240
  VERIFICATION_SECTION,
207
- RISKS_SECTION,
208
241
  HANDOFF_NOTES_MARKER,
209
242
  ];
210
243
  for (const section of requiredSections) {
@@ -1,4 +1,10 @@
1
+ import { type PrMeta } from "../../shared/pr-meta.js";
1
2
  import { type CommandContext } from "../../shared/task-backend.js";
3
+ export type PrRemoteMode = "auto" | "sync-only";
4
+ export type PrOpenOutcome = {
5
+ action: "linked-existing" | "created" | "sync-only" | "staged";
6
+ message: string;
7
+ };
2
8
  type PrSyncMode = "open" | "update";
3
9
  export declare function ensurePrArtifactsSynced(opts: {
4
10
  ctx?: CommandContext;
@@ -22,11 +28,14 @@ export declare function syncPrArtifacts(opts: {
22
28
  mode: PrSyncMode;
23
29
  author?: string;
24
30
  branch?: string;
31
+ remoteMode?: PrRemoteMode;
25
32
  }): Promise<{
33
+ meta: PrMeta;
26
34
  prDir: string;
27
35
  resolved: {
28
36
  gitRoot: string;
29
37
  };
38
+ openOutcome?: PrOpenOutcome;
30
39
  }>;
31
40
  export {};
32
41
  //# sourceMappingURL=sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../src/commands/pr/internal/sync.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