feat: Implement workon Command for Automated Todo/Fix Workflow Integration
#9
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/workon_cmd"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR introduces the
workoncommand to the Grokkit CLI, addressing the bootstrapping needs for new features, todos, and fixes as outlined in thetodo/doing/workon.mdspec. The goal is to streamline developer workflows by automating repetitive tasks such as:cnaddand opening the repo in a configured IDE.This reduces manual overhead, ensures consistency in todo management, and leverages Grok for intelligent planning. It's designed to be purely transactional (e.g., atomic operations with error handling) and extensible via configuration. The command supports both todo and fix modes, with an option to complete items by moving them to
todo/completed/.This implementation directly resolves the "workon" todo item, moving it from
queuedtodoing(and potentiallycompletedupon merge).Changes
CLI Integration:
workonCmdtocmd/root.goand registered it as a subcommand under the root command.cmd/workon.goto define theworkoncommand, including:workon <todo_item_title>(e.g.,workon my-new-feature).--message/-Mfor custom commit messages,--fix/-ffor fix mode (creates new.mdfiles),--complete/-cfor completing items (moves tocompleted/and commits).-cand-Mare mutually exclusive).fatih/color.Configuration Updates:
config.toml.examplewith new defaults:commands.workon.model = "grok-4-1-fast-non-reasoning"(for fast Grok-based work plan generation) andcommands.workon.ide = ""(e.g., set to"code"for VS Code).config/config.goto include defaults forworkonmodel and a newGetIDECommand()function to retrieve the configured IDE.Internal Logic:
internal/todo/todo.gowithBootstrap()to create the todo directory structure (queued/,doing/,completed/) and a basicREADME.mdindex if missing.internal/workon/workon.gofor the coreRun()function, which handles the transactional flow:feature/my-todoorfix/my-fix)..mdfile using Grok (prompt-based, streaming silently for clean output).completed/, updating thetodo/README.mdindex (for todos), and committing.cnadd logif available; opens the repo in the configured IDE (e.g.,code .).Todo File Updates (as part of the feature demonstration):
todo/queued/workon.mdtotodo/doing/workon.md.todo/README.mdto reflect the moved todo item.No breaking changes; this is a net-new feature. All operations are safe (e.g., Git branch creation falls back to checkout if existing) and logged via the internal logger.
Testing Notes
Unit/Integration Testing: While no formal tests were added in this PR (future work could include them in a testing suite), the code was manually tested in a local Git repository:
grokkit workon test-todo(todo mode): Verified file move fromqueued/todoing/, branch creation (feature/test-todo), Grok-generated work plan appended, and commit.grokkit workon test-fix -f(fix mode): Confirmed new.mdfile creation indoing/, branch (fix/test-fix), plan generation, and commit.grokkit workon test-todo -c(complete mode): Checked file move tocompleted/, README index update, and commit.grokkit workon test-todo -M "Custom start".-c -Mcombo), missing title, non-existent todos—ensured proper error messages and no partial changes.workon.ide = "code"and verified VS Code opens; tested withcnaddinstalled for logging.Environment: Tested on macOS with Go 1.21, Git 2.30+, and a valid Grok API setup. Recommend testing in a clean repo clone to avoid conflicts.
Edge Cases:
If approved, this can be merged to main. Future enhancements could include full test coverage or additional flags (e.g., for dry-run mode). Let me know if any adjustments are needed!