@webpieces/pr-gate 0.4.837 → 0.4.839

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 (85) hide show
  1. package/package.json +6 -4
  2. package/src/scripts/commands/cleanup-command.d.ts +2 -1
  3. package/src/scripts/commands/cleanup-command.js +13 -12
  4. package/src/scripts/commands/cleanup-command.js.map +1 -1
  5. package/src/scripts/commands/finish-upsert-pr-command.js +5 -3
  6. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  7. package/src/scripts/commands/human-post-pr-command.d.ts +2 -1
  8. package/src/scripts/commands/human-post-pr-command.js +3 -2
  9. package/src/scripts/commands/human-post-pr-command.js.map +1 -1
  10. package/src/scripts/commands/land-pr-command.d.ts +2 -1
  11. package/src/scripts/commands/land-pr-command.js +12 -9
  12. package/src/scripts/commands/land-pr-command.js.map +1 -1
  13. package/src/scripts/commands/reap-worktree-command.d.ts +2 -1
  14. package/src/scripts/commands/reap-worktree-command.js +4 -2
  15. package/src/scripts/commands/reap-worktree-command.js.map +1 -1
  16. package/src/scripts/commands/sync-main-command.js +2 -1
  17. package/src/scripts/commands/sync-main-command.js.map +1 -1
  18. package/src/scripts/commands/upsert-hotfix-pr-command.d.ts +2 -1
  19. package/src/scripts/commands/upsert-hotfix-pr-command.js +2 -1
  20. package/src/scripts/commands/upsert-hotfix-pr-command.js.map +1 -1
  21. package/src/scripts/commands/worktree-cleanup.d.ts +1 -1
  22. package/src/scripts/commands/worktree-cleanup.js +11 -11
  23. package/src/scripts/commands/worktree-cleanup.js.map +1 -1
  24. package/src/scripts/commands/write-review-command.js +13 -10
  25. package/src/scripts/commands/write-review-command.js.map +1 -1
  26. package/src/scripts/commands/write-review-fixes-command.js +3 -2
  27. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  28. package/src/scripts/pr-gate-cli-app.js +2 -1
  29. package/src/scripts/pr-gate-cli-app.js.map +1 -1
  30. package/src/scripts/workflow/build-affected.d.ts +2 -1
  31. package/src/scripts/workflow/build-affected.js +2 -1
  32. package/src/scripts/workflow/build-affected.js.map +1 -1
  33. package/src/scripts/workflow/cleanTmp.d.ts +2 -1
  34. package/src/scripts/workflow/cleanTmp.js +3 -2
  35. package/src/scripts/workflow/cleanTmp.js.map +1 -1
  36. package/src/scripts/workflow/diff-materializer.js +2 -1
  37. package/src/scripts/workflow/diff-materializer.js.map +1 -1
  38. package/src/scripts/workflow/gate-log-file.js +5 -4
  39. package/src/scripts/workflow/gate-log-file.js.map +1 -1
  40. package/src/scripts/workflow/generated-artifact-registry.js +2 -1
  41. package/src/scripts/workflow/generated-artifact-registry.js.map +1 -1
  42. package/src/scripts/workflow/hotfix-redirect.d.ts +1 -1
  43. package/src/scripts/workflow/hotfix-redirect.js +2 -1
  44. package/src/scripts/workflow/hotfix-redirect.js.map +1 -1
  45. package/src/scripts/workflow/landed-tree-resolver.d.ts +1 -1
  46. package/src/scripts/workflow/landed-tree-resolver.js +2 -2
  47. package/src/scripts/workflow/landed-tree-resolver.js.map +1 -1
  48. package/src/scripts/workflow/landed-worktree-reaper.d.ts +1 -1
  49. package/src/scripts/workflow/landed-worktree-reaper.js +2 -1
  50. package/src/scripts/workflow/landed-worktree-reaper.js.map +1 -1
  51. package/src/scripts/workflow/merge-end.d.ts +1 -1
  52. package/src/scripts/workflow/merge-end.js +6 -5
  53. package/src/scripts/workflow/merge-end.js.map +1 -1
  54. package/src/scripts/workflow/merge-info-index.d.ts +1 -1
  55. package/src/scripts/workflow/merge-info-index.js +5 -4
  56. package/src/scripts/workflow/merge-info-index.js.map +1 -1
  57. package/src/scripts/workflow/merge-start.d.ts +1 -1
  58. package/src/scripts/workflow/merge-start.js +11 -9
  59. package/src/scripts/workflow/merge-start.js.map +1 -1
  60. package/src/scripts/workflow/merge-state.d.ts +1 -1
  61. package/src/scripts/workflow/merge-state.js +3 -2
  62. package/src/scripts/workflow/merge-state.js.map +1 -1
  63. package/src/scripts/workflow/provenance-enforcer.js +5 -4
  64. package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
  65. package/src/scripts/workflow/push-dev-state.d.ts +1 -1
  66. package/src/scripts/workflow/push-dev-state.js +4 -2
  67. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  68. package/src/scripts/workflow/review-round-state.d.ts +2 -1
  69. package/src/scripts/workflow/review-round-state.js +22 -20
  70. package/src/scripts/workflow/review-round-state.js.map +1 -1
  71. package/src/scripts/workflow/review-stage-receipt.js +2 -1
  72. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  73. package/src/scripts/workflow/reviewer-briefing-builder.js +2 -1
  74. package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
  75. package/src/scripts/workflow/reviewer-identity.d.ts +1 -1
  76. package/src/scripts/workflow/reviewer-identity.js +8 -7
  77. package/src/scripts/workflow/reviewer-identity.js.map +1 -1
  78. package/src/scripts/workflow/reviewer-verdict-gate.js +2 -1
  79. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  80. package/src/scripts/workflow/run-update.d.ts +1 -1
  81. package/src/scripts/workflow/run-update.js +4 -4
  82. package/src/scripts/workflow/run-update.js.map +1 -1
  83. package/src/scripts/workflow/verdict-provenance.d.ts +2 -1
  84. package/src/scripts/workflow/verdict-provenance.js +10 -7
  85. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WorktreeCleanupSection = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const rules_config_1 = require("@webpieces/rules-config");
