@neuralaxis/vibedoctor 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +70 -24
  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 +17 -3
  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 +17 -4
  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 +9 -1
  13. package/dist/cli/commands/scan.js +37 -3
  14. package/dist/cli/index.js +40 -11
  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 +73 -51
  21. package/dist/core/executable.js +14 -6
  22. package/dist/core/executionPolicy.d.ts +55 -0
  23. package/dist/core/executionPolicy.js +144 -0
  24. package/dist/core/finding.d.ts +1 -1
  25. package/dist/core/finding.js +8 -3
  26. package/dist/core/findingCorrelator.d.ts +19 -0
  27. package/dist/core/findingCorrelator.js +112 -0
  28. package/dist/core/findingNormalizer.js +1 -0
  29. package/dist/core/git.d.ts +2 -0
  30. package/dist/core/git.js +26 -1
  31. package/dist/core/managedTools.d.ts +25 -0
  32. package/dist/core/managedTools.js +186 -0
  33. package/dist/core/repoGraph.d.ts +62 -0
  34. package/dist/core/repoGraph.js +408 -0
  35. package/dist/core/riskRanker.d.ts +6 -0
  36. package/dist/core/riskRanker.js +127 -0
  37. package/dist/core/scanContext.d.ts +26 -0
  38. package/dist/core/scanContext.js +44 -0
  39. package/dist/core/scanPlanner.d.ts +1 -0
  40. package/dist/core/scanPlanner.js +18 -6
  41. package/dist/core/toolRegistry.js +12 -5
  42. package/dist/core/toolRunner.d.ts +4 -0
  43. package/dist/core/toolRunner.js +28 -3
  44. package/dist/core/toolRuntime.d.ts +40 -0
  45. package/dist/core/toolRuntime.js +417 -0
  46. package/dist/core/toolVerification.d.ts +3 -1
  47. package/dist/core/toolVerification.js +58 -3
  48. package/dist/index.d.ts +5 -0
  49. package/dist/index.js +5 -0
  50. package/dist/integration/envelope.d.ts +72 -0
  51. package/dist/integration/envelope.js +61 -0
  52. package/dist/integration/sourceFingerprint.d.ts +21 -0
  53. package/dist/integration/sourceFingerprint.js +68 -0
  54. package/dist/reporters/agent.d.ts +1 -1
  55. package/dist/reporters/agent.js +7 -0
  56. package/package.json +81 -80
  57. package/schemas/machine-envelope.v1.schema.json +92 -0
package/README.md CHANGED
@@ -1,42 +1,45 @@
1
1
  # VibeDoctor
2
2
 
3
+ <p align="center">
4
+ <img src="website/public/logo-lockup.png" alt="VibeDoctor, a NeuralAxis product" width="360" />
5
+ </p>
6
+
3
7
  **A local health check for code you did not write line by line.**
8
+ **Give VibeDoctor a repository. It figures out what applies, runs the diagnosis, and tells you or your coding agent what to fix first.**
4
9
 
5
- VibeDoctor scans JavaScript, TypeScript, Python, and mixed repositories for code-health, security, privacy, testing, and maintainability problems. It combines repository-local scanner output into one ranked report, one normalized finding format, and a fix-next plan that humans and coding agents can use without interpreting a wall of unrelated logs.
10
+ VibeDoctor scans JavaScript, TypeScript, Python, and mixed repositories for code-health, security, privacy, testing, and maintainability problems. It combines engine output into one ranked report, one normalized finding format, and a fix-next plan that humans and coding agents can use without interpreting a wall of unrelated logs.
6
11
 
7
12
  ```bash
8
- npx @neuralaxis/vibedoctor scan --changed
13
+ npx @neuralaxis/vibedoctor scan
9
14
  ```
10
15
 
11
- VibeDoctor runs locally by default. Missing or failed scanners are reported as incomplete evidence, never silently counted as a clean result.
16
+ That is the default path: full applicable diagnosis, local by default. Missing or failed scanners are reported as incomplete evidence, never silently counted as a clean result.
17
+
18
+ The public product site lives in [`website/`](website/README.md) and deploys from GitHub Pages.
12
19
 
13
20
  ## Start here
14
21
 
15
- Choose the shortest path for what you are doing:
22
+ ```bash
23
+ npx @neuralaxis/vibedoctor scan
24
+ ```
16
25
 
