infiniloom-node 0.4.3 → 0.4.4

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/index.d.ts CHANGED
@@ -258,30 +258,30 @@ export interface GitBlameLine {
258
258
  /** Line number (1-indexed) */
259
259
  lineNumber: number
260
260
  }
261
- /** Diff line information for structured diff parsing */
261
+ /** A single line change within a diff hunk */
262
262
  export interface GitDiffLine {
263
- /** Change type: "add", "remove", or "context" */
263
+ /** Type of change: "add", "remove", or "context" */
264
264
  changeType: string
265
- /** Line number in old file (for remove/context lines) */
265
+ /** Line number in the old file (null for additions) */
266
266
  oldLine?: number
267
- /** Line number in new file (for add/context lines) */
267
+ /** Line number in the new file (null for deletions) */
268
268
  newLine?: number
269
- /** Line content (without +/- prefix) */
269
+ /** The actual line content (without +/- prefix) */
270
270
  content: string
271
271
  }
272
- /** Diff hunk information for structured diff parsing */
272
+ /** A diff hunk representing a contiguous block of changes */
273
273
  export interface GitDiffHunk {
274
- /** Starting line in old file */
274
+ /** Starting line in the old file */
275
275
  oldStart: number
276
- /** Number of lines in old file */
276
+ /** Number of lines in the old file section */
277
277
  oldCount: number
278
- /** Starting line in new file */
278
+ /** Starting line in the new file */
279
279
  newStart: number
280
- /** Number of lines in new file */
280
+ /** Number of lines in the new file section */
281
281
  newCount: number
282
- /** Hunk header (e.g., "@@ -1,5 +1,6 @@ function name") */
282
+ /** Header line (e.g., "@@ -1,5 +1,7 @@ function name") */
283
283
  header: string
284
- /** Lines in this hunk */
284
+ /** Individual line changes within this hunk */
285
285
  lines: Array<GitDiffLine>
286
286
  }
287
287
  /** Security finding information */
