From 63072a9dbbbcc8afef9360bbe2288e3481e74023 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:28:37 +0900 Subject: [PATCH 01/10] chore: add lsp-tools-mcp upstream as git submodule at packages/lsp-tools-mcp --- .gitmodules | 3 +++ packages/lsp-tools-mcp | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 packages/lsp-tools-mcp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3f36f2b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "packages/lsp-tools-mcp"] + path = packages/lsp-tools-mcp + url = https://github.com/code-yeongyu/lsp-tools-mcp.git diff --git a/packages/lsp-tools-mcp b/packages/lsp-tools-mcp new file mode 160000 index 0000000..ff2c514 --- /dev/null +++ b/packages/lsp-tools-mcp @@ -0,0 +1 @@ +Subproject commit ff2c5145e8333ac3e0eeae4b3dcfdcffe2325134 From cad581941f288a2bbea2300b94c2fe395c08746b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:30:24 +0900 Subject: [PATCH 02/10] chore: depend on lsp-tools-mcp via file dep and prebuild submodule --- .github/workflows/ci.yml | 2 ++ .github/workflows/publish.yml | 2 ++ package-lock.json | 24 ++++++++++++++++++++++++ package.json | 14 +++++++++----- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cc7a16..208b2ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + with: + submodules: recursive - name: Setup Node ${{ matrix.node }} uses: actions/setup-node@v6 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4214a99..cff9b70 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,6 +20,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v6 + with: + submodules: recursive - name: Setup Node 22 uses: actions/setup-node@v6 diff --git a/package-lock.json b/package-lock.json index 9f63c93..a2a8942 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "@code-yeongyu/codex-lsp", "version": "0.1.0", "license": "MIT", + "dependencies": { + "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp" + }, "bin": { "codex-lsp": "dist/cli.js" }, @@ -196,6 +199,10 @@ "node": ">=14.21.3" } }, + "node_modules/@code-yeongyu/lsp-tools-mcp": { + "resolved": "packages/lsp-tools-mcp", + "link": true + }, "node_modules/@emnapi/core": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", @@ -1502,6 +1509,23 @@ "engines": { "node": ">=8" } + }, + "packages/lsp-tools-mcp": { + "name": "@code-yeongyu/lsp-tools-mcp", + "version": "0.1.0", + "license": "MIT", + "bin": { + "lsp-tools-mcp": "dist/cli.js" + }, + "devDependencies": { + "@biomejs/biome": "2.4.15", + "@types/node": "^25.7.0", + "typescript": "^6.0.3", + "vitest": "^4.1.5" + }, + "engines": { + "node": ">=20.0.0" + } } } } diff --git a/package.json b/package.json index 36fde53..5dce9f5 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,17 @@ "CHANGELOG.md" ], "scripts": { - "build": "tsc -p tsconfig.build.json", - "test": "vitest --run", + "prepare": "npm --prefix packages/lsp-tools-mcp install", + "build": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && tsc -p tsconfig.build.json", + "test": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && vitest --run", "test:watch": "vitest", "typecheck": "tsc --noEmit", - "lint": "biome check .", - "lint:fix": "biome check --write .", - "check": "tsc --noEmit && biome check . && npm run build" + "lint": "biome check src test", + "lint:fix": "biome check --write src test", + "check": "tsc --noEmit && biome check src test && npm run build" + }, + "dependencies": { + "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp" }, "devDependencies": { "@biomejs/biome": "2.4.15", From 8a083b5b2723f951c2c2b19ea75829e5b2b1c74b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:31:15 +0900 Subject: [PATCH 03/10] chore: add lsp-tools-mcp upstream as git submodule Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .gitmodules | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitmodules b/.gitmodules index 3f36f2b..f172b51 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "packages/lsp-tools-mcp"] path = packages/lsp-tools-mcp url = https://github.com/code-yeongyu/lsp-tools-mcp.git + branch = main From a6a5460c641520ac5d64424a3ff4484e8e40f480 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:32:15 +0900 Subject: [PATCH 04/10] chore: depend on lsp-tools-mcp and prebuild submodule Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a2a8942..90b04f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@code-yeongyu/codex-lsp", - "version": "0.1.0", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@code-yeongyu/codex-lsp", - "version": "0.1.0", + "version": "0.2.0", "license": "MIT", "dependencies": { "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp" diff --git a/package.json b/package.json index 5dce9f5..479c2fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@code-yeongyu/codex-lsp", - "version": "0.1.0", + "version": "0.2.0", "description": "Codex plugin that exposes Language Server Protocol tools and post-edit diagnostics.", "type": "module", "packageManager": "npm@11.12.1", From e5acb3a44dc5a3c63f391a2d96d1cf34de54cb3a Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:32:30 +0900 Subject: [PATCH 05/10] refactor: route cli and codex hook to upstream lsp runtime Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- dist/cli.js | 4 ++-- dist/cli.js.map | 2 +- dist/codex-hook.js | 2 +- dist/codex-hook.js.map | 2 +- src/cli.ts | 4 ++-- src/codex-hook.ts | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/cli.js b/dist/cli.js index ab21936..cbe5b54 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1,8 +1,8 @@ #!/usr/bin/env node import { argv, stderr } from "node:process"; +import { disposeDefaultLspManager } from "@code-yeongyu/lsp-tools-mcp/dist/lsp/manager.js"; +import { runMcpStdioServer } from "@code-yeongyu/lsp-tools-mcp/dist/mcp.js"; import { runPostToolUseHookCli } from "./codex-hook.js"; -import { disposeDefaultLspManager } from "./lsp/manager.js"; -import { runMcpStdioServer } from "./mcp.js"; async function main() { const [command = "mcp", subcommand = ""] = argv.slice(2); try { diff --git a/dist/cli.js.map b/dist/cli.js.map index 7e75a2b..8d1e490 100644 --- a/dist/cli.js.map +++ b/dist/cli.js.map @@ -1 +1 @@ -{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,KAAK,UAAU,IAAI;IAClB,MAAM,CAAC,OAAO,GAAG,KAAK,EAAE,UAAU,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAI,CAAC;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,UAAU,KAAK,eAAe,EAAE,CAAC;YAC1D,MAAM,qBAAqB,EAAE,CAAC;YAC9B,OAAO;QACR,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YACvB,MAAM,iBAAiB,EAAE,CAAC;YAC1B,OAAO;QACR,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACtB,CAAC;YAAS,CAAC;QACV,MAAM,wBAAwB,EAAE,CAAC;IAClC,CAAC;AACF,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAc,EAAE,EAAE;IACrC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7F,MAAM,wBAAwB,EAAE,CAAC;IACjC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACtB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/dist/codex-hook.js b/dist/codex-hook.js index 80c5234..69341bc 100644 --- a/dist/codex-hook.js +++ b/dist/codex-hook.js @@ -1,5 +1,5 @@ import { stdin as processStdin } from "node:process"; -import { executeLspDiagnostics } from "./tools.js"; +import { executeLspDiagnostics } from "@code-yeongyu/lsp-tools-mcp/dist/tools.js"; const MUTATION_TOOL_NAMES = new Set(["apply_patch", "write", "edit", "multiedit", "multi_edit"]); const CLEAN_DIAGNOSTICS_TEXT = "No diagnostics found"; const UNSUPPORTED_EXTENSION_TEXT = "No LSP server configured for extension:"; diff --git a/dist/codex-hook.js.map b/dist/codex-hook.js.map index 912dab9..f696ef1 100644 --- a/dist/codex-hook.js.map +++ b/dist/codex-hook.js.map @@ -1 +1 @@ -{"version":3,"file":"codex-hook.js","sourceRoot":"","sources":["../src/cod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IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAC,KAAkB,EAAE,KAAc;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QAC9B,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;AACF,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,KAAwB;IAChD,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QACjC,GAAG,IAAI,KAAK,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"} \ No newline at end of file diff --git a/src/cli.ts b/src/cli.ts index ff8dd61..9373ad7 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,9 +1,9 @@ #!/usr/bin/env node import { argv, stderr } from "node:process"; +import { disposeDefaultLspManager } from "@code-yeongyu/lsp-tools-mcp/dist/lsp/manager.js"; +import { runMcpStdioServer } from "@code-yeongyu/lsp-tools-mcp/dist/mcp.js"; import { runPostToolUseHookCli } from "./codex-hook.js"; -import { disposeDefaultLspManager } from "./lsp/manager.js"; -import { runMcpStdioServer } from "./mcp.js"; async function main(): Promise { const [command = "mcp", subcommand = ""] = argv.slice(2); diff --git a/src/codex-hook.ts b/src/codex-hook.ts index 990beae..8b66172 100644 --- a/src/codex-hook.ts +++ b/src/codex-hook.ts @@ -1,6 +1,6 @@ import { stdin as processStdin } from "node:process"; -import { executeLspDiagnostics } from "./tools.js"; +import { executeLspDiagnostics } from "@code-yeongyu/lsp-tools-mcp/dist/tools.js"; export type DiagnosticsRunner = (filePath: string) => Promise; From 4625cb5d739dce0cf8ffb781a2b63f12830b5378 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:32:47 +0900 Subject: [PATCH 06/10] chore: remove duplicated local mcp and lsp runtime Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- dist/lsp/cleanup-errors.d.ts | 2 - dist/lsp/cleanup-errors.d.ts.map | 1 - dist/lsp/cleanup-errors.js | 7 - dist/lsp/cleanup-errors.js.map | 1 - dist/lsp/client-wrapper.d.ts | 14 - dist/lsp/client-wrapper.d.ts.map | 1 - dist/lsp/client-wrapper.js | 110 ---- dist/lsp/client-wrapper.js.map | 1 - dist/lsp/client.d.ts | 21 - dist/lsp/client.d.ts.map | 1 - dist/lsp/client.js | 130 ----- dist/lsp/client.js.map | 1 - dist/lsp/config-loader.d.ts | 25 - dist/lsp/config-loader.d.ts.map | 1 - dist/lsp/config-loader.js | 100 ---- dist/lsp/config-loader.js.map | 1 - dist/lsp/connection.d.ts | 5 - dist/lsp/connection.d.ts.map | 1 - dist/lsp/connection.js | 67 --- dist/lsp/connection.js.map | 1 - dist/lsp/constants.d.ts | 11 - dist/lsp/constants.d.ts.map | 1 - dist/lsp/constants.js | 11 - dist/lsp/constants.js.map | 1 - dist/lsp/directory-diagnostics.d.ts | 4 - dist/lsp/directory-diagnostics.d.ts.map | 1 - dist/lsp/directory-diagnostics.js | 124 ----- dist/lsp/directory-diagnostics.js.map | 1 - dist/lsp/errors.d.ts | 36 -- dist/lsp/errors.d.ts.map | 1 - dist/lsp/errors.js | 57 --- dist/lsp/errors.js.map | 1 - dist/lsp/formatters.d.ts | 13 - dist/lsp/formatters.d.ts.map | 1 - dist/lsp/formatters.js | 109 ---- dist/lsp/formatters.js.map | 1 - dist/lsp/infer-extension.d.ts | 2 - dist/lsp/infer-extension.d.ts.map | 1 - dist/lsp/infer-extension.js | 59 --- dist/lsp/infer-extension.js.map | 1 - dist/lsp/json-rpc-connection.d.ts | 37 -- dist/lsp/json-rpc-connection.d.ts.map | 1 - dist/lsp/json-rpc-connection.js | 248 --------- dist/lsp/json-rpc-connection.js.map | 1 - dist/lsp/language-mappings.d.ts | 5 - dist/lsp/language-mappings.d.ts.map | 1 - dist/lsp/language-mappings.js | 170 ------ dist/lsp/language-mappings.js.map | 1 - dist/lsp/manager.d.ts | 48 -- dist/lsp/manager.d.ts.map | 1 - dist/lsp/manager.js | 308 ----------- dist/lsp/manager.js.map | 1 - dist/lsp/process.d.ts | 26 - dist/lsp/process.d.ts.map | 1 - dist/lsp/process.js | 124 ----- dist/lsp/process.js.map | 1 - dist/lsp/server-definitions.d.ts | 5 - dist/lsp/server-definitions.d.ts.map | 1 - dist/lsp/server-definitions.js | 159 ------ dist/lsp/server-definitions.js.map | 1 - dist/lsp/server-installation.d.ts | 3 - dist/lsp/server-installation.d.ts.map | 1 - dist/lsp/server-installation.js | 51 -- dist/lsp/server-installation.js.map | 1 - dist/lsp/server-resolution.d.ts | 12 - dist/lsp/server-resolution.d.ts.map | 1 - dist/lsp/server-resolution.js | 75 --- dist/lsp/server-resolution.js.map | 1 - dist/lsp/transport.d.ts | 26 - dist/lsp/transport.d.ts.map | 1 - dist/lsp/transport.js | 234 --------- dist/lsp/transport.js.map | 1 - dist/lsp/types.d.ts | 125 ----- dist/lsp/types.d.ts.map | 1 - dist/lsp/types.js | 2 - dist/lsp/types.js.map | 1 - dist/lsp/utils.d.ts | 4 - dist/lsp/utils.d.ts.map | 1 - dist/lsp/utils.js | 15 - dist/lsp/utils.js.map | 1 - dist/lsp/workspace-edit.d.ts | 9 - dist/lsp/workspace-edit.d.ts.map | 1 - dist/lsp/workspace-edit.js | 114 ----- dist/lsp/workspace-edit.js.map | 1 - dist/mcp.d.ts | 31 -- dist/mcp.d.ts.map | 1 - dist/mcp.js | 95 ---- dist/mcp.js.map | 1 - dist/tools.d.ts | 91 ---- dist/tools.d.ts.map | 1 - dist/tools.js | 453 ---------------- dist/tools.js.map | 1 - src/lsp/cleanup-errors.ts | 5 - src/lsp/client-wrapper.ts | 146 ------ src/lsp/client.ts | 170 ------ src/lsp/config-loader.ts | 128 ----- src/lsp/connection.ts | 69 --- src/lsp/constants.ts | 11 - src/lsp/directory-diagnostics.ts | 152 ------ src/lsp/errors.ts | 63 --- src/lsp/formatters.ts | 140 ----- src/lsp/infer-extension.ts | 65 --- src/lsp/json-rpc-connection.ts | 296 ----------- src/lsp/language-mappings.ts | 172 ------- src/lsp/manager.ts | 385 -------------- src/lsp/process.ts | 166 ------ src/lsp/server-definitions.ts | 162 ------ src/lsp/server-installation.ts | 57 --- src/lsp/server-resolution.ts | 92 ---- src/lsp/transport.ts | 272 ---------- src/lsp/types.ts | 126 ----- src/lsp/utils.ts | 14 - src/lsp/workspace-edit.ts | 132 ----- src/mcp.ts | 140 ----- src/tools.ts | 655 ------------------------ 115 files changed, 7041 deletions(-) delete mode 100644 dist/lsp/cleanup-errors.d.ts delete mode 100644 dist/lsp/cleanup-errors.d.ts.map delete mode 100644 dist/lsp/cleanup-errors.js delete mode 100644 dist/lsp/cleanup-errors.js.map delete mode 100644 dist/lsp/client-wrapper.d.ts delete mode 100644 dist/lsp/client-wrapper.d.ts.map delete mode 100644 dist/lsp/client-wrapper.js delete mode 100644 dist/lsp/client-wrapper.js.map delete mode 100644 dist/lsp/client.d.ts delete mode 100644 dist/lsp/client.d.ts.map delete mode 100644 dist/lsp/client.js delete mode 100644 dist/lsp/client.js.map delete mode 100644 dist/lsp/config-loader.d.ts delete mode 100644 dist/lsp/config-loader.d.ts.map delete mode 100644 dist/lsp/config-loader.js delete mode 100644 dist/lsp/config-loader.js.map delete mode 100644 dist/lsp/connection.d.ts delete mode 100644 dist/lsp/connection.d.ts.map delete mode 100644 dist/lsp/connection.js delete mode 100644 dist/lsp/connection.js.map delete mode 100644 dist/lsp/constants.d.ts delete mode 100644 dist/lsp/constants.d.ts.map delete mode 100644 dist/lsp/constants.js delete mode 100644 dist/lsp/constants.js.map delete mode 100644 dist/lsp/directory-diagnostics.d.ts delete mode 100644 dist/lsp/directory-diagnostics.d.ts.map delete mode 100644 dist/lsp/directory-diagnostics.js delete mode 100644 dist/lsp/directory-diagnostics.js.map delete mode 100644 dist/lsp/errors.d.ts delete mode 100644 dist/lsp/errors.d.ts.map delete mode 100644 dist/lsp/errors.js delete mode 100644 dist/lsp/errors.js.map delete mode 100644 dist/lsp/formatters.d.ts delete mode 100644 dist/lsp/formatters.d.ts.map delete mode 100644 dist/lsp/formatters.js delete mode 100644 dist/lsp/formatters.js.map delete mode 100644 dist/lsp/infer-extension.d.ts delete mode 100644 dist/lsp/infer-extension.d.ts.map delete mode 100644 dist/lsp/infer-extension.js delete mode 100644 dist/lsp/infer-extension.js.map delete mode 100644 dist/lsp/json-rpc-connection.d.ts delete mode 100644 dist/lsp/json-rpc-connection.d.ts.map delete mode 100644 dist/lsp/json-rpc-connection.js delete mode 100644 dist/lsp/json-rpc-connection.js.map delete mode 100644 dist/lsp/language-mappings.d.ts delete mode 100644 dist/lsp/language-mappings.d.ts.map delete mode 100644 dist/lsp/language-mappings.js delete mode 100644 dist/lsp/language-mappings.js.map delete mode 100644 dist/lsp/manager.d.ts delete mode 100644 dist/lsp/manager.d.ts.map delete mode 100644 dist/lsp/manager.js delete mode 100644 dist/lsp/manager.js.map delete mode 100644 dist/lsp/process.d.ts delete mode 100644 dist/lsp/process.d.ts.map delete mode 100644 dist/lsp/process.js delete mode 100644 dist/lsp/process.js.map delete mode 100644 dist/lsp/server-definitions.d.ts delete mode 100644 dist/lsp/server-definitions.d.ts.map delete mode 100644 dist/lsp/server-definitions.js delete mode 100644 dist/lsp/server-definitions.js.map delete mode 100644 dist/lsp/server-installation.d.ts delete mode 100644 dist/lsp/server-installation.d.ts.map delete mode 100644 dist/lsp/server-installation.js delete mode 100644 dist/lsp/server-installation.js.map delete mode 100644 dist/lsp/server-resolution.d.ts delete mode 100644 dist/lsp/server-resolution.d.ts.map delete mode 100644 dist/lsp/server-resolution.js delete mode 100644 dist/lsp/server-resolution.js.map delete mode 100644 dist/lsp/transport.d.ts delete mode 100644 dist/lsp/transport.d.ts.map delete mode 100644 dist/lsp/transport.js delete mode 100644 dist/lsp/transport.js.map delete mode 100644 dist/lsp/types.d.ts delete mode 100644 dist/lsp/types.d.ts.map delete mode 100644 dist/lsp/types.js delete mode 100644 dist/lsp/types.js.map delete mode 100644 dist/lsp/utils.d.ts delete mode 100644 dist/lsp/utils.d.ts.map delete mode 100644 dist/lsp/utils.js delete mode 100644 dist/lsp/utils.js.map delete mode 100644 dist/lsp/workspace-edit.d.ts delete mode 100644 dist/lsp/workspace-edit.d.ts.map delete mode 100644 dist/lsp/workspace-edit.js delete mode 100644 dist/lsp/workspace-edit.js.map delete mode 100644 dist/mcp.d.ts delete mode 100644 dist/mcp.d.ts.map delete mode 100644 dist/mcp.js delete mode 100644 dist/mcp.js.map delete mode 100644 dist/tools.d.ts delete mode 100644 dist/tools.d.ts.map delete mode 100644 dist/tools.js delete mode 100644 dist/tools.js.map delete mode 100644 src/lsp/cleanup-errors.ts delete mode 100644 src/lsp/client-wrapper.ts delete mode 100644 src/lsp/client.ts delete mode 100644 src/lsp/config-loader.ts delete mode 100644 src/lsp/connection.ts delete mode 100644 src/lsp/constants.ts delete mode 100644 src/lsp/directory-diagnostics.ts delete mode 100644 src/lsp/errors.ts delete mode 100644 src/lsp/formatters.ts delete mode 100644 src/lsp/infer-extension.ts delete mode 100644 src/lsp/json-rpc-connection.ts delete mode 100644 src/lsp/language-mappings.ts delete mode 100644 src/lsp/manager.ts delete mode 100644 src/lsp/process.ts delete mode 100644 src/lsp/server-definitions.ts delete mode 100644 src/lsp/server-installation.ts delete mode 100644 src/lsp/server-resolution.ts delete mode 100644 src/lsp/transport.ts delete mode 100644 src/lsp/types.ts delete mode 100644 src/lsp/utils.ts delete mode 100644 src/lsp/workspace-edit.ts delete mode 100644 src/mcp.ts delete mode 100644 src/tools.ts diff --git a/dist/lsp/cleanup-errors.d.ts b/dist/lsp/cleanup-errors.d.ts deleted file mode 100644 index 6030e79..0000000 --- a/dist/lsp/cleanup-errors.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare function reportBestEffortCleanupError(operation: string, error: unknown): void; -//# sourceMappingURL=cleanup-errors.d.ts.map \ No newline at end of file diff --git a/dist/lsp/cleanup-errors.d.ts.map b/dist/lsp/cleanup-errors.d.ts.map deleted file mode 100644 index 9459126..0000000 --- a/dist/lsp/cleanup-errors.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cleanup-errors.d.ts","sourceRoot":"","sources":["../../src/lsp/cleanup-errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAIpF"} \ No newline at end of file diff --git a/dist/lsp/cleanup-errors.js b/dist/lsp/cleanup-errors.js deleted file mode 100644 index f22fee5..0000000 --- a/dist/lsp/cleanup-errors.js +++ /dev/null @@ -1,7 +0,0 @@ -export function reportBestEffortCleanupError(operation, error) { - if (process.env.CODEX_LSP_DEBUG_CLEANUP !== "1") - return; - const message = error instanceof Error ? error.message : String(error); - console.error(`[codex-lsp] ignored ${operation} failure during cleanup: ${message}`); -} -//# sourceMappingURL=cleanup-errors.js.map \ No newline at end of file diff --git a/dist/lsp/cleanup-errors.js.map b/dist/lsp/cleanup-errors.js.map deleted file mode 100644 index 18288a4..0000000 --- a/dist/lsp/cleanup-errors.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cleanup-errors.js","sourceRoot":"","sources":["../../src/lsp/cleanup-errors.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,4BAA4B,CAAC,SAAiB,EAAE,KAAc;IAC7E,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,GAAG;QAAE,OAAO;IACxD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO,CAAC,KAAK,CAAC,uBAAuB,SAAS,4BAA4B,OAAO,EAAE,CAAC,CAAC;AACtF,CAAC"} \ No newline at end of file diff --git a/dist/lsp/client-wrapper.d.ts b/dist/lsp/client-wrapper.d.ts deleted file mode 100644 index 203f0f8..0000000 --- a/dist/lsp/client-wrapper.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { LspClient } from "./client.js"; -import { type LspManager } from "./manager.js"; -import type { ServerLookupResult } from "./types.js"; -export declare function isDirectoryPath(filePath: string): boolean; -export declare function findWorkspaceRoot(filePath: string): string; -export declare function formatServerLookupError(result: Exclude): string; -export interface WithLspClientOptions { - signal?: AbortSignal; - manager?: LspManager; -} -export declare function withLspClient(filePath: string, fn: (client: LspClient) => Promise, toolName: string, options?: WithLspClientOptions): Promise; -//# sourceMappingURL=client-wrapper.d.ts.map \ No newline at end of file diff --git a/dist/lsp/client-wrapper.d.ts.map b/dist/lsp/client-wrapper.d.ts.map deleted file mode 100644 index 91dfbfd..0000000 --- a/dist/lsp/client-wrapper.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"client-wrapper.d.ts","sourceRoot":"","sources":["../../src/lsp/client-wrapper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIrD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAMzD;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoB1D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,kBAAkB,EAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,GAAG,MAAM,CAkCxG;AAED,MAAM,WAAW,oBAAoB;IACpC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,UAAU,CAAC;CACrB;AAWD,wBAAsB,aAAa,CAAC,CAAC,EACpC,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,EACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,oBAAyB,GAChC,OAAO,CAAC,CAAC,CAAC,CA2CZ"} \ No newline at end of file diff --git a/dist/lsp/client-wrapper.js b/dist/lsp/client-wrapper.js deleted file mode 100644 index 385a185..0000000 --- a/dist/lsp/client-wrapper.js +++ /dev/null @@ -1,110 +0,0 @@ -import { existsSync, statSync } from "node:fs"; -import { dirname, extname, join, resolve } from "node:path"; -import { isLspDeadConnectionError, LspInvalidPathError, LspRequestTimeoutError, LspServerInitializingError, LspServerLookupError, } from "./errors.js"; -import { getLspManager } from "./manager.js"; -import { findServerForExtension } from "./server-resolution.js"; -const WORKSPACE_MARKERS = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"]; -export function isDirectoryPath(filePath) { - try { - return statSync(filePath).isDirectory(); - } - catch { - return false; - } -} -export function findWorkspaceRoot(filePath) { - const abs = resolve(filePath); - let dir = abs; - if (!isDirectoryPath(dir)) { - dir = dirname(dir); - } - let prevDir = ""; - while (dir !== prevDir) { - for (const marker of WORKSPACE_MARKERS) { - if (existsSync(join(dir, marker))) { - return dir; - } - } - prevDir = dir; - dir = dirname(dir); - } - return dirname(abs); -} -export function formatServerLookupError(result) { - if (result.status === "not_installed") { - const { server, installHint } = result; - return [ - `LSP server '${server.id}' is configured but NOT INSTALLED.`, - "", - `Command not found: ${server.command[0]}`, - "", - "To install:", - ` ${installHint}`, - "", - `Supported extensions: ${server.extensions.join(", ")}`, - "", - "After installation, the server will be available automatically.", - ].join("\n"); - } - return [ - `No LSP server configured for extension: ${result.extension}`, - "", - `Available servers: ${result.availableServers.slice(0, 10).join(", ")}${result.availableServers.length > 10 ? "..." : ""}`, - "", - "Configure a custom server in '.codex/lsp-client.json':", - " {", - ' "lsp": {', - ' "my-server": {', - ' "command": ["my-lsp", "--stdio"],', - ` "extensions": ["${result.extension}"]`, - " }", - " }", - " }", - ].join("\n"); -} -const READ_ONLY_RETRY_TOOLS = new Set([ - "diagnostics", - "definition", - "references", - "documentSymbols", - "workspaceSymbols", - "prepareRename", -]); -export async function withLspClient(filePath, fn, toolName, options = {}) { - const absPath = resolve(filePath); - if (isDirectoryPath(absPath)) { - throw new LspInvalidPathError("Directory paths are not supported by this LSP tool. " + - "Use lsp.diagnostics with a directory path for directory diagnostics."); - } - const ext = extname(absPath); - const result = findServerForExtension(ext); - if (result.status !== "found") { - throw new LspServerLookupError(formatServerLookupError(result)); - } - const server = result.server; - const root = findWorkspaceRoot(absPath); - const manager = options.manager ?? getLspManager(); - const acquireAndCall = async (allowRetry) => { - const client = await manager.getClient(root, server, options.signal); - try { - return await fn(client); - } - catch (err) { - if (allowRetry && READ_ONLY_RETRY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) { - manager.invalidateClient(root, server.id, client); - return acquireAndCall(false); - } - if (err instanceof LspRequestTimeoutError) { - if (manager.isServerInitializing(root, server.id)) { - throw new LspServerInitializingError(err); - } - } - throw err; - } - finally { - manager.releaseClient(root, server.id); - } - }; - return acquireAndCall(true); -} -//# sourceMappingURL=client-wrapper.js.map \ No newline at end of file diff --git a/dist/lsp/client-wrapper.js.map b/dist/lsp/client-wrapper.js.map deleted file mode 100644 index 1ddbb83..0000000 --- a/dist/lsp/client-wrapper.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"client-wrapper.js","sourceRoot":"","sources":["../../src/lsp/client-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG5D,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAmB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;AAExH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC/C,IAAI,CAAC;QACJ,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,QAAgB;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAI,GAAG,GAAG,GAAG,CAAC;IAEd,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB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QAAQ,CAAC,IAAI,wBAAwB,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxF,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;gBAClD,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC;YAED,IAAI,GAAG,YAAY,sBAAsB,EAAE,CAAC;gBAC3C,IAAI,OAAO,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnD,MAAM,IAAI,0BAA0B,CAAC,GAAG,CAAC,CAAC;gBAC3C,CAAC;YACF,CAAC;YACD,MAAM,GAAG,CAAC;QACX,CAAC;gBAAS,CAAC;YACV,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;QACxC,CAAC;IACF,CAAC,CAAC;IAEF,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"} \ No newline at end of file diff --git a/dist/lsp/client.d.ts b/dist/lsp/client.d.ts deleted file mode 100644 index a107b26..0000000 --- a/dist/lsp/client.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { LspClientConnection } from "./connection.js"; -import type { Diagnostic, DocumentSymbol, Location, LocationLink, PrepareRenameDefaultBehavior, PrepareRenameResult, Range, SymbolInfo, WorkspaceEdit } from "./types.js"; -export declare class LspClient extends LspClientConnection { - private readonly openedFiles; - private readonly documentVersions; - private readonly lastSyncedText; - private readonly diagnosticPullErrors; - getDiagnosticPullErrors(): readonly Error[]; - openFile(filePath: string): Promise; - definition(filePath: string, line: number, character: number): Promise | null>; - references(filePath: string, line: number, character: number, includeDeclaration?: boolean): Promise; - documentSymbols(filePath: string): Promise>; - workspaceSymbols(query: string): Promise; - private isUnsupportedDiagnosticPullError; - diagnostics(filePath: string): Promise<{ - items: Diagnostic[]; - }>; - prepareRename(filePath: string, line: number, character: number): Promise; - rename(filePath: string, line: number, character: number, newName: string): Promise; -} -//# sourceMappingURL=client.d.ts.map \ No newline at end of file diff --git a/dist/lsp/client.d.ts.map b/dist/lsp/client.d.ts.map deleted file mode 100644 index 46a5c3c..0000000 --- a/dist/lsp/client.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lsp/client.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EACX,UAAU,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,EACL,UAAU,EACV,aAAa,EACb,MAAM,YAAY,CAAC;AAKpB,qBAAa,SAAU,SAAQ,mBAAmB;IACjD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;IAC5D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAe;IAEpD,uBAAuB,IAAI,SAAS,KAAK,EAAE;IAIrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CzC,UAAU,CACf,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,GAAG,YAAY,GAAG,KAAK,CAAC,QAAQ,GAAG,YAAY,CAAC,GAAG,IAAI,CAAC;IAYrE,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,UAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAU7G,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,UAAU,CAAC,CAAC;IAQ9E,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI5D,OAAO,CAAC,gCAAgC;IAOlC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,UAAU,EAAE,CAAA;KAAE,CAAC;IAsB/D,aAAa,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,GAAG,4BAA4B,GAAG,KAAK,GAAG,IAAI,CAAC;IAYvE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;CAS/G"} \ No newline at end of file diff --git a/dist/lsp/client.js b/dist/lsp/client.js deleted file mode 100644 index c49ea31..0000000 --- a/dist/lsp/client.js +++ /dev/null @@ -1,130 +0,0 @@ -import { readFileSync } from "node:fs"; -import { extname, resolve } from "node:path"; -import { pathToFileURL } from "node:url"; -import { LspClientConnection } from "./connection.js"; -import { getLanguageId } from "./language-mappings.js"; -const POST_OPEN_DELAY_MS = 1000; -const POST_DIAGNOSTICS_WAIT_MS = 500; -export class LspClient extends LspClientConnection { - constructor() { - super(...arguments); - this.openedFiles = new Set(); - this.documentVersions = new Map(); - this.lastSyncedText = new Map(); - this.diagnosticPullErrors = []; - } - getDiagnosticPullErrors() { - return this.diagnosticPullErrors; - } - async openFile(filePath) { - const absPath = resolve(filePath); - const uri = pathToFileURL(absPath).href; - const text = readFileSync(absPath, "utf-8"); - if (!this.openedFiles.has(absPath)) { - const ext = extname(absPath); - const languageId = getLanguageId(ext); - const version = 1; - await this.sendNotification("textDocument/didOpen", { - textDocument: { - uri, - languageId, - version, - text, - }, - }); - this.openedFiles.add(absPath); - this.documentVersions.set(uri, version); - this.lastSyncedText.set(uri, text); - await new Promise((r) => setTimeout(r, POST_OPEN_DELAY_MS)); - return; - } - const prevText = this.lastSyncedText.get(uri); - if (prevText === text) { - return; - } - const nextVersion = (this.documentVersions.get(uri) ?? 1) + 1; - this.documentVersions.set(uri, nextVersion); - this.lastSyncedText.set(uri, text); - await this.sendNotification("textDocument/didChange", { - textDocument: { uri, version: nextVersion }, - contentChanges: [{ text }], - }); - await this.sendNotification("textDocument/didSave", { - textDocument: { uri }, - text, - }); - } - async definition(filePath, line, character) { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/definition", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - }); - } - async references(filePath, line, character, includeDeclaration = true) { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/references", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - context: { includeDeclaration }, - }); - } - async documentSymbols(filePath) { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/documentSymbol", { - textDocument: { uri: pathToFileURL(absPath).href }, - }); - } - async workspaceSymbols(query) { - return this.sendRequest("workspace/symbol", { query }); - } - isUnsupportedDiagnosticPullError(error) { - if (!(error instanceof Error)) - return false; - const code = "code" in error && typeof error.code === "number" ? error.code : undefined; - if (code === -32601) - return true; - return /unsupported|not supported|method not found|unknown request/i.test(error.message); - } - async diagnostics(filePath) { - const absPath = resolve(filePath); - const uri = pathToFileURL(absPath).href; - await this.openFile(absPath); - await new Promise((r) => setTimeout(r, POST_DIAGNOSTICS_WAIT_MS)); - try { - const result = await this.sendRequest("textDocument/diagnostic", { - textDocument: { uri }, - }); - if (result.items) { - return { items: result.items }; - } - } - catch (error) { - if (!this.isUnsupportedDiagnosticPullError(error)) { - this.diagnosticPullErrors.push(error instanceof Error ? error : new Error(String(error))); - } - } - return { items: this.getStoredDiagnostics(uri) }; - } - async prepareRename(filePath, line, character) { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/prepareRename", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - }); - } - async rename(filePath, line, character, newName) { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/rename", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - newName, - }); - } -} -//# sourceMappingURL=client.js.map \ No newline at end of file diff --git a/dist/lsp/client.js.map b/dist/lsp/client.js.map deleted file mode 100644 index 7b3c049..0000000 --- a/dist/lsp/client.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lsp/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAavD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,MAAM,OAAO,SAAU,SAAQ,mBAAmB;IAAlD;;QACkB,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QAChC,qBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC7C,mBAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC3C,yBAAoB,GAAY,EAAE,CAAC;IAgJrD,CAAC;IA9IA,uBAAuB;QACtB,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAClC,MAAM,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC;QACxC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;Q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,CAAC,CAAC;IACJ,CAAC;CACD"} \ No newline at end of file diff --git a/dist/lsp/config-loader.d.ts b/dist/lsp/config-loader.d.ts deleted file mode 100644 index 0cd8e37..0000000 --- a/dist/lsp/config-loader.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ResolvedServer } from "./types.js"; -interface LspEntry { - disabled?: boolean; - command?: string[]; - extensions?: string[]; - priority?: number; - env?: Record; - initialization?: Record; -} -interface ConfigJson { - lsp?: Record; -} -type ConfigSource = "project" | "user"; -export interface ServerWithSource extends ResolvedServer { - source: "project" | "user" | "builtin"; -} -export declare function getConfigPaths(): { - project: string; - user: string; -}; -export declare function loadAllConfigs(): Map; -export declare function getMergedServers(): ServerWithSource[]; -export declare function getDisabledServerIds(): Set; -export {}; -//# sourceMappingURL=config-loader.d.ts.map \ No newline at end of file diff --git a/dist/lsp/config-loader.d.ts.map b/dist/lsp/config-loader.d.ts.map deleted file mode 100644 index 4c4fd43..0000000 --- a/dist/lsp/config-loader.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/lsp/config-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,UAAU,QAAQ;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,UAAU,UAAU;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC/B;AAED,KAAK,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvC,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACvD,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,wBAAgB,cAAc,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAMlE;AAWD,wBAAgB,cAAc,IAAI,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAW9D;AAED,wBAAgB,gBAAgB,IAAI,gBAAgB,EAAE,CAyDrD;AAED,wBAAgB,oBAAoB,IAAI,GAAG,CAAC,MAAM,CAAC,CAYlD"} \ No newline at end of file diff --git a/dist/lsp/config-loader.js b/dist/lsp/config-loader.js deleted file mode 100644 index 2428039..0000000 --- a/dist/lsp/config-loader.js +++ /dev/null @@ -1,100 +0,0 @@ -import { existsSync, readFileSync } from "node:fs"; -import { homedir } from "node:os"; -import { join } from "node:path"; -import { BUILTIN_SERVERS } from "./server-definitions.js"; -export function getConfigPaths() { - const cwd = process.cwd(); - return { - project: join(cwd, ".codex", "lsp-client.json"), - user: join(homedir(), ".codex", "lsp-client.json"), - }; -} -function loadJsonFile(path) { - if (!existsSync(path)) - return null; - try { - return JSON.parse(readFileSync(path, "utf-8")); - } - catch { - return null; - } -} -export function loadAllConfigs() { - const paths = getConfigPaths(); - const configs = new Map(); - const project = loadJsonFile(paths.project); - if (project) - configs.set("project", project); - const user = loadJsonFile(paths.user); - if (user) - configs.set("user", user); - return configs; -} -export function getMergedServers() { - const configs = loadAllConfigs(); - const servers = []; - const disabled = new Set(); - const seen = new Set(); - const sources = ["project", "user"]; - for (const source of sources) { - const config = configs.get(source); - if (!config?.lsp) - continue; - for (const [id, entry] of Object.entries(config.lsp)) { - if (entry.disabled) { - disabled.add(id); - continue; - } - if (seen.has(id)) - continue; - if (!entry.command || !entry.extensions) - continue; - servers.push({ - id, - command: entry.command, - extensions: entry.extensions, - priority: entry.priority ?? 0, - env: entry.env, - initialization: entry.initialization, - source, - }); - seen.add(id); - } - } - for (const [id, config] of Object.entries(BUILTIN_SERVERS)) { - if (disabled.has(id) || seen.has(id)) - continue; - servers.push({ - id, - command: config.command, - extensions: config.extensions, - priority: -100, - source: "builtin", - }); - } - return servers.sort((a, b) => { - if (a.source !== b.source) { - const order = { - project: 0, - user: 1, - builtin: 2, - }; - return order[a.source] - order[b.source]; - } - return b.priority - a.priority; - }); -} -export function getDisabledServerIds() { - const configs = loadAllConfigs(); - const disabled = new Set(); - for (const config of configs.values()) { - if (!config.lsp) - continue; - for (const [id, entry] of Object.entries(config.lsp)) { - if (entry.disabled) - disabled.add(id); - } - } - return disabled; -} -//# sourceMappingURL=config-loader.js.map \ No newline at end of file diff --git a/dist/lsp/config-loader.js.map b/dist/lsp/config-loader.js.map deleted file mode 100644 index 3d4811e..0000000 --- a/dist/lsp/config-loader.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../../src/lsp/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAsB1D,MAAM,UAAU,cAAc;IAC7B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,OAAO;QACN,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,iBAAiB,CAAC;QAC/C,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,iBAAiB,CAAC;KAClD,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,C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AC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;IAChC,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG;YAAE,SAAS;QAC1B,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACtD,IAAI,KAAK,CAAC,QAAQ;gBAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC"} \ No newline at end of file diff --git a/dist/lsp/connection.d.ts b/dist/lsp/connection.d.ts deleted file mode 100644 index 393cd25..0000000 --- a/dist/lsp/connection.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { LspClientTransport } from "./transport.js"; -export declare class LspClientConnection extends LspClientTransport { - initialize(): Promise; -} -//# sourceMappingURL=connection.d.ts.map \ No newline at end of file diff --git a/dist/lsp/connection.d.ts.map b/dist/lsp/connection.d.ts.map deleted file mode 100644 index e475d44..0000000 --- a/dist/lsp/connection.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/lsp/connection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,qBAAa,mBAAoB,SAAQ,kBAAkB;IACpD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CA6DjC"} \ No newline at end of file diff --git a/dist/lsp/connection.js b/dist/lsp/connection.js deleted file mode 100644 index dd19895..0000000 --- a/dist/lsp/connection.js +++ /dev/null @@ -1,67 +0,0 @@ -import { pathToFileURL } from "node:url"; -import { LspClientTransport } from "./transport.js"; -const INITIALIZE_SETTLE_MS = 300; -export class LspClientConnection extends LspClientTransport { - async initialize() { - const rootUri = pathToFileURL(this.root).href; - await this.sendRequest("initialize", { - processId: process.pid, - rootUri, - rootPath: this.root, - workspaceFolders: [{ uri: rootUri, name: "workspace" }], - capabilities: { - textDocument: { - hover: { contentFormat: ["markdown", "plaintext"] }, - definition: { linkSupport: true }, - references: {}, - documentSymbol: { hierarchicalDocumentSymbolSupport: true }, - publishDiagnostics: {}, - rename: { - prepareSupport: true, - prepareSupportDefaultBehavior: 1, - honorsChangeAnnotations: true, - }, - codeAction: { - codeActionLiteralSupport: { - codeActionKind: { - valueSet: [ - "quickfix", - "refactor", - "refactor.extract", - "refactor.inline", - "refactor.rewrite", - "source", - "source.organizeImports", - "source.fixAll", - ], - }, - }, - isPreferredSupport: true, - disabledSupport: true, - dataSupport: true, - resolveSupport: { - properties: ["edit", "command"], - }, - }, - }, - workspace: { - symbol: {}, - workspaceFolders: true, - configuration: true, - applyEdit: true, - workspaceEdit: { - documentChanges: true, - }, - }, - }, - initializationOptions: this.server.initialization, - }); - await this.sendNotification("initialized"); - await this.sendNotification("workspace/didChangeConfiguration", { - settings: { json: { validate: { enable: true } } }, - }); - // Some servers accept initialized before their diagnostics/indexing handlers are ready. - await new Promise((r) => setTimeout(r, INITIALIZE_SETTLE_MS)); - } -} -//# sourceMappingURL=connection.js.map \ No newline at end of file diff --git a/dist/lsp/connection.js.map b/dist/lsp/connection.js.map deleted file mode 100644 index ed51a43..0000000 --- a/dist/lsp/connection.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/lsp/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MA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;oBACtB,aAAa,EAAE,IAAI;oBACnB,SAAS,EAAE,IAAI;oBACf,aAAa,EAAE;wBACd,eAAe,EAAE,IAAI;qBACrB;iBACD;aACD;YACD,qBAAqB,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc;SACjD,CAAC,CAAC;QACH,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC3C,MAAM,IAAI,CAAC,gBAAgB,CAAC,kCAAkC,EAAE;YAC/D,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;SAClD,CAAC,CAAC;QACH,wFAAwF;QACxF,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAC/D,CAAC;CACD"} \ No newline at end of file diff --git a/dist/lsp/constants.d.ts b/dist/lsp/constants.d.ts deleted file mode 100644 index c04c816..0000000 --- a/dist/lsp/constants.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export declare const DEFAULT_MAX_REFERENCES = 200; -export declare const DEFAULT_MAX_SYMBOLS = 200; -export declare const DEFAULT_MAX_DIAGNOSTICS = 200; -export declare const DEFAULT_MAX_DIRECTORY_FILES = 50; -export declare const REQUEST_TIMEOUT_MS = 15000; -export declare const INIT_TIMEOUT_MS = 60000; -export declare const IDLE_TIMEOUT_MS: number; -export declare const REAPER_INTERVAL_MS = 60000; -export declare const STOP_HARD_KILL_TIMEOUT_MS = 5000; -export declare const STOP_SIGKILL_GRACE_MS = 1000; -//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/dist/lsp/constants.d.ts.map b/dist/lsp/constants.d.ts.map deleted file mode 100644 index 3ac43d5..0000000 --- a/dist/lsp/constants.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lsp/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAC1C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAC/C,eAAO,MAAM,qBAAqB,OAAQ,CAAC"} \ No newline at end of file diff --git a/dist/lsp/constants.js b/dist/lsp/constants.js deleted file mode 100644 index 3f24585..0000000 --- a/dist/lsp/constants.js +++ /dev/null @@ -1,11 +0,0 @@ -export const DEFAULT_MAX_REFERENCES = 200; -export const DEFAULT_MAX_SYMBOLS = 200; -export const DEFAULT_MAX_DIAGNOSTICS = 200; -export const DEFAULT_MAX_DIRECTORY_FILES = 50; -export const REQUEST_TIMEOUT_MS = 15_000; -export const INIT_TIMEOUT_MS = 60_000; -export const IDLE_TIMEOUT_MS = 5 * 60_000; -export const REAPER_INTERVAL_MS = 60_000; -export const STOP_HARD_KILL_TIMEOUT_MS = 5_000; -export const STOP_SIGKILL_GRACE_MS = 1_000; -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/dist/lsp/constants.js.map b/dist/lsp/constants.js.map deleted file mode 100644 index 88876b6..0000000 --- a/dist/lsp/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lsp/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAC;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC"} \ No newline at end of file diff --git a/dist/lsp/directory-diagnostics.d.ts b/dist/lsp/directory-diagnostics.d.ts deleted file mode 100644 index 0ed9a2a..0000000 --- a/dist/lsp/directory-diagnostics.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { SeverityFilter } from "./types.js"; -export declare function collectFilesWithExtension(dir: string, extension: string, maxFiles: number): string[]; -export declare function aggregateDiagnosticsForDirectory(directory: string, extension: string, severity?: SeverityFilter, maxFiles?: number): Promise; -//# sourceMappingURL=directory-diagnostics.d.ts.map \ No newline at end of file diff --git a/dist/lsp/directory-diagnostics.d.ts.map b/dist/lsp/directory-diagnostics.d.ts.map deleted file mode 100644 index c27d2fe..0000000 --- a/dist/lsp/directory-diagnostics.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"directory-diagnostics.d.ts","sourceRoot":"","sources":["../../src/lsp/directory-diagnostics.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AAS7D,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAuCpG;AAED,wBAAsB,gCAAgC,CACrD,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,cAAc,EACzB,QAAQ,GAAE,MAAoC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAwFjB"} \ No newline at end of file diff --git a/dist/lsp/directory-diagnostics.js b/dist/lsp/directory-diagnostics.js deleted file mode 100644 index 19997f5..0000000 --- a/dist/lsp/directory-diagnostics.js +++ /dev/null @@ -1,124 +0,0 @@ -import { existsSync, lstatSync, readdirSync } from "node:fs"; -import { extname, join, resolve } from "node:path"; -import { findWorkspaceRoot, formatServerLookupError } from "./client-wrapper.js"; -import { DEFAULT_MAX_DIAGNOSTICS, DEFAULT_MAX_DIRECTORY_FILES } from "./constants.js"; -import { LspInvalidPathError, LspServerLookupError } from "./errors.js"; -import { filterDiagnosticsBySeverity, formatDiagnostic } from "./formatters.js"; -import { getLspManager } from "./manager.js"; -import { findServerForExtension } from "./server-resolution.js"; -const SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]); -export function collectFilesWithExtension(dir, extension, maxFiles) { - const files = []; - function walk(currentDir) { - if (files.length >= maxFiles) - return; - let entries = []; - try { - entries = readdirSync(currentDir); - } - catch { - return; - } - for (const entry of entries) { - if (files.length >= maxFiles) - return; - const fullPath = join(currentDir, entry); - let stat; - try { - stat = lstatSync(fullPath); - } - catch { - continue; - } - if (!stat || stat.isSymbolicLink()) - continue; - if (stat.isDirectory()) { - if (!SKIP_DIRECTORIES.has(entry)) { - walk(fullPath); - } - } - else if (stat.isFile() && extname(fullPath) === extension) { - files.push(fullPath); - } - } - } - walk(dir); - return files; -} -export async function aggregateDiagnosticsForDirectory(directory, extension, severity, maxFiles = DEFAULT_MAX_DIRECTORY_FILES) { - if (!extension.startsWith(".")) { - throw new LspInvalidPathError(`Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`); - } - const absDir = resolve(directory); - if (!existsSync(absDir)) { - throw new LspInvalidPathError(`Directory does not exist: ${absDir}`); - } - const serverResult = findServerForExtension(extension); - if (serverResult.status !== "found") { - throw new LspServerLookupError(formatServerLookupError(serverResult)); - } - const server = serverResult.server; - const allFiles = collectFilesWithExtension(absDir, extension, maxFiles + 1); - const wasCapped = allFiles.length > maxFiles; - const filesToProcess = allFiles.slice(0, maxFiles); - if (filesToProcess.length === 0) { - return [ - `Directory: ${absDir}`, - `Extension: ${extension}`, - "Files scanned: 0", - `No files found with extension "${extension}".`, - ].join("\n"); - } - const root = findWorkspaceRoot(absDir); - const manager = getLspManager(); - const allDiagnostics = []; - const fileErrors = []; - const client = await manager.getClient(root, server); - try { - for (const file of filesToProcess) { - try { - const result = await client.diagnostics(file); - const filtered = filterDiagnosticsBySeverity(result.items, severity); - allDiagnostics.push(...filtered.map((diagnostic) => ({ - filePath: file, - diagnostic, - }))); - } - catch (e) { - fileErrors.push({ - file, - error: e instanceof Error ? e.message : String(e), - }); - } - } - } - finally { - manager.releaseClient(root, server.id); - } - const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS); - const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS; - const lines = [ - `Directory: ${absDir}`, - `Extension: ${extension}`, - `Files scanned: ${filesToProcess.length}${wasCapped ? ` (capped at ${maxFiles})` : ""}`, - `Files with errors: ${fileErrors.length}`, - `Total diagnostics: ${allDiagnostics.length}`, - ]; - if (fileErrors.length > 0) { - lines.push("", "File processing errors:"); - for (const { file, error } of fileErrors) { - lines.push(` ${file}: ${error}`); - } - } - if (displayDiagnostics.length > 0) { - lines.push(""); - for (const { filePath, diagnostic } of displayDiagnostics) { - lines.push(`${filePath}: ${formatDiagnostic(diagnostic)}`); - } - if (wasDiagCapped) { - lines.push("", `... (${allDiagnostics.length - DEFAULT_MAX_DIAGNOSTICS} more diagnostics not shown)`); - } - } - return lines.join("\n"); -} -//# sourceMappingURL=directory-diagnostics.js.map \ No newline at end of file diff --git a/dist/lsp/directory-diagnostics.js.map b/dist/lsp/directory-diagnostics.js.map deleted file mode 100644 index 76e16ce..0000000 --- a/dist/lsp/directory-diagnostics.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"directory-diagnostics.js","sourceRo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,QAAQ,KAAK,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,aAAa,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,cAAc,CAAC,MAAM,GAAG,uBAAuB,8BAA8B,CAAC,CAAC;QACvG,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"} \ No newline at end of file diff --git a/dist/lsp/errors.d.ts b/dist/lsp/errors.d.ts deleted file mode 100644 index e9fa1df..0000000 --- a/dist/lsp/errors.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -export declare class LspConnectionClosedError extends Error { - readonly serverId: string; - readonly root: string; - readonly name = "LspConnectionClosedError"; - constructor(serverId: string, root: string, message?: string); -} -export declare class LspProcessExitedError extends Error { - readonly serverId: string; - readonly root: string; - readonly exitCode: number | null; - readonly stderrTail?: string | undefined; - readonly name = "LspProcessExitedError"; - constructor(serverId: string, root: string, exitCode: number | null, stderrTail?: string | undefined); -} -export declare class LspRequestTimeoutError extends Error { - readonly method: string; - readonly stderrTail?: string | undefined; - readonly name = "LspRequestTimeoutError"; - constructor(method: string, stderrTail?: string | undefined); -} -export declare class LspInvalidPathError extends Error { - readonly name = "LspInvalidPathError"; -} -export declare class LspServerLookupError extends Error { - readonly name = "LspServerLookupError"; -} -export declare class LspServerInitializingError extends Error { - readonly originalError: LspRequestTimeoutError; - readonly name = "LspServerInitializingError"; - constructor(originalError: LspRequestTimeoutError); -} -export declare class LspProcessSpawnError extends Error { - readonly name = "LspProcessSpawnError"; -} -export declare function isLspDeadConnectionError(err: unknown): err is LspConnectionClosedError | LspProcessExitedError; -//# sourceMappingURL=errors.d.ts.map \ No newline at end of file diff --git a/dist/lsp/errors.d.ts.map b/dist/lsp/errors.d.ts.map deleted file mode 100644 index 5c5136c..0000000 --- a/dist/lsp/errors.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{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AgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,wBAAwB,GAAG,qBAAqB,CAE9G"} \ No newline at end of file diff --git a/dist/lsp/errors.js b/dist/lsp/errors.js deleted file mode 100644 index f00b26c..0000000 --- a/dist/lsp/errors.js +++ /dev/null @@ -1,57 +0,0 @@ -export class LspConnectionClosedError extends Error { - constructor(serverId, root, message) { - super(message ?? `LSP connection closed for ${serverId} at ${root}`); - this.serverId = serverId; - this.root = root; - this.name = "LspConnectionClosedError"; - } -} -export class LspProcessExitedError extends Error { - constructor(serverId, root, exitCode, stderrTail) { - const stderrSuffix = stderrTail ? `\nstderr tail: ${stderrTail}` : ""; - super(`LSP server ${serverId} at ${root} exited with code ${exitCode ?? "null"}${stderrSuffix}`); - this.serverId = serverId; - this.root = root; - this.exitCode = exitCode; - this.stderrTail = stderrTail; - this.name = "LspProcessExitedError"; - } -} -export class LspRequestTimeoutError extends Error { - constructor(method, stderrTail) { - const stderrSuffix = stderrTail ? `\nrecent stderr: ${stderrTail}` : ""; - super(`LSP request timeout (method: ${method})${stderrSuffix}`); - this.method = method; - this.stderrTail = stderrTail; - this.name = "LspRequestTimeoutError"; - } -} -export class LspInvalidPathError extends Error { - constructor() { - super(...arguments); - this.name = "LspInvalidPathError"; - } -} -export class LspServerLookupError extends Error { - constructor() { - super(...arguments); - this.name = "LspServerLookupError"; - } -} -export class LspServerInitializingError extends Error { - constructor(originalError) { - super(`LSP server is still initializing. Please retry in a few seconds. Original error: ${originalError.message}`); - this.originalError = originalError; - this.name = "LspServerInitializingError"; - } -} -export class LspProcessSpawnError extends Error { - constructor() { - super(...arguments); - this.name = "LspProcessSpawnError"; - } -} -export function isLspDeadConnectionError(err) { - return err instanceof LspConnectionClosedError || err instanceof LspProcessExitedError; -} -//# sourceMappingURL=errors.js.map \ No newline at end of file diff --git a/dist/lsp/errors.js.map b/dist/lsp/errors.js.map deleted file mode 100644 index fc43444..0000000 --- a/dist/lsp/errors.js.map +++ /dev/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ACmB,SAAI,GAAG,qBAAqB,CAAC;IAChD,CAAC;CAAA;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAA/C;;QACmB,SAAI,GAAG,sBAAsB,CAAC;IACjD,CAAC;CAAA;AAED,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAGpD,YAAqB,aAAqC;QACzD,KAAK,CACJ,oFAAoF,aAAa,CAAC,OAAO,EAAE,CAC3G,CAAC;QAHkB,kBAAa,GAAb,aAAa,CAAwB;QAFxC,SAAI,GAAG,4BAA4B,CAAC;IAMtD,CAAC;CACD;AAED,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAA/C;;QACmB,SAAI,GAAG,sBAAsB,CAAC;IACjD,CAAC;CAAA;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACpD,OAAO,GAAG,YAAY,wBAAwB,IAAI,GAAG,YAAY,qBAAqB,CAAC;AACxF,CAAC"} \ No newline at end of file diff --git a/dist/lsp/formatters.d.ts b/dist/lsp/formatters.d.ts deleted file mode 100644 index ba72fad..0000000 --- a/dist/lsp/formatters.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { Diagnostic, DocumentSymbol, Location, LocationLink, PrepareRenameDefaultBehavior, PrepareRenameResult, Range, SeverityFilter, SymbolInfo } from "./types.js"; -import type { ApplyResult } from "./workspace-edit.js"; -export declare function uriToPath(uri: string): string; -export declare function formatLocation(loc: Location | LocationLink): string; -export declare function formatSymbolKind(kind: number): string; -export declare function formatSeverity(severity: number | undefined): string; -export declare function formatDocumentSymbol(symbol: DocumentSymbol, indent?: number): string; -export declare function formatSymbolInfo(symbol: SymbolInfo): string; -export declare function formatDiagnostic(diag: Diagnostic): string; -export declare function filterDiagnosticsBySeverity(diagnostics: Diagnostic[], severityFilter?: SeverityFilter): Diagnostic[]; -export declare function formatPrepareRenameResult(result: PrepareRenameResult | PrepareRenameDefaultBehavior | Range | null): string; -export declare function formatApplyResult(result: ApplyResult): string; -//# sourceMappingURL=formatters.d.ts.map \ No newline at end of file diff --git a/dist/lsp/formatters.d.ts.map b/dist/lsp/formatters.d.ts.map deleted file mode 100644 index 51565c7..0000000 --- a/dist/lsp/formatters.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../../src/lsp/formatters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,UAAU,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,UAAU,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,CAYnE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGnE;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,SAAI,GAAG,MAAM,CAa/E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAK3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAOzD;AAED,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,UAAU,EAAE,CAepH;AAED,wBAAgB,yBAAyB,CACxC,MAAM,EAAE,mBAAmB,GAAG,4BAA4B,GAAG,KAAK,GAAG,IAAI,GACvE,MAAM,CAyBR;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAmB7D"} \ No newline at end of file diff --git a/dist/lsp/formatters.js b/dist/lsp/formatters.js deleted file mode 100644 index 76a38b2..0000000 --- a/dist/lsp/formatters.js +++ /dev/null @@ -1,109 +0,0 @@ -import { fileURLToPath } from "node:url"; -import { SEVERITY_MAP, SYMBOL_KIND_MAP } from "./language-mappings.js"; -export function uriToPath(uri) { - return fileURLToPath(uri); -} -export function formatLocation(loc) { - if ("targetUri" in loc) { - const uri = uriToPath(loc.targetUri); - const line = loc.targetRange.start.line + 1; - const char = loc.targetRange.start.character; - return `${uri}:${line}:${char}`; - } - const uri = uriToPath(loc.uri); - const line = loc.range.start.line + 1; - const char = loc.range.start.character; - return `${uri}:${line}:${char}`; -} -export function formatSymbolKind(kind) { - return SYMBOL_KIND_MAP[kind] ?? `Unknown(${kind})`; -} -export function formatSeverity(severity) { - if (!severity) - return "unknown"; - return SEVERITY_MAP[severity] ?? `unknown(${severity})`; -} -export function formatDocumentSymbol(symbol, indent = 0) { - const prefix = " ".repeat(indent); - const kind = formatSymbolKind(symbol.kind); - const line = symbol.range.start.line + 1; - let result = `${prefix}${symbol.name} (${kind}) - line ${line}`; - if (symbol.children && symbol.children.length > 0) { - for (const child of symbol.children) { - result += `\n${formatDocumentSymbol(child, indent + 1)}`; - } - } - return result; -} -export function formatSymbolInfo(symbol) { - const kind = formatSymbolKind(symbol.kind); - const loc = formatLocation(symbol.location); - const container = symbol.containerName ? ` (in ${symbol.containerName})` : ""; - return `${symbol.name} (${kind})${container} - ${loc}`; -} -export function formatDiagnostic(diag) { - const severity = formatSeverity(diag.severity); - const line = diag.range.start.line + 1; - const char = diag.range.start.character; - const source = diag.source ? `[${diag.source}]` : ""; - const code = diag.code ? ` (${diag.code})` : ""; - return `${severity}${source}${code} at ${line}:${char}: ${diag.message}`; -} -export function filterDiagnosticsBySeverity(diagnostics, severityFilter) { - if (!severityFilter || severityFilter === "all") { - return diagnostics; - } - const severityMap = { - error: 1, - warning: 2, - information: 3, - hint: 4, - }; - const targetSeverity = severityMap[severityFilter]; - if (targetSeverity === undefined) - return diagnostics; - return diagnostics.filter((d) => d.severity === targetSeverity); -} -export function formatPrepareRenameResult(result) { - if (!result) - return "Cannot rename at this position"; - if ("defaultBehavior" in result) { - return result.defaultBehavior ? "Rename supported (using default behavior)" : "Cannot rename at this position"; - } - if ("range" in result && result.range) { - const startLine = result.range.start.line + 1; - const startChar = result.range.start.character; - const endLine = result.range.end.line + 1; - const endChar = result.range.end.character; - const placeholder = result.placeholder ? ` (current: "${result.placeholder}")` : ""; - return `Rename available at ${startLine}:${startChar}-${endLine}:${endChar}${placeholder}`; - } - if ("start" in result && "end" in result) { - const startLine = result.start.line + 1; - const startChar = result.start.character; - const endLine = result.end.line + 1; - const endChar = result.end.character; - return `Rename available at ${startLine}:${startChar}-${endLine}:${endChar}`; - } - return "Cannot rename at this position"; -} -export function formatApplyResult(result) { - const lines = []; - if (result.success) { - lines.push(`Applied ${result.totalEdits} edit(s) to ${result.filesModified.length} file(s):`); - for (const file of result.filesModified) { - lines.push(` - ${file}`); - } - } - else { - lines.push("Failed to apply some changes:"); - for (const err of result.errors) { - lines.push(` Error: ${err}`); - } - if (result.filesModified.length > 0) { - lines.push(`Successfully modified: ${result.filesModified.join(", ")}`); - } - } - return lines.join("\n"); -} -//# sourceMappingURL=formatters.js.map \ No newline at end of file diff --git a/dist/lsp/formatters.js.map b/dist/lsp/formatters.js.map deleted file mode 100644 index 24fbaa1..0000000 --- a/dist/lsp/formatters.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/lsp/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAcvE,MAAM,UAAU,SAAS,CAAC,GAAW;IACpC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAA4B;IAC1D,IAAI,WAAW,IAAI,GAAG,E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AAE,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,0BAA0B,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"} \ No newline at end of file diff --git a/dist/lsp/infer-extension.d.ts b/dist/lsp/infer-extension.d.ts deleted file mode 100644 index 743207b..0000000 --- a/dist/lsp/infer-extension.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare function inferExtensionFromDirectory(directory: string): string | null; -//# sourceMappingURL=infer-extension.d.ts.map \ No newline at end of file diff --git a/dist/lsp/infer-extension.d.ts.map b/dist/lsp/infer-extension.d.ts.map deleted file mode 100644 index 8d48052..0000000 --- a/dist/lsp/infer-extension.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"infer-extension.d.ts","sourceRoot":"","sources":["../../src/lsp/infer-extension.ts"],"names":[],"mappings":"AAQA,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwD5E"} \ No newline at end of file diff --git a/dist/lsp/infer-extension.js b/dist/lsp/infer-extension.js deleted file mode 100644 index 73e4a02..0000000 --- a/dist/lsp/infer-extension.js +++ /dev/null @@ -1,59 +0,0 @@ -import { lstatSync, readdirSync } from "node:fs"; -import { extname, join } from "node:path"; -import { EXT_TO_LANG } from "./language-mappings.js"; -const SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]); -const MAX_SCAN_ENTRIES = 500; -export function inferExtensionFromDirectory(directory) { - const extensionCounts = new Map(); - let scanned = 0; - function walk(dir) { - if (scanned >= MAX_SCAN_ENTRIES) - return; - let entries; - try { - entries = readdirSync(dir); - } - catch { - return; - } - for (const entry of entries) { - if (scanned >= MAX_SCAN_ENTRIES) - return; - const fullPath = join(dir, entry); - let stat; - try { - stat = lstatSync(fullPath); - } - catch { - continue; - } - if (stat.isSymbolicLink()) - continue; - scanned++; - if (stat.isDirectory()) { - if (!SKIP_DIRECTORIES.has(entry)) { - walk(fullPath); - } - } - else if (stat.isFile()) { - const ext = extname(fullPath); - if (ext && ext in EXT_TO_LANG) { - extensionCounts.set(ext, (extensionCounts.get(ext) ?? 0) + 1); - } - } - } - } - walk(directory); - if (extensionCounts.size === 0) - return null; - let maxExt = ""; - let maxCount = 0; - for (const [ext, count] of extensionCounts) { - if (count > maxCount) { - maxCount = count; - maxExt = ext; - } - } - return maxExt || null; -} -//# sourceMappingURL=infer-extension.js.map \ No newline at end of file diff --git a/dist/lsp/infer-extension.js.map b/dist/lsp/infer-extension.js.map deleted file mode 100644 index 9aaeedb..0000000 --- a/dist/lsp/infer-extension.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"infer-extension.js","sourceRoot":"","sources":["../../src/lsp/infer-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5F,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,UAAU,2BAA2B,CAAC,SAAiB;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClD,IAAI,OAAO,GAAG,CAAC,CAAC;IAEhB,SAAS,IAAI,CAAC,GAAW;QACxB,IAAI,OAAO,IAAI,gBAAgB;YAAE,OAAO;QAExC,IAAI,OAAiB,CAAC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E,KAAK,CAAC,IAAI,eAAe,EAAE,CAAC;QAC5C,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;YACtB,QAAQ,GAAG,KAAK,CAAC;YACjB,MAAM,GAAG,GAAG,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,MAAM,IAAI,IAAI,CAAC;AACvB,CAAC"} \ No newline at end of file diff --git a/dist/lsp/json-rpc-connection.d.ts b/dist/lsp/json-rpc-connection.d.ts deleted file mode 100644 index f810fe9..0000000 --- a/dist/lsp/json-rpc-connection.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -type NotificationHandler = (params: unknown) => void; -type RequestHandler = (params: unknown) => Promise | unknown; -export declare class JsonRpcConnection { - private readonly reader; - private readonly writer; - private readonly pendingRequests; - private readonly notificationHandlers; - private readonly requestHandlers; - private readonly closeHandlers; - private readonly errorHandlers; - private inputBuffer; - private nextRequestId; - private listening; - private disposed; - constructor(reader: NodeJS.ReadableStream, writer: NodeJS.WritableStream); - listen(): void; - onNotification(method: string, handler: NotificationHandler): void; - onRequest(method: string, handler: RequestHandler): void; - onClose(handler: () => void): void; - onError(handler: (error: Error) => void): void; - sendRequest(method: string, params?: unknown): Promise; - sendNotification(method: string, params?: unknown): Promise; - dispose(): void; - private readonly handleData; - private readonly handleClose; - private readonly handleStreamError; - private drainInputBuffer; - private dispatchBody; - private handleResponse; - private handleNotification; - private handleRequest; - private writeError; - private writeMessage; - private emitError; -} -export {}; -//# sourceMappingURL=json-rpc-connection.d.ts.map \ No newline at end of file diff --git a/dist/lsp/json-rpc-connection.d.ts.map b/dist/lsp/json-rpc-connection.d.ts.map deleted file mode 100644 index 3cd74f4..0000000 --- a/dist/lsp/json-rpc-connection.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"json-rpc-connection.d.ts","sourceRoot":"","sources":["../../src/lsp/json-rpc-connection.ts"],"names":[],"mappings":"AAOA,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI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AAC,QAAQ,CAAC,WAAW,CAI1B;IAEF,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAEhC;IAEF,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,YAAY;IAuCpB,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,aAAa;YA2BP,UAAU;IAIxB,OAAO,CAAC,YAAY;IAcpB,OAAO,CAAC,SAAS;CAKjB"} \ No newline at end of file diff --git a/dist/lsp/json-rpc-connection.js b/dist/lsp/json-rpc-connection.js deleted file mode 100644 index 47375b3..0000000 --- a/dist/lsp/json-rpc-connection.js +++ /dev/null @@ -1,248 +0,0 @@ -const HEADER_SEPARATOR = "\r\n\r\n"; -const PARSE_ERROR = -32700; -const INVALID_REQUEST = -32600; -const METHOD_NOT_FOUND = -32601; -const INTERNAL_ERROR = -32603; -export class JsonRpcConnection { - constructor(reader, writer) { - this.reader = reader; - this.writer = writer; - this.pendingRequests = new Map(); - this.notificationHandlers = new Map(); - this.requestHandlers = new Map(); - this.closeHandlers = []; - this.errorHandlers = []; - this.inputBuffer = Buffer.alloc(0); - this.nextRequestId = 1; - this.listening = false; - this.disposed = false; - this.handleData = (chunk) => { - const chunkBuffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8"); - this.inputBuffer = Buffer.concat([this.inputBuffer, chunkBuffer]); - this.drainInputBuffer(); - }; - this.handleClose = () => { - for (const handler of this.closeHandlers) { - handler(); - } - }; - this.handleStreamError = (error) => { - this.emitError(error); - }; - } - listen() { - if (this.listening) - return; - this.listening = true; - this.reader.on("data", this.handleData); - this.reader.on("close", this.handleClose); - this.reader.on("end", this.handleClose); - this.reader.on("error", this.handleStreamError); - this.writer.on("error", this.handleStreamError); - } - onNotification(method, handler) { - this.notificationHandlers.set(method, handler); - } - onRequest(method, handler) { - this.requestHandlers.set(method, handler); - } - onClose(handler) { - this.closeHandlers.push(handler); - } - onError(handler) { - this.errorHandlers.push(handler); - } - async sendRequest(method, params) { - if (this.disposed) - throw new Error("JSON-RPC connection is disposed"); - const id = this.nextRequestId; - this.nextRequestId += 1; - const message = params === undefined ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params }; - const responsePromise = new Promise((resolve, reject) => { - this.pendingRequests.set(String(id), { - resolve(result) { - resolve(result); - }, - reject, - }); - }); - try { - await this.writeMessage(message); - } - catch (error) { - this.pendingRequests.delete(String(id)); - throw error; - } - return responsePromise; - } - async sendNotification(method, params) { - if (this.disposed) - return; - const message = params === undefined ? { jsonrpc: "2.0", method } : { jsonrpc: "2.0", method, params }; - await this.writeMessage(message); - } - dispose() { - if (this.disposed) - return; - this.disposed = true; - this.reader.off("data", this.handleData); - this.reader.off("close", this.handleClose); - this.reader.off("end", this.handleClose); - this.reader.off("error", this.handleStreamError); - this.writer.off("error", this.handleStreamError); - for (const pending of this.pendingRequests.values()) { - pending.reject(new Error("JSON-RPC connection disposed")); - } - this.pendingRequests.clear(); - this.notificationHandlers.clear(); - this.requestHandlers.clear(); - } - drainInputBuffer() { - while (true) { - const headerEnd = this.inputBuffer.indexOf(HEADER_SEPARATOR); - if (headerEnd === -1) - return; - const headers = this.inputBuffer.subarray(0, headerEnd).toString("ascii"); - const contentLength = parseContentLength(headers); - if (contentLength === null) { - this.inputBuffer = Buffer.alloc(0); - this.emitError(new Error("JSON-RPC message is missing Content-Length header")); - return; - } - const bodyStart = headerEnd + Buffer.byteLength(HEADER_SEPARATOR); - const bodyEnd = bodyStart + contentLength; - if (this.inputBuffer.length < bodyEnd) - return; - const body = this.inputBuffer.subarray(bodyStart, bodyEnd).toString("utf8"); - this.inputBuffer = this.inputBuffer.subarray(bodyEnd); - this.dispatchBody(body); - } - } - dispatchBody(body) { - let parsed; - try { - parsed = JSON.parse(body); - } - catch (error) { - void this.writeError(null, PARSE_ERROR, error instanceof Error ? error.message : "Parse error").catch((writeError) => this.emitError(toError(writeError))); - return; - } - if (!isJsonRpcObject(parsed)) { - void this.writeError(null, INVALID_REQUEST, "Invalid JSON-RPC message").catch((error) => this.emitError(toError(error))); - return; - } - if ("id" in parsed && ("result" in parsed || "error" in parsed)) { - this.handleResponse(parsed); - return; - } - if (typeof parsed.method !== "string") { - const id = getMessageId(parsed) ?? null; - void this.writeError(id, INVALID_REQUEST, "Invalid JSON-RPC method").catch((error) => this.emitError(toError(error))); - return; - } - if ("id" in parsed) { - this.handleRequest(parsed); - return; - } - this.handleNotification(parsed.method, parsed.params); - } - handleResponse(message) { - const id = getMessageId(message); - if (id === undefined) - return; - const pending = this.pendingRequests.get(String(id)); - if (!pending) - return; - this.pendingRequests.delete(String(id)); - if ("error" in message) { - pending.reject(jsonRpcErrorToError(message.error)); - return; - } - pending.resolve(message.result); - } - handleNotification(method, params) { - const handler = this.notificationHandlers.get(method); - if (!handler) - return; - try { - handler(params); - } - catch (error) { - this.emitError(toError(error)); - } - } - handleRequest(message) { - const id = getMessageId(message); - if (id === undefined) { - void this.writeError(null, INVALID_REQUEST, "Invalid JSON-RPC id").catch((error) => this.emitError(toError(error))); - return; - } - const method = typeof message.method === "string" ? message.method : ""; - const handler = this.requestHandlers.get(method); - if (!handler) { - void this.writeError(id, METHOD_NOT_FOUND, `Method not found: ${method}`).catch((error) => this.emitError(toError(error))); - return; - } - Promise.resolve() - .then(() => handler(message.params)) - .then((result) => this.writeMessage({ jsonrpc: "2.0", id, result }), (error) => this.writeError(id, INTERNAL_ERROR, toError(error).message)) - .catch((error) => this.emitError(toError(error))); - } - async writeError(id, code, message) { - await this.writeMessage({ jsonrpc: "2.0", id, error: { code, message } }); - } - writeMessage(message) { - const body = JSON.stringify(message); - const payload = `Content-Length: ${Buffer.byteLength(body, "utf8")}\r\n\r\n${body}`; - return new Promise((resolve, reject) => { - this.writer.write(payload, (error) => { - if (error) { - reject(error); - return; - } - resolve(); - }); - }); - } - emitError(error) { - for (const handler of this.errorHandlers) { - handler(error); - } - } -} -function parseContentLength(headers) { - for (const line of headers.split("\r\n")) { - const separatorIndex = line.indexOf(":"); - if (separatorIndex === -1) - continue; - const name = line.slice(0, separatorIndex).trim().toLowerCase(); - if (name !== "content-length") - continue; - const value = Number.parseInt(line.slice(separatorIndex + 1).trim(), 10); - return Number.isFinite(value) && value >= 0 ? value : null; - } - return null; -} -function isJsonRpcObject(value) { - return typeof value === "object" && value !== null && !Array.isArray(value); -} -function getMessageId(message) { - const id = message.id; - if (typeof id === "number" || typeof id === "string" || id === null) - return id; - return undefined; -} -function jsonRpcErrorToError(value) { - if (!isJsonRpcObject(value)) - return new Error("JSON-RPC request failed"); - const message = typeof value.message === "string" ? value.message : "JSON-RPC request failed"; - const error = new Error(message); - if (typeof value.code === "number") { - error.name = `JsonRpcError(${value.code})`; - } - return error; -} -function toError(error) { - return error instanceof Error ? error : new Error(String(error)); -} -//# sourceMappingURL=json-rpc-connection.js.map \ No newline at end of file diff --git a/dist/lsp/json-rpc-connection.js.map b/dist/lsp/json-rpc-connection.js.map deleted file mode 100644 index 888b6a5..0000000 --- a/dist/lsp/json-rpc-connection.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"json-rpc-connection.js","sourceRoot":"","sources":["../../src/lsp/json-rpc-connection.ts"],"names":[],"mappings":"AAUA,MAAM,gBAAgB,GAAG,UAAU,CAAC;AACpC,MAAM,WAAW,GAAG,CAAC,KAAK,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,KAAK,CAAC;AAC/B,MAAM,gBAAgB,GAAG,CAAC,KAAK,CAAC;AAChC,MAAM,cAAc,GAAG,CAAC,KAAK,CAAC;AAE9B,MAAM,OAAO,iBAAiB;IAW7B,YACkB,MAA6B,EAC7B,MAA6B;QAD7B,WAAM,GAAN,MAAM,CAAuB;QAC7B,WAAM,GAAN,MAAM,CAAuB;QAZ9B,oBAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;QACpD,yBAAoB,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC9D,oBAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;QACpD,kBAAa,G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C;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC9B,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAClE,CAAC"} \ No newline at end of file diff --git a/dist/lsp/language-mappings.d.ts b/dist/lsp/language-mappings.d.ts deleted file mode 100644 index 0e908f9..0000000 --- a/dist/lsp/language-mappings.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export declare const SYMBOL_KIND_MAP: Record; -export declare const SEVERITY_MAP: Record; -export declare const EXT_TO_LANG: Record; -export declare function getLanguageId(ext: string): string; -//# sourceMappingURL=language-mappings.d.ts.map \ No newline at end of file diff --git a/dist/lsp/language-mappings.d.ts.map b/dist/lsp/language-mappings.d.ts.map deleted file mode 100644 index 75a887f..0000000 --- a/dist/lsp/language-mappings.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"language-mappings.d.ts","sourceRoot":"","sources":["../../src/lsp/language-mappings.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2BlD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK/C,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAmI9C,CAAC;AAEF,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD"} \ No newline at end of file diff --git a/dist/lsp/language-mappings.js b/dist/lsp/language-mappings.js deleted file mode 100644 index cf854a1..0000000 --- a/dist/lsp/language-mappings.js +++ /dev/null @@ -1,170 +0,0 @@ -export const SYMBOL_KIND_MAP = { - 1: "File", - 2: "Module", - 3: "Namespace", - 4: "Package", - 5: "Class", - 6: "Method", - 7: "Property", - 8: "Field", - 9: "Constructor", - 10: "Enum", - 11: "Interface", - 12: "Function", - 13: "Variable", - 14: "Constant", - 15: "String", - 16: "Number", - 17: "Boolean", - 18: "Array", - 19: "Object", - 20: "Key", - 21: "Null", - 22: "EnumMember", - 23: "Struct", - 24: "Event", - 25: "Operator", - 26: "TypeParameter", -}; -export const SEVERITY_MAP = { - 1: "error", - 2: "warning", - 3: "information", - 4: "hint", -}; -export const EXT_TO_LANG = { - ".abap": "abap", - ".bat": "bat", - ".bib": "bibtex", - ".bibtex": "bibtex", - ".clj": "clojure", - ".cljs": "clojure", - ".cljc": "clojure", - ".edn": "clojure", - ".coffee": "coffeescript", - ".c": "c", - ".cpp": "cpp", - ".cxx": "cpp", - ".cc": "cpp", - ".c++": "cpp", - ".cs": "csharp", - ".css": "css", - ".d": "d", - ".pas": "pascal", - ".pascal": "pascal", - ".diff": "diff", - ".patch": "diff", - ".dart": "dart", - ".dockerfile": "dockerfile", - ".ex": "elixir", - ".exs": "elixir", - ".erl": "erlang", - ".hrl": "erlang", - ".fs": "fsharp", - ".fsi": "fsharp", - ".fsx": "fsharp", - ".fsscript": "fsharp", - ".gitcommit": "git-commit", - ".gitrebase": "git-rebase", - ".go": "go", - ".groovy": "groovy", - ".gleam": "gleam", - ".hbs": "handlebars", - ".handlebars": "handlebars", - ".hs": "haskell", - ".html": "html", - ".htm": "html", - ".ini": "ini", - ".java": "java", - ".js": "javascript", - ".jsx": "javascriptreact", - ".json": "json", - ".jsonc": "jsonc", - ".tex": "latex", - ".latex": "latex", - ".less": "less", - ".lua": "lua", - ".makefile": "makefile", - makefile: "makefile", - ".md": "markdown", - ".markdown": "markdown", - ".m": "objective-c", - ".mm": "objective-cpp", - ".pl": "perl", - ".pm": "perl", - ".pm6": "perl6", - ".php": "php", - ".ps1": "powershell", - ".psm1": "powershell", - ".pug": "jade", - ".jade": "jade", - ".py": "python", - ".pyi": "python", - ".r": "r", - ".cshtml": "razor", - ".razor": "razor", - ".rb": "ruby", - ".rake": "ruby", - ".gemspec": "ruby", - ".ru": "ruby", - ".erb": "erb", - ".html.erb": "erb", - ".js.erb": "erb", - ".css.erb": "erb", - ".json.erb": "erb", - ".rs": "rust", - ".scss": "scss", - ".sass": "sass", - ".scala": "scala", - ".shader": "shaderlab", - ".sh": "shellscript", - ".bash": "shellscript", - ".zsh": "shellscript", - ".ksh": "shellscript", - ".sql": "sql", - ".svelte": "svelte", - ".swift": "swift", - ".ts": "typescript", - ".tsx": "typescriptreact", - ".mts": "typescript", - ".cts": "typescript", - ".mtsx": "typescriptreact", - ".ctsx": "typescriptreact", - ".xml": "xml", - ".xsl": "xsl", - ".yaml": "yaml", - ".yml": "yaml", - ".mjs": "javascript", - ".cjs": "javascript", - ".vue": "vue", - ".zig": "zig", - ".zon": "zig", - ".astro": "astro", - ".ml": "ocaml", - ".mli": "ocaml", - ".tf": "terraform", - ".tfvars": "terraform-vars", - ".hcl": "hcl", - ".nix": "nix", - ".typ": "typst", - ".typc": "typst", - ".ets": "typescript", - ".lhs": "haskell", - ".kt": "kotlin", - ".kts": "kotlin", - ".prisma": "prisma", - ".h": "c", - ".hpp": "cpp", - ".hh": "cpp", - ".hxx": "cpp", - ".h++": "cpp", - ".objc": "objective-c", - ".objcpp": "objective-cpp", - ".fish": "fish", - ".graphql": "graphql", - ".gql": "graphql", -}; -export function getLanguageId(ext) { - return EXT_TO_LANG[ext] ?? "plaintext"; -} -//# sourceMappingURL=language-mappings.js.map \ No newline at end of file diff --git a/dist/lsp/language-mappings.js.map b/dist/lsp/language-mappings.js.map deleted file mode 100644 index 95f8e2c..0000000 --- a/dist/lsp/language-mappings.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"language-mappings.js","sourceRoot":"","sources":["../../src/lsp/language-mappings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,SAAS;IACZ,CAAC,EAAE,OA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O,EAAE,aAAa;IACtB,SAAS,EAAE,eAAe;IAC1B,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,SAAS;IACrB,MAAM,EAAE,SAAS;CACjB,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,GAAW;IACxC,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,WAAW,CAAC;AACxC,CAAC"} \ No newline at end of file diff --git a/dist/lsp/manager.d.ts b/dist/lsp/manager.d.ts deleted file mode 100644 index 324323b..0000000 --- a/dist/lsp/manager.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { LspClient } from "./client.js"; -import type { ResolvedServer } from "./types.js"; -export interface ClientSnapshot { - root: string; - serverId: string; - refCount: number; - pendingWaiters: number; - lastUsedAt: number; - isInitializing: boolean; - alive: boolean; - command: string[]; -} -export interface LspManagerOptions { - idleTimeoutMs?: number; - initTimeoutMs?: number; - reaperIntervalMs?: number; - clientFactory?: (root: string, server: ResolvedServer) => LspClient; - now?: () => number; -} -export declare class LspManager { - private readonly clients; - private reaperHandle; - private exitDisposer; - private disposed; - private readonly idleTimeoutMs; - private readonly initTimeoutMs; - private readonly reaperIntervalMs; - private readonly clientFactory; - private readonly now; - constructor(options?: LspManagerOptions); - private startReaper; - private installProcessExitHandler; - private getKey; - private reapStale; - private tryDeleteIfOrphaned; - getClient(root: string, server: ResolvedServer, signal?: AbortSignal): Promise; - releaseClient(root: string, serverId: string): void; - invalidateClient(root: string, serverId: string, client?: LspClient): void; - warmupClient(root: string, server: ResolvedServer): void; - isServerInitializing(root: string, serverId: string): boolean; - getSnapshot(): ClientSnapshot[]; - hasClient(root: string, serverId: string): boolean; - clientCount(): number; - stopAll(): Promise; -} -export declare function getLspManager(): LspManager; -export declare function disposeDefaultLspManager(): Promise; -//# sourceMappingURL=manager.d.ts.map \ No newline at end of file diff --git a/dist/lsp/manager.d.ts.map b/dist/lsp/manager.d.ts.map deleted file mode 100644 index 3581ce1..0000000 --- a/dist/lsp/manager.d.ts.map +++ /dev/null @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IAId,OAAO,CAAC,SAAS;YAyBH,mBAAmB;IAY3B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IA+F/F,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IASnD,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI;IAS1E,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IAuCxD,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAK7D,WAAW,IAAI,cAAc,EAAE;IAkB/B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIlD,WAAW,IAAI,MAAM;IAIf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB9B;AAID,wBAAgB,aAAa,IAAI,UAAU,CAK1C;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAM9D"} \ No newline at end of file diff --git a/dist/lsp/manager.js b/dist/lsp/manager.js deleted file mode 100644 index ed51439..0000000 --- a/dist/lsp/manager.js +++ /dev/null @@ -1,308 +0,0 @@ -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { LspClient } from "./client.js"; -import { IDLE_TIMEOUT_MS, INIT_TIMEOUT_MS, REAPER_INTERVAL_MS } from "./constants.js"; -async function stopClientBestEffort(client) { - try { - await client.stop(); - } - catch (error) { - reportBestEffortCleanupError("client stop", error); - } -} -function awaitWithSignal(promise, signal) { - if (!signal) - return promise; - return new Promise((resolve, reject) => { - let settled = false; - const onAbort = () => { - if (settled) - return; - settled = true; - reject(new DOMException("Aborted", "AbortError")); - }; - if (signal.aborted) { - onAbort(); - return; - } - signal.addEventListener("abort", onAbort, { once: true }); - promise.then((value) => { - if (settled) - return; - settled = true; - signal.removeEventListener("abort", onAbort); - resolve(value); - }, (err) => { - if (settled) - return; - settled = true; - signal.removeEventListener("abort", onAbort); - reject(err); - }); - }); -} -export class LspManager { - constructor(options = {}) { - this.clients = new Map(); - this.reaperHandle = null; - this.exitDisposer = null; - this.disposed = false; - this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS; - this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS; - this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS; - this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server)); - this.now = options.now ?? (() => Date.now()); - this.startReaper(); - this.installProcessExitHandler(); - } - startReaper() { - if (this.reaperHandle) - return; - this.reaperHandle = setInterval(() => { - this.reapStale(); - }, this.reaperIntervalMs); - if (typeof this.reaperHandle.unref === "function") { - this.reaperHandle.unref(); - } - } - installProcessExitHandler() { - const handler = () => { - for (const managed of this.clients.values()) { - try { - void stopClientBestEffort(managed.client); - } - catch (error) { - reportBestEffortCleanupError("exit handler client stop", error); - } - } - this.clients.clear(); - }; - process.on("exit", handler); - this.exitDisposer = () => { - process.removeListener("exit", handler); - }; - } - getKey(root, serverId) { - return `${root}::${serverId}`; - } - reapStale() { - const t = this.now(); - for (const [key, managed] of this.clients) { - if (managed.isInitializing && - managed.initializingSince !== null && - t - managed.initializingSince > this.initTimeoutMs) { - void stopClientBestEffort(managed.client); - this.clients.delete(key); - continue; - } - if (!managed.isInitializing && - managed.refCount === 0 && - managed.pendingWaiters === 0 && - t - managed.lastUsedAt > this.idleTimeoutMs) { - void stopClientBestEffort(managed.client); - this.clients.delete(key); - } - } - } - async tryDeleteIfOrphaned(key, managed) { - if (managed.refCount === 0 && - managed.pendingWaiters === 0 && - !managed.isInitializing && - this.clients.get(key) === managed) { - this.clients.delete(key); - await stopClientBestEffort(managed.client); - } - } - async getClient(root, server, signal) { - if (this.disposed) { - throw new Error("LspManager has been disposed"); - } - signal?.throwIfAborted(); - const key = this.getKey(root, server.id); - let managed = this.clients.get(key); - if (managed) { - const t = this.now(); - if (managed.isInitializing && - managed.initializingSince !== null && - t - managed.initializingSince > this.initTimeoutMs) { - await stopClientBestEffort(managed.client); - this.clients.delete(key); - managed = undefined; - } - } - if (managed) { - if (managed.initPromise) { - managed.pendingWaiters++; - try { - await awaitWithSignal(managed.initPromise, signal); - } - catch (err) { - managed.pendingWaiters--; - await this.tryDeleteIfOrphaned(key, managed); - throw err; - } - managed.pendingWaiters--; - } - if (signal?.aborted) { - await this.tryDeleteIfOrphaned(key, managed); - signal.throwIfAborted(); - } - if (!managed.client.isAlive()) { - await stopClientBestEffort(managed.client); - this.clients.delete(key); - return this.getClient(root, server, signal); - } - managed.refCount++; - managed.lastUsedAt = this.now(); - return managed.client; - } - const client = this.clientFactory(root, server); - const initStartedAt = this.now(); - const initPromise = (async () => { - await client.start(); - await client.initialize(); - })(); - const newManaged = { - client, - refCount: 0, - pendingWaiters: 1, - lastUsedAt: initStartedAt, - initPromise, - isInitializing: true, - initializingSince: initStartedAt, - }; - this.clients.set(key, newManaged); - try { - await awaitWithSignal(initPromise, signal); - } - catch (err) { - newManaged.pendingWaiters--; - if (this.clients.get(key) === newManaged) { - this.clients.delete(key); - } - await stopClientBestEffort(client); - throw err; - } - newManaged.pendingWaiters--; - newManaged.isInitializing = false; - newManaged.initializingSince = null; - newManaged.initPromise = null; - if (signal?.aborted) { - await this.tryDeleteIfOrphaned(key, newManaged); - signal.throwIfAborted(); - } - newManaged.refCount++; - newManaged.lastUsedAt = this.now(); - return client; - } - releaseClient(root, serverId) { - const key = this.getKey(root, serverId); - const managed = this.clients.get(key); - if (managed && managed.refCount > 0) { - managed.refCount--; - managed.lastUsedAt = this.now(); - } - } - invalidateClient(root, serverId, client) { - const key = this.getKey(root, serverId); - const managed = this.clients.get(key); - if (!managed) - return; - if (client && managed.client !== client) - return; - this.clients.delete(key); - void stopClientBestEffort(managed.client); - } - warmupClient(root, server) { - if (this.disposed) - return; - const key = this.getKey(root, server.id); - if (this.clients.has(key)) - return; - const client = this.clientFactory(root, server); - const initStartedAt = this.now(); - const initPromise = (async () => { - await client.start(); - await client.initialize(); - })(); - const managed = { - client, - refCount: 0, - pendingWaiters: 0, - lastUsedAt: initStartedAt, - initPromise, - isInitializing: true, - initializingSince: initStartedAt, - }; - this.clients.set(key, managed); - initPromise.then(() => { - managed.isInitializing = false; - managed.initializingSince = null; - managed.initPromise = null; - managed.lastUsedAt = this.now(); - }, () => { - if (this.clients.get(key) === managed) { - this.clients.delete(key); - } - void stopClientBestEffort(client); - }); - } - isServerInitializing(root, serverId) { - const managed = this.clients.get(this.getKey(root, serverId)); - return managed?.isInitializing ?? false; - } - getSnapshot() { - const snapshots = []; - for (const [key, managed] of this.clients) { - const [root, serverId] = key.split("::"); - snapshots.push({ - root, - serverId, - refCount: managed.refCount, - pendingWaiters: managed.pendingWaiters, - lastUsedAt: managed.lastUsedAt, - isInitializing: managed.isInitializing, - alive: managed.client.isAlive(), - command: managed.client.command(), - }); - } - return snapshots; - } - hasClient(root, serverId) { - return this.clients.has(this.getKey(root, serverId)); - } - clientCount() { - return this.clients.size; - } - async stopAll() { - this.disposed = true; - if (this.reaperHandle) { - clearInterval(this.reaperHandle); - this.reaperHandle = null; - } - if (this.exitDisposer) { - this.exitDisposer(); - this.exitDisposer = null; - } - const stopPromises = []; - for (const managed of this.clients.values()) { - stopPromises.push(stopClientBestEffort(managed.client)); - } - this.clients.clear(); - await Promise.allSettled(stopPromises); - } -} -let _defaultInstance = null; -export function getLspManager() { - if (!_defaultInstance) { - _defaultInstance = new LspManager(); - } - return _defaultInstance; -} -export async function disposeDefaultLspManager() { - if (_defaultInstance) { - const m = _defaultInstance; - _defaultInstance = null; - await m.stopAll(); - } -} -//# sourceMappingURL=manager.js.map \ No newline at end of file diff --git a/dist/lsp/manager.js.map b/dist/lsp/manager.js.map deleted file mode 100644 index ed711df..0000000 --- a/dist/lsp/manager.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/lsp/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAgCtF,KAAK,UAAU,oBAAoB,CAAC,MAAiB;IACpD,IAAI,CAAC;QACJ,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,4BAA4B,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,SAAS,eAAe,CAAI,OAAmB,EAAE,MAA+B;IAC/E,IAAI,CAAC,MAAM;QAAE,OAAO,OAAO,CAAC;IAC5B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,MAAM,OAAO,GAAG,GAAG,EAAE;YACpB,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;QACnD,CAAC,CAAC;QACF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,OAAO;QACR,CAAC;QACD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,IAAI,CACX,CAAC,KAAK,EAAE,EAAE;YACT,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,mBAAmB,C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AAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC1B,CAAC;QAED,MAAM,YAAY,GAAoB,EAAE,CAAC;QACzC,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;CACD;AAED,IAAI,gBAAgB,GAAsB,IAAI,CAAC;AAE/C,MAAM,UAAU,aAAa;IAC5B,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACvB,gBAAgB,GAAG,IAAI,UAAU,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC7C,IAAI,gBAAgB,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,gBAAgB,CAAC;QAC3B,gBAAgB,GAAG,IAAI,CAAC;QACxB,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;AACF,CAAC"} \ No newline at end of file diff --git a/dist/lsp/process.d.ts b/dist/lsp/process.d.ts deleted file mode 100644 index 6db5e9a..0000000 --- a/dist/lsp/process.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export interface SpawnedProcess { - stdin: NodeJS.WritableStream; - stdout: NodeJS.ReadableStream; - stderr: NodeJS.ReadableStream; - pid: number | undefined; - exitCode: number | null; - exited: Promise; - kill(signal?: NodeJS.Signals): void; - killed: boolean; -} -export interface SpawnOptions { - cwd: string; - env: Record; -} -export interface PreparedSpawnCommand { - command: string; - args: string[]; - shell: false; -} -export declare function validateCwd(cwd: string): { - valid: boolean; - error?: string; -}; -export declare function createSpawnCommand(command: string[], platform?: NodeJS.Platform, commandProcessor?: string, env?: Record): PreparedSpawnCommand; -export declare function spawnProcess(command: string[], options: SpawnOptions): SpawnedProcess; -//# sourceMappingURL=process.d.ts.map \ No newline at end of file diff --git a/dist/lsp/process.d.ts.map b/dist/lsp/process.d.ts.map deleted file mode 100644 index 07accf3..0000000 --- a/dist/lsp/process.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/lsp/process.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAgB3E;AAwED,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EAAE,EACjB,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,gBAAgB,GAAE,MAAyC,EAC3D,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACnD,oBAAoB,CAoBtB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,cAAc,CAqBrF"} \ No newline at end of file diff --git a/dist/lsp/process.js b/dist/lsp/process.js deleted file mode 100644 index 3b50d53..0000000 --- a/dist/lsp/process.js +++ /dev/null @@ -1,124 +0,0 @@ -import { spawn } from "node:child_process"; -import { existsSync, statSync } from "node:fs"; -import { delimiter, join } from "node:path"; -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { LspInvalidPathError, LspProcessSpawnError } from "./errors.js"; -export function validateCwd(cwd) { - try { - if (!existsSync(cwd)) { - return { valid: false, error: `Working directory does not exist: ${cwd}` }; - } - const stats = statSync(cwd); - if (!stats.isDirectory()) { - return { valid: false, error: `Path is not a directory: ${cwd}` }; - } - return { valid: true }; - } - catch (err) { - return { - valid: false, - error: `Cannot access working directory: ${cwd} (${err instanceof Error ? err.message : String(err)})`, - }; - } -} -function wrap(proc) { - const exitedPromise = new Promise((resolve) => { - proc.once("close", (code) => resolve(code ?? 0)); - proc.once("error", () => resolve(1)); - }); - if (!proc.stdin || !proc.stdout || !proc.stderr) { - throw new LspProcessSpawnError("Spawned process is missing one of stdin/stdout/stderr pipes"); - } - return { - stdin: proc.stdin, - stdout: proc.stdout, - stderr: proc.stderr, - get pid() { - return proc.pid ?? undefined; - }, - get exitCode() { - return proc.exitCode; - }, - get killed() { - return proc.killed; - }, - exited: exitedPromise, - kill(signal) { - try { - proc.kill(signal ?? "SIGTERM"); - } - catch (error) { - reportBestEffortCleanupError("process kill", error); - } - }, - }; -} -function isWindowsShellShim(command) { - const lowerCommand = command.toLowerCase(); - return lowerCommand.endsWith(".cmd") || lowerCommand.endsWith(".bat"); -} -function splitPath(pathValue, platform) { - const separator = platform === "win32" ? ";" : delimiter; - return pathValue.split(separator).filter(Boolean); -} -function getWindowsPathExtensions(env) { - const rawExtensions = env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD"; - const extensions = rawExtensions - .split(";") - .map((extension) => extension.trim()) - .filter(Boolean) - .map((extension) => (extension.startsWith(".") ? extension : `.${extension}`)); - return [...new Set(["", ...extensions, ".exe", ".cmd", ".bat"])]; -} -function resolveWindowsCommand(command, env) { - const hasPathSeparator = command.includes("/") || command.includes("\\"); - const pathValue = env.PATH ?? env.Path ?? ""; - const baseDirectories = hasPathSeparator ? [""] : splitPath(pathValue, "win32"); - const extensions = getWindowsPathExtensions(env); - for (const baseDirectory of baseDirectories) { - for (const extension of extensions) { - const candidate = baseDirectory ? join(baseDirectory, `${command}${extension}`) : `${command}${extension}`; - if (existsSync(candidate)) - return candidate; - } - } - return command; -} -export function createSpawnCommand(command, platform = process.platform, commandProcessor = process.env.ComSpec ?? "cmd.exe", env = process.env) { - const [cmd, ...args] = command; - if (!cmd) { - throw new LspProcessSpawnError("[lsp] empty command"); - } - if (platform !== "win32") { - return { command: cmd, args, shell: false }; - } - const resolvedCommand = resolveWindowsCommand(cmd, env); - if (!isWindowsShellShim(resolvedCommand)) { - return { command: resolvedCommand, args, shell: false }; - } - return { - command: commandProcessor, - args: ["/d", "/s", "/c", resolvedCommand, ...args], - shell: false, - }; -} -export function spawnProcess(command, options) { - const cwdValidation = validateCwd(options.cwd); - if (!cwdValidation.valid) { - throw new LspInvalidPathError(`[lsp] ${cwdValidation.error}`); - } - const [cmd] = command; - if (!cmd) { - throw new LspProcessSpawnError("[lsp] empty command"); - } - const preparedCommand = createSpawnCommand(command, process.platform, process.env.ComSpec ?? "cmd.exe", options.env); - const proc = spawn(preparedCommand.command, preparedCommand.args, { - cwd: options.cwd, - env: options.env, - stdio: ["pipe", "pipe", "pipe"], - windowsHide: true, - shell: preparedCommand.shell, - }); - return wrap(proc); -} -//# sourceMappingURL=process.js.map \ No newline at end of file diff --git a/dist/lsp/process.js.map b/dist/lsp/process.js.map deleted file mode 100644 index 92b742e..0000000 --- a/dist/lsp/process.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/lsp/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAwBxE,MAAM,UAAU,WAAW,CAAC,GAAW;IACtC,IAAI,CAAC;QACJ,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,qCAAqC,GAAG,EAAE,EAAE,CAAC;QAC5E,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,4BAA4B,GAAG,EAAE,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,oCAAoC,GAAG,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG;SACtG,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAS,IAAI,CAAC,IAAkB;IAC/B,MAAM,aAAa,GAAG,IAAI,OAAO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E,KAAK;KACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAiB,EAAE,OAAqB;IACpE,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC/C,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,mBAAmB,CAAC,SAAS,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;IACtB,IAAI,CAAC,GAAG,EAAE,CAAC;QACV,MAAM,IAAI,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,eAAe,GAAG,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACrH,MAAM,IAAI,GAAG,KAAK,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,IAAI,EAAE;QACjE,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE,OAAO,CAAC,GAAwB;QACrC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QAC/B,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,eAAe,CAAC,KAAK;KAC5B,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;AACnB,CAAC"} \ No newline at end of file diff --git a/dist/lsp/server-definitions.d.ts b/dist/lsp/server-definitions.d.ts deleted file mode 100644 index 7c97fbd..0000000 --- a/dist/lsp/server-definitions.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { LspServerConfig } from "./types.js"; -export declare const LSP_INSTALL_HINTS: Record; -export declare const BUILTIN_SERVERS: Record>; -export declare const AUTO_INSTALLABLE_SERVERS: Record; -//# sourceMappingURL=server-definitions.d.ts.map \ No newline at end of file diff --git a/dist/lsp/server-definitions.d.ts.map b/dist/lsp/server-definitions.d.ts.map deleted file mode 100644 index 9eac202..0000000 --- a/dist/lsp/server-definitions.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server-definitions.d.ts","sourceRoot":"","sources":["../../src/lsp/server-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyCpD,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CA4FvE,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAsB7D,CAAC"} \ No newline at end of file diff --git a/dist/lsp/server-definitions.js b/dist/lsp/server-definitions.js deleted file mode 100644 index 1ca965f..0000000 --- a/dist/lsp/server-definitions.js +++ /dev/null @@ -1,159 +0,0 @@ -export const LSP_INSTALL_HINTS = { - typescript: "npm install -g typescript-language-server typescript", - deno: "Install Deno from https://deno.land", - vue: "npm install -g @vue/language-server", - eslint: "npm install -g vscode-langservers-extracted", - oxlint: "npm install -g oxlint", - biome: "npm install -g @biomejs/biome", - gopls: "go install golang.org/x/tools/gopls@latest", - "ruby-lsp": "gem install ruby-lsp", - basedpyright: "pip install basedpyright", - pyright: "pip install pyright", - ty: "pip install ty", - ruff: "pip install ruff", - "elixir-ls": "See https://github.com/elixir-lsp/elixir-ls", - zls: "See https://github.com/zigtools/zls", - csharp: "dotnet tool install -g csharp-ls", - fsharp: "dotnet tool install -g fsautocomplete", - "sourcekit-lsp": "Included with Xcode or Swift toolchain", - rust: "rustup component add rust-analyzer", - clangd: "See https://clangd.llvm.org/installation", - svelte: "npm install -g svelte-language-server", - astro: "npm install -g @astrojs/language-server", - "bash-ls": "npm install -g bash-language-server", - jdtls: "See https://github.com/eclipse-jdtls/eclipse.jdt.ls", - "yaml-ls": "npm install -g yaml-language-server", - "lua-ls": "See https://github.com/LuaLS/lua-language-server", - php: "npm install -g intelephense", - dart: "Included with Dart SDK", - "terraform-ls": "See https://github.com/hashicorp/terraform-ls", - terraform: "See https://github.com/hashicorp/terraform-ls", - prisma: "npm install -g prisma", - "ocaml-lsp": "opam install ocaml-lsp-server", - texlab: "See https://github.com/latex-lsp/texlab", - dockerfile: "npm install -g dockerfile-language-server-nodejs", - gleam: "See https://gleam.run/getting-started/installing/", - "clojure-lsp": "See https://clojure-lsp.io/installation/", - nixd: "nix profile install nixpkgs#nixd", - tinymist: "See https://github.com/Myriad-Dreamin/tinymist", - "haskell-language-server": "ghcup install hls", - bash: "npm install -g bash-language-server", - "kotlin-ls": "See https://github.com/Kotlin/kotlin-lsp", -}; -export const BUILTIN_SERVERS = { - typescript: { - command: ["typescript-language-server", "--stdio"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"], - }, - deno: { command: ["deno", "lsp"], extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs"] }, - vue: { command: ["vue-language-server", "--stdio"], extensions: [".vue"] }, - eslint: { - command: ["vscode-eslint-language-server", "--stdio"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue"], - }, - oxlint: { - command: ["oxlint", "--lsp"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".astro", ".svelte"], - }, - biome: { - command: ["biome", "lsp-proxy", "--stdio"], - extensions: [ - ".ts", - ".tsx", - ".js", - ".jsx", - ".mjs", - ".cjs", - ".mts", - ".cts", - ".json", - ".jsonc", - ".vue", - ".astro", - ".svelte", - ".css", - ".graphql", - ".gql", - ".html", - ], - }, - gopls: { command: ["gopls"], extensions: [".go"] }, - "ruby-lsp": { - command: ["rubocop", "--lsp"], - extensions: [".rb", ".rake", ".gemspec", ".ru"], - }, - basedpyright: { - command: ["basedpyright-langserver", "--stdio"], - extensions: [".py", ".pyi"], - }, - pyright: { command: ["pyright-langserver", "--stdio"], extensions: [".py", ".pyi"] }, - ty: { command: ["ty", "server"], extensions: [".py", ".pyi"] }, - ruff: { command: ["ruff", "server"], extensions: [".py", ".pyi"] }, - "elixir-ls": { command: ["elixir-ls"], extensions: [".ex", ".exs"] }, - zls: { command: ["zls"], extensions: [".zig", ".zon"] }, - csharp: { command: ["csharp-ls"], extensions: [".cs"] }, - fsharp: { command: ["fsautocomplete"], extensions: [".fs", ".fsi", ".fsx", ".fsscript"] }, - "sourcekit-lsp": { command: ["sourcekit-lsp"], extensions: [".swift", ".objc", ".objcpp"] }, - rust: { command: ["rust-analyzer"], extensions: [".rs"] }, - clangd: { - command: ["clangd", "--background-index", "--clang-tidy"], - extensions: [".c", ".cpp", ".cc", ".cxx", ".c++", ".h", ".hpp", ".hh", ".hxx", ".h++"], - }, - svelte: { command: ["svelteserver", "--stdio"], extensions: [".svelte"] }, - astro: { command: ["astro-ls", "--stdio"], extensions: [".astro"] }, - bash: { - command: ["bash-language-server", "start"], - extensions: [".sh", ".bash", ".zsh", ".ksh"], - }, - "bash-ls": { - command: ["bash-language-server", "start"], - extensions: [".sh", ".bash", ".zsh", ".ksh"], - }, - jdtls: { command: ["jdtls"], extensions: [".java"] }, - "yaml-ls": { command: ["yaml-language-server", "--stdio"], extensions: [".yaml", ".yml"] }, - "lua-ls": { command: ["lua-language-server"], extensions: [".lua"] }, - php: { command: ["intelephense", "--stdio"], extensions: [".php"] }, - dart: { command: ["dart", "language-server", "--lsp"], extensions: [".dart"] }, - terraform: { command: ["terraform-ls", "serve"], extensions: [".tf", ".tfvars"] }, - "terraform-ls": { command: ["terraform-ls", "serve"], extensions: [".tf", ".tfvars"] }, - prisma: { command: ["prisma", "language-server"], extensions: [".prisma"] }, - "ocaml-lsp": { command: ["ocamllsp"], extensions: [".ml", ".mli"] }, - texlab: { command: ["texlab"], extensions: [".tex", ".bib"] }, - dockerfile: { command: ["docker-langserver", "--stdio"], extensions: [".dockerfile"] }, - gleam: { command: ["gleam", "lsp"], extensions: [".gleam"] }, - "clojure-lsp": { - command: ["clojure-lsp", "listen"], - extensions: [".clj", ".cljs", ".cljc", ".edn"], - }, - nixd: { command: ["nixd"], extensions: [".nix"] }, - tinymist: { command: ["tinymist"], extensions: [".typ", ".typc"] }, - "haskell-language-server": { - command: ["haskell-language-server-wrapper", "--lsp"], - extensions: [".hs", ".lhs"], - }, - "kotlin-ls": { command: ["kotlin-lsp"], extensions: [".kt", ".kts"] }, -}; -export const AUTO_INSTALLABLE_SERVERS = { - typescript: ["npm", "install", "-g", "typescript-language-server", "typescript"], - vue: ["npm", "install", "-g", "@vue/language-server"], - eslint: ["npm", "install", "-g", "vscode-langservers-extracted"], - oxlint: ["npm", "install", "-g", "oxlint"], - biome: ["npm", "install", "-g", "@biomejs/biome"], - svelte: ["npm", "install", "-g", "svelte-language-server"], - astro: ["npm", "install", "-g", "@astrojs/language-server"], - "bash-ls": ["npm", "install", "-g", "bash-language-server"], - bash: ["npm", "install", "-g", "bash-language-server"], - "yaml-ls": ["npm", "install", "-g", "yaml-language-server"], - php: ["npm", "install", "-g", "intelephense"], - prisma: ["npm", "install", "-g", "prisma"], - dockerfile: ["npm", "install", "-g", "dockerfile-language-server-nodejs"], - gopls: ["go", "install", "golang.org/x/tools/gopls@latest"], - pyright: ["pip", "install", "pyright"], - basedpyright: ["pip", "install", "basedpyright"], - ruff: ["pip", "install", "ruff"], - ty: ["pip", "install", "ty"], - "ruby-lsp": ["gem", "install", "ruby-lsp"], - rust: ["rustup", "component", "add", "rust-analyzer"], - "ocaml-lsp": ["opam", "install", "ocaml-lsp-server"], -}; -//# sourceMappingURL=server-definitions.js.map \ No newline at end of file diff --git a/dist/lsp/server-definitions.js.map b/dist/lsp/server-definitions.js.map deleted file mode 100644 index c3a7a04..0000000 --- a/dist/lsp/server-definitions.js.map +++ /dev/null @@ -1 +0,0 @@ -{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C;IAC7C,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;IAC1C,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,mCAAmC,CAAC;IACzE,KAAK,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,iCAAiC,CAAC;IAC3D,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC;IACtC,YAAY,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC;IAChD,IAAI,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC;IAChC,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC;IAC5B,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC;IAC1C,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe,CAAC;IACrD,WAAW,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,kBAAkB,CAAC;CACpD,CAAC"} \ No newline at end of file diff --git a/dist/lsp/server-installation.d.ts b/dist/lsp/server-installation.d.ts deleted file mode 100644 index ef8dc7a..0000000 --- a/dist/lsp/server-installation.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare function getAdditionalPathBases(workingDirectory: string): string[]; -export declare function isServerInstalled(command: string[]): boolean; -//# sourceMappingURL=server-installation.d.ts.map \ No newline at end of file diff --git a/dist/lsp/server-installation.d.ts.map b/dist/lsp/server-installation.d.ts.map deleted file mode 100644 index 4b170e9..0000000 --- a/dist/lsp/server-installation.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server-installation.d.ts","sourceRoot":"","sources":["../../src/lsp/server-installation.ts"],"names":[],"mappings":"AAGA,wBAAgB,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAiD5D"} \ No newline at end of file diff --git a/dist/lsp/server-installation.js b/dist/lsp/server-installation.js deleted file mode 100644 index 6409ef7..0000000 --- a/dist/lsp/server-installation.js +++ /dev/null @@ -1,51 +0,0 @@ -import { existsSync } from "node:fs"; -import { delimiter, join } from "node:path"; -export function getAdditionalPathBases(workingDirectory) { - return [join(workingDirectory, "node_modules", ".bin")]; -} -export function isServerInstalled(command) { - if (command.length === 0) - return false; - const [cmd] = command; - if (!cmd) - return false; - if (cmd.includes("/") || cmd.includes("\\")) { - if (existsSync(cmd)) - return true; - } - const isWindows = process.platform === "win32"; - let exts = [""]; - if (isWindows) { - const pathExt = process.env.PATHEXT ?? ""; - if (pathExt) { - const systemExts = pathExt.split(";").filter(Boolean); - exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])]; - } - else { - exts = ["", ".exe", ".cmd", ".bat", ".ps1"]; - } - } - let pathEnv = process.env.PATH ?? ""; - if (isWindows && !pathEnv) { - pathEnv = process.env.Path ?? ""; - } - const paths = pathEnv.split(delimiter); - for (const p of paths) { - for (const suffix of exts) { - if (existsSync(join(p, cmd + suffix))) { - return true; - } - } - } - for (const base of getAdditionalPathBases(process.cwd())) { - for (const suffix of exts) { - if (existsSync(join(base, cmd + suffix))) { - return true; - } - } - } - if (cmd === "node") - return true; - return false; -} -//# sourceMappingURL=server-installation.js.map \ No newline at end of file diff --git a/dist/lsp/server-installation.js.map b/dist/lsp/server-installation.js.map deleted file mode 100644 index 6dbcb82..0000000 --- a/dist/lsp/server-installation.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server-installation.js","sourceRoot":"","sources":["../../src/lsp/server-installation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,UAAU,sBAAsB,CAAC,gBAAwB;IAC9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O,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEvC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;YAC3B,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,sBAAsB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC;QAC1D,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE,CAAC;YAC3B,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC;gBAC1C,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAED,IAAI,GAAG,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IAEhC,OAAO,KAAK,CAAC;AACd,CAAC"} \ No newline at end of file diff --git a/dist/lsp/server-resolution.d.ts b/dist/lsp/server-resolution.d.ts deleted file mode 100644 index ad1569e..0000000 --- a/dist/lsp/server-resolution.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { ServerLookupResult } from "./types.js"; -export declare function findServerForExtension(ext: string): ServerLookupResult; -export interface ServerStatus { - id: string; - installed: boolean; - extensions: string[]; - disabled: boolean; - source: string; - priority: number; -} -export declare function getAllServers(): ServerStatus[]; -//# sourceMappingURL=server-resolution.d.ts.map \ No newline at end of file diff --git a/dist/lsp/server-resolution.d.ts.map b/dist/lsp/server-resolution.d.ts.map deleted file mode 100644 index 1bcc650..0000000 --- a/dist/lsp/server-resolution.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server-resolution.d.ts","sourceRoot":"","sources":["../../src/lsp/server-resolution.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAyCtE;AAED,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,IAAI,YAAY,EAAE,CAkC9C"} \ No newline at end of file diff --git a/dist/lsp/server-resolution.js b/dist/lsp/server-resolution.js deleted file mode 100644 index 25cddea..0000000 --- a/dist/lsp/server-resolution.js +++ /dev/null @@ -1,75 +0,0 @@ -import { getDisabledServerIds, getMergedServers } from "./config-loader.js"; -import { BUILTIN_SERVERS, LSP_INSTALL_HINTS } from "./server-definitions.js"; -import { isServerInstalled } from "./server-installation.js"; -export function findServerForExtension(ext) { - const servers = getMergedServers(); - for (const server of servers) { - if (server.extensions.includes(ext) && isServerInstalled(server.command)) { - return { - status: "found", - server: { - id: server.id, - command: server.command, - extensions: server.extensions, - priority: server.priority, - env: server.env, - initialization: server.initialization, - }, - }; - } - } - for (const server of servers) { - if (server.extensions.includes(ext)) { - const installHint = LSP_INSTALL_HINTS[server.id] ?? `Install '${server.command[0]}' and ensure it's in your PATH`; - return { - status: "not_installed", - server: { - id: server.id, - command: server.command, - extensions: server.extensions, - }, - installHint, - }; - } - } - const availableServers = [...new Set(servers.map((s) => s.id))]; - return { - status: "not_configured", - extension: ext, - availableServers, - }; -} -export function getAllServers() { - const servers = getMergedServers(); - const disabled = getDisabledServerIds(); - const result = []; - const seen = new Set(); - for (const server of servers) { - if (seen.has(server.id)) - continue; - result.push({ - id: server.id, - installed: isServerInstalled(server.command), - extensions: server.extensions, - disabled: false, - source: server.source, - priority: server.priority, - }); - seen.add(server.id); - } - for (const id of disabled) { - if (seen.has(id)) - continue; - const builtin = BUILTIN_SERVERS[id]; - result.push({ - id, - installed: builtin ? isServerInstalled(builtin.command) : false, - extensions: builtin?.extensions ?? [], - disabled: true, - source: "disabled", - priority: 0, - }); - } - return result; -} -//# sourceMappingURL=server-resolution.js.map \ No newline at end of file diff --git a/dist/lsp/server-resolution.js.map b/dist/lsp/server-resolution.js.map deleted file mode 100644 index d33d276..0000000 --- a/dist/lsp/server-resolution.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"server-resolution.js","sourceRoot":"","sources":["../../src/lsp/server-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,MAAM,UAAU,sBAAsB,CAAC,GAAW;IACjD,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1E,OAAO;gBACN,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE;oBACP,EAAE,EAAE,MAAM,CAAC,EAAE;oBACb,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,UAAU,EAAE,MAAM,CAAC,UAAU;oBAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,GAAG,EAAE,MAAM,CAAC,GAAG;oBACf,cAAc,EAAE,MAAM,CAAC,cAAc;iBACrC;aACD,CAAC;QACH,CAAC;IACF,CAAC;IAED,KAAK,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M,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAS;QAC3B,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC;YACX,EAAE;YACF,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;YAC/D,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,EAAE;YACrC,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,CAAC;SACX,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/dist/lsp/transport.d.ts b/dist/lsp/transport.d.ts deleted file mode 100644 index dff1a01..0000000 --- a/dist/lsp/transport.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { JsonRpcConnection } from "./json-rpc-connection.js"; -import { type SpawnedProcess } from "./process.js"; -import type { Diagnostic, ResolvedServer } from "./types.js"; -export declare class LspClientTransport { - protected readonly root: string; - protected readonly server: ResolvedServer; - protected proc: SpawnedProcess | null; - protected connection: JsonRpcConnection | null; - protected readonly stderrBuffer: string[]; - protected processExited: boolean; - protected readonly diagnosticsStore: Map; - constructor(root: string, server: ResolvedServer); - pid(): number | undefined; - command(): string[]; - start(): Promise; - protected startStderrReading(): void; - private isConnectionClosedError; - protected sendRequest(method: string): Promise; - protected sendRequest(method: string, params: unknown): Promise; - protected sendNotification(method: string): Promise; - protected sendNotification(method: string, params: unknown): Promise; - isAlive(): boolean; - stop(): Promise; - getStoredDiagnostics(uri: string): Diagnostic[]; -} -//# sourceMappingURL=transport.d.ts.map \ No newline at end of file diff --git a/dist/lsp/transport.d.ts.map b/dist/lsp/transport.d.ts.map deleted file mode 100644 index c9961fb..0000000 --- a/dist/lsp/transport.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/lsp/transport.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,KAAK,cAAc,EAAgB,MAAM,cAAc,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA+B7D,qBAAa,kBAAkB;IAQ7B,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAC/B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc;IAR1C,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAQ;IAC7C,SAAS,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IACtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAM;IAC/C,SAAS,CAAC,aAAa,UAAS;IAChC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,4BAAmC;gBAGlD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc;IAG1C,GAAG,IAAI,MAAM,GAAG,SAAS;IAIzB,OAAO,IAAI,MAAM,EAAE;IAIb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwD5B,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAWpC,OAAO,CAAC,uBAAuB;IAW/B,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IACpD,SAAS,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IA+CrE,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACzD,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB1E,OAAO,IAAI,OAAO;IAIZ,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA4D3B,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,EAAE;CAG/C"} \ No newline at end of file diff --git a/dist/lsp/transport.js b/dist/lsp/transport.js deleted file mode 100644 index a431eb5..0000000 --- a/dist/lsp/transport.js +++ /dev/null @@ -1,234 +0,0 @@ -import { delimiter } from "node:path"; -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { REQUEST_TIMEOUT_MS, STOP_HARD_KILL_TIMEOUT_MS, STOP_SIGKILL_GRACE_MS } from "./constants.js"; -import { LspConnectionClosedError, LspProcessExitedError, LspRequestTimeoutError } from "./errors.js"; -import { JsonRpcConnection } from "./json-rpc-connection.js"; -import { spawnProcess } from "./process.js"; -import { getAdditionalPathBases } from "./server-installation.js"; -function isRecord(value) { - return typeof value === "object" && value !== null && !Array.isArray(value); -} -function parseConfigurationItems(params) { - if (!isRecord(params) || !Array.isArray(params.items)) - return []; - const items = []; - for (const item of params.items) { - if (!isRecord(item)) - continue; - items.push({ section: typeof item.section === "string" ? item.section : undefined }); - } - return items; -} -function parseDiagnosticsParams(params) { - if (!isRecord(params) || typeof params.uri !== "string") - return null; - const diagnostics = Array.isArray(params.diagnostics) ? params.diagnostics : []; - return { uri: params.uri, diagnostics }; -} -export class LspClientTransport { - constructor(root, server) { - this.root = root; - this.server = server; - this.proc = null; - this.connection = null; - this.stderrBuffer = []; - this.processExited = false; - this.diagnosticsStore = new Map(); - } - pid() { - return this.proc?.pid; - } - command() { - return [...this.server.command]; - } - async start() { - const env = { - ...process.env, - ...this.server.env, - }; - const pathValue = process.platform === "win32" ? (env.PATH ?? env.Path ?? "") : (env.PATH ?? ""); - const spawnPath = [pathValue, ...getAdditionalPathBases(this.root)].filter(Boolean).join(delimiter); - if (process.platform === "win32" && env.Path !== undefined) { - env.Path = spawnPath; - } - env.PATH = spawnPath; - this.proc = spawnProcess(this.server.command, { - cwd: this.root, - env, - }); - this.startStderrReading(); - await new Promise((resolve) => setTimeout(resolve, 100)); - if (this.proc.exitCode !== null) { - const stderr = this.stderrBuffer.join("\n"); - throw new LspProcessExitedError(this.server.id, this.root, this.proc.exitCode, stderr.slice(-2000)); - } - this.connection = new JsonRpcConnection(this.proc.stdout, this.proc.stdin); - this.connection.onNotification("textDocument/publishDiagnostics", (params) => { - const diagnosticsParams = parseDiagnosticsParams(params); - if (diagnosticsParams?.uri) { - this.diagnosticsStore.set(diagnosticsParams.uri, diagnosticsParams.diagnostics); - } - }); - this.connection.onRequest("workspace/configuration", (params) => { - const items = parseConfigurationItems(params); - return items.map((item) => { - if (item.section === "json") - return { validate: { enable: true } }; - return {}; - }); - }); - this.connection.onRequest("client/registerCapability", () => null); - this.connection.onRequest("window/workDoneProgress/create", () => null); - this.connection.onClose(() => { - this.processExited = true; - }); - this.connection.onError((error) => { - reportBestEffortCleanupError("connection error notification", error); - }); - this.connection.listen(); - } - startStderrReading() { - if (!this.proc) - return; - this.proc.stderr.setEncoding("utf-8"); - this.proc.stderr.on("data", (chunk) => { - this.stderrBuffer.push(chunk); - if (this.stderrBuffer.length > 100) { - this.stderrBuffer.shift(); - } - }); - } - isConnectionClosedError(error) { - if (!(error instanceof Error)) { - return false; - } - const code = "code" in error && typeof error.code === "string" ? error.code : undefined; - return (code === "ERR_STREAM_DESTROYED" || - /connection closed|connection is disposed|stream was destroyed/i.test(error.message)); - } - async sendRequest(method, ...args) { - if (!this.connection) - throw new Error("LSP client not started"); - if (this.processExited || (this.proc && this.proc.exitCode !== null)) { - const stderrTail = this.stderrBuffer.slice(-10).join("\n"); - throw new LspProcessExitedError(this.server.id, this.root, this.proc?.exitCode ?? null, stderrTail || undefined); - } - let timeoutHandle = null; - const timeoutPromise = new Promise((_, reject) => { - timeoutHandle = setTimeout(() => { - const stderrTail = this.stderrBuffer.slice(-5).join("\n"); - reject(new LspRequestTimeoutError(method, stderrTail || undefined)); - }, REQUEST_TIMEOUT_MS); - }); - try { - const requestPromise = args.length === 0 - ? this.connection.sendRequest(method) - : this.connection.sendRequest(method, args[0]); - const result = await Promise.race([requestPromise, timeoutPromise]); - if (timeoutHandle !== null) - clearTimeout(timeoutHandle); - return result; - } - catch (error) { - if (timeoutHandle !== null) - clearTimeout(timeoutHandle); - if (this.processExited || (this.proc && this.proc.exitCode !== null)) { - throw new LspProcessExitedError(this.server.id, this.root, this.proc?.exitCode ?? null, this.stderrBuffer.slice(-10).join("\n") || undefined); - } - if (this.isConnectionClosedError(error)) { - throw new LspConnectionClosedError(this.server.id, this.root, error.message); - } - throw error; - } - } - async sendNotification(method, ...args) { - if (!this.connection) - return; - if (this.processExited || (this.proc && this.proc.exitCode !== null)) - return; - try { - if (args.length === 0) { - await this.connection.sendNotification(method); - } - else { - await this.connection.sendNotification(method, args[0]); - } - } - catch (error) { - if (this.isConnectionClosedError(error)) { - throw new LspConnectionClosedError(this.server.id, this.root, error.message); - } - throw error; - } - } - isAlive() { - return this.proc !== null && !this.processExited && this.proc.exitCode === null; - } - async stop() { - if (this.connection) { - try { - await this.sendRequest("shutdown"); - } - catch (error) { - reportBestEffortCleanupError("shutdown request", error); - } - try { - await this.sendNotification("exit"); - } - catch (error) { - reportBestEffortCleanupError("exit notification", error); - } - try { - this.connection.dispose(); - } - catch (error) { - reportBestEffortCleanupError("connection dispose", error); - } - this.connection = null; - } - const proc = this.proc; - if (proc) { - this.proc = null; - let exitedBeforeTimeout = false; - try { - proc.kill(); - let timeoutId; - const timeoutPromise = new Promise((resolve) => { - timeoutId = setTimeout(resolve, STOP_HARD_KILL_TIMEOUT_MS); - }); - await Promise.race([ - proc.exited - .then(() => { - exitedBeforeTimeout = true; - }) - .finally(() => { - if (timeoutId) - clearTimeout(timeoutId); - }), - timeoutPromise, - ]); - if (!exitedBeforeTimeout) { - try { - proc.kill("SIGKILL"); - await Promise.race([ - proc.exited, - new Promise((resolve) => setTimeout(resolve, STOP_SIGKILL_GRACE_MS)), - ]); - } - catch (error) { - reportBestEffortCleanupError("hard process kill", error); - } - } - } - catch (error) { - reportBestEffortCleanupError("process stop", error); - } - } - this.processExited = true; - this.diagnosticsStore.clear(); - } - getStoredDiagnostics(uri) { - return this.diagnosticsStore.get(uri) ?? []; - } -} -//# sourceMappingURL=transport.js.map \ No newline at end of file diff --git a/dist/lsp/transport.js.map b/dist/lsp/transport.js.map deleted file mode 100644 index 917f037..0000000 --- a/dist/lsp/transport.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/lsp/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACtG,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAuB,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAYlE,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAe;IAC/C,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,C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B,CAAC;IAED,oBAAoB,CAAC,GAAW;QAC/B,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IAC7C,CAAC;CACD"} \ No newline at end of file diff --git a/dist/lsp/types.d.ts b/dist/lsp/types.d.ts deleted file mode 100644 index 3d4b285..0000000 --- a/dist/lsp/types.d.ts +++ /dev/null @@ -1,125 +0,0 @@ -export interface LspServerConfig { - id: string; - command: string[]; - extensions: string[]; - disabled?: boolean; - env?: Record; - initialization?: Record; -} -export interface ResolvedServer { - id: string; - command: string[]; - extensions: string[]; - priority: number; - env?: Record; - initialization?: Record; -} -export interface ServerLookupInfo { - id: string; - command: string[]; - extensions: string[]; -} -export type ServerLookupResult = { - status: "found"; - server: ResolvedServer; -} | { - status: "not_configured"; - extension: string; - availableServers: string[]; -} | { - status: "not_installed"; - server: ServerLookupInfo; - installHint: string; -}; -export interface Position { - line: number; - character: number; -} -export interface Range { - start: Position; - end: Position; -} -export interface Location { - uri: string; - range: Range; -} -export interface LocationLink { - targetUri: string; - targetRange: Range; - targetSelectionRange: Range; - originSelectionRange?: Range; -} -export interface SymbolInfo { - name: string; - kind: number; - location: Location; - containerName?: string; -} -export interface DocumentSymbol { - name: string; - kind: number; - range: Range; - selectionRange: Range; - children?: DocumentSymbol[]; -} -export interface Diagnostic { - range: Range; - severity?: number; - code?: string | number; - source?: string; - message: string; -} -export interface TextDocumentIdentifier { - uri: string; -} -export interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier { - version: number | null; -} -export interface TextEdit { - range: Range; - newText: string; -} -export interface TextDocumentEdit { - textDocument: VersionedTextDocumentIdentifier; - edits: TextEdit[]; -} -export interface CreateFile { - kind: "create"; - uri: string; - options?: { - overwrite?: boolean; - ignoreIfExists?: boolean; - }; -} -export interface RenameFile { - kind: "rename"; - oldUri: string; - newUri: string; - options?: { - overwrite?: boolean; - ignoreIfExists?: boolean; - }; -} -export interface DeleteFile { - kind: "delete"; - uri: string; - options?: { - recursive?: boolean; - ignoreIfNotExists?: boolean; - }; -} -export interface WorkspaceEdit { - changes?: { - [uri: string]: TextEdit[]; - }; - documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]; -} -export interface PrepareRenameResult { - range: Range; - placeholder?: string; -} -export interface PrepareRenameDefaultBehavior { - defaultBehavior: boolean; -} -export type SeverityFilter = "error" | "warning" | "information" | "hint" | "all"; -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/dist/lsp/types.d.ts.map b/dist/lsp/types.d.ts.map deleted file mode 100644 index f7332a7..0000000 --- a/dist/lsp/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lsp/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,MAAM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CAAC,EAAE,CAAC;CAC9E;AAED,MAAM,WAAW,mBAAmB;IACnC,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA4B;IAC5C,eAAe,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,GAAG,KAAK,CAAC"} \ No newline at end of file diff --git a/dist/lsp/types.js b/dist/lsp/types.js deleted file mode 100644 index 718fd38..0000000 --- a/dist/lsp/types.js +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/dist/lsp/types.js.map b/dist/lsp/types.js.map deleted file mode 100644 index aa92546..0000000 --- a/dist/lsp/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lsp/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/lsp/utils.d.ts b/dist/lsp/utils.d.ts deleted file mode 100644 index abd5e48..0000000 --- a/dist/lsp/utils.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function shorten(value: string, max: number): string; -export declare function errorMessage(error: unknown): string; -export declare function handleMissingDependencyError(error: unknown): string | null; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/dist/lsp/utils.d.ts.map b/dist/lsp/utils.d.ts.map deleted file mode 100644 index 077b9a9..0000000 --- a/dist/lsp/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lsp/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAI1D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG1E"} \ No newline at end of file diff --git a/dist/lsp/utils.js b/dist/lsp/utils.js deleted file mode 100644 index 4c0cf2f..0000000 --- a/dist/lsp/utils.js +++ /dev/null @@ -1,15 +0,0 @@ -export function shorten(value, max) { - if (value.length <= max) - return value; - if (max <= 3) - return ".".repeat(Math.max(0, max)); - return `${value.slice(0, max - 3)}...`; -} -export function errorMessage(error) { - return error instanceof Error ? error.message : String(error); -} -export function handleMissingDependencyError(error) { - const message = errorMessage(error); - return message.includes("NOT INSTALLED") || message.includes("No LSP server configured") ? message : null; -} -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/lsp/utils.js.map b/dist/lsp/utils.js.map deleted file mode 100644 index 7526476..0000000 --- a/dist/lsp/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lsp/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,GAAW;IACjD,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAClD,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAc;IAC1C,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAc;IAC1D,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3G,CAAC"} \ No newline at end of file diff --git a/dist/lsp/workspace-edit.d.ts b/dist/lsp/workspace-edit.d.ts deleted file mode 100644 index 9a323b6..0000000 --- a/dist/lsp/workspace-edit.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { WorkspaceEdit } from "./types.js"; -export interface ApplyResult { - success: boolean; - filesModified: string[]; - totalEdits: number; - errors: string[]; -} -export declare function applyWorkspaceEdit(edit: WorkspaceEdit | null): ApplyResult; -//# sourceMappingURL=workspace-edit.d.ts.map \ No newline at end of file diff --git a/dist/lsp/workspace-edit.d.ts.map b/dist/lsp/workspace-edit.d.ts.map deleted file mode 100644 index b6ed1f7..0000000 --- a/dist/lsp/workspace-edit.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"workspace-edit.d.ts","sourceRoot":"","sources":["../../src/lsp/workspace-edit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAY,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAgDD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,GAAG,WAAW,CAyE1E"} \ No newline at end of file diff --git a/dist/lsp/workspace-edit.js b/dist/lsp/workspace-edit.js deleted file mode 100644 index efeef6c..0000000 --- a/dist/lsp/workspace-edit.js +++ /dev/null @@ -1,114 +0,0 @@ -import { readFileSync, unlinkSync, writeFileSync } from "node:fs"; -import { uriToPath } from "./formatters.js"; -function applyTextEditsToFile(filePath, edits) { - try { - const content = readFileSync(filePath, "utf-8"); - const lines = content.split("\n"); - const sortedEdits = [...edits].sort((a, b) => { - if (b.range.start.line !== a.range.start.line) { - return b.range.start.line - a.range.start.line; - } - return b.range.start.character - a.range.start.character; - }); - for (const edit of sortedEdits) { - const startLine = edit.range.start.line; - const startChar = edit.range.start.character; - const endLine = edit.range.end.line; - const endChar = edit.range.end.character; - if (startLine === endLine) { - const line = lines[startLine] ?? ""; - lines[startLine] = line.substring(0, startChar) + edit.newText + line.substring(endChar); - } - else { - const firstLine = lines[startLine] ?? ""; - const lastLine = lines[endLine] ?? ""; - const newContent = firstLine.substring(0, startChar) + edit.newText + lastLine.substring(endChar); - lines.splice(startLine, endLine - startLine + 1, ...newContent.split("\n")); - } - } - writeFileSync(filePath, lines.join("\n"), "utf-8"); - return { success: true, editCount: edits.length }; - } - catch (err) { - return { - success: false, - editCount: 0, - error: err instanceof Error ? err.message : String(err), - }; - } -} -export function applyWorkspaceEdit(edit) { - if (!edit) { - return { success: false, filesModified: [], totalEdits: 0, errors: ["No edit provided"] }; - } - const result = { success: true, filesModified: [], totalEdits: 0, errors: [] }; - if (edit.changes) { - for (const [uri, edits] of Object.entries(edit.changes)) { - const filePath = uriToPath(uri); - const applyResult = applyTextEditsToFile(filePath, edits); - if (applyResult.success) { - result.filesModified.push(filePath); - result.totalEdits += applyResult.editCount; - } - else { - result.success = false; - result.errors.push(`${filePath}: ${applyResult.error}`); - } - } - } - if (edit.documentChanges) { - for (const change of edit.documentChanges) { - if (!("kind" in change)) { - const filePath = uriToPath(change.textDocument.uri); - const applyResult = applyTextEditsToFile(filePath, change.edits); - if (applyResult.success) { - result.filesModified.push(filePath); - result.totalEdits += applyResult.editCount; - } - else { - result.success = false; - result.errors.push(`${filePath}: ${applyResult.error}`); - } - continue; - } - if (change.kind === "create") { - try { - const filePath = uriToPath(change.uri); - writeFileSync(filePath, "", "utf-8"); - result.filesModified.push(filePath); - } - catch (err) { - result.success = false; - result.errors.push(`Create ${change.uri}: ${String(err)}`); - } - } - else if (change.kind === "rename") { - try { - const oldPath = uriToPath(change.oldUri); - const newPath = uriToPath(change.newUri); - const content = readFileSync(oldPath, "utf-8"); - writeFileSync(newPath, content, "utf-8"); - unlinkSync(oldPath); - result.filesModified.push(newPath); - } - catch (err) { - result.success = false; - result.errors.push(`Rename ${change.oldUri}: ${String(err)}`); - } - } - else if (change.kind === "delete") { - try { - const filePath = uriToPath(change.uri); - unlinkSync(filePath); - result.filesModified.push(filePath); - } - catch (err) { - result.success = false; - result.errors.push(`Delete ${change.uri}: ${String(err)}`); - } - } - } - } - return result; -} -//# sourceMappingURL=workspace-edit.js.map \ No newline at end of file diff --git a/dist/lsp/workspace-edit.js.map b/dist/lsp/workspace-edit.js.map deleted file mode 100644 index ea44e02..0000000 --- a/dist/lsp/workspace-edit.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"workspace-edit.js","sourceRoot":"","sources":["../../src/lsp/workspace-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAgB5C,SAAS,oBAAoB,CAAC,QAAgB,EAAE,KAAiB;IAChE,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAElC,MAAM,WAAW,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC5C,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC/C,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;YAChD,CAAC;YACD,OAAO,CAAC,CAA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,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"} \ No newline at end of file diff --git a/dist/mcp.d.ts b/dist/mcp.d.ts deleted file mode 100644 index 818f8b3..0000000 --- a/dist/mcp.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { type TextContent } from "./tools.js"; -export type JsonRpcId = string | number | null; -export interface McpToolDescriptor { - name: string; - title: string; - description: string; - inputSchema: unknown; -} -export interface JsonRpcError { - code: number; - message: string; - data?: unknown; -} -export interface JsonRpcResult { - capabilities?: Record; - serverInfo?: Record; - protocolVersion?: string; - tools?: McpToolDescriptor[]; - content?: TextContent[]; - isError?: boolean; - [key: string]: unknown; -} -export interface JsonRpcResponse { - jsonrpc: "2.0"; - id: JsonRpcId; - result?: JsonRpcResult; - error?: JsonRpcError; -} -export declare function handleLspMcpRequest(input: unknown): Promise; -export declare function runMcpStdioServer(input?: NodeJS.ReadableStream, output?: NodeJS.WritableStream): Promise; -//# sourceMappingURL=mcp.d.ts.map \ No newline at end of file diff --git a/dist/mcp.d.ts.map b/dist/mcp.d.ts.map deleted file mode 100644 index 2e143dd..0000000 --- a/dist/mcp.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../src/mcp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsD,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAElG,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAKD,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CA0B9F;AAED,wBAAsB,iBAAiB,CACtC,KAAK,GAAE,MAAM,CAAC,cAA8B,EAC5C,MAAM,GAAE,MAAM,CAAC,cAA+B,GAC5C,OAAO,CAAC,IAAI,CAAC,CAef"} \ No newline at end of file diff --git a/dist/mcp.js b/dist/mcp.js deleted file mode 100644 index 1b48851..0000000 --- a/dist/mcp.js +++ /dev/null @@ -1,95 +0,0 @@ -import { createInterface } from "node:readline"; -import { coerceToolArguments, executeLspTool, LSP_MCP_TOOLS } from "./tools.js"; -const SERVER_NAME = "lsp"; -const SERVER_VERSION = "0.1.0"; -export async function handleLspMcpRequest(input) { - if (!isRecord(input)) { - return errorResponse(null, -32600, "Invalid Request"); - } - const id = jsonRpcId(input.id); - if (input.method === "notifications/initialized") - return undefined; - if (input.method === "ping") - return successResponse(id, {}); - if (input.method === "initialize") { - const protocolVersion = requestedProtocolVersion(input.params); - return successResponse(id, { - capabilities: { tools: { listChanged: false } }, - serverInfo: { name: SERVER_NAME, version: SERVER_VERSION }, - protocolVersion, - }); - } - if (input.method === "tools/list") { - return successResponse(id, { tools: LSP_MCP_TOOLS.map(describeTool) }); - } - if (input.method === "tools/call") { - return handleToolCall(id, input.params); - } - return errorResponse(id, -32601, `Method not found: ${String(input.method)}`); -} -export async function runMcpStdioServer(input = process.stdin, output = process.stdout) { - const lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY }); - for await (const line of lines) { - if (!line.trim()) - continue; - let parsed; - try { - parsed = JSON.parse(line); - } - catch (error) { - output.write(`${JSON.stringify(errorResponse(null, -32700, "Parse error", messageFromError(error)))}\n`); - continue; - } - const response = await handleLspMcpRequest(parsed); - if (response) - output.write(`${JSON.stringify(response)}\n`); - } -} -async function handleToolCall(id, params) { - if (!isRecord(params) || typeof params.name !== "string") { - return errorResponse(id, -32602, "tools/call requires params.name"); - } - try { - const result = await executeLspTool(params.name, coerceToolArguments(params.arguments)); - return successResponse(id, { - content: result.content, - isError: result.isError ?? false, - details: result.details, - }); - } - catch (error) { - return successResponse(id, { - content: [{ type: "text", text: messageFromError(error) }], - isError: true, - }); - } -} -function describeTool(tool) { - return { - name: tool.name, - title: tool.title, - description: tool.description, - inputSchema: tool.inputSchema, - }; -} -function successResponse(id, result) { - return { jsonrpc: "2.0", id, result }; -} -function errorResponse(id, code, message, data) { - return { jsonrpc: "2.0", id, error: data === undefined ? { code, message } : { code, message, data } }; -} -function requestedProtocolVersion(params) { - if (!isRecord(params) || typeof params.protocolVersion !== "string") - return "2024-11-05"; - return params.protocolVersion; -} -function jsonRpcId(value) { - return typeof value === "string" || typeof value === "number" || value === null ? value : null; -} -function isRecord(value) { - return typeof value === "object" && value !== null && !Array.isArray(value); -} -function messageFromError(error) { - return error instanceof Error ? error.message : String(error); -} -//# sourceMappingURL=mcp.js.map \ No newline at end of file diff --git a/dist/mcp.js.map b/dist/mcp.js.map deleted file mode 100644 index c2503ab..0000000 --- a/dist/mcp.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"mcp.js","sourceRoot":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AAC;AACxG,CAAC;AAED,SAAS,wBAAwB,CAAC,MAAe;IAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAC;IACzF,OAAO,MAAM,CAAC,eAAe,CAAC;AAC/B,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAChG,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/D,CAAC"} \ No newline at end of file diff --git a/dist/tools.d.ts b/dist/tools.d.ts deleted file mode 100644 index ce83375..0000000 --- a/dist/tools.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -import type { Diagnostic, DocumentSymbol, Location, LocationLink, PrepareRenameDefaultBehavior, PrepareRenameResult, Range, SeverityFilter, SymbolInfo, WorkspaceEdit } from "./lsp/types.js"; -import { type ApplyResult } from "./lsp/workspace-edit.js"; -export interface TextContent { - type: "text"; - text: string; -} -export interface ToolExecutionResult { - content: TextContent[]; - isError?: boolean; - details?: unknown; -} -export interface JsonSchema { - type: string; - description?: string; - properties?: Record; - required?: string[]; - items?: JsonSchema; - enum?: string[]; -} -export interface LspMcpTool { - name: string; - aliases?: string[]; - title: string; - description: string; - inputSchema: JsonSchema; - execute(params: Record, signal?: AbortSignal): Promise; -} -export interface LspDiagnosticsDetails { - filePath: string; - severity: SeverityFilter; - mode: "file" | "directory"; - diagnostics: Array<{ - file: string; - diagnostic: Diagnostic; - }>; - totalDiagnostics: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency" | "no_files" | "invalid_path"; -} -export interface LspGotoDefinitionDetails { - filePath: string; - line: number; - character: number; - locations: Array; - error?: string; - errorKind?: "missing_dependency"; -} -export interface LspFindReferencesDetails { - filePath: string; - line: number; - character: number; - references: Location[]; - totalReferences: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency"; -} -export interface LspSymbolsDetails { - filePath: string; - scope: "document" | "workspace"; - query?: string; - symbols: Array; - totalSymbols: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency" | "missing_query"; -} -export interface LspPrepareRenameDetails { - filePath: string; - line: number; - character: number; - result: PrepareRenameResult | PrepareRenameDefaultBehavior | Range | null; - error?: string; - errorKind?: "missing_dependency"; -} -export interface LspRenameDetails { - filePath: string; - line: number; - character: number; - newName: string; - apply: ApplyResult | null; - edit: WorkspaceEdit | null; - error?: string; - errorKind?: "missing_dependency"; -} -export declare function executeLspDiagnostics(params: Record, signal?: AbortSignal): Promise; -export declare function executeLspTool(name: string, params: Record, signal?: AbortSignal): Promise; -export declare function coerceToolArguments(value: unknown): Record; -export declare const LSP_MCP_TOOLS: LspMcpTool[]; -//# sourceMappingURL=tools.d.ts.map \ No newline at end of file diff --git a/dist/tools.d.ts.map b/dist/tools.d.ts.map deleted file mode 100644 index babb938..0000000 --- a/dist/tools.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACX,UAAU,EACV,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,4BAA4B,EAC5B,mBAAmB,EACnB,KAAK,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,WAAW,E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ChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,oBAAoB,CAAC;CACjC;AA2FD,wBAAsB,qBAAqB,CAC1C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,mBAAmB,CAAC,CA2E9B;AA6OD,wBAAsB,cAAc,CACnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAI9B;AAMD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3E;AAED,eAAO,MAAM,aAAa,EAAE,UAAU,EA6GrC,CAAC"} \ No newline at end of file diff --git a/dist/tools.js b/dist/tools.js deleted file mode 100644 index ccbfba9..0000000 --- a/dist/tools.js +++ /dev/null @@ -1,453 +0,0 @@ -import { resolve } from "node:path"; -import { isDirectoryPath, withLspClient } from "./lsp/client-wrapper.js"; -import { DEFAULT_MAX_DIAGNOSTICS, DEFAULT_MAX_REFERENCES, DEFAULT_MAX_SYMBOLS } from "./lsp/constants.js"; -import { aggregateDiagnosticsForDirectory } from "./lsp/directory-diagnostics.js"; -import { filterDiagnosticsBySeverity, formatApplyResult, formatDiagnostic, formatDocumentSymbol, formatLocation, formatPrepareRenameResult, formatSymbolInfo, } from "./lsp/formatters.js"; -import { inferExtensionFromDirectory } from "./lsp/infer-extension.js"; -import { getLspManager } from "./lsp/manager.js"; -import { getAllServers } from "./lsp/server-resolution.js"; -import { handleMissingDependencyError } from "./lsp/utils.js"; -import { applyWorkspaceEdit } from "./lsp/workspace-edit.js"; -const objectSchema = (properties, required = []) => ({ - type: "object", - properties, - required, -}); -function text(text, details, isError = false) { - return { content: [{ type: "text", text }], details, isError }; -} -function isRecord(value) { - return typeof value === "object" && value !== null && !Array.isArray(value); -} -function requireString(params, key) { - const value = params[key]; - if (typeof value !== "string" || value.length === 0) { - throw new Error(`Missing required string parameter '${key}'`); - } - return value; -} -function optionalString(params, key) { - const value = params[key]; - return typeof value === "string" ? value : undefined; -} -function requireNumber(params, key) { - const value = params[key]; - if (typeof value !== "number" || !Number.isFinite(value)) { - throw new Error(`Missing required number parameter '${key}'`); - } - return value; -} -function optionalNumber(params, key) { - const value = params[key]; - return typeof value === "number" && Number.isFinite(value) ? value : undefined; -} -function optionalBoolean(params, key) { - const value = params[key]; - return typeof value === "boolean" ? value : undefined; -} -function isSeverityFilter(value) { - return value === "error" || value === "warning" || value === "information" || value === "hint" || value === "all"; -} -function severityFilter(params) { - const value = params.severity; - if (isSeverityFilter(value)) - return value; - return "all"; -} -function asDiagnosticArray(result) { - if (!result) - return []; - if (Array.isArray(result)) - return result; - return result.items ?? []; -} -function isDocumentSymbol(symbol) { - return "range" in symbol; -} -async function executeLspStatus() { - const servers = getAllServers(); - const snapshots = getLspManager().getSnapshot(); - const installed = servers.filter((server) => server.installed && !server.disabled); - const configuredLines = servers.map((server) => { - const state = server.disabled ? "disabled" : server.installed ? "installed" : "missing"; - return `- ${server.id}: ${state}; source=${server.source}; extensions=${server.extensions.join(", ")}`; - }); - const activeLines = snapshots.map((snapshot) => { - const state = snapshot.alive ? (snapshot.isInitializing ? "initializing" : "alive") : "dead"; - return `- ${snapshot.serverId}: ${state}; root=${snapshot.root}; refs=${snapshot.refCount}`; - }); - const lines = [ - `Configured LSP servers: ${servers.length}`, - `Installed LSP servers: ${installed.length}`, - "", - ...configuredLines, - "", - `Active LSP clients: ${snapshots.length}`, - ...activeLines, - ]; - return text(lines.join("\n"), { servers, snapshots }); -} -export async function executeLspDiagnostics(params, signal) { - const filePath = requireString(params, "filePath"); - const severity = severityFilter(params); - try { - const absPath = resolve(filePath); - if (isDirectoryPath(absPath)) { - const extension = inferExtensionFromDirectory(absPath); - if (!extension) { - const message = `No supported source files found in directory: ${absPath}`; - const details = { - filePath, - severity, - mode: "directory", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - error: message, - errorKind: "no_files", - }; - return text(message, details); - } - const output = await aggregateDiagnosticsForDirectory(absPath, extension, severity); - const details = { - filePath, - severity, - mode: "directory", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - }; - return text(output, details); - } - const result = await withLspClient(filePath, async (client) => client.diagnostics(filePath), "diagnostics", { - signal, - }); - const diagnostics = filterDiagnosticsBySeverity(asDiagnosticArray(result), severity); - const total = diagnostics.length; - const truncated = total > DEFAULT_MAX_DIAGNOSTICS; - const limited = truncated ? diagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS) : diagnostics; - const output = total === 0 - ? "No diagnostics found" - : [ - ...(truncated ? [`Found ${total} diagnostics (showing first ${DEFAULT_MAX_DIAGNOSTICS}):`] : []), - ...limited.map(formatDiagnostic), - ].join("\n"); - const details = { - filePath, - severity, - mode: "file", - diagnostics: diagnostics.map((diagnostic) => ({ file: absPath, diagnostic })), - totalDiagnostics: total, - truncated, - }; - return text(output, details); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - const details = { - filePath, - severity, - mode: "file", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }; - return text(message, details); - } - throw error; - } -} -async function executeLspGotoDefinition(params, signal) { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - try { - const result = await withLspClient(filePath, async (client) => client.definition(filePath, line, character), "definition", { signal }); - const locations = !result ? [] : Array.isArray(result) ? result : [result]; - const details = { filePath, line, character, locations }; - if (locations.length === 0) - return text("No definition found", details); - return text(locations.map(formatLocation).join("\n"), details); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - locations: [], - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} -async function executeLspFindReferences(params, signal) { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - const includeDeclaration = optionalBoolean(params, "includeDeclaration") ?? true; - try { - const result = await withLspClient(filePath, async (client) => client.references(filePath, line, character, includeDeclaration), "references", { signal }); - const references = Array.isArray(result) ? result : []; - const total = references.length; - const truncated = total > DEFAULT_MAX_REFERENCES; - const limited = truncated ? references.slice(0, DEFAULT_MAX_REFERENCES) : references; - const details = { - filePath, - line, - character, - references, - totalReferences: total, - truncated, - }; - if (total === 0) - return text("No references found", details); - const output = [ - ...(truncated ? [`Found ${total} references (showing first ${DEFAULT_MAX_REFERENCES}):`] : []), - ...limited.map(formatLocation), - ].join("\n"); - return text(output, details); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - references: [], - totalReferences: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} -async function executeLspSymbols(params, signal) { - const filePath = requireString(params, "filePath"); - const rawScope = optionalString(params, "scope") ?? "document"; - const scope = rawScope === "workspace" ? "workspace" : "document"; - const limit = Math.min(optionalNumber(params, "limit") ?? DEFAULT_MAX_SYMBOLS, DEFAULT_MAX_SYMBOLS); - try { - if (scope === "workspace") { - const query = optionalString(params, "query"); - if (!query) { - const message = "Error: 'query' is required for workspace scope"; - return text(message, { - filePath, - scope, - query: undefined, - symbols: [], - totalSymbols: 0, - truncated: false, - error: message, - errorKind: "missing_query", - }); - } - const symbols = await withLspClient(filePath, async (client) => client.workspaceSymbols(query), "workspaceSymbols", { signal }); - return formatSymbolsResult(filePath, scope, symbols, limit, query); - } - const symbols = await withLspClient(filePath, async (client) => client.documentSymbols(filePath), "documentSymbols", { signal }); - return formatSymbolsResult(filePath, scope, symbols, limit); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - scope, - query: optionalString(params, "query"), - symbols: [], - totalSymbols: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} -function formatSymbolsResult(filePath, scope, symbols, limit, query) { - const total = symbols.length; - const truncated = total > limit; - const limited = truncated ? symbols.slice(0, limit) : symbols; - const details = { filePath, scope, query, symbols, totalSymbols: total, truncated }; - if (total === 0) - return text("No symbols found", details); - const lines = []; - if (truncated) - lines.push(`Found ${total} symbols (showing first ${limit}):`); - const documentSymbols = limited.filter(isDocumentSymbol); - if (documentSymbols.length === limited.length) { - lines.push(...documentSymbols.map((symbol) => formatDocumentSymbol(symbol))); - } - else { - lines.push(...limited.filter((symbol) => !isDocumentSymbol(symbol)).map(formatSymbolInfo)); - } - return text(lines.join("\n"), details); -} -async function executeLspPrepareRename(params, signal) { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - try { - const result = await withLspClient(filePath, async (client) => client.prepareRename(filePath, line, character), "prepareRename", { signal }); - const details = { filePath, line, character, result }; - return text(formatPrepareRenameResult(result), details); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - result: null, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} -async function executeLspRename(params, signal) { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - const newName = requireString(params, "newName"); - try { - const edit = await withLspClient(filePath, async (client) => client.rename(filePath, line, character, newName), "rename", { signal }); - const apply = applyWorkspaceEdit(edit); - const details = { filePath, line, character, newName, apply, edit }; - return text(formatApplyResult(apply), details, !apply.success); - } - catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - newName, - apply: null, - edit: null, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} -export async function executeLspTool(name, params, signal) { - const tool = LSP_MCP_TOOLS.find((candidate) => matchesToolName(candidate, name)); - if (!tool) - throw new Error(`Unknown LSP tool: ${name}`); - return tool.execute(params, signal); -} -function matchesToolName(tool, name) { - return tool.name === name || (tool.aliases?.includes(name) ?? false); -} -export function coerceToolArguments(value) { - return isRecord(value) ? value : {}; -} -export const LSP_MCP_TOOLS = [ - { - name: "status", - aliases: ["lsp_status"], - title: "LSP Status", - description: "List configured and active LSP servers without starting a new language server.", - inputSchema: objectSchema({}), - execute: executeLspStatus, - }, - { - name: "diagnostics", - aliases: ["lsp_diagnostics"], - title: "LSP Diagnostics", - description: "Get errors, warnings, and hints for a source file or directory.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "File or directory path to check." }, - severity: { - type: "string", - enum: ["error", "warning", "information", "hint", "all"], - description: "Severity filter. Defaults to all.", - }, - }, ["filePath"]), - execute: executeLspDiagnostics, - }, - { - name: "goto_definition", - aliases: ["lsp_goto_definition"], - title: "LSP Goto Definition", - description: "Find where a symbol is defined.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "Source file containing the symbol." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - }, ["filePath", "line", "character"]), - execute: executeLspGotoDefinition, - }, - { - name: "find_references", - aliases: ["lsp_find_references"], - title: "LSP Find References", - description: "Find references of a symbol across the workspace.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "Source file containing the symbol." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - includeDeclaration: { type: "boolean", description: "Include the declaration. Defaults to true." }, - }, ["filePath", "line", "character"]), - execute: executeLspFindReferences, - }, - { - name: "symbols", - aliases: ["lsp_symbols"], - title: "LSP Symbols", - description: "List document symbols or search workspace symbols.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "File path used as LSP context." }, - scope: { - type: "string", - enum: ["document", "workspace"], - description: "Use document for file outline or workspace for project-wide search.", - }, - query: { type: "string", description: "Workspace symbol query." }, - limit: { type: "number", description: "Maximum number of symbols to return." }, - }, ["filePath", "scope"]), - execute: executeLspSymbols, - }, - { - name: "prepare_rename", - aliases: ["lsp_prepare_rename"], - title: "LSP Prepare Rename", - description: "Check whether a symbol can be renamed at a position.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "Source file path." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - }, ["filePath", "line", "character"]), - execute: executeLspPrepareRename, - }, - { - name: "rename", - aliases: ["lsp_rename"], - title: "LSP Rename", - description: "Rename a symbol across the workspace and apply the returned workspace edit.", - inputSchema: objectSchema({ - filePath: { type: "string", description: "Source file path." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - newName: { type: "string", description: "New symbol name." }, - }, ["filePath", "line", "character", "newName"]), - execute: executeLspRename, - }, -]; -//# sourceMappingURL=tools.js.map \ No newline at end of file diff --git a/dist/tools.js.map b/dist/tools.js.map deleted file mode 100644 index e9939b2..0000000 --- a/dist/tools.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC1G,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EACN,2BAA2B,EAC3B,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,gBAAgB,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC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C1F,WAAW,EAAE,YAAY,CACxB;YACC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE;YAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;YAC7D,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE;YAC7D,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kBAAkB,EAAE;SAC5D,EACD,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,CAC5C;QACD,OAAO,EAAE,gBAAgB;KACzB;CACD,CAAC"} \ No newline at end of file diff --git a/src/lsp/cleanup-errors.ts b/src/lsp/cleanup-errors.ts deleted file mode 100644 index f78f1eb..0000000 --- a/src/lsp/cleanup-errors.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function reportBestEffortCleanupError(operation: string, error: unknown): void { - if (process.env.CODEX_LSP_DEBUG_CLEANUP !== "1") return; - const message = error instanceof Error ? error.message : String(error); - console.error(`[codex-lsp] ignored ${operation} failure during cleanup: ${message}`); -} diff --git a/src/lsp/client-wrapper.ts b/src/lsp/client-wrapper.ts deleted file mode 100644 index 9e9d4bc..0000000 --- a/src/lsp/client-wrapper.ts +++ /dev/null @@ -1,146 +0,0 @@ -import { existsSync, statSync } from "node:fs"; -import { dirname, extname, join, resolve } from "node:path"; - -import type { LspClient } from "./client.js"; -import { - isLspDeadConnectionError, - LspInvalidPathError, - LspRequestTimeoutError, - LspServerInitializingError, - LspServerLookupError, -} from "./errors.js"; -import { getLspManager, type LspManager } from "./manager.js"; -import { findServerForExtension } from "./server-resolution.js"; -import type { ServerLookupResult } from "./types.js"; - -const WORKSPACE_MARKERS = [".git", "package.json", "pyproject.toml", "Cargo.toml", "go.mod", "pom.xml", "build.gradle"]; - -export function isDirectoryPath(filePath: string): boolean { - try { - return statSync(filePath).isDirectory(); - } catch { - return false; - } -} - -export function findWorkspaceRoot(filePath: string): string { - const abs = resolve(filePath); - let dir = abs; - - if (!isDirectoryPath(dir)) { - dir = dirname(dir); - } - - let prevDir = ""; - while (dir !== prevDir) { - for (const marker of WORKSPACE_MARKERS) { - if (existsSync(join(dir, marker))) { - return dir; - } - } - prevDir = dir; - dir = dirname(dir); - } - - return dirname(abs); -} - -export function formatServerLookupError(result: Exclude): string { - if (result.status === "not_installed") { - const { server, installHint } = result; - return [ - `LSP server '${server.id}' is configured but NOT INSTALLED.`, - "", - `Command not found: ${server.command[0]}`, - "", - "To install:", - ` ${installHint}`, - "", - `Supported extensions: ${server.extensions.join(", ")}`, - "", - "After installation, the server will be available automatically.", - ].join("\n"); - } - - return [ - `No LSP server configured for extension: ${result.extension}`, - "", - `Available servers: ${result.availableServers.slice(0, 10).join(", ")}${ - result.availableServers.length > 10 ? "..." : "" - }`, - "", - "Configure a custom server in '.codex/lsp-client.json':", - " {", - ' "lsp": {', - ' "my-server": {', - ' "command": ["my-lsp", "--stdio"],', - ` "extensions": ["${result.extension}"]`, - " }", - " }", - " }", - ].join("\n"); -} - -export interface WithLspClientOptions { - signal?: AbortSignal; - manager?: LspManager; -} - -const READ_ONLY_RETRY_TOOLS = new Set([ - "diagnostics", - "definition", - "references", - "documentSymbols", - "workspaceSymbols", - "prepareRename", -]); - -export async function withLspClient( - filePath: string, - fn: (client: LspClient) => Promise, - toolName: string, - options: WithLspClientOptions = {}, -): Promise { - const absPath = resolve(filePath); - - if (isDirectoryPath(absPath)) { - throw new LspInvalidPathError( - "Directory paths are not supported by this LSP tool. " + - "Use lsp.diagnostics with a directory path for directory diagnostics.", - ); - } - - const ext = extname(absPath); - const result = findServerForExtension(ext); - if (result.status !== "found") { - throw new LspServerLookupError(formatServerLookupError(result)); - } - - const server = result.server; - const root = findWorkspaceRoot(absPath); - const manager = options.manager ?? getLspManager(); - - const acquireAndCall = async (allowRetry: boolean): Promise => { - const client = await manager.getClient(root, server, options.signal); - - try { - return await fn(client); - } catch (err) { - if (allowRetry && READ_ONLY_RETRY_TOOLS.has(toolName) && isLspDeadConnectionError(err)) { - manager.invalidateClient(root, server.id, client); - return acquireAndCall(false); - } - - if (err instanceof LspRequestTimeoutError) { - if (manager.isServerInitializing(root, server.id)) { - throw new LspServerInitializingError(err); - } - } - throw err; - } finally { - manager.releaseClient(root, server.id); - } - }; - - return acquireAndCall(true); -} diff --git a/src/lsp/client.ts b/src/lsp/client.ts deleted file mode 100644 index 45dcf86..0000000 --- a/src/lsp/client.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { readFileSync } from "node:fs"; -import { extname, resolve } from "node:path"; -import { pathToFileURL } from "node:url"; - -import { LspClientConnection } from "./connection.js"; -import { getLanguageId } from "./language-mappings.js"; -import type { - Diagnostic, - DocumentSymbol, - Location, - LocationLink, - PrepareRenameDefaultBehavior, - PrepareRenameResult, - Range, - SymbolInfo, - WorkspaceEdit, -} from "./types.js"; - -const POST_OPEN_DELAY_MS = 1000; -const POST_DIAGNOSTICS_WAIT_MS = 500; - -export class LspClient extends LspClientConnection { - private readonly openedFiles = new Set(); - private readonly documentVersions = new Map(); - private readonly lastSyncedText = new Map(); - private readonly diagnosticPullErrors: Error[] = []; - - getDiagnosticPullErrors(): readonly Error[] { - return this.diagnosticPullErrors; - } - - async openFile(filePath: string): Promise { - const absPath = resolve(filePath); - const uri = pathToFileURL(absPath).href; - const text = readFileSync(absPath, "utf-8"); - - if (!this.openedFiles.has(absPath)) { - const ext = extname(absPath); - const languageId = getLanguageId(ext); - const version = 1; - - await this.sendNotification("textDocument/didOpen", { - textDocument: { - uri, - languageId, - version, - text, - }, - }); - - this.openedFiles.add(absPath); - this.documentVersions.set(uri, version); - this.lastSyncedText.set(uri, text); - await new Promise((r) => setTimeout(r, POST_OPEN_DELAY_MS)); - return; - } - - const prevText = this.lastSyncedText.get(uri); - if (prevText === text) { - return; - } - - const nextVersion = (this.documentVersions.get(uri) ?? 1) + 1; - this.documentVersions.set(uri, nextVersion); - this.lastSyncedText.set(uri, text); - - await this.sendNotification("textDocument/didChange", { - textDocument: { uri, version: nextVersion }, - contentChanges: [{ text }], - }); - - await this.sendNotification("textDocument/didSave", { - textDocument: { uri }, - text, - }); - } - - async definition( - filePath: string, - line: number, - character: number, - ): Promise | null> { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest | null>( - "textDocument/definition", - { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - }, - ); - } - - async references(filePath: string, line: number, character: number, includeDeclaration = true): Promise { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/references", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - context: { includeDeclaration }, - }); - } - - async documentSymbols(filePath: string): Promise> { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest>("textDocument/documentSymbol", { - textDocument: { uri: pathToFileURL(absPath).href }, - }); - } - - async workspaceSymbols(query: string): Promise { - return this.sendRequest("workspace/symbol", { query }); - } - - private isUnsupportedDiagnosticPullError(error: unknown): boolean { - if (!(error instanceof Error)) return false; - const code = "code" in error && typeof error.code === "number" ? error.code : undefined; - if (code === -32601) return true; - return /unsupported|not supported|method not found|unknown request/i.test(error.message); - } - - async diagnostics(filePath: string): Promise<{ items: Diagnostic[] }> { - const absPath = resolve(filePath); - const uri = pathToFileURL(absPath).href; - await this.openFile(absPath); - await new Promise((r) => setTimeout(r, POST_DIAGNOSTICS_WAIT_MS)); - - try { - const result = await this.sendRequest<{ items?: Diagnostic[] }>("textDocument/diagnostic", { - textDocument: { uri }, - }); - if (result.items) { - return { items: result.items }; - } - } catch (error) { - if (!this.isUnsupportedDiagnosticPullError(error)) { - this.diagnosticPullErrors.push(error instanceof Error ? error : new Error(String(error))); - } - } - - return { items: this.getStoredDiagnostics(uri) }; - } - - async prepareRename( - filePath: string, - line: number, - character: number, - ): Promise { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest( - "textDocument/prepareRename", - { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - }, - ); - } - - async rename(filePath: string, line: number, character: number, newName: string): Promise { - const absPath = resolve(filePath); - await this.openFile(absPath); - return this.sendRequest("textDocument/rename", { - textDocument: { uri: pathToFileURL(absPath).href }, - position: { line: line - 1, character }, - newName, - }); - } -} diff --git a/src/lsp/config-loader.ts b/src/lsp/config-loader.ts deleted file mode 100644 index 2b53643..0000000 --- a/src/lsp/config-loader.ts +++ /dev/null @@ -1,128 +0,0 @@ -import { existsSync, readFileSync } from "node:fs"; -import { homedir } from "node:os"; -import { join } from "node:path"; - -import { BUILTIN_SERVERS } from "./server-definitions.js"; -import type { ResolvedServer } from "./types.js"; - -interface LspEntry { - disabled?: boolean; - command?: string[]; - extensions?: string[]; - priority?: number; - env?: Record; - initialization?: Record; -} - -interface ConfigJson { - lsp?: Record; -} - -type ConfigSource = "project" | "user"; - -export interface ServerWithSource extends ResolvedServer { - source: "project" | "user" | "builtin"; -} - -export function getConfigPaths(): { project: string; user: string } { - const cwd = process.cwd(); - return { - project: join(cwd, ".codex", "lsp-client.json"), - user: join(homedir(), ".codex", "lsp-client.json"), - }; -} - -function loadJsonFile(path: string): ConfigJson | null { - if (!existsSync(path)) return null; - try { - return JSON.parse(readFileSync(path, "utf-8")) as ConfigJson; - } catch { - return null; - } -} - -export function loadAllConfigs(): Map { - const paths = getConfigPaths(); - const configs = new Map(); - - const project = loadJsonFile(paths.project); - if (project) configs.set("project", project); - - const user = loadJsonFile(paths.user); - if (user) configs.set("user", user); - - return configs; -} - -export function getMergedServers(): ServerWithSource[] { - const configs = loadAllConfigs(); - const servers: ServerWithSource[] = []; - const disabled = new Set(); - const seen = new Set(); - - const sources: ConfigSource[] = ["project", "user"]; - - for (const source of sources) { - const config = configs.get(source); - if (!config?.lsp) continue; - - for (const [id, entry] of Object.entries(config.lsp)) { - if (entry.disabled) { - disabled.add(id); - continue; - } - - if (seen.has(id)) continue; - if (!entry.command || !entry.extensions) continue; - - servers.push({ - id, - command: entry.command, - extensions: entry.extensions, - priority: entry.priority ?? 0, - env: entry.env, - initialization: entry.initialization, - source, - }); - seen.add(id); - } - } - - for (const [id, config] of Object.entries(BUILTIN_SERVERS)) { - if (disabled.has(id) || seen.has(id)) continue; - - servers.push({ - id, - command: config.command, - extensions: config.extensions, - priority: -100, - source: "builtin", - }); - } - - return servers.sort((a, b) => { - if (a.source !== b.source) { - const order: Record<"project" | "user" | "builtin", number> = { - project: 0, - user: 1, - builtin: 2, - }; - return order[a.source] - order[b.source]; - } - return b.priority - a.priority; - }); -} - -export function getDisabledServerIds(): Set { - const configs = loadAllConfigs(); - const disabled = new Set(); - - for (const config of configs.values()) { - if (!config.lsp) continue; - for (const [id, entry] of Object.entries(config.lsp)) { - if (entry.disabled) disabled.add(id); - } - } - - return disabled; -} diff --git a/src/lsp/connection.ts b/src/lsp/connection.ts deleted file mode 100644 index 8cf905f..0000000 --- a/src/lsp/connection.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { pathToFileURL } from "node:url"; - -import { LspClientTransport } from "./transport.js"; - -const INITIALIZE_SETTLE_MS = 300; - -export class LspClientConnection extends LspClientTransport { - async initialize(): Promise { - const rootUri = pathToFileURL(this.root).href; - await this.sendRequest("initialize", { - processId: process.pid, - rootUri, - rootPath: this.root, - workspaceFolders: [{ uri: rootUri, name: "workspace" }], - capabilities: { - textDocument: { - hover: { contentFormat: ["markdown", "plaintext"] }, - definition: { linkSupport: true }, - references: {}, - documentSymbol: { hierarchicalDocumentSymbolSupport: true }, - publishDiagnostics: {}, - rename: { - prepareSupport: true, - prepareSupportDefaultBehavior: 1, - honorsChangeAnnotations: true, - }, - codeAction: { - codeActionLiteralSupport: { - codeActionKind: { - valueSet: [ - "quickfix", - "refactor", - "refactor.extract", - "refactor.inline", - "refactor.rewrite", - "source", - "source.organizeImports", - "source.fixAll", - ], - }, - }, - isPreferredSupport: true, - disabledSupport: true, - dataSupport: true, - resolveSupport: { - properties: ["edit", "command"], - }, - }, - }, - workspace: { - symbol: {}, - workspaceFolders: true, - configuration: true, - applyEdit: true, - workspaceEdit: { - documentChanges: true, - }, - }, - }, - initializationOptions: this.server.initialization, - }); - await this.sendNotification("initialized"); - await this.sendNotification("workspace/didChangeConfiguration", { - settings: { json: { validate: { enable: true } } }, - }); - // Some servers accept initialized before their diagnostics/indexing handlers are ready. - await new Promise((r) => setTimeout(r, INITIALIZE_SETTLE_MS)); - } -} diff --git a/src/lsp/constants.ts b/src/lsp/constants.ts deleted file mode 100644 index 8dbddbb..0000000 --- a/src/lsp/constants.ts +++ /dev/null @@ -1,11 +0,0 @@ -export const DEFAULT_MAX_REFERENCES = 200; -export const DEFAULT_MAX_SYMBOLS = 200; -export const DEFAULT_MAX_DIAGNOSTICS = 200; -export const DEFAULT_MAX_DIRECTORY_FILES = 50; - -export const REQUEST_TIMEOUT_MS = 15_000; -export const INIT_TIMEOUT_MS = 60_000; -export const IDLE_TIMEOUT_MS = 5 * 60_000; -export const REAPER_INTERVAL_MS = 60_000; -export const STOP_HARD_KILL_TIMEOUT_MS = 5_000; -export const STOP_SIGKILL_GRACE_MS = 1_000; diff --git a/src/lsp/directory-diagnostics.ts b/src/lsp/directory-diagnostics.ts deleted file mode 100644 index 90e6849..0000000 --- a/src/lsp/directory-diagnostics.ts +++ /dev/null @@ -1,152 +0,0 @@ -import { existsSync, lstatSync, readdirSync, type Stats } from "node:fs"; -import { extname, join, resolve } from "node:path"; -import { findWorkspaceRoot, formatServerLookupError } from "./client-wrapper.js"; -import { DEFAULT_MAX_DIAGNOSTICS, DEFAULT_MAX_DIRECTORY_FILES } from "./constants.js"; -import { LspInvalidPathError, LspServerLookupError } from "./errors.js"; -import { filterDiagnosticsBySeverity, formatDiagnostic } from "./formatters.js"; -import { getLspManager } from "./manager.js"; -import { findServerForExtension } from "./server-resolution.js"; -import type { Diagnostic, SeverityFilter } from "./types.js"; - -const SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]); - -interface FileDiagnostic { - filePath: string; - diagnostic: Diagnostic; -} - -export function collectFilesWithExtension(dir: string, extension: string, maxFiles: number): string[] { - const files: string[] = []; - - function walk(currentDir: string): void { - if (files.length >= maxFiles) return; - - let entries: string[] = []; - try { - entries = readdirSync(currentDir); - } catch { - return; - } - - for (const entry of entries) { - if (files.length >= maxFiles) return; - - const fullPath = join(currentDir, entry); - - let stat: Stats | undefined; - try { - stat = lstatSync(fullPath); - } catch { - continue; - } - - if (!stat || stat.isSymbolicLink()) continue; - - if (stat.isDirectory()) { - if (!SKIP_DIRECTORIES.has(entry)) { - walk(fullPath); - } - } else if (stat.isFile() && extname(fullPath) === extension) { - files.push(fullPath); - } - } - } - - walk(dir); - return files; -} - -export async function aggregateDiagnosticsForDirectory( - directory: string, - extension: string, - severity?: SeverityFilter, - maxFiles: number = DEFAULT_MAX_DIRECTORY_FILES, -): Promise { - if (!extension.startsWith(".")) { - throw new LspInvalidPathError( - `Extension must start with a dot (e.g., ".ts", not "${extension}"). Use ".${extension}" instead.`, - ); - } - - const absDir = resolve(directory); - if (!existsSync(absDir)) { - throw new LspInvalidPathError(`Directory does not exist: ${absDir}`); - } - - const serverResult = findServerForExtension(extension); - if (serverResult.status !== "found") { - throw new LspServerLookupError(formatServerLookupError(serverResult)); - } - - const server = serverResult.server; - const allFiles = collectFilesWithExtension(absDir, extension, maxFiles + 1); - const wasCapped = allFiles.length > maxFiles; - const filesToProcess = allFiles.slice(0, maxFiles); - - if (filesToProcess.length === 0) { - return [ - `Directory: ${absDir}`, - `Extension: ${extension}`, - "Files scanned: 0", - `No files found with extension "${extension}".`, - ].join("\n"); - } - - const root = findWorkspaceRoot(absDir); - const manager = getLspManager(); - const allDiagnostics: FileDiagnostic[] = []; - const fileErrors: { file: string; error: string }[] = []; - - const client = await manager.getClient(root, server); - try { - for (const file of filesToProcess) { - try { - const result = await client.diagnostics(file); - const filtered = filterDiagnosticsBySeverity(result.items, severity); - allDiagnostics.push( - ...filtered.map((diagnostic) => ({ - filePath: file, - diagnostic, - })), - ); - } catch (e) { - fileErrors.push({ - file, - error: e instanceof Error ? e.message : String(e), - }); - } - } - } finally { - manager.releaseClient(root, server.id); - } - - const displayDiagnostics = allDiagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS); - const wasDiagCapped = allDiagnostics.length > DEFAULT_MAX_DIAGNOSTICS; - - const lines: string[] = [ - `Directory: ${absDir}`, - `Extension: ${extension}`, - `Files scanned: ${filesToProcess.length}${wasCapped ? ` (capped at ${maxFiles})` : ""}`, - `Files with errors: ${fileErrors.length}`, - `Total diagnostics: ${allDiagnostics.length}`, - ]; - - if (fileErrors.length > 0) { - lines.push("", "File processing errors:"); - for (const { file, error } of fileErrors) { - lines.push(` ${file}: ${error}`); - } - } - - if (displayDiagnostics.length > 0) { - lines.push(""); - for (const { filePath, diagnostic } of displayDiagnostics) { - lines.push(`${filePath}: ${formatDiagnostic(diagnostic)}`); - } - if (wasDiagCapped) { - lines.push("", `... (${allDiagnostics.length - DEFAULT_MAX_DIAGNOSTICS} more diagnostics not shown)`); - } - } - - return lines.join("\n"); -} diff --git a/src/lsp/errors.ts b/src/lsp/errors.ts deleted file mode 100644 index 186c3c7..0000000 --- a/src/lsp/errors.ts +++ /dev/null @@ -1,63 +0,0 @@ -export class LspConnectionClosedError extends Error { - override readonly name = "LspConnectionClosedError"; - - constructor( - readonly serverId: string, - readonly root: string, - message?: string, - ) { - super(message ?? `LSP connection closed for ${serverId} at ${root}`); - } -} - -export class LspProcessExitedError extends Error { - override readonly name = "LspProcessExitedError"; - - constructor( - readonly serverId: string, - readonly root: string, - readonly exitCode: number | null, - readonly stderrTail?: string, - ) { - const stderrSuffix = stderrTail ? `\nstderr tail: ${stderrTail}` : ""; - super(`LSP server ${serverId} at ${root} exited with code ${exitCode ?? "null"}${stderrSuffix}`); - } -} - -export class LspRequestTimeoutError extends Error { - override readonly name = "LspRequestTimeoutError"; - - constructor( - readonly method: string, - readonly stderrTail?: string, - ) { - const stderrSuffix = stderrTail ? `\nrecent stderr: ${stderrTail}` : ""; - super(`LSP request timeout (method: ${method})${stderrSuffix}`); - } -} - -export class LspInvalidPathError extends Error { - override readonly name = "LspInvalidPathError"; -} - -export class LspServerLookupError extends Error { - override readonly name = "LspServerLookupError"; -} - -export class LspServerInitializingError extends Error { - override readonly name = "LspServerInitializingError"; - - constructor(readonly originalError: LspRequestTimeoutError) { - super( - `LSP server is still initializing. Please retry in a few seconds. Original error: ${originalError.message}`, - ); - } -} - -export class LspProcessSpawnError extends Error { - override readonly name = "LspProcessSpawnError"; -} - -export function isLspDeadConnectionError(err: unknown): err is LspConnectionClosedError | LspProcessExitedError { - return err instanceof LspConnectionClosedError || err instanceof LspProcessExitedError; -} diff --git a/src/lsp/formatters.ts b/src/lsp/formatters.ts deleted file mode 100644 index 1e5a2e0..0000000 --- a/src/lsp/formatters.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { fileURLToPath } from "node:url"; - -import { SEVERITY_MAP, SYMBOL_KIND_MAP } from "./language-mappings.js"; -import type { - Diagnostic, - DocumentSymbol, - Location, - LocationLink, - PrepareRenameDefaultBehavior, - PrepareRenameResult, - Range, - SeverityFilter, - SymbolInfo, -} from "./types.js"; -import type { ApplyResult } from "./workspace-edit.js"; - -export function uriToPath(uri: string): string { - return fileURLToPath(uri); -} - -export function formatLocation(loc: Location | LocationLink): string { - if ("targetUri" in loc) { - const uri = uriToPath(loc.targetUri); - const line = loc.targetRange.start.line + 1; - const char = loc.targetRange.start.character; - return `${uri}:${line}:${char}`; - } - - const uri = uriToPath(loc.uri); - const line = loc.range.start.line + 1; - const char = loc.range.start.character; - return `${uri}:${line}:${char}`; -} - -export function formatSymbolKind(kind: number): string { - return SYMBOL_KIND_MAP[kind] ?? `Unknown(${kind})`; -} - -export function formatSeverity(severity: number | undefined): string { - if (!severity) return "unknown"; - return SEVERITY_MAP[severity] ?? `unknown(${severity})`; -} - -export function formatDocumentSymbol(symbol: DocumentSymbol, indent = 0): string { - const prefix = " ".repeat(indent); - const kind = formatSymbolKind(symbol.kind); - const line = symbol.range.start.line + 1; - let result = `${prefix}${symbol.name} (${kind}) - line ${line}`; - - if (symbol.children && symbol.children.length > 0) { - for (const child of symbol.children) { - result += `\n${formatDocumentSymbol(child, indent + 1)}`; - } - } - - return result; -} - -export function formatSymbolInfo(symbol: SymbolInfo): string { - const kind = formatSymbolKind(symbol.kind); - const loc = formatLocation(symbol.location); - const container = symbol.containerName ? ` (in ${symbol.containerName})` : ""; - return `${symbol.name} (${kind})${container} - ${loc}`; -} - -export function formatDiagnostic(diag: Diagnostic): string { - const severity = formatSeverity(diag.severity); - const line = diag.range.start.line + 1; - const char = diag.range.start.character; - const source = diag.source ? `[${diag.source}]` : ""; - const code = diag.code ? ` (${diag.code})` : ""; - return `${severity}${source}${code} at ${line}:${char}: ${diag.message}`; -} - -export function filterDiagnosticsBySeverity(diagnostics: Diagnostic[], severityFilter?: SeverityFilter): Diagnostic[] { - if (!severityFilter || severityFilter === "all") { - return diagnostics; - } - - const severityMap: Record = { - error: 1, - warning: 2, - information: 3, - hint: 4, - }; - - const targetSeverity = severityMap[severityFilter]; - if (targetSeverity === undefined) return diagnostics; - return diagnostics.filter((d) => d.severity === targetSeverity); -} - -export function formatPrepareRenameResult( - result: PrepareRenameResult | PrepareRenameDefaultBehavior | Range | null, -): string { - if (!result) return "Cannot rename at this position"; - - if ("defaultBehavior" in result) { - return result.defaultBehavior ? "Rename supported (using default behavior)" : "Cannot rename at this position"; - } - - if ("range" in result && result.range) { - const startLine = result.range.start.line + 1; - const startChar = result.range.start.character; - const endLine = result.range.end.line + 1; - const endChar = result.range.end.character; - const placeholder = result.placeholder ? ` (current: "${result.placeholder}")` : ""; - return `Rename available at ${startLine}:${startChar}-${endLine}:${endChar}${placeholder}`; - } - - if ("start" in result && "end" in result) { - const startLine = result.start.line + 1; - const startChar = result.start.character; - const endLine = result.end.line + 1; - const endChar = result.end.character; - return `Rename available at ${startLine}:${startChar}-${endLine}:${endChar}`; - } - - return "Cannot rename at this position"; -} - -export function formatApplyResult(result: ApplyResult): string { - const lines: string[] = []; - - if (result.success) { - lines.push(`Applied ${result.totalEdits} edit(s) to ${result.filesModified.length} file(s):`); - for (const file of result.filesModified) { - lines.push(` - ${file}`); - } - } else { - lines.push("Failed to apply some changes:"); - for (const err of result.errors) { - lines.push(` Error: ${err}`); - } - if (result.filesModified.length > 0) { - lines.push(`Successfully modified: ${result.filesModified.join(", ")}`); - } - } - - return lines.join("\n"); -} diff --git a/src/lsp/infer-extension.ts b/src/lsp/infer-extension.ts deleted file mode 100644 index 31771cb..0000000 --- a/src/lsp/infer-extension.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { lstatSync, readdirSync } from "node:fs"; -import { extname, join } from "node:path"; - -import { EXT_TO_LANG } from "./language-mappings.js"; - -const SKIP_DIRECTORIES = new Set(["node_modules", ".git", "dist", "build", ".next", "out"]); -const MAX_SCAN_ENTRIES = 500; - -export function inferExtensionFromDirectory(directory: string): string | null { - const extensionCounts = new Map(); - let scanned = 0; - - function walk(dir: string): void { - if (scanned >= MAX_SCAN_ENTRIES) return; - - let entries: string[]; - try { - entries = readdirSync(dir); - } catch { - return; - } - - for (const entry of entries) { - if (scanned >= MAX_SCAN_ENTRIES) return; - - const fullPath = join(dir, entry); - - let stat: ReturnType | undefined; - try { - stat = lstatSync(fullPath); - } catch { - continue; - } - - if (stat.isSymbolicLink()) continue; - scanned++; - - if (stat.isDirectory()) { - if (!SKIP_DIRECTORIES.has(entry)) { - walk(fullPath); - } - } else if (stat.isFile()) { - const ext = extname(fullPath); - if (ext && ext in EXT_TO_LANG) { - extensionCounts.set(ext, (extensionCounts.get(ext) ?? 0) + 1); - } - } - } - } - - walk(directory); - - if (extensionCounts.size === 0) return null; - - let maxExt = ""; - let maxCount = 0; - for (const [ext, count] of extensionCounts) { - if (count > maxCount) { - maxCount = count; - maxExt = ext; - } - } - - return maxExt || null; -} diff --git a/src/lsp/json-rpc-connection.ts b/src/lsp/json-rpc-connection.ts deleted file mode 100644 index c5ed24d..0000000 --- a/src/lsp/json-rpc-connection.ts +++ /dev/null @@ -1,296 +0,0 @@ -type JsonRpcId = number | string | null; - -interface PendingRequest { - resolve(result: unknown): void; - reject(error: Error): void; -} - -type NotificationHandler = (params: unknown) => void; -type RequestHandler = (params: unknown) => Promise | unknown; - -const HEADER_SEPARATOR = "\r\n\r\n"; -const PARSE_ERROR = -32700; -const INVALID_REQUEST = -32600; -const METHOD_NOT_FOUND = -32601; -const INTERNAL_ERROR = -32603; - -export class JsonRpcConnection { - private readonly pendingRequests = new Map(); - private readonly notificationHandlers = new Map(); - private readonly requestHandlers = new Map(); - private readonly closeHandlers: Array<() => void> = []; - private readonly errorHandlers: Array<(error: Error) => void> = []; - private inputBuffer = Buffer.alloc(0); - private nextRequestId = 1; - private listening = false; - private disposed = false; - - constructor( - private readonly reader: NodeJS.ReadableStream, - private readonly writer: NodeJS.WritableStream, - ) {} - - listen(): void { - if (this.listening) return; - this.listening = true; - this.reader.on("data", this.handleData); - this.reader.on("close", this.handleClose); - this.reader.on("end", this.handleClose); - this.reader.on("error", this.handleStreamError); - this.writer.on("error", this.handleStreamError); - } - - onNotification(method: string, handler: NotificationHandler): void { - this.notificationHandlers.set(method, handler); - } - - onRequest(method: string, handler: RequestHandler): void { - this.requestHandlers.set(method, handler); - } - - onClose(handler: () => void): void { - this.closeHandlers.push(handler); - } - - onError(handler: (error: Error) => void): void { - this.errorHandlers.push(handler); - } - - async sendRequest(method: string, params?: unknown): Promise { - if (this.disposed) throw new Error("JSON-RPC connection is disposed"); - - const id = this.nextRequestId; - this.nextRequestId += 1; - const message = params === undefined ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params }; - - const responsePromise = new Promise((resolve, reject) => { - this.pendingRequests.set(String(id), { - resolve(result) { - resolve(result as T); - }, - reject, - }); - }); - - try { - await this.writeMessage(message); - } catch (error) { - this.pendingRequests.delete(String(id)); - throw error; - } - - return responsePromise; - } - - async sendNotification(method: string, params?: unknown): Promise { - if (this.disposed) return; - const message = params === undefined ? { jsonrpc: "2.0", method } : { jsonrpc: "2.0", method, params }; - await this.writeMessage(message); - } - - dispose(): void { - if (this.disposed) return; - this.disposed = true; - this.reader.off("data", this.handleData); - this.reader.off("close", this.handleClose); - this.reader.off("end", this.handleClose); - this.reader.off("error", this.handleStreamError); - this.writer.off("error", this.handleStreamError); - for (const pending of this.pendingRequests.values()) { - pending.reject(new Error("JSON-RPC connection disposed")); - } - this.pendingRequests.clear(); - this.notificationHandlers.clear(); - this.requestHandlers.clear(); - } - - private readonly handleData = (chunk: Buffer | string): void => { - const chunkBuffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, "utf8"); - this.inputBuffer = Buffer.concat([this.inputBuffer, chunkBuffer]); - this.drainInputBuffer(); - }; - - private readonly handleClose = (): void => { - for (const handler of this.closeHandlers) { - handler(); - } - }; - - private readonly handleStreamError = (error: Error): void => { - this.emitError(error); - }; - - private drainInputBuffer(): void { - while (true) { - const headerEnd = this.inputBuffer.indexOf(HEADER_SEPARATOR); - if (headerEnd === -1) return; - - const headers = this.inputBuffer.subarray(0, headerEnd).toString("ascii"); - const contentLength = parseContentLength(headers); - if (contentLength === null) { - this.inputBuffer = Buffer.alloc(0); - this.emitError(new Error("JSON-RPC message is missing Content-Length header")); - return; - } - - const bodyStart = headerEnd + Buffer.byteLength(HEADER_SEPARATOR); - const bodyEnd = bodyStart + contentLength; - if (this.inputBuffer.length < bodyEnd) return; - - const body = this.inputBuffer.subarray(bodyStart, bodyEnd).toString("utf8"); - this.inputBuffer = this.inputBuffer.subarray(bodyEnd); - this.dispatchBody(body); - } - } - - private dispatchBody(body: string): void { - let parsed: unknown; - try { - parsed = JSON.parse(body); - } catch (error) { - void this.writeError(null, PARSE_ERROR, error instanceof Error ? error.message : "Parse error").catch( - (writeError) => this.emitError(toError(writeError)), - ); - return; - } - - if (!isJsonRpcObject(parsed)) { - void this.writeError(null, INVALID_REQUEST, "Invalid JSON-RPC message").catch((error) => - this.emitError(toError(error)), - ); - return; - } - - if ("id" in parsed && ("result" in parsed || "error" in parsed)) { - this.handleResponse(parsed); - return; - } - - if (typeof parsed.method !== "string") { - const id = getMessageId(parsed) ?? null; - void this.writeError(id, INVALID_REQUEST, "Invalid JSON-RPC method").catch((error) => - this.emitError(toError(error)), - ); - return; - } - - if ("id" in parsed) { - this.handleRequest(parsed); - return; - } - - this.handleNotification(parsed.method, parsed.params); - } - - private handleResponse(message: Record): void { - const id = getMessageId(message); - if (id === undefined) return; - const pending = this.pendingRequests.get(String(id)); - if (!pending) return; - this.pendingRequests.delete(String(id)); - - if ("error" in message) { - pending.reject(jsonRpcErrorToError(message.error)); - return; - } - - pending.resolve(message.result); - } - - private handleNotification(method: string, params: unknown): void { - const handler = this.notificationHandlers.get(method); - if (!handler) return; - try { - handler(params); - } catch (error) { - this.emitError(toError(error)); - } - } - - private handleRequest(message: Record): void { - const id = getMessageId(message); - if (id === undefined) { - void this.writeError(null, INVALID_REQUEST, "Invalid JSON-RPC id").catch((error) => - this.emitError(toError(error)), - ); - return; - } - - const method = typeof message.method === "string" ? message.method : ""; - const handler = this.requestHandlers.get(method); - if (!handler) { - void this.writeError(id, METHOD_NOT_FOUND, `Method not found: ${method}`).catch((error) => - this.emitError(toError(error)), - ); - return; - } - - Promise.resolve() - .then(() => handler(message.params)) - .then( - (result) => this.writeMessage({ jsonrpc: "2.0", id, result }), - (error) => this.writeError(id, INTERNAL_ERROR, toError(error).message), - ) - .catch((error) => this.emitError(toError(error))); - } - - private async writeError(id: JsonRpcId, code: number, message: string): Promise { - await this.writeMessage({ jsonrpc: "2.0", id, error: { code, message } }); - } - - private writeMessage(message: Record): Promise { - const body = JSON.stringify(message); - const payload = `Content-Length: ${Buffer.byteLength(body, "utf8")}\r\n\r\n${body}`; - return new Promise((resolve, reject) => { - this.writer.write(payload, (error?: Error | null) => { - if (error) { - reject(error); - return; - } - resolve(); - }); - }); - } - - private emitError(error: Error): void { - for (const handler of this.errorHandlers) { - handler(error); - } - } -} - -function parseContentLength(headers: string): number | null { - for (const line of headers.split("\r\n")) { - const separatorIndex = line.indexOf(":"); - if (separatorIndex === -1) continue; - const name = line.slice(0, separatorIndex).trim().toLowerCase(); - if (name !== "content-length") continue; - const value = Number.parseInt(line.slice(separatorIndex + 1).trim(), 10); - return Number.isFinite(value) && value >= 0 ? value : null; - } - return null; -} - -function isJsonRpcObject(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} - -function getMessageId(message: Record): JsonRpcId | undefined { - const id = message.id; - if (typeof id === "number" || typeof id === "string" || id === null) return id; - return undefined; -} - -function jsonRpcErrorToError(value: unknown): Error { - if (!isJsonRpcObject(value)) return new Error("JSON-RPC request failed"); - const message = typeof value.message === "string" ? value.message : "JSON-RPC request failed"; - const error = new Error(message); - if (typeof value.code === "number") { - error.name = `JsonRpcError(${value.code})`; - } - return error; -} - -function toError(error: unknown): Error { - return error instanceof Error ? error : new Error(String(error)); -} diff --git a/src/lsp/language-mappings.ts b/src/lsp/language-mappings.ts deleted file mode 100644 index ace3c23..0000000 --- a/src/lsp/language-mappings.ts +++ /dev/null @@ -1,172 +0,0 @@ -export const SYMBOL_KIND_MAP: Record = { - 1: "File", - 2: "Module", - 3: "Namespace", - 4: "Package", - 5: "Class", - 6: "Method", - 7: "Property", - 8: "Field", - 9: "Constructor", - 10: "Enum", - 11: "Interface", - 12: "Function", - 13: "Variable", - 14: "Constant", - 15: "String", - 16: "Number", - 17: "Boolean", - 18: "Array", - 19: "Object", - 20: "Key", - 21: "Null", - 22: "EnumMember", - 23: "Struct", - 24: "Event", - 25: "Operator", - 26: "TypeParameter", -}; - -export const SEVERITY_MAP: Record = { - 1: "error", - 2: "warning", - 3: "information", - 4: "hint", -}; - -export const EXT_TO_LANG: Record = { - ".abap": "abap", - ".bat": "bat", - ".bib": "bibtex", - ".bibtex": "bibtex", - ".clj": "clojure", - ".cljs": "clojure", - ".cljc": "clojure", - ".edn": "clojure", - ".coffee": "coffeescript", - ".c": "c", - ".cpp": "cpp", - ".cxx": "cpp", - ".cc": "cpp", - ".c++": "cpp", - ".cs": "csharp", - ".css": "css", - ".d": "d", - ".pas": "pascal", - ".pascal": "pascal", - ".diff": "diff", - ".patch": "diff", - ".dart": "dart", - ".dockerfile": "dockerfile", - ".ex": "elixir", - ".exs": "elixir", - ".erl": "erlang", - ".hrl": "erlang", - ".fs": "fsharp", - ".fsi": "fsharp", - ".fsx": "fsharp", - ".fsscript": "fsharp", - ".gitcommit": "git-commit", - ".gitrebase": "git-rebase", - ".go": "go", - ".groovy": "groovy", - ".gleam": "gleam", - ".hbs": "handlebars", - ".handlebars": "handlebars", - ".hs": "haskell", - ".html": "html", - ".htm": "html", - ".ini": "ini", - ".java": "java", - ".js": "javascript", - ".jsx": "javascriptreact", - ".json": "json", - ".jsonc": "jsonc", - ".tex": "latex", - ".latex": "latex", - ".less": "less", - ".lua": "lua", - ".makefile": "makefile", - makefile: "makefile", - ".md": "markdown", - ".markdown": "markdown", - ".m": "objective-c", - ".mm": "objective-cpp", - ".pl": "perl", - ".pm": "perl", - ".pm6": "perl6", - ".php": "php", - ".ps1": "powershell", - ".psm1": "powershell", - ".pug": "jade", - ".jade": "jade", - ".py": "python", - ".pyi": "python", - ".r": "r", - ".cshtml": "razor", - ".razor": "razor", - ".rb": "ruby", - ".rake": "ruby", - ".gemspec": "ruby", - ".ru": "ruby", - ".erb": "erb", - ".html.erb": "erb", - ".js.erb": "erb", - ".css.erb": "erb", - ".json.erb": "erb", - ".rs": "rust", - ".scss": "scss", - ".sass": "sass", - ".scala": "scala", - ".shader": "shaderlab", - ".sh": "shellscript", - ".bash": "shellscript", - ".zsh": "shellscript", - ".ksh": "shellscript", - ".sql": "sql", - ".svelte": "svelte", - ".swift": "swift", - ".ts": "typescript", - ".tsx": "typescriptreact", - ".mts": "typescript", - ".cts": "typescript", - ".mtsx": "typescriptreact", - ".ctsx": "typescriptreact", - ".xml": "xml", - ".xsl": "xsl", - ".yaml": "yaml", - ".yml": "yaml", - ".mjs": "javascript", - ".cjs": "javascript", - ".vue": "vue", - ".zig": "zig", - ".zon": "zig", - ".astro": "astro", - ".ml": "ocaml", - ".mli": "ocaml", - ".tf": "terraform", - ".tfvars": "terraform-vars", - ".hcl": "hcl", - ".nix": "nix", - ".typ": "typst", - ".typc": "typst", - ".ets": "typescript", - ".lhs": "haskell", - ".kt": "kotlin", - ".kts": "kotlin", - ".prisma": "prisma", - ".h": "c", - ".hpp": "cpp", - ".hh": "cpp", - ".hxx": "cpp", - ".h++": "cpp", - ".objc": "objective-c", - ".objcpp": "objective-cpp", - ".fish": "fish", - ".graphql": "graphql", - ".gql": "graphql", -}; - -export function getLanguageId(ext: string): string { - return EXT_TO_LANG[ext] ?? "plaintext"; -} diff --git a/src/lsp/manager.ts b/src/lsp/manager.ts deleted file mode 100644 index 376c2ed..0000000 --- a/src/lsp/manager.ts +++ /dev/null @@ -1,385 +0,0 @@ -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { LspClient } from "./client.js"; -import { IDLE_TIMEOUT_MS, INIT_TIMEOUT_MS, REAPER_INTERVAL_MS } from "./constants.js"; -import type { ResolvedServer } from "./types.js"; - -interface ManagedClient { - client: LspClient; - refCount: number; - pendingWaiters: number; - lastUsedAt: number; - initPromise: Promise | null; - isInitializing: boolean; - initializingSince: number | null; -} - -export interface ClientSnapshot { - root: string; - serverId: string; - refCount: number; - pendingWaiters: number; - lastUsedAt: number; - isInitializing: boolean; - alive: boolean; - command: string[]; -} - -export interface LspManagerOptions { - idleTimeoutMs?: number; - initTimeoutMs?: number; - reaperIntervalMs?: number; - clientFactory?: (root: string, server: ResolvedServer) => LspClient; - now?: () => number; -} - -async function stopClientBestEffort(client: LspClient): Promise { - try { - await client.stop(); - } catch (error) { - reportBestEffortCleanupError("client stop", error); - } -} - -function awaitWithSignal(promise: Promise, signal: AbortSignal | undefined): Promise { - if (!signal) return promise; - return new Promise((resolve, reject) => { - let settled = false; - const onAbort = () => { - if (settled) return; - settled = true; - reject(new DOMException("Aborted", "AbortError")); - }; - if (signal.aborted) { - onAbort(); - return; - } - signal.addEventListener("abort", onAbort, { once: true }); - promise.then( - (value) => { - if (settled) return; - settled = true; - signal.removeEventListener("abort", onAbort); - resolve(value); - }, - (err) => { - if (settled) return; - settled = true; - signal.removeEventListener("abort", onAbort); - reject(err); - }, - ); - }); -} - -export class LspManager { - private readonly clients = new Map(); - private reaperHandle: NodeJS.Timeout | null = null; - private exitDisposer: (() => void) | null = null; - private disposed = false; - - private readonly idleTimeoutMs: number; - private readonly initTimeoutMs: number; - private readonly reaperIntervalMs: number; - private readonly clientFactory: (root: string, server: ResolvedServer) => LspClient; - private readonly now: () => number; - - constructor(options: LspManagerOptions = {}) { - this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS; - this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS; - this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS; - this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server)); - this.now = options.now ?? (() => Date.now()); - - this.startReaper(); - this.installProcessExitHandler(); - } - - private startReaper(): void { - if (this.reaperHandle) return; - this.reaperHandle = setInterval(() => { - this.reapStale(); - }, this.reaperIntervalMs); - if (typeof this.reaperHandle.unref === "function") { - this.reaperHandle.unref(); - } - } - - private installProcessExitHandler(): void { - const handler = () => { - for (const managed of this.clients.values()) { - try { - void stopClientBestEffort(managed.client); - } catch (error) { - reportBestEffortCleanupError("exit handler client stop", error); - } - } - this.clients.clear(); - }; - process.on("exit", handler); - this.exitDisposer = () => { - process.removeListener("exit", handler); - }; - } - - private getKey(root: string, serverId: string): string { - return `${root}::${serverId}`; - } - - private reapStale(): void { - const t = this.now(); - for (const [key, managed] of this.clients) { - if ( - managed.isInitializing && - managed.initializingSince !== null && - t - managed.initializingSince > this.initTimeoutMs - ) { - void stopClientBestEffort(managed.client); - this.clients.delete(key); - continue; - } - - if ( - !managed.isInitializing && - managed.refCount === 0 && - managed.pendingWaiters === 0 && - t - managed.lastUsedAt > this.idleTimeoutMs - ) { - void stopClientBestEffort(managed.client); - this.clients.delete(key); - } - } - } - - private async tryDeleteIfOrphaned(key: string, managed: ManagedClient): Promise { - if ( - managed.refCount === 0 && - managed.pendingWaiters === 0 && - !managed.isInitializing && - this.clients.get(key) === managed - ) { - this.clients.delete(key); - await stopClientBestEffort(managed.client); - } - } - - async getClient(root: string, server: ResolvedServer, signal?: AbortSignal): Promise { - if (this.disposed) { - throw new Error("LspManager has been disposed"); - } - signal?.throwIfAborted(); - - const key = this.getKey(root, server.id); - let managed = this.clients.get(key); - - if (managed) { - const t = this.now(); - if ( - managed.isInitializing && - managed.initializingSince !== null && - t - managed.initializingSince > this.initTimeoutMs - ) { - await stopClientBestEffort(managed.client); - this.clients.delete(key); - managed = undefined; - } - } - - if (managed) { - if (managed.initPromise) { - managed.pendingWaiters++; - try { - await awaitWithSignal(managed.initPromise, signal); - } catch (err) { - managed.pendingWaiters--; - await this.tryDeleteIfOrphaned(key, managed); - throw err; - } - managed.pendingWaiters--; - } - - if (signal?.aborted) { - await this.tryDeleteIfOrphaned(key, managed); - signal.throwIfAborted(); - } - - if (!managed.client.isAlive()) { - await stopClientBestEffort(managed.client); - this.clients.delete(key); - return this.getClient(root, server, signal); - } - - managed.refCount++; - managed.lastUsedAt = this.now(); - return managed.client; - } - - const client = this.clientFactory(root, server); - const initStartedAt = this.now(); - const initPromise = (async () => { - await client.start(); - await client.initialize(); - })(); - - const newManaged: ManagedClient = { - client, - refCount: 0, - pendingWaiters: 1, - lastUsedAt: initStartedAt, - initPromise, - isInitializing: true, - initializingSince: initStartedAt, - }; - this.clients.set(key, newManaged); - - try { - await awaitWithSignal(initPromise, signal); - } catch (err) { - newManaged.pendingWaiters--; - if (this.clients.get(key) === newManaged) { - this.clients.delete(key); - } - await stopClientBestEffort(client); - throw err; - } - - newManaged.pendingWaiters--; - newManaged.isInitializing = false; - newManaged.initializingSince = null; - newManaged.initPromise = null; - - if (signal?.aborted) { - await this.tryDeleteIfOrphaned(key, newManaged); - signal.throwIfAborted(); - } - - newManaged.refCount++; - newManaged.lastUsedAt = this.now(); - return client; - } - - releaseClient(root: string, serverId: string): void { - const key = this.getKey(root, serverId); - const managed = this.clients.get(key); - if (managed && managed.refCount > 0) { - managed.refCount--; - managed.lastUsedAt = this.now(); - } - } - - invalidateClient(root: string, serverId: string, client?: LspClient): void { - const key = this.getKey(root, serverId); - const managed = this.clients.get(key); - if (!managed) return; - if (client && managed.client !== client) return; - this.clients.delete(key); - void stopClientBestEffort(managed.client); - } - - warmupClient(root: string, server: ResolvedServer): void { - if (this.disposed) return; - const key = this.getKey(root, server.id); - if (this.clients.has(key)) return; - - const client = this.clientFactory(root, server); - const initStartedAt = this.now(); - const initPromise = (async () => { - await client.start(); - await client.initialize(); - })(); - - const managed: ManagedClient = { - client, - refCount: 0, - pendingWaiters: 0, - lastUsedAt: initStartedAt, - initPromise, - isInitializing: true, - initializingSince: initStartedAt, - }; - this.clients.set(key, managed); - - initPromise.then( - () => { - managed.isInitializing = false; - managed.initializingSince = null; - managed.initPromise = null; - managed.lastUsedAt = this.now(); - }, - () => { - if (this.clients.get(key) === managed) { - this.clients.delete(key); - } - void stopClientBestEffort(client); - }, - ); - } - - isServerInitializing(root: string, serverId: string): boolean { - const managed = this.clients.get(this.getKey(root, serverId)); - return managed?.isInitializing ?? false; - } - - getSnapshot(): ClientSnapshot[] { - const snapshots: ClientSnapshot[] = []; - for (const [key, managed] of this.clients) { - const [root, serverId] = key.split("::") as [string, string]; - snapshots.push({ - root, - serverId, - refCount: managed.refCount, - pendingWaiters: managed.pendingWaiters, - lastUsedAt: managed.lastUsedAt, - isInitializing: managed.isInitializing, - alive: managed.client.isAlive(), - command: managed.client.command(), - }); - } - return snapshots; - } - - hasClient(root: string, serverId: string): boolean { - return this.clients.has(this.getKey(root, serverId)); - } - - clientCount(): number { - return this.clients.size; - } - - async stopAll(): Promise { - this.disposed = true; - - if (this.reaperHandle) { - clearInterval(this.reaperHandle); - this.reaperHandle = null; - } - - if (this.exitDisposer) { - this.exitDisposer(); - this.exitDisposer = null; - } - - const stopPromises: Promise[] = []; - for (const managed of this.clients.values()) { - stopPromises.push(stopClientBestEffort(managed.client)); - } - this.clients.clear(); - await Promise.allSettled(stopPromises); - } -} - -let _defaultInstance: LspManager | null = null; - -export function getLspManager(): LspManager { - if (!_defaultInstance) { - _defaultInstance = new LspManager(); - } - return _defaultInstance; -} - -export async function disposeDefaultLspManager(): Promise { - if (_defaultInstance) { - const m = _defaultInstance; - _defaultInstance = null; - await m.stopAll(); - } -} diff --git a/src/lsp/process.ts b/src/lsp/process.ts deleted file mode 100644 index 11efafa..0000000 --- a/src/lsp/process.ts +++ /dev/null @@ -1,166 +0,0 @@ -import { type ChildProcess, spawn } from "node:child_process"; -import { existsSync, statSync } from "node:fs"; -import { delimiter, join } from "node:path"; - -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { LspInvalidPathError, LspProcessSpawnError } from "./errors.js"; - -export interface SpawnedProcess { - stdin: NodeJS.WritableStream; - stdout: NodeJS.ReadableStream; - stderr: NodeJS.ReadableStream; - pid: number | undefined; - exitCode: number | null; - exited: Promise; - kill(signal?: NodeJS.Signals): void; - killed: boolean; -} - -export interface SpawnOptions { - cwd: string; - env: Record; -} - -export interface PreparedSpawnCommand { - command: string; - args: string[]; - shell: false; -} - -export function validateCwd(cwd: string): { valid: boolean; error?: string } { - try { - if (!existsSync(cwd)) { - return { valid: false, error: `Working directory does not exist: ${cwd}` }; - } - const stats = statSync(cwd); - if (!stats.isDirectory()) { - return { valid: false, error: `Path is not a directory: ${cwd}` }; - } - return { valid: true }; - } catch (err) { - return { - valid: false, - error: `Cannot access working directory: ${cwd} (${err instanceof Error ? err.message : String(err)})`, - }; - } -} - -function wrap(proc: ChildProcess): SpawnedProcess { - const exitedPromise = new Promise((resolve) => { - proc.once("close", (code) => resolve(code ?? 0)); - proc.once("error", () => resolve(1)); - }); - - if (!proc.stdin || !proc.stdout || !proc.stderr) { - throw new LspProcessSpawnError("Spawned process is missing one of stdin/stdout/stderr pipes"); - } - - return { - stdin: proc.stdin, - stdout: proc.stdout, - stderr: proc.stderr, - get pid() { - return proc.pid ?? undefined; - }, - get exitCode() { - return proc.exitCode; - }, - get killed() { - return proc.killed; - }, - exited: exitedPromise, - kill(signal?: NodeJS.Signals) { - try { - proc.kill(signal ?? "SIGTERM"); - } catch (error) { - reportBestEffortCleanupError("process kill", error); - } - }, - }; -} - -function isWindowsShellShim(command: string): boolean { - const lowerCommand = command.toLowerCase(); - return lowerCommand.endsWith(".cmd") || lowerCommand.endsWith(".bat"); -} - -function splitPath(pathValue: string, platform: NodeJS.Platform): string[] { - const separator = platform === "win32" ? ";" : delimiter; - return pathValue.split(separator).filter(Boolean); -} - -function getWindowsPathExtensions(env: Record): string[] { - const rawExtensions = env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD"; - const extensions = rawExtensions - .split(";") - .map((extension) => extension.trim()) - .filter(Boolean) - .map((extension) => (extension.startsWith(".") ? extension : `.${extension}`)); - return [...new Set(["", ...extensions, ".exe", ".cmd", ".bat"])]; -} - -function resolveWindowsCommand(command: string, env: Record): string { - const hasPathSeparator = command.includes("/") || command.includes("\\"); - const pathValue = env.PATH ?? env.Path ?? ""; - const baseDirectories = hasPathSeparator ? [""] : splitPath(pathValue, "win32"); - const extensions = getWindowsPathExtensions(env); - - for (const baseDirectory of baseDirectories) { - for (const extension of extensions) { - const candidate = baseDirectory ? join(baseDirectory, `${command}${extension}`) : `${command}${extension}`; - if (existsSync(candidate)) return candidate; - } - } - - return command; -} - -export function createSpawnCommand( - command: string[], - platform: NodeJS.Platform = process.platform, - commandProcessor: string = process.env.ComSpec ?? "cmd.exe", - env: Record = process.env, -): PreparedSpawnCommand { - const [cmd, ...args] = command; - if (!cmd) { - throw new LspProcessSpawnError("[lsp] empty command"); - } - - if (platform !== "win32") { - return { command: cmd, args, shell: false }; - } - - const resolvedCommand = resolveWindowsCommand(cmd, env); - if (!isWindowsShellShim(resolvedCommand)) { - return { command: resolvedCommand, args, shell: false }; - } - - return { - command: commandProcessor, - args: ["/d", "/s", "/c", resolvedCommand, ...args], - shell: false, - }; -} - -export function spawnProcess(command: string[], options: SpawnOptions): SpawnedProcess { - const cwdValidation = validateCwd(options.cwd); - if (!cwdValidation.valid) { - throw new LspInvalidPathError(`[lsp] ${cwdValidation.error}`); - } - - const [cmd] = command; - if (!cmd) { - throw new LspProcessSpawnError("[lsp] empty command"); - } - - const preparedCommand = createSpawnCommand(command, process.platform, process.env.ComSpec ?? "cmd.exe", options.env); - const proc = spawn(preparedCommand.command, preparedCommand.args, { - cwd: options.cwd, - env: options.env as NodeJS.ProcessEnv, - stdio: ["pipe", "pipe", "pipe"], - windowsHide: true, - shell: preparedCommand.shell, - }); - - return wrap(proc); -} diff --git a/src/lsp/server-definitions.ts b/src/lsp/server-definitions.ts deleted file mode 100644 index b62976d..0000000 --- a/src/lsp/server-definitions.ts +++ /dev/null @@ -1,162 +0,0 @@ -import type { LspServerConfig } from "./types.js"; - -export const LSP_INSTALL_HINTS: Record = { - typescript: "npm install -g typescript-language-server typescript", - deno: "Install Deno from https://deno.land", - vue: "npm install -g @vue/language-server", - eslint: "npm install -g vscode-langservers-extracted", - oxlint: "npm install -g oxlint", - biome: "npm install -g @biomejs/biome", - gopls: "go install golang.org/x/tools/gopls@latest", - "ruby-lsp": "gem install ruby-lsp", - basedpyright: "pip install basedpyright", - pyright: "pip install pyright", - ty: "pip install ty", - ruff: "pip install ruff", - "elixir-ls": "See https://github.com/elixir-lsp/elixir-ls", - zls: "See https://github.com/zigtools/zls", - csharp: "dotnet tool install -g csharp-ls", - fsharp: "dotnet tool install -g fsautocomplete", - "sourcekit-lsp": "Included with Xcode or Swift toolchain", - rust: "rustup component add rust-analyzer", - clangd: "See https://clangd.llvm.org/installation", - svelte: "npm install -g svelte-language-server", - astro: "npm install -g @astrojs/language-server", - "bash-ls": "npm install -g bash-language-server", - jdtls: "See https://github.com/eclipse-jdtls/eclipse.jdt.ls", - "yaml-ls": "npm install -g yaml-language-server", - "lua-ls": "See https://github.com/LuaLS/lua-language-server", - php: "npm install -g intelephense", - dart: "Included with Dart SDK", - "terraform-ls": "See https://github.com/hashicorp/terraform-ls", - terraform: "See https://github.com/hashicorp/terraform-ls", - prisma: "npm install -g prisma", - "ocaml-lsp": "opam install ocaml-lsp-server", - texlab: "See https://github.com/latex-lsp/texlab", - dockerfile: "npm install -g dockerfile-language-server-nodejs", - gleam: "See https://gleam.run/getting-started/installing/", - "clojure-lsp": "See https://clojure-lsp.io/installation/", - nixd: "nix profile install nixpkgs#nixd", - tinymist: "See https://github.com/Myriad-Dreamin/tinymist", - "haskell-language-server": "ghcup install hls", - bash: "npm install -g bash-language-server", - "kotlin-ls": "See https://github.com/Kotlin/kotlin-lsp", -}; - -export const BUILTIN_SERVERS: Record> = { - typescript: { - command: ["typescript-language-server", "--stdio"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"], - }, - deno: { command: ["deno", "lsp"], extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs"] }, - vue: { command: ["vue-language-server", "--stdio"], extensions: [".vue"] }, - eslint: { - command: ["vscode-eslint-language-server", "--stdio"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue"], - }, - oxlint: { - command: ["oxlint", "--lsp"], - extensions: [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts", ".vue", ".astro", ".svelte"], - }, - biome: { - command: ["biome", "lsp-proxy", "--stdio"], - extensions: [ - ".ts", - ".tsx", - ".js", - ".jsx", - ".mjs", - ".cjs", - ".mts", - ".cts", - ".json", - ".jsonc", - ".vue", - ".astro", - ".svelte", - ".css", - ".graphql", - ".gql", - ".html", - ], - }, - gopls: { command: ["gopls"], extensions: [".go"] }, - "ruby-lsp": { - command: ["rubocop", "--lsp"], - extensions: [".rb", ".rake", ".gemspec", ".ru"], - }, - basedpyright: { - command: ["basedpyright-langserver", "--stdio"], - extensions: [".py", ".pyi"], - }, - pyright: { command: ["pyright-langserver", "--stdio"], extensions: [".py", ".pyi"] }, - ty: { command: ["ty", "server"], extensions: [".py", ".pyi"] }, - ruff: { command: ["ruff", "server"], extensions: [".py", ".pyi"] }, - "elixir-ls": { command: ["elixir-ls"], extensions: [".ex", ".exs"] }, - zls: { command: ["zls"], extensions: [".zig", ".zon"] }, - csharp: { command: ["csharp-ls"], extensions: [".cs"] }, - fsharp: { command: ["fsautocomplete"], extensions: [".fs", ".fsi", ".fsx", ".fsscript"] }, - "sourcekit-lsp": { command: ["sourcekit-lsp"], extensions: [".swift", ".objc", ".objcpp"] }, - rust: { command: ["rust-analyzer"], extensions: [".rs"] }, - clangd: { - command: ["clangd", "--background-index", "--clang-tidy"], - extensions: [".c", ".cpp", ".cc", ".cxx", ".c++", ".h", ".hpp", ".hh", ".hxx", ".h++"], - }, - svelte: { command: ["svelteserver", "--stdio"], extensions: [".svelte"] }, - astro: { command: ["astro-ls", "--stdio"], extensions: [".astro"] }, - bash: { - command: ["bash-language-server", "start"], - extensions: [".sh", ".bash", ".zsh", ".ksh"], - }, - "bash-ls": { - command: ["bash-language-server", "start"], - extensions: [".sh", ".bash", ".zsh", ".ksh"], - }, - jdtls: { command: ["jdtls"], extensions: [".java"] }, - "yaml-ls": { command: ["yaml-language-server", "--stdio"], extensions: [".yaml", ".yml"] }, - "lua-ls": { command: ["lua-language-server"], extensions: [".lua"] }, - php: { command: ["intelephense", "--stdio"], extensions: [".php"] }, - dart: { command: ["dart", "language-server", "--lsp"], extensions: [".dart"] }, - terraform: { command: ["terraform-ls", "serve"], extensions: [".tf", ".tfvars"] }, - "terraform-ls": { command: ["terraform-ls", "serve"], extensions: [".tf", ".tfvars"] }, - prisma: { command: ["prisma", "language-server"], extensions: [".prisma"] }, - "ocaml-lsp": { command: ["ocamllsp"], extensions: [".ml", ".mli"] }, - texlab: { command: ["texlab"], extensions: [".tex", ".bib"] }, - dockerfile: { command: ["docker-langserver", "--stdio"], extensions: [".dockerfile"] }, - gleam: { command: ["gleam", "lsp"], extensions: [".gleam"] }, - "clojure-lsp": { - command: ["clojure-lsp", "listen"], - extensions: [".clj", ".cljs", ".cljc", ".edn"], - }, - nixd: { command: ["nixd"], extensions: [".nix"] }, - tinymist: { command: ["tinymist"], extensions: [".typ", ".typc"] }, - "haskell-language-server": { - command: ["haskell-language-server-wrapper", "--lsp"], - extensions: [".hs", ".lhs"], - }, - "kotlin-ls": { command: ["kotlin-lsp"], extensions: [".kt", ".kts"] }, -}; - -export const AUTO_INSTALLABLE_SERVERS: Record = { - typescript: ["npm", "install", "-g", "typescript-language-server", "typescript"], - vue: ["npm", "install", "-g", "@vue/language-server"], - eslint: ["npm", "install", "-g", "vscode-langservers-extracted"], - oxlint: ["npm", "install", "-g", "oxlint"], - biome: ["npm", "install", "-g", "@biomejs/biome"], - svelte: ["npm", "install", "-g", "svelte-language-server"], - astro: ["npm", "install", "-g", "@astrojs/language-server"], - "bash-ls": ["npm", "install", "-g", "bash-language-server"], - bash: ["npm", "install", "-g", "bash-language-server"], - "yaml-ls": ["npm", "install", "-g", "yaml-language-server"], - php: ["npm", "install", "-g", "intelephense"], - prisma: ["npm", "install", "-g", "prisma"], - dockerfile: ["npm", "install", "-g", "dockerfile-language-server-nodejs"], - gopls: ["go", "install", "golang.org/x/tools/gopls@latest"], - pyright: ["pip", "install", "pyright"], - basedpyright: ["pip", "install", "basedpyright"], - ruff: ["pip", "install", "ruff"], - ty: ["pip", "install", "ty"], - "ruby-lsp": ["gem", "install", "ruby-lsp"], - rust: ["rustup", "component", "add", "rust-analyzer"], - "ocaml-lsp": ["opam", "install", "ocaml-lsp-server"], -}; diff --git a/src/lsp/server-installation.ts b/src/lsp/server-installation.ts deleted file mode 100644 index 28cd18c..0000000 --- a/src/lsp/server-installation.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { existsSync } from "node:fs"; -import { delimiter, join } from "node:path"; - -export function getAdditionalPathBases(workingDirectory: string): string[] { - return [join(workingDirectory, "node_modules", ".bin")]; -} - -export function isServerInstalled(command: string[]): boolean { - if (command.length === 0) return false; - - const [cmd] = command; - if (!cmd) return false; - - if (cmd.includes("/") || cmd.includes("\\")) { - if (existsSync(cmd)) return true; - } - - const isWindows = process.platform === "win32"; - - let exts = [""]; - if (isWindows) { - const pathExt = process.env.PATHEXT ?? ""; - if (pathExt) { - const systemExts = pathExt.split(";").filter(Boolean); - exts = [...new Set([...exts, ...systemExts, ".exe", ".cmd", ".bat", ".ps1"])]; - } else { - exts = ["", ".exe", ".cmd", ".bat", ".ps1"]; - } - } - - let pathEnv = process.env.PATH ?? ""; - if (isWindows && !pathEnv) { - pathEnv = process.env.Path ?? ""; - } - - const paths = pathEnv.split(delimiter); - - for (const p of paths) { - for (const suffix of exts) { - if (existsSync(join(p, cmd + suffix))) { - return true; - } - } - } - - for (const base of getAdditionalPathBases(process.cwd())) { - for (const suffix of exts) { - if (existsSync(join(base, cmd + suffix))) { - return true; - } - } - } - - if (cmd === "node") return true; - - return false; -} diff --git a/src/lsp/server-resolution.ts b/src/lsp/server-resolution.ts deleted file mode 100644 index ccdaeeb..0000000 --- a/src/lsp/server-resolution.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { getDisabledServerIds, getMergedServers } from "./config-loader.js"; -import { BUILTIN_SERVERS, LSP_INSTALL_HINTS } from "./server-definitions.js"; -import { isServerInstalled } from "./server-installation.js"; -import type { ServerLookupResult } from "./types.js"; - -export function findServerForExtension(ext: string): ServerLookupResult { - const servers = getMergedServers(); - - for (const server of servers) { - if (server.extensions.includes(ext) && isServerInstalled(server.command)) { - return { - status: "found", - server: { - id: server.id, - command: server.command, - extensions: server.extensions, - priority: server.priority, - env: server.env, - initialization: server.initialization, - }, - }; - } - } - - for (const server of servers) { - if (server.extensions.includes(ext)) { - const installHint = - LSP_INSTALL_HINTS[server.id] ?? `Install '${server.command[0]}' and ensure it's in your PATH`; - return { - status: "not_installed", - server: { - id: server.id, - command: server.command, - extensions: server.extensions, - }, - installHint, - }; - } - } - - const availableServers = [...new Set(servers.map((s) => s.id))]; - return { - status: "not_configured", - extension: ext, - availableServers, - }; -} - -export interface ServerStatus { - id: string; - installed: boolean; - extensions: string[]; - disabled: boolean; - source: string; - priority: number; -} - -export function getAllServers(): ServerStatus[] { - const servers = getMergedServers(); - const disabled = getDisabledServerIds(); - - const result: ServerStatus[] = []; - const seen = new Set(); - - for (const server of servers) { - if (seen.has(server.id)) continue; - result.push({ - id: server.id, - installed: isServerInstalled(server.command), - extensions: server.extensions, - disabled: false, - source: server.source, - priority: server.priority, - }); - seen.add(server.id); - } - - for (const id of disabled) { - if (seen.has(id)) continue; - const builtin = BUILTIN_SERVERS[id]; - result.push({ - id, - installed: builtin ? isServerInstalled(builtin.command) : false, - extensions: builtin?.extensions ?? [], - disabled: true, - source: "disabled", - priority: 0, - }); - } - - return result; -} diff --git a/src/lsp/transport.ts b/src/lsp/transport.ts deleted file mode 100644 index bd879f7..0000000 --- a/src/lsp/transport.ts +++ /dev/null @@ -1,272 +0,0 @@ -import { delimiter } from "node:path"; - -import { reportBestEffortCleanupError } from "./cleanup-errors.js"; -import { REQUEST_TIMEOUT_MS, STOP_HARD_KILL_TIMEOUT_MS, STOP_SIGKILL_GRACE_MS } from "./constants.js"; -import { LspConnectionClosedError, LspProcessExitedError, LspRequestTimeoutError } from "./errors.js"; -import { JsonRpcConnection } from "./json-rpc-connection.js"; -import { type SpawnedProcess, spawnProcess } from "./process.js"; -import { getAdditionalPathBases } from "./server-installation.js"; -import type { Diagnostic, ResolvedServer } from "./types.js"; - -interface ConfigurationItem { - section?: string; -} - -interface DiagnosticsParams { - uri: string; - diagnostics: Diagnostic[]; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} - -function parseConfigurationItems(params: unknown): ConfigurationItem[] { - if (!isRecord(params) || !Array.isArray(params.items)) return []; - const items: ConfigurationItem[] = []; - for (const item of params.items) { - if (!isRecord(item)) continue; - items.push({ section: typeof item.section === "string" ? item.section : undefined }); - } - return items; -} - -function parseDiagnosticsParams(params: unknown): DiagnosticsParams | null { - if (!isRecord(params) || typeof params.uri !== "string") return null; - const diagnostics = Array.isArray(params.diagnostics) ? (params.diagnostics as Diagnostic[]) : []; - return { uri: params.uri, diagnostics }; -} - -export class LspClientTransport { - protected proc: SpawnedProcess | null = null; - protected connection: JsonRpcConnection | null = null; - protected readonly stderrBuffer: string[] = []; - protected processExited = false; - protected readonly diagnosticsStore = new Map(); - - constructor( - protected readonly root: string, - protected readonly server: ResolvedServer, - ) {} - - pid(): number | undefined { - return this.proc?.pid; - } - - command(): string[] { - return [...this.server.command]; - } - - async start(): Promise { - const env: Record = { - ...process.env, - ...this.server.env, - }; - const pathValue = process.platform === "win32" ? (env.PATH ?? env.Path ?? "") : (env.PATH ?? ""); - const spawnPath = [pathValue, ...getAdditionalPathBases(this.root)].filter(Boolean).join(delimiter); - if (process.platform === "win32" && env.Path !== undefined) { - env.Path = spawnPath; - } - env.PATH = spawnPath; - - this.proc = spawnProcess(this.server.command, { - cwd: this.root, - env, - }); - this.startStderrReading(); - - await new Promise((resolve) => setTimeout(resolve, 100)); - - if (this.proc.exitCode !== null) { - const stderr = this.stderrBuffer.join("\n"); - throw new LspProcessExitedError(this.server.id, this.root, this.proc.exitCode, stderr.slice(-2000)); - } - - this.connection = new JsonRpcConnection(this.proc.stdout, this.proc.stdin); - - this.connection.onNotification("textDocument/publishDiagnostics", (params) => { - const diagnosticsParams = parseDiagnosticsParams(params); - if (diagnosticsParams?.uri) { - this.diagnosticsStore.set(diagnosticsParams.uri, diagnosticsParams.diagnostics); - } - }); - - this.connection.onRequest("workspace/configuration", (params) => { - const items = parseConfigurationItems(params); - return items.map((item) => { - if (item.section === "json") return { validate: { enable: true } }; - return {}; - }); - }); - - this.connection.onRequest("client/registerCapability", () => null); - this.connection.onRequest("window/workDoneProgress/create", () => null); - - this.connection.onClose(() => { - this.processExited = true; - }); - - this.connection.onError((error) => { - reportBestEffortCleanupError("connection error notification", error); - }); - - this.connection.listen(); - } - - protected startStderrReading(): void { - if (!this.proc) return; - this.proc.stderr.setEncoding("utf-8"); - this.proc.stderr.on("data", (chunk: string) => { - this.stderrBuffer.push(chunk); - if (this.stderrBuffer.length > 100) { - this.stderrBuffer.shift(); - } - }); - } - - private isConnectionClosedError(error: unknown): error is Error { - if (!(error instanceof Error)) { - return false; - } - const code = "code" in error && typeof error.code === "string" ? error.code : undefined; - return ( - code === "ERR_STREAM_DESTROYED" || - /connection closed|connection is disposed|stream was destroyed/i.test(error.message) - ); - } - - protected sendRequest(method: string): Promise; - protected sendRequest(method: string, params: unknown): Promise; - protected async sendRequest(method: string, ...args: [] | [unknown]): Promise { - if (!this.connection) throw new Error("LSP client not started"); - - if (this.processExited || (this.proc && this.proc.exitCode !== null)) { - const stderrTail = this.stderrBuffer.slice(-10).join("\n"); - throw new LspProcessExitedError( - this.server.id, - this.root, - this.proc?.exitCode ?? null, - stderrTail || undefined, - ); - } - - let timeoutHandle: NodeJS.Timeout | null = null; - const timeoutPromise = new Promise((_, reject) => { - timeoutHandle = setTimeout(() => { - const stderrTail = this.stderrBuffer.slice(-5).join("\n"); - reject(new LspRequestTimeoutError(method, stderrTail || undefined)); - }, REQUEST_TIMEOUT_MS); - }); - - try { - const requestPromise = - args.length === 0 - ? this.connection.sendRequest(method) - : this.connection.sendRequest(method, args[0]); - const result = await Promise.race([requestPromise, timeoutPromise]); - if (timeoutHandle !== null) clearTimeout(timeoutHandle); - return result; - } catch (error) { - if (timeoutHandle !== null) clearTimeout(timeoutHandle); - if (this.processExited || (this.proc && this.proc.exitCode !== null)) { - throw new LspProcessExitedError( - this.server.id, - this.root, - this.proc?.exitCode ?? null, - this.stderrBuffer.slice(-10).join("\n") || undefined, - ); - } - if (this.isConnectionClosedError(error)) { - throw new LspConnectionClosedError(this.server.id, this.root, error.message); - } - throw error; - } - } - - protected sendNotification(method: string): Promise; - protected sendNotification(method: string, params: unknown): Promise; - protected async sendNotification(method: string, ...args: [] | [unknown]): Promise { - if (!this.connection) return; - if (this.processExited || (this.proc && this.proc.exitCode !== null)) return; - try { - if (args.length === 0) { - await this.connection.sendNotification(method); - } else { - await this.connection.sendNotification(method, args[0]); - } - } catch (error) { - if (this.isConnectionClosedError(error)) { - throw new LspConnectionClosedError(this.server.id, this.root, error.message); - } - throw error; - } - } - - isAlive(): boolean { - return this.proc !== null && !this.processExited && this.proc.exitCode === null; - } - - async stop(): Promise { - if (this.connection) { - try { - await this.sendRequest("shutdown"); - } catch (error) { - reportBestEffortCleanupError("shutdown request", error); - } - try { - await this.sendNotification("exit"); - } catch (error) { - reportBestEffortCleanupError("exit notification", error); - } - try { - this.connection.dispose(); - } catch (error) { - reportBestEffortCleanupError("connection dispose", error); - } - this.connection = null; - } - - const proc = this.proc; - if (proc) { - this.proc = null; - let exitedBeforeTimeout = false; - try { - proc.kill(); - let timeoutId: NodeJS.Timeout | undefined; - const timeoutPromise = new Promise((resolve) => { - timeoutId = setTimeout(resolve, STOP_HARD_KILL_TIMEOUT_MS); - }); - await Promise.race([ - proc.exited - .then(() => { - exitedBeforeTimeout = true; - }) - .finally(() => { - if (timeoutId) clearTimeout(timeoutId); - }), - timeoutPromise, - ]); - if (!exitedBeforeTimeout) { - try { - proc.kill("SIGKILL"); - await Promise.race([ - proc.exited, - new Promise((resolve) => setTimeout(resolve, STOP_SIGKILL_GRACE_MS)), - ]); - } catch (error) { - reportBestEffortCleanupError("hard process kill", error); - } - } - } catch (error) { - reportBestEffortCleanupError("process stop", error); - } - } - - this.processExited = true; - this.diagnosticsStore.clear(); - } - - getStoredDiagnostics(uri: string): Diagnostic[] { - return this.diagnosticsStore.get(uri) ?? []; - } -} diff --git a/src/lsp/types.ts b/src/lsp/types.ts deleted file mode 100644 index 9fe67af..0000000 --- a/src/lsp/types.ts +++ /dev/null @@ -1,126 +0,0 @@ -export interface LspServerConfig { - id: string; - command: string[]; - extensions: string[]; - disabled?: boolean; - env?: Record; - initialization?: Record; -} - -export interface ResolvedServer { - id: string; - command: string[]; - extensions: string[]; - priority: number; - env?: Record; - initialization?: Record; -} - -export interface ServerLookupInfo { - id: string; - command: string[]; - extensions: string[]; -} - -export type ServerLookupResult = - | { status: "found"; server: ResolvedServer } - | { status: "not_configured"; extension: string; availableServers: string[] } - | { status: "not_installed"; server: ServerLookupInfo; installHint: string }; - -export interface Position { - line: number; - character: number; -} - -export interface Range { - start: Position; - end: Position; -} - -export interface Location { - uri: string; - range: Range; -} - -export interface LocationLink { - targetUri: string; - targetRange: Range; - targetSelectionRange: Range; - originSelectionRange?: Range; -} - -export interface SymbolInfo { - name: string; - kind: number; - location: Location; - containerName?: string; -} - -export interface DocumentSymbol { - name: string; - kind: number; - range: Range; - selectionRange: Range; - children?: DocumentSymbol[]; -} - -export interface Diagnostic { - range: Range; - severity?: number; - code?: string | number; - source?: string; - message: string; -} - -export interface TextDocumentIdentifier { - uri: string; -} - -export interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier { - version: number | null; -} - -export interface TextEdit { - range: Range; - newText: string; -} - -export interface TextDocumentEdit { - textDocument: VersionedTextDocumentIdentifier; - edits: TextEdit[]; -} - -export interface CreateFile { - kind: "create"; - uri: string; - options?: { overwrite?: boolean; ignoreIfExists?: boolean }; -} - -export interface RenameFile { - kind: "rename"; - oldUri: string; - newUri: string; - options?: { overwrite?: boolean; ignoreIfExists?: boolean }; -} - -export interface DeleteFile { - kind: "delete"; - uri: string; - options?: { recursive?: boolean; ignoreIfNotExists?: boolean }; -} - -export interface WorkspaceEdit { - changes?: { [uri: string]: TextEdit[] }; - documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]; -} - -export interface PrepareRenameResult { - range: Range; - placeholder?: string; -} - -export interface PrepareRenameDefaultBehavior { - defaultBehavior: boolean; -} - -export type SeverityFilter = "error" | "warning" | "information" | "hint" | "all"; diff --git a/src/lsp/utils.ts b/src/lsp/utils.ts deleted file mode 100644 index 5241a6d..0000000 --- a/src/lsp/utils.ts +++ /dev/null @@ -1,14 +0,0 @@ -export function shorten(value: string, max: number): string { - if (value.length <= max) return value; - if (max <= 3) return ".".repeat(Math.max(0, max)); - return `${value.slice(0, max - 3)}...`; -} - -export function errorMessage(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} - -export function handleMissingDependencyError(error: unknown): string | null { - const message = errorMessage(error); - return message.includes("NOT INSTALLED") || message.includes("No LSP server configured") ? message : null; -} diff --git a/src/lsp/workspace-edit.ts b/src/lsp/workspace-edit.ts deleted file mode 100644 index fccf7bf..0000000 --- a/src/lsp/workspace-edit.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { readFileSync, unlinkSync, writeFileSync } from "node:fs"; - -import { uriToPath } from "./formatters.js"; -import type { TextEdit, WorkspaceEdit } from "./types.js"; - -export interface ApplyResult { - success: boolean; - filesModified: string[]; - totalEdits: number; - errors: string[]; -} - -interface FileApplyResult { - success: boolean; - editCount: number; - error?: string; -} - -function applyTextEditsToFile(filePath: string, edits: TextEdit[]): FileApplyResult { - try { - const content = readFileSync(filePath, "utf-8"); - const lines = content.split("\n"); - - const sortedEdits = [...edits].sort((a, b) => { - if (b.range.start.line !== a.range.start.line) { - return b.range.start.line - a.range.start.line; - } - return b.range.start.character - a.range.start.character; - }); - - for (const edit of sortedEdits) { - const startLine = edit.range.start.line; - const startChar = edit.range.start.character; - const endLine = edit.range.end.line; - const endChar = edit.range.end.character; - - if (startLine === endLine) { - const line = lines[startLine] ?? ""; - lines[startLine] = line.substring(0, startChar) + edit.newText + line.substring(endChar); - } else { - const firstLine = lines[startLine] ?? ""; - const lastLine = lines[endLine] ?? ""; - const newContent = firstLine.substring(0, startChar) + edit.newText + lastLine.substring(endChar); - lines.splice(startLine, endLine - startLine + 1, ...newContent.split("\n")); - } - } - - writeFileSync(filePath, lines.join("\n"), "utf-8"); - return { success: true, editCount: edits.length }; - } catch (err) { - return { - success: false, - editCount: 0, - error: err instanceof Error ? err.message : String(err), - }; - } -} - -export function applyWorkspaceEdit(edit: WorkspaceEdit | null): ApplyResult { - if (!edit) { - return { success: false, filesModified: [], totalEdits: 0, errors: ["No edit provided"] }; - } - - const result: ApplyResult = { success: true, filesModified: [], totalEdits: 0, errors: [] }; - - if (edit.changes) { - for (const [uri, edits] of Object.entries(edit.changes)) { - const filePath = uriToPath(uri); - const applyResult = applyTextEditsToFile(filePath, edits); - - if (applyResult.success) { - result.filesModified.push(filePath); - result.totalEdits += applyResult.editCount; - } else { - result.success = false; - result.errors.push(`${filePath}: ${applyResult.error}`); - } - } - } - - if (edit.documentChanges) { - for (const change of edit.documentChanges) { - if (!("kind" in change)) { - const filePath = uriToPath(change.textDocument.uri); - const applyResult = applyTextEditsToFile(filePath, change.edits); - - if (applyResult.success) { - result.filesModified.push(filePath); - result.totalEdits += applyResult.editCount; - } else { - result.success = false; - result.errors.push(`${filePath}: ${applyResult.error}`); - } - continue; - } - - if (change.kind === "create") { - try { - const filePath = uriToPath(change.uri); - writeFileSync(filePath, "", "utf-8"); - result.filesModified.push(filePath); - } catch (err) { - result.success = false; - result.errors.push(`Create ${change.uri}: ${String(err)}`); - } - } else if (change.kind === "rename") { - try { - const oldPath = uriToPath(change.oldUri); - const newPath = uriToPath(change.newUri); - const content = readFileSync(oldPath, "utf-8"); - writeFileSync(newPath, content, "utf-8"); - unlinkSync(oldPath); - result.filesModified.push(newPath); - } catch (err) { - result.success = false; - result.errors.push(`Rename ${change.oldUri}: ${String(err)}`); - } - } else if (change.kind === "delete") { - try { - const filePath = uriToPath(change.uri); - unlinkSync(filePath); - result.filesModified.push(filePath); - } catch (err) { - result.success = false; - result.errors.push(`Delete ${change.uri}: ${String(err)}`); - } - } - } - } - - return result; -} diff --git a/src/mcp.ts b/src/mcp.ts deleted file mode 100644 index bd4dbe8..0000000 --- a/src/mcp.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { createInterface } from "node:readline"; - -import { coerceToolArguments, executeLspTool, LSP_MCP_TOOLS, type TextContent } from "./tools.js"; - -export type JsonRpcId = string | number | null; - -export interface McpToolDescriptor { - name: string; - title: string; - description: string; - inputSchema: unknown; -} - -export interface JsonRpcError { - code: number; - message: string; - data?: unknown; -} - -export interface JsonRpcResult { - capabilities?: Record; - serverInfo?: Record; - protocolVersion?: string; - tools?: McpToolDescriptor[]; - content?: TextContent[]; - isError?: boolean; - [key: string]: unknown; -} - -export interface JsonRpcResponse { - jsonrpc: "2.0"; - id: JsonRpcId; - result?: JsonRpcResult; - error?: JsonRpcError; -} - -const SERVER_NAME = "lsp"; -const SERVER_VERSION = "0.1.0"; - -export async function handleLspMcpRequest(input: unknown): Promise { - if (!isRecord(input)) { - return errorResponse(null, -32600, "Invalid Request"); - } - - const id = jsonRpcId(input.id); - if (input.method === "notifications/initialized") return undefined; - if (input.method === "ping") return successResponse(id, {}); - if (input.method === "initialize") { - const protocolVersion = requestedProtocolVersion(input.params); - return successResponse(id, { - capabilities: { tools: { listChanged: false } }, - serverInfo: { name: SERVER_NAME, version: SERVER_VERSION }, - protocolVersion, - }); - } - - if (input.method === "tools/list") { - return successResponse(id, { tools: LSP_MCP_TOOLS.map(describeTool) }); - } - - if (input.method === "tools/call") { - return handleToolCall(id, input.params); - } - - return errorResponse(id, -32601, `Method not found: ${String(input.method)}`); -} - -export async function runMcpStdioServer( - input: NodeJS.ReadableStream = process.stdin, - output: NodeJS.WritableStream = process.stdout, -): Promise { - const lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY }); - for await (const line of lines) { - if (!line.trim()) continue; - let parsed: unknown; - try { - parsed = JSON.parse(line); - } catch (error) { - output.write(`${JSON.stringify(errorResponse(null, -32700, "Parse error", messageFromError(error)))}\n`); - continue; - } - - const response = await handleLspMcpRequest(parsed); - if (response) output.write(`${JSON.stringify(response)}\n`); - } -} - -async function handleToolCall(id: JsonRpcId, params: unknown): Promise { - if (!isRecord(params) || typeof params.name !== "string") { - return errorResponse(id, -32602, "tools/call requires params.name"); - } - - try { - const result = await executeLspTool(params.name, coerceToolArguments(params.arguments)); - return successResponse(id, { - content: result.content, - isError: result.isError ?? false, - details: result.details, - }); - } catch (error) { - return successResponse(id, { - content: [{ type: "text", text: messageFromError(error) }], - isError: true, - }); - } -} - -function describeTool(tool: (typeof LSP_MCP_TOOLS)[number]): McpToolDescriptor { - return { - name: tool.name, - title: tool.title, - description: tool.description, - inputSchema: tool.inputSchema, - }; -} - -function successResponse(id: JsonRpcId, result: JsonRpcResult): JsonRpcResponse { - return { jsonrpc: "2.0", id, result }; -} - -function errorResponse(id: JsonRpcId, code: number, message: string, data?: unknown): JsonRpcResponse { - return { jsonrpc: "2.0", id, error: data === undefined ? { code, message } : { code, message, data } }; -} - -function requestedProtocolVersion(params: unknown): string { - if (!isRecord(params) || typeof params.protocolVersion !== "string") return "2024-11-05"; - return params.protocolVersion; -} - -function jsonRpcId(value: unknown): JsonRpcId { - return typeof value === "string" || typeof value === "number" || value === null ? value : null; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} - -function messageFromError(error: unknown): string { - return error instanceof Error ? error.message : String(error); -} diff --git a/src/tools.ts b/src/tools.ts deleted file mode 100644 index 08d87db..0000000 --- a/src/tools.ts +++ /dev/null @@ -1,655 +0,0 @@ -import { resolve } from "node:path"; - -import { isDirectoryPath, withLspClient } from "./lsp/client-wrapper.js"; -import { DEFAULT_MAX_DIAGNOSTICS, DEFAULT_MAX_REFERENCES, DEFAULT_MAX_SYMBOLS } from "./lsp/constants.js"; -import { aggregateDiagnosticsForDirectory } from "./lsp/directory-diagnostics.js"; -import { - filterDiagnosticsBySeverity, - formatApplyResult, - formatDiagnostic, - formatDocumentSymbol, - formatLocation, - formatPrepareRenameResult, - formatSymbolInfo, -} from "./lsp/formatters.js"; -import { inferExtensionFromDirectory } from "./lsp/infer-extension.js"; -import { getLspManager } from "./lsp/manager.js"; -import { getAllServers } from "./lsp/server-resolution.js"; -import type { - Diagnostic, - DocumentSymbol, - Location, - LocationLink, - PrepareRenameDefaultBehavior, - PrepareRenameResult, - Range, - SeverityFilter, - SymbolInfo, - WorkspaceEdit, -} from "./lsp/types.js"; -import { handleMissingDependencyError } from "./lsp/utils.js"; -import { type ApplyResult, applyWorkspaceEdit } from "./lsp/workspace-edit.js"; - -export interface TextContent { - type: "text"; - text: string; -} - -export interface ToolExecutionResult { - content: TextContent[]; - isError?: boolean; - details?: unknown; -} - -export interface JsonSchema { - type: string; - description?: string; - properties?: Record; - required?: string[]; - items?: JsonSchema; - enum?: string[]; -} - -export interface LspMcpTool { - name: string; - aliases?: string[]; - title: string; - description: string; - inputSchema: JsonSchema; - execute(params: Record, signal?: AbortSignal): Promise; -} - -export interface LspDiagnosticsDetails { - filePath: string; - severity: SeverityFilter; - mode: "file" | "directory"; - diagnostics: Array<{ file: string; diagnostic: Diagnostic }>; - totalDiagnostics: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency" | "no_files" | "invalid_path"; -} - -export interface LspGotoDefinitionDetails { - filePath: string; - line: number; - character: number; - locations: Array; - error?: string; - errorKind?: "missing_dependency"; -} - -export interface LspFindReferencesDetails { - filePath: string; - line: number; - character: number; - references: Location[]; - totalReferences: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency"; -} - -export interface LspSymbolsDetails { - filePath: string; - scope: "document" | "workspace"; - query?: string; - symbols: Array; - totalSymbols: number; - truncated: boolean; - error?: string; - errorKind?: "missing_dependency" | "missing_query"; -} - -export interface LspPrepareRenameDetails { - filePath: string; - line: number; - character: number; - result: PrepareRenameResult | PrepareRenameDefaultBehavior | Range | null; - error?: string; - errorKind?: "missing_dependency"; -} - -export interface LspRenameDetails { - filePath: string; - line: number; - character: number; - newName: string; - apply: ApplyResult | null; - edit: WorkspaceEdit | null; - error?: string; - errorKind?: "missing_dependency"; -} - -const objectSchema = (properties: Record, required: string[] = []): JsonSchema => ({ - type: "object", - properties, - required, -}); - -function text(text: string, details?: unknown, isError = false): ToolExecutionResult { - return { content: [{ type: "text", text }], details, isError }; -} - -function isRecord(value: unknown): value is Record { - return typeof value === "object" && value !== null && !Array.isArray(value); -} - -function requireString(params: Record, key: string): string { - const value = params[key]; - if (typeof value !== "string" || value.length === 0) { - throw new Error(`Missing required string parameter '${key}'`); - } - return value; -} - -function optionalString(params: Record, key: string): string | undefined { - const value = params[key]; - return typeof value === "string" ? value : undefined; -} - -function requireNumber(params: Record, key: string): number { - const value = params[key]; - if (typeof value !== "number" || !Number.isFinite(value)) { - throw new Error(`Missing required number parameter '${key}'`); - } - return value; -} - -function optionalNumber(params: Record, key: string): number | undefined { - const value = params[key]; - return typeof value === "number" && Number.isFinite(value) ? value : undefined; -} - -function optionalBoolean(params: Record, key: string): boolean | undefined { - const value = params[key]; - return typeof value === "boolean" ? value : undefined; -} - -function isSeverityFilter(value: unknown): value is SeverityFilter { - return value === "error" || value === "warning" || value === "information" || value === "hint" || value === "all"; -} - -function severityFilter(params: Record): SeverityFilter { - const value = params.severity; - if (isSeverityFilter(value)) return value; - return "all"; -} - -function asDiagnosticArray(result: { items?: Diagnostic[] } | Diagnostic[] | null | undefined): Diagnostic[] { - if (!result) return []; - if (Array.isArray(result)) return result; - return result.items ?? []; -} - -function isDocumentSymbol(symbol: DocumentSymbol | SymbolInfo): symbol is DocumentSymbol { - return "range" in symbol; -} - -async function executeLspStatus(): Promise { - const servers = getAllServers(); - const snapshots = getLspManager().getSnapshot(); - const installed = servers.filter((server) => server.installed && !server.disabled); - const configuredLines = servers.map((server) => { - const state = server.disabled ? "disabled" : server.installed ? "installed" : "missing"; - return `- ${server.id}: ${state}; source=${server.source}; extensions=${server.extensions.join(", ")}`; - }); - const activeLines = snapshots.map((snapshot) => { - const state = snapshot.alive ? (snapshot.isInitializing ? "initializing" : "alive") : "dead"; - return `- ${snapshot.serverId}: ${state}; root=${snapshot.root}; refs=${snapshot.refCount}`; - }); - const lines = [ - `Configured LSP servers: ${servers.length}`, - `Installed LSP servers: ${installed.length}`, - "", - ...configuredLines, - "", - `Active LSP clients: ${snapshots.length}`, - ...activeLines, - ]; - return text(lines.join("\n"), { servers, snapshots }); -} - -export async function executeLspDiagnostics( - params: Record, - signal?: AbortSignal, -): Promise { - const filePath = requireString(params, "filePath"); - const severity = severityFilter(params); - - try { - const absPath = resolve(filePath); - if (isDirectoryPath(absPath)) { - const extension = inferExtensionFromDirectory(absPath); - if (!extension) { - const message = `No supported source files found in directory: ${absPath}`; - const details: LspDiagnosticsDetails = { - filePath, - severity, - mode: "directory", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - error: message, - errorKind: "no_files", - }; - return text(message, details); - } - - const output = await aggregateDiagnosticsForDirectory(absPath, extension, severity); - const details: LspDiagnosticsDetails = { - filePath, - severity, - mode: "directory", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - }; - return text(output, details); - } - - const result = await withLspClient(filePath, async (client) => client.diagnostics(filePath), "diagnostics", { - signal, - }); - const diagnostics = filterDiagnosticsBySeverity(asDiagnosticArray(result), severity); - const total = diagnostics.length; - const truncated = total > DEFAULT_MAX_DIAGNOSTICS; - const limited = truncated ? diagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS) : diagnostics; - const output = - total === 0 - ? "No diagnostics found" - : [ - ...(truncated ? [`Found ${total} diagnostics (showing first ${DEFAULT_MAX_DIAGNOSTICS}):`] : []), - ...limited.map(formatDiagnostic), - ].join("\n"); - const details: LspDiagnosticsDetails = { - filePath, - severity, - mode: "file", - diagnostics: diagnostics.map((diagnostic) => ({ file: absPath, diagnostic })), - totalDiagnostics: total, - truncated, - }; - return text(output, details); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - const details: LspDiagnosticsDetails = { - filePath, - severity, - mode: "file", - diagnostics: [], - totalDiagnostics: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }; - return text(message, details); - } - throw error; - } -} - -async function executeLspGotoDefinition( - params: Record, - signal?: AbortSignal, -): Promise { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - - try { - const result = await withLspClient( - filePath, - async (client) => client.definition(filePath, line, character), - "definition", - { signal }, - ); - const locations = !result ? [] : Array.isArray(result) ? result : [result]; - const details: LspGotoDefinitionDetails = { filePath, line, character, locations }; - if (locations.length === 0) return text("No definition found", details); - return text(locations.map(formatLocation).join("\n"), details); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - locations: [], - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} - -async function executeLspFindReferences( - params: Record, - signal?: AbortSignal, -): Promise { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - const includeDeclaration = optionalBoolean(params, "includeDeclaration") ?? true; - - try { - const result = await withLspClient( - filePath, - async (client) => client.references(filePath, line, character, includeDeclaration), - "references", - { signal }, - ); - const references = Array.isArray(result) ? result : []; - const total = references.length; - const truncated = total > DEFAULT_MAX_REFERENCES; - const limited = truncated ? references.slice(0, DEFAULT_MAX_REFERENCES) : references; - const details: LspFindReferencesDetails = { - filePath, - line, - character, - references, - totalReferences: total, - truncated, - }; - if (total === 0) return text("No references found", details); - const output = [ - ...(truncated ? [`Found ${total} references (showing first ${DEFAULT_MAX_REFERENCES}):`] : []), - ...limited.map(formatLocation), - ].join("\n"); - return text(output, details); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - references: [], - totalReferences: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} - -async function executeLspSymbols(params: Record, signal?: AbortSignal): Promise { - const filePath = requireString(params, "filePath"); - const rawScope = optionalString(params, "scope") ?? "document"; - const scope = rawScope === "workspace" ? "workspace" : "document"; - const limit = Math.min(optionalNumber(params, "limit") ?? DEFAULT_MAX_SYMBOLS, DEFAULT_MAX_SYMBOLS); - - try { - if (scope === "workspace") { - const query = optionalString(params, "query"); - if (!query) { - const message = "Error: 'query' is required for workspace scope"; - return text(message, { - filePath, - scope, - query: undefined, - symbols: [], - totalSymbols: 0, - truncated: false, - error: message, - errorKind: "missing_query", - }); - } - - const symbols = await withLspClient( - filePath, - async (client) => client.workspaceSymbols(query), - "workspaceSymbols", - { signal }, - ); - return formatSymbolsResult(filePath, scope, symbols, limit, query); - } - - const symbols = await withLspClient( - filePath, - async (client) => client.documentSymbols(filePath), - "documentSymbols", - { signal }, - ); - return formatSymbolsResult(filePath, scope, symbols, limit); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - scope, - query: optionalString(params, "query"), - symbols: [], - totalSymbols: 0, - truncated: false, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} - -function formatSymbolsResult( - filePath: string, - scope: "document" | "workspace", - symbols: Array, - limit: number, - query?: string, -): ToolExecutionResult { - const total = symbols.length; - const truncated = total > limit; - const limited = truncated ? symbols.slice(0, limit) : symbols; - const details: LspSymbolsDetails = { filePath, scope, query, symbols, totalSymbols: total, truncated }; - if (total === 0) return text("No symbols found", details); - - const lines: string[] = []; - if (truncated) lines.push(`Found ${total} symbols (showing first ${limit}):`); - const documentSymbols = limited.filter(isDocumentSymbol); - if (documentSymbols.length === limited.length) { - lines.push(...documentSymbols.map((symbol) => formatDocumentSymbol(symbol))); - } else { - lines.push(...limited.filter((symbol): symbol is SymbolInfo => !isDocumentSymbol(symbol)).map(formatSymbolInfo)); - } - return text(lines.join("\n"), details); -} - -async function executeLspPrepareRename( - params: Record, - signal?: AbortSignal, -): Promise { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - - try { - const result = await withLspClient( - filePath, - async (client) => client.prepareRename(filePath, line, character), - "prepareRename", - { signal }, - ); - const details: LspPrepareRenameDetails = { filePath, line, character, result }; - return text(formatPrepareRenameResult(result), details); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - result: null, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} - -async function executeLspRename(params: Record, signal?: AbortSignal): Promise { - const filePath = requireString(params, "filePath"); - const line = requireNumber(params, "line"); - const character = requireNumber(params, "character"); - const newName = requireString(params, "newName"); - - try { - const edit = await withLspClient( - filePath, - async (client) => client.rename(filePath, line, character, newName), - "rename", - { signal }, - ); - const apply = applyWorkspaceEdit(edit); - const details: LspRenameDetails = { filePath, line, character, newName, apply, edit }; - return text(formatApplyResult(apply), details, !apply.success); - } catch (error) { - const message = handleMissingDependencyError(error); - if (message) { - return text(message, { - filePath, - line, - character, - newName, - apply: null, - edit: null, - error: message, - errorKind: "missing_dependency", - }); - } - throw error; - } -} - -export async function executeLspTool( - name: string, - params: Record, - signal?: AbortSignal, -): Promise { - const tool = LSP_MCP_TOOLS.find((candidate) => matchesToolName(candidate, name)); - if (!tool) throw new Error(`Unknown LSP tool: ${name}`); - return tool.execute(params, signal); -} - -function matchesToolName(tool: LspMcpTool, name: string): boolean { - return tool.name === name || (tool.aliases?.includes(name) ?? false); -} - -export function coerceToolArguments(value: unknown): Record { - return isRecord(value) ? value : {}; -} - -export const LSP_MCP_TOOLS: LspMcpTool[] = [ - { - name: "status", - aliases: ["lsp_status"], - title: "LSP Status", - description: "List configured and active LSP servers without starting a new language server.", - inputSchema: objectSchema({}), - execute: executeLspStatus, - }, - { - name: "diagnostics", - aliases: ["lsp_diagnostics"], - title: "LSP Diagnostics", - description: "Get errors, warnings, and hints for a source file or directory.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "File or directory path to check." }, - severity: { - type: "string", - enum: ["error", "warning", "information", "hint", "all"], - description: "Severity filter. Defaults to all.", - }, - }, - ["filePath"], - ), - execute: executeLspDiagnostics, - }, - { - name: "goto_definition", - aliases: ["lsp_goto_definition"], - title: "LSP Goto Definition", - description: "Find where a symbol is defined.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "Source file containing the symbol." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - }, - ["filePath", "line", "character"], - ), - execute: executeLspGotoDefinition, - }, - { - name: "find_references", - aliases: ["lsp_find_references"], - title: "LSP Find References", - description: "Find references of a symbol across the workspace.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "Source file containing the symbol." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - includeDeclaration: { type: "boolean", description: "Include the declaration. Defaults to true." }, - }, - ["filePath", "line", "character"], - ), - execute: executeLspFindReferences, - }, - { - name: "symbols", - aliases: ["lsp_symbols"], - title: "LSP Symbols", - description: "List document symbols or search workspace symbols.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "File path used as LSP context." }, - scope: { - type: "string", - enum: ["document", "workspace"], - description: "Use document for file outline or workspace for project-wide search.", - }, - query: { type: "string", description: "Workspace symbol query." }, - limit: { type: "number", description: "Maximum number of symbols to return." }, - }, - ["filePath", "scope"], - ), - execute: executeLspSymbols, - }, - { - name: "prepare_rename", - aliases: ["lsp_prepare_rename"], - title: "LSP Prepare Rename", - description: "Check whether a symbol can be renamed at a position.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "Source file path." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - }, - ["filePath", "line", "character"], - ), - execute: executeLspPrepareRename, - }, - { - name: "rename", - aliases: ["lsp_rename"], - title: "LSP Rename", - description: "Rename a symbol across the workspace and apply the returned workspace edit.", - inputSchema: objectSchema( - { - filePath: { type: "string", description: "Source file path." }, - line: { type: "number", description: "1-based line number." }, - character: { type: "number", description: "0-based column." }, - newName: { type: "string", description: "New symbol name." }, - }, - ["filePath", "line", "character", "newName"], - ), - execute: executeLspRename, - }, -]; From cab7a86d0f90420e6577c049b8ff2415430ab8f2 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:32:57 +0900 Subject: [PATCH 07/10] test: keep codex-only coverage and remove upstream tests Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .mcp.json | 2 +- test/config-loader.test.ts | 17 ------- test/directory-diagnostics.test.ts | 32 ------------ test/json-rpc-connection.test.ts | 69 ------------------------- test/mcp.test.ts | 82 ------------------------------ test/package-smoke.test.ts | 6 ++- test/process.test.ts | 69 ------------------------- 7 files changed, 5 insertions(+), 272 deletions(-) delete mode 100644 test/config-loader.test.ts delete mode 100644 test/directory-diagnostics.test.ts delete mode 100644 test/json-rpc-connection.test.ts delete mode 100644 test/mcp.test.ts delete mode 100644 test/process.test.ts diff --git a/.mcp.json b/.mcp.json index fe93857..13ff674 100644 --- a/.mcp.json +++ b/.mcp.json @@ -2,7 +2,7 @@ "mcpServers": { "lsp": { "command": "node", - "args": ["./dist/cli.js", "mcp"], + "args": ["./packages/lsp-tools-mcp/dist/cli.js", "mcp"], "cwd": "." } } diff --git a/test/config-loader.test.ts b/test/config-loader.test.ts deleted file mode 100644 index d806489..0000000 --- a/test/config-loader.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { join, sep } from "node:path"; -import { describe, expect, it } from "vitest"; - -import { getConfigPaths } from "../src/lsp/config-loader.js"; - -describe("config loader", () => { - it("uses Codex config locations instead of pi config locations", () => { - const paths = getConfigPaths(); - const expectedSuffix = join(".codex", "lsp-client.json"); - const piMarker = `${sep}.pi${sep}`; - - expect(paths.project.endsWith(expectedSuffix)).toBe(true); - expect(paths.user.endsWith(expectedSuffix)).toBe(true); - expect(paths.project).not.toContain(piMarker); - expect(paths.user).not.toContain(piMarker); - }); -}); diff --git a/test/directory-diagnostics.test.ts b/test/directory-diagnostics.test.ts deleted file mode 100644 index cbd85ca..0000000 --- a/test/directory-diagnostics.test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; -import { tmpdir } from "node:os"; -import { join } from "node:path"; -import { afterEach, describe, expect, it } from "vitest"; - -import { collectFilesWithExtension } from "../src/lsp/directory-diagnostics.js"; - -const tempDirectories: string[] = []; - -afterEach(() => { - for (const directory of tempDirectories.splice(0)) { - rmSync(directory, { recursive: true, force: true }); - } -}); - -describe("collectFilesWithExtension", () => { - it("#given more matching files than max #when collecting diagnostics inputs #then traversal returns only capped files", () => { - // given - const root = mkdtempSync(join(tmpdir(), "codex-lsp-directory-")); - tempDirectories.push(root); - mkdirSync(join(root, "src"), { recursive: true }); - for (let index = 0; index < 5; index += 1) { - writeFileSync(join(root, "src", `file-${index}.ts`), `export const value${index} = ${index};\n`); - } - - // when - const files = collectFilesWithExtension(root, ".ts", 2); - - // then - expect(files).toHaveLength(2); - }); -}); diff --git a/test/json-rpc-connection.test.ts b/test/json-rpc-connection.test.ts deleted file mode 100644 index c31c9fd..0000000 --- a/test/json-rpc-connection.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { PassThrough } from "node:stream"; -import { describe, expect, it } from "vitest"; - -import { JsonRpcConnection } from "../src/lsp/json-rpc-connection.js"; - -function encodeMessage(message: Record): string { - const body = JSON.stringify(message); - return `Content-Length: ${Buffer.byteLength(body, "utf8")}\r\n\r\n${body}`; -} - -function readOneMessage(stream: PassThrough): Promise> { - return new Promise((resolve) => { - stream.once("data", (chunk: Buffer) => { - const text = chunk.toString("utf8"); - const bodyStart = text.indexOf("\r\n\r\n") + 4; - resolve(JSON.parse(text.slice(bodyStart)) as Record); - }); - }); -} - -describe("JsonRpcConnection", () => { - it("#given a framed response #when sending request #then resolves the matching result", async () => { - // given - const serverOutput = new PassThrough(); - const serverInput = new PassThrough(); - const connection = new JsonRpcConnection(serverOutput, serverInput); - connection.listen(); - const requestMessage = readOneMessage(serverInput); - - // when - const resultPromise = connection.sendRequest<{ capabilities: Record }>("initialize", { - rootUri: "file:///tmp/project", - }); - const request = await requestMessage; - serverOutput.write(encodeMessage({ jsonrpc: "2.0", id: request.id, result: { capabilities: {} } })); - - // then - await expect(resultPromise).resolves.toEqual({ capabilities: {} }); - connection.dispose(); - }); - - it("#given a server request #when handler returns #then writes a json-rpc response", async () => { - // given - const serverOutput = new PassThrough(); - const serverInput = new PassThrough(); - const connection = new JsonRpcConnection(serverOutput, serverInput); - connection.onRequest("workspace/configuration", () => [{ validate: { enable: true } }]); - connection.listen(); - - // when - const responseMessage = readOneMessage(serverInput); - serverOutput.write( - encodeMessage({ - jsonrpc: "2.0", - id: 7, - method: "workspace/configuration", - params: { items: [{ section: "json" }] }, - }), - ); - - // then - await expect(responseMessage).resolves.toMatchObject({ - jsonrpc: "2.0", - id: 7, - result: [{ validate: { enable: true } }], - }); - connection.dispose(); - }); -}); diff --git a/test/mcp.test.ts b/test/mcp.test.ts deleted file mode 100644 index 61f380a..0000000 --- a/test/mcp.test.ts +++ /dev/null @@ -1,82 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { handleLspMcpRequest } from "../src/mcp.js"; - -describe("lsp MCP server", () => { - it("responds to initialize with tool capabilities", async () => { - const response = await handleLspMcpRequest({ - jsonrpc: "2.0", - id: 1, - method: "initialize", - params: { - protocolVersion: "2024-11-05", - capabilities: {}, - clientInfo: { name: "test", version: "0.0.0" }, - }, - }); - - expect(response).toMatchObject({ - jsonrpc: "2.0", - id: 1, - result: { - capabilities: { tools: { listChanged: false } }, - serverInfo: { name: "lsp", version: "0.1.0" }, - }, - }); - }); - - it("lists LSP MCP tools", async () => { - const response = await handleLspMcpRequest({ - jsonrpc: "2.0", - id: 2, - method: "tools/list", - }); - - const tools = response?.result?.tools as Array<{ name: string }>; - expect(tools.map((tool) => tool.name)).toEqual([ - "status", - "diagnostics", - "goto_definition", - "find_references", - "symbols", - "prepare_rename", - "rename", - ]); - }); - - it("calls status without starting a language server", async () => { - const response = await handleLspMcpRequest({ - jsonrpc: "2.0", - id: 3, - method: "tools/call", - params: { name: "status", arguments: {} }, - }); - - expect(response).toMatchObject({ - jsonrpc: "2.0", - id: 3, - result: { - isError: false, - }, - }); - expect(response?.result?.content?.[0]?.text).toContain("Configured LSP servers"); - }); - - it("accepts legacy lsp-prefixed tool names without listing them", async () => { - const response = await handleLspMcpRequest({ - jsonrpc: "2.0", - id: 4, - method: "tools/call", - params: { name: "lsp_status", arguments: {} }, - }); - - expect(response).toMatchObject({ - jsonrpc: "2.0", - id: 4, - result: { - isError: false, - }, - }); - expect(response?.result?.content?.[0]?.text).toContain("Configured LSP servers"); - }); -}); diff --git a/test/package-smoke.test.ts b/test/package-smoke.test.ts index 44f21be..c718dec 100644 --- a/test/package-smoke.test.ts +++ b/test/package-smoke.test.ts @@ -25,13 +25,15 @@ describe("plugin package metadata", () => { // then expect(packageJson.type).toBe("module"); expect(packageJson.packageManager).toBe("npm@11.12.1"); - expect(dependencies ?? {}).toEqual({}); + expect(dependencies).toEqual({ + "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp", + }); expect(bin["codex-lsp"]).toBe("./dist/cli.js"); expect(pluginJson.hooks).toBe("./hooks/hooks.json"); expect(pluginJson.mcpServers).toBe("./.mcp.json"); expect(cliSource.startsWith("#!/usr/bin/env node")).toBe(true); expect(command).toBe(`node "${pluginRoot}/dist/cli.js" hook post-tool-use`); expect(mcpServers.lsp?.command).toBe("node"); - expect(mcpServers.lsp?.args).toEqual(["./dist/cli.js", "mcp"]); + expect(mcpServers.lsp?.args).toEqual(["./packages/lsp-tools-mcp/dist/cli.js", "mcp"]); }); }); diff --git a/test/process.test.ts b/test/process.test.ts deleted file mode 100644 index 8999a22..0000000 --- a/test/process.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; -import { tmpdir } from "node:os"; -import { join } from "node:path"; - -import { afterEach, describe, expect, it } from "vitest"; - -import { createSpawnCommand } from "../src/lsp/process.js"; - -const tempDirectories: string[] = []; - -afterEach(() => { - for (const directory of tempDirectories.splice(0)) { - rmSync(directory, { recursive: true, force: true }); - } -}); - -describe("createSpawnCommand", () => { - it("#given windows executable command #when building spawn command #then it avoids shell mode", () => { - // given - const command = ["typescript-language-server", "--stdio"]; - - // when - const prepared = createSpawnCommand(command, "win32", "cmd.exe"); - - // then - expect(prepared).toEqual({ - command: "typescript-language-server", - args: ["--stdio"], - shell: false, - }); - }); - - it("#given windows cmd shim #when building spawn command #then it uses cmd only for the shim", () => { - // given - const command = ["typescript-language-server.cmd", "--stdio"]; - - // when - const prepared = createSpawnCommand(command, "win32", "cmd.exe"); - - // then - expect(prepared).toEqual({ - command: "cmd.exe", - args: ["/d", "/s", "/c", "typescript-language-server.cmd", "--stdio"], - shell: false, - }); - }); - - it("#given windows PATH shim #when resolving spawn command #then it executes the shim without shell mode", () => { - // given - const binaryDirectory = mkdtempSync(join(tmpdir(), "codex-lsp-bin-")); - tempDirectories.push(binaryDirectory); - mkdirSync(binaryDirectory, { recursive: true }); - const shimPath = join(binaryDirectory, "typescript-language-server.cmd"); - writeFileSync(shimPath, "@echo off\n"); - - // when - const prepared = createSpawnCommand(["typescript-language-server", "--stdio"], "win32", "cmd.exe", { - PATH: binaryDirectory, - PATHEXT: ".cmd;.exe", - }); - - // then - expect(prepared).toEqual({ - command: "cmd.exe", - args: ["/d", "/s", "/c", shimPath, "--stdio"], - shell: false, - }); - }); -}); From d9e16e8c0a6540bcf5fa5b463b5e9c98b2eb63ea Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:33:10 +0900 Subject: [PATCH 08/10] docs: describe lsp-tools-mcp submodule architecture Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- CHANGELOG.md | 7 +++++++ README.md | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b5040c..5853ed1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +## 0.2.0 + +- Extracted the LSP runtime and MCP server into [`@code-yeongyu/lsp-tools-mcp`](https://github.com/code-yeongyu/lsp-tools-mcp). +- codex-lsp now consumes that runtime as a git submodule at `packages/lsp-tools-mcp`. +- Kept the Codex-specific PostToolUse hook in this package and routed MCP serving through the upstream CLI. + +- Extract LSP runtime to `lsp-tools-mcp` upstream and consume it via git submodule at `packages/lsp-tools-mcp`. - Renamed the MCP server namespace to `lsp` and exposed shorter tool names such as `lsp.diagnostics`. - Use portable Codex hook interpolation and add package smoke coverage for hook/MCP entrypoints. - Spawn language servers without shell mode; Windows `.cmd` and `.bat` shims are routed through `cmd.exe` with explicit arguments. diff --git a/README.md b/README.md index dddb48c..f3ef1e4 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ Codex plugin that ports the standalone LSP runtime from [`pi-lsp-client`](https://github.com/code-yeongyu/pi-lsp-client). It gives Codex post-edit diagnostics plus explicit MCP tools for language-aware code work. +## Architecture + +The LSP runtime moved to [`lsp-tools-mcp`](https://github.com/code-yeongyu/lsp-tools-mcp) and is consumed here as a git submodule at `packages/lsp-tools-mcp/`. + +- `codex-lsp` keeps Codex-specific integration (`hook post-tool-use`, plugin metadata, package wiring). +- `lsp-tools-mcp` owns MCP runtime, LSP manager, and tool implementations. +- `src/cli.ts` routes `mcp` to upstream runtime and keeps `hook post-tool-use` local. + ## Behavior | Case | Result | @@ -67,7 +75,7 @@ The plugin ships: - `hooks/hooks.json` for the `PostToolUse` diagnostics hook. - `skills/lsp/SKILL.md` with MCP usage guidance. -The runtime has no npm production dependencies, so a clean Codex marketplace copy can run without a follow-up `npm install`. +The runtime depends on `@code-yeongyu/lsp-tools-mcp` via `file:./packages/lsp-tools-mcp`, so marketplace builds must include submodule contents. The hook command is: @@ -78,12 +86,13 @@ node "${PLUGIN_ROOT}/dist/cli.js" hook post-tool-use The MCP command is: ```bash -node ./dist/cli.js mcp +node ./packages/lsp-tools-mcp/dist/cli.js mcp ``` ## Local Development ```bash +git submodule update --init --recursive npm install npm test npm run typecheck @@ -112,7 +121,7 @@ codex plugin marketplace add /path/to/codex-plugins node /path/to/codex-plugins/scripts/install-local.mjs /path/to/codex-plugins ``` -If your local Codex build exposes plugin install commands, you can install from the UI or CLI instead. For older local builds, the marketplace installer builds and copies the plugin into `~/.codex/plugins/cache//codex-lsp/0.1.0` and enables: +If your local Codex build exposes plugin install commands, you can install from the UI or CLI instead. For older local builds, the marketplace installer builds and copies the plugin into `~/.codex/plugins/cache//codex-lsp/0.2.0` and enables: ```toml [plugins."codex-lsp@code-yeongyu-codex-plugins"] From e05709e9a12a41e69d352e91de6780de88dee839 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:34:54 +0900 Subject: [PATCH 09/10] chore: build submodule before typecheck and tests Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 479c2fb..6c0c5b7 100644 --- a/package.json +++ b/package.json @@ -37,13 +37,14 @@ ], "scripts": { "prepare": "npm --prefix packages/lsp-tools-mcp install", - "build": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && tsc -p tsconfig.build.json", - "test": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && vitest --run", + "build:submodule": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && npm install --no-fund --no-audit --ignore-scripts", + "build": "npm run build:submodule && tsc -p tsconfig.build.json", + "test": "npm run build:submodule && vitest --run", "test:watch": "vitest", "typecheck": "tsc --noEmit", "lint": "biome check src test", "lint:fix": "biome check --write src test", - "check": "tsc --noEmit && biome check src test && npm run build" + "check": "npm run build:submodule && tsc --noEmit && biome check src test && tsc -p tsconfig.build.json" }, "dependencies": { "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp" From 66292681135529af256310ac2c8b2eb4d01e66de Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 11:39:56 +0900 Subject: [PATCH 10/10] ci: bootstrap submodule explicitly in workflows to avoid Windows prepare recursion --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/publish.yml | 7 +++++++ README.md | 4 ++++ package.json | 9 ++++----- scripts/bootstrap-submodule.mjs | 27 +++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 scripts/bootstrap-submodule.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 208b2ad..f8d6415 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,13 @@ jobs: node-version: ${{ matrix.node }} cache: npm + - name: Bootstrap lsp-tools-mcp submodule + shell: bash + run: | + cd packages/lsp-tools-mcp + npm ci + npm run build + - name: Install dependencies run: npm ci diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cff9b70..125a455 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,6 +30,13 @@ jobs: registry-url: https://registry.npmjs.org cache: npm + - name: Bootstrap lsp-tools-mcp submodule + shell: bash + run: | + cd packages/lsp-tools-mcp + npm ci + npm run build + - name: Install dependencies run: npm ci diff --git a/README.md b/README.md index f3ef1e4..40f3bcb 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ node ./packages/lsp-tools-mcp/dist/cli.js mcp ```bash git submodule update --init --recursive +npm run bootstrap # installs + builds the lsp-tools-mcp submodule npm install npm test npm run typecheck @@ -100,6 +101,9 @@ npm run check npm pack --dry-run ``` +The `bootstrap` script installs and builds the `lsp-tools-mcp` git submodule so +`@code-yeongyu/lsp-tools-mcp/dist/*.js` is available for the codex-lsp build. + Smoke-test the hook: ```bash diff --git a/package.json b/package.json index 6c0c5b7..2a6ff99 100644 --- a/package.json +++ b/package.json @@ -36,15 +36,14 @@ "CHANGELOG.md" ], "scripts": { - "prepare": "npm --prefix packages/lsp-tools-mcp install", - "build:submodule": "npm --prefix packages/lsp-tools-mcp install && npm --prefix packages/lsp-tools-mcp run build && npm install --no-fund --no-audit --ignore-scripts", - "build": "npm run build:submodule && tsc -p tsconfig.build.json", - "test": "npm run build:submodule && vitest --run", + "bootstrap": "node scripts/bootstrap-submodule.mjs", + "build": "tsc -p tsconfig.build.json", + "test": "vitest --run", "test:watch": "vitest", "typecheck": "tsc --noEmit", "lint": "biome check src test", "lint:fix": "biome check --write src test", - "check": "npm run build:submodule && tsc --noEmit && biome check src test && tsc -p tsconfig.build.json" + "check": "tsc --noEmit && biome check src test && tsc -p tsconfig.build.json" }, "dependencies": { "@code-yeongyu/lsp-tools-mcp": "file:./packages/lsp-tools-mcp" diff --git a/scripts/bootstrap-submodule.mjs b/scripts/bootstrap-submodule.mjs new file mode 100644 index 0000000..a09626e --- /dev/null +++ b/scripts/bootstrap-submodule.mjs @@ -0,0 +1,27 @@ +#!/usr/bin/env node +// Bootstrap the lsp-tools-mcp git submodule for local development. +// CI runs the install+build steps explicitly in the workflow, so this +// script is for `npm run bootstrap` after a fresh clone. +import { existsSync } from "node:fs"; +import { execSync } from "node:child_process"; +import { dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const submoduleDir = join(__dirname, "..", "packages", "lsp-tools-mcp"); +const submodulePackageJson = join(submoduleDir, "package.json"); + +if (!existsSync(submodulePackageJson)) { + console.error( + "lsp-tools-mcp submodule is missing. Run: git submodule update --init --recursive", + ); + process.exit(1); +} + +console.log("Installing lsp-tools-mcp dependencies..."); +execSync("npm ci", { cwd: submoduleDir, stdio: "inherit" }); + +console.log("Building lsp-tools-mcp..."); +execSync("npm run build", { cwd: submoduleDir, stdio: "inherit" }); + +console.log("Done.");