Repository navigation
feat(lsp): gate runtime downloads behind auto_install via CODE_LSP_AUTO_INSTALL - #156
Conversation
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).
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.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request implements a mechanism to respect the auto_install user configuration by preventing spawn-time downloads and installations of language servers when disabled. It introduces the CODE_LSP_AUTO_INSTALL environment variable and helper functions in utils.ts to check this setting across all supported language servers, accompanied by comprehensive unit tests and plugin configuration updates. The review feedback suggests adding optional chaining to the env parameter in isAutoInstallEnabled to defensively guard against nullish values.
There was a problem hiding this comment.
All reported issues were addressed across 46 files
Architecture diagram
sequenceDiagram
participant User as Claude Code User
participant CC as Claude Code Core
participant Plugin as LSP Plugin
participant LSP as packages/lsp Server Runtime
participant Env as Environment
participant Downloader as Download/Install System
participant Cache as ~/.cache/dora
Note over User,CC: Configuration Flow
User->>CC: Configure auto_install (default true)
CC->>CC: Resolve user_config.auto_install
Note over CC,Plugin: Claude Code sets ${user_config.*} in LSP env
CC->>Plugin: Launch LSP server process
Plugin->>Plugin: Read LSP config with env
Plugin->>Env: Set CODE_LSP_AUTO_INSTALL=<resolved value>
Note over LSP,Downloader: Spawn-time Server Resolution
LSP->>LSP: Resolve server (PATH lookup)
alt Found on PATH
LSP->>LSP: Use binary directly
LSP-->>Plugin: Start server
else Not on PATH
LSP->>Cache: Check project-local/cache
alt Found in cache
LSP->>LSP: Use cached binary
LSP->>Cache: Verify version marker
alt Stale marker
LSP->>LSP: Log warning (cached binary still runs)
end
LSP-->>Plugin: Start server
else Not cached
LSP->>LSP: Call autoInstallDisabled(serverId)
LSP->>Env: Read CODE_LSP_AUTO_INSTALL
alt AUTO_INSTALL undefined/true/placeholder
LSP->>Downloader: Download/install server
Note over Downloader: GitHub releases, npm install,<br/>dotnet tool, gem, or bunx fallback
Downloader-->>LSP: Binary ready
LSP-->>Plugin: Start server
else AUTO_INSTALL = false|0|no|off
Note over LSP: Log warning: "Auto-install is off"
LSP-->>Plugin: Return undefined (no server)
Note over Plugin: Server not started
end
end
end
Note over LSP,Downloader: 26 gated sites across servers
Note over LSP: GitHub/Eclipse: clangd, dart, jdtls, lua, terraform<br/>texlab, zls, elixir, eslint, kotlin
Note over LSP: npm cache: astro, bash, dockerfile, php,<br/>prisma, svelte, vue, yaml
Note over LSP: dotnet/gem: csharp, fsharp, rubocop
Note over LSP: bunx fallback: biome, pyright, typescript
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryThis PR makes
Reviews (5) · Last reviewed commit: "chore: apply AI code review suggestions" · Reviewed by Greptile |
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.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to disable spawn-time downloading and installation of language servers when the CODE_LSP_AUTO_INSTALL environment variable is set to false, off, 0, or no. It integrates this check across all supported language servers, updates documentation, and adds comprehensive unit tests. Feedback on the changes suggests adding a defensive check for the potentially nullable env parameter in the utility function, and improving the robustness of the lua-ls staging directory replacement to ensure it is fully atomic.
There was a problem hiding this comment.
1 issue found across 16 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/eslint-lsp/.claude-plugin/plugin.json">
<violation number="1" location="plugins/eslint-lsp/.claude-plugin/plugin.json:48">
P3: The new description says the server runs only if it is "cached or on PATH", but ESLint actually needs a project-local `node_modules/.bin/eslint` and a cached vscode-eslint server. Name the project-local ESLint package in the description so users know what an earlier install must provide.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
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.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements a mechanism to disable spawn-time language server downloads and installs when the CODE_LSP_AUTO_INSTALL environment variable is set to false, off, no, or 0. This option is integrated across all supported language servers, documented, and covered by new unit tests. Additionally, the Lua language server installation process was refactored to use a staging directory to prevent concurrent or interrupted starts from leaving half-extracted installs. A review comment suggests using Promise.allSettled in the cleanup finally block of the Lua server to ensure both the archive file and the staging directory are reliably cleaned up even if one of the operations fails.
Run both LuaLS download cleanups even if one fails, log failures, and cover the download path with a stubbed-network test.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to prevent language servers from auto-installing or downloading dependencies at spawn time when CODE_LSP_AUTO_INSTALL is disabled. It integrates this check across all supported language servers, updates documentation and plugin configurations, and adds unit tests. Additionally, the Lua server installation is refactored to use a staging directory to avoid partial extractions. Feedback on the changes recommends wrapping the fs.rm cleanup call in the new publishInstall helper within a try/catch block to prevent unhandled exceptions from unexpectedly failing the spawn process.
Return false from publishInstall when a broken LuaLS install cannot be removed, so spawn fails cleanly instead of throwing.
|


