@webpieces/rules-config 0.4.916 → 0.4.917

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 (78) hide show
  1. package/package.json +5 -5
  2. package/src/aged-tree-sweep.d.ts +2 -2
  3. package/src/aged-tree-sweep.js +2 -2
  4. package/src/aged-tree-sweep.js.map +1 -1
  5. package/src/build-log-doc.d.ts +1 -1
  6. package/src/build-log-doc.js +3 -3
  7. package/src/build-log-doc.js.map +1 -1
  8. package/src/builds-log.d.ts +2 -2
  9. package/src/builds-log.js +2 -2
  10. package/src/builds-log.js.map +1 -1
  11. package/src/checklist-override.d.ts +1 -1
  12. package/src/checklist-override.js +1 -1
  13. package/src/checklist-override.js.map +1 -1
  14. package/src/config-error-banner.js +1 -1
  15. package/src/config-error-banner.js.map +1 -1
  16. package/src/constants.js +3 -3
  17. package/src/constants.js.map +1 -1
  18. package/src/exclude-hook-paths.d.ts +5 -5
  19. package/src/exclude-hook-paths.js +5 -5
  20. package/src/exclude-hook-paths.js.map +1 -1
  21. package/src/exclude-paths.d.ts +1 -1
  22. package/src/exclude-paths.js +1 -1
  23. package/src/exclude-paths.js.map +1 -1
  24. package/src/hook-fault-codes.js.map +1 -1
  25. package/src/index.js +5 -5
  26. package/src/index.js.map +1 -1
  27. package/src/instruct-ai-docs.d.ts +3 -3
  28. package/src/instruct-ai-docs.js +3 -3
  29. package/src/instruct-ai-docs.js.map +1 -1
  30. package/src/legacy-config-upgrade.js +2 -2
  31. package/src/legacy-config-upgrade.js.map +1 -1
  32. package/src/load-template.d.ts +1 -1
  33. package/src/load-template.js +2 -2
  34. package/src/load-template.js.map +1 -1
  35. package/src/merge-process-doc.d.ts +1 -1
  36. package/src/merge-process-doc.js +2 -2
  37. package/src/merge-process-doc.js.map +1 -1
  38. package/src/migrate-dirs-cli.js +1 -1
  39. package/src/migrate-dirs-cli.js.map +1 -1
  40. package/src/orphan-dir-archive.d.ts +4 -4
  41. package/src/orphan-dir-archive.js +4 -4
  42. package/src/orphan-dir-archive.js.map +1 -1
  43. package/src/orphan-dir-scan.d.ts +1 -1
  44. package/src/orphan-dir-scan.js +1 -1
  45. package/src/orphan-dir-scan.js.map +1 -1
  46. package/src/orphan-dir-sweep.js +1 -1
  47. package/src/orphan-dir-sweep.js.map +1 -1
  48. package/src/policy-tracking.js +5 -8
  49. package/src/policy-tracking.js.map +1 -1
  50. package/src/pr-gate-config.d.ts +1 -1
  51. package/src/pr-gate-config.js +1 -1
  52. package/src/pr-gate-config.js.map +1 -1
  53. package/src/repo-root.d.ts +7 -7
  54. package/src/repo-root.js +8 -8
  55. package/src/repo-root.js.map +1 -1
  56. package/src/repo-scratch-dirs.d.ts +3 -3
  57. package/src/repo-scratch-dirs.js +5 -5
  58. package/src/repo-scratch-dirs.js.map +1 -1
  59. package/src/review-json-data.js +2 -2
  60. package/src/review-json-data.js.map +1 -1
  61. package/src/review-json.js +1 -1
  62. package/src/review-json.js.map +1 -1
  63. package/src/reviewer-instructions.d.ts +1 -1
  64. package/src/reviewer-instructions.js +1 -1
  65. package/src/reviewer-instructions.js.map +1 -1
  66. package/src/stale-bin-sweep.js +1 -1
  67. package/src/stale-bin-sweep.js.map +1 -1
  68. package/src/subagent-provenance.d.ts +6 -6
  69. package/src/subagent-provenance.js +6 -6
  70. package/src/subagent-provenance.js.map +1 -1
  71. package/src/sync-flow-guidance.js +1 -1
  72. package/src/sync-flow-guidance.js.map +1 -1
  73. package/templates/webpieces.branch-state-matrix.md +2 -2
  74. package/templates/webpieces.buildlog.md +3 -3
  75. package/templates/webpieces.ci-gate-setup.md +2 -2
  76. package/templates/webpieces.git-workflow.md +8 -9
  77. package/templates/webpieces.location-matrix.md +10 -10
  78. package/templates/webpieces.review-checklists.md +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"orphan-dir-sweep.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/orphan-dir-sweep.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AA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ACxC,KAAK,CAAC,IAAI,CAAC,iBAAiB,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC;QACxD,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClC,KAAK,CAAC,IAAI,CAAC,eAAe,OAAO,CAAC,YAAY,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,MAAM,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAChC,KAAK,CAAC,IAAI,CAAC,kDAAkD,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;YACrF,KAAK,CAAC,IAAI,CAAC,uFAAuF,CAAC,CAAC;QACxG,CAAC;QACD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YACxB,KAAK,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,6CAA6C,CAAC,CAAC;QAC3F,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACnC,CAAC;IAEO,OAAO;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,OAAO,sFAAsF,KAAK,EAAE,CAAC;IACzG,CAAC;IAED,uGAAuG;IACvG,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACzD,CAAC;IAED,qEAAqE;IACrE,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC1D,CAAC;CACJ;AA/ED,8CA+EC","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\n\nimport { OrphanCandidate, OrphanDirScanner } from './orphan-dir-scan';\nimport { ArchivedOrphan, FailedOrphan, OrphanDirArchiver, OrphanSweepResult } from './orphan-dir-archive';\nimport { HOME_EXPERIMENTAL_SECTION, HOME_KEY_ORPHAN_DIR_SWEEP, HomeConfigService } from './home-config';\n\n/**\n * The orphan-directory sweep, end to end: find the corpses an `nx g move` left behind, and — only on a\n * machine that has explicitly opted in — archive them where they can be recovered.\n *\n * ─── WHY THE DEFAULT IS REPORT-ONLY ───────────────────────────────────────────────────────────────────\n * `experimental.orphan-dir-sweep` in `~/.webpieces/config.json` defaults to false, like every other key\n * in that optional, machine-local file. That gives the author of this feature exactly one thing nothing\n * else can: they can run it live across all of their own clones for a release, while every colleague\n * pulling the same version gets a report and an untouched working tree.\n *\n * The default direction is the whole safety argument, and it only points one way: absent means REPORT.\n * Nobody can discover this feature by finding their directories somewhere else — the machine has to say\n * `true` out loud first, and the key is greppable precisely because the permissive state is a token\n * rather than an absence.\n *\n * ─── WHY IT NEVER THROWS ──────────────────────────────────────────────────────────────────────────────\n * Every caller is a command whose real work is a checkout and a pull. Tidying is worth doing on the back\n * of that, and worth nothing at all if it can fail the thing it rode in on, so every failure below\n * resolves to a line of prose in the report. The one exception is deliberate: a MALFORMED\n * `~/.webpieces/config.json` propagates, because that file is the user's own instruction to this code and\n * silently ignoring a broken one is how a machine ends up in a state its owner did not choose.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class OrphanDirSweeper {\n constructor(\n private readonly scanner: OrphanDirScanner,\n private readonly archiver: OrphanDirArchiver,\n private readonly homeConfigService: HomeConfigService,\n ) {}\n\n /**\n * Scan `repoRoot`, and archive what was found when this machine has opted in. `now` is a parameter\n * so specs pin the sweep id rather than racing the clock.\n */\n sweep(repoRoot: string, now: Date): OrphanSweepReport {\n const candidates = this.scanner.scan(repoRoot);\n const enabled = this.homeConfigService.load().orphanDirSweep;\n if (candidates.length === 0) return new OrphanSweepReport(enabled, candidates, null, 0);\n if (!enabled) return new OrphanSweepReport(false, candidates, null, 0);\n const result = this.archiver.archive(repoRoot, candidates, now);\n return new OrphanSweepReport(true, candidates, result, this.archiver.reapAged(repoRoot, now));\n }\n}\n\n/**\n * What one sweep found and did, and how to say it out loud. Data-only apart from `render()`, which is\n * the report's own presentation of itself rather than business logic living somewhere else.\n */\nexport class OrphanSweepReport {\n /** Was archiving switched on for this machine? False means nothing on disk was touched. */\n enabled: boolean;\n /** Every orphan directory found, whether or not it was archived. */\n found: readonly OrphanCandidate[];\n /** The archive, or null when this was a report-only run or there was nothing to archive. */\n result: OrphanSweepResult | null;\n /** How many aged sweep directories were reaped from the trash on this run. */\n reapedSweeps: number;\n\n constructor(enabled: boolean, found: readonly OrphanCandidate[], result: OrphanSweepResult | null,\n reapedSweeps: number) {\n this.enabled = enabled;\n this.found = found;\n this.result = result;\n this.reapedSweeps = reapedSweeps;\n }\n\n /**\n * The human-facing block, or empty string when there is nothing to say. A clean tree prints NOTHING —\n * this rides along on somebody else's command, and a tidier that announces having found no work is a\n * tidier people start ignoring, and then stop reading the run where it did find some.\n */\n render(): string {\n if (this.found.length === 0) return '';\n if (!this.enabled) return this.renderReportOnly();\n return this.renderArchived();\n }\n\n /**\n * The opted-out form: name what was found, name the one edit that turns archiving on, and touch\n * nothing. It names the KEY rather than describing it, because the reader is usually an agent and the\n * mechanical edit is the only part of this it can act on.\n */\n private renderReportOnly(): string {\n return `${this.heading()}\\n`\n + ` Nothing was moved — archiving is off on this machine.\\n`\n + ` To archive them (never delete: they move to .webpieces-logs/trash/<sweepId>/ with a recover=\\n`\n + ` command printed for each), add this key in ~/.webpieces/config.json — every key in that\\n`\n + ` file is optional, so this one line beside whatever is already there is the whole edit:\\n\\n`\n + ` { \"${HOME_EXPERIMENTAL_SECTION}\": { \"${HOME_KEY_ORPHAN_DIR_SWEEP}\": true } }\\n`;\n }\n\n private renderArchived(): string {\n const lines: string[] = [this.heading()];\n const result = this.result;\n if (result === null) return `${lines.join('\\n')}\\n`;\n lines.push(` archived to ${result.sweepDir}`);\n for (const moved of result.moved) {\n lines.push(` ${moved.relativePath}`);\n lines.push(` recover=${moved.recoverCommand}`);\n }\n for (const failure of result.failed) {\n lines.push(` SKIPPED ${failure.relativePath} — ${failure.reason}`);\n }\n if (result.manifestError !== null) {\n lines.push(` WARNING: the manifest could not be written — ${result.manifestError}`);\n lines.push(' The recover= lines above are the only copy. Save them before closing this terminal.');\n }\n if (this.reapedSweeps > 0) {\n lines.push(` reaped ${this.reapedSweeps} sweep(s) older than 30 days from the trash`);\n }\n return `${lines.join('\\n')}\\n`;\n }\n\n private heading(): string {\n const count = this.found.length;\n return `orphan directories (left by a project move; every file under them is git-ignored): ${count}`;\n }\n\n /** Everything archived on this run — empty on a report-only run. Convenience for callers and specs. */\n archived(): readonly ArchivedOrphan[] {\n return this.result === null ? [] : this.result.moved;\n }\n\n /** Everything found but not movable — empty on a report-only run. */\n skipped(): readonly FailedOrphan[] {\n return this.result === null ? [] : this.result.failed;\n }\n}\n"]}
