magi-code 0.97.4

Repository-aware CLI coding agent for terminal work
Documentation
# LSP diagnostics

After a successful `write` or `hash_edit`, magi-code can send the changed file to a language server and append fresh diagnostics to the tool result. This is optional and disabled by default.

Language-server feedback helps catch syntax and type errors. It does not replace the project's build, lint, or other checks.

## Enable diagnostics

Install the language server and make its command available on `PATH`. Then configure `settings.json`:

```json
{
  "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"]
        }
      }
    }
  }
}
```

| Setting | Default | Behavior |
| --- | --- | --- |
| `enabled` | `false` | Allow language servers to start. |
| `inject_diagnostics_on_edit` | `true` | Append fresh diagnostics after supported file edits when LSP is enabled. |
| `diagnostics_wait_ms` | `2000` | Total time for startup, initialization, file synchronization, and diagnostics. Maximum: `30000`. |
| `idle_shutdown_minutes` | `10` | Stop unused servers after this interval. Maximum: `240`. |
| `servers` | Built-in commands | Override a supported server's command and arguments. Arguments are not shell-expanded. |

## Supported languages

| Files | Language ID | Server key | Default command |
| --- | --- | --- | --- |
| `.rs` | `rust` | `rust-analyzer` | `rust-analyzer` |
| `.ts`, `.tsx` | `typescript` | `typescript-language-server` | `typescript-language-server --stdio` |
| `.js`, `.jsx` | `javascript` | `typescript-language-server` | `typescript-language-server --stdio` |
| `.py` | `python` | `pyright-langserver` | `pyright-langserver --stdio` |
| `.go` | `go` | `gopls` | `gopls` |

Overrides change these commands, not extension routing. Code actions, rename, formatting, hover, completion, semantic tokens, and multi-root workspaces are not supported.

## Feedback after edits

Only successful `write` and `hash_edit` mutations trigger diagnostics. The file must be UTF-8 text inside the workspace and match a supported language. Shell and external-editor changes are not watched.

Fresh errors and warnings appear in a block such as:

```text
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)
```

Each block contains at most 20 diagnostics and about 2 KiB of text. Information and hints are omitted. If fresh diagnostics do not arrive before the deadline, no block appears.

## Failures and privacy

LSP never changes whether an edit succeeds. Missing binaries, crashes, indexing delays, stale results, unsupported files, and timeouts skip diagnostics.

Servers start on the first matching edit, stay available during use, and stop after the idle interval. Unexpected failures allow two recovery attempts; a third disables that server for the session. Planned idle restarts do not count as failures.

Diagnostics are redacted before reaching the provider or session history. Raw server stdout and stderr are not exposed. Language servers receive a filtered environment without provider keys or token-shaped variables. Keep credentials out of server arguments.

## Troubleshooting

- No server starts: check `capabilities.lsp.enabled`, installation, and `PATH`.
- No feedback during indexing: allow the server to finish, or increase `diagnostics_wait_ms` if slower edits are acceptable.
- Stale feedback: diagnostics must match the synchronized file version when the server supplies versions. Run project checks for a current result.

See [Configuration](configuration.md), [Tools and safety](tools-and-safety.md), and [Integrations](../user/integrations.md).