diff --git a/cmd/root.go b/cmd/root.go index a837216..50f06c3 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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)") diff --git a/cmd/workon.go b/cmd/workon.go new file mode 100644 index 0000000..f18a868 --- /dev/null +++ b/cmd/workon.go @@ -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 \")") + // -f and -c flags will be added later when the spec needs them +} diff --git a/internal/workon/workon.go b/internal/workon/workon.go new file mode 100644 index 0000000..ae30094 --- /dev/null +++ b/internal/workon/workon.go @@ -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 +}