driftdetect-core 0.1.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/dist/analyzers/ast-analyzer.d.ts +251 -0
- package/dist/analyzers/ast-analyzer.d.ts.map +1 -0
- package/dist/analyzers/ast-analyzer.js +548 -0
- package/dist/analyzers/ast-analyzer.js.map +1 -0
- package/dist/analyzers/flow-analyzer.d.ts +241 -0
- package/dist/analyzers/flow-analyzer.d.ts.map +1 -0
- package/dist/analyzers/flow-analyzer.js +1219 -0
- package/dist/analyzers/flow-analyzer.js.map +1 -0
- package/dist/analyzers/index.d.ts +18 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +19 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/semantic-analyzer.d.ts +252 -0
- package/dist/analyzers/semantic-analyzer.d.ts.map +1 -0
- package/dist/analyzers/semantic-analyzer.js +1182 -0
- package/dist/analyzers/semantic-analyzer.js.map +1 -0
- package/dist/analyzers/type-analyzer.d.ts +289 -0
- package/dist/analyzers/type-analyzer.d.ts.map +1 -0
- package/dist/analyzers/type-analyzer.js +1269 -0
- package/dist/analyzers/type-analyzer.js.map +1 -0
- package/dist/analyzers/types.d.ts +537 -0
- package/dist/analyzers/types.d.ts.map +1 -0
- package/dist/analyzers/types.js +11 -0
- package/dist/analyzers/types.js.map +1 -0
- package/dist/config/config-loader.d.ts +166 -0
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/config/config-loader.js +429 -0
- package/dist/config/config-loader.js.map +1 -0
- package/dist/config/config-validator.d.ts +204 -0
- package/dist/config/config-validator.d.ts.map +1 -0
- package/dist/config/config-validator.js +632 -0
- package/dist/config/config-validator.js.map +1 -0
- package/dist/config/defaults.d.ts +8 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +26 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +10 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/types.d.ts +47 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +7 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest/exporter.d.ts +21 -0
- package/dist/manifest/exporter.d.ts.map +1 -0
- package/dist/manifest/exporter.js +339 -0
- package/dist/manifest/exporter.js.map +1 -0
- package/dist/manifest/index.d.ts +14 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +15 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/manifest-store.d.ts +111 -0
- package/dist/manifest/manifest-store.d.ts.map +1 -0
- package/dist/manifest/manifest-store.js +418 -0
- package/dist/manifest/manifest-store.js.map +1 -0
- package/dist/manifest/types.d.ts +238 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +11 -0
- package/dist/manifest/types.js.map +1 -0
- package/dist/matcher/confidence-scorer.d.ts +188 -0
- package/dist/matcher/confidence-scorer.d.ts.map +1 -0
- package/dist/matcher/confidence-scorer.js +302 -0
- package/dist/matcher/confidence-scorer.js.map +1 -0
- package/dist/matcher/index.d.ts +24 -0
- package/dist/matcher/index.d.ts.map +1 -0
- package/dist/matcher/index.js +26 -0
- package/dist/matcher/index.js.map +1 -0
- package/dist/matcher/outlier-detector.d.ts +252 -0
- package/dist/matcher/outlier-detector.d.ts.map +1 -0
- package/dist/matcher/outlier-detector.js +544 -0
- package/dist/matcher/outlier-detector.js.map +1 -0
- package/dist/matcher/pattern-matcher.d.ts +169 -0
- package/dist/matcher/pattern-matcher.d.ts.map +1 -0
- package/dist/matcher/pattern-matcher.js +692 -0
- package/dist/matcher/pattern-matcher.js.map +1 -0
- package/dist/matcher/types.d.ts +476 -0
- package/dist/matcher/types.d.ts.map +1 -0
- package/dist/matcher/types.js +36 -0
- package/dist/matcher/types.js.map +1 -0
- package/dist/parsers/base-parser.d.ts +282 -0
- package/dist/parsers/base-parser.d.ts.map +1 -0
- package/dist/parsers/base-parser.js +421 -0
- package/dist/parsers/base-parser.js.map +1 -0
- package/dist/parsers/css-parser.d.ts +225 -0
- package/dist/parsers/css-parser.d.ts.map +1 -0
- package/dist/parsers/css-parser.js +477 -0
- package/dist/parsers/css-parser.js.map +1 -0
- package/dist/parsers/index.d.ts +15 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +15 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/json-parser.d.ts +219 -0
- package/dist/parsers/json-parser.d.ts.map +1 -0
- package/dist/parsers/json-parser.js +602 -0
- package/dist/parsers/json-parser.js.map +1 -0
- package/dist/parsers/markdown-parser.d.ts +276 -0
- package/dist/parsers/markdown-parser.d.ts.map +1 -0
- package/dist/parsers/markdown-parser.js +731 -0
- package/dist/parsers/markdown-parser.js.map +1 -0
- package/dist/parsers/parser-manager.d.ts +294 -0
- package/dist/parsers/parser-manager.d.ts.map +1 -0
- package/dist/parsers/parser-manager.js +738 -0
- package/dist/parsers/parser-manager.js.map +1 -0
- package/dist/parsers/python-parser.d.ts +204 -0
- package/dist/parsers/python-parser.d.ts.map +1 -0
- package/dist/parsers/python-parser.js +517 -0
- package/dist/parsers/python-parser.js.map +1 -0
- package/dist/parsers/types.d.ts +43 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/types.js +7 -0
- package/dist/parsers/types.js.map +1 -0
- package/dist/parsers/typescript-parser.d.ts +264 -0
- package/dist/parsers/typescript-parser.d.ts.map +1 -0
- package/dist/parsers/typescript-parser.js +658 -0
- package/dist/parsers/typescript-parser.js.map +1 -0
- package/dist/rules/evaluator.d.ts +305 -0
- package/dist/rules/evaluator.d.ts.map +1 -0
- package/dist/rules/evaluator.js +579 -0
- package/dist/rules/evaluator.js.map +1 -0
- package/dist/rules/index.d.ts +13 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +13 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/quick-fix-generator.d.ts +334 -0
- package/dist/rules/quick-fix-generator.d.ts.map +1 -0
- package/dist/rules/quick-fix-generator.js +1075 -0
- package/dist/rules/quick-fix-generator.js.map +1 -0
- package/dist/rules/rule-engine.d.ts +241 -0
- package/dist/rules/rule-engine.d.ts.map +1 -0
- package/dist/rules/rule-engine.js +585 -0
- package/dist/rules/rule-engine.js.map +1 -0
- package/dist/rules/severity-manager.d.ts +394 -0
- package/dist/rules/severity-manager.d.ts.map +1 -0
- package/dist/rules/severity-manager.js +619 -0
- package/dist/rules/severity-manager.js.map +1 -0
- package/dist/rules/types.d.ts +370 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +133 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/variant-manager.d.ts +388 -0
- package/dist/rules/variant-manager.d.ts.map +1 -0
- package/dist/rules/variant-manager.js +777 -0
- package/dist/rules/variant-manager.js.map +1 -0
- package/dist/scanner/change-detector.d.ts +164 -0
- package/dist/scanner/change-detector.d.ts.map +1 -0
- package/dist/scanner/change-detector.js +263 -0
- package/dist/scanner/change-detector.js.map +1 -0
- package/dist/scanner/dependency-graph.d.ts +270 -0
- package/dist/scanner/dependency-graph.d.ts.map +1 -0
- package/dist/scanner/dependency-graph.js +436 -0
- package/dist/scanner/dependency-graph.js.map +1 -0
- package/dist/scanner/file-walker.d.ts +127 -0
- package/dist/scanner/file-walker.d.ts.map +1 -0
- package/dist/scanner/file-walker.js +526 -0
- package/dist/scanner/file-walker.js.map +1 -0
- package/dist/scanner/index.d.ts +12 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/index.js +12 -0
- package/dist/scanner/index.js.map +1 -0
- package/dist/scanner/types.d.ts +218 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +10 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/scanner/worker-pool.d.ts +317 -0
- package/dist/scanner/worker-pool.d.ts.map +1 -0
- package/dist/scanner/worker-pool.js +571 -0
- package/dist/scanner/worker-pool.js.map +1 -0
- package/dist/store/cache-manager.d.ts +179 -0
- package/dist/store/cache-manager.d.ts.map +1 -0
- package/dist/store/cache-manager.js +391 -0
- package/dist/store/cache-manager.js.map +1 -0
- package/dist/store/history-store.d.ts +314 -0
- package/dist/store/history-store.d.ts.map +1 -0
- package/dist/store/history-store.js +707 -0
- package/dist/store/history-store.js.map +1 -0
- package/dist/store/index.d.ts +20 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +26 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/lock-file-manager.d.ts +202 -0
- package/dist/store/lock-file-manager.d.ts.map +1 -0
- package/dist/store/lock-file-manager.js +475 -0
- package/dist/store/lock-file-manager.js.map +1 -0
- package/dist/store/pattern-store.d.ts +289 -0
- package/dist/store/pattern-store.d.ts.map +1 -0
- package/dist/store/pattern-store.js +936 -0
- package/dist/store/pattern-store.js.map +1 -0
- package/dist/store/schema-validator.d.ts +159 -0
- package/dist/store/schema-validator.d.ts.map +1 -0
- package/dist/store/schema-validator.js +1096 -0
- package/dist/store/schema-validator.js.map +1 -0
- package/dist/store/types.d.ts +585 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +82 -0
- package/dist/store/types.js.map +1 -0
- package/dist/types/analysis.d.ts +19 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +5 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/common.d.ts +7 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +5 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/patterns.d.ts +40 -0
- package/dist/types/patterns.d.ts.map +1 -0
- package/dist/types/patterns.js +7 -0
- package/dist/types/patterns.js.map +1 -0
- package/dist/types/violations.d.ts +7 -0
- package/dist/types/violations.d.ts.map +1 -0
- package/dist/types/violations.js +7 -0
- package/dist/types/violations.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest type definitions for pattern location discovery
|
|
3
|
+
*
|
|
4
|
+
* The manifest provides a complete architectural map of a codebase,
|
|
5
|
+
* storing semantic locations for all detected patterns. This enables
|
|
6
|
+
* AI agents to understand codebase architecture from a single file.
|
|
7
|
+
*
|
|
8
|
+
* @requirements PATTERN-LOCATION-DISCOVERY.md
|
|
9
|
+
*/
|
|
10
|
+
import type { PatternCategory } from '../store/types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Type of code element at a location
|
|
13
|
+
*/
|
|
14
|
+
export type SemanticType = 'class' | 'function' | 'method' | 'variable' | 'constant' | 'interface' | 'type' | 'enum' | 'module' | 'decorator' | 'block' | 'file';
|
|
15
|
+
/**
|
|
16
|
+
* Semantic location with rich metadata about code elements
|
|
17
|
+
*
|
|
18
|
+
* Unlike basic Location (file:line), SemanticLocation includes:
|
|
19
|
+
* - What type of code element (class, function, method, etc.)
|
|
20
|
+
* - The name and signature of the element
|
|
21
|
+
* - Nested members (methods in a class, etc.)
|
|
22
|
+
* - Content hash for change detection
|
|
23
|
+
*/
|
|
24
|
+
export interface SemanticLocation {
|
|
25
|
+
/** Relative file path from project root */
|
|
26
|
+
file: string;
|
|
27
|
+
/** Content hash for change detection (first 12 chars of SHA-256) */
|
|
28
|
+
hash: string;
|
|
29
|
+
/** Line range in the file */
|
|
30
|
+
range: {
|
|
31
|
+
/** Start line (1-indexed) */
|
|
32
|
+
start: number;
|
|
33
|
+
/** End line (1-indexed) */
|
|
34
|
+
end: number;
|
|
35
|
+
};
|
|
36
|
+
/** Type of code element */
|
|
37
|
+
type: SemanticType;
|
|
38
|
+
/** Name of the element (e.g., "AuthMiddleware", "authenticate") */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Full signature (e.g., "class AuthMiddleware:", "async def authenticate(token: str)") */
|
|
41
|
+
signature?: string;
|
|
42
|
+
/** Confidence score for this location (0.0 to 1.0) */
|
|
43
|
+
confidence: number;
|
|
44
|
+
/** Nested members (e.g., methods in a class) */
|
|
45
|
+
members?: SemanticLocation[];
|
|
46
|
+
/** Code snippet (first few lines) */
|
|
47
|
+
snippet?: string;
|
|
48
|
+
/** Language of the file */
|
|
49
|
+
language?: string;
|
|
50
|
+
/** Additional metadata */
|
|
51
|
+
metadata?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Pattern entry in the manifest
|
|
55
|
+
*/
|
|
56
|
+
export interface ManifestPattern {
|
|
57
|
+
/** Pattern ID */
|
|
58
|
+
id: string;
|
|
59
|
+
/** Human-readable name */
|
|
60
|
+
name: string;
|
|
61
|
+
/** Pattern category */
|
|
62
|
+
category: PatternCategory;
|
|
63
|
+
/** Pattern subcategory */
|
|
64
|
+
subcategory: string;
|
|
65
|
+
/** Pattern status */
|
|
66
|
+
status: 'discovered' | 'approved' | 'ignored';
|
|
67
|
+
/** Overall confidence score (0.0 to 1.0) */
|
|
68
|
+
confidence: number;
|
|
69
|
+
/** Semantic locations where pattern is found */
|
|
70
|
+
locations: SemanticLocation[];
|
|
71
|
+
/** Outlier locations (violations) */
|
|
72
|
+
outliers: SemanticLocation[];
|
|
73
|
+
/** Pattern description */
|
|
74
|
+
description?: string;
|
|
75
|
+
/** When first detected */
|
|
76
|
+
firstSeen: string;
|
|
77
|
+
/** When last seen */
|
|
78
|
+
lastSeen: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* File entry in the manifest (reverse index)
|
|
82
|
+
*/
|
|
83
|
+
export interface ManifestFile {
|
|
84
|
+
/** Content hash for change detection */
|
|
85
|
+
hash: string;
|
|
86
|
+
/** Pattern IDs found in this file */
|
|
87
|
+
patterns: string[];
|
|
88
|
+
/** When this file was last scanned */
|
|
89
|
+
lastScanned: string;
|
|
90
|
+
/** File language */
|
|
91
|
+
language?: string;
|
|
92
|
+
/** Line count */
|
|
93
|
+
lineCount?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Complete manifest structure
|
|
97
|
+
*
|
|
98
|
+
* The manifest contains:
|
|
99
|
+
* 1. Forward index: pattern → locations
|
|
100
|
+
* 2. Reverse index: file → patterns
|
|
101
|
+
*
|
|
102
|
+
* This enables efficient queries in both directions.
|
|
103
|
+
*/
|
|
104
|
+
export interface Manifest {
|
|
105
|
+
/** Manifest format version */
|
|
106
|
+
version: string;
|
|
107
|
+
/** When the manifest was generated */
|
|
108
|
+
generated: string;
|
|
109
|
+
/** Hash of all tracked files (for quick change detection) */
|
|
110
|
+
codebaseHash: string;
|
|
111
|
+
/** Project root path */
|
|
112
|
+
projectRoot: string;
|
|
113
|
+
/** Summary statistics */
|
|
114
|
+
summary: ManifestSummary;
|
|
115
|
+
/** Forward index: pattern ID → pattern data with locations */
|
|
116
|
+
patterns: Record<string, ManifestPattern>;
|
|
117
|
+
/** Reverse index: file path → file data with pattern IDs */
|
|
118
|
+
files: Record<string, ManifestFile>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Summary statistics for the manifest
|
|
122
|
+
*/
|
|
123
|
+
export interface ManifestSummary {
|
|
124
|
+
/** Total number of patterns */
|
|
125
|
+
totalPatterns: number;
|
|
126
|
+
/** Patterns by status */
|
|
127
|
+
patternsByStatus: {
|
|
128
|
+
discovered: number;
|
|
129
|
+
approved: number;
|
|
130
|
+
ignored: number;
|
|
131
|
+
};
|
|
132
|
+
/** Patterns by category */
|
|
133
|
+
patternsByCategory: Record<string, number>;
|
|
134
|
+
/** Total number of files tracked */
|
|
135
|
+
totalFiles: number;
|
|
136
|
+
/** Total number of locations */
|
|
137
|
+
totalLocations: number;
|
|
138
|
+
/** Total number of outliers */
|
|
139
|
+
totalOutliers: number;
|
|
140
|
+
/** Scan duration in milliseconds */
|
|
141
|
+
scanDuration?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Export format options
|
|
145
|
+
*/
|
|
146
|
+
export type ExportFormat = 'json' | 'ai-context' | 'summary' | 'markdown';
|
|
147
|
+
/**
|
|
148
|
+
* Options for exporting the manifest
|
|
149
|
+
*/
|
|
150
|
+
export interface ExportOptions {
|
|
151
|
+
/** Output format */
|
|
152
|
+
format: ExportFormat;
|
|
153
|
+
/** Output file path (stdout if not specified) */
|
|
154
|
+
output?: string;
|
|
155
|
+
/** Categories to include (all if not specified) */
|
|
156
|
+
categories?: PatternCategory[];
|
|
157
|
+
/** Pattern statuses to include */
|
|
158
|
+
statuses?: Array<'discovered' | 'approved' | 'ignored'>;
|
|
159
|
+
/** Minimum confidence threshold */
|
|
160
|
+
minConfidence?: number;
|
|
161
|
+
/** Whether to include code snippets */
|
|
162
|
+
includeSnippets?: boolean;
|
|
163
|
+
/** Maximum tokens for AI context format */
|
|
164
|
+
maxTokens?: number;
|
|
165
|
+
/** Whether to use compact output */
|
|
166
|
+
compact?: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Token estimation result
|
|
170
|
+
*/
|
|
171
|
+
export interface TokenEstimate {
|
|
172
|
+
/** Estimated token count */
|
|
173
|
+
tokens: number;
|
|
174
|
+
/** Size category */
|
|
175
|
+
category: 'small' | 'medium' | 'large' | 'xlarge';
|
|
176
|
+
/** Warning message if too large */
|
|
177
|
+
warning?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Query options for finding patterns
|
|
181
|
+
*/
|
|
182
|
+
export interface PatternQuery {
|
|
183
|
+
/** Pattern ID or name (supports partial matching) */
|
|
184
|
+
pattern?: string;
|
|
185
|
+
/** Category filter */
|
|
186
|
+
category?: PatternCategory;
|
|
187
|
+
/** Status filter */
|
|
188
|
+
status?: 'discovered' | 'approved' | 'ignored';
|
|
189
|
+
/** Minimum confidence */
|
|
190
|
+
minConfidence?: number;
|
|
191
|
+
/** File path filter (glob pattern) */
|
|
192
|
+
filePath?: string;
|
|
193
|
+
/** Limit number of results */
|
|
194
|
+
limit?: number;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Query result for pattern locations
|
|
198
|
+
*/
|
|
199
|
+
export interface PatternQueryResult {
|
|
200
|
+
/** Pattern ID */
|
|
201
|
+
patternId: string;
|
|
202
|
+
/** Pattern name */
|
|
203
|
+
patternName: string;
|
|
204
|
+
/** Pattern category */
|
|
205
|
+
category: PatternCategory;
|
|
206
|
+
/** Matching locations */
|
|
207
|
+
locations: SemanticLocation[];
|
|
208
|
+
/** Total location count (may be more than returned if limited) */
|
|
209
|
+
totalCount: number;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Query options for finding patterns in files
|
|
213
|
+
*/
|
|
214
|
+
export interface FileQuery {
|
|
215
|
+
/** File path (supports glob patterns) */
|
|
216
|
+
path: string;
|
|
217
|
+
/** Whether to include nested patterns */
|
|
218
|
+
includeNested?: boolean;
|
|
219
|
+
/** Category filter */
|
|
220
|
+
category?: PatternCategory;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Query result for file patterns
|
|
224
|
+
*/
|
|
225
|
+
export interface FileQueryResult {
|
|
226
|
+
/** File path */
|
|
227
|
+
file: string;
|
|
228
|
+
/** Patterns found in the file */
|
|
229
|
+
patterns: Array<{
|
|
230
|
+
id: string;
|
|
231
|
+
name: string;
|
|
232
|
+
category: PatternCategory;
|
|
233
|
+
locations: SemanticLocation[];
|
|
234
|
+
}>;
|
|
235
|
+
/** File metadata */
|
|
236
|
+
metadata: ManifestFile;
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/manifest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAA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ACpB,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS,CAAC;IAE/C,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAElB,mBAAmB;IACnB,WAAW,EAAE,MAAM,CAAC;IAEpB,uBAAuB;IACvB,QAAQ,EAAE,eAAe,CAAC;IAE1B,yBAAyB;IACzB,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAE9B,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IAEb,yCAAyC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IAEb,iCAAiC;IACjC,QAAQ,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,eAAe,CAAC;QAC1B,SAAS,EAAE,gBAAgB,EAAE,CAAC;KAC/B,CAAC,CAAC;IAEH,oBAAoB;IACpB,QAAQ,EAAE,YAAY,CAAC;CACxB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest type definitions for pattern location discovery
|
|
3
|
+
*
|
|
4
|
+
* The manifest provides a complete architectural map of a codebase,
|
|
5
|
+
* storing semantic locations for all detected patterns. This enables
|
|
6
|
+
* AI agents to understand codebase architecture from a single file.
|
|
7
|
+
*
|
|
8
|
+
* @requirements PATTERN-LOCATION-DISCOVERY.md
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/manifest/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confidence Scorer - Pattern confidence calculation
|
|
3
|
+
*
|
|
4
|
+
* Calculates confidence scores based on frequency, consistency,
|
|
5
|
+
* age, and spread. Classifies patterns into confidence levels.
|
|
6
|
+
*
|
|
7
|
+
* The confidence score is a weighted combination of four factors:
|
|
8
|
+
* - Frequency: How often the pattern appears relative to applicable locations
|
|
9
|
+
* - Consistency: How consistent the pattern implementation is across occurrences
|
|
10
|
+
* - Age: How long the pattern has been observed (normalized)
|
|
11
|
+
* - Spread: How many files contain the pattern relative to total files
|
|
12
|
+
*
|
|
13
|
+
* @requirements 5.1 - Pattern confidence scoring with frequency, consistency, age, spread factors
|
|
14
|
+
* @requirements 5.2 - Confidence score SHALL be a decimal value between 0.0 and 1.0
|
|
15
|
+
* @requirements 5.3 - High confidence: score >= 0.85
|
|
16
|
+
* @requirements 5.4 - Medium confidence: score >= 0.70 and < 0.85
|
|
17
|
+
* @requirements 5.5 - Low confidence: score >= 0.50 and < 0.70
|
|
18
|
+
* @requirements 5.6 - Uncertain: score < 0.50
|
|
19
|
+
*/
|
|
20
|
+
import type { ConfidenceScore, ConfidenceLevel, ConfidenceWeights, ConfidenceInput } from './types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for age normalization
|
|
23
|
+
*/
|
|
24
|
+
export interface AgeNormalizationConfig {
|
|
25
|
+
/**
|
|
26
|
+
* Number of days at which age factor reaches maximum (1.0)
|
|
27
|
+
* Default: 30 days
|
|
28
|
+
*/
|
|
29
|
+
maxAgeDays: number;
|
|
30
|
+
/**
|
|
31
|
+
* Minimum age factor for newly observed patterns
|
|
32
|
+
* Default: 0.1
|
|
33
|
+
*/
|
|
34
|
+
minAgeFactor: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Default age normalization configuration
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_AGE_CONFIG: AgeNormalizationConfig;
|
|
40
|
+
/**
|
|
41
|
+
* ConfidenceScorer class for calculating pattern confidence scores.
|
|
42
|
+
*
|
|
43
|
+
* Calculates a weighted confidence score from four factors:
|
|
44
|
+
* - Frequency: occurrences / totalLocations
|
|
45
|
+
* - Consistency: 1 - variance (inverted so higher is better)
|
|
46
|
+
* - Age: normalized based on days since first seen
|
|
47
|
+
* - Spread: fileCount / totalFiles
|
|
48
|
+
*
|
|
49
|
+
* The final score is classified into confidence levels:
|
|
50
|
+
* - High: score >= 0.85
|
|
51
|
+
* - Medium: score >= 0.70 and < 0.85
|
|
52
|
+
* - Low: score >= 0.50 and < 0.70
|
|
53
|
+
* - Uncertain: score < 0.50
|
|
54
|
+
*
|
|
55
|
+
* @requirements 5.1, 5.2, 5.3, 5.4, 5.5, 5.6
|
|
56
|
+
*/
|
|
57
|
+
export declare class ConfidenceScorer {
|
|
58
|
+
private weights;
|
|
59
|
+
private ageConfig;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new ConfidenceScorer instance.
|
|
62
|
+
*
|
|
63
|
+
* @param weights - Optional custom weights for score calculation
|
|
64
|
+
* @param ageConfig - Optional custom age normalization configuration
|
|
65
|
+
*/
|
|
66
|
+
constructor(weights?: Partial<ConfidenceWeights>, ageConfig?: Partial<AgeNormalizationConfig>);
|
|
67
|
+
/**
|
|
68
|
+
* Calculate the confidence score for a pattern.
|
|
69
|
+
*
|
|
70
|
+
* @param input - The input data for confidence calculation
|
|
71
|
+
* @returns The calculated confidence score with all factors
|
|
72
|
+
*
|
|
73
|
+
* @requirements 5.1 - Pattern confidence scoring with frequency, consistency, age, spread factors
|
|
74
|
+
* @requirements 5.2 - Confidence score SHALL be a decimal value between 0.0 and 1.0
|
|
75
|
+
*/
|
|
76
|
+
calculateScore(input: ConfidenceInput): ConfidenceScore;
|
|
77
|
+
/**
|
|
78
|
+
* Calculate the frequency factor.
|
|
79
|
+
*
|
|
80
|
+
* Frequency = occurrences / totalLocations
|
|
81
|
+
* Represents how often the pattern appears relative to applicable locations.
|
|
82
|
+
*
|
|
83
|
+
* @param occurrences - Number of pattern occurrences
|
|
84
|
+
* @param totalLocations - Total applicable locations
|
|
85
|
+
* @returns Frequency factor (0.0 to 1.0)
|
|
86
|
+
*
|
|
87
|
+
* @requirements 5.1 - Frequency factor in confidence scoring
|
|
88
|
+
*/
|
|
89
|
+
calculateFrequency(occurrences: number, totalLocations: number): number;
|
|
90
|
+
/**
|
|
91
|
+
* Calculate the consistency factor.
|
|
92
|
+
*
|
|
93
|
+
* Consistency = 1 - variance
|
|
94
|
+
* Higher consistency means less variance in pattern implementation.
|
|
95
|
+
* Variance should be normalized to [0.0, 1.0] range.
|
|
96
|
+
*
|
|
97
|
+
* @param variance - Variance in pattern implementation (0 = perfectly consistent)
|
|
98
|
+
* @returns Consistency factor (0.0 to 1.0)
|
|
99
|
+
*
|
|
100
|
+
* @requirements 5.1 - Consistency factor in confidence scoring
|
|
101
|
+
*/
|
|
102
|
+
calculateConsistency(variance: number): number;
|
|
103
|
+
/**
|
|
104
|
+
* Calculate the age factor.
|
|
105
|
+
*
|
|
106
|
+
* Age factor is normalized based on days since first observation.
|
|
107
|
+
* Older patterns get higher scores (more established).
|
|
108
|
+
* Uses logarithmic scaling for diminishing returns after maxAgeDays.
|
|
109
|
+
*
|
|
110
|
+
* @param daysSinceFirstSeen - Days since pattern was first observed
|
|
111
|
+
* @returns Age factor (0.0 to 1.0)
|
|
112
|
+
*
|
|
113
|
+
* @requirements 5.1 - Age factor in confidence scoring
|
|
114
|
+
*/
|
|
115
|
+
calculateAgeFactor(daysSinceFirstSeen: number): number;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate the spread factor.
|
|
118
|
+
*
|
|
119
|
+
* Spread = fileCount / totalFiles
|
|
120
|
+
* Represents how widely the pattern is used across the codebase.
|
|
121
|
+
*
|
|
122
|
+
* @param fileCount - Number of files containing the pattern
|
|
123
|
+
* @param totalFiles - Total files in scope
|
|
124
|
+
* @returns Spread factor (0.0 to 1.0)
|
|
125
|
+
*
|
|
126
|
+
* @requirements 5.1 - Spread factor in confidence scoring
|
|
127
|
+
*/
|
|
128
|
+
calculateSpread(fileCount: number, totalFiles: number): number;
|
|
129
|
+
/**
|
|
130
|
+
* Classify a score into a confidence level.
|
|
131
|
+
*
|
|
132
|
+
* @param score - The confidence score (0.0 to 1.0)
|
|
133
|
+
* @returns The confidence level classification
|
|
134
|
+
*
|
|
135
|
+
* @requirements 5.3 - High confidence: score >= 0.85
|
|
136
|
+
* @requirements 5.4 - Medium confidence: score >= 0.70 and < 0.85
|
|
137
|
+
* @requirements 5.5 - Low confidence: score >= 0.50 and < 0.70
|
|
138
|
+
* @requirements 5.6 - Uncertain: score < 0.50
|
|
139
|
+
*/
|
|
140
|
+
classifyLevel(score: number): ConfidenceLevel;
|
|
141
|
+
/**
|
|
142
|
+
* Get the current weights configuration.
|
|
143
|
+
*
|
|
144
|
+
* @returns The current confidence weights
|
|
145
|
+
*/
|
|
146
|
+
getWeights(): ConfidenceWeights;
|
|
147
|
+
/**
|
|
148
|
+
* Get the current age normalization configuration.
|
|
149
|
+
*
|
|
150
|
+
* @returns The current age configuration
|
|
151
|
+
*/
|
|
152
|
+
getAgeConfig(): AgeNormalizationConfig;
|
|
153
|
+
/**
|
|
154
|
+
* Validate that weights sum to approximately 1.0.
|
|
155
|
+
* Throws an error if weights are invalid.
|
|
156
|
+
*/
|
|
157
|
+
private validateWeights;
|
|
158
|
+
/**
|
|
159
|
+
* Clamp a value to a range.
|
|
160
|
+
*
|
|
161
|
+
* @param value - The value to clamp
|
|
162
|
+
* @param min - Minimum value
|
|
163
|
+
* @param max - Maximum value
|
|
164
|
+
* @returns The clamped value
|
|
165
|
+
*/
|
|
166
|
+
private clamp;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Create a confidence score from raw values.
|
|
170
|
+
* Utility function for creating ConfidenceScore objects directly.
|
|
171
|
+
*
|
|
172
|
+
* @param frequency - Frequency factor (0.0 to 1.0)
|
|
173
|
+
* @param consistency - Consistency factor (0.0 to 1.0)
|
|
174
|
+
* @param age - Age in days
|
|
175
|
+
* @param spread - Number of files
|
|
176
|
+
* @param score - Overall score (0.0 to 1.0)
|
|
177
|
+
* @returns A ConfidenceScore object
|
|
178
|
+
*/
|
|
179
|
+
export declare function createConfidenceScore(frequency: number, consistency: number, age: number, spread: number, score: number): ConfidenceScore;
|
|
180
|
+
/**
|
|
181
|
+
* Calculate confidence score using default weights.
|
|
182
|
+
* Convenience function for quick calculations.
|
|
183
|
+
*
|
|
184
|
+
* @param input - The input data for confidence calculation
|
|
185
|
+
* @returns The calculated confidence score
|
|
186
|
+
*/
|
|
187
|
+
export declare function calculateConfidence(input: ConfidenceInput): ConfidenceScore;
|
|
188
|
+
//# sourceMappingURL=confidence-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confidence-scorer.d.ts","sourceRoot":"","sources":["../../src/matcher/confidence-scorer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAOpB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,sBAGhC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CA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