@compilr-dev/agents-coding-ts 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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +34 -0
  3. package/dist/index.js +66 -0
  4. package/dist/parser/index.d.ts +7 -0
  5. package/dist/parser/index.js +6 -0
  6. package/dist/parser/typescript-parser.d.ts +22 -0
  7. package/dist/parser/typescript-parser.js +423 -0
  8. package/dist/skills/code-health.d.ts +9 -0
  9. package/dist/skills/code-health.js +167 -0
  10. package/dist/skills/code-structure.d.ts +9 -0
  11. package/dist/skills/code-structure.js +97 -0
  12. package/dist/skills/dependency-audit.d.ts +9 -0
  13. package/dist/skills/dependency-audit.js +110 -0
  14. package/dist/skills/index.d.ts +16 -0
  15. package/dist/skills/index.js +27 -0
  16. package/dist/skills/refactor-impact.d.ts +9 -0
  17. package/dist/skills/refactor-impact.js +135 -0
  18. package/dist/skills/type-analysis.d.ts +9 -0
  19. package/dist/skills/type-analysis.js +150 -0
  20. package/dist/tools/find-dead-code.d.ts +20 -0
  21. package/dist/tools/find-dead-code.js +375 -0
  22. package/dist/tools/find-duplicates.d.ts +21 -0
  23. package/dist/tools/find-duplicates.js +274 -0
  24. package/dist/tools/find-implementations.d.ts +21 -0
  25. package/dist/tools/find-implementations.js +436 -0
  26. package/dist/tools/find-patterns.d.ts +21 -0
  27. package/dist/tools/find-patterns.js +457 -0
  28. package/dist/tools/find-references.d.ts +23 -0
  29. package/dist/tools/find-references.js +488 -0
  30. package/dist/tools/find-symbol.d.ts +21 -0
  31. package/dist/tools/find-symbol.js +458 -0
  32. package/dist/tools/get-call-graph.d.ts +23 -0
  33. package/dist/tools/get-call-graph.js +469 -0
  34. package/dist/tools/get-complexity.d.ts +21 -0
  35. package/dist/tools/get-complexity.js +394 -0
  36. package/dist/tools/get-dependency-graph.d.ts +23 -0
  37. package/dist/tools/get-dependency-graph.js +482 -0
  38. package/dist/tools/get-documentation.d.ts +21 -0
  39. package/dist/tools/get-documentation.js +613 -0
  40. package/dist/tools/get-exports.d.ts +21 -0
  41. package/dist/tools/get-exports.js +427 -0
  42. package/dist/tools/get-file-structure.d.ts +27 -0
  43. package/dist/tools/get-file-structure.js +120 -0
  44. package/dist/tools/get-imports.d.ts +23 -0
  45. package/dist/tools/get-imports.js +350 -0
  46. package/dist/tools/get-signature.d.ts +20 -0
  47. package/dist/tools/get-signature.js +758 -0
  48. package/dist/tools/get-type-hierarchy.d.ts +22 -0
  49. package/dist/tools/get-type-hierarchy.js +485 -0
  50. package/dist/tools/index.d.ts +23 -0
  51. package/dist/tools/index.js +25 -0
  52. package/dist/tools/types.d.ts +1302 -0
  53. package/dist/tools/types.js +7 -0
  54. package/package.json +84 -0
