codeyak 0.0.1__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.
- codeyak-0.0.1/.env.example +14 -0
- codeyak-0.0.1/.github/workflows/publish.yml +26 -0
- codeyak-0.0.1/.gitignore +20 -0
- codeyak-0.0.1/.vscode/settings.json +13 -0
- codeyak-0.0.1/.vscode/tasks.json +67 -0
- codeyak-0.0.1/LICENSE +21 -0
- codeyak-0.0.1/PKG-INFO +200 -0
- codeyak-0.0.1/README.md +164 -0
- codeyak-0.0.1/TODO.md +10 -0
- codeyak-0.0.1/images/codeyak-logo-circle.png +0 -0
- codeyak-0.0.1/images/codeyak-logo.png +0 -0
- codeyak-0.0.1/pyproject.toml +76 -0
- codeyak-0.0.1/src/codeyak/__init__.py +3 -0
- codeyak-0.0.1/src/codeyak/__main__.py +27 -0
- codeyak-0.0.1/src/codeyak/apps/__init__.py +3 -0
- codeyak-0.0.1/src/codeyak/apps/cli/__init__.py +7 -0
- codeyak-0.0.1/src/codeyak/apps/cli/configure.py +185 -0
- codeyak-0.0.1/src/codeyak/apps/cli/main.py +262 -0
- codeyak-0.0.1/src/codeyak/config.py +145 -0
- codeyak-0.0.1/src/codeyak/domain/__init__.py +52 -0
- codeyak-0.0.1/src/codeyak/domain/exceptions.py +55 -0
- codeyak-0.0.1/src/codeyak/domain/models.py +334 -0
- codeyak-0.0.1/src/codeyak/infrastructure/__init__.py +17 -0
- codeyak-0.0.1/src/codeyak/infrastructure/llm/azure.py +59 -0
- codeyak-0.0.1/src/codeyak/infrastructure/vcs/diff_parser.py +110 -0
- codeyak-0.0.1/src/codeyak/infrastructure/vcs/gitlab.py +342 -0
- codeyak-0.0.1/src/codeyak/infrastructure/vcs/local_git.py +209 -0
- codeyak-0.0.1/src/codeyak/prebuilt/__init__.py +0 -0
- codeyak-0.0.1/src/codeyak/prebuilt/code-quality.yaml +32 -0
- codeyak-0.0.1/src/codeyak/prebuilt/default.yaml +6 -0
- codeyak-0.0.1/src/codeyak/prebuilt/security.yaml +51 -0
- codeyak-0.0.1/src/codeyak/protocols/__init__.py +128 -0
- codeyak-0.0.1/src/codeyak/py.typed +0 -0
- codeyak-0.0.1/src/codeyak/services/__init__.py +22 -0
- codeyak-0.0.1/src/codeyak/services/code.py +92 -0
- codeyak-0.0.1/src/codeyak/services/context.py +150 -0
- codeyak-0.0.1/src/codeyak/services/feedback/__init__.py +11 -0
- codeyak-0.0.1/src/codeyak/services/feedback/console.py +96 -0
- codeyak-0.0.1/src/codeyak/services/feedback/merge_request.py +89 -0
- codeyak-0.0.1/src/codeyak/services/guidelines/__init__.py +27 -0
- codeyak-0.0.1/src/codeyak/services/guidelines/parser.py +461 -0
- codeyak-0.0.1/src/codeyak/services/guidelines/provider.py +399 -0
- codeyak-0.0.1/src/codeyak/services/reviewer.py +325 -0
- codeyak-0.0.1/src/codeyak/services/summary.py +131 -0
- codeyak-0.0.1/uv.lock +1719 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# GitLab Configuration
|
|
2
|
+
GITLAB_URL=https://gitlab.com
|
|
3
|
+
GITLAB_TOKEN=
|
|
4
|
+
|
|
5
|
+
# Azure OpenAI Configuration
|
|
6
|
+
AZURE_OPENAI_API_KEY=
|
|
7
|
+
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
|
|
8
|
+
AZURE_OPENAI_API_VERSION=2024-02-15-preview
|
|
9
|
+
AZURE_DEPLOYMENT_NAME=gpt-4o
|
|
10
|
+
|
|
11
|
+
# Observability (Langfuse)
|
|
12
|
+
LANGFUSE_SECRET_KEY=
|
|
13
|
+
LANGFUSE_PUBLIC_KEY=
|
|
14
|
+
LANGFUSE_HOST=https://cloud.langfuse.com
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment: pypi
|
|
12
|
+
permissions:
|
|
13
|
+
id-token: write
|
|
14
|
+
contents: read
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
|
|
22
|
+
- name: Build package
|
|
23
|
+
run: uv build
|
|
24
|
+
|
|
25
|
+
- name: Publish to PyPI
|
|
26
|
+
run: uv publish
|
codeyak-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"python.testing.pytestEnabled": true,
|
|
3
|
+
"python.testing.unittestEnabled": false,
|
|
4
|
+
"python.testing.pytestArgs": [
|
|
5
|
+
"tests"
|
|
6
|
+
],
|
|
7
|
+
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
|
|
8
|
+
"python.testing.pytestPath": "uv",
|
|
9
|
+
"python.testing.pytestExtraArgs": [
|
|
10
|
+
"run",
|
|
11
|
+
"pytest"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "Run All Tests",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "uv run pytest",
|
|
8
|
+
"options": {
|
|
9
|
+
"cwd": "${workspaceFolder}"
|
|
10
|
+
},
|
|
11
|
+
"group": "test",
|
|
12
|
+
"presentation": {
|
|
13
|
+
"reveal": "always",
|
|
14
|
+
"panel": "dedicated",
|
|
15
|
+
"focus": true
|
|
16
|
+
},
|
|
17
|
+
"problemMatcher": []
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"label": "Run Tests with Coverage",
|
|
21
|
+
"type": "shell",
|
|
22
|
+
"command": "uv run pytest --cov=src/codeyak --cov-report=term-missing",
|
|
23
|
+
"group": "test",
|
|
24
|
+
"presentation": {
|
|
25
|
+
"reveal": "always",
|
|
26
|
+
"panel": "dedicated"
|
|
27
|
+
},
|
|
28
|
+
"problemMatcher": []
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"label": "Run Current File Tests",
|
|
32
|
+
"type": "shell",
|
|
33
|
+
"command": "uv run pytest ${file}",
|
|
34
|
+
"group": "test",
|
|
35
|
+
"presentation": {
|
|
36
|
+
"reveal": "always",
|
|
37
|
+
"panel": "dedicated"
|
|
38
|
+
},
|
|
39
|
+
"problemMatcher": []
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"label": "Run Tests (Verbose)",
|
|
43
|
+
"type": "shell",
|
|
44
|
+
"command": "uv run pytest -v",
|
|
45
|
+
"group": "test",
|
|
46
|
+
"presentation": {
|
|
47
|
+
"reveal": "always",
|
|
48
|
+
"panel": "dedicated"
|
|
49
|
+
},
|
|
50
|
+
"problemMatcher": []
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"label": "Run Tests (Fast Fail)",
|
|
54
|
+
"type": "shell",
|
|
55
|
+
"command": "uv run pytest -x",
|
|
56
|
+
"group": {
|
|
57
|
+
"kind": "test",
|
|
58
|
+
"isDefault": true
|
|
59
|
+
},
|
|
60
|
+
"presentation": {
|
|
61
|
+
"reveal": "always",
|
|
62
|
+
"panel": "dedicated"
|
|
63
|
+
},
|
|
64
|
+
"problemMatcher": []
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
codeyak-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ray Martinez
|
|
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.
|
codeyak-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codeyak
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A code review agent optimized for following strict guidelines
|
|
5
|
+
Project-URL: Homepage, https://github.com/ai-rayven/codeyak
|
|
6
|
+
Project-URL: Repository, https://github.com/ai-rayven/codeyak
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/ai-rayven/codeyak/issues
|
|
8
|
+
Author-email: Ray Martinez <raiselmartinez@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,automation,azure-openai,code-review,gitlab,linting,llm
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
20
|
+
Classifier: Topic :: Software Development :: Testing
|
|
21
|
+
Requires-Python: >=3.12
|
|
22
|
+
Requires-Dist: click>=8.1.0
|
|
23
|
+
Requires-Dist: gitpython>=3.1.0
|
|
24
|
+
Requires-Dist: instructor>=1.14.1
|
|
25
|
+
Requires-Dist: langfuse>=3.11.2
|
|
26
|
+
Requires-Dist: openai>=2.15.0
|
|
27
|
+
Requires-Dist: pydantic-settings>=2.12.0
|
|
28
|
+
Requires-Dist: python-gitlab>=7.1.0
|
|
29
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
30
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
31
|
+
Provides-Extra: test
|
|
32
|
+
Requires-Dist: pytest-cov>=6.0.0; extra == 'test'
|
|
33
|
+
Requires-Dist: pytest-mock>=3.14.0; extra == 'test'
|
|
34
|
+
Requires-Dist: pytest>=8.0.0; extra == 'test'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# CodeYak 🐻 - Guard your codebase
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="images/codeyak-logo-circle.png" alt="CodeYak Logo" width="200"/>
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+

|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
**Built Strong:**
|
|
49
|
+
- 🎯 **Territorial guidelines system** - Defend your code standards with built-in presets (security, style, balanced)
|
|
50
|
+
- 🔍 **Multi-pass hunting** - Thorough, focused reviews that don't miss a thing
|
|
51
|
+
- 🧠 **Smart deduplication** - Never repeats itself
|
|
52
|
+
|
|
53
|
+
**Current Territory:** GitLab + Azure OpenAI (Expanding to GitHub, OpenAI, Anthropic)
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
56
|
+
|
|
57
|
+
1. Configure CI/CD variables in GitLab (Settings → CI/CD → Variables):
|
|
58
|
+
- `GITLAB_TOKEN`, `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_DEPLOYMENT_NAME`, `AGENT_REPO_URL`
|
|
59
|
+
|
|
60
|
+
2. Add to `.gitlab-ci.yml`:
|
|
61
|
+
```yaml
|
|
62
|
+
codeyak:
|
|
63
|
+
stage: review
|
|
64
|
+
image: python:3.12-slim
|
|
65
|
+
before_script:
|
|
66
|
+
- apt-get update && apt-get install -y git && pip install uv
|
|
67
|
+
script:
|
|
68
|
+
- git clone $AGENT_REPO_URL agent_code && cd agent_code
|
|
69
|
+
- uv sync --frozen
|
|
70
|
+
- uv run python -m codeyak $CI_MERGE_REQUEST_IID $CI_PROJECT_ID
|
|
71
|
+
rules:
|
|
72
|
+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. **Watch it work** - Open a merge request and CodeYak automatically hunts for issues
|
|
76
|
+
|
|
77
|
+
## Guidelines System
|
|
78
|
+
|
|
79
|
+
Command CodeYak's behavior with YAML guideline files. The bear follows:
|
|
80
|
+
- **Your project guidelines** (`.codeyak/*.yaml`) when marking territory
|
|
81
|
+
- **Built-in `default` preset** when roaming free
|
|
82
|
+
|
|
83
|
+
Each YAML file triggers a separate focused hunting pass.
|
|
84
|
+
|
|
85
|
+
### Battle-Tested Presets
|
|
86
|
+
|
|
87
|
+
**`default`** - Full-strength protection (32 guidelines)
|
|
88
|
+
- Combines: `security` + `readability` + `maintainability`
|
|
89
|
+
- Comprehensive coverage of code quality
|
|
90
|
+
|
|
91
|
+
**`security`** - Fortress mode (15 guidelines)
|
|
92
|
+
- Secrets management, injection prevention (SQL, XSS, command)
|
|
93
|
+
- Authentication, authorization, session management
|
|
94
|
+
- Strong cryptography, password hashing
|
|
95
|
+
- Data encryption, safe error handling
|
|
96
|
+
|
|
97
|
+
**`readability`** - Crystal clear code (7 guidelines)
|
|
98
|
+
- Function length and clarity
|
|
99
|
+
- Descriptive and intentional naming
|
|
100
|
+
- Self-documenting code, meaningful comments
|
|
101
|
+
|
|
102
|
+
**`maintainability`** - Built to last (10 guidelines)
|
|
103
|
+
- Single Responsibility, low complexity
|
|
104
|
+
- Logical organization, code proximity
|
|
105
|
+
- DRY principle, no dead code
|
|
106
|
+
- Proper exception handling
|
|
107
|
+
|
|
108
|
+
### Custom Guidelines
|
|
109
|
+
|
|
110
|
+
Train CodeYak with your own rules in `.codeyak/my-rules.yaml`:
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
guidelines:
|
|
114
|
+
- label: rate-limiting
|
|
115
|
+
description: All API endpoints must include rate limiting.
|
|
116
|
+
|
|
117
|
+
- label: n-plus-one
|
|
118
|
+
description: Avoid N+1 queries by using eager loading.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Guidelines are automatically tagged based on filename and label:
|
|
122
|
+
- File: `my-rules.yaml` → Prefix: `my-rules`
|
|
123
|
+
- Label: `rate-limiting` → ID: `my-rules/rate-limiting`
|
|
124
|
+
|
|
125
|
+
**ID format:** `prefix/label` (e.g., `security/sql-injection`, `custom/rate-limiting`)
|
|
126
|
+
**Label requirements:** lowercase, alphanumeric, hyphens only
|
|
127
|
+
|
|
128
|
+
### Combining Forces
|
|
129
|
+
|
|
130
|
+
Stack built-in presets with your custom rules:
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
includes:
|
|
134
|
+
- builtin:security
|
|
135
|
+
- builtin:readability
|
|
136
|
+
|
|
137
|
+
guidelines:
|
|
138
|
+
- label: api-timeout
|
|
139
|
+
description: All external API calls must have timeout limits.
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Available reinforcements:** `builtin:default`, `builtin:security`, `builtin:readability`, `builtin:maintainability`
|
|
143
|
+
|
|
144
|
+
### Multi-Pass Reviews
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
.codeyak/
|
|
148
|
+
├── 01-security.yaml # Security sweep
|
|
149
|
+
├── 02-style.yaml # Style enforcement
|
|
150
|
+
└── 03-project-rules.yaml # Your custom rules
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Each file can include built-in presets or define custom guidelines. CodeYak never misses.
|
|
154
|
+
|
|
155
|
+
## Environment Variables
|
|
156
|
+
|
|
157
|
+
**Required:**
|
|
158
|
+
```bash
|
|
159
|
+
GITLAB_URL=https://gitlab.com
|
|
160
|
+
GITLAB_TOKEN=<your-token>
|
|
161
|
+
AZURE_OPENAI_API_KEY=<your-key>
|
|
162
|
+
AZURE_OPENAI_ENDPOINT=<your-endpoint>
|
|
163
|
+
AZURE_OPENAI_API_VERSION=2024-02-15-preview
|
|
164
|
+
AZURE_DEPLOYMENT_NAME=gpt-4o
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Optional:**
|
|
168
|
+
```bash
|
|
169
|
+
LANGFUSE_SECRET_KEY=<key> # For observability
|
|
170
|
+
LANGFUSE_PUBLIC_KEY=<key>
|
|
171
|
+
LANGFUSE_HOST=https://cloud.langfuse.com
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Local Development
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Get the bear
|
|
178
|
+
git clone <repo-url> && cd codeyak
|
|
179
|
+
cp .env.example .env # Fill in credentials
|
|
180
|
+
uv sync
|
|
181
|
+
|
|
182
|
+
# Release it on a merge request
|
|
183
|
+
uv run python -m codeyak <MR_IID> <PROJECT_ID>
|
|
184
|
+
|
|
185
|
+
# Test with custom guidelines
|
|
186
|
+
mkdir -p .codeyak
|
|
187
|
+
echo "includes:
|
|
188
|
+
- builtin:security" > .codeyak/security.yaml
|
|
189
|
+
uv run python -m codeyak <MR_IID> <PROJECT_ID>
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## How It Works
|
|
193
|
+
|
|
194
|
+
1. Fetches MR diff and existing review comments
|
|
195
|
+
2. Runs review pass(es) based on active guidelines
|
|
196
|
+
4. Posts only new, unique findings as inline comments
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
**Built with fierce determination** 🐻 **using Python and AI**
|
codeyak-0.0.1/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# CodeYak 🐻 - Guard your codebase
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="images/codeyak-logo-circle.png" alt="CodeYak Logo" width="200"/>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
**Built Strong:**
|
|
13
|
+
- 🎯 **Territorial guidelines system** - Defend your code standards with built-in presets (security, style, balanced)
|
|
14
|
+
- 🔍 **Multi-pass hunting** - Thorough, focused reviews that don't miss a thing
|
|
15
|
+
- 🧠 **Smart deduplication** - Never repeats itself
|
|
16
|
+
|
|
17
|
+
**Current Territory:** GitLab + Azure OpenAI (Expanding to GitHub, OpenAI, Anthropic)
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
1. Configure CI/CD variables in GitLab (Settings → CI/CD → Variables):
|
|
22
|
+
- `GITLAB_TOKEN`, `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, `AZURE_DEPLOYMENT_NAME`, `AGENT_REPO_URL`
|
|
23
|
+
|
|
24
|
+
2. Add to `.gitlab-ci.yml`:
|
|
25
|
+
```yaml
|
|
26
|
+
codeyak:
|
|
27
|
+
stage: review
|
|
28
|
+
image: python:3.12-slim
|
|
29
|
+
before_script:
|
|
30
|
+
- apt-get update && apt-get install -y git && pip install uv
|
|
31
|
+
script:
|
|
32
|
+
- git clone $AGENT_REPO_URL agent_code && cd agent_code
|
|
33
|
+
- uv sync --frozen
|
|
34
|
+
- uv run python -m codeyak $CI_MERGE_REQUEST_IID $CI_PROJECT_ID
|
|
35
|
+
rules:
|
|
36
|
+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
3. **Watch it work** - Open a merge request and CodeYak automatically hunts for issues
|
|
40
|
+
|
|
41
|
+
## Guidelines System
|
|
42
|
+
|
|
43
|
+
Command CodeYak's behavior with YAML guideline files. The bear follows:
|
|
44
|
+
- **Your project guidelines** (`.codeyak/*.yaml`) when marking territory
|
|
45
|
+
- **Built-in `default` preset** when roaming free
|
|
46
|
+
|
|
47
|
+
Each YAML file triggers a separate focused hunting pass.
|
|
48
|
+
|
|
49
|
+
### Battle-Tested Presets
|
|
50
|
+
|
|
51
|
+
**`default`** - Full-strength protection (32 guidelines)
|
|
52
|
+
- Combines: `security` + `readability` + `maintainability`
|
|
53
|
+
- Comprehensive coverage of code quality
|
|
54
|
+
|
|
55
|
+
**`security`** - Fortress mode (15 guidelines)
|
|
56
|
+
- Secrets management, injection prevention (SQL, XSS, command)
|
|
57
|
+
- Authentication, authorization, session management
|
|
58
|
+
- Strong cryptography, password hashing
|
|
59
|
+
- Data encryption, safe error handling
|
|
60
|
+
|
|
61
|
+
**`readability`** - Crystal clear code (7 guidelines)
|
|
62
|
+
- Function length and clarity
|
|
63
|
+
- Descriptive and intentional naming
|
|
64
|
+
- Self-documenting code, meaningful comments
|
|
65
|
+
|
|
66
|
+
**`maintainability`** - Built to last (10 guidelines)
|
|
67
|
+
- Single Responsibility, low complexity
|
|
68
|
+
- Logical organization, code proximity
|
|
69
|
+
- DRY principle, no dead code
|
|
70
|
+
- Proper exception handling
|
|
71
|
+
|
|
72
|
+
### Custom Guidelines
|
|
73
|
+
|
|
74
|
+
Train CodeYak with your own rules in `.codeyak/my-rules.yaml`:
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
guidelines:
|
|
78
|
+
- label: rate-limiting
|
|
79
|
+
description: All API endpoints must include rate limiting.
|
|
80
|
+
|
|
81
|
+
- label: n-plus-one
|
|
82
|
+
description: Avoid N+1 queries by using eager loading.
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Guidelines are automatically tagged based on filename and label:
|
|
86
|
+
- File: `my-rules.yaml` → Prefix: `my-rules`
|
|
87
|
+
- Label: `rate-limiting` → ID: `my-rules/rate-limiting`
|
|
88
|
+
|
|
89
|
+
**ID format:** `prefix/label` (e.g., `security/sql-injection`, `custom/rate-limiting`)
|
|
90
|
+
**Label requirements:** lowercase, alphanumeric, hyphens only
|
|
91
|
+
|
|
92
|
+
### Combining Forces
|
|
93
|
+
|
|
94
|
+
Stack built-in presets with your custom rules:
|
|
95
|
+
|
|
96
|
+
```yaml
|
|
97
|
+
includes:
|
|
98
|
+
- builtin:security
|
|
99
|
+
- builtin:readability
|
|
100
|
+
|
|
101
|
+
guidelines:
|
|
102
|
+
- label: api-timeout
|
|
103
|
+
description: All external API calls must have timeout limits.
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Available reinforcements:** `builtin:default`, `builtin:security`, `builtin:readability`, `builtin:maintainability`
|
|
107
|
+
|
|
108
|
+
### Multi-Pass Reviews
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
.codeyak/
|
|
112
|
+
├── 01-security.yaml # Security sweep
|
|
113
|
+
├── 02-style.yaml # Style enforcement
|
|
114
|
+
└── 03-project-rules.yaml # Your custom rules
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Each file can include built-in presets or define custom guidelines. CodeYak never misses.
|
|
118
|
+
|
|
119
|
+
## Environment Variables
|
|
120
|
+
|
|
121
|
+
**Required:**
|
|
122
|
+
```bash
|
|
123
|
+
GITLAB_URL=https://gitlab.com
|
|
124
|
+
GITLAB_TOKEN=<your-token>
|
|
125
|
+
AZURE_OPENAI_API_KEY=<your-key>
|
|
126
|
+
AZURE_OPENAI_ENDPOINT=<your-endpoint>
|
|
127
|
+
AZURE_OPENAI_API_VERSION=2024-02-15-preview
|
|
128
|
+
AZURE_DEPLOYMENT_NAME=gpt-4o
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Optional:**
|
|
132
|
+
```bash
|
|
133
|
+
LANGFUSE_SECRET_KEY=<key> # For observability
|
|
134
|
+
LANGFUSE_PUBLIC_KEY=<key>
|
|
135
|
+
LANGFUSE_HOST=https://cloud.langfuse.com
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Local Development
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Get the bear
|
|
142
|
+
git clone <repo-url> && cd codeyak
|
|
143
|
+
cp .env.example .env # Fill in credentials
|
|
144
|
+
uv sync
|
|
145
|
+
|
|
146
|
+
# Release it on a merge request
|
|
147
|
+
uv run python -m codeyak <MR_IID> <PROJECT_ID>
|
|
148
|
+
|
|
149
|
+
# Test with custom guidelines
|
|
150
|
+
mkdir -p .codeyak
|
|
151
|
+
echo "includes:
|
|
152
|
+
- builtin:security" > .codeyak/security.yaml
|
|
153
|
+
uv run python -m codeyak <MR_IID> <PROJECT_ID>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## How It Works
|
|
157
|
+
|
|
158
|
+
1. Fetches MR diff and existing review comments
|
|
159
|
+
2. Runs review pass(es) based on active guidelines
|
|
160
|
+
4. Posts only new, unique findings as inline comments
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
**Built with fierce determination** 🐻 **using Python and AI**
|
codeyak-0.0.1/TODO.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
TODO:
|
|
3
|
+
- need to determine when a new lib is used or updated to add web search to get context around the lib and usage
|
|
4
|
+
- handle multiple triggers to same MR what to do?
|
|
5
|
+
- model can change scope and review also, consistencny??
|
|
6
|
+
|
|
7
|
+
- need some way to add context for each project?? or maybe just guidelines is good enough for now?
|
|
8
|
+
- think about what you are reviewing, is it SDK, microservice, API? etc
|
|
9
|
+
|
|
10
|
+
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "codeyak"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "A code review agent optimized for following strict guidelines"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Ray Martinez", email = "raiselmartinez@gmail.com" }
|
|
9
|
+
]
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
keywords = [
|
|
12
|
+
"code-review",
|
|
13
|
+
"ai",
|
|
14
|
+
"llm",
|
|
15
|
+
"gitlab",
|
|
16
|
+
"automation",
|
|
17
|
+
"linting",
|
|
18
|
+
"azure-openai",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Environment :: Console",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Operating System :: OS Independent",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
29
|
+
"Topic :: Software Development :: Testing",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"click>=8.1.0",
|
|
33
|
+
"gitpython>=3.1.0",
|
|
34
|
+
"instructor>=1.14.1",
|
|
35
|
+
"langfuse>=3.11.2",
|
|
36
|
+
"openai>=2.15.0",
|
|
37
|
+
"pydantic-settings>=2.12.0",
|
|
38
|
+
"python-gitlab>=7.1.0",
|
|
39
|
+
"pyyaml>=6.0.1",
|
|
40
|
+
"tomli-w>=1.0.0",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/ai-rayven/codeyak"
|
|
45
|
+
Repository = "https://github.com/ai-rayven/codeyak"
|
|
46
|
+
"Bug Tracker" = "https://github.com/ai-rayven/codeyak/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
yak = "codeyak.apps.cli:main"
|
|
50
|
+
|
|
51
|
+
[project.optional-dependencies]
|
|
52
|
+
test = [
|
|
53
|
+
"pytest>=8.0.0",
|
|
54
|
+
"pytest-cov>=6.0.0",
|
|
55
|
+
"pytest-mock>=3.14.0",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[build-system]
|
|
59
|
+
requires = ["hatchling"]
|
|
60
|
+
build-backend = "hatchling.build"
|
|
61
|
+
|
|
62
|
+
[tool.hatch.build.targets.wheel]
|
|
63
|
+
packages = ["src/codeyak"]
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
minversion = "8.0"
|
|
67
|
+
testpaths = ["tests"]
|
|
68
|
+
python_files = ["test_*.py"]
|
|
69
|
+
python_classes = ["Test*"]
|
|
70
|
+
python_functions = ["test_*"]
|
|
71
|
+
addopts = [
|
|
72
|
+
"-ra",
|
|
73
|
+
"--strict-markers",
|
|
74
|
+
"--strict-config",
|
|
75
|
+
"--showlocals",
|
|
76
|
+
]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Entry point for running codeyak as a module.
|
|
3
|
+
|
|
4
|
+
Supports both the new CLI interface and backwards-compatible direct invocation:
|
|
5
|
+
python -m codeyak review # New: local review
|
|
6
|
+
python -m codeyak mr <MR_ID> [PROJECT_ID] # New: MR review
|
|
7
|
+
python -m codeyak <MR_ID> [PROJECT_ID] # Legacy: MR review
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main():
|
|
14
|
+
"""Entry point that handles both CLI and legacy invocation."""
|
|
15
|
+
# Check if using legacy invocation (first arg is a number = MR_ID)
|
|
16
|
+
if len(sys.argv) > 1 and sys.argv[1].isdigit():
|
|
17
|
+
# Legacy mode: convert to new CLI format
|
|
18
|
+
# python -m codeyak <MR_ID> [PROJECT_ID] -> yak mr <MR_ID> [PROJECT_ID]
|
|
19
|
+
sys.argv = [sys.argv[0], "mr"] + sys.argv[1:]
|
|
20
|
+
|
|
21
|
+
# Import and run CLI
|
|
22
|
+
from .apps.cli import main as cli_main
|
|
23
|
+
cli_main()
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
if __name__ == "__main__":
|
|
27
|
+
main()
|