@aiready/pattern-detect 0.8.0 → 0.8.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 +11 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,11 +24,21 @@ aiready-patterns ./src
|
|
|
24
24
|
|
|
25
25
|
AI tools generate similar code in different ways because they lack awareness of your codebase patterns. This tool:
|
|
26
26
|
|
|
27
|
-
- **Semantic detection**: Finds functionally similar code (not just copy-paste)
|
|
27
|
+
- **Semantic detection**: Finds functionally similar code (not just copy-paste) using Jaccard similarity on AST tokens
|
|
28
28
|
- **Pattern classification**: Groups duplicates by type (API handlers, validators, utilities, etc.)
|
|
29
29
|
- **Token cost analysis**: Shows wasted AI context budget
|
|
30
30
|
- **Refactoring guidance**: Suggests specific fixes per pattern type
|
|
31
31
|
|
|
32
|
+
### How It Works
|
|
33
|
+
|
|
34
|
+
The tool uses **Jaccard similarity** to compare code semantically:
|
|
35
|
+
1. Parses TypeScript/JavaScript files into Abstract Syntax Trees (AST)
|
|
36
|
+
2. Extracts semantic tokens (identifiers, operators, keywords) from each function
|
|
37
|
+
3. Calculates Jaccard similarity between token sets: `|A ∩ B| / |A ∪ B|`
|
|
38
|
+
4. Groups similar functions above the similarity threshold
|
|
39
|
+
|
|
40
|
+
This approach catches duplicates even when variable names or minor logic differs.
|
|
41
|
+
|
|
32
42
|
### Example Output
|
|
33
43
|
|
|
34
44
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/pattern-detect",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
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.5.
|
|
48
|
+
"@aiready/core": "0.5.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.3.5",
|