Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#!/bin/sh
# Run linting and build to ensure code quality and dist is up to date

# Get list of staged files before linting
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM)

# Run linting (which may modify files)
bun run lint
bun run build

# Re-stage any files that were modified by linting
if [ -n "$STAGED_FILES" ]; then
echo "$STAGED_FILES" | while IFS= read -r file; do
if [ -f "$file" ]; then
git add "$file"
fi
done
fi
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ npm install -D @arittr/commitment
# 2. Set up git hooks (automatic)
npx commitment init

# Or configure with a specific AI agent
npx commitment init --agent gemini

# 3. Make changes and commit
git add .
git commit # Message generated automatically!
Expand Down Expand Up @@ -159,6 +162,12 @@ commitment supports multiple hook managers:
| **simple-git-hooks** | `npx commitment init --hook-manager simple-git-hooks` | Lightweight alternative to husky |
| **Plain Git Hooks** | `npx commitment init --hook-manager plain` | No dependencies |

**Configure default agent:**
```bash
npx commitment init --agent gemini # Use Gemini by default
npx commitment init --agent codex # Use Codex by default
```

See [docs/HOOKS.md](./docs/HOOKS.md) for detailed hook integration guide.

## Troubleshooting
Expand Down
11 changes: 9 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,23 @@ async function main(): Promise<void> {
.command('init')
.description('Initialize commitment hooks in your project')
.option('--hook-manager <type>', 'Hook manager to use: husky, simple-git-hooks, plain')
.option('--agent <name>', 'AI agent to use: claude, codex, gemini (default: claude)')
.option('--agent <name>', 'Default AI agent for hooks: claude, codex, gemini')
.option('--cwd <path>', 'Working directory', process.cwd())
.action(
async (options: {
cwd: string;
hookManager?: 'husky' | 'simple-git-hooks' | 'plain';
agent?: 'claude' | 'codex' | 'gemini';
}) => {
// Parse --agent manually from process.argv due to Commander.js subcommand option conflict
const agentFlagIndex = process.argv.indexOf('--agent');
const agentValue =
agentFlagIndex >= 0 && agentFlagIndex < process.argv.length - 1
? (process.argv[agentFlagIndex + 1] as 'claude' | 'codex' | 'gemini')
: undefined;

await initCommand({
agent: options.agent,
agent: agentValue,
cwd: options.cwd,
hookManager: options.hookManager,
});
Expand Down
3 changes: 3 additions & 0 deletions src/cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ export async function initCommand(options: InitOptions): Promise<void> {
// Print next steps
console.log('');
console.log(chalk.green('🎉 Setup complete!'));
if (options.agent !== undefined) {
console.log(chalk.cyan(` Default agent: ${options.agent}`));
}
console.log('');
console.log(chalk.cyan('Next steps:'));
console.log(chalk.white(' 1. Stage your changes: ') + chalk.gray('git add .'));
Expand Down