roast-my-codebase 1.0.0

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +468 -0
  3. package/dist/index.js +4480 -0
  4. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
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.
package/README.md ADDED
@@ -0,0 +1,468 @@
1
+ # roast-my-codebase 🔥
2
+
3
+ > Get roasted. Get better. Ship faster.
4
+
5
+ A zero-config CLI that analyzes your codebase and delivers brutally honest (but funny) feedback. Every roast is backed by a real finding — no random nonsense.
6
+
7
+ ```
8
+ npx roast-my-codebase
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ Scans your project in seconds and produces:
14
+
15
+ - **Health Score** (0–100) based on real code quality signals
16
+ - **Project Statistics** — files, lines, dependencies
17
+ - **Actionable Findings** — large files, circular deps, unused packages, TODOs
18
+ - **Roasts** — humorous commentary tied to actual issues
19
+ - **Verdict** — a one-liner summary of your codebase's state
20
+
21
+ ## Screenshot
22
+
23
+ ```
24
+ ╔═════════════════════════════╗
25
+ ║ Roast My Codebase 🔥 ║
26
+ ╚═════════════════════════════╝
27
+
28
+ Project Health: 72/100 C Fair
29
+
30
+ [██████████████████████░░░░░░░░]
31
+
32
+ Files Scanned 438
33
+ Lines of Code 64,112
34
+ Dependencies 87
35
+
36
+ ⚠ 14 TODOs
37
+ ⚠ 7 Large Files (500+ lines)
38
+ ⚠ 2 Circular Dependencies
39
+
40
+ 🔥 Roast
41
+
42
+ auth.service.ts (1,847 lines)
43
+ This file contains several geological layers.
44
+
45
+ Verdict:
46
+ Your codebase is at that stage where 'refactor sprint'
47
+ keeps getting postponed.
48
+ ```
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ # Run directly (no install needed)
54
+ npx roast-my-codebase
55
+
56
+ # Or install globally
57
+ npm install -g roast-my-codebase
58
+ roast-my-codebase
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ```bash
64
+ # Basic scan
65
+ npx roast-my-codebase
66
+
67
+ # Scan specific path
68
+ npx roast-my-codebase ./path/to/project
69
+
70
+ # Get actionable fix suggestions
71
+ npx roast-my-codebase --fix
72
+
73
+ # AI-powered contextual roasts
74
+ npx roast-my-codebase --ai-roasts
75
+
76
+ # Interactive mode - walk through fixing issues
77
+ npx roast-my-codebase --interactive
78
+
79
+ # Preview fixes without applying them
80
+ npx roast-my-codebase --interactive --dry-run
81
+
82
+ # Watch mode (re-run on file changes)
83
+ npx roast-my-codebase --watch
84
+
85
+ # JSON output for CI/CD
86
+ npx roast-my-codebase --json --threshold 80
87
+
88
+ # Compare against a git branch
89
+ npx roast-my-codebase --compare main
90
+
91
+ # Viral features for sharing
92
+ npx roast-my-codebase --ascii # Big ASCII art grade
93
+ npx roast-my-codebase --badge # Generate SVG badge
94
+ npx roast-my-codebase --markdown # Markdown for PRs
95
+ npx roast-my-codebase --markdown-file # Save to .roast-report.md
96
+ ```
97
+
98
+ ## What gets analyzed
99
+
100
+ | Check | What it finds |
101
+ |-------|--------------|
102
+ | **File Size** | Files over 500/1000/2000 lines |
103
+ | **TODOs** | TODO, FIXME, HACK, XXX comments |
104
+ | **Dependencies** | Excessive or unused packages |
105
+ | **Circular Deps** | Import cycles between modules |
106
+ | **Structure** | Deep nesting, bloated folders, utils explosion |
107
+ | **Complexity** | Functions with high cyclomatic complexity (15+) |
108
+ | **Duplicates** | Copy-pasted code blocks across files |
109
+ | **Dead Exports** | Exports that are never imported |
110
+ | **Type Safety** | `any` usage, `@ts-ignore`, type bypasses |
111
+
112
+ ## Supported Languages
113
+
114
+ ### Fully Supported
115
+ - **JavaScript** (.js, .jsx, .mjs, .cjs)
116
+ - **TypeScript** (.ts, .tsx)
117
+ - **Python** (.py) - NEW! ✨
118
+ - Complexity analysis
119
+ - Type hints detection
120
+ - Import pattern analysis
121
+
122
+ ### Universal Features (All Languages)
123
+ - File size analysis
124
+ - TODO/FIXME detection
125
+ - Git insights
126
+ - Security scans
127
+
128
+ ### Coming Soon
129
+ - Go (.go)
130
+ - Rust (.rs)
131
+ - Java (.java)
132
+ - C# (.cs)
133
+
134
+ Language detection is automatic! The tool detects your project's languages and runs appropriate scanners.
135
+
136
+ ## Design principles
137
+
138
+ 1. **Real value** — Humor is the presentation layer. Analysis is the product.
139
+ 2. **Completely offline** — No APIs, no cloud, no telemetry, no data collection.
140
+ 3. **Fast** — Under 3 seconds for repos with < 1000 files.
141
+ 4. **Beautiful output** — Designed to be screenshot-worthy.
142
+
143
+ ## Health Score
144
+
145
+ Starts at 100. Deductions for:
146
+
147
+ | Issue | Deduction |
148
+ |-------|-----------|
149
+ | Large file (1000+ lines) | -3 |
150
+ | Extreme file (2000+ lines) | -5 |
151
+ | Circular dependency | -5 |
152
+ | Unused dependency | -2 |
153
+ | TODO/FIXME (per occurrence) | -0.25 |
154
+ | Excessive total dependencies | -5 |
155
+ | Deep nesting | -2 |
156
+
157
+ Grades:
158
+ - **90–100** Excellent
159
+ - **80–89** Good
160
+ - **70–79** Fair
161
+ - **60–69** Risky
162
+ - **0–59** Chaotic
163
+
164
+ ## Viral / Shareable Features
165
+
166
+ ### ASCII Art Grade
167
+ ```bash
168
+ roast-my-codebase --ascii
169
+ ```
170
+ - Big, colorful letter grade at the top (A/B/C/D/F)
171
+ - Perfect for screenshots and social media
172
+ - Color-coded based on health score
173
+
174
+ ### SVG Badge Generation
175
+ ```bash
176
+ roast-my-codebase --badge
177
+ ```
178
+ - Generates `.roast-badge.svg` for your README
179
+ - Shields.io-style badge showing "Health: 82/100"
180
+ - Color-coded: green (90+), yellow-green (80+), yellow (70+), orange (60+), red (<60)
181
+ - Embed in your README:
182
+ ```markdown
183
+ ![Codebase Health](.roast-badge.svg)
184
+ ```
185
+
186
+ ### Markdown Output
187
+ ```bash
188
+ roast-my-codebase --markdown # Output to stdout
189
+ roast-my-codebase --markdown-file # Save to .roast-report.md
190
+ ```
191
+ - Beautiful markdown with collapsible sections
192
+ - Perfect for GitHub PRs, Notion, and documentation
193
+ - Includes emoji severity indicators (🔴/⚠️/ℹ️)
194
+ - Tables for stats, blockquotes for roasts
195
+
196
+ ## Developer Experience Features
197
+
198
+ ### JSON Output for CI/CD
199
+ ```bash
200
+ roast-my-codebase --json --threshold 80
201
+ ```
202
+ - Machine-readable output
203
+ - Exit code 1 if score < threshold
204
+ - Perfect for CI pipelines
205
+
206
+ ### Fix Suggestions
207
+ ```bash
208
+ roast-my-codebase --fix
209
+ ```
210
+ - Actionable one-liner fixes for each issue
211
+ - Specific commands (e.g., `npm uninstall unused-package`)
212
+ - Refactoring guidance
213
+
214
+ ### AI-Powered Roasts
215
+ ```bash
216
+ roast-my-codebase --ai-roasts
217
+ ```
218
+ - 🤖 Context-aware roasts generated by Claude AI
219
+ - 🎯 Specific to your actual code issues
220
+ - 😄 More witty and relevant than generic roasts
221
+ - 💾 Cached for 7 days to minimize API costs
222
+ - 🔒 Requires ANTHROPIC_API_KEY environment variable
223
+
224
+ **Example comparison:**
225
+
226
+ Generic roast:
227
+ > "This file contains several geological layers."
228
+
229
+ AI-powered roast:
230
+ > "This 1,847-line auth service is doing authentication, authorization, password reset, email verification, 2FA, and probably making coffee. Pick a lane."
231
+
232
+ **Setup:**
233
+ ```bash
234
+ # Set API key
235
+ export ANTHROPIC_API_KEY=your_key_here
236
+
237
+ # Or configure in .roastrc.json
238
+ {
239
+ "ai": {
240
+ "enabled": true,
241
+ "apiKey": "your_key_here",
242
+ "model": "claude-3-5-sonnet-20241022",
243
+ "cacheEnabled": true
244
+ }
245
+ }
246
+ ```
247
+
248
+ **Cost control:**
249
+ - Only roasts top 10 most interesting findings
250
+ - Caches roasts for 7 days
251
+ - Cache stored in `.roast-ai-cache.json`
252
+ - Typical cost: $0.01-0.05 per scan
253
+
254
+ ### Interactive Mode
255
+ ```bash
256
+ roast-my-codebase --interactive
257
+ ```
258
+ - 🎯 Walk through issues one by one
259
+ - 💡 See detailed explanations and fix suggestions
260
+ - ✨ Apply automatic fixes where possible
261
+ - ⚡ Preview changes with `--dry-run` flag
262
+ - 🎨 Beautiful interactive UI
263
+
264
+ **What can be auto-fixed:**
265
+ - ✅ Remove unused dependencies (`npm uninstall`)
266
+ - ✅ Add issue references to TODO comments
267
+ - ✅ Remove dead exports
268
+ - 🔜 More fixes coming soon!
269
+
270
+ **Example session:**
271
+ ```
272
+ 🔧 Interactive Fix Mode
273
+
274
+ Found 12 fixable issues.
275
+
276
+ Issue 1/12 - 🔴 Critical
277
+ ─────────────────────────────────────────
278
+ Unused dependency `lodash` is installed but never imported
279
+
280
+ 💡 Fix suggestion:
281
+ Remove unused dependency: lodash
282
+
283
+ ✓ This can be fixed automatically!
284
+
285
+ ? What would you like to do?
286
+ ❯ Apply fix automatically
287
+ Show details
288
+ Skip
289
+ Exit interactive mode
290
+ ```
291
+
292
+ ### Watch Mode
293
+ ```bash
294
+ roast-my-codebase --watch
295
+ ```
296
+ - Re-runs on file changes
297
+ - Shows score delta
298
+ - Compact summaries for quick feedback
299
+
300
+ ### Compare Branches
301
+ ```bash
302
+ roast-my-codebase --compare main
303
+ ```
304
+ - Diff current code vs. a git branch
305
+ - Shows new issues introduced
306
+ - Shows resolved issues
307
+ - Score delta comparison
308
+
309
+ ### Historical Health Tracking
310
+ ```bash
311
+ roast-my-codebase --track
312
+ ```
313
+ - 📊 Track health score over time
314
+ - 📈 See trends (improving/declining/stable)
315
+ - 📉 Visual ASCII charts
316
+ - 💾 Stores in `.roast-history.json` (gitignored)
317
+ - ⏱️ Per-commit snapshots with git info
318
+
319
+ **View history:**
320
+ ```bash
321
+ roast-my-codebase --history # Last 30 days
322
+ roast-my-codebase --history 7 # Last 7 days
323
+ roast-my-codebase --history 90 # Last 90 days
324
+ ```
325
+
326
+ **What's tracked:**
327
+ - Health score over time
328
+ - Finding counts by severity
329
+ - Category-level trends
330
+ - Git commit information
331
+ - Score improvement rate
332
+
333
+ **Example output:**
334
+ ```
335
+ 📊 Health History Report
336
+
337
+ Project: my-app
338
+ Total snapshots: 45
339
+
340
+ Current Health
341
+ Score: 85/100 (B)
342
+ Findings: 12
343
+ ● 2 critical ● 6 warnings ● 4 info
344
+
345
+ Trend Analysis (Last 30 days)
346
+ ↗ IMPROVING (+12 points)
347
+
348
+ Statistics:
349
+ Average score: 78.5/100
350
+ Best score: 85/100
351
+ Worst score: 68/100
352
+ Improvement rate: +0.4 points/day
353
+
354
+ Score Trend
355
+ 100 ┤
356
+ 90 ┤ ●●
357
+ 80 ┤ ●● ●
358
+ 70 ┤ ●●
359
+ 60 ┼──────────────→
360
+ Jan 1 Jan 30
361
+
362
+ Category Changes
363
+ ↓ Improving:
364
+ ✓ unused-dependencies: -5 issues
365
+ ✓ todos: -8 issues
366
+ ↑ Declining:
367
+ ✗ complexity: +2 issues
368
+ ```
369
+
370
+ **Use in CI:**
371
+ ```bash
372
+ # Track on every commit
373
+ roast-my-codebase --track
374
+
375
+ # Fail if declining trend
376
+ roast-my-codebase --history 7 | grep -q "DECLINING" && exit 1
377
+ ```
378
+
379
+ ## Customization
380
+
381
+ ### Config File (`.roastrc.json`)
382
+
383
+ Create a `.roastrc.json` in your project root to customize behavior:
384
+
385
+ ```json
386
+ {
387
+ "thresholds": {
388
+ "largeFile": 1000,
389
+ "extremeFile": 3000
390
+ },
391
+ "scanners": {
392
+ "disabled": ["test-coverage", "framework"]
393
+ },
394
+ "ignore": [
395
+ "**/vendor/**",
396
+ "**/generated/**"
397
+ ],
398
+ "deductions": {
399
+ "secret": -20,
400
+ "missingTest": -1
401
+ },
402
+ "plugins": [
403
+ "roast-plugin-graphql"
404
+ ]
405
+ }
406
+ ```
407
+
408
+ **See [CUSTOMIZATION.md](CUSTOMIZATION.md) for full documentation.**
409
+
410
+ ### Plugin Development
411
+
412
+ Create custom scanners as npm packages:
413
+
414
+ ```javascript
415
+ // roast-plugin-example/index.js
416
+ export default {
417
+ name: "roast-plugin-example",
418
+ version: "1.0.0",
419
+ scanner: {
420
+ name: "example",
421
+ async scan(rootDir) {
422
+ const findings = [];
423
+ // Your scanner logic
424
+ return { findings };
425
+ }
426
+ }
427
+ };
428
+ ```
429
+
430
+ **See [CUSTOMIZATION.md](CUSTOMIZATION.md) for plugin development guide.**
431
+
432
+ ## VS Code Extension
433
+
434
+ Bring roast-my-codebase directly into your editor! The VS Code extension provides:
435
+
436
+ - **Real-time analysis** with inline diagnostics
437
+ - **Status bar widget** showing live health score
438
+ - **Tree view panels** for browsing findings and stats
439
+ - **Interactive HTML reports** in VS Code
440
+ - **Badge generation** from the command palette
441
+ - **Configurable** - reads `.roastrc.json` and VS Code settings
442
+
443
+ ### Installation
444
+
445
+ 1. Search for "Roast My Codebase" in VS Code Extensions marketplace
446
+ 2. Install the CLI: `npm install -g roast-my-codebase`
447
+ 3. Open any workspace and run: `Roast: Scan Workspace`
448
+
449
+ See [vscode-extension/README.md](vscode-extension/README.md) for full documentation.
450
+
451
+ ## Contributing
452
+
453
+ PRs welcome. The architecture is modular — each scanner is independent and easy to add to.
454
+
455
+ ```
456
+ src/
457
+ ├── cli/ # Command setup
458
+ ├── scanners/ # Modular analysis passes
459
+ ├── scoring/ # Health score calculation
460
+ ├── roasts/ # Roast generation
461
+ ├── report/ # Terminal rendering
462
+ ├── types/ # Shared interfaces
463
+ └── utils/ # Shared helpers
464
+ ```
465
+
466
+ ## License
467
+
468
+ MIT