@webpieces/ai-hook-rules 0.4.927 → 0.4.928

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/ai-hook-rules",
3
- "version": "0.4.927",
3
+ "version": "0.4.928",
4
4
  "description": "Independent source edit rules and source hook for AI coding agents.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,18 +23,18 @@
23
23
  "directory": "packages/tooling/ai-hook-rules"
24
24
  },
25
25
  "dependencies": {
26
- "@webpieces/hook-runtime": "0.4.927",
27
- "@webpieces/rules-config": "0.4.927",
26
+ "@webpieces/hook-runtime": "0.4.928",
27
+ "@webpieces/rules-config": "0.4.928",
28
28
  "inversify": "7.10.4",
29
29
  "reflect-metadata": "0.2.2",
30
- "@webpieces/tooling-common": "0.4.927",
31
- "@webpieces/rules-sdk": "0.4.927"
30
+ "@webpieces/tooling-common": "0.4.928",
31
+ "@webpieces/rules-sdk": "0.4.928"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "devDependencies": {
37
- "@webpieces/tooling-testkit": "0.4.927"
37
+ "@webpieces/tooling-testkit": "0.4.928"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
@@ -175,7 +175,8 @@ class GoldenRepoBuilder {
175
175
  .manifests()
176
176
  .map((pack) => pack.packageName === rule_pack_1.rulePackManifest.packageName ? rule_pack_1.rulePackManifest : pack);
177
177
  if (fixture.crashingRuntime) {
178
- const seed = Object.assign(new rules_sdk_1.ConfigObject(), { mode: 'ON' });
178
+ // Every rule carries the framework-owned hatches (#1253), so the client seed states them.
179
+ const seed = Object.assign(new rules_sdk_1.ConfigObject(), { mode: 'ON', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null });
179
180
  const definition = new rules_sdk_1.OwnedRuleDefinition('client-crash', { mode: new rules_sdk_1.FieldDef('string', ['ON', 'OFF']) }, 1, {}, seed, 'rules', new rules_sdk_1.RuleHelp('Client failure fixture', 'Repair {configFile}.'));
180
181
  manifests.push(new rules_sdk_1.RulePackManifest('@client/crash', '1.0.0-fixture', 3, [definition], [
181
182
  new rules_sdk_1.RuleContribution('client-crash', '@client/crash', 'source-hook', './crash-runtime.cjs'),
@@ -201,7 +202,7 @@ class GoldenRepoBuilder {
201
202
  return this.configJson;
202
203
  // webpieces-disable no-any-unknown -- the frozen fixture config is data on disk; re-parsing it into a named type here would be a second declaration of a file whose whole point is being literal
203
204
  const parsed = JSON.parse(this.configJson);
204
- parsed['rules']['client-crash'] = Object.assign(new rules_sdk_1.ConfigObject(), { mode: 'ON' });
205
+ parsed['rules']['client-crash'] = Object.assign(new rules_sdk_1.ConfigObject(), { mode: 'ON', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null });
205
206
  return JSON.stringify(parsed, null, 4);
206
207
  }
207
208
  git(repo, args) {
@@ -1 +1 @@
1
- {"version":3,"file":"hook-app-fixtures.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/adapters/hook-app-fixtures.ts"],"names":[],"mappings":";;;;AAAA,oDAO8B;AAC9B,4CAAgD;AAChD,gEAA2D;AAC3D,gEAA0D;AAC1D,iDAAyC;AACzC,+CAAyB;AAEzB,mDAA6B;AAI7B;;;;;;;;;;;GAWG;AAEH,yFAAyF;AACzF,MAAa,aAAa;IACtB,2DAA2D;IAClD,IAAI,CAAS;IACtB,sDAAsD;IAC7C,IAAI,CAAW;IACxB;;;OAGG;IACM,KAAK,CAAS;IACvB,4FAA4F;IACnF,eAAe,CAAU;IAElC,YAAY,IAAY,EAAE,IAAc,EAAE,KAAa,EAAE,kBAA2B,KAAK;QACrF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC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ePackManifest } from '../rule-pack';\nimport { policyFixture } from '@webpieces/tooling-testkit';\nimport { specTempDirs } from '@webpieces/tooling-testkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\n\nimport { HookMode } from '@webpieces/hook-runtime';\n\n/**\n * THE WIRE BYTES the golden tests drive, and the throwaway repo they are judged against.\n *\n * Everything here exists so a reader can see EXACTLY what a harness sends: the payloads are built from\n * the measured envelope key sets (see the fixture docs on GoldenFixture below), not from anything the\n * hook itself produces, and the repo is a real `git init` with a frozen webpieces.config.json rather\n * than whatever tree the suite happens to be running in. A golden computed against the live repo would\n * change verdict with the branch you are standing on.\n *\n * This is NOT a spec file, deliberately: `tsconfig.lib.json` excludes `*.spec.ts`, so a payload builder\n * living in one would never be type-checked by the build.\n */\n\n/** How one PreToolUse call is presented to the hook. Data class per CLAUDE.md rule 1. */\nexport class GoldenFixture {\n /** Stable key into `__goldens__/hook-app-goldens.json`. */\n readonly name: string;\n /** Which hook binary's mode — `guards` or `rules`. */\n readonly mode: HookMode;\n /**\n * The raw stdin bytes. A STRING, never an object, because malformed stdin is one of the fixtures\n * and a shape that cannot express \"not JSON\" would quietly drop the case that matters most.\n */\n readonly stdin: string;\n /** True ⇒ the fixture repo also gets a `rulesDir` whose one module throws when required. */\n readonly crashingRuntime: boolean;\n\n constructor(name: string, mode: HookMode, stdin: string, crashingRuntime: boolean = false) {\n this.name = name;\n this.mode = mode;\n this.stdin = stdin;\n this.crashingRuntime = crashingRuntime;\n }\n}\n\n/** A built fixture repo: where it lives, and the stdin bytes with `<REPO>` resolved into it. */\nexport class PreparedFixture {\n readonly repo: string;\n readonly root: string;\n readonly stdin: string;\n\n constructor(repo: string, root: string, stdin: string) {\n this.repo = repo;\n this.root = root;\n this.stdin = stdin;\n }\n}\n\n/**\n * The placeholder that stands for the fixture repo's absolute path, in BOTH directions: payloads are\n * written with it and it is substituted in before the run; golden bytes are compared with the real\n * path substituted back out. Guard reports legitimately name absolute paths (the git-workflow doc\n * pointer, the blocked file), and a golden that hard-coded one machine's `/var/folders/...` would be\n * a golden nobody else could run.\n */\nexport const REPO_TOKEN = '<REPO>';\n\nconst CLAUDE_ENVELOPE = {\n hook_event_name: 'PreToolUse',\n session_id: 'sess-golden',\n transcript_path: '/dev/null',\n cwd: REPO_TOKEN,\n};\n\n/**\n * The Codex additions, MEASURED from codex-cli 0.151.0: it uses Claude's key names and merely ADDS\n * `model`, `turn_id`, `tool_use_id` and `permission_mode`. `turn_id` is the one discriminator (see\n * detect-ai.ts). `agent_id` empty ⇒ the coordinator, populated ⇒ a subagent — identical semantics in\n * both harnesses.\n */\nconst CODEX_ENVELOPE = {\n ...CLAUDE_ENVELOPE,\n model: 'gpt-5-codex',\n turn_id: 'turn-golden',\n tool_use_id: 'call_1',\n permission_mode: 'default',\n agent_type: 'default',\n agent_id: '',\n};\n\n// Codex's edit tool. MEASURED: the tool is named `apply_patch`, it carries `tool_input.command` (not\n// file_path), hunk headers are a bare `@@`, and ONE patch may carry many files with mixed operations.\nconst PATCH_ADD_JS = '*** Begin Patch\\n*** Add File: src/foo.js\\n+var x = 1;\\n*** End Patch\\n';\nconst PATCH_ADD_TS =\n '*** Begin Patch\\n*** Add File: scripts/added.ts\\n+export const b = 2;\\n*** End Patch\\n';\n\n/**\n * Serializes ONE PreToolUse envelope to the bytes a harness would put on stdin. A class rather than a\n * module-scope function because that is the repo rule, and the one instance below is built at module\n * load so the fixture table can stay a plain literal list.\n */\nclass WirePayload {\n // webpieces-disable no-any-unknown -- these objects ARE the wire envelope; JSON.stringify of a plain object is the payload under test, and naming a type for it would assert a shape the fixtures exist to state literally\n write(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n envelope: Record<string, unknown>,\n toolName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n toolInput: Record<string, unknown>,\n ): string {\n return JSON.stringify({ ...envelope, tool_name: toolName, tool_input: toolInput });\n }\n}\n\nconst WIRE = new WirePayload();\n\n/**\n * ONE fixture per row of the coverage the composed pipeline had none of before: for BOTH harnesses a\n * Bash deny (the ANSI-red systemMessage), a file-tool deny (NO systemMessage), an allow, a read-only\n * tool, malformed stdin, and a fail-closed crash.\n */\nexport const GOLDEN_FIXTURES: readonly GoldenFixture[] = [\n // ── Claude Code ────────────────────────────────────────────────────────────────────────────────\n // A Bash deny. `git merge` is blocked on every branch, so this verdict does not depend on repo\n // state — and a Bash deny is the ONE case that carries the red `systemMessage`.\n // The read-only tool: log-and-allow, and the only guard that can deny it is a stale `main`.\n // Write / Edit / MultiEdit denies — all three must emit NO systemMessage.\n new GoldenFixture(\n 'claude/write-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/src/foo.js`,\n content: 'var x = 1;\\n',\n }),\n ),\n new GoldenFixture(\n 'claude/edit-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Edit', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n old_string: 'const a = 1;',\n new_string: 'const { a } = b;',\n }),\n ),\n new GoldenFixture(\n 'claude/multiedit-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'MultiEdit', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n edits: [{ old_string: 'const a = 1;', new_string: 'const { a } = b;' }],\n }),\n ),\n new GoldenFixture(\n 'claude/write-allow',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n content: 'export const a = 1;\\n',\n }),\n ),\n new GoldenFixture(\n 'claude/crash',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n content: 'export const a = 1;\\n',\n }),\n true,\n ),\n\n // ── Codex ──────────────────────────────────────────────────────────────────────────────────────\n // Codex has no Read tool: a read arrives as `Bash` running a pager, which read parity turns into a\n // read-scoped verdict ON TOP of the bash guards.\n new GoldenFixture(\n 'codex/apply-patch-deny',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_JS }),\n ),\n new GoldenFixture(\n 'codex/apply-patch-allow',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_TS }),\n ),\n new GoldenFixture(\n 'codex/crash',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_TS }),\n true,\n ),\n];\n\n// A rules module that blows up the moment it is required — the shortest honest way to reach the hook's\n// fail-closed boundary from OUTSIDE the hook, i.e. without stubbing anything the pipeline owns.\nconst CRASHING_RULE_MODULE = \"throw new Error('boom from a custom rule module');\\n\";\n\n/**\n * Builds ONE throwaway git repo per fixture and returns it with the payload's `<REPO>` resolved.\n *\n * A FRESH repo per fixture, not one shared: the hook writes `.webpieces/` state (the decision log, the\n * main-sync cache) as it runs, so a shared tree would let fixture N's leftovers decide fixture N+1's\n * verdict — an order-dependent suite, which is the one kind of golden test worse than none.\n *\n * `realpathSync` matters on macOS: `os.tmpdir()` hands back `/var/folders/...` which resolves to\n * `/private/var/...`, and the L1 location guard compares the payload's cwd against the resolved repo\n * root. Without it every fixture denies with \"run git from the repo root\" instead of the verdict under\n * test.\n */\nexport class GoldenRepoBuilder {\n private readonly configJson: string;\n\n constructor() {\n this.configJson = fs.readFileSync(\n path.join(__dirname, '__goldens__', 'fixture-webpieces.config.json'),\n 'utf8',\n );\n }\n\n build(fixture: GoldenFixture): PreparedFixture {\n const root = specTempDirs.makeReal('wp-hook-golden-');\n const repo = path.join(root, 'repo');\n fs.mkdirSync(repo);\n this.git(repo, 'init -q -b main');\n // The developer's own commit hooks would otherwise fire inside this throwaway repo.\n this.git(repo, 'config core.hooksPath /dev/null');\n this.git(repo, 'config user.email t@t.co');\n this.git(repo, 'config user.name tester');\n const manifests = policyFixture\n .manifests()\n .map((pack: RulePackManifest) =>\n pack.packageName === rulePackManifest.packageName ? rulePackManifest : pack,\n );\n if (fixture.crashingRuntime) {\n const seed = Object.assign(new ConfigObject(), { mode: 'ON' });\n const definition = new OwnedRuleDefinition(\n 'client-crash',\n { mode: new FieldDef('string', ['ON', 'OFF']) },\n 1,\n {},\n seed,\n 'rules',\n new RuleHelp('Client failure fixture', 'Repair {configFile}.'),\n );\n manifests.push(\n new RulePackManifest(\n '@client/crash',\n '1.0.0-fixture',\n 3,\n [definition],\n [\n new RuleContribution(\n 'client-crash',\n '@client/crash',\n 'source-hook',\n './crash-runtime.cjs',\n ),\n ],\n [],\n [],\n ),\n );\n }\n policyFixture.writeOwnerConfig(repo, JSON.parse(this.repoConfig(fixture)), manifests);\n fs.writeFileSync(path.join(repo, 'f.txt'), 'hello\\n');\n fs.mkdirSync(path.join(repo, 'scripts'));\n fs.writeFileSync(path.join(repo, 'scripts', 'ok.ts'), 'const a = 1;\\n');\n if (fixture.crashingRuntime) {\n fs.writeFileSync(path.join(repo, 'crash-runtime.cjs'), CRASHING_RULE_MODULE);\n }\n this.git(repo, 'add -A');\n this.git(repo, 'commit -qm init');\n // A local origin/main, so `origin/main..<branch>` resolves exactly as it does in a real clone.\n this.git(repo, 'update-ref refs/remotes/origin/main HEAD');\n // A feature branch, because that is where an agent actually works.\n this.git(repo, 'checkout -q -b dean/fixture');\n return new PreparedFixture(repo, root, fixture.stdin.split(REPO_TOKEN).join(repo));\n }\n\n private repoConfig(fixture: GoldenFixture): string {\n if (!fixture.crashingRuntime) return this.configJson;\n // webpieces-disable no-any-unknown -- the frozen fixture config is data on disk; re-parsing it into a named type here would be a second declaration of a file whose whole point is being literal\n const parsed = JSON.parse(this.configJson) as Record<string, unknown>;\n (parsed['rules'] as Record<string, ConfigObject>)['client-crash'] = Object.assign(\n new ConfigObject(),\n { mode: 'ON' },\n );\n return JSON.stringify(parsed, null, 4);\n }\n\n private git(repo: string, args: string): void {\n execSync(`git ${args}`, { cwd: repo, encoding: 'utf8' });\n }\n}\n"]}
1
+ {"version":3,"file":"hook-app-fixtures.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/adapters/hook-app-fixtures.ts"],"names":[],"mappings":";;;;AAAA,oDAO8B;AAC9B,4CAAgD;AAChD,gEAA2D;AAC3D,gEAA0D;AAC1D,iDAAyC;AACzC,+CAAyB;AAEzB,mDAA6B;AAI7B;;;;;;;;;;;GAWG;AAEH,yFAAyF;AACzF,MAAa,aAAa;IACtB,2DAA2D;IAClD,IAAI,CAAS;IACtB,sDAAsD;IAC7C,IAAI,CAAW;IACxB;;;OAGG;IACM,KAAK,CAAS;IACvB,4FAA4F;IACnF,eAAe,CAAU;IAElC,YAAY,IAAY,EAAE,IAAc,EAAE,KAAa,EAAE,kBAA2B,KAAK;QACrF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;CACJ;AAnBD,sCAmBC;AAED,gGAAgG;AAChG,MAAa,eAAe;IACf,IAAI,CAAS;IACb,IAAI,CAAS;IACb,KAAK,CAAS;IAEvB,YAAY,IAAY,EAAE,IAAY,EAAE,KAAa;QACjD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAVD,0CAUC;AAED;;;;;;GAMG;AACU,QAAA,UAAU,GAAG,QAAQ,CAAC;AAEnC,MAAM,eAAe,GAAG;IACpB,eAAe,EAAE,YAAY;IAC7B,UAAU,EAAE,aAAa;IACzB,eAAe,EAAE,WAAW;IAC5B,GAAG,EAAE,kBAAU;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,cAAc,GAAG;IACnB,GAAG,eAAe;IAClB,KAAK,EAAE,aAAa;IACpB,OAAO,EAAE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AAE,OAAO,IAAI,CAAC,UAAU,CAAC;QACrD,iMAAiM;QACjM,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAA4B,CAAC;QACrE,MAAM,CAAC,OAAO,CAAkC,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,CAC7E,IAAI,wBAAY,EAAE,EAClB,EAAE,IAAI,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAAC,EAAE,wBAAwB,EAAE,IAAI,EAAE,CAC3E,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAEO,GAAG,CAAC,IAAY,EAAE,IAAY;QAClC,IAAA,wBAAQ,EAAC,OAAO,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;CACJ;AArFD,8CAqFC","sourcesContent":["import {\n ConfigObject,\n FieldDef,\n OwnedRuleDefinition,\n RuleContribution,\n RuleHelp,\n RulePackManifest,\n} from '@webpieces/rules-sdk';\nimport { rulePackManifest } from '../rule-pack';\nimport { policyFixture } from '@webpieces/tooling-testkit';\nimport { specTempDirs } from '@webpieces/tooling-testkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\n\nimport { HookMode } from '@webpieces/hook-runtime';\n\n/**\n * THE WIRE BYTES the golden tests drive, and the throwaway repo they are judged against.\n *\n * Everything here exists so a reader can see EXACTLY what a harness sends: the payloads are built from\n * the measured envelope key sets (see the fixture docs on GoldenFixture below), not from anything the\n * hook itself produces, and the repo is a real `git init` with a frozen webpieces.config.json rather\n * than whatever tree the suite happens to be running in. A golden computed against the live repo would\n * change verdict with the branch you are standing on.\n *\n * This is NOT a spec file, deliberately: `tsconfig.lib.json` excludes `*.spec.ts`, so a payload builder\n * living in one would never be type-checked by the build.\n */\n\n/** How one PreToolUse call is presented to the hook. Data class per CLAUDE.md rule 1. */\nexport class GoldenFixture {\n /** Stable key into `__goldens__/hook-app-goldens.json`. */\n readonly name: string;\n /** Which hook binary's mode — `guards` or `rules`. */\n readonly mode: HookMode;\n /**\n * The raw stdin bytes. A STRING, never an object, because malformed stdin is one of the fixtures\n * and a shape that cannot express \"not JSON\" would quietly drop the case that matters most.\n */\n readonly stdin: string;\n /** True ⇒ the fixture repo also gets a `rulesDir` whose one module throws when required. */\n readonly crashingRuntime: boolean;\n\n constructor(name: string, mode: HookMode, stdin: string, crashingRuntime: boolean = false) {\n this.name = name;\n this.mode = mode;\n this.stdin = stdin;\n this.crashingRuntime = crashingRuntime;\n }\n}\n\n/** A built fixture repo: where it lives, and the stdin bytes with `<REPO>` resolved into it. */\nexport class PreparedFixture {\n readonly repo: string;\n readonly root: string;\n readonly stdin: string;\n\n constructor(repo: string, root: string, stdin: string) {\n this.repo = repo;\n this.root = root;\n this.stdin = stdin;\n }\n}\n\n/**\n * The placeholder that stands for the fixture repo's absolute path, in BOTH directions: payloads are\n * written with it and it is substituted in before the run; golden bytes are compared with the real\n * path substituted back out. Guard reports legitimately name absolute paths (the git-workflow doc\n * pointer, the blocked file), and a golden that hard-coded one machine's `/var/folders/...` would be\n * a golden nobody else could run.\n */\nexport const REPO_TOKEN = '<REPO>';\n\nconst CLAUDE_ENVELOPE = {\n hook_event_name: 'PreToolUse',\n session_id: 'sess-golden',\n transcript_path: '/dev/null',\n cwd: REPO_TOKEN,\n};\n\n/**\n * The Codex additions, MEASURED from codex-cli 0.151.0: it uses Claude's key names and merely ADDS\n * `model`, `turn_id`, `tool_use_id` and `permission_mode`. `turn_id` is the one discriminator (see\n * detect-ai.ts). `agent_id` empty ⇒ the coordinator, populated ⇒ a subagent — identical semantics in\n * both harnesses.\n */\nconst CODEX_ENVELOPE = {\n ...CLAUDE_ENVELOPE,\n model: 'gpt-5-codex',\n turn_id: 'turn-golden',\n tool_use_id: 'call_1',\n permission_mode: 'default',\n agent_type: 'default',\n agent_id: '',\n};\n\n// Codex's edit tool. MEASURED: the tool is named `apply_patch`, it carries `tool_input.command` (not\n// file_path), hunk headers are a bare `@@`, and ONE patch may carry many files with mixed operations.\nconst PATCH_ADD_JS = '*** Begin Patch\\n*** Add File: src/foo.js\\n+var x = 1;\\n*** End Patch\\n';\nconst PATCH_ADD_TS =\n '*** Begin Patch\\n*** Add File: scripts/added.ts\\n+export const b = 2;\\n*** End Patch\\n';\n\n/**\n * Serializes ONE PreToolUse envelope to the bytes a harness would put on stdin. A class rather than a\n * module-scope function because that is the repo rule, and the one instance below is built at module\n * load so the fixture table can stay a plain literal list.\n */\nclass WirePayload {\n // webpieces-disable no-any-unknown -- these objects ARE the wire envelope; JSON.stringify of a plain object is the payload under test, and naming a type for it would assert a shape the fixtures exist to state literally\n write(\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n envelope: Record<string, unknown>,\n toolName: string,\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n toolInput: Record<string, unknown>,\n ): string {\n return JSON.stringify({ ...envelope, tool_name: toolName, tool_input: toolInput });\n }\n}\n\nconst WIRE = new WirePayload();\n\n/**\n * ONE fixture per row of the coverage the composed pipeline had none of before: for BOTH harnesses a\n * Bash deny (the ANSI-red systemMessage), a file-tool deny (NO systemMessage), an allow, a read-only\n * tool, malformed stdin, and a fail-closed crash.\n */\nexport const GOLDEN_FIXTURES: readonly GoldenFixture[] = [\n // ── Claude Code ────────────────────────────────────────────────────────────────────────────────\n // A Bash deny. `git merge` is blocked on every branch, so this verdict does not depend on repo\n // state — and a Bash deny is the ONE case that carries the red `systemMessage`.\n // The read-only tool: log-and-allow, and the only guard that can deny it is a stale `main`.\n // Write / Edit / MultiEdit denies — all three must emit NO systemMessage.\n new GoldenFixture(\n 'claude/write-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/src/foo.js`,\n content: 'var x = 1;\\n',\n }),\n ),\n new GoldenFixture(\n 'claude/edit-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Edit', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n old_string: 'const a = 1;',\n new_string: 'const { a } = b;',\n }),\n ),\n new GoldenFixture(\n 'claude/multiedit-deny',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'MultiEdit', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n edits: [{ old_string: 'const a = 1;', new_string: 'const { a } = b;' }],\n }),\n ),\n new GoldenFixture(\n 'claude/write-allow',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n content: 'export const a = 1;\\n',\n }),\n ),\n new GoldenFixture(\n 'claude/crash',\n 'rules',\n WIRE.write(CLAUDE_ENVELOPE, 'Write', {\n file_path: `${REPO_TOKEN}/scripts/ok.ts`,\n content: 'export const a = 1;\\n',\n }),\n true,\n ),\n\n // ── Codex ──────────────────────────────────────────────────────────────────────────────────────\n // Codex has no Read tool: a read arrives as `Bash` running a pager, which read parity turns into a\n // read-scoped verdict ON TOP of the bash guards.\n new GoldenFixture(\n 'codex/apply-patch-deny',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_JS }),\n ),\n new GoldenFixture(\n 'codex/apply-patch-allow',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_TS }),\n ),\n new GoldenFixture(\n 'codex/crash',\n 'rules',\n WIRE.write(CODEX_ENVELOPE, 'apply_patch', { command: PATCH_ADD_TS }),\n true,\n ),\n];\n\n// A rules module that blows up the moment it is required — the shortest honest way to reach the hook's\n// fail-closed boundary from OUTSIDE the hook, i.e. without stubbing anything the pipeline owns.\nconst CRASHING_RULE_MODULE = \"throw new Error('boom from a custom rule module');\\n\";\n\n/**\n * Builds ONE throwaway git repo per fixture and returns it with the payload's `<REPO>` resolved.\n *\n * A FRESH repo per fixture, not one shared: the hook writes `.webpieces/` state (the decision log, the\n * main-sync cache) as it runs, so a shared tree would let fixture N's leftovers decide fixture N+1's\n * verdict — an order-dependent suite, which is the one kind of golden test worse than none.\n *\n * `realpathSync` matters on macOS: `os.tmpdir()` hands back `/var/folders/...` which resolves to\n * `/private/var/...`, and the L1 location guard compares the payload's cwd against the resolved repo\n * root. Without it every fixture denies with \"run git from the repo root\" instead of the verdict under\n * test.\n */\nexport class GoldenRepoBuilder {\n private readonly configJson: string;\n\n constructor() {\n this.configJson = fs.readFileSync(\n path.join(__dirname, '__goldens__', 'fixture-webpieces.config.json'),\n 'utf8',\n );\n }\n\n build(fixture: GoldenFixture): PreparedFixture {\n const root = specTempDirs.makeReal('wp-hook-golden-');\n const repo = path.join(root, 'repo');\n fs.mkdirSync(repo);\n this.git(repo, 'init -q -b main');\n // The developer's own commit hooks would otherwise fire inside this throwaway repo.\n this.git(repo, 'config core.hooksPath /dev/null');\n this.git(repo, 'config user.email t@t.co');\n this.git(repo, 'config user.name tester');\n const manifests = policyFixture\n .manifests()\n .map((pack: RulePackManifest) =>\n pack.packageName === rulePackManifest.packageName ? rulePackManifest : pack,\n );\n if (fixture.crashingRuntime) {\n // Every rule carries the framework-owned hatches (#1253), so the client seed states them.\n const seed = Object.assign(new ConfigObject(), { mode: 'ON', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null });\n const definition = new OwnedRuleDefinition(\n 'client-crash',\n { mode: new FieldDef('string', ['ON', 'OFF']) },\n 1,\n {},\n seed,\n 'rules',\n new RuleHelp('Client failure fixture', 'Repair {configFile}.'),\n );\n manifests.push(\n new RulePackManifest(\n '@client/crash',\n '1.0.0-fixture',\n 3,\n [definition],\n [\n new RuleContribution(\n 'client-crash',\n '@client/crash',\n 'source-hook',\n './crash-runtime.cjs',\n ),\n ],\n [],\n [],\n ),\n );\n }\n policyFixture.writeOwnerConfig(repo, JSON.parse(this.repoConfig(fixture)), manifests);\n fs.writeFileSync(path.join(repo, 'f.txt'), 'hello\\n');\n fs.mkdirSync(path.join(repo, 'scripts'));\n fs.writeFileSync(path.join(repo, 'scripts', 'ok.ts'), 'const a = 1;\\n');\n if (fixture.crashingRuntime) {\n fs.writeFileSync(path.join(repo, 'crash-runtime.cjs'), CRASHING_RULE_MODULE);\n }\n this.git(repo, 'add -A');\n this.git(repo, 'commit -qm init');\n // A local origin/main, so `origin/main..<branch>` resolves exactly as it does in a real clone.\n this.git(repo, 'update-ref refs/remotes/origin/main HEAD');\n // A feature branch, because that is where an agent actually works.\n this.git(repo, 'checkout -q -b dean/fixture');\n return new PreparedFixture(repo, root, fixture.stdin.split(REPO_TOKEN).join(repo));\n }\n\n private repoConfig(fixture: GoldenFixture): string {\n if (!fixture.crashingRuntime) return this.configJson;\n // webpieces-disable no-any-unknown -- the frozen fixture config is data on disk; re-parsing it into a named type here would be a second declaration of a file whose whole point is being literal\n const parsed = JSON.parse(this.configJson) as Record<string, unknown>;\n (parsed['rules'] as Record<string, ConfigObject>)['client-crash'] = Object.assign(\n new ConfigObject(),\n { mode: 'ON', turnOffRuleUntilEpoch: 0, turnOffRuleWhileOnBranch: null },\n );\n return JSON.stringify(parsed, null, 4);\n }\n\n private git(repo: string, args: string): void {\n execSync(`git ${args}`, { cwd: repo, encoding: 'utf8' });\n }\n}\n"]}
@@ -12,12 +12,10 @@ export declare class ThrowCauseRequiredConfig extends BaseRuleConfig {
12
12
  }
13
13
  export declare class NoJsFilesConfig extends BaseRuleConfig {
14
14
  mode?: FileLimitMode;
15
- allowedPaths?: string[];
16
15
  static readonly SCHEMA: SchemaShape<NoJsFilesConfig>;
17
16
  }
18
17
  export declare class ValidateTsInSrcConfig extends BaseRuleConfig {
19
18
  mode?: ValidateTsMode;
20
19
  allowedRootFiles?: string[];
21
- excludePaths?: string[];
22
20
  static readonly SCHEMA: SchemaShape<ValidateTsInSrcConfig>;
23
21
  }
@@ -11,27 +11,20 @@ class ThrowCauseRequiredConfig extends rules_sdk_2.BaseRuleConfig {
11
11
  static SCHEMA = {
12
12
  mode: new rules_sdk_3.FieldDef('string', exports.THROW_CAUSE_MODES),
13
13
  disableAllowed: rules_sdk_3.FieldDef.optional('boolean'),
14
- ...rules_sdk_2.BASE_RULE_SCHEMA,
15
14
  };
16
15
  }
17
16
  exports.ThrowCauseRequiredConfig = ThrowCauseRequiredConfig;
18
17
  class NoJsFilesConfig extends rules_sdk_2.BaseRuleConfig {
19
- allowedPaths;
20
18
  static SCHEMA = {
21
19
  mode: new rules_sdk_3.FieldDef('string', rules_sdk_1.FILE_LIMIT_MODES),
22
- allowedPaths: rules_sdk_3.FieldDef.optional('string[]'),
23
- ...rules_sdk_2.BASE_RULE_SCHEMA,
24
20
  };
25
21
  }
26
22
  exports.NoJsFilesConfig = NoJsFilesConfig;
27
23
  class ValidateTsInSrcConfig extends rules_sdk_2.BaseRuleConfig {
28
24
  allowedRootFiles;
29
- excludePaths;
30
25
  static SCHEMA = {
31
26
  mode: new rules_sdk_3.FieldDef('string', exports.VALIDATE_TS_MODES),
32
27
  allowedRootFiles: rules_sdk_3.FieldDef.optional('string[]'),
33
- excludePaths: rules_sdk_3.FieldDef.optional('string[]'),
34
- ...rules_sdk_2.BASE_RULE_SCHEMA,
35
28
  };
36
29
  }
37
30
  exports.ValidateTsInSrcConfig = ValidateTsInSrcConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"rule-configs.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/configs/rule-configs.ts"],"names":[],"mappings":";;;AAAA,oDAAuE;AACvE,oDAAwE;AACxE,oDAA6D;AAChD,QAAA,iBAAiB,GAAG,CAAC,KAAK,EAAE,uBAAuB,CAAU,CAAC;AAI9D,QAAA,iBAAiB,GAAG,CAAC,KAAK,EAAE,wBAAwB,CAAU,CAAC;AAI5E,MAAa,wBAAyB,SAAQ,0BAAc;IAExD,cAAc,CAAW;IAEzB,MAAM,CAAU,MAAM,GAA0C;QAC5D,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,yBAAiB,CAAC;QAC/C,cAAc,EAAE,oBAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC5C,GAAG,4BAAgB;KACtB,CAAC;;AARN,4DASC;AAED,MAAa,eAAgB,SAAQ,0BAAc;IAI/C,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAAiC;QACnD,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,4BAAgB,CAAC;QAC9C,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AAVN,0CAWC;AAED,MAAa,qBAAsB,SAAQ,0BAAc;IAErD,gBAAgB,CAAY;IAC5B,YAAY,CAAY;IAExB,MAAM,CAAU,MAAM,GAAuC;QACzD,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,yBAAiB,CAAC;QAC/C,gBAAgB,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC/C,YAAY,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC3C,GAAG,4BAAgB;KACtB,CAAC;;AAVN,sDAWC","sourcesContent":["import { FileLimitMode, FILE_LIMIT_MODES } from \"@webpieces/rules-sdk\";\nimport { BaseRuleConfig, BASE_RULE_SCHEMA } from \"@webpieces/rules-sdk\";\nimport { FieldDef, SchemaShape } from \"@webpieces/rules-sdk\";\nexport const THROW_CAUSE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE'] as const;\n\nexport type ThrowCauseMode = typeof THROW_CAUSE_MODES[number];\n\nexport const VALIDATE_TS_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'] as const;\n\nexport type ValidateTsMode = typeof VALIDATE_TS_MODES[number];\n\nexport class ThrowCauseRequiredConfig extends BaseRuleConfig {\n declare mode?: ThrowCauseMode;\n disableAllowed?: boolean;\n\n static readonly SCHEMA: SchemaShape<ThrowCauseRequiredConfig> = {\n mode: new FieldDef('string', THROW_CAUSE_MODES),\n disableAllowed: FieldDef.optional('boolean'),\n ...BASE_RULE_SCHEMA,\n };\n}\n\nexport class NoJsFilesConfig extends BaseRuleConfig {\n // File-tier: NEW_AND_MODIFIED_FILES (active) intercepts a .js/.jsx Write — the file being\n // written is inherently a new/modified file, so it's already diff-scoped in practice.\n declare mode?: FileLimitMode;\n allowedPaths?: string[];\n\n static readonly SCHEMA: SchemaShape<NoJsFilesConfig> = {\n mode: new FieldDef('string', FILE_LIMIT_MODES),\n allowedPaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n\nexport class ValidateTsInSrcConfig extends BaseRuleConfig {\n declare mode?: ValidateTsMode;\n allowedRootFiles?: string[];\n excludePaths?: string[];\n\n static readonly SCHEMA: SchemaShape<ValidateTsInSrcConfig> = {\n mode: new FieldDef('string', VALIDATE_TS_MODES),\n allowedRootFiles: FieldDef.optional('string[]'),\n excludePaths: FieldDef.optional('string[]'),\n ...BASE_RULE_SCHEMA,\n };\n}\n"]}
1
+ {"version":3,"file":"rule-configs.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/configs/rule-configs.ts"],"names":[],"mappings":";;;AAAA,oDAAuE;AACvE,oDAAsD;AACtD,oDAA6D;AAChD,QAAA,iBAAiB,GAAG,CAAC,KAAK,EAAE,uBAAuB,CAAU,CAAC;AAI9D,QAAA,iBAAiB,GAAG,CAAC,KAAK,EAAE,wBAAwB,CAAU,CAAC;AAI5E,MAAa,wBAAyB,SAAQ,0BAAc;IAExD,cAAc,CAAW;IAEzB,MAAM,CAAU,MAAM,GAA0C;QAC5D,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,yBAAiB,CAAC;QAC/C,cAAc,EAAE,oBAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC;KAC/C,CAAC;;AAPN,4DAQC;AAED,MAAa,eAAgB,SAAQ,0BAAc;IAK/C,MAAM,CAAU,MAAM,GAAiC;QACnD,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,4BAAgB,CAAC;KACjD,CAAC;;AAPN,0CAQC;AAED,MAAa,qBAAsB,SAAQ,0BAAc;IAErD,gBAAgB,CAAY;IAE5B,MAAM,CAAU,MAAM,GAAuC;QACzD,IAAI,EAAE,IAAI,oBAAQ,CAAC,QAAQ,EAAE,yBAAiB,CAAC;QAC/C,gBAAgB,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;KAClD,CAAC;;AAPN,sDAQC","sourcesContent":["import { FileLimitMode, FILE_LIMIT_MODES } from \"@webpieces/rules-sdk\";\nimport { BaseRuleConfig } from \"@webpieces/rules-sdk\";\nimport { FieldDef, SchemaShape } from \"@webpieces/rules-sdk\";\nexport const THROW_CAUSE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE'] as const;\n\nexport type ThrowCauseMode = typeof THROW_CAUSE_MODES[number];\n\nexport const VALIDATE_TS_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'] as const;\n\nexport type ValidateTsMode = typeof VALIDATE_TS_MODES[number];\n\nexport class ThrowCauseRequiredConfig extends BaseRuleConfig {\n declare mode?: ThrowCauseMode;\n disableAllowed?: boolean;\n\n static readonly SCHEMA: SchemaShape<ThrowCauseRequiredConfig> = {\n mode: new FieldDef('string', THROW_CAUSE_MODES),\n disableAllowed: FieldDef.optional('boolean'),\n };\n}\n\nexport class NoJsFilesConfig extends BaseRuleConfig {\n // File-tier: NEW_AND_MODIFIED_FILES (active) intercepts a .js/.jsx Write — the file being\n // written is inherently a new/modified file, so it's already diff-scoped in practice.\n declare mode?: FileLimitMode;\n\n static readonly SCHEMA: SchemaShape<NoJsFilesConfig> = {\n mode: new FieldDef('string', FILE_LIMIT_MODES),\n };\n}\n\nexport class ValidateTsInSrcConfig extends BaseRuleConfig {\n declare mode?: ValidateTsMode;\n allowedRootFiles?: string[];\n\n static readonly SCHEMA: SchemaShape<ValidateTsInSrcConfig> = {\n mode: new FieldDef('string', VALIDATE_TS_MODES),\n allowedRootFiles: FieldDef.optional('string[]'),\n };\n}\n"]}
@@ -8,7 +8,6 @@ export declare class MaxFileLinesRule extends FileRuleBase<SourceContributionCon
8
8
  readonly files: string[];
9
9
  readonly defaultOptions: {
10
10
  limit: number;
11
- allowedPaths: never[];
12
11
  };
13
12
  get fixHint(): FixHint;
14
13
  check(ctx: FileContext): readonly Violation[];
@@ -13,20 +13,18 @@ class MaxFileLinesRule extends hook_runtime_2.FileRuleBase {
13
13
  }
14
14
  description = 'Cap file length at a configured line limit.';
15
15
  files = ['**/*.ts', '**/*.tsx'];
16
- defaultOptions = { limit: DEFAULT_LIMIT, allowedPaths: [] };
16
+ defaultOptions = { limit: DEFAULT_LIMIT };
17
17
  get fixHint() {
18
18
  return new hook_runtime_3.FixHint('File exceeds the max-file-lines limit.', 'Pick one:', [
19
19
  new rules_config_1.Option('Refactor to reduce the file size — READ the instruct-ai doc at the absolute path on the violation line above.', true),
20
- new rules_config_1.Option('If this file is MACHINE-GENERATED and its size is not yours to control, add its tree to max-file-lines.allowedPaths in {configFile} (the generated trees in GENERATED_CODE_PATHS are already exempt with no config at all). Never do this for hand-written code.'),
20
+ new rules_config_1.Option('If this file is MACHINE-GENERATED and its size is not yours to control, add its tree to max-file-lines.excludePaths in {configFile} (the generated trees in GENERATED_CODE_PATHS are already exempt with no config at all). Never do this for hand-written code.'),
21
21
  ], new hook_runtime_3.DisableEscape(this.config.disableAllowed ?? true, '// eslint-disable-next-line @webpieces/max-file-lines (also suppresses the eslint rule)'));
22
22
  }
23
23
  check(ctx) {
24
24
  const limit = this.config.limit ?? DEFAULT_LIMIT;
25
- // Machine-generated trees are exempt unconditionally; allowedPaths ADDS to that floor.
26
- if ((0, rules_config_1.isPathExcluded)(ctx.relativePath, [
27
- ...rules_config_1.GENERATED_CODE_PATHS,
28
- ...(this.config.allowedPaths ?? []),
29
- ]))
25
+ // Machine-generated trees are exempt unconditionally. The repo's own excludePaths (this rule's
26
+ // and the top-level one) are applied by the engine before the rule is dispatched (#1253).
27
+ if ((0, rules_config_1.isPathExcluded)(ctx.relativePath, rules_config_1.GENERATED_CODE_PATHS))
30
28
  return [];
31
29
  if (ctx.projectedFileLines <= limit)
32
30
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"max-file-lines.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/max-file-lines.ts"],"names":[],"mappings":";;;AACA,0DAMiC;AAGjC,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,MAAa,gBAAiB,SAAQ,2BAAsC;IACxE,YAAY,MAAgC;QACxC,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAEQ,WAAW,GAAG,6CAA6C,CAAC;IACnD,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC9E,IAAI,OAAO;QACP,OAAO,IAAI,sBAAO,CACd,wCAAwC,EACxC,WAAW,EACX;YACI,IAAI,qBAAM,CACN,+GAA+G,EAC/G,IAAI,CACP;YACD,IAAI,qBAAM,CACN,kQAAkQ,CACrQ;SACJ,EACD,IAAI,4BAAa,CACb,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,EAClC,0FAA0F,CAC7F,CACJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAgB;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,aAAa,CAAC;QACjD,uFAAuF;QACvF,IACI,IAAA,6BAAc,EAAC,GAAG,CAAC,YAAY,EAAE;YAC7B,GAAG,mCAAoB;YACvB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;SACtC,CAAC;YAEF,OAAO,EAAE,CAAC;QACd,IAAI,GAAG,CAAC,kBAAkB,IAAI,KAAK;YAAE,OAAO,EAAE,CAAC;QAC/C,IAAA,qCAAsB,EAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,6BAAc,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACzF,OAAO;YACH,IAAI,wBAAC,CACD,CAAC,EACD,cAAc,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,SAAS,EACrD,gBAAgB,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,yBAAyB,MAAM,CAAC,KAAK,CAAC,qBAAqB,OAAO,yCAAyC,CAC5J;SACJ,CAAC;IACN,CAAC;CACJ;AAjDD,4CAiDC","sourcesContent":["import { SourceContributionConfig } from '../source-contribution-config';\nimport {\n writeTemplateIfMissing,\n RepoRootFinder,\n isPathExcluded,\n GENERATED_CODE_PATHS,\n Option,\n} from '@webpieces/rules-config';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst DEFAULT_LIMIT = 900;\nconst INSTRUCT_FILE = 'webpieces.filesize.md';\n\nexport class MaxFileLinesRule extends FileRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) {\n super(config, 'max-file-lines', 'max-file-lines');\n }\n\n readonly description = 'Cap file length at a configured line limit.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = { limit: DEFAULT_LIMIT, allowedPaths: [] };\n get fixHint(): FixHint {\n return new FixHint(\n 'File exceeds the max-file-lines limit.',\n 'Pick one:',\n [\n new Option(\n 'Refactor to reduce the file size — READ the instruct-ai doc at the absolute path on the violation line above.',\n true,\n ),\n new Option(\n 'If this file is MACHINE-GENERATED and its size is not yours to control, add its tree to max-file-lines.allowedPaths in {configFile} (the generated trees in GENERATED_CODE_PATHS are already exempt with no config at all). Never do this for hand-written code.',\n ),\n ],\n new DisableEscape(\n this.config.disableAllowed ?? true,\n '// eslint-disable-next-line @webpieces/max-file-lines (also suppresses the eslint rule)',\n ),\n );\n }\n\n check(ctx: FileContext): readonly Violation[] {\n const limit = this.config.limit ?? DEFAULT_LIMIT;\n // Machine-generated trees are exempt unconditionally; allowedPaths ADDS to that floor.\n if (\n isPathExcluded(ctx.relativePath, [\n ...GENERATED_CODE_PATHS,\n ...(this.config.allowedPaths ?? []),\n ])\n )\n return [];\n if (ctx.projectedFileLines <= limit) return [];\n writeTemplateIfMissing(ctx.workspaceRoot, INSTRUCT_FILE);\n const docPath = new RepoRootFinder().instructAiDocPath(ctx.workspaceRoot, INSTRUCT_FILE);\n return [\n new V(\n 1,\n `(projected ${String(ctx.projectedFileLines)} lines)`,\n `File will be ${String(ctx.projectedFileLines)} lines, exceeding the ${String(limit)}-line limit. READ ${docPath} for detailed refactoring instructions.`,\n ),\n ];\n }\n}\n"]}
1
+ {"version":3,"file":"max-file-lines.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/max-file-lines.ts"],"names":[],"mappings":";;;AACA,0DAMiC;AAGjC,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAE9C,MAAa,gBAAiB,SAAQ,2BAAsC;IACxE,YAAY,MAAgC;QACxC,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAEQ,WAAW,GAAG,6CAA6C,CAAC;IACnD,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAC5D,IAAI,OAAO;QACP,OAAO,IAAI,sBAAO,CACd,wCAAwC,EACxC,WAAW,EACX;YACI,IAAI,qBAAM,CACN,+GAA+G,EAC/G,IAAI,CACP;YACD,IAAI,qBAAM,CACN,kQAAkQ,CACrQ;SACJ,EACD,IAAI,4BAAa,CACb,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,EAClC,0FAA0F,CAC7F,CACJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAgB;QAClB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,aAAa,CAAC;QACjD,+FAA+F;QAC/F,0FAA0F;QAC1F,IAAI,IAAA,6BAAc,EAAC,GAAG,CAAC,YAAY,EAAE,mCAAoB,CAAC;YAAE,OAAO,EAAE,CAAC;QACtE,IAAI,GAAG,CAAC,kBAAkB,IAAI,KAAK;YAAE,OAAO,EAAE,CAAC;QAC/C,IAAA,qCAAsB,EAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,6BAAc,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACzF,OAAO;YACH,IAAI,wBAAC,CACD,CAAC,EACD,cAAc,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,SAAS,EACrD,gBAAgB,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,yBAAyB,MAAM,CAAC,KAAK,CAAC,qBAAqB,OAAO,yCAAyC,CAC5J;SACJ,CAAC;IACN,CAAC;CACJ;AA5CD,4CA4CC","sourcesContent":["import { SourceContributionConfig } from '../source-contribution-config';\nimport {\n writeTemplateIfMissing,\n RepoRootFinder,\n isPathExcluded,\n GENERATED_CODE_PATHS,\n Option,\n} from '@webpieces/rules-config';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst DEFAULT_LIMIT = 900;\nconst INSTRUCT_FILE = 'webpieces.filesize.md';\n\nexport class MaxFileLinesRule extends FileRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) {\n super(config, 'max-file-lines', 'max-file-lines');\n }\n\n readonly description = 'Cap file length at a configured line limit.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = { limit: DEFAULT_LIMIT };\n get fixHint(): FixHint {\n return new FixHint(\n 'File exceeds the max-file-lines limit.',\n 'Pick one:',\n [\n new Option(\n 'Refactor to reduce the file size — READ the instruct-ai doc at the absolute path on the violation line above.',\n true,\n ),\n new Option(\n 'If this file is MACHINE-GENERATED and its size is not yours to control, add its tree to max-file-lines.excludePaths in {configFile} (the generated trees in GENERATED_CODE_PATHS are already exempt with no config at all). Never do this for hand-written code.',\n ),\n ],\n new DisableEscape(\n this.config.disableAllowed ?? true,\n '// eslint-disable-next-line @webpieces/max-file-lines (also suppresses the eslint rule)',\n ),\n );\n }\n\n check(ctx: FileContext): readonly Violation[] {\n const limit = this.config.limit ?? DEFAULT_LIMIT;\n // Machine-generated trees are exempt unconditionally. The repo's own excludePaths (this rule's\n // and the top-level one) are applied by the engine before the rule is dispatched (#1253).\n if (isPathExcluded(ctx.relativePath, GENERATED_CODE_PATHS)) return [];\n if (ctx.projectedFileLines <= limit) return [];\n writeTemplateIfMissing(ctx.workspaceRoot, INSTRUCT_FILE);\n const docPath = new RepoRootFinder().instructAiDocPath(ctx.workspaceRoot, INSTRUCT_FILE);\n return [\n new V(\n 1,\n `(projected ${String(ctx.projectedFileLines)} lines)`,\n `File will be ${String(ctx.projectedFileLines)} lines, exceeding the ${String(limit)}-line limit. READ ${docPath} for detailed refactoring instructions.`,\n ),\n ];\n }\n}\n"]}
@@ -8,7 +8,6 @@ export declare class NoDestructureRule extends EditRuleBase<SourceContributionCo
8
8
  readonly files: string[];
