infiniloom-node 0.4.6 → 0.4.8

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
@@ -187,10 +187,10 @@ Scan a repository with full configuration options.
187
187
  Count tokens in text for a specific model.
188
188
 
189
189
  **Parameters:**
190
- - `text` - Text to tokenize
190
+ - `text` - Text to tokenize (null/undefined returns 0)
191
191
  - `model` - Optional model name (default: "claude")
192
192
 
193
- **Returns:** Token count
193
+ **Returns:** Token count (0 for empty, null, or undefined input)
194
194
 
195
195
  #### `semanticCompress(text: string, similarityThreshold?: number, budgetRatio?: number): string`
196
196
 
@@ -198,10 +198,10 @@ Compress text using semantic compression while preserving important content.
198
198
 
199
199
  **Parameters:**
200
200
  - `text` - Text to compress
201
- - `similarityThreshold` - Threshold for grouping similar chunks (0.0-1.0, default: 0.7)
202
- - `budgetRatio` - Target size as ratio of original (0.0-1.0, default: 0.5)
201
+ - `similarityThreshold` - Threshold for grouping similar chunks (0.0-1.0, default: 0.7). Note: Only affects output when built with "embeddings" feature.
202
+ - `budgetRatio` - Target size as ratio of original (0.0-1.0, default: 0.5). Lower values = more aggressive compression. Affects content as small as 10 characters. Use 1.0 to preserve content unchanged.
203
203
 
204
- **Returns:** Compressed text
204
+ **Returns:** Compressed text (may include truncation markers showing percentage and character counts)
205
205
 
206
206
  #### `scanSecurity(path: string): SecurityFinding[]`
207
207
 
