@aiready/pattern-detect 0.9.8 → 0.9.10
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 +35 -5
- package/dist/cli.js +5 -4
- package/dist/cli.mjs +5 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,20 +6,50 @@ Finds semantically similar but syntactically different code patterns that waste
|
|
|
6
6
|
|
|
7
7
|
## 🚀 Quick Start
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**Zero config, works out of the box:**
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
13
|
-
aiready
|
|
12
|
+
# Run without installation (recommended)
|
|
13
|
+
npx @aiready/pattern-detect ./src
|
|
14
|
+
|
|
15
|
+
# Or use the unified CLI (includes all AIReady tools)
|
|
16
|
+
npx @aiready/cli scan ./src
|
|
17
|
+
|
|
18
|
+
# Or install globally for faster runs
|
|
19
|
+
npm install -g @aiready/pattern-detect
|
|
20
|
+
aiready-patterns ./src
|
|
14
21
|
```
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
### 🎯 Input & Output
|
|
17
24
|
|
|
25
|
+
**Input:** Path to your source code directory
|
|
18
26
|
```bash
|
|
19
|
-
npm install -g @aiready/pattern-detect
|
|
20
27
|
aiready-patterns ./src
|
|
21
28
|
```
|
|
22
29
|
|
|
30
|
+
**Output:** Terminal report + optional JSON file (saved to `.aiready/` directory)
|
|
31
|
+
```
|
|
32
|
+
📊 Duplicate Pattern Analysis
|
|
33
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
34
|
+
📁 Files analyzed: 47
|
|
35
|
+
⚠️ Duplicate patterns: 12 files with 23 issues
|
|
36
|
+
💰 Wasted tokens: 8,450
|
|
37
|
+
|
|
38
|
+
CRITICAL (6 files)
|
|
39
|
+
src/handlers/users.ts - 4 duplicates (1,200 tokens)
|
|
40
|
+
src/handlers/posts.ts - 3 duplicates (950 tokens)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### ✨ Smart Defaults (Zero Config)
|
|
44
|
+
|
|
45
|
+
- ✅ **Auto-excludes** test files (`**/*.test.*`, `**/*.spec.*`, `**/__tests__/**`)
|
|
46
|
+
- ✅ **Auto-excludes** build outputs (`dist/`, `build/`, `.next/`)
|
|
47
|
+
- ✅ **Auto-excludes** dependencies (`node_modules/`)
|
|
48
|
+
- ✅ **Adaptive threshold**: Adjusts similarity detection based on codebase size
|
|
49
|
+
- ✅ **Pattern classification**: Automatically categorizes duplicates (API handlers, validators, etc.)
|
|
50
|
+
|
|
51
|
+
> Override defaults with `--include-tests` or `--exclude <patterns>` as needed
|
|
52
|
+
|
|
23
53
|
## 🎯 What It Does
|
|
24
54
|
|
|
25
55
|
AI tools generate similar code in different ways because they lack awareness of your codebase patterns. This tool:
|
package/dist/cli.js
CHANGED
|
@@ -726,16 +726,17 @@ program.name("aiready-patterns").description("Detect duplicate patterns in your
|
|
|
726
726
|
includeTests: options.includeTests || mergedConfig.includeTests,
|
|
727
727
|
maxResults: options.maxResults ? parseInt(options.maxResults) : mergedConfig.maxResults
|
|
728
728
|
};
|
|
729
|
-
if (
|
|
729
|
+
if (finalOptions.includeTests && finalOptions.exclude) {
|
|
730
730
|
const testPatterns = [
|
|
731
731
|
"**/*.test.*",
|
|
732
732
|
"**/*.spec.*",
|
|
733
733
|
"**/__tests__/**",
|
|
734
734
|
"**/test/**",
|
|
735
|
-
"
|
|
736
|
-
"**/*.spec"
|
|
735
|
+
"**/tests/**"
|
|
737
736
|
];
|
|
738
|
-
finalOptions.exclude = finalOptions.exclude
|
|
737
|
+
finalOptions.exclude = finalOptions.exclude.filter(
|
|
738
|
+
(pattern) => !testPatterns.includes(pattern)
|
|
739
|
+
);
|
|
739
740
|
}
|
|
740
741
|
const { results, duplicates: rawDuplicates, files } = await analyzePatterns(finalOptions);
|
|
741
742
|
let filteredDuplicates = rawDuplicates;
|
package/dist/cli.mjs
CHANGED
|
@@ -55,16 +55,17 @@ program.name("aiready-patterns").description("Detect duplicate patterns in your
|
|
|
55
55
|
includeTests: options.includeTests || mergedConfig.includeTests,
|
|
56
56
|
maxResults: options.maxResults ? parseInt(options.maxResults) : mergedConfig.maxResults
|
|
57
57
|
};
|
|
58
|
-
if (
|
|
58
|
+
if (finalOptions.includeTests && finalOptions.exclude) {
|
|
59
59
|
const testPatterns = [
|
|
60
60
|
"**/*.test.*",
|
|
61
61
|
"**/*.spec.*",
|
|
62
62
|
"**/__tests__/**",
|
|
63
63
|
"**/test/**",
|
|
64
|
-
"
|
|
65
|
-
"**/*.spec"
|
|
64
|
+
"**/tests/**"
|
|
66
65
|
];
|
|
67
|
-
finalOptions.exclude = finalOptions.exclude
|
|
66
|
+
finalOptions.exclude = finalOptions.exclude.filter(
|
|
67
|
+
(pattern) => !testPatterns.includes(pattern)
|
|
68
|
+
);
|
|
68
69
|
}
|
|
69
70
|
const { results, duplicates: rawDuplicates, files } = await analyzePatterns(finalOptions);
|
|
70
71
|
let filteredDuplicates = rawDuplicates;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/pattern-detect",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.10",
|
|
4
4
|
"description": "Semantic duplicate pattern detection for AI-generated code - finds similar implementations that waste AI context tokens",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"commander": "^14.0.0",
|
|
47
47
|
"chalk": "^5.3.0",
|
|
48
|
-
"@aiready/core": "0.7.
|
|
48
|
+
"@aiready/core": "0.7.4"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.3.5",
|