commitguard-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.
- commitguard_ai-0.1.0/LICENSE +21 -0
- commitguard_ai-0.1.0/PKG-INFO +122 -0
- commitguard_ai-0.1.0/README.md +90 -0
- commitguard_ai-0.1.0/commitguard/__init__.py +3 -0
- commitguard_ai-0.1.0/commitguard/analyzer.py +77 -0
- commitguard_ai-0.1.0/commitguard/cli.py +122 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/PKG-INFO +122 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/SOURCES.txt +12 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/dependency_links.txt +1 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/entry_points.txt +2 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/requires.txt +8 -0
- commitguard_ai-0.1.0/commitguard_ai.egg-info/top_level.txt +1 -0
- commitguard_ai-0.1.0/pyproject.toml +50 -0
- commitguard_ai-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PierrunoYT
|
|
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,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitguard-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered tool to analyze Git commits for bugs and issues
|
|
5
|
+
Author: CommitGuard
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/PierrunoYT/commitguard
|
|
8
|
+
Project-URL: Repository, https://github.com/PierrunoYT/commitguard
|
|
9
|
+
Project-URL: Issues, https://github.com/PierrunoYT/commitguard/issues
|
|
10
|
+
Keywords: git,commit,ai,code-review,openai,cli,commitguard,commitguard-ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
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 :: Quality Assurance
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: click>=8.1.0
|
|
25
|
+
Requires-Dist: gitpython>=3.1.0
|
|
26
|
+
Requires-Dist: openai>=1.0.0
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# CommitGuard
|
|
34
|
+
|
|
35
|
+
AI-powered CLI that analyzes Git commits for bugs, security issues, and code quality problems.
|
|
36
|
+
|
|
37
|
+
**[GitHub](https://github.com/PierrunoYT/commitguard)**
|
|
38
|
+
|
|
39
|
+
## Requirements
|
|
40
|
+
|
|
41
|
+
- Python 3.9+
|
|
42
|
+
- OpenAI API key
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
From PyPI:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install commitguard-ai
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
From source (development):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or install dependencies only:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install -r requirements.txt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
Set your OpenAI API key:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Linux / macOS
|
|
70
|
+
export OPENAI_API_KEY=sk-...
|
|
71
|
+
|
|
72
|
+
# Windows (PowerShell)
|
|
73
|
+
$env:OPENAI_API_KEY = "sk-..."
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or pass it via `--api-key` when running commands.
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
**Analyze the last commit (HEAD):**
|
|
81
|
+
```bash
|
|
82
|
+
commitguard analyze
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Analyze a specific commit:**
|
|
86
|
+
```bash
|
|
87
|
+
commitguard analyze abc123
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Analyze last 5 commits:**
|
|
91
|
+
```bash
|
|
92
|
+
commitguard analyze -n 5
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Analyze staged changes (before committing):**
|
|
96
|
+
```bash
|
|
97
|
+
commitguard check
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Options
|
|
101
|
+
|
|
102
|
+
| Option | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `-r, --repo PATH` | Path to Git repository (default: current dir) |
|
|
105
|
+
| `--api-key KEY` | OpenAI API key (or use `OPENAI_API_KEY` env) |
|
|
106
|
+
| `--model MODEL` | Model to use (default: `gpt-4o-mini`) |
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
Run from source without installing:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python -m commitguard.cli analyze
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
[MIT](LICENSE)
|
|
119
|
+
|
|
120
|
+
## Changelog
|
|
121
|
+
|
|
122
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# CommitGuard
|
|
2
|
+
|
|
3
|
+
AI-powered CLI that analyzes Git commits for bugs, security issues, and code quality problems.
|
|
4
|
+
|
|
5
|
+
**[GitHub](https://github.com/PierrunoYT/commitguard)**
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Python 3.9+
|
|
10
|
+
- OpenAI API key
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
From PyPI:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install commitguard-ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
From source (development):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install -e .
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or install dependencies only:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install -r requirements.txt
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
Set your OpenAI API key:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Linux / macOS
|
|
38
|
+
export OPENAI_API_KEY=sk-...
|
|
39
|
+
|
|
40
|
+
# Windows (PowerShell)
|
|
41
|
+
$env:OPENAI_API_KEY = "sk-..."
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or pass it via `--api-key` when running commands.
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
**Analyze the last commit (HEAD):**
|
|
49
|
+
```bash
|
|
50
|
+
commitguard analyze
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Analyze a specific commit:**
|
|
54
|
+
```bash
|
|
55
|
+
commitguard analyze abc123
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Analyze last 5 commits:**
|
|
59
|
+
```bash
|
|
60
|
+
commitguard analyze -n 5
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Analyze staged changes (before committing):**
|
|
64
|
+
```bash
|
|
65
|
+
commitguard check
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Options
|
|
69
|
+
|
|
70
|
+
| Option | Description |
|
|
71
|
+
|--------|-------------|
|
|
72
|
+
| `-r, --repo PATH` | Path to Git repository (default: current dir) |
|
|
73
|
+
| `--api-key KEY` | OpenAI API key (or use `OPENAI_API_KEY` env) |
|
|
74
|
+
| `--model MODEL` | Model to use (default: `gpt-4o-mini`) |
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
Run from source without installing:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
python -m commitguard.cli analyze
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
[MIT](LICENSE)
|
|
87
|
+
|
|
88
|
+
## Changelog
|
|
89
|
+
|
|
90
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Commit analysis using AI."""
|
|
2
|
+
|
|
3
|
+
from git import Repo
|
|
4
|
+
from openai import OpenAI
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
SYSTEM_PROMPT = """You are a code review assistant. Analyze Git commits for:
|
|
8
|
+
1. Potential bugs and logic errors
|
|
9
|
+
2. Security vulnerabilities
|
|
10
|
+
3. Code quality issues
|
|
11
|
+
4. Missing error handling or validation
|
|
12
|
+
5. Performance concerns
|
|
13
|
+
|
|
14
|
+
Respond in markdown. Be concise. If nothing concerning is found, say "No issues detected."
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_diff(repo: Repo, commit) -> str:
|
|
19
|
+
"""Get diff for a commit."""
|
|
20
|
+
if commit.parents:
|
|
21
|
+
diff = repo.git.diff(commit.parents[0], commit)
|
|
22
|
+
else:
|
|
23
|
+
diff = repo.git.show(commit, format="", no_patch=False)
|
|
24
|
+
return diff[:12000] # Limit context size
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def _call_ai(diff: str, message: str, files: list[str], api_key: str, model: str) -> str:
|
|
28
|
+
"""Call OpenAI API for analysis."""
|
|
29
|
+
client = OpenAI(api_key=api_key)
|
|
30
|
+
user_content = f"""Analyze this commit:
|
|
31
|
+
|
|
32
|
+
**Message:** {message}
|
|
33
|
+
**Files:** {', '.join(files) if files else 'N/A'}
|
|
34
|
+
|
|
35
|
+
**Diff:**
|
|
36
|
+
```
|
|
37
|
+
{diff or '(no diff)'}
|
|
38
|
+
```
|
|
39
|
+
"""
|
|
40
|
+
response = client.chat.completions.create(
|
|
41
|
+
model=model,
|
|
42
|
+
messages=[
|
|
43
|
+
{"role": "system", "content": SYSTEM_PROMPT},
|
|
44
|
+
{"role": "user", "content": user_content},
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
return response.choices[0].message.content or "No response."
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def analyze_commit(
|
|
51
|
+
repo_path: str,
|
|
52
|
+
ref: str = "HEAD",
|
|
53
|
+
*,
|
|
54
|
+
api_key: str,
|
|
55
|
+
model: str = "gpt-4o-mini",
|
|
56
|
+
) -> str:
|
|
57
|
+
"""Analyze a specific commit."""
|
|
58
|
+
repo = Repo(repo_path)
|
|
59
|
+
commit = repo.commit(ref)
|
|
60
|
+
diff = _get_diff(repo, commit)
|
|
61
|
+
files = [d.a_path for d in commit.diff(commit.parents[0] if commit.parents else None, create_patch=False)]
|
|
62
|
+
return _call_ai(diff, commit.message, files, api_key, model)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def analyze_staged(
|
|
66
|
+
repo_path: str,
|
|
67
|
+
*,
|
|
68
|
+
api_key: str,
|
|
69
|
+
model: str = "gpt-4o-mini",
|
|
70
|
+
) -> str:
|
|
71
|
+
"""Analyze staged changes."""
|
|
72
|
+
repo = Repo(repo_path)
|
|
73
|
+
diff = repo.git.diff("--cached")
|
|
74
|
+
if not diff.strip():
|
|
75
|
+
return "No staged changes to analyze."
|
|
76
|
+
files = repo.git.diff("--cached", "--name-only").splitlines()
|
|
77
|
+
return _call_ai(diff, "(staged changes)", files, api_key, model)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""CLI for CommitGuard."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
|
|
8
|
+
from .analyzer import analyze_commit, analyze_staged
|
|
9
|
+
from . import __version__
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_repo_path(path: str | None) -> Path:
|
|
13
|
+
"""Resolve repository path. Defaults to current directory."""
|
|
14
|
+
repo_path = Path(path or ".").resolve()
|
|
15
|
+
if not (repo_path / ".git").exists():
|
|
16
|
+
raise click.ClickException(f"Not a Git repository: {repo_path}")
|
|
17
|
+
return repo_path
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@click.group()
|
|
21
|
+
@click.version_option(version=__version__, prog_name="CommitGuard")
|
|
22
|
+
def main() -> None:
|
|
23
|
+
"""AI-powered tool to analyze Git commits for bugs and issues."""
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@main.command()
|
|
28
|
+
@click.argument("commit", default="HEAD", required=False)
|
|
29
|
+
@click.option(
|
|
30
|
+
"-r",
|
|
31
|
+
"--repo",
|
|
32
|
+
"repo_path",
|
|
33
|
+
type=click.Path(exists=True, file_okay=False, path_type=Path),
|
|
34
|
+
default=".",
|
|
35
|
+
help="Path to Git repository.",
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"-n",
|
|
39
|
+
"--count",
|
|
40
|
+
type=int,
|
|
41
|
+
default=1,
|
|
42
|
+
help="Number of commits to analyze (when using HEAD~n).",
|
|
43
|
+
)
|
|
44
|
+
@click.option(
|
|
45
|
+
"--api-key",
|
|
46
|
+
envvar="OPENAI_API_KEY",
|
|
47
|
+
help="OpenAI API key (or set OPENAI_API_KEY).",
|
|
48
|
+
)
|
|
49
|
+
@click.option(
|
|
50
|
+
"--model",
|
|
51
|
+
default="gpt-4o-mini",
|
|
52
|
+
help="OpenAI model to use.",
|
|
53
|
+
)
|
|
54
|
+
def analyze(
|
|
55
|
+
commit: str,
|
|
56
|
+
repo_path: Path,
|
|
57
|
+
count: int,
|
|
58
|
+
api_key: str | None,
|
|
59
|
+
model: str,
|
|
60
|
+
) -> None:
|
|
61
|
+
"""Analyze one or more commits for bugs and issues."""
|
|
62
|
+
repo = get_repo_path(str(repo_path))
|
|
63
|
+
key = api_key or os.environ.get("OPENAI_API_KEY")
|
|
64
|
+
if not key:
|
|
65
|
+
raise click.ClickException(
|
|
66
|
+
"OpenAI API key required. Set OPENAI_API_KEY or use --api-key."
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
refs = [commit] if count == 1 else [f"HEAD~{i}" for i in range(count)]
|
|
70
|
+
for ref in refs:
|
|
71
|
+
try:
|
|
72
|
+
result = analyze_commit(str(repo), ref, api_key=key, model=model)
|
|
73
|
+
click.echo()
|
|
74
|
+
click.secho(f"Commit: {ref}", fg="cyan", bold=True)
|
|
75
|
+
click.echo(result)
|
|
76
|
+
click.echo()
|
|
77
|
+
except Exception as e:
|
|
78
|
+
click.echo(click.style(f"Error analyzing {ref}: {e}", fg="red"))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@main.command()
|
|
82
|
+
@click.option(
|
|
83
|
+
"-r",
|
|
84
|
+
"--repo",
|
|
85
|
+
"repo_path",
|
|
86
|
+
type=click.Path(exists=True, file_okay=False, path_type=Path),
|
|
87
|
+
default=".",
|
|
88
|
+
help="Path to Git repository.",
|
|
89
|
+
)
|
|
90
|
+
@click.option(
|
|
91
|
+
"--api-key",
|
|
92
|
+
envvar="OPENAI_API_KEY",
|
|
93
|
+
help="OpenAI API key (or set OPENAI_API_KEY).",
|
|
94
|
+
)
|
|
95
|
+
@click.option(
|
|
96
|
+
"--model",
|
|
97
|
+
default="gpt-4o-mini",
|
|
98
|
+
help="OpenAI model to use.",
|
|
99
|
+
)
|
|
100
|
+
def check(
|
|
101
|
+
repo_path: Path,
|
|
102
|
+
api_key: str | None,
|
|
103
|
+
model: str,
|
|
104
|
+
) -> None:
|
|
105
|
+
"""Analyze staged changes (before commit)."""
|
|
106
|
+
repo = get_repo_path(str(repo_path))
|
|
107
|
+
key = api_key or os.environ.get("OPENAI_API_KEY")
|
|
108
|
+
if not key:
|
|
109
|
+
raise click.ClickException(
|
|
110
|
+
"OpenAI API key required. Set OPENAI_API_KEY or use --api-key."
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
click.echo("Analyzing staged changes...")
|
|
114
|
+
try:
|
|
115
|
+
result = analyze_staged(str(repo), api_key=key, model=model)
|
|
116
|
+
click.echo(result)
|
|
117
|
+
except Exception as e:
|
|
118
|
+
raise click.ClickException(str(e))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
main()
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: commitguard-ai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered tool to analyze Git commits for bugs and issues
|
|
5
|
+
Author: CommitGuard
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/PierrunoYT/commitguard
|
|
8
|
+
Project-URL: Repository, https://github.com/PierrunoYT/commitguard
|
|
9
|
+
Project-URL: Issues, https://github.com/PierrunoYT/commitguard/issues
|
|
10
|
+
Keywords: git,commit,ai,code-review,openai,cli,commitguard,commitguard-ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
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 :: Quality Assurance
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: click>=8.1.0
|
|
25
|
+
Requires-Dist: gitpython>=3.1.0
|
|
26
|
+
Requires-Dist: openai>=1.0.0
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# CommitGuard
|
|
34
|
+
|
|
35
|
+
AI-powered CLI that analyzes Git commits for bugs, security issues, and code quality problems.
|
|
36
|
+
|
|
37
|
+
**[GitHub](https://github.com/PierrunoYT/commitguard)**
|
|
38
|
+
|
|
39
|
+
## Requirements
|
|
40
|
+
|
|
41
|
+
- Python 3.9+
|
|
42
|
+
- OpenAI API key
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
From PyPI:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install commitguard-ai
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
From source (development):
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or install dependencies only:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install -r requirements.txt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
Set your OpenAI API key:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Linux / macOS
|
|
70
|
+
export OPENAI_API_KEY=sk-...
|
|
71
|
+
|
|
72
|
+
# Windows (PowerShell)
|
|
73
|
+
$env:OPENAI_API_KEY = "sk-..."
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or pass it via `--api-key` when running commands.
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
**Analyze the last commit (HEAD):**
|
|
81
|
+
```bash
|
|
82
|
+
commitguard analyze
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Analyze a specific commit:**
|
|
86
|
+
```bash
|
|
87
|
+
commitguard analyze abc123
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Analyze last 5 commits:**
|
|
91
|
+
```bash
|
|
92
|
+
commitguard analyze -n 5
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Analyze staged changes (before committing):**
|
|
96
|
+
```bash
|
|
97
|
+
commitguard check
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Options
|
|
101
|
+
|
|
102
|
+
| Option | Description |
|
|
103
|
+
|--------|-------------|
|
|
104
|
+
| `-r, --repo PATH` | Path to Git repository (default: current dir) |
|
|
105
|
+
| `--api-key KEY` | OpenAI API key (or use `OPENAI_API_KEY` env) |
|
|
106
|
+
| `--model MODEL` | Model to use (default: `gpt-4o-mini`) |
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
Run from source without installing:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python -m commitguard.cli analyze
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## License
|
|
117
|
+
|
|
118
|
+
[MIT](LICENSE)
|
|
119
|
+
|
|
120
|
+
## Changelog
|
|
121
|
+
|
|
122
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
commitguard/__init__.py
|
|
5
|
+
commitguard/analyzer.py
|
|
6
|
+
commitguard/cli.py
|
|
7
|
+
commitguard_ai.egg-info/PKG-INFO
|
|
8
|
+
commitguard_ai.egg-info/SOURCES.txt
|
|
9
|
+
commitguard_ai.egg-info/dependency_links.txt
|
|
10
|
+
commitguard_ai.egg-info/entry_points.txt
|
|
11
|
+
commitguard_ai.egg-info/requires.txt
|
|
12
|
+
commitguard_ai.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
commitguard
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "commitguard-ai"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "AI-powered tool to analyze Git commits for bugs and issues"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "CommitGuard"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["git", "commit", "ai", "code-review", "openai", "cli", "commitguard", "commitguard-ai"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.9",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"click>=8.1.0",
|
|
30
|
+
"gitpython>=3.1.0",
|
|
31
|
+
"openai>=1.0.0",
|
|
32
|
+
"python-dotenv>=1.0.0",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
dev = [
|
|
37
|
+
"pytest>=7.0",
|
|
38
|
+
"ruff>=0.1.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/PierrunoYT/commitguard"
|
|
43
|
+
Repository = "https://github.com/PierrunoYT/commitguard"
|
|
44
|
+
Issues = "https://github.com/PierrunoYT/commitguard/issues"
|
|
45
|
+
|
|
46
|
+
[project.scripts]
|
|
47
|
+
commitguard = "commitguard.cli:main"
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
include = ["commitguard*"]
|