5
+ const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
6
6
  const inversify_1 = require("inversify");
7
7
  const cleanup_options_1 = require("./cleanup-options");
8
8
  const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
@@ -57,7 +57,7 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
57
57
  */
58
58
  promptable(verdicts) {
59
59
  const out = [];
60
- for (const classification of rules_config_1.ADJUDICATED_CLASSIFICATIONS) {
60
+ for (const classification of repo_workflow_core_1.ADJUDICATED_CLASSIFICATIONS) {
61
61
  for (const tree of verdicts) {
62
62
  if (!tree.deletable && tree.classification === classification)
63
63
  out.push(tree);
@@ -153,7 +153,7 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
153
153
  let unverified = 0;
154
154
  for (const tree of spared) {
155
155
  out += ` · ${tree.path} — ${tree.reason}\n`;
156
- if (tree.reason.includes(rules_config_1.LOCK_LIVENESS_UNVERIFIABLE))
156
+ if (tree.reason.includes(repo_workflow_core_1.LOCK_LIVENESS_UNVERIFIABLE))
157
157
  unverified += 1;
158
158
  }
159
159
  if (unverified > 0) {
@@ -164,10 +164,10 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
164
164
  return out;
165
165
  }
166
166
  isMechanical(classification) {
167
- return classification === rules_config_1.CLASSIFICATION_LOCKED
168
- || classification === rules_config_1.CLASSIFICATION_CURRENT
169
- || classification === rules_config_1.CLASSIFICATION_DETACHED
170
- || classification === rules_config_1.CLASSIFICATION_PRUNABLE;
167
+ return classification === repo_workflow_core_1.CLASSIFICATION_LOCKED
168
+ || classification === repo_workflow_core_1.CLASSIFICATION_CURRENT
169
+ || classification === repo_workflow_core_1.CLASSIFICATION_DETACHED
170
+ || classification === repo_workflow_core_1.CLASSIFICATION_PRUNABLE;
171
171
  }
172
172
  // The table a human answers: path, branch, and the same reason the branch prompt would show, since
173
173
  // the verdict IS the branch's verdict.
@@ -187,9 +187,9 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
187
187
  exports.WorktreeCleanupSection = WorktreeCleanupSection;
188
188
  exports.WorktreeCleanupSection = WorktreeCleanupSection = tslib_1.__decorate([
189
189
  (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
190
- tslib_1.__metadata("design:paramtypes", [rules_config_1.MergedBranchesService,
191
- rules_config_1.WorktreeReaper,
192
- rules_config_1.WorktreeService,
193
- rules_config_1.BranchMutationLog])
190
+ tslib_1.__metadata("design:paramtypes", [repo_workflow_core_1.MergedBranchesService,
191
+ repo_workflow_core_1.WorktreeReaper,
192
+ repo_workflow_core_1.WorktreeService,
193
+ repo_workflow_core_1.BranchMutationLog])
194
194
  ], WorktreeCleanupSection);
195
195
  //# sourceMappingURL=worktree-cleanup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-cleanup.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/worktree-cleanup.ts"],"names":[],"mappings":";;;;AAAA,0DAgBiC;AACjC,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,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,0CAA2B,EAAE,CAAC;YACvD,KAAK,MAAM,IAAI,IAAI,QAAQ,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YAAY,CAAC,cAAsB;QACvC,OAAO,cAAc,KAAK,oCAAqB;eACxC,cAAc,KAAK,qCAAsB;eACzC,cAAc,KAAK,sCAAuB;eAC1C,cAAc,KAAK,sCAAuB,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,oCAAqB;QAC7B,6BAAc;QACL,8BAAe;QAGnB,gCAAiB;GAP1C,sBAAsB,CA0KlC","sourcesContent":["import {\n BranchMutationLog,\n MutationVerb,\n DeletableWorktree,\n MergedBranchesService,\n ReapedWorktree,\n WorktreeReapResult,\n WorktreeReaper,\n WorktreeService,\n WorktreeWorkInFlight,\n CLASSIFICATION_LOCKED,\n CLASSIFICATION_CURRENT,\n CLASSIFICATION_DETACHED,\n CLASSIFICATION_PRUNABLE,\n ADJUDICATED_CLASSIFICATIONS,\n LOCK_LIVENESS_UNVERIFIABLE,\n} from '@webpieces/rules-config';\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":[],"mapp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F,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 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"]}
@@ -3,7 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WriteReviewInput = exports.WriteReviewCommand = exports.ReviewBudgetCheckOptions = exports.WriteReviewOptions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("fs"));
6
+ const tooling_common_1 = require("@webpieces/tooling-common");
7
+ const to_error_1 = require("@webpieces/tooling-common/to-error");
6
8
  const rules_config_1 = require("@webpieces/rules-config");
9
+ const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
7
10
  const inversify_1 = require("inversify");
8
11
  const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
9
12
  const review_stage_receipt_1 = require("../workflow/review-stage-receipt");
@@ -109,7 +112,7 @@ let WriteReviewCommand = class WriteReviewCommand {
109
112
  ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${rules_config_1.VERDICT_RED} — mark every must-fix finding ${rules_config_1.VERDICT_ORANGE}.`
110
113
  : '';
111
114
  process.stdout.write(`✅ "${id}" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `
112
- + `Review it, then submit with pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
115
+ + `Review it, then submit with pnpm ${repo_workflow_core_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
113
116
  return Promise.resolve();
114
117
  }
115
118
  /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
@@ -131,7 +134,7 @@ let WriteReviewCommand = class WriteReviewCommand {
131
134
  const why = receipt.round > max
132
135
  ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`
133
136
  : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;
134
- throw new rules_config_1.InformAiError(`I am not allowed to review ${id}: ${why}.\n`
137
+ throw new tooling_common_1.InformAiError(`I am not allowed to review ${id}: ${why}.\n`
135
138
  + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `
136
139
  + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `
137
140
  + 'the author records any fix with pnpm wp-write-review-fixes.');
@@ -139,15 +142,15 @@ let WriteReviewCommand = class WriteReviewCommand {
139
142
  /** The stage-② receipt, provided it briefed THIS checklist this round. */
140
143
  briefedReceipt(repoRoot, featureName, id) {
141
144
  if (id === '')
142
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN} needs the checklist id: pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist <id>`);
145
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN} needs the checklist id: pnpm ${repo_workflow_core_1.WRITE_REVIEW_BIN} --checklist <id>`);
143
146
  const receipt = this.receipts.read(repoRoot, featureName);
144
147
  if (receipt === null) {
145
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `
148
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `
146
149
  + 'so there is nothing to submit a verdict against.');
147
150
  }
148
151
  if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {
149
152
  const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');
150
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: checklist "${id}" was not briefed by the last pnpm wp-review-upsert-pr `
153
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: checklist "${id}" was not briefed by the last pnpm wp-review-upsert-pr `
151
154
  + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `
152
155
  + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');
153
156
  }
@@ -178,7 +181,7 @@ let WriteReviewCommand = class WriteReviewCommand {
178
181
  problems.push(`"${key}" must be a non-empty string${key === 'output' ? '' : ' (use "unknown" when unavailable)'}`);
179
182
  }
180
183
  if (problems.length > 0) {
181
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict for "${id}" was NOT submitted:\n`
184
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: the verdict for "${id}" was NOT submitted:\n`
182
185
  + problems.map((p) => ` • ${p}`).join('\n'));
183
186
  }
184
187
  return new verdict_provenance_1.SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output']);
@@ -216,11 +219,11 @@ let WriteReviewCommand = class WriteReviewCommand {
216
219
  parsed = JSON.parse(json);
217
220
  }
218
221
  catch (err) {
219
- const error = (0, rules_config_1.toError)(err);
220
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });
222
+ const error = (0, to_error_1.toError)(err);
223
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });
221
224
  }
222
225
  if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
223
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);
226
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);
224
227
  }
225
228
  // webpieces-disable no-any-unknown -- narrowed to a plain object just above
226
229
  return parsed;
@@ -244,7 +247,7 @@ let WriteReviewInput = class WriteReviewInput {
244
247
  read(filePath, stdin) {
245
248
  if (filePath.trim() !== '') {
246
249
  if (!fs.existsSync(filePath))
247
- throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);
250
+ throw new tooling_common_1.InformAiError(`${repo_workflow_core_1.WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);
248
251
  return fs.readFileSync(filePath, 'utf8');
249
252
  }
250
253
  return stdin.read();
@@ -1 +1 @@
1
- {"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAGiC;AACjC,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAG/G,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CA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a,CAAC,GAAG,+BAAgB,wCAAwC,CAAC,CAAC;QACzF,CAAC;QACD,4EAA4E;QAC5E,OAAO,MAAiC,CAAC;IAC7C,CAAC;CACJ,CAAA;AArKY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QAChB,mCAAY;QAChB,gDAAyB;QACzB,4CAAwB;QACtB,6CAAwB;QACjB,gCAAiB;GARhD,kBAAkB,CAqK9B;AAED;;;GAGG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACzB,IAAI,CAAC,QAAgB,EAAE,KAAqB;QACxC,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,YAAY,QAAQ,kBAAkB,CAAC,CAAC;YACjH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CACJ,CAAA;AARY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAQ5B","sourcesContent":["import * as fs from 'fs';\nimport {\n InformAiError, RepoRootFinder, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService,\n summaryJsonPath, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\nimport type { PrGateCliStdin } from '../pr-gate-cli-invocation';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */\nexport class ReviewBudgetCheckOptions {\n checklistId: string;\n cwd: string;\n\n constructor(checklistId: string, cwd: string) {\n this.checklistId = checklistId;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which\n * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict\n * without one, or one edited since;\n * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records\n * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the\n * same question BEFORE a reviewer spends a review on it;\n * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is\n * orange, never re-reviewed — and orange is refused before the final round, where red still means\n * \"fix it and it will be reviewed again\".\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly reviewJsonService: ReviewJsonService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const verdict = this.parse(opts.json, id, receipt);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /**\n * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse\n * on the budget, so a reviewer past the budget learns it before it reviews rather than after.\n */\n check(opts: ReviewBudgetCheckOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const final = this.isFinalRound(receipt)\n ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${VERDICT_RED} — mark every must-fix finding ${VERDICT_ORANGE}.`\n : '';\n process.stdout.write(\n `✅ \"${id}\" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `\n + `Review it, then submit with pnpm ${WRITE_REVIEW_BIN} --checklist ${id}.\\n`);\n return Promise.resolve();\n }\n\n /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */\n private isFinalRound(receipt: ReviewStageReceipt): boolean {\n return receipt.round >= receipt.maxReviewerRounds;\n }\n\n /**\n * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already\n * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions\n * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above\n * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a\n * later one) gets no second one — a round's verdict is never overwritten.\n */\n private assertWithinBudget(summaryPath: string, receipt: ReviewStageReceipt, id: string): void {\n const max = receipt.maxReviewerRounds;\n const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);\n if (receipt.round <= max && latest < receipt.round) return;\n const why = receipt.round > max\n ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`\n : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;\n throw new InformAiError(\n `I am not allowed to review ${id}: ${why}.\\n`\n + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `\n + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `\n + 'the author records any fix with pnpm wp-write-review-fixes.');\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /**\n * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits\n * the round — red only BEFORE the final round, orange only ON it (issue #1053).\n */\n private parse(json: string, id: string, receipt: ReviewStageReceipt): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n problems.push(...this.colorForRound(status, receipt));\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n /**\n * The round decides which blocking color exists. The FINAL round's red would mean \"fix it and it will be\n * reviewed again\", and there is no again — so it is refused and orange named. Orange before the final\n * round would waive a re-review that the budget still pays for — so it is refused and red named.\n */\n private colorForRound(status: string, receipt: ReviewStageReceipt): string[] {\n const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;\n if (status === VERDICT_RED && this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_RED}\" is not allowed: ${round} is the FINAL round, and there is no re-review. `\n + `Mark anything that must be fixed \"${VERDICT_ORANGE}\", with a concrete, actionable fix in \"output\" — the author applies it `\n + 'best effort and ships without another review.'];\n }\n if (status === VERDICT_ORANGE && !this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_ORANGE}\" is only for the FINAL review round, and ${round} is not it. `\n + `Use \"${VERDICT_RED}\" for a must-fix finding: the author's fix will be reviewed again next round.`];\n }\n return [];\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string, stdin: PrGateCliStdin): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n return stdin.read();\n }\n}\n"]}
1
+ {"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,8DAA0D;AAC1D,iEAA6D;AAC7D,0DAAsK;AACtK,sEAAiE;AACjE,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAG/G,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CAAS;IACb,kGAAkG;IAClG,8EAA8E;IAC9E,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,IAAY,EAAE,GAAW;QACtD,IAAI,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;CACJ,CAAA;AArKY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIA,6BAAc;QAChB,mCAAY;QAChB,gDAAyB;QACzB,4CAAwB;QACtB,6CAAwB;QACjB,gCAAiB;GARhD,kBAAkB,CAqK9B;AAED;;;GAGG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACzB,IAAI,CAAC,QAAgB,EAAE,KAAqB;QACxC,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,8BAAa,CAAC,GAAG,qCAAgB,YAAY,QAAQ,kBAAkB,CAAC,CAAC;YACjH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CACJ,CAAA;AARY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAQ5B","sourcesContent":["import * as fs from 'fs';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { RepoRootFinder, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED, VERDICT_STATUSES, checklistOverrideService, summaryJsonPath } from '@webpieces/rules-config';\nimport { WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\nimport type { PrGateCliStdin } from '../pr-gate-cli-invocation';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */\nexport class ReviewBudgetCheckOptions {\n checklistId: string;\n cwd: string;\n\n constructor(checklistId: string, cwd: string) {\n this.checklistId = checklistId;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which\n * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict\n * without one, or one edited since;\n * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records\n * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the\n * same question BEFORE a reviewer spends a review on it;\n * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is\n * orange, never re-reviewed — and orange is refused before the final round, where red still means\n * \"fix it and it will be reviewed again\".\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly reviewJsonService: ReviewJsonService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const verdict = this.parse(opts.json, id, receipt);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /**\n * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse\n * on the budget, so a reviewer past the budget learns it before it reviews rather than after.\n */\n check(opts: ReviewBudgetCheckOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const final = this.isFinalRound(receipt)\n ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${VERDICT_RED} — mark every must-fix finding ${VERDICT_ORANGE}.`\n : '';\n process.stdout.write(\n `✅ \"${id}\" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `\n + `Review it, then submit with pnpm ${WRITE_REVIEW_BIN} --checklist ${id}.\\n`);\n return Promise.resolve();\n }\n\n /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */\n private isFinalRound(receipt: ReviewStageReceipt): boolean {\n return receipt.round >= receipt.maxReviewerRounds;\n }\n\n /**\n * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already\n * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions\n * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above\n * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a\n * later one) gets no second one — a round's verdict is never overwritten.\n */\n private assertWithinBudget(summaryPath: string, receipt: ReviewStageReceipt, id: string): void {\n const max = receipt.maxReviewerRounds;\n const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);\n if (receipt.round <= max && latest < receipt.round) return;\n const why = receipt.round > max\n ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`\n : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;\n throw new InformAiError(\n `I am not allowed to review ${id}: ${why}.\\n`\n + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `\n + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `\n + 'the author records any fix with pnpm wp-write-review-fixes.');\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /**\n * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits\n * the round — red only BEFORE the final round, orange only ON it (issue #1053).\n */\n private parse(json: string, id: string, receipt: ReviewStageReceipt): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n problems.push(...this.colorForRound(status, receipt));\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n /**\n * The round decides which blocking color exists. The FINAL round's red would mean \"fix it and it will be\n * reviewed again\", and there is no again — so it is refused and orange named. Orange before the final\n * round would waive a re-review that the budget still pays for — so it is refused and red named.\n */\n private colorForRound(status: string, receipt: ReviewStageReceipt): string[] {\n const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;\n if (status === VERDICT_RED && this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_RED}\" is not allowed: ${round} is the FINAL round, and there is no re-review. `\n + `Mark anything that must be fixed \"${VERDICT_ORANGE}\", with a concrete, actionable fix in \"output\" — the author applies it `\n + 'best effort and ships without another review.'];\n }\n if (status === VERDICT_ORANGE && !this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_ORANGE}\" is only for the FINAL review round, and ${round} is not it. `\n + `Use \"${VERDICT_RED}\" for a must-fix finding: the author's fix will be reviewed again next round.`];\n }\n return [];\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string, stdin: PrGateCliStdin): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n return stdin.read();\n }\n}\n"]}
@@ -4,6 +4,7 @@ exports.WriteReviewFixesInput = exports.WriteReviewFixesCommand = exports.WriteR
4
4
  const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("fs"));
6
6
  const rules_config_1 = require("@webpieces/rules-config");
7
+ const tooling_common_1 = require("@webpieces/tooling-common");
7
8
  const inversify_1 = require("inversify");
8
9
  const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
9
10
  const review_round_state_1 = require("../workflow/review-round-state");
@@ -38,7 +39,7 @@ let WriteReviewFixesCommand = class WriteReviewFixesCommand {
38
39
  const featureName = this.aiBranchName.getFeatureName();
39
40
  const receipt = this.receipts.read(repoRoot, featureName);
40
41
  if (receipt === null)
41
- throw new rules_config_1.InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');
42
+ throw new tooling_common_1.InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');
42
43
  const written = this.rounds.writeRemediation(repoRoot, (0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, opts.json);
43
44
  process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\n`);
44
45
  return Promise.resolve();
@@ -56,7 +57,7 @@ let WriteReviewFixesInput = class WriteReviewFixesInput {
56
57
  read(filePath, stdin) {
57
58
  if (filePath.trim() !== '') {
58
59
  if (!fs.existsSync(filePath))
59
- throw new rules_config_1.InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);
60
+ throw new tooling_common_1.InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);
60
61
  return fs.readFileSync(filePath, 'utf8');
61
62
  }
62
63
  return stdin.read();
@@ -1 +1 @@
1
- {"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-fixes-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAAyF;AACzF,yCAA2D;AAC3D,2EAAgE;AAChE,uEAAyE;AACzE,2EAA6E;AAG7E,MAAa,uBAAuB;IAChC,IAAI,CAAS;IACb,GAAG,CAAS;IAEZ,YAAY,IAAY,EAAE,GAAW;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,0DAQC;AAED;;;;GAIG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEX;IACA;IACA;IACA;IAJrB,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,MAA+B;QAH/B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA2B;QACnC,WAAM,GAAN,MAAM,CAAyB;IACjD,CAAC;IAEJ,GAAG,CAAC,IAA6B;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,IAAI,CAAC,YAA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der, InformAiError, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\nimport { ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport type { PrGateCliStdin } from '../pr-gate-cli-invocation';\n\nexport class WriteReviewFixesOptions {\n json: string;\n cwd: string;\n\n constructor(json: string, cwd: string) {\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/**\n * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round\n * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish\n * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewFixesOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) throw new InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');\n const written = this.rounds.writeRemediation(repoRoot, summaryJsonPath(repoRoot, featureName), receipt, opts.json);\n process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\\n`);\n return Promise.resolve();\n }\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesInput {\n read(filePath: string, stdin: PrGateCliStdin): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n return stdin.read();\n }\n}\n"]}
1
+ {"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-g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CAAC,CAAC;QAClE,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ,CAAA;AAjBY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QAChB,mCAAY;QAChB,gDAAyB;QAC3B,4CAAuB;GAL3C,uBAAuB,CAiBnC;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,IAAI,CAAC,QAAgB,EAAE,KAAqB;QACxC,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,8BAAa,CAAC,iCAAiC,QAAQ,kBAAkB,CAAC,CAAC;YACnH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;CACJ,CAAA;AARY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,qBAAqB,CAQjC","sourcesContent":["import * as fs from 'fs';\nimport { RepoRootFinder, summaryJsonPath } from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\nimport { ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport type { PrGateCliStdin } from '../pr-gate-cli-invocation';\n\nexport class WriteReviewFixesOptions {\n json: string;\n cwd: string;\n\n constructor(json: string, cwd: string) {\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/**\n * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round\n * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish\n * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewFixesOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) throw new InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');\n const written = this.rounds.writeRemediation(repoRoot, summaryJsonPath(repoRoot, featureName), receipt, opts.json);\n process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\\n`);\n return Promise.resolve();\n }\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesInput {\n read(filePath: string, stdin: PrGateCliStdin): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n return stdin.read();\n }\n}\n"]}
@@ -4,6 +4,7 @@ exports.PrGateCliApp = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const path = tslib_1.__importStar(require("path"));
6
6
  const rules_config_1 = require("@webpieces/rules-config");
7
+ const to_error_1 = require("@webpieces/tooling-common/to-error");
7
8
  const inversify_1 = require("inversify");
8
9
  const await_checks_command_1 = require("./commands/await-checks-command");
9
10
  const build_command_1 = require("./commands/build-command");
@@ -42,7 +43,7 @@ let PrGateCliApp = class PrGateCliApp {
42
43
  await this.dispatch(path.basename(invocation.binName), invocation);
43
44
  }
44
45
  catch (err) {
45
- const error = (0, rules_config_1.toError)(err);
46
+ const error = (0, to_error_1.toError)(err);
46
47
  if (err instanceof rules_config_1.CliExitError) {
47
48
  if (err.message !== '') {
48
49
  (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(err.message + '\n');
@@ -1 +1 @@
1
- {"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DASiC;AACjC,yCAA2D;AAE3D,0EAAkE;AAClE,4DAAwD;AACxD,gEASoC;AACpC,gFAA0E;AAC1E,gEAA2D;AAC3D,kEAA6D;AAC7D,0EAIyC;AACzC,sFAG+C;AAC/C,+CAA0C;AAG1C,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,MAAM,EAAE,GAAG,MAAM,CAAC;AAClB,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAChD,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,OAAO,GAAG,WAAW,CAAC;AAE5B,sEAAsE;AAE/D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEA;IACA;IACA;IACA;IAJrB,YACqB,GAAc,EACd,YAA0B,EAC1B,gBAAkC,EAClC,qBAA4C;QAH5C,QAAG,GAAH,GAAG,CAAW;QACd,iBAAY,GAAZ,YAAY,CAAc;QAC1B,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,0BAAqB,GAArB,qBAAqB,CAAuB;IAC9D,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,UAA+B;QACrC,8DAA8D;QAC9D,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,M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,EAAE;YACrF,IAAI,sBAAO,CAAC,SAAS,EAAE,6BAA6B,EAAE,IAAI,CAAC;YAC3D,IAAI,sBAAO,CAAC,IAAI,EAAE,4CAA4C,EAAE,IAAI,CAAC;YACrE,IAAI,sBAAO,CAAC,KAAK,EAAE,0DAA0D,CAAC;SACjF,CAAC,CAAC;IACP,CAAC;IAEO,qBAAqB;QACzB,OAAO,IAAI,uBAAQ,CACf,uBAAuB,EACvB,kDAAkD,EAClD,CAAC,IAAI,sBAAO,CAAC,IAAI,EAAE,gCAAgC,EAAE,IAAI,CAAC,CAAC,CAC9D,CAAC;IACN,CAAC;CACJ,CAAA;AAtWY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGX,uBAAS;QACA,8BAAY;QACR,uCAAgB;QACX,kDAAqB;GALxD,YAAY,CAsWxB","sourcesContent":["import * as path from 'path';\n\nimport {\n CliArgs,\n CliArgSet,\n CliExitError,\n CliFlag,\n CliUsage,\n RuleFailError,\n renderRuleFailForHuman,\n toError,\n} from '@webpieces/rules-config';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport { PushDevOptions } from './commands/push-dev-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REBASE_RESOLUTION = '--rebase-resolution';\nconst REMOVE = '--remove';\nconst RESOLVE = '--resolve';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-push-dev') {\n const args = this.parse(invocation, this.pushDevUsage());\n const opts = new PushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n opts.force = args.has(FORCE);\n opts.rebaseResolution = args.has(REBASE_RESOLUTION);\n opts.resolve = args.has(RESOLVE);\n opts.resolveTarget = args.value(RESOLVE);\n await this.app.pushDev(opts);\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n await this.app.finishPushDev(new FinishPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private pushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-push-dev',\n 'Publish a disposable copy of this branch for shared dev.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(REMOVE, \"Delete this branch's dev copy.\"),\n new CliFlag(\n RESOLVE,\n 'Compose other published copies, optionally one named branch.',\n true,\n ),\n new CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),\n new CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),\n ],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Commit a resolved dev composition and publish it.',\n [new CliFlag(ABORT, 'Throw the resolve away without publishing.')],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
1
+ {"version":3,"file":"pr-gate-cli-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-cli-app.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAqI;AACrI,i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;SACjF,CAAC,CAAC;IACP,CAAC;IAEO,qBAAqB;QACzB,OAAO,IAAI,uBAAQ,CACf,uBAAuB,EACvB,kDAAkD,EAClD,CAAC,IAAI,sBAAO,CAAC,IAAI,EAAE,gCAAgC,EAAE,IAAI,CAAC,CAAC,CAC9D,CAAC;IACN,CAAC;CACJ,CAAA;AAtWY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGX,uBAAS;QACA,8BAAY;QACR,uCAAgB;QACX,kDAAqB;GALxD,YAAY,CAsWxB","sourcesContent":["import * as path from 'path';\n\nimport { CliArgs, CliArgSet, CliExitError, CliFlag, CliUsage, RuleFailError, renderRuleFailForHuman } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { bindingScopeValues, injectable } from 'inversify';\n\nimport { AwaitChecksArgs } from './commands/await-checks-command';\nimport { BuildOptions } from './commands/build-command';\nimport {\n CleanupOptions,\n CleanupUsage,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n FLAG_IGNORE_STALE_LOCKS,\n FLAG_INTERACTIVE,\n FLAG_REPORT,\n} from './commands/cleanup-options';\nimport { FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { LandPrRequest } from './commands/land-pr-command';\nimport { PushDevOptions } from './commands/push-dev-command';\nimport {\n ReviewBudgetCheckOptions,\n WriteReviewInput,\n WriteReviewOptions,\n} from './commands/write-review-command';\nimport {\n WriteReviewFixesInput,\n WriteReviewFixesOptions,\n} from './commands/write-review-fixes-command';\nimport { PrGateApp } from './pr-gate-app';\nimport { PrGateCliInvocation } from './pr-gate-cli-invocation';\n\nconst ABORT = '--abort';\nconst CHECK = '--check';\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\nconst FORCE = '--force';\nconst LIST = '--list';\nconst PR = '--pr';\nconst REBASE_RESOLUTION = '--rebase-resolution';\nconst REMOVE = '--remove';\nconst RESOLVE = '--resolve';\n\n/** Stable application boundary for every published `wp-*` command. */\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateCliApp {\n constructor(\n private readonly app: PrGateApp,\n private readonly cleanupUsage: CleanupUsage,\n private readonly writeReviewInput: WriteReviewInput,\n private readonly writeReviewFixesInput: WriteReviewFixesInput,\n ) {}\n\n async run(invocation: PrGateCliInvocation): Promise<void> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n await this.dispatch(path.basename(invocation.binName), invocation);\n } catch (err: unknown) {\n const error = toError(err);\n if (err instanceof CliExitError) {\n if (err.message !== '') {\n (err.exitCode === 0 ? invocation.stdout : invocation.stderr).write(\n err.message + '\\n',\n );\n }\n invocation.processExit.exit(err.exitCode);\n return;\n }\n const message =\n err instanceof RuleFailError ? renderRuleFailForHuman(err) : error.message;\n invocation.stderr.write(message + '\\n');\n invocation.processExit.exit(1);\n }\n }\n\n private async dispatch(binName: string, invocation: PrGateCliInvocation): Promise<void> {\n if (await this.dispatchUpdateCommand(binName, invocation)) return;\n if (await this.dispatchPrCommand(binName, invocation)) return;\n if (await this.dispatchRepoCommand(binName, invocation)) return;\n if (await this.dispatchReviewCommand(binName, invocation)) return;\n throw new CliExitError(2, `Unknown PR-gate command: ${binName}`);\n }\n\n private async dispatchUpdateCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-finish-upsert-pr') {\n await this.noArgs(\n invocation,\n this.finishUpsertUsage(),\n (): Promise<void> => this.app.finishUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-upsert-pr') {\n await this.noArgs(\n invocation,\n this.startUpsertUsage(),\n (): Promise<void> => this.app.startUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-start-update') {\n await this.noArgs(\n invocation,\n this.startUpdateUsage(),\n (): Promise<void> => this.app.startUpdate(),\n );\n return true;\n }\n if (binName === 'wp-finish-update') {\n await this.noArgs(\n invocation,\n this.finishUpdateUsage(),\n (): Promise<void> => this.app.finishUpdate(),\n );\n return true;\n }\n if (binName === 'wp-sync-main') {\n await this.noArgs(\n invocation,\n this.syncMainUsage(),\n (): Promise<void> => this.app.syncMain(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchPrCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-human-post-pr') {\n await this.noArgs(\n invocation,\n this.humanPostUsage(),\n (): Promise<void> => this.app.humanPostPr(),\n );\n return true;\n }\n if (binName === 'wp-upsert-hotfix-pr') {\n await this.noArgs(\n invocation,\n this.hotfixUsage(),\n (): Promise<void> => this.app.upsertHotfixPr(),\n );\n return true;\n }\n if (binName === 'wp-check-pr') {\n await this.noArgs(\n invocation,\n this.checkPrUsage(),\n (): Promise<void> => this.app.checkPr(),\n );\n return true;\n }\n if (binName === 'wp-review-upsert-pr') {\n await this.noArgs(\n invocation,\n this.reviewUpsertUsage(),\n (): Promise<void> => this.app.reviewUpsertPr(),\n );\n return true;\n }\n if (binName === 'wp-await-reviews') {\n await this.noArgs(\n invocation,\n this.awaitReviewsUsage(),\n (): Promise<void> => this.app.awaitReviews(),\n );\n return true;\n }\n return false;\n }\n\n private async dispatchRepoCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-build') {\n const args = this.parse(invocation, this.buildUsage());\n await this.app.build(new BuildOptions(args.has(FORCE)));\n return true;\n }\n if (binName === 'wp-cleanup') {\n const args = this.parse(invocation, this.cleanupUsage.declare());\n await this.app.cleanup(\n new CleanupOptions(\n new DeleteSelection(\n FLAG_DELETE_BRANCHES,\n args.has(FLAG_DELETE_BRANCHES),\n args.value(FLAG_DELETE_BRANCHES),\n ),\n new DeleteSelection(\n FLAG_DELETE_WORKTREES,\n args.has(FLAG_DELETE_WORKTREES),\n args.value(FLAG_DELETE_WORKTREES),\n ),\n args.has(FLAG_REPORT),\n args.has(FLAG_INTERACTIVE),\n args.has(FLAG_IGNORE_STALE_LOCKS),\n ),\n );\n return true;\n }\n if (binName === 'wp-land-pr') {\n const args = this.parse(invocation, this.landUsage());\n await this.app.landPr(new LandPrRequest(args.has(PR), args.value(PR)));\n return true;\n }\n if (binName === 'wp-push-dev') {\n const args = this.parse(invocation, this.pushDevUsage());\n const opts = new PushDevOptions();\n opts.list = args.has(LIST);\n opts.remove = args.has(REMOVE);\n opts.force = args.has(FORCE);\n opts.rebaseResolution = args.has(REBASE_RESOLUTION);\n opts.resolve = args.has(RESOLVE);\n opts.resolveTarget = args.value(RESOLVE);\n await this.app.pushDev(opts);\n return true;\n }\n if (binName === 'wp-finish-push-dev') {\n const args = this.parse(invocation, this.finishPushDevUsage());\n await this.app.finishPushDev(new FinishPushDevOptions(args.has(ABORT)));\n return true;\n }\n if (binName === 'wp-await-checks') {\n const args = this.parse(invocation, this.awaitChecksUsage());\n await this.app.awaitChecks(new AwaitChecksArgs().parse(args.value(PR)));\n return true;\n }\n return false;\n }\n\n private async dispatchReviewCommand(\n binName: string,\n invocation: PrGateCliInvocation,\n ): Promise<boolean> {\n if (binName === 'wp-write-review') {\n const args = this.parse(invocation, this.writeReviewUsage());\n if (args.has(CHECK)) {\n await this.app.checkReviewBudget(\n new ReviewBudgetCheckOptions(args.value(CHECKLIST), invocation.cwd),\n );\n return true;\n }\n const json = this.writeReviewInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReview(\n new WriteReviewOptions(args.value(CHECKLIST), json, invocation.cwd),\n );\n return true;\n }\n if (binName === 'wp-write-review-fixes') {\n const args = this.parse(invocation, this.writeReviewFixesUsage());\n const json = this.writeReviewFixesInput.read(args.value(FILE), invocation.stdin);\n await this.app.writeReviewFixes(new WriteReviewFixesOptions(json, invocation.cwd));\n return true;\n }\n return false;\n }\n\n private parse(invocation: PrGateCliInvocation, usage: CliUsage): CliArgSet {\n return new CliArgs().parseArgs(invocation.argv, usage);\n }\n\n private async noArgs(\n invocation: PrGateCliInvocation,\n usage: CliUsage,\n action: () => Promise<void>,\n ): Promise<void> {\n this.parse(invocation, usage);\n await action();\n }\n\n private buildUsage(): CliUsage {\n return new CliUsage(\n 'wp-build',\n 'Run this repo`s configured build (commands.pr-gate.buildCommand) — the same command the PR gate runs.',\n [\n new CliFlag(\n FORCE,\n 'Build even though this machine is already at its concurrent-build limit.',\n ),\n ],\n );\n }\n\n private finishUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-upsert-pr',\n 'Finalize the merge, run the authoritative build gate, render the dashboard, and create/update the PR.',\n );\n }\n private humanPostUsage(): CliUsage {\n return new CliUsage(\n 'wp-human-post-pr',\n 'Interactively attest that a human is posting the current clean, current-main feature branch.',\n );\n }\n private hotfixUsage(): CliUsage {\n return new CliUsage(\n 'wp-upsert-hotfix-pr',\n 'Publish the current /hotfix/ branch through the hotfix gate.',\n );\n }\n private startUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-upsert-pr',\n 'Update from main and hand off the PR review stage.',\n );\n }\n private startUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-start-update',\n '3-point squash-update this feature branch from main (no PR).',\n );\n }\n private finishUpdateUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-update',\n 'Validate + finalize a resolved 3-point merge (no PR).',\n );\n }\n private syncMainUsage(): CliUsage {\n return new CliUsage(\n 'wp-sync-main',\n 'Go to main, fast-forward it, reap dead worktrees and branches, and sweep orphan directories.',\n );\n }\n private checkPrUsage(): CliUsage {\n return new CliUsage(\n 'wp-check-pr',\n 'CI check: verify this PR was created through the webpieces gated flow (valid gate token).',\n );\n }\n private reviewUpsertUsage(): CliUsage {\n return new CliUsage(\n 'wp-review-upsert-pr',\n 'Validate the merge, build, extract the diff, and brief required reviewers.',\n );\n }\n private awaitReviewsUsage(): CliUsage {\n return new CliUsage('wp-await-reviews', 'Block until every reviewer verdict has landed.');\n }\n\n private landUsage(): CliUsage {\n return new CliUsage(\n 'wp-land-pr',\n 'Squash-merge a PR into main with its description as the commit body.',\n [new CliFlag(PR, 'The PR number to land.', true)],\n );\n }\n\n private pushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-push-dev',\n 'Publish a disposable copy of this branch for shared dev.',\n [\n new CliFlag(LIST, 'List published dev copies.'),\n new CliFlag(REMOVE, \"Delete this branch's dev copy.\"),\n new CliFlag(\n RESOLVE,\n 'Compose other published copies, optionally one named branch.',\n true,\n ),\n new CliFlag(REBASE_RESOLUTION, 'Replay an existing resolution onto new commits.'),\n new CliFlag(FORCE, 'Discard the published resolution and overwrite it.'),\n ],\n );\n }\n\n private finishPushDevUsage(): CliUsage {\n return new CliUsage(\n 'wp-finish-push-dev',\n 'Commit a resolved dev composition and publish it.',\n [new CliFlag(ABORT, 'Throw the resolve away without publishing.')],\n );\n }\n\n private awaitChecksUsage(): CliUsage {\n return new CliUsage('wp-await-checks', 'Block until checks on one PR stop running.', [\n new CliFlag(PR, 'REQUIRED. The PR number to wait on.', true),\n ]);\n }\n\n private writeReviewUsage(): CliUsage {\n return new CliUsage('wp-write-review', 'Submit one reviewer verdict for one checklist.', [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id.', true),\n new CliFlag(FILE, 'The verdict JSON file. Omit to read stdin.', true),\n new CliFlag(CHECK, 'Only check whether this checklist may still be reviewed.'),\n ]);\n }\n\n private writeReviewFixesUsage(): CliUsage {\n return new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinator response to red findings.',\n [new CliFlag(FILE, 'JSON file. Omit to read stdin.', true)],\n );\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
- import { BuildsLog, BranchIdentity } from '@webpieces/rules-config';
1
+ import { BuildsLog } from '@webpieces/rules-config';
2
+ import { BranchIdentity } from '@webpieces/repo-workflow-core';
2
3
  import { BuildGateLog } from './build-gate-log';
3
4
  import { StageOutputLog } from './stage-output-log';
4
5
  /**
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildAffected = exports.BuildGateOptions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const rules_config_1 = require("@webpieces/rules-config");
6
+ const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
6
7
  const inversify_1 = require("inversify");
7
8
  const build_gate_log_1 = require("./build-gate-log");
8
9
  const stage_output_log_1 = require("./stage-output-log");
@@ -128,6 +129,6 @@ exports.BuildAffected = BuildAffected = tslib_1.__decorate([
128
129
  tslib_1.__metadata("design:paramtypes", [build_gate_log_1.BuildGateLog,
129
130
  rules_config_1.BuildsLog,
130
131
  stage_output_log_1.StageOutputLog,
131
- rules_config_1.BranchIdentity])
132
+ repo_workflow_core_1.BranchIdentity])
132
133
  ], BuildAffected);
133
134
  //# sourceMappingURL=build-affected.js.map