@webpieces/rules-config 0.4.910 → 0.4.911
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.
- package/package.json +7 -6
- package/src/aged-tree-sweep.d.ts +2 -2
- package/src/aged-tree-sweep.js +2 -2
- package/src/aged-tree-sweep.js.map +1 -1
- package/src/build-log-doc.d.ts +1 -1
- package/src/build-log-doc.js +3 -3
- package/src/build-log-doc.js.map +1 -1
- package/src/builds-log.d.ts +2 -2
- package/src/builds-log.js +2 -2
- package/src/builds-log.js.map +1 -1
- package/src/checklist-override.d.ts +1 -1
- package/src/checklist-override.js +1 -1
- package/src/checklist-override.js.map +1 -1
- package/src/config-error-banner.js +1 -1
- package/src/config-error-banner.js.map +1 -1
- package/src/config-repair-bootstrap-source.d.ts +1 -1
- package/src/config-repair-bootstrap-source.js +1 -1
- package/src/config-repair-bootstrap-source.js.map +1 -1
- package/src/config-repair-probe.js +3 -3
- package/src/config-repair-probe.js.map +1 -1
- package/src/constants.js +3 -3
- package/src/constants.js.map +1 -1
- package/src/exclude-hook-paths.d.ts +5 -5
- package/src/exclude-hook-paths.js +5 -5
- package/src/exclude-hook-paths.js.map +1 -1
- package/src/exclude-paths.d.ts +1 -1
- package/src/exclude-paths.js +1 -1
- package/src/exclude-paths.js.map +1 -1
- package/src/hook-fault-codes.js.map +1 -1
- package/src/index.js +5 -5
- package/src/index.js.map +1 -1
- package/src/instruct-ai-docs.d.ts +3 -3
- package/src/instruct-ai-docs.js +3 -3
- package/src/instruct-ai-docs.js.map +1 -1
- package/src/legacy-config-upgrade.js +2 -2
- package/src/legacy-config-upgrade.js.map +1 -1
- package/src/load-config.js +3 -0
- package/src/load-config.js.map +1 -1
- package/src/load-template.d.ts +1 -1
- package/src/load-template.js +2 -2
- package/src/load-template.js.map +1 -1
- package/src/merge-process-doc.d.ts +1 -1
- package/src/merge-process-doc.js +2 -2
- package/src/merge-process-doc.js.map +1 -1
- package/src/migrate-dirs-cli.d.ts +4 -0
- package/src/migrate-dirs-cli.js +32 -0
- package/src/migrate-dirs-cli.js.map +1 -0
- package/src/orphan-dir-archive.d.ts +4 -4
- package/src/orphan-dir-archive.js +4 -4
- package/src/orphan-dir-archive.js.map +1 -1
- package/src/orphan-dir-scan.d.ts +1 -1
- package/src/orphan-dir-scan.js +1 -1
- package/src/orphan-dir-scan.js.map +1 -1
- package/src/orphan-dir-sweep.js +1 -1
- package/src/orphan-dir-sweep.js.map +1 -1
- package/src/pack-policy-files.js +4 -3
- package/src/pack-policy-files.js.map +1 -1
- package/src/policy-tracking.d.ts +7 -0
- package/src/policy-tracking.js +68 -0
- package/src/policy-tracking.js.map +1 -0
- package/src/pr-gate-config.d.ts +1 -1
- package/src/pr-gate-config.js +1 -1
- package/src/pr-gate-config.js.map +1 -1
- package/src/repo-root.d.ts +7 -7
- package/src/repo-root.js +8 -8
- package/src/repo-root.js.map +1 -1
- package/src/repo-scratch-dirs.d.ts +3 -3
- package/src/repo-scratch-dirs.js +5 -5
- package/src/repo-scratch-dirs.js.map +1 -1
- package/src/review-json-data.js +2 -2
- package/src/review-json-data.js.map +1 -1
- package/src/review-json.js +1 -1
- package/src/review-json.js.map +1 -1
- package/src/reviewer-instructions.d.ts +1 -1
- package/src/reviewer-instructions.js +1 -1
- package/src/reviewer-instructions.js.map +1 -1
- package/src/rule-pack-artifacts.d.ts +2 -2
- package/src/rule-pack-artifacts.js +2 -2
- package/src/rule-pack-artifacts.js.map +1 -1
- package/src/rule-pack-sync.js +5 -4
- package/src/rule-pack-sync.js.map +1 -1
- package/src/stale-bin-sweep.js +1 -1
- package/src/stale-bin-sweep.js.map +1 -1
- package/src/subagent-provenance.d.ts +6 -6
- package/src/subagent-provenance.js +6 -6
- package/src/subagent-provenance.js.map +1 -1
- package/src/sync-flow-guidance.js +1 -1
- package/src/sync-flow-guidance.js.map +1 -1
- package/templates/webpieces.branch-state-matrix.md +2 -2
- package/templates/webpieces.buildlog.md +3 -3
- package/templates/webpieces.ci-gate-setup.md +2 -2
- package/templates/webpieces.git-workflow.md +9 -9
- package/templates/webpieces.guard-matrix.md +6 -5
- package/templates/webpieces.location-matrix.md +9 -9
- package/templates/webpieces.review-checklists.md +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instruct-ai-docs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/instruct-ai-docs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,sEAAkE;AAClE,2DAA6F;AAE7F,8EAA8E;AAC9E,+DAA+D;AAC/D,EAAE;AACF,uGAAuG;AACvG,kGAAkG;AAClG,0EAA0E;AAC1E,uGAAuG;AACvG,wBAAwB;AACxB,EAAE;AACF,uGAAuG;AACvG,sGAAsG;AACtG,qGAAqG;AACrG,iEAAiE;AACjE,EAAE;AACF,uCAAuC;AACvC,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,qGAAqG;AACrG,gEAAgE;AAChE,uGAAuG;AACvG,yFAAyF;AACzF,8EAA8E;AAE9E,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAE9D,wGAAwG;AACxG,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAExD;;;;;GAKG;AACH,MAAa,aAAa;IACD;IAArB,YAAqB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAErC;;;;;;;;OAQG;IACH,MAAM,CAAC,YAAoB,EAAE,IAAY;QACrC,KAAK,IAAI,CAAC;QACV,OAAO,YAAY,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACJ,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA1BD,sCA0BC;AAED;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,aAAa;IAC9C;QACI,KAAK,CAAC,qCAAiB,CAAC,CAAC;IAC7B,CAAC;IAEQ,MAAM,CAAC,YAAoB,EAAE,IAA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vD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7B,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QACrD,MAAM,GAAG,GAAoB,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAChC,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;oBAAE,SAAS;gBAClD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACpB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAxED,4CAwEC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { BranchMutationLog } from '@webpieces/repo-workflow-core';\nimport { MERGE_PROCESS_DOC, MergeProcessText, ReferenceMergeRun } from './merge-process-doc';\n\n// ---------------------------------------------------------------------------\n// THE INSTRUCT-AI DOCS ARE WRITTEN AS A SET, NEVER ONE BY ONE.\n//\n// The bug this fixes: `webpieces.git-workflow.md` links to `webpieces.mergeprocess.md`, and six of the\n// nine governed repos had the first file and not the second — the link pointed at nothing. Nobody\n// forgot on purpose. Each `wp-*` command named the ONE doc it cared about\n// (`writeTemplate(root, 'webpieces.git-workflow.md')`), and a doc that only some other code path wrote\n// simply never arrived.\n//\n// Adding `webpieces.mergeprocess.md` to those six call sites would fix that one link and nothing else:\n// the NEXT doc to gain a sibling link would go missing the same way. So the fix is structural — a doc\n// is never written alone. Writing one writes the TRANSITIVE CLOSURE of the instruct-ai docs it links\n// to, so a doc and everything it points at always land together.\n//\n// TWO CONSEQUENCES WORTH SPELLING OUT:\n//\n// • THE SET IS THE TEMPLATES DIRECTORY. Membership is `readdirSync(templates/)`, not a hand-kept\n// array — dropping `webpieces.<something>.md` into that directory enrols it, and there is no\n// second place to remember. That is the same reason L1/L2 render their tables from the array the\n// guard dispatches on rather than from a description of it.\n// • `instruct-ai-docs.spec.ts` FAILS THE BUILD if any template references a `webpieces.*.md` sibling\n// that is not a member. Without that test this is one instance fixed, not the class.\n// ---------------------------------------------------------------------------\n\nconst TEMPLATES_DIR = path.join(__dirname, '..', 'templates');\n\n/** Every `webpieces.*.md` name mentioned anywhere in a doc's body — links, prose, code fences alike. */\nconst DOC_REFERENCE = /webpieces\\.[A-Za-z0-9._-]*\\.md/g;\n\n/**\n * One deliverable instruct-ai doc.\n *\n * The default is a byte-for-byte copy of its template, rewritten whenever the bytes change. A doc that\n * needs rendering, or that must not clobber live run state, overrides one of the two methods below.\n */\nexport class InstructAiDoc {\n constructor(readonly name: string) {}\n\n /**\n * The bytes to deliver, given the template's own bytes and the ROOT of the tree they are being\n * written into.\n *\n * `root` is not decoration: every webpieces state path is per-tree (a linked worktree's state lives\n * under `<primary>/.webpieces/worktrees/<name>/`), so a doc that names one must RESOLVE it for the\n * tree the reader is standing in. A template that restated a relative path instead shipped a path\n * that does not exist in a worktree — see `GitWorkflowDoc`.\n */\n render(templateText: string, root: string): string {\n void root;\n return templateText;\n }\n\n /**\n * True when an EXISTING copy must be left alone.\n *\n * Only docs a `wp-*` command stamps with live run state say yes: overwriting one mid-run would\n * replace the handback an agent is reading with a generic reference copy.\n */\n seedOnly(): boolean {\n return false;\n }\n}\n\n/**\n * `webpieces.mergeprocess.md` — delivered as the reference rendering, never over a live handback.\n *\n * See merge-process-doc.ts for why one template with two inputs is the whole point.\n */\nexport class MergeProcessDoc extends InstructAiDoc {\n constructor() {\n super(MERGE_PROCESS_DOC);\n }\n\n override render(templateText: string, root: string): string {\n void root;\n return new MergeProcessText(templateText).render(new ReferenceMergeRun());\n }\n\n override seedOnly(): boolean {\n return true;\n }\n}\n\n/** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */\nexport const GIT_WORKFLOW_DOC = 'webpieces.git-workflow.md';\n\n/**\n * `webpieces.git-workflow.md` — the one doc that names the branch-mutation log by path.\n *\n * It used to restate `.webpieces/logs/branch-mutations.log` as a literal. That log is deliberately\n * PER-WORKTREE (one appender each), so in a linked worktree the literal names a file that does not\n * exist: the reader greps nothing, and the silence reads as \"no deletions were logged\" — the exact\n * opposite of the truth, from the one file whose job is to prove every deletion is recoverable.\n *\n * So the template carries `{{BRANCH_MUTATION_LOG}}` and this class fills it from the SAME resolver the\n * writer uses, for the tree the doc is being written into. There is one answer to \"where is that log\",\n * and it is `BranchMutationLog.branchMutationLogPath`.\n */\nexport class GitWorkflowDoc extends InstructAiDoc {\n constructor(private readonly mutationLog: BranchMutationLog = new BranchMutationLog()) {\n super(GIT_WORKFLOW_DOC);\n }\n\n override render(templateText: string, root: string): string {\n return templateText.replace(/\\{\\{BRANCH_MUTATION_LOG\\}\\}/g, this.mutationLog.branchMutationLogPath(root));\n }\n}\n\n/**\n * The set of instruct-ai docs, and the link graph over them.\n *\n * Constructed from the templates directory, so the set cannot disagree with what ships.\n */\nexport class InstructAiDocSet {\n constructor(private readonly mutationLog: BranchMutationLog = new BranchMutationLog()) {}\n\n // Resolved on FIRST USE, never in the constructor. `TemplateWriter` is constructed at module load\n // (its migration delegators), and a spec that mocks `fs` for its own subject would otherwise blow up\n // on an unrelated package's import — which is exactly what happened to read-stale-guard.spec.ts.\n private byName: Map<string, InstructAiDoc> | null = null;\n\n /** Every `webpieces.*.md` template that ships with this package. */\n templateNames(): readonly string[] {\n return fs.readdirSync(TEMPLATES_DIR)\n .filter((name: string): boolean => name.startsWith('webpieces.') && name.endsWith('.md'))\n .sort();\n }\n\n /** Every member, in name order. */\n all(): readonly InstructAiDoc[] {\n return [...this.members().values()];\n }\n\n /** The member called `name`, or null when `name` is not an instruct-ai doc at all. */\n get(name: string): InstructAiDoc | null {\n return this.members().get(name) ?? null;\n }\n\n /** Every `webpieces.*.md` name `text` mentions, member or not, de-duplicated in first-seen order. */\n referencesIn(text: string): readonly string[] {\n return [...new Set(text.match(DOC_REFERENCE) ?? [])];\n }\n\n /** The references in `text` that are NOT members — what the link-integrity test refuses. */\n danglingIn(text: string): readonly string[] {\n const members = this.members();\n return this.referencesIn(text).filter((name: string): boolean => !members.has(name));\n }\n\n // The set, built once from the templates directory. The overrides are the docs that need rendering\n // or that must not clobber live run state; everything else is a plain copy of its template.\n private members(): Map<string, InstructAiDoc> {\n if (this.byName !== null) return this.byName;\n const overrides = new Map<string, InstructAiDoc>();\n overrides.set(MERGE_PROCESS_DOC, new MergeProcessDoc());\n overrides.set(GIT_WORKFLOW_DOC, new GitWorkflowDoc(this.mutationLog));\n const built = new Map<string, InstructAiDoc>();\n for (const name of this.templateNames()) {\n built.set(name, overrides.get(name) ?? new InstructAiDoc(name));\n }\n this.byName = built;\n return built;\n }\n\n /**\n * `name` plus every member reachable from it by links, breadth-first from `name`.\n *\n * A non-member is returned alone: a caller writing something that is not an instruct-ai doc (the\n * CI workflow yml) still gets exactly what it asked for.\n */\n closure(name: string, loadText: (docName: string) => string): readonly InstructAiDoc[] {\n const first = this.get(name);\n if (first === null) return [new InstructAiDoc(name)];\n const out: InstructAiDoc[] = [first];\n const seen = new Set<string>([name]);\n for (let i = 0; i < out.length; i++) {\n for (const reference of this.referencesIn(loadText(out[i].name))) {\n const doc = this.get(reference);\n if (doc === null || seen.has(reference)) continue;\n seen.add(reference);\n out.push(doc);\n }\n }\n return out;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"instruct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oB,CAAC,KAAK,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAClC,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBAChC,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;oBAAE,SAAS;gBAClD,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;gBACpB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC;QACL,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAxED,4CAwEC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { BranchMutationLog } from '@webpieces/repo-workflow-core';\nimport { MERGE_PROCESS_DOC, MergeProcessText, ReferenceMergeRun } from './merge-process-doc';\n\n// ---------------------------------------------------------------------------\n// THE INSTRUCT-AI DOCS ARE WRITTEN AS A SET, NEVER ONE BY ONE.\n//\n// The bug this fixes: `webpieces.git-workflow.md` links to `webpieces.mergeprocess.md`, and six of the\n// nine governed repos had the first file and not the second — the link pointed at nothing. Nobody\n// forgot on purpose. Each `wp-*` command named the ONE doc it cared about\n// (`writeTemplate(root, 'webpieces.git-workflow.md')`), and a doc that only some other code path wrote\n// simply never arrived.\n//\n// Adding `webpieces.mergeprocess.md` to those six call sites would fix that one link and nothing else:\n// the NEXT doc to gain a sibling link would go missing the same way. So the fix is structural — a doc\n// is never written alone. Writing one writes the TRANSITIVE CLOSURE of the instruct-ai docs it links\n// to, so a doc and everything it points at always land together.\n//\n// TWO CONSEQUENCES WORTH SPELLING OUT:\n//\n// • THE SET IS THE TEMPLATES DIRECTORY. Membership is `readdirSync(templates/)`, not a hand-kept\n// array — dropping `webpieces.<something>.md` into that directory enrols it, and there is no\n// second place to remember. That is the same reason L1/L2 render their tables from the array the\n// guard dispatches on rather than from a description of it.\n// • `instruct-ai-docs.spec.ts` FAILS THE BUILD if any template references a `webpieces.*.md` sibling\n// that is not a member. Without that test this is one instance fixed, not the class.\n// ---------------------------------------------------------------------------\n\nconst TEMPLATES_DIR = path.join(__dirname, '..', 'templates');\n\n/** Every `webpieces.*.md` name mentioned anywhere in a doc's body — links, prose, code fences alike. */\nconst DOC_REFERENCE = /webpieces\\.[A-Za-z0-9._-]*\\.md/g;\n\n/**\n * One deliverable instruct-ai doc.\n *\n * The default is a byte-for-byte copy of its template, rewritten whenever the bytes change. A doc that\n * needs rendering, or that must not clobber live run state, overrides one of the two methods below.\n */\nexport class InstructAiDoc {\n constructor(readonly name: string) {}\n\n /**\n * The bytes to deliver, given the template's own bytes and the ROOT of the tree they are being\n * written into.\n *\n * `root` is not decoration: every webpieces state path is per-tree (a linked worktree's state lives\n * under `<primary>/.webpieces-logs/worktrees/<name>/`), so a doc that names one must RESOLVE it for the\n * tree the reader is standing in. A template that restated a relative path instead shipped a path\n * that does not exist in a worktree — see `GitWorkflowDoc`.\n */\n render(templateText: string, root: string): string {\n void root;\n return templateText;\n }\n\n /**\n * True when an EXISTING copy must be left alone.\n *\n * Only docs a `wp-*` command stamps with live run state say yes: overwriting one mid-run would\n * replace the handback an agent is reading with a generic reference copy.\n */\n seedOnly(): boolean {\n return false;\n }\n}\n\n/**\n * `webpieces.mergeprocess.md` — delivered as the reference rendering, never over a live handback.\n *\n * See merge-process-doc.ts for why one template with two inputs is the whole point.\n */\nexport class MergeProcessDoc extends InstructAiDoc {\n constructor() {\n super(MERGE_PROCESS_DOC);\n }\n\n override render(templateText: string, root: string): string {\n void root;\n return new MergeProcessText(templateText).render(new ReferenceMergeRun());\n }\n\n override seedOnly(): boolean {\n return true;\n }\n}\n\n/** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */\nexport const GIT_WORKFLOW_DOC = 'webpieces.git-workflow.md';\n\n/**\n * `webpieces.git-workflow.md` — the one doc that names the branch-mutation log by path.\n *\n * It used to restate `.webpieces-logs/logs/branch-mutations.log` as a literal. That log is deliberately\n * PER-WORKTREE (one appender each), so in a linked worktree the literal names a file that does not\n * exist: the reader greps nothing, and the silence reads as \"no deletions were logged\" — the exact\n * opposite of the truth, from the one file whose job is to prove every deletion is recoverable.\n *\n * So the template carries `{{BRANCH_MUTATION_LOG}}` and this class fills it from the SAME resolver the\n * writer uses, for the tree the doc is being written into. There is one answer to \"where is that log\",\n * and it is `BranchMutationLog.branchMutationLogPath`.\n */\nexport class GitWorkflowDoc extends InstructAiDoc {\n constructor(private readonly mutationLog: BranchMutationLog = new BranchMutationLog()) {\n super(GIT_WORKFLOW_DOC);\n }\n\n override render(templateText: string, root: string): string {\n return templateText.replace(/\\{\\{BRANCH_MUTATION_LOG\\}\\}/g, this.mutationLog.branchMutationLogPath(root));\n }\n}\n\n/**\n * The set of instruct-ai docs, and the link graph over them.\n *\n * Constructed from the templates directory, so the set cannot disagree with what ships.\n */\nexport class InstructAiDocSet {\n constructor(private readonly mutationLog: BranchMutationLog = new BranchMutationLog()) {}\n\n // Resolved on FIRST USE, never in the constructor. `TemplateWriter` is constructed at module load\n // (its migration delegators), and a spec that mocks `fs` for its own subject would otherwise blow up\n // on an unrelated package's import — which is exactly what happened to read-stale-guard.spec.ts.\n private byName: Map<string, InstructAiDoc> | null = null;\n\n /** Every `webpieces.*.md` template that ships with this package. */\n templateNames(): readonly string[] {\n return fs.readdirSync(TEMPLATES_DIR)\n .filter((name: string): boolean => name.startsWith('webpieces.') && name.endsWith('.md'))\n .sort();\n }\n\n /** Every member, in name order. */\n all(): readonly InstructAiDoc[] {\n return [...this.members().values()];\n }\n\n /** The member called `name`, or null when `name` is not an instruct-ai doc at all. */\n get(name: string): InstructAiDoc | null {\n return this.members().get(name) ?? null;\n }\n\n /** Every `webpieces.*.md` name `text` mentions, member or not, de-duplicated in first-seen order. */\n referencesIn(text: string): readonly string[] {\n return [...new Set(text.match(DOC_REFERENCE) ?? [])];\n }\n\n /** The references in `text` that are NOT members — what the link-integrity test refuses. */\n danglingIn(text: string): readonly string[] {\n const members = this.members();\n return this.referencesIn(text).filter((name: string): boolean => !members.has(name));\n }\n\n // The set, built once from the templates directory. The overrides are the docs that need rendering\n // or that must not clobber live run state; everything else is a plain copy of its template.\n private members(): Map<string, InstructAiDoc> {\n if (this.byName !== null) return this.byName;\n const overrides = new Map<string, InstructAiDoc>();\n overrides.set(MERGE_PROCESS_DOC, new MergeProcessDoc());\n overrides.set(GIT_WORKFLOW_DOC, new GitWorkflowDoc(this.mutationLog));\n const built = new Map<string, InstructAiDoc>();\n for (const name of this.templateNames()) {\n built.set(name, overrides.get(name) ?? new InstructAiDoc(name));\n }\n this.byName = built;\n return built;\n }\n\n /**\n * `name` plus every member reachable from it by links, breadth-first from `name`.\n *\n * A non-member is returned alone: a caller writing something that is not an instruct-ai doc (the\n * CI workflow yml) still gets exactly what it asked for.\n */\n closure(name: string, loadText: (docName: string) => string): readonly InstructAiDoc[] {\n const first = this.get(name);\n if (first === null) return [new InstructAiDoc(name)];\n const out: InstructAiDoc[] = [first];\n const seen = new Set<string>([name]);\n for (let i = 0; i < out.length; i++) {\n for (const reference of this.referencesIn(loadText(out[i].name))) {\n const doc = this.get(reference);\n if (doc === null || seen.has(reference)) continue;\n seen.add(reference);\n out.push(doc);\n }\n }\n return out;\n }\n}\n"]}
|
|
@@ -60,9 +60,9 @@ function seedRule(ruleName, registry) {
|
|
|
60
60
|
// Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty
|
|
61
61
|
// (enforce everywhere) — a client adds paths (e.g. "repositories/**") to exempt vendored trees.
|
|
62
62
|
//
|
|
63
|
-
// Deliberately NOT seeded with webpieces' own `.webpieces/` state dir. That exemption lives in CODE
|
|
63
|
+
// Deliberately NOT seeded with webpieces' own `.webpieces-logs/` state dir. That exemption lives in CODE
|
|
64
64
|
// (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),
|
|
65
|
-
// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces/**` compiles to
|
|
65
|
+
// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces-logs/**` compiles to
|
|
66
66
|
// an anchored regex that misses the bare directory the predicate matches, and because a config entry
|
|
67
67
|
// invites a consumer to delete it and believe the exemption went with it.
|
|
68
68
|
// Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-config-upgrade.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/legacy-config-upgrade.ts"],"names":[],"mappings":";;;AA+QA,oDAiEC;AA9UD,uDAAmE;AACnE,iDAAkD;AAClD,yCAAyD;AACzD,6DAA2D;AAC3D,qDAAyD;AACzD,+DAA2D;AAE3D,oFAAoF;AACpF,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAS1D,MAAa,oBAAoB;IAKhB;IACA;IACA;IACA;IAEA;IATJ,aAAa,CAAS;IACtB,OAAO,CAAqB;IACrC,yDAAyD;IACzD,YACa,KAAc,EACd,UAAmB,EACnB,QAAc,EACd,YAAsB,EAC/B,OAAe,EACN,QAAkB,EAC3B,aAAiC;QANxB,UAAK,GAAL,KAAK,CAAS;QACd,eAAU,GAAV,UAAU,CAAS;QACnB,aAAQ,GAAR,QAAQ,CAAM;QACd,iBAAY,GAAZ,YAAY,CAAU;QAEtB,aAAQ,GAAR,QAAQ,CAAU;QAG3B,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC;IACjC,CAAC;CACJ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GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,2BAA2B,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,QAAc,EAAE,OAAiB;IACxD,mGAAmG;IACnG,2EAA2E;IAC3E,IAAI,UAAkB,CAAC;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QACzC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAW,CAAC;IACnD,CAAC;SAAM,CAAC;QACJ,UAAU,GAAG,cAAc,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/** Previous-root conversion is reachable only through an explicit upgrade command; normal loading never calls it. */\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames, seedEntryForRule } from './validate-config';\nimport { schemaFieldNames } from './rule-schemas';\nimport { sectionForRule, isHookGuard } from './sections';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { DEFAULT_BUILD_COMMAND } from './pr-gate-config';\nimport { RETIRED_SCOPE_RULE } from './retired-config-keys';\n\n// Explicit upgrade applies owner-declared retirements and writes reviewed settings.\nconst DEFAULT_UPSERT_PR = 'pnpm wp-start-upsert-pr';\nconst DEFAULT_MERGE_COMPLETE = 'pnpm wp-finish-upsert-pr';\n// ---------------------------------------------------------------------------\n// webpieces.config.json seeding + migration to the rules / hookGuards / commands layout.\n// ---------------------------------------------------------------------------\n// webpieces-disable no-any-unknown -- webpieces.config.json / settings.json are opaque consumer JSON\ntype Json = Record<string, unknown>;\ntype RuleEntry = Json;\ntype Section = Record<string, RuleEntry>;\n\nexport class LegacyConfigDocument {\n readonly 'match-rules': Json[];\n readonly extends: string | undefined;\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly rules: Section,\n readonly hookGuards: Section,\n readonly commands: Json,\n readonly excludePaths: string[],\n matches: Json[],\n readonly rulesDir: string[],\n inheritedFrom: string | undefined,\n ) {\n this['match-rules'] = matches;\n this.extends = inheritedFrom;\n }\n}\n\nexport class LegacyUpgradeResult {\n constructor(\n readonly config: LegacyConfigDocument,\n readonly changes: string[],\n ) {}\n}\n\n// webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design\nfunction seedRule(ruleName: string, registry: RulePackRegistry): RuleEntry {\n // Both escape hatches are seeded (and REQUIRED) so every rule block shows them: 0 = active,\n // null = no branch scoping. A human/AI edits these to time-box or branch-scope a rule off.\n //\n // The ENTIRE entry comes from rules-config's seedEntryForRule() — the same module that owns the\n // schema the loader validates against, so the installer can never emit an entry the loader\n // rejects. It supplies: the recommended mode (the SAME recommendation the validator prints in its\n // copy-paste snippet, so seed and advice cannot disagree), both hatches, and a default for every\n // other schema-REQUIRED field. Seeding used to be a flat 'OFF' plus the two hatches, which was\n // wrong twice over: adopters got nothing enforced, AND the entry was missing required fields\n // (e.g. branch-creation-guard.autoReapMergedBranches), so the config failed to load on first run.\n return seedEntryForRule(ruleName, registry);\n}\n\n// The guard-hint command strings live under `guardHints`. The flat `upsertPr`/`mergeComplete` keys this\n// used to seed are RETIRED and now fail validation — seeding them meant every freshly installed repo was\n// born on a shape the validator rejects.\n\n// Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty\n// (enforce everywhere) — a client adds paths (e.g. \"repositories/**\") to exempt vendored trees.\n//\n// Deliberately NOT seeded with webpieces' own `.webpieces/` state dir. That exemption lives in CODE\n// (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),\n// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces/**` compiles to\n// an anchored regex that misses the bare directory the predicate matches, and because a config entry\n// invites a consumer to delete it and believe the exemption went with it.\n\n// Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.\n// Legacy `{ rules, guards }` → unioned (order preserved, duplicates dropped) and recorded as a change\n// so `pnpm wp-rules-sync --upgrade` is the migration path rather than a hand-edit. Anything else → seeded [].\n// webpieces-disable no-any-unknown -- opaque legacy JSON is narrowed before use\n// webpieces-disable no-function-outside-class -- pure legacy config conversion helper\nfunction migrateExcludePaths(raw: unknown, changes: string[]): string[] {\n if (Array.isArray(raw)) return (raw as string[]).filter((p: string) => typeof p === 'string');\n if (typeof raw === 'object' && raw !== null) {\n // webpieces-disable no-any-unknown -- narrowing the opaque legacy block from consumer JSON\n const legacy = raw as Record<string, unknown>;\n const rules = Array.isArray(legacy['rules']) ? (legacy['rules'] as string[]) : [];\n const guards = Array.isArray(legacy['guards']) ? (legacy['guards'] as string[]) : [];\n const merged = [\n ...new Set([...rules, ...guards].filter((p: string) => typeof p === 'string')),\n ];\n changes.push(`migrated excludePaths {rules,guards} -> one list (${merged.length} path(s))`);\n return merged;\n }\n changes.push('added excludePaths ([])');\n return [];\n}\n\n/** One retired flat command string and the guardHints field it becomes. Data-only (per CLAUDE.md). */\nclass GuardHintMove {\n retiredKey: string;\n hintKey: string;\n fallback: string;\n\n constructor(retiredKey: string, hintKey: string, fallback: string) {\n this.retiredKey = retiredKey;\n this.hintKey = hintKey;\n this.fallback = fallback;\n }\n}\n\n/**\n * Bring `commands` forward to the `guardHints` shape, moving the RETIRED flat `upsertPr`/`mergeComplete`\n * strings and DELETING them. Deleting is the point: the validator now rejects them, so leaving them behind\n * would keep the config failing after a \"successful\" sync.\n *\n * The consumer's own value wins over the default — a repo that renamed its gated command keeps that name.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateGuardHints(commands: Json, changes: string[]): void {\n const hints: Json =\n typeof commands['guardHints'] === 'object' && commands['guardHints'] !== null\n ? (commands['guardHints'] as Json)\n : {};\n const moves: readonly GuardHintMove[] = [\n new GuardHintMove('upsertPr', 'prCreationOrPush', DEFAULT_UPSERT_PR),\n new GuardHintMove('mergeComplete', 'mergeInProgress', DEFAULT_MERGE_COMPLETE),\n ];\n for (const move of moves) {\n const retiredKey = move.retiredKey;\n const hintKey = move.hintKey;\n const fallback = move.fallback;\n const carried = commands[retiredKey];\n if (carried !== undefined) {\n delete commands[retiredKey];\n if (hints[hintKey] === undefined) hints[hintKey] = carried;\n changes.push(`moved retired commands.${retiredKey} -> commands.guardHints.${hintKey}`);\n }\n if (hints[hintKey] === undefined) {\n hints[hintKey] = fallback;\n changes.push(`added commands.guardHints.${hintKey}`);\n }\n }\n commands['guardHints'] = hints;\n}\n\n/**\n * Apply the RETIRED rule/guard retirements in place. These used to be rewritten silently at load time, so\n * a consumer's file kept the dead name forever; the loader now rejects it, which makes this the one\n * command that can fix the file. Skips a rename when the new name is already configured, so an explicit\n * entry is never clobbered by a stale one.\n *\n * NOT EVERY RETIREMENT IS A RENAME, and treating them all as one produced garbage. `whole-repo-build-guard`\n * moved OUT of webpieces.config.json entirely — its `movedTo` is the PROSE destination\n * `~/.webpieces/config.json → experimental.whole-repo-build-guard`, not a sibling key — so the rename\n * branch below would have created a hookGuards entry literally named that whole sentence, which no\n * validator knows and which the next run reports as another unknown rule. `prunable` is the discriminator:\n * when the entry says deleting is the whole fix, DELETE it, exactly as `ConfigPruner` does.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateRetiredRuleNames(\n section: Section,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n for (const entry of registry.migrations()) {\n if (entry.scope !== RETIRED_SCOPE_RULE) continue;\n if (!(entry.key in section)) continue;\n if (entry.prunable) {\n delete section[entry.key];\n changes.push(`deleted retired \"${entry.key}\" (it moved to ${entry.movedTo})`);\n continue;\n }\n mergeIntoDestination(section, entry.key, entry.movedTo, changes, registry);\n }\n fillRequiredFields(section, changes, registry);\n}\n\n/**\n * Fold one retired key's entry into its destination, whether the destination exists yet or not.\n *\n * THIS IS N→1, NOT 1:1, and the difference is the whole reason this helper exists. Four retired keys\n * now point at ONE destination (`branch-state-guard`, `pr-lifecycle-guard`). The previous code renamed\n * the first key it met and then, finding the destination already present, DELETED each of the other\n * three outright — so which guard's settings survived depended on RETIRED_CONFIG_KEYS declaration\n * order rather than on the consumer's file, and the survivor carried only that one guard's fields, so\n * it was missing required fields of the merged schema. `pnpm wp-rules-sync --upgrade` is the command advertised\n * as the migration path; half-migrating every consumer into an invalid config is not an option.\n *\n * UNION, first writer wins per field. Earlier-declared keys are the more specific ones (only\n * feature-branch-guard carries `branchNamingConvention`), and a field already present on the\n * destination — because the consumer wrote it, or an earlier key contributed it — is never overwritten.\n * Fields the merged schema does not know are dropped by the same pass, since carrying a deleted field\n * across (`upsertPrCommand`) would produce a config the validator immediately rejects.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction mergeIntoDestination(\n section: Section,\n key: string,\n destination: string,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n const source = asSection(section[key]);\n delete section[key];\n const fields = schemaFieldNames(destination, registry);\n const target = asSection(section[destination]);\n const existed = destination in section;\n const carried: string[] = [];\n const dropped: string[] = [];\n for (const field of Object.keys(source)) {\n if (fields !== null && !fields.includes(field)) {\n dropped.push(field);\n continue;\n }\n if (field in target) continue;\n target[field] = source[field];\n carried.push(field);\n }\n section[destination] = target;\n const verb = existed ? 'merged' : 'renamed';\n const droppedNote =\n dropped.length > 0 ? `; dropped deleted field(s) ${dropped.join(', ')}` : '';\n changes.push(\n `${verb} retired \"${key}\" -> \"${destination}\" (carried ${carried.join(', ') || 'nothing new'}${droppedNote})`,\n );\n}\n\n/**\n * Fill any schema-REQUIRED field a migrated entry ended up without.\n *\n * A union of four partial entries is not guaranteed to satisfy the destination's schema — the merged\n * `branch-state-guard` needs `mode` and both escape hatches, and a consumer whose four old entries\n * predate one of them would land short. Seeding the gap from the SAME source the installer and the\n * validator use (seedEntryForRule) is what makes the install command a complete instruction\n * rather than a first step. Only ever ADDS; a value the consumer stated is never touched.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction fillRequiredFields(section: Section, changes: string[], registry: RulePackRegistry): void {\n for (const name of Object.keys(section)) {\n if (schemaFieldNames(name, registry) === null) continue;\n // A rule ENTRY is a flat bag of scalars, so it is read as Json here rather than through\n // asSection (whose values are whole entries). Same object either way; only the view differs.\n const entry: Json = asSection(section[name]);\n const seed = seedEntryForRule(name, registry);\n const added: string[] = [];\n for (const field of Object.keys(seed)) {\n if (field in entry) continue;\n entry[field] = seed[field];\n added.push(field);\n }\n if (added.length === 0) continue;\n section[name] = entry;\n changes.push(`filled required field(s) on \"${name}\": ${added.join(', ')}`);\n }\n}\n\n// Deep-copy the framework's default match-rules (the no-fetch guard) into plain JSON for the config\n// file. Round-tripping through JSON turns the MatchRuleConfig instances into plain objects.\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction seedMatchRules(): Json[] {\n return JSON.parse(JSON.stringify(DEFAULT_MATCH_RULES)) as Json[];\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction asSection(value: Json[string]): Section {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Section)\n : {};\n}\n\n// Migrate an existing config to the rules / hookGuards / commands layout and add any missing rules.\n// Returns a human-readable list of what changed (empty = already up to date).\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nexport function prepareLegacyUpgrade(\n existing: Json,\n registry: RulePackRegistry,\n): LegacyUpgradeResult {\n const changes: string[] = [];\n const rules: Section = asSection(existing['rules']);\n const hookGuards: Section = asSection(existing['hookGuards']);\n const commands: Json =\n typeof existing['commands'] === 'object' && existing['commands'] !== null\n ? (existing['commands'] as Json)\n : {};\n\n // Move a deprecated top-level pr-gate block under commands.\n if (existing['pr-gate'] !== undefined && commands['pr-gate'] === undefined) {\n commands['pr-gate'] = existing['pr-gate'];\n changes.push('moved top-level \"pr-gate\" → commands[\"pr-gate\"]');\n }\n // Apply retired RENAMES first, so a renamed guard is placed and presence-checked under its new name\n // rather than being treated as unknown and re-added alongside its own stale entry.\n migrateRetiredRuleNames(rules, changes, registry);\n migrateRetiredRuleNames(hookGuards, changes, registry);\n\n migratePolicySections(rules, hookGuards, changes, registry);\n // Add any missing built-in into its correct section, ENFORCING at its recommended mode (not OFF).\n for (const name of allRuleNames(registry)) {\n const target = sectionForRule(name, registry) === 'hookGuards' ? hookGuards : rules;\n if (!(name in target)) {\n const entry = seedRule(name, registry);\n target[name] = entry;\n changes.push(\n `added \"${name}\" (${String(entry['mode'])}) to ${sectionForRule(name, registry)}`,\n );\n }\n }\n // Fill command defaults.\n if (commands['pr-gate'] === undefined) {\n commands['pr-gate'] = { mode: 'OFF', buildCommand: DEFAULT_BUILD_COMMAND, gates: [] };\n changes.push('added commands[\"pr-gate\"] (OFF)');\n }\n migrateGuardHints(commands, changes);\n\n // Seed the now-required excludePaths list (empty = enforce everywhere) if the config predates it,\n // and MIGRATE the legacy `{ rules: [], guards: [] }` object to the single list by unioning them.\n // The union is behaviour-preserving for every config we have seen (both lists set identically), and\n // widening is the safe direction anyway: a path either side excluded stays excluded.\n const excludePaths: string[] = migrateExcludePaths(existing['excludePaths'], changes);\n\n const matchRules = upgradeMatchRules(existing, changes);\n\n const rulesDir: string[] = Array.isArray(existing['rulesDir'])\n ? (existing['rulesDir'] as string[])\n : [];\n const inherited = typeof existing['extends'] === 'string' ? existing['extends'] : undefined;\n return new LegacyUpgradeResult(\n new LegacyConfigDocument(\n rules,\n hookGuards,\n commands,\n excludePaths,\n matchRules,\n rulesDir,\n inherited,\n ),\n changes,\n );\n}\n\n// webpieces-disable no-function-outside-class -- explicit upgrade conversion remains independent of DI\nfunction migratePolicySections(rules: Section, hookGuards: Section, changes: string[], registry: RulePackRegistry): void {\n // Move guards mistakenly left in rules into hookGuards.\n for (const name of Object.keys(rules)) {\n if (isHookGuard(name, registry)) {\n hookGuards[name] = rules[name];\n delete rules[name];\n changes.push(`moved \"${name}\" from rules → hookGuards`);\n }\n }\n // Move code rules mistakenly placed in hookGuards back into rules.\n for (const name of Object.keys(hookGuards)) {\n if (!isHookGuard(name, registry) && allRuleNames(registry).includes(name)) {\n rules[name] = hookGuards[name];\n delete hookGuards[name];\n changes.push(`moved \"${name}\" from hookGuards → rules`);\n }\n }\n}\n\n// webpieces-disable no-function-outside-class -- pure explicit-upgrade conversion\nfunction upgradeMatchRules(existing: Json, changes: string[]): Json[] {\n // Seed the now-required match-rules array (with the default no-fetch guard) if the config predates\n // it. A client that has already customized it keeps their array untouched.\n let matchRules: Json[];\n if (Array.isArray(existing['match-rules'])) {\n matchRules = existing['match-rules'] as Json[];\n } else {\n matchRules = seedMatchRules();\n changes.push('added \"match-rules\" (seeded with the no-fetch guard)');\n }\n\n return matchRules;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"legacy-config-upgrade.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/legacy-config-upgrade.ts"],"names":[],"mappings":";;;AA+QA,oDAiEC;AA9UD,uDAAmE;AACnE,iDAAkD;AAClD,yCAAyD;AACzD,6DAA2D;AAC3D,qDAAyD;AACzD,+DAA2D;AAE3D,oFAAoF;AACpF,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAS1D,MAAa,oBAAoB;IAKhB;IACA;IACA;IACA;IAEA;IATJ,aAAa,CAAS;IACtB,OAAO,CAAqB;IACrC,yDAAyD;IACzD,YACa,KAAc,EACd,UAAmB,EACnB,QAAc,EACd,YAAsB,EA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,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;IACD,mEAAmE;IACnE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,IAAA,sBAAW,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAA,8BAAY,EAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACxE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,2BAA2B,CAAC,CAAC;QAC5D,CAAC;IACL,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,QAAc,EAAE,OAAiB;IACxD,mGAAmG;IACnG,2EAA2E;IAC3E,IAAI,UAAkB,CAAC;IACvB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC;QACzC,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAW,CAAC;IACnD,CAAC;SAAM,CAAC;QACJ,UAAU,GAAG,cAAc,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["/** Previous-root conversion is reachable only through an explicit upgrade command; normal loading never calls it. */\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { allRuleNames, seedEntryForRule } from './validate-config';\nimport { schemaFieldNames } from './rule-schemas';\nimport { sectionForRule, isHookGuard } from './sections';\nimport { DEFAULT_MATCH_RULES } from './match-rules-config';\nimport { DEFAULT_BUILD_COMMAND } from './pr-gate-config';\nimport { RETIRED_SCOPE_RULE } from './retired-config-keys';\n\n// Explicit upgrade applies owner-declared retirements and writes reviewed settings.\nconst DEFAULT_UPSERT_PR = 'pnpm wp-start-upsert-pr';\nconst DEFAULT_MERGE_COMPLETE = 'pnpm wp-finish-upsert-pr';\n// ---------------------------------------------------------------------------\n// webpieces.config.json seeding + migration to the rules / hookGuards / commands layout.\n// ---------------------------------------------------------------------------\n// webpieces-disable no-any-unknown -- webpieces.config.json / settings.json are opaque consumer JSON\ntype Json = Record<string, unknown>;\ntype RuleEntry = Json;\ntype Section = Record<string, RuleEntry>;\n\nexport class LegacyConfigDocument {\n readonly 'match-rules': Json[];\n readonly extends: string | undefined;\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly rules: Section,\n readonly hookGuards: Section,\n readonly commands: Json,\n readonly excludePaths: string[],\n matches: Json[],\n readonly rulesDir: string[],\n inheritedFrom: string | undefined,\n ) {\n this['match-rules'] = matches;\n this.extends = inheritedFrom;\n }\n}\n\nexport class LegacyUpgradeResult {\n constructor(\n readonly config: LegacyConfigDocument,\n readonly changes: string[],\n ) {}\n}\n\n// webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design\nfunction seedRule(ruleName: string, registry: RulePackRegistry): RuleEntry {\n // Both escape hatches are seeded (and REQUIRED) so every rule block shows them: 0 = active,\n // null = no branch scoping. A human/AI edits these to time-box or branch-scope a rule off.\n //\n // The ENTIRE entry comes from rules-config's seedEntryForRule() — the same module that owns the\n // schema the loader validates against, so the installer can never emit an entry the loader\n // rejects. It supplies: the recommended mode (the SAME recommendation the validator prints in its\n // copy-paste snippet, so seed and advice cannot disagree), both hatches, and a default for every\n // other schema-REQUIRED field. Seeding used to be a flat 'OFF' plus the two hatches, which was\n // wrong twice over: adopters got nothing enforced, AND the entry was missing required fields\n // (e.g. branch-creation-guard.autoReapMergedBranches), so the config failed to load on first run.\n return seedEntryForRule(ruleName, registry);\n}\n\n// The guard-hint command strings live under `guardHints`. The flat `upsertPr`/`mergeComplete` keys this\n// used to seed are RETIRED and now fail validation — seeding them meant every freshly installed repo was\n// born on a shape the validator rejects.\n\n// Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty\n// (enforce everywhere) — a client adds paths (e.g. \"repositories/**\") to exempt vendored trees.\n//\n// Deliberately NOT seeded with webpieces' own `.webpieces-logs/` state dir. That exemption lives in CODE\n// (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),\n// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces-logs/**` compiles to\n// an anchored regex that misses the bare directory the predicate matches, and because a config entry\n// invites a consumer to delete it and believe the exemption went with it.\n\n// Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.\n// Legacy `{ rules, guards }` → unioned (order preserved, duplicates dropped) and recorded as a change\n// so `pnpm wp-rules-sync --upgrade` is the migration path rather than a hand-edit. Anything else → seeded [].\n// webpieces-disable no-any-unknown -- opaque legacy JSON is narrowed before use\n// webpieces-disable no-function-outside-class -- pure legacy config conversion helper\nfunction migrateExcludePaths(raw: unknown, changes: string[]): string[] {\n if (Array.isArray(raw)) return (raw as string[]).filter((p: string) => typeof p === 'string');\n if (typeof raw === 'object' && raw !== null) {\n // webpieces-disable no-any-unknown -- narrowing the opaque legacy block from consumer JSON\n const legacy = raw as Record<string, unknown>;\n const rules = Array.isArray(legacy['rules']) ? (legacy['rules'] as string[]) : [];\n const guards = Array.isArray(legacy['guards']) ? (legacy['guards'] as string[]) : [];\n const merged = [\n ...new Set([...rules, ...guards].filter((p: string) => typeof p === 'string')),\n ];\n changes.push(`migrated excludePaths {rules,guards} -> one list (${merged.length} path(s))`);\n return merged;\n }\n changes.push('added excludePaths ([])');\n return [];\n}\n\n/** One retired flat command string and the guardHints field it becomes. Data-only (per CLAUDE.md). */\nclass GuardHintMove {\n retiredKey: string;\n hintKey: string;\n fallback: string;\n\n constructor(retiredKey: string, hintKey: string, fallback: string) {\n this.retiredKey = retiredKey;\n this.hintKey = hintKey;\n this.fallback = fallback;\n }\n}\n\n/**\n * Bring `commands` forward to the `guardHints` shape, moving the RETIRED flat `upsertPr`/`mergeComplete`\n * strings and DELETING them. Deleting is the point: the validator now rejects them, so leaving them behind\n * would keep the config failing after a \"successful\" sync.\n *\n * The consumer's own value wins over the default — a repo that renamed its gated command keeps that name.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateGuardHints(commands: Json, changes: string[]): void {\n const hints: Json =\n typeof commands['guardHints'] === 'object' && commands['guardHints'] !== null\n ? (commands['guardHints'] as Json)\n : {};\n const moves: readonly GuardHintMove[] = [\n new GuardHintMove('upsertPr', 'prCreationOrPush', DEFAULT_UPSERT_PR),\n new GuardHintMove('mergeComplete', 'mergeInProgress', DEFAULT_MERGE_COMPLETE),\n ];\n for (const move of moves) {\n const retiredKey = move.retiredKey;\n const hintKey = move.hintKey;\n const fallback = move.fallback;\n const carried = commands[retiredKey];\n if (carried !== undefined) {\n delete commands[retiredKey];\n if (hints[hintKey] === undefined) hints[hintKey] = carried;\n changes.push(`moved retired commands.${retiredKey} -> commands.guardHints.${hintKey}`);\n }\n if (hints[hintKey] === undefined) {\n hints[hintKey] = fallback;\n changes.push(`added commands.guardHints.${hintKey}`);\n }\n }\n commands['guardHints'] = hints;\n}\n\n/**\n * Apply the RETIRED rule/guard retirements in place. These used to be rewritten silently at load time, so\n * a consumer's file kept the dead name forever; the loader now rejects it, which makes this the one\n * command that can fix the file. Skips a rename when the new name is already configured, so an explicit\n * entry is never clobbered by a stale one.\n *\n * NOT EVERY RETIREMENT IS A RENAME, and treating them all as one produced garbage. `whole-repo-build-guard`\n * moved OUT of webpieces.config.json entirely — its `movedTo` is the PROSE destination\n * `~/.webpieces/config.json → experimental.whole-repo-build-guard`, not a sibling key — so the rename\n * branch below would have created a hookGuards entry literally named that whole sentence, which no\n * validator knows and which the next run reports as another unknown rule. `prunable` is the discriminator:\n * when the entry says deleting is the whole fix, DELETE it, exactly as `ConfigPruner` does.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateRetiredRuleNames(\n section: Section,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n for (const entry of registry.migrations()) {\n if (entry.scope !== RETIRED_SCOPE_RULE) continue;\n if (!(entry.key in section)) continue;\n if (entry.prunable) {\n delete section[entry.key];\n changes.push(`deleted retired \"${entry.key}\" (it moved to ${entry.movedTo})`);\n continue;\n }\n mergeIntoDestination(section, entry.key, entry.movedTo, changes, registry);\n }\n fillRequiredFields(section, changes, registry);\n}\n\n/**\n * Fold one retired key's entry into its destination, whether the destination exists yet or not.\n *\n * THIS IS N→1, NOT 1:1, and the difference is the whole reason this helper exists. Four retired keys\n * now point at ONE destination (`branch-state-guard`, `pr-lifecycle-guard`). The previous code renamed\n * the first key it met and then, finding the destination already present, DELETED each of the other\n * three outright — so which guard's settings survived depended on RETIRED_CONFIG_KEYS declaration\n * order rather than on the consumer's file, and the survivor carried only that one guard's fields, so\n * it was missing required fields of the merged schema. `pnpm wp-rules-sync --upgrade` is the command advertised\n * as the migration path; half-migrating every consumer into an invalid config is not an option.\n *\n * UNION, first writer wins per field. Earlier-declared keys are the more specific ones (only\n * feature-branch-guard carries `branchNamingConvention`), and a field already present on the\n * destination — because the consumer wrote it, or an earlier key contributed it — is never overwritten.\n * Fields the merged schema does not know are dropped by the same pass, since carrying a deleted field\n * across (`upsertPrCommand`) would produce a config the validator immediately rejects.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction mergeIntoDestination(\n section: Section,\n key: string,\n destination: string,\n changes: string[],\n registry: RulePackRegistry,\n): void {\n const source = asSection(section[key]);\n delete section[key];\n const fields = schemaFieldNames(destination, registry);\n const target = asSection(section[destination]);\n const existed = destination in section;\n const carried: string[] = [];\n const dropped: string[] = [];\n for (const field of Object.keys(source)) {\n if (fields !== null && !fields.includes(field)) {\n dropped.push(field);\n continue;\n }\n if (field in target) continue;\n target[field] = source[field];\n carried.push(field);\n }\n section[destination] = target;\n const verb = existed ? 'merged' : 'renamed';\n const droppedNote =\n dropped.length > 0 ? `; dropped deleted field(s) ${dropped.join(', ')}` : '';\n changes.push(\n `${verb} retired \"${key}\" -> \"${destination}\" (carried ${carried.join(', ') || 'nothing new'}${droppedNote})`,\n );\n}\n\n/**\n * Fill any schema-REQUIRED field a migrated entry ended up without.\n *\n * A union of four partial entries is not guaranteed to satisfy the destination's schema — the merged\n * `branch-state-guard` needs `mode` and both escape hatches, and a consumer whose four old entries\n * predate one of them would land short. Seeding the gap from the SAME source the installer and the\n * validator use (seedEntryForRule) is what makes the install command a complete instruction\n * rather than a first step. Only ever ADDS; a value the consumer stated is never touched.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction fillRequiredFields(section: Section, changes: string[], registry: RulePackRegistry): void {\n for (const name of Object.keys(section)) {\n if (schemaFieldNames(name, registry) === null) continue;\n // A rule ENTRY is a flat bag of scalars, so it is read as Json here rather than through\n // asSection (whose values are whole entries). Same object either way; only the view differs.\n const entry: Json = asSection(section[name]);\n const seed = seedEntryForRule(name, registry);\n const added: string[] = [];\n for (const field of Object.keys(seed)) {\n if (field in entry) continue;\n entry[field] = seed[field];\n added.push(field);\n }\n if (added.length === 0) continue;\n section[name] = entry;\n changes.push(`filled required field(s) on \"${name}\": ${added.join(', ')}`);\n }\n}\n\n// Deep-copy the framework's default match-rules (the no-fetch guard) into plain JSON for the config\n// file. Round-tripping through JSON turns the MatchRuleConfig instances into plain objects.\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction seedMatchRules(): Json[] {\n return JSON.parse(JSON.stringify(DEFAULT_MATCH_RULES)) as Json[];\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction asSection(value: Json[string]): Section {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Section)\n : {};\n}\n\n// Migrate an existing config to the rules / hookGuards / commands layout and add any missing rules.\n// Returns a human-readable list of what changed (empty = already up to date).\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `pnpm wp-rules-sync --upgrade` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nexport function prepareLegacyUpgrade(\n existing: Json,\n registry: RulePackRegistry,\n): LegacyUpgradeResult {\n const changes: string[] = [];\n const rules: Section = asSection(existing['rules']);\n const hookGuards: Section = asSection(existing['hookGuards']);\n const commands: Json =\n typeof existing['commands'] === 'object' && existing['commands'] !== null\n ? (existing['commands'] as Json)\n : {};\n\n // Move a deprecated top-level pr-gate block under commands.\n if (existing['pr-gate'] !== undefined && commands['pr-gate'] === undefined) {\n commands['pr-gate'] = existing['pr-gate'];\n changes.push('moved top-level \"pr-gate\" → commands[\"pr-gate\"]');\n }\n // Apply retired RENAMES first, so a renamed guard is placed and presence-checked under its new name\n // rather than being treated as unknown and re-added alongside its own stale entry.\n migrateRetiredRuleNames(rules, changes, registry);\n migrateRetiredRuleNames(hookGuards, changes, registry);\n\n migratePolicySections(rules, hookGuards, changes, registry);\n // Add any missing built-in into its correct section, ENFORCING at its recommended mode (not OFF).\n for (const name of allRuleNames(registry)) {\n const target = sectionForRule(name, registry) === 'hookGuards' ? hookGuards : rules;\n if (!(name in target)) {\n const entry = seedRule(name, registry);\n target[name] = entry;\n changes.push(\n `added \"${name}\" (${String(entry['mode'])}) to ${sectionForRule(name, registry)}`,\n );\n }\n }\n // Fill command defaults.\n if (commands['pr-gate'] === undefined) {\n commands['pr-gate'] = { mode: 'OFF', buildCommand: DEFAULT_BUILD_COMMAND, gates: [] };\n changes.push('added commands[\"pr-gate\"] (OFF)');\n }\n migrateGuardHints(commands, changes);\n\n // Seed the now-required excludePaths list (empty = enforce everywhere) if the config predates it,\n // and MIGRATE the legacy `{ rules: [], guards: [] }` object to the single list by unioning them.\n // The union is behaviour-preserving for every config we have seen (both lists set identically), and\n // widening is the safe direction anyway: a path either side excluded stays excluded.\n const excludePaths: string[] = migrateExcludePaths(existing['excludePaths'], changes);\n\n const matchRules = upgradeMatchRules(existing, changes);\n\n const rulesDir: string[] = Array.isArray(existing['rulesDir'])\n ? (existing['rulesDir'] as string[])\n : [];\n const inherited = typeof existing['extends'] === 'string' ? existing['extends'] : undefined;\n return new LegacyUpgradeResult(\n new LegacyConfigDocument(\n rules,\n hookGuards,\n commands,\n excludePaths,\n matchRules,\n rulesDir,\n inherited,\n ),\n changes,\n );\n}\n\n// webpieces-disable no-function-outside-class -- explicit upgrade conversion remains independent of DI\nfunction migratePolicySections(rules: Section, hookGuards: Section, changes: string[], registry: RulePackRegistry): void {\n // Move guards mistakenly left in rules into hookGuards.\n for (const name of Object.keys(rules)) {\n if (isHookGuard(name, registry)) {\n hookGuards[name] = rules[name];\n delete rules[name];\n changes.push(`moved \"${name}\" from rules → hookGuards`);\n }\n }\n // Move code rules mistakenly placed in hookGuards back into rules.\n for (const name of Object.keys(hookGuards)) {\n if (!isHookGuard(name, registry) && allRuleNames(registry).includes(name)) {\n rules[name] = hookGuards[name];\n delete hookGuards[name];\n changes.push(`moved \"${name}\" from hookGuards → rules`);\n }\n }\n}\n\n// webpieces-disable no-function-outside-class -- pure explicit-upgrade conversion\nfunction upgradeMatchRules(existing: Json, changes: string[]): Json[] {\n // Seed the now-required match-rules array (with the default no-fetch guard) if the config predates\n // it. A client that has already customized it keeps their array untouched.\n let matchRules: Json[];\n if (Array.isArray(existing['match-rules'])) {\n matchRules = existing['match-rules'] as Json[];\n } else {\n matchRules = seedMatchRules();\n changes.push('added \"match-rules\" (seeded with the no-fetch guard)');\n }\n\n return matchRules;\n}\n"]}
|
package/src/load-config.js
CHANGED
|
@@ -18,6 +18,7 @@ const commands_section_validators_1 = require("./commands-section-validators");
|
|
|
18
18
|
const config_key_rules_1 = require("./config-key-rules");
|
|
19
19
|
const validate_config_1 = require("./validate-config");
|
|
20
20
|
const WebpiecesRulesConfig_1 = require("./WebpiecesRulesConfig");
|
|
21
|
+
const policy_tracking_1 = require("./policy-tracking");
|
|
21
22
|
const config_error_banner_1 = require("./config-error-banner");
|
|
22
23
|
/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */
|
|
23
24
|
class LoadedConfig {
|
|
@@ -68,9 +69,11 @@ let ConfigLoader = class ConfigLoader {
|
|
|
68
69
|
];
|
|
69
70
|
if (errors.length)
|
|
70
71
|
throw new tooling_common_1.InformAiError((0, config_error_banner_1.formatConfigErrorsBanner)(errors));
|
|
72
|
+
new tooling_common_1.RepositoryLayout().assertCurrent(root);
|
|
71
73
|
const declarations = this.files.declarations(raw.rulePacks, root);
|
|
72
74
|
const policy = this.files.resolve(root, this.files.select(root, declarations));
|
|
73
75
|
this.artifacts.check(root, policy);
|
|
76
|
+
new policy_tracking_1.PolicyTracking().check(root, declarations);
|
|
74
77
|
return this.loaded(configPath, raw.commands, raw.excludePaths, raw['match-rules'], policy);
|
|
75
78
|
}
|
|
76
79
|
loaded(configPath,
|
package/src/load-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-config.ts"],"names":[],"mappings":";;;AAkIA,0CAEC;;AApID,wDAAkC;AAClC,yCAA2D;AAC3D,oDAAoD;AACpD,8DAAwF;AACxF,uDAAwE;AACxE,+CAA2C;AAC3C,6DAAwD;AACxD,2DAA6E;AAC7E,+DAA0D;AAC1D,6DAAoD;AAEpD,mCAA6D;AAC7D,+EAAwE;AACxE,yDAA0D;AAC1D,uDAAoF;AAEpF,iEAA8D;AAC9D,uDAAmD;AACnD,+DAAiE;AAEjE,6GAA6G;AAC7G,MAAa,YAAY;IAGR;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA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IAAI,uCAAiB,CAAC,IAAI,2BAAU,EAAE,CAAC,CAC1C,CAAC;AAEF,oFAAoF;AACpF,oHAAoH;AACpH,SAAgB,eAAe,CAAC,GAAW;IACvC,OAAO,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import * as path from 'node:path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ConfigObject } from '@webpieces/rules-sdk';\nimport { InformAiError, AtomicFile, RepositoryLayout } from '@webpieces/tooling-common';\nimport { buildCommandsConfig, CommandsConfig } from './commands-config';\nimport { ConfigFile } from './config-file';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { PackPolicyFiles, PackPolicyFilesResult } from './pack-policy-files';\nimport { RulePackArtifacts } from './rule-pack-artifacts';\nimport { ExcludePaths } from './exclude-hook-paths';\nimport { PrGateConfig } from './pr-gate-config';\nimport { ResolvedConfig, ResolvedRuleConfig } from './types';\nimport { validateCommandsSection } from './commands-section-validators';\nimport { validateTopLevelKeys } from './config-key-rules';\nimport { validateExcludePaths, validateMatchRulesSection } from './validate-config';\nimport { MatchRuleConfig } from './match-rules-config';\nimport { WebpiecesRulesConfig } from './WebpiecesRulesConfig';\nimport { PolicyTracking } from './policy-tracking';\nimport { formatConfigErrorsBanner } from './config-error-banner';\n\n/** One root parse and one owner-resolution pass supply all consumers with the same registry and settings. */\nexport class LoadedConfig {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly resolved: ResolvedConfig,\n readonly rulesConfig: WebpiecesRulesConfig,\n readonly commands: CommandsConfig,\n readonly prGate: PrGateConfig,\n readonly excludePaths: ExcludePaths,\n readonly matchRules: readonly MatchRuleConfig[],\n readonly configPath: string | null,\n readonly ruleRegistry: RulePackRegistry,\n readonly policyFiles: PackPolicyFilesResult | null,\n ) {}\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigLoader {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly files: PackPolicyFiles,\n private readonly artifacts: RulePackArtifacts,\n ) {}\n\n loadAndValidate(cwd: string): LoadedConfig {\n const configPath = this.configFile.findConfigFile(cwd);\n if (!configPath) return this.empty();\n const raw = this.configFile.readRawConfig(configPath),\n root = path.dirname(configPath);\n // webpieces-disable no-any-unknown -- the root parser returns opaque client JSON; these validators narrow every accepted field\n const document = raw as Record<string, unknown>;\n const errors = [\n ...validateTopLevelKeys(document),\n ...validateCommandsSection(raw.commands, document['pr-gate'], root),\n ...validateExcludePaths(raw.excludePaths),\n ...validateMatchRulesSection(raw['match-rules']),\n ];\n if (errors.length) throw new InformAiError(formatConfigErrorsBanner(errors));\n new RepositoryLayout().assertCurrent(root);\n const declarations = this.files.declarations(raw.rulePacks, root);\n const policy = this.files.resolve(root, this.files.select(root, declarations));\n this.artifacts.check(root, policy);\n new PolicyTracking().check(root, declarations);\n return this.loaded(\n configPath,\n raw.commands,\n raw.excludePaths as string[],\n raw['match-rules'] as MatchRuleConfig[],\n policy,\n );\n }\n\n private loaded(\n configPath: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n commandsRaw: unknown,\n excluded: readonly string[],\n matches: readonly MatchRuleConfig[],\n policy: PackPolicyFilesResult,\n ): LoadedConfig {\n const commands = buildCommandsConfig(commandsRaw),\n values = new WebpiecesRulesConfig();\n const resolved = new Map<string, ResolvedRuleConfig>();\n for (const id of policy.registry.ruleIds()) {\n const explicit = policy.values[id];\n values[id] = explicit;\n const options = Object.assign(\n new ConfigObject(),\n policy.registry.optionalTuningFor(id),\n explicit,\n );\n resolved.set(id, new ResolvedRuleConfig(options));\n }\n return new LoadedConfig(\n new ResolvedConfig(resolved, new Set(policy.registry.ruleIds()), configPath),\n values,\n commands,\n commands.prGate,\n new ExcludePaths([...excluded]),\n matches,\n configPath,\n policy.registry,\n policy,\n );\n }\n\n private empty(): LoadedConfig {\n const commands = buildCommandsConfig(undefined);\n return new LoadedConfig(\n new ResolvedConfig(new Map(), new Set(), null),\n new WebpiecesRulesConfig(),\n commands,\n commands.prGate,\n new ExcludePaths([]),\n [],\n null,\n new RulePackRegistry([]),\n null,\n );\n }\n}\n\nconst configLoaderSvc = new ConfigLoader(\n new ConfigFile(),\n new PackPolicyFiles(),\n new RulePackArtifacts(new AtomicFile()),\n);\n\n/** Public function entry point and injected service use the same implementation. */\n// webpieces-disable no-function-outside-class -- canonical public loader function for CLI and executor entry points\nexport function loadAndValidate(cwd: string): LoadedConfig {\n return configLoaderSvc.loadAndValidate(cwd);\n}\n"]}
|
package/src/load-template.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { InstructAiDocSet } from './instruct-ai-docs';
|
|
|
3
3
|
import { DotWebpieces } from '@webpieces/tooling-common';
|
|
4
4
|
import { StaleBinSweeper } from './stale-bin-sweep';
|
|
5
5
|
/**
|
|
6
|
-
* Writes the AI-facing instruct-ai template docs under `<workspaceRoot>/.webpieces/instruct-ai/`.
|
|
6
|
+
* Writes the AI-facing instruct-ai template docs under `<workspaceRoot>/.webpieces-logs/instruct-ai/`.
|
|
7
7
|
* `@injectable(bindingScopeValues.Singleton)` so it can be injected and appear in the rules-config DI design.
|
|
8
8
|
*/
|
|
9
9
|
export declare class TemplateWriter {
|
package/src/load-template.js
CHANGED
|
@@ -19,7 +19,7 @@ const TEMPLATES_DIR = path.join(__dirname, '..', 'templates');
|
|
|
19
19
|
// unaffected; anything passing the default gets DotWebpieces.local() resolution.
|
|
20
20
|
const DEFAULT_INSTRUCT_DIR = '';
|
|
21
21
|
/**
|
|
22
|
-
* Writes the AI-facing instruct-ai template docs under `<workspaceRoot>/.webpieces/instruct-ai/`.
|
|
22
|
+
* Writes the AI-facing instruct-ai template docs under `<workspaceRoot>/.webpieces-logs/instruct-ai/`.
|
|
23
23
|
* `@injectable(bindingScopeValues.Singleton)` so it can be injected and appear in the rules-config DI design.
|
|
24
24
|
*/
|
|
25
25
|
let TemplateWriter = class TemplateWriter {
|
|
@@ -93,7 +93,7 @@ let TemplateWriter = class TemplateWriter {
|
|
|
93
93
|
for (const line of this.staleBins.report(removed))
|
|
94
94
|
process.stdout.write(line + '\n');
|
|
95
95
|
}
|
|
96
|
-
// LOCAL `.webpieces/instruct-ai/<name>` by default; an explicitly-passed relative dir is still
|
|
96
|
+
// LOCAL `.webpieces-logs/instruct-ai/<name>` by default; an explicitly-passed relative dir is still
|
|
97
97
|
// joined onto workspaceRoot exactly as before.
|
|
98
98
|
destination(workspaceRoot, name, instructDir) {
|
|
99
99
|
if (instructDir === DEFAULT_INSTRUCT_DIR) {
|
package/src/load-template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-template.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-template.ts"],"names":[],"mappings":";;;AAsGA,oCAEC;AAED,wDAMC;AAED,sCAMC;;AAxHD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D,8DAAuD;AACvD,yDAAsD;AACtD,2CAA+C;AAC/C,8DAAuE;AACvE,uDAAqE;AAErE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC9D,sGAAsG;AACtG,iGAAiG;AACjG,iFAAiF;AACjF,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAEF;IACA;IACA;IAGA;IANrB,YACqB,SAAuB,6BAAY,EACnC,aAAyB,IAAI,2BAAU,EAAE,EACzC,OAAyB,IAAI,mCAAgB,EAAE;IAChE,4FAA4F;IAC5F,+EAA+E;IAC9D,YAA6B,iCAAe;QAL5C,WAAM,GAAN,MAAM,CAA6B;QACnC,eAAU,GAAV,UAAU,CAA+B;QACzC,SAAI,GAAJ,IAAI,CAA2C;QAG/C,cAAS,GAAT,SAAS,CAAmC;IAC9D,CAAC;IAEJ,YAAY,CAAC,IAAY;QACrB,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,aA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CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;QACnG,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,aAAqB;QACxC,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;QACxD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACzF,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"load-template.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/load-template.ts"],"names":[],"mappings":";;;AAsGA,oCAEC;AAED,wDAMC;AAED,sCAMC;;AAxHD,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAE3D,8DAAuD;AACvD,yDAAsD;AACtD,2CAA+C;AAC/C,8DAAuE;AACvE,uDAAqE;AAErE,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC9D,sGAAsG;AACtG,iGAAiG;AACjG,iFAAiF;AACjF,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IAEF;IACA;IACA;IAGA;IANrB,YACqB,SAAuB,6BAAY,EACnC,aAAyB,IAAI,2BAAU,EAAE,EACzC,OAAyB,IAAI,mCAAgB,EAAE;IAChE,4FAA4F;IAC5F,+EAA+E;IAC9D,YAA6B,iCAAe;QAL5C,WAAM,GAAN,MAAM,CAA6B;QACnC,eAAU,GAAV,UAAU,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c,EAAE,CAAC;AAE/C,SAAgB,YAAY,CAAC,IAAY;IACrC,OAAO,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,SAAgB,sBAAsB,CAClC,aAAqB,EACrB,IAAY,EACZ,cAAsB,oBAAoB;IAE1C,iBAAiB,CAAC,sBAAsB,CAAC,aAAa,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC/E,CAAC;AAED,SAAgB,aAAa,CACzB,aAAqB,EACrB,IAAY,EACZ,cAAsB,oBAAoB;IAE1C,OAAO,iBAAiB,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC7E,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { AtomicFile } from '@webpieces/tooling-common';\nimport { InstructAiDocSet } from './instruct-ai-docs';\nimport { INSTRUCT_AI_LEAF } from './repo-root';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\nimport { StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';\n\nconst TEMPLATES_DIR = path.join(__dirname, '..', 'templates');\n// Sentinel for \"use the resolved LOCAL instruct-ai dir\". Kept as the parameter default so the handful\n// of callers that pass an explicit relative dir (they join it onto workspaceRoot themselves) are\n// unaffected; anything passing the default gets DotWebpieces.local() resolution.\nconst DEFAULT_INSTRUCT_DIR = '';\n\n/**\n * Writes the AI-facing instruct-ai template docs under `<workspaceRoot>/.webpieces-logs/instruct-ai/`.\n * `@injectable(bindingScopeValues.Singleton)` so it can be injected and appear in the rules-config DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class TemplateWriter {\n constructor(\n private readonly dotDir: DotWebpieces = dotWebpieces,\n private readonly atomicFile: AtomicFile = new AtomicFile(),\n private readonly docs: InstructAiDocSet = new InstructAiDocSet(),\n // The SHARED sweeper instance, never a fresh one: its \"already swept this root\" memo is per\n // instance, and that memo is what keeps the report to once per `wp-*` command.\n private readonly staleBins: StaleBinSweeper = staleBinSweeper,\n ) {}\n\n loadTemplate(name: string): string {\n return fs.readFileSync(path.join(TEMPLATES_DIR, name), 'utf-8');\n }\n\n /**\n * SEED `name` and everything it links to — writing only the ones that are not already on disk.\n *\n * Same closure as `writeTemplate`, for the same reason: a rule that drops\n * `webpieces.exceptions.md` next to its violation is delivering a doc a reader follows links out\n * of, and a seeded doc that later gains a sibling link would otherwise dangle exactly the way\n * git-workflow.md's link to the merge process did. The difference from `writeTemplate` is only\n * WHETHER an existing file is refreshed, never WHICH files are considered.\n */\n writeTemplateIfMissing(workspaceRoot: string, name: string, instructDir: string = DEFAULT_INSTRUCT_DIR): void {\n for (const doc of this.docs.closure(name, (docName: string): string => this.loadTemplate(docName))) {\n const target = this.destination(workspaceRoot, doc.name, instructDir);\n if (fs.existsSync(target)) continue;\n this.atomicFile.writeAtomic(target, doc.render(this.loadTemplate(doc.name), workspaceRoot));\n }\n }\n\n /**\n * Write `name` AND every instruct-ai doc it links to, ATOMICALLY and only where bytes changed.\n * Returns the absolute path of `name` itself.\n *\n * THE CLOSURE IS THE POINT. Callers name the ONE doc their command is about; the docs a reader is\n * sent on to arrive with it, because a doc whose links dangle is worse than no doc — it teaches the\n * reader that the paths in these files cannot be trusted. See instruct-ai-docs.ts for the incident.\n *\n * Every `wp-*` command regenerates these, and the AI is routinely told to open one by absolute\n * path. A plain truncating write means a reader can catch it empty; skip-if-unchanged means the\n * overwhelmingly common case (same package version ⇒ identical content) does not write at all.\n */\n writeTemplate(workspaceRoot: string, name: string, instructDir: string = DEFAULT_INSTRUCT_DIR): string {\n // THE SELF-HEAL. This is the pass every `wp-*` command takes, which makes it the only place a\n // RELEASED sweep reaches every clone on every developer's machine — see stale-bin-sweep.ts. Silent\n // when there is nothing to remove, and once per root per process.\n this.sweepStaleBins(workspaceRoot);\n for (const doc of this.docs.closure(name, (docName: string): string => this.loadTemplate(docName))) {\n const target = this.destination(workspaceRoot, doc.name, instructDir);\n // A doc stamped with live run state is SEEDED, never refreshed: `wp-finish-upsert-pr` runs\n // while a conflicted merge is still open, and clobbering that handback with the reference\n // copy would delete the file list the agent is working from.\n if (doc.seedOnly() && fs.existsSync(target)) continue;\n this.atomicFile.writeIfChanged(target, doc.render(this.loadTemplate(doc.name), workspaceRoot));\n }\n return this.destination(workspaceRoot, name, instructDir);\n }\n\n /**\n * Remove this tree's dangling `wp-*` bin symlinks and SAY what went, on stdout beside everything else\n * a `wp-*` command prints. Nothing removed ⇒ nothing printed, which is the overwhelmingly common case.\n */\n private sweepStaleBins(workspaceRoot: string): void {\n const removed = this.staleBins.sweepOnce(workspaceRoot);\n for (const line of this.staleBins.report(removed)) process.stdout.write(line + '\\n');\n }\n\n // LOCAL `.webpieces-logs/instruct-ai/<name>` by default; an explicitly-passed relative dir is still\n // joined onto workspaceRoot exactly as before.\n private destination(workspaceRoot: string, name: string, instructDir: string): string {\n if (instructDir === DEFAULT_INSTRUCT_DIR) {\n return this.dotDir.localFile(workspaceRoot, INSTRUCT_AI_LEAF, name);\n }\n return path.join(workspaceRoot, instructDir, name);\n }\n}\n\n// Temporary migration delegators — consumers migrate to injecting TemplateWriter over follow-up PRs.\nconst templateWriterSvc = new TemplateWriter();\n\nexport function loadTemplate(name: string): string {\n return templateWriterSvc.loadTemplate(name);\n}\n\nexport function writeTemplateIfMissing(\n workspaceRoot: string,\n name: string,\n instructDir: string = DEFAULT_INSTRUCT_DIR,\n): void {\n templateWriterSvc.writeTemplateIfMissing(workspaceRoot, name, instructDir);\n}\n\nexport function writeTemplate(\n workspaceRoot: string,\n name: string,\n instructDir: string = DEFAULT_INSTRUCT_DIR,\n): string {\n return templateWriterSvc.writeTemplate(workspaceRoot, name, instructDir);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */
|
|
1
|
+
/** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */
|
|
2
2
|
export declare const MERGE_PROCESS_DOC = "webpieces.mergeprocess.md";
|
|
3
3
|
/**
|
|
4
4
|
* The values one merge run stamps into the doc, plus the one rendering that depends on WHICH state
|
package/src/merge-process-doc.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.MergeProcessText = exports.ReferenceMergeRun = exports.MergeRun = exports.MERGE_PROCESS_DOC = void 0;
|
|
22
22
|
const constants_1 = require("./constants");
|
|
23
|
-
/** The rules-config template name, and the file name it lands under in `.webpieces/instruct-ai/`. */
|
|
23
|
+
/** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */
|
|
24
24
|
exports.MERGE_PROCESS_DOC = 'webpieces.mergeprocess.md';
|
|
25
25
|
const REFERENCE_RUN_STATE = `**Reference copy — no conflicted 3-point merge is in progress in this tree.** It is written beside
|
|
26
26
|
\`webpieces.git-workflow.md\` on every \`wp-*\` command, so the link from that doc always resolves.
|
|
@@ -30,7 +30,7 @@ this file in place with the branch you are standing on, that run's absolute \`ME
|
|
|
30
30
|
finish command for the flow you started, and the list of conflicted files. Until that happens, read
|
|
31
31
|
what follows as the PROCESS and not as a live handback: \`<feature>Squash\` stands for the transient
|
|
32
32
|
branch a conflicted merge puts you on, and \`MERGE_DIR\` for that run's
|
|
33
|
-
\`.webpieces/merge-info/<feature>/merge-<n>/\` directory.`;
|
|
33
|
+
\`.webpieces-logs/merge-info/<feature>/merge-<n>/\` directory.`;
|
|
34
34
|
const REFERENCE_FILE_LIST = '*(none — no conflicted merge is in progress; the live copy lists this run\'s conflicted files here)*';
|
|
35
35
|
/**
|
|
36
36
|
* The values one merge run stamps into the doc, plus the one rendering that depends on WHICH state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-process-doc.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/merge-process-doc.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,0DAA0D;AAC1D,EAAE;AACF,sGAAsG;AACtG,iGAAiG;AACjG,mGAAmG;AACnG,0CAA0C;AAC1C,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,4EAA4E;AAC5E,EAAE;AACF,6FAA6F;AAC7F,4FAA4F;AAC5F,EAAE;AACF,sGAAsG;AACtG,8DAA8D;AAC9D,8EAA8E;;;AAE9E,2CAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"merge-process-doc.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/merge-process-doc.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,0DAA0D;AAC1D,EAAE;AACF,sGAAsG;AACtG,iGAAiG;AACjG,mGAAmG;AACnG,0CAA0C;AAC1C,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,4EAA4E;AAC5E,EAAE;AACF,6FAA6F;AAC7F,4FAA4F;AAC5F,EAAE;AACF,sGAAsG;AACtG,8DAA8D;AAC9D,8EAA8E;;;AAE9E,2CAAqD;AAErD,0GAA0G;AAC7F,QAAA,iBAAiB,GAAG,2BAA2B,CAAC;AAE7D,MAAM,mBAAmB,GAAG;;;;;;;;+DAQmC,CAAC;AAEhE,MAAM,mBAAmB,GACrB,sGAAsG,CAAC;AAE3G;;;;;;;GAOG;AACH,MAAa,QAAQ;IAIJ;IAEA;IAEA;IAEA;IAEA;IAXb,oGAAoG;IACpG;IACI,yDAAyD;IAChD,YAAoB;IAC7B,iFAAiF;IACxE,aAAqB;IAC9B,0EAA0E;IACjE,YAAoB;IAC7B,4DAA4D;IACnD,QAAgB;IACzB,oDAAoD;IAC3C,QAAgB;QARhB,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,kBAAa,GAAb,aAAa,CAAQ;QAErB,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,aAAQ,GAAR,QAAQ,CAAQ;IAC1B,CAAC;IAEJ,0FAA0F;IAC1F,QAAQ;QACJ,OAAO,qCAAqC,IAAI,CAAC,YAAY,mDAAmD;YAC5G,iFAAiF;YACjF,uBAAuB,IAAI,CAAC,YAAY,iDAAiD;YACzF,iBAAiB,IAAI,CAAC,QAAQ,IAAI,CAAC;IAC3C,CAAC;CACJ;AAtBD,4BAsBC;AAED,wGAAwG;AACxG,MAAa,iBAAkB,SAAQ,QAAQ;IAC3C;QACI,KAAK,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAC5G,CAAC;IAEQ,QAAQ;QACb,OAAO,mBAAmB,CAAC;IAC/B,CAAC;CACJ;AARD,8CAQC;AAED,wGAAwG;AACxG,MAAa,gBAAgB;IACI;IAAmC;IAAhE,YAA6B,QAAgB,EAAmB,kBAA0B,kCAAsB;QAAnF,aAAQ,GAAR,QAAQ,CAAQ;QAAmB,oBAAe,GAAf,eAAe,CAAiC;IAAG,CAAC;IAEpH,MAAM,CAAC,GAAa;QAChB,OAAO,IAAI,CAAC,QAAQ;aACf,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC;aAC7C,OAAO,CAAC,wBAAwB,EAAE,GAAG,CAAC,YAAY,CAAC;aACnD,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,QAAQ,CAAC;aAC3C,OAAO,CAAC,2BAA2B,EAAE,IAAI,CAAC,eAAe,CAAC;aAC1D,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC,aAAa,CAAC;aACrD,OAAO,CAAC,wBAAwB,EAAE,GAAG,CAAC,YAAY,CAAC;aACnD,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;CACJ;AAbD,4CAaC","sourcesContent":["// ---------------------------------------------------------------------------\n// `webpieces.mergeprocess.md` — ONE template, TWO inputs.\n//\n// The merge-process doc used to live as a template literal inside pr-gate's `merge-start.ts`, and was\n// written ONLY when a 3-point merge actually conflicted. `webpieces.git-workflow.md` links to it\n// unconditionally, so in every tree that had not yet hit a conflict that link pointed at nothing —\n// measured in six of nine governed repos.\n//\n// The cure is not \"write it from one more place\". It is to make the doc a rules-config TEMPLATE like\n// every other instruct-ai doc, so `InstructAiDocSet` delivers it as part of git-workflow.md's LINK\n// CLOSURE, and to give that template one renderer with two possible inputs:\n//\n// new ReferenceMergeRun() the tree has no conflicted merge — the doc reads as the PROCESS\n// new MergeRun(...) pr-gate's conflict handback — the doc reads as a LIVE handback\n//\n// Two inputs, one output shape: there is exactly one spelling of the merge process, and the delivered\n// copy cannot drift from it because the delivered copy IS it.\n// ---------------------------------------------------------------------------\n\nimport { MERGE_EXPLANATION_FILE } from './constants';\n\n/** The rules-config template name, and the file name it lands under in `.webpieces-logs/instruct-ai/`. */\nexport const MERGE_PROCESS_DOC = 'webpieces.mergeprocess.md';\n\nconst REFERENCE_RUN_STATE = `**Reference copy — no conflicted 3-point merge is in progress in this tree.** It is written beside\n\\`webpieces.git-workflow.md\\` on every \\`wp-*\\` command, so the link from that doc always resolves.\n\nWhen a 3-point merge DOES conflict, \\`pnpm wp-start-upsert-pr\\` (or \\`pnpm wp-start-update\\`) rewrites\nthis file in place with the branch you are standing on, that run's absolute \\`MERGE_DIR\\`, the exact\nfinish command for the flow you started, and the list of conflicted files. Until that happens, read\nwhat follows as the PROCESS and not as a live handback: \\`<feature>Squash\\` stands for the transient\nbranch a conflicted merge puts you on, and \\`MERGE_DIR\\` for that run's\n\\`.webpieces-logs/merge-info/<feature>/merge-<n>/\\` directory.`;\n\nconst REFERENCE_FILE_LIST =\n '*(none — no conflicted merge is in progress; the live copy lists this run\\'s conflicted files here)*';\n\n/**\n * The values one merge run stamps into the doc, plus the one rendering that depends on WHICH state\n * this is.\n *\n * `ReferenceMergeRun` below is not a second document — it is these same fields standing for \"no run in\n * progress\", which is exactly what a reader of the delivered copy has to be told before following the\n * steps. One class and its subclass, so there is one merge process and two things it can be about.\n */\nexport class MergeRun {\n // eslint-disable-next-line @typescript-eslint/max-params -- the five values one merge run stamps in\n constructor(\n /** The `wp-start-*` command that produced this state. */\n readonly startCommand: string,\n /** Its paired `wp-finish-*` command — the ONLY way out of a conflicted merge. */\n readonly finishCommand: string,\n /** The transient `<feature>Squash` branch the merge put the caller on. */\n readonly squashBranch: string,\n /** Absolute path of this run's `merge-<n>/` context dir. */\n readonly mergeDir: string,\n /** Markdown bullet list of the conflicted files. */\n readonly fileList: string,\n ) {}\n\n /** The doc's opening block: a LIVE conflict handback naming this run's branch and dir. */\n runState(): string {\n return `This file was generated by \\`pnpm ${this.startCommand}\\` when the 3-point squash-merge hit conflicts.\\n` +\n 'It is the single source of truth for the merge process — follow it exactly.\\n\\n' +\n `You are on branch \\`${this.squashBranch}\\` with conflict markers in the working tree.\\n` +\n `\\`MERGE_DIR = ${this.mergeDir}\\``;\n }\n}\n\n/** The state of a tree with NO conflicted merge in it — what the delivered reference copy describes. */\nexport class ReferenceMergeRun extends MergeRun {\n constructor() {\n super('wp-start-upsert-pr', 'wp-finish-upsert-pr', '<feature>Squash', 'MERGE_DIR', REFERENCE_FILE_LIST);\n }\n\n override runState(): string {\n return REFERENCE_RUN_STATE;\n }\n}\n\n/** Substitutes one `MergeRun` (and the fixed explanation-file name) into the merge-process template. */\nexport class MergeProcessText {\n constructor(private readonly template: string, private readonly explanationFile: string = MERGE_EXPLANATION_FILE) {}\n\n render(run: MergeRun): string {\n return this.template\n .replace(/\\{\\{RUN_STATE\\}\\}/g, run.runState())\n .replace(/\\{\\{SQUASH_BRANCH\\}\\}/g, run.squashBranch)\n .replace(/\\{\\{MERGE_DIR\\}\\}/g, run.mergeDir)\n .replace(/\\{\\{EXPLANATION_FILE\\}\\}/g, this.explanationFile)\n .replace(/\\{\\{FINISH_COMMAND\\}\\}/g, run.finishCommand)\n .replace(/\\{\\{START_COMMAND\\}\\}/g, run.startCommand)\n .replace(/\\{\\{FILE_LIST\\}\\}/g, run.fileList);\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.MigrateDirsCli = void 0;
|
|
5
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
6
|
+
const config_file_1 = require("./config-file");
|
|
7
|
+
const pack_policy_files_1 = require("./pack-policy-files");
|
|
8
|
+
const rule_pack_artifacts_1 = require("./rule-pack-artifacts");
|
|
9
|
+
const rule_pack_sync_1 = require("./rule-pack-sync");
|
|
10
|
+
const policy_tracking_1 = require("./policy-tracking");
|
|
11
|
+
const repo_root_1 = require("./repo-root");
|
|
12
|
+
const run_main_1 = require("./run-main");
|
|
13
|
+
class MigrateDirsCli {
|
|
14
|
+
async main() {
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
if (args.some((argument) => argument !== '--stage'))
|
|
17
|
+
throw new tooling_common_1.InformAiError('Usage: pnpm wp-migrate-dirs [--stage]. --stage explicitly stages the migrated policy for commit.');
|
|
18
|
+
const root = new repo_root_1.RepoRootFinder().resolveRepoRoot(process.cwd());
|
|
19
|
+
const changed = new tooling_common_1.RepositoryLayout().migrate(root);
|
|
20
|
+
const atomic = new tooling_common_1.AtomicFile();
|
|
21
|
+
new rule_pack_sync_1.RulePackSync(new config_file_1.ConfigFile(), new pack_policy_files_1.PackPolicyFiles(), new rule_pack_artifacts_1.RulePackArtifacts(atomic), atomic).run(root, new rule_pack_sync_1.RulePackSyncOptions('sync', null));
|
|
22
|
+
if (args.includes('--stage')) {
|
|
23
|
+
const raw = new config_file_1.ConfigFile().readRawConfig(`${root}/webpieces.config.json`);
|
|
24
|
+
new policy_tracking_1.PolicyTracking().stage(root, new pack_policy_files_1.PackPolicyFiles().declarations(raw.rulePacks, root));
|
|
25
|
+
}
|
|
26
|
+
console.log(`Webpieces directories migrated. Review and commit .webpieces-config/ and webpieces.config.json; ignore only .webpieces-logs/.\n${changed.join('\n')}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.MigrateDirsCli = MigrateDirsCli;
|
|
30
|
+
if (require.main === module)
|
|
31
|
+
(0, run_main_1.runMain)(() => new MigrateDirsCli().main());
|
|
32
|
+
//# sourceMappingURL=migrate-dirs-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-dirs-cli.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/migrate-dirs-cli.ts"],"names":[],"mappings":";;;;AACA,8DAAwF;AACxF,+CAA2C;AAC3C,2DAAsD;AACtD,+DAA0D;AAC1D,qDAAqE;AACrE,uDAAmD;AACnD,2CAA6C;AAC7C,yCAAqC;AAErC,MAAa,cAAc;IACvB,KAAK,CAAC,IAAI;QACN,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC;YAC/C,MAAM,IAAI,8BAAa,CACnB,kGAAkG,CACrG,CAAC;QACN,MAAM,IAAI,GAAG,IAAI,0BAAc,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,IAAI,iCAAgB,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,IAAI,2BAAU,EAAE,CAAC;QAChC,IAAI,6BAAY,CACZ,IAAI,wBAAU,EAAE,EAChB,IAAI,mCAAe,EAAE,EACrB,IAAI,uCAAiB,CAAC,MAAM,CAAC,EAC7B,MAAM,CACT,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,oCAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,IAAI,wBAAU,EAAE,CAAC,aAAa,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC;YAC5E,IAAI,gCAAc,EAAE,CAAC,KAAK,CACtB,IAAI,EACJ,IAAI,mCAAe,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAC1D,CAAC;QACN,CAAC;QACD,OAAO,CAAC,GAAG,CACP,kIAAkI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzJ,CAAC;IACN,CAAC;CACJ;AA3BD,wCA2BC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,kBAAO,EAAC,GAAG,EAAE,CAAC,IAAI,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { RepositoryLayout, AtomicFile, InformAiError } from '@webpieces/tooling-common';\nimport { ConfigFile } from './config-file';\nimport { PackPolicyFiles } from './pack-policy-files';\nimport { RulePackArtifacts } from './rule-pack-artifacts';\nimport { RulePackSync, RulePackSyncOptions } from './rule-pack-sync';\nimport { PolicyTracking } from './policy-tracking';\nimport { RepoRootFinder } from './repo-root';\nimport { runMain } from './run-main';\n\nexport class MigrateDirsCli {\n async main(): Promise<void> {\n const args = process.argv.slice(2);\n if (args.some((argument) => argument !== '--stage'))\n throw new InformAiError(\n 'Usage: pnpm wp-migrate-dirs [--stage]. --stage explicitly stages the migrated policy for commit.',\n );\n const root = new RepoRootFinder().resolveRepoRoot(process.cwd());\n const changed = new RepositoryLayout().migrate(root);\n const atomic = new AtomicFile();\n new RulePackSync(\n new ConfigFile(),\n new PackPolicyFiles(),\n new RulePackArtifacts(atomic),\n atomic,\n ).run(root, new RulePackSyncOptions('sync', null));\n if (args.includes('--stage')) {\n const raw = new ConfigFile().readRawConfig(`${root}/webpieces.config.json`);\n new PolicyTracking().stage(\n root,\n new PackPolicyFiles().declarations(raw.rulePacks, root),\n );\n }\n console.log(\n `Webpieces directories migrated. Review and commit .webpieces-config/ and webpieces.config.json; ignore only .webpieces-logs/.\\n${changed.join('\\n')}`,\n );\n }\n}\n\nif (require.main === module) runMain(() => new MigrateDirsCli().main());\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OrphanCandidate } from './orphan-dir-scan';
|
|
2
|
-
/** Where every sweep's archive lands, under the repo-wide `.webpieces/` — never under a worktree's own. */
|
|
2
|
+
/** Where every sweep's archive lands, under the repo-wide `.webpieces-logs/` — never under a worktree's own. */
|
|
3
3
|
export declare const TRASH_STATE_DIR = "trash";
|
|
4
4
|
/** The per-sweep manifest, holding what moved and the command that brings each one back. */
|
|
5
5
|
export declare const TRASH_MANIFEST_FILE = "manifest.json";
|
|
6
6
|
/** Sweeps older than this are reaped by the next sweep. Matches RETENTION_DAYS for the aged-tree sweep. */
|
|
7
7
|
export declare const TRASH_RETENTION_DAYS = 30;
|
|
8
8
|
/**
|
|
9
|
-
* Moves orphan directories into `.webpieces/trash/<sweepId>/` and records how to bring each one back.
|
|
9
|
+
* Moves orphan directories into `.webpieces-logs/trash/<sweepId>/` and records how to bring each one back.
|
|
10
10
|
*
|
|
11
11
|
* ─── WHY `mv` AND NEVER `rm -rf` ──────────────────────────────────────────────────────────────────────
|
|
12
12
|
* This runs unattended, on other people's machines, against a predicate that is very good but is still a
|
|
@@ -37,7 +37,7 @@ export declare class OrphanDirArchiver {
|
|
|
37
37
|
* flag on. This one really does delete — it is deleting the archive, which is the second copy.
|
|
38
38
|
*/
|
|
39
39
|
reapAged(repoRoot: string, now: Date): number;
|
|
40
|
-
/** `<repo>/.webpieces/trash` — the SHARED state dir, so a worktree's trash is not stranded with it. */
|
|
40
|
+
/** `<repo>/.webpieces-logs/trash` — the SHARED state dir, so a worktree's trash is not stranded with it. */
|
|
41
41
|
trashRoot(repoRoot: string): string;
|
|
42
42
|
/**
|
|
43
43
|
* `2026-08-19T14-32-05Z`. ISO order with `:` replaced, and milliseconds dropped — a sweep is a
|
|
@@ -52,7 +52,7 @@ export declare class OrphanDirArchiver {
|
|
|
52
52
|
* failure's message — a directory we cannot move is REPORTED and skipped, never fatal.
|
|
53
53
|
*
|
|
54
54
|
* `fs.renameSync` first because it is atomic and instant within a filesystem; a cross-device rename
|
|
55
|
-
* (EXDEV — a repo whose `.webpieces` sits on a different mount) falls back to a recursive copy plus
|
|
55
|
+
* (EXDEV — a repo whose `.webpieces-logs` sits on a different mount) falls back to a recursive copy plus
|
|
56
56
|
* delete, which is what `mv` itself does in the same situation.
|
|
57
57
|
*/
|
|
58
58
|
private move;
|
|
@@ -7,7 +7,7 @@ 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
|
const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
10
|
-
/** Where every sweep's archive lands, under the repo-wide `.webpieces/` — never under a worktree's own. */
|
|
10
|
+
/** Where every sweep's archive lands, under the repo-wide `.webpieces-logs/` — never under a worktree's own. */
|
|
11
11
|
exports.TRASH_STATE_DIR = 'trash';
|
|
12
12
|
/** The per-sweep manifest, holding what moved and the command that brings each one back. */
|
|
13
13
|
exports.TRASH_MANIFEST_FILE = 'manifest.json';
|
|
@@ -15,7 +15,7 @@ exports.TRASH_MANIFEST_FILE = 'manifest.json';
|
|
|
15
15
|
exports.TRASH_RETENTION_DAYS = 30;
|
|
16
16
|
const MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
17
17
|
/**
|
|
18
|
-
* Moves orphan directories into `.webpieces/trash/<sweepId>/` and records how to bring each one back.
|
|
18
|
+
* Moves orphan directories into `.webpieces-logs/trash/<sweepId>/` and records how to bring each one back.
|
|
19
19
|
*
|
|
20
20
|
* ─── WHY `mv` AND NEVER `rm -rf` ──────────────────────────────────────────────────────────────────────
|
|
21
21
|
* This runs unattended, on other people's machines, against a predicate that is very good but is still a
|
|
@@ -74,7 +74,7 @@ let OrphanDirArchiver = class OrphanDirArchiver {
|
|
|
74
74
|
}
|
|
75
75
|
return reaped;
|
|
76
76
|
}
|
|
77
|
-
/** `<repo>/.webpieces/trash` — the SHARED state dir, so a worktree's trash is not stranded with it. */
|
|
77
|
+
/** `<repo>/.webpieces-logs/trash` — the SHARED state dir, so a worktree's trash is not stranded with it. */
|
|
78
78
|
trashRoot(repoRoot) {
|
|
79
79
|
return path.join(tooling_common_1.dotWebpieces.shared(repoRoot), exports.TRASH_STATE_DIR);
|
|
80
80
|
}
|
|
@@ -111,7 +111,7 @@ let OrphanDirArchiver = class OrphanDirArchiver {
|
|
|
111
111
|
* failure's message — a directory we cannot move is REPORTED and skipped, never fatal.
|
|
112
112
|
*
|
|
113
113
|
* `fs.renameSync` first because it is atomic and instant within a filesystem; a cross-device rename
|
|
114
|
-
* (EXDEV — a repo whose `.webpieces` sits on a different mount) falls back to a recursive copy plus
|
|
114
|
+
* (EXDEV — a repo whose `.webpieces-logs` sits on a different mount) falls back to a recursive copy plus
|
|
115
115
|
* delete, which is what `mv` itself does in the same situation.
|
|
116
116
|
*/
|
|
117
117
|
move(from, to) {
|