9
9
  readonly defaultOptions: {
10
10
  allowTopLevel: boolean;
11
- allowedPaths: never[];
12
11
  };
13
12
  get fixHint(): FixHint;
14
13
  check(ctx: EditContext): readonly Violation[];
@@ -12,17 +12,14 @@ class NoDestructureRule extends hook_runtime_2.EditRuleBase {
12
12
  }
13
13
  description = 'Disallow destructuring patterns. Assign the whole result and pass it around or access properties explicitly.';
14
14
  files = ['**/*.ts', '**/*.tsx'];
15
- defaultOptions = { allowTopLevel: true, allowedPaths: [] };
15
+ defaultOptions = { allowTopLevel: true };
16
16
  get fixHint() {
17
17
  return new hook_runtime_3.FixHint('Destructuring pattern on a call result.', 'Pick one:', [
18
18
  new rules_config_1.Option('Assign the whole result instead: const obj = methodCall(); then pass obj around or use obj.x.', true),
19
- new rules_config_1.Option('If this whole tree is destructuring by construction (a React/React Native component or hook tree), add a glob to no-destructure.allowedPaths in {configFile}'),
19
+ new rules_config_1.Option('If this whole tree is destructuring by construction (a React/React Native component or hook tree), add a glob to no-destructure.excludePaths in {configFile}'),
20
20
  ], new hook_runtime_3.DisableEscape(this.config.disableAllowed ?? true, '// webpieces-disable no-destructure -- <reason>'));
21
21
  }
