driftdetect-detectors 0.4.5 → 0.5.0
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/LICENSE +21 -0
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/index.js +2 -0
- package/dist/base/index.js.map +1 -1
- package/dist/base/unified-detector.d.ts +183 -0
- package/dist/base/unified-detector.d.ts.map +1 -0
- package/dist/base/unified-detector.js +290 -0
- package/dist/base/unified-detector.js.map +1 -0
- package/dist/structural/file-naming-unified.d.ts +82 -0
- package/dist/structural/file-naming-unified.d.ts.map +1 -0
- package/dist/structural/file-naming-unified.js +496 -0
- package/dist/structural/file-naming-unified.js.map +1 -0
- package/dist/structural/index.d.ts +1 -0
- package/dist/structural/index.d.ts.map +1 -1
- package/dist/structural/index.js +4 -0
- package/dist/structural/index.js.map +1 -1
- package/package.json +12 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Geoffrey Fernald
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/base/index.d.ts
CHANGED
|
@@ -10,5 +10,6 @@ export { RegexDetector, isRegexDetector, type RegexMatch, type LineMatch, type C
|
|
|
10
10
|
export { StructuralDetector, isStructuralDetector, type NamingConvention, type NamingConventionResult, type PathMatchResult, type PathInfo, type PathMatchOptions, } from './structural-detector.js';
|
|
11
11
|
export { LearningDetector, ValueDistribution, DEFAULT_PATTERN_LEARNING_CONFIG, type LearnedConvention, type PatternLearningConfig, type LearningResult, } from './learning-detector.js';
|
|
12
12
|
export { SemanticDetector, DEFAULT_SEMANTIC_CONFIG, type ContextType, type SemanticMatch, type UsagePattern, type SemanticLearningResult, type SemanticDetectorConfig, } from './semantic-detector.js';
|
|
13
|
+
export { UnifiedDetector, isUnifiedDetector, type DetectionStrategy, type StrategyResult, type StrategyOptions, type MergeConfig, } from './unified-detector.js';
|
|
13
14
|
export * from './types.js';
|
|
14
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/base/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,WAAW,EACX,aAAa,EACb,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC;AAGhC,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,WAAW,EACX,aAAa,EACb,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,aAAa,EACb,eAAe,EACf,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAG/B,cAAc,YAAY,CAAC"}
|
package/dist/base/index.js
CHANGED
|
@@ -16,6 +16,8 @@ export { StructuralDetector, isStructuralDetector, } from './structural-detector
|
|
|
16
16
|
export { LearningDetector, ValueDistribution, DEFAULT_PATTERN_LEARNING_CONFIG, } from './learning-detector.js';
|
|
17
17
|
// Export Semantic detector class and related types
|
|
18
18
|
export { SemanticDetector, DEFAULT_SEMANTIC_CONFIG, } from './semantic-detector.js';
|
|
19
|
+
// Export Unified detector class and related types
|
|
20
|
+
export { UnifiedDetector, isUnifiedDetector, } from './unified-detector.js';
|
|
19
21
|
// Export types from types.ts (for backward compatibility)
|
|
20
22
|
export * from './types.js';
|
|
21
23
|
//# sourceMappingURL=index.js.map
|
package/dist/base/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+CAA+C;AAC/C,OAAO,EACL,YAAY,EACZ,cAAc,GASf,MAAM,oBAAoB,CAAC;AAE5B,8CAA8C;AAC9C,OAAO,EACL,WAAW,EACX,aAAa,GAKd,MAAM,mBAAmB,CAAC;AAE3B,gDAAgD;AAChD,OAAO,EACL,aAAa,EACb,eAAe,GAMhB,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAMrB,MAAM,0BAA0B,CAAC;AAElC,mDAAmD;AACnD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,GAIhC,MAAM,wBAAwB,CAAC;AAEhC,mDAAmD;AACnD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GAMxB,MAAM,wBAAwB,CAAC;AAEhC,0DAA0D;AAC1D,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,+CAA+C;AAC/C,OAAO,EACL,YAAY,EACZ,cAAc,GASf,MAAM,oBAAoB,CAAC;AAE5B,8CAA8C;AAC9C,OAAO,EACL,WAAW,EACX,aAAa,GAKd,MAAM,mBAAmB,CAAC;AAE3B,gDAAgD;AAChD,OAAO,EACL,aAAa,EACb,eAAe,GAMhB,MAAM,qBAAqB,CAAC;AAE7B,qDAAqD;AACrD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,GAMrB,MAAM,0BAA0B,CAAC;AAElC,mDAAmD;AACnD,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,+BAA+B,GAIhC,MAAM,wBAAwB,CAAC;AAEhC,mDAAmD;AACnD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GAMxB,MAAM,wBAAwB,CAAC;AAEhC,kDAAkD;AAClD,OAAO,EACL,eAAe,EACf,iBAAiB,GAKlB,MAAM,uBAAuB,CAAC;AAE/B,0DAA0D;AAC1D,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Detector - Composite detector with multiple detection strategies
|
|
3
|
+
*
|
|
4
|
+
* Consolidates detector variants (base, learning, semantic) into a single class
|
|
5
|
+
* that can run multiple detection strategies and merge results.
|
|
6
|
+
*
|
|
7
|
+
* This is part of Phase 4 of the Pattern System Consolidation.
|
|
8
|
+
*
|
|
9
|
+
* @requirements 6.4 - THE Detector_System SHALL support multiple detection methods
|
|
10
|
+
*/
|
|
11
|
+
import type { PatternMatch, Violation } from 'driftdetect-core';
|
|
12
|
+
import { BaseDetector, type DetectionContext, type DetectionResult } from './base-detector.js';
|
|
13
|
+
/**
|
|
14
|
+
* Detection strategies that can be combined in a unified detector
|
|
15
|
+
*/
|
|
16
|
+
export type DetectionStrategy = 'structural' | 'ast' | 'regex' | 'semantic' | 'learning';
|
|
17
|
+
/**
|
|
18
|
+
* Result from a single strategy execution
|
|
19
|
+
*/
|
|
20
|
+
export interface StrategyResult {
|
|
21
|
+
/** Strategy that produced this result */
|
|
22
|
+
strategy: DetectionStrategy;
|
|
23
|
+
/** Patterns found by this strategy */
|
|
24
|
+
patterns: PatternMatch[];
|
|
25
|
+
/** Violations found by this strategy */
|
|
26
|
+
violations: Violation[];
|
|
27
|
+
/** Confidence score for this strategy's results */
|
|
28
|
+
confidence: number;
|
|
29
|
+
/** Whether this strategy was skipped (e.g., no AST available) */
|
|
30
|
+
skipped?: boolean;
|
|
31
|
+
/** Reason for skipping */
|
|
32
|
+
skipReason?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options for running detection strategies
|
|
36
|
+
*/
|
|
37
|
+
export interface StrategyOptions {
|
|
38
|
+
/** Only run specific strategies (default: all supported) */
|
|
39
|
+
strategies?: DetectionStrategy[];
|
|
40
|
+
/** Stop after first strategy finds results */
|
|
41
|
+
stopOnFirstMatch?: boolean;
|
|
42
|
+
/** Minimum confidence to include results */
|
|
43
|
+
minConfidence?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for merging strategy results
|
|
47
|
+
*/
|
|
48
|
+
export interface MergeConfig {
|
|
49
|
+
/** How to handle duplicate patterns at same location */
|
|
50
|
+
duplicateHandling: 'highest-confidence' | 'first' | 'merge';
|
|
51
|
+
/** How to combine confidence scores */
|
|
52
|
+
confidenceCombination: 'max' | 'average' | 'weighted';
|
|
53
|
+
/** Weights for each strategy (for weighted confidence) */
|
|
54
|
+
strategyWeights?: Partial<Record<DetectionStrategy, number>>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Abstract base class for unified detectors
|
|
58
|
+
*
|
|
59
|
+
* Unified detectors combine multiple detection strategies (structural, AST,
|
|
60
|
+
* regex, semantic, learning) into a single detector class. This reduces
|
|
61
|
+
* code duplication and makes it easier to maintain detection logic.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* class FileNamingDetector extends UnifiedDetector {
|
|
66
|
+
* readonly id = 'structural/file-naming';
|
|
67
|
+
* readonly category = 'structural';
|
|
68
|
+
* readonly subcategory = 'naming-conventions';
|
|
69
|
+
* readonly name = 'File Naming Convention Detector';
|
|
70
|
+
* readonly description = 'Detects file naming patterns';
|
|
71
|
+
* readonly supportedLanguages = ['typescript', 'javascript'];
|
|
72
|
+
* readonly strategies: DetectionStrategy[] = ['structural', 'learning', 'semantic'];
|
|
73
|
+
*
|
|
74
|
+
* protected async detectWithStrategy(
|
|
75
|
+
* strategy: DetectionStrategy,
|
|
76
|
+
* context: DetectionContext
|
|
77
|
+
* ): Promise<StrategyResult> {
|
|
78
|
+
* switch (strategy) {
|
|
79
|
+
* case 'structural':
|
|
80
|
+
* return this.detectStructural(context);
|
|
81
|
+
* case 'learning':
|
|
82
|
+
* return this.detectLearning(context);
|
|
83
|
+
* case 'semantic':
|
|
84
|
+
* return this.detectSemantic(context);
|
|
85
|
+
* default:
|
|
86
|
+
* return this.createSkippedResult(strategy, 'Not implemented');
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare abstract class UnifiedDetector extends BaseDetector {
|
|
93
|
+
/**
|
|
94
|
+
* Detection strategies this detector supports
|
|
95
|
+
*
|
|
96
|
+
* Override this to specify which strategies the detector implements.
|
|
97
|
+
* The detect() method will run all supported strategies and merge results.
|
|
98
|
+
*/
|
|
99
|
+
abstract readonly strategies: DetectionStrategy[];
|
|
100
|
+
/**
|
|
101
|
+
* Primary detection method (for BaseDetector compatibility)
|
|
102
|
+
*
|
|
103
|
+
* This is derived from the first strategy in the strategies array.
|
|
104
|
+
*/
|
|
105
|
+
get detectionMethod(): 'ast' | 'regex' | 'semantic' | 'structural' | 'custom';
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for merging strategy results
|
|
108
|
+
*
|
|
109
|
+
* Override this to customize how results from different strategies
|
|
110
|
+
* are combined.
|
|
111
|
+
*/
|
|
112
|
+
protected mergeConfig: MergeConfig;
|
|
113
|
+
/**
|
|
114
|
+
* Detect patterns and violations using all supported strategies
|
|
115
|
+
*
|
|
116
|
+
* Runs each strategy in parallel, then merges the results according
|
|
117
|
+
* to the merge configuration.
|
|
118
|
+
*
|
|
119
|
+
* @param context - Detection context
|
|
120
|
+
* @param options - Optional strategy options
|
|
121
|
+
* @returns Merged detection results
|
|
122
|
+
*/
|
|
123
|
+
detect(context: DetectionContext, options?: StrategyOptions): Promise<DetectionResult>;
|
|
124
|
+
/**
|
|
125
|
+
* Run detection with a specific strategy
|
|
126
|
+
*
|
|
127
|
+
* Subclasses must implement this method to provide strategy-specific
|
|
128
|
+
* detection logic.
|
|
129
|
+
*
|
|
130
|
+
* @param strategy - The strategy to use
|
|
131
|
+
* @param context - Detection context
|
|
132
|
+
* @returns Strategy result
|
|
133
|
+
*/
|
|
134
|
+
protected abstract detectWithStrategy(strategy: DetectionStrategy, context: DetectionContext): Promise<StrategyResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Merge results from multiple strategies
|
|
137
|
+
*
|
|
138
|
+
* Combines patterns and violations from all strategies, handling
|
|
139
|
+
* duplicates according to the merge configuration.
|
|
140
|
+
*
|
|
141
|
+
* @param results - Array of strategy results
|
|
142
|
+
* @returns Merged detection result
|
|
143
|
+
*/
|
|
144
|
+
protected mergeResults(results: StrategyResult[]): DetectionResult;
|
|
145
|
+
/**
|
|
146
|
+
* Merge patterns from multiple strategies
|
|
147
|
+
*
|
|
148
|
+
* Handles duplicates based on location (file + line + column).
|
|
149
|
+
*/
|
|
150
|
+
private mergePatterns;
|
|
151
|
+
/**
|
|
152
|
+
* Merge violations from multiple strategies
|
|
153
|
+
*
|
|
154
|
+
* Handles duplicates based on location and message.
|
|
155
|
+
*/
|
|
156
|
+
private mergeViolations;
|
|
157
|
+
/**
|
|
158
|
+
* Calculate combined confidence from multiple strategy results
|
|
159
|
+
*/
|
|
160
|
+
private calculateCombinedConfidence;
|
|
161
|
+
/**
|
|
162
|
+
* Create a strategy result with patterns
|
|
163
|
+
*/
|
|
164
|
+
protected createStrategyResult(strategy: DetectionStrategy, patterns: PatternMatch[], violations?: Violation[], confidence?: number): StrategyResult;
|
|
165
|
+
/**
|
|
166
|
+
* Create an empty strategy result
|
|
167
|
+
*/
|
|
168
|
+
protected createEmptyStrategyResult(strategy: DetectionStrategy, confidence?: number): StrategyResult;
|
|
169
|
+
/**
|
|
170
|
+
* Create a skipped strategy result
|
|
171
|
+
*/
|
|
172
|
+
protected createSkippedResult(strategy: DetectionStrategy, reason: string): StrategyResult;
|
|
173
|
+
/**
|
|
174
|
+
* Check if a strategy is supported by this detector
|
|
175
|
+
*/
|
|
176
|
+
protected supportsStrategy(strategy: DetectionStrategy): boolean;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Type guard to check if a detector is a unified detector
|
|
180
|
+
*/
|
|
181
|
+
export declare function isUnifiedDetector(detector: BaseDetector): detector is UnifiedDetector;
|
|
182
|
+
export type { DetectionContext, DetectionResult };
|
|
183
|
+
//# sourceMappingURL=unified-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-detector.d.ts","sourceRoot":"","sources":["../../src/base/unified-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAM/F;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,KAAK,GACL,OAAO,GACP,UAAU,GACV,UAAU,CAAC;AAEf;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,wCAAwC;IACxC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,4DAA4D;IAC5D,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACjC,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,GAAG,OAAO,CAAC;IAC5D,uCAAuC;IACvC,qBAAqB,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;IAC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AAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,GACb,cAAc;IAWjB;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO;CAGjE;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,QAAQ,IAAI,eAAe,CAErF;AAMD,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Detector - Composite detector with multiple detection strategies
|
|
3
|
+
*
|
|
4
|
+
* Consolidates detector variants (base, learning, semantic) into a single class
|
|
5
|
+
* that can run multiple detection strategies and merge results.
|
|
6
|
+
*
|
|
7
|
+
* This is part of Phase 4 of the Pattern System Consolidation.
|
|
8
|
+
*
|
|
9
|
+
* @requirements 6.4 - THE Detector_System SHALL support multiple detection methods
|
|
10
|
+
*/
|
|
11
|
+
import { BaseDetector } from './base-detector.js';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Default Configuration
|
|
14
|
+
// ============================================================================
|
|
15
|
+
const DEFAULT_MERGE_CONFIG = {
|
|
16
|
+
duplicateHandling: 'highest-confidence',
|
|
17
|
+
confidenceCombination: 'max',
|
|
18
|
+
strategyWeights: {
|
|
19
|
+
structural: 1.0,
|
|
20
|
+
ast: 1.0,
|
|
21
|
+
regex: 0.8,
|
|
22
|
+
semantic: 0.7,
|
|
23
|
+
learning: 0.9,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Unified Detector Abstract Class
|
|
28
|
+
// ============================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Abstract base class for unified detectors
|
|
31
|
+
*
|
|
32
|
+
* Unified detectors combine multiple detection strategies (structural, AST,
|
|
33
|
+
* regex, semantic, learning) into a single detector class. This reduces
|
|
34
|
+
* code duplication and makes it easier to maintain detection logic.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* class FileNamingDetector extends UnifiedDetector {
|
|
39
|
+
* readonly id = 'structural/file-naming';
|
|
40
|
+
* readonly category = 'structural';
|
|
41
|
+
* readonly subcategory = 'naming-conventions';
|
|
42
|
+
* readonly name = 'File Naming Convention Detector';
|
|
43
|
+
* readonly description = 'Detects file naming patterns';
|
|
44
|
+
* readonly supportedLanguages = ['typescript', 'javascript'];
|
|
45
|
+
* readonly strategies: DetectionStrategy[] = ['structural', 'learning', 'semantic'];
|
|
46
|
+
*
|
|
47
|
+
* protected async detectWithStrategy(
|
|
48
|
+
* strategy: DetectionStrategy,
|
|
49
|
+
* context: DetectionContext
|
|
50
|
+
* ): Promise<StrategyResult> {
|
|
51
|
+
* switch (strategy) {
|
|
52
|
+
* case 'structural':
|
|
53
|
+
* return this.detectStructural(context);
|
|
54
|
+
* case 'learning':
|
|
55
|
+
* return this.detectLearning(context);
|
|
56
|
+
* case 'semantic':
|
|
57
|
+
* return this.detectSemantic(context);
|
|
58
|
+
* default:
|
|
59
|
+
* return this.createSkippedResult(strategy, 'Not implemented');
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export class UnifiedDetector extends BaseDetector {
|
|
66
|
+
/**
|
|
67
|
+
* Primary detection method (for BaseDetector compatibility)
|
|
68
|
+
*
|
|
69
|
+
* This is derived from the first strategy in the strategies array.
|
|
70
|
+
*/
|
|
71
|
+
get detectionMethod() {
|
|
72
|
+
const primary = this.strategies[0];
|
|
73
|
+
if (primary === 'learning')
|
|
74
|
+
return 'custom';
|
|
75
|
+
return primary || 'custom';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for merging strategy results
|
|
79
|
+
*
|
|
80
|
+
* Override this to customize how results from different strategies
|
|
81
|
+
* are combined.
|
|
82
|
+
*/
|
|
83
|
+
mergeConfig = DEFAULT_MERGE_CONFIG;
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// Main Detection Method
|
|
86
|
+
// ============================================================================
|
|
87
|
+
/**
|
|
88
|
+
* Detect patterns and violations using all supported strategies
|
|
89
|
+
*
|
|
90
|
+
* Runs each strategy in parallel, then merges the results according
|
|
91
|
+
* to the merge configuration.
|
|
92
|
+
*
|
|
93
|
+
* @param context - Detection context
|
|
94
|
+
* @param options - Optional strategy options
|
|
95
|
+
* @returns Merged detection results
|
|
96
|
+
*/
|
|
97
|
+
async detect(context, options = {}) {
|
|
98
|
+
const strategiesToRun = options.strategies ?? this.strategies;
|
|
99
|
+
const minConfidence = options.minConfidence ?? 0;
|
|
100
|
+
// Run all strategies in parallel
|
|
101
|
+
const strategyResults = await Promise.all(strategiesToRun.map(async (strategy) => {
|
|
102
|
+
try {
|
|
103
|
+
return await this.detectWithStrategy(strategy, context);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.warn(`Strategy ${strategy} failed for ${this.id}:`, error);
|
|
107
|
+
return this.createSkippedResult(strategy, error instanceof Error ? error.message : 'Unknown error');
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
// Filter out skipped strategies and low-confidence results
|
|
111
|
+
const validResults = strategyResults.filter((r) => !r.skipped && r.confidence >= minConfidence);
|
|
112
|
+
// Check for early exit
|
|
113
|
+
if (options.stopOnFirstMatch && validResults.length > 0) {
|
|
114
|
+
const first = validResults[0];
|
|
115
|
+
if (first.patterns.length > 0 || first.violations.length > 0) {
|
|
116
|
+
return this.createResult(first.patterns, first.violations, first.confidence, { custom: { strategy: first.strategy } });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Merge results from all strategies
|
|
120
|
+
return this.mergeResults(validResults);
|
|
121
|
+
}
|
|
122
|
+
// ============================================================================
|
|
123
|
+
// Result Merging
|
|
124
|
+
// ============================================================================
|
|
125
|
+
/**
|
|
126
|
+
* Merge results from multiple strategies
|
|
127
|
+
*
|
|
128
|
+
* Combines patterns and violations from all strategies, handling
|
|
129
|
+
* duplicates according to the merge configuration.
|
|
130
|
+
*
|
|
131
|
+
* @param results - Array of strategy results
|
|
132
|
+
* @returns Merged detection result
|
|
133
|
+
*/
|
|
134
|
+
mergeResults(results) {
|
|
135
|
+
if (results.length === 0) {
|
|
136
|
+
return this.createEmptyResult();
|
|
137
|
+
}
|
|
138
|
+
if (results.length === 1) {
|
|
139
|
+
const r = results[0];
|
|
140
|
+
return this.createResult(r.patterns, r.violations, r.confidence);
|
|
141
|
+
}
|
|
142
|
+
// Merge patterns
|
|
143
|
+
const mergedPatterns = this.mergePatterns(results.flatMap((r) => r.patterns.map((p) => ({ ...p, _strategy: r.strategy }))));
|
|
144
|
+
// Merge violations
|
|
145
|
+
const mergedViolations = this.mergeViolations(results.flatMap((r) => r.violations.map((v) => ({ ...v, _strategy: r.strategy }))));
|
|
146
|
+
// Calculate combined confidence
|
|
147
|
+
const confidence = this.calculateCombinedConfidence(results);
|
|
148
|
+
return this.createResult(mergedPatterns, mergedViolations, confidence, {
|
|
149
|
+
custom: {
|
|
150
|
+
strategies: results.map((r) => r.strategy),
|
|
151
|
+
strategyConfidences: Object.fromEntries(results.map((r) => [r.strategy, r.confidence])),
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Merge patterns from multiple strategies
|
|
157
|
+
*
|
|
158
|
+
* Handles duplicates based on location (file + line + column).
|
|
159
|
+
*/
|
|
160
|
+
mergePatterns(patterns) {
|
|
161
|
+
const byLocation = new Map();
|
|
162
|
+
for (const pattern of patterns) {
|
|
163
|
+
const key = `${pattern.location.file}:${pattern.location.line}:${pattern.location.column}:${pattern.patternId}`;
|
|
164
|
+
const existing = byLocation.get(key);
|
|
165
|
+
if (!existing) {
|
|
166
|
+
byLocation.set(key, pattern);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
// Handle duplicate based on config
|
|
170
|
+
switch (this.mergeConfig.duplicateHandling) {
|
|
171
|
+
case 'highest-confidence':
|
|
172
|
+
if (pattern.confidence > existing.confidence) {
|
|
173
|
+
byLocation.set(key, pattern);
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
case 'first':
|
|
177
|
+
// Keep existing (first)
|
|
178
|
+
break;
|
|
179
|
+
case 'merge':
|
|
180
|
+
// Merge by taking highest confidence
|
|
181
|
+
byLocation.set(key, {
|
|
182
|
+
...existing,
|
|
183
|
+
confidence: Math.max(existing.confidence, pattern.confidence),
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
// Remove internal _strategy field
|
|
190
|
+
return Array.from(byLocation.values()).map(({ _strategy, ...p }) => p);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Merge violations from multiple strategies
|
|
194
|
+
*
|
|
195
|
+
* Handles duplicates based on location and message.
|
|
196
|
+
*/
|
|
197
|
+
mergeViolations(violations) {
|
|
198
|
+
const byKey = new Map();
|
|
199
|
+
for (const violation of violations) {
|
|
200
|
+
const key = `${violation.file}:${violation.range.start.line}:${violation.range.start.character}:${violation.patternId}`;
|
|
201
|
+
const existing = byKey.get(key);
|
|
202
|
+
if (!existing) {
|
|
203
|
+
byKey.set(key, violation);
|
|
204
|
+
}
|
|
205
|
+
// For violations, we typically keep the first one (most specific)
|
|
206
|
+
}
|
|
207
|
+
// Remove internal _strategy field
|
|
208
|
+
return Array.from(byKey.values()).map(({ _strategy, ...v }) => v);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Calculate combined confidence from multiple strategy results
|
|
212
|
+
*/
|
|
213
|
+
calculateCombinedConfidence(results) {
|
|
214
|
+
if (results.length === 0)
|
|
215
|
+
return 0;
|
|
216
|
+
switch (this.mergeConfig.confidenceCombination) {
|
|
217
|
+
case 'max':
|
|
218
|
+
return Math.max(...results.map((r) => r.confidence));
|
|
219
|
+
case 'average':
|
|
220
|
+
return results.reduce((sum, r) => sum + r.confidence, 0) / results.length;
|
|
221
|
+
case 'weighted': {
|
|
222
|
+
const weights = this.mergeConfig.strategyWeights ?? {};
|
|
223
|
+
let totalWeight = 0;
|
|
224
|
+
let weightedSum = 0;
|
|
225
|
+
for (const result of results) {
|
|
226
|
+
const weight = weights[result.strategy] ?? 1.0;
|
|
227
|
+
weightedSum += result.confidence * weight;
|
|
228
|
+
totalWeight += weight;
|
|
229
|
+
}
|
|
230
|
+
return totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
231
|
+
}
|
|
232
|
+
default:
|
|
233
|
+
return Math.max(...results.map((r) => r.confidence));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// ============================================================================
|
|
237
|
+
// Helper Methods for Subclasses
|
|
238
|
+
// ============================================================================
|
|
239
|
+
/**
|
|
240
|
+
* Create a strategy result with patterns
|
|
241
|
+
*/
|
|
242
|
+
createStrategyResult(strategy, patterns, violations = [], confidence = 1.0) {
|
|
243
|
+
return {
|
|
244
|
+
strategy,
|
|
245
|
+
patterns,
|
|
246
|
+
violations,
|
|
247
|
+
confidence,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Create an empty strategy result
|
|
252
|
+
*/
|
|
253
|
+
createEmptyStrategyResult(strategy, confidence = 1.0) {
|
|
254
|
+
return {
|
|
255
|
+
strategy,
|
|
256
|
+
patterns: [],
|
|
257
|
+
violations: [],
|
|
258
|
+
confidence,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Create a skipped strategy result
|
|
263
|
+
*/
|
|
264
|
+
createSkippedResult(strategy, reason) {
|
|
265
|
+
return {
|
|
266
|
+
strategy,
|
|
267
|
+
patterns: [],
|
|
268
|
+
violations: [],
|
|
269
|
+
confidence: 0,
|
|
270
|
+
skipped: true,
|
|
271
|
+
skipReason: reason,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Check if a strategy is supported by this detector
|
|
276
|
+
*/
|
|
277
|
+
supportsStrategy(strategy) {
|
|
278
|
+
return this.strategies.includes(strategy);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// ============================================================================
|
|
282
|
+
// Type Guards
|
|
283
|
+
// ============================================================================
|
|
284
|
+
/**
|
|
285
|
+
* Type guard to check if a detector is a unified detector
|
|
286
|
+
*/
|
|
287
|
+
export function isUnifiedDetector(detector) {
|
|
288
|
+
return 'strategies' in detector && Array.isArray(detector.strategies);
|
|
289
|
+
}
|
|
290
|
+
//# sourceMappingURL=unified-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified-detector.js","sourceRoot":"","sources":["../../src/base/unified-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH,OAAO,EAAE,YAAY,EAA+C,MAAM,oBAAoB,CAAC;AA0D/F,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,MAAM,oBAAoB,GAAgB;IACxC,iBAAiB,EAAE,oBAAoB;IACvC,qBAAqB,EAAE,KAAK;IAC5B,eAAe,EAAE;QACf,UAAU,EAAE,GAAG;QACf,GAAG,EAAE,GAAG;QACR,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,GAAG;QACb,QAAQ,EAAE,GAAG;KACd;CACF,CAAC;AAEF,+EAA+E;AAC/E,kCAAkC;AAClC,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,OAAgB,eAAgB,SAAQ,YAAY;IASxD;;;;OAIG;IACH,IAAI,eAAe;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,OAAO,KAAK,UAAU;YAAE,OAAO,QAAQ,CAAC;QAC5C,OAAO,OAAO,IAAI,QAAQ,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACO,WAAW,GAAgB,oBAAoB,CAAC;IAE1D,+EAA+E;IAC/E,wBAAwB;I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OAEG;IACO,oBAAoB,CAC5B,QAA2B,EAC3B,QAAwB,EACxB,aAA0B,EAAE,EAC5B,aAAqB,GAAG;QAExB,OAAO;YACL,QAAQ;YACR,QAAQ;YACR,UAAU;YACV,UAAU;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,yBAAyB,CACjC,QAA2B,EAC3B,aAAqB,GAAG;QAExB,OAAO;YACL,QAAQ;YACR,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,EAAE;YACd,UAAU;SACX,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,mBAAmB,CAC3B,QAA2B,EAC3B,MAAc;QAEd,OAAO;YACL,QAAQ;YACR,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,EAAE;YACd,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,MAAM;SACnB,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,gBAAgB,CAAC,QAA2B;QACpD,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAsB;IACtD,OAAO,YAAY,IAAI,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,QAA4B,CAAC,UAAU,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified File Naming Detector
|
|
3
|
+
*
|
|
4
|
+
* Consolidates file-naming.ts, file-naming-learning.ts, and file-naming-semantic.ts
|
|
5
|
+
* into a single detector with multiple detection strategies.
|
|
6
|
+
*
|
|
7
|
+
* Strategies:
|
|
8
|
+
* - structural: Analyzes file/directory structure patterns
|
|
9
|
+
* - learning: Learns conventions from the codebase
|
|
10
|
+
* - semantic: Keyword-based semantic matching
|
|
11
|
+
*
|
|
12
|
+
* @requirements 7.1 - THE Structural_Detector SHALL detect file naming conventions
|
|
13
|
+
* @requirements DRIFT-CORE - Learn patterns from user's code
|
|
14
|
+
*/
|
|
15
|
+
import type { Violation, QuickFix, Language } from 'driftdetect-core';
|
|
16
|
+
import { UnifiedDetector, type DetectionStrategy, type StrategyResult, type DetectionContext } from '../base/index.js';
|
|
17
|
+
export type NamingConvention = 'PascalCase' | 'camelCase' | 'kebab-case' | 'snake_case' | 'SCREAMING_SNAKE_CASE' | 'unknown';
|
|
18
|
+
export interface SuffixPattern {
|
|
19
|
+
suffix: string;
|
|
20
|
+
description: string;
|
|
21
|
+
expectedConvention?: NamingConvention;
|
|
22
|
+
}
|
|
23
|
+
export interface NamingPattern {
|
|
24
|
+
convention: NamingConvention;
|
|
25
|
+
extension: string;
|
|
26
|
+
suffix: string | undefined;
|
|
27
|
+
count: number;
|
|
28
|
+
examples: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface FileNamingAnalysis {
|
|
31
|
+
fileName: string;
|
|
32
|
+
baseName: string;
|
|
33
|
+
convention: NamingConvention;
|
|
34
|
+
extension: string;
|
|
35
|
+
suffix: string | undefined;
|
|
36
|
+
followsPattern: boolean;
|
|
37
|
+
suggestedName: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
export interface LearnedConventions {
|
|
40
|
+
componentNaming: NamingConvention | null;
|
|
41
|
+
utilityNaming: NamingConvention | null;
|
|
42
|
+
hookNaming: NamingConvention | null;
|
|
43
|
+
serviceNaming: NamingConvention | null;
|
|
44
|
+
testSuffix: '.test' | '.spec' | null;
|
|
45
|
+
usesIndexFiles: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare const COMMON_SUFFIXES: SuffixPattern[];
|
|
48
|
+
export declare function detectNamingConvention(name: string): NamingConvention;
|
|
49
|
+
export declare function splitIntoWords(name: string): string[];
|
|
50
|
+
export declare function convertToConvention(name: string, target: NamingConvention): string;
|
|
51
|
+
export declare function extractBaseName(fileName: string, suffixes?: SuffixPattern[]): {
|
|
52
|
+
baseName: string;
|
|
53
|
+
suffix: string | undefined;
|
|
54
|
+
extension: string;
|
|
55
|
+
};
|
|
56
|
+
export declare function analyzeFileName(filePath: string, dominant?: NamingConvention): FileNamingAnalysis;
|
|
57
|
+
export declare class FileNamingUnifiedDetector extends UnifiedDetector {
|
|
58
|
+
readonly id = "structural/file-naming";
|
|
59
|
+
readonly category: "structural";
|
|
60
|
+
readonly subcategory = "naming-conventions";
|
|
61
|
+
readonly name = "File Naming Convention Detector";
|
|
62
|
+
readonly description = "Detects file naming patterns using structural analysis, learning, and semantic matching";
|
|
63
|
+
readonly supportedLanguages: Language[];
|
|
64
|
+
readonly strategies: DetectionStrategy[];
|
|
65
|
+
private learnedConventions;
|
|
66
|
+
protected detectWithStrategy(strategy: DetectionStrategy, context: DetectionContext): Promise<StrategyResult>;
|
|
67
|
+
private detectStructural;
|
|
68
|
+
private analyzeProjectFiles;
|
|
69
|
+
private getDominantConvention;
|
|
70
|
+
private createStructuralPatternMatch;
|
|
71
|
+
private createConventionViolation;
|
|
72
|
+
private checkSuffixPattern;
|
|
73
|
+
private calculateStructuralConfidence;
|
|
74
|
+
private detectLearning;
|
|
75
|
+
private learnConventions;
|
|
76
|
+
private createLearningViolation;
|
|
77
|
+
private detectSemantic;
|
|
78
|
+
generateQuickFix(violation: Violation): QuickFix | null;
|
|
79
|
+
}
|
|
80
|
+
export declare function createFileNamingUnifiedDetector(): FileNamingUnifiedDetector;
|
|
81
|
+
export { FileNamingUnifiedDetector as FileNamingDetector };
|
|
82
|
+
//# sourceMappingURL=file-naming-unified.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-naming-unified.d.ts","sourceRoot":"","sources":["../../src/structural/file-naming-unified.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAgB,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAS,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EACL,eAAe,EACf,KAAK,iBAAi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jE;AAMD,wBAAgB,+BAA+B,IAAI,yBAAyB,CAE3E;AAGD,OAAO,EAAE,yBAAyB,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified File Naming Detector
|
|
3
|
+
*
|
|
4
|
+
* Consolidates file-naming.ts, file-naming-learning.ts, and file-naming-semantic.ts
|
|
5
|
+
* into a single detector with multiple detection strategies.
|
|
6
|
+
*
|
|
7
|
+
* Strategies:
|
|
8
|
+
* - structural: Analyzes file/directory structure patterns
|
|
9
|
+
* - learning: Learns conventions from the codebase
|
|
10
|
+
* - semantic: Keyword-based semantic matching
|
|
11
|
+
*
|
|
12
|
+
* @requirements 7.1 - THE Structural_Detector SHALL detect file naming conventions
|
|
13
|
+
* @requirements DRIFT-CORE - Learn patterns from user's code
|
|
14
|
+
*/
|
|
15
|
+
import { UnifiedDetector, ValueDistribution, } from '../base/index.js';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Constants
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export const COMMON_SUFFIXES = [
|
|
20
|
+
{ suffix: '.service', description: 'Service file', expectedConvention: 'kebab-case' },
|
|
21
|
+
{ suffix: '.controller', description: 'Controller file', expectedConvention: 'kebab-case' },
|
|
22
|
+
{ suffix: '.model', description: 'Model file', expectedConvention: 'PascalCase' },
|
|
23
|
+
{ suffix: '.test', description: 'Test file' },
|
|
24
|
+
{ suffix: '.spec', description: 'Spec file' },
|
|
25
|
+
{ suffix: '.stories', description: 'Storybook file', expectedConvention: 'PascalCase' },
|
|
26
|
+
{ suffix: '.hook', description: 'Hook file', expectedConvention: 'camelCase' },
|
|
27
|
+
{ suffix: '.utils', description: 'Utilities file', expectedConvention: 'kebab-case' },
|
|
28
|
+
{ suffix: '.types', description: 'Types file', expectedConvention: 'kebab-case' },
|
|
29
|
+
{ suffix: '.schema', description: 'Schema file', expectedConvention: 'kebab-case' },
|
|
30
|
+
{ suffix: '.context', description: 'Context file', expectedConvention: 'PascalCase' },
|
|
31
|
+
{ suffix: '.reducer', description: 'Reducer file', expectedConvention: 'camelCase' },
|
|
32
|
+
{ suffix: '.page', description: 'Page file', expectedConvention: 'PascalCase' },
|
|
33
|
+
{ suffix: '.layout', description: 'Layout file', expectedConvention: 'PascalCase' },
|
|
34
|
+
{ suffix: '.component', description: 'Component file', expectedConvention: 'PascalCase' },
|
|
35
|
+
{ suffix: '.styles', description: 'Styles file', expectedConvention: 'kebab-case' },
|
|
36
|
+
];
|
|
37
|
+
const SPECIAL_FILES = [
|
|
38
|
+
'index', 'main', 'app', 'readme', 'license', 'changelog', 'dockerfile',
|
|
39
|
+
'makefile', 'package', 'tsconfig', 'eslint', 'prettier', 'jest', 'vitest',
|
|
40
|
+
'vite', 'webpack', 'rollup', 'babel', 'postcss', 'tailwind', 'next',
|
|
41
|
+
];
|
|
42
|
+
const SEMANTIC_KEYWORDS = [
|
|
43
|
+
'file', 'name', 'naming', 'convention', 'case',
|
|
44
|
+
'camel', 'pascal', 'kebab', 'snake',
|
|
45
|
+
];
|
|
46
|
+
// ============================================================================
|
|
47
|
+
// Utility Functions
|
|
48
|
+
// ============================================================================
|
|
49
|
+
export function detectNamingConvention(name) {
|
|
50
|
+
if (!name || name.length === 0)
|
|
51
|
+
return 'unknown';
|
|
52
|
+
if (/^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/.test(name))
|
|
53
|
+
return 'SCREAMING_SNAKE_CASE';
|
|
54
|
+
if (/^[A-Z][a-zA-Z0-9]*$/.test(name))
|
|
55
|
+
return 'PascalCase';
|
|
56
|
+
if (/^[a-z][a-zA-Z0-9]*$/.test(name) && /[A-Z]/.test(name))
|
|
57
|
+
return 'camelCase';
|
|
58
|
+
if (/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(name))
|
|
59
|
+
return 'kebab-case';
|
|
60
|
+
if (/^[a-z][a-z0-9]*(_[a-z0-9]+)*$/.test(name))
|
|
61
|
+
return 'snake_case';
|
|
62
|
+
if (/^[a-z][a-z0-9]*$/.test(name))
|
|
63
|
+
return 'kebab-case';
|
|
64
|
+
return 'unknown';
|
|
65
|
+
}
|
|
66
|
+
export function splitIntoWords(name) {
|
|
67
|
+
let n = name.replace(/[-_]/g, ' ');
|
|
68
|
+
n = n.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
69
|
+
n = n.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');
|
|
70
|
+
return n.split(/\s+/).filter((w) => w.length > 0);
|
|
71
|
+
}
|
|
72
|
+
export function convertToConvention(name, target) {
|
|
73
|
+
const words = splitIntoWords(name);
|
|
74
|
+
if (words.length === 0)
|
|
75
|
+
return name;
|
|
76
|
+
switch (target) {
|
|
77
|
+
case 'PascalCase':
|
|
78
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('');
|
|
79
|
+
case 'camelCase':
|
|
80
|
+
return words.map((w, i) => i === 0 ? w.toLowerCase() : w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join('');
|
|
81
|
+
case 'kebab-case':
|
|
82
|
+
return words.map((w) => w.toLowerCase()).join('-');
|
|
83
|
+
case 'snake_case':
|
|
84
|
+
return words.map((w) => w.toLowerCase()).join('_');
|
|
85
|
+
case 'SCREAMING_SNAKE_CASE':
|
|
86
|
+
return words.map((w) => w.toUpperCase()).join('_');
|
|
87
|
+
default:
|
|
88
|
+
return name;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
export function extractBaseName(fileName, suffixes = COMMON_SUFFIXES) {
|
|
92
|
+
const lastDot = fileName.lastIndexOf('.');
|
|
93
|
+
if (lastDot === -1)
|
|
94
|
+
return { baseName: fileName, suffix: undefined, extension: '' };
|
|
95
|
+
const ext = fileName.slice(lastDot);
|
|
96
|
+
const nameNoExt = fileName.slice(0, lastDot);
|
|
97
|
+
for (const { suffix } of suffixes) {
|
|
98
|
+
if (nameNoExt.toLowerCase().endsWith(suffix.toLowerCase())) {
|
|
99
|
+
const base = nameNoExt.slice(0, -suffix.length);
|
|
100
|
+
if (base.length > 0)
|
|
101
|
+
return { baseName: base, suffix, extension: ext };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return { baseName: nameNoExt, suffix: undefined, extension: ext };
|
|
105
|
+
}
|
|
106
|
+
export function analyzeFileName(filePath, dominant) {
|
|
107
|
+
const fileName = filePath.split(/[/\\]/).pop() ?? filePath;
|
|
108
|
+
const { baseName, suffix, extension } = extractBaseName(fileName);
|
|
109
|
+
const convention = detectNamingConvention(baseName);
|
|
110
|
+
const followsPattern = dominant === undefined || convention === dominant;
|
|
111
|
+
let suggestedName;
|
|
112
|
+
if (!followsPattern && dominant && dominant !== 'unknown') {
|
|
113
|
+
const converted = convertToConvention(baseName, dominant);
|
|
114
|
+
suggestedName = suffix ? `${converted}${suffix}${extension}` : `${converted}${extension}`;
|
|
115
|
+
}
|
|
116
|
+
return { fileName, baseName, convention, extension, suffix, followsPattern, suggestedName };
|
|
117
|
+
}
|
|
118
|
+
function getFileType(filePath) {
|
|
119
|
+
const filename = filePath.split('/').pop() || '';
|
|
120
|
+
const lowerPath = filePath.toLowerCase();
|
|
121
|
+
if (filename === 'index.ts' || filename === 'index.tsx' || filename === 'index.js')
|
|
122
|
+
return 'index';
|
|
123
|
+
if (/\.test\.[jt]sx?$/.test(filename) || /\.spec\.[jt]sx?$/.test(filename))
|
|
124
|
+
return 'test';
|
|
125
|
+
if (/^use[A-Z]/.test(filename) || lowerPath.includes('/hooks/'))
|
|
126
|
+
return 'hook';
|
|
127
|
+
if (lowerPath.includes('/services/') || /Service\.[jt]sx?$/.test(filename))
|
|
128
|
+
return 'service';
|
|
129
|
+
if (lowerPath.includes('/components/') || /\.[jt]sx$/.test(filename))
|
|
130
|
+
return 'component';
|
|
131
|
+
if (lowerPath.includes('/utils/') || lowerPath.includes('/helpers/') || lowerPath.includes('/lib/'))
|
|
132
|
+
return 'utility';
|
|
133
|
+
return 'other';
|
|
134
|
+
}
|
|
135
|
+
function isSpecialFile(fileName) {
|
|
136
|
+
const lower = fileName.toLowerCase().replace(/\.[^.]+$/, '');
|
|
137
|
+
return SPECIAL_FILES.some((s) => lower === s || lower.startsWith(`${s}.`));
|
|
138
|
+
}
|
|
139
|
+
function isReactComponentFile(file) {
|
|
140
|
+
return /\.(tsx|jsx)$/.test(file);
|
|
141
|
+
}
|
|
142
|
+
function isReactHookFile(fileName) {
|
|
143
|
+
const baseName = fileName.replace(/\.[^.]+$/, '');
|
|
144
|
+
return /^use[A-Z]/.test(baseName);
|
|
145
|
+
}
|
|
146
|
+
// ============================================================================
|
|
147
|
+
// Unified File Naming Detector
|
|
148
|
+
// ============================================================================
|
|
149
|
+
export class FileNamingUnifiedDetector extends UnifiedDetector {
|
|
150
|
+
id = 'structural/file-naming';
|
|
151
|
+
category = 'structural';
|
|
152
|
+
subcategory = 'naming-conventions';
|
|
153
|
+
name = 'File Naming Convention Detector';
|
|
154
|
+
description = 'Detects file naming patterns using structural analysis, learning, and semantic matching';
|
|
155
|
+
supportedLanguages = [
|
|
156
|
+
'typescript', 'javascript', 'python', 'css', 'scss', 'json', 'yaml', 'markdown'
|
|
157
|
+
];
|
|
158
|
+
strategies = ['structural', 'learning', 'semantic'];
|
|
159
|
+
// Learned conventions cache (populated by learning strategy)
|
|
160
|
+
learnedConventions = null;
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// Strategy Dispatch
|
|
163
|
+
// ============================================================================
|
|
164
|
+
async detectWithStrategy(strategy, context) {
|
|
165
|
+
switch (strategy) {
|
|
166
|
+
case 'structural':
|
|
167
|
+
return this.detectStructural(context);
|
|
168
|
+
case 'learning':
|
|
169
|
+
return this.detectLearning(context);
|
|
170
|
+
case 'semantic':
|
|
171
|
+
return this.detectSemantic(context);
|
|
172
|
+
default:
|
|
173
|
+
return this.createSkippedResult(strategy, `Strategy '${strategy}' not implemented`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// Structural Detection (from file-naming.ts)
|
|
178
|
+
// ============================================================================
|
|
179
|
+
async detectStructural(context) {
|
|
180
|
+
const patterns = [];
|
|
181
|
+
const violations = [];
|
|
182
|
+
const analysis = analyzeFileName(context.file);
|
|
183
|
+
const projectAnalysis = this.analyzeProjectFiles(context.projectContext.files);
|
|
184
|
+
const dominant = this.getDominantConvention(projectAnalysis);
|
|
185
|
+
// Create pattern match if convention detected
|
|
186
|
+
if (analysis.convention !== 'unknown') {
|
|
187
|
+
patterns.push(this.createStructuralPatternMatch(context.file, analysis, projectAnalysis));
|
|
188
|
+
}
|
|
189
|
+
// Check for convention violations
|
|
190
|
+
if (dominant && analysis.convention !== dominant) {
|
|
191
|
+
const v = this.createConventionViolation(context.file, analysis, dominant);
|
|
192
|
+
if (v)
|
|
193
|
+
violations.push(v);
|
|
194
|
+
}
|
|
195
|
+
// Check suffix pattern violations
|
|
196
|
+
const suffixV = this.checkSuffixPattern(context.file, analysis);
|
|
197
|
+
if (suffixV)
|
|
198
|
+
violations.push(suffixV);
|
|
199
|
+
const confidence = this.calculateStructuralConfidence(projectAnalysis);
|
|
200
|
+
return this.createStrategyResult('structural', patterns, violations, confidence);
|
|
201
|
+
}
|
|
202
|
+
analyzeProjectFiles(files) {
|
|
203
|
+
const patterns = new Map();
|
|
204
|
+
for (const file of files) {
|
|
205
|
+
const a = analyzeFileName(file);
|
|
206
|
+
if (a.convention === 'unknown')
|
|
207
|
+
continue;
|
|
208
|
+
const existing = patterns.get(a.convention);
|
|
209
|
+
if (existing) {
|
|
210
|
+
existing.count++;
|
|
211
|
+
if (existing.examples.length < 5)
|
|
212
|
+
existing.examples.push(file);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
patterns.set(a.convention, {
|
|
216
|
+
convention: a.convention,
|
|
217
|
+
extension: a.extension,
|
|
218
|
+
suffix: a.suffix,
|
|
219
|
+
count: 1,
|
|
220
|
+
examples: [file],
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return patterns;
|
|
225
|
+
}
|
|
226
|
+
getDominantConvention(patterns) {
|
|
227
|
+
let maxCount = 0;
|
|
228
|
+
let dominant;
|
|
229
|
+
for (const [conv, p] of patterns) {
|
|
230
|
+
if (p.count > maxCount) {
|
|
231
|
+
maxCount = p.count;
|
|
232
|
+
dominant = conv;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
const total = Array.from(patterns.values()).reduce((s, p) => s + p.count, 0);
|
|
236
|
+
return dominant && maxCount / total > 0.5 ? dominant : undefined;
|
|
237
|
+
}
|
|
238
|
+
createStructuralPatternMatch(file, analysis, projectAnalysis) {
|
|
239
|
+
const p = projectAnalysis.get(analysis.convention);
|
|
240
|
+
const total = Array.from(projectAnalysis.values()).reduce((s, x) => s + x.count, 0);
|
|
241
|
+
const freq = p ? p.count / total : 0;
|
|
242
|
+
return {
|
|
243
|
+
patternId: `file-naming-${analysis.convention}`,
|
|
244
|
+
location: { file, line: 1, column: 1 },
|
|
245
|
+
confidence: freq,
|
|
246
|
+
isOutlier: freq < 0.5,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
createConventionViolation(file, analysis, dominant) {
|
|
250
|
+
const fileName = file.split(/[/\\]/).pop() ?? '';
|
|
251
|
+
if (isSpecialFile(fileName))
|
|
252
|
+
return null;
|
|
253
|
+
// PascalCase is standard for React components
|
|
254
|
+
if (analysis.convention === 'PascalCase' && isReactComponentFile(file))
|
|
255
|
+
return null;
|
|
256
|
+
// camelCase is standard for React hooks
|
|
257
|
+
if (analysis.convention === 'camelCase' && isReactHookFile(fileName))
|
|
258
|
+
return null;
|
|
259
|
+
const suggested = analysis.suggestedName ??
|
|
260
|
+
convertToConvention(analysis.baseName, dominant) + (analysis.suffix ?? '') + analysis.extension;
|
|
261
|
+
const range = { start: { line: 1, character: 1 }, end: { line: 1, character: 1 } };
|
|
262
|
+
return {
|
|
263
|
+
id: `file-naming-${file.replace(/[^a-zA-Z0-9]/g, '-')}`,
|
|
264
|
+
patternId: 'structural/file-naming',
|
|
265
|
+
severity: 'warning',
|
|
266
|
+
file,
|
|
267
|
+
range,
|
|
268
|
+
message: `File '${fileName}' uses ${analysis.convention} but project uses ${dominant}. It should be renamed to '${suggested}'`,
|
|
269
|
+
expected: `${dominant} naming convention`,
|
|
270
|
+
actual: `${analysis.convention} naming convention`,
|
|
271
|
+
aiExplainAvailable: false,
|
|
272
|
+
aiFixAvailable: true,
|
|
273
|
+
firstSeen: new Date(),
|
|
274
|
+
occurrences: 1,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
checkSuffixPattern(file, analysis) {
|
|
278
|
+
if (!analysis.suffix)
|
|
279
|
+
return null;
|
|
280
|
+
const sp = COMMON_SUFFIXES.find((s) => s.suffix.toLowerCase() === analysis.suffix?.toLowerCase());
|
|
281
|
+
if (!sp?.expectedConvention || analysis.convention === sp.expectedConvention || analysis.convention === 'unknown') {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
const suggestedBase = convertToConvention(analysis.baseName, sp.expectedConvention);
|
|
285
|
+
const suggested = `${suggestedBase}${analysis.suffix}${analysis.extension}`;
|
|
286
|
+
const range = { start: { line: 1, character: 1 }, end: { line: 1, character: 1 } };
|
|
287
|
+
return {
|
|
288
|
+
id: `file-naming-suffix-${file.replace(/[^a-zA-Z0-9]/g, '-')}`,
|
|
289
|
+
patternId: 'structural/file-naming-suffix',
|
|
290
|
+
severity: 'info',
|
|
291
|
+
file,
|
|
292
|
+
range,
|
|
293
|
+
message: `${sp.description} '${analysis.fileName}' should use ${sp.expectedConvention} naming. It should be renamed to '${suggested}'`,
|
|
294
|
+
expected: `${sp.expectedConvention} naming for ${sp.description.toLowerCase()}`,
|
|
295
|
+
actual: `${analysis.convention} naming`,
|
|
296
|
+
aiExplainAvailable: false,
|
|
297
|
+
aiFixAvailable: true,
|
|
298
|
+
firstSeen: new Date(),
|
|
299
|
+
occurrences: 1,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
calculateStructuralConfidence(patterns) {
|
|
303
|
+
const total = Array.from(patterns.values()).reduce((s, p) => s + p.count, 0);
|
|
304
|
+
if (total === 0)
|
|
305
|
+
return 0.5;
|
|
306
|
+
let max = 0;
|
|
307
|
+
for (const p of patterns.values())
|
|
308
|
+
if (p.count > max)
|
|
309
|
+
max = p.count;
|
|
310
|
+
return Math.min(max / total + 0.2, 1.0);
|
|
311
|
+
}
|
|
312
|
+
// ============================================================================
|
|
313
|
+
// Learning Detection (from file-naming-learning.ts)
|
|
314
|
+
// ============================================================================
|
|
315
|
+
async detectLearning(context) {
|
|
316
|
+
const patterns = [];
|
|
317
|
+
const violations = [];
|
|
318
|
+
// Learn conventions from project files if not cached
|
|
319
|
+
if (!this.learnedConventions) {
|
|
320
|
+
this.learnedConventions = this.learnConventions(context.projectContext.files);
|
|
321
|
+
}
|
|
322
|
+
const filename = context.file.split('/').pop() || '';
|
|
323
|
+
const fileType = getFileType(context.file);
|
|
324
|
+
if (fileType === 'other' || fileType === 'index') {
|
|
325
|
+
return this.createEmptyStrategyResult('learning', 1.0);
|
|
326
|
+
}
|
|
327
|
+
const actualConvention = detectNamingConvention(filename.replace(/\.[^.]+$/, ''));
|
|
328
|
+
let expectedConvention = null;
|
|
329
|
+
let conventionKey = '';
|
|
330
|
+
switch (fileType) {
|
|
331
|
+
case 'component':
|
|
332
|
+
expectedConvention = this.learnedConventions.componentNaming;
|
|
333
|
+
conventionKey = 'component file naming';
|
|
334
|
+
break;
|
|
335
|
+
case 'utility':
|
|
336
|
+
expectedConvention = this.learnedConventions.utilityNaming;
|
|
337
|
+
conventionKey = 'utility file naming';
|
|
338
|
+
break;
|
|
339
|
+
case 'hook':
|
|
340
|
+
expectedConvention = this.learnedConventions.hookNaming;
|
|
341
|
+
conventionKey = 'hook file naming';
|
|
342
|
+
break;
|
|
343
|
+
case 'service':
|
|
344
|
+
expectedConvention = this.learnedConventions.serviceNaming;
|
|
345
|
+
conventionKey = 'service file naming';
|
|
346
|
+
break;
|
|
347
|
+
case 'test':
|
|
348
|
+
const expectedSuffix = this.learnedConventions.testSuffix;
|
|
349
|
+
if (expectedSuffix) {
|
|
350
|
+
const actualSuffix = /\.spec\.[jt]sx?$/.test(filename) ? '.spec' : '.test';
|
|
351
|
+
if (actualSuffix !== expectedSuffix) {
|
|
352
|
+
const baseName = filename.replace(/\.(test|spec)\.[jt]sx?$/, '');
|
|
353
|
+
const ext = filename.match(/\.[jt]sx?$/)?.[0] || '.ts';
|
|
354
|
+
violations.push(this.createLearningViolation(context.file, 'test file suffix', actualSuffix, expectedSuffix, `Test file uses '${actualSuffix}' but project uses '${expectedSuffix}'. Rename to '${baseName}${expectedSuffix}${ext}'`));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return this.createStrategyResult('learning', patterns, violations, violations.length === 0 ? 1.0 : 0.8);
|
|
358
|
+
}
|
|
359
|
+
if (expectedConvention && actualConvention !== expectedConvention && actualConvention !== 'unknown') {
|
|
360
|
+
const baseName = filename.replace(/\.[^.]+$/, '');
|
|
361
|
+
const ext = filename.match(/\.[^.]+$/)?.[0] || '';
|
|
362
|
+
const suggestedName = convertToConvention(baseName, expectedConvention) + ext;
|
|
363
|
+
violations.push(this.createLearningViolation(context.file, conventionKey, actualConvention, expectedConvention, `File '${filename}' uses ${actualConvention} but project uses ${expectedConvention}. Rename to '${suggestedName}'`));
|
|
364
|
+
}
|
|
365
|
+
return this.createStrategyResult('learning', patterns, violations, violations.length === 0 ? 1.0 : 0.8);
|
|
366
|
+
}
|
|
367
|
+
learnConventions(files) {
|
|
368
|
+
const distributions = {
|
|
369
|
+
componentNaming: new ValueDistribution(),
|
|
370
|
+
utilityNaming: new ValueDistribution(),
|
|
371
|
+
hookNaming: new ValueDistribution(),
|
|
372
|
+
serviceNaming: new ValueDistribution(),
|
|
373
|
+
testSuffix: new ValueDistribution(),
|
|
374
|
+
usesIndexFiles: new ValueDistribution(),
|
|
375
|
+
};
|
|
376
|
+
for (const file of files) {
|
|
377
|
+
const filename = file.split('/').pop() || '';
|
|
378
|
+
const fileType = getFileType(file);
|
|
379
|
+
if (fileType === 'index') {
|
|
380
|
+
distributions.usesIndexFiles.add(true, file);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (fileType === 'test') {
|
|
384
|
+
const suffix = /\.spec\.[jt]sx?$/.test(filename) ? '.spec' : '.test';
|
|
385
|
+
distributions.testSuffix.add(suffix, file);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
const convention = detectNamingConvention(filename.replace(/\.[^.]+$/, ''));
|
|
389
|
+
if (convention === 'unknown')
|
|
390
|
+
continue;
|
|
391
|
+
switch (fileType) {
|
|
392
|
+
case 'component':
|
|
393
|
+
distributions.componentNaming.add(convention, file);
|
|
394
|
+
break;
|
|
395
|
+
case 'utility':
|
|
396
|
+
distributions.utilityNaming.add(convention, file);
|
|
397
|
+
break;
|
|
398
|
+
case 'hook':
|
|
399
|
+
distributions.hookNaming.add(convention, file);
|
|
400
|
+
break;
|
|
401
|
+
case 'service':
|
|
402
|
+
distributions.serviceNaming.add(convention, file);
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
// Learning config for determining dominant conventions
|
|
407
|
+
const learningConfig = {
|
|
408
|
+
minOccurrences: 2,
|
|
409
|
+
dominanceThreshold: 0.3,
|
|
410
|
+
minFiles: 1,
|
|
411
|
+
};
|
|
412
|
+
return {
|
|
413
|
+
componentNaming: distributions.componentNaming.getDominant(learningConfig)?.value ?? null,
|
|
414
|
+
utilityNaming: distributions.utilityNaming.getDominant(learningConfig)?.value ?? null,
|
|
415
|
+
hookNaming: distributions.hookNaming.getDominant(learningConfig)?.value ?? null,
|
|
416
|
+
serviceNaming: distributions.serviceNaming.getDominant(learningConfig)?.value ?? null,
|
|
417
|
+
testSuffix: distributions.testSuffix.getDominant(learningConfig)?.value ?? null,
|
|
418
|
+
usesIndexFiles: distributions.usesIndexFiles.getTotal() > 0,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
createLearningViolation(file, conventionKey, actual, expected, message) {
|
|
422
|
+
const range = { start: { line: 1, character: 1 }, end: { line: 1, character: 1 } };
|
|
423
|
+
return {
|
|
424
|
+
id: `file-naming-learning-${file.replace(/[^a-zA-Z0-9]/g, '-')}`,
|
|
425
|
+
patternId: 'structural/file-naming',
|
|
426
|
+
severity: 'warning',
|
|
427
|
+
file,
|
|
428
|
+
range,
|
|
429
|
+
message,
|
|
430
|
+
expected: `${expected} for ${conventionKey}`,
|
|
431
|
+
actual: `${actual}`,
|
|
432
|
+
aiExplainAvailable: true,
|
|
433
|
+
aiFixAvailable: false,
|
|
434
|
+
firstSeen: new Date(),
|
|
435
|
+
occurrences: 1,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
// ============================================================================
|
|
439
|
+
// Semantic Detection (from file-naming-semantic.ts)
|
|
440
|
+
// ============================================================================
|
|
441
|
+
async detectSemantic(context) {
|
|
442
|
+
const patterns = [];
|
|
443
|
+
const violations = [];
|
|
444
|
+
// Semantic detection looks for naming-related keywords in code
|
|
445
|
+
// This is a simplified version - the full semantic detector does more
|
|
446
|
+
const content = context.content;
|
|
447
|
+
if (!content) {
|
|
448
|
+
return this.createSkippedResult('semantic', 'No content available');
|
|
449
|
+
}
|
|
450
|
+
// Check if file content mentions naming conventions
|
|
451
|
+
const hasNamingKeywords = SEMANTIC_KEYWORDS.some((kw) => content.toLowerCase().includes(kw));
|
|
452
|
+
if (hasNamingKeywords) {
|
|
453
|
+
// File discusses naming conventions - create a pattern match
|
|
454
|
+
patterns.push({
|
|
455
|
+
patternId: 'file-naming-semantic',
|
|
456
|
+
location: { file: context.file, line: 1, column: 1 },
|
|
457
|
+
confidence: 0.7,
|
|
458
|
+
isOutlier: false,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
return this.createStrategyResult('semantic', patterns, violations, 0.7);
|
|
462
|
+
}
|
|
463
|
+
// ============================================================================
|
|
464
|
+
// Quick Fix Generation
|
|
465
|
+
// ============================================================================
|
|
466
|
+
generateQuickFix(violation) {
|
|
467
|
+
const match = violation.message.match(/renamed to '([^']+)'/);
|
|
468
|
+
if (!match || !match[1])
|
|
469
|
+
return null;
|
|
470
|
+
const suggested = match[1];
|
|
471
|
+
const newPath = violation.file.replace(/[^/\\]+$/, suggested);
|
|
472
|
+
return {
|
|
473
|
+
title: `Rename to ${suggested}`,
|
|
474
|
+
kind: 'quickfix',
|
|
475
|
+
edit: {
|
|
476
|
+
changes: {},
|
|
477
|
+
documentChanges: [
|
|
478
|
+
{ uri: violation.file, edits: [] },
|
|
479
|
+
{ uri: newPath, edits: [] },
|
|
480
|
+
],
|
|
481
|
+
},
|
|
482
|
+
isPreferred: true,
|
|
483
|
+
confidence: 0.9,
|
|
484
|
+
preview: `Rename file from '${violation.file.split(/[/\\]/).pop()}' to '${suggested}'`,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// ============================================================================
|
|
489
|
+
// Factory Function
|
|
490
|
+
// ============================================================================
|
|
491
|
+
export function createFileNamingUnifiedDetector() {
|
|
492
|
+
return new FileNamingUnifiedDetector();
|
|
493
|
+
}
|
|
494
|
+
// Re-export for backward compatibility
|
|
495
|
+
export { FileNamingUnifiedDetector as FileNamingDetector };
|
|
496
|
+
//# sourceMappingURL=file-naming-unified.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-naming-unified.js","sourceRoot":"","sources":["../../src/structural/file-naming-unified.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EACL,eAAe,EAIf,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AA+C1B,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE;IACrF,EAAE,MAAM,EAAE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AAU;YAChB,IAAI,EAAE;gBACJ,OAAO,EAAE,EAAE;gBACX,eAAe,EAAE;oBACf,EAAE,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;oBAClC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;iBAC5B;aACF;YACD,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,qBAAqB,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,SAAS,SAAS,GAAG;SACvF,CAAC;IACJ,CAAC;CACF;AAED,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,MAAM,UAAU,+BAA+B;IAC7C,OAAO,IAAI,yBAAyB,EAAE,CAAC;AACzC,CAAC;AAED,uCAAuC;AACvC,OAAO,EAAE,yBAAyB,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @requirements 7.8 - THE Structural_Detector SHALL detect package boundary violations in monorepos
|
|
14
14
|
*/
|
|
15
15
|
export * from './file-naming.js';
|
|
16
|
+
export { FileNamingUnifiedDetector, createFileNamingUnifiedDetector, type NamingConvention as UnifiedNamingConvention, type SuffixPattern, type NamingPattern, type FileNamingAnalysis, type LearnedConventions, } from './file-naming-unified.js';
|
|
16
17
|
export { isLayerDirectory, isFeatureContainer, extractDirectories as extractDirectoryInfo, detectLayerBasedStructure, detectFeatureBasedStructure, analyzeDirectoryStructure, detectDirectoryPatterns, DirectoryStructureDetector, createDirectoryStructureDetector, LAYER_DIRECTORIES, FEATURE_DIRECTORIES, type DirectoryOrganization, type DirectoryInfo, type DirectoryStructureAnalysis, type DirectoryPattern, } from './directory-structure.js';
|
|
17
18
|
export { isTestFile, isInTestDirectory, getTestDirectory, isStyleFile, isInStyleDirectory, getStyleDirectory, extractTestBaseName, extractStyleBaseName, findSourceFileForTest, findComponentFileForStyle, analyzeTestCoLocation, analyzeStyleCoLocation, analyzeCoLocation, CoLocationDetector, createCoLocationDetector, TEST_FILE_PATTERNS, TEST_DIRECTORIES, STYLE_FILE_PATTERNS, STYLE_DIRECTORIES, getFileDirectory as getCoLocationFileDirectory, type CoLocationPattern, type TestFileInfo, type StyleFileInfo, type TestCoLocationAnalysis, type StyleCoLocationAnalysis, type CoLocationAnalysis, } from './co-location.js';
|
|
18
19
|
export { isBarrelFile, getFileDirectory as getBarrelFileDirectory, getFileName, shouldDirectoryHaveBarrel, parseExportPatterns, analyzeBarrelFile, extractDirectories as extractBarrelDirectories, analyzeBarrelPatterns, checkDirectoryNeedsBarrel, BarrelExportsDetector, createBarrelExportsDetector, BARREL_FILE_NAMES, BARREL_EXPECTED_DIRECTORIES, type BarrelPattern, type ExportType, type BarrelFileInfo, type DirectoryBarrelInfo, type BarrelAnalysis, type ExportPattern, } from './barrel-exports.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structural/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structural/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;AAMjC,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAE/B,KAAK,gBAAgB,IAAI,uBAAuB,EAChD,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,IAAI,oBAAoB,EAC1C,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,qBAAqB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ist/structural/index.js
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
* @requirements 7.8 - THE Structural_Detector SHALL detect package boundary violations in monorepos
|
|
14
14
|
*/
|
|
15
15
|
export * from './file-naming.js';
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Unified Detectors (Phase 4 - Consolidated)
|
|
18
|
+
// ============================================================================
|
|
19
|
+
export { FileNamingUnifiedDetector, createFileNamingUnifiedDetector, } from './file-naming-unified.js';
|
|
16
20
|
// Re-export directory-structure with explicit names to avoid conflicts
|
|
17
21
|
export { isLayerDirectory, isFeatureContainer, extractDirectories as extractDirectoryInfo, detectLayerBasedStructure, detectFeatureBasedStructure, analyzeDirectoryStructure, detectDirectoryPatterns, DirectoryStructureDetector, createDirectoryStructureDetector, LAYER_DIRECTORIES, FEATURE_DIRECTORIES, } from './directory-structure.js';
|
|
18
22
|
// Re-export co-location with explicit names to avoid conflicts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structural/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;AAEjC,uEAAuE;AACvE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,IAAI,oBAAoB,EAC1C,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,GAKpB,MAAM,0BAA0B,CAAC;AAElC,+DAA+D;AAC/D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,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1B,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GACzC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,gCAAgC,EAChC,sCAAsC,GACvC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,iCAAiC,EACjC,uCAAuC,GACxC,MAAM,kCAAkC,CAAC;AAE1C,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structural/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,cAAc,kBAAkB,CAAC;AAEjC,+EAA+E;AAC/E,6CAA6C;AAC7C,+EAA+E;AAE/E,OAAO,EACL,yBAAyB,EACzB,+BAA+B,GAOhC,MAAM,0BAA0B,CAAC;AAElC,uEAAuE;AACvE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,IAAI,oBAAoB,EAC1C,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,0BAA0B,EAC1B,gCAAgC,EAChC,iBAAiB,EACjB,mBAAmB,GAKpB,MAAM,0BAA0B,CAAC;AAElC,+DAA+D;AAC/D,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,q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C,uCAAuC,GAGxC,MAAM,kCAAkC,CAAC;AAE1C,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GACzC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,8BAA8B,EAC9B,oCAAoC,GACrC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,gCAAgC,EAChC,sCAAsC,GACvC,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,iCAAiC,EACjC,uCAAuC,GACxC,MAAM,kCAAkC,CAAC;AAE1C,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E,cAAc,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driftdetect-detectors",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Pattern detectors for Drift - 150+ detectors across 15 categories",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,16 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"driftdetect-core": "^0.5.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^20.10.0",
|
|
37
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
38
|
+
"fast-check": "^3.15.0",
|
|
39
|
+
"typescript": "^5.3.0",
|
|
40
|
+
"vitest": "^1.0.0"
|
|
41
|
+
},
|
|
32
42
|
"scripts": {
|
|
33
43
|
"build": "tsc",
|
|
34
44
|
"clean": "rm -rf dist",
|
|
@@ -39,15 +49,5 @@
|
|
|
39
49
|
"test:watch": "vitest",
|
|
40
50
|
"test:coverage": "vitest run --coverage",
|
|
41
51
|
"typecheck": "tsc --noEmit"
|
|
42
|
-
},
|
|
43
|
-
"dependencies": {
|
|
44
|
-
"driftdetect-core": "^0.4.5"
|
|
45
|
-
},
|
|
46
|
-
"devDependencies": {
|
|
47
|
-
"@types/node": "^20.10.0",
|
|
48
|
-
"@vitest/coverage-v8": "^1.0.0",
|
|
49
|
-
"fast-check": "^3.15.0",
|
|
50
|
-
"typescript": "^5.3.0",
|
|
51
|
-
"vitest": "^1.0.0"
|
|
52
52
|
}
|
|
53
|
-
}
|
|
53
|
+
}
|