@aiready/pattern-detect 0.17.8 → 0.17.12

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.
Files changed (190) hide show
  1. package/dist/analyzer-entry/index.d.mts +1 -1
  2. package/dist/analyzer-entry/index.d.ts +1 -1
  3. package/dist/analyzer-entry/index.js +370 -135
  4. package/dist/analyzer-entry/index.mjs +4 -3
  5. package/dist/chunk-2P7BQHGR.mjs +306 -0
  6. package/dist/{chunk-VGMM3L3O.mjs → chunk-3EORD7DC.mjs} +1 -1
  7. package/dist/{chunk-GREN7X5H.mjs → chunk-4PVPQMRT.mjs} +2 -2
  8. package/dist/{chunk-RS73WLNI.mjs → chunk-6VDL7TAS.mjs} +5 -113
  9. package/dist/chunk-AQIP4JGM.mjs +283 -0
  10. package/dist/{chunk-JBUZ6YHE.mjs → chunk-B4NLWKPZ.mjs} +85 -9
  11. package/dist/chunk-IPBGVPUX.mjs +143 -0
  12. package/dist/chunk-LUUJOUK5.mjs +283 -0
  13. package/dist/chunk-P3BOCGVV.mjs +498 -0
  14. package/dist/{scoring-entry.js → chunk-PHJE6A3J.mjs} +20 -37
  15. package/dist/chunk-PQXOORR4.mjs +234 -0
  16. package/dist/{chunk-GLKAGFKX.mjs → chunk-RDR75DVI.mjs} +85 -9
  17. package/dist/chunk-SXVLRPMF.mjs +143 -0
  18. package/dist/{chunk-DNZS4ESD.mjs → chunk-SY7RX5YQ.mjs} +85 -9
  19. package/dist/{context-rules-entry.js → chunk-TIBF7KST.mjs} +81 -78
  20. package/dist/chunk-WYYSQX5M.mjs +467 -0
  21. package/dist/{chunk-I6ETJC7L.mjs → chunk-X553BOMI.mjs} +56 -26
  22. package/dist/{chunk-K7BO57OO.mjs → chunk-Y6OB7K34.mjs} +80 -4
  23. package/dist/chunk-YLVV6YZ5.mjs +143 -0
  24. package/dist/chunk-ZUWPFVJV.mjs +115 -0
  25. package/dist/chunk-ZZMONVPE.mjs +467 -0
  26. package/dist/cli.js +402 -167
  27. package/dist/cli.mjs +4 -3
  28. package/dist/context-rules-entry/index.d.mts +35 -1
  29. package/dist/context-rules-entry/index.d.ts +35 -1
  30. package/dist/context-rules-entry/index.js +194 -48
  31. package/dist/context-rules-entry/index.mjs +1 -1
  32. package/dist/detector-entry/index.js +192 -46
  33. package/dist/detector-entry/index.mjs +2 -2
  34. package/dist/{analyzer-entry-BVz-HnZd.d.mts → index-B-pnXpgn.d.mts} +10 -1
  35. package/dist/{index-BwuoiCNm.d.ts → index-CWgYOKaK.d.ts} +35 -16
  36. package/dist/{index-BVz-HnZd.d.mts → index-Dl4BrGIT.d.mts} +35 -16
  37. package/dist/{analyzer-entry-BwuoiCNm.d.ts → index-DqS2e0kK.d.ts} +10 -1
  38. package/dist/index.d.mts +5 -6
  39. package/dist/index.d.ts +5 -6
  40. package/dist/index.js +467 -214
  41. package/dist/index.mjs +37 -22
  42. package/dist/scoring-entry/index.js +7 -3
  43. package/dist/scoring-entry/index.mjs +1 -1
  44. package/package.json +2 -2
  45. package/dist/analyzer-entry.d.mts +0 -100
  46. package/dist/analyzer-entry.d.ts +0 -100
  47. package/dist/analyzer-entry.js +0 -693
  48. package/dist/analyzer-entry.mjs +0 -12
  49. package/dist/chunk-262N2JB7.mjs +0 -497
  50. package/dist/chunk-2R7HOR5H.mjs +0 -777
  51. package/dist/chunk-3D7RVGHM.mjs +0 -64
  52. package/dist/chunk-3LS3E6MO.mjs +0 -508
  53. package/dist/chunk-3VRQYFW3.mjs +0 -782
  54. package/dist/chunk-3WK24ZOX.mjs +0 -860
  55. package/dist/chunk-3YYN6ZXN.mjs +0 -1038
  56. package/dist/chunk-4BPRGZRG.mjs +0 -1041
  57. package/dist/chunk-4UHDGB7U.mjs +0 -920
  58. package/dist/chunk-5LYDB7DY.mjs +0 -771
  59. package/dist/chunk-65G3HXLQ.mjs +0 -497
  60. package/dist/chunk-65UQ5J2J.mjs +0 -64
  61. package/dist/chunk-6JTVOBJX.mjs +0 -64
  62. package/dist/chunk-6OEHUI5J.mjs +0 -1045
  63. package/dist/chunk-6YUGU4P4.mjs +0 -914
  64. package/dist/chunk-7EJGNGXM.mjs +0 -771
  65. package/dist/chunk-7O2DUBSN.mjs +0 -1058
  66. package/dist/chunk-7S4AUL5S.mjs +0 -911
  67. package/dist/chunk-A76JUWER.mjs +0 -786
  68. package/dist/chunk-AJZUNNFH.mjs +0 -817
  69. package/dist/chunk-AXHGYYYZ.mjs +0 -404
  70. package/dist/chunk-BKRPSTT2.mjs +0 -64
  71. package/dist/chunk-BUBQ3W6W.mjs +0 -980
  72. package/dist/chunk-CCHM2VLK.mjs +0 -1051
  73. package/dist/chunk-CHFK6EBT.mjs +0 -419
  74. package/dist/chunk-CMT3MWWO.mjs +0 -948
  75. package/dist/chunk-CMWW24HW.mjs +0 -259
  76. package/dist/chunk-CTDBJP25.mjs +0 -1043
  77. package/dist/chunk-DGAKXYIP.mjs +0 -1041
  78. package/dist/chunk-DQSLTL7J.mjs +0 -788
  79. package/dist/chunk-DR5W7S3Z.mjs +0 -968
  80. package/dist/chunk-EFUKPMBE.mjs +0 -950
  81. package/dist/chunk-EVBFDILL.mjs +0 -927
  82. package/dist/chunk-EXORBAXR.mjs +0 -887
  83. package/dist/chunk-EZT3NZGB.mjs +0 -1057
  84. package/dist/chunk-FWUKMJEQ.mjs +0 -1133
  85. package/dist/chunk-GSJFORRO.mjs +0 -504
  86. package/dist/chunk-H4ADJYOG.mjs +0 -925
  87. package/dist/chunk-H5FB2USZ.mjs +0 -762
  88. package/dist/chunk-H73HEG7M.mjs +0 -670
  89. package/dist/chunk-HOS5Z2NC.mjs +0 -669
  90. package/dist/chunk-HXHQOQB5.mjs +0 -508
  91. package/dist/chunk-INEOYHUM.mjs +0 -911
  92. package/dist/chunk-INJ4SBTV.mjs +0 -754
  93. package/dist/chunk-J5CW6NYY.mjs +0 -64
  94. package/dist/chunk-JAFZCZAP.mjs +0 -776
  95. package/dist/chunk-JKVKOXYR.mjs +0 -407
  96. package/dist/chunk-JTHW7EYW.mjs +0 -1041
  97. package/dist/chunk-JWR3AHKO.mjs +0 -788
  98. package/dist/chunk-KC2CQMG2.mjs +0 -858
  99. package/dist/chunk-KDWGWBP5.mjs +0 -832
  100. package/dist/chunk-KPEK5REL.mjs +0 -919
  101. package/dist/chunk-KT6O2IAE.mjs +0 -861
  102. package/dist/chunk-KWMNN3TG.mjs +0 -391
  103. package/dist/chunk-LUA5FXSZ.mjs +0 -771
  104. package/dist/chunk-LYKRYBSM.mjs +0 -64
  105. package/dist/chunk-M4PQMW34.mjs +0 -480
  106. package/dist/chunk-MH6LBXZF.mjs +0 -816
  107. package/dist/chunk-MHU3CL4R.mjs +0 -64
  108. package/dist/chunk-MJWBS6SM.mjs +0 -1058
  109. package/dist/chunk-OFGMDX66.mjs +0 -402
  110. package/dist/chunk-P7B6Z4I2.mjs +0 -1043
  111. package/dist/chunk-PBCXSG7E.mjs +0 -658
  112. package/dist/chunk-PEEHSFDR.mjs +0 -1058
  113. package/dist/chunk-PSVG2NLH.mjs +0 -966
  114. package/dist/chunk-PWNQ6JZW.mjs +0 -508
  115. package/dist/chunk-QE4E3F7C.mjs +0 -410
  116. package/dist/chunk-QEP76HGK.mjs +0 -1039
  117. package/dist/chunk-QX2BQJEO.mjs +0 -1058
  118. package/dist/chunk-R2S73CVG.mjs +0 -503
  119. package/dist/chunk-RMGDSNLE.mjs +0 -770
  120. package/dist/chunk-S2KQFII2.mjs +0 -491
  121. package/dist/chunk-SLDK5PQK.mjs +0 -1129
  122. package/dist/chunk-SNSDVGWW.mjs +0 -783
  123. package/dist/chunk-SUUZMLPS.mjs +0 -391
  124. package/dist/chunk-SVCSIZ2A.mjs +0 -259
  125. package/dist/chunk-T2C6WS73.mjs +0 -670
  126. package/dist/chunk-TCG2G32F.mjs +0 -911
  127. package/dist/chunk-TGBZP7SB.mjs +0 -773
  128. package/dist/chunk-THF4RW63.mjs +0 -254
  129. package/dist/chunk-TJKDLVLN.mjs +0 -503
  130. package/dist/chunk-TXWPOVYU.mjs +0 -402
  131. package/dist/chunk-UB3CGOQ7.mjs +0 -64
  132. package/dist/chunk-UKIKN27B.mjs +0 -950
  133. package/dist/chunk-V5DP4FP6.mjs +0 -876
  134. package/dist/chunk-VRMXVYDZ.mjs +0 -419
  135. package/dist/chunk-WACZ5LFH.mjs +0 -1055
  136. package/dist/chunk-WC7CBAA7.mjs +0 -1058
  137. package/dist/chunk-WKBCNITM.mjs +0 -1072
  138. package/dist/chunk-WMOGJFME.mjs +0 -391
  139. package/dist/chunk-X4GR2N2M.mjs +0 -947
  140. package/dist/chunk-XCWY2DQY.mjs +0 -788
  141. package/dist/chunk-XJD35DS6.mjs +0 -1058
  142. package/dist/chunk-XNPID6FU.mjs +0 -391
  143. package/dist/chunk-XUUVS54V.mjs +0 -776
  144. package/dist/chunk-YCGV65F5.mjs +0 -508
  145. package/dist/chunk-YJYDBFT3.mjs +0 -780
  146. package/dist/chunk-YP3HEDQW.mjs +0 -859
  147. package/dist/chunk-YSDOUNJJ.mjs +0 -1142
  148. package/dist/chunk-Z6GBFFOV.mjs +0 -1040
  149. package/dist/cli.d.ts.map +0 -1
  150. package/dist/cli.js.map +0 -1
  151. package/dist/context-rules-entry-y2uJSngh.d.mts +0 -60
  152. package/dist/context-rules-entry-y2uJSngh.d.ts +0 -60
  153. package/dist/context-rules-entry.d.mts +0 -55
  154. package/dist/context-rules-entry.d.ts +0 -55
  155. package/dist/context-rules-entry.mjs +0 -12
  156. package/dist/context-rules.d.ts +0 -41
  157. package/dist/context-rules.d.ts.map +0 -1
  158. package/dist/context-rules.js +0 -225
  159. package/dist/context-rules.js.map +0 -1
  160. package/dist/detector-entry.d.mts +0 -14
  161. package/dist/detector-entry.d.ts +0 -14
  162. package/dist/detector-entry.js +0 -301
  163. package/dist/detector-entry.mjs +0 -7
  164. package/dist/detector.d.ts +0 -40
  165. package/dist/detector.d.ts.map +0 -1
  166. package/dist/detector.js +0 -385
  167. package/dist/detector.js.map +0 -1
  168. package/dist/extractors/python-extractor.d.ts +0 -19
  169. package/dist/extractors/python-extractor.d.ts.map +0 -1
  170. package/dist/extractors/python-extractor.js +0 -164
  171. package/dist/extractors/python-extractor.js.map +0 -1
  172. package/dist/grouping.d.ts +0 -54
  173. package/dist/grouping.d.ts.map +0 -1
  174. package/dist/grouping.js +0 -347
  175. package/dist/grouping.js.map +0 -1
  176. package/dist/index-y2uJSngh.d.mts +0 -60
  177. package/dist/index-y2uJSngh.d.ts +0 -60
  178. package/dist/index.d.ts.map +0 -1
  179. package/dist/index.js.map +0 -1
  180. package/dist/python-extractor-BGKGX6BK.mjs +0 -131
  181. package/dist/python-extractor-ELAKYK2W.mjs +0 -140
  182. package/dist/scoring-entry.d.mts +0 -23
  183. package/dist/scoring-entry.d.ts +0 -23
  184. package/dist/scoring-entry.mjs +0 -6
  185. package/dist/scoring.d.ts +0 -12
  186. package/dist/scoring.d.ts.map +0 -1
  187. package/dist/scoring.js +0 -116
  188. package/dist/scoring.js.map +0 -1
  189. package/dist/types-C4lmb2Yh.d.mts +0 -36
  190. package/dist/types-C4lmb2Yh.d.ts +0 -36
