This repository is a single-binary Go CLI. main.go contains command dispatch, terminal UI helpers, Git integration, Groq API calls, credential storage, and commit-planning logic. Module metadata lives in go.mod. Distribution is handled by Makefile, .goreleaser.yml, and .github/workflows/release.yml.
Keep new behavior consistent with the existing approval-driven commit and push flow.
make build # build binary with version from git describe
make fmt # run gofmt on main.go
make clean # remove local binary
make release-dry # test GoReleaser build locally without publishingOr with Go directly:
go build -ldflags="-X main.version=dev" -o gitpilot .
go run . help
gofmt -w main.go
go build ./...If Go cache writes fail in restricted environments, use GOCACHE=/tmp/gocache go build ./....
Follow standard Go formatting and naming: tabs, PascalCase for exported identifiers, camelCase for internal helpers. Prefer focused helpers for UI (printPanel, printSection), Git operations, and AI prompts instead of growing one large command function further.
Terminal UX matters here. Preserve the modern CLI style: structured panels, concise status messages, and explicit confirmation prompts before any mutating Git action.
API key resolution order (highest to lowest priority):
GROQ_API_KEYenvironment variable — for CI/CD- OS keychain — macOS Keychain (
securityCLI), Linux GNOME Keyring (secret-tool), Windows Credential Manager (PowerShell) ~/.config/gitpilot/credentials— chmod 0600 fallback file
The auth command manages keys:
gitpilot auth login # hidden input, validates key, stores in keychain or credentials file
gitpilot auth logout # removes from keychain and credentials file
gitpilot auth status # shows active source and masked keyDo not store the API key in git config (gitpilot.groq-api-key is deprecated). Never log or print the key in full — use maskKey() for display.
GROQ_MODELenv var orgitpilot.groq-modelgit config key sets the model (default:llama-3.3-70b-versatile)gitpilot initwritesgitpilot.initializedandgitpilot.groq-modelto local git configgitpilot config showdisplays active key source and model
There is no automated test suite yet. Validate changes with targeted manual runs:
gitpilot version
gitpilot auth login
gitpilot auth status
gitpilot auth logout
gitpilot help
gitpilot diff
gitpilot init
gitpilot pull
gitpilot pushTest the installer end-to-end without a GitHub release:
sh install-test.shFor commit-flow changes, test both missing-key behavior and an approval/cancel path. Add *_test.go files for pure helpers where practical.
Releases are fully automated. On every pushed tag matching v*, GitHub Actions runs GoReleaser which builds 5 binaries (linux/darwin amd64+arm64, windows amd64), generates checksums.txt, and publishes a GitHub Release.
git tag v1.x.x
git push origin v1.x.xTo test the release pipeline locally without publishing:
make release-dryUse short imperative commit subjects with conventional prefixes: feat:, fix:, refactor:, chore:, docs:, ci:. PRs should include the user-facing behavior change, the commands used for verification, and terminal snippets when CLI output changed.