@spences10/pi-lsp

Language Server Protocol tools for Pi agents to inspect diagnostics, hovers, definitions, references, and symbols

Packages

Package details

extension

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

$ pi install npm:@spences10/pi-lsp
Package
@spences10/pi-lsp
Version
0.0.35
Published
Jun 17, 2026
Downloads
2,289/mo · 276/wk
Author
spences10
License
MIT
Types
extension
Size
153.8 KB
Dependencies
3 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./dist/index.js"
  ],
  "image": "https://raw.githubusercontent.com/spences10/my-pi/main/assets/pi-package-preview.png"
}

Security note

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

README

@spences10/pi-lsp

built with Vite+ tested with Vitest npm version license

my-pi package preview

Give agents precise code intelligence instead of guesswork. pi-lsp exposes language-server diagnostics, hovers, definitions, references, and symbols as Pi tools so models can validate edits and navigate typed codebases accurately.

Installation

pi install npm:@spences10/pi-lsp

Local development from this monorepo:

pnpm --filter @spences10/pi-lsp run build
pi install ./packages/pi-lsp
# or for one run only
pi -e ./packages/pi-lsp

Required language servers

This package talks to language-server binaries installed in your project or on PATH. For TypeScript, JavaScript, and Svelte projects:

pnpm add -D typescript typescript-language-server svelte-language-server

Supported server discovery includes:

  • TypeScript / JavaScript via typescript-language-server
  • Svelte via svelteserver
  • Python via python-lsp-server
  • Go via gopls
  • Rust via rust-analyzer
  • Ruby via solargraph
  • Java via jdtls
  • Lua via lua-language-server

Project-local binaries in node_modules/.bin are detected before global binaries, but are untrusted by default because they can execute repo-controlled code. Interactive sessions prompt before starting a project-local binary; headless sessions fall back to the global PATH binary unless MY_PI_LSP_PROJECT_BINARY=allow or MY_PI_LSP_PROJECT_BINARY=trust is set. /lsp status shows the resolved binary path for running and idle servers.

Language servers receive a restricted child-process environment by default. Use MY_PI_LSP_ENV_ALLOWLIST=NAME,OTHER_NAME or the shared MY_PI_CHILD_ENV_ALLOWLIST to pass selected ambient variables through.

Tools

The extension registers LSP-backed Pi tools for:

  • diagnostics
  • hover
  • definitions
  • references
  • document symbols

These tools let the model inspect types, find usages, and catch diagnostics without guessing from text search alone.

Model reminder

When LSP tools are active, the extension injects a small system prompt reminder telling the model to use LSP for focused diagnostics, type and symbol questions, definitions, references, and validation before reporting completion. It also reminds the model to run diagnostics on changed language-server-supported files before completion or commit, preferring lsp_diagnostics_many for batches.

Commands

/lsp status
/lsp list
/lsp restart all
/lsp restart <language>

Use /lsp status to inspect active clients and /lsp restart after dependency installs or language-server crashes.

Using from a custom harness

import lsp from '@spences10/pi-lsp';

// pass `lsp` as an ExtensionFactory to your Pi runtime

For harnesses that need to provide their own language-server client factory, use the named extension factory:

import { create_lsp_extension } from '@spences10/pi-lsp';

const lsp = create_lsp_extension({ create_client });

The package also exports CreateLspExtensionOptions, should_inject_lsp_prompt, and LspClientLike for custom harnesses and tests that need to share the same prompt-gating or client seam.

my-pi imports this package directly and enables it as the built-in LSP extension.

Development

Package scripts build transitive workspace dependencies first, then run local tools through Vite+ with vp exec.

pnpm --filter @spences10/pi-lsp run check
pnpm --filter @spences10/pi-lsp run test
pnpm --filter @spences10/pi-lsp run build

License

MIT