@@ -0,0 +1,1302 @@
1
+ /**
2
+ * Types for Source Code Analysis Tools
3
+ *
4
+ * Uses TypeScript Compiler API for structural analysis of source code,
5
+ * reducing the need for the agent to read and reason through raw text.
6
+ */
7
+ /**
8
+ * Supported languages for analysis
9
+ */
10
+ export type SupportedLanguage = 'typescript' | 'javascript';
11
+ /**
12
+ * Parameter information for functions/methods
13
+ */
14
+ export interface ParameterInfo {
15
+ /** Parameter name */
16
+ name: string;
17
+ /** Type annotation (if available) */
18
+ type?: string;
19
+ }
20
+ /**
21
+ * Input for getFileStructure tool
22
+ */
23
+ export interface GetFileStructureInput {
24
+ /** Absolute path to the file to analyze */
25
+ path: string;
26
+ /** Maximum depth for nested structures (default: 2) */
27
+ maxDepth?: number;
28
+ /** Include private/internal symbols (default: true) */
29
+ includePrivate?: boolean;
30
+ }
31
+ /**
32
+ * Output from getFileStructure tool
33
+ */
34
+ export interface FileStructure {
35
+ /** Analyzed file path */
36
+ path: string;
37
+ /** Detected language */
38
+ language: string;
39
+ /** Language detection confidence (0-1) */
40
+ languageConfidence: number;
41
+ /** File imports */
42
+ imports: ImportInfo[];
43
+ /** File exports */
44
+ exports: ExportInfo[];
45
+ /** Top-level classes */
46
+ classes: ClassInfo[];
47
+ /** Top-level functions */
48
+ functions: FunctionInfo[];
49
+ /** Top-level variables/constants */
50
+ variables: VariableInfo[];
51
+ /** Type definitions (interfaces, types, enums) */
52
+ types: TypeDefinitionInfo[];
53
+ /** File statistics */
54
+ stats?: FileStats;
55
+ }
56
+ /**
57
+ * Import information
58
+ */
59
+ export interface ImportInfo {
60
+ /** Module/package being imported */
61
+ source: string;
62
+ /** Named imports */
63
+ names: string[];
64
+ /** Default import name */
65
+ defaultImport?: string;
66
+ /** Namespace import (import * as x) */
67
+ namespaceImport?: string;
68
+ /** Is type-only import */
69
+ isTypeOnly: boolean;
70
+ }
71
+ /**
72
+ * Export information
73
+ */
74
+ export interface ExportInfo {
75
+ /** Exported symbol name */
76
+ name: string;
77
+ /** Is default export */
78
+ isDefault: boolean;
79
+ /** Is type-only export */
80
+ isTypeOnly: boolean;
81
+ }
82
+ /**
83
+ * Class information
84
+ */
85
+ export interface ClassInfo {
86
+ /** Class name */
87
+ name: string;
88
+ /** Is exported */
89
+ exported: boolean;
90
+ /** Is abstract */
91
+ abstract?: boolean;
92
+ /** Class methods */
93
+ methods?: MethodInfo[];
94
+ /** Class properties */
95
+ properties?: PropertyInfo[];
96
+ }
97
+ /**
98
+ * Function information
99
+ */
100
+ export interface FunctionInfo {
101
+ /** Function name */
102
+ name: string;
103
+ /** Is exported */
104
+ exported: boolean;
105
+ /** Is async */
106
+ async: boolean;
107
+ /** Parameters */
108
+ parameters?: ParameterInfo[];
109
+ /** Return type (if available) */
110
+ returnType?: string;
111
+ }
112
+ /**
113
+ * Method information
114
+ */
115
+ export interface MethodInfo {
116
+ /** Method name */
117
+ name: string;
118
+ /** Visibility */
119
+ visibility: 'public' | 'private' | 'protected';
120
+ /** Is async */
121
+ async: boolean;
122
+ /** Is static */
123
+ static: boolean;
124
+ /** Parameters */
125
+ parameters?: ParameterInfo[];
126
+ /** Return type (if available) */
127
+ returnType?: string;
128
+ }
129
+ /**
130
+ * Property information
131
+ */
132
+ export interface PropertyInfo {
133
+ /** Property name */
134
+ name: string;
135
+ /** Type annotation */
136
+ type?: string;
137
+ /** Visibility */
138
+ visibility: 'public' | 'private' | 'protected';
139
+ /** Is static */
140
+ static: boolean;
141
+ /** Is readonly */
142
+ readonly?: boolean;
143
+ }
144
+ /**
145
+ * Variable/constant information
146
+ */
147
+ export interface VariableInfo {
148
+ /** Variable name */
149
+ name: string;
150
+ /** Declaration kind */
151
+ kind: 'const' | 'let' | 'var';
152
+ /** Type annotation */
153
+ type?: string;
154
+ /** Is exported */
155
+ exported: boolean;
156
+ }
157
+ /**
158
+ * Type definition information (interface, type alias, enum)
159
+ */
160
+ export interface TypeDefinitionInfo {
161
+ /** Type name */
162
+ name: string;
163
+ /** Kind of type definition */
164
+ kind: 'interface' | 'type' | 'enum';
165
+ /** Is exported */
166
+ exported: boolean;
167
+ }
168
+ /**
169
+ * File statistics
170
+ */
171
+ export interface FileStats {
172
+ /** Total line count */
173
+ lineCount: number;
174
+ /** Number of imports */
175
+ importCount: number;
176
+ /** Number of exports */
177
+ exportCount: number;
178
+ /** Number of classes */
179
+ classCount: number;
180
+ /** Number of functions */
181
+ functionCount: number;
182
+ /** Number of type definitions */
183
+ typeCount: number;
184
+ }
185
+ /**
186
+ * Options for parsing/extraction
187
+ */
188
+ export interface ExtractorOptions {
189
+ /** Maximum depth for nested structures */
190
+ maxDepth?: number;
191
+ /** Include private members */
192
+ includePrivate?: boolean;
193
+ }
194
+ /**
195
+ * Symbol kind for filtering
196
+ */
197
+ export type SymbolKind = 'function' | 'class' | 'variable' | 'type' | 'interface' | 'enum' | 'method' | 'property';
198
+ /**
199
+ * Symbol kind filter (includes 'any' for no filtering)
200
+ */
201
+ export type SymbolKindFilter = SymbolKind | 'any';
202
+ /**
203
+ * Input for findSymbol tool
204
+ */
205
+ export interface FindSymbolInput {
206
+ /** Symbol name to find */
207
+ symbol: string;
208
+ /** Scope the search to a specific file or directory */
209
+ scope?: string;
210
+ /** Filter by symbol kind */
211
+ kind?: SymbolKindFilter;
212
+ /** Maximum results to return (default: 10) */
213
+ limit?: number;
214
+ /** Include symbols from node_modules (default: false) */
215
+ includeNodeModules?: boolean;
216
+ }
217
+ /**
218
+ * A found symbol definition
219
+ */
220
+ export interface SymbolDefinition {
221
+ /** Symbol name */
222
+ name: string;
223
+ /** File path */
224
+ path: string;
225
+ /** Line number (1-based) */
226
+ line: number;
227
+ /** Column number (1-based) */
228
+ column: number;
229
+ /** Symbol kind */
230
+ kind: SymbolKind;
231
+ /** Containing class/module (if applicable) */
232
+ container?: string;
233
+ /** Is exported */
234
+ exported: boolean;
235
+ /** Signature (for functions/methods) */
236
+ signature?: string;
237
+ /** JSDoc/docstring summary */
238
+ docSummary?: string;
239
+ /** Confidence score (0-1) for fuzzy matches */
240
+ confidence: number;
241
+ }
242
+ /**
243
+ * Search statistics
244
+ */
245
+ export interface SearchStats {
246
+ /** Number of files searched */
247
+ filesSearched: number;
248
+ /** Time taken in milliseconds */
249
+ timeMs: number;
250
+ }
251
+ /**
252
+ * Output from findSymbol tool
253
+ */
254
+ export interface FindSymbolResult {
255
+ /** Symbol that was searched */
256
+ query: string;
257
+ /** Found definitions */
258
+ definitions: SymbolDefinition[];
259
+ /** Search statistics */
260
+ stats: SearchStats;
261
+ }
262
+ /**
263
+ * Reference type - how the symbol is used
264
+ */
265
+ export type ReferenceType = 'read' | 'write' | 'call' | 'import' | 'export' | 'type' | 'extend' | 'implement';
266
+ /**
267
+ * Input for findReferences tool
268
+ */
269
+ export interface FindReferencesInput {
270
+ /** Symbol name to find */
271
+ symbol: string;
272
+ /** File where the symbol is defined (improves accuracy) */
273
+ definitionFile?: string;
274
+ /** Line where symbol is defined (improves accuracy) */
275
+ definitionLine?: number;
276
+ /** Scope the search to a specific file or directory */
277
+ scope?: string;
278
+ /** Maximum results to return (default: 50) */
279
+ limit?: number;
280
+ /** Include the definition itself (default: false) */
281
+ includeDefinition?: boolean;
282
+ /** Group results by file (default: true) */
283
+ groupByFile?: boolean;
284
+ }
285
+ /**
286
+ * A reference to a symbol
287
+ */
288
+ export interface Reference {
289
+ /** File path */
290
+ path: string;
291
+ /** Line number (1-based) */
292
+ line: number;
293
+ /** Column number (1-based) */
294
+ column: number;
295
+ /** Reference context (the line of code, trimmed) */
296
+ context: string;
297
+ /** Reference type */
298
+ type: ReferenceType;
299
+ /** Containing function/method */
300
+ containingFunction?: string;
301
+ }
302
+ /**
303
+ * References grouped by file
304
+ */
305
+ export interface FileReferences {
306
+ /** File path */
307
+ path: string;
308
+ /** References in this file */
309
+ references: Reference[];
310
+ }
311
+ /**
312
+ * Output from findReferences tool
313
+ */
314
+ export interface FindReferencesResult {
315
+ /** Symbol that was searched */
316
+ symbol: string;
317
+ /** Definition location (if found) */
318
+ definition?: SymbolDefinition;
319
+ /** References grouped by file (if groupByFile=true) */
320
+ byFile?: FileReferences[];
321
+ /** Flat list of references (if groupByFile=false) */
322
+ references?: Reference[];
323
+ /** Total reference count */
324
+ totalCount: number;
325
+ /** Whether results were truncated */
326
+ truncated: boolean;
327
+ /** Search statistics */
328
+ stats: SearchStats;
329
+ }
330
+ /**
331
+ * Input for getImports tool
332
+ */
333
+ export interface GetImportsInput {
334
+ /** File or directory to analyze */
335
+ path: string;
336
+ /** Recursively analyze directory (default: false) */
337
+ recursive?: boolean;
338
+ /** Filter to specific import sources */
339
+ filterSource?: string;
340
+ /** Include transitive imports (default: false) */
341
+ transitive?: boolean;
342
+ /** Max depth for transitive imports (default: 3) */
343
+ maxDepth?: number;
344
+ }
345
+ /**
346
+ * An imported symbol
347
+ */
348
+ export interface ImportedSymbol {
349
+ /** Symbol name as imported */
350
+ name: string;
351
+ /** Original name if aliased */
352
+ originalName?: string;
353
+ /** Is default import */
354
+ isDefault: boolean;
355
+ /** Is namespace import */
356
+ isNamespace: boolean;
357
+ /** Used in file (for dead import detection) */
358
+ isUsed?: boolean;
359
+ }
360
+ /**
361
+ * Detailed import information
362
+ */
363
+ export interface DetailedImport {
364
+ /** Import source (package or path) */
365
+ source: string;
366
+ /** Resolved absolute path (for local imports) */
367
+ resolvedPath?: string;
368
+ /** Is external package */
369
+ isExternal: boolean;
370
+ /** Is type-only import */
371
+ typeOnly: boolean;
372
+ /** Imported symbols */
373
+ symbols: ImportedSymbol[];
374
+ /** Line number (1-based) */
375
+ line: number;
376
+ /** For external: package version from lockfile */
377
+ version?: string;
378
+ }
379
+ /**
380
+ * Transitive import chain
381
+ */
382
+ export interface TransitiveImport {
383
+ /** Import chain: [fileA, fileB, fileC] means A->B->C */
384
+ chain: string[];
385
+ /** Final imported module */
386
+ target: string;
387
+ /** Depth in import tree */
388
+ depth: number;
389
+ }
390
+ /**
391
+ * Import statistics
392
+ */
393
+ export interface ImportStats {
394
+ /** Total number of imports */
395
+ totalImports: number;
396
+ /** Number of external package imports */
397
+ externalPackages: number;
398
+ /** Number of internal module imports */
399
+ internalModules: number;
400
+ /** Number of type-only imports */
401
+ typeOnlyImports: number;
402
+ }
403
+ /**
404
+ * Output from getImports tool
405
+ */
406
+ export interface GetImportsResult {
407
+ /** Analyzed path */
408
+ path: string;
409
+ /** Direct imports */
410
+ imports: DetailedImport[];
411
+ /** Transitive imports (if requested) */
412
+ transitiveImports?: TransitiveImport[];
413
+ /** Import statistics */
414
+ stats: ImportStats;
415
+ }
416
+ /**
417
+ * Input for getExports tool
418
+ */
419
+ export interface GetExportsInput {
420
+ /** File or directory to analyze */
421
+ path: string;
422
+ /** Include re-exports (default: true) */
423
+ includeReExports?: boolean;
424
+ /** Resolve re-exports to original source (default: false) */
425
+ resolveReExports?: boolean;
426
+ }
427
+ /**
428
+ * Kind of exported symbol
429
+ */
430
+ export type ExportKind = 'function' | 'class' | 'variable' | 'type' | 'interface' | 'enum' | 'namespace' | 'unknown';
431
+ /**
432
+ * An exported symbol
433
+ */
434
+ export interface ExportedSymbol {
435
+ /** Exported name */
436
+ name: string;
437
+ /** Kind of export */
438
+ kind: ExportKind;
439
+ /** Line number (1-based) */
440
+ line: number;
441
+ /** Signature (for functions) */
442
+ signature?: string;
443
+ /** JSDoc summary */
444
+ docSummary?: string;
445
+ /** Is type-only export */
446
+ typeOnly?: boolean;
447
+ }
448
+ /**
449
+ * A re-export (export from another module)
450
+ */
451
+ export interface ReExport {
452
+ /** What is being re-exported ('*' for all) */
453
+ symbols: string[] | '*';
454
+ /** Source module */
455
+ from: string;
456
+ /** Resolved absolute path (for local modules) */
457
+ resolvedFrom?: string;
458
+ /** Line number (1-based) */
459
+ line: number;
460
+ /** Is type-only re-export */
461
+ typeOnly?: boolean;
462
+ }
463
+ /**
464
+ * Export statistics
465
+ */
466
+ export interface ExportStats {
467
+ /** Total number of exports */
468
+ totalExports: number;
469
+ /** Number of function exports */
470
+ functions: number;
471
+ /** Number of class exports */
472
+ classes: number;
473
+ /** Number of type/interface exports */
474
+ types: number;
475
+ /** Number of variable exports */
476
+ variables: number;
477
+ /** Number of re-exports */
478
+ reExports: number;
479
+ }
480
+ /**
481
+ * Output from getExports tool
482
+ */
483
+ export interface GetExportsResult {
484
+ /** Analyzed path */
485
+ path: string;
486
+ /** Default export (if any) */
487
+ defaultExport?: ExportedSymbol;
488
+ /** Named exports */
489
+ namedExports: ExportedSymbol[];
490
+ /** Re-exports (exports from other modules) */
491
+ reExports?: ReExport[];
492
+ /** Export statistics */
493
+ stats: ExportStats;
494
+ }
495
+ /**
496
+ * Direction for call graph traversal
497
+ */
498
+ export type CallGraphDirection = 'callers' | 'callees' | 'both';
499
+ /**
500
+ * Type of function call
501
+ */
502
+ export type CallType = 'direct' | 'callback' | 'promise' | 'event' | 'method';
503
+ /**
504
+ * Input for getCallGraph tool
505
+ */
506
+ export interface GetCallGraphInput {
507
+ /** File to analyze */
508
+ path: string;
509
+ /** Specific function to analyze (optional - analyzes all if not specified) */
510
+ functionName?: string;
511
+ /** Direction: 'callers' | 'callees' | 'both' (default: 'both') */
512
+ direction?: CallGraphDirection;
513
+ /** Maximum depth to traverse (default: 2) */
514
+ maxDepth?: number;
515
+ /** Include external package calls (default: false) */
516
+ includeExternal?: boolean;
517
+ /** Scope directory for finding callers (default: file's directory) */
518
+ scope?: string;
519
+ }
520
+ /**
521
+ * A function node in the call graph
522
+ */
523
+ export interface FunctionNode {
524
+ /** Function name */
525
+ name: string;
526
+ /** File path */
527
+ path: string;
528
+ /** Line number (1-based) */
529
+ line: number;
530
+ /** Column number (1-based) */
531
+ column: number;
532
+ /** Containing class (if method) */
533
+ className?: string;
534
+ /** Is async function */
535
+ async?: boolean;
536
+ /** Is exported */
537
+ exported?: boolean;
538
+ }
539
+ /**
540
+ * Information about a function call
541
+ */
542
+ export interface CallInfo {
543
+ /** Called/calling function */
544
+ function: FunctionNode;
545
+ /** Line where call occurs (1-based) */
546
+ callLine: number;
547
+ /** Column where call occurs (1-based) */
548
+ callColumn: number;
549
+ /** Call type */
550
+ type: CallType;
551
+ /** Number of call sites (for aggregated results) */
552
+ count: number;
553
+ }
554
+ /**
555
+ * A node in the call graph with its edges
556
+ */
557
+ export interface CallGraphNode {
558
+ /** Function info */
559
+ function: FunctionNode;
560
+ /** Functions this function calls (outgoing edges) */
561
+ calls: CallInfo[];
562
+ /** Functions that call this function (incoming edges) */
563
+ calledBy: CallInfo[];
564
+ }
565
+ /**
566
+ * Call graph statistics
567
+ */
568
+ export interface CallGraphStats {
569
+ /** Total number of functions in the graph */
570
+ totalFunctions: number;
571
+ /** Total number of call edges */
572
+ totalCalls: number;
573
+ /** Maximum depth reached */
574
+ maxDepthReached: number;
575
+ /** Number of external calls (if includeExternal) */
576
+ externalCalls?: number;
577
+ }
578
+ /**
579
+ * Output from getCallGraph tool
580
+ */
581
+ export interface GetCallGraphResult {
582
+ /** Root function analyzed (if functionName was specified) */
583
+ root?: FunctionNode;
584
+ /** Call graph nodes */
585
+ graph: CallGraphNode[];
586
+ /** Statistics */
587
+ stats: CallGraphStats;
588
+ }
589
+ /**
590
+ * Input for getDependencyGraph tool
591
+ */
592
+ export interface GetDependencyGraphInput {
593
+ /** Directory or file to analyze */
594
+ path: string;
595
+ /** Include external package dependencies (default: true) */
596
+ includeExternal?: boolean;
597
+ /** Include type-only imports (default: true) */
598
+ includeTypeOnly?: boolean;
599
+ /** Maximum depth for directory traversal (default: 10) */
600
+ maxDepth?: number;
601
+ /** File patterns to include (glob patterns like *.ts, *.tsx, *.js) */
602
+ include?: string[];
603
+ /** File patterns to exclude (glob patterns like node_modules, dist) */
604
+ exclude?: string[];
605
+ }
606
+ /**
607
+ * A module node in the dependency graph
608
+ */
609
+ export interface ModuleNode {
610
+ /** Module path (relative to analysis root) */
611
+ path: string;
612
+ /** Absolute path */
613
+ absolutePath: string;
614
+ /** Is external package */
615
+ isExternal: boolean;
616
+ /** Package name (for external modules) */
617
+ packageName?: string;
618
+ /** Number of exports */
619
+ exportCount?: number;
620
+ }
621
+ /**
622
+ * A dependency edge in the graph
623
+ */
624
+ export interface DependencyEdge {
625
+ /** Source module */
626
+ from: string;
627
+ /** Target module */
628
+ to: string;
629
+ /** Import type */
630
+ importType: 'named' | 'default' | 'namespace' | 'side-effect';
631
+ /** Is type-only import */
632
+ typeOnly: boolean;
633
+ /** Number of symbols imported */
634
+ symbolCount: number;
635
+ /** Imported symbol names (up to 10) */
636
+ symbols?: string[];
637
+ }
638
+ /**
639
+ * A circular dependency chain
640
+ */
641
+ export interface CircularDependency {
642
+ /** Modules in the cycle (first and last are the same) */
643
+ cycle: string[];
644
+ /** Length of the cycle */
645
+ length: number;
646
+ }
647
+ /**
648
+ * Dependency graph statistics
649
+ */
650
+ export interface DependencyGraphStats {
651
+ /** Total number of modules */
652
+ totalModules: number;
653
+ /** Number of internal modules */
654
+ internalModules: number;
655
+ /** Number of external packages */
656
+ externalPackages: number;
657
+ /** Total number of dependency edges */
658
+ totalEdges: number;
659
+ /** Number of circular dependencies detected */
660
+ circularDependencies: number;
661
+ /** List of external package names */
662
+ externalPackageList: string[];
663
+ /** Module with most dependencies (imports) */
664
+ mostDependencies?: {
665
+ module: string;
666
+ count: number;
667
+ };
668
+ /** Module with most dependents (imported by) */
669
+ mostDependents?: {
670
+ module: string;
671
+ count: number;
672
+ };
673
+ }
674
+ /**
675
+ * Output from getDependencyGraph tool
676
+ */
677
+ export interface GetDependencyGraphResult {
678
+ /** Root path analyzed */
679
+ root: string;
680
+ /** All modules in the graph */
681
+ modules: ModuleNode[];
682
+ /** Dependency edges */
683
+ edges: DependencyEdge[];
684
+ /** Detected circular dependencies */
685
+ circularDependencies: CircularDependency[];
686
+ /** Statistics */
687
+ stats: DependencyGraphStats;
688
+ }
689
+ /**
690
+ * Input for findImplementations tool
691
+ */
692
+ export interface FindImplementationsInput {
693
+ /** Interface or abstract class name to find implementations of */
694
+ name: string;
695
+ /** Scope: file or directory to search in */
696
+ scope?: string;
697
+ /** Include abstract classes that partially implement (default: false) */
698
+ includeAbstract?: boolean;
699
+ /** Maximum files to search (default: 100) */
700
+ maxFiles?: number;
701
+ }
702
+ /**
703
+ * An implementation of an interface or abstract class
704
+ */
705
+ export interface ImplementationInfo {
706
+ /** Class/type name */
707
+ name: string;
708
+ /** File path */
709
+ path: string;
710
+ /** Line number (1-based) */
711
+ line: number;
712
+ /** Column number (1-based) */
713
+ column: number;
714
+ /** Kind of implementation */
715
+ kind: 'class' | 'type' | 'object';
716
+ /** Is abstract (partial implementation) */
717
+ isAbstract?: boolean;
718
+ /** Is exported */
719
+ exported: boolean;
720
+ /** Methods implemented (if interface) */
721
+ implementedMethods?: string[];
722
+ /** Methods missing (if partial) */
723
+ missingMethods?: string[];
724
+ }
725
+ /**
726
+ * Output from findImplementations tool
727
+ */
728
+ export interface FindImplementationsResult {
729
+ /** Interface/abstract class that was searched */
730
+ target: string;
731
+ /** Target location (if found) */
732
+ targetLocation?: {
733
+ path: string;
734
+ line: number;
735
+ };
736
+ /** Found implementations */
737
+ implementations: ImplementationInfo[];
738
+ /** Statistics */
739
+ stats: {
740
+ filesSearched: number;
741
+ implementationsFound: number;
742
+ timeMs: number;
743
+ };
744
+ }
745
+ /**
746
+ * Direction for type hierarchy traversal
747
+ */
748
+ export type HierarchyDirection = 'ancestors' | 'descendants' | 'both';
749
+ /**
750
+ * Input for getTypeHierarchy tool
751
+ */
752
+ export interface GetTypeHierarchyInput {
753
+ /** Class or interface name */
754
+ name: string;
755
+ /** File where the type is defined (improves accuracy) */
756
+ file?: string;
757
+ /** Direction: 'ancestors' | 'descendants' | 'both' (default: 'both') */
758
+ direction?: HierarchyDirection;
759
+ /** Maximum depth to traverse (default: 5) */
760
+ maxDepth?: number;
761
+ /** Scope for searching descendants */
762
+ scope?: string;
763
+ }
764
+ /**
765
+ * A type in the hierarchy
766
+ */
767
+ export interface TypeHierarchyNode {
768
+ /** Type name */
769
+ name: string;
770
+ /** File path */
771
+ path: string;
772
+ /** Line number (1-based) */
773
+ line: number;
774
+ /** Kind of type */
775
+ kind: 'class' | 'interface' | 'type';
776
+ /** Is abstract */
777
+ isAbstract?: boolean;
778
+ /** Is exported */
779
+ exported: boolean;
780
+ /** Parent types (extends/implements) */
781
+ parents?: TypeHierarchyNode[];
782
+ /** Child types (extended by/implemented by) */
783
+ children?: TypeHierarchyNode[];
784
+ }
785
+ /**
786
+ * Output from getTypeHierarchy tool
787
+ */
788
+ export interface GetTypeHierarchyResult {
789
+ /** Root type that was analyzed */
790
+ root: TypeHierarchyNode;
791
+ /** Flat list of all types in hierarchy */
792
+ allTypes: TypeHierarchyNode[];
793
+ /** Statistics */
794
+ stats: {
795
+ totalTypes: number;
796
+ maxDepthReached: number;
797
+ filesSearched: number;
798
+ };
799
+ }
800
+ /**
801
+ * Input for getComplexity tool
802
+ */
803
+ export interface GetComplexityInput {
804
+ /** File or directory to analyze */
805
+ path: string;
806
+ /** Recursive analysis for directories (default: false) */
807
+ recursive?: boolean;
808
+ /** Complexity threshold for warnings (default: 10) */
809
+ threshold?: number;
810
+ /** Only return items above threshold (default: false) */
811
+ onlyAboveThreshold?: boolean;
812
+ /** Maximum files to analyze (default: 50) */
813
+ maxFiles?: number;
814
+ }
815
+ /**
816
+ * Complexity contributor type
817
+ */
818
+ export type ComplexityContributorType = 'if' | 'else' | 'switch' | 'case' | 'for' | 'while' | 'do' | 'catch' | 'ternary' | 'logical_and' | 'logical_or' | 'nullish' | 'nesting';
819
+ /**
820
+ * A contributor to complexity score
821
+ */
822
+ export interface ComplexityContributor {
823
+ /** Type of complexity contributor */
824
+ type: ComplexityContributorType;
825
+ /** Line number */
826
+ line: number;
827
+ /** Contribution to complexity score */
828
+ contribution: number;
829
+ }
830
+ /**
831
+ * Complexity metrics for a single function
832
+ */
833
+ export interface FunctionComplexity {
834
+ /** Function name */
835
+ name: string;
836
+ /** Line number */
837
+ line: number;
838
+ /** End line number */
839
+ endLine: number;
840
+ /** Cyclomatic complexity */
841
+ cyclomatic: number;
842
+ /** Cognitive complexity (Sonar-style) */
843
+ cognitive: number;
844
+ /** Maximum nesting depth */
845
+ maxNesting: number;
846
+ /** Lines of code (excluding blank/comments) */
847
+ loc: number;
848
+ /** Parameter count */
849
+ parameterCount: number;
850
+ /** Is above threshold */
851
+ aboveThreshold: boolean;
852
+ /** Complexity contributors (if above threshold) */
853
+ contributors?: ComplexityContributor[];
854
+ }
855
+ /**
856
+ * Complexity metrics for a file
857
+ */
858
+ export interface FileComplexity {
859
+ /** File path */
860
+ path: string;
861
+ /** File-level metrics */
862
+ metrics: {
863
+ /** Total lines */
864
+ lines: number;
865
+ /** Lines of code */
866
+ linesOfCode: number;
867
+ /** Number of functions */
868
+ functions: number;
869
+ /** Number of classes */
870
+ classes: number;
871
+ /** Average complexity */
872
+ avgComplexity: number;
873
+ /** Maximum complexity */
874
+ maxComplexity: number;
875
+ };
876
+ /** Function-level complexity */
877
+ functions: FunctionComplexity[];
878
+ }
879
+ /**
880
+ * Output from getComplexity tool
881
+ */
882
+ export interface GetComplexityResult {
883
+ /** Analyzed path */
884
+ path: string;
885
+ /** File-level complexity */
886
+ files: FileComplexity[];
887
+ /** Summary statistics */
888
+ summary: {
889
+ totalFiles: number;
890
+ totalFunctions: number;
891
+ averageComplexity: number;
892
+ maxComplexity: number;
893
+ aboveThreshold: number;
894
+ threshold: number;
895
+ };
896
+ /** Most complex functions (top 5) */
897
+ hotspots: Array<{
898
+ name: string;
899
+ path: string;
900
+ line: number;
901
+ cyclomatic: number;
902
+ cognitive: number;
903
+ }>;
904
+ }
905
+ /**
906
+ * Input for findDeadCode tool
907
+ */
908
+ export interface FindDeadCodeInput {
909
+ /** Directory to analyze */
910
+ path: string;
911
+ /** Include test files in analysis (default: false) */
912
+ includeTests?: boolean;
913
+ /** Check for unused exports (default: true) */
914
+ checkExports?: boolean;
915
+ /** Check for unused functions (default: true) */
916
+ checkFunctions?: boolean;
917
+ /** Check for unused variables (default: false) */
918
+ checkVariables?: boolean;
919
+ /** Maximum files to analyze (default: 100) */
920
+ maxFiles?: number;
921
+ }
922
+ /**
923
+ * A potentially dead code item
924
+ */
925
+ export interface DeadCodeItem {
926
+ /** Symbol name */
927
+ name: string;
928
+ /** File path */
929
+ path: string;
930
+ /** Line number */
931
+ line: number;
932
+ /** Kind of symbol */
933
+ kind: 'function' | 'class' | 'variable' | 'type' | 'interface' | 'enum' | 'export';
934
+ /** Is exported */
935
+ exported: boolean;
936
+ /** Confidence level */
937
+ confidence: 'high' | 'medium' | 'low';
938
+ /** Reason for flagging */
939
+ reason: string;
940
+ }
941
+ /**
942
+ * Output from findDeadCode tool
943
+ */
944
+ export interface FindDeadCodeResult {
945
+ /** Analyzed path */
946
+ path: string;
947
+ /** Potentially dead code items */
948
+ deadCode: DeadCodeItem[];
949
+ /** Statistics */
950
+ stats: {
951
+ filesAnalyzed: number;
952
+ totalExports: number;
953
+ unusedExports: number;
954
+ totalFunctions: number;
955
+ unusedFunctions: number;
956
+ totalVariables: number;
957
+ unusedVariables: number;
958
+ };
959
+ }
960
+ /**
961
+ * Input for findDuplicates tool
962
+ */
963
+ export interface FindDuplicatesInput {
964
+ /** Directory to analyze */
965
+ path: string;
966
+ /** Minimum lines for a duplicate (default: 6) */
967
+ minLines?: number;
968
+ /** Minimum tokens for a duplicate (default: 50) */
969
+ minTokens?: number;
970
+ /** Ignore identical files (default: true) */
971
+ ignoreIdenticalFiles?: boolean;
972
+ /** Maximum files to analyze (default: 100) */
973
+ maxFiles?: number;
974
+ }
975
+ /**
976
+ * A code location
977
+ */
978
+ export interface CodeLocation {
979
+ /** File path */
980
+ path: string;
981
+ /** Start line */
982
+ startLine: number;
983
+ /** End line */
984
+ endLine: number;
985
+ }
986
+ /**
987
+ * A group of duplicate code blocks
988
+ */
989
+ export interface DuplicateGroup {
990
+ /** Unique identifier for this group */
991
+ id: string;
992
+ /** Number of lines in duplicate */
993
+ lines: number;
994
+ /** Number of tokens in duplicate */
995
+ tokens: number;
996
+ /** Locations of duplicates */
997
+ locations: CodeLocation[];
998
+ /** Sample code (first few lines) */
999
+ sample: string;
1000
+ }
1001
+ /**
1002
+ * Output from findDuplicates tool
1003
+ */
1004
+ export interface FindDuplicatesResult {
1005
+ /** Analyzed path */
1006
+ path: string;
1007
+ /** Duplicate groups */
1008
+ duplicates: DuplicateGroup[];
1009
+ /** Statistics */
1010
+ stats: {
1011
+ filesAnalyzed: number;
1012
+ duplicateGroups: number;
1013
+ totalDuplicateLines: number;
1014
+ percentageDuplicate: number;
1015
+ };
1016
+ }
1017
+ /**
1018
+ * A pattern to search for
1019
+ */
1020
+ export interface CodePattern {
1021
+ /** Pattern name */
1022
+ name: string;
1023
+ /** Description */
1024
+ description: string;
1025
+ /** Pattern type */
1026
+ type: 'anti-pattern' | 'pattern' | 'smell';
1027
+ /** AST pattern or regex */
1028
+ matcher: string;
1029
+ /** Severity */
1030
+ severity: 'error' | 'warning' | 'info';
1031
+ }
1032
+ /**
1033
+ * Input for findPatterns tool
1034
+ */
1035
+ export interface FindPatternsInput {
1036
+ /** Directory to analyze */
1037
+ path: string;
1038
+ /** Patterns to search for (uses built-in if not specified) */
1039
+ patterns?: CodePattern[];
1040
+ /** Pattern categories to include */
1041
+ categories?: Array<'security' | 'performance' | 'maintainability' | 'all'>;
1042
+ /** Maximum files to analyze (default: 100) */
1043
+ maxFiles?: number;
1044
+ }
1045
+ /**
1046
+ * A pattern match
1047
+ */
1048
+ export interface PatternMatch {
1049
+ /** Pattern that matched */
1050
+ pattern: string;
1051
+ /** Pattern description */
1052
+ description: string;
1053
+ /** Severity */
1054
+ severity: 'error' | 'warning' | 'info';
1055
+ /** File path */
1056
+ path: string;
1057
+ /** Line number */
1058
+ line: number;
1059
+ /** Matched code snippet */
1060
+ snippet: string;
1061
+ /** Suggested fix (if available) */
1062
+ suggestion?: string;
1063
+ }
1064
+ /**
1065
+ * Output from findPatterns tool
1066
+ */
1067
+ export interface FindPatternsResult {
1068
+ /** Analyzed path */
1069
+ path: string;
1070
+ /** Pattern matches */
1071
+ matches: PatternMatch[];
1072
+ /** Statistics */
1073
+ stats: {
1074
+ filesAnalyzed: number;
1075
+ totalMatches: number;
1076
+ byPattern: Record<string, number>;
1077
+ bySeverity: {
1078
+ error: number;
1079
+ warning: number;
1080
+ info: number;
1081
+ };
1082
+ };
1083
+ }
1084
+ /**
1085
+ * Input for getSignature tool
1086
+ */
1087
+ export interface GetSignatureInput {
1088
+ /** File containing the symbol */
1089
+ path: string;
1090
+ /** Symbol name to get signature for */
1091
+ name: string;
1092
+ /** Line number for disambiguation (optional) */
1093
+ line?: number;
1094
+ /** Include full documentation (default: true) */
1095
+ includeDoc?: boolean;
1096
+ /** Expand type aliases (default: false) */
1097
+ expandTypes?: boolean;
1098
+ }
1099
+ /**
1100
+ * Detailed parameter information
1101
+ */
1102
+ export interface ParameterDetail {
1103
+ /** Parameter name */
1104
+ name: string;
1105
+ /** Type string */
1106
+ type: string;
1107
+ /** Expanded type (if expandTypes=true) */
1108
+ expandedType?: string;
1109
+ /** Is optional */
1110
+ optional: boolean;
1111
+ /** Default value (as string) */
1112
+ defaultValue?: string;
1113
+ /** JSDoc description */
1114
+ description?: string;
1115
+ /** Is rest parameter */
1116
+ rest?: boolean;
1117
+ }
1118
+ /**
1119
+ * Detailed type information
1120
+ */
1121
+ export interface TypeDetail {
1122
+ /** Type string */
1123
+ type: string;
1124
+ /** Expanded type */
1125
+ expandedType?: string;
1126
+ /** Is promise */
1127
+ isPromise: boolean;
1128
+ /** Is nullable */
1129
+ nullable: boolean;
1130
+ }
1131
+ /**
1132
+ * Generic parameter information
1133
+ */
1134
+ export interface GenericDetail {
1135
+ /** Generic name (T, K, etc.) */
1136
+ name: string;
1137
+ /** Constraint (extends X) */
1138
+ constraint?: string;
1139
+ /** Default type */
1140
+ default?: string;
1141
+ }
1142
+ /**
1143
+ * Documentation extracted from JSDoc/TSDoc
1144
+ */
1145
+ export interface Documentation {
1146
+ /** Summary (first paragraph) */
1147
+ summary: string;
1148
+ /** Full description */
1149
+ description?: string;
1150
+ /** @param tags */
1151
+ params?: Record<string, string>;
1152
+ /** @returns tag */
1153
+ returns?: string;
1154
+ /** @throws tags */
1155
+ throws?: string[];
1156
+ /** @example tags */
1157
+ examples?: string[];
1158
+ /** @see tags */
1159
+ see?: string[];
1160
+ /** Deprecation message from JSDoc tag */
1161
+ deprecatedMessage?: string;
1162
+ /** @since version */
1163
+ since?: string;
1164
+ }
1165
+ /**
1166
+ * Member signature (for classes/interfaces)
1167
+ */
1168
+ export interface MemberSignature {
1169
+ /** Member name */
1170
+ name: string;
1171
+ /** Member kind */
1172
+ kind: 'property' | 'method' | 'getter' | 'setter';
1173
+ /** Signature string */
1174
+ signature: string;
1175
+ /** Is optional */
1176
+ optional: boolean;
1177
+ /** Is readonly */
1178
+ readonly: boolean;
1179
+ /** Visibility */
1180
+ visibility?: 'public' | 'private' | 'protected';
1181
+ /** Is static */
1182
+ static?: boolean;
1183
+ }
1184
+ /**
1185
+ * Symbol kind for signature
1186
+ */
1187
+ export type SignatureSymbolKind = 'function' | 'method' | 'class' | 'interface' | 'type' | 'enum' | 'variable';
1188
+ /**
1189
+ * Output from getSignature tool
1190
+ */
1191
+ export interface GetSignatureResult {
1192
+ /** Symbol name */
1193
+ name: string;
1194
+ /** Symbol kind */
1195
+ kind: SignatureSymbolKind;
1196
+ /** File path */
1197
+ path: string;
1198
+ /** Line number */
1199
+ line: number;
1200
+ /** Full signature string */
1201
+ signature: string;
1202
+ /** Formatted signature (multi-line for complex types) */
1203
+ formattedSignature: string;
1204
+ /** Is exported */
1205
+ exported: boolean;
1206
+ /** For functions/methods: parameters */
1207
+ parameters?: ParameterDetail[];
1208
+ /** Return type */
1209
+ returnType?: TypeDetail;
1210
+ /** Generic parameters */
1211
+ generics?: GenericDetail[];
1212
+ /** Full documentation */
1213
+ documentation?: Documentation;
1214
+ /** For classes: constructor signature */
1215
+ constructorSignature?: string;
1216
+ /** For interfaces/classes: members */
1217
+ members?: MemberSignature[];
1218
+ }
1219
+ /**
1220
+ * Symbol kind for documentation extraction
1221
+ */
1222
+ export type DocumentationSymbolKind = 'function' | 'class' | 'interface' | 'type' | 'enum' | 'variable' | 'method' | 'property';
1223
+ /**
1224
+ * Input for getDocumentation tool
1225
+ */
1226
+ export interface GetDocumentationInput {
1227
+ /** File or directory to analyze */
1228
+ path: string;
1229
+ /** Recursive analysis for directories (default: false) */
1230
+ recursive?: boolean;
1231
+ /** Filter by symbol kinds */
1232
+ kinds?: DocumentationSymbolKind[];
1233
+ /** Only include exported symbols (default: false) */
1234
+ exportedOnly?: boolean;
1235
+ /** Only include symbols with documentation (default: true) */
1236
+ documentedOnly?: boolean;
1237
+ /** Maximum files to analyze (default: 50) */
1238
+ maxFiles?: number;
1239
+ /** Include private class members (default: false) */
1240
+ includePrivate?: boolean;
1241
+ }
1242
+ /**
1243
+ * Documented symbol information
1244
+ */
1245
+ export interface DocumentedSymbol {
1246
+ /** Symbol name */
1247
+ name: string;
1248
+ /** Symbol kind */
1249
+ kind: DocumentationSymbolKind;
1250
+ /** Line number */
1251
+ line: number;
1252
+ /** Is exported */
1253
+ exported: boolean;
1254
+ /** Signature string */
1255
+ signature: string;
1256
+ /** Documentation content */
1257
+ documentation: Documentation;
1258
+ /** Containing class/interface (for methods/properties) */
1259
+ container?: string;
1260
+ }
1261
+ /**
1262
+ * File documentation information
1263
+ */
1264
+ export interface FileDocumentation {
1265
+ /** File path */
1266
+ path: string;
1267
+ /** File-level documentation (module doc comment) */
1268
+ fileDoc?: Documentation;
1269
+ /** Documented symbols in this file */
1270
+ symbols: DocumentedSymbol[];
1271
+ /** Statistics */
1272
+ stats: {
1273
+ totalSymbols: number;
1274
+ documentedSymbols: number;
1275
+ undocumentedSymbols: number;
1276
+ coveragePercent: number;
1277
+ };
1278
+ }
1279
+ /**
1280
+ * Output from getDocumentation tool
1281
+ */
1282
+ export interface GetDocumentationResult {
1283
+ /** Analyzed path */
1284
+ path: string;
1285
+ /** Documentation by file */
1286
+ files: FileDocumentation[];
1287
+ /** Aggregated statistics */
1288
+ summary: {
1289
+ totalFiles: number;
1290
+ totalSymbols: number;
1291
+ documentedSymbols: number;
1292
+ undocumentedSymbols: number;
1293
+ coveragePercent: number;
1294
+ };
1295
+ /** Undocumented exported symbols (for coverage reports) */
1296
+ undocumentedExports?: Array<{
1297
+ name: string;
1298
+ kind: DocumentationSymbolKind;
1299
+ path: string;
1300
+ line: number;
1301
+ }>;
1302
+ }