@aiready/pattern-detect 0.16.5 → 0.16.6
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/index.d.mts +45 -2
- package/dist/index.d.ts +45 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -37,6 +37,10 @@ interface DetectionOptions {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Detect duplicate patterns across files
|
|
40
|
+
*
|
|
41
|
+
* @param fileContents - Array of file contents to analyze.
|
|
42
|
+
* @param options - Configuration for duplicate detection (thresholds, progress, etc).
|
|
43
|
+
* @returns Promise resolving to an array of detected duplicate patterns sorted by similarity.
|
|
40
44
|
*/
|
|
41
45
|
declare function detectDuplicatePatterns(fileContents: FileContent[], options: DetectionOptions): Promise<DuplicatePattern[]>;
|
|
42
46
|
|
|
@@ -122,9 +126,20 @@ interface PatternSummary {
|
|
|
122
126
|
}>;
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
|
-
* Determine smart defaults based on repository size estimation
|
|
129
|
+
* Determine smart defaults based on repository size estimation.
|
|
130
|
+
*
|
|
131
|
+
* @param directory - The directory to analyze for size.
|
|
132
|
+
* @param userOptions - User-provided option overrides.
|
|
133
|
+
* @returns Promise resolving to optimal detection options.
|
|
126
134
|
*/
|
|
127
135
|
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
136
|
+
/**
|
|
137
|
+
* Main entry point for pattern detection analysis.
|
|
138
|
+
*
|
|
139
|
+
* @param options - Configuration including rootDir and detection parameters.
|
|
140
|
+
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
141
|
+
* @lastUpdated 2026-03-18
|
|
142
|
+
*/
|
|
128
143
|
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
129
144
|
results: AnalysisResult[];
|
|
130
145
|
duplicates: DuplicatePattern[];
|
|
@@ -133,6 +148,12 @@ declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
|
133
148
|
clusters?: RefactorCluster[];
|
|
134
149
|
config: PatternDetectOptions;
|
|
135
150
|
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Generate a summary of pattern detection results.
|
|
153
|
+
*
|
|
154
|
+
* @param results - Array of file-level analysis results.
|
|
155
|
+
* @returns Consolidated pattern summary object.
|
|
156
|
+
*/
|
|
136
157
|
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
137
158
|
|
|
138
159
|
/**
|
|
@@ -146,6 +167,11 @@ declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
|
146
167
|
* Includes business value metrics:
|
|
147
168
|
* - Estimated monthly cost of token waste
|
|
148
169
|
* - Estimated developer hours to fix
|
|
170
|
+
*
|
|
171
|
+
* @param duplicates - Array of detected duplicate patterns.
|
|
172
|
+
* @param totalFilesAnalyzed - Total count of files scanned.
|
|
173
|
+
* @param costConfig - Optional configuration for business value calculations.
|
|
174
|
+
* @returns Standardized scoring output for pattern detection.
|
|
149
175
|
*/
|
|
150
176
|
declare function calculatePatternScore(duplicates: DuplicatePattern[], totalFilesAnalyzed: number, costConfig?: Partial<CostConfig>): ToolScoringOutput;
|
|
151
177
|
|
|
@@ -167,6 +193,13 @@ interface ContextRule {
|
|
|
167
193
|
declare const CONTEXT_RULES: ContextRule[];
|
|
168
194
|
/**
|
|
169
195
|
* Calculate severity based on context rules and code characteristics
|
|
196
|
+
*
|
|
197
|
+
* @param file1 - First file path in the duplicate pair.
|
|
198
|
+
* @param file2 - Second file path in the duplicate pair.
|
|
199
|
+
* @param code - Snippet of the duplicated code.
|
|
200
|
+
* @param similarity - The calculated similarity score (0-1).
|
|
201
|
+
* @param linesOfCode - Number of lines in the duplicated block.
|
|
202
|
+
* @returns An object containing the severity level and reasoning.
|
|
170
203
|
*/
|
|
171
204
|
declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
|
|
172
205
|
severity: Severity;
|
|
@@ -176,16 +209,26 @@ declare function calculateSeverity(file1: string, file2: string, code: string, s
|
|
|
176
209
|
};
|
|
177
210
|
/**
|
|
178
211
|
* Get a human-readable severity label with emoji
|
|
212
|
+
*
|
|
213
|
+
* @param severity - The severity level to label.
|
|
214
|
+
* @returns Formatted label string for UI display.
|
|
179
215
|
*/
|
|
180
216
|
declare function getSeverityLabel(severity: Severity): string;
|
|
181
217
|
/**
|
|
182
218
|
* Filter duplicates by minimum severity threshold
|
|
219
|
+
*
|
|
220
|
+
* @param duplicates - List of items with a severity property.
|
|
221
|
+
* @param minSeverity - Minimum threshold for inclusion.
|
|
222
|
+
* @returns Filtered list of items.
|
|
183
223
|
*/
|
|
184
224
|
declare function filterBySeverity<T extends {
|
|
185
225
|
severity: Severity;
|
|
186
226
|
}>(duplicates: T[], minSeverity: Severity): T[];
|
|
187
227
|
/**
|
|
188
|
-
* Get
|
|
228
|
+
* Get numerical similarity threshold associated with a severity level
|
|
229
|
+
*
|
|
230
|
+
* @param severity - The severity level to look up.
|
|
231
|
+
* @returns Minimum similarity value for this severity.
|
|
189
232
|
*/
|
|
190
233
|
declare function getSeverityThreshold(severity: Severity): number;
|
|
191
234
|
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ interface DetectionOptions {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Detect duplicate patterns across files
|
|
40
|
+
*
|
|
41
|
+
* @param fileContents - Array of file contents to analyze.
|
|
42
|
+
* @param options - Configuration for duplicate detection (thresholds, progress, etc).
|
|
43
|
+
* @returns Promise resolving to an array of detected duplicate patterns sorted by similarity.
|
|
40
44
|
*/
|
|
41
45
|
declare function detectDuplicatePatterns(fileContents: FileContent[], options: DetectionOptions): Promise<DuplicatePattern[]>;
|
|
42
46
|
|
|
@@ -122,9 +126,20 @@ interface PatternSummary {
|
|
|
122
126
|
}>;
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
|
-
* Determine smart defaults based on repository size estimation
|
|
129
|
+
* Determine smart defaults based on repository size estimation.
|
|
130
|
+
*
|
|
131
|
+
* @param directory - The directory to analyze for size.
|
|
132
|
+
* @param userOptions - User-provided option overrides.
|
|
133
|
+
* @returns Promise resolving to optimal detection options.
|
|
126
134
|
*/
|
|
127
135
|
declare function getSmartDefaults(directory: string, userOptions: Partial<PatternDetectOptions>): Promise<PatternDetectOptions>;
|
|
136
|
+
/**
|
|
137
|
+
* Main entry point for pattern detection analysis.
|
|
138
|
+
*
|
|
139
|
+
* @param options - Configuration including rootDir and detection parameters.
|
|
140
|
+
* @returns Promise resolving to the comprehensive pattern detect report.
|
|
141
|
+
* @lastUpdated 2026-03-18
|
|
142
|
+
*/
|
|
128
143
|
declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
129
144
|
results: AnalysisResult[];
|
|
130
145
|
duplicates: DuplicatePattern[];
|
|
@@ -133,6 +148,12 @@ declare function analyzePatterns(options: PatternDetectOptions): Promise<{
|
|
|
133
148
|
clusters?: RefactorCluster[];
|
|
134
149
|
config: PatternDetectOptions;
|
|
135
150
|
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Generate a summary of pattern detection results.
|
|
153
|
+
*
|
|
154
|
+
* @param results - Array of file-level analysis results.
|
|
155
|
+
* @returns Consolidated pattern summary object.
|
|
156
|
+
*/
|
|
136
157
|
declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
137
158
|
|
|
138
159
|
/**
|
|
@@ -146,6 +167,11 @@ declare function generateSummary(results: AnalysisResult[]): PatternSummary;
|
|
|
146
167
|
* Includes business value metrics:
|
|
147
168
|
* - Estimated monthly cost of token waste
|
|
148
169
|
* - Estimated developer hours to fix
|
|
170
|
+
*
|
|
171
|
+
* @param duplicates - Array of detected duplicate patterns.
|
|
172
|
+
* @param totalFilesAnalyzed - Total count of files scanned.
|
|
173
|
+
* @param costConfig - Optional configuration for business value calculations.
|
|
174
|
+
* @returns Standardized scoring output for pattern detection.
|
|
149
175
|
*/
|
|
150
176
|
declare function calculatePatternScore(duplicates: DuplicatePattern[], totalFilesAnalyzed: number, costConfig?: Partial<CostConfig>): ToolScoringOutput;
|
|
151
177
|
|
|
@@ -167,6 +193,13 @@ interface ContextRule {
|
|
|
167
193
|
declare const CONTEXT_RULES: ContextRule[];
|
|
168
194
|
/**
|
|
169
195
|
* Calculate severity based on context rules and code characteristics
|
|
196
|
+
*
|
|
197
|
+
* @param file1 - First file path in the duplicate pair.
|
|
198
|
+
* @param file2 - Second file path in the duplicate pair.
|
|
199
|
+
* @param code - Snippet of the duplicated code.
|
|
200
|
+
* @param similarity - The calculated similarity score (0-1).
|
|
201
|
+
* @param linesOfCode - Number of lines in the duplicated block.
|
|
202
|
+
* @returns An object containing the severity level and reasoning.
|
|
170
203
|
*/
|
|
171
204
|
declare function calculateSeverity(file1: string, file2: string, code: string, similarity: number, linesOfCode: number): {
|
|
172
205
|
severity: Severity;
|
|
@@ -176,16 +209,26 @@ declare function calculateSeverity(file1: string, file2: string, code: string, s
|
|
|
176
209
|
};
|
|
177
210
|
/**
|
|
178
211
|
* Get a human-readable severity label with emoji
|
|
212
|
+
*
|
|
213
|
+
* @param severity - The severity level to label.
|
|
214
|
+
* @returns Formatted label string for UI display.
|
|
179
215
|
*/
|
|
180
216
|
declare function getSeverityLabel(severity: Severity): string;
|
|
181
217
|
/**
|
|
182
218
|
* Filter duplicates by minimum severity threshold
|
|
219
|
+
*
|
|
220
|
+
* @param duplicates - List of items with a severity property.
|
|
221
|
+
* @param minSeverity - Minimum threshold for inclusion.
|
|
222
|
+
* @returns Filtered list of items.
|
|
183
223
|
*/
|
|
184
224
|
declare function filterBySeverity<T extends {
|
|
185
225
|
severity: Severity;
|
|
186
226
|
}>(duplicates: T[], minSeverity: Severity): T[];
|
|
187
227
|
/**
|
|
188
|
-
* Get
|
|
228
|
+
* Get numerical similarity threshold associated with a severity level
|
|
229
|
+
*
|
|
230
|
+
* @param severity - The severity level to look up.
|
|
231
|
+
* @returns Minimum similarity value for this severity.
|
|
189
232
|
*/
|
|
190
233
|
declare function getSeverityThreshold(severity: Severity): number;
|
|
191
234
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/pattern-detect",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.6",
|
|
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.23.
|
|
48
|
+
"@aiready/core": "0.23.7"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"tsup": "^8.3.5",
|