@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
package/dist/cli.mjs CHANGED
@@ -2,11 +2,12 @@
2
2
  import {
3
3
  analyzePatterns,
4
4
  generateSummary
5
- } from "./chunk-K7BO57OO.mjs";
6
- import "./chunk-NQBYYWHJ.mjs";
5
+ } from "./chunk-P3BOCGVV.mjs";
6
+ import "./chunk-IPBGVPUX.mjs";
7
7
  import {
8
8
  filterBySeverity
9
- } from "./chunk-J2G742QF.mjs";
9
+ } from "./chunk-2P7BQHGR.mjs";
10
+ import "./chunk-PHJE6A3J.mjs";
10
11
 
11
12
  // src/cli.ts
12
13
  import { Command } from "commander";
@@ -1,2 +1,36 @@
1
- export { a as ContextRule, c as calculateSeverity, g as getSeverityThreshold } from '../index-szjQDBsm.mjs';
1
+ import { Severity } from '@aiready/core';
2
2
  export { filterBySeverity, getSeverityLabel } from '@aiready/core';
3
+
4
+ interface ContextRule {
5
+ name: string;
6
+ detect: (file: string, code: string) => boolean;
7
+ severity: Severity;
8
+ reason: string;
9
+ suggestion?: string;
10
+ }
11
+
12
+ /**
13
+ * Calculate severity based on context rules and code characteristics
14
+ *
15
+ * @param file1 - First file path in the duplicate pair.
16
+ * @param file2 - Second file path in the duplicate pair.
17
+ * @param code - Snippet of the duplicated code.
18
+ * @param similarity - The calculated similarity score (0-1).
19
+ * @param linesOfCode - Number of lines in the duplicated block.
20
+ * @returns An object containing the severity level and reasoning.
21
+ */
22
+ declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
23
+ severity: Severity;
24
+ reason?: string;
25
+ suggestion?: string;
26
+ matchedRule?: string;
27
+ };
28
+ /**
29
+ * Get numerical similarity threshold associated with a severity level
30
+ *
31
+ * @param severity - The severity level to look up.
32
+ * @returns Minimum similarity value for this severity.
33
+ */
34
+ declare function getSeverityThreshold(severity: Severity): number;
35
+
36
+ export { type ContextRule, calculateSeverity, getSeverityThreshold };
@@ -1,2 +1,36 @@
1
- export { a as ContextRule, c as calculateSeverity, g as getSeverityThreshold } from '../index-szjQDBsm.js';
1
+ import { Severity } from '@aiready/core';
2
2
  export { filterBySeverity, getSeverityLabel } from '@aiready/core';
3
+
4
+ interface ContextRule {
5
+ name: string;
6
+ detect: (file: string, code: string) => boolean;
7
+ severity: Severity;
8
+ reason: string;
9
+ suggestion?: string;
10
+ }
11
+
12
+ /**
13
+ * Calculate severity based on context rules and code characteristics
14
+ *
15
+ * @param file1 - First file path in the duplicate pair.
16
+ * @param file2 - Second file path in the duplicate pair.
17
+ * @param code - Snippet of the duplicated code.
18
+ * @param similarity - The calculated similarity score (0-1).
19
+ * @param linesOfCode - Number of lines in the duplicated block.
20
+ * @returns An object containing the severity level and reasoning.
21
+ */
22
+ declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
23
+ severity: Severity;
24
+ reason?: string;
25
+ suggestion?: string;
26
+ matchedRule?: string;
27
+ };
28
+ /**
29
+ * Get numerical similarity threshold associated with a severity level
30
+ *
31
+ * @param severity - The severity level to look up.
32
+ * @returns Minimum similarity value for this severity.
33
+ */
34
+ declare function getSeverityThreshold(severity: Severity): number;
35
+
36
+ export { type ContextRule, calculateSeverity, getSeverityThreshold };
@@ -21,15 +21,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var context_rules_entry_exports = {};
22
22
  __export(context_rules_entry_exports, {
23
23
  calculateSeverity: () => calculateSeverity,
24
- filterBySeverity: () => import_core.filterBySeverity,
25
- getSeverityLabel: () => import_core.getSeverityLabel,
24
+ filterBySeverity: () => import_core5.filterBySeverity,
25
+ getSeverityLabel: () => import_core5.getSeverityLabel,
26
26
  getSeverityThreshold: () => getSeverityThreshold
27
27
  });
28
28
  module.exports = __toCommonJS(context_rules_entry_exports);
