@webpieces/rules-config 0.4.843 → 0.4.845
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 +9 -4
- package/src/WebpiecesRulesConfig.d.ts +3 -49
- package/src/WebpiecesRulesConfig.js +1 -44
- package/src/WebpiecesRulesConfig.js.map +1 -1
- package/src/abstract-rule.d.ts +1 -1
- package/src/abstract-rule.js.map +1 -1
- package/src/config-pruner.d.ts +3 -1
- package/src/config-pruner.js +13 -9
- package/src/config-pruner.js.map +1 -1
- package/src/constants.d.ts +0 -37
- package/src/constants.js +1 -38
- package/src/constants.js.map +1 -1
- package/src/index.d.ts +7 -24
- package/src/index.js +14 -105
- package/src/index.js.map +1 -1
- package/src/load-config.d.ts +6 -2
- package/src/load-config.js +17 -11
- package/src/load-config.js.map +1 -1
- package/src/match-rules-config.d.ts +2 -1
- package/src/match-rules-config.js +2 -2
- package/src/match-rules-config.js.map +1 -1
- package/src/no-custom-css-scope.d.ts +9 -25
- package/src/no-custom-css-scope.js +10 -24
- package/src/no-custom-css-scope.js.map +1 -1
- package/src/retired-config-keys.d.ts +3 -64
- package/src/retired-config-keys.js +14 -152
- package/src/retired-config-keys.js.map +1 -1
- package/src/rule-pack-registry.d.ts +41 -0
- package/src/rule-pack-registry.js +231 -0
- package/src/rule-pack-registry.js.map +1 -0
- package/src/rule-pack-selection.d.ts +6 -0
- package/src/rule-pack-selection.js +50 -0
- package/src/rule-pack-selection.js.map +1 -0
- package/src/rule-schemas.d.ts +4 -14
- package/src/rule-schemas.js +6 -92
- package/src/rule-schemas.js.map +1 -1
- package/src/sections.d.ts +5 -46
- package/src/sections.js +5 -56
- package/src/sections.js.map +1 -1
- package/src/seed-entry.d.ts +5 -16
- package/src/seed-entry.js +14 -141
- package/src/seed-entry.js.map +1 -1
- package/src/validate-config.d.ts +3 -2
- package/src/validate-config.js +62 -73
- package/src/validate-config.js.map +1 -1
- package/templates/webpieces.branch-state-matrix.md +1 -1
- package/src/api-doc-rules-config.d.ts +0 -60
- package/src/api-doc-rules-config.js +0 -71
- package/src/api-doc-rules-config.js.map +0 -1
- package/src/api-lib-spelling-configs.d.ts +0 -40
- package/src/api-lib-spelling-configs.js +0 -52
- package/src/api-lib-spelling-configs.js.map +0 -1
- package/src/default-rules.d.ts +0 -2
- package/src/default-rules.js +0 -119
- package/src/default-rules.js.map +0 -1
- package/src/field-def.d.ts +0 -24
- package/src/field-def.js +0 -59
- package/src/field-def.js.map +0 -1
- package/src/main-sync-guard-configs.d.ts +0 -38
- package/src/main-sync-guard-configs.js +0 -54
- package/src/main-sync-guard-configs.js.map +0 -1
- package/src/no-client-creation-config.d.ts +0 -12
- package/src/no-client-creation-config.js +0 -40
- package/src/no-client-creation-config.js.map +0 -1
- package/src/no-root-union-config.d.ts +0 -25
- package/src/no-root-union-config.js +0 -33
- package/src/no-root-union-config.js.map +0 -1
- package/src/no-state-paths-config.d.ts +0 -41
- package/src/no-state-paths-config.js +0 -51
- package/src/no-state-paths-config.js.map +0 -1
- package/src/no-utility-types-config.d.ts +0 -30
- package/src/no-utility-types-config.js +0 -39
- package/src/no-utility-types-config.js.map +0 -1
- package/src/required-type-suffix-config.d.ts +0 -49
- package/src/required-type-suffix-config.js +0 -62
- package/src/required-type-suffix-config.js.map +0 -1
- package/src/rule-configs.d.ts +0 -273
- package/src/rule-configs.js +0 -595
- package/src/rule-configs.js.map +0 -1
- package/src/spec-temp-dirs.d.ts +0 -37
- package/src/spec-temp-dirs.js +0 -113
- package/src/spec-temp-dirs.js.map +0 -1
- package/src/tag-truth-configs.d.ts +0 -137
- package/src/tag-truth-configs.js +0 -175
- package/src/tag-truth-configs.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/rules-config",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.845",
|
|
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",
|
|
@@ -11,15 +11,17 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"src/**/*",
|
|
13
13
|
"templates/**/*",
|
|
14
|
-
"README.md"
|
|
14
|
+
"README.md",
|
|
15
|
+
"RULE_PACKS.md"
|
|
15
16
|
],
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
18
19
|
"inversify": "7.10.4",
|
|
19
20
|
"reflect-metadata": "0.2.2",
|
|
20
21
|
"minimatch": "10.0.1",
|
|
21
|
-
"@webpieces/tooling-common": "0.4.
|
|
22
|
-
"@webpieces/repo-workflow-core": "0.4.
|
|
22
|
+
"@webpieces/tooling-common": "0.4.845",
|
|
23
|
+
"@webpieces/repo-workflow-core": "0.4.845",
|
|
24
|
+
"@webpieces/rules-sdk": "0.4.845"
|
|
23
25
|
},
|
|
24
26
|
"author": "Dean Hiller",
|
|
25
27
|
"license": "Apache-2.0",
|
|
@@ -31,5 +33,8 @@
|
|
|
31
33
|
"publishConfig": {
|
|
32
34
|
"access": "public"
|
|
33
35
|
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.845"
|
|
38
|
+
},
|
|
34
39
|
"types": "./src/index.d.ts"
|
|
35
40
|
}
|
|
@@ -1,52 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { NoClientCreationOutsideServerOrClientConfig } from './no-client-creation-config';
|
|
4
|
-
import { NoInlineImportInApiLibConfig, OneEnumSpellingInApiLibConfig } from './api-lib-spelling-configs';
|
|
5
|
-
import { NoUtilityTypesInApiLibConfig } from './no-utility-types-config';
|
|
6
|
-
import { RequiredTypeSuffixConfig } from './required-type-suffix-config';
|
|
7
|
-
import { NoStatePathsInTemplatesConfig } from './no-state-paths-config';
|
|
8
|
-
import { ApiLibDependenciesConfig, ApiLibPathConfig, FrameworkFolderConfig, FrameworkPackagesConfig, FrameworkTsconfigConfig } from './tag-truth-configs';
|
|
1
|
+
import { BaseRuleConfig } from '@webpieces/rules-sdk';
|
|
2
|
+
/** The framework carries validated values; concrete packs supply and interpret their own types. */
|
|
9
3
|
export declare class WebpiecesRulesConfig {
|
|
10
|
-
|
|
11
|
-
'max-file-lines'?: MaxFileLinesConfig;
|
|
12
|
-
'require-return-type'?: RequireReturnTypeConfig;
|
|
13
|
-
'no-inline-type-literals'?: NoInlineTypeLiteralsConfig;
|
|
14
|
-
'no-any-unknown'?: NoAnyUnknownConfig;
|
|
15
|
-
'no-implicit-any'?: NoImplicitAnyConfig;
|
|
16
|
-
'prisma-validate-dtos'?: PrismaValidateDtosConfig;
|
|
17
|
-
'prisma-converter'?: PrismaConverterConfig;
|
|
18
|
-
'no-destructure'?: NoDestructureConfig;
|
|
19
|
-
'no-unmanaged-exceptions'?: NoUnmanagedExceptionsConfig;
|
|
20
|
-
'catch-error-pattern'?: CatchErrorPatternConfig;
|
|
21
|
-
'throw-cause-required'?: ThrowCauseRequiredConfig;
|
|
22
|
-
'angular-no-direct-api-in-resolver'?: AngularNoDirectApiInResolverConfig;
|
|
23
|
-
'no-symbol-di-tokens'?: NoSymbolDiTokensConfig;
|
|
24
|
-
'no-client-creation-outside-server-or-client'?: NoClientCreationOutsideServerOrClientConfig;
|
|
25
|
-
'no-custom-css'?: NoCustomCssConfig;
|
|
26
|
-
'no-state-paths-in-templates'?: NoStatePathsInTemplatesConfig;
|
|
27
|
-
'no-process-exit-outside-main'?: NoProcessExitOutsideMainConfig;
|
|
28
|
-
'no-function-outside-class'?: NoFunctionOutsideClassConfig;
|
|
29
|
-
'inject-annotation-not-needed-for-concrete-class'?: InjectAnnotationNotNeededForConcreteClassConfig;
|
|
30
|
-
'framework-tag'?: FrameworkTagConfig;
|
|
31
|
-
'role-tag'?: RoleTagConfig;
|
|
32
|
-
'ensure-we-are-secure'?: EnsureWeAreSecureConfig;
|
|
33
|
-
'no-inline-import-in-api-lib'?: NoInlineImportInApiLibConfig;
|
|
34
|
-
'one-enum-spelling-in-api-lib'?: OneEnumSpellingInApiLibConfig;
|
|
35
|
-
'no-utility-types-in-api-lib'?: NoUtilityTypesInApiLibConfig;
|
|
36
|
-
'required-type-suffix'?: RequiredTypeSuffixConfig;
|
|
37
|
-
'api-lib-dependencies'?: ApiLibDependenciesConfig;
|
|
38
|
-
'api-lib-path'?: ApiLibPathConfig;
|
|
39
|
-
'framework-folder'?: FrameworkFolderConfig;
|
|
40
|
-
'framework-tsconfig'?: FrameworkTsconfigConfig;
|
|
41
|
-
'framework-packages'?: FrameworkPackagesConfig;
|
|
42
|
-
'branch-state-guard'?: BranchStateGuardConfig;
|
|
43
|
-
'branch-creation-guard'?: BranchCreationGuardConfig;
|
|
44
|
-
'pr-lifecycle-guard'?: PrLifecycleGuardConfig;
|
|
45
|
-
'no-file-import-cycles'?: NoFileImportCyclesConfig;
|
|
46
|
-
'runtime-architecture'?: RuntimeArchitectureConfig;
|
|
47
|
-
'di-graph'?: DiGraphConfig;
|
|
48
|
-
'missing-design-annotation'?: MissingDesignAnnotationConfig;
|
|
49
|
-
'no-js-files'?: NoJsFilesConfig;
|
|
50
|
-
'validate-ts-in-src'?: ValidateTsInSrcConfig;
|
|
4
|
+
[configKey: string]: BaseRuleConfig | string[] | undefined;
|
|
51
5
|
rulesDir?: string[];
|
|
52
6
|
}
|
|
@@ -1,51 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WebpiecesRulesConfig = void 0;
|
|
4
|
+
/** The framework carries validated values; concrete packs supply and interpret their own types. */
|
|
4
5
|
class WebpiecesRulesConfig {
|
|
5
|
-
'max-method-lines';
|
|
6
|
-
'max-file-lines';
|
|
7
|
-
'require-return-type';
|
|
8
|
-
'no-inline-type-literals';
|
|
9
|
-
'no-any-unknown';
|
|
10
|
-
'no-implicit-any';
|
|
11
|
-
'prisma-validate-dtos';
|
|
12
|
-
'prisma-converter';
|
|
13
|
-
'no-destructure';
|
|
14
|
-
'no-unmanaged-exceptions';
|
|
15
|
-
'catch-error-pattern';
|
|
16
|
-
'throw-cause-required';
|
|
17
|
-
'angular-no-direct-api-in-resolver';
|
|
18
|
-
'no-symbol-di-tokens';
|
|
19
|
-
'no-client-creation-outside-server-or-client';
|
|
20
|
-
'no-custom-css';
|
|
21
|
-
'no-state-paths-in-templates';
|
|
22
|
-
'no-process-exit-outside-main';
|
|
23
|
-
'no-function-outside-class';
|
|
24
|
-
'inject-annotation-not-needed-for-concrete-class';
|
|
25
|
-
'framework-tag';
|
|
26
|
-
'role-tag';
|
|
27
|
-
'ensure-we-are-secure';
|
|
28
|
-
'no-inline-import-in-api-lib';
|
|
29
|
-
'one-enum-spelling-in-api-lib';
|
|
30
|
-
'no-utility-types-in-api-lib';
|
|
31
|
-
'required-type-suffix';
|
|
32
|
-
'api-lib-dependencies';
|
|
33
|
-
'api-lib-path';
|
|
34
|
-
'framework-folder';
|
|
35
|
-
'framework-tsconfig';
|
|
36
|
-
'framework-packages';
|
|
37
|
-
// The THREE hookGuards keys, complete. It used to list five of the nine class-named keys — both
|
|
38
|
-
// bash guards were simply missing — and nothing caught it, because this class is populated by
|
|
39
|
-
// dynamic key assignment in the loader. One key per POLICY makes completeness checkable by eye.
|
|
40
|
-
'branch-state-guard';
|
|
41
|
-
'branch-creation-guard';
|
|
42
|
-
'pr-lifecycle-guard';
|
|
43
|
-
'no-file-import-cycles';
|
|
44
|
-
'runtime-architecture';
|
|
45
|
-
'di-graph';
|
|
46
|
-
'missing-design-annotation';
|
|
47
|
-
'no-js-files';
|
|
48
|
-
'validate-ts-in-src';
|
|
49
6
|
rulesDir;
|
|
50
7
|
}
|
|
51
8
|
exports.WebpiecesRulesConfig = WebpiecesRulesConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebpiecesRulesConfig.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/WebpiecesRulesConfig.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"WebpiecesRulesConfig.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/WebpiecesRulesConfig.ts"],"names":[],"mappings":";;;AAEA,mGAAmG;AACnG,MAAa,oBAAoB;IAE7B,QAAQ,CAAY;CACvB;AAHD,oDAGC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\n\n/** The framework carries validated values; concrete packs supply and interpret their own types. */\nexport class WebpiecesRulesConfig {\n [configKey: string]: BaseRuleConfig | string[] | undefined;\n rulesDir?: string[];\n}\n"]}
|
package/src/abstract-rule.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRuleConfig } from '
|
|
1
|
+
import { BaseRuleConfig } from '@webpieces/rules-sdk';
|
|
2
2
|
/**
|
|
3
3
|
* Shared base for every rule in BOTH packages (ai-hook-rules and code-rules). A rule is
|
|
4
4
|
* constructed with its typed config (`new NoAnyUnknownRule(config['no-any-unknown'])`), so the
|
package/src/abstract-rule.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-rule.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/abstract-rule.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"abstract-rule.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/abstract-rule.ts"],"names":[],"mappings":";;;AAEA,2CAA6C;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAsB,YAAY;IACC;IAAoB;IAAuB;IAA1E,YAA+B,MAAS,EAAW,IAAY,EAAW,SAAiB;QAA5D,WAAM,GAAN,MAAM,CAAG;QAAW,SAAI,GAAJ,IAAI,CAAQ;QAAW,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAE/F,uFAAuF;IACvF,SAAS;QACL,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAA,0BAAc,EAAC,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;QACrG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IACtB,CAAC;CACJ;AATD,oCASC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\n\nimport { shouldSkipRule } from './skip-rule';\n\n/**\n * Shared base for every rule in BOTH packages (ai-hook-rules and code-rules). A rule is\n * constructed with its typed config (`new NoAnyUnknownRule(config['no-any-unknown'])`), so the\n * config class is genuinely consumed — find-usages/rename work across packages.\n *\n * It is execution-agnostic: it owns only `name` + `configKey` + the on/off + escape-hatch decision\n * (`shouldRun`). Each package's base adds its own execution surface (ai-hook `check(ctx)`,\n * code-rules `run(workspaceRoot)`), so rules-config stays free of package-specific types.\n *\n * ## `name` and `configKey` are two different identities, and they are BOTH required\n *\n * `name` is the OPERATOR identity: it is what a decision-log line carries as `rule=`, what a deny\n * report titles itself with, and what prose in `guards/**` names when it describes behaviour. It is\n * per-CLASS and it never changes when the config collapses.\n *\n * `configKey` is the webpieces.config.json KEY whose entry configures this rule. Several classes may\n * share one key when they implement one POLICY — the four branch-state guards all read\n * `branch-state-guard`, the four PR-lifecycle guards all read `pr-lifecycle-guard` — because a\n * consumer switches a POLICY on and off, not an implementation class. Half a policy (`read-stale-guard`\n * OFF while `merged-branch-bash-guard` stays ON: read the file, yes; `cat` the same file, no) was\n * representable while the two were the same string, and this split is what makes it unrepresentable.\n *\n * BOTH are constructor params with NO default. A `configKey = name` default would make the common\n * case silent and the shared case a thing you have to remember — which is the same \"widening that is\n * an ABSENCE rather than a token\" `.claude/rules/no-backwards-compat.md` rejects. Every rule says which\n * key configures it, out loud,\n * so `grep \"'branch-state-guard'\"` lists every class that key governs.\n */\nexport abstract class AbstractRule<C extends BaseRuleConfig> {\n constructor(protected readonly config: C, readonly name: string, readonly configKey: string) {}\n\n /** True unless the rule is `mode: \"OFF\"` or skipped by a branch/epoch escape hatch. */\n shouldRun(): boolean {\n if (this.config.mode === 'OFF') return false;\n const skip = shouldSkipRule(this.config.turnOffRuleUntilEpoch, this.config.turnOffRuleWhileOnBranch);\n return !skip.skip;\n }\n}\n"]}
|
package/src/config-pruner.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AtomicFile } from '@webpieces/tooling-common';
|
|
2
2
|
import { ConfigFile } from './config-file';
|
|
3
|
+
import { RulePackSelection } from './rule-pack-selection';
|
|
3
4
|
/**
|
|
4
5
|
* `wp-prune-unknown-config` — the MECHANICAL cure for "[x] Unknown rule".
|
|
5
6
|
*
|
|
@@ -60,7 +61,8 @@ export declare class PruneResult {
|
|
|
60
61
|
export declare class ConfigPruner {
|
|
61
62
|
private readonly configFile;
|
|
62
63
|
private readonly atomicFile;
|
|
63
|
-
|
|
64
|
+
private readonly rulePacks;
|
|
65
|
+
constructor(configFile: ConfigFile, atomicFile: AtomicFile, rulePacks: RulePackSelection);
|
|
64
66
|
/**
|
|
65
67
|
* Strip every unknown key from the webpieces.config.json above `cwd` and rewrite it. Throws when no
|
|
66
68
|
* config file is found — a prune with no target is a mistake, not a no-op.
|
package/src/config-pruner.js
CHANGED
|
@@ -7,7 +7,8 @@ const inversify_1 = require("inversify");
|
|
|
7
7
|
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
8
8
|
const config_file_1 = require("./config-file");
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
|
-
const
|
|
10
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
11
|
+
const rule_pack_selection_1 = require("./rule-pack-selection");
|
|
11
12
|
const retired_config_keys_1 = require("./retired-config-keys");
|
|
12
13
|
/**
|
|
13
14
|
* `wp-prune-unknown-config` — the MECHANICAL cure for "[x] Unknown rule".
|
|
@@ -89,9 +90,11 @@ const PRUNABLE_SECTIONS = ['rules', 'hookGuards'];
|
|
|
89
90
|
let ConfigPruner = class ConfigPruner {
|
|
90
91
|
configFile;
|
|
91
92
|
atomicFile;
|
|
92
|
-
|
|
93
|
+
rulePacks;
|
|
94
|
+
constructor(configFile, atomicFile, rulePacks) {
|
|
93
95
|
this.configFile = configFile;
|
|
94
96
|
this.atomicFile = atomicFile;
|
|
97
|
+
this.rulePacks = rulePacks;
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* Strip every unknown key from the webpieces.config.json above `cwd` and rewrite it. Throws when no
|
|
@@ -118,7 +121,7 @@ let ConfigPruner = class ConfigPruner {
|
|
|
118
121
|
}
|
|
119
122
|
// webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above
|
|
120
123
|
const document = parsed;
|
|
121
|
-
const removed = this.removeUnknown(document);
|
|
124
|
+
const removed = this.removeUnknown(document, this.rulePacks.loadFrom(path.dirname(configPath)));
|
|
122
125
|
if (removed.length > 0) {
|
|
123
126
|
this.atomicFile.writeAtomic(configPath, JSON.stringify(document, null, this.indentOf(text)) + '\n');
|
|
124
127
|
}
|
|
@@ -126,7 +129,7 @@ let ConfigPruner = class ConfigPruner {
|
|
|
126
129
|
}
|
|
127
130
|
/** Mutates `document`, deleting every prunable name from the two rule sections. */
|
|
128
131
|
// webpieces-disable no-any-unknown -- opaque parsed config document
|
|
129
|
-
removeUnknown(document) {
|
|
132
|
+
removeUnknown(document, registry) {
|
|
130
133
|
// A custom rules directory means a name with no built-in schema may be entirely legitimate.
|
|
131
134
|
const rulesDir = document['rulesDir'];
|
|
132
135
|
if (Array.isArray(rulesDir) && rulesDir.length > 0)
|
|
@@ -139,7 +142,7 @@ let ConfigPruner = class ConfigPruner {
|
|
|
139
142
|
// webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above
|
|
140
143
|
const entries = section;
|
|
141
144
|
for (const key of Object.keys(entries)) {
|
|
142
|
-
const reason = this.reasonToRemove(key);
|
|
145
|
+
const reason = this.reasonToRemove(key, registry);
|
|
143
146
|
if (reason === null)
|
|
144
147
|
continue;
|
|
145
148
|
delete entries[key];
|
|
@@ -149,10 +152,10 @@ let ConfigPruner = class ConfigPruner {
|
|
|
149
152
|
return removed;
|
|
150
153
|
}
|
|
151
154
|
/** Why `key` is safe to delete, or null when it must be kept. */
|
|
152
|
-
reasonToRemove(key) {
|
|
153
|
-
if (
|
|
155
|
+
reasonToRemove(key, registry) {
|
|
156
|
+
if (registry.hasRule(key))
|
|
154
157
|
return null;
|
|
155
|
-
const retired =
|
|
158
|
+
const retired = registry.migrations().find(e => e.scope === retired_config_keys_1.RETIRED_SCOPE_RULE && e.key === key);
|
|
156
159
|
if (retired) {
|
|
157
160
|
if (!retired.prunable)
|
|
158
161
|
return null;
|
|
@@ -177,6 +180,7 @@ exports.ConfigPruner = ConfigPruner;
|
|
|
177
180
|
exports.ConfigPruner = ConfigPruner = tslib_1.__decorate([
|
|
178
181
|
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
179
182
|
tslib_1.__metadata("design:paramtypes", [config_file_1.ConfigFile,
|
|
180
|
-
tooling_common_1.AtomicFile
|
|
183
|
+
tooling_common_1.AtomicFile,
|
|
184
|
+
rule_pack_selection_1.RulePackSelection])
|
|
181
185
|
], ConfigPruner);
|
|
182
186
|
//# sourceMappingURL=config-pruner.js.map
|
package/src/config-pruner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-pruner.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-pruner.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,yCAA2D;AAE3D,8DAAuD;AACvD,+CAA2C;AAC3C,2CAAoD;AACpD,iDAA8C;AAC9C,+DAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iGAAiG;AACjG,MAAa,SAAS;IAClB,4DAA4D;IAC5D,OAAO,CAAS;IAChB,8DAA8D;IA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V,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC;YACnC,OAAO,OAAO,CAAC,OAAO,KAAK,EAAE;gBACzB,CAAC,CAAC,yCAAyC;gBAC3C,CAAC,CAAC,sCAAsC,OAAO,CAAC,OAAO,EAAE,CAAC;QAClE,CAAC;QACD,OAAO,+DAA+D,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACK,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3B,CAAC;CACJ,CAAA;AArFY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,wBAAU;QACV,2BAAU;GAHlC,YAAY,CAqFxB","sourcesContent":["import * as fs from 'fs';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { AtomicFile } from '@webpieces/tooling-common';\nimport { ConfigFile } from './config-file';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\nimport { RULE_SCHEMAS } from './rule-schemas';\nimport { RETIRED_CONFIG_KEYS, RETIRED_SCOPE_RULE } from './retired-config-keys';\n\n/**\n * `wp-prune-unknown-config` — the MECHANICAL cure for \"[x] Unknown rule\".\n *\n * ## Why a command and not just advice\n *\n * An unknown key controls nothing, so deleting it is the fix, and the validator now says so. But the\n * moment that advice is read is the worst possible moment to act on it by hand: the hook guard denies\n * every Bash call while the config is invalid, so the reader is editing JSON blind, with no way to\n * re-run the validator between edits. Making the cleanup one command means cleanliness is the default\n * path rather than a judgement call taken under a total block — and it makes \"the file validates\" mean\n * \"every key in it is real\", which is the property that keeps dead config from reading as live config.\n *\n * ## What it removes, and what it deliberately does NOT\n *\n * Removed, from the `rules` and `hookGuards` sections only:\n * - a name with no entry in RULE_SCHEMAS and no entry in RETIRED_CONFIG_KEYS (a typo, or a rule some\n * release deleted). Nothing reads it, by construction.\n * - a name in RETIRED_CONFIG_KEYS whose entry is `prunable` — the retirement's own instruction is\n * \"delete this entry\", because the setting left webpieces.config.json entirely.\n *\n * NOT removed:\n * - a RENAME or an in-file move (`prunable: false`). Deleting those discards a value the new key still\n * needs, so they keep their migration instruction and a human/agent applies it.\n * - anything at all when `rulesDir` is configured. A custom rule legitimately has no built-in schema,\n * and this command must never eat one.\n * - top-level keys, `commands`, `excludePaths`, `match-rules`. Those are validated by shape, not by a\n * name table, so \"unknown\" is not defined for them and a pruner would be guessing.\n *\n * ## The one destructive case, and why the drift guard already covers it\n *\n * A key CAN be valid-but-unlearned when package.json pins an @webpieces older than the config. Pruning\n * then would delete live config. That case cannot reach here: the shim's version-drift guard compares\n * the pin against the installed version and denies every tool call — including this one — before the\n * validator or this command ever runs. It is also why `PruneResult` names every key it removed rather\n * than reporting a count: a silent sweep is the thing that would make the rare case unrecoverable.\n */\n\n/** One key this run removed, and the reason it was safe to remove. Data-only (per CLAUDE.md). */\nexport class PrunedKey {\n /** `rules` or `hookGuards` — the section the key sat in. */\n section: string;\n /** The rule/guard name exactly as it appeared in the file. */\n key: string;\n /** Human-readable justification, printed per key so no removal is silent. */\n reason: string;\n\n constructor(section: string, key: string, reason: string) {\n this.section = section;\n this.key = key;\n this.reason = reason;\n }\n}\n\n/** The outcome of one prune. Data-only. */\nexport class PruneResult {\n /** The webpieces.config.json that was inspected. */\n configPath: string;\n removed: PrunedKey[];\n\n constructor(configPath: string, removed: PrunedKey[]) {\n this.configPath = configPath;\n this.removed = removed;\n }\n\n /** True when the file was rewritten. */\n changed(): boolean {\n return this.removed.length > 0;\n }\n\n /** The report the CLI prints. Every removed key is named; nothing is summarised away. */\n describeSelf(): string {\n if (!this.changed()) {\n return `[${PRUNE_UNKNOWN_COMMAND}] No unknown keys in ${this.configPath} — nothing to remove.`;\n }\n const lines = this.removed.map((r: PrunedKey): string => ` • ${r.section}.${r.key} — ${r.reason}`);\n return `[${PRUNE_UNKNOWN_COMMAND}] Removed ${this.removed.length} unknown key(s) from ` +\n `${this.configPath}:\\n${lines.join('\\n')}`;\n }\n}\n\n/** The sections a rule/guard name may legally sit in — the only two this command touches. */\nconst PRUNABLE_SECTIONS: readonly string[] = ['rules', 'hookGuards'];\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigPruner {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n /**\n * Strip every unknown key from the webpieces.config.json above `cwd` and rewrite it. Throws when no\n * config file is found — a prune with no target is a mistake, not a no-op.\n */\n pruneFrom(cwd: string): PruneResult {\n const configPath = this.configFile.findConfigFile(cwd);\n if (configPath === null) {\n throw new Error(`[${PRUNE_UNKNOWN_COMMAND}] No webpieces.config.json found above ${cwd}.`);\n }\n return this.prune(configPath);\n }\n\n /**\n * Strip every unknown key from `configPath` and rewrite it in place. Reads the file directly rather\n * than through the loader: the loader VALIDATES, and this command's whole purpose is to run on a\n * file that fails validation.\n */\n prune(configPath: string): PruneResult {\n const text = fs.readFileSync(configPath, 'utf8');\n // webpieces-disable no-any-unknown -- the raw config document is opaque JSON until narrowed below\n const parsed: unknown = JSON.parse(text);\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error(`[${PRUNE_UNKNOWN_COMMAND}] ${configPath} is not a JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above\n const document = parsed as Record<string, unknown>;\n const removed = this.removeUnknown(document);\n if (removed.length > 0) {\n this.atomicFile.writeAtomic(configPath, JSON.stringify(document, null, this.indentOf(text)) + '\\n');\n }\n return new PruneResult(configPath, removed);\n }\n\n /** Mutates `document`, deleting every prunable name from the two rule sections. */\n // webpieces-disable no-any-unknown -- opaque parsed config document\n private removeUnknown(document: Record<string, unknown>): PrunedKey[] {\n // A custom rules directory means a name with no built-in schema may be entirely legitimate.\n const rulesDir = document['rulesDir'];\n if (Array.isArray(rulesDir) && rulesDir.length > 0) return [];\n\n const removed: PrunedKey[] = [];\n for (const sectionName of PRUNABLE_SECTIONS) {\n const section = document[sectionName];\n if (typeof section !== 'object' || section === null || Array.isArray(section)) continue;\n // webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above\n const entries = section as Record<string, unknown>;\n for (const key of Object.keys(entries)) {\n const reason = this.reasonToRemove(key);\n if (reason === null) continue;\n delete entries[key];\n removed.push(new PrunedKey(sectionName, key, reason));\n }\n }\n return removed;\n }\n\n /** Why `key` is safe to delete, or null when it must be kept. */\n private reasonToRemove(key: string): string | null {\n if (RULE_SCHEMAS[key]) return null;\n const retired = RETIRED_CONFIG_KEYS.find(\n e => e.scope === RETIRED_SCOPE_RULE && e.key === key);\n if (retired) {\n if (!retired.prunable) return null;\n return retired.movedTo === ''\n ? 'RETIRED and removed with no replacement'\n : `RETIRED — the setting now lives at ${retired.movedTo}`;\n }\n return 'no running validator has a schema for it, so nothing reads it';\n }\n\n /**\n * The file's own indentation, so a prune does not reformat every line it did not touch. Falls back to\n * 4 (the shape every webpieces.config.json in the wild uses) when the document is single-line.\n */\n private indentOf(text: string): number {\n const match = /\\n( +)\"/.exec(text);\n if (match === null) return 4;\n return match[1].length;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config-pruner.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/config-pruner.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,yCAA2D;AAE3D,8DAAuD;AACvD,+CAA2C;AAC3C,2CAAoD;AACpD,wDAAkC;AAElC,+DAA0D;AAC1D,+DAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,iGAAiG;AACjG,MAAa,SAAS;IAClB,4DAA4D;IAC5D,OAAO,CAAS;IAChB,8DAA8D;IAC9D,GAAG,CAAS;IACZ,6EAA6E;IAC7E,MAAM,CAAS;IAEf,YAAY,OAAe,EAAE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CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,wCAAkB,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QAC1D,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC;YACnC,OAAO,OAAO,CAAC,OAAO,KAAK,EAAE;gBACzB,CAAC,CAAC,yCAAyC;gBAC3C,CAAC,CAAC,sCAAsC,OAAO,CAAC,OAAO,EAAE,CAAC;QAClE,CAAC;QACD,OAAO,+DAA+D,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACK,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3B,CAAC;CACJ,CAAA;AAtFY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,wBAAU;QACV,2BAAU;QACX,uCAAiB;GAJxC,YAAY,CAsFxB","sourcesContent":["import * as fs from 'fs';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { AtomicFile } from '@webpieces/tooling-common';\nimport { ConfigFile } from './config-file';\nimport { PRUNE_UNKNOWN_COMMAND } from './constants';\nimport * as path from 'node:path';\nimport { RulePackRegistry } from './rule-pack-registry';\nimport { RulePackSelection } from './rule-pack-selection';\nimport { RETIRED_SCOPE_RULE } from './retired-config-keys';\n\n/**\n * `wp-prune-unknown-config` — the MECHANICAL cure for \"[x] Unknown rule\".\n *\n * ## Why a command and not just advice\n *\n * An unknown key controls nothing, so deleting it is the fix, and the validator now says so. But the\n * moment that advice is read is the worst possible moment to act on it by hand: the hook guard denies\n * every Bash call while the config is invalid, so the reader is editing JSON blind, with no way to\n * re-run the validator between edits. Making the cleanup one command means cleanliness is the default\n * path rather than a judgement call taken under a total block — and it makes \"the file validates\" mean\n * \"every key in it is real\", which is the property that keeps dead config from reading as live config.\n *\n * ## What it removes, and what it deliberately does NOT\n *\n * Removed, from the `rules` and `hookGuards` sections only:\n * - a name with no entry in RULE_SCHEMAS and no entry in RETIRED_CONFIG_KEYS (a typo, or a rule some\n * release deleted). Nothing reads it, by construction.\n * - a name in RETIRED_CONFIG_KEYS whose entry is `prunable` — the retirement's own instruction is\n * \"delete this entry\", because the setting left webpieces.config.json entirely.\n *\n * NOT removed:\n * - a RENAME or an in-file move (`prunable: false`). Deleting those discards a value the new key still\n * needs, so they keep their migration instruction and a human/agent applies it.\n * - anything at all when `rulesDir` is configured. A custom rule legitimately has no built-in schema,\n * and this command must never eat one.\n * - top-level keys, `commands`, `excludePaths`, `match-rules`. Those are validated by shape, not by a\n * name table, so \"unknown\" is not defined for them and a pruner would be guessing.\n *\n * ## The one destructive case, and why the drift guard already covers it\n *\n * A key CAN be valid-but-unlearned when package.json pins an @webpieces older than the config. Pruning\n * then would delete live config. That case cannot reach here: the shim's version-drift guard compares\n * the pin against the installed version and denies every tool call — including this one — before the\n * validator or this command ever runs. It is also why `PruneResult` names every key it removed rather\n * than reporting a count: a silent sweep is the thing that would make the rare case unrecoverable.\n */\n\n/** One key this run removed, and the reason it was safe to remove. Data-only (per CLAUDE.md). */\nexport class PrunedKey {\n /** `rules` or `hookGuards` — the section the key sat in. */\n section: string;\n /** The rule/guard name exactly as it appeared in the file. */\n key: string;\n /** Human-readable justification, printed per key so no removal is silent. */\n reason: string;\n\n constructor(section: string, key: string, reason: string) {\n this.section = section;\n this.key = key;\n this.reason = reason;\n }\n}\n\n/** The outcome of one prune. Data-only. */\nexport class PruneResult {\n /** The webpieces.config.json that was inspected. */\n configPath: string;\n removed: PrunedKey[];\n\n constructor(configPath: string, removed: PrunedKey[]) {\n this.configPath = configPath;\n this.removed = removed;\n }\n\n /** True when the file was rewritten. */\n changed(): boolean {\n return this.removed.length > 0;\n }\n\n /** The report the CLI prints. Every removed key is named; nothing is summarised away. */\n describeSelf(): string {\n if (!this.changed()) {\n return `[${PRUNE_UNKNOWN_COMMAND}] No unknown keys in ${this.configPath} — nothing to remove.`;\n }\n const lines = this.removed.map((r: PrunedKey): string => ` • ${r.section}.${r.key} — ${r.reason}`);\n return `[${PRUNE_UNKNOWN_COMMAND}] Removed ${this.removed.length} unknown key(s) from ` +\n `${this.configPath}:\\n${lines.join('\\n')}`;\n }\n}\n\n/** The sections a rule/guard name may legally sit in — the only two this command touches. */\nconst PRUNABLE_SECTIONS: readonly string[] = ['rules', 'hookGuards'];\n\n@injectable(bindingScopeValues.Singleton)\nexport class ConfigPruner {\n constructor(\n private readonly configFile: ConfigFile,\n private readonly atomicFile: AtomicFile,\n private readonly rulePacks: RulePackSelection,\n ) {}\n\n /**\n * Strip every unknown key from the webpieces.config.json above `cwd` and rewrite it. Throws when no\n * config file is found — a prune with no target is a mistake, not a no-op.\n */\n pruneFrom(cwd: string): PruneResult {\n const configPath = this.configFile.findConfigFile(cwd);\n if (configPath === null) {\n throw new Error(`[${PRUNE_UNKNOWN_COMMAND}] No webpieces.config.json found above ${cwd}.`);\n }\n return this.prune(configPath);\n }\n\n /**\n * Strip every unknown key from `configPath` and rewrite it in place. Reads the file directly rather\n * than through the loader: the loader VALIDATES, and this command's whole purpose is to run on a\n * file that fails validation.\n */\n prune(configPath: string): PruneResult {\n const text = fs.readFileSync(configPath, 'utf8');\n // webpieces-disable no-any-unknown -- the raw config document is opaque JSON until narrowed below\n const parsed: unknown = JSON.parse(text);\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new Error(`[${PRUNE_UNKNOWN_COMMAND}] ${configPath} is not a JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above\n const document = parsed as Record<string, unknown>;\n const removed = this.removeUnknown(document, this.rulePacks.loadFrom(path.dirname(configPath)));\n if (removed.length > 0) {\n this.atomicFile.writeAtomic(configPath, JSON.stringify(document, null, this.indentOf(text)) + '\\n');\n }\n return new PruneResult(configPath, removed);\n }\n\n /** Mutates `document`, deleting every prunable name from the two rule sections. */\n // webpieces-disable no-any-unknown -- opaque parsed config document\n private removeUnknown(document: Record<string, unknown>, registry: RulePackRegistry): PrunedKey[] {\n // A custom rules directory means a name with no built-in schema may be entirely legitimate.\n const rulesDir = document['rulesDir'];\n if (Array.isArray(rulesDir) && rulesDir.length > 0) return [];\n\n const removed: PrunedKey[] = [];\n for (const sectionName of PRUNABLE_SECTIONS) {\n const section = document[sectionName];\n if (typeof section !== 'object' || section === null || Array.isArray(section)) continue;\n // webpieces-disable no-any-unknown -- narrowed to a non-null, non-array object one line above\n const entries = section as Record<string, unknown>;\n for (const key of Object.keys(entries)) {\n const reason = this.reasonToRemove(key, registry);\n if (reason === null) continue;\n delete entries[key];\n removed.push(new PrunedKey(sectionName, key, reason));\n }\n }\n return removed;\n }\n\n /** Why `key` is safe to delete, or null when it must be kept. */\n private reasonToRemove(key: string, registry: RulePackRegistry): string | null {\n if (registry.hasRule(key)) return null;\n const retired = registry.migrations().find(\n e => e.scope === RETIRED_SCOPE_RULE && e.key === key);\n if (retired) {\n if (!retired.prunable) return null;\n return retired.movedTo === ''\n ? 'RETIRED and removed with no replacement'\n : `RETIRED — the setting now lives at ${retired.movedTo}`;\n }\n return 'no running validator has a schema for it, so nothing reads it';\n }\n\n /**\n * The file's own indentation, so a prune does not reformat every line it did not touch. Falls back to\n * 4 (the shape every webpieces.config.json in the wild uses) when the document is single-line.\n */\n private indentOf(text: string): number {\n const match = /\\n( +)\"/.exec(text);\n if (match === null) return 4;\n return match[1].length;\n }\n}\n"]}
|
package/src/constants.d.ts
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
1
|
export declare const WEBPIECES_DISABLE = "webpieces-disable";
|
|
2
|
-
export declare const RULE_NAMES: {
|
|
3
|
-
readonly NO_ANY_UNKNOWN: "no-any-unknown";
|
|
4
|
-
readonly NO_IMPLICIT_ANY: "no-implicit-any";
|
|
5
|
-
readonly NO_DESTRUCTURE: "no-destructure";
|
|
6
|
-
readonly NO_UNMANAGED_EXCEPTIONS: "no-unmanaged-exceptions";
|
|
7
|
-
readonly CATCH_ERROR_PATTERN: "catch-error-pattern";
|
|
8
|
-
readonly THROW_CAUSE_REQUIRED: "throw-cause-required";
|
|
9
|
-
readonly REQUIRE_RETURN_TYPE: "require-return-type";
|
|
10
|
-
readonly NO_SYMBOL_DI_TOKENS: "no-symbol-di-tokens";
|
|
11
|
-
readonly NO_CLIENT_CREATION_OUTSIDE_SERVER_OR_CLIENT: "no-client-creation-outside-server-or-client";
|
|
12
|
-
readonly NO_PROCESS_EXIT_OUTSIDE_MAIN: "no-process-exit-outside-main";
|
|
13
|
-
readonly NO_FUNCTION_OUTSIDE_CLASS: "no-function-outside-class";
|
|
14
|
-
readonly INJECT_ANNOTATION_NOT_NEEDED_FOR_CONCRETE_CLASS: "inject-annotation-not-needed-for-concrete-class";
|
|
15
|
-
readonly FRAMEWORK_TAG: "framework-tag";
|
|
16
|
-
readonly ROLE_TAG: "role-tag";
|
|
17
|
-
readonly ENSURE_WE_ARE_SECURE: "ensure-we-are-secure";
|
|
18
|
-
readonly NO_INLINE_TYPES: "no-inline-types";
|
|
19
|
-
readonly NO_DIRECT_API_RESOLVER: "no-direct-api-resolver";
|
|
20
|
-
readonly NO_CUSTOM_CSS: "no-custom-css";
|
|
21
|
-
readonly NO_STATE_PATHS_IN_TEMPLATES: "no-state-paths-in-templates";
|
|
22
|
-
readonly PRISMA_CONVERTER: "prisma-converter";
|
|
23
|
-
readonly MAX_LINES_NEW_METHODS: "max-lines-new-methods";
|
|
24
|
-
readonly MAX_LINES_MODIFIED_FILES: "max-lines-modified-files";
|
|
25
|
-
readonly MAX_LINES_MODIFIED: "max-lines-modified";
|
|
26
|
-
readonly NO_ROOT_UNION_API_TYPE: "no-root-union-api-type";
|
|
27
|
-
readonly API_RULES_FOR_OPENAPI: "api-rules-for-openapi";
|
|
28
|
-
readonly API_RULES_FOR_MCP: "api-rules-for-mcp";
|
|
29
|
-
readonly NO_INLINE_IMPORT_IN_API_LIB: "no-inline-import-in-api-lib";
|
|
30
|
-
readonly ONE_ENUM_SPELLING_IN_API_LIB: "one-enum-spelling-in-api-lib";
|
|
31
|
-
readonly NO_UTILITY_TYPES_IN_API_LIB: "no-utility-types-in-api-lib";
|
|
32
|
-
readonly REQUIRED_TYPE_SUFFIX: "required-type-suffix";
|
|
33
|
-
readonly API_LIB_DEPENDENCIES: "api-lib-dependencies";
|
|
34
|
-
readonly API_LIB_PATH: "api-lib-path";
|
|
35
|
-
readonly FRAMEWORK_FOLDER: "framework-folder";
|
|
36
|
-
readonly FRAMEWORK_TSCONFIG: "framework-tsconfig";
|
|
37
|
-
readonly FRAMEWORK_PACKAGES: "framework-packages";
|
|
38
|
-
};
|
|
39
2
|
export declare const MERGE_INFO_DIR = "merge-info";
|
|
40
3
|
export declare const MERGE_IN_PROGRESS_FILE = "merge-in-progress.json";
|
|
41
4
|
export declare const PUSH_DEV_STATE_FILE = "push-dev-in-progress.json";
|
package/src/constants.js
CHANGED
|
@@ -6,50 +6,13 @@
|
|
|
6
6
|
// The legacy `ai-hook-disable` alias and the `-file`/`-next`/`-all` variants and the
|
|
7
7
|
// `*`/bare (no-rule) wildcard have been removed — every disable MUST name a rule.
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.MERGE_EXPLANATION_FILE = exports.PUSH_DEV_STATE_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.MERGE_INFO_DIR = exports.
|
|
9
|
+
exports.UPGRADE_SHIM_COMMAND = exports.PRUNE_UNKNOWN_COMMAND = exports.MERGE_EXPLANATION_FILE = exports.PUSH_DEV_STATE_FILE = exports.MERGE_IN_PROGRESS_FILE = exports.MERGE_INFO_DIR = exports.WEBPIECES_DISABLE = void 0;
|
|
10
10
|
exports.hasDisable = hasDisable;
|
|
11
11
|
exports.WEBPIECES_DISABLE = 'webpieces-disable';
|
|
12
12
|
// Rule-name tokens as they appear AFTER `webpieces-disable` in a disable comment.
|
|
13
13
|
// Values must match existing comments exactly — changing a value silently breaks every
|
|
14
14
|
// disable that names that rule. Note MAX_LINES_MODIFIED is a prefix of
|
|
15
15
|
// MAX_LINES_MODIFIED_FILES (a historical substring-match quirk preserved on purpose).
|
|
16
|
-
exports.RULE_NAMES = {
|
|
17
|
-
NO_ANY_UNKNOWN: 'no-any-unknown',
|
|
18
|
-
NO_IMPLICIT_ANY: 'no-implicit-any',
|
|
19
|
-
NO_DESTRUCTURE: 'no-destructure',
|
|
20
|
-
NO_UNMANAGED_EXCEPTIONS: 'no-unmanaged-exceptions',
|
|
21
|
-
CATCH_ERROR_PATTERN: 'catch-error-pattern',
|
|
22
|
-
THROW_CAUSE_REQUIRED: 'throw-cause-required',
|
|
23
|
-
REQUIRE_RETURN_TYPE: 'require-return-type',
|
|
24
|
-
NO_SYMBOL_DI_TOKENS: 'no-symbol-di-tokens',
|
|
25
|
-
NO_CLIENT_CREATION_OUTSIDE_SERVER_OR_CLIENT: 'no-client-creation-outside-server-or-client',
|
|
26
|
-
NO_PROCESS_EXIT_OUTSIDE_MAIN: 'no-process-exit-outside-main',
|
|
27
|
-
NO_FUNCTION_OUTSIDE_CLASS: 'no-function-outside-class',
|
|
28
|
-
INJECT_ANNOTATION_NOT_NEEDED_FOR_CONCRETE_CLASS: 'inject-annotation-not-needed-for-concrete-class',
|
|
29
|
-
FRAMEWORK_TAG: 'framework-tag',
|
|
30
|
-
ROLE_TAG: 'role-tag',
|
|
31
|
-
ENSURE_WE_ARE_SECURE: 'ensure-we-are-secure',
|
|
32
|
-
NO_INLINE_TYPES: 'no-inline-types',
|
|
33
|
-
NO_DIRECT_API_RESOLVER: 'no-direct-api-resolver',
|
|
34
|
-
NO_CUSTOM_CSS: 'no-custom-css',
|
|
35
|
-
NO_STATE_PATHS_IN_TEMPLATES: 'no-state-paths-in-templates',
|
|
36
|
-
PRISMA_CONVERTER: 'prisma-converter',
|
|
37
|
-
MAX_LINES_NEW_METHODS: 'max-lines-new-methods',
|
|
38
|
-
MAX_LINES_MODIFIED_FILES: 'max-lines-modified-files',
|
|
39
|
-
MAX_LINES_MODIFIED: 'max-lines-modified',
|
|
40
|
-
NO_ROOT_UNION_API_TYPE: 'no-root-union-api-type',
|
|
41
|
-
API_RULES_FOR_OPENAPI: 'api-rules-for-openapi',
|
|
42
|
-
API_RULES_FOR_MCP: 'api-rules-for-mcp',
|
|
43
|
-
NO_INLINE_IMPORT_IN_API_LIB: 'no-inline-import-in-api-lib',
|
|
44
|
-
ONE_ENUM_SPELLING_IN_API_LIB: 'one-enum-spelling-in-api-lib',
|
|
45
|
-
NO_UTILITY_TYPES_IN_API_LIB: 'no-utility-types-in-api-lib',
|
|
46
|
-
REQUIRED_TYPE_SUFFIX: 'required-type-suffix',
|
|
47
|
-
API_LIB_DEPENDENCIES: 'api-lib-dependencies',
|
|
48
|
-
API_LIB_PATH: 'api-lib-path',
|
|
49
|
-
FRAMEWORK_FOLDER: 'framework-folder',
|
|
50
|
-
FRAMEWORK_TSCONFIG: 'framework-tsconfig',
|
|
51
|
-
FRAMEWORK_PACKAGES: 'framework-packages',
|
|
52
|
-
};
|
|
53
16
|
// Merge-state convention shared by the pr-gate scripts (which WRITE the marker during a
|
|
54
17
|
// conflicted 3-point merge) and the ai-hook-rules merge-in-progress-guard (which READS it
|
|
55
18
|
// to block commit/push/PR until the merge is validated). Kept here so neither package
|
package/src/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/constants.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,sEAAsE;AACtE,EAAE;AACF,yFAAyF;AACzF,qFAAqF;AACrF,kFAAkF;;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/constants.ts"],"names":[],"mappings":";AAAA,iFAAiF;AACjF,sEAAsE;AACtE,EAAE;AACF,yFAAyF;AACzF,qFAAqF;AACrF,kFAAkF;;;AA6ElF,gCAEC;AA7EY,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,kFAAkF;AAClF,uFAAuF;AACvF,uEAAuE;AACvE,sFAAsF;AAGtF,wFAAwF;AACxF,0FAA0F;AAC1F,sFAAsF;AACtF,0DAA0D;AAC1D,EAAE;AACF,mFAAmF;AACnF,uFAAuF;AACvF,0FAA0F;AAC1F,iGAAiG;AACjG,8FAA8F;AAC9F,yFAAyF;AACzF,mGAAmG;AACnG,2FAA2F;AAC3F,kGAAkG;AAClG,mGAAmG;AACnG,4DAA4D;AAC/C,QAAA,cAAc,GAAG,YAAY,CAAC;AAC3C,kGAAkG;AAClG,qGAAqG;AACrG,iCAAiC;AACpB,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,uFAAuF;AACvF,qGAAqG;AACrG,8FAA8F;AAC9F,2DAA2D;AAC3D,EAAE;AACF,kGAAkG;AAClG,iGAAiG;AACjG,oGAAoG;AACpG,kGAAkG;AACrF,QAAA,mBAAmB,GAAG,2BAA2B,CAAC;AAE/D,2FAA2F;AAC3F,mFAAmF;AACnF,uFAAuF;AACvF,uGAAuG;AACvG,kGAAkG;AAClG,kGAAkG;AAClG,iDAAiD;AACpC,QAAA,sBAAsB,GAAG,sBAAsB,CAAC;AAE7D;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,8BAA8B,CAAC;AAEpE;;;;GAIG;AACU,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAE3D;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,IAAI,CAAC,QAAQ,CAAC,yBAAiB,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvE,CAAC","sourcesContent":["// Single source of truth for the disable-comment token and rule-name identifiers\n// shared across rules-config, ai-hook-rules, code-rules, and pr-gate.\n//\n// There is exactly ONE disable form: `// webpieces-disable <rule>[, <rule2>] -- reason`.\n// The legacy `ai-hook-disable` alias and the `-file`/`-next`/`-all` variants and the\n// `*`/bare (no-rule) wildcard have been removed — every disable MUST name a rule.\n\nexport const WEBPIECES_DISABLE = 'webpieces-disable';\n\n// Rule-name tokens as they appear AFTER `webpieces-disable` in a disable comment.\n// Values must match existing comments exactly — changing a value silently breaks every\n// disable that names that rule. Note MAX_LINES_MODIFIED is a prefix of\n// MAX_LINES_MODIFIED_FILES (a historical substring-match quirk preserved on purpose).\n\n\n// Merge-state convention shared by the pr-gate scripts (which WRITE the marker during a\n// conflicted 3-point merge) and the ai-hook-rules merge-in-progress-guard (which READS it\n// to block commit/push/PR until the merge is validated). Kept here so neither package\n// depends on the other — they only share this vocabulary.\n//\n// `.webpieces/` is the single working dir for all webpieces tooling: ai-hook-rules\n// bootstrap/cache, the instruct-ai docs, and the workflow state. To keep the top level\n// quiet, per-feature workflow dirs are nested one level down under `merge-info/<feature>`\n// and `pr-review/<feature>` rather than scattered as top-level `merge-<feature>`/`pr-<feature>`.\n// `.webpieces/` is gitignored; only the per-feature subdirs under those two homes are subject\n// to 30-day cleanup (the homes themselves, like hooks/ and instruct-ai/, are permanent).\n// The DIRECTORY NAME only. Never join it onto a root yourself — go through `DotWebpieces.shared()`\n// (repo-wide state), `DotWebpieces.local()` (this worktree's own tooling-written state) or\n// `DotWebpieces.aiWritable()` (this worktree's state that a CODING AGENT writes) so the call site\n// declares its scope. In a linked worktree the three resolve to different places, and getting that\n// silently wrong is the bug those methods exist to prevent.\nexport const MERGE_INFO_DIR = 'merge-info';\n// The PR working home. Renamed from the legacy `pr-info` to `pr-review` for clarity (it holds the\n// AI's PR review + rendered body). Old `pr-info/` dirs are gitignored local state and self-clear via\n// cleanTmp's legacy `pr-` sweep.\nexport const MERGE_IN_PROGRESS_FILE = 'merge-in-progress.json';\n\n// The dev-deploy resolve state file, written by `wp-push-dev --resolve` and cleared by\n// `wp-finish-push-dev` (or `--abort`). Named here for the same reason MERGE_IN_PROGRESS_FILE is: the\n// pr-gate commands WRITE it and things outside pr-gate READ it to decide whether a resolve is\n// half-finished, and neither side may depend on the other.\n//\n// It lives directly under `.webpieces/` local state (NOT under merge-info/), because a dev-deploy\n// resolve is not a 3-point merge: it never touches the feature branch, never produces merge-info\n// context, and must NOT be picked up by merge-in-progress-guard's marker scan — that guard's remedy\n// is `pnpm wp-finish-upsert-pr`, which is the wrong command here and would strand the tmp branch.\nexport const PUSH_DEV_STATE_FILE = 'push-dev-in-progress.json';\n\n// Proof-of-work the AI must produce for every conflicted file it resolves during a 3-point\n// merge: a short explanation written NEXT TO that file's 3-point context (the same\n// `updatemain-<safe_path>/` dir that holds A-forkpoint.txt / B-A.diff / C-A.diff). The\n// wp-finish-upsert-pr gate requires a non-empty file of this name per conflicted file before passing —\n// it is the only check on the part of the process the AI actually owns (resolving files). Using a\n// sidecar file (rather than an in-source comment) works for any file type, including comment-less\n// ones like JSON and files resolved by deletion.\nexport const MERGE_EXPLANATION_FILE = 'merge-explanation.md';\n\n/**\n * The command that MECHANICALLY strips every unknown key from webpieces.config.json.\n *\n * An unknown key controls nothing, so deleting it is the cure — but \"delete it\" is a judgement call made\n * while the guard denies every Bash call, which is exactly when a reader is least able to make one. This\n * command turns that judgement into one keystroke, and every message that reports an unknown key names it.\n *\n * Lives in this leaf module (no imports) so both the banner and the validators can name it without\n * importing the pruner and re-creating an import cycle.\n */\nexport const PRUNE_UNKNOWN_COMMAND = 'pnpm wp-prune-unknown-config';\n\n/**\n * The command that rewrites every webpieces-owned file a repo commits — the L0 hook shim and the generic\n * reviewer agent (`.claude/agents/webpieces-reviewer.md`). Named here, in the leaf module, so the config\n * validator that finds that agent missing can print the cure without importing ai-hook-rules.\n */\nexport const UPGRADE_SHIM_COMMAND = 'pnpm wp-upgrade-shim';\n\n/**\n * Fast predicate: does this text carry a webpieces-disable for the given rule?\n * Line-agnostic — the caller decides which line(s) or block of text to feed it.\n * This is the cheap substring form used by code-rules detection and pr-gate's\n * dashboard grep/count. (ai-hook-rules uses a richer line-mapping parser.)\n */\nexport function hasDisable(text: string, ruleName: string): boolean {\n return text.includes(WEBPIECES_DISABLE) && text.includes(ruleName);\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -17,8 +17,7 @@ export { DocumentDesign, isDocumentDesign, DESIGN_METADATA_KEYS } from './di';
|
|
|
17
17
|
export { ExcludePaths, isWebpiecesStateDir } from './exclude-hook-paths';
|
|
18
18
|
export { isPathExcluded, matchesAnyGlob } from './exclude-paths';
|
|
19
19
|
export { GENERATED_CODE_PATHS } from './generated-code-paths';
|
|
20
|
-
export { NoCustomCssScope } from './no-custom-css-scope';
|
|
21
|
-
export { defaultRules, defaultRulesDir } from './default-rules';
|
|
20
|
+
export { NoCustomCssScope, PathScopeConfig } from './no-custom-css-scope';
|
|
22
21
|
export { loadTemplate, writeTemplateIfMissing, writeTemplate, TemplateWriter, } from './load-template';
|
|
23
22
|
export { GIT_WORKFLOW_DOC, GitWorkflowDoc, InstructAiDoc, InstructAiDocSet, MergeProcessDoc, } from './instruct-ai-docs';
|
|
24
23
|
export { MERGE_PROCESS_DOC, MergeProcessText, MergeRun, ReferenceMergeRun, } from './merge-process-doc';
|
|
@@ -26,7 +25,7 @@ export { BUILD_LOG_DOC } from './build-log-doc';
|
|
|
26
25
|
export { validateWebpiecesConfig, validatePrGateSection, validateChecklistsSection, validateSectionPlacement, validateExcludePaths, validateMatchRulesSection, allRuleNames, recommendedSeedMode, recommendedSeedModeFor, seedEntryForRule, } from './validate-config';
|
|
27
26
|
export { validateCommandsSection } from './commands-section-validators';
|
|
28
27
|
export { unknownKeyErrors, isCommentKey, validateTopLevelKeys, COMMENT_KEY_SUFFIX, } from './config-key-rules';
|
|
29
|
-
export { RETIRED_CONFIG_KEYS, RETIRED_SCOPE_KEY, RETIRED_SCOPE_RULE,
|
|
28
|
+
export { RETIRED_CONFIG_KEYS, RETIRED_SCOPE_KEY, RETIRED_SCOPE_RULE, isRetiredKey, retiredEntry, retiredKeyError, retiredKeyErrorsIn, retiredRuleFor, } from './retired-config-keys';
|
|
30
29
|
export { ConfigPruner, PruneResult, PrunedKey } from './config-pruner';
|
|
31
30
|
export { validateChecklistDocs } from './checklist-docs-validator';
|
|
32
31
|
export { HomeConfig, HomeConfigService, RetiredHomeConfigKey, RETIRED_HOME_CONFIG_KEYS, HOME_CONFIG_DIR, HOME_CONFIG_FILE, HOME_EXPERIMENTAL_SECTION, HOME_KEY_ORPHAN_DIR_SWEEP, HOME_KEY_WHOLE_REPO_BUILD_GUARD, HOME_KEY_MAX_CONCURRENT_BUILDS, HOME_KEY_TURN_OFF_ALL_REVIEWERS, DEFAULT_MAX_CONCURRENT_BUILDS, HOME_KEY_DOC, HOME_KEY_AI_DOC, DOCUMENTATION_KEYS, } from './home-config';
|
|
@@ -36,32 +35,15 @@ export { OrphanDirArchiver, ArchivedOrphan, FailedOrphan, OrphanSweepResult, Orp
|
|
|
36
35
|
export { OrphanDirSweeper, OrphanSweepReport } from './orphan-dir-sweep';
|
|
37
36
|
export { MatchRuleConfig, MatchRuleViolation, findMatchRuleViolations, isMatchRuleAllowedPath, compileMatchRulePatterns, renderMatchRuleMessage, DEFAULT_MATCH_RULES, } from './match-rules-config';
|
|
38
37
|
export type { ConfigSection } from './sections';
|
|
39
|
-
export { schemaFieldNames
|
|
40
|
-
export {
|
|
41
|
-
export { FieldDef } from './field-def';
|
|
42
|
-
export type { SchemaShape } from './field-def';
|
|
38
|
+
export { schemaFieldNames } from './rule-schemas';
|
|
39
|
+
export { isHookGuard, sectionForRule, } from './sections';
|
|
43
40
|
export { shouldSkipRule, HOTFIX_BUILD_COMMAND, HOTFIX_AUDIT_BANNER } from './skip-rule';
|
|
44
41
|
export { SkipRuleResult } from './skip-rule';
|
|
45
42
|
export { detectBase, resolveBase, getChangedFiles, getFileDiff, getChangedLineNumbers, findNewMethodSignaturesInDiff, hasChangesInRange, isNewOrModified, DiffScope, DiffRange, ChangedFilesOptions, } from './diff-scope';
|
|
46
43
|
export { AbstractRule } from './abstract-rule';
|
|
47
|
-
export { WEBPIECES_DISABLE,
|
|
44
|
+
export { WEBPIECES_DISABLE, hasDisable, MERGE_INFO_DIR, MERGE_IN_PROGRESS_FILE, MERGE_EXPLANATION_FILE, PUSH_DEV_STATE_FILE, PRUNE_UNKNOWN_COMMAND, UPGRADE_SHIM_COMMAND } from './constants';
|
|
48
45
|
export { WebpiecesRulesConfig } from './WebpiecesRulesConfig';
|
|
49
46
|
export { SyncFlowGuidance, WP_START_UPDATE, WP_FINISH_UPDATE, WP_START_UPSERT_PR, WP_FINISH_UPSERT_PR, WP_PUSH_DEV, WP_FINISH_PUSH_DEV, } from './sync-flow-guidance';
|
|
50
|
-
export { MaxMethodLinesConfig, MaxFileLinesConfig, RequireReturnTypeConfig, NoInlineTypeLiteralsConfig, NoAnyUnknownConfig, NoImplicitAnyConfig, PrismaValidateDtosConfig, PrismaConverterConfig, NoDestructureConfig, NoUnmanagedExceptionsConfig, CatchErrorPatternConfig, ThrowCauseRequiredConfig, AngularNoDirectApiInResolverConfig, NoSymbolDiTokensConfig, NoCustomCssConfig, NoProcessExitOutsideMainConfig, NoFunctionOutsideClassConfig, InjectAnnotationNotNeededForConcreteClassConfig, FrameworkTagConfig, RoleTagConfig, EnsureWeAreSecureConfig, BranchCreationGuardConfig, PrLifecycleGuardConfig, NoFileImportCyclesConfig, RuntimeArchitectureConfig, NxWiringConfig, DiGraphConfig, NoJsFilesConfig, ValidateTsInSrcConfig, ValidateArchitectureUnchangedConfig, ValidateNoArchitectureCyclesConfig, ValidatePackageJsonConfig, ValidateVersionsLockedConfig, ValidateEslintSyncConfig, BaseRuleConfig, } from './rule-configs';
|
|
51
|
-
export { NoRootUnionApiTypeConfig } from './no-root-union-config';
|
|
52
|
-
export { NoInlineImportInApiLibConfig, OneEnumSpellingInApiLibConfig } from './api-lib-spelling-configs';
|
|
53
|
-
export { NoUtilityTypesInApiLibConfig } from './no-utility-types-config';
|
|
54
|
-
export { RequiredTypeSuffixConfig, RequiredTypeSuffixEntry } from './required-type-suffix-config';
|
|
55
|
-
export { ApiClientPackagesEntry, ApiLibDependenciesConfig, ApiLibPathConfig, FrameworkFolderConfig, FrameworkFolderEntry, FrameworkPackagesConfig, FrameworkPackagesEntry, FrameworkTsconfigConfig, PROJECT_SCAN_MODES, } from './tag-truth-configs';
|
|
56
|
-
export type { ProjectScanMode } from './tag-truth-configs';
|
|
57
|
-
export { ApiRulesForMcpConfig, ApiRulesForOpenApiConfig, API_DOC_MODES } from './api-doc-rules-config';
|
|
58
|
-
export type { ApiDocMode } from './api-doc-rules-config';
|
|
59
|
-
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';
|
|
60
|
-
export { NoClientCreationOutsideServerOrClientConfig, CLIENT_CREATION_SEVERITIES, } from './no-client-creation-config';
|
|
61
|
-
export type { ClientCreationSeverity } from './no-client-creation-config';
|
|
62
|
-
export { NoStatePathsInTemplatesConfig, DEFAULT_TEMPLATE_DIRS, DEFAULT_BANNED_STATE_PATH_PREFIXES, } from './no-state-paths-config';
|
|
63
|
-
export type { MethodLimitMode, FileLimitMode, ReturnTypeMode, InlineTypeMode, ModifiedCodeMode, ProjectMode, PrismaValidateDtosMode, PrismaConverterMode, DirectApiResolverMode, ThrowCauseMode, OnOffMode, StructuralMode, ValidateTsMode, } from './rule-configs';
|
|
64
|
-
export { BranchStateGuardConfig, DEFAULT_MAX_COMMITS_BEHIND } from './main-sync-guard-configs';
|
|
65
47
|
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';
|
|
66
48
|
export { ChecklistDefinition, ReviewerAgentPolicy, REVIEWER_AGENTS_PLACEHOLDER, DEFAULT_REVIEWER_AGENT_NAME, toChecklist, normalizeChecklistDoc, formatFileList, } from './checklist-config';
|
|
67
49
|
export type { RawChecklistItem } from './checklist-config';
|
|
@@ -74,8 +56,9 @@ export { ReviewProvenanceService, ReviewProvenance, ReviewerTranscript, Reviewer
|
|
|
74
56
|
export { PrSummary, PrContext, ChecklistResult, ChecklistVerdict, ChecklistOverride, ChecklistOverrideService, checklistOverrideService, CK_PASS, CK_WARN, CK_OVERRIDDEN, CK_ORANGE_FIXED, CK_ORANGE, CK_FAIL, CK_MISSING, CK_BAD_FORMAT, VERDICT_GREEN, VERDICT_YELLOW, VERDICT_ORANGE, VERDICT_RED, VERDICT_STATUSES, RequiredChecklist, ChecklistReviewContext, ReviewJsonService, prDirFor, summaryJsonPath, summaryJsonSchemaHint, } from './review-json';
|
|
75
57
|
export { CommandsConfig, buildCommandsConfig, DEFAULT_UPSERT_PR_COMMAND, DEFAULT_MERGE_COMPLETE_COMMAND, } from './commands-config';
|
|
76
58
|
export { StaleBinRemoval, StaleBinSweeper, staleBinSweeper } from './stale-bin-sweep';
|
|
77
|
-
export { SpecTempDirs, specTempDirs } from './spec-temp-dirs';
|
|
78
59
|
export { RepoScratchDirs, SCRATCH_DIR_NAME } from './repo-scratch-dirs';
|
|
79
60
|
export { TmpScratchSweeper, TMP_SCRATCH_RETENTION_DAYS, TMP_SCRATCH_PREFIX } from './tmp-scratch-sweep';
|
|
80
61
|
export * from './hook-fault-codes';
|
|
81
62
|
export * from './hook-config-diagnostics';
|
|
63
|
+
export { RulePackRegistry, NodeRulePackModuleLoader, RulePackDiscovery, RulePackModuleLoader } from './rule-pack-registry';
|
|
64
|
+
export { RulePackSelection } from './rule-pack-selection';
|