This package is called AI GCM and it is responsible for performing an
artificial intelligence git commit -am <message> where the <message>
shall become the output of a prompt request made to the AI Provider of
your choice including Ollama. The summarize package is
used in conjunction with this application.
If you have a summaries/ directory with valid summary.*.md files therein,
the aigcm will use that for the context of the request.
This is capable of having project-aware capabilities to ask it to create
single-sentence summaries of the STDIN with the anticipation that it's going
to be come a git commit -m "<message>" where I use AI
to populate the <message>.
Easy one-line to auto-commit new changes with meaningful message:
git add --all && git diff --staged | aigcm | git commit -a -F -
Easy one-line to auto-commit new changes to the last commit:
git add --all && git diff --staged | aigcm | git commit --amend -F -
go install github.com/andreimerlescu/aigcm@latest# do something
# don't run `git add` them yet
# if you do, then you need to run `git diff --staged | aigcm`
# reuse the output to reduce duplicate calls to the LLM
output=$(git diff | aigcm)
echo -e "${output}"
read -r -p "Commit this? [y|n*] " commit_this
if [ "${commit_this}" =~ /^y|Y/ ]; then
git commit -m "${output}"
fi
# or if you trust the AI lol (bruh... terminator... yeshua saves us all!!!)
git diff | aigcm | git commit -a -F - # diff unstaged only with add
git diff | aigcm | git commit -F - # diff unstaged
git diff --staged | aigcm | git commit -a -F - # staged diff with add
git diff --staged | aigcm | git commit -F - # staged diff
# lets say that aigcm spits back a stupid output, or lets say you change a file
# and want to update the commit message...
git diff --staged | aigcm | git commit --amend -F -
[hotfix/stateman-workflow ad197d6] Renamed a GITHUB_ENV variable name to align with artifact upload naming conventions in the Terraform state reporting workflow.
1 file changed, 1 insertion(+)
As you can see from the above example, the aigcm command is designed to run without passing any arguments into it,
however, that doesn't mean that there aren't a ton of configurables that aren't falling back to defaults that leverage
Ollama and the qwen3:8b model via the http://127.0.0.1:11434 API and the gollm package.
In order to understand the usage of this binary outside of the default -h that you can pass into it to get:
aigcm -hUsage of aigcm (powered by figtree v2.0.14):
-api-key [String] AI API Key to use for query (leave empty for ollama)
-caching[=true] [Bool] Enable LLM caching
-max-tokens[=3000] [Int] AI Max Tokens to use for query
-memory[=36963] [Int] AI Memory to use for query
-model[=qwen3:8b] [String] AI Model to use for query
-provider[=ollama] [String] AI Provider to use. (eg. ollama, openai, claude)
-seed[=-1] [Int] AI Seed to use for query
-summaries[=summaries] [String] Path to your summaries
-timeout[=77s] [UnitDuration] AI Timeout on each request allowed
-v[=false] [Bool] Display binary version
Therefore, when understanding how this connects to the actual Go application, you can see the breakdown of Variable to
Type with the corresponding data-point where the pattern used demonstrates consumption of the
goenv/env and
figtree/v2 package.
| Variable | Type | Default Value |
|---|---|---|
| dAlwaysDebug | bool | false |
| dAiSeed | int | -1 |
| dAiMaxTokens | int | 3000 |
| dAiProvider | string | ollama |
| dAiModel | string | qwen3:8b |
| dCachingEnabled | bool | true |
| dMemory | int | 36963 |
| dTimeout | time.Duration | 77 |
| dTimeoutUnit | time.Duration | time.Second |
This package uses the goenv/env package in order to connect ENV variables
using env.String(eAiProvider, dAiProvider)
| Variable | Type | Environment Variable |
|---|---|---|
| eAiProvider | string | AI_GCM_PROVIDER |
| eAiModel | string | AI_GCM_MODEL |
| eAiApiKey | string | AI_GCM_API_KEY |
| eAiMaxTokens | string | AI_GCM_MAX_TOKENS |
| eAiSeed | string | AI_GCM_SEED |
| eAiMemory | string | AI_GCM_MEMORY |
| eAiAlwaysEnableCache | string | AI_GCM_ENABLE_CACHE |
| eAiGlobalTimeout | string | AI_GCM_GLOBAL_TIMEOUT |
This package uses the figtree package in order to provide a command line interface.
| Variable | Type | Command Line Argument |
|---|---|---|
| kShowVersion | string | -v |
| kAiProvider | string | -provider |
| kAiModel | string | -model |
| kAiApiKey | string | -api-key |
| kAiMaxTokens | string | -max-tokens |
| kAiSeed | string | -seed |
| kMemory | string | -memory |
| kAiCachingEnabled | string | -caching |
| kAiTimeout | string | -timeout |
| kSummaries | string | -summaries |
The manner in which these gets registered to the flag package via figtree is through the env.<Type>(k<Property>, d<Property>) strategy.
This makes using <Type> in the figtree like *figs.<Type>(k<Property>) and you know that it'll at least have d<Property of <Type> assigned to it.
One strategy that I use for the aigcm package, instead of typing out:
git diff --staged | aigcm | git commit -a -F -
Is to use a helper script instead, which is why the install_helper.sh has been added. In here, once executed, four
new binaries will be installed in the /usr/local/bin under the names of:
- No changes to staging workspace
-
gcaiaka ai git commit (read as GC AI) -
gcsaiaka staged ai git commit (read as G CS AI) -
gcmaiaka amended ai git commit (read as G CM AI) -
gmsaiaka amend staged ai git commit (read as G MS AI)
-
- Includes all changes to staging workspace
-
gacaiaka add all & ai git commit (read as GA C AI) -
gacsaiaka add all & staged ai git commit (read as GA CS AI) -
gacmaiaka add all & amended ai git commit (read as GA CM AI) -
gamsaiaka add all & amend staged ai git commit (read as GA MS AI)
-
So to simplify the matrix of command's naming conventions:
- G is for git
- C is for commit
- GC is for git commit
- GA is for git add
- CS is for commit staged
- CM is for amend commit
- MS is for amend staged
- AI is for artificial intelligence
8 commands that have 8 keys that unlock all 8 capabilities.
When using these helpers (bash shell scripts) on your host (supports any OS that supports bash 5.2+), you'll see:
$ gcsai
Received: Added aigcm usage examples and installed scripts for automated commit message generation.
Use? [y|n]
When you provide the y that its looking for, you'll see:
[master 211d58a] Added aigcm usage examples and installed scripts for automated commit message generation.
2 files changed, 114 insertions(+)
create mode 100755 install_helper.sh