diff --git a/internal/recipe/runner.go b/internal/recipe/runner.go index 347ddb1..cd3feda 100644 --- a/internal/recipe/runner.go +++ b/internal/recipe/runner.go @@ -81,11 +81,11 @@ Execute this step now. Respond ONLY with the expected output format — no expla return nil } -// discoverFiles — now fully generic using recipe metadata +// discoverFiles — respects package_path param, with smart defaults func (r *Runner) discoverFiles() []string { var files []string - // Get root from --param or default + // 1. Use explicit --param package_path if provided root := "." if v, ok := r.Recipe.ResolvedParams["package_path"]; ok { 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 allowedExt := make(map[string]bool) for _, lang := range r.Recipe.ProjectLanguages { @@ -109,7 +118,7 @@ func (r *Runner) discoverFiles() []string { } if allowedExt[filepath.Ext(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) } }