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
Owner

This PR introduces the workon command to the Grokkit CLI, addressing the bootstrapping needs for new features, todos, and fixes as outlined in the todo/doing/workon.md spec. The goal is to streamline developer workflows by automating repetitive tasks such as:

  • Moving todos from queued to doing (or creating new fix files).
  • Creating corresponding Git branches.
  • Generating AI-assisted work plans via Grok.
  • Committing changes transactionally.
  • Optional integrations like logging with cnadd and 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 queued to doing (and potentially completed upon merge).

Changes

  • CLI Integration:

    • Added workonCmd to cmd/root.go and registered it as a subcommand under the root command.
    • Created cmd/workon.go to define the workon command, including:
      • Usage: workon <todo_item_title> (e.g., workon my-new-feature).
      • Flags: --message/-M for custom commit messages, --fix/-f for fix mode (creates new .md files), --complete/-c for completing items (moves to completed/ and commits).
      • Error handling for invalid flag combinations (e.g., -c and -M are mutually exclusive).
      • Colored output for success/failure feedback using fatih/color.
  • Configuration Updates:

    • Updated config.toml.example with new defaults: commands.workon.model = "grok-4-1-fast-non-reasoning" (for fast Grok-based work plan generation) and commands.workon.ide = "" (e.g., set to "code" for VS Code).
    • Modified config/config.go to include defaults for workon model and a new GetIDECommand() function to retrieve the configured IDE.
  • Internal Logic:

    • Added internal/todo/todo.go with Bootstrap() to create the todo directory structure (queued/, doing/, completed/) and a basic README.md index if missing.
    • Created internal/workon/workon.go for the core Run() function, which handles the transactional flow:
      • Bootstraps todo structure.
      • Moves queued todos to doing or creates new fix files.
      • Creates or checks out Git branches (e.g., feature/my-todo or fix/my-fix).
      • Generates and appends a "Work Plan" section to the .md file using Grok (prompt-based, streaming silently for clean output).
      • Commits changes with a default or custom message.
      • Completes items by moving to completed/, updating the todo/README.md index (for todos), and committing.
      • Optional: Runs cnadd log if available; opens the repo in the configured IDE (e.g., code .).
      • Includes helper functions for file operations, Git commands, and README updates.
  • Todo File Updates (as part of the feature demonstration):

    • Renamed todo/queued/workon.md to todo/doing/workon.md.
    • Updated todo/README.md to 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:

    • Ran grokkit workon test-todo (todo mode): Verified file move from queued/ to doing/, branch creation (feature/test-todo), Grok-generated work plan appended, and commit.
    • Ran grokkit workon test-fix -f (fix mode): Confirmed new .md file creation in doing/, branch (fix/test-fix), plan generation, and commit.
    • Ran grokkit workon test-todo -c (complete mode): Checked file move to completed/, README index update, and commit.
    • Tested with custom message: grokkit workon test-todo -M "Custom start".
    • Error cases: Invalid flags (e.g., -c -M combo), missing title, non-existent todos—ensured proper error messages and no partial changes.
    • Grok integration: Used a mock prompt to verify plan generation; in production, ensure Grok API key is set.
    • Optional features: Configured workon.ide = "code" and verified VS Code opens; tested with cnadd installed 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:

    • Existing branches: Command checks out instead of failing.
    • Missing todo structure: Auto-bootstraps without errors.
    • README updates: Handles insertions correctly without duplicating entries.
    • Failures: Any error (e.g., Git commit fail) aborts the transaction, leaving the repo clean.

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!

