@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.
- package/dist/analyzer-entry/index.d.mts +1 -1
- package/dist/analyzer-entry/index.d.ts +1 -1
- package/dist/analyzer-entry/index.js +370 -135
- package/dist/analyzer-entry/index.mjs +4 -3
- package/dist/chunk-2P7BQHGR.mjs +306 -0
- package/dist/{chunk-VGMM3L3O.mjs → chunk-3EORD7DC.mjs} +1 -1
- package/dist/{chunk-GREN7X5H.mjs → chunk-4PVPQMRT.mjs} +2 -2
- package/dist/{chunk-RS73WLNI.mjs → chunk-6VDL7TAS.mjs} +5 -113
- package/dist/chunk-AQIP4JGM.mjs +283 -0
- package/dist/{chunk-JBUZ6YHE.mjs → chunk-B4NLWKPZ.mjs} +85 -9
- package/dist/chunk-IPBGVPUX.mjs +143 -0
- package/dist/chunk-LUUJOUK5.mjs +283 -0
- package/dist/chunk-P3BOCGVV.mjs +498 -0
- package/dist/{scoring-entry.js → chunk-PHJE6A3J.mjs} +20 -37
- package/dist/chunk-PQXOORR4.mjs +234 -0
- package/dist/{chunk-GLKAGFKX.mjs → chunk-RDR75DVI.mjs} +85 -9
- package/dist/chunk-SXVLRPMF.mjs +143 -0
- package/dist/{chunk-DNZS4ESD.mjs → chunk-SY7RX5YQ.mjs} +85 -9
- package/dist/{context-rules-entry.js → chunk-TIBF7KST.mjs} +81 -78
- package/dist/chunk-WYYSQX5M.mjs +467 -0
- package/dist/{chunk-I6ETJC7L.mjs → chunk-X553BOMI.mjs} +56 -26
- package/dist/{chunk-K7BO57OO.mjs → chunk-Y6OB7K34.mjs} +80 -4
- package/dist/chunk-YLVV6YZ5.mjs +143 -0
- package/dist/chunk-ZUWPFVJV.mjs +115 -0
- package/dist/chunk-ZZMONVPE.mjs +467 -0
- package/dist/cli.js +402 -167
- package/dist/cli.mjs +4 -3
- package/dist/context-rules-entry/index.d.mts +35 -1
- package/dist/context-rules-entry/index.d.ts +35 -1
- package/dist/context-rules-entry/index.js +194 -48
- package/dist/context-rules-entry/index.mjs +1 -1
- package/dist/detector-entry/index.js +192 -46
- package/dist/detector-entry/index.mjs +2 -2
- package/dist/{analyzer-entry-BVz-HnZd.d.mts → index-B-pnXpgn.d.mts} +10 -1
- package/dist/{index-BwuoiCNm.d.ts → index-CWgYOKaK.d.ts} +35 -16
- package/dist/{index-BVz-HnZd.d.mts → index-Dl4BrGIT.d.mts} +35 -16
- package/dist/{analyzer-entry-BwuoiCNm.d.ts → index-DqS2e0kK.d.ts} +10 -1
- package/dist/index.d.mts +5 -6
- package/dist/index.d.ts +5 -6
- package/dist/index.js +467 -214
- package/dist/index.mjs +37 -22
- package/dist/scoring-entry/index.js +7 -3
- package/dist/scoring-entry/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/analyzer-entry.d.mts +0 -100
- package/dist/analyzer-entry.d.ts +0 -100
- package/dist/analyzer-entry.js +0 -693
- package/dist/analyzer-entry.mjs +0 -12
- package/dist/chunk-262N2JB7.mjs +0 -497
- package/dist/chunk-2R7HOR5H.mjs +0 -777
- package/dist/chunk-3D7RVGHM.mjs +0 -64
- package/dist/chunk-3LS3E6MO.mjs +0 -508
- package/dist/chunk-3VRQYFW3.mjs +0 -782
- package/dist/chunk-3WK24ZOX.mjs +0 -860
- package/dist/chunk-3YYN6ZXN.mjs +0 -1038
- package/dist/chunk-4BPRGZRG.mjs +0 -1041
- package/dist/chunk-4UHDGB7U.mjs +0 -920
- package/dist/chunk-5LYDB7DY.mjs +0 -771
- package/dist/chunk-65G3HXLQ.mjs +0 -497
- package/dist/chunk-65UQ5J2J.mjs +0 -64
- package/dist/chunk-6JTVOBJX.mjs +0 -64
- package/dist/chunk-6OEHUI5J.mjs +0 -1045
- package/dist/chunk-6YUGU4P4.mjs +0 -914
- package/dist/chunk-7EJGNGXM.mjs +0 -771
- package/dist/chunk-7O2DUBSN.mjs +0 -1058
- package/dist/chunk-7S4AUL5S.mjs +0 -911
- package/dist/chunk-A76JUWER.mjs +0 -786
- package/dist/chunk-AJZUNNFH.mjs +0 -817
- package/dist/chunk-AXHGYYYZ.mjs +0 -404
- package/dist/chunk-BKRPSTT2.mjs +0 -64
- package/dist/chunk-BUBQ3W6W.mjs +0 -980
- package/dist/chunk-CCHM2VLK.mjs +0 -1051
- package/dist/chunk-CHFK6EBT.mjs +0 -419
- package/dist/chunk-CMT3MWWO.mjs +0 -948
- package/dist/chunk-CMWW24HW.mjs +0 -259
- package/dist/chunk-CTDBJP25.mjs +0 -1043
- package/dist/chunk-DGAKXYIP.mjs +0 -1041
- package/dist/chunk-DQSLTL7J.mjs +0 -788
- package/dist/chunk-DR5W7S3Z.mjs +0 -968
- package/dist/chunk-EFUKPMBE.mjs +0 -950
- package/dist/chunk-EVBFDILL.mjs +0 -927
- package/dist/chunk-EXORBAXR.mjs +0 -887
- package/dist/chunk-EZT3NZGB.mjs +0 -1057
- package/dist/chunk-FWUKMJEQ.mjs +0 -1133
- package/dist/chunk-GSJFORRO.mjs +0 -504
- package/dist/chunk-H4ADJYOG.mjs +0 -925
- package/dist/chunk-H5FB2USZ.mjs +0 -762
- package/dist/chunk-H73HEG7M.mjs +0 -670
- package/dist/chunk-HOS5Z2NC.mjs +0 -669
- package/dist/chunk-HXHQOQB5.mjs +0 -508
- package/dist/chunk-INEOYHUM.mjs +0 -911
- package/dist/chunk-INJ4SBTV.mjs +0 -754
- package/dist/chunk-J5CW6NYY.mjs +0 -64
- package/dist/chunk-JAFZCZAP.mjs +0 -776
- package/dist/chunk-JKVKOXYR.mjs +0 -407
- package/dist/chunk-JTHW7EYW.mjs +0 -1041
- package/dist/chunk-JWR3AHKO.mjs +0 -788
- package/dist/chunk-KC2CQMG2.mjs +0 -858
- package/dist/chunk-KDWGWBP5.mjs +0 -832
- package/dist/chunk-KPEK5REL.mjs +0 -919
- package/dist/chunk-KT6O2IAE.mjs +0 -861
- package/dist/chunk-KWMNN3TG.mjs +0 -391
- package/dist/chunk-LUA5FXSZ.mjs +0 -771
- package/dist/chunk-LYKRYBSM.mjs +0 -64
- package/dist/chunk-M4PQMW34.mjs +0 -480
- package/dist/chunk-MH6LBXZF.mjs +0 -816
- package/dist/chunk-MHU3CL4R.mjs +0 -64
- package/dist/chunk-MJWBS6SM.mjs +0 -1058
- package/dist/chunk-OFGMDX66.mjs +0 -402
- package/dist/chunk-P7B6Z4I2.mjs +0 -1043
- package/dist/chunk-PBCXSG7E.mjs +0 -658
- package/dist/chunk-PEEHSFDR.mjs +0 -1058
- package/dist/chunk-PSVG2NLH.mjs +0 -966
- package/dist/chunk-PWNQ6JZW.mjs +0 -508
- package/dist/chunk-QE4E3F7C.mjs +0 -410
- package/dist/chunk-QEP76HGK.mjs +0 -1039
- package/dist/chunk-QX2BQJEO.mjs +0 -1058
- package/dist/chunk-R2S73CVG.mjs +0 -503
- package/dist/chunk-RMGDSNLE.mjs +0 -770
- package/dist/chunk-S2KQFII2.mjs +0 -491
- package/dist/chunk-SLDK5PQK.mjs +0 -1129
- package/dist/chunk-SNSDVGWW.mjs +0 -783
- package/dist/chunk-SUUZMLPS.mjs +0 -391
- package/dist/chunk-SVCSIZ2A.mjs +0 -259
- package/dist/chunk-T2C6WS73.mjs +0 -670
- package/dist/chunk-TCG2G32F.mjs +0 -911
- package/dist/chunk-TGBZP7SB.mjs +0 -773
- package/dist/chunk-THF4RW63.mjs +0 -254
- package/dist/chunk-TJKDLVLN.mjs +0 -503
- package/dist/chunk-TXWPOVYU.mjs +0 -402
- package/dist/chunk-UB3CGOQ7.mjs +0 -64
- package/dist/chunk-UKIKN27B.mjs +0 -950
- package/dist/chunk-V5DP4FP6.mjs +0 -876
- package/dist/chunk-VRMXVYDZ.mjs +0 -419
- package/dist/chunk-WACZ5LFH.mjs +0 -1055
- package/dist/chunk-WC7CBAA7.mjs +0 -1058
- package/dist/chunk-WKBCNITM.mjs +0 -1072
- package/dist/chunk-WMOGJFME.mjs +0 -391
- package/dist/chunk-X4GR2N2M.mjs +0 -947
- package/dist/chunk-XCWY2DQY.mjs +0 -788
- package/dist/chunk-XJD35DS6.mjs +0 -1058
- package/dist/chunk-XNPID6FU.mjs +0 -391
- package/dist/chunk-XUUVS54V.mjs +0 -776
- package/dist/chunk-YCGV65F5.mjs +0 -508
- package/dist/chunk-YJYDBFT3.mjs +0 -780
- package/dist/chunk-YP3HEDQW.mjs +0 -859
- package/dist/chunk-YSDOUNJJ.mjs +0 -1142
- package/dist/chunk-Z6GBFFOV.mjs +0 -1040
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/context-rules-entry-y2uJSngh.d.mts +0 -60
- package/dist/context-rules-entry-y2uJSngh.d.ts +0 -60
- package/dist/context-rules-entry.d.mts +0 -55
- package/dist/context-rules-entry.d.ts +0 -55
- package/dist/context-rules-entry.mjs +0 -12
- package/dist/context-rules.d.ts +0 -41
- package/dist/context-rules.d.ts.map +0 -1
- package/dist/context-rules.js +0 -225
- package/dist/context-rules.js.map +0 -1
- package/dist/detector-entry.d.mts +0 -14
- package/dist/detector-entry.d.ts +0 -14
- package/dist/detector-entry.js +0 -301
- package/dist/detector-entry.mjs +0 -7
- package/dist/detector.d.ts +0 -40
- package/dist/detector.d.ts.map +0 -1
- package/dist/detector.js +0 -385
- package/dist/detector.js.map +0 -1
- package/dist/extractors/python-extractor.d.ts +0 -19
- package/dist/extractors/python-extractor.d.ts.map +0 -1
- package/dist/extractors/python-extractor.js +0 -164
- package/dist/extractors/python-extractor.js.map +0 -1
- package/dist/grouping.d.ts +0 -54
- package/dist/grouping.d.ts.map +0 -1
- package/dist/grouping.js +0 -347
- package/dist/grouping.js.map +0 -1
- package/dist/index-y2uJSngh.d.mts +0 -60
- package/dist/index-y2uJSngh.d.ts +0 -60
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/python-extractor-BGKGX6BK.mjs +0 -131
- package/dist/python-extractor-ELAKYK2W.mjs +0 -140
- package/dist/scoring-entry.d.mts +0 -23
- package/dist/scoring-entry.d.ts +0 -23
- package/dist/scoring-entry.mjs +0 -6
- package/dist/scoring.d.ts +0 -12
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -116
- package/dist/scoring.js.map +0 -1
- package/dist/types-C4lmb2Yh.d.mts +0 -36
- package/dist/types-C4lmb2Yh.d.ts +0 -36
package/dist/index.mjs
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Severity,
|
|
2
3
|
analyzePatterns,
|
|
4
|
+
areBrandSpecificVariants,
|
|
5
|
+
calculateSeverity,
|
|
3
6
|
createRefactorClusters,
|
|
7
|
+
filterBrandSpecificVariants,
|
|
8
|
+
filterBySeverity as filterBySeverity2,
|
|
4
9
|
filterClustersByImpact,
|
|
5
10
|
generateSummary,
|
|
11
|
+
getSeverityLabel,
|
|
6
12
|
getSmartDefaults,
|
|
7
|
-
groupDuplicatesByFilePair
|
|
8
|
-
|
|
13
|
+
groupDuplicatesByFilePair,
|
|
14
|
+
logConfiguration
|
|
15
|
+
} from "./chunk-P3BOCGVV.mjs";
|
|
9
16
|
import {
|
|
10
17
|
detectDuplicatePatterns
|
|
11
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-IPBGVPUX.mjs";
|
|
12
19
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
calculateSeverity,
|
|
16
|
-
filterBySeverity,
|
|
17
|
-
getSeverityLabel,
|
|
18
|
-
getSeverityThreshold
|
|
19
|
-
} from "./chunk-J2G742QF.mjs";
|
|
20
|
+
filterBySeverity
|
|
21
|
+
} from "./chunk-2P7BQHGR.mjs";
|
|
20
22
|
import {
|
|
21
23
|
calculatePatternScore
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-PHJE6A3J.mjs";
|
|
23
25
|
|
|
24
26
|
// src/index.ts
|
|
25
|
-
import { ToolRegistry
|
|
27
|
+
import { ToolRegistry } from "@aiready/core";
|
|
26
28
|
|
|
27
29
|
// src/provider.ts
|
|
28
30
|
import {
|
|
29
31
|
ToolName,
|
|
30
32
|
SpokeOutputSchema,
|
|
31
|
-
GLOBAL_SCAN_OPTIONS
|
|
33
|
+
GLOBAL_SCAN_OPTIONS,
|
|
34
|
+
Severity as Severity2
|
|
32
35
|
} from "@aiready/core";
|
|
33
|
-
var
|
|
36
|
+
var PATTERN_DETECT_PROVIDER = {
|
|
34
37
|
id: ToolName.PatternDetect,
|
|
35
38
|
alias: ["patterns", "duplicates", "duplication"],
|
|
36
39
|
async analyze(options) {
|
|
@@ -61,30 +64,42 @@ var PatternDetectProvider = {
|
|
|
61
64
|
},
|
|
62
65
|
score(output, options) {
|
|
63
66
|
const duplicates = output.summary.duplicates || [];
|
|
64
|
-
const scoreData = duplicates;
|
|
65
67
|
const totalFiles = output.summary.totalFiles || output.results.length;
|
|
68
|
+
let scoreData = duplicates;
|
|
69
|
+
const patternOptions = options;
|
|
70
|
+
if (patternOptions.severity && patternOptions.severity !== "all") {
|
|
71
|
+
const severityMap = {
|
|
72
|
+
critical: Severity2.Critical,
|
|
73
|
+
high: Severity2.Major,
|
|
74
|
+
// 'high' maps to Major and above
|
|
75
|
+
medium: Severity2.Minor,
|
|
76
|
+
all: Severity2.Info
|
|
77
|
+
};
|
|
78
|
+
const minSeverity = severityMap[patternOptions.severity] || Severity2.Info;
|
|
79
|
+
scoreData = filterBySeverity(duplicates, minSeverity);
|
|
80
|
+
}
|
|
66
81
|
return calculatePatternScore(scoreData, totalFiles, options.costConfig);
|
|
67
82
|
},
|
|
68
83
|
defaultWeight: 22
|
|
69
84
|
};
|
|
70
85
|
|
|
71
86
|
// src/index.ts
|
|
72
|
-
ToolRegistry.register(
|
|
87
|
+
ToolRegistry.register(PATTERN_DETECT_PROVIDER);
|
|
73
88
|
export {
|
|
74
|
-
|
|
75
|
-
IssueType,
|
|
76
|
-
PatternDetectProvider,
|
|
89
|
+
PATTERN_DETECT_PROVIDER,
|
|
77
90
|
Severity,
|
|
78
91
|
analyzePatterns,
|
|
92
|
+
areBrandSpecificVariants,
|
|
79
93
|
calculatePatternScore,
|
|
80
94
|
calculateSeverity,
|
|
81
95
|
createRefactorClusters,
|
|
82
96
|
detectDuplicatePatterns,
|
|
83
|
-
|
|
97
|
+
filterBrandSpecificVariants,
|
|
98
|
+
filterBySeverity2 as filterBySeverity,
|
|
84
99
|
filterClustersByImpact,
|
|
85
100
|
generateSummary,
|
|
86
101
|
getSeverityLabel,
|
|
87
|
-
getSeverityThreshold,
|
|
88
102
|
getSmartDefaults,
|
|
89
|
-
groupDuplicatesByFilePair
|
|
103
|
+
groupDuplicatesByFilePair,
|
|
104
|
+
logConfiguration
|
|
90
105
|
};
|
|
@@ -27,9 +27,13 @@ module.exports = __toCommonJS(scoring_entry_exports);
|
|
|
27
27
|
// src/scoring.ts
|
|
28
28
|
var import_core = require("@aiready/core");
|
|
29
29
|
function calculatePatternScore(duplicates, totalFilesAnalyzed, costConfig) {
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
30
|
+
const actionableDuplicates = duplicates.filter((d) => d.severity !== "info");
|
|
31
|
+
const totalDuplicates = actionableDuplicates.length;
|
|
32
|
+
const totalTokenCost = actionableDuplicates.reduce(
|
|
33
|
+
(sum, d) => sum + d.tokenCost,
|
|
34
|
+
0
|
|
35
|
+
);
|
|
36
|
+
const highImpactDuplicates = actionableDuplicates.filter(
|
|
33
37
|
(d) => d.tokenCost > 1e3 || d.similarity > 0.7
|
|
34
38
|
).length;
|
|
35
39
|
if (totalFilesAnalyzed === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/pattern-detect",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.12",
|
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"commander": "^14.0.0",
|
|
67
67
|
"chalk": "^5.3.0",
|
|
68
|
-
"@aiready/core": "0.24.
|
|
68
|
+
"@aiready/core": "0.24.13"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"tsup": "^8.3.5",
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Severity, ScanOptions, AnalysisResult } from '@aiready/core';
|
|
2
|
-
import { P as PatternType, a as DuplicatePattern } from './types-C4lmb2Yh.mjs';
|
|
3
|
-
|
|
4
|
-
interface DuplicateGroup {
|
|
5
|
-
filePair: string;
|
|
6
|
-
severity: Severity;
|
|
7
|
-
occurrences: number;
|
|
8
|
-
totalTokenCost: number;
|
|
9
|
-
averageSimilarity: number;
|
|
10
|
-
patternTypes: Set<PatternType>;
|
|
11
|
-
lineRanges: Array<{
|
|
12
|
-
file1: {
|
|
13
|
-
start: number;
|
|
14
|
-
end: number;
|
|
15
|
-
};
|
|
16
|
-
file2: {
|
|
17
|
-
start: number;
|
|
18
|
-
end: number;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
interface RefactorCluster {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
files: string[];
|
|
26
|
-
severity: Severity;
|
|
27
|
-
duplicateCount: number;
|
|
28
|
-
totalTokenCost: number;
|
|
29
|
-
averageSimilarity: number;
|
|
30
|
-
reason?: string;
|
|
31
|
-
suggestion?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface PatternDetectOptions extends ScanOptions {
|
|
35
|
-
minSimilarity?: number;
|
|
36
|
-
minLines?: number;
|
|
37
|
-
batchSize?: number;
|
|
38
|
-
approx?: boolean;
|
|
39
|
-
minSharedTokens?: number;
|
|
40
|
-
maxCandidatesPerBlock?: number;
|
|
41
|
-
streamResults?: boolean;
|
|
42
|
-
severity?: string;
|
|
43
|
-
includeTests?: boolean;
|
|
44
|
-
useSmartDefaults?: boolean;
|
|
45
|
-
groupByFilePair?: boolean;
|
|
46
|
-
createClusters?: boolean;
|
|
47
|
-
minClusterTokenCost?: number;
|
|
48
|
-
minClusterFiles?: number;
|
|
49
|
-
excludePatterns?: string[];
|
|
50
|
-
confidenceThreshold?: number;
|
|
51
|
-
ignoreWhitelist?: string[];
|
|
52
|
-
onProgress?: (processed: number, total: number, message: string) => void;
|
|
53
|
-
}
|
|
54
|
-
interface PatternSummary {
|
|
55
|
-
totalPatterns: number;
|
|
56
|
-
totalTokenCost: number;
|
|
57
|
-
patternsByType: Record<PatternType, number>;
|
|
58
|
-
topDuplicates: Array<{
|
|
59
|
-
files: Array<{
|
|
60
|
-
path: string;
|
|
61
|
-
startLine: number;
|
|
62
|
-
endLine: number;
|
|
63
|
-
}>;
|
|
64
|
-
similarity: number;
|
|
65
|
-
patternType: PatternType;
|
|
66
|
-
tokenCost: number;
|
|
67
|
-
}>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Determine smart defaults based on repository size estimation.
|
|
71
|
-
*
|
|
72
|
-
* @param directory - The directory to analyze for size.
|
|
73
|
-
* @param userOptions - User-provided option overrides.
|
|
74
|
-
* @returns Promise resolving to optimal detection options.
|
|
75
|
-
*/
|
|
76
|
-
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
77
|
-
/**
|
|
78
|
-
* Main entry point for pattern detection analysis.
|
|
79
|
-
*
|
|
80
|
-
* @param options - Configuration including rootDir and detection parameters.
|
|
81
|
-
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
82
|
-
* @lastUpdated 2026-03-18
|
|
83
|
-
*/
|
|
84
|
-
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
85
|
-
results: AnalysisResult[];
|
|
86
|
-
duplicates: DuplicatePattern[];
|
|
87
|
-
files: string[];
|
|
88
|
-
groups?: DuplicateGroup[];
|
|
89
|
-
clusters?: RefactorCluster[];
|
|
90
|
-
config: PatternDetectOptions;
|
|
91
|
-
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Generate a summary of pattern detection results.
|
|
94
|
-
*
|
|
95
|
-
* @param results - Array of file-level analysis results.
|
|
96
|
-
* @returns Consolidated pattern summary object.
|
|
97
|
-
*/
|
|
98
|
-
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
99
|
-
|
|
100
|
-
export { type PatternDetectOptions, type PatternSummary, analyzePatterns, generateSummary, getSmartDefaults };
|
package/dist/analyzer-entry.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { Severity, ScanOptions, AnalysisResult } from '@aiready/core';
|
|
2
|
-
import { P as PatternType, a as DuplicatePattern } from './types-C4lmb2Yh.js';
|
|
3
|
-
|
|
4
|
-
interface DuplicateGroup {
|
|
5
|
-
filePair: string;
|
|
6
|
-
severity: Severity;
|
|
7
|
-
occurrences: number;
|
|
8
|
-
totalTokenCost: number;
|
|
9
|
-
averageSimilarity: number;
|
|
10
|
-
patternTypes: Set<PatternType>;
|
|
11
|
-
lineRanges: Array<{
|
|
12
|
-
file1: {
|
|
13
|
-
start: number;
|
|
14
|
-
end: number;
|
|
15
|
-
};
|
|
16
|
-
file2: {
|
|
17
|
-
start: number;
|
|
18
|
-
end: number;
|
|
19
|
-
};
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
interface RefactorCluster {
|
|
23
|
-
id: string;
|
|
24
|
-
name: string;
|
|
25
|
-
files: string[];
|
|
26
|
-
severity: Severity;
|
|
27
|
-
duplicateCount: number;
|
|
28
|
-
totalTokenCost: number;
|
|
29
|
-
averageSimilarity: number;
|
|
30
|
-
reason?: string;
|
|
31
|
-
suggestion?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface PatternDetectOptions extends ScanOptions {
|
|
35
|
-
minSimilarity?: number;
|
|
36
|
-
minLines?: number;
|
|
37
|
-
batchSize?: number;
|
|
38
|
-
approx?: boolean;
|
|
39
|
-
minSharedTokens?: number;
|
|
40
|
-
maxCandidatesPerBlock?: number;
|
|
41
|
-
streamResults?: boolean;
|
|
42
|
-
severity?: string;
|
|
43
|
-
includeTests?: boolean;
|
|
44
|
-
useSmartDefaults?: boolean;
|
|
45
|
-
groupByFilePair?: boolean;
|
|
46
|
-
createClusters?: boolean;
|
|
47
|
-
minClusterTokenCost?: number;
|
|
48
|
-
minClusterFiles?: number;
|
|
49
|
-
excludePatterns?: string[];
|
|
50
|
-
confidenceThreshold?: number;
|
|
51
|
-
ignoreWhitelist?: string[];
|
|
52
|
-
onProgress?: (processed: number, total: number, message: string) => void;
|
|
53
|
-
}
|
|
54
|
-
interface PatternSummary {
|
|
55
|
-
totalPatterns: number;
|
|
56
|
-
totalTokenCost: number;
|
|
57
|
-
patternsByType: Record<PatternType, number>;
|
|
58
|
-
topDuplicates: Array<{
|
|
59
|
-
files: Array<{
|
|
60
|
-
path: string;
|
|
61
|
-
startLine: number;
|
|
62
|
-
endLine: number;
|
|
63
|
-
}>;
|
|
64
|
-
similarity: number;
|
|
65
|
-
patternType: PatternType;
|
|
66
|
-
tokenCost: number;
|
|
67
|
-
}>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Determine smart defaults based on repository size estimation.
|
|
71
|
-
*
|
|
72
|
-
* @param directory - The directory to analyze for size.
|
|
73
|
-
* @param userOptions - User-provided option overrides.
|
|
74
|
-
* @returns Promise resolving to optimal detection options.
|
|
75
|
-
*/
|
|
76
|
-
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
77
|
-
/**
|
|
78
|
-
* Main entry point for pattern detection analysis.
|
|
79
|
-
*
|
|
80
|
-
* @param options - Configuration including rootDir and detection parameters.
|
|
81
|
-
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
82
|
-
* @lastUpdated 2026-03-18
|
|
83
|
-
*/
|
|
84
|
-
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
85
|
-
results: AnalysisResult[];
|
|
86
|
-
duplicates: DuplicatePattern[];
|
|
87
|
-
files: string[];
|
|
88
|
-
groups?: DuplicateGroup[];
|
|
89
|
-
clusters?: RefactorCluster[];
|
|
90
|
-
config: PatternDetectOptions;
|
|
91
|
-
}>;
|
|
92
|
-
/**
|
|
93
|
-
* Generate a summary of pattern detection results.
|
|
94
|
-
*
|
|
95
|
-
* @param results - Array of file-level analysis results.
|
|
96
|
-
* @returns Consolidated pattern summary object.
|
|
97
|
-
*/
|
|
98
|
-
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
99
|
-
|
|
100
|
-
export { type PatternDetectOptions, type PatternSummary, analyzePatterns, generateSummary, getSmartDefaults };
|