@webpieces/pr-gate 0.4.822 → 0.4.824

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 (74) hide show
  1. package/package.json +5 -3
  2. package/src/dashboard/checklist-comment-renderer.js +6 -4
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/dashboard.js +6 -1
  5. package/src/dashboard/dashboard.js.map +1 -1
  6. package/src/index.d.ts +1 -1
  7. package/src/index.js +1 -1
  8. package/src/index.js.map +1 -1
  9. package/src/scripts/commands/build-command.d.ts +3 -0
  10. package/src/scripts/commands/build-command.js +29 -17
  11. package/src/scripts/commands/build-command.js.map +1 -1
  12. package/src/scripts/commands/check-pr-command.d.ts +10 -3
  13. package/src/scripts/commands/check-pr-command.js +31 -10
  14. package/src/scripts/commands/check-pr-command.js.map +1 -1
  15. package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
  16. package/src/scripts/commands/finish-upsert-pr-command.js +26 -5
  17. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  18. package/src/scripts/commands/human-post-pr-command.d.ts +52 -0
  19. package/src/scripts/commands/human-post-pr-command.js +260 -0
  20. package/src/scripts/commands/human-post-pr-command.js.map +1 -0
  21. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -1
  22. package/src/scripts/commands/review-upsert-pr-command.js +40 -23
  23. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  24. package/src/scripts/commands/write-review-command.d.ts +3 -1
  25. package/src/scripts/commands/write-review-command.js +9 -3
  26. package/src/scripts/commands/write-review-command.js.map +1 -1
  27. package/src/scripts/commands/write-review-fixes-command.d.ts +21 -0
  28. package/src/scripts/commands/write-review-fixes-command.js +68 -0
  29. package/src/scripts/commands/write-review-fixes-command.js.map +1 -0
  30. package/src/scripts/pr-gate-app.d.ts +9 -1
  31. package/src/scripts/pr-gate-app.js +18 -1
  32. package/src/scripts/pr-gate-app.js.map +1 -1
  33. package/src/scripts/workflow/build-affected.d.ts +3 -0
  34. package/src/scripts/workflow/build-affected.js +16 -3
  35. package/src/scripts/workflow/build-affected.js.map +1 -1
  36. package/src/scripts/workflow/build-gate-log.d.ts +4 -1
  37. package/src/scripts/workflow/build-gate-log.js +20 -5
  38. package/src/scripts/workflow/build-gate-log.js.map +1 -1
  39. package/src/scripts/workflow/build-log-follower.d.ts +13 -0
  40. package/src/scripts/workflow/build-log-follower.js +48 -0
  41. package/src/scripts/workflow/build-log-follower.js.map +1 -0
  42. package/src/scripts/workflow/checklist-scanner.d.ts +1 -3
  43. package/src/scripts/workflow/checklist-scanner.js +6 -9
  44. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  45. package/src/scripts/workflow/gated-pr-publisher.d.ts +1 -1
  46. package/src/scripts/workflow/gated-pr-publisher.js +20 -7
  47. package/src/scripts/workflow/gated-pr-publisher.js.map +1 -1
  48. package/src/scripts/workflow/push-dev-state.js +30 -17
  49. package/src/scripts/workflow/push-dev-state.js.map +1 -1
  50. package/src/scripts/workflow/repo-config-testkit.js +2 -0
  51. package/src/scripts/workflow/repo-config-testkit.js.map +1 -1
  52. package/src/scripts/workflow/review-report.d.ts +7 -4
  53. package/src/scripts/workflow/review-report.js +44 -24
  54. package/src/scripts/workflow/review-report.js.map +1 -1
  55. package/src/scripts/workflow/review-round-state.d.ts +58 -0
  56. package/src/scripts/workflow/review-round-state.js +300 -0
  57. package/src/scripts/workflow/review-round-state.js.map +1 -0
  58. package/src/scripts/workflow/review-stage-receipt.d.ts +6 -0
  59. package/src/scripts/workflow/review-stage-receipt.js +13 -0
  60. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  61. package/src/scripts/workflow/reviewer-verdict-gate.js +6 -24
  62. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  63. package/src/scripts/workflow/verdict-provenance.d.ts +3 -8
  64. package/src/scripts/workflow/verdict-provenance.js +7 -17
  65. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
  66. package/src/scripts/wp-human-post-pr.d.ts +2 -0
  67. package/src/scripts/wp-human-post-pr.js +15 -0
  68. package/src/scripts/wp-human-post-pr.js.map +1 -0
  69. package/src/scripts/wp-write-review-fixes.d.ts +2 -0
  70. package/src/scripts/wp-write-review-fixes.js +16 -0
  71. package/src/scripts/wp-write-review-fixes.js.map +1 -0
  72. package/src/scripts/workflow/git-validateUpToDate.d.ts +0 -1
  73. package/src/scripts/workflow/git-validateUpToDate.js +0 -70
  74. package/src/scripts/workflow/git-validateUpToDate.js.map +0 -1
