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/README.md +1 -1
- package/index.d.ts +0 -2491
- package/infiniloom.darwin-arm64.node +0 -0
- package/infiniloom.darwin-x64.node +0 -0
- package/infiniloom.linux-arm64-gnu.node +0 -0
- package/infiniloom.linux-x64-gnu.node +0 -0
- package/package.json +38 -3
- package/schemas.ts +692 -0
- package/tsconfig.json +40 -0
- package/types.ts +592 -0
package/schemas.ts
ADDED
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for runtime validation of infiniloom-node options
|
|
3
|
+
*
|
|
4
|
+
* These schemas provide runtime validation with helpful error messages.
|
|
5
|
+
* Use them when accepting options from external sources (API calls, config files, etc.)
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { PackOptionsSchema, validatePackOptions } from 'infiniloom-node/schemas';
|
|
10
|
+
* import { pack } from 'infiniloom-node';
|
|
11
|
+
*
|
|
12
|
+
* // Validate options from external source
|
|
13
|
+
* const result = PackOptionsSchema.safeParse(userInput);
|
|
14
|
+
* if (!result.success) {
|
|
15
|
+
* console.error('Invalid options:', result.error.format());
|
|
16
|
+
* return;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Or use the helper function
|
|
20
|
+
* const options = validatePackOptions(userInput);
|
|
21
|
+
* const output = pack('./repo', options);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Enum Schemas
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Output format enum schema
|
|
33
|
+
*/
|
|
34
|
+
export const OutputFormatSchema = z.enum([
|
|
35
|
+
'xml',
|
|
36
|
+
'markdown',
|
|
37
|
+
'json',
|
|
38
|
+
'yaml',
|
|
39
|
+
'toon',
|
|
40
|
+
'plain',
|
|
41
|
+
]);
|
|
42
|
+
export type OutputFormat = z.infer<typeof OutputFormatSchema>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Tokenizer model enum schema
|
|
46
|
+
*/
|
|
47
|
+
export const TokenizerModelSchema = z.enum([
|
|
48
|
+
// OpenAI models (exact tokenization via tiktoken)
|
|
49
|
+
'gpt-5.2',
|
|
50
|
+
'gpt-5.2-pro',
|
|
51
|
+
'gpt-5.1',
|
|
52
|
+
'gpt-5.1-mini',
|
|
53
|
+
'gpt-5.1-codex',
|
|
54
|
+
'gpt-5',
|
|
55
|
+
'gpt-5-mini',
|
|
56
|
+
'gpt-5-nano',
|
|
57
|
+
'o4-mini',
|
|
58
|
+
'o3',
|
|
59
|
+
'o3-mini',
|
|
60
|
+
'o1',
|
|
61
|
+
'o1-mini',
|
|
62
|
+
'o1-preview',
|
|
63
|
+
'gpt-4o',
|
|
64
|
+
'gpt-4o-mini',
|
|
65
|
+
'gpt-4',
|
|
66
|
+
'gpt-4-turbo',
|
|
67
|
+
'gpt-3.5-turbo',
|
|
68
|
+
// Anthropic
|
|
69
|
+
'claude',
|
|
70
|
+
// Google
|
|
71
|
+
'gemini',
|
|
72
|
+
'gemini-1.5',
|
|
73
|
+
'gemini-2.0',
|
|
74
|
+
'gemini-3.1',
|
|
75
|
+
// Meta
|
|
76
|
+
'llama',
|
|
77
|
+
'llama-3',
|
|
78
|
+
'llama-3.1',
|
|
79
|
+
'llama-3.2',
|
|
80
|
+
'codellama',
|
|
81
|
+
// Mistral
|
|
82
|
+
'mistral',
|
|
83
|
+
'mixtral',
|
|
84
|
+
// DeepSeek
|
|
85
|
+
'deepseek',
|
|
86
|
+
'deepseek-v3',
|
|
87
|
+
// Alibaba
|
|
88
|
+
'qwen',
|
|
89
|
+
'qwen-2.5',
|
|
90
|
+
// Cohere
|
|
91
|
+
'cohere',
|
|
92
|
+
'command-r',
|
|
93
|
+
// xAI
|
|
94
|
+
'grok',
|
|
95
|
+
]);
|
|
96
|
+
export type TokenizerModel = z.infer<typeof TokenizerModelSchema>;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compression level enum schema
|
|
100
|
+
*/
|
|
101
|
+
export const CompressionLevelSchema = z.enum([
|
|
102
|
+
'none',
|
|
103
|
+
'minimal',
|
|
104
|
+
'balanced',
|
|
105
|
+
'aggressive',
|
|
106
|
+
'extreme',
|
|
107
|
+
'focused',
|
|
108
|
+
'semantic',
|
|
109
|
+
]);
|
|
110
|
+
export type CompressionLevel = z.infer<typeof CompressionLevelSchema>;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Security severity enum schema
|
|
114
|
+
*/
|
|
115
|
+
export const SecuritySeveritySchema = z.enum([
|
|
116
|
+
'critical',
|
|
117
|
+
'high',
|
|
118
|
+
'medium',
|
|
119
|
+
'low',
|
|
120
|
+
'info',
|
|
121
|
+
]);
|
|
122
|
+
export type SecuritySeverity = z.infer<typeof SecuritySeveritySchema>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Symbol kind enum schema
|
|
126
|
+
*/
|
|
127
|
+
export const SymbolKindSchema = z.enum([
|
|
128
|
+
'function',
|
|
129
|
+
'method',
|
|
130
|
+
'class',
|
|
131
|
+
'struct',
|
|
132
|
+
'interface',
|
|
133
|
+
'trait',
|
|
134
|
+
'enum',
|
|
135
|
+
'constant',
|
|
136
|
+
'variable',
|
|
137
|
+
'import',
|
|
138
|
+
'export',
|
|
139
|
+
'type',
|
|
140
|
+
'module',
|
|
141
|
+
'macro',
|
|
142
|
+
]);
|
|
143
|
+
export type SymbolKind = z.infer<typeof SymbolKindSchema>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Visibility enum schema
|
|
147
|
+
*/
|
|
148
|
+
export const VisibilitySchema = z.enum([
|
|
149
|
+
'public',
|
|
150
|
+
'private',
|
|
151
|
+
'protected',
|
|
152
|
+
'internal',
|
|
153
|
+
]);
|
|
154
|
+
export type Visibility = z.infer<typeof VisibilitySchema>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Chunk strategy enum schema
|
|
158
|
+
*/
|
|
159
|
+
export const ChunkStrategySchema = z.enum([
|
|
160
|
+
'fixed',
|
|
161
|
+
'file',
|
|
162
|
+
'module',
|
|
163
|
+
'symbol',
|
|
164
|
+
'semantic',
|
|
165
|
+
'dependency',
|
|
166
|
+
]);
|
|
167
|
+
export type ChunkStrategy = z.infer<typeof ChunkStrategySchema>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Impact level enum schema
|
|
171
|
+
*/
|
|
172
|
+
export const ImpactLevelSchema = z.enum([
|
|
173
|
+
'low',
|
|
174
|
+
'medium',
|
|
175
|
+
'high',
|
|
176
|
+
'critical',
|
|
177
|
+
]);
|
|
178
|
+
export type ImpactLevel = z.infer<typeof ImpactLevelSchema>;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Git status enum schema
|
|
182
|
+
*/
|
|
183
|
+
export const GitStatusSchema = z.enum([
|
|
184
|
+
'Added',
|
|
185
|
+
'Modified',
|
|
186
|
+
'Deleted',
|
|
187
|
+
'Renamed',
|
|
188
|
+
'Copied',
|
|
189
|
+
'Unknown',
|
|
190
|
+
]);
|
|
191
|
+
export type GitStatus = z.infer<typeof GitStatusSchema>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Change type enum schema
|
|
195
|
+
*/
|
|
196
|
+
export const ChangeTypeSchema = z.enum([
|
|
197
|
+
'added',
|
|
198
|
+
'modified',
|
|
199
|
+
'deleted',
|
|
200
|
+
]);
|
|
201
|
+
export type ChangeType = z.infer<typeof ChangeTypeSchema>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Breaking change severity enum schema
|
|
205
|
+
*/
|
|
206
|
+
export const ChangeSeveritySchema = z.enum([
|
|
207
|
+
'critical',
|
|
208
|
+
'high',
|
|
209
|
+
'medium',
|
|
210
|
+
'low',
|
|
211
|
+
]);
|
|
212
|
+
export type ChangeSeverity = z.infer<typeof ChangeSeveritySchema>;
|
|
213
|
+
|
|
214
|
+
// ============================================================================
|
|
215
|
+
// Option Schemas
|
|
216
|
+
// ============================================================================
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Pack options schema with full validation
|
|
220
|
+
*/
|
|
221
|
+
export const PackOptionsSchema = z.object({
|
|
222
|
+
format: OutputFormatSchema.optional(),
|
|
223
|
+
model: TokenizerModelSchema.optional(),
|
|
224
|
+
compression: CompressionLevelSchema.optional(),
|
|
225
|
+
mapBudget: z.number().int().nonnegative().max(10_000_000).optional(),
|
|
226
|
+
maxSymbols: z.number().int().positive().max(10_000).optional(),
|
|
227
|
+
skipSecurity: z.boolean().optional(),
|
|
228
|
+
redactSecrets: z.boolean().optional(),
|
|
229
|
+
skipSymbols: z.boolean().optional(),
|
|
230
|
+
include: z.array(z.string().max(256)).max(100).optional(),
|
|
231
|
+
exclude: z.array(z.string().max(256)).max(100).optional(),
|
|
232
|
+
includeTests: z.boolean().optional(),
|
|
233
|
+
securityThreshold: SecuritySeveritySchema.optional(),
|
|
234
|
+
tokenBudget: z.number().int().nonnegative().max(10_000_000).optional(),
|
|
235
|
+
changedOnly: z.boolean().optional(),
|
|
236
|
+
baseSha: z.string().regex(/^[a-f0-9]{7,40}$/i).optional(),
|
|
237
|
+
headSha: z.string().regex(/^[a-f0-9]{7,40}$/i).optional(),
|
|
238
|
+
stagedOnly: z.boolean().optional(),
|
|
239
|
+
includeRelated: z.boolean().optional(),
|
|
240
|
+
relatedDepth: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
|
|
241
|
+
}).strict();
|
|
242
|
+
export type PackOptions = z.infer<typeof PackOptionsSchema>;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Scan options schema
|
|
246
|
+
*/
|
|
247
|
+
export const ScanOptionsSchema = z.object({
|
|
248
|
+
model: TokenizerModelSchema.optional(),
|
|
249
|
+
include: z.array(z.string()).optional(),
|
|
250
|
+
exclude: z.array(z.string()).optional(),
|
|
251
|
+
includeTests: z.boolean().optional(),
|
|
252
|
+
applyDefaultIgnores: z.boolean().optional(),
|
|
253
|
+
}).strict();
|
|
254
|
+
export type ScanOptions = z.infer<typeof ScanOptionsSchema>;
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Chunk options schema
|
|
258
|
+
*/
|
|
259
|
+
export const ChunkOptionsSchema = z.object({
|
|
260
|
+
strategy: ChunkStrategySchema.optional(),
|
|
261
|
+
maxTokens: z.number().int().positive().max(100_000).optional(),
|
|
262
|
+
overlap: z.number().int().nonnegative().max(10_000).optional(),
|
|
263
|
+
model: TokenizerModelSchema.optional(),
|
|
264
|
+
format: OutputFormatSchema.optional(),
|
|
265
|
+
priorityFirst: z.boolean().optional(),
|
|
266
|
+
exclude: z.array(z.string().max(256)).max(100).optional(),
|
|
267
|
+
}).strict();
|
|
268
|
+
export type ChunkOptions = z.infer<typeof ChunkOptionsSchema>;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Index options schema
|
|
272
|
+
*/
|
|
273
|
+
export const IndexOptionsSchema = z.object({
|
|
274
|
+
force: z.boolean().optional(),
|
|
275
|
+
includeTests: z.boolean().optional(),
|
|
276
|
+
maxFileSize: z.number().int().positive().max(100 * 1024 * 1024).optional(), // 100MB max
|
|
277
|
+
exclude: z.array(z.string().max(256)).max(100).optional(),
|
|
278
|
+
incremental: z.boolean().optional(),
|
|
279
|
+
}).strict();
|
|
280
|
+
export type IndexOptions = z.infer<typeof IndexOptionsSchema>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Diff context options schema
|
|
284
|
+
*/
|
|
285
|
+
export const DiffContextOptionsSchema = z.object({
|
|
286
|
+
depth: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
|
|
287
|
+
budget: z.number().int().positive().max(10_000_000).optional(),
|
|
288
|
+
includeDiff: z.boolean().optional(),
|
|
289
|
+
format: OutputFormatSchema.optional(),
|
|
290
|
+
model: TokenizerModelSchema.optional(),
|
|
291
|
+
exclude: z.array(z.string().max(256)).max(100).optional(),
|
|
292
|
+
include: z.array(z.string().max(256)).max(100).optional(),
|
|
293
|
+
}).strict();
|
|
294
|
+
export type DiffContextOptions = z.infer<typeof DiffContextOptionsSchema>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Impact options schema
|
|
298
|
+
*/
|
|
299
|
+
export const ImpactOptionsSchema = z.object({
|
|
300
|
+
depth: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
|
|
301
|
+
includeTests: z.boolean().optional(),
|
|
302
|
+
model: TokenizerModelSchema.optional(),
|
|
303
|
+
exclude: z.array(z.string().max(256)).max(100).optional(),
|
|
304
|
+
include: z.array(z.string().max(256)).max(100).optional(),
|
|
305
|
+
}).strict();
|
|
306
|
+
export type ImpactOptions = z.infer<typeof ImpactOptionsSchema>;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Embed options schema
|
|
310
|
+
*/
|
|
311
|
+
export const EmbedOptionsSchema = z.object({
|
|
312
|
+
maxTokens: z.number().int().positive().max(100_000).optional(),
|
|
313
|
+
minTokens: z.number().int().nonnegative().max(10_000).optional(),
|
|
314
|
+
contextLines: z.number().int().nonnegative().max(1_000).optional(),
|
|
315
|
+
includeImports: z.boolean().optional(),
|
|
316
|
+
includeTopLevel: z.boolean().optional(),
|
|
317
|
+
includeTests: z.boolean().optional(),
|
|
318
|
+
securityScan: z.boolean().optional(),
|
|
319
|
+
includePatterns: z.array(z.string().max(256)).max(100).optional(),
|
|
320
|
+
excludePatterns: z.array(z.string().max(256)).max(100).optional(),
|
|
321
|
+
manifestPath: z.string().max(4096).refine(p => !p.includes('..'), { message: 'Path traversal not allowed' }).optional(),
|
|
322
|
+
diffOnly: z.boolean().optional(),
|
|
323
|
+
}).strict();
|
|
324
|
+
export type EmbedOptions = z.infer<typeof EmbedOptionsSchema>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Query filter schema
|
|
328
|
+
*/
|
|
329
|
+
export const QueryFilterSchema = z.object({
|
|
330
|
+
kinds: z.array(SymbolKindSchema).optional(),
|
|
331
|
+
excludeKinds: z.array(SymbolKindSchema).optional(),
|
|
332
|
+
}).strict();
|
|
333
|
+
export type QueryFilter = z.infer<typeof QueryFilterSchema>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Symbol filter schema
|
|
337
|
+
*/
|
|
338
|
+
export const SymbolFilterSchema = z.object({
|
|
339
|
+
kind: SymbolKindSchema.optional(),
|
|
340
|
+
visibility: VisibilitySchema.optional(),
|
|
341
|
+
}).strict();
|
|
342
|
+
export type SymbolFilter = z.infer<typeof SymbolFilterSchema>;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Call graph options schema
|
|
346
|
+
*/
|
|
347
|
+
export const CallGraphOptionsSchema = z.object({
|
|
348
|
+
maxNodes: z.number().int().positive().max(100_000).optional(),
|
|
349
|
+
maxEdges: z.number().int().positive().max(100_000).optional(),
|
|
350
|
+
}).strict();
|
|
351
|
+
export type CallGraphOptions = z.infer<typeof CallGraphOptionsSchema>;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Semantic compress options schema
|
|
355
|
+
*/
|
|
356
|
+
export const SemanticCompressOptionsSchema = z.object({
|
|
357
|
+
similarityThreshold: z.number().min(0).max(1).optional(),
|
|
358
|
+
budgetRatio: z.number().min(0).max(1).optional(),
|
|
359
|
+
minChunkSize: z.number().int().positive().max(100_000).optional(),
|
|
360
|
+
maxChunkSize: z.number().int().positive().max(100_000).optional(),
|
|
361
|
+
}).strict();
|
|
362
|
+
export type SemanticCompressOptions = z.infer<typeof SemanticCompressOptionsSchema>;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Generate map options schema
|
|
366
|
+
*/
|
|
367
|
+
export const GenerateMapOptionsSchema = z.object({
|
|
368
|
+
budget: z.number().int().positive().max(10_000_000).optional(),
|
|
369
|
+
maxSymbols: z.number().int().positive().max(10_000).optional(),
|
|
370
|
+
}).strict();
|
|
371
|
+
export type GenerateMapOptions = z.infer<typeof GenerateMapOptionsSchema>;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Transitive callers options schema
|
|
375
|
+
*/
|
|
376
|
+
export const TransitiveCallersOptionsSchema = z.object({
|
|
377
|
+
maxDepth: z.number().int().positive().max(100).optional(),
|
|
378
|
+
maxResults: z.number().int().positive().max(10_000).optional(),
|
|
379
|
+
}).strict();
|
|
380
|
+
export type TransitiveCallersOptions = z.infer<typeof TransitiveCallersOptionsSchema>;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Call sites context options schema
|
|
384
|
+
*/
|
|
385
|
+
export const CallSitesContextOptionsSchema = z.object({
|
|
386
|
+
linesBefore: z.number().int().nonnegative().max(1_000).optional(),
|
|
387
|
+
linesAfter: z.number().int().nonnegative().max(1_000).optional(),
|
|
388
|
+
}).strict();
|
|
389
|
+
export type CallSitesContextOptions = z.infer<typeof CallSitesContextOptionsSchema>;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Changed symbols filter schema
|
|
393
|
+
*/
|
|
394
|
+
export const ChangedSymbolsFilterSchema = z.object({
|
|
395
|
+
kinds: z.array(SymbolKindSchema).optional(),
|
|
396
|
+
excludeKinds: z.array(SymbolKindSchema).optional(),
|
|
397
|
+
}).strict();
|
|
398
|
+
export type ChangedSymbolsFilter = z.infer<typeof ChangedSymbolsFilterSchema>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Breaking change options schema
|
|
402
|
+
*/
|
|
403
|
+
export const BreakingChangeOptionsSchema = z.object({
|
|
404
|
+
oldRef: z.string().min(1),
|
|
405
|
+
newRef: z.string().min(1),
|
|
406
|
+
}).strict();
|
|
407
|
+
export type BreakingChangeOptions = z.infer<typeof BreakingChangeOptionsSchema>;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Dead code options schema
|
|
411
|
+
*/
|
|
412
|
+
export const DeadCodeOptionsSchema = z.object({
|
|
413
|
+
paths: z.array(z.string()).optional(),
|
|
414
|
+
languages: z.array(z.string()).optional(),
|
|
415
|
+
}).strict();
|
|
416
|
+
export type DeadCodeOptions = z.infer<typeof DeadCodeOptionsSchema>;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Multi-repo entry schema
|
|
420
|
+
*/
|
|
421
|
+
export const MultiRepoEntrySchema = z.object({
|
|
422
|
+
id: z.string().min(1),
|
|
423
|
+
name: z.string().min(1),
|
|
424
|
+
path: z.string().min(1),
|
|
425
|
+
}).strict();
|
|
426
|
+
export type MultiRepoEntry = z.infer<typeof MultiRepoEntrySchema>;
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Multi-repo options schema
|
|
430
|
+
*/
|
|
431
|
+
export const MultiRepoOptionsSchema = z.object({
|
|
432
|
+
repositories: z.array(MultiRepoEntrySchema),
|
|
433
|
+
}).strict();
|
|
434
|
+
export type MultiRepoOptions = z.infer<typeof MultiRepoOptionsSchema>;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Extract documentation options schema
|
|
438
|
+
*/
|
|
439
|
+
export const ExtractDocOptionsSchema = z.object({
|
|
440
|
+
language: z.string().min(1),
|
|
441
|
+
}).strict();
|
|
442
|
+
export type ExtractDocOptions = z.infer<typeof ExtractDocOptionsSchema>;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* Complexity options schema
|
|
446
|
+
*/
|
|
447
|
+
export const ComplexityOptionsSchema = z.object({
|
|
448
|
+
language: z.string().min(1),
|
|
449
|
+
}).strict();
|
|
450
|
+
export type ComplexityOptions = z.infer<typeof ComplexityOptionsSchema>;
|
|
451
|
+
|
|
452
|
+
// ============================================================================
|
|
453
|
+
// Validation Helper Functions
|
|
454
|
+
// ============================================================================
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Validate pack options with detailed error messages
|
|
458
|
+
* @throws {z.ZodError} if validation fails
|
|
459
|
+
*/
|
|
460
|
+
export function validatePackOptions(input: unknown): PackOptions {
|
|
461
|
+
return PackOptionsSchema.parse(input);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Safely validate pack options, returns result object
|
|
466
|
+
*/
|
|
467
|
+
export function safeValidatePackOptions(input: unknown): z.ZodSafeParseResult<PackOptions> {
|
|
468
|
+
return PackOptionsSchema.safeParse(input);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Validate scan options
|
|
473
|
+
* @throws {z.ZodError} if validation fails
|
|
474
|
+
*/
|
|
475
|
+
export function validateScanOptions(input: unknown): ScanOptions {
|
|
476
|
+
return ScanOptionsSchema.parse(input);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Safely validate scan options
|
|
481
|
+
*/
|
|
482
|
+
export function safeValidateScanOptions(input: unknown): z.ZodSafeParseResult<ScanOptions> {
|
|
483
|
+
return ScanOptionsSchema.safeParse(input);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Validate chunk options
|
|
488
|
+
* @throws {z.ZodError} if validation fails
|
|
489
|
+
*/
|
|
490
|
+
export function validateChunkOptions(input: unknown): ChunkOptions {
|
|
491
|
+
return ChunkOptionsSchema.parse(input);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Safely validate chunk options
|
|
496
|
+
*/
|
|
497
|
+
export function safeValidateChunkOptions(input: unknown): z.ZodSafeParseResult<ChunkOptions> {
|
|
498
|
+
return ChunkOptionsSchema.safeParse(input);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Validate embed options
|
|
503
|
+
* @throws {z.ZodError} if validation fails
|
|
504
|
+
*/
|
|
505
|
+
export function validateEmbedOptions(input: unknown): EmbedOptions {
|
|
506
|
+
return EmbedOptionsSchema.parse(input);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Safely validate embed options
|
|
511
|
+
*/
|
|
512
|
+
export function safeValidateEmbedOptions(input: unknown): z.ZodSafeParseResult<EmbedOptions> {
|
|
513
|
+
return EmbedOptionsSchema.safeParse(input);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Validate index options
|
|
518
|
+
* @throws {z.ZodError} if validation fails
|
|
519
|
+
*/
|
|
520
|
+
export function validateIndexOptions(input: unknown): IndexOptions {
|
|
521
|
+
return IndexOptionsSchema.parse(input);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Safely validate index options
|
|
526
|
+
*/
|
|
527
|
+
export function safeValidateIndexOptions(input: unknown): z.ZodSafeParseResult<IndexOptions> {
|
|
528
|
+
return IndexOptionsSchema.safeParse(input);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Validate diff context options
|
|
533
|
+
* @throws {z.ZodError} if validation fails
|
|
534
|
+
*/
|
|
535
|
+
export function validateDiffContextOptions(input: unknown): DiffContextOptions {
|
|
536
|
+
return DiffContextOptionsSchema.parse(input);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Safely validate diff context options
|
|
541
|
+
*/
|
|
542
|
+
export function safeValidateDiffContextOptions(input: unknown): z.ZodSafeParseResult<DiffContextOptions> {
|
|
543
|
+
return DiffContextOptionsSchema.safeParse(input);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Validate impact options
|
|
548
|
+
* @throws {z.ZodError} if validation fails
|
|
549
|
+
*/
|
|
550
|
+
export function validateImpactOptions(input: unknown): ImpactOptions {
|
|
551
|
+
return ImpactOptionsSchema.parse(input);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* Safely validate impact options
|
|
556
|
+
*/
|
|
557
|
+
export function safeValidateImpactOptions(input: unknown): z.ZodSafeParseResult<ImpactOptions> {
|
|
558
|
+
return ImpactOptionsSchema.safeParse(input);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
// ============================================================================
|
|
562
|
+
// Output Schemas (for validating return values)
|
|
563
|
+
// ============================================================================
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Language stat schema
|
|
567
|
+
*/
|
|
568
|
+
export const LanguageStatSchema = z.object({
|
|
569
|
+
language: z.string(),
|
|
570
|
+
files: z.number().int().nonnegative(),
|
|
571
|
+
lines: z.number().int().nonnegative(),
|
|
572
|
+
percentage: z.number().min(0).max(100),
|
|
573
|
+
});
|
|
574
|
+
export type LanguageStat = z.infer<typeof LanguageStatSchema>;
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Scan stats schema
|
|
578
|
+
*/
|
|
579
|
+
export const ScanStatsSchema = z.object({
|
|
580
|
+
name: z.string(),
|
|
581
|
+
totalFiles: z.number().int().nonnegative(),
|
|
582
|
+
totalLines: z.number().int().nonnegative(),
|
|
583
|
+
totalTokens: z.number().int().nonnegative(),
|
|
584
|
+
primaryLanguage: z.string().optional(),
|
|
585
|
+
languages: z.array(LanguageStatSchema),
|
|
586
|
+
securityFindings: z.number().int().nonnegative(),
|
|
587
|
+
});
|
|
588
|
+
export type ScanStats = z.infer<typeof ScanStatsSchema>;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Security finding schema
|
|
592
|
+
*/
|
|
593
|
+
export const SecurityFindingSchema = z.object({
|
|
594
|
+
file: z.string(),
|
|
595
|
+
line: z.number().int().positive(),
|
|
596
|
+
severity: z.string(),
|
|
597
|
+
kind: z.string(),
|
|
598
|
+
pattern: z.string(),
|
|
599
|
+
});
|
|
600
|
+
export type SecurityFinding = z.infer<typeof SecurityFindingSchema>;
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Index status schema
|
|
604
|
+
*/
|
|
605
|
+
export const IndexStatusSchema = z.object({
|
|
606
|
+
exists: z.boolean(),
|
|
607
|
+
fileCount: z.number().int().nonnegative(),
|
|
608
|
+
symbolCount: z.number().int().nonnegative(),
|
|
609
|
+
lastBuilt: z.string().optional(),
|
|
610
|
+
version: z.string().optional(),
|
|
611
|
+
filesUpdated: z.number().int().nonnegative().optional(),
|
|
612
|
+
incremental: z.boolean().optional(),
|
|
613
|
+
});
|
|
614
|
+
export type IndexStatus = z.infer<typeof IndexStatusSchema>;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Symbol info schema
|
|
618
|
+
*/
|
|
619
|
+
export const SymbolInfoSchema = z.object({
|
|
620
|
+
id: z.number().int().nonnegative(),
|
|
621
|
+
name: z.string(),
|
|
622
|
+
kind: z.string(),
|
|
623
|
+
file: z.string(),
|
|
624
|
+
line: z.number().int().positive(),
|
|
625
|
+
endLine: z.number().int().positive(),
|
|
626
|
+
signature: z.string().optional(),
|
|
627
|
+
visibility: z.string(),
|
|
628
|
+
});
|
|
629
|
+
export type SymbolInfo = z.infer<typeof SymbolInfoSchema>;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Embed chunk schema
|
|
633
|
+
*/
|
|
634
|
+
export const EmbedChunkSchema = z.object({
|
|
635
|
+
id: z.string().regex(/^ec_[a-f0-9]{32}$/),
|
|
636
|
+
fullHash: z.string(),
|
|
637
|
+
content: z.string(),
|
|
638
|
+
tokens: z.number().int().nonnegative(),
|
|
639
|
+
kind: z.string(),
|
|
640
|
+
source: z.object({
|
|
641
|
+
file: z.string(),
|
|
642
|
+
linesStart: z.number().int().positive(),
|
|
643
|
+
linesEnd: z.number().int().positive(),
|
|
644
|
+
symbol: z.string(),
|
|
645
|
+
fqn: z.string().optional(),
|
|
646
|
+
language: z.string(),
|
|
647
|
+
parent: z.string().optional(),
|
|
648
|
+
visibility: z.string(),
|
|
649
|
+
isTest: z.boolean(),
|
|
650
|
+
}),
|
|
651
|
+
context: z.object({
|
|
652
|
+
docstring: z.string().optional(),
|
|
653
|
+
comments: z.array(z.string()),
|
|
654
|
+
signature: z.string().optional(),
|
|
655
|
+
calls: z.array(z.string()),
|
|
656
|
+
calledBy: z.array(z.string()),
|
|
657
|
+
imports: z.array(z.string()),
|
|
658
|
+
tags: z.array(z.string()),
|
|
659
|
+
linesOfCode: z.number().int().nonnegative(),
|
|
660
|
+
maxNestingDepth: z.number().int().nonnegative(),
|
|
661
|
+
}),
|
|
662
|
+
part: z.object({
|
|
663
|
+
part: z.number().int().positive(),
|
|
664
|
+
of: z.number().int().positive(),
|
|
665
|
+
parentId: z.string(),
|
|
666
|
+
parentSignature: z.string().optional(),
|
|
667
|
+
}).optional(),
|
|
668
|
+
});
|
|
669
|
+
export type EmbedChunk = z.infer<typeof EmbedChunkSchema>;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Embed diff summary schema
|
|
673
|
+
*/
|
|
674
|
+
export const EmbedDiffSummarySchema = z.object({
|
|
675
|
+
added: z.number().int().nonnegative(),
|
|
676
|
+
modified: z.number().int().nonnegative(),
|
|
677
|
+
removed: z.number().int().nonnegative(),
|
|
678
|
+
unchanged: z.number().int().nonnegative(),
|
|
679
|
+
totalChunks: z.number().int().nonnegative(),
|
|
680
|
+
});
|
|
681
|
+
export type EmbedDiffSummary = z.infer<typeof EmbedDiffSummarySchema>;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Embed result schema
|
|
685
|
+
*/
|
|
686
|
+
export const EmbedResultSchema = z.object({
|
|
687
|
+
chunks: z.array(EmbedChunkSchema),
|
|
688
|
+
diff: EmbedDiffSummarySchema.optional(),
|
|
689
|
+
manifestVersion: z.number().int().nonnegative(),
|
|
690
|
+
elapsedMs: z.number().int().nonnegative(),
|
|
691
|
+
});
|
|
692
|
+
export type EmbedResult = z.infer<typeof EmbedResultSchema>;
|