Class: RubynCode::Tools::IdeSymbols
- Defined in:
- lib/rubyn_code/tools/ide_symbols.rb
Overview
Searches VS Code workspace symbols via the language server. Only available when running in IDE mode.
Constant Summary collapse
- TOOL_NAME =
'ide_symbols'- DESCRIPTION =
'Search workspace symbols (classes, methods, modules) via VS Code language server. Only available in IDE mode.'- PARAMETERS =
{ query: { type: 'string', description: 'Symbol search query (e.g. "User", "authenticate")', required: true } }.freeze
- RISK_LEVEL =
:read
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #execute(**params) ⇒ Object
-
#initialize(project_root:, ide_client: nil) ⇒ IdeSymbols
constructor
A new instance of IdeSymbols.
Methods inherited from Base
description, parameters, requires_confirmation?, risk_level, #safe_path, to_schema, tool_name, #truncate
Constructor Details
#initialize(project_root:, ide_client: nil) ⇒ IdeSymbols
Returns a new instance of IdeSymbols.
19 20 21 22 |
# File 'lib/rubyn_code/tools/ide_symbols.rb', line 19 def initialize(project_root:, ide_client: nil) super(project_root: project_root) @ide_client = ide_client end |
Class Method Details
.summarize(output, _args) ⇒ Object
47 48 49 50 |
# File 'lib/rubyn_code/tools/ide_symbols.rb', line 47 def self.summarize(output, _args) first_line = output.lines.first&.strip || '' first_line.start_with?('Found') ? first_line : '' end |
Instance Method Details
#execute(**params) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubyn_code/tools/ide_symbols.rb', line 24 def execute(**params) unless @ide_client return 'IDE symbols are only available when running inside VS Code.' end query = params[:query] || '' return 'Query is required.' if query.empty? result = @ide_client.request('ide/getWorkspaceSymbols', { query: query }, timeout: 10) symbols = result['symbols'] || [] return "No symbols found matching '#{query}'." if symbols.empty? lines = symbols.first(50).map do |s| container = s['containerName'] ? " (in #{s['containerName']})" : '' line_info = s['line'] ? ":#{s['line']}" : '' "#{s['kind']} #{s['name']}#{container} — #{s['file']}#{line_info}" end header = "Found #{symbols.size} symbol(s) matching '#{query}':" ([header] + lines).join("\n") end |