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,725 +0,0 @@
1
- /**
2
- * LSP Server Definitions for pi-lens
3
- *
4
- * Defines 40+ language servers with:
5
- * - Root detection (monorepo support)
6
- * - Auto-installation strategies
7
- * - Platform-specific handling
8
- */
9
- import { stat } from "node:fs/promises";
10
- import path from "node:path";
11
- import { ensureTool, getToolEnvironment } from "../installer/index.js";
12
- import { promptForInstall, supportsInteractiveInstall, } from "./interactive-install.js";
13
- import { launchLSP, launchViaPackageManager, } from "./launch.js";
14
- // --- Root Detection Helpers ---
15
- import { dirname } from "node:path";
16
- import { fileURLToPath } from "node:url";
17
- const __filename = fileURLToPath(import.meta.url);
18
- const __dirname = dirname(__filename);
19
- // --- Interactive Install Helper ---
20
- /**
21
- * Spawn LSP with interactive install support for common languages
22
- *
23
- * For Go, Rust, YAML, JSON, Bash: prompts user to install if tool not found
24
- * Other languages: throws error with install instructions
25
- */
26
- async function spawnWithInteractiveInstall(language, _command, _args, options, spawnFn) {
27
- try {
28
- return await spawnFn();
29
- }
30
- catch (error) {
31
- // Check if this is a "command not found" error
32
- const errorMsg = String(error);
33
- if (!errorMsg.includes("not found") && !errorMsg.includes("ENOENT")) {
34
- throw error; // Re-throw if it's a different error
35
- }
36
- // Check if language supports interactive install
37
- if (supportsInteractiveInstall(language)) {
38
- const shouldInstall = await promptForInstall(language, options.cwd);
39
- if (shouldInstall) {
40
- // Try again after install
41
- return await spawnFn();
42
- }
43
- // User declined, return undefined to skip this LSP
44
- return undefined;
45
- }
46
- // For other languages, throw with install instructions
47
- throw error;
48
- }
49
- }
50
- /**
51
- * Walk up the directory tree looking for project root markers.
52
- *
53
- * NearestRoot(includePatterns, excludePatterns?) → RootFunction
54
- *
55
- * - includePatterns: file/dir names that signal the project root (e.g. ["package.json"])
56
- * - excludePatterns: if any of these exist in a directory, skip it (e.g. ["node_modules"])
57
- * - stopDir: walk stops here (defaults to filesystem root; set to project cwd for safety)
58
- *
59
- * Equivalent to createRootDetector; exported under both names for clarity.
60
- */
61
- export function NearestRoot(includePatterns, excludePatterns, stopDir) {
62
- return async (file) => {
63
- let currentDir = path.dirname(file);
64
- const fsRoot = path.parse(currentDir).root;
65
- const stop = stopDir ?? fsRoot;
66
- while (currentDir !== fsRoot) {
67
- // Bail out if we've reached the stop boundary
68
- if (currentDir === stop ||
69
- (currentDir.startsWith(stop + path.sep) === false &&
70
- currentDir === stop)) {
71
- break;
72
- }
73
- // Check exclude patterns — skip this dir (but keep walking up)
74
- if (excludePatterns) {
75
- let excluded = false;
76
- for (const pattern of excludePatterns) {
77
- try {
78
- await stat(path.join(currentDir, pattern));
79
- excluded = true;
80
- break;
81
- }
82
- catch {
83
- /* not found */
84
- }
85
- }
86
- if (excluded) {
87
- currentDir = path.dirname(currentDir);
88
- continue;
89
- }
90
- }
91
- // Check include patterns
92
- for (const pattern of includePatterns) {
93
- try {
94
- await stat(path.join(currentDir, pattern));
95
- return currentDir;
96
- }
97
- catch {
98
- /* not found */
99
- }
100
- }
101
- currentDir = path.dirname(currentDir);
102
- }
103
- return undefined;
104
- };
105
- }
106
- /** Alias kept for backward compatibility */
107
- export const createRootDetector = NearestRoot;
108
- // --- Server Definitions ---
109
- export const TypeScriptServer = {
110
- id: "typescript",
111
- name: "TypeScript Language Server",
112
- extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"],
113
- root: createRootDetector([
114
- "package-lock.json",
115
- "bun.lockb",
116
- "bun.lock",
117
- "pnpm-lock.yaml",
118
- "yarn.lock",
119
- "package.json",
120
- ]),
121
- async spawn(root) {
122
- const path = await import("node:path");
123
- const fs = await import("node:fs/promises");
124
- // Find typescript-language-server - prefer local project version
125
- let lspPath;
126
- const localLsp = path.join(root, "node_modules", ".bin", "typescript-language-server");
127
- const localLspCmd = path.join(root, "node_modules", ".bin", "typescript-language-server.cmd");
128
- // Check for local version first (Windows .cmd first, then Unix)
129
- for (const checkPath of [localLspCmd, localLsp]) {
130
- try {
131
- await fs.access(checkPath);
132
- lspPath = checkPath;
133
- break;
134
- }
135
- catch {
136
- /* not found */
137
- }
138
- }
139
- // Fall back to auto-installed version
140
- if (!lspPath) {
141
- lspPath = await ensureTool("typescript-language-server");
142
- if (!lspPath) {
143
- console.error("[lsp] typescript-language-server not found");
144
- return undefined;
145
- }
146
- }
147
- // Find tsserver.js path (needed for TypeScript LSP initialization)
148
- // Check relative to the LSP path first, then project root
149
- let tsserverPath;
150
- const tsserverCandidates = [
151
- // Relative to LSP binary (for locally installed)
152
- path.join(path.dirname(lspPath), "..", "typescript", "lib", "tsserver.js"),
153
- // Project root
154
- path.join(root, "node_modules", "typescript", "lib", "tsserver.js"),
155
- // Current working directory
156
- path.join(process.cwd(), "node_modules", "typescript", "lib", "tsserver.js"),
157
- ];
158
- for (const checkPath of tsserverCandidates) {
159
- try {
160
- await fs.access(checkPath);
161
- tsserverPath = checkPath;
162
- break;
163
- }
164
- catch {
165
- /* not found */
166
- }
167
- }
168
- // Use absolute path and proper environment
169
- const env = await getToolEnvironment();
170
- const proc = await launchLSP(lspPath, ["--stdio"], {
171
- cwd: root,
172
- env: {
173
- ...env,
174
- TSSERVER_PATH: tsserverPath,
175
- },
176
- });
177
- return {
178
- process: proc,
179
- initialization: tsserverPath
180
- ? { tsserver: { path: tsserverPath } }
181
- : undefined,
182
- };
183
- },
184
- };
185
- export const PythonServer = {
186
- id: "python",
187
- name: "Pyright Language Server",
188
- extensions: [".py", ".pyi"],
189
- root: createRootDetector([
190
- "pyproject.toml",
191
- "setup.py",
192
- "setup.cfg",
193
- "requirements.txt",
194
- "Pipfile",
195
- "poetry.lock",
196
- ]),
197
- async spawn(root) {
198
- const path = await import("node:path");
199
- const fs = await import("node:fs/promises");
200
- const env = await getToolEnvironment();
201
- // Strategy 1: Find pyright - prefer local project version
202
- let pyrightPath;
203
- const localPyright = path.join(root, "node_modules", ".bin", "pyright");
204
- const localPyrightCmd = path.join(root, "node_modules", ".bin", "pyright.cmd");
205
- // Check for local version first (Windows .cmd first, then Unix)
206
- for (const checkPath of [localPyrightCmd, localPyright]) {
207
- try {
208
- await fs.access(checkPath);
209
- pyrightPath = checkPath;
210
- break;
211
- }
212
- catch {
213
- /* not found */
214
- }
215
- }
216
- // Strategy 2: Fall back to auto-installed version
217
- if (!pyrightPath) {
218
- pyrightPath = await ensureTool("pyright");
219
- if (!pyrightPath) {
220
- console.error("[lsp] pyright not found, falling back to npx");
221
- }
222
- }
223
- // Strategy 3: Use found pyright to derive pyright-langserver path
224
- let langserverPath;
225
- if (pyrightPath) {
226
- // Derive langserver from pyright binary location
227
- // Both are in the same .bin directory
228
- const binDir = path.dirname(pyrightPath);
229
- const isWindows = process.platform === "win32";
230
- const candidates = isWindows
231
- ? [
232
- path.join(binDir, "pyright-langserver.cmd"),
233
- path.join(binDir, "pyright-langserver.ps1"),
234
- path.join(binDir, "pyright-langserver"),
235
- ]
236
- : [path.join(binDir, "pyright-langserver")];
237
- for (const candidate of candidates) {
238
- try {
239
- await fs.access(candidate);
240
- langserverPath = candidate;
241
- console.error(`[lsp] Found pyright-langserver: ${candidate}`);
242
- break;
243
- }
244
- catch {
245
- /* not found */
246
- }
247
- }
248
- }
249
- // Spawn the LSP server
250
- let proc;
251
- if (langserverPath) {
252
- // Use resolved langserver path
253
- proc = await launchLSP(langserverPath, ["--stdio"], {
254
- cwd: root,
255
- env,
256
- });
257
- }
258
- else {
259
- // Fallback to npx for auto-download
260
- console.error("[lsp] Falling back to npx for pyright-langserver");
261
- proc = await launchViaPackageManager("pyright-langserver", ["--stdio"], {
262
- cwd: root,
263
- env,
264
- });
265
- }
266
- // Detect virtual environment
267
- const initialization = {};
268
- const venvPaths = [
269
- path.join(root, ".venv"),
270
- path.join(root, "venv"),
271
- process.env.VIRTUAL_ENV,
272
- ].filter(Boolean);
273
- for (const venv of venvPaths) {
274
- if (!venv)
275
- continue;
276
- try {
277
- const pythonPath = process.platform === "win32"
278
- ? path.join(venv, "Scripts", "python.exe")
279
- : path.join(venv, "bin", "python");
280
- await fs.access(pythonPath);
281
- // Pyright expects pythonPath at top level, not nested
282
- initialization.pythonPath = pythonPath;
283
- break;
284
- }
285
- catch {
286
- /* not found */
287
- }
288
- }
289
- return { process: proc, initialization };
290
- },
291
- };
292
- export const GoServer = {
293
- id: "go",
294
- name: "gopls",
295
- extensions: [".go"],
296
- root: createRootDetector(["go.mod", "go.sum"]),
297
- async spawn(root) {
298
- const proc = await spawnWithInteractiveInstall("go", "gopls", [], { cwd: root }, async () => await launchLSP("gopls", [], { cwd: root }));
299
- // gopls works best with minimal initialization options
300
- // The client capabilities fix (workspaceFolders: true) is the key fix
301
- return proc
302
- ? {
303
- process: proc,
304
- initialization: {
305
- // Disable experimental features that may cause issues
306
- ui: {
307
- semanticTokens: true,
308
- },
309
- },
310
- }
311
- : undefined;
312
- },
313
- };
314
- export const RustServer = {
315
- id: "rust",
316
- name: "rust-analyzer",
317
- extensions: [".rs"],
318
- root: createRootDetector(["Cargo.toml", "Cargo.lock"]),
319
- async spawn(root) {
320
- const proc = await spawnWithInteractiveInstall("rust", "rust-analyzer", [], { cwd: root }, async () => await launchLSP("rust-analyzer", [], { cwd: root }));
321
- // rust-analyzer needs minimal initialization to avoid capability mismatches
322
- return proc
323
- ? {
324
- process: proc,
325
- initialization: {
326
- // Disable features that may conflict with our client capabilities
327
- cargo: {
328
- buildScripts: { enable: true },
329
- },
330
- procMacro: { enable: true },
331
- diagnostics: { enable: true },
332
- },
333
- }
334
- : undefined;
335
- },
336
- };
337
- export const RubyServer = {
338
- id: "ruby",
339
- name: "Ruby LSP",
340
- extensions: [".rb", ".rake", ".gemspec", ".ru"],
341
- root: createRootDetector(["Gemfile", ".ruby-version"]),
342
- async spawn(root) {
343
- // Try ruby-lsp first, fall back to solargraph
344
- try {
345
- const proc = await launchLSP("ruby-lsp", [], { cwd: root });
346
- return { process: proc };
347
- }
348
- catch {
349
- const proc = await launchViaPackageManager("solargraph", ["stdio"], {
350
- cwd: root,
351
- });
352
- return { process: proc };
353
- }
354
- },
355
- };
356
- export const PHPServer = {
357
- id: "php",
358
- name: "Intelephense",
359
- extensions: [".php"],
360
- root: createRootDetector(["composer.json", "composer.lock"]),
361
- async spawn(root) {
362
- const proc = await launchViaPackageManager("intelephense", ["--stdio"], {
363
- cwd: root,
364
- });
365
- return {
366
- process: proc,
367
- initialization: { storagePath: path.join(__dirname, ".intelephense") },
368
- };
369
- },
370
- };
371
- export const CSharpServer = {
372
- id: "csharp",
373
- name: "csharp-ls",
374
- extensions: [".cs"],
375
- root: createRootDetector([".sln", ".csproj", ".slnx"]),
376
- async spawn(root) {
377
- const proc = await launchLSP("csharp-ls", [], { cwd: root });
378
- return { process: proc };
379
- },
380
- };
381
- export const FSharpServer = {
382
- id: "fsharp",
383
- name: "FSAutocomplete",
384
- extensions: [".fs", ".fsi", ".fsx"],
385
- root: createRootDetector([".sln", ".fsproj"]),
386
- async spawn(root) {
387
- const proc = await launchLSP("fsautocomplete", [], { cwd: root });
388
- return { process: proc };
389
- },
390
- };
391
- export const JavaServer = {
392
- id: "java",
393
- name: "JDT Language Server",
394
- extensions: [".java"],
395
- root: createRootDetector(["pom.xml", "build.gradle", ".classpath"]),
396
- async spawn(root) {
397
- // JDTLS requires special handling - paths to launcher jar
398
- const jdtlsPath = process.env.JDTLS_PATH || "jdtls";
399
- const proc = await launchLSP(jdtlsPath, [], { cwd: root });
400
- return { process: proc };
401
- },
402
- };
403
- export const KotlinServer = {
404
- id: "kotlin",
405
- name: "Kotlin Language Server",
406
- extensions: [".kt", ".kts"],
407
- root: createRootDetector(["build.gradle.kts", "build.gradle", "pom.xml"]),
408
- async spawn(root) {
409
- const proc = await launchLSP("kotlin-language-server", [], { cwd: root });
410
- return { process: proc };
411
- },
412
- };
413
- export const SwiftServer = {
414
- id: "swift",
415
- name: "SourceKit-LSP",
416
- extensions: [".swift"],
417
- root: createRootDetector(["Package.swift"]),
418
- async spawn(root) {
419
- const proc = await launchLSP("sourcekit-lsp", [], { cwd: root });
420
- return { process: proc };
421
- },
422
- };
423
- export const DartServer = {
424
- id: "dart",
425
- name: "Dart Analysis Server",
426
- extensions: [".dart"],
427
- root: createRootDetector(["pubspec.yaml"]),
428
- async spawn(root) {
429
- const proc = await launchLSP("dart", ["language-server", "--protocol=lsp"], {
430
- cwd: root,
431
- });
432
- return { process: proc };
433
- },
434
- };
435
- export const LuaServer = {
436
- id: "lua",
437
- name: "Lua Language Server",
438
- extensions: [".lua"],
439
- root: createRootDetector([".luarc.json", ".luacheckrc"]),
440
- async spawn(root) {
441
- const proc = await launchLSP("lua-language-server", [], { cwd: root });
442
- return { process: proc };
443
- },
444
- };
445
- export const CppServer = {
446
- id: "cpp",
447
- name: "clangd",
448
- extensions: [".c", ".cpp", ".cc", ".cxx", ".h", ".hpp"],
449
- root: createRootDetector([
450
- "compile_commands.json",
451
- ".clangd",
452
- "CMakeLists.txt",
453
- "Makefile",
454
- ]),
455
- async spawn(root) {
456
- const proc = await launchLSP("clangd", ["--background-index"], {
457
- cwd: root,
458
- });
459
- return { process: proc };
460
- },
461
- };
462
- export const ZigServer = {
463
- id: "zig",
464
- name: "ZLS",
465
- extensions: [".zig", ".zon"],
466
- root: createRootDetector(["build.zig"]),
467
- async spawn(root) {
468
- const proc = await launchLSP("zls", [], { cwd: root });
469
- return { process: proc };
470
- },
471
- };
472
- export const HaskellServer = {
473
- id: "haskell",
474
- name: "Haskell Language Server",
475
- extensions: [".hs", ".lhs"],
476
- root: createRootDetector(["stack.yaml", "cabal.project", "*.cabal"]),
477
- async spawn(root) {
478
- const proc = await launchLSP("haskell-language-server-wrapper", ["--lsp"], {
479
- cwd: root,
480
- });
481
- return { process: proc };
482
- },
483
- };
484
- export const ElixirServer = {
485
- id: "elixir",
486
- name: "ElixirLS",
487
- extensions: [".ex", ".exs"],
488
- root: createRootDetector(["mix.exs"]),
489
- async spawn(root) {
490
- const proc = await launchLSP("elixir-ls", [], { cwd: root });
491
- return { process: proc };
492
- },
493
- };
494
- export const GleamServer = {
495
- id: "gleam",
496
- name: "Gleam LSP",
497
- extensions: [".gleam"],
498
- root: createRootDetector(["gleam.toml"]),
499
- async spawn(root) {
500
- const proc = await launchLSP("gleam", ["lsp"], { cwd: root });
501
- return { process: proc };
502
- },
503
- };
504
- export const OCamlServer = {
505
- id: "ocaml",
506
- name: "ocamllsp",
507
- extensions: [".ml", ".mli"],
508
- root: createRootDetector(["dune-project", "opam"]),
509
- async spawn(root) {
510
- const proc = await launchLSP("ocamllsp", [], { cwd: root });
511
- return { process: proc };
512
- },
513
- };
514
- export const ClojureServer = {
515
- id: "clojure",
516
- name: "Clojure LSP",
517
- extensions: [".clj", ".cljs", ".cljc", ".edn"],
518
- root: createRootDetector(["deps.edn", "project.clj"]),
519
- async spawn(root) {
520
- const proc = await launchLSP("clojure-lsp", [], { cwd: root });
521
- return { process: proc };
522
- },
523
- };
524
- export const TerraformServer = {
525
- id: "terraform",
526
- name: "Terraform LSP",
527
- extensions: [".tf", ".tfvars"],
528
- root: createRootDetector([".terraform.lock.hcl"]),
529
- async spawn(root) {
530
- const proc = await launchLSP("terraform-ls", ["serve"], { cwd: root });
531
- return { process: proc };
532
- },
533
- };
534
- export const NixServer = {
535
- id: "nix",
536
- name: "nixd",
537
- extensions: [".nix"],
538
- root: createRootDetector(["flake.nix"]),
539
- async spawn(root) {
540
- const proc = await launchLSP("nixd", [], { cwd: root });
541
- return { process: proc };
542
- },
543
- };
544
- export const BashServer = {
545
- id: "bash",
546
- name: "Bash Language Server",
547
- extensions: [".sh", ".bash", ".zsh"],
548
- root: async () => process.cwd(),
549
- async spawn() {
550
- const cwd = process.cwd();
551
- const proc = await spawnWithInteractiveInstall("bash", "bash-language-server", ["start"], { cwd }, async () => await launchLSP("bash-language-server", ["start"], {}));
552
- return proc ? { process: proc } : undefined;
553
- },
554
- };
555
- export const DockerServer = {
556
- id: "docker",
557
- name: "Dockerfile Language Server",
558
- extensions: [".dockerfile", "Dockerfile"],
559
- root: async () => process.cwd(),
560
- async spawn() {
561
- // Use npx since it's not auto-installed
562
- const proc = await launchViaPackageManager("dockerfile-language-server-nodejs", ["--stdio"], {});
563
- return { process: proc };
564
- },
565
- };
566
- export const YamlServer = {
567
- id: "yaml",
568
- name: "YAML Language Server",
569
- extensions: [".yaml", ".yml"],
570
- root: async () => process.cwd(),
571
- async spawn() {
572
- const cwd = process.cwd();
573
- const proc = await spawnWithInteractiveInstall("yaml", "yaml-language-server", ["--stdio"], { cwd }, async () => await launchLSP("yaml-language-server", ["--stdio"], {}));
574
- return proc ? { process: proc } : undefined;
575
- },
576
- };
577
- export const JsonServer = {
578
- id: "json",
579
- name: "VSCode JSON Language Server",
580
- extensions: [".json", ".jsonc"],
581
- root: async () => process.cwd(),
582
- async spawn() {
583
- const cwd = process.cwd();
584
- const proc = await spawnWithInteractiveInstall("json", "vscode-json-language-server", ["--stdio"], { cwd }, async () => await launchLSP("vscode-json-language-server", ["--stdio"], {}));
585
- return proc ? { process: proc } : undefined;
586
- },
587
- };
588
- export const PrismaServer = {
589
- id: "prisma",
590
- name: "Prisma Language Server",
591
- extensions: [".prisma"],
592
- root: createRootDetector(["prisma/schema.prisma"]),
593
- async spawn(root) {
594
- // Use npx since it's not auto-installed
595
- const proc = await launchViaPackageManager("@prisma/language-server", ["--stdio"], { cwd: root });
596
- return { process: proc };
597
- },
598
- };
599
- // --- Web Framework & Styling Servers ---
600
- export const VueServer = {
601
- id: "vue",
602
- name: "Vue Language Server",
603
- extensions: [".vue"],
604
- root: createRootDetector([
605
- "package-lock.json",
606
- "bun.lockb",
607
- "bun.lock",
608
- "pnpm-lock.yaml",
609
- "yarn.lock",
610
- ]),
611
- async spawn(root) {
612
- // Use npx since it's not auto-installed
613
- const proc = await launchViaPackageManager("@vue/language-server", ["--stdio"], {
614
- cwd: root,
615
- });
616
- return { process: proc };
617
- },
618
- };
619
- export const SvelteServer = {
620
- id: "svelte",
621
- name: "Svelte Language Server",
622
- extensions: [".svelte"],
623
- root: createRootDetector([
624
- "package-lock.json",
625
- "bun.lockb",
626
- "bun.lock",
627
- "pnpm-lock.yaml",
628
- "yarn.lock",
629
- ]),
630
- async spawn(root) {
631
- // Use npx since it's not auto-installed
632
- const proc = await launchViaPackageManager("svelte-language-server", ["--stdio"], { cwd: root });
633
- return { process: proc };
634
- },
635
- };
636
- export const ESLintServer = {
637
- id: "eslint",
638
- name: "ESLint Language Server",
639
- extensions: [".js", ".jsx", ".vue", ".svelte"], // Note: .ts/.tsx handled by TypeScript LSP + Biome
640
- root: createRootDetector([
641
- ".eslintrc",
642
- ".eslintrc.json",
643
- ".eslintrc.js",
644
- "eslint.config.js",
645
- "eslint.config.mjs",
646
- "package.json",
647
- ]),
648
- async spawn(root) {
649
- // Try via package manager (npx) since it's not auto-installed
650
- try {
651
- const proc = await launchViaPackageManager("vscode-eslint-language-server", ["--stdio"], { cwd: root });
652
- return { process: proc };
653
- }
654
- catch {
655
- // Fall back to global install message
656
- console.error("[lsp] ESLint Language Server not found. Install: npm install -g vscode-langservers-extracted");
657
- return undefined;
658
- }
659
- },
660
- };
661
- export const CssServer = {
662
- id: "css",
663
- name: "CSS Language Server",
664
- extensions: [".css", ".scss", ".sass", ".less"],
665
- root: async () => process.cwd(),
666
- async spawn() {
667
- // Use npx since it's not auto-installed
668
- const proc = await launchViaPackageManager("vscode-css-languageserver", ["--stdio"], {});
669
- return { process: proc };
670
- },
671
- };
672
- // --- Registry ---
673
- export const LSP_SERVERS = [
674
- TypeScriptServer,
675
- PythonServer,
676
- GoServer,
677
- RustServer,
678
- RubyServer,
679
- PHPServer,
680
- CSharpServer,
681
- FSharpServer,
682
- JavaServer,
683
- KotlinServer,
684
- SwiftServer,
685
- DartServer,
686
- LuaServer,
687
- CppServer,
688
- ZigServer,
689
- HaskellServer,
690
- ElixirServer,
691
- GleamServer,
692
- OCamlServer,
693
- ClojureServer,
694
- TerraformServer,
695
- NixServer,
696
- BashServer,
697
- DockerServer,
698
- YamlServer,
699
- JsonServer,
700
- PrismaServer,
701
- // Web frameworks & styling
702
- VueServer,
703
- SvelteServer,
704
- ESLintServer,
705
- CssServer,
706
- ];
707
- /**
708
- * Get server for a file extension
709
- */
710
- export function getServerForExtension(ext) {
711
- return LSP_SERVERS.find((server) => server.extensions.includes(ext));
712
- }
713
- /**
714
- * Get server by ID
715
- */
716
- export function getServerById(id) {
717
- return LSP_SERVERS.find((server) => server.id === id);
718
- }
719
- /**
720
- * Get all servers for a file (may have multiple matches)
721
- */
722
- export function getServersForFile(filePath) {
723
- const ext = path.extname(filePath).toLowerCase();
724
- return LSP_SERVERS.filter((server) => server.extensions.includes(ext));
725
- }