@neuralaxis/vibedoctor 0.2.0 → 0.2.2

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 (80) hide show
  1. package/README.md +135 -23
  2. package/dist/adapters/biome.js +136 -21
  3. package/dist/adapters/flowDoctor.d.ts +7 -0
  4. package/dist/adapters/flowDoctor.js +195 -0
  5. package/dist/adapters/gitleaks.js +4 -2
  6. package/dist/adapters/index.d.ts +1 -0
  7. package/dist/adapters/index.js +3 -1
  8. package/dist/adapters/osvScanner.js +140 -19
  9. package/dist/adapters/presidio.js +3 -1
  10. package/dist/adapters/ruff.js +7 -3
  11. package/dist/adapters/shared.d.ts +4 -0
  12. package/dist/cli/commands/init.js +112 -50
  13. package/dist/cli/commands/privacyReview.js +3 -4
  14. package/dist/cli/commands/scan.d.ts +6 -0
  15. package/dist/cli/commands/scan.js +16 -2
  16. package/dist/cli/commands/setup.d.ts +13 -17
  17. package/dist/cli/commands/setup.js +138 -200
  18. package/dist/cli/index.js +4 -4
  19. package/dist/core/agentDiagnosis.d.ts +39 -0
  20. package/dist/core/agentDiagnosis.js +96 -0
  21. package/dist/core/capability.d.ts +92 -0
  22. package/dist/core/capability.js +122 -0
  23. package/dist/core/config.d.ts +47 -0
  24. package/dist/core/config.js +134 -3
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +29 -1
  28. package/dist/core/engine.js +510 -126
  29. package/dist/core/executable.d.ts +18 -0
  30. package/dist/core/executable.js +137 -0
  31. package/dist/core/fileRole.d.ts +24 -0
  32. package/dist/core/fileRole.js +125 -0
  33. package/dist/core/finding.d.ts +125 -1
  34. package/dist/core/finding.js +70 -8
  35. package/dist/core/findingCorrelator.d.ts +19 -0
  36. package/dist/core/findingCorrelator.js +112 -0
  37. package/dist/core/findingNormalizer.d.ts +33 -0
  38. package/dist/core/findingNormalizer.js +172 -0
  39. package/dist/core/managedTools.d.ts +25 -0
  40. package/dist/core/managedTools.js +186 -0
  41. package/dist/core/projectDetector.d.ts +13 -0
  42. package/dist/core/projectDetector.js +100 -15
  43. package/dist/core/relevance.d.ts +87 -0
  44. package/dist/core/relevance.js +367 -0
  45. package/dist/core/repoGraph.d.ts +62 -0
  46. package/dist/core/repoGraph.js +408 -0
  47. package/dist/core/riskRanker.d.ts +6 -0
  48. package/dist/core/riskRanker.js +127 -0
  49. package/dist/core/scanContext.d.ts +26 -0
  50. package/dist/core/scanContext.js +44 -0
  51. package/dist/core/scanPlanner.d.ts +13 -0
  52. package/dist/core/scanPlanner.js +66 -38
  53. package/dist/core/semverLite.d.ts +27 -0
  54. package/dist/core/semverLite.js +163 -0
  55. package/dist/core/suppressions.d.ts +96 -0
  56. package/dist/core/suppressions.js +302 -0
  57. package/dist/core/toolRegistry.d.ts +58 -0
  58. package/dist/core/toolRegistry.js +254 -0
  59. package/dist/core/toolRunner.d.ts +27 -2
  60. package/dist/core/toolRunner.js +79 -93
  61. package/dist/core/toolRuntime.d.ts +40 -0
  62. package/dist/core/toolRuntime.js +417 -0
  63. package/dist/core/toolVerification.d.ts +89 -0
  64. package/dist/core/toolVerification.js +425 -0
  65. package/dist/dpdp/collectors/optionalScanners.js +120 -30
  66. package/dist/dpdp/findings.d.ts +33 -3
  67. package/dist/dpdp/findings.js +191 -4
  68. package/dist/dpdp/scan.js +2 -2
  69. package/dist/dpdp/scoring.d.ts +14 -4
  70. package/dist/dpdp/scoring.js +34 -8
  71. package/dist/dpdp/types.d.ts +19 -1
  72. package/dist/index.d.ts +5 -0
  73. package/dist/index.js +5 -0
  74. package/dist/reporters/agent.d.ts +1 -1
  75. package/dist/reporters/agent.js +7 -0
  76. package/dist/reporters/html.js +57 -13
  77. package/dist/reporters/json.js +7 -1
  78. package/dist/reporters/markdown.js +46 -4
  79. package/dist/reporters/sarif.js +54 -5
  80. package/package.json +80 -80
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SUPPRESSIONS_TEMPLATE = exports.SUPPRESSIONS_FILE = void 0;
7
+ exports.loadSuppressions = loadSuppressions;
8
+ exports.applySuppressions = applySuppressions;
9
+ exports.renderSuppressionLines = renderSuppressionLines;
10
+ const node_fs_1 = require("node:fs");
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const yaml_1 = __importDefault(require("yaml"));
13
+ const minimatch_1 = require("minimatch");
14
+ const finding_1 = require("./finding");
15
+ /**
16
+ * Acknowledgement of findings that are known and accepted, with a reason and an
17
+ * expiry date.
18
+ *
19
+ * The only existing lever was the baseline, which answers "was this here
20
+ * before?" and nothing else. There was no way to say "this is a synthetic
21
+ * fixture", "we accept this risk until the Q3 migration", or "this is a false
22
+ * positive because the identifier is a cache key, not a credential" — so the
23
+ * same rejected findings came back every scan and users learned to ignore whole
24
+ * categories. A suppression here must carry a rationale, and one with an expiry
25
+ * stops hiding its findings the day it lapses rather than quietly living forever.
26
+ */
27
+ exports.SUPPRESSIONS_FILE = ".vibedoctor/suppressions.yml";
28
+ const VALID_CLASSIFICATIONS = new Set([
29
+ "false_positive",
30
+ "accepted_risk",
31
+ "deferred",
32
+ "fixture"
33
+ ]);
34
+ const MIN_REASON_LENGTH = 12;
35
+ function asStringArray(value) {
36
+ if (!Array.isArray(value)) {
37
+ return typeof value === "string" ? [value] : undefined;
38
+ }
39
+ const items = value.filter((item) => typeof item === "string");
40
+ return items.length > 0 ? items : undefined;
41
+ }
42
+ function parseRule(raw, index) {
43
+ if (typeof raw !== "object" || raw === null) {
44
+ return { id: `#${index + 1}`, problem: "Entry is not a mapping." };
45
+ }
46
+ const record = raw;
47
+ const id = typeof record.id === "string" && record.id.trim() ? record.id.trim() : `#${index + 1}`;
48
+ const reason = typeof record.reason === "string" ? record.reason.trim() : "";
49
+ // A suppression without a stated reason is indistinguishable from forgetting
50
+ // why something was hidden, which is the problem this file exists to solve.
51
+ if (reason.length < MIN_REASON_LENGTH) {
52
+ return {
53
+ id,
54
+ problem: `A reason of at least ${MIN_REASON_LENGTH} characters is required explaining why this is acceptable.`
55
+ };
56
+ }
57
+ const classification = record.classification ?? record.kind;
58
+ if (typeof classification !== "string" || !VALID_CLASSIFICATIONS.has(classification)) {
59
+ return {
60
+ id,
61
+ problem: `classification must be one of ${Array.from(VALID_CLASSIFICATIONS).join(", ")}.`
62
+ };
63
+ }
64
+ const rawMatch = (record.match ?? record.matches ?? {});
65
+ const match = {
66
+ tools: asStringArray(rawMatch.tools ?? rawMatch.sources ?? rawMatch.tool),
67
+ paths: asStringArray(rawMatch.paths ?? rawMatch.path ?? rawMatch.files),
68
+ rules: asStringArray(rawMatch.rules ?? rawMatch.rule ?? rawMatch.titles),
69
+ categories: asStringArray(rawMatch.categories ?? rawMatch.category),
70
+ fingerprints: asStringArray(rawMatch.fingerprints ?? rawMatch.fingerprint ?? record.fingerprints)
71
+ };
72
+ // Without at least one criterion the rule would hide the entire report.
73
+ if (!match.tools && !match.paths && !match.rules && !match.categories && !match.fingerprints) {
74
+ return {
75
+ id,
76
+ problem: "At least one match criterion (tools, paths, rules, categories, or fingerprints) is required."
77
+ };
78
+ }
79
+ const expiresRaw = record.expires ?? record.expiresAt ?? record.expires_at;
80
+ let expiresAt;
81
+ if (expiresRaw !== undefined && expiresRaw !== null) {
82
+ const parsed = expiresRaw instanceof Date ? expiresRaw : new Date(String(expiresRaw));
83
+ if (Number.isNaN(parsed.getTime())) {
84
+ return { id, problem: `expires must be a date (got "${String(expiresRaw)}").` };
85
+ }
86
+ expiresAt = parsed.toISOString().slice(0, 10);
87
+ }
88
+ return {
89
+ id,
90
+ reason,
91
+ classification: classification,
92
+ owner: typeof record.owner === "string" ? record.owner : undefined,
93
+ expiresAt,
94
+ match
95
+ };
96
+ }
97
+ function isInvalid(value) {
98
+ return "problem" in value;
99
+ }
100
+ async function loadSuppressions(root, file = exports.SUPPRESSIONS_FILE) {
101
+ const absolute = node_path_1.default.join(root, file);
102
+ let content;
103
+ try {
104
+ content = await node_fs_1.promises.readFile(absolute, "utf8");
105
+ }
106
+ catch {
107
+ return { file, rules: [], invalid: [] };
108
+ }
109
+ let parsed;
110
+ try {
111
+ parsed = file.endsWith(".json") ? JSON.parse(content) : yaml_1.default.parse(content);
112
+ }
113
+ catch (error) {
114
+ return {
115
+ file,
116
+ rules: [],
117
+ invalid: [{ id: file, problem: `Could not parse: ${error instanceof Error ? error.message : String(error)}` }]
118
+ };
119
+ }
120
+ const record = (parsed ?? {});
121
+ const entries = record.suppressions ?? record.acknowledgements ?? record.rules;
122
+ if (!Array.isArray(entries)) {
123
+ return entries === undefined
124
+ ? { file, rules: [], invalid: [] }
125
+ : { file, rules: [], invalid: [{ id: file, problem: "`suppressions` must be a list." }] };
126
+ }
127
+ const parsedRules = entries.map(parseRule);
128
+ return {
129
+ file,
130
+ rules: parsedRules.filter((rule) => !isInvalid(rule)),
131
+ invalid: parsedRules.filter(isInvalid)
132
+ };
133
+ }
134
+ function compile(rule, now) {
135
+ return {
136
+ rule,
137
+ pathMatchers: rule.match.paths?.map((pattern) => new minimatch_1.Minimatch(pattern, { dot: true })),
138
+ expired: rule.expiresAt !== undefined && new Date(`${rule.expiresAt}T23:59:59Z`).getTime() < now.getTime()
139
+ };
140
+ }
141
+ function matches(compiled, finding, fingerprint) {
142
+ const { match } = compiled.rule;
143
+ // Every declared criterion must hold, so rules narrow rather than widen. A
144
+ // fingerprint is a criterion like any other: when it is listed alongside a
145
+ // path or tool, a fingerprint that collides or goes stale must not be able to
146
+ // suppress something the rest of the rule excludes.
147
+ if (match.fingerprints && !match.fingerprints.includes(fingerprint)) {
148
+ return false;
149
+ }
150
+ if (match.tools && !match.tools.includes(finding.source)) {
151
+ return false;
152
+ }
153
+ if (match.categories && !match.categories.includes(finding.category)) {
154
+ return false;
155
+ }
156
+ if (compiled.pathMatchers) {
157
+ const file = finding.file;
158
+ if (!file || !compiled.pathMatchers.some((matcher) => matcher.match(file))) {
159
+ return false;
160
+ }
161
+ }
162
+ if (match.rules) {
163
+ const haystack = `${finding.title} ${finding.evidence?.toolRawId ?? ""}`.toLowerCase();
164
+ if (!match.rules.some((rule) => haystack.includes(rule.toLowerCase()))) {
165
+ return false;
166
+ }
167
+ }
168
+ // A rule with no criteria at all would match everything; parsing rejects those,
169
+ // and this guards against one slipping through.
170
+ return Boolean(match.tools || match.categories || match.paths || match.rules || match.fingerprints);
171
+ }
172
+ /**
173
+ * Applies suppressions to findings. Expired rules do not suppress; instead their
174
+ * findings are marked `resurfaced` so a lapsed acknowledgement is visible rather
175
+ * than being mistaken for a new regression.
176
+ */
177
+ function applySuppressions(findings, loaded, options = {}) {
178
+ const now = options.now ?? new Date();
179
+ // Enforced here rather than at parse time because whether a permanent
180
+ // acknowledgement is acceptable is a policy question the config answers.
181
+ const invalid = [...loaded.invalid];
182
+ const usable = [];
183
+ for (const rule of loaded.rules) {
184
+ if (options.requireExpiry && !rule.expiresAt) {
185
+ invalid.push({
186
+ id: rule.id,
187
+ problem: "An expiry date is required (suppressions.require_expiry is on), so this rule was not applied."
188
+ });
189
+ continue;
190
+ }
191
+ usable.push(rule);
192
+ }
193
+ const compiled = usable.map((rule) => compile(rule, now));
194
+ const hits = {};
195
+ const expiredHits = {};
196
+ const kept = [];
197
+ const suppressed = [];
198
+ let resurfaced = 0;
199
+ for (const finding of findings) {
200
+ const fingerprint = (0, finding_1.fingerprintFinding)(finding);
201
+ const hit = compiled.find((candidate) => matches(candidate, finding, fingerprint));
202
+ if (!hit) {
203
+ kept.push(finding);
204
+ continue;
205
+ }
206
+ const tally = hit.expired ? expiredHits : hits;
207
+ tally[hit.rule.id] = (tally[hit.rule.id] ?? 0) + 1;
208
+ const suppression = {
209
+ ruleId: hit.rule.id,
210
+ classification: hit.rule.classification,
211
+ reason: hit.rule.reason,
212
+ owner: hit.rule.owner,
213
+ expiresAt: hit.rule.expiresAt,
214
+ expired: hit.expired
215
+ };
216
+ if (hit.expired) {
217
+ resurfaced += 1;
218
+ kept.push({
219
+ ...finding,
220
+ suppression,
221
+ baselineState: "resurfaced",
222
+ // Surface the lapse in the message itself; a report reader should not
223
+ // have to cross-reference the suppressions file to understand why this
224
+ // reappeared.
225
+ message: `${finding.message} (suppression "${hit.rule.id}" expired ${hit.rule.expiresAt})`
226
+ });
227
+ continue;
228
+ }
229
+ suppressed.push({ ...finding, suppression });
230
+ }
231
+ const active = compiled.filter((candidate) => !candidate.expired).map((candidate) => candidate.rule);
232
+ const expired = compiled.filter((candidate) => candidate.expired).map((candidate) => candidate.rule);
233
+ return {
234
+ findings: kept,
235
+ suppressed,
236
+ report: {
237
+ file: loaded.file,
238
+ active,
239
+ expired,
240
+ invalid,
241
+ permanent: active.filter((rule) => !rule.expiresAt).map((rule) => rule.id),
242
+ hits,
243
+ expiredHits,
244
+ // A lapsed rule that matched is still in use, so it is not dead weight to
245
+ // clean up — only a rule that matched nothing is.
246
+ unused: usable.filter((rule) => !hits[rule.id] && !expiredHits[rule.id]).map((rule) => rule.id),
247
+ resurfaced
248
+ }
249
+ };
250
+ }
251
+ function renderSuppressionLines(report) {
252
+ const lines = [];
253
+ const suppressedTotal = Object.values(report.hits).reduce((sum, count) => sum + count, 0);
254
+ if (suppressedTotal > 0) {
255
+ lines.push(`Suppressed: ${suppressedTotal} finding(s) via ${Object.keys(report.hits).length} acknowledgement(s)`);
256
+ if (report.scopeNote) {
257
+ lines.push(`- ${report.scopeNote}`);
258
+ }
259
+ for (const [ruleId, count] of Object.entries(report.hits)) {
260
+ const rule = report.active.find((candidate) => candidate.id === ruleId);
261
+ const expiry = rule?.expiresAt ? `expires ${rule.expiresAt}` : "no expiry";
262
+ lines.push(`- ${ruleId}: ${count} finding(s) — ${rule?.reason ?? "reason unavailable"} (${expiry})`);
263
+ }
264
+ }
265
+ if (report.expired.length > 0) {
266
+ lines.push(`Expired acknowledgements: ${report.expired
267
+ .map((rule) => {
268
+ const count = report.expiredHits[rule.id] ?? 0;
269
+ return `${rule.id} (${rule.expiresAt}${count > 0 ? `, ${count} finding(s) shown again` : ""})`;
270
+ })
271
+ .join(", ")} — their findings are no longer hidden.`);
272
+ }
273
+ if (report.invalid.length > 0) {
274
+ lines.push(`Rejected acknowledgements in ${report.file}:`);
275
+ for (const invalid of report.invalid) {
276
+ lines.push(`- ${invalid.id}: ${invalid.problem}`);
277
+ }
278
+ }
279
+ if (report.permanent.length > 0) {
280
+ lines.push(`Permanent acknowledgements (no expiry): ${report.permanent.join(", ")}`);
281
+ }
282
+ if (report.unused.length > 0) {
283
+ lines.push(`Acknowledgements that matched nothing: ${report.unused.join(", ")}`);
284
+ }
285
+ return lines;
286
+ }
287
+ exports.SUPPRESSIONS_TEMPLATE = `# VibeDoctor acknowledgements.
288
+ #
289
+ # Each entry hides findings that are known and accepted. A reason is required,
290
+ # and an expiry date is strongly recommended: when it passes, the findings come
291
+ # back marked "resurfaced" instead of staying hidden indefinitely.
292
+ version: 1
293
+ suppressions:
294
+ # - id: fixture-credentials
295
+ # reason: Synthetic credentials in test fixtures, never used against real systems.
296
+ # classification: fixture # false_positive | accepted_risk | deferred | fixture
297
+ # owner: platform-team
298
+ # expires: 2026-12-31
299
+ # match:
300
+ # tools: [gitleaks]
301
+ # paths: ["fixtures/**"]
302
+ `;
@@ -0,0 +1,58 @@
1
+ import type { ProjectLanguage } from "./projectDetector";
2
+ /**
3
+ * The single description of every tool VibeDoctor can run.
4
+ *
5
+ * Setup and the scanner used to keep separate lists, which let them disagree
6
+ * about what a tool is called, how to find it, and whether it was installed.
7
+ * Both now read this registry, so a tool that setup claims to have installed is
8
+ * by construction the same tool the scanner looks for.
9
+ */
10
+ export type ToolEcosystem = "npm" | "python" | "manual" | "built-in";
11
+ export type ToolPriority = "essential" | "recommended";
12
+ export type RuntimeEngine = "node" | "python";
13
+ export type ToolRegistryEntry = {
14
+ /** Matches the adapter id and the `source` on findings the tool produces. */
15
+ id: string;
16
+ ecosystem: ToolEcosystem;
17
+ priority: ToolPriority;
18
+ reason: string;
19
+ /** Command name the scanner invokes. Absent for built-in checks. */
20
+ executable?: string;
21
+ /** Package to install, when the ecosystem has a package manager. */
22
+ packageName?: string;
23
+ /** Arguments that make the tool report its version and exit successfully. */
24
+ probeArgs?: string[];
25
+ /** Extracts a version string from probe output; defaults to the first x.y.z found. */
26
+ versionPattern?: RegExp;
27
+ /**
28
+ * Runtime the tool executes on. Used to preflight compatibility before a tool
29
+ * is installed into an interpreter that cannot run it.
30
+ */
31
+ runtime?: RuntimeEngine;
32
+ languages?: ProjectLanguage[];
33
+ requiresLockfile?: boolean;
34
+ installHint?: string;
35
+ /**
36
+ * Set when the tool has no executable of its own and is exercised through
37
+ * another runtime (Presidio runs as a Python module, not a binary).
38
+ */
39
+ moduleProbe?: {
40
+ runtime: RuntimeEngine;
41
+ module: string;
42
+ };
43
+ };
44
+ export declare const TOOL_REGISTRY: ToolRegistryEntry[];
45
+ export declare function getToolEntry(id: string): ToolRegistryEntry | undefined;
46
+ /** Command names the scanner may invoke, for availability probing. */
47
+ export declare function registryExecutables(): string[];
48
+ export declare function toolsForPriority(priority: ToolPriority | "all"): ToolRegistryEntry[];
49
+ export declare function installHintFor(entry: ToolRegistryEntry): string;
50
+ /**
51
+ * Reads the runtime requirement a tool declares for itself, from the package
52
+ * metadata of the copy that is actually installed. Hardcoding "knip needs Node
53
+ * 20.19" would go stale on the next release; the package says so itself.
54
+ */
55
+ export declare function readDeclaredNodeRequirement(root: string, packageName: string | undefined): Promise<{
56
+ range?: string;
57
+ source?: string;
58
+ }>;
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.TOOL_REGISTRY = void 0;
7
+ exports.getToolEntry = getToolEntry;
8
+ exports.registryExecutables = registryExecutables;
9
+ exports.toolsForPriority = toolsForPriority;
10
+ exports.installHintFor = installHintFor;
11
+ exports.readDeclaredNodeRequirement = readDeclaredNodeRequirement;
12
+ const node_fs_1 = require("node:fs");
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ exports.TOOL_REGISTRY = [
15
+ {
16
+ id: "custom-leftovers",
17
+ ecosystem: "built-in",
18
+ priority: "essential",
19
+ reason: "Finds stale TODOs, commented-out code, legacy fallback paths, and AI leftovers without any external install."
20
+ },
21
+ {
22
+ id: "custom-dead-chain",
23
+ ecosystem: "built-in",
24
+ priority: "essential",
25
+ reason: "Finds isolated file clusters after external dead-code tools report candidates."
26
+ },
27
+ {
28
+ id: "custom-refactor",
29
+ ecosystem: "built-in",
30
+ priority: "essential",
31
+ reason: "Finds large or complex files that need tests before refactor work."
32
+ },
33
+ {
34
+ id: "privacy-detector",
35
+ ecosystem: "built-in",
36
+ priority: "essential",
37
+ reason: "Finds personal-data and Privacy Review signals without sending data to an external service."
38
+ },
39
+ {
40
+ id: "flow-doctor",
41
+ ecosystem: "built-in",
42
+ priority: "essential",
43
+ reason: "High-confidence structural flow checks: route/method mismatches and swallowed error paths."
44
+ },
45
+ {
46
+ id: "tsc",
47
+ packageName: "typescript",
48
+ executable: "tsc",
49
+ ecosystem: "npm",
50
+ priority: "essential",
51
+ languages: ["typescript"],
52
+ runtime: "node",
53
+ probeArgs: ["--version"],
54
+ reason: "TypeScript correctness signal."
55
+ },
56
+ {
57
+ id: "biome",
58
+ packageName: "@biomejs/biome",
59
+ executable: "biome",
60
+ ecosystem: "npm",
61
+ priority: "essential",
62
+ languages: ["javascript", "typescript"],
63
+ runtime: "node",
64
+ probeArgs: ["--version"],
65
+ reason: "Fast JS/TS lint and safe formatting signal."
66
+ },
67
+ {
68
+ id: "knip",
69
+ packageName: "knip",
70
+ executable: "knip",
71
+ ecosystem: "npm",
72
+ priority: "essential",
73
+ languages: ["javascript", "typescript"],
74
+ runtime: "node",
75
+ probeArgs: ["--version"],
76
+ reason: "Unused files, exports, and dependency signal for JS/TS."
77
+ },
78
+ {
79
+ id: "jscpd",
80
+ packageName: "jscpd",
81
+ executable: "jscpd",
82
+ ecosystem: "npm",
83
+ priority: "recommended",
84
+ languages: ["javascript", "typescript"],
85
+ runtime: "node",
86
+ probeArgs: ["--version"],
87
+ reason: "Duplication signal for refactor planning."
88
+ },
89
+ {
90
+ id: "ruff",
91
+ packageName: "ruff",
92
+ executable: "ruff",
93
+ ecosystem: "python",
94
+ priority: "essential",
95
+ languages: ["python"],
96
+ runtime: "python",
97
+ probeArgs: ["--version"],
98
+ reason: "Python lint and safe-fix signal. VibeDoctor can provision a pinned managed copy.",
99
+ installHint: "VibeDoctor provisions Ruff into ~/.cache/vibedoctor. To pin a project-local copy, install ruff in the environment."
100
+ },
101
+ {
102
+ id: "pyright",
103
+ packageName: "pyright",
104
+ executable: "pyright",
105
+ ecosystem: "python",
106
+ priority: "essential",
107
+ languages: ["python"],
108
+ runtime: "python",
109
+ probeArgs: ["--version"],
110
+ reason: "Python type correctness signal."
111
+ },
112
+ {
113
+ id: "vulture",
114
+ packageName: "vulture",
115
+ executable: "vulture",
116
+ ecosystem: "python",
117
+ priority: "essential",
118
+ languages: ["python"],
119
+ runtime: "python",
120
+ probeArgs: ["--version"],
121
+ reason: "Python dead-code signal."
122
+ },
123
+ {
124
+ id: "coverage.py",
125
+ packageName: "coverage",
126
+ executable: "coverage",
127
+ ecosystem: "python",
128
+ priority: "recommended",
129
+ languages: ["python"],
130
+ runtime: "python",
131
+ probeArgs: ["--version"],
132
+ reason: "Python coverage signal."
133
+ },
134
+ {
135
+ id: "radon",
136
+ packageName: "radon",
137
+ executable: "radon",
138
+ ecosystem: "python",
139
+ priority: "recommended",
140
+ languages: ["python"],
141
+ runtime: "python",
142
+ probeArgs: ["--version"],
143
+ reason: "Python complexity signal."
144
+ },
145
+ {
146
+ id: "deptry",
147
+ packageName: "deptry",
148
+ executable: "deptry",
149
+ ecosystem: "python",
150
+ priority: "recommended",
151
+ languages: ["python"],
152
+ runtime: "python",
153
+ probeArgs: ["--version"],
154
+ reason: "Python dependency hygiene signal."
155
+ },
156
+ {
157
+ id: "gitleaks",
158
+ executable: "gitleaks",
159
+ ecosystem: "manual",
160
+ priority: "essential",
161
+ probeArgs: ["version"],
162
+ reason: "Secret detection across every repository. VibeDoctor can provision a pinned managed copy.",
163
+ installHint: "VibeDoctor provisions Gitleaks into ~/.cache/vibedoctor. To pin a project-local copy, install gitleaks on PATH."
164
+ },
165
+ {
166
+ id: "osv-scanner",
167
+ executable: "osv-scanner",
168
+ ecosystem: "manual",
169
+ priority: "essential",
170
+ requiresLockfile: true,
171
+ probeArgs: ["--version"],
172
+ reason: "Known-vulnerability detection for dependency lockfiles. VibeDoctor can provision a pinned managed copy.",
173
+ installHint: "VibeDoctor provisions OSV-Scanner into ~/.cache/vibedoctor. To pin a project-local copy, install osv-scanner on PATH."
174
+ },
175
+ {
176
+ id: "lizard",
177
+ executable: "lizard",
178
+ ecosystem: "manual",
179
+ priority: "recommended",
180
+ runtime: "python",
181
+ probeArgs: ["--version"],
182
+ reason: "Function-level complexity and code size hotspots (great for spotting refactor candidates).",
183
+ installHint: "Install Lizard with: pipx install lizard, uv tool install lizard, or your OS package manager."
184
+ },
185
+ {
186
+ id: "semgrep",
187
+ executable: "semgrep",
188
+ ecosystem: "manual",
189
+ priority: "recommended",
190
+ runtime: "python",
191
+ probeArgs: ["--version"],
192
+ reason: "Additional security and correctness rules.",
193
+ installHint: "Install Semgrep with: pipx install semgrep, uv tool install semgrep, or your OS package manager."
194
+ },
195
+ {
196
+ id: "presidio",
197
+ ecosystem: "manual",
198
+ priority: "recommended",
199
+ runtime: "python",
200
+ // Presidio ships no console script; the scanner drives it as a Python module,
201
+ // so verification must import the module rather than look for a binary.
202
+ moduleProbe: { runtime: "python", module: "presidio_analyzer" },
203
+ reason: "External PII analyzer used by privacy + DPDP scans by default (skipped gracefully if missing). The normal privacy and DPDP opt-outs are independent.",
204
+ installHint: "Install in the project Python environment with: python -m pip install presidio-analyzer"
205
+ }
206
+ ];
207
+ const BY_ID = new Map(exports.TOOL_REGISTRY.map((entry) => [entry.id, entry]));
208
+ function getToolEntry(id) {
209
+ return BY_ID.get(id);
210
+ }
211
+ /** Command names the scanner may invoke, for availability probing. */
212
+ function registryExecutables() {
213
+ return Array.from(new Set(exports.TOOL_REGISTRY.map((entry) => entry.executable).filter((name) => Boolean(name))));
214
+ }
215
+ function toolsForPriority(priority) {
216
+ if (priority === "all") {
217
+ return exports.TOOL_REGISTRY;
218
+ }
219
+ if (priority === "recommended") {
220
+ return exports.TOOL_REGISTRY;
221
+ }
222
+ return exports.TOOL_REGISTRY.filter((entry) => entry.priority === "essential");
223
+ }
224
+ function installHintFor(entry) {
225
+ if (entry.installHint) {
226
+ return entry.installHint;
227
+ }
228
+ if (entry.ecosystem === "npm" && entry.packageName) {
229
+ return `Install with: npm install -D ${entry.packageName}`;
230
+ }
231
+ if (entry.ecosystem === "python" && entry.packageName) {
232
+ return `Install with: python -m pip install -U ${entry.packageName}`;
233
+ }
234
+ return `Install ${entry.id} and make sure it is on PATH.`;
235
+ }
236
+ /**
237
+ * Reads the runtime requirement a tool declares for itself, from the package
238
+ * metadata of the copy that is actually installed. Hardcoding "knip needs Node
239
+ * 20.19" would go stale on the next release; the package says so itself.
240
+ */
241
+ async function readDeclaredNodeRequirement(root, packageName) {
242
+ if (!packageName) {
243
+ return {};
244
+ }
245
+ const manifest = node_path_1.default.join(root, "node_modules", ...packageName.split("/"), "package.json");
246
+ try {
247
+ const parsed = JSON.parse(await node_fs_1.promises.readFile(manifest, "utf8"));
248
+ const range = parsed.engines?.node;
249
+ return range ? { range, source: `${packageName} engines.node` } : {};
250
+ }
251
+ catch {
252
+ return {};
253
+ }
254
+ }
@@ -1,9 +1,15 @@
1
+ import { buildCommandEnv, getLocalToolSearchPaths } from "./executable";
2
+ import { type ToolRuntime } from "./toolRuntime";
3
+ export { buildCommandEnv, getLocalToolSearchPaths };
1
4
  export type CommandSpec = {
2
5
  cmd: string;
6
+ /** Request a named engine; ToolRuntime resolves the executable. */
7
+ tool?: string;
3
8
  args: string[];
4
9
  cwd?: string;
5
10
  timeoutMs?: number;
6
11
  env?: NodeJS.ProcessEnv;
12
+ runtime?: ToolRuntime;
7
13
  };
