feature/recipe_implementation #5

Merged
gmgauthier merged 54 commits from feature/recipe_implementation into master 2026-03-07 23:17:54 +00:00
3 changed files with 11 additions and 3 deletions
Showing only changes of commit 757f422765 - Show all commits

View File

@ -20,6 +20,8 @@ extensions:
go: go:
- .go - .go
search_pattern: "if err != nil"
allowed_shell_commands: allowed_shell_commands:
- go test ./... - go test ./...
- go fmt ./... - go fmt ./...

View File

@ -81,7 +81,7 @@ Execute this step now. Respond ONLY with the expected output format — no expla
return nil return nil
} }
// discoverFiles — fully generic using recipe metadata + smart defaults // discoverFiles — fully generic using recipe metadata
func (r *Runner) discoverFiles() []string { func (r *Runner) discoverFiles() []string {
var files []string var files []string
@ -110,14 +110,19 @@ func (r *Runner) discoverFiles() []string {
} }
} }
// 4. Use the configurable search pattern (defaults to "if err != nil")
searchFor := r.Recipe.SearchPattern
if searchFor == "" {
searchFor = "if err != nil"
}
_ = filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error { _ = filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
if err != nil || d.IsDir() { if err != nil || d.IsDir() {
return nil return nil
} }
if allowedExt[filepath.Ext(path)] { if allowedExt[filepath.Ext(path)] {
// For now we still look for "if err != nil" — we can generalize this later with a recipe hint if needed
b, _ := os.ReadFile(path) b, _ := os.ReadFile(path)
if strings.Contains(string(b), "if err != nil") { if strings.Contains(string(b), searchFor) {
files = append(files, path) files = append(files, path)
} }
} }

View File

@ -10,6 +10,7 @@ type Recipe struct {
// Generic discovery support (option 2) // Generic discovery support (option 2)
ProjectLanguages []string `yaml:"project_languages"` ProjectLanguages []string `yaml:"project_languages"`
Extensions map[string][]string `yaml:"extensions"` Extensions map[string][]string `yaml:"extensions"`
SearchPattern string `yaml:"search_pattern"` // new
// Resolved runtime values from --param flags // Resolved runtime values from --param flags
ResolvedParams map[string]any `yaml:"-"` ResolvedParams map[string]any `yaml:"-"`