3 ms·
Wow! What a coincidence. Just the other day I finished "v1" of a similar tool: https://github.com/alexpovel/srgn https://github.com/alexpovel/srgn , calling it
by alexpovel 3y ago
Wow! What a coincidence. Just the other day I finished "v1" of a similar tool: https://github.com/alexpovel/srgn https://github.com/alexpovel/srgn , calling it a combination of tr/sed, ripgrep and tree-sitter. It's more about editing code in-place, not finding matches.
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.
- conartist6 3y agoI'm working on an another similar tool! https://github.com/bablr-lang https://github.com/bablr-lang 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.
- tekacs 3y agoThis looks really interesting, thank you for putting this together! I’ll likely give it a go today. I say that as someone who has explored quite a few of these and found them mostly quite basic. srgn looks like more than the usual. 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. :)
- alexpovel 3y ago> diff formatting Thank you for the feedback! That sounds good, I'll add that.
- alchemist1e9 3y agoSuch an awesome idea and useful tool! Do you use tree-sitter for the AST part also?
- alexpovel 3y agoExactly, all the parsing is done by tree-sitter. The Rust bindings to the tree-sitter C lib are a "first-class consumer".
- larve 3y agoI'll post my own crappy one called oak which uses templates to render the result of tree-sitter queries. https://github.com/go-go-golems/oak 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/queries/go/definitions.yaml 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.