22
22
  check(ctx) {
23
- const allowedPaths = this.config.allowedPaths ?? [];
24
- if ((0, rules_config_1.isPathExcluded)(ctx.relativePath, allowedPaths))
25
- return [];
26
23
  const disableAllowed = this.config.disableAllowed ?? true;
27
24
  const violations = [];
28
25
  for (let i = 0; i < ctx.strippedLines.length; i += 1) {
@@ -1 +1 @@
1
- {"version":3,"file":"no-destructure.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-destructure.ts"],"names":[],"mappings":";;;AACA,0DAAiE;AAGjE,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,MAAa,iBAAkB,SAAQ,2BAAsC;IACzE,YAAY,MAAgC;QACxC,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACtD,CAAC;IA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CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AA5CD,8CA4CC","sourcesContent":["import { SourceContributionConfig } from '../source-contribution-config';\nimport { isPathExcluded, Option } from '@webpieces/rules-config';\n\nimport type { EditContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { EditRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst VARIABLE_DESTRUCTURE = /\\b(?:const|let|var)\\s*\\{/;\n\nexport class NoDestructureRule extends EditRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) {\n super(config, 'no-destructure', 'no-destructure');\n }\n\n readonly description =\n 'Disallow destructuring patterns. Assign the whole result and pass it around or access properties explicitly.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = { allowTopLevel: true, allowedPaths: [] };\n get fixHint(): FixHint {\n return new FixHint(\n 'Destructuring pattern on a call result.',\n 'Pick one:',\n [\n new Option(\n 'Assign the whole result instead: const obj = methodCall(); then pass obj around or use obj.x.',\n true,\n ),\n new Option(\n 'If this whole tree is destructuring by construction (a React/React Native component or hook tree), add a glob to no-destructure.allowedPaths in {configFile}',\n ),\n ],\n new DisableEscape(\n this.config.disableAllowed ?? true,\n '// webpieces-disable no-destructure -- <reason>',\n ),\n );\n }\n\n check(ctx: EditContext): readonly Violation[] {\n const allowedPaths = this.config.allowedPaths ?? [];\n if (isPathExcluded(ctx.relativePath, allowedPaths)) return [];\n\n const disableAllowed = this.config.disableAllowed ?? true;\n const violations: V[] = [];\n for (let i = 0; i < ctx.strippedLines.length; i += 1) {\n const stripped = ctx.strippedLines[i];\n if (!VARIABLE_DESTRUCTURE.test(stripped)) continue;\n const lineNum = i + 1;\n if (disableAllowed && ctx.isLineDisabled(lineNum, 'no-destructure')) continue;\n violations.push(new V(lineNum, ctx.lines[i].trim()));\n }\n return violations;\n }\n}\n"]}
1
+ {"version":3,"file":"no-destructure.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-destructure.ts"],"names":[],"mappings":";;;AACA,0DAAiD;AAGjD,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,oBAAoB,GAAG,0BAA0B,CAAC;AAExD,MAAa,iBAAkB,SAAQ,2BAAsC;IACzE,YAAY,MAAgC;QACxC,KAAK,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAEQ,WAAW,GAChB,8GAA8G,CAAC;IACjG,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;IAC3D,IAAI,OAAO;QACP,OAAO,IAAI,sBAAO,CACd,yCAAyC,EACzC,WAAW,EACX;YACI,IAAI,qBAAM,CACN,+FAA+F,EAC/F,IAAI,CACP;YACD,IAAI,qBAAM,CACN,8JAA8J,CACjK;SACJ,EACD,IAAI,4BAAa,CACb,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,EAClC,iDAAiD,CACpD,CACJ,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAgB;QAClB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QAC1D,MAAM,UAAU,GAAQ,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACnD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,cAAc,IAAI,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,gBAAgB,CAAC;gBAAE,SAAS;YAC9E,UAAU,CAAC,IAAI,CAAC,IAAI,wBAAC,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAzCD,8CAyCC","sourcesContent":["import { SourceContributionConfig } from '../source-contribution-config';\nimport { Option } from '@webpieces/rules-config';\n\nimport type { EditContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { EditRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst VARIABLE_DESTRUCTURE = /\\b(?:const|let|var)\\s*\\{/;\n\nexport class NoDestructureRule extends EditRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) {\n super(config, 'no-destructure', 'no-destructure');\n }\n\n readonly description =\n 'Disallow destructuring patterns. Assign the whole result and pass it around or access properties explicitly.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = { allowTopLevel: true };\n get fixHint(): FixHint {\n return new FixHint(\n 'Destructuring pattern on a call result.',\n 'Pick one:',\n [\n new Option(\n 'Assign the whole result instead: const obj = methodCall(); then pass obj around or use obj.x.',\n true,\n ),\n new Option(\n 'If this whole tree is destructuring by construction (a React/React Native component or hook tree), add a glob to no-destructure.excludePaths in {configFile}',\n ),\n ],\n new DisableEscape(\n this.config.disableAllowed ?? true,\n '// webpieces-disable no-destructure -- <reason>',\n ),\n );\n }\n\n check(ctx: EditContext): readonly Violation[] {\n const disableAllowed = this.config.disableAllowed ?? true;\n const violations: V[] = [];\n for (let i = 0; i < ctx.strippedLines.length; i += 1) {\n const stripped = ctx.strippedLines[i];\n if (!VARIABLE_DESTRUCTURE.test(stripped)) continue;\n const lineNum = i + 1;\n if (disableAllowed && ctx.isLineDisabled(lineNum, 'no-destructure')) continue;\n violations.push(new V(lineNum, ctx.lines[i].trim()));\n }\n return violations;\n }\n}\n"]}
@@ -6,9 +6,7 @@ export declare class NoJsFilesRule extends FileRuleBase<NoJsFilesConfig> {
6
6
  constructor(config: NoJsFilesConfig);
7
7
  readonly description = "Disallow writing new .js/.jsx files. Use .ts/.tsx instead.";
8
8
  readonly files: string[];
9
- readonly defaultOptions: {
10
- allowedPaths: never[];
11
- };
9
+ readonly defaultOptions: {};
12
10
  readonly fixHint: FixHint;
13
11
  check(ctx: FileContext): readonly Violation[];
14
12
  }