@@ -317,363 +317,74 @@ export interface SecurityFinding {
317
317
  * ```
318
318
  */
319
319
  export declare function scanSecurity(path: string): Array<SecurityFinding>
320
- /** Infiniloom class for advanced usage */
321
- export declare class Infiniloom {
322
- /**
323
- * Create a new Infiniloom instance
324
- *
325
- * # Arguments
326
- * * `path` - Path to repository root
327
- * * `model` - Optional model name (default: "claude")
328
- */
329
- constructor(path: string, model?: string | undefined | null)
330
- /** Get repository statistics (Bug #4 fix - consistent with scan() function) */
331
- getStats(): ScanStats
332
- /**
333
- * Generate a repository map
334
- *
335
- * # Arguments
336
- * * `budget` - Token budget (default: 2000)
337
- * * `max_symbols` - Maximum symbols (default: 50)
338
- */
339
- generateMap(budget?: number | undefined | null, maxSymbols?: number | undefined | null): string
340
- /** Pack repository with specific options */
341
- pack(options?: PackOptions | undefined | null): string
342
- /** Check for security issues (Bug #8 fix - now returns structured findings) */
343
- securityScan(): Array<SecurityFinding>
344
- /** Check for security issues (legacy format, returns formatted strings) */
345
- securityScanFormatted(): Array<string>
320
+ /** Options for building an index */
321
+ export interface IndexOptions {
322
+ /** Force full rebuild even if index exists */
323
+ force?: boolean
324
+ /** Include test files in index */
325
+ includeTests?: boolean
326
+ /** Maximum file size to index (bytes) */
327
+ maxFileSize?: number
328
+ }
329
+ /** Index status information */
330
+ export interface IndexStatus {
331
+ /** Whether an index exists */
332
+ exists: boolean
333
+ /** Number of files indexed */
334
+ fileCount: number
335
+ /** Number of symbols indexed */
336
+ symbolCount: number
337
+ /** Last build timestamp (ISO 8601) */
338
+ lastBuilt?: string
339
+ /** Index version */
340
+ version?: string
346
341
  }
347
342
  /**
348
- * Git repository wrapper for Node.js
343
+ * Build or update the symbol index for a repository
349
344
  *
350
- * Provides access to git operations like status, diff, log, and blame.
345
+ * The index enables fast diff-to-context lookups and impact analysis.
346
+ *
347
+ * # Arguments
348
+ * * `path` - Path to repository root
349
+ * * `options` - Optional index build options
350
+ *
351
+ * # Returns
352
+ * Index status after building
351
353
  *
352
354
  * # Example
353
355
  * ```javascript
354
- * const { GitRepo } = require('infiniloom-node');
356
+ * const { buildIndex } = require('infiniloom-node');
355
357
  *
356
- * const repo = new GitRepo('./my-project');
357
- * console.log(`Branch: ${repo.currentBranch()}`);
358
- * console.log(`Commit: ${repo.currentCommit()}`);
358
+ * const status = buildIndex('./my-repo');
359
+ * console.log(`Indexed ${status.symbolCount} symbols`);
359
360
  *
360
- * for (const file of repo.status()) {
361
- * console.log(`${file.status}: ${file.path}`);
362
- * }
363
- * ```
364
- */
365
- export declare class GitRepo {
366
- /**
367
- * Open a git repository
368
- *
369
- * # Arguments
370
- * * `path` - Path to the repository
371
- *
372
- * # Throws
373
- * Error if path is not a git repository
374
- */
375
- constructor(path: string)
376
- /**
377
- * Get the current branch name
378
- *
379
- * # Returns
380
- * Current branch name (e.g., "main", "feature/xyz")
381
- */
382
- currentBranch(): string
383
- /**
384
- * Get the current commit hash
385
- *
386
- * # Returns
387
- * Full SHA-1 hash of HEAD commit
388
- */
389
- currentCommit(): string
390
- /**
391
- * Get working tree status
392
- *
393
- * Returns both staged and unstaged changes.
394
- *
395
- * # Returns
396
- * Array of file status objects
397
- */
398
- status(): Array<GitFileStatus>
399
- /**
400
- * Get files changed between two commits
401
- *
402
- * # Arguments
403
- * * `from_ref` - Starting commit/branch/tag
404
- * * `to_ref` - Ending commit/branch/tag
405
- *
406
- * # Returns
407
- * Array of changed files with diff stats
408
- */
409
- diffFiles(fromRef: string, toRef: string): Array<GitChangedFile>
410
- /**
411
- * Get recent commits
412
- *
413
- * # Arguments
414
- * * `count` - Maximum number of commits to return (default: 10)
415
- *
416
- * # Returns
417
- * Array of commit objects
418
- */
419
- log(count?: number | undefined | null): Array<GitCommit>
420
- /**
421
- * Get commits that modified a specific file
422
- *
423
- * # Arguments
424
- * * `path` - File path (relative to repo root)
425
- * * `count` - Maximum number of commits to return (default: 10)
426
- *
427
- * # Returns
428
- * Array of commits that modified the file
429
- */
430
- fileLog(path: string, count?: number | undefined | null): Array<GitCommit>
431
- /**
432
- * Get blame information for a file
433
- *
434
- * # Arguments
435
- * * `path` - File path (relative to repo root)
436
- *
437
- * # Returns
438
- * Array of blame line objects
439
- */
440
- blame(path: string): Array<GitBlameLine>
441
- /**
442
- * Get list of files tracked by git
443
- *
444
- * # Returns
445
- * Array of file paths tracked by git
446
- */
447
- lsFiles(): Array<string>
448
- /**
449
- * Get diff content between two commits for a file
450
- *
451
- * # Arguments
452
- * * `from_ref` - Starting commit/branch/tag
453
- * * `to_ref` - Ending commit/branch/tag
454
- * * `path` - File path (relative to repo root)
455
- *
456
- * # Returns
457
- * Unified diff content as string
458
- */
459
- diffContent(fromRef: string, toRef: string, path: string): string
460
- /**
461
- * Get diff content for uncommitted changes in a file
462
- *
463
- * Includes both staged and unstaged changes compared to HEAD.
464
- *
465
- * # Arguments
466
- * * `path` - File path (relative to repo root)
467
- *
468
- * # Returns
469
- * Unified diff content as string
470
- */
471
- uncommittedDiff(path: string): string
472
- /**
473
- * Get diff for all uncommitted changes
474
- *
475
- * Returns combined diff for all changed files.
476
- *
477
- * # Returns
478
- * Unified diff content as string
479
- */
480
- allUncommittedDiffs(): string
481
- /**
482
- * Check if a file has uncommitted changes
483
- *
484
- * # Arguments
485
- * * `path` - File path (relative to repo root)
486
- *
487
- * # Returns
488
- * True if file has changes, false otherwise
489
- */
490
- hasChanges(path: string): boolean
491
- /**
492
- * Get the last commit that modified a file
493
- *
494
- * # Arguments
495
- * * `path` - File path (relative to repo root)
496
- *
497
- * # Returns
498
- * Commit information object
499
- */
500
- lastModifiedCommit(path: string): GitCommit
501
- /**
502
- * Get file change frequency in recent days
503
- *
504
- * Useful for determining file importance based on recent activity.
505
- *
506
- * # Arguments
507
- * * `path` - File path (relative to repo root)
508
- * * `days` - Number of days to look back (default: 30)
509
- *
510
- * # Returns
511
- * Number of commits that modified the file in the period
512
- */
513
- fileChangeFrequency(path: string, days?: number | undefined | null): number
514
- /**
515
- * Get file content at a specific git ref (commit, branch, tag)
516
- *
517
- * Uses `git show <ref>:<path>` to retrieve file content at that revision.
518
- *
519
- * # Arguments
520
- * * `path` - File path (relative to repo root)
521
- * * `gitRef` - Git ref (commit hash, branch name, tag, HEAD~n, etc.)
522
- *
523
- * # Returns
524
- * File content as string
525
- *
526
- * # Example
527
- * ```javascript
528
- * const repo = new GitRepo('./my-project');
529
- * const oldVersion = repo.fileAtRef('src/main.js', 'HEAD~5');
530
- * const mainVersion = repo.fileAtRef('src/main.js', 'main');
531
- * ```
532
- */
533
- fileAtRef(path: string, gitRef: string): string
534
- /**
535
- * Parse diff between two refs into structured hunks
536
- *
537
- * Returns detailed hunk information including line numbers for each change.
538
- * Useful for PR review tools that need to post comments at specific lines.
539
- *
540
- * # Arguments
541
- * * `fromRef` - Starting ref (e.g., "main", "HEAD~5", commit hash)
542
- * * `toRef` - Ending ref (e.g., "HEAD", "feature-branch")
543
- * * `path` - Optional file path to filter to a single file
544
- *
545
- * # Returns
546
- * Array of diff hunks with line-level change information
547
- *
548
- * # Example
549
- * ```javascript
550
- * const repo = new GitRepo('./my-project');
551
- * const hunks = repo.diffHunks('main', 'HEAD', 'src/index.js');
552
- * for (const hunk of hunks) {
553
- * console.log(`Hunk at old:${hunk.oldStart} new:${hunk.newStart}`);
554
- * for (const line of hunk.lines) {
555
- * console.log(`${line.changeType}: ${line.content}`);
556
- * }
557
- * }
558
- * ```
559
- */
560
- diffHunks(fromRef: string, toRef: string, path?: string | undefined | null): Array<GitDiffHunk>
561
- /**
562
- * Parse uncommitted changes (working tree vs HEAD) into structured hunks
563
- *
564
- * # Arguments
565
- * * `path` - Optional file path to filter to a single file
566
- *
567
- * # Returns
568
- * Array of diff hunks for uncommitted changes
569
- *
570
- * # Example
571
- * ```javascript
572
- * const repo = new GitRepo('./my-project');
573
- * const hunks = repo.uncommittedHunks('src/index.js');
574
- * console.log(`${hunks.length} hunks with uncommitted changes`);
575
- * ```
576
- */
577
- uncommittedHunks(path?: string | undefined | null): Array<GitDiffHunk>
578
- /**
579
- * Parse staged changes into structured hunks
580
- *
581
- * # Arguments
582
- * * `path` - Optional file path to filter to a single file
583
- *
584
- * # Returns
585
- * Array of diff hunks for staged changes only
586
- *
587
- * # Example
588
- * ```javascript
589
- * const repo = new GitRepo('./my-project');
590
- * const hunks = repo.stagedHunks('src/index.js');
591
- * console.log(`${hunks.length} hunks staged for commit`);
592
- * ```
593
- */
594
- stagedHunks(path?: string | undefined | null): Array<GitDiffHunk>
595
- }
596
-
597
- // ============================================================================
598
- // Index API - Build and query symbol indexes
599
- // ============================================================================
600
-
601
- /** Options for building an index */
602
- export interface IndexOptions {
603
- /** Force full rebuild even if index exists */
604
- force?: boolean
605
- /** Include test files in index */
606
- includeTests?: boolean
607
- /** Maximum file size to index (bytes) */
608
- maxFileSize?: number
609
- }
610
-
611
- /** Index status information */
612
- export interface IndexStatus {
613
- /** Whether an index exists */
614
- exists: boolean
615
- /** Number of files indexed */
616
- fileCount: number
617
- /** Number of symbols indexed */
618
- symbolCount: number
619
- /** Last build timestamp (ISO 8601) */
620
- lastBuilt?: string
621
- /** Index version */
622
- version?: string
623
- }
624
-
625
- /**
626
- * Build or update the symbol index for a repository
627
- *
628
- * The index enables fast diff-to-context lookups and impact analysis.
629
- *
630
- * # Arguments
631
- * * `path` - Path to repository root
632
- * * `options` - Optional index build options
633
- *
634
- * # Returns
635
- * Index status after building
636
- *
637
- * # Example
638
- * ```javascript
639
- * const { buildIndex } = require('infiniloom-node');
640
- *
641
- * const status = buildIndex('./my-repo');
642
- * console.log(`Indexed ${status.symbolCount} symbols`);
643
- *
644
- * // Force rebuild
645
- * const status2 = buildIndex('./my-repo', { force: true });
646
- * ```
647
- */
648
- export declare function buildIndex(path: string, options?: IndexOptions | undefined | null): IndexStatus
649
-
650
- /**
651
- * Get the status of an existing index
652
- *
653
- * # Arguments
654
- * * `path` - Path to repository root
655
- *
656
- * # Returns
657
- * Index status information
658
- *
659
- * # Example
660
- * ```javascript
661
- * const { indexStatus } = require('infiniloom-node');
662
- *
663
- * const status = indexStatus('./my-repo');
664
- * if (status.exists) {
665
- * console.log(`Index has ${status.symbolCount} symbols`);
666
- * } else {
667
- * console.log('No index found, run buildIndex first');
361
+ * // Force rebuild
362
+ * const status2 = buildIndex('./my-repo', { force: true });
363
+ * ```
364
+ */
365
+ export declare function buildIndex(path: string, options?: IndexOptions | undefined | null): IndexStatus
366
+ /**
367
+ * Get the status of an existing index
368
+ *
369
+ * # Arguments
370
+ * * `path` - Path to repository root
371
+ *
372
+ * # Returns
373
+ * Index status information
374
+ *
375
+ * # Example
376
+ * ```javascript
377
+ * const { indexStatus } = require('infiniloom-node');
378
+ *
379
+ * const status = indexStatus('./my-repo');
380
+ * if (status.exists) {
381
+ * console.log(`Index has ${status.symbolCount} symbols`);
382
+ * } else {
383
+ * console.log('No index found, run buildIndex first');
668
384
  * }
669
385
  * ```
670
386
  */
671
387
  export declare function indexStatus(path: string): IndexStatus
672
-
673
- // ============================================================================
674
- // Call Graph API - Query symbol relationships
675
- // ============================================================================
676
-
677
388
  /** Information about a symbol in the call graph */
678
389
  export interface SymbolInfo {
679
390
  /** Symbol ID */
@@ -693,7 +404,6 @@ export interface SymbolInfo {
693
404
  /** Visibility (public, private, etc.) */
694
405
  visibility: string
695
406
  }
696
-
697
407
  /** A reference to a symbol with context */
698
408
  export interface ReferenceInfo {
699
409
  /** Symbol making the reference */
@@ -705,7 +415,6 @@ export interface ReferenceInfo {
705
415
  /** Line number of the reference (convenience field, same as symbol.line) */
706
416
  line: number
707
417
  }
708
-
709
418
  /** An edge in the call graph */
710
419
  export interface CallGraphEdge {
711
420
  /** Caller symbol ID */
@@ -721,7 +430,6 @@ export interface CallGraphEdge {
721
430
  /** Line number of the call */
722
431
  line: number
723
432
  }
724
-
725
433
  /** Call graph statistics */
726
434
  export interface CallGraphStats {
727
435
  /** Total number of symbols */
@@ -733,7 +441,6 @@ export interface CallGraphStats {
733
441
  /** Number of classes/structs */
734
442
  classes: number
735
443
  }
736
-
737
444
  /** Complete call graph with nodes and edges */
738
445
  export interface CallGraph {
739
446
  /** All symbols (nodes) */
@@ -743,7 +450,6 @@ export interface CallGraph {
743
450
  /** Summary statistics */
744
451
  stats: CallGraphStats
745
452
  }
746
-
747
453
  /** Options for call graph queries */
748
454
  export interface CallGraphOptions {
749
455
  /** Maximum number of nodes to return (default: unlimited) */
@@ -751,12 +457,11 @@ export interface CallGraphOptions {
751
457
  /** Maximum number of edges to return (default: unlimited) */
752
458
  maxEdges?: number
753
459
  }
754
-
755
460
  /**
756
461
  * Find a symbol by name
757
462
  *
758
463
  * Searches the index for all symbols matching the given name.
759
- * Requires an index to be built first (use buildIndex).
464
+ * Requires an index to be built first (use `buildIndex`).
760
465
  *
761
466
  * # Arguments
762
467
  * * `path` - Path to repository root
@@ -775,16 +480,15 @@ export interface CallGraphOptions {
775
480
  * ```
776
481
  */
777
482
  export declare function findSymbol(path: string, name: string): Array<SymbolInfo>
778
-
779
483
  /**
780
484
  * Get all callers of a symbol
781
485
  *
782
486
  * Returns symbols that call any symbol with the given name.
783
- * Requires an index to be built first (use buildIndex).
487
+ * Requires an index to be built first (use `buildIndex`).
784
488
  *
785
489
  * # Arguments
786
490
  * * `path` - Path to repository root
787
- * * `symbolName` - Name of the symbol to find callers for
491
+ * * `symbol_name` - Name of the symbol to find callers for
788
492
  *
789
493
  * # Returns
790
494
  * Array of symbols that call the target symbol
@@ -802,16 +506,15 @@ export declare function findSymbol(path: string, name: string): Array<SymbolInfo
802
506
  * ```
803
507
  */
804
508
  export declare function getCallers(path: string, symbolName: string): Array<SymbolInfo>
805
-
806
509
  /**
807
510
  * Get all callees of a symbol
808
511
  *
809
512
  * Returns symbols that are called by any symbol with the given name.
810
- * Requires an index to be built first (use buildIndex).
513
+ * Requires an index to be built first (use `buildIndex`).
811
514
  *
812
515
  * # Arguments
813
516
  * * `path` - Path to repository root
814
- * * `symbolName` - Name of the symbol to find callees for
517
+ * * `symbol_name` - Name of the symbol to find callees for
815
518
  *
816
519
  * # Returns
817
520
  * Array of symbols that the target symbol calls
@@ -829,16 +532,15 @@ export declare function getCallers(path: string, symbolName: string): Array<Symb
829
532
  * ```
830
533
  */
831
534
  export declare function getCallees(path: string, symbolName: string): Array<SymbolInfo>
832
-
833
535
  /**
834
536
  * Get all references to a symbol
835
537
  *
836
538
  * Returns all locations where a symbol is referenced (calls, imports, inheritance).
837
- * Requires an index to be built first (use buildIndex).
539
+ * Requires an index to be built first (use `buildIndex`).
838
540
  *
839
541
  * # Arguments
840
542
  * * `path` - Path to repository root
841
- * * `symbolName` - Name of the symbol to find references for
543
+ * * `symbol_name` - Name of the symbol to find references for
842
544
  *
843
545
  * # Returns
844
546
  * Array of reference information including the referencing symbol and kind
@@ -856,12 +558,11 @@ export declare function getCallees(path: string, symbolName: string): Array<Symb
856
558
  * ```
857
559
  */
858
560
  export declare function getReferences(path: string, symbolName: string): Array<ReferenceInfo>
859
-
860
561
  /**
861
562
  * Get the complete call graph
862
563
  *
863
564
  * Returns all symbols and their call relationships.
864
- * Requires an index to be built first (use buildIndex).
565
+ * Requires an index to be built first (use `buildIndex`).
865
566
  *
866
567
  * # Arguments
867
568
  * * `path` - Path to repository root
@@ -888,26 +589,16 @@ export declare function getReferences(path: string, symbolName: string): Array<R
888
589
  * ```
889
590
  */
890
591
  export declare function getCallGraph(path: string, options?: CallGraphOptions | undefined | null): CallGraph
891
-
892
592
  /** Async version of findSymbol */
893
593
  export declare function findSymbolAsync(path: string, name: string): Promise<Array<SymbolInfo>>
894
-
895
594
  /** Async version of getCallers */
896
595
  export declare function getCallersAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
897
-
898
596
  /** Async version of getCallees */
899
597
  export declare function getCalleesAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
900
-
901
598
  /** Async version of getReferences */
902
599
  export declare function getReferencesAsync(path: string, symbolName: string): Promise<Array<ReferenceInfo>>
903
-
904
600
  /** Async version of getCallGraph */
905
601
  export declare function getCallGraphAsync(path: string, options?: CallGraphOptions | undefined | null): Promise<CallGraph>
906
-
907
- // ============================================================================
908
- // Chunk API - Split repositories into manageable pieces
909
- // ============================================================================
910
-
911
602
  /** Options for chunking a repository */
912
603
  export interface ChunkOptions {
913
604
  /** Chunking strategy: "fixed", "file", "module", "symbol", "semantic", "dependency" */
@@ -923,7 +614,6 @@ export interface ChunkOptions {
923
614
  /** Sort chunks by priority (core modules first) */
924
615
  priorityFirst?: boolean
925
616
  }
926
-
927
617
  /** A chunk of repository content */
928
618
  export interface RepoChunk {
929
619
  /** Chunk index (0-based) */
@@ -939,7 +629,6 @@ export interface RepoChunk {
939
629
  /** Formatted content of the chunk */
940
630
  content: string
941
631
  }
942
-
943
632
  /**
944
633
  * Split a repository into chunks for incremental processing
945
634
  *
@@ -969,11 +658,6 @@ export interface RepoChunk {
969
658
  * ```
970
659
  */
971
660
  export declare function chunk(path: string, options?: ChunkOptions | undefined | null): Array<RepoChunk>
972
-
973
- // ============================================================================
974
- // Impact API - Analyze change impact
975
- // ============================================================================
976
-
977
661
  /** Options for impact analysis */
978
662
  export interface ImpactOptions {
979
663
  /** Depth of dependency traversal (1-3, default: 2) */
@@ -981,7 +665,6 @@ export interface ImpactOptions {
981
665
  /** Include test files in analysis */
982
666
  includeTests?: boolean
983
667
  }
984
-
985
668
  /** Symbol affected by a change */
986
669
  export interface AffectedSymbol {
987
670
  /** Symbol name */
@@ -995,7 +678,6 @@ export interface AffectedSymbol {
995
678
  /** How the symbol is affected: "direct", "caller", "callee", "dependent" */
996
679
  impactType: string
997
680
  }
998
-
999
681
  /** Impact analysis result */
1000
682
  export interface ImpactResult {
1001
683
  /** Files directly changed */
@@ -1011,7 +693,6 @@ export interface ImpactResult {
1011
693
  /** Summary of the impact */
1012
694
  summary: string
1013
695
  }
1014
-
1015
696
  /**
1016
697
  * Analyze the impact of changes to files or symbols
1017
698
  *
@@ -1039,11 +720,6 @@ export interface ImpactResult {
1039
720
  * ```
1040
721
  */
1041
722
  export declare function analyzeImpact(path: string, files: Array<string>, options?: ImpactOptions | undefined | null): ImpactResult
1042
-
1043
- // ============================================================================
1044
- // Diff Context API - Get context-aware diffs
1045
- // ============================================================================
1046
-
1047
723
  /** Options for diff context */
1048
724
  export interface DiffContextOptions {
1049
725
  /** Depth of context expansion (1-3, default: 2) */
@@ -1055,7 +731,19 @@ export interface DiffContextOptions {
1055
731
  /** Output format: "xml", "markdown", "json" (default: "xml") */
1056
732
  format?: string
1057
733
  }
1058
-
734
+ /** Context-aware diff result */
735
+ export interface DiffContextResult {
736
+ /** Changed files with context */
737
+ changedFiles: Array<DiffFileContext>
738
+ /** Related symbols and their context */
739
+ contextSymbols: Array<ContextSymbolInfo>
740
+ /** Related test files */
741
+ relatedTests: Array<string>
742
+ /** Formatted output (if format specified) */
743
+ formattedOutput?: string
744
+ /** Total token count */
745
+ totalTokens: number
746
+ }
1059
747
  /** A changed file with surrounding context */
1060
748
  export interface DiffFileContext {
1061
749
  /** File path */
@@ -1066,12 +754,11 @@ export interface DiffFileContext {
1066
754
  additions: number
1067
755
  /** Lines deleted */
1068
756
  deletions: number
1069
- /** Unified diff content (if includeDiff is true) */
757
+ /** Unified diff content (if include_diff is true) */
1070
758
  diff?: string
1071
759
  /** Relevant code context around changes */
1072
760
  contextSnippets: Array<string>
1073
761
  }
1074
-
1075
762
  /** Symbol context information */
1076
763
  export interface ContextSymbolInfo {
1077
764
  /** Symbol name */
@@ -1087,21 +774,6 @@ export interface ContextSymbolInfo {
1087
774
  /** Symbol signature/definition */
1088
775
  signature?: string
1089
776
  }
1090
-
1091
- /** Context-aware diff result */
1092
- export interface DiffContextResult {
1093
- /** Changed files with context */
1094
- changedFiles: Array<DiffFileContext>
1095
- /** Related symbols and their context */
1096
- contextSymbols: Array<ContextSymbolInfo>
1097
- /** Related test files */
1098
- relatedTests: Array<string>
1099
- /** Formatted output (if format specified) */
1100
- formattedOutput?: string
1101
- /** Total token count */
1102
- totalTokens: number
1103
- }
1104
-
1105
777
  /**
1106
778
  * Get context-aware diff with surrounding symbols and dependencies
1107
779
  *
@@ -1110,8 +782,8 @@ export interface DiffContextResult {
1110
782
  *
1111
783
  * # Arguments
1112
784
  * * `path` - Path to repository root
1113
- * * `fromRef` - Starting commit/branch (use "" for unstaged changes)
1114
- * * `toRef` - Ending commit/branch (use "HEAD" for staged, "" for working tree)
785
+ * * `from_ref` - Starting commit/branch (use "" for unstaged changes)
786
+ * * `to_ref` - Ending commit/branch (use "HEAD" for staged, "" for working tree)
1115
787
  * * `options` - Optional context options
1116
788
  *
1117
789
  * # Returns
@@ -1134,11 +806,6 @@ export interface DiffContextResult {
1134
806
  * ```
1135
807
  */
1136
808
  export declare function getDiffContext(path: string, fromRef: string, toRef: string, options?: DiffContextOptions | undefined | null): DiffContextResult
1137
-
1138
- // ============================================================================
1139
- // Async API - Async versions of key functions
1140
- // ============================================================================
1141
-
1142
809
  /**
1143
810
  * Async version of pack
1144
811
  *
@@ -1150,7 +817,6 @@ export declare function getDiffContext(path: string, fromRef: string, toRef: str
1150
817
  * ```
1151
818
  */
1152
819
  export declare function packAsync(path: string, options?: PackOptions | undefined | null): Promise<string>
1153
-
1154
820
  /**
1155
821
  * Async version of scan
1156
822
  *
@@ -1162,7 +828,6 @@ export declare function packAsync(path: string, options?: PackOptions | undefine
1162
828
  * ```
1163
829
  */
1164
830
  export declare function scanAsync(path: string, model?: string | undefined | null): Promise<ScanStats>
1165
-
1166
831
  /**
1167
832
  * Async version of buildIndex
1168
833
  *
@@ -1174,7 +839,6 @@ export declare function scanAsync(path: string, model?: string | undefined | nul
1174
839
  * ```
1175
840
  */
1176
841
  export declare function buildIndexAsync(path: string, options?: IndexOptions | undefined | null): Promise<IndexStatus>
1177
-
1178
842
  /**
1179
843
  * Async version of chunk
1180
844
  *
@@ -1186,7 +850,6 @@ export declare function buildIndexAsync(path: string, options?: IndexOptions | u
1186
850
  * ```
1187
851
  */
1188
852
  export declare function chunkAsync(path: string, options?: ChunkOptions | undefined | null): Promise<Array<RepoChunk>>
1189
-
1190
853
  /**
1191
854
  * Async version of analyzeImpact
1192
855
  *
@@ -1198,7 +861,6 @@ export declare function chunkAsync(path: string, options?: ChunkOptions | undefi
1198
861
  * ```
1199
862
  */
1200
863
  export declare function analyzeImpactAsync(path: string, files: Array<string>, options?: ImpactOptions | undefined | null): Promise<ImpactResult>
1201
-
1202
864
  /**
1203
865
  * Async version of getDiffContext
1204
866
  *
@@ -1210,3 +872,458 @@ export declare function analyzeImpactAsync(path: string, files: Array<string>, o
1210
872
  * ```
1211
873
  */
1212
874
  export declare function getDiffContextAsync(path: string, fromRef: string, toRef: string, options?: DiffContextOptions | undefined | null): Promise<DiffContextResult>
875
+ /** Options for filtering symbols */
876
+ export interface SymbolFilter {
877
+ /** Filter by symbol kind: "function", "class", "method", etc. */
878
+ kind?: string
879
+ /** Filter by visibility: "public", "private", "protected" */
880
+ visibility?: string
881
+ }
882
+ /** A call site where a symbol is called */
883
+ export interface CallSite {
884
+ /** Name of the calling function/method */
885
+ caller: string
886
+ /** Name of the function/method being called */
887
+ callee: string
888
+ /** File containing the call */
889
+ file: string
890
+ /** Line number of the call (1-indexed) */
891
+ line: number
892
+ /** Column number of the call (0-indexed, if available) */
893
+ column?: number
894
+ /** Caller symbol ID */
895
+ callerId: number
896
+ /** Callee symbol ID */
897
+ calleeId: number
898
+ }
899
+ /**
900
+ * Get all symbols in a specific file
901
+ *
902
+ * Requires an index to be built first (use `buildIndex`).
903
+ *
904
+ * # Arguments
905
+ * * `path` - Path to repository root
906
+ * * `file_path` - Relative path to the file within the repository
907
+ * * `filter` - Optional filter for symbol kind/visibility
908
+ *
909
+ * # Returns
910
+ * Array of symbols defined in the file
911
+ *
912
+ * # Example
913
+ * ```javascript
914
+ * const { getSymbolsInFile, buildIndex } = require('infiniloom-node');
915
+ *
916
+ * buildIndex('./my-repo');
917
+ * const symbols = getSymbolsInFile('./my-repo', 'src/auth.ts');
918
+ * console.log(`Found ${symbols.length} symbols in auth.ts`);
919
+ * for (const s of symbols) {
920
+ * console.log(` ${s.kind}: ${s.name} at line ${s.line}`);
921
+ * }
922
+ * ```
923
+ */
924
+ export declare function getSymbolsInFile(path: string, filePath: string, filter?: SymbolFilter | undefined | null): Array<SymbolInfo>
925
+ /**
926
+ * Get the source code of a symbol
927
+ *
928
+ * Reads the file and extracts the source code for the specified symbol.
929
+ * Requires an index to be built first (use `buildIndex`).
930
+ *
931
+ * # Arguments
932
+ * * `path` - Path to repository root
933
+ * * `symbol_name` - Name of the symbol to get source for
934
+ * * `file_path` - Optional file path to disambiguate when multiple symbols have the same name
935
+ *
936
+ * # Returns
937
+ * Source code of the symbol (or the first matching symbol if multiple exist)
938
+ *
939
+ * # Example
940
+ * ```javascript
941
+ * const { getSymbolSource, buildIndex } = require('infiniloom-node');
942
+ *
943
+ * buildIndex('./my-repo');
944
+ * const source = getSymbolSource('./my-repo', 'authenticate', 'src/auth.ts');
945
+ * console.log(source);
946
+ * ```
947
+ */
948
+ export declare function getSymbolSource(path: string, symbolName: string, filePath?: string | undefined | null): string
949
+ /**
950
+ * Get symbols that were changed in a diff
951
+ *
952
+ * Parses the diff between two refs and identifies which symbols were modified.
953
+ * Requires an index to be built first (use `buildIndex`).
954
+ *
955
+ * # Arguments
956
+ * * `path` - Path to repository root
957
+ * * `from_ref` - Starting commit/branch (e.g., "main", "HEAD~1")
958
+ * * `to_ref` - Ending commit/branch (e.g., "HEAD", "feature-branch")
959
+ *
960
+ * # Returns
961
+ * Array of symbols that were modified in the diff
962
+ *
963
+ * # Example
964
+ * ```javascript
965
+ * const { getChangedSymbols, buildIndex } = require('infiniloom-node');
966
+ *
967
+ * buildIndex('./my-repo');
968
+ * const changed = getChangedSymbols('./my-repo', 'main', 'HEAD');
969
+ * console.log(`${changed.length} symbols were modified`);
970
+ * for (const s of changed) {
971
+ * console.log(` ${s.kind}: ${s.name} in ${s.file}`);
972
+ * }
973
+ * ```
974
+ */
975
+ export declare function getChangedSymbols(path: string, fromRef: string, toRef: string): Array<SymbolInfo>
976
+ /**
977
+ * Get test files related to a source file
978
+ *
979
+ * Finds test files that:
980
+ * 1. Import the specified file
981
+ * 2. Match common test naming conventions (e.g., foo.ts -> foo.test.ts, test_foo.py)
982
+ *
983
+ * Requires an index to be built first (use `buildIndex`).
984
+ *
985
+ * # Arguments
986
+ * * `path` - Path to repository root
987
+ * * `file_path` - Relative path to the source file
988
+ *
989
+ * # Returns
990
+ * Array of test file paths related to the source file
991
+ *
992
+ * # Example
993
+ * ```javascript
994
+ * const { getTestsForFile, buildIndex } = require('infiniloom-node');
995
+ *
996
+ * buildIndex('./my-repo');
997
+ * const tests = getTestsForFile('./my-repo', 'src/auth.ts');
998
+ * console.log(`Found ${tests.length} test files for auth.ts`);
999
+ * for (const t of tests) {
1000
+ * console.log(` ${t}`);
1001
+ * }
1002
+ * ```
1003
+ */
1004
+ export declare function getTestsForFile(path: string, filePath: string): Array<string>
1005
+ /**
1006
+ * Get call sites where a symbol is called
1007
+ *
1008
+ * Returns the locations where a function/method is called, with exact line numbers.
1009
+ * This is useful for PR review tools that need to post inline comments.
1010
+ *
1011
+ * The function scans the caller's body to find the actual line where the callee is called,
1012
+ * rather than just returning the caller's definition line.
1013
+ *
1014
+ * Requires an index to be built first (use `buildIndex`).
1015
+ *
1016
+ * # Arguments
1017
+ * * `path` - Path to repository root
1018
+ * * `symbol_name` - Name of the symbol to find call sites for
1019
+ *
1020
+ * # Returns
1021
+ * Array of call sites with caller information and line numbers
1022
+ *
1023
+ * # Example
1024
+ * ```javascript
1025
+ * const { getCallSites, buildIndex } = require('infiniloom-node');
1026
+ *
1027
+ * buildIndex('./my-repo');
1028
+ * const callSites = getCallSites('./my-repo', 'authenticate');
1029
+ * console.log(`authenticate is called from ${callSites.length} locations`);
1030
+ * for (const site of callSites) {
1031
+ * console.log(` ${site.caller} in ${site.file}:${site.line}`);
1032
+ * }
1033
+ * ```
1034
+ */
1035
+ export declare function getCallSites(path: string, symbolName: string): Array<CallSite>
1036
+ /** Async version of getSymbolsInFile */
1037
+ export declare function getSymbolsInFileAsync(path: string, filePath: string, filter?: SymbolFilter | undefined | null): Promise<Array<SymbolInfo>>
1038
+ /** Async version of getSymbolSource */
1039
+ export declare function getSymbolSourceAsync(path: string, symbolName: string, filePath?: string | undefined | null): Promise<string>
1040
+ /** Async version of getChangedSymbols */
1041
+ export declare function getChangedSymbolsAsync(path: string, fromRef: string, toRef: string): Promise<Array<SymbolInfo>>
1042
+ /** Async version of getTestsForFile */
1043
+ export declare function getTestsForFileAsync(path: string, filePath: string): Promise<Array<string>>
1044
+ /** Async version of getCallSites */
1045
+ export declare function getCallSitesAsync(path: string, symbolName: string): Promise<Array<CallSite>>
1046
+ /** Infiniloom class for advanced usage */
1047
+ export declare class Infiniloom {
1048
+ /**
1049
+ * Create a new Infiniloom instance
1050
+ *
1051
+ * # Arguments
1052
+ * * `path` - Path to repository root
1053
+ * * `model` - Optional model name (default: "claude")
1054
+ */
1055
+ constructor(path: string, model?: string | undefined | null)
1056
+ /** Get repository statistics (Bug #4 fix - consistent with scan() function) */
1057
+ getStats(): ScanStats
1058
+ /**
1059
+ * Generate a repository map
1060
+ *
1061
+ * # Arguments
1062
+ * * `budget` - Token budget (default: 2000)
1063
+ * * `max_symbols` - Maximum symbols (default: 50)
1064
+ */
1065
+ generateMap(budget?: number | undefined | null, maxSymbols?: number | undefined | null): string
1066
+ /** Pack repository with specific options */
1067
+ pack(options?: PackOptions | undefined | null): string
1068
+ /** Check for security issues (Bug #8 fix - now returns structured findings) */
1069
+ securityScan(): Array<SecurityFinding>
1070
+ /** Check for security issues (legacy format, returns formatted strings) */
1071
+ securityScanFormatted(): Array<string>
1072
+ }
1073
+ /**
1074
+ * Git repository wrapper for Node.js
1075
+ *
1076
+ * Provides access to git operations like status, diff, log, and blame.
1077
+ *
1078
+ * # Example
1079
+ * ```javascript
1080
+ * const { GitRepo } = require('infiniloom-node');
1081
+ *
1082
+ * const repo = new GitRepo('./my-project');
1083
+ * console.log(`Branch: ${repo.currentBranch()}`);
1084
+ * console.log(`Commit: ${repo.currentCommit()}`);
1085
+ *
1086
+ * for (const file of repo.status()) {
1087
+ * console.log(`${file.status}: ${file.path}`);
1088
+ * }
1089
+ * ```
1090
+ */
1091
+ export declare class GitRepo {
1092
+ /**
1093
+ * Open a git repository
1094
+ *
1095
+ * # Arguments
1096
+ * * `path` - Path to the repository
1097
+ *
1098
+ * # Throws
1099
+ * Error if path is not a git repository
1100
+ */
1101
+ constructor(path: string)
1102
+ /**
1103
+ * Get the current branch name
1104
+ *
1105
+ * # Returns
1106
+ * Current branch name (e.g., "main", "feature/xyz")
1107
+ */
1108
+ currentBranch(): string
1109
+ /**
1110
+ * Get the current commit hash
1111
+ *
1112
+ * # Returns
1113
+ * Full SHA-1 hash of HEAD commit
1114
+ */
1115
+ currentCommit(): string
1116
+ /**
1117
+ * Get working tree status
1118
+ *
1119
+ * Returns both staged and unstaged changes.
1120
+ *
1121
+ * # Returns
1122
+ * Array of file status objects
1123
+ */
1124
+ status(): Array<GitFileStatus>
1125
+ /**
1126
+ * Get files changed between two commits
1127
+ *
1128
+ * # Arguments
1129
+ * * `from_ref` - Starting commit/branch/tag
1130
+ * * `to_ref` - Ending commit/branch/tag
1131
+ *
1132
+ * # Returns
1133
+ * Array of changed files with diff stats
1134
+ */
1135
+ diffFiles(fromRef: string, toRef: string): Array<GitChangedFile>
1136
+ /**
1137
+ * Get recent commits
1138
+ *
1139
+ * # Arguments
1140
+ * * `count` - Maximum number of commits to return (default: 10)
1141
+ *
1142
+ * # Returns
1143
+ * Array of commit objects
1144
+ */
1145
+ log(count?: number | undefined | null): Array<GitCommit>
1146
+ /**
1147
+ * Get commits that modified a specific file
1148
+ *
1149
+ * # Arguments
1150
+ * * `path` - File path (relative to repo root)
1151
+ * * `count` - Maximum number of commits to return (default: 10)
1152
+ *
1153
+ * # Returns
1154
+ * Array of commits that modified the file
1155
+ */
1156
+ fileLog(path: string, count?: number | undefined | null): Array<GitCommit>
1157
+ /**
1158
+ * Get blame information for a file
1159
+ *
1160
+ * # Arguments
1161
+ * * `path` - File path (relative to repo root)
1162
+ *
1163
+ * # Returns
1164
+ * Array of blame line objects
1165
+ */
1166
+ blame(path: string): Array<GitBlameLine>
1167
+ /**
1168
+ * Get list of files tracked by git
1169
+ *
1170
+ * # Returns
1171
+ * Array of file paths tracked by git
1172
+ */
1173
+ lsFiles(): Array<string>
1174
+ /**
1175
+ * Get diff content between two commits for a file
1176
+ *
1177
+ * # Arguments
1178
+ * * `from_ref` - Starting commit/branch/tag
1179
+ * * `to_ref` - Ending commit/branch/tag
1180
+ * * `path` - File path (relative to repo root)
1181
+ *
1182
+ * # Returns
1183
+ * Unified diff content as string
1184
+ */
1185
+ diffContent(fromRef: string, toRef: string, path: string): string
1186
+ /**
1187
+ * Get diff content for uncommitted changes in a file
1188
+ *
1189
+ * Includes both staged and unstaged changes compared to HEAD.
1190
+ *
1191
+ * # Arguments
1192
+ * * `path` - File path (relative to repo root)
1193
+ *
1194
+ * # Returns
1195
+ * Unified diff content as string
1196
+ */
1197
+ uncommittedDiff(path: string): string
1198
+ /**
1199
+ * Get diff for all uncommitted changes
1200
+ *
1201
+ * Returns combined diff for all changed files.
1202
+ *
1203
+ * # Returns
1204
+ * Unified diff content as string
1205
+ */
1206
+ allUncommittedDiffs(): string
1207
+ /**
1208
+ * Check if a file has uncommitted changes
1209
+ *
1210
+ * # Arguments
1211
+ * * `path` - File path (relative to repo root)
1212
+ *
1213
+ * # Returns
1214
+ * True if file has changes, false otherwise
1215
+ */
1216
+ hasChanges(path: string): boolean
1217
+ /**
1218
+ * Get the last commit that modified a file
1219
+ *
1220
+ * # Arguments
1221
+ * * `path` - File path (relative to repo root)
1222
+ *
1223
+ * # Returns
1224
+ * Commit information object
1225
+ */
1226
+ lastModifiedCommit(path: string): GitCommit
1227
+ /**
1228
+ * Get file change frequency in recent days
1229
+ *
1230
+ * Useful for determining file importance based on recent activity.
1231
+ *
1232
+ * # Arguments
1233
+ * * `path` - File path (relative to repo root)
1234
+ * * `days` - Number of days to look back (default: 30)
1235
+ *
1236
+ * # Returns
1237
+ * Number of commits that modified the file in the period
1238
+ */
1239
+ fileChangeFrequency(path: string, days?: number | undefined | null): number
1240
+ /**
1241
+ * Get file content at a specific git ref (commit, branch, tag)
1242
+ *
1243
+ * Uses `git show <ref>:<path>` to retrieve file content at that revision.
1244
+ *
1245
+ * # Arguments
1246
+ * * `path` - File path (relative to repo root)
1247
+ * * `git_ref` - Git ref (commit hash, branch name, tag, HEAD~n, etc.)
1248
+ *
1249
+ * # Returns
1250
+ * File content as string
1251
+ *
1252
+ * # Example
1253
+ * ```javascript
1254
+ * const { GitRepo } = require('infiniloom-node');
1255
+ *
1256
+ * const repo = new GitRepo('./my-project');
1257
+ * const oldVersion = repo.fileAtRef('src/main.ts', 'HEAD~5');
1258
+ * const mainVersion = repo.fileAtRef('src/main.ts', 'main');
1259
+ * ```
1260
+ */
1261
+ fileAtRef(path: string, gitRef: string): string
1262
+ /**
1263
+ * Parse diff between two refs into structured hunks
1264
+ *
1265
+ * Returns detailed hunk information including line numbers for each change.
1266
+ * Useful for PR review tools that need to post comments at specific lines.
1267
+ *
1268
+ * # Arguments
1269
+ * * `from_ref` - Starting ref (e.g., "main", "HEAD~5", commit hash)
1270
+ * * `to_ref` - Ending ref (e.g., "HEAD", "feature-branch")
1271
+ * * `path` - Optional file path to filter to a single file
1272
+ *
1273
+ * # Returns
1274
+ * Array of diff hunks with line-level information
1275
+ *
1276
+ * # Example
1277
+ * ```javascript
1278
+ * const { GitRepo } = require('infiniloom-node');
1279
+ *
1280
+ * const repo = new GitRepo('./my-project');
1281
+ * const hunks = repo.diffHunks('main', 'HEAD', 'src/index.ts');
1282
+ * for (const hunk of hunks) {
1283
+ * console.log(`Hunk at old:${hunk.oldStart} new:${hunk.newStart}`);
1284
+ * for (const line of hunk.lines) {
1285
+ * console.log(`${line.changeType}: ${line.content}`);
1286
+ * }
1287
+ * }
1288
+ * ```
1289
+ */
1290
+ diffHunks(fromRef: string, toRef: string, path?: string | undefined | null): Array<GitDiffHunk>
1291
+ /**
1292
+ * Parse uncommitted changes (working tree vs HEAD) into structured hunks
1293
+ *
1294
+ * # Arguments
1295
+ * * `path` - Optional file path to filter to a single file
1296
+ *
1297
+ * # Returns
1298
+ * Array of diff hunks for uncommitted changes
1299
+ *
1300
+ * # Example
1301
+ * ```javascript
1302
+ * const { GitRepo } = require('infiniloom-node');
1303
+ *
1304
+ * const repo = new GitRepo('./my-project');
1305
+ * const hunks = repo.uncommittedHunks('src/index.ts');
1306
+ * console.log(`${hunks.length} hunks with uncommitted changes`);
1307
+ * ```
1308
+ */
1309
+ uncommittedHunks(path?: string | undefined | null): Array<GitDiffHunk>
1310
+ /**
1311
+ * Parse staged changes into structured hunks
1312
+ *
1313
+ * # Arguments
1314
+ * * `path` - Optional file path to filter to a single file
1315
+ *
1316
+ * # Returns
1317
+ * Array of diff hunks for staged changes only
1318
+ *
1319
+ * # Example
1320
+ * ```javascript
1321
+ * const { GitRepo } = require('infiniloom-node');
1322
+ *
1323
+ * const repo = new GitRepo('./my-project');
1324
+ * const hunks = repo.stagedHunks('src/index.ts');
1325
+ * console.log(`${hunks.length} hunks staged for commit`);
1326
+ * ```
1327
+ */
1328
+ stagedHunks(path?: string | undefined | null): Array<GitDiffHunk>
1329
+ }