vigiles 14.7.0 → 14.9.0

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.
Files changed (47) hide show
  1. package/dist/adapters/claude-code/agent-runtime.d.ts +2 -19
  2. package/dist/adapters/claude-code/agent-runtime.js +5 -30
  3. package/dist/adapters/claude-code/agent-tools.d.ts +20 -0
  4. package/dist/adapters/claude-code/agent-tools.js +40 -0
  5. package/dist/audit-report.d.ts +1 -1
  6. package/dist/audit-report.template.html +37 -32
  7. package/dist/audit-score.d.ts +1 -1
  8. package/dist/audit-score.js +20 -20
  9. package/dist/audit-verdict.d.ts +1 -1
  10. package/dist/audit-verdict.js +3 -3
  11. package/dist/core/assert-never.d.ts +9 -0
  12. package/dist/core/assert-never.js +14 -0
  13. package/dist/core/description-overlap.js +2 -2
  14. package/dist/core/effects.js +3 -3
  15. package/dist/core/hash.d.ts +1 -2
  16. package/dist/core/hash.js +6 -4
  17. package/dist/core/hook-block-ineffective.d.ts +55 -6
  18. package/dist/core/hook-block-ineffective.js +9 -14
  19. package/dist/core/mcp-contract-message.d.ts +22 -0
  20. package/dist/core/mcp-contract-message.js +29 -0
  21. package/dist/core/mcp.d.ts +4 -12
  22. package/dist/core/mcp.js +3 -14
  23. package/dist/core/ncd.d.ts +12 -0
  24. package/dist/core/ncd.js +50 -0
  25. package/dist/core/plugin-dir-layout.d.ts +5 -5
  26. package/dist/core/plugin-dir-layout.js +10 -22
  27. package/dist/core/proofs.d.ts +2 -11
  28. package/dist/core/proofs.js +4 -39
  29. package/dist/core/skill-resources.d.ts +3 -3
  30. package/dist/core/skill-resources.js +9 -8
  31. package/dist/leaderboard.d.ts +2 -51
  32. package/dist/leaderboard.js +20 -225
  33. package/dist/optimize.d.ts +1 -1
  34. package/dist/optimize.js +3 -3
  35. package/dist/posix-path.d.ts +40 -0
  36. package/dist/posix-path.js +293 -0
  37. package/dist/scan-core.d.ts +154 -0
  38. package/dist/scan-core.js +690 -0
  39. package/dist/scan-files.d.ts +28 -0
  40. package/dist/scan-files.js +489 -0
  41. package/dist/scan.d.ts +11 -34
  42. package/dist/scan.js +55 -668
  43. package/dist/score-core.d.ts +83 -0
  44. package/dist/score-core.js +236 -0
  45. package/dist/test-coverage-files.d.ts +11 -0
  46. package/dist/test-coverage-files.js +208 -0
  47. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Structural-health SCORING core — extracted as a NODE-FREE leaf.