@@ -27,6 +27,7 @@ export declare class VerdictProvenance {
27
27
  status: string;
28
28
  verdictHash: string;
29
29
  writtenAt: string;
30
+ round: number;
30
31
  constructor(checklistId: string, harness: string, sessionId: string, agentId: string, agentType: string, headSha: string, scopeHash: string);
31
32
  }
32
33
  /** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */
@@ -75,16 +76,10 @@ export declare class VerdictProvenanceService {
75
76
  read(summaryPath: string, checklistId: string): VerdictProvenance | null;
76
77
  /**
77
78
  * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it
78
- * could not be computed, which never marks anything stale). `singleRound` is the machine's
79
- * `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what
80
- * that experimental flag already promises:
81
- * - scope never goes STALE: one round means one round, and its verdicts are the review record;
82
- * - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in
83
- * place — is accepted, and nothing else is.
79
+ * could not be computed, which never marks anything stale).
84
80
  */
85
- assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string, singleRound: boolean): VerdictStanding;
81
+ assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string): VerdictStanding;
86
82
  /** The first 8 characters of a sha, the way every banner line prints one. */
87
83
  short(sha: string): string;
88
- private matchesSubmission;
89
84
  private str;
90
85
  }
@@ -49,6 +49,7 @@ class VerdictProvenance {
49
49
  status; // the status as submitted
50
50
  verdictHash; // VerdictProvenanceService.canonicalHash of the verdict as submitted
51
51
  writtenAt;
52
+ round;
52
53
  // eslint-disable-next-line @typescript-eslint/max-params
53
54
  constructor(checklistId, harness, sessionId, agentId, agentType, headSha, scopeHash) {
54
55
  this.writer = rules_config_1.WRITE_REVIEW_BIN;
@@ -62,6 +63,7 @@ class VerdictProvenance {
62
63
  this.status = '';
63
64
  this.verdictHash = '';
64
65
  this.writtenAt = '';
66
+ this.round = 0;
65
67
  }
66
68
  }
67
69
  exports.VerdictProvenance = VerdictProvenance;
@@ -146,6 +148,7 @@ let VerdictProvenanceService = class VerdictProvenanceService {
146
148
  record.status = this.str(raw['status']);
147
149
  record.verdictHash = this.str(raw['verdictHash']);
148
150
  record.writtenAt = this.str(raw['writtenAt']);
151
+ record.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] : 0;
149
152
  return record;
150
153
  }
