From 7b04f536ffcc1607987485a0fc401b8db6a8eb49 Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:20:50 +0900 Subject: [PATCH 1/6] feat(lsp): gate runtime downloads behind CODE_LSP_AUTO_INSTALL Add AUTO_INSTALL_ENV, isAutoInstallEnabled() and autoInstallDisabled() and call them before every spawn-time download or install (GitHub release, npm into ~/.cache/dora, dotnet tool, gem, versioned bunx). --- packages/lsp/src/server/astro.ts | 4 +- packages/lsp/src/server/bash.ts | 4 +- packages/lsp/src/server/biome.ts | 3 +- packages/lsp/src/server/clangd.ts | 3 +- packages/lsp/src/server/csharp.ts | 4 +- packages/lsp/src/server/dart.ts | 3 +- packages/lsp/src/server/dockerfile.ts | 4 +- packages/lsp/src/server/elixir.ts | 4 +- packages/lsp/src/server/eslint.ts | 4 +- packages/lsp/src/server/fsharp.ts | 4 +- packages/lsp/src/server/index.ts | 3 + packages/lsp/src/server/jdtls.ts | 3 +- packages/lsp/src/server/kotlin.ts | 4 +- packages/lsp/src/server/lua.ts | 3 +- packages/lsp/src/server/php.ts | 4 +- packages/lsp/src/server/prisma.ts | 4 +- packages/lsp/src/server/pyright.ts | 3 +- packages/lsp/src/server/rubocop.ts | 4 +- packages/lsp/src/server/svelte.ts | 4 +- packages/lsp/src/server/terraform.ts | 3 +- packages/lsp/src/server/texlab.ts | 3 +- packages/lsp/src/server/typescript.ts | 3 +- packages/lsp/src/server/utils.ts | 25 +++++++ packages/lsp/src/server/vue.ts | 4 +- packages/lsp/src/server/yaml.ts | 4 +- packages/lsp/src/server/zls.ts | 3 +- packages/lsp/test/unit/auto-install.test.ts | 83 +++++++++++++++++++++ 27 files changed, 173 insertions(+), 24 deletions(-) create mode 100644 packages/lsp/test/unit/auto-install.test.ts diff --git a/packages/lsp/src/server/astro.ts b/packages/lsp/src/server/astro.ts index c55d169..50c1151 100644 --- a/packages/lsp/src/server/astro.ts +++ b/packages/lsp/src/server/astro.ts @@ -8,7 +8,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' const ASTRO_RUNTIME_DEPS = { astroLanguageServer: { @@ -63,6 +63,8 @@ async function setupAstroDependencies(): Promise<{ needsInstall = true } + if (needsInstall && autoInstallDisabled('astro')) { needsInstall = false } + if (needsInstall) { log.info('Installing Astro Language Server') try { diff --git a/packages/lsp/src/server/bash.ts b/packages/lsp/src/server/bash.ts index 33b8298..29d010c 100644 --- a/packages/lsp/src/server/bash.ts +++ b/packages/lsp/src/server/bash.ts @@ -8,7 +8,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log } from './utils' const BASH_RUNTIME_DEPS = { bashLanguageServer: { @@ -48,6 +48,8 @@ async function setupBashDependencies(): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('bash')) { needsInstall = false } + if (needsInstall) { log.info('Installing Bash Language Server') try { diff --git a/packages/lsp/src/server/biome.ts b/packages/lsp/src/server/biome.ts index 6d02215..82f0ae0 100644 --- a/packages/lsp/src/server/biome.ts +++ b/packages/lsp/src/server/biome.ts @@ -8,7 +8,7 @@ import { spawn } from 'node:child_process' import fs from 'node:fs/promises' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' /** @biomejs/biome version installed by the bunx fallback. */ export const BIOME_VERSION = '2.6.2' @@ -81,6 +81,7 @@ export const BiomeServer: LSPServerInfo = { log.warn({ root }, 'Biome not found. Install with: npm install @biomejs/biome') return undefined } + if (autoInstallDisabled('biome')) { return undefined } const proc = spawn(bunx, [`@biomejs/biome@${BIOME_VERSION}`, 'lsp-proxy', '--stdio'], { cwd: root, env: { ...process.env, BUN_BE_BUN: '1' }, diff --git a/packages/lsp/src/server/clangd.ts b/packages/lsp/src/server/clangd.ts index 02c7308..50b7254 100644 --- a/packages/lsp/src/server/clangd.ts +++ b/packages/lsp/src/server/clangd.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getClangdResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'clangd-lsp') @@ -55,6 +55,7 @@ export const ClangdServer: LSPServerInfo = { } // Download from GitHub releases + if (autoInstallDisabled('clangd')) { return undefined } log.info('Downloading clangd from GitHub releases') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/csharp.ts b/packages/lsp/src/server/csharp.ts index a994286..bf45bcf 100644 --- a/packages/lsp/src/server/csharp.ts +++ b/packages/lsp/src/server/csharp.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' function getCsharpResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'csharp-lsp') @@ -37,6 +37,8 @@ export const CsharpServer: LSPServerInfo = { return undefined } + if (autoInstallDisabled('csharp')) { return undefined } + log.info('Installing csharp-ls via dotnet tool') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/dart.ts b/packages/lsp/src/server/dart.ts index 5e87cb7..f96bcbe 100644 --- a/packages/lsp/src/server/dart.ts +++ b/packages/lsp/src/server/dart.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadAndExtract, findRunnableBin, getPlatformId, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadAndExtract, findRunnableBin, getPlatformId, log, nearestRoot } from './utils' /** * Dart SDK runtime dependency configuration @@ -78,6 +78,7 @@ async function setupDartDependencies(platformId: PlatformId): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('dockerfile')) { needsInstall = false } + if (needsInstall) { log.info('Installing Dockerfile Language Server') try { diff --git a/packages/lsp/src/server/elixir.ts b/packages/lsp/src/server/elixir.ts index 7184bd6..ab754e3 100644 --- a/packages/lsp/src/server/elixir.ts +++ b/packages/lsp/src/server/elixir.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getElixirLsResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'elixir-lsp') @@ -57,6 +57,8 @@ export const ElixirLsServer: LSPServerInfo = { return undefined } + if (autoInstallDisabled('elixir-ls')) { return undefined } + log.info('Downloading and building ElixirLS') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/eslint.ts b/packages/lsp/src/server/eslint.ts index 76e3957..a4787ec 100644 --- a/packages/lsp/src/server/eslint.ts +++ b/packages/lsp/src/server/eslint.ts @@ -11,7 +11,7 @@ import os from 'node:os' import path from 'node:path' import process from 'node:process' import { pipeline } from 'node:stream/promises' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' function getEslintResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'eslint-lsp') @@ -37,6 +37,8 @@ async function setupEslintDependencies(): Promise { } } + if (autoInstallDisabled('eslint')) { return undefined } + log.info('Downloading and building VS Code ESLint server...') try { diff --git a/packages/lsp/src/server/fsharp.ts b/packages/lsp/src/server/fsharp.ts index f0ee769..e779ed6 100644 --- a/packages/lsp/src/server/fsharp.ts +++ b/packages/lsp/src/server/fsharp.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' function getFsharpResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'fsharp-lsp') @@ -37,6 +37,8 @@ export const FsharpServer: LSPServerInfo = { return undefined } + if (autoInstallDisabled('fsharp')) { return undefined } + log.info('Installing fsautocomplete via dotnet tool') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/index.ts b/packages/lsp/src/server/index.ts index 27e4f67..3663c30 100644 --- a/packages/lsp/src/server/index.ts +++ b/packages/lsp/src/server/index.ts @@ -48,10 +48,13 @@ export type { LSPServerHandle, LSPServerInfo, PlatformId, RootFunction } from '. // Re-export utilities export { attachLSPProcessHandlers, + AUTO_INSTALL_ENV, + autoInstallDisabled, downloadAndExtract, downloadFile, extractZip, getPlatformId, + isAutoInstallEnabled, log, nearestRoot, } from './utils' diff --git a/packages/lsp/src/server/jdtls.ts b/packages/lsp/src/server/jdtls.ts index 71062cc..7ef1794 100644 --- a/packages/lsp/src/server/jdtls.ts +++ b/packages/lsp/src/server/jdtls.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, log, nearestRoot } from './utils' function getJdtlsResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'jdtls-lsp') @@ -56,6 +56,7 @@ export const JdtlsServer: LSPServerInfo = { await fs.access(launcherDir) } catch { + if (autoInstallDisabled('jdtls')) { return undefined } log.info('Downloading JDTLS from Eclipse') await fs.mkdir(distPath, { recursive: true }) diff --git a/packages/lsp/src/server/kotlin.ts b/packages/lsp/src/server/kotlin.ts index dfa3586..f47998e 100644 --- a/packages/lsp/src/server/kotlin.ts +++ b/packages/lsp/src/server/kotlin.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadAndExtract, getPlatformId, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadAndExtract, getPlatformId, log, nearestRoot } from './utils' /** * Kotlin Language Server runtime dependency configuration @@ -91,6 +91,7 @@ async function setupKotlinDependencies(platformId: PlatformId): Promise<{ } // Java not found, download it + if (autoInstallDisabled('kotlin')) { return undefined } log.info({ platformId }, 'Downloading Java 21') try { await downloadAndExtract(javaConfig.url, javaDir) @@ -141,6 +142,7 @@ async function setupKotlinDependencies(platformId: PlatformId): Promise<{ } // Kotlin LSP not found, download it + if (autoInstallDisabled('kotlin')) { return undefined } log.info('Downloading Kotlin Language Server') try { await downloadAndExtract(KOTLIN_RUNTIME_DEPS.kotlinLsp.url, resourcesDir) diff --git a/packages/lsp/src/server/lua.ts b/packages/lsp/src/server/lua.ts index c967855..9a5db33 100644 --- a/packages/lsp/src/server/lua.ts +++ b/packages/lsp/src/server/lua.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getLuaLsResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'lua-lsp') @@ -38,6 +38,7 @@ export const LuaLsServer: LSPServerInfo = { }) if (!bin) { + if (autoInstallDisabled('lua-ls')) { return undefined } log.info('Downloading lua-language-server from GitHub releases') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/php.ts b/packages/lsp/src/server/php.ts index e7674ea..b8e3282 100644 --- a/packages/lsp/src/server/php.ts +++ b/packages/lsp/src/server/php.ts @@ -8,7 +8,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' const PHP_RUNTIME_DEPS = { intelephense: { @@ -48,6 +48,8 @@ async function setupPhpDependencies(): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('php')) { needsInstall = false } + if (needsInstall) { log.info('Installing PHP Intelephense') try { diff --git a/packages/lsp/src/server/prisma.ts b/packages/lsp/src/server/prisma.ts index bbde95b..96d46a4 100644 --- a/packages/lsp/src/server/prisma.ts +++ b/packages/lsp/src/server/prisma.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' const PRISMA_RUNTIME_DEPS = { prismaLanguageServer: { @@ -51,6 +51,8 @@ async function setupPrismaDependencies(): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('prisma')) { needsInstall = false } + if (needsInstall) { log.info('Installing Prisma Language Server') diff --git a/packages/lsp/src/server/pyright.ts b/packages/lsp/src/server/pyright.ts index 03a0278..9d7129d 100644 --- a/packages/lsp/src/server/pyright.ts +++ b/packages/lsp/src/server/pyright.ts @@ -5,7 +5,7 @@ import type { LSPServerInfo } from './types' import { spawn } from 'node:child_process' import process from 'node:process' -import { attachLSPProcessHandlers, findPackageBin, log, nearestRoot, prepareSpawnCommand } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, findPackageBin, log, nearestRoot, prepareSpawnCommand } from './utils' export const PYRIGHT_VERSION = '1.1.414' @@ -30,6 +30,7 @@ export const PyrightServer: LSPServerInfo = { log.warn({ root }, 'pyright not found. Install with: npm install pyright') return undefined } + if (autoInstallDisabled('pyright')) { return undefined } const proc = spawn(bunx, ['-p', `pyright@${PYRIGHT_VERSION}`, 'pyright-langserver', '--stdio'], { cwd: root, }) diff --git a/packages/lsp/src/server/rubocop.ts b/packages/lsp/src/server/rubocop.ts index bd6b9a3..e2ac759 100644 --- a/packages/lsp/src/server/rubocop.ts +++ b/packages/lsp/src/server/rubocop.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' function getRubocopResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'rubocop-lsp') @@ -38,6 +38,8 @@ export const RubocopServer: LSPServerInfo = { return undefined } + if (autoInstallDisabled('rubocop')) { return undefined } + log.info('Installing Rubocop') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/svelte.ts b/packages/lsp/src/server/svelte.ts index 3c0dd4a..62357f7 100644 --- a/packages/lsp/src/server/svelte.ts +++ b/packages/lsp/src/server/svelte.ts @@ -8,7 +8,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' const SVELTE_RUNTIME_DEPS = { svelteLanguageServer: { @@ -48,6 +48,8 @@ async function setupSvelteDependencies(): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('svelte')) { needsInstall = false } + if (needsInstall) { log.info('Installing Svelte Language Server') try { diff --git a/packages/lsp/src/server/terraform.ts b/packages/lsp/src/server/terraform.ts index 5296a1d..258ab71 100644 --- a/packages/lsp/src/server/terraform.ts +++ b/packages/lsp/src/server/terraform.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getTerraformResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'terraform-lsp') @@ -30,6 +30,7 @@ export const TerraformServer: LSPServerInfo = { }) if (!bin) { + if (autoInstallDisabled('terraform')) { return undefined } log.info('Downloading terraform-ls from GitHub releases') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/texlab.ts b/packages/lsp/src/server/texlab.ts index f076171..9d9f5ed 100644 --- a/packages/lsp/src/server/texlab.ts +++ b/packages/lsp/src/server/texlab.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getTexlabResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'texlab-lsp') @@ -30,6 +30,7 @@ export const TexlabServer: LSPServerInfo = { }) if (!bin) { + if (autoInstallDisabled('texlab')) { return undefined } log.info('Downloading texlab from GitHub releases') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/src/server/typescript.ts b/packages/lsp/src/server/typescript.ts index 05b0917..e5e499e 100644 --- a/packages/lsp/src/server/typescript.ts +++ b/packages/lsp/src/server/typescript.ts @@ -14,7 +14,7 @@ import fs from 'node:fs' import { createRequire } from 'node:module' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, findPackageBin, findRunnableBin, log, nearestRoot, prepareSpawnCommand, resolvePackageBin, runsVersion } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, findPackageBin, findRunnableBin, log, nearestRoot, prepareSpawnCommand, resolvePackageBin, runsVersion } from './utils' const TS_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts'] @@ -261,6 +261,7 @@ export const TypescriptServer: LSPServerInfo = { log.warn({ root }, 'typescript-language-server not found. Install with: npm install typescript-language-server typescript') return undefined } + if (autoInstallDisabled('typescript')) { return undefined } const proc = spawn(bunx, [`typescript-language-server@${TS_LANGUAGE_SERVER_VERSION}`, '--stdio'], { cwd: root, env: { ...process.env, BUN_BE_BUN: '1' }, diff --git a/packages/lsp/src/server/utils.ts b/packages/lsp/src/server/utils.ts index edf8ee1..5d17f0e 100644 --- a/packages/lsp/src/server/utils.ts +++ b/packages/lsp/src/server/utils.ts @@ -22,6 +22,31 @@ export type { PlatformId } from '@pleaseai/binaries' export const log = createLogger('lsp') +/** Plugins set this from their `auto_install` option through the lspServers `env`. */ +export const AUTO_INSTALL_ENV = 'CODE_LSP_AUTO_INSTALL' + +/** + * Whether a server may download or install itself at spawn time. Only an explicit + * false, 0, no, or off (any case) turns it off, so an unset or unsubstituted value + * keeps the default. + */ +export function isAutoInstallEnabled(env: NodeJS.ProcessEnv = process.env): boolean { + const value = env[AUTO_INSTALL_ENV]?.trim().toLowerCase() + return !(value === 'false' || value === '0' || value === 'no' || value === 'off') +} + +/** Logs and returns true when auto-install is off, so the caller skips its download. */ +export function autoInstallDisabled(serverId: string): boolean { + if (isAutoInstallEnabled()) { + return false + } + log.warn( + { serverId, env: AUTO_INSTALL_ENV }, + 'Auto-install is off: not downloading the language server. Put it on PATH or turn auto_install back on.', + ) + return true +} + // ============================================================================= // Process Lifecycle Utilities // ============================================================================= diff --git a/packages/lsp/src/server/vue.ts b/packages/lsp/src/server/vue.ts index 3c74266..98f51d0 100644 --- a/packages/lsp/src/server/vue.ts +++ b/packages/lsp/src/server/vue.ts @@ -10,7 +10,7 @@ import os from 'node:os' import path from 'node:path' import process from 'node:process' import { TS_LANGUAGE_SERVER_VERSION } from './typescript' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' /** * Vue Language Server runtime dependency configuration @@ -86,6 +86,8 @@ async function setupVueDependencies(): Promise<{ needsInstall = true } + if (needsInstall && autoInstallDisabled('vue')) { needsInstall = false } + if (needsInstall) { log.info('Installing Vue Language Server dependencies') diff --git a/packages/lsp/src/server/yaml.ts b/packages/lsp/src/server/yaml.ts index 6c95f9a..5ad5e3e 100644 --- a/packages/lsp/src/server/yaml.ts +++ b/packages/lsp/src/server/yaml.ts @@ -8,7 +8,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, log, nearestRoot } from './utils' const YAML_RUNTIME_DEPS = { yamlLanguageServer: { @@ -48,6 +48,8 @@ async function setupYamlDependencies(): Promise { needsInstall = true } + if (needsInstall && autoInstallDisabled('yaml')) { needsInstall = false } + if (needsInstall) { log.info('Installing YAML Language Server') try { diff --git a/packages/lsp/src/server/zls.ts b/packages/lsp/src/server/zls.ts index ff691ed..424d958 100644 --- a/packages/lsp/src/server/zls.ts +++ b/packages/lsp/src/server/zls.ts @@ -9,7 +9,7 @@ import fs from 'node:fs/promises' import os from 'node:os' import path from 'node:path' import process from 'node:process' -import { attachLSPProcessHandlers, downloadFile, extractZip, log, nearestRoot } from './utils' +import { attachLSPProcessHandlers, autoInstallDisabled, downloadFile, extractZip, log, nearestRoot } from './utils' function getZlsResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'zls-lsp') @@ -37,6 +37,7 @@ export const ZlsServer: LSPServerInfo = { return undefined } + if (autoInstallDisabled('zls')) { return undefined } log.info('Downloading ZLS from GitHub releases') await fs.mkdir(resourcesDir, { recursive: true }) diff --git a/packages/lsp/test/unit/auto-install.test.ts b/packages/lsp/test/unit/auto-install.test.ts new file mode 100644 index 0000000..6b54e07 --- /dev/null +++ b/packages/lsp/test/unit/auto-install.test.ts @@ -0,0 +1,83 @@ +import fs from 'node:fs/promises' +import os from 'node:os' +import path from 'node:path' +import process from 'node:process' +import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test' +import { TerraformServer } from '../../src/server/terraform' +import { TexlabServer } from '../../src/server/texlab' +import { AUTO_INSTALL_ENV, isAutoInstallEnabled } from '../../src/server/utils' + +describe('isAutoInstallEnabled', () => { + test('defaults to enabled when unset, true, or an unsubstituted placeholder', () => { + expect(isAutoInstallEnabled({})).toBe(true) + expect(isAutoInstallEnabled({ [AUTO_INSTALL_ENV]: 'true' })).toBe(true) + // eslint-disable-next-line no-template-curly-in-string + expect(isAutoInstallEnabled({ [AUTO_INSTALL_ENV]: '${user_config.auto_install}' })).toBe(true) + }) + + test.each(['false', 'FALSE', ' off ', '0', 'no'])('is disabled for %j', (value) => { + expect(isAutoInstallEnabled({ [AUTO_INSTALL_ENV]: value })).toBe(false) + }) +}) + +describe('spawn with auto-install disabled', () => { + const saved = { + path: process.env.PATH, + flag: process.env[AUTO_INSTALL_ENV], + fetch: globalThis.fetch, + } + let tmp: string + let fetchCalls: string[] + let homedirSpy: ReturnType + + beforeEach(async () => { + tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'auto-install-')) + await fs.mkdir(path.join(tmp, 'emptybin')) + homedirSpy = spyOn(os, 'homedir').mockReturnValue(tmp) + process.env.PATH = path.join(tmp, 'emptybin') + process.env[AUTO_INSTALL_ENV] = 'false' + fetchCalls = [] + globalThis.fetch = (async (input: unknown) => { + fetchCalls.push(String(input)) + throw new Error('network access is not allowed in this test') + }) as unknown as typeof fetch + }) + + afterEach(async () => { + const restore = (key: string, value: string | undefined): void => { + if (value === undefined) { + delete process.env[key] + } + else { + process.env[key] = value + } + } + homedirSpy.mockRestore() + restore('PATH', saved.path) + restore(AUTO_INSTALL_ENV, saved.flag) + globalThis.fetch = saved.fetch + await fs.rm(tmp, { recursive: true, force: true }) + }) + + test.each([ + ['texlab', TexlabServer], + ['terraform', TerraformServer], + ])('%s returns undefined without downloading', async (_name, server) => { + expect(os.homedir()).toBe(tmp) + expect(await server.spawn(tmp)).toBeUndefined() + expect(fetchCalls).toEqual([]) + }) + + test.skipIf(process.platform === 'win32')('texlab still runs a binary already in the cache', async () => { + const cacheDir = path.join(tmp, '.cache', 'dora', 'texlab-lsp') + await fs.mkdir(cacheDir, { recursive: true }) + const bin = path.join(cacheDir, 'texlab') + await fs.writeFile(bin, '#!/bin/sh\nexit 0\n', { mode: 0o755 }) + + const handle = await TexlabServer.spawn(tmp) + + expect(handle).toBeDefined() + expect(fetchCalls).toEqual([]) + handle?.process.kill() + }) +}) From d355789c06f8fb8385c3cd16322860c78a6b53f9 Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:20:59 +0900 Subject: [PATCH 2/6] feat(plugins): pass auto_install to code lsp-server via lspServers env Set CODE_LSP_AUTO_INSTALL from user_config.auto_install in the lspServers entry of 13 plugins plus code-intelligence-lsp, update the option description, the unified .lsp.json generator, and the docs. --- ARCHITECTURE.md | 7 ++++++- README.md | 3 +++ packages/lsp/CLAUDE.md | 5 ++++- plugins/clangd-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/code-intelligence-lsp/.claude-plugin/plugin.json | 2 +- plugins/code-intelligence-lsp/.lsp.json | 5 ++++- plugins/csharp-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/dart-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/elixir-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/eslint-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/fsharp-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/jdtls-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/kotlin-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/lua-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/rubocop-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/terraform-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/texlab-lsp/.claude-plugin/plugin.json | 5 ++++- plugins/zls-lsp/.claude-plugin/plugin.json | 5 ++++- scripts/gen-unified-lsp-json.ts | 2 ++ 19 files changed, 72 insertions(+), 17 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index cf2d2e7..51dd1d6 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -206,7 +206,12 @@ directory, and rust-analyzer and ocaml-lsp install into the active rustup toolchain and opam switch. Every installing plugin declares a `userConfig.auto_install` boolean (default `true`); the hook reads it as `CLAUDE_PLUGIN_OPTION_AUTO_INSTALL` and -skips the install when it is off. +skips the install when it is off. Plugins that launch `code lsp-server` or +`code lsp-multiplex` also pass the option to the server process as +`CODE_LSP_AUTO_INSTALL` through the lspServers `env`, and +`autoInstallDisabled()` in `packages/lsp/src/server/utils.ts` then stops each +server's spawn-time download or install (GitHub releases, `npm install` into +`~/.cache/dora/`, `dotnet tool`, `gem`, versioned `bunx`). Example (`plugins/typescript-lsp/package.json`): ```json diff --git a/README.md b/README.md index 07833d9..5cb628f 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ Install only the language servers you need: > > Each installing plugin has an **Auto-install language server** option (`auto_install`, default > on). Turn it off in `/config` to stop session-start installs and updates for that plugin. +> For plugins that run through `code` (clangd, kotlin, dart, and the others that download a +> server the first time it starts), turning it off also stops those downloads, so the plugin +> uses only a server that is already installed or on `PATH`. ### Plugin management diff --git a/packages/lsp/CLAUDE.md b/packages/lsp/CLAUDE.md index f72fc55..ebccfac 100644 --- a/packages/lsp/CLAUDE.md +++ b/packages/lsp/CLAUDE.md @@ -90,7 +90,10 @@ export const MyServer: LSPServerInfo = { ## Auto-Download Pattern (Kotlin Example) -For servers requiring runtime dependencies: +For servers requiring runtime dependencies. Call `autoInstallDisabled('')` from +`./utils` right before any download or install, after the PATH and cache lookups: +it returns true when `CODE_LSP_AUTO_INSTALL` is false/0/no/off, which the plugins +set from their `auto_install` option. ```typescript const KOTLIN_RUNTIME_DEPS = { diff --git a/plugins/clangd-lsp/.claude-plugin/plugin.json b/plugins/clangd-lsp/.claude-plugin/plugin.json index 9f13033..f430f9a 100644 --- a/plugins/clangd-lsp/.claude-plugin/plugin.json +++ b/plugins/clangd-lsp/.claude-plugin/plugin.json @@ -36,6 +36,9 @@ ".hh": "cpp", ".hxx": "cpp", ".h++": "cpp" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -43,7 +46,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/code-intelligence-lsp/.claude-plugin/plugin.json b/plugins/code-intelligence-lsp/.claude-plugin/plugin.json index 3fe4b29..f449046 100644 --- a/plugins/code-intelligence-lsp/.claude-plugin/plugin.json +++ b/plugins/code-intelligence-lsp/.claude-plugin/plugin.json @@ -23,7 +23,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/code-intelligence-lsp/.lsp.json b/plugins/code-intelligence-lsp/.lsp.json index 55ea764..dbdd08f 100644 --- a/plugins/code-intelligence-lsp/.lsp.json +++ b/plugins/code-intelligence-lsp/.lsp.json @@ -72,6 +72,9 @@ ".zon": "zig", ".zsh": "shellscript" }, - "startupTimeout": 60000 + "startupTimeout": 60000, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" + } } } diff --git a/plugins/csharp-lsp/.claude-plugin/plugin.json b/plugins/csharp-lsp/.claude-plugin/plugin.json index e0811f6..1f57f47 100644 --- a/plugins/csharp-lsp/.claude-plugin/plugin.json +++ b/plugins/csharp-lsp/.claude-plugin/plugin.json @@ -27,6 +27,9 @@ ], "extensionToLanguage": { ".cs": "csharp" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -34,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/dart-lsp/.claude-plugin/plugin.json b/plugins/dart-lsp/.claude-plugin/plugin.json index 77bdb80..a2e96c5 100644 --- a/plugins/dart-lsp/.claude-plugin/plugin.json +++ b/plugins/dart-lsp/.claude-plugin/plugin.json @@ -27,6 +27,9 @@ ], "extensionToLanguage": { ".dart": "dart" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -34,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/elixir-lsp/.claude-plugin/plugin.json b/plugins/elixir-lsp/.claude-plugin/plugin.json index b954d7d..f6abd4c 100644 --- a/plugins/elixir-lsp/.claude-plugin/plugin.json +++ b/plugins/elixir-lsp/.claude-plugin/plugin.json @@ -28,6 +28,9 @@ "extensionToLanguage": { ".ex": "elixir", ".exs": "elixir" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -35,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/eslint-lsp/.claude-plugin/plugin.json b/plugins/eslint-lsp/.claude-plugin/plugin.json index 4f3cc20..4f69026 100644 --- a/plugins/eslint-lsp/.claude-plugin/plugin.json +++ b/plugins/eslint-lsp/.claude-plugin/plugin.json @@ -35,6 +35,9 @@ ".mts": "typescript", ".cts": "typescript", ".vue": "vue" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -42,7 +45,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/fsharp-lsp/.claude-plugin/plugin.json b/plugins/fsharp-lsp/.claude-plugin/plugin.json index 47b398c..b67caeb 100644 --- a/plugins/fsharp-lsp/.claude-plugin/plugin.json +++ b/plugins/fsharp-lsp/.claude-plugin/plugin.json @@ -30,6 +30,9 @@ ".fsi": "fsharp", ".fsx": "fsharp", ".fsscript": "fsharp" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -37,7 +40,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/jdtls-lsp/.claude-plugin/plugin.json b/plugins/jdtls-lsp/.claude-plugin/plugin.json index 41271ce..e053625 100644 --- a/plugins/jdtls-lsp/.claude-plugin/plugin.json +++ b/plugins/jdtls-lsp/.claude-plugin/plugin.json @@ -27,6 +27,9 @@ ], "extensionToLanguage": { ".java": "java" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -34,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/kotlin-lsp/.claude-plugin/plugin.json b/plugins/kotlin-lsp/.claude-plugin/plugin.json index d23fd3c..c311c55 100644 --- a/plugins/kotlin-lsp/.claude-plugin/plugin.json +++ b/plugins/kotlin-lsp/.claude-plugin/plugin.json @@ -28,6 +28,9 @@ "extensionToLanguage": { ".kt": "kotlin", ".kts": "kotlin" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -35,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/lua-lsp/.claude-plugin/plugin.json b/plugins/lua-lsp/.claude-plugin/plugin.json index fbc8931..6fb5bfe 100644 --- a/plugins/lua-lsp/.claude-plugin/plugin.json +++ b/plugins/lua-lsp/.claude-plugin/plugin.json @@ -27,6 +27,9 @@ ], "extensionToLanguage": { ".lua": "lua" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -34,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/rubocop-lsp/.claude-plugin/plugin.json b/plugins/rubocop-lsp/.claude-plugin/plugin.json index a859472..f476456 100644 --- a/plugins/rubocop-lsp/.claude-plugin/plugin.json +++ b/plugins/rubocop-lsp/.claude-plugin/plugin.json @@ -30,6 +30,9 @@ ".rake": "ruby", ".gemspec": "ruby", ".ru": "ruby" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -37,7 +40,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/terraform-lsp/.claude-plugin/plugin.json b/plugins/terraform-lsp/.claude-plugin/plugin.json index 95b50ed..84751d8 100644 --- a/plugins/terraform-lsp/.claude-plugin/plugin.json +++ b/plugins/terraform-lsp/.claude-plugin/plugin.json @@ -28,6 +28,9 @@ "extensionToLanguage": { ".tf": "terraform", ".tfvars": "terraform-vars" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -35,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/texlab-lsp/.claude-plugin/plugin.json b/plugins/texlab-lsp/.claude-plugin/plugin.json index edcdf77..f86c95a 100644 --- a/plugins/texlab-lsp/.claude-plugin/plugin.json +++ b/plugins/texlab-lsp/.claude-plugin/plugin.json @@ -28,6 +28,9 @@ "extensionToLanguage": { ".tex": "latex", ".bib": "bibtex" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -35,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/plugins/zls-lsp/.claude-plugin/plugin.json b/plugins/zls-lsp/.claude-plugin/plugin.json index 8eeccf1..f7dc398 100644 --- a/plugins/zls-lsp/.claude-plugin/plugin.json +++ b/plugins/zls-lsp/.claude-plugin/plugin.json @@ -28,6 +28,9 @@ "extensionToLanguage": { ".zig": "zig", ".zon": "zig" + }, + "env": { + "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" } } }, @@ -35,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server in the plugin data directory at session start. Turn off to skip it; the server then runs whatever is already installed there.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", "default": true } } diff --git a/scripts/gen-unified-lsp-json.ts b/scripts/gen-unified-lsp-json.ts index cce2e13..1275353 100644 --- a/scripts/gen-unified-lsp-json.ts +++ b/scripts/gen-unified-lsp-json.ts @@ -50,6 +50,8 @@ function main(): void { args: ['lsp-multiplex'], extensionToLanguage, startupTimeout: 60000, + // eslint-disable-next-line no-template-curly-in-string -- literal Claude Code plugin variable + env: { CODE_LSP_AUTO_INSTALL: '${user_config.auto_install}' }, }, } From 990dd6fbdfc153ce47d7e9e1b1212e64ea64a20d Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 09:42:42 +0900 Subject: [PATCH 3/6] chore: apply AI code review suggestions Find a previously downloaded LuaLS before the auto-install gate and extract new downloads into a staging dir. Reword the auto_install description: with it off, the plugin needs an install from an earlier session. --- packages/lsp/src/server/lua.ts | 34 +++++++++---------- packages/lsp/test/unit/auto-install.test.ts | 13 +++++++ plugins/clangd-lsp/.claude-plugin/plugin.json | 2 +- .../.claude-plugin/plugin.json | 2 +- plugins/csharp-lsp/.claude-plugin/plugin.json | 2 +- plugins/dart-lsp/.claude-plugin/plugin.json | 2 +- plugins/elixir-lsp/.claude-plugin/plugin.json | 2 +- plugins/eslint-lsp/.claude-plugin/plugin.json | 2 +- plugins/fsharp-lsp/.claude-plugin/plugin.json | 2 +- plugins/jdtls-lsp/.claude-plugin/plugin.json | 2 +- plugins/kotlin-lsp/.claude-plugin/plugin.json | 2 +- plugins/lua-lsp/.claude-plugin/plugin.json | 2 +- .../rubocop-lsp/.claude-plugin/plugin.json | 2 +- .../terraform-lsp/.claude-plugin/plugin.json | 2 +- plugins/texlab-lsp/.claude-plugin/plugin.json | 2 +- plugins/zls-lsp/.claude-plugin/plugin.json | 2 +- 16 files changed, 44 insertions(+), 31 deletions(-) diff --git a/packages/lsp/src/server/lua.ts b/packages/lsp/src/server/lua.ts index 9a5db33..86e67de 100644 --- a/packages/lsp/src/server/lua.ts +++ b/packages/lsp/src/server/lua.ts @@ -31,10 +31,11 @@ export const LuaLsServer: LSPServerInfo = { const isWindows = process.platform === 'win32' const ext = isWindows ? '.exe' : '' const resourcesDir = getLuaLsResourcesDir() + const installDir = path.join(resourcesDir, `lua-language-server-${process.arch}-${process.platform}`) - // Check PATH first + // Check PATH first, then a previous download let bin = Bun.which('lua-language-server', { - PATH: `${process.env.PATH}${path.delimiter}${resourcesDir}`, + PATH: [process.env.PATH, resourcesDir, path.join(installDir, 'bin')].filter(Boolean).join(path.delimiter), }) if (!bin) { @@ -69,25 +70,20 @@ export const LuaLsServer: LSPServerInfo = { return undefined } - const installDir = path.join(resourcesDir, `lua-language-server-${arch}-${platform}`) - - // Remove old installation - try { - await fs.rm(installDir, { force: true, recursive: true }) - } - catch { - // Directory doesn't exist - } - await fs.mkdir(installDir, { recursive: true }) + // Extract next to installDir and move it into place only once it is complete, + // so an interrupted download never leaves a binary the lookup above would reuse. + const stagingDir = `${installDir}.partial` + await fs.rm(stagingDir, { force: true, recursive: true }) + await fs.mkdir(stagingDir, { recursive: true }) const archivePath = path.join(resourcesDir, assetName) await downloadFile(asset.browser_download_url, archivePath) if (archiveExt === 'zip') { - await extractZip(archivePath, installDir) + await extractZip(archivePath, stagingDir) } else { - const tarProc = Bun.spawn(['tar', '-xzf', archivePath, '-C', installDir], { + const tarProc = Bun.spawn(['tar', '-xzf', archivePath, '-C', stagingDir], { stdout: 'pipe', stderr: 'pipe', }) @@ -102,15 +98,19 @@ export const LuaLsServer: LSPServerInfo = { await fs.rm(archivePath, { force: true }) - bin = path.join(installDir, 'bin', `lua-language-server${ext}`) + const stagedBin = path.join(stagingDir, 'bin', `lua-language-server${ext}`) try { - await fs.access(bin) + await fs.access(stagedBin) } catch { - log.error({ bin }, 'lua-language-server binary not found after extraction') + log.error({ bin: stagedBin }, 'lua-language-server binary not found after extraction') return undefined } + await fs.rm(installDir, { force: true, recursive: true }) + await fs.rename(stagingDir, installDir) + bin = path.join(installDir, 'bin', `lua-language-server${ext}`) + if (!isWindows) { await fs.chmod(bin, 0o755) } diff --git a/packages/lsp/test/unit/auto-install.test.ts b/packages/lsp/test/unit/auto-install.test.ts index 6b54e07..65d8155 100644 --- a/packages/lsp/test/unit/auto-install.test.ts +++ b/packages/lsp/test/unit/auto-install.test.ts @@ -3,6 +3,7 @@ import os from 'node:os' import path from 'node:path' import process from 'node:process' import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test' +import { LuaLsServer } from '../../src/server/lua' import { TerraformServer } from '../../src/server/terraform' import { TexlabServer } from '../../src/server/texlab' import { AUTO_INSTALL_ENV, isAutoInstallEnabled } from '../../src/server/utils' @@ -80,4 +81,16 @@ describe('spawn with auto-install disabled', () => { expect(fetchCalls).toEqual([]) handle?.process.kill() }) + + test.skipIf(process.platform === 'win32')('lua-ls still runs a binary from an earlier download', async () => { + const binDir = path.join(tmp, '.cache', 'dora', 'lua-lsp', `lua-language-server-${process.arch}-${process.platform}`, 'bin') + await fs.mkdir(binDir, { recursive: true }) + await fs.writeFile(path.join(binDir, 'lua-language-server'), '#!/bin/sh\nexit 0\n', { mode: 0o755 }) + + const handle = await LuaLsServer.spawn(tmp) + + expect(handle).toBeDefined() + expect(fetchCalls).toEqual([]) + handle?.process.kill() + }) }) diff --git a/plugins/clangd-lsp/.claude-plugin/plugin.json b/plugins/clangd-lsp/.claude-plugin/plugin.json index f430f9a..d003a09 100644 --- a/plugins/clangd-lsp/.claude-plugin/plugin.json +++ b/plugins/clangd-lsp/.claude-plugin/plugin.json @@ -46,7 +46,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/code-intelligence-lsp/.claude-plugin/plugin.json b/plugins/code-intelligence-lsp/.claude-plugin/plugin.json index f449046..0917a2b 100644 --- a/plugins/code-intelligence-lsp/.claude-plugin/plugin.json +++ b/plugins/code-intelligence-lsp/.claude-plugin/plugin.json @@ -23,7 +23,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/csharp-lsp/.claude-plugin/plugin.json b/plugins/csharp-lsp/.claude-plugin/plugin.json index 1f57f47..87057d1 100644 --- a/plugins/csharp-lsp/.claude-plugin/plugin.json +++ b/plugins/csharp-lsp/.claude-plugin/plugin.json @@ -37,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/dart-lsp/.claude-plugin/plugin.json b/plugins/dart-lsp/.claude-plugin/plugin.json index a2e96c5..f2c7394 100644 --- a/plugins/dart-lsp/.claude-plugin/plugin.json +++ b/plugins/dart-lsp/.claude-plugin/plugin.json @@ -37,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/elixir-lsp/.claude-plugin/plugin.json b/plugins/elixir-lsp/.claude-plugin/plugin.json index f6abd4c..688b3d3 100644 --- a/plugins/elixir-lsp/.claude-plugin/plugin.json +++ b/plugins/elixir-lsp/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/eslint-lsp/.claude-plugin/plugin.json b/plugins/eslint-lsp/.claude-plugin/plugin.json index 4f69026..cb3f530 100644 --- a/plugins/eslint-lsp/.claude-plugin/plugin.json +++ b/plugins/eslint-lsp/.claude-plugin/plugin.json @@ -45,7 +45,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/fsharp-lsp/.claude-plugin/plugin.json b/plugins/fsharp-lsp/.claude-plugin/plugin.json index b67caeb..85fb095 100644 --- a/plugins/fsharp-lsp/.claude-plugin/plugin.json +++ b/plugins/fsharp-lsp/.claude-plugin/plugin.json @@ -40,7 +40,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/jdtls-lsp/.claude-plugin/plugin.json b/plugins/jdtls-lsp/.claude-plugin/plugin.json index e053625..3419bdd 100644 --- a/plugins/jdtls-lsp/.claude-plugin/plugin.json +++ b/plugins/jdtls-lsp/.claude-plugin/plugin.json @@ -37,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/kotlin-lsp/.claude-plugin/plugin.json b/plugins/kotlin-lsp/.claude-plugin/plugin.json index c311c55..7f435ab 100644 --- a/plugins/kotlin-lsp/.claude-plugin/plugin.json +++ b/plugins/kotlin-lsp/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/lua-lsp/.claude-plugin/plugin.json b/plugins/lua-lsp/.claude-plugin/plugin.json index 6fb5bfe..55b9485 100644 --- a/plugins/lua-lsp/.claude-plugin/plugin.json +++ b/plugins/lua-lsp/.claude-plugin/plugin.json @@ -37,7 +37,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/rubocop-lsp/.claude-plugin/plugin.json b/plugins/rubocop-lsp/.claude-plugin/plugin.json index f476456..dae969b 100644 --- a/plugins/rubocop-lsp/.claude-plugin/plugin.json +++ b/plugins/rubocop-lsp/.claude-plugin/plugin.json @@ -40,7 +40,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/terraform-lsp/.claude-plugin/plugin.json b/plugins/terraform-lsp/.claude-plugin/plugin.json index 84751d8..79aa6f9 100644 --- a/plugins/terraform-lsp/.claude-plugin/plugin.json +++ b/plugins/terraform-lsp/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/texlab-lsp/.claude-plugin/plugin.json b/plugins/texlab-lsp/.claude-plugin/plugin.json index f86c95a..198ab62 100644 --- a/plugins/texlab-lsp/.claude-plugin/plugin.json +++ b/plugins/texlab-lsp/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } diff --git a/plugins/zls-lsp/.claude-plugin/plugin.json b/plugins/zls-lsp/.claude-plugin/plugin.json index f7dc398..e6a0f74 100644 --- a/plugins/zls-lsp/.claude-plugin/plugin.json +++ b/plugins/zls-lsp/.claude-plugin/plugin.json @@ -38,7 +38,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the server then runs only what is already installed or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", "default": true } } From 276fadf19947deedb345665ab220389f2101bdb1 Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:00:32 +0900 Subject: [PATCH 4/6] chore: apply AI code review suggestions Publish a LuaLS download without moving a working install aside, clean up each attempt's staging dir and archive, and say what eslint-lsp needs when auto_install is off. --- packages/lsp/src/server/lua.ts | 92 ++++++++++++------- plugins/eslint-lsp/.claude-plugin/plugin.json | 2 +- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/packages/lsp/src/server/lua.ts b/packages/lsp/src/server/lua.ts index 86e67de..9ce3b0a 100644 --- a/packages/lsp/src/server/lua.ts +++ b/packages/lsp/src/server/lua.ts @@ -15,6 +15,29 @@ function getLuaLsResourcesDir(): string { return path.join(os.homedir(), '.cache', 'dora', 'lua-lsp') } +/** + * Moves a complete staged install to `installDir`. A working install already there + * (another start published first) is kept; only a leftover without the binary is replaced. + */ +async function publishInstall(stagingDir: string, installDir: string, bin: string): Promise { + for (let attempt = 0; attempt < 2; attempt++) { + try { + await fs.rename(stagingDir, installDir) + return true + } + catch { + try { + await fs.access(bin) + return true + } + catch { + await fs.rm(installDir, { force: true, recursive: true }) + } + } + } + return false +} + export const LuaLsServer: LSPServerInfo = { id: 'lua-ls', extensions: ['.lua'], @@ -70,47 +93,50 @@ export const LuaLsServer: LSPServerInfo = { return undefined } - // Extract next to installDir and move it into place only once it is complete, - // so an interrupted download never leaves a binary the lookup above would reuse. - const stagingDir = `${installDir}.partial` - await fs.rm(stagingDir, { force: true, recursive: true }) - await fs.mkdir(stagingDir, { recursive: true }) + // Extract into a per-attempt staging dir and move it into place only once it is + // complete, so an interrupted download or a concurrent start never leaves a + // half-extracted install that the lookup above would reuse. + const stagingDir = await fs.mkdtemp(`${installDir}.partial-`) + const archivePath = `${stagingDir}-${assetName}` + bin = path.join(installDir, 'bin', `lua-language-server${ext}`) + try { + await downloadFile(asset.browser_download_url, archivePath) - const archivePath = path.join(resourcesDir, assetName) - await downloadFile(asset.browser_download_url, archivePath) + if (archiveExt === 'zip') { + await extractZip(archivePath, stagingDir) + } + else { + const tarProc = Bun.spawn(['tar', '-xzf', archivePath, '-C', stagingDir], { + stdout: 'pipe', + stderr: 'pipe', + }) + const tarExitCode = await tarProc.exited + if (tarExitCode !== 0) { + const stderr = await new Response(tarProc.stderr).text() + log.error({ tarExitCode, stderr }, 'Failed to extract lua-language-server archive') + return undefined + } + } - if (archiveExt === 'zip') { - await extractZip(archivePath, stagingDir) - } - else { - const tarProc = Bun.spawn(['tar', '-xzf', archivePath, '-C', stagingDir], { - stdout: 'pipe', - stderr: 'pipe', - }) - const tarExitCode = await tarProc.exited - if (tarExitCode !== 0) { - const stderr = await new Response(tarProc.stderr).text() - log.error({ tarExitCode, stderr }, 'Failed to extract lua-language-server archive') - await fs.rm(archivePath, { force: true }) + const stagedBin = path.join(stagingDir, 'bin', `lua-language-server${ext}`) + try { + await fs.access(stagedBin) + } + catch { + log.error({ bin: stagedBin }, 'lua-language-server binary not found after extraction') return undefined } - } - await fs.rm(archivePath, { force: true }) - - const stagedBin = path.join(stagingDir, 'bin', `lua-language-server${ext}`) - try { - await fs.access(stagedBin) + if (!await publishInstall(stagingDir, installDir, bin)) { + log.error({ bin }, 'lua-language-server install could not be moved into place') + return undefined + } } - catch { - log.error({ bin: stagedBin }, 'lua-language-server binary not found after extraction') - return undefined + finally { + await fs.rm(archivePath, { force: true }) + await fs.rm(stagingDir, { force: true, recursive: true }) } - await fs.rm(installDir, { force: true, recursive: true }) - await fs.rename(stagingDir, installDir) - bin = path.join(installDir, 'bin', `lua-language-server${ext}`) - if (!isWindows) { await fs.chmod(bin, 0o755) } diff --git a/plugins/eslint-lsp/.claude-plugin/plugin.json b/plugins/eslint-lsp/.claude-plugin/plugin.json index cb3f530..93a78ec 100644 --- a/plugins/eslint-lsp/.claude-plugin/plugin.json +++ b/plugins/eslint-lsp/.claude-plugin/plugin.json @@ -45,7 +45,7 @@ "auto_install": { "type": "boolean", "title": "Auto-install language server", - "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, and runs only a server that is already cached or on PATH.", + "description": "Install and update the language server at session start, and let it download its own binaries the first time it runs. Turn off to skip both; the plugin then needs an install from an earlier session, including the cached ESLint server, and eslint installed in the project.", "default": true } } From 05829021fdebf9c37a5e11f91231ca4314f090f8 Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:05:15 +0900 Subject: [PATCH 5/6] chore: apply AI code review suggestions Run both LuaLS download cleanups even if one fails, log failures, and cover the download path with a stubbed-network test. --- packages/lsp/src/server/lua.ts | 11 +++++-- packages/lsp/test/unit/auto-install.test.ts | 32 ++++++++++++++++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/lsp/src/server/lua.ts b/packages/lsp/src/server/lua.ts index 9ce3b0a..899642e 100644 --- a/packages/lsp/src/server/lua.ts +++ b/packages/lsp/src/server/lua.ts @@ -133,8 +133,15 @@ export const LuaLsServer: LSPServerInfo = { } } finally { - await fs.rm(archivePath, { force: true }) - await fs.rm(stagingDir, { force: true, recursive: true }) + const cleanup = await Promise.allSettled([ + fs.rm(archivePath, { force: true }), + fs.rm(stagingDir, { force: true, recursive: true }), + ]) + for (const result of cleanup) { + if (result.status === 'rejected') { + log.warn({ err: result.reason, archivePath, stagingDir }, 'Failed to clean up lua-language-server download files') + } + } } if (!isWindows) { diff --git a/packages/lsp/test/unit/auto-install.test.ts b/packages/lsp/test/unit/auto-install.test.ts index 65d8155..5dd9b0b 100644 --- a/packages/lsp/test/unit/auto-install.test.ts +++ b/packages/lsp/test/unit/auto-install.test.ts @@ -21,7 +21,7 @@ describe('isAutoInstallEnabled', () => { }) }) -describe('spawn with auto-install disabled', () => { +describe('spawn with a stubbed network (auto-install off unless a test turns it on)', () => { const saved = { path: process.env.PATH, flag: process.env[AUTO_INSTALL_ENV], @@ -93,4 +93,34 @@ describe('spawn with auto-install disabled', () => { expect(fetchCalls).toEqual([]) handle?.process.kill() }) + + test.skipIf(process.platform === 'win32')('lua-ls download replaces a broken leftover and cleans up staging', async () => { + process.env[AUTO_INSTALL_ENV] = 'true' + const resourcesDir = path.join(tmp, '.cache', 'dora', 'lua-lsp') + const installDir = path.join(resourcesDir, `lua-language-server-${process.arch}-${process.platform}`) + await fs.mkdir(path.join(installDir, 'script'), { recursive: true }) + + const src = path.join(tmp, 'archive-src') + await fs.mkdir(path.join(src, 'bin'), { recursive: true }) + await fs.writeFile(path.join(src, 'bin', 'lua-language-server'), '#!/bin/sh\nexit 0\n', { mode: 0o755 }) + const archive = path.join(tmp, 'lua.tar.gz') + expect(Bun.spawnSync(['tar', '-czf', archive, '-C', src, '.']).exitCode).toBe(0) + const assetName = `lua-language-server-9.9.9-${process.platform}-${process.arch}.tar.gz` + globalThis.fetch = (async (input: unknown) => { + const url = String(input) + fetchCalls.push(url) + if (url.includes('/releases/latest')) { + return Response.json({ tag_name: 'v9.9.9', assets: [{ name: assetName, browser_download_url: 'https://example.test/lua.tar.gz' }] }) + } + return new Response(await fs.readFile(archive)) + }) as unknown as typeof fetch + + const handle = await LuaLsServer.spawn(tmp) + + expect(handle).toBeDefined() + expect(fetchCalls).toHaveLength(2) + await fs.access(path.join(installDir, 'bin', 'lua-language-server')) + expect((await fs.readdir(resourcesDir)).filter(name => name.includes('.partial-'))).toEqual([]) + handle?.process.kill() + }) }) From d2754917ece7e9a99de756fb7269ea652bcf2df9 Mon Sep 17 00:00:00 2001 From: Minsu Lee <1964421+amondnet@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:09:52 +0900 Subject: [PATCH 6/6] chore: apply AI code review suggestions Return false from publishInstall when a broken LuaLS install cannot be removed, so spawn fails cleanly instead of throwing. --- packages/lsp/src/server/lua.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/lsp/src/server/lua.ts b/packages/lsp/src/server/lua.ts index 899642e..ccb1f1b 100644 --- a/packages/lsp/src/server/lua.ts +++ b/packages/lsp/src/server/lua.ts @@ -31,7 +31,13 @@ async function publishInstall(stagingDir: string, installDir: string, bin: strin return true } catch { - await fs.rm(installDir, { force: true, recursive: true }) + try { + await fs.rm(installDir, { force: true, recursive: true }) + } + catch (err) { + log.warn({ err, installDir }, 'Failed to remove a broken lua-language-server install') + return false + } } } }