@aiready/pattern-detect 0.16.19 → 0.16.21

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 (56) hide show
  1. package/dist/analyzer-entry/index.d.mts +3 -0
  2. package/dist/analyzer-entry/index.d.ts +3 -0
  3. package/dist/analyzer-entry/index.js +693 -0
  4. package/dist/analyzer-entry/index.mjs +12 -0
  5. package/dist/analyzer-entry.d.mts +100 -3
  6. package/dist/analyzer-entry.d.ts +100 -3
  7. package/dist/analyzer-entry.js +9 -126
  8. package/dist/analyzer-entry.mjs +2 -2
  9. package/dist/chunk-65UQ5J2J.mjs +64 -0
  10. package/dist/chunk-6JTVOBJX.mjs +64 -0
  11. package/dist/chunk-BKRPSTT2.mjs +64 -0
  12. package/dist/chunk-CMWW24HW.mjs +259 -0
  13. package/dist/chunk-DNZS4ESD.mjs +391 -0
  14. package/dist/chunk-GLKAGFKX.mjs +391 -0
  15. package/dist/chunk-GREN7X5H.mjs +143 -0
  16. package/dist/chunk-JBUZ6YHE.mjs +391 -0
  17. package/dist/chunk-KWMNN3TG.mjs +391 -0
  18. package/dist/chunk-LYKRYBSM.mjs +64 -0
  19. package/dist/chunk-MHU3CL4R.mjs +64 -0
  20. package/dist/chunk-RS73WLNI.mjs +251 -0
  21. package/dist/chunk-SVCSIZ2A.mjs +259 -0
  22. package/dist/chunk-VGMM3L3O.mjs +143 -0
  23. package/dist/chunk-XNPID6FU.mjs +391 -0
  24. package/dist/cli.js +29 -147
  25. package/dist/cli.mjs +27 -25
  26. package/dist/context-rules-entry/index.d.mts +2 -0
  27. package/dist/context-rules-entry/index.d.ts +2 -0
  28. package/dist/context-rules-entry/index.js +207 -0
  29. package/dist/context-rules-entry/index.mjs +12 -0
  30. package/dist/context-rules-entry.d.mts +55 -2
  31. package/dist/context-rules-entry.d.ts +55 -2
  32. package/dist/detector-entry/index.d.mts +14 -0
  33. package/dist/detector-entry/index.d.ts +14 -0
  34. package/dist/detector-entry/index.js +301 -0
  35. package/dist/detector-entry/index.mjs +7 -0
  36. package/dist/detector-entry.d.mts +2 -2
  37. package/dist/detector-entry.d.ts +2 -2
  38. package/dist/detector-entry.js +9 -126
  39. package/dist/detector-entry.mjs +1 -1
  40. package/dist/index-BVz-HnZd.d.mts +119 -0
  41. package/dist/index-BwuoiCNm.d.ts +119 -0
  42. package/dist/index-y2uJSngh.d.mts +60 -0
  43. package/dist/index-y2uJSngh.d.ts +60 -0
  44. package/dist/index.d.mts +4 -4
  45. package/dist/index.d.ts +4 -4
  46. package/dist/index.js +9 -126
  47. package/dist/index.mjs +3 -3
  48. package/dist/scoring-entry/index.d.mts +23 -0
  49. package/dist/scoring-entry/index.d.ts +23 -0
  50. package/dist/scoring-entry/index.js +133 -0
  51. package/dist/scoring-entry/index.mjs +6 -0
  52. package/dist/scoring-entry.d.mts +1 -1
  53. package/dist/scoring-entry.d.ts +1 -1
  54. package/dist/types-C4lmb2Yh.d.mts +36 -0
  55. package/dist/types-C4lmb2Yh.d.ts +36 -0
  56. package/package.json +16 -16
package/dist/cli.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-UB3CGOQ7.mjs";
2
+ import "./chunk-6JTVOBJX.mjs";
3
3
  import {
4
4
  analyzePatterns,
5
5
  generateSummary
6
- } from "./chunk-WMOGJFME.mjs";
7
- import "./chunk-THF4RW63.mjs";
6
+ } from "./chunk-DNZS4ESD.mjs";
7
+ import "./chunk-VGMM3L3O.mjs";
8
8
  import {
9
9
  filterBySeverity
10
10
  } from "./chunk-I6ETJC7L.mjs";
