pi-diet-lsp

On-demand LSP code-intelligence tools for Pi without automatic diagnostics or context injection.

Packages

Package details

extension

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

$ pi install npm:pi-diet-lsp
Package
pi-diet-lsp
Version
0.1.5
Published
Jun 20, 2026
Downloads
637/mo · 326/wk
Author
probabilityengineer
License
MIT
Types
extension
Size
35.2 KB
Dependencies
0 dependencies · 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-diet-lsp

On-demand LSP code-intelligence tools for Pi without automatic diagnostics or context injection.

pi-diet-lsp gives Pi agents focused, model-visible Language Server Protocol tools for definitions, references, symbols, hover/type information, and diagnostics. It keeps the surface compact and explicit: no automatic diagnostics pipeline, no context injection, no read guard, no skills, and no session-start bootstrap. Agents call the tools when precise code intelligence is useful.

This is intentionally different from automatic LSP feedback extensions: pi-diet-lsp favors low prompt overhead and explicit tool calls over continuously appending diagnostics to every edit.

Tools

  • lsp_definition — jump to definition at a 1-based file position
  • lsp_references — find references at a 1-based file position
  • lsp_symbols — document symbols for a file, or workspace symbols by query
  • lsp_hover — show hover/type info at a 1-based file position
  • lsp_diagnostics — open a file in LSP and return current diagnostics

lsp_symbols has two modes:

{ "filePath": "src/index.ts", "query": "optional-filter" }
{ "query": "SymbolName" }

With filePath, it returns document symbols. Without filePath, it uses LSP workspace symbol search.

Large symbol/reference results are compacted and capped to avoid runaway context growth.

Install

From npm, after publication:

pi install npm:pi-diet-lsp

From GitHub:

pi install git:github.com/ProbabilityEngineer/pi-diet-lsp

For project-local install, add -l:

pi install -l git:github.com/ProbabilityEngineer/pi-diet-lsp

For local testing:

pi -e ./index.ts

Runtime requirements

LSP tools resolve language servers from PATH using broader built-in defaults and first-available selection when multiple servers are supported.

Current built-in mappings include:

  • TypeScript/JavaScript: typescript-language-server --stdio
  • Vue: vue-language-server --stdio
  • Python: basedpyright-langserver --stdio, fallback pyright-langserver --stdio
  • Go: gopls
  • Rust: rust-analyzer
  • Swift: sourcekit-lsp
  • C/C++: clangd
  • C#: csharp-ls, fallback omnisharp --languageserver
  • Java: jdtls
  • Kotlin: kotlin-language-server
  • PHP: intelephense --stdio, fallback phpactor language-server
  • Ruby: ruby-lsp, fallback solargraph stdio
  • Lua: lua-language-server
  • Nix: nixd, fallback nil
  • HTML: vscode-html-language-server --stdio
  • CSS/SCSS/Less: vscode-css-language-server --stdio
  • JSON: vscode-json-language-server --stdio
  • YAML: yaml-language-server --stdio

Configuration overrides

You can override or add language mappings with:

~/.pi/agent/pi-diet-lsp/config.json

Example:

{
  "languages": {
    "lua_override": {
      "languageId": "lua",
      "extensions": [".lua"],
      "servers": [
        { "command": "custom-lua-lsp", "args": ["--stdio"] }
      ]
    }
  }
}

Configured languages are checked before built-in defaults.

You can also provide per-server environment variables, which is especially useful for OmniSharp:

{
  "languages": {
    "csharp_override": {
      "languageId": "csharp",
      "extensions": [".cs"],
      "servers": [
        {
          "command": "omnisharp",
          "args": ["--languageserver"],
          "env": {
            "DOTNET_ROOT": "/Users/you/.dotnet"
          }
        }
      ]
    }
  }
}

C# notes and troubleshooting

  • pi-diet-lsp prefers csharp-ls first, then falls back to omnisharp.
  • The selected executable must be runnable from PATH in a non-interactive shell.
  • For OmniSharp, pi-diet-lsp now auto-uses ~/.dotnet as DOTNET_ROOT when present. If your setup differs, set env.DOTNET_ROOT in config.
  • Legacy .NET Framework projects may still load with partial diagnostics on macOS/Linux if reference assemblies/targeting packs are unavailable.
  • If a server fails to launch, tool errors now include launch details and stderr instead of only reporting an initialize timeout.

Validation

npm run lint
npm run test:resolution

Prompt overhead

pi-diet-lsp avoids automatic context injection. It registers compact tools and guidance, then waits for agents to call LSP tools explicitly when code intelligence is relevant.