@aiready/context-analyzer 0.21.8 → 0.21.10

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.
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @aiready/context-analyzer@0.21.8 build /Users/pengcao/projects/aiready/packages/context-analyzer
3
+ > @aiready/context-analyzer@0.21.10 build /Users/pengcao/projects/aiready/packages/context-analyzer
4
4
  > tsup src/index.ts src/cli.ts --format cjs,esm --dts
5
5
 
6
6
  CLI Building entry: src/cli.ts, src/index.ts
@@ -9,18 +9,18 @@
9
9
  CLI Target: es2020
10
10
  CJS Build start
11
11
  ESM Build start
12
- CJS dist/cli.js 65.97 KB
13
- CJS dist/index.js 77.31 KB
14
- CJS ⚡️ Build success in 58ms
15
- ESM dist/cli.mjs 4.20 KB
16
- ESM dist/index.mjs 9.27 KB
17
- ESM dist/python-context-3GZKN3LR.mjs 4.47 KB
12
+ CJS dist/cli.js 66.15 KB
13
+ CJS dist/index.js 78.58 KB
14
+ CJS ⚡️ Build success in 219ms
15
+ ESM dist/cli.mjs 4.38 KB
18
16
  ESM dist/chunk-D25B5LZR.mjs 57.60 KB
17
+ ESM dist/index.mjs 10.53 KB
19
18
  ESM dist/chunk-64U3PNO3.mjs 2.65 KB
20
- ESM ⚡️ Build success in 58ms
19
+ ESM dist/python-context-3GZKN3LR.mjs 4.47 KB
20
+ ESM ⚡️ Build success in 220ms
21
21
  DTS Build start
22
- DTS ⚡️ Build success in 4899ms
22
+ DTS ⚡️ Build success in 5273ms
23
23
  DTS dist/cli.d.ts 20.00 B
24
- DTS dist/index.d.ts 15.68 KB
24
+ DTS dist/index.d.ts 20.88 KB
25
25
  DTS dist/cli.d.mts 20.00 B
26
- DTS dist/index.d.mts 15.68 KB
26
+ DTS dist/index.d.mts 20.88 KB
@@ -1,41 +1,41 @@
1
1
 
2
2
  
3
- > @aiready/context-analyzer@0.21.7 test /Users/pengcao/projects/aiready/packages/context-analyzer
3
+ > @aiready/context-analyzer@0.21.9 test /Users/pengcao/projects/aiready/packages/context-analyzer
4
4
  > vitest run
5
5
 
