infiniloom-node 0.6.1 → 0.6.3

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/tsconfig.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "module": "commonjs",
6
+ "moduleResolution": "node",
7
+ "lib": ["ES2020"],
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "outDir": ".",
11
+ "strict": true,
12
+ "strictNullChecks": true,
13
+ "strictFunctionTypes": true,
14
+ "strictBindCallApply": true,
15
+ "strictPropertyInitialization": true,
16
+ "noImplicitAny": true,
17
+ "noImplicitThis": true,
18
+ "noImplicitReturns": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true,
22
+ "noUncheckedIndexedAccess": true,
23
+ "exactOptionalPropertyTypes": true,
24
+ "esModuleInterop": true,
25
+ "allowSyntheticDefaultImports": true,
26
+ "skipLibCheck": true,
27
+ "forceConsistentCasingInFileNames": true,
28
+ "resolveJsonModule": true,
29
+ "isolatedModules": true
30
+ },
31
+ "include": [
32
+ "types.ts",
33
+ "schemas.ts"
34
+ ],
35
+ "exclude": [
36
+ "node_modules",
37
+ "*.node",
38
+ "*.js"
39
+ ]
40
+ }
package/types.ts ADDED
@@ -0,0 +1,588 @@
1
+ /**
2
+ * Strict TypeScript types for infiniloom-node
3
+ *
4
+ * These types provide string literal unions for better type safety
5
+ * compared to the auto-generated index.d.ts which uses generic strings.
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import type { StrictPackOptions, OutputFormat, TokenizerModel } from 'infiniloom-node/types';
10
+ * import { pack } from 'infiniloom-node';
11
+ *
12
+ * const options: StrictPackOptions = {
13
+ * format: 'xml', // Type-checked!
14
+ * model: 'claude',
15
+ * compression: 'balanced'
16
+ * };
17
+ *
18
+ * const output = pack('./repo', options);
19
+ * ```
20
+ */
21
+
22
+ // Re-export base types from auto-generated index
23
+ export type {
24
+ ScanStats,
25
+ LanguageStat,
26
+ GitFileStatus,
27
+ GitChangedFile,
28
+ GitCommit,
29
+ GitBlameLine,
30
+ GitDiffLine,
31
+ GitDiffHunk,
32
+ SecurityFinding,
33
+ IndexStatus,
34
+ SymbolInfo,
35
+ ReferenceInfo,
36
+ CallGraphEdge,
37
+ CallGraphStats,
38
+ CallGraph,
39
+ DependencyCycle,
40
+ SymbolSourceResult,
41
+ RepoChunk,
42
+ AffectedSymbol,
43
+ DiffFileContext,
44
+ ContextSymbolInfo,
45
+ CallSite,
46
+ CallSiteWithContext,
47
+ ChangedSymbolInfo,
48
+ TransitiveCallerInfo,
49
+ EmbedChunkSource,
50
+ EmbedChunkContext,
51
+ EmbedChunkPart,
52
+ EmbedChunk,
53
+ EmbedDiffSummary,
54
+ EmbedResult,
55
+ EmbedManifestStatus,
56
+ JsTypeInfo,
57
+ JsParameterInfo,
58
+ JsGenericParam,
59
+ JsTypeSignature,
60
+ JsParamDoc,
61
+ JsReturnDoc,
62
+ JsThrowsDoc,
63
+ JsExample,
64
+ JsDocumentation,
65
+ JsAncestorInfo,
66
+ JsTypeHierarchy,
67
+ JsHalsteadMetrics,
68
+ JsLocMetrics,
69
+ JsComplexityMetrics,
70
+ JsUnusedExport,
71
+ JsUnreachableCode,
72
+ JsUnusedSymbol,
73
+ JsUnusedImport,
74
+ JsUnusedVariable,
75
+ JsDeadCodeInfo,
76
+ JsBreakingChange,
77
+ JsBreakingChangeSummary,
78
+ JsBreakingChangeReport,
79
+ JsRepoEntry,
80
+ JsCrossRepoLink,
81
+ JsUnifiedSymbolRef,
82
+ JsMultiRepoStats,
83
+ } from './index';
84
+
85
+ // ============================================================================
86
+ // String Literal Union Types
87
+ // ============================================================================
88
+
89
+ /**
90
+ * Output format for pack/chunk operations
91
+ * - xml: Optimized for Claude (CDATA sections, structured XML)
92
+ * - markdown: Optimized for GPT models (fenced code blocks)
93
+ * - json: Machine-readable JSON format
94
+ * - yaml: Optimized for Gemini (query at end)
95
+ * - toon: Token-efficient format (30-40% fewer tokens)
96
+ * - plain: Plain text format
97
+ */
98
+ export type OutputFormat = 'xml' | 'markdown' | 'json' | 'yaml' | 'toon' | 'plain';
99
+
100
+ /**
101
+ * Supported LLM tokenizer models
102
+ *
103
+ * OpenAI models (exact via tiktoken):
104
+ * - gpt-5.2, gpt-5.1, gpt-5, o4-mini, o3, o1, gpt-4o, gpt-4o-mini: o200k_base encoding
105
+ * - gpt-4, gpt-4-turbo, gpt-3.5-turbo: cl100k_base encoding
106
+ *
107
+ * Other models (calibrated estimation):
108
+ * - claude: Anthropic Claude models
109
+ * - gemini, gemini-1.5, gemini-2.0: Google Gemini models
110
+ * - llama, llama-3, llama-3.1, llama-3.2, codellama: Meta Llama models
111
+ * - mistral, mixtral: Mistral AI models
112
+ * - deepseek, deepseek-v3: DeepSeek models
113
+ * - qwen, qwen-2.5: Alibaba Qwen models
114
+ * - cohere, command-r: Cohere models
115
+ * - grok: xAI Grok models
116
+ */
117
+ export type TokenizerModel =
118
+ // OpenAI models (exact tokenization via tiktoken)
119
+ | 'gpt-5.2'
120
+ | 'gpt-5.2-pro'
121
+ | 'gpt-5.1'
122
+ | 'gpt-5.1-mini'
123
+ | 'gpt-5.1-codex'
124
+ | 'gpt-5'
125
+ | 'gpt-5-mini'
126
+ | 'gpt-5-nano'
127
+ | 'o4-mini'
128
+ | 'o3'
129
+ | 'o3-mini'
130
+ | 'o1'
131
+ | 'o1-mini'
132
+ | 'o1-preview'
133
+ | 'gpt-4o'
134
+ | 'gpt-4o-mini'
135
+ | 'gpt-4'
136
+ | 'gpt-4-turbo'
137
+ | 'gpt-3.5-turbo'
138
+ // Anthropic
139
+ | 'claude'
140
+ // Google
141
+ | 'gemini'
142
+ | 'gemini-1.5'
143
+ | 'gemini-2.0'
144
+ // Meta
145
+ | 'llama'
146
+ | 'llama-3'
147
+ | 'llama-3.1'
148
+ | 'llama-3.2'
149
+ | 'codellama'
150
+ // Mistral
151
+ | 'mistral'
152
+ | 'mixtral'
153
+ // DeepSeek
154
+ | 'deepseek'
155
+ | 'deepseek-v3'
156
+ // Alibaba
157
+ | 'qwen'
158
+ | 'qwen-2.5'
159
+ // Cohere
160
+ | 'cohere'
161
+ | 'command-r'
162
+ // xAI
163
+ | 'grok';
164
+
165
+ /**
166
+ * Compression level for output
167
+ * - none: No compression, full output
168
+ * - minimal: Light compression (remove blank lines)
169
+ * - balanced: Moderate compression (recommended)
170
+ * - aggressive: Heavy compression (remove comments, simplify)
171
+ * - extreme: Maximum compression (signatures only)
172
+ * - focused: Focus on key symbols
173
+ * - semantic: AI-aware semantic compression
174
+ */
175
+ export type CompressionLevel =
176
+ | 'none'
177
+ | 'minimal'
178
+ | 'balanced'
179
+ | 'aggressive'
180
+ | 'extreme'
181
+ | 'focused'
182
+ | 'semantic';
183
+
184
+ /**
185
+ * Security severity levels
186
+ */
187
+ export type SecuritySeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
188
+
189
+ /**
190
+ * Git file status
191
+ */
192
+ export type GitStatus = 'Added' | 'Modified' | 'Deleted' | 'Renamed' | 'Copied' | 'Unknown';
193
+
194
+ /**
195
+ * Diff line change type
196
+ */
197
+ export type DiffChangeType = 'add' | 'remove' | 'context';
198
+
199
+ /**
200
+ * Symbol kinds (matches Rust SymbolKind enum)
201
+ */
202
+ export type SymbolKind =
203
+ | 'function'
204
+ | 'method'
205
+ | 'class'
206
+ | 'struct'
207
+ | 'interface'
208
+ | 'trait'
209
+ | 'enum'
210
+ | 'constant'
211
+ | 'variable'
212
+ | 'import'
213
+ | 'export'
214
+ | 'type'
215
+ | 'module'
216
+ | 'macro';
217
+
218
+ /**
219
+ * Symbol visibility
220
+ */
221
+ export type Visibility = 'public' | 'private' | 'protected' | 'internal';
222
+
223
+ /**
224
+ * Impact type for affected symbols
225
+ */
226
+ export type ImpactType = 'direct' | 'caller' | 'callee' | 'dependent';
227
+
228
+ /**
229
+ * Impact level for analysis results
230
+ */
231
+ export type ImpactLevel = 'low' | 'medium' | 'high' | 'critical';
232
+
233
+ /**
234
+ * Reference kind
235
+ */
236
+ export type ReferenceKind = 'call' | 'import' | 'inherit' | 'implement';
237
+
238
+ /**
239
+ * Context symbol reason
240
+ */
241
+ export type ContextReason = 'changed' | 'caller' | 'callee' | 'dependent';
242
+
243
+ /**
244
+ * Change type for symbols
245
+ */
246
+ export type ChangeType = 'added' | 'modified' | 'deleted';
247
+
248
+ /**
249
+ * Chunking strategy
250
+ */
251
+ export type ChunkStrategy =
252
+ | 'fixed'
253
+ | 'file'
254
+ | 'module'
255
+ | 'symbol'
256
+ | 'semantic'
257
+ | 'dependency';
258
+
259
+ /**
260
+ * Embed chunk kind (matches Rust ChunkKind enum)
261
+ */
262
+ export type EmbedChunkKind =
263
+ | 'function'
264
+ | 'method'
265
+ | 'class'
266
+ | 'struct'
267
+ | 'enum'
268
+ | 'interface'
269
+ | 'trait'
270
+ | 'module'
271
+ | 'constant'
272
+ | 'variable'
273
+ | 'imports'
274
+ | 'top_level'
275
+ | 'function_part'
276
+ | 'class_part';
277
+
278
+ /**
279
+ * Breaking change type
280
+ */
281
+ export type BreakingChangeType =
282
+ | 'removed'
283
+ | 'signature_changed'
284
+ | 'type_changed'
285
+ | 'visibility_reduced'
286
+ | 'parameter_added'
287
+ | 'parameter_removed'
288
+ | 'return_type_changed';
289
+
290
+ /**
291
+ * Breaking change severity
292
+ */
293
+ export type ChangeSeverity = 'critical' | 'high' | 'medium' | 'low';
294
+
295
+ /**
296
+ * Cross-repo link type
297
+ */
298
+ export type CrossRepoLinkType = 'import' | 'call' | 'inherit' | 'implement';
299
+
300
+ /**
301
+ * Variance for generic parameters
302
+ */
303
+ export type GenericVariance = 'invariant' | 'covariant' | 'contravariant' | 'bivariant';
304
+
305
+ /**
306
+ * Parameter kind
307
+ */
308
+ export type ParameterKind = 'positional' | 'named' | 'rest' | 'keyword_only' | 'positional_only';
309
+
310
+ // ============================================================================
311
+ // Strict Option Interfaces
312
+ // ============================================================================
313
+
314
+ /**
315
+ * Strict pack options with literal union types
316
+ */
317
+ export interface StrictPackOptions {
318
+ /** Output format with strict typing */
319
+ format?: OutputFormat;
320
+ /** Target model with strict typing */
321
+ model?: TokenizerModel;
322
+ /** Compression level with strict typing */
323
+ compression?: CompressionLevel;
324
+ /** Token budget for repository map */
325
+ mapBudget?: number;
326
+ /** Maximum number of symbols in map */
327
+ maxSymbols?: number;
328
+ /** Skip security scanning */
329
+ skipSecurity?: boolean;
330
+ /** Redact detected secrets in output */
331
+ redactSecrets?: boolean;
332
+ /** Skip symbol extraction */
333
+ skipSymbols?: boolean;
334
+ /** Glob patterns to include */
335
+ include?: readonly string[];
336
+ /** Glob patterns to exclude */
337
+ exclude?: readonly string[];
338
+ /** Include test files */
339
+ includeTests?: boolean;
340
+ /** Minimum security severity to block on */
341
+ securityThreshold?: SecuritySeverity;
342
+ /** Token budget for total output (0 = no limit) */
343
+ tokenBudget?: number;
344
+ /** Only include files changed in git */
345
+ changedOnly?: boolean;
346
+ /** Base SHA/ref for diff comparison */
347
+ baseSha?: string;
348
+ /** Head SHA/ref for diff comparison */
349
+ headSha?: string;
350
+ /** Include staged changes only */
351
+ stagedOnly?: boolean;
352
+ /** Include related files */
353
+ includeRelated?: boolean;
354
+ /** Depth for related file traversal (1-3) */
355
+ relatedDepth?: 1 | 2 | 3;
356
+ }
357
+
358
+ /**
359
+ * Strict scan options with literal union types
360
+ */
361
+ export interface StrictScanOptions {
362
+ /** Target model for token counting */
363
+ model?: TokenizerModel;
364
+ /** Glob patterns to include */
365
+ include?: readonly string[];
366
+ /** Glob patterns to exclude */
367
+ exclude?: readonly string[];
368
+ /** Include test files */
369
+ includeTests?: boolean;
370
+ /** Apply default ignores */
371
+ applyDefaultIgnores?: boolean;
372
+ }
373
+
374
+ /**
375
+ * Strict chunk options with literal union types
376
+ */
377
+ export interface StrictChunkOptions {
378
+ /** Chunking strategy */
379
+ strategy?: ChunkStrategy;
380
+ /** Maximum tokens per chunk */
381
+ maxTokens?: number;
382
+ /** Token overlap between chunks */
383
+ overlap?: number;
384
+ /** Target model for token counting */
385
+ model?: TokenizerModel;
386
+ /** Output format */
387
+ format?: OutputFormat;
388
+ /** Sort chunks by priority */
389
+ priorityFirst?: boolean;
390
+ /** Directories/patterns to exclude */
391
+ exclude?: readonly string[];
392
+ }
393
+
394
+ /**
395
+ * Strict diff context options
396
+ */
397
+ export interface StrictDiffContextOptions {
398
+ /** Depth of context expansion (1-3) */
399
+ depth?: 1 | 2 | 3;
400
+ /** Token budget for context */
401
+ budget?: number;
402
+ /** Include the actual diff content */
403
+ includeDiff?: boolean;
404
+ /** Output format */
405
+ format?: OutputFormat;
406
+ /** Target model for token counting */
407
+ model?: TokenizerModel;
408
+ /** Glob patterns to exclude */
409
+ exclude?: readonly string[];
410
+ /** Glob patterns to include */
411
+ include?: readonly string[];
412
+ }
413
+
414
+ /**
415
+ * Strict impact options
416
+ */
417
+ export interface StrictImpactOptions {
418
+ /** Depth of dependency traversal (1-3) */
419
+ depth?: 1 | 2 | 3;
420
+ /** Include test files in analysis */
421
+ includeTests?: boolean;
422
+ /** Target model for token counting */
423
+ model?: TokenizerModel;
424
+ /** Glob patterns to exclude */
425
+ exclude?: readonly string[];
426
+ /** Glob patterns to include */
427
+ include?: readonly string[];
428
+ }
429
+
430
+ /**
431
+ * Strict embed options
432
+ */
433
+ export interface StrictEmbedOptions {
434
+ /** Maximum tokens per chunk */
435
+ maxTokens?: number;
436
+ /** Minimum tokens for a chunk */
437
+ minTokens?: number;
438
+ /** Lines of context around symbols */
439
+ contextLines?: number;
440
+ /** Include imports in chunks */
441
+ includeImports?: boolean;
442
+ /** Include top-level code */
443
+ includeTopLevel?: boolean;
444
+ /** Include test files */
445
+ includeTests?: boolean;
446
+ /** Enable secret scanning */
447
+ securityScan?: boolean;
448
+ /** Include patterns (glob) */
449
+ includePatterns?: readonly string[];
450
+ /** Exclude patterns (glob) */
451
+ excludePatterns?: readonly string[];
452
+ /** Path to manifest file */
453
+ manifestPath?: string;
454
+ /** Only return changed chunks (diff mode) */
455
+ diffOnly?: boolean;
456
+ }
457
+
458
+ /**
459
+ * Strict query filter
460
+ */
461
+ export interface StrictQueryFilter {
462
+ /** Filter by symbol kinds */
463
+ kinds?: readonly SymbolKind[];
464
+ /** Exclude specific kinds */
465
+ excludeKinds?: readonly SymbolKind[];
466
+ }
467
+
468
+ /**
469
+ * Strict symbol filter
470
+ */
471
+ export interface StrictSymbolFilter {
472
+ /** Filter by symbol kind */
473
+ kind?: SymbolKind;
474
+ /** Filter by visibility */
475
+ visibility?: Visibility;
476
+ }
477
+
478
+ /**
479
+ * Strict index options
480
+ */
481
+ export interface StrictIndexOptions {
482
+ /** Force full rebuild */
483
+ force?: boolean;
484
+ /** Include test files */
485
+ includeTests?: boolean;
486
+ /** Maximum file size to index (bytes) */
487
+ maxFileSize?: number;
488
+ /** Directories/patterns to exclude */
489
+ exclude?: readonly string[];
490
+ /** Incremental update */
491
+ incremental?: boolean;
492
+ }
493
+
494
+ // ============================================================================
495
+ // Type Guards
496
+ // ============================================================================
497
+
498
+ /**
499
+ * Type guard for OutputFormat
500
+ */
501
+ export function isOutputFormat(value: unknown): value is OutputFormat {
502
+ return (
503
+ typeof value === 'string' &&
504
+ ['xml', 'markdown', 'json', 'yaml', 'toon', 'plain'].includes(value)
505
+ );
506
+ }
507
+
508
+ /**
509
+ * Type guard for TokenizerModel
510
+ */
511
+ export function isTokenizerModel(value: unknown): value is TokenizerModel {
512
+ const models: TokenizerModel[] = [
513
+ // OpenAI models (exact tokenization via tiktoken)
514
+ 'gpt-5.2', 'gpt-5.2-pro', 'gpt-5.1', 'gpt-5.1-mini', 'gpt-5.1-codex',
515
+ 'gpt-5', 'gpt-5-mini', 'gpt-5-nano',
516
+ 'o4-mini', 'o3', 'o3-mini', 'o1', 'o1-mini', 'o1-preview',
517
+ 'gpt-4o', 'gpt-4o-mini', 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo',
518
+ // Anthropic
519
+ 'claude',
520
+ // Google
521
+ 'gemini', 'gemini-1.5', 'gemini-2.0',
522
+ // Meta
523
+ 'llama', 'llama-3', 'llama-3.1', 'llama-3.2', 'codellama',
524
+ // Mistral
525
+ 'mistral', 'mixtral',
526
+ // DeepSeek
527
+ 'deepseek', 'deepseek-v3',
528
+ // Alibaba
529
+ 'qwen', 'qwen-2.5',
530
+ // Cohere
531
+ 'cohere', 'command-r',
532
+ // xAI
533
+ 'grok',
534
+ ];
535
+ return typeof value === 'string' && models.includes(value as TokenizerModel);
536
+ }
537
+
538
+ /**
539
+ * Type guard for CompressionLevel
540
+ */
541
+ export function isCompressionLevel(value: unknown): value is CompressionLevel {
542
+ return (
543
+ typeof value === 'string' &&
544
+ ['none', 'minimal', 'balanced', 'aggressive', 'extreme', 'focused', 'semantic'].includes(value)
545
+ );
546
+ }
547
+
548
+ /**
549
+ * Type guard for SymbolKind
550
+ */
551
+ export function isSymbolKind(value: unknown): value is SymbolKind {
552
+ const kinds: SymbolKind[] = [
553
+ 'function', 'method', 'class', 'struct', 'interface', 'trait',
554
+ 'enum', 'constant', 'variable', 'import', 'export', 'type', 'module', 'macro',
555
+ ];
556
+ return typeof value === 'string' && kinds.includes(value as SymbolKind);
557
+ }
558
+
559
+ /**
560
+ * Type guard for SecuritySeverity
561
+ */
562
+ export function isSecuritySeverity(value: unknown): value is SecuritySeverity {
563
+ return (
564
+ typeof value === 'string' &&
565
+ ['critical', 'high', 'medium', 'low', 'info'].includes(value)
566
+ );
567
+ }
568
+
569
+ // ============================================================================
570
+ // Utility Types
571
+ // ============================================================================
572
+
573
+ /**
574
+ * Make specific properties required
575
+ */
576
+ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
577
+
578
+ /**
579
+ * Make all properties readonly and non-nullable
580
+ */
581
+ export type Strict<T> = {
582
+ readonly [P in keyof T]-?: NonNullable<T[P]>;
583
+ };
584
+
585
+ /**
586
+ * Extract the element type from an array type
587
+ */
588
+ export type ElementOf<T> = T extends readonly (infer E)[] ? E : never;
Binary file