17
- | Goal | Command |
18
- | --- | --- |
19
- | Check files changed in Git | `npx @neuralaxis/vibedoctor scan --changed` |
20
- | Run a fast repository check | `npx @neuralaxis/vibedoctor scan --quick` |
21
- | Run the most complete check | `npx @neuralaxis/vibedoctor scan --full` |
22
- | Prepare local scanner tools | `npx @neuralaxis/vibedoctor setup` |
23
- | Get a repair plan for an AI agent | `npx @neuralaxis/vibedoctor agent-plan --format markdown` |
24
- | Check India DPDP technical readiness | `npx @neuralaxis/vibedoctor dpdp scan --full` |
26
+ That is enough for a first diagnosis. VibeDoctor detects the repository, runs the capabilities that apply, correlates overlapping evidence, and ranks what to fix first.
25
27
 
26
- For a new repository, initialize the config and review the scanner setup plan:
28
+ For an AI coding agent:
27
29
 
28
30
  ```bash
29
- npx @neuralaxis/vibedoctor init
30
- npx @neuralaxis/vibedoctor setup
31
- npx @neuralaxis/vibedoctor setup --apply
32
- npx @neuralaxis/vibedoctor scan --quick
31
+ npx @neuralaxis/vibedoctor scan --report agent-json
33
32
  ```
34
33
 
35
- `setup --apply` installs supported recommended tools, so review the plan before applying it. To use the shorter `vibedoctor` command everywhere:
34
+ Optional narrower runs:
36
35
 
37
- ```bash
38
- npm install -g @neuralaxis/vibedoctor
39
- ```
36
+ | Goal | Command |
37
+ | --- | --- |
38
+ | Fast profile | `npx @neuralaxis/vibedoctor scan --quick` |
39
+ | Git-changed files | `npx @neuralaxis/vibedoctor scan --changed` |
40
+ | Explicit full alias | `npx @neuralaxis/vibedoctor scan --full` |
41
+ | Agent repair plan file | `npx @neuralaxis/vibedoctor agent-plan --format markdown` |
42
+ | India DPDP technical readiness | `npx @neuralaxis/vibedoctor dpdp scan --full` |
40
43
 
41
44
  ## What you get
42
45
 
@@ -51,7 +54,29 @@ Default artifacts are written under `.vibedoctor/`:
51
54
  └── agent-plan.md # ordered repair work
52
55
  ```
53
56
 
54
- Use the terminal report for quick triage, HTML for review, JSON for automation, and `agent-plan.md` for a coding agent.
57
+ Use the terminal report for quick triage, HTML for review, JSON for automation, `agent-json` for a coding agent, and `agent-plan.md` for a file-based handoff.
58
+
59
+ ## Advanced setup and troubleshooting
60
+
61
+ You do not need to install Ruff, Gitleaks, or OSV-Scanner just to run VibeDoctor. The default scan uses built-in detectors plus managed copies of those three engines when they apply. Other engines are used when they are already on PATH or installed in the project; missing ones are reported as incomplete evidence.
62
+
63
+ To install extra project-local scanners, or to debug a tool that did not run:
64
+
65
+ ```bash
66
+ npx @neuralaxis/vibedoctor init
67
+ npx @neuralaxis/vibedoctor setup
68
+ npx @neuralaxis/vibedoctor setup --apply
69
+ ```
70
+
71
+ `setup --apply` can mutate the scanned project (it installs recommended tools there), so review the plan first. Managed Ruff, Gitleaks, and OSV-Scanner are cached under `~/.cache/vibedoctor/` and do not edit `package.json`, lockfiles, or Python manifests.
72
+
73
+ To use the shorter `vibedoctor` command everywhere:
74
+
75
+ ```bash
76
+ npm install -g @neuralaxis/vibedoctor
77
+ ```
78
+
79
+ Override the tool cache with `VIBEDOCTOR_TOOL_CACHE`. Disable downloads with `VIBEDOCTOR_ALLOW_NETWORK=0`.
55
80
 
56
81
  ## What VibeDoctor checks
57
82
 
@@ -144,6 +169,8 @@ CLI exit codes let people, agents, and CI distinguish health failures from missi
144
169
  | `0` | The scan completed and configured gates passed. |
145
170
  | `1` | One or more configured health gates failed. |
146
171
  | `2` | Required checks were incomplete. |
172
+ | `64` | Invalid `scan` options (unknown `--profile`, `--root` not a directory). |
173
+ | `70` | `--report envelope` only: the scan crashed before completing, so no envelope was written. |
147
174
 
148
175
  Skipped scanners are never treated as clean results. Privacy findings affect the privacy category score by default, but do not lower the overall score or fail CI unless you opt into privacy gates.
149
176
 
@@ -349,7 +376,8 @@ Human-review-only DPDP items do not fail CI. Configure `checks.dpdp.fail_on_seve
349
376
  | --- | --- |
