feat: Implement workon Command for Automated Todo/Fix Workflow Integration #9

Merged
gmgauthier merged 7 commits from feature/workon_cmd into master 2026-03-31 21:14:00 +00:00
3 changed files with 76 additions and 0 deletions
Showing only changes of commit 9080cf7f3e - Show all commits

View File

@ -65,6 +65,7 @@ func init() {
rootCmd.AddCommand(scaffoldCmd)
rootCmd.AddCommand(queryCmd)
rootCmd.AddCommand(analyzeCmd)
rootCmd.AddCommand(workonCmd)
// Add model flag to all commands
rootCmd.PersistentFlags().StringP("model", "m", "", "Grok model to use (overrides config)")

40
cmd/workon.go Normal file
View File

@ -0,0 +1,40 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"gmgauthier.com/grokkit/internal/logger"
"gmgauthier.com/grokkit/internal/workon" // we'll create this next
)
var workonCmd = &cobra.Command{
Use: "workon",
Short: "Start work on the next todo item from the queue",
Long: `workon picks the next .md file from todo/queued/,
moves it to todo/doing/, creates a matching git branch,
asks Grok to generate a Work Plan section,
appends it to the file, and commits everything.
Purely transactional one command, clear success or failure.`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
return fmt.Errorf("workon takes no arguments")
}
logger.Info("Starting workon transaction")
if err := workon.Run(); err != nil {
return fmt.Errorf("workon failed: %w", err)
}
logger.Info("Workon completed successfully")
return nil
},
}
func init() {
workonCmd.Flags().StringP("message", "m", "", "Custom commit message (default: \"Start working on <item>\")")
// -f and -c flags will be added later when the spec needs them
}

35
internal/workon/workon.go Normal file
View File

@ -0,0 +1,35 @@
package workon
import (
_ "gmgauthier.com/grokkit/internal/errors"
"gmgauthier.com/grokkit/internal/logger"
// TODO: import todo, git, grok packages as we build them
)
// Run executes the full workon transaction
func Run() error {
logger.Info("Bootstrapping todo structure if needed...")
// TODO: todo.BootstrapIfMissing()
logger.Info("Selecting next queued item...")
// TODO: item, err := todo.NextQueued()
// if err != nil { return err }
logger.Info("Moving item to doing/ and creating branch...")
// TODO: branchName, err := todo.MoveToDoingAndCreateBranch(item)
logger.Info("Generating Work Plan via Grok...")
// TODO: plan, err := grok.GenerateWorkPlan(item)
logger.Info("Appending plan to todo file...")
// TODO: err = todo.AppendWorkPlan(item, plan)
logger.Info("Committing changes...")
// TODO: err = git.CommitWorkonChanges(branchName, item)
logger.Info("Optional post-steps (cnadd, open IDE)...")
// TODO: postSteps()
return nil
}