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
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
Expand All @@ -27,20 +27,17 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Cache Maven
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Run Tests
run: mvn test

- name: Build JAR
run: mvn clean package -DskipTests
run: mvn verify -DskipNativeBuild=true

- name: Test Native Compilation
run: mvn clean package -Pnative -DskipTests
run: mvn clean package -DskipTests

- name: Test Binary (Unix)
if: runner.os != 'Windows'
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
Expand All @@ -36,14 +36,14 @@ jobs:
native-image-job-reports: 'true'

- name: Cache Maven
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Build Native Binary
run: mvn clean package -Pnative -DskipTests
run: mvn clean verify

- name: Rename Artifact (Unix)
if: runner.os != 'Windows'
Expand All @@ -66,7 +66,7 @@ jobs:
"$($hash.Hash.ToLower()) ai-commit-${{ matrix.platform }}.exe" | Out-File -Encoding ASCII ai-commit-${{ matrix.platform }}.exe.sha256

- name: Upload Artifacts
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: ai-commit-${{ matrix.platform }}
path: |
Expand All @@ -83,24 +83,19 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Download Artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
path: artifacts
merge-multiple: true

- name: Display Structure
run: ls -R artifacts || ls -R .

- name: Prepare Release Files
run: |
mkdir -p release-files
find . -name "ai-commit-*" -type f -exec cp {} release-files/ \;

