# Oak - [GitHub - go-go-golems/oak: GO GO PARSE YOUR CODE GO GO](https://github.com/go-go-golems/oak) Use [[tree-sitter]] to run queries against programming language files. ## Similar Project [[2023-12-10]] - [GitHub - ast-grep/ast-grep: ⚡A CLI tool for code structural search, lint and rewriting. Written in Rust](https://github.com/ast-grep/ast-grep) - Hacker News Discussion: [AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting | Hacker News](https://news.ycombinator.com/item?id=38590984) - Used by [CodeRabbit: AI-powered Code Reviews](https://coderabbit.ai/) - [GitHub - paul-gauthier/grep-ast: Grep source code and see useful code context about matching lines](https://github.com/paul-gauthier/grep-ast) - [GitHub - BenHanson/gram\_grep: Search text using a grammer, lexer, or straight regex. Chain searches for greater refinement.](https://github.com/BenHanson/gram_grep) - [Building a better repository map with tree sitter | aider](https://aider.chat/docs/repomap.html) Use a github action to provide the binary as a pip package: - [release.yaml](https://github.com/astral-sh/ruff/blob/main/.github/workflows/release.yaml) Programming language to match code: - [GritQL Tutorial](https://docs.grit.io/tutorials/gritql) Article about background for [[aider]]: - [Building a better repository map with tree sitter | aider](https://aider.chat/docs/repomap.html) ## See also - [[SK - 2n5 - LLMs for Programming]] - [[Prompt Engineering]] ## Ideas [[2023-08-08]] Processing [[SKETCHBOOK - 2023-05-29 - weinheim sketchbook]] p. 8-9 which is mostly about [[IDEA - GO GO GOLEMS - 2023-08–05 - Prompt Context Manager]], but prompts quite a few ideas for Oak, since really oak was built to support the context manager as a building block. ## Git support See [[IDEA - GO GO GOLEMS - Idea repository#Add git support to PROJ - GO GO GOLEMS - OAK]] and [[2023-08-08#Claude for comments on code]] ### Tree like output structure Currently, we handle matches as mostly a flat list of matches, but what would it mean for tree-sitter to be a simplifying AST kind of filter, where one matching query would then apply further matching query on its body, and do the replacement with a YAML template instead of a text template at the end. We could have nested queries, and each query has a structured template for its output. Potentially the top output template also has access to the structured data of the submatches, and vice versa. That is, we match the queries recursively first, construct a tree of matches, then pass that tree of matches to the template renderer, along with a tree of templates. ### diff + oak for pull request feedback See [[2023-08-08#Claude for comments on code]] Which leads me to: This is really cool and something I should add to my workflow. Potentially I can couple this with a diff, use the diff to extract functions/files/methods that changed, and then use that in combination with oak to query for comments… - [ ] #toDesign brainstorm out what a diff pull request functionality would be and see how efficient it is ➕ 2023-08-08