Skip to content

Commit 48a9550

Browse files
Initial commit: AI Dev Copilot — review, test & document code with Gemini
Three unified dev agents (reviewer, tester, documenter) behind one CLI, built on Google Gemini with a shared client, unit-tested pure helpers, packaging, and CI across Python 3.10-3.12. Inspired by the 500-AI-Agents-Projects collection (MIT), reimplemented from scratch on Gemini. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 parents  commit 48a9550

16 files changed

Lines changed: 727 additions & 0 deletions

File tree

‎.env.example‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Get a free API key at https://aistudio.google.com/app/apikey
2+
GEMINI_API_KEY=your-key-here
3+
4+
# Optional: override the default model (gemini-2.0-flash)
5+
# GEMINI_MODEL=gemini-2.0-flash

‎.github/workflows/ci.yaml‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -e ".[dev]"
25+
- name: Lint
26+
run: ruff check .
27+
- name: Test
28+
run: pytest -v

‎.gitignore‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*.egg-info/
5+
build/
6+
dist/
7+
.pytest_cache/
8+
.ruff_cache/
9+
.coverage
10+
11+
# Environment
12+
.env
13+
.venv/
14+
venv/
15+
16+
# Generated by the copilot (anchored to repo root so real tests/ stay tracked)
17+
/test_*.py
18+
/README_*.md
19+
/documented_*.py
20+
21+
# IDE / OS
22+
.vscode/
23+
.idea/
24+
.DS_Store

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Meriam Inoubli
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.

