aislop 0.1.3 → 0.2.1

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
@@ -3,355 +3,231 @@
3
3
  **Stop AI slop from shipping.**
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/aislop.svg)](https://www.npmjs.com/package/aislop)
6
+ [![npm downloads](https://img.shields.io/npm/dm/aislop.svg)](https://www.npmjs.com/package/aislop)
6
7
  [![CI](https://github.com/heavykenny/aislop/actions/workflows/ci.yml/badge.svg)](https://github.com/heavykenny/aislop/actions/workflows/ci.yml)
7
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+ [![Node >= 20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](https://nodejs.org)
8
10
 
9
- AI coding assistants are fast, but they leave behind a trail of sloppy code: swallowed exceptions, trivial comments that restate the obvious, unused imports, `as any` casts, empty catch blocks, leftover `console.log` calls, and copy-paste duplication. **aislop** catches all of it in one command.
11
+ `aislop` is a unified code-quality CLI that catches the lazy patterns AI coding tools leave behind. One command, one score out of 100.
10
12
 
11
- `aislop` is a unified code-quality CLI for multi-language repositories. It runs formatting, linting, code-quality, AI-pattern, architecture, and security checks behind a single command and summarizes everything as one score out of 100.
13
+ `aislop` helps teams review AI-assisted code faster by combining formatting, linting, maintainability, AI-pattern detection, architecture checks, and security checks into a single report.
12
14
 
13
- ```
14
- $ npx aislop scan
15
-
16
- aislop Scan v0.1.0
17
-
18
- ✓ Project my-app (typescript)
19
- Source files: 142
20
-
21
- ✓ Formatting: done (0 issues)
22
- ✓ Linting: done (2 warnings)
23
- ✓ Code Quality: done (1 warning)
24
- ! Maintainability: done (4 warnings)
25
- ✓ Security: done (0 issues)
26
-
27
- Score: 80/100 (Healthy)
28
- ```
29
-
30
- ---
15
+ ## See it in action
31
16
 
32
- ## Why aislop?
17
+ ### Scan
33
18
 
34
- Code generated by AI assistants often looks correct at first glance but is full of quality issues that pass review because they are spread across dozens of files. No single existing linter catches all of them. `aislop` was built to be the one tool that does:
19
+ ![aislop scan demo](assets/scan.gif)
35
20
 
36
- - **Catches AI-specific patterns** that ESLint and Prettier ignore: trivial comments (`// Import React`), thin wrappers, generic names (`data2`, `helper_1`), swallowed exceptions
37
- - **Multi-language** -- TypeScript, JavaScript, Python, Go, Rust, Ruby, PHP in one CLI
38
- - **Single score** -- one number to gate PRs, track in CI, and trend over time
39
- - **Zero config to start** -- run `npx aislop scan` and get results immediately
40
- - **Batteries included** -- ships with oxlint, biome, and knip; downloads ruff and golangci-lint automatically on install
21
+ ### Fix
41
22
 
42
- ---
23
+ ![aislop fix demo](assets/fix.gif)
43
24
 
44
- ## Installation
45
-
46
- ### Run without installing
25
+ ## Quick start
47
26
 
48
27
  ```bash
28
+ # scan your project
49
29
  npx aislop scan
50
- ```
51
-
52
- ### Install as a dev dependency
53
30
 
54
- ```bash
55
- # npm
56
- npm install --save-dev aislop
57
-
58
- # yarn
59
- yarn add --dev aislop
31
+ # auto-fix what can be fixed safely
32
+ npx aislop fix
60
33
 
61
- # pnpm
62
- pnpm add -D aislop
34
+ # CI mode (JSON output + quality gate)
35
+ npx aislop ci
63
36
  ```
64
37
 
65
- ### Global install
38
+ Sample output:
66
39
 
67
- ```bash
68
- npm install -g aislop
69
- aislop scan
70
- ```
40
+ ```text
41
+ aislop scan v0.2.0
71
42
 
72
- `aislop` ships with Node-based tooling (oxlint, biome, knip) as package dependencies. On install it also downloads bundled binaries for **ruff** and **golangci-lint**. To skip those downloads:
43
+ Project my-app (typescript)
44
+ Source files: 142
73
45
 
74
- ```bash
75
- AISLOP_SKIP_TOOL_DOWNLOAD=1 npm install
46
+ ✓ Formatting: done (0 issues)
47
+ ! Linting: done (2 warnings)
48
+ ! Code Quality: done (1 warning)
49
+ ✓ Maintainability: done (0 issues)
50
+ ✓ Security: done (0 issues)
51
+
52
+ ------------------------------------------------------------
53
+ Summary
54
+ Score: 89/100 (Healthy)
55
+ Issues: 0 errors, 3 warnings
56
+ Auto-fixable: 2
57
+ Files: 142
58
+ Time: 2.3s
59
+ ------------------------------------------------------------
76
60
  ```
77
61
 
78
- Some checks depend on tools already present on your machine: `gofmt`, `govulncheck`, `cargo`, `rubocop`, `phpcs`, `php-cs-fixer`. Run `aislop doctor` to see what is available.
79
-
80
62
  ---
81
63
 
82
- ## Quick start
64
+ ## Why aislop
83
65
 
84
- ```bash
85
- # Scan the current directory
86
- npx aislop scan
66
+ AI-generated changes often pass review because problems are spread across many files and many categories.
67
+ `aislop` gives you one view and one score.
87
68
 
88
- # Auto-fix formatting and lint issues
89
- npx aislop fix
69
+ - **One command, full picture**: formatting + lint + maintainability + AI slop + security (+ architecture)
70
+ - **Score-based quality gate**: use a single 0-100 score in CI and PR checks
71
+ - **Auto-fix support**: remove unused imports, apply lint suggestions, and format in one pass
72
+ - **Duplication visibility**: flag repeated blocks and encourage extraction into shared modules
73
+ - **Software engineering best practices**: enforce function/file size limits, nesting limits, dead code cleanup, and safer patterns
74
+ - **Works across stacks**: TypeScript, JavaScript, Python, Go, Rust, Ruby, PHP, Expo/React Native
75
+ - **Zero-config start**: run `npx aislop scan` and get useful output immediately
90
76
 
91
- # Scan only changed files (great for pre-commit)
92
- npx aislop scan --changes
77
+ ## What it catches
93
78
 
94
- # Scan only staged files
95
- npx aislop scan --staged
79
+ Six engines run in parallel: **Formatting**, **Linting**, **Code Quality**, **AI Slop Detection**, **Security**, and **Architecture** (opt-in).
96
80
 
97
- # CI-friendly JSON output
98
- npx aislop ci
99
-
100
- # Initialize config files
101
- npx aislop init
81
+ | Engine | Examples |
82
+ |---|---|
83
+ | Formatting | Biome, ruff, gofmt, cargo fmt, rubocop, php-cs-fixer |
84
+ | Linting | oxlint, ruff, golangci-lint, clippy, expo-doctor |
85
+ | Code Quality | Function/file size limits, deep nesting, duplication, dead code, unused dependencies (knip) |
86
+ | AI Slop | Trivial comments, swallowed exceptions, unused imports, console leftovers, type assertion abuse, TODO stubs |
87
+ | Security | Hardcoded secrets, eval, innerHTML, SQL/shell injection, dependency audits |
88
+ | Architecture | Custom import bans, layering rules, required patterns |
102
89
 
103
- # Interactive menu
104
- npx aislop
105
- ```
90
+ See the full [rules reference](docs/rules.md).
106
91
 
107
92
  ---
108
93
 
109
- ## Commands
110
-
111
- | Command | What it does |
112
- |---|---|
113
- | `aislop` | Interactive TTY menu (falls back to `scan` in non-TTY) |
114
- | `aislop scan [dir]` | Run all enabled engines and print a scored report |
115
- | `aislop fix [dir]` | Apply safe auto-fixes (formatting + lint) |
116
- | `aislop ci [dir]` | Output JSON for CI pipelines |
117
- | `aislop init [dir]` | Create `.aislop/config.yml` and `.aislop/rules.yml` |
118
- | `aislop doctor [dir]` | Report which tools are installed and available |
119
- | `aislop rules [dir]` | List all built-in and configured rules |
120
-
121
- ### Flags
94
+ ## Installation
122
95
 
123
- | Flag | Description |
124
- |---|---|
125
- | `--changes` | Only scan files changed from `HEAD` |
126
- | `--staged` | Only scan staged files |
127
- | `-d, --verbose` | Show detailed per-file output |
128
- | `--json` | Output JSON instead of terminal UI |
129
- | `-v, --version` | Print version |
96
+ ```bash
97
+ # Run without installing
98
+ npx aislop scan
130
99
 
131
- ---
100
+ # npm
101
+ npm install --save-dev aislop
132
102
 
133
- ## What it catches
103
+ # yarn
104
+ yarn add --dev aislop
134
105
 
135
- `aislop` groups checks into six engines. Each engine runs in parallel for speed.
106
+ # pnpm
107
+ pnpm add -D aislop
136
108
 
137
- ### Formatting
109
+ # Global
110
+ npm install -g aislop
111
+ ```
138
112
 
139
- Enforces consistent formatting using the best tool for each language.
113
+ Also available as [`@heavykenny/aislop`](docs/installation.md) on GitHub Packages.
140
114
 
141
- | Language | Tool |
142
- |---|---|
143
- | TypeScript / JavaScript | Biome |
144
- | Python | ruff format |
145
- | Go | gofmt |
146
- | Rust | cargo fmt |
147
- | Ruby | rubocop |
148
- | PHP | php-cs-fixer |
115
+ ---
149
116
 
150
- ### Linting
117
+ ## Usage
151
118
 
152
- Catches bugs and bad practices.
119
+ ### Scan your project
153
120
 
154
- | Language | Tool |
155
- |---|---|
156
- | TypeScript / JavaScript | oxlint (bundled, with React/Next.js awareness) |
157
- | Python | ruff |
158
- | Go | golangci-lint |
159
- | Rust | clippy |
160
- | Ruby | rubocop |
121
+ ```bash
122
+ aislop scan # scan current directory
123
+ aislop scan ./src # scan a specific directory
124
+ aislop scan --changes # only files changed from HEAD
125
+ aislop scan --staged # only staged files (pre-commit)
126
+ aislop scan --json # output JSON
127
+ ```
161
128
 
162
- ### Code quality
129
+ ### Fix issues automatically
163
130
 
164
- Measures structural complexity and finds dead code.
131
+ ```bash
132
+ aislop fix # auto-fix unused imports, formatting, and lint fixes
133
+ ```
165
134
 
166
- | Rule | What it checks |
167
- |---|---|
168
- | `complexity/function-too-long` | Functions exceeding configurable line limit (default: 80) |
169
- | `complexity/file-too-large` | Files exceeding configurable line limit (default: 400) |
170
- | `complexity/deep-nesting` | Control-flow nesting beyond threshold (default: 5) |
171
- | `complexity/too-many-params` | Functions with too many parameters (default: 6) |
172
- | `duplication/block` | Cross-file duplicate code blocks (12+ lines) |
173
- | `knip/files`, `knip/exports`, `knip/types` | Dead code via knip (JS/TS) |
174
-
175
- ### AI slop detection (Maintainability)
176
-
177
- The rules that make aislop unique. These catch the patterns AI assistants leave behind.
178
-
179
- | Rule | Severity | What it catches |
180
- |---|---|---|
181
- | `ai-slop/trivial-comment` | warning | Comments restating the code (`// Import React`, `// Return the value`) |
182
- | `ai-slop/swallowed-exception` | error | Empty catch blocks, catch blocks that only log (JS/TS/Python/Go/Ruby/Java) |
183
- | `ai-slop/thin-wrapper` | warning | Functions that only delegate to another function |
184
- | `ai-slop/generic-naming` | info | AI-generated names: `helper_1`, `data2`, `temp1` |
185
- | `ai-slop/unused-import` | warning | Unused imports (JS/TS and Python) |
186
- | `ai-slop/console-leftover` | warning | `console.log`/`debug`/`info` left in production code |
187
- | `ai-slop/todo-stub` | info | Unresolved TODO/FIXME/HACK comments |
188
- | `ai-slop/unreachable-code` | warning | Code after `return`/`throw` statements |
189
- | `ai-slop/constant-condition` | warning | `if (true)`, `if (false)`, `if (0)` |
190
- | `ai-slop/empty-function` | info | Empty function bodies |
191
- | `ai-slop/unsafe-type-assertion` | warning | `as any` in TypeScript |
192
- | `ai-slop/double-type-assertion` | warning | `as unknown as X` pattern |
193
- | `ai-slop/ts-directive` | info | `@ts-ignore` / `@ts-expect-error` usage |
194
-
195
- ### Security
196
-
197
- Finds secrets, risky constructs, and vulnerable dependencies.
198
-
199
- | Rule | What it catches |
200
- |---|---|
201
- | `security/hardcoded-secret` | API keys, AWS credentials, JWT tokens, database URLs, passwords |
202
- | `security/eval` | `eval()` usage (JS/TS/Python/Ruby/PHP) |
203
- | `security/innerhtml` | `.innerHTML` and `dangerouslySetInnerHTML` |
204
- | `security/sql-injection` | String concatenation in SQL queries |
205
- | `security/shell-injection` | User input in command execution |
206
- | `security/vulnerable-dependency` | npm/pip/cargo/go dependency audit |
135
+ ### Use in CI pipelines
207
136
 
208
- ### Architecture (opt-in)
137
+ ```bash
138
+ aislop ci # JSON output, exits 1 if score < threshold
139
+ ```
209
140
 
210
- Custom import and path rules defined in `.aislop/rules.yml`.
141
+ ### Common workflow
211
142
 
212
- | Rule type | Example |
213
- |---|---|
214
- | `forbid_import` | Ban `axios` project-wide |
215
- | `forbid_import_from_path` | Controllers cannot import database modules |
216
- | `require_pattern` | Require error handling in API routes |
143
+ ```bash
144
+ # before commit
145
+ aislop scan --staged
217
146
 
218
- ---
147
+ # during local cleanup
148
+ aislop fix
219
149
 
220
- Every diagnostic contributes a weighted penalty:
150
+ # full project check
151
+ aislop scan
152
+ ```
221
153
 
222
- | Severity | Penalty |
223
- |---|---|
224
- | Error | 3.0 |
225
- | Warning | 1.0 |
226
- | Info | 0.25 |
154
+ ### Other commands
227
155
 
228
- Penalties are multiplied by engine weight (configurable, security defaults to 2x). The final score uses logarithmic scaling with issue-density normalization (relative to source file count), so a few issues still matter but a single finding in an otherwise clean project remains proportional.
156
+ ```bash
157
+ aislop init # create .aislop/config.yml
158
+ aislop doctor # check which tools are available
159
+ aislop rules # list all built-in rules
160
+ aislop # interactive menu
161
+ ```
229
162
 
230
- | Score | Label |
231
- |---|---|
232
- | 75 -- 100 | Healthy |
233
- | 50 -- 74 | Needs Work |
234
- | 0 -- 49 | Critical |
163
+ See [all commands and flags](docs/commands.md).
235
164
 
236
165
  ---
237
166
 
238
- ## Configuration
167
+ ## Use in your project
239
168
 
240
- Run `aislop init` to generate `.aislop/config.yml`:
241
-
242
- ```yaml
243
- version: 1
244
-
245
- engines:
246
- format: true
247
- lint: true
248
- code-quality: true
249
- ai-slop: true
250
- architecture: false # opt-in, needs rules.yml
251
- security: true
252
-
253
- quality:
254
- maxFunctionLoc: 80
255
- maxFileLoc: 400
256
- maxNesting: 5
257
- maxParams: 6
258
-
259
- security:
260
- audit: true
261
- auditTimeout: 25000
262
-
263
- scoring:
264
- weights:
265
- format: 0.5
266
- lint: 1.0
267
- code-quality: 1.5
268
- ai-slop: 1.0
269
- architecture: 1.0
270
- security: 2.0
271
- thresholds:
272
- good: 75
273
- ok: 50
169
+ ### Pre-commit hook
274
170
 
275
- ci:
276
- failBelow: 0 # set to e.g. 70 to fail CI below that score
277
- format: json
171
+ ```bash
172
+ npx aislop scan --staged
278
173
  ```
279
174
 
280
- ---
281
-
282
- ## CI / CD
283
-
284
175
  ### GitHub Actions
285
176
 
286
177
  ```yaml
287
- - uses: actions/setup-node@v4
178
+ - uses: actions/setup-node@v6
288
179
  with:
289
180
  node-version: 20
290
-
181
+ - run: npm ci
291
182
  - run: npx aislop ci
292
183
  ```
293
184
 
294
- ### Fail below a score threshold
185
+ ### Quality gate
295
186
 
296
- Set `ci.failBelow` in `.aislop/config.yml`:
187
+ Set a minimum score in `.aislop/config.yml`:
297
188
 
298
189
  ```yaml
299
190
  ci:
300
191
  failBelow: 70
301
192
  ```
302
193
 
303
- `aislop ci` exits with code 1 when the score is below the threshold.
304
-
305
- ### Pre-commit hook
306
-
307
- ```bash
308
- npx aislop scan --staged
309
- ```
194
+ `aislop ci` exits with code 1 when the score drops below the threshold. See [CI/CD docs](docs/ci.md) for more.
310
195
 
311
196
  ---
312
197
 
313
- ## Supported languages
198
+ ## Documentation
314
199
 
315
- | Language | Format | Lint | Code quality | AI slop | Security |
316
- |---|---|---|---|---|---|
317
- | TypeScript | Biome | oxlint | knip, complexity | All rules | All rules |
318
- | JavaScript | Biome | oxlint | knip, complexity | All rules | All rules |
319
- | Python | ruff | ruff | complexity | Imports, exceptions, comments | Secrets, audit |
320
- | Go | gofmt | golangci-lint | complexity | Exceptions, comments | Secrets, audit |
321
- | Rust | cargo fmt | clippy | complexity | Comments | Secrets, audit |
322
- | Ruby | rubocop | rubocop | complexity | Exceptions, comments | Secrets |
323
- | PHP | php-cs-fixer | -- | complexity | Comments | Secrets |
200
+ | Topic | Link |
201
+ |---|---|
202
+ | Installation | [docs/installation.md](docs/installation.md) |
203
+ | Commands & flags | [docs/commands.md](docs/commands.md) |
204
+ | Rules reference | [docs/rules.md](docs/rules.md) |
205
+ | Configuration | [docs/configuration.md](docs/configuration.md) |
206
+ | Scoring | [docs/scoring.md](docs/scoring.md) |
207
+ | CI / CD | [docs/ci.md](docs/ci.md) |
208
+ | Telemetry | [docs/telemetry.md](docs/telemetry.md) |
324
209
 
325
210
  ---
326
211
 
327
- ## Telemetry
328
-
329
- `aislop` collects anonymous usage analytics to help us understand how the tool is used and prioritize improvements. **No code, file paths, project names, or secrets are ever collected.**
330
-
331
- What we collect: command run (scan/fix/ci), languages detected, score bucket, issue counts per engine, engine timing, OS, Node version, and aislop version.
332
-
333
- Telemetry is **off in CI** by default. To opt out anywhere:
334
-
335
- ```bash
336
- # Environment variable (any of these)
337
- AISLOP_NO_TELEMETRY=1 aislop scan
338
- DO_NOT_TRACK=1 aislop scan
212
+ ## Contributing
339
213
 
340
- # Or in .aislop/config.yml
341
- telemetry:
342
- enabled: false
343
- ```
214
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and how to add new rules. AI coding assistants can find project context in [AGENTS.md](AGENTS.md).
344
215
 
345
- ---
216
+ ## Acknowledgments
346
217
 
347
- ## Contributing
218
+ `aislop` is built on top of excellent open-source projects:
348
219
 
349
- See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, project architecture, and how to add new rules or engines.
220
+ - [Biome](https://biomejs.dev/) formatting and linting for JS/TS
221
+ - [oxlint](https://oxc.rs/) — fast JavaScript/TypeScript linter
222
+ - [knip](https://knip.dev/) — unused files, exports, and dependencies
223
+ - [ruff](https://docs.astral.sh/ruff/) — Python linting and formatting
224
+ - [golangci-lint](https://golangci-lint.run/) — Go linting
225
+ - [expo-doctor](https://docs.expo.dev/) — Expo/React Native project health
350
226
 
351
- ## Security
227
+ ## Contributors
352
228
 
353
- See [SECURITY.md](SECURITY.md) for reporting vulnerabilities.
229
+ [![Contributors](https://contrib.rocks/image?repo=heavykenny/aislop)](https://github.com/heavykenny/aislop/graphs/contributors)
354
230
 
355
231
  ## License
356
232
 
357
- [MIT](LICENSE) -- see the [LICENSE](LICENSE) file.
233
+ [MIT](LICENSE)