@webpieces/hook-runtime 0.4.927 → 0.4.929

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/hook-runtime",
3
- "version": "0.4.927",
3
+ "version": "0.4.929",
4
4
  "description": "Agent hook protocol, normalized events, and fail-closed application boundary.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -22,16 +22,16 @@
22
22
  "dependencies": {
23
23
  "inversify": "7.10.4",
24
24
  "reflect-metadata": "0.2.2",
25
- "@webpieces/rules-config": "0.4.927",
26
- "@webpieces/tooling-common": "0.4.927",
25
+ "@webpieces/rules-config": "0.4.929",
26
+ "@webpieces/tooling-common": "0.4.929",
27
27
  "tslib": "2.8.1",
28
- "@webpieces/rules-sdk": "0.4.927"
28
+ "@webpieces/rules-sdk": "0.4.929"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@webpieces/tooling-testkit": "0.4.927"
34
+ "@webpieces/tooling-testkit": "0.4.929"
35
35
  },
36
36
  "types": "./src/index.d.ts"
37
37
  }
@@ -5,7 +5,7 @@ exports.bashGovernedPath = bashGovernedPath;
5
5
  const tslib_1 = require("tslib");
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const rules_config_1 = require("@webpieces/rules-config");
8
- const glob_1 = require("./glob");
8
+ const rules_config_2 = require("@webpieces/rules-config");
9
9
  const target_tree_1 = require("./target-tree");
10
10
  /**
11
11
  * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its
@@ -34,9 +34,12 @@ function filterByExcludedPaths(rules, governed, ex) {
34
34
  // revertable in the tree it belongs to.
35
35
  if ((0, rules_config_1.isWebpiecesStateDir)(governed.treeRelativePath))
36
36
  return [];
37
- if (ex.paths.some((p) => (0, glob_1.globMatches)(p, governed.relativePath)))
37
+ if (ex.paths.some((p) => (0, rules_config_2.globMatches)(p, governed.relativePath)))
38
38
  return [];
39
- return rules;
39
+ // Then each rule's OWN `excludePaths` (#1253) — the same globs, the same matcher, applied here once
40
+ // so no rule filters its own paths. `.webpieces/` and the top-level list above drop every rule; this
41
+ // drops only the rule whose entry names the path.
42
+ return rules.filter((rule) => !rule.excludesPath(governed.relativePath));
40
43
  }
41
44
  /**
42
45
  * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —
@@ -1 +1 @@
1
- {"version":3,"file":"excluded-paths.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/excluded-paths.ts"],"names":[],"mappings":";;AA6BA,sDASC;AAYD,4CAMC;;AAxDD,mDAA6B;AAE7B,0DAA4E;AAG5E,iCAAqC;AACrC,+CAA6C;AAG7C;;;;;;;GAOG;AAEH,uGAAuG;AACvG,wGAAwG;AACxG,4FAA4F;AAC5F,qEAAqE;AACrE,EAAE;AACF,kGAAkG;AAClG,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,2CAA2C;AAC3C,kOAAkO;AAClO,SAAgB,qBAAqB,CAAC,KAAsB,EAAE,QAAsB,EAAE,EAAgB;IAClG,mGAAmG;IACnG,8FAA8F;IAC9F,oGAAoG;IACpG,6FAA6F;IAC7F,wCAAwC;IACxC,IAAI,IAAA,kCAAmB,EAAC,QAAQ,CAAC,gBAAgB,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9D,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,IAAA,kBAAW,EAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5F,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,0GAA0G;AAC1G,SAAgB,gBAAgB,CAAC,IAAmB,EAAE,aAAqB;IACvE,OAAO,IAAI,0BAAY,CACnB,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,EAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,EAC3C,IAAI,CAAC,IAAI,CACZ,CAAC;AACN,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { ExcludePaths, isWebpiecesStateDir } from '@webpieces/rules-config';\n\nimport { EffectiveTree } from './effective-tree';\nimport { globMatches } from './glob';\nimport { GovernedPath } from './target-tree';\nimport type { Rule } from './types';\n\n/**\n * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its\n * argument for the bash surface.\n *\n * Lifted out of runner.ts, which the file-size rule had outgrown. It is a natural seam rather than a\n * page-count fix: this is the only place `excludePaths` and the hard-coded `.webpieces/` skip are\n * consulted, and runner.ts is otherwise the four tool ENTRY POINTS and their L0/L1 preamble.\n */\n\n// Drop every rule excluded for this path (webpieces.config.json → excludePaths). ONE glob list: a path\n// listed there is hands-off for code-style rules and file-scoped guards alike, because webpieces either\n// governs a path or it does not. Per-rule carve-outs live in the rule's own `excludePaths`.\n// This is L1's FILTER (not a table row) — see guards/L1-location.md.\n//\n// It takes a GovernedPath and not a bare string because the two questions below are asked against\n// DIFFERENT roots, and answering both from the governed-root spelling is issue #851's secondary defect:\n// the excludePaths globs are authored against the governed root, while `.webpieces/` is the state dir OF\n// A TREE and a linked worktree has its own. One argument carrying both spellings is what stops a caller\n// picking the wrong one; see GovernedPath.\n// webpieces-disable no-function-outside-class -- L1's filter, a pure predicate over one path and one glob list; it is called from four module-scope entry points in runner.ts and a class here would be a namespace with no state\nexport function filterByExcludedPaths(rules: readonly Rule[], governed: GovernedPath, ex: ExcludePaths): readonly Rule[] {\n // webpieces' OWN gitignored state dir is never governed, config or no config. Ahead of the list on\n // purpose — see isWebpiecesStateDir for why it is code and not a seeded glob. Asked about the\n // OWNING tree's spelling, so `<primary>/.claude/worktrees/agent-X/.webpieces/...` is exempt for the\n // identical reason `<primary>/.webpieces/...` is: nothing under it is tracked, reviewable or\n // revertable in the tree it belongs to.\n if (isWebpiecesStateDir(governed.treeRelativePath)) return [];\n if (ex.paths.some((p: string): boolean => globMatches(p, governed.relativePath))) return [];\n return rules;\n}\n\n/**\n * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —\n * so it costs no extra git call on the hook's blocking path.\n *\n * Both spellings of the command's effective cwd: relative to the governed root for the excludePaths\n * globs, and relative to the OWNING tree for the `.webpieces/` skip — which for\n * `cd <worktree>/.webpieces && …` is the worktree's state dir, not the primary's. Both are '' for a\n * command with no leading `cd`, which matches no glob and is not the state dir.\n */\n// webpieces-disable no-function-outside-class -- the bash-side constructor for the value above, beside it\nexport function bashGovernedPath(tree: EffectiveTree, workspaceRoot: string): GovernedPath {\n return new GovernedPath(\n path.relative(workspaceRoot, tree.effectiveCwd),\n path.relative(tree.root, tree.effectiveCwd),\n tree.root,\n );\n}\n"]}
1
+ {"version":3,"file":"excluded-paths.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/excluded-paths.ts"],"names":[],"mappings":";;AA6BA,sDAYC;AAYD,4CAMC;;AA3DD,mDAA6B;AAE7B,0DAA4E;AAG5E,0DAAsD;AACtD,+CAA6C;AAG7C;;;;;;;GAOG;AAEH,uGAAuG;AACvG,wGAAwG;AACxG,4FAA4F;AAC5F,qEAAqE;AACrE,EAAE;AACF,kGAAkG;AAClG,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,2CAA2C;AAC3C,kOAAkO;AAClO,SAAgB,qBAAqB,CAAC,KAAsB,EAAE,QAAsB,EAAE,EAAgB;IAClG,mGAAmG;IACnG,8FAA8F;IAC9F,oGAAoG;IACpG,6FAA6F;IAC7F,wCAAwC;IACxC,IAAI,IAAA,kCAAmB,EAAC,QAAQ,CAAC,gBAAgB,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9D,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,IAAA,0BAAW,EAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5F,oGAAoG;IACpG,qGAAqG;IACrG,kDAAkD;IAClD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAU,EAAW,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;;;GAQG;AACH,0GAA0G;AAC1G,SAAgB,gBAAgB,CAAC,IAAmB,EAAE,aAAqB;IACvE,OAAO,IAAI,0BAAY,CACnB,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,EAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,EAC3C,IAAI,CAAC,IAAI,CACZ,CAAC;AACN,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { ExcludePaths, isWebpiecesStateDir } from '@webpieces/rules-config';\n\nimport { EffectiveTree } from './effective-tree';\nimport { globMatches } from '@webpieces/rules-config';\nimport { GovernedPath } from './target-tree';\nimport type { Rule } from './types';\n\n/**\n * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its\n * argument for the bash surface.\n *\n * Lifted out of runner.ts, which the file-size rule had outgrown. It is a natural seam rather than a\n * page-count fix: this is the only place `excludePaths` and the hard-coded `.webpieces/` skip are\n * consulted, and runner.ts is otherwise the four tool ENTRY POINTS and their L0/L1 preamble.\n */\n\n// Drop every rule excluded for this path (webpieces.config.json → excludePaths). ONE glob list: a path\n// listed there is hands-off for code-style rules and file-scoped guards alike, because webpieces either\n// governs a path or it does not. Per-rule carve-outs live in the rule's own `excludePaths`.\n// This is L1's FILTER (not a table row) — see guards/L1-location.md.\n//\n// It takes a GovernedPath and not a bare string because the two questions below are asked against\n// DIFFERENT roots, and answering both from the governed-root spelling is issue #851's secondary defect:\n// the excludePaths globs are authored against the governed root, while `.webpieces/` is the state dir OF\n// A TREE and a linked worktree has its own. One argument carrying both spellings is what stops a caller\n// picking the wrong one; see GovernedPath.\n// webpieces-disable no-function-outside-class -- L1's filter, a pure predicate over one path and one glob list; it is called from four module-scope entry points in runner.ts and a class here would be a namespace with no state\nexport function filterByExcludedPaths(rules: readonly Rule[], governed: GovernedPath, ex: ExcludePaths): readonly Rule[] {\n // webpieces' OWN gitignored state dir is never governed, config or no config. Ahead of the list on\n // purpose — see isWebpiecesStateDir for why it is code and not a seeded glob. Asked about the\n // OWNING tree's spelling, so `<primary>/.claude/worktrees/agent-X/.webpieces/...` is exempt for the\n // identical reason `<primary>/.webpieces/...` is: nothing under it is tracked, reviewable or\n // revertable in the tree it belongs to.\n if (isWebpiecesStateDir(governed.treeRelativePath)) return [];\n if (ex.paths.some((p: string): boolean => globMatches(p, governed.relativePath))) return [];\n // Then each rule's OWN `excludePaths` (#1253) — the same globs, the same matcher, applied here once\n // so no rule filters its own paths. `.webpieces/` and the top-level list above drop every rule; this\n // drops only the rule whose entry names the path.\n return rules.filter((rule: Rule): boolean => !rule.excludesPath(governed.relativePath));\n}\n\n/**\n * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —\n * so it costs no extra git call on the hook's blocking path.\n *\n * Both spellings of the command's effective cwd: relative to the governed root for the excludePaths\n * globs, and relative to the OWNING tree for the `.webpieces/` skip — which for\n * `cd <worktree>/.webpieces && …` is the worktree's state dir, not the primary's. Both are '' for a\n * command with no leading `cd`, which matches no glob and is not the state dir.\n */\n// webpieces-disable no-function-outside-class -- the bash-side constructor for the value above, beside it\nexport function bashGovernedPath(tree: EffectiveTree, workspaceRoot: string): GovernedPath {\n return new GovernedPath(\n path.relative(workspaceRoot, tree.effectiveCwd),\n path.relative(tree.root, tree.effectiveCwd),\n tree.root,\n );\n}\n"]}
@@ -7,7 +7,7 @@ exports.runFileRules = runFileRules;
7
7
  const rules_config_1 = require("@webpieces/rules-config");