6
6
  [?25l
7
7
   RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/context-analyzer
8
8
 
9
+ ✓ dist/__tests__/scoring.test.js (15 tests) 215ms
10
+ ✓ dist/__tests__/fragmentation-coupling.test.js (2 tests) 72ms
11
+ ✓ dist/__tests__/analyzer.test.js (14 tests) 85ms
12
+ ✓ dist/__tests__/auto-detection.test.js (8 tests) 183ms
13
+ ✓ dist/__tests__/contract.test.js (1 test) 167ms
14
+ ✓ src/__tests__/file-classification.test.ts (63 tests) 19ms
15
+ ✓ src/__tests__/auto-detection.test.ts (8 tests) 29ms
16
+ ✓ src/__tests__/provider.test.ts (2 tests) 4ms
17
+ ✓ src/__tests__/contract.test.ts (1 test) 62ms
18
+ ✓ src/__tests__/fragmentation-coupling.test.ts (2 tests) 66ms
19
+ ✓ src/__tests__/analyzer.test.ts (14 tests) 20ms
9
20
  ✓ dist/__tests__/remediation.test.js (6 tests) 3ms
10
21
  ✓ src/__tests__/remediation.test.ts (6 tests) 2ms
11
- ✓ src/__tests__/scoring.test.ts (15 tests) 3ms
12
- ✓ dist/__tests__/contract.test.js (1 test) 12ms
13
- ✓ dist/__tests__/fragmentation-coupling.test.js (2 tests) 15ms
14
- ✓ dist/__tests__/analyzer.test.js (14 tests) 25ms
15
- ✓ dist/__tests__/auto-detection.test.js (8 tests) 23ms
16
- ✓ src/__tests__/cluster-detector.test.ts (3 tests) 6ms
17
- ✓ src/__tests__/file-classification.test.ts (63 tests) 7ms
18
- ✓ src/__tests__/fragmentation-coupling.test.ts (2 tests) 12ms
19
- ✓ src/__tests__/auto-detection.test.ts (8 tests) 17ms
20
- ✓ src/__tests__/contract.test.ts (1 test) 50ms
21
- ✓ src/__tests__/analyzer.test.ts (14 tests) 23ms
22
- ✓ dist/__tests__/provider.test.js (2 tests) 3ms
23
- ✓ dist/__tests__/file-classification.test.js (63 tests) 6ms
24
- ✓ dist/__tests__/cluster-detector.test.js (3 tests) 6ms
25
- ✓ src/__tests__/structural-cohesion.test.ts (4 tests) 2ms
26
- ✓ dist/__tests__/scoring.test.js (15 tests) 8ms
27
- ✓ src/__tests__/provider.test.ts (2 tests) 7ms
28
- ✓ dist/__tests__/structural-cohesion.test.js (4 tests) 2ms
29
- ✓ dist/__tests__/fragmentation-log.test.js (3 tests) 3ms
30
- ✓ dist/__tests__/fragmentation-advanced.test.js (3 tests) 2ms
22
+ ✓ dist/__tests__/file-classification.test.js (63 tests) 7ms
23
+ ✓ src/__tests__/scoring.test.ts (15 tests) 4ms
24
+ ✓ dist/__tests__/provider.test.js (2 tests) 7ms
25
+ ✓ dist/__tests__/fragmentation-log.test.js (3 tests) 2ms
26
+ ✓ src/__tests__/cluster-detector.test.ts (3 tests) 2ms
27
+ ✓ dist/__tests__/cluster-detector.test.js (3 tests) 20ms
31
28
  ✓ dist/__tests__/enhanced-cohesion.test.js (6 tests) 3ms
32
- ✓ src/__tests__/enhanced-cohesion.test.ts (6 tests) 2ms
33
- ✓ src/__tests__/fragmentation-advanced.test.ts (3 tests) 1ms
34
- ✓ src/__tests__/fragmentation-log.test.ts (3 tests) 1ms
29
+ ✓ src/__tests__/structural-cohesion.test.ts (4 tests) 2ms
30
+ ✓ src/__tests__/enhanced-cohesion.test.ts (6 tests) 5ms
31
+ ✓ dist/__tests__/fragmentation-advanced.test.js (3 tests) 5ms
32
+ ✓ dist/__tests__/structural-cohesion.test.js (4 tests) 3ms
33
+ ✓ src/__tests__/fragmentation-advanced.test.ts (3 tests) 2ms
34
+ ✓ src/__tests__/fragmentation-log.test.ts (3 tests) 2ms
35
35
 
36
36
   Test Files  26 passed (26)
37
37
   Tests  260 passed (260)
38
-  Start at  10:36:29
39
-  Duration  1.74s (transform 2.12s, setup 0ms, import 11.15s, tests 244ms, environment 2ms)
38
+  Start at  10:12:34
39
+  Duration  8.91s (transform 10.79s, setup 0ms, import 61.94s, tests 991ms, environment 14ms)
40
40
 
41
41
  [?25h
package/dist/cli.js CHANGED
@@ -1927,29 +1927,43 @@ async function contextActionHandler(directory, options) {
1927
1927
  }
1928
1928
  }
1929
1929
 
1930
+ // src/cli-definition.ts
1931
+ function defineContextCommand(program2) {
1932
+ program2.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").addHelpText(
1933
+ "after",
1934
+ "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings"
1935
+ ).argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth").option(
1936
+ "--max-context <number>",
1937
+ "Maximum acceptable context budget (tokens)"
1938
+ ).option(
1939
+ "--min-cohesion <number>",
1940
+ "Minimum acceptable cohesion score (0-1)"
1941
+ ).option(
1942
+ "--max-fragmentation <number>",
1943
+ "Maximum acceptable fragmentation (0-1)"
1944
+ ).option(
1945
+ "--focus <type>",
1946
+ "Analysis focus: fragmentation, cohesion, depth, all"
1947
+ ).option("--include-node-modules", "Include node_modules in analysis").option(
1948
+ "--include <patterns>",
1949
+ "File patterns to include (comma-separated)"
1950
+ ).option(
1951
+ "--exclude <patterns>",
1952
+ "File patterns to exclude (comma-separated)"
1953
+ ).option(
1954
+ "--max-results <number>",
1955
+ "Maximum number of results to show in console output"
1956
+ ).option(
1957
+ "-o, --output <format>",
1958
+ "Output format: console, json, html",
1959
+ "console"
1960
+ ).option("--output-file <path>", "Output file path (for json/html)").option(
1961
+ "--interactive",
1962
+ "Run interactive setup to suggest excludes and focus areas"
1963
+ ).action(contextActionHandler);
1964
+ }
1965
+
1930
1966
  // src/cli.ts
