@webpieces/rules-config 0.4.819 → 0.4.821

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/rules-config",
3
- "version": "0.4.819",
3
+ "version": "0.4.821",
4
4
  "description": "Shared webpieces.config.json loader. Single source of truth for validation rule configuration consumed by @webpieces/ai-hook-rules, @webpieces/code-rules, and @webpieces/nx-webpieces-rules.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -8,8 +8,8 @@ import { BaseRuleConfig, ModifiedCodeMode } from './rule-configs';
8
8
  *
9
9
  * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`): OFF |
10
10
  * NEW_AND_MODIFIED_CODE (only changed lines — grandfathers the rest) | NEW_AND_MODIFIED_FILES (every
11
- * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in each touched
12
- * project / the whole repo — #1027). `allowedPaths` exempts whole trees. The per-site escape hatch is
11
+ * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in a touched
12
+ * project / in the repo — #1027; count what is left with `wp-validate-code --rule=… --mode=RUN_EVERY_TIME`). `allowedPaths` exempts whole trees. The per-site escape hatch is
13
13
  * `// webpieces-disable no-inline-import-in-api-lib -- <reason>` on the line or the line above.
14
14
  */
15
15
  export declare class NoInlineImportInApiLibConfig extends BaseRuleConfig {
@@ -30,7 +30,7 @@ export declare class NoInlineImportInApiLibConfig extends BaseRuleConfig {
30
30
  * The GENERATOR keeps supporting string-literal unions — for other consumers, and for code this rule's
31
31
  * mode grandfathers. This rule is what forbids NEW ones in an api library.
32
32
  *
33
- * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same five
33
+ * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same three
34
34
  * values as above; `allowedPaths` and the per-site disable work the same way.
35
35
  */
36
36
  export declare class OneEnumSpellingInApiLibConfig extends BaseRuleConfig {
@@ -11,8 +11,8 @@ const rule_configs_1 = require("./rule-configs");
11
11
  *
12
12
  * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`): OFF |
13
13
  * NEW_AND_MODIFIED_CODE (only changed lines — grandfathers the rest) | NEW_AND_MODIFIED_FILES (every
14
- * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in each touched
15
- * project / the whole repo — #1027). `allowedPaths` exempts whole trees. The per-site escape hatch is
14
+ * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in a touched
15
+ * project / in the repo — #1027; count what is left with `wp-validate-code --rule=… --mode=RUN_EVERY_TIME`). `allowedPaths` exempts whole trees. The per-site escape hatch is
16
16
  * `// webpieces-disable no-inline-import-in-api-lib -- <reason>` on the line or the line above.
17
17
  */
18
18
  class NoInlineImportInApiLibConfig extends rule_configs_1.BaseRuleConfig {
@@ -37,7 +37,7 @@ exports.NoInlineImportInApiLibConfig = NoInlineImportInApiLibConfig;
37
37
  * The GENERATOR keeps supporting string-literal unions — for other consumers, and for code this rule's
38
38
  * mode grandfathers. This rule is what forbids NEW ones in an api library.
39
39
  *
40
- * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same five
40
+ * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same three
41
41
  * values as above; `allowedPaths` and the per-site disable work the same way.
42
42
  */
43
43
  class OneEnumSpellingInApiLibConfig extends rule_configs_1.BaseRuleConfig {
@@ -1 +1 @@
1
- {"version":3,"file":"api-lib-spelling-configs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/api-lib-spelling-configs.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AACpD,iDAAyG;AAEzG;;;;;;;;;;;GAWG;AACH,MAAa,4BAA6B,SAAQ,6BAAc;IAE5D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA8C;QAChE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,kCAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,+BAAgB;KACtB,CAAC;;AARN,oEASC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,6BAA8B,SAAQ,6BAAc;IAE7D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA+C;QACjE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,kCAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,+BAAgB;KACtB,CAAC;;AARN,sEASC","sourcesContent":["import { FieldDef, SchemaShape } from './field-def';\nimport { BaseRuleConfig, BASE_RULE_SCHEMA, ModifiedCodeMode, MODIFIED_CODE_MODES } from './rule-configs';\n\n/**\n * `no-inline-import-in-api-lib` (#1023) — in every `role:api-lib` project, refuse an `import('…')`\n * TYPE node (`activeAiProvider?: import('@myorg/company-core').AiProvider`) and a dynamic `import()`\n * EXPRESSION. An API imports at the top of the file, only: an inline import hides a cross-library\n * dependency from every reader of the contract and from the tools that read its imports.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`): OFF |\n * NEW_AND_MODIFIED_CODE (only changed lines — grandfathers the rest) | NEW_AND_MODIFIED_FILES (every\n * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in each touched\n * project / the whole repo — #1027). `allowedPaths` exempts whole trees. The per-site escape hatch is\n * `// webpieces-disable no-inline-import-in-api-lib -- <reason>` on the line or the line above.\n */\nexport class NoInlineImportInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoInlineImportInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n\n/**\n * `one-enum-spelling-in-api-lib` (#1023) — in every `role:api-lib` project, a fixed set of string\n * values has ONE spelling: a string `enum` whose every member is explicitly initialised with a string\n * literal (`export enum SpeakerGender { FEMALE = 'female', MALE = 'male' }`), used as the enum, one\n * member of it, or a union of its members. Refused, each with a cure that prints the enum to write:\n * a string-literal union of two or more members (in a type alias, a field or a parameter),\n * `(typeof X)[number]`, `keyof typeof X`, a single string-literal type used as a union discriminator,\n * and a numeric, heterogeneous, `const` or non-initialised enum (a numeric enum puts numbers on the\n * wire).\n *\n * The GENERATOR keeps supporting string-literal unions — for other consumers, and for code this rule's\n * mode grandfathers. This rule is what forbids NEW ones in an api library.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same five\n * values as above; `allowedPaths` and the per-site disable work the same way.\n */\nexport class OneEnumSpellingInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<OneEnumSpellingInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
1
+ {"version":3,"file":"api-lib-spelling-configs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/api-lib-spelling-configs.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AACpD,iDAAyG;AAEzG;;;;;;;;;;;GAWG;AACH,MAAa,4BAA6B,SAAQ,6BAAc;IAE5D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA8C;QAChE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,kCAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,+BAAgB;KACtB,CAAC;;AARN,oEASC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,6BAA8B,SAAQ,6BAAc;IAE7D,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAA+C;QACjE,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,kCAAmB,CAAC;QACjD,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,+BAAgB;KACtB,CAAC;;AARN,sEASC","sourcesContent":["import { FieldDef, SchemaShape } from './field-def';\nimport { BaseRuleConfig, BASE_RULE_SCHEMA, ModifiedCodeMode, MODIFIED_CODE_MODES } from './rule-configs';\n\n/**\n * `no-inline-import-in-api-lib` (#1023) — in every `role:api-lib` project, refuse an `import('…')`\n * TYPE node (`activeAiProvider?: import('@myorg/company-core').AiProvider`) and a dynamic `import()`\n * EXPRESSION. An API imports at the top of the file, only: an inline import hides a cross-library\n * dependency from every reader of the contract and from the tools that read its imports.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`): OFF |\n * NEW_AND_MODIFIED_CODE (only changed lines — grandfathers the rest) | NEW_AND_MODIFIED_FILES (every\n * occurrence in a changed file) | MODIFIED_PROJECTS / RUN_EVERY_TIME (every occurrence in a touched\n * project / in the repo — #1027; count what is left with `wp-validate-code --rule=… --mode=RUN_EVERY_TIME`). `allowedPaths` exempts whole trees. The per-site escape hatch is\n * `// webpieces-disable no-inline-import-in-api-lib -- <reason>` on the line or the line above.\n */\nexport class NoInlineImportInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoInlineImportInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n\n/**\n * `one-enum-spelling-in-api-lib` (#1023) — in every `role:api-lib` project, a fixed set of string\n * values has ONE spelling: a string `enum` whose every member is explicitly initialised with a string\n * literal (`export enum SpeakerGender { FEMALE = 'female', MALE = 'male' }`), used as the enum, one\n * member of it, or a union of its members. Refused, each with a cure that prints the enum to write:\n * a string-literal union of two or more members (in a type alias, a field or a parameter),\n * `(typeof X)[number]`, `keyof typeof X`, a single string-literal type used as a union discriminator,\n * and a numeric, heterogeneous, `const` or non-initialised enum (a numeric enum puts numbers on the\n * wire).\n *\n * The GENERATOR keeps supporting string-literal unions — for other consumers, and for code this rule's\n * mode grandfathers. This rule is what forbids NEW ones in an api library.\n *\n * `mode` is REQUIRED and has no default (`.claude/rules/no-rule-defaults.md`), with the same three\n * values as above; `allowedPaths` and the per-site disable work the same way.\n */\nexport class OneEnumSpellingInApiLibConfig extends BaseRuleConfig {\n declare mode?: ModifiedCodeMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<OneEnumSpellingInApiLibConfig> = {\n mode: new FieldDef('string', MODIFIED_CODE_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
@@ -6,7 +6,6 @@
6
6
  * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting
7
7
  * {@link DiffScope} over follow-up PRs, then the delegators are removed.
8
8
  */
9
- import { FileScope } from './file-scope';
10
9
  /** A git diff range: the base ref to compare against and an optional head (else the working tree). */
11
10
  export declare class DiffRange {
12
11
  base?: string;
@@ -27,46 +26,30 @@ export declare class ChangedFilesOptions {
27
26
  includeDeletions?: boolean;
28
27
  }
29
28
  export declare class DiffScope {
30
- /**
31
- * The {@link FileScope} the current async call chain runs inside. AsyncLocalStorage rather than a
32
- * field, because the free-function delegators below and every injected instance must see the SAME
33
- * scope, and because the scope must never leak past the one rule run that set it.
34
- */
35
- private static readonly active;
36
- /**
37
- * Run `work` with every getChangedFiles / getFileDiff call inside it answering for `scope` — the
38
- * one switch the whole-scope modes (#1027) and the debug run's `--projects` are built on.
39
- */
40
- within<T>(scope: FileScope, work: () => Promise<T>): Promise<T>;
41
- /** The scope the caller is running inside; plain DIFF outside any {@link within}. */
42
- currentScope(): FileScope;
43
- /**
44
- * Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. Under
45
- * RUN_EVERY_TIME the base is irrelevant to the file set, so an undetectable one falls back to HEAD
46
- * rather than making the rule skip.
47
- */
29
+ /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */
48
30
  detectBase(workspaceRoot: string): string | null;
49
- private detectMergeBase;
50
31
  /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */
51
32
  resolveBase(workspaceRoot: string): DiffRange;
52
33
  /**
53
- * The files a rule judges. Outside any {@link within} (and for the gate's plain diff scope) these are
54
- * the changed files between base and head (or base→working-tree when head is omitted), untracked
55
- * files unioned in for the working-tree case. Inside a widened {@link FileScope} they are the files
56
- * that scope selects — see file-scope.ts. `tsOnly` (default true) restricts to *.ts/*.tsx and drops
57
- * test files, in every scope. Deletions are excluded (`--diff-filter=d`).
34
+ * Changed files between base and head (or base→working-tree when head is omitted). Untracked files
35
+ * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and
36
+ * drops test files. Deletions are excluded (`--diff-filter=d`).
58
37
  */
59
38
  getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[];
60
- private everyChangedFile;
61
- private diffFiles;
62
39
  /**
63
- * Diff content for a single file (synthetic all-added diff for an untracked file with no head). Inside
64
- * a whole-scope {@link FileScope} every file is judged WHOLE, so the diff is the synthetic all-added
65
- * one for every file — a line- or method-scoped rule then sees the entire file as new.
40
+ * EVERY file in the working tree — tracked plus untracked-not-ignored, minus files deleted on disk —
41
+ * filtered exactly like {@link getChangedFiles} (`tsOnly` default true: *.ts/*.tsx, no test files).
42
+ * The file set of the whole-scope modes (#1027): RUN_EVERY_TIME judges all of it, MODIFIED_PROJECTS the
43
+ * part owned by a touched project. Git, not a directory walk, so `.gitignore` (node_modules, dist)
44
+ * is honoured for free.
45
+ *
46
+ * Unlike getChangedFiles it does NOT swallow a git failure into an empty list: an empty whole-scope
47
+ * listing reads as "0 sites left", a false answer to exactly the question these modes exist to
48
+ * answer, so a failed `git ls-files` throws and fails the run.
66
49
  */
50
+ getAllFiles(workspaceRoot: string, opts?: ChangedFilesOptions): string[];
51
+ /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */
67
52
  getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string;
68
- private allAddedDiff;
69
- private realFileDiff;
70
53
  /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */
71
54
  getChangedLineNumbers(diffContent: string): Set<number>;
72
55
  /** Method names whose signature line is a `+` addition in the diff — the basis of "NEW" methods. */
package/src/diff-scope.js CHANGED
@@ -7,7 +7,6 @@
7
7
  * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting
8
8
  * {@link DiffScope} over follow-up PRs, then the delegators are removed.
9
9
  */
10
- var DiffScope_1;
11
10
  Object.defineProperty(exports, "__esModule", { value: true });
12
11
  exports.DiffScope = exports.ChangedFilesOptions = exports.DiffRange = void 0;
13
12
  exports.detectBase = detectBase;
@@ -19,12 +18,10 @@ exports.findNewMethodSignaturesInDiff = findNewMethodSignaturesInDiff;
19
18
  exports.hasChangesInRange = hasChangesInRange;
20
19
  exports.isNewOrModified = isNewOrModified;
21
20
  const tslib_1 = require("tslib");
22
- const async_hooks_1 = require("async_hooks");
23
21
  const child_process_1 = require("child_process");
24
22
  const fs = tslib_1.__importStar(require("fs"));
25
23
  const path = tslib_1.__importStar(require("path"));
26
24
  const inversify_1 = require("inversify");
27
- const file_scope_1 = require("./file-scope");
28
25
  const to_error_1 = require("./to-error");
29
26
  /** A git diff range: the base ref to compare against and an optional head (else the working tree). */
30
27
  class DiffRange {
@@ -48,36 +45,8 @@ class ChangedFilesOptions {
48
45
  }
49
46
  exports.ChangedFilesOptions = ChangedFilesOptions;
50
47
  let DiffScope = class DiffScope {
51
- static { DiffScope_1 = this; }
52
- /**
53
- * The {@link FileScope} the current async call chain runs inside. AsyncLocalStorage rather than a
54
- * field, because the free-function delegators below and every injected instance must see the SAME
55
- * scope, and because the scope must never leak past the one rule run that set it.
56
- */
57
- static active = new async_hooks_1.AsyncLocalStorage();
58
- /**
59
- * Run `work` with every getChangedFiles / getFileDiff call inside it answering for `scope` — the
60
- * one switch the whole-scope modes (#1027) and the debug run's `--projects` are built on.
61
- */
62
- within(scope, work) {
63
- return DiffScope_1.active.run(scope, work);
64
- }
65
- /** The scope the caller is running inside; plain DIFF outside any {@link within}. */
66
- currentScope() {
67
- return DiffScope_1.active.getStore() ?? file_scope_1.FileScope.DIFF;
68
- }
69
- /**
70
- * Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. Under
71
- * RUN_EVERY_TIME the base is irrelevant to the file set, so an undetectable one falls back to HEAD
72
- * rather than making the rule skip.
73
- */
48
+ /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */
74
49
  detectBase(workspaceRoot) {
75
- const detected = this.detectMergeBase(workspaceRoot);
76
- if (detected === null && this.currentScope().kind === 'RUN_EVERY_TIME')
77
- return 'HEAD';
78
- return detected;
79
- }
80
- detectMergeBase(workspaceRoot) {
81
50
  for (const ref of ['origin/main', 'main']) {
82
51
  // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
83
52
  try {
@@ -105,29 +74,12 @@ let DiffScope = class DiffScope {
105
74
  return range;
106
75
  }
107
76
  /**
108
- * The files a rule judges. Outside any {@link within} (and for the gate's plain diff scope) these are
109
- * the changed files between base and head (or base→working-tree when head is omitted), untracked
110
- * files unioned in for the working-tree case. Inside a widened {@link FileScope} they are the files
111
- * that scope selects — see file-scope.ts. `tsOnly` (default true) restricts to *.ts/*.tsx and drops
112
- * test files, in every scope. Deletions are excluded (`--diff-filter=d`).
77
+ * Changed files between base and head (or base→working-tree when head is omitted). Untracked files
78
+ * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and
79
+ * drops test files. Deletions are excluded (`--diff-filter=d`).
113
80
  */
114
- getChangedFiles(workspaceRoot, base, head, opts) {
115
- const scope = this.currentScope();
116
- const diffFiles = this.diffFiles(workspaceRoot, base, head, opts);
117
- if (scope.isPlainDiff())
118
- return diffFiles;
119
- const tsOnly = opts?.tsOnly ?? true;
120
- return new file_scope_1.ScopedFileSelector().select(workspaceRoot, scope, diffFiles, () => this.diffFiles(workspaceRoot, base, head, this.everyChangedFile()), tsOnly ? ['*.ts', '*.tsx'] : [], (f) => !tsOnly || !this.isTestFile(f));
121
- }
122
- // "Which projects did the diff touch" counts ANY changed file — a project.json, a README — not only
123
- // the files the rule itself judges.
124
- everyChangedFile() {
125
- const opts = new ChangedFilesOptions();
126
- opts.tsOnly = false;
127
- return opts;
128
- }
129
81
  // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths
130
- diffFiles(workspaceRoot, base, head, opts) {
82
+ getChangedFiles(workspaceRoot, base, head, opts) {
131
83
  const tsOnly = opts?.tsOnly ?? true;
132
84
  const glob = tsOnly ? " -- '*.ts' '*.tsx'" : '';
133
85
  const keep = (f) => f.length > 0 && (!tsOnly || !this.isTestFile(f));
@@ -168,24 +120,29 @@ let DiffScope = class DiffScope {
168
120
  }
169
121
  }
170
122
  /**
171
- * Diff content for a single file (synthetic all-added diff for an untracked file with no head). Inside
172
- * a whole-scope {@link FileScope} every file is judged WHOLE, so the diff is the synthetic all-added
173
- * one for every file — a line- or method-scoped rule then sees the entire file as new.
123
+ * EVERY file in the working tree — tracked plus untracked-not-ignored, minus files deleted on disk —
124
+ * filtered exactly like {@link getChangedFiles} (`tsOnly` default true: *.ts/*.tsx, no test files).
125
+ * The file set of the whole-scope modes (#1027): RUN_EVERY_TIME judges all of it, MODIFIED_PROJECTS the
126
+ * part owned by a touched project. Git, not a directory walk, so `.gitignore` (node_modules, dist)
127
+ * is honoured for free.
128
+ *
129
+ * Unlike getChangedFiles it does NOT swallow a git failure into an empty list: an empty whole-scope
130
+ * listing reads as "0 sites left", a false answer to exactly the question these modes exist to
131
+ * answer, so a failed `git ls-files` throws and fails the run.
174
132
  */
175
- getFileDiff(workspaceRoot, file, base, head) {
176
- if (this.currentScope().isWhole())
177
- return this.allAddedDiff(workspaceRoot, file);
178
- return this.realFileDiff(workspaceRoot, file, base, head);
179
- }
180
- allAddedDiff(workspaceRoot, file) {
181
- const fullPath = path.join(workspaceRoot, file);
182
- if (!fs.existsSync(fullPath))
183
- return '';
184
- const lines = fs.readFileSync(fullPath, 'utf-8').split('\n');
185
- // A real hunk header, so getChangedLineNumbers numbers the lines from 1 like any git diff.
186
- return [`@@ -0,0 +1,${lines.length} @@`, ...lines.map((l) => `+${l}`)].join('\n');
133
+ getAllFiles(workspaceRoot, opts) {
134
+ const tsOnly = opts?.tsOnly ?? true;
135
+ const glob = tsOnly ? " -- '*.ts' '*.tsx'" : '';
136
+ const output = (0, child_process_1.execSync)(`git ls-files --cached --others --exclude-standard${glob}`, {
137
+ cwd: workspaceRoot,
138
+ encoding: 'utf-8',
139
+ maxBuffer: 256 * 1024 * 1024,
140
+ });
141
+ const keep = (f) => f.length > 0 && (!tsOnly || !this.isTestFile(f)) && fs.existsSync(path.join(workspaceRoot, f));
142
+ return Array.from(new Set(output.trim().split('\n').filter(keep)));
187
143
  }
188
- realFileDiff(workspaceRoot, file, base, head) {
144
+ /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */
145
+ getFileDiff(workspaceRoot, file, base, head) {
189
146
  // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
190
147
  try {
191
148
  const diffTarget = head ? `${base} ${head}` : base;
@@ -286,7 +243,7 @@ let DiffScope = class DiffScope {
286
243
  }
287
244
  };
288
245
  exports.DiffScope = DiffScope;
289
- exports.DiffScope = DiffScope = DiffScope_1 = tslib_1.__decorate([
246
+ exports.DiffScope = DiffScope = tslib_1.__decorate([
290
247
  (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
291
248
  ], DiffScope);
292
249
  // Temporary migration delegators to DiffScope — removed once consumers inject it.
@@ -1 +1 @@
1
- {"version":3,"file":"diff-scope.js","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AAC,aAAa,CAAC,CAAC;AACnD,CAAC;AAED,gIAAgI;AAChI,SAAgB,eAAe,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa,EAAE,IAA0B;IAC1G,OAAO,YAAY,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzE,CAAC;AAED,gIAAgI;AAChI,SAAgB,WAAW,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAY,EAAE,IAAa;IACxF,OAAO,YAAY,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACrE,CAAC;AAED,gIAAgI;AAChI,SAAgB,qBAAqB,CAAC,WAAmB;IACrD,OAAO,YAAY,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,gIAAgI;AAChI,SAAgB,6BAA6B,CAAC,WAAmB;IAC7D,OAAO,YAAY,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,gIAAgI;AAChI,SAAgB,iBAAiB,CAAC,SAAiB,EAAE,OAAe,EAAE,YAAyB;IAC3F,OAAO,YAAY,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC5E,CAAC;AAED,gIAAgI;AAChI,SAAgB,eAAe,CAC3B,IAAY,EACZ,SAAiB,EACjB,OAAe,EACf,YAAyB,EACzB,cAA2B;IAE3B,OAAO,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAChG,CAAC","sourcesContent":["/**\n * Shared git-diff + diff-scoping service for ALL rule validators (code-rules) and nx executors\n * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both depend on.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it can be injected and appear in the rules-config DI design. Free-function\n * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting\n * {@link DiffScope} over follow-up PRs, then the delegators are removed.\n */\n\nimport { AsyncLocalStorage } from 'async_hooks';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { FileScope, ScopedFileSelector } from './file-scope';\nimport { toError } from './to-error';\n\n/** A git diff range: the base ref to compare against and an optional head (else the working tree). */\nexport class DiffRange {\n base?: string;\n head?: string;\n}\n\n/** Options for getChangedFiles. `tsOnly` (default true) restricts to *.ts/*.tsx and drops test files. */\nexport class ChangedFilesOptions {\n tsOnly?: boolean;\n /**\n * Include DELETED files in the result. Default false, which is `--diff-filter=d` — the historical\n * behavior, kept as the default so every existing caller is byte-identical.\n *\n * The default is right for lint validators (you cannot lint a file that is gone) and WRONG for checklist\n * matching: a PR that DELETES a migration, an auth check or a terraform rule changed exactly the thing a\n * checklist exists to catch, and dropping it from the changed-file set means the checklist never fires\n * and no reviewer is ever asked. The review flow sets this true.\n */\n includeDeletions?: boolean;\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class DiffScope {\n /**\n * The {@link FileScope} the current async call chain runs inside. AsyncLocalStorage rather than a\n * field, because the free-function delegators below and every injected instance must see the SAME\n * scope, and because the scope must never leak past the one rule run that set it.\n */\n private static readonly active = new AsyncLocalStorage<FileScope>();\n\n /**\n * Run `work` with every getChangedFiles / getFileDiff call inside it answering for `scope` — the\n * one switch the whole-scope modes (#1027) and the debug run's `--projects` are built on.\n */\n within<T>(scope: FileScope, work: () => Promise<T>): Promise<T> {\n return DiffScope.active.run(scope, work);\n }\n\n /** The scope the caller is running inside; plain DIFF outside any {@link within}. */\n currentScope(): FileScope {\n return DiffScope.active.getStore() ?? FileScope.DIFF;\n }\n\n /**\n * Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. Under\n * RUN_EVERY_TIME the base is irrelevant to the file set, so an undetectable one falls back to HEAD\n * rather than making the rule skip.\n */\n detectBase(workspaceRoot: string): string | null {\n const detected = this.detectMergeBase(workspaceRoot);\n if (detected === null && this.currentScope().kind === 'RUN_EVERY_TIME') return 'HEAD';\n return detected;\n }\n\n private detectMergeBase(workspaceRoot: string): string | null {\n for (const ref of ['origin/main', 'main']) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const merged = execSync(`git merge-base HEAD ${ref}`, {\n cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n if (merged) return merged;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — try the next ref\n }\n }\n return null;\n }\n\n /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */\n resolveBase(workspaceRoot: string): DiffRange {\n const range = new DiffRange();\n range.base = process.env['NX_BASE'];\n range.head = process.env['NX_HEAD'];\n if (!range.base) {\n range.base = this.detectBase(workspaceRoot) ?? undefined;\n }\n return range;\n }\n\n /**\n * The files a rule judges. Outside any {@link within} (and for the gate's plain diff scope) these are\n * the changed files between base and head (or base→working-tree when head is omitted), untracked\n * files unioned in for the working-tree case. Inside a widened {@link FileScope} they are the files\n * that scope selects — see file-scope.ts. `tsOnly` (default true) restricts to *.ts/*.tsx and drops\n * test files, in every scope. Deletions are excluded (`--diff-filter=d`).\n */\n getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n const scope = this.currentScope();\n const diffFiles = this.diffFiles(workspaceRoot, base, head, opts);\n if (scope.isPlainDiff()) return diffFiles;\n const tsOnly = opts?.tsOnly ?? true;\n return new ScopedFileSelector().select(\n workspaceRoot,\n scope,\n diffFiles,\n () => this.diffFiles(workspaceRoot, base, head, this.everyChangedFile()),\n tsOnly ? ['*.ts', '*.tsx'] : [],\n (f: string) => !tsOnly || !this.isTestFile(f),\n );\n }\n\n // \"Which projects did the diff touch\" counts ANY changed file — a project.json, a README — not only\n // the files the rule itself judges.\n private everyChangedFile(): ChangedFilesOptions {\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n return opts;\n }\n\n // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths\n private diffFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n const tsOnly = opts?.tsOnly ?? true;\n const glob = tsOnly ? \" -- '*.ts' '*.tsx'\" : '';\n const keep = (f: string): boolean => f.length > 0 && (!tsOnly || !this.isTestFile(f));\n // Deletions are excluded by default (see ChangedFilesOptions.includeDeletions) — the review flow\n // opts in, every lint validator keeps the historical filter.\n const filter = opts?.includeDeletions === true ? '' : ' --diff-filter=d';\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only${filter} ${diffTarget}${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output.trim().split('\\n').filter(keep);\n\n // Working-tree comparison (no head): also include untracked files, as nx affected does.\n if (!head) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput.trim().split('\\n').filter(keep);\n return Array.from(new Set([...changedFiles, ...untrackedFiles]));\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — ls-files failure falls back to the tracked list\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns an empty list\n return [];\n }\n }\n\n /**\n * Diff content for a single file (synthetic all-added diff for an untracked file with no head). Inside\n * a whole-scope {@link FileScope} every file is judged WHOLE, so the diff is the synthetic all-added\n * one for every file — a line- or method-scoped rule then sees the entire file as new.\n */\n getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n if (this.currentScope().isWhole()) return this.allAddedDiff(workspaceRoot, file);\n return this.realFileDiff(workspaceRoot, file, base, head);\n }\n\n private allAddedDiff(workspaceRoot: string, file: string): string {\n const fullPath = path.join(workspaceRoot, file);\n if (!fs.existsSync(fullPath)) return '';\n const lines = fs.readFileSync(fullPath, 'utf-8').split('\\n');\n // A real hunk header, so getChangedLineNumbers numbers the lines from 1 like any git diff.\n return [`@@ -0,0 +1,${lines.length} @@`, ...lines.map((l: string) => `+${l}`)].join('\\n');\n }\n\n private realFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n return content.split('\\n').map((l: string) => `+${l}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns no diff\n return '';\n }\n }\n\n /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */\n getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't advance the new-file line counter.\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n }\n\n /** Method names whose signature line is a `+` addition in the diff — the basis of \"NEW\" methods. */\n findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n }\n\n /** True if any line in [startLine, endLine] is in the changedLines set. */\n hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n for (let line = startLine; line <= endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n }\n\n /** True if a node (method/function) is newly added or has any changed line in its range. */\n isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n ): boolean {\n if (newMethodNames.has(name)) return true;\n return this.hasChangesInRange(startLine, endLine, changedLines);\n }\n\n // A file is \"a test file\" (excluded from diff-scoped rules) when it is a .spec/.test file or lives\n // under a __tests__/ directory.\n private isTestFile(file: string): boolean {\n return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');\n }\n}\n\n// Temporary migration delegators to DiffScope — removed once consumers inject it.\nconst diffScopeSvc = new DiffScope();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function detectBase(workspaceRoot: string): string | null {\n return diffScopeSvc.detectBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function resolveBase(workspaceRoot: string): DiffRange {\n return diffScopeSvc.resolveBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n return diffScopeSvc.getChangedFiles(workspaceRoot, base, head, opts);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n return diffScopeSvc.getFileDiff(workspaceRoot, file, base, head);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedLineNumbers(diffContent: string): Set<number> {\n return diffScopeSvc.getChangedLineNumbers(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n return diffScopeSvc.findNewMethodSignaturesInDiff(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n return diffScopeSvc.hasChangesInRange(startLine, endLine, changedLines);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n): boolean {\n return diffScopeSvc.isNewOrModified(name, startLine, endLine, changedLines, newMethodNames);\n}\n"]}
1
+ {"version":3,"file":"diff-scope.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/diff-scope.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA6PH,gCAEC;AAGD,kCAEC;AAGD,0CAEC;AAGD,kCAEC;AAGD,sDAEC;AAGD,sEAEC;AAGD,8CAEC;AA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AAmB;IACrD,OAAO,YAAY,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,gIAAgI;AAChI,SAAgB,6BAA6B,CAAC,WAAmB;IAC7D,OAAO,YAAY,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;AACnE,CAAC;AAED,gIAAgI;AAChI,SAAgB,iBAAiB,CAAC,SAAiB,EAAE,OAAe,EAAE,YAAyB;IAC3F,OAAO,YAAY,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC5E,CAAC;AAED,gIAAgI;AAChI,SAAgB,eAAe,CAC3B,IAAY,EACZ,SAAiB,EACjB,OAAe,EACf,YAAyB,EACzB,cAA2B;IAE3B,OAAO,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;AAChG,CAAC","sourcesContent":["/**\n * Shared git-diff + diff-scoping service for ALL rule validators (code-rules) and nx executors\n * (nx-webpieces-rules). Centralized here in rules-config because it is the one package both depend on.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it can be injected and appear in the rules-config DI design. Free-function\n * delegators are kept temporarily so the many existing consumers stay green; they migrate to injecting\n * {@link DiffScope} over follow-up PRs, then the delegators are removed.\n */\n\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { toError } from './to-error';\n\n/** A git diff range: the base ref to compare against and an optional head (else the working tree). */\nexport class DiffRange {\n base?: string;\n head?: string;\n}\n\n/** Options for getChangedFiles. `tsOnly` (default true) restricts to *.ts/*.tsx and drops test files. */\nexport class ChangedFilesOptions {\n tsOnly?: boolean;\n /**\n * Include DELETED files in the result. Default false, which is `--diff-filter=d` — the historical\n * behavior, kept as the default so every existing caller is byte-identical.\n *\n * The default is right for lint validators (you cannot lint a file that is gone) and WRONG for checklist\n * matching: a PR that DELETES a migration, an auth check or a terraform rule changed exactly the thing a\n * checklist exists to catch, and dropping it from the changed-file set means the checklist never fires\n * and no reviewer is ever asked. The review flow sets this true.\n */\n includeDeletions?: boolean;\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class DiffScope {\n /** Auto-detect the diff base: merge-base of HEAD with origin/main, falling back to local main. */\n detectBase(workspaceRoot: string): string | null {\n for (const ref of ['origin/main', 'main']) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const merged = execSync(`git merge-base HEAD ${ref}`, {\n cwd: workspaceRoot, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n if (merged) return merged;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — try the next ref\n }\n }\n return null;\n }\n\n /** Resolve the diff range a rule should compare against (honors nx's NX_BASE / NX_HEAD). */\n resolveBase(workspaceRoot: string): DiffRange {\n const range = new DiffRange();\n range.base = process.env['NX_BASE'];\n range.head = process.env['NX_HEAD'];\n if (!range.base) {\n range.base = this.detectBase(workspaceRoot) ?? undefined;\n }\n return range;\n }\n\n /**\n * Changed files between base and head (or base→working-tree when head is omitted). Untracked files\n * are unioned in for the working-tree case. `tsOnly` (default true) restricts to *.ts/*.tsx and\n * drops test files. Deletions are excluded (`--diff-filter=d`).\n */\n // webpieces-disable max-lines-new-methods -- git command handling with untracked files needs several code paths\n getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n const tsOnly = opts?.tsOnly ?? true;\n const glob = tsOnly ? \" -- '*.ts' '*.tsx'\" : '';\n const keep = (f: string): boolean => f.length > 0 && (!tsOnly || !this.isTestFile(f));\n // Deletions are excluded by default (see ChangedFilesOptions.includeDeletions) — the review flow\n // opts in, every lint validator keeps the historical filter.\n const filter = opts?.includeDeletions === true ? '' : ' --diff-filter=d';\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only${filter} ${diffTarget}${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output.trim().split('\\n').filter(keep);\n\n // Working-tree comparison (no head): also include untracked files, as nx affected does.\n if (!head) {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput.trim().split('\\n').filter(keep);\n return Array.from(new Set([...changedFiles, ...untrackedFiles]));\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — ls-files failure falls back to the tracked list\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns an empty list\n return [];\n }\n }\n\n /**\n * EVERY file in the working tree — tracked plus untracked-not-ignored, minus files deleted on disk —\n * filtered exactly like {@link getChangedFiles} (`tsOnly` default true: *.ts/*.tsx, no test files).\n * The file set of the whole-scope modes (#1027): RUN_EVERY_TIME judges all of it, MODIFIED_PROJECTS the\n * part owned by a touched project. Git, not a directory walk, so `.gitignore` (node_modules, dist)\n * is honoured for free.\n *\n * Unlike getChangedFiles it does NOT swallow a git failure into an empty list: an empty whole-scope\n * listing reads as \"0 sites left\", a false answer to exactly the question these modes exist to\n * answer, so a failed `git ls-files` throws and fails the run.\n */\n getAllFiles(workspaceRoot: string, opts?: ChangedFilesOptions): string[] {\n const tsOnly = opts?.tsOnly ?? true;\n const glob = tsOnly ? \" -- '*.ts' '*.tsx'\" : '';\n const output = execSync(`git ls-files --cached --others --exclude-standard${glob}`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n maxBuffer: 256 * 1024 * 1024,\n });\n const keep = (f: string): boolean =>\n f.length > 0 && (!tsOnly || !this.isTestFile(f)) && fs.existsSync(path.join(workspaceRoot, f));\n return Array.from(new Set(output.trim().split('\\n').filter(keep)));\n }\n\n /** Diff content for a single file (synthetic all-added diff for an untracked file with no head). */\n getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n return content.split('\\n').map((l: string) => `+${l}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // swallow — git diff failure returns no diff\n return '';\n }\n }\n\n /** Added/changed line numbers (the `+` lines per hunk) — basis of NEW_AND_MODIFIED_CODE scoping. */\n getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't advance the new-file line counter.\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n }\n\n /** Method names whose signature line is a `+` addition in the diff — the basis of \"NEW\" methods. */\n findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n const newMethods = new Set<string>();\n const lines = diffContent.split('\\n');\n\n const patterns = [\n /^\\+\\s*(?:export\\s+)?(?:async\\s+)?function\\s+(\\w+)\\s*\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s*)?\\(/,\n /^\\+\\s*(?:export\\s+)?(?:const|let)\\s+(\\w+)\\s*=\\s*(?:async\\s+)?function/,\n /^\\+\\s*(?:(?:public|private|protected)\\s+)?(?:static\\s+)?(?:async\\s+)?(\\w+)\\s*\\(/,\n ];\n\n for (const line of lines) {\n if (line.startsWith('+') && !line.startsWith('+++')) {\n for (const pattern of patterns) {\n const match = line.match(pattern);\n if (match) {\n const methodName = match[1];\n if (methodName && !['if', 'for', 'while', 'switch', 'catch', 'constructor'].includes(methodName)) {\n newMethods.add(methodName);\n }\n break;\n }\n }\n }\n }\n\n return newMethods;\n }\n\n /** True if any line in [startLine, endLine] is in the changedLines set. */\n hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n for (let line = startLine; line <= endLine; line++) {\n if (changedLines.has(line)) {\n return true;\n }\n }\n return false;\n }\n\n /** True if a node (method/function) is newly added or has any changed line in its range. */\n isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n ): boolean {\n if (newMethodNames.has(name)) return true;\n return this.hasChangesInRange(startLine, endLine, changedLines);\n }\n\n // A file is \"a test file\" (excluded from diff-scoped rules) when it is a .spec/.test file or lives\n // under a __tests__/ directory.\n private isTestFile(file: string): boolean {\n return file.includes('.spec.ts') || file.includes('.test.ts') || file.includes('__tests__/');\n }\n}\n\n// Temporary migration delegators to DiffScope — removed once consumers inject it.\nconst diffScopeSvc = new DiffScope();\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function detectBase(workspaceRoot: string): string | null {\n return diffScopeSvc.detectBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function resolveBase(workspaceRoot: string): DiffRange {\n return diffScopeSvc.resolveBase(workspaceRoot);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedFiles(workspaceRoot: string, base: string, head?: string, opts?: ChangedFilesOptions): string[] {\n return diffScopeSvc.getChangedFiles(workspaceRoot, base, head, opts);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n return diffScopeSvc.getFileDiff(workspaceRoot, file, base, head);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function getChangedLineNumbers(diffContent: string): Set<number> {\n return diffScopeSvc.getChangedLineNumbers(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function findNewMethodSignaturesInDiff(diffContent: string): Set<string> {\n return diffScopeSvc.findNewMethodSignaturesInDiff(diffContent);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function hasChangesInRange(startLine: number, endLine: number, changedLines: Set<number>): boolean {\n return diffScopeSvc.hasChangesInRange(startLine, endLine, changedLines);\n}\n\n// webpieces-disable no-function-outside-class -- temporary back-compat delegator to DiffScope; removed once consumers inject it\nexport function isNewOrModified(\n name: string,\n startLine: number,\n endLine: number,\n changedLines: Set<number>,\n newMethodNames: Set<string>,\n): boolean {\n return diffScopeSvc.isNewOrModified(name, startLine, endLine, changedLines, newMethodNames);\n}\n"]}
package/src/index.d.ts CHANGED
@@ -41,15 +41,13 @@ export { OrphanDirArchiver, ArchivedOrphan, FailedOrphan, OrphanSweepResult, Orp
41
41
  export { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';
42
42
  export { MatchRuleConfig, MatchRuleViolation, findMatchRuleViolations, isMatchRuleAllowedPath, compileMatchRulePatterns, renderMatchRuleMessage, DEFAULT_MATCH_RULES, } from './match-rules-config';
43
43
  export type { ConfigSection } from './sections';
44
- export { schemaFieldNames, schemaModeValues } from './rule-schemas';
44
+ export { schemaFieldNames, RULE_SCHEMAS } from './rule-schemas';
45
45
  export { HOOK_GUARD_NAMES, BRANCH_STATE_GUARD_KEY, PR_LIFECYCLE_GUARD_KEY, isHookGuard, sectionForRule, } from './sections';
46
46
  export { FieldDef } from './field-def';
47
47
  export type { SchemaShape } from './field-def';
48
- export { shouldSkipRule, getCurrentBranch } from './skip-rule';
48
+ export { shouldSkipRule, BranchIdentity, HOTFIX_BRANCH_SEGMENT, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';
49
49
  export { SkipRuleResult } from './skip-rule';
50
50
  export { detectBase, resolveBase, getChangedFiles, getFileDiff, getChangedLineNumbers, findNewMethodSignaturesInDiff, hasChangesInRange, isNewOrModified, DiffScope, DiffRange, ChangedFilesOptions, } from './diff-scope';
51
- export { FileScope, ProjectIndex, WholeScopeModes } from './file-scope';
52
- export type { FileScopeKind } from './file-scope';
53
51
  export { AbstractRule } from './abstract-rule';
54
52
  export { WEBPIECES_DISABLE, RULE_NAMES, hasDisable, WEBPIECES_TMP_DIR, MERGE_INFO_DIR, PR_REVIEW_DIR, MERGE_IN_PROGRESS_FILE, MERGE_EXPLANATION_FILE, PUSH_DEV_STATE_FILE, PRUNE_UNKNOWN_COMMAND, UPGRADE_SHIM_COMMAND, } from './constants';
55
53
  export { WebpiecesRulesConfig } from './WebpiecesRulesConfig';
@@ -61,11 +59,11 @@ export { NoUtilityTypesInApiLibConfig } from './no-utility-types-config';
61
59
  export { RequiredTypeSuffixConfig, RequiredTypeSuffixEntry } from './required-type-suffix-config';
62
60
  export { ApiRulesForMcpConfig, ApiRulesForOpenApiConfig, API_DOC_MODES } from './api-doc-rules-config';
63
61
  export type { ApiDocMode } from './api-doc-rules-config';
64
- export { METHOD_LIMIT_MODES, FILE_LIMIT_MODES, RETURN_TYPE_MODES, INLINE_TYPE_MODES, MODIFIED_CODE_MODES, PROJECT_MODES, PRISMA_DTOS_MODES, PRISMA_CONVERTER_MODES, DIRECT_API_RESOLVER_MODES, THROW_CAUSE_MODES, ON_OFF_MODES, STRUCTURAL_MODES, VALIDATE_TS_MODES, WHOLE_SCOPE_MODES, NO_JS_FILES_MODES, } from './rule-configs';
62
+ export { METHOD_LIMIT_MODES, FILE_LIMIT_MODES, RETURN_TYPE_MODES, INLINE_TYPE_MODES, MODIFIED_CODE_MODES, PROJECT_MODES, PRISMA_DTOS_MODES, PRISMA_CONVERTER_MODES, DIRECT_API_RESOLVER_MODES, THROW_CAUSE_MODES, ON_OFF_MODES, STRUCTURAL_MODES, VALIDATE_TS_MODES, } from './rule-configs';
65
63
  export { NoClientCreationOutsideServerOrClientConfig, CLIENT_CREATION_SEVERITIES, } from './no-client-creation-config';
66
64
  export type { ClientCreationSeverity } from './no-client-creation-config';
67
65
  export { NoStatePathsInTemplatesConfig, DEFAULT_TEMPLATE_DIRS, DEFAULT_BANNED_STATE_PATH_PREFIXES, } from './no-state-paths-config';
68
- export type { MethodLimitMode, FileLimitMode, ReturnTypeMode, InlineTypeMode, ModifiedCodeMode, ProjectMode, PrismaValidateDtosMode, PrismaConverterMode, DirectApiResolverMode, ThrowCauseMode, OnOffMode, StructuralMode, ValidateTsMode, WholeScopeMode, NoJsFilesMode, } from './rule-configs';
66
+ export type { MethodLimitMode, FileLimitMode, ReturnTypeMode, InlineTypeMode, ModifiedCodeMode, ProjectMode, PrismaValidateDtosMode, PrismaConverterMode, DirectApiResolverMode, ThrowCauseMode, OnOffMode, StructuralMode, ValidateTsMode, } from './rule-configs';
69
67
  export { BranchStateGuardConfig, DEFAULT_MAX_COMMITS_BEHIND } from './main-sync-guard-configs';
70
68
  export { GateDefinition, PrGateConfig, DEFAULT_BUILD_COMMAND, LandPrConfig, DevDeployConfig, DEFAULT_DEV_BRANCH_NAMESPACE, DEFAULT_DEV_BRANCH, ReviewContextEntry, defaultGates, defaultPrGateConfig, defaultLandPrConfig, defaultDevDeployConfig, buildPrGateConfig, buildLandPrConfig, buildDevDeployConfig, MERGE_MODE_AUTO, MERGE_MODE_NONE, MERGE_MODES, } from './pr-gate-config';
71
69
  export { ChecklistDefinition, ReviewerAgentPolicy, REVIEWER_AGENTS_PLACEHOLDER, DEFAULT_REVIEWER_AGENT_NAME, toChecklist, normalizeChecklistDoc, formatFileList, } from './checklist-config';
package/src/index.js CHANGED
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RulesConfigDesign = exports.atRoot = exports.AtomicFile = exports.CLAUDE_PROJECT_DIR_UNSET = exports.CLAUDE_PROJECT_DIR_ENV = exports.claudeEnv = exports.ClaudeEnv = exports.RETENTION_DAYS = exports.SweepCount = exports.AgedTreeSweeper = exports.StateMigrationReport = exports.StateDirMigrator = exports.LOGS_STATE_DIR = exports.WORKTREE_STATE_DIR = exports.GitDirs = exports.dotWebpieces = exports.DotWebpieces = exports.INSTRUCT_AI_LEAF = exports.INSTRUCT_AI_DIR = exports.RepoRootFinder = exports.CONFIG_PARSE_RETRY_MILLIS = exports.CONFIG_PARSE_ATTEMPTS = exports.ConfigParseAttempt = exports.ConfigFile = exports.CONFIG_FILENAME = exports.findConfigFile = exports.SECTION_PLACEMENT_MARKER = exports.RETIRED_TOP_LEVEL_MARKER = exports.RETIRED_KEY_MARKER = exports.CONFIG_POLICY_DOC = exports.formatConfigErrorsBanner = exports.ConfigLoader = exports.LoadedConfig = exports.loadAndValidate = exports.toError = exports.runMain = exports.CliArgs = exports.CliArgsCheck = exports.CliArgSet = exports.CliFlag = exports.CliUsage = exports.CliExitError = exports.formatFixOptions = exports.Option = exports.renderRuleFailForHuman = exports.renderRuleFailForAi = exports.RuleFailError = exports.InformAiError = exports.ResolvedRuleConfig = exports.ResolvedConfig = void 0;
4
4
  exports.ConfigPruner = exports.retiredRuleFor = exports.retiredKeyErrorsIn = exports.retiredKeyError = exports.retiredEntry = exports.isRetiredKey = exports.RetiredConfigKey = exports.RETIRED_SCOPE_RULE = exports.RETIRED_SCOPE_KEY = exports.RETIRED_CONFIG_KEYS = exports.COMMENT_KEY_SUFFIX = exports.validateTopLevelKeys = exports.isCommentKey = exports.unknownKeyErrors = exports.validateCommandsSection = exports.seedEntryForRule = exports.recommendedSeedModeFor = exports.recommendedSeedMode = exports.allRuleNames = exports.validateMatchRulesSection = exports.validateExcludePaths = exports.validateSectionPlacement = exports.validateChecklistsSection = exports.validatePrGateSection = exports.validateWebpiecesConfig = exports.BUILD_LOG_DOC = exports.ReferenceMergeRun = exports.MergeRun = exports.MergeProcessText = exports.MERGE_PROCESS_DOC = exports.MergeProcessDoc = exports.InstructAiDocSet = exports.InstructAiDoc = exports.GitWorkflowDoc = exports.GIT_WORKFLOW_DOC = exports.TemplateWriter = exports.writeTemplate = exports.writeTemplateIfMissing = exports.loadTemplate = exports.defaultRulesDir = exports.defaultRules = exports.NoCustomCssScope = exports.GENERATED_CODE_PATHS = exports.matchesAnyGlob = exports.isPathExcluded = exports.isWebpiecesStateDir = exports.ExcludePaths = exports.DESIGN_METADATA_KEYS = exports.isDocumentDesign = exports.DocumentDesign = void 0;
5
5
  exports.DEFAULT_MATCH_RULES = exports.renderMatchRuleMessage = exports.compileMatchRulePatterns = exports.isMatchRuleAllowedPath = exports.findMatchRuleViolations = exports.MatchRuleViolation = exports.MatchRuleConfig = exports.OrphanSweepReport = exports.OrphanDirSweeper = exports.TRASH_RETENTION_DAYS = exports.TRASH_MANIFEST_FILE = exports.TRASH_STATE_DIR = exports.OrphanSweepManifest = exports.OrphanSweepResult = exports.FailedOrphan = exports.ArchivedOrphan = exports.OrphanDirArchiver = exports.OrphanCandidate = exports.OrphanDirScanner = exports.MAX_ROW_BYTES = exports.BUILDS_LOG_GENERATIONS = exports.MAX_BUILDS_LOG_BYTES = exports.BUILD_DONE_FAIL = exports.BUILD_DONE_SUCCESS = exports.BUILD_START = exports.BUILDS_LOCK_FILE = exports.BUILDS_LOG_FILE = exports.RunningBuild = exports.BuildTermination = exports.BuildTicket = exports.BuildsLog = exports.DOCUMENTATION_KEYS = exports.HOME_KEY_AI_DOC = exports.HOME_KEY_DOC = exports.DEFAULT_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_SINGLE_ROUND_REVIEW = exports.HOME_KEY_TURN_OFF_ALL_REVIEWERS = exports.HOME_KEY_MAX_CONCURRENT_BUILDS = exports.HOME_KEY_WHOLE_REPO_BUILD_GUARD = exports.HOME_KEY_ORPHAN_DIR_SWEEP = exports.HOME_EXPERIMENTAL_SECTION = exports.HOME_CONFIG_FILE = exports.HOME_CONFIG_DIR = exports.RETIRED_HOME_CONFIG_KEYS = exports.RetiredHomeConfigKey = exports.HomeConfigService = exports.HomeConfig = exports.validateChecklistDocs = exports.PrunedKey = exports.PruneResult = void 0;
6
- exports.NoAnyUnknownConfig = exports.NoInlineTypeLiteralsConfig = exports.RequireReturnTypeConfig = exports.MaxFileLinesConfig = exports.MaxMethodLinesConfig = exports.WP_FINISH_PUSH_DEV = exports.WP_PUSH_DEV = exports.WP_FINISH_UPSERT_PR = exports.WP_START_UPSERT_PR = exports.WP_FINISH_UPDATE = exports.WP_START_UPDATE = exports.SyncFlowGuidance = exports.WebpiecesRulesConfig = exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.PUSH_DEV_STATE_FILE = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.PR_REVIEW_DIR = exports.MERGE_INFO_DIR = exports.WEBPIECES_TMP_DIR = exports.hasDisable = exports.RULE_NAMES = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.WholeScopeModes = exports.ProjectIndex = exports.FileScope = exports.ChangedFilesOptions = exports.DiffRange = exports.DiffScope = exports.isNewOrModified = exports.hasChangesInRange = exports.findNewMethodSignaturesInDiff = exports.getChangedLineNumbers = exports.getFileDiff = exports.getChangedFiles = exports.resolveBase = exports.detectBase = exports.SkipRuleResult = exports.getCurrentBranch = exports.shouldSkipRule = exports.FieldDef = exports.sectionForRule = exports.isHookGuard = exports.PR_LIFECYCLE_GUARD_KEY = exports.BRANCH_STATE_GUARD_KEY = exports.HOOK_GUARD_NAMES = exports.schemaModeValues = exports.schemaFieldNames = void 0;
6
+ exports.NoAnyUnknownConfig = exports.NoInlineTypeLiteralsConfig = exports.RequireReturnTypeConfig = exports.MaxFileLinesConfig = exports.MaxMethodLinesConfig = exports.WP_FINISH_PUSH_DEV = exports.WP_PUSH_DEV = exports.WP_FINISH_UPSERT_PR = exports.WP_START_UPSERT_PR = exports.WP_FINISH_UPDATE = exports.WP_START_UPDATE = exports.SyncFlowGuidance = exports.WebpiecesRulesConfig = exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.PUSH_DEV_STATE_FILE = exports.MERGE_EXPLANATION_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.PR_REVIEW_DIR = exports.MERGE_INFO_DIR = exports.WEBPIECES_TMP_DIR = exports.hasDisable = exports.RULE_NAMES = exports.WEBPIECES_DISABLE = exports.AbstractRule = exports.ChangedFilesOptions = exports.DiffRange = exports.DiffScope = exports.isNewOrModified = exports.hasChangesInRange = exports.findNewMethodSignaturesInDiff = exports.getChangedLineNumbers = exports.getFileDiff = exports.getChangedFiles = exports.resolveBase = exports.detectBase = exports.SkipRuleResult = exports.HOTFIX_AUDIT_BANNER = exports.HOTFIX_BUILD_COMMAND = exports.HOTFIX_BRANCH_SEGMENT = exports.BranchIdentity = exports.shouldSkipRule = exports.FieldDef = exports.sectionForRule = exports.isHookGuard = exports.PR_LIFECYCLE_GUARD_KEY = exports.BRANCH_STATE_GUARD_KEY = exports.HOOK_GUARD_NAMES = exports.RULE_SCHEMAS = exports.schemaFieldNames = void 0;
7
7
  exports.ON_OFF_MODES = exports.THROW_CAUSE_MODES = exports.DIRECT_API_RESOLVER_MODES = exports.PRISMA_CONVERTER_MODES = exports.PRISMA_DTOS_MODES = exports.PROJECT_MODES = exports.MODIFIED_CODE_MODES = exports.INLINE_TYPE_MODES = exports.RETURN_TYPE_MODES = exports.FILE_LIMIT_MODES = exports.METHOD_LIMIT_MODES = exports.API_DOC_MODES = exports.ApiRulesForOpenApiConfig = exports.ApiRulesForMcpConfig = exports.RequiredTypeSuffixEntry = exports.RequiredTypeSuffixConfig = exports.NoUtilityTypesInApiLibConfig = exports.OneEnumSpellingInApiLibConfig = exports.NoInlineImportInApiLibConfig = exports.NoRootUnionApiTypeConfig = exports.BaseRuleConfig = exports.ValidateEslintSyncConfig = exports.ValidateVersionsLockedConfig = exports.ValidatePackageJsonConfig = exports.ValidateNoArchitectureCyclesConfig = exports.ValidateArchitectureUnchangedConfig = exports.ValidateTsInSrcConfig = exports.NoJsFilesConfig = exports.DiGraphConfig = exports.NxWiringConfig = exports.RuntimeArchitectureConfig = exports.NoFileImportCyclesConfig = exports.PrLifecycleGuardConfig = exports.BranchCreationGuardConfig = exports.EnsureWeAreSecureConfig = exports.RoleTagConfig = exports.FrameworkTagConfig = exports.InjectAnnotationNotNeededForConcreteClassConfig = exports.NoFunctionOutsideClassConfig = exports.NoProcessExitOutsideMainConfig = exports.NoCustomCssConfig = exports.NoSymbolDiTokensConfig = exports.AngularNoDirectApiInResolverConfig = exports.ThrowCauseRequiredConfig = exports.CatchErrorPatternConfig = exports.NoUnmanagedExceptionsConfig = exports.NoDestructureConfig = exports.PrismaConverterConfig = exports.PrismaValidateDtosConfig = exports.NoImplicitAnyConfig = void 0;
8
- exports.SubagentProvenanceService = exports.verifyGateToken = exports.extractGateToken = exports.gateTokenMarker = exports.computeGateToken = exports.GateTokenService = exports.ALL_DIFF_ONE_READ_LINES = exports.READ_TRUNCATION_LINES = exports.ContextEntry = exports.BriefedFile = exports.ReviewerBriefing = exports.ReviewerInstructionsService = exports.ChecklistInstructionsService = exports.ChecklistValidator = exports.formatFileList = exports.normalizeChecklistDoc = exports.toChecklist = exports.DEFAULT_REVIEWER_AGENT_NAME = exports.REVIEWER_AGENTS_PLACEHOLDER = exports.ReviewerAgentPolicy = exports.ChecklistDefinition = exports.MERGE_MODES = exports.MERGE_MODE_NONE = exports.MERGE_MODE_AUTO = exports.buildDevDeployConfig = exports.buildLandPrConfig = exports.buildPrGateConfig = exports.defaultDevDeployConfig = exports.defaultLandPrConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.ReviewContextEntry = exports.DEFAULT_DEV_BRANCH = exports.DEFAULT_DEV_BRANCH_NAMESPACE = exports.DevDeployConfig = exports.LandPrConfig = exports.DEFAULT_BUILD_COMMAND = exports.PrGateConfig = exports.GateDefinition = exports.DEFAULT_MAX_COMMITS_BEHIND = exports.BranchStateGuardConfig = exports.DEFAULT_BANNED_STATE_PATH_PREFIXES = exports.DEFAULT_TEMPLATE_DIRS = exports.NoStatePathsInTemplatesConfig = exports.CLIENT_CREATION_SEVERITIES = exports.NoClientCreationOutsideServerOrClientConfig = exports.NO_JS_FILES_MODES = exports.WHOLE_SCOPE_MODES = exports.VALIDATE_TS_MODES = exports.STRUCTURAL_MODES = void 0;
9
- exports.MainSyncStatus = exports.summaryJsonSchemaHint = exports.summaryJsonPath = exports.prDirFor = exports.ReviewJsonService = exports.ChecklistReviewContext = exports.RequiredChecklist = exports.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS = exports.VERDICT_STATUSES = exports.VERDICT_RED = exports.VERDICT_YELLOW = exports.VERDICT_GREEN = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.checklistOverrideService = exports.ChecklistOverrideService = exports.ChecklistOverride = exports.ChecklistVerdict = exports.ChecklistResult = exports.PrContext = exports.PrSummary = exports.DEFAULT_RETENTION_DAYS = exports.ProvenanceWriteRequest = exports.OfferedContext = exports.ReviewerPaths = exports.ReviewerTranscript = exports.ReviewProvenance = exports.ReviewProvenanceService = exports.REVIEW_STAMP_MAX_AGE_MS = exports.REVIEW_STAMP_DIR = exports.WRITE_REVIEW_CHECKLIST_FLAG = exports.WRITE_REVIEW_BIN = exports.reviewIdentityStamps = exports.ReviewIdentityStampService = exports.ReviewIdentityStamp = exports.claudeConfigDir = exports.ClaudeConfigDir = exports.CLAUDE_CONFIG_DIR_ENV = exports.PROVENANCE_SKIPPED = exports.PROVENANCE_MISSING = exports.PROVENANCE_OK = exports.ProvenanceResult = exports.TranscriptScan = exports.ExpectedReviewer = exports.ReviewerContext = exports.ReviewerEvidence = void 0;
10
- exports.BRANCH_RETENTION_ARCHIVE_TAG = exports.BRANCH_RETENTION_DELETE = exports.BRANCH_RETENTIONS = exports.ARCHIVE_TAG_PREFIX = exports.ArchiveResult = exports.BranchArchiver = exports.ADJUDICATED_CLASSIFICATIONS = exports.CLASSIFICATION_DETACHED = exports.CLASSIFICATION_CURRENT = exports.CLASSIFICATION_LOCKED = exports.CLASSIFICATION_PRUNABLE = exports.CLASSIFICATION_IN_USE = exports.CLASSIFICATION_NEVER_PROPOSED = exports.CLASSIFICATION_CONTENT_IN_MAIN = exports.CLASSIFICATION_SUPERSEDED = exports.CLASSIFICATION_NO_COMMITS = exports.CLASSIFICATION_BACKUP_OF_LIVE = exports.CLASSIFICATION_BACKUP_OF_MERGED = exports.CLASSIFICATION_MERGED_PR = exports.CACHE_STALE_AFTER_MS = exports.CacheFreshness = exports.MergedBranchesService = exports.MergedBranchesCache = exports.DeletableWorktree = exports.DeletableBranch = exports.MergedBranch = exports.squashRecoverySteps = exports.stampCleanMainSyncStatus = exports.computeMainSyncStatus = exports.finishedLock = exports.inProcessLock = exports.tryAcquireMainSyncLock = exports.isRefreshInProgress = exports.isLockStale = exports.writeMainSyncLock = exports.readMainSyncLock = exports.computeAllMainSyncStatuses = exports.writeMainSyncStatusFile = exports.writeMainSyncStatus = exports.readMainSyncStatusFile = exports.readMainSyncStatus = exports.mainSyncLockPath = exports.mainSyncStatusPath = exports.DEFAULT_HANG_TIMEOUT_MINUTES = exports.MainSyncStatusService = exports.MainSyncLock = exports.MAIN_SYNC_STATUS_VERSION = exports.PullRequestIndex = exports.MainSyncFileStore = exports.MainSyncStatusFile = void 0;
11
- exports.TMP_SCRATCH_PREFIX = exports.TMP_SCRATCH_RETENTION_DAYS = exports.TmpScratchSweeper = exports.SCRATCH_DIR_NAME = exports.RepoScratchDirs = exports.specTempDirs = exports.SpecTempDirs = exports.staleBinSweeper = exports.StaleBinSweeper = exports.StaleBinRemoval = exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.logBranchMutation = exports.branchMutationLogPath = exports.BranchMutationLog = exports.BranchMutationEvent = exports.WorktreeReaper = exports.WorktreeReapResult = exports.ReapedWorktree = exports.BranchReaper = exports.ReapResult = exports.ReapedBranch = exports.HarnessAgentActivityReader = exports.AgentActivity = exports.AGENT_TRANSCRIPT_QUIET_MS = exports.AGENT_ACTIVITY_UNKNOWN = exports.AGENT_ACTIVITY_RETURNED = exports.AGENT_ACTIVITY_LIVE = exports.WorktreeLockVerdicts = exports.LockEvidence = exports.LockDecision = exports.LOCK_LIVENESS_UNVERIFIABLE = exports.HARNESS_NOT_CONSULTED = exports.AgentWorktreeLockReader = exports.AgentWorktreeLock = exports.WorktreeService = exports.WorktreeWorkInFlight = exports.Worktree = exports.BRANCH_RETENTION_KEEP = void 0;
8
+ exports.ReviewerContext = exports.ReviewerEvidence = exports.SubagentProvenanceService = exports.verifyGateToken = exports.extractGateToken = exports.gateTokenMarker = exports.computeGateToken = exports.GateTokenService = exports.ALL_DIFF_ONE_READ_LINES = exports.READ_TRUNCATION_LINES = exports.ContextEntry = exports.BriefedFile = exports.ReviewerBriefing = exports.ReviewerInstructionsService = exports.ChecklistInstructionsService = exports.ChecklistValidator = exports.formatFileList = exports.normalizeChecklistDoc = exports.toChecklist = exports.DEFAULT_REVIEWER_AGENT_NAME = exports.REVIEWER_AGENTS_PLACEHOLDER = exports.ReviewerAgentPolicy = exports.ChecklistDefinition = exports.MERGE_MODES = exports.MERGE_MODE_NONE = exports.MERGE_MODE_AUTO = exports.buildDevDeployConfig = exports.buildLandPrConfig = exports.buildPrGateConfig = exports.defaultDevDeployConfig = exports.defaultLandPrConfig = exports.defaultPrGateConfig = exports.defaultGates = exports.ReviewContextEntry = exports.DEFAULT_DEV_BRANCH = exports.DEFAULT_DEV_BRANCH_NAMESPACE = exports.DevDeployConfig = exports.LandPrConfig = exports.DEFAULT_BUILD_COMMAND = exports.PrGateConfig = exports.GateDefinition = exports.DEFAULT_MAX_COMMITS_BEHIND = exports.BranchStateGuardConfig = exports.DEFAULT_BANNED_STATE_PATH_PREFIXES = exports.DEFAULT_TEMPLATE_DIRS = exports.NoStatePathsInTemplatesConfig = exports.CLIENT_CREATION_SEVERITIES = exports.NoClientCreationOutsideServerOrClientConfig = exports.VALIDATE_TS_MODES = exports.STRUCTURAL_MODES = void 0;
9
+ exports.MainSyncFileStore = exports.MainSyncStatusFile = exports.MainSyncStatus = exports.summaryJsonSchemaHint = exports.summaryJsonPath = exports.prDirFor = exports.ReviewJsonService = exports.ChecklistReviewContext = exports.RequiredChecklist = exports.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS = exports.VERDICT_STATUSES = exports.VERDICT_RED = exports.VERDICT_YELLOW = exports.VERDICT_GREEN = exports.CK_BAD_FORMAT = exports.CK_MISSING = exports.CK_FAIL = exports.CK_OVERRIDDEN = exports.CK_WARN = exports.CK_PASS = exports.checklistOverrideService = exports.ChecklistOverrideService = exports.ChecklistOverride = exports.ChecklistVerdict = exports.ChecklistResult = exports.PrContext = exports.PrSummary = exports.DEFAULT_RETENTION_DAYS = exports.ProvenanceWriteRequest = exports.OfferedContext = exports.ReviewerPaths = exports.ReviewerTranscript = exports.ReviewProvenance = exports.ReviewProvenanceService = exports.REVIEW_STAMP_MAX_AGE_MS = exports.REVIEW_STAMP_DIR = exports.WRITE_REVIEW_CHECKLIST_FLAG = exports.WRITE_REVIEW_BIN = exports.reviewIdentityStamps = exports.ReviewIdentityStampService = exports.ReviewIdentityStamp = exports.claudeConfigDir = exports.ClaudeConfigDir = exports.CLAUDE_CONFIG_DIR_ENV = exports.PROVENANCE_SKIPPED = exports.PROVENANCE_MISSING = exports.PROVENANCE_OK = exports.ProvenanceResult = exports.TranscriptScan = exports.ExpectedReviewer = void 0;
10
+ exports.Worktree = exports.BRANCH_RETENTION_KEEP = exports.BRANCH_RETENTION_ARCHIVE_TAG = exports.BRANCH_RETENTION_DELETE = exports.BRANCH_RETENTIONS = exports.ARCHIVE_TAG_PREFIX = exports.ArchiveResult = exports.BranchArchiver = exports.ADJUDICATED_CLASSIFICATIONS = exports.CLASSIFICATION_DETACHED = exports.CLASSIFICATION_CURRENT = exports.CLASSIFICATION_LOCKED = exports.CLASSIFICATION_PRUNABLE = exports.CLASSIFICATION_IN_USE = exports.CLASSIFICATION_NEVER_PROPOSED = exports.CLASSIFICATION_CONTENT_IN_MAIN = exports.CLASSIFICATION_SUPERSEDED = exports.CLASSIFICATION_NO_COMMITS = exports.CLASSIFICATION_BACKUP_OF_LIVE = exports.CLASSIFICATION_BACKUP_OF_MERGED = exports.CLASSIFICATION_MERGED_PR = exports.CACHE_STALE_AFTER_MS = exports.CacheFreshness = exports.MergedBranchesService = exports.MergedBranchesCache = exports.DeletableWorktree = exports.DeletableBranch = exports.MergedBranch = exports.squashRecoverySteps = exports.stampCleanMainSyncStatus = exports.computeMainSyncStatus = exports.finishedLock = exports.inProcessLock = exports.tryAcquireMainSyncLock = exports.isRefreshInProgress = exports.isLockStale = exports.writeMainSyncLock = exports.readMainSyncLock = exports.computeAllMainSyncStatuses = exports.writeMainSyncStatusFile = exports.writeMainSyncStatus = exports.readMainSyncStatusFile = exports.readMainSyncStatus = exports.mainSyncLockPath = exports.mainSyncStatusPath = exports.DEFAULT_HANG_TIMEOUT_MINUTES = exports.MainSyncStatusService = exports.MainSyncLock = exports.MAIN_SYNC_STATUS_VERSION = exports.PullRequestIndex = void 0;
11
+ exports.TMP_SCRATCH_PREFIX = exports.TMP_SCRATCH_RETENTION_DAYS = exports.TmpScratchSweeper = exports.SCRATCH_DIR_NAME = exports.RepoScratchDirs = exports.specTempDirs = exports.SpecTempDirs = exports.staleBinSweeper = exports.StaleBinSweeper = exports.StaleBinRemoval = exports.DEFAULT_MERGE_COMPLETE_COMMAND = exports.DEFAULT_UPSERT_PR_COMMAND = exports.buildCommandsConfig = exports.CommandsConfig = exports.logBranchMutation = exports.branchMutationLogPath = exports.BranchMutationLog = exports.BranchMutationEvent = exports.WorktreeReaper = exports.WorktreeReapResult = exports.ReapedWorktree = exports.BranchReaper = exports.ReapResult = exports.ReapedBranch = exports.HarnessAgentActivityReader = exports.AgentActivity = exports.AGENT_TRANSCRIPT_QUIET_MS = exports.AGENT_ACTIVITY_UNKNOWN = exports.AGENT_ACTIVITY_RETURNED = exports.AGENT_ACTIVITY_LIVE = exports.WorktreeLockVerdicts = exports.LockEvidence = exports.LockDecision = exports.LOCK_LIVENESS_UNVERIFIABLE = exports.HARNESS_NOT_CONSULTED = exports.AgentWorktreeLockReader = exports.AgentWorktreeLock = exports.WorktreeService = exports.WorktreeWorkInFlight = void 0;
12
12
  var types_1 = require("./types");
13
13
  Object.defineProperty(exports, "ResolvedConfig", { enumerable: true, get: function () { return types_1.ResolvedConfig; } });
14
14
  Object.defineProperty(exports, "ResolvedRuleConfig", { enumerable: true, get: function () { return types_1.ResolvedRuleConfig; } });
@@ -244,7 +244,7 @@ Object.defineProperty(exports, "renderMatchRuleMessage", { enumerable: true, get
244
244
  Object.defineProperty(exports, "DEFAULT_MATCH_RULES", { enumerable: true, get: function () { return match_rules_config_1.DEFAULT_MATCH_RULES; } });
245
245
  var rule_schemas_1 = require("./rule-schemas");
246
246
  Object.defineProperty(exports, "schemaFieldNames", { enumerable: true, get: function () { return rule_schemas_1.schemaFieldNames; } });
247
- Object.defineProperty(exports, "schemaModeValues", { enumerable: true, get: function () { return rule_schemas_1.schemaModeValues; } });
247
+ Object.defineProperty(exports, "RULE_SCHEMAS", { enumerable: true, get: function () { return rule_schemas_1.RULE_SCHEMAS; } });
248
248
  var sections_1 = require("./sections");
249
249
  Object.defineProperty(exports, "HOOK_GUARD_NAMES", { enumerable: true, get: function () { return sections_1.HOOK_GUARD_NAMES; } });
250
250
  Object.defineProperty(exports, "BRANCH_STATE_GUARD_KEY", { enumerable: true, get: function () { return sections_1.BRANCH_STATE_GUARD_KEY; } });
@@ -255,7 +255,10 @@ var field_def_1 = require("./field-def");
255
255
  Object.defineProperty(exports, "FieldDef", { enumerable: true, get: function () { return field_def_1.FieldDef; } });
256
256
  var skip_rule_1 = require("./skip-rule");
257
257
  Object.defineProperty(exports, "shouldSkipRule", { enumerable: true, get: function () { return skip_rule_1.shouldSkipRule; } });
258
- Object.defineProperty(exports, "getCurrentBranch", { enumerable: true, get: function () { return skip_rule_1.getCurrentBranch; } });
258
+ Object.defineProperty(exports, "BranchIdentity", { enumerable: true, get: function () { return skip_rule_1.BranchIdentity; } });
259
+ Object.defineProperty(exports, "HOTFIX_BRANCH_SEGMENT", { enumerable: true, get: function () { return skip_rule_1.HOTFIX_BRANCH_SEGMENT; } });
260
+ Object.defineProperty(exports, "HOTFIX_BUILD_COMMAND", { enumerable: true, get: function () { return skip_rule_1.HOTFIX_BUILD_COMMAND; } });
261
+ Object.defineProperty(exports, "HOTFIX_AUDIT_BANNER", { enumerable: true, get: function () { return skip_rule_1.HOTFIX_AUDIT_BANNER; } });
259
262
  var skip_rule_2 = require("./skip-rule");
260
263
  Object.defineProperty(exports, "SkipRuleResult", { enumerable: true, get: function () { return skip_rule_2.SkipRuleResult; } });
261
264
  var diff_scope_1 = require("./diff-scope");
@@ -270,10 +273,6 @@ Object.defineProperty(exports, "isNewOrModified", { enumerable: true, get: funct
270
273
  Object.defineProperty(exports, "DiffScope", { enumerable: true, get: function () { return diff_scope_1.DiffScope; } });
271
274
  Object.defineProperty(exports, "DiffRange", { enumerable: true, get: function () { return diff_scope_1.DiffRange; } });
272
275
  Object.defineProperty(exports, "ChangedFilesOptions", { enumerable: true, get: function () { return diff_scope_1.ChangedFilesOptions; } });
273
- var file_scope_1 = require("./file-scope");
274
- Object.defineProperty(exports, "FileScope", { enumerable: true, get: function () { return file_scope_1.FileScope; } });
275
- Object.defineProperty(exports, "ProjectIndex", { enumerable: true, get: function () { return file_scope_1.ProjectIndex; } });
276
- Object.defineProperty(exports, "WholeScopeModes", { enumerable: true, get: function () { return file_scope_1.WholeScopeModes; } });
277
276
  var abstract_rule_1 = require("./abstract-rule");
278
277
  Object.defineProperty(exports, "AbstractRule", { enumerable: true, get: function () { return abstract_rule_1.AbstractRule; } });
279
278
  var constants_1 = require("./constants");
@@ -363,8 +362,6 @@ Object.defineProperty(exports, "THROW_CAUSE_MODES", { enumerable: true, get: fun
363
362
  Object.defineProperty(exports, "ON_OFF_MODES", { enumerable: true, get: function () { return rule_configs_2.ON_OFF_MODES; } });
364
363
  Object.defineProperty(exports, "STRUCTURAL_MODES", { enumerable: true, get: function () { return rule_configs_2.STRUCTURAL_MODES; } });
365
364
  Object.defineProperty(exports, "VALIDATE_TS_MODES", { enumerable: true, get: function () { return rule_configs_2.VALIDATE_TS_MODES; } });
366
- Object.defineProperty(exports, "WHOLE_SCOPE_MODES", { enumerable: true, get: function () { return rule_configs_2.WHOLE_SCOPE_MODES; } });
367
- Object.defineProperty(exports, "NO_JS_FILES_MODES", { enumerable: true, get: function () { return rule_configs_2.NO_JS_FILES_MODES; } });
368
365
  var no_client_creation_config_1 = require("./no-client-creation-config");
369
366
  Object.defineProperty(exports, "NoClientCreationOutsideServerOrClientConfig", { enumerable: true, get: function () { return no_client_creation_config_1.NoClientCreationOutsideServerOrClientConfig; } });
370
367
  Object.defineProperty(exports, "CLIENT_CREATION_SEVERITIES", { enumerable: true, get: function () { return no_client_creation_config_1.CLIENT_CREATION_SEVERITIES; } });