errorlens 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.
Potentially problematic release.
This version of errorlens might be problematic. Click here for more details.
- errorlens-0.1.0/PKG-INFO +256 -0
- errorlens-0.1.0/README.md +228 -0
- errorlens-0.1.0/errorlens/__init__.py +1 -0
- errorlens-0.1.0/errorlens/cli.py +147 -0
- errorlens-0.1.0/errorlens/core/__init__.py +0 -0
- errorlens-0.1.0/errorlens/core/analyzer.py +123 -0
- errorlens-0.1.0/errorlens/core/config.py +88 -0
- errorlens-0.1.0/errorlens/providers/__init__.py +0 -0
- errorlens-0.1.0/errorlens/providers/anthropic_provider.py +103 -0
- errorlens-0.1.0/errorlens/providers/groq_provider.py +109 -0
- errorlens-0.1.0/errorlens/providers/mistral_provider.py +134 -0
- errorlens-0.1.0/errorlens/providers/mock_provider.py +120 -0
- errorlens-0.1.0/errorlens/tui.py +230 -0
- errorlens-0.1.0/errorlens.egg-info/PKG-INFO +256 -0
- errorlens-0.1.0/errorlens.egg-info/SOURCES.txt +20 -0
- errorlens-0.1.0/errorlens.egg-info/dependency_links.txt +1 -0
- errorlens-0.1.0/errorlens.egg-info/entry_points.txt +3 -0
- errorlens-0.1.0/errorlens.egg-info/requires.txt +7 -0
- errorlens-0.1.0/errorlens.egg-info/top_level.txt +1 -0
- errorlens-0.1.0/pyproject.toml +45 -0
- errorlens-0.1.0/setup.cfg +4 -0
- errorlens-0.1.0/setup.py +4 -0
errorlens-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: errorlens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered CLI tool for finding bugs and security issues in codebases
|
|
5
|
+
Author-email: ErrorLens <info@errorlens.io>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: security,static-analysis,ai,bugs,code-review
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Topic :: Security
|
|
11
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: textual>=0.50.0
|
|
22
|
+
Requires-Dist: click>=8.0.0
|
|
23
|
+
Requires-Dist: requests>=2.25.0
|
|
24
|
+
Requires-Dist: python-dotenv>=0.19.0
|
|
25
|
+
Requires-Dist: anthropic>=0.20.0
|
|
26
|
+
Requires-Dist: mistralai>=0.1.0
|
|
27
|
+
Requires-Dist: groq>=0.4.0
|
|
28
|
+
|
|
29
|
+
# ErrorLens
|
|
30
|
+
|
|
31
|
+
A CLI and TUI tool that analyzes codebases for bugs and security issues using multiple AI providers.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- **Multi-provider analysis** — Anthropic (Claude), Groq (Llama 3), and Mistral
|
|
38
|
+
- **Two interfaces** — a classic CLI for scripting and a rich Terminal UI (TUI) for interactive use
|
|
39
|
+
- **Parallel file processing** — analyzes directories concurrently
|
|
40
|
+
- **Multiple output formats** — console, JSON, and Markdown
|
|
41
|
+
- **12+ languages supported** — Python, JavaScript, TypeScript, Go, Rust, Java, and more
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
**Requirements:** Python 3.8+
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Clone the repo
|
|
51
|
+
git clone https://github.com/your-repo/errorlens.git
|
|
52
|
+
cd errorlens
|
|
53
|
+
|
|
54
|
+
# Create and activate a virtual environment
|
|
55
|
+
python -m venv venv
|
|
56
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
57
|
+
|
|
58
|
+
# Install dependencies
|
|
59
|
+
pip install -r requirements.txt
|
|
60
|
+
|
|
61
|
+
# Install the package (gives you the `errorlens` command)
|
|
62
|
+
pip install -e .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
Create a `.env` file in the project root:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cat > .env << 'EOF'
|
|
73
|
+
ANTHROPIC_API_KEY="your-anthropic-api-key"
|
|
74
|
+
MISTRAL_API_KEY="your-mistral-api-key"
|
|
75
|
+
GROQ_API_KEY="your-groq-api-key"
|
|
76
|
+
EOF
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You only need keys for the providers you plan to use.
|
|
80
|
+
|
|
81
|
+
| Provider | Model | Notes |
|
|
82
|
+
|-----------|------------------------|------------------------|
|
|
83
|
+
| Anthropic | claude-3-opus-20240229 | Real API call |
|
|
84
|
+
| Groq | llama3-70b-8192 | Real API call |
|
|
85
|
+
| Mistral | mistral-large-latest | Pattern-based (mock) |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## CLI Usage
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# Analyze a single file (all providers)
|
|
93
|
+
python main.py path/to/file.py
|
|
94
|
+
|
|
95
|
+
# Analyze a directory
|
|
96
|
+
python main.py path/to/project/
|
|
97
|
+
|
|
98
|
+
# Choose a specific provider
|
|
99
|
+
python main.py file.py --provider anthropic
|
|
100
|
+
python main.py file.py --provider groq
|
|
101
|
+
python main.py file.py --provider mistral
|
|
102
|
+
|
|
103
|
+
# Change output format
|
|
104
|
+
python main.py file.py --output json
|
|
105
|
+
python main.py file.py --output markdown
|
|
106
|
+
|
|
107
|
+
# Verbose logging
|
|
108
|
+
python main.py file.py --verbose
|
|
109
|
+
|
|
110
|
+
# If installed via pip install -e .
|
|
111
|
+
errorlens file.py --provider anthropic
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### CLI Options
|
|
115
|
+
|
|
116
|
+
| Flag | Values | Default |
|
|
117
|
+
|--------------|-------------------------------------|----------|
|
|
118
|
+
| `--provider` | `anthropic`, `mistral`, `groq`, `all` | `all` |
|
|
119
|
+
| `--output` | `console`, `json`, `markdown` | `console`|
|
|
120
|
+
| `--verbose` | — | off |
|
|
121
|
+
| `--config` | path to JSON config file | — |
|
|
122
|
+
|
|
123
|
+
### Example console output
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
ErrorLens
|
|
127
|
+
Analyzing: example_test.py
|
|
128
|
+
Provider: groq
|
|
129
|
+
|
|
130
|
+
==================================================
|
|
131
|
+
ERRORLENS ANALYSIS RESULTS
|
|
132
|
+
==================================================
|
|
133
|
+
|
|
134
|
+
File: example_test.py
|
|
135
|
+
Language: python
|
|
136
|
+
Status: SUCCESS
|
|
137
|
+
|
|
138
|
+
--- GROQ ANALYSIS ---
|
|
139
|
+
Security Issues:
|
|
140
|
+
- Hardcoded credentials found in DB_PASSWORD and API_KEY variables
|
|
141
|
+
- SQL injection vulnerability in login() function
|
|
142
|
+
- Insecure deserialization using pickle.loads()
|
|
143
|
+
Potential Bugs:
|
|
144
|
+
- Division by zero possible in complex_calculation()
|
|
145
|
+
Code Quality Issues:
|
|
146
|
+
- Unused function detected
|
|
147
|
+
Suggestions:
|
|
148
|
+
- Use environment variables for credentials
|
|
149
|
+
- Use parameterized queries
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## TUI Usage
|
|
155
|
+
|
|
156
|
+
Launch the interactive terminal interface:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
python tui.py
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Layout
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
┌─────────────────────────────────────────────────────────┐
|
|
166
|
+
│ ErrorLens 12:00:00 │
|
|
167
|
+
├────────────────┬────────────────────────────────────────┤
|
|
168
|
+
│ │ │
|
|
169
|
+
│ Path │ Analyzing: example_test.py │
|
|
170
|
+
│ [___________] │ Provider: mistral │
|
|
171
|
+
│ │ ════════════════════════════════════ │
|
|
172
|
+
│ Provider │ │
|
|
173
|
+
│ ○ anthropic │ ✔ example_test.py [python] │
|
|
174
|
+
│ ○ mistral │ │
|
|
175
|
+
│ ○ groq │ ── MISTRAL ── │
|
|
176
|
+
│ ● all │ Security Issues: │
|
|
177
|
+
│ │ • Hardcoded credentials detected │
|
|
178
|
+
│ [Run Analysis]│ • Insecure pickle deserialization │
|
|
179
|
+
│ │ Potential Bugs: │
|
|
180
|
+
│ Analyzing... │ • Division by zero │
|
|
181
|
+
│ │ │
|
|
182
|
+
├────────────────┴────────────────────────────────────────┤
|
|
183
|
+
│ R Run C Clear Q Quit │
|
|
184
|
+
└─────────────────────────────────────────────────────────┘
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Keybindings
|
|
188
|
+
|
|
189
|
+
| Key | Action |
|
|
190
|
+
|-----|---------------|
|
|
191
|
+
| `R` | Run analysis |
|
|
192
|
+
| `C` | Clear results |
|
|
193
|
+
| `Q` | Quit |
|
|
194
|
+
|
|
195
|
+
Results are color-coded:
|
|
196
|
+
- **Red** — Security issues
|
|
197
|
+
- **Yellow** — Potential bugs
|
|
198
|
+
- **Cyan** — Code quality issues
|
|
199
|
+
- **Green** — Suggestions
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Supported Languages
|
|
204
|
+
|
|
205
|
+
| Language | Extension(s) |
|
|
206
|
+
|------------|----------------|
|
|
207
|
+
| Python | `.py` |
|
|
208
|
+
| JavaScript | `.js` |
|
|
209
|
+
| TypeScript | `.ts` |
|
|
210
|
+
| Java | `.java` |
|
|
211
|
+
| C / C++ | `.c`, `.cpp` |
|
|
212
|
+
| Go | `.go` |
|
|
213
|
+
| Rust | `.rs` |
|
|
214
|
+
| Ruby | `.rb` |
|
|
215
|
+
| PHP | `.php` |
|
|
216
|
+
| Swift | `.swift` |
|
|
217
|
+
| Kotlin | `.kt` |
|
|
218
|
+
| C# | `.cs` |
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Project Structure
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
errorlens/
|
|
226
|
+
├── main.py # CLI entry point
|
|
227
|
+
├── tui.py # TUI entry point
|
|
228
|
+
├── requirements.txt
|
|
229
|
+
├── setup.py
|
|
230
|
+
├── .env # API keys (not committed)
|
|
231
|
+
├── example_test.py # Sample file with intentional issues
|
|
232
|
+
├── core/
|
|
233
|
+
│ ├── analyzer.py # File discovery and analysis orchestration
|
|
234
|
+
│ └── config.py # Configuration and env loading
|
|
235
|
+
└── providers/
|
|
236
|
+
├── anthropic_provider.py # Anthropic Claude integration
|
|
237
|
+
├── groq_provider.py # Groq Llama 3 integration
|
|
238
|
+
├── mistral_provider.py # Mistral integration
|
|
239
|
+
└── mock_provider.py # Offline mock for testing
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Testing with the Example File
|
|
245
|
+
|
|
246
|
+
`example_test.py` is bundled with intentional security flaws and bugs — use it to verify your setup:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
python main.py example_test.py --provider groq
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT License — see LICENSE for details.
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# ErrorLens
|
|
2
|
+
|
|
3
|
+
A CLI and TUI tool that analyzes codebases for bugs and security issues using multiple AI providers.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Multi-provider analysis** — Anthropic (Claude), Groq (Llama 3), and Mistral
|
|
10
|
+
- **Two interfaces** — a classic CLI for scripting and a rich Terminal UI (TUI) for interactive use
|
|
11
|
+
- **Parallel file processing** — analyzes directories concurrently
|
|
12
|
+
- **Multiple output formats** — console, JSON, and Markdown
|
|
13
|
+
- **12+ languages supported** — Python, JavaScript, TypeScript, Go, Rust, Java, and more
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
**Requirements:** Python 3.8+
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Clone the repo
|
|
23
|
+
git clone https://github.com/your-repo/errorlens.git
|
|
24
|
+
cd errorlens
|
|
25
|
+
|
|
26
|
+
# Create and activate a virtual environment
|
|
27
|
+
python -m venv venv
|
|
28
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
29
|
+
|
|
30
|
+
# Install dependencies
|
|
31
|
+
pip install -r requirements.txt
|
|
32
|
+
|
|
33
|
+
# Install the package (gives you the `errorlens` command)
|
|
34
|
+
pip install -e .
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Create a `.env` file in the project root:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cat > .env << 'EOF'
|
|
45
|
+
ANTHROPIC_API_KEY="your-anthropic-api-key"
|
|
46
|
+
MISTRAL_API_KEY="your-mistral-api-key"
|
|
47
|
+
GROQ_API_KEY="your-groq-api-key"
|
|
48
|
+
EOF
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
You only need keys for the providers you plan to use.
|
|
52
|
+
|
|
53
|
+
| Provider | Model | Notes |
|
|
54
|
+
|-----------|------------------------|------------------------|
|
|
55
|
+
| Anthropic | claude-3-opus-20240229 | Real API call |
|
|
56
|
+
| Groq | llama3-70b-8192 | Real API call |
|
|
57
|
+
| Mistral | mistral-large-latest | Pattern-based (mock) |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## CLI Usage
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Analyze a single file (all providers)
|
|
65
|
+
python main.py path/to/file.py
|
|
66
|
+
|
|
67
|
+
# Analyze a directory
|
|
68
|
+
python main.py path/to/project/
|
|
69
|
+
|
|
70
|
+
# Choose a specific provider
|
|
71
|
+
python main.py file.py --provider anthropic
|
|
72
|
+
python main.py file.py --provider groq
|
|
73
|
+
python main.py file.py --provider mistral
|
|
74
|
+
|
|
75
|
+
# Change output format
|
|
76
|
+
python main.py file.py --output json
|
|
77
|
+
python main.py file.py --output markdown
|
|
78
|
+
|
|
79
|
+
# Verbose logging
|
|
80
|
+
python main.py file.py --verbose
|
|
81
|
+
|
|
82
|
+
# If installed via pip install -e .
|
|
83
|
+
errorlens file.py --provider anthropic
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### CLI Options
|
|
87
|
+
|
|
88
|
+
| Flag | Values | Default |
|
|
89
|
+
|--------------|-------------------------------------|----------|
|
|
90
|
+
| `--provider` | `anthropic`, `mistral`, `groq`, `all` | `all` |
|
|
91
|
+
| `--output` | `console`, `json`, `markdown` | `console`|
|
|
92
|
+
| `--verbose` | — | off |
|
|
93
|
+
| `--config` | path to JSON config file | — |
|
|
94
|
+
|
|
95
|
+
### Example console output
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
ErrorLens
|
|
99
|
+
Analyzing: example_test.py
|
|
100
|
+
Provider: groq
|
|
101
|
+
|
|
102
|
+
==================================================
|
|
103
|
+
ERRORLENS ANALYSIS RESULTS
|
|
104
|
+
==================================================
|
|
105
|
+
|
|
106
|
+
File: example_test.py
|
|
107
|
+
Language: python
|
|
108
|
+
Status: SUCCESS
|
|
109
|
+
|
|
110
|
+
--- GROQ ANALYSIS ---
|
|
111
|
+
Security Issues:
|
|
112
|
+
- Hardcoded credentials found in DB_PASSWORD and API_KEY variables
|
|
113
|
+
- SQL injection vulnerability in login() function
|
|
114
|
+
- Insecure deserialization using pickle.loads()
|
|
115
|
+
Potential Bugs:
|
|
116
|
+
- Division by zero possible in complex_calculation()
|
|
117
|
+
Code Quality Issues:
|
|
118
|
+
- Unused function detected
|
|
119
|
+
Suggestions:
|
|
120
|
+
- Use environment variables for credentials
|
|
121
|
+
- Use parameterized queries
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## TUI Usage
|
|
127
|
+
|
|
128
|
+
Launch the interactive terminal interface:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
python tui.py
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Layout
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
┌─────────────────────────────────────────────────────────┐
|
|
138
|
+
│ ErrorLens 12:00:00 │
|
|
139
|
+
├────────────────┬────────────────────────────────────────┤
|
|
140
|
+
│ │ │
|
|
141
|
+
│ Path │ Analyzing: example_test.py │
|
|
142
|
+
│ [___________] │ Provider: mistral │
|
|
143
|
+
│ │ ════════════════════════════════════ │
|
|
144
|
+
│ Provider │ │
|
|
145
|
+
│ ○ anthropic │ ✔ example_test.py [python] │
|
|
146
|
+
│ ○ mistral │ │
|
|
147
|
+
│ ○ groq │ ── MISTRAL ── │
|
|
148
|
+
│ ● all │ Security Issues: │
|
|
149
|
+
│ │ • Hardcoded credentials detected │
|
|
150
|
+
│ [Run Analysis]│ • Insecure pickle deserialization │
|
|
151
|
+
│ │ Potential Bugs: │
|
|
152
|
+
│ Analyzing... │ • Division by zero │
|
|
153
|
+
│ │ │
|
|
154
|
+
├────────────────┴────────────────────────────────────────┤
|
|
155
|
+
│ R Run C Clear Q Quit │
|
|
156
|
+
└─────────────────────────────────────────────────────────┘
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Keybindings
|
|
160
|
+
|
|
161
|
+
| Key | Action |
|
|
162
|
+
|-----|---------------|
|
|
163
|
+
| `R` | Run analysis |
|
|
164
|
+
| `C` | Clear results |
|
|
165
|
+
| `Q` | Quit |
|
|
166
|
+
|
|
167
|
+
Results are color-coded:
|
|
168
|
+
- **Red** — Security issues
|
|
169
|
+
- **Yellow** — Potential bugs
|
|
170
|
+
- **Cyan** — Code quality issues
|
|
171
|
+
- **Green** — Suggestions
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Supported Languages
|
|
176
|
+
|
|
177
|
+
| Language | Extension(s) |
|
|
178
|
+
|------------|----------------|
|
|
179
|
+
| Python | `.py` |
|
|
180
|
+
| JavaScript | `.js` |
|
|
181
|
+
| TypeScript | `.ts` |
|
|
182
|
+
| Java | `.java` |
|
|
183
|
+
| C / C++ | `.c`, `.cpp` |
|
|
184
|
+
| Go | `.go` |
|
|
185
|
+
| Rust | `.rs` |
|
|
186
|
+
| Ruby | `.rb` |
|
|
187
|
+
| PHP | `.php` |
|
|
188
|
+
| Swift | `.swift` |
|
|
189
|
+
| Kotlin | `.kt` |
|
|
190
|
+
| C# | `.cs` |
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Project Structure
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
errorlens/
|
|
198
|
+
├── main.py # CLI entry point
|
|
199
|
+
├── tui.py # TUI entry point
|
|
200
|
+
├── requirements.txt
|
|
201
|
+
├── setup.py
|
|
202
|
+
├── .env # API keys (not committed)
|
|
203
|
+
├── example_test.py # Sample file with intentional issues
|
|
204
|
+
├── core/
|
|
205
|
+
│ ├── analyzer.py # File discovery and analysis orchestration
|
|
206
|
+
│ └── config.py # Configuration and env loading
|
|
207
|
+
└── providers/
|
|
208
|
+
├── anthropic_provider.py # Anthropic Claude integration
|
|
209
|
+
├── groq_provider.py # Groq Llama 3 integration
|
|
210
|
+
├── mistral_provider.py # Mistral integration
|
|
211
|
+
└── mock_provider.py # Offline mock for testing
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Testing with the Example File
|
|
217
|
+
|
|
218
|
+
`example_test.py` is bundled with intentional security flaws and bugs — use it to verify your setup:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python main.py example_test.py --provider groq
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT License — see LICENSE for details.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
ErrorLens CLI — non-interactive analysis mode
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import json
|
|
8
|
+
import logging
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from errorlens.core.analyzer import CodeAnalyzer
|
|
13
|
+
from errorlens.core.config import Config
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
parser = argparse.ArgumentParser(
|
|
18
|
+
description="ErrorLens - Find bugs and security issues in your codebase"
|
|
19
|
+
)
|
|
20
|
+
parser.add_argument(
|
|
21
|
+
"path", nargs="?", default=".",
|
|
22
|
+
help="Path to file or directory to analyze (default: current directory)"
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--provider", choices=["anthropic", "mistral", "groq", "mock", "all"],
|
|
26
|
+
default="all", help="AI provider to use (default: all)"
|
|
27
|
+
)
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"--output", choices=["console", "json", "markdown"],
|
|
30
|
+
default="console", help="Output format (default: console)"
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument("--verbose", action="store_true", help="Enable verbose output")
|
|
33
|
+
parser.add_argument("--config", help="Path to configuration file")
|
|
34
|
+
|
|
35
|
+
args = parser.parse_args()
|
|
36
|
+
config = Config(args.config)
|
|
37
|
+
|
|
38
|
+
logging.basicConfig(
|
|
39
|
+
level=logging.INFO if args.verbose or config.get("output.verbose") else logging.WARNING,
|
|
40
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
target_path = Path(args.path)
|
|
44
|
+
if not target_path.exists():
|
|
45
|
+
print(f"Error: Path '{args.path}' does not exist")
|
|
46
|
+
sys.exit(1)
|
|
47
|
+
|
|
48
|
+
provider_list = ["anthropic", "mistral", "groq"] if args.provider == "all" else [args.provider]
|
|
49
|
+
|
|
50
|
+
analyzer = CodeAnalyzer()
|
|
51
|
+
analyzer.initialize_providers(provider_list)
|
|
52
|
+
|
|
53
|
+
print(f"ErrorLens — analyzing: {args.path} provider: {args.provider}")
|
|
54
|
+
results = analyzer.analyze_path(target_path, provider_list)
|
|
55
|
+
_output_results(results, args.output)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _output_results(results: dict, output_format: str):
|
|
59
|
+
if output_format == "json":
|
|
60
|
+
print(json.dumps(results, indent=2))
|
|
61
|
+
elif output_format == "markdown":
|
|
62
|
+
_output_markdown(results)
|
|
63
|
+
else:
|
|
64
|
+
_output_console(results)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _output_console(results: dict):
|
|
68
|
+
print("\n" + "=" * 50)
|
|
69
|
+
print("ERRORLENS ANALYSIS RESULTS")
|
|
70
|
+
print("=" * 50)
|
|
71
|
+
if "directory" in results:
|
|
72
|
+
print(f"Directory: {results['directory']}")
|
|
73
|
+
print(f"Files analyzed: {len(results['files'])}")
|
|
74
|
+
print(f"Successful: {results['summary']['successful_analyses']}")
|
|
75
|
+
print(f"Failed: {results['summary']['failed_analyses']}")
|
|
76
|
+
for file_result in results['files']:
|
|
77
|
+
_print_file_result(file_result)
|
|
78
|
+
else:
|
|
79
|
+
_print_file_result(results)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _print_file_result(file_result: dict):
|
|
83
|
+
print(f"\nFile: {file_result['file']}")
|
|
84
|
+
print(f"Language: {file_result.get('language', 'unknown')}")
|
|
85
|
+
if not file_result.get('success'):
|
|
86
|
+
print(f"Error: {file_result.get('error', 'Unknown error')}")
|
|
87
|
+
return
|
|
88
|
+
for provider_name, provider_result in file_result['providers'].items():
|
|
89
|
+
print(f"\n--- {provider_name.upper()} ---")
|
|
90
|
+
if provider_result.get('success'):
|
|
91
|
+
analysis = provider_result.get('analysis', {})
|
|
92
|
+
for label, key in [
|
|
93
|
+
("Security Issues", "security_issues"),
|
|
94
|
+
("Potential Bugs", "bugs"),
|
|
95
|
+
("Code Quality", "code_quality"),
|
|
96
|
+
("Suggestions", "suggestions"),
|
|
97
|
+
]:
|
|
98
|
+
items = analysis.get(key, [])
|
|
99
|
+
if items:
|
|
100
|
+
print(f"{label}:")
|
|
101
|
+
for item in items:
|
|
102
|
+
print(f" - {item}")
|
|
103
|
+
else:
|
|
104
|
+
print(f"Error: {provider_result.get('error', 'Unknown error')}")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _output_markdown(results: dict):
|
|
108
|
+
print("# ErrorLens Analysis Results\n")
|
|
109
|
+
if "directory" in results:
|
|
110
|
+
print(f"## Directory: {results['directory']}")
|
|
111
|
+
print(f"- Files: {len(results['files'])}")
|
|
112
|
+
print(f"- OK: {results['summary']['successful_analyses']}")
|
|
113
|
+
print(f"- Failed: {results['summary']['failed_analyses']}\n")
|
|
114
|
+
for file_result in results['files']:
|
|
115
|
+
_print_file_markdown(file_result)
|
|
116
|
+
else:
|
|
117
|
+
_print_file_markdown(results)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _print_file_markdown(file_result: dict):
|
|
121
|
+
status = "✅" if file_result.get('success') else "❌"
|
|
122
|
+
print(f"## {status} {file_result['file']}")
|
|
123
|
+
if not file_result.get('success'):
|
|
124
|
+
print(f"**Error:** {file_result.get('error', 'Unknown error')}\n")
|
|
125
|
+
return
|
|
126
|
+
for provider_name, provider_result in file_result['providers'].items():
|
|
127
|
+
print(f"### {provider_name.upper()}")
|
|
128
|
+
if provider_result.get('success'):
|
|
129
|
+
analysis = provider_result.get('analysis', {})
|
|
130
|
+
for label, key in [
|
|
131
|
+
("Security Issues", "security_issues"),
|
|
132
|
+
("Potential Bugs", "bugs"),
|
|
133
|
+
("Code Quality Issues", "code_quality"),
|
|
134
|
+
("Suggestions", "suggestions"),
|
|
135
|
+
]:
|
|
136
|
+
items = analysis.get(key, [])
|
|
137
|
+
if items:
|
|
138
|
+
print(f"**{label}:**")
|
|
139
|
+
for item in items:
|
|
140
|
+
print(f"- {item}")
|
|
141
|
+
else:
|
|
142
|
+
print(f"**Error:** {provider_result.get('error', 'Unknown error')}")
|
|
143
|
+
print()
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
if __name__ == "__main__":
|
|
147
|
+
main()
|
|
File without changes
|