Summary
Follow-up to #154, which added the
auto_installuserConfig and the SessionStart install gates.auto_installnow also stops the downloads thatpackages/lspmakes at spawn time, so turning it off means no runtime download of any kind.What changed
isAutoInstallEnabled()/autoInstallDisabled(serverId)inpackages/lsp/src/server/utils.ts. Onlyfalse,0,nooroff(any case, trimmed) disable. An unset or unsubstituted value keeps auto-install on.~/.cache/dora: astro, bash, dockerfile, php, prisma, svelte, vue, yaml.code lsp-server(clangd, csharp, dart, elixir, eslint, fsharp, jdtls, kotlin, lua, rubocop, terraform, texlab, zls) set"env": { "CODE_LSP_AUTO_INSTALL": "${user_config.auto_install}" }on theirlspServersentry. Claude Code substitutes${user_config.*}in LSPenv; LSP processes don't get theCLAUDE_PLUGIN_OPTION_*variables that hook processes do.code-intelligence-lsp(lsp-multiplex) gets the same env throughscripts/gen-unified-lsp-json.tsand the regenerated.lsp.json.Scope
Covers spawn-time downloads in
packages/lsp. It does not cover thecode lsp --stdindiagnostics hook path, which doesn't receive this env and so isn't gated.Blast radius
The default is unchanged: with the option unset or on, behavior is identical. For npm-cache servers, a cached binary with a stale version marker still runs; only the reinstall is skipped.
Verification
packages/lsp/test/unit/auto-install.test.tscovers the truth table, checks that texlab and terraform returnundefinedwithout callingfetchwhen the option is off, and checks that a cached texlab still spawns.claude plugin validatepasses on all 14 changed plugins.Known follow-ups
README.ko.mdis not updated.Related issue
No linked issue. Follows up #154.
Checklist
bun run test)bun run lint)README.ko.mdpending)BREAKING CHANGE:note is includedSummary by cubic
Makes
auto_installstop the spawn-time downloads thatpackages/lspmakes, so turning it off means no runtime download of any kind on top of the session-start gate from #154.packages/lspnow readsCODE_LSP_AUTO_INSTALLthrough newisAutoInstallEnabled()/autoInstallDisabled()helpers and gates 26 download sites (GitHub releases, npm into~/.cache/dora,dotnet tool,gem, versionedbunx) right after PATH and cache lookups. Plugins that launchcode lsp-serverorcode lsp-multiplexset the env fromuser_config.auto_installso Claude Code substitutes it like other${user_config.*}values. New tests cover the truth table, servers returningundefinedwithout fetching, cached binaries still spawning, and the lua-ls download path with a stubbed network.Behavior
auto_installoff now skips a server's first-run downloads too, not just the session-start install.false,0,no, oroff(any case, trimmed) disables; unset or an unsubstituted placeholder keeps installing.lua-lsfinds a previously downloaded binary before the gate and extracts new downloads into a staging directory it renames only on success, so an interrupted download never leaves a binary the lookup reuses. A broken leftover install is replaced; if it can't be removed, spawn fails cleanly. Cleanup removes both the archive and staging dir even if one removal fails, and logs failures.code lsp --stdindiagnostics hook path is not gated because it doesn't receive this env.Written for commit d275491. Summary will update on new commits.