cascade-review 0.2.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 (47) hide show
  1. cascade_review-0.2.0/LICENSE +21 -0
  2. cascade_review-0.2.0/PKG-INFO +467 -0
  3. cascade_review-0.2.0/README.md +436 -0
  4. cascade_review-0.2.0/cascade/__init__.py +1 -0
  5. cascade_review-0.2.0/cascade/analyzers/__init__.py +0 -0
  6. cascade_review-0.2.0/cascade/analyzers/llm/__init__.py +0 -0
  7. cascade_review-0.2.0/cascade/analyzers/llm/bug_detector.py +47 -0
  8. cascade_review-0.2.0/cascade/analyzers/llm/change_summary.py +46 -0
  9. cascade_review-0.2.0/cascade/analyzers/llm/fix_suggester.py +54 -0
  10. cascade_review-0.2.0/cascade/analyzers/llm/llm_detector.py +47 -0
  11. cascade_review-0.2.0/cascade/analyzers/static/__init__.py +0 -0
  12. cascade_review-0.2.0/cascade/analyzers/static/arch_check.py +115 -0
  13. cascade_review-0.2.0/cascade/analyzers/static/blast_radius.py +45 -0
  14. cascade_review-0.2.0/cascade/analyzers/static/build_breaker.py +356 -0
  15. cascade_review-0.2.0/cascade/analyzers/static/regression_risk.py +51 -0
  16. cascade_review-0.2.0/cascade/analyzers/static/secrets.py +74 -0
  17. cascade_review-0.2.0/cascade/analyzers/static/sonar.py +197 -0
  18. cascade_review-0.2.0/cascade/analyzers/static/version_conflict.py +95 -0
  19. cascade_review-0.2.0/cascade/audit.py +51 -0
  20. cascade_review-0.2.0/cascade/cli.py +313 -0
  21. cascade_review-0.2.0/cascade/clients/__init__.py +0 -0
  22. cascade_review-0.2.0/cascade/clients/anthropic.py +33 -0
  23. cascade_review-0.2.0/cascade/clients/base.py +11 -0
  24. cascade_review-0.2.0/cascade/clients/gemini.py +30 -0
  25. cascade_review-0.2.0/cascade/clients/ollama.py +24 -0
  26. cascade_review-0.2.0/cascade/clients/openai_compatible.py +30 -0
  27. cascade_review-0.2.0/cascade/clients/registry.py +23 -0
  28. cascade_review-0.2.0/cascade/config.py +80 -0
  29. cascade_review-0.2.0/cascade/diff_parser.py +93 -0
  30. cascade_review-0.2.0/cascade/output/__init__.py +0 -0
  31. cascade_review-0.2.0/cascade/output/github_inline.py +34 -0
  32. cascade_review-0.2.0/cascade/output/html_report.py +265 -0
  33. cascade_review-0.2.0/cascade/output/markdown.py +74 -0
  34. cascade_review-0.2.0/cascade/output/sarif.py +39 -0
  35. cascade_review-0.2.0/cascade/output/terminal.py +121 -0
  36. cascade_review-0.2.0/cascade/policy.py +79 -0
  37. cascade_review-0.2.0/cascade/quota_tracker.py +36 -0
  38. cascade_review-0.2.0/cascade/redact.py +32 -0
  39. cascade_review-0.2.0/cascade/router.py +27 -0
  40. cascade_review-0.2.0/cascade_review.egg-info/PKG-INFO +467 -0
  41. cascade_review-0.2.0/cascade_review.egg-info/SOURCES.txt +45 -0
  42. cascade_review-0.2.0/cascade_review.egg-info/dependency_links.txt +1 -0
  43. cascade_review-0.2.0/cascade_review.egg-info/entry_points.txt +2 -0
  44. cascade_review-0.2.0/cascade_review.egg-info/requires.txt +8 -0
  45. cascade_review-0.2.0/cascade_review.egg-info/top_level.txt +1 -0
  46. cascade_review-0.2.0/pyproject.toml +49 -0
  47. cascade_review-0.2.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vyshakh G Nair
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,467 @@
1
+ Metadata-Version: 2.4
2
+ Name: cascade-review
3
+ Version: 0.2.0
4
+ Summary: AI code reviewer with SonarQube simulation, blast radius analysis, and smart model routing
5
+ Author-email: Vyshakh G Nair <vyshakh@loqo.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/vyshakhgnair/cascade-review
8
+ Project-URL: Repository, https://github.com/vyshakhgnair/cascade-review
9
+ Project-URL: Issues, https://github.com/vyshakhgnair/cascade-review/issues
10
+ Keywords: code-review,ai,llm,sonarqube,static-analysis,developer-tools
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
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
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: requests>=2.31.0
24
+ Requires-Dist: pyyaml>=6.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-cov; extra == "dev"
28
+ Requires-Dist: black; extra == "dev"
29
+ Requires-Dist: ruff; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # cascade-review
33
+
34
+ > AI-powered code reviewer that catches what others miss.
35
+ > Build-breaker prevention. SonarQube-grade checks. Blast radius analysis.
36
+ > Works with 8 LLM providers. **Zero cost to start.**
37
+
38
+ [![PyPI](https://img.shields.io/pypi/v/cascade-review)](https://pypi.org/project/cascade-review/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
40
+ [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
41
+
42
+ ```bash
43
+ pip install cascade-review
44
+ git diff | cascade
45
+ ```
46
+
47
+ ---
48
+
49
+ ## What it does
50
+
51
+ Most AI code reviewers give you comments. Cascade gives you **impact** — and catches builds that would break in CI before you push.
52
+
53
+ ```
54
+ ──────────────────────────────────────────────────────────
55
+ cascade-review github.com/vyshakhgnair/cascade-review
56
+
57
+ CHANGE SUMMARY
58
+ Added token refresh logic to authenticate_user(). Extends
59
+ session handling with a new remember_me parameter.
60
+ Type: LOGIC ⚠ Auth path changed — affects all logged-in users
61
+
62
+ ⛔ SECRETS DETECTED
63
+ CRITICAL [API Key] in config/settings.py
64
+ api_key = "sk-proj-xxxxxxxxxxxxxxxxxxx..."
65
+
66
+ REGRESSION RISK
67
+ 8/10 ████████░░ CRITICAL
68
+ › Security-sensitive file: auth/login.py
69
+ › 3 files depend on authenticate_user()
70
+
71
+ BLAST RADIUS
72
+ Changed: authenticate_user, refresh_token
73
+ Risk: HIGH
74
+ → routes/dashboard.py uses authenticate_user
75
+ → middleware/guard.py uses authenticate_user
76
+ → api/v2/token.py uses refresh_token
77
+
78
+ SONARQUBE SIMULATION
79
+ CRITICAL S2077 SQL built from user input — use parameterised queries [30min]
80
+ MAJOR S3776 Cognitive complexity 18 exceeds threshold of 15 [1h]
81
+ MINOR S1481 Variable "tmp" assigned but never used [2min]
82
+
83
+ 🚧 BUILD BREAKERS
84
+ HIGH [MISSING_DEP] 'redis' imported but not in requirements.txt
85
+ CRITICAL [CASE_SENSITIVITY] Import 'Utils' — actual file is 'utils.py' (breaks on Linux CI)
86
+ WARNING [LOCKFILE_DRIFT] package.json changed but lock file not updated
87
+ ──────────────────────────────────────────────────────────
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Why Cascade is different
93
+
94
+ | Feature | Cascade | CodeRabbit | PR-Agent | SonarQube |
95
+ |---|---|---|---|---|
96
+ | **Build-breaker prevention** | **✅ 8 checks** | ❌ | ❌ | ❌ |
97
+ | **Code redaction** (privacy) | **✅** | ❌ | ❌ | n/a |
98
+ | Blast radius analysis | ✅ | ❌ | ❌ | ❌ |
99
+ | SonarQube rule simulation | ✅ | ❌ | ❌ | ✅ paid |
100
+ | Regression risk score | ✅ | ❌ | ❌ | ❌ |
101
+ | AI-generated code detection | ✅ | ❌ | ❌ | ❌ |
102
+ | Architecture drift check | ✅ | ❌ | ❌ | ❌ |
103
+ | Version conflict detection | ✅ | ❌ | ❌ | ❌ |
104
+ | Review policy as code | ✅ | ✅ | ❌ | ✅ |
105
+ | Works fully offline | ✅ | ❌ | ❌ | ❌ |
106
+ | Pre-commit hook | ✅ | ❌ | ❌ | ❌ |
107
+ | Audit trail (SOC 2) | ✅ | ❌ | ❌ | ✅ |
108
+ | Cost | **$0** | $24/mo | Self-host | Enterprise |
109
+ | Supports 8 LLM providers | ✅ | ❌ | Partial | ❌ |
110
+
111
+ **Cascade catches builds that would break in CI — no other code reviewer does this.**
112
+
113
+ ---
114
+
115
+ ## Quick start
116
+
117
+ ```bash
118
+ pip install cascade-review
119
+
120
+ # Review current changes (static only, no API key needed)
121
+ git diff | cascade --no-llm
122
+
123
+ # Review staged changes
124
+ cascade --staged
125
+
126
+ # Full review with LLM (free with Groq)
127
+ export GROQ_API_KEY=your-key-here
128
+ git diff | cascade
129
+
130
+ # Use a specific provider
131
+ cascade --provider anthropic --model claude-sonnet-4-6
132
+
133
+ # Output as markdown (for PR comments)
134
+ git diff | cascade --output markdown
135
+
136
+ # HTML dashboard report
137
+ git diff | cascade --output html > report.html
138
+
139
+ # Privacy mode — redact code before sending to LLM
140
+ git diff | cascade --redact
141
+
142
+ # CI mode — fail if critical findings exist
143
+ git diff | cascade --no-llm --severity-gate high
144
+ ```
145
+
146
+ ---
147
+
148
+ ## Build-breaker prevention
149
+
150
+ Cascade's unique feature — catches things that pass code review but **explode in CI**:
151
+
152
+ | Check | What it catches |
153
+ |---|---|
154
+ | `MISSING_DEP` | Imported package not in requirements.txt / package.json |
155
+ | `DEV_IN_PROD` | devDependency used in production code |
156
+ | `CASE_SENSITIVITY` | File imports that work on Mac/Windows but break on Linux CI |
157
+ | `DELETED_SYMBOL` | Function/class removed but still imported elsewhere |
158
+ | `PLATFORM_PATH` | Hardcoded `C:\` or `/Users/` paths |
159
+ | `LOCKFILE_DRIFT` | package.json changed but lock file not updated |
160
+ | `LARGE_FILE` | Binary or data file accidentally committed |
161
+ | `MISSING_ENV_VAR` | Env var used in code but not in .env.example |
162
+
163
+ ---
164
+
165
+ ## Code redaction (privacy)
166
+
167
+ Don't trust your LLM provider with proprietary code? Use `--redact`:
168
+
169
+ ```bash
170
+ # Before redaction:
171
+ api_key = "sk-prod-abc123"
172
+ price = 99.99
173
+
174
+ # What the LLM sees:
175
+ api_key = "STR_1"
176
+ price = NUM_2
177
+ ```
178
+
179
+ Structure is preserved for accurate review. Values never leave your machine.
180
+
181
+ ---
182
+
183
+ ## Supported providers
184
+
185
+ ```bash
186
+ cascade --list-providers # See all providers and their status
187
+ ```
188
+
189
+ | Provider | Free tier | Privacy | Notes |
190
+ |---|---|---|---|
191
+ | **Ollama** | ✅ Free (local) | ✅ Local | Offline, private, no quota |
192
+ | **Groq** | ✅ 30K TPM | ⚠ Check ToS | Fastest cloud inference |
193
+ | **OpenRouter** | ✅ 29 free models | ⚠ Check ToS | Frontier models at no cost |
194
+ | **DeepSeek** | ✅ Free tier | ⚠ Check ToS | Strong reasoning |
195
+ | **Gemini** | ✅ Free tier | ⚠ Check ToS | Gemini Flash / Pro |
196
+ | **Mistral** | ✅ Free tier | ✅ No-train | Fast, European |
197
+ | **Anthropic** | Paid | ✅ No-train | Claude Sonnet / Opus |
198
+ | **OpenAI** | Paid | ✅ No-train | GPT-4o, o1 |
199
+
200
+ Privacy labels: **local** = nothing leaves your machine, **no-train** = provider won't train on your inputs, **check ToS** = free tier may use inputs for training.
201
+
202
+ Cascade warns you when using providers with unclear privacy policies.
203
+
204
+ ---
205
+
206
+ ## Configuration
207
+
208
+ ```bash
209
+ cascade --init # Creates .cascade.yml in your repo
210
+ ```
211
+
212
+ `.cascade.yml`:
213
+
214
+ ```yaml
215
+ models:
216
+ local:
217
+ provider: ollama
218
+ model: qwen2.5-coder:3b
219
+
220
+ mid:
221
+ provider: groq
222
+ model: llama-3.3-70b-versatile
223
+ api_key_env: GROQ_API_KEY
224
+
225
+ frontier:
226
+ provider: anthropic
227
+ model: claude-sonnet-4-6
228
+ api_key_env: ANTHROPIC_API_KEY
229
+
230
+ routing:
231
+ local_max_lines: 50 # < 50 lines → local model
232
+ mid_max_lines: 200 # 50-200 lines → mid tier
233
+ force_tier: auto # or: local / mid / frontier
234
+
235
+ review:
236
+ severity_threshold: warning
237
+ exclude: [migrations/, vendor/, node_modules/]
238
+ ```
239
+
240
+ ### Team config inheritance (monorepos)
241
+
242
+ Place a root `.cascade.yml` at the repo root, then override per-package:
243
+
244
+ ```
245
+ my-monorepo/
246
+ .cascade.yml ← root config (shared settings)
247
+ packages/
248
+ api/
249
+ .cascade.yml ← overrides for API package
250
+ frontend/
251
+ .cascade.yml ← overrides for frontend
252
+ ```
253
+
254
+ Package configs deep-merge with root — you only override what's different.
255
+
256
+ ---
257
+
258
+ ## Review policy as code
259
+
260
+ Create `.cascade-rules.yml` to enforce team standards:
261
+
262
+ ```yaml
263
+ rules:
264
+ - name: no-console-log
265
+ message: "Remove console.log before merging"
266
+ files: "\\.(js|ts|tsx)$"
267
+ pattern: "console\\.log\\("
268
+ severity: WARNING
269
+
270
+ - name: no-debugger
271
+ message: "Debugger statement left in code"
272
+ pattern: "\\bdebugger\\b"
273
+ severity: HIGH
274
+
275
+ - name: no-axios-in-services
276
+ message: "Use the shared HTTP client, not raw axios"
277
+ files: "services/"
278
+ forbidden_imports: ["axios"]
279
+ severity: WARNING
280
+
281
+ - name: max-file-size
282
+ message: "File too large — consider splitting"
283
+ max_lines: 500
284
+ severity: WARNING
285
+
286
+ - name: tests-required
287
+ message: "Test file should include at least one assertion"
288
+ files: "(test_|spec\\.|__test)"
289
+ require: "(assert|expect|should)"
290
+ severity: HIGH
291
+ ```
292
+
293
+ See [`examples/cascade-rules.yml`](examples/cascade-rules.yml) for more.
294
+
295
+ ---
296
+
297
+ ## Pre-commit hook
298
+
299
+ ```bash
300
+ cascade --hook install # Install pre-commit hook
301
+ cascade --hook uninstall # Remove it
302
+ ```
303
+
304
+ Runs static analysis on staged changes before every commit. Blocks commits with high-severity findings.
305
+
306
+ ---
307
+
308
+ ## Audit trail (SOC 2)
309
+
310
+ ```bash
311
+ git diff | cascade --audit # Log to .cascade/audit.jsonl
312
+ git diff | cascade --audit --audit-path logs/reviews.jsonl # Custom path
313
+ ```
314
+
315
+ Every review is logged as a JSON line:
316
+
317
+ ```json
318
+ {
319
+ "timestamp": "2026-06-25T18:19:08Z",
320
+ "version": "0.2.0",
321
+ "provider": "groq",
322
+ "model": "llama-3.3-70b-versatile",
323
+ "redacted": false,
324
+ "files_reviewed": ["auth/login.py"],
325
+ "findings": {"secrets": 0, "sonar": 3, "build_breakers": 1, "bugs": 0},
326
+ "severities": {"CRITICAL": 1, "MAJOR": 2},
327
+ "regression_risk": {"score": 6, "level": "HIGH"}
328
+ }
329
+ ```
330
+
331
+ ---
332
+
333
+ ## CI / GitHub Action
334
+
335
+ ```yaml
336
+ # .github/workflows/cascade.yml
337
+ name: Cascade Review
338
+ on:
339
+ pull_request:
340
+ types: [opened, synchronize]
341
+
342
+ jobs:
343
+ review:
344
+ runs-on: ubuntu-latest
345
+ permissions:
346
+ pull-requests: write
347
+ contents: read
348
+ security-events: write
349
+
350
+ steps:
351
+ - uses: actions/checkout@v4
352
+ with:
353
+ fetch-depth: 0
354
+
355
+ - uses: vyshakhgnair/cascade-review@v1
356
+ with:
357
+ groq_api_key: ${{ secrets.GROQ_API_KEY }}
358
+ output_format: markdown
359
+ severity_gate: high
360
+ fail_on_secrets: true
361
+ ```
362
+
363
+ Add `GROQ_API_KEY` to repo secrets (free at [console.groq.com](https://console.groq.com)).
364
+
365
+ ### Other CI platforms
366
+
367
+ - [GitLab CI](examples/gitlab-ci.yml)
368
+ - [Bitbucket Pipelines](examples/bitbucket-pipelines.yml)
369
+ - [Azure DevOps](examples/azure-pipelines.yml)
370
+
371
+ ---
372
+
373
+ ## Output formats
374
+
375
+ | Format | Flag | Use case |
376
+ |---|---|---|
377
+ | Terminal | `--output terminal` | Local development (default) |
378
+ | Markdown | `--output markdown` | PR comments |
379
+ | HTML | `--output html` | Shareable dashboard report |
380
+ | SARIF | `--output sarif` | GitHub Security tab |
381
+ | JSON | `--output json` | Programmatic consumption |
382
+
383
+ ---
384
+
385
+ ## Smart routing
386
+
387
+ ```
388
+ < 50 lines → local Ollama 3B (instant, private, zero quota)
389
+ 50–200 lines → Groq 70B (fast, free tier)
390
+ 200+ lines → OpenRouter/Claude (full context, deepest reasoning)
391
+ ```
392
+
393
+ Auto-fallback when quotas run out. Override anytime: `cascade --tier frontier`
394
+
395
+ ---
396
+
397
+ ## What Cascade checks
398
+
399
+ **Static analysis — instant, works offline, no API key:**
400
+ - SonarQube rule simulation (Python + JS/TS — S1192, S2077, S3776, S1481, S106 and more)
401
+ - Secret / credential detection (15+ patterns — API keys, AWS, Stripe, GitHub, SSH keys)
402
+ - Blast radius — which files break if this change fails
403
+ - Regression risk score (1–10)
404
+ - Architecture drift (naming, layer violations, broad exceptions, god classes, circular imports)
405
+ - Build-breaker prevention (8 checks)
406
+ - Version conflict detection (cross-workspace / monorepo)
407
+ - Review policy enforcement (.cascade-rules.yml)
408
+
409
+ **LLM analysis — requires a model:**
410
+ - Plain English change summary (LOGIC / REFACTOR / FEATURE / BUGFIX / CONFIG / TEST / DOCS)
411
+ - Bug and logic error detection
412
+ - AI-generated code detection
413
+ - Fix suggestions with effort estimates
414
+
415
+ ---
416
+
417
+ ## Exit codes
418
+
419
+ | Code | Meaning |
420
+ |---|---|
421
+ | `0` | Clean — no blocking findings |
422
+ | `1` | Error — could not parse diff |
423
+ | `2` | Secrets detected |
424
+ | `3` | Severity gate failed |
425
+
426
+ ---
427
+
428
+ ## All CLI flags
429
+
430
+ ```
431
+ cascade --version # Show version
432
+ cascade --staged # Review staged changes only
433
+ cascade --no-llm # Static analysis only
434
+ cascade --redact # Strip literals before sending to LLM
435
+ cascade --provider groq # Override LLM provider
436
+ cascade --model llama-3.3-70b # Override model
437
+ cascade --tier frontier # Force model tier
438
+ cascade --output html # terminal / markdown / sarif / json / html
439
+ cascade --severity-gate high # Fail if findings >= severity
440
+ cascade --audit # Write audit trail
441
+ cascade --audit-path path/log.jsonl # Custom audit log path
442
+ cascade --hook install # Install pre-commit hook
443
+ cascade --hook uninstall # Remove pre-commit hook
444
+ cascade --list-providers # Show providers and key status
445
+ cascade --init # Create .cascade.yml
446
+ ```
447
+
448
+ ---
449
+
450
+ ## Contributing
451
+
452
+ ```bash
453
+ git clone https://github.com/vyshakhgnair/cascade-review
454
+ cd cascade-review
455
+ pip install -e ".[dev]"
456
+ pytest
457
+ ```
458
+
459
+ ---
460
+
461
+ ## License
462
+
463
+ MIT — use it, fork it, build on it.
464
+
465
+ ---
466
+
467
+ *Built by [Vyshakh G Nair](https://github.com/vyshakhgnair) — [cascade-review](https://github.com/vyshakhgnair/cascade-review)*