codeviz 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,11 +1,737 @@
1
+ import { e as DirectoryNode, d as FileNode, g as SymbolNode, F as FileMetrics, b as SourceLocation, I as ImportEdge, C as CallEdge, i as CodeGraph, d3 as ViewMode, am as Theme, Z as ZoomLevel, r as ZoomLevelConfig, k as MapNode, cQ as IOverlayPort, cx as Overlay, d4 as SigmaTheme, p as CodeMap } from './useOverlayPort-dGxZQTue.mjs';
2
+ export { cl as AbsolutePosition, cL as AgentStatus, cw as AgentWidgetOverlay, cE as AgentWidgetOverlayInput, bM as AggregateNodeComponent, A as AggregateNodeData, c6 as AggregateReactFlowNodeData, ck as AnchorPoint, s as AnimationConfig, cI as AnnotationContentType, cu as AnnotationOverlay, cC as AnnotationOverlayInput, ct as BadgeOverlay, cB as BadgeOverlayInput, cH as BadgeSize, cG as BadgeVariant, cq as BaseOverlay, B as BoundingBox, bQ as BundledEdgeComponent, cb as BundledEdgeData, cS as CalculatedPosition, bP as CallEdgeComponent, ca as CallEdgeData, aU as ClusteringOptions, aV as ClusteringResult, bD as CodeMapComponent, t as CodeMapConfig, b$ as CodeMapProps, h as CodebaseMetadata, ag as ColorPalette, b3 as ComputeLayoutOptions, cr as CursorOverlay, cz as CursorOverlayInput, w as DEFAULT_ANIMATION_CONFIG, x as DEFAULT_CODEMAP_CONFIG, v as DEFAULT_LAYOUT_CONFIG, u as DEFAULT_ZOOM_LEVELS, aQ as DirectoryEdgeAttributes, aW as DirectoryForceOptions, aX as DirectoryForceResult, aT as DirectoryGraphResult, D as DirectoryMetrics, cv as DocumentOverlay, cD as DocumentOverlayInput, cK as DocumentStatus, cJ as DocumentType, aj as EdgeColors, cU as EdgePath, cn as EdgePosition, b0 as EdgeRoutingOptions, c3 as EdgeType, aR as EntityIdMapping, bJ as FileNodeComponent, c4 as FileNodeData, bE as Flow, c0 as FlowProps, a_ as ForcePositioningOptions, aP as GraphEdgeAttributes, aO as GraphNodeAttributes, aS as GraphologyConversionResult, aY as HierarchyOptions, aZ as HierarchyResult, cs as HighlightOverlay, cA as HighlightOverlayInput, cF as HighlightStyle, bO as ImportEdgeComponent, c9 as ImportEdgeData, L as LayoutConfig, cf as LayoutProgress, b4 as LayoutProgressCallback, o as MapEdge, n as MapEdgeType, j as MapNodeData, M as MapNodeType, m as MapScope, l as MapScopeData, cT as NodeBounds, ai as NodeColors, cm as NodePosition, c2 as NodeType, a$ as NoverlapOptions, cN as OverlayBatchUpdate, cO as OverlayClickHandler, ak as OverlayColors, cM as OverlayFilter, cP as OverlayHoverHandler, cy as OverlayInput, cY as OverlayLayer, cR as OverlayLayerProps, cW as OverlayPort, co as OverlayPosition, cp as OverlayType, a as Padding, c_ as PortalOverlayLayer, P as Position, af as RGBAColor, ae as RGBColor, cc as ReactFlowEdgeData, c8 as ReactFlowNodeData, d7 as RendererType, cZ as SVGOverlayLayer, ah as ScopeDepthColors, bK as ScopeNodeComponent, c7 as ScopeNodeData, c1 as ScopeNodeProps, d6 as SigmaEdgeAttributes, d9 as SigmaEdgeColors, da as SigmaHighlightConfig, db as SigmaLabelConfig, d5 as SigmaNodeAttributes, d8 as SigmaNodeColors, S as Size, f as SymbolKind, c as SymbolMetrics, bL as SymbolNodeComponent, c5 as SymbolNodeData, an as ThemeContextValue, bF as ThemeProvider, ao as ThemeProviderProps, al as UIColors, cg as UseLayoutOptions, ch as UseLayoutResult, ci as UseOverlayPortOptions, cj as UseOverlayPortResult, cV as ViewportTransform, b2 as ZoomLevelData, q as ZoomLevelName, b1 as ZoomPrecomputeOptions, be as assignClusterColors, W as boundingBoxFromCorners, _ as boundingBoxesOverlap, b6 as buildDirectoryGraph, bq as calculateNodeSize, c$ as calculateOverlayPosition, a4 as clampPosition, b5 as codeGraphToGraphology, bY as codeMapToReactFlowEdges, bX as codeMapToReactFlowNodes, bg as computeDirectoryForces, bt as computeEdges, bk as computeHierarchy, bC as computeLayout, bw as computeZoomLevels, V as createBoundingBox, cX as createOverlayPort, aM as createScopeColorGetter, aq as darkTheme, aB as darken, bb as detectCommunities, ab as detectLanguage, a2 as distance, bR as edgeTypes, a0 as expandBoundingBox, bW as formatLoc, bV as formatNumber, H as generateCallEdgeId, z as generateDirectoryId, y as generateFileId, G as generateImportEdgeId, aH as generateScopeDepthColors, E as generateSymbolId, d0 as getAnchorOffset, Q as getBasename, X as getBoundingBoxCenter, bm as getChildScopes, bd as getClusterStats, aJ as getContrastRatio, bZ as getDefaultExpandedScopes, au as getDefaultTheme, K as getDirectory, ba as getDirectoryConnectionWeight, bi as getDirectoryPosition, bv as getEdgeLabel, bu as getEdgesAtZoomLevel, b7 as getEntityId, O as getExtension, bS as getFileIcon, N as getFilename, b9 as getFilesInDirectory, ad as getIconName, aI as getLuminance, aa as getMediumFileLabel, bf as getNodeCluster, b8 as getNodeKey, bB as getNodeOpacityAtLevel, bA as getNodeSizeAtLevel, bc as getNodesInCluster, R as getParentDirectories, T as getPathDepth, bj as getPositionsAtDepth, bn as getRootScopes, bl as getScopeByDirectoryId, aG as getScopeDepthColor, a9 as getShortFileLabel, bT as getSymbolIcon, bU as getSymbolKindLabel, aL as getTextColorForBackground, ar as getTheme, at as getThemeIds, bz as getVisibleEdges, bx as getVisibleNodes, by as getVisibleScopes, a7 as getZoomLevel, b_ as getZoomLevelFromZoom, d1 as graphToScreen, av as hexToRgb, ay as hslToHex, ax as hslToRgb, ac as isCodeFile, Y as isPointInBoundingBox, a3 as lerp, ap as lightTheme, aA as lighten, U as matchesPattern, aN as mergeTheme, aD as mix, bN as nodeTypes, J as normalizePath, bh as normalizePositions, bp as positionAllNodes, bo as positionNodesInScope, as as registerTheme, bs as removeAllOverlaps, br as removeOverlapsInScope, aw as rgbToHex, az as rgbToHsl, aF as rgbaToCss, aC as saturate, a5 as scaleSize, d2 as screenToGraph, aK as shouldUseDarkText, a1 as shrinkBoundingBox, a8 as truncateLabel, a6 as uniformPadding, $ as unionBoundingBoxes, bH as useCurrentTheme, bI as useIsDarkTheme, cd as useLayout, ce as useOverlayPort, bG as useTheme, aE as withOpacity } from './useOverlayPort-dGxZQTue.mjs';
3
+ import * as react from 'react';
4
+ import { ReactNode } from 'react';
5
+ import Sigma from 'sigma';
6
+ import * as Graph from 'graphology';
7
+ import Graph__default from 'graphology';
8
+ import { Attributes } from 'graphology-types';
9
+ import Parser from 'tree-sitter';
10
+ import 'react/jsx-runtime';
11
+ import '@xyflow/react';
12
+ import 'lucide-react';
13
+
14
+ /**
15
+ * Directory scanner with gitignore support
16
+ * Recursively scans directories respecting .gitignore rules
17
+ */
18
+
19
+ /**
20
+ * Scanner configuration
21
+ */
22
+ interface ScannerConfig {
23
+ rootPath: string;
24
+ include?: string[];
25
+ exclude?: string[];
26
+ respectGitignore?: boolean;
27
+ maxDepth?: number;
28
+ maxFiles?: number;
29
+ }
30
+ /**
31
+ * Information about a skipped file
32
+ */
33
+ interface SkippedFile {
34
+ path: string;
35
+ reason: 'gitignore' | 'excluded' | 'not-code' | 'max-depth' | 'max-files' | 'permission' | 'binary' | 'too-large';
36
+ }
37
+ /**
38
+ * Scan result containing discovered files and directories
39
+ */
40
+ interface ScanResult {
41
+ directories: DirectoryNode[];
42
+ files: FileNode[];
43
+ skipped: SkippedFile[];
44
+ rootPath: string;
45
+ }
46
+ /**
47
+ * Convenience function to scan a directory
48
+ */
49
+ declare function scanDirectory(config: ScannerConfig): Promise<ScanResult>;
50
+
51
+ /**
52
+ * Symbol extraction module
53
+ * Coordinates extraction of symbols from source files using language-specific extractors
54
+ * Supports native high-quality extractors for TS/JS/Python and generic WASM-based extraction for other languages
55
+ */
56
+
57
+ /**
58
+ * Result of symbol extraction
59
+ */
60
+ interface SymbolExtractionResult {
61
+ symbols: SymbolNode[];
62
+ metrics: FileMetrics;
63
+ parseErrors?: string[];
64
+ }
65
+ /**
66
+ * Extract symbols from a file
67
+ * Uses native extractors for TS/JS/Python, falls back to generic WASM-based extraction for other languages
68
+ */
69
+ declare function extractSymbols(filePath: string, content: string, fileId: string): Promise<SymbolExtractionResult>;
70
+ /**
71
+ * Extract symbols from a file by reading it from disk
72
+ */
73
+ declare function extractSymbolsFromFile(filePath: string, fileId: string): Promise<SymbolExtractionResult>;
74
+
75
+ /**
76
+ * Import resolution module
77
+ * Handles resolution of import statements to actual file paths
78
+ */
79
+
80
+ /**
81
+ * Import information extracted from source
82
+ */
83
+ interface ImportInfo {
84
+ source: string;
85
+ importType: 'static' | 'dynamic' | 'type-only';
86
+ importedSymbols: string[];
87
+ location: SourceLocation;
88
+ }
89
+ /**
90
+ * Resolved import with edge information
91
+ */
92
+ interface ResolvedImport {
93
+ edge: ImportEdge;
94
+ resolved: boolean;
95
+ resolvedPath?: string;
96
+ }
97
+ /**
98
+ * File index for resolving imports
99
+ */
100
+ type FileIndex = Map<string, string>;
101
+ /**
102
+ * Extract imports from a source file
103
+ */
104
+ declare function extractImports(filePath: string, content: string): Promise<ImportInfo[]>;
105
+ /**
106
+ * Resolve an import to a file path and create an edge
107
+ */
108
+ declare function resolveImport(importInfo: ImportInfo, fromFileId: string, fromFilePath: string, rootPath: string, fileIndex: FileIndex): ResolvedImport;
109
+ /**
110
+ * Build a file index from file paths
111
+ */
112
+ declare function buildFileIndex(files: Array<{
113
+ id: string;
114
+ path: string;
115
+ }>): FileIndex;
116
+
117
+ /**
118
+ * Shared extraction utilities for all languages
119
+ * Contains common patterns and helper functions for AST traversal
120
+ */
121
+
122
+ /**
123
+ * Raw call information extracted from source
124
+ */
125
+ interface RawCall {
126
+ callerName: string;
127
+ calleeName: string;
128
+ callType: 'direct' | 'method' | 'constructor';
129
+ location: SourceLocation;
130
+ }
131
+
132
+ /**
133
+ * Call graph resolution module
134
+ * Handles extraction and resolution of function/method calls
135
+ */
136
+
137
+ /**
138
+ * Resolved call with edge information
139
+ */
140
+ interface ResolvedCall {
141
+ edge: CallEdge;
142
+ resolved: boolean;
143
+ }
144
+ /**
145
+ * Symbol index for resolving calls
146
+ */
147
+ type SymbolIndex = Map<string, SymbolNode>;
148
+ /**
149
+ * Extract calls from a source file
150
+ */
151
+ declare function extractCalls(filePath: string, content: string, symbols: SymbolNode[]): Promise<RawCall[]>;
152
+ /**
153
+ * Resolve all calls for a file
154
+ */
155
+ declare function resolveFileCalls(filePath: string, content: string, fileSymbols: SymbolNode[], globalSymbolIndex: SymbolIndex): Promise<ResolvedCall[]>;
156
+ /**
157
+ * Build a global symbol index from all files
158
+ */
159
+ declare function buildGlobalSymbolIndex(allSymbols: SymbolNode[]): SymbolIndex;
160
+
161
+ /**
162
+ * Language registry for tree-sitter grammars
163
+ * Handles lazy loading of language grammars
164
+ * Supports both native tree-sitter and WASM-based grammars
165
+ */
166
+ /**
167
+ * Language configuration
168
+ */
169
+ interface Language {
170
+ name: string;
171
+ extensions: string[];
172
+ grammar: unknown;
173
+ }
174
+ /**
175
+ * Lazy-loaded language definitions
176
+ */
177
+ interface LanguageLoader {
178
+ name: string;
179
+ extensions: string[];
180
+ load: () => Promise<unknown>;
181
+ }
182
+ /**
183
+ * Language registry with lazy loading
184
+ */
185
+ declare class LanguageRegistry {
186
+ private loaders;
187
+ private loaded;
188
+ private extensionMap;
189
+ constructor();
190
+ /**
191
+ * Register built-in language loaders
192
+ */
193
+ private registerBuiltinLanguages;
194
+ /**
195
+ * Register a language loader
196
+ */
197
+ registerLoader(loader: LanguageLoader): void;
198
+ /**
199
+ * Get language by name, loading if necessary
200
+ */
201
+ getLanguage(name: string): Promise<Language | null>;
202
+ /**
203
+ * Get language by file extension
204
+ */
205
+ getLanguageForExtension(extension: string): Promise<Language | null>;
206
+ /**
207
+ * Get language for a file path
208
+ */
209
+ getLanguageForFile(filePath: string): Promise<Language | null>;
210
+ /**
211
+ * Extract file extension from path
212
+ */
213
+ private getExtension;
214
+ /**
215
+ * Get list of supported languages
216
+ */
217
+ getSupportedLanguages(): string[];
218
+ /**
219
+ * Get list of supported extensions
220
+ */
221
+ getSupportedExtensions(): string[];
222
+ /**
223
+ * Check if a file extension is supported (native only)
224
+ */
225
+ isSupported(extension: string): boolean;
226
+ /**
227
+ * Check if a file extension is supported by WASM grammars
228
+ */
229
+ isWasmSupported(extension: string): boolean;
230
+ /**
231
+ * Check if a file is supported based on its path
232
+ * Considers both native tree-sitter and WASM-based grammars
233
+ */
234
+ isFileSupported(filePath: string): boolean;
235
+ }
236
+ declare function getLanguageRegistry(): LanguageRegistry;
237
+ /**
238
+ * Reset the registry (useful for testing)
239
+ */
240
+ declare function resetLanguageRegistry(): void;
241
+
242
+ /**
243
+ * Tree-sitter parser initialization and caching
244
+ * Provides lazy loading of language parsers and parsed tree caching
245
+ * Supports both native tree-sitter and WASM-based web-tree-sitter
246
+ */
247
+
248
+ /**
249
+ * Parsed tree with associated metadata
250
+ */
251
+ interface ParsedTree {
252
+ tree: Parser.Tree;
253
+ language: string;
254
+ filePath: string;
255
+ parseTime: number;
256
+ }
257
+ /**
258
+ * Parse error information
259
+ */
260
+ interface ParseError {
261
+ message: string;
262
+ filePath: string;
263
+ language?: string;
264
+ }
265
+ /**
266
+ * Parser manager that handles lazy loading and caching
267
+ */
268
+ declare class ParserManager {
269
+ private parsers;
270
+ private treeCache;
271
+ private maxCacheSize;
272
+ constructor(maxCacheSize?: number);
273
+ /**
274
+ * Get or create a parser for the specified language
275
+ */
276
+ getParser(language: Language): Promise<Parser>;
277
+ /**
278
+ * Parse source code and return the syntax tree
279
+ */
280
+ parse(filePath: string, content: string, language: Language): Promise<ParsedTree>;
281
+ /**
282
+ * Parse with error handling - returns result or error
283
+ */
284
+ safeParse(filePath: string, content: string, language: Language): Promise<{
285
+ result: ParsedTree;
286
+ } | {
287
+ error: ParseError;
288
+ }>;
289
+ /**
290
+ * Add parsed tree to cache with LRU eviction
291
+ */
292
+ private addToCache;
293
+ /**
294
+ * Clear the cache for a specific file (e.g., when file changes)
295
+ */
296
+ invalidate(filePath: string): void;
297
+ /**
298
+ * Clear all cached trees
299
+ */
300
+ clearCache(): void;
301
+ /**
302
+ * Get cache statistics
303
+ */
304
+ getCacheStats(): {
305
+ size: number;
306
+ maxSize: number;
307
+ };
308
+ }
309
+ declare function getParserManager(): ParserManager;
310
+ /**
311
+ * Reset the default parser manager (useful for testing)
312
+ */
313
+ declare function resetParserManager(): void;
314
+
315
+ /**
316
+ * CodeGraph Builder - Main orchestrator for codebase analysis
317
+ * Coordinates scanning, parsing, and graph building
318
+ */
319
+
320
+ /**
321
+ * Analyzer configuration
322
+ */
323
+ interface AnalyzerConfig {
324
+ rootPath: string;
325
+ include?: string[];
326
+ exclude?: string[];
327
+ respectGitignore?: boolean;
328
+ languages?: string[];
329
+ extractCalls?: boolean;
330
+ maxFiles?: number;
331
+ onProgress?: (progress: AnalysisProgress) => void;
332
+ }
333
+ /**
334
+ * Analysis progress information
335
+ */
336
+ interface AnalysisProgress {
337
+ phase: 'scanning' | 'parsing' | 'resolving';
338
+ current: number;
339
+ total: number;
340
+ currentFile?: string;
341
+ }
342
+ /**
343
+ * Analysis result with additional metadata
344
+ */
345
+ interface AnalysisResult {
346
+ graph: CodeGraph;
347
+ stats: AnalysisStats;
348
+ errors: AnalysisError[];
349
+ }
350
+ /**
351
+ * Analysis statistics
352
+ */
353
+ interface AnalysisStats {
354
+ totalFiles: number;
355
+ totalDirectories: number;
356
+ totalSymbols: number;
357
+ totalImports: number;
358
+ totalCalls: number;
359
+ resolvedImports: number;
360
+ resolvedCalls: number;
361
+ parseTime: number;
362
+ totalTime: number;
363
+ skippedFiles: number;
364
+ }
365
+ /**
366
+ * Analysis error information
367
+ */
368
+ interface AnalysisError {
369
+ file: string;
370
+ message: string;
371
+ phase: 'scan' | 'parse' | 'resolve';
372
+ }
373
+ /**
374
+ * Analyze a codebase and build a CodeGraph
375
+ */
376
+ declare function analyzeCodebase(config: AnalyzerConfig): Promise<AnalysisResult>;
377
+ /**
378
+ * Reset all caches (useful for testing or memory management)
379
+ */
380
+ declare function resetAnalyzer(): void;
381
+
382
+ /**
383
+ * Position options for the controls panel
384
+ */
385
+ type ControlsPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
386
+
387
+ /**
388
+ * Props for SigmaRenderer component
389
+ */
390
+ interface SigmaRendererProps {
391
+ /** Graphology graph to render */
392
+ graph: Graph__default | null;
393
+ /** View mode */
394
+ view: ViewMode;
395
+ /** CodeViz theme */
396
+ theme: Theme;
397
+ /** Current semantic zoom level (0-4) */
398
+ zoomLevel?: ZoomLevel;
399
+ /** Zoom level configuration for filtering */
400
+ zoomConfig?: ZoomLevelConfig | null;
401
+ /** Auto-run ForceAtlas2 layout on graph changes - default: false */
402
+ runLayout?: boolean;
403
+ onNodeClick?: (nodeId: string, data: MapNode) => void;
404
+ onNodeDoubleClick?: (nodeId: string) => void;
405
+ onNodeHover?: (nodeId: string | null) => void;
406
+ onEdgeClick?: (edgeId: string) => void;
407
+ onCanvasClick?: () => void;
408
+ selectedNodeId?: string | null;
409
+ onSelectedNodeChange?: (nodeId: string | null) => void;
410
+ highlightedNodeIds?: string[];
411
+ /** Overlay port for imperative overlay management */
412
+ overlayPort?: IOverlayPort;
413
+ /** Declarative overlays */
414
+ overlays?: Overlay[];
415
+ /** Throttle overlay position updates (ms) - default: 16 */
416
+ overlayUpdateThrottleMs?: number;
417
+ /** Overlay click handler */
418
+ onOverlayClick?: (id: string, overlay: Overlay) => void;
419
+ /** Overlay hover handler */
420
+ onOverlayHover?: (id: string, overlay: Overlay, isHovering: boolean) => void;
421
+ /** Show graph controls (zoom, reset, etc.) - default: true */
422
+ showControls?: boolean;
423
+ /** Position of graph controls */
424
+ controlsPosition?: ControlsPosition;
425
+ className?: string;
426
+ /** Disable the built-in error boundary - default: false */
427
+ disableErrorBoundary?: boolean;
428
+ /** Custom fallback UI for error boundary */
429
+ errorFallback?: ReactNode;
430
+ /** Callback when error occurs in the renderer */
431
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
432
+ }
433
+ /**
434
+ * Imperative handle for SigmaRenderer
435
+ */
436
+ interface SigmaRendererHandle {
437
+ zoomIn: () => void;
438
+ zoomOut: () => void;
439
+ resetView: () => void;
440
+ focusNode: (nodeId: string) => void;
441
+ fitToNodes: (nodeIds: string[]) => void;
442
+ getSigma: () => Sigma | null;
443
+ isLayoutRunning: boolean;
444
+ startLayout: () => void;
445
+ stopLayout: () => void;
446
+ }
447
+ /**
448
+ * Sigma renderer component
449
+ *
450
+ * @example
451
+ * ```tsx
452
+ * <SigmaRenderer
453
+ * graph={graphologyGraph}
454
+ * view="nexus"
455
+ * theme={darkTheme}
456
+ * onNodeClick={(id) => console.log('clicked', id)}
457
+ * />
458
+ * ```
459
+ */
460
+ declare const SigmaRenderer: react.ForwardRefExoticComponent<SigmaRendererProps & react.RefAttributes<SigmaRendererHandle>>;
461
+
462
+ /**
463
+ * Core React hook for Sigma.js integration
464
+ *
465
+ * Manages Sigma instance lifecycle, event handling, and camera controls
466
+ */
467
+
468
+ /**
469
+ * Options for useSigma hook
470
+ */
471
+ interface UseSigmaOptions {
472
+ /** Graphology graph to render */
473
+ graph: Graph__default | null;
474
+ /** Container element for Sigma */
475
+ container: HTMLDivElement | null;
476
+ /** CodeViz theme */
477
+ theme: Theme;
478
+ /** Current semantic zoom level (0-4) */
479
+ zoomLevel?: ZoomLevel;
480
+ /** Zoom level configuration for filtering */
481
+ zoomConfig?: ZoomLevelConfig | null;
482
+ /** Run ForceAtlas2 layout on graph changes - default: false */
483
+ runLayout?: boolean;
484
+ /** Node IDs to highlight (from overlay system) */
485
+ highlightedNodes?: string[];
486
+ onNodeClick?: (nodeId: string, attrs: Record<string, unknown>) => void;
487
+ onNodeDoubleClick?: (nodeId: string) => void;
488
+ onNodeHover?: (nodeId: string | null) => void;
489
+ onEdgeClick?: (edgeId: string) => void;
490
+ onStageClick?: () => void;
491
+ }
492
+ /**
493
+ * Return value from useSigma hook
494
+ */
495
+ interface UseSigmaReturn {
496
+ /** Sigma instance (null until initialized) */
497
+ sigma: Sigma | null;
498
+ zoomIn: () => void;
499
+ zoomOut: () => void;
500
+ resetView: () => void;
501
+ focusNode: (nodeId: string) => void;
502
+ /** Fit camera to show all specified nodes */
503
+ fitToNodes: (nodeIds: string[]) => void;
504
+ /** Whether ForceAtlas2 layout is currently running */
505
+ isLayoutRunning: boolean;
506
+ /** Start ForceAtlas2 layout */
507
+ startLayout: () => void;
508
+ /** Stop ForceAtlas2 layout */
509
+ stopLayout: () => void;
510
+ isReady: boolean;
511
+ }
512
+ declare function useSigma(options: UseSigmaOptions): UseSigmaReturn;
513
+
514
+ /**
515
+ * Sigma rendering constants and defaults
516
+ *
517
+ * Node colors, sizes, edge styles for Sigma visualization
518
+ */
519
+
520
+ /**
521
+ * Default dark Sigma theme
522
+ */
523
+ declare const DEFAULT_DARK_SIGMA_THEME: SigmaTheme;
524
+ /**
525
+ * Default light Sigma theme
526
+ */
527
+ declare const DEFAULT_LIGHT_SIGMA_THEME: SigmaTheme;
528
+ /**
529
+ * Default Sigma theme (dark)
530
+ */
531
+ declare const DEFAULT_SIGMA_THEME: SigmaTheme;
532
+ /**
533
+ * Node sizes by type
534
+ */
535
+ declare const NODE_SIZES: Record<string, number>;
536
+ /**
537
+ * Edge sizes by relationship type
538
+ */
539
+ declare const EDGE_SIZES: Record<string, number>;
540
+ /**
541
+ * Get scaled node size based on graph size
542
+ *
543
+ * @param baseSize - Base node size
544
+ * @param nodeCount - Total nodes in graph
545
+ * @returns Scaled size
546
+ */
547
+ declare function getScaledNodeSize(baseSize: number, nodeCount: number): number;
548
+ /**
549
+ * Get Sigma theme from CodeViz theme, with fallback to defaults
550
+ *
551
+ * @param theme - CodeViz theme
552
+ * @returns Sigma theme configuration
553
+ */
554
+ declare function getSigmaTheme(theme: Theme): SigmaTheme;
555
+
556
+ /**
557
+ * Graph adapters for converting CodeViz data structures to Sigma-compatible Graphology graphs
558
+ */
559
+
560
+ /**
561
+ * Convert CodeMap to Graphology graph for Structure view
562
+ * Preserves hierarchical layout with scopes as container regions
563
+ *
564
+ * @param codeMap - The CodeMap data from layout computation
565
+ * @param theme - Optional theme for colors
566
+ * @returns Graphology graph configured for Sigma rendering
567
+ */
568
+ declare function structureToGraphology(codeMap: CodeMap, theme?: Theme): Graph__default;
569
+ /**
570
+ * Options for nexusToGraphology conversion
571
+ */
572
+ interface NexusToGraphologyOptions {
573
+ /** Include symbol nodes (functions, classes, etc.) - default: false */
574
+ includeSymbols?: boolean;
575
+ /** Theme for colors */
576
+ theme?: Theme;
577
+ }
1
578
  /**
2
- * codeviz - Interactive 2D codebase visualization
579
+ * Convert CodeGraph to Graphology graph for Nexus view
580
+ * Creates flat relationship graph with code connections
581
+ *
582
+ * @param codeGraph - The CodeGraph from analysis
583
+ * @param options - Configuration options
584
+ * @returns Graphology graph configured for Sigma rendering
585
+ *
586
+ * @remarks
587
+ * Uses golden angle spiral positioning for directories, then positions
588
+ * children (files, optionally symbols) near their parents using BFS.
589
+ * This creates a good initial layout that ForceAtlas2 can refine quickly.
590
+ */
591
+ declare function nexusToGraphology(codeGraph: CodeGraph, options?: NexusToGraphologyOptions): Graph__default;
592
+
593
+ /**
594
+ * ForceAtlas2 configuration for Sigma graph layout
595
+ *
596
+ * Settings are dynamically scaled based on graph size for optimal performance
597
+ * Based on GitNexus implementation patterns
598
+ */
599
+
600
+ /**
601
+ * ForceAtlas2 settings type
602
+ */
603
+ interface FA2Settings {
604
+ gravity: number;
605
+ scalingRatio: number;
606
+ slowDown: number;
607
+ barnesHutOptimize: boolean;
608
+ barnesHutTheta: number;
609
+ strongGravityMode: boolean;
610
+ outboundAttractionDistribution: boolean;
611
+ linLogMode: boolean;
612
+ adjustSizes: boolean;
613
+ edgeWeightInfluence: number;
614
+ }
615
+ /**
616
+ * Get ForceAtlas2 settings dynamically scaled by node count
617
+ *
618
+ * @param nodeCount - Number of nodes in the graph
619
+ * @returns Optimized FA2 settings for the graph size
620
+ *
621
+ * @remarks
622
+ * This is a placeholder - full implementation in Phase 3
623
+ */
624
+ declare function getFA2Settings(nodeCount: number): FA2Settings;
625
+ /**
626
+ * Get layout duration based on graph size
627
+ *
628
+ * @param nodeCount - Number of nodes in the graph
629
+ * @returns Duration in milliseconds for ForceAtlas2 to run
630
+ */
631
+ declare function getLayoutDuration(nodeCount: number): number;
632
+ /**
633
+ * Get node mass based on type for ForceAtlas2
634
+ * Higher mass nodes spread apart and pull their children
635
+ *
636
+ * @param nodeType - Type of the node
637
+ * @param nodeCount - Total nodes in graph (affects scaling)
638
+ * @returns Mass value for the node
639
+ */
640
+ declare function getNodeMass(nodeType: 'directory' | 'file' | 'symbol' | 'aggregate', nodeCount: number): number;
641
+
642
+ /**
643
+ * Initial positioning algorithms for Sigma graph layout
644
+ *
645
+ * Uses golden angle spiral for structural nodes to provide
646
+ * a good starting point for ForceAtlas2
647
+ */
648
+
649
+ /**
650
+ * Options for initial position assignment
651
+ */
652
+ interface InitialPositionOptions {
653
+ /** Spread factor for structural nodes */
654
+ structuralSpread?: number;
655
+ /** Jitter factor for child nodes */
656
+ childJitter?: number;
657
+ }
658
+ /**
659
+ * Assign initial positions to graph nodes using golden angle spiral
660
+ *
661
+ * Structural nodes (directories) are spread in a spiral pattern,
662
+ * while child nodes are positioned near their parents with jitter.
663
+ *
664
+ * @param graph - Graphology graph to position
665
+ * @param options - Positioning options
666
+ *
667
+ * @remarks
668
+ * This is a placeholder - full implementation in Phase 3
669
+ */
670
+ declare function assignInitialPositions(graph: Graph__default, options?: InitialPositionOptions): void;
671
+
672
+ /**
673
+ * State used by reducers to compute appearance
674
+ */
675
+ interface ReducerState {
676
+ /** Currently selected node ID */
677
+ selectedNode: string | null;
678
+ /** Set of highlighted node IDs (from search/AI) */
679
+ highlightedNodes: Set<string>;
680
+ /** Neighbor node IDs of selected node */
681
+ neighborNodes: Set<string>;
682
+ }
683
+ /**
684
+ * Extended state with zoom level for visibility filtering
685
+ */
686
+ interface ZoomReducerState extends ReducerState {
687
+ /** Current semantic zoom level (0-4) */
688
+ zoomLevel: ZoomLevel;
689
+ /** Configuration for current zoom level (null to disable filtering) */
690
+ zoomConfig: ZoomLevelConfig | null;
691
+ }
692
+ /**
693
+ * Dim a hex color by mixing it toward a dark background
694
+ *
695
+ * @param hex - Hex color string
696
+ * @param amount - Amount to dim (0-1, lower = more dim)
697
+ * @returns Dimmed hex color
698
+ */
699
+ declare function dimColor(hex: string, amount: number): string;
700
+ /**
701
+ * Brighten a hex color
702
+ *
703
+ * @param hex - Hex color string
704
+ * @param factor - Brightening factor (>1 = brighter)
705
+ * @returns Brightened hex color
706
+ */
707
+ declare function brightenColor(hex: string, factor: number): string;
708
+ /**
709
+ * Create a node reducer for Sigma with zoom-based visibility
710
+ *
711
+ * @param state - Current reducer state (with optional zoom level)
712
+ * @param theme - Sigma theme configuration
713
+ * @returns Node reducer function
714
+ */
715
+ declare function createNodeReducer(state: ReducerState | ZoomReducerState, theme: SigmaTheme): (node: string, data: Attributes) => Attributes;
716
+ /**
717
+ * Create an edge reducer for Sigma with zoom-based visibility
718
+ *
719
+ * @param state - Current reducer state (with optional zoom level)
720
+ * @param theme - Sigma theme configuration
721
+ * @param graph - Optional graph to look up edge endpoints for selection highlighting
722
+ * @returns Edge reducer function
723
+ *
724
+ * @remarks
725
+ * The returned function signature matches Sigma's expected edge reducer format.
726
+ * For selection/highlight logic that needs source/target info, pass the graph parameter.
727
+ */
728
+ declare function createEdgeReducer(state: ReducerState | ZoomReducerState, theme: SigmaTheme, graph?: Graph.default): (edge: string, data: Attributes) => Attributes;
729
+
730
+ /**
731
+ * CodeViz - Interactive 2D codebase visualization with hierarchical semantic zoom
3
732
  *
4
733
  * @packageDocumentation
5
734
  */