350
377
  | Initialize configuration | `vibedoctor init` |
351
378
  | Plan or apply scanner setup | `vibedoctor setup` / `vibedoctor setup --apply` |
352
- | Quick, changed, or full scan | `vibedoctor scan --quick` / `--changed` / `--full` |
379
+ | Full applicable diagnosis | `vibedoctor scan` |
380
+ | Quick, changed, or explicit full | `vibedoctor scan --quick` / `--changed` / `--full` |
353
381
  | Scan selected categories | `vibedoctor scan --category dead_code,leftovers` |
354
382
  | Render a fresh full report | `vibedoctor report --json`, `--html`, `--markdown`, `--sarif`, or `--agent` |
355
383
  | Apply supported safe fixes | `vibedoctor fix --safe` |
@@ -360,7 +388,25 @@ Human-review-only DPDP items do not fail CI. Configure `checks.dpdp.fail_on_seve
360
388
  | Generate an agent plan | `vibedoctor agent-plan --format markdown` |
361
389
  | Start MCP | `vibedoctor mcp` |
362
390
 
363
- `scan --report` supports `terminal`, `json`, `html`, `agent`, and `agent-json`. The separate `report` command performs a fresh full scan and can also render Markdown or SARIF to standard output.
391
+ `scan --report` supports `terminal`, `json`, `html`, `agent`, `agent-json`, and `envelope`. The separate `report` command performs a fresh full scan and can also render Markdown or SARIF to standard output.
392
+
393
+ ### Scanning code you do not fully trust
394
+
395
+ By default VibeDoctor behaves as it always has: project-local tools (for example `node_modules/.bin/tsc`) are preferred, and test runners can execute the project's tests. When you scan a repository you did not write (CI bots, other tools, downloaded code), choose an explicit profile:
396
+
397
+ ```bash
398
+ vibedoctor scan --root ./some-repo --profile static --report envelope
399
+ ```
400
+
401
+ | Profile | What runs |
402
+ | --- | --- |
403
+ | `default` | Everything applicable, as before. |
404
+ | `static` | Only analysers that read files and run from outside the repository. No project-local executables, no project tests or scripts, no tools that load executable project config (vitest, jest, knip, coverage.py, Presidio), no network (Semgrep registry, OSV), a minimal child environment, and no Windows `cmd.exe` fallback. Excluded tools appear in the capability matrix with the reason. |
405
+ | `trusted` | The project's own tools and tests may run; network stays off unless `--allow-network`. |
406
+
407
+ `--allow-network` re-enables network-backed tools under `static` or `trusted`. The repository's `vibedoctor.yml` cannot re-enable a tool the profile excludes. Reports are still written to `.vibedoctor/` in every profile.
408
+
409
+ `--report envelope` prints one versioned JSON document for integrations. It contains the unchanged `--report json` report plus the producer version, run identity, profile, a content fingerprint of the scanned files, git state, the configuration fingerprint, a stable fingerprint per finding, and the gate outcome. See [docs/machine-envelope.md](docs/machine-envelope.md) and [schemas/machine-envelope.v1.schema.json](schemas/machine-envelope.v1.schema.json).
364
410
 
365
411
  ## Network and data behavior
366
412
 
@@ -58,8 +58,9 @@ function readMessage(item) {
58
58
  return item.description;
59
59
  }
60
60
  function readFile(item) {
61
- const path = item.location?.path;
62
- return typeof path === "string" ? path : path?.file;
61
+ const locationPath = item.location?.path;
62
+ const file = typeof locationPath === "string" ? locationPath : locationPath?.file;
63
+ return file?.replaceAll("\\", "/");
63
64
  }
64
65
  function mapSeverity(level) {
65
66
  if (level === "fatal") {
@@ -0,0 +1,7 @@
1
+ import type { Finding } from "../core/finding";
2
+ import { type RepoGraph } from "../core/repoGraph";
3
+ import type { ToolAdapter } from "./shared";
4
+ export declare function analyzeFlows(graph: RepoGraph, options?: {
5
+ reportHeuristics?: boolean;
6
+ }): Finding[];
7
+ export declare const flowDoctorAdapter: ToolAdapter;
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flowDoctorAdapter = void 0;
4
+ exports.analyzeFlows = analyzeFlows;
5
+ const repoGraph_1 = require("../core/repoGraph");
6
+ function findingBase(partial) {
7
+ return {
8
+ isNew: true,
9
+ isAutofixable: false,
10
+ safeToAutofix: false,
11
+ scoreImpact: 0,
12
+ tags: partial.tags ?? ["flow"],
13
+ ...partial
14
+ };
15
+ }
16
+ function describeRoute(route) {
17
+ return `${route.method} ${route.path} (${route.file}:${route.line})`;
18
+ }
19
+ function mismatchFinding(call, routes, verified) {
20
+ const available = routes.slice(0, 6).map(describeRoute).join("; ");
21
+ return findingBase({
22
+ id: `flow-doctor:${call.file}:${call.line}:route-mismatch`,
23
+ source: "flow-doctor",
24
+ category: "correctness",
25
+ severity: verified ? "high" : "medium",
26
+ confidence: verified ? "high" : "medium",
27
+ evidenceGrade: verified ? "verified" : "heuristic",
28
+ title: "HTTP call has no matching backend route",
29
+ message: `${call.method} ${call.path} has no matching server route.`,
30
+ file: call.file,
31
+ startLine: call.line,
32
+ agentInstruction: `Add a ${call.method} handler for ${call.path}, or change the client call to a route the server actually exposes.`,
33
+ evidence: { toolRawId: "flow-route-mismatch", detectionPath: available },
34
+ remediation: {
35
+ kind: "code",
36
+ steps: [
37
+ `Align the client ${call.method} ${call.path} call with an existing route, or add that route on the server.`
38
+ ],
39
+ requiredEvidence: "A server handler exists for the same method and path."
40
+ }
41
+ });
42
+ }
43
+ function heuristicCallFinding(call) {
44
+ return findingBase({
45
+ id: `flow-doctor:${call.file}:${call.line}:dynamic-route`,
46
+ source: "flow-doctor",
47
+ category: "correctness",
48
+ severity: "low",
49
+ confidence: "low",
50
+ evidenceGrade: "heuristic",
51
+ title: "Dynamic HTTP path could not be verified",
52
+ message: `Call uses a constructed path (${call.path}); Flow Doctor cannot prove a route match.`,
53
+ file: call.file,
54
+ startLine: call.line,
55
+ agentInstruction: "Leave this unless a concrete method/path mismatch is visible nearby.",
56
+ evidence: { toolRawId: "flow-dynamic-path" },
57
+ tags: ["flow", "heuristic"]
58
+ });
59
+ }
60
+ function errorPathFinding(file, line, kind, detail) {
61
+ const verified = kind === "empty_handler" || kind === "success_after_failure";
62
+ return findingBase({
63
+ id: `flow-doctor:${file}:${line}:${kind}`,
64
+ source: "flow-doctor",
65
+ category: "correctness",
66
+ severity: kind === "success_after_failure" ? "high" : "medium",
67
+ confidence: "high",
68
+ evidenceGrade: verified ? "verified" : "heuristic",
69
+ title: kind === "empty_handler" ? "Swallowed error path" : "Success response after a caught failure",
70
+ message: detail,
71
+ file,
72
+ startLine: line,
73
+ agentInstruction: kind === "empty_handler"
74
+ ? "Log, rethrow, or return an explicit error from this handler. Do not leave it empty."
75
+ : "Return a failure status from the catch/except path, or rethrow after recording the error.",
76
+ evidence: { toolRawId: `flow-${kind}` }
77
+ });
78
+ }
79
+ function missingHandlerFinding(route) {
80
+ return findingBase({
81
+ id: `flow-doctor:${route.file}:${route.line}:missing-handler`,
82
+ source: "flow-doctor",
83
+ category: "correctness",
84
+ severity: "high",
85
+ confidence: "high",
86
+ evidenceGrade: "verified",
87
+ title: "Route handler is not defined",
88
+ message: `${route.method} ${route.path} is wired to ${route.handler}, but that function is not defined or imported.`,
89
+ file: route.file,
90
+ startLine: route.line,
91
+ agentInstruction: `Define ${route.handler} or point this route at a function that exists.`,
92
+ evidence: { toolRawId: "flow-missing-handler" },
93
+ remediation: {
94
+ kind: "code",
95
+ steps: [`Add ${route.handler} in this file or import it, then keep the ${route.method} ${route.path} wiring.`],
96
+ requiredEvidence: `A function named ${route.handler} is defined or imported.`
97
+ }
98
+ });
99
+ }
100
+ function orphanedHandlerFinding(symbol) {
101
+ return findingBase({
102
+ id: `flow-doctor:${symbol.file}:${symbol.line}:orphaned-handler`,
103
+ source: "flow-doctor",
104
+ category: "correctness",
105
+ severity: "medium",
106
+ confidence: "high",
107
+ evidenceGrade: "verified",
108
+ title: "Unreachable handler in a route file",
109
+ message: `${symbol.name} is defined next to routes but is never called and is not wired to any route.`,
110
+ file: symbol.file,
111
+ startLine: symbol.line,
112
+ agentInstruction: `Wire ${symbol.name} to a route, call it, or delete it if it is leftover.`,
113
+ evidence: { toolRawId: "flow-orphaned-handler" }
114
+ });
115
+ }
116
+ function handlerIsBound(route) {
117
+ return Boolean(route.handlerFile || route.handlerExternal || route.handlerMember);
118
+ }
119
+ function isReferenced(symbol, graph) {
120
+ if (graph.routes.some((route) => route.handler === symbol.name && (route.handlerFile === symbol.file || route.file === symbol.file))) {
121
+ return true;
122
+ }
123
+ return graph.calls.some((call) => call.callee === symbol.name && call.file === symbol.file && call.line !== symbol.line);
124
+ }
125
+ function analyzeFlows(graph, options = {}) {
126
+ const findings = [];
127
+ const reportHeuristics = options.reportHeuristics ?? false;
128
+ const backendPresent = graph.routes.length > 0;
129
+ if (backendPresent) {
130
+ for (const call of graph.httpCalls) {
131
+ if (call.absolute) {
132
+ continue;
133
+ }
134
+ if (call.dynamic || !call.methodExplicit) {
135
+ if (reportHeuristics) {
136
+ findings.push(heuristicCallFinding(call));
137
+ }
138
+ continue;
139
+ }
140
+ const match = graph.routes.some((route) => (0, repoGraph_1.routeMatchesCall)(call, route));
141
+ if (match) {
142
+ continue;
143
+ }
144
+ const samePath = graph.routes.some((route) => (0, repoGraph_1.pathsCompatible)(call.path, route.path));
145
+ // Same path, wrong method is a real bug. Unrelated paths in a monorepo are not.
146
+ if (samePath) {
147
+ findings.push(mismatchFinding(call, graph.routes, true));
148
+ }
149
+ else if (reportHeuristics) {
150
+ findings.push(mismatchFinding(call, graph.routes, false));
151
+ }
152
+ }
153
+ }
154
+ for (const errorPath of graph.errorPaths) {
155
+ findings.push(errorPathFinding(errorPath.file, errorPath.line, errorPath.kind, errorPath.detail));
156
+ }
157
+ for (const route of graph.routes) {
158
+ if (!route.handler || route.handlerMember || handlerIsBound(route)) {
159
+ continue;
160
+ }
161
+ if (route.handler.length < 2) {
162
+ continue;
163
+ }
164
+ findings.push(missingHandlerFinding(route));
165
+ }
166
+ const routerFiles = new Set(graph.routes.map((route) => route.file));
167
+ for (const symbol of graph.symbols) {
168
+ if (symbol.kind !== "function" || symbol.exported || symbol.name.startsWith("_")) {
169
+ continue;
170
+ }
171
+ if (!routerFiles.has(symbol.file)) {
172
+ continue;
173
+ }
174
+ if (isReferenced(symbol, graph)) {
175
+ continue;
176
+ }
177
+ findings.push(orphanedHandlerFinding(symbol));
178
+ }
179
+ return findings;
180
+ }
181
+ exports.flowDoctorAdapter = {
182
+ id: "flow-doctor",
183
+ category: "correctness",
184
+ async detect(project, config) {
185
+ if (config.checks.flowAnalysis.enabled === false) {
186
+ return false;
187
+ }
188
+ return project.languages.length > 0;
189
+ },
190
+ async runStandalone(ctx) {
191
+ const graph = await (0, repoGraph_1.buildRepoGraph)(ctx.root, ctx.project.projectFiles);
192
+ return { findings: analyzeFlows(graph) };
193
+ },
194
+ installHint: "Built-in Flow Doctor. No external install."
195
+ };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gitleaksAdapter = void 0;
4
4
  const finding_1 = require("../core/finding");
5
+ const executionPolicy_1 = require("../core/executionPolicy");
5
6
  function parseGitleaks(stdout) {
6
7
  const trimmed = stdout.trim();
7
8
  return trimmed ? JSON.parse(trimmed) : [];
@@ -14,10 +15,23 @@ exports.gitleaksAdapter = {
14
15
  },
15
16
  buildScanCommand(ctx) {
16
17
  return {
18
+ tool: "gitleaks",
17
19
  cmd: "gitleaks",
18
- args: ["detect", "--no-banner", "--redact", "--report-format", "json", "--report-path", "-"],
20
+ // The static profile scans files only (--no-git), so the target's git configuration is
21
+ // never consulted by gitleaks' internal `git log -p`.
22
+ args: [
23
+ "detect",
24
+ ...((0, executionPolicy_1.currentPolicy)().profile === "static" ? ["--no-git"] : []),
25
+ "--no-banner",
26
+ "--redact",
27
+ "--report-format",
28
+ "json",
29
+ "--report-path",
30
+ "-"
31
+ ],
19
32
  cwd: ctx.root,
20
- timeoutMs: 60_000
33
+ timeoutMs: 60_000,
34
+ runtime: ctx.toolRuntime
21
35
  };
22
36
  },
23
37
  parseResult(result, ctx) {
@@ -43,5 +57,5 @@ exports.gitleaksAdapter = {
43
57
  scoreImpact: 0
44
58
  }));
45
59
  },
46
- installHint: "Install Gitleaks from https://gitleaks.io/ or your package manager."
60
+ installHint: "VibeDoctor provisions a pinned Gitleaks into ~/.cache/vibedoctor when needed. To use a project-local copy, put gitleaks on PATH."
47
61
  };
@@ -18,3 +18,4 @@ export { vultureAdapter } from "./vulture";
18
18
  export { privacyDetectorAdapter } from "./privacyDetector";
19
19
  export { dpdpAdapter } from "./dpdp";
20
20
  export { telemetryDetectorAdapter } from "./telemetryDetector";
21
+ export { flowDoctorAdapter } from "./flowDoctor";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.telemetryDetectorAdapter = exports.dpdpAdapter = exports.privacyDetectorAdapter = exports.vultureAdapter = exports.vitestAdapter = exports.tscAdapter = exports.semgrepAdapter = exports.ruffAdapter = exports.radonAdapter = exports.pyrightAdapter = exports.presidioAdapter = exports.osvScannerAdapter = exports.lizardAdapter = exports.knipAdapter = exports.jscpdAdapter = exports.jestAdapter = exports.gitleaksAdapter = exports.deptryAdapter = exports.coveragePyAdapter = exports.biomeAdapter = void 0;
3
+ exports.flowDoctorAdapter = exports.telemetryDetectorAdapter = exports.dpdpAdapter = exports.privacyDetectorAdapter = exports.vultureAdapter = exports.vitestAdapter = exports.tscAdapter = exports.semgrepAdapter = exports.ruffAdapter = exports.radonAdapter = exports.pyrightAdapter = exports.presidioAdapter = exports.osvScannerAdapter = exports.lizardAdapter = exports.knipAdapter = exports.jscpdAdapter = exports.jestAdapter = exports.gitleaksAdapter = exports.deptryAdapter = exports.coveragePyAdapter = exports.biomeAdapter = void 0;
4
4
  var biome_1 = require("./biome");
5
5
  Object.defineProperty(exports, "biomeAdapter", { enumerable: true, get: function () { return biome_1.biomeAdapter; } });
6
6
  var coveragePy_1 = require("./coveragePy");
@@ -41,3 +41,5 @@ var dpdp_1 = require("./dpdp");
41
41
  Object.defineProperty(exports, "dpdpAdapter", { enumerable: true, get: function () { return dpdp_1.dpdpAdapter; } });
42
42
  var telemetryDetector_1 = require("./telemetryDetector");
43
43
  Object.defineProperty(exports, "telemetryDetectorAdapter", { enumerable: true, get: function () { return telemetryDetector_1.telemetryDetectorAdapter; } });
44
+ var flowDoctor_1 = require("./flowDoctor");
45
+ Object.defineProperty(exports, "flowDoctorAdapter", { enumerable: true, get: function () { return flowDoctor_1.flowDoctorAdapter; } });
@@ -104,6 +104,7 @@ exports.osvScannerAdapter = {
104
104
  },
105
105
  buildScanCommand(ctx) {
106
106
  return {
107
+ tool: "osv-scanner",
107
108
  cmd: "osv-scanner",
108
109
  args: [
109
110
  "scan",
@@ -115,7 +116,8 @@ exports.osvScannerAdapter = {
115
116
  "error"
116
117
  ],
117
118
  cwd: ctx.root,
118
- timeoutMs: 60_000
119
+ timeoutMs: 60_000,
120
+ runtime: ctx.toolRuntime
119
121
  };
120
122
  },
121
123
  parseResult(result, ctx) {
@@ -195,5 +197,5 @@ exports.osvScannerAdapter = {
195
197
  };
196
198
  });
197
199
  },
198
- installHint: "Install OSV-Scanner from https://google.github.io/osv-scanner/"
200
+ installHint: "VibeDoctor provisions a pinned OSV-Scanner into ~/.cache/vibedoctor when needed. To use a project-local copy, put osv-scanner on PATH."
199
201
  };
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ruffAdapter = void 0;
4
4
  const finding_1 = require("../core/finding");
5
5
  const shared_1 = require("./shared");
6
+ const executionPolicy_1 = require("../core/executionPolicy");
6
7
  function parseRuffOutput(stdout) {
7
8
  const trimmed = stdout.trim();
8
9
  if (!trimmed) {
@@ -29,10 +30,20 @@ exports.ruffAdapter = {
29
30
  const targets = (0, shared_1.adapterTargets)(ctx, /\.py$/i);
30
31
  const excludePatterns = ctx.config.paths.exclude.length > 0 ? ["--exclude", ctx.config.paths.exclude.join(",")] : [];
31
32
  return {
33
+ tool: "ruff",
32
34
  cmd: "ruff",
33
- args: ["check", ...targets, "--output-format", "json", ...excludePatterns],
35
+ // Explicit profiles leave the scanned repository unchanged: no .ruff_cache is written.
36
+ args: [
37
+ "check",
38
+ ...targets,
39
+ "--output-format",
40
+ "json",
41
+ ...excludePatterns,
42
+ ...((0, executionPolicy_1.currentPolicy)().profile === "default" ? [] : ["--no-cache"])
43
+ ],
34
44
  cwd: ctx.root,
35
- timeoutMs: 60_000
45
+ timeoutMs: 60_000,
46
+ runtime: ctx.toolRuntime
36
47
  };
37
48
  },
38
49
  parseResult(result, ctx) {
@@ -64,11 +75,13 @@ exports.ruffAdapter = {
64
75
  },
65
76
  buildFixCommand(ctx) {
66
77
  return {
78
+ tool: "ruff",
67
79
  cmd: "ruff",
68
80
  args: ["check", ".", "--fix"],
69
81
  cwd: ctx.root,
70
- timeoutMs: 60_000
82
+ timeoutMs: 60_000,
83
+ runtime: ctx.toolRuntime
71
84
  };
72
85
  },
73
- installHint: "Install Ruff with: pipx install ruff, uv tool install ruff, or add it to your project."
86
+ installHint: "VibeDoctor provisions a pinned Ruff into ~/.cache/vibedoctor when needed. To use a project-local copy, install it in the environment."
74
87
  };
@@ -1,12 +1,16 @@
1
1
  import type { VibeDoctorConfig } from "../core/config";
2
2
  import type { Finding, FindingCategory } from "../core/finding";
3
3
  import type { ProjectContext } from "../core/projectDetector";
4
+ import type { ScanContext } from "../core/scanContext";
5
+ import type { ToolRuntime } from "../core/toolRuntime";
4
6
  import type { CommandSpec, ToolResult } from "../core/toolRunner";
5
7
  export type ToolAdapterContext = {
6
8
  root: string;
7
9
  project: ProjectContext;
8
10
  config: VibeDoctorConfig;
9
11
  scanMode: "default" | "changed" | "quick" | "full";
12
+ toolRuntime?: ToolRuntime;
13
+ scanContext?: ScanContext;
10
14
  /** Results already produced by the scan engine, available to dependent adapters for reuse. */
11
15
  sharedToolResults?: Record<string, SharedToolExecution>;
12
16
  };
@@ -72,6 +72,10 @@ runtime:
72
72
  # implying they passed — use this for tools this environment cannot support.
73
73
  deferred_tools: []
74
74
  verify_tools_before_scan: true
75
+ managed_tools:
76
+ enabled: true
77
+ allow_network: true
78
+ prefer_project_local: true
75
79
 
76
80
  # Controls how much of what the tools report actually reaches the report.
77
81
  # Nothing is dropped silently: every filter states what it withheld and why.
@@ -118,6 +122,9 @@ checks:
118
122
  fail_on_type_errors: true
119
123
  fail_on_test_failures: true
120
124
 
125
+ flow_analysis:
126
+ enabled: true
127
+
121
128
  dead_code:
122
129
  enabled: true
123
130
  delete_automatically: false
@@ -1,14 +1,22 @@
1
1
  import type { VibeDoctorConfig } from "../../core/config";
2
2
  import { type ScanOutput } from "../../core/engine";
3
+ import type { ScanMode } from "../../core/scanPlanner";
3
4
  export type ScanCommandResult = {
4
5
  output: string;
5
6
  exitCode: number;
6
7
  };
7
8
  export declare function determineExitCode(scan: Pick<ScanOutput, "score" | "findings"> & Partial<Pick<ScanOutput, "completeness">>, config: VibeDoctorConfig): number;
9
+ export declare function resolveScanMode(options: {
10
+ changed?: boolean;
11
+ quick?: boolean;
12
+ full?: boolean;
13
+ }): ScanMode;
8
14
  export declare function runScanCommand(root: string, options: {
9
15
  changed?: boolean;
10
16
  quick?: boolean;
11
17
  full?: boolean;
12
18
  category?: string;
13
- report?: "terminal" | "json" | "html" | "agent" | "agent-json";
19
+ report?: "terminal" | "json" | "html" | "agent" | "agent-json" | "envelope";
20
+ /** Producer version recorded in the machine envelope. */
21
+ version?: string;
14
22
  }): Promise<ScanCommandResult>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.determineExitCode = determineExitCode;
4
+ exports.resolveScanMode = resolveScanMode;
4
5
  exports.runScanCommand = runScanCommand;
5
6
  const engine_1 = require("../../core/engine");
6
7
  const finding_1 = require("../../core/finding");
@@ -11,6 +12,9 @@ const html_1 = require("../../reporters/html");
11
12
  const agent_1 = require("../../reporters/agent");
12
13
  const shared_1 = require("./shared");
13
14
  const gates_1 = require("../../dpdp/gates");
15
+ const executionPolicy_1 = require("../../core/executionPolicy");
16
+ const envelope_1 = require("../../integration/envelope");
17
+ const sourceFingerprint_1 = require("../../integration/sourceFingerprint");
14
18
  function shouldCountForFailure(isNew, config) {
15
19
  return config.baseline.failOnlyOnNewIssues ? isNew : true;
16
20
  }
@@ -43,7 +47,11 @@ function determineExitCode(scan, config) {
43
47
  failingFindings.some((finding) => finding.source === "deptry" && finding.title === "DEP002");
44
48
  const typeFailure = config.checks.correctness.enabled &&
45
49
  config.checks.correctness.failOnTypeErrors &&
46
- failingFindings.some((finding) => ["tsc", "pyright"].includes(finding.source) || (finding.category === "correctness" && isHighSeverity(finding)));
50
+ failingFindings.some((finding) => finding.source === "tsc" ||
51
+ finding.source === "pyright" ||
52
+ (finding.category === "correctness" &&
53
+ isHighSeverity(finding) &&
54
+ finding.source !== "flow-doctor"));
47
55
  const testFailure = config.checks.correctness.enabled &&
48
56
  config.checks.correctness.failOnTestFailures &&
49
57
  failingFindings.some((finding) => finding.category === "tests" && isHighSeverity(finding));
@@ -71,15 +79,41 @@ function determineExitCode(scan, config) {
71
79
  ? 1
72
80
  : 0;
73
81
  }
82
+ function resolveScanMode(options) {
83
+ if (options.changed) {
84
+ return "changed";
85
+ }
86
+ if (options.quick) {
87
+ return "quick";
88
+ }
89
+ return "full";
90
+ }
74
91
  async function runScanCommand(root, options) {
75
- const mode = options.changed ? "changed" : options.quick ? "quick" : options.full ? "full" : "default";
76
- const scan = await (0, engine_1.runScan)(root, mode);
92
+ const mode = resolveScanMode(options);
77
93
  const categories = (0, finding_1.parseFindingCategoryList)(options.category);
94
+ const startedAt = new Date();
95
+ // Fingerprint the snapshot before tools run, so the envelope names exactly what was scanned.
96
+ const source = options.report === "envelope" ? await (0, sourceFingerprint_1.sourceFingerprint)(root) : null;
97
+ const scan = await (0, engine_1.runScan)(root, mode);
78
98
  const filteredScan = categories ? (0, engine_2.filterScanByCategories)(scan, categories) : scan;
79
99
  const { config } = await (0, shared_1.getConfig)(root);
80
100
  await (0, shared_1.ensureOutputArtifacts)(root, config, filteredScan);
81
101
  const exitCode = determineExitCode(filteredScan, config);
82
102
  switch (options.report) {
103
+ case "envelope": {
104
+ const envelope = await (0, envelope_1.buildMachineEnvelope)({
105
+ scan: filteredScan,
106
+ config,
107
+ policy: (0, executionPolicy_1.currentPolicy)(),
108
+ version: options.version ?? "unknown",
109
+ startedAt,
110
+ finishedAt: new Date(),
111
+ exitCode,
112
+ categories: categories ?? null,
113
+ source: source
114
+ });
115
+ return { output: `${JSON.stringify(envelope)}\n`, exitCode };
116
+ }
83
117
  case "json":
84
118
  return { output: (0, json_1.renderJsonReport)(filteredScan), exitCode };
85
119
  case "html":