pi-lsp-lite

LSP diagnostics for pi — errors and warnings on every edit, same turn. Go, Rust, TypeScript, Python, C/C++.

Packages

Package details

extension

Install pi-lsp-lite from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-lsp-lite
Package
pi-lsp-lite
Version
0.4.0
Published
May 14, 2026
Downloads
1,108/mo · 57/wk
Author
mcphailtom
License
MIT
Types
extension
Size
54.1 KB
Dependencies
1 dependency · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-lsp-lite

CI npm License: MIT

Your agent can't see compiler errors. Now it can.

pi extension that runs language servers in the background and feeds diagnostics back inline after every edit. Errors appear on the same turn — no context switch, no separate command.

Go · Rust · TypeScript · Python · C/C++

Install

pi install npm:pi-lsp-lite

That's it. If you have gopls, rust-analyzer, typescript-language-server, pylsp, or clangd on PATH, diagnostics start flowing automatically.

What you see

  edit ─ src/main.go
  ✓ Edited src/main.go (replaced 2 lines)

  ⚠ LSP diagnostics for src/main.go (2 errors):
    error 12:5 [compiler] undefined: foo
    error 18:2 [compiler] too many arguments in call to bar
    + 1 diagnostic in 1 other file

The agent sees these too — they're appended to the tool result, so it can self-correct on the same turn.

Commands

Command What it does
/lsp-status Show running servers, PIDs, workspace roots, uptime
/lsp-diag Show all current diagnostics (or /lsp-diag path/to/file for one file)
/lsp-add Interactively add a new language server
/lsp-remove Disable a configured server
/lsp-toggle Flip a server on/off without removing config
/lsp-install Install a missing server binary

Supported servers

Server Language Install
gopls Go go install golang.org/x/tools/gopls@latest
rust-analyzer Rust rustup component add rust-analyzer
typescript-language-server TypeScript/JS npm install -g typescript-language-server typescript
pylsp Python pip install python-lsp-server
clangd C/C++ Xcode CLI tools / apt install clangd

Missing a server? /lsp-add lets you configure any LSP server that speaks stdio. Or add it to .pi-lsp-lite.json:

{
  "servers": {
    "haskell": {
      "extensions": [".hs"],
      "command": "haskell-language-server-wrapper",
      "args": ["--lsp"],
      "rootPatterns": ["cabal.project", "stack.yaml"]
    }
  }
}

Configuration

Works without config. For customisation, create .pi-lsp-lite.json (project) or ~/.pi-lsp-lite.json (global):

Field Description Default
servers.<id>.diagnosticTimeout Per-attempt timeout (ms) per-language
servers.<id>.maxRetries Retry attempts on timeout (0-10) 3
servers.<id>.disabled Disable this server false
diagnosticTimeout Global default timeout (ms) 5000
documentIdleTimeout Close idle documents after (ms) 120000

Project config merges over global. Partial overrides work — only specify what you want to change.

How it works

  1. Agent writes/edits a file
  2. Extension detects the language, finds the workspace root
  3. Spawns (or reuses) an LSP server for that language + root
  4. Sends didChange, waits for publishDiagnostics
  5. If timeout: retries with exponential backoff + jitter (up to maxRetries times)
  6. Filters to errors + warnings, formats, appends to tool result + shows in TUI

Cross-file impact is detected via snapshot-diff: if editing lib.ts breaks caller.ts, you see "+ N diagnostics in M other files".

Servers are lazy (spawn on first edit), idle-shutdown after 240s, and clean up on session end.

Development

git clone https://github.com/mcphailtom/pi-lsp-lite
cd pi-lsp-lite && npm install
npm run check              # typecheck
npm test                   # unit tests (106, no servers needed)
npm run test:integration   # real server tests (needs servers on PATH)

See docs/ARCHITECTURE.md and docs/CONTRIBUTING.md.

License

MIT