@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.
- package/README.md +17 -1
- package/dist/adapters/biome.d.ts +1 -1
- package/dist/adapters/biome.js +7 -4
- package/dist/adapters/coveragePy.js +3 -0
- package/dist/adapters/deptry.js +21 -2
- package/dist/adapters/knip.js +29 -4
- package/dist/adapters/lizard.d.ts +1 -1
- package/dist/adapters/lizard.js +51 -2
- package/dist/adapters/osvScanner.js +14 -2
- package/dist/adapters/privacyDetector.js +5 -5
- package/dist/adapters/ruff.d.ts +1 -1
- package/dist/adapters/ruff.js +4 -1
- package/dist/adapters/semgrep.d.ts +1 -1
- package/dist/adapters/semgrep.js +17 -3
- package/dist/adapters/shared.d.ts +1 -0
- package/dist/adapters/shared.js +22 -0
- package/dist/adapters/tsc.js +43 -18
- package/dist/adapters/vulture.d.ts +1 -1
- package/dist/adapters/vulture.js +25 -6
- package/dist/agentPack/templates/index.js +7 -4
- package/dist/agentPack/templates/skills.js +10 -4
- package/dist/cli/commands/agentPlan.js +9 -1
- package/dist/cli/commands/init.js +12 -4
- package/dist/cli/commands/scan.d.ts +1 -1
- package/dist/cli/commands/scan.js +4 -0
- package/dist/cli/commands/setup.js +3 -1
- package/dist/cli/commands/tool.d.ts +4 -0
- package/dist/cli/commands/tool.js +11 -0
- package/dist/cli/index.js +12 -0
- package/dist/core/config.d.ts +6 -0
- package/dist/core/config.js +29 -1
- package/dist/core/engine.d.ts +32 -1
- package/dist/core/engine.js +173 -27
- package/dist/core/projectDetector.d.ts +1 -1
- package/dist/core/projectDetector.js +29 -12
- package/dist/core/toolRunner.d.ts +1 -0
- package/dist/core/toolRunner.js +73 -11
- package/dist/mcp/tools/shared.js +8 -1
- package/dist/reporters/agent.js +8 -0
- package/dist/reporters/html.js +4 -2
- package/dist/reporters/json.js +2 -0
- package/dist/reporters/markdown.js +8 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ vibedoctor scan --full
|
|
|
34
34
|
- It focuses on the failure modes AI-heavy repos accumulate: dead branches, stale fallbacks, leftovers, weak coverage, and accidental sensitive-data exposure.
|
|
35
35
|
- It collapses many tool results into one finding model, one score, and a ranked fix list instead of a wall of unrelated warnings.
|
|
36
36
|
- It is agent-native without locking you into a hosted service: reports stay local and output remains plain JSON, HTML, Markdown, and SARIF.
|
|
37
|
+
- It tells agents whether a scan is complete, provides exact recovery commands for failed tools, and prevents partial scores from masquerading as authoritative health checks.
|
|
37
38
|
|
|
38
39
|
## What VibeDoctor Checks
|
|
39
40
|
|
|
@@ -70,9 +71,24 @@ VibeDoctor prefers repository-local tools and config so the scan matches the ver
|
|
|
70
71
|
| Create a baseline | `vibedoctor baseline create` |
|
|
71
72
|
| Explain a finding | `vibedoctor explain <finding-id>` |
|
|
72
73
|
| Verify after edits | `vibedoctor verify` |
|
|
74
|
+
| Retry a timed-out scanner | `vibedoctor tool retry <tool-id> [--timeout 600]` |
|
|
73
75
|
| Generate an agent repair plan | `vibedoctor agent-plan --format markdown` |
|
|
74
76
|
|
|
75
|
-
`scan` and `verify` return
|
|
77
|
+
`scan` and `verify` return exit code `1` when completed health gates fail and exit code `2` when required checks are incomplete. Reports label incomplete scores as `PARTIAL` or `INVALID` and include machine-readable `recoveryActions`.
|
|
78
|
+
|
|
79
|
+
Timeouts and required checks are configurable:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
runtime:
|
|
83
|
+
default_timeout_seconds: 120
|
|
84
|
+
tool_timeouts:
|
|
85
|
+
biome: 180
|
|
86
|
+
semgrep: 300
|
|
87
|
+
required_tools:
|
|
88
|
+
- biome
|
|
89
|
+
- semgrep
|
|
90
|
+
fail_on_incomplete_scan: true
|
|
91
|
+
```
|
|
76
92
|
|
|
77
93
|
## Privacy Review
|
|
78
94
|
|
package/dist/adapters/biome.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolAdapter } from "./shared";
|
|
2
2
|
export declare const biomeAdapter: ToolAdapter;
|
package/dist/adapters/biome.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.biomeAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
5
6
|
function parseBiomeOutput(stdout) {
|
|
6
7
|
const trimmed = stdout.trim();
|
|
7
8
|
if (!trimmed) {
|
|
@@ -26,11 +27,12 @@ exports.biomeAdapter = {
|
|
|
26
27
|
return project.languages.includes("javascript") || project.languages.includes("typescript");
|
|
27
28
|
},
|
|
28
29
|
buildScanCommand(ctx) {
|
|
30
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.(?:js|jsx|ts|tsx|json|jsonc)$/i);
|
|
29
31
|
return {
|
|
30
32
|
cmd: "biome",
|
|
31
|
-
args: ["check",
|
|
33
|
+
args: ["check", ...targets, "--reporter=json"],
|
|
32
34
|
cwd: ctx.root,
|
|
33
|
-
timeoutMs:
|
|
35
|
+
timeoutMs: 180_000
|
|
34
36
|
};
|
|
35
37
|
},
|
|
36
38
|
parseResult(result, ctx) {
|
|
@@ -55,11 +57,12 @@ exports.biomeAdapter = {
|
|
|
55
57
|
}));
|
|
56
58
|
},
|
|
57
59
|
buildFixCommand(ctx) {
|
|
60
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.(?:js|jsx|ts|tsx|json|jsonc)$/i);
|
|
58
61
|
return {
|
|
59
62
|
cmd: "biome",
|
|
60
|
-
args: ["check",
|
|
63
|
+
args: ["check", ...targets, "--write"],
|
|
61
64
|
cwd: ctx.root,
|
|
62
|
-
timeoutMs:
|
|
65
|
+
timeoutMs: 180_000
|
|
63
66
|
};
|
|
64
67
|
},
|
|
65
68
|
installHint: "Install Biome with: npm install -D @biomejs/biome"
|
|
@@ -46,6 +46,9 @@ exports.coveragePyAdapter = {
|
|
|
46
46
|
}
|
|
47
47
|
catch {
|
|
48
48
|
findings = [];
|
|
49
|
+
if (/no data to report|no coverage data/i.test(`${status.stderr}\n${status.stdout}`)) {
|
|
50
|
+
status.status = "skipped";
|
|
51
|
+
}
|
|
49
52
|
}
|
|
50
53
|
finally {
|
|
51
54
|
await node_fs_1.promises.rm(reportFile, { force: true }).catch(() => undefined);
|
package/dist/adapters/deptry.js
CHANGED
|
@@ -19,13 +19,32 @@ exports.deptryAdapter = {
|
|
|
19
19
|
return project.languages.includes("python");
|
|
20
20
|
},
|
|
21
21
|
async runStandalone(ctx) {
|
|
22
|
+
const manifestFile = ctx.project.projectFiles.find((f) => /(^|\/)(pyproject\.toml|requirements\.txt|setup\.py|Pipfile)$/i.test(f));
|
|
23
|
+
if (!manifestFile) {
|
|
24
|
+
return {
|
|
25
|
+
findings: [],
|
|
26
|
+
status: {
|
|
27
|
+
command: "deptry",
|
|
28
|
+
stdout: "",
|
|
29
|
+
stderr: "No Python dependency specification file (pyproject.toml, requirements.txt, setup.py) found.",
|
|
30
|
+
exitCode: null,
|
|
31
|
+
durationMs: 0,
|
|
32
|
+
status: "skipped",
|
|
33
|
+
installHint: exports.deptryAdapter.installHint
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const workingDir = node_path_1.default.dirname(manifestFile) === "." ? ctx.root : node_path_1.default.join(ctx.root, node_path_1.default.dirname(manifestFile));
|
|
22
38
|
const tempPath = node_path_1.default.join(node_os_1.default.tmpdir(), `vibedoctor-deptry-${Date.now()}.json`);
|
|
23
39
|
const status = await (0, toolRunner_1.runCommand)({
|
|
24
40
|
cmd: "deptry",
|
|
25
41
|
args: [".", "--json-output", tempPath],
|
|
26
|
-
cwd:
|
|
42
|
+
cwd: workingDir,
|
|
27
43
|
timeoutMs: 90_000
|
|
28
44
|
}, "Install deptry with: pipx install deptry or uv tool install deptry");
|
|
45
|
+
if (status.status === "error" && /DependencySpecificationNotFoundError|no pyproject\.toml/i.test(`${status.stderr}\n${status.stdout}`)) {
|
|
46
|
+
status.status = "skipped";
|
|
47
|
+
}
|
|
29
48
|
let findings = [];
|
|
30
49
|
try {
|
|
31
50
|
const content = await node_fs_1.promises.readFile(tempPath, "utf8");
|
|
@@ -37,7 +56,7 @@ exports.deptryAdapter = {
|
|
|
37
56
|
confidence: "high",
|
|
38
57
|
title: item.error.code,
|
|
39
58
|
message: item.error.message,
|
|
40
|
-
file: (0, finding_1.normalizeFilePath)(item.location?.file, ctx.root),
|
|
59
|
+
file: (0, finding_1.normalizeFilePath)(item.location?.file ? node_path_1.default.join(node_path_1.default.dirname(manifestFile), item.location.file) : undefined, ctx.root),
|
|
41
60
|
startLine: item.location?.line,
|
|
42
61
|
isNew: true,
|
|
43
62
|
isAutofixable: false,
|
package/dist/adapters/knip.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.knipAdapter = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
4
8
|
const finding_1 = require("../core/finding");
|
|
5
9
|
function parseKnip(stdout) {
|
|
6
|
-
|
|
10
|
+
const trimmed = stdout.trim();
|
|
11
|
+
return trimmed && trimmed.startsWith("{") ? JSON.parse(trimmed) : {};
|
|
12
|
+
}
|
|
13
|
+
function findPackageJsonPath(projectFiles) {
|
|
14
|
+
if (projectFiles.includes("package.json")) {
|
|
15
|
+
return "package.json";
|
|
16
|
+
}
|
|
17
|
+
return projectFiles.find((f) => f.endsWith("/package.json"));
|
|
7
18
|
}
|
|
8
19
|
exports.knipAdapter = {
|
|
9
20
|
id: "knip",
|
|
@@ -12,14 +23,28 @@ exports.knipAdapter = {
|
|
|
12
23
|
return project.languages.includes("javascript") || project.languages.includes("typescript");
|
|
13
24
|
},
|
|
14
25
|
buildScanCommand(ctx) {
|
|
26
|
+
const packageJsonPath = findPackageJsonPath(ctx.project.projectFiles);
|
|
27
|
+
const cwd = packageJsonPath && node_path_1.default.dirname(packageJsonPath) !== "." ? node_path_1.default.join(ctx.root, node_path_1.default.dirname(packageJsonPath)) : ctx.root;
|
|
15
28
|
return {
|
|
16
29
|
cmd: "knip",
|
|
17
30
|
args: ["--reporter", "json"],
|
|
18
|
-
cwd
|
|
31
|
+
cwd,
|
|
19
32
|
timeoutMs: 60_000
|
|
20
33
|
};
|
|
21
34
|
},
|
|
22
35
|
parseResult(result, ctx) {
|
|
36
|
+
const output = `${result.stdout}\n${result.stderr}`;
|
|
37
|
+
if (/styleText|ERR_UNKNOWN_BUILTIN_MODULE|SyntaxError.*styleText/i.test(output)) {
|
|
38
|
+
result.status = "skipped";
|
|
39
|
+
result.installHint = "Knip 5+ requires Node >= 20.19. Please upgrade Node.js to run Knip.";
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
if (result.exitCode !== 0 && /Could not find package\.json|ENOENT.*package\.json/i.test(output)) {
|
|
43
|
+
result.status = "skipped";
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const packageJsonPath = findPackageJsonPath(ctx.project.projectFiles);
|
|
47
|
+
const prefix = packageJsonPath && node_path_1.default.dirname(packageJsonPath) !== "." ? node_path_1.default.dirname(packageJsonPath) : "";
|
|
23
48
|
const parsed = parseKnip(result.stdout);
|
|
24
49
|
const fileFindings = (parsed.unusedFiles ?? []).map((file) => ({
|
|
25
50
|
id: `knip:file:${file}`,
|
|
@@ -29,7 +54,7 @@ exports.knipAdapter = {
|
|
|
29
54
|
confidence: "high",
|
|
30
55
|
title: "Unused file",
|
|
31
56
|
message: `${file} is not reachable from detected entrypoints.`,
|
|
32
|
-
file: (0, finding_1.normalizeFilePath)(file, ctx.root),
|
|
57
|
+
file: (0, finding_1.normalizeFilePath)(prefix ? node_path_1.default.join(prefix, file) : file, ctx.root),
|
|
33
58
|
isNew: true,
|
|
34
59
|
isAutofixable: false,
|
|
35
60
|
safeToAutofix: false,
|
|
@@ -45,7 +70,7 @@ exports.knipAdapter = {
|
|
|
45
70
|
confidence: "high",
|
|
46
71
|
title: "Unused export",
|
|
47
72
|
message: `${item.symbol ?? "Export"} appears unused.`,
|
|
48
|
-
file: (0, finding_1.normalizeFilePath)(item.file, ctx.root),
|
|
73
|
+
file: (0, finding_1.normalizeFilePath)(item.file ? (prefix ? node_path_1.default.join(prefix, item.file) : item.file) : undefined, ctx.root),
|
|
49
74
|
startLine: item.line,
|
|
50
75
|
isNew: true,
|
|
51
76
|
isAutofixable: false,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolAdapter } from "./shared";
|
|
2
2
|
export declare const lizardAdapter: ToolAdapter;
|
package/dist/adapters/lizard.js
CHANGED
|
@@ -2,8 +2,51 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lizardAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
function parseCsvLine(line) {
|
|
7
|
+
const values = [];
|
|
8
|
+
let value = "";
|
|
9
|
+
let quoted = false;
|
|
10
|
+
for (let index = 0; index < line.length; index += 1) {
|
|
11
|
+
const character = line[index];
|
|
12
|
+
if (character === '"') {
|
|
13
|
+
if (quoted && line[index + 1] === '"') {
|
|
14
|
+
value += '"';
|
|
15
|
+
index += 1;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
quoted = !quoted;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else if (character === "," && !quoted) {
|
|
22
|
+
values.push(value);
|
|
23
|
+
value = "";
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
value += character;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
values.push(value);
|
|
30
|
+
return values;
|
|
31
|
+
}
|
|
5
32
|
function parseLizard(stdout) {
|
|
6
|
-
|
|
33
|
+
const files = new Map();
|
|
34
|
+
for (const line of stdout.split(/\r?\n/).filter(Boolean)) {
|
|
35
|
+
const columns = parseCsvLine(line);
|
|
36
|
+
if (columns.length < 11) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const filename = columns[6];
|
|
40
|
+
const functions = files.get(filename) ?? [];
|
|
41
|
+
functions.push({
|
|
42
|
+
name: columns[7],
|
|
43
|
+
start_line: Number(columns[9]),
|
|
44
|
+
end_line: Number(columns[10]),
|
|
45
|
+
cyclomatic_complexity: Number(columns[1])
|
|
46
|
+
});
|
|
47
|
+
files.set(filename, functions);
|
|
48
|
+
}
|
|
49
|
+
return Array.from(files, ([filename, function_list]) => ({ filename, function_list }));
|
|
7
50
|
}
|
|
8
51
|
exports.lizardAdapter = {
|
|
9
52
|
id: "lizard",
|
|
@@ -12,9 +55,15 @@ exports.lizardAdapter = {
|
|
|
12
55
|
return project.languages.length > 0;
|
|
13
56
|
},
|
|
14
57
|
buildScanCommand(ctx) {
|
|
58
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.(?:js|jsx|ts|tsx|py)$/i);
|
|
15
59
|
return {
|
|
16
60
|
cmd: "lizard",
|
|
17
|
-
args: [
|
|
61
|
+
args: [
|
|
62
|
+
"--csv",
|
|
63
|
+
"--ignore_warnings",
|
|
64
|
+
"-1",
|
|
65
|
+
...targets
|
|
66
|
+
],
|
|
18
67
|
cwd: ctx.root,
|
|
19
68
|
timeoutMs: 120_000
|
|
20
69
|
};
|
|
@@ -21,6 +21,10 @@ function parseOsv(stdout) {
|
|
|
21
21
|
return findings;
|
|
22
22
|
}
|
|
23
23
|
function severityFromCvss(item) {
|
|
24
|
+
const namedSeverity = item.database_specific?.severity?.toLowerCase();
|
|
25
|
+
if (namedSeverity === "critical" || namedSeverity === "high" || namedSeverity === "medium" || namedSeverity === "low") {
|
|
26
|
+
return namedSeverity;
|
|
27
|
+
}
|
|
24
28
|
const score = Number(item.severity?.[0]?.score ?? 0);
|
|
25
29
|
if (score >= 9) {
|
|
26
30
|
return "critical";
|
|
@@ -42,14 +46,22 @@ exports.osvScannerAdapter = {
|
|
|
42
46
|
buildScanCommand(ctx) {
|
|
43
47
|
return {
|
|
44
48
|
cmd: "osv-scanner",
|
|
45
|
-
args: [
|
|
49
|
+
args: [
|
|
50
|
+
"scan",
|
|
51
|
+
"source",
|
|
52
|
+
...ctx.project.lockfiles.flatMap((lockfile) => ["--lockfile", lockfile]),
|
|
53
|
+
"--format",
|
|
54
|
+
"json",
|
|
55
|
+
"--verbosity",
|
|
56
|
+
"error"
|
|
57
|
+
],
|
|
46
58
|
cwd: ctx.root,
|
|
47
59
|
timeoutMs: 60_000
|
|
48
60
|
};
|
|
49
61
|
},
|
|
50
62
|
parseResult(result) {
|
|
51
63
|
return parseOsv(result.stdout).map((item, index) => ({
|
|
52
|
-
id: `osv:${item.package?.name}:${item.id ?? index}`,
|
|
64
|
+
id: `osv:${item.package?.name}:${item.package?.version ?? "unknown"}:${item.id ?? index}`,
|
|
53
65
|
source: "osv-scanner",
|
|
54
66
|
category: "dependencies",
|
|
55
67
|
severity: severityFromCvss(item),
|
|
@@ -200,7 +200,7 @@ function fieldEntity(field) {
|
|
|
200
200
|
if (/aadhaar|aadhar|uidai/.test(normalized)) {
|
|
201
201
|
return { entityType: "aadhaar", sensitivity: "regulated_identifier", confidenceScore: 0.82, matchedPattern: "aadhaar-field", reasons: [reason] };
|
|
202
202
|
}
|
|
203
|
-
if (
|
|
203
|
+
if (/^(?:permanentaccountnumber|pan(?:number|no|card)?)$/.test(normalized)) {
|
|
204
204
|
return { entityType: "pan", sensitivity: "regulated_identifier", confidenceScore: 0.82, matchedPattern: "pan-field", reasons: [reason] };
|
|
205
205
|
}
|
|
206
206
|
if (/passport/.test(normalized)) {
|
|
@@ -378,16 +378,16 @@ function combinationRisk(file, fields) {
|
|
|
378
378
|
const groups = new Map();
|
|
379
379
|
for (const field of fields) {
|
|
380
380
|
const normalized = field.normalized;
|
|
381
|
-
if (
|
|
381
|
+
if (/^(?:age|dob|dateofbirth|birthdate|userage|customerage|employeeage|patientage)$/.test(normalized)) {
|
|
382
382
|
groups.set("age_or_dob", [...(groups.get("age_or_dob") ?? []), field.field]);
|
|
383
383
|
}
|
|
384
|
-
if (
|
|
384
|
+
if (/^(?:gender|sex|usergender|customergender|employeegender|patientgender)$/.test(normalized)) {
|
|
385
385
|
groups.set("gender", [...(groups.get("gender") ?? []), field.field]);
|
|
386
386
|
}
|
|
387
|
-
if (
|
|
387
|
+
if (/^(?:location|site|city|branch|address|latitude|longitude|gps|userlocation|customerlocation|employeelocation|patientlocation)$/.test(normalized)) {
|
|
388
388
|
groups.set("location", [...(groups.get("location") ?? []), field.field]);
|
|
389
389
|
}
|
|
390
|
-
if (
|
|
390
|
+
if (/^(?:designation|role|title|department|team|job|jobtitle|employeerole|employeedepartment)$/.test(normalized)) {
|
|
391
391
|
groups.set("role_or_department", [...(groups.get("role_or_department") ?? []), field.field]);
|
|
392
392
|
}
|
|
393
393
|
}
|
package/dist/adapters/ruff.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolAdapter } from "./shared";
|
|
2
2
|
export declare const ruffAdapter: ToolAdapter;
|
package/dist/adapters/ruff.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ruffAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
5
6
|
function parseRuffOutput(stdout) {
|
|
6
7
|
const trimmed = stdout.trim();
|
|
7
8
|
if (!trimmed) {
|
|
@@ -25,9 +26,11 @@ exports.ruffAdapter = {
|
|
|
25
26
|
return project.languages.includes("python");
|
|
26
27
|
},
|
|
27
28
|
buildScanCommand(ctx) {
|
|
29
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.py$/i);
|
|
30
|
+
const excludePatterns = ctx.config.paths.exclude.length > 0 ? ["--exclude", ctx.config.paths.exclude.join(",")] : [];
|
|
28
31
|
return {
|
|
29
32
|
cmd: "ruff",
|
|
30
|
-
args: ["check",
|
|
33
|
+
args: ["check", ...targets, "--output-format", "json", ...excludePatterns],
|
|
31
34
|
cwd: ctx.root,
|
|
32
35
|
timeoutMs: 60_000
|
|
33
36
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolAdapter } from "./shared";
|
|
2
2
|
export declare const semgrepAdapter: ToolAdapter;
|
package/dist/adapters/semgrep.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.semgrepAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
|
+
const toolRunner_1 = require("../core/toolRunner");
|
|
6
|
+
const shared_1 = require("./shared");
|
|
5
7
|
function parseSemgrep(stdout) {
|
|
6
8
|
return stdout.trim() ? JSON.parse(stdout) : {};
|
|
7
9
|
}
|
|
@@ -30,11 +32,23 @@ exports.semgrepAdapter = {
|
|
|
30
32
|
return project.languages.length > 0;
|
|
31
33
|
},
|
|
32
34
|
buildScanCommand(ctx) {
|
|
35
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.(?:js|jsx|ts|tsx|py)$/i);
|
|
36
|
+
// The Semgrep Windows launcher expands wildcard arguments before handing
|
|
37
|
+
// them to pysemgrep. Calling pysemgrep directly preserves exclude globs,
|
|
38
|
+
// but fall back to the regular launcher when only "semgrep" is installed.
|
|
39
|
+
const useDirectEntryPoint = process.platform === "win32" && (0, toolRunner_1.commandExistsOnWindowsPath)("pysemgrep", ctx.root);
|
|
33
40
|
return {
|
|
34
|
-
cmd: "semgrep",
|
|
35
|
-
args: [
|
|
41
|
+
cmd: useDirectEntryPoint ? "pysemgrep" : "semgrep",
|
|
42
|
+
args: [
|
|
43
|
+
"scan",
|
|
44
|
+
"--json",
|
|
45
|
+
"--no-git-ignore",
|
|
46
|
+
"--config",
|
|
47
|
+
"auto",
|
|
48
|
+
...targets
|
|
49
|
+
],
|
|
36
50
|
cwd: ctx.root,
|
|
37
|
-
timeoutMs:
|
|
51
|
+
timeoutMs: 300_000
|
|
38
52
|
};
|
|
39
53
|
},
|
|
40
54
|
parseResult(result, ctx) {
|
package/dist/adapters/shared.js
CHANGED
|
@@ -1,2 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adapterTargets = adapterTargets;
|
|
4
|
+
const paths_1 = require("../core/paths");
|
|
5
|
+
const MAX_TARGET_ARGS_LENGTH = 6_000;
|
|
6
|
+
function getTopLevelTargets(targets) {
|
|
7
|
+
const topLevels = new Set();
|
|
8
|
+
for (const target of targets) {
|
|
9
|
+
const parts = target.split("/");
|
|
10
|
+
if (parts.length > 0 && parts[0]) {
|
|
11
|
+
topLevels.add(parts[0]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const result = Array.from(topLevels).sort();
|
|
15
|
+
return result.length > 0 ? result : ["."];
|
|
16
|
+
}
|
|
17
|
+
function adapterTargets(ctx, extensionPattern) {
|
|
18
|
+
const targets = (0, paths_1.filterPaths)(ctx.project.projectFiles, ctx.config.paths.include, ctx.config.paths.exclude).filter((file) => extensionPattern.test(file));
|
|
19
|
+
if (targets.length === 0) {
|
|
20
|
+
return ["."];
|
|
21
|
+
}
|
|
22
|
+
const totalLength = targets.reduce((sum, target) => sum + target.length + 1, 0);
|
|
23
|
+
return totalLength > MAX_TARGET_ARGS_LENGTH ? getTopLevelTargets(targets) : targets;
|
|
24
|
+
}
|
package/dist/adapters/tsc.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.tscAdapter = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
4
8
|
const finding_1 = require("../core/finding");
|
|
5
9
|
const TSC_PATTERN = /^(?<file>.+?)\((?<line>\d+),(?<column>\d+)\): error (?<code>TS\d+): (?<message>.+)$/gm;
|
|
6
10
|
function parseTsc(stdout, stderr) {
|
|
@@ -20,6 +24,12 @@ function mapSeverity(code) {
|
|
|
20
24
|
}
|
|
21
25
|
return "medium";
|
|
22
26
|
}
|
|
27
|
+
function findTsconfigPath(projectFiles) {
|
|
28
|
+
if (projectFiles.includes("tsconfig.json")) {
|
|
29
|
+
return "tsconfig.json";
|
|
30
|
+
}
|
|
31
|
+
return projectFiles.find((f) => f.endsWith("/tsconfig.json"));
|
|
32
|
+
}
|
|
23
33
|
exports.tscAdapter = {
|
|
24
34
|
id: "tsc",
|
|
25
35
|
category: "correctness",
|
|
@@ -27,31 +37,46 @@ exports.tscAdapter = {
|
|
|
27
37
|
return project.languages.includes("typescript");
|
|
28
38
|
},
|
|
29
39
|
buildScanCommand(ctx) {
|
|
40
|
+
const tsconfig = findTsconfigPath(ctx.project.projectFiles);
|
|
41
|
+
const cwd = tsconfig && node_path_1.default.dirname(tsconfig) !== "." ? node_path_1.default.join(ctx.root, node_path_1.default.dirname(tsconfig)) : ctx.root;
|
|
30
42
|
return {
|
|
31
43
|
cmd: "tsc",
|
|
32
44
|
args: ["--noEmit", "--pretty", "false"],
|
|
33
|
-
cwd
|
|
45
|
+
cwd,
|
|
34
46
|
timeoutMs: 90_000
|
|
35
47
|
};
|
|
36
48
|
},
|
|
37
49
|
parseResult(result, ctx) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const output = `${result.stdout}\n${result.stderr}`;
|
|
51
|
+
const parsed = parseTsc(result.stdout, result.stderr);
|
|
52
|
+
// With no tsconfig, tsc prints CLI help and can exit successfully. That
|
|
53
|
+
// does not represent a completed type check.
|
|
54
|
+
if (/Syntax:\s*tsc|TS2304.*--help|Version \d+/i.test(output) && parsed.length === 0) {
|
|
55
|
+
result.status = "skipped";
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const tsconfig = findTsconfigPath(ctx.project.projectFiles);
|
|
59
|
+
const prefix = tsconfig && node_path_1.default.dirname(tsconfig) !== "." ? node_path_1.default.dirname(tsconfig) : "";
|
|
60
|
+
return parsed.map((item) => {
|
|
61
|
+
const fullPath = prefix ? node_path_1.default.join(prefix, item.file) : item.file;
|
|
62
|
+
return {
|
|
63
|
+
id: `tsc:${fullPath}:${item.line}:${item.code}`,
|
|
64
|
+
source: "tsc",
|
|
65
|
+
category: "correctness",
|
|
66
|
+
severity: mapSeverity(item.code),
|
|
67
|
+
confidence: "high",
|
|
68
|
+
title: item.code,
|
|
69
|
+
message: item.message,
|
|
70
|
+
file: (0, finding_1.normalizeFilePath)(fullPath, ctx.root),
|
|
71
|
+
startLine: Number(item.line),
|
|
72
|
+
isNew: true,
|
|
73
|
+
isAutofixable: false,
|
|
74
|
+
safeToAutofix: false,
|
|
75
|
+
agentInstruction: "Fix the type error without changing public behavior unless required.",
|
|
76
|
+
tags: ["typescript", "types"],
|
|
77
|
+
scoreImpact: 0
|
|
78
|
+
};
|
|
79
|
+
});
|
|
55
80
|
},
|
|
56
81
|
installHint: "Install TypeScript with: npm install -D typescript"
|
|
57
82
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ToolAdapter } from "./shared";
|
|
2
2
|
export declare const vultureAdapter: ToolAdapter;
|
package/dist/adapters/vulture.js
CHANGED
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vultureAdapter = void 0;
|
|
4
4
|
const finding_1 = require("../core/finding");
|
|
5
|
+
const shared_1 = require("./shared");
|
|
6
|
+
const VULTURE_PATTERN = /^(?<file>.+?):(?<line>\d+):\s*unused\s+(?<type>[\w\s]+)\s+'(?<name>[^']+)'(?:\s*\((?<confidence>\d+)%\s*confidence\))?/gm;
|
|
5
7
|
function parseVulture(stdout) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
+
const items = [];
|
|
9
|
+
const matches = stdout.matchAll(VULTURE_PATTERN);
|
|
10
|
+
for (const match of matches) {
|
|
11
|
+
if (!match.groups) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
items.push({
|
|
15
|
+
filename: match.groups.file,
|
|
16
|
+
first_lineno: Number(match.groups.line),
|
|
17
|
+
name: match.groups.name,
|
|
18
|
+
type: match.groups.type.trim(),
|
|
19
|
+
confidence: match.groups.confidence ? Number(match.groups.confidence) : 60
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return items;
|
|
8
23
|
}
|
|
9
24
|
function isPackageInitializer(file) {
|
|
10
25
|
return file.replaceAll("\\", "/").endsWith("/__init__.py") || file === "__init__.py";
|
|
@@ -16,15 +31,19 @@ exports.vultureAdapter = {
|
|
|
16
31
|
return project.languages.includes("python");
|
|
17
32
|
},
|
|
18
33
|
buildScanCommand(ctx) {
|
|
34
|
+
const targets = (0, shared_1.adapterTargets)(ctx, /\.py$/i);
|
|
35
|
+
const excludePatterns = ctx.config.paths.exclude.length > 0 ? ctx.config.paths.exclude.join(",") : undefined;
|
|
36
|
+
const excludeArgs = excludePatterns ? ["--exclude", excludePatterns] : [];
|
|
19
37
|
return {
|
|
20
38
|
cmd: "vulture",
|
|
21
|
-
args: [
|
|
39
|
+
args: [...targets, ...excludeArgs],
|
|
22
40
|
cwd: ctx.root,
|
|
23
41
|
timeoutMs: 60_000
|
|
24
42
|
};
|
|
25
43
|
},
|
|
26
44
|
parseResult(result, ctx) {
|
|
27
|
-
|
|
45
|
+
const text = `${result.stdout}\n${result.stderr}`;
|
|
46
|
+
return parseVulture(text).map((item) => {
|
|
28
47
|
const packageInitializer = isPackageInitializer(item.filename);
|
|
29
48
|
return {
|
|
30
49
|
id: `vulture:${item.filename}:${item.first_lineno}:${item.name}`,
|
|
@@ -33,9 +52,9 @@ exports.vultureAdapter = {
|
|
|
33
52
|
severity: "low",
|
|
34
53
|
confidence: packageInitializer
|
|
35
54
|
? "low"
|
|
36
|
-
:
|
|
55
|
+
: item.confidence >= 90
|
|
37
56
|
? "high"
|
|
38
|
-
:
|
|
57
|
+
: item.confidence >= 70
|
|
39
58
|
? "medium"
|
|
40
59
|
: "low",
|
|
41
60
|
title: packageInitializer ? `Review package initializer ${item.type}` : `Unused ${item.type}`,
|
|
@@ -18,8 +18,10 @@ Use VibeDoctor as the source of truth for code-health checks.
|
|
|
18
18
|
|
|
19
19
|
Before major edits:
|
|
20
20
|
\`\`\`bash
|
|
21
|
-
vibedoctor scan --changed --report json
|
|
22
|
-
\`\`\`
|
|
21
|
+
vibedoctor scan --changed --report json
|
|
22
|
+
\`\`\`
|
|
23
|
+
|
|
24
|
+
Read \`completeness.status\` before editing. If it is \`partial\` or \`invalid\`, run the report's \`recoveryActions\` first. Never compare a partial score with a complete score or assume a timed-out tool passed.
|
|
23
25
|
|
|
24
26
|
After edits:
|
|
25
27
|
\`\`\`bash
|
|
@@ -63,8 +65,9 @@ After each meaningful change, run the smallest relevant verification command.
|
|
|
63
65
|
At the end, report:
|
|
64
66
|
|
|
65
67
|
\`\`\`text
|
|
66
|
-
Health score:
|
|
67
|
-
|
|
68
|
+
Health score:
|
|
69
|
+
Scan completeness:
|
|
70
|
+
Commands run:
|
|
68
71
|
Files changed:
|
|
69
72
|
Remaining blockers:
|
|
70
73
|
Suggested next step:
|
|
@@ -60,9 +60,14 @@ vibedoctor scan --changed --report json
|
|
|
60
60
|
vibedoctor scan --full --report json
|
|
61
61
|
\`\`\`
|
|
62
62
|
|
|
63
|
-
3. Read \`.vibedoctor/report.json\`.
|
|
64
|
-
|
|
65
|
-
4.
|
|
63
|
+
3. Read \`.vibedoctor/report.json\`.
|
|
64
|
+
|
|
65
|
+
4. Check \`completeness.status\` before changing code:
|
|
66
|
+
- \`complete\`: the score is comparable and findings can be prioritized.
|
|
67
|
+
- \`partial\` or \`invalid\`: run every command in \`recoveryActions\` first.
|
|
68
|
+
- If recovery fails, disclose the missing coverage and request human review before risky edits.
|
|
69
|
+
|
|
70
|
+
5. Prioritize validated findings in this order:
|
|
66
71
|
- security blockers
|
|
67
72
|
- correctness blockers
|
|
68
73
|
- failing tests
|
|
@@ -79,7 +84,8 @@ Give only:
|
|
|
79
84
|
- blockers
|
|
80
85
|
- safest next command
|
|
81
86
|
- top 3 fixes
|
|
82
|
-
- whether work is safe to continue
|
|
87
|
+
- whether work is safe to continue
|
|
88
|
+
- scan completeness and any missing tool coverage
|
|
83
89
|
|
|
84
90
|
Do not paste the full JSON unless the user asks.
|
|
85
91
|
`),
|