3
+ *
4
+ * The scoring functions (`scoreReport`/`reportDeductions`/`computeIntegrityScore`/
5
+ * `gradeFor` + the penalty weights) are pure: they take a {@link ScanReport} and
6
+ * return numbers/labels, touching no filesystem. They lived in `leaderboard.ts`,
7
+ * but that module ALSO holds the node-only `rankPlugins`/`pluginLabel` (which call
8
+ * `scanPlugin` + `node:fs`), so importing ANY symbol from it eagerly pulled the
9
+ * whole `scan.ts` → `@ast-grep/napi` (a native binary) + `node:fs` chain into the
10
+ * graph — tainting `buildAuditReport` and blocking the in-browser audit engine
11
+ * (`scanFiles` is node-free, but the report BUILDER re-tainted it via
12
+ * audit-score/optimize/audit-verdict → leaderboard → scan).
13
+ *
14
+ * Splitting the pure core out here — exactly like `core/ncd.ts` was extracted from
15
+ * `proofs.ts` to keep `node:crypto` out of the browser graph — lets the report
16
+ * builder import scoring WITHOUT the node-only leaderboard code. `leaderboard.ts`
17
+ * re-exports these for its own consumers (rankPlugins/formatters), so nothing that
18
+ * imported them from `./leaderboard.js` breaks. The `ScanReport` import is
19
+ * TYPE-ONLY (elided at build), so no runtime `scan.ts` dependency enters this leaf.
20
+ * See src/scan-files.ts (BROWSER_ROOT) and research/report-view-and-browser-demo.md.
21
+ */
22
+ import type { ScanReport } from "./scan.js";
23
+ export interface PluginScore {
24
+ readonly dir: string;
25
+ readonly name: string;
26
+ /** 0–100 structural-health score (100 = no structural issues found). */
27
+ readonly score: number;
28
+ readonly grade: "A" | "B" | "C" | "D" | "F";
29
+ /** Human-readable deductions, worst first. */
30
+ readonly issues: readonly string[];
31
+ readonly report: ScanReport;
32
+ }
33
+ export declare const W_MISSING_HOOK = 15;
34
+ export declare const W_NO_DESCRIPTION = 10;
35
+ export declare const W_DANGLING_REF = 8;
36
+ export declare const W_OVERLAP = 8;
37
+ export declare const W_NO_CONTRACT = 5;
38
+ export declare const W_TRIFECTA = 10;
39
+ /**
40
+ * The one canonical, jargon-free finding string for a HARD lethal-trifecta unit —
41
+ * shared by the Safety category card (audit-score) AND the verdict sentence / overall
42
+ * deduction (reportDeductions here), so the plain-language copy can't drift between
43
+ * surfaces (one-detector-no-drift). It NAMES the three legs and the consequence in
44
+ * plain words instead of the old "holding all three lethal-trifecta legs
45
+ * (prompt-injection exfil path)" shorthand a first-time reader can't parse. The
46
+ * `(s)` placeholder is resolved by the caller's pluralizer against the count.
47
+ */
48
+ export declare const TRIFECTA_LABEL = "unit(s) can read data, reach the web, and run commands \u2014 the \"lethal trifecta\", so a prompt injection could exfiltrate secrets";
49
+ /** Map a 0–100 structural-health score to its letter grade (A ≥90 … F <60). */
50
+ export declare function gradeFor(score: number): PluginScore["grade"];
51
+ /** One deduction: a count, its per-item weight, and the label if non-zero. */
52
+ export interface Deduction {
53
+ readonly n: number;
54
+ readonly weight: number;
55
+ readonly label: string;
56
+ }
57
+ /**
58
+ * The COMPLETE graded-penalty list a report incurs — the single source of truth
59
+ * BOTH the leaderboard's single health number and the audit's category rings
60
+ * read, so the overall can never drift between the two surfaces. Each entry is a
61
+ * graded penalty; untested surfaces are deliberately ABSENT (they're advisory,
62
+ * surfaced separately, never scored).
63
+ */
64
+ export declare function reportDeductions(r: ScanReport): Deduction[];
65
+ /** True when a report has no loadable plugin surface at all (the empty machine). */
66
+ export declare function isEmptyMachine(r: ScanReport): boolean;
67
+ /**
68
+ * THE shared integrity score — `100 − Σ(all graded penalties)`, clamped to
69
+ * [0,100]. Both the leaderboard's single health number AND the audit's headline
70
+ * overall read this, so the two can never disagree (the summed model is the
71
+ * honest one — averaging rings would dilute a real problem). Returns the score
72
+ * plus the per-item deductions so callers render their own issue/finding lists.
73
+ */
74
+ export declare function computeIntegrityScore(deductions: readonly Deduction[]): {
75
+ score: number;
76
+ penalty: number;
77
+ };
78
+ /** Deterministic structural-health score for one scanned plugin. */
79
+ export declare function scoreReport(r: ScanReport): {
80
+ score: number;
81
+ issues: string[];
82
+ };
83
+ //# sourceMappingURL=score-core.d.ts.map
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRIFECTA_LABEL = exports.W_TRIFECTA = exports.W_NO_CONTRACT = exports.W_OVERLAP = exports.W_DANGLING_REF = exports.W_NO_DESCRIPTION = exports.W_MISSING_HOOK = void 0;
4
+ exports.gradeFor = gradeFor;
5
+ exports.reportDeductions = reportDeductions;
6
+ exports.isEmptyMachine = isEmptyMachine;
7
+ exports.computeIntegrityScore = computeIntegrityScore;
8
+ exports.scoreReport = scoreReport;
9
+ // Penalty weights — broken-at-runtime costs most, footguns less, nudges least.
10
+ // Exported so the category view (audit-score.ts) reuses the SAME weights and the
11
+ // two surfaces can never drift on a per-item cost.
12
+ exports.W_MISSING_HOOK = 15; // a hook script that doesn't exist → never runs
13
+ exports.W_NO_DESCRIPTION = 10; // a skill with no usable description → can't trigger
14
+ exports.W_DANGLING_REF = 8; // a referenced intra-plugin file that's missing → broken path
15
+ exports.W_OVERLAP = 8; // a description collision → the wrong skill fires
16
+ exports.W_NO_CONTRACT = 5; // generic small-footgun weight (disallowedTools typo, invalid model/color)
17
+ exports.W_TRIFECTA = 10; // a HARD lethal-trifecta contract (all three legs, explicit) → a prompt-injection exfil path. HALF the old 20: a DING, not a fail — a trifecta is a real risk worth surfacing in the grade, but official plugins ship the pattern by design, so it dents the score (e.g. feature-dev's 3 hard units → −30 → C) without a catastrophic F.
18
+ /**
19
+ * The one canonical, jargon-free finding string for a HARD lethal-trifecta unit —
20
+ * shared by the Safety category card (audit-score) AND the verdict sentence / overall
21
+ * deduction (reportDeductions here), so the plain-language copy can't drift between
22
+ * surfaces (one-detector-no-drift). It NAMES the three legs and the consequence in
23
+ * plain words instead of the old "holding all three lethal-trifecta legs
24
+ * (prompt-injection exfil path)" shorthand a first-time reader can't parse. The
25
+ * `(s)` placeholder is resolved by the caller's pluralizer against the count.
26
+ */
27
+ exports.TRIFECTA_LABEL = 'unit(s) can read data, reach the web, and run commands — the "lethal trifecta", so a prompt injection could exfiltrate secrets';
28
+ // Two things are advisory, NOT graded penalties (shown, never scored — see scoreReport):
29
+ // - untested surfaces — a hardening gap, not breakage.
30
+ // - an agent that inherits all tools (no `tools:` line) — see reportDeductions for why.
31
+ // - an inherits-all (severity "advisory") trifecta finding — shown by the Safety
32
+ // ring but never scored; only the HARD, explicit all-three-legs finding grades.
33
+ /** Map a 0–100 structural-health score to its letter grade (A ≥90 … F <60). */
34
+ function gradeFor(score) {
35
+ if (score >= 90)
36
+ return "A";
37
+ if (score >= 80)
38
+ return "B";
39
+ if (score >= 70)
40
+ return "C";
41
+ if (score >= 60)
42
+ return "D";
43
+ return "F";
44
+ }
45
+ /**
46
+ * The COMPLETE graded-penalty list a report incurs — the single source of truth
47
+ * BOTH the leaderboard's single health number and the audit's category rings
48
+ * read, so the overall can never drift between the two surfaces. Each entry is a
49
+ * graded penalty; untested surfaces are deliberately ABSENT (they're advisory,
50
+ * surfaced separately, never scored).
51
+ */
52
+ function reportDeductions(r) {
53
+ const missingHooks = r.hooks.filter((h) => h.status === "missing").length;
54
+ const noDesc = r.skills.filter((s) => !s.hasDescription).length;
55
+ const deadTools = r.agents.reduce((n, a) => n + a.toolIssues.length, 0);
56
+ const deadMcpTools = r.agents.reduce((n, a) => n + a.mcpToolIssues.length, 0);
57
+ const deadDisallowed = r.agents.reduce((n, a) => n + a.disallowedToolIssues.length, 0);
58
+ // HARD lethal-trifecta findings only — an EXPLICIT contract naming all three
59
+ // legs (a prompt-injection exfil path). Graded at W_TRIFECTA=10 (HALF the old
60
+ // 20): a DING that surfaces a real risk in the grade without a catastrophic F
61
+ // for an accepted design pattern official plugins ship. Advisory (inherits-all)
62
+ // trifecta findings are surfaced but NEVER graded (aligned with the inherits-all
63
+ // stance), so they're excluded here.
64
+ const hardTrifecta = r.trifectaFindings.filter((f) => f.finding.severity === "hard").length;
65
+ return [
66
+ {
67
+ n: hardTrifecta,
68
+ weight: exports.W_TRIFECTA,
69
+ label: exports.TRIFECTA_LABEL,
70
+ },
71
+ {
72
+ n: missingHooks,
73
+ weight: exports.W_MISSING_HOOK,
74
+ label: "hook script(s) MISSING",
75
+ },
76
+ {
77
+ n: r.hookEventIssues.length,
78
+ weight: exports.W_MISSING_HOOK,
79
+ label: "hook(s) on an unknown event (never fire)",
80
+ },
81
+ {
82
+ n: noDesc,
83
+ weight: exports.W_NO_DESCRIPTION,
84
+ label: "skill(s) with no usable description",
85
+ },
86
+ {
87
+ n: r.descriptionOverlaps.length,
88
+ weight: exports.W_OVERLAP,
89
+ label: "near-identical skill description(s) (wrong one fires)",
90
+ },
91
+ {
92
+ n: r.danglingRefs.length,
93
+ weight: exports.W_DANGLING_REF,
94
+ label: "broken intra-plugin reference(s)",
95
+ },
96
+ {
97
+ n: deadTools,
98
+ weight: exports.W_DANGLING_REF,
99
+ label: "unavailable agent tool(s) (typo / never-available)",
100
+ },
101
+ {
102
+ n: deadMcpTools,
103
+ weight: exports.W_DANGLING_REF,
104
+ label: "agent MCP tool(s) whose server isn't declared (can't resolve)",
105
+ },
106
+ {
107
+ n: deadDisallowed,
108
+ weight: exports.W_NO_CONTRACT,
109
+ label: "agent disallowedTools typo(s) that block nothing",
110
+ },
111
+ // NB: an agent that inherits all tools (no `tools:` line) is ADVISORY, not a
112
+ // graded penalty — it's surfaced by scoreReport / the Structure ring but never
113
+ // drags the score. WHY: omitting the `tools:` line is a near-universal,
114
+ // legitimate authoring style (a measured OSS sweep of 122 real plugins found
115
+ // 109 whose ONLY finding was this), so penalizing it makes the grade cry wolf
116
+ // on idiomatic subagents. A health score should mean "something is BROKEN", and
117
+ // a broad-by-default tool surface is a hardening/least-privilege NUDGE, not
118
+ // breakage. The count is re-derived where the advisory note is built.
119
+ {
120
+ n: r.frontmatterIssues.length,
121
+ weight: exports.W_NO_DESCRIPTION,
122
+ label: "surface(s) missing required frontmatter (name/description)",
123
+ },
124
+ {
125
+ n: r.frontmatterValueIssues.length,
126
+ weight: exports.W_NO_CONTRACT,
127
+ label: "agent(s) with an invalid model/color (typo → silent fallback)",
128
+ },
129
+ {
130
+ n: r.mcpIssues.length,
131
+ weight: exports.W_DANGLING_REF,
132
+ label: "MCP server(s) that can't start (no command/url)",
133
+ },
134
+ {
135
+ n: r.mcpHookIssues.length,
136
+ weight: exports.W_DANGLING_REF,
137
+ label: "mcp_tool hook(s) incomplete / targeting an undeclared server",
138
+ },
139
+ {
140
+ n: r.skillResourceIssues.length,
141
+ weight: exports.W_DANGLING_REF,
142
+ label: "skill bundled-resource ref(s) that don't resolve on disk",
143
+ },
144
+ {
145
+ n: r.skillFenceIssues.length,
146
+ weight: exports.W_NO_DESCRIPTION,
147
+ label: "invisible skill(s) (frontmatter with no opening `---` fence)",
148
+ },
149
+ {
150
+ n: r.pluginLayoutIssues.length,
151
+ weight: exports.W_NO_DESCRIPTION,
152
+ label: "functional dir(s) misplaced inside `.claude-plugin/` (invisible)",
153
+ },
154
+ {
155
+ n: r.hookBlockFindings.length,
156
+ weight: exports.W_MISSING_HOOK,
157
+ label: "hook(s) that look like they block but silently don't",
158
+ },
159
+ {
160
+ n: r.hookMatcherFindings.length,
161
+ weight: exports.W_MISSING_HOOK,
162
+ label: "hook matcher(s) that never fire (typo / wrong MCP form)",
163
+ },
164
+ // NB: delegationTrifecta (like the advisory per-unit/inherits-all trifecta) is a
165
+ // ⚠ RISK, surfaced but NOT graded — only the HARD per-unit trifecta above scores.
166
+ // NB: untested surfaces are NOT a penalty — an untested surface is a hardening
167
+ // gap, not breakage, so it never drags the health score (it's appended as an
168
+ // advisory note below). The score ranks what's BROKEN.
169
+ ];
170
+ }
171
+ /** True when a report has no loadable plugin surface at all (the empty machine). */
172
+ function isEmptyMachine(r) {
173
+ const surfaces = r.skills.length +
174
+ r.agents.length +
175
+ r.hooks.length +
176
+ r.inlineHooks +
177
+ r.commands;
178
+ return surfaces === 0 && !r.mcp;
179
+ }
180
+ /**
181
+ * THE shared integrity score — `100 − Σ(all graded penalties)`, clamped to
182
+ * [0,100]. Both the leaderboard's single health number AND the audit's headline
183
+ * overall read this, so the two can never disagree (the summed model is the
184
+ * honest one — averaging rings would dilute a real problem). Returns the score
185
+ * plus the per-item deductions so callers render their own issue/finding lists.
186
+ */
187
+ function computeIntegrityScore(deductions) {
188
+ let penalty = 0;
189
+ for (const d of deductions) {
190
+ if (d.n <= 0)
191
+ continue;
192
+ penalty += d.n * d.weight;
193
+ }
194
+ return { score: Math.max(0, 100 - penalty), penalty };
195
+ }
196
+ /** Resolve the terse "thing(s)" plural placeholder against a count:
197
+ * n===1 drops the "(s)" ("1 tool"); otherwise it becomes "s" ("3 tools").
198
+ * (Kept local — audit-score.ts has its own copy to avoid a circular import.) */
199
+ function pluralizeLabel(n, label) {
200
+ return label.replace(/\(s\)/g, n === 1 ? "" : "s");
201
+ }
202
+ /** Deterministic structural-health score for one scanned plugin. */
203
+ function scoreReport(r) {
204
+ // An empty/unloadable machine isn't healthy — it's a non-plugin or a broken
205
+ // load. A command-only or MCP-only plugin (commands/*.md or .mcp.json with no
206
+ // skills/agents/hooks) IS a legitimate plugin, though — Anthropic ships
207
+ // command-only plugins in its own marketplace — so it must NOT score 0.
208
+ const surfaces = r.skills.length + r.agents.length + r.hooks.length + r.commands;
209
+ if (surfaces === 0 && !r.mcp) {
210
+ return { score: 0, issues: ["no loadable plugin surface"] };
211
+ }
212
+ const deductions = reportDeductions(r);
213
+ const { score } = computeIntegrityScore(deductions);
214
+ const issues = [];
215
+ for (const d of deductions) {
216
+ if (d.n === 0)
217
+ continue;
218
+ issues.push(`${String(d.n)} ${pluralizeLabel(d.n, d.label)}`);
219
+ }
220
+ // Sort issues by cost (worst first) so the report leads with what matters.
221
+ issues.sort((a, b) => Number(b.split(" ")[0]) - Number(a.split(" ")[0]));
222
+ // Advisory notes are surfaced for visibility but DON'T affect the score, so they
223
+ // come AFTER the real (score-affecting) issues:
224
+ // - inherit-all (no tool contract): a least-privilege NUDGE, not breakage —
225
+ // see reportDeductions for the full rationale.
226
+ // - untested surfaces: a hardening gap, not breakage.
227
+ const noContract = r.agents.filter((a) => a.tools === null).length;
228
+ if (noContract > 0) {
229
+ issues.push(`${String(noContract)} ${pluralizeLabel(noContract, "agent(s) inherit all tools (no contract) (advisory)")}`);
230
+ }
231
+ if (r.untested > 0) {
232
+ issues.push(`${String(r.untested)} ${pluralizeLabel(r.untested, "untested surface(s) (advisory)")}`);
233
+ }
234
+ return { score, issues };
235
+ }
236
+ //# sourceMappingURL=score-core.js.map
@@ -0,0 +1,11 @@
1
+ import type { PluginLayout } from "./core/layout.js";
2
+ import type { Surface } from "./test-coverage.js";
3
+ /**
4
+ * The untested harness surfaces (skills / agents / hooks) in a file map — the
5
+ * browser-safe twin of `findUntestedSurfaces`, returning only the `untested` list
6
+ * (`scanFiles` needs the count). Same coverage rules as the disk detector.
7
+ */
8
+ export declare function findUntestedSurfacesInFiles(files: Record<string, string>, layout: PluginLayout): {
9
+ untested: Surface[];
10
+ };
11
+ //# sourceMappingURL=test-coverage-files.d.ts.map
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findUntestedSurfacesInFiles = findUntestedSurfacesInFiles;
4
+ /**
5
+ * Browser-safe twin of `findUntestedSurfaces` (src/test-coverage.ts) — the same
6
+ * untested-surface detection over an in-memory repo-relative file map instead of
7
+ * a disk walk. `findUntestedSurfaces` globs the filesystem; this reimplements each
8
+ * of its `globSync` calls as an `Object.keys(files).filter(...)` over the map, so
9
+ * `scanFiles` reaches the SAME `untested` count with no disk I/O.
10
+ *
11
+ * Mirrors the disk detector exactly: the skill/agent surface globs (both the plain
12
+ * and the materialize-root form), the hook-script discovery from the
13
+ * manifest/settings/`.local` settings, the test-file globs (harness/eval/test
14
+ * suffixes) with the same ignore set, the `vigiles:ignore-test` exemption, and the
15
+ * colocation + content-reference coverage rules. See the parity test in
16
+ * src/scan-files.test.ts.
17
+ */
18
+ const posix_path_js_1 = require("./posix-path.js");
19
+ // Mirrors src/test-coverage.ts constants.
20
+ const DEFAULT_TEST_SUFFIXES = [
21
+ ".harness.mjs",
22
+ ".eval.mjs",
23
+ ".test.ts",
24
+ ".test.mts",
25
+ ".test.cts",
26
+ ".test.js",
27
+ ".test.mjs",
28
+ ".test.cjs",
29
+ ];
30
+ const IGNORE_MARKER = "vigiles:ignore-test";
31
+ const SCRIPT_RE = /[\w./${}@-]+\.(?:sh|mjs|cjs|js|ts|py|rb)/g;
32
+ /** Mirror of the DEFAULT_IGNORE globs (root-anchored), as a key predicate. */
33
+ function isIgnored(key) {
34
+ return /^(?:node_modules|dist|\.vigiles|\.git)\//.test(key);
35
+ }
36
+ /** Escape a literal path segment for use inside a RegExp. */
37
+ function escapeRe(s) {
38
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
39
+ }
40
+ /** The two prefixes a surface dir can occupy (plain + materialize-root form). */
41
+ function surfacePrefixes(dir, materializeRoot) {
42
+ if (!dir)
43
+ return [];
44
+ const matForm = materializeRoot ? `${materializeRoot}/${dir}` : dir;
45
+ return [...new Set([dir, matForm])];
46
+ }
47
+ /** Keys matching `<prefix>/<leafRe>` for any prefix, deduped + sorted (globSync order). */
48
+ function matchSurface(files, prefixes, leafRe) {
49
+ const found = new Set();
50
+ for (const prefix of prefixes) {
51
+ const re = new RegExp(`^${escapeRe(prefix)}/${leafRe}$`);
52
+ for (const key of Object.keys(files)) {
53
+ if (isIgnored(key))
54
+ continue;
55
+ if (re.test(key))
56
+ found.add(key);
57
+ }
58
+ }
59
+ return [...found].sort();
60
+ }
61
+ function discoverSkills(files, layout) {
62
+ const out = [];
63
+ if (layout.skillDir) {
64
+ const prefixes = surfacePrefixes(layout.skillDir, layout.materializeRoot);
65
+ for (const path of matchSurface(files, prefixes, "[^/]+/SKILL\\.md")) {
66
+ const name = (0, posix_path_js_1.basename)((0, posix_path_js_1.dirname)(path));
67
+ const content = files[path];
68
+ out.push({
69
+ kind: "skill",
70
+ path,
71
+ name,
72
+ tokens: [`${layout.skillDir}/${name}`, `:${name}`],
73
+ ignored: content.includes(IGNORE_MARKER),
74
+ });
75
+ }
76
+ }
77
+ // Single-skill-directory target: a bare `SKILL.md` at the repo root.
78
+ if (Object.prototype.hasOwnProperty.call(files, "SKILL.md")) {
79
+ const name = "SKILL"; // browser has no real base dir name (see BROWSER_ROOT).
80
+ const content = files["SKILL.md"];
81
+ out.push({
82
+ kind: "skill",
83
+ path: "SKILL.md",
84
+ name,
85
+ tokens: [`${layout.skillDir}/${name}`, `:${name}`],
86
+ ignored: content.includes(IGNORE_MARKER),
87
+ });
88
+ }
89
+ return out;
90
+ }
91
+ function discoverAgents(files, layout) {
92
+ const out = [];
93
+ if (!layout.agentDir)
94
+ return out;
95
+ const prefixes = surfacePrefixes(layout.agentDir, layout.materializeRoot);
96
+ for (const path of matchSurface(files, prefixes, "[^/]+\\.md")) {
97
+ if (path.endsWith(".spec.ts"))
98
+ continue;
99
+ const content = files[path];
100
+ const name = (0, posix_path_js_1.basename)(path, ".md");
101
+ const dir = (0, posix_path_js_1.dirname)(path);
102
+ out.push({
103
+ kind: "agent",
104
+ path,
105
+ name,
106
+ tokens: [`${dir}/${name}`],
107
+ ignored: content.includes(IGNORE_MARKER),
108
+ });
109
+ }
110
+ return out;
111
+ }
112
+ /** Hook-script paths referenced from a manifest's `hooks` block (file hooks only). */
113
+ function hookScripts(files, manifest, pluginRootToken) {
114
+ const text = files[manifest];
115
+ if (text === undefined)
116
+ return [];
117
+ let hooks;
118
+ try {
119
+ hooks = JSON.parse(text).hooks;
120
+ }
121
+ catch {
122
+ return [];
123
+ }
124
+ if (hooks === undefined)
125
+ return [];
126
+ const raw = JSON.stringify(hooks);
127
+ const unbraced = pluginRootToken.replace(/^\$\{(.+)\}$/, "$$$1");
128
+ const scripts = new Set();
129
+ for (const m of raw.matchAll(SCRIPT_RE)) {
130
+ const rel = m[0]
131
+ .replaceAll(pluginRootToken, "")
132
+ .replaceAll(unbraced, "")
133
+ .replace(/^\/+/, "")
134
+ .replace(/^\.\//, "");
135
+ if (Object.prototype.hasOwnProperty.call(files, rel))
136
+ scripts.add(rel);
137
+ }
138
+ return [...scripts];
139
+ }
140
+ function discoverHooks(files, layout) {
141
+ const scripts = new Set();
142
+ const localSettings = layout.settingsPath.replace(/(\.[^./]+)$/, ".local$1");
143
+ const manifests = [
144
+ ...new Set([layout.manifestPath, layout.settingsPath, localSettings]),
145
+ ];
146
+ for (const m of manifests) {
147
+ for (const s of hookScripts(files, m, layout.pluginRootToken)) {
148
+ scripts.add(s);
149
+ }
150
+ }
151
+ return [...scripts].sort().map((path) => ({
152
+ kind: "hook",
153
+ path,
154
+ name: (0, posix_path_js_1.basename)(path).replace(/\.[^.]+$/, ""),
155
+ tokens: [path],
156
+ ignored: false,
157
+ }));
158
+ }
159
+ function discoverTests(files) {
160
+ const out = [];
161
+ for (const [path, content] of Object.entries(files)) {
162
+ if (isIgnored(path))
163
+ continue;
164
+ if (DEFAULT_TEST_SUFFIXES.some((s) => path.endsWith(s))) {
165
+ out.push({ path, content });
166
+ }
167
+ }
168
+ return out;
169
+ }
170
+ /** Mirror of test-coverage.ts `isColocated`. */
171
+ function isColocated(surface, testPath) {
172
+ if (surface.kind === "skill") {
173
+ const dir = (0, posix_path_js_1.dirname)(surface.path);
174
+ return dir === "."
175
+ ? (0, posix_path_js_1.dirname)(testPath) === "."
176
+ : testPath.startsWith(`${dir}/`);
177
+ }
178
+ return ((0, posix_path_js_1.dirname)(testPath) === (0, posix_path_js_1.dirname)(surface.path) &&
179
+ (0, posix_path_js_1.basename)(testPath).startsWith(`${surface.name}.`));
180
+ }
181
+ function isCovered(surface, tests) {
182
+ for (const t of tests) {
183
+ if (t.path === surface.path)
184
+ continue;
185
+ if (isColocated(surface, t.path))
186
+ return true;
187
+ if (surface.tokens.some((tok) => t.content.includes(tok)))
188
+ return true;
189
+ }
190
+ return false;
191
+ }
192
+ /**
193
+ * The untested harness surfaces (skills / agents / hooks) in a file map — the
194
+ * browser-safe twin of `findUntestedSurfaces`, returning only the `untested` list
195
+ * (`scanFiles` needs the count). Same coverage rules as the disk detector.
196
+ */
197
+ function findUntestedSurfacesInFiles(files, layout) {
198
+ const surfaces = [
199
+ ...discoverSkills(files, layout),
200
+ ...discoverAgents(files, layout),
201
+ ...discoverHooks(files, layout),
202
+ ];
203
+ const considered = surfaces.filter((s) => !s.ignored);
204
+ const tests = discoverTests(files);
205
+ const untested = considered.filter((s) => !isCovered(s, tests));
206
+ return { untested };
207
+ }
208
+ //# sourceMappingURL=test-coverage-files.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigiles",
3
- "version": "14.7.0",
3
+ "version": "14.9.0",
4
4
  "description": "Lint & test the harness your AI agent runs on — verify the references in your CLAUDE.md / AGENTS.md and test that your hooks and skills actually work.",
5
5
  "keywords": [
6
6
  "claude-code",