@aiready/consistency 0.8.29 → 0.8.30

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/consistency@0.8.29 build /Users/pengcao/projects/aiready/packages/consistency
3
+ > @aiready/consistency@0.8.30 build /Users/pengcao/projects/aiready/packages/consistency
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,15 +9,15 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/index.js 55.56 KB
13
- CJS dist/cli.js 50.90 KB
14
- CJS ⚡️ Build success in 245ms
15
12
  ESM dist/index.mjs 12.92 KB
16
- ESM dist/chunk-YEHXYHGY.mjs 40.95 KB
17
13
  ESM dist/cli.mjs 8.76 KB
18
- ESM ⚡️ Build success in 239ms
14
+ ESM dist/chunk-YEHXYHGY.mjs 40.95 KB
15
+ ESM ⚡️ Build success in 168ms
16
+ CJS dist/cli.js 50.90 KB
17
+ CJS dist/index.js 55.56 KB
18
+ CJS ⚡️ Build success in 205ms
19
19
  DTS Build start
20
- DTS ⚡️ Build success in 11399ms
20
+ DTS ⚡️ Build success in 9020ms
21
21
  DTS dist/cli.d.ts 20.00 B
22
22
  DTS dist/index.d.ts 3.41 KB
23
23
  DTS dist/cli.d.mts 20.00 B
@@ -1,22 +1,24 @@
1
1
 
2
2
  
3
- > @aiready/consistency@0.8.29 test /Users/pengcao/projects/aiready/packages/consistency
3
+ > @aiready/consistency@0.8.30 test /Users/pengcao/projects/aiready/packages/consistency
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/consistency
8
8
 
9
9
  ✓ dist/__tests__/scoring.test.js (8 tests) 3ms
10
- ✓ src/__tests__/language-filter.test.ts (3 tests) 7ms
11
- ✓ dist/__tests__/language-filter.test.js (3 tests) 3ms
12
- ✓ src/__tests__/scoring.test.ts (8 tests) 4ms
13
- ✓ src/__tests__/analyzer.test.ts (18 tests) 722ms
14
- ✓ should analyze naming issues  363ms
15
- ✓ dist/__tests__/analyzer.test.js (18 tests) 582ms
10
+ ✓ src/__tests__/scoring.test.ts (8 tests) 7ms
11
+ ✓ src/__tests__/language-filter.test.ts (3 tests) 5ms
12
+ ✓ dist/__tests__/language-filter.test.js (3 tests) 4ms
13
+ ✓ dist/__tests__/analyzer.test.js (18 tests) 1061ms
14
+ ✓ should analyze naming issues  494ms
15
+ ✓ should detect minimum severity filtering  372ms
16
+ ✓ src/__tests__/analyzer.test.ts (18 tests) 1009ms
17
+ ✓ should analyze naming issues  673ms
16
18
 
17
19
   Test Files  6 passed (6)
18
20
   Tests  58 passed (58)
19
-  Start at  22:34:02
20
-  Duration  1.92s (transform 874ms, setup 0ms, import 4.31s, tests 1.32s, environment 83ms)
21
+  Start at  13:04:30
22
+  Duration  4.31s (transform 3.85s, setup 0ms, import 13.17s, tests 2.09s, environment 4ms)
21
23
 
