pi-lens 3.6.2 → 3.6.4
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/CHANGELOG.md +10 -2
- package/package.json +4 -4
- package/tsconfig.json +1 -1
- package/clients/__tests__/file-time.test.js +0 -216
- package/clients/__tests__/file-time.test.ts +0 -276
- package/clients/__tests__/format-service.test.js +0 -245
- package/clients/__tests__/format-service.test.ts +0 -339
- package/clients/__tests__/formatters.test.js +0 -271
- package/clients/__tests__/formatters.test.ts +0 -401
- package/clients/agent-behavior-client.js +0 -110
- package/clients/agent-behavior-client.test.js +0 -94
- package/clients/agent-behavior-client.test.ts +0 -116
- package/clients/amain-types.js +0 -164
- package/clients/architect-client.js +0 -291
- package/clients/ast-grep-client.js +0 -253
- package/clients/ast-grep-parser.js +0 -84
- package/clients/ast-grep-rule-manager.js +0 -89
- package/clients/ast-grep-types.js +0 -9
- package/clients/auto-loop.js +0 -131
- package/clients/biome-client.js +0 -420
- package/clients/biome-client.test.js +0 -144
- package/clients/biome-client.test.ts +0 -163
- package/clients/cache/rule-cache.js +0 -72
- package/clients/cache-manager.js +0 -245
- package/clients/cache-manager.test.js +0 -197
- package/clients/cache-manager.test.ts +0 -299
- package/clients/complexity-client.js +0 -675
- package/clients/complexity-client.test.js +0 -234
- package/clients/complexity-client.test.ts +0 -255
- package/clients/config-validator.js +0 -465
- package/clients/dependency-checker.js +0 -325
- package/clients/dependency-checker.test.js +0 -60
- package/clients/dependency-checker.test.ts +0 -71
- package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
- package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
- package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
- package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
- package/clients/dispatch/debug.log +0 -1
- package/clients/dispatch/dispatcher.edge.test.js +0 -82
- package/clients/dispatch/dispatcher.edge.test.ts +0 -100
- package/clients/dispatch/dispatcher.format.test.js +0 -46
- package/clients/dispatch/dispatcher.format.test.ts +0 -58
- package/clients/dispatch/dispatcher.inline.test.js +0 -74
- package/clients/dispatch/dispatcher.inline.test.ts +0 -93
- package/clients/dispatch/dispatcher.js +0 -381
- package/clients/dispatch/dispatcher.test.js +0 -116
- package/clients/dispatch/dispatcher.test.ts +0 -149
- package/clients/dispatch/integration.js +0 -108
- package/clients/dispatch/plan.js +0 -183
- package/clients/dispatch/runners/architect.js +0 -83
- package/clients/dispatch/runners/architect.test.js +0 -138
- package/clients/dispatch/runners/architect.test.ts +0 -162
- package/clients/dispatch/runners/ast-grep-napi.js +0 -405
- package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
- package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
- package/clients/dispatch/runners/ast-grep.js +0 -157
- package/clients/dispatch/runners/biome.js +0 -55
- package/clients/dispatch/runners/config-validation.js +0 -67
- package/clients/dispatch/runners/go-vet.js +0 -48
- package/clients/dispatch/runners/index.js +0 -47
- package/clients/dispatch/runners/lsp.js +0 -102
- package/clients/dispatch/runners/oxlint.js +0 -67
- package/clients/dispatch/runners/oxlint.test.js +0 -230
- package/clients/dispatch/runners/oxlint.test.ts +0 -303
- package/clients/dispatch/runners/pyright.js +0 -100
- package/clients/dispatch/runners/pyright.test.js +0 -98
- package/clients/dispatch/runners/pyright.test.ts +0 -121
- package/clients/dispatch/runners/python-slop.js +0 -97
- package/clients/dispatch/runners/python-slop.test.js +0 -203
- package/clients/dispatch/runners/python-slop.test.ts +0 -298
- package/clients/dispatch/runners/ruff.js +0 -48
- package/clients/dispatch/runners/rust-clippy.js +0 -102
- package/clients/dispatch/runners/scan_codebase.test.js +0 -89
- package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
- package/clients/dispatch/runners/shellcheck.js +0 -147
- package/clients/dispatch/runners/shellcheck.test.js +0 -98
- package/clients/dispatch/runners/shellcheck.test.ts +0 -129
- package/clients/dispatch/runners/similarity.js +0 -230
- package/clients/dispatch/runners/spellcheck.js +0 -106
- package/clients/dispatch/runners/spellcheck.test.js +0 -158
- package/clients/dispatch/runners/spellcheck.test.ts +0 -214
- package/clients/dispatch/runners/tree-sitter.js +0 -246
- package/clients/dispatch/runners/ts-lsp.js +0 -125
- package/clients/dispatch/runners/ts-slop.js +0 -113
- package/clients/dispatch/runners/type-safety.js +0 -142
- package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
- package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
- package/clients/dispatch/runners/utils.js +0 -51
- package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
- package/clients/dispatch/types.js +0 -16
- package/clients/dispatch/utils/format-utils.js +0 -44
- package/clients/dogfood.test.js +0 -201
- package/clients/dogfood.test.ts +0 -269
- package/clients/file-kinds.js +0 -177
- package/clients/file-kinds.test.js +0 -169
- package/clients/file-kinds.test.ts +0 -210
- package/clients/file-time.js +0 -152
- package/clients/file-utils.js +0 -40
- package/clients/fix-scanners.js +0 -204
- package/clients/format-service.js +0 -184
- package/clients/formatters.js +0 -488
- package/clients/go-client.js +0 -203
- package/clients/go-client.test.js +0 -127
- package/clients/go-client.test.ts +0 -143
- package/clients/installer/index.js +0 -403
- package/clients/interviewer-templates.js +0 -75
- package/clients/interviewer.js +0 -173
- package/clients/jscpd-client.js +0 -196
- package/clients/jscpd-client.test.js +0 -127
- package/clients/jscpd-client.test.ts +0 -145
- package/clients/knip-client.js +0 -239
- package/clients/knip-client.test.js +0 -112
- package/clients/knip-client.test.ts +0 -128
- package/clients/latency-logger.js +0 -40
- package/clients/lsp/__tests__/client.test.js +0 -310
- package/clients/lsp/__tests__/client.test.ts +0 -412
- package/clients/lsp/__tests__/config.test.js +0 -167
- package/clients/lsp/__tests__/config.test.ts +0 -217
- package/clients/lsp/__tests__/error-recovery.test.js +0 -213
- package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
- package/clients/lsp/__tests__/integration.test.js +0 -127
- package/clients/lsp/__tests__/integration.test.ts +0 -160
- package/clients/lsp/__tests__/launch.test.js +0 -313
- package/clients/lsp/__tests__/launch.test.ts +0 -394
- package/clients/lsp/__tests__/server.test.js +0 -259
- package/clients/lsp/__tests__/server.test.ts +0 -332
- package/clients/lsp/__tests__/service.test.js +0 -438
- package/clients/lsp/__tests__/service.test.ts +0 -530
- package/clients/lsp/client.js +0 -350
- package/clients/lsp/config.js +0 -112
- package/clients/lsp/index.js +0 -318
- package/clients/lsp/installer/index.js +0 -391
- package/clients/lsp/interactive-install.js +0 -221
- package/clients/lsp/language.js +0 -170
- package/clients/lsp/launch.js +0 -329
- package/clients/lsp/lsp/launch.js +0 -116
- package/clients/lsp/lsp/server.js +0 -532
- package/clients/lsp/lsp-index.js +0 -10
- package/clients/lsp/path-utils.js +0 -5
- package/clients/lsp/server.js +0 -725
- package/clients/lsp/test-py-spawn/requirements.txt +0 -1
- package/clients/lsp/test-py-spawn/test.py +0 -3
- package/clients/lsp/test-py-svc/requirements.txt +0 -1
- package/clients/lsp/test-py-svc/test.py +0 -3
- package/clients/lsp/test-python-project/requirements.txt +0 -1
- package/clients/lsp/test-python-project/test.py +0 -5
- package/clients/metrics-client.js +0 -107
- package/clients/metrics-client.test.js +0 -128
- package/clients/metrics-client.test.ts +0 -163
- package/clients/metrics-history.js +0 -367
- package/clients/path-utils.js +0 -142
- package/clients/pipeline.js +0 -272
- package/clients/production-readiness.js +0 -522
- package/clients/project-index.js +0 -255
- package/clients/project-metadata.js +0 -531
- package/clients/ruff-client.js +0 -325
- package/clients/ruff-client.test.js +0 -132
- package/clients/ruff-client.test.ts +0 -153
- package/clients/rules-scanner.js +0 -97
- package/clients/runner-tracker.js +0 -152
- package/clients/rust-client.js +0 -205
- package/clients/rust-client.test.js +0 -108
- package/clients/rust-client.test.ts +0 -130
- package/clients/safe-spawn-async.js +0 -163
- package/clients/safe-spawn.js +0 -241
- package/clients/sanitize.js +0 -291
- package/clients/sanitize.test.js +0 -177
- package/clients/sanitize.test.ts +0 -223
- package/clients/scan-architectural-debt.js +0 -167
- package/clients/scan-utils.js +0 -83
- package/clients/secrets-scanner.js +0 -119
- package/clients/secrets-scanner.test.js +0 -100
- package/clients/secrets-scanner.test.ts +0 -113
- package/clients/sg-runner.js +0 -292
- package/clients/state-matrix.js +0 -160
- package/clients/subprocess-client.js +0 -65
- package/clients/symbol-types.js +0 -5
- package/clients/test-runner-client.js +0 -523
- package/clients/test-runner-client.test.js +0 -192
- package/clients/test-runner-client.test.ts +0 -253
- package/clients/test-utils.js +0 -27
- package/clients/test-utils.ts +0 -36
- package/clients/todo-scanner.js +0 -200
- package/clients/todo-scanner.test.js +0 -301
- package/clients/todo-scanner.test.ts +0 -352
- package/clients/tool-availability.js +0 -207
- package/clients/tree-sitter-client.js +0 -601
- package/clients/tree-sitter-query-loader.js +0 -355
- package/clients/tree-sitter-symbol-extractor.js +0 -289
- package/clients/ts-service.js +0 -129
- package/clients/type-coverage-client.js +0 -127
- package/clients/type-coverage-client.test.js +0 -105
- package/clients/type-coverage-client.test.ts +0 -125
- package/clients/type-safety-client.js +0 -138
- package/clients/types.js +0 -11
- package/clients/typescript-client.codefix.test.js +0 -157
- package/clients/typescript-client.codefix.test.ts +0 -186
- package/clients/typescript-client.js +0 -509
- package/clients/typescript-client.test.js +0 -105
- package/clients/typescript-client.test.ts +0 -126
- package/commands/booboo.js +0 -1007
- package/commands/fix-from-booboo.js +0 -398
- package/commands/fix-simplified.js +0 -618
- package/commands/rate.js +0 -281
- package/commands/rate.test.js +0 -119
- package/commands/rate.test.ts +0 -131
- package/commands/refactor.js +0 -130
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ast-grep runner for dispatch system
|
|
3
|
-
*
|
|
4
|
-
* Structural code analysis for detecting patterns like:
|
|
5
|
-
* - redundant state
|
|
6
|
-
* - async/await issues
|
|
7
|
-
* - security anti-patterns
|
|
8
|
-
*/
|
|
9
|
-
import * as fs from "node:fs";
|
|
10
|
-
import * as path from "node:path";
|
|
11
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
12
|
-
// Simple YAML fix: field extractor
|
|
13
|
-
function extractFixFromRule(ruleId, ruleDir) {
|
|
14
|
-
try {
|
|
15
|
-
const rulePath = `${ruleDir}/${ruleId}.yml`;
|
|
16
|
-
if (!fs.existsSync(rulePath))
|
|
17
|
-
return undefined;
|
|
18
|
-
const content = fs.readFileSync(rulePath, "utf-8");
|
|
19
|
-
const fixMatch = content.match(/^fix:\s*\|?([\s\S]*?)(?=^\w|^rule:|Z)/m);
|
|
20
|
-
if (fixMatch) {
|
|
21
|
-
return fixMatch[1]
|
|
22
|
-
.split("\n")
|
|
23
|
-
.map((line) => line.replace(/^\s*\|?\s*/, ""))
|
|
24
|
-
.filter((line) => line.length > 0)
|
|
25
|
-
.join("\n");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// Ignore errors
|
|
30
|
-
}
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
const astGrepRunner = {
|
|
34
|
-
id: "ast-grep",
|
|
35
|
-
appliesTo: ["jsts", "python", "go", "rust", "cxx"],
|
|
36
|
-
priority: 30,
|
|
37
|
-
enabledByDefault: false,
|
|
38
|
-
skipTestFiles: true, // Many rules are noisy in tests
|
|
39
|
-
async run(ctx) {
|
|
40
|
-
// Check if ast-grep is available (use npx for local installs)
|
|
41
|
-
const check = await safeSpawnAsync("npx", ["sg", "--version"], {
|
|
42
|
-
timeout: 5000,
|
|
43
|
-
});
|
|
44
|
-
if (check.error || check.status !== 0) {
|
|
45
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
46
|
-
}
|
|
47
|
-
// Find ast-grep config
|
|
48
|
-
const configPath = findAstGrepConfig(ctx.cwd);
|
|
49
|
-
if (!configPath) {
|
|
50
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
51
|
-
}
|
|
52
|
-
// Run ast-grep scan on the file (use npx for local installs)
|
|
53
|
-
const args = ["sg", "scan", "--config", configPath, "--json", ctx.filePath];
|
|
54
|
-
const result = await safeSpawnAsync("npx", args, {
|
|
55
|
-
timeout: 30000,
|
|
56
|
-
});
|
|
57
|
-
const raw = result.stdout + result.stderr;
|
|
58
|
-
if (result.status === 0 && !raw.trim()) {
|
|
59
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
60
|
-
}
|
|
61
|
-
// Parse results
|
|
62
|
-
const diagnostics = parseAstGrepOutput(raw, ctx.filePath, configPath);
|
|
63
|
-
if (diagnostics.length === 0) {
|
|
64
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
status: "failed",
|
|
68
|
-
diagnostics,
|
|
69
|
-
semantic: "warning",
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
function findAstGrepConfig(cwd) {
|
|
74
|
-
const candidates = [
|
|
75
|
-
"rules/ast-grep-rules/.sgconfig.yml",
|
|
76
|
-
".sgconfig.yml",
|
|
77
|
-
"sgconfig.yml",
|
|
78
|
-
];
|
|
79
|
-
for (const candidate of candidates) {
|
|
80
|
-
const fullPath = `${cwd}/${candidate}`;
|
|
81
|
-
if (fs.existsSync(fullPath)) {
|
|
82
|
-
return fullPath;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
function parseAstGrepOutput(raw, filePath, _configPath) {
|
|
88
|
-
const diagnostics = [];
|
|
89
|
-
// Try to parse as JSON
|
|
90
|
-
// Determine rule directory for fix: extraction
|
|
91
|
-
const ruleDir = _configPath
|
|
92
|
-
? path.dirname(_configPath).replace("/.sgconfig.yml", "/rules")
|
|
93
|
-
: path.join(process.cwd(), "rules", "ast-grep-rules", "rules");
|
|
94
|
-
try {
|
|
95
|
-
const parsed = JSON.parse(raw);
|
|
96
|
-
if (Array.isArray(parsed)) {
|
|
97
|
-
for (const item of parsed) {
|
|
98
|
-
const line = item.range?.start?.line || 1;
|
|
99
|
-
const ruleId = item.rule || "unknown";
|
|
100
|
-
// Build message with inline fix suggestion
|
|
101
|
-
let message = item.message || item.lines || "";
|
|
102
|
-
let fixSuggestion;
|
|
103
|
-
if (item.replacement) {
|
|
104
|
-
// Show the actual code change inline in the message
|
|
105
|
-
const replacementPreview = item.replacement.length > 40
|
|
106
|
-
? `${item.replacement.substring(0, 40)}...`
|
|
107
|
-
: item.replacement;
|
|
108
|
-
message += `\n💡 Suggested fix: → "${replacementPreview}"`;
|
|
109
|
-
fixSuggestion = `Replace with: ${item.replacement}`;
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
// Try to get fix: from rule YAML
|
|
113
|
-
const ruleFix = extractFixFromRule(ruleId, ruleDir);
|
|
114
|
-
if (ruleFix) {
|
|
115
|
-
const fixPreview = ruleFix.length > 60 ? `${ruleFix.substring(0, 60)}...` : ruleFix;
|
|
116
|
-
message += `\n💡 Suggested fix:\n${fixPreview}`;
|
|
117
|
-
fixSuggestion = ruleFix;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
diagnostics.push({
|
|
121
|
-
id: `ast-grep-${line}-${ruleId}`,
|
|
122
|
-
message,
|
|
123
|
-
filePath,
|
|
124
|
-
line,
|
|
125
|
-
severity: item.severity === "error" ? "error" : "warning",
|
|
126
|
-
semantic: item.severity === "error" ? "blocking" : "warning",
|
|
127
|
-
tool: "ast-grep",
|
|
128
|
-
rule: ruleId,
|
|
129
|
-
fixable: !!item.replacement || !!fixSuggestion,
|
|
130
|
-
fixSuggestion,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
// Not JSON, try line-by-line parsing
|
|
137
|
-
const lines = raw.split("\n");
|
|
138
|
-
for (const line of lines) {
|
|
139
|
-
if (line.includes(":") && line.includes("L")) {
|
|
140
|
-
const match = line.match(/L(\d+):?\s*(.+)/);
|
|
141
|
-
if (match) {
|
|
142
|
-
diagnostics.push({
|
|
143
|
-
id: `ast-grep-${match[1]}-line`,
|
|
144
|
-
message: match[2].trim(),
|
|
145
|
-
filePath,
|
|
146
|
-
line: parseInt(match[1], 10),
|
|
147
|
-
severity: "warning",
|
|
148
|
-
semantic: "warning",
|
|
149
|
-
tool: "ast-grep",
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return diagnostics;
|
|
156
|
-
}
|
|
157
|
-
export default astGrepRunner;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Biome runner for dispatch system
|
|
3
|
-
*
|
|
4
|
-
* Requires: @biomejs/biome (npm install -D @biomejs/biome)
|
|
5
|
-
*/
|
|
6
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
7
|
-
import { createBiomeParser } from "./utils/diagnostic-parsers.js";
|
|
8
|
-
import { biome } from "./utils/runner-helpers.js";
|
|
9
|
-
const biomeRunner = {
|
|
10
|
-
id: "biome-lint",
|
|
11
|
-
appliesTo: ["jsts", "json"],
|
|
12
|
-
priority: 10,
|
|
13
|
-
enabledByDefault: true,
|
|
14
|
-
async run(ctx) {
|
|
15
|
-
// Check if biome is available (via PATH, venv, or npx)
|
|
16
|
-
let cmd = biome.getCommand();
|
|
17
|
-
let useNpx = false;
|
|
18
|
-
if (!cmd || !biome.isAvailable(ctx.cwd)) {
|
|
19
|
-
// Try npx as fallback
|
|
20
|
-
const npxCheck = await safeSpawnAsync("npx", ["biome", "--version"], {
|
|
21
|
-
timeout: 5000,
|
|
22
|
-
});
|
|
23
|
-
if (!npxCheck.error && npxCheck.status === 0) {
|
|
24
|
-
cmd = "npx";
|
|
25
|
-
useNpx = true;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// IMPORTANT: Never use --write in dispatch runner to prevent infinite loops.
|
|
32
|
-
// Writing to the file would trigger another tool_result event, which would
|
|
33
|
-
// call dispatchLint again, creating a feedback loop.
|
|
34
|
-
// Auto-format handles formatting on write; this runner only checks.
|
|
35
|
-
const args = useNpx
|
|
36
|
-
? ["biome", "check", ctx.filePath]
|
|
37
|
-
: ["check", ctx.filePath];
|
|
38
|
-
const result = await safeSpawnAsync(cmd, args, {
|
|
39
|
-
timeout: 30000,
|
|
40
|
-
});
|
|
41
|
-
const output = result.stdout + result.stderr;
|
|
42
|
-
if (result.status === 0) {
|
|
43
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
44
|
-
}
|
|
45
|
-
// Parse diagnostics (never autofix in dispatch to prevent loops)
|
|
46
|
-
const parseBiomeOutput = createBiomeParser(false);
|
|
47
|
-
const diagnostics = parseBiomeOutput(output, ctx.filePath);
|
|
48
|
-
return {
|
|
49
|
-
status: "failed",
|
|
50
|
-
diagnostics,
|
|
51
|
-
semantic: "warning",
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
export default biomeRunner;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config Validation Runner
|
|
3
|
-
*
|
|
4
|
-
* Validates config/environment variable access against actual config files.
|
|
5
|
-
* Detects undefined keys, typos, and missing env vars.
|
|
6
|
-
*
|
|
7
|
-
* Uses Tree-sitter to find config access patterns in code and validates
|
|
8
|
-
* against parsed config files (.env, config.ini, config.yaml, etc.)
|
|
9
|
-
*/
|
|
10
|
-
import { createConfigValidator } from "../../config-validator.js";
|
|
11
|
-
const configValidationRunner = {
|
|
12
|
-
id: "config-validation",
|
|
13
|
-
appliesTo: ["jsts", "python", "go", "rust"],
|
|
14
|
-
priority: 8, // Run early, before other linters
|
|
15
|
-
enabledByDefault: true,
|
|
16
|
-
async run(ctx) {
|
|
17
|
-
// Only check supported file extensions
|
|
18
|
-
const ext = ctx.filePath.match(/\.(py|js|ts|tsx|go|rs)$/);
|
|
19
|
-
if (!ext) {
|
|
20
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const validator = await createConfigValidator(ctx.cwd);
|
|
24
|
-
const result = await validator.validateFile(ctx.filePath);
|
|
25
|
-
const diagnostics = [];
|
|
26
|
-
// Report undefined keys as warnings
|
|
27
|
-
for (const access of result.undefined) {
|
|
28
|
-
diagnostics.push({
|
|
29
|
-
id: `config-undefined:${access.key}`,
|
|
30
|
-
message: `Undefined config key: "${access.key}"`,
|
|
31
|
-
filePath: ctx.filePath,
|
|
32
|
-
line: access.line,
|
|
33
|
-
column: access.column,
|
|
34
|
-
severity: "warning",
|
|
35
|
-
semantic: "warning",
|
|
36
|
-
tool: "config-validation",
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
// Report typos with suggestion
|
|
40
|
-
for (const { access, suggestion } of result.typos) {
|
|
41
|
-
diagnostics.push({
|
|
42
|
-
id: `config-typo:${access.key}`,
|
|
43
|
-
message: `Possible typo: "${access.key}" — did you mean "${suggestion}"?`,
|
|
44
|
-
filePath: ctx.filePath,
|
|
45
|
-
line: access.line,
|
|
46
|
-
column: access.column,
|
|
47
|
-
severity: "warning",
|
|
48
|
-
semantic: "warning",
|
|
49
|
-
tool: "config-validation",
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (diagnostics.length === 0) {
|
|
53
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
54
|
-
}
|
|
55
|
-
return {
|
|
56
|
-
status: "failed",
|
|
57
|
-
diagnostics,
|
|
58
|
-
semantic: "warning",
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
catch (_err) {
|
|
62
|
-
// Silently fail if validator can't run (e.g., tree-sitter not available)
|
|
63
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
export default configValidationRunner;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Go vet runner for dispatch system
|
|
3
|
-
*
|
|
4
|
-
* Runs `go vet` for Go files to catch common mistakes.
|
|
5
|
-
*/
|
|
6
|
-
import { safeSpawn } from "../../safe-spawn.js";
|
|
7
|
-
import { stripAnsi } from "../../sanitize.js";
|
|
8
|
-
import { parseGoVetOutput } from "./utils/diagnostic-parsers.js";
|
|
9
|
-
const goVetRunner = {
|
|
10
|
-
id: "go-vet",
|
|
11
|
-
appliesTo: ["go"],
|
|
12
|
-
priority: 15,
|
|
13
|
-
enabledByDefault: true,
|
|
14
|
-
async run(ctx) {
|
|
15
|
-
// Check if go is available
|
|
16
|
-
const check = safeSpawn("go", ["version"], {
|
|
17
|
-
timeout: 5000,
|
|
18
|
-
});
|
|
19
|
-
if (check.error || check.status !== 0) {
|
|
20
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
21
|
-
}
|
|
22
|
-
// Run go vet on the file
|
|
23
|
-
const result = safeSpawn("go", ["vet", ctx.filePath], {
|
|
24
|
-
timeout: 30000,
|
|
25
|
-
});
|
|
26
|
-
const raw = stripAnsi(result.stdout + result.stderr);
|
|
27
|
-
if (result.status === 0 && !raw.trim()) {
|
|
28
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
29
|
-
}
|
|
30
|
-
// Parse output
|
|
31
|
-
const diagnostics = parseGoVetOutput(raw, ctx.filePath);
|
|
32
|
-
if (diagnostics.length === 0) {
|
|
33
|
-
// go vet returned non-zero but no parseable output
|
|
34
|
-
return {
|
|
35
|
-
status: "failed",
|
|
36
|
-
diagnostics: [],
|
|
37
|
-
semantic: "warning",
|
|
38
|
-
rawOutput: raw,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
status: "failed",
|
|
43
|
-
diagnostics,
|
|
44
|
-
semantic: "warning",
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
export default goVetRunner;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runner definitions for pi-lens dispatch system
|
|
3
|
-
*/
|
|
4
|
-
import { registerRunner } from "../dispatcher.js";
|
|
5
|
-
import architectRunner from "./architect.js";
|
|
6
|
-
import astGrepNapiRunner from "./ast-grep-napi.js";
|
|
7
|
-
import biomeRunner from "./biome.js";
|
|
8
|
-
import configValidationRunner from "./config-validation.js";
|
|
9
|
-
import goVetRunner from "./go-vet.js";
|
|
10
|
-
import lspRunner from "./lsp.js";
|
|
11
|
-
import oxlintRunner from "./oxlint.js";
|
|
12
|
-
import pyrightRunner from "./pyright.js";
|
|
13
|
-
import pythonSlopRunner from "./python-slop.js";
|
|
14
|
-
import ruffRunner from "./ruff.js";
|
|
15
|
-
import rustClippyRunner from "./rust-clippy.js";
|
|
16
|
-
import shellcheckRunner from "./shellcheck.js";
|
|
17
|
-
// Import similarity runner
|
|
18
|
-
import similarityRunner from "./similarity.js";
|
|
19
|
-
import spellcheckRunner from "./spellcheck.js";
|
|
20
|
-
// Import tree-sitter runner
|
|
21
|
-
import treeSitterRunner from "./tree-sitter.js";
|
|
22
|
-
import tsLspRunner from "./ts-lsp.js";
|
|
23
|
-
import tsSlopRunner from "./ts-slop.js";
|
|
24
|
-
import typeSafetyRunner from "./type-safety.js";
|
|
25
|
-
// Register all runners (ordered by priority)
|
|
26
|
-
// Unified LSP runner for all languages (TypeScript, Python, Go, Rust, etc.) - priority 4
|
|
27
|
-
registerRunner(lspRunner); // Unified LSP type-checking for all languages (priority 4)
|
|
28
|
-
registerRunner(tsLspRunner); // TypeScript type-checking (priority 5) - fallback when --lens-lsp disabled
|
|
29
|
-
registerRunner(pyrightRunner); // Python type-checking (priority 5) - fallback when --lens-lsp disabled
|
|
30
|
-
registerRunner(configValidationRunner); // Config/env validation (priority 8)
|
|
31
|
-
// DISABLED in post-write dispatch - ast-grep-napi can crash. Enabled via /lens-booboo plan only.
|
|
32
|
-
registerRunner(astGrepNapiRunner); // TS/JS structural analysis via NAPI (priority 15, post-write disabled)
|
|
33
|
-
registerRunner(biomeRunner); // Biome formatting/linting (priority 10)
|
|
34
|
-
registerRunner(oxlintRunner); // Oxlint fast JS/TS linter (priority 12)
|
|
35
|
-
registerRunner(treeSitterRunner); // Tree-sitter structural analysis (priority 14)
|
|
36
|
-
registerRunner(ruffRunner); // Python linting (priority 10)
|
|
37
|
-
registerRunner(tsSlopRunner); // DISABLED - TypeScript slop via CLI (disabled, use NAPI)
|
|
38
|
-
registerRunner(pythonSlopRunner); // Python slop via CLI (priority 25)
|
|
39
|
-
registerRunner(typeSafetyRunner); // Type safety checks (priority 20)
|
|
40
|
-
registerRunner(shellcheckRunner); // Shell script linting (priority 20)
|
|
41
|
-
// DISABLED: registerRunner(astGrepRunner); // Replaced by ast-grep-napi for dispatch
|
|
42
|
-
// CLI ast-grep kept for ast_grep_search/ast_grep_replace tools only
|
|
43
|
-
registerRunner(similarityRunner); // Semantic reuse detection (priority 35)
|
|
44
|
-
registerRunner(architectRunner); // Architectural rules (priority 40)
|
|
45
|
-
registerRunner(spellcheckRunner); // Spellcheck for markdown/docs (priority 30)
|
|
46
|
-
registerRunner(goVetRunner); // Go analysis (priority 50)
|
|
47
|
-
registerRunner(rustClippyRunner); // Rust analysis (priority 50)
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unified LSP Runner for pi-lens
|
|
3
|
-
*
|
|
4
|
-
* Handles type checking for ALL LSP-supported languages:
|
|
5
|
-
* - TypeScript/JavaScript (typescript-language-server)
|
|
6
|
-
* - Python (pyright/pylsp)
|
|
7
|
-
* - Go (gopls)
|
|
8
|
-
* - Rust (rust-analyzer)
|
|
9
|
-
* - Ruby, PHP, C#, Java, Kotlin, Swift, Dart, etc.
|
|
10
|
-
*
|
|
11
|
-
* Replaces language-specific runners (ts-lsp, pyright) with a single
|
|
12
|
-
* unified runner that delegates to the LSP service.
|
|
13
|
-
*/
|
|
14
|
-
import { getLSPService } from "../../lsp/index.js";
|
|
15
|
-
import { readFileContent } from "./utils.js";
|
|
16
|
-
const lspRunner = {
|
|
17
|
-
id: "lsp",
|
|
18
|
-
appliesTo: ["jsts", "python", "go", "rust"], // Core LSP languages
|
|
19
|
-
priority: 4, // Run before everything (even ts-lsp was priority 5)
|
|
20
|
-
enabledByDefault: true,
|
|
21
|
-
async run(ctx) {
|
|
22
|
-
// Only run if --lens-lsp flag is enabled
|
|
23
|
-
if (!ctx.pi.getFlag("lens-lsp")) {
|
|
24
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
25
|
-
}
|
|
26
|
-
const lspService = getLSPService();
|
|
27
|
-
// Check if we have LSP available for this file
|
|
28
|
-
const hasLSP = await lspService.hasLSP(ctx.filePath);
|
|
29
|
-
if (!hasLSP) {
|
|
30
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
31
|
-
}
|
|
32
|
-
// Read file content
|
|
33
|
-
const content = readFileContent(ctx.filePath);
|
|
34
|
-
if (!content) {
|
|
35
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
36
|
-
}
|
|
37
|
-
// Try to open file in LSP and get diagnostics
|
|
38
|
-
// If the server fails to spawn or crashes, this will be caught
|
|
39
|
-
let lspDiags = [];
|
|
40
|
-
let serverFailed = false;
|
|
41
|
-
let failureReason = "";
|
|
42
|
-
try {
|
|
43
|
-
await lspService.openFile(ctx.filePath, content);
|
|
44
|
-
// getDiagnostics() internally calls waitForDiagnostics() with bus
|
|
45
|
-
// subscription + 150ms debounce + 3s timeout
|
|
46
|
-
lspDiags = await lspService.getDiagnostics(ctx.filePath);
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
serverFailed = true;
|
|
50
|
-
failureReason = err instanceof Error ? err.message : String(err);
|
|
51
|
-
// Check if this is a server spawn/connection error
|
|
52
|
-
if (failureReason.includes("spawn") ||
|
|
53
|
-
failureReason.includes("exited") ||
|
|
54
|
-
failureReason.includes("connection") ||
|
|
55
|
-
failureReason.includes("JSON RPC")) {
|
|
56
|
-
// Mark this server as broken so we don't keep trying
|
|
57
|
-
console.error(`[lsp-runner] LSP server failed for ${ctx.filePath}: ${failureReason}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// If server failed to provide diagnostics, report as failed status
|
|
61
|
-
if (serverFailed) {
|
|
62
|
-
return {
|
|
63
|
-
status: "failed",
|
|
64
|
-
diagnostics: [
|
|
65
|
-
{
|
|
66
|
-
id: `lsp:server-error:0`,
|
|
67
|
-
message: `LSP server failed: ${failureReason}`,
|
|
68
|
-
filePath: ctx.filePath,
|
|
69
|
-
line: 1,
|
|
70
|
-
column: 1,
|
|
71
|
-
severity: "error",
|
|
72
|
-
semantic: "warning", // Don't block - fallback to other runners
|
|
73
|
-
tool: "lsp",
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
semantic: "warning",
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// Convert LSP diagnostics to our format
|
|
80
|
-
// Defensive: filter out malformed diagnostics that may lack range
|
|
81
|
-
const diagnostics = lspDiags
|
|
82
|
-
.filter((d) => d.range?.start?.line !== undefined)
|
|
83
|
-
.map((d) => ({
|
|
84
|
-
id: `lsp:${d.code ?? "unknown"}:${d.range.start.line}`,
|
|
85
|
-
message: d.message,
|
|
86
|
-
filePath: ctx.filePath,
|
|
87
|
-
line: d.range.start.line + 1,
|
|
88
|
-
column: d.range.start.character + 1,
|
|
89
|
-
severity: d.severity === 1 ? "error" : d.severity === 2 ? "warning" : "info",
|
|
90
|
-
semantic: d.severity === 1 ? "blocking" : "warning",
|
|
91
|
-
tool: "lsp",
|
|
92
|
-
code: String(d.code ?? ""),
|
|
93
|
-
}));
|
|
94
|
-
const hasErrors = diagnostics.some((d) => d.semantic === "blocking");
|
|
95
|
-
return {
|
|
96
|
-
status: hasErrors ? "failed" : "succeeded",
|
|
97
|
-
diagnostics,
|
|
98
|
-
semantic: hasErrors ? "blocking" : "warning",
|
|
99
|
-
};
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
export default lspRunner;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Oxlint runner for dispatch system
|
|
3
|
-
*
|
|
4
|
-
* Fast JavaScript/TypeScript linter written in Rust.
|
|
5
|
-
* Drop-in replacement for ESLint with better performance.
|
|
6
|
-
*
|
|
7
|
-
* Requires: oxlint (npm install -g oxlint)
|
|
8
|
-
*/
|
|
9
|
-
import { safeSpawnAsync } from "../../safe-spawn.js";
|
|
10
|
-
import { createAvailabilityChecker } from "./utils/runner-helpers.js";
|
|
11
|
-
const oxlint = createAvailabilityChecker("oxlint", ".exe");
|
|
12
|
-
const oxlintRunner = {
|
|
13
|
-
id: "oxlint",
|
|
14
|
-
appliesTo: ["jsts"],
|
|
15
|
-
priority: 12,
|
|
16
|
-
enabledByDefault: false, // Opt-in: may conflict with ESLint in existing projects
|
|
17
|
-
skipTestFiles: true,
|
|
18
|
-
async run(ctx) {
|
|
19
|
-
const cwd = ctx.cwd || process.cwd();
|
|
20
|
-
// Check if oxlint is available
|
|
21
|
-
if (!oxlint.isAvailable(cwd)) {
|
|
22
|
-
return { status: "skipped", diagnostics: [], semantic: "none" };
|
|
23
|
-
}
|
|
24
|
-
// Run oxlint on the file
|
|
25
|
-
const result = await safeSpawnAsync(oxlint.getCommand(), ["--format", "unix", ctx.filePath], {
|
|
26
|
-
timeout: 30000,
|
|
27
|
-
});
|
|
28
|
-
// Oxlint returns non-zero when issues found
|
|
29
|
-
if (result.status === 0) {
|
|
30
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
31
|
-
}
|
|
32
|
-
// Parse Unix format output: file:line:column: message (rule)
|
|
33
|
-
const diagnostics = parseOxlintOutput(result.stdout + result.stderr, ctx.filePath);
|
|
34
|
-
if (diagnostics.length === 0) {
|
|
35
|
-
return { status: "succeeded", diagnostics: [], semantic: "none" };
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
status: "failed",
|
|
39
|
-
diagnostics,
|
|
40
|
-
semantic: "warning",
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
function parseOxlintOutput(raw, filePath) {
|
|
45
|
-
const diagnostics = [];
|
|
46
|
-
const lines = raw.split("\n");
|
|
47
|
-
for (const line of lines) {
|
|
48
|
-
// Parse: file:line:column: message (rule)
|
|
49
|
-
// Example: src/main.ts:10:5: Unexpected console statement (no-console)
|
|
50
|
-
const match = line.match(/^(.+):(\d+):(\d+):\s*(.+?)\s*\(([^)]+)\)$/);
|
|
51
|
-
if (match) {
|
|
52
|
-
const [, _file, lineStr, _col, message, rule] = match;
|
|
53
|
-
diagnostics.push({
|
|
54
|
-
id: `oxlint-${rule}-${lineStr}`,
|
|
55
|
-
message: `${message} (${rule})`,
|
|
56
|
-
filePath,
|
|
57
|
-
line: parseInt(lineStr, 10),
|
|
58
|
-
severity: "warning",
|
|
59
|
-
semantic: "warning",
|
|
60
|
-
tool: "oxlint",
|
|
61
|
-
rule,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return diagnostics;
|
|
66
|
-
}
|
|
67
|
-
export default oxlintRunner;
|