@neuralaxis/vibedoctor 0.1.1 → 0.1.3

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 (75) hide show
  1. package/README.md +219 -290
  2. package/dist/adapters/biome.d.ts +1 -1
  3. package/dist/adapters/biome.js +7 -4
  4. package/dist/adapters/coveragePy.js +3 -0
  5. package/dist/adapters/customDeadChain.d.ts +2 -1
  6. package/dist/adapters/customDeadChain.js +100 -8
  7. package/dist/adapters/customLeftovers.js +33 -10
  8. package/dist/adapters/deptry.js +21 -2
  9. package/dist/adapters/index.d.ts +3 -0
  10. package/dist/adapters/index.js +7 -1
  11. package/dist/adapters/jscpd.d.ts +1 -0
  12. package/dist/adapters/jscpd.js +10 -1
  13. package/dist/adapters/knip.js +29 -4
  14. package/dist/adapters/lizard.d.ts +1 -1
  15. package/dist/adapters/lizard.js +51 -2
  16. package/dist/adapters/osvScanner.js +14 -2
  17. package/dist/adapters/presidio.d.ts +2 -0
  18. package/dist/adapters/presidio.js +158 -0
  19. package/dist/adapters/privacyDetector.d.ts +10 -0
  20. package/dist/adapters/privacyDetector.js +600 -0
  21. package/dist/adapters/ruff.d.ts +1 -1
  22. package/dist/adapters/ruff.js +4 -1
  23. package/dist/adapters/semgrep.d.ts +1 -1
  24. package/dist/adapters/semgrep.js +17 -3
  25. package/dist/adapters/shared.d.ts +1 -0
  26. package/dist/adapters/shared.js +22 -0
  27. package/dist/adapters/telemetryDetector.d.ts +2 -0
  28. package/dist/adapters/telemetryDetector.js +118 -0
  29. package/dist/adapters/tsc.js +43 -18
  30. package/dist/adapters/vulture.d.ts +1 -1
  31. package/dist/adapters/vulture.js +25 -6
  32. package/dist/agentPack/generateAgentPack.d.ts +7 -0
  33. package/dist/agentPack/generateAgentPack.js +89 -1
  34. package/dist/agentPack/templates/index.js +21 -15
  35. package/dist/agentPack/templates/skills.js +57 -4
  36. package/dist/cli/commands/agent.d.ts +5 -0
  37. package/dist/cli/commands/agent.js +10 -0
  38. package/dist/cli/commands/agentPlan.js +9 -1
  39. package/dist/cli/commands/init.js +50 -17
  40. package/dist/cli/commands/privacyReview.d.ts +9 -0
  41. package/dist/cli/commands/privacyReview.js +304 -0
  42. package/dist/cli/commands/scan.d.ts +1 -1
  43. package/dist/cli/commands/scan.js +31 -1
  44. package/dist/cli/commands/setup.js +16 -1
  45. package/dist/cli/commands/tool.d.ts +4 -0
  46. package/dist/cli/commands/tool.js +11 -0
  47. package/dist/cli/index.js +36 -0
  48. package/dist/core/config.d.ts +29 -0
  49. package/dist/core/config.js +142 -5
  50. package/dist/core/engine.d.ts +35 -1
  51. package/dist/core/engine.js +204 -36
  52. package/dist/core/finding.d.ts +16 -2
  53. package/dist/core/finding.js +5 -0
  54. package/dist/core/paths.js +5 -0
  55. package/dist/core/privacyReview.d.ts +51 -0
  56. package/dist/core/privacyReview.js +94 -0
  57. package/dist/core/projectDetector.d.ts +1 -1
  58. package/dist/core/projectDetector.js +34 -12
  59. package/dist/core/scanPlanner.js +4 -0
  60. package/dist/core/scoring.js +6 -0
  61. package/dist/core/toolRunner.d.ts +1 -0
  62. package/dist/core/toolRunner.js +73 -11
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +5 -0
  65. package/dist/mcp/tools/shared.d.ts +1 -1
  66. package/dist/mcp/tools/shared.js +8 -1
  67. package/dist/reporters/agent.js +8 -0
  68. package/dist/reporters/html.js +12 -8
  69. package/dist/reporters/json.js +5 -5
  70. package/dist/reporters/markdown.js +15 -1
  71. package/dist/reporters/sarif.js +6 -0
  72. package/dist/reporters/terminal.js +1 -5
  73. package/dist/rules/severityMap.d.ts +1 -0
  74. package/dist/rules/severityMap.js +1 -0
  75. package/package.json +6 -2
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAgentPlan = createAgentPlan;
4
4
  exports.runScan = runScan;
5
+ exports.retryTool = retryTool;
5
6
  exports.filterScanByCategories = filterScanByCategories;
6
7
  exports.buildSummaryLines = buildSummaryLines;
7
8
  exports.buildExplainPayload = buildExplainPayload;
@@ -9,8 +10,10 @@ exports.createBaseline = createBaseline;
9
10
  exports.safeFix = safeFix;