@@ -11,17 +11,14 @@ class NoJsFilesRule extends hook_runtime_2.FileRuleBase {
11
11
  }
12
12
  description = 'Disallow writing new .js/.jsx files. Use .ts/.tsx instead.';
13
13
  files = ['**/*.js', '**/*.jsx'];
14
- defaultOptions = { allowedPaths: [] };
14
+ defaultOptions = {};
15
15
  fixHint = new hook_runtime_3.FixHint('Writing .js/.jsx files is not allowed. Use .ts/.tsx instead.', 'Pick one:', [
16
16
  new rules_config_1.Option('Write a .ts or .tsx file instead of .js/.jsx.', true),
17
- new rules_config_1.Option('If this path must be .js (generated/legacy), add it to no-js-files.allowedPaths in {configFile}'),
17
+ new rules_config_1.Option('If this path must be .js (generated/legacy), add it to no-js-files.excludePaths in {configFile}'),
18
18
  ]);
19
19
  check(ctx) {
20
20
  if (ctx.tool !== 'Write')
21
21
  return [];
22
- const allowedPaths = this.config.allowedPaths ?? [];
23
- if ((0, rules_config_1.isPathExcluded)(ctx.relativePath, allowedPaths))
24
- return [];
25
22
  return [new hook_runtime_1.Violation(1, ctx.relativePath)];
26
23
  }
