@aiready/pattern-detect 0.14.1 → 0.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -286,12 +286,12 @@ async function detectDuplicatePatterns(fileContents, options) {
286
286
  );
287
287
  }
288
288
  }
289
+ const b1 = allBlocks[i];
290
+ const norm1 = normalizeCode(b1.code);
289
291
  for (let j = i + 1; j < allBlocks.length; j++) {
290
292
  comparisons++;
291
- const b1 = allBlocks[i];
292
293
  const b2 = allBlocks[j];
293
294
  if (b1.file === b2.file) continue;
294
- const norm1 = normalizeCode(b1.code);
295
295
  const norm2 = normalizeCode(b2.code);
296
296
  const sim = calculateSimilarity(norm1, norm2);
297
297
  if (sim >= minSimilarity) {
@@ -585,7 +585,8 @@ var PatternDetectProvider = {
585
585
  ),
586
586
  duplicates: results.duplicates,
587
587
  groups: results.groups,
588
- clusters: results.clusters
588
+ clusters: results.clusters,
589
+ config: results.config
589
590
  },
590
591
  metadata: {
591
592
  toolName: import_core5.ToolName.PatternDetect,
@@ -643,29 +644,26 @@ async function getSmartDefaults(directory, userOptions) {
643
644
  };
644
645
  const { scanFiles: scanFiles2 } = await import("@aiready/core");
645
646
  const files = await scanFiles2(scanOptions);
646
- const estimatedBlocks = files.length * 3;
647
- const maxCandidatesPerBlock = Math.max(
648
- 3,
649
- Math.min(10, Math.floor(3e4 / estimatedBlocks))
650
- );
651
- const minSimilarity = Math.min(0.75, 0.5 + estimatedBlocks / 1e4 * 0.25);
647
+ const fileCount = files.length;
648
+ const estimatedBlocks = fileCount * 5;
652
649
  const minLines = Math.max(
653
650
  6,
654
- Math.min(12, 6 + Math.floor(estimatedBlocks / 2e3))
655
- );
656
- const minSharedTokens = Math.max(
657
- 10,
658
- Math.min(20, 10 + Math.floor(estimatedBlocks / 2e3))
651
+ Math.min(20, 6 + Math.floor(estimatedBlocks / 1e3) * 2)
659
652
  );
653
+ const minSimilarity = Math.min(0.85, 0.5 + estimatedBlocks / 5e3 * 0.3);
660
654
  const batchSize = estimatedBlocks > 1e3 ? 200 : 100;
661
- const severity = estimatedBlocks > 5e3 ? "high" : "all";
655
+ const severity = estimatedBlocks > 3e3 ? "high" : "all";
656
+ const maxCandidatesPerBlock = Math.max(
657
+ 5,
658
+ Math.min(100, Math.floor(1e6 / estimatedBlocks))
659
+ );
662
660
  const defaults = {
663
661
  rootDir: directory,
664
662
  minSimilarity,
665
663
  minLines,
666
664
  batchSize,
667
665
  approx: true,
668
- minSharedTokens,
666
+ minSharedTokens: 10,
669
667
  maxCandidatesPerBlock,
670
668
  streamResults: false,
671
669
  severity,
@@ -794,7 +792,7 @@ async function analyzePatterns(options) {
794
792
  minClusterFiles
795
793
  );
796
794
  }
797
- return { results, duplicates, files, groups, clusters };
795
+ return { results, duplicates, files, groups, clusters, config: finalOptions };
798
796
  }
799
797
  function generateSummary(results) {
800
798
  const allIssues = results.flatMap((r) => r.issues);
package/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  analyzePatterns,
4
4
  filterBySeverity,
5
5
  generateSummary
6
- } from "./chunk-3WK24ZOX.mjs";
6
+ } from "./chunk-KC2CQMG2.mjs";
7
7
 
8
8
  // src/cli.ts
9
9
  import { Command } from "commander";
package/dist/index.d.mts CHANGED
@@ -150,6 +150,7 @@ declare function analyzePatterns(options: PatternDetectOptions): Promise<{
150
150
  files: string[];
151
151
  groups?: DuplicateGroup[];
152
152
  clusters?: RefactorCluster[];
153
+ config: PatternDetectOptions;
153
154
  }>;
