autogit-ai 0.1.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.
- autogit_ai-0.1.0/.github/workflows/ci.yml +38 -0
- autogit_ai-0.1.0/.github/workflows/publish.yml +45 -0
- autogit_ai-0.1.0/.gitignore +38 -0
- autogit_ai-0.1.0/.python-version +1 -0
- autogit_ai-0.1.0/.smartgit.toml +1 -0
- autogit_ai-0.1.0/CHANGELOG.md +29 -0
- autogit_ai-0.1.0/LICENSE +21 -0
- autogit_ai-0.1.0/PKG-INFO +147 -0
- autogit_ai-0.1.0/README.md +113 -0
- autogit_ai-0.1.0/pyproject.toml +83 -0
- autogit_ai-0.1.0/src/autogit/__init__.py +8 -0
- autogit_ai-0.1.0/src/autogit/__main__.py +6 -0
- autogit_ai-0.1.0/src/autogit/ai/__init__.py +6 -0
- autogit_ai-0.1.0/src/autogit/ai/base.py +41 -0
- autogit_ai-0.1.0/src/autogit/ai/factory.py +39 -0
- autogit_ai-0.1.0/src/autogit/ai/prompt.py +100 -0
- autogit_ai-0.1.0/src/autogit/ai/providers/__init__.py +1 -0
- autogit_ai-0.1.0/src/autogit/ai/providers/fake.py +66 -0
- autogit_ai-0.1.0/src/autogit/ai/providers/ollama.py +101 -0
- autogit_ai-0.1.0/src/autogit/cli/__init__.py +6 -0
- autogit_ai-0.1.0/src/autogit/cli/app.py +89 -0
- autogit_ai-0.1.0/src/autogit/cli/console.py +63 -0
- autogit_ai-0.1.0/src/autogit/commands/__init__.py +5 -0
- autogit_ai-0.1.0/src/autogit/commands/analyze.py +48 -0
- autogit_ai-0.1.0/src/autogit/commands/commit.py +76 -0
- autogit_ai-0.1.0/src/autogit/commands/config.py +100 -0
- autogit_ai-0.1.0/src/autogit/commands/doctor.py +75 -0
- autogit_ai-0.1.0/src/autogit/commands/session.py +35 -0
- autogit_ai-0.1.0/src/autogit/commands/status.py +28 -0
- autogit_ai-0.1.0/src/autogit/config/__init__.py +6 -0
- autogit_ai-0.1.0/src/autogit/config/io.py +49 -0
- autogit_ai-0.1.0/src/autogit/config/loader.py +81 -0
- autogit_ai-0.1.0/src/autogit/config/paths.py +24 -0
- autogit_ai-0.1.0/src/autogit/config/schema.py +67 -0
- autogit_ai-0.1.0/src/autogit/core/__init__.py +6 -0
- autogit_ai-0.1.0/src/autogit/core/analyzer.py +46 -0
- autogit_ai-0.1.0/src/autogit/core/commit_service.py +60 -0
- autogit_ai-0.1.0/src/autogit/core/diff_stats.py +27 -0
- autogit_ai-0.1.0/src/autogit/core/errors.py +11 -0
- autogit_ai-0.1.0/src/autogit/git/__init__.py +6 -0
- autogit_ai-0.1.0/src/autogit/git/exceptions.py +34 -0
- autogit_ai-0.1.0/src/autogit/git/repository.py +105 -0
- autogit_ai-0.1.0/src/autogit/git/runner.py +67 -0
- autogit_ai-0.1.0/src/autogit/git/status.py +81 -0
- autogit_ai-0.1.0/src/autogit/models/__init__.py +5 -0
- autogit_ai-0.1.0/src/autogit/models/changes.py +48 -0
- autogit_ai-0.1.0/src/autogit/models/commit.py +84 -0
- autogit_ai-0.1.0/src/autogit/utils/__init__.py +5 -0
- autogit_ai-0.1.0/tests/__init__.py +0 -0
- autogit_ai-0.1.0/tests/test_analyzer.py +56 -0
- autogit_ai-0.1.0/tests/test_cli.py +23 -0
- autogit_ai-0.1.0/tests/test_commit_service.py +77 -0
- autogit_ai-0.1.0/tests/test_config_io.py +30 -0
- autogit_ai-0.1.0/tests/test_config_loader.py +76 -0
- autogit_ai-0.1.0/tests/test_config_schema.py +52 -0
- autogit_ai-0.1.0/tests/test_diff_stats.py +31 -0
- autogit_ai-0.1.0/tests/test_factory.py +19 -0
- autogit_ai-0.1.0/tests/test_fake_provider.py +56 -0
- autogit_ai-0.1.0/tests/test_ollama_provider.py +81 -0
- autogit_ai-0.1.0/tests/test_prompt.py +47 -0
- autogit_ai-0.1.0/tests/test_repository.py +80 -0
- autogit_ai-0.1.0/tests/test_status_parser.py +49 -0
- autogit_ai-0.1.0/tests/test_version.py +31 -0
- autogit_ai-0.1.0/uv.lock +827 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
quality:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Instalar uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Sincronizar dependencias
|
|
26
|
+
run: uv sync --extra dev
|
|
27
|
+
|
|
28
|
+
- name: Lint (ruff)
|
|
29
|
+
run: uv run ruff check .
|
|
30
|
+
|
|
31
|
+
- name: Formato (ruff format)
|
|
32
|
+
run: uv run ruff format --check .
|
|
33
|
+
|
|
34
|
+
- name: Tipado (mypy)
|
|
35
|
+
run: uv run mypy
|
|
36
|
+
|
|
37
|
+
- name: Tests (pytest)
|
|
38
|
+
run: uv run pytest
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Publicar en PyPI
|
|
2
|
+
|
|
3
|
+
# Se dispara al empujar un tag de versión, por ejemplo v0.1.0.
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- "v*"
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Instalar uv
|
|
16
|
+
uses: astral-sh/setup-uv@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
|
|
20
|
+
- name: Construir el paquete (wheel + sdist)
|
|
21
|
+
run: uv build
|
|
22
|
+
|
|
23
|
+
- name: Guardar los artefactos
|
|
24
|
+
uses: actions/upload-artifact@v4
|
|
25
|
+
with:
|
|
26
|
+
name: dist
|
|
27
|
+
path: dist/
|
|
28
|
+
|
|
29
|
+
publish:
|
|
30
|
+
needs: build
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
# El 'environment' permite exigir aprobaciones antes de publicar.
|
|
33
|
+
environment: pypi
|
|
34
|
+
permissions:
|
|
35
|
+
# Necesario para 'trusted publishing' vía OIDC (sin tokens).
|
|
36
|
+
id-token: write
|
|
37
|
+
steps:
|
|
38
|
+
- name: Descargar los artefactos
|
|
39
|
+
uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: dist
|
|
42
|
+
path: dist/
|
|
43
|
+
|
|
44
|
+
- name: Publicar en PyPI
|
|
45
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
|
|
12
|
+
# Virtual environments / uv
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# Testing / coverage
|
|
18
|
+
.pytest_cache/
|
|
19
|
+
.coverage
|
|
20
|
+
coverage.xml
|
|
21
|
+
htmlcov/
|
|
22
|
+
.tox/
|
|
23
|
+
|
|
24
|
+
# Type / lint caches
|
|
25
|
+
.mypy_cache/
|
|
26
|
+
.ruff_cache/
|
|
27
|
+
.dmypy.json
|
|
28
|
+
|
|
29
|
+
# IDE / OS
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
.DS_Store
|
|
33
|
+
Thumbs.db
|
|
34
|
+
|
|
35
|
+
# AutoGit local config / secrets
|
|
36
|
+
.autogit/
|
|
37
|
+
*.env
|
|
38
|
+
.env
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.10
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
language = "en"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Todas las novedades notables de este proyecto se documentan en este archivo.
|
|
4
|
+
|
|
5
|
+
El formato se basa en [Keep a Changelog](https://keepachangelog.com/es/1.1.0/)
|
|
6
|
+
y el proyecto sigue [Versionado Semántico](https://semver.org/lang/es/).
|
|
7
|
+
|
|
8
|
+
## [No publicado]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-07-07
|
|
11
|
+
|
|
12
|
+
### Añadido
|
|
13
|
+
- **Capa Git**: adaptador sobre el binario `git` (`GitRunner`), interfaz
|
|
14
|
+
`GitRepository` e implementación `GitCommandRepository` con `status`, `diff`,
|
|
15
|
+
`add`, `commit`, `push` y `discover`. Parser puro de `git status --porcelain`.
|
|
16
|
+
- **Configuración por capas** validada con Pydantic: valores por defecto →
|
|
17
|
+
archivo global (`~/.autogit/config.toml`) → archivo de proyecto
|
|
18
|
+
(`.autogit.toml`) → variables de entorno (`AUTOGIT_*`).
|
|
19
|
+
- **Capa IA**: interfaz `AIProvider`, constructor de prompts con recorte de
|
|
20
|
+
diffs, proveedor `fake` (offline), proveedor `ollama` (vía httpx) y una
|
|
21
|
+
fábrica de proveedores extensible.
|
|
22
|
+
- **Núcleo (core)**: `ChangeAnalyzer` y `CommitService` que orquestan el
|
|
23
|
+
análisis de cambios y la generación del commit.
|
|
24
|
+
- **CLI**: comandos `commit`, `status`, `analyze`, `config` (show/set/path),
|
|
25
|
+
`doctor` y `version`, con experiencia interactiva basada en Rich.
|
|
26
|
+
- Suite de tests, configuración de calidad (ruff, mypy) y CI en GitHub Actions.
|
|
27
|
+
|
|
28
|
+
[No publicado]: https://github.com/OptimScul/autogit-ai/compare/v0.1.0...HEAD
|
|
29
|
+
[0.1.0]: https://github.com/OptimScul/autogit-ai/releases/tag/v0.1.0
|
autogit_ai-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OptimScul
|
|
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.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: autogit-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: CLI que analiza tu repositorio Git y genera commits profesionales con IA (Conventional Commits).
|
|
5
|
+
Project-URL: Homepage, https://github.com/OptimScul/autogit-ai
|
|
6
|
+
Project-URL: Repository, https://github.com/OptimScul/autogit-ai
|
|
7
|
+
Project-URL: Issues, https://github.com/OptimScul/autogit-ai/issues
|
|
8
|
+
Author: OptimScul
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,cli,commit,conventional-commits,devtools,git
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: click>=8.1
|
|
23
|
+
Requires-Dist: httpx>=0.27
|
|
24
|
+
Requires-Dist: pydantic>=2.7
|
|
25
|
+
Requires-Dist: rich>=13.0
|
|
26
|
+
Requires-Dist: tomli>=2.0.1; python_version < '3.11'
|
|
27
|
+
Requires-Dist: typer>=0.12
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# AutoGit AI
|
|
36
|
+
|
|
37
|
+
**AutoGit AI** analiza automáticamente los cambios de tu repositorio Git, los
|
|
38
|
+
agrupa de forma inteligente y usa IA para generar mensajes de commit
|
|
39
|
+
profesionales siguiendo **Conventional Commits**.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
autogit commit # o el alias corto: ag commit
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> ⚠️ Proyecto en desarrollo temprano (Alpha). La API y los comandos pueden cambiar.
|
|
46
|
+
|
|
47
|
+
## Características
|
|
48
|
+
|
|
49
|
+
- Detecta el repositorio Git actual y lee su estado (añadidos, modificados,
|
|
50
|
+
eliminados, renombrados y sin seguimiento).
|
|
51
|
+
- Construye el contexto (diffs y estadísticas por archivo) y lo envía a la IA.
|
|
52
|
+
- Genera el mensaje, muestra una vista previa y te deja **confirmar, editar o
|
|
53
|
+
cancelar**.
|
|
54
|
+
- Configuración flexible por capas y varios proveedores de IA intercambiables.
|
|
55
|
+
|
|
56
|
+
## Instalación
|
|
57
|
+
|
|
58
|
+
Requisitos: [uv](https://docs.astral.sh/uv/) y Git.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/OptimScul/autogit-ai.git
|
|
62
|
+
cd autogit-ai
|
|
63
|
+
uv sync --extra dev
|
|
64
|
+
uv run autogit version
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Una vez publicado en PyPI podrás instalarlo con `pip install autogit-ai`.
|
|
68
|
+
|
|
69
|
+
## Uso rápido
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
autogit status # ver los cambios del repositorio
|
|
73
|
+
autogit analyze # analizar y previsualizar el mensaje sin commitear
|
|
74
|
+
autogit commit # generar el commit con IA (menú Sí / Editar / Cancelar)
|
|
75
|
+
autogit commit -p # además hacer push tras el commit
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Comandos
|
|
79
|
+
|
|
80
|
+
| Comando | Descripción |
|
|
81
|
+
| ----------------- | ------------------------------------------------------- |
|
|
82
|
+
| `autogit commit` | Analiza los cambios y genera el commit con IA |
|
|
83
|
+
| `autogit status` | Estado del repositorio en formato enriquecido |
|
|
84
|
+
| `autogit analyze` | Analiza y previsualiza el mensaje sin hacer commit |
|
|
85
|
+
| `autogit config` | Gestiona proveedor, modelo, API key, idioma, etc. |
|
|
86
|
+
| `autogit doctor` | Diagnóstico del entorno (git, config, proveedor de IA) |
|
|
87
|
+
| `autogit version` | Muestra la versión instalada |
|
|
88
|
+
|
|
89
|
+
## Configuración
|
|
90
|
+
|
|
91
|
+
La configuración se resuelve combinando, de menor a mayor prioridad:
|
|
92
|
+
|
|
93
|
+
1. Valores por defecto.
|
|
94
|
+
2. Archivo global del usuario: `~/.autogit/config.toml`.
|
|
95
|
+
3. Archivo del proyecto: `.autogit.toml` en la raíz del repo.
|
|
96
|
+
4. Variables de entorno: `AUTOGIT_PROVIDER`, `AUTOGIT_MODEL`, `AUTOGIT_API_KEY`,
|
|
97
|
+
`AUTOGIT_LANGUAGE`, `AUTOGIT_COMMIT_STYLE`, `AUTOGIT_MAX_MESSAGE_LENGTH`.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
autogit config show # ver la configuración efectiva
|
|
101
|
+
autogit config path # ver dónde viven los archivos
|
|
102
|
+
autogit config set provider ollama # fijar un valor (se valida antes de guardar)
|
|
103
|
+
autogit config set model llama3
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> La API key es más segura como variable de entorno (`AUTOGIT_API_KEY`) que
|
|
107
|
+
> escrita en un archivo.
|
|
108
|
+
|
|
109
|
+
### Proveedores de IA
|
|
110
|
+
|
|
111
|
+
| Proveedor | Estado | Notas |
|
|
112
|
+
| ------------ | ---------------- | -------------------------------------- |
|
|
113
|
+
| `fake` | ✅ Disponible | Determinista y offline (desarrollo) |
|
|
114
|
+
| `ollama` | ✅ Disponible | Modelos locales, sin API key |
|
|
115
|
+
| `openai` | ⏳ Planificado | |
|
|
116
|
+
| `claude` | ⏳ Planificado | |
|
|
117
|
+
| `gemini` | ⏳ Planificado | |
|
|
118
|
+
| `openrouter` | ⏳ Planificado | |
|
|
119
|
+
|
|
120
|
+
## Desarrollo
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
uv run pytest # tests
|
|
124
|
+
uv run ruff check . # lint
|
|
125
|
+
uv run ruff format . # formato
|
|
126
|
+
uv run mypy # tipado estático
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Arquitectura
|
|
130
|
+
|
|
131
|
+
Clean Architecture con capas desacopladas:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
src/autogit/
|
|
135
|
+
├── cli/ # Interacción de terminal (Typer + Rich)
|
|
136
|
+
├── commands/ # Un módulo por subcomando
|
|
137
|
+
├── core/ # Casos de uso y reglas de negocio (dominio)
|
|
138
|
+
├── git/ # Adaptador sobre el binario git
|
|
139
|
+
├── ai/ # Interfaz AIProvider + implementaciones + fábrica
|
|
140
|
+
├── config/ # Carga y validación de configuración (Pydantic)
|
|
141
|
+
├── models/ # Modelos de datos tipados
|
|
142
|
+
└── utils/ # Utilidades transversales
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Licencia
|
|
146
|
+
|
|
147
|
+
MIT
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# AutoGit AI
|
|
2
|
+
|
|
3
|
+
**AutoGit AI** analiza automáticamente los cambios de tu repositorio Git, los
|
|
4
|
+
agrupa de forma inteligente y usa IA para generar mensajes de commit
|
|
5
|
+
profesionales siguiendo **Conventional Commits**.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
autogit commit # o el alias corto: ag commit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> ⚠️ Proyecto en desarrollo temprano (Alpha). La API y los comandos pueden cambiar.
|
|
12
|
+
|
|
13
|
+
## Características
|
|
14
|
+
|
|
15
|
+
- Detecta el repositorio Git actual y lee su estado (añadidos, modificados,
|
|
16
|
+
eliminados, renombrados y sin seguimiento).
|
|
17
|
+
- Construye el contexto (diffs y estadísticas por archivo) y lo envía a la IA.
|
|
18
|
+
- Genera el mensaje, muestra una vista previa y te deja **confirmar, editar o
|
|
19
|
+
cancelar**.
|
|
20
|
+
- Configuración flexible por capas y varios proveedores de IA intercambiables.
|
|
21
|
+
|
|
22
|
+
## Instalación
|
|
23
|
+
|
|
24
|
+
Requisitos: [uv](https://docs.astral.sh/uv/) y Git.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/OptimScul/autogit-ai.git
|
|
28
|
+
cd autogit-ai
|
|
29
|
+
uv sync --extra dev
|
|
30
|
+
uv run autogit version
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Una vez publicado en PyPI podrás instalarlo con `pip install autogit-ai`.
|
|
34
|
+
|
|
35
|
+
## Uso rápido
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
autogit status # ver los cambios del repositorio
|
|
39
|
+
autogit analyze # analizar y previsualizar el mensaje sin commitear
|
|
40
|
+
autogit commit # generar el commit con IA (menú Sí / Editar / Cancelar)
|
|
41
|
+
autogit commit -p # además hacer push tras el commit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Comandos
|
|
45
|
+
|
|
46
|
+
| Comando | Descripción |
|
|
47
|
+
| ----------------- | ------------------------------------------------------- |
|
|
48
|
+
| `autogit commit` | Analiza los cambios y genera el commit con IA |
|
|
49
|
+
| `autogit status` | Estado del repositorio en formato enriquecido |
|
|
50
|
+
| `autogit analyze` | Analiza y previsualiza el mensaje sin hacer commit |
|
|
51
|
+
| `autogit config` | Gestiona proveedor, modelo, API key, idioma, etc. |
|
|
52
|
+
| `autogit doctor` | Diagnóstico del entorno (git, config, proveedor de IA) |
|
|
53
|
+
| `autogit version` | Muestra la versión instalada |
|
|
54
|
+
|
|
55
|
+
## Configuración
|
|
56
|
+
|
|
57
|
+
La configuración se resuelve combinando, de menor a mayor prioridad:
|
|
58
|
+
|
|
59
|
+
1. Valores por defecto.
|
|
60
|
+
2. Archivo global del usuario: `~/.autogit/config.toml`.
|
|
61
|
+
3. Archivo del proyecto: `.autogit.toml` en la raíz del repo.
|
|
62
|
+
4. Variables de entorno: `AUTOGIT_PROVIDER`, `AUTOGIT_MODEL`, `AUTOGIT_API_KEY`,
|
|
63
|
+
`AUTOGIT_LANGUAGE`, `AUTOGIT_COMMIT_STYLE`, `AUTOGIT_MAX_MESSAGE_LENGTH`.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
autogit config show # ver la configuración efectiva
|
|
67
|
+
autogit config path # ver dónde viven los archivos
|
|
68
|
+
autogit config set provider ollama # fijar un valor (se valida antes de guardar)
|
|
69
|
+
autogit config set model llama3
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
> La API key es más segura como variable de entorno (`AUTOGIT_API_KEY`) que
|
|
73
|
+
> escrita en un archivo.
|
|
74
|
+
|
|
75
|
+
### Proveedores de IA
|
|
76
|
+
|
|
77
|
+
| Proveedor | Estado | Notas |
|
|
78
|
+
| ------------ | ---------------- | -------------------------------------- |
|
|
79
|
+
| `fake` | ✅ Disponible | Determinista y offline (desarrollo) |
|
|
80
|
+
| `ollama` | ✅ Disponible | Modelos locales, sin API key |
|
|
81
|
+
| `openai` | ⏳ Planificado | |
|
|
82
|
+
| `claude` | ⏳ Planificado | |
|
|
83
|
+
| `gemini` | ⏳ Planificado | |
|
|
84
|
+
| `openrouter` | ⏳ Planificado | |
|
|
85
|
+
|
|
86
|
+
## Desarrollo
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv run pytest # tests
|
|
90
|
+
uv run ruff check . # lint
|
|
91
|
+
uv run ruff format . # formato
|
|
92
|
+
uv run mypy # tipado estático
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Arquitectura
|
|
96
|
+
|
|
97
|
+
Clean Architecture con capas desacopladas:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
src/autogit/
|
|
101
|
+
├── cli/ # Interacción de terminal (Typer + Rich)
|
|
102
|
+
├── commands/ # Un módulo por subcomando
|
|
103
|
+
├── core/ # Casos de uso y reglas de negocio (dominio)
|
|
104
|
+
├── git/ # Adaptador sobre el binario git
|
|
105
|
+
├── ai/ # Interfaz AIProvider + implementaciones + fábrica
|
|
106
|
+
├── config/ # Carga y validación de configuración (Pydantic)
|
|
107
|
+
├── models/ # Modelos de datos tipados
|
|
108
|
+
└── utils/ # Utilidades transversales
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Licencia
|
|
112
|
+
|
|
113
|
+
MIT
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "autogit-ai"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "CLI que analiza tu repositorio Git y genera commits profesionales con IA (Conventional Commits)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "OptimScul" }]
|
|
9
|
+
keywords = ["git", "cli", "ai", "commit", "conventional-commits", "devtools"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Environment :: Console",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Topic :: Software Development :: Version Control :: Git",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"typer>=0.12",
|
|
23
|
+
"click>=8.1",
|
|
24
|
+
"pydantic>=2.7",
|
|
25
|
+
"tomli>=2.0.1; python_version < '3.11'",
|
|
26
|
+
"httpx>=0.27",
|
|
27
|
+
"rich>=13.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/OptimScul/autogit-ai"
|
|
32
|
+
Repository = "https://github.com/OptimScul/autogit-ai"
|
|
33
|
+
Issues = "https://github.com/OptimScul/autogit-ai/issues"
|
|
34
|
+
|
|
35
|
+
# Dos nombres para el mismo entry point: el largo y el alias corto.
|
|
36
|
+
[project.scripts]
|
|
37
|
+
autogit = "autogit.cli.app:main"
|
|
38
|
+
ag = "autogit.cli.app:main"
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
dev = [
|
|
42
|
+
"pytest>=8.0",
|
|
43
|
+
"pytest-cov>=5.0",
|
|
44
|
+
"ruff>=0.6",
|
|
45
|
+
"mypy>=1.11",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["hatchling"]
|
|
50
|
+
build-backend = "hatchling.build"
|
|
51
|
+
|
|
52
|
+
# La versión se lee dinámicamente de src/autogit/__init__.py (fuente única).
|
|
53
|
+
[tool.hatch.version]
|
|
54
|
+
path = "src/autogit/__init__.py"
|
|
55
|
+
|
|
56
|
+
[tool.hatch.build.targets.wheel]
|
|
57
|
+
packages = ["src/autogit"]
|
|
58
|
+
|
|
59
|
+
# --- Herramientas de calidad --------------------------------------------------
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length = 88
|
|
63
|
+
src = ["src", "tests"]
|
|
64
|
+
target-version = "py310"
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint]
|
|
67
|
+
# E/F: pyflakes+pycodestyle, I: isort, UP: pyupgrade, B: bugbear,
|
|
68
|
+
# SIM: simplificaciones, C4: comprehensions, PTH: usar pathlib.
|
|
69
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "C4", "PTH"]
|
|
70
|
+
|
|
71
|
+
[tool.mypy]
|
|
72
|
+
python_version = "3.10"
|
|
73
|
+
strict = true
|
|
74
|
+
warn_unused_ignores = true
|
|
75
|
+
warn_redundant_casts = true
|
|
76
|
+
files = ["src", "tests"]
|
|
77
|
+
# El plugin de Pydantic ensena a mypy a entender los modelos (campos, validadores).
|
|
78
|
+
plugins = ["pydantic.mypy"]
|
|
79
|
+
|
|
80
|
+
[tool.pytest.ini_options]
|
|
81
|
+
addopts = "-q"
|
|
82
|
+
testpaths = ["tests"]
|
|
83
|
+
pythonpath = ["src"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""AutoGit AI — herramienta CLI para generar commits profesionales con IA.
|
|
2
|
+
|
|
3
|
+
El número de versión se define aquí como única fuente de verdad y se expone
|
|
4
|
+
al empaquetado a través de ``pyproject.toml`` (``[tool.hatch...]`` o lectura
|
|
5
|
+
dinámica). Ver ``autogit.cli.app`` para el punto de entrada.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""Capa IA: interfaz ``AIProvider`` e implementaciones intercambiables.
|
|
2
|
+
|
|
3
|
+
Cada proveedor (OpenAI, Claude, Gemini, Ollama, OpenRouter) implementa el
|
|
4
|
+
mismo contrato. El dominio depende de la abstracción, no de un proveedor
|
|
5
|
+
concreto (Inversión de Dependencias).
|
|
6
|
+
"""
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Contrato de la capa IA: la abstracción ``AIProvider`` y sus errores.
|
|
2
|
+
|
|
3
|
+
Todo el resto de la aplicación depende de esta interfaz, NO de un proveedor
|
|
4
|
+
concreto (OpenAI, Ollama, ...). Cambiar de proveedor será cuestión de elegir
|
|
5
|
+
otra implementación en la configuración, sin tocar el dominio ni la CLI.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Protocol
|
|
11
|
+
|
|
12
|
+
from autogit.config.schema import AutoGitConfig
|
|
13
|
+
from autogit.models.commit import CommitContext, CommitMessage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AIError(Exception):
|
|
17
|
+
"""Error base de la capa IA."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AIConfigurationError(AIError):
|
|
21
|
+
"""Configuración inválida o incompleta (por ejemplo, falta la API key)."""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AIRequestError(AIError):
|
|
25
|
+
"""La petición al proveedor falló (red, autenticación, respuesta inválida)."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class AIProvider(Protocol):
|
|
29
|
+
"""Genera un mensaje de commit a partir del contexto de cambios."""
|
|
30
|
+
|
|
31
|
+
name: str
|
|
32
|
+
"""Identificador legible del proveedor (para logs y diagnóstico)."""
|
|
33
|
+
|
|
34
|
+
def generate(self, context: CommitContext, config: AutoGitConfig) -> CommitMessage:
|
|
35
|
+
"""Produce un ``CommitMessage`` a partir del contexto y la configuración.
|
|
36
|
+
|
|
37
|
+
Raises:
|
|
38
|
+
AIConfigurationError: Si al proveedor le falta algo para operar.
|
|
39
|
+
AIRequestError: Si la comunicación con el proveedor falla.
|
|
40
|
+
"""
|
|
41
|
+
...
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Fábrica de proveedores de IA.
|
|
2
|
+
|
|
3
|
+
Traduce el ``Provider`` de la configuración a una implementación concreta de
|
|
4
|
+
``AIProvider``. Usamos un diccionario de constructores (patrón *registry*): el
|
|
5
|
+
día que implementemos OpenAI o Claude, bastará con añadir una entrada, sin
|
|
6
|
+
tocar el resto del código. Los proveedores aún no implementados fallan con un
|
|
7
|
+
mensaje claro en lugar de un error críptico.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from collections.abc import Callable
|
|
13
|
+
|
|
14
|
+
from autogit.ai.base import AIConfigurationError, AIProvider
|
|
15
|
+
from autogit.ai.providers.fake import FakeProvider
|
|
16
|
+
from autogit.ai.providers.ollama import OllamaProvider
|
|
17
|
+
from autogit.config.schema import AutoGitConfig, Provider
|
|
18
|
+
|
|
19
|
+
# Cada proveedor soportado se registra aquí con una función que lo construye.
|
|
20
|
+
_FACTORIES: dict[Provider, Callable[[AutoGitConfig], AIProvider]] = {
|
|
21
|
+
Provider.OLLAMA: lambda _config: OllamaProvider(),
|
|
22
|
+
Provider.FAKE: lambda _config: FakeProvider(),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def create_provider(config: AutoGitConfig) -> AIProvider:
|
|
27
|
+
"""Devuelve el proveedor de IA correspondiente a la configuración.
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
AIConfigurationError: Si el proveedor elegido aún no está implementado.
|
|
31
|
+
"""
|
|
32
|
+
factory = _FACTORIES.get(config.provider)
|
|
33
|
+
if factory is None:
|
|
34
|
+
disponibles = ", ".join(p.value for p in _FACTORIES)
|
|
35
|
+
raise AIConfigurationError(
|
|
36
|
+
f"El proveedor '{config.provider.value}' todavía no está implementado. "
|
|
37
|
+
f"Disponibles: {disponibles}."
|
|
38
|
+
)
|
|
39
|
+
return factory(config)
|