Add ast_grep tool: structural code search via ast-grep

AST-level pattern matching — find code by structure, not text.
e.g. find all `if let Some($X) = $Y { $$$BODY }` patterns.
Supports C, Rust, Python, JS/TS, Go, and 20+ languages.

Gracefully errors if sg binary isn't installed.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-09 02:57:02 -04:00 committed by Kent Overstreet
parent c53c4f9071
commit ec7e11db56
5 changed files with 552 additions and 5 deletions

View file

@ -5,6 +5,7 @@
// working_stack) and delegates everything else to thought::dispatch.
// Core tools
mod ast_grep;
mod bash;
pub mod channels;
mod edit;
@ -160,7 +161,7 @@ pub fn tools() -> Vec<Tool> {
let mut all = vec![
read::tool(), write::tool(), edit::tool(),
grep::tool(), glob::tool(), bash::tool(),
vision::tool(),
ast_grep::tool(), vision::tool(),
];
all.extend(web::tools());
all.extend(memory::memory_tools());