- name: Create Release
uses: softprops/action-gh-release@v2
uses: softprops/action-gh-release@v3
with:
files: |
artifacts/**/*
Expand All @@ -113,13 +108,17 @@ jobs:
**Linux:**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ai-commit-linux-amd64 -o ai-commit
curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ai-commit-linux-amd64.sha256 -o ai-commit-linux-amd64.sha256
sha256sum -c ai-commit-linux-amd64.sha256
chmod +x ai-commit
sudo mv ai-commit /usr/local/bin/
```

**macOS:**
```bash
curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ai-commit-macos-amd64 -o ai-commit
curl -L https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/ai-commit-macos-amd64.sha256 -o ai-commit-macos-amd64.sha256
shasum -a 256 -c ai-commit-macos-amd64.sha256
chmod +x ai-commit
sudo mv ai-commit /usr/local/bin/
```
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ ai-commit-*-amd64*

# GraalVM
graal_isolate.h
graal_isolate_dynamic.h
graal_isolate_dynamic.h

# Audit dossier (local-only, never push)
findings/
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Breaking
- Interactive confirmation is now fail-closed: empty input, end-of-stream, or read errors cancel the commit (`[c]` default). Explicit `y`/`yes` is required to commit.
- `hasStagedChanges()` now propagates git failures instead of returning `false`; non-repositories and timeouts surface as errors.
- Diffs over 64KB, containing secrets, binary content, or generated lockfiles are refused before any AI call.

### Security
- Secret redaction: staged diffs are scanned locally (API keys, private keys, JWTs, bearer tokens, credential assignments, credentialed URLs) and blocked findings never leave the machine; only rule IDs, lengths, and fingerprints are logged.
- Provider base URLs validated: https required except loopback unless `AI_ALLOW_INSECURE_HTTP=true`; credentials in URLs rejected.
- AI credentials (`*_API_KEY`, `AI_*`) stripped from git hook environments.
- Dependency CVEs fixed: Spring AI 1.1.0 to 1.1.8 (CVE-2026-22738, CVE-2026-40967, CVE-2026-41705, CVE-2026-47835), Jackson 2.20.1 to 2.21.7 (CVE-2026-54512, CVE-2026-54514, CVE-2026-68497).
- Installers verify release SHA256 checksums, use `mktemp`/random temp names, validate version format, support `AI_COMMIT_VERSION` pinning and `--verify-only` mode.
- Residual risk: Spring AI CVE-2026-47851/47852/59294/59318 have no OSS 1.1.x fix (Enterprise 1.1.9 only); affected components (PDF outline reader, ONNX cache, tool-calling fallback, resource cache) are not used by this CLI.

### Changed
- `AI_COMMAND_TIMEOUT` is the canonical git timeout setting; `AI_TIMEOUT` remains as a deprecated alias with a warning.
- `config --auto-commit/--auto-push` reject invalid values instead of silently treating them as off.
- AI providers use bounded timeouts (10s connect, 60s read, 120s for Ollama) and a 512-token output cap; 401/429/timeout/DNS failures map to actionable errors.
- Single staged-diff fetch per run; bounded process capture; release builds run `mvn clean verify` (tests + coverage gate, no skips).
- Dependency hygiene: slf4j 2.0.20, JUnit 6.1.3, Mockito 5.23.0, maven-compiler 3.15.0, maven-shade 3.6.2, maven-surefire 3.5.6, native-maven-plugin 0.11.5.
- GitHub Actions moved to Node 24 runtimes: checkout v5, cache v5, upload-artifact v6, download-artifact v7, gh-release v3 (setup-graalvm v1 already current).

### Technical
- JaCoCo 0.8.15 enforces 90% line + branch coverage on `verify` (currently 96.2% line, 90.5% branch across 168 tests).
- CI runs `mvn verify -DskipNativeBuild=true`; release runs `mvn clean verify`.

## [1.2.0] - 2025-11-29

### Added
Expand Down
36 changes: 22 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ So I built this. A standalone CLI that works everywhere, supports any OpenAI-com

### Option 1: One-Line Installer (Easiest)

Installers verify the release SHA256 checksum before installing. Pin a version with `AI_COMMIT_VERSION=vX.Y.Z`, or verify without installing via `--verify-only`.

**Linux/macOS:**
```bash
curl -fsSL https://raw.githubusercontent.com/kxng0109/ai-commit-cli/main/install.sh | bash
Expand All @@ -70,6 +72,8 @@ Download the pre-built binary for your platform from [Releases](https://github.c
**Linux:**
```bash
curl -L https://github.com/kxng0109/ai-commit-cli/releases/latest/download/ai-commit-linux-amd64 -o ai-commit
curl -L https://github.com/kxng0109/ai-commit-cli/releases/latest/download/ai-commit-linux-amd64.sha256 -o ai-commit-linux-amd64.sha256
sha256sum -c ai-commit-linux-amd64.sha256
chmod +x ai-commit
sudo mv ai-commit /usr/local/bin/
ai-commit --version
Expand All @@ -95,15 +99,15 @@ ai-commit --version

**Requirements:**
- GraalVM 25 (with native-image)
- Apache Maven 3.9.11
- Apache Maven 3.9.16
- Java 25

**Steps:**
```bash
git clone https://github.com/kxng0109/ai-commit-cli.git
cd ai-commit-cli

mvn clean package -Pnative
mvn clean verify

# Binary location: target/ai-commit (or ai-commit.exe on Windows)
sudo cp target/ai-commit /usr/local/bin/ # Linux/macOS
Expand All @@ -115,7 +119,7 @@ ai-commit --version
**Development build (JAR, faster):**
```bash
mvn clean package
java -jar target/ai-commit-cli-1.0.0.jar --version
java -jar target/ai-commit-cli-1.2.0.jar --version
```

## Quick Start
Expand Down Expand Up @@ -166,7 +170,8 @@ ai-commit
| Variable | Default | Range |
|----------|---------|-------|
| `AI_TEMPERATURE` | 0.1 | 0.0 - 2.0 |
| `AI_COMMAND_TIMEOUT` | 30 | 1 - 3600 seconds |
| `AI_COMMAND_TIMEOUT` | 30 | 1 - 3600 seconds (`AI_TIMEOUT` still works as a deprecated alias) |
| `AI_ALLOW_INSECURE_HTTP` | false | Set `true` only to allow plain-http AI endpoints for non-local hosts |
| `AI_LOG_LEVEL` | WARN | ERROR, WARN, INFO, DEBUG |

### User Preferences (Persistent)
Expand Down Expand Up @@ -215,14 +220,17 @@ Implement Google OAuth2 integration with JWT token handling
and secure session management.
────────────────────────────────────────────────────────────

Commit with this message? (y)es / (r)egenerate / (e)dit / (c)ancel [y]:
Commit with this message? (y)es / (r)egenerate / (e)dit / (c)ancel [c]:
```

Fail-closed by design: empty input, end-of-stream, or a read error cancels
the commit. Only an explicit `y`/`yes` commits.

**Options:**
- **`y` (yes)** - Commit with the AI-generated message (default, just press Enter)
- **`y`/`yes`** - Commit with the AI-generated message (explicit confirmation required)
- **`r` (regenerate)** - Generate a new message with different wording
- **`e` (edit)** - Manually edit the message before committing
- **`c` (cancel)** - Cancel and don't commit
- **`e` (edit)** - Manually edit the message before committing (`c` at the edit prompt cancels)
- **`c` (cancel)** - Cancel and don't commit (default, just press Enter)

### Auto-Commit Mode

Expand Down Expand Up @@ -501,17 +509,17 @@ ai-commit config --auto-commit on
```bash
# Build JAR (fast iteration)
mvn clean package
java -jar target/ai-commit-cli-1.0.0.jar
java -jar target/ai-commit-cli-1.2.0.jar

# Build native binary
mvn clean package -Pnative
# Build native binary (GraalVM required; JaCoCo gate enforced via verify)
mvn clean verify

# Run with debug logging
export AI_LOG_LEVEL=DEBUG
./target/ai-commit

# Run tests
mvn test
# Run tests with the 90% line+branch coverage gate
mvn verify -DskipNativeBuild=true
```

## FAQ
Expand All @@ -523,7 +531,7 @@ A: It's excellent for IntelliJ users, but it limits you to their provider select
A: Honestly, it's your choice. For instance, I use OpenRouter mainly since you can get really good models for free and have access to a lot of models with just one API key. Then I use ollama (or LM Studio) just for testing. You can get professional grade models, but you're limited by your system's hardware.

**Q: Does this send my code to AI providers?**
A: It sends the git diff (changes only), not your entire codebase. Use Ollama for fully local processing with zero external API calls.
A: It sends the git diff (changes only), not your entire codebase. Before sending, the diff is scanned locally: secrets (API keys, private keys, tokens, credentialed URLs), binary content, generated lockfiles, and diffs over 64KB are refused and never leave your machine. Provider base URLs must be https except for loopback hosts. Use Ollama for fully local processing with zero external API calls.

**Q: When should I use auto-commit vs interactive mode?**
A: Use **auto-commit** for rapid development when you trust the AI (small, frequent commits). Use **interactive mode** when you want to review messages carefully (large changes, important commits).
Expand Down
39 changes: 30 additions & 9 deletions TEST_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Test Suite Summary

## Total Tests: 56
## Total Tests: 168

JaCoCo gate on `verify`: 90% line + branch minimum (currently 96.2% line, 90.5% branch).

---

Expand Down Expand Up @@ -61,14 +63,14 @@
## Running Tests

```bash
# Run all tests
mvn test
# Run all tests with the coverage gate (skips native-image; needs JDK 25)
mvn verify -DskipNativeBuild=true

# Run a specific test class
mvn test -Dtest=ConfigTest
mvn test "-Dtest=ConfigTest" "-Djacoco.skip=true"

# Skip tests during build
mvn package -DskipTests
# Full native build (GraalVM 25 required)
mvn clean verify
```

## Test Dependencies
Expand All @@ -77,19 +79,25 @@ mvn package -DskipTests
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>6.0.1</version>
<version>6.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.20.0</version>
<version>5.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.20.0</version>
<version>5.23.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.7</version>
<scope>test</scope>
</dependency>
```
Expand All @@ -99,11 +107,24 @@ mvn package -DskipTests
| Class | Tests | Coverage |
|---------------------------|-------|---------------------------------------------|
| ConfigTest | 9 | ~100% provider/config logic and guards |
| ConfigPolicyTest | 10 | URL policy, loopback, truthy, timeout range |
| ConfigParsingTest | 10 | temperature/timeout parsing, isConfigured |
| UserPreferencesTest | 10 | ~100% preference/state/formatting |
| AiCommitCliTest | 4 | toggle parsing, error description |
| AiCommitCliRunTest | 18 | run() paths: version/help/config/commit-flow|
| AiProviderFactoryTest | 4 | ~100% provider selection/prioritization |
| AiProviderFactoryReliabilityTest | 6 | per-provider type, output caps, priority |
| GitServiceTest | 6 | ~90% public GitService usage scenarios |
| GitServiceEnvTest | 2 | secret env scrubbing |
| GitServiceValidationTest | 7 | timeout/dir/message validation |
| GitServiceWorkingDirTest | 6 | directory resolution matrix |
| GitServiceProcessTest | 8 | timeout/interrupt/truncation/process errors |
| SecretScannerTest | 17 | secret patterns, caps, summary hygiene |
| CommitServiceTest | 15 | ~95% workflow, interactive, AI |
| CommitServiceAutoPushTest | 12 | ~100% all auto-commit/push paths |
| CommitServiceGuardTest | 9 | fail-closed consent, diff policy |
| CommitServiceReliabilityTest | 9 | AI error mapping, null stages, interrupt |
| CommitServiceEdgeTest | 6 | null diff/output, 5xx, edit edges |

---

Expand Down
Loading
Loading