Skip to content

Commit eb1761e

Browse files
author
Yogthos
committed
LSP Phase 5: agent-facing lsp tool
src/agent/tools/lsp.rs (LspTool) - One tool, one `operation` parameter. Operations mirror opencode's surface so agents' mental model carries over: definition / references / hover / documentSymbol / workspaceSymbol / implementation / prepareCallHierarchy / incomingCalls / outgoingCalls - Accepts both camelCase (goToDefinition) and short (definition) aliases. - 1-based line/character (matches editor display); converts to 0-based before sending to the LSP wire. saturating_sub guards against agents passing 0. - Relative file_path resolved against the dirge worktree cwd. - Permission check via check_perm_path on the resolved absolute path. - touch_file(TouchMode::Notify) before each request so the file is in sync with the server. Notify (not AwaitPush) — diagnostics are the edit tool's concern in Phase 6. - Empty result reported as '(no results from <op>)' rather than '[]' so the agent doesn't have to special-case. 14 tool tests including regressions: - unknown operation returns clear error (regression — bad name shouldn't panic or produce a cryptic parse error) - position op without file_path errors (regression — would crash a manager.hover(None, ...) otherwise) - position op without line/character errors - workspaceSymbol requires file_path (regression — without one, no LSP attaches; silent empty result) - workspaceSymbol requires query - missing file on disk returns clean error - 1-based -> 0-based coordinate conversion (regression for off-by-one that would land the LSP cursor on the wrong identifier) - documentSymbol accepts no position (regression — needs_position must not include doc/workspace symbol) - successful hover returns pretty-printed JSON - empty array / null response reports '(no results)' - accepts opencode camelCase aliases - relative file_path resolves against cwd (regression) - line=0 / character=0 doesn't panic (saturating_sub guards) Builder.rs wiring (Option<Arc<LspManager>> threaded through, tool attached when manager is present) lands in Phase 7 with the rest of the CLI/config plumbing. Phase 5's tool symbols are #![allow(dead_code)] until then to keep the warning surface clean. Phase 4: 86, Phase 5: +14 -> 100 LSP tests. Suite: 391 -> 405.
1 parent 4c54633 commit eb1761e

2 files changed

Lines changed: 755 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)