commitar 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- commitar-1.0.0/LICENSE +21 -0
- commitar-1.0.0/PKG-INFO +292 -0
- commitar-1.0.0/README.md +272 -0
- commitar-1.0.0/commitar/__init__.py +3 -0
- commitar-1.0.0/commitar/ai.py +150 -0
- commitar-1.0.0/commitar/cli.py +302 -0
- commitar-1.0.0/commitar/config.py +141 -0
- commitar-1.0.0/commitar/errors.py +14 -0
- commitar-1.0.0/commitar/git.py +90 -0
- commitar-1.0.0/commitar/scope.py +47 -0
- commitar-1.0.0/commitar.egg-info/PKG-INFO +292 -0
- commitar-1.0.0/commitar.egg-info/SOURCES.txt +19 -0
- commitar-1.0.0/commitar.egg-info/dependency_links.txt +1 -0
- commitar-1.0.0/commitar.egg-info/entry_points.txt +2 -0
- commitar-1.0.0/commitar.egg-info/requires.txt +9 -0
- commitar-1.0.0/commitar.egg-info/top_level.txt +1 -0
- commitar-1.0.0/pyproject.toml +49 -0
- commitar-1.0.0/setup.cfg +4 -0
- commitar-1.0.0/tests/test_ai.py +62 -0
- commitar-1.0.0/tests/test_config.py +51 -0
- commitar-1.0.0/tests/test_scope.py +237 -0
commitar-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 André Argôlo (argolo.dev)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
commitar-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitar
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Gerador seguro de mensagens e commits Git com IA
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Repository, https://github.com/argolo/commitar
|
|
7
|
+
Project-URL: Homepage, https://argolo.dev
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Requires-Dist: typer>=0.12
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
14
|
+
Requires-Dist: mypy>=1.11; extra == "dev"
|
|
15
|
+
Requires-Dist: pip-audit>=2.7; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
17
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# Commitar
|
|
22
|
+
|
|
23
|
+
**Commitar** is a Python CLI that generates [Conventional Commits](https://www.conventionalcommits.org/) messages with AI and can optionally create Git commits. Its core principle is preserving the staging area: when the index already has changes, only those changes are considered.
|
|
24
|
+
|
|
25
|
+
Portuguese documentation is available in [README-PT.md](README-PT.md).
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Safe preview by default: no changes are made without `--output commit`.
|
|
30
|
+
- One-line Conventional Commit messages.
|
|
31
|
+
- OpenAI, Gemini, and Ollama support.
|
|
32
|
+
- File, directory, or whole-repository scope.
|
|
33
|
+
- Staging isolation, including partially staged files.
|
|
34
|
+
- TOML, environment-variable, and flag configuration.
|
|
35
|
+
- Colored feedback, a generation spinner, and elapsed time per message.
|
|
36
|
+
- Configurable AI timeout; the default is 60 seconds.
|
|
37
|
+
|
|
38
|
+
## Requirements
|
|
39
|
+
|
|
40
|
+
- Python 3.11 or later.
|
|
41
|
+
- Git installed and a Git repository initialized.
|
|
42
|
+
- A configured AI provider:
|
|
43
|
+
- OpenAI: `OPENAI_API_KEY`;
|
|
44
|
+
- Gemini: `GEMINI_API_KEY`;
|
|
45
|
+
- Ollama: a local service running with an installed model.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip3 install commitar
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For development, install the test dependencies too:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python -m pip install -e '.[dev]'
|
|
57
|
+
commitar --help
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Quick start
|
|
61
|
+
|
|
62
|
+
Configure your Git identity if necessary:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git config user.name "Your Name"
|
|
66
|
+
git config user.email "you@example.com"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Preview tracked changes:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
commitar
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
When there is no staging, Commitar generates a preview for each changed file. The preview lists the source, files, suggested message, and generation time.
|
|
76
|
+
|
|
77
|
+
Untracked files are ignored for safety. Include them explicitly:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
commitar --include-added
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Create commits after a single confirmation:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
commitar src/ --output commit
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For automation, skip the interaction:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
commitar src/ --output commit --yes
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
To create one commit from files explicitly selected with `git add`:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
git add src/moon_service.py tests/test_moon_service.py
|
|
99
|
+
commitar --output commit
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
With existing staging, Commitar exclusively uses `git diff --cached`, generates one message, and creates a commit containing exactly the files in the index.
|
|
103
|
+
|
|
104
|
+
Use `--message` to skip the AI provider call. The value must be a valid one-line Conventional Commit:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
commitar app.py --include-added \
|
|
108
|
+
--message "feat: add moon phase endpoint" \
|
|
109
|
+
--output commit --yes
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Staging safety
|
|
113
|
+
|
|
114
|
+
The behavior is deliberately conservative.
|
|
115
|
+
|
|
116
|
+
| Situation | Behavior |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| Staged files exist and `commitar` runs without a `PATH` | One message is generated from `git diff --cached`; the commit contains exactly the current index. |
|
|
119
|
+
| Staged files exist and a `PATH` is supplied | The command fails without changing the repository. |
|
|
120
|
+
| No staging and no `PATH` is supplied | One group is created for each changed file. |
|
|
121
|
+
| No staging and a file/directory is supplied | One group contains that file or all eligible files in the directory. |
|
|
122
|
+
| A file is partially staged | Only its index version is committed; remaining worktree changes stay intact. |
|
|
123
|
+
|
|
124
|
+
In path mode, Commitar verifies that the index remains empty before each commit. If another process changes staging, the operation stops to prevent changes from being mixed.
|
|
125
|
+
|
|
126
|
+
## Command reference
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
commitar [OPTIONS] [PATH]
|
|
130
|
+
commitar config init [OPTIONS]
|
|
131
|
+
commitar config show [OPTIONS]
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
| Option | Description |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `PATH` | A file or directory inside the worktree. With no value, one changed file is grouped at a time. |
|
|
137
|
+
| `--output preview` | Displays the preview; this is the default. |
|
|
138
|
+
| `--output commit` | Requests confirmation and creates commits. |
|
|
139
|
+
| `--dry-run` | Alias for `--output preview`. |
|
|
140
|
+
| `--yes`, `-y` | Does not request confirmation in `commit` mode. |
|
|
141
|
+
| `--message TEXT` | Uses a manual message without calling the AI. |
|
|
142
|
+
| `--include-added` | Includes untracked files. |
|
|
143
|
+
| `--provider` | Selects `openai`, `gemini`, or `ollama`. |
|
|
144
|
+
| `--model` | Sets the selected provider model. |
|
|
145
|
+
| `--timeout-seconds` | Temporarily overrides the AI timeout. |
|
|
146
|
+
| `--max-input-tokens` | Limits the estimated number of tokens in the full prompt sent to the AI. |
|
|
147
|
+
| `--context-window-tokens` | Sets the shared input and reserved-output context window. |
|
|
148
|
+
| `--config PATH` | Loads an additional TOML file, taking precedence over default files. |
|
|
149
|
+
|
|
150
|
+
Use `commitar --help` and `commitar config --help` for current CLI details.
|
|
151
|
+
|
|
152
|
+
## Configuration
|
|
153
|
+
|
|
154
|
+
Create a configuration template in the repository root:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
commitar config init
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Example `.commitar.toml`:
|
|
161
|
+
|
|
162
|
+
```toml
|
|
163
|
+
[ai]
|
|
164
|
+
provider = "ollama"
|
|
165
|
+
models = ["gemma4:e4b", "qwen2.5-coder:14b"]
|
|
166
|
+
endpoint = "http://localhost:11434/api/generate"
|
|
167
|
+
max_input_tokens = 12000
|
|
168
|
+
context_window_tokens = 32768
|
|
169
|
+
max_output_tokens = 80
|
|
170
|
+
temperature = 0.2
|
|
171
|
+
timeout_seconds = 60
|
|
172
|
+
|
|
173
|
+
[commit]
|
|
174
|
+
language = "pt-BR"
|
|
175
|
+
format = "conventional"
|
|
176
|
+
include_added = false
|
|
177
|
+
output = "preview"
|
|
178
|
+
confirm = true
|
|
179
|
+
|
|
180
|
+
[limits]
|
|
181
|
+
max_files_per_request = 50
|
|
182
|
+
max_diff_bytes = 100000
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`models` accepts up to three models in preference order. If the AI returns an invalid message, Commitar tries the next model, for up to three attempts. `model = "name"` remains supported for a single model; `--model` takes precedence for the current run.
|
|
186
|
+
|
|
187
|
+
The configuration precedence, from highest to lowest, is: CLI flags; the `--config` file; `COMMITAR_*` environment variables; `.commitar.toml` in the repository root; `~/.config/commitar/config.toml`; and built-in defaults.
|
|
188
|
+
|
|
189
|
+
Supported variables are `COMMITAR_PROVIDER`, `COMMITAR_MODEL`, `COMMITAR_LANGUAGE`, `COMMITAR_OUTPUT`, `COMMITAR_ENDPOINT`, `COMMITAR_MAX_DIFF_BYTES`, and `COMMITAR_TIMEOUT_SECONDS`.
|
|
190
|
+
|
|
191
|
+
Credentials are never read from TOML. Use `OPENAI_API_KEY` or `GEMINI_API_KEY`; Ollama normally does not need a key for local use.
|
|
192
|
+
|
|
193
|
+
## AI providers
|
|
194
|
+
|
|
195
|
+
### Ollama
|
|
196
|
+
|
|
197
|
+
| Model | Recommended use |
|
|
198
|
+
| --- | --- |
|
|
199
|
+
| `gemma4:e4b` | A lighter option for general use and resource-constrained machines. |
|
|
200
|
+
| `qwen2.5-coder:14b` | A code-focused option for machines with more memory and processing capacity. |
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
ollama pull gemma4:e4b
|
|
204
|
+
ollama serve
|
|
205
|
+
commitar --provider ollama --model gemma4:e4b
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The default endpoint is `http://localhost:11434/api/generate`.
|
|
209
|
+
|
|
210
|
+
### OpenAI
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
export OPENAI_API_KEY="..."
|
|
214
|
+
commitar --provider openai --model gpt-5-mini
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Gemini
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
export GEMINI_API_KEY="..."
|
|
221
|
+
commitar --provider gemini --model gemini-2.5-flash
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Context limits
|
|
225
|
+
|
|
226
|
+
The context is controlled by four settings: `max_files_per_request` (maximum files per group), `max_diff_bytes` (maximum diff size), `max_input_tokens` (estimated full-prompt limit), and `context_window_tokens` (total input/output window).
|
|
227
|
+
|
|
228
|
+
`max_input_tokens + max_output_tokens` cannot exceed `context_window_tokens`. Input counting is a conservative estimate independent of the provider tokenizer. In Ollama, the context window is sent as `num_ctx` and the output limit as `num_predict`. OpenAI and Gemini validate the window locally before sending the output limit.
|
|
229
|
+
|
|
230
|
+
If the diff exceeds its byte or token limit, Commitar produces a deterministic summary of diff metadata. If that still exceeds a limit, the command fails explicitly; content is never silently truncated.
|
|
231
|
+
|
|
232
|
+
## FastAPI example
|
|
233
|
+
|
|
234
|
+
The [example/](example/) directory contains an asynchronous FastAPI API that returns the approximate Moon phase for an ISO date:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
python -m pip install fastapi uvicorn
|
|
238
|
+
uvicorn example.app:app --reload
|
|
239
|
+
curl 'http://127.0.0.1:8000/moon-phase?date=2026-07-28'
|
|
240
|
+
curl 'http://127.0.0.1:8000/next-moon-phase?phase=lua-cheia&from_date=2026-07-28'
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`/next-moon-phase` accepts `lua-nova`, `crescente`, `quarto-crescente`, `gibosa-crescente`, `lua-cheia`, `gibosa-minguante`, `quarto-minguante`, and `minguante`. The calculation is an approximation based on the average synodic month.
|
|
244
|
+
|
|
245
|
+
## Development and testing
|
|
246
|
+
|
|
247
|
+
Use the `Makefile` to standardize local tasks:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
make help
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
| Command | Purpose |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| `make venv` | Creates the local virtual environment in `.venv`. |
|
|
256
|
+
| `make shell` | Opens a shell with the virtual environment enabled; run `exit` to leave it. |
|
|
257
|
+
| `make install` | Installs Commitar in editable mode and all development dependencies. |
|
|
258
|
+
| `make clear` | Deletes Git-ignored files with `git clean -Xdf`, including `.venv`, `.env`, caches, and builds. |
|
|
259
|
+
| `make build` | Generates the wheel and source distribution in `dist/`. |
|
|
260
|
+
| `make test` | Runs the pytest suite. |
|
|
261
|
+
| `make coverage` | Runs tests and shows uncovered lines. |
|
|
262
|
+
| `make lint` | Checks style, imports, and common issues with Ruff. |
|
|
263
|
+
| `make format` | Formats code with Ruff. |
|
|
264
|
+
| `make typecheck` | Runs static analysis with mypy. |
|
|
265
|
+
| `make audit` | Checks dependencies for known vulnerabilities with pip-audit. |
|
|
266
|
+
| `make check` | Runs linting, type checking, tests, and the audit. |
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
make venv
|
|
270
|
+
make install
|
|
271
|
+
make check
|
|
272
|
+
make build
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
> **Warning:** `make clear` is destructive to ignored files. It also removes virtual environments and local files such as `.env`; back up needed local data.
|
|
276
|
+
|
|
277
|
+
## Troubleshooting
|
|
278
|
+
|
|
279
|
+
| Message / symptom | Recommended action |
|
|
280
|
+
| --- | --- |
|
|
281
|
+
| `No tracked file changes were found...` | Only new files exist. Run `commitar --include-added` to include them in the preview. |
|
|
282
|
+
| `There are no eligible changed files in this scope.` | There are no changes in the supplied scope; modify a tracked file or provide another path. |
|
|
283
|
+
| `There are staged changes...` | Run without a `PATH` to commit only the index, or clear/commit staging before supplying a path. |
|
|
284
|
+
| Provider timeout | Commitar retries up to three times across configured models. Check the service and increase `timeout_seconds`. |
|
|
285
|
+
| Credential error | Set `OPENAI_API_KEY` or `GEMINI_API_KEY` in the environment. |
|
|
286
|
+
| Invalid AI response | After three invalid attempts, the current group is skipped and execution continues with the next files. |
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
Distributed under the [MIT License](LICENSE). A project by André Argôlo ([argolo.dev](https://argolo.dev)).
|
|
291
|
+
|
|
292
|
+
Repository: [github.com/argolo/commitar](https://github.com/argolo/commitar).
|
commitar-1.0.0/README.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Commitar
|
|
2
|
+
|
|
3
|
+
**Commitar** is a Python CLI that generates [Conventional Commits](https://www.conventionalcommits.org/) messages with AI and can optionally create Git commits. Its core principle is preserving the staging area: when the index already has changes, only those changes are considered.
|
|
4
|
+
|
|
5
|
+
Portuguese documentation is available in [README-PT.md](README-PT.md).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Safe preview by default: no changes are made without `--output commit`.
|
|
10
|
+
- One-line Conventional Commit messages.
|
|
11
|
+
- OpenAI, Gemini, and Ollama support.
|
|
12
|
+
- File, directory, or whole-repository scope.
|
|
13
|
+
- Staging isolation, including partially staged files.
|
|
14
|
+
- TOML, environment-variable, and flag configuration.
|
|
15
|
+
- Colored feedback, a generation spinner, and elapsed time per message.
|
|
16
|
+
- Configurable AI timeout; the default is 60 seconds.
|
|
17
|
+
|
|
18
|
+
## Requirements
|
|
19
|
+
|
|
20
|
+
- Python 3.11 or later.
|
|
21
|
+
- Git installed and a Git repository initialized.
|
|
22
|
+
- A configured AI provider:
|
|
23
|
+
- OpenAI: `OPENAI_API_KEY`;
|
|
24
|
+
- Gemini: `GEMINI_API_KEY`;
|
|
25
|
+
- Ollama: a local service running with an installed model.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip3 install commitar
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For development, install the test dependencies too:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
python -m pip install -e '.[dev]'
|
|
37
|
+
commitar --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick start
|
|
41
|
+
|
|
42
|
+
Configure your Git identity if necessary:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git config user.name "Your Name"
|
|
46
|
+
git config user.email "you@example.com"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Preview tracked changes:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
commitar
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
When there is no staging, Commitar generates a preview for each changed file. The preview lists the source, files, suggested message, and generation time.
|
|
56
|
+
|
|
57
|
+
Untracked files are ignored for safety. Include them explicitly:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
commitar --include-added
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Create commits after a single confirmation:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
commitar src/ --output commit
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For automation, skip the interaction:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
commitar src/ --output commit --yes
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To create one commit from files explicitly selected with `git add`:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git add src/moon_service.py tests/test_moon_service.py
|
|
79
|
+
commitar --output commit
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
With existing staging, Commitar exclusively uses `git diff --cached`, generates one message, and creates a commit containing exactly the files in the index.
|
|
83
|
+
|
|
84
|
+
Use `--message` to skip the AI provider call. The value must be a valid one-line Conventional Commit:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
commitar app.py --include-added \
|
|
88
|
+
--message "feat: add moon phase endpoint" \
|
|
89
|
+
--output commit --yes
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Staging safety
|
|
93
|
+
|
|
94
|
+
The behavior is deliberately conservative.
|
|
95
|
+
|
|
96
|
+
| Situation | Behavior |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| Staged files exist and `commitar` runs without a `PATH` | One message is generated from `git diff --cached`; the commit contains exactly the current index. |
|
|
99
|
+
| Staged files exist and a `PATH` is supplied | The command fails without changing the repository. |
|
|
100
|
+
| No staging and no `PATH` is supplied | One group is created for each changed file. |
|
|
101
|
+
| No staging and a file/directory is supplied | One group contains that file or all eligible files in the directory. |
|
|
102
|
+
| A file is partially staged | Only its index version is committed; remaining worktree changes stay intact. |
|
|
103
|
+
|
|
104
|
+
In path mode, Commitar verifies that the index remains empty before each commit. If another process changes staging, the operation stops to prevent changes from being mixed.
|
|
105
|
+
|
|
106
|
+
## Command reference
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
commitar [OPTIONS] [PATH]
|
|
110
|
+
commitar config init [OPTIONS]
|
|
111
|
+
commitar config show [OPTIONS]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
| Option | Description |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `PATH` | A file or directory inside the worktree. With no value, one changed file is grouped at a time. |
|
|
117
|
+
| `--output preview` | Displays the preview; this is the default. |
|
|
118
|
+
| `--output commit` | Requests confirmation and creates commits. |
|
|
119
|
+
| `--dry-run` | Alias for `--output preview`. |
|
|
120
|
+
| `--yes`, `-y` | Does not request confirmation in `commit` mode. |
|
|
121
|
+
| `--message TEXT` | Uses a manual message without calling the AI. |
|
|
122
|
+
| `--include-added` | Includes untracked files. |
|
|
123
|
+
| `--provider` | Selects `openai`, `gemini`, or `ollama`. |
|
|
124
|
+
| `--model` | Sets the selected provider model. |
|
|
125
|
+
| `--timeout-seconds` | Temporarily overrides the AI timeout. |
|
|
126
|
+
| `--max-input-tokens` | Limits the estimated number of tokens in the full prompt sent to the AI. |
|
|
127
|
+
| `--context-window-tokens` | Sets the shared input and reserved-output context window. |
|
|
128
|
+
| `--config PATH` | Loads an additional TOML file, taking precedence over default files. |
|
|
129
|
+
|
|
130
|
+
Use `commitar --help` and `commitar config --help` for current CLI details.
|
|
131
|
+
|
|
132
|
+
## Configuration
|
|
133
|
+
|
|
134
|
+
Create a configuration template in the repository root:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
commitar config init
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Example `.commitar.toml`:
|
|
141
|
+
|
|
142
|
+
```toml
|
|
143
|
+
[ai]
|
|
144
|
+
provider = "ollama"
|
|
145
|
+
models = ["gemma4:e4b", "qwen2.5-coder:14b"]
|
|
146
|
+
endpoint = "http://localhost:11434/api/generate"
|
|
147
|
+
max_input_tokens = 12000
|
|
148
|
+
context_window_tokens = 32768
|
|
149
|
+
max_output_tokens = 80
|
|
150
|
+
temperature = 0.2
|
|
151
|
+
timeout_seconds = 60
|
|
152
|
+
|
|
153
|
+
[commit]
|
|
154
|
+
language = "pt-BR"
|
|
155
|
+
format = "conventional"
|
|
156
|
+
include_added = false
|
|
157
|
+
output = "preview"
|
|
158
|
+
confirm = true
|
|
159
|
+
|
|
160
|
+
[limits]
|
|
161
|
+
max_files_per_request = 50
|
|
162
|
+
max_diff_bytes = 100000
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
`models` accepts up to three models in preference order. If the AI returns an invalid message, Commitar tries the next model, for up to three attempts. `model = "name"` remains supported for a single model; `--model` takes precedence for the current run.
|
|
166
|
+
|
|
167
|
+
The configuration precedence, from highest to lowest, is: CLI flags; the `--config` file; `COMMITAR_*` environment variables; `.commitar.toml` in the repository root; `~/.config/commitar/config.toml`; and built-in defaults.
|
|
168
|
+
|
|
169
|
+
Supported variables are `COMMITAR_PROVIDER`, `COMMITAR_MODEL`, `COMMITAR_LANGUAGE`, `COMMITAR_OUTPUT`, `COMMITAR_ENDPOINT`, `COMMITAR_MAX_DIFF_BYTES`, and `COMMITAR_TIMEOUT_SECONDS`.
|
|
170
|
+
|
|
171
|
+
Credentials are never read from TOML. Use `OPENAI_API_KEY` or `GEMINI_API_KEY`; Ollama normally does not need a key for local use.
|
|
172
|
+
|
|
173
|
+
## AI providers
|
|
174
|
+
|
|
175
|
+
### Ollama
|
|
176
|
+
|
|
177
|
+
| Model | Recommended use |
|
|
178
|
+
| --- | --- |
|
|
179
|
+
| `gemma4:e4b` | A lighter option for general use and resource-constrained machines. |
|
|
180
|
+
| `qwen2.5-coder:14b` | A code-focused option for machines with more memory and processing capacity. |
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
ollama pull gemma4:e4b
|
|
184
|
+
ollama serve
|
|
185
|
+
commitar --provider ollama --model gemma4:e4b
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The default endpoint is `http://localhost:11434/api/generate`.
|
|
189
|
+
|
|
190
|
+
### OpenAI
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
export OPENAI_API_KEY="..."
|
|
194
|
+
commitar --provider openai --model gpt-5-mini
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Gemini
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
export GEMINI_API_KEY="..."
|
|
201
|
+
commitar --provider gemini --model gemini-2.5-flash
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Context limits
|
|
205
|
+
|
|
206
|
+
The context is controlled by four settings: `max_files_per_request` (maximum files per group), `max_diff_bytes` (maximum diff size), `max_input_tokens` (estimated full-prompt limit), and `context_window_tokens` (total input/output window).
|
|
207
|
+
|
|
208
|
+
`max_input_tokens + max_output_tokens` cannot exceed `context_window_tokens`. Input counting is a conservative estimate independent of the provider tokenizer. In Ollama, the context window is sent as `num_ctx` and the output limit as `num_predict`. OpenAI and Gemini validate the window locally before sending the output limit.
|
|
209
|
+
|
|
210
|
+
If the diff exceeds its byte or token limit, Commitar produces a deterministic summary of diff metadata. If that still exceeds a limit, the command fails explicitly; content is never silently truncated.
|
|
211
|
+
|
|
212
|
+
## FastAPI example
|
|
213
|
+
|
|
214
|
+
The [example/](example/) directory contains an asynchronous FastAPI API that returns the approximate Moon phase for an ISO date:
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python -m pip install fastapi uvicorn
|
|
218
|
+
uvicorn example.app:app --reload
|
|
219
|
+
curl 'http://127.0.0.1:8000/moon-phase?date=2026-07-28'
|
|
220
|
+
curl 'http://127.0.0.1:8000/next-moon-phase?phase=lua-cheia&from_date=2026-07-28'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`/next-moon-phase` accepts `lua-nova`, `crescente`, `quarto-crescente`, `gibosa-crescente`, `lua-cheia`, `gibosa-minguante`, `quarto-minguante`, and `minguante`. The calculation is an approximation based on the average synodic month.
|
|
224
|
+
|
|
225
|
+
## Development and testing
|
|
226
|
+
|
|
227
|
+
Use the `Makefile` to standardize local tasks:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
make help
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
| Command | Purpose |
|
|
234
|
+
| --- | --- |
|
|
235
|
+
| `make venv` | Creates the local virtual environment in `.venv`. |
|
|
236
|
+
| `make shell` | Opens a shell with the virtual environment enabled; run `exit` to leave it. |
|
|
237
|
+
| `make install` | Installs Commitar in editable mode and all development dependencies. |
|
|
238
|
+
| `make clear` | Deletes Git-ignored files with `git clean -Xdf`, including `.venv`, `.env`, caches, and builds. |
|
|
239
|
+
| `make build` | Generates the wheel and source distribution in `dist/`. |
|
|
240
|
+
| `make test` | Runs the pytest suite. |
|
|
241
|
+
| `make coverage` | Runs tests and shows uncovered lines. |
|
|
242
|
+
| `make lint` | Checks style, imports, and common issues with Ruff. |
|
|
243
|
+
| `make format` | Formats code with Ruff. |
|
|
244
|
+
| `make typecheck` | Runs static analysis with mypy. |
|
|
245
|
+
| `make audit` | Checks dependencies for known vulnerabilities with pip-audit. |
|
|
246
|
+
| `make check` | Runs linting, type checking, tests, and the audit. |
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
make venv
|
|
250
|
+
make install
|
|
251
|
+
make check
|
|
252
|
+
make build
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
> **Warning:** `make clear` is destructive to ignored files. It also removes virtual environments and local files such as `.env`; back up needed local data.
|
|
256
|
+
|
|
257
|
+
## Troubleshooting
|
|
258
|
+
|
|
259
|
+
| Message / symptom | Recommended action |
|
|
260
|
+
| --- | --- |
|
|
261
|
+
| `No tracked file changes were found...` | Only new files exist. Run `commitar --include-added` to include them in the preview. |
|
|
262
|
+
| `There are no eligible changed files in this scope.` | There are no changes in the supplied scope; modify a tracked file or provide another path. |
|
|
263
|
+
| `There are staged changes...` | Run without a `PATH` to commit only the index, or clear/commit staging before supplying a path. |
|
|
264
|
+
| Provider timeout | Commitar retries up to three times across configured models. Check the service and increase `timeout_seconds`. |
|
|
265
|
+
| Credential error | Set `OPENAI_API_KEY` or `GEMINI_API_KEY` in the environment. |
|
|
266
|
+
| Invalid AI response | After three invalid attempts, the current group is skipped and execution continues with the next files. |
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
Distributed under the [MIT License](LICENSE). A project by André Argôlo ([argolo.dev](https://argolo.dev)).
|
|
271
|
+
|
|
272
|
+
Repository: [github.com/argolo/commitar](https://github.com/argolo/commitar).
|