@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,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.osvScannerAdapter = void 0;
4
+ function parseOsv(stdout) {
5
+ const trimmed = stdout.trim();
6
+ if (!trimmed) {
7
+ return [];
8
+ }
9
+ const parsed = JSON.parse(trimmed);
10
+ const findings = [];
11
+ for (const result of parsed.results ?? []) {
12
+ for (const pkg of result.packages ?? []) {
13
+ for (const vulnerability of pkg.vulnerabilities ?? []) {
14
+ findings.push({
15
+ ...vulnerability,
16
+ package: vulnerability.package ?? pkg.package
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return findings;
22
+ }
23
+ function severityFromCvss(item) {
24
+ const score = Number(item.severity?.[0]?.score ?? 0);
25
+ if (score >= 9) {
26
+ return "critical";
27
+ }
28
+ if (score >= 7) {
29
+ return "high";
30
+ }
31
+ if (score >= 4) {
32
+ return "medium";
33
+ }
34
+ return "low";
35
+ }
36
+ exports.osvScannerAdapter = {
37
+ id: "osv-scanner",
38
+ category: "dependencies",
39
+ async detect(project) {
40
+ return project.lockfiles.length > 0;
41
+ },
42
+ buildScanCommand(ctx) {
43
+ return {
44
+ cmd: "osv-scanner",
45
+ args: ["scan", "--lockfile=auto", "--format=json", "."],
46
+ cwd: ctx.root,
47
+ timeoutMs: 60_000
48
+ };
49
+ },
50
+ parseResult(result) {
51
+ return parseOsv(result.stdout).map((item, index) => ({
52
+ id: `osv:${item.package?.name}:${item.id ?? index}`,
53
+ source: "osv-scanner",
54
+ category: "dependencies",
55
+ severity: severityFromCvss(item),
56
+ confidence: "high",
57
+ title: item.id ?? "Dependency vulnerability",
58
+ message: `${item.package?.name ?? "Dependency"}: ${item.summary ?? "Known vulnerability detected."}`,
59
+ isNew: true,
60
+ isAutofixable: false,
61
+ safeToAutofix: false,
62
+ agentInstruction: "Upgrade or replace the affected dependency after checking compatibility and changelog risk.",
63
+ tags: ["dependencies", "security"],
64
+ scoreImpact: 0
65
+ }));
66
+ },
67
+ installHint: "Install OSV-Scanner from https://google.github.io/osv-scanner/"
68
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const pyrightAdapter: ToolAdapter;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pyrightAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ function parsePyright(stdout) {
6
+ return stdout.trim() ? JSON.parse(stdout) : {};
7
+ }
8
+ function mapSeverity(level) {
9
+ if (level === "error") {
10
+ return "high";
11
+ }
12
+ if (level === "warning") {
13
+ return "medium";
14
+ }
15
+ return "low";
16
+ }
17
+ exports.pyrightAdapter = {
18
+ id: "pyright",
19
+ category: "correctness",
20
+ async detect(project) {
21
+ return project.languages.includes("python");
22
+ },
23
+ buildScanCommand(ctx) {
24
+ return {
25
+ cmd: "pyright",
26
+ args: ["--outputjson"],
27
+ cwd: ctx.root,
28
+ timeoutMs: 90_000
29
+ };
30
+ },
31
+ parseResult(result, ctx) {
32
+ return (parsePyright(result.stdout).generalDiagnostics ?? []).map((item, index) => ({
33
+ id: `pyright:${item.file}:${item.range?.start.line ?? 0}:${item.rule ?? index}`,
34
+ source: "pyright",
35
+ category: "correctness",
36
+ severity: mapSeverity(item.severity),
37
+ confidence: "high",
38
+ title: item.rule ?? "pyright",
39
+ message: item.message,
40
+ file: (0, finding_1.normalizeFilePath)(item.file, ctx.root),
41
+ startLine: item.range ? item.range.start.line + 1 : undefined,
42
+ endLine: item.range ? item.range.end.line + 1 : undefined,
43
+ isNew: true,
44
+ isAutofixable: false,
45
+ safeToAutofix: false,
46
+ agentInstruction: "Address the Python type issue and rerun the affected tests.",
47
+ tags: ["python", "types"],
48
+ scoreImpact: 0
49
+ }));
50
+ },
51
+ installHint: "Install Pyright with: npm install -D pyright"
52
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const radonAdapter: ToolAdapter;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.radonAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ function parseRadon(stdout) {
6
+ return stdout.trim() ? JSON.parse(stdout) : {};
7
+ }
8
+ exports.radonAdapter = {
9
+ id: "radon",
10
+ category: "maintainability",
11
+ async detect(project) {
12
+ return project.languages.includes("python");
13
+ },
14
+ buildScanCommand(ctx) {
15
+ return {
16
+ cmd: "radon",
17
+ args: ["cc", "-j", "."],
18
+ cwd: ctx.root,
19
+ timeoutMs: 120_000
20
+ };
21
+ },
22
+ parseResult(result, ctx) {
23
+ return Object.entries(parseRadon(result.stdout)).flatMap(([file, blocks]) => blocks
24
+ .filter((block) => (block.complexity ?? 0) >= ctx.config.checks.refactorReadiness.minComplexity)
25
+ .map((block) => ({
26
+ id: `radon:${file}:${block.lineno ?? 0}:${block.name}`,
27
+ source: "radon",
28
+ category: "maintainability",
29
+ severity: (block.complexity ?? 0) >= ctx.config.checks.refactorReadiness.minComplexity * 2 ? "high" : "medium",
30
+ confidence: "high",
31
+ title: `Complex Python block (${block.rank ?? "?"})`,
32
+ message: `${block.name ?? "Block"} complexity is ${block.complexity}.`,
33
+ file: (0, finding_1.normalizeFilePath)(file, ctx.root),
34
+ startLine: block.lineno,
35
+ endLine: block.endline,
36
+ isNew: true,
37
+ isAutofixable: false,
38
+ safeToAutofix: false,
39
+ agentInstruction: "Split or simplify the complex Python logic after protecting behavior with tests.",
40
+ tags: ["python", "complexity"],
41
+ scoreImpact: 0
42
+ })));
43
+ },
44
+ installHint: "Install radon with: pipx install radon or uv tool install radon"
45
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const ruffAdapter: ToolAdapter;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ruffAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ function parseRuffOutput(stdout) {
6
+ const trimmed = stdout.trim();
7
+ if (!trimmed) {
8
+ return [];
9
+ }
10
+ return JSON.parse(trimmed);
11
+ }
12
+ function mapSeverity(code) {
13
+ if (/^F|^E9|^B/.test(code)) {
14
+ return "medium";
15
+ }
16
+ if (/^S/.test(code)) {
17
+ return "high";
18
+ }
19
+ return "low";
20
+ }
21
+ exports.ruffAdapter = {
22
+ id: "ruff",
23
+ category: "correctness",
24
+ async detect(project) {
25
+ return project.languages.includes("python");
26
+ },
27
+ buildScanCommand(ctx) {
28
+ return {
29
+ cmd: "ruff",
30
+ args: ["check", ".", "--output-format", "json"],
31
+ cwd: ctx.root,
32
+ timeoutMs: 60_000
33
+ };
34
+ },
35
+ parseResult(result, ctx) {
36
+ if (!result.stdout.trim()) {
37
+ return [];
38
+ }
39
+ return parseRuffOutput(result.stdout).map((item) => ({
40
+ id: `ruff:${item.filename}:${item.location.row}:${item.code}`,
41
+ source: "ruff",
42
+ category: "correctness",
43
+ severity: mapSeverity(item.code),
44
+ confidence: "high",
45
+ title: item.code,
46
+ message: item.message,
47
+ file: (0, finding_1.normalizeFilePath)(item.filename, ctx.root),
48
+ startLine: item.location.row,
49
+ endLine: item.end_location?.row,
50
+ isNew: true,
51
+ isAutofixable: Boolean(item.fix),
52
+ safeToAutofix: Boolean(item.fix),
53
+ fixCommand: "ruff check . --fix && ruff format .",
54
+ agentInstruction: "Apply the Ruff fix if safe, then rerun the affected Python tests.",
55
+ tags: ["python", "lint"],
56
+ evidence: {
57
+ toolRawId: item.code
58
+ },
59
+ scoreImpact: 0
60
+ }));
61
+ },
62
+ buildFixCommand(ctx) {
63
+ return {
64
+ cmd: "ruff",
65
+ args: ["check", ".", "--fix"],
66
+ cwd: ctx.root,
67
+ timeoutMs: 60_000
68
+ };
69
+ },
70
+ installHint: "Install Ruff with: pipx install ruff, uv tool install ruff, or add it to your project."
71
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const semgrepAdapter: ToolAdapter;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.semgrepAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ function parseSemgrep(stdout) {
6
+ return stdout.trim() ? JSON.parse(stdout) : {};
7
+ }
8
+ function mapSeverity(level) {
9
+ if (level === "ERROR") {
10
+ return "high";
11
+ }
12
+ if (level === "WARNING") {
13
+ return "medium";
14
+ }
15
+ return "low";
16
+ }
17
+ function mapConfidence(level) {
18
+ if (level === "HIGH") {
19
+ return "high";
20
+ }
21
+ if (level === "MEDIUM") {
22
+ return "medium";
23
+ }
24
+ return "low";
25
+ }
26
+ exports.semgrepAdapter = {
27
+ id: "semgrep",
28
+ category: "security",
29
+ async detect(project) {
30
+ return project.languages.length > 0;
31
+ },
32
+ buildScanCommand(ctx) {
33
+ return {
34
+ cmd: "semgrep",
35
+ args: ["scan", "--json", "--quiet", "--config", "auto", "."],
36
+ cwd: ctx.root,
37
+ timeoutMs: 120_000
38
+ };
39
+ },
40
+ parseResult(result, ctx) {
41
+ return (parseSemgrep(result.stdout).results ?? []).map((item) => ({
42
+ id: `semgrep:${item.path}:${item.start.line}:${item.check_id}`,
43
+ source: "semgrep",
44
+ category: item.extra?.metadata?.category === "correctness" ? "correctness" : "security",
45
+ severity: mapSeverity(item.extra?.severity),
46
+ confidence: mapConfidence(item.extra?.metadata?.confidence),
47
+ title: item.check_id,
48
+ message: item.extra?.message ?? "Semgrep reported a potential issue.",
49
+ file: (0, finding_1.normalizeFilePath)(item.path, ctx.root),
50
+ startLine: item.start.line,
51
+ endLine: item.end?.line,
52
+ isNew: true,
53
+ isAutofixable: false,
54
+ safeToAutofix: false,
55
+ agentInstruction: "Review the data flow around this finding and make the smallest safe fix.",
56
+ tags: ["security", "semgrep"],
57
+ evidence: {
58
+ snippet: item.extra?.lines
59
+ },
60
+ scoreImpact: 0
61
+ }));
62
+ },
63
+ installHint: "Install Semgrep with: pipx install semgrep or your package manager."
64
+ };
@@ -0,0 +1,23 @@
1
+ import type { VibeDoctorConfig } from "../core/config";
2
+ import type { Finding, FindingCategory } from "../core/finding";
3
+ import type { ProjectContext } from "../core/projectDetector";
4
+ import type { CommandSpec, ToolResult } from "../core/toolRunner";
5
+ export type ToolAdapterContext = {
6
+ root: string;
7
+ project: ProjectContext;
8
+ config: VibeDoctorConfig;
9
+ scanMode: "default" | "changed" | "quick" | "full";
10
+ };
11
+ export type ToolAdapter = {
12
+ id: string;
13
+ category: FindingCategory;
14
+ detect(ctx: ProjectContext, config: VibeDoctorConfig): Promise<boolean>;
15
+ buildScanCommand?(ctx: ToolAdapterContext): CommandSpec;
16
+ parseResult?(result: ToolResult, ctx: ToolAdapterContext): Finding[];
17
+ buildFixCommand?(ctx: ToolAdapterContext): CommandSpec;
18
+ runStandalone?(ctx: ToolAdapterContext): Promise<{
19
+ findings: Finding[];
20
+ status?: ToolResult;
21
+ }>;
22
+ installHint: string;
23
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const tscAdapter: ToolAdapter;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tscAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ const TSC_PATTERN = /^(?<file>.+?)\((?<line>\d+),(?<column>\d+)\): error (?<code>TS\d+): (?<message>.+)$/gm;
6
+ function parseTsc(stdout, stderr) {
7
+ const text = `${stdout}\n${stderr}`;
8
+ const matches = [];
9
+ for (const match of text.matchAll(TSC_PATTERN)) {
10
+ if (!match.groups) {
11
+ continue;
12
+ }
13
+ matches.push(match.groups);
14
+ }
15
+ return matches;
16
+ }
17
+ function mapSeverity(code) {
18
+ if (/TS2307|TS2322|TS2554|TS7006/.test(code)) {
19
+ return "high";
20
+ }
21
+ return "medium";
22
+ }
23
+ exports.tscAdapter = {
24
+ id: "tsc",
25
+ category: "correctness",
26
+ async detect(project) {
27
+ return project.languages.includes("typescript");
28
+ },
29
+ buildScanCommand(ctx) {
30
+ return {
31
+ cmd: "tsc",
32
+ args: ["--noEmit", "--pretty", "false"],
33
+ cwd: ctx.root,
34
+ timeoutMs: 90_000
35
+ };
36
+ },
37
+ parseResult(result, ctx) {
38
+ return parseTsc(result.stdout, result.stderr).map((item) => ({
39
+ id: `tsc:${item.file}:${item.line}:${item.code}`,
40
+ source: "tsc",
41
+ category: "correctness",
42
+ severity: mapSeverity(item.code),
43
+ confidence: "high",
44
+ title: item.code,
45
+ message: item.message,
46
+ file: (0, finding_1.normalizeFilePath)(item.file, ctx.root),
47
+ startLine: Number(item.line),
48
+ isNew: true,
49
+ isAutofixable: false,
50
+ safeToAutofix: false,
51
+ agentInstruction: "Fix the type error without changing public behavior unless required.",
52
+ tags: ["typescript", "types"],
53
+ scoreImpact: 0
54
+ }));
55
+ },
56
+ installHint: "Install TypeScript with: npm install -D typescript"
57
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const vitestAdapter: ToolAdapter;
@@ -0,0 +1,62 @@
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.vitestAdapter = void 0;
7
+ const node_fs_1 = require("node:fs");
8
+ const node_os_1 = __importDefault(require("node:os"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const paths_1 = require("../core/paths");
11
+ const toolRunner_1 = require("../core/toolRunner");
12
+ async function readCoverageSummary(filePath) {
13
+ if (!(await (0, paths_1.pathExists)(filePath))) {
14
+ return undefined;
15
+ }
16
+ const parsed = JSON.parse(await node_fs_1.promises.readFile(filePath, "utf8"));
17
+ return parsed.total?.lines?.pct;
18
+ }
19
+ exports.vitestAdapter = {
20
+ id: "vitest",
21
+ category: "tests",
22
+ async detect(project) {
23
+ return project.frameworkHints.includes("vitest") || project.testCommands.some((command) => /vitest/i.test(command));
24
+ },
25
+ async runStandalone(ctx) {
26
+ const existingSummary = node_path_1.default.join(ctx.root, "coverage", "coverage-summary.json");
27
+ let percent = await readCoverageSummary(existingSummary);
28
+ let status;
29
+ if (percent === undefined) {
30
+ const outputDir = node_path_1.default.join(node_os_1.default.tmpdir(), `vibedoctor-vitest-${Date.now()}`);
31
+ status = await (0, toolRunner_1.runCommand)({
32
+ cmd: "vitest",
33
+ args: ["run", "--coverage.enabled=true", "--coverage.reporter=json-summary", `--coverage.reportsDirectory=${outputDir}`],
34
+ cwd: ctx.root,
35
+ timeoutMs: 180_000
36
+ }, "Install Vitest with: npm install -D vitest @vitest/coverage-v8");
37
+ percent = await readCoverageSummary(node_path_1.default.join(outputDir, "coverage-summary.json"));
38
+ await node_fs_1.promises.rm(outputDir, { recursive: true, force: true }).catch(() => undefined);
39
+ }
40
+ const findings = typeof percent === "number" && percent < ctx.config.checks.tests.minCoverage
41
+ ? [
42
+ {
43
+ id: "vitest:coverage",
44
+ source: "vitest",
45
+ category: "tests",
46
+ severity: percent < ctx.config.checks.tests.minCoverage / 2 ? "high" : "medium",
47
+ confidence: "high",
48
+ title: "JS/TS coverage below target",
49
+ message: `Coverage is ${percent}% which is below the configured minimum of ${ctx.config.checks.tests.minCoverage}%.`,
50
+ isNew: true,
51
+ isAutofixable: false,
52
+ safeToAutofix: false,
53
+ agentInstruction: "Add or expand Vitest coverage before larger refactors.",
54
+ tags: ["javascript", "typescript", "coverage"],
55
+ scoreImpact: 0
56
+ }
57
+ ]
58
+ : [];
59
+ return { findings, status };
60
+ },
61
+ installHint: "Install Vitest with: npm install -D vitest @vitest/coverage-v8"
62
+ };
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const vultureAdapter: ToolAdapter;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.vultureAdapter = void 0;
4
+ const finding_1 = require("../core/finding");
5
+ function parseVulture(stdout) {
6
+ const trimmed = stdout.trim();
7
+ return trimmed ? JSON.parse(trimmed) : [];
8
+ }
9
+ function isPackageInitializer(file) {
10
+ return file.replaceAll("\\", "/").endsWith("/__init__.py") || file === "__init__.py";
11
+ }
12
+ exports.vultureAdapter = {
13
+ id: "vulture",
14
+ category: "dead_code",
15
+ async detect(project) {
16
+ return project.languages.includes("python");
17
+ },
18
+ buildScanCommand(ctx) {
19
+ return {
20
+ cmd: "vulture",
21
+ args: [".", "--json"],
22
+ cwd: ctx.root,
23
+ timeoutMs: 60_000
24
+ };
25
+ },
26
+ parseResult(result, ctx) {
27
+ return parseVulture(result.stdout).map((item) => {
28
+ const packageInitializer = isPackageInitializer(item.filename);
29
+ return {
30
+ id: `vulture:${item.filename}:${item.first_lineno}:${item.name}`,
31
+ source: "vulture",
32
+ category: "dead_code",
33
+ severity: "low",
34
+ confidence: packageInitializer
35
+ ? "low"
36
+ : (item.confidence ?? 60) >= 90
37
+ ? "high"
38
+ : (item.confidence ?? 60) >= 70
39
+ ? "medium"
40
+ : "low",
41
+ title: packageInitializer ? `Review package initializer ${item.type}` : `Unused ${item.type}`,
42
+ message: packageInitializer
43
+ ? `${item.name} is in a package initializer and needs manual review before removal.`
44
+ : `${item.name} appears unused according to Vulture.`,
45
+ file: (0, finding_1.normalizeFilePath)(item.filename, ctx.root),
46
+ startLine: item.first_lineno,
47
+ isNew: true,
48
+ isAutofixable: false,
49
+ safeToAutofix: false,
50
+ agentInstruction: packageInitializer
51
+ ? "Review this package initializer manually; verify imports, package exports, and framework discovery before changing it."
52
+ : "Treat this as advisory for Python: verify decorators, reflection, and framework registration before deletion.",
53
+ tags: packageInitializer ? ["python", "dead-code", "review-only"] : ["python", "dead-code"],
54
+ scoreImpact: 0
55
+ };
56
+ });
57
+ },
58
+ installHint: "Install Vulture with: pipx install vulture or uv tool install vulture"
59
+ };
@@ -0,0 +1,48 @@
1
+ export declare const AGENT_TARGETS: readonly ["codex", "copilot", "claude", "cursor"];
2
+ export type AgentTarget = (typeof AGENT_TARGETS)[number];
3
+ export type AgentPackManifest = {
4
+ version: number;
5
+ generatedBy: string;
6
+ generatedAt: string;
7
+ targets: AgentTarget[];
8
+ skills: string[];
9
+ files: {
10
+ agents: string;
11
+ canonicalSkillDir: string;
12
+ policy: string;
13
+ manifest: string;
14
+ shims: Partial<Record<AgentTarget, string[]>>;
15
+ };
16
+ };
17
+ export type AgentPackApplyResult = {
18
+ created: string[];
19
+ updated: string[];
20
+ skipped: string[];
21
+ };
22
+ export type AgentPackDoctorItem = {
23
+ status: "ok" | "warn";
24
+ message: string;
25
+ };
26
+ export type AgentPackDoctorResult = {
27
+ ok: boolean;
28
+ items: AgentPackDoctorItem[];
29
+ };
30
+ export declare function loadAgentPackManifest(root: string): Promise<AgentPackManifest | undefined>;
31
+ export declare function parseAgentTargets(value: string | undefined, defaultTargets?: AgentTarget[]): AgentTarget[];
32
+ export declare function generateCanonicalAgentPack(root: string, options: {
33
+ targets: AgentTarget[];
34
+ force?: boolean;
35
+ }): Promise<AgentPackApplyResult>;
36
+ export declare function syncAgentPack(root: string, options: {
37
+ targets: AgentTarget[];
38
+ force?: boolean;
39
+ }): Promise<AgentPackApplyResult>;
40
+ export declare function initAgentPack(root: string, options: {
41
+ targets: AgentTarget[];
42
+ force?: boolean;
43
+ }): Promise<AgentPackApplyResult>;
44
+ export declare function packAgentPack(root: string, options?: {
45
+ targets?: AgentTarget[];
46
+ force?: boolean;
47
+ }): Promise<AgentPackApplyResult>;
48
+ export declare function doctorAgentPack(root: string, targets?: AgentTarget[]): Promise<AgentPackDoctorResult>;