@neuralaxis/vibedoctor 0.1.2 → 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 (43) hide show
  1. package/README.md +17 -1
  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/deptry.js +21 -2
  6. package/dist/adapters/knip.js +29 -4
  7. package/dist/adapters/lizard.d.ts +1 -1
  8. package/dist/adapters/lizard.js +51 -2
  9. package/dist/adapters/osvScanner.js +14 -2
  10. package/dist/adapters/privacyDetector.js +5 -5
  11. package/dist/adapters/ruff.d.ts +1 -1
  12. package/dist/adapters/ruff.js +4 -1
  13. package/dist/adapters/semgrep.d.ts +1 -1
  14. package/dist/adapters/semgrep.js +17 -3
  15. package/dist/adapters/shared.d.ts +1 -0
  16. package/dist/adapters/shared.js +22 -0
  17. package/dist/adapters/tsc.js +43 -18
  18. package/dist/adapters/vulture.d.ts +1 -1
  19. package/dist/adapters/vulture.js +25 -6
  20. package/dist/agentPack/templates/index.js +7 -4
  21. package/dist/agentPack/templates/skills.js +10 -4
  22. package/dist/cli/commands/agentPlan.js +9 -1
  23. package/dist/cli/commands/init.js +12 -4
  24. package/dist/cli/commands/scan.d.ts +1 -1
  25. package/dist/cli/commands/scan.js +4 -0
  26. package/dist/cli/commands/setup.js +3 -1
  27. package/dist/cli/commands/tool.d.ts +4 -0
  28. package/dist/cli/commands/tool.js +11 -0
  29. package/dist/cli/index.js +12 -0
  30. package/dist/core/config.d.ts +6 -0
  31. package/dist/core/config.js +29 -1
  32. package/dist/core/engine.d.ts +32 -1
  33. package/dist/core/engine.js +173 -27
  34. package/dist/core/projectDetector.d.ts +1 -1
  35. package/dist/core/projectDetector.js +29 -12
  36. package/dist/core/toolRunner.d.ts +1 -0
  37. package/dist/core/toolRunner.js +73 -11
  38. package/dist/mcp/tools/shared.js +8 -1
  39. package/dist/reporters/agent.js +8 -0
  40. package/dist/reporters/html.js +4 -2
  41. package/dist/reporters/json.js +2 -0
  42. package/dist/reporters/markdown.js +8 -1
  43. package/package.json +6 -2
@@ -110,12 +110,12 @@ function isFrameworkEntryFile(file) {
110
110
  /^(?:src\/)?pages\/(?:.+)\.(ts|tsx|js|jsx)$/.test(file) ||
111
111
  /^(?:src\/)?(?:middleware|instrumentation)\.(ts|js)$/.test(file));
112
112
  }
