@aiready/pattern-detect 0.17.15 → 0.17.16
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 +2 -2
- package/dist/analyzer-entry/index.d.ts +2 -2
- package/dist/analyzer-entry/index.js +357 -140
- package/dist/analyzer-entry/index.mjs +4 -4
- package/dist/chunk-3LMYFYWG.mjs +514 -0
- package/dist/chunk-4YXKUW4P.mjs +143 -0
- package/dist/chunk-5A3ULAQ5.mjs +571 -0
- package/dist/chunk-5FACKJ7M.mjs +519 -0
- package/dist/chunk-6B72OWZA.mjs +143 -0
- package/dist/chunk-6SHBBRHF.mjs +600 -0
- package/dist/chunk-BKSIA7A2.mjs +516 -0
- package/dist/chunk-CM5YJR7G.mjs +516 -0
- package/dist/chunk-FSXOU23F.mjs +620 -0
- package/dist/chunk-GUYQI3AF.mjs +514 -0
- package/dist/chunk-H2TGXGMX.mjs +587 -0
- package/dist/chunk-KMAOEVRS.mjs +150 -0
- package/dist/chunk-NWG2ZIGX.mjs +146 -0
- package/dist/chunk-OFVJFGQW.mjs +514 -0
- package/dist/chunk-PCCZREHY.mjs +143 -0
- package/dist/chunk-PQS5ACTN.mjs +516 -0
- package/dist/chunk-TVE75IDM.mjs +143 -0
- package/dist/chunk-UDOGQ42Q.mjs +603 -0
- package/dist/chunk-UFI4UDQI.mjs +514 -0
- package/dist/chunk-UXV57HN3.mjs +144 -0
- package/dist/chunk-VC2BOV6R.mjs +143 -0
- package/dist/chunk-VI2OVG73.mjs +514 -0
- package/dist/chunk-VKGYNHFY.mjs +514 -0
- package/dist/chunk-WBLZYAQ2.mjs +518 -0
- package/dist/chunk-WFVXMMB3.mjs +143 -0
- package/dist/chunk-WQC43BIO.mjs +516 -0
- package/dist/chunk-WTAIM3SG.mjs +146 -0
- package/dist/chunk-XC7U55PE.mjs +514 -0
- package/dist/chunk-XR373Q6G.mjs +146 -0
- package/dist/chunk-XWIBTD67.mjs +620 -0
- package/dist/chunk-YUQ2VQVJ.mjs +514 -0
- package/dist/chunk-Z4NOH52X.mjs +143 -0
- package/dist/cli.js +357 -140
- package/dist/cli.mjs +4 -4
- package/dist/context-rules-entry/index.js +351 -139
- package/dist/context-rules-entry/index.mjs +1 -1
- package/dist/detector-entry/index.d.mts +2 -2
- package/dist/detector-entry/index.d.ts +2 -2
- package/dist/detector-entry/index.js +355 -140
- package/dist/detector-entry/index.mjs +2 -2
- package/dist/index-BGvkJ9j1.d.mts +136 -0
- package/dist/index-BJq32qmj.d.mts +137 -0
- package/dist/index-BpoJSgX-.d.mts +136 -0
- package/dist/index-C7qLPKmH.d.ts +150 -0
- package/dist/index-CThnG9hv.d.ts +155 -0
- package/dist/index-D0Hpg9nN.d.mts +150 -0
- package/dist/index-DN6XpBOW.d.mts +155 -0
- package/dist/index-F8xqZ2PS.d.ts +136 -0
- package/dist/index-HNhDr6CV.d.ts +137 -0
- package/dist/index-ux0Wo8Ps.d.ts +136 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +359 -142
- package/dist/index.mjs +4 -4
- package/dist/scoring-entry/index.d.mts +1 -1
- package/dist/scoring-entry/index.d.ts +1 -1
- package/dist/scoring-entry/index.js +2 -2
- package/dist/scoring-entry/index.mjs +1 -1
- package/dist/types-tgrmUrHE.d.mts +37 -0
- package/dist/types-tgrmUrHE.d.ts +37 -0
- package/package.json +5 -3
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Severity, ScanOptions, Issue, AnalysisResult } from '@aiready/core';
|
|
2
|
+
import { P as PatternType, D as DuplicatePattern } from './types-tgrmUrHE.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
|
+
* Group raw duplicates by file pairs to reduce noise
|
|
35
|
+
*/
|
|
36
|
+
declare function groupDuplicatesByFilePair(duplicates: DuplicatePattern[]): DuplicateGroup[];
|
|
37
|
+
/**
|
|
38
|
+
* Create clusters of highly related files (refactor targets)
|
|
39
|
+
* Uses a simple connected components algorithm
|
|
40
|
+
* @param duplicates - Array of duplicate patterns to cluster
|
|
41
|
+
* @returns Array of refactor clusters
|
|
42
|
+
*/
|
|
43
|
+
declare function createRefactorClusters(duplicates: DuplicatePattern[]): RefactorCluster[];
|
|
44
|
+
/**
|
|
45
|
+
* Filter clusters by impact threshold
|
|
46
|
+
* @param clusters - Array of refactor clusters to filter
|
|
47
|
+
* @param minTokenCost - Minimum token cost threshold (default: 1000)
|
|
48
|
+
* @param minFiles - Minimum number of files in cluster (default: 3)
|
|
49
|
+
* @returns Filtered array of refactor clusters
|
|
50
|
+
*/
|
|
51
|
+
declare function filterClustersByImpact(clusters: RefactorCluster[], minTokenCost?: number, minFiles?: number): RefactorCluster[];
|
|
52
|
+
/**
|
|
53
|
+
* Detect if two duplicate files are likely brand-specific variants
|
|
54
|
+
* (e.g., different themed versions of the same UI component)
|
|
55
|
+
*/
|
|
56
|
+
declare function areBrandSpecificVariants(file1: string, file2: string, code1: string, code2: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Filter out brand-specific variants from duplicates
|
|
59
|
+
*/
|
|
60
|
+
declare function filterBrandSpecificVariants(duplicates: DuplicatePattern[]): DuplicatePattern[];
|
|
61
|
+
|
|
62
|
+
interface PatternDetectOptions extends ScanOptions {
|
|
63
|
+
minSimilarity?: number;
|
|
64
|
+
minLines?: number;
|
|
65
|
+
batchSize?: number;
|
|
66
|
+
approx?: boolean;
|
|
67
|
+
minSharedTokens?: number;
|
|
68
|
+
maxCandidatesPerBlock?: number;
|
|
69
|
+
streamResults?: boolean;
|
|
70
|
+
useSmartDefaults?: boolean;
|
|
71
|
+
groupByFilePair?: boolean;
|
|
72
|
+
createClusters?: boolean;
|
|
73
|
+
minClusterTokenCost?: number;
|
|
74
|
+
minClusterFiles?: number;
|
|
75
|
+
excludePatterns?: string[];
|
|
76
|
+
excludeFiles?: string[];
|
|
77
|
+
confidenceThreshold?: number;
|
|
78
|
+
ignoreWhitelist?: string[];
|
|
79
|
+
onProgress?: (processed: number, total: number, message: string) => void;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Determine smart defaults based on repository size estimation.
|
|
83
|
+
*/
|
|
84
|
+
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
85
|
+
/**
|
|
86
|
+
* Log current configuration settings to the console.
|
|
87
|
+
*/
|
|
88
|
+
declare function logConfiguration(config: PatternDetectOptions, estimatedBlocks: number): void;
|
|
89
|
+
|
|
90
|
+
interface PatternSummary {
|
|
91
|
+
totalPatterns: number;
|
|
92
|
+
totalTokenCost: number;
|
|
93
|
+
patternsByType: Record<PatternType, number>;
|
|
94
|
+
topDuplicates: Array<{
|
|
95
|
+
files: Array<{
|
|
96
|
+
path: string;
|
|
97
|
+
startLine: number;
|
|
98
|
+
endLine: number;
|
|
99
|
+
}>;
|
|
100
|
+
similarity: number;
|
|
101
|
+
patternType: PatternType;
|
|
102
|
+
tokenCost: number;
|
|
103
|
+
}>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Generate a summary of pattern detection results.
|
|
107
|
+
*/
|
|
108
|
+
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
109
|
+
/**
|
|
110
|
+
* Filter issues by severity level.
|
|
111
|
+
*/
|
|
112
|
+
declare function filterBySeverity(issues: Issue[], severity: string): Issue[];
|
|
113
|
+
/**
|
|
114
|
+
* Get human-readable label for severity.
|
|
115
|
+
*/
|
|
116
|
+
declare function getSeverityLabel(severity: Severity): string;
|
|
117
|
+
/**
|
|
118
|
+
* Calculate severity based on similarity.
|
|
119
|
+
*/
|
|
120
|
+
declare function calculateSeverity(similarity: number): Severity;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Main entry point for pattern detection analysis.
|
|
124
|
+
*
|
|
125
|
+
* @param options - Configuration including rootDir and detection parameters.
|
|
126
|
+
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
127
|
+
*/
|
|
128
|
+
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
129
|
+
results: AnalysisResult[];
|
|
130
|
+
duplicates: DuplicatePattern[];
|
|
131
|
+
files: string[];
|
|
132
|
+
groups?: DuplicateGroup[];
|
|
133
|
+
clusters?: RefactorCluster[];
|
|
134
|
+
config: PatternDetectOptions;
|
|
135
|
+
}>;
|
|
136
|
+
|
|
137
|
+
export { type DuplicateGroup as D, type PatternDetectOptions as P, type RefactorCluster as R, type PatternSummary as a, analyzePatterns as b, areBrandSpecificVariants as c, calculateSeverity as d, createRefactorClusters as e, filterBrandSpecificVariants as f, filterBySeverity as g, filterClustersByImpact as h, generateSummary as i, getSeverityLabel as j, getSmartDefaults as k, groupDuplicatesByFilePair as l, logConfiguration as m };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Severity, ScanOptions, Issue, AnalysisResult } from '@aiready/core';
|
|
2
|
+
import { P as PatternType, D as DuplicatePattern } from './types-tgrmUrHE.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
|
+
* Group raw duplicates by file pairs to reduce noise
|
|
35
|
+
*/
|
|
36
|
+
declare function groupDuplicatesByFilePair(duplicates: DuplicatePattern[]): DuplicateGroup[];
|
|
37
|
+
/**
|
|
38
|
+
* Create clusters of highly related files (refactor targets)
|
|
39
|
+
* Uses a simple connected components algorithm
|
|
40
|
+
* @param duplicates - Array of duplicate patterns to cluster
|
|
41
|
+
* @returns Array of refactor clusters
|
|
42
|
+
*/
|
|
43
|
+
declare function createRefactorClusters(duplicates: DuplicatePattern[]): RefactorCluster[];
|
|
44
|
+
/**
|
|
45
|
+
* Filter clusters by impact threshold
|
|
46
|
+
* @param clusters - Array of refactor clusters to filter
|
|
47
|
+
* @param minTokenCost - Minimum token cost threshold (default: 1000)
|
|
48
|
+
* @param minFiles - Minimum number of files in cluster (default: 3)
|
|
49
|
+
* @returns Filtered array of refactor clusters
|
|
50
|
+
*/
|
|
51
|
+
declare function filterClustersByImpact(clusters: RefactorCluster[], minTokenCost?: number, minFiles?: number): RefactorCluster[];
|
|
52
|
+
/**
|
|
53
|
+
* Detect if two duplicate files are likely brand-specific variants
|
|
54
|
+
* (e.g., different themed versions of the same UI component)
|
|
55
|
+
*/
|
|
56
|
+
declare function areBrandSpecificVariants(file1: string, file2: string, code1: string, code2: string): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Filter out brand-specific variants from duplicates
|
|
59
|
+
*/
|
|
60
|
+
declare function filterBrandSpecificVariants(duplicates: DuplicatePattern[]): DuplicatePattern[];
|
|
61
|
+
|
|
62
|
+
interface PatternDetectOptions extends ScanOptions {
|
|
63
|
+
minSimilarity?: number;
|
|
64
|
+
minLines?: number;
|
|
65
|
+
batchSize?: number;
|
|
66
|
+
approx?: boolean;
|
|
67
|
+
minSharedTokens?: number;
|
|
68
|
+
maxCandidatesPerBlock?: number;
|
|
69
|
+
streamResults?: boolean;
|
|
70
|
+
useSmartDefaults?: boolean;
|
|
71
|
+
groupByFilePair?: boolean;
|
|
72
|
+
createClusters?: boolean;
|
|
73
|
+
minClusterTokenCost?: number;
|
|
74
|
+
minClusterFiles?: number;
|
|
75
|
+
excludePatterns?: string[];
|
|
76
|
+
confidenceThreshold?: number;
|
|
77
|
+
ignoreWhitelist?: string[];
|
|
78
|
+
onProgress?: (processed: number, total: number, message: string) => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Determine smart defaults based on repository size estimation.
|
|
82
|
+
*/
|
|
83
|
+
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
84
|
+
/**
|
|
85
|
+
* Log current configuration settings to the console.
|
|
86
|
+
*/
|
|
87
|
+
declare function logConfiguration(config: PatternDetectOptions, estimatedBlocks: number): void;
|
|
88
|
+
|
|
89
|
+
interface PatternSummary {
|
|
90
|
+
totalPatterns: number;
|
|
91
|
+
totalTokenCost: number;
|
|
92
|
+
patternsByType: Record<PatternType, number>;
|
|
93
|
+
topDuplicates: Array<{
|
|
94
|
+
files: Array<{
|
|
95
|
+
path: string;
|
|
96
|
+
startLine: number;
|
|
97
|
+
endLine: number;
|
|
98
|
+
}>;
|
|
99
|
+
similarity: number;
|
|
100
|
+
patternType: PatternType;
|
|
101
|
+
tokenCost: number;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Generate a summary of pattern detection results.
|
|
106
|
+
*/
|
|
107
|
+
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
108
|
+
/**
|
|
109
|
+
* Filter issues by severity level.
|
|
110
|
+
*/
|
|
111
|
+
declare function filterBySeverity(issues: Issue[], severity: string): Issue[];
|
|
112
|
+
/**
|
|
113
|
+
* Get human-readable label for severity.
|
|
114
|
+
*/
|
|
115
|
+
declare function getSeverityLabel(severity: Severity): string;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate severity based on similarity.
|
|
118
|
+
*/
|
|
119
|
+
declare function calculateSeverity(similarity: number): Severity;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Main entry point for pattern detection analysis.
|
|
123
|
+
*
|
|
124
|
+
* @param options - Configuration including rootDir and detection parameters.
|
|
125
|
+
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
126
|
+
*/
|
|
127
|
+
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
128
|
+
results: AnalysisResult[];
|
|
129
|
+
duplicates: DuplicatePattern[];
|
|
130
|
+
files: string[];
|
|
131
|
+
groups?: DuplicateGroup[];
|
|
132
|
+
clusters?: RefactorCluster[];
|
|
133
|
+
config: PatternDetectOptions;
|
|
134
|
+
}>;
|
|
135
|
+
|
|
136
|
+
export { type DuplicateGroup as D, type PatternDetectOptions as P, type RefactorCluster as R, type PatternSummary as a, analyzePatterns as b, areBrandSpecificVariants as c, calculateSeverity as d, createRefactorClusters as e, filterBrandSpecificVariants as f, filterBySeverity as g, filterClustersByImpact as h, generateSummary as i, getSeverityLabel as j, getSmartDefaults as k, groupDuplicatesByFilePair as l, logConfiguration as m };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ToolProvider } from '@aiready/core';
|
|
2
2
|
export { Severity } from '@aiready/core';
|
|
3
3
|
export { detectDuplicatePatterns } from './detector-entry/index.mjs';
|
|
4
|
-
export { D as DuplicateGroup, P as PatternDetectOptions, a as PatternSummary, R as RefactorCluster, b as analyzePatterns, c as areBrandSpecificVariants, d as calculateSeverity, e as createRefactorClusters, f as filterBrandSpecificVariants, g as filterBySeverity, h as filterClustersByImpact, i as generateSummary, j as getSeverityLabel, k as getSmartDefaults, l as groupDuplicatesByFilePair, m as logConfiguration } from './index-
|
|
5
|
-
export { D as DuplicatePattern, P as PatternType } from './types-
|
|
4
|
+
export { D as DuplicateGroup, P as PatternDetectOptions, a as PatternSummary, R as RefactorCluster, b as analyzePatterns, c as areBrandSpecificVariants, d as calculateSeverity, e as createRefactorClusters, f as filterBrandSpecificVariants, g as filterBySeverity, h as filterClustersByImpact, i as generateSummary, j as getSeverityLabel, k as getSmartDefaults, l as groupDuplicatesByFilePair, m as logConfiguration } from './index-DN6XpBOW.mjs';
|
|
5
|
+
export { D as DuplicatePattern, P as PatternType } from './types-tgrmUrHE.mjs';
|
|
6
6
|
export { calculatePatternScore } from './scoring-entry/index.mjs';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ToolProvider } from '@aiready/core';
|
|
2
2
|
export { Severity } from '@aiready/core';
|
|
3
3
|
export { detectDuplicatePatterns } from './detector-entry/index.js';
|
|
4
|
-
export { D as DuplicateGroup, P as PatternDetectOptions, a as PatternSummary, R as RefactorCluster, b as analyzePatterns, c as areBrandSpecificVariants, d as calculateSeverity, e as createRefactorClusters, f as filterBrandSpecificVariants, g as filterBySeverity, h as filterClustersByImpact, i as generateSummary, j as getSeverityLabel, k as getSmartDefaults, l as groupDuplicatesByFilePair, m as logConfiguration } from './index-
|
|
5
|
-
export { D as DuplicatePattern, P as PatternType } from './types-
|
|
4
|
+
export { D as DuplicateGroup, P as PatternDetectOptions, a as PatternSummary, R as RefactorCluster, b as analyzePatterns, c as areBrandSpecificVariants, d as calculateSeverity, e as createRefactorClusters, f as filterBrandSpecificVariants, g as filterBySeverity, h as filterClustersByImpact, i as generateSummary, j as getSeverityLabel, k as getSmartDefaults, l as groupDuplicatesByFilePair, m as logConfiguration } from './index-CThnG9hv.js';
|
|
5
|
+
export { D as DuplicatePattern, P as PatternType } from './types-tgrmUrHE.js';
|
|
6
6
|
export { calculatePatternScore } from './scoring-entry/index.js';
|
|
7
7
|
|
|
8
8
|
/**
|