From 2cc728eed4fae58527603d8f0655eb00a85109c3 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Fri, 6 Mar 2026 19:00:16 +0000 Subject: [PATCH] refactor(recipe): clean up comments, error handling, and output formatting - Simplify import comments and error handling in cmd/recipe.go - Streamline regex comment in internal/recipe/loader.go - Enhance console output and add LLM placeholder in internal/recipe/runner.go --- cmd/recipe.go | 7 +++---- internal/recipe/loader.go | 3 +-- internal/recipe/runner.go | 11 +++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmd/recipe.go b/cmd/recipe.go index e4eb74e..f488e6d 100644 --- a/cmd/recipe.go +++ b/cmd/recipe.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "gmgauthier.com/grokkit/internal/recipe" // adjust if your module name differs + "gmgauthier.com/grokkit/internal/recipe" ) var recipeCmd = &cobra.Command{ @@ -25,7 +25,7 @@ var runCmd = &cobra.Command{ func init() { recipeCmd.AddCommand(runCmd) - rootCmd.AddCommand(recipeCmd) // this is how every other command is wired in your project + rootCmd.AddCommand(recipeCmd) } func runRecipe(cmd *cobra.Command, args []string) error { @@ -84,8 +84,7 @@ func resolveRecipePath(nameOrPath string) (string, error) { if _, err := os.Stat(global); err == nil { fmt.Printf("Recipe %q not found in project.\nFound globally at %s\nUse this one? [y/N] ", nameOrPath, global) var answer string - _, err := fmt.Scanln(&answer) - if err != nil { + if _, err := fmt.Scanln(&answer); err != nil { return "", err } if strings.HasPrefix(strings.ToLower(answer), "y") { diff --git a/internal/recipe/loader.go b/internal/recipe/loader.go index 9ee03a3..d081679 100644 --- a/internal/recipe/loader.go +++ b/internal/recipe/loader.go @@ -15,8 +15,7 @@ var ( // stepRe finds every "### Step N: Title" heading stepRe = regexp.MustCompile(`(?m)^### Step (\d+): (.+)$`) - // subRe finds the three labelled sections inside each step. - // We use a simple non-capturing group + word-boundary approach instead of lookahead. + // subRe finds the three labelled sections inside each step (no Perl lookahead) subRe = regexp.MustCompile(`(?m)^(\*\*(?:Objective|Instructions|Expected output):\*\*)\s*(.+?)(?:\n\n|\n###|\z)`) ) diff --git a/internal/recipe/runner.go b/internal/recipe/runner.go index f848619..d8e2427 100644 --- a/internal/recipe/runner.go +++ b/internal/recipe/runner.go @@ -11,12 +11,15 @@ func NewRunner(r *Recipe) *Runner { } func (r *Runner) Run() error { - fmt.Printf("šŸ³ Starting recipe: %s v%s\n", r.Recipe.Name, r.Recipe.Version) + fmt.Printf("šŸ³ Starting recipe: %s v%s\n\n", r.Recipe.Name, r.Recipe.Version) + for _, step := range r.Recipe.Steps { fmt.Printf("Step %d/%d: %s\n", step.Number, len(r.Recipe.Steps), step.Title) - // TODO: here we will send step.Instructions to the LLM - // and handle the response according to Expected + // TODO: here we will send step.Instructions (plus Objective/Expected) to the LLM + // and handle the response according to Expected output + fmt.Println(" → (LLM call coming soon)") } - fmt.Println("āœ… Recipe complete.") + + fmt.Println("\nāœ… Recipe complete.") return nil }