Skip to content

feat(lsp): gate runtime downloads behind auto_install via CODE_LSP_AUTO_INSTALL - #156

Merged
amondnet merged 6 commits into
mainfrom
amondnet/lsp-auto-install-gate
Nov 23, 2026
Merged

amondnet merged 6 commits into
mainfrom
amondnet/lsp-auto-install-gate

Conversation

@amondnet

@amondnet amondnet commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #154, which added the auto_install userConfig and the SessionStart install gates. auto_install now also stops the downloads that packages/lsp makes at spawn time, so turning it off means no runtime download of any kind.

What changed

  • isAutoInstallEnabled() / autoInstallDisabled(serverId) in packages/lsp/src/server/utils.ts. Only false, 0, no or off (any case, trimmed) disable. An unset or unsubstituted value keeps auto-install on.
  • The gate sits after the PATH, project-local and cache lookups, at 26 sites:
    • GitHub/Eclipse downloads: clangd, dart, jdtls, lua, terraform, texlab, zls, elixir, eslint, kotlin (the Java and kotlin-lsp downloads).
    • npm into ~/.cache/dora: astro, bash, dockerfile, php, prisma, svelte, vue, yaml.
    • dotnet tool: csharp, fsharp. gem: rubocop.
    • Versioned bunx fallback: biome, pyright, typescript.
  • 13 plugins that launch 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 their lspServers entry. Claude Code substitutes ${user_config.*} in LSP env; LSP processes don't get the CLAUDE_PLUGIN_OPTION_* variables that hook processes do.
  • code-intelligence-lsp (lsp-multiplex) gets the same env through scripts/gen-unified-lsp-json.ts and the regenerated .lsp.json.

Scope

Covers spawn-time downloads in packages/lsp. It does not cover the code lsp --stdin diagnostics 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

  • New packages/lsp/test/unit/auto-install.test.ts covers the truth table, checks that texlab and terraform return undefined without calling fetch when the option is off, and checks that a cached texlab still spawns.
  • lsp unit suite passes 191/191; root typecheck passes; ESLint is clean.
  • claude plugin validate passes on all 14 changed plugins.

Known follow-ups

  • The stale-marker case logs the warning even though the cached binary runs.
  • README.ko.md is not updated.

Related issue

No linked issue. Follows up #154.

Checklist

  • PR title follows Conventional Commits
  • Tests added or updated, and the suite passes (bun run test)
  • Lint/format pass (bun run lint)
  • Documentation updated if behavior changed (README.ko.md pending)
  • No breaking change, or a BREAKING CHANGE: note is included

Summary by cubic

Makes auto_install stop the spawn-time downloads that packages/lsp makes, so turning it off means no runtime download of any kind on top of the session-start gate from #154.

packages/lsp now reads CODE_LSP_AUTO_INSTALL through new isAutoInstallEnabled()/autoInstallDisabled() helpers and gates 26 download sites (GitHub releases, npm into ~/.cache/dora, dotnet tool, gem, versioned bunx) right after PATH and cache lookups. Plugins that launch code lsp-server or code lsp-multiplex set the env from user_config.auto_install so Claude Code substitutes it like other ${user_config.*} values. New tests cover the truth table, servers returning undefined without fetching, cached binaries still spawning, and the lua-ls download path with a stubbed network.

Behavior

  • Turning auto_install off now skips a server's first-run downloads too, not just the session-start install.
  • Default behavior is unchanged: only false, 0, no, or off (any case, trimmed) disables; unset or an unsubstituted placeholder keeps installing.
  • A cached binary still runs; only a download or reinstall is skipped.
  • lua-ls finds 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.
  • The code lsp --stdin diagnostics hook path is not gated because it doesn't receive this env.

Written for commit d275491. Summary will update on new commits.

Turn on auto-fix

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

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/lsp/src/server/utils.ts Resolved
@amondnet
amondnet marked this pull request as ready for review November 23, 2026 00:35

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Loading

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread packages/lsp/src/server/lua.ts Resolved
Comment thread packages/lsp/src/server/yaml.ts Resolved
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

This PR makes auto_install control downloads when language servers start.

  • Language server plugins can turn off downloads that happen when their servers start.
  • Lua servers reuse cached downloads and publish new installs only when complete.

Reviews (5) · Last reviewed commit: "chore: apply AI code review suggestions" · Reviewed by Greptile

Comment thread packages/lsp/src/server/lua.ts Resolved
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.
@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

Comment thread packages/lsp/src/server/lua.ts Resolved

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/lsp/src/server/utils.ts Resolved
Comment thread packages/lsp/src/server/lua.ts Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread packages/lsp/src/server/lua.ts Resolved
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.
@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/lsp/src/server/lua.ts Resolved
Run both LuaLS download cleanups even if one fails, log failures, and
cover the download path with a stubbed-network test.
@amondnet

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/lsp/src/server/lua.ts Resolved
Return false from publishInstall when a broken LuaLS install cannot be
removed, so spawn fails cleanly instead of throwing.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@amondnet
amondnet merged commit 9fd2064 into main Nov 23, 2026
9 of 10 checks passed
@amondnet
amondnet deleted the amondnet/lsp-auto-install-gate branch November 23, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant