@neuralaxis/vibedoctor 0.2.1 → 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 (47) hide show
  1. package/README.md +49 -23
  2. package/dist/adapters/biome.js +3 -2
  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 +4 -2
  9. package/dist/adapters/ruff.js +7 -3
  10. package/dist/adapters/shared.d.ts +4 -0
  11. package/dist/cli/commands/init.js +7 -0
  12. package/dist/cli/commands/scan.d.ts +6 -0
  13. package/dist/cli/commands/scan.js +16 -2
  14. package/dist/cli/index.js +4 -4
  15. package/dist/core/agentDiagnosis.d.ts +39 -0
  16. package/dist/core/agentDiagnosis.js +96 -0
  17. package/dist/core/config.d.ts +11 -0
  18. package/dist/core/config.js +31 -2
  19. package/dist/core/engine.d.ts +8 -1
  20. package/dist/core/engine.js +54 -51
  21. package/dist/core/finding.d.ts +1 -1
  22. package/dist/core/finding.js +8 -3
  23. package/dist/core/findingCorrelator.d.ts +19 -0
  24. package/dist/core/findingCorrelator.js +112 -0
  25. package/dist/core/findingNormalizer.js +1 -0
  26. package/dist/core/managedTools.d.ts +25 -0
  27. package/dist/core/managedTools.js +186 -0
  28. package/dist/core/repoGraph.d.ts +62 -0
  29. package/dist/core/repoGraph.js +408 -0
  30. package/dist/core/riskRanker.d.ts +6 -0
  31. package/dist/core/riskRanker.js +127 -0
  32. package/dist/core/scanContext.d.ts +26 -0
  33. package/dist/core/scanContext.js +44 -0
  34. package/dist/core/scanPlanner.d.ts +1 -0
  35. package/dist/core/scanPlanner.js +10 -6
  36. package/dist/core/toolRegistry.js +12 -5
  37. package/dist/core/toolRunner.d.ts +4 -0
  38. package/dist/core/toolRunner.js +18 -0
  39. package/dist/core/toolRuntime.d.ts +40 -0
  40. package/dist/core/toolRuntime.js +417 -0
  41. package/dist/core/toolVerification.d.ts +3 -1
  42. package/dist/core/toolVerification.js +58 -3
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.js +5 -0
  45. package/dist/reporters/agent.d.ts +1 -1
  46. package/dist/reporters/agent.js +7 -0
  47. package/package.json +80 -80