1
+ {"version":3,"file":"orphan-dir-sweep.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/orphan-dir-sweep.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAE3D,uDAAsE;AACtE,6DAA0G;AAC1G,+CAAwG;AAExG;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEJ;IACA;IACA;IAHrB,YACqB,OAAyB,EACzB,QAA2B,EAC3B,iBAAoC;QAFpC,YAAO,GAAP,OAAO,CAAkB;QACzB,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,sBAAiB,GAAjB,iBAAiB,CAAmB;IACtD,CAAC;IAEJ;;;OAGG;IACH,KAAK,CAAC,QAAgB,EAAE,GAAS;QAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC;QAC7D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;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AC,CAAC;QAC3F,CAAC;QACD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACnC,CAAC;IAEO,OAAO;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAChC,OAAO,sFAAsF,KAAK,EAAE,CAAC;IACzG,CAAC;IAED,uGAAuG;IACvG,QAAQ;QACJ,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IACzD,CAAC;IAED,qEAAqE;IACrE,OAAO;QACH,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC1D,CAAC;CACJ;AA/ED,8CA+EC","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\n\nimport { OrphanCandidate, OrphanDirScanner } from './orphan-dir-scan';\nimport { ArchivedOrphan, FailedOrphan, OrphanDirArchiver, OrphanSweepResult } from './orphan-dir-archive';\nimport { HOME_EXPERIMENTAL_SECTION, HOME_KEY_ORPHAN_DIR_SWEEP, HomeConfigService } from './home-config';\n\n/**\n * The orphan-directory sweep, end to end: find the corpses an `nx g move` left behind, and — only on a\n * machine that has explicitly opted in — archive them where they can be recovered.\n *\n * ─── WHY THE DEFAULT IS REPORT-ONLY ───────────────────────────────────────────────────────────────────\n * `experimental.orphan-dir-sweep` in `~/.webpieces/config.json` defaults to false, like every other key\n * in that optional, machine-local file. That gives the author of this feature exactly one thing nothing\n * else can: they can run it live across all of their own clones for a release, while every colleague\n * pulling the same version gets a report and an untouched working tree.\n *\n * The default direction is the whole safety argument, and it only points one way: absent means REPORT.\n * Nobody can discover this feature by finding their directories somewhere else — the machine has to say\n * `true` out loud first, and the key is greppable precisely because the permissive state is a token\n * rather than an absence.\n *\n * ─── WHY IT NEVER THROWS ──────────────────────────────────────────────────────────────────────────────\n * Every caller is a command whose real work is a checkout and a pull. Tidying is worth doing on the back\n * of that, and worth nothing at all if it can fail the thing it rode in on, so every failure below\n * resolves to a line of prose in the report. The one exception is deliberate: a MALFORMED\n * `~/.webpieces/config.json` propagates, because that file is the user's own instruction to this code and\n * silently ignoring a broken one is how a machine ends up in a state its owner did not choose.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class OrphanDirSweeper {\n constructor(\n private readonly scanner: OrphanDirScanner,\n private readonly archiver: OrphanDirArchiver,\n private readonly homeConfigService: HomeConfigService,\n ) {}\n\n /**\n * Scan `repoRoot`, and archive what was found when this machine has opted in. `now` is a parameter\n * so specs pin the sweep id rather than racing the clock.\n */\n sweep(repoRoot: string, now: Date): OrphanSweepReport {\n const candidates = this.scanner.scan(repoRoot);\n const enabled = this.homeConfigService.load().orphanDirSweep;\n if (candidates.length === 0) return new OrphanSweepReport(enabled, candidates, null, 0);\n if (!enabled) return new OrphanSweepReport(false, candidates, null, 0);\n const result = this.archiver.archive(repoRoot, candidates, now);\n return new OrphanSweepReport(true, candidates, result, this.archiver.reapAged(repoRoot, now));\n }\n}\n\n/**\n * What one sweep found and did, and how to say it out loud. Data-only apart from `render()`, which is\n * the report's own presentation of itself rather than business logic living somewhere else.\n */\nexport class OrphanSweepReport {\n /** Was archiving switched on for this machine? False means nothing on disk was touched. */\n enabled: boolean;\n /** Every orphan directory found, whether or not it was archived. */\n found: readonly OrphanCandidate[];\n /** The archive, or null when this was a report-only run or there was nothing to archive. */\n result: OrphanSweepResult | null;\n /** How many aged sweep directories were reaped from the trash on this run. */\n reapedSweeps: number;\n\n constructor(enabled: boolean, found: readonly OrphanCandidate[], result: OrphanSweepResult | null,\n reapedSweeps: number) {\n this.enabled = enabled;\n this.found = found;\n this.result = result;\n this.reapedSweeps = reapedSweeps;\n }\n\n /**\n * The human-facing block, or empty string when there is nothing to say. A clean tree prints NOTHING —\n * this rides along on somebody else's command, and a tidier that announces having found no work is a\n * tidier people start ignoring, and then stop reading the run where it did find some.\n */\n render(): string {\n if (this.found.length === 0) return '';\n if (!this.enabled) return this.renderReportOnly();\n return this.renderArchived();\n }\n\n /**\n * The opted-out form: name what was found, name the one edit that turns archiving on, and touch\n * nothing. It names the KEY rather than describing it, because the reader is usually an agent and the\n * mechanical edit is the only part of this it can act on.\n */\n private renderReportOnly(): string {\n return `${this.heading()}\\n`\n + ` Nothing was moved — archiving is off on this machine.\\n`\n + ` To archive them (never delete: they move to .webpieces/trash/<sweepId>/ with a recover=\\n`\n + ` command printed for each), add this key in ~/.webpieces/config.json — every key in that\\n`\n + ` file is optional, so this one line beside whatever is already there is the whole edit:\\n\\n`\n + ` { \"${HOME_EXPERIMENTAL_SECTION}\": { \"${HOME_KEY_ORPHAN_DIR_SWEEP}\": true } }\\n`;\n }\n\n private renderArchived(): string {\n const lines: string[] = [this.heading()];\n const result = this.result;\n if (result === null) return `${lines.join('\\n')}\\n`;\n lines.push(` archived to ${result.sweepDir}`);\n for (const moved of result.moved) {\n lines.push(` ${moved.relativePath}`);\n lines.push(` recover=${moved.recoverCommand}`);\n }\n for (const failure of result.failed) {\n lines.push(` SKIPPED ${failure.relativePath} — ${failure.reason}`);\n }\n if (result.manifestError !== null) {\n lines.push(` WARNING: the manifest could not be written — ${result.manifestError}`);\n lines.push(' The recover= lines above are the only copy. Save them before closing this terminal.');\n }\n if (this.reapedSweeps > 0) {\n lines.push(` reaped ${this.reapedSweeps} sweep(s) older than 30 days from the trash`);\n }\n return `${lines.join('\\n')}\\n`;\n }\n\n private heading(): string {\n const count = this.found.length;\n return `orphan directories (left by a project move; every file under them is git-ignored): ${count}`;\n }\n\n /** Everything archived on this run — empty on a report-only run. Convenience for callers and specs. */\n archived(): readonly ArchivedOrphan[] {\n return this.result === null ? [] : this.result.moved;\n }\n\n /** Everything found but not movable — empty on a report-only run. */\n skipped(): readonly FailedOrphan[] {\n return this.result === null ? [] : this.result.failed;\n }\n}\n"]}
@@ -21,7 +21,7 @@ class PolicyTracking {
21
21
  if (ignored.status !== 0 && ignored.status !== 1)
22
22
  throw new tooling_common_1.InformAiError(`Cannot verify policy ignore status: ${ignored.stderr}. Repair git access, then retry.`);
23
23
  if (ignored.stdout.trim())
24
- throw new tooling_common_1.InformAiError(`Committed Webpieces policy is gitignored:\n${ignored.stdout}Remove the matching ignore patterns. Only .webpieces-logs/ belongs in .gitignore; .webpieces-config/ must be tracked.`);
24
+ throw new tooling_common_1.InformAiError(`Committed Webpieces policy is gitignored:\n${ignored.stdout}Remove the matching ignore patterns. Only .webpieces/ belongs in .gitignore; .webpieces-config/ must be tracked.`);
25
25
  const tracked = (0, node_child_process_1.spawnSync)('git', ['--literal-pathspecs', 'ls-files', '--error-unmatch', '--', ...files], {
26
26
  cwd: root,
27
27
  encoding: 'utf8',
@@ -30,13 +30,11 @@ class PolicyTracking {
30
30
  throw new tooling_common_1.InformAiError(`Webpieces policy must be tracked by git: ${tracked.stderr}\nReview the policy files, then run pnpm wp-migrate-dirs --stage to stage the declaration, owner files, lock and catalog. Commit them with your change.`);
31
31
  }
32
32
  stage(root, declarations) {
33
- const retired = (0, node_child_process_1.spawnSync)('git', ['ls-files', '-z', '--', '.webpieces'], {
34
- cwd: root,
35
- encoding: 'utf8',
36
- });
33
+ // `.webpieces/` is the gitignored state directory, so `git add` refuses its paths. Untrack whatever
34
+ // policy older releases committed there with `rm --cached`, which keeps every file on disk.
35
+ const retired = (0, node_child_process_1.spawnSync)('git', ['rm', '-r', '-q', '--cached', '--ignore-unmatch', '--', '.webpieces'], { cwd: root, encoding: 'utf8' });
37
36
  if (retired.status !== 0)
38
- throw new tooling_common_1.InformAiError(`Cannot inspect retired policy paths for staging: ${retired.stderr}. Verify git access before retrying.`);
39
- const deletions = retired.stdout.split('\0').filter((filename) => filename.length > 0);
37
+ throw new tooling_common_1.InformAiError(`Cannot untrack retired policy paths in .webpieces/: ${retired.stderr}. Verify git access before retrying.`);
40
38
  const result = (0, node_child_process_1.spawnSync)('git', [
41
39
  '--literal-pathspecs',
42
40
  'add',
@@ -45,7 +43,6 @@ class PolicyTracking {
45
43
  'webpieces.config.json',
46
44
  '.gitignore',
47
45
  ...this.files(root, declarations),
48
- ...deletions,
49
46
  ], { cwd: root, encoding: 'utf8' });
50
47
  if (result.status !== 0)
51
48
  throw new tooling_common_1.InformAiError(`Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`);
@@ -1 +1 @@
1
- {"version":3,"file":"policy-tracking.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/policy-tracking.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,2DAA+C;AAC/C,8DAA0D;AAE1D,+DAA0E;AAE1E,4FAA4F;AAC5F,MAAa,cAAc;IACvB,KAAK,CAAC,IAAY,EAAE,YAA8C;QAC9D,0FAA0F;QAC1F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC7C,MAAM,OAAO,GAAG,IAAA,8BAAS,EAAC,KAAK,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE;YAC7E,GAAG,EAAE,IAAI;YACT,QAAQ,EAAE,MAAM;SACnB,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAC5C,MAAM,IAAI,8BAAa,CACnB,uCAAuC,OAAO,CAAC,MAAM,kCAAkC,CAC1F,CAAC;QACN,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE;YACrB,MAAM,IAAI,8BAAa,CACnB,8CAA8C,OAAO,CAAC,MAAM,uHAAuH,CACtL,CAAC;QACN,MAAM,OAAO,GAAG,IAAA,8BAAS,E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AAY,EAAE,YAA8C;QACtE,MAAM,QAAQ,GAAG;YACb,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;YACxD,oCAAc;YACd,uCAAiB;SACpB,CAAC;QACF,OAAO;YACH,GAAG,IAAI,GAAG,CACN,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC3B,QAAQ;gBACR,IAAI,CAAC,QAAQ,CACT,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACrB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAC7C;aACJ,CAAC,CACL;SACJ,CAAC;IACN,CAAC;CACJ;AA/ED,wCA+EC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport type { PackPolicyDeclaration } from './pack-policy-files';\nimport { RULE_LOCK_FILE, RULE_CATALOG_FILE } from './rule-pack-artifacts';\n\n/** Git repositories must share policy through their index, including rules switched OFF. */\nexport class PolicyTracking {\n check(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // Standalone non-git schema validation is supported; CI and governed checkouts have .git.\n if (!fs.existsSync(path.join(root, '.git'))) return;\n const files = this.files(root, declarations);\n const ignored = spawnSync('git', ['check-ignore', '--no-index', '--', ...files], {\n cwd: root,\n encoding: 'utf8',\n });\n if (ignored.status !== 0 && ignored.status !== 1)\n throw new InformAiError(\n `Cannot verify policy ignore status: ${ignored.stderr}. Repair git access, then retry.`,\n );\n if (ignored.stdout.trim())\n throw new InformAiError(\n `Committed Webpieces policy is gitignored:\\n${ignored.stdout}Remove the matching ignore patterns. Only .webpieces-logs/ belongs in .gitignore; .webpieces-config/ must be tracked.`,\n );\n const tracked = spawnSync(\n 'git',\n ['--literal-pathspecs', 'ls-files', '--error-unmatch', '--', ...files],\n {\n cwd: root,\n encoding: 'utf8',\n },\n );\n if (tracked.status !== 0)\n throw new InformAiError(\n `Webpieces policy must be tracked by git: ${tracked.stderr}\\nReview the policy files, then run pnpm wp-migrate-dirs --stage to stage the declaration, owner files, lock and catalog. Commit them with your change.`,\n );\n }\n\n stage(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n const retired = spawnSync('git', ['ls-files', '-z', '--', '.webpieces'], {\n cwd: root,\n encoding: 'utf8',\n });\n if (retired.status !== 0)\n throw new InformAiError(\n `Cannot inspect retired policy paths for staging: ${retired.stderr}. Verify git access before retrying.`,\n );\n const deletions = retired.stdout.split('\\0').filter((filename) => filename.length > 0);\n const result = spawnSync(\n 'git',\n [\n '--literal-pathspecs',\n 'add',\n '-A',\n '--',\n 'webpieces.config.json',\n '.gitignore',\n ...this.files(root, declarations),\n ...deletions,\n ],\n { cwd: root, encoding: 'utf8' },\n );\n if (result.status !== 0)\n throw new InformAiError(\n `Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`,\n );\n }\n\n private files(root: string, declarations: readonly PackPolicyDeclaration[]): string[] {\n const declared = [\n ...declarations.map((declaration) => declaration.config),\n RULE_LOCK_FILE,\n RULE_CATALOG_FILE,\n ];\n return [\n ...new Set(\n declared.flatMap((filename) => [\n filename,\n path.relative(\n fs.realpathSync(root),\n fs.realpathSync(path.join(root, filename)),\n ),\n ]),\n ),\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"policy-tracking.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/policy-tracking.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,2DAA+C;AAC/C,8DAA0D;AAE1D,+DAA0E;AAE1E,4FAA4F;AAC5F,MAAa,cAAc;IACvB,KAAK,CAAC,IAAY,EAAE,YAA8C;QAC9D,0FAA0F;QAC1F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,M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K,CAAC;YACpB,MAAM,IAAI,8BAAa,CACnB,uDAAuD,OAAO,CAAC,MAAM,sCAAsC,CAC9G,CAAC;QACN,MAAM,MAAM,GAAG,IAAA,8BAAS,EACpB,KAAK,EACL;YACI,qBAAqB;YACrB,KAAK;YACL,IAAI;YACJ,IAAI;YACJ,uBAAuB;YACvB,YAAY;YACZ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC;SACpC,EACD,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAClC,CAAC;QACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YACnB,MAAM,IAAI,8BAAa,CACnB,qCAAqC,MAAM,CAAC,MAAM,wEAAwE,CAC7H,CAAC;IACV,CAAC;IAEO,KAAK,CAAC,IAAY,EAAE,YAA8C;QACtE,MAAM,QAAQ,GAAG;YACb,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;YACxD,oCAAc;YACd,uCAAiB;SACpB,CAAC;QACF,OAAO;YACH,GAAG,IAAI,GAAG,CACN,QAAQ,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC3B,QAAQ;gBACR,IAAI,CAAC,QAAQ,CACT,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACrB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAC7C;aACJ,CAAC,CACL;SACJ,CAAC;IACN,CAAC;CACJ;AAhFD,wCAgFC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { spawnSync } from 'node:child_process';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport type { PackPolicyDeclaration } from './pack-policy-files';\nimport { RULE_LOCK_FILE, RULE_CATALOG_FILE } from './rule-pack-artifacts';\n\n/** Git repositories must share policy through their index, including rules switched OFF. */\nexport class PolicyTracking {\n check(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // Standalone non-git schema validation is supported; CI and governed checkouts have .git.\n if (!fs.existsSync(path.join(root, '.git'))) return;\n const files = this.files(root, declarations);\n const ignored = spawnSync('git', ['check-ignore', '--no-index', '--', ...files], {\n cwd: root,\n encoding: 'utf8',\n });\n if (ignored.status !== 0 && ignored.status !== 1)\n throw new InformAiError(\n `Cannot verify policy ignore status: ${ignored.stderr}. Repair git access, then retry.`,\n );\n if (ignored.stdout.trim())\n throw new InformAiError(\n `Committed Webpieces policy is gitignored:\\n${ignored.stdout}Remove the matching ignore patterns. Only .webpieces/ belongs in .gitignore; .webpieces-config/ must be tracked.`,\n );\n const tracked = spawnSync(\n 'git',\n ['--literal-pathspecs', 'ls-files', '--error-unmatch', '--', ...files],\n {\n cwd: root,\n encoding: 'utf8',\n },\n );\n if (tracked.status !== 0)\n throw new InformAiError(\n `Webpieces policy must be tracked by git: ${tracked.stderr}\\nReview the policy files, then run pnpm wp-migrate-dirs --stage to stage the declaration, owner files, lock and catalog. Commit them with your change.`,\n );\n }\n\n stage(root: string, declarations: readonly PackPolicyDeclaration[]): void {\n // `.webpieces/` is the gitignored state directory, so `git add` refuses its paths. Untrack whatever\n // policy older releases committed there with `rm --cached`, which keeps every file on disk.\n const retired = spawnSync(\n 'git',\n ['rm', '-r', '-q', '--cached', '--ignore-unmatch', '--', '.webpieces'],\n { cwd: root, encoding: 'utf8' },\n );\n if (retired.status !== 0)\n throw new InformAiError(\n `Cannot untrack retired policy paths in .webpieces/: ${retired.stderr}. Verify git access before retrying.`,\n );\n const result = spawnSync(\n 'git',\n [\n '--literal-pathspecs',\n 'add',\n '-A',\n '--',\n 'webpieces.config.json',\n '.gitignore',\n ...this.files(root, declarations),\n ],\n { cwd: root, encoding: 'utf8' },\n );\n if (result.status !== 0)\n throw new InformAiError(\n `Could not stage Webpieces policy: ${result.stderr}. Remove policy ignore patterns and verify git access before retrying.`,\n );\n }\n\n private files(root: string, declarations: readonly PackPolicyDeclaration[]): string[] {\n const declared = [\n ...declarations.map((declaration) => declaration.config),\n RULE_LOCK_FILE,\n RULE_CATALOG_FILE,\n ];\n return [\n ...new Set(\n declared.flatMap((filename) => [\n filename,\n path.relative(\n fs.realpathSync(root),\n fs.realpathSync(path.join(root, filename)),\n ),\n ]),\n ),\n ];\n }\n}\n"]}
@@ -138,7 +138,7 @@ export declare class PrGateConfig {
138
138
  */
139
139
  landPr: LandPrConfig;
140
140
  /**
141
- * Globs whose diffs are NOT extracted into `.webpieces-logs/pr-review/<feature>/diff/` — regenerated noise a
141
+ * Globs whose diffs are NOT extracted into `.webpieces/pr-review/<feature>/diff/` — regenerated noise a
142
142
  * reviewer should not spend context reading (lockfiles, generated graphs). Default [].
143
143
  *
144
144
  * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the
@@ -205,7 +205,7 @@ class PrGateConfig {
205
205
  */
206
206
  landPr = defaultLandPrConfig();
207
207
  /**
208
- * Globs whose diffs are NOT extracted into `.webpieces-logs/pr-review/<feature>/diff/` — regenerated noise a
208
+ * Globs whose diffs are NOT extracted into `.webpieces/pr-review/<feature>/diff/` — regenerated noise a
209
209
  * reviewer should not spend context reading (lockfiles, generated graphs). Default [].
210
210
  *
211
211
  * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the
@@ -1 +1 @@
1
- {"version":3,"file":"pr-gate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pr-gate-config.ts"],"names":[],"mappings":";;;AA2FA,kDAEC;AAgDD,wDAEC;AAwID,oCAmBC;AAED,kDAGC;AA4DD,8CAgEC;AAQD,oDAYC;AAQD,8CAMC;AA7cD,sEAAgG;AAChG,yDAO4B;AAE5B,2FAA2F;AAC3F,2FAA2F;AAC3F,iFAAiF;AACjF,iGAAiG;AAEjG;;;;;;;;;;;GAWG;AACU,QAAA,qBAAqB,GAC9B,wEAAwE,CAAC;AAE7E,MAAa,cAAc;IACvB,IAAI,CAAS;IACb,QAAQ,CAAW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,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,gHAAgH;AAChH,SAAgB,iBAAiB,CAAC,GAA0B;IACxD,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IACvC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClF,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC;IACtC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,sCAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC7F,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { BRANCH_RETENTION_ARCHIVE_TAG, BRANCH_RETENTIONS } from '@webpieces/repo-workflow-core';\nimport {\n ChecklistDefinition,\n DEFAULT_REVIEWER_AGENT_NAME,\n RawChecklistItem,\n REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy,\n toChecklist,\n} from './checklist-config';\n\n// PrGateConfig is the \"special section\" for the pr-gate dashboard. It does NOT live in the\n// validated `rules` map (the FieldDef schema can't express nested object arrays), but as a\n// top-level `pr-gate` key in webpieces.config.json. It is built and validated by\n// loadAndValidate (load-config.ts); this module holds only the data classes + defaults + toGate.\n\n/**\n * The build the pr-gate runs when a repo configures no `commands.pr-gate.buildCommand` — and the ONE\n * definition of it, because two things now need it: the gate that RUNS it (pr-gate's BuildAffected)\n * and the guard that REFUSES a whole-monorepo build and prints it instead (ai-hook-rules'\n * whole-repo-build-guard). A second copy in either package is a message that can teach a command the\n * gate does not run.\n *\n * `--base=$(git merge-base origin/main HEAD)` — the FORK POINT, not `origin/main`: basing on\n * origin/main marks projects touched by other people's already-merged PRs as affected. The `$(…)`\n * resolves because the gate spawns with `shell: true`; the guard resolves it itself before printing,\n * so the AI is never handed a template it might paste somewhere without a shell.\n */\nexport const DEFAULT_BUILD_COMMAND =\n 'pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)';\n\nexport class GateDefinition {\n name: string;\n patterns: string[];\n // The warning color shown on the dashboard WHEN this gate's patterns match a changed file. Green\n // is implicit (shown when nothing matched), so it is never configured. warningColor is purely\n // visual — even 'red' never fails/blocks the PR (only the build gate can). 'yellow' = caution,\n // 'red' = louder \"look here\" flag (e.g. DB schema / migration changes). REQUIRED on every gate.\n warningColor: string; // 'yellow' | 'red'\n // Example/inactive gate: parsed and kept in the file (JSON has no comments) but skipped at\n // compute/render time. Other projects flip this to false and tune patterns/warningColor.\n disabled: boolean;\n\n constructor(name: string, patterns: string[], warningColor: string, disabled = false) {\n this.name = name;\n this.patterns = patterns;\n this.warningColor = warningColor;\n this.disabled = disabled;\n }\n}\n\n// How wp-finish-upsert-pr should try to LAND the PR once it has posted it. GitHub's auto-merge queue\n// is a REPO-level setting (`allow_auto_merge`) that many orgs turn OFF as a policy control, and it\n// CANNOT be forced from the client: `gh pr merge --auto` calls the enablePullRequestAutoMerge GraphQL\n// mutation, which hard-errors with \"Auto merge is not allowed for this repository\" when the repo says\n// no. So the only lever a config knob has is WHICH PATHS WE ATTEMPT — never whether the queue exists.\nexport const MERGE_MODE_AUTO = 'AUTO';\nexport const MERGE_MODE_NONE = 'NONE';\nexport const MERGE_MODES = [MERGE_MODE_AUTO, MERGE_MODE_NONE];\n\n/**\n * `pr-gate.landPr` — what happens to the LOCAL branch once its PR has landed.\n *\n * A rich object rather than a bare string (the `commands.pr-gate` precedent) so the next knob about\n * landing has a home, and so the rationale can sit beside the setting as a `*Why` sibling: JSON has no\n * comments, and `<key>Why` is how this repo documents non-obvious config.\n */\n/**\n * One `pr-gate.reviewContext` entry: a human label and a repo-relative path a reviewer is handed instead of\n * having to find it. Data-only (per CLAUDE.md).\n */\nexport class ReviewContextEntry {\n label: string;\n path: string; // repo-relative in config; resolved to absolute when written into an instructions file\n\n constructor(label: string, entryPath: string) {\n this.label = label;\n this.path = entryPath;\n }\n}\n\nexport class LandPrConfig {\n // One of BRANCH_RETENTIONS. Defaults to 'archive-tag' — see BranchArchiver for why a tag beats\n // keeping the branch, storing a patch, or trusting the reflog.\n branchRetention: string;\n\n constructor(branchRetention: string = BRANCH_RETENTION_ARCHIVE_TAG) {\n this.branchRetention = branchRetention;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultLandPrConfig(): LandPrConfig {\n return new LandPrConfig(BRANCH_RETENTION_ARCHIVE_TAG);\n}\n\n// The two literal ref names the dev-deploy flow derives everything else from. Defaults, not policy —\n// `pr-gate.devDeploy` overrides both, because a consumer whose shared environment is called `staging`\n// must not be forced onto webpieces' vocabulary.\nexport const DEFAULT_DEV_BRANCH_NAMESPACE = 'dev-include';\nexport const DEFAULT_DEV_BRANCH = 'dev';\n\n/**\n * `pr-gate.devDeploy` — where `wp-push-dev` publishes the throwaway copy of a feature branch, and which\n * ref is the shared dev branch itself.\n *\n * WHY A NAMESPACE AT ALL, i.e. why the copy is not just the feature branch: the feature branch is the PR\n * head, and landing that PR ships whatever is on it. The moment a conflict between two devs has to be\n * resolved SOMEWHERE for the shared environment to build, that resolution needs a home that is not the PR\n * branch — otherwise \"test it in dev\" silently ships another dev's unreviewed work to production. The\n * `<branchNamespace>/<feature>` copy is that home, and it is disposable by construction.\n *\n * `devBranch` is REFUSED as a source branch (you never push the composed branch back into itself); it is\n * written by the consumer's CI only, which recomputes it from `origin/main` on every run.\n */\nexport class DevDeployConfig {\n // Literal prefix on the feature branch name: `dev-include/dean/ONE-2275`. Git refs allow slashes, and\n // nobody ever types this — the command derives it.\n branchNamespace: string;\n // The composed, CI-owned branch that actually deploys. Never a source, never pushed to by this flow.\n devBranch: string;\n\n constructor(\n branchNamespace: string = DEFAULT_DEV_BRANCH_NAMESPACE,\n devBranch: string = DEFAULT_DEV_BRANCH,\n ) {\n this.branchNamespace = branchNamespace;\n this.devBranch = devBranch;\n }\n\n /** `<branchNamespace>/<branch>` — the remote ref holding the disposable copy of `branch`. */\n copyRefFor(branch: string): string {\n return `${this.branchNamespace}/${branch}`;\n }\n\n /** The `git ls-remote --heads origin <pattern>` pattern matching every live copy. */\n copyRefGlob(): string {\n return `${this.branchNamespace}/*`;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultDevDeployConfig(): DevDeployConfig {\n return new DevDeployConfig(DEFAULT_DEV_BRANCH_NAMESPACE, DEFAULT_DEV_BRANCH);\n}\n\nexport class PrGateConfig {\n mode: string;\n /**\n * The nx-affected build gate command, shared by the two commands that can run it.\n *\n * It is NOT finish-only any more, and the change is the point. It used to run once, in\n * wp-finish-upsert-pr, which meant reviewers were spawned against a branch nobody had built — they could\n * spend a full review on code that does not compile, or on an unresolved 3-point merge.\n *\n * Now `wp-review-upsert-pr` finalizes the merge and runs this gate BEFORE briefing any reviewer, and\n * records the passing HEAD sha in the stage receipt. `wp-finish-upsert-pr` re-runs it only when HEAD has\n * moved since — so the flow gained a gate where it mattered without paying for two full builds.\n *\n * Empty string => BuildAffected falls back to DEFAULT_BUILD_COMMAND.\n */\n buildCommand: string;\n gates: GateDefinition[];\n /**\n * REQUIRED — every repo must state its policy; there is deliberately no default, because the two\n * answers are a real policy decision and guessing it either merges when a team did not want that,\n * or silently stops landing PRs on a team that relied on it.\n *\n * AUTO — wp-finish-upsert-pr LANDS the PR: squash-merge it right away when it is mergeable, else\n * enable GitHub auto-merge so it lands when the checks pass. Both carry an explicit --subject /\n * --body-file, which is the ONLY way main's history gets the PR title plus the compact\n * risk/flags body — no repo setting can produce that. Requires allow_auto_merge on the repo.\n * NONE — wp-finish-upsert-pr only opens/updates the PR and stops; a human merges. NOTE the cost:\n * a UI merge cannot use the compact body, so main's commit falls back to the repo's\n * squash_merge_commit_title/message settings. Set squash_merge_commit_title=PR_TITLE there, or\n * commits land as the internal \"Squash merge of <branch>\" subject.\n */\n mergeMode: string;\n // This repo's review checklists, straight from the `pr-gate.checklists` ARRAY in webpieces.config.json —\n // the ONLY accepted shape (`patterns` is a path-glob dispatch table and `id` the checklist's name, so both\n // are config). Every def carries {@link reviewer}. [] = no checklists. The removed `{ doc }` manifest\n // form is a hard config error; see validateChecklistsSection.\n checklists: ChecklistDefinition[];\n /**\n * The ONE agent type every checklist is reviewed by — `webpieces-reviewer` unless\n * `overrideReviewerAgent` is true, in which case `reviewerAgentName` — and `reviewerAgents`, the most such\n * subagents a round may use. The same instance is bound into every {@link checklists} entry, so a caller\n * holding only a checklist still knows what to spawn. Field-with-default because the constructor is at\n * max-params; the agent name defaults to the webpieces reviewer, exactly what a config that says nothing\n * gets, while the CAP is a required field, so the placeholder here is only ever overwritten by the real\n * number buildPrGateConfig reads.\n */\n reviewer: ReviewerAgentPolicy = new ReviewerAgentPolicy(DEFAULT_REVIEWER_AGENT_NAME, REVIEWER_AGENTS_PLACEHOLDER);\n /**\n * REQUIRED positive integer: the maximum number of complete global reviewer rounds a PR review state\n * may start. This is deliberately repository policy rather than a machine-local preference.\n */\n maxReviewerRounds!: number;\n // Whether wp-finish-upsert-pr publishes each reviewer's full `output` as ONE combined PR comment\n // (idempotently updated on every push). Defaults to true. Set false to keep the PR body-only.\n checklistComments: boolean;\n /**\n * Shared secret used to mint the server-verifiable gate token. `wp-finish-upsert-pr` writes it after\n * the automated gate passes; `wp-human-post-pr` writes the same token after explicit human attestation\n * and visibly labels review as skipped plus whether its optional local build ran. A CI check\n * recomputes it from the PR head + salt.\n *\n * Optional, defaults to '' — empty means \"no token minted, no CI enforcement\" (byte-identical to\n * before this field existed). This is COMMITTED, obscurity-grade: it stops unhooked teammates who\n * push + open a PR in the web UI, but is readable in-repo and therefore forgeable by a determined\n * reader. It is deliberately NOT cryptographically sound; nothing local can stop a filesystem-reading\n * agent. See RESPONSE-pr-gate-ci-enforcement / the design memo for the full tradeoff.\n */\n gateSalt: string;\n /**\n * What `wp-land-pr` (and `wp-cleanup`, which reaps the same branches) does with the LOCAL branch\n * once its PR is in main. Field-with-default rather than another positional constructor param —\n * this constructor is already at the max-params limit, and every existing `new PrGateConfig(...)`\n * call site correctly wants the default.\n */\n landPr: LandPrConfig = defaultLandPrConfig();\n /**\n * Globs whose diffs are NOT extracted into `.webpieces-logs/pr-review/<feature>/diff/` — regenerated noise a\n * reviewer should not spend context reading (lockfiles, generated graphs). Default [].\n *\n * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the\n * command that gets the real diff. Removing them from the changed-file set would read as \"this file did\n * not change\", which is a different and false claim.\n *\n * Fields-with-defaults rather than constructor params: that constructor is already at max-params, and\n * every existing `new PrGateConfig(...)` correctly wants the defaults.\n */\n reviewDiffExclude: string[] = [];\n /**\n * Repo-specific places a reviewer would otherwise hunt for, as `{label, path}` — e.g.\n * `{\"label\":\"Cloud Tasks queue names\",\"path\":\"terraform/services/\"}`. Resolved to absolute paths in each\n * generated instructions file; a configured-but-missing path is printed as missing, never dropped.\n */\n reviewContext: ReviewContextEntry[] = [];\n /**\n * Installed packages to resolve and hand reviewers by absolute directory. This is the knob aimed at a\n * measured failure: one reviewer burned three separate greps into `node_modules/@webpieces` looking for\n * a scanner the tooling could have pointed at directly.\n */\n reviewContextPackages: string[] = [];\n /**\n * Promote \"this reviewer wrote a verdict without ever opening the diff\" from a warning to a refusal.\n * Default false, and it should stay false until a repo has watched the warning for a while: the signal\n * is derived from undocumented Claude Code transcript internals, so a format change would otherwise\n * wedge every PR in the repo with no self-service way out.\n */\n requireDiffEvidence = false;\n /**\n * Where `wp-push-dev` publishes the disposable copy. Omitted ⇒ `dev-include` / `dev`, which is what\n * makes the whole flow work with NO config edit at all.\n */\n devDeploy: DevDeployConfig = defaultDevDeployConfig();\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n mode: string,\n buildCommand: string,\n gates: GateDefinition[],\n mergeMode: string,\n checklists: ChecklistDefinition[] = [],\n gateSalt = '',\n checklistComments = true,\n ) {\n this.mode = mode;\n this.buildCommand = buildCommand;\n this.gates = gates;\n this.mergeMode = mergeMode;\n this.checklists = checklists;\n this.gateSalt = gateSalt;\n this.checklistComments = checklistComments;\n }\n}\n\n// Default infra gates — path-pattern based, tuned for this monorepo. Clients override the\n// whole list via the `pr-gate.gates` array in webpieces.config.json.\nexport function defaultGates(): GateDefinition[] {\n return [\n new GateDefinition('API Changed', ['libraries/apis/**', '**/*Api.ts'], 'yellow'),\n new GateDefinition(\n 'Config Files Changed',\n ['**/package.json', '**/tsconfig*.json', 'nx.json', '**/*.config.*'],\n 'yellow',\n ),\n new GateDefinition(\n 'Dependency Graph Changed',\n ['architecture/dependencies.json'],\n 'yellow',\n ),\n new GateDefinition(\n 'Claude / Rules Changed',\n ['**/CLAUDE.md', '**/claude.*.md', '.claude/**', 'webpieces.config.json'],\n 'yellow',\n ),\n ];\n}\n\nexport function defaultPrGateConfig(): PrGateConfig {\n // No default checklists — the extension point is opt-in; the default monorepo ships none.\n return new PrGateConfig('ON', '', defaultGates(), MERGE_MODE_AUTO, []);\n}\n\ninterface RawGate {\n name?: string;\n patterns?: string[];\n warningColor?: string;\n disabled?: boolean;\n}\n\ninterface RawPrGateSection {\n mode?: string;\n buildCommand?: string;\n gates?: RawGate[];\n mergeMode?: string;\n // An ARRAY, always. validateChecklistsSection rejects every other shape (including the removed { doc }).\n checklists?: RawChecklistItem[];\n overrideReviewerAgent?: boolean;\n reviewerAgentName?: string;\n reviewerAgents?: number;\n maxReviewerRounds?: number;\n gateSalt?: string;\n checklistComments?: boolean;\n landPr?: RawLandPr;\n reviewDiffExclude?: string[];\n reviewContext?: RawReviewContext[];\n reviewContextPackages?: string[];\n requireDiffEvidence?: boolean;\n devDeploy?: RawDevDeploy;\n}\n\ninterface RawDevDeploy {\n branchNamespace?: string;\n devBranch?: string;\n}\n\ninterface RawLandPr {\n branchRetention?: string;\n}\n\ninterface RawReviewContext {\n label?: string;\n path?: string;\n}\n\nfunction toGate(raw: RawGate): GateDefinition {\n return new GateDefinition(\n raw.name ?? '',\n raw.patterns ?? [],\n raw.warningColor ?? 'yellow',\n raw.disabled ?? false,\n );\n}\n\n/**\n * Build a PrGateConfig from the already-parsed top-level `pr-gate` section, falling back to defaults\n * for any field the consumer omits. Pure transform — the file read + structural validation happen in\n * loadAndValidate (load-config.ts) so every consumer goes through one validated path. Pass undefined\n * (no `pr-gate` key / no config file) to get full defaults.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed here\nexport function buildPrGateConfig(section: unknown): PrGateConfig {\n const defaults = defaultPrGateConfig();\n if (section === undefined || section === null || typeof section !== 'object') return defaults;\n\n const raw = section as RawPrGateSection;\n const mode = raw.mode ?? defaults.mode;\n const buildCommand = raw.buildCommand ?? defaults.buildCommand;\n const gates = raw.gates !== undefined ? raw.gates.map(toGate) : defaults.gates;\n // REQUIRED — validatePrGateSection rejects an omitted/unknown value, so this fallback only ever\n // applies to the no-config-file path that defaultPrGateConfig() serves.\n const mergeMode = raw.mergeMode ?? defaults.mergeMode;\n // Optional extension point — omitted ⇒ [] ⇒ no checklists computed anywhere downstream. A non-array here\n // cannot reach us: validateChecklistsSection has already failed the load.\n // The webpieces reviewer unless `overrideReviewerAgent` is true, in which case `reviewerAgentName` names the\n // agent (validatePrGateSection rejects a name without the override, and the override without a name).\n // Required nonnegative integer: 0 disables reviewer-agent reviews; positive values cap the round.\n const agentName =\n raw.overrideReviewerAgent === true\n ? (raw.reviewerAgentName ?? '').trim()\n : DEFAULT_REVIEWER_AGENT_NAME;\n // `reviewerAgents` is REQUIRED and validated as a nonnegative integer before this runs, so the fallback is\n // unreachable in a loaded config and exists only to keep this total for a structure-only caller.\n const reviewer = new ReviewerAgentPolicy(\n agentName,\n typeof raw.reviewerAgents === 'number' ? raw.reviewerAgents : REVIEWER_AGENTS_PLACEHOLDER,\n );\n const checklists = Array.isArray(raw.checklists)\n ? raw.checklists.map(\n (item: RawChecklistItem): ChecklistDefinition => toChecklist(item, reviewer),\n )\n : defaults.checklists;\n // Optional — omitted ⇒ '' ⇒ no gate token minted and CI enforcement is a no-op (back-compat).\n const gateSalt = raw.gateSalt ?? defaults.gateSalt;\n // Optional — omitted ⇒ true ⇒ reviewer output published as a PR comment.\n const checklistComments = raw.checklistComments ?? defaults.checklistComments;\n const built = new PrGateConfig(\n mode,\n buildCommand,\n gates,\n mergeMode,\n checklists,\n gateSalt,\n checklistComments,\n );\n built.landPr = buildLandPrConfig(raw.landPr);\n built.reviewer = reviewer;\n built.maxReviewerRounds = raw.maxReviewerRounds as number;\n // Review-context knobs. All optional and all defaulted, so a config that omits every one of them (which\n // is every consumer's config today) behaves exactly as it did before they existed.\n built.reviewDiffExclude = Array.isArray(raw.reviewDiffExclude)\n ? raw.reviewDiffExclude\n : defaults.reviewDiffExclude;\n built.reviewContextPackages = Array.isArray(raw.reviewContextPackages)\n ? raw.reviewContextPackages\n : defaults.reviewContextPackages;\n built.reviewContext = Array.isArray(raw.reviewContext)\n ? raw.reviewContext.map(\n (e: RawReviewContext): ReviewContextEntry =>\n new ReviewContextEntry(e.label ?? '', e.path ?? ''),\n )\n : defaults.reviewContext;\n built.requireDiffEvidence = raw.requireDiffEvidence ?? defaults.requireDiffEvidence;\n built.devDeploy = buildDevDeployConfig(raw.devDeploy);\n return built;\n}\n\n/**\n * Build the `pr-gate.devDeploy` block. Omitted (the state of every consumer config today) ⇒ the\n * `dev-include` / `dev` defaults. An invalid value cannot reach here — validateDevDeploySection has\n * already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildDevDeployConfig(raw: RawDevDeploy | undefined): DevDeployConfig {\n const defaults = defaultDevDeployConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const namespace =\n typeof raw.branchNamespace === 'string' && raw.branchNamespace.trim() !== ''\n ? raw.branchNamespace.trim()\n : defaults.branchNamespace;\n const devBranch =\n typeof raw.devBranch === 'string' && raw.devBranch.trim() !== ''\n ? raw.devBranch.trim()\n : defaults.devBranch;\n return new DevDeployConfig(namespace, devBranch);\n}\n\n/**\n * Build the `pr-gate.landPr` block. Omitted (the current state of every consumer's config) ⇒ the\n * 'archive-tag' default, which is what makes this feature work with NO config edit at all. An invalid\n * value cannot reach here — validatePrGateSection has already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildLandPrConfig(raw: RawLandPr | undefined): LandPrConfig {\n const defaults = defaultLandPrConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const retention = raw.branchRetention;\n if (typeof retention !== 'string' || !BRANCH_RETENTIONS.includes(retention)) return defaults;\n return new LandPrConfig(retention);\n}\n"]}
1
+ {"version":3,"file":"pr-gate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pr-gate-config.ts"],"names":[],"mappings":";;;AA2FA,kDAEC;AAgDD,wDAEC;AAwID,oCAmBC;AAED,kDAGC;AA4DD,8CAgEC;AAQD,oDAYC;AAQD,8CAMC;AA7cD,sEAAgG;AAChG,yDAO4B;AAE5B,2FAA2F;AAC3F,2FAA2F;AAC3F,iFAAiF;AACjF,iGAAiG;AAEjG;;;;;;;;;;;GAWG;AACU,QAAA,qBAAqB,GAC9B,wEAAwE,CAAC;AAE7E,MAAa,cAAc;IACvB,IAAI,CAAS;IACb,QAAQ,CAAW;IACnB,iGAAiG;IACjG,8FAA8F;IAC9F,+FAA+F;IAC/F,gGAAgG;IAChG,YAAY,CAAS,CAAC,mBAAmB;IACzC,2FAA2F;IAC3F,yFAAyF;IACzF,QAAQ,CAAU;IAElB,YAAY,IAAY,EAAE,QAAkB,EAAE,YAAoB,EAAE,QAAQ,GAAG,KAAK;QAChF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AAlBD,wCAkBC;AAED,qGAAqG;A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S,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { BRANCH_RETENTION_ARCHIVE_TAG, BRANCH_RETENTIONS } from '@webpieces/repo-workflow-core';\nimport {\n ChecklistDefinition,\n DEFAULT_REVIEWER_AGENT_NAME,\n RawChecklistItem,\n REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy,\n toChecklist,\n} from './checklist-config';\n\n// PrGateConfig is the \"special section\" for the pr-gate dashboard. It does NOT live in the\n// validated `rules` map (the FieldDef schema can't express nested object arrays), but as a\n// top-level `pr-gate` key in webpieces.config.json. It is built and validated by\n// loadAndValidate (load-config.ts); this module holds only the data classes + defaults + toGate.\n\n/**\n * The build the pr-gate runs when a repo configures no `commands.pr-gate.buildCommand` — and the ONE\n * definition of it, because two things now need it: the gate that RUNS it (pr-gate's BuildAffected)\n * and the guard that REFUSES a whole-monorepo build and prints it instead (ai-hook-rules'\n * whole-repo-build-guard). A second copy in either package is a message that can teach a command the\n * gate does not run.\n *\n * `--base=$(git merge-base origin/main HEAD)` — the FORK POINT, not `origin/main`: basing on\n * origin/main marks projects touched by other people's already-merged PRs as affected. The `$(…)`\n * resolves because the gate spawns with `shell: true`; the guard resolves it itself before printing,\n * so the AI is never handed a template it might paste somewhere without a shell.\n */\nexport const DEFAULT_BUILD_COMMAND =\n 'pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)';\n\nexport class GateDefinition {\n name: string;\n patterns: string[];\n // The warning color shown on the dashboard WHEN this gate's patterns match a changed file. Green\n // is implicit (shown when nothing matched), so it is never configured. warningColor is purely\n // visual — even 'red' never fails/blocks the PR (only the build gate can). 'yellow' = caution,\n // 'red' = louder \"look here\" flag (e.g. DB schema / migration changes). REQUIRED on every gate.\n warningColor: string; // 'yellow' | 'red'\n // Example/inactive gate: parsed and kept in the file (JSON has no comments) but skipped at\n // compute/render time. Other projects flip this to false and tune patterns/warningColor.\n disabled: boolean;\n\n constructor(name: string, patterns: string[], warningColor: string, disabled = false) {\n this.name = name;\n this.patterns = patterns;\n this.warningColor = warningColor;\n this.disabled = disabled;\n }\n}\n\n// How wp-finish-upsert-pr should try to LAND the PR once it has posted it. GitHub's auto-merge queue\n// is a REPO-level setting (`allow_auto_merge`) that many orgs turn OFF as a policy control, and it\n// CANNOT be forced from the client: `gh pr merge --auto` calls the enablePullRequestAutoMerge GraphQL\n// mutation, which hard-errors with \"Auto merge is not allowed for this repository\" when the repo says\n// no. So the only lever a config knob has is WHICH PATHS WE ATTEMPT — never whether the queue exists.\nexport const MERGE_MODE_AUTO = 'AUTO';\nexport const MERGE_MODE_NONE = 'NONE';\nexport const MERGE_MODES = [MERGE_MODE_AUTO, MERGE_MODE_NONE];\n\n/**\n * `pr-gate.landPr` — what happens to the LOCAL branch once its PR has landed.\n *\n * A rich object rather than a bare string (the `commands.pr-gate` precedent) so the next knob about\n * landing has a home, and so the rationale can sit beside the setting as a `*Why` sibling: JSON has no\n * comments, and `<key>Why` is how this repo documents non-obvious config.\n */\n/**\n * One `pr-gate.reviewContext` entry: a human label and a repo-relative path a reviewer is handed instead of\n * having to find it. Data-only (per CLAUDE.md).\n */\nexport class ReviewContextEntry {\n label: string;\n path: string; // repo-relative in config; resolved to absolute when written into an instructions file\n\n constructor(label: string, entryPath: string) {\n this.label = label;\n this.path = entryPath;\n }\n}\n\nexport class LandPrConfig {\n // One of BRANCH_RETENTIONS. Defaults to 'archive-tag' — see BranchArchiver for why a tag beats\n // keeping the branch, storing a patch, or trusting the reflog.\n branchRetention: string;\n\n constructor(branchRetention: string = BRANCH_RETENTION_ARCHIVE_TAG) {\n this.branchRetention = branchRetention;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultLandPrConfig(): LandPrConfig {\n return new LandPrConfig(BRANCH_RETENTION_ARCHIVE_TAG);\n}\n\n// The two literal ref names the dev-deploy flow derives everything else from. Defaults, not policy —\n// `pr-gate.devDeploy` overrides both, because a consumer whose shared environment is called `staging`\n// must not be forced onto webpieces' vocabulary.\nexport const DEFAULT_DEV_BRANCH_NAMESPACE = 'dev-include';\nexport const DEFAULT_DEV_BRANCH = 'dev';\n\n/**\n * `pr-gate.devDeploy` — where `wp-push-dev` publishes the throwaway copy of a feature branch, and which\n * ref is the shared dev branch itself.\n *\n * WHY A NAMESPACE AT ALL, i.e. why the copy is not just the feature branch: the feature branch is the PR\n * head, and landing that PR ships whatever is on it. The moment a conflict between two devs has to be\n * resolved SOMEWHERE for the shared environment to build, that resolution needs a home that is not the PR\n * branch — otherwise \"test it in dev\" silently ships another dev's unreviewed work to production. The\n * `<branchNamespace>/<feature>` copy is that home, and it is disposable by construction.\n *\n * `devBranch` is REFUSED as a source branch (you never push the composed branch back into itself); it is\n * written by the consumer's CI only, which recomputes it from `origin/main` on every run.\n */\nexport class DevDeployConfig {\n // Literal prefix on the feature branch name: `dev-include/dean/ONE-2275`. Git refs allow slashes, and\n // nobody ever types this — the command derives it.\n branchNamespace: string;\n // The composed, CI-owned branch that actually deploys. Never a source, never pushed to by this flow.\n devBranch: string;\n\n constructor(\n branchNamespace: string = DEFAULT_DEV_BRANCH_NAMESPACE,\n devBranch: string = DEFAULT_DEV_BRANCH,\n ) {\n this.branchNamespace = branchNamespace;\n this.devBranch = devBranch;\n }\n\n /** `<branchNamespace>/<branch>` — the remote ref holding the disposable copy of `branch`. */\n copyRefFor(branch: string): string {\n return `${this.branchNamespace}/${branch}`;\n }\n\n /** The `git ls-remote --heads origin <pattern>` pattern matching every live copy. */\n copyRefGlob(): string {\n return `${this.branchNamespace}/*`;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultDevDeployConfig(): DevDeployConfig {\n return new DevDeployConfig(DEFAULT_DEV_BRANCH_NAMESPACE, DEFAULT_DEV_BRANCH);\n}\n\nexport class PrGateConfig {\n mode: string;\n /**\n * The nx-affected build gate command, shared by the two commands that can run it.\n *\n * It is NOT finish-only any more, and the change is the point. It used to run once, in\n * wp-finish-upsert-pr, which meant reviewers were spawned against a branch nobody had built — they could\n * spend a full review on code that does not compile, or on an unresolved 3-point merge.\n *\n * Now `wp-review-upsert-pr` finalizes the merge and runs this gate BEFORE briefing any reviewer, and\n * records the passing HEAD sha in the stage receipt. `wp-finish-upsert-pr` re-runs it only when HEAD has\n * moved since — so the flow gained a gate where it mattered without paying for two full builds.\n *\n * Empty string => BuildAffected falls back to DEFAULT_BUILD_COMMAND.\n */\n buildCommand: string;\n gates: GateDefinition[];\n /**\n * REQUIRED — every repo must state its policy; there is deliberately no default, because the two\n * answers are a real policy decision and guessing it either merges when a team did not want that,\n * or silently stops landing PRs on a team that relied on it.\n *\n * AUTO — wp-finish-upsert-pr LANDS the PR: squash-merge it right away when it is mergeable, else\n * enable GitHub auto-merge so it lands when the checks pass. Both carry an explicit --subject /\n * --body-file, which is the ONLY way main's history gets the PR title plus the compact\n * risk/flags body — no repo setting can produce that. Requires allow_auto_merge on the repo.\n * NONE — wp-finish-upsert-pr only opens/updates the PR and stops; a human merges. NOTE the cost:\n * a UI merge cannot use the compact body, so main's commit falls back to the repo's\n * squash_merge_commit_title/message settings. Set squash_merge_commit_title=PR_TITLE there, or\n * commits land as the internal \"Squash merge of <branch>\" subject.\n */\n mergeMode: string;\n // This repo's review checklists, straight from the `pr-gate.checklists` ARRAY in webpieces.config.json —\n // the ONLY accepted shape (`patterns` is a path-glob dispatch table and `id` the checklist's name, so both\n // are config). Every def carries {@link reviewer}. [] = no checklists. The removed `{ doc }` manifest\n // form is a hard config error; see validateChecklistsSection.\n checklists: ChecklistDefinition[];\n /**\n * The ONE agent type every checklist is reviewed by — `webpieces-reviewer` unless\n * `overrideReviewerAgent` is true, in which case `reviewerAgentName` — and `reviewerAgents`, the most such\n * subagents a round may use. The same instance is bound into every {@link checklists} entry, so a caller\n * holding only a checklist still knows what to spawn. Field-with-default because the constructor is at\n * max-params; the agent name defaults to the webpieces reviewer, exactly what a config that says nothing\n * gets, while the CAP is a required field, so the placeholder here is only ever overwritten by the real\n * number buildPrGateConfig reads.\n */\n reviewer: ReviewerAgentPolicy = new ReviewerAgentPolicy(DEFAULT_REVIEWER_AGENT_NAME, REVIEWER_AGENTS_PLACEHOLDER);\n /**\n * REQUIRED positive integer: the maximum number of complete global reviewer rounds a PR review state\n * may start. This is deliberately repository policy rather than a machine-local preference.\n */\n maxReviewerRounds!: number;\n // Whether wp-finish-upsert-pr publishes each reviewer's full `output` as ONE combined PR comment\n // (idempotently updated on every push). Defaults to true. Set false to keep the PR body-only.\n checklistComments: boolean;\n /**\n * Shared secret used to mint the server-verifiable gate token. `wp-finish-upsert-pr` writes it after\n * the automated gate passes; `wp-human-post-pr` writes the same token after explicit human attestation\n * and visibly labels review as skipped plus whether its optional local build ran. A CI check\n * recomputes it from the PR head + salt.\n *\n * Optional, defaults to '' — empty means \"no token minted, no CI enforcement\" (byte-identical to\n * before this field existed). This is COMMITTED, obscurity-grade: it stops unhooked teammates who\n * push + open a PR in the web UI, but is readable in-repo and therefore forgeable by a determined\n * reader. It is deliberately NOT cryptographically sound; nothing local can stop a filesystem-reading\n * agent. See RESPONSE-pr-gate-ci-enforcement / the design memo for the full tradeoff.\n */\n gateSalt: string;\n /**\n * What `wp-land-pr` (and `wp-cleanup`, which reaps the same branches) does with the LOCAL branch\n * once its PR is in main. Field-with-default rather than another positional constructor param —\n * this constructor is already at the max-params limit, and every existing `new PrGateConfig(...)`\n * call site correctly wants the default.\n */\n landPr: LandPrConfig = defaultLandPrConfig();\n /**\n * Globs whose diffs are NOT extracted into `.webpieces/pr-review/<feature>/diff/` — regenerated noise a\n * reviewer should not spend context reading (lockfiles, generated graphs). Default [].\n *\n * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the\n * command that gets the real diff. Removing them from the changed-file set would read as \"this file did\n * not change\", which is a different and false claim.\n *\n * Fields-with-defaults rather than constructor params: that constructor is already at max-params, and\n * every existing `new PrGateConfig(...)` correctly wants the defaults.\n */\n reviewDiffExclude: string[] = [];\n /**\n * Repo-specific places a reviewer would otherwise hunt for, as `{label, path}` — e.g.\n * `{\"label\":\"Cloud Tasks queue names\",\"path\":\"terraform/services/\"}`. Resolved to absolute paths in each\n * generated instructions file; a configured-but-missing path is printed as missing, never dropped.\n */\n reviewContext: ReviewContextEntry[] = [];\n /**\n * Installed packages to resolve and hand reviewers by absolute directory. This is the knob aimed at a\n * measured failure: one reviewer burned three separate greps into `node_modules/@webpieces` looking for\n * a scanner the tooling could have pointed at directly.\n */\n reviewContextPackages: string[] = [];\n /**\n * Promote \"this reviewer wrote a verdict without ever opening the diff\" from a warning to a refusal.\n * Default false, and it should stay false until a repo has watched the warning for a while: the signal\n * is derived from undocumented Claude Code transcript internals, so a format change would otherwise\n * wedge every PR in the repo with no self-service way out.\n */\n requireDiffEvidence = false;\n /**\n * Where `wp-push-dev` publishes the disposable copy. Omitted ⇒ `dev-include` / `dev`, which is what\n * makes the whole flow work with NO config edit at all.\n */\n devDeploy: DevDeployConfig = defaultDevDeployConfig();\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n mode: string,\n buildCommand: string,\n gates: GateDefinition[],\n mergeMode: string,\n checklists: ChecklistDefinition[] = [],\n gateSalt = '',\n checklistComments = true,\n ) {\n this.mode = mode;\n this.buildCommand = buildCommand;\n this.gates = gates;\n this.mergeMode = mergeMode;\n this.checklists = checklists;\n this.gateSalt = gateSalt;\n this.checklistComments = checklistComments;\n }\n}\n\n// Default infra gates — path-pattern based, tuned for this monorepo. Clients override the\n// whole list via the `pr-gate.gates` array in webpieces.config.json.\nexport function defaultGates(): GateDefinition[] {\n return [\n new GateDefinition('API Changed', ['libraries/apis/**', '**/*Api.ts'], 'yellow'),\n new GateDefinition(\n 'Config Files Changed',\n ['**/package.json', '**/tsconfig*.json', 'nx.json', '**/*.config.*'],\n 'yellow',\n ),\n new GateDefinition(\n 'Dependency Graph Changed',\n ['architecture/dependencies.json'],\n 'yellow',\n ),\n new GateDefinition(\n 'Claude / Rules Changed',\n ['**/CLAUDE.md', '**/claude.*.md', '.claude/**', 'webpieces.config.json'],\n 'yellow',\n ),\n ];\n}\n\nexport function defaultPrGateConfig(): PrGateConfig {\n // No default checklists — the extension point is opt-in; the default monorepo ships none.\n return new PrGateConfig('ON', '', defaultGates(), MERGE_MODE_AUTO, []);\n}\n\ninterface RawGate {\n name?: string;\n patterns?: string[];\n warningColor?: string;\n disabled?: boolean;\n}\n\ninterface RawPrGateSection {\n mode?: string;\n buildCommand?: string;\n gates?: RawGate[];\n mergeMode?: string;\n // An ARRAY, always. validateChecklistsSection rejects every other shape (including the removed { doc }).\n checklists?: RawChecklistItem[];\n overrideReviewerAgent?: boolean;\n reviewerAgentName?: string;\n reviewerAgents?: number;\n maxReviewerRounds?: number;\n gateSalt?: string;\n checklistComments?: boolean;\n landPr?: RawLandPr;\n reviewDiffExclude?: string[];\n reviewContext?: RawReviewContext[];\n reviewContextPackages?: string[];\n requireDiffEvidence?: boolean;\n devDeploy?: RawDevDeploy;\n}\n\ninterface RawDevDeploy {\n branchNamespace?: string;\n devBranch?: string;\n}\n\ninterface RawLandPr {\n branchRetention?: string;\n}\n\ninterface RawReviewContext {\n label?: string;\n path?: string;\n}\n\nfunction toGate(raw: RawGate): GateDefinition {\n return new GateDefinition(\n raw.name ?? '',\n raw.patterns ?? [],\n raw.warningColor ?? 'yellow',\n raw.disabled ?? false,\n );\n}\n\n/**\n * Build a PrGateConfig from the already-parsed top-level `pr-gate` section, falling back to defaults\n * for any field the consumer omits. Pure transform — the file read + structural validation happen in\n * loadAndValidate (load-config.ts) so every consumer goes through one validated path. Pass undefined\n * (no `pr-gate` key / no config file) to get full defaults.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed here\nexport function buildPrGateConfig(section: unknown): PrGateConfig {\n const defaults = defaultPrGateConfig();\n if (section === undefined || section === null || typeof section !== 'object') return defaults;\n\n const raw = section as RawPrGateSection;\n const mode = raw.mode ?? defaults.mode;\n const buildCommand = raw.buildCommand ?? defaults.buildCommand;\n const gates = raw.gates !== undefined ? raw.gates.map(toGate) : defaults.gates;\n // REQUIRED — validatePrGateSection rejects an omitted/unknown value, so this fallback only ever\n // applies to the no-config-file path that defaultPrGateConfig() serves.\n const mergeMode = raw.mergeMode ?? defaults.mergeMode;\n // Optional extension point — omitted ⇒ [] ⇒ no checklists computed anywhere downstream. A non-array here\n // cannot reach us: validateChecklistsSection has already failed the load.\n // The webpieces reviewer unless `overrideReviewerAgent` is true, in which case `reviewerAgentName` names the\n // agent (validatePrGateSection rejects a name without the override, and the override without a name).\n // Required nonnegative integer: 0 disables reviewer-agent reviews; positive values cap the round.\n const agentName =\n raw.overrideReviewerAgent === true\n ? (raw.reviewerAgentName ?? '').trim()\n : DEFAULT_REVIEWER_AGENT_NAME;\n // `reviewerAgents` is REQUIRED and validated as a nonnegative integer before this runs, so the fallback is\n // unreachable in a loaded config and exists only to keep this total for a structure-only caller.\n const reviewer = new ReviewerAgentPolicy(\n agentName,\n typeof raw.reviewerAgents === 'number' ? raw.reviewerAgents : REVIEWER_AGENTS_PLACEHOLDER,\n );\n const checklists = Array.isArray(raw.checklists)\n ? raw.checklists.map(\n (item: RawChecklistItem): ChecklistDefinition => toChecklist(item, reviewer),\n )\n : defaults.checklists;\n // Optional — omitted ⇒ '' ⇒ no gate token minted and CI enforcement is a no-op (back-compat).\n const gateSalt = raw.gateSalt ?? defaults.gateSalt;\n // Optional — omitted ⇒ true ⇒ reviewer output published as a PR comment.\n const checklistComments = raw.checklistComments ?? defaults.checklistComments;\n const built = new PrGateConfig(\n mode,\n buildCommand,\n gates,\n mergeMode,\n checklists,\n gateSalt,\n checklistComments,\n );\n built.landPr = buildLandPrConfig(raw.landPr);\n built.reviewer = reviewer;\n built.maxReviewerRounds = raw.maxReviewerRounds as number;\n // Review-context knobs. All optional and all defaulted, so a config that omits every one of them (which\n // is every consumer's config today) behaves exactly as it did before they existed.\n built.reviewDiffExclude = Array.isArray(raw.reviewDiffExclude)\n ? raw.reviewDiffExclude\n : defaults.reviewDiffExclude;\n built.reviewContextPackages = Array.isArray(raw.reviewContextPackages)\n ? raw.reviewContextPackages\n : defaults.reviewContextPackages;\n built.reviewContext = Array.isArray(raw.reviewContext)\n ? raw.reviewContext.map(\n (e: RawReviewContext): ReviewContextEntry =>\n new ReviewContextEntry(e.label ?? '', e.path ?? ''),\n )\n : defaults.reviewContext;\n built.requireDiffEvidence = raw.requireDiffEvidence ?? defaults.requireDiffEvidence;\n built.devDeploy = buildDevDeployConfig(raw.devDeploy);\n return built;\n}\n\n/**\n * Build the `pr-gate.devDeploy` block. Omitted (the state of every consumer config today) ⇒ the\n * `dev-include` / `dev` defaults. An invalid value cannot reach here — validateDevDeploySection has\n * already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildDevDeployConfig(raw: RawDevDeploy | undefined): DevDeployConfig {\n const defaults = defaultDevDeployConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const namespace =\n typeof raw.branchNamespace === 'string' && raw.branchNamespace.trim() !== ''\n ? raw.branchNamespace.trim()\n : defaults.branchNamespace;\n const devBranch =\n typeof raw.devBranch === 'string' && raw.devBranch.trim() !== ''\n ? raw.devBranch.trim()\n : defaults.devBranch;\n return new DevDeployConfig(namespace, devBranch);\n}\n\n/**\n * Build the `pr-gate.landPr` block. Omitted (the current state of every consumer's config) ⇒ the\n * 'archive-tag' default, which is what makes this feature work with NO config edit at all. An invalid\n * value cannot reach here — validatePrGateSection has already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildLandPrConfig(raw: RawLandPr | undefined): LandPrConfig {\n const defaults = defaultLandPrConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const retention = raw.branchRetention;\n if (typeof retention !== 'string' || !BRANCH_RETENTIONS.includes(retention)) return defaults;\n return new LandPrConfig(retention);\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import { DotWebpieces } from '@webpieces/tooling-common';
2
- export declare const INSTRUCT_AI_DIR = ".webpieces-logs/instruct-ai";
2
+ export declare const INSTRUCT_AI_DIR = ".webpieces/instruct-ai";
3
3
  export declare const INSTRUCT_AI_LEAF = "instruct-ai";
4
4
  /**
5
- * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath
5
+ * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath
6
6
  * it.
7
7
  *
8
- * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
9
- * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own
10
- * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every
11
- * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
8
+ * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
9
+ * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own
10
+ * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every
11
+ * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
12
12
  * path here rather than at `process.cwd()`.
13
13
  */
14
14
  export declare class RepoRootFinder {
@@ -36,7 +36,7 @@ export declare class RepoRootFinder {
36
36
  resolveRepoRoot(startDir: string): string;
37
37
  /**
38
38
  * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a
39
- * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
39
+ * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
40
40
  * resolve against the wrong directory and fail to open.
41
41
  *
42
42
  * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven
package/src/repo-root.js CHANGED
@@ -7,19 +7,19 @@ const inversify_1 = require("inversify");
7
7
  const config_file_1 = require("./config-file");
8
8
  const tooling_common_1 = require("@webpieces/tooling-common");
9
9
  const tooling_common_2 = require("@webpieces/tooling-common");
10
- // The single instruct-ai home under `.webpieces-logs/`. Kept here (not just in load-template) so callers
10
+ // The single instruct-ai home under `.webpieces/`. Kept here (not just in load-template) so callers
11
11
  // building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.
12
12
  exports.INSTRUCT_AI_DIR = `${tooling_common_1.WEBPIECES_TMP_DIR}/instruct-ai`;
13
- // The instruct-ai leaf under a resolved `.webpieces-logs` dir. LOCAL scope — see instructAiDocPath.
13
+ // The instruct-ai leaf under a resolved `.webpieces` dir. LOCAL scope — see instructAiDocPath.
14
14
  exports.INSTRUCT_AI_LEAF = 'instruct-ai';
15
15
  /**
16
- * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath
16
+ * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath
17
17
  * it.
18
18
  *
19
- * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
20
- * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own
21
- * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every
22
- * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
19
+ * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
20
+ * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own
21
+ * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every
22
+ * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
23
23
  * path here rather than at `process.cwd()`.
24
24
  */
25
25
  let RepoRootFinder = class RepoRootFinder {
@@ -57,7 +57,7 @@ let RepoRootFinder = class RepoRootFinder {
57
57
  }
58
58
  /**
59
59
  * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a
60
- * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
60
+ * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
61
61
  * resolve against the wrong directory and fail to open.
62
62
  *
63
63
  * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven
@@ -1 +1 @@
1
- {"version":3,"file":"repo-root.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-root.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAE3D,+CAA+C;AAC/C,8DAA8D;AAC9D,8DAAuE;AAEvE,yGAAyG;AACzG,0FAA0F;AAC7E,QAAA,eAAe,GAAG,GAAG,kCAAiB,cAAc,CAAC;AAClE,oGAAoG;AACvF,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;;;;;;;GASG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IACM;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,QAAgB;QAC5B,MAAM,UAAU,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC;QACrC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,QAAgB,EAAE,OAAe;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,wBAAgB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,gGAAgG;IAChG,WAAW,CAAC,QAAgB,EAAE,OAAe;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CAEJ,CAAA;AAlDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,cAAc,CAkD1B","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { findConfigFile } from './config-file';\nimport { WEBPIECES_TMP_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// The single instruct-ai home under `.webpieces-logs/`. Kept here (not just in load-template) so callers\n// building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.\nexport const INSTRUCT_AI_DIR = `${WEBPIECES_TMP_DIR}/instruct-ai`;\n// The instruct-ai leaf under a resolved `.webpieces-logs` dir. LOCAL scope — see instructAiDocPath.\nexport const INSTRUCT_AI_LEAF = 'instruct-ai';\n\n/**\n * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath\n * it.\n *\n * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked\n * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own\n * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every\n * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its\n * path here rather than at `process.cwd()`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoRootFinder {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * The repo root for `startDir`. Resolution order (first hit wins):\n * 1. Directory holding webpieces.config.json — the webpieces workspace root, and the exact\n * anchor the hook runner already uses. Walks UP from startDir, so a subdir resolves to root.\n * 2. git toplevel — the repo root when no config is present yet (e.g. the installer runs before\n * webpieces.config.json exists). Asked via `DotWebpieces.treeRoot`, which is the ONE\n * `git rev-parse` tree-root resolver in this repo (memoized, fails closed). This class used to\n * carry its own byte-identical `spawnSync` copy, with a comment claiming to \"mirror\"\n * runner.ts's — a mirror that had already drifted, since runner.ts had moved the call to\n * effective-tree.ts. There is one implementation now, so a mirror cannot drift.\n * 3. `startDir` — last resort (git unavailable / not a repo / no config). Best-effort only.\n *\n * Step 1 is deliberately FIRST and deliberately not identity: config walk-up climbs PAST a nested\n * clone's `.git` to the outer webpieces root (repo-root.spec.ts pins that), and in a linked worktree\n * it answers with the WORKTREE, because `webpieces.config.json` is TRACKED IN GIT and therefore part\n * of the BRANCH — a branch may change its own rules. See state-dir.ts for that boundary, and\n * `EffectiveTreeResolver` for the different question (\"which tree is this, and is it ours\") that\n * must NOT be answered from the config file.\n */\n resolveRepoRoot(startDir: string): string {\n const configPath = findConfigFile(startDir);\n if (configPath !== null) return path.dirname(configPath);\n const gitRoot = this.dotDir.treeRoot(startDir);\n if (gitRoot !== null) return gitRoot;\n return startDir;\n }\n\n /**\n * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a\n * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would\n * resolve against the wrong directory and fail to open.\n *\n * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven\n * agents would rewrite one file concurrently for no benefit — the content is version-scoped and\n * identical, and a doc the AI is told to open must never be mid-truncation. Per-worktree it has one\n * writer. TemplateWriter additionally writes it atomically and skips the write entirely when the\n * bytes already match.\n */\n instructAiDocPath(repoRoot: string, docName: string): string {\n return this.dotDir.localFile(repoRoot, INSTRUCT_AI_LEAF, docName);\n }\n\n /** Absolute instruct-ai doc path resolved directly from `startDir` (resolveRepoRoot + join). */\n docPathFrom(startDir: string, docName: string): string {\n return this.instructAiDocPath(this.resolveRepoRoot(startDir), docName);\n }\n\n}\n"]}
1
+ {"version":3,"file":"repo-root.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-root.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAE3D,+CAA+C;AAC/C,8DAA8D;AAC9D,8DAAuE;AAEvE,oGAAoG;AACpG,0FAA0F;AAC7E,QAAA,eAAe,GAAG,GAAG,kCAAiB,cAAc,CAAC;AAClE,+FAA+F;AAClF,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;;;;;;;GASG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IACM;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,QAAgB;QAC5B,MAAM,UAAU,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC;QACrC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,QAAgB,EAAE,OAAe;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,wBAAgB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,gGAAgG;IAChG,WAAW,CAAC,QAAgB,EAAE,OAAe;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CAEJ,CAAA;AAlDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,cAAc,CAkD1B","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { findConfigFile } from './config-file';\nimport { WEBPIECES_TMP_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// The single instruct-ai home under `.webpieces/`. Kept here (not just in load-template) so callers\n// building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.\nexport const INSTRUCT_AI_DIR = `${WEBPIECES_TMP_DIR}/instruct-ai`;\n// The instruct-ai leaf under a resolved `.webpieces` dir. LOCAL scope — see instructAiDocPath.\nexport const INSTRUCT_AI_LEAF = 'instruct-ai';\n\n/**\n * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath\n * it.\n *\n * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked\n * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own\n * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every\n * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its\n * path here rather than at `process.cwd()`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoRootFinder {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * The repo root for `startDir`. Resolution order (first hit wins):\n * 1. Directory holding webpieces.config.json — the webpieces workspace root, and the exact\n * anchor the hook runner already uses. Walks UP from startDir, so a subdir resolves to root.\n * 2. git toplevel — the repo root when no config is present yet (e.g. the installer runs before\n * webpieces.config.json exists). Asked via `DotWebpieces.treeRoot`, which is the ONE\n * `git rev-parse` tree-root resolver in this repo (memoized, fails closed). This class used to\n * carry its own byte-identical `spawnSync` copy, with a comment claiming to \"mirror\"\n * runner.ts's — a mirror that had already drifted, since runner.ts had moved the call to\n * effective-tree.ts. There is one implementation now, so a mirror cannot drift.\n * 3. `startDir` — last resort (git unavailable / not a repo / no config). Best-effort only.\n *\n * Step 1 is deliberately FIRST and deliberately not identity: config walk-up climbs PAST a nested\n * clone's `.git` to the outer webpieces root (repo-root.spec.ts pins that), and in a linked worktree\n * it answers with the WORKTREE, because `webpieces.config.json` is TRACKED IN GIT and therefore part\n * of the BRANCH — a branch may change its own rules. See state-dir.ts for that boundary, and\n * `EffectiveTreeResolver` for the different question (\"which tree is this, and is it ours\") that\n * must NOT be answered from the config file.\n */\n resolveRepoRoot(startDir: string): string {\n const configPath = findConfigFile(startDir);\n if (configPath !== null) return path.dirname(configPath);\n const gitRoot = this.dotDir.treeRoot(startDir);\n if (gitRoot !== null) return gitRoot;\n return startDir;\n }\n\n /**\n * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a\n * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would\n * resolve against the wrong directory and fail to open.\n *\n * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven\n * agents would rewrite one file concurrently for no benefit — the content is version-scoped and\n * identical, and a doc the AI is told to open must never be mid-truncation. Per-worktree it has one\n * writer. TemplateWriter additionally writes it atomically and skips the write entirely when the\n * bytes already match.\n */\n instructAiDocPath(repoRoot: string, docName: string): string {\n return this.dotDir.localFile(repoRoot, INSTRUCT_AI_LEAF, docName);\n }\n\n /** Absolute instruct-ai doc path resolved directly from `startDir` (resolveRepoRoot + join). */\n docPathFrom(startDir: string, docName: string): string {\n return this.instructAiDocPath(this.resolveRepoRoot(startDir), docName);\n }\n\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { DotWebpieces } from '@webpieces/tooling-common';
2
- /** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */
2
+ /** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */
3
3
  export declare const SCRATCH_DIR_NAME = "scratch";
4
4
  /**
5
- * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.
5
+ * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
6
6
  *
7
7
  * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
8
8
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
@@ -12,7 +12,7 @@ export declare class RepoScratchDirs {
12
12
  private readonly dotDir;
13
13
  constructor(dotDir?: DotWebpieces);
14
14
  /**
15
- * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.
15
+ * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.
16
16
  *
17
17
  * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.
18
18
  */
@@ -7,13 +7,13 @@ const path = tslib_1.__importStar(require("path"));
7
7
  const inversify_1 = require("inversify");
8
8
  const tooling_common_1 = require("@webpieces/tooling-common");
9
9
  // ---------------------------------------------------------------------------
10
- // SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces-logs/`, NOT IN `$TMPDIR`.
10
+ // SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.
11
11
  //
12
12
  // Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for
13
13
  // `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the
14
14
  // reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating
15
15
  // themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are
16
- // ordinary gate state, and every other piece of gate state lives under `.webpieces-logs/`.
16
+ // ordinary gate state, and every other piece of gate state lives under `.webpieces/`.
17
17
  //
18
18
  // Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps
19
19
  // `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file
@@ -21,10 +21,10 @@ const tooling_common_1 = require("@webpieces/tooling-common");
21
21
  // `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one
22
22
  // machine.
23
23
  // ---------------------------------------------------------------------------
24
- /** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */
24
+ /** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */
25
25
  exports.SCRATCH_DIR_NAME = 'scratch';
26
26
  /**
27
- * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.
27
+ * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
28
28
  *
29
29
  * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
30
30
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
@@ -36,7 +36,7 @@ let RepoScratchDirs = class RepoScratchDirs {
36
36
  this.dotDir = dotDir;
37
37
  }
38
38
  /**
39
- * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.
39
+ * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.
40
40
  *
41
41
  * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.
42
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,oFAAoF;AACpF,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,2FAA2F;AAC3F,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,uGAAuG;AAC1F,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces-logs/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces-logs/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.\n *\n * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
1
+ {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,sFAAsF;AACtF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.\n *\n * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
@@ -25,7 +25,7 @@ exports.VERDICT_YELLOW = 'yellow';
25
25
  exports.VERDICT_ORANGE = 'orange';
26
26
  exports.VERDICT_RED = 'red';
27
27
  exports.VERDICT_STATUSES = [exports.VERDICT_GREEN, exports.VERDICT_YELLOW, exports.VERDICT_ORANGE, exports.VERDICT_RED];
28
- // The verdict a reviewer SUBAGENT submits into `.webpieces-logs/pr-review/<featureSlug>/review-round<N>-<id>.json`,
28
+ // The verdict a reviewer SUBAGENT submits into `.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json`,
29
29
  // one per briefed checklist per round. One file per checklist per ROUND, so N concurrent reviewer subagents
30
30
  // never clobber a shared file and no round's verdict is ever overwritten by a later one (issue #1053): the
31
31
  // gate reads the HIGHEST round per checklist, and the earlier rounds stay on disk as the audit trail. It
@@ -198,7 +198,7 @@ class ChecklistVerdict {
198
198
  }
199
199
  }
200
200
  exports.ChecklistVerdict = ChecklistVerdict;
201
- // The PR's diff context, written by wp-start-upsert-pr into `.webpieces-logs/pr-review/<featureSlug>/pr-context.json`
201
+ // The PR's diff context, written by wp-start-upsert-pr into `.webpieces/pr-review/<featureSlug>/pr-context.json`
202
202
  // so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then
203
203
  // reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match
204
204
  // coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.