id: task-187 title: Fix autoCommit setting not being respected by all CLI commands status: Done assignee:
- '@mjgs' created_date: '2025-07-12' updated_date: '2025-07-13' labels:
- bug
- config
- git
- cli dependencies: [] priority: high
Description
The autoCommit configuration setting in config.yml was not being consistently respected across all CLI commands. Some commands were hardcoded to always commit (passing true to autoCommit parameters), while others were ignoring the setting entirely. This led to inconsistent behavior where users couldn't reliably control git commit behavior through configuration.
Acceptance Criteria
- [x] Remove hardcoded
truevalues fromcore.createDocument()calls in CLI - [x] Remove hardcoded
truevalues fromcore.createDecision()calls in CLI - [x] Remove hardcoded
truevalues fromcore.archiveDraft()calls in CLI - [x] Ensure all Core methods check config.autoCommit before performing git commits
- [x] Add comprehensive E2E tests for autoCommit behavior with both true and false settings
- [x] Test task creation, document creation, and decision creation with both autoCommit modes
- [x] Verify git repository state after operations (clean vs dirty) based on autoCommit setting
- [x] Ensure commit count increases only when autoCommit is enabled
Implementation Plan
-
Audit CLI commands for hardcoded autoCommit values
- Find all instances where
trueis passed to autoCommit parameters - Replace with default parameter handling (undefined) to let Core decide
- Find all instances where
-
Update CLI command implementations
doc create: Change fromcore.createDocument(document, true, ...)tocore.createDocument(document, undefined, ...)decision create: Change fromcore.createDecision(decision, true)tocore.createDecision(decision)draft archive: Change fromcore.archiveDraft(taskId, true)tocore.archiveDraft(taskId)
-
Ensure Core methods respect configuration
- Verify that Core methods check
config.autoCommitbefore performing git operations - Ensure default behavior when autoCommit is undefined
- Verify that Core methods check
-
Add comprehensive testing
- Create E2E tests using
Bun.spawnSyncto test actual CLI behavior - Test both
autoCommit: trueandautoCommit: falsescenarios - Verify git repository state after each operation
- Use git commit count to verify commit behavior
- Create E2E tests using
Implementation Notes
Removed hardcoded true values from CLI commands that were bypassing the autoCommit configuration setting. The fix involved changing three commands:
doc create: Changedcore.createDocument(document, true, ...)tocore.createDocument(document, undefined, ...)decision create: Changedcore.createDecision(decision, true)tocore.createDecision(decision)draft archive: Changedcore.archiveDraft(taskId, true)tocore.archiveDraft(taskId)
Added comprehensive E2E tests in src/test/cli-commit-behaviour.test.ts that verify the behavior works correctly with both autoCommit: true and autoCommit: false configurations. Tests check git repository state (clean vs dirty) and commit count to ensure commits only happen when expected.
The root cause was hardcoded parameters in the CLI layer overriding the user's configuration preference. Core methods were already designed to respect the config, but the CLI wasn't letting them.