@@ -0,0 +1,417 @@
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.isManagedTool = exports.MAX_DOWNLOAD_BYTES = exports.DOWNLOAD_TIMEOUT_MS = void 0;
7
+ exports.defaultToolCacheDir = defaultToolCacheDir;
8
+ exports.createToolRuntime = createToolRuntime;
9
+ exports.isProjectLocalPath = isProjectLocalPath;
10
+ exports.sha256File = sha256File;
11
+ const node_crypto_1 = require("node:crypto");
12
+ const node_child_process_1 = require("node:child_process");
13
+ const node_fs_1 = require("node:fs");
14
+ const node_https_1 = __importDefault(require("node:https"));
15
+ const node_os_1 = __importDefault(require("node:os"));
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const executable_1 = require("./executable");
18
+ const managedTools_1 = require("./managedTools");
19
+ Object.defineProperty(exports, "isManagedTool", { enumerable: true, get: function () { return managedTools_1.isManagedTool; } });
20
+ exports.DOWNLOAD_TIMEOUT_MS = 45_000;
21
+ exports.MAX_DOWNLOAD_BYTES = 80 * 1024 * 1024;
22
+ const MANIFEST_NAME = "manifest.json";
23
+ function defaultToolCacheDir() {
24
+ if (process.env.VIBEDOCTOR_TOOL_CACHE) {
25
+ return process.env.VIBEDOCTOR_TOOL_CACHE;
26
+ }
27
+ return node_path_1.default.join(node_os_1.default.homedir(), ".cache", "vibedoctor");
28
+ }
29
+ function envAllowsNetwork() {
30
+ const value = process.env.VIBEDOCTOR_ALLOW_NETWORK;
31
+ if (value === "0" || value === "false") {
32
+ return false;
33
+ }
34
+ return true;
35
+ }
36
+ function createToolRuntime(options = {}) {
37
+ const cacheDir = options.cacheDir ?? defaultToolCacheDir();
38
+ const managedEnabled = options.enabled ?? true;
39
+ const allowNetwork = (options.allowNetwork ?? true) && envAllowsNetwork();
40
+ const preferProjectLocal = options.preferProjectLocal ?? true;
41
+ const allowPathFallback = options.allowPathFallback ?? true;
42
+ const catalog = options.catalog;
43
+ const localArtifacts = options.localArtifacts ?? {};
44
+ const fetchArtifact = options.fetchArtifact ?? downloadFile;
45
+ async function resolve(tool, resolveOptions = {}) {
46
+ const projectRoot = resolveOptions.projectRoot ?? options.projectRoot;
47
+ const spec = catalog?.[tool] ?? (0, managedTools_1.getManagedTool)(tool);
48
+ if (preferProjectLocal && projectRoot) {
49
+ const local = findProjectLocal(tool, projectRoot);
50
+ if (local) {
51
+ return {
52
+ tool,
53
+ status: "resolved",
54
+ source: "project-local",
55
+ version: spec?.version,
56
+ executablePath: local,
57
+ reusedCache: false,
58
+ reason: `Using project-local ${tool} at ${local}.`
59
+ };
60
+ }
61
+ }
62
+ if (spec && managedEnabled) {
63
+ const managed = await resolveManaged(spec);
64
+ if (managed.status === "resolved" || managed.status === "checksum_mismatch") {
65
+ return managed;
66
+ }
67
+ if (managed.status === "unsupported_platform") {
68
+ const fromPath = allowPathFallback
69
+ ? projectRoot
70
+ ? (0, executable_1.resolveExecutable)(tool, projectRoot)
71
+ : (0, executable_1.resolveExecutable)(tool)
72
+ : undefined;
73
+ if (fromPath) {
74
+ return {
75
+ tool,
76
+ status: "resolved",
77
+ source: "path",
78
+ executablePath: fromPath.path,
79
+ reusedCache: false,
80
+ reason: `No managed ${tool} artifact for this platform; using PATH at ${fromPath.path}.`
81
+ };
82
+ }
83
+ return managed;
84
+ }
85
+ const fromPath = allowPathFallback
86
+ ? projectRoot
87
+ ? (0, executable_1.resolveExecutable)(tool, projectRoot)
88
+ : (0, executable_1.resolveExecutable)(tool)
89
+ : undefined;
90
+ if (fromPath && !isProjectLocalPath(fromPath.path, projectRoot)) {
91
+ return {
92
+ tool,
93
+ status: "resolved",
94
+ source: "path",
95
+ version: spec.version,
96
+ executablePath: fromPath.path,
97
+ reusedCache: false,
98
+ reason: `Managed ${tool} was not available (${managed.reason}); using PATH at ${fromPath.path}.`
99
+ };
100
+ }
101
+ return managed;
102
+ }
103
+ const fromPath = projectRoot ? (0, executable_1.resolveExecutable)(tool, projectRoot) : (0, executable_1.resolveExecutable)(tool);
104
+ if (fromPath) {
105
+ return {
106
+ tool,
107
+ status: "resolved",
108
+ source: isProjectLocalPath(fromPath.path, projectRoot) ? "project-local" : "path",
109
+ executablePath: fromPath.path,
110
+ reusedCache: false,
111
+ reason: `Resolved ${tool} at ${fromPath.path}.`
112
+ };
113
+ }
114
+ return {
115
+ tool,
116
+ status: "not_found",
117
+ reusedCache: false,
118
+ reason: spec
119
+ ? `Managed ${tool} is disabled and ${tool} was not found on PATH.`
120
+ : `${tool} is not a managed engine and was not found on PATH.`,
121
+ remediation: `Install ${tool} or add a managed-tool entry for it.`
122
+ };
123
+ }
124
+ async function resolveManaged(spec) {
125
+ const platform = (0, managedTools_1.currentPlatformKey)();
126
+ const artifact = (0, managedTools_1.artifactFor)(spec, platform);
127
+ if (!artifact) {
128
+ return {
129
+ tool: spec.id,
130
+ status: "unsupported_platform",
131
+ version: spec.version,
132
+ reusedCache: false,
133
+ reason: `No managed ${spec.id} ${spec.version} artifact for platform ${platform}.`,
134
+ remediation: `Install ${spec.id} yourself, or run on a supported platform (win32-x64, darwin-arm64, linux-x64, …).`
135
+ };
136
+ }
137
+ const toolDir = node_path_1.default.join(cacheDir, "tools", spec.id, spec.version);
138
+ const binaryPath = node_path_1.default.join(toolDir, artifact.binary);
139
+ const cached = await readValidCache(spec, artifact, toolDir, binaryPath);
140
+ if (cached) {
141
+ return cached;
142
+ }
143
+ try {
144
+ await node_fs_1.promises.mkdir(toolDir, { recursive: true });
145
+ const staged = await stageArtifact(spec, artifact, toolDir);
146
+ const digest = await sha256File(staged.archivePath);
147
+ if (digest !== artifact.sha256.toLowerCase()) {
148
+ await rmQuiet(staged.archivePath);
149
+ return {
150
+ tool: spec.id,
151
+ status: "checksum_mismatch",
152
+ version: spec.version,
153
+ cachePath: toolDir,
154
+ reusedCache: false,
155
+ reason: `Checksum mismatch for managed ${spec.id} ${spec.version}: expected ${artifact.sha256}, got ${digest}. The file was not installed.`,
156
+ remediation: `Delete ${toolDir} and rerun the scan. If this persists, the download is corrupt or the catalog checksum is wrong.`
157
+ };
158
+ }
159
+ const executablePath = await materializeBinary(staged, artifact, toolDir, binaryPath);
160
+ await writeManifest(toolDir, {
161
+ tool: spec.id,
162
+ version: spec.version,
163
+ platform,
164
+ sha256: artifact.sha256,
165
+ binary: artifact.binary,
166
+ binarySha256: await sha256File(executablePath),
167
+ provisionedAt: new Date().toISOString()
168
+ });
169
+ if (staged.cleanup) {
170
+ await rmQuiet(staged.archivePath);
171
+ }
172
+ return {
173
+ tool: spec.id,
174
+ status: "resolved",
175
+ source: "managed",
176
+ version: spec.version,
177
+ executablePath,
178
+ cachePath: toolDir,
179
+ reusedCache: false,
180
+ reason: `Provisioned managed ${spec.id} ${spec.version} at ${executablePath}.`
181
+ };
182
+ }
183
+ catch (error) {
184
+ const message = error instanceof Error ? error.message : String(error);
185
+ return {
186
+ tool: spec.id,
187
+ status: /checksum/i.test(message) ? "checksum_mismatch" : "failed",
188
+ version: spec.version,
189
+ cachePath: toolDir,
190
+ reusedCache: false,
191
+ reason: `Could not provision managed ${spec.id} ${spec.version}: ${message}`,
192
+ remediation: allowNetwork
193
+ ? `Check network access to the artifact URL, or install ${spec.id} on PATH.`
194
+ : `Network is disabled. Provide a cached copy under ${toolDir} or a test artifact, or install ${spec.id} on PATH.`
195
+ };
196
+ }
197
+ }
198
+ async function readValidCache(spec, artifact, toolDir, binaryPath) {
199
+ try {
200
+ await node_fs_1.promises.access(binaryPath);
201
+ const manifest = await readManifest(toolDir);
202
+ if (!manifest || manifest.sha256.toLowerCase() !== artifact.sha256.toLowerCase()) {
203
+ return undefined;
204
+ }
205
+ if (manifest.binarySha256) {
206
+ const digest = await sha256File(binaryPath);
207
+ if (digest !== manifest.binarySha256.toLowerCase()) {
208
+ return undefined;
209
+ }
210
+ }
211
+ return {
212
+ tool: spec.id,
213
+ status: "resolved",
214
+ source: "managed",
215
+ version: spec.version,
216
+ executablePath: binaryPath,
217
+ cachePath: toolDir,
218
+ reusedCache: true,
219
+ reason: `Reused managed ${spec.id} ${spec.version} at ${binaryPath}.`
220
+ };
221
+ }
222
+ catch {
223
+ return undefined;
224
+ }
225
+ }
226
+ async function stageArtifact(spec, artifact, toolDir) {
227
+ const local = localArtifacts[spec.id];
228
+ if (local) {
229
+ const dest = node_path_1.default.join(toolDir, node_path_1.default.basename(local));
230
+ await node_fs_1.promises.copyFile(local, dest);
231
+ return { archivePath: dest, cleanup: artifact.archive !== "none" };
232
+ }
233
+ if (!allowNetwork) {
234
+ throw new Error(`Network is disabled and ${spec.id} ${spec.version} is not in the VibeDoctor cache (${toolDir}).`);
235
+ }
236
+ const fileName = node_path_1.default.basename(new URL(artifact.url).pathname) || `${spec.id}.bin`;
237
+ const dest = node_path_1.default.join(toolDir, fileName);
238
+ await fetchArtifact(artifact.url, dest);
239
+ return { archivePath: dest, cleanup: artifact.archive !== "none" };
240
+ }
241
+ return { cacheDir, resolve };
242
+ }
243
+ function findProjectLocal(tool, projectRoot) {
244
+ const resolved = (0, executable_1.resolveExecutable)(tool, projectRoot);
245
+ if (!resolved) {
246
+ return undefined;
247
+ }
248
+ return isProjectLocalPath(resolved.path, projectRoot) ? resolved.path : undefined;
249
+ }
250
+ function isProjectLocalPath(candidate, projectRoot) {
251
+ if (!projectRoot) {
252
+ return false;
253
+ }
254
+ const relative = node_path_1.default.relative(projectRoot, candidate);
255
+ if (!relative || relative.startsWith("..") || node_path_1.default.isAbsolute(relative)) {
256
+ return false;
257
+ }
258
+ return /(^|[/\\])(node_modules|\.venv|venv)([/\\]|$)/i.test(relative);
259
+ }
260
+ async function materializeBinary(staged, artifact, toolDir, binaryPath) {
261
+ if (artifact.archive === "none") {
262
+ if (node_path_1.default.resolve(staged.archivePath) !== node_path_1.default.resolve(binaryPath)) {
263
+ await node_fs_1.promises.copyFile(staged.archivePath, binaryPath);
264
+ }
265
+ if (process.platform !== "win32") {
266
+ await node_fs_1.promises.chmod(binaryPath, 0o755);
267
+ }
268
+ return binaryPath;
269
+ }
270
+ await extractArchive(staged.archivePath, toolDir, artifact.archive);
271
+ const found = await findExtractedBinary(toolDir, artifact.binary);
272
+ if (!found) {
273
+ throw new Error(`Archive extracted but ${artifact.binary} was not found in ${toolDir}.`);
274
+ }
275
+ if (node_path_1.default.resolve(found) !== node_path_1.default.resolve(binaryPath)) {
276
+ await node_fs_1.promises.copyFile(found, binaryPath);
277
+ }
278
+ if (process.platform !== "win32") {
279
+ await node_fs_1.promises.chmod(binaryPath, 0o755);
280
+ }
281
+ return binaryPath;
282
+ }
283
+ async function extractArchive(archivePath, destDir, kind) {
284
+ const args = kind === "tar.gz" ? ["-xzf", archivePath, "-C", destDir] : ["-xf", archivePath, "-C", destDir];
285
+ await new Promise((resolve, reject) => {
286
+ (0, node_child_process_1.execFile)("tar", args, { windowsHide: true }, (error, _stdout, stderr) => {
287
+ if (error) {
288
+ reject(new Error(stderr || error.message));
289
+ return;
290
+ }
291
+ resolve();
292
+ });
293
+ });
294
+ }
295
+ async function findExtractedBinary(dir, binary) {
296
+ const direct = node_path_1.default.join(dir, binary);
297
+ try {
298
+ await node_fs_1.promises.access(direct);
299
+ return direct;
300
+ }
301
+ catch {
302
+ // Search one level down — some archives wrap the binary in a folder.
303
+ }
304
+ const entries = await node_fs_1.promises.readdir(dir, { withFileTypes: true });
305
+ for (const entry of entries) {
306
+ if (entry.isDirectory()) {
307
+ const nested = node_path_1.default.join(dir, entry.name, binary);
308
+ try {
309
+ await node_fs_1.promises.access(nested);
310
+ return nested;
311
+ }
312
+ catch {
313
+ // keep looking
314
+ }
315
+ }
316
+ if (entry.isFile() && entry.name === binary) {
317
+ return node_path_1.default.join(dir, entry.name);
318
+ }
319
+ }
320
+ return undefined;
321
+ }
322
+ async function readManifest(toolDir) {
323
+ try {
324
+ return JSON.parse(await node_fs_1.promises.readFile(node_path_1.default.join(toolDir, MANIFEST_NAME), "utf8"));
325
+ }
326
+ catch {
327
+ return undefined;
328
+ }
329
+ }
330
+ async function writeManifest(toolDir, manifest) {
331
+ await node_fs_1.promises.writeFile(node_path_1.default.join(toolDir, MANIFEST_NAME), `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
332
+ }
333
+ async function sha256File(filePath) {
334
+ const hash = (0, node_crypto_1.createHash)("sha256");
335
+ const handle = await node_fs_1.promises.open(filePath, "r");
336
+ try {
337
+ const stream = handle.createReadStream();
338
+ for await (const chunk of stream) {
339
+ hash.update(chunk);
340
+ }
341
+ }
342
+ finally {
343
+ await handle.close();
344
+ }
345
+ return hash.digest("hex");
346
+ }
347
+ async function downloadFile(url, destFile) {
348
+ await node_fs_1.promises.mkdir(node_path_1.default.dirname(destFile), { recursive: true });
349
+ await new Promise((resolve, reject) => {
350
+ let settled = false;
351
+ const fail = (error) => {
352
+ if (settled) {
353
+ return;
354
+ }
355
+ settled = true;
356
+ reject(error);
357
+ };
358
+ const succeed = () => {
359
+ if (settled) {
360
+ return;
361
+ }
362
+ settled = true;
363
+ resolve();
364
+ };
365
+ const follow = (target, remaining) => {
366
+ if (!target.startsWith("https://")) {
367
+ fail(new Error(`Refusing non-HTTPS download: ${target}`));
368
+ return;
369
+ }
370
+ const request = node_https_1.default.get(target, { timeout: exports.DOWNLOAD_TIMEOUT_MS }, (response) => {
371
+ const status = response.statusCode ?? 0;
372
+ if (status >= 300 && status < 400 && response.headers.location && remaining > 0) {
373
+ response.resume();
374
+ follow(new URL(response.headers.location, target).toString(), remaining - 1);
375
+ return;
376
+ }
377
+ if (status !== 200) {
378
+ response.resume();
379
+ fail(new Error(`Download failed (${status}) for ${target}`));
380
+ return;
381
+ }
382
+ const out = (0, node_fs_1.createWriteStream)(destFile);
383
+ let received = 0;
384
+ response.on("data", (chunk) => {
385
+ received += chunk.length;
386
+ if (received > exports.MAX_DOWNLOAD_BYTES) {
387
+ request.destroy();
388
+ out.destroy();
389
+ fail(new Error(`Download exceeded ${exports.MAX_DOWNLOAD_BYTES} bytes for ${target}`));
390
+ }
391
+ });
392
+ response.setTimeout(exports.DOWNLOAD_TIMEOUT_MS, () => {
393
+ request.destroy();
394
+ out.destroy();
395
+ fail(new Error(`Download timed out after ${exports.DOWNLOAD_TIMEOUT_MS}ms`));
396
+ });
397
+ response.pipe(out);
398
+ out.on("finish", () => out.close((error) => (error ? fail(error) : succeed())));
399
+ out.on("error", fail);
400
+ });
401
+ request.setTimeout(exports.DOWNLOAD_TIMEOUT_MS, () => {
402
+ request.destroy();
403
+ fail(new Error(`Download timed out after ${exports.DOWNLOAD_TIMEOUT_MS}ms`));
404
+ });
405
+ request.on("error", fail);
406
+ };
407
+ follow(url, 5);
408
+ });
409
+ }
410
+ async function rmQuiet(target) {
411
+ try {
412
+ await node_fs_1.promises.rm(target, { force: true });
413
+ }
414
+ catch {
415
+ // best effort
416
+ }
417
+ }
@@ -1,4 +1,5 @@
1
1
  import { type RuntimeEngine, type ToolRegistryEntry } from "./toolRegistry";
2
+ import { type ToolRuntime } from "./toolRuntime";
2
3
  /**
3
4
  * Proves a tool is usable rather than merely present.
4
5
  *
@@ -80,8 +81,9 @@ export type VerifyToolOptions = {
80
81
  root: string;
81
82
  runtimes: RuntimeProbes;
82
83
  depth?: VerificationDepth;
84
+ toolRuntime?: ToolRuntime;
83
85
  };
84
86
  export declare function verifyTool(entry: ToolRegistryEntry, options: VerifyToolOptions): Promise<ToolVerification>;
85
- export declare function verifyTools(entries: ToolRegistryEntry[], root: string, depth?: VerificationDepth): Promise<ToolVerification[]>;
87
+ export declare function verifyTools(entries: ToolRegistryEntry[], root: string, depth?: VerificationDepth, toolRuntime?: ToolRuntime): Promise<ToolVerification[]>;
86
88
  export declare function summarizeVerification(verification: ToolVerification): string;
87
89
  export declare function formatVersionForDisplay(value: string | undefined): string;
@@ -17,6 +17,7 @@ const executable_1 = require("./executable");
17
17
  const semverLite_1 = require("./semverLite");
18
18
  const toolRegistry_1 = require("./toolRegistry");
19
19
  const toolRunner_1 = require("./toolRunner");
20
+ const toolRuntime_1 = require("./toolRuntime");
20
21
  function isVerificationBlocking(verification) {
21
22
  return verification.state === "not_found" || verification.state === "broken" || verification.state === "incompatible_runtime";
22
23
  }
@@ -212,6 +213,60 @@ async function verifyTool(entry, options) {
212
213
  runtime
213
214
  };
214
215
  }
216
+ if (options.toolRuntime && (0, toolRuntime_1.isManagedTool)(entry.id)) {
217
+ const managed = await options.toolRuntime.resolve(entry.id, { projectRoot: root });
218
+ if (managed.executablePath) {
219
+ if (depth === "resolve") {
220
+ return {
221
+ id: entry.id,
222
+ state: "verified",
223
+ resolvedPath: managed.executablePath,
224
+ version: managed.version,
225
+ reason: managed.reason,
226
+ runtime
227
+ };
228
+ }
229
+ const probeArgs = entry.probeArgs ?? ["--version"];
230
+ const result = await (0, toolRunner_1.runCommand)({
231
+ cmd: managed.executablePath,
232
+ args: probeArgs,
233
+ cwd: root,
234
+ timeoutMs: PROBE_TIMEOUT_MS
235
+ });
236
+ const probeCommand = [managed.executablePath, ...probeArgs].join(" ");
237
+ if (result.status !== "ok") {
238
+ return {
239
+ id: entry.id,
240
+ state: "broken",
241
+ resolvedPath: managed.executablePath,
242
+ version: managed.version,
243
+ probeCommand,
244
+ reason: `Managed ${entry.id} at ${managed.executablePath} failed its version probe.`,
245
+ remediation: managed.remediation ?? (0, toolRegistry_1.installHintFor)(entry),
246
+ runtime
247
+ };
248
+ }
249
+ return {
250
+ id: entry.id,
251
+ state: "verified",
252
+ resolvedPath: managed.executablePath,
253
+ version: extractVersion(`${result.stdout}\n${result.stderr}`, entry.versionPattern) ?? managed.version,
254
+ probeCommand,
255
+ reason: `Ran managed ${entry.id} at ${managed.executablePath}.`,
256
+ runtime
257
+ };
258
+ }
259
+ if (managed.status === "checksum_mismatch" || managed.status === "failed") {
260
+ return {
261
+ id: entry.id,
262
+ state: "broken",
263
+ version: managed.version,
264
+ reason: managed.reason,
265
+ remediation: managed.remediation,
266
+ runtime
267
+ };
268
+ }
269
+ }
215
270
  const resolved = (0, executable_1.resolveExecutable)(entry.executable, root);
216
271
  if (!resolved) {
217
272
  const searched = (0, executable_1.describeSearchPaths)(root);
@@ -318,11 +373,11 @@ async function saveVerificationCache(root, entries) {
318
373
  // A cache that cannot be written only costs time on the next run.
319
374
  }
320
375
  }
321
- async function verifyTools(entries, root, depth = "execute") {
376
+ async function verifyTools(entries, root, depth = "execute", toolRuntime) {
322
377
  const runtimes = await probeRuntimesFor(entries, root, depth);
323
378
  if (depth === "resolve") {
324
379
  // Resolution is a filesystem lookup; caching it would only add staleness.
325
- return Promise.all(entries.map((entry) => verifyTool(entry, { root, runtimes, depth })));
380
+ return Promise.all(entries.map((entry) => verifyTool(entry, { root, runtimes, depth, toolRuntime })));
326
381
  }
327
382
  const cache = await loadVerificationCache(root);
328
383
  const results = await Promise.all(entries.map(async (entry) => {
@@ -334,7 +389,7 @@ async function verifyTools(entries, root, depth = "execute") {
334
389
  return { verification, cacheEntry: cached };
335
390
  }
336
391
  }
337
- const verification = await verifyTool(entry, { root, runtimes, depth });
392
+ const verification = await verifyTool(entry, { root, runtimes, depth, toolRuntime });
338
393
  const fingerprint = fingerprintFile(verification.resolvedPath);
339
394
  return {
340
395
  verification,
package/dist/index.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  export * from "./agentPack/generateAgentPack";
2
2
  export * from "./agentPack/policy";
3
3
  export { AGENT_SKILLS, DEFAULT_SKILL_NAMES, type SkillTemplate } from "./agentPack/templates";
4
+ export * from "./core/agentDiagnosis";
4
5
  export * from "./core/config";
5
6
  export * from "./core/engine";
6
7
  export * from "./core/finding";
8
+ export * from "./core/findingCorrelator";
7
9
  export * from "./core/privacyReview";
8
10
  export * from "./core/projectDetector";
11
+ export * from "./core/scanContext";
12
+ export * from "./core/scanPlanner";
13
+ export * from "./core/toolRuntime";
9
14
  export * from "./mcp/server";
10
15
  export * from "./dpdp";
package/dist/index.js CHANGED
@@ -20,10 +20,15 @@ __exportStar(require("./agentPack/policy"), exports);
20
20
  var templates_1 = require("./agentPack/templates");
21
21
  Object.defineProperty(exports, "AGENT_SKILLS", { enumerable: true, get: function () { return templates_1.AGENT_SKILLS; } });
22
22
  Object.defineProperty(exports, "DEFAULT_SKILL_NAMES", { enumerable: true, get: function () { return templates_1.DEFAULT_SKILL_NAMES; } });
23
+ __exportStar(require("./core/agentDiagnosis"), exports);
23
24
  __exportStar(require("./core/config"), exports);
24
25
  __exportStar(require("./core/engine"), exports);
25
26
  __exportStar(require("./core/finding"), exports);
27
+ __exportStar(require("./core/findingCorrelator"), exports);
26
28
  __exportStar(require("./core/privacyReview"), exports);
27
29
  __exportStar(require("./core/projectDetector"), exports);
30
+ __exportStar(require("./core/scanContext"), exports);
31
+ __exportStar(require("./core/scanPlanner"), exports);
32
+ __exportStar(require("./core/toolRuntime"), exports);
28
33
  __exportStar(require("./mcp/server"), exports);
29
34
  __exportStar(require("./dpdp"), exports);
@@ -1,3 +1,3 @@
1
1
  import type { AgentPlan, ScanOutput } from "../core/engine";
2
2
  export declare function renderAgentMarkdown(input: Pick<ScanOutput, "agentPlan"> | AgentPlan): string;
3
- export declare function renderAgentJson(input: Pick<ScanOutput, "agentPlan"> | AgentPlan): string;
3
+ export declare function renderAgentJson(input: Pick<ScanOutput, "agentPlan"> | AgentPlan | ScanOutput): string;
@@ -2,9 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderAgentMarkdown = renderAgentMarkdown;
4
4
  exports.renderAgentJson = renderAgentJson;
5
+ const agentDiagnosis_1 = require("../core/agentDiagnosis");
5
6
  function getPlan(input) {
6
7
  return "agentPlan" in input ? input.agentPlan : input;
7
8
  }
9
+ function isScanOutput(input) {
10
+ return "findings" in input && "completeness" in input && "score" in input;
11
+ }
8
12
  function renderAgentMarkdown(input) {
9
13
  const plan = getPlan(input);
10
14
  const lines = ["# VibeDoctor Agent Plan", "", `Goal: ${plan.goal}.`, "", `Target: ${plan.target}`, "", "## Workflow", ""];
@@ -52,5 +56,8 @@ function renderAgentMarkdown(input) {
52
56
  return `${lines.join("\n")}\n`;
53
57
  }
54
58
  function renderAgentJson(input) {
59
+ if (isScanOutput(input)) {
60
+ return JSON.stringify(input.diagnosis ?? (0, agentDiagnosis_1.buildAgentDiagnosis)(input), null, 2);
61
+ }
55
62
  return JSON.stringify(getPlan(input), null, 2);
56
63
  }