27
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"no-js-files.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-js-files.ts"],"names":[],"mappings":";;;AAAA,0DAAiE;AAIjE,0DAAyD;AACzD,0DAAuD;AACvD,0DAAkD;AAElD,MAAa,aAAc,SAAQ,2BAA6B;IAC5D,YAAY,MAAuB;QAC/B,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;IAEQ,WAAW,GAAG,4DAA4D,CAAC;IAClE,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAC/C,OAAO,GAAG,IAAI,sBAAO,CAC1B,8DAA8D,EAC9D,WAAW,EACX;QACI,IAAI,qBAAM,CAAC,+CAA+C,EAAE,IAAI,CAAC;QACjE,IAAI,qBAAM,CACN,iGAAiG,CACpG;KACJ,CACJ,CAAC;IAEF,KAAK,CAAC,GAAgB;QAClB,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,EAAE,CAAC;QAEpC,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;QAEpD,IAAI,IAAA,6BAAc,EAAC,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAE9D,OAAO,CAAC,IAAI,wBAAC,CAAC,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;IACxC,CAAC;CACJ;AA5BD,sCA4BC","sourcesContent":["import { isPathExcluded, Option } from '@webpieces/rules-config';\nimport { NoJsFilesConfig } from '../../configs/rule-configs';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint } from '@webpieces/hook-runtime';\n\nexport class NoJsFilesRule extends FileRuleBase<NoJsFilesConfig> {\n constructor(config: NoJsFilesConfig) {\n super(config, 'no-js-files', 'no-js-files');\n }\n\n readonly description = 'Disallow writing new .js/.jsx files. Use .ts/.tsx instead.';\n override readonly files = ['**/*.js', '**/*.jsx'];\n override readonly defaultOptions = { allowedPaths: [] };\n readonly fixHint = new FixHint(\n 'Writing .js/.jsx files is not allowed. Use .ts/.tsx instead.',\n 'Pick one:',\n [\n new Option('Write a .ts or .tsx file instead of .js/.jsx.', true),\n new Option(\n 'If this path must be .js (generated/legacy), add it to no-js-files.allowedPaths in {configFile}',\n ),\n ],\n );\n\n check(ctx: FileContext): readonly Violation[] {\n if (ctx.tool !== 'Write') return [];\n\n const allowedPaths = this.config.allowedPaths ?? [];\n\n if (isPathExcluded(ctx.relativePath, allowedPaths)) return [];\n\n return [new V(1, ctx.relativePath)];\n }\n}\n"]}
1
+ {"version":3,"file":"no-js-files.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-js-files.ts"],"names":[],"mappings":";;;AAAA,0DAAiD;AAIjD,0DAAyD;AACzD,0DAAuD;AACvD,0DAAkD;AAElD,MAAa,aAAc,SAAQ,2BAA6B;IAC5D,YAAY,MAAuB;QAC/B,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;IAChD,CAAC;IAEQ,WAAW,GAAG,4DAA4D,CAAC;IAClE,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,CAAC;IAC7B,OAAO,GAAG,IAAI,sBAAO,CAC1B,8DAA8D,EAC9D,WAAW,EACX;QACI,IAAI,qBAAM,CAAC,+CAA+C,EAAE,IAAI,CAAC;QACjE,IAAI,qBAAM,CACN,iGAAiG,CACpG;KACJ,CACJ,CAAC;IAEF,KAAK,CAAC,GAAgB;QAClB,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,EAAE,CAAC;QAEpC,OAAO,CAAC,IAAI,wBAAC,CAAC,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;IACxC,CAAC;CACJ;AAxBD,sCAwBC","sourcesContent":["import { Option } from '@webpieces/rules-config';\nimport { NoJsFilesConfig } from '../../configs/rule-configs';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint } from '@webpieces/hook-runtime';\n\nexport class NoJsFilesRule extends FileRuleBase<NoJsFilesConfig> {\n constructor(config: NoJsFilesConfig) {\n super(config, 'no-js-files', 'no-js-files');\n }\n\n readonly description = 'Disallow writing new .js/.jsx files. Use .ts/.tsx instead.';\n override readonly files = ['**/*.js', '**/*.jsx'];\n override readonly defaultOptions = {};\n readonly fixHint = new FixHint(\n 'Writing .js/.jsx files is not allowed. Use .ts/.tsx instead.',\n 'Pick one:',\n [\n new Option('Write a .ts or .tsx file instead of .js/.jsx.', true),\n new Option(\n 'If this path must be .js (generated/legacy), add it to no-js-files.excludePaths in {configFile}',\n ),\n ],\n );\n\n check(ctx: FileContext): readonly Violation[] {\n if (ctx.tool !== 'Write') return [];\n\n return [new V(1, ctx.relativePath)];\n }\n}\n"]}
@@ -6,9 +6,7 @@ export declare class NoSymbolDiTokensRule extends EditRuleBase<SourceContributio
6
6
  constructor(config: SourceContributionConfig);
7
7
  readonly description = "Disallow Symbol() DI tokens outside explicitly configured paths. Use @injectable(bindingScopeValues.Singleton) + inject-by-type instead.";
8
8
  readonly files: string[];
9
- readonly defaultOptions: {
10
- allowedPaths: never[];
11
- };
9
+ readonly defaultOptions: {};
12
10
  get fixHint(): FixHint;
13
11
  check(ctx: EditContext): readonly Violation[];
14
12
  }
@@ -7,48 +7,16 @@ const hook_runtime_2 = require("@webpieces/hook-runtime");
7
7
  const hook_runtime_3 = require("@webpieces/hook-runtime");
