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.
Files changed (207) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/package.json +4 -4
  3. package/tsconfig.json +1 -1
  4. package/clients/__tests__/file-time.test.js +0 -216
  5. package/clients/__tests__/file-time.test.ts +0 -276
  6. package/clients/__tests__/format-service.test.js +0 -245
  7. package/clients/__tests__/format-service.test.ts +0 -339
  8. package/clients/__tests__/formatters.test.js +0 -271
  9. package/clients/__tests__/formatters.test.ts +0 -401
  10. package/clients/agent-behavior-client.js +0 -110
  11. package/clients/agent-behavior-client.test.js +0 -94
  12. package/clients/agent-behavior-client.test.ts +0 -116
  13. package/clients/amain-types.js +0 -164
  14. package/clients/architect-client.js +0 -291
  15. package/clients/ast-grep-client.js +0 -253
  16. package/clients/ast-grep-parser.js +0 -84
  17. package/clients/ast-grep-rule-manager.js +0 -89
  18. package/clients/ast-grep-types.js +0 -9
  19. package/clients/auto-loop.js +0 -131
  20. package/clients/biome-client.js +0 -420
  21. package/clients/biome-client.test.js +0 -144
  22. package/clients/biome-client.test.ts +0 -163
  23. package/clients/cache/rule-cache.js +0 -72
  24. package/clients/cache-manager.js +0 -245
  25. package/clients/cache-manager.test.js +0 -197
  26. package/clients/cache-manager.test.ts +0 -299
  27. package/clients/complexity-client.js +0 -675
  28. package/clients/complexity-client.test.js +0 -234
  29. package/clients/complexity-client.test.ts +0 -255
  30. package/clients/config-validator.js +0 -465
  31. package/clients/dependency-checker.js +0 -325
  32. package/clients/dependency-checker.test.js +0 -60
  33. package/clients/dependency-checker.test.ts +0 -71
  34. package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
  35. package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
  36. package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
  37. package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
  38. package/clients/dispatch/debug.log +0 -1
  39. package/clients/dispatch/dispatcher.edge.test.js +0 -82
  40. package/clients/dispatch/dispatcher.edge.test.ts +0 -100
  41. package/clients/dispatch/dispatcher.format.test.js +0 -46
  42. package/clients/dispatch/dispatcher.format.test.ts +0 -58
  43. package/clients/dispatch/dispatcher.inline.test.js +0 -74
  44. package/clients/dispatch/dispatcher.inline.test.ts +0 -93
  45. package/clients/dispatch/dispatcher.js +0 -381
  46. package/clients/dispatch/dispatcher.test.js +0 -116
  47. package/clients/dispatch/dispatcher.test.ts +0 -149
  48. package/clients/dispatch/integration.js +0 -108
  49. package/clients/dispatch/plan.js +0 -183
  50. package/clients/dispatch/runners/architect.js +0 -83
  51. package/clients/dispatch/runners/architect.test.js +0 -138
  52. package/clients/dispatch/runners/architect.test.ts +0 -162
  53. package/clients/dispatch/runners/ast-grep-napi.js +0 -405
  54. package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
  55. package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
  56. package/clients/dispatch/runners/ast-grep.js +0 -157
  57. package/clients/dispatch/runners/biome.js +0 -55
  58. package/clients/dispatch/runners/config-validation.js +0 -67
  59. package/clients/dispatch/runners/go-vet.js +0 -48
  60. package/clients/dispatch/runners/index.js +0 -47
  61. package/clients/dispatch/runners/lsp.js +0 -102
  62. package/clients/dispatch/runners/oxlint.js +0 -67
  63. package/clients/dispatch/runners/oxlint.test.js +0 -230
  64. package/clients/dispatch/runners/oxlint.test.ts +0 -303
  65. package/clients/dispatch/runners/pyright.js +0 -100
  66. package/clients/dispatch/runners/pyright.test.js +0 -98
  67. package/clients/dispatch/runners/pyright.test.ts +0 -121
  68. package/clients/dispatch/runners/python-slop.js +0 -97
  69. package/clients/dispatch/runners/python-slop.test.js +0 -203
  70. package/clients/dispatch/runners/python-slop.test.ts +0 -298
  71. package/clients/dispatch/runners/ruff.js +0 -48
  72. package/clients/dispatch/runners/rust-clippy.js +0 -102
  73. package/clients/dispatch/runners/scan_codebase.test.js +0 -89
  74. package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
  75. package/clients/dispatch/runners/shellcheck.js +0 -147
  76. package/clients/dispatch/runners/shellcheck.test.js +0 -98
  77. package/clients/dispatch/runners/shellcheck.test.ts +0 -129
  78. package/clients/dispatch/runners/similarity.js +0 -230
  79. package/clients/dispatch/runners/spellcheck.js +0 -106
  80. package/clients/dispatch/runners/spellcheck.test.js +0 -158
  81. package/clients/dispatch/runners/spellcheck.test.ts +0 -214
  82. package/clients/dispatch/runners/tree-sitter.js +0 -246
  83. package/clients/dispatch/runners/ts-lsp.js +0 -125
  84. package/clients/dispatch/runners/ts-slop.js +0 -113
  85. package/clients/dispatch/runners/type-safety.js +0 -142
  86. package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
  87. package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
  88. package/clients/dispatch/runners/utils.js +0 -51
  89. package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
  90. package/clients/dispatch/types.js +0 -16
  91. package/clients/dispatch/utils/format-utils.js +0 -44
  92. package/clients/dogfood.test.js +0 -201
  93. package/clients/dogfood.test.ts +0 -269
  94. package/clients/file-kinds.js +0 -177
  95. package/clients/file-kinds.test.js +0 -169
  96. package/clients/file-kinds.test.ts +0 -210
  97. package/clients/file-time.js +0 -152
  98. package/clients/file-utils.js +0 -40
  99. package/clients/fix-scanners.js +0 -204
  100. package/clients/format-service.js +0 -184
  101. package/clients/formatters.js +0 -488
  102. package/clients/go-client.js +0 -203
  103. package/clients/go-client.test.js +0 -127
  104. package/clients/go-client.test.ts +0 -143
  105. package/clients/installer/index.js +0 -403
  106. package/clients/interviewer-templates.js +0 -75
  107. package/clients/interviewer.js +0 -173
  108. package/clients/jscpd-client.js +0 -196
  109. package/clients/jscpd-client.test.js +0 -127
  110. package/clients/jscpd-client.test.ts +0 -145
  111. package/clients/knip-client.js +0 -239
  112. package/clients/knip-client.test.js +0 -112
  113. package/clients/knip-client.test.ts +0 -128
  114. package/clients/latency-logger.js +0 -40
  115. package/clients/lsp/__tests__/client.test.js +0 -310
  116. package/clients/lsp/__tests__/client.test.ts +0 -412
  117. package/clients/lsp/__tests__/config.test.js +0 -167
  118. package/clients/lsp/__tests__/config.test.ts +0 -217
  119. package/clients/lsp/__tests__/error-recovery.test.js +0 -213
  120. package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
  121. package/clients/lsp/__tests__/integration.test.js +0 -127
  122. package/clients/lsp/__tests__/integration.test.ts +0 -160
  123. package/clients/lsp/__tests__/launch.test.js +0 -313
  124. package/clients/lsp/__tests__/launch.test.ts +0 -394
  125. package/clients/lsp/__tests__/server.test.js +0 -259
  126. package/clients/lsp/__tests__/server.test.ts +0 -332
  127. package/clients/lsp/__tests__/service.test.js +0 -438
  128. package/clients/lsp/__tests__/service.test.ts +0 -530
  129. package/clients/lsp/client.js +0 -350
  130. package/clients/lsp/config.js +0 -112
  131. package/clients/lsp/index.js +0 -318
  132. package/clients/lsp/installer/index.js +0 -391
  133. package/clients/lsp/interactive-install.js +0 -221
  134. package/clients/lsp/language.js +0 -170
  135. package/clients/lsp/launch.js +0 -329
  136. package/clients/lsp/lsp/launch.js +0 -116
  137. package/clients/lsp/lsp/server.js +0 -532
  138. package/clients/lsp/lsp-index.js +0 -10
  139. package/clients/lsp/path-utils.js +0 -5
  140. package/clients/lsp/server.js +0 -725
  141. package/clients/lsp/test-py-spawn/requirements.txt +0 -1
  142. package/clients/lsp/test-py-spawn/test.py +0 -3
  143. package/clients/lsp/test-py-svc/requirements.txt +0 -1
  144. package/clients/lsp/test-py-svc/test.py +0 -3
  145. package/clients/lsp/test-python-project/requirements.txt +0 -1
  146. package/clients/lsp/test-python-project/test.py +0 -5
  147. package/clients/metrics-client.js +0 -107
  148. package/clients/metrics-client.test.js +0 -128
  149. package/clients/metrics-client.test.ts +0 -163
  150. package/clients/metrics-history.js +0 -367
  151. package/clients/path-utils.js +0 -142
  152. package/clients/pipeline.js +0 -272
  153. package/clients/production-readiness.js +0 -522
  154. package/clients/project-index.js +0 -255
  155. package/clients/project-metadata.js +0 -531
  156. package/clients/ruff-client.js +0 -325
  157. package/clients/ruff-client.test.js +0 -132
  158. package/clients/ruff-client.test.ts +0 -153
  159. package/clients/rules-scanner.js +0 -97
  160. package/clients/runner-tracker.js +0 -152
  161. package/clients/rust-client.js +0 -205
  162. package/clients/rust-client.test.js +0 -108
  163. package/clients/rust-client.test.ts +0 -130
  164. package/clients/safe-spawn-async.js +0 -163
  165. package/clients/safe-spawn.js +0 -241
  166. package/clients/sanitize.js +0 -291
  167. package/clients/sanitize.test.js +0 -177
  168. package/clients/sanitize.test.ts +0 -223
  169. package/clients/scan-architectural-debt.js +0 -167
  170. package/clients/scan-utils.js +0 -83
  171. package/clients/secrets-scanner.js +0 -119
  172. package/clients/secrets-scanner.test.js +0 -100
  173. package/clients/secrets-scanner.test.ts +0 -113
  174. package/clients/sg-runner.js +0 -292
  175. package/clients/state-matrix.js +0 -160
  176. package/clients/subprocess-client.js +0 -65
  177. package/clients/symbol-types.js +0 -5
  178. package/clients/test-runner-client.js +0 -523
  179. package/clients/test-runner-client.test.js +0 -192
  180. package/clients/test-runner-client.test.ts +0 -253
  181. package/clients/test-utils.js +0 -27
  182. package/clients/test-utils.ts +0 -36
  183. package/clients/todo-scanner.js +0 -200
  184. package/clients/todo-scanner.test.js +0 -301
  185. package/clients/todo-scanner.test.ts +0 -352
  186. package/clients/tool-availability.js +0 -207
  187. package/clients/tree-sitter-client.js +0 -601
  188. package/clients/tree-sitter-query-loader.js +0 -355
  189. package/clients/tree-sitter-symbol-extractor.js +0 -289
  190. package/clients/ts-service.js +0 -129
  191. package/clients/type-coverage-client.js +0 -127
  192. package/clients/type-coverage-client.test.js +0 -105
  193. package/clients/type-coverage-client.test.ts +0 -125
  194. package/clients/type-safety-client.js +0 -138
  195. package/clients/types.js +0 -11
  196. package/clients/typescript-client.codefix.test.js +0 -157
  197. package/clients/typescript-client.codefix.test.ts +0 -186
  198. package/clients/typescript-client.js +0 -509
  199. package/clients/typescript-client.test.js +0 -105
  200. package/clients/typescript-client.test.ts +0 -126
  201. package/commands/booboo.js +0 -1007
  202. package/commands/fix-from-booboo.js +0 -398
  203. package/commands/fix-simplified.js +0 -618
  204. package/commands/rate.js +0 -281
  205. package/commands/rate.test.js +0 -119
  206. package/commands/rate.test.ts +0 -131
  207. 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;