diff --git a/plugins/claude/ai-commit/.claude-plugin/plugin.json b/plugins/claude/ai-commit/.claude-plugin/plugin.json index aff2008..ddb22db 100644 --- a/plugins/claude/ai-commit/.claude-plugin/plugin.json +++ b/plugins/claude/ai-commit/.claude-plugin/plugin.json @@ -1,8 +1,9 @@ { "name": "ai-commit", "description": "Generate Git commit messages from staged diffs and apply them automatically, using git-ai-commit as the execution backend.", - "version": "0.1.0", + "version": "0.2.0", "author": { "name": "Naoto Takai" - } + }, + "repository": "https://github.com/takai/git-ai-commit" } diff --git a/plugins/claude/ai-commit/README.md b/plugins/claude/ai-commit/README.md index 5bfd119..9b505fb 100644 --- a/plugins/claude/ai-commit/README.md +++ b/plugins/claude/ai-commit/README.md @@ -9,10 +9,16 @@ A Claude Code plugin that organizes git changes into atomic, logical commits usi ## Installation -Clone this repository into your Claude Code plugins directory: +If you installed `git-ai-commit` via `go install`, the plugin is already available at `plugins/claude/ai-commit/` inside the source tree. + +To register it with Claude Code, add the plugin directory to your project or global settings: ```bash -git clone https://github.com/takai/git-ai-commit-plugin ~/.claude/plugins/git-ai-commit-plugin +# If you have the git-ai-commit source cloned +claude --plugin-dir /path/to/git-ai-commit/plugins/claude/ai-commit + +# Or symlink into your plugins directory +ln -s /path/to/git-ai-commit/plugins/claude/ai-commit ~/.claude/plugins/ai-commit ``` ## Usage @@ -20,7 +26,7 @@ git clone https://github.com/takai/git-ai-commit-plugin ~/.claude/plugins/git-ai In any git repository with Claude Code, run: ``` -/ai-commit:organize-commits +/ai-commit:organize ``` The plugin will: @@ -31,16 +37,7 @@ The plugin will: ## Commands -### `/ai-commit:organize-commits` - -Organizes pending changes into multiple atomic commits. The command: - -- Examines current git status and diffs -- Groups related changes together -- Stages files/hunks for each logical unit -- Invokes `git ai-commit` to generate commit messages automatically - -### `/ai-commit:commit-staged` +### `/ai-commit:staged` Commits only the currently staged changes. The command: @@ -48,6 +45,22 @@ Commits only the currently staged changes. The command: - Does not stage, unstage, or modify any files - Invokes `git ai-commit` to generate the commit message automatically +### `/ai-commit:all` + +Stages all pending changes and commits them as a single commit. The command: + +- Stages all tracked and untracked changes with `git add -A` +- Invokes `git ai-commit` to generate the commit message automatically + +### `/ai-commit:organize` + +Organizes pending changes into multiple atomic commits. The command: + +- Examines current git status and diffs +- Groups related changes together +- Stages files for each logical unit +- Invokes `git ai-commit` to generate commit messages automatically + ## License MIT diff --git a/plugins/claude/ai-commit/commands/all.md b/plugins/claude/ai-commit/commands/all.md new file mode 100644 index 0000000..b6e0b0a --- /dev/null +++ b/plugins/claude/ai-commit/commands/all.md @@ -0,0 +1,31 @@ +--- +allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git ai-commit:*) +context: fork +description: Stage and commit all changes using git-ai-commit +argument-hint: "" +--- + +## Context + +- Current git status: !`git status` +- Staged diff: !`git diff --staged` +- Unstaged diff: !`git diff` +- Current branch: !`git branch --show-current` +- Recent commits: !`git log --oneline -10 2>/dev/null || true` + +## Your task + +Stage **all** pending changes (both staged and unstaged) and create a single Git commit. + +Follow these rules strictly: + +- If there are no staged or unstaged changes, do nothing. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt a commit. +- Stage all changes with `git add -A`. +- Generate and apply the commit by invoking `git ai-commit`. +- Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. +- Do not manually write a commit message and run `git commit` directly. +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. +- Do not output explanations or confirmations. + +Respond with tool invocations only. diff --git a/plugins/claude/ai-commit/commands/organize-commits.md b/plugins/claude/ai-commit/commands/organize.md similarity index 69% rename from plugins/claude/ai-commit/commands/organize-commits.md rename to plugins/claude/ai-commit/commands/organize.md index f4c3522..6e1d54d 100644 --- a/plugins/claude/ai-commit/commands/organize-commits.md +++ b/plugins/claude/ai-commit/commands/organize.md @@ -2,6 +2,7 @@ allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git add:*), Bash(git reset:*), Bash(git ai-commit:*), Bash(git log:*) context: fork description: Organize changes into atomic commits using git-ai-commit +argument-hint: "" --- ## Context @@ -10,6 +11,7 @@ description: Organize changes into atomic commits using git-ai-commit - Staged diff: !`git diff --staged` - Unstaged diff: !`git diff` - Current branch: !`git branch --show-current` +- Recent commits: !`git log --oneline -10 2>/dev/null || true` ## Your task @@ -26,13 +28,20 @@ You must create multiple commits if needed. Prefer small, coherent commits over 2) Execute loop (repeat for each logical unit) - Step A: Identify the exact files or hunks that belong to one unit. - Step B: Stage only that unit. - - Prefer partial staging with `git add -p ` when a file contains mixed changes. - - If you staged something by mistake, fix it with `git reset -p ` (or `git reset ` if appropriate). + - Use `git add ` to stage entire files. + - When a file contains changes belonging to different logical units, stage the whole file in the unit where the majority of changes belong. + - If you staged something by mistake, fix it with `git reset `. - Step C: Create the commit by invoking `git ai-commit`. - Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. - Do not manually write a commit message and run `git commit` directly. - Step D: Repeat until `git status` is clean (no staged or unstaged changes). +### Safety rules + +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt commits. +- Do not loop more than 20 iterations. If changes remain after 20 commits, stop and report. + ### Output rules - Respond with tool invocations only (no explanations, no confirmations). diff --git a/plugins/claude/ai-commit/commands/commit-staged.md b/plugins/claude/ai-commit/commands/staged.md similarity index 74% rename from plugins/claude/ai-commit/commands/commit-staged.md rename to plugins/claude/ai-commit/commands/staged.md index f8dc277..31acbe0 100644 --- a/plugins/claude/ai-commit/commands/commit-staged.md +++ b/plugins/claude/ai-commit/commands/staged.md @@ -1,7 +1,8 @@ --- allowed-tools: Bash(git status:*), Bash(git diff:*), Bash(git ai-commit:*) context: fork -description: Commit staged changes only using git-ai-commit +description: Commit staged changes using git-ai-commit +argument-hint: "" --- ## Context @@ -19,9 +20,11 @@ Follow these rules strictly: - Do NOT stage, unstage, or modify any files. - If there are no staged changes, do nothing. +- If the repository is in a merge, rebase, or cherry-pick state, stop immediately and report the state. Do not attempt a commit. - Generate and apply the commit by invoking `git ai-commit`. - Pass a short, human-readable summary via `--context` that describes the intent and the logical unit of this commit. - Do not manually write a commit message and run `git commit` directly. +- If `git ai-commit` fails, stop immediately and report the error. Do not retry. - Do not output explanations or confirmations. Respond with tool invocations only.