29
29
 
30
30
  // src/context-rules.ts
31
+ var import_core5 = require("@aiready/core");
32
+
33
+ // src/rules/categories/test-rules.ts
31
34
  var import_core = require("@aiready/core");
32
- var CONTEXT_RULES = [
35
+ var TEST_RULES = [
33
36
  // Test Fixtures - Intentional duplication for test isolation
34
37
  {
35
38
  name: "test-fixtures",
@@ -42,6 +45,35 @@ var CONTEXT_RULES = [
42
45
  reason: "Test fixture duplication is intentional for test isolation",
43
46
  suggestion: "Consider if shared test setup would improve maintainability without coupling tests"
44
47
  },
48
+ // E2E/Integration Test Page Objects - Test independence
49
+ {
50
+ name: "e2e-page-objects",
51
+ detect: (file, code) => {
52
+ 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/");
53
+ const hasPageObjectPatterns = code.includes("page.") || code.includes("await page") || code.includes("locator") || code.includes("getBy") || code.includes("selector") || code.includes("click(") || code.includes("fill(");
54
+ return isE2ETest && hasPageObjectPatterns;
55
+ },
56
+ severity: import_core.Severity.Info,
57
+ reason: "E2E test duplication ensures test independence and reduces coupling",
58
+ suggestion: "Consider page object pattern only if duplication causes maintenance issues"
59
+ },
60
+ // Mock Data - Test data intentionally duplicated
61
+ {
62
+ name: "mock-data",
63
+ detect: (file, code) => {
64
+ const isMockFile = file.includes("/mocks/") || file.includes("/__mocks__/") || file.includes("/fixtures/") || file.includes(".mock.") || file.includes(".fixture.");
65
+ const hasMockData = code.includes("mock") || code.includes("Mock") || code.includes("fixture") || code.includes("stub") || code.includes("export const");
66
+ return isMockFile && hasMockData;
67
+ },
68
+ severity: import_core.Severity.Info,
69
+ reason: "Mock data duplication is expected for comprehensive test coverage",
70
+ suggestion: "Consider shared factories only for complex mock generation"
71
+ }
72
+ ];
73
+
74
+ // src/rules/categories/web-rules.ts
75
+ var import_core2 = require("@aiready/core");
76
+ var WEB_RULES = [
45
77
  // Email/Document Templates - Often intentionally similar for consistency
46
78
  {
47
79
  name: "templates",
@@ -50,66 +82,59 @@ var CONTEXT_RULES = [
50
82
  const hasTemplateContent = (code.includes("return") || code.includes("export")) && (code.includes("html") || code.includes("subject") || code.includes("body"));
51
83
  return isTemplate && hasTemplateContent;
52
84
  },
53
- severity: import_core.Severity.Minor,
85
+ severity: import_core2.Severity.Info,
54
86
  reason: "Template duplication may be intentional for maintainability and branding consistency",
55
87
  suggestion: "Extract shared structure only if templates become hard to maintain"
56
88
  },
57
- // E2E/Integration Test Page Objects - Test independence
89
+ // Common UI Event Handlers - Very specific patterns only
58
90
  {
59
- name: "e2e-page-objects",
91
+ name: "common-ui-handlers",
60
92
  detect: (file, code) => {
61
- 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/");
62
- const hasPageObjectPatterns = code.includes("page.") || code.includes("await page") || code.includes("locator") || code.includes("getBy") || code.includes("selector") || code.includes("click(") || code.includes("fill(");
63
- return isE2ETest && hasPageObjectPatterns;
93
+ const isUIFile = file.includes("/components/") || file.includes(".tsx") || file.includes(".jsx") || file.includes("/hooks/");
94
+ 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");
95
+ return isUIFile && hasCommonHandler;
64
96
  },
65
- severity: import_core.Severity.Minor,
66
- reason: "E2E test duplication ensures test independence and reduces coupling",
67
- suggestion: "Consider page object pattern only if duplication causes maintenance issues"
97
+ severity: import_core2.Severity.Info,
98
+ reason: "Common UI event handlers are boilerplate patterns that repeat across components",
99
+ suggestion: "Consider extracting to shared hooks (useClickOutside, useEscapeKey) only if causing maintenance issues"
68
100
  },
101
+ // Next.js Route Handler Patterns - Boilerplate API route patterns
102
+ {
103
+ name: "nextjs-route-handlers",
104
+ detect: (file, code) => {
105
+ const isRouteFile = file.includes("/api/") && (file.endsWith("/route.ts") || file.endsWith("/route.js"));
106
+ 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");
107
+ return isRouteFile && hasRoutePattern;
108
+ },
109
+ severity: import_core2.Severity.Info,
110
+ reason: "Next.js route handlers follow standard patterns and are intentionally similar across endpoints",
111
+ suggestion: "Route handler duplication is acceptable for API endpoint boilerplate"
112
+ }
113
+ ];
114
+
115
+ // src/rules/categories/infra-rules.ts
116
+ var import_core3 = require("@aiready/core");
117
+ var INFRA_RULES = [
69
118
  // Configuration Files - Often necessarily similar by design
70
119
  {
71
120
  name: "config-files",
72
121
  detect: (file) => {
73
122
  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");
74
123
  },
75
- severity: import_core.Severity.Minor,
124
+ severity: import_core3.Severity.Info,
76
125
  reason: "Configuration files often have similar structure by design",
77
126
  suggestion: "Consider shared config base only if configurations become hard to maintain"
78
127
  },
79
- // Type Definitions - Duplication for type safety and module independence
80
- {
81
- name: "type-definitions",
82
- detect: (file, code) => {
83
- const isTypeFile = file.endsWith(".d.ts") || file.includes("/types/");
84
- const hasTypeDefinitions = code.includes("interface ") || code.includes("type ") || code.includes("enum ");
85
- return isTypeFile && hasTypeDefinitions;
86
- },
87
- severity: import_core.Severity.Info,
88
- reason: "Type duplication may be intentional for module independence and type safety",
89
- suggestion: "Extract to shared types package only if causing maintenance burden"
90
- },
91
128
  // Migration Scripts - One-off scripts that are similar by nature
92
129
  {
93
130
  name: "migration-scripts",
94
131
  detect: (file) => {
95
132
  return file.includes("/migrations/") || file.includes("/migrate/") || file.includes(".migration.");
96
133
  },
97
- severity: import_core.Severity.Info,
134
+ severity: import_core3.Severity.Info,
98
135
  reason: "Migration scripts are typically one-off and intentionally similar",
99
136
  suggestion: "Duplication is acceptable for migration scripts"
100
137
  },
101
- // Mock Data - Test data intentionally duplicated
102
- {
103
- name: "mock-data",
104
- detect: (file, code) => {
105
- const isMockFile = file.includes("/mocks/") || file.includes("/__mocks__/") || file.includes("/fixtures/") || file.includes(".mock.") || file.includes(".fixture.");
106
- const hasMockData = code.includes("mock") || code.includes("Mock") || code.includes("fixture") || code.includes("stub") || code.includes("export const");
107
- return isMockFile && hasMockData;
108
- },
109
- severity: import_core.Severity.Info,
110
- reason: "Mock data duplication is expected for comprehensive test coverage",
111
- suggestion: "Consider shared factories only for complex mock generation"
112
- },
113
138
  // Tool Implementations - Structural Boilerplate
114
139
  {
115
140
  name: "tool-implementations",
@@ -118,11 +143,132 @@ var CONTEXT_RULES = [
118
143
  const hasToolStructure = code.includes("execute") && (code.includes("try") || code.includes("catch"));
119
144
  return isToolFile && hasToolStructure;
120
145
  },
121
- severity: import_core.Severity.Info,
146
+ severity: import_core3.Severity.Info,
122
147
  reason: "Tool implementations share structural boilerplate but have distinct business logic",
123
148
  suggestion: "Tool duplication is acceptable for boilerplate interface wrappers"
149
+ },
150
+ // CLI Command Definitions - Commander.js boilerplate patterns
151
+ {
152
+ name: "cli-command-definitions",
153
+ detect: (file, code) => {
154
+ const isCliFile = file.includes("/commands/") || file.includes("/cli/") || file.endsWith(".command.ts");
155
+ const hasCommandPattern = (code.includes(".command(") || code.includes("defineCommand")) && (code.includes(".description(") || code.includes(".option(")) && (code.includes(".action(") || code.includes("async"));
156
+ return isCliFile && hasCommandPattern;
157
+ },
158
+ severity: import_core3.Severity.Info,
159
+ reason: "CLI command definitions follow standard Commander.js patterns and are intentionally similar",
160
+ suggestion: "Command boilerplate duplication is acceptable for CLI interfaces"
124
161
  }
125
162
  ];
163
+
164
+ // src/rules/categories/logic-rules.ts
165
+ var import_core4 = require("@aiready/core");
166
+ var LOGIC_RULES = [
167
+ // Type Definitions - Duplication for type safety and module independence
168
+ {
169
+ name: "type-definitions",
170
+ detect: (file, code) => {
171
+ const isTypeFile = file.endsWith(".d.ts") || file.includes("/types/");
172
+ 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");
173
+ const isInterfaceOnlySnippet = code.trim().startsWith("interface ") && code.includes("{") && code.includes("}") && !code.includes("function ") && !code.includes("const ") && !code.includes("return ");
174
+ return isTypeFile && hasOnlyTypeDefinitions || isInterfaceOnlySnippet;
175
+ },
176
+ severity: import_core4.Severity.Info,
177
+ reason: "Type/interface definitions are intentionally duplicated for module independence",
178
+ suggestion: "Extract to shared types package only if causing maintenance burden"
179
+ },
180
+ // Utility Functions - Small helpers in dedicated utility files
181
+ {
182
+ name: "utility-functions",
183
+ detect: (file, code) => {
184
+ const isUtilFile = file.endsWith(".util.ts") || file.endsWith(".helper.ts") || file.endsWith(".utils.ts");
185
+ const hasUtilPattern = code.includes("function format") || code.includes("function parse") || code.includes("function sanitize") || code.includes("function normalize") || code.includes("function convert");
186
+ return isUtilFile && hasUtilPattern;
187
+ },
188
+ severity: import_core4.Severity.Info,
189
+ reason: "Utility functions in dedicated utility files may be intentionally similar",
190
+ suggestion: "Consider extracting to shared utilities only if causing significant duplication"
191
+ },
192
+ // React/Vue Hooks - Standard patterns
193
+ {
194
+ name: "shared-hooks",
195
+ detect: (file, code) => {
196
+ const isHookFile = file.includes("/hooks/") || file.endsWith(".hook.ts") || file.endsWith(".hook.tsx");
197
+ const hasHookPattern = code.includes("function use") || code.includes("export function use") || code.includes("const use") || code.includes("export const use");
198
+ return isHookFile && hasHookPattern;
199
+ },
200
+ severity: import_core4.Severity.Info,
201
+ reason: "Hooks follow standard patterns and are often intentionally similar across components",
202
+ suggestion: "Consider extracting common hook logic only if hooks become complex"
203
+ },
204
+ // Score/Rating Helper Functions - Common threshold patterns
205
+ {
206
+ name: "score-helpers",
207
+ detect: (file, code) => {
208
+ const isHelperFile = file.includes("/utils/") || file.includes("/helpers/") || file.endsWith(".util.ts");
209
+ const hasScorePattern = (code.includes("if (score >=") || code.includes("if (score >")) && code.includes("return") && code.includes("'") && code.split("if (score").length >= 3;
210
+ return isHelperFile && hasScorePattern;
211
+ },
212
+ severity: import_core4.Severity.Info,
213
+ reason: "Score/rating helper functions use common threshold patterns that are intentionally similar",
214
+ suggestion: "Score formatting duplication is acceptable for consistent UI display"
215
+ },
216
+ // D3/Canvas Event Handlers - Standard visualization patterns
217
+ {
218
+ name: "visualization-handlers",
219
+ detect: (file, code) => {
220
+ const isVizFile = file.includes("/visualizer/") || file.includes("/charts/") || file.includes("GraphCanvas") || file.includes("ForceDirected");
221
+ const hasVizPattern = (code.includes("dragstarted") || code.includes("dragged") || code.includes("dragended")) && (code.includes("simulation") || code.includes("d3.") || code.includes("alphaTarget"));
222
+ return isVizFile && hasVizPattern;
223
+ },
224
+ severity: import_core4.Severity.Info,
225
+ reason: "D3/visualization event handlers follow standard patterns and are intentionally similar",
226
+ suggestion: "Visualization boilerplate duplication is acceptable for interactive charts"
227
+ },
228
+ // Icon/Switch Statement Helpers - Common enum-to-value patterns
229
+ {
230
+ name: "switch-helpers",
231
+ detect: (file, code) => {
232
+ const hasSwitchPattern = code.includes("switch (") && code.includes("case '") && code.includes("return") && code.split("case ").length >= 4;
233
+ const hasIconPattern = code.includes("getIcon") || code.includes("getColor") || code.includes("getLabel") || code.includes("getRating");
234
+ return hasSwitchPattern && hasIconPattern;
235
+ },
236
+ severity: import_core4.Severity.Info,
237
+ reason: "Switch statement helpers for enum-to-value mapping are inherently similar",
238
+ suggestion: "Switch duplication is acceptable for mapping enums to display values"
239
+ },
240
+ // Common API/Utility Functions - Legitimate duplication across modules
241
+ {
242
+ name: "common-api-functions",
243
+ detect: (file, code) => {
244
+ const isApiFile = file.includes("/api/") || file.includes("/lib/") || file.includes("/utils/") || file.endsWith(".ts");
245
+ 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");
246
+ return isApiFile && hasCommonApiPattern;
247
+ },
248
+ severity: import_core4.Severity.Info,
249
+ reason: "Common API/utility functions are legitimately duplicated across modules for clarity and independence",
250
+ suggestion: "Consider extracting to shared utilities only if causing significant duplication"
251
+ },
252
+ // Validation Functions - Inherently similar patterns
253
+ {
254
+ name: "validation-functions",
255
+ detect: (file, code) => {
256
+ 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");
257
+ return hasValidationPattern;
258
+ },
259
+ severity: import_core4.Severity.Info,
260
+ reason: "Validation functions are inherently similar and often intentionally duplicated for domain clarity",
261
+ suggestion: "Consider extracting to shared validators only if validation logic becomes complex"
262
+ }
263
+ ];
264
+
265
+ // src/context-rules.ts
266
+ var CONTEXT_RULES = [
267
+ ...TEST_RULES,
268
+ ...WEB_RULES,
269
+ ...INFRA_RULES,
270
+ ...LOGIC_RULES
271
+ ];
126
272
  function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
127
273
  for (const rule of CONTEXT_RULES) {
128
274
  if (rule.detect(file1, code) || rule.detect(file2, code)) {
@@ -136,31 +282,31 @@ function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
136
282
  }
137
283
  if (similarity >= 0.95 && linesOfCode >= 30) {
138
284
  return {
139
- severity: import_core.Severity.Critical,
285
+ severity: import_core5.Severity.Critical,
140
286
  reason: "Large nearly-identical code blocks waste tokens and create maintenance burden",
141
287
  suggestion: "Extract to shared utility module immediately"
142
288
  };
143
289
  } else if (similarity >= 0.95 && linesOfCode >= 15) {
144
290
  return {
145
- severity: import_core.Severity.Major,
291
+ severity: import_core5.Severity.Major,
146
292
  reason: "Nearly identical code should be consolidated",
147
293
  suggestion: "Move to shared utility file"
148
294
  };
149
295
  } else if (similarity >= 0.85) {
150
296
  return {
151
- severity: import_core.Severity.Major,
297
+ severity: import_core5.Severity.Major,
152
298
  reason: "High similarity indicates significant duplication",
153
299
  suggestion: "Extract common logic to shared function"
154
300
  };
155
301
  } else if (similarity >= 0.7) {
156
302
  return {
157
- severity: import_core.Severity.Minor,
303
+ severity: import_core5.Severity.Minor,
158
304
  reason: "Moderate similarity detected",
159
305
  suggestion: "Consider extracting shared patterns if code evolves together"
160
306
  };
161
307
  } else {
162
308
  return {
163
- severity: import_core.Severity.Minor,
309
+ severity: import_core5.Severity.Minor,
164
310
  reason: "Minor similarity detected",
165
311
  suggestion: "Monitor but refactoring may not be worthwhile"
166
312
  };
@@ -168,10 +314,10 @@ function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
168
314
  }
169
315
  function getSeverityThreshold(severity) {
170
316
  const thresholds = {
171
- [import_core.Severity.Critical]: 0.95,
172
- [import_core.Severity.Major]: 0.85,
173
- [import_core.Severity.Minor]: 0.5,
174
- [import_core.Severity.Info]: 0
317
+ [import_core5.Severity.Critical]: 0.95,
318
+ [import_core5.Severity.Major]: 0.85,
319
+ [import_core5.Severity.Minor]: 0.5,
320
+ [import_core5.Severity.Info]: 0
175
321
  };
176
322
  return thresholds[severity] || 0;
177
323
  }
@@ -3,7 +3,7 @@ import {
3
3
  filterBySeverity,
4
4
  getSeverityLabel,
5
5
  getSeverityThreshold
6
- } from "../chunk-J2G742QF.mjs";
6
+ } from "../chunk-2P7BQHGR.mjs";
7
7
  export {
8
8
  calculateSeverity,
9
9
  filterBySeverity,