@glyphier/cli 0.1.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.
@@ -0,0 +1,1421 @@
1
+ import Parser from 'web-tree-sitter';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * Core type definitions for the Glyphier AI-Native Code Representation Engine.
6
+ */
7
+ /**
8
+ * 1-indexed line range [start, end] inclusive.
9
+ */
10
+ interface LineRange {
11
+ start: number;
12
+ end: number;
13
+ }
14
+ /**
15
+ * Metadata associated with a parsed file.
16
+ */
17
+ interface FileMetadata {
18
+ path: string;
19
+ language: string;
20
+ lineCount: number;
21
+ functionCount: number;
22
+ mtime: number;
23
+ sizeBytes?: number;
24
+ }
25
+ /**
26
+ * Represents an imported dependency.
27
+ */
28
+ interface ImportNode {
29
+ kind: "use";
30
+ path: string;
31
+ symbols: string[];
32
+ }
33
+ /**
34
+ * Represents a type declaration, interface, struct, or typedef.
35
+ */
36
+ interface TypeNode {
37
+ kind: "type";
38
+ name: string;
39
+ lines: LineRange;
40
+ fields: Array<{
41
+ name: string;
42
+ type: string;
43
+ }>;
44
+ isExported?: boolean;
45
+ values?: string[];
46
+ }
47
+ /**
48
+ * Represents a function or method declaration.
49
+ */
50
+ interface FunctionNode {
51
+ kind: "fn";
52
+ name: string;
53
+ lines: LineRange;
54
+ params: Array<{
55
+ name: string;
56
+ type: string;
57
+ }>;
58
+ returnType: string;
59
+ isAsync?: boolean;
60
+ isExported?: boolean;
61
+ /** L2 only: names of guard/validation functions called */
62
+ validates?: string[];
63
+ /** L2 only: names or scoped descriptors of functions/methods called */
64
+ calls?: Array<string | ScopedCall>;
65
+ /** L2 only: names of error types thrown or raised */
66
+ throws?: string[];
67
+ /** Decorators applied to function/method */
68
+ decorators?: Array<{
69
+ name: string;
70
+ args?: string[];
71
+ }>;
72
+ /** L2 only: key state transitions, status strings, or enum literals */
73
+ states?: string[];
74
+ /** L2 only: concise return object shapes */
75
+ returns?: string[];
76
+ /** L2 only: paired test names exercising this function */
77
+ tests?: string[];
78
+ }
79
+ /**
80
+ * Scoped call target indicating whether a call is to self, local module, or external.
81
+ */
82
+ interface ScopedCall {
83
+ name: string;
84
+ scope: "self" | "local" | "ext";
85
+ target?: string;
86
+ line?: number;
87
+ }
88
+ /**
89
+ * Represents a class or trait declaration.
90
+ */
91
+ interface ClassNode {
92
+ kind: "class";
93
+ name: string;
94
+ lines: LineRange;
95
+ extends?: string;
96
+ implements?: string[];
97
+ methods: FunctionNode[];
98
+ isExported?: boolean;
99
+ /** Decorators applied to class */
100
+ decorators?: Array<{
101
+ name: string;
102
+ args?: string[];
103
+ }>;
104
+ }
105
+ /**
106
+ * Represents a parse or syntax error within a file region.
107
+ */
108
+ interface ErrorNode {
109
+ kind: "error";
110
+ message: string;
111
+ lines: LineRange;
112
+ }
113
+ /**
114
+ * Represents the top-level module node for a single file.
115
+ */
116
+ interface ModuleNode {
117
+ kind: "mod";
118
+ name: string;
119
+ lines: LineRange;
120
+ imports: ImportNode[];
121
+ types: TypeNode[];
122
+ functions: FunctionNode[];
123
+ classes: ClassNode[];
124
+ errors?: ErrorNode[];
125
+ }
126
+ /**
127
+ * The complete parsed IR representation of a file.
128
+ */
129
+ interface Glyphier {
130
+ module: ModuleNode;
131
+ metadata: FileMetadata;
132
+ }
133
+ /**
134
+ * Node in the project directory tree.
135
+ */
136
+ interface TreeNode {
137
+ name: string;
138
+ type: "file" | "directory";
139
+ children?: TreeNode[];
140
+ metadata?: FileMetadata;
141
+ extension?: string;
142
+ }
143
+ /**
144
+ * Result of a semantic IR search.
145
+ */
146
+ interface SearchResult {
147
+ file: string;
148
+ symbol: string;
149
+ kind: "fn" | "class" | "type" | "use" | "calls" | "route" | "var";
150
+ lines: LineRange;
151
+ context?: string;
152
+ }
153
+ /**
154
+ * Configuration options for Glyphier.
155
+ */
156
+ interface GlyphierConfig {
157
+ ignore: string[];
158
+ languages?: Record<string, {
159
+ extensions: string[];
160
+ grammar?: string;
161
+ tags?: string;
162
+ }>;
163
+ maxFileSize: number;
164
+ defaultLevel: 0 | 1 | 2;
165
+ callFilter?: {
166
+ exclude?: string[];
167
+ };
168
+ }
169
+ /**
170
+ * Information about a caller in the inverted call graph.
171
+ */
172
+ interface CallerReference {
173
+ file: string;
174
+ symbol: string;
175
+ kind: "function" | "method" | "constructor";
176
+ lines: LineRange;
177
+ callsTarget: string;
178
+ }
179
+ /**
180
+ * Result of impact / blast radius analysis.
181
+ */
182
+ interface ImpactAnalysisResult {
183
+ target: string;
184
+ file?: string;
185
+ kind?: string;
186
+ callers: CallerReference[];
187
+ transitiveCount: number;
188
+ depth: number;
189
+ risk: "low" | "med" | "high" | "critical";
190
+ importers: string[];
191
+ }
192
+ /**
193
+ * Delta representation for a modified declaration in semantic diff.
194
+ */
195
+ interface DeclarationDelta {
196
+ name: string;
197
+ kind: "function" | "class" | "method" | "type";
198
+ status: "added" | "removed" | "modified";
199
+ lines?: LineRange;
200
+ oldSignature?: string;
201
+ newSignature?: string;
202
+ addedCalls?: string[];
203
+ removedCalls?: string[];
204
+ paramChanges?: string[];
205
+ }
206
+ /**
207
+ * Result of semantic AST diffing.
208
+ */
209
+ interface SemanticDiffResult {
210
+ file: string;
211
+ revision: string;
212
+ deltas: DeclarationDelta[];
213
+ addedLinesCount: number;
214
+ deletedLinesCount: number;
215
+ }
216
+ /**
217
+ * Adaptive token budgeting projection plan.
218
+ */
219
+ interface BudgetPlan {
220
+ targetBudget: number;
221
+ projectedTokens: number;
222
+ l0Files: string[];
223
+ l1Files: string[];
224
+ l2Files: string[];
225
+ centralityRankings: Array<{
226
+ file: string;
227
+ score: number;
228
+ level: 0 | 1 | 2;
229
+ }>;
230
+ }
231
+ /**
232
+ * Pre-flight AST check result.
233
+ */
234
+ interface PreflightCheckResult {
235
+ file: string;
236
+ valid: boolean;
237
+ syntaxErrors: Array<{
238
+ line: number;
239
+ message: string;
240
+ }>;
241
+ unresolvedImports: string[];
242
+ astSummary?: string;
243
+ }
244
+ /**
245
+ * BullMQ / message queue architectural mapping.
246
+ */
247
+ interface QueueInfo {
248
+ name: string;
249
+ processor?: string;
250
+ processorFile?: string;
251
+ jobs?: string[];
252
+ injectedIn?: string[];
253
+ }
254
+ /**
255
+ * Cross-module external dependency boundary.
256
+ */
257
+ interface ExternalDependency {
258
+ source: string;
259
+ symbols: string[];
260
+ }
261
+ /**
262
+ * Subsystem architectural dependency graph.
263
+ */
264
+ interface SubsystemGraph {
265
+ name: string;
266
+ path: string;
267
+ fileCount: number;
268
+ moduleName?: string;
269
+ isGlobal?: boolean;
270
+ importedModules?: string[];
271
+ externalDeps: ExternalDependency[];
272
+ queues: QueueInfo[];
273
+ services: Array<{
274
+ name: string;
275
+ file: string;
276
+ calls: string[];
277
+ }>;
278
+ }
279
+ /**
280
+ * A single node within a multi-file program slice.
281
+ */
282
+ interface SliceNode {
283
+ file: string;
284
+ kind: "fn" | "type";
285
+ name: string;
286
+ lines: LineRange;
287
+ signature?: string;
288
+ calls?: string[];
289
+ validates?: string[];
290
+ tests?: string[];
291
+ }
292
+ /**
293
+ * The self-contained result of a program slice across multiple files.
294
+ */
295
+ interface ProgramSliceResult {
296
+ rootSymbol: string;
297
+ targetSymbol?: string;
298
+ depth: number;
299
+ nodes: SliceNode[];
300
+ files: string[];
301
+ tokenEstimate: number;
302
+ }
303
+ /**
304
+ * Result of a multi-turn session delta comparison.
305
+ */
306
+ interface SessionDeltaResult {
307
+ file: string;
308
+ sessionId: string;
309
+ status: "unchanged" | "modified" | "new";
310
+ fingerprint: string;
311
+ unchangedCount?: number;
312
+ modifiedFunctions?: FunctionNode[];
313
+ addedFunctions?: FunctionNode[];
314
+ removedFunctions?: string[];
315
+ }
316
+ type PatchAction = "add-call" | "add-fn" | "add-field" | "replace-call" | "remove-node";
317
+ interface PatchOperation {
318
+ action: PatchAction;
319
+ target: string;
320
+ code: string;
321
+ }
322
+ interface PatchResult {
323
+ file: string;
324
+ success: boolean;
325
+ appliedOps: number;
326
+ error?: string;
327
+ diff?: string;
328
+ patchedCode?: string;
329
+ }
330
+
331
+ declare const DEFAULT_CONFIG: GlyphierConfig;
332
+ /**
333
+ * Loads configuration from a `.glyphierrc.json` in the target directory or its parents,
334
+ * merging with default values.
335
+ */
336
+ declare function loadConfig(rootPath?: string): GlyphierConfig;
337
+ /**
338
+ * Resolves the root directory of the repository/project by walking up to find .git, pnpm-workspace.yaml, or package.json.
339
+ */
340
+ declare function findProjectRoot(startPath?: string): string;
341
+
342
+ /**
343
+ * File-level cache with in-memory fast path and persistent SQLite backing.
344
+ */
345
+ declare class MtimeCache {
346
+ private entries;
347
+ private hits;
348
+ private misses;
349
+ /**
350
+ * Retrieves a cached IR if the file modification time matches.
351
+ */
352
+ get(filePath: string, currentMtime?: number): Glyphier | null;
353
+ /**
354
+ * Sets or updates the cache entry for a file.
355
+ */
356
+ set(filePath: string, mtime: number, ir: Glyphier): void;
357
+ /**
358
+ * Checks if an entry is present and fresh.
359
+ */
360
+ isValid(filePath: string, currentMtime: number): boolean;
361
+ /**
362
+ * Removes a file from the cache.
363
+ */
364
+ delete(filePath: string): boolean;
365
+ /**
366
+ * Clears the entire cache.
367
+ */
368
+ clear(): void;
369
+ /**
370
+ * Returns cache metrics.
371
+ */
372
+ getStats(): {
373
+ size: number;
374
+ hits: number;
375
+ misses: number;
376
+ };
377
+ }
378
+ declare const globalCache: MtimeCache;
379
+
380
+ /**
381
+ * Maps file extensions to tree-sitter language names.
382
+ */
383
+ declare const EXTENSION_TO_LANGUAGE: Record<string, string>;
384
+ /**
385
+ * Initializes the web-tree-sitter WASM engine.
386
+ */
387
+ declare function initTreeSitter(): Promise<void>;
388
+ /**
389
+ * Detects the language from a file name or path.
390
+ */
391
+ declare function detectLanguage(filePath: string): string | null;
392
+ /**
393
+ * Loads and caches a Tree-sitter Language instance.
394
+ */
395
+ declare function loadLanguage(langName: string): Promise<Parser.Language | null>;
396
+ /**
397
+ * Returns a list of all built-in supported languages.
398
+ */
399
+ declare function getSupportedLanguages(): string[];
400
+
401
+ interface ParseResult {
402
+ tree: Parser.Tree;
403
+ language: string;
404
+ langInstance: Parser.Language;
405
+ lineCount: number;
406
+ }
407
+ declare function parseSource(source: string, languageHint?: string): Promise<ParseResult | null>;
408
+ /**
409
+ * Parses a file on disk into a Tree-sitter CST.
410
+ */
411
+ declare function parseFileTree(filePath: string): Promise<ParseResult | null>;
412
+
413
+ /**
414
+ * Normalizes types to compact abbreviations.
415
+ */
416
+ declare function abbreviateType(rawType: string): string;
417
+ /**
418
+ * Options for IR generation.
419
+ */
420
+ interface GenerateIROptions {
421
+ level?: 1 | 2;
422
+ config?: GlyphierConfig;
423
+ rootPath?: string;
424
+ }
425
+ /**
426
+ * Generates Glyphier IR from a parsed Tree-sitter CST.
427
+ */
428
+ declare function generateIR(tree: Parser.Tree, filePath: string, language: string, lineCount: number, options?: GenerateIROptions): Glyphier;
429
+
430
+ interface BuildTreeOptions {
431
+ depth?: number;
432
+ config?: GlyphierConfig;
433
+ rootPath?: string;
434
+ ignore?: string[];
435
+ }
436
+ /**
437
+ * Builds a hierarchical TreeNode representation of a project directory.
438
+ */
439
+ declare function buildTree(targetDir: string, options?: BuildTreeOptions): Promise<TreeNode>;
440
+
441
+ interface SearchOptions {
442
+ kind?: "calls" | "fn" | "type" | "use" | "route" | "var" | "all";
443
+ }
444
+ type SearchTarget = Glyphier[] | {
445
+ files: Map<string, Glyphier>;
446
+ } | Map<string, Glyphier>;
447
+ /**
448
+ * Searches across a collection of parsed IR files for symbols or patterns.
449
+ */
450
+ declare function searchIR(target: SearchTarget, query: string, kindOrOptions?: SearchOptions["kind"] | SearchOptions): SearchResult[];
451
+ /**
452
+ * Formats search results into a concise string for LLM agents or terminal users.
453
+ */
454
+ declare function formatSearchResults(query: string, results: SearchResult[]): string;
455
+
456
+ interface ProjectParseResult {
457
+ tree: TreeNode;
458
+ files: Map<string, Glyphier>;
459
+ rootPath: string;
460
+ }
461
+ interface ParseFileOptions {
462
+ level?: 1 | 2;
463
+ config?: GlyphierConfig;
464
+ rootPath?: string;
465
+ source?: string;
466
+ language?: string;
467
+ noCache?: boolean;
468
+ }
469
+ interface ParseProjectOptions extends ParseFileOptions {
470
+ ignore?: string[];
471
+ depth?: number;
472
+ }
473
+ /**
474
+ * Parses a single file into Glyphier, utilizing cache where possible.
475
+ */
476
+ declare function parseFile(filePath: string, languageOrOptions?: string | ParseFileOptions, maybeOptions?: ParseFileOptions): Promise<Glyphier | null>;
477
+ /**
478
+ * Parses an entire project or directory recursively into IR.
479
+ */
480
+ declare function parseProject(targetDir?: string, options?: ParseProjectOptions): Promise<ProjectParseResult>;
481
+ interface ReadRawOptions {
482
+ startLine?: number;
483
+ endLine?: number;
484
+ }
485
+ /**
486
+ * Reads raw source code lines from a file with line numbers prefixed.
487
+ */
488
+ declare function readRaw(filePath: string, options?: ReadRawOptions): string | null;
489
+
490
+ interface ImpactOptions {
491
+ depth?: number;
492
+ rootPath?: string;
493
+ project?: ProjectParseResult;
494
+ }
495
+ /**
496
+ * Analyzes the blast radius / impact of modifying or renaming a symbol.
497
+ */
498
+ declare function analyzeImpact(symbolName: string, targetPathOrOptions?: string | ImpactOptions, maybeOptions?: ImpactOptions): Promise<ImpactAnalysisResult>;
499
+
500
+ interface SemanticDiffOptions {
501
+ since?: string;
502
+ rootPath?: string;
503
+ baseSource?: string;
504
+ currentSource?: string;
505
+ }
506
+ /**
507
+ * Computes a semantic AST diff between two versions of a file.
508
+ */
509
+ declare function semanticDiff(filePath: string, options?: SemanticDiffOptions): Promise<SemanticDiffResult>;
510
+
511
+ interface BudgetProjectionOptions {
512
+ budget: number;
513
+ rootPath?: string;
514
+ project?: ProjectParseResult;
515
+ countTokens?: (s: string) => number;
516
+ }
517
+ interface BudgetProjectionResult {
518
+ plan: BudgetPlan;
519
+ formattedOutput: string;
520
+ totalTokens: number;
521
+ }
522
+ /**
523
+ * Adaptive token budgeting engine: packs maximum semantic information
524
+ * into a strict token budget using PageRank / centrality ranking.
525
+ */
526
+ declare function projectBudget(options: BudgetProjectionOptions): Promise<BudgetProjectionResult>;
527
+
528
+ interface PreflightCheckOptions {
529
+ rootPath?: string;
530
+ originalSource?: string;
531
+ }
532
+ /**
533
+ * Pre-flight validator: checks proposed agent patches/code for AST syntax errors,
534
+ * missing braces, and structural defects BEFORE writing to disk.
535
+ */
536
+ declare function preflightCheck(filePath: string, patchOrCode: string, options?: PreflightCheckOptions): Promise<PreflightCheckResult>;
537
+
538
+ interface GraphOptions {
539
+ rootPath?: string;
540
+ project?: ProjectParseResult;
541
+ }
542
+ /**
543
+ * Analyzes the architectural dependency graph of a module or subsystem directory.
544
+ */
545
+ declare function analyzeModuleGraph(targetDir: string, options?: GraphOptions): Promise<SubsystemGraph>;
546
+ /**
547
+ * Formats a SubsystemGraph into an ultra-dense symbolic S-expression.
548
+ */
549
+ declare function formatGraphSExpr(graph: SubsystemGraph): string;
550
+
551
+ interface SliceOptions {
552
+ depth?: number;
553
+ targetSymbol?: string;
554
+ rootPath?: string;
555
+ project?: {
556
+ files: Map<string, Glyphier>;
557
+ };
558
+ }
559
+ /**
560
+ * Computes a targeted, multi-file program slice around a root symbol.
561
+ * Traces call graphs and type dependencies to isolate only the code execution path.
562
+ */
563
+ declare function computeProgramSlice(targetPath: string, rootSymbol: string, options?: SliceOptions): Promise<ProgramSliceResult>;
564
+
565
+ /**
566
+ * Computes a session delta for a file.
567
+ * Returns 'unchanged' if file has already been sent to this agent session without modifications,
568
+ * or an inverted delta of only modified/added functions.
569
+ */
570
+ declare function computeSessionDelta(sessionId: string, filePath: string, ir: Glyphier): SessionDeltaResult;
571
+ /**
572
+ * Resets or clears a session state.
573
+ */
574
+ declare function clearSession(sessionId?: string): void;
575
+
576
+ /**
577
+ * Applies surgical AST-native structural patches to a source file.
578
+ * Pre-validates syntax with Tree-sitter prior to persisting changes to disk.
579
+ */
580
+ declare function applyAstPatch(filePath: string, operations: PatchOperation[] | string, options?: {
581
+ dryRun?: boolean;
582
+ }): Promise<PatchResult>;
583
+
584
+ interface FileStat {
585
+ path: string;
586
+ rawTokens: number;
587
+ l1Tokens: number;
588
+ l2Tokens: number;
589
+ ratio: number;
590
+ }
591
+ interface ProjectStats {
592
+ targetPath: string;
593
+ filesCount: number;
594
+ rawTokens: number;
595
+ l1Tokens: number;
596
+ l2Tokens: number;
597
+ compressionRatio: number;
598
+ languageBreakdown: Record<string, {
599
+ files: number;
600
+ rawTokens: number;
601
+ l2Tokens: number;
602
+ }>;
603
+ heaviestFiles: FileStat[];
604
+ pricing: {
605
+ sonnetRaw: string;
606
+ sonnetIr: string;
607
+ sonnetSaved: string;
608
+ gpt4oRaw: string;
609
+ gpt4oIr: string;
610
+ gpt4oSaved: string;
611
+ };
612
+ }
613
+ interface StatsOptions {
614
+ rootPath?: string;
615
+ topN?: number;
616
+ }
617
+ /**
618
+ * Computes token density, compression ratios, and pricing analytics across a codebase or file.
619
+ */
620
+ declare function computeStats(targetPath: string, options?: StatsOptions): Promise<ProjectStats>;
621
+ /**
622
+ * Formats ProjectStats into a compact S-expression.
623
+ */
624
+ declare function formatStatsSExpr(stats: ProjectStats): string;
625
+
626
+ interface FormatSExprOptions {
627
+ level?: 1 | 2;
628
+ }
629
+ /**
630
+ * Formats a Glyphier module into compact S-expression notation.
631
+ */
632
+ declare function formatSExpr(ir: Glyphier, optionsOrLevel?: FormatSExprOptions | 1 | 2): string;
633
+ /**
634
+ * Formats an Impact Analysis result into compact S-expression notation.
635
+ */
636
+ declare function formatImpactSExpr(res: ImpactAnalysisResult): string;
637
+ /**
638
+ * Formats a Semantic Diff result into compact S-expression notation.
639
+ */
640
+ declare function formatDiffSExpr(res: SemanticDiffResult): string;
641
+ /**
642
+ * Formats a Pre-flight Check result into compact S-expression notation.
643
+ */
644
+ declare function formatCheckSExpr(res: PreflightCheckResult): string;
645
+ /**
646
+ * Formats a ProgramSliceResult into a compact S-expression.
647
+ */
648
+ declare function formatSliceSExpr(res: ProgramSliceResult): string;
649
+ /**
650
+ * Formats a SessionDeltaResult into compact S-expression notation.
651
+ */
652
+ declare function formatDeltaSExpr(res: SessionDeltaResult): string;
653
+
654
+ /**
655
+ * Formats a project TreeNode into a compact Prefix-Trie brace-expansion string.
656
+ */
657
+ declare function formatTrie(rootOrProject: TreeNode | {
658
+ tree: TreeNode;
659
+ }): string;
660
+
661
+ declare function formatJSON(data: Glyphier | TreeNode | SearchResult[] | unknown, pretty?: boolean): string;
662
+
663
+ interface LicenseSession {
664
+ valid: boolean;
665
+ plan: "dev" | "enterprise" | "unknown";
666
+ userId?: string;
667
+ expiresAt?: string;
668
+ source: "remote" | "lease" | "missing-key";
669
+ }
670
+ /**
671
+ * Derives a stable, anonymous hardware machine fingerprint.
672
+ */
673
+ declare function getMachineFingerprint(): string;
674
+ /**
675
+ * Retrieves the API key from the process environment only. Never persist a
676
+ * commercial credential in a workspace or a user-readable configuration file.
677
+ */
678
+ declare function getApiKey(): string | null;
679
+ /**
680
+ * Validates the Glyphier license.
681
+ * Online verification is normal. A device-bound, Ed25519-signed 72-hour lease
682
+ * is accepted only when the control plane is unreachable, preserving paid local
683
+ * work during a verified service outage without persisting an API credential.
684
+ */
685
+ declare function verifyLicense(): Promise<LicenseSession>;
686
+ declare function assertPaidLicense(): Promise<LicenseSession>;
687
+ /**
688
+ * Asynchronously report token telemetry to Glyphier cloud in the background.
689
+ * Non-blocking, completely fire-and-forget. Never throws.
690
+ */
691
+ declare function reportTokenTelemetry(stats: {
692
+ rawTokens: number;
693
+ irTokens: number;
694
+ source?: string;
695
+ }): void;
696
+
697
+ interface StoredFile {
698
+ path: string;
699
+ mtime: number;
700
+ hash: string;
701
+ language: string;
702
+ classification: string;
703
+ lineCount: number;
704
+ tokenCount: number;
705
+ }
706
+ interface StoredSymbol {
707
+ id: string;
708
+ filePath: string;
709
+ name: string;
710
+ qualifiedName: string;
711
+ kind: string;
712
+ startLine: number;
713
+ endLine: number;
714
+ signature: string;
715
+ isExported: boolean;
716
+ hash: string;
717
+ language: string;
718
+ }
719
+ interface StoredEdge {
720
+ sourceId: string;
721
+ targetId: string;
722
+ kind: string;
723
+ filePath: string;
724
+ line: number;
725
+ confidence: number;
726
+ }
727
+ interface StoredSession {
728
+ sessionId: string;
729
+ filePath: string;
730
+ fingerprint: string;
731
+ createdAt: number;
732
+ expiresAt: number;
733
+ }
734
+ interface StoredFact {
735
+ id: string;
736
+ statement: string;
737
+ provenance: Array<{
738
+ file: string;
739
+ startLine: number;
740
+ endLine: number;
741
+ symbolId?: string;
742
+ }>;
743
+ confidence: number;
744
+ category: string;
745
+ createdAt: number;
746
+ verifiedAt: number;
747
+ dependencies: string[];
748
+ }
749
+ declare class GlyphierStorage {
750
+ private db;
751
+ readonly dbPath: string;
752
+ constructor(dbPath?: string);
753
+ private initSchema;
754
+ upsertFile(file: StoredFile): void;
755
+ getFile(filePath: string): StoredFile | null;
756
+ getAllFiles(): StoredFile[];
757
+ deleteFile(filePath: string): void;
758
+ upsertSymbols(symbols: StoredSymbol[]): void;
759
+ getSymbolsByFile(filePath: string): StoredSymbol[];
760
+ getSymbol(id: string): StoredSymbol | null;
761
+ findSymbols(query: string, kind?: string): StoredSymbol[];
762
+ deleteSymbolsByFile(filePath: string): void;
763
+ private mapSymbolRow;
764
+ upsertEdges(edges: StoredEdge[]): void;
765
+ getOutgoingEdges(sourceId: string, kind?: string): StoredEdge[];
766
+ getIncomingEdges(targetId: string, kind?: string): StoredEdge[];
767
+ deleteEdgesByFile(filePath: string): void;
768
+ private mapEdgeRow;
769
+ getIR(filePath: string, level: number, contentHash?: string): string | null;
770
+ setIR(filePath: string, level: number, contentHash: string, irBlob: string): void;
771
+ invalidateIR(filePath: string): void;
772
+ getSession(sessionId: string, filePath: string): StoredSession | null;
773
+ setSession(sessionId: string, filePath: string, fingerprint: string, ttlHours?: number): void;
774
+ cleanExpiredSessions(): number;
775
+ clearSession(sessionId: string): void;
776
+ upsertFact(fact: StoredFact): void;
777
+ getFacts(category?: string): StoredFact[];
778
+ deleteFact(id: string): void;
779
+ close(): void;
780
+ }
781
+ /**
782
+ * Returns or initializes the Glyphier persistent storage for a repository root.
783
+ */
784
+ declare function getStorage(repoRoot?: string): GlyphierStorage;
785
+
786
+ type FileClassification = "SOURCE" | "GENERATED" | "VENDOR" | "DEPENDENCY" | "CONFIGURATION" | "TEST" | "DOCUMENTATION" | "MIGRATION" | "ASSET" | "BUILD_OUTPUT";
787
+ /**
788
+ * Classifies a repository file path and optional content into semantic file categories.
789
+ */
790
+ declare function classifyFile(filePath: string, content?: string): FileClassification;
791
+
792
+ type SymbolKind = "fn" | "method" | "class" | "interface" | "type" | "enum" | "struct" | "const" | "var" | "mod" | "route" | "handler";
793
+ interface SymbolEntry {
794
+ id: string;
795
+ name: string;
796
+ qualifiedName: string;
797
+ kind: SymbolKind;
798
+ filePath: string;
799
+ startLine: number;
800
+ endLine: number;
801
+ signature: string;
802
+ isExported: boolean;
803
+ hash: string;
804
+ language: string;
805
+ }
806
+ /**
807
+ * Computes a deterministic 16-character hexadecimal ID for a symbol.
808
+ */
809
+ declare function computeSymbolId(filePath: string, qualifiedName: string, kind: string, startLine: number): string;
810
+ /**
811
+ * Extracts normalized SymbolEntry records from a parsed Glyphier.
812
+ */
813
+ declare function extractSymbolsFromIR(ir: Glyphier, filePath: string): SymbolEntry[];
814
+
815
+ type EdgeKind = "calls" | "called_by" | "imports" | "imported_by" | "extends" | "implements" | "tests" | "tested_by" | "routes_to" | "validates" | "throws" | "references";
816
+ interface SymbolEdge {
817
+ sourceId: string;
818
+ targetId: string;
819
+ kind: EdgeKind;
820
+ filePath: string;
821
+ line: number;
822
+ confidence: number;
823
+ }
824
+ declare function getInverseEdgeKind(kind: EdgeKind): EdgeKind | null;
825
+
826
+ /**
827
+ * Resolves cross-file symbol references and extracts directed graph edges.
828
+ */
829
+ declare function resolveModuleEdges(ir: Glyphier, filePath: string, localSymbols: SymbolEntry[], storage: GlyphierStorage): SymbolEdge[];
830
+
831
+ interface IndexStats {
832
+ indexedFiles: number;
833
+ skippedFiles: number;
834
+ deletedFiles: number;
835
+ symbolCount: number;
836
+ edgeCount: number;
837
+ durationMs: number;
838
+ }
839
+ /**
840
+ * Incrementally indexes a repository, synchronizing the ASTs, symbol table,
841
+ * and dependency edges in SQLite.
842
+ */
843
+ declare function indexProject(repoRoot: string, options?: {
844
+ extensions?: string[];
845
+ force?: boolean;
846
+ storage?: GlyphierStorage;
847
+ }): Promise<IndexStats>;
848
+
849
+ interface TraceOptions {
850
+ direction?: "callers" | "callees" | "both";
851
+ depth?: number;
852
+ storage: GlyphierStorage;
853
+ }
854
+ interface TraceNode {
855
+ symbol: StoredSymbol;
856
+ depth: number;
857
+ }
858
+ interface TraceResult {
859
+ rootSymbol: string;
860
+ direction: "callers" | "callees" | "both";
861
+ depth: number;
862
+ nodes: TraceNode[];
863
+ edges: StoredEdge[];
864
+ }
865
+ /**
866
+ * Traces the semantic neighborhood of a symbol through the symbol graph.
867
+ */
868
+ declare function traceSymbol(symbolQuery: string, options: TraceOptions): TraceResult;
869
+ /**
870
+ * Formats a TraceResult into dense S-expression notation.
871
+ */
872
+ declare function formatTraceSExpr(result: TraceResult): string;
873
+
874
+ interface SentSymbolRecord {
875
+ symbolId: string;
876
+ name: string;
877
+ level: number;
878
+ hash: string;
879
+ sentAt: number;
880
+ }
881
+ /**
882
+ * Tracks which symbols and definitions have already been delivered to an agent session.
883
+ * Replaces repetitive full declarations with dense `@Symbol` references.
884
+ */
885
+ declare class ContextLedger {
886
+ readonly sessionId: string;
887
+ private storage;
888
+ private sentMap;
889
+ constructor(sessionId: string, storage: GlyphierStorage);
890
+ /**
891
+ * Records that a symbol was delivered to the agent at a given representation level.
892
+ */
893
+ recordSent(symbolId: string, name: string, level: number, hash: string): void;
894
+ /**
895
+ * Returns true if the symbol was already delivered to this session at the same
896
+ * or higher level, and its AST hash has not changed.
897
+ */
898
+ isAlreadyKnown(symbolId: string, level: number, currentHash: string): boolean;
899
+ /**
900
+ * Returns the count of unique symbols known in this session.
901
+ */
902
+ get knownCount(): number;
903
+ /**
904
+ * Formats a shorthand reference indicating a previously delivered symbol.
905
+ */
906
+ formatReference(name: string): string;
907
+ }
908
+ declare function getContextLedger(sessionId: string, storage: GlyphierStorage): ContextLedger;
909
+
910
+ interface ContextOptimizeOptions {
911
+ task: string;
912
+ budget?: number;
913
+ rootPath?: string;
914
+ sessionId?: string;
915
+ storage?: GlyphierStorage;
916
+ }
917
+ interface OptimizedContextResult {
918
+ task: string;
919
+ budget: number;
920
+ usedTokens: number;
921
+ savedTokens: number;
922
+ files: string[];
923
+ symbols: Array<{
924
+ name: string;
925
+ isRef: boolean;
926
+ }>;
927
+ renderedContext: string;
928
+ }
929
+ /**
930
+ * Extracts key domain tokens from a natural language task prompt.
931
+ */
932
+ declare function extractTaskKeywords(task: string): string[];
933
+ /**
934
+ * Assembles a minimally sufficient, budget-optimized semantic context for an agent task.
935
+ */
936
+ declare function optimizeContext(options: ContextOptimizeOptions): Promise<OptimizedContextResult>;
937
+
938
+ interface FrameworkMetadata {
939
+ framework: string;
940
+ role: "route" | "page" | "layout" | "middleware" | "service" | "controller" | "queue" | "handler" | "model";
941
+ endpoint?: string;
942
+ method?: string;
943
+ description?: string;
944
+ }
945
+ interface FrameworkAdapter {
946
+ name: string;
947
+ detect(files: string[]): boolean;
948
+ classifyFileRole(filePath: string): string | null;
949
+ enrichSymbol(symbol: SymbolEntry): FrameworkMetadata | null;
950
+ }
951
+
952
+ declare class FrameworkRegistry {
953
+ private adapters;
954
+ constructor();
955
+ register(adapter: FrameworkAdapter): void;
956
+ detectFrameworks(files: string[]): FrameworkAdapter[];
957
+ getAdapter(name: string): FrameworkAdapter | undefined;
958
+ getAll(): FrameworkAdapter[];
959
+ }
960
+ declare const globalFrameworkRegistry: FrameworkRegistry;
961
+
962
+ declare class NextJsAdapter implements FrameworkAdapter {
963
+ readonly name = "nextjs";
964
+ detect(files: string[]): boolean;
965
+ classifyFileRole(filePath: string): string | null;
966
+ enrichSymbol(symbol: SymbolEntry): FrameworkMetadata | null;
967
+ }
968
+
969
+ interface KnowledgeEntity {
970
+ id: string;
971
+ kind: "capability" | "domain" | "service" | "api" | "queue" | "database";
972
+ name: string;
973
+ description?: string;
974
+ symbols: string[];
975
+ routes?: string[];
976
+ dependencies?: string[];
977
+ tests?: string[];
978
+ }
979
+ interface KnowledgeGraph {
980
+ entities: KnowledgeEntity[];
981
+ }
982
+ /**
983
+ * Constructs a domain-aware knowledge graph from indexed repository symbols and files.
984
+ */
985
+ declare function buildKnowledgeGraph(storage: GlyphierStorage): KnowledgeGraph;
986
+
987
+ /**
988
+ * Single source of truth for the public Glyphier release and artifact ABI.
989
+ *
990
+ * PRODUCT_VERSION follows the pre-1.0 SemVer policy in VERSIONING.md.
991
+ * ARTIFACT_SCHEMA_VERSION changes only when durable artifacts cease to
992
+ * round-trip with the prior release.
993
+ */
994
+ declare const PRODUCT_VERSION: "0.1.0";
995
+ declare const ARTIFACT_SCHEMA_VERSION: "0.1";
996
+
997
+ declare const SourceAuthoritySchema: z.ZodEnum<{
998
+ worktree: "worktree";
999
+ committed: "committed";
1000
+ generated: "generated";
1001
+ }>;
1002
+ declare const SnapshotFreshnessSchema: z.ZodEnum<{
1003
+ unknown: "unknown";
1004
+ fresh: "fresh";
1005
+ stale_source: "stale_source";
1006
+ stale_compiler: "stale_compiler";
1007
+ partially_fresh: "partially_fresh";
1008
+ }>;
1009
+ declare const AnalysisSnapshotSchema: z.ZodObject<{
1010
+ snapshotId: z.ZodString;
1011
+ repositoryId: z.ZodString;
1012
+ headRef: z.ZodNullable<z.ZodString>;
1013
+ worktreeDigest: z.ZodString;
1014
+ sourceAuthority: z.ZodEnum<{
1015
+ worktree: "worktree";
1016
+ committed: "committed";
1017
+ generated: "generated";
1018
+ }>;
1019
+ dirtyPathsDigest: z.ZodNullable<z.ZodString>;
1020
+ generatedPathsDigest: z.ZodNullable<z.ZodString>;
1021
+ compilerFingerprint: z.ZodString;
1022
+ coverageDigest: z.ZodString;
1023
+ freshness: z.ZodEnum<{
1024
+ unknown: "unknown";
1025
+ fresh: "fresh";
1026
+ stale_source: "stale_source";
1027
+ stale_compiler: "stale_compiler";
1028
+ partially_fresh: "partially_fresh";
1029
+ }>;
1030
+ capturedAt: z.ZodString;
1031
+ schemaVersion: z.ZodLiteral<"0.1">;
1032
+ }, z.core.$strip>;
1033
+ declare const EvidenceAnchorSchema: z.ZodObject<{
1034
+ path: z.ZodString;
1035
+ startLine: z.ZodOptional<z.ZodNumber>;
1036
+ endLine: z.ZodOptional<z.ZodNumber>;
1037
+ symbol: z.ZodOptional<z.ZodString>;
1038
+ }, z.core.$strip>;
1039
+ declare const EvidenceRefSchema: z.ZodObject<{
1040
+ evidenceId: z.ZodString;
1041
+ snapshotId: z.ZodString;
1042
+ sourceKind: z.ZodEnum<{
1043
+ symbol: "symbol";
1044
+ source: "source";
1045
+ test: "test";
1046
+ edge: "edge";
1047
+ document: "document";
1048
+ configuration: "configuration";
1049
+ inference: "inference";
1050
+ }>;
1051
+ anchor: z.ZodObject<{
1052
+ path: z.ZodString;
1053
+ startLine: z.ZodOptional<z.ZodNumber>;
1054
+ endLine: z.ZodOptional<z.ZodNumber>;
1055
+ symbol: z.ZodOptional<z.ZodString>;
1056
+ }, z.core.$strip>;
1057
+ excerptDigest: z.ZodString;
1058
+ freshness: z.ZodEnum<{
1059
+ unknown: "unknown";
1060
+ fresh: "fresh";
1061
+ stale_source: "stale_source";
1062
+ stale_compiler: "stale_compiler";
1063
+ partially_fresh: "partially_fresh";
1064
+ }>;
1065
+ authority: z.ZodNumber;
1066
+ schemaVersion: z.ZodLiteral<"0.1">;
1067
+ }, z.core.$strip>;
1068
+ declare const ContextArtifactSchema: z.ZodObject<{
1069
+ artifactId: z.ZodString;
1070
+ snapshot: z.ZodObject<{
1071
+ snapshotId: z.ZodString;
1072
+ repositoryId: z.ZodString;
1073
+ headRef: z.ZodNullable<z.ZodString>;
1074
+ worktreeDigest: z.ZodString;
1075
+ sourceAuthority: z.ZodEnum<{
1076
+ worktree: "worktree";
1077
+ committed: "committed";
1078
+ generated: "generated";
1079
+ }>;
1080
+ dirtyPathsDigest: z.ZodNullable<z.ZodString>;
1081
+ generatedPathsDigest: z.ZodNullable<z.ZodString>;
1082
+ compilerFingerprint: z.ZodString;
1083
+ coverageDigest: z.ZodString;
1084
+ freshness: z.ZodEnum<{
1085
+ unknown: "unknown";
1086
+ fresh: "fresh";
1087
+ stale_source: "stale_source";
1088
+ stale_compiler: "stale_compiler";
1089
+ partially_fresh: "partially_fresh";
1090
+ }>;
1091
+ capturedAt: z.ZodString;
1092
+ schemaVersion: z.ZodLiteral<"0.1">;
1093
+ }, z.core.$strip>;
1094
+ taskDigest: z.ZodString;
1095
+ riskTier: z.ZodEnum<{
1096
+ low: "low";
1097
+ high: "high";
1098
+ critical: "critical";
1099
+ medium: "medium";
1100
+ }>;
1101
+ evidence: z.ZodArray<z.ZodObject<{
1102
+ evidenceId: z.ZodString;
1103
+ snapshotId: z.ZodString;
1104
+ sourceKind: z.ZodEnum<{
1105
+ symbol: "symbol";
1106
+ source: "source";
1107
+ test: "test";
1108
+ edge: "edge";
1109
+ document: "document";
1110
+ configuration: "configuration";
1111
+ inference: "inference";
1112
+ }>;
1113
+ anchor: z.ZodObject<{
1114
+ path: z.ZodString;
1115
+ startLine: z.ZodOptional<z.ZodNumber>;
1116
+ endLine: z.ZodOptional<z.ZodNumber>;
1117
+ symbol: z.ZodOptional<z.ZodString>;
1118
+ }, z.core.$strip>;
1119
+ excerptDigest: z.ZodString;
1120
+ freshness: z.ZodEnum<{
1121
+ unknown: "unknown";
1122
+ fresh: "fresh";
1123
+ stale_source: "stale_source";
1124
+ stale_compiler: "stale_compiler";
1125
+ partially_fresh: "partially_fresh";
1126
+ }>;
1127
+ authority: z.ZodNumber;
1128
+ schemaVersion: z.ZodLiteral<"0.1">;
1129
+ }, z.core.$strip>>;
1130
+ selectedEvidenceIds: z.ZodArray<z.ZodString>;
1131
+ excludedEvidence: z.ZodArray<z.ZodObject<{
1132
+ evidenceId: z.ZodString;
1133
+ reason: z.ZodString;
1134
+ }, z.core.$strip>>;
1135
+ tokenBudget: z.ZodNumber;
1136
+ tokensUsed: z.ZodNumber;
1137
+ claimLedger: z.ZodArray<z.ZodObject<{
1138
+ claimId: z.ZodString;
1139
+ kind: z.ZodEnum<{
1140
+ unknown: "unknown";
1141
+ inference: "inference";
1142
+ fact: "fact";
1143
+ }>;
1144
+ evidenceIds: z.ZodArray<z.ZodString>;
1145
+ supported: z.ZodBoolean;
1146
+ }, z.core.$strip>>;
1147
+ schemaVersion: z.ZodLiteral<"0.1">;
1148
+ }, z.core.$strip>;
1149
+ declare const ReceiptKindSchema: z.ZodEnum<{
1150
+ verification: "verification";
1151
+ review: "review";
1152
+ knowledge_promotion: "knowledge_promotion";
1153
+ invalidation: "invalidation";
1154
+ provider_decision: "provider_decision";
1155
+ sync_delivery: "sync_delivery";
1156
+ }>;
1157
+ declare const ReceiptSchema: z.ZodObject<{
1158
+ receiptId: z.ZodString;
1159
+ kind: z.ZodEnum<{
1160
+ verification: "verification";
1161
+ review: "review";
1162
+ knowledge_promotion: "knowledge_promotion";
1163
+ invalidation: "invalidation";
1164
+ provider_decision: "provider_decision";
1165
+ sync_delivery: "sync_delivery";
1166
+ }>;
1167
+ repositoryId: z.ZodString;
1168
+ snapshotId: z.ZodString;
1169
+ principalId: z.ZodString;
1170
+ policyRevision: z.ZodString;
1171
+ subjectDigest: z.ZodString;
1172
+ evidenceDigests: z.ZodArray<z.ZodString>;
1173
+ issuedAt: z.ZodString;
1174
+ schemaVersion: z.ZodLiteral<"0.1">;
1175
+ }, z.core.$strip>;
1176
+ declare const DecisionClassSchema: z.ZodEnum<{
1177
+ evidence_disposition: "evidence_disposition";
1178
+ sufficiency_routing: "sufficiency_routing";
1179
+ documentation_assertion_support: "documentation_assertion_support";
1180
+ prompt_injection_signal: "prompt_injection_signal";
1181
+ }>;
1182
+ declare const DecisionPacketSchema: z.ZodObject<{
1183
+ packetId: z.ZodString;
1184
+ repositoryId: z.ZodString;
1185
+ snapshotId: z.ZodString;
1186
+ principalId: z.ZodString;
1187
+ policyRevision: z.ZodString;
1188
+ decisionClass: z.ZodEnum<{
1189
+ evidence_disposition: "evidence_disposition";
1190
+ sufficiency_routing: "sufficiency_routing";
1191
+ documentation_assertion_support: "documentation_assertion_support";
1192
+ prompt_injection_signal: "prompt_injection_signal";
1193
+ }>;
1194
+ riskTier: z.ZodEnum<{
1195
+ low: "low";
1196
+ high: "high";
1197
+ critical: "critical";
1198
+ medium: "medium";
1199
+ }>;
1200
+ contextDigest: z.ZodString;
1201
+ evidenceDigests: z.ZodArray<z.ZodString>;
1202
+ inputBytes: z.ZodNumber;
1203
+ model: z.ZodString;
1204
+ schemaVersion: z.ZodLiteral<"0.1">;
1205
+ }, z.core.$strip>;
1206
+ type AnalysisSnapshot = z.infer<typeof AnalysisSnapshotSchema>;
1207
+ type EvidenceRef = z.infer<typeof EvidenceRefSchema>;
1208
+ type ContextArtifact = z.infer<typeof ContextArtifactSchema>;
1209
+ type Receipt = z.infer<typeof ReceiptSchema>;
1210
+ type DecisionPacket = z.infer<typeof DecisionPacketSchema>;
1211
+ type DecisionClass = z.infer<typeof DecisionClassSchema>;
1212
+ /** Produce a stable SHA-256 over an object without relying on insertion order. */
1213
+ declare function digestCanonical(value: unknown): string;
1214
+ /** Only low-risk, explicitly approved judgment classes may leave the device. */
1215
+ declare function assertJevEligible(packet: DecisionPacket): void;
1216
+
1217
+ declare const SnapshotSymbolIdSchema: z.ZodString;
1218
+ declare const LogicalEntityIdSchema: z.ZodString;
1219
+ declare const IdentityMappingClaimSchema: z.ZodObject<{
1220
+ claimId: z.ZodString;
1221
+ fromSnapshotId: z.ZodString;
1222
+ toSnapshotId: z.ZodString;
1223
+ fromSymbolId: z.ZodString;
1224
+ toSymbolId: z.ZodString;
1225
+ logicalEntityId: z.ZodString;
1226
+ evidenceDigests: z.ZodArray<z.ZodString>;
1227
+ replayAlgorithm: z.ZodString;
1228
+ replayInputDigest: z.ZodString;
1229
+ confidence: z.ZodNumber;
1230
+ issuedAt: z.ZodString;
1231
+ schemaVersion: z.ZodLiteral<"0.1">;
1232
+ }, z.core.$strip>;
1233
+ type IdentityMappingClaim = z.infer<typeof IdentityMappingClaimSchema>;
1234
+ type IdentityCandidate = {
1235
+ snapshotSymbolId: string;
1236
+ evidenceDigests: string[];
1237
+ score: number;
1238
+ };
1239
+ type IdentityResolution = {
1240
+ outcome: "mapped";
1241
+ winner: IdentityCandidate;
1242
+ } | {
1243
+ outcome: "abstained";
1244
+ reason: "no_candidate" | "ambiguous" | "insufficient_proof";
1245
+ };
1246
+ /**
1247
+ * Automatic preservation is intentionally conservative. A mapping needs one
1248
+ * qualifying candidate and a material separation from every alternative.
1249
+ */
1250
+ declare function resolveIdentity(candidates: IdentityCandidate[], minimumScore?: number, minimumMargin?: number): IdentityResolution;
1251
+ declare function createSnapshotSymbolId(snapshotId: string, qualifiedName: string, kind: string): string;
1252
+ declare function createLogicalEntityId(repositoryId: string, seed: string): string;
1253
+
1254
+ declare const GlyphierLanguageSchema: z.ZodEnum<{
1255
+ typescript: "typescript";
1256
+ tsx: "tsx";
1257
+ javascript: "javascript";
1258
+ python: "python";
1259
+ rust: "rust";
1260
+ go: "go";
1261
+ java: "java";
1262
+ c: "c";
1263
+ cpp: "cpp";
1264
+ c_sharp: "c_sharp";
1265
+ ruby: "ruby";
1266
+ php: "php";
1267
+ swift: "swift";
1268
+ kotlin: "kotlin";
1269
+ lua: "lua";
1270
+ zig: "zig";
1271
+ elm: "elm";
1272
+ elixir: "elixir";
1273
+ bash: "bash";
1274
+ }>;
1275
+ declare const CapabilitySchema: z.ZodEnum<{
1276
+ slice: "slice";
1277
+ symbols: "symbols";
1278
+ diff: "diff";
1279
+ freshness: "freshness";
1280
+ snapshot: "snapshot";
1281
+ evidence: "evidence";
1282
+ parse: "parse";
1283
+ imports_exports: "imports_exports";
1284
+ call_edges: "call_edges";
1285
+ semantic_search: "semantic_search";
1286
+ impact: "impact";
1287
+ identity: "identity";
1288
+ }>;
1289
+ declare const CalibrationStateSchema: z.ZodEnum<{
1290
+ unqualified: "unqualified";
1291
+ provisional: "provisional";
1292
+ calibrated: "calibrated";
1293
+ high_risk_qualified: "high_risk_qualified";
1294
+ }>;
1295
+ declare const LanguageCapabilityProfileSchema: z.ZodObject<{
1296
+ language: z.ZodEnum<{
1297
+ typescript: "typescript";
1298
+ tsx: "tsx";
1299
+ javascript: "javascript";
1300
+ python: "python";
1301
+ rust: "rust";
1302
+ go: "go";
1303
+ java: "java";
1304
+ c: "c";
1305
+ cpp: "cpp";
1306
+ c_sharp: "c_sharp";
1307
+ ruby: "ruby";
1308
+ php: "php";
1309
+ swift: "swift";
1310
+ kotlin: "kotlin";
1311
+ lua: "lua";
1312
+ zig: "zig";
1313
+ elm: "elm";
1314
+ elixir: "elixir";
1315
+ bash: "bash";
1316
+ }>;
1317
+ framework: z.ZodDefault<z.ZodString>;
1318
+ taskClass: z.ZodEnum<{
1319
+ review: "review";
1320
+ bug_fix: "bug_fix";
1321
+ refactor: "refactor";
1322
+ feature: "feature";
1323
+ investigation: "investigation";
1324
+ }>;
1325
+ riskTier: z.ZodEnum<{
1326
+ low: "low";
1327
+ high: "high";
1328
+ critical: "critical";
1329
+ medium: "medium";
1330
+ }>;
1331
+ compilerFingerprint: z.ZodString;
1332
+ supportedCapabilities: z.ZodArray<z.ZodEnum<{
1333
+ slice: "slice";
1334
+ symbols: "symbols";
1335
+ diff: "diff";
1336
+ freshness: "freshness";
1337
+ snapshot: "snapshot";
1338
+ evidence: "evidence";
1339
+ parse: "parse";
1340
+ imports_exports: "imports_exports";
1341
+ call_edges: "call_edges";
1342
+ semantic_search: "semantic_search";
1343
+ impact: "impact";
1344
+ identity: "identity";
1345
+ }>>;
1346
+ fixtures: z.ZodNumber;
1347
+ falseSufficiencyEvents: z.ZodNumber;
1348
+ calibration: z.ZodEnum<{
1349
+ unqualified: "unqualified";
1350
+ provisional: "provisional";
1351
+ calibrated: "calibrated";
1352
+ high_risk_qualified: "high_risk_qualified";
1353
+ }>;
1354
+ }, z.core.$strip>;
1355
+ type GlyphierLanguage = z.infer<typeof GlyphierLanguageSchema>;
1356
+ type LanguageCapabilityProfile = z.infer<typeof LanguageCapabilityProfileSchema>;
1357
+ declare const REGISTERED_LANGUAGE_CATALOG: ("typescript" | "tsx" | "javascript" | "python" | "rust" | "go" | "java" | "c" | "cpp" | "c_sharp" | "ruby" | "php" | "swift" | "kotlin" | "lua" | "zig" | "elm" | "elixir" | "bash")[];
1358
+ declare const REQUIRED_CAPABILITIES: ("slice" | "symbols" | "diff" | "freshness" | "snapshot" | "evidence" | "parse" | "imports_exports" | "call_edges" | "semantic_search" | "impact" | "identity")[];
1359
+ /** The conservative zero-event upper bound used by the architecture gate. */
1360
+ declare function upperFalseSufficiencyBound(fixtures: number, falseSufficiencyEvents: number): number;
1361
+ declare function canPromoteCalibration(profile: LanguageCapabilityProfile): boolean;
1362
+
1363
+ declare const SyncScopeSchema: z.ZodEnum<{
1364
+ local: "local";
1365
+ enterprise: "enterprise";
1366
+ team: "team";
1367
+ }>;
1368
+ declare const SyncEnvelopeSchema: z.ZodObject<{
1369
+ eventId: z.ZodString;
1370
+ tenantId: z.ZodString;
1371
+ repositoryId: z.ZodString;
1372
+ principalId: z.ZodString;
1373
+ scope: z.ZodEnum<{
1374
+ local: "local";
1375
+ enterprise: "enterprise";
1376
+ team: "team";
1377
+ }>;
1378
+ sensitivity: z.ZodEnum<{
1379
+ public: "public";
1380
+ internal: "internal";
1381
+ restricted: "restricted";
1382
+ }>;
1383
+ receipt: z.ZodObject<{
1384
+ receiptId: z.ZodString;
1385
+ kind: z.ZodEnum<{
1386
+ verification: "verification";
1387
+ review: "review";
1388
+ knowledge_promotion: "knowledge_promotion";
1389
+ invalidation: "invalidation";
1390
+ provider_decision: "provider_decision";
1391
+ sync_delivery: "sync_delivery";
1392
+ }>;
1393
+ repositoryId: z.ZodString;
1394
+ snapshotId: z.ZodString;
1395
+ principalId: z.ZodString;
1396
+ policyRevision: z.ZodString;
1397
+ subjectDigest: z.ZodString;
1398
+ evidenceDigests: z.ZodArray<z.ZodString>;
1399
+ issuedAt: z.ZodString;
1400
+ schemaVersion: z.ZodLiteral<"0.1">;
1401
+ }, z.core.$strip>;
1402
+ invalidatesReceiptIds: z.ZodArray<z.ZodString>;
1403
+ expiresAt: z.ZodNullable<z.ZodString>;
1404
+ signature: z.ZodString;
1405
+ schemaVersion: z.ZodLiteral<"0.1">;
1406
+ }, z.core.$strip>;
1407
+ type SyncEnvelope = z.infer<typeof SyncEnvelopeSchema>;
1408
+ declare function signSyncEnvelope(envelope: Omit<SyncEnvelope, "signature">, signingSecret: string): SyncEnvelope;
1409
+ declare function verifySyncEnvelope(envelope: SyncEnvelope, signingSecret: string, expectedTenantId: string): boolean;
1410
+
1411
+ type BuildSnapshotOptions = {
1412
+ rootPath: string;
1413
+ now?: Date;
1414
+ };
1415
+ /**
1416
+ * Filesystem/Git adapter for snapshot capture. Source bytes are used only to
1417
+ * derive digests and never appear in the returned AnalysisSnapshot.
1418
+ */
1419
+ declare function buildAnalysisSnapshot(options: BuildSnapshotOptions): AnalysisSnapshot;
1420
+
1421
+ export { ARTIFACT_SCHEMA_VERSION, type AnalysisSnapshot, AnalysisSnapshotSchema, type BudgetPlan, type BudgetProjectionOptions, type BudgetProjectionResult, type BuildSnapshotOptions, type BuildTreeOptions, CalibrationStateSchema, type CallerReference, CapabilitySchema, type ClassNode, type ContextArtifact, ContextArtifactSchema, ContextLedger, type ContextOptimizeOptions, DEFAULT_CONFIG, type DecisionClass, DecisionClassSchema, type DecisionPacket, DecisionPacketSchema, type DeclarationDelta, EXTENSION_TO_LANGUAGE, type EdgeKind, type ErrorNode, EvidenceAnchorSchema, type EvidenceRef, EvidenceRefSchema, type ExternalDependency, type FileClassification, type FileMetadata, type FileStat, type FormatSExprOptions, type FrameworkAdapter, type FrameworkMetadata, FrameworkRegistry, type FunctionNode, type GenerateIROptions, type Glyphier, type GlyphierConfig, type GlyphierLanguage, GlyphierLanguageSchema, GlyphierStorage, type GraphOptions, type IdentityCandidate, type IdentityMappingClaim, IdentityMappingClaimSchema, type IdentityResolution, type ImpactAnalysisResult, type ImpactOptions, type ImportNode, type IndexStats, type KnowledgeEntity, type KnowledgeGraph, type LanguageCapabilityProfile, LanguageCapabilityProfileSchema, type LicenseSession, type LineRange, LogicalEntityIdSchema, type ModuleNode, MtimeCache, NextJsAdapter, type OptimizedContextResult, PRODUCT_VERSION, type ParseFileOptions, type ParseProjectOptions, type ParseResult, type PatchAction, type PatchOperation, type PatchResult, type PreflightCheckOptions, type PreflightCheckResult, type ProgramSliceResult, type ProjectParseResult, type ProjectStats, type QueueInfo, REGISTERED_LANGUAGE_CATALOG, REQUIRED_CAPABILITIES, type ReadRawOptions, type Receipt, ReceiptKindSchema, ReceiptSchema, type ScopedCall, type SearchOptions, type SearchResult, type SearchTarget, type SemanticDiffOptions, type SemanticDiffResult, type SentSymbolRecord, type SessionDeltaResult, type SliceNode, type SliceOptions, SnapshotFreshnessSchema, SnapshotSymbolIdSchema, SourceAuthoritySchema, type StatsOptions, type StoredEdge, type StoredFact, type StoredFile, type StoredSession, type StoredSymbol, type SubsystemGraph, type SymbolEdge, type SymbolEntry, type SymbolKind, type SyncEnvelope, SyncEnvelopeSchema, SyncScopeSchema, type TraceNode, type TraceOptions, type TraceResult, type TreeNode, type TypeNode, abbreviateType, analyzeImpact, analyzeModuleGraph, applyAstPatch, assertJevEligible, assertPaidLicense, buildAnalysisSnapshot, buildKnowledgeGraph, buildTree, canPromoteCalibration, classifyFile, clearSession, computeProgramSlice, computeSessionDelta, computeStats, computeSymbolId, createLogicalEntityId, createSnapshotSymbolId, detectLanguage, digestCanonical, extractSymbolsFromIR, extractTaskKeywords, findProjectRoot, formatCheckSExpr, formatDeltaSExpr, formatDiffSExpr, formatGraphSExpr, formatImpactSExpr, formatJSON, formatSExpr, formatSearchResults, formatSliceSExpr, formatStatsSExpr, formatTraceSExpr, formatTrie, generateIR, getApiKey, getContextLedger, getInverseEdgeKind, getMachineFingerprint, getStorage, getSupportedLanguages, globalCache, globalFrameworkRegistry, indexProject, initTreeSitter, loadConfig, loadLanguage, optimizeContext, parseFile, parseFileTree, parseProject, parseSource, preflightCheck, projectBudget, readRaw, reportTokenTelemetry, resolveIdentity, resolveModuleEdges, searchIR, semanticDiff, signSyncEnvelope, traceSymbol, upperFalseSufficiencyBound, verifyLicense, verifySyncEnvelope };