@shrkcrft/inspector 0.1.0-alpha.21 → 0.1.0-alpha.23
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/dist/command-recommender.d.ts.map +1 -1
- package/dist/command-recommender.js +110 -1
- package/dist/context-tuning.d.ts +14 -0
- package/dist/context-tuning.d.ts.map +1 -0
- package/dist/context-tuning.js +38 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/knowledge-stale.d.ts +23 -0
- package/dist/knowledge-stale.d.ts.map +1 -1
- package/dist/knowledge-stale.js +58 -9
- package/dist/monorepo-onboarding.d.ts.map +1 -1
- package/dist/monorepo-onboarding.js +122 -12
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +79 -18
- package/dist/pack-doctor.d.ts +8 -1
- package/dist/pack-doctor.d.ts.map +1 -1
- package/dist/pack-doctor.js +110 -3
- package/dist/pack-quality-score.d.ts.map +1 -1
- package/dist/pack-quality-score.js +7 -8
- package/dist/pack-release-check.d.ts.map +1 -1
- package/dist/pack-release-check.js +23 -20
- package/dist/pack-signature-status.d.ts +9 -3
- package/dist/pack-signature-status.d.ts.map +1 -1
- package/dist/pack-signature-status.js +13 -2
- package/dist/plan-simulation.d.ts.map +1 -1
- package/dist/plan-simulation.js +26 -12
- package/dist/registry-lifecycle.d.ts +8 -0
- package/dist/registry-lifecycle.d.ts.map +1 -1
- package/dist/registry-lifecycle.js +21 -3
- package/dist/resolve-project-config.d.ts +26 -0
- package/dist/resolve-project-config.d.ts.map +1 -0
- package/dist/resolve-project-config.js +128 -0
- package/dist/resolve-verification-commands.d.ts +7 -0
- package/dist/resolve-verification-commands.d.ts.map +1 -1
- package/dist/resolve-verification-commands.js +53 -4
- package/dist/review-packet.d.ts +8 -0
- package/dist/review-packet.d.ts.map +1 -1
- package/dist/review-packet.js +11 -12
- package/dist/sharkcraft-inspector.d.ts.map +1 -1
- package/dist/sharkcraft-inspector.js +28 -2
- package/dist/spec/__tests__/spec-evidence.test.d.ts +2 -0
- package/dist/spec/__tests__/spec-evidence.test.d.ts.map +1 -0
- package/dist/spec/__tests__/spec-evidence.test.js +81 -0
- package/dist/spec/spec-evidence.d.ts +62 -0
- package/dist/spec/spec-evidence.d.ts.map +1 -0
- package/dist/spec/spec-evidence.js +215 -0
- package/dist/spec/spec-review.d.ts +1 -0
- package/dist/spec/spec-review.d.ts.map +1 -1
- package/dist/spec/spec-review.js +5 -0
- package/dist/symbol-index.d.ts +9 -0
- package/dist/symbol-index.d.ts.map +1 -1
- package/dist/symbol-index.js +6 -0
- package/dist/task-packet.d.ts.map +1 -1
- package/dist/task-packet.js +6 -1
- package/dist/task-ranker.d.ts +2 -1
- package/dist/task-ranker.d.ts.map +1 -1
- package/dist/task-ranker.js +30 -5
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +3 -0
- package/dist/why-file.d.ts.map +1 -1
- package/dist/why-file.js +13 -0
- package/package.json +17 -17
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic feature-checklist → changeset-evidence mapper.
|
|
3
|
+
*
|
|
4
|
+
* For each acceptance criterion of a spec, scan the changeset (the set of
|
|
5
|
+
* tracked + untracked changed files plus their current contents) for
|
|
6
|
+
* backing evidence:
|
|
7
|
+
*
|
|
8
|
+
* - a new exported symbol whose name relates to the criterion,
|
|
9
|
+
* - a new registration / array membership,
|
|
10
|
+
* - a new route / command registration,
|
|
11
|
+
* - a touched companion file whose path relates to the criterion,
|
|
12
|
+
* - a new test file.
|
|
13
|
+
*
|
|
14
|
+
* A criterion with zero footprint across the whole changeset is `UNMET`
|
|
15
|
+
* (claimed-but-unimplemented). There is NO model in the loop: matching is a
|
|
16
|
+
* pure keyword/identifier intersection between the criterion text and the
|
|
17
|
+
* identifiers/paths added in the changeset.
|
|
18
|
+
*
|
|
19
|
+
* This module is read-only and side-effect free; the caller is responsible
|
|
20
|
+
* for collecting `changedFiles` + `fileContents` (see the CLI
|
|
21
|
+
* `collectChangedPaths` helper and `spec verify --coverage`).
|
|
22
|
+
*/
|
|
23
|
+
/** Cap on evidence items retained per criterion (deterministic, insertion-ordered). */
|
|
24
|
+
const MAX_EVIDENCE_PER_CRITERION = 12;
|
|
25
|
+
/**
|
|
26
|
+
* Words too generic to be a useful match signal. English filler plus
|
|
27
|
+
* code-structure nouns that appear in nearly every changed file.
|
|
28
|
+
*/
|
|
29
|
+
const STOPWORDS = new Set([
|
|
30
|
+
// english filler
|
|
31
|
+
'the', 'and', 'for', 'with', 'that', 'this', 'are', 'its', 'from', 'when',
|
|
32
|
+
'then', 'must', 'should', 'shall', 'will', 'can', 'via', 'into', 'onto',
|
|
33
|
+
'per', 'not', 'new', 'add', 'added', 'adds', 'adding', 'also', 'only',
|
|
34
|
+
'both', 'same', 'each', 'all', 'any', 'one', 'two', 'every', 'ensure',
|
|
35
|
+
'ensures', 'return', 'returns', 'returned', 'use', 'uses', 'using', 'used',
|
|
36
|
+
'support', 'supports', 'make', 'makes', 'get', 'gets', 'set', 'sets', 'run',
|
|
37
|
+
'runs', 'call', 'calls', 'allow', 'allows', 'emit', 'emits', 'show', 'shows',
|
|
38
|
+
'print', 'prints', 'such', 'over', 'under', 'where', 'which', 'while',
|
|
39
|
+
// code-structure nouns
|
|
40
|
+
'flag', 'flags', 'file', 'files', 'function', 'functions', 'const', 'class',
|
|
41
|
+
'interface', 'type', 'types', 'enum', 'test', 'tests', 'value', 'values',
|
|
42
|
+
'field', 'fields', 'array', 'arrays', 'list', 'lists', 'table', 'output',
|
|
43
|
+
'input', 'json', 'human', 'count', 'counts', 'result', 'results', 'report',
|
|
44
|
+
'reports', 'command', 'commands', 'option', 'options', 'arg', 'args', 'case',
|
|
45
|
+
'cases', 'line', 'lines', 'code', 'name', 'names', 'data', 'item', 'items',
|
|
46
|
+
'entry', 'entries', 'key', 'keys', 'string', 'number', 'boolean', 'object',
|
|
47
|
+
]);
|
|
48
|
+
/** Markers that, when present on a line, treat a keyword match as a route. */
|
|
49
|
+
const ROUTE_MARKER = /\b(route|router|endpoint|register[a-z]*|addcommand|handlermap|usage)\b/i;
|
|
50
|
+
/**
|
|
51
|
+
* Map a spec checklist to changeset evidence. Pure; deterministic for a
|
|
52
|
+
* given input (stable iteration over `changedFiles` and sorted keywords).
|
|
53
|
+
*/
|
|
54
|
+
export function mapChecklistToEvidence(input) {
|
|
55
|
+
const criteria = input.criteria.map((c) => analyzeCriterion(c, input));
|
|
56
|
+
const coveredCount = criteria.filter((c) => c.covered).length;
|
|
57
|
+
return {
|
|
58
|
+
criteria,
|
|
59
|
+
coveredCount,
|
|
60
|
+
unmetCount: criteria.length - coveredCount,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function analyzeCriterion(criterion, input) {
|
|
64
|
+
const keywords = extractKeywords(criterion.text);
|
|
65
|
+
const evidence = new Map();
|
|
66
|
+
const push = (item) => {
|
|
67
|
+
if (evidence.size >= MAX_EVIDENCE_PER_CRITERION)
|
|
68
|
+
return;
|
|
69
|
+
evidence.set(`${item.kind}|${item.file}|${item.detail}`, item);
|
|
70
|
+
};
|
|
71
|
+
if (keywords.size > 0) {
|
|
72
|
+
for (const file of input.changedFiles) {
|
|
73
|
+
const content = input.fileContents[file] ?? '';
|
|
74
|
+
collectFileEvidence(file, content, keywords, push);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const items = [...evidence.values()];
|
|
78
|
+
return {
|
|
79
|
+
id: criterion.id,
|
|
80
|
+
text: criterion.text,
|
|
81
|
+
covered: items.length > 0,
|
|
82
|
+
evidence: items,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function collectFileEvidence(file, content, keywords, push) {
|
|
86
|
+
const pathTokens = tokenizeIdentifier(stripExtension(baseName(file)));
|
|
87
|
+
if (isTestFile(file)) {
|
|
88
|
+
// A new test backs a criterion when its path (or an exported helper)
|
|
89
|
+
// names the feature. Test files are reported ONLY as `test` evidence.
|
|
90
|
+
const onPath = firstMatch(pathTokens, keywords);
|
|
91
|
+
if (onPath) {
|
|
92
|
+
push({ kind: 'test', file, detail: baseName(file), matched: onPath });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
for (const symbol of extractExportedSymbols(content)) {
|
|
96
|
+
const hit = firstMatch(tokenizeIdentifier(symbol), keywords);
|
|
97
|
+
if (hit) {
|
|
98
|
+
push({ kind: 'test', file, detail: symbol, matched: hit });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// companion: the touched file's own path names the feature.
|
|
105
|
+
const onPath = firstMatch(pathTokens, keywords);
|
|
106
|
+
if (onPath) {
|
|
107
|
+
push({ kind: 'companion', file, detail: baseName(file), matched: onPath });
|
|
108
|
+
}
|
|
109
|
+
// symbol: a newly exported declaration names the feature.
|
|
110
|
+
for (const symbol of extractExportedSymbols(content)) {
|
|
111
|
+
const hit = firstMatch(tokenizeIdentifier(symbol), keywords);
|
|
112
|
+
if (hit)
|
|
113
|
+
push({ kind: 'symbol', file, detail: symbol, matched: hit });
|
|
114
|
+
}
|
|
115
|
+
// route / registration: line-level membership.
|
|
116
|
+
for (const rawLine of content.split('\n')) {
|
|
117
|
+
const line = rawLine.trim();
|
|
118
|
+
if (line.length === 0)
|
|
119
|
+
continue;
|
|
120
|
+
const member = registrationMember(line);
|
|
121
|
+
if (member) {
|
|
122
|
+
const hit = firstMatch(tokenizeIdentifier(member), keywords);
|
|
123
|
+
if (hit) {
|
|
124
|
+
const kind = ROUTE_MARKER.test(line) ? 'route' : 'registration';
|
|
125
|
+
push({ kind, file, detail: member, matched: hit });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The "registration token" of a line: an object-property key
|
|
132
|
+
* (`coverage: ...`), a quoted map/array string entry (`'coverage'`), or the
|
|
133
|
+
* identifier following a route/registration marker.
|
|
134
|
+
*/
|
|
135
|
+
function registrationMember(line) {
|
|
136
|
+
const prop = line.match(/^['"]?([A-Za-z_$][\w-]*)['"]?\s*:/);
|
|
137
|
+
if (prop)
|
|
138
|
+
return prop[1];
|
|
139
|
+
const quoted = line.match(/^['"]([\w./-]+)['"]\s*,?$/);
|
|
140
|
+
if (quoted)
|
|
141
|
+
return quoted[1];
|
|
142
|
+
if (ROUTE_MARKER.test(line)) {
|
|
143
|
+
const ident = line.match(/['"]([\w./-]+)['"]/);
|
|
144
|
+
if (ident)
|
|
145
|
+
return ident[1];
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
function extractExportedSymbols(content) {
|
|
150
|
+
const out = [];
|
|
151
|
+
const seen = new Set();
|
|
152
|
+
for (const rawLine of content.split('\n')) {
|
|
153
|
+
const line = rawLine.trim();
|
|
154
|
+
const decl = line.match(/^export\s+(?:default\s+)?(?:async\s+)?(?:abstract\s+)?(?:function\*?|const|let|var|class|interface|type|enum)\s+([A-Za-z_$][\w$]*)/);
|
|
155
|
+
if (decl && !seen.has(decl[1])) {
|
|
156
|
+
seen.add(decl[1]);
|
|
157
|
+
out.push(decl[1]);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const named = line.match(/^export\s*\{([^}]*)\}/);
|
|
161
|
+
if (named) {
|
|
162
|
+
for (const part of named[1].split(',')) {
|
|
163
|
+
const id = part.trim().split(/\s+as\s+/)[0].trim();
|
|
164
|
+
if (/^[A-Za-z_$][\w$]*$/.test(id) && !seen.has(id)) {
|
|
165
|
+
seen.add(id);
|
|
166
|
+
out.push(id);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
/** Distinctive lowercase keyword tokens of a criterion (stopwords removed). */
|
|
174
|
+
function extractKeywords(text) {
|
|
175
|
+
const out = new Set();
|
|
176
|
+
for (const raw of text.toLowerCase().match(/[a-z0-9][a-z0-9_-]*/g) ?? []) {
|
|
177
|
+
for (const tok of tokenizeIdentifier(raw)) {
|
|
178
|
+
if (tok.length >= 3 && !STOPWORDS.has(tok))
|
|
179
|
+
out.add(tok);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Split an identifier into lowercase tokens across camelCase, PascalCase,
|
|
186
|
+
* snake_case, kebab-case and digit boundaries.
|
|
187
|
+
*/
|
|
188
|
+
function tokenizeIdentifier(name) {
|
|
189
|
+
return name
|
|
190
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
191
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')
|
|
192
|
+
.split(/[^A-Za-z0-9]+/)
|
|
193
|
+
.map((t) => t.toLowerCase())
|
|
194
|
+
.filter((t) => t.length > 0);
|
|
195
|
+
}
|
|
196
|
+
function firstMatch(tokens, keywords) {
|
|
197
|
+
for (const t of tokens) {
|
|
198
|
+
if (keywords.has(t))
|
|
199
|
+
return t;
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
function isTestFile(file) {
|
|
204
|
+
return (/\.(test|spec)\.[cm]?[jt]sx?$/.test(file) ||
|
|
205
|
+
file.includes('/__tests__/') ||
|
|
206
|
+
file.startsWith('__tests__/'));
|
|
207
|
+
}
|
|
208
|
+
function baseName(file) {
|
|
209
|
+
const norm = file.split('\\').join('/');
|
|
210
|
+
const idx = norm.lastIndexOf('/');
|
|
211
|
+
return idx === -1 ? norm : norm.slice(idx + 1);
|
|
212
|
+
}
|
|
213
|
+
function stripExtension(name) {
|
|
214
|
+
return name.replace(/\.[^.]+$/, '');
|
|
215
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type ISpecJson, type ISpecValidationIssue } from '@shrkcrft/generator';
|
|
9
9
|
import type { ISharkcraftInspection } from '../sharkcraft-inspector.js';
|
|
10
|
+
export * from './spec-evidence.js';
|
|
10
11
|
export declare const SPEC_REVIEW_SCHEMA = "sharkcraft.spec-review/v1";
|
|
11
12
|
export interface ISpecReviewReport {
|
|
12
13
|
readonly schema: typeof SPEC_REVIEW_SCHEMA;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec-review.d.ts","sourceRoot":"","sources":["../../src/spec/spec-review.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"spec-review.d.ts","sourceRoot":"","sources":["../../src/spec/spec-review.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,oBAAoB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAOxE,cAAc,oBAAoB,CAAC;AAEnC,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,kBAAkB,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACjD,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,CAAC,aAAa,EAAE,SAAS;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACjF,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,qBAAqB,GAAG,iBAAiB,CA6B/E"}
|
package/dist/spec/spec-review.js
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { validateSpecStructural, } from '@shrkcrft/generator';
|
|
9
9
|
import { validateSpecAgainstWorkspace } from "./spec-cross-validate.js";
|
|
10
|
+
// Surface the deterministic checklist→changeset evidence analyzer through
|
|
11
|
+
// the package barrel. `index.ts` re-exports this module (`export *`), so
|
|
12
|
+
// `spec verify --coverage` can import `mapChecklistToEvidence` from
|
|
13
|
+
// `@shrkcrft/inspector` without a new top-level barrel edit.
|
|
14
|
+
export * from "./spec-evidence.js";
|
|
10
15
|
export const SPEC_REVIEW_SCHEMA = 'sharkcraft.spec-review/v1';
|
|
11
16
|
export function buildSpecReview(input) {
|
|
12
17
|
const structural = validateSpecStructural(input.spec, input.body, {
|
package/dist/symbol-index.d.ts
CHANGED
|
@@ -36,6 +36,15 @@ export interface ISymbolEntry {
|
|
|
36
36
|
export interface IReExportEntry {
|
|
37
37
|
/** Symbol name as exposed (the "name" half of `export { foo } from`). */
|
|
38
38
|
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* Original name in the target module for a RENAMED re-export
|
|
41
|
+
* (`export { Orig as Exposed } from './x'` → `localName` is `Orig`). Absent
|
|
42
|
+
* for a plain `export { foo } from './x'` where the exposed name equals the
|
|
43
|
+
* original. `default` for `export { default as Foo } from './x'`. Threaded
|
|
44
|
+
* through so the graph re-export resolver can recurse with the ORIGINAL
|
|
45
|
+
* name and land on the real declaring symbol instead of giving up.
|
|
46
|
+
*/
|
|
47
|
+
localName?: string;
|
|
39
48
|
/** Original specifier path (e.g. `./feature`). */
|
|
40
49
|
from: string;
|
|
41
50
|
/** If true, this is `export * from "..."`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-index.d.ts","sourceRoot":"","sources":["../src/symbol-index.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAEhE,oBAAY,qBAAqB;IAC/B,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,SAAS,eAAe;IACxB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED,oBAAY,gBAAgB;IAC1B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,QAAQ,cAAc;IACtB,OAAO,YAAY;CACpB;AAED,oBAAY,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,aAAa,mBAAmB;IAChC,YAAY,kBAAkB;IAC9B,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,qBAAqB,CAAC;IAC5B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;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zE;AAMD,MAAM,WAAW,YAAY;IAC3B,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,6BAA6B,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,YAAY,EAAE,SAAS,YAAY,EAAE,CAAC;IACtC,iEAAiE;IACjE,WAAW,EAAE,SAAS,YAAY,EAAE,CAAC;IACrC;mDAC+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6BAA6B;IAC7B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CAChC;AAoCD,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,QAAQ,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;IAChF,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,kBAAuB,GAC/B,mBAAmB,CAsGrB"}
|
package/dist/symbol-index.js
CHANGED
|
@@ -164,8 +164,14 @@ export function buildSymbolIndex(fileAbsPath, content, options = {}) {
|
|
|
164
164
|
for (const spec of stmt.exportClause.elements) {
|
|
165
165
|
const name = spec.name.text;
|
|
166
166
|
if (fromSpec) {
|
|
167
|
+
// `export { Orig as Exposed } from './x'` — keep the ORIGINAL name
|
|
168
|
+
// (`spec.propertyName`) so a renamed re-export can be resolved to
|
|
169
|
+
// its real declaration. Plain `export { foo } from` has no
|
|
170
|
+
// propertyName (exposed === original).
|
|
171
|
+
const localName = spec.propertyName?.text;
|
|
167
172
|
reExportsList.push({
|
|
168
173
|
name,
|
|
174
|
+
...(localName !== undefined ? { localName } : {}),
|
|
169
175
|
from: fromSpec,
|
|
170
176
|
star: false,
|
|
171
177
|
line: lineOf(sf, spec),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-packet.d.ts","sourceRoot":"","sources":["../src/task-packet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-packet.d.ts","sourceRoot":"","sources":["../src/task-packet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAK/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,MAAM,CAAC;IAC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
|
import { buildContext } from '@shrkcrft/context';
|
|
2
2
|
import { aggregateActionHints, } from '@shrkcrft/knowledge';
|
|
3
3
|
import { rankAll } from "./task-ranker.js";
|
|
4
|
+
import { listSearchTuning } from "./search-tuning-registry.js";
|
|
5
|
+
import { contextTuningBoostFor } from "./context-tuning.js";
|
|
4
6
|
import { buildProjectOverview, renderOverviewText } from "./project-overview.js";
|
|
5
7
|
import { resolveVerificationCommands } from "./resolve-verification-commands.js";
|
|
6
8
|
/**
|
|
@@ -66,16 +68,19 @@ export function buildTaskPacket(inspection, task, options = {}) {
|
|
|
66
68
|
const compact = options.compact !== false;
|
|
67
69
|
const overview = buildProjectOverview(inspection.workspace, inspection.config?.projectName);
|
|
68
70
|
const overviewText = renderOverviewText(overview);
|
|
71
|
+
const contextBoost = contextTuningBoostFor(inspection, task);
|
|
69
72
|
const contextResult = buildContext(inspection.knowledgeEntries, {
|
|
70
73
|
task,
|
|
71
74
|
maxTokens,
|
|
72
75
|
...(options.scope ? { scope: options.scope } : {}),
|
|
73
76
|
projectOverview: overviewText,
|
|
77
|
+
...(contextBoost ? { boostFor: contextBoost } : {}),
|
|
74
78
|
});
|
|
75
79
|
// ── Deterministic ranker — replaces the old substring search ─────────
|
|
76
80
|
// Compact mode requests top-5; full mode requests top-10 (the original).
|
|
77
81
|
const rankN = compact ? 8 : 10;
|
|
78
|
-
const
|
|
82
|
+
const tuning = listSearchTuning(inspection);
|
|
83
|
+
const ranking = rankAll(inspection, task, rankN, tuning);
|
|
79
84
|
const relevantRules = compact
|
|
80
85
|
? ranking.rules.slice(0, COMPACT_CAPS.rules).map((r) => r.item)
|
|
81
86
|
: ranking.rules.map((r) => r.item);
|
package/dist/task-ranker.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { IKnowledgeEntry } from '@shrkcrft/knowledge';
|
|
|
2
2
|
import type { ITemplateDefinition } from '@shrkcrft/templates';
|
|
3
3
|
import type { IPipelineDefinition } from '@shrkcrft/pipelines';
|
|
4
4
|
import type { IPreset, IResolvedPreset } from '@shrkcrft/presets';
|
|
5
|
+
import { type ISearchTuningEntry } from './search-tuning-registry.js';
|
|
5
6
|
/**
|
|
6
7
|
* Deterministic relevance ranker.
|
|
7
8
|
*
|
|
@@ -44,7 +45,7 @@ export declare function rankAll(inspection: {
|
|
|
44
45
|
pathService: {
|
|
45
46
|
list: () => readonly IKnowledgeEntry[];
|
|
46
47
|
};
|
|
47
|
-
}, task: string, limit?: number): IRankAllResult;
|
|
48
|
+
}, task: string, limit?: number, tuning?: readonly ISearchTuningEntry[]): IRankAllResult;
|
|
48
49
|
export declare function explainRanked<T>(items: readonly IRankedItem<T>[], describe: (item: T) => string, limit?: number): string;
|
|
49
50
|
/** Re-export resolved-preset for callers that want to combine ranker + composition. */
|
|
50
51
|
export type { IResolvedPreset };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-ranker.d.ts","sourceRoot":"","sources":["../src/task-ranker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"task-ranker.d.ts","sourceRoot":"","sources":["../src/task-ranker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,6BAA6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AAC;IAC7C,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,SAAS,OAAO,EAAE,CAAA;KAAE,CAAC;IACnD,SAAS,EAAE;QAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;IAC3C,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,SAAS,eAAe,EAAE,CAAA;KAAE,CAAC;IACxD,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,SAAS,eAAe,EAAE,CAAA;KAAE,CAAC;CACzD,EACD,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAW,EAClB,MAAM,GAAE,SAAS,kBAAkB,EAAO,GACzC,cAAc,CAuEhB;AAGD,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC7B,KAAK,GAAE,MAAU,GAChB,MAAM,CAKR;AAED,uFAAuF;AACvF,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/dist/task-ranker.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tuningBoostFor } from "./search-tuning-registry.js";
|
|
1
2
|
// ── Verb hints (what kind of work) ──────────────────────────────────────
|
|
2
3
|
const VERB_HINTS = [
|
|
3
4
|
{
|
|
@@ -309,7 +310,26 @@ export function rankPresets(presets, task, detectedProfiles) {
|
|
|
309
310
|
out.sort((a, b) => b.score - a.score);
|
|
310
311
|
return out;
|
|
311
312
|
}
|
|
312
|
-
|
|
313
|
+
/**
|
|
314
|
+
* Apply pack search-tuning boostIds/boostTags/taskHints to an already-ranked
|
|
315
|
+
* list, mirroring exactly what `searchIndex` does (search-index.ts) so the
|
|
316
|
+
* task ranker and the search ranker honor the same pack tuning. Re-sorts so a
|
|
317
|
+
* boosted item can cross the top-N slice.
|
|
318
|
+
*/
|
|
319
|
+
function applyTuningToRanked(ranked, kind, idPrefix, tuningTokens, tuning) {
|
|
320
|
+
if (tuning.length === 0)
|
|
321
|
+
return ranked.slice();
|
|
322
|
+
const out = ranked.map((r) => {
|
|
323
|
+
const tags = r.item.tags;
|
|
324
|
+
const boost = tuningBoostFor({ id: `${idPrefix}${r.item.id}`, kind, ...(tags ? { tags } : {}), source: 'local' }, tuningTokens, tuning);
|
|
325
|
+
if (boost.delta === 0)
|
|
326
|
+
return r;
|
|
327
|
+
return { item: r.item, score: r.score + boost.delta, reasons: [...r.reasons, ...boost.reasons] };
|
|
328
|
+
});
|
|
329
|
+
out.sort((a, b) => b.score - a.score);
|
|
330
|
+
return out;
|
|
331
|
+
}
|
|
332
|
+
export function rankAll(inspection, task, limit = 10, tuning = []) {
|
|
313
333
|
const initialRules = rankKnowledgeEntries(inspection.ruleService.list(), task);
|
|
314
334
|
const initialPaths = rankPathConventions(inspection.pathService.list(), task);
|
|
315
335
|
const initialTemplates = rankTemplates(inspection.templates, task);
|
|
@@ -363,11 +383,16 @@ export function rankAll(inspection, task, limit = 10) {
|
|
|
363
383
|
};
|
|
364
384
|
});
|
|
365
385
|
templates.sort((a, b) => b.score - a.score);
|
|
386
|
+
const tuningTokens = task.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 1);
|
|
387
|
+
const tunedRules = applyTuningToRanked(rules, 'rule', 'rule:', tuningTokens, tuning);
|
|
388
|
+
const tunedPaths = applyTuningToRanked(initialPaths, 'path', 'path:', tuningTokens, tuning);
|
|
389
|
+
const tunedTemplates = applyTuningToRanked(templates, 'template', 'template:', tuningTokens, tuning);
|
|
390
|
+
const tunedPipelines = applyTuningToRanked(initialPipelines, 'pipeline', 'pipeline:', tuningTokens, tuning);
|
|
366
391
|
return {
|
|
367
|
-
rules:
|
|
368
|
-
paths:
|
|
369
|
-
templates:
|
|
370
|
-
pipelines:
|
|
392
|
+
rules: tunedRules.slice(0, limit),
|
|
393
|
+
paths: tunedPaths.slice(0, limit),
|
|
394
|
+
templates: tunedTemplates.slice(0, limit),
|
|
395
|
+
pipelines: tunedPipelines.slice(0, limit),
|
|
371
396
|
presets: rankPresets(inspection.presetRegistry.list(), task, inspection.workspace.profiles).slice(0, limit),
|
|
372
397
|
};
|
|
373
398
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIvE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAK/B;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,sBAAsB;IACrC,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,wFAAwF;IACxF,gBAAgB,EAAE,OAAO,CAAC;IAC1B,sEAAsE;IACtE,eAAe,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAC9E,mDA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,CAAC;IACnC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,uDAAuD;IACvD,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,SAAS,+BAA+B,EAAE,CAAC;CAC1D;AAYD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,YAAY,EAAE,CAAC,CAkBzB;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAgB/B;AAED,wBAAgB,cAAc,CAC5B,UAAU,EAAE,qBAAqB,EACjC,IAAI,EAAE,YAAY,GACjB,kBAAkB,CA6EpB;AAsBD,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,qBAAqB,EACjC,IAAI,EAAE,kBAAkB,EACxB,UAAU,CAAC,EAAE,wBAAwB,GACpC,wBAAwB,CA6Q1B;AAuDD;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,wBAAwB,CAAC,CASnC"}
|
package/dist/test-runner.js
CHANGED
|
@@ -3,6 +3,7 @@ import * as nodePath from 'node:path';
|
|
|
3
3
|
import { buildContext } from '@shrkcrft/context';
|
|
4
4
|
import { buildTaskPacket } from "./task-packet.js";
|
|
5
5
|
import { rankKnowledgeEntries } from "./task-ranker.js";
|
|
6
|
+
import { contextTuningBoostFor } from "./context-tuning.js";
|
|
6
7
|
import { buildProjectOverview, renderOverviewText } from "./project-overview.js";
|
|
7
8
|
import { HELPERS } from "./helper-registry.js";
|
|
8
9
|
import { importModuleViaLoader } from '@shrkcrft/core';
|
|
@@ -58,10 +59,12 @@ export async function loadAgentContractTests(inspection) {
|
|
|
58
59
|
}
|
|
59
60
|
export function runContextTest(inspection, test) {
|
|
60
61
|
const overview = buildProjectOverview(inspection.workspace, inspection.config?.projectName);
|
|
62
|
+
const boostFor = contextTuningBoostFor(inspection, test.task);
|
|
61
63
|
const ctx = buildContext(inspection.knowledgeEntries, {
|
|
62
64
|
task: test.task,
|
|
63
65
|
maxTokens: test.maxTokens ?? 3500,
|
|
64
66
|
projectOverview: renderOverviewText(overview),
|
|
67
|
+
...(boostFor ? { boostFor } : {}),
|
|
65
68
|
});
|
|
66
69
|
const bodyIds = new Set();
|
|
67
70
|
for (const section of ctx.sections) {
|
package/dist/why-file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"why-file.d.ts","sourceRoot":"","sources":["../src/why-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"why-file.d.ts","sourceRoot":"","sources":["../src/why-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,eAAe,sBAAsB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAE7D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAA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AC,MAAM,EAAE,OAAO,eAAe,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,eAAe,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACxD,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,aAAa,EAAE,CAAC;IAC7C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,oBAAoB,GAAG,UAAU,CAuBtE"}
|
package/dist/why-file.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { existsSync, statSync } from 'node:fs';
|
|
17
17
|
import * as nodePath from 'node:path';
|
|
18
18
|
import { matchesAny } from '@shrkcrft/boundaries';
|
|
19
|
+
import { deriveApplicability } from '@shrkcrft/rules';
|
|
19
20
|
export const WHY_FILE_SCHEMA = 'sharkcraft.why/v1';
|
|
20
21
|
export function buildWhyReport(input) {
|
|
21
22
|
const limit = input.limit ?? 10;
|
|
@@ -131,6 +132,18 @@ function ruleReasonForFile(r, target, inferredPackage, inferredLayer) {
|
|
|
131
132
|
if (hit)
|
|
132
133
|
return `path pattern ${hit}`;
|
|
133
134
|
}
|
|
135
|
+
// 2b. Tag / metadata applicability — the SAME mapping `shrk rule-graph for
|
|
136
|
+
// <file>` uses (deriveApplicability): `metadata.appliesTo` globs
|
|
137
|
+
// (authoritative) or a conservative tag→path table (e.g. an `imports`-tagged
|
|
138
|
+
// rule → packages/**/*.ts). This is what makes `why` surface topical-but-real
|
|
139
|
+
// per-file rules that carry no explicit path reference, instead of an empty
|
|
140
|
+
// rules section. Kept consistent with the bridge so the two never diverge.
|
|
141
|
+
const appl = deriveApplicability({ tags: r.tags, metadata: r.metadata });
|
|
142
|
+
if (appl.source !== 'none') {
|
|
143
|
+
const hit = appl.patterns.find((g) => matchesAny(rel, [g]));
|
|
144
|
+
if (hit)
|
|
145
|
+
return appl.source === 'metadata' ? `appliesTo glob ${hit}` : `tag-mapped path ${hit}`;
|
|
146
|
+
}
|
|
134
147
|
// 3. Package reference / scope-or-tag equal to the inferred package or layer.
|
|
135
148
|
const labels = [...(r.scope ?? []), ...(r.tags ?? [])];
|
|
136
149
|
if (inferredPackage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/inspector",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.23",
|
|
4
4
|
"description": "SharkCraft inspector: project overview, doctor checks, AI-agent instructions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
46
|
-
"@shrkcrft/config": "^0.1.0-alpha.
|
|
47
|
-
"@shrkcrft/workspace": "^0.1.0-alpha.
|
|
48
|
-
"@shrkcrft/knowledge": "^0.1.0-alpha.
|
|
49
|
-
"@shrkcrft/rules": "^0.1.0-alpha.
|
|
50
|
-
"@shrkcrft/paths": "^0.1.0-alpha.
|
|
51
|
-
"@shrkcrft/templates": "^0.1.0-alpha.
|
|
52
|
-
"@shrkcrft/context": "^0.1.0-alpha.
|
|
53
|
-
"@shrkcrft/pipelines": "^0.1.0-alpha.
|
|
54
|
-
"@shrkcrft/packs": "^0.1.0-alpha.
|
|
55
|
-
"@shrkcrft/presets": "^0.1.0-alpha.
|
|
56
|
-
"@shrkcrft/boundaries": "^0.1.0-alpha.
|
|
57
|
-
"@shrkcrft/generator": "^0.1.0-alpha.
|
|
58
|
-
"@shrkcrft/importer": "^0.1.0-alpha.
|
|
59
|
-
"@shrkcrft/plugin-api": "^0.1.0-alpha.
|
|
60
|
-
"@shrkcrft/dashboard-api": "^0.1.0-alpha.
|
|
45
|
+
"@shrkcrft/core": "^0.1.0-alpha.23",
|
|
46
|
+
"@shrkcrft/config": "^0.1.0-alpha.23",
|
|
47
|
+
"@shrkcrft/workspace": "^0.1.0-alpha.23",
|
|
48
|
+
"@shrkcrft/knowledge": "^0.1.0-alpha.23",
|
|
49
|
+
"@shrkcrft/rules": "^0.1.0-alpha.23",
|
|
50
|
+
"@shrkcrft/paths": "^0.1.0-alpha.23",
|
|
51
|
+
"@shrkcrft/templates": "^0.1.0-alpha.23",
|
|
52
|
+
"@shrkcrft/context": "^0.1.0-alpha.23",
|
|
53
|
+
"@shrkcrft/pipelines": "^0.1.0-alpha.23",
|
|
54
|
+
"@shrkcrft/packs": "^0.1.0-alpha.23",
|
|
55
|
+
"@shrkcrft/presets": "^0.1.0-alpha.23",
|
|
56
|
+
"@shrkcrft/boundaries": "^0.1.0-alpha.23",
|
|
57
|
+
"@shrkcrft/generator": "^0.1.0-alpha.23",
|
|
58
|
+
"@shrkcrft/importer": "^0.1.0-alpha.23",
|
|
59
|
+
"@shrkcrft/plugin-api": "^0.1.0-alpha.23",
|
|
60
|
+
"@shrkcrft/dashboard-api": "^0.1.0-alpha.23",
|
|
61
61
|
"typescript": "^5.6.0"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|