8
8
  const to_error_1 = require("@webpieces/tooling-common/to-error");
9
9
  const types_1 = require("./types");
10
- const glob_1 = require("./glob");
10
+ const rules_config_2 = require("@webpieces/rules-config");
11
11
  // Every entry was read from its declared owner file and validated before execution.
12
12
  // webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers
13
13
  function runRuleCheck(rule, ctx) {
@@ -36,7 +36,7 @@ function violationFromRuleFail(error) {
36
36
  // webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers
37
37
  function ruleMatchesFile(rule, relativePath) {
38
38
  for (const pattern of rule.files) {
39
- if ((0, glob_1.globMatches)(pattern, relativePath))
39
+ if ((0, rules_config_2.globMatches)(pattern, relativePath))
40
40
  return true;
41
41
  }
42
42
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"rule-evaluation.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/rule-evaluation.ts"],"names":[],"mappings":";;AAgBA,oCAeC;AAqBD,oCAcC;AAGD,oCAwBC;AAGD,oCAeC;AA/GD,0DAA6E;AAC7E,iEAA6D;AAC7D,mCAQiB;AAEjB,iCAAqC;AAErC,oFAAoF;AACpF,+HAA+H;AAC/H,SAAgB,YAAY,CACxB,IAAU,EACV,GAA4C;IAE5C,8DAA8D;IAC9D,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,6GAA6G;IAC7G,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,KAAK,YAAY,4BAAa,EAAE,CAAC;YACjC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,iBAAS,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,IAAI,CAAC,IAAI,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;AACL,C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C,SAAS,EAAE;YAAE,SAAS;QAChC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC;YAAE,SAAS;QAC/D,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC3C,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChB,MAAM,CAAC,IAAI,CAAC,IAAI,iBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { RuleFailError, renderRuleFailForAi } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport {\n Rule,\n EditContext,\n FileContext,\n BashContext,\n Violation,\n RuleGroup,\n BlockedResult,\n} from './types';\n\nimport { globMatches } from './glob';\n\n// Every entry was read from its declared owner file and validated before execution.\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runRuleCheck(\n rule: Rule,\n ctx: EditContext | FileContext | BashContext,\n): readonly Violation[] {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return rule.check(ctx);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof RuleFailError) {\n return [violationFromRuleFail(error)];\n }\n return [new Violation(0, '', `Rule '${rule.name}' crashed: ${error.message}`)];\n }\n}\n\n// A thrown RuleFailError carries its own AI-facing message + optional location and cures. Fold the\n// cures into the message because Violation has no fixHint field (RuleGroup's fixHint comes from the\n// rule definition, not a per-throw value). The \"Fix Option N:\"/\"(preferred)\" labels come from the ONE\n// framework-owned renderer, exactly as report.ts renders a rule's static FixHint — a rule never\n// hand-numbers its own cures.\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nfunction violationFromRuleFail(error: RuleFailError): Violation {\n return new Violation(error.line ?? 0, error.snippet ?? '', renderRuleFailForAi(error));\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nfunction ruleMatchesFile(rule: Rule, relativePath: string): boolean {\n for (const pattern of rule.files) {\n if (globMatches(pattern, relativePath)) return true;\n }\n return false;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runBashRules(\n rules: readonly Rule[],\n bashContext: BashContext,\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'bash') continue;\n if (!rule.shouldRun()) continue;\n const vs = runRuleCheck(rule, bashContext);\n if (vs.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, [...vs]));\n }\n }\n return groups;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runEditRules(\n rules: readonly Rule[],\n editContexts: readonly EditContext[],\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'edit') continue;\n if (!rule.shouldRun()) continue;\n const allViolations: Violation[] = [];\n for (const ctx of editContexts) {\n if (!ruleMatchesFile(rule, ctx.relativePath)) continue;\n const vs = runRuleCheck(rule, ctx);\n for (const v of vs) {\n const copy = new Violation(v.line, v.snippet, v.message);\n copy.editIndex = ctx.editIndex;\n copy.editCount = ctx.editCount;\n allViolations.push(copy);\n }\n }\n if (allViolations.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, allViolations));\n }\n }\n return groups;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runFileRules(\n rules: readonly Rule[],\n fileContext: FileContext,\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'file') continue;\n if (!rule.shouldRun()) continue;\n if (!ruleMatchesFile(rule, fileContext.relativePath)) continue;\n const vs = runRuleCheck(rule, fileContext);\n if (vs.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, [...vs]));\n }\n }\n return groups;\n}\n"]}
1
+ {"version":3,"file":"rule-evaluation.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/rule-evaluation.ts"],"names":[],"mappings":";;AAgBA,oCAeC;AAqBD,oCAcC;AAGD,oCAwBC;AAGD,oCAeC;AA/GD,0DAA6E;AAC7E,iEAA6D;AAC7D,mCAQiB;AAEjB,0DAAsD;AAEtD,oFAAoF;AACpF,+HAA+H;AAC/H,SAAgB,YAAY,CACxB,IAAU,EACV,GAA4C;IAE5C,8DAA8D;IAC9D,IAAI,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3B,6GAA6G;IAC7G,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,IAAI,KAAK,YAAY,4BAAa,EAAE,CAAC;YACjC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,iBAAS,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,IAAI,CAAC,IAAI,cAAc,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;AACL,CAAC;AAED,mGAAmG;AACnG,oGAAoG;AACpG,sGAAsG;AACtG,gGAAgG;AAChG,8BAA8B;AAC9B,+HAA+H;AAC/H,SAAS,qBAAqB,CAAC,KAAoB;IAC/C,OAAO,IAAI,iBAAS,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,EAAE,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,IAAA,kCAAmB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC3F,CAAC;AAED,+HAA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E,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { RuleFailError, renderRuleFailForAi } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport {\n Rule,\n EditContext,\n FileContext,\n BashContext,\n Violation,\n RuleGroup,\n BlockedResult,\n} from './types';\n\nimport { globMatches } from '@webpieces/rules-config';\n\n// Every entry was read from its declared owner file and validated before execution.\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runRuleCheck(\n rule: Rule,\n ctx: EditContext | FileContext | BashContext,\n): readonly Violation[] {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return rule.check(ctx);\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof RuleFailError) {\n return [violationFromRuleFail(error)];\n }\n return [new Violation(0, '', `Rule '${rule.name}' crashed: ${error.message}`)];\n }\n}\n\n// A thrown RuleFailError carries its own AI-facing message + optional location and cures. Fold the\n// cures into the message because Violation has no fixHint field (RuleGroup's fixHint comes from the\n// rule definition, not a per-throw value). The \"Fix Option N:\"/\"(preferred)\" labels come from the ONE\n// framework-owned renderer, exactly as report.ts renders a rule's static FixHint — a rule never\n// hand-numbers its own cures.\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nfunction violationFromRuleFail(error: RuleFailError): Violation {\n return new Violation(error.line ?? 0, error.snippet ?? '', renderRuleFailForAi(error));\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nfunction ruleMatchesFile(rule: Rule, relativePath: string): boolean {\n for (const pattern of rule.files) {\n if (globMatches(pattern, relativePath)) return true;\n }\n return false;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runBashRules(\n rules: readonly Rule[],\n bashContext: BashContext,\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'bash') continue;\n if (!rule.shouldRun()) continue;\n const vs = runRuleCheck(rule, bashContext);\n if (vs.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, [...vs]));\n }\n }\n return groups;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runEditRules(\n rules: readonly Rule[],\n editContexts: readonly EditContext[],\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'edit') continue;\n if (!rule.shouldRun()) continue;\n const allViolations: Violation[] = [];\n for (const ctx of editContexts) {\n if (!ruleMatchesFile(rule, ctx.relativePath)) continue;\n const vs = runRuleCheck(rule, ctx);\n for (const v of vs) {\n const copy = new Violation(v.line, v.snippet, v.message);\n copy.editIndex = ctx.editIndex;\n copy.editCount = ctx.editCount;\n allViolations.push(copy);\n }\n }\n if (allViolations.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, allViolations));\n }\n }\n return groups;\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless evaluator helpers extracted intact for both hook providers\nexport function runFileRules(\n rules: readonly Rule[],\n fileContext: FileContext,\n): readonly RuleGroup[] {\n const groups: RuleGroup[] = [];\n for (const rule of rules) {\n if (rule.scope !== 'file') continue;\n if (!rule.shouldRun()) continue;\n if (!ruleMatchesFile(rule, fileContext.relativePath)) continue;\n const vs = runRuleCheck(rule, fileContext);\n if (vs.length > 0) {\n groups.push(new RuleGroup(rule.name, rule.description, rule.fixHint, [...vs]));\n }\n }\n return groups;\n}\n"]}
@@ -125,6 +125,12 @@ export interface Rule extends PlainRule {
125
125
  */
126
126
  readonly configKey: string;
127
127
  shouldRun(): boolean;
128
+ /**
129
+ * True when this rule's own `excludePaths` matches the workspace-relative path (#1253). The engine
130
+ * asks it before dispatching the rule on a path, exactly as it asks shouldRun() — no rule filters
131
+ * its own paths. AbstractRule supplies it.
132
+ */
133
+ excludesPath(relativePath: string): boolean;
128
134
  }
