feat: add smart git commit CLI with OpenAI and codex backends #1

Merged
caleb-brown merged 2 commits from codex/explain-specifying-reasoning-level into dev 2026-03-05 20:35:05 -05:00
Owner

Summary

This PR introduces smart-git-commit, a Python CLI for generating three conventional commit message options from the currently staged git changes. It supports both direct OpenAI-compatible API calls and the codex CLI, can optionally include commit bodies, and can commit the selected option interactively.

What Changed

  • Added packaging and CLI entrypoints for both sgc and smart-git-commit
  • Implemented staged git diff collection, including file status, diff stats, and truncated patch content
  • Added commit message generation through an OpenAI-compatible chat completions backend
  • Added an alternative codex backend that uses codex exec with schema-constrained output
  • Added strict response parsing and validation to enforce JSON output, three distinct options, and conventional commit formatting
  • Added a retry/repair flow when the first model response is invalid
  • Added optional subject-plus-body generation alongside subject-only mode
  • Added an interactive --commit flow to choose one of the generated options and run git commit
  • Added persistent config management via sgc config init/show/set/unset
  • Added config resolution precedence across CLI flags, environment variables, config file values, and defaults
  • Documented installation, configuration, environment variables, providers, and usage examples in the README
  • Added unit tests covering API behavior, CLI flows, config handling, and git helper logic

Notes

  • The openai-api provider requires an API key and model to be configured
  • The codex provider requires the codex CLI to be installed and already authenticated

Test Coverage

  • Added API tests for payload construction, output parsing, retry behavior, and Codex execution
  • Added CLI tests for config commands, generation flows, provider selection, and interactive commit behavior
  • Added config tests for validation, precedence, redaction, and persistence
  • Added git helper coverage for patch truncation
## Summary This PR introduces `smart-git-commit`, a Python CLI for generating three conventional commit message options from the currently staged git changes. It supports both direct OpenAI-compatible API calls and the `codex` CLI, can optionally include commit bodies, and can commit the selected option interactively. ## What Changed - Added packaging and CLI entrypoints for both `sgc` and `smart-git-commit` - Implemented staged git diff collection, including file status, diff stats, and truncated patch content - Added commit message generation through an OpenAI-compatible chat completions backend - Added an alternative `codex` backend that uses `codex exec` with schema-constrained output - Added strict response parsing and validation to enforce JSON output, three distinct options, and conventional commit formatting - Added a retry/repair flow when the first model response is invalid - Added optional subject-plus-body generation alongside subject-only mode - Added an interactive `--commit` flow to choose one of the generated options and run `git commit` - Added persistent config management via `sgc config init/show/set/unset` - Added config resolution precedence across CLI flags, environment variables, config file values, and defaults - Documented installation, configuration, environment variables, providers, and usage examples in the README - Added unit tests covering API behavior, CLI flows, config handling, and git helper logic ## Notes - The `openai-api` provider requires an API key and model to be configured - The `codex` provider requires the `codex` CLI to be installed and already authenticated ## Test Coverage - Added API tests for payload construction, output parsing, retry behavior, and Codex execution - Added CLI tests for config commands, generation flows, provider selection, and interactive commit behavior - Added config tests for validation, precedence, redaction, and persistence - Added git helper coverage for patch truncation
requested review from kip-taylor 2026-03-05 20:22:27 -05:00
caleb-brown changed target branch from main to dev 2026-03-05 20:34:50 -05:00
caleb-brown deleted branch codex/explain-specifying-reasoning-level 2026-03-05 20:35:06 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: caleb-brown/smart-git-commit#1
No description provided.