@neuralaxis/vibedoctor 0.1.3 → 0.2.1

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 (112) hide show
  1. package/README.md +298 -115
  2. package/dist/adapters/biome.js +135 -21
  3. package/dist/adapters/dpdp.d.ts +6 -0
  4. package/dist/adapters/dpdp.js +34 -0
  5. package/dist/adapters/index.d.ts +1 -0
  6. package/dist/adapters/index.js +3 -1
  7. package/dist/adapters/osvScanner.js +136 -17
  8. package/dist/adapters/presidio.js +6 -2
  9. package/dist/adapters/privacyDetector.d.ts +24 -1
  10. package/dist/adapters/privacyDetector.js +86 -2
  11. package/dist/adapters/shared.d.ts +6 -0
  12. package/dist/agentPack/templates/skills.js +159 -53
  13. package/dist/cli/commands/dpdp.d.ts +35 -0
  14. package/dist/cli/commands/dpdp.js +103 -0
  15. package/dist/cli/commands/init.js +105 -50
  16. package/dist/cli/commands/privacyReview.js +3 -4
  17. package/dist/cli/commands/scan.js +4 -1
  18. package/dist/cli/commands/setup.d.ts +13 -17
  19. package/dist/cli/commands/setup.js +138 -200
  20. package/dist/cli/index.js +84 -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 +57 -0
  24. package/dist/core/config.js +194 -7
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +21 -0
  28. package/dist/core/engine.js +484 -84
  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 +63 -5
  35. package/dist/core/findingNormalizer.d.ts +33 -0
  36. package/dist/core/findingNormalizer.js +171 -0
  37. package/dist/core/projectDetector.d.ts +13 -0
  38. package/dist/core/projectDetector.js +100 -15
  39. package/dist/core/relevance.d.ts +87 -0
  40. package/dist/core/relevance.js +367 -0
  41. package/dist/core/scanPlanner.d.ts +12 -0
  42. package/dist/core/scanPlanner.js +61 -29
  43. package/dist/core/semverLite.d.ts +27 -0
  44. package/dist/core/semverLite.js +163 -0
  45. package/dist/core/suppressions.d.ts +96 -0
  46. package/dist/core/suppressions.js +302 -0
  47. package/dist/core/toolRegistry.d.ts +58 -0
  48. package/dist/core/toolRegistry.js +247 -0
  49. package/dist/core/toolRunner.d.ts +23 -2
  50. package/dist/core/toolRunner.js +61 -93
  51. package/dist/core/toolVerification.d.ts +87 -0
  52. package/dist/core/toolVerification.js +370 -0
  53. package/dist/dpdp/artifacts.d.ts +11 -0
  54. package/dist/dpdp/artifacts.js +120 -0
  55. package/dist/dpdp/catalogue.d.ts +14 -0
  56. package/dist/dpdp/catalogue.js +661 -0
  57. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  58. package/dist/dpdp/collectors/confidence.js +25 -0
  59. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  60. package/dist/dpdp/collectors/dependencies.js +63 -0
  61. package/dist/dpdp/collectors/index.d.ts +24 -0
  62. package/dist/dpdp/collectors/index.js +71 -0
  63. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  64. package/dist/dpdp/collectors/lifecycle.js +202 -0
  65. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  66. package/dist/dpdp/collectors/optionalScanners.js +437 -0
  67. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  68. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  69. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  70. package/dist/dpdp/collectors/safeguards.js +186 -0
  71. package/dist/dpdp/collectors/schema.d.ts +6 -0
  72. package/dist/dpdp/collectors/schema.js +122 -0
  73. package/dist/dpdp/collectors/shared.d.ts +10 -0
  74. package/dist/dpdp/collectors/shared.js +43 -0
  75. package/dist/dpdp/context.d.ts +28 -0
  76. package/dist/dpdp/context.js +195 -0
  77. package/dist/dpdp/dataMap.d.ts +7 -0
  78. package/dist/dpdp/dataMap.js +339 -0
  79. package/dist/dpdp/evaluators.d.ts +20 -0
  80. package/dist/dpdp/evaluators.js +522 -0
  81. package/dist/dpdp/evidence.d.ts +11 -0
  82. package/dist/dpdp/evidence.js +123 -0
  83. package/dist/dpdp/findings.d.ts +44 -0
  84. package/dist/dpdp/findings.js +286 -0
  85. package/dist/dpdp/gates.d.ts +14 -0
  86. package/dist/dpdp/gates.js +47 -0
  87. package/dist/dpdp/index.d.ts +16 -0
  88. package/dist/dpdp/index.js +32 -0
  89. package/dist/dpdp/legalSources.d.ts +10 -0
  90. package/dist/dpdp/legalSources.js +104 -0
  91. package/dist/dpdp/paths.d.ts +25 -0
  92. package/dist/dpdp/paths.js +85 -0
  93. package/dist/dpdp/report.d.ts +6 -0
  94. package/dist/dpdp/report.js +222 -0
  95. package/dist/dpdp/reviewQueue.d.ts +3 -0
  96. package/dist/dpdp/reviewQueue.js +88 -0
  97. package/dist/dpdp/scan.d.ts +26 -0
  98. package/dist/dpdp/scan.js +310 -0
  99. package/dist/dpdp/scoring.d.ts +41 -0
  100. package/dist/dpdp/scoring.js +237 -0
  101. package/dist/dpdp/types.d.ts +312 -0
  102. package/dist/dpdp/types.js +86 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/mcp/tools/dpdp.d.ts +11 -0
  106. package/dist/mcp/tools/dpdp.js +151 -0
  107. package/dist/mcp/tools/index.js +3 -1
  108. package/dist/reporters/html.js +57 -13
  109. package/dist/reporters/json.js +12 -1
  110. package/dist/reporters/markdown.js +46 -4
  111. package/dist/reporters/sarif.js +54 -5
  112. package/package.json +4 -1
