diff --git a/internal/recipe/runner.go b/internal/recipe/runner.go index cd3feda..1cc98b6 100644 --- a/internal/recipe/runner.go +++ b/internal/recipe/runner.go @@ -81,7 +81,7 @@ Execute this step now. Respond ONLY with the expected output format — no expla return nil } -// discoverFiles — respects package_path param, with smart defaults +// discoverFiles — fully generic using recipe metadata + smart defaults func (r *Runner) discoverFiles() []string { var files []string @@ -93,16 +93,14 @@ func (r *Runner) discoverFiles() []string { } } - // 2. If no param was given, apply smart defaults + // 2. Smart defaults if no param was given 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 + // 3. Build allowed extensions from recipe frontmatter allowedExt := make(map[string]bool) for _, lang := range r.Recipe.ProjectLanguages { if exts, ok := r.Recipe.Extensions[lang]; ok { @@ -117,8 +115,9 @@ func (r *Runner) discoverFiles() []string { return nil } 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) - if strings.Contains(string(b), "if err != nil") { // TODO: generalize this too later + if strings.Contains(string(b), "if err != nil") { files = append(files, path) } }