@yofriadi/pi-lsp
v1.16.11
Published
```bash pi install git:github.com/yofriadi/pi-extensions@lsp-v<version> ```
Readme
LSP Extension Scaffold
Install from git URL
pi install git:github.com/yofriadi/pi-extensions@lsp-v<version>To load only this extension from the monorepo package source, use package filtering in settings:
{
"packages": [
{
"source": "git:github.com/yofriadi/pi-extensions@lsp-v<version>",
"extensions": ["packages/lsp/src/index.ts"]
}
]
}Standalone package scaffold for pi LSP integration work.
Scope
This extension package now includes:
- Runtime lifecycle management for an LSP subprocess (Bun
spawnwhen available, Nodechild_process.spawnfallback) + JSON-RPC initialize/shutdown - PATH/Mason-first server resolution with lightweight user/project config
- Multi-server registry with file-type routing and workspace fallback selection
- Full
lsptool action surface (diagnostics,definition,references,hover,symbols,rename,status,reload) - Backward-compatible
lsp_healthstatus alias - Write-through hooks that run format-on-write and diagnostics-on-write for successful
write/editresults
The extension remains opt-in and does not alter default pi behavior unless loaded.
Lightweight Server Config
Server resolution order:
- User config:
~/.pi/agent/lsp.json|yaml|yml(fallback:~/.pi/lsp.json|yaml|yml) - Project config:
<cwd>/.pi/lsp.json|yaml|yml(overrides user config) - Mason bin directories before regular
PATH - Small built-in candidate list (no large bundled server catalog)
Supported config keys:
serverCommand: string or string array, e.g.["typescript-language-server", "--stdio"]server: command name/path with optionalargsserverCandidates: explicit command candidates in probe orderservers: named multi-server map/array entries withcommand/server+args, optionalfileTypes, anddisabled
When servers is present, the extension starts each resolved server and routes document-scoped requests by fileTypes (extension or filename). Workspace-scoped requests target the first ready server.
Package Layout
src/index.ts: extension entrypoint and runtime/tool/hook wiringsrc/client/runtime.ts: single LSP client lifecycle, JSON-RPC request surface, diagnostics cachesrc/client/registry.ts: multi-server runtime orchestration and per-path routingsrc/config/resolver.ts: server command/config resolution (single and multi-server)src/tools/lsp-tool.ts: fulllsptool schema/action routing +lsp_healthaliassrc/hooks/writethrough.ts: format-on-write and diagnostics-on-write hooks
Install and Load
Upstream pi
# Load for one run
pi -e ./packages/coding-agent/examples/extensions/lsp
# Install as local package source
pi install ./packages/coding-agent/examples/extensions/lspFork Workflow
Use whichever launcher your fork environment provides:
# Source-run from repo
bun packages/coding-agent/src/cli.ts -e ./packages/coding-agent/examples/extensions/lsp
# If your fork is installed as a separate binary (example name)
pib -e ./packages/coding-agent/examples/extensions/lspUsage
After loading the extension:
- Run
/lsp-statusto inspect runtime/config/transport state, including per-server routing/status details. - Use the
lsptool with action-based params:statusreloadhover/definition/references/rename(requirepath,line,character)symbols(usequeryfor workspace mode orpathfor document mode)diagnostics
- Successful
write/edittool results automatically trigger format+diagnostics hooks and show a summary notification.
Test Coverage
Focused extension tests:
packages/lsp/test/runtime.test.ts- lifecycle readiness and JSON-RPC id handling
packages/lsp/test/resolver.test.ts- multi-server config resolution and project-over-user override behavior
packages/lsp/test/registry.test.ts- per-file routing and workspace fallback selection
Run focused validation:
bunx vitest run packages/lsp/test/runtime.test.ts packages/lsp/test/resolver.test.ts packages/lsp/test/registry.test.ts