feat: add lsp_references tool for symbol references via LSP #32

Merged
FO
4mo ago
+1288-0

Closes #32


Summary by cubic

Adds the lsp_references tool to find symbol references via LSP and expose it in the supertools plugin. Ships a minimal LSP client and registry with default servers; fixes Content‑Length byte handling and path output; requires an installed language server. Meets #32.

  • New Features

    • lsp_references: finds references for a file and 1‑based position; returns relative paths and 1‑based positions; supports max_results with a truncation hint; clear hints when no server or file is missing.
    • LspClient: JSON‑RPC 2.0 over stdio with Content‑Length framing; initialize/hover/references, diagnostics cache, timeouts, and graceful shutdown.
    • LspRegistry: maps extensions to servers, checks install via which, spawns/reuses clients; defaults for typescript-language-server, gopls, pyright-langserver, rust-analyzer, intelephense.
    • Plugin registers lsp_references.
  • Bug Fixes

    • Tool returns ToolResult‑compatible JSON strings; removed invalid permission; fixed lsp-client.ts stdin/stdout casts; added missing globals in eslint.config.js.
    • Correct Content-Length uses byte length; reference paths now use node:path relative (prefixed with ./ when appropriate); tests parse JSON and clean up registry/processes and temp dirs.
    • Removed references to non‑existent lsp_hover and lsp_diagnostics; plugin also registers gh_bot_review.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added LSP-backed capabilities for hover, diagnostics, document symbols, and cross-file symbol references.
    • Introduced automatic language-server selection based on file extension and installation status.
    • Exposed a new LSP references tool with truncation and helpful “server not available” messaging.
  • Tests
    • Added end-to-end tests with mock LSP servers covering availability, missing files, default parameters, empty results, and truncation behavior.
  • Chores
    • Updated ESLint globals for additional runtime/browser-related built-ins.