Skip to content

feat: expose VS Code language-analysis APIs as tools#11904

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/vscode-language-analysis-tools
Draft

feat: expose VS Code language-analysis APIs as tools#11904
roomote-v0[bot] wants to merge 1 commit intomainfrom
feature/vscode-language-analysis-tools

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 10, 2026

Related GitHub Issue

Closes: #11903

Description

This PR attempts to address Issue #11903 by adding 4 new read-only tools that wrap VS Code language server APIs, enabling the LLM to query definitions, references, and symbols directly from the editor.

New tools added (Phase 1):

  1. go_to_definition - Wraps vscode.executeDefinitionProvider(uri, position). Given a file path + line + character, returns the definition location(s).
  2. find_references - Wraps vscode.executeReferenceProvider(uri, position). Returns all reference locations (capped at 50 results).
  3. workspace_symbols - Wraps vscode.executeWorkspaceSymbolProvider(query). Searches for symbols across the workspace by name (capped at 100 results).
  4. document_symbols - Wraps vscode.executeDocumentSymbolProvider(uri). Lists all symbols in a specific file with their hierarchy preserved.

Implementation approach:

  • All tools are registered in the read tool group (read-only, no side effects)
  • Follows existing tool patterns exactly (BaseTool, NativeToolCallParser, native tool definitions)
  • Returns compact JSON to minimize token usage
  • Result limits prevent context overflow (50 for references, 100 for workspace symbols)
  • Graceful handling when no language server results are available

Files changed:

  • packages/types/src/tool.ts - Added 4 new tool names
  • packages/types/src/vscode-extension-host.ts - Added ClineSayTool entries
  • src/shared/tools.ts - Tool params, display names, NativeToolArgs, group registration
  • src/core/prompts/tools/native-tools/ - 4 new tool schema definitions + index registration
  • src/core/tools/ - 4 new tool implementations
  • src/core/assistant-message/presentAssistantMessage.ts - Tool dispatch wiring
  • src/core/assistant-message/NativeToolCallParser.ts - Partial and complete arg parsing

Test Procedure

  • 17 new unit tests across 4 test files covering:
    • Missing parameter validation
    • Successful results with Location and LocationLink formats
    • Empty results handling
    • Result truncation for large result sets
    • Approval denial flow
    • DocumentSymbol vs SymbolInformation format handling
  • Existing validateToolUse tests still pass (24/24)
  • All lint and type checks pass

Run tests with:

cd src && npx vitest run core/tools/__tests__/goToDefinitionTool.spec.ts core/tools/__tests__/findReferencesTool.spec.ts core/tools/__tests__/workspaceSymbolsTool.spec.ts core/tools/__tests__/documentSymbolsTool.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue
  • Scope: Changes are focused on the linked issue (adding language analysis tools)
  • Self-Review: Code follows existing patterns and conventions
  • Testing: 17 new unit tests added
  • Documentation Impact: User-facing docs may need updating to describe new tools
  • Contribution Guidelines: Read and agreed

Documentation Updates

  • Yes, documentation updates may be needed to describe the 4 new tools available to the LLM.

Additional Notes

Feedback and guidance are welcome. This implements Phase 1 (most commonly useful tools) from the issue. Phase 2 (call hierarchy) can be added in a follow-up PR.

Interactively review PR in Roo Code Cloud

…erences, workspace_symbols, document_symbols)

Adds 4 new read-only tools that wrap VS Code language server APIs:
- go_to_definition: wraps vscode.executeDefinitionProvider
- find_references: wraps vscode.executeReferenceProvider
- workspace_symbols: wraps vscode.executeWorkspaceSymbolProvider
- document_symbols: wraps vscode.executeDocumentSymbolProvider

These tools let the LLM query definitions, references, and symbols
directly from the editor language server for deeper codebase understanding.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Expose more powerful VS Code language-analysis APIs as tools for the Roo Code LLM

1 participant