1931
1967
  var program = new import_commander.Command();
1932
- program.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").addHelpText(
1933
- "after",
1934
- "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings"
1935
- ).argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth").option(
1936
- "--max-context <number>",
1937
- "Maximum acceptable context budget (tokens)"
1938
- ).option("--min-cohesion <number>", "Minimum acceptable cohesion score (0-1)").option(
1939
- "--max-fragmentation <number>",
1940
- "Maximum acceptable fragmentation (0-1)"
1941
- ).option(
1942
- "--focus <type>",
1943
- "Analysis focus: fragmentation, cohesion, depth, all"
1944
- ).option("--include-node-modules", "Include node_modules in analysis").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option(
1945
- "--max-results <number>",
1946
- "Maximum number of results to show in console output"
1947
- ).option(
1948
- "-o, --output <format>",
1949
- "Output format: console, json, html",
1950
- "console"
1951
- ).option("--output-file <path>", "Output file path (for json/html)").option(
1952
- "--interactive",
1953
- "Run interactive setup to suggest excludes and focus areas"
1954
- ).action(contextActionHandler);
1968
+ defineContextCommand(program);
1955
1969
  program.parse(process.argv);
package/dist/cli.mjs CHANGED
@@ -90,29 +90,43 @@ async function contextActionHandler(directory, options) {
90
90
  }
91
91
  }
92
92
 
93
+ // src/cli-definition.ts
94
+ function defineContextCommand(program2) {
95
+ program2.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").addHelpText(
96
+ "after",
97
+ "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings"
98
+ ).argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth").option(
99
+ "--max-context <number>",
100
+ "Maximum acceptable context budget (tokens)"
101
+ ).option(
102
+ "--min-cohesion <number>",
103
+ "Minimum acceptable cohesion score (0-1)"
104
+ ).option(
105
+ "--max-fragmentation <number>",
106
+ "Maximum acceptable fragmentation (0-1)"
107
+ ).option(
108
+ "--focus <type>",
109
+ "Analysis focus: fragmentation, cohesion, depth, all"
110
+ ).option("--include-node-modules", "Include node_modules in analysis").option(
111
+ "--include <patterns>",
112
+ "File patterns to include (comma-separated)"
113
+ ).option(
114
+ "--exclude <patterns>",
115
+ "File patterns to exclude (comma-separated)"
116
+ ).option(
117
+ "--max-results <number>",
118
+ "Maximum number of results to show in console output"
119
+ ).option(
120
+ "-o, --output <format>",
121
+ "Output format: console, json, html",
122
+ "console"
123
+ ).option("--output-file <path>", "Output file path (for json/html)").option(
124
+ "--interactive",
125
+ "Run interactive setup to suggest excludes and focus areas"
126
+ ).action(contextActionHandler);
127
+ }
128
+
93
129
  // src/cli.ts
