Browse documentation

Technical documentation / Reference

LSP diagnostics

Feature docs index · Repository README

Overview

LSP diagnostics are an opt-in live feedback loop for coding sessions. After successful write or hash_edit, magi-code can sync the changed file to a language server, wait briefly for fresh diagnostics, and append a capped DIAGNOSTICS block to the same tool result.

This gives faster, immediate feedback on syntax, types, and compiler-style diagnostics after edits. It complements normal project checks; it does not replace cargo check, tests, linters, or repository-specific verification.

Enablement and settings

LSP is disabled by default. Enable it in non-secret settings.json only when the needed language servers are installed on PATH.

{
  "capabilities": { "lsp": {
    "enabled": true,
    "inject_diagnostics_on_edit": true,
    "diagnostics_wait_ms": 2000,
    "idle_shutdown_minutes": 10,
    "servers": {
      "rust-analyzer": { "command": "rust-analyzer", "args": [] },
      "typescript-language-server": { "command": "typescript-language-server", "args": ["--stdio"] }
    }
  }
} }

Fields:

FieldBehavior
enabledStarts LSP support for the session. Default false; disabled mode spawns no language servers and injects no diagnostics.
inject_diagnostics_on_editWhen true, successful write and hash_edit calls can append fresh diagnostics to tool output. Default true when LSP is enabled.
diagnostics_wait_msTotal edit-injection LSP budget, including cold spawn, initialize, sync, and diagnostic wait. Default 2000; max 30000.
idle_shutdown_minutesIdle server shutdown window. Default 10; max 240.
serversOptional command/args overrides for built-in server route keys. Values are direct process args, not shell-expanded.

Supported language defaults

Built-in routes:

FilesLanguage idServer keyDefault command
.rsrustrust-analyzerrust-analyzer
.ts, .tsxtypescripttypescript-language-servertypescript-language-server --stdio
.js, .jsxjavascripttypescript-language-servertypescript-language-server --stdio
.pypythonpyright-langserverpyright-langserver --stdio
.gogogoplsgopls

First release supports command/args overrides for these route keys. It does not add code actions, rename, formatting, hover, completion, semantic tokens, custom extension routing, or multi-root workspaces.

Edit injection behavior

Injection runs only after successful write or hash_edit file mutations. The changed file must be a UTF-8 text file inside the workspace root and match a supported route. Shell/external-editor changes are not watched.

When fresh diagnostics arrive before diagnostics_wait_ms, magi-code appends a redacted block shaped like:

DIAGNOSTICS (rust-analyzer, src/example.rs):
  ERROR [E0382] line 42: borrow of moved value: `value`
  WARNING [unused_imports] line 3: unused import: `std::fmt`
  (2 shown, 0 truncated)

Injected blocks show errors and warnings, omit information/hints, cap at 20 diagnostics, and cap appended text at about 2 KiB. No fresh diagnostics before the deadline means no block is appended; magi-code does not emit empty placeholders.

Limits and caps

SurfaceCap
Edit injection20 diagnostics and about 2 KiB appended text.
Edit waitdiagnostics_wait_ms, including spawn/init/sync/wait.
Server lifetimeAutonomous watchdog shutdown after idle_shutdown_minutes without accepted live-client use; planned idle shutdown/restart does not consume recovery budget.

Caps keep provider-visible tool output small and deterministic.

Degradation/failure behavior

LSP never changes edit success. Missing binaries, spawn failures, crashes, stale diagnostics, indexing delays, timeouts, unsupported file types, and disabled settings cause injection to be skipped.

Server lifecycle behavior:

Privacy/redaction boundaries

LSP output follows normal tool-output privacy rules:

Troubleshooting

Missing server:

Indexing delay:

Stale diagnostics:


Back to feature docs · Back to repository README

Edit this page on GitHub ↗