feature/recipe_implementation #5

Merged
gmgauthier merged 54 commits from feature/recipe_implementation into master 2026-03-07 23:17:54 +00:00
Showing only changes of commit 8c14977ec6 - Show all commits

View File

@ -81,11 +81,11 @@ Execute this step now. Respond ONLY with the expected output format — no expla
return nil return nil
} }
// discoverFiles — now fully generic using recipe metadata // discoverFiles — respects package_path param, with smart defaults
func (r *Runner) discoverFiles() []string { func (r *Runner) discoverFiles() []string {
var files []string var files []string
// Get root from --param or default // 1. Use explicit --param package_path if provided
root := "." root := "."
if v, ok := r.Recipe.ResolvedParams["package_path"]; ok { if v, ok := r.Recipe.ResolvedParams["package_path"]; ok {
if s, ok := v.(string); ok && s != "" { if s, ok := v.(string); ok && s != "" {
@ -93,6 +93,15 @@ func (r *Runner) discoverFiles() []string {
} }
} }
// 2. If no param was given, apply smart defaults
if root == "." {
// Check for src/ directory (common in some layouts)
if _, err := os.Stat("src"); err == nil {
root = "src"
}
// otherwise stay at project root (.)
}
// Build allowed extensions from recipe frontmatter // Build allowed extensions from recipe frontmatter
allowedExt := make(map[string]bool) allowedExt := make(map[string]bool)
for _, lang := range r.Recipe.ProjectLanguages { for _, lang := range r.Recipe.ProjectLanguages {
@ -109,7 +118,7 @@ func (r *Runner) discoverFiles() []string {
} }
if allowedExt[filepath.Ext(path)] { if allowedExt[filepath.Ext(path)] {
b, _ := os.ReadFile(path) b, _ := os.ReadFile(path)
if strings.Contains(string(b), "if err != nil") { if strings.Contains(string(b), "if err != nil") { // TODO: generalize this too later
files = append(files, path) files = append(files, path)
} }
} }