@neuralaxis/vibedoctor 0.1.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 (135) hide show
  1. package/LICENSE +232 -0
  2. package/README.md +280 -0
  3. package/dist/adapters/biome.d.ts +2 -0
  4. package/dist/adapters/biome.js +66 -0
  5. package/dist/adapters/coveragePy.d.ts +2 -0
  6. package/dist/adapters/coveragePy.js +56 -0
  7. package/dist/adapters/customDeadChain.d.ts +20 -0
  8. package/dist/adapters/customDeadChain.js +243 -0
  9. package/dist/adapters/customLeftovers.d.ts +2 -0
  10. package/dist/adapters/customLeftovers.js +244 -0
  11. package/dist/adapters/customRefactor.d.ts +2 -0
  12. package/dist/adapters/customRefactor.js +176 -0
  13. package/dist/adapters/deptry.d.ts +2 -0
  14. package/dist/adapters/deptry.js +59 -0
  15. package/dist/adapters/gitleaks.d.ts +2 -0
  16. package/dist/adapters/gitleaks.js +47 -0
  17. package/dist/adapters/index.d.ts +16 -0
  18. package/dist/adapters/index.js +35 -0
  19. package/dist/adapters/jest.d.ts +2 -0
  20. package/dist/adapters/jest.js +62 -0
  21. package/dist/adapters/jscpd.d.ts +2 -0
  22. package/dist/adapters/jscpd.js +59 -0
  23. package/dist/adapters/knip.d.ts +2 -0
  24. package/dist/adapters/knip.js +75 -0
  25. package/dist/adapters/lizard.d.ts +2 -0
  26. package/dist/adapters/lizard.js +45 -0
  27. package/dist/adapters/osvScanner.d.ts +2 -0
  28. package/dist/adapters/osvScanner.js +68 -0
  29. package/dist/adapters/pyright.d.ts +2 -0
  30. package/dist/adapters/pyright.js +52 -0
  31. package/dist/adapters/radon.d.ts +2 -0
  32. package/dist/adapters/radon.js +45 -0
  33. package/dist/adapters/ruff.d.ts +2 -0
  34. package/dist/adapters/ruff.js +71 -0
  35. package/dist/adapters/semgrep.d.ts +2 -0
  36. package/dist/adapters/semgrep.js +64 -0
  37. package/dist/adapters/shared.d.ts +23 -0
  38. package/dist/adapters/shared.js +2 -0
  39. package/dist/adapters/tsc.d.ts +2 -0
  40. package/dist/adapters/tsc.js +57 -0
  41. package/dist/adapters/vitest.d.ts +2 -0
  42. package/dist/adapters/vitest.js +62 -0
  43. package/dist/adapters/vulture.d.ts +2 -0
  44. package/dist/adapters/vulture.js +59 -0
  45. package/dist/agentPack/generateAgentPack.d.ts +48 -0
  46. package/dist/agentPack/generateAgentPack.js +219 -0
  47. package/dist/agentPack/policy.d.ts +19 -0
  48. package/dist/agentPack/policy.js +117 -0
  49. package/dist/agentPack/templates/index.d.ts +7 -0
  50. package/dist/agentPack/templates/index.js +134 -0
  51. package/dist/agentPack/templates/skills.d.ts +7 -0
  52. package/dist/agentPack/templates/skills.js +337 -0
  53. package/dist/cli/commands/agent.d.ts +22 -0
  54. package/dist/cli/commands/agent.js +57 -0
  55. package/dist/cli/commands/agentPlan.d.ts +1 -0
  56. package/dist/cli/commands/agentPlan.js +12 -0
  57. package/dist/cli/commands/baseline.d.ts +1 -0
  58. package/dist/cli/commands/baseline.js +8 -0
  59. package/dist/cli/commands/explain.d.ts +1 -0
  60. package/dist/cli/commands/explain.js +35 -0
  61. package/dist/cli/commands/fix.d.ts +1 -0
  62. package/dist/cli/commands/fix.js +19 -0
  63. package/dist/cli/commands/init.d.ts +1 -0
  64. package/dist/cli/commands/init.js +101 -0
  65. package/dist/cli/commands/report.d.ts +1 -0
  66. package/dist/cli/commands/report.js +25 -0
  67. package/dist/cli/commands/scan.d.ts +14 -0
  68. package/dist/cli/commands/scan.js +61 -0
  69. package/dist/cli/commands/setup.d.ts +35 -0
  70. package/dist/cli/commands/setup.js +326 -0
  71. package/dist/cli/commands/shared.d.ts +8 -0
  72. package/dist/cli/commands/shared.js +29 -0
  73. package/dist/cli/index.d.ts +2 -0
  74. package/dist/cli/index.js +148 -0
  75. package/dist/core/baseline.d.ts +7 -0
  76. package/dist/core/baseline.js +33 -0
  77. package/dist/core/config.d.ts +72 -0
  78. package/dist/core/config.js +236 -0
  79. package/dist/core/engine.d.ts +87 -0
  80. package/dist/core/engine.js +437 -0
  81. package/dist/core/finding.d.ts +40 -0
  82. package/dist/core/finding.js +141 -0
  83. package/dist/core/git.d.ts +3 -0
  84. package/dist/core/git.js +67 -0
  85. package/dist/core/paths.d.ts +7 -0
  86. package/dist/core/paths.js +104 -0
  87. package/dist/core/projectDetector.d.ts +17 -0
  88. package/dist/core/projectDetector.js +160 -0
  89. package/dist/core/scanPlanner.d.ts +11 -0
  90. package/dist/core/scanPlanner.js +47 -0
  91. package/dist/core/scoring.d.ts +8 -0
  92. package/dist/core/scoring.js +57 -0
  93. package/dist/core/toolRunner.d.ts +24 -0
  94. package/dist/core/toolRunner.js +130 -0
  95. package/dist/index.d.ts +7 -0
  96. package/dist/index.js +23 -0
  97. package/dist/mcp/server.d.ts +1 -0
  98. package/dist/mcp/server.js +141 -0
  99. package/dist/mcp/tools/explainFinding.d.ts +2 -0
  100. package/dist/mcp/tools/explainFinding.js +23 -0
  101. package/dist/mcp/tools/fixSafe.d.ts +2 -0
  102. package/dist/mcp/tools/fixSafe.js +15 -0
  103. package/dist/mcp/tools/getAgentPlan.d.ts +2 -0
  104. package/dist/mcp/tools/getAgentPlan.js +31 -0
  105. package/dist/mcp/tools/getReport.d.ts +2 -0
  106. package/dist/mcp/tools/getReport.js +26 -0
  107. package/dist/mcp/tools/index.d.ts +1 -0
  108. package/dist/mcp/tools/index.js +19 -0
  109. package/dist/mcp/tools/scanChanged.d.ts +2 -0
  110. package/dist/mcp/tools/scanChanged.js +23 -0
  111. package/dist/mcp/tools/scanFull.d.ts +2 -0
  112. package/dist/mcp/tools/scanFull.js +23 -0
  113. package/dist/mcp/tools/shared.d.ts +51 -0
  114. package/dist/mcp/tools/shared.js +126 -0
  115. package/dist/mcp/tools/verify.d.ts +2 -0
  116. package/dist/mcp/tools/verify.js +21 -0
  117. package/dist/reporters/agent.d.ts +3 -0
  118. package/dist/reporters/agent.js +48 -0
  119. package/dist/reporters/html.d.ts +2 -0
  120. package/dist/reporters/html.js +81 -0
  121. package/dist/reporters/json.d.ts +2 -0
  122. package/dist/reporters/json.js +18 -0
  123. package/dist/reporters/markdown.d.ts +2 -0
  124. package/dist/reporters/markdown.js +33 -0
  125. package/dist/reporters/sarif.d.ts +2 -0
  126. package/dist/reporters/sarif.js +38 -0
  127. package/dist/reporters/terminal.d.ts +2 -0
  128. package/dist/reporters/terminal.js +11 -0
  129. package/dist/rules/leftoverPatterns.d.ts +7 -0
  130. package/dist/rules/leftoverPatterns.js +10 -0
  131. package/dist/rules/refactorRules.d.ts +13 -0
  132. package/dist/rules/refactorRules.js +16 -0
  133. package/dist/rules/severityMap.d.ts +15 -0
  134. package/dist/rules/severityMap.js +33 -0
  135. package/package.json +72 -0
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.determineExitCode = determineExitCode;
4
+ exports.runScanCommand = runScanCommand;
5
+ const engine_1 = require("../../core/engine");
6
+ const finding_1 = require("../../core/finding");
7
+ const engine_2 = require("../../core/engine");
8
+ const terminal_1 = require("../../reporters/terminal");
9
+ const json_1 = require("../../reporters/json");
10
+ const html_1 = require("../../reporters/html");
11
+ const agent_1 = require("../../reporters/agent");
12
+ const shared_1 = require("./shared");
13
+ function shouldCountForFailure(isNew, config) {
14
+ return config.baseline.failOnlyOnNewIssues ? isNew : true;
15
+ }
16
+ function isHighSeverity(finding) {
17
+ return finding.severity === "high" || finding.severity === "critical";
18
+ }
19
+ function determineExitCode(scan, config) {
20
+ if (scan.score.overall < config.score.minimum) {
21
+ return 1;
22
+ }
23
+ const failingFindings = scan.findings.filter((finding) => shouldCountForFailure(finding.isNew, config));
24
+ const secretFailure = config.checks.security.enabled &&
25
+ config.checks.security.failOnSecrets && failingFindings.some((finding) => finding.source === "gitleaks");
26
+ const dependencyFailure = ((config.checks.security.enabled && config.checks.security.failOnNewHighVulnerabilities) ||
27
+ (config.checks.dependencies.enabled && config.checks.dependencies.failOnNewDirectVulnerabilities))
28
+ ? failingFindings.some((finding) => finding.category === "dependencies" && isHighSeverity(finding))
29
+ : false;
30
+ const missingDependencyFailure = config.checks.dependencies.enabled &&
31
+ config.checks.dependencies.failOnMissingDependencies &&
32
+ failingFindings.some((finding) => finding.source === "deptry" && finding.title === "DEP002");
33
+ const typeFailure = config.checks.correctness.enabled &&
34
+ config.checks.correctness.failOnTypeErrors &&
35
+ failingFindings.some((finding) => ["tsc", "pyright"].includes(finding.source) || (finding.category === "correctness" && isHighSeverity(finding)));
36
+ const testFailure = config.checks.correctness.enabled &&
37
+ config.checks.correctness.failOnTestFailures &&
38
+ failingFindings.some((finding) => finding.category === "tests" && isHighSeverity(finding));
39
+ return secretFailure || dependencyFailure || missingDependencyFailure || typeFailure || testFailure ? 1 : 0;
40
+ }
41
+ async function runScanCommand(root, options) {
42
+ const mode = options.changed ? "changed" : options.quick ? "quick" : options.full ? "full" : "default";
43
+ const scan = await (0, engine_1.runScan)(root, mode);
44
+ const categories = (0, finding_1.parseFindingCategoryList)(options.category);
45
+ const filteredScan = categories ? (0, engine_2.filterScanByCategories)(scan, categories) : scan;
46
+ const { config } = await (0, shared_1.getConfig)(root);
47
+ await (0, shared_1.ensureOutputArtifacts)(root, config, filteredScan);
48
+ const exitCode = determineExitCode(filteredScan, config);
49
+ switch (options.report) {
50
+ case "json":
51
+ return { output: (0, json_1.renderJsonReport)(filteredScan), exitCode };
52
+ case "html":
53
+ return { output: (0, html_1.renderHtmlReport)(filteredScan), exitCode };
54
+ case "agent":
55
+ return { output: (0, agent_1.renderAgentMarkdown)(filteredScan), exitCode };
56
+ case "agent-json":
57
+ return { output: (0, agent_1.renderAgentJson)(filteredScan), exitCode };
58
+ default:
59
+ return { output: (0, terminal_1.renderTerminalReport)(filteredScan), exitCode };
60
+ }
61
+ }
@@ -0,0 +1,35 @@
1
+ import type { CommandSpec } from "../../core/toolRunner";
2
+ import { type ProjectContext, type ProjectLanguage } from "../../core/projectDetector";
3
+ export type SetupPriority = "essential" | "recommended";
4
+ export type SetupInclude = "essential" | "recommended" | "all" | "npm" | "python" | "manual" | "built-in";
5
+ export type SetupOptions = {
6
+ apply?: boolean;
7
+ include?: SetupInclude;
8
+ };
9
+ type SetupTool = {
10
+ id: string;
11
+ packageName?: string;
12
+ executable?: string;
13
+ ecosystem: "npm" | "python" | "manual" | "built-in";
14
+ priority: SetupPriority;
15
+ languages?: ProjectLanguage[];
16
+ requiresLockfile?: boolean;
17
+ reason: string;
18
+ installHint?: string;
19
+ };
20
+ export type SetupPlan = {
21
+ project: ProjectContext;
22
+ builtIn: SetupTool[];
23
+ available: SetupTool[];
24
+ npmPackages: string[];
25
+ pythonPackages: string[];
26
+ manual: SetupTool[];
27
+ skipped: SetupTool[];
28
+ commands: CommandSpec[];
29
+ };
30
+ export declare function createSetupPlan(root: string, include?: SetupInclude): Promise<SetupPlan>;
31
+ export declare function runSetupCommand(root: string, options?: SetupOptions): Promise<{
32
+ output: string;
33
+ exitCode: number;
34
+ }>;
35
+ export {};
@@ -0,0 +1,326 @@
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.createSetupPlan = createSetupPlan;
7
+ exports.runSetupCommand = runSetupCommand;
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const toolRunner_1 = require("../../core/toolRunner");
10
+ const projectDetector_1 = require("../../core/projectDetector");
11
+ const paths_1 = require("../../core/paths");
12
+ const VALID_SETUP_INCLUDES = new Set(["essential", "recommended", "all", "npm", "python", "manual", "built-in"]);
13
+ const essentialTools = [
14
+ {
15
+ id: "custom-leftovers",
16
+ ecosystem: "built-in",
17
+ priority: "essential",
18
+ reason: "Finds stale TODOs, commented-out code, legacy fallback paths, and AI leftovers without any external install."
19
+ },
20
+ {
21
+ id: "custom-dead-chain",
22
+ ecosystem: "built-in",
23
+ priority: "essential",
24
+ reason: "Finds isolated file clusters after external dead-code tools report candidates."
25
+ },
26
+ {
27
+ id: "custom-refactor",
28
+ ecosystem: "built-in",
29
+ priority: "essential",
30
+ reason: "Finds large or complex files that need tests before refactor work."
31
+ },
32
+ {
33
+ id: "tsc",
34
+ packageName: "typescript",
35
+ executable: "tsc",
36
+ ecosystem: "npm",
37
+ priority: "essential",
38
+ languages: ["typescript"],
39
+ reason: "TypeScript correctness signal."
40
+ },
41
+ {
42
+ id: "biome",
43
+ packageName: "@biomejs/biome",
44
+ executable: "biome",
45
+ ecosystem: "npm",
46
+ priority: "essential",
47
+ languages: ["javascript", "typescript"],
48
+ reason: "Fast JS/TS lint and safe formatting signal."
49
+ },
50
+ {
51
+ id: "knip",
52
+ packageName: "knip",
53
+ executable: "knip",
54
+ ecosystem: "npm",
55
+ priority: "essential",
56
+ languages: ["javascript", "typescript"],
57
+ reason: "Unused files, exports, and dependency signal for JS/TS."
58
+ },
59
+ {
60
+ id: "ruff",
61
+ packageName: "ruff",
62
+ executable: "ruff",
63
+ ecosystem: "python",
64
+ priority: "essential",
65
+ languages: ["python"],
66
+ reason: "Python lint and safe-fix signal."
67
+ },
68
+ {
69
+ id: "pyright",
70
+ packageName: "pyright",
71
+ executable: "pyright",
72
+ ecosystem: "python",
73
+ priority: "essential",
74
+ languages: ["python"],
75
+ reason: "Python type correctness signal."
76
+ },
77
+ {
78
+ id: "vulture",
79
+ packageName: "vulture",
80
+ executable: "vulture",
81
+ ecosystem: "python",
82
+ priority: "essential",
83
+ languages: ["python"],
84
+ reason: "Python dead-code signal."
85
+ },
86
+ {
87
+ id: "gitleaks",
88
+ executable: "gitleaks",
89
+ ecosystem: "manual",
90
+ priority: "essential",
91
+ reason: "Secret detection across every repository.",
92
+ installHint: "Install Gitleaks from https://gitleaks.io/ or your OS package manager."
93
+ },
94
+ {
95
+ id: "osv-scanner",
96
+ executable: "osv-scanner",
97
+ ecosystem: "manual",
98
+ priority: "essential",
99
+ requiresLockfile: true,
100
+ reason: "Known-vulnerability detection for dependency lockfiles.",
101
+ installHint: "Install OSV-Scanner from https://google.github.io/osv-scanner/ or your OS package manager."
102
+ }
103
+ ];
104
+ const recommendedTools = [
105
+ {
106
+ id: "jscpd",
107
+ packageName: "jscpd",
108
+ executable: "jscpd",
109
+ ecosystem: "npm",
110
+ priority: "recommended",
111
+ languages: ["javascript", "typescript"],
112
+ reason: "Duplication signal for refactor planning."
113
+ },
114
+ {
115
+ id: "coverage.py",
116
+ packageName: "coverage",
117
+ executable: "coverage",
118
+ ecosystem: "python",
119
+ priority: "recommended",
120
+ languages: ["python"],
121
+ reason: "Python coverage signal."
122
+ },
123
+ {
124
+ id: "radon",
125
+ packageName: "radon",
126
+ executable: "radon",
127
+ ecosystem: "python",
128
+ priority: "recommended",
129
+ languages: ["python"],
130
+ reason: "Python complexity signal."
131
+ },
132
+ {
133
+ id: "deptry",
134
+ packageName: "deptry",
135
+ executable: "deptry",
136
+ ecosystem: "python",
137
+ priority: "recommended",
138
+ languages: ["python"],
139
+ reason: "Python dependency hygiene signal."
140
+ },
141
+ {
142
+ id: "semgrep",
143
+ executable: "semgrep",
144
+ ecosystem: "manual",
145
+ priority: "recommended",
146
+ reason: "Additional security and correctness rules.",
147
+ installHint: "Install Semgrep with: pipx install semgrep, uv tool install semgrep, or your OS package manager."
148
+ }
149
+ ];
150
+ function hasActiveLanguage(project, language) {
151
+ if (!project.languages.includes(language)) {
152
+ return false;
153
+ }
154
+ if (language === "python" && project.packageManagers.some((manager) => ["pip", "uv", "poetry", "pdm"].includes(manager))) {
155
+ return true;
156
+ }
157
+ if ((language === "javascript" || language === "typescript") && project.packageManagers.some((manager) => ["npm", "pnpm", "yarn", "bun"].includes(manager))) {
158
+ return true;
159
+ }
160
+ const sourcePattern = language === "python"
161
+ ? /^(src|app|packages|services)\/.*\.py$/
162
+ : language === "typescript"
163
+ ? /^(src|app|packages|services)\/.*\.tsx?$/
164
+ : /^(src|app|packages|services)\/.*\.jsx?$/;
165
+ return project.projectFiles.some((file) => sourcePattern.test(file));
166
+ }
167
+ function includesAnyLanguage(project, languages) {
168
+ return !languages || languages.some((language) => hasActiveLanguage(project, language));
169
+ }
170
+ function activeLanguages(project) {
171
+ return project.languages.filter((language) => hasActiveLanguage(project, language));
172
+ }
173
+ function appliesToProject(tool, project) {
174
+ if (!includesAnyLanguage(project, tool.languages)) {
175
+ return false;
176
+ }
177
+ if (tool.requiresLockfile && project.lockfiles.length === 0) {
178
+ return false;
179
+ }
180
+ return true;
181
+ }
182
+ function isToolAvailable(tool, project) {
183
+ if (!tool.executable) {
184
+ return false;
185
+ }
186
+ return Boolean(project.toolsAvailable[tool.executable] ?? project.toolsAvailable[tool.id]);
187
+ }
188
+ function jsPackageManager(project) {
189
+ return ["pnpm", "yarn", "bun", "npm"].find((manager) => project.packageManagers.includes(manager));
190
+ }
191
+ function jsInstallCommand(root, manager, packages) {
192
+ if (manager === "pnpm") {
193
+ return { cmd: "pnpm", args: ["add", "-D", ...packages], cwd: root, timeoutMs: 180_000 };
194
+ }
195
+ if (manager === "yarn") {
196
+ return { cmd: "yarn", args: ["add", "-D", ...packages], cwd: root, timeoutMs: 180_000 };
197
+ }
198
+ if (manager === "bun") {
199
+ return { cmd: "bun", args: ["add", "-d", ...packages], cwd: root, timeoutMs: 180_000 };
200
+ }
201
+ return { cmd: "npm", args: ["install", "-D", ...packages], cwd: root, timeoutMs: 180_000 };
202
+ }
203
+ async function pythonInstallCommand(root, project, packages) {
204
+ if (project.packageManagers.includes("uv")) {
205
+ return { cmd: "uv", args: ["add", "--dev", ...packages], cwd: root, timeoutMs: 180_000 };
206
+ }
207
+ if (project.packageManagers.includes("poetry")) {
208
+ return { cmd: "poetry", args: ["add", "--group", "dev", ...packages], cwd: root, timeoutMs: 180_000 };
209
+ }
210
+ if (project.packageManagers.includes("pdm")) {
211
+ return { cmd: "pdm", args: ["add", "-dG", "dev", ...packages], cwd: root, timeoutMs: 180_000 };
212
+ }
213
+ 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")));
214
+ if (!hasLocalVenv) {
215
+ return undefined;
216
+ }
217
+ return { cmd: "python", args: ["-m", "pip", "install", "-U", ...packages], cwd: root, timeoutMs: 180_000 };
218
+ }
219
+ function commandText(command) {
220
+ return [command.cmd, ...command.args].join(" ");
221
+ }
222
+ function resolveTools(include) {
223
+ if (include === "essential") {
224
+ return essentialTools;
225
+ }
226
+ if (include === "recommended") {
227
+ return recommendedTools;
228
+ }
229
+ const allTools = [...essentialTools, ...recommendedTools];
230
+ if (include === "all") {
231
+ return allTools;
232
+ }
233
+ return allTools.filter((tool) => tool.ecosystem === include);
234
+ }
235
+ async function createSetupPlan(root, include = "essential") {
236
+ const project = await (0, projectDetector_1.detectProject)(root);
237
+ const tools = resolveTools(include);
238
+ const relevantTools = tools.filter((tool) => appliesToProject(tool, project));
239
+ const builtIn = relevantTools.filter((tool) => tool.ecosystem === "built-in");
240
+ const externalTools = relevantTools.filter((tool) => tool.ecosystem !== "built-in");
241
+ const available = externalTools.filter((tool) => isToolAvailable(tool, project));
242
+ const missing = externalTools.filter((tool) => !isToolAvailable(tool, project));
243
+ const npmPackages = missing
244
+ .filter((tool) => tool.ecosystem === "npm" && tool.packageName)
245
+ .map((tool) => tool.packageName);
246
+ const pythonPackages = missing
247
+ .filter((tool) => tool.ecosystem === "python" && tool.packageName)
248
+ .map((tool) => tool.packageName);
249
+ const manual = missing.filter((tool) => tool.ecosystem === "manual");
250
+ const skipped = [];
251
+ const commands = [];
252
+ if (npmPackages.length > 0) {
253
+ const manager = jsPackageManager(project);
254
+ if (manager) {
255
+ commands.push(jsInstallCommand(root, manager, npmPackages));
256
+ }
257
+ else {
258
+ skipped.push(...missing.filter((tool) => tool.ecosystem === "npm").map((tool) => ({
259
+ ...tool,
260
+ installHint: "Add a package.json first, then install this as a dev dependency."
261
+ })));
262
+ }
263
+ }
264
+ if (pythonPackages.length > 0) {
265
+ const command = await pythonInstallCommand(root, project, pythonPackages);
266
+ if (command) {
267
+ commands.push(command);
268
+ }
269
+ else {
270
+ skipped.push(...missing.filter((tool) => tool.ecosystem === "python").map((tool) => ({
271
+ ...tool,
272
+ installHint: "Create or activate a Python virtualenv, then run: python -m pip install -U " + pythonPackages.join(" ")
273
+ })));
274
+ }
275
+ }
276
+ return { project, builtIn, available, npmPackages, pythonPackages, manual, skipped, commands };
277
+ }
278
+ function renderToolList(prefix, tools) {
279
+ if (tools.length === 0) {
280
+ return [];
281
+ }
282
+ return [prefix, ...tools.map((tool) => `- ${tool.id}: ${tool.reason}${tool.installHint ? ` ${tool.installHint}` : ""}`), ""];
283
+ }
284
+ function renderPlan(plan, include, results = []) {
285
+ const languages = activeLanguages(plan.project);
286
+ 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}`, ""];
287
+ lines.push(...renderToolList("Already built in", plan.builtIn));
288
+ lines.push(...renderToolList("Already available", plan.available));
289
+ if (plan.commands.length > 0) {
290
+ lines.push("Automatable installs", ...plan.commands.map((command) => `- ${commandText(command)}`), "");
291
+ }
292
+ lines.push(...renderToolList("Manual installs", plan.manual));
293
+ lines.push(...renderToolList("Skipped until project setup exists", plan.skipped));
294
+ if (results.length > 0) {
295
+ lines.push("Install results");
296
+ for (const result of results) {
297
+ lines.push(`- ${result.command}: ${result.status}${result.exitCode === null ? "" : ` (${result.exitCode})`}`);
298
+ if (result.stderr.trim()) {
299
+ lines.push(` ${result.stderr.trim().split(/\r?\n/)[0]}`);
300
+ }
301
+ }
302
+ lines.push("");
303
+ }
304
+ if (plan.commands.length > 0 && results.length === 0) {
305
+ lines.push("Run `vibedoctor setup --apply` to install the automatable tools.");
306
+ }
307
+ else if (plan.commands.length === 0 && plan.manual.length === 0 && plan.skipped.length === 0) {
308
+ lines.push(`All relevant ${include} tools are already available.`);
309
+ }
310
+ return `${lines.join("\n")}\n`;
311
+ }
312
+ async function runSetupCommand(root, options = {}) {
313
+ const include = VALID_SETUP_INCLUDES.has(options.include ?? "essential") ? (options.include ?? "essential") : "essential";
314
+ const plan = await createSetupPlan(root, include);
315
+ if (!options.apply) {
316
+ return { output: renderPlan(plan, include), exitCode: 0 };
317
+ }
318
+ const results = [];
319
+ for (const command of plan.commands) {
320
+ results.push(await (0, toolRunner_1.runCommand)(command));
321
+ }
322
+ return {
323
+ output: renderPlan(plan, include, results),
324
+ exitCode: results.some((result) => result.status === "error" || result.status === "timeout" || result.status === "skipped") ? 1 : 0
325
+ };
326
+ }
@@ -0,0 +1,8 @@
1
+ import type { ScanOutput } from "../../core/engine";
2
+ import { type VibeDoctorConfig } from "../../core/config";
3
+ export declare function ensureOutputArtifacts(root: string, config: VibeDoctorConfig, scan: ScanOutput): Promise<void>;
4
+ export declare function getConfig(root: string): Promise<{
5
+ config: VibeDoctorConfig;
6
+ configPath?: string;
7
+ }>;
8
+ export declare function writeOutput(root: string, file: string, content: string): Promise<void>;
@@ -0,0 +1,29 @@
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.ensureOutputArtifacts = ensureOutputArtifacts;
7
+ exports.getConfig = getConfig;
8
+ exports.writeOutput = writeOutput;
9
+ const node_fs_1 = require("node:fs");
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ const config_1 = require("../../core/config");
12
+ const paths_1 = require("../../core/paths");
13
+ const agent_1 = require("../../reporters/agent");
14
+ const html_1 = require("../../reporters/html");
15
+ const json_1 = require("../../reporters/json");
16
+ async function ensureOutputArtifacts(root, config, scan) {
17
+ await (0, paths_1.ensureDir)(node_path_1.default.join(root, ".vibedoctor"));
18
+ await writeOutput(root, config.output.json, (0, json_1.renderJsonReport)(scan));
19
+ await writeOutput(root, config.output.html, (0, html_1.renderHtmlReport)(scan));
20
+ await writeOutput(root, config.output.agent, (0, agent_1.renderAgentMarkdown)(scan));
21
+ }
22
+ async function getConfig(root) {
23
+ return (0, config_1.loadConfig)(root);
24
+ }
25
+ async function writeOutput(root, file, content) {
26
+ const absolutePath = node_path_1.default.join(root, file);
27
+ await (0, paths_1.ensureDir)(node_path_1.default.dirname(absolutePath));
28
+ await node_fs_1.promises.writeFile(absolutePath, content, "utf8");
29
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const agent_1 = require("./commands/agent");
6
+ const agentPlan_1 = require("./commands/agentPlan");
7
+ const baseline_1 = require("./commands/baseline");
8
+ const explain_1 = require("./commands/explain");
9
+ const fix_1 = require("./commands/fix");
10
+ const init_1 = require("./commands/init");
11
+ const server_1 = require("../mcp/server");
12
+ const report_1 = require("./commands/report");
13
+ const scan_1 = require("./commands/scan");
14
+ const setup_1 = require("./commands/setup");
15
+ async function main() {
16
+ const program = new commander_1.Command();
17
+ program.name("vibedoctor").description("Brutally simple repo health diagnosis.").version("0.1.0");
18
+ program
19
+ .command("init")
20
+ .description("Create vibedoctor.yml and .vibedoctor baseline scaffolding")
21
+ .action(async () => {
22
+ process.stdout.write(`Created ${await (0, init_1.runInit)(process.cwd())}\n`);
23
+ });
24
+ program
25
+ .command("scan")
26
+ .description("Run relevant checks and print a short health report")
27
+ .option("--changed", "Only report changed-file issues")
28
+ .option("--quick", "Quick mode")
29
+ .option("--full", "Full mode")
30
+ .option("--category <categories>", "Comma-separated finding categories")
31
+ .option("--report <format>", "terminal|json|html|agent|agent-json", "terminal")
32
+ .action(async (options) => {
33
+ const result = await (0, scan_1.runScanCommand)(process.cwd(), options);
34
+ process.stdout.write(result.output);
35
+ process.exitCode = result.exitCode;
36
+ });
37
+ program
38
+ .command("setup")
39
+ .description("Print or install scanner tools for the selected setup set")
40
+ .option("--apply", "Install automatable tools")
41
+ .option("--include <level>", "essential|recommended|all|npm|python|manual|built-in", "essential")
42
+ .action(async (options) => {
43
+ const result = await (0, setup_1.runSetupCommand)(process.cwd(), options);
44
+ process.stdout.write(result.output);
45
+ process.exitCode = result.exitCode;
46
+ });
47
+ program
48
+ .command("fix")
49
+ .description("Run safe autofix commands")
50
+ .option("--safe", "Only allow safe fixes", true)
51
+ .action(async () => {
52
+ process.stdout.write(await (0, fix_1.runSafeFixCommand)(process.cwd()));
53
+ });
54
+ program
55
+ .command("report")
56
+ .description("Emit a full report")
57
+ .option("--full", "Render the full human-readable report")
58
+ .option("--json", "Render JSON")
59
+ .option("--html", "Render HTML")
60
+ .option("--markdown", "Render Markdown")
61
+ .option("--agent", "Render agent markdown")
62
+ .option("--sarif", "Render SARIF")
63
+ .action(async (options) => {
64
+ const format = options.full ? "full" : options.html ? "html" : options.markdown ? "markdown" : options.agent ? "agent" : options.sarif ? "sarif" : "json";
65
+ process.stdout.write(await (0, report_1.runReportCommand)(process.cwd(), format));
66
+ });
67
+ const agent = program.command("agent").description("Manage the VibeDoctor agent pack");
68
+ agent
69
+ .command("init")
70
+ .description("Create AGENTS.md, canonical skills, policy, and optional target shims")
71
+ .option("--target <target>", "Single target alias for --targets")
72
+ .option("--targets <targets>", "codex,copilot,claude,cursor|all", "codex")
73
+ .option("--force", "Overwrite generated files")
74
+ .action(async (options) => {
75
+ process.stdout.write(await (0, agent_1.runAgentInitCommand)(process.cwd(), options));
76
+ });
77
+ agent
78
+ .command("pack")
79
+ .description("Regenerate canonical AGENTS.md and .agents skills from templates")
80
+ .option("--target <target>", "Single target alias for --targets")
81
+ .option("--targets <targets>", "codex,copilot,claude,cursor|all")
82
+ .option("--force", "Overwrite generated files")
83
+ .action(async (options) => {
84
+ process.stdout.write(await (0, agent_1.runAgentPackCommand)(process.cwd(), options));
85
+ });
86
+ agent
87
+ .command("sync")
88
+ .description("Copy canonical skills into agent-specific locations")
89
+ .option("--target <target>", "Single target alias for --targets")
90
+ .option("--targets <targets>", "codex,copilot,claude,cursor|all")
91
+ .option("--force", "Overwrite generated files")
92
+ .action(async (options) => {
93
+ process.stdout.write(await (0, agent_1.runAgentSyncCommand)(process.cwd(), options));
94
+ });
95
+ agent
96
+ .command("doctor")
97
+ .description("Check whether the agent-pack setup is healthy")
98
+ .option("--target <target>", "Single target alias for --targets")
99
+ .option("--targets <targets>", "codex,copilot,claude,cursor|all")
100
+ .action(async (options) => {
101
+ const result = await (0, agent_1.runAgentDoctorCommand)(process.cwd(), options);
102
+ process.stdout.write(result.output);
103
+ process.exitCode = result.exitCode;
104
+ });
105
+ const baseline = program.command("baseline").description("Manage baselines");
106
+ baseline
107
+ .command("create")
108
+ .description("Create a baseline file from the current findings")
109
+ .action(async () => {
110
+ process.stdout.write(await (0, baseline_1.runBaselineCreateCommand)(process.cwd()));
111
+ });
112
+ program
113
+ .command("agent-plan")
114
+ .description("Generate an AI-agent-oriented fix plan")
115
+ .option("--format <format>", "markdown|json", "markdown")
116
+ .option("--for <target>", "codex|copilot|claude|cursor")
117
+ .action(async (options) => {
118
+ process.stdout.write(await (0, agentPlan_1.runAgentPlanCommand)(process.cwd(), options.format, options.for));
119
+ });
120
+ program
121
+ .command("explain")
122
+ .description("Explain a finding")
123
+ .argument("<finding-id>")
124
+ .option("--format <format>", "text|json", "text")
125
+ .action(async (findingId, options) => {
126
+ process.stdout.write(await (0, explain_1.runExplainCommand)(process.cwd(), findingId, options.format));
127
+ });
128
+ program
129
+ .command("verify")
130
+ .description("Re-run scan in changed mode for agent verification")
131
+ .action(async () => {
132
+ const result = await (0, scan_1.runScanCommand)(process.cwd(), { changed: true });
133
+ process.stdout.write(result.output);
134
+ process.exitCode = result.exitCode;
135
+ });
136
+ program
137
+ .command("mcp")
138
+ .description("Start the VibeDoctor MCP server over stdio")
139
+ .action(async () => {
140
+ await (0, server_1.runMcpServer)(process.cwd());
141
+ });
142
+ await program.parseAsync(process.argv);
143
+ }
144
+ main().catch((error) => {
145
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
146
+ process.stderr.write(`${message}\n`);
147
+ process.exitCode = 1;
148
+ });
@@ -0,0 +1,7 @@
1
+ import { type BaselineEntry, type Finding } from "./finding";
2
+ export type BaselineFile = {
3
+ createdAt: string;
4
+ findings: BaselineEntry[];
5
+ };
6
+ export declare function loadBaseline(root: string, filePath: string): Promise<BaselineFile>;
7
+ export declare function writeBaseline(root: string, filePath: string, findings: Finding[]): Promise<BaselineFile>;
@@ -0,0 +1,33 @@
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.loadBaseline = loadBaseline;
7
+ exports.writeBaseline = writeBaseline;
8
+ const node_fs_1 = require("node:fs");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const paths_1 = require("./paths");
11
+ const finding_1 = require("./finding");
12
+ async function loadBaseline(root, filePath) {
13
+ const absolutePath = node_path_1.default.join(root, filePath);
14
+ if (!(await (0, paths_1.pathExists)(absolutePath))) {
15
+ return {
16
+ createdAt: new Date().toISOString(),
17
+ findings: []
18
+ };
19
+ }
20
+ return JSON.parse(await node_fs_1.promises.readFile(absolutePath, "utf8"));
21
+ }
22
+ async function writeBaseline(root, filePath, findings) {
23
+ const absolutePath = node_path_1.default.join(root, filePath);
24
+ await (0, paths_1.ensureDir)(node_path_1.default.dirname(absolutePath));
25
+ const baseline = {
26
+ createdAt: new Date().toISOString(),
27
+ findings: findings.map((finding) => ({
28
+ fingerprint: (0, finding_1.fingerprintFinding)(finding)
29
+ }))
30
+ };
31
+ await node_fs_1.promises.writeFile(absolutePath, JSON.stringify(baseline, null, 2), "utf8");
32
+ return baseline;
33
+ }