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
This commit is contained in:
parent
dcac119e57
commit
2cc728eed4
@ -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") {
|
||||
|
||||
@ -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)`)
|
||||
)
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user