feat: add symbols tool — file symbol tree with line numbers#546
Conversation
Add a new `symbols` command that lists all symbols (functions, structs, classes, constants, enums, traits, impl blocks, type aliases, etc.) in files as a table of contents with line numbers and nesting. Rust implementation uses tree-sitter AST parsing with a new `is_symbol_node()` trait method (broader than `is_acceptable_parent`) and recursive descent for nested symbols (methods inside impl/class). Full pipeline: CLI subcommand → Node.js wrapper → Vercel AI SDK tool → agent registration (schema, system prompt, predefined prompts). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Overview: Add Symbols Tool — File Symbol Tree with Line NumbersSummaryThis PR introduces a new Files Changed Analysis30 files changed with 1,355 additions and 148 deletions: Core Rust Implementation (5 files)
Language Trait Extensions (4 files)
Node.js SDK (8 files)
Documentation (9 files)
Tests (1 file)
Architecture & Impact AssessmentWhat This PR Accomplishes
Key Technical ChangesRust Core:
Node.js Integration:
Agent Registration:
Affected System Componentsgraph TD
A[CLI: probe symbols] --> B[src/extract/symbols.rs]
B --> C[Language Trait: is_symbol_node]
C --> D[Rust/TS/Go Overrides]
B --> E[Tree-sitter Parser Pool]
E --> F[SymbolNode Extraction]
F --> G[Text/JSON Formatter]
H[Node.js SDK] --> I[npm/src/symbols.js]
I --> J[Spawn: probe symbols --format json]
J --> A
K[Vercel AI SDK] --> L[npm/src/tools/vercel.js]
L --> M[symbolsTool Wrapper]
M --> I
N[ProbeAgent] --> O[toolImplementations.symbols]
O --> M
N --> P[_getToolSchemaAndDescription]
N --> Q[System Prompt Updates]
R[Protocols] --> S[MCP Server]
R --> T[ACP]
S --> U[symbols_code Tool]
T --> V[symbols Tool]
Scope Discovery & Context ExpansionImmediate Impact
Related Components
Testing Coverage
Documentation Completeness
Review Focus Areas
ReferencesCore Implementation:
Language Trait:
Node.js SDK:
Agent Integration:
Documentation:
Metadata
Powered by Visor from Probelabs Last updated: 2026-03-21T15:58:17.952Z | Triggered by: pr_updated | Commit: 4a7ec53 💡 TIP: You can chat with Visor using |
Security Issues (8)
Security Issues (8)
✅ Quality Check PassedNo quality issues found – changes LGTM. Powered by Visor from Probelabs Last updated: 2026-03-21T15:57:38.325Z | Triggered by: pr_updated | Commit: 4a7ec53 💡 TIP: You can chat with Visor using |
- Refactor processor.rs extract_all_symbols_from_file to delegate to symbols::extract_symbols, eliminating duplicate AST traversal logic - Fix Vercel tool to return full result array instead of only first element - Add escapeString for file paths in symbols.js matching extract.js pattern Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Extract depth limit to named constant MAX_SYMBOL_DEPTH with docs - Pre-allocate Vec capacity in collect_symbols and format_symbols_text - Simplify Vercel tool return: always result[0] (schema takes single file) - Return consistent JSON for empty results instead of plain string - Improve symbolsSchema description to mention hierarchical nesting - Include stdout preview in JSON parse error messages - Clarify processor.rs legacy wrapper documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
probe symbolsCLI command that lists all symbols (functions, structs, classes, constants, enums, traits, impl blocks, type aliases, macros) in files as a table of contents with line numbers and nestingis_symbol_node()trait method and recursive descent for nested symbols (methods inside impl/class blocks)--allow-testsflag, multi-file supportChanges
Rust (core engine):
src/language/language_trait.rs— newis_symbol_node()default trait method (broader thanis_acceptable_parent)src/language/rust.rs,typescript.rs,go.rs— language-specific overrides adding const/static/type/var nodessrc/extract/symbols.rs— new — core symbol tree extraction withSymbolNode/FileSymbolsstructs, recursive collection, text/JSON formatting, 11 unit testssrc/cli.rs,src/main.rs—Symbolssubcommand registration and dispatchNode.js (SDK + agent):
npm/src/symbols.js— new — Node.js wrapper spawningprobe symbols --format jsonnpm/src/tools/common.js—symbolsSchemaZod schemanpm/src/tools/vercel.js—symbolsToolVercel AI SDK wrappernpm/src/tools/index.js,npm/src/index.js,npm/src/agent/tools.js— export chainnpm/src/agent/probeTool.js—wrapToolWithEmitterintegrationnpm/src/agent/ProbeAgent.js— 4-point registration (toolImplementations, schema map, system prompt, valid tools)npm/src/agent/shared/prompts.js— updated code-explorer, code-searcher, engineer prompts with symbols guidancenpm/src/tools/system-message.js— added to Tool Referencenpm/index.d.ts— TypeScript declarationsDocumentation (everywhere
extractis documented):docs/probe-cli/symbols.md— new — full CLI documentationREADME.md,npm/README.md,docs/index.md— updateddocs/probe-agent/sdk/api-reference.md,tools-reference.md— SDK docsdocs/probe-agent/protocols/mcp.md,mcp-integration.md,mcp-server.md,acp.md— protocol docsTesting
probe symbols src/main.rs --format textand--format json