@mrclrchtr/supi-lsp 2.2.0 → 2.2.1
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-code-runtime",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "SuPi code-runtime — shared workspace context, capability contracts, and canonical types for the code-understanding stack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!__tests__"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mrclrchtr/supi-core": "2.2.
|
|
32
|
+
"@mrclrchtr/supi-core": "2.2.1"
|
|
33
33
|
},
|
|
34
34
|
"bundledDependencies": [
|
|
35
35
|
"@mrclrchtr/supi-core"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "SuPi LSP extension — Language Server Protocol integration for pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vscode-jsonrpc": "^9.0.0",
|
|
39
39
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
40
40
|
"vscode-languageserver-types": "^3.17.5",
|
|
41
|
-
"@mrclrchtr/supi-code-runtime": "2.2.
|
|
42
|
-
"@mrclrchtr/supi-core": "2.2.
|
|
41
|
+
"@mrclrchtr/supi-code-runtime": "2.2.1",
|
|
42
|
+
"@mrclrchtr/supi-core": "2.2.1"
|
|
43
43
|
},
|
|
44
44
|
"bundledDependencies": [
|
|
45
45
|
"@mrclrchtr/supi-code-runtime",
|
package/src/client/client.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Handles initialize handshake, document sync, shutdown, and crash recovery.
|
|
3
3
|
|
|
4
4
|
// biome-ignore lint/style/noExcessiveLinesPerFile: LspClient remains a cohesive stateful wrapper; refresh logic is already split out.
|
|
5
|
-
import { type ChildProcess, spawn } from "node:child_process";
|
|
5
|
+
import { type ChildProcess, execSync, spawn } from "node:child_process";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import * as path from "node:path";
|
|
8
8
|
import { recordDebugEvent } from "@mrclrchtr/supi-core/debug";
|
|
@@ -37,6 +37,31 @@ import { JsonRpcClient, JsonRpcRequestError } from "./transport.ts";
|
|
|
37
37
|
const SHUTDOWN_TIMEOUT_MS = 5_000;
|
|
38
38
|
const DIAGNOSTIC_WAIT_MS = 3_000;
|
|
39
39
|
|
|
40
|
+
// ── Process-tree cleanup ──────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Kill a process and all its descendants.
|
|
44
|
+
*
|
|
45
|
+
* On Unix, sends SIGTERM to the process group (negative PID).
|
|
46
|
+
* This requires the child to be spawned with `detached: true`.
|
|
47
|
+
* On Windows, uses `taskkill /T /F` to force-kill the entire tree.
|
|
48
|
+
*/
|
|
49
|
+
function killProcessTree(pid: number): void {
|
|
50
|
+
if (process.platform === "win32") {
|
|
51
|
+
try {
|
|
52
|
+
execSync(`taskkill /PID ${pid} /T /F`, { stdio: "ignore" });
|
|
53
|
+
} catch {
|
|
54
|
+
// Process may have already exited — ignore.
|
|
55
|
+
}
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
process.kill(-pid, "SIGTERM");
|
|
60
|
+
} catch {
|
|
61
|
+
// Process group may already be dead — ignore.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
40
65
|
// ── Types ─────────────────────────────────────────────────────────────
|
|
41
66
|
export type ClientStatus = "initializing" | "running" | "error" | "shutdown";
|
|
42
67
|
|
|
@@ -116,6 +141,10 @@ export class LspClient {
|
|
|
116
141
|
cwd: this.root,
|
|
117
142
|
stdio: ["pipe", "pipe", "pipe"],
|
|
118
143
|
env: { ...process.env },
|
|
144
|
+
// Run the server in its own process group so we can atomically
|
|
145
|
+
// kill the entire tree (server + subprocesses like tsserver)
|
|
146
|
+
// with `process.kill(-pid, signal)` on Unix or `taskkill /T` on Windows.
|
|
147
|
+
detached: true,
|
|
119
148
|
});
|
|
120
149
|
} catch (err) {
|
|
121
150
|
this._status = "error";
|
|
@@ -209,18 +238,26 @@ export class LspClient {
|
|
|
209
238
|
|
|
210
239
|
this.rpc.dispose();
|
|
211
240
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
241
|
+
// Kill the entire process tree (server + subprocesses like tsserver).
|
|
242
|
+
// The LSP shutdown/exit protocol above should trigger a graceful exit,
|
|
243
|
+
// but the process-group kill ensures no orphans survive.
|
|
244
|
+
const pid = this.process.pid;
|
|
245
|
+
if (this.process.exitCode === null && pid) {
|
|
246
|
+
killProcessTree(pid);
|
|
247
|
+
if (process.platform !== "win32") {
|
|
248
|
+
// Escalate to SIGKILL after a brief grace period on Unix.
|
|
249
|
+
// Windows taskkill /F is already forceful.
|
|
250
|
+
await new Promise<void>((resolve) => {
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
try {
|
|
253
|
+
process.kill(-pid, "SIGKILL");
|
|
254
|
+
} catch {
|
|
255
|
+
// Already dead — ignore.
|
|
256
|
+
}
|
|
257
|
+
resolve();
|
|
258
|
+
}, 500);
|
|
222
259
|
});
|
|
223
|
-
}
|
|
260
|
+
}
|
|
224
261
|
}
|
|
225
262
|
|
|
226
263
|
this.openDocs.clear();
|