by alexpovel · 2y ago · 0 comments
I've spent a lot of time trying to find similar tools, and even list them in the README, but `AST-grep` did not come up! I was a bit confused, as I was sure such a thing must exist already. AST-grep looks much more capable and dynamic, great work, especially around the variable syntax.
One minor comment: I personally found the first Python example involving a docstring a little hard to parse (ha). It may show a variety of features, but in particular I found that it was hard to spot at a glance what had changed.
If you could use diff formatting or a screenshot with color to show the differences it would make it much easier to follow. If I get around to using it later today, I might submit a PR for that. :)
Thank you for the feedback! That sounds good, I'll add that.
A lot like your project but with more of a focus on supporting data structures for incremental editing of programs. Kind of a DOM for code.
https://github.com/go-go-golems/oak
I initially hope the queries would be more powerful, but they are really not. You can write queries and a resulting template in a yaml file. The program will scan a list of repositories for all these YAML files, and expose them as command line verbs.
Here is one to find go definitions:
https://github.com/go-go-golems/oak/blob/main/cmd/oak/querie...
This can then be run as:
oak go definitions /home/manuel/code/wesen/corporate-headquarters/geppetto/pkg/cmds/cmd.go
type GeppettoCommandDescription struct {
Name string `yaml:"name"`
Short string `yaml:"short"`
Long string `yaml:"long,omitempty"`
Flags []*parameters.ParameterDefinition `yaml:"flags,omitempty"`
Arguments []*parameters.ParameterDefinition `yaml:"arguments,omitempty"`
Layers []layers.ParameterLayer `yaml:"layers,omitempty"`
Prompt string `yaml:"prompt,omitempty"`
Messages []*geppetto_context.Message `yaml:"messages,omitempty"`
SystemPrompt string `yaml:"system-prompt,omitempty"`
}
type GeppettoCommand struct {
*glazedcmds.CommandDescription
StepSettings *settings.StepSettings
Prompt string
Messages []*geppetto_context.Message
SystemPrompt string
}
While I can use it for good effect for LLM prompting as is, I really would like to add a unification algorithm (like the one in Peter Norvig's Prolog compiler) to get better queries, and connect it to LSP as well.Do you use tree-sitter for the AST part also?