@@ -37,14 +37,17 @@ __export(analyzer_entry_exports, {
37
37
  module.exports = __toCommonJS(analyzer_entry_exports);
38
38
 
39
39
  // src/analyzer.ts
40
- var import_core4 = require("@aiready/core");
40
+ var import_core11 = require("@aiready/core");
41
41
 
42
42
  // src/detector.ts
43
- var import_core2 = require("@aiready/core");
43
+ var import_core6 = require("@aiready/core");
44
44
 
45
45
  // src/context-rules.ts
46
+ var import_core5 = require("@aiready/core");
47
+
48
+ // src/rules/categories/test-rules.ts
46
49
  var import_core = require("@aiready/core");
47
- var CONTEXT_RULES = [
50
+ var TEST_RULES = [
48
51
  // Test Fixtures - Intentional duplication for test isolation
49
52
  {
50
53
  name: "test-fixtures",
@@ -57,6 +60,35 @@ var CONTEXT_RULES = [
57
60
  reason: "Test fixture duplication is intentional for test isolation",
58
61
  suggestion: "Consider if shared test setup would improve maintainability without coupling tests"
59
62
  },
63
+ // E2E/Integration Test Page Objects - Test independence
64
+ {
65
+ name: "e2e-page-objects",
66
+ detect: (file, code) => {
67
+ const isE2ETest = file.includes("e2e/") || file.includes("/e2e/") || file.includes(".e2e.") || file.includes("/playwright/") || file.includes("playwright/") || file.includes("/cypress/") || file.includes("cypress/") || file.includes("/integration/") || file.includes("integration/");
68
+ const hasPageObjectPatterns = code.includes("page.") || code.includes("await page") || code.includes("locator") || code.includes("getBy") || code.includes("selector") || code.includes("click(") || code.includes("fill(");
69
+ return isE2ETest && hasPageObjectPatterns;
70
+ },
71
+ severity: import_core.Severity.Info,
72
+ reason: "E2E test duplication ensures test independence and reduces coupling",
73
+ suggestion: "Consider page object pattern only if duplication causes maintenance issues"
74
+ },
75
+ // Mock Data - Test data intentionally duplicated
76
+ {
77
+ name: "mock-data",
78
+ detect: (file, code) => {
79
+ const isMockFile = file.includes("/mocks/") || file.includes("/__mocks__/") || file.includes("/fixtures/") || file.includes(".mock.") || file.includes(".fixture.");
80
+ const hasMockData = code.includes("mock") || code.includes("Mock") || code.includes("fixture") || code.includes("stub") || code.includes("export const");
81
+ return isMockFile && hasMockData;
82
+ },
83
+ severity: import_core.Severity.Info,
84
+ reason: "Mock data duplication is expected for comprehensive test coverage",
85
+ suggestion: "Consider shared factories only for complex mock generation"
86
+ }
87
+ ];
88
+
89
+ // src/rules/categories/web-rules.ts
90
+ var import_core2 = require("@aiready/core");
91
+ var WEB_RULES = [
60
92
  // Email/Document Templates - Often intentionally similar for consistency
61
93
  {
62
94
  name: "templates",
@@ -65,66 +97,59 @@ var CONTEXT_RULES = [
65
97
  const hasTemplateContent = (code.includes("return") || code.includes("export")) && (code.includes("html") || code.includes("subject") || code.includes("body"));
66
98
  return isTemplate && hasTemplateContent;
67
99
  },
68
- severity: import_core.Severity.Minor,
100
+ severity: import_core2.Severity.Info,
69
101
  reason: "Template duplication may be intentional for maintainability and branding consistency",
70
102
  suggestion: "Extract shared structure only if templates become hard to maintain"
71
103
  },
72
- // E2E/Integration Test Page Objects - Test independence
104
+ // Common UI Event Handlers - Very specific patterns only
73
105
  {
74
- name: "e2e-page-objects",
106
+ name: "common-ui-handlers",
75
107
  detect: (file, code) => {
76
- const isE2ETest = file.includes("e2e/") || file.includes("/e2e/") || file.includes(".e2e.") || file.includes("/playwright/") || file.includes("playwright/") || file.includes("/cypress/") || file.includes("cypress/") || file.includes("/integration/") || file.includes("integration/");
77
- const hasPageObjectPatterns = code.includes("page.") || code.includes("await page") || code.includes("locator") || code.includes("getBy") || code.includes("selector") || code.includes("click(") || code.includes("fill(");
78
- return isE2ETest && hasPageObjectPatterns;
108
+ const isUIFile = file.includes("/components/") || file.includes(".tsx") || file.includes(".jsx") || file.includes("/hooks/");
109
+ const hasCommonHandler = code.includes("handleClickOutside") && code.includes("dropdownRef.current") && code.includes("!dropdownRef.current.contains") || code.includes("handleEscape") && code.includes("event.key") && code.includes("=== 'Escape'") || code.includes("handleClickInside") && code.includes("event.stopPropagation");
110
+ return isUIFile && hasCommonHandler;
79
111
  },
80
- severity: import_core.Severity.Minor,
81
- reason: "E2E test duplication ensures test independence and reduces coupling",
82
- suggestion: "Consider page object pattern only if duplication causes maintenance issues"
112
+ severity: import_core2.Severity.Info,
113
+ reason: "Common UI event handlers are boilerplate patterns that repeat across components",
114
+ suggestion: "Consider extracting to shared hooks (useClickOutside, useEscapeKey) only if causing maintenance issues"
83
115
  },
116
+ // Next.js Route Handler Patterns - Boilerplate API route patterns
117
+ {
118
+ name: "nextjs-route-handlers",
119
+ detect: (file, code) => {
120
+ const isRouteFile = file.includes("/api/") && (file.endsWith("/route.ts") || file.endsWith("/route.js"));
121
+ const hasRoutePattern = code.includes("export async function POST") || code.includes("export async function GET") || code.includes("export async function PUT") || code.includes("export async function DELETE") || code.includes("NextResponse.json") || code.includes("NextRequest");
122
+ return isRouteFile && hasRoutePattern;
123
+ },
124
+ severity: import_core2.Severity.Info,
125
+ reason: "Next.js route handlers follow standard patterns and are intentionally similar across endpoints",
126
+ suggestion: "Route handler duplication is acceptable for API endpoint boilerplate"
127
+ }
128
+ ];
129
+
130
+ // src/rules/categories/infra-rules.ts
131
+ var import_core3 = require("@aiready/core");
132
+ var INFRA_RULES = [
84
133
  // Configuration Files - Often necessarily similar by design
85
134
  {
86
135
  name: "config-files",
87
136
  detect: (file) => {
88
137
  return file.endsWith(".config.ts") || file.endsWith(".config.js") || file.includes("jest.config") || file.includes("vite.config") || file.includes("webpack.config") || file.includes("rollup.config") || file.includes("tsconfig");
89
138
  },
90
- severity: import_core.Severity.Minor,
139
+ severity: import_core3.Severity.Info,
91
140
  reason: "Configuration files often have similar structure by design",
92
141
  suggestion: "Consider shared config base only if configurations become hard to maintain"
93
142
  },
94
- // Type Definitions - Duplication for type safety and module independence
95
- {
96
- name: "type-definitions",
97
- detect: (file, code) => {
98
- const isTypeFile = file.endsWith(".d.ts") || file.includes("/types/");
99
- const hasTypeDefinitions = code.includes("interface ") || code.includes("type ") || code.includes("enum ");
100
- return isTypeFile && hasTypeDefinitions;
101
- },
102
- severity: import_core.Severity.Info,
103
- reason: "Type duplication may be intentional for module independence and type safety",
104
- suggestion: "Extract to shared types package only if causing maintenance burden"
105
- },
106
143
  // Migration Scripts - One-off scripts that are similar by nature
107
144
  {
108
145
  name: "migration-scripts",
109
146
  detect: (file) => {
110
147
  return file.includes("/migrations/") || file.includes("/migrate/") || file.includes(".migration.");
111
148
  },
112
- severity: import_core.Severity.Info,
149
+ severity: import_core3.Severity.Info,
113
150
  reason: "Migration scripts are typically one-off and intentionally similar",
114
151
  suggestion: "Duplication is acceptable for migration scripts"
115
152
  },
116
- // Mock Data - Test data intentionally duplicated
117
- {
118
- name: "mock-data",
119
- detect: (file, code) => {
120
- const isMockFile = file.includes("/mocks/") || file.includes("/__mocks__/") || file.includes("/fixtures/") || file.includes(".mock.") || file.includes(".fixture.");
121
- const hasMockData = code.includes("mock") || code.includes("Mock") || code.includes("fixture") || code.includes("stub") || code.includes("export const");
122
- return isMockFile && hasMockData;
123
- },
124
- severity: import_core.Severity.Info,
125
- reason: "Mock data duplication is expected for comprehensive test coverage",
126
- suggestion: "Consider shared factories only for complex mock generation"
127
- },
128
153
  // Tool Implementations - Structural Boilerplate
129
154
  {
130
155
  name: "tool-implementations",
@@ -133,11 +158,132 @@ var CONTEXT_RULES = [
133
158
  const hasToolStructure = code.includes("execute") && (code.includes("try") || code.includes("catch"));
134
159
  return isToolFile && hasToolStructure;
135
160
  },
136
- severity: import_core.Severity.Info,
161
+ severity: import_core3.Severity.Info,
137
162
  reason: "Tool implementations share structural boilerplate but have distinct business logic",
138
163
  suggestion: "Tool duplication is acceptable for boilerplate interface wrappers"
164
+ },
165
+ // CLI Command Definitions - Commander.js boilerplate patterns
166
+ {
167
+ name: "cli-command-definitions",
168
+ detect: (file, code) => {
169
+ const isCliFile = file.includes("/commands/") || file.includes("/cli/") || file.endsWith(".command.ts");
170
+ const hasCommandPattern = (code.includes(".command(") || code.includes("defineCommand")) && (code.includes(".description(") || code.includes(".option(")) && (code.includes(".action(") || code.includes("async"));
171
+ return isCliFile && hasCommandPattern;
172
+ },
173
+ severity: import_core3.Severity.Info,
174
+ reason: "CLI command definitions follow standard Commander.js patterns and are intentionally similar",
175
+ suggestion: "Command boilerplate duplication is acceptable for CLI interfaces"
139
176
  }
140
177
  ];
178
+
179
+ // src/rules/categories/logic-rules.ts
180
+ var import_core4 = require("@aiready/core");
181
+ var LOGIC_RULES = [
182
+ // Type Definitions - Duplication for type safety and module independence
183
+ {
184
+ name: "type-definitions",
185
+ detect: (file, code) => {
186
+ const isTypeFile = file.endsWith(".d.ts") || file.includes("/types/");
187
+ const hasOnlyTypeDefinitions = (code.includes("interface ") || code.includes("type ") || code.includes("enum ")) && !code.includes("function ") && !code.includes("class ") && !code.includes("const ") && !code.includes("let ") && !code.includes("export default");
188
+ const isInterfaceOnlySnippet = code.trim().startsWith("interface ") && code.includes("{") && code.includes("}") && !code.includes("function ") && !code.includes("const ") && !code.includes("return ");
189
+ return isTypeFile && hasOnlyTypeDefinitions || isInterfaceOnlySnippet;
190
+ },
191
+ severity: import_core4.Severity.Info,
192
+ reason: "Type/interface definitions are intentionally duplicated for module independence",
193
+ suggestion: "Extract to shared types package only if causing maintenance burden"
194
+ },
195
+ // Utility Functions - Small helpers in dedicated utility files
196
+ {
197
+ name: "utility-functions",
198
+ detect: (file, code) => {
199
+ const isUtilFile = file.endsWith(".util.ts") || file.endsWith(".helper.ts") || file.endsWith(".utils.ts");
200
+ const hasUtilPattern = code.includes("function format") || code.includes("function parse") || code.includes("function sanitize") || code.includes("function normalize") || code.includes("function convert");
201
+ return isUtilFile && hasUtilPattern;
202
+ },
203
+ severity: import_core4.Severity.Info,
204
+ reason: "Utility functions in dedicated utility files may be intentionally similar",
205
+ suggestion: "Consider extracting to shared utilities only if causing significant duplication"
206
+ },
207
+ // React/Vue Hooks - Standard patterns
208
+ {
209
+ name: "shared-hooks",
210
+ detect: (file, code) => {
211
+ const isHookFile = file.includes("/hooks/") || file.endsWith(".hook.ts") || file.endsWith(".hook.tsx");
212
+ const hasHookPattern = code.includes("function use") || code.includes("export function use") || code.includes("const use") || code.includes("export const use");
213
+ return isHookFile && hasHookPattern;
214
+ },
215
+ severity: import_core4.Severity.Info,
216
+ reason: "Hooks follow standard patterns and are often intentionally similar across components",
217
+ suggestion: "Consider extracting common hook logic only if hooks become complex"
218
+ },
219
+ // Score/Rating Helper Functions - Common threshold patterns
220
+ {
221
+ name: "score-helpers",
222
+ detect: (file, code) => {
223
+ const isHelperFile = file.includes("/utils/") || file.includes("/helpers/") || file.endsWith(".util.ts");
224
+ const hasScorePattern = (code.includes("if (score >=") || code.includes("if (score >")) && code.includes("return") && code.includes("'") && code.split("if (score").length >= 3;
225
+ return isHelperFile && hasScorePattern;
226
+ },
227
+ severity: import_core4.Severity.Info,
228
+ reason: "Score/rating helper functions use common threshold patterns that are intentionally similar",
229
+ suggestion: "Score formatting duplication is acceptable for consistent UI display"
230
+ },
231
+ // D3/Canvas Event Handlers - Standard visualization patterns
232
+ {
233
+ name: "visualization-handlers",
234
+ detect: (file, code) => {
235
+ const isVizFile = file.includes("/visualizer/") || file.includes("/charts/") || file.includes("GraphCanvas") || file.includes("ForceDirected");
236
+ const hasVizPattern = (code.includes("dragstarted") || code.includes("dragged") || code.includes("dragended")) && (code.includes("simulation") || code.includes("d3.") || code.includes("alphaTarget"));
237
+ return isVizFile && hasVizPattern;
238
+ },
239
+ severity: import_core4.Severity.Info,
240
+ reason: "D3/visualization event handlers follow standard patterns and are intentionally similar",
241
+ suggestion: "Visualization boilerplate duplication is acceptable for interactive charts"
242
+ },
243
+ // Icon/Switch Statement Helpers - Common enum-to-value patterns
244
+ {
245
+ name: "switch-helpers",
246
+ detect: (file, code) => {
247
+ const hasSwitchPattern = code.includes("switch (") && code.includes("case '") && code.includes("return") && code.split("case ").length >= 4;
248
+ const hasIconPattern = code.includes("getIcon") || code.includes("getColor") || code.includes("getLabel") || code.includes("getRating");
249
+ return hasSwitchPattern && hasIconPattern;
250
+ },
251
+ severity: import_core4.Severity.Info,
252
+ reason: "Switch statement helpers for enum-to-value mapping are inherently similar",
253
+ suggestion: "Switch duplication is acceptable for mapping enums to display values"
254
+ },
255
+ // Common API/Utility Functions - Legitimate duplication across modules
256
+ {
257
+ name: "common-api-functions",
258
+ detect: (file, code) => {
259
+ const isApiFile = file.includes("/api/") || file.includes("/lib/") || file.includes("/utils/") || file.endsWith(".ts");
260
+ const hasCommonApiPattern = code.includes("getStripe") && code.includes("process.env.STRIPE_SECRET_KEY") || code.includes("getUserByEmail") && code.includes("queryItems") || code.includes("updateUser") && code.includes("buildUpdateExpression") || code.includes("listUserRepositories") && code.includes("queryItems") || code.includes("listTeamRepositories") && code.includes("queryItems") || code.includes("getRemediation") && code.includes("queryItems") || code.includes("formatBreakdownKey") && code.includes(".replace(/([A-Z])/g") || code.includes("queryItems") && code.includes("KeyConditionExpression") || code.includes("putItem") && code.includes("createdAt") || code.includes("updateItem") && code.includes("buildUpdateExpression");
261
+ return isApiFile && hasCommonApiPattern;
262
+ },
263
+ severity: import_core4.Severity.Info,
264
+ reason: "Common API/utility functions are legitimately duplicated across modules for clarity and independence",
265
+ suggestion: "Consider extracting to shared utilities only if causing significant duplication"
266
+ },
267
+ // Validation Functions - Inherently similar patterns
268
+ {
269
+ name: "validation-functions",
270
+ detect: (file, code) => {
271
+ const hasValidationPattern = code.includes("isValid") || code.includes("validate") || code.includes("checkValid") || code.includes("isEmail") || code.includes("isPhone") || code.includes("isUrl") || code.includes("isNumeric") || code.includes("isAlpha") || code.includes("isAlphanumeric") || code.includes("isEmpty") || code.includes("isNotEmpty") || code.includes("isRequired") || code.includes("isOptional");
272
+ return hasValidationPattern;
273
+ },
274
+ severity: import_core4.Severity.Info,
275
+ reason: "Validation functions are inherently similar and often intentionally duplicated for domain clarity",
276
+ suggestion: "Consider extracting to shared validators only if validation logic becomes complex"
277
+ }
278
+ ];
279
+
280
+ // src/context-rules.ts
281
+ var CONTEXT_RULES = [
282
+ ...TEST_RULES,
283
+ ...WEB_RULES,
284
+ ...INFRA_RULES,
285
+ ...LOGIC_RULES
286
+ ];
141
287
  function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
142
288
  for (const rule of CONTEXT_RULES) {
143
289
  if (rule.detect(file1, code) || rule.detect(file2, code)) {
@@ -151,31 +297,31 @@ function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
151
297
  }
152
298
  if (similarity >= 0.95 && linesOfCode >= 30) {
153
299
  return {
154
- severity: import_core.Severity.Critical,
300
+ severity: import_core5.Severity.Critical,
155
301
  reason: "Large nearly-identical code blocks waste tokens and create maintenance burden",
156
302
  suggestion: "Extract to shared utility module immediately"
157
303
  };
158
304
  } else if (similarity >= 0.95 && linesOfCode >= 15) {
159
305
  return {
160
- severity: import_core.Severity.Major,
306
+ severity: import_core5.Severity.Major,
161
307
  reason: "Nearly identical code should be consolidated",
162
308
  suggestion: "Move to shared utility file"
163
309
  };
164
310
  } else if (similarity >= 0.85) {
165
311
  return {
166
- severity: import_core.Severity.Major,
312
+ severity: import_core5.Severity.Major,
167
313
  reason: "High similarity indicates significant duplication",
168
314
  suggestion: "Extract common logic to shared function"
169
315
  };
170
316
  } else if (similarity >= 0.7) {
171
317
  return {
172
- severity: import_core.Severity.Minor,
318
+ severity: import_core5.Severity.Minor,
173
319
  reason: "Moderate similarity detected",
174
320
  suggestion: "Consider extracting shared patterns if code evolves together"
175
321
  };
176
322
  } else {
177
323
  return {
178
- severity: import_core.Severity.Minor,
324
+ severity: import_core5.Severity.Minor,
179
325
  reason: "Minor similarity detected",
180
326
  suggestion: "Monitor but refactoring may not be worthwhile"
181
327
  };
@@ -196,13 +342,13 @@ function normalizeCode(code, isPython = false) {
196
342
 
197
343
  // src/detector.ts
198
344
  function extractBlocks(file, content) {
199
- return (0, import_core2.extractCodeBlocks)(file, content);
345
+ return (0, import_core6.extractCodeBlocks)(file, content);
200
346
  }
201
347
  function calculateSimilarity(a, b) {
202
- return (0, import_core2.calculateStringSimilarity)(a, b);
348
+ return (0, import_core6.calculateStringSimilarity)(a, b);
203
349
  }
204
350
  function calculateConfidence(similarity, tokens, lines) {
205
- return (0, import_core2.calculateHeuristicConfidence)(similarity, tokens, lines);
351
+ return (0, import_core6.calculateHeuristicConfidence)(similarity, tokens, lines);
206
352
  }
207
353
  async function detectDuplicatePatterns(fileContents, options) {
208
354
  const {
@@ -312,7 +458,7 @@ async function detectDuplicatePatterns(fileContents, options) {
312
458
  }
313
459
 
314
460
  // src/grouping.ts
315
- var import_core3 = require("@aiready/core");
461
+ var import_core7 = require("@aiready/core");
316
462
  var import_path = __toESM(require("path"));
317
463
  function groupDuplicatesByFilePair(duplicates) {
318
464
  const groups = /* @__PURE__ */ new Map();
@@ -340,7 +486,7 @@ function groupDuplicatesByFilePair(duplicates) {
340
486
  file2: { start: dup.line2, end: dup.endLine2 }
341
487
  });
342
488
  const currentSev = dup.severity;
343
- if ((0, import_core3.getSeverityLevel)(currentSev) > (0, import_core3.getSeverityLevel)(group.severity)) {
489
+ if ((0, import_core7.getSeverityLevel)(currentSev) > (0, import_core7.getSeverityLevel)(group.severity)) {
344
490
  group.severity = currentSev;
345
491
  }
346
492
  }
@@ -430,21 +576,77 @@ function filterClustersByImpact(clusters, minTokenCost = 1e3, minFiles = 3) {
430
576
  (c) => c.totalTokenCost >= minTokenCost && c.files.length >= minFiles
431
577
  );
432
578
  }
433
-
434
- // src/analyzer.ts
435
- function getRefactoringSuggestion(patternType, similarity) {
436
- const baseMessages = {
437
- "api-handler": "Extract common middleware or create a base handler class",
438
- validator: "Consolidate validation logic into shared schema validators (Zod/Yup)",
439
- utility: "Move to a shared utilities file and reuse across modules",
440
- "class-method": "Consider inheritance or composition to share behavior",
441
- component: "Extract shared logic into a custom hook or HOC",
442
- function: "Extract into a shared helper function",
443
- unknown: "Extract common logic into a reusable module"
444
- };
445
- const urgency = similarity > 0.95 ? " (CRITICAL: Nearly identical code)" : similarity > 0.9 ? " (HIGH: Very similar, refactor soon)" : "";
446
- return baseMessages[patternType] + urgency;
579
+ function isPureInterfaceDefinition(code) {
580
+ const trimmed = code.trim();
581
+ if (!trimmed.startsWith("interface ") && !trimmed.startsWith("type ") && !trimmed.startsWith("export interface ") && !trimmed.startsWith("export type ") && !trimmed.startsWith("enum ") && !trimmed.startsWith("export enum ")) {
582
+ return false;
583
+ }
584
+ if (trimmed.includes("={") || trimmed.includes("=> {") || trimmed.includes("function ") || trimmed.includes("() {") || trimmed.includes(" implements ")) {
585
+ return false;
586
+ }
587
+ if (trimmed.length > 200) return false;
588
+ return true;
589
+ }
590
+ var BRAND_INDICATORS = [
591
+ "cyberpunk",
592
+ "cyber-blue",
593
+ "cyber-purple",
594
+ "slate-900",
595
+ "slate-400",
596
+ "zinc-",
597
+ "indigo-",
598
+ "neon-",
599
+ "glassmorphism",
600
+ "backdrop-blur"
601
+ ];
602
+ function isBrandSpecificComponent(filePath) {
603
+ const lower = filePath.toLowerCase();
604
+ const brandingTerms = ["landing", "clawmore", "platform", "apps/"];
605
+ for (const term of brandingTerms) {
606
+ if (lower.includes(term)) return true;
607
+ }
608
+ return false;
447
609
  }
610
+ function areBrandSpecificVariants(file1, file2, code1, code2) {
611
+ const f1IsBrand = isBrandSpecificComponent(file1);
612
+ const f2IsBrand = isBrandSpecificComponent(file2);
613
+ if (f1IsBrand && f2IsBrand && file1 !== file2) {
614
+ const hasBrandKeyword = (code) => {
615
+ const lowerCode = code.toLowerCase();
616
+ return BRAND_INDICATORS.some((ind) => lowerCode.includes(ind));
617
+ };
618
+ const code1Brand = hasBrandKeyword(code1);
619
+ const code2Brand = hasBrandKeyword(code2);
620
+ if (code1Brand && code2Brand) {
621
+ return true;
622
+ }
623
+ }
624
+ return false;
625
+ }
626
+ function filterBrandSpecificVariants(duplicates) {
627
+ return duplicates.filter((dup) => {
628
+ if (dup.file1 === dup.file2) return true;
629
+ const isBrandVariant = areBrandSpecificVariants(
630
+ dup.file1,
631
+ dup.file2,
632
+ dup.code1,
633
+ dup.code2
634
+ );
635
+ if (isBrandVariant) {
636
+ dup.severity = import_core7.Severity.Info;
637
+ dup.suggestion = "Brand-specific themed component variant (intentional)";
638
+ }
639
+ const isInterfaceDef = isPureInterfaceDefinition(dup.code1) && isPureInterfaceDefinition(dup.code2);
640
+ if (isInterfaceDef) {
641
+ dup.severity = import_core7.Severity.Info;
642
+ dup.suggestion = "Pure interface/type definition - intentional for module independence";
643
+ }
644
+ return true;
645
+ });
646
+ }
647
+
648
+ // src/config.ts
649
+ var import_core8 = require("@aiready/core");
448
650
  async function getSmartDefaults(directory, userOptions) {
449
651
  if (userOptions.useSmartDefaults === false) {
450
652
  return {
@@ -465,7 +667,7 @@ async function getSmartDefaults(directory, userOptions) {
465
667
  include: userOptions.include || ["**/*.{ts,tsx,js,jsx,py,java}"],
466
668
  exclude: userOptions.exclude
467
669
  };
468
- const files = await (0, import_core4.scanFiles)(scanOptions);
670
+ const files = await (0, import_core8.scanFiles)(scanOptions);
469
671
  const fileCount = files.length;
470
672
  const estimatedBlocks = fileCount * 5;
471
673
  const minLines = Math.max(
@@ -523,6 +725,98 @@ function logConfiguration(config, estimatedBlocks) {
523
725
  }
524
726
  console.log("");
525
727
  }
728
+
729
+ // src/summary.ts
730
+ var import_core9 = require("@aiready/core");
731
+ function getRefactoringSuggestion(patternType, similarity) {
732
+ const baseMessages = {
733
+ "api-handler": "Extract common middleware or create a base handler class",
734
+ validator: "Consolidate validation logic into shared schema validators (Zod/Yup)",
735
+ utility: "Move to a shared utilities file and reuse across modules",
736
+ "class-method": "Consider inheritance or composition to share behavior",
737
+ component: "Extract shared logic into a custom hook or HOC",
738
+ function: "Extract into a shared helper function",
739
+ unknown: "Extract common logic into a reusable module"
740
+ };
741
+ const urgency = similarity > 0.95 ? " (CRITICAL: Nearly identical code)" : similarity > 0.9 ? " (HIGH: Very similar, refactor soon)" : "";
742
+ return baseMessages[patternType] + urgency;
743
+ }
744
+ function generateSummary(results) {
745
+ const allIssues = results.flatMap((r) => r.issues || []);
746
+ const totalTokenCost = results.reduce(
747
+ (sum, r) => sum + (r.metrics?.tokenCost || 0),
748
+ 0
749
+ );
750
+ const patternsByType = {
751
+ "api-handler": 0,
752
+ validator: 0,
753
+ utility: 0,
754
+ "class-method": 0,
755
+ component: 0,
756
+ function: 0,
757
+ unknown: 0
758
+ };
759
+ allIssues.forEach((issue) => {
760
+ const match = issue.message.match(/^(\S+(?:-\S+)*) pattern/);
761
+ if (match) {
762
+ const type = match[1] || "unknown";
763
+ patternsByType[type] = (patternsByType[type] || 0) + 1;
764
+ }
765
+ });
766
+ const topDuplicates = allIssues.slice(0, 10).map((issue) => {
767
+ const similarityMatch = issue.message.match(/(\d+)% similar/);
768
+ const tokenMatch = issue.message.match(/\((\d+) tokens/);
769
+ const typeMatch = issue.message.match(/^(\S+(?:-\S+)*) pattern/);
770
+ const fileMatch = issue.message.match(/similar to (.+?) \(/);
771
+ return {
772
+ files: [
773
+ {
774
+ path: issue.location.file,
775
+ startLine: issue.location.line,
776
+ endLine: 0
777
+ },
778
+ {
779
+ path: fileMatch?.[1] || "unknown",
780
+ startLine: 0,
781
+ endLine: 0
782
+ }
783
+ ],
784
+ similarity: similarityMatch ? parseInt(similarityMatch[1]) / 100 : 0,
785
+ patternType: typeMatch?.[1] || "unknown",
786
+ tokenCost: tokenMatch ? parseInt(tokenMatch[1]) : 0
787
+ };
788
+ });
789
+ return {
790
+ totalPatterns: allIssues.length,
791
+ totalTokenCost,
792
+ patternsByType,
793
+ topDuplicates
794
+ };
795
+ }
796
+ function filterBySeverity2(issues, severity) {
797
+ if (severity === "all") return issues;
798
+ const severityMap = {
799
+ critical: [import_core9.Severity.Critical],
800
+ high: [import_core9.Severity.Critical, import_core9.Severity.Major],
801
+ medium: [import_core9.Severity.Critical, import_core9.Severity.Major, import_core9.Severity.Minor]
802
+ };
803
+ const allowed = severityMap[severity] || [
804
+ import_core9.Severity.Critical,
805
+ import_core9.Severity.Major,
806
+ import_core9.Severity.Minor
807
+ ];
808
+ return issues.filter((issue) => allowed.includes(issue.severity));
809
+ }
810
+ function calculateSeverity2(similarity) {
811
+ if (similarity > 0.95) return import_core9.Severity.Critical;
812
+ if (similarity > 0.9) return import_core9.Severity.Major;
813
+ return import_core9.Severity.Minor;
814
+ }
815
+
816
+ // src/scoring.ts
817
+ var import_core10 = require("@aiready/core");
818
+
819
+ // src/analyzer.ts
526
820
  async function analyzePatterns(options) {
527
821
  const smartDefaults = await getSmartDefaults(options.rootDir || ".", options);
528
822
  const finalOptions = { ...smartDefaults, ...options };
@@ -544,7 +838,7 @@ async function analyzePatterns(options) {
544
838
  ignoreWhitelist = [],
545
839
  ...scanOptions
546
840
  } = finalOptions;
547
- const files = await (0, import_core4.scanFiles)(scanOptions);
841
+ const files = await (0, import_core11.scanFiles)(scanOptions);
548
842
  const estimatedBlocks = files.length * 3;
549
843
  logConfiguration(finalOptions, estimatedBlocks);
550
844
  const results = [];
@@ -555,7 +849,7 @@ async function analyzePatterns(options) {
555
849
  const batchContents = await Promise.all(
556
850
  batch.map(async (file) => ({
557
851
  file,
558
- content: await (0, import_core4.readFileContent)(file)
852
+ content: await (0, import_core11.readFileContent)(file)
559
853
  }))
560
854
  );
561
855
  fileContents.push(...batchContents);
@@ -573,16 +867,22 @@ async function analyzePatterns(options) {
573
867
  ignoreWhitelist,
574
868
  onProgress: options.onProgress
575
869
  });
870
+ filterBrandSpecificVariants(duplicates);
576
871
  for (const file of files) {
577
872
  const fileDuplicates = duplicates.filter(
578
873
  (dup) => dup.file1 === file || dup.file2 === file
579
874
  );
580
875
  const issues = fileDuplicates.map((dup) => {
581
876
  const otherFile = dup.file1 === file ? dup.file2 : dup.file1;
582
- const severity2 = dup.similarity > 0.95 ? import_core4.Severity.Critical : dup.similarity > 0.9 ? import_core4.Severity.Major : import_core4.Severity.Minor;
877
+ let severityLevel;
878
+ if (dup.severity === "info" || dup.severity === "Info") {
879
+ severityLevel = import_core11.Severity.Info;
880
+ } else {
881
+ severityLevel = calculateSeverity2(dup.similarity);
882
+ }
583
883
  return {
584
- type: import_core4.IssueType.DuplicatePattern,
585
- severity: severity2,
884
+ type: import_core11.IssueType.DuplicatePattern,
885
+ severity: severityLevel,
586
886
  message: `${dup.patternType} pattern ${Math.round(dup.similarity * 100)}% similar to ${otherFile} (${dup.tokenCost} tokens wasted)`,
587
887
  location: {
588
888
  file,
@@ -591,18 +891,7 @@ async function analyzePatterns(options) {
591
891
  suggestion: getRefactoringSuggestion(dup.patternType, dup.similarity)
592
892
  };
593
893
  });
594
- let filteredIssues = issues;
595
- if (severity !== "all") {
596
- const severityMap = {
597
- critical: [import_core4.Severity.Critical],
598
- high: [import_core4.Severity.Critical, import_core4.Severity.Major],
599
- medium: [import_core4.Severity.Critical, import_core4.Severity.Major, import_core4.Severity.Minor]
600
- };
601
- const allowedSeverities = severityMap[severity] || [import_core4.Severity.Critical, import_core4.Severity.Major, import_core4.Severity.Minor];
602
- filteredIssues = issues.filter(
603
- (issue) => allowedSeverities.includes(issue.severity)
604
- );
605
- }
894
+ const filteredIssues = filterBySeverity2(issues, severity || "all");
606
895
  const totalTokenCost = fileDuplicates.reduce(
607
896
  (sum, dup) => sum + dup.tokenCost,
608
897
  0
@@ -631,60 +920,6 @@ async function analyzePatterns(options) {
631
920
  }
632
921
  return { results, duplicates, files, groups, clusters, config: finalOptions };
633
922
  }
634
- function generateSummary(results) {
635
- const allIssues = results.flatMap((r) => r.issues || []);
636
- const totalTokenCost = results.reduce(
637
- (sum, r) => sum + (r.metrics?.tokenCost || 0),
638
- 0
639
- );
640
- const patternsByType = {
641
- "api-handler": 0,
642
- validator: 0,
643
- utility: 0,
644
- "class-method": 0,
645
- component: 0,
646
- function: 0,
647
- unknown: 0
648
- };
649
- allIssues.forEach((issue) => {
650
- const match = issue.message.match(/^(\S+(?:-\S+)*) pattern/);
651
- if (match) {
652
- const type = match[1];
653
- patternsByType[type] = (patternsByType[type] || 0) + 1;
654
- }
655
- });
656
- const topDuplicates = allIssues.slice(0, 10).map((issue) => {
657
- const similarityMatch = issue.message.match(/(\d+)% similar/);
658
- const tokenMatch = issue.message.match(/\((\d+) tokens/);
659
- const typeMatch = issue.message.match(/^(\S+(?:-\S+)*) pattern/);
660
- const fileMatch = issue.message.match(/similar to (.+?) \(/);
661
- return {
662
- files: [
663
- {
664
- path: issue.location.file,
665
- startLine: issue.location.line,
666
- endLine: 0
667
- },
668
- {
669
- path: fileMatch?.[1] || "unknown",
670
- startLine: 0,
671
- endLine: 0
672
- }
673
- ],
674
- similarity: similarityMatch ? parseInt(similarityMatch[1]) / 100 : 0,
675
- confidence: similarityMatch ? parseInt(similarityMatch[1]) / 100 : 0,
676
- // Fallback for summary
677
- patternType: typeMatch?.[1] || "unknown",
678
- tokenCost: tokenMatch ? parseInt(tokenMatch[1]) : 0
679
- };
680
- });
681
- return {
682
- totalPatterns: allIssues.length,
683
- totalTokenCost,
684
- patternsByType,
685
- topDuplicates
686
- };
687
- }
688
923
  // Annotate the CommonJS export names for ESM import in node:
689
924
  0 && (module.exports = {
690
925
  analyzePatterns,