@webpieces/pr-gate 0.4.975 → 0.4.977

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 (182) hide show
  1. package/package.json +6 -6
  2. package/src/scripts/commands/await-checks-command.d.ts +6 -3
  3. package/src/scripts/commands/await-checks-command.js +17 -12
  4. package/src/scripts/commands/await-checks-command.js.map +1 -1
  5. package/src/scripts/commands/await-reviews-command.d.ts +1 -1
  6. package/src/scripts/commands/await-reviews-command.js +3 -3
  7. package/src/scripts/commands/await-reviews-command.js.map +1 -1
  8. package/src/scripts/commands/check-pr-command.d.ts +3 -1
  9. package/src/scripts/commands/check-pr-command.js +12 -9
  10. package/src/scripts/commands/check-pr-command.js.map +1 -1
  11. package/src/scripts/commands/cleanup-command.js +12 -12
  12. package/src/scripts/commands/cleanup-command.js.map +1 -1
  13. package/src/scripts/commands/finish-push-dev-command.js +3 -4
  14. package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
  15. package/src/scripts/commands/finish-update-command.js +1 -1
  16. package/src/scripts/commands/finish-update-command.js.map +1 -1
  17. package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
  18. package/src/scripts/commands/finish-upsert-pr-command.js +65 -62
  19. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  20. package/src/scripts/commands/human-post-pr-command.d.ts +8 -6
  21. package/src/scripts/commands/human-post-pr-command.js +33 -32
  22. package/src/scripts/commands/human-post-pr-command.js.map +1 -1
  23. package/src/scripts/commands/land-pr-command.d.ts +5 -1
  24. package/src/scripts/commands/land-pr-command.js +37 -23
  25. package/src/scripts/commands/land-pr-command.js.map +1 -1
  26. package/src/scripts/commands/main-checkout.d.ts +4 -1
  27. package/src/scripts/commands/main-checkout.js +22 -22
  28. package/src/scripts/commands/main-checkout.js.map +1 -1
  29. package/src/scripts/commands/push-dev-command.js +28 -29
  30. package/src/scripts/commands/push-dev-command.js.map +1 -1
  31. package/src/scripts/commands/reap-worktree-command.js +4 -5
  32. package/src/scripts/commands/reap-worktree-command.js.map +1 -1
  33. package/src/scripts/commands/review-upsert-pr-command.js +10 -10
  34. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  35. package/src/scripts/commands/start-update-command.d.ts +1 -1
  36. package/src/scripts/commands/start-update-command.js +3 -3
  37. package/src/scripts/commands/start-update-command.js.map +1 -1
  38. package/src/scripts/commands/start-upsert-pr-command.js +4 -4
  39. package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
  40. package/src/scripts/commands/sync-main-command.js +6 -6
  41. package/src/scripts/commands/sync-main-command.js.map +1 -1
  42. package/src/scripts/commands/upsert-hotfix-pr-command.d.ts +6 -4
  43. package/src/scripts/commands/upsert-hotfix-pr-command.js +46 -43
  44. package/src/scripts/commands/upsert-hotfix-pr-command.js.map +1 -1
  45. package/src/scripts/commands/working-tree-gate.d.ts +4 -1
  46. package/src/scripts/commands/working-tree-gate.js +14 -11
  47. package/src/scripts/commands/working-tree-gate.js.map +1 -1
  48. package/src/scripts/commands/worktree-cleanup.d.ts +4 -4
  49. package/src/scripts/commands/worktree-cleanup.js +4 -4
  50. package/src/scripts/commands/worktree-cleanup.js.map +1 -1
  51. package/src/scripts/commands/write-review-command.js +4 -6
  52. package/src/scripts/commands/write-review-command.js.map +1 -1
  53. package/src/scripts/commands/write-review-fixes-command.js +3 -4
  54. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  55. package/src/scripts/git-finishUpsertPr.js +2 -2
  56. package/src/scripts/git-finishUpsertPr.js.map +1 -1
  57. package/src/scripts/git-gatherInfo.js +6 -7
  58. package/src/scripts/git-gatherInfo.js.map +1 -1
  59. package/src/scripts/pr-gate-container.d.ts +9 -0
  60. package/src/scripts/pr-gate-container.js +19 -0
  61. package/src/scripts/pr-gate-container.js.map +1 -0
  62. package/src/scripts/workflow/await-loop.d.ts +1 -1
  63. package/src/scripts/workflow/await-loop.js +1 -1
  64. package/src/scripts/workflow/await-loop.js.map +1 -1
  65. package/src/scripts/workflow/build-affected.js +1 -1
  66. package/src/scripts/workflow/build-affected.js.map +1 -1
  67. package/src/scripts/workflow/build-artifact-gate.d.ts +1 -1
  68. package/src/scripts/workflow/build-artifact-gate.js +3 -3
  69. package/src/scripts/workflow/build-artifact-gate.js.map +1 -1
  70. package/src/scripts/workflow/build-gate-log.d.ts +9 -6
  71. package/src/scripts/workflow/build-gate-log.js +34 -40
  72. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  73. package/src/scripts/workflow/checklist-detector.d.ts +2 -2
  74. package/src/scripts/workflow/checklist-detector.js +4 -4
  75. package/src/scripts/workflow/checklist-detector.js.map +1 -1
  76. package/src/scripts/workflow/checklist-scanner.d.ts +1 -1
  77. package/src/scripts/workflow/checklist-scanner.js +11 -11
  78. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  79. package/src/scripts/workflow/checklist-scope-hasher.d.ts +1 -1
  80. package/src/scripts/workflow/checklist-scope-hasher.js +2 -2
  81. package/src/scripts/workflow/checklist-scope-hasher.js.map +1 -1
  82. package/src/scripts/workflow/dev-deploy-refs.d.ts +5 -5
  83. package/src/scripts/workflow/dev-deploy-refs.js +8 -8
  84. package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
  85. package/src/scripts/workflow/dev-resolve-runner.d.ts +3 -3
  86. package/src/scripts/workflow/dev-resolve-runner.js +30 -30
  87. package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
  88. package/src/scripts/workflow/diff-basis.d.ts +4 -2
  89. package/src/scripts/workflow/diff-basis.js +18 -15
  90. package/src/scripts/workflow/diff-basis.js.map +1 -1
  91. package/src/scripts/workflow/diff-materializer.d.ts +5 -3
  92. package/src/scripts/workflow/diff-materializer.js +18 -15
  93. package/src/scripts/workflow/diff-materializer.js.map +1 -1
  94. package/src/scripts/workflow/gated-pr-publisher.d.ts +8 -6
  95. package/src/scripts/workflow/gated-pr-publisher.js +23 -22
  96. package/src/scripts/workflow/gated-pr-publisher.js.map +1 -1
  97. package/src/scripts/workflow/generated-artifact-registry.d.ts +4 -2
  98. package/src/scripts/workflow/generated-artifact-registry.js +11 -8
  99. package/src/scripts/workflow/generated-artifact-registry.js.map +1 -1
  100. package/src/scripts/workflow/git-exec.d.ts +22 -12
  101. package/src/scripts/workflow/git-exec.js +45 -29
  102. package/src/scripts/workflow/git-exec.js.map +1 -1
  103. package/src/scripts/workflow/git-findForkPoint.d.ts +6 -2
  104. package/src/scripts/workflow/git-findForkPoint.js +31 -23
  105. package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
  106. package/src/scripts/workflow/git-readAiBranchName.d.ts +4 -2
  107. package/src/scripts/workflow/git-readAiBranchName.js +8 -5
  108. package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
  109. package/src/scripts/workflow/hotfix-pr-publisher.d.ts +4 -3
  110. package/src/scripts/workflow/hotfix-pr-publisher.js +7 -6
  111. package/src/scripts/workflow/hotfix-pr-publisher.js.map +1 -1
  112. package/src/scripts/workflow/landed-tree-resolver.d.ts +4 -2
  113. package/src/scripts/workflow/landed-tree-resolver.js +11 -8
  114. package/src/scripts/workflow/landed-tree-resolver.js.map +1 -1
  115. package/src/scripts/workflow/landed-worktree-reaper.d.ts +4 -2
  116. package/src/scripts/workflow/landed-worktree-reaper.js +12 -9
  117. package/src/scripts/workflow/landed-worktree-reaper.js.map +1 -1
  118. package/src/scripts/workflow/merge-end.d.ts +5 -4
  119. package/src/scripts/workflow/merge-end.js +28 -27
  120. package/src/scripts/workflow/merge-end.js.map +1 -1
  121. package/src/scripts/workflow/merge-start.d.ts +5 -1
  122. package/src/scripts/workflow/merge-start.js +56 -49
  123. package/src/scripts/workflow/merge-start.js.map +1 -1
  124. package/src/scripts/workflow/open-pr-check.d.ts +4 -2
  125. package/src/scripts/workflow/open-pr-check.js +11 -8
  126. package/src/scripts/workflow/open-pr-check.js.map +1 -1
  127. package/src/scripts/workflow/pr-comment-upserter.d.ts +5 -3
  128. package/src/scripts/workflow/pr-comment-upserter.js +15 -14
  129. package/src/scripts/workflow/pr-comment-upserter.js.map +1 -1
  130. package/src/scripts/workflow/pr-context-writer.d.ts +1 -1
  131. package/src/scripts/workflow/pr-context-writer.js +3 -3
  132. package/src/scripts/workflow/pr-context-writer.js.map +1 -1
  133. package/src/scripts/workflow/pr-merger.d.ts +8 -5
  134. package/src/scripts/workflow/pr-merger.js +32 -27
  135. package/src/scripts/workflow/pr-merger.js.map +1 -1
  136. package/src/scripts/workflow/provenance-enforcer.d.ts +4 -2
  137. package/src/scripts/workflow/provenance-enforcer.js +19 -17
  138. package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
  139. package/src/scripts/workflow/review-round-state.d.ts +7 -6
  140. package/src/scripts/workflow/review-round-state.js +33 -38
  141. package/src/scripts/workflow/review-round-state.js.map +1 -1
  142. package/src/scripts/workflow/run-update.js +1 -1
  143. package/src/scripts/workflow/run-update.js.map +1 -1
  144. package/src/scripts/workflow/squash-settings-enforcer.d.ts +6 -3
  145. package/src/scripts/workflow/squash-settings-enforcer.js +19 -14
  146. package/src/scripts/workflow/squash-settings-enforcer.js.map +1 -1
  147. package/src/scripts/wp-await-checks.js +2 -2
  148. package/src/scripts/wp-await-checks.js.map +1 -1
  149. package/src/scripts/wp-await-reviews.js +2 -2
  150. package/src/scripts/wp-await-reviews.js.map +1 -1
  151. package/src/scripts/wp-build.js +2 -2
  152. package/src/scripts/wp-build.js.map +1 -1
  153. package/src/scripts/wp-check-pr.js +2 -2
  154. package/src/scripts/wp-check-pr.js.map +1 -1
  155. package/src/scripts/wp-cleanup.js +2 -2
  156. package/src/scripts/wp-cleanup.js.map +1 -1
  157. package/src/scripts/wp-finish-push-dev.js +2 -2
  158. package/src/scripts/wp-finish-push-dev.js.map +1 -1
  159. package/src/scripts/wp-finish-update.js +2 -2
  160. package/src/scripts/wp-finish-update.js.map +1 -1
  161. package/src/scripts/wp-human-post-pr.js +2 -2
  162. package/src/scripts/wp-human-post-pr.js.map +1 -1
  163. package/src/scripts/wp-land-pr.js +2 -2
  164. package/src/scripts/wp-land-pr.js.map +1 -1
  165. package/src/scripts/wp-push-dev.js +2 -2
  166. package/src/scripts/wp-push-dev.js.map +1 -1
  167. package/src/scripts/wp-reap-worktree.js +2 -2
  168. package/src/scripts/wp-reap-worktree.js.map +1 -1
  169. package/src/scripts/wp-review-upsert-pr.js +2 -2
  170. package/src/scripts/wp-review-upsert-pr.js.map +1 -1
  171. package/src/scripts/wp-start-update.js +2 -2
  172. package/src/scripts/wp-start-update.js.map +1 -1
  173. package/src/scripts/wp-start-upsert-pr.js +2 -2
  174. package/src/scripts/wp-start-upsert-pr.js.map +1 -1
  175. package/src/scripts/wp-sync-main.js +2 -2
  176. package/src/scripts/wp-sync-main.js.map +1 -1
  177. package/src/scripts/wp-upsert-hotfix-pr.js +2 -2
  178. package/src/scripts/wp-upsert-hotfix-pr.js.map +1 -1
  179. package/src/scripts/wp-write-review-fixes.js +2 -2
  180. package/src/scripts/wp-write-review-fixes.js.map +1 -1
  181. package/src/scripts/wp-write-review.js +2 -2
  182. package/src/scripts/wp-write-review.js.map +1 -1
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UpsertHotfixPrCommand = exports.HotfixPrRef = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const child_process_1 = require("child_process");
6
5
  const fs = tslib_1.__importStar(require("fs"));