8
8
  const SYMBOL_DI_REGEX = /=\s*Symbol(?:\.for)?\(/;
9
9
  const TEST_PATHS = [/\.test\.ts$/, /\.spec\.ts$/, /__tests__\//];
10
- function globToRegex(pattern) {
11
- let re = '';
12
- let i = 0;
13
- while (i < pattern.length) {
14
- const ch = pattern[i];
15
- if (ch === '*') {
16
- if (pattern[i + 1] === '*') {
17
- re += '.*';
18
- i += 2;
19
- if (pattern[i] === '/')
20
- i += 1;
21
- continue;
22
- }
23
- re += '[^/]*';
24
- i += 1;
25
- continue;
26
- }
27
- if (ch === '?') {
28
- re += '[^/]';
29
- i += 1;
30
- continue;
31
- }
32
- if ('.+^$(){}|[]\\'.includes(ch)) {
33
- re += '\\' + ch;
34
- i += 1;
35
- continue;
36
- }
37
- re += ch;
38
- i += 1;
39
- }
40
- return new RegExp('^' + re + '$');
41
- }
42
- function isAllowedPath(relativePath, allowedPaths) {
43
- if (TEST_PATHS.some((re) => re.test(relativePath)))
44
- return true;
45
- return allowedPaths.some((pattern) => globToRegex(pattern).test(relativePath));
10
+ // webpieces-disable no-function-outside-class -- leaf predicate over one path, beside the TEST_PATHS it reads
11
+ function isTestPath(relativePath) {
12
+ // Configured trees (this rule's excludePaths, the top-level one) are dropped by the engine (#1253).
13
+ return TEST_PATHS.some((re) => re.test(relativePath));
46
14
  }
47
15
  class NoSymbolDiTokensRule extends hook_runtime_2.EditRuleBase {
48
16
  constructor(config) { super(config, 'no-symbol-di-tokens', 'no-symbol-di-tokens'); }
49
17
  description = 'Disallow Symbol() DI tokens outside explicitly configured paths. Use @injectable(bindingScopeValues.Singleton) + inject-by-type instead.';
50
18
  files = ['**/*.ts', '**/*.tsx'];
51
- defaultOptions = { allowedPaths: [] };
19
+ defaultOptions = {};
52
20
  get fixHint() {
53
21
  return new hook_runtime_3.FixHint('Symbol() used as a DI token — we avoid Symbol DI tokens where we can.', 'Pick one:', [
54
22
  new rules_config_1.Option('Use @injectable(bindingScopeValues.Singleton) on the class and inject by type — no Symbol needed.', true),
@@ -57,8 +25,7 @@ class NoSymbolDiTokensRule extends hook_runtime_2.EditRuleBase {
57
25
  ], new hook_runtime_3.DisableEscape(this.config.disableAllowed ?? true, '// webpieces-disable no-symbol-di-tokens -- <reason>'));
58
26
  }
59
27
  check(ctx) {
60
- const allowedPaths = this.config.allowedPaths ?? [];
61
- if (isAllowedPath(ctx.relativePath, allowedPaths))
28
+ if (isTestPath(ctx.relativePath))
62
29
  return [];
63
30
  const disableAllowed = this.config.disableAllowed ?? true;
64
31
  const violations = [];
@@ -1 +1 @@
1
- {"version":3,"file":"no-symbol-di-tokens.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-symbol-di-tokens.ts"],"names":[],"mappings":";;;AACA,0DAAiD;AAGjD,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD,MAAM,UAAU,GAAa,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAE3E,SAAS,WAAW,CAAC,OAAe;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACb,IAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACzB,EAAE,IAAI,IAAI,CAAC;gBACX,CAAC,IAAI,CAAC,CAAC;gBACP,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG;oBAAE,CAAC,IAAI,CAAC,CAAC;gBAC/B,SAAS;YACb,CAAC;YACD,EAAE,IAAI,OAAO,CAAC;YACd,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACb,CAAC;QACD,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACb,EAAE,IAAI,MAAM,CAAC;YACb,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACb,CAAC;QACD,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;YAC/B,EAAE,IAAI,IAAI,GAAG,EAAE,CAAC;YAChB,CAAC,IAAI,CAAC,CAAC;YACP,SAAS;QACb,CAAC;QACD,EAAE,IAAI,EAAE,CAAC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AAc,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QAC1D,MAAM,UAAU,GAAQ,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAAE,SAAS;YACpD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,cAAc,IAAI,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,CAAC;gBAAE,SAAS;YACnF,UAAU,CAAC,IAAI,CAAC,IAAI,wBAAC,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAlCD,oDAkCC","sourcesContent":["import { SourceContributionConfig } from \"../source-contribution-config\";\nimport { Option } from \"@webpieces/rules-config\";\n\nimport type { EditContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { EditRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst SYMBOL_DI_REGEX = /=\\s*Symbol(?:\\.for)?\\(/;\n\nconst TEST_PATHS: RegExp[] = [/\\.test\\.ts$/, /\\.spec\\.ts$/, /__tests__\\//];\n\nfunction globToRegex(pattern: string): RegExp {\n let re = '';\n let i = 0;\n while (i < pattern.length) {\n const ch = pattern[i];\n if (ch === '*') {\n if (pattern[i + 1] === '*') {\n re += '.*';\n i += 2;\n if (pattern[i] === '/') i += 1;\n continue;\n }\n re += '[^/]*';\n i += 1;\n continue;\n }\n if (ch === '?') {\n re += '[^/]';\n i += 1;\n continue;\n }\n if ('.+^$(){}|[]\\\\'.includes(ch)) {\n re += '\\\\' + ch;\n i += 1;\n continue;\n }\n re += ch;\n i += 1;\n }\n return new RegExp('^' + re + '$');\n}\n\nfunction isAllowedPath(relativePath: string, allowedPaths: readonly string[]): boolean {\n if (TEST_PATHS.some((re: RegExp) => re.test(relativePath))) return true;\n return allowedPaths.some((pattern: string) => globToRegex(pattern).test(relativePath));\n}\n\nexport class NoSymbolDiTokensRule extends EditRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) { super(config, 'no-symbol-di-tokens', 'no-symbol-di-tokens'); }\n\n readonly description = 'Disallow Symbol() DI tokens outside explicitly configured paths. Use @injectable(bindingScopeValues.Singleton) + inject-by-type instead.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = { allowedPaths: [] };\n get fixHint(): FixHint {\n return new FixHint(\n 'Symbol() used as a DI token — we avoid Symbol DI tokens where we can.',\n 'Pick one:',\n [\n new Option('Use @injectable(bindingScopeValues.Singleton) on the class and inject by type — no Symbol needed.', true),\n new Option('Implement an API interface — import the Symbol from the API definition and use @provideSingletonDefaultForApi(TOKEN).'),\n new Option('External lib class (DataSource, Anthropic, etc.) — bind<Cls>(Cls).toDynamicValue(...).inSingletonScope() — no Symbol.'),\n ],\n new DisableEscape(this.config.disableAllowed ?? true, '// webpieces-disable no-symbol-di-tokens -- <reason>'),\n );\n }\n\n check(ctx: EditContext): readonly Violation[] {\n const allowedPaths = this.config.allowedPaths ?? [];\n if (isAllowedPath(ctx.relativePath, allowedPaths)) return [];\n\n const disableAllowed = this.config.disableAllowed ?? true;\n const violations: V[] = [];\n for (let i = 0; i < ctx.strippedLines.length; i += 1) {\n const stripped = ctx.strippedLines[i];\n if (!SYMBOL_DI_REGEX.test(stripped ?? '')) continue;\n const lineNum = i + 1;\n if (disableAllowed && ctx.isLineDisabled(lineNum, \"no-symbol-di-tokens\")) continue;\n violations.push(new V(lineNum, ctx.lines[i]?.trim() ?? ''));\n }\n return violations;\n }\n}\n"]}
1
+ {"version":3,"file":"no-symbol-di-tokens.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/no-symbol-di-tokens.ts"],"names":[],"mappings":";;;AACA,0DAAiD;AAGjD,0DAAyD;AACzD,0DAAuD;AACvD,0DAAiE;AAEjE,MAAM,eAAe,GAAG,wBAAwB,CAAC;AAEjD,MAAM,UAAU,GAAa,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC;AAE3E,8GAA8G;AAC9G,SAAS,UAAU,CAAC,YAAoB;IACpC,oGAAoG;IACpG,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAa,oBAAqB,SAAQ,2BAAsC;IAC5E,YAAY,MAAgC,IAAI,KAAK,CAAC,MAAM,EAAE,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAErG,WAAW,GAAG,0IAA0I,CAAC;IAChJ,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG,EAAE,CAAC;IACtC,IAAI,OAAO;QACP,OAAO,IAAI,sBAAO,CACd,uEAAuE,EACvE,WAAW,EACX;YACI,IAAI,qBAAM,CAAC,mGAAmG,EAAE,IAAI,CAAC;YACrH,IAAI,qBAAM,CAAC,uHAAuH,CAAC;YACnI,IAAI,qBAAM,CAAC,uHAAuH,CAAC;SACtI,EACD,IAAI,4BAAa,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,EAAE,sDAAsD,CAAC,CAChH,CAAC;IACN,CAAC;IAED,KAAK,CAAC,GAAgB;QAClB,IAAI,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC;YAAE,OAAO,EAAE,CAAC;QAE5C,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,IAAI,IAAI,CAAC;QAC1D,MAAM,UAAU,GAAQ,EAAE,CAAC;QAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACtC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;gBAAE,SAAS;YACpD,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,cAAc,IAAI,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,qBAAqB,CAAC;gBAAE,SAAS;YACnF,UAAU,CAAC,IAAI,CAAC,IAAI,wBAAC,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;CACJ;AAjCD,oDAiCC","sourcesContent":["import { SourceContributionConfig } from \"../source-contribution-config\";\nimport { Option } from \"@webpieces/rules-config\";\n\nimport type { EditContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { EditRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint, DisableEscape } from '@webpieces/hook-runtime';\n\nconst SYMBOL_DI_REGEX = /=\\s*Symbol(?:\\.for)?\\(/;\n\nconst TEST_PATHS: RegExp[] = [/\\.test\\.ts$/, /\\.spec\\.ts$/, /__tests__\\//];\n\n// webpieces-disable no-function-outside-class -- leaf predicate over one path, beside the TEST_PATHS it reads\nfunction isTestPath(relativePath: string): boolean {\n // Configured trees (this rule's excludePaths, the top-level one) are dropped by the engine (#1253).\n return TEST_PATHS.some((re: RegExp) => re.test(relativePath));\n}\n\nexport class NoSymbolDiTokensRule extends EditRuleBase<SourceContributionConfig> {\n constructor(config: SourceContributionConfig) { super(config, 'no-symbol-di-tokens', 'no-symbol-di-tokens'); }\n\n readonly description = 'Disallow Symbol() DI tokens outside explicitly configured paths. Use @injectable(bindingScopeValues.Singleton) + inject-by-type instead.';\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = {};\n get fixHint(): FixHint {\n return new FixHint(\n 'Symbol() used as a DI token — we avoid Symbol DI tokens where we can.',\n 'Pick one:',\n [\n new Option('Use @injectable(bindingScopeValues.Singleton) on the class and inject by type — no Symbol needed.', true),\n new Option('Implement an API interface — import the Symbol from the API definition and use @provideSingletonDefaultForApi(TOKEN).'),\n new Option('External lib class (DataSource, Anthropic, etc.) — bind<Cls>(Cls).toDynamicValue(...).inSingletonScope() — no Symbol.'),\n ],\n new DisableEscape(this.config.disableAllowed ?? true, '// webpieces-disable no-symbol-di-tokens -- <reason>'),\n );\n }\n\n check(ctx: EditContext): readonly Violation[] {\n if (isTestPath(ctx.relativePath)) return [];\n\n const disableAllowed = this.config.disableAllowed ?? true;\n const violations: V[] = [];\n for (let i = 0; i < ctx.strippedLines.length; i += 1) {\n const stripped = ctx.strippedLines[i];\n if (!SYMBOL_DI_REGEX.test(stripped ?? '')) continue;\n const lineNum = i + 1;\n if (disableAllowed && ctx.isLineDisabled(lineNum, \"no-symbol-di-tokens\")) continue;\n violations.push(new V(lineNum, ctx.lines[i]?.trim() ?? ''));\n }\n return violations;\n }\n}\n"]}
@@ -7,7 +7,6 @@ export declare class ValidateTsInSrcRule extends FileRuleBase<ValidateTsInSrcCon
7
7
  readonly description = "Every .ts file must belong to a project's src/ directory.";
8
8
  readonly files: string[];
9
9
  readonly defaultOptions: {
10
- excludePaths: string[];
11
10
  allowedRootFiles: string[];
12
11
  };
13
12
  readonly fixHint: FixHint;
@@ -8,7 +8,10 @@ const rules_config_1 = require("@webpieces/rules-config");
8
8
  const hook_runtime_1 = require("@webpieces/hook-runtime");
9
9
  const hook_runtime_2 = require("@webpieces/hook-runtime");
10
10
  const hook_runtime_3 = require("@webpieces/hook-runtime");
11
- const DEFAULT_EXCLUDE_PATHS = [
11
+ // Never project source, whatever the config says: a FLOOR the rule applies itself (like GENERATED_CODE_PATHS
12
+ // for max-file-lines). The repo's own `excludePaths` — this rule's and the top-level one — are framework
13
+ // fields the engine applies before this rule is dispatched (#1253); they ADD to this list.
14
+ const BUILT_IN_EXCLUDE_PATHS = [
12
15
  'node_modules',
13
16
  'dist',
14
17
  '.nx',
@@ -33,20 +36,18 @@ class ValidateTsInSrcRule extends hook_runtime_2.FileRuleBase {
33
36
  description = "Every .ts file must belong to a project's src/ directory.";
34
37
  files = ['**/*.ts', '**/*.tsx'];
35
38
  defaultOptions = {
36
- excludePaths: DEFAULT_EXCLUDE_PATHS,
37
39
  allowedRootFiles: DEFAULT_ALLOWED_ROOT_FILES,
38
40
  };
39
41
  fixHint = new hook_runtime_3.FixHint('TypeScript file is outside a project src/ directory.', 'Fix by one of:', [
40
42
  new rules_config_1.Option("Move the file into an existing project's src/ directory, or create a new project with project.json that owns the directory.", true),
41
- new rules_config_1.Option('Add a dir or glob (e.g. "**/codegen.ts") to validate-ts-in-src.excludePaths in {configFile}'),
43
+ new rules_config_1.Option('Add a glob (e.g. "**/codegen.ts", "scripts/**") to validate-ts-in-src.excludePaths in {configFile}'),
42
44
  ]);
43
45
  check(ctx) {
44
46
  if (ctx.tool !== 'Write')
45
47
  return [];
46
- const excludePaths = this.config.excludePaths ?? DEFAULT_EXCLUDE_PATHS;
47
48
  const allowedRootFiles = this.config.allowedRootFiles ?? DEFAULT_ALLOWED_ROOT_FILES;
48
- // Holistic exclusion (Layer 1 + Layer 2): bare dir names + globs.
49
- if ((0, rules_config_1.isPathExcluded)(ctx.targetRelativePath, excludePaths))
49
+ // The built-in floor (bare dir names + globs); configured excludePaths never reach this rule.
50
+ if ((0, rules_config_1.isPathExcluded)(ctx.targetRelativePath, BUILT_IN_EXCLUDE_PATHS))
50
51
  return [];
51
52
  const relParts = ctx.targetRelativePath.split(path.sep);
52
53
  if (relParts.length === 1 && allowedRootFiles.indexOf(relParts[0] ?? '') >= 0)
@@ -1 +1 @@
1
- {"version":3,"file":"validate-ts-in-src.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/validate-ts-in-src.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,0DAAiE;AAIjE,0DAAyD;AACzD,0DAAuD;AACvD,0DAAkD;AAElD,MAAM,qBAAqB,GAAG;IAC1B,cAAc;IACd,MAAM;IACN,KAAK;IACL,MAAM;IACN,WAAW;IACX,mBAAmB;CACtB,CAAC;AACF,MAAM,0BAA0B,GAAG,CAAC,eAAe,CAAC,CAAC;AAErD,SAAS,eAAe,CAAC,QAAgB,EAAE,aAAqB;IAC5D,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,OAAO,GAAG,KAAK,aAAa,IAAI,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC5D,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QAC9D,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAa,mBAAoB,SAAQ,2BAAmC;IACxE,YAAY,MAA6B;QACrC,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;IAC9D,CAAC;IAEQ,WAAW,GAAG,2DAA2D,CAAC;IACjE,KAAK,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAChC,cAAc,GAAG;QAC/B,YAAY,EAAE,qBAAqB;QACnC,gBAAgB,EAAE,0BAA0B;KAC/C,CAAC;IACO,OAAO,GAAG,IAA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CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAC/D,OAAO;gBACH,IAAI,wBAAC,CACD,CAAC,EACD,GAAG,CAAC,kBAAkB,EACtB,4BAA4B,WAAW,uDAAuD,CACjG;aACJ,CAAC;QACN,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AA/DD,kDA+DC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { isPathExcluded, Option } from '@webpieces/rules-config';\nimport { ValidateTsInSrcConfig } from '../../configs/rule-configs';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint } from '@webpieces/hook-runtime';\n\nconst DEFAULT_EXCLUDE_PATHS = [\n 'node_modules',\n 'dist',\n '.nx',\n '.git',\n '**/*.d.ts',\n '**/jest.config.ts',\n];\nconst DEFAULT_ALLOWED_ROOT_FILES = ['jest.setup.ts'];\n\nfunction findProjectRoot(filePath: string, workspaceRoot: string): string | null {\n let dir = path.dirname(filePath);\n while (dir !== workspaceRoot && dir.startsWith(workspaceRoot)) {\n if (fs.existsSync(path.join(dir, 'project.json'))) return dir;\n dir = path.dirname(dir);\n }\n return null;\n}\n\nexport class ValidateTsInSrcRule extends FileRuleBase<ValidateTsInSrcConfig> {\n constructor(config: ValidateTsInSrcConfig) {\n super(config, 'validate-ts-in-src', 'validate-ts-in-src');\n }\n\n readonly description = \"Every .ts file must belong to a project's src/ directory.\";\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = {\n excludePaths: DEFAULT_EXCLUDE_PATHS,\n allowedRootFiles: DEFAULT_ALLOWED_ROOT_FILES,\n };\n readonly fixHint = new FixHint(\n 'TypeScript file is outside a project src/ directory.',\n 'Fix by one of:',\n [\n new Option(\n \"Move the file into an existing project's src/ directory, or create a new project with project.json that owns the directory.\",\n true,\n ),\n new Option(\n 'Add a dir or glob (e.g. \"**/codegen.ts\") to validate-ts-in-src.excludePaths in {configFile}',\n ),\n ],\n );\n\n check(ctx: FileContext): readonly Violation[] {\n if (ctx.tool !== 'Write') return [];\n\n const excludePaths = this.config.excludePaths ?? DEFAULT_EXCLUDE_PATHS;\n const allowedRootFiles = this.config.allowedRootFiles ?? DEFAULT_ALLOWED_ROOT_FILES;\n\n // Holistic exclusion (Layer 1 + Layer 2): bare dir names + globs.\n if (isPathExcluded(ctx.targetRelativePath, excludePaths)) return [];\n\n const relParts = ctx.targetRelativePath.split(path.sep);\n if (relParts.length === 1 && allowedRootFiles.indexOf(relParts[0] ?? '') >= 0) return [];\n\n const projectRoot = findProjectRoot(ctx.filePath, ctx.targetRoot);\n\n if (!projectRoot) {\n return [\n new V(\n 1,\n ctx.targetRelativePath,\n \"File is not inside any Nx project. Move it into a project's src/ directory.\",\n ),\n ];\n }\n\n const relToProject = path.relative(projectRoot, ctx.filePath);\n if (!relToProject.startsWith('src' + path.sep) && relToProject !== 'src') {\n const projectName = path.relative(ctx.targetRoot, projectRoot);\n return [\n new V(\n 1,\n ctx.targetRelativePath,\n `File is inside project \\`${projectName}\\` but outside its src/ directory. Move it into src/.`,\n ),\n ];\n }\n\n return [];\n }\n}\n"]}
1
+ {"version":3,"file":"validate-ts-in-src.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/validate-ts-in-src.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAE7B,0DAAiE;AAIjE,0DAAyD;AACzD,0DAAuD;AACvD,0DAAkD;AAElD,6GAA6G;AAC7G,yGAAyG;AACzG,2FAA2F;AAC3F,MAAM,sBAAsB,GAAG;IAC3B,cAAc;IACd,MAAM;IACN,KAAK;IACL,MAAM;IACN,WAAW;IACX,mBAAmB;CACtB,CAAC;AACF,MAAM,0BAA0B,GAAG,CAAC,eAAe,CAAC,CAAC;AAErD,SAAS,eAAe,CAAC,QAAgB,EAAE,aAAq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CAAC,MAAM,KAAK,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;QAEzF,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;QAElE,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,OAAO;gBACH,IAAI,wBAAC,CACD,CAAC,EACD,GAAG,CAAC,kBAAkB,EACtB,6EAA6E,CAChF;aACJ,CAAC;QACN,CAAC;QAED,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9D,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;YACvE,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;YAC/D,OAAO;gBACH,IAAI,wBAAC,CACD,CAAC,EACD,GAAG,CAAC,kBAAkB,EACtB,4BAA4B,WAAW,uDAAuD,CACjG;aACJ,CAAC;QACN,CAAC;QAED,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AA7DD,kDA6DC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { isPathExcluded, Option } from '@webpieces/rules-config';\nimport { ValidateTsInSrcConfig } from '../../configs/rule-configs';\n\nimport type { FileContext, Violation } from '@webpieces/hook-runtime';\nimport { Violation as V } from '@webpieces/hook-runtime';\nimport { FileRuleBase } from '@webpieces/hook-runtime';\nimport { FixHint } from '@webpieces/hook-runtime';\n\n// Never project source, whatever the config says: a FLOOR the rule applies itself (like GENERATED_CODE_PATHS\n// for max-file-lines). The repo's own `excludePaths` — this rule's and the top-level one — are framework\n// fields the engine applies before this rule is dispatched (#1253); they ADD to this list.\nconst BUILT_IN_EXCLUDE_PATHS = [\n 'node_modules',\n 'dist',\n '.nx',\n '.git',\n '**/*.d.ts',\n '**/jest.config.ts',\n];\nconst DEFAULT_ALLOWED_ROOT_FILES = ['jest.setup.ts'];\n\nfunction findProjectRoot(filePath: string, workspaceRoot: string): string | null {\n let dir = path.dirname(filePath);\n while (dir !== workspaceRoot && dir.startsWith(workspaceRoot)) {\n if (fs.existsSync(path.join(dir, 'project.json'))) return dir;\n dir = path.dirname(dir);\n }\n return null;\n}\n\nexport class ValidateTsInSrcRule extends FileRuleBase<ValidateTsInSrcConfig> {\n constructor(config: ValidateTsInSrcConfig) {\n super(config, 'validate-ts-in-src', 'validate-ts-in-src');\n }\n\n readonly description = \"Every .ts file must belong to a project's src/ directory.\";\n override readonly files = ['**/*.ts', '**/*.tsx'];\n override readonly defaultOptions = {\n allowedRootFiles: DEFAULT_ALLOWED_ROOT_FILES,\n };\n readonly fixHint = new FixHint(\n 'TypeScript file is outside a project src/ directory.',\n 'Fix by one of:',\n [\n new Option(\n \"Move the file into an existing project's src/ directory, or create a new project with project.json that owns the directory.\",\n true,\n ),\n new Option(\n 'Add a glob (e.g. \"**/codegen.ts\", \"scripts/**\") to validate-ts-in-src.excludePaths in {configFile}',\n ),\n ],\n );\n\n check(ctx: FileContext): readonly Violation[] {\n if (ctx.tool !== 'Write') return [];\n\n const allowedRootFiles = this.config.allowedRootFiles ?? DEFAULT_ALLOWED_ROOT_FILES;\n\n // The built-in floor (bare dir names + globs); configured excludePaths never reach this rule.\n if (isPathExcluded(ctx.targetRelativePath, BUILT_IN_EXCLUDE_PATHS)) return [];\n\n const relParts = ctx.targetRelativePath.split(path.sep);\n if (relParts.length === 1 && allowedRootFiles.indexOf(relParts[0] ?? '') >= 0) return [];\n\n const projectRoot = findProjectRoot(ctx.filePath, ctx.targetRoot);\n\n if (!projectRoot) {\n return [\n new V(\n 1,\n ctx.targetRelativePath,\n \"File is not inside any Nx project. Move it into a project's src/ directory.\",\n ),\n ];\n }\n\n const relToProject = path.relative(projectRoot, ctx.filePath);\n if (!relToProject.startsWith('src' + path.sep) && relToProject !== 'src') {\n const projectName = path.relative(ctx.targetRoot, projectRoot);\n return [\n new V(\n 1,\n ctx.targetRelativePath,\n `File is inside project \\`${projectName}\\` but outside its src/ directory. Move it into src/.`,\n ),\n ];\n }\n\n return [];\n }\n}\n"]}
@@ -4,6 +4,5 @@ export declare class SourceContributionConfig extends BaseRuleConfig {
4
4
  limit?: number;
5
5
  disableAllowed?: boolean;
6
6
  allowTopLevel?: boolean;
7
- allowedPaths?: string[];
8
7
  allowGlobs?: string[];
9
8
  }
@@ -7,7 +7,6 @@ class SourceContributionConfig extends rules_sdk_1.BaseRuleConfig {
7
7
  limit;
8
8
  disableAllowed;
9
9
  allowTopLevel;
10
- allowedPaths;
11
10
  allowGlobs;
12
11
  }
13
12
  exports.SourceContributionConfig = SourceContributionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"source-contribution-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/source-contribution-config.ts"],"names":[],"mappings":";;;AAAA,oDAAsD;AAEtD,sGAAsG;AACtG,MAAa,wBAAyB,SAAQ,0BAAc;IACxD,KAAK,CAAU;IACf,cAAc,CAAW;IACzB,aAAa,CAAW;IACxB,YAAY,CAAY;IACxB,UAAU,CAAY;CACzB;AAND,4DAMC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\n\n/** Resolved settings consumed by source contributions; the canonical owner validates their schema. */\nexport class SourceContributionConfig extends BaseRuleConfig {\n limit?: number;\n disableAllowed?: boolean;\n allowTopLevel?: boolean;\n allowedPaths?: string[];\n allowGlobs?: string[];\n}\n"]}
1
+ {"version":3,"file":"source-contribution-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/source-contribution-config.ts"],"names":[],"mappings":";;;AAAA,oDAAsD;AAEtD,sGAAsG;AACtG,MAAa,wBAAyB,SAAQ,0BAAc;IACxD,KAAK,CAAU;IACf,cAAc,CAAW;IACzB,aAAa,CAAW;IACxB,UAAU,CAAY;CACzB;AALD,4DAKC","sourcesContent":["import { BaseRuleConfig } from '@webpieces/rules-sdk';\n\n/** Resolved settings consumed by source contributions; the canonical owner validates their schema. */\nexport class SourceContributionConfig extends BaseRuleConfig {\n limit?: number;\n disableAllowed?: boolean;\n allowTopLevel?: boolean;\n allowGlobs?: string[];\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { RetiredConfigKey } from '@webpieces/rules-sdk';
2
+ /**
3
+ * Rejected obsolete ai-hook-rules fields, each with its exact repair instruction. `no-js-files.allowedPaths`
4
+ * meant "do not judge these files"; the framework-owned `excludePaths`, which every rule accepts and the
5
+ * engine applies, replaced it (#1253). There is no alias.
6
+ */
7
+ export declare const ruleMigrations: readonly RetiredConfigKey[];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ruleMigrations = void 0;
4
+ const rules_sdk_1 = require("@webpieces/rules-sdk");
5
+ /**
6
+ * Rejected obsolete ai-hook-rules fields, each with its exact repair instruction. `no-js-files.allowedPaths`
7
+ * meant "do not judge these files"; the framework-owned `excludePaths`, which every rule accepts and the
8
+ * engine applies, replaced it (#1253). There is no alias.
9
+ */
10
+ exports.ruleMigrations = [
11
+ new rules_sdk_1.RetiredConfigKey('field', 'no-js-files.allowedPaths', 'no-js-files.excludePaths', '"allowedPaths" was renamed to "excludePaths" — a framework field every rule now accepts (#1253). ' +
12
+ 'Rename the key inside the "no-js-files" entry and keep its globs; they are matched against the ' +
13
+ 'workspace-relative path ("**" any depth, "*" one segment), so write a tree as "dir/**". To exclude ' +
14
+ 'a path from EVERY rule instead, list it in the top-level "excludePaths" of webpieces.config.json.', '[no-js-files]', false),
15
+ ];
16
+ //# sourceMappingURL=rule-migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-migrations.js","sourceRoot":"","sources":["../../../../../packages/tooling/ai-hook-rules/src/rule-migrations.ts"],"names":[],"mappings":";;;AAAA,oDAAwD;AAExD;;;;GAIG;AACU,QAAA,cAAc,GAAgC;IACvD,IAAI,4BAAgB,CAChB,OAAO,EACP,0BAA0B,EAC1B,0BAA0B,EAC1B,mGAAmG;QAC/F,iGAAiG;QACjG,qGAAqG;QACrG,mGAAmG,EACvG,eAAe,EACf,KAAK,CACR;CACJ,CAAC","sourcesContent":["import { RetiredConfigKey } from '@webpieces/rules-sdk';\n\n/**\n * Rejected obsolete ai-hook-rules fields, each with its exact repair instruction. `no-js-files.allowedPaths`\n * meant \"do not judge these files\"; the framework-owned `excludePaths`, which every rule accepts and the\n * engine applies, replaced it (#1253). There is no alias.\n */\nexport const ruleMigrations: readonly RetiredConfigKey[] = [\n new RetiredConfigKey(\n 'field',\n 'no-js-files.allowedPaths',\n 'no-js-files.excludePaths',\n '\"allowedPaths\" was renamed to \"excludePaths\" — a framework field every rule now accepts (#1253). ' +\n 'Rename the key inside the \"no-js-files\" entry and keep its globs; they are matched against the ' +\n 'workspace-relative path (\"**\" any depth, \"*\" one segment), so write a tree as \"dir/**\". To exclude ' +\n 'a path from EVERY rule instead, list it in the top-level \"excludePaths\" of webpieces.config.json.',\n '[no-js-files]',\n false,\n ),\n];\n"]}
package/src/rule-pack.js CHANGED
@@ -4,5 +4,6 @@ exports.rulePackManifest = void 0;
4
4
  const rules_sdk_1 = require("@webpieces/rules-sdk");
5
5
  const source_policy_registry_1 = require("./source-policy-registry");
6
6
  const package_json_1 = require("../package.json");
7
- exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/ai-hook-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION, source_policy_registry_1.ownedRules, source_policy_registry_1.SOURCE_POLICIES.map((policy) => new rules_sdk_1.RuleContribution(policy.id, policy.ownerPack, 'source-hook', '@webpieces/ai-hook-rules/rule-runtime')), [], []);
7
+ const rule_migrations_1 = require("./rule-migrations");
8
+ exports.rulePackManifest = new rules_sdk_1.RulePackManifest('@webpieces/ai-hook-rules', package_json_1.version, rules_sdk_1.RULE_PACK_API_VERSION, source_policy_registry_1.ownedRules, source_policy_registry_1.SOURCE_POLICIES.map((policy) => new rules_sdk_1.RuleContribution(policy.id, policy.ownerPack, 'source-hook', '@webpieces/ai-hook-rules/rule-runtime')), rule_migrations_1.ruleMigrations, []);
8
9
  //# sourceMappingURL=rule-pack.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/ai-hook-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,oDAAiG;AACjG,qEAAqF;AACrF,kDAA0C;AAE7B,QAAA,gBAAgB,GAAG,IAAI,4BAAgB,CAChD,0BAA0B,EAC1B,sBAAO,EACP,iCAAqB,EACrB,mCAAU,EACV,wCAAe,CAAC,GAAG,CACf,CAAC,MAAoB,EAAE,EAAE,CACrB,IAAI,4BAAgB,CAChB,MAAM,CAAC,EAAE,EACT,MAAM,CAAC,SAAS,EAChB,aAAa,EACb,uCAAuC,CAC1C,CACR,EACD,EAAE,EACF,EAAE,CACL,CAAC","sourcesContent":["import { RuleContribution, RulePackManifest, RULE_PACK_API_VERSION } from '@webpieces/rules-sdk';\nimport { ownedRules, SOURCE_POLICIES, SourcePolicy } from './source-policy-registry';\nimport { version } from '../package.json';\n\nexport const rulePackManifest = new RulePackManifest(\n '@webpieces/ai-hook-rules',\n version,\n RULE_PACK_API_VERSION,\n ownedRules,\n SOURCE_POLICIES.map(\n (policy: SourcePolicy) =>\n new RuleContribution(\n policy.id,\n policy.ownerPack,\n 'source-hook',\n '@webpieces/ai-hook-rules/rule-runtime',\n ),\n ),\n [],\n [],\n);\n"]}
1
+ {"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/ai-hook-rules/src/rule-pack.ts"],"names":[],"mappings":";;;AAAA,oDAAiG;AACjG,qEAAqF;AACrF,kDAA0C;AAC1C,uDAAmD;AAEtC,QAAA,gBAAgB,GAAG,IAAI,4BAAgB,CAChD,0BAA0B,EAC1B,sBAAO,EACP,iCAAqB,EACrB,mCAAU,EACV,wCAAe,CAAC,GAAG,CACf,CAAC,MAAoB,EAAE,EAAE,CACrB,IAAI,4BAAgB,CAChB,MAAM,CAAC,EAAE,EACT,MAAM,CAAC,SAAS,EAChB,aAAa,EACb,uCAAuC,CAC1C,CACR,EACD,gCAAc,EACd,EAAE,CACL,CAAC","sourcesContent":["import { RuleContribution, RulePackManifest, RULE_PACK_API_VERSION } from '@webpieces/rules-sdk';\nimport { ownedRules, SOURCE_POLICIES, SourcePolicy } from './source-policy-registry';\nimport { version } from '../package.json';\nimport { ruleMigrations } from './rule-migrations';\n\nexport const rulePackManifest = new RulePackManifest(\n '@webpieces/ai-hook-rules',\n version,\n RULE_PACK_API_VERSION,\n ownedRules,\n SOURCE_POLICIES.map(\n (policy: SourcePolicy) =>\n new RuleContribution(\n policy.id,\n policy.ownerPack,\n 'source-hook',\n '@webpieces/ai-hook-rules/rule-runtime',\n ),\n ),\n ruleMigrations,\n [],\n);\n"]}
@@ -8,14 +8,6 @@ exports.optionalTuning = {
8
8
  "validate-ts-in-src": {
9
9
  "allowedRootFiles": [
10
10
  "jest.setup.ts"
11
- ],
12
- "excludePaths": [
13
- "node_modules",
14
- "dist",
15
- ".nx",
16
- ".git",
17
- "**/*.d.ts",
18
- "**/jest.config.ts"
19
11
  ]
20
12
  }
21
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rule-settings.js","sourceRoot":"","sources":["../../../../../packages/tooling/ai-hook-rules/src/rule-settings.ts"],"names":[],"mappings":";;;AAEA,oFAAoF;AACvE,QAAA,cAAc,GAA2C;IAClE,sBAAsB,EAAE,EAAE;IAC1B,aAAa,EAAE,EAAE;IACjB,oBAAoB,EAAE;QAClB,kBAAkB,EAAE;YAChB,eAAe;SAClB;QACD,cAAc,EAAE;YACZ,cAAc;YACd,MAAM;YACN,KAAK;YACL,MAAM;YACN,WAAW;YACX,mBAAmB;SACtB;KACJ;CACJ,CAAC;AAEF,yEAAyE;AAC5D,QAAA,gBAAgB,GAA2C;IACpE,sBAAsB,EAAE;QACpB,MAAM,EAAE,uBAAuB;QAC/B,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;IACD,aAAa,EAAE;QACX,MAAM,EAAE,wBAAwB;QAChC,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;IACD,oBAAoB,EAAE;QAClB,MAAM,EAAE,wBAAwB;QAChC,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;CACJ,CAAC","sourcesContent":["import { ConfigObject } from '@webpieces/rules-sdk';\n\n/** Optional knobs only. Required behaviour is always supplied by the repository. */\nexport const optionalTuning: Readonly<Record<string, ConfigObject>> = {\n \"throw-cause-required\": {},\n \"no-js-files\": {},\n \"validate-ts-in-src\": {\n \"allowedRootFiles\": [\n \"jest.setup.ts\"\n ],\n \"excludePaths\": [\n \"node_modules\",\n \"dist\",\n \".nx\",\n \".git\",\n \"**/*.d.ts\",\n \"**/jest.config.ts\"\n ]\n }\n};\n\n/** Written for review by setup/sync; never used as a loader fallback. */\nexport const recommendedSeeds: Readonly<Record<string, ConfigObject>> = {\n \"throw-cause-required\": {\n \"mode\": \"NEW_AND_MODIFIED_CODE\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n },\n \"no-js-files\": {\n \"mode\": \"NEW_AND_MODIFIED_FILES\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n },\n \"validate-ts-in-src\": {\n \"mode\": \"NEW_AND_MODIFIED_FILES\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n }\n};\n"]}
1
+ {"version":3,"file":"rule-settings.js","sourceRoot":"","sources":["../../../../../packages/tooling/ai-hook-rules/src/rule-settings.ts"],"names":[],"mappings":";;;AAEA,oFAAoF;AACvE,QAAA,cAAc,GAA2C;IAClE,sBAAsB,EAAE,EAAE;IAC1B,aAAa,EAAE,EAAE;IACjB,oBAAoB,EAAE;QAClB,kBAAkB,EAAE;YAChB,eAAe;SAClB;KACJ;CACJ,CAAC;AAEF,yEAAyE;AAC5D,QAAA,gBAAgB,GAA2C;IACpE,sBAAsB,EAAE;QACpB,MAAM,EAAE,uBAAuB;QAC/B,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;IACD,aAAa,EAAE;QACX,MAAM,EAAE,wBAAwB;QAChC,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;IACD,oBAAoB,EAAE;QAClB,MAAM,EAAE,wBAAwB;QAChC,uBAAuB,EAAE,CAAC;QAC1B,0BAA0B,EAAE,IAAI;KACnC;CACJ,CAAC","sourcesContent":["import { ConfigObject } from '@webpieces/rules-sdk';\n\n/** Optional knobs only. Required behaviour is always supplied by the repository. */\nexport const optionalTuning: Readonly<Record<string, ConfigObject>> = {\n \"throw-cause-required\": {},\n \"no-js-files\": {},\n \"validate-ts-in-src\": {\n \"allowedRootFiles\": [\n \"jest.setup.ts\"\n ]\n }\n};\n\n/** Written for review by setup/sync; never used as a loader fallback. */\nexport const recommendedSeeds: Readonly<Record<string, ConfigObject>> = {\n \"throw-cause-required\": {\n \"mode\": \"NEW_AND_MODIFIED_CODE\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n },\n \"no-js-files\": {\n \"mode\": \"NEW_AND_MODIFIED_FILES\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n },\n \"validate-ts-in-src\": {\n \"mode\": \"NEW_AND_MODIFIED_FILES\",\n \"turnOffRuleUntilEpoch\": 0,\n \"turnOffRuleWhileOnBranch\": null\n }\n};\n"]}