infiniloom-node 0.6.2 → 0.7.0

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