feat(agent): add lsp diagnostics and semantic rename tools - #345
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Agent needs structured language-server results to inspect errors and rename symbols across files while preserving unsaved work. This adds access to Red's existing language servers without opening editor dialogs or moving focus.
lsp_statusandlsp_diagnosticsfor server capabilities and filtered, paginated diagnostics from a file, open buffers, or known workspace reports. Collection continues when diagnostic display is disabled; responses distinguish provisional, stale, unversioned, and absent reports instead of claiming the project is clean.lsp_prepare_rename,lsp_preview_rename, andlsp_apply_edit. Previews return a bounded diff and an expiring plan tied to the active turn and server. Applying rechecks buffer revisions, unopened-file snapshots, and workspace access policy, then changes buffers with Agent attribution and one undo transaction per file. It never saves files.Start a new Agent conversation after upgrading; resumed conversations retain their previous tool list. General symbol queries, code actions, and formatting tools remain follow-up work. The tool contracts and limits are documented in docs/AGENT_WORKFLOW.md.
How to Test
cargo test --all-features --test lsp_lazy agent_lsp_. The new tests cover cross-file rename with unsaved text, Unicode positions, diagnostic filtering and pagination, push-only servers, and rejected edits. In particular,agent_lsp_preview_rejects_changed_buffers_and_restarted_serversmust reject both stale-buffer and server-restart cases without changing text;agent_lsp_queries_allow_typing_and_reject_late_resultschecks responsiveness and late responses.cargo build --bin red. With an authenticated Codex app-server and a configuredrust-analyzerortypescript-language-server, open a disposable project containingAccount.idreferences in two files, an unrelatedOther.idfield, and an intentional type error. Start a fresh conversation with:AgentNew, then open the composer with:Agent.Account.idreferences to change, both buffers to remain unsaved, and disk contents to remain unchanged. The Agent should state the diagnostic freshness limits and that the edits are unsaved.Validated at
9a3a803d: Clippy with all targets/features and warnings denied, formatting, and live Rust and TypeScript Agent workflows passed. Both live runs preservedOther.idand disk contents; manual per-file undo also passed.The remaining suite passed with 3,532 tests passed, 2 ignored, and 1 excluded using:
RUST_TEST_THREADS=2 cargo test --all-targets --all-features -- --skip dot_repeats_linewise_paste_and_visual_block_insertThe unfiltered suite aborts in
editing::dot_repeats_linewise_paste_and_visual_block_insert, which uses a 2 MiB thread stack. The same crash reproduced on untouchedmainat5862875eusing a fresh, separate target directory. This PR does not change that guard.