154
155
  /**
155
156
  * Generate a summary of pattern analysis
package/dist/index.d.ts CHANGED
@@ -150,6 +150,7 @@ declare function analyzePatterns(options: PatternDetectOptions): Promise<{
150
150
  files: string[];
151
151
  groups?: DuplicateGroup[];
152
152
  clusters?: RefactorCluster[];
153
+ config: PatternDetectOptions;
153
154
  }>;
154
155
  /**
155
156
  * Generate a summary of pattern analysis
package/dist/index.js CHANGED
@@ -310,12 +310,12 @@ async function detectDuplicatePatterns(fileContents, options) {
310
310
  );
311
311
  }
312
312
  }
313
+ const b1 = allBlocks[i];
314
+ const norm1 = normalizeCode(b1.code);
313
315
  for (let j = i + 1; j < allBlocks.length; j++) {
314
316
  comparisons++;
315
- const b1 = allBlocks[i];
316
317
  const b2 = allBlocks[j];
317
318
  if (b1.file === b2.file) continue;
318
- const norm1 = normalizeCode(b1.code);
319
319
  const norm2 = normalizeCode(b2.code);
320
320
  const sim = calculateSimilarity(norm1, norm2);
321
321
  if (sim >= minSimilarity) {
@@ -609,7 +609,8 @@ var PatternDetectProvider = {
609
609
  ),
610
610
  duplicates: results.duplicates,
611
611
  groups: results.groups,
612
- clusters: results.clusters
612
+ clusters: results.clusters,
613
+ config: results.config
613
614
  },
614
615
  metadata: {
615
616
  toolName: import_core5.ToolName.PatternDetect,
@@ -667,29 +668,26 @@ async function getSmartDefaults(directory, userOptions) {
667
668
  };
668
669
  const { scanFiles: scanFiles2 } = await import("@aiready/core");
669
670
  const files = await scanFiles2(scanOptions);
670
- const estimatedBlocks = files.length * 3;
671
- const maxCandidatesPerBlock = Math.max(
672
- 3,
673
- Math.min(10, Math.floor(3e4 / estimatedBlocks))
674
- );
675
- const minSimilarity = Math.min(0.75, 0.5 + estimatedBlocks / 1e4 * 0.25);
671
+ const fileCount = files.length;
672
+ const estimatedBlocks = fileCount * 5;
676
673
  const minLines = Math.max(
677
674
  6,
678
- Math.min(12, 6 + Math.floor(estimatedBlocks / 2e3))
679
- );
680
- const minSharedTokens = Math.max(
681
- 10,
682
- Math.min(20, 10 + Math.floor(estimatedBlocks / 2e3))
675
+ Math.min(20, 6 + Math.floor(estimatedBlocks / 1e3) * 2)
683
676
  );
677
+ const minSimilarity = Math.min(0.85, 0.5 + estimatedBlocks / 5e3 * 0.3);
684
678
  const batchSize = estimatedBlocks > 1e3 ? 200 : 100;
685
- const severity = estimatedBlocks > 5e3 ? "high" : "all";
679
+ const severity = estimatedBlocks > 3e3 ? "high" : "all";
680
+ const maxCandidatesPerBlock = Math.max(
681
+ 5,
682
+ Math.min(100, Math.floor(1e6 / estimatedBlocks))
683
+ );
686
684
  const defaults = {
687
685
  rootDir: directory,
688
686
  minSimilarity,
689
687
  minLines,
690
688
  batchSize,
691
689
  approx: true,
692
- minSharedTokens,
690
+ minSharedTokens: 10,
693
691
  maxCandidatesPerBlock,
694
692
  streamResults: false,
695
693
  severity,
@@ -818,7 +816,7 @@ async function analyzePatterns(options) {
818
816
  minClusterFiles
819
817
  );
820
818
  }
821
- return { results, duplicates, files, groups, clusters };
819
+ return { results, duplicates, files, groups, clusters, config: finalOptions };
822
820
  }
823
821
  function generateSummary(results) {
824
822
  const allIssues = results.flatMap((r) => r.issues);
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  generateSummary,
10
10
  getSeverityLabel,
11
11
  getSmartDefaults
12
- } from "./chunk-3WK24ZOX.mjs";
12
+ } from "./chunk-KC2CQMG2.mjs";
13
13
  export {
14
14
  PatternDetectProvider,
15
15
  Severity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/pattern-detect",
3
- "version": "0.14.1",
3
+ "version": "0.14.4",
4
4
  "description": "Semantic duplicate pattern detection for AI-generated code - finds similar implementations that waste AI context tokens",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "commander": "^14.0.0",
47
47
  "chalk": "^5.3.0",
48
- "@aiready/core": "0.21.1"
48
+ "@aiready/core": "0.21.4"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.3.5",