94
130
  var program = new Command();
95
- program.name("aiready-context").description("Analyze AI context window cost and code structure").version("0.1.0").addHelpText(
96
- "after",
97
- "\nCONFIGURATION:\n Supports config files: aiready.json, aiready.config.json, .aiready.json, .aireadyrc.json, aiready.config.js, .aireadyrc.js\n CLI options override config file settings"
98
- ).argument("<directory>", "Directory to analyze").option("--max-depth <number>", "Maximum acceptable import depth").option(
99
- "--max-context <number>",
100
- "Maximum acceptable context budget (tokens)"
101
- ).option("--min-cohesion <number>", "Minimum acceptable cohesion score (0-1)").option(
102
- "--max-fragmentation <number>",
103
- "Maximum acceptable fragmentation (0-1)"
104
- ).option(
105
- "--focus <type>",
106
- "Analysis focus: fragmentation, cohesion, depth, all"
107
- ).option("--include-node-modules", "Include node_modules in analysis").option("--include <patterns>", "File patterns to include (comma-separated)").option("--exclude <patterns>", "File patterns to exclude (comma-separated)").option(
108
- "--max-results <number>",
109
- "Maximum number of results to show in console output"
110
- ).option(
111
- "-o, --output <format>",
112
- "Output format: console, json, html",
113
- "console"
114
- ).option("--output-file <path>", "Output file path (for json/html)").option(
115
- "--interactive",
116
- "Run interactive setup to suggest excludes and focus areas"
117
- ).action(contextActionHandler);
131
+ defineContextCommand(program);
118
132
  program.parse(process.argv);
