infiniloom-node 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -221,6 +221,105 @@ for (const finding of findings) {
221
221
  }
222
222
  ```
223
223
 
224
+ ### Call Graph API
225
+
226
+ Query caller/callee relationships and navigate your codebase programmatically.
227
+
228
+ #### `buildIndex(path: string, options?: IndexOptions): IndexStatus`
229
+
230
+ Build or update the symbol index for a repository (required for call graph queries).
231
+
232
+ ```javascript
233
+ const { buildIndex } = require('infiniloom-node');
234
+
235
+ const status = buildIndex('./my-repo');
236
+ console.log(`Indexed ${status.symbolCount} symbols`);
237
+ ```
238
+
239
+ #### `findSymbol(path: string, name: string): SymbolInfo[]`
240
+
241
+ Find symbols by name.
242
+
243
+ ```javascript
244
+ const { findSymbol, buildIndex } = require('infiniloom-node');
245
+
246
+ buildIndex('./my-repo');
247
+ const symbols = findSymbol('./my-repo', 'processRequest');
248
+ for (const s of symbols) {
249
+ console.log(`${s.name} (${s.kind}) at ${s.file}:${s.line}`);
250
+ }
251
+ ```
252
+
253
+ #### `getCallers(path: string, symbolName: string): SymbolInfo[]`
254
+
255
+ Get all functions/methods that call the target symbol.
256
+
257
+ ```javascript
258
+ const { getCallers, buildIndex } = require('infiniloom-node');
259
+
260
+ buildIndex('./my-repo');
261
+ const callers = getCallers('./my-repo', 'authenticate');
262
+ console.log(`authenticate is called by ${callers.length} functions`);
263
+ for (const c of callers) {
264
+ console.log(` ${c.name} at ${c.file}:${c.line}`);
265
+ }
266
+ ```
267
+
268
+ #### `getCallees(path: string, symbolName: string): SymbolInfo[]`
269
+
270
+ Get all functions/methods that the target symbol calls.
271
+
272
+ ```javascript
273
+ const { getCallees, buildIndex } = require('infiniloom-node');
274
+
275
+ buildIndex('./my-repo');
276
+ const callees = getCallees('./my-repo', 'main');
277
+ console.log(`main calls ${callees.length} functions`);
278
+ ```
279
+
280
+ #### `getReferences(path: string, symbolName: string): ReferenceInfo[]`
281
+
282
+ Get all references to a symbol (calls, imports, inheritance).
283
+
284
+ ```javascript
285
+ const { getReferences, buildIndex } = require('infiniloom-node');
286
+
287
+ buildIndex('./my-repo');
288
+ const refs = getReferences('./my-repo', 'UserService');
289
+ for (const r of refs) {
290
+ console.log(`${r.kind}: ${r.symbol.name} at ${r.symbol.file}:${r.symbol.line}`);
291
+ }
292
+ ```
293
+
294
+ #### `getCallGraph(path: string, options?: CallGraphOptions): CallGraph`
295
+
296
+ Get the complete call graph with all symbols and call relationships.
297
+
298
+ ```javascript
299
+ const { getCallGraph, buildIndex } = require('infiniloom-node');
300
+
301
+ buildIndex('./my-repo');
302
+ const graph = getCallGraph('./my-repo');
303
+ console.log(`${graph.stats.totalSymbols} symbols, ${graph.stats.totalCalls} calls`);
304
+
305
+ // Find most called functions
306
+ const callCounts = new Map();
307
+ for (const edge of graph.edges) {
308
+ callCounts.set(edge.callee, (callCounts.get(edge.callee) || 0) + 1);
309
+ }
310
+ const sorted = [...callCounts.entries()].sort((a, b) => b[1] - a[1]);
311
+ console.log('Most called:', sorted.slice(0, 5));
312
+ ```
313
+
314
+ #### Async versions
315
+
316
+ All call graph functions have async versions:
317
+ - `findSymbolAsync(path, name)`
318
+ - `getCallersAsync(path, symbolName)`
319
+ - `getCalleesAsync(path, symbolName)`
320
+ - `getReferencesAsync(path, symbolName)`
321
+ - `getCallGraphAsync(path, options)`
322
+
224
323
  #### `isGitRepo(path: string): boolean`
225
324
 
226
325
  Check if a path is a git repository.
package/index.d.ts CHANGED
@@ -670,6 +670,236 @@ export declare function buildIndex(path: string, options?: IndexOptions | undefi
670
670
  */
671
671
  export declare function indexStatus(path: string): IndexStatus
672
672
 
673
+ // ============================================================================
674
+ // Call Graph API - Query symbol relationships
675
+ // ============================================================================
676
+
677
+ /** Information about a symbol in the call graph */
678
+ export interface SymbolInfo {
679
+ /** Symbol ID */
680
+ id: number
681
+ /** Symbol name */
682
+ name: string
683
+ /** Symbol kind (function, class, method, etc.) */
684
+ kind: string
685
+ /** File path containing the symbol */
686
+ file: string
687
+ /** Start line number */
688
+ line: number
689
+ /** End line number */
690
+ endLine: number
691
+ /** Function/method signature */
692
+ signature?: string
693
+ /** Visibility (public, private, etc.) */
694
+ visibility: string
695
+ }
696
+
697
+ /** A reference to a symbol with context */
698
+ export interface ReferenceInfo {
699
+ /** Symbol making the reference */
700
+ symbol: SymbolInfo
701
+ /** Reference kind (call, import, inherit, implement) */
702
+ kind: string
703
+ }
704
+
705
+ /** An edge in the call graph */
706
+ export interface CallGraphEdge {
707
+ /** Caller symbol ID */
708
+ callerId: number
709
+ /** Callee symbol ID */
710
+ calleeId: number
711
+ /** Caller symbol name */
712
+ caller: string
713
+ /** Callee symbol name */
714
+ callee: string
715
+ /** File containing the call site */
716
+ file: string
717
+ /** Line number of the call */
718
+ line: number
719
+ }
720
+
721
+ /** Call graph statistics */
722
+ export interface CallGraphStats {
723
+ /** Total number of symbols */
724
+ totalSymbols: number
725
+ /** Total number of call edges */
726
+ totalCalls: number
727
+ /** Number of functions/methods */
728
+ functions: number
729
+ /** Number of classes/structs */
730
+ classes: number
731
+ }
732
+
733
+ /** Complete call graph with nodes and edges */
734
+ export interface CallGraph {
735
+ /** All symbols (nodes) */
736
+ nodes: Array<SymbolInfo>
737
+ /** Call relationships (edges) */
738
+ edges: Array<CallGraphEdge>
739
+ /** Summary statistics */
740
+ stats: CallGraphStats
741
+ }
742
+
743
+ /** Options for call graph queries */
744
+ export interface CallGraphOptions {
745
+ /** Maximum number of nodes to return (default: unlimited) */
746
+ maxNodes?: number
747
+ /** Maximum number of edges to return (default: unlimited) */
748
+ maxEdges?: number
749
+ }
750
+
751
+ /**
752
+ * Find a symbol by name
753
+ *
754
+ * Searches the index for all symbols matching the given name.
755
+ * Requires an index to be built first (use buildIndex).
756
+ *
757
+ * # Arguments
758
+ * * `path` - Path to repository root
759
+ * * `name` - Symbol name to search for
760
+ *
761
+ * # Returns
762
+ * Array of matching symbols
763
+ *
764
+ * # Example
765
+ * ```javascript
766
+ * const { findSymbol, buildIndex } = require('infiniloom-node');
767
+ *
768
+ * buildIndex('./my-repo');
769
+ * const symbols = findSymbol('./my-repo', 'processRequest');
770
+ * console.log(`Found ${symbols.length} symbols named processRequest`);
771
+ * ```
772
+ */
773
+ export declare function findSymbol(path: string, name: string): Array<SymbolInfo>
774
+
775
+ /**
776
+ * Get all callers of a symbol
777
+ *
778
+ * Returns symbols that call any symbol with the given name.
779
+ * Requires an index to be built first (use buildIndex).
780
+ *
781
+ * # Arguments
782
+ * * `path` - Path to repository root
783
+ * * `symbolName` - Name of the symbol to find callers for
784
+ *
785
+ * # Returns
786
+ * Array of symbols that call the target symbol
787
+ *
788
+ * # Example
789
+ * ```javascript
790
+ * const { getCallers, buildIndex } = require('infiniloom-node');
791
+ *
792
+ * buildIndex('./my-repo');
793
+ * const callers = getCallers('./my-repo', 'authenticate');
794
+ * console.log(`authenticate is called by ${callers.length} functions`);
795
+ * for (const c of callers) {
796
+ * console.log(` ${c.name} at ${c.file}:${c.line}`);
797
+ * }
798
+ * ```
799
+ */
800
+ export declare function getCallers(path: string, symbolName: string): Array<SymbolInfo>
801
+
802
+ /**
803
+ * Get all callees of a symbol
804
+ *
805
+ * Returns symbols that are called by any symbol with the given name.
806
+ * Requires an index to be built first (use buildIndex).
807
+ *
808
+ * # Arguments
809
+ * * `path` - Path to repository root
810
+ * * `symbolName` - Name of the symbol to find callees for
811
+ *
812
+ * # Returns
813
+ * Array of symbols that the target symbol calls
814
+ *
815
+ * # Example
816
+ * ```javascript
817
+ * const { getCallees, buildIndex } = require('infiniloom-node');
818
+ *
819
+ * buildIndex('./my-repo');
820
+ * const callees = getCallees('./my-repo', 'main');
821
+ * console.log(`main calls ${callees.length} functions`);
822
+ * for (const c of callees) {
823
+ * console.log(` ${c.name} at ${c.file}:${c.line}`);
824
+ * }
825
+ * ```
826
+ */
827
+ export declare function getCallees(path: string, symbolName: string): Array<SymbolInfo>
828
+
829
+ /**
830
+ * Get all references to a symbol
831
+ *
832
+ * Returns all locations where a symbol is referenced (calls, imports, inheritance).
833
+ * Requires an index to be built first (use buildIndex).
834
+ *
835
+ * # Arguments
836
+ * * `path` - Path to repository root
837
+ * * `symbolName` - Name of the symbol to find references for
838
+ *
839
+ * # Returns
840
+ * Array of reference information including the referencing symbol and kind
841
+ *
842
+ * # Example
843
+ * ```javascript
844
+ * const { getReferences, buildIndex } = require('infiniloom-node');
845
+ *
846
+ * buildIndex('./my-repo');
847
+ * const refs = getReferences('./my-repo', 'UserService');
848
+ * console.log(`UserService is referenced ${refs.length} times`);
849
+ * for (const r of refs) {
850
+ * console.log(` ${r.kind}: ${r.symbol.name} at ${r.symbol.file}:${r.symbol.line}`);
851
+ * }
852
+ * ```
853
+ */
854
+ export declare function getReferences(path: string, symbolName: string): Array<ReferenceInfo>
855
+
856
+ /**
857
+ * Get the complete call graph
858
+ *
859
+ * Returns all symbols and their call relationships.
860
+ * Requires an index to be built first (use buildIndex).
861
+ *
862
+ * # Arguments
863
+ * * `path` - Path to repository root
864
+ * * `options` - Optional filtering options
865
+ *
866
+ * # Returns
867
+ * Call graph with nodes (symbols), edges (calls), and statistics
868
+ *
869
+ * # Example
870
+ * ```javascript
871
+ * const { getCallGraph, buildIndex } = require('infiniloom-node');
872
+ *
873
+ * buildIndex('./my-repo');
874
+ * const graph = getCallGraph('./my-repo');
875
+ * console.log(`Call graph: ${graph.stats.totalSymbols} symbols, ${graph.stats.totalCalls} calls`);
876
+ *
877
+ * // Find most called functions
878
+ * const callCounts = new Map();
879
+ * for (const edge of graph.edges) {
880
+ * callCounts.set(edge.callee, (callCounts.get(edge.callee) || 0) + 1);
881
+ * }
882
+ * const sorted = [...callCounts.entries()].sort((a, b) => b[1] - a[1]);
883
+ * console.log('Most called functions:', sorted.slice(0, 10));
884
+ * ```
885
+ */
886
+ export declare function getCallGraph(path: string, options?: CallGraphOptions | undefined | null): CallGraph
887
+
888
+ /** Async version of findSymbol */
889
+ export declare function findSymbolAsync(path: string, name: string): Promise<Array<SymbolInfo>>
890
+
891
+ /** Async version of getCallers */
892
+ export declare function getCallersAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
893
+
894
+ /** Async version of getCallees */
895
+ export declare function getCalleesAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
896
+
897
+ /** Async version of getReferences */
898
+ export declare function getReferencesAsync(path: string, symbolName: string): Promise<Array<ReferenceInfo>>
899
+
900
+ /** Async version of getCallGraph */
901
+ export declare function getCallGraphAsync(path: string, options?: CallGraphOptions | undefined | null): Promise<CallGraph>
902
+
673
903
  // ============================================================================
674
904
  // Chunk API - Split repositories into manageable pieces
675
905
  // ============================================================================
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infiniloom-node",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "Node.js bindings for infiniloom - Repository context engine for LLMs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",