An open API service indexing awesome lists of open source software.

https://github.com/brbousnguar/ai-git-flow-cli

AI-powered scripts for generating commit messages and release notes using local Ollama — includes a Next.js web app
https://github.com/brbousnguar/ai-git-flow-cli

ai automation git local-ai nextjs ollama

Last synced: about 1 month ago
JSON representation

AI-powered scripts for generating commit messages and release notes using local Ollama — includes a Next.js web app

Awesome Lists containing this project

README

          

# AI Local Git Flow

CLI tools for AI-assisted Git workflows in Git Bash and PowerShell.

## Commands

The intended setup is through aliases in `~/.bashrc`:

```bash
alias ai-commit='node /d/Projects/RocheBB/Tools/ai-local-git-flow/bin/ai-commit.js'
alias ai-release='node /d/Projects/RocheBB/Tools/ai-local-git-flow/bin/ai-release.js'
```

Reload Git Bash after editing `~/.bashrc`, or run:

```bash
source ~/.bashrc
```

You can also run the tools from this repository:

```bash
npm run ai-commit --
npm run ai-release --
```

## PowerShell setup

From this repository, register the local CLI package once:

```powershell
npm link
```

This creates `ai-commit.ps1` and `ai-release.ps1` shims in your npm user command folder, for example:

```powershell
C:\Users\\AppData\Roaming\npm
```

Make sure that folder is on your PowerShell `PATH`, then restart PowerShell or open a new terminal. After that, run the commands from any Git repository:

```powershell
ai-commit --yes -t SFSC-1573 -m "implement SSO authentication"
ai-release
```

If your execution policy blocks npm `.ps1` shims, run the CLI through npm from this repo instead:

```powershell
npm run ai-commit -- --yes -t SFSC-1573 -m "implement SSO authentication"
npm run ai-release --
```

## Install

```bash
npm install
```

## Configuration

Configuration is loaded from `config.json`.

For OpenAI cloud usage, create `.env` next to the scripts:

```env
OPENAI_API_KEY=sk-your-key
```

Optional JIRA enrichment for ticket-aware commit generation:

```env
JIRA_BASE_URL=https://your-company.atlassian.net
JIRA_EMAIL=your.email@company.com
JIRA_API_TOKEN=your-token
```

Use `config.json` to switch providers:

```json
{
"provider": "cloud"
}
```

or:

```json
{
"provider": "local",
"local": {
"default": "qwen2.5-coder:14b",
"baseURL": "http://localhost:11434/v1",
"endpoints": [
{
"name": "mac-mini-m4-pro",
"baseURL": "http://192.168.1.95:11434/v1",
"default": "qwen3-coder:30b-64k",
"models": {
"devstral:24b-64k": "Mac Mini model for complex implementation and reasoning",
"qwen3-coder:30b-64k": "Mac Mini default for coding, diffs, and workflow generation"
}
},
{
"name": "local",
"baseURL": "http://localhost:11434/v1",
"default": "qwen2.5-coder:14b"
}
]
}
}
```

When `local.endpoints` is configured, the CLI tries them in order. The Mac Mini Ollama server is checked first, then the local machine is used as fallback. Each endpoint can keep its own default model list, so Mac Mini models do not need to match local models.

You can override the configured AI runtime for a single CLI run:

```bash
ai-commit --cloud
ai-commit --ollama-auto
ai-commit --local-ollama
ai-commit --hosted-ollama
ai-commit --provider cloud --model gpt-5.1-codex-mini
ai-commit --ollama-url http://localhost:11434/v1 --model qwen2.5-coder:14b
```

Runtime options are supported by both `ai-commit` and `ai-release`:

- `--provider `: override `config.json` provider selection
- `--cloud`: use OpenAI cloud for this run
- `--ollama-auto`: use configured Ollama endpoints and fallback order, for example Mac Mini first and this machine second
- `--local-ollama`: use only this machine's localhost Ollama endpoint, skipping Mac Mini
- `--hosted-ollama`: use only non-localhost Ollama endpoints from `local.endpoints`
- `--model `: override the configured model for this run
- `--ollama-url `: use one explicit Ollama-compatible `/v1` base URL for this run