22
24
  [?25h
package/README.md CHANGED
@@ -1,8 +1,13 @@
1
1
  # @aiready/consistency
2
2
 
3
- > **Detect consistency issues in naming, patterns, and architecture that confuse AI models**
3
+ > AIReady Spoke: Scans for naming violations, architectural drift, and pattern mismatches that confuse AI agents.
4
4
 
5
- Helps teams maintain consistent coding practices across their codebase, making it easier for AI tools to understand and work with your code.
5
+ [![npm version](https://img.shields.io/npm/v/@aiready/consistency.svg)](https://npmjs.com/package/@aiready/consistency)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Overview
9
+
10
+ Consistent naming and project structure are the bedrock of high-performing AI teams. The **Consistency** analyzer scans your project for naming violations, architectural drift, and pattern mismatches that slow down AI agents.
6
11
 
7
12
  ## 🏛️ Architecture
8
13
 
@@ -10,349 +15,42 @@ Helps teams maintain consistent coding practices across their codebase, making i
10
15
  🎯 USER
11
16
 
12
17
 
13
- 🎛️ CLI (orchestrator)
14
-
15
- ┌─────────────────┴─────────────────┐
16
- │ │
17
- ▼ ▼
18
- ┌────────┐ ┌────────┐
19
- │🎨 VIS- │ ANALY- │
20
- │UALIZER │ │ SIS │
21
- │✅ Ready│ │ SPOKES │
22
- └────────┘ └───┬────┘
23
- │ │
24
- │ ┌─────────────────────┼─────────────────────┐
25
- │ ▼ ▼ ▼
26
- │ ┌────────┐ ┌────────┐ ┌────────┐
27
- │ │📊 PAT- │ │📦 CON- │ │🔧 CON- │
28
- │ │TERN │ │TEXT │ │SISTENCY│
29
- │ │DETECT │ │ANALYZER│ │ │
30
- │ │ │ │ │ │ │
31
- │ │✅ Ready│ │✅ Ready│ │✅ Ready│
32
- │ └────────┘ └────────┘ └────────┘
33
- │ │
34
- │ ← YOU ARE HERE ──────┘
35
- │ │
36
- └───────────────────────────────────────────────────────┘
37
-
38
-
39
- 🏢 HUB (@aiready/core)
40
- ```
41
-
42
- ## 🌍 Language Support
43
-
44
- **Currently Supported (64% market coverage):**
45
- - ✅ **TypeScript** (`.ts`, `.tsx`) - camelCase, PascalCase conventions
46
- - ✅ **JavaScript** (`.js`, `.jsx`) - camelCase, PascalCase conventions
47
- - ✅ **Python** (`.py`) - PEP 8 conventions (snake_case, PascalCase, UPPER_CASE)
48
-
49
- **Roadmap:**
50
- - 🔜 **Java** (Q3 2026) - Java naming conventions, JavaBean patterns
51
- - 🔜 **Go** (Q4 2026) - Go naming conventions, exported names
52
- - 🔜 **Rust** (Q4 2026) - Rust naming conventions, snake_case
53
- - 🔜 **C#** (Q1 2027) - C# conventions, PascalCase
54
-
55
- ## 🚀 Quick Start
56
-
57
- **Zero config, works out of the box:**
58
-
59
- ```bash
60
- # Run without installation (recommended)
61
- npx @aiready/consistency ./src
18
+ 🎛️ @aiready/cli (orchestrator)
19
+ │ │ │ │ │ │ │ │
20
+ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼
21
+ [PAT] [CTX] [CON] [AMP] [DEP] [DOC] [SIG] [AGT] [TST]
22
+ │ │ │ │ │ │ │ │ │
23
+ └─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘
24
+
25
+
26
+ 🏢 @aiready/core
62
27
 
63
- # Or use the unified CLI (includes all AIReady tools)
64
- npx @aiready/cli scan ./src
65
-
66
- # Or install globally for simpler command and faster runs
67
- npm install -g @aiready/consistency
68
- aiready-consistency ./src
69
- ```
70
-
71
- ### 🎯 Input & Output
72
-
73
- **Input:** Path to your source code directory
74
- ```bash
75
- aiready-consistency ./src
28
+ Legend:
29
+ PAT = pattern-detect CTX = context-analyzer
30
+ CON = consistency ★ AMP = change-amplification
31
+ DEP = deps-health DOC = doc-drift
32
+ SIG = ai-signal-clarity AGT = agent-grounding
33
+ TST = testability ★ = YOU ARE HERE
76
34
  ```
77
35
 
78
- **Output:** Terminal report + optional JSON file (saved to `.aiready/` directory)
79
- ```
80
- 📊 Consistency Analysis
81
- ━━━━━━━━━━━━━━━━━━━━━━━━
82
- 📁 Files analyzed: 47
83
- ⚠️ Issues found: 15 naming + 8 pattern issues
84
-
85
- CRITICAL (2 files)
86
- src/utils/helpers.ts:12 - poor-naming: x
87
- src/api/users.ts:45 - convention-mix: user_name
88
- ```
89
-
90
- ### ✨ Smart Defaults (Zero Config)
91
-
92
- - ✅ **Auto-excludes** test files (`**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`)
93
- - ✅ **Auto-excludes** build outputs (`dist/`, `build/`, `.next/`)
94
- - ✅ **Auto-excludes** dependencies (`node_modules/`)
95
- - ✅ **Context-aware**: Skips common iterators (i, j, k) in loops
96
- - ✅ **100+ built-in** acceptable abbreviations (env, api, url, ctx, etc.)
97
- - ✅ **Smart detection**: Recognizes arrow functions, factory patterns, callbacks
98
-
99
- > Override defaults with `--include-tests` or `--exclude <patterns>` as needed
100
-
101
- ## 🎯 What It Does
102
-
103
- Inconsistent code patterns confuse AI models and reduce their effectiveness. This tool analyzes:
104
-
105
- ### 🔧 Language Support
106
-
107
- **Fully Supported:**
108
- - TypeScript (`.ts`, `.tsx`)
109
- - JavaScript (`.js`, `.jsx`)
110
-
111
- **Not Yet Supported:**
112
- - Python (`.py`) - Files will be skipped
113
- - Java (`.java`) - Files will be skipped
114
- - Other languages - Files will be skipped
115
-
116
- If you see "Failed to parse" warnings for non-JS/TS files, this is expected behavior and won't affect the analysis of your JavaScript/TypeScript code.
117
-
118
- ### 🏷️ Naming Quality & Conventions
119
- - **Single-letter variables** - Detects unclear variable names (skips common iterators: i, j, k, l, x, y, z in appropriate contexts)
120
- - **Abbreviations** - Identifies unclear abbreviations while allowing 60+ standard ones (env, req, res, ctx, max, min, etc.)
121
- - **Mixed naming conventions** - Detects snake_case in TypeScript/JavaScript projects (should use camelCase)
122
- - **Boolean naming** - Ensures booleans use clear prefixes (is/has/can/should)
123
- - **Function naming** - Checks for action verbs while allowing factory patterns and descriptive names
124
-
125
- **Smart Detection:** The tool understands context and won't flag:
126
- - Common abbreviations (env, api, url, max, min, now, etc.) - 100+ built-in
127
- - Boolean prefixes (is, has, can used as variables)
128
- - Loop iterators (i, j, k) in appropriate contexts
129
- - Arrow function parameters in callbacks (`.map(s => ...)`)
130
- - Multi-line arrow functions (detects across 3-5 line context)
131
- - Short-lived comparison variables (used within 5 lines)
132
- - Factory/builder patterns
133
- - Long descriptive function names
134
- - Project-specific abbreviations via configuration
135
-
136
- ### 🔄 Pattern Consistency
137
- - **Error handling strategies** - Detects mixed approaches (try-catch vs returns vs throws)
138
- - **Async patterns** - Identifies mixing of async/await, promises, and callbacks
139
- - **Import styles** - Flags mixing of ES modules and CommonJS
140
- - **API design patterns** - Ensures consistent patterns across endpoints
141
-
142
- ### 🏗️ Architectural Consistency *(coming soon)*
143
- - File organization patterns
144
- - Module structure
145
- - Export/import patterns
146
-
147
- ## 📊 Example Output
148
-
149
- ```
150
- 📊 Summary
151
-
152
- Files Analyzed: 47
153
- Total Issues: 23
154
- Naming: 15
155
- Patterns: 8
156
- Architecture: 0
157
-
158
- 🏷️ Naming Issues
159
-
160
- MINOR src/utils/helpers.ts:12
161
- poor-naming: x
162
- → Use descriptive variable name instead of single letter 'x'
163
-
164
- MINOR src/components/User.ts:45
165
- convention-mix: user_name
166
- → Use camelCase 'userName' instead of snake_case in TypeScript/JavaScript
167
-
168
- 🔄 Pattern Issues
169
-
170
- MAJOR multiple files
171
- Inconsistent error handling strategies across codebase
172
- → Standardize error handling strategy (prefer try-catch with typed errors)
36
+ ## Features
173
37
 
174
- 💡 Recommendations
38
+ - **Naming Conventions**: Enforces consistent naming for files, classes, and variables.
39
+ - **Architectural Guardrails**: Ensures components stay within their defined layer (e.g., spokes don't import from other spokes).
40
+ - **Pattern Matcher**: Detects if new code follows established project patterns.
175
41
 
176
- 1. Standardize naming conventions: Found 7 snake_case variables in TypeScript
177
- 2. Improve variable naming: Found 8 single-letter or unclear variable names
178
- 3. Use async/await consistently instead of mixing with promise chains
179
- ```
180
-
181
- ## ⚙️ Usage
42
+ ## Installation
182
43
 
183
44
  ```bash
184
- # Full analysis
185
- aiready-consistency ./src
186
-
187
- # Skip naming checks
188
- aiready-consistency ./src --no-naming
189
-
190
- # Skip pattern checks
191
- aiready-consistency ./src --no-patterns
192
-
193
- # Show only major issues
194
- aiready-consistency ./src --min-severity major
195
-
196
- # Export to JSON (saved to .aiready/ by default)
197
- aiready-consistency ./src --output json
198
-
199
- # Export to Markdown (saved to .aiready/ by default)
200
- aiready-consistency ./src --output markdown
201
-
202
- # Or specify custom paths
203
- aiready-consistency ./src --output json --output-file custom-report.json
204
- aiready-consistency ./src --output markdown --output-file custom-report.md
45
+ pnpm add @aiready/consistency
205
46
  ```
206
47
 
207
- > **📁 Output Files:** By default, all output files are saved to the `.aiready/` directory in your project root with timestamped filenames. You can override this with `--output-file`.
208
-
209
- ## 🎛️ Options
210
-
211
- | Option | Description | Default |
212
- |--------|-------------|---------|
213
- | `--naming` | Enable naming analysis | `true` |
214
- | `--no-naming` | Skip naming analysis | - |
215
- | `--patterns` | Enable pattern analysis | `true` |
216
- | `--no-patterns` | Skip pattern analysis | - |
217
- | `--min-severity` | Minimum severity: info\|minor\|major\|critical | `info` |
218
- | `--include` | File patterns to include | All files |
219
- | `--exclude` | File patterns to exclude | - |
220
- | `--output` | Output format: console\|json\|markdown | `console` |
221
- | `--output-file` | Output file path | - |
222
-
223
- ## 📝 Configuration File
224
-
225
- Create `.airreadyrc.json`, `aiready.json`, or `aiready.config.json` in your project root:
226
-
227
- ```json
228
- {
229
- "scan": {
230
- "include": ["src/**/*.{ts,tsx,js,jsx}"],
231
- "exclude": ["**/dist/**", "**/node_modules/**"]
232
- },
233
- "tools": {
234
- "consistency": {
235
- "checkNaming": true,
236
- "checkPatterns": true,
237
- "minSeverity": "minor",
238
- "acceptedAbbreviations": ["ses", "gst", "cdk"],
239
- "shortWords": ["oak", "elm"],
240
- "disableChecks": []
241
- }
242
- },
243
- "output": {
244
- "format": "console"
245
- }
246
- }
247
- ```
248
-
249
- **Configuration Options:**
250
-
251
- | Option | Type | Default | Description |
252
- |--------|------|---------|-------------|
253
- | `checkNaming` | boolean | `true` | Check naming conventions |
254
- | `checkPatterns` | boolean | `true` | Check code pattern consistency |
255
- | `minSeverity` | string | `'info'` | Filter: `'info'`, `'minor'`, `'major'`, `'critical'` |
256
- | `acceptedAbbreviations` | string[] | `[]` | Custom abbreviations to accept (e.g., domain-specific terms) |
257
- | `shortWords` | string[] | `[]` | Additional full English words to accept |
258
- | `disableChecks` | string[] | `[]` | Disable specific checks: `'single-letter'`, `'abbreviation'`, `'convention-mix'`, `'unclear'`, `'poor-naming'` |
259
-
260
- ### Project-Specific Configuration Examples
261
-
262
- **React/Next.js Projects:**
263
- ```json
264
- {
265
- "tools": {
266
- "consistency": {
267
- "acceptedAbbreviations": ["jsx", "tsx", "ref", "ctx", "req", "res"]
268
- }
269
- }
270
- }
271
- ```
272
-
273
- **AWS/Cloud Projects:**
274
- ```json
275
- {
276
- "tools": {
277
- "consistency": {
278
- "acceptedAbbreviations": ["ses", "sns", "sqs", "ec2", "vpc", "iam"]
279
- }
280
- }
281
- }
282
- ```
48
+ ## Usage
283
49
 
284
- **E-commerce Projects:**
285
- ```json
286
- {
287
- "tools": {
288
- "consistency": {
289
- "acceptedAbbreviations": ["gst", "vat", "sku", "upc"],
290
- "shortWords": ["tax", "buy", "pay", "cart"]
291
- }
292
- }
293
- }
294
- ```
295
-
296
- ### Acceptable Abbreviations
297
-
298
- The tool recognizes 100+ standard abbreviations and won't flag them:
299
-
300
- **Web/Network:** url, uri, api, cdn, dns, ip, http, utm, seo, xhr, cors, ws, wss
301
- **Data:** json, xml, yaml, csv, html, css, svg, pdf, dto, dao
302
- **System:** env, os, fs, cli, tmp, src, dst, bin, lib, pkg
303
- **Request/Response:** req, res, ctx, err, msg
304
- **Math:** max, min, avg, sum, abs, cos, sin, log, sqrt
305
- **Time:** now, utc, ms, sec, hr, yr, mo
306
- **Loop Counters:** i, j, k, n, m
307
- **Cloud/Infrastructure:** s3, ec2, sqs, sns, vpc, ami, iam, aws
308
- **Common:** id, uid, db, sql, orm, ui, ux, dom, ref, val, str, obj, arr, cfg, init
309
-
310
- See [naming.ts](src/analyzers/naming.ts) for the complete list.
311
-
312
- ## 🔧 Programmatic API
313
-
314
- ```typescript
315
- import { analyzeConsistency } from '@aiready/consistency';
316
-
317
- const report = await analyzeConsistency({
318
- rootDir: './src',
319
- checkNaming: true,
320
- checkPatterns: true,
321
- minSeverity: 'minor'
322
- });
323
-
324
- console.log(`Found ${report.summary.totalIssues} issues`);
50
+ ```bash
51
+ aiready scan . --tools consistency
325
52
  ```
326
53
 
327
- ## 🤝 Why This Matters for AI
328
-
329
- AI models work best with consistent codebases because:
330
-
331
- 1. **Pattern Recognition**: Consistent patterns help AI understand your coding style
332
- 2. **Context Efficiency**: Less variation = more useful code fits in context window
333
- 3. **Accurate Suggestions**: AI can predict conventions and follow them
334
- 4. **Reduced Errors**: AI makes fewer mistakes with clear, consistent patterns
335
-
336
- ## 📦 Integration with AIReady
337
-
338
- This tool is part of the [AIReady](https://getaiready.dev) ecosystem:
339
-
340
- **Related packages:**
341
- - [**@aiready/cli**](https://www.npmjs.com/package/@aiready/cli) - Unified interface for all analysis tools
342
- - [**@aiready/pattern-detect**](https://www.npmjs.com/package/@aiready/pattern-detect) - Semantic duplicate detection
343
- - [**@aiready/context-analyzer**](https://www.npmjs.com/package/@aiready/context-analyzer) - Context window cost analysis
344
- - **@aiready/context-analyzer** - Context window cost analysis
345
- - **@aiready/consistency** - Consistency analysis (this tool)
346
-
347
- ## 📖 Documentation
348
-
349
- - [Contributing Guide](./CONTRIBUTING.md)
350
- - [AIReady Website](https://getaiready.dev)
351
-
352
- ## 🌐 Visit Our Website
353
-
354
- **Try AIReady tools online and maintain code consistency:** [getaiready.dev](https://getaiready.dev)
355
-
356
- ## 📄 License
54
+ ## License
357
55
 
358
- MIT © AIReady Team
56
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/consistency",
3
- "version": "0.8.29",
3
+ "version": "0.8.30",
4
4
  "description": "Detects consistency issues in naming, patterns, and architecture that confuse AI models",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -43,7 +43,7 @@
43
43
  "@typescript-eslint/typescript-estree": "^8.53.0",
44
44
  "chalk": "^5.3.0",
45
45
  "commander": "^14.0.0",
46
- "@aiready/core": "0.9.30"
46
+ "@aiready/core": "0.9.31"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^24.0.0",