package/dist/index.d.mts CHANGED
@@ -184,43 +184,66 @@ declare function calculateCohesion(exports: ExportInfo[], filePath?: string, opt
184
184
  declare function analyzeContext(options: ContextAnalyzerOptions): Promise<ContextAnalysisResult[]>;
185
185
 
186
186
  /**
187
- * Auto-detect domain keywords from workspace folder structure
187
+ * Auto-detect domain keywords from workspace folder structure.
188
+ *
189
+ * @param files - Array of file contents to analyze for folder patterns.
190
+ * @returns Array of singularized domain keywords.
188
191
  */
189
192
  declare function extractDomainKeywordsFromPaths(files: FileContent[]): string[];
190
193
  /**
191
- * Build a dependency graph from file contents
194
+ * Build a dependency graph from file contents, resolving imports and extracting metadata.
195
+ *
196
+ * @param files - Array of file contents to process.
197
+ * @param options - Optional configuration for domain detection.
198
+ * @returns Complete dependency graph with nodes, edges, and semantic matrices.
192
199
  */
193
200
  declare function buildDependencyGraph(files: FileContent[], options?: {
194
201
  domainKeywords?: string[];
195
202
  }): DependencyGraph;
196
203
  /**
197
- * Calculate the maximum depth of import tree for a file
204
+ * Calculate the maximum depth of the import tree for a specific file.
205
+ *
206
+ * @param file - File path to start depth calculation from.
207
+ * @param graph - The dependency graph.
208
+ * @param visited - Optional set to track visited nodes during traversal.
209
+ * @param depth - Current recursion depth.
210
+ * @returns Maximum depth of the import chain.
198
211
  */
199
212
  declare function calculateImportDepth(file: string, graph: DependencyGraph, visited?: Set<string>, depth?: number): number;
200
213
  /**
201
- * Get all transitive dependencies for a file
214
+ * Retrieve all transitive dependencies for a specific file.
215
+ *
216
+ * @param file - File path to analyze.
217
+ * @param graph - The dependency graph.
218
+ * @param visited - Optional set to track visited nodes.
219
+ * @returns Array of all reachable file paths.
202
220
  */
203
221
  declare function getTransitiveDependencies(file: string, graph: DependencyGraph, visited?: Set<string>): string[];
204
222
  /**
205
- * Calculate total context budget (tokens needed to understand this file)
223
+ * Calculate total context budget (tokens needed to understand this file and its dependencies).
224
+ *
225
+ * @param file - File path to calculate budget for.
226
+ * @param graph - The dependency graph.
227
+ * @returns Total token count including recursive dependencies.
206
228
  */
207
229
  declare function calculateContextBudget(file: string, graph: DependencyGraph): number;
208
230
  /**
209
- * Detect circular dependencies
231
+ * Detect circular dependencies (cycles) within the dependency graph.
232
+ *
233
+ * @param graph - The dependency graph to scan.
234
+ * @returns Array of dependency cycles (each cycle is an array of file paths).
210
235
  */
211
236
  declare function detectCircularDependencies(graph: DependencyGraph): string[][];
212
237
 
213
- /**
214
- * Calculate cohesion score (how related are exports in a file)
215
- */
216
238
  /**
217
239
  * Calculates a cohesion score (0-1) for a module based on its exports,
218
240
  * shared imports, and internal structure. High cohesion indicates
219
241
  * a well-focused module that is easy for AI models to reason about.
220
242
  *
221
- * @param exports - Exported symbols and their metadata
222
- * @param imports - Imported symbols and their sources
223
- * @returns Cohesion score between 0 and 1
243
+ * @param exports - Exported symbols and their metadata.
244
+ * @param filePath - Optional file path for context.
245
+ * @param options - Optional configuration for weights and co-usage context.
246
+ * @returns Cohesion score between 0 and 1.
224
247
  */
225
248
  declare function calculateEnhancedCohesion(exports: ExportInfo[], filePath?: string, options?: {
226
249
  coUsageMatrix?: Map<string, Map<string, number>>;
@@ -232,10 +255,19 @@ declare function calculateEnhancedCohesion(exports: ExportInfo[], filePath?: str
232
255
  }): number;
233
256
  /**
234
257
  * Calculate structural cohesion for a file based on co-usage patterns.
258
+ *
259
+ * @param file - The file path to analyze.
260
+ * @param coUsageMatrix - Matrix of files frequently imported together.
261
+ * @returns Cohesion score between 0 and 1 based on co-usage distribution.
235
262
  */
236
263
  declare function calculateStructuralCohesionFromCoUsage(file: string, coUsageMatrix?: Map<string, Map<string, number>>): number;
237
264
  /**
238
265
  * Calculate fragmentation score (how scattered is a domain)
266
+ *
267
+ * @param files - List of files belonging to the domain.
268
+ * @param domain - The domain identifier.
269
+ * @param options - Optional calculation parameters (log scale, thresholds).
270
+ * @returns Fragmentation score from 0 (perfect) to 1 (highly scattered).
239
271
  */
240
272
  declare function calculateFragmentation(files: string[], domain: string, options?: {
241
273
  useLogScale?: boolean;
@@ -244,11 +276,17 @@ declare function calculateFragmentation(files: string[], domain: string, options
244
276
  dependencyCount?: number;
245
277
  }): number;
246
278
  /**
247
- * Calculate path entropy for a set of files
279
+ * Calculate path entropy for a set of files to measure directory distribution.
280
+ *
281
+ * @param files - Array of file paths.
282
+ * @returns Entropy score representing the spread across directories.
248
283
  */
249
284
  declare function calculatePathEntropy(files: string[]): number;
250
285
  /**
251
- * Calculate directory-distance metric based on common ancestor depth
286
+ * Calculate directory-distance metric based on common ancestor depth.
287
+ *
288
+ * @param files - Array of file paths to compare.
289
+ * @returns Normalized distance metric (0-1).
252
290
  */
253
291
  declare function calculateDirectoryDistance(files: string[]): number;
254
292
 
@@ -308,10 +346,19 @@ declare function detectModuleClusters(graph: DependencyGraph, options?: {
308
346
 
309
347
  /**
310
348
  * Get classification-specific recommendations
349
+ *
350
+ * @param classification - The identified type of file (e.g., 'barrel-export', 'utility-module').
351
+ * @param file - File path or identifier.
352
+ * @param issues - Initial list of issues to supplement.
353
+ * @returns Array of tailored recommendations.
311
354
  */
312
355
  declare function getClassificationRecommendations(classification: FileClassification, file: string, issues: string[]): string[];
313
356
  /**
314
- * Generate general context recommendations
357
+ * Generate general context recommendations based on cross-tool metrics and thresholds.
358
+ *
359
+ * @param metrics - Object containing context budget, depth, circular dependencies, cohesion, and fragmentation.
360
+ * @param thresholds - Configurable limits for each metric.
361
+ * @returns Object with recommendations array, issues array, and overall severity level.
315
362
  */
316
363
  declare function getGeneralRecommendations(metrics: {
317
364
  contextBudget: number;
@@ -331,9 +378,23 @@ declare function getGeneralRecommendations(metrics: {
331
378
  };
332
379
 
333
380
  /**
334
- * Calculate AI Readiness Score for context efficiency (0-100)
381
+ * Calculate AI Readiness Score for context efficiency (0-100).
382
+ *
383
+ * Evaluates how efficiently an AI model can process the project's code context
384
+ * based on token budgets, import depth, and file fragmentation.
385
+ *
386
+ * @param summary - Consolidated context summary from the scan.
387
+ * @param costConfig - Optional configuration for business value calculations.
388
+ * @returns Standardized scoring output for the context analyzer tool.
389
+ * @lastUpdated 2026-03-18
335
390
  */
336
391
  declare function calculateContextScore(summary: ContextSummary, costConfig?: Partial<CostConfig>): ToolScoringOutput;
392
+ /**
393
+ * Maps a numerical score to a human-readable rating slug.
394
+ *
395
+ * @param score - The 0-100 readiness score.
396
+ * @returns A formatted rating string (e.g., "excellent", "at risk").
397
+ */
337
398
  declare function mapScoreToRating(score: number): string;
338
399
 
339
400
  /**
@@ -347,46 +408,96 @@ declare function getSmartDefaults(directory: string, userOptions: Partial<Contex
347
408
 
348
409
  /**
349
410
  * Generate summary of context analysis results
411
+ *
412
+ * @param results - Array of individual file analysis results.
413
+ * @param options - Optional scan configuration for context extraction.
414
+ * @returns A consolidated summary of the entire context scan.
350
415
  */
351
416
  declare function generateSummary(results: ContextAnalysisResult[], options?: any): ContextSummary;
352
417
 
353
418
  /**
354
- * Build co-usage matrix: track which files are imported together
355
- * @param graph - The dependency graph to analyze
356
- * @returns Map of file to co-usage counts
419
+ * Build co-usage matrix: track which files are imported together frequently.
420
+ *
421
+ * @param graph - The dependency graph to analyze.
422
+ * @returns Map of file path to nested map of related files and their co-occurrence counts.
357
423
  */
358
424
  declare function buildCoUsageMatrix(graph: DependencyGraph): Map<string, Map<string, number>>;
359
425
  /**
360
- * Extract type dependencies from AST exports
361
- * @param graph - The dependency graph to analyze
362
- * @returns Map of type references to files that use them
426
+ * Extract type dependencies from AST exports to build a type-based relationship graph.
427
+ *
428
+ * @param graph - The dependency graph to analyze.
429
+ * @returns Map of type reference names to sets of files that consume or export them.
363
430
  */
364
431
  declare function buildTypeGraph(graph: DependencyGraph): Map<string, Set<string>>;
365
432
  /**
366
- * Find semantic clusters using co-usage patterns
367
- * @param coUsageMatrix - The co-usage matrix from buildCoUsageMatrix
368
- * @param minCoUsage - Minimum co-usage count to consider (default: 3)
369
- * @returns Map of cluster representative files to their cluster members
433
+ * Find semantic clusters using frequently occurring co-usage patterns.
434
+ *
435
+ * @param coUsageMatrix - The co-usage matrix from buildCoUsageMatrix.
436
+ * @param minCoUsage - Minimum co-usage count to consider a strong relationship (default: 3).
437
+ * @returns Map of cluster representative files to their associated cluster members.
370
438
  */
371
439
  declare function findSemanticClusters(coUsageMatrix: Map<string, Map<string, number>>, minCoUsage?: number): Map<string, string[]>;
372
440
  /**
373
- * Infer domain from semantic analysis (co-usage + types)
441
+ * Infer domain from semantic analysis (co-usage + types) to identify logical modules.
442
+ *
443
+ * @param file - The file path to infer domain for.
444
+ * @param exportName - The specific export identifier.
445
+ * @param graph - The full dependency graph.
446
+ * @param coUsageMatrix - Matrix of files frequently imported together.
447
+ * @param typeGraph - Map of type references to files.
448
+ * @param exportTypeRefs - Optional list of types referenced by the export.
449
+ * @returns Array of potential domain assignments with confidence scores.
374
450
  */
375
451
  declare function inferDomainFromSemantics(file: string, exportName: string, graph: DependencyGraph, coUsageMatrix: Map<string, Map<string, number>>, typeGraph: Map<string, Set<string>>, exportTypeRefs?: string[]): DomainAssignment[];
452
+ /**
453
+ * Calculate confidence score for a domain assignment based on signals.
454
+ *
455
+ * @param signals - The set of semantic signals detected for a domain.
456
+ * @returns Numerical confidence score (0-1).
457
+ */
376
458
  declare function calculateDomainConfidence(signals: DomainSignals): number;
377
459
  /**
378
460
  * Regex-based export extraction (legacy/fallback)
461
+ *
462
+ * @param content - Source code content.
463
+ * @param filePath - Optional file path for domain context.
464
+ * @param domainOptions - Optional overrides for domain keywords.
465
+ * @param fileImports - Optional list of actual imports for semantic context.
466
+ * @returns Array of extracted export information.
379
467
  */
380
468
  declare function extractExports(content: string, filePath?: string, domainOptions?: {
381
469
  domainKeywords?: string[];
382
470
  }, fileImports?: string[]): ExportInfo[];
383
471
  /**
384
472
  * Infer domain from name, path, or imports
473
+ *
474
+ * @param name - The identifier name to analyze.
475
+ * @param filePath - Optional file path for structure context.
476
+ * @param domainOptions - Optional overrides for domain keywords.
477
+ * @param fileImports - Optional list of imports for domain context.
478
+ * @returns The inferred domain name (string).
385
479
  */
386
480
  declare function inferDomain(name: string, filePath?: string, domainOptions?: {
387
481
  domainKeywords?: string[];
388
482
  }, fileImports?: string[]): string;
483
+ /**
484
+ * Retrieve co-usage data for a specific file.
485
+ *
486
+ * @param file - The file path to look up.
487
+ * @param coUsageMatrix - The global co-usage matrix.
488
+ * @returns Formatted co-usage data object.
489
+ */
389
490
  declare function getCoUsageData(file: string, coUsageMatrix: Map<string, Map<string, number>>): CoUsageData;
491
+ /**
492
+ * Identify candidates for module consolidation based on high co-usage or shared types.
493
+ *
494
+ * @param graph - The dependency graph.
495
+ * @param coUsageMatrix - Matrix of frequently paired files.
496
+ * @param typeGraph - Map of shared type references.
497
+ * @param minCoUsage - Minimum co-usage count threshold.
498
+ * @param minSharedTypes - Minimum shared types threshold.
499
+ * @returns Array of consolidation candidates sorted by strength.
500
+ */
390
501
  declare function findConsolidationCandidates(graph: DependencyGraph, coUsageMatrix: Map<string, Map<string, number>>, typeGraph: Map<string, Set<string>>, minCoUsage?: number, minSharedTypes?: number): any[];
391
502
 
392
503
  /**