@shrkcrft/rule-graph 0.1.0-alpha.20 → 0.1.0-alpha.22
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.
|
@@ -1,33 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Heuristic file matchers for
|
|
2
|
+
* Heuristic file matchers for knowledge-model rules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* patterns. Authoritative when present.
|
|
10
|
-
* 2. **Tag-based heuristics**: well-known tags map to file
|
|
11
|
-
* patterns. For example a rule tagged `mcp` likely applies to
|
|
12
|
-
* files under `packages/mcp-server/**`. The map is intentionally
|
|
13
|
-
* conservative — when no tag matches, the rule is *not* bridged
|
|
14
|
-
* (better silent than noisy).
|
|
15
|
-
*
|
|
16
|
-
* Authors who want predictable bridging set `metadata.appliesTo`.
|
|
4
|
+
* The implementation moved DOWN to `@shrkcrft/rules` (`rule-applicability.ts`)
|
|
5
|
+
* so the inspector's `shrk why <file>` can share the exact same per-file rule
|
|
6
|
+
* applicability the bridge uses here — otherwise the two surfaces drift on which
|
|
7
|
+
* rules apply to a file. This module re-exports it for backward compatibility
|
|
8
|
+
* (the bridge builder + the package barrel still import from here).
|
|
17
9
|
*/
|
|
18
|
-
export
|
|
19
|
-
/** Glob patterns to match against file paths. */
|
|
20
|
-
patterns: readonly string[];
|
|
21
|
-
/**
|
|
22
|
-
* When non-empty, the rule applies to every file whose `tags` array
|
|
23
|
-
* intersects this set. Currently used by `testing`-tagged rules.
|
|
24
|
-
*/
|
|
25
|
-
fileTags: readonly string[];
|
|
26
|
-
/** How we derived the applicability — useful for diagnostics. */
|
|
27
|
-
source: 'metadata' | 'tags' | 'none';
|
|
28
|
-
}
|
|
29
|
-
export declare function deriveApplicability(rule: {
|
|
30
|
-
tags?: readonly string[];
|
|
31
|
-
metadata?: Readonly<Record<string, unknown>>;
|
|
32
|
-
}): IRuleApplicability;
|
|
10
|
+
export { deriveApplicability, type IRuleApplicability } from '@shrkcrft/rules';
|
|
33
11
|
//# sourceMappingURL=knowledge-rule-matching.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-rule-matching.d.ts","sourceRoot":"","sources":["../../src/bridge/knowledge-rule-matching.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"knowledge-rule-matching.d.ts","sourceRoot":"","sources":["../../src/bridge/knowledge-rule-matching.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,65 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Heuristic file matchers for
|
|
2
|
+
* Heuristic file matchers for knowledge-model rules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* patterns. Authoritative when present.
|
|
10
|
-
* 2. **Tag-based heuristics**: well-known tags map to file
|
|
11
|
-
* patterns. For example a rule tagged `mcp` likely applies to
|
|
12
|
-
* files under `packages/mcp-server/**`. The map is intentionally
|
|
13
|
-
* conservative — when no tag matches, the rule is *not* bridged
|
|
14
|
-
* (better silent than noisy).
|
|
15
|
-
*
|
|
16
|
-
* Authors who want predictable bridging set `metadata.appliesTo`.
|
|
4
|
+
* The implementation moved DOWN to `@shrkcrft/rules` (`rule-applicability.ts`)
|
|
5
|
+
* so the inspector's `shrk why <file>` can share the exact same per-file rule
|
|
6
|
+
* applicability the bridge uses here — otherwise the two surfaces drift on which
|
|
7
|
+
* rules apply to a file. This module re-exports it for backward compatibility
|
|
8
|
+
* (the bridge builder + the package barrel still import from here).
|
|
17
9
|
*/
|
|
18
|
-
|
|
19
|
-
// Engine packages.
|
|
20
|
-
['mcp', ['packages/mcp-server/**']],
|
|
21
|
-
['cli', ['packages/cli/**']],
|
|
22
|
-
['dashboard', ['packages/dashboard/**', 'packages/dashboard-api/**']],
|
|
23
|
-
['generator', ['packages/generator/**']],
|
|
24
|
-
['importer', ['packages/importer/**']],
|
|
25
|
-
['inspector', ['packages/inspector/**']],
|
|
26
|
-
['packs', ['packages/packs/**']],
|
|
27
|
-
['core', ['packages/core/**']],
|
|
28
|
-
// Asset categories.
|
|
29
|
-
['boundaries', ['sharkcraft/boundaries.ts', 'packages/boundaries/**']],
|
|
30
|
-
['rules', ['sharkcraft/rules.ts', 'packages/rules/**']],
|
|
31
|
-
['paths', ['sharkcraft/paths.ts', 'packages/paths/**']],
|
|
32
|
-
['templates', ['sharkcraft/templates.ts', 'packages/templates/**']],
|
|
33
|
-
['pipelines', ['sharkcraft/pipelines.ts', 'packages/pipelines/**']],
|
|
34
|
-
['presets', ['sharkcraft/presets.ts', 'packages/presets/**']],
|
|
35
|
-
// Cross-cutting concerns.
|
|
36
|
-
['imports', ['packages/**/*.ts']],
|
|
37
|
-
['testing', []], // signal-only; the bridge attaches via the file's `tags: test` separately
|
|
38
|
-
['tests', []],
|
|
39
|
-
]);
|
|
40
|
-
export function deriveApplicability(rule) {
|
|
41
|
-
const explicit = rule.metadata?.['appliesTo'];
|
|
42
|
-
if (Array.isArray(explicit) && explicit.every((p) => typeof p === 'string')) {
|
|
43
|
-
return { patterns: explicit, fileTags: [], source: 'metadata' };
|
|
44
|
-
}
|
|
45
|
-
const tags = rule.tags ?? [];
|
|
46
|
-
const patterns = [];
|
|
47
|
-
const fileTags = [];
|
|
48
|
-
for (const tag of tags) {
|
|
49
|
-
if (tag === 'testing' || tag === 'tests') {
|
|
50
|
-
fileTags.push('test');
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const mapped = TAG_PATTERNS.get(tag);
|
|
54
|
-
if (mapped) {
|
|
55
|
-
for (const p of mapped) {
|
|
56
|
-
if (!patterns.includes(p))
|
|
57
|
-
patterns.push(p);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (patterns.length === 0 && fileTags.length === 0) {
|
|
62
|
-
return { patterns: [], fileTags: [], source: 'none' };
|
|
63
|
-
}
|
|
64
|
-
return { patterns, fileTags, source: 'tags' };
|
|
65
|
-
}
|
|
10
|
+
export { deriveApplicability } from '@shrkcrft/rules';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/rule-graph",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.22",
|
|
4
4
|
"description": "SharkCraft rule-graph: bridges code-graph file nodes to rules / paths / templates / boundaries so 'which assets apply to this file?' is a 1-hop query.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
47
|
-
"@shrkcrft/boundaries": "^0.1.0-alpha.
|
|
48
|
-
"@shrkcrft/
|
|
49
|
-
"@shrkcrft/
|
|
46
|
+
"@shrkcrft/core": "^0.1.0-alpha.22",
|
|
47
|
+
"@shrkcrft/boundaries": "^0.1.0-alpha.22",
|
|
48
|
+
"@shrkcrft/rules": "^0.1.0-alpha.22",
|
|
49
|
+
"@shrkcrft/graph": "^0.1.0-alpha.22",
|
|
50
|
+
"@shrkcrft/inspector": "^0.1.0-alpha.22"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|