113
- async function detectProject(root) {
113
+ async function detectProject(root, excludePatterns) {
114
114
  const projectFiles = await (0, paths_1.listProjectFiles)(root);
115
- const fileSet = new Set(projectFiles);
115
+ const detectionFiles = excludePatterns ? (0, paths_1.filterPaths)(projectFiles, ["**/*"], excludePatterns) : projectFiles;
116
116
  const languages = new Set();
117
117
  const frameworkHints = new Set();
118
- for (const file of projectFiles) {
118
+ for (const file of detectionFiles) {
119
119
  if (file.endsWith(".py")) {
120
120
  languages.add("python");
121
121
  }
@@ -133,29 +133,46 @@ async function detectProject(root) {
133
133
  }
134
134
  }
135
135
  const packageManagers = new Set();
136
- if (fileSet.has("package.json")) {
137
- packageManagers.add(fileSet.has("pnpm-lock.yaml") ? "pnpm" : fileSet.has("yarn.lock") ? "yarn" : fileSet.has("bun.lockb") ? "bun" : "npm");
138
- }
139
- if (fileSet.has("requirements.txt") || fileSet.has("pyproject.toml")) {
140
- packageManagers.add(fileSet.has("uv.lock") ? "uv" : fileSet.has("poetry.lock") ? "poetry" : fileSet.has("pdm.lock") ? "pdm" : "pip");
136
+ const hasPackageJson = detectionFiles.some((f) => f === "package.json" || f.endsWith("/package.json"));
137
+ const hasPythonManifest = detectionFiles.some((f) => f === "requirements.txt" || f.endsWith("/requirements.txt") || f === "pyproject.toml" || f.endsWith("/pyproject.toml"));
138
+ if (hasPackageJson) {
139
+ packageManagers.add(detectionFiles.some((f) => f === "pnpm-lock.yaml" || f.endsWith("/pnpm-lock.yaml"))
140
+ ? "pnpm"
141
+ : detectionFiles.some((f) => f === "yarn.lock" || f.endsWith("/yarn.lock"))
142
+ ? "yarn"
143
+ : detectionFiles.some((f) => f === "bun.lockb" || f.endsWith("/bun.lockb"))
144
+ ? "bun"
145
+ : "npm");
146
+ }
147
+ if (hasPythonManifest) {
148
+ packageManagers.add(detectionFiles.some((f) => f === "uv.lock" || f.endsWith("/uv.lock"))
149
+ ? "uv"
150
+ : detectionFiles.some((f) => f === "poetry.lock" || f.endsWith("/poetry.lock"))
151
+ ? "poetry"
152
+ : detectionFiles.some((f) => f === "pdm.lock" || f.endsWith("/pdm.lock"))
153
+ ? "pdm"
154
+ : "pip");
141
155
  }
142
156
  const packageMetadata = await readPackageMetadata(root, ["npm", "pnpm", "yarn", "bun"].find((manager) => packageManagers.has(manager)));
143
157
  for (const hint of packageMetadata.frameworkHints) {
144
158
  frameworkHints.add(hint);
145
159
  }
146
- if (fileSet.has("pytest.ini") || projectFiles.some((file) => /(^|\/)tests?\//.test(file) && file.endsWith(".py"))) {
160
+ if (detectionFiles.some((f) => f === "pytest.ini" || f.endsWith("/pytest.ini")) ||
161
+ detectionFiles.some((file) => /(^|\/)tests?\//.test(file) && file.endsWith(".py"))) {
147
162
  packageMetadata.testCommands.push(pythonTestCommand(packageManagers));
148
163
  }
149
164
  const toolPairs = await Promise.all(KNOWN_TOOLS.map(async (tool) => [tool, await commandExists(tool, root)]));
150
- const entryFiles = projectFiles.filter((file) => /(^|\/)(main|index|app|server|cli)\.(ts|tsx|js|jsx|py)$/.test(file) || isFrameworkEntryFile(file) || file === "package.json");
165
+ const entryFiles = detectionFiles.filter((file) => /(^|\/)(main|index|app|server|cli)\.(ts|tsx|js|jsx|py)$/.test(file) || isFrameworkEntryFile(file) || file.endsWith("package.json"));
151
166
  return {
152
167
  root,
153
168
  languages: Array.from(languages).sort(),
154
169
  packageManagers: Array.from(packageManagers).sort(),
155
170
  hasGit: await (0, git_1.isGitRepo)(root),
156
171
  changedFiles: await (0, git_1.getChangedFiles)(root),
157
- configFiles: KNOWN_CONFIG_FILES.filter((fileName) => fileSet.has(fileName)),
158
- lockfiles: KNOWN_LOCKFILES.filter((fileName) => fileSet.has(fileName)),
172
+ configFiles: KNOWN_CONFIG_FILES.filter((fileName) => detectionFiles.some((f) => f === fileName || f.endsWith(`/${fileName}`))),
173
+ // Consumers pass these values directly to tools such as osv-scanner, so
174
+ // retain the repository-relative path rather than just the basename.
175
+ lockfiles: detectionFiles.filter((file) => KNOWN_LOCKFILES.some((fileName) => file === fileName || file.endsWith(`/${fileName}`))),
159
176
  testCommands: Array.from(new Set(packageMetadata.testCommands)),
160
177
  toolsAvailable: Object.fromEntries(toolPairs),
161
178
  frameworkHints: Array.from(frameworkHints).sort(),
@@ -16,6 +16,7 @@ export type ToolResult = {
16
16
  };
17
17
  export declare function getLocalToolSearchPaths(cwd: string | undefined): string[];
18
18
  export declare function buildCommandEnv(cwd: string | undefined, overrides: NodeJS.ProcessEnv | undefined): NodeJS.ProcessEnv;
19
+ export declare function commandExistsOnWindowsPath(command: string, cwd?: string): boolean;
19
20
  export declare function runCommand(spec: CommandSpec, installHint?: string): Promise<ToolResult>;
20
21
  export declare function runCommands(commands: Array<{
21
22
  id: string;
@@ -5,10 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getLocalToolSearchPaths = getLocalToolSearchPaths;
7
7
  exports.buildCommandEnv = buildCommandEnv;
8
+ exports.commandExistsOnWindowsPath = commandExistsOnWindowsPath;
8
9
  exports.runCommand = runCommand;
9
10
  exports.runCommands = runCommands;
10
11
  const node_path_1 = __importDefault(require("node:path"));
12
+ const node_fs_1 = require("node:fs");
11
13
  const node_child_process_1 = require("node:child_process");
14
+ const node_child_process_2 = require("node:child_process");
12
15
  const LOCAL_TOOL_PATHS = [
13
16
  ["node_modules", ".bin"],
14
17
  [".venv", "Scripts"],
@@ -38,23 +41,78 @@ function getLocalToolSearchPaths(cwd) {
38
41
  const paths = ancestorDirs(cwd).flatMap((dir) => LOCAL_TOOL_PATHS.map((segments) => node_path_1.default.join(dir, ...segments)));
39
42
  return Array.from(new Set(paths));
40
43
  }
44
+ function getUserToolSearchPaths(env) {
45
+ const paths = [];
46
+ if (process.platform === "win32" && env.APPDATA) {
47
+ const pythonRoot = node_path_1.default.join(env.APPDATA, "Python");
48
+ try {
49
+ for (const entry of (0, node_fs_1.readdirSync)(pythonRoot, { withFileTypes: true })) {
50
+ if (entry.isDirectory() && /^Python\d+$/i.test(entry.name)) {
51
+ paths.push(node_path_1.default.join(pythonRoot, entry.name, "Scripts"));
52
+ }
53
+ }
54
+ }
55
+ catch {
56
+ // Python user packages have not been installed for this account.
57
+ }
58
+ }
59
+ else if (env.HOME) {
60
+ paths.push(node_path_1.default.join(env.HOME, ".local", "bin"));
61
+ }
62
+ return paths;
63
+ }
41
64
  function buildCommandEnv(cwd, overrides) {
42
65
  const env = { ...process.env, ...overrides };
43
66
  const pathKey = getPathKey(env);
44
67
  const existingPath = env[pathKey];
45
- env[pathKey] = [...getLocalToolSearchPaths(cwd), existingPath].filter(Boolean).join(node_path_1.default.delimiter);
68
+ env[pathKey] = [...getLocalToolSearchPaths(cwd), ...getUserToolSearchPaths(env), existingPath].filter(Boolean).join(node_path_1.default.delimiter);
46
69
  return env;
47
70
  }
71
+ function findWindowsCommandOnPath(command, env) {
72
+ const pathValue = env[getPathKey(env)] ?? "";
73
+ const extensions = (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD")
74
+ .split(";")
75
+ .map((extension) => extension.toLowerCase());
76
+ for (const directory of pathValue.split(node_path_1.default.delimiter).filter(Boolean)) {
77
+ for (const extension of extensions) {
78
+ const candidate = node_path_1.default.join(directory, `${command}${extension}`);
79
+ if ((0, node_fs_1.existsSync)(candidate)) {
80
+ return candidate;
81
+ }
82
+ }
83
+ }
84
+ return undefined;
85
+ }
86
+ function commandExistsOnWindowsPath(command, cwd) {
87
+ return findWindowsCommandOnPath(command, buildCommandEnv(cwd, undefined)) !== undefined;
88
+ }
89
+ function resolveWindowsCommand(command, env) {
90
+ if (process.platform !== "win32" || node_path_1.default.isAbsolute(command) || node_path_1.default.extname(command)) {
91
+ return { command, useShell: false };
92
+ }
93
+ const candidate = findWindowsCommandOnPath(command, env);
94
+ if (candidate) {
95
+ if (/\.(?:cmd|bat)$/i.test(candidate)) {
96
+ // cmd.exe scripts must run through the shell; quote the resolved path so
97
+ // directories with spaces (e.g. "Program Files") do not break parsing.
98
+ return { command: candidate.includes(" ") ? `"${candidate}"` : candidate, useShell: true };
99
+ }
100
+ return { command: candidate, useShell: false };
101
+ }
102
+ // Not found via PATH/PATHEXT probing. Fall back to the shell so commands that
103
+ // are only reachable through cmd.exe mechanisms (App Execution Aliases,
104
+ // App Paths registry entries) still launch, matching the previous behavior.
105
+ return { command, useShell: true };
106
+ }
48
107
  async function runCommand(spec, installHint) {
49
108
  const startedAt = Date.now();
50
- const useShell = process.platform === "win32" &&
51
- !node_path_1.default.isAbsolute(spec.cmd) &&
52
- node_path_1.default.extname(spec.cmd).length === 0;
109
+ const env = buildCommandEnv(spec.cwd, spec.env);
110
+ const resolved = resolveWindowsCommand(spec.cmd, env);
53
111
  return new Promise((resolve) => {
54
- const child = (0, node_child_process_1.spawn)(spec.cmd, spec.args, {
112
+ const child = (0, node_child_process_1.spawn)(resolved.command, spec.args, {
55
113
  cwd: spec.cwd,
56
- env: buildCommandEnv(spec.cwd, spec.env),
57
- shell: useShell,
114
+ env,
115
+ shell: resolved.useShell,
58
116
  windowsHide: true
59
117
  });
60
118
  let stdout = "";
@@ -126,11 +184,15 @@ async function runCommand(spec, installHint) {
126
184
  return;
127
185
  }
128
186
  settled = true;
129
- const killSignal = process.platform === "win32" ? undefined : "SIGTERM";
130
- try {
131
- child.kill(killSignal);
187
+ if (process.platform === "win32" && child.pid) {
188
+ (0, node_child_process_2.execFile)("taskkill", ["/pid", String(child.pid), "/T", "/F"], { windowsHide: true }, () => undefined);
189
+ }
190
+ else {
191
+ try {
192
+ child.kill("SIGTERM");
193
+ }
194
+ catch { }
132
195
  }
133
- catch { }
134
196
  cleanup();
135
197
  resolve({
136
198
  command: [spec.cmd, ...spec.args].join(" "),
@@ -50,7 +50,14 @@ async function prepareScan(root, mode, categories, target = "generic") {
50
50
  const filtered = categories && categories.length > 0 ? (0, engine_1.filterScanByCategories)(scan, categories, { policy, target }) : scan;
51
51
  const withPlan = {
52
52
  ...filtered,
53
- agentPlan: (0, engine_1.createAgentPlan)({ findings: filtered.findings, score: filtered.score, skippedTools: filtered.skippedTools }, { policy, target })
53
+ agentPlan: (0, engine_1.createAgentPlan)({
54
+ findings: filtered.findings,
55
+ score: filtered.score,
56
+ skippedTools: filtered.skippedTools,
57
+ toolStatuses: filtered.toolStatuses,
58
+ completeness: filtered.completeness,
59
+ recoveryActions: filtered.recoveryActions
60
+ }, { policy, target })
54
61
  };
55
62
  await (0, shared_1.ensureOutputArtifacts)(root, config, withPlan);
56
63
  return {
@@ -9,6 +9,14 @@ function renderAgentMarkdown(input) {
9
9
  const plan = getPlan(input);
10
10
  const lines = ["# VibeDoctor Agent Plan", "", `Goal: ${plan.goal}.`, "", `Target: ${plan.target}`, "", "## Workflow", ""];
11
11
  plan.workflow.forEach((step, index) => lines.push(`${index + 1}. ${step}`));
12
+ if (plan.recoveryActions.length > 0) {
13
+ lines.push("", "## Recover before editing", "");
14
+ plan.recoveryActions.forEach((action) => {
15
+ lines.push(`- ${action.tool}: \`${action.command}\``);
16
+ lines.push(` Success: ${action.successCondition}.`);
17
+ lines.push(` If it fails: ${action.onFailure}`);
18
+ });
19
+ }
12
20
  lines.push("", "## Allowed actions", "");
13
21
  plan.allowedActions.forEach((action) => lines.push(`- ${action}`));
14
22
  lines.push("", "## Forbidden actions", "");
@@ -49,7 +49,8 @@ function renderHtmlReport(scan) {
49
49
  <h1>VibeDoctor Health Report</h1>
50
50
  <div class="meta">Root: <code>${escapeHtml(scan.root)}</code> &middot; Mode: ${scan.mode} &middot; Generated for agents &amp; humans</div>
51
51
 
52
- <div class="score">Health: ${scan.score.overall}/100 ${scan.score.overall >= 85 ? "✅" : "⚠️"}</div>
52
+ <div class="score">Health: ${scan.score.overall}/100 — ${scan.completeness.status.toUpperCase()} ${scan.score.overall >= 85 ? "✅" : "⚠️"}</div>
53
+ <div class="meta">Scan coverage: ${scan.completeness.completed}/${scan.completeness.planned} checks completed.${scan.completeness.comparable ? "" : " This score is not comparable to a complete scan."}</div>
53
54
 
54
55
  <div class="summary">
55
56
  <span class="pill">Blockers: ${scan.blockers.length}</span>
@@ -71,7 +72,8 @@ function renderHtmlReport(scan) {
71
72
 
72
73
  ${toolList(scan.toolStatuses.filter(t => t.status !== "ok"), "Tool Statuses (non-ok)")}
73
74
  ${toolList(scan.skippedTools, "Skipped Tools")}
74
- ${errored.length ? toolList(errored, "Errored / Timed Out Tools") : ""}
75
+ ${errored.length ? toolList(errored, "Errored / Timed Out Tools") : ""}
76
+ ${scan.recoveryActions.length ? `<h3>Recover before editing</h3><ul>${scan.recoveryActions.map(action => `<li><code>${escapeHtml(action.command)}</code> — ${escapeHtml(action.successCondition)}</li>`).join("")}</ul>` : ""}
75
77
 
76
78
  <p class="meta" style="margin-top:32px">Run <code>vibedoctor agent-plan</code> for guided repair. Full JSON/HTML/Markdown/SARIF available via --report.</p>
77
79
  </body>
@@ -4,6 +4,8 @@ exports.renderJsonReport = renderJsonReport;
4
4
  function renderJsonReport(scan) {
5
5
  return JSON.stringify({
6
6
  score: scan.score.overall,
7
+ completeness: scan.completeness,
8
+ recoveryActions: scan.recoveryActions,
7
9
  categoryScores: scan.score.categories,
8
10
  findings: scan.findings,
9
11
  topFindings: scan.topFindings,
@@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderMarkdownReport = renderMarkdownReport;
4
4
  function renderMarkdownReport(scan) {
5
5
  const plan = scan.agentPlan;
6
- const lines = [`# VibeDoctor Report`, "", `Health: **${scan.score.overall}/100**`, ""];
6
+ const lines = [
7
+ `# VibeDoctor Report`,
8
+ "",
9
+ `Health: **${scan.score.overall}/100** — ${scan.completeness.status.toUpperCase()}`,
10
+ `Scan coverage: **${scan.completeness.completed}/${scan.completeness.planned} checks completed**`,
11
+ ...(scan.completeness.comparable ? [] : ["This score is not comparable to a complete scan."]),
12
+ ""
13
+ ];
7
14
  lines.push("## Summary");
8
15
  lines.push(`- Blockers: ${scan.blockers.length}`);
9
16
  lines.push(`- Fix next: ${scan.fixNext.length}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neuralaxis/vibedoctor",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Health diagnosis and fix planning for JS, TS, Python, and mixed repositories.",
5
5
  "type": "commonjs",
6
6
  "publishConfig": {
@@ -68,6 +68,10 @@
68
68
  "knip": "^6.16.1",
69
69
  "tsx": "^4.20.3",
70
70
  "typescript": "^5.8.3",
71
- "vitest": "^3.2.4"
71
+ "vite": "^7.3.5",
72
+ "vitest": "^3.2.6"
73
+ },
74
+ "overrides": {
75
+ "esbuild": "0.28.1"
72
76
  }
73
77
  }