This PR introduces the `workon` command to the Grokkit CLI, addressing the bootstrapping needs for new features, todos, and fixes as outlined in the `todo/doing/workon.md` spec. The goal is to streamline developer workflows by automating repetitive tasks such as: - Moving todos from queued to doing (or creating new fix files). - Creating corresponding Git branches. - Generating AI-assisted work plans via Grok. - Committing changes transactionally. - Optional integrations like logging with `cnadd` and 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 `queued` to `doing` (and potentially `completed` upon merge). #### Changes - **CLI Integration**: - Added `workonCmd` to `cmd/root.go` and registered it as a subcommand under the root command. - Created `cmd/workon.go` to define the `workon` command, including: - Usage: `workon <todo_item_title>` (e.g., `workon my-new-feature`). - Flags: `--message/-M` for custom commit messages, `--fix/-f` for fix mode (creates new `.md` files), `--complete/-c` for completing items (moves to `completed/` and commits). - Error handling for invalid flag combinations (e.g., `-c` and `-M` are mutually exclusive). - Colored output for success/failure feedback using `fatih/color`. - **Configuration Updates**: - Updated `config.toml.example` with new defaults: `commands.workon.model = "grok-4-1-fast-non-reasoning"` (for fast Grok-based work plan generation) and `commands.workon.ide = ""` (e.g., set to `"code"` for VS Code). - Modified `config/config.go` to include defaults for `workon` model and a new `GetIDECommand()` function to retrieve the configured IDE. - **Internal Logic**: - Added `internal/todo/todo.go` with `Bootstrap()` to create the todo directory structure (`queued/`, `doing/`, `completed/`) and a basic `README.md` index if missing. - Created `internal/workon/workon.go` for the core `Run()` function, which handles the transactional flow: - Bootstraps todo structure. - Moves queued todos to doing or creates new fix files. - Creates or checks out Git branches (e.g., `feature/my-todo` or `fix/my-fix`). - Generates and appends a "Work Plan" section to the `.md` file using Grok (prompt-based, streaming silently for clean output). - Commits changes with a default or custom message. - Completes items by moving to `completed/`, updating the `todo/README.md` index (for todos), and committing. - Optional: Runs `cnadd log` if available; opens the repo in the configured IDE (e.g., `code .`). - Includes helper functions for file operations, Git commands, and README updates. - **Todo File Updates** (as part of the feature demonstration): - Renamed `todo/queued/workon.md` to `todo/doing/workon.md`. - Updated `todo/README.md` to 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: - Ran `grokkit workon test-todo` (todo mode): Verified file move from `queued/` to `doing/`, branch creation (`feature/test-todo`), Grok-generated work plan appended, and commit. - Ran `grokkit workon test-fix -f` (fix mode): Confirmed new `.md` file creation in `doing/`, branch (`fix/test-fix`), plan generation, and commit. - Ran `grokkit workon test-todo -c` (complete mode): Checked file move to `completed/`, README index update, and commit. - Tested with custom message: `grokkit workon test-todo -M "Custom start"`. - Error cases: Invalid flags (e.g., `-c -M` combo), missing title, non-existent todos—ensured proper error messages and no partial changes. - Grok integration: Used a mock prompt to verify plan generation; in production, ensure Grok API key is set. - Optional features: Configured `workon.ide = "code"` and verified VS Code opens; tested with `cnadd` installed 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**: - Existing branches: Command checks out instead of failing. - Missing todo structure: Auto-bootstraps without errors. - README updates: Handles insertions correctly without duplicating entries. - Failures: Any error (e.g., Git commit fail) aborts the transaction, leaving the repo clean. 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!
gmgauthier added 7 commits 2026-03-31 21:11:19 +00:00
Update README.md to reflect the new file location and rename the workon.md file accordingly.
Introduces the `workon` CLI command which selects the next queued todo item,
moves it to doing/, creates a git branch, generates a work plan via Grok,
appends it to the file, and commits the changes. Includes skeleton implementation
with TODOs for full functionality.
- Update workonCmd to accept todo_item_title arg and add -f/--fix, -c/--complete flags
- Implement transactional flow: bootstrap todo dirs, move/create .md files, create branch, append Grok-generated Work Plan, commit
- Add todo package with Bootstrap for directory structure
- Expand workon.Run to handle modes (todo, fix, complete) with placeholders for Grok integration and optional cnadd/IDE open
- Bootstrap todo structure and handle fix/complete modes.
- Create safe git branches and append AI-generated work plans.
- Commit changes and move items to completed on finish.
- Add stubs for Grok client and config-dependent IDE open.
- 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.
Replace placeholder with actual Grok client call to generate and append a tailored work plan section to todo/fix files. Add prompt engineering for concise, actionable plans. Include file content reading and model config integration. Update comments and error handling for clarity.
feat(workon): enhance command with IDE integration and README updates
All checks were successful
CI / Test (pull_request) Successful in 36s
CI / Lint (pull_request) Successful in 26s
CI / Build (pull_request) Successful in 20s
ce878f058f
- Add colorized output for success/error messages
- Change custom message flag from -m to -M
- Implement branch prefixing (feature/ or fix/)
- Add config for workon.model and workon.ide
- Update README.md index on task completion
- Integrate IDE opening if configured
- Refine error handling and logging
gmgauthier merged commit 6692b9a050 into master 2026-03-31 21:14:00 +00:00
gmgauthier deleted branch feature/workon_cmd 2026-03-31 21:14:00 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gmgauthier/grokkit#9
No description provided.