@@ -422,6 +422,9 @@ for (const sym of impact.affectedSymbols) {
422
422
  interface ImpactOptions {
423
423
  depth?: number; // Depth of dependency traversal (1-3, default: 2)
424
424
  includeTests?: boolean; // Include test files in analysis (default: false)
425
+ model?: string; // Target model for token counting (default: "claude")
426
+ exclude?: string[]; // Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"])
427
+ include?: string[]; // Glob patterns to include (e.g., ["src/**/*.ts"])
425
428
  }
426
429
  ```
427
430
 
@@ -495,6 +498,10 @@ interface DiffContextOptions {
495
498
  depth?: number; // Context expansion depth (1-3, default: 2)
496
499
  budget?: number; // Token budget for context (default: 50000)
497
500
  includeDiff?: boolean; // Include actual diff content (default: false)
501
+ format?: string; // Output format: "xml", "markdown", "json" (default: "xml")
502
+ model?: string; // Target model for token counting (default: "claude")
503
+ exclude?: string[]; // Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"])
504
+ include?: string[]; // Glob patterns to include (e.g., ["src/**/*.ts"])
498
505
  }
499
506
  ```
500
507
 
@@ -560,7 +567,7 @@ interface PackOptions {
560
567
  exclude?: string[]; // Glob patterns to exclude (e.g., ["**/*.test.ts"])
561
568
  includeTests?: boolean; // Include test files (default: false)
562
569
  securityThreshold?: string;// Minimum severity to block: "critical", "high", "medium", "low"
563
- tokenBudget?: number; // Limit total output tokens (0 = no limit)
570
+ tokenBudget?: number; // Limit total output tokens (0 = no limit, negative values rejected)
564
571
  // Git-based filtering options (PR review integration)
565
572
  changedOnly?: boolean; // Only include files changed in git
566
573
  baseSha?: string; // Base SHA/ref for diff comparison (e.g., "main", "HEAD~5")
package/index.d.ts CHANGED
@@ -29,7 +29,10 @@ export interface PackOptions {
29
29
  includeTests?: boolean
30
30
  /** Minimum security severity to block on: "critical", "high", "medium", "low" (default: "critical") */
31
31
  securityThreshold?: string
32
- /** Token budget for total output (0 = no limit). Files are included by importance until budget is reached. */
32
+ /**
33
+ * Token budget for total output (0 = no limit). Files are included by importance until budget is reached.
34
+ * Negative values are invalid and will throw an error.
35
+ */
33
36
  tokenBudget?: number
34
37
  /** Only include files changed in git (requires baseSha or uses uncommitted changes) */
35
38
  changedOnly?: boolean
@@ -154,7 +157,7 @@ export declare function scanWithOptions(path: string, options?: ScanOptions | un
154
157
  * Count tokens in text for a specific model
155
158
  *
156
159
  * # Arguments
157
- * * `text` - Text to tokenize
160
+ * * `text` - Text to tokenize (null/undefined returns 0)
158
161
  * * `model` - Optional model name (default: "claude")
159
162
  *
160
163
  * # Returns
@@ -168,26 +171,39 @@ export declare function scanWithOptions(path: string, options?: ScanOptions | un
168
171
  * console.log(`Tokens: ${count}`);
169
172
  * ```
170
173
  */
171
- export declare function countTokens(text: string, model?: string | undefined | null): number
174
+ export declare function countTokens(text?: string | undefined | null, model?: string | undefined | null): number
172
175
  /**
173
176
  * Compress text using semantic compression
174
177
  *
175
178
  * Uses heuristic-based compression to reduce content while preserving meaning.
176
- * When built with the "embeddings" feature, uses neural networks for clustering.
179
+ * The compression works in three modes:
180
+ *
181
+ * 1. **Repetitive content**: Detects and collapses repeated patterns/lines
182
+ * 2. **Chunk-based**: Splits content at paragraph/sentence boundaries and keeps a ratio
183
+ * 3. **Character-based**: For content without boundaries, truncates to budget_ratio
177
184
  *
178
185
  * # Arguments
179
186
  * * `text` - Text to compress
180
- * * `similarity_threshold` - Threshold for grouping similar chunks (0.0-1.0, default: 0.7)
181
- * * `budget_ratio` - Target size as ratio of original (0.0-1.0, default: 0.5)
187
+ * * `similarity_threshold` - Threshold for grouping similar chunks (0.0-1.0, default: 0.7).
188
+ * Note: Only affects output when built with "embeddings" feature.
189
+ * * `budget_ratio` - Target size as ratio of original (0.0-1.0, default: 0.5).
190
+ * Lower values = more aggressive compression. For example:
191
+ * - 0.5 = keep ~50% of content
192
+ * - 0.3 = keep ~30% of content
193
+ * - 1.0 = no compression
182
194
  *
183
195
  * # Returns
184
- * Compressed text
196
+ * Compressed text with markers indicating what was removed
185
197
  *
186
198
  * # Example
187
199
  * ```javascript
188
200
  * const { semanticCompress } = require('infiniloom-node');
189
201
  *
202
+ * // Compress to ~30% of original size
190
203
  * const compressed = semanticCompress(longText, 0.7, 0.3);
204
+ *
205
+ * // Aggressive compression to ~20%
206
+ * const veryCompressed = semanticCompress(longText, 0.7, 0.2);
191
207
  * ```
192
208
  */
193
209
  export declare function semanticCompress(text: string, similarityThreshold?: number | undefined | null, budgetRatio?: number | undefined | null): string
@@ -325,6 +341,13 @@ export interface IndexOptions {
325
341
  includeTests?: boolean
326
342
  /** Maximum file size to index (bytes) */
327
343
  maxFileSize?: number
344
+ /** Directories/patterns to exclude (e.g., ["node_modules", "dist", "vendor", "*.generated.*"]) */
345
+ exclude?: Array<string>
346
+ /**
347
+ * Incremental update - only re-index changed files (default: false)
348
+ * When true, compares file hashes with existing index and only rebuilds changed files
349
+ */
350
+ incremental?: boolean
328
351
  }
329
352
  /** Index status information */
330
353
  export interface IndexStatus {
@@ -338,6 +361,10 @@ export interface IndexStatus {
338
361
  lastBuilt?: string
339
362
  /** Index version */
340
363
  version?: string
364
+ /** Number of files updated in incremental build (only set for incremental builds) */
365
+ filesUpdated?: number
366
+ /** Whether this was an incremental update */
367
+ incremental?: boolean
341
368
  }
342
369
  /**
343
370
  * Build or update the symbol index for a repository
@@ -395,9 +422,9 @@ export interface SymbolInfo {
395
422
  kind: string
396
423
  /** File path containing the symbol */
397
424
  file: string
398
- /** Start line number */
425
+ /** Start line number (1-indexed, consistent with editors/IDEs) */
399
426
  line: number
400
- /** End line number */
427
+ /** End line number (1-indexed, consistent with editors/IDEs) */
401
428
  endLine: number
402
429
  /** Function/method signature */
403
430
  signature?: string
@@ -412,7 +439,11 @@ export interface ReferenceInfo {
412
439
  kind: string
413
440
  /** File path containing the reference (convenience field, same as symbol.file) */
414
441
  file: string
415
- /** Line number of the reference (convenience field, same as symbol.line) */
442
+ /**
443
+ * Line number of the reference (1-indexed, convenience field, same as symbol.line)
444
+ * Note: This is the line where the referencing symbol is defined, not where the
445
+ * actual reference occurs. For call site line numbers, use getCallSites() instead.
446
+ */
416
447
  line: number
417
448
  }
418
449
  /** An edge in the call graph */
@@ -457,6 +488,20 @@ export interface CallGraphOptions {
457
488
  /** Maximum number of edges to return (default: unlimited) */
458
489
  maxEdges?: number
459
490
  }
491
+ /**
492
+ * Feature #2: Filter options for symbol queries
493
+ *
494
+ * Allows filtering query results by symbol kind.
495
+ */
496
+ export interface QueryFilter {
497
+ /**
498
+ * Filter by symbol kinds: "function", "method", "class", "struct", "interface", "trait", "enum", etc.
499
+ * If specified, only symbols of these kinds are returned.
500
+ */
501
+ kinds?: Array<string>
502
+ /** Exclude specific kinds (e.g., exclude "import" to skip import statements) */
503
+ excludeKinds?: Array<string>
504
+ }
460
505
  /**
461
506
  * Find a symbol by name
462
507
  *
@@ -558,6 +603,119 @@ export declare function getCallees(path: string, symbolName: string): Array<Symb
558
603
  * ```
559
604
  */
560
605
  export declare function getReferences(path: string, symbolName: string): Array<ReferenceInfo>
606
+ /**
607
+ * Find symbols by name with filtering
608
+ *
609
+ * Like `findSymbol`, but allows filtering results by symbol kind.
610
+ *
611
+ * # Arguments
612
+ * * `path` - Path to repository root
613
+ * * `name` - Symbol name to search for
614
+ * * `filter` - Optional filter for symbol kinds
615
+ *
616
+ * # Returns
617
+ * Array of matching symbols that pass the filter
618
+ *
619
+ * # Example
620
+ * ```javascript
621
+ * const { findSymbolFiltered, buildIndex } = require('infiniloom-node');
622
+ *
623
+ * buildIndex('./my-repo');
624
+ * // Find only functions named "process"
625
+ * const funcs = findSymbolFiltered('./my-repo', 'process', {
626
+ * kinds: ['function', 'method']
627
+ * });
628
+ * // Find all symbols except imports
629
+ * const noImports = findSymbolFiltered('./my-repo', 'User', {
630
+ * excludeKinds: ['import']
631
+ * });
632
+ * ```
633
+ */
634
+ export declare function findSymbolFiltered(path: string, name: string, filter?: QueryFilter | undefined | null): Array<SymbolInfo>
635
+ /**
636
+ * Get callers of a symbol with filtering
637
+ *
638
+ * Like `getCallers`, but allows filtering results by symbol kind.
639
+ *
640
+ * # Arguments
641
+ * * `path` - Path to repository root
642
+ * * `symbol_name` - Name of the symbol to find callers for
643
+ * * `filter` - Optional filter for symbol kinds
644
+ *
645
+ * # Returns
646
+ * Array of filtered calling symbols
647
+ *
648
+ * # Example
649
+ * ```javascript
650
+ * const { getCallersFiltered, buildIndex } = require('infiniloom-node');
651
+ *
652
+ * buildIndex('./my-repo');
653
+ * // Get only function callers (not class methods)
654
+ * const callers = getCallersFiltered('./my-repo', 'authenticate', {
655
+ * kinds: ['function']
656
+ * });
657
+ * ```
658
+ */
659
+ export declare function getCallersFiltered(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Array<SymbolInfo>
660
+ /**
661
+ * Get callees of a symbol with filtering
662
+ *
663
+ * Like `getCallees`, but allows filtering results by symbol kind.
664
+ *
665
+ * # Arguments
666
+ * * `path` - Path to repository root
667
+ * * `symbol_name` - Name of the symbol to find callees for
668
+ * * `filter` - Optional filter for symbol kinds
669
+ *
670
+ * # Returns
671
+ * Array of filtered called symbols
672
+ *
673
+ * # Example
674
+ * ```javascript
675
+ * const { getCalleesFiltered, buildIndex } = require('infiniloom-node');
676
+ *
677
+ * buildIndex('./my-repo');
678
+ * // Get only function calls (not method calls)
679
+ * const callees = getCalleesFiltered('./my-repo', 'main', {
680
+ * kinds: ['function']
681
+ * });
682
+ * ```
683
+ */
684
+ export declare function getCalleesFiltered(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Array<SymbolInfo>
685
+ /**
686
+ * Get references to a symbol with filtering
687
+ *
688
+ * Like `getReferences`, but allows filtering results by symbol kind.
689
+ *
690
+ * # Arguments
691
+ * * `path` - Path to repository root
692
+ * * `symbol_name` - Name of the symbol to find references for
693
+ * * `filter` - Optional filter for referencing symbol kinds
694
+ *
695
+ * # Returns
696
+ * Array of filtered reference information
697
+ *
698
+ * # Example
699
+ * ```javascript
700
+ * const { getReferencesFiltered, buildIndex } = require('infiniloom-node');
701
+ *
702
+ * buildIndex('./my-repo');
703
+ * // Get only call references from functions
704
+ * const refs = getReferencesFiltered('./my-repo', 'UserService', {
705
+ * kinds: ['function', 'method'],
706
+ * excludeKinds: ['import']
707
+ * });
708
+ * ```
709
+ */
710
+ export declare function getReferencesFiltered(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Array<ReferenceInfo>
711
+ /** Async version of findSymbolFiltered */
712
+ export declare function findSymbolFilteredAsync(path: string, name: string, filter?: QueryFilter | undefined | null): Promise<Array<SymbolInfo>>
713
+ /** Async version of getCallersFiltered */
714
+ export declare function getCallersFilteredAsync(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Promise<Array<SymbolInfo>>
715
+ /** Async version of getCalleesFiltered */
716
+ export declare function getCalleesFilteredAsync(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Promise<Array<SymbolInfo>>
717
+ /** Async version of getReferencesFiltered */
718
+ export declare function getReferencesFilteredAsync(path: string, symbolName: string, filter?: QueryFilter | undefined | null): Promise<Array<ReferenceInfo>>
561
719
  /**
562
720
  * Get the complete call graph
563
721
  *
@@ -613,6 +771,8 @@ export interface ChunkOptions {
613
771
  format?: string
614
772
  /** Sort chunks by priority (core modules first) */
615
773
  priorityFirst?: boolean
774
+ /** Directories/patterns to exclude (e.g., ["vendor", "generated", "*.test.*"]) */
775
+ exclude?: Array<string>
616
776
  }
617
777
  /** A chunk of repository content */
618
778
  export interface RepoChunk {
@@ -664,6 +824,12 @@ export interface ImpactOptions {
664
824
  depth?: number
665
825
  /** Include test files in analysis */
666
826
  includeTests?: boolean
827
+ /** Target model for token counting (default: "claude") */
828
+ model?: string
829
+ /** Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"]) */
830
+ exclude?: Array<string>
831
+ /** Glob patterns to include (e.g., ["src/**/*.ts"]) */
832
+ include?: Array<string>
667
833
  }
668
834
  /** Symbol affected by a change */
669
835
  export interface AffectedSymbol {
@@ -730,6 +896,12 @@ export interface DiffContextOptions {
730
896
  includeDiff?: boolean
731
897
  /** Output format: "xml", "markdown", "json" (default: "xml") */
732
898
  format?: string
899
+ /** Target model for token counting (default: "claude") */
900
+ model?: string
901
+ /** Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"]) */
902
+ exclude?: Array<string>
903
+ /** Glob patterns to include (e.g., ["src/**/*.ts"]) */
904
+ include?: Array<string>
733
905
  }
734
906
  /** Context-aware diff result */
735
907
  export interface DiffContextResult {
package/index.js CHANGED
@@ -310,7 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { pack, scan, scanWithOptions, countTokens, Infiniloom, semanticCompress, isGitRepo, GitRepo, scanSecurity, buildIndex, indexStatus, findSymbol, getCallers, getCallees, getReferences, getCallGraph, findSymbolAsync, getCallersAsync, getCalleesAsync, getReferencesAsync, getCallGraphAsync, chunk, analyzeImpact, getDiffContext, packAsync, scanAsync, buildIndexAsync, chunkAsync, analyzeImpactAsync, getDiffContextAsync, getSymbolsInFile, getSymbolSource, getChangedSymbols, getTestsForFile, getCallSites, getSymbolsInFileAsync, getSymbolSourceAsync, getChangedSymbolsAsync, getTestsForFileAsync, getCallSitesAsync, getChangedSymbolsFiltered, getTransitiveCallers, getCallSitesWithContext, getChangedSymbolsFilteredAsync, getTransitiveCallersAsync, getCallSitesWithContextAsync } = nativeBinding
313
+ const { pack, scan, scanWithOptions, countTokens, Infiniloom, semanticCompress, isGitRepo, GitRepo, scanSecurity, buildIndex, indexStatus, findSymbol, getCallers, getCallees, getReferences, findSymbolFiltered, getCallersFiltered, getCalleesFiltered, getReferencesFiltered, findSymbolFilteredAsync, getCallersFilteredAsync, getCalleesFilteredAsync, getReferencesFilteredAsync, getCallGraph, findSymbolAsync, getCallersAsync, getCalleesAsync, getReferencesAsync, getCallGraphAsync, chunk, analyzeImpact, getDiffContext, packAsync, scanAsync, buildIndexAsync, chunkAsync, analyzeImpactAsync, getDiffContextAsync, getSymbolsInFile, getSymbolSource, getChangedSymbols, getTestsForFile, getCallSites, getSymbolsInFileAsync, getSymbolSourceAsync, getChangedSymbolsAsync, getTestsForFileAsync, getCallSitesAsync, getChangedSymbolsFiltered, getTransitiveCallers, getCallSitesWithContext, getChangedSymbolsFilteredAsync, getTransitiveCallersAsync, getCallSitesWithContextAsync } = nativeBinding
314
314
 
315
315
  module.exports.pack = pack
316
316
  module.exports.scan = scan
@@ -327,6 +327,14 @@ module.exports.findSymbol = findSymbol
327
327
  module.exports.getCallers = getCallers
328
328
  module.exports.getCallees = getCallees
329
329
  module.exports.getReferences = getReferences
330
+ module.exports.findSymbolFiltered = findSymbolFiltered
331
+ module.exports.getCallersFiltered = getCallersFiltered
332
+ module.exports.getCalleesFiltered = getCalleesFiltered
333
+ module.exports.getReferencesFiltered = getReferencesFiltered
334
+ module.exports.findSymbolFilteredAsync = findSymbolFilteredAsync
335
+ module.exports.getCallersFilteredAsync = getCallersFilteredAsync
336
+ module.exports.getCalleesFilteredAsync = getCalleesFilteredAsync
337
+ module.exports.getReferencesFilteredAsync = getReferencesFilteredAsync
330
338
  module.exports.getCallGraph = getCallGraph
331
339
  module.exports.findSymbolAsync = findSymbolAsync
332
340
  module.exports.getCallersAsync = getCallersAsync
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.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "Node.js bindings for infiniloom - Repository context engine for LLMs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",