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 b2b8c1a482 - Show all commits

View File

@ -77,7 +77,7 @@ Execute this step now. Respond ONLY with the expected output format — no expla
return nil return nil
} }
// discoverFiles does a real filesystem scan (used by "Discover files" steps) // discoverFiles does a real filesystem scan
func (r *Runner) discoverFiles() []string { func (r *Runner) discoverFiles() []string {
var files []string var files []string
root := "internal" root := "internal"
@ -99,7 +99,7 @@ func (r *Runner) discoverFiles() []string {
return files return files
} }
// handleApplyStep (dry-run patch + confirmation) // handleApplyStep now uses a more flexible regex that matches both formats Grok uses
func (r *Runner) handleApplyStep(previousResults []string) { func (r *Runner) handleApplyStep(previousResults []string) {
if len(previousResults) == 0 { if len(previousResults) == 0 {
fmt.Println(" ⚠️ No previous results to apply — skipping.") fmt.Println(" ⚠️ No previous results to apply — skipping.")
@ -124,8 +124,8 @@ func (r *Runner) handleApplyStep(previousResults []string) {
fmt.Println(" Review it, then run with dry_run=false to apply.") fmt.Println(" Review it, then run with dry_run=false to apply.")
} }
// regex split across lines to avoid backtick collision // Flexible regex that works whether Grok puts "// filename" or just "filename"
var blockRe = regexp.MustCompile(`(?s)^//\s*(.+?\.go)\n` + var blockRe = regexp.MustCompile(`(?s)^(?://\s*)?(.+?\.go)\n` +
"```go\n" + "```go\n" +
`(.*?)\n` + `(.*?)\n` +
"```") "```")
@ -146,23 +146,12 @@ func createUnifiedPatch(blocks map[string]string, patchPath string) error {
if err != nil { if err != nil {
return err return err
} }
defer func(f *os.File) { defer f.Close()
err := f.Close()
if err != nil {
return
}
}(f)
for path, content := range blocks { for path, content := range blocks {
_, err := fmt.Fprintf(f, "--- %s\n+++ %s\n@@ -0,0 +1,%d @@\n", path, path, strings.Count(content, "\n")+1) fmt.Fprintf(f, "--- %s\n+++ %s\n@@ -0,0 +1,%d @@\n", path, path, strings.Count(content, "\n")+1)
if err != nil {
return err
}
for _, line := range strings.Split(content, "\n") { for _, line := range strings.Split(content, "\n") {
_, err := fmt.Fprintf(f, "+%s\n", line) fmt.Fprintf(f, "+%s\n", line)
if err != nil {
return err
}
} }
} }
return nil return nil