8
14
  export type ToolResult = {
9
15
  command: string;
@@ -13,10 +19,29 @@ export type ToolResult = {
13
19
  durationMs: number;
14
20
  status: "ok" | "error" | "skipped" | "timeout";
15
21
  installHint?: string;
22
+ /** Absolute path of the executable that ran, so reports can prove what was invoked. */
23
+ resolvedPath?: string;
24
+ /** Set when the run covered less than the requested scope (scoped timeout fallback). */
25
+ coverage?: ToolCoverage;
26
+ };
27
+ export type ToolCoverage = {
28
+ scope: "full" | "scoped" | "none";
29
+ detail: string;
30
+ targetsRequested?: number;
31
+ targetsScanned?: number;
16
32
  };
17
- export declare function getLocalToolSearchPaths(cwd: string | undefined): string[];
18
- export declare function buildCommandEnv(cwd: string | undefined, overrides: NodeJS.ProcessEnv | undefined): NodeJS.ProcessEnv;
19
33
  export declare function commandExistsOnWindowsPath(command: string, cwd?: string): boolean;
34
+ /**
35
+ * Quotes one argument for a cmd.exe command line.
36
+ *
37
+ * Node's `shell: true` joins the command and arguments with spaces and hands the
38
+ * result to cmd.exe verbatim (the behaviour deprecated as DEP0190), so an
39
+ * argument containing a space, a quote, or a shell metacharacter — a repository
40
+ * path under "Program Files", a glob, a rule id with a pipe — arrives split or
41
+ * partly interpreted by the shell. Arguments with nothing special in them are
42
+ * left exactly as they were, so this only changes the cases that were broken.
43
+ */
44
+ export declare function quoteForWindowsShell(argument: string): string;
20
45
  export declare function runCommand(spec: CommandSpec, installHint?: string): Promise<ToolResult>;
21
46
  export declare function runCommands(commands: Array<{
22
47
  id: string;