Skip to content

[FEAT] S6: lsp_references tool — find all symbol references via LSP #32

Description

@four-bytes-robby

Background\nBuilding Wave S6 for @four-bytes/four-opencode-supertools. The LSP client library (src/lib/lsp-client.ts, src/lib/lsp-registry.ts) is in PR #29. This task builds the lsp_references tool.\n\n## Acceptance Criteria\n- [ ] Tool file: src/tools/lsp-references.ts\n- [ ] Registered in main plugin entry\n- [ ] Tests in tests/lsp-references.test.ts\n- [ ] All tests pass\n- [ ] PR created (do NOT merge)\n\n## Tool Definition\n- Name: lsp_references\n- Description: "Find all references to a symbol at a position via LSP. Saves ~90% tokens vs grep + manual tracing."\n- Permission: "read"\n- Parameters:\n - file_path (string, required) — absolute path to file\n - line (number, required) — 1-based line number\n - character (number, optional, default 1) — 1-based character offset\n - max_results (number, optional, default 50) — limit results\n\n## Output Shape\nts\ninterface LspReferencesOutput {\n available: boolean\n symbol?: string\n file: string\n position: { line: number; character: number }\n count: number\n references: { file: string; line: number; character: number }[]\n truncated: boolean\n hint?: string\n}\n\n\n## Implementation Notes\n- Import getLspRegistry from ../lib/lsp-registry.js\n- Resolve LSP server for file; if none: return { available: false, hint: "..." }\n- Convert line/character to 0-based for LSP\n- Read and open document via LSP\n- Call client.references(uri, line, character)\n- Truncate to max_results (default 50); set truncated: true if exceeded\n- Group references by file for compact output\n- Use relative paths where possible

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions