@floydous/pi-agent-kernel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +108 -0
- package/config.toml +24 -0
- package/docs/README.md +22 -0
- package/docs/architecture.md +40 -0
- package/docs/configuration.md +43 -0
- package/docs/editing-and-verification.md +41 -0
- package/docs/lsp.md +31 -0
- package/docs/retrieval.md +42 -0
- package/docs/testing.md +32 -0
- package/package.json +48 -0
- package/src/config/index.ts +2 -0
- package/src/config/kernel_config.ts +218 -0
- package/src/config/toml.ts +237 -0
- package/src/context/session_repair.ts +99 -0
- package/src/dedup/content_store.ts +365 -0
- package/src/dedup/recall_tool.ts +157 -0
- package/src/editing/patch.ts +482 -0
- package/src/editing/post_edit_verification.ts +200 -0
- package/src/editing/syntax-verify.ts +353 -0
- package/src/index.ts +852 -0
- package/src/lsp/adapters/base.ts +42 -0
- package/src/lsp/adapters/index.ts +21 -0
- package/src/lsp/adapters/python.ts +37 -0
- package/src/lsp/adapters/rust.ts +35 -0
- package/src/lsp/adapters/typescript.ts +40 -0
- package/src/lsp/index.ts +13 -0
- package/src/lsp/lsp_client.ts +650 -0
- package/src/lsp/lsp_detector.ts +52 -0
- package/src/lsp/lsp_formatter.ts +284 -0
- package/src/lsp/lsp_installer.ts +604 -0
- package/src/lsp/lsp_manager.ts +202 -0
- package/src/lsp/lsp_modal.ts +675 -0
- package/src/lsp/lsp_registry.ts +539 -0
- package/src/lsp/lsp_types.ts +143 -0
- package/src/retrieval/ast_search.ts +926 -0
- package/src/retrieval/repomap.ts +779 -0
- package/src/retrieval/search_bm25.ts +190 -0
- package/src/retrieval/search_chunker.ts +251 -0
- package/src/retrieval/search_config.ts +162 -0
- package/src/retrieval/search_embedder.ts +362 -0
- package/src/retrieval/search_index.ts +753 -0
- package/src/retrieval/search_modal.ts +358 -0
- package/src/retrieval/symbol_reader.ts +200 -0
- package/src/safety/atomic_write.ts +26 -0
- package/src/safety/epistemic_guard.ts +733 -0
- package/src/safety/kernel_debug.ts +15 -0
- package/src/safety/output_clamper.ts +213 -0
- package/src/tools/ast_search_tool.ts +131 -0
- package/src/tools/code_search_tool.ts +147 -0
- package/src/tools/context.ts +20 -0
- package/src/tools/edit_tool.ts +288 -0
- package/src/tools/lsp_tool.ts +813 -0
- package/src/tools/read_tool.ts +348 -0
- package/src/tools/repo_map_tool.ts +57 -0
- package/src/ui/footer.ts +287 -0
- package/src/ui/tui_utils.ts +278 -0
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import * as https from "node:https";
|
|
4
|
+
import { exec, execSync } from "node:child_process";
|
|
5
|
+
import {
|
|
6
|
+
PI_LSP_BIN_DIR,
|
|
7
|
+
LSP_SERVERS,
|
|
8
|
+
clearExecutableCache,
|
|
9
|
+
findExecutable,
|
|
10
|
+
} from "./lsp_registry";
|
|
11
|
+
import { kernelDebug } from "../safety/kernel_debug";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Ensure ~/.pi/lsp/bin directory exists
|
|
15
|
+
*/
|
|
16
|
+
export function ensureLspBinDir(): string {
|
|
17
|
+
if (!fs.existsSync(PI_LSP_BIN_DIR)) {
|
|
18
|
+
fs.mkdirSync(PI_LSP_BIN_DIR, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
return PI_LSP_BIN_DIR;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface InstallResult {
|
|
24
|
+
success: boolean;
|
|
25
|
+
message: string;
|
|
26
|
+
binPath?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Install language server via npm, uv, cargo, or binary release
|
|
31
|
+
*/
|
|
32
|
+
export async function installLanguageServer(
|
|
33
|
+
languageOrKey: string,
|
|
34
|
+
onProgress?: (msg: string) => void,
|
|
35
|
+
): Promise<InstallResult> {
|
|
36
|
+
const norm = languageOrKey.toLowerCase().trim();
|
|
37
|
+
ensureLspBinDir();
|
|
38
|
+
|
|
39
|
+
onProgress?.(`Resolving server installer for '${norm}'...`);
|
|
40
|
+
|
|
41
|
+
// TypeScript / JavaScript: Install @vtsls/language-server + typescript
|
|
42
|
+
if (
|
|
43
|
+
norm === "typescript" ||
|
|
44
|
+
norm === "ts" ||
|
|
45
|
+
norm === "javascript" ||
|
|
46
|
+
norm === "js"
|
|
47
|
+
) {
|
|
48
|
+
onProgress?.("Installing @vtsls/language-server & typescript via npm...");
|
|
49
|
+
try {
|
|
50
|
+
execSync(`npm install -g @vtsls/language-server typescript`, {
|
|
51
|
+
stdio: "pipe",
|
|
52
|
+
});
|
|
53
|
+
clearExecutableCache();
|
|
54
|
+
const bin = findExecutable("vtsls");
|
|
55
|
+
return {
|
|
56
|
+
success: true,
|
|
57
|
+
message: `Successfully installed vtsls (${bin || "vtsls"})`,
|
|
58
|
+
binPath: bin || undefined,
|
|
59
|
+
};
|
|
60
|
+
} catch (e: any) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
message: `Failed to install vtsls: ${e.message}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Python: Install Astral ty or pyright
|
|
69
|
+
if (norm === "python" || norm === "py") {
|
|
70
|
+
// Try uv first if available
|
|
71
|
+
const uvBin = findExecutable("uv");
|
|
72
|
+
if (uvBin) {
|
|
73
|
+
onProgress?.("Installing Astral 'ty' via uv...");
|
|
74
|
+
try {
|
|
75
|
+
execSync(`uv tool install ty`, { stdio: "pipe" });
|
|
76
|
+
clearExecutableCache();
|
|
77
|
+
const bin = findExecutable("ty");
|
|
78
|
+
if (bin) {
|
|
79
|
+
return {
|
|
80
|
+
success: true,
|
|
81
|
+
message: `Successfully installed Astral ty (${bin})`,
|
|
82
|
+
binPath: bin,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
kernelDebug(e);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Fall back to pyright via npm
|
|
91
|
+
onProgress?.("Installing pyright via npm...");
|
|
92
|
+
try {
|
|
93
|
+
execSync(`npm install -g pyright`, { stdio: "pipe" });
|
|
94
|
+
clearExecutableCache();
|
|
95
|
+
const bin = findExecutable("pyright-langserver");
|
|
96
|
+
return {
|
|
97
|
+
success: true,
|
|
98
|
+
message: `Successfully installed pyright (${bin || "pyright-langserver"})`,
|
|
99
|
+
binPath: bin || undefined,
|
|
100
|
+
};
|
|
101
|
+
} catch (e: any) {
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
message: `Failed to install python LSP: ${e.message}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Rust: rust-analyzer via rustup
|
|
110
|
+
if (norm === "rust" || norm === "rs") {
|
|
111
|
+
onProgress?.("Installing rust-analyzer via rustup...");
|
|
112
|
+
try {
|
|
113
|
+
execSync(`rustup component add rust-analyzer`, { stdio: "pipe" });
|
|
114
|
+
clearExecutableCache();
|
|
115
|
+
const bin = findExecutable("rust-analyzer");
|
|
116
|
+
return {
|
|
117
|
+
success: true,
|
|
118
|
+
message: `Successfully installed rust-analyzer (${bin || "rust-analyzer"})`,
|
|
119
|
+
binPath: bin || undefined,
|
|
120
|
+
};
|
|
121
|
+
} catch (e: any) {
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
message: `Failed to install rust-analyzer: ${e.message}`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Go: gopls
|
|
130
|
+
if (norm === "go" || norm === "golang") {
|
|
131
|
+
onProgress?.("Installing gopls via go install...");
|
|
132
|
+
try {
|
|
133
|
+
execSync(`go install golang.org/x/tools/gopls@latest`, { stdio: "pipe" });
|
|
134
|
+
clearExecutableCache();
|
|
135
|
+
const bin = findExecutable("gopls");
|
|
136
|
+
return {
|
|
137
|
+
success: true,
|
|
138
|
+
message: `Successfully installed gopls (${bin || "gopls"})`,
|
|
139
|
+
binPath: bin || undefined,
|
|
140
|
+
};
|
|
141
|
+
} catch (e: any) {
|
|
142
|
+
return {
|
|
143
|
+
success: false,
|
|
144
|
+
message: `Failed to install gopls: ${e.message}`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// TOML: taplo
|
|
150
|
+
if (norm === "toml" || norm === "taplo") {
|
|
151
|
+
onProgress?.("Installing taplo-cli via cargo...");
|
|
152
|
+
try {
|
|
153
|
+
execSync(`cargo install taplo-cli --locked --features lsp`, {
|
|
154
|
+
stdio: "pipe",
|
|
155
|
+
});
|
|
156
|
+
clearExecutableCache();
|
|
157
|
+
const bin = findExecutable("taplo");
|
|
158
|
+
return {
|
|
159
|
+
success: true,
|
|
160
|
+
message: `Successfully installed taplo (${bin || "taplo"})`,
|
|
161
|
+
binPath: bin || undefined,
|
|
162
|
+
};
|
|
163
|
+
} catch (e: any) {
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
message: `Failed to install taplo: ${e.message}`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Shell / Bash: bash-language-server via npm
|
|
172
|
+
if (norm === "shell" || norm === "bash" || norm === "sh") {
|
|
173
|
+
onProgress?.("Installing bash-language-server via npm...");
|
|
174
|
+
try {
|
|
175
|
+
execSync(`npm install -g bash-language-server`, { stdio: "pipe" });
|
|
176
|
+
clearExecutableCache();
|
|
177
|
+
const bin = findExecutable("bash-language-server");
|
|
178
|
+
return {
|
|
179
|
+
success: true,
|
|
180
|
+
message: `Successfully installed bash-language-server (${bin || "bash-language-server"})`,
|
|
181
|
+
binPath: bin || undefined,
|
|
182
|
+
};
|
|
183
|
+
} catch (e: any) {
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
message: `Failed to install bash-language-server: ${e.message}`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// HTML: superhtml or vscode-html-language-server
|
|
192
|
+
if (norm === "html" || norm === "htm") {
|
|
193
|
+
onProgress?.("Installing superhtml via package manager...");
|
|
194
|
+
const isWindows = process.platform === "win32";
|
|
195
|
+
try {
|
|
196
|
+
if (isWindows) {
|
|
197
|
+
execSync(
|
|
198
|
+
`winget install kristoff-it.superhtml --accept-source-agreements --accept-package-agreements --silent`,
|
|
199
|
+
{ stdio: "pipe" },
|
|
200
|
+
);
|
|
201
|
+
} else if (process.platform === "darwin") {
|
|
202
|
+
execSync(`brew install superhtml`, { stdio: "pipe" });
|
|
203
|
+
}
|
|
204
|
+
} catch (e) {
|
|
205
|
+
kernelDebug(e);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
clearExecutableCache();
|
|
209
|
+
let bin = findExecutable("superhtml");
|
|
210
|
+
if (bin) {
|
|
211
|
+
return {
|
|
212
|
+
success: true,
|
|
213
|
+
message: `Successfully installed superhtml (${bin})`,
|
|
214
|
+
binPath: bin,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Fallback to vscode-langservers-extracted via npm
|
|
219
|
+
onProgress?.("Installing vscode-langservers-extracted via npm...");
|
|
220
|
+
try {
|
|
221
|
+
execSync(`npm install -g vscode-langservers-extracted`, {
|
|
222
|
+
stdio: "pipe",
|
|
223
|
+
});
|
|
224
|
+
clearExecutableCache();
|
|
225
|
+
bin = findExecutable("vscode-html-language-server");
|
|
226
|
+
return {
|
|
227
|
+
success: true,
|
|
228
|
+
message: `Successfully installed vscode-html-language-server (${bin || "vscode-html-language-server"})`,
|
|
229
|
+
binPath: bin || undefined,
|
|
230
|
+
};
|
|
231
|
+
} catch (e: any) {
|
|
232
|
+
return {
|
|
233
|
+
success: false,
|
|
234
|
+
message: `Failed to install HTML LSP: ${e.message}`,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// JSON: Biome (Rust ultra-fast) or vscode-json-language-server
|
|
240
|
+
if (norm === "json" || norm === "jsonc") {
|
|
241
|
+
onProgress?.("Installing Biome (Rust) via npm...");
|
|
242
|
+
try {
|
|
243
|
+
execSync(`npm install -g @biomejs/biome`, { stdio: "pipe" });
|
|
244
|
+
clearExecutableCache();
|
|
245
|
+
const bin = findExecutable("biome");
|
|
246
|
+
if (bin) {
|
|
247
|
+
return {
|
|
248
|
+
success: true,
|
|
249
|
+
message: `Successfully installed Biome (${bin})`,
|
|
250
|
+
binPath: bin,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
} catch (e) {
|
|
254
|
+
kernelDebug(e);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
onProgress?.("Installing vscode-langservers-extracted via npm...");
|
|
258
|
+
try {
|
|
259
|
+
execSync(`npm install -g vscode-langservers-extracted`, {
|
|
260
|
+
stdio: "pipe",
|
|
261
|
+
});
|
|
262
|
+
clearExecutableCache();
|
|
263
|
+
const bin = findExecutable("vscode-json-language-server");
|
|
264
|
+
return {
|
|
265
|
+
success: true,
|
|
266
|
+
message: `Successfully installed vscode-json-language-server (${bin || "vscode-json-language-server"})`,
|
|
267
|
+
binPath: bin || undefined,
|
|
268
|
+
};
|
|
269
|
+
} catch (e: any) {
|
|
270
|
+
return {
|
|
271
|
+
success: false,
|
|
272
|
+
message: `Failed to install JSON LSP: ${e.message}`,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// YAML: yaml-language-server via npm
|
|
278
|
+
if (norm === "yaml" || norm === "yml") {
|
|
279
|
+
onProgress?.("Installing yaml-language-server via npm...");
|
|
280
|
+
try {
|
|
281
|
+
execSync(`npm install -g yaml-language-server`, { stdio: "pipe" });
|
|
282
|
+
clearExecutableCache();
|
|
283
|
+
const bin = findExecutable("yaml-language-server");
|
|
284
|
+
return {
|
|
285
|
+
success: true,
|
|
286
|
+
message: `Successfully installed yaml-language-server (${bin || "yaml-language-server"})`,
|
|
287
|
+
binPath: bin || undefined,
|
|
288
|
+
};
|
|
289
|
+
} catch (e: any) {
|
|
290
|
+
return {
|
|
291
|
+
success: false,
|
|
292
|
+
message: `Failed to install yaml-language-server: ${e.message}`,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Dockerfile: dockerfile-language-server-nodejs via npm
|
|
298
|
+
if (norm === "docker" || norm === "dockerfile") {
|
|
299
|
+
onProgress?.("Installing dockerfile-language-server-nodejs via npm...");
|
|
300
|
+
try {
|
|
301
|
+
execSync(`npm install -g dockerfile-language-server-nodejs`, {
|
|
302
|
+
stdio: "pipe",
|
|
303
|
+
});
|
|
304
|
+
clearExecutableCache();
|
|
305
|
+
const bin = findExecutable("docker-langserver");
|
|
306
|
+
return {
|
|
307
|
+
success: true,
|
|
308
|
+
message: `Successfully installed docker-langserver (${bin || "docker-langserver"})`,
|
|
309
|
+
binPath: bin || undefined,
|
|
310
|
+
};
|
|
311
|
+
} catch (e: any) {
|
|
312
|
+
return {
|
|
313
|
+
success: false,
|
|
314
|
+
message: `Failed to install dockerfile-language-server: ${e.message}`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// PHP: intelephense via npm
|
|
320
|
+
if (norm === "php") {
|
|
321
|
+
onProgress?.("Installing intelephense via npm...");
|
|
322
|
+
try {
|
|
323
|
+
execSync(`npm install -g intelephense`, { stdio: "pipe" });
|
|
324
|
+
clearExecutableCache();
|
|
325
|
+
const bin = findExecutable("intelephense");
|
|
326
|
+
return {
|
|
327
|
+
success: true,
|
|
328
|
+
message: `Successfully installed intelephense (${bin || "intelephense"})`,
|
|
329
|
+
binPath: bin || undefined,
|
|
330
|
+
};
|
|
331
|
+
} catch (e: any) {
|
|
332
|
+
return {
|
|
333
|
+
success: false,
|
|
334
|
+
message: `Failed to install intelephense: ${e.message}`,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Markdown: marksman
|
|
340
|
+
if (norm === "markdown" || norm === "md") {
|
|
341
|
+
onProgress?.("Installing marksman...");
|
|
342
|
+
const isWindows = process.platform === "win32";
|
|
343
|
+
const binDir = ensureLspBinDir();
|
|
344
|
+
|
|
345
|
+
// 1. Try winget / brew / package manager first
|
|
346
|
+
try {
|
|
347
|
+
if (isWindows) {
|
|
348
|
+
execSync(
|
|
349
|
+
`winget install Artempyanykh.Marksman --accept-source-agreements --accept-package-agreements --silent`,
|
|
350
|
+
{ stdio: "pipe" },
|
|
351
|
+
);
|
|
352
|
+
} else if (process.platform === "darwin") {
|
|
353
|
+
execSync(`brew install marksman`, { stdio: "pipe" });
|
|
354
|
+
}
|
|
355
|
+
} catch (e) {
|
|
356
|
+
kernelDebug(e);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
clearExecutableCache();
|
|
360
|
+
let bin = findExecutable("marksman");
|
|
361
|
+
if (bin) {
|
|
362
|
+
return {
|
|
363
|
+
success: true,
|
|
364
|
+
message: `Successfully installed marksman (${bin})`,
|
|
365
|
+
binPath: bin,
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return {
|
|
370
|
+
success: false,
|
|
371
|
+
message:
|
|
372
|
+
"Please install marksman using your system package manager (e.g. winget, brew, or cargo install marksman).",
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// C / C++: clangd
|
|
377
|
+
if (norm === "cpp" || norm === "c" || norm === "clangd") {
|
|
378
|
+
onProgress?.("Installing clangd...");
|
|
379
|
+
const isWindows = process.platform === "win32";
|
|
380
|
+
try {
|
|
381
|
+
if (isWindows) {
|
|
382
|
+
execSync(
|
|
383
|
+
`winget install LLVM.clangd --accept-source-agreements --accept-package-agreements --silent`,
|
|
384
|
+
{ stdio: "pipe" },
|
|
385
|
+
);
|
|
386
|
+
} else if (process.platform === "darwin") {
|
|
387
|
+
execSync(`brew install llvm`, { stdio: "pipe" });
|
|
388
|
+
}
|
|
389
|
+
clearExecutableCache();
|
|
390
|
+
const bin = findExecutable("clangd");
|
|
391
|
+
if (bin) {
|
|
392
|
+
return {
|
|
393
|
+
success: true,
|
|
394
|
+
message: `Successfully installed clangd (${bin})`,
|
|
395
|
+
binPath: bin,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
} catch (e: any) {
|
|
399
|
+
return {
|
|
400
|
+
success: false,
|
|
401
|
+
message: `Failed to install clangd: ${e.message}`,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Zig: zls
|
|
407
|
+
if (norm === "zig" || norm === "zls") {
|
|
408
|
+
onProgress?.("Installing zls...");
|
|
409
|
+
const isWindows = process.platform === "win32";
|
|
410
|
+
try {
|
|
411
|
+
if (isWindows) {
|
|
412
|
+
execSync(
|
|
413
|
+
`winget install zigtools.zls --accept-source-agreements --accept-package-agreements --silent`,
|
|
414
|
+
{ stdio: "pipe" },
|
|
415
|
+
);
|
|
416
|
+
} else if (process.platform === "darwin") {
|
|
417
|
+
execSync(`brew install zls`, { stdio: "pipe" });
|
|
418
|
+
}
|
|
419
|
+
clearExecutableCache();
|
|
420
|
+
const bin = findExecutable("zls");
|
|
421
|
+
if (bin) {
|
|
422
|
+
return {
|
|
423
|
+
success: true,
|
|
424
|
+
message: `Successfully installed zls (${bin})`,
|
|
425
|
+
binPath: bin,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
} catch (e: any) {
|
|
429
|
+
return { success: false, message: `Failed to install zls: ${e.message}` };
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// Lua: lua-language-server
|
|
434
|
+
if (norm === "lua") {
|
|
435
|
+
onProgress?.("Installing lua-language-server...");
|
|
436
|
+
const isWindows = process.platform === "win32";
|
|
437
|
+
try {
|
|
438
|
+
if (isWindows) {
|
|
439
|
+
execSync(
|
|
440
|
+
`winget install LuaLS.lua-language-server --accept-source-agreements --accept-package-agreements --silent`,
|
|
441
|
+
{ stdio: "pipe" },
|
|
442
|
+
);
|
|
443
|
+
} else if (process.platform === "darwin") {
|
|
444
|
+
execSync(`brew install lua-language-server`, { stdio: "pipe" });
|
|
445
|
+
}
|
|
446
|
+
clearExecutableCache();
|
|
447
|
+
const bin = findExecutable("lua-language-server");
|
|
448
|
+
if (bin) {
|
|
449
|
+
return {
|
|
450
|
+
success: true,
|
|
451
|
+
message: `Successfully installed lua-language-server (${bin})`,
|
|
452
|
+
binPath: bin,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
} catch (e: any) {
|
|
456
|
+
return {
|
|
457
|
+
success: false,
|
|
458
|
+
message: `Failed to install lua-language-server: ${e.message}`,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// Typst: tinymist
|
|
464
|
+
if (norm === "typst" || norm === "tinymist") {
|
|
465
|
+
onProgress?.("Installing tinymist...");
|
|
466
|
+
const isWindows = process.platform === "win32";
|
|
467
|
+
try {
|
|
468
|
+
if (isWindows) {
|
|
469
|
+
execSync(
|
|
470
|
+
`winget install Myriad-Dreamin.Tinymist --accept-source-agreements --accept-package-agreements --silent`,
|
|
471
|
+
{ stdio: "pipe" },
|
|
472
|
+
);
|
|
473
|
+
} else if (process.platform === "darwin") {
|
|
474
|
+
execSync(`brew install tinymist`, { stdio: "pipe" });
|
|
475
|
+
} else {
|
|
476
|
+
execSync(`cargo install --locked tinymist`, { stdio: "pipe" });
|
|
477
|
+
}
|
|
478
|
+
clearExecutableCache();
|
|
479
|
+
const bin = findExecutable("tinymist");
|
|
480
|
+
if (bin) {
|
|
481
|
+
return {
|
|
482
|
+
success: true,
|
|
483
|
+
message: `Successfully installed tinymist (${bin})`,
|
|
484
|
+
binPath: bin,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
} catch (e: any) {
|
|
488
|
+
return {
|
|
489
|
+
success: false,
|
|
490
|
+
message: `Failed to install tinymist: ${e.message}`,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// C#: csharp-ls via dotnet
|
|
496
|
+
if (norm === "csharp" || norm === "cs") {
|
|
497
|
+
onProgress?.("Installing csharp-ls via dotnet tool...");
|
|
498
|
+
try {
|
|
499
|
+
execSync(`dotnet tool install -g csharp-ls`, { stdio: "pipe" });
|
|
500
|
+
clearExecutableCache();
|
|
501
|
+
const bin = findExecutable("csharp-ls");
|
|
502
|
+
return {
|
|
503
|
+
success: true,
|
|
504
|
+
message: `Successfully installed csharp-ls (${bin || "csharp-ls"})`,
|
|
505
|
+
binPath: bin || undefined,
|
|
506
|
+
};
|
|
507
|
+
} catch (e: any) {
|
|
508
|
+
return {
|
|
509
|
+
success: false,
|
|
510
|
+
message: `Failed to install csharp-ls: ${e.message}`,
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Ruby: ruby-lsp via gem
|
|
516
|
+
if (norm === "ruby" || norm === "rb") {
|
|
517
|
+
onProgress?.("Installing ruby-lsp via gem...");
|
|
518
|
+
try {
|
|
519
|
+
execSync(`gem install ruby-lsp`, { stdio: "pipe" });
|
|
520
|
+
clearExecutableCache();
|
|
521
|
+
const bin = findExecutable("ruby-lsp");
|
|
522
|
+
return {
|
|
523
|
+
success: true,
|
|
524
|
+
message: `Successfully installed ruby-lsp (${bin || "ruby-lsp"})`,
|
|
525
|
+
binPath: bin || undefined,
|
|
526
|
+
};
|
|
527
|
+
} catch (e: any) {
|
|
528
|
+
return {
|
|
529
|
+
success: false,
|
|
530
|
+
message: `Failed to install ruby-lsp: ${e.message}`,
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// SQL: sqls via go
|
|
536
|
+
if (norm === "sql" || norm === "sqls") {
|
|
537
|
+
onProgress?.("Installing sqls via go install...");
|
|
538
|
+
try {
|
|
539
|
+
execSync(`go install github.com/sqls-server/sqls@latest`, {
|
|
540
|
+
stdio: "pipe",
|
|
541
|
+
});
|
|
542
|
+
clearExecutableCache();
|
|
543
|
+
const bin = findExecutable("sqls");
|
|
544
|
+
return {
|
|
545
|
+
success: true,
|
|
546
|
+
message: `Successfully installed sqls (${bin || "sqls"})`,
|
|
547
|
+
binPath: bin || undefined,
|
|
548
|
+
};
|
|
549
|
+
} catch (e: any) {
|
|
550
|
+
return {
|
|
551
|
+
success: false,
|
|
552
|
+
message: `Failed to install sqls: ${e.message}`,
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// LaTeX: texlab via cargo
|
|
558
|
+
if (norm === "latex" || norm === "tex" || norm === "texlab") {
|
|
559
|
+
onProgress?.("Installing texlab via cargo...");
|
|
560
|
+
try {
|
|
561
|
+
execSync(`cargo install --locked texlab`, { stdio: "pipe" });
|
|
562
|
+
clearExecutableCache();
|
|
563
|
+
const bin = findExecutable("texlab");
|
|
564
|
+
return {
|
|
565
|
+
success: true,
|
|
566
|
+
message: `Successfully installed texlab (${bin || "texlab"})`,
|
|
567
|
+
binPath: bin || undefined,
|
|
568
|
+
};
|
|
569
|
+
} catch (e: any) {
|
|
570
|
+
return {
|
|
571
|
+
success: false,
|
|
572
|
+
message: `Failed to install texlab: ${e.message}`,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// Protobuf: protols via cargo
|
|
578
|
+
if (norm === "protobuf" || norm === "proto" || norm === "protols") {
|
|
579
|
+
onProgress?.("Installing protols via cargo...");
|
|
580
|
+
try {
|
|
581
|
+
execSync(`cargo install --locked protols`, { stdio: "pipe" });
|
|
582
|
+
clearExecutableCache();
|
|
583
|
+
const bin = findExecutable("protols");
|
|
584
|
+
return {
|
|
585
|
+
success: true,
|
|
586
|
+
message: `Successfully installed protols (${bin || "protols"})`,
|
|
587
|
+
binPath: bin || undefined,
|
|
588
|
+
};
|
|
589
|
+
} catch (e: any) {
|
|
590
|
+
return {
|
|
591
|
+
success: false,
|
|
592
|
+
message: `Failed to install protols: ${e.message}`,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
const hint =
|
|
598
|
+
LSP_SERVERS[norm]?.installHint ||
|
|
599
|
+
"No automated installer available for this language.";
|
|
600
|
+
return {
|
|
601
|
+
success: false,
|
|
602
|
+
message: `Manual installation required for '${norm}'. Recommended: ${hint}`,
|
|
603
|
+
};
|
|
604
|
+
}
|