## ai-commit

Generates branch-name variants, commit-message variants, GitHub labels, commits staged changes, pushes the branch, and creates a PR.

Stage files first:

```bash
git add
```

Run the workflow:

```bash
ai-commit
```

Common options:

```bash
ai-commit -m "new feature, add customer request endpoint"
ai-commit -t SFSC-1573 -m "new feature, implement SSO authentication"
ai-commit -l "bug,enhancement" -m "hotfix, critical security patch"
ai-commit -m "update RAML customer request type" -n bug
ai-commit --yes -t SFSC-1573 -m "implement SSO authentication"
ai-commit --dry-run --local-ollama
ai-commit --dry-run --local-ollama --stream --progress
```

Options:

- `-t, --ticket `: ticket or issue number, for example `SFSC-1573`
- `-m, --message `: context for branch naming and commit message generation
- `-l, --labels `: comma-separated GitHub labels
- `-n, --exclude-label `: exclude a label from suggestions and PR creation
- `-d, --debug`: print LLM request details
- `--debug-context`: print context windows used for generation
- `--dry-run`: generate and select branch/commit values without renaming the branch, committing, pushing, or creating a PR
- `--progress`: print heartbeat messages while waiting for local model calls
- `--stream`: stream raw local Ollama output tokens while they are generated; also enables `--progress`
- `--think`: enable local Ollama thinking mode; by default the CLI disables thinking for faster structured branch and commit generation
- `-y, --yes`: non-interactive mode; choose variant 1 for the branch and commit message

When `-m, --message` is provided, that developer context is treated as the highest-priority intent. JIRA and diff context are skipped for generation so naming and commit wording stay aligned with the supplied message.

For AI agents such as Codex or Claude, prefer staging the intended files first and then running:

```bash
npm run ai-commit -- --yes -t SFSC-1573 -m "short implementation context"
```

The `--yes` flag keeps the workflow non-interactive while still using this CLI for branch naming, commit messages, labels, push, and PR creation.

Branch and commit generation use split context windows:

- Branch names use `prompts/branch-naming.md` plus JIRA ticket context, unless `-m` is provided. If neither `-m` nor JIRA context is available, branch names are inferred from the staged git diff.
- Commit messages use `prompts/commit-message.md` plus the staged git diff, unless `-m` is provided.

When a JIRA ticket is provided, the ticket type is used to correct GitHub labels: Task/Tache maps to `enhancement`, and Bug maps to `bug`. Explicit `-l, --labels` values still take priority.

## ai-release

Generates release PR title and notes by comparing the development branch with the production branch.

```bash
ai-release
ai-release -v v1.1.23
ai-release -l "release,enhancement"
ai-release --debug
```

The script auto-detects:

- production branch: `main` or `master`
- development branch: `develop` or `dev`

It fetches remotes, summarizes commit messages grouped by ticket ID, then can create the release PR through GitHub CLI.

Use `-d, --debug` to print release LLM request details.

## Automatic GitHub Releases

When a pull request from `develop` into `main` is merged, GitHub Actions creates the next patch tag and a GitHub Release with generated release notes.

Examples:

- No existing tags: creates `v1.0.0`
- Latest tag `v1.0.0`: creates `v1.0.1`
- Latest tag `v1.2.9`: creates `v1.2.10`

The workflow can also be run manually from the GitHub Actions tab.

## Requirements

- Node.js 18+
- Git
- GitHub CLI (`gh`) authenticated for PR creation
- OpenAI API key or local Ollama-compatible endpoint

## Runtime

- Node.js ES modules
- OpenAI SDK
- `dotenv`
- Git CLI
- GitHub CLI (`gh`)
- Optional JIRA REST enrichment for commit generation through `.env`

## Project Files

- `bin/ai-commit.js`: commit workflow CLI
- `bin/ai-release.js`: release PR workflow CLI
- `src/ai-common.js`: shared config, OpenAI/Ollama client, token usage, console formatting
- `config.json`: provider/model/pricing configuration
- `prompts/branch-naming.md`: branch naming rules used in prompts
- `prompts/commit-message.md`: commit message rules used in prompts