151
154
  catch (err) {
@@ -156,15 +159,10 @@ let VerdictProvenanceService = class VerdictProvenanceService {
156
159
  }
157
160
  /**
158
161
  * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it
159
- * could not be computed, which never marks anything stale). `singleRound` is the machine's
160
- * `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what
161
- * that experimental flag already promises:
162
- * - scope never goes STALE: one round means one round, and its verdicts are the review record;
163
- * - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in
164
- * place — is accepted, and nothing else is.
162
+ * could not be computed, which never marks anything stale).
165
163
  */
166
164
  // eslint-disable-next-line @typescript-eslint/max-params
167
- assess(summaryPath, result, currentScopeHash, singleRound) {
165
+ assess(summaryPath, result, currentScopeHash) {
168
166
  const id = result.id;
169
167
  const record = this.read(summaryPath, id);
170
168
  const reject = (reason) => new VerdictStanding(id, exports.STANDING_REJECTED, result.status, '', reason);
@@ -180,10 +178,10 @@ let VerdictProvenanceService = class VerdictProvenanceService {
180
178
  return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);
181
179
  }
182
180
  const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);
183
- if (!this.matchesSubmission(submitted, record, singleRound)) {
181
+ if (this.canonicalHash(submitted) !== record.verdictHash) {
184
182
  return reject(`review-${id}.json was EDITED after ${rules_config_1.WRITE_REVIEW_BIN} wrote it — a verdict is the reviewer's words, not a draft`);
185
183
  }
186
- if (!singleRound && currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {
184
+ if (currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {
187
185
  return new VerdictStanding(id, exports.STANDING_STALE, result.status, record.headSha, `in-scope files CHANGED since the verdict was written at ${this.short(record.headSha)}`);
188
186
  }
189
187
  return new VerdictStanding(id, exports.STANDING_CURRENT, result.status, record.headSha, `in-scope files unchanged since ${this.short(record.headSha)}`);
@@ -192,14 +190,6 @@ let VerdictProvenanceService = class VerdictProvenanceService {
192
190
  short(sha) {
193
191
  return sha === '' ? '(unknown sha)' : sha.slice(0, 8);
194
192
  }
195
- matchesSubmission(submitted, record, singleRound) {
196
- if (this.canonicalHash(submitted) === record.verdictHash)
197
- return true;
198
- if (!singleRound || record.status !== rules_config_1.VERDICT_RED || submitted.status !== rules_config_1.VERDICT_YELLOW)
199
- return false;
200
- const asSubmitted = new SubmittedVerdict(submitted.id, rules_config_1.VERDICT_RED, submitted.agent, submitted.model, submitted.output);
201
- return this.canonicalHash(asSubmitted) === record.verdictHash;
202
- }
203
193
  // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string
204
194
  str(value) {
205
195
  return typeof value === 'string' ? value : '';
@@ -1 +1 @@
1
- {"version":3,"file":"verdict-provenance.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verdict-provenance.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAE3D,6GAA6G;AAChG,QAAA,gBAAgB,GAAG,UAAU,CAAC;AAE3C,MAAM,YAAY,GACd,2GAA2G;IAC3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,CAAC,EAAE,EAAE,0BAAW,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QACxH,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC;IAClE,CAAC;IAED,kFAAkF;IAC1E,GAAG,CAAC,KAAc;QACtB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,CAAC;CACJ,CAAA;AA5GY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGG,gCAAiB;QACxB,yBAAU;GAHlC,wBAAwB,CA4GpC","sourcesContent":["import * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n AtomicFile, ChecklistResult, ReviewJsonService, VERDICT_RED, VERDICT_YELLOW, WRITE_REVIEW_BIN, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** `harness` for a verdict submitted from a plain terminal — a HUMAN reviewer, with no AI harness at all. */\nexport const HARNESS_TERMINAL = 'terminal';\n\nconst WHAT_THIS_IS =\n 'PROVENANCE — written by pnpm wp-write-review beside the verdict it submitted, never by an AI. It records ' +\n 'WHO submitted that verdict (harness, session, agent — as the harness reported them to the PreToolUse ' +\n 'hook), WHICH commit and in-scope diff the reviewer was briefed on, and a hash of the verdict itself. ' +\n 'wp-finish-upsert-pr rejects a verdict with no provenance, or one edited after submission. Do not ' +\n 'hand-edit or copy it: that is forging a review.';\n\n/** A verdict exactly as `wp-write-review` accepts it — the five fields and nothing else. Data-only. */\nexport class SubmittedVerdict {\n id: string;\n status: string;\n agent: string;\n model: string;\n output: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, status: string, agent: string, model: string, output: string) {\n this.id = id;\n this.status = status;\n this.agent = agent;\n this.model = model;\n this.output = output;\n }\n}\n\n/**\n * The record `wp-write-review` writes to `review-<id>.provenance.json`. Data-only; field names are the JSON\n * keys, `_WHAT_THIS_IS` first so a reader learns what the file is before anything it might act on.\n */\nexport class VerdictProvenance {\n // webpieces-disable naming-convention -- the leading underscore marks a note-to-the-reader key, not data\n _WHAT_THIS_IS = WHAT_THIS_IS;\n writer: string; // always WRITE_REVIEW_BIN — a record naming anything else was not written by it\n checklistId: string;\n harness: string; // 'claude-code' | 'codex' | HARNESS_TERMINAL\n sessionId: string;\n agentId: string; // the SUBAGENT that submitted; '' only for HARNESS_TERMINAL\n agentType: string;\n headSha: string; // the commit stage ② briefed this reviewer on\n scopeHash: string; // ChecklistScopeHasher's hash of this checklist's in-scope diff at that commit\n status: string; // the status as submitted\n verdictHash: string; // VerdictProvenanceService.canonicalHash of the verdict as submitted\n writtenAt: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, harness: string, sessionId: string, agentId: string, agentType: string, headSha: string, scopeHash: string) {\n this.writer = WRITE_REVIEW_BIN;\n this.checklistId = checklistId;\n this.harness = harness;\n this.sessionId = sessionId;\n this.agentId = agentId;\n this.agentType = agentType;\n this.headSha = headSha;\n this.scopeHash = scopeHash;\n this.status = '';\n this.verdictHash = '';\n this.writtenAt = '';\n }\n}\n\n/** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */\nexport const STANDING_CURRENT = 'current';\n/** Submitted through the bin, but the checklist's in-scope diff has changed since — it judged other code. */\nexport const STANDING_STALE = 'stale';\n/** No bin provenance, or edited after submission: not a reviewer's verdict at all. */\nexport const STANDING_REJECTED = 'rejected';\n\n/**\n * How ONE existing verdict file stands against the branch as it is now. Data-only. Carried on the\n * checklist scan so stage ② (which briefs) and stage ③ (which blocks) read one answer.\n */\nexport class VerdictStanding {\n checklistId: string;\n standing: string; // STANDING_CURRENT | STANDING_STALE | STANDING_REJECTED\n status: string; // the verdict's own green | yellow | red\n fromSha: string; // the commit it was briefed on ('' when rejected)\n reason: string; // why — printed verbatim\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, standing: string, status: string, fromSha: string, reason: string) {\n this.checklistId = checklistId;\n this.standing = standing;\n this.status = status;\n this.fromSha = fromSha;\n this.reason = reason;\n }\n}\n\n/**\n * Writes a submitted verdict WITH its provenance, and judges an existing verdict against it (issue #863).\n *\n * This is what closes the forgery the issue measured: a Codex coordinator wrote five `review-<id>.json`\n * files itself and the gate accepted them, because nothing distinguished a reviewer's verdict from a file\n * that merely had the right shape. Now a verdict counts only when `wp-write-review` wrote it — which it does\n * only for a caller the harness identified as a subagent — and only while it still says exactly what was\n * submitted.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class VerdictProvenanceService {\n constructor(\n private readonly reviewJsonService: ReviewJsonService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n /** `review-<id>.provenance.json`, beside the verdict. */\n provenancePath(summaryPath: string, checklistId: string): string {\n return path.join(path.dirname(summaryPath), `review-${checklistId}.provenance.json`);\n }\n\n /**\n * sha256 over the five fields in a FIXED order, so formatting, key order and whitespace outside the\n * values cannot move it — only a change to what the verdict SAYS can.\n */\n canonicalHash(verdict: SubmittedVerdict): string {\n const canonical = JSON.stringify([verdict.id, verdict.status, verdict.agent, verdict.model, verdict.output]);\n return crypto.createHash('sha256').update(canonical).digest('hex');\n }\n\n /** Write the verdict, then its provenance. Returns the verdict path. */\n write(summaryPath: string, verdict: SubmittedVerdict, provenance: VerdictProvenance): string {\n const verdictPath = this.reviewJsonService.checklistResultPath(summaryPath, verdict.id);\n provenance.status = verdict.status;\n provenance.verdictHash = this.canonicalHash(verdict);\n provenance.writtenAt = new Date().toISOString();\n this.atomicFile.writeJsonAtomic(verdictPath, verdict);\n this.atomicFile.writeJsonAtomic(this.provenancePath(summaryPath, verdict.id), provenance);\n return verdictPath;\n }\n\n /** The provenance for one checklist, or null when there is none (or it is unreadable). */\n read(summaryPath: string, checklistId: string): VerdictProvenance | null {\n const file = this.provenancePath(summaryPath, checklistId);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable record is treated as no record, which REJECTS the verdict\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<string, unknown>;\n const record = new VerdictProvenance(\n this.str(raw['checklistId']), this.str(raw['harness']), this.str(raw['sessionId']),\n this.str(raw['agentId']), this.str(raw['agentType']), this.str(raw['headSha']), this.str(raw['scopeHash']));\n record.writer = this.str(raw['writer']);\n record.status = this.str(raw['status']);\n record.verdictHash = this.str(raw['verdictHash']);\n record.writtenAt = this.str(raw['writtenAt']);\n return record;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it\n * could not be computed, which never marks anything stale). `singleRound` is the machine's\n * `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what\n * that experimental flag already promises:\n * - scope never goes STALE: one round means one round, and its verdicts are the review record;\n * - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in\n * place — is accepted, and nothing else is.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string, singleRound: boolean): VerdictStanding {\n const id = result.id;\n const record = this.read(summaryPath, id);\n const reject = (reason: string): VerdictStanding => new VerdictStanding(id, STANDING_REJECTED, result.status, '', reason);\n if (record === null) {\n const file = this.provenancePath(summaryPath, id);\n const why = fs.existsSync(file) ? `${path.basename(file)} is unreadable` : `no ${path.basename(file)}`;\n return reject(`review-${id}.json was not submitted through pnpm ${WRITE_REVIEW_BIN} (${why}) — a hand-written verdict is not a review`);\n }\n if (record.writer !== WRITE_REVIEW_BIN || record.checklistId !== id) {\n return reject(`review-${id}.provenance.json was not written by ${WRITE_REVIEW_BIN} for this checklist`);\n }\n if (record.agentId.trim() === '' && record.harness !== HARNESS_TERMINAL) {\n return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);\n }\n const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);\n if (!this.matchesSubmission(submitted, record, singleRound)) {\n return reject(`review-${id}.json was EDITED after ${WRITE_REVIEW_BIN} wrote it — a verdict is the reviewer's words, not a draft`);\n }\n if (!singleRound && currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {\n return new VerdictStanding(id, STANDING_STALE, result.status, record.headSha,\n `in-scope files CHANGED since the verdict was written at ${this.short(record.headSha)}`);\n }\n return new VerdictStanding(id, STANDING_CURRENT, result.status, record.headSha,\n `in-scope files unchanged since ${this.short(record.headSha)}`);\n }\n\n /** The first 8 characters of a sha, the way every banner line prints one. */\n short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n private matchesSubmission(submitted: SubmittedVerdict, record: VerdictProvenance, singleRound: boolean): boolean {\n if (this.canonicalHash(submitted) === record.verdictHash) return true;\n if (!singleRound || record.status !== VERDICT_RED || submitted.status !== VERDICT_YELLOW) return false;\n const asSubmitted = new SubmittedVerdict(submitted.id, VERDICT_RED, submitted.agent, submitted.model, submitted.output);\n return this.canonicalHash(asSubmitted) === record.verdictHash;\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string\n private str(value: unknown): string {\n return typeof value === 'string' ? value : '';\n }\n}\n"]}
1
+ {"version":3,"file":"verdict-provenance.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verdict-provenance.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAE3D,6GAA6G;AAChG,QAAA,gBAAgB,GAAG,UAAU,CAAC;AAE3C,MAAM,YAAY,GACd,2GA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KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,CAAC;CACJ,CAAA;AAjGY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGG,gCAAiB;QACxB,yBAAU;GAHlC,wBAAwB,CAiGpC","sourcesContent":["import * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n AtomicFile, ChecklistResult, ReviewJsonService, WRITE_REVIEW_BIN, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** `harness` for a verdict submitted from a plain terminal — a HUMAN reviewer, with no AI harness at all. */\nexport const HARNESS_TERMINAL = 'terminal';\n\nconst WHAT_THIS_IS =\n 'PROVENANCE — written by pnpm wp-write-review beside the verdict it submitted, never by an AI. It records ' +\n 'WHO submitted that verdict (harness, session, agent — as the harness reported them to the PreToolUse ' +\n 'hook), WHICH commit and in-scope diff the reviewer was briefed on, and a hash of the verdict itself. ' +\n 'wp-finish-upsert-pr rejects a verdict with no provenance, or one edited after submission. Do not ' +\n 'hand-edit or copy it: that is forging a review.';\n\n/** A verdict exactly as `wp-write-review` accepts it — the five fields and nothing else. Data-only. */\nexport class SubmittedVerdict {\n id: string;\n status: string;\n agent: string;\n model: string;\n output: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, status: string, agent: string, model: string, output: string) {\n this.id = id;\n this.status = status;\n this.agent = agent;\n this.model = model;\n this.output = output;\n }\n}\n\n/**\n * The record `wp-write-review` writes to `review-<id>.provenance.json`. Data-only; field names are the JSON\n * keys, `_WHAT_THIS_IS` first so a reader learns what the file is before anything it might act on.\n */\nexport class VerdictProvenance {\n // webpieces-disable naming-convention -- the leading underscore marks a note-to-the-reader key, not data\n _WHAT_THIS_IS = WHAT_THIS_IS;\n writer: string; // always WRITE_REVIEW_BIN — a record naming anything else was not written by it\n checklistId: string;\n harness: string; // 'claude-code' | 'codex' | HARNESS_TERMINAL\n sessionId: string;\n agentId: string; // the SUBAGENT that submitted; '' only for HARNESS_TERMINAL\n agentType: string;\n headSha: string; // the commit stage ② briefed this reviewer on\n scopeHash: string; // ChecklistScopeHasher's hash of this checklist's in-scope diff at that commit\n status: string; // the status as submitted\n verdictHash: string; // VerdictProvenanceService.canonicalHash of the verdict as submitted\n writtenAt: string;\n round: number;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, harness: string, sessionId: string, agentId: string, agentType: string, headSha: string, scopeHash: string) {\n this.writer = WRITE_REVIEW_BIN;\n this.checklistId = checklistId;\n this.harness = harness;\n this.sessionId = sessionId;\n this.agentId = agentId;\n this.agentType = agentType;\n this.headSha = headSha;\n this.scopeHash = scopeHash;\n this.status = '';\n this.verdictHash = '';\n this.writtenAt = '';\n this.round = 0;\n }\n}\n\n/** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */\nexport const STANDING_CURRENT = 'current';\n/** Submitted through the bin, but the checklist's in-scope diff has changed since — it judged other code. */\nexport const STANDING_STALE = 'stale';\n/** No bin provenance, or edited after submission: not a reviewer's verdict at all. */\nexport const STANDING_REJECTED = 'rejected';\n\n/**\n * How ONE existing verdict file stands against the branch as it is now. Data-only. Carried on the\n * checklist scan so stage ② (which briefs) and stage ③ (which blocks) read one answer.\n */\nexport class VerdictStanding {\n checklistId: string;\n standing: string; // STANDING_CURRENT | STANDING_STALE | STANDING_REJECTED\n status: string; // the verdict's own green | yellow | red\n fromSha: string; // the commit it was briefed on ('' when rejected)\n reason: string; // why — printed verbatim\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, standing: string, status: string, fromSha: string, reason: string) {\n this.checklistId = checklistId;\n this.standing = standing;\n this.status = status;\n this.fromSha = fromSha;\n this.reason = reason;\n }\n}\n\n/**\n * Writes a submitted verdict WITH its provenance, and judges an existing verdict against it (issue #863).\n *\n * This is what closes the forgery the issue measured: a Codex coordinator wrote five `review-<id>.json`\n * files itself and the gate accepted them, because nothing distinguished a reviewer's verdict from a file\n * that merely had the right shape. Now a verdict counts only when `wp-write-review` wrote it — which it does\n * only for a caller the harness identified as a subagent — and only while it still says exactly what was\n * submitted.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class VerdictProvenanceService {\n constructor(\n private readonly reviewJsonService: ReviewJsonService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n /** `review-<id>.provenance.json`, beside the verdict. */\n provenancePath(summaryPath: string, checklistId: string): string {\n return path.join(path.dirname(summaryPath), `review-${checklistId}.provenance.json`);\n }\n\n /**\n * sha256 over the five fields in a FIXED order, so formatting, key order and whitespace outside the\n * values cannot move it — only a change to what the verdict SAYS can.\n */\n canonicalHash(verdict: SubmittedVerdict): string {\n const canonical = JSON.stringify([verdict.id, verdict.status, verdict.agent, verdict.model, verdict.output]);\n return crypto.createHash('sha256').update(canonical).digest('hex');\n }\n\n /** Write the verdict, then its provenance. Returns the verdict path. */\n write(summaryPath: string, verdict: SubmittedVerdict, provenance: VerdictProvenance): string {\n const verdictPath = this.reviewJsonService.checklistResultPath(summaryPath, verdict.id);\n provenance.status = verdict.status;\n provenance.verdictHash = this.canonicalHash(verdict);\n provenance.writtenAt = new Date().toISOString();\n this.atomicFile.writeJsonAtomic(verdictPath, verdict);\n this.atomicFile.writeJsonAtomic(this.provenancePath(summaryPath, verdict.id), provenance);\n return verdictPath;\n }\n\n /** The provenance for one checklist, or null when there is none (or it is unreadable). */\n read(summaryPath: string, checklistId: string): VerdictProvenance | null {\n const file = this.provenancePath(summaryPath, checklistId);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable record is treated as no record, which REJECTS the verdict\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<string, unknown>;\n const record = new VerdictProvenance(\n this.str(raw['checklistId']), this.str(raw['harness']), this.str(raw['sessionId']),\n this.str(raw['agentId']), this.str(raw['agentType']), this.str(raw['headSha']), this.str(raw['scopeHash']));\n record.writer = this.str(raw['writer']);\n record.status = this.str(raw['status']);\n record.verdictHash = this.str(raw['verdictHash']);\n record.writtenAt = this.str(raw['writtenAt']);\n record.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] as number : 0;\n return record;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it\n * could not be computed, which never marks anything stale).\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string): VerdictStanding {\n const id = result.id;\n const record = this.read(summaryPath, id);\n const reject = (reason: string): VerdictStanding => new VerdictStanding(id, STANDING_REJECTED, result.status, '', reason);\n if (record === null) {\n const file = this.provenancePath(summaryPath, id);\n const why = fs.existsSync(file) ? `${path.basename(file)} is unreadable` : `no ${path.basename(file)}`;\n return reject(`review-${id}.json was not submitted through pnpm ${WRITE_REVIEW_BIN} (${why}) — a hand-written verdict is not a review`);\n }\n if (record.writer !== WRITE_REVIEW_BIN || record.checklistId !== id) {\n return reject(`review-${id}.provenance.json was not written by ${WRITE_REVIEW_BIN} for this checklist`);\n }\n if (record.agentId.trim() === '' && record.harness !== HARNESS_TERMINAL) {\n return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);\n }\n const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);\n if (this.canonicalHash(submitted) !== record.verdictHash) {\n return reject(`review-${id}.json was EDITED after ${WRITE_REVIEW_BIN} wrote it — a verdict is the reviewer's words, not a draft`);\n }\n if (currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {\n return new VerdictStanding(id, STANDING_STALE, result.status, record.headSha,\n `in-scope files CHANGED since the verdict was written at ${this.short(record.headSha)}`);\n }\n return new VerdictStanding(id, STANDING_CURRENT, result.status, record.headSha,\n `in-scope files unchanged since ${this.short(record.headSha)}`);\n }\n\n /** The first 8 characters of a sha, the way every banner line prints one. */\n short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string\n private str(value: unknown): string {\n return typeof value === 'string' ? value : '';\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'reflect-metadata';
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const rules_config_1 = require("@webpieces/rules-config");
7
+ const pr_gate_app_1 = require("./pr-gate-app");
8
+ (0, rules_config_1.runMain)(async () => {
9
+ const container = new inversify_1.Container({ autobind: true });
10
+ container
11
+ .get(rules_config_1.CliArgs)
12
+ .assertNoArgs(new rules_config_1.CliUsage('wp-human-post-pr', 'Interactively attest that a human is posting the current clean, current-main feature branch.'));
13
+ await container.get(pr_gate_app_1.PrGateApp).humanPostPr();
14
+ });
15
+ //# sourceMappingURL=wp-human-post-pr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-human-post-pr.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-human-post-pr.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAAqE;AACrE,+CAA0C;AAE1C,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,SAAS;SACJ,GAAG,CAAC,sBAAO,CAAC;SACZ,YAAY,CACT,IAAI,uBAAQ,CACR,kBAAkB,EAClB,8FAA8F,CACjG,CACJ,CAAC;IACN,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACjD,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { CliArgs, CliUsage, runMain } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\n\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n container\n .get(CliArgs)\n .assertNoArgs(\n 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 await container.get(PrGateApp).humanPostPr();\n});\n"]}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import 'reflect-metadata';
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("reflect-metadata");
5
+ const inversify_1 = require("inversify");
6
+ const rules_config_1 = require("@webpieces/rules-config");
7
+ const pr_gate_app_1 = require("./pr-gate-app");
8
+ const write_review_fixes_command_1 = require("./commands/write-review-fixes-command");
9
+ const FILE = '--file';
10
+ (0, rules_config_1.runMain)(async () => {
11
+ const container = new inversify_1.Container({ autobind: true });
12
+ const args = container.get(rules_config_1.CliArgs).parse(new rules_config_1.CliUsage('wp-write-review-fixes', 'Record the coordinating agent response to every red finding in the completed reviewer round.', [new rules_config_1.CliFlag(FILE, 'JSON file. Omit to pass JSON on stdin.', true)]));
13
+ const json = container.get(write_review_fixes_command_1.WriteReviewFixesInput).read(args.value(FILE));
14
+ await container.get(pr_gate_app_1.PrGateApp).writeReviewFixes(new write_review_fixes_command_1.WriteReviewFixesOptions(json, process.cwd()));
15
+ });
16
+ //# sourceMappingURL=wp-write-review-fixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-write-review-fixes.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-write-review-fixes.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAA8E;AAC9E,+CAA0C;AAC1C,sFAAuG;AAEvG,MAAM,IAAI,GAAG,QAAQ,CAAC;AAEtB,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,sBAAO,CAAC,CAAC,KAAK,CAAC,IAAI,uBAAQ,CAClD,uBAAuB,EACvB,8FAA8F,EAC9F,CAAC,IAAI,sBAAO,CAAC,IAAI,EAAE,wCAAwC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,kDAAqB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,gBAAgB,CAAC,IAAI,oDAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { CliArgs, CliFlag, CliUsage, runMain } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\nimport { WriteReviewFixesInput, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\n\nconst FILE = '--file';\n\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n const args = container.get(CliArgs).parse(new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinating agent response to every red finding in the completed reviewer round.',\n [new CliFlag(FILE, 'JSON file. Omit to pass JSON on stdin.', true)]));\n const json = container.get(WriteReviewFixesInput).read(args.value(FILE));\n await container.get(PrGateApp).writeReviewFixes(new WriteReviewFixesOptions(json, process.cwd()));\n});\n"]}
@@ -1 +0,0 @@
1
- export declare function main(): Promise<void>;
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = main;
4
- const child_process_1 = require("child_process");
5
- const rules_config_1 = require("@webpieces/rules-config");
6
- const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
7
- async function main() {
8
- const branch = (0, child_process_1.execSync)('git branch --show-current', { encoding: 'utf8' }).trim();
9
- if (branch === 'main') {
10
- process.stdout.write('✅ On main branch - no validation needed\n');
11
- return;
12
- }
13
- process.stdout.write('Validating branch is up to date with origin/main...\n');
14
- process.stdout.write(`Current branch: ${branch}\n`);
15
- process.stdout.write('\n');
16
- process.stdout.write('Fetching latest from origin/main...\n');
17
- (0, child_process_1.spawnSync)('git', ['fetch', 'origin', 'main', '--quiet'], { stdio: 'inherit' });
18
- const isUpToDate = (0, child_process_1.spawnSync)('git', ['merge-base', '--is-ancestor', 'origin/main', 'HEAD']).status === 0;
19
- if (isUpToDate) {
20
- process.stdout.write('✅ Branch is up to date with origin/main\n');
21
- return;
22
- }
23
- const behindResult = (0, child_process_1.spawnSync)('git', ['rev-list', '--count', 'HEAD..origin/main'], { encoding: 'utf8' });
24
- const commitsBehind = (behindResult.stdout ?? '').trim();
25
- const recentResult = (0, child_process_1.spawnSync)('git', ['log', '--oneline', 'HEAD..origin/main'], { encoding: 'utf8' });
26
- const recentLines = (recentResult.stdout ?? '').split('\n').filter((l) => l).slice(0, 5).join('\n');
27
- process.stdout.write('\n');
28
- process.stdout.write(SEP);
29
- process.stdout.write('❌ ERROR: Branch is NOT up to date with origin/main\n');
30
- process.stdout.write(SEP);
31
- process.stdout.write('\n');
32
- process.stdout.write(`Your branch is ${commitsBehind} commit(s) behind origin/main\n`);
33
- process.stdout.write('\n');
34
- process.stdout.write('Recent commits in origin/main not in your branch:\n');
35
- process.stdout.write(recentLines + '\n');
36
- process.stdout.write('\n');
37
- process.stdout.write(SEP);
38
- process.stdout.write('⚠️ CRITICAL: You must update your branch first!\n');
39
- process.stdout.write(SEP);
40
- process.stdout.write('\n');
41
- process.stdout.write('1. Update your branch with latest main:\n');
42
- process.stdout.write(new rules_config_1.SyncFlowGuidance().flows().map((l) => ' ' + l).join('\n') + '\n');
43
- process.stdout.write('\n');
44
- process.stdout.write('2. ⚠️ IMPORTANT: REVIEW THE CODE AFTER MERGE!\n');
45
- process.stdout.write(' - Check for merge conflicts\n');
46
- process.stdout.write(' - Review how your changes interact with new main code\n');
47
- process.stdout.write(' - Test that everything still works\n');
48
- process.stdout.write(' - This is where things often go wrong!\n');
49
- process.stdout.write('\n');
50
- process.stdout.write('3. After reviewing, run your command again\n');
51
- process.stdout.write('\n');
52
- process.stdout.write(SEP);
53
- process.stdout.write('Why this matters:\n');
54
- process.stdout.write(SEP);
55
- process.stdout.write('\n');
56
- process.stdout.write('- Your test plan should cover how your changes work with\n');
57
- process.stdout.write(' the LATEST code from main, not outdated code\n');
58
- process.stdout.write('- Merging main might introduce conflicts or integration\n');
59
- process.stdout.write(' issues that need testing\n');
60
- process.stdout.write('- Your changes might interact unexpectedly with new code\n');
61
- process.stdout.write(' from main\n');
62
- process.stdout.write('\n');
63
- process.stdout.write(SEP);
64
- // The full guidance was already printed to stdout above; throw with an empty message so runMain
65
- // exits 1 without echoing a redundant line.
66
- throw new rules_config_1.CliExitError(1, '');
67
- }
68
- if (require.main === module)
69
- (0, rules_config_1.runMain)(main);
70
- //# sourceMappingURL=git-validateUpToDate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"git-validateUpToDate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/git-validateUpToDate.ts"],"names":[],"mappings":";;AAKA,oBAqEC;AA1ED,iDAAoD;AACpD,0DAAkF;AAElF,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEhE,KAAK,UAAU,IAAI;IACtB,MAAM,MAAM,GAAG,IAAA,wBAAQ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CAAC,8BAA8B,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACnF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE1B,gGAAgG;IAChG,4CAA4C;IAC5C,MAAM,IAAI,2BAAY,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,sBAAO,EAAC,IAAI,CAAC,CAAC","sourcesContent":["import { execSync, spawnSync } from 'child_process';\nimport { CliExitError, runMain, SyncFlowGuidance } from '@webpieces/rules-config';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\nexport async function main(): Promise<void> {\n const branch = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\n\n if (branch === 'main') {\n process.stdout.write('✅ On main branch - no validation needed\\n');\n return;\n }\n\n process.stdout.write('Validating branch is up to date with origin/main...\\n');\n process.stdout.write(`Current branch: ${branch}\\n`);\n process.stdout.write('\\n');\n\n process.stdout.write('Fetching latest from origin/main...\\n');\n spawnSync('git', ['fetch', 'origin', 'main', '--quiet'], { stdio: 'inherit' });\n\n const isUpToDate = spawnSync('git', ['merge-base', '--is-ancestor', 'origin/main', 'HEAD']).status === 0;\n\n if (isUpToDate) {\n process.stdout.write('✅ Branch is up to date with origin/main\\n');\n return;\n }\n\n const behindResult = spawnSync('git', ['rev-list', '--count', 'HEAD..origin/main'], { encoding: 'utf8' });\n const commitsBehind = (behindResult.stdout ?? '').trim();\n\n const recentResult = spawnSync('git', ['log', '--oneline', 'HEAD..origin/main'], { encoding: 'utf8' });\n const recentLines = (recentResult.stdout ?? '').split('\\n').filter((l: string) => l).slice(0, 5).join('\\n');\n\n process.stdout.write('\\n');\n process.stdout.write(SEP);\n process.stdout.write('❌ ERROR: Branch is NOT up to date with origin/main\\n');\n process.stdout.write(SEP);\n process.stdout.write('\\n');\n process.stdout.write(`Your branch is ${commitsBehind} commit(s) behind origin/main\\n`);\n process.stdout.write('\\n');\n process.stdout.write('Recent commits in origin/main not in your branch:\\n');\n process.stdout.write(recentLines + '\\n');\n process.stdout.write('\\n');\n process.stdout.write(SEP);\n process.stdout.write('⚠️ CRITICAL: You must update your branch first!\\n');\n process.stdout.write(SEP);\n process.stdout.write('\\n');\n process.stdout.write('1. Update your branch with latest main:\\n');\n process.stdout.write(new SyncFlowGuidance().flows().map((l: string): string => ' ' + l).join('\\n') + '\\n');\n process.stdout.write('\\n');\n process.stdout.write('2. ⚠️ IMPORTANT: REVIEW THE CODE AFTER MERGE!\\n');\n process.stdout.write(' - Check for merge conflicts\\n');\n process.stdout.write(' - Review how your changes interact with new main code\\n');\n process.stdout.write(' - Test that everything still works\\n');\n process.stdout.write(' - This is where things often go wrong!\\n');\n process.stdout.write('\\n');\n process.stdout.write('3. After reviewing, run your command again\\n');\n process.stdout.write('\\n');\n process.stdout.write(SEP);\n process.stdout.write('Why this matters:\\n');\n process.stdout.write(SEP);\n process.stdout.write('\\n');\n process.stdout.write('- Your test plan should cover how your changes work with\\n');\n process.stdout.write(' the LATEST code from main, not outdated code\\n');\n process.stdout.write('- Merging main might introduce conflicts or integration\\n');\n process.stdout.write(' issues that need testing\\n');\n process.stdout.write('- Your changes might interact unexpectedly with new code\\n');\n process.stdout.write(' from main\\n');\n process.stdout.write('\\n');\n process.stdout.write(SEP);\n\n // The full guidance was already printed to stdout above; throw with an empty message so runMain\n // exits 1 without echoing a redundant line.\n throw new CliExitError(1, '');\n}\n\nif (require.main === module) runMain(main);\n"]}