7
6
  const path = tslib_1.__importStar(require("path"));
8
7
  const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
9
8
  const rules_config_1 = require("@webpieces/rules-config");
9
+ const tooling_common_1 = require("@webpieces/tooling-common");
10
10
  const inversify_1 = require("inversify");
11
11
  const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
12
12
  const git_exec_1 = require("../workflow/git-exec");
@@ -70,8 +70,9 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
70
70
  commentUpserter;
71
71
  squashSettings;
72
72
  gateTokenService;
73
+ processes;
73
74
  // eslint-disable-next-line @typescript-eslint/max-params
74
- constructor(repoRootFinder, branchIdentity, aiBranchName, gitExec, reviewJsonService, buildAffected, buildArtifactGate, mergeState, checklistScanner, publisher, dashboard, authorIdentity, checklistComment, commentUpserter, squashSettings, gateTokenService) {
75
+ constructor(repoRootFinder, branchIdentity, aiBranchName, gitExec, reviewJsonService, buildAffected, buildArtifactGate, mergeState, checklistScanner, publisher, dashboard, authorIdentity, checklistComment, commentUpserter, squashSettings, gateTokenService, processes) {
75
76
  this.repoRootFinder = repoRootFinder;
76
77
  this.branchIdentity = branchIdentity;
77
78
  this.aiBranchName = aiBranchName;
@@ -88,6 +89,7 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
88
89
  this.commentUpserter = commentUpserter;
89
90
  this.squashSettings = squashSettings;
90
91
  this.gateTokenService = gateTokenService;
92
+ this.processes = processes;
91
93
  }
92
94
  async run() {
93
95
  const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());
@@ -95,26 +97,26 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
95
97
  // FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.
96
98
  this.assertHotfixBranch(branch);
97
99
  (0, rules_config_1.writeTemplate)(repoRoot, 'webpieces.git-workflow.md');
98
- this.gitExec.assertCleanTree(repoRoot);
99
- this.assertNoUnvalidatedMerge(repoRoot);
100
- const featureName = this.aiBranchName.getFeatureName();
100
+ await this.gitExec.assertCleanTree(repoRoot);
101
+ await this.assertNoUnvalidatedMerge(repoRoot);
102
+ const featureName = await this.aiBranchName.getFeatureName();
101
103
  const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);
102
104
  // Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.
103
105
  const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
104
106
  // FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.
105
107
  new issue_references_1.IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
106
108
  // origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.
107
- this.fetchMain(repoRoot);
108
- const headBefore = this.headSha(repoRoot);
109
+ await this.fetchMain(repoRoot);
110
+ const headBefore = await this.headSha(repoRoot);
109
111
  await this.buildAffected.runBuildGate(repoRoot, new build_affected_1.BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', build_gate_log_1.FINISH_STAGE));
110
- this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);
111
- this.gitExec.assertCleanTree(repoRoot);
112
- if (this.headSha(repoRoot) !== headBefore) {
112
+ await this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);
113
+ await this.gitExec.assertCleanTree(repoRoot);
114
+ if (await this.headSha(repoRoot) !== headBefore) {
113
115
  throw new rules_config_1.CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}.`);
114
116
  }
115
- const ref = this.publish(repoRoot, branch, summary, headBefore);
116
- this.postComments(repoRoot, featureName, ref, summary);
117
- this.squashSettings.ensure();
117
+ const ref = await this.publish(repoRoot, branch, summary, headBefore);
118
+ await this.postComments(repoRoot, featureName, ref, summary);
119
+ await this.squashSettings.ensure();
118
120
  const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);
119
121
  if (archived !== '')
120
122
  process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\n`);
@@ -128,8 +130,8 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
128
130
  ' pnpm wp-start-upsert-pr\n pnpm wp-review-upsert-pr\n pnpm wp-finish-upsert-pr');
129
131
  }
130
132
  // A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.
131
- assertNoUnvalidatedMerge(repoRoot) {
132
- const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
133
+ async assertNoUnvalidatedMerge(repoRoot) {
134
+ const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());
133
135
  const active = this.mergeState.findActiveMergeRunDir(home);
134
136
  const marker = active === null ? null : this.mergeState.readMergeMarker(active);
135
137
  if (marker === null || marker.validated)
@@ -139,50 +141,50 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
139
141
  `commits, then re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`);
140
142
  }
141
143
  /** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */
142
- publish(repoRoot, branch, summary, headSha) {
144
+ async publish(repoRoot, branch, summary, headSha) {
143
145
  const config = this.prGateConfig(repoRoot);
144
- const input = this.dashboardInput(repoRoot, summary, config);
146
+ const input = await this.dashboardInput(repoRoot, summary, config);
145
147
  const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);
146
- const initial = this.prRef(branch);
148
+ const initial = await this.prRef(branch);
147
149
  const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;
148
150
  for (const warning of new issue_references_1.IssueReferences().closeWarnings(summary.addressesIssues))
149
151
  process.stdout.write(`${warning}\n`);
150
- const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, this.aiBranchName.getFeatureName()), 'pr-body.md');
152
+ const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, await this.aiBranchName.getFeatureName()), 'pr-body.md');
151
153
  fs.mkdirSync(path.dirname(bodyFile), { recursive: true });
152
154
  fs.writeFileSync(bodyFile, body + '\n');
153
155
  process.stdout.write('\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\n' + SEP + '\n');
154
- const published = this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
156
+ const published = await this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND);
155
157
  if (published.createFailed) {
156
158
  throw new rules_config_1.CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND}.`);
157
159
  }
158
- const ref = this.prRef(branch);
160
+ const ref = await this.prRef(branch);
159
161
  const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);
160
162
  // A brand-new PR had no URL to self-link until `gh pr create` returned one.
161
163
  const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;
162
164
  if (finalBody !== body && resolved.number !== '') {
163
165
  fs.writeFileSync(bodyFile, finalBody + '\n');
164
- if (!this.editPrBody(resolved.number, bodyFile)) {
166
+ if (!(await this.editPrBody(resolved.number, bodyFile))) {
165
167
  process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\n`);
166
168
  }
167
169
  }
168
170
  return resolved;
169
171
  }
170
- dashboardInput(repoRoot, summary, config) {
171
- const forkPoint = this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);
172
- const featureHead = this.git(repoRoot, ['rev-parse', 'HEAD']);
173
- const mainHead = this.git(repoRoot, ['rev-parse', 'origin/main']);
172
+ async dashboardInput(repoRoot, summary, config) {
173
+ const forkPoint = await this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);
174
+ const featureHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);
175
+ const mainHead = await this.git(repoRoot, ['rev-parse', 'origin/main']);
174
176
  const range = `${forkPoint}..${featureHead}`;
175
- const changedFiles = this.git(repoRoot, ['diff', range, '--name-only'])
177
+ const changedFiles = (await this.git(repoRoot, ['diff', range, '--name-only']))
176
178
  .split('\n')
177
179
  .filter((f) => f.trim() !== '');
178
180
  const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);
179
- const disables = this.dashboard.countAddedDisables(this.git(repoRoot, ['diff', range]));
181
+ const disables = this.dashboard.countAddedDisables(await this.git(repoRoot, ['diff', range]));
180
182
  const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);
181
183
  const title = this.titleFrom(summary, this.branchIdentity.current());
182
184
  return new dashboard_1.DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);
183
185
  }
184
186
  /** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */
185
- postComments(repoRoot, featureName, ref, summary) {
187
+ async postComments(repoRoot, featureName, ref, summary) {
186
188
  if (ref.number === '') {
187
189
  process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\n still carries the hotfix banner. Re-run ${hotfix_redirect_1.UPSERT_HOTFIX_PR_COMMAND} to post them.\n`);
188
190
  return;
@@ -193,14 +195,14 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
193
195
  detail.prNumber = ref.number;
194
196
  detail.marker = dashboard_1.DETAIL_COMMENT_MARKER;
195
197
  // The audit banner must be the FIRST thing on the comment, so the marker goes last.
196
- detail.body = this.dashboard.renderDetailComment(this.dashboardInput(repoRoot, summary, config)) + '\n\n' + dashboard_1.DETAIL_COMMENT_MARKER;
198
+ detail.body = this.dashboard.renderDetailComment(await this.dashboardInput(repoRoot, summary, config)) + '\n\n' + dashboard_1.DETAIL_COMMENT_MARKER;
197
199
  detail.payloadDir = prDir;
198
200
  detail.payloadName = 'detail-comment.json';
199
201
  detail.label = 'full dashboard comment';
200
- this.commentUpserter.upsert(detail);
202
+ await this.commentUpserter.upsert(detail);
201
203
  if (config.checklists.length === 0 || !config.checklistComments)
202
204
  return;
203
- const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
205
+ const scan = await this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
204
206
  const rows = scan.roster.entries.map((entry) => new checklist_comment_row_1.ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount));
205
207
  const roster = new pr_comment_upserter_1.PrCommentRequest();
206
208
  roster.prNumber = ref.number;
@@ -209,7 +211,7 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
209
211
  roster.payloadDir = prDir;
210
212
  roster.payloadName = 'checklist-comment.json';
211
213
  roster.label = 'checklist review comment';
212
- this.commentUpserter.upsert(roster);
214
+ await this.commentUpserter.upsert(roster);
213
215
  }
214
216
  closingBlock(ref, title, branch) {
215
217
  const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;
@@ -239,25 +241,25 @@ let UpsertHotfixPrCommand = class UpsertHotfixPrCommand {
239
241
  git(repoRoot, args) {
240
242
  return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);
241
243
  }
242
- // ── seams, protected so the spec drives them with no network, no gh and no webpieces.config.json ──
244
+ // ── seam, protected so the spec drives it with no webpieces.config.json ──
243
245
  prGateConfig(repoRoot) {
244
246
  return (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
245
247
  }
246
- fetchMain(repoRoot) {
247
- const out = this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);
248
+ async fetchMain(repoRoot) {
249
+ const out = await this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);
248
250
  if (out.ok)
249
251
  return;
250
252
  throw new rules_config_1.CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\n git said: ${out.stderr}`);
251
253
  }
252
- prRef(branch) {
253
- const out = (0, child_process_1.spawnSync)('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '"\\(.number)\\t\\(.url)"'], { encoding: 'utf8' });
254
- if (out.status !== 0)
254
+ async prRef(branch) {
255
+ const out = await this.processes.run('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '"\\(.number)\\t\\(.url)"']);
256
+ if (!out.ok)
255
257
  return new HotfixPrRef('', '');
256
- const parts = (out.stdout ?? '').trim().split('\t');
258
+ const parts = out.stdout.trim().split('\t');
257
259
  return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');
258
260
  }
259
- editPrBody(prNumber, bodyFile) {
260
- return (0, child_process_1.spawnSync)('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile], { stdio: 'inherit' }).status === 0;
261
+ async editPrBody(prNumber, bodyFile) {
262
+ return (await this.processes.passThrough('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile])).ok;
261
263
  }
262
264
  };
263
265
  exports.UpsertHotfixPrCommand = UpsertHotfixPrCommand;
@@ -278,6 +280,7 @@ exports.UpsertHotfixPrCommand = UpsertHotfixPrCommand = tslib_1.__decorate([
278
280
  checklist_comment_renderer_1.ChecklistCommentRenderer,
279
281
  pr_comment_upserter_1.PrCommentUpserter,
280
282
  squash_settings_enforcer_1.SquashSettingsEnforcer,
281
- rules_config_1.GateTokenService])
283
+ rules_config_1.GateTokenService,
284
+ tooling_common_1.NativeProcessApi])
282
285
  ], UpsertHotfixPrCommand);
283
286
  //# sourceMappingURL=upsert-hotfix-pr-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"upsert-hotfix-pr-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/upsert-hotfix-pr-command.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,+CAAyB;AACzB,mDAA6B;AAC7B,sEAA+D;AAC/D,0DAAqK;AACrK,yCAA2D;AAC3D,2EAAgE;AAChE,mDAA+C;AAC/C,+DAA6E;AAC7E,yEAAoE;AACpE,+DAA0D;AAC1D,yDAAqD;AACrD,qEAAuF;AAEvF,yEAAoE;AACpE,iEAAuE;AACvE,yEAAsF;AACtF,mFAA8E;AAC9E,yDAA6F;AAC7F,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AqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QACd,mCAAc;QAChB,mCAAY;QACjB,kBAAO;QACG,gCAAiB;QACrB,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACJ,oCAAgB;QACvB,uCAAiB;QACjB,qBAAS;QACJ,wCAAsB;QACpB,qDAAwB;QACzB,uCAAiB;QAClB,iDAAsB;QACpB,+BAAgB;GAlB9C,qBAAqB,CA0NjC","sourcesContent":["import { spawnSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { CliExitError, GateTokenService, PrGateConfig, PrSummary, RepoRootFinder, ReviewJsonService, loadAndValidate, writeTemplate } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { GitExec } from '../workflow/git-exec';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { FINISH_STAGE } from '../workflow/build-gate-log';\nimport { MergeState } from '../workflow/merge-state';\nimport { ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { TriggeredChecklist } from '../workflow/checklist-detector';\nimport { HotfixPrPublisher } from '../workflow/hotfix-pr-publisher';\nimport { UPSERT_HOTFIX_PR_COMMAND } from '../workflow/hotfix-redirect';\nimport { PrCommentRequest, PrCommentUpserter } from '../workflow/pr-comment-upserter';\nimport { SquashSettingsEnforcer } from '../workflow/squash-settings-enforcer';\nimport { Dashboard, DashboardInput, DETAIL_COMMENT_MARKER } from '../../dashboard/dashboard';\nimport { ChecklistCommentRenderer, CHECKLIST_COMMENT_MARKER } from '../../dashboard/checklist-comment-renderer';\nimport { ChecklistCommentRow } from '../../dashboard/checklist-comment-row';\nimport { AuthorIdentityResolver } from '../../dashboard/author-identity';\nimport { IssueReferences } from '../../dashboard/issue-references';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The PR this run landed on. Both '' when it could not be resolved. Data-only, per CLAUDE.md. */\nexport class HotfixPrRef {\n number: string;\n url: string;\n\n constructor(number: string, url: string) {\n this.number = number;\n this.url = url;\n }\n}\n\n/**\n * `wp-upsert-hotfix-pr` — the ONE command that publishes a `/hotfix/` branch (issue #1057).\n *\n * A hotfix branch is cut from the exact sha running in production, so that what ships is production plus\n * the fix and nothing else. The three-stage PR flow cannot publish it: stage ① merges main into the branch,\n * which turns \"prod + fix\" into \"main + fix\" and ships every commit that has landed but has not been\n * promoted. And a hotfix runs no reviewers, so the stages have nothing to do between them. This is the\n * whole flow, in one command, in this order:\n *\n * 1. refuse unless the branch carries the exact, case-sensitive `/hotfix/` segment;\n * 2. require a clean tree and summary.json — a missing one prints its path and schema and exits;\n * 3. run ONLY the `hotfix-ci` gate (build + test). Red means nothing is pushed;\n * 4. NEVER merge main into the branch, never squash it, never rewrite it — HEAD is checked unchanged;\n * 5. push ONCE, fast-forward only, as a child process (pr-creation-or-push-guard stays intact);\n * 6. create or update the audit-bannered PR to main, and NEVER enable auto-merge — the consumer merges\n * after it has deployed and verified the hotfix. Re-running after another commit pushes again and\n * updates the same PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class UpsertHotfixPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly checklistScanner: ChecklistScanner,\n private readonly publisher: HotfixPrPublisher,\n private readonly dashboard: Dashboard,\n private readonly authorIdentity: AuthorIdentityResolver,\n private readonly checklistComment: ChecklistCommentRenderer,\n private readonly commentUpserter: PrCommentUpserter,\n private readonly squashSettings: SquashSettingsEnforcer,\n private readonly gateTokenService: GateTokenService,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n const branch = this.branchIdentity.current();\n // FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.\n this.assertHotfixBranch(branch);\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n this.gitExec.assertCleanTree(repoRoot);\n this.assertNoUnvalidatedMerge(repoRoot);\n\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);\n // Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.\n const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, UPSERT_HOTFIX_PR_COMMAND);\n // FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.\n new IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, UPSERT_HOTFIX_PR_COMMAND);\n\n // origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.\n this.fetchMain(repoRoot);\n const headBefore = this.headSha(repoRoot);\n await this.buildAffected.runBuildGate(\n repoRoot,\n new BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', FINISH_STAGE),\n );\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n if (this.headSha(repoRoot) !== headBefore) {\n throw new CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n\n const ref = this.publish(repoRoot, branch, summary, headBefore);\n this.postComments(repoRoot, featureName, ref, summary);\n this.squashSettings.ensure();\n const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);\n if (archived !== '') process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\\n`);\n process.stdout.write(this.closingBlock(ref, summary.title, branch));\n }\n\n private assertHotfixBranch(branch: string): void {\n if (this.branchIdentity.isHotfix(branch)) return;\n throw new CliExitError(\n 1,\n `wp-upsert-hotfix-pr only runs on a branch containing the exact, case-sensitive /hotfix/ segment; '${branch}' does not.\\n` +\n 'Nothing was changed. A normal branch is published with the three-stage flow:\\n' +\n ' pnpm wp-start-upsert-pr\\n pnpm wp-review-upsert-pr\\n pnpm wp-finish-upsert-pr',\n );\n }\n\n // A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.\n private assertNoUnvalidatedMerge(repoRoot: string): void {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const active = this.mergeState.findActiveMergeRunDir(home);\n const marker = active === null ? null : this.mergeState.readMergeMarker(active);\n if (marker === null || marker.validated) return;\n throw new CliExitError(\n 1,\n 'wp-upsert-hotfix-pr refuses a branch with an active, unvalidated 3-point merge. A hotfix branch must\\n' +\n 'not take main at all: abort that merge and return the branch to the production sha plus your fix\\n' +\n `commits, then re-run ${UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`,\n );\n }\n\n /** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */\n private publish(repoRoot: string, branch: string, summary: PrSummary, headSha: string): HotfixPrRef {\n const config = this.prGateConfig(repoRoot);\n const input = this.dashboardInput(repoRoot, summary, config);\n const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);\n const initial = this.prRef(branch);\n const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;\n for (const warning of new IssueReferences().closeWarnings(summary.addressesIssues)) process.stdout.write(`${warning}\\n`);\n const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, this.aiBranchName.getFeatureName()), 'pr-body.md');\n fs.mkdirSync(path.dirname(bodyFile), { recursive: true });\n fs.writeFileSync(bodyFile, body + '\\n');\n\n process.stdout.write('\\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\\n' + SEP + '\\n');\n const published = this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, UPSERT_HOTFIX_PR_COMMAND);\n if (published.createFailed) {\n throw new CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n const ref = this.prRef(branch);\n const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);\n // A brand-new PR had no URL to self-link until `gh pr create` returned one.\n const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;\n if (finalBody !== body && resolved.number !== '') {\n fs.writeFileSync(bodyFile, finalBody + '\\n');\n if (!this.editPrBody(resolved.number, bodyFile)) {\n process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\\n`);\n }\n }\n return resolved;\n }\n\n private dashboardInput(repoRoot: string, summary: PrSummary, config: PrGateConfig): DashboardInput {\n const forkPoint = this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);\n const featureHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const mainHead = this.git(repoRoot, ['rev-parse', 'origin/main']);\n const range = `${forkPoint}..${featureHead}`;\n const changedFiles = this.git(repoRoot, ['diff', range, '--name-only'])\n .split('\\n')\n .filter((f: string): boolean => f.trim() !== '');\n const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);\n const disables = this.dashboard.countAddedDisables(this.git(repoRoot, ['diff', range]));\n const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);\n const title = this.titleFrom(summary, this.branchIdentity.current());\n return new DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);\n }\n\n /** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */\n private postComments(repoRoot: string, featureName: string, ref: HotfixPrRef, summary: PrSummary): void {\n if (ref.number === '') {\n process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\\n still carries the hotfix banner. Re-run ${UPSERT_HOTFIX_PR_COMMAND} to post them.\\n`);\n return;\n }\n const config = this.prGateConfig(repoRoot);\n const prDir = this.reviewJsonService.prDirFor(repoRoot, featureName);\n const detail = new PrCommentRequest();\n detail.prNumber = ref.number;\n detail.marker = DETAIL_COMMENT_MARKER;\n // The audit banner must be the FIRST thing on the comment, so the marker goes last.\n detail.body = this.dashboard.renderDetailComment(this.dashboardInput(repoRoot, summary, config)) + '\\n\\n' + DETAIL_COMMENT_MARKER;\n detail.payloadDir = prDir;\n detail.payloadName = 'detail-comment.json';\n detail.label = 'full dashboard comment';\n this.commentUpserter.upsert(detail);\n\n if (config.checklists.length === 0 || !config.checklistComments) return;\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n const rows = scan.roster.entries.map(\n (entry: TriggeredChecklist): ChecklistCommentRow =>\n new ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount),\n );\n const roster = new PrCommentRequest();\n roster.prNumber = ref.number;\n roster.marker = CHECKLIST_COMMENT_MARKER;\n roster.body = this.checklistComment.render(rows, false, scan.roster.baseResolved, 0, true);\n roster.payloadDir = prDir;\n roster.payloadName = 'checklist-comment.json';\n roster.label = 'checklist review comment';\n this.commentUpserter.upsert(roster);\n }\n\n private closingBlock(ref: HotfixPrRef, title: string, branch: string): string {\n const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;\n return (\n '\\n' +\n SEP +\n `✅ Hotfix PR ${ref.number === '' ? '' : `#${ref.number} `}is up — NOT merged, and auto-merge was NOT enabled\\n` +\n SEP +\n '\\n' +\n ' 1. ran hotfix-ci (build + test only); lint, validators and reviewers are bypassed and bannered\\n' +\n ` 2. pushed ${branch} fast-forward only — main was never merged in and the branch was not rewritten\\n` +\n ` 3. wrote the audit-bannered body to the PR titled: \"${title}\"\\n\\n` +\n ' A hotfix PR is never auto-merged. Deploy and verify the hotfix first; the merge to main is then a\\n' +\n ' deliberate step (pnpm wp-land-pr). Another commit on this branch? Commit it and re-run\\n' +\n ` ${UPSERT_HOTFIX_PR_COMMAND} — it pushes again and updates this same PR.\\n\\n` +\n `🔗 ${link}\\n`\n );\n }\n\n private tokenSuffix(gateSalt: string, headSha: string): string {\n const marker = this.gateTokenService.gateTokenMarker(gateSalt, headSha);\n return marker === '' ? '' : `\\n\\n${marker}\\n`;\n }\n\n private titleFrom(summary: PrSummary, branch: string): string {\n return summary.title !== '' ? summary.title : branch.replace(/[-/]+/g, ' ').trim();\n }\n\n private headSha(repoRoot: string): string {\n return this.git(repoRoot, ['rev-parse', 'HEAD']);\n }\n\n private git(repoRoot: string, args: string[]): string {\n return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);\n }\n\n // ── seams, protected so the spec drives them with no network, no gh and no webpieces.config.json ──\n\n protected prGateConfig(repoRoot: string): PrGateConfig {\n return loadAndValidate(repoRoot).prGate;\n }\n\n protected fetchMain(repoRoot: string): void {\n const out = this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);\n if (out.ok) return;\n throw new CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\\n git said: ${out.stderr}`);\n }\n\n protected prRef(branch: string): HotfixPrRef {\n const out = spawnSync('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '\"\\\\(.number)\\\\t\\\\(.url)\"'], { encoding: 'utf8' });\n if (out.status !== 0) return new HotfixPrRef('', '');\n const parts = (out.stdout ?? '').trim().split('\\t');\n return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');\n }\n\n protected editPrBody(prNumber: string, bodyFile: string): boolean {\n return spawnSync('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile], { stdio: 'inherit' }).status === 0;\n }\n}\n"]}
1
+ {"version":3,"file":"upsert-hotfix-pr-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/upsert-hotfix-pr-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,sEAA+D;AAC/D,0DAAqK;AACrK,8DAA6D;AAC7D,yCAA2D;AAC3D,2EAAgE;AAChE,mDAA+C;AAC/C,+DAA6E;AAC7E,yEAAoE;AACpE,+DAA0D;AAC1D,yDAAqD;AACrD,qEAAuF;AAEvF,yEAAoE;AACpE,iEAAuE;AACvE,yEAAsF;AACtF,mFAA8E;AAC9E,yDAA6F;AAC7F,2FAAgH;AAChH,iFAA4E;AAC5E,qEAAyE;AACzE,uEAAmE;AAEnE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE,kGAAkG;AAClG,MAAa,WAAW;IACpB,MAAM,CAAS;IACf,GAAG,CAAS;IAEZ,YAAY,MAAc,EAAE,GAAW;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,kCAQC;AAED;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAGT;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IAlBrB,yDAAyD;IACzD,YACqB,cAA8B,EAC9B,cAA8B,EAC9B,YAA0B,EAC1B,OAAgB,EAChB,iBAAoC,EACpC,aAA4B,EAC5B,iBAAoC,EACpC,UAAsB,EACtB,gBAAkC,EAClC,SAA4B,EAC5B,SAAoB,EACpB,cAAsC,EACtC,gBAA0C,EAC1C,eAAkC,EAClC,cAAsC,EACtC,gBAAkC,EAClC,SAA2B;QAhB3B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,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AE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC;QAC/H,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,OAAO,IAAI,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,QAAgB;QACvD,OAAO,CAAC,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1G,CAAC;CACJ,CAAA;AA3NY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QACd,mCAAc;QAChB,mCAAY;QACjB,kBAAO;QACG,gCAAiB;QACrB,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACJ,oCAAgB;QACvB,uCAAiB;QACjB,qBAAS;QACJ,wCAAsB;QACpB,qDAAwB;QACzB,uCAAiB;QAClB,iDAAsB;QACpB,+BAAgB;QACvB,iCAAgB;GAnBvC,qBAAqB,CA2NjC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { BranchIdentity } from '@webpieces/repo-workflow-core';\nimport { CliExitError, GateTokenService, PrGateConfig, PrSummary, RepoRootFinder, ReviewJsonService, loadAndValidate, writeTemplate } from '@webpieces/rules-config';\nimport { NativeProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { GitExec } from '../workflow/git-exec';\nimport { BuildAffected, BuildGateOptions } from '../workflow/build-affected';\nimport { BuildArtifactGate } from '../workflow/build-artifact-gate';\nimport { FINISH_STAGE } from '../workflow/build-gate-log';\nimport { MergeState } from '../workflow/merge-state';\nimport { ChecklistScanOptions, ChecklistScanner } from '../workflow/checklist-scanner';\nimport { TriggeredChecklist } from '../workflow/checklist-detector';\nimport { HotfixPrPublisher } from '../workflow/hotfix-pr-publisher';\nimport { UPSERT_HOTFIX_PR_COMMAND } from '../workflow/hotfix-redirect';\nimport { PrCommentRequest, PrCommentUpserter } from '../workflow/pr-comment-upserter';\nimport { SquashSettingsEnforcer } from '../workflow/squash-settings-enforcer';\nimport { Dashboard, DashboardInput, DETAIL_COMMENT_MARKER } from '../../dashboard/dashboard';\nimport { ChecklistCommentRenderer, CHECKLIST_COMMENT_MARKER } from '../../dashboard/checklist-comment-renderer';\nimport { ChecklistCommentRow } from '../../dashboard/checklist-comment-row';\nimport { AuthorIdentityResolver } from '../../dashboard/author-identity';\nimport { IssueReferences } from '../../dashboard/issue-references';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/** The PR this run landed on. Both '' when it could not be resolved. Data-only, per CLAUDE.md. */\nexport class HotfixPrRef {\n number: string;\n url: string;\n\n constructor(number: string, url: string) {\n this.number = number;\n this.url = url;\n }\n}\n\n/**\n * `wp-upsert-hotfix-pr` — the ONE command that publishes a `/hotfix/` branch (issue #1057).\n *\n * A hotfix branch is cut from the exact sha running in production, so that what ships is production plus\n * the fix and nothing else. The three-stage PR flow cannot publish it: stage ① merges main into the branch,\n * which turns \"prod + fix\" into \"main + fix\" and ships every commit that has landed but has not been\n * promoted. And a hotfix runs no reviewers, so the stages have nothing to do between them. This is the\n * whole flow, in one command, in this order:\n *\n * 1. refuse unless the branch carries the exact, case-sensitive `/hotfix/` segment;\n * 2. require a clean tree and summary.json — a missing one prints its path and schema and exits;\n * 3. run ONLY the `hotfix-ci` gate (build + test). Red means nothing is pushed;\n * 4. NEVER merge main into the branch, never squash it, never rewrite it — HEAD is checked unchanged;\n * 5. push ONCE, fast-forward only, as a child process (pr-creation-or-push-guard stays intact);\n * 6. create or update the audit-bannered PR to main, and NEVER enable auto-merge — the consumer merges\n * after it has deployed and verified the hotfix. Re-running after another commit pushes again and\n * updates the same PR.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class UpsertHotfixPrCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly checklistScanner: ChecklistScanner,\n private readonly publisher: HotfixPrPublisher,\n private readonly dashboard: Dashboard,\n private readonly authorIdentity: AuthorIdentityResolver,\n private readonly checklistComment: ChecklistCommentRenderer,\n private readonly commentUpserter: PrCommentUpserter,\n private readonly squashSettings: SquashSettingsEnforcer,\n private readonly gateTokenService: GateTokenService,\n private readonly processes: NativeProcessApi,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n const branch = this.branchIdentity.current();\n // FIRST, before any write: a non-hotfix branch gets nothing from this command, not even a template.\n this.assertHotfixBranch(branch);\n writeTemplate(repoRoot, 'webpieces.git-workflow.md');\n await this.gitExec.assertCleanTree(repoRoot);\n await this.assertNoUnvalidatedMerge(repoRoot);\n\n const featureName = await this.aiBranchName.getFeatureName();\n const summaryPath = this.reviewJsonService.summaryJsonPath(repoRoot, featureName);\n // Throws InformAiError carrying the path and the schema when summary.json is missing or invalid.\n const summary = this.reviewJsonService.loadSummaryJson(summaryPath, [], '', {}, UPSERT_HOTFIX_PR_COMMAND);\n // FAIL FAST on a hand-written closing reference (issue #1310); renderPrBody re-judges the final body.\n new IssueReferences().assertNoStrayClosingReferences(summary.summary, summary.addressesIssues, UPSERT_HOTFIX_PR_COMMAND);\n\n // origin/main is READ (the build's merge-base and the dashboard's fork point) — never merged.\n await this.fetchMain(repoRoot);\n const headBefore = await this.headSha(repoRoot);\n await this.buildAffected.runBuildGate(\n repoRoot,\n new BuildGateOptions('🛠️ Hotfix build gate (hotfix-ci: build + test only)', UPSERT_HOTFIX_PR_COMMAND, 'Hotfix build failed — nothing was pushed and no PR was created or updated.', FINISH_STAGE),\n );\n await this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n await this.gitExec.assertCleanTree(repoRoot);\n if (await this.headSha(repoRoot) !== headBefore) {\n throw new CliExitError(1, `❌ HEAD moved while the hotfix build ran, so the build does not cover the commit that would be pushed. Nothing was pushed. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n\n const ref = await this.publish(repoRoot, branch, summary, headBefore);\n await this.postComments(repoRoot, featureName, ref, summary);\n await this.squashSettings.ensure();\n const archived = this.reviewJsonService.archiveSummaryJson(summaryPath);\n if (archived !== '') process.stdout.write(` archived this run's summary.json → ${archived} (audit only) ✓\\n`);\n process.stdout.write(this.closingBlock(ref, summary.title, branch));\n }\n\n private assertHotfixBranch(branch: string): void {\n if (this.branchIdentity.isHotfix(branch)) return;\n throw new CliExitError(\n 1,\n `wp-upsert-hotfix-pr only runs on a branch containing the exact, case-sensitive /hotfix/ segment; '${branch}' does not.\\n` +\n 'Nothing was changed. A normal branch is published with the three-stage flow:\\n' +\n ' pnpm wp-start-upsert-pr\\n pnpm wp-review-upsert-pr\\n pnpm wp-finish-upsert-pr',\n );\n }\n\n // A hotfix flow never STARTS a merge, but a branch somebody ran wp-start-update on can carry one.\n private async assertNoUnvalidatedMerge(repoRoot: string): Promise<void> {\n const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());\n const active = this.mergeState.findActiveMergeRunDir(home);\n const marker = active === null ? null : this.mergeState.readMergeMarker(active);\n if (marker === null || marker.validated) return;\n throw new CliExitError(\n 1,\n 'wp-upsert-hotfix-pr refuses a branch with an active, unvalidated 3-point merge. A hotfix branch must\\n' +\n 'not take main at all: abort that merge and return the branch to the production sha plus your fix\\n' +\n `commits, then re-run ${UPSERT_HOTFIX_PR_COMMAND}. Nothing was pushed.`,\n );\n }\n\n /** Body before push (GatedPrPublisher's ordering), fast-forward push, then create or edit — never merge. */\n private async publish(repoRoot: string, branch: string, summary: PrSummary, headSha: string): Promise<HotfixPrRef> {\n const config = this.prGateConfig(repoRoot);\n const input = await this.dashboardInput(repoRoot, summary, config);\n const tokenSuffix = this.tokenSuffix(config.gateSalt, headSha);\n const initial = await this.prRef(branch);\n const body = this.dashboard.renderPrBody(input, initial.url) + tokenSuffix;\n for (const warning of new IssueReferences().closeWarnings(summary.addressesIssues)) process.stdout.write(`${warning}\\n`);\n const bodyFile = path.join(this.reviewJsonService.prDirFor(repoRoot, await this.aiBranchName.getFeatureName()), 'pr-body.md');\n fs.mkdirSync(path.dirname(bodyFile), { recursive: true });\n fs.writeFileSync(bodyFile, body + '\\n');\n\n process.stdout.write('\\n' + SEP + '📋 Hotfix PR (bannered audit, never auto-merged)\\n' + SEP + '\\n');\n const published = await this.publisher.publish(branch, this.titleFrom(summary, branch), bodyFile, UPSERT_HOTFIX_PR_COMMAND);\n if (published.createFailed) {\n throw new CliExitError(1, `❌ gh pr create failed after the push. The rendered body is in ${bodyFile}; summary.json was kept. Re-run ${UPSERT_HOTFIX_PR_COMMAND}.`);\n }\n const ref = await this.prRef(branch);\n const resolved = new HotfixPrRef(ref.number !== '' ? ref.number : published.number, ref.url);\n // A brand-new PR had no URL to self-link until `gh pr create` returned one.\n const finalBody = this.dashboard.renderPrBody(input, resolved.url) + tokenSuffix;\n if (finalBody !== body && resolved.number !== '') {\n fs.writeFileSync(bodyFile, finalBody + '\\n');\n if (!(await this.editPrBody(resolved.number, bodyFile))) {\n process.stderr.write(`⚠️ Could not add the PR's own link to its description (non-fatal — the PR and the gate token are up).\\n`);\n }\n }\n return resolved;\n }\n\n private async dashboardInput(repoRoot: string, summary: PrSummary, config: PrGateConfig): Promise<DashboardInput> {\n const forkPoint = await this.git(repoRoot, ['merge-base', 'origin/main', 'HEAD']);\n const featureHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);\n const mainHead = await this.git(repoRoot, ['rev-parse', 'origin/main']);\n const range = `${forkPoint}..${featureHead}`;\n const changedFiles = (await this.git(repoRoot, ['diff', range, '--name-only']))\n .split('\\n')\n .filter((f: string): boolean => f.trim() !== '');\n const gateResults = this.dashboard.computeGateResults(config.gates, changedFiles);\n const disables = this.dashboard.countAddedDisables(await this.git(repoRoot, ['diff', range]));\n const buildCommand = this.buildAffected.resolveBuildCommand(repoRoot);\n const title = this.titleFrom(summary, this.branchIdentity.current());\n return new DashboardInput(title, gateResults, disables, true, forkPoint, featureHead, mainHead, summary, [], buildCommand, 0, this.authorIdentity.resolve(summary.model), true);\n }\n\n /** The 1st comment (full dashboard) and, when the repo defines checklists, the bypassed-roster 2nd. */\n private async postComments(repoRoot: string, featureName: string, ref: HotfixPrRef, summary: PrSummary): Promise<void> {\n if (ref.number === '') {\n process.stderr.write(`⚠️ Could not resolve the PR number after the push, so the audit comments were not posted. The PR body\\n still carries the hotfix banner. Re-run ${UPSERT_HOTFIX_PR_COMMAND} to post them.\\n`);\n return;\n }\n const config = this.prGateConfig(repoRoot);\n const prDir = this.reviewJsonService.prDirFor(repoRoot, featureName);\n const detail = new PrCommentRequest();\n detail.prNumber = ref.number;\n detail.marker = DETAIL_COMMENT_MARKER;\n // The audit banner must be the FIRST thing on the comment, so the marker goes last.\n detail.body = this.dashboard.renderDetailComment(await this.dashboardInput(repoRoot, summary, config)) + '\\n\\n' + DETAIL_COMMENT_MARKER;\n detail.payloadDir = prDir;\n detail.payloadName = 'detail-comment.json';\n detail.label = 'full dashboard comment';\n await this.commentUpserter.upsert(detail);\n\n if (config.checklists.length === 0 || !config.checklistComments) return;\n const scan = await this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n const rows = scan.roster.entries.map(\n (entry: TriggeredChecklist): ChecklistCommentRow =>\n new ChecklistCommentRow('none', 'none', entry.def.id, '', '', entry.matchedFiles.length > 0, entry.def.patterns, entry.matchedPatterns, entry.matchedFiles, scan.roster.changedFileCount),\n );\n const roster = new PrCommentRequest();\n roster.prNumber = ref.number;\n roster.marker = CHECKLIST_COMMENT_MARKER;\n roster.body = this.checklistComment.render(rows, false, scan.roster.baseResolved, 0, true);\n roster.payloadDir = prDir;\n roster.payloadName = 'checklist-comment.json';\n roster.label = 'checklist review comment';\n await this.commentUpserter.upsert(roster);\n }\n\n private closingBlock(ref: HotfixPrRef, title: string, branch: string): string {\n const link = ref.url === '' ? '(PR URL unresolved — see the gh output above)' : ref.url;\n return (\n '\\n' +\n SEP +\n `✅ Hotfix PR ${ref.number === '' ? '' : `#${ref.number} `}is up — NOT merged, and auto-merge was NOT enabled\\n` +\n SEP +\n '\\n' +\n ' 1. ran hotfix-ci (build + test only); lint, validators and reviewers are bypassed and bannered\\n' +\n ` 2. pushed ${branch} fast-forward only — main was never merged in and the branch was not rewritten\\n` +\n ` 3. wrote the audit-bannered body to the PR titled: \"${title}\"\\n\\n` +\n ' A hotfix PR is never auto-merged. Deploy and verify the hotfix first; the merge to main is then a\\n' +\n ' deliberate step (pnpm wp-land-pr). Another commit on this branch? Commit it and re-run\\n' +\n ` ${UPSERT_HOTFIX_PR_COMMAND} — it pushes again and updates this same PR.\\n\\n` +\n `🔗 ${link}\\n`\n );\n }\n\n private tokenSuffix(gateSalt: string, headSha: string): string {\n const marker = this.gateTokenService.gateTokenMarker(gateSalt, headSha);\n return marker === '' ? '' : `\\n\\n${marker}\\n`;\n }\n\n private titleFrom(summary: PrSummary, branch: string): string {\n return summary.title !== '' ? summary.title : branch.replace(/[-/]+/g, ' ').trim();\n }\n\n private headSha(repoRoot: string): Promise<string> {\n return this.git(repoRoot, ['rev-parse', 'HEAD']);\n }\n\n private git(repoRoot: string, args: string[]): Promise<string> {\n return this.gitExec.gitQuery(args, repoRoot, `git ${args.join(' ')} failed in ${repoRoot}`);\n }\n\n // ── seam, protected so the spec drives it with no webpieces.config.json ──\n\n protected prGateConfig(repoRoot: string): PrGateConfig {\n return loadAndValidate(repoRoot).prGate;\n }\n\n private async fetchMain(repoRoot: string): Promise<void> {\n const out = await this.gitExec.tryGit(['fetch', 'origin', 'main'], repoRoot);\n if (out.ok) return;\n throw new CliExitError(1, `❌ Could not fetch origin/main (needed to READ the fork point — it is never merged). Nothing was pushed.\\n git said: ${out.stderr}`);\n }\n\n private async prRef(branch: string): Promise<HotfixPrRef> {\n const out = await this.processes.run('gh', ['pr', 'view', branch, '--json', 'number,url', '--jq', '\"\\\\(.number)\\\\t\\\\(.url)\"']);\n if (!out.ok) return new HotfixPrRef('', '');\n const parts = out.stdout.trim().split('\\t');\n return new HotfixPrRef(parts[0] ?? '', parts[1] ?? '');\n }\n\n private async editPrBody(prNumber: string, bodyFile: string): Promise<boolean> {\n return (await this.processes.passThrough('gh', ['pr', 'edit', prNumber, '--body-file', bodyFile])).ok;\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { GitProcessApi } from '@webpieces/tooling-common';
1
2
  /**
2
3
  * The untracked files a branch switch is about to leave exactly where they are — carried out of the gate
3
4
  * so the caller can SAY so, rather than surprise anyone with files that appear to have followed them.
@@ -43,11 +44,13 @@ export declare class UntrackedFiles {
43
44
  * mangled name for exactly the paths a human most needs to read correctly.
44
45
  */
45
46
  export declare class WorkingTreeGate {
47
+ private readonly gitProcess;
48
+ constructor(gitProcess: GitProcessApi);
46
49
  /**
47
50
  * Throw when tracked files are modified or staged; otherwise hand back the untracked files that were
48
51
  * deliberately allowed through, for the caller to mention.
49
52
  */
50
- assertNoTrackedChanges(repoRoot: string): UntrackedFiles;
53
+ assertNoTrackedChanges(repoRoot: string): Promise<UntrackedFiles>;
51
54
  private untrackedFiles;
52
55
  /** Captured git output, or null when git could not be run or exited non-zero. */
53
56
  private git;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WorkingTreeGate = exports.UntrackedFiles = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const child_process_1 = require("child_process");
6
5
  const inversify_1 = require("inversify");
7
6
  const rules_config_1 = require("@webpieces/rules-config");
7
+ const tooling_common_1 = require("@webpieces/tooling-common");
8
8
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
9
9
  /**
10
10
  * The untracked files a branch switch is about to leave exactly where they are — carried out of the gate
@@ -63,12 +63,16 @@ exports.UntrackedFiles = UntrackedFiles;
63
63
  * mangled name for exactly the paths a human most needs to read correctly.
64
64
  */
65
65
  let WorkingTreeGate = class WorkingTreeGate {
66
+ gitProcess;
67
+ constructor(gitProcess) {
68
+ this.gitProcess = gitProcess;
69
+ }
66
70
  /**
67
71
  * Throw when tracked files are modified or staged; otherwise hand back the untracked files that were
68
72
  * deliberately allowed through, for the caller to mention.
69
73
  */
70
- assertNoTrackedChanges(repoRoot) {
71
- const tracked = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);
74
+ async assertNoTrackedChanges(repoRoot) {
75
+ const tracked = await this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);
72
76
  if (tracked !== null && tracked.trim() !== '') {
73
77
  throw new rules_config_1.CliExitError(1, `${SEP}❌ Uncommitted changes to tracked files\n${SEP}\n`
74
78
  + 'Going to main would carry them along. Commit them on this branch, or `git stash` them\n'
@@ -78,24 +82,23 @@ let WorkingTreeGate = class WorkingTreeGate {
78
82
  }
79
83
  return this.untrackedFiles(repoRoot);
80
84
  }
81
- untrackedFiles(repoRoot) {
82
- const output = this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);
85
+ async untrackedFiles(repoRoot) {
86
+ const output = await this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);
83
87
  if (output === null)
84
88
  return new UntrackedFiles([]);
85
89
  return new UntrackedFiles(output.split('\0').filter((path) => path !== ''));
86
90
  }
87
91
  /** Captured git output, or null when git could not be run or exited non-zero. */
88
- git(repoRoot, args) {
89
- const result = (0, child_process_1.spawnSync)('git', ['-C', repoRoot, ...args], {
90
- encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],
91
- });
92
- if (result.error !== undefined || result.status !== 0)
92
+ async git(repoRoot, args) {
93
+ const result = await this.gitProcess.run(['-C', repoRoot, ...args]);
94
+ if (!result.ok)
93
95
  return null;
94
96
  return result.stdout;
95
97
  }
96
98
  };
97
99
  exports.WorkingTreeGate = WorkingTreeGate;
98
100
  exports.WorkingTreeGate = WorkingTreeGate = tslib_1.__decorate([
99
- (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
101
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
102
+ tslib_1.__metadata("design:paramtypes", [tooling_common_1.GitProcessApi])
100
103
  ], WorkingTreeGate);
101
104
  //# sourceMappingURL=working-tree-gate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"working-tree-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/working-tree-gate.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,yCAA2D;AAC3D,0DAAuD;AAEvD,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,cAAc;IACF;IAArB,YAAqB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAEjD,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,kEAAkE;IAClE,MAAM;QACF,IAAI,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,EAAE,CA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CAAC,QAAgB,EAAE,IAAc;QACxC,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE;YACvD,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACxD,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACnE,OAAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;CACJ,CAAA;AAhCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAgC3B","sourcesContent":["import { spawnSync } from 'child_process';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { CliExitError } from '@webpieces/rules-config';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The untracked files a branch switch is about to leave exactly where they are — carried out of the gate\n * so the caller can SAY so, rather than surprise anyone with files that appear to have followed them.\n */\nexport class UntrackedFiles {\n constructor(readonly paths: readonly string[]) {}\n\n isEmpty(): boolean {\n return this.paths.length === 0;\n }\n\n /** The human-facing block, or '' when there is nothing to say. */\n render(): string {\n if (this.isEmpty()) return '';\n const list = this.paths.map((path: string): string => ` ${path}\\n`).join('');\n return 'These untracked files are not on any branch, so the checkout leaves them exactly where\\n'\n + 'they are — nothing about them changed:\\n'\n + list;\n }\n}\n\n/**\n * The clean-tree gate for `wp-sync-main`: refuse when TRACKED work would ride onto main, and\n * only then.\n *\n * ─── WHY UNTRACKED FILES ARE NOT A REASON TO REFUSE ───────────────────────────────────────────────────\n * The hazard the gate exists for is real but narrow: `git checkout` carries uncommitted changes to\n * TRACKED files across the switch, and main is the one place nobody wants to discover their work. An\n * untracked file has none of that. It is not on any branch, the switch does not move it, and no branch\n * can end up holding it — so refusing on one blocks a routine, safe operation.\n *\n * Worse, it was a refusal the user could not clear without deleting their file. The message prescribed\n * \"commit them on this branch, or stash them\", and a plain `git stash` does NOT take untracked files\n * (that needs `-u`) — so a user who did exactly what the error said got the identical refusal back. That\n * is the shape this repo treats as a defect in its own right: a cure that does not resolve the state it\n * is prescribed for. Reported from the field, where a generated `design.html` sitting untracked made the\n * command permanently unusable in that clone.\n *\n * Now the refusal only ever names tracked changes, so `git stash` — the cure it prints — always resolves\n * it, by construction.\n *\n * That is true about the FILES and not about the CHECKOUT: git itself aborts a switch when an untracked\n * file sits at a path the destination branch TRACKS. Letting untracked files through is what makes that\n * abort reachable, and `MainCheckout` is where it is handled — it reacts to git's own refusal by stashing\n * with `-u`, retrying, and shouting about it. This gate does not predict that case, deliberately: git's\n * rules for it are the authority, and re-deriving them here would drift from the git actually installed.\n *\n * ─── WHY `--untracked-files=no` AND `ls-files -z` RATHER THAN PARSING `??` ─────────────────────────────\n * The decision half asks git the tracked-only question directly, so no line of porcelain output is ever\n * parsed to make it. The reporting half asks `ls-files --others --exclude-standard -z`, which emits bare\n * NUL-separated paths — no `?? ` prefix to strip and, crucially, no quoting: porcelain v1 wraps paths\n * containing special characters in quotes with C-style escapes, so a hand-parser would hand back a\n * mangled name for exactly the paths a human most needs to read correctly.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorkingTreeGate {\n /**\n * Throw when tracked files are modified or staged; otherwise hand back the untracked files that were\n * deliberately allowed through, for the caller to mention.\n */\n assertNoTrackedChanges(repoRoot: string): UntrackedFiles {\n const tracked = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);\n if (tracked !== null && tracked.trim() !== '') {\n throw new CliExitError(1,\n `${SEP}❌ Uncommitted changes to tracked files\\n${SEP}\\n`\n + 'Going to main would carry them along. Commit them on this branch, or `git stash` them\\n'\n + '(everything listed below is tracked, which is exactly what a plain stash takes), then\\n'\n + 're-run. The webpieces tooling never commits your work for you.\\n\\n'\n + `${tracked}`);\n }\n return this.untrackedFiles(repoRoot);\n }\n\n private untrackedFiles(repoRoot: string): UntrackedFiles {\n const output = this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);\n if (output === null) return new UntrackedFiles([]);\n return new UntrackedFiles(output.split('\\0').filter((path: string): boolean => path !== ''));\n }\n\n /** Captured git output, or null when git could not be run or exited non-zero. */\n private git(repoRoot: string, args: string[]): string | null {\n const result = spawnSync('git', ['-C', repoRoot, ...args], {\n encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'],\n });\n if (result.error !== undefined || result.status !== 0) return null;\n return result.stdout;\n }\n}\n"]}
1
+ {"version":3,"file":"working-tree-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/working-tree-gate.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAC3D,0DAAuD;AACvD,8DAA0D;AAE1D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;GAGG;AACH,MAAa,cAAc;IACF;IAArB,YAAqB,KAAwB;QAAxB,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAEjD,OAAO;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,kEAAkE;IAClE,MAAM;QACF,IAAI,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAY,EAAU,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9E,OAAO,0FAA0F;cAC3F,0CAA0C;cAC1C,IAAI,CAAC;IACf,CAAC;CACJ;AAfD,wCAeC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6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AAO,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;CACJ,CAAA;AAhCY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEI,8BAAa;GAD7C,eAAe,CAgC3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport { CliExitError } from '@webpieces/rules-config';\nimport { GitProcessApi } from '@webpieces/tooling-common';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The untracked files a branch switch is about to leave exactly where they are — carried out of the gate\n * so the caller can SAY so, rather than surprise anyone with files that appear to have followed them.\n */\nexport class UntrackedFiles {\n constructor(readonly paths: readonly string[]) {}\n\n isEmpty(): boolean {\n return this.paths.length === 0;\n }\n\n /** The human-facing block, or '' when there is nothing to say. */\n render(): string {\n if (this.isEmpty()) return '';\n const list = this.paths.map((path: string): string => ` ${path}\\n`).join('');\n return 'These untracked files are not on any branch, so the checkout leaves them exactly where\\n'\n + 'they are — nothing about them changed:\\n'\n + list;\n }\n}\n\n/**\n * The clean-tree gate for `wp-sync-main`: refuse when TRACKED work would ride onto main, and\n * only then.\n *\n * ─── WHY UNTRACKED FILES ARE NOT A REASON TO REFUSE ───────────────────────────────────────────────────\n * The hazard the gate exists for is real but narrow: `git checkout` carries uncommitted changes to\n * TRACKED files across the switch, and main is the one place nobody wants to discover their work. An\n * untracked file has none of that. It is not on any branch, the switch does not move it, and no branch\n * can end up holding it — so refusing on one blocks a routine, safe operation.\n *\n * Worse, it was a refusal the user could not clear without deleting their file. The message prescribed\n * \"commit them on this branch, or stash them\", and a plain `git stash` does NOT take untracked files\n * (that needs `-u`) — so a user who did exactly what the error said got the identical refusal back. That\n * is the shape this repo treats as a defect in its own right: a cure that does not resolve the state it\n * is prescribed for. Reported from the field, where a generated `design.html` sitting untracked made the\n * command permanently unusable in that clone.\n *\n * Now the refusal only ever names tracked changes, so `git stash` — the cure it prints — always resolves\n * it, by construction.\n *\n * That is true about the FILES and not about the CHECKOUT: git itself aborts a switch when an untracked\n * file sits at a path the destination branch TRACKS. Letting untracked files through is what makes that\n * abort reachable, and `MainCheckout` is where it is handled — it reacts to git's own refusal by stashing\n * with `-u`, retrying, and shouting about it. This gate does not predict that case, deliberately: git's\n * rules for it are the authority, and re-deriving them here would drift from the git actually installed.\n *\n * ─── WHY `--untracked-files=no` AND `ls-files -z` RATHER THAN PARSING `??` ─────────────────────────────\n * The decision half asks git the tracked-only question directly, so no line of porcelain output is ever\n * parsed to make it. The reporting half asks `ls-files --others --exclude-standard -z`, which emits bare\n * NUL-separated paths — no `?? ` prefix to strip and, crucially, no quoting: porcelain v1 wraps paths\n * containing special characters in quotes with C-style escapes, so a hand-parser would hand back a\n * mangled name for exactly the paths a human most needs to read correctly.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorkingTreeGate {\n constructor(private readonly gitProcess: GitProcessApi) {}\n\n /**\n * Throw when tracked files are modified or staged; otherwise hand back the untracked files that were\n * deliberately allowed through, for the caller to mention.\n */\n async assertNoTrackedChanges(repoRoot: string): Promise<UntrackedFiles> {\n const tracked = await this.git(repoRoot, ['status', '--porcelain', '--untracked-files=no']);\n if (tracked !== null && tracked.trim() !== '') {\n throw new CliExitError(1,\n `${SEP}❌ Uncommitted changes to tracked files\\n${SEP}\\n`\n + 'Going to main would carry them along. Commit them on this branch, or `git stash` them\\n'\n + '(everything listed below is tracked, which is exactly what a plain stash takes), then\\n'\n + 're-run. The webpieces tooling never commits your work for you.\\n\\n'\n + `${tracked}`);\n }\n return this.untrackedFiles(repoRoot);\n }\n\n private async untrackedFiles(repoRoot: string): Promise<UntrackedFiles> {\n const output = await this.git(repoRoot, ['ls-files', '--others', '--exclude-standard', '-z']);\n if (output === null) return new UntrackedFiles([]);\n return new UntrackedFiles(output.split('\\0').filter((path: string): boolean => path !== ''));\n }\n\n /** Captured git output, or null when git could not be run or exited non-zero. */\n private async git(repoRoot: string, args: string[]): Promise<string | null> {\n const result = await this.gitProcess.run(['-C', repoRoot, ...args]);\n if (!result.ok) return null;\n return result.stdout;\n }\n}\n"]}
@@ -25,7 +25,7 @@ export declare class WorktreeCleanupSection {
25
25
  * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine
26
26
  * for removing a directory, since the tree may have gained uncommitted work since it was written.
27
27
  */
28
- verdicts(repoRoot: string, ignoreStaleLocks: boolean): DeletableWorktree[];
28
+ verdicts(repoRoot: string, ignoreStaleLocks: boolean): Promise<DeletableWorktree[]>;
29
29
  provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[];
30
30
  /**
31
31
  * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same
@@ -51,9 +51,9 @@ export declare class WorktreeCleanupSection {
51
51
  * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody
52
52
  * was asked about, which is why the husk path states the spare instead of tripping over it.
53
53
  */
54
- withoutUncommitted(husks: DeletableWorktree[]): DeletableWorktree[];
55
- protected workInFlight(worktreePath: string): WorktreeWorkInFlight;
56
- reap(repoRoot: string, verb: MutationVerb, targets: DeletableWorktree[], retention: string): WorktreeReapResult;
54
+ withoutUncommitted(husks: DeletableWorktree[]): Promise<DeletableWorktree[]>;
55
+ protected workInFlight(worktreePath: string): Promise<WorktreeWorkInFlight>;
56
+ reap(repoRoot: string, verb: MutationVerb, targets: DeletableWorktree[], retention: string): Promise<WorktreeReapResult>;
57
57
  report(repoRoot: string, result: WorktreeReapResult): string;
58
58
  private reapedLine;
59
59
  /**
@@ -40,8 +40,8 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
40
40
  * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine
41
41
  * for removing a directory, since the tree may have gained uncommitted work since it was written.
42
42
  */
43
- verdicts(repoRoot, ignoreStaleLocks) {
44
- return this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks).worktrees;
43
+ async verdicts(repoRoot, ignoreStaleLocks) {
44
+ return (await this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks)).worktrees;
45
45
  }
46
46
  provablyDead(verdicts) {
47
47
  return verdicts.filter((tree) => tree.deletable);
@@ -79,11 +79,11 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
79
79
  * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody
80
80
  * was asked about, which is why the husk path states the spare instead of tripping over it.
81
81
  */
82
- withoutUncommitted(husks) {
82
+ async withoutUncommitted(husks) {
83
83
  const clean = [];
84
84
  let spared = '';
85
85
  for (const tree of husks) {
86
- const held = this.workInFlight(tree.path);
86
+ const held = await this.workInFlight(tree.path);
87
87
  if (held.held) {
88
88
  // The REASON is printed verbatim, because "it has uncommitted files" and "git would
89
89
  // not tell me" send an operator to two different places.
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-cleanup.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/worktree-cleanup.ts"],"names":[],"mappings":";;;;AAAA,sEAA+W;AAC/W,yCAA2D;AAE3D,uDAA4D;AAE5D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEV;IACA;IACA;IAGA;IANrB,YACqB,cAAqC,EACrC,MAAsB,EACtB,eAAgC;IACjD,gGAAgG;IAChG,+EAA+E;IAC9D,WAA8B;QAL9B,mBAAc,GAAd,cAAc,CAAuB;QACrC,WAAM,GAAN,MAAM,CAAgB;QACtB,oBAAe,GAAf,eAAe,CAAiB;QAGhC,gBAAW,GAAX,WAAW,CAAmB;IAChD,CAAC;IAEJ;;;;OAIG;IACH,QAAQ,CAAC,QAAgB,EAAE,gBAAyB;QAChD,OAAO,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,SAAS,CAAC;IAC3F,CAAC;IAED,YAAY,CAAC,QAA6B;QACtC,OAAO,QA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ReapedWorktree, WorktreeReapResult, WorktreeReaper, WorktreeService, WorktreeWorkInFlight, CLASSIFICATION_LOCKED, CLASSIFICATION_CURRENT, CLASSIFICATION_DETACHED, CLASSIFICATION_PRUNABLE, ADJUDICATED_CLASSIFICATIONS, LOCK_LIVENESS_UNVERIFIABLE } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { FLAG_IGNORE_STALE_LOCKS } from './cleanup-options';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The WORKTREE half of `wp-cleanup` — the verdicts, the reap and the human-facing text.\n *\n * Split out of CleanupCommand rather than bolted onto it because the two halves answer different\n * questions: a branch is a ref, a worktree is a DIRECTORY OF FILES, and the second one needs its own\n * report (paths, not just names), its own restore command (`git worktree add`, not `git checkout -b`)\n * and its own spared vocabulary (locked, detached, \"you are standing in it\"). Keeping them in one class\n * meant every string had to hedge about which kind of thing it was talking about.\n *\n * WHY worktrees are reaped BEFORE branches in wp-cleanup: a worktree HOLDS its branch, so that branch\n * is spared as `in-use` with \"remove that worktree before deleting the branch\". Reaping the worktree\n * first is what makes the branch reapable — the reap takes the branch with it, and the branch pass that\n * follows recomputes its verdicts against the post-removal truth. Run the other way round, every\n * worktree-held branch survives forever, which is exactly the deadlock this change exists to break.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorktreeCleanupSection {\n constructor(\n private readonly mergedBranches: MergedBranchesService,\n private readonly reaper: WorktreeReaper,\n private readonly worktreeService: WorktreeService,\n // COMPUTED, not restated: the branch-mutation log is per-worktree, so the relative literal this\n // message used to carry named a file that does not exist in a linked worktree.\n private readonly mutationLog: BranchMutationLog,\n ) {}\n\n /**\n * FRESH verdicts — never the cache on disk. Same rule the branch half follows: the cached file is\n * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine\n * for removing a directory, since the tree may have gained uncommitted work since it was written.\n */\n verdicts(repoRoot: string, ignoreStaleLocks: boolean): DeletableWorktree[] {\n return this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks).worktrees;\n }\n\n provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n return verdicts.filter((tree: DeletableWorktree): boolean => tree.deletable);\n }\n\n /**\n * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same\n * classification order the branch prompt uses, because it is literally the same verdict on the\n * branch the worktree holds.\n *\n * Deliberately excluded: LOCKED (a lock is standing and we cannot say whose), CURRENT (removing your own cwd\n * is not a thing to offer), DETACHED (no branch, so nothing to archive and nothing to judge) and\n * PRUNABLE (already provably dead — it is in the auto-reap list, not this one).\n */\n promptable(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n const out: DeletableWorktree[] = [];\n for (const classification of ADJUDICATED_CLASSIFICATIONS) {\n for (const tree of verdicts) {\n if (!tree.deletable && tree.classification === classification) out.push(tree);\n }\n }\n return out;\n }\n\n /**\n * The zero-commit worktrees that are genuinely husks — the ones holding no uncommitted or\n * untracked work — with a printed line for each one that is spared.\n *\n * THIS IS THE ONE CHECK THAT MAKES REAPING A ZERO-COMMIT WORKTREE SAFE. A branch with no commits\n * of its own can lose nothing; a DIRECTORY with no commits can lose everything an agent has typed\n * in the last twenty minutes, and the two are indistinguishable by ref alone. `git status\n * --porcelain` is the difference, it is one local spawn, and it fails safe to \"dirty\".\n *\n * It is applied ONLY to the husks. Anything with unique commits is decided by flag or prompt, and\n * git's own refusal to remove a dirty worktree (WorktreeReaper never passes `--force`) is the\n * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody\n * was asked about, which is why the husk path states the spare instead of tripping over it.\n */\n withoutUncommitted(husks: DeletableWorktree[]): DeletableWorktree[] {\n const clean: DeletableWorktree[] = [];\n let spared = '';\n for (const tree of husks) {\n const held = this.workInFlight(tree.path);\n if (held.held) {\n // The REASON is printed verbatim, because \"it has uncommitted files\" and \"git would\n // not tell me\" send an operator to two different places.\n spared += ` · ${tree.path} [${tree.branch}] — ${held.reason};\\n`\n + ' nothing archives that, so it is left exactly where it is\\n';\n continue;\n }\n clean.push(tree);\n }\n if (spared !== '') {\n process.stdout.write('\\nZero-commit worktrees SPARED because work may be in flight in them:\\n' + spared);\n }\n return clean;\n }\n\n // Seam: one git spawn per candidate, overridden in the spec so the decision is testable with no\n // real worktrees on disk.\n protected workInFlight(worktreePath: string): WorktreeWorkInFlight {\n return this.worktreeService.workInFlight(worktreePath);\n }\n\n reap(\n repoRoot: string,\n verb: MutationVerb,\n targets: DeletableWorktree[],\n retention: string,\n ): WorktreeReapResult {\n return this.reaper.reapWorktrees(repoRoot, process.cwd(), verb, targets, retention);\n }\n\n report(repoRoot: string, result: WorktreeReapResult): string {\n if (result.reaped.length === 0 && result.failed.length === 0) return '';\n\n let out = '\\n' + SEP + `🌲 Removed ${String(result.reaped.length)} dead worktree(s)\\n` + SEP + '\\n';\n for (const entry of result.reaped) out += this.reapedLine(entry);\n\n if (result.failed.length > 0) {\n out += `\\n⚠️ ${String(result.failed.length)} worktree(s) could not be removed:\\n`;\n for (const entry of result.failed) out += ` ✗ ${entry.path} — ${entry.error}\\n`;\n }\n // Printed on success too: removing a worktree deletes real files, and a human who cannot see\n // how to undo that has to take it on trust — which is precisely what nobody should have to do.\n out += `\\nEvery removal is logged (phase REAP_WORKTREE) in\\n${this.mutationLog.branchMutationLogPath(repoRoot)}\\n`\n + 'with the `recover=` command that brings back both the directory and its branch.\\n';\n return out;\n }\n\n private reapedLine(entry: ReapedWorktree): string {\n const branch = entry.branch !== '' ? ` [${entry.branch}]` : ' [detached]';\n // The restore command is printed inline for the same reason the branch half prints the archive\n // tag: it is the one thing that makes this reversible without going and digging in a log.\n const restore = `\\n restore: ${this.reaper.restoreCommand(entry)}`;\n // A directory that went while its branch survived is a real half-state and must not read as done.\n const partial = entry.branch !== '' && !entry.branchDeleted\n ? `\\n ⚠️ the branch '${entry.branch}' was NOT deleted — git refused it`\n : '';\n return ` ✓ ${entry.path}${branch} — ${entry.reason}${restore}${partial}\\n`;\n }\n\n /**\n * The spared worktrees, with WHY — including the ones nobody will ever be asked about.\n *\n * When any of them is a claude-agent lock whose agent could not be verified either way, the block\n * ends with the flag that judges it on its branch instead. That hint lives HERE and not in the\n * verdict's own reason for one reason: the flag is wp-cleanup's, its spelling is one constant in\n * this package, and a rules-config message naming it would be a second copy of that spelling free\n * to drift. The reason says what is KNOWN; this says what you can DO about it.\n */\n sparedBlock(verdicts: DeletableWorktree[], removed: DeletableWorktree[]): string {\n const gone = new Set(removed.map((tree: DeletableWorktree): string => tree.path));\n const spared = verdicts.filter(\n (tree: DeletableWorktree): boolean => !tree.deletable && !gone.has(tree.path)\n && this.isMechanical(tree.classification));\n if (spared.length === 0) return '';\n let out = '\\nWorktrees deliberately left alone:\\n';\n let unverified = 0;\n for (const tree of spared) {\n out += ` · ${tree.path} — ${tree.reason}\\n`;\n if (tree.reason.includes(LOCK_LIVENESS_UNVERIFIABLE)) unverified += 1;\n }\n if (unverified > 0) {\n out += `\\n${String(unverified)} of those carry a claude-agent lock whose liveness cannot be `\n + 'verified.\\nTo judge those on their branch and commits alone — unlocking and removing only\\n'\n + `the ones that come back dead — re-run:\\n pnpm wp-cleanup ${FLAG_IGNORE_STALE_LOCKS}\\n`;\n }\n return out;\n }\n\n private isMechanical(classification: string): boolean {\n return classification === CLASSIFICATION_LOCKED\n || classification === CLASSIFICATION_CURRENT\n || classification === CLASSIFICATION_DETACHED\n || classification === CLASSIFICATION_PRUNABLE;\n }\n\n // The table a human answers: path, branch, and the same reason the branch prompt would show, since\n // the verdict IS the branch's verdict.\n promptBlock(promptable: DeletableWorktree[]): string {\n let out = '\\n' + SEP\n + `🤔 ${String(promptable.length)} worktree(s) are probably dead — your call\\n` + SEP + '\\n'\n + 'Removing one deletes its DIRECTORY and its branch. The branch is archived as a tag first,\\n'\n + 'so both come back with one `git worktree add -b …` — but uncommitted or untracked files in\\n'\n + 'that directory are NOT archived, and git will refuse the removal if any exist.\\n\\n';\n for (let i = 0; i < promptable.length; i += 1) {\n const tree = promptable[i];\n out += ` [${String(i + 1)}] ${tree.path}\\n [${tree.branch}] — ${tree.reason}\\n`;\n }\n return out;\n }\n}\n"]}
1
+ {"version":3,"file":"worktree-cleanup.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/worktree-cleanup.ts"],"names":[],"mappings":";;;;AAAA,sEAA+W;AAC/W,yCAA2D;AAE3D,uDAA4D;AAE5D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEV;IACA;IACA;IAGA;IANrB,YACqB,cAAqC,EACrC,MAAsB,EACtB,eAAgC;IACjD,gGAAgG;IAChG,+EAA+E;IAC9D,WAA8B;QAL9B,mBAAc,GAAd,cAAc,CAAuB;QACrC,WAAM,GAAN,MAAM,CAAgB;QACtB,oBAAe,GAAf,eAAe,CAAiB;QAGhC,gBAAW,GAAX,WAAW,CAAmB;IAChD,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,gBAAyB;QACtD,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;IACnG,CAAC;IAED,YAAY,CAAC,QAA6B;QACtC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAuB,EAAW,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjF,CAAC;IAED;;;;;;;;OAQG;IACH,UAAU,CAAC,QAA6B;QACpC,MAAM,GAAG,GAAwB,EAAE,CAAC;QACpC,KAAK,MAAM,cAAc,IAAI,gDAA2B,EAAE,CAAC;YACvD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,cAAc,KAAK,cAAc;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,2CAAsB;eACzC,cAAc,KAAK,4CAAuB;eAC1C,cAAc,KAAK,4CAAuB,CAAC;IACtD,CAAC;IAED,mGAAmG;IACnG,uCAAuC;IACvC,WAAW,CAAC,UAA+B;QACvC,IAAI,GAAG,GAAG,IAAI,GAAG,GAAG;cACd,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,8CAA8C,GAAG,GAAG,GAAG,IAAI;cAC1F,6FAA6F;cAC7F,8FAA8F;cAC9F,oFAAoF,CAAC;QAC3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3B,GAAG,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,cAAc,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC;QAC5F,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA1KY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,0CAAqB;QAC7B,mCAAc;QACL,oCAAe;QAGnB,sCAAiB;GAP1C,sBAAsB,CA0KlC","sourcesContent":["import { BranchMutationLog, MutationVerb, DeletableWorktree, MergedBranchesService, ReapedWorktree, WorktreeReapResult, WorktreeReaper, WorktreeService, WorktreeWorkInFlight, CLASSIFICATION_LOCKED, CLASSIFICATION_CURRENT, CLASSIFICATION_DETACHED, CLASSIFICATION_PRUNABLE, ADJUDICATED_CLASSIFICATIONS, LOCK_LIVENESS_UNVERIFIABLE } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { FLAG_IGNORE_STALE_LOCKS } from './cleanup-options';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The WORKTREE half of `wp-cleanup` — the verdicts, the reap and the human-facing text.\n *\n * Split out of CleanupCommand rather than bolted onto it because the two halves answer different\n * questions: a branch is a ref, a worktree is a DIRECTORY OF FILES, and the second one needs its own\n * report (paths, not just names), its own restore command (`git worktree add`, not `git checkout -b`)\n * and its own spared vocabulary (locked, detached, \"you are standing in it\"). Keeping them in one class\n * meant every string had to hedge about which kind of thing it was talking about.\n *\n * WHY worktrees are reaped BEFORE branches in wp-cleanup: a worktree HOLDS its branch, so that branch\n * is spared as `in-use` with \"remove that worktree before deleting the branch\". Reaping the worktree\n * first is what makes the branch reapable — the reap takes the branch with it, and the branch pass that\n * follows recomputes its verdicts against the post-removal truth. Run the other way round, every\n * worktree-held branch survives forever, which is exactly the deadlock this change exists to break.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorktreeCleanupSection {\n constructor(\n private readonly mergedBranches: MergedBranchesService,\n private readonly reaper: WorktreeReaper,\n private readonly worktreeService: WorktreeService,\n // COMPUTED, not restated: the branch-mutation log is per-worktree, so the relative literal this\n // message used to carry named a file that does not exist in a linked worktree.\n private readonly mutationLog: BranchMutationLog,\n ) {}\n\n /**\n * FRESH verdicts — never the cache on disk. Same rule the branch half follows: the cached file is\n * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine\n * for removing a directory, since the tree may have gained uncommitted work since it was written.\n */\n async verdicts(repoRoot: string, ignoreStaleLocks: boolean): Promise<DeletableWorktree[]> {\n return (await this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks)).worktrees;\n }\n\n provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n return verdicts.filter((tree: DeletableWorktree): boolean => tree.deletable);\n }\n\n /**\n * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same\n * classification order the branch prompt uses, because it is literally the same verdict on the\n * branch the worktree holds.\n *\n * Deliberately excluded: LOCKED (a lock is standing and we cannot say whose), CURRENT (removing your own cwd\n * is not a thing to offer), DETACHED (no branch, so nothing to archive and nothing to judge) and\n * PRUNABLE (already provably dead — it is in the auto-reap list, not this one).\n */\n promptable(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n const out: DeletableWorktree[] = [];\n for (const classification of ADJUDICATED_CLASSIFICATIONS) {\n for (const tree of verdicts) {\n if (!tree.deletable && tree.classification === classification) out.push(tree);\n }\n }\n return out;\n }\n\n /**\n * The zero-commit worktrees that are genuinely husks — the ones holding no uncommitted or\n * untracked work — with a printed line for each one that is spared.\n *\n * THIS IS THE ONE CHECK THAT MAKES REAPING A ZERO-COMMIT WORKTREE SAFE. A branch with no commits\n * of its own can lose nothing; a DIRECTORY with no commits can lose everything an agent has typed\n * in the last twenty minutes, and the two are indistinguishable by ref alone. `git status\n * --porcelain` is the difference, it is one local spawn, and it fails safe to \"dirty\".\n *\n * It is applied ONLY to the husks. Anything with unique commits is decided by flag or prompt, and\n * git's own refusal to remove a dirty worktree (WorktreeReaper never passes `--force`) is the\n * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody\n * was asked about, which is why the husk path states the spare instead of tripping over it.\n */\n async withoutUncommitted(husks: DeletableWorktree[]): Promise<DeletableWorktree[]> {\n const clean: DeletableWorktree[] = [];\n let spared = '';\n for (const tree of husks) {\n const held = await this.workInFlight(tree.path);\n if (held.held) {\n // The REASON is printed verbatim, because \"it has uncommitted files\" and \"git would\n // not tell me\" send an operator to two different places.\n spared += ` · ${tree.path} [${tree.branch}] — ${held.reason};\\n`\n + ' nothing archives that, so it is left exactly where it is\\n';\n continue;\n }\n clean.push(tree);\n }\n if (spared !== '') {\n process.stdout.write('\\nZero-commit worktrees SPARED because work may be in flight in them:\\n' + spared);\n }\n return clean;\n }\n\n // Seam: one git spawn per candidate, overridden in the spec so the decision is testable with no\n // real worktrees on disk.\n protected workInFlight(worktreePath: string): Promise<WorktreeWorkInFlight> {\n return this.worktreeService.workInFlight(worktreePath);\n }\n\n reap(\n repoRoot: string,\n verb: MutationVerb,\n targets: DeletableWorktree[],\n retention: string,\n ): Promise<WorktreeReapResult> {\n return this.reaper.reapWorktrees(repoRoot, process.cwd(), verb, targets, retention);\n }\n\n report(repoRoot: string, result: WorktreeReapResult): string {\n if (result.reaped.length === 0 && result.failed.length === 0) return '';\n\n let out = '\\n' + SEP + `🌲 Removed ${String(result.reaped.length)} dead worktree(s)\\n` + SEP + '\\n';\n for (const entry of result.reaped) out += this.reapedLine(entry);\n\n if (result.failed.length > 0) {\n out += `\\n⚠️ ${String(result.failed.length)} worktree(s) could not be removed:\\n`;\n for (const entry of result.failed) out += ` ✗ ${entry.path} — ${entry.error}\\n`;\n }\n // Printed on success too: removing a worktree deletes real files, and a human who cannot see\n // how to undo that has to take it on trust — which is precisely what nobody should have to do.\n out += `\\nEvery removal is logged (phase REAP_WORKTREE) in\\n${this.mutationLog.branchMutationLogPath(repoRoot)}\\n`\n + 'with the `recover=` command that brings back both the directory and its branch.\\n';\n return out;\n }\n\n private reapedLine(entry: ReapedWorktree): string {\n const branch = entry.branch !== '' ? ` [${entry.branch}]` : ' [detached]';\n // The restore command is printed inline for the same reason the branch half prints the archive\n // tag: it is the one thing that makes this reversible without going and digging in a log.\n const restore = `\\n restore: ${this.reaper.restoreCommand(entry)}`;\n // A directory that went while its branch survived is a real half-state and must not read as done.\n const partial = entry.branch !== '' && !entry.branchDeleted\n ? `\\n ⚠️ the branch '${entry.branch}' was NOT deleted — git refused it`\n : '';\n return ` ✓ ${entry.path}${branch} — ${entry.reason}${restore}${partial}\\n`;\n }\n\n /**\n * The spared worktrees, with WHY — including the ones nobody will ever be asked about.\n *\n * When any of them is a claude-agent lock whose agent could not be verified either way, the block\n * ends with the flag that judges it on its branch instead. That hint lives HERE and not in the\n * verdict's own reason for one reason: the flag is wp-cleanup's, its spelling is one constant in\n * this package, and a rules-config message naming it would be a second copy of that spelling free\n * to drift. The reason says what is KNOWN; this says what you can DO about it.\n */\n sparedBlock(verdicts: DeletableWorktree[], removed: DeletableWorktree[]): string {\n const gone = new Set(removed.map((tree: DeletableWorktree): string => tree.path));\n const spared = verdicts.filter(\n (tree: DeletableWorktree): boolean => !tree.deletable && !gone.has(tree.path)\n && this.isMechanical(tree.classification));\n if (spared.length === 0) return '';\n let out = '\\nWorktrees deliberately left alone:\\n';\n let unverified = 0;\n for (const tree of spared) {\n out += ` · ${tree.path} — ${tree.reason}\\n`;\n if (tree.reason.includes(LOCK_LIVENESS_UNVERIFIABLE)) unverified += 1;\n }\n if (unverified > 0) {\n out += `\\n${String(unverified)} of those carry a claude-agent lock whose liveness cannot be `\n + 'verified.\\nTo judge those on their branch and commits alone — unlocking and removing only\\n'\n + `the ones that come back dead — re-run:\\n pnpm wp-cleanup ${FLAG_IGNORE_STALE_LOCKS}\\n`;\n }\n return out;\n }\n\n private isMechanical(classification: string): boolean {\n return classification === CLASSIFICATION_LOCKED\n || classification === CLASSIFICATION_CURRENT\n || classification === CLASSIFICATION_DETACHED\n || classification === CLASSIFICATION_PRUNABLE;\n }\n\n // The table a human answers: path, branch, and the same reason the branch prompt would show, since\n // the verdict IS the branch's verdict.\n promptBlock(promptable: DeletableWorktree[]): string {\n let out = '\\n' + SEP\n + `🤔 ${String(promptable.length)} worktree(s) are probably dead — your call\\n` + SEP + '\\n'\n + 'Removing one deletes its DIRECTORY and its branch. The branch is archived as a tag first,\\n'\n + 'so both come back with one `git worktree add -b …` — but uncommitted or untracked files in\\n'\n + 'that directory are NOT archived, and git will refuse the removal if any exist.\\n\\n';\n for (let i = 0; i < promptable.length; i += 1) {\n const tree = promptable[i];\n out += ` [${String(i + 1)}] ${tree.path}\\n [${tree.branch}] — ${tree.reason}\\n`;\n }\n return out;\n }\n}\n"]}