@@ -23,7 +23,9 @@ import {
23
23
  resolveOutputPath,
24
24
  Severity,
25
25
  getSeverityBadge as getSeverityBadge2,
26
- getSeverityValue as getSeverityValue2
26
+ getSeverityValue as getSeverityValue2,
27
+ printTerminalHeader,
28
+ getTerminalDivider
27
29
  } from "@aiready/core";
28
30
 
29
31
  // src/cli-output.ts
@@ -32,6 +34,7 @@ import {
32
34
  getSeverityValue,
33
35
  generateReportHead,
34
36
  generateStatCards,
37
+ generateScoreCard,
35
38
  generateTable,
36
39
  generateReportFooter
37
40
  } from "@aiready/core";
@@ -52,10 +55,14 @@ function generateHTMLReport(results, summary) {
52
55
  const { metadata } = data;
53
56
  const s = data.summary;
54
57
  const head = generateReportHead("AIReady - Pattern Detection Report");
55
- const scoreCard = `<div class="stat-card" style="margin-bottom: 2rem;">
56
- <div class="stat-label">AI Ready Score (Deduplication)</div>
57
- <div class="stat-value">${Math.max(0, 100 - Math.round((s.duplicates?.length || 0) / (s.totalFiles || 1) * 20))}%</div>
58
- </div>`;
58
+ const score = Math.max(
59
+ 0,
60
+ 100 - Math.round((s.duplicates?.length || 0) / (s.totalFiles || 1) * 20)
61
+ );
62
+ const scoreCard = generateScoreCard(
63
+ `${score}%`,
64
+ "AI Ready Score (Deduplication)"
65
+ );
59
66
  const stats = generateStatCards([
60
67
  { value: s.totalFiles, label: "Files Analyzed" },
61
68
  { value: s.duplicates?.length || 0, label: "Duplicate Clusters" },
@@ -254,12 +261,7 @@ async function patternActionHandler(directory, options) {
254
261
  \u2713 HTML report saved to ${outputPath}`));
255
262
  return;
256
263
  }
257
- const terminalWidth = process.stdout.columns || 80;
258
- const dividerWidth = Math.min(60, terminalWidth - 2);
259
- const divider = "\u2501".repeat(dividerWidth);
260
- console.log(chalk.cyan(divider));
261
- console.log(chalk.bold.white(" PATTERN ANALYSIS SUMMARY"));
262
- console.log(chalk.cyan(divider) + "\n");
264
+ printTerminalHeader("PATTERN ANALYSIS SUMMARY");
263
265
  console.log(chalk.white(`\u{1F4C1} Files analyzed: ${chalk.bold(results.length)}`));
264
266
  console.log(
265
267
  chalk.yellow(
@@ -274,9 +276,9 @@ async function patternActionHandler(directory, options) {
274
276
  console.log(chalk.gray(`\u23F1 Analysis time: ${chalk.bold(elapsedTime + "s")}`));
275
277
  const sortedTypes = Object.entries(summary.patternsByType).filter(([, count]) => count > 0).sort(([, a], [, b]) => b - a);
276
278
  if (sortedTypes.length > 0) {
277
- console.log(chalk.cyan("\n" + divider));
279
+ console.log("\n" + getTerminalDivider());
278
280
  console.log(chalk.bold.white(" PATTERNS BY TYPE"));
279
- console.log(chalk.cyan(divider) + "\n");
281
+ console.log(getTerminalDivider() + "\n");
280
282
  sortedTypes.forEach(([type, count]) => {
281
283
  const icon = getPatternIcon(type);
282
284
  console.log(
@@ -285,11 +287,11 @@ async function patternActionHandler(directory, options) {
285
287
  });
286
288
  }
287
289
  if (!finalOptions.showRawDuplicates && groups && groups.length > 0) {
288
- console.log(chalk.cyan("\n" + divider));
290
+ console.log("\n" + getTerminalDivider());
289
291
  console.log(
290
292
  chalk.bold.white(` \u{1F4E6} DUPLICATE GROUPS (${groups.length} file pairs)`)
291
293
  );
292
- console.log(chalk.cyan(divider) + "\n");
294
+ console.log(getTerminalDivider() + "\n");
293
295
  const topGroups = groups.sort((a, b) => {
294
296
  const bVal = getSeverityValue2(b.severity);
295
297
  const aVal = getSeverityValue2(a.severity);
@@ -330,11 +332,11 @@ async function patternActionHandler(directory, options) {
330
332
  }
331
333
  }
332
334
  if (!finalOptions.showRawDuplicates && clusters && clusters.length > 0) {
333
- console.log(chalk.cyan("\n" + divider));
335
+ console.log("\n" + getTerminalDivider());
334
336
  console.log(
335
337
  chalk.bold.white(` \u{1F3AF} REFACTOR CLUSTERS (${clusters.length} patterns)`)
336
338
  );
337
- console.log(chalk.cyan(divider) + "\n");
339
+ console.log(getTerminalDivider() + "\n");
338
340
  clusters.sort((a, b) => b.totalTokenCost - a.totalTokenCost).forEach((cluster, idx) => {
339
341
  const severityBadge = getSeverityBadge2(cluster.severity);
340
342
  console.log(`${idx + 1}. ${severityBadge} ${chalk.bold(cluster.name)}`);
@@ -362,9 +364,9 @@ async function patternActionHandler(directory, options) {
362
364
  });
363
365
  }
364
366
  if (totalIssues > 0 && (finalOptions.showRawDuplicates || !groups || groups.length === 0)) {
365
- console.log(chalk.cyan("\n" + divider));
367
+ console.log("\n" + getTerminalDivider());
366
368
  console.log(chalk.bold.white(" TOP DUPLICATE PATTERNS"));
367
- console.log(chalk.cyan(divider) + "\n");
369
+ console.log(getTerminalDivider() + "\n");
368
370
  const topDuplicates = filteredDuplicates.sort((a, b) => {
369
371
  const bVal = getSeverityValue2(b.severity);
370
372
  const aVal = getSeverityValue2(a.severity);
@@ -411,9 +413,9 @@ async function patternActionHandler(directory, options) {
411
413
  (issue) => getSeverityValue2(issue.severity) === 4
412
414
  );
413
415
  if (criticalIssues.length > 0) {
414
- console.log(chalk.cyan(divider));
416
+ console.log(getTerminalDivider());
415
417
  console.log(chalk.bold.white(" CRITICAL ISSUES (>95% similar)"));
416
- console.log(chalk.cyan(divider) + "\n");
418
+ console.log(getTerminalDivider() + "\n");
417
419
  criticalIssues.slice(0, 5).forEach((issue) => {
418
420
  console.log(
419
421
  chalk.red("\u25CF ") + chalk.white(`${issue.file}:${issue.location.line}`)
@@ -450,7 +452,7 @@ async function patternActionHandler(directory, options) {
450
452
  );
451
453
  console.log("");
452
454
  }
453
- console.log(chalk.cyan(divider));
455
+ console.log(getTerminalDivider());
454
456
  if (totalIssues > 0) {
455
457
  console.log(
456
458
  chalk.white(
@@ -0,0 +1,2 @@
1
+ export { a as ContextRule, c as calculateSeverity, f as filterBySeverity, g as getSeverityLabel, b as getSeverityThreshold } from '../index-y2uJSngh.mjs';
2
+ import '@aiready/core';
@@ -0,0 +1,2 @@
1
+ export { a as ContextRule, c as calculateSeverity, f as filterBySeverity, g as getSeverityLabel, b as getSeverityThreshold } from '../index-y2uJSngh.js';
2
+ import '@aiready/core';
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/context-rules-entry/index.ts
21
+ var context_rules_entry_exports = {};
22
+ __export(context_rules_entry_exports, {
23
+ calculateSeverity: () => calculateSeverity,
24
+ filterBySeverity: () => filterBySeverity,
25
+ getSeverityLabel: () => getSeverityLabel,
26
+ getSeverityThreshold: () => getSeverityThreshold
27
+ });
28
+ module.exports = __toCommonJS(context_rules_entry_exports);
29
+
30
+ // src/context-rules.ts
31
+ var import_core = require("@aiready/core");
32
+ var CONTEXT_RULES = [
33
+ // Test Fixtures - Intentional duplication for test isolation
34
+ {
35
+ name: "test-fixtures",
36
+ detect: (file, code) => {
37
+ const isTestFile = file.includes(".test.") || file.includes(".spec.") || file.includes("__tests__") || file.includes("/test/") || file.includes("/tests/");
38
+ const hasTestFixtures = code.includes("beforeAll") || code.includes("afterAll") || code.includes("beforeEach") || code.includes("afterEach") || code.includes("setUp") || code.includes("tearDown");
39
+ return isTestFile && hasTestFixtures;
40
+ },
41
+ severity: import_core.Severity.Info,
42
+ reason: "Test fixture duplication is intentional for test isolation",
43
+ suggestion: "Consider if shared test setup would improve maintainability without coupling tests"
44
+ },
45
+ // Email/Document Templates - Often intentionally similar for consistency
46
+ {
47
+ name: "templates",
48
+ detect: (file, code) => {
49
+ const isTemplate = file.includes("/templates/") || file.includes("-template") || file.includes("/email-templates/") || file.includes("/emails/");
50
+ const hasTemplateContent = (code.includes("return") || code.includes("export")) && (code.includes("html") || code.includes("subject") || code.includes("body"));
51
+ return isTemplate && hasTemplateContent;
52
+ },
53
+ severity: import_core.Severity.Minor,
54
+ reason: "Template duplication may be intentional for maintainability and branding consistency",
55
+ suggestion: "Extract shared structure only if templates become hard to maintain"
56
+ },
57
+ // E2E/Integration Test Page Objects - Test independence
58
+ {
59
+ name: "e2e-page-objects",
60
+ 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;
64
+ },
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"
68
+ },
69
+ // Configuration Files - Often necessarily similar by design
70
+ {
71
+ name: "config-files",
72
+ detect: (file) => {
73
+ 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
+ },
75
+ severity: import_core.Severity.Minor,
76
+ reason: "Configuration files often have similar structure by design",
77
+ suggestion: "Consider shared config base only if configurations become hard to maintain"
78
+ },
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
+ // Migration Scripts - One-off scripts that are similar by nature
92
+ {
93
+ name: "migration-scripts",
94
+ detect: (file) => {
95
+ return file.includes("/migrations/") || file.includes("/migrate/") || file.includes(".migration.");
96
+ },
97
+ severity: import_core.Severity.Info,
98
+ reason: "Migration scripts are typically one-off and intentionally similar",
99
+ suggestion: "Duplication is acceptable for migration scripts"
100
+ },
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
+ // Tool Implementations - Structural Boilerplate
114
+ {
115
+ name: "tool-implementations",
116
+ detect: (file, code) => {
117
+ const isToolFile = file.includes("/tools/") || file.endsWith(".tool.ts") || code.includes("toolDefinitions");
118
+ const hasToolStructure = code.includes("execute") && (code.includes("try") || code.includes("catch"));
119
+ return isToolFile && hasToolStructure;
120
+ },
121
+ severity: import_core.Severity.Info,
122
+ reason: "Tool implementations share structural boilerplate but have distinct business logic",
123
+ suggestion: "Tool duplication is acceptable for boilerplate interface wrappers"
124
+ }
125
+ ];
126
+ function calculateSeverity(file1, file2, code, similarity, linesOfCode) {
127
+ for (const rule of CONTEXT_RULES) {
128
+ if (rule.detect(file1, code) || rule.detect(file2, code)) {
129
+ return {
130
+ severity: rule.severity,
131
+ reason: rule.reason,
132
+ suggestion: rule.suggestion,
133
+ matchedRule: rule.name
134
+ };
135
+ }
136
+ }
137
+ if (similarity >= 0.95 && linesOfCode >= 30) {
138
+ return {
139
+ severity: import_core.Severity.Critical,
140
+ reason: "Large nearly-identical code blocks waste tokens and create maintenance burden",
141
+ suggestion: "Extract to shared utility module immediately"
142
+ };
143
+ } else if (similarity >= 0.95 && linesOfCode >= 15) {
144
+ return {
145
+ severity: import_core.Severity.Major,
146
+ reason: "Nearly identical code should be consolidated",
147
+ suggestion: "Move to shared utility file"
148
+ };
149
+ } else if (similarity >= 0.85) {
150
+ return {
151
+ severity: import_core.Severity.Major,
152
+ reason: "High similarity indicates significant duplication",
153
+ suggestion: "Extract common logic to shared function"
154
+ };
155
+ } else if (similarity >= 0.7) {
156
+ return {
157
+ severity: import_core.Severity.Minor,
158
+ reason: "Moderate similarity detected",
159
+ suggestion: "Consider extracting shared patterns if code evolves together"
160
+ };
161
+ } else {
162
+ return {
163
+ severity: import_core.Severity.Minor,
164
+ reason: "Minor similarity detected",
165
+ suggestion: "Monitor but refactoring may not be worthwhile"
166
+ };
167
+ }
168
+ }
169
+ function getSeverityLabel(severity) {
170
+ const labels = {
171
+ [import_core.Severity.Critical]: "\u{1F534} CRITICAL",
172
+ [import_core.Severity.Major]: "\u{1F7E1} MAJOR",
173
+ [import_core.Severity.Minor]: "\u{1F535} MINOR",
174
+ [import_core.Severity.Info]: "\u2139\uFE0F INFO"
175
+ };
176
+ return labels[severity];
177
+ }
178
+ function filterBySeverity(duplicates, minSeverity) {
179
+ const severityOrder = [
180
+ import_core.Severity.Info,
181
+ import_core.Severity.Minor,
182
+ import_core.Severity.Major,
183
+ import_core.Severity.Critical
184
+ ];
185
+ const minIndex = severityOrder.indexOf(minSeverity);
186
+ if (minIndex === -1) return duplicates;
187
+ return duplicates.filter((dup) => {
188
+ const dupIndex = severityOrder.indexOf(dup.severity);
189
+ return dupIndex >= minIndex;
190
+ });
191
+ }
192
+ function getSeverityThreshold(severity) {
193
+ const thresholds = {
194
+ [import_core.Severity.Critical]: 0.95,
195
+ [import_core.Severity.Major]: 0.85,
196
+ [import_core.Severity.Minor]: 0.5,
197
+ [import_core.Severity.Info]: 0
198
+ };
199
+ return thresholds[severity] || 0;
200
+ }
201
+ // Annotate the CommonJS export names for ESM import in node:
202
+ 0 && (module.exports = {
203
+ calculateSeverity,
204
+ filterBySeverity,
205
+ getSeverityLabel,
206
+ getSeverityThreshold
207
+ });
@@ -0,0 +1,12 @@
1
+ import {
2
+ calculateSeverity,
3
+ filterBySeverity,
4
+ getSeverityLabel,
5
+ getSeverityThreshold
6
+ } from "../chunk-I6ETJC7L.mjs";
7
+ export {
8
+ calculateSeverity,
9
+ filterBySeverity,
10
+ getSeverityLabel,
11
+ getSeverityThreshold
12
+ };
@@ -1,2 +1,55 @@
1
- export { a as ContextRule, c as calculateSeverity, f as filterBySeverity, g as getSeverityLabel, b as getSeverityThreshold } from './context-rules-entry-y2uJSngh.mjs';
2
- import '@aiready/core';
1
+ import { Severity } from '@aiready/core';
2
+
3
+ /**
4
+ * Context-aware severity detection for duplicate patterns
5
+ * Identifies intentional duplication patterns and adjusts severity accordingly
6
+ */
7
+ interface ContextRule {
8
+ name: string;
9
+ detect: (file: string, code: string) => boolean;
10
+ severity: Severity;
11
+ reason: string;
12
+ suggestion?: string;
13
+ }
14
+ /**
15
+ * Calculate severity based on context rules and code characteristics
16
+ *
17
+ * @param file1 - First file path in the duplicate pair.
18
+ * @param file2 - Second file path in the duplicate pair.
19
+ * @param code - Snippet of the duplicated code.
20
+ * @param similarity - The calculated similarity score (0-1).
21
+ * @param linesOfCode - Number of lines in the duplicated block.
22
+ * @returns An object containing the severity level and reasoning.
23
+ */
24
+ declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
25
+ severity: Severity;
26
+ reason?: string;
27
+ suggestion?: string;
28
+ matchedRule?: string;
29
+ };
30
+ /**
31
+ * Get a human-readable severity label with emoji
32
+ *
33
+ * @param severity - The severity level to label.
34
+ * @returns Formatted label string for UI display.
35
+ */
36
+ declare function getSeverityLabel(severity: Severity): string;
37
+ /**
38
+ * Filter duplicates by minimum severity threshold
39
+ *
40
+ * @param duplicates - List of items with a severity property.
41
+ * @param minSeverity - Minimum threshold for inclusion.
42
+ * @returns Filtered list of items.
43
+ */
44
+ declare function filterBySeverity<T extends {
45
+ severity: Severity;
46
+ }>(duplicates: T[], minSeverity: Severity): T[];
47
+ /**
48
+ * Get numerical similarity threshold associated with a severity level
49
+ *
50
+ * @param severity - The severity level to look up.
51
+ * @returns Minimum similarity value for this severity.
52
+ */
53
+ declare function getSeverityThreshold(severity: Severity): number;
54
+
55
+ export { type ContextRule, calculateSeverity, filterBySeverity, getSeverityLabel, getSeverityThreshold };
@@ -1,2 +1,55 @@
1
- export { a as ContextRule, c as calculateSeverity, f as filterBySeverity, g as getSeverityLabel, b as getSeverityThreshold } from './context-rules-entry-y2uJSngh.js';
2
- import '@aiready/core';
1
+ import { Severity } from '@aiready/core';
2
+
3
+ /**
4
+ * Context-aware severity detection for duplicate patterns
5
+ * Identifies intentional duplication patterns and adjusts severity accordingly
6
+ */
7
+ interface ContextRule {
8
+ name: string;
9
+ detect: (file: string, code: string) => boolean;
10
+ severity: Severity;
11
+ reason: string;
12
+ suggestion?: string;
13
+ }
14
+ /**
15
+ * Calculate severity based on context rules and code characteristics
16
+ *
17
+ * @param file1 - First file path in the duplicate pair.
18
+ * @param file2 - Second file path in the duplicate pair.
19
+ * @param code - Snippet of the duplicated code.
20
+ * @param similarity - The calculated similarity score (0-1).
21
+ * @param linesOfCode - Number of lines in the duplicated block.
22
+ * @returns An object containing the severity level and reasoning.
23
+ */
24
+ declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
25
+ severity: Severity;
26
+ reason?: string;
27
+ suggestion?: string;
28
+ matchedRule?: string;
29
+ };
30
+ /**
31
+ * Get a human-readable severity label with emoji
32
+ *
33
+ * @param severity - The severity level to label.
34
+ * @returns Formatted label string for UI display.
35
+ */
36
+ declare function getSeverityLabel(severity: Severity): string;
37
+ /**
38
+ * Filter duplicates by minimum severity threshold
39
+ *
40
+ * @param duplicates - List of items with a severity property.
41
+ * @param minSeverity - Minimum threshold for inclusion.
42
+ * @returns Filtered list of items.
43
+ */
44
+ declare function filterBySeverity<T extends {
45
+ severity: Severity;
46
+ }>(duplicates: T[], minSeverity: Severity): T[];
47
+ /**
48
+ * Get numerical similarity threshold associated with a severity level
49
+ *
50
+ * @param severity - The severity level to look up.
51
+ * @returns Minimum similarity value for this severity.
52
+ */
53
+ declare function getSeverityThreshold(severity: Severity): number;
54
+
55
+ export { type ContextRule, calculateSeverity, filterBySeverity, getSeverityLabel, getSeverityThreshold };
@@ -0,0 +1,14 @@
1
+ import { a as DetectionOptions, D as DuplicatePattern } from '../types-DU2mmhwb.mjs';
2
+ export { P as PatternType } from '../types-DU2mmhwb.mjs';
3
+ import { FileContent } from '@aiready/core';
4
+
5
+ /**
6
+ * Detect duplicate patterns across files
7
+ *
8
+ * @param fileContents - Array of file contents to analyze.
9
+ * @param options - Configuration for duplicate detection (thresholds, progress, etc).
10
+ * @returns Promise resolving to an array of detected duplicate patterns sorted by similarity.
11
+ */
12
+ declare function detectDuplicatePatterns(fileContents: FileContent[], options: DetectionOptions): Promise<DuplicatePattern[]>;
13
+
14
+ export { DuplicatePattern, detectDuplicatePatterns };
@@ -0,0 +1,14 @@
1
+ import { a as DetectionOptions, D as DuplicatePattern } from '../types-DU2mmhwb.js';
2
+ export { P as PatternType } from '../types-DU2mmhwb.js';
3
+ import { FileContent } from '@aiready/core';
4
+
5
+ /**
6
+ * Detect duplicate patterns across files
7
+ *
8
+ * @param fileContents - Array of file contents to analyze.
9
+ * @param options - Configuration for duplicate detection (thresholds, progress, etc).
10
+ * @returns Promise resolving to an array of detected duplicate patterns sorted by similarity.
11
+ */
12
+ declare function detectDuplicatePatterns(fileContents: FileContent[], options: DetectionOptions): Promise<DuplicatePattern[]>;
13
+
14
+ export { DuplicatePattern, detectDuplicatePatterns };