---
description: "Implementation plan for commit-polish AI agent swarm execution"
version: "1.2"
tasks:
- [ ] Priority 1: Task A - Project structure initialization
- [ ] Priority 1: Task B - Configuration files setup
- [ ] Priority 1: Task C - Pre-commit hook configuration
- [ ] Priority 1: Task D - Package dependency files
- [ ] Priority 2: Task E - commit-polish core modules
- [ ] Priority 2: Task F - commit-polish validator system
- [ ] Priority 2: Task G - commit-polish unit tests
- [ ] Priority 3: Task H - commit-polish-installer core modules
- [ ] Priority 3: Task I - commit-polish-installer CLI
- [ ] Priority 3: Task J - commit-polish-installer tests
- [ ] Priority 4: Task K - Integration testing
- [ ] Priority 4: Task L - Documentation
---
This plan coordinates AI agent swarm execution to implement commit-polish, a two-package pre-commit hook system that automatically rewrites git commit messages using local LLMs via LiteLLM. Tasks are organized by dependency-based priorities enabling massively parallel execution.
Architecture Context:
- Package 1:
commit-polish(hook runtime) - lightweight, implements first - Package 2:
commit-polish-installer(setup tool) - heavy dependencies, implements second - Monorepo structure with uv workspace
- Python 3.11+ required, LiteLLM for API abstraction, llamafile for local inference
graph TB
A[Task A: Project Structure] --> E[Task E: Core Modules]
B[Task B: Config Files] --> E
C[Task C: Pre-commit Hook Config] --> E
D[Task D: Package Dependencies] --> E
E --> F[Task F: Validator System]
F --> G[Task G: Unit Tests]
A --> H[Task H: Installer Core]
B --> H
D --> H
H --> I[Task I: Installer CLI]
I --> J[Task J: Installer Tests]
G --> K[Task K: Integration Tests]
J --> K
K --> L[Task L: Documentation]
- Priority 1: 4 tasks can run in parallel (no dependencies)
- Priority 2: Task E enables Tasks F→G (3 tasks total, partial parallelization)
- Priority 3: Task H enables Tasks I→J (3 tasks total, sequential)
- Priority 4: Task K enables Task L (2 tasks total, sequential)
Tasks in this priority can execute in parallel with no coordination required.
Dependencies: None Priority: 1 (Foundational) Complexity: Low
Acceptance Criteria:
- Directory structure created:
packages/commit-polish/src/commit_polish/packages/commit-polish/tests/packages/commit-polish-installer/src/commit_polish_installer/packages/commit-polish-installer/tests/references/(already exists)
- All directories contain
__init__.pyfiles where appropriate - Structure matches architecture specification in architecture.md
- No files with content yet (just directory structure)
- Verification command succeeds:
find packages/ -type d
Required Inputs:
- Architecture document at
/home/ubuntulinuxqa2/repos/commit-polish/architecture.md - CLAUDE.md package structure specifications
Expected Outputs:
packages/commit-polish/src/commit_polish/__init__.pypackages/commit-polish/tests/__init__.pypackages/commit-polish-installer/src/commit_polish_installer/__init__.pypackages/commit-polish-installer/tests/__init__.py- Subdirectories:
packages/commit-polish/src/commit_polish/validators/ - Subdirectories:
packages/commit-polish/tests/test_validators/
Can Parallelize With: Task B (Config Files), Task C (Pre-commit Hook Config), Task D (Package Dependencies) Reason: Operates on directory structure only, no file conflicts
Verification Steps:
- Run
find packages/ -type d- should show all expected directories - Run
find packages/ -name '__init__.py'- should show all init.py files - Verify directory tree matches architecture.md specifications
- No syntax errors when importing empty packages
Dependencies: None Priority: 1 (Foundational) Complexity: Low
Acceptance Criteria:
- Root
pyproject.tomlcreated with uv workspace configuration - Workspace members configured:
packages/* - Ruff configuration with line-length=100, target-version="py311"
- Mypy configuration with strict=true, python_version="3.11"
.gitignorecreated with Python patterns (__pycache__, *.pyc, .pytest_cache, .mypy_cache, dist/, build/)- Validation:
uv syncruns without errors (will show no dependencies yet)
Required Inputs:
- Architecture document section: "Workspace Configuration"
- Python 3.11+ requirement
- Tool specifications from architecture.md
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/pyproject.toml(root workspace)/home/ubuntulinuxqa2/repos/commit-polish/.gitignore- Configuration includes:
[tool.uv.workspace]with members[tool.ruff]with linting rules[tool.mypy]with type checking rules
Can Parallelize With: Task A (Project Structure), Task C (Pre-commit Hook Config), Task D (Package Dependencies) Reason: Operates on root configuration files, no conflicts with other tasks
Verification Steps:
- Run
uv sync- should complete without errors - Validate TOML syntax with
tomlkit.load() - Verify workspace members are recognized
- Check ruff config:
uv run ruff --versionshould work - Check mypy config:
uv run mypy --versionshould work
Dependencies: None Priority: 1 (Foundational) Complexity: Low
Acceptance Criteria:
.pre-commit-hooks.yamlcreated inpackages/commit-polish/- Hook ID:
commit-polish - Stage:
[prepare-commit-msg](CRITICAL - not commit-msg) - Entry point:
commit-polish - Settings:
pass_filenames: false,always_run: true - Language:
python - YAML syntax validates successfully
Required Inputs:
- Architecture document section: "Pre-commit Hook Configuration"
- CLAUDE.md critical specifications about prepare-commit-msg stage
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/.pre-commit-hooks.yaml- File content matches architecture specification exactly
Can Parallelize With: Task A (Project Structure), Task B (Config Files), Task D (Package Dependencies) Reason: Operates on commit-polish package config only, no conflicts
Verification Steps:
- Validate YAML syntax:
python -c "import yaml; yaml.safe_load(open('.pre-commit-hooks.yaml'))" - Verify stages contains
prepare-commit-msg(notcommit-msg) - Verify
pass_filenames: falseis set - Verify
always_run: trueis set - Check entry point matches script name in pyproject.toml (will be created in Task D)
Dependencies: None Priority: 1 (Foundational) Complexity: Medium
Acceptance Criteria:
packages/commit-polish/pyproject.tomlcreated with:- name: "commit-polish"
- requires-python: ">=3.11"
- dependencies: ["litellm>=1.0.0", "tomlkit>=0.13.0"]
- dev dependencies: pytest, pytest-asyncio, pytest-mock, ruff, mypy
- script entry point:
commit-polish = "commit_polish.hook:main" - build-system with uv_build
packages/commit-polish-installer/pyproject.tomlcreated with:- name: "commit-polish-installer"
- requires-python: ">=3.11"
- dependencies: ["typer>=0.9.0", "tomlkit>=0.13.0", "rich>=13.0.0", "httpx>=0.25.0"]
- dev dependencies: pytest, ruff, mypy
- script entry point:
commit-polish-install = "commit_polish_installer.cli:app" - build-system with uv_build
- Both files validate as correct TOML
uv synccompletes successfully and installs all dependencies
Required Inputs:
- Architecture document sections: "Dependencies" for both packages
- CLAUDE.md dependency specifications
- Python 3.11+ requirement
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/pyproject.toml/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/pyproject.tomluv.lockfile generated afteruv sync
Can Parallelize With: Task A (Project Structure), Task B (Config Files), Task C (Pre-commit Hook Config) Reason: Operates on package-specific pyproject.toml files, different locations
Verification Steps:
- Validate TOML syntax for both files
- Run
uv syncfrom workspace root - should install all dependencies - Verify package recognition:
uv treeshould show both packages and their dependencies - Check dependencies installed:
uv run pip listshould show litellm, typer, tomlkit, rich, httpx, pytest, ruff, mypy - No dependency conflicts reported
Convergence Point: Task A, Task B, Task C, Task D must all complete
Quality Gates:
- Project structure exists with all required directories
- All configuration files are valid TOML/YAML
-
uv synccompletes without errors - All dependencies installed correctly
- Pre-commit hook configuration uses
prepare-commit-msgstage (notcommit-msg) - Workspace recognizes both packages
- No syntax errors in any configuration file
-
.gitignoreincludes necessary Python patterns
Review Questions:
- Does directory structure match architecture.md specification exactly?
- Are all critical configuration values correct (prepare-commit-msg, llamafile/ prefix, port 8080)?
- Are dependency versions compatible and available?
- Is workspace configuration recognizing both packages?
- Are there any missing directories or files from architecture specification?
Reflection Phase:
- Orchestrator reviews foundational setup
- Validates consistency between package structures
- Verifies configuration matches CLAUDE.md critical requirements
- Checks for common pitfalls (commit-msg vs prepare-commit-msg, port 8000 vs 8080)
- User approves foundation before core development begins
Proceed to Priority 2 only after explicit approval
Tasks in this priority depend on Priority 1 completion. Some can run in parallel.
Dependencies: Task A (Directory structure), Task B (Root config), Task D (Package dependencies) Priority: 2 (Core) Complexity: High
Acceptance Criteria:
config.pyimplemented:load_config()function usingtomlkit.load()with text modeConfig,AIConfig,LlamafileConfig,ValidationConfigdataclassesget_config_file()returns XDG-compliant path:~/.config/commit-polish/config.toml- Validates required fields (model starts with
llamafile/, temperature 0.0-1.0, etc.) - Comprehensive docstrings with type hints
ai_service.pyimplemented:AIServiceclass withcomplete()andacomplete()methodsCompletionRequestandCompletionResponsedataclasses- LiteLLM integration with
llamafile/prefix routing - API base:
http://127.0.0.1:8080/v1(port 8080, includes /v1) - Exception handling for
litellm.APIConnectionError,litellm.Timeout,litellm.BadRequestError - CRITICAL: Import exceptions from
litellmNOTlitellm.exceptions
hook.pyimplemented:main()function with correct signature and return codes (0=success, 1=error)- Reads commit message from
sys.argv[1]file path - Delegates to MessageRewriter
- Writes rewritten message back to file
- Error handling with clear messages (config missing, llamafile not running)
message_rewriter.pyimplemented:MessageRewriterclass withrewrite_message()methodRewriteResultdataclass with success, message, attempts, validation_errors- Orchestrates LLM generation with validation feedback loop
- Max retries logic (configurable, default 3)
- Default system prompt for Conventional Commits format
- All modules have:
- Complete type hints (pass
mypy --strict) - Comprehensive docstrings (Google style)
- No placeholder code or TODOs
- Error handling for common failure modes
- Complete type hints (pass
- Linting passes:
uv run ruff check src/ - Type checking passes:
uv run mypy src/
Required Inputs:
- Architecture document sections: "Package 1: commit-polish" component specifications
- CLAUDE.md technical specifications (LiteLLM integration, exception handling)
- Default system prompt from architecture.md
- Configuration schema from architecture.md
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/config.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/ai_service.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/hook.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/message_rewriter.py- All files fully implemented with production-ready code
Can Parallelize With: None - This task must complete before Task F Reason: Validator system depends on these core modules
Verification Steps:
- Type check:
cd packages/commit-polish && uv run mypy src/ - Lint:
cd packages/commit-polish && uv run ruff check src/ - Format check:
cd packages/commit-polish && uv run ruff format --check src/ - Import test:
uv run python -c "from commit_polish import config, ai_service, hook, message_rewriter" - Verify exception imports:
uv run python -c "from litellm import APIConnectionError, Timeout, BadRequestError" - Check for critical pitfalls:
- No imports from
litellm.exceptions - API base uses port 8080 (not 8000)
- Config loader uses text mode ('r') for tomlkit
- Model names require
llamafile/prefix in validation
- No imports from
Dependencies: Task E (Core modules must exist) Priority: 2 (Core) Complexity: High
Acceptance Criteria:
validators/base.pyimplemented:ValidatorProtocol withvalidate()andget_system_prompt_additions()methods- Type hints using
typing.Protocol
validators/detector.pyimplemented:detect_validator()function with auto-detection logic- Searches for commitlint configs (commitlint.config.js, .commitlintrc, .commitlintrc.json, etc.)
- Searches for semantic-release config (release.config.js)
- Searches for commitizen config (.cz.json, .czrc)
- Returns appropriate validator instance or None
validators/commitlint.pyimplemented:CommitlintValidatorclass implementingValidatorprotocolCOMMITLINT_CONFIG_FILESconstant with all config filename variantsvalidate()method runsnpx commitlintsubprocess and parses outputget_system_prompt_additions()extracts allowed types from config- Error handling for missing commitlint or invalid config
validators/semantic_release.pyimplemented (basic):SemanticReleaseValidatorclass implementingValidatorprotocol- Extracts commit types from semantic-release configuration
- Basic validation support
- All validators have:
- Complete type hints
- Comprehensive docstrings
- Error handling for subprocess failures
- No shell=True in subprocess calls (security requirement)
- Linting and type checking pass
Required Inputs:
- Architecture document section: "validators/ (Validator Integration)"
- Task E outputs (core modules for integration)
- Validator configuration file examples from references/commitlint.md
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/validators/__init__.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/validators/base.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/validators/detector.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/validators/commitlint.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/src/commit_polish/validators/semantic_release.py
Can Parallelize With: None - Task G (Unit Tests) depends on this Reason: Tests need validator system to be complete
Verification Steps:
- Type check validators:
uv run mypy src/commit_polish/validators/ - Lint validators:
uv run ruff check src/commit_polish/validators/ - Import test:
uv run python -c "from commit_polish.validators import detect_validator, Validator" - Verify no shell=True usage:
grep -r "shell=True" src/commit_polish/validators/should return empty - Check Protocol implementation:
uv run python -c "from commit_polish.validators.commitlint import CommitlintValidator; from commit_polish.validators.base import Validator; assert isinstance(CommitlintValidator(), Validator)"
Dependencies: Task E (Core modules), Task F (Validator system) Priority: 2 (Core) Complexity: High
Acceptance Criteria:
tests/conftest.pywith shared fixtures:- Mock config fixture
- Mock LiteLLM response fixture
- Temporary file fixtures for commit messages
- Mock validator fixtures
tests/test_config.pywith tests for:- Loading valid TOML configuration
- Handling missing config file
- Handling invalid TOML syntax
- Validating config field requirements (model prefix, temperature range, etc.)
- XDG path resolution
tests/test_ai_service.pywith tests for:- Successful completion request
- APIConnectionError handling (llamafile not running)
- Timeout handling
- BadRequestError handling
- Response parsing
- Mock LiteLLM (use pytest-mock)
tests/test_hook.pywith tests for:- Reading commit message from file
- Writing rewritten message to file
- Return code 0 on success
- Return code 1 on errors (config missing, llamafile down, etc.)
- sys.argv[1] parsing
tests/test_message_rewriter.pywith tests for:- Message generation without validator
- Message generation with validator (valid)
- Message generation with validator (invalid, retries)
- Max retries reached (returns last attempt)
- Validation error feedback to LLM
tests/test_validators/test_detector.pywith tests for:- Commitlint config detection (all file variants)
- Semantic-release config detection
- No config found (returns None)
tests/test_validators/test_commitlint.pywith tests for:- Validation success (valid message)
- Validation failure (invalid message with error parsing)
- Commitlint not installed handling
- System prompt additions extraction
- All tests:
- Use pytest with modern patterns
- Have type hints with pytest fixtures typed
- Follow AAA pattern (Arrange-Act-Assert)
- Use pytest-mock for mocking (not unittest.mock)
- Coverage >80% for tested modules
- Test suite passes:
uv run pytest -v - Coverage report generated:
uv run pytest --cov=commit_polish --cov-report=term
Required Inputs:
- Task E outputs (core modules to test)
- Task F outputs (validator system to test)
- Architecture document section: "Testing Architecture"
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/conftest.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_config.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_ai_service.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_hook.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_message_rewriter.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_validators/test_detector.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/test_validators/test_commitlint.py
Can Parallelize With: None - Completes Priority 2 Reason: Final task in this priority level
Verification Steps:
- Run all tests:
cd packages/commit-polish && uv run pytest tests/ -v - Check coverage:
cd packages/commit-polish && uv run pytest --cov=commit_polish tests/ --cov-report=term - Verify coverage >80%: Check coverage report output
- Run specific test files to verify each module
- Check for flaky tests: Run suite 3 times, all should pass
- Verify no tests marked with
@pytest.mark.skip
Convergence Point: Task E, Task F, Task G must all complete
Quality Gates:
- All core modules fully implemented with type hints and docstrings
- Validator system implements Protocol correctly
- All tests pass:
uv run pytest -v - Coverage >80% for all modules
- Type checking passes:
uv run mypy src/ - Linting passes:
uv run ruff check src/ - No TODO or FIXME comments in code
- Critical specifications verified:
- prepare-commit-msg stage (not commit-msg)
- llamafile/ prefix required for models
- Port 8080 (not 8000) in API base
- Exceptions imported from
litellm(notlitellm.exceptions) - Config uses text mode ('r') for tomlkit
- No shell=True in subprocess calls
Review Questions:
- Does hook.py correctly parse sys.argv[1] for commit message file path?
- Does ai_service.py use correct API base (port 8080, includes /v1)?
- Does message_rewriter.py implement validation feedback loop correctly?
- Do validators run subprocess commands safely (no shell=True)?
- Are all tests realistic and testing actual behavior (not just mocks)?
- Is error handling appropriate for each failure mode?
Reflection Phase:
- Orchestrator reviews hook package implementation
- Verifies integration between core modules and validator system
- Tests hook manually with mock commit message file
- Validates all critical pitfalls have been avoided
- User approves hook package before proceeding to installer
Proceed to Priority 3 only after explicit approval
Tasks in this priority depend on Priority 1 completion but are independent of Priority 2.
Dependencies: Task A (Directory structure), Task B (Root config), Task D (Package dependencies) Priority: 3 (Installer Core) Complexity: High
Acceptance Criteria:
paths.pyimplemented:get_config_dir()returns~/.config/commit-polish(respects XDG_CONFIG_HOME)get_config_file()returns~/.config/commit-polish/config.tomlget_data_dir()returns~/.local/share/commit-polish(respects XDG_DATA_HOME)get_models_dir()returns~/.local/share/commit-polish/modelsget_cache_dir()returns~/.cache/commit-polish(respects XDG_CACHE_HOME)ensure_directories()creates all directories with parents- All functions handle environment variable overrides correctly
llamafile_installer.pyimplemented:LlamafileConfigandModelConfigdataclassesLlamafileInstaller.install_llamafile()method:- Downloads from
https://github.com/mozilla-ai/llamafile/releases/download/0.9.3/llamafile-0.9.3 - Writes to
~/.local/bin/llamafile - chmod 755 (makes executable)
- Progress reporting with Rich
- Downloads from
LlamafileInstaller.install_model()method:- Downloads Gemma 3 3B Q4_K_M from Hugging Face
- URL:
https://huggingface.co/Mozilla/gemma-3-3b-it-gguf/resolve/main/gemma-3-3b-it-Q4_K_M.gguf - Writes to
~/.local/share/commit-polish/models/gemma-3-3b.gguf - Verifies file size (~2GB)
- Progress reporting
- Error handling for network failures with retry logic
- Uses httpx for downloads
config_generator.pyimplemented:ConfigGenerator.generate_config()method- Creates TOML config with
tomlkit.dump() - Opens file in text mode ('w')
- Generated config includes:
[ai]section with model="llamafile/gemma-3-3b", temperature=0.3, max_tokens=200[llamafile]section with paths[validation]section with auto_detect=true, max_retries=3
- Creates parent directories if needed
hook_installer.pyimplemented:HookInstaller.install_hook()method:- Verifies pre-commit is installed
- Runs
pre-commit install --hook-type prepare-commit-msg - Uses subprocess without shell=True
HookInstaller.verify_installation()method:- Checks
.git/hooks/prepare-commit-msgexists - Verifies file contains "pre-commit" reference
- Checks
server_manager.pyimplemented:ServerManager.start_server()method:- Command:
./llamafile --server -m model.gguf --nobrowser --port 8080 --host 127.0.0.1 - Runs in background if requested
- Returns process handle
- Command:
ServerManager.stop_server()method:- Finds process by port 8080 and kills
ServerManager.check_status()method:- Curls http://localhost:8080/health or /v1/models
- Returns True if responding
- All modules have complete type hints, docstrings, error handling
- Linting and type checking pass
Required Inputs:
- Architecture document sections: "Package 2: commit-polish-installer" component specifications
- CLAUDE.md critical URLs and versions
- XDG Base Directory specification from references/
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/paths.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/llamafile_installer.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/config_generator.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/hook_installer.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/server_manager.py
Can Parallelize With: None - Task I depends on this Reason: CLI needs core modules to orchestrate
Verification Steps:
- Type check:
cd packages/commit-polish-installer && uv run mypy src/ - Lint:
cd packages/commit-polish-installer && uv run ruff check src/ - Import test:
uv run python -c "from commit_polish_installer import paths, llamafile_installer, config_generator, hook_installer, server_manager" - Test XDG paths:
uv run python -c "from commit_polish_installer.paths import get_config_file; print(get_config_file())" - Verify URLs are correct (0.9.3 for llamafile, Gemma 3 3B Q4_K_M for model)
- Verify port 8080 (not 8000) in server_manager
- Verify no shell=True in subprocess calls
- Check tomlkit usage: Text mode ('w') is used with
tomlkit.dump()
Dependencies: Task H (Installer core modules) Priority: 3 (Installer CLI) Complexity: Medium
Acceptance Criteria:
cli.pyimplemented with Typer:app = typer.Typer()instance createdinstall()command implemented:- Options: --model (default="gemma-3-3b"), --start-server (default=True), --dry-run (default=False)
- Orchestrates: llamafile download → model download → config generation → hook installation → optional server start
- Rich progress reporting for each step
- Error handling with actionable messages
server()command implemented:- Argument: action (start|stop|status)
- Delegates to ServerManager
- Rich status output
config()command implemented:- Options: --show, --edit
- Shows current config or opens in $EDITOR
- All commands have:
- Complete help text
- Type hints using Annotated from typing_extensions
- Error handling with Rich error panels
- Dry-run support for install command
- Entry point registered in pyproject.toml:
commit-polish-install = "commit_polish_installer.cli:app" - CLI can be invoked:
uv run --package commit-polish-installer commit-polish-install --help
Required Inputs:
- Task H outputs (core installer modules)
- Architecture document section: "cli.py (CLI Interface)"
- Typer and Rich documentation from references/
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/src/commit_polish_installer/cli.py
Can Parallelize With: None - Task J depends on this Reason: Tests need CLI implementation
Verification Steps:
- Type check CLI:
uv run mypy src/commit_polish_installer/cli.py - Lint CLI:
uv run ruff check src/commit_polish_installer/cli.py - Test help:
uv run --package commit-polish-installer commit-polish-install --help - Test install help:
uv run --package commit-polish-installer commit-polish-install install --help - Test dry-run:
uv run --package commit-polish-installer commit-polish-install install --dry-run - Verify Rich formatting displays correctly
Dependencies: Task H (Core modules), Task I (CLI) Priority: 3 (Installer Tests) Complexity: High
Acceptance Criteria:
tests/conftest.pywith shared fixtures:- Temporary directory fixtures
- Mock httpx fixtures for downloads
- Mock subprocess fixtures for pre-commit/llamafile commands
tests/test_paths.pywith tests for:- XDG path resolution (config, data, cache)
- Environment variable override (XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME)
- Directory creation
tests/test_llamafile_installer.pywith tests for:- Llamafile download (mock httpx)
- Model download (mock httpx)
- File permissions (chmod 755)
- Retry logic on network failures
- File size verification
tests/test_config_generator.pywith tests for:- Config generation with correct structure
- TOML validation of generated config
- Text mode used ('w')
- Parent directory creation
tests/test_hook_installer.pywith tests for:- pre-commit installation command (mock subprocess)
- Installation verification
- pre-commit not installed handling
tests/test_cli.pywith tests for:- Install command with --dry-run
- Server command (start/stop/status)
- Config command (show/edit)
- Help text rendering
- Error handling with Rich panels
- All tests pass:
uv run pytest -v - Coverage >70% for installer modules
Required Inputs:
- Task H outputs (core modules to test)
- Task I outputs (CLI to test)
- Architecture document section: "Testing Architecture"
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/conftest.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/test_paths.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/test_llamafile_installer.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/test_config_generator.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/test_hook_installer.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/test_cli.py
Can Parallelize With: None - Completes Priority 3 Reason: Final task in this priority level
Verification Steps:
- Run all tests:
cd packages/commit-polish-installer && uv run pytest tests/ -v - Check coverage:
cd packages/commit-polish-installer && uv run pytest --cov=commit_polish_installer tests/ --cov-report=term - Verify coverage >70%
- Test httpx mocking is realistic
- Test subprocess mocking captures correct commands
- Check for flaky tests: Run suite 3 times
Convergence Point: Task H, Task I, Task J must all complete
Quality Gates:
- All installer core modules fully implemented
- CLI commands functional with Rich formatting
- All tests pass:
uv run pytest -v - Coverage >70% for installer modules
- Type checking passes:
uv run mypy src/ - Linting passes:
uv run ruff check src/ - No TODO or FIXME comments in code
- Critical specifications verified:
- Llamafile version 0.9.3
- Gemma 3 3B Q4_K_M model
- Port 8080 for server (not 8000)
- XDG-compliant paths
- prepare-commit-msg hook type
- No shell=True in subprocess calls
- Text mode ('w') for TOML files with tomlkit
Review Questions:
- Does installer download correct llamafile version (0.9.3)?
- Does installer download correct model (Gemma 3 3B Q4_K_M)?
- Does config_generator create valid TOML with llamafile/ prefix?
- Does hook_installer use --hook-type prepare-commit-msg?
- Does server_manager start server on port 8080?
- Are all XDG paths implemented correctly with environment variable support?
- Is error handling appropriate with actionable user messages?
Reflection Phase:
- Orchestrator reviews installer package implementation
- Tests install command with --dry-run to verify orchestration
- Validates all URLs and versions are correct
- Checks for common pitfalls in installer logic
- User approves installer package before proceeding to integration testing
Proceed to Priority 4 only after explicit approval
Final tasks requiring both packages to be complete.
Dependencies: Task G (Hook tests complete), Task J (Installer tests complete) Priority: 4 (Integration) Complexity: High
Acceptance Criteria:
packages/commit-polish/tests/integration/directory created- Integration test files:
test_end_to_end_hook.py: Tests full commit message rewriting flow- Creates temporary git repo
- Creates mock config file
- Mocks LiteLLM responses
- Invokes hook with commit message file
- Verifies rewritten message
test_validator_integration.py: Tests hook with real validator configs- Creates commitlint.config.js in test repo
- Tests validation loop with valid/invalid messages
- Verifies retry logic
test_hook_without_config.py: Tests error handling when config missing- Verifies appropriate error message
- Verifies exit code 1
packages/commit-polish-installer/tests/integration/directory created- Integration test files:
test_install_flow.py: Tests full installation process- Mocks httpx downloads
- Mocks subprocess calls (pre-commit install)
- Verifies all files created in correct locations
- Verifies config file contents
test_dry_run.py: Tests dry-run mode- Verifies no files actually created
- Verifies progress messages displayed
- All integration tests:
- Use temporary directories (pytest tmp_path fixture)
- Clean up after themselves
- Can run independently in any order
- Pass consistently:
uv run pytest tests/integration/ -v
- Security verification test:
- Grep for shell=True across entire codebase (should find none)
- Verify all subprocess calls use list arguments
- Cross-package integration test:
- Tests that installer-generated config can be loaded by hook
- Verifies config structure compatibility
Required Inputs:
- Task E, F outputs (hook implementation)
- Task H, I outputs (installer implementation)
- Architecture document section: "Testing Architecture"
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/integration/test_end_to_end_hook.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/integration/test_validator_integration.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/tests/integration/test_hook_without_config.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/integration/test_install_flow.py/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/tests/integration/test_dry_run.py- Security verification passing
Can Parallelize With: Task L (Documentation) can start while integration tests are being written Reason: Documentation doesn't depend on test completion, only on code existence
Verification Steps:
- Run hook integration tests:
cd packages/commit-polish && uv run pytest tests/integration/ -v - Run installer integration tests:
cd packages/commit-polish-installer && uv run pytest tests/integration/ -v - Run all tests (unit + integration):
uv run pytest -vfrom workspace root - Security check:
grep -r "shell=True" packages/should return empty - Verify tests are independent: Run tests in random order with pytest-random-order
- Check integration test cleanup: No leftover files in /tmp after tests
Dependencies: Task K (Integration tests verify system works) Priority: 4 (Documentation) Complexity: Medium
Acceptance Criteria:
README.mdcreated at workspace root with:- Project overview and features
- Installation instructions (uvx, uv tool install, pipx)
- Quick start guide
- Configuration documentation (with example config.toml)
- Usage examples
- Troubleshooting section (common errors and solutions)
- Architecture diagram reference
- Links to architecture.md and CLAUDE.md
packages/commit-polish/README.mdcreated with:- Hook-specific documentation
- API documentation for modules
- Configuration schema
- Pre-commit hook setup instructions
- Manual testing instructions
packages/commit-polish-installer/README.mdcreated with:- Installer-specific documentation
- CLI command reference
- Server management guide
- Uninstallation instructions
- All documentation:
- Uses code blocks with language specifiers
- Has working examples (verified manually)
- Links are valid (no 404s)
- Markdown linting passes:
markdownlint-cli2 "**/*.md"
- Documentation covers common pitfalls from architecture.md:
- prepare-commit-msg vs commit-msg
- llamafile/ prefix requirement
- Port 8080 vs 8000
- Exception import location
- Text mode for TOML files with tomlkit
Required Inputs:
- All implemented code from Priority 2 and 3
- Architecture document (for reference and diagrams)
- CLAUDE.md (for development workflow)
- Common pitfalls section from architecture.md
Expected Outputs:
/home/ubuntulinuxqa2/repos/commit-polish/README.md/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish/README.md/home/ubuntulinuxqa2/repos/commit-polish/packages/commit-polish-installer/README.md- All markdown files pass linting
Can Parallelize With: None - Final task in implementation plan Reason: Last priority task
Verification Steps:
- Validate markdown:
markdownlint-cli2 "**/*.md"(install if needed:npm install -g markdownlint-cli2) - Check all links: Use markdown-link-check or manual verification
- Verify code examples are accurate (check against actual code)
- Test installation instructions manually
- Verify troubleshooting section covers common errors
- Ensure README.md has clear project value proposition
Convergence Point: Task K (Integration tests), Task L (Documentation) must complete
Quality Gates:
- All unit tests pass:
cd packages/commit-polish && uv run pytest -v - All installer tests pass:
cd packages/commit-polish-installer && uv run pytest -v - All integration tests pass for both packages
- Coverage >80% for hook package, >70% for installer package
- Type checking passes for both packages:
uv run mypy . - Linting passes for both packages:
uv run ruff check . - Security check passes: No shell=True found in codebase
- Documentation is complete and accurate
- All markdown files pass linting
- Common pitfalls verified avoided:
- All config files use prepare-commit-msg (not commit-msg)
- All model references use llamafile/ prefix
- All API bases use port 8080 (not 8000)
- All exceptions imported from litellm (not litellm.exceptions)
- All TOML operations use text mode ('r'/'w') with tomlkit
- No subprocess calls use shell=True
Review Questions:
- Can orchestrator successfully run end-to-end integration test?
- Does generated config from installer work correctly with hook?
- Are all error messages actionable for users?
- Is documentation clear enough for external users?
- Have all critical specifications been verified in code?
- Are there any remaining TODOs or FIXMEs?
- Is the codebase ready for manual testing with real llamafile server?
Reflection Phase:
- Orchestrator performs full system review
- Validates all quality gates passed
- Reviews documentation for completeness
- Confirms no critical pitfalls exist in implementation
- Prepares for manual integration testing with real llamafile server
- User approves project completion
Next Steps After Approval:
- Manual testing with real llamafile server
- Test full flow: install → start server → make commit
- Test with real commitlint configuration
- Performance testing (commit message generation time)
- Prepare for alpha release
Before marking this plan as executed, orchestrator must verify:
Plan Structure:
- No temporal language (weeks, sprints, hours, days, deadlines, timelines)
- All tasks have explicit dependencies (or "None")
- All tasks have acceptance criteria
- All tasks identify parallelization opportunities
- Sync checkpoints between priorities
- YAML frontmatter with version and task checkboxes
Task Completeness:
- Every task has: Dependencies, Priority, Complexity
- Every task has: Acceptance Criteria (specific, measurable)
- Every task has: Required Inputs, Expected Outputs
- Every task has: Parallelization markers with rationale
- Every task has: Verification Steps
Quality Gates:
- Sync checkpoints include quality gates
- Review questions guide reflection
- Approval required before priority transitions
Orchestration Readiness:
- Plan enables orchestrator to delegate tasks to specialist agents
- Acceptance criteria enable agent self-verification
- Dependencies enable orchestrator to sequence work correctly
- Parallelization markers enable horizontal scaling
Critical Specifications Covered:
- prepare-commit-msg stage (not commit-msg)
- llamafile/ prefix for model names
- Port 8080 (not 8000) for llamafile server
- Exception imports from litellm (not litellm.exceptions)
- Text mode ('r'/'w') for TOML file operations with tomlkit
- No shell=True in subprocess calls
- XDG-compliant configuration paths
- Validation feedback loop with max retries
- Llamafile version 0.9.3
- Gemma 3 3B Q4_K_M model
This implementation plan coordinates AI agent swarm execution for commit-polish development:
4 Priority Levels:
- Priority 1 (Foundation): 4 parallel tasks - project structure, config files, hook config, dependencies
- Priority 2 (Hook Implementation): 3 sequential tasks - core modules, validators, tests
- Priority 3 (Installer Implementation): 3 sequential tasks - core modules, CLI, tests
- Priority 4 (Integration): 2 tasks - integration tests (parallel with Task L), documentation
12 Total Tasks with clear dependency chains and convergence points
4 Sync Checkpoints with quality gates ensuring:
- Foundation consistency before core development
- Hook package completion before installer dependencies
- Installer package completion before integration testing
- Full project completion before release preparation
Key Architectural Constraints Enforced:
- Hook MUST use prepare-commit-msg stage (enables message rewriting)
- Models MUST use llamafile/ prefix (enables LiteLLM routing)
- Server MUST use port 8080 (llamafile default, not 8000)
- Exceptions MUST import from litellm root (not litellm.exceptions)
- TOML files MUST use text mode ('r'/'w') with tomlkit
- Subprocess MUST NOT use shell=True (security requirement)
Parallelization Strategy:
- Priority 1: All 4 tasks run concurrently (foundational setup)
- Priority 2: Task E blocks Task F blocks Task G (dependency chain)
- Priority 3: Task H blocks Task I blocks Task J (dependency chain)
- Priority 4: Task K and Task L can overlap (documentation during testing)
This plan enables efficient agent swarm execution while maintaining code quality and architectural consistency throughout development.