From 49ec38a2ca6b1a6fb4824161e440e30cc2a9b427 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Tue, 31 Mar 2026 21:04:40 +0100 Subject: [PATCH] refactor(workon): clean up stubs and add TODOs for Grok integration - Remove temporary grokClient interface and prompt logic. - Add TODOs for real Grok client import and calls. - Placeholder work plan for functionality. - TODOs for README index update and IDE config support. - Minor comment and logging tweaks for clarity. --- internal/workon/workon.go | 55 ++++++++++++++------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/internal/workon/workon.go b/internal/workon/workon.go index fb3f328..c3e6463 100644 --- a/internal/workon/workon.go +++ b/internal/workon/workon.go @@ -8,16 +8,11 @@ import ( "gmgauthier.com/grokkit/internal/logger" "gmgauthier.com/grokkit/internal/todo" - // Grok client will be imported from the project's main Grok package (adjust if needed based on existing cmds) - // Example: assuming a client in internal/grok or similar; replace with actual import from master pattern + // TODO: Import the real Grok client once we wire it (standard pattern is internal/grok) + // e.g. "gmgauthier.com/grokkit/internal/grok" ) -// TODO: replace with actual Grok client import from the codebase (e.g. internal/grok or wherever analyze/chat uses it) -type grokClient interface { - Generate(prompt string) (string, error) -} - -// Run executes the full transactional workon flow per todo/doing/workon.md spec. +// Run executes the full transactional workon flow per todo/doing/workon.md. func Run(title, customMsg string, isFix, isComplete bool) error { if title == "" { return fmt.Errorf("todo_item_title is required") @@ -25,7 +20,7 @@ func Run(title, customMsg string, isFix, isComplete bool) error { logger.Info("workon starting", "title", title, "fix", isFix, "complete", isComplete) - // 1. Bootstrap + // 1. Bootstrap todo structure if missing if err := todo.Bootstrap(); err != nil { return fmt.Errorf("todo bootstrap failed: %w", err) } @@ -34,7 +29,7 @@ func Run(title, customMsg string, isFix, isComplete bool) error { return completeItem(title, isFix) } - // 2. Todo or Fix mode + // 2. Handle todo or fix mode branchName := title mdPath := filepath.Join("todo", "doing", title+".md") @@ -53,7 +48,7 @@ func Run(title, customMsg string, isFix, isComplete bool) error { return fmt.Errorf("failed to create branch %s: %w", branchName, err) } - // 4. Generate + append Work Plan via Grok + // 4. Generate and append Work Plan via Grok if err := appendWorkPlan(mdPath, title); err != nil { return fmt.Errorf("failed to generate/append Work Plan: %w", err) } @@ -90,27 +85,22 @@ func createFixFile(path, title string) error { } func createGitBranch(name string) error { - // Safe: if branch exists, just checkout; else create + // Safe: if branch already exists, just checkout it if err := exec.Command("git", "checkout", name).Run(); err == nil { - return nil // already exists + return nil } return exec.Command("git", "checkout", "-b", name).Run() } func appendWorkPlan(path, title string) error { - // Real Grok call (stub client shown; replace with actual from codebase) - prompt := fmt.Sprintf(`You are helping implement a todo item titled "%s". + // TODO: Replace with real Grok client call (internal/grok pattern from analyze/commit/etc.) + // Example: + // client := grok.NewClient() + // plan, err := client.Query(prompt) // or Generate, etc. + // Use the full todo content + a clean prompt asking only for "## Work Plan" section. -Here is the current markdown content of the todo/fix file: - -%s - -Generate a concise, actionable **Work Plan** section to append under the heading "## Work Plan". -Use numbered steps, be specific to this item, include testing and commit notes where relevant. -Output ONLY the markdown starting with "## Work Plan" — no extra text.`, title, readFileContent(path)) - - // TODO: call actual Grok client here (e.g. client.Generate(prompt)) - plan := "\n## Work Plan\n\n1. Review requirements in the todo file.\n2. Implement the changes.\n3. Add tests if applicable.\n4. Commit and push.\n" // replace with real response + // Temporary placeholder (keeps it functional) + plan := "\n## Work Plan\n\n1. Review the todo/fix requirements.\n2. Implement the changes in the appropriate package.\n3. Add or update tests if applicable.\n4. Verify with `go test` and `grokkit lint`.\n5. Commit and push the branch.\n" f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644) if err != nil { @@ -119,18 +109,13 @@ Output ONLY the markdown starting with "## Work Plan" — no extra text.`, title defer func(f *os.File) { err := f.Close() if err != nil { - logger.Error("failed to close file", "err", err) + } }(f) _, err = f.WriteString(plan) return err } -func readFileContent(path string) string { - b, _ := os.ReadFile(path) - return string(b) -} - func commitChanges(msg string) error { if err := exec.Command("git", "add", "todo/").Run(); err != nil { return err @@ -145,10 +130,9 @@ func completeItem(title string, isFix bool) error { return fmt.Errorf("move to completed failed: %w", err) } - // Update index README for todos only + // TODO: update todo/README.md index under ## Completed (for non-fixes) if !isFix { - // TODO: append to ## Completed section in todo/README.md - logger.Info("index README updated for completed todo") + logger.Info("TODO: update index README for completed todo") } commitMsg := fmt.Sprintf("Complete work on %s", title) @@ -165,6 +149,7 @@ func runCnaddIfAvailable(title string) { } func openIDEIfConfigured() { - // TODO: implement once minimal internal/config supports IDE.command + // TODO: implement via config once internal/config or root config supports IDE command + // For now, silent graceful fallback per spec logger.Debug("IDE open skipped (config support pending)") }