infiniloom-node 0.4.7 → 0.4.9

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
 
@@ -199,9 +199,9 @@ Compress text using semantic compression while preserving important content.
199
199
  **Parameters:**
200
200
  - `text` - Text to compress
201
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.
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
 
@@ -567,7 +567,7 @@ interface PackOptions {
567
567
  exclude?: string[]; // Glob patterns to exclude (e.g., ["**/*.test.ts"])
568
568
  includeTests?: boolean; // Include test files (default: false)
569
569
  securityThreshold?: string;// Minimum severity to block: "critical", "high", "medium", "low"
570
- tokenBudget?: number; // Limit total output tokens (0 = no limit)
570
+ tokenBudget?: number; // Limit total output tokens (0 = no limit, negative values rejected)
571
571
  // Git-based filtering options (PR review integration)
572
572
  changedOnly?: boolean; // Only include files changed in git
573
573
  baseSha?: string; // Base SHA/ref for diff comparison (e.g., "main", "HEAD~5")
package/index.d.ts CHANGED
@@ -3,6 +3,20 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ /**
7
+ * Get the package version
8
+ *
9
+ * # Returns
10
+ * The version string of the infiniloom-node package
11
+ *
12
+ * # Example
13
+ * ```javascript
14
+ * const { version } = require('infiniloom-node');
15
+ *
16
+ * console.log(`infiniloom-node v${version()}`);
17
+ * ```
18
+ */
19
+ export declare function version(): string
6
20
  /** Options for packing a repository */
7
21
  export interface PackOptions {
8
22
  /** Output format: "xml", "markdown", "json", "yaml", "toon", or "plain" */
@@ -29,7 +43,10 @@ export interface PackOptions {
29
43
  includeTests?: boolean
30
44
  /** Minimum security severity to block on: "critical", "high", "medium", "low" (default: "critical") */
31
45
  securityThreshold?: string
32
- /** Token budget for total output (0 = no limit). Files are included by importance until budget is reached. */
46
+ /**
47
+ * Token budget for total output (0 = no limit). Files are included by importance until budget is reached.
48
+ * Negative values are invalid and will throw an error.
49
+ */
33
50
  tokenBudget?: number
34
51
  /** Only include files changed in git (requires baseSha or uses uncommitted changes) */
35
52
  changedOnly?: boolean
@@ -107,12 +124,12 @@ export interface ScanOptions {
107
124
  * });
108
125
  * ```
109
126
  */
110
- export declare function pack(path: string, options?: PackOptions | undefined | null): string
127
+ export declare function pack(path?: string | undefined | null, options?: PackOptions | undefined | null): string
111
128
  /**
112
129
  * Scan a repository and return statistics
113
130
  *
114
131
  * # Arguments
115
- * * `path` - Path to repository root
132
+ * * `path` - Path to repository root (null/undefined returns error)
116
133
  * * `model` - Optional target model (default: "claude") - for backwards compatibility
117
134
  *
118
135
  * # Returns
@@ -127,7 +144,7 @@ export declare function pack(path: string, options?: PackOptions | undefined | n
127
144
  * console.log(`Total tokens: ${stats.totalTokens}`);
128
145
  * ```
129
146
  */
130
- export declare function scan(path: string, model?: string | undefined | null): ScanStats
147
+ export declare function scan(path?: string | undefined | null, model?: string | undefined | null): ScanStats
131
148
  /**
132
149
  * Scan a repository with full options
133
150
  *
@@ -154,7 +171,7 @@ export declare function scanWithOptions(path: string, options?: ScanOptions | un
154
171
  * Count tokens in text for a specific model
155
172
  *
156
173
  * # Arguments
157
- * * `text` - Text to tokenize
174
+ * * `text` - Text to tokenize (null/undefined returns 0)
158
175
  * * `model` - Optional model name (default: "claude")
159
176
  *
160
177
  * # Returns
@@ -168,7 +185,7 @@ export declare function scanWithOptions(path: string, options?: ScanOptions | un
168
185
  * console.log(`Tokens: ${count}`);
169
186
  * ```
170
187
  */
171
- export declare function countTokens(text: string, model?: string | undefined | null): number
188
+ export declare function countTokens(text?: string | undefined | null, model?: string | undefined | null): number
172
189
  /**
173
190
  * Compress text using semantic compression
174
191
  *
@@ -196,14 +213,19 @@ export declare function countTokens(text: string, model?: string | undefined | n
196
213
  * ```javascript
197
214
  * const { semanticCompress } = require('infiniloom-node');
198
215
  *
199
- * // Compress to ~30% of original size
200
- * const compressed = semanticCompress(longText, 0.7, 0.3);
216
+ * // Using options object (recommended)
217
+ * const compressed = semanticCompress(longText, { budgetRatio: 0.3 });
201
218
  *
202
- * // Aggressive compression to ~20%
203
- * const veryCompressed = semanticCompress(longText, 0.7, 0.2);
219
+ * // With all options
220
+ * const custom = semanticCompress(longText, {
221
+ * similarityThreshold: 0.7,
222
+ * budgetRatio: 0.3,
223
+ * minChunkSize: 100,
224
+ * maxChunkSize: 2000
225
+ * });
204
226
  * ```
205
227
  */
206
- export declare function semanticCompress(text: string, similarityThreshold?: number | undefined | null, budgetRatio?: number | undefined | null): string
228
+ export declare function semanticCompress(text?: string | undefined | null, options?: SemanticCompressOptions | undefined | null): string
207
229
  /**
208
230
  * Check if a path is a git repository
209
231
  *
@@ -329,7 +351,7 @@ export interface SecurityFinding {
329
351
  * }
330
352
  * ```
331
353
  */
332
- export declare function scanSecurity(path: string): Array<SecurityFinding>
354
+ export declare function scanSecurity(path?: string | undefined | null): Array<SecurityFinding>
333
355
  /** Options for building an index */
334
356
  export interface IndexOptions {
335
357
  /** Force full rebuild even if index exists */
@@ -485,6 +507,45 @@ export interface CallGraphOptions {
485
507
  /** Maximum number of edges to return (default: unlimited) */
486
508
  maxEdges?: number
487
509
  }
510
+ /** Result from getSymbolSource containing source code and metadata */
511
+ export interface SymbolSourceResult {
512
+ /** The source code of the symbol */
513
+ source: string
514
+ /** Path to the file containing the symbol (relative to repo root) */
515
+ path: string
516
+ /** Start line number (1-indexed) */
517
+ startLine: number
518
+ /** End line number (1-indexed) */
519
+ endLine: number
520
+ /** Symbol name */
521
+ name: string
522
+ /** Symbol kind (function, method, class, etc.) */
523
+ kind: string
524
+ }
525
+ /** Options for generateMap */
526
+ export interface GenerateMapOptions {
527
+ /** Token budget for the map (default: 2000) */
528
+ budget?: number
529
+ /** Maximum number of symbols to include (default: 50) */
530
+ maxSymbols?: number
531
+ }
532
+ /** Options for semanticCompress */
533
+ export interface SemanticCompressOptions {
534
+ /**
535
+ * Threshold for grouping similar chunks (0.0-1.0, default: 0.7)
536
+ * Note: Only affects output when built with "embeddings" feature.
537
+ */
538
+ similarityThreshold?: number
539
+ /**
540
+ * Target size as ratio of original (0.0-1.0, default: 0.5)
541
+ * Lower values = more aggressive compression
542
+ */
543
+ budgetRatio?: number
544
+ /** Minimum chunk size in characters (default: 100) */
545
+ minChunkSize?: number
546
+ /** Maximum chunk size in characters (default: 2000) */
547
+ maxChunkSize?: number
548
+ }
488
549
  /**
489
550
  * Feature #2: Filter options for symbol queries
490
551
  *
@@ -506,8 +567,8 @@ export interface QueryFilter {
506
567
  * Requires an index to be built first (use `buildIndex`).
507
568
  *
508
569
  * # Arguments
509
- * * `path` - Path to repository root
510
- * * `name` - Symbol name to search for
570
+ * * `path` - Path to repository root (null/undefined returns error)
571
+ * * `name` - Symbol name to search for (null/undefined returns error)
511
572
  *
512
573
  * # Returns
513
574
  * Array of matching symbols
@@ -521,7 +582,7 @@ export interface QueryFilter {
521
582
  * console.log(`Found ${symbols.length} symbols named processRequest`);
522
583
  * ```
523
584
  */
524
- export declare function findSymbol(path: string, name: string): Array<SymbolInfo>
585
+ export declare function findSymbol(path?: string | undefined | null, name?: string | undefined | null): Array<SymbolInfo>
525
586
  /**
526
587
  * Get all callers of a symbol
527
588
  *
@@ -529,8 +590,8 @@ export declare function findSymbol(path: string, name: string): Array<SymbolInfo
529
590
  * Requires an index to be built first (use `buildIndex`).
530
591
  *
531
592
  * # Arguments
532
- * * `path` - Path to repository root
533
- * * `symbol_name` - Name of the symbol to find callers for
593
+ * * `path` - Path to repository root (null/undefined returns error)
594
+ * * `symbol_name` - Name of the symbol to find callers for (null/undefined returns error)
534
595
  *
535
596
  * # Returns
536
597
  * Array of symbols that call the target symbol
@@ -547,7 +608,7 @@ export declare function findSymbol(path: string, name: string): Array<SymbolInfo
547
608
  * }
548
609
  * ```
549
610
  */
550
- export declare function getCallers(path: string, symbolName: string): Array<SymbolInfo>
611
+ export declare function getCallers(path?: string | undefined | null, symbolName?: string | undefined | null): Array<SymbolInfo>
551
612
  /**
552
613
  * Get all callees of a symbol
553
614
  *
@@ -555,8 +616,8 @@ export declare function getCallers(path: string, symbolName: string): Array<Symb
555
616
  * Requires an index to be built first (use `buildIndex`).
556
617
  *
557
618
  * # Arguments
558
- * * `path` - Path to repository root
559
- * * `symbol_name` - Name of the symbol to find callees for
619
+ * * `path` - Path to repository root (null/undefined returns error)
620
+ * * `symbol_name` - Name of the symbol to find callees for (null/undefined returns error)
560
621
  *
561
622
  * # Returns
562
623
  * Array of symbols that the target symbol calls
@@ -573,7 +634,7 @@ export declare function getCallers(path: string, symbolName: string): Array<Symb
573
634
  * }
574
635
  * ```
575
636
  */
576
- export declare function getCallees(path: string, symbolName: string): Array<SymbolInfo>
637
+ export declare function getCallees(path?: string | undefined | null, symbolName?: string | undefined | null): Array<SymbolInfo>
577
638
  /**
578
639
  * Get all references to a symbol
579
640
  *
@@ -599,7 +660,7 @@ export declare function getCallees(path: string, symbolName: string): Array<Symb
599
660
  * }
600
661
  * ```
601
662
  */
602
- export declare function getReferences(path: string, symbolName: string): Array<ReferenceInfo>
663
+ export declare function getReferences(path?: string | undefined | null, symbolName?: string | undefined | null): Array<ReferenceInfo>
603
664
  /**
604
665
  * Find symbols by name with filtering
605
666
  *
@@ -743,17 +804,17 @@ export declare function getReferencesFilteredAsync(path: string, symbolName: str
743
804
  * console.log('Most called functions:', sorted.slice(0, 10));
744
805
  * ```
745
806
  */
746
- export declare function getCallGraph(path: string, options?: CallGraphOptions | undefined | null): CallGraph
807
+ export declare function getCallGraph(path?: string | undefined | null, options?: CallGraphOptions | undefined | null): CallGraph
747
808
  /** Async version of findSymbol */
748
- export declare function findSymbolAsync(path: string, name: string): Promise<Array<SymbolInfo>>
809
+ export declare function findSymbolAsync(path?: string | undefined | null, name?: string | undefined | null): Promise<Array<SymbolInfo>>
749
810
  /** Async version of getCallers */
750
- export declare function getCallersAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
811
+ export declare function getCallersAsync(path?: string | undefined | null, symbolName?: string | undefined | null): Promise<Array<SymbolInfo>>
751
812
  /** Async version of getCallees */
752
- export declare function getCalleesAsync(path: string, symbolName: string): Promise<Array<SymbolInfo>>
813
+ export declare function getCalleesAsync(path?: string | undefined | null, symbolName?: string | undefined | null): Promise<Array<SymbolInfo>>
753
814
  /** Async version of getReferences */
754
- export declare function getReferencesAsync(path: string, symbolName: string): Promise<Array<ReferenceInfo>>
815
+ export declare function getReferencesAsync(path?: string | undefined | null, symbolName?: string | undefined | null): Promise<Array<ReferenceInfo>>
755
816
  /** Async version of getCallGraph */
756
- export declare function getCallGraphAsync(path: string, options?: CallGraphOptions | undefined | null): Promise<CallGraph>
817
+ export declare function getCallGraphAsync(path?: string | undefined | null, options?: CallGraphOptions | undefined | null): Promise<CallGraph>
757
818
  /** Options for chunking a repository */
758
819
  export interface ChunkOptions {
759
820
  /** Chunking strategy: "fixed", "file", "module", "symbol", "semantic", "dependency" */
@@ -821,6 +882,12 @@ export interface ImpactOptions {
821
882
  depth?: number
822
883
  /** Include test files in analysis */
823
884
  includeTests?: boolean
885
+ /** Target model for token counting (default: "claude") */
886
+ model?: string
887
+ /** Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"]) */
888
+ exclude?: Array<string>
889
+ /** Glob patterns to include (e.g., ["src/**/*.ts"]) */
890
+ include?: Array<string>
824
891
  }
825
892
  /** Symbol affected by a change */
826
893
  export interface AffectedSymbol {
@@ -887,6 +954,12 @@ export interface DiffContextOptions {
887
954
  includeDiff?: boolean
888
955
  /** Output format: "xml", "markdown", "json" (default: "xml") */
889
956
  format?: string
957
+ /** Target model for token counting (default: "claude") */
958
+ model?: string
959
+ /** Glob patterns to exclude (e.g., ["**/*.test.ts", "dist/**"]) */
960
+ exclude?: Array<string>
961
+ /** Glob patterns to include (e.g., ["src/**/*.ts"]) */
962
+ include?: Array<string>
890
963
  }
891
964
  /** Context-aware diff result */
892
965
  export interface DiffContextResult {
@@ -973,7 +1046,7 @@ export declare function getDiffContext(path: string, fromRef: string, toRef: str
973
1046
  * const context = await packAsync('./my-repo', { format: 'xml' });
974
1047
  * ```
975
1048
  */
976
- export declare function packAsync(path: string, options?: PackOptions | undefined | null): Promise<string>
1049
+ export declare function packAsync(path?: string | undefined | null, options?: PackOptions | undefined | null): Promise<string>
977
1050
  /**
978
1051
  * Async version of scan
979
1052
  *
@@ -984,7 +1057,7 @@ export declare function packAsync(path: string, options?: PackOptions | undefine
984
1057
  * const stats = await scanAsync('./my-repo', 'claude');
985
1058
  * ```
986
1059
  */
987
- export declare function scanAsync(path: string, model?: string | undefined | null): Promise<ScanStats>
1060
+ export declare function scanAsync(path?: string | undefined | null, model?: string | undefined | null): Promise<ScanStats>
988
1061
  /**
989
1062
  * Async version of buildIndex
990
1063
  *
@@ -1098,11 +1171,12 @@ export declare function getSymbolsInFile(path: string, filePath: string, filter?
1098
1171
  * const { getSymbolSource, buildIndex } = require('infiniloom-node');
1099
1172
  *
1100
1173
  * buildIndex('./my-repo');
1101
- * const source = getSymbolSource('./my-repo', 'authenticate', 'src/auth.ts');
1102
- * console.log(source);
1174
+ * const result = getSymbolSource('./my-repo', 'authenticate', 'src/auth.ts');
1175
+ * console.log(`Source at ${result.path}:${result.startLine}`);
1176
+ * console.log(result.source);
1103
1177
  * ```
1104
1178
  */
1105
- export declare function getSymbolSource(path: string, symbolName: string, filePath?: string | undefined | null): string
1179
+ export declare function getSymbolSource(path?: string | undefined | null, symbolName?: string | undefined | null, filePath?: string | undefined | null): SymbolSourceResult
1106
1180
  /**
1107
1181
  * Get symbols that were changed in a diff
1108
1182
  *
@@ -1193,7 +1267,7 @@ export declare function getCallSites(path: string, symbolName: string): Array<Ca
1193
1267
  /** Async version of getSymbolsInFile */
1194
1268
  export declare function getSymbolsInFileAsync(path: string, filePath: string, filter?: SymbolFilter | undefined | null): Promise<Array<SymbolInfo>>
1195
1269
  /** Async version of getSymbolSource */
1196
- export declare function getSymbolSourceAsync(path: string, symbolName: string, filePath?: string | undefined | null): Promise<string>
1270
+ export declare function getSymbolSourceAsync(path?: string | undefined | null, symbolName?: string | undefined | null, filePath?: string | undefined | null): Promise<SymbolSourceResult>
1197
1271
  /** Async version of getChangedSymbols */
1198
1272
  export declare function getChangedSymbolsAsync(path: string, fromRef: string, toRef: string): Promise<Array<SymbolInfo>>
1199
1273
  /** Async version of getTestsForFile */
@@ -1391,10 +1465,15 @@ export declare class Infiniloom {
1391
1465
  * Generate a repository map
1392
1466
  *
1393
1467
  * # Arguments
1394
- * * `budget` - Token budget (default: 2000)
1395
- * * `max_symbols` - Maximum symbols (default: 50)
1468
+ * * `options` - Options object with budget (default: 2000) and maxSymbols (default: 50)
1469
+ *
1470
+ * # Example
1471
+ * ```javascript
1472
+ * const loom = new Infiniloom('./my-repo');
1473
+ * const map = loom.generateMap({ budget: 3000, maxSymbols: 100 });
1474
+ * ```
1396
1475
  */
1397
- generateMap(budget?: number | undefined | null, maxSymbols?: number | undefined | null): string
1476
+ generateMap(options?: GenerateMapOptions | undefined | null): string
1398
1477
  /** Pack repository with specific options */
1399
1478
  pack(options?: PackOptions | undefined | null): string
1400
1479
  /** Check for security issues (Bug #8 fix - now returns structured findings) */
@@ -1428,9 +1507,9 @@ export declare class GitRepo {
1428
1507
  * * `path` - Path to the repository
1429
1508
  *
1430
1509
  * # Throws
1431
- * Error if path is not a git repository
1510
+ * Error if path is null/undefined or not a git repository
1432
1511
  */
1433
- constructor(path: string)
1512
+ constructor(path?: string | undefined | null)
1434
1513
  /**
1435
1514
  * Get the current branch name
1436
1515
  *
package/index.js CHANGED
@@ -310,8 +310,9 @@ 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, 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
313
+ const { version, 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
+ module.exports.version = version
315
316
  module.exports.pack = pack
316
317
  module.exports.scan = scan
317
318
  module.exports.scanWithOptions = scanWithOptions
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.7",
3
+ "version": "0.4.9",
4
4
  "description": "Node.js bindings for infiniloom - Repository context engine for LLMs",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",