129
135
  export declare class RuleGroup {
130
136
  readonly ruleName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/types.ts"],"names":[],"mappings":";;;AAWA,0DAAwD;AAmBxD,MAAa,SAAS;IACT,IAAI,CAAS;IACb,OAAO,CAAS;IACzB,yFAAyF;IACzF,yFAAyF;IACzF,iEAAiE;IACxD,OAAO,CAAqB;IACrC,SAAS,CAAqB;IAC9B,SAAS,CAAqB;IAE9B,YAAY,IAAY,EAAE,OAAe,EAAE,OAAgB;QACvD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAjBD,8BAiBC;AAED,MAAa,WAAW;IACX,IAAI,CAAW;IACf,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,aAAa,CAAS;IACtB,YAAY,CAAS;IACrB,eAAe,CAAS;IACxB,KAAK,CAAoB;IACzB,aAAa,CAAoB;IACjC,cAAc,CAAS;IACvB,cAAc,CAAiB;IACxC,OAAO,CAAc;IAErB,YACI,IAAc,EACd,SAAiB,EACjB,SAAiB,EACjB,QAAgB,EAChB,YAAoB,EACpB,aAAqB,EACrB,YAAoB,EACpB,eAAuB,EACvB,KAAwB,EACxB,aAAgC,EAChC,cAAsB,EACtB,cAA8B;QAE9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CA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UAAU,CAAC;QAC7B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACtB,CAAC;CACJ;AAvCD,kCAuCC;AAoCD,MAAa,SAAS;IACT,QAAQ,CAAS;IACjB,eAAe,CAAS;IACxB,OAAO,CAAU;IACjB,UAAU,CAAuB;IAE1C,YACI,QAAgB,EAChB,eAAuB,EACvB,OAAgB,EAChB,UAAgC;QAEhC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;CACJ;AAjBD,8BAiBC;AAED,MAAa,aAAa;IACb,MAAM,CAAS;IACxB;;;;;;;;OAQG;IACM,KAAK,CAAS;IAEvB,YAAY,MAAc,EAAE,QAAgB,4BAAa;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAjBD,sCAiBC","sourcesContent":["// ResolvedConfig / ResolvedRuleConfig / RuleOptions now live in @webpieces/rules-config\n// so ai-hooks and the Nx validate-code executor share one loader and one config file.\nimport { RuleOptions } from '@webpieces/rules-config';\nimport {\n HookMode,\n NormalizedBashInput,\n NormalizedEdit,\n NormalizedToolInput,\n ToolKind,\n} from '../protocol';\nimport { FixHint } from './fix-hint';\nimport { L0_FAULT_NONE } from '@webpieces/rules-config';\n\n// 'Read' is a first-class member because read-stale-guard is a file-scoped guard that runs on the\n// Read fast path. It is deliberately NOT in HANDLED_FILE_TOOLS (adapters/claude-code-adapter.ts), so\n// ClaudeCodeAdapter.kindOf() maps it to the 'Read' routing kind and Read never enters the edit/file\n// rule pipeline — only the one guard that asks for it. Nothing switches exhaustively on this union;\n// it is carried for logging.\n//\n// 'Delete' arrives ONLY from a Codex `apply_patch` carrying a `*** Delete File:` directive — no Claude\n// Code tool produces it. Every existing rule DEFAULTS TO NOT FIRING on it (see DeleteScopedRules in\n// ./delete-scoped-rules.ts): a rule written to judge the bytes an edit ADDS has nothing to say about a file going\n// away, and inventing a verdict for it would be guessing. Rules for which a delete IS meaningful — a\n// barrel export disappearing, a doc that documents a deleted file — opt in there, deliberately.\nexport type RuleScope = 'edit' | 'file' | 'bash';\n// Which category of built-in rules a hook invocation runs: code-style 'rules', git/PR/branch\n// 'guards' (the hookGuards section), or 'all' (both categories — used by the openclaw plugin adapter,\n// which is a single before_tool_call hook rather than two split PreToolUse hooks).\nexport type IsLineDisabled = (lineNum: number, ruleName: string) => boolean;\n\nexport class Violation {\n readonly line: number;\n readonly snippet: string;\n // Optional per-occurrence override for the `→` line. When omitted, the report falls back\n // to the rule's `FixHint.violation`. Dynamic rules (param name, line count, marker path,\n // branch/PR) pass a specific message here; static rules omit it.\n readonly message: string | undefined;\n editIndex: number | undefined;\n editCount: number | undefined;\n\n constructor(line: number, snippet: string, message?: string) {\n this.line = line;\n this.snippet = snippet;\n this.message = message;\n this.editIndex = undefined;\n this.editCount = undefined;\n }\n}\n\nexport class EditContext {\n readonly tool: ToolKind;\n readonly editIndex: number;\n readonly editCount: number;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n readonly addedContent: string;\n readonly strippedContent: string;\n readonly lines: readonly string[];\n readonly strippedLines: readonly string[];\n readonly removedContent: string;\n readonly isLineDisabled: IsLineDisabled;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n editIndex: number,\n editCount: number,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n addedContent: string,\n strippedContent: string,\n lines: readonly string[],\n strippedLines: readonly string[],\n removedContent: string,\n isLineDisabled: IsLineDisabled,\n ) {\n this.tool = tool;\n this.editIndex = editIndex;\n this.editCount = editCount;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.addedContent = addedContent;\n this.strippedContent = strippedContent;\n this.lines = lines;\n this.strippedLines = strippedLines;\n this.removedContent = removedContent;\n this.isLineDisabled = isLineDisabled;\n this.options = {};\n }\n}\n\n// A heredoc and its body: `<<EOF` / `<<'EOF'` / `<<-EOF` through the terminator line.\nconst HEREDOC_BODY = /<<-?\\s*(['\"]?)(\\w+)\\1[\\s\\S]*?^\\t*\\2\\s*$/gm;\n\n// A single- or double-quoted span.\nconst QUOTED_SPAN = /'([^']*)'|\"([^\"]*)\"/g;\n\n// Shell syntax that a quoted span is explicitly NOT: separators, pipes, subshells, redirection,\n// expansion. Content carrying any of these is data (a jq filter, a regex, a glob), and unquoting it\n// would hand the segment scanner syntax the shell never sees. See stripProse.\nconst SHELL_METACHARACTER = /[|;&()<>$`]/;\n\nexport class BashContext {\n readonly tool: 'Bash';\n readonly command: string;\n /**\n * `command` with heredoc bodies and prose-in-quotes removed — what a guard should MATCH on, while\n * `command` stays raw for the violation message (a human needs to see what they actually typed).\n *\n * A commit message that merely MENTIONS a blocked command is not that command. This repo's whole\n * subject matter is the git workflow, so its commit messages, docs and the guards' own fix-hint\n * text are full of `git push` / `gh pr …` strings; matching raw text blocks writing about the\n * tooling. A guard that cries wolf is a guard someone eventually turns OFF, which costs far more\n * than the theoretical bypass this opens (`sh -c '<blocked command>'` stops matching). That trade\n * is deliberate: these guards exist to catch a FORGETFUL agent, not an adversarial one.\n *\n * ONLY for blocklist-shaped guards (\"if the command matches X, block\"), where stripping can only\n * ever block LESS. Never use it in an allowlist-shaped guard such as merged-branch-bash-guard,\n * where stripping could turn a permitted recovery command into a blocked one and deadlock the\n * session — there, match on the raw `command`.\n */\n readonly commandCode: string;\n /**\n * The tree this command is JUDGED against — the root of the worktree it actually acts on, which\n * is NOT the shell's cwd whenever the command carries a leading `cd <path> &&` (see\n * EffectiveTreeResolver). Guards read git state, the main-sync cache and the decision log from\n * here, so a command aimed at a linked worktree is judged on that worktree's branch, never the\n * primary clone's.\n */\n readonly workspaceRoot: string;\n /** The directory the command really runs in (post-`cd`). Relative paths resolve against THIS. */\n readonly effectiveCwd: string;\n /** The root owning webpieces.config.json. Equals workspaceRoot except in a linked worktree. */\n readonly governedRoot: string;\n options: RuleOptions;\n\n constructor(\n command: string,\n workspaceRoot: string,\n effectiveCwd?: string,\n governedRoot?: string,\n ) {\n this.tool = 'Bash';\n this.command = command;\n this.commandCode = this.stripProse(command);\n this.workspaceRoot = workspaceRoot;\n this.effectiveCwd = effectiveCwd ?? workspaceRoot;\n this.governedRoot = governedRoot ?? workspaceRoot;\n this.options = {};\n }\n\n /**\n * A quoted span WITHOUT whitespace is kept: `git checkout \"main\"` is a real command with a quoted\n * argument, not prose. One containing whitespace is a sentence, and becomes a single space.\n *\n * ONE exception, and it is a false positive that actually fired: a whitespace-free span carrying\n * SHELL METACHARACTERS is dropped too. Keeping the content strips only the quotes, so a jq filter —\n * `--jq '[.[]|select(.title|test(\"x\"))]|length'` — was handed to the guards as bare shell syntax.\n * Every guard then split it on its `|`, `(` and `;` and saw a segment reading exactly `test`, which\n * whole-repo-build-guard classified as the workspace-wide test script and BLOCKED. There was no\n * build anywhere in that command; it polled npm and GitHub.\n *\n * Quoting is precisely how a shell says \"this is DATA, not syntax\", so honouring the quotes is the\n * correct reading. And because commandCode only ever feeds blocklist-shaped guards, dropping more\n * can only ever block LESS — never turn an allowed command into a refused one.\n */\n private stripProse(command: string): string {\n const withoutHeredocs = command.replace(HEREDOC_BODY, ' ');\n return withoutHeredocs.replace(\n QUOTED_SPAN,\n (match: string, single?: string, double?: string): string => {\n const content = single ?? double ?? '';\n if (/\\s/.test(content)) return ' ';\n return SHELL_METACHARACTER.test(content) ? ' ' : content;\n },\n );\n }\n}\n\nexport class FileContext {\n readonly tool: ToolKind;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n /** The git tree that owns filePath. workspaceRoot remains the root that owns policy/config. */\n readonly targetRoot: string;\n /** filePath relative to targetRoot, independent of its governed-root spelling. */\n readonly targetRelativePath: string;\n readonly currentFileLines: number;\n readonly linesAdded: number;\n readonly linesRemoved: number;\n readonly projectedFileLines: number;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n currentFileLines: number,\n linesAdded: number,\n linesRemoved: number,\n projectedFileLines: number,\n targetRoot: string = workspaceRoot,\n targetRelativePath: string = relativePath,\n ) {\n this.tool = tool;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.targetRoot = targetRoot;\n this.targetRelativePath = targetRelativePath;\n this.currentFileLines = currentFileLines;\n this.linesAdded = linesAdded;\n this.linesRemoved = linesRemoved;\n this.projectedFileLines = projectedFileLines;\n this.options = {};\n }\n}\n\n/**\n * The shape of a client hook policy returned by its declared runtime factory.\n * It carries only metadata + a `check` method — no on/off logic of its own.\n */\nexport interface PlainRule {\n readonly name: string;\n readonly description: string;\n readonly scope: RuleScope;\n readonly files: readonly string[];\n readonly defaultOptions: RuleOptions;\n readonly fixHint: FixHint;\n check(ctx: EditContext | FileContext | BashContext): readonly Violation[];\n}\n\n/**\n * The runtime contract the runner iterates. Both the built-in rule classes (which extend\n * EditRuleBase/FileRuleBase/BashRuleBase) and the custom-rule adapter satisfy this: they add\n * `shouldRun()` (mode + escape-hatch decision) on top of the PlainRule metadata.\n */\nexport interface Rule extends PlainRule {\n /**\n * The webpieces.config.json key whose entry configures this rule — NOT necessarily `name`.\n *\n * `name` is the operator identity (what a decision-log line and a deny report carry); `configKey`\n * is the switch. They differ wherever several classes implement one POLICY: all four branch-state\n * guards read `branch-state-guard`, all four PR-lifecycle guards read `pr-lifecycle-guard`. Every\n * consumer that asks \"which section does this live in?\" (filterByMode) or \"does this have an\n * entry?\" (the fault-Y config-sync check) must read THIS field, because asking for `name` there\n * demands entries under keys the validator rejects as retired.\n */\n readonly configKey: string;\n shouldRun(): boolean;\n}\n\nexport class RuleGroup {\n readonly ruleName: string;\n readonly ruleDescription: string;\n readonly fixHint: FixHint;\n readonly violations: readonly Violation[];\n\n constructor(\n ruleName: string,\n ruleDescription: string,\n fixHint: FixHint,\n violations: readonly Violation[],\n ) {\n this.ruleName = ruleName;\n this.ruleDescription = ruleDescription;\n this.fixHint = fixHint;\n this.violations = violations;\n }\n}\n\nexport class BlockedResult {\n readonly report: string;\n /**\n * The L0 fault this block IS, in the codebook's own letter (see core/l0-fault-codes.ts), or `-` for\n * an ordinary rule block.\n *\n * It rides on the result rather than being re-derived from the report text because the block is\n * decided deep in the runner (fault C in configMissingBlock, fault Y during owner-config validation) and\n * STAMPED by the adapter at the terminal boundary, several frames up. Scraping the report for a\n * fault would be a second answer to a question the producer already knows.\n */\n readonly fault: string;\n\n constructor(report: string, fault: string = L0_FAULT_NONE) {\n this.report = report;\n this.fault = fault;\n }\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/types.ts"],"names":[],"mappings":";;;AAWA,0DAAwD;AAmBxD,MAAa,SAAS;IACT,IAAI,CAAS;IACb,OAAO,CAAS;IACzB,yFAAyF;IACzF,yFAAyF;IACzF,iEAAiE;IACxD,OAAO,CAAqB;IACrC,SAAS,CAAqB;IAC9B,SAAS,CAAqB;IAE9B,YAAY,IAAY,EAAE,OAAe,EAAE,OAAgB;QACvD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAjBD,8BAi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M,KAAK,CAAS;IAEvB,YAAY,MAAc,EAAE,QAAgB,4BAAa;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAjBD,sCAiBC","sourcesContent":["// ResolvedConfig / ResolvedRuleConfig / RuleOptions now live in @webpieces/rules-config\n// so ai-hooks and the Nx validate-code executor share one loader and one config file.\nimport { RuleOptions } from '@webpieces/rules-config';\nimport {\n HookMode,\n NormalizedBashInput,\n NormalizedEdit,\n NormalizedToolInput,\n ToolKind,\n} from '../protocol';\nimport { FixHint } from './fix-hint';\nimport { L0_FAULT_NONE } from '@webpieces/rules-config';\n\n// 'Read' is a first-class member because read-stale-guard is a file-scoped guard that runs on the\n// Read fast path. It is deliberately NOT in HANDLED_FILE_TOOLS (adapters/claude-code-adapter.ts), so\n// ClaudeCodeAdapter.kindOf() maps it to the 'Read' routing kind and Read never enters the edit/file\n// rule pipeline — only the one guard that asks for it. Nothing switches exhaustively on this union;\n// it is carried for logging.\n//\n// 'Delete' arrives ONLY from a Codex `apply_patch` carrying a `*** Delete File:` directive — no Claude\n// Code tool produces it. Every existing rule DEFAULTS TO NOT FIRING on it (see DeleteScopedRules in\n// ./delete-scoped-rules.ts): a rule written to judge the bytes an edit ADDS has nothing to say about a file going\n// away, and inventing a verdict for it would be guessing. Rules for which a delete IS meaningful — a\n// barrel export disappearing, a doc that documents a deleted file — opt in there, deliberately.\nexport type RuleScope = 'edit' | 'file' | 'bash';\n// Which category of built-in rules a hook invocation runs: code-style 'rules', git/PR/branch\n// 'guards' (the hookGuards section), or 'all' (both categories — used by the openclaw plugin adapter,\n// which is a single before_tool_call hook rather than two split PreToolUse hooks).\nexport type IsLineDisabled = (lineNum: number, ruleName: string) => boolean;\n\nexport class Violation {\n readonly line: number;\n readonly snippet: string;\n // Optional per-occurrence override for the `→` line. When omitted, the report falls back\n // to the rule's `FixHint.violation`. Dynamic rules (param name, line count, marker path,\n // branch/PR) pass a specific message here; static rules omit it.\n readonly message: string | undefined;\n editIndex: number | undefined;\n editCount: number | undefined;\n\n constructor(line: number, snippet: string, message?: string) {\n this.line = line;\n this.snippet = snippet;\n this.message = message;\n this.editIndex = undefined;\n this.editCount = undefined;\n }\n}\n\nexport class EditContext {\n readonly tool: ToolKind;\n readonly editIndex: number;\n readonly editCount: number;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n readonly addedContent: string;\n readonly strippedContent: string;\n readonly lines: readonly string[];\n readonly strippedLines: readonly string[];\n readonly removedContent: string;\n readonly isLineDisabled: IsLineDisabled;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n editIndex: number,\n editCount: number,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n addedContent: string,\n strippedContent: string,\n lines: readonly string[],\n strippedLines: readonly string[],\n removedContent: string,\n isLineDisabled: IsLineDisabled,\n ) {\n this.tool = tool;\n this.editIndex = editIndex;\n this.editCount = editCount;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.addedContent = addedContent;\n this.strippedContent = strippedContent;\n this.lines = lines;\n this.strippedLines = strippedLines;\n this.removedContent = removedContent;\n this.isLineDisabled = isLineDisabled;\n this.options = {};\n }\n}\n\n// A heredoc and its body: `<<EOF` / `<<'EOF'` / `<<-EOF` through the terminator line.\nconst HEREDOC_BODY = /<<-?\\s*(['\"]?)(\\w+)\\1[\\s\\S]*?^\\t*\\2\\s*$/gm;\n\n// A single- or double-quoted span.\nconst QUOTED_SPAN = /'([^']*)'|\"([^\"]*)\"/g;\n\n// Shell syntax that a quoted span is explicitly NOT: separators, pipes, subshells, redirection,\n// expansion. Content carrying any of these is data (a jq filter, a regex, a glob), and unquoting it\n// would hand the segment scanner syntax the shell never sees. See stripProse.\nconst SHELL_METACHARACTER = /[|;&()<>$`]/;\n\nexport class BashContext {\n readonly tool: 'Bash';\n readonly command: string;\n /**\n * `command` with heredoc bodies and prose-in-quotes removed — what a guard should MATCH on, while\n * `command` stays raw for the violation message (a human needs to see what they actually typed).\n *\n * A commit message that merely MENTIONS a blocked command is not that command. This repo's whole\n * subject matter is the git workflow, so its commit messages, docs and the guards' own fix-hint\n * text are full of `git push` / `gh pr …` strings; matching raw text blocks writing about the\n * tooling. A guard that cries wolf is a guard someone eventually turns OFF, which costs far more\n * than the theoretical bypass this opens (`sh -c '<blocked command>'` stops matching). That trade\n * is deliberate: these guards exist to catch a FORGETFUL agent, not an adversarial one.\n *\n * ONLY for blocklist-shaped guards (\"if the command matches X, block\"), where stripping can only\n * ever block LESS. Never use it in an allowlist-shaped guard such as merged-branch-bash-guard,\n * where stripping could turn a permitted recovery command into a blocked one and deadlock the\n * session — there, match on the raw `command`.\n */\n readonly commandCode: string;\n /**\n * The tree this command is JUDGED against — the root of the worktree it actually acts on, which\n * is NOT the shell's cwd whenever the command carries a leading `cd <path> &&` (see\n * EffectiveTreeResolver). Guards read git state, the main-sync cache and the decision log from\n * here, so a command aimed at a linked worktree is judged on that worktree's branch, never the\n * primary clone's.\n */\n readonly workspaceRoot: string;\n /** The directory the command really runs in (post-`cd`). Relative paths resolve against THIS. */\n readonly effectiveCwd: string;\n /** The root owning webpieces.config.json. Equals workspaceRoot except in a linked worktree. */\n readonly governedRoot: string;\n options: RuleOptions;\n\n constructor(\n command: string,\n workspaceRoot: string,\n effectiveCwd?: string,\n governedRoot?: string,\n ) {\n this.tool = 'Bash';\n this.command = command;\n this.commandCode = this.stripProse(command);\n this.workspaceRoot = workspaceRoot;\n this.effectiveCwd = effectiveCwd ?? workspaceRoot;\n this.governedRoot = governedRoot ?? workspaceRoot;\n this.options = {};\n }\n\n /**\n * A quoted span WITHOUT whitespace is kept: `git checkout \"main\"` is a real command with a quoted\n * argument, not prose. One containing whitespace is a sentence, and becomes a single space.\n *\n * ONE exception, and it is a false positive that actually fired: a whitespace-free span carrying\n * SHELL METACHARACTERS is dropped too. Keeping the content strips only the quotes, so a jq filter —\n * `--jq '[.[]|select(.title|test(\"x\"))]|length'` — was handed to the guards as bare shell syntax.\n * Every guard then split it on its `|`, `(` and `;` and saw a segment reading exactly `test`, which\n * whole-repo-build-guard classified as the workspace-wide test script and BLOCKED. There was no\n * build anywhere in that command; it polled npm and GitHub.\n *\n * Quoting is precisely how a shell says \"this is DATA, not syntax\", so honouring the quotes is the\n * correct reading. And because commandCode only ever feeds blocklist-shaped guards, dropping more\n * can only ever block LESS — never turn an allowed command into a refused one.\n */\n private stripProse(command: string): string {\n const withoutHeredocs = command.replace(HEREDOC_BODY, ' ');\n return withoutHeredocs.replace(\n QUOTED_SPAN,\n (match: string, single?: string, double?: string): string => {\n const content = single ?? double ?? '';\n if (/\\s/.test(content)) return ' ';\n return SHELL_METACHARACTER.test(content) ? ' ' : content;\n },\n );\n }\n}\n\nexport class FileContext {\n readonly tool: ToolKind;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n /** The git tree that owns filePath. workspaceRoot remains the root that owns policy/config. */\n readonly targetRoot: string;\n /** filePath relative to targetRoot, independent of its governed-root spelling. */\n readonly targetRelativePath: string;\n readonly currentFileLines: number;\n readonly linesAdded: number;\n readonly linesRemoved: number;\n readonly projectedFileLines: number;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n currentFileLines: number,\n linesAdded: number,\n linesRemoved: number,\n projectedFileLines: number,\n targetRoot: string = workspaceRoot,\n targetRelativePath: string = relativePath,\n ) {\n this.tool = tool;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.targetRoot = targetRoot;\n this.targetRelativePath = targetRelativePath;\n this.currentFileLines = currentFileLines;\n this.linesAdded = linesAdded;\n this.linesRemoved = linesRemoved;\n this.projectedFileLines = projectedFileLines;\n this.options = {};\n }\n}\n\n/**\n * The shape of a client hook policy returned by its declared runtime factory.\n * It carries only metadata + a `check` method — no on/off logic of its own.\n */\nexport interface PlainRule {\n readonly name: string;\n readonly description: string;\n readonly scope: RuleScope;\n readonly files: readonly string[];\n readonly defaultOptions: RuleOptions;\n readonly fixHint: FixHint;\n check(ctx: EditContext | FileContext | BashContext): readonly Violation[];\n}\n\n/**\n * The runtime contract the runner iterates. Both the built-in rule classes (which extend\n * EditRuleBase/FileRuleBase/BashRuleBase) and the custom-rule adapter satisfy this: they add\n * `shouldRun()` (mode + escape-hatch decision) on top of the PlainRule metadata.\n */\nexport interface Rule extends PlainRule {\n /**\n * The webpieces.config.json key whose entry configures this rule — NOT necessarily `name`.\n *\n * `name` is the operator identity (what a decision-log line and a deny report carry); `configKey`\n * is the switch. They differ wherever several classes implement one POLICY: all four branch-state\n * guards read `branch-state-guard`, all four PR-lifecycle guards read `pr-lifecycle-guard`. Every\n * consumer that asks \"which section does this live in?\" (filterByMode) or \"does this have an\n * entry?\" (the fault-Y config-sync check) must read THIS field, because asking for `name` there\n * demands entries under keys the validator rejects as retired.\n */\n readonly configKey: string;\n shouldRun(): boolean;\n /**\n * True when this rule's own `excludePaths` matches the workspace-relative path (#1253). The engine\n * asks it before dispatching the rule on a path, exactly as it asks shouldRun() — no rule filters\n * its own paths. AbstractRule supplies it.\n */\n excludesPath(relativePath: string): boolean;\n}\n\nexport class RuleGroup {\n readonly ruleName: string;\n readonly ruleDescription: string;\n readonly fixHint: FixHint;\n readonly violations: readonly Violation[];\n\n constructor(\n ruleName: string,\n ruleDescription: string,\n fixHint: FixHint,\n violations: readonly Violation[],\n ) {\n this.ruleName = ruleName;\n this.ruleDescription = ruleDescription;\n this.fixHint = fixHint;\n this.violations = violations;\n }\n}\n\nexport class BlockedResult {\n readonly report: string;\n /**\n * The L0 fault this block IS, in the codebook's own letter (see core/l0-fault-codes.ts), or `-` for\n * an ordinary rule block.\n *\n * It rides on the result rather than being re-derived from the report text because the block is\n * decided deep in the runner (fault C in configMissingBlock, fault Y during owner-config validation) and\n * STAMPED by the adapter at the terminal boundary, several frames up. Scraping the report for a\n * fault would be a second answer to a question the producer already knows.\n */\n readonly fault: string;\n\n constructor(report: string, fault: string = L0_FAULT_NONE) {\n this.report = report;\n this.fault = fault;\n }\n}\n"]}
package/src/index.d.ts CHANGED
@@ -19,7 +19,6 @@ export * from './core/excluded-paths';
19
19
  export * from './core/delete-scoped-rules';
20
20
  export * from './core/apply-patch-parse';
21
21
  export * from './core/shell-read-parity';
22
- export * from './core/glob';
23
22
  export * from './adapters/agent-payload';
24
23
  export * from './adapters/detect-ai';
25
24
  export * from './adapters/agent-adapters';
package/src/index.js CHANGED
@@ -46,7 +46,6 @@ tslib_1.__exportStar(require("./core/excluded-paths"), exports);
46
46
  tslib_1.__exportStar(require("./core/delete-scoped-rules"), exports);
47
47
  tslib_1.__exportStar(require("./core/apply-patch-parse"), exports);
48
48
  tslib_1.__exportStar(require("./core/shell-read-parity"), exports);
49
- tslib_1.__exportStar(require("./core/glob"), exports);
50
49
  tslib_1.__exportStar(require("./adapters/agent-payload"), exports);
51
50
  tslib_1.__exportStar(require("./adapters/detect-ai"), exports);
52
51
  tslib_1.__exportStar(require("./adapters/agent-adapters"), exports);
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/index.ts"],"names":[],"mappings":";;;;AAAA,uCAYoB;AAVhB,oGAAA,QAAQ,OAAA;AACR,2GAAA,eAAe,OAAA;AAIf,0GAAA,cAAc,OAAA;AACd,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,yGAAA,aAAa,OAAA;AACb,0GAAA,cAAc,OAAA;AAElB,qCAAkE;AAAzD,sGAAA,WAAW,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC9C,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAAgF;AAAvE,6GAAA,eAAe,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,6GAAA,eAAe,OAAA;AACzD,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,uCAAsD;AAA7C,mGAAA,OAAO,OAAA;AAAE,2GAAA,eAAe,OAAA;AAEjC,sCAWsB;AARlB,kGAAA,SAAS,OAAA;AACT,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AAGX,kGAAA,SAAS,OAAA;AACT,sGAAA,aAAa,OAAA;AAEjB,0DAAgC;AAChC,2DAAiC;AACjC,qEAA2C;AAC3C,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,wDAA8B;AAC9B,gEAAsC;AACtC,8DAAoC;AACpC,6DAAmC;AACnC,gEAAsC;AACtC,qEAA2C;AAC3C,mEAAyC;AACzC,mEAAyC;AACzC,sDAA4B;AAC5B,mEAAyC;AACzC,+DAAqC;AACrC,oEAA0C;AAC1C,yEAA+C;AAC/C,mEAAyC;AACzC,+DAAqC;AACrC,iEAAuC;AACvC,0EAAgD;AAChD,iEAAuC;AAEvC,mDAA4D;AAAnD,0HAAA,wBAAwB,OAAA;AAEjC,+DAAiE;AAAxD,+HAAA,uBAAuB,OAAA","sourcesContent":["export {\n AiType,\n AI_TYPES,\n AI_TYPE_UNKNOWN,\n HookMode,\n ToolKind,\n AgentEventKind,\n NormalizedEdit,\n NormalizedToolInput,\n NormalizedBashInput,\n FileOperation,\n AgentHookEvent,\n} from './protocol';\nexport { HookOutcome, HookArgs, HookTerminated } from './outcome';\nexport { denyJson } from './response';\nexport { HookStdinSource, HookStdoutSink, HookProcessExit } from './hook-ports';\nexport { HookEvaluator } from './hook-evaluator';\nexport { HookApp, HookBootFailure } from './hook-app';\n\nexport {\n RuleScope,\n IsLineDisabled,\n Violation,\n EditContext,\n FileContext,\n BashContext,\n Rule,\n PlainRule,\n RuleGroup,\n BlockedResult,\n} from './core/types';\nexport * from './core/fix-hint';\nexport * from './core/rule-base';\nexport * from './core/custom-rule-adapter';\nexport * from './core/strip-ts-noise';\nexport * from './core/disable-directives';\nexport * from './core/build-context';\nexport * from './core/report';\nexport * from './core/effective-tree';\nexport * from './core/command-scan';\nexport * from './core/target-tree';\nexport * from './core/excluded-paths';\nexport * from './core/delete-scoped-rules';\nexport * from './core/apply-patch-parse';\nexport * from './core/shell-read-parity';\nexport * from './core/glob';\nexport * from './adapters/agent-payload';\nexport * from './adapters/detect-ai';\nexport * from './adapters/agent-adapters';\nexport * from './adapters/claude-code-adapter';\nexport * from './adapters/codex-adapter';\nexport * from './core/root-manifest';\nexport * from './core/rule-evaluation';\nexport * from './core/rules/shell-segment-scan';\nexport * from './core/file-evaluation';\n\nexport { HookPolicyRuntimeRequest } from './policy-runtime';\nexport type { HookRuleRuntime } from './policy-runtime';\nexport { HookPolicyContributions } from './policy-contributions';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/index.ts"],"names":[],"mappings":";;;;AAAA,uCAYoB;AAVhB,oGAAA,QAAQ,OAAA;AACR,2GAAA,eAAe,OAAA;AAIf,0GAAA,cAAc,OAAA;AACd,+GAAA,mBAAmB,OAAA;AACnB,+GAAA,mBAAmB,OAAA;AACnB,yGAAA,aAAa,OAAA;AACb,0GAAA,cAAc,OAAA;AAElB,qCAAkE;AAAzD,sGAAA,WAAW,OAAA;AAAE,mGAAA,QAAQ,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC9C,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,2CAAgF;AAAvE,6GAAA,eAAe,OAAA;AAAE,4GAAA,cAAc,OAAA;AAAE,6GAAA,eAAe,OAAA;AACzD,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,uCAAsD;AAA7C,mGAAA,OAAO,OAAA;AAAE,2GAAA,eAAe,OAAA;AAEjC,sCAWsB;AARlB,kGAAA,SAAS,OAAA;AACT,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AAGX,kGAAA,SAAS,OAAA;AACT,sGAAA,aAAa,OAAA;AAEjB,0DAAgC;AAChC,2DAAiC;AACjC,qEAA2C;AAC3C,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,wDAA8B;AAC9B,gEAAsC;AACtC,8DAAoC;AACpC,6DAAmC;AACnC,gEAAsC;AACtC,qEAA2C;AAC3C,mEAAyC;AACzC,mEAAyC;AACzC,mEAAyC;AACzC,+DAAqC;AACrC,oEAA0C;AAC1C,yEAA+C;AAC/C,mEAAyC;AACzC,+DAAqC;AACrC,iEAAuC;AACvC,0EAAgD;AAChD,iEAAuC;AAEvC,mDAA4D;AAAnD,0HAAA,wBAAwB,OAAA;AAEjC,+DAAiE;AAAxD,+HAAA,uBAAuB,OAAA","sourcesContent":["export {\n AiType,\n AI_TYPES,\n AI_TYPE_UNKNOWN,\n HookMode,\n ToolKind,\n AgentEventKind,\n NormalizedEdit,\n NormalizedToolInput,\n NormalizedBashInput,\n FileOperation,\n AgentHookEvent,\n} from './protocol';\nexport { HookOutcome, HookArgs, HookTerminated } from './outcome';\nexport { denyJson } from './response';\nexport { HookStdinSource, HookStdoutSink, HookProcessExit } from './hook-ports';\nexport { HookEvaluator } from './hook-evaluator';\nexport { HookApp, HookBootFailure } from './hook-app';\n\nexport {\n RuleScope,\n IsLineDisabled,\n Violation,\n EditContext,\n FileContext,\n BashContext,\n Rule,\n PlainRule,\n RuleGroup,\n BlockedResult,\n} from './core/types';\nexport * from './core/fix-hint';\nexport * from './core/rule-base';\nexport * from './core/custom-rule-adapter';\nexport * from './core/strip-ts-noise';\nexport * from './core/disable-directives';\nexport * from './core/build-context';\nexport * from './core/report';\nexport * from './core/effective-tree';\nexport * from './core/command-scan';\nexport * from './core/target-tree';\nexport * from './core/excluded-paths';\nexport * from './core/delete-scoped-rules';\nexport * from './core/apply-patch-parse';\nexport * from './core/shell-read-parity';\nexport * from './adapters/agent-payload';\nexport * from './adapters/detect-ai';\nexport * from './adapters/agent-adapters';\nexport * from './adapters/claude-code-adapter';\nexport * from './adapters/codex-adapter';\nexport * from './core/root-manifest';\nexport * from './core/rule-evaluation';\nexport * from './core/rules/shell-segment-scan';\nexport * from './core/file-evaluation';\n\nexport { HookPolicyRuntimeRequest } from './policy-runtime';\nexport type { HookRuleRuntime } from './policy-runtime';\nexport { HookPolicyContributions } from './policy-contributions';\n"]}
@@ -46,7 +46,7 @@ class HookPolicyContributions {
46
46
  for (const group of modules.groups(loaded.ruleRegistry, kind)) {
47
47
  const runtime = this.composed.get(group.implementationModule) ??
48
48
  this.runtime(modules.load(group, loaded.ruleRegistry.manifestModules, loader), group);
49
- const request = modules.request(root, loaded.rulesConfig, group);
49
+ const request = modules.request(root, loaded.rulesConfig, group, loaded.excludePaths.paths);
50
50
  const rules = runtime.create(new policy_runtime_1.HookPolicyRuntimeRequest(request, loaded.commands));
51
51
  this.validate(rules, group);
52
52
  for (const rule of rules) {
@@ -86,7 +86,8 @@ class HookPolicyContributions {
86
86
  !rule.defaultOptions ||
87
87
  !rule.fixHint ||
88
88
  typeof rule.check !== 'function' ||
89
- typeof rule.shouldRun !== 'function') {
89
+ typeof rule.shouldRun !== 'function' ||
90
+ typeof rule.excludesPath !== 'function') {
90
91
  throw new tooling_common_1.InformAiError(`Invalid hook policy returned by ${group.implementationModule}. Supply the declared configKey and complete hook contract.`);
91
92
  }
92
93
  covered.add(rule.configKey);
@@ -1 +1 @@
1
- {"version":3,"file":"policy-contributions.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/policy-contributions.ts"],"names":[],"mappings":";;;;AAAA,wDAAkC;AAElC,0DAOiC;AACjC,8DAA0D;AAC1D,qDAA6E;AAE7E,8CAA0C;AAE1C,uGAAuG;AACvG,MAAM,oBAAqB,SAAQ,2BAA4B;IAStC;IARZ,WAAW,CAAS;IACpB,KAAK,CAAgB;IACrB,KAAK,CAAoB;IACzB,cAAc,CAAyB;IACvC,OAAO,CAAU;IAE1B,YACI,MAAsB,EACL,cAAoB,EACrC,UAAkB;QAElB,KAAK,CAAC,MAA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C,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;gBAC3D,CAAC,IAAI,CAAC,cAAc;gBACpB,CAAC,IAAI,CAAC,OAAO;gBACb,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU;gBAChC,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU,EACtC,CAAC;gBACC,MAAM,IAAI,8BAAa,CACnB,mCAAmC,KAAK,CAAC,oBAAoB,6DAA6D,CAC7H,CAAC;YACN,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,8BAAa,CACnB,GAAG,KAAK,CAAC,oBAAoB,iCAAiC,EAAE,qCAAqC,CACxG,CAAC;QACV,CAAC;IACL,CAAC;CACJ;AA9FD,0DA8FC","sourcesContent":["import * as path from 'node:path';\nimport { BaseRuleConfig, ConfigObject, ExecutionKind } from '@webpieces/rules-sdk';\nimport {\n AbstractRule,\n LoadedConfig,\n Option,\n NodeRuleRuntimeModuleLoader,\n RuleRuntimeModules,\n RuntimeContributionGroup,\n} from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { HookRuleRuntime, HookPolicyRuntimeRequest } from './policy-runtime';\nimport { Rule, EditContext, FileContext, BashContext, Violation } from './core/types';\nimport { FixHint } from './core/fix-hint';\n\n/** The framework enforces explicit OFF and escape hatches even for client-authored implementations. */\nclass ConfiguredHookPolicy extends AbstractRule<BaseRuleConfig> implements Rule {\n readonly description: string;\n readonly scope: Rule['scope'];\n readonly files: readonly string[];\n readonly defaultOptions: Rule['defaultOptions'];\n readonly fixHint: FixHint;\n\n constructor(\n config: BaseRuleConfig,\n private readonly implementation: Rule,\n configFile: string,\n ) {\n super(config, implementation.name, implementation.configKey);\n this.description = implementation.description;\n this.scope = implementation.scope;\n this.files = implementation.files;\n this.defaultOptions = implementation.defaultOptions;\n const hint = implementation.fixHint;\n this.fixHint = new FixHint(\n hint.violation.replaceAll('{configFile}', configFile),\n hint.mainMessage.replaceAll('{configFile}', configFile),\n hint.fixOptions.map(\n (option: Option) =>\n new Option(\n option.text.replaceAll('{configFile}', configFile),\n option.preferred,\n ),\n ),\n hint.escape,\n );\n }\n\n override shouldRun(): boolean {\n return super.shouldRun() && this.implementation.shouldRun();\n }\n check(context: EditContext | FileContext | BashContext): readonly Violation[] {\n return this.implementation.check(context);\n }\n}\n\n/** Composition may supply its own public runtime directly; all other declared modules use Node transport. */\nexport class HookPolicyContributions {\n constructor(private readonly composed: ReadonlyMap<string, HookRuleRuntime>) {}\n\n load(\n loaded: LoadedConfig,\n kind: Extract<ExecutionKind, 'source-hook' | 'workflow-guard'>,\n ): readonly Rule[] {\n if (loaded.configPath === null) return [];\n const root = path.dirname(loaded.configPath),\n modules = new RuleRuntimeModules();\n const loader = new NodeRuleRuntimeModuleLoader(root),\n result: Rule[] = [];\n for (const group of modules.groups(loaded.ruleRegistry, kind)) {\n const runtime =\n this.composed.get(group.implementationModule) ??\n this.runtime(\n modules.load(group, loaded.ruleRegistry.manifestModules, loader),\n group,\n );\n const request = modules.request(\n root,\n loaded.rulesConfig as Record<string, ConfigObject>,\n group,\n );\n const rules = runtime.create(new HookPolicyRuntimeRequest(request, loaded.commands));\n this.validate(rules, group);\n for (const rule of rules) {\n const filename = loaded.policyFiles?.targetFiles.get(rule.configKey);\n if (!filename)\n throw new InformAiError(\n `Missing declared owner config path for ${rule.configKey}. Repair the root declaration.`,\n );\n result.push(\n new ConfiguredHookPolicy(\n request.configs[rule.configKey] as BaseRuleConfig,\n rule,\n filename,\n ),\n );\n }\n }\n return result;\n }\n\n // webpieces-disable no-any-unknown -- the selected execution-family module is validated before invocation\n private runtime(exports: unknown, group: RuntimeContributionGroup): HookRuleRuntime {\n const name =\n group.executionKind === 'source-hook' ? 'sourceRuleRuntime' : 'workflowRuleRuntime';\n if (!exports || typeof exports !== 'object' || !(name in exports)) {\n throw new InformAiError(\n `${group.implementationModule} must export ${name}.create(request). Repair the declared public runtime module.`,\n );\n }\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n const runtime = (exports as Record<string, unknown>)[name] as HookRuleRuntime;\n if (!runtime || typeof runtime.create !== 'function')\n throw new InformAiError(`Invalid ${name}.create in ${group.implementationModule}.`);\n return runtime;\n }\n\n private validate(rules: readonly Rule[], group: RuntimeContributionGroup): void {\n if (!Array.isArray(rules))\n throw new InformAiError(\n `${group.implementationModule} must return an array of configured hook policies.`,\n );\n const covered = new Set<string>();\n for (const rule of rules) {\n if (\n !rule ||\n !group.ruleIds.includes(rule.configKey) ||\n typeof rule.name !== 'string' ||\n !rule.name ||\n typeof rule.description !== 'string' ||\n !['edit', 'file', 'bash'].includes(rule.scope) ||\n !Array.isArray(rule.files) ||\n rule.files.some((file: string) => typeof file !== 'string') ||\n !rule.defaultOptions ||\n !rule.fixHint ||\n typeof rule.check !== 'function' ||\n typeof rule.shouldRun !== 'function'\n ) {\n throw new InformAiError(\n `Invalid hook policy returned by ${group.implementationModule}. Supply the declared configKey and complete hook contract.`,\n );\n }\n covered.add(rule.configKey);\n }\n for (const id of group.ruleIds) {\n if (!covered.has(id))\n throw new InformAiError(\n `${group.implementationModule} omitted declared hook policy ${id}. Supply its actual implementation.`,\n );\n }\n }\n}\n"]}
1
+ {"version":3,"file":"policy-contributions.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/policy-contributions.ts"],"names":[],"mappings":";;;;AAAA,wDAAkC;AAElC,0DAOiC;AACjC,8DAA0D;AAC1D,qDAA6E;AAE7E,8CAA0C;AAE1C,uGAAuG;AACvG,MAAM,oBAAqB,S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OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ;gBAC7B,CAAC,IAAI,CAAC,IAAI;gBACV,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ;gBACpC,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC9C,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;gBAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC;gBAC3D,CAAC,IAAI,CAAC,cAAc;gBACpB,CAAC,IAAI,CAAC,OAAO;gBACb,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU;gBAChC,OAAO,IAAI,CAAC,SAAS,KAAK,UAAU;gBACpC,OAAO,IAAI,CAAC,YAAY,KAAK,UAAU,EACzC,CAAC;gBACC,MAAM,IAAI,8BAAa,CACnB,mCAAmC,KAAK,CAAC,oBAAoB,6DAA6D,CAC7H,CAAC;YACN,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,8BAAa,CACnB,GAAG,KAAK,CAAC,oBAAoB,iCAAiC,EAAE,qCAAqC,CACxG,CAAC;QACV,CAAC;IACL,CAAC;CACJ;AAhGD,0DAgGC","sourcesContent":["import * as path from 'node:path';\nimport { BaseRuleConfig, ConfigObject, ExecutionKind } from '@webpieces/rules-sdk';\nimport {\n AbstractRule,\n LoadedConfig,\n Option,\n NodeRuleRuntimeModuleLoader,\n RuleRuntimeModules,\n RuntimeContributionGroup,\n} from '@webpieces/rules-config';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { HookRuleRuntime, HookPolicyRuntimeRequest } from './policy-runtime';\nimport { Rule, EditContext, FileContext, BashContext, Violation } from './core/types';\nimport { FixHint } from './core/fix-hint';\n\n/** The framework enforces explicit OFF and escape hatches even for client-authored implementations. */\nclass ConfiguredHookPolicy extends AbstractRule<BaseRuleConfig> implements Rule {\n readonly description: string;\n readonly scope: Rule['scope'];\n readonly files: readonly string[];\n readonly defaultOptions: Rule['defaultOptions'];\n readonly fixHint: FixHint;\n\n constructor(\n config: BaseRuleConfig,\n private readonly implementation: Rule,\n configFile: string,\n ) {\n super(config, implementation.name, implementation.configKey);\n this.description = implementation.description;\n this.scope = implementation.scope;\n this.files = implementation.files;\n this.defaultOptions = implementation.defaultOptions;\n const hint = implementation.fixHint;\n this.fixHint = new FixHint(\n hint.violation.replaceAll('{configFile}', configFile),\n hint.mainMessage.replaceAll('{configFile}', configFile),\n hint.fixOptions.map(\n (option: Option) =>\n new Option(\n option.text.replaceAll('{configFile}', configFile),\n option.preferred,\n ),\n ),\n hint.escape,\n );\n }\n\n override shouldRun(): boolean {\n return super.shouldRun() && this.implementation.shouldRun();\n }\n check(context: EditContext | FileContext | BashContext): readonly Violation[] {\n return this.implementation.check(context);\n }\n}\n\n/** Composition may supply its own public runtime directly; all other declared modules use Node transport. */\nexport class HookPolicyContributions {\n constructor(private readonly composed: ReadonlyMap<string, HookRuleRuntime>) {}\n\n load(\n loaded: LoadedConfig,\n kind: Extract<ExecutionKind, 'source-hook' | 'workflow-guard'>,\n ): readonly Rule[] {\n if (loaded.configPath === null) return [];\n const root = path.dirname(loaded.configPath),\n modules = new RuleRuntimeModules();\n const loader = new NodeRuleRuntimeModuleLoader(root),\n result: Rule[] = [];\n for (const group of modules.groups(loaded.ruleRegistry, kind)) {\n const runtime =\n this.composed.get(group.implementationModule) ??\n this.runtime(\n modules.load(group, loaded.ruleRegistry.manifestModules, loader),\n group,\n );\n const request = modules.request(\n root,\n loaded.rulesConfig as Record<string, ConfigObject>,\n group,\n loaded.excludePaths.paths,\n );\n const rules = runtime.create(new HookPolicyRuntimeRequest(request, loaded.commands));\n this.validate(rules, group);\n for (const rule of rules) {\n const filename = loaded.policyFiles?.targetFiles.get(rule.configKey);\n if (!filename)\n throw new InformAiError(\n `Missing declared owner config path for ${rule.configKey}. Repair the root declaration.`,\n );\n result.push(\n new ConfiguredHookPolicy(\n request.configs[rule.configKey] as BaseRuleConfig,\n rule,\n filename,\n ),\n );\n }\n }\n return result;\n }\n\n // webpieces-disable no-any-unknown -- the selected execution-family module is validated before invocation\n private runtime(exports: unknown, group: RuntimeContributionGroup): HookRuleRuntime {\n const name =\n group.executionKind === 'source-hook' ? 'sourceRuleRuntime' : 'workflowRuleRuntime';\n if (!exports || typeof exports !== 'object' || !(name in exports)) {\n throw new InformAiError(\n `${group.implementationModule} must export ${name}.create(request). Repair the declared public runtime module.`,\n );\n }\n // webpieces-disable no-any-unknown -- external JSON or runtime exports are validated before policy execution\n const runtime = (exports as Record<string, unknown>)[name] as HookRuleRuntime;\n if (!runtime || typeof runtime.create !== 'function')\n throw new InformAiError(`Invalid ${name}.create in ${group.implementationModule}.`);\n return runtime;\n }\n\n private validate(rules: readonly Rule[], group: RuntimeContributionGroup): void {\n if (!Array.isArray(rules))\n throw new InformAiError(\n `${group.implementationModule} must return an array of configured hook policies.`,\n );\n const covered = new Set<string>();\n for (const rule of rules) {\n if (\n !rule ||\n !group.ruleIds.includes(rule.configKey) ||\n typeof rule.name !== 'string' ||\n !rule.name ||\n typeof rule.description !== 'string' ||\n !['edit', 'file', 'bash'].includes(rule.scope) ||\n !Array.isArray(rule.files) ||\n rule.files.some((file: string) => typeof file !== 'string') ||\n !rule.defaultOptions ||\n !rule.fixHint ||\n typeof rule.check !== 'function' ||\n typeof rule.shouldRun !== 'function' ||\n typeof rule.excludesPath !== 'function'\n ) {\n throw new InformAiError(\n `Invalid hook policy returned by ${group.implementationModule}. Supply the declared configKey and complete hook contract.`,\n );\n }\n covered.add(rule.configKey);\n }\n for (const id of group.ruleIds) {\n if (!covered.has(id))\n throw new InformAiError(\n `${group.implementationModule} omitted declared hook policy ${id}. Supply its actual implementation.`,\n );\n }\n }\n}\n"]}
@@ -6,7 +6,7 @@ const rules_sdk_1 = require("@webpieces/rules-sdk");
6
6
  class HookPolicyRuntimeRequest extends rules_sdk_1.PolicyRuntimeRequest {
7
7
  commands;
8
8
  constructor(request, commands) {
9
- super(request.workspaceRoot, request.configs, request.ruleIds);
9
+ super(request.workspaceRoot, request.configs, request.ruleIds, request.excludePaths);
10
10
  this.commands = commands;
11
11
  }
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"policy-runtime.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/policy-runtime.ts"],"names":[],"mappings":";;;AAAA,oDAA4D;AAI5D,wGAAwG;AACxG,MAAa,wBAAyB,SAAQ,gCAAoB;IAGjD;IAFb,YACI,OAA6B,EACpB,QAAwB;QAEjC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAFtD,aAAQ,GAAR,QAAQ,CAAgB;IAGrC,CAAC;CACJ;AAPD,4DAOC","sourcesContent":["import { PolicyRuntimeRequest } from '@webpieces/rules-sdk';\nimport { CommandsConfig } from '@webpieces/rules-config';\nimport { Rule } from './core/types';\n\n/** Hook mechanics receive the resolved generic command configuration separately from owner settings. */\nexport class HookPolicyRuntimeRequest extends PolicyRuntimeRequest {\n constructor(\n request: PolicyRuntimeRequest,\n readonly commands: CommandsConfig,\n ) {\n super(request.workspaceRoot, request.configs, request.ruleIds);\n }\n}\n\nexport interface HookRuleRuntime {\n create(request: HookPolicyRuntimeRequest): readonly Rule[];\n}\n"]}
1
+ {"version":3,"file":"policy-runtime.js","sourceRoot":"","sources":["../../../../../packages/tooling/hook-runtime/src/policy-runtime.ts"],"names":[],"mappings":";;;AAAA,oDAA4D;AAI5D,wGAAwG;AACxG,MAAa,wBAAyB,SAAQ,gCAAoB;IAGjD;IAFb,YACI,OAA6B,EACpB,QAAwB;QAEjC,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QAF5E,aAAQ,GAAR,QAAQ,CAAgB;IAGrC,CAAC;CACJ;AAPD,4DAOC","sourcesContent":["import { PolicyRuntimeRequest } from '@webpieces/rules-sdk';\nimport { CommandsConfig } from '@webpieces/rules-config';\nimport { Rule } from './core/types';\n\n/** Hook mechanics receive the resolved generic command configuration separately from owner settings. */\nexport class HookPolicyRuntimeRequest extends PolicyRuntimeRequest {\n constructor(\n request: PolicyRuntimeRequest,\n readonly commands: CommandsConfig,\n ) {\n super(request.workspaceRoot, request.configs, request.ruleIds, request.excludePaths);\n }\n}\n\nexport interface HookRuleRuntime {\n create(request: HookPolicyRuntimeRequest): readonly Rule[];\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function globMatches(pattern: string, filePath: string): boolean;
package/src/core/glob.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globMatches = globMatches;
4
- // webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API
5
- function globMatches(pattern, filePath) {
6
- const regex = globToRegex(pattern);
7
- return regex.test(filePath);
8
- }
9
- // webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API
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
- //# sourceMappingURL=glob.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../../../packages/tooling/hook-runtime/src/core/glob.ts"],"names":[],"mappings":";;AACA,kCAGC;AAJD,mKAAmK;AACnK,SAAgB,WAAW,CAAC,OAAe,EAAE,QAAgB;IACzD,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAED,mKAAmK;AACnK,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;QACT,CAAC,IAAI,CAAC,CAAC;IACX,CAAC;IACD,OAAO,IAAI,MAAM,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC","sourcesContent":["// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\nexport function globMatches(pattern: string, filePath: string): boolean {\n const regex = globToRegex(pattern);\n return regex.test(filePath);\n}\n\n// webpieces-disable no-function-outside-class -- existing stateless module helper moved intact with its callers; ownership extraction preserves its functional API\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"]}