This is a lightweight ZSH tool that generates git commit messages using various AI providers (Anthropic, OpenAI, Gemini, Ollama). The codebase is pure shell script with zero runtime dependencies.
# Run all tests
./run-tests.zsh
# Run specific test directory
./run-tests.zsh tests/providers
# Run single test file
zsh tests/providers/anthropic.test.zsh- Tests are located in
tests/directory - Provider-specific tests in
tests/providers/ - Test helper utilities in
tests/test_helper.zsh - Custom ZSH-based testing framework with mocking support
- Follow existing test patterns in test files
- Use
test_helper.zshfunctions for assertions and mocking - Each test should have proper setup/teardown
- Mock external commands (curl, jq) rather than making real API calls
- Run all tests:
./run-tests.zsh - Verify shellcheck passes (runs automatically in CI)
- Test your changes manually with different providers
- Ensure no API keys or sensitive data are committed
- Follow existing ZSH scripting patterns
- Use meaningful variable names with proper scoping
- Add error handling for all external commands
- Keep functions small and focused
- Maintain backwards compatibility with older ZSH versions
When adding/modifying AI providers:
- Implement provider in
lib/providers/directory - Add comprehensive tests in
tests/providers/ - Update documentation if adding new configuration options
- Test with actual API calls (use your own keys)
- Ensure provider follows the standard interface:
{provider}_check_requirementsfunction{provider}_generate_commit_messagefunction accepting diff and status
- Adding a new provider: Copy existing provider pattern, add tests
- Modifying commit generation: Update provider logic and test with various diff formats
- Changing main script logic: Update
zsh-git-ai.plugin.zshand test intests/main.test.zsh
- This is a shell-only project - no Node.js, Python, or other runtimes
- Keep the codebase lightweight
- Preserve zero-dependency philosophy (jq is optional)
- CI runs on every PR - ensure tests pass before merging
- All providers should gracefully handle missing jq by falling back to sed/grep