10
11
  const adapters_1 = require("../adapters");
11
12
  const customLeftovers_1 = require("../adapters/customLeftovers");
13
+ const privacyDetector_1 = require("../adapters/privacyDetector");
12
14
  const customRefactor_1 = require("../adapters/customRefactor");
13
15
  const customDeadChain_1 = require("../adapters/customDeadChain");
16
+ const presidio_1 = require("../adapters/presidio");
14
17
  const policy_1 = require("../agentPack/policy");
15
18
  const baseline_1 = require("./baseline");
16
19
  const config_1 = require("./config");
@@ -20,6 +23,7 @@ const scanPlanner_1 = require("./scanPlanner");
20
23
  const scoring_1 = require("./scoring");
21
24
  const toolRunner_1 = require("./toolRunner");
22
25
  const severityMap_1 = require("../rules/severityMap");
26
+ const privacyReview_1 = require("./privacyReview");
23
27
  const ALL_ADAPTERS = [
24
28
  adapters_1.gitleaksAdapter,
25
29
  adapters_1.osvScannerAdapter,
@@ -37,6 +41,9 @@ const ALL_ADAPTERS = [
37
41
  adapters_1.coveragePyAdapter,
38
42
  adapters_1.vitestAdapter,
39
43
  adapters_1.jestAdapter,
44
+ privacyDetector_1.privacyDetectorAdapter,
45
+ presidio_1.presidioAdapter,
46
+ adapters_1.telemetryDetectorAdapter,
40
47
  customLeftovers_1.customLeftoversAdapter,
41
48
  customRefactor_1.customRefactorAdapter
42
49
  ];
@@ -45,11 +52,12 @@ const categoryPriority = {
45
52
  tests: 1,
46
53
  correctness: 2,
47
54
  dependencies: 3,
48
- dead_code: 4,
49
- leftovers: 5,
50
- refactor_readiness: 6,
51
- maintainability: 7,
52
- efficiency: 8
55
+ privacy: 4,
56
+ dead_code: 5,
57
+ leftovers: 6,
58
+ refactor_readiness: 7,
59
+ maintainability: 8,
60
+ efficiency: 9
53
61
  };
54
62
  function sortFindings(findings) {
55
63
  return [...findings].sort((left, right) => {
@@ -82,7 +90,8 @@ function sortFindings(findings) {
82
90
  function summarizeFindings(findings) {
83
91
  const ordered = sortFindings(findings);
84
92
  const blockers = ordered.filter((finding) => severityMap_1.severityRank[finding.severity] >= severityMap_1.severityRank.high);
85
- const fixNext = ordered.filter((finding) => finding.category !== "leftovers").slice(0, 3);
93
+ const fixNext = ordered.filter((finding) => finding.category !== "leftovers" && finding.category !== "privacy").slice(0, 3);
94
+ const privacyFindings = ordered.filter((finding) => finding.category === "privacy");
86
95
  const leftovers = ordered.filter((finding) => finding.category === "leftovers");
87
96
  const deadCodeCandidates = ordered.filter((finding) => finding.category === "dead_code");
88
97
  const refactorCandidates = ordered.filter((finding) => finding.category === "refactor_readiness");
@@ -91,6 +100,7 @@ function summarizeFindings(findings) {
91
100
  ordered,
92
101
  blockers,
93
102
  fixNext,
103
+ privacyFindings,
94
104
  leftovers,
95
105
  deadCodeCandidates,
96
106
  refactorCandidates,
@@ -165,8 +175,18 @@ function targetScore(overall) {
165
175
  function createAgentPlan(scan, options = {}) {
166
176
  const policy = options.policy ?? policy_1.defaultAgentPolicy;
167
177
  const target = options.target ?? "generic";
178
+ const toolStatuses = scan.toolStatuses ?? [];
179
+ const completeness = scan.completeness ?? {
180
+ status: scan.skippedTools.length > 0 ? "partial" : "complete",
181
+ comparable: scan.skippedTools.length === 0,
182
+ planned: 0,
183
+ completed: 0,
184
+ incompleteTools: scan.skippedTools.map((tool) => tool.id),
185
+ requiredIncompleteTools: []
186
+ };
187
+ const recoveryActions = scan.recoveryActions ?? buildRecoveryActions(toolStatuses, scan.skippedTools);
168
188
  const ordered = sortFindings(scan.findings);
169
- const tasks = ordered.slice(0, 5).map((finding, index) => ({
189
+ const tasks = (completeness.status === "invalid" ? [] : ordered.slice(0, 5)).map((finding, index) => ({
170
190
  id: `task-${index + 1}`,
171
191
  title: finding.title,
172
192
  priority: index + 1,
@@ -177,9 +197,12 @@ function createAgentPlan(scan, options = {}) {
177
197
  commands: buildTaskCommands(finding, policy)
178
198
  }));
179
199
  return {
180
- goal: `Raise health score from ${scan.score.overall} to ${targetScore(scan.score.overall)}`,
200
+ goal: completeness.status === "complete"
201
+ ? `Raise health score from ${scan.score.overall} to ${targetScore(scan.score.overall)}`
202
+ : "Recover incomplete checks before changing code, then improve validated findings",
203
+ status: completeness.status,
181
204
  target,
182
- workflow: ["scan", "plan", "safe fix", "edit carefully", "verify", "scan again", "summarize"],
205
+ workflow: ["scan", "validate completeness", "recover tools", "plan", "safe fix", "edit carefully", "verify", "scan again", "summarize"],
183
206
  rules: [
184
207
  "Fix blockers before cleanup work.",
185
208
  "Do not delete low-confidence dead code.",
@@ -188,13 +211,20 @@ function createAgentPlan(scan, options = {}) {
188
211
  ],
189
212
  allowedActions: (0, policy_1.getAllowedActions)(policy),
190
213
  forbiddenActions: (0, policy_1.getForbiddenActions)(policy),
191
- doNotTouch: scan.skippedTools.map((tool) => `Do not assume ${tool.id} was fully checked because the tool was skipped.`),
214
+ doNotTouch: [
215
+ ...scan.skippedTools.map((tool) => `Do not assume ${tool.id} was fully checked because the tool was skipped.`),
216
+ ...toolStatuses
217
+ .filter((tool) => tool.status === "timeout" || tool.status === "error")
218
+ .map((tool) => `Do not treat the health score as complete because ${tool.id} ${tool.status === "timeout" ? "timed out" : "failed"}.`)
219
+ ],
220
+ recoveryActions,
192
221
  tasks
193
222
  };
194
223
  }
195
224
  function buildScanOutput(options) {
196
225
  const summary = summarizeFindings(options.findings);
197
226
  const policy = options.policy ?? policy_1.defaultAgentPolicy;
227
+ const recoveryActions = buildRecoveryActions(options.toolStatuses, options.skippedTools);
198
228
  return {
199
229
  root: options.root,
200
230
  mode: options.mode,
@@ -203,16 +233,23 @@ function buildScanOutput(options) {
203
233
  topFindings: summary.topFindings,
204
234
  blockers: summary.blockers,
205
235
  fixNext: summary.fixNext,
236
+ privacyFindings: summary.privacyFindings,
237
+ privacyReview: options.privacyReview,
206
238
  leftovers: summary.leftovers,
207
239
  deadCodeCandidates: summary.deadCodeCandidates,
208
240
  refactorCandidates: summary.refactorCandidates,
209
241
  toolStatuses: [...options.toolStatuses].sort((left, right) => left.id.localeCompare(right.id)),
210
242
  skippedTools: [...options.skippedTools].sort((left, right) => left.id.localeCompare(right.id)),
243
+ completeness: options.completeness,
244
+ recoveryActions,
211
245
  testCommands: options.testCommands,
212
246
  agentPlan: createAgentPlan({
213
247
  findings: summary.ordered,
214
248
  score: options.score,
249
+ toolStatuses: options.toolStatuses,
215
250
  skippedTools: options.skippedTools,
251
+ completeness: options.completeness,
252
+ recoveryActions,
216
253
  testCommands: options.testCommands
217
254
  }, { policy, target: options.target }),
218
255
  configPath: options.configPath
@@ -234,12 +271,40 @@ function summarizeToolStatus(status) {
234
271
  const message = rawMessage.length > 300 ? `${rawMessage.slice(0, 297)}...` : rawMessage;
235
272
  return { message, command: status.command };
236
273
  }
274
+ // Tools that intentionally use a non-zero exit for "findings reported" or emit
275
+ // experimental warnings on otherwise-successful runs. Shared by runScan and
276
+ // retryTool so a tool never "fails" in one path while "succeeding" in the other.
277
+ function forgiveKnownToolQuirks(toolId, result, findingsCount = 0) {
278
+ if (result.status !== "error") {
279
+ return undefined;
280
+ }
281
+ if (findingsCount > 0) {
282
+ return { status: "ok", message: "Reported issues (debt surfaced as findings)" };
283
+ }
284
+ const output = `${result.stderr}\n${result.stdout}`;
285
+ if (toolId === "biome" && /unstable|experimental/i.test(output)) {
286
+ return { status: "ok" };
287
+ }
288
+ if (toolId === "knip" && result.stdout.trim().startsWith("{")) {
289
+ return { status: "ok", message: "Reported issues (debt surfaced as findings)" };
290
+ }
291
+ if (toolId === "vitest" && /Loaded .*vitest@.*coverage-v8/i.test(output)) {
292
+ return { status: "ok" };
293
+ }
294
+ if (toolId === "osv-scanner" && result.stdout.trim().startsWith("{")) {
295
+ return { status: "ok", message: "Reported vulnerabilities as findings" };
296
+ }
297
+ return undefined;
298
+ }
237
299
  async function runAdapter(adapter, ctx) {
238
300
  if (adapter.runStandalone) {
239
301
  return adapter.runStandalone(ctx);
240
302
  }
241
303
  if (adapter.buildScanCommand && adapter.parseResult) {
242
- const status = await (0, toolRunner_1.runCommand)(adapter.buildScanCommand(ctx), adapter.installHint);
304
+ const command = adapter.buildScanCommand(ctx);
305
+ const timeoutSeconds = ctx.config.runtime.toolTimeouts[adapter.id] ?? ctx.config.runtime.defaultTimeoutSeconds;
306
+ command.timeoutMs = timeoutSeconds * 1000;
307
+ const status = await (0, toolRunner_1.runCommand)(command, adapter.installHint);
243
308
  if (status.status === "skipped") {
244
309
  return { findings: [], status };
245
310
  }
@@ -268,7 +333,8 @@ async function runAdapter(adapter, ctx) {
268
333
  };
269
334
  }
270
335
  async function runScan(root, mode = "default") {
271
- const [{ config, configPath }, { policy }, project] = await Promise.all([(0, config_1.loadConfig)(root), (0, policy_1.loadAgentPolicy)(root), (0, projectDetector_1.detectProject)(root)]);
336
+ const [{ config, configPath }, { policy }] = await Promise.all([(0, config_1.loadConfig)(root), (0, policy_1.loadAgentPolicy)(root)]);
337
+ const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
272
338
  const plan = await (0, scanPlanner_1.createScanPlan)(project, config, [...ALL_ADAPTERS], mode);
273
339
  const ctx = { root, project, config, scanMode: mode };
274
340
  const selectedAdapters = ALL_ADAPTERS.filter((adapter) => plan.adapterIds.includes(adapter.id));
@@ -291,29 +357,42 @@ async function runScan(root, mode = "default") {
291
357
  });
292
358
  continue;
293
359
  }
294
- toolStatuses.push({ id: adapter.id, status: result.status.status, ...summarizeToolStatus(result.status) });
295
- }
296
- // Ouroboros/self-scan improvement: normalize statuses for tools that intentionally use non-zero exit for "findings reported"
297
- // or emit experimental warnings on otherwise-successful report formats (biome --reporter=json, knip exit-on-issues).
298
- // This prevents noise in "ERRORED TOOLS" while still surfacing real parse/crash errors.
299
- for (const ts of toolStatuses) {
300
- if (ts.id === "biome" && /unstable|experimental/i.test(ts.message || "")) {
301
- ts.status = "ok";
302
- ts.message = undefined;
303
- }
304
- if (ts.id === "knip" && ts.status === "error" && (ts.message || "").trim().startsWith("{")) {
305
- ts.status = "ok";
306
- ts.message = "Reported issues (debt surfaced as findings)";
307
- }
308
- if (ts.id === "vitest" && /Loaded .*vitest@.*coverage-v8/i.test(ts.message || "")) {
309
- // Vitest coverage adapter produces startup "Loaded ..." logs; treat as success when the dependency is available and a report was produced.
310
- ts.status = "ok";
311
- ts.message = undefined;
312
- }
360
+ const forgiven = forgiveKnownToolQuirks(adapter.id, result.status, result.findings.length);
361
+ const summarized = summarizeToolStatus(result.status);
362
+ toolStatuses.push({
363
+ id: adapter.id,
364
+ status: forgiven?.status ?? result.status.status,
365
+ ...summarized,
366
+ ...(forgiven ? { message: forgiven.message } : {})
367
+ });
313
368
  }
369
+ const incompleteTools = Array.from(new Set([
370
+ ...skippedTools.map((tool) => tool.id),
371
+ ...toolStatuses.filter((tool) => tool.status === "error" || tool.status === "timeout").map((tool) => tool.id)
372
+ ])).sort();
373
+ // Skipped tools can include checks that were never selected as adapters
374
+ // (built-in checks, mode-filtered tools); count them in the denominator so
375
+ // "completed" never underflows.
376
+ const plannedIds = new Set([...selectedAdapters.map((adapter) => adapter.id), ...incompleteTools]);
377
+ const requiredIncompleteTools = incompleteTools.filter((id) => config.runtime.requiredTools.includes(id));
378
+ const completeness = {
379
+ status: incompleteTools.length === 0
380
+ ? "complete"
381
+ : requiredIncompleteTools.length > 0 || config.runtime.failOnIncompleteScan
382
+ ? "invalid"
383
+ : "partial",
384
+ comparable: incompleteTools.length === 0,
385
+ planned: plannedIds.size,
386
+ completed: plannedIds.size - incompleteTools.length,
387
+ incompleteTools,
388
+ requiredIncompleteTools,
389
+ reason: incompleteTools.length > 0
390
+ ? `${incompleteTools.length} of ${plannedIds.size} planned checks did not complete.`
391
+ : undefined
392
+ };
314
393
  let deadChainFindings = [];
315
394
  if (config.checks.deadCode.enabled) {
316
- const rawDead = await (0, customDeadChain_1.detectDeadChains)(project, findings);
395
+ const rawDead = await (0, customDeadChain_1.detectDeadChains)(project, findings, config);
317
396
  const minConf = config.checks.deadCode.minConfidenceToReport;
318
397
  const rank = { low: 0, medium: 1, high: 2 };
319
398
  const minRank = rank[minConf];
@@ -324,6 +403,8 @@ async function runScan(root, mode = "default") {
324
403
  const baseline = await (0, baseline_1.loadBaseline)(root, config.baseline.file);
325
404
  allFindings = (0, finding_1.applyBaseline)(allFindings, new Set(baseline.findings.map((entry) => entry.fingerprint)));
326
405
  }
406
+ const privacyReview = await (0, privacyReview_1.loadPrivacyReview)(root, config.output.privacyReview);
407
+ allFindings = (0, privacyReview_1.mergePrivacyReviewIntoFindings)(allFindings, privacyReview);
327
408
  allFindings = sortFindings(allFindings);
328
409
  const score = (0, scoring_1.buildScore)(allFindings);
329
410
  return buildScanOutput({
@@ -333,11 +414,79 @@ async function runScan(root, mode = "default") {
333
414
  score,
334
415
  toolStatuses,
335
416
  skippedTools,
417
+ completeness,
336
418
  testCommands: project.testCommands,
337
419
  policy,
338
- configPath
420
+ configPath,
421
+ privacyReview: privacyReview?.summary
339
422
  });
340
423
  }
424
+ async function retryTool(root, toolId, timeoutSeconds) {
425
+ const { config } = await (0, config_1.loadConfig)(root);
426
+ const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
427
+ const adapter = ALL_ADAPTERS.find((candidate) => candidate.id === toolId);
428
+ if (!adapter || !adapter.buildScanCommand || !adapter.parseResult) {
429
+ return {
430
+ tool: toolId,
431
+ status: "skipped",
432
+ timeoutSeconds: timeoutSeconds ?? config.runtime.defaultTimeoutSeconds,
433
+ findings: [],
434
+ message: `Tool ${toolId} is unknown or does not support isolated retry.`,
435
+ successCondition: `${toolId} completes with status ok`,
436
+ nextAction: "Run vibedoctor scan --full --report agent-json and request human review if the tool remains incomplete."
437
+ };
438
+ }
439
+ const ctx = { root, project, config, scanMode: "full" };
440
+ const seconds = timeoutSeconds ?? Math.max(config.runtime.defaultTimeoutSeconds, (config.runtime.toolTimeouts[toolId] ?? config.runtime.defaultTimeoutSeconds) * 2);
441
+ const command = adapter.buildScanCommand(ctx);
442
+ command.timeoutMs = seconds * 1000;
443
+ const result = await (0, toolRunner_1.runCommand)(command, adapter.installHint);
444
+ let parseError;
445
+ let findings = [];
446
+ if (result.status !== "skipped") {
447
+ try {
448
+ findings = adapter.parseResult(result, ctx) ?? [];
449
+ }
450
+ catch (error) {
451
+ // A run that produced unparseable output is not a success; report it so
452
+ // agents do not mistake "ok with zero findings" for a clean result.
453
+ parseError = `Could not parse ${toolId} output: ${error instanceof Error ? error.message : String(error)}`;
454
+ }
455
+ }
456
+ const forgiven = forgiveKnownToolQuirks(toolId, result, findings.length);
457
+ const status = parseError ? "error" : forgiven?.status ?? result.status;
458
+ const summary = summarizeToolStatus(result);
459
+ return {
460
+ tool: toolId,
461
+ status,
462
+ timeoutSeconds: seconds,
463
+ findings,
464
+ message: parseError ?? forgiven?.message ?? summary.message,
465
+ successCondition: `${toolId} completes with status ok`,
466
+ nextAction: status === "ok"
467
+ ? "Run vibedoctor scan --full --report agent-json to produce a comparable health result."
468
+ : `Keep the scan partial and disclose missing ${toolId} coverage before changing risky code.`
469
+ };
470
+ }
471
+ function buildRecoveryActions(toolStatuses, skippedTools = []) {
472
+ const failed = toolStatuses
473
+ .filter((tool) => tool.status === "timeout" || tool.status === "error")
474
+ .map((tool) => ({
475
+ id: `recover-${tool.id}`,
476
+ tool: tool.id,
477
+ command: `vibedoctor tool retry ${tool.id}`,
478
+ successCondition: `${tool.id} completes with status ok`,
479
+ onFailure: `Keep the scan partial, disclose missing ${tool.id} coverage, and request human review before risky changes.`
480
+ }));
481
+ const skipped = skippedTools.map((tool) => ({
482
+ id: `recover-${tool.id}`,
483
+ tool: tool.id,
484
+ command: "vibedoctor setup --include recommended",
485
+ successCondition: `${tool.id} is installed and completes on the next scan`,
486
+ onFailure: `${(tool.installHint ?? `Install ${tool.id}`).replace(/[.,;:]$/, "")}, then rerun the scan; otherwise disclose missing ${tool.id} coverage.`
487
+ }));
488
+ return [...failed, ...skipped];
489
+ }
341
490
  function filterScanByCategories(scan, categories, options = {}) {
342
491
  const findings = sortFindings(scan.findings.filter((finding) => categories.includes(finding.category)));
343
492
  const score = (0, scoring_1.buildScore)(findings);
@@ -348,16 +497,24 @@ function filterScanByCategories(scan, categories, options = {}) {
348
497
  score,
349
498
  toolStatuses: scan.toolStatuses,
350
499
  skippedTools: scan.skippedTools,
500
+ completeness: scan.completeness,
351
501
  testCommands: scan.testCommands,
352
502
  policy: options.policy,
353
503
  target: options.target ?? scan.agentPlan.target,
354
- configPath: scan.configPath
504
+ configPath: scan.configPath,
505
+ privacyReview: scan.privacyReview
355
506
  });
356
507
  }
357
508
  function buildSummaryLines(scan) {
358
- const lines = [`Health: ${scan.score.overall}/100 ${scan.score.overall >= 85 ? "✅" : "⚠️"}`, ""];
509
+ const lines = [
510
+ `Health: ${scan.score.overall}/100 — ${scan.completeness.status.toUpperCase()} ${scan.score.overall >= 85 ? "✅" : "⚠️"}`,
511
+ `Scan coverage: ${scan.completeness.completed}/${scan.completeness.planned} checks completed`,
512
+ ...(scan.completeness.comparable ? [] : ["This score is not comparable to a complete scan."]),
513
+ ""
514
+ ];
359
515
  lines.push(`Blockers: ${scan.blockers.length}`);
360
516
  lines.push(`Fix next: ${scan.fixNext.length}`);
517
+ lines.push(`Privacy Review findings: ${scan.privacyFindings.length}`);
361
518
  lines.push(`Leftovers: ${scan.leftovers.length}`);
362
519
  lines.push(`Dead code candidates: ${scan.deadCodeCandidates.length}`);
363
520
  lines.push(`Refactor candidates: ${scan.refactorCandidates.length}`);
@@ -369,6 +526,12 @@ function buildSummaryLines(scan) {
369
526
  lines.push("", "FIX NEXT");
370
527
  scan.fixNext.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file})` : ""}`));
371
528
  }
529
+ if (scan.privacyFindings.length > 0) {
530
+ lines.push("", "PRIVACY REVIEW FINDINGS");
531
+ scan.privacyFindings
532
+ .slice(0, 5)
533
+ .forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file}${finding.startLine ? `:${finding.startLine}` : ""})` : ""}`));
534
+ }
372
535
  if (scan.leftovers.length > 0) {
373
536
  lines.push("", "LEFTOVERS");
374
537
  scan.leftovers.forEach((finding, index) => lines.push(`${index + 1}. ${finding.title}${finding.file ? ` (${finding.file})` : ""}`));
@@ -386,6 +549,10 @@ function buildSummaryLines(scan) {
386
549
  lines.push("", "ERRORED TOOLS");
387
550
  erroredTools.forEach((tool, index) => lines.push(`${index + 1}. ${tool.id}${tool.message ? ` — ${tool.message}` : ` — ${tool.status}`}`));
388
551
  }
552
+ if (scan.recoveryActions.length > 0) {
553
+ lines.push("", "RECOVER BEFORE EDITING");
554
+ scan.recoveryActions.forEach((action, index) => lines.push(`${index + 1}. ${action.command} — success: ${action.successCondition}`));
555
+ }
389
556
  lines.push("", "READY FOR AGENT", "Run:", "vibedoctor agent-plan");
390
557
  return lines;
391
558
  }
@@ -420,7 +587,8 @@ async function createBaseline(root) {
420
587
  }
421
588
  async function safeFix(root) {
422
589
  const before = await runScan(root, "default");
423
- const [{ config }, project] = await Promise.all([(0, config_1.loadConfig)(root), (0, projectDetector_1.detectProject)(root)]);
590
+ const { config } = await (0, config_1.loadConfig)(root);
591
+ const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
424
592
  const ctx = { root, project, config, scanMode: "default" };
425
593
  const fixableAdapters = ALL_ADAPTERS.filter((adapter) => adapter.buildFixCommand && adapter.detect);
426
594
  const results = [];
@@ -1,5 +1,5 @@
1
- export declare const FINDING_SOURCES: readonly ["ruff", "biome", "tsc", "pyright", "semgrep", "gitleaks", "osv-scanner", "knip", "vulture", "deptry", "jscpd", "lizard", "radon", "coverage.py", "vitest", "jest", "custom-leftovers", "custom-refactor", "custom-dead-chain"];
2
- export declare const FINDING_CATEGORIES: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "efficiency", "refactor_readiness"];
1
+ export declare const FINDING_SOURCES: readonly ["ruff", "biome", "tsc", "pyright", "semgrep", "gitleaks", "osv-scanner", "knip", "vulture", "deptry", "jscpd", "lizard", "radon", "coverage.py", "vitest", "jest", "privacy-detector", "presidio", "privacy-ai-review", "telemetry-detector", "custom-leftovers", "custom-refactor", "custom-dead-chain"];
2
+ export declare const FINDING_CATEGORIES: readonly ["security", "correctness", "dead_code", "leftovers", "maintainability", "dependencies", "tests", "privacy", "efficiency", "refactor_readiness"];
3
3
  export type FindingSource = (typeof FINDING_SOURCES)[number];
4
4
  export type FindingCategory = (typeof FINDING_CATEGORIES)[number];
5
5
  export type Severity = "info" | "low" | "medium" | "high" | "critical";
@@ -25,6 +25,20 @@ export type Finding = {
25
25
  snippet?: string;
26
26
  toolRawId?: string;
27
27
  matchedPattern?: string;
28
+ detector?: string;
29
+ entityType?: string;
30
+ sensitivity?: string;
31
+ maskedValue?: string;
32
+ fieldPath?: string;
33
+ detectionPath?: string;
34
+ confidenceScore?: number;
35
+ coverageConfidence?: number;
36
+ reviewState?: "confirmed" | "likely" | "false_positive" | "needs_human_review";
37
+ reviewedAt?: string;
38
+ reviewedBy?: string;
39
+ rationale?: string;
40
+ recommendedAction?: string;
41
+ reasons?: string[];
28
42
  };
29
43
  scoreImpact: number;
30
44
  };
@@ -30,6 +30,10 @@ exports.FINDING_SOURCES = [
30
30
  "coverage.py",
31
31
  "vitest",
32
32
  "jest",
33
+ "privacy-detector",
34
+ "presidio",
35
+ "privacy-ai-review",
36
+ "telemetry-detector",
33
37
  "custom-leftovers",
34
38
  "custom-refactor",
35
39
  "custom-dead-chain"
@@ -42,6 +46,7 @@ exports.FINDING_CATEGORIES = [
42
46
  "maintainability",
43
47
  "dependencies",
44
48
  "tests",
49
+ "privacy",
45
50
  "efficiency",
46
51
  "refactor_readiness"
47
52
  ];
@@ -23,7 +23,12 @@ exports.DEFAULT_EXCLUDES = [
23
23
  "**/.venv/**",
24
24
  "coverage/**",
25
25
  ".next/**",
26
+ "**/.next/**",
26
27
  "vendor/**",
28
+ ".agents/**",
29
+ "**/.agents/**",
30
+ ".vibedoctor/**",
31
+ "**/.vibedoctor/**",
27
32
  ".git/**",
28
33
  "**/__pycache__/**",
29
34
  "**/*.egg-info/**"
@@ -0,0 +1,51 @@
1
+ import type { Finding } from "./finding";
2
+ export type PrivacyReviewState = "confirmed" | "likely" | "false_positive" | "needs_human_review";
3
+ export type PrivacyReviewStatus = "ok" | "needs_human_review" | "ai_error";
4
+ export type PrivacyReviewFinding = {
5
+ id: string;
6
+ title: string;
7
+ file?: string;
8
+ startLine?: number;
9
+ entityType?: string;
10
+ sensitivity?: string;
11
+ reviewState: PrivacyReviewState;
12
+ reviewedAt: string;
13
+ reviewedBy: string;
14
+ rationale: string;
15
+ recommendedAction: string;
16
+ };
17
+ export type PrivacyReviewSummary = {
18
+ total: number;
19
+ confirmed: number;
20
+ likely: number;
21
+ falsePositive: number;
22
+ needsHumanReview: number;
23
+ regulatedIdentifiers: number;
24
+ sensitiveAttributes: number;
25
+ combinationRisk: number;
26
+ generatedAt?: string;
27
+ reviewedBy?: string;
28
+ model?: string;
29
+ status?: PrivacyReviewStatus;
30
+ };
31
+ export type PrivacyReviewArtifact = {
32
+ version: 1;
33
+ generatedAt: string;
34
+ reviewedBy: string;
35
+ model?: string;
36
+ status: PrivacyReviewStatus;
37
+ summary: PrivacyReviewSummary;
38
+ findings: PrivacyReviewFinding[];
39
+ };
40
+ export declare const DEFAULT_PRIVACY_REVIEW_FILE = ".vibedoctor/privacy-review.json";
41
+ export declare function summarizePrivacyReview(findings: PrivacyReviewFinding[], metadata: Pick<PrivacyReviewArtifact, "generatedAt" | "reviewedBy" | "model" | "status">): PrivacyReviewSummary;
42
+ export declare function buildPrivacyReviewArtifact(options: {
43
+ generatedAt: string;
44
+ reviewedBy: string;
45
+ model?: string;
46
+ status: PrivacyReviewStatus;
47
+ findings: PrivacyReviewFinding[];
48
+ }): PrivacyReviewArtifact;
49
+ export declare function loadPrivacyReview(root: string, reviewFile?: string): Promise<PrivacyReviewArtifact | undefined>;
50
+ export declare function writePrivacyReview(root: string, artifact: PrivacyReviewArtifact, reviewFile?: string): Promise<string>;
51
+ export declare function mergePrivacyReviewIntoFindings(findings: Finding[], artifact: PrivacyReviewArtifact | undefined): Finding[];
@@ -0,0 +1,94 @@
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.DEFAULT_PRIVACY_REVIEW_FILE = void 0;
7
+ exports.summarizePrivacyReview = summarizePrivacyReview;
8
+ exports.buildPrivacyReviewArtifact = buildPrivacyReviewArtifact;
9
+ exports.loadPrivacyReview = loadPrivacyReview;
10
+ exports.writePrivacyReview = writePrivacyReview;
11
+ exports.mergePrivacyReviewIntoFindings = mergePrivacyReviewIntoFindings;
12
+ const node_fs_1 = require("node:fs");
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ const paths_1 = require("./paths");
15
+ exports.DEFAULT_PRIVACY_REVIEW_FILE = ".vibedoctor/privacy-review.json";
16
+ function toAbsolutePath(root, reviewFile) {
17
+ return node_path_1.default.isAbsolute(reviewFile) ? reviewFile : node_path_1.default.join(root, reviewFile);
18
+ }
19
+ function summarizePrivacyReview(findings, metadata) {
20
+ return {
21
+ total: findings.length,
22
+ confirmed: findings.filter((finding) => finding.reviewState === "confirmed").length,
23
+ likely: findings.filter((finding) => finding.reviewState === "likely").length,
24
+ falsePositive: findings.filter((finding) => finding.reviewState === "false_positive").length,
25
+ needsHumanReview: findings.filter((finding) => finding.reviewState === "needs_human_review").length,
26
+ regulatedIdentifiers: findings.filter((finding) => finding.sensitivity === "regulated_identifier").length,
27
+ sensitiveAttributes: findings.filter((finding) => finding.sensitivity === "high").length,
28
+ combinationRisk: findings.filter((finding) => finding.sensitivity === "combination_risk").length,
29
+ generatedAt: metadata.generatedAt,
30
+ reviewedBy: metadata.reviewedBy,
31
+ model: metadata.model,
32
+ status: metadata.status
33
+ };
34
+ }
35
+ function buildPrivacyReviewArtifact(options) {
36
+ return {
37
+ version: 1,
38
+ generatedAt: options.generatedAt,
39
+ reviewedBy: options.reviewedBy,
40
+ model: options.model,
41
+ status: options.status,
42
+ findings: options.findings,
43
+ summary: summarizePrivacyReview(options.findings, options)
44
+ };
45
+ }
46
+ async function loadPrivacyReview(root, reviewFile = exports.DEFAULT_PRIVACY_REVIEW_FILE) {
47
+ const reviewPath = toAbsolutePath(root, reviewFile);
48
+ if (!(await (0, paths_1.pathExists)(reviewPath))) {
49
+ return undefined;
50
+ }
51
+ const parsed = JSON.parse(await node_fs_1.promises.readFile(reviewPath, "utf8"));
52
+ if (parsed.version !== 1 || !Array.isArray(parsed.findings)) {
53
+ return undefined;
54
+ }
55
+ const generatedAt = parsed.generatedAt ?? "";
56
+ const reviewedBy = parsed.reviewedBy ?? "unknown";
57
+ const status = parsed.status ?? "needs_human_review";
58
+ return buildPrivacyReviewArtifact({
59
+ generatedAt,
60
+ reviewedBy,
61
+ model: parsed.model,
62
+ status,
63
+ findings: parsed.findings.filter((finding) => typeof finding.id === "string")
64
+ });
65
+ }
66
+ async function writePrivacyReview(root, artifact, reviewFile = exports.DEFAULT_PRIVACY_REVIEW_FILE) {
67
+ const reviewPath = toAbsolutePath(root, reviewFile);
68
+ await (0, paths_1.ensureDir)(node_path_1.default.dirname(reviewPath));
69
+ await node_fs_1.promises.writeFile(reviewPath, `${JSON.stringify(artifact, null, 2)}\n`, "utf8");
70
+ return reviewPath;
71
+ }
72
+ function mergePrivacyReviewIntoFindings(findings, artifact) {
73
+ if (!artifact) {
74
+ return findings;
75
+ }
76
+ const byId = new Map(artifact.findings.map((finding) => [finding.id, finding]));
77
+ return findings.map((finding) => {
78
+ const review = byId.get(finding.id);
79
+ if (!review) {
80
+ return finding;
81
+ }
82
+ return {
83
+ ...finding,
84
+ evidence: {
85
+ ...finding.evidence,
86
+ reviewState: review.reviewState,
87
+ reviewedAt: review.reviewedAt,
88
+ reviewedBy: review.reviewedBy,
89
+ rationale: review.rationale,
90
+ recommendedAction: review.recommendedAction
91
+ }
92
+ };
93
+ });
94
+ }
@@ -14,4 +14,4 @@ export type ProjectContext = {
14
14
  entryFiles: string[];
15
15
  projectFiles: string[];
16
16
  };
17
- export declare function detectProject(root: string): Promise<ProjectContext>;
17
+ export declare function detectProject(root: string, excludePatterns?: string[]): Promise<ProjectContext>;