‎README.md‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# 🤖 AI Dev Copilot
2+
3+
> Review, test and document your Python code with **Google Gemini** — three developer agents in one clean CLI.
4+
5+
[![CI](https://github.com/Meriam-Inoubli/ai-dev-copilot/actions/workflows/ci.yaml/badge.svg)](https://github.com/Meriam-Inoubli/ai-dev-copilot/actions/workflows/ci.yaml)
6+
[![Python](https://img.shields.io/badge/python-3.10%2B-blue?logo=python&logoColor=white)](https://www.python.org/)
7+
[![Gemini](https://img.shields.io/badge/LLM-Google%20Gemini-8E75B2?logo=googlegemini&logoColor=white)](https://ai.google.dev/)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
9+
10+
**AI Dev Copilot** bundles three focused agents behind a single command:
11+
12+
| Agent | What it does |
13+
|-------|--------------|
14+
| 🔍 **Reviewer** | Structured review — bugs, security, performance, style, with concrete fixes |
15+
| 🧪 **Tester** | Generates a ready-to-run `pytest` suite (happy paths, edge cases, errors) |
16+
| 📝 **Documenter** | Writes a professional README and adds Google-style docstrings |
17+
18+
Run them individually, or run **`all`** to review + test + document a file in one pass.
19+
20+
---
21+
22+
## ✨ Why this exists
23+
24+
Most "AI agent" demos are single throwaway scripts, each reinventing its own LLM
25+
plumbing. AI Dev Copilot is built like a small product instead:
26+
27+
- **One shared Gemini client** (`llm.py`) — consistent config, one place to change models.
28+
- **Pure, tested helpers** — AST-based structure extraction and fence-stripping are unit-tested with **no API key required**, so CI stays green and free.
29+
- **Zero-setup demo** — every command falls back to a bundled example file, so you can try it before wiring up your own code.
30+
- **Proper packaging** — installable, with a `devcopilot` entry point, `ruff` linting and CI across Python 3.10–3.12.
31+
32+
---
33+
34+
## 🚀 Quick Start
35+
36+
```bash
37+
git clone https://github.com/Meriam-Inoubli/ai-dev-copilot.git
38+
cd ai-dev-copilot
39+
40+
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
41+
pip install -e .
42+
43+
cp .env.example .env # then paste your free Gemini key
44+
```
45+
46+
Get a free key at **[aistudio.google.com/app/apikey](https://aistudio.google.com/app/apikey)**.
47+
48+
```bash
49+
# Try it instantly on the bundled demo (no --file needed)
50+
devcopilot review
51+
52+
# Point it at your own code
53+
devcopilot review --file path/to/app.py
54+
devcopilot test --file path/to/app.py --output tests/test_app.py
55+
devcopilot doc --file path/to/app.py --mode readme
56+
devcopilot all --file path/to/app.py
57+
```
58+
59+
---
60+
61+
## 🧑‍💻 Use it as a library
62+
63+
```python
64+
from ai_dev_copilot import review_code, generate_tests, generate_readme
65+
66+
code = open("app.py").read()
67+
68+
print(review_code(code)) # markdown review
69+
open("test_app.py", "w").write(generate_tests(code, "app"))
70+
open("README_app.md", "w").write(generate_readme(code, "app.py"))
71+
```
72+
73+
---
74+
75+
## 🏗️ Architecture
76+
77+
```
78+
src/ai_dev_copilot/
79+
├── llm.py # single Gemini client (system + user prompt → text)
80+
├── utils.py # pure helpers: AST outline, code-fence stripping (unit-tested)
81+
├── reviewer.py # 🔍 review_code()
82+
├── tester.py # 🧪 generate_tests()
83+
├── documenter.py # 📄 generate_readme() + add_docstrings()
84+
└── cli.py # devcopilot: review | test | doc | all
85+
```
86+
87+
Each agent is just a focused prompt over the shared client — easy to read, extend, or swap the model.
88+
89+
---
90+
91+
## ⚙️ Configuration
92+
93+
| Variable | Default | Description |
94+
|----------|---------|-------------|
95+
| `GEMINI_API_KEY` | — | Your Gemini API key (required for live calls) |
96+
| `GEMINI_MODEL` | `gemini-2.0-flash` | Model override |
97+
98+
---
99+
100+
## 🧪 Development
101+
102+
```bash
103+
pip install -e ".[dev]"
104+
pytest -v # runs offline — no API key needed
105+
ruff check .
106+
```
107+
108+
---
109+
110+
## 🙏 Credits
111+
112+
The three agent ideas were inspired by the excellent
113+
[500 AI Agents Projects](https://github.com/ashishpatel26/500-AI-Agents-Projects)
114+
collection (MIT). This project reimplements them from scratch on **Gemini**, unified
115+
into one tested, installable package.
116+
117+
## 📄 License
118+
119+
[MIT](LICENSE) © 2026 Meriam Inoubli

‎examples/sample_module.py‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""A small sample module the copilot can review, test and document."""
2+
3+
4+
def calculate_discount(price, discount_percent):
5+
if price < 0:
6+
raise ValueError("Price cannot be negative")
7+
if not 0 <= discount_percent <= 100:
8+
raise ValueError("Discount must be between 0 and 100")
9+
return price * (1 - discount_percent / 100)
10+
11+
12+
def find_longest_word(text):
13+
if not text or not text.strip():
14+
return ""
15+
return max(text.split(), key=len)
16+
17+
18+
class ShoppingCart:
19+
def __init__(self):
20+
self.items = {}
21+
22+
def add_item(self, name, price, quantity=1):
23+
if price < 0:
24+
raise ValueError("Price cannot be negative")
25+
if quantity < 1:
26+
raise ValueError("Quantity must be at least 1")
27+
if name in self.items:
28+
self.items[name]["quantity"] += quantity
29+
else:
30+
self.items[name] = {"price": price, "quantity": quantity}
31+
32+
def remove_item(self, name):
33+
if name not in self.items:
34+
raise KeyError(f"Item '{name}' not in cart")
35+
del self.items[name]
36+
37+
def total(self):
38+
return sum(i["price"] * i["quantity"] for i in self.items.values())

‎pyproject.toml‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[build-system]
2+
requires = ["setuptools>=68"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "ai-dev-copilot"
7+
version = "0.1.0"
8+
description = "Review, test and document Python code with Google Gemini — three dev agents in one CLI."
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
license = { text = "MIT" }
12+
authors = [{ name = "Meriam Inoubli", email = "meriam.inoubli@dauphine.tn" }]
13+
keywords = ["ai", "agent", "gemini", "llm", "code-review", "test-generation", "documentation", "devtools"]
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"License :: OSI Approved :: MIT License",
17+
"Topic :: Software Development :: Quality Assurance",
18+
]
19+
dependencies = [
20+
"google-generativeai>=0.8.0",
21+
"python-dotenv>=1.0.0",
22+
]
23+
24+
[project.optional-dependencies]
25+
dev = ["pytest>=8.0", "ruff>=0.6"]
26+
27+
[project.urls]
28+
Homepage = "https://github.com/Meriam-Inoubli/ai-dev-copilot"
29+
Issues = "https://github.com/Meriam-Inoubli/ai-dev-copilot/issues"
30+
31+
[project.scripts]
32+
devcopilot = "ai_dev_copilot.cli:main"
33+
34+
[tool.setuptools.packages.find]
35+
where = ["src"]
36+
37+
[tool.pytest.ini_options]
38+
pythonpath = ["src"]
39+
testpaths = ["tests"]
40+
41+
[tool.ruff]
42+
line-length = 100

‎requirements.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
google-generativeai>=0.8.0
2+
python-dotenv>=1.0.0

‎src/ai_dev_copilot/__init__.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""AI Dev Copilot — review, test and document Python code with Gemini.
2+
3+
A single, cohesive toolkit that combines three developer agents:
4+
5+
* :func:`~ai_dev_copilot.reviewer.review_code` — structured code review
6+
* :func:`~ai_dev_copilot.tester.generate_tests` — pytest suite generation
7+
* :func:`~ai_dev_copilot.documenter.generate_readme` / ``add_docstrings`` — docs
8+
"""
9+
10+
from __future__ import annotations
11+
12+
from .documenter import add_docstrings, generate_readme
13+
from .reviewer import review_code
14+
from .tester import generate_tests
15+
16+
__version__ = "0.1.0"
17+
18+
__all__ = [
19+
"__version__",
20+
"add_docstrings",
21+
"generate_readme",
22+
"generate_tests",
23+
"review_code",
24+
]

0 commit comments

Comments
 (0)