@@ -10,165 +10,17 @@ const toolRunner_1 = require("../../core/toolRunner");
10
10
  const projectDetector_1 = require("../../core/projectDetector");
11
11
  const config_1 = require("../../core/config");
12
12
  const paths_1 = require("../../core/paths");
13
- const VALID_SETUP_INCLUDES = new Set(["essential", "recommended", "all", "npm", "python", "manual", "built-in"]);
14
- const essentialTools = [
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: "tsc",
41
- packageName: "typescript",
42
- executable: "tsc",
43
- ecosystem: "npm",
44
- priority: "essential",
45
- languages: ["typescript"],
46
- reason: "TypeScript correctness signal."
47
- },
48
- {
49
- id: "biome",
50
- packageName: "@biomejs/biome",
51
- executable: "biome",
52
- ecosystem: "npm",
53
- priority: "essential",
54
- languages: ["javascript", "typescript"],
55
- reason: "Fast JS/TS lint and safe formatting signal."
56
- },
57
- {
58
- id: "knip",
59
- packageName: "knip",
60
- executable: "knip",
61
- ecosystem: "npm",
62
- priority: "essential",
63
- languages: ["javascript", "typescript"],
64
- reason: "Unused files, exports, and dependency signal for JS/TS."
65
- },
66
- {
67
- id: "ruff",
68
- packageName: "ruff",
69
- executable: "ruff",
70
- ecosystem: "python",
71
- priority: "essential",
72
- languages: ["python"],
73
- reason: "Python lint and safe-fix signal."
74
- },
75
- {
76
- id: "pyright",
77
- packageName: "pyright",
78
- executable: "pyright",
79
- ecosystem: "python",
80
- priority: "essential",
81
- languages: ["python"],
82
- reason: "Python type correctness signal."
83
- },
84
- {
85
- id: "vulture",
86
- packageName: "vulture",
87
- executable: "vulture",
88
- ecosystem: "python",
89
- priority: "essential",
90
- languages: ["python"],
91
- reason: "Python dead-code signal."
92
- },
93
- {
94
- id: "gitleaks",
95
- executable: "gitleaks",
96
- ecosystem: "manual",
97
- priority: "essential",
98
- reason: "Secret detection across every repository.",
99
- installHint: "Install Gitleaks from https://gitleaks.io/ or your OS package manager."
100
- },
101
- {
102
- id: "osv-scanner",
103
- executable: "osv-scanner",
104
- ecosystem: "manual",
105
- priority: "essential",
106
- requiresLockfile: true,
107
- reason: "Known-vulnerability detection for dependency lockfiles.",
108
- installHint: "Install OSV-Scanner from https://google.github.io/osv-scanner/ or your OS package manager."
109
- }
110
- ];
111
- const recommendedTools = [
112
- {
113
- id: "jscpd",
114
- packageName: "jscpd",
115
- executable: "jscpd",
116
- ecosystem: "npm",
117
- priority: "recommended",
118
- languages: ["javascript", "typescript"],
119
- reason: "Duplication signal for refactor planning."
120
- },
121
- {
122
- id: "coverage.py",
123
- packageName: "coverage",
124
- executable: "coverage",
125
- ecosystem: "python",
126
- priority: "recommended",
127
- languages: ["python"],
128
- reason: "Python coverage signal."
129
- },
130
- {
131
- id: "radon",
132
- packageName: "radon",
133
- executable: "radon",
134
- ecosystem: "python",
135
- priority: "recommended",
136
- languages: ["python"],
137
- reason: "Python complexity signal."
138
- },
139
- {
140
- id: "deptry",
141
- packageName: "deptry",
142
- executable: "deptry",
143
- ecosystem: "python",
144
- priority: "recommended",
145
- languages: ["python"],
146
- reason: "Python dependency hygiene signal."
147
- },
148
- {
149
- id: "lizard",
150
- executable: "lizard",
151
- ecosystem: "manual",
152
- priority: "recommended",
153
- reason: "Function-level complexity and code size hotspots (great for spotting refactor candidates).",
154
- installHint: "Install Lizard with: pipx install lizard, uv tool install lizard, or your OS package manager."
155
- },
156
- {
157
- id: "semgrep",
158
- executable: "semgrep",
159
- ecosystem: "manual",
160
- priority: "recommended",
161
- reason: "Additional security and correctness rules.",
162
- installHint: "Install Semgrep with: pipx install semgrep, uv tool install semgrep, or your OS package manager."
163
- },
164
- {
165
- id: "presidio",
166
- ecosystem: "manual",
167
- priority: "recommended",
168
- reason: "Optional external scanner for Privacy Review when checks.privacy.presidio.enabled is true.",
169
- installHint: "Install in the project Python environment with: python -m pip install presidio-analyzer"
170
- }
171
- ];
13
+ const toolRegistry_1 = require("../../core/toolRegistry");
14
+ const toolVerification_1 = require("../../core/toolVerification");
15
+ const VALID_SETUP_INCLUDES = new Set([
16
+ "essential",
17
+ "recommended",
18
+ "all",
19
+ "npm",
20
+ "python",
21
+ "manual",
22
+ "built-in"
23
+ ]);
172
24
  function hasActiveLanguage(project, language) {
173
25
  if (!project.languages.includes(language)) {
174
26
  return false;
@@ -176,7 +28,8 @@ function hasActiveLanguage(project, language) {
176
28
  if (language === "python" && project.packageManagers.some((manager) => ["pip", "uv", "poetry", "pdm"].includes(manager))) {
177
29
  return true;
178
30
  }
179
- if ((language === "javascript" || language === "typescript") && project.packageManagers.some((manager) => ["npm", "pnpm", "yarn", "bun"].includes(manager))) {
31
+ if ((language === "javascript" || language === "typescript") &&
32
+ project.packageManagers.some((manager) => ["npm", "pnpm", "yarn", "bun"].includes(manager))) {
180
33
  return true;
181
34
  }
182
35
  const sourcePattern = language === "python"
@@ -201,12 +54,6 @@ function appliesToProject(tool, project) {
201
54
  }
202
55
  return true;
203
56
  }
204
- function isToolAvailable(tool, project) {
205
- if (!tool.executable) {
206
- return false;
207
- }
208
- return Boolean(project.toolsAvailable[tool.executable] ?? project.toolsAvailable[tool.id]);
209
- }
210
57
  function jsPackageManager(project) {
211
58
  return ["pnpm", "yarn", "bun", "npm"].find((manager) => project.packageManagers.includes(manager));
212
59
  }
@@ -222,7 +69,13 @@ function jsInstallCommand(root, manager, packages) {
222
69
  }
223
70
  return { cmd: "npm", args: ["install", "-D", ...packages], cwd: root, timeoutMs: 180_000 };
224
71
  }
225
- async function pythonInstallCommand(root, project, packages) {
72
+ /**
73
+ * Chooses how to install Python packages. Returns undefined when there is no
74
+ * interpreter or environment to install into — previously this produced an
75
+ * install command that failed at spawn time and was reported as a skip, which
76
+ * read like success.
77
+ */
78
+ async function pythonInstallCommand(root, project, packages, runtimes) {
226
79
  if (project.packageManagers.includes("uv")) {
227
80
  return { cmd: "uv", args: ["add", "--dev", ...packages], cwd: root, timeoutMs: 180_000 };
228
81
  }
@@ -232,42 +85,49 @@ async function pythonInstallCommand(root, project, packages) {
232
85
  if (project.packageManagers.includes("pdm")) {
233
86
  return { cmd: "pdm", args: ["add", "-dG", "dev", ...packages], cwd: root, timeoutMs: 180_000 };
234
87
  }
235
- const hasLocalVenv = Boolean(process.env.VIRTUAL_ENV) || (await (0, paths_1.pathExists)(node_path_1.default.join(root, ".venv"))) || (await (0, paths_1.pathExists)(node_path_1.default.join(root, "venv")));
88
+ const python = runtimes.python;
89
+ if (!python?.available || !python.command) {
90
+ return undefined;
91
+ }
92
+ const hasLocalVenv = Boolean(process.env.VIRTUAL_ENV) ||
93
+ (await (0, paths_1.pathExists)(node_path_1.default.join(root, ".venv"))) ||
94
+ (await (0, paths_1.pathExists)(node_path_1.default.join(root, "venv")));
236
95
  if (!hasLocalVenv) {
237
96
  return undefined;
238
97
  }
239
- return { cmd: "python", args: ["-m", "pip", "install", "-U", ...packages], cwd: root, timeoutMs: 180_000 };
98
+ return { cmd: python.command, args: ["-m", "pip", "install", "-U", ...packages], cwd: root, timeoutMs: 180_000 };
240
99
  }
241
100
  function commandText(command) {
242
101
  return [command.cmd, ...command.args].join(" ");
243
102
  }
244
103
  function resolveTools(include) {
245
104
  if (include === "essential") {
246
- return essentialTools;
105
+ return toolRegistry_1.TOOL_REGISTRY.filter((tool) => tool.priority === "essential");
247
106
  }
248
- const combined = [...essentialTools, ...recommendedTools];
249
107
  if (include === "recommended" || include === "all") {
250
108
  // "recommended" is the sensible default experience (essential + high-value extras).
251
109
  // "all" currently resolves to the same set (add future extended tools here if needed).
252
- return combined;
110
+ return toolRegistry_1.TOOL_REGISTRY;
253
111
  }
254
- return combined.filter((tool) => tool.ecosystem === include);
112
+ return toolRegistry_1.TOOL_REGISTRY.filter((tool) => tool.ecosystem === include);
255
113
  }
256
114
  async function createSetupPlan(root, include = "recommended") {
257
115
  const { config } = await (0, config_1.loadConfig)(root);
258
116
  const project = await (0, projectDetector_1.detectProject)(root, config.paths.exclude);
259
- const tools = resolveTools(include);
260
- const relevantTools = tools.filter((tool) => appliesToProject(tool, project));
117
+ const relevantTools = resolveTools(include).filter((tool) => appliesToProject(tool, project));
118
+ const runtimes = await (0, toolVerification_1.probeRuntimesFor)(relevantTools, root);
119
+ // Verification, not a name lookup, decides what counts as installed. This runs
120
+ // each tool the way the scanner will, so the two cannot disagree.
121
+ const verifications = await (0, toolVerification_1.verifyTools)(relevantTools, root);
122
+ const verificationById = new Map(verifications.map((verification) => [verification.id, verification]));
261
123
  const builtIn = relevantTools.filter((tool) => tool.ecosystem === "built-in");
262
124
  const externalTools = relevantTools.filter((tool) => tool.ecosystem !== "built-in");
263
- const available = externalTools.filter((tool) => isToolAvailable(tool, project));
264
- const missing = externalTools.filter((tool) => !isToolAvailable(tool, project));
265
- const npmPackages = missing
266
- .filter((tool) => tool.ecosystem === "npm" && tool.packageName)
267
- .map((tool) => tool.packageName);
268
- const pythonPackages = missing
269
- .filter((tool) => tool.ecosystem === "python" && tool.packageName)
270
- .map((tool) => tool.packageName);
125
+ const available = externalTools.filter((tool) => verificationById.get(tool.id)?.state === "verified");
126
+ const missing = externalTools.filter((tool) => verificationById.get(tool.id)?.state !== "verified");
127
+ const npmMissing = missing.filter((tool) => tool.ecosystem === "npm" && tool.packageName);
128
+ const pythonMissing = missing.filter((tool) => tool.ecosystem === "python" && tool.packageName);
129
+ const npmPackages = npmMissing.map((tool) => tool.packageName);
130
+ const pythonPackages = pythonMissing.map((tool) => tool.packageName);
271
131
  const manual = missing.filter((tool) => tool.ecosystem === "manual");
272
132
  const skipped = [];
273
133
  const commands = [];
@@ -277,35 +137,84 @@ async function createSetupPlan(root, include = "recommended") {
277
137
  commands.push(jsInstallCommand(root, manager, npmPackages));
278
138
  }
279
139
  else {
280
- skipped.push(...missing.filter((tool) => tool.ecosystem === "npm").map((tool) => ({
140
+ skipped.push(...npmMissing.map((tool) => ({
281
141
  ...tool,
282
142
  installHint: "Add a package.json first, then install this as a dev dependency."
283
143
  })));
284
144
  }
285
145
  }
286
146
  if (pythonPackages.length > 0) {
287
- const command = await pythonInstallCommand(root, project, pythonPackages);
147
+ const command = await pythonInstallCommand(root, project, pythonPackages, runtimes);
288
148
  if (command) {
289
149
  commands.push(command);
290
150
  }
291
151
  else {
292
- skipped.push(...missing.filter((tool) => tool.ecosystem === "python").map((tool) => ({
152
+ // Naming the actual obstacle matters: "no interpreter" and "no virtualenv"
153
+ // have different fixes, and reporting the wrong one wastes the user's time.
154
+ const obstacle = runtimes.python?.available
155
+ ? "Create or activate a Python virtualenv (.venv), then run"
156
+ : `No Python interpreter was found on PATH. Install Python, then run`;
157
+ skipped.push(...pythonMissing.map((tool) => ({
293
158
  ...tool,
294
- installHint: "Create or activate a Python virtualenv, then run: python -m pip install -U " + pythonPackages.join(" ")
159
+ installHint: `${obstacle}: python -m pip install -U ${pythonPackages.join(" ")}`
295
160
  })));
296
161
  }
297
162
  }
298
- return { project, builtIn, available, npmPackages, pythonPackages, manual, skipped, commands };
163
+ return { project, builtIn, available, npmPackages, pythonPackages, manual, skipped, commands, runtimes, verifications };
299
164
  }
300
165
  function renderToolList(prefix, tools) {
301
166
  if (tools.length === 0) {
302
167
  return [];
303
168
  }
304
- return [prefix, ...tools.map((tool) => `- ${tool.id}: ${tool.reason}${tool.installHint ? ` ${tool.installHint}` : ""}`), ""];
169
+ return [
170
+ prefix,
171
+ ...tools.map((tool) => `- ${tool.id}: ${tool.reason}${tool.installHint ? ` ${tool.installHint}` : ""}`),
172
+ ""
173
+ ];
174
+ }
175
+ function renderRuntimeLines(runtimes) {
176
+ const entries = Object.values(runtimes).filter(Boolean);
177
+ if (entries.length === 0) {
178
+ return [];
179
+ }
180
+ return [
181
+ "Runtimes",
182
+ ...entries.map((probe) => `- ${probe.engine}: ${probe.available ? probe.detail : `NOT AVAILABLE — ${probe.detail}`}`),
183
+ ""
184
+ ];
185
+ }
186
+ /**
187
+ * Renders verification results. Each line names the resolved path, because
188
+ * "installed" without a path is the claim that turned out to be unreliable.
189
+ */
190
+ function renderVerificationLines(verifications) {
191
+ if (verifications.length === 0) {
192
+ return [];
193
+ }
194
+ const lines = ["Verification (each tool resolved and run the way the scanner will run it)"];
195
+ for (const verification of [...verifications].sort((left, right) => left.id.localeCompare(right.id))) {
196
+ lines.push(`- ${(0, toolVerification_1.summarizeVerification)(verification)}`);
197
+ if (verification.probeCommand && verification.state === "verified") {
198
+ lines.push(` probe: ${verification.probeCommand}`);
199
+ }
200
+ if (verification.remediation && (0, toolVerification_1.isVerificationBlocking)(verification)) {
201
+ lines.push(` fix: ${verification.remediation}`);
202
+ }
203
+ }
204
+ lines.push("");
205
+ return lines;
305
206
  }
306
- function renderPlan(plan, include, results = []) {
207
+ function renderPlan({ plan, include, installResults = [], postInstall }) {
307
208
  const languages = activeLanguages(plan.project);
308
- const lines = ["VibeDoctor setup", "", `Detected languages: ${languages.length > 0 ? languages.join(", ") : "none"}`, `Package managers: ${plan.project.packageManagers.length > 0 ? plan.project.packageManagers.join(", ") : "none"}`, `Install set: ${include}`, ""];
209
+ const lines = [
210
+ "VibeDoctor setup",
211
+ "",
212
+ `Detected languages: ${languages.length > 0 ? languages.join(", ") : "none"}`,
213
+ `Package managers: ${plan.project.packageManagers.length > 0 ? plan.project.packageManagers.join(", ") : "none"}`,
214
+ `Install set: ${include}`,
215
+ ""
216
+ ];
217
+ lines.push(...renderRuntimeLines(plan.runtimes));
309
218
  lines.push(...renderToolList("Already built in", plan.builtIn));
310
219
  lines.push(...renderToolList("Already available", plan.available));
311
220
  if (plan.commands.length > 0) {
@@ -313,9 +222,9 @@ function renderPlan(plan, include, results = []) {
313
222
  }
314
223
  lines.push(...renderToolList("Manual installs", plan.manual));
315
224
  lines.push(...renderToolList("Skipped until project setup exists", plan.skipped));
316
- if (results.length > 0) {
225
+ if (installResults.length > 0) {
317
226
  lines.push("Install results");
318
- for (const result of results) {
227
+ for (const result of installResults) {
319
228
  lines.push(`- ${result.command}: ${result.status}${result.exitCode === null ? "" : ` (${result.exitCode})`}`);
320
229
  if (result.stderr.trim()) {
321
230
  lines.push(` ${result.stderr.trim().split(/\r?\n/)[0]}`);
@@ -323,8 +232,28 @@ function renderPlan(plan, include, results = []) {
323
232
  }
324
233
  lines.push("");
325
234
  }
326
- if (plan.commands.length > 0 && results.length === 0) {
327
- lines.push("Run `vibedoctor setup --apply` to install the automatable tools.");
235
+ // After applying, the verification pass is the authoritative result: an install
236
+ // command exiting zero is not evidence the scanner can run the tool.
237
+ const verifications = postInstall ?? plan.verifications;
238
+ lines.push(...renderVerificationLines(verifications));
239
+ const blocking = verifications.filter(toolVerification_1.isVerificationBlocking);
240
+ const runtimeMismatches = blocking.filter((verification) => verification.state === "incompatible_runtime");
241
+ if (postInstall) {
242
+ if (blocking.length === 0) {
243
+ lines.push("All selected tools verified. The next scan will use exactly these executables.");
244
+ }
245
+ else {
246
+ lines.push(`Setup did not complete: ${blocking.length} tool(s) could not be verified — ${blocking
247
+ .map((verification) => verification.id)
248
+ .join(", ")}.`, "The scan will report these as missing coverage rather than treating their silence as a pass.");
249
+ if (runtimeMismatches.length > 0) {
250
+ lines.push("", "Runtime mismatches are installed but unusable here. To keep them out of the way deliberately, add to vibedoctor.yml:", " runtime:", " deferred_tools:", ...runtimeMismatches.map((verification) => ` - ${verification.id}`));
251
+ }
252
+ }
253
+ lines.push("");
254
+ }
255
+ else if (plan.commands.length > 0) {
256
+ lines.push("Run `vibedoctor setup --apply` to install the automatable tools and verify each one.");
328
257
  }
329
258
  else if (plan.commands.length === 0 && plan.manual.length === 0 && plan.skipped.length === 0) {
330
259
  lines.push(`All relevant ${include} tools are already available.`);
@@ -355,14 +284,23 @@ async function runSetupCommand(root, options = {}) {
355
284
  const include = VALID_SETUP_INCLUDES.has(options.include ?? "recommended") ? (options.include ?? "recommended") : "recommended";
356
285
  const plan = await createSetupPlan(root, include);
357
286
  if (!options.apply) {
358
- return { output: renderPlan(plan, include), exitCode: 0 };
287
+ return { output: renderPlan({ plan, include }), exitCode: 0 };
359
288
  }
360
- const results = [];
289
+ const installResults = [];
361
290
  for (const command of plan.commands) {
362
- results.push(await (0, toolRunner_1.runCommand)(command));
291
+ installResults.push(await (0, toolRunner_1.runCommand)(command));
363
292
  }
293
+ // Re-probe runtimes as well: an install can add the interpreter or venv that
294
+ // was missing when the plan was built.
295
+ const relevantTools = resolveTools(include).filter((tool) => appliesToProject(tool, plan.project));
296
+ const postInstall = await (0, toolVerification_1.verifyTools)(relevantTools, root);
297
+ const installFailed = installResults.some((result) => result.status === "error" || result.status === "timeout" || result.status === "skipped");
298
+ const verificationFailed = postInstall.some(toolVerification_1.isVerificationBlocking);
364
299
  return {
365
- output: renderPlan(plan, include, results),
366
- exitCode: results.some((result) => result.status === "error" || result.status === "timeout" || result.status === "skipped") ? 1 : 0
300
+ output: renderPlan({ plan, include, installResults, postInstall }),
301
+ // Setup fails when a tool cannot be verified, even if every install command
302
+ // succeeded. Reporting success for an unusable tool is the failure mode this
303
+ // exit code exists to prevent.
304
+ exitCode: installFailed || verificationFailed ? 1 : 0
367
305
  };
368
306
  }
package/dist/cli/index.js CHANGED
@@ -15,6 +15,7 @@ const fix_1 = require("./commands/fix");
15
15
  const init_1 = require("./commands/init");
16
16
  const server_1 = require("../mcp/server");
17
17
  const privacyReview_1 = require("./commands/privacyReview");
18
+ const dpdp_1 = require("./commands/dpdp");
18
19
  const report_1 = require("./commands/report");
19
20
  const scan_1 = require("./commands/scan");
20
21
  const setup_1 = require("./commands/setup");
@@ -201,6 +202,89 @@ async function main() {
201
202
  process.stdout.write(result.output);
202
203
  process.exit(result.exitCode);
203
204
  });
205
+ const dpdp = program
206
+ .command("dpdp")
207
+ .description("DPDP technical readiness assessment (not legal certification)");
208
+ dpdp
209
+ .command("init")
210
+ .description("Create optional DPDP context and declared-evidence scaffolding")
211
+ .action(async () => {
212
+ const result = await (0, dpdp_1.runDpdpInitCommand)(process.cwd());
213
+ process.stdout.write(result.output);
214
+ process.exit(result.exitCode);
215
+ });
216
+ dpdp
217
+ .command("scan")
218
+ .description("Run deterministic DPDP technical readiness scan")
219
+ .option("--full", "Full repository scan (default)", true)
220
+ .option("--changed", "Collect evidence only from git changed files (falls back to full scope if no delta); control matrix remains full catalogue")
221
+ .option("--report <format>", "terminal|json|html|markdown", "terminal")
222
+ .action(async (options) => {
223
+ const result = await (0, dpdp_1.runDpdpScanCommand)(process.cwd(), {
224
+ full: !options.changed,
225
+ changed: Boolean(options.changed),
226
+ report: options.report
227
+ });
228
+ process.stdout.write(result.output);
229
+ process.exit(result.exitCode);
230
+ });
231
+ dpdp
232
+ .command("map")
233
+ .description("Print the personal-data processing map JSON (uses cached artifacts unless --refresh)")
234
+ .option("--refresh", "Force a new scan before printing", false)
235
+ .action(async (options) => {
236
+ const result = await (0, dpdp_1.runDpdpMapCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
237
+ process.stdout.write(result.output);
238
+ process.exit(result.exitCode);
239
+ });
240
+ dpdp
241
+ .command("review-queue")
242
+ .description("Print human-review questions grouped by audience (uses cached artifacts unless --refresh)")
243
+ .option("--refresh", "Force a new scan before printing", false)
244
+ .action(async (options) => {
245
+ const result = await (0, dpdp_1.runDpdpReviewQueueCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
246
+ process.stdout.write(result.output);
247
+ process.exit(result.exitCode);
248
+ });
249
+ dpdp
250
+ .command("report")
251
+ .description("Emit DPDP readiness report (uses cached artifacts unless --refresh)")
252
+ .option("--json", "JSON report")
253
+ .option("--html", "HTML report")
254
+ .option("--markdown", "Markdown report")
255
+ .option("--refresh", "Force a new scan before reporting", false)
256
+ .action(async (options) => {
257
+ const result = await (0, dpdp_1.runDpdpReportCommand)(process.cwd(), options);
258
+ process.stdout.write(result.output);
259
+ process.exit(result.exitCode);
260
+ });
261
+ dpdp
262
+ .command("handoff")
263
+ .description("Generate agent handoff markdown from deterministic artifacts (cached unless --refresh)")
264
+ .option("--refresh", "Force a new scan before generating handoff", false)
265
+ .action(async (options) => {
266
+ const result = await (0, dpdp_1.runDpdpHandoffCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
267
+ process.stdout.write(result.output);
268
+ process.exit(result.exitCode);
269
+ });
270
+ dpdp
271
+ .command("verify")
272
+ .description("Re-run DPDP collection on changed files for post-fix verification (same scope as scan --changed; falls back to full if no git delta)")
273
+ .action(async () => {
274
+ const result = await (0, dpdp_1.runDpdpVerifyCommand)(process.cwd());
275
+ process.stdout.write(result.output);
276
+ process.exit(result.exitCode);
277
+ });
278
+ dpdp
279
+ .command("explain")
280
+ .description("Explain a DPDP control or finding id (uses cached artifacts unless --refresh)")
281
+ .argument("<control-or-finding-id>")
282
+ .option("--refresh", "Force a new scan before explaining", false)
283
+ .action(async (id, options) => {
284
+ const result = await (0, dpdp_1.runDpdpExplainCommand)(process.cwd(), id, { refresh: Boolean(options.refresh) });
285
+ process.stdout.write(result.output);
286
+ process.exit(result.exitCode);
287
+ });
204
288
  program
205
289
  .command("mcp")
206
290
  .description("Start the VibeDoctor MCP server over stdio")
@@ -0,0 +1,92 @@
1
+ import type { FindingCategory } from "./finding";
2
+ import type { ToolCoverage } from "./toolRunner";
3
+ /**
4
+ * The capability matrix: one row per tool VibeDoctor considered, recording what
5
+ * actually happened to it.
6
+ *
7
+ * The previous model had two lists — `toolStatuses` and `skippedTools` — which
8
+ * could not express the distinctions that matter. A tool that was installed but
9
+ * never ran, a tool that ran but only over part of the repo, and a tool that was
10
+ * never applicable all collapsed into "skipped". Reports built on that could say
11
+ * a tool was installed while its findings were absent, with no way to tell which
12
+ * link in the chain broke. Each facet below is recorded independently, and
13
+ * `state` is derived from them rather than asserted.
14
+ */
15
+ export type CapabilityState =
16
+ /** Ran to completion over the full requested scope. */
17
+ "completed"
18
+ /** Ran, but covered less than the requested scope (scoped fallback after a timeout). */
19
+ | "partial"
20
+ /** Exceeded its time budget and was killed. */
21
+ | "timed_out"
22
+ /** Ran and failed, or produced output that could not be parsed. */
23
+ | "failed"
24
+ /** Not present on PATH. */
25
+ | "not_installed"
26
+ /** Present, but the runtime cannot run it. */
27
+ | "runtime_incompatible"
28
+ /** Deliberately deferred by configuration. */
29
+ | "deferred"
30
+ /** Turned off by configuration. */
31
+ | "disabled"
32
+ /** Nothing in this repository for it to analyse. */
33
+ | "not_applicable"
34
+ /** Excluded by the current scan mode (for example a full-scan-only tool in quick mode). */
35
+ | "not_selected";
36
+ /** Whether findings from this tool can be trusted as covering the repository. */
37
+ export type CapabilityTrust = "authoritative" | "partial" | "absent";
38
+ export type ToolCapability = {
39
+ id: string;
40
+ category: FindingCategory;
41
+ state: CapabilityState;
42
+ /** Selected for this scan mode. */
43
+ planned: boolean;
44
+ /** There is something in this repository for the tool to analyse. */
45
+ applicable: boolean;
46
+ /** Found on PATH (or importable, for module-driven tools). */
47
+ discovered: boolean;
48
+ /** Started at least once. */
49
+ executed: boolean;
50
+ resolvedPath?: string;
51
+ version?: string;
52
+ /** Exact command line that ran, so any row can be reproduced by hand. */
53
+ command?: string;
54
+ durationMs?: number;
55
+ timeoutSeconds?: number;
56
+ coverage?: ToolCoverage;
57
+ /** Findings the tool reported, before relevance filtering and suppressions. */
58
+ findingsReported: number;
59
+ /** Findings that reached the report. Differs from reported whenever filters ran. */
60
+ findingsSurfaced: number;
61
+ /** Why this row ended in this state. Always populated. */
62
+ reason: string;
63
+ /** What to do about it, when there is something to do. */
64
+ remediation?: string;
65
+ trust: CapabilityTrust;
66
+ };
67
+ export declare function trustForState(state: CapabilityState): CapabilityTrust;
68
+ /**
69
+ * States that mean "this check did not happen and you should know". Deliberate
70
+ * exclusions are not gaps; a tool that timed out or is missing is.
71
+ */
72
+ export declare function isCoverageGap(capability: ToolCapability): boolean;
73
+ export declare function didRun(capability: ToolCapability): boolean;
74
+ export type CapabilityMatrix = {
75
+ tools: ToolCapability[];
76
+ counts: Record<CapabilityState, number>;
77
+ /** Tools whose absence or partial coverage limits what the report can claim. */
78
+ gaps: string[];
79
+ /** Gaps for tools the config marks required. */
80
+ requiredGaps: string[];
81
+ /** True when every planned tool completed over full scope. */
82
+ fullCoverage: boolean;
83
+ };
84
+ export declare function buildCapabilityMatrix(tools: ToolCapability[], requiredTools: string[]): CapabilityMatrix;
85
+ export declare function capabilityStateLabel(state: CapabilityState): string;
86
+ /**
87
+ * Renders the matrix as aligned text. Every row states what happened, why, and
88
+ * what to do — including the findings-reported vs findings-surfaced split, so a
89
+ * tool that ran but had everything filtered out cannot look like a tool that
90
+ * found nothing.
91
+ */
92
+ export declare function renderCapabilityMatrixLines(matrix: CapabilityMatrix): string[];