codefox 0.3.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.
Files changed (42) hide show
  1. codefox-0.3.0/.github/workflows/ci.yml +39 -0
  2. codefox-0.3.0/.gitignore +12 -0
  3. codefox-0.3.0/.python-version +1 -0
  4. codefox-0.3.0/LICENSE +21 -0
  5. codefox-0.3.0/PKG-INFO +229 -0
  6. codefox-0.3.0/README.md +203 -0
  7. codefox-0.3.0/WIKI.md +496 -0
  8. codefox-0.3.0/assets/logo.png +0 -0
  9. codefox-0.3.0/assets/work_review.gif +0 -0
  10. codefox-0.3.0/codefox/__init__.py +0 -0
  11. codefox-0.3.0/codefox/__main__.py +4 -0
  12. codefox-0.3.0/codefox/api/__init__.py +0 -0
  13. codefox-0.3.0/codefox/api/base_api.py +112 -0
  14. codefox-0.3.0/codefox/api/gemini.py +224 -0
  15. codefox-0.3.0/codefox/api/model_enum.py +31 -0
  16. codefox-0.3.0/codefox/api/ollama.py +138 -0
  17. codefox-0.3.0/codefox/api/openrouter.py +175 -0
  18. codefox-0.3.0/codefox/base_cli.py +7 -0
  19. codefox-0.3.0/codefox/cli_manager.py +59 -0
  20. codefox-0.3.0/codefox/init.py +191 -0
  21. codefox-0.3.0/codefox/list.py +35 -0
  22. codefox-0.3.0/codefox/main.py +36 -0
  23. codefox-0.3.0/codefox/prompts/__init__.py +0 -0
  24. codefox-0.3.0/codefox/prompts/audit_system.py +383 -0
  25. codefox-0.3.0/codefox/prompts/prompt_template.py +102 -0
  26. codefox-0.3.0/codefox/prompts/template.py +7 -0
  27. codefox-0.3.0/codefox/scan.py +68 -0
  28. codefox-0.3.0/codefox/utils/__init__.py +0 -0
  29. codefox-0.3.0/codefox/utils/helper.py +79 -0
  30. codefox-0.3.0/codefox/utils/local_rag.py +47 -0
  31. codefox-0.3.0/pyproject.toml +67 -0
  32. codefox-0.3.0/requirements-dev.txt +8 -0
  33. codefox-0.3.0/requirements.in +9 -0
  34. codefox-0.3.0/requirements.txt +9 -0
  35. codefox-0.3.0/setup.py +36 -0
  36. codefox-0.3.0/tests/conftest.py +41 -0
  37. codefox-0.3.0/tests/test_base_api_config.py +45 -0
  38. codefox-0.3.0/tests/test_cli_manager.py +39 -0
  39. codefox-0.3.0/tests/test_helper.py +90 -0
  40. codefox-0.3.0/tests/test_model_enum.py +40 -0
  41. codefox-0.3.0/tests/test_prompt_template.py +59 -0
  42. codefox-0.3.0/uv.lock +1348 -0
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main, dev]
8
+
9
+ jobs:
10
+ lint-and-test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+
29
+ - name: Ruff
30
+ run: ruff check codefox tests
31
+
32
+ - name: Ruff format check
33
+ run: ruff format --check codefox tests
34
+
35
+ - name: Mypy
36
+ run: mypy codefox --no-error-summary || true
37
+
38
+ - name: Pytest
39
+ run: pytest tests -v --tb=short
@@ -0,0 +1,12 @@
1
+ .vscode/
2
+ .idea/
3
+ .venv/
4
+ .*_cache/
5
+ .env
6
+ .codefoxenv
7
+ .codefoxignore
8
+ .codefox.yml
9
+
10
+ venv*/
11
+ __pycache__/
12
+ *.pyc
@@ -0,0 +1 @@
1
+ 3.14
codefox-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 CodeFox Inc.
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
13
+ all 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
21
+ THE SOFTWARE.
codefox-0.3.0/PKG-INFO ADDED
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: codefox
3
+ Version: 0.3.0
4
+ Summary: CodeFox CLI - code auditing and code review tool
5
+ License-File: LICENSE
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: faiss-cpu>=1.7.4
8
+ Requires-Dist: fastembed>=0.3.0
9
+ Requires-Dist: gitpython==3.1.46
10
+ Requires-Dist: google-genai==1.63.0
11
+ Requires-Dist: numpy>=1.24.0
12
+ Requires-Dist: ollama==0.6.1
13
+ Requires-Dist: openai==2.21.0
14
+ Requires-Dist: python-dotenv==1.2.1
15
+ Requires-Dist: pyyaml==6.0.3
16
+ Requires-Dist: rich==14.3.2
17
+ Requires-Dist: typer==0.23.1
18
+ Provides-Extra: dev
19
+ Requires-Dist: mypy>=1.0; extra == 'dev'
20
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
21
+ Requires-Dist: pytest>=8.0; extra == 'dev'
22
+ Requires-Dist: ruff>=0.8; extra == 'dev'
23
+ Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
24
+ Requires-Dist: types-requests>=2.31.0; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ <p align="center">
28
+ <img src="assets/logo.png" alt="CodeFox logo" width="120" />
29
+ </p>
30
+
31
+ <h1 align="center">CodeFox-CLI</h1>
32
+ <p align="center">
33
+ Intelligent automated code review system
34
+ </p>
35
+
36
+ <p align="center">
37
+ <a href="https://github.com/URLbug/CodeFox-CLI/actions"><img src="https://github.com/URLbug/CodeFox-CLI/workflows/CI/badge.svg" alt="CI" /></a>
38
+ <a href="https://github.com/URLbug/CodeFox-CLI/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" /></a>
39
+ <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.11+-green.svg" alt="Python 3.11+" /></a>
40
+ </p>
41
+
42
+ ---
43
+
44
+ ## ๐ŸฆŠ Overview
45
+
46
+ **CodeFox-CLI** is an intelligent automated code review system that takes over routine security and code quality checks, allowing senior developers to focus on architecture and complex tasks.
47
+
48
+ Unlike traditional linters, CodeFox understands the context of the entire project and its business logic, delivering not just review comments but **ready-to-apply fixes** (Auto-Fix). Works with **Gemini**, **Ollama**, and **OpenRouter** - use your preferred AI backend.
49
+
50
+ | vs Linters | vs AI code review (e.g. CodeRabbit) |
51
+ |------------|-------------------------------------|
52
+ | Understands full project context & business logic | Self-hosted / local (Ollama), no vendor lock-in |
53
+ | Suggests fixes, not only rules | Configurable models, security/performance/style rules |
54
+ | RAG over your codebase for relevant hints | CLI-first: `git diff` โ†’ review in seconds |
55
+
56
+ <p align="center">
57
+ <img src="assets/work_review.gif" alt="CodeFox scan demo" width="800" />
58
+ </p>
59
+
60
+ ---
61
+
62
+ ## ๐Ÿ“ฅ Installation
63
+
64
+ Choose the installation method that fits your workflow.
65
+
66
+ ### ๐Ÿ”น Install dependencies (local setup)
67
+
68
+ ```bash
69
+ pip install -r requirements.txt
70
+ ```
71
+ ### ๐Ÿ”น Development mode (editable install)
72
+
73
+ Provides the local codefox CLI command and enables live code changes.
74
+
75
+ ```bash
76
+ python3 -m pip install -e .
77
+ ```
78
+
79
+ ### ๐Ÿ”น Install from GitHub
80
+
81
+ ๐Ÿ Using pip
82
+
83
+ ```bash
84
+ python3 -m pip install git+https://github.com/URLbug/CodeFox-CLI.git@main
85
+ ```
86
+
87
+ โšก Using uv (recommended for CLI usage)
88
+ ```bash
89
+ uv tool install git+https://github.com/URLbug/CodeFox-CLI.git@main
90
+ ```
91
+
92
+ ---
93
+
94
+ โœ… Verify installation
95
+ ```bash
96
+ codefox --command version
97
+ ```
98
+ Or
99
+ ```bash
100
+ python3 -m codefox --command version
101
+ ```
102
+
103
+ ## ๐Ÿš€ Quick Start
104
+
105
+ ### Initialize (stores your API key)
106
+
107
+ ```bash
108
+ codefox --command init
109
+ ```
110
+
111
+ ### Run a scan (uses the current git diff)
112
+
113
+ ```bash
114
+ codefox --command scan
115
+ ```
116
+
117
+ ### Show version
118
+
119
+ ```bash
120
+ codefox --command version
121
+ ```
122
+
123
+ ---
124
+
125
+ ## โš™๏ธ Configuration
126
+
127
+ **Ignore file:** `./.codefoxignore`
128
+ Specifies paths that should not be uploaded to the File Store.
129
+
130
+ **Model settings:** `./.codefox.yml`
131
+ Used for fine-grained configuration of the analysis behavior and model parameters (such as model selection, temperature, review rules, baseline, and prompts).
132
+ For detailed configuration options and examples, see [wiki](WIKI.md).
133
+
134
+ Example config used in the demo above (Ollama + qwen3-coder):
135
+
136
+ ```yaml
137
+ provider: ollama
138
+ model:
139
+ name: qwen3-coder:480b
140
+ temperature: 0.5
141
+ max_tokens: 4000
142
+ review:
143
+ severity: high
144
+ max_issues: null
145
+ suggest_fixes: true
146
+ diff_only: false
147
+ baseline:
148
+ enable: true
149
+ ruler:
150
+ security: true
151
+ performance: true
152
+ style: true
153
+ prompt:
154
+ system: null
155
+ extra: null
156
+ ```
157
+
158
+ **Token configuration:** `./codefoxenv`
159
+ Stores the API token for the model. This file is used by the CLI for authentication and should not be committed to version control.
160
+
161
+ ---
162
+
163
+ ## ๐Ÿงฉ Commands
164
+
165
+ | Command | Description |
166
+ | --------- | ---------------------------------------------------------------------------------------------------- |
167
+ | `init` | Saves the API key locally and creates a `.codefoxignore` and `.codefox.yml` file in the current directory. |
168
+ | `list` | Shows the full list of models available for the current provider (Gemini, Ollama, or OpenRouter) from `.codefox.yml`. |
169
+ | `scan` | Collects changes from the `git diff`, uploads files to the File Store, and sends requests to the configured model. |
170
+ | `version` | Displays the current CodeFox CLI version. |
171
+ | `--help` | Shows available flags and usage information. |
172
+
173
+ ---
174
+
175
+ ## ๐Ÿงช Examples
176
+
177
+ ### List available models (for the provider in `.codefox.yml`)
178
+
179
+ ```bash
180
+ codefox --command list
181
+ ```
182
+
183
+ ### Run a scan in a project
184
+
185
+ ```bash
186
+ codefox --command scan
187
+ ```
188
+
189
+ ---
190
+
191
+ ## ๐Ÿ›  Development
192
+
193
+ Install with dev dependencies (includes pytest, mypy, ruff, types-PyYAML):
194
+
195
+ **pip:**
196
+ ```bash
197
+ pip install -e ".[dev]"
198
+ # or: pip install -r requirements.txt -r requirements-dev.txt
199
+ ```
200
+
201
+ **uv:**
202
+ ```bash
203
+ uv pip install -e ".[dev]"
204
+ ```
205
+
206
+ Run tests:
207
+
208
+ ```bash
209
+ pytest tests -v
210
+ ```
211
+
212
+ Lint and format:
213
+
214
+ ```bash
215
+ ruff check codefox tests
216
+ ruff format codefox tests
217
+ ```
218
+
219
+ Static type check:
220
+
221
+ ```bash
222
+ mypy codefox
223
+ ```
224
+
225
+ ---
226
+
227
+ ## ๐Ÿค Contributing
228
+
229
+ Bug reports, pull requests, and documentation improvements are welcome.
@@ -0,0 +1,203 @@
1
+ <p align="center">
2
+ <img src="assets/logo.png" alt="CodeFox logo" width="120" />
3
+ </p>
4
+
5
+ <h1 align="center">CodeFox-CLI</h1>
6
+ <p align="center">
7
+ Intelligent automated code review system
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/URLbug/CodeFox-CLI/actions"><img src="https://github.com/URLbug/CodeFox-CLI/workflows/CI/badge.svg" alt="CI" /></a>
12
+ <a href="https://github.com/URLbug/CodeFox-CLI/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" /></a>
13
+ <a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.11+-green.svg" alt="Python 3.11+" /></a>
14
+ </p>
15
+
16
+ ---
17
+
18
+ ## ๐ŸฆŠ Overview
19
+
20
+ **CodeFox-CLI** is an intelligent automated code review system that takes over routine security and code quality checks, allowing senior developers to focus on architecture and complex tasks.
21
+
22
+ Unlike traditional linters, CodeFox understands the context of the entire project and its business logic, delivering not just review comments but **ready-to-apply fixes** (Auto-Fix). Works with **Gemini**, **Ollama**, and **OpenRouter** - use your preferred AI backend.
23
+
24
+ | vs Linters | vs AI code review (e.g. CodeRabbit) |
25
+ |------------|-------------------------------------|
26
+ | Understands full project context & business logic | Self-hosted / local (Ollama), no vendor lock-in |
27
+ | Suggests fixes, not only rules | Configurable models, security/performance/style rules |
28
+ | RAG over your codebase for relevant hints | CLI-first: `git diff` โ†’ review in seconds |
29
+
30
+ <p align="center">
31
+ <img src="assets/work_review.gif" alt="CodeFox scan demo" width="800" />
32
+ </p>
33
+
34
+ ---
35
+
36
+ ## ๐Ÿ“ฅ Installation
37
+
38
+ Choose the installation method that fits your workflow.
39
+
40
+ ### ๐Ÿ”น Install dependencies (local setup)
41
+
42
+ ```bash
43
+ pip install -r requirements.txt
44
+ ```
45
+ ### ๐Ÿ”น Development mode (editable install)
46
+
47
+ Provides the local codefox CLI command and enables live code changes.
48
+
49
+ ```bash
50
+ python3 -m pip install -e .
51
+ ```
52
+
53
+ ### ๐Ÿ”น Install from GitHub
54
+
55
+ ๐Ÿ Using pip
56
+
57
+ ```bash
58
+ python3 -m pip install git+https://github.com/URLbug/CodeFox-CLI.git@main
59
+ ```
60
+
61
+ โšก Using uv (recommended for CLI usage)
62
+ ```bash
63
+ uv tool install git+https://github.com/URLbug/CodeFox-CLI.git@main
64
+ ```
65
+
66
+ ---
67
+
68
+ โœ… Verify installation
69
+ ```bash
70
+ codefox --command version
71
+ ```
72
+ Or
73
+ ```bash
74
+ python3 -m codefox --command version
75
+ ```
76
+
77
+ ## ๐Ÿš€ Quick Start
78
+
79
+ ### Initialize (stores your API key)
80
+
81
+ ```bash
82
+ codefox --command init
83
+ ```
84
+
85
+ ### Run a scan (uses the current git diff)
86
+
87
+ ```bash
88
+ codefox --command scan
89
+ ```
90
+
91
+ ### Show version
92
+
93
+ ```bash
94
+ codefox --command version
95
+ ```
96
+
97
+ ---
98
+
99
+ ## โš™๏ธ Configuration
100
+
101
+ **Ignore file:** `./.codefoxignore`
102
+ Specifies paths that should not be uploaded to the File Store.
103
+
104
+ **Model settings:** `./.codefox.yml`
105
+ Used for fine-grained configuration of the analysis behavior and model parameters (such as model selection, temperature, review rules, baseline, and prompts).
106
+ For detailed configuration options and examples, see [wiki](WIKI.md).
107
+
108
+ Example config used in the demo above (Ollama + qwen3-coder):
109
+
110
+ ```yaml
111
+ provider: ollama
112
+ model:
113
+ name: qwen3-coder:480b
114
+ temperature: 0.5
115
+ max_tokens: 4000
116
+ review:
117
+ severity: high
118
+ max_issues: null
119
+ suggest_fixes: true
120
+ diff_only: false
121
+ baseline:
122
+ enable: true
123
+ ruler:
124
+ security: true
125
+ performance: true
126
+ style: true
127
+ prompt:
128
+ system: null
129
+ extra: null
130
+ ```
131
+
132
+ **Token configuration:** `./codefoxenv`
133
+ Stores the API token for the model. This file is used by the CLI for authentication and should not be committed to version control.
134
+
135
+ ---
136
+
137
+ ## ๐Ÿงฉ Commands
138
+
139
+ | Command | Description |
140
+ | --------- | ---------------------------------------------------------------------------------------------------- |
141
+ | `init` | Saves the API key locally and creates a `.codefoxignore` and `.codefox.yml` file in the current directory. |
142
+ | `list` | Shows the full list of models available for the current provider (Gemini, Ollama, or OpenRouter) from `.codefox.yml`. |
143
+ | `scan` | Collects changes from the `git diff`, uploads files to the File Store, and sends requests to the configured model. |
144
+ | `version` | Displays the current CodeFox CLI version. |
145
+ | `--help` | Shows available flags and usage information. |
146
+
147
+ ---
148
+
149
+ ## ๐Ÿงช Examples
150
+
151
+ ### List available models (for the provider in `.codefox.yml`)
152
+
153
+ ```bash
154
+ codefox --command list
155
+ ```
156
+
157
+ ### Run a scan in a project
158
+
159
+ ```bash
160
+ codefox --command scan
161
+ ```
162
+
163
+ ---
164
+
165
+ ## ๐Ÿ›  Development
166
+
167
+ Install with dev dependencies (includes pytest, mypy, ruff, types-PyYAML):
168
+
169
+ **pip:**
170
+ ```bash
171
+ pip install -e ".[dev]"
172
+ # or: pip install -r requirements.txt -r requirements-dev.txt
173
+ ```
174
+
175
+ **uv:**
176
+ ```bash
177
+ uv pip install -e ".[dev]"
178
+ ```
179
+
180
+ Run tests:
181
+
182
+ ```bash
183
+ pytest tests -v
184
+ ```
185
+
186
+ Lint and format:
187
+
188
+ ```bash
189
+ ruff check codefox tests
190
+ ruff format codefox tests
191
+ ```
192
+
193
+ Static type check:
194
+
195
+ ```bash
196
+ mypy codefox
197
+ ```
198
+
199
+ ---
200
+
201
+ ## ๐Ÿค Contributing
202
+
203
+ Bug reports, pull requests, and documentation improvements are welcome.