6
735
  declare const VERSION = "0.1.0";
7
- interface CodeVizConfig {
8
- }
9
- declare function createCodeViz(_config?: CodeVizConfig): void;
10
736
 
11
- export { type CodeVizConfig, VERSION, createCodeViz };
737
+ export { type AnalysisError, type AnalysisProgress, type AnalysisResult, type AnalysisStats, type AnalyzerConfig, CallEdge, CodeGraph, CodeMap, DEFAULT_DARK_SIGMA_THEME, DEFAULT_LIGHT_SIGMA_THEME, DEFAULT_SIGMA_THEME, DirectoryNode, EDGE_SIZES, type FA2Settings, FileMetrics, FileNode, IOverlayPort, ImportEdge, type InitialPositionOptions, MapNode, NODE_SIZES, Overlay, type ReducerState, type ScanResult, type ScannerConfig, SigmaRenderer, type SigmaRendererHandle, type SigmaRendererProps, SigmaTheme, SourceLocation, type SymbolExtractionResult, SymbolNode, Theme, type UseSigmaOptions, type UseSigmaReturn, VERSION, ViewMode, ZoomLevel, ZoomLevelConfig, analyzeCodebase, assignInitialPositions, brightenColor, buildFileIndex, buildGlobalSymbolIndex, createEdgeReducer, createNodeReducer, dimColor, extractCalls, extractImports, extractSymbols, extractSymbolsFromFile, getFA2Settings, getLanguageRegistry, getLayoutDuration, getNodeMass, getParserManager, getScaledNodeSize, getSigmaTheme, nexusToGraphology, resetAnalyzer, resetLanguageRegistry, resetParserManager, resolveFileCalls, resolveImport, scanDirectory, structureToGraphology, useSigma };