vibertest 0.1.0 → 0.1.2

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.
package/README.md CHANGED
@@ -12,418 +12,103 @@
12
12
 
13
13
  **Your AI writes code. ViberTest makes sure it doesn't suck.**
14
14
 
15
- *Got sick of vibecoders' mess, so I vibecoded this.*
15
+ Static analyzer for JavaScript & TypeScript that detects quality issues commonly produced by AI-assisted development.
16
16
 
17
- A CLI tool + Web Dashboard that analyzes JavaScript/TypeScript projects to detect quality issues commonly produced by AI-assisted development (vibecoding).
18
-
19
- **[Full Documentation →](https://vibertest.chyste.dev/docs)**
20
-
21
- [Getting Started](#getting-started) · [24 Rules](#the-24-rules) · [Grading System](#grading-system) · [Dashboard](#web-dashboard) · [Configuration](#configuration)
17
+ 24 rules · Zero config · One command
22
18
 
23
19
  </div>
24
20
 
25
21
  ---
26
22
 
27
- ## The Problem
28
-
29
- AI coding tools (Cursor, Copilot, v0, Bolt) generate code that **works** but is often:
30
-
31
- - Copy-pasted across files with no abstraction
32
- - Missing error handling, tests, and proper architecture
33
- - Full of `console.log`, generic variable names, and TODO comments
34
- - Using outdated patterns (`var`, class components, callback hell)
35
- - Dumping everything into god files with circular dependencies
36
-
37
- **ViberTest catches all of this.** It scans your project, scores it 0-100, and tells you exactly what to fix.
38
-
39
- ## Getting Started
40
-
41
- ### Prerequisites
42
-
43
- - **Node.js** >= 20.0.0
44
- - **pnpm** >= 10.x
45
-
46
- ### Installation
23
+ ## Quick Start
47
24
 
48
25
  ```bash
49
- # Clone the repository
50
- git clone https://github.com/Chyste/vibertest.git
51
- cd vibertest
52
-
53
- # Install dependencies
54
- pnpm install
55
-
56
- # Build all packages
57
- pnpm run build
58
-
59
- # Link the CLI globally
60
- cd packages/cli
61
- pnpm link --global
26
+ npm i -g vibertest
27
+ vibertest scan .
62
28
  ```
63
29
 
64
- ### Run Your First Scan
30
+ Or run without installing:
65
31
 
66
32
  ```bash
67
- # Scan the current directory
68
- vibertest scan .
33
+ npx vibertest scan .
34
+ ```
69
35
 
70
- # Scan a specific project
71
- vibertest scan ~/my-project
36
+ ## Usage
72
37
 
73
- # Export results as JSON
38
+ ```bash
39
+ # JSON output
74
40
  vibertest scan . --format json --output report.json
75
41
 
76
- # Run only specific rules
77
- vibertest scan . --rules oversized-files,dead-code,ai-smell
42
+ # Specific rules only
43
+ vibertest scan . --rules hardcoded-secrets,dead-code,ai-smell
78
44
 
79
- # Silent mode (no terminal output, just JSON)
80
- vibertest scan . --format json --silent
81
- ```
82
-
83
- ### Initialize Config
45
+ # Silent mode (no terminal output, just the report)
46
+ vibertest scan . --format json --silent --output report.json
84
47
 
85
- ```bash
86
- # Create a .vibertestrc.json in your project
48
+ # Initialize config
87
49
  vibertest init
88
50
  ```
89
51
 
90
- ---
91
-
92
- ## The 24 Rules
93
-
94
- ViberTest analyzes your codebase with **24 rules** organized by what they detect. Each rule is specifically designed to catch patterns that AI tools produce when developers accept generated code without review.
95
-
96
- ### Architecture & Structure
97
-
98
- | Rule | Severity | What It Detects |
99
- |------|----------|-----------------|
100
- | **Oversized Files** | Medium | Files exceeding line threshold. AI dumps everything in one file. |
101
- | **God File** | High | Files with >10 exports, mixed concerns, and high import fan-in. The "does everything" file. |
102
- | **Bloated Barrel** | Medium/High | `index.ts` files with >15 re-exports. Kills tree-shaking and slows bundlers. |
103
- | **Circular Dependencies** | High | Import cycles (A → B → C → A) detected via DFS graph traversal. Causes runtime errors. |
104
- | **Separation of Concerns** | Medium | `fetch()` in React components, SQL outside data layers, business logic in route handlers. |
105
-
106
- ### Code Quality
107
-
108
- | Rule | Severity | What It Detects |
109
- |------|----------|-----------------|
110
- | **Dead Code & Unused Exports** | High | Exported functions, types, and variables that are never imported anywhere. |
111
- | **Code Duplication** | High/Medium | 6+ duplicate lines across different files. Copy-paste without abstraction. |
112
- | **Poor Maintainability** | High/Medium/Low | Long functions (>50 lines), too many parameters (>4), excessive imports (>10), magic numbers. |
113
- | **Missing Error Handling** | High/Medium | `async` functions without try/catch, unhandled Promise chains, empty/swallowed catch blocks, console-only error handling. |
114
- | **Missing Tests** | High/Medium | No test files, low test-to-source ratio, empty tests, trivial assertions (`expect(true).toBe(true)`), generic test names, skipped/todo tests. |
115
-
116
- ### Style & Patterns
117
-
118
- | Rule | Severity | What It Detects |
119
- |------|----------|-----------------|
120
- | **Style Inconsistency** | Medium | Mixed camelCase/snake_case, function declarations vs arrows, single vs double quotes, semicolons. |
121
- | **Pattern Inconsistency** | Medium | Mixed styling approaches (Tailwind + CSS Modules + inline styles in the same project). |
122
- | **Obsolete Patterns** | Medium | `var` declarations, `.then()` chains (3+ deep), React class components, CommonJS in `.ts` files, `arguments` keyword. |
123
-
124
- ### Dependencies & Config
125
-
126
- | Rule | Severity | What It Detects |
127
- |------|----------|-----------------|
128
- | **Unused Dependencies** | High/Medium | Packages in `package.json` that are never imported in your code. |
129
- | **Duplicate Dependencies** | High | Multiple packages for the same purpose: axios + fetch, jest + vitest, moment + dayjs, etc. |
130
- | **Hardcoded Secrets** | Critical | API keys, tokens, passwords, and connection strings hardcoded in source files. |
131
-
132
- ### AI-Specific Smells
52
+ ## What It Detects
133
53
 
134
- | Rule | Severity | What It Detects |
135
- |------|----------|-----------------|
136
- | **AI Smell** | High/Medium/Info | `console.log` in production, generic names (`data`, `result`, `temp`) as info-level, obvious comments, `utils.ts` dumping grounds, placeholder logic (`throw new Error('Not implemented')`) as high. |
137
- | **Abandoned TODO/FIXME** | Medium/Low | Unresolved `TODO`, `FIXME`, `HACK`, `XXX` comments unfinished work that shipped anyway. |
54
+ | Category | Rules | Focus |
55
+ |----------|:-----:|-------|
56
+ | **Architecture** | 5 | Oversized files, god files, bloated barrels, circular dependencies, mixed concerns |
57
+ | **Code Quality** | 5 | Dead code, copy-paste duplication, long functions, missing error handling, missing tests |
58
+ | **Style & Patterns** | 3 | Inconsistent naming, mixed styling approaches, `var` declarations, `.then()` chains |
59
+ | **Dependencies** | 3 | Unused packages, duplicate libraries (axios + fetch), hardcoded secrets |
60
+ | **AI Smells** | 2 | `console.log` in production, generic names (`data`, `temp`), placeholder logic, abandoned TODOs |
61
+ | **Ship-Readiness** | 6 | Security anti-patterns, accessibility violations, missing linter, no favicon, missing legal pages |
138
62
 
139
- ### Security & Compliance
63
+ ## Scoring
140
64
 
141
- | Rule | Severity | What It Detects |
142
- |------|----------|-----------------|
143
- | **Security Anti-Patterns** | Critical/High | SQL injection risks, `eval()` with dynamic input, hardcoded credentials, CORS wildcards, sensitive data in localStorage, `innerHTML` with user input, `Math.random()` for security, `dangerouslySetInnerHTML`. |
144
- | **Missing Compliance Pages** | Critical/High | Missing Terms of Service, Privacy Policy, unresolved legal placeholders (`[Company Name]`), analytics without cookie consent, auth without account deletion. |
145
- | **Accessibility Anti-Patterns** | Medium/Low | Images without `alt` text, non-semantic click handlers (`<div onClick>`), form inputs without labels, missing ARIA landmarks, non-descriptive link text ("click here"). |
146
-
147
- ### Ship-Readiness
148
-
149
- | Rule | Severity | What It Detects |
150
- |------|----------|-----------------|
151
- | **Missing Project Standards** | High/Medium/Low | Missing `tsconfig.json`, no linter config (ESLint/Biome), missing `.gitignore`, `.env` without `.env.example`, no formatter config, missing `.editorconfig`, no `README.md`. |
152
- | **Missing Production Basics** | Medium/Low | Generic page titles ("Create Next App"), missing meta description, default/missing favicon, no Open Graph tags, missing custom 404 page, no `robots.txt`, no `sitemap.xml`. |
153
- | **React Performance** | High/Medium/Low | Array index as key, problematic `useEffect` patterns, `setState` in loops, nested component definitions, inline objects/functions in JSX, spreading all props. *(Disabled by default — very noisy)* |
154
-
155
- ---
156
-
157
- ## Grading System
158
-
159
- ViberTest scores your project **0 to 100** and assigns a letter grade:
65
+ Each scan produces a **health score (10–100)** with a letter grade (A–F). Issues are weighted by severity with diminishing returns — 15 medium issues from one rule won't crush your score the same as 5 critical ones.
160
66
 
161
67
  | Grade | Score | Meaning |
162
- |-------|-------|---------|
163
- | **A** | 90–100 | Excellent — Clean, well-structured code |
164
- | **B** | 75–89 | Good — Minor issues, solid foundation |
165
- | **C** | 60–74 | Needs Work — Noticeable quality gaps |
166
- | **D** | 40–59 | Poor — Significant structural problems |
167
- | **F** | 0–39 | Critical — Major issues across the board |
168
-
169
- ### How Scoring Works
170
-
171
- Each issue deducts penalty points based on severity:
172
-
173
- | Severity | Penalty | Scaling |
174
- |----------|---------|---------|
175
- | **Critical** | 5 pts | Linear — every instance fully counts |
176
- | **High** | 3 pts | Linear — every instance fully counts |
177
- | **Medium** | 1 pt | Diminishing returns — `log₂(count + 1)` per rule |
178
- | **Low** | 0.5 pts | Diminishing returns — `log₂(count + 1)` per rule |
179
- | **Info** | 0 pts | No penalty |
180
-
181
- **Why diminishing returns?** Having 15 medium issues from the same rule shouldn't crush your score the same as 15 critical issues. The logarithmic curve means the first few instances of a medium/low rule matter, but additional ones have decreasing impact. This keeps the scoring fair while still rewarding cleanup.
182
-
183
- **Example:** 15 medium issues from one rule = **4 points** (not 15). But 5 critical issues = **25 points** (every one counts).
184
-
185
- ---
186
-
187
- ## Web Dashboard
188
-
189
- ViberTest includes a built-in web dashboard for visualizing scan results. Upload a JSON report and get interactive charts, file rankings, and a visual health thermometer.
190
-
191
- <!-- Replace with your actual screenshot -->
192
- <div align="center">
193
- <img src="docs/assets/dashboard.png" alt="ViberTest Web Dashboard" width="800" />
194
- </div>
195
-
196
- ### Features
197
-
198
- - **Health Thermometer** — Vertical segmented gauge showing your score at a glance
199
- - **Severity Breakdown** — Pie chart of issues by severity level
200
- - **Rule Distribution** — Bar chart showing which rules found the most issues
201
- - **File Ranking** — Top problematic files sorted by issue count
202
- - **Scan Metadata** — Project name, scan duration, file count, timestamp
203
-
204
- ### Running the Dashboard Locally
205
-
206
- ```bash
207
- # From the project root
208
- cd packages/web
209
-
210
- # Development mode (with hot reload)
211
- pnpm dev
212
-
213
- # Open http://localhost:3000
214
- ```
215
-
216
- ### How to Use
217
-
218
- 1. **Generate a JSON report** from the CLI:
219
- ```bash
220
- vibertest scan ~/my-project --format json --output report.json
221
- ```
222
-
223
- 2. **Open the dashboard** at `http://localhost:3000`
224
-
225
- 3. **Upload the JSON file** — drag & drop or click to browse
226
-
227
- 4. **Explore the results** — interactive charts, file rankings, and detailed breakdowns
228
-
229
- ### Production Build
230
-
231
- ```bash
232
- cd packages/web
233
- pnpm build
234
- pnpm start
235
- # Dashboard available at http://localhost:3000
236
- ```
237
-
238
- ---
68
+ |:-----:|:-----:|---------|
69
+ | **A** | 90–100 | Excellent |
70
+ | **B** | 75–89 | Good |
71
+ | **C** | 60–74 | Needs Work |
72
+ | **D** | 40–59 | Poor |
73
+ | **F** | 0–39 | Critical |
239
74
 
240
75
  ## Configuration
241
76
 
242
- Create a `.vibertestrc.json` in your project root to customize ViberTest:
243
-
244
77
  ```bash
245
78
  vibertest init
246
79
  ```
247
80
 
248
- ### Default Configuration
81
+ Creates a `.vibertestrc.json` where you can enable/disable rules, set thresholds, and configure ignore patterns:
249
82
 
250
83
  ```jsonc
251
84
  {
252
85
  "rules": {
253
- // Architecture & Structure
254
- "oversized-files": { "enabled": true },
255
- "god-file": { "enabled": true },
256
- "bloated-barrel": { "enabled": true },
257
- "circular-deps": { "enabled": true },
258
- "separation-of-concerns": { "enabled": true },
259
-
260
- // Code Quality
261
- "dead-code": { "enabled": true },
262
- "code-duplication": { "enabled": true },
263
- "poor-maintainability": { "enabled": true },
264
- "missing-error-handling": { "enabled": true },
265
- "missing-tests": { "enabled": true },
266
-
267
- // Style & Patterns
268
- "style-inconsistency": { "enabled": true },
269
- "pattern-inconsistency": { "enabled": true },
270
- "obsolete-patterns": { "enabled": true },
271
-
272
- // Dependencies & Config
273
- "unused-deps": { "enabled": true },
274
- "duplicate-deps": { "enabled": true },
275
- "hardcoded-secrets": { "enabled": true },
276
-
277
- // AI-Specific Smells
278
- "ai-smell": { "enabled": true },
279
- "abandoned-todo": { "enabled": true },
280
-
281
- // Security & Compliance
282
- "security-antipatterns": { "enabled": true },
283
- "missing-compliance": { "enabled": true },
284
- "accessibility": { "enabled": true },
285
-
286
- // Ship-Readiness
287
- "missing-project-standards": { "enabled": true },
288
- "missing-production-basics": { "enabled": true },
289
- "react-performance": { "enabled": false } // Disabled by default (very noisy)
86
+ "react-performance": { "enabled": true },
87
+ "pattern-inconsistency": { "enabled": false }
290
88
  },
291
- "ignore": [
292
- "node_modules", "dist", "build",
293
- ".next", "coverage", ".turbo", ".git"
294
- ],
89
+ "ignore": ["generated", "legacy"],
295
90
  "thresholds": {
296
- "maxFileLines": 300,
297
- "maxFunctionLines": 50,
298
- "maxFunctionParams": 4,
299
- "maxImports": 10,
300
- "minTestRatio": 0.05
301
- }
302
- }
303
- ```
304
-
305
- ### Disabling Rules
306
-
307
- ```jsonc
308
- {
309
- "rules": {
310
- // Disable rules you don't need
311
- "pattern-inconsistency": { "enabled": false },
312
- "style-inconsistency": { "enabled": false }
91
+ "maxFileLines": 500,
92
+ "maxFunctionLines": 60
313
93
  }
314
94
  }
315
95
  ```
316
96
 
317
- ### Custom Thresholds
318
-
319
- ```jsonc
320
- {
321
- "thresholds": {
322
- "maxFileLines": 500, // Allow larger files
323
- "maxFunctionLines": 80, // Allow longer functions
324
- "maxFunctionParams": 5, // Allow more parameters
325
- "maxImports": 15, // Allow more imports
326
- "minTestRatio": 0.1 // Lower test coverage requirement
327
- }
328
- }
329
- ```
330
-
331
- ### Ignoring Files
332
-
333
- ```jsonc
334
- {
335
- "ignore": [
336
- "node_modules", "dist", "build",
337
- "generated", // Skip generated code
338
- "legacy", // Skip legacy modules
339
- "**/*.generated.ts" // Skip generated files
340
- ]
341
- }
342
- ```
343
-
344
- ---
345
-
346
97
  ## CI Integration
347
98
 
348
- ViberTest exits with code **1** when issues are found, making it easy to integrate into CI pipelines:
99
+ Exits with code **1** when issues are found, **0** when clean:
349
100
 
350
101
  ```yaml
351
- # GitHub Actions example
352
102
  - name: Run ViberTest
353
- run: vibertest scan . --format json --output vibertest-report.json
354
- ```
355
-
356
- ```bash
357
- # Or in any CI script
358
- vibertest scan . || echo "ViberTest found issues"
359
- ```
360
-
361
- ---
362
-
363
- ## Project Structure
364
-
365
- ```
366
- vibertest/
367
- ├── packages/
368
- │ ├── cli/ # CLI tool (@vibertest/cli)
369
- │ │ ├── src/
370
- │ │ │ ├── rules/ # 24 analysis rules
371
- │ │ │ ├── scorer/ # Scoring engine with diminishing returns
372
- │ │ │ ├── scanner/ # File collection & orchestration
373
- │ │ │ ├── reporter/ # Terminal & JSON output
374
- │ │ │ └── config/ # Config loading & validation (Zod)
375
- │ │ └── bin/ # CLI entry point
376
- │ ├── shared/ # Shared types & constants (@vibertest/shared)
377
- │ └── web/ # Web Dashboard (@vibertest/web)
378
- │ └── src/
379
- │ ├── app/ # Next.js 15 App Router pages
380
- │ ├── components/ # Dashboard UI components
381
- │ ├── stores/ # Zustand state management
382
- │ └── lib/ # Utilities
383
- ├── docs/ # Specs & design system
384
- ├── turbo.json # Turborepo config
385
- ├── biome.json # Linting & formatting
386
- └── pnpm-workspace.yaml # Monorepo workspace
387
- ```
388
-
389
- ## Tech Stack
390
-
391
- | Package | Stack |
392
- |---------|-------|
393
- | **CLI** | TypeScript, Commander.js, Chalk, Ora, Zod 3, Cosmiconfig |
394
- | **Shared** | TypeScript, tsup |
395
- | **Web** | Next.js 15, React 19, Tailwind CSS 4, Zustand 5, Recharts, Lucide Icons |
396
- | **Tooling** | pnpm workspaces, Turborepo, Biome, Vitest |
397
-
398
- ---
399
-
400
- ## Self-Scan Results
401
-
402
- ViberTest analyzes itself and scores **88/100 (Grade B)** with 24 rules enabled:
403
-
404
- ```
405
- HEALTH SCORE
406
-
407
- ██████╗
408
- ██╔══██╗
409
- ██████╔╝
410
- ██╔══██╗
411
- ██████╔╝
412
- ╚═════╝
413
-
414
- 88/100 ██████████████████████████░░░░ Good
103
+ run: npx vibertest scan . --format json --output vibertest-report.json
415
104
  ```
416
105
 
417
- ---
418
-
419
- ## License
106
+ ## Links
420
107
 
421
- AGPL-3.0 — See [LICENSE](LICENSE) for details.
422
-
423
- ---
424
-
425
- <div align="center">
426
-
427
- **ViberTest** Stop shipping AI slop.
428
-
429
- </div>
108
+ - [Documentation](https://vibertest.chyste.dev/docs)
109
+ - [Report Viewer](https://vibertest.chyste.dev/report)
110
+ - [All 24 Rules](https://vibertest.chyste.dev/docs/rules)
111
+ - [Configuration Guide](https://vibertest.chyste.dev/docs/configuration)
112
+ - [CI Integration](https://vibertest.chyste.dev/docs/ci-integration)
113
+ - [GitHub](https://github.com/Chyste/vibertest)
114
+ - [Issues & Feature Requests](https://github.com/Chyste/vibertest/issues)