From 2e1300047f457eeaac8a387f56d9f4c58e10124f Mon Sep 17 00:00:00 2001 From: Codebug53 Date: Thu, 27 Aug 2026 17:05:54 +0530 Subject: [PATCH] updated: for git commit iq subcommand specification --- Commands.md | 18 ++++++++ etc/bash_completion.sh | 53 ++++++++++++++++++++++ etc/git-extras-completion.zsh | 84 +++++++++++++++++++++++++++++++++++ etc/git-extras.fish | 21 +++++++++ 4 files changed, 176 insertions(+) diff --git a/Commands.md b/Commands.md index 87b6da6..818ac30 100644 --- a/Commands.md +++ b/Commands.md @@ -494,7 +494,25 @@ $ git commits-since yesterday ... changes since yesterday TJ Holowaychuk - Fixed readme ``` +## git commitiq +Semantic commit summaries as a git subcommand. Runs `git commit` and then asks a configured LLM to produce a structured JSON summary of the diff, stored as a git note. + +```bash +$ git commitiq -m "fix login bug" +``` + +Set up a provider: + +```bash +$ git commitiq setup --provider anthropic --api-key sk-ant-... --model claude-3-5-sonnet-latest +``` + +View a stored summary: + +```bash +$ git commitiq show a1b2c3 +``` ## git count Output commit count: diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index 06fd02e..2197861 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -218,3 +218,56 @@ _git_stamp(){ _git_undo(){ __gitcomp "--hard --soft -h -s" } + +_git_commitiq(){ + local cur prev commands subcmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + commands="commit setup config notes-enable push show log help" + + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $(compgen -W "$commands" -- "$cur") ) + return 0 + fi + + case "${COMP_WORDS[1]}" in + config) + subcmds="get set unset list" + if [ $COMP_CWORD -eq 2 ]; then + COMPREPLY=( $(compgen -W "$subcmds" -- "$cur") ) + return 0 + fi + case "${COMP_WORDS[2]}" in + get|set|unset) + if [ $COMP_CWORD -eq 3 ]; then + COMPREPLY=( $(compgen -W "provider model api_key endpoint command" -- "$cur") ) + return 0 + fi + ;; + esac + ;; + setup) + if [[ "$cur" == --* ]]; then + COMPREPLY=( $(compgen -W "--provider --api-key --model --endpoint --command --skip-verify" -- "$cur") ) + return 0 + fi + case "$prev" in + --provider) + COMPREPLY=( $(compgen -W "anthropic openai gemini ollama local cli" -- "$cur") ) + return 0 + ;; + esac + ;; + push) + _git_push + ;; + show) + if [ $COMP_CWORD -eq 2 ]; then + COMPREPLY=( $(compgen -f -- "$cur") ) + return 0 + fi + ;; + esac +} \ No newline at end of file diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index c6aab46..ee11ef1 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -488,3 +488,87 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ utimes:'change files modification time to their last commit date' \ unwip:'undo a WIP commit' \ wip:'create a WIP commit' + + + +# git-commitiq completion +_commitiq_commands() { + local commands=( + 'commit:Run a real git commit, then attach an LLM summary as a git note' + 'setup:Interactive or non-interactive provider setup' + 'config:Manage provider/model/API-key configuration' + 'notes-enable:Configure this repo so git push/fetch also sync git notes' + 'push:Push like git push, also syncing git notes' + 'show:Print the stored JSON summary from git notes' + 'log:List commits that have a stored summary' + 'help:Show usage information' + ) + _describe 'command' commands +} + +_commitiq_config_commands() { + local commands=( + 'get:Show a config value' + 'set:Change a config value' + 'unset:Remove a config value' + 'list:Show current config' + ) + _describe 'config command' commands +} + +_commitiq_config_keys() { + local keys=( + 'provider:LLM provider (anthropic|openai|gemini|ollama|local|cli)' + 'model:Model name' + 'api_key:API key' + 'endpoint:Custom endpoint URL' + 'command:CLI command for cli provider' + ) + _describe 'config key' keys +} + +_git-commitiq() { + local curcontext="$curcontext" state line + + _arguments -C \ + '1:command:_commitiq_commands' \ + '*::arg:->args' + + case $state in + args) + case $line[1] in + config) + _arguments -C \ + '1:config command:_commitiq_config_commands' \ + '*::arg:->config_args' + + case $words[1] in + get|set|unset) + _arguments \ + '1:config key:_commitiq_config_keys' + ;; + esac + ;; + setup) + _arguments \ + '--provider[LLM provider]:provider:(anthropic openai gemini ollama local cli)' \ + '--api-key[API key]:api key:' \ + '--model[Model name]:model:' \ + '--endpoint[Custom endpoint URL]:endpoint:' \ + '--command[CLI command for cli provider]:command:' \ + '--skip-verify[Skip credential validation]' + ;; + push) + _git_push + ;; + show) + _arguments \ + '1:sha or prefix:' + ;; + esac + ;; + esac +} + +zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ + commitiq:'semantic commit summaries as a git subcommand' \ No newline at end of file diff --git a/etc/git-extras.fish b/etc/git-extras.fish index 5104b27..7dc56a1 100644 --- a/etc/git-extras.fish +++ b/etc/git-extras.fish @@ -218,3 +218,24 @@ complete -c git -x -n '__fish_git_using_command release' -l no-empty-commit -d ' # undo complete -c git -x -n '__fish_git_using_command undo' -s s -l soft -d 'only rolls back the commit but changes remain un-staged' complete -c git -x -n '__fish_git_using_command undo' -s h -l hard -d 'wipes your commit(s)' + +# commitiq +complete -c git-commitiq -f -n '__fish_use_subcommand' -a commit -d 'Run a real git commit, then attach an LLM summary' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a setup -d 'Interactive or non-interactive provider setup' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a config -d 'Manage provider/model/API-key configuration' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a notes-enable -d 'Configure notes push/fetch sync' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a push -d 'Push like git push, also syncing git notes' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a show -d 'Print the stored JSON summary from git notes' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a log -d 'List commits that have a stored summary' +complete -c git-commitiq -f -n '__fish_use_subcommand' -a help -d 'Show usage information' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from config' -a get -d 'Show a config value' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from config' -a set -d 'Change a config value' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from config' -a unset -d 'Remove a config value' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from config' -a list -d 'Show current config' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from get set unset' -a 'provider model api_key endpoint command' +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l provider -d 'LLM provider' -r +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l api-key -d 'API key' -r +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l model -d 'Model name' -r +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l endpoint -d 'Custom endpoint URL' -r +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l command -d 'CLI command for cli provider' -r +complete -c git-commitiq -f -n '__fish_seen_subcommand_from setup' -l skip-verify -d 'Skip credential validation' \ No newline at end of file