@webpieces/ai-hook-rules 0.4.971 → 0.4.973

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.971",
3
+ "version": "0.4.973",
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.971",
27
- "@webpieces/rules-config": "0.4.971",
26
+ "@webpieces/hook-runtime": "0.4.973",
27
+ "@webpieces/rules-config": "0.4.973",
28
28
  "inversify": "7.10.4",
29
29
  "reflect-metadata": "0.2.2",
30
- "@webpieces/tooling-common": "0.4.971",
31
- "@webpieces/rules-sdk": "0.4.971"
30
+ "@webpieces/tooling-common": "0.4.973",
31
+ "@webpieces/rules-sdk": "0.4.973"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "devDependencies": {
37
- "@webpieces/tooling-testkit": "0.4.971"
37
+ "@webpieces/tooling-testkit": "0.4.973"
38
38
  },
39
39
  "types": "./src/index.d.ts",
40
40
  "bin": {
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SourceHookRules = exports.SourceHookRuleSet = void 0;
4
4
  exports.run = run;
5
+ const tslib_1 = require("tslib");
6
+ const path = tslib_1.__importStar(require("path"));
5
7
  const rule_runtime_1 = require("../rule-runtime");
6
8
  const rules_config_1 = require("@webpieces/rules-config");
7
9
  const hook_runtime_1 = require("@webpieces/hook-runtime");
@@ -36,6 +38,11 @@ function run(toolKind, input, cwd, mode = 'rules') {
36
38
  if (loaded.configPath === null)
37
39
  return new hook_runtime_1.BlockedResult(rules_config_1.CONFIG_MISSING_REPORT +
38
40
  (0, rules_config_1.guardMatrixPointer)((0, rules_config_1.writeGuardMatrixDoc)(new rules_config_1.RepoRootFinder().resolveRepoRoot(cwd))), rules_config_1.L0_FAULT_CONFIG_MISSING);
41
+ // A file checked out on a `/hotfix/` branch runs no edit-time code rule, matching `hotfix-ci` (compile +
42
+ // tests only; issue #1371). The branch is the one in the tree that OWNS the file, never the session's.
43
+ const owner = new hook_runtime_1.TargetTreeResolver().resolve(input.filePath, path.dirname(loaded.configPath));
44
+ if (new rules_config_1.HotfixCheckout().isHotfix(owner.root))
45
+ return null;
39
46
  return new hook_runtime_1.HookFileEvaluation().evaluate(toolKind, input, loaded, new SourceHookRules().load(loaded));
40
47
  }
41
48
  //# sourceMappingURL=runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/runner.ts"],"names":[],"mappings":";;;AA4CA,kBA8BC;AA1ED,kDAAoD;AACpD,0DAUiC;AACjC,0DAUiC;AACjC,6CAA8C;AAE9C,MAAa,iBAAkB,SAAQ,0BAAW;IAEjC;IACA;IAFb,YACa,gBAAiC,EACjC,UAA2B;QAEpC,KAAK,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;QAHnC,qBAAgB,GAAhB,gBAAgB,CAAiB;QACjC,eAAU,GAAV,UAAU,CAAiB;IAGxC,CAAC;CACJ;AAPD,8CAOC;AAED,MAAa,eAAe;IACxB,IAAI,CAAC,MAAoB;QACrB,MAAM,QAAQ,GAAG,IAAI,sCAAuB,CACxC,IAAI,GAAG,CAAC,CAAC,CAAC,uCAAuC,EAAE,IAAI,gCAAiB,EAAE,CAAC,CAAC,CAAC,CAChF,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAC9B,OAAO,IAAI,iBAAiB,CAAC,QAAQ,EAAE,IAAA,2BAAc,EAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAC9E,CAAC;CACJ;AAPD,0CAOC;AAED,kGAAkG;AAClG,SAAgB,GAAG,CACf,QAAkB,EAClB,KAA0B,EAC1B,GAAW,EACX,OAAiB,OAAO;IAExB,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,IACI,QAAQ,KAAK,QAAQ;QACrB,CAAC,IAAI,iCAAkB,EAAE,CAAC,YAAY,CAClC,IAAI,6BAAc,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,EACzC,KAAK,CAAC,QAAQ,CACjB;YACG,IAAA,6BAAc,EAAC,KAAK,CAAC,QAAQ,CAAC;YAC9B,IAAI,gCAAiB,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE7D,OAAO,IAAI,CAAC;IAChB,MAAM,MAAM,GAAG,IAAA,8BAAe,EAAC,GAAG,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,UAAU,KAAK,IAAI;QAC1B,OAAO,IAAI,4BAAa,CACpB,oCAAqB;YACjB,IAAA,iCAAkB,EAAC,IAAA,kCAAmB,EAAC,IAAI,6BAAc,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EACtF,sCAAuB,CAC1B,CAAC;IACN,OAAO,IAAI,iCAAkB,EAAE,CAAC,QAAQ,CACpC,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,eAAe,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CACrC,CAAC;AACN,CAAC","sourcesContent":["import { SourceRuleRuntime } from '../rule-runtime';\nimport {\n loadAndValidate,\n LoadedConfig,\n ConfigRepairAccess,\n HomeConfigService,\n CONFIG_MISSING_REPORT,\n L0_FAULT_CONFIG_MISSING,\n RepoRootFinder,\n writeGuardMatrixDoc,\n guardMatrixPointer,\n} from '@webpieces/rules-config';\nimport {\n Rule,\n isRootManifest,\n HookPolicyContributions,\n HookRuleSet,\n HookFileEvaluation,\n ToolKind,\n NormalizedToolInput,\n HookMode,\n BlockedResult,\n} from '@webpieces/hook-runtime';\nimport { loadMatchRules } from './load-rules';\n\nexport class SourceHookRuleSet extends HookRuleSet {\n constructor(\n readonly contributedRules: readonly Rule[],\n readonly matchRules: readonly Rule[],\n ) {\n super([...contributedRules, ...matchRules]);\n }\n}\n\nexport class SourceHookRules {\n load(loaded: LoadedConfig): SourceHookRuleSet {\n const builtIns = new HookPolicyContributions(\n new Map([['@webpieces/ai-hook-rules/rule-runtime', new SourceRuleRuntime()]]),\n ).load(loaded, 'source-hook');\n return new SourceHookRuleSet(builtIns, loadMatchRules(loaded.matchRules));\n }\n}\n\n// webpieces-disable no-function-outside-class -- preserves the existing source runner entry point\nexport function run(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode = 'rules',\n): BlockedResult | null {\n if (mode === 'guards') return null;\n if (\n toolKind !== 'Delete' &&\n (new ConfigRepairAccess().isRepairFile(\n new RepoRootFinder().resolveRepoRoot(cwd),\n input.filePath,\n ) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath))\n )\n return null;\n const loaded = loadAndValidate(cwd);\n if (loaded.configPath === null)\n return new BlockedResult(\n CONFIG_MISSING_REPORT +\n guardMatrixPointer(writeGuardMatrixDoc(new RepoRootFinder().resolveRepoRoot(cwd))),\n L0_FAULT_CONFIG_MISSING,\n );\n return new HookFileEvaluation().evaluate(\n toolKind,\n input,\n loaded,\n new SourceHookRules().load(loaded),\n );\n}\n"]}
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/runner.ts"],"names":[],"mappings":";;;AAgDA,kBAkCC;;AAlFD,mDAA6B;AAE7B,kDAAoD;AACpD,0DAWiC;AACjC,0DAWiC;AACjC,6CAA8C;AAE9C,MAAa,iBAAkB,SAAQ,0BAAW;IAEjC;IACA;IAFb,YACa,gBAAiC,EACjC,UAA2B;QAEpC,KAAK,CAAC,CAAC,GAAG,gBAAgB,EAAE,GAAG,U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GAAyG;IACzG,uGAAuG;IACvG,MAAM,KAAK,GAAG,IAAI,iCAAkB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IAChG,IAAI,IAAI,6BAAc,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,OAAO,IAAI,iCAAkB,EAAE,CAAC,QAAQ,CACpC,QAAQ,EACR,KAAK,EACL,MAAM,EACN,IAAI,eAAe,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CACrC,CAAC;AACN,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { SourceRuleRuntime } from '../rule-runtime';\nimport {\n loadAndValidate,\n LoadedConfig,\n ConfigRepairAccess,\n HomeConfigService,\n CONFIG_MISSING_REPORT,\n L0_FAULT_CONFIG_MISSING,\n RepoRootFinder,\n writeGuardMatrixDoc,\n guardMatrixPointer,\n HotfixCheckout,\n} from '@webpieces/rules-config';\nimport {\n Rule,\n isRootManifest,\n HookPolicyContributions,\n HookRuleSet,\n HookFileEvaluation,\n ToolKind,\n NormalizedToolInput,\n HookMode,\n BlockedResult,\n TargetTreeResolver,\n} from '@webpieces/hook-runtime';\nimport { loadMatchRules } from './load-rules';\n\nexport class SourceHookRuleSet extends HookRuleSet {\n constructor(\n readonly contributedRules: readonly Rule[],\n readonly matchRules: readonly Rule[],\n ) {\n super([...contributedRules, ...matchRules]);\n }\n}\n\nexport class SourceHookRules {\n load(loaded: LoadedConfig): SourceHookRuleSet {\n const builtIns = new HookPolicyContributions(\n new Map([['@webpieces/ai-hook-rules/rule-runtime', new SourceRuleRuntime()]]),\n ).load(loaded, 'source-hook');\n return new SourceHookRuleSet(builtIns, loadMatchRules(loaded.matchRules));\n }\n}\n\n// webpieces-disable no-function-outside-class -- preserves the existing source runner entry point\nexport function run(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n cwd: string,\n mode: HookMode = 'rules',\n): BlockedResult | null {\n if (mode === 'guards') return null;\n if (\n toolKind !== 'Delete' &&\n (new ConfigRepairAccess().isRepairFile(\n new RepoRootFinder().resolveRepoRoot(cwd),\n input.filePath,\n ) ||\n isRootManifest(input.filePath) ||\n new HomeConfigService().isHomeConfigPath(input.filePath))\n )\n return null;\n const loaded = loadAndValidate(cwd);\n if (loaded.configPath === null)\n return new BlockedResult(\n CONFIG_MISSING_REPORT +\n guardMatrixPointer(writeGuardMatrixDoc(new RepoRootFinder().resolveRepoRoot(cwd))),\n L0_FAULT_CONFIG_MISSING,\n );\n // A file checked out on a `/hotfix/` branch runs no edit-time code rule, matching `hotfix-ci` (compile +\n // tests only; issue #1371). The branch is the one in the tree that OWNS the file, never the session's.\n const owner = new TargetTreeResolver().resolve(input.filePath, path.dirname(loaded.configPath));\n if (new HotfixCheckout().isHotfix(owner.root)) return null;\n return new HookFileEvaluation().evaluate(\n toolKind,\n input,\n loaded,\n new SourceHookRules().load(loaded),\n );\n}\n"]}