tree-sitter AST-based Signature Extraction
LeanCTX now uses tree-sitter for signature extraction instead of regex. This is a major accuracy improvement:
New
- tree-sitter AST parsing for signatures and map mode (enabled by default)
- 10 languages supported: TypeScript, JavaScript, Rust, Python, Go, Java, C, C++, Ruby
- Multi-line signatures are now correctly parsed
- Arrow functions (
const fn = () => {}) are detected - Nested class/method scoping via AST
- Optional Cargo feature flag — build without tree-sitter:
cargo install lean-ctx --no-default-features
Comparison: Regex vs tree-sitter
| Capability | Regex (old) | tree-sitter (new) |
|---|---|---|
| Multi-line signatures | Missed | Fully parsed |
| Arrow functions | Missed | Fully parsed |
| Nested classes/methods | Heuristic | AST scope tracking |
| Languages | 4 | 10 |
Binary Size
- With tree-sitter (default): ~17 MB
- Without tree-sitter: ~5.7 MB
Install
brew tap yvgude/lean-ctx && brew install lean-ctx
# or
cargo install lean-ctx