feature/recipe_implementation #5
@ -77,7 +77,7 @@ Execute this step now. Respond ONLY with the expected output format — no expla
|
||||
return nil
|
||||
}
|
||||
|
||||
// discoverFiles does a real filesystem scan (used by "Discover files" steps)
|
||||
// discoverFiles does a real filesystem scan
|
||||
func (r *Runner) discoverFiles() []string {
|
||||
var files []string
|
||||
root := "internal"
|
||||
@ -99,7 +99,7 @@ func (r *Runner) discoverFiles() []string {
|
||||
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) {
|
||||
if len(previousResults) == 0 {
|
||||
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.")
|
||||
}
|
||||
|
||||
// regex split across lines to avoid backtick collision
|
||||
var blockRe = regexp.MustCompile(`(?s)^//\s*(.+?\.go)\n` +
|
||||
// Flexible regex that works whether Grok puts "// filename" or just "filename"
|
||||
var blockRe = regexp.MustCompile(`(?s)^(?://\s*)?(.+?\.go)\n` +
|
||||
"```go\n" +
|
||||
`(.*?)\n` +
|
||||
"```")
|
||||
@ -146,23 +146,12 @@ func createUnifiedPatch(blocks map[string]string, patchPath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func(f *os.File) {
|
||||
err := f.Close()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}(f)
|
||||
defer f.Close()
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(f, "--- %s\n+++ %s\n@@ -0,0 +1,%d @@\n", path, path, strings.Count(content, "\n")+1)
|
||||
for _, line := range strings.Split(content, "\n") {
|
||||
_, err := fmt.Fprintf(f, "+%s\n", line)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(f, "+%s\n", line)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user