From d4f3e3adbcc83dea9d817acd24cba04279fdef52 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Fri, 6 Mar 2026 22:25:39 +0000 Subject: [PATCH] refactor(recipe): update regex for robust Grok output matching - Blank import bufio to avoid unused warnings. - Refine regex to handle double-quoted format and fix backtick issues. - Update comments for clarity on regex changes. --- internal/recipe/runner.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/recipe/runner.go b/internal/recipe/runner.go index 57b5325..649eadc 100644 --- a/internal/recipe/runner.go +++ b/internal/recipe/runner.go @@ -1,7 +1,7 @@ package recipe import ( - "bufio" + _ "bufio" "fmt" "os" "path/filepath" @@ -99,7 +99,7 @@ func (r *Runner) discoverFiles() []string { return files } -// handleApplyStep with flexible regex that matches Grok's current output style +// handleApplyStep with robust regex that matches Grok's current output 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.") } -// Flexible regex — matches both old and new Grok formats -var blockRe = regexp.MustCompile(`(?s)```go\n(?://\s*)?(.+?\.go)\n(.*?)\n````) +// Double-quoted regex — no raw-string backtick problems ever again +var blockRe = regexp.MustCompile(`(?s)```go\n// \s*(.+?\.go)\n(.*?)\n````) func extractCodeBlocks(text string) map[string]string { blocks := make(map[string]string)