@titan-design/code-read 0.0.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,953 @@
1
+ import { z, ZodType } from 'zod';
2
+ import { JsonEnvelope } from '@titan-design/rpc-protocol';
3
+
4
+ /** The read API's semver. Bump it whenever `CONTRACT` changes; `contract.lock.json` records the last one. */
5
+ declare const CODE_READ_API_VERSION = "0.1.2";
6
+ interface CommandContract<Args extends ZodType = ZodType, Result extends ZodType = ZodType> {
7
+ description: string;
8
+ args: Args;
9
+ result: Result;
10
+ }
11
+ /** The single source of command names, argument schemas, and result schemas for every surface. */
12
+ declare const CONTRACT: {
13
+ readonly "api.describe": {
14
+ readonly description: "Contract version, commands served, capabilities, the newest snapshot, and the metric and rule catalogues. Call first to pin compatibility.";
15
+ readonly args: z.ZodObject<{}, z.core.$strip>;
16
+ readonly result: z.ZodObject<{
17
+ api: z.ZodString;
18
+ dataset: z.ZodEnum<{
19
+ live: "live";
20
+ static: "static";
21
+ }>;
22
+ commands: z.ZodArray<z.ZodString>;
23
+ newest: z.ZodNullable<z.ZodObject<{
24
+ id: z.ZodNumber;
25
+ ref: z.ZodString;
26
+ commit: z.ZodNullable<z.ZodString>;
27
+ takenAt: z.ZodString;
28
+ indexVersion: z.ZodString;
29
+ }, z.core.$strip>>;
30
+ indexVersions: z.ZodArray<z.ZodString>;
31
+ capabilities: z.ZodObject<{
32
+ findings: z.ZodEnum<{
33
+ none: "none";
34
+ "check-rules": "check-rules";
35
+ store: "store";
36
+ }>;
37
+ verdicts: z.ZodBoolean;
38
+ themes: z.ZodBoolean;
39
+ feedback: z.ZodBoolean;
40
+ embeddings: z.ZodNullable<z.ZodObject<{
41
+ model: z.ZodString;
42
+ embedded: z.ZodNumber;
43
+ symbols: z.ZodNumber;
44
+ }, z.core.$strip>>;
45
+ cochange: z.ZodBoolean;
46
+ sourceAtCommit: z.ZodBoolean;
47
+ excerpts: z.ZodEnum<{
48
+ any: "any";
49
+ none: "none";
50
+ flagged: "flagged";
51
+ }>;
52
+ }, z.core.$strip>;
53
+ metrics: z.ZodArray<z.ZodObject<{
54
+ name: z.ZodString;
55
+ unit: z.ZodNullable<z.ZodString>;
56
+ appliesTo: z.ZodArray<z.ZodString>;
57
+ rollup: z.ZodEnum<{
58
+ sum: "sum";
59
+ max: "max";
60
+ mean: "mean";
61
+ none: "none";
62
+ }>;
63
+ direction: z.ZodEnum<{
64
+ "higher-worse": "higher-worse";
65
+ "lower-worse": "lower-worse";
66
+ neutral: "neutral";
67
+ }>;
68
+ absent: z.ZodEnum<{
69
+ zero: "zero";
70
+ exclude: "exclude";
71
+ }>;
72
+ window: z.ZodOptional<z.ZodString>;
73
+ description: z.ZodString;
74
+ provenance: z.ZodObject<{
75
+ kind: z.ZodEnum<{
76
+ measured: "measured";
77
+ derived: "derived";
78
+ model: "model";
79
+ }>;
80
+ source: z.ZodString;
81
+ at: z.ZodOptional<z.ZodString>;
82
+ }, z.core.$strip>;
83
+ }, z.core.$strip>>;
84
+ rules: z.ZodArray<z.ZodObject<{
85
+ id: z.ZodString;
86
+ type: z.ZodString;
87
+ severity: z.ZodString;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$strip>;
90
+ };
91
+ readonly "snapshot.list": {
92
+ readonly description: "Indexed snapshots, newest first, with ref, commit, time, and index version. Optionally one ref only.";
93
+ readonly args: z.ZodObject<{
94
+ ref: z.ZodOptional<z.ZodString>;
95
+ limit: z.ZodDefault<z.ZodNumber>;
96
+ }, z.core.$strip>;
97
+ readonly result: z.ZodObject<{
98
+ snapshots: z.ZodArray<z.ZodObject<{
99
+ id: z.ZodNumber;
100
+ ref: z.ZodString;
101
+ commit: z.ZodNullable<z.ZodString>;
102
+ takenAt: z.ZodString;
103
+ indexVersion: z.ZodString;
104
+ }, z.core.$strip>>;
105
+ }, z.core.$strip>;
106
+ };
107
+ readonly "hierarchy.get": {
108
+ readonly description: string;
109
+ readonly args: z.ZodObject<{
110
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
111
+ root: z.ZodOptional<z.ZodString>;
112
+ depth: z.ZodDefault<z.ZodNumber>;
113
+ metrics: z.ZodDefault<z.ZodArray<z.ZodString>>;
114
+ baseline: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
115
+ include_symbols: z.ZodDefault<z.ZodBoolean>;
116
+ exclude_roles: z.ZodDefault<z.ZodArray<z.ZodString>>;
117
+ }, z.core.$strip>;
118
+ readonly result: z.ZodObject<{
119
+ nodes: z.ZodArray<z.ZodObject<{
120
+ id: z.ZodString;
121
+ kind: z.ZodString;
122
+ name: z.ZodString;
123
+ path: z.ZodString;
124
+ span: z.ZodOptional<z.ZodObject<{
125
+ startLine: z.ZodNumber;
126
+ endLine: z.ZodNumber;
127
+ }, z.core.$strip>>;
128
+ parentId: z.ZodNullable<z.ZodString>;
129
+ depth: z.ZodNumber;
130
+ childCount: z.ZodNumber;
131
+ role: z.ZodOptional<z.ZodString>;
132
+ values: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>;
133
+ missing: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
134
+ deltas: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>>;
135
+ }, z.core.$strip>>;
136
+ truncated: z.ZodBoolean;
137
+ baselineSnapshotId: z.ZodOptional<z.ZodNumber>;
138
+ comparable: z.ZodOptional<z.ZodBoolean>;
139
+ snapshotId: z.ZodNumber;
140
+ }, z.core.$strip>;
141
+ };
142
+ readonly "node.get": {
143
+ readonly description: string;
144
+ readonly args: z.ZodObject<{
145
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
146
+ id: z.ZodString;
147
+ baseline: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
148
+ metrics: z.ZodDefault<z.ZodArray<z.ZodString>>;
149
+ }, z.core.$strip>;
150
+ readonly result: z.ZodObject<{
151
+ node: z.ZodObject<{
152
+ id: z.ZodString;
153
+ kind: z.ZodString;
154
+ name: z.ZodString;
155
+ path: z.ZodString;
156
+ span: z.ZodOptional<z.ZodObject<{
157
+ startLine: z.ZodNumber;
158
+ endLine: z.ZodNumber;
159
+ }, z.core.$strip>>;
160
+ language: z.ZodOptional<z.ZodString>;
161
+ role: z.ZodOptional<z.ZodString>;
162
+ exported: z.ZodOptional<z.ZodBoolean>;
163
+ signature: z.ZodOptional<z.ZodString>;
164
+ purpose: z.ZodOptional<z.ZodString>;
165
+ }, z.core.$strip>;
166
+ ancestors: z.ZodArray<z.ZodObject<{
167
+ id: z.ZodString;
168
+ kind: z.ZodString;
169
+ name: z.ZodString;
170
+ path: z.ZodString;
171
+ span: z.ZodOptional<z.ZodObject<{
172
+ startLine: z.ZodNumber;
173
+ endLine: z.ZodNumber;
174
+ }, z.core.$strip>>;
175
+ }, z.core.$strip>>;
176
+ childCounts: z.ZodRecord<z.ZodString, z.ZodNumber>;
177
+ metrics: z.ZodArray<z.ZodObject<{
178
+ name: z.ZodString;
179
+ unit: z.ZodNullable<z.ZodString>;
180
+ direction: z.ZodEnum<{
181
+ "higher-worse": "higher-worse";
182
+ "lower-worse": "lower-worse";
183
+ neutral: "neutral";
184
+ }>;
185
+ rollup: z.ZodEnum<{
186
+ sum: "sum";
187
+ max: "max";
188
+ mean: "mean";
189
+ none: "none";
190
+ }>;
191
+ value: z.ZodNullable<z.ZodNumber>;
192
+ missing: z.ZodOptional<z.ZodString>;
193
+ percentile: z.ZodNullable<z.ZodNumber>;
194
+ siblingMedian: z.ZodNullable<z.ZodNumber>;
195
+ siblingRank: z.ZodNullable<z.ZodNumber>;
196
+ siblingCount: z.ZodNumber;
197
+ baseline: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
198
+ delta: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
199
+ }, z.core.$strip>>;
200
+ baselineSnapshotId: z.ZodOptional<z.ZodNumber>;
201
+ comparable: z.ZodOptional<z.ZodBoolean>;
202
+ snapshotId: z.ZodNumber;
203
+ }, z.core.$strip>;
204
+ };
205
+ readonly "node.resolve": {
206
+ readonly description: string;
207
+ readonly args: z.ZodObject<{
208
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
209
+ query: z.ZodOptional<z.ZodString>;
210
+ path: z.ZodOptional<z.ZodString>;
211
+ line: z.ZodOptional<z.ZodNumber>;
212
+ limit: z.ZodDefault<z.ZodNumber>;
213
+ }, z.core.$strip>;
214
+ readonly result: z.ZodObject<{
215
+ candidates: z.ZodArray<z.ZodObject<{
216
+ node: z.ZodObject<{
217
+ id: z.ZodString;
218
+ kind: z.ZodString;
219
+ name: z.ZodString;
220
+ path: z.ZodString;
221
+ span: z.ZodOptional<z.ZodObject<{
222
+ startLine: z.ZodNumber;
223
+ endLine: z.ZodNumber;
224
+ }, z.core.$strip>>;
225
+ }, z.core.$strip>;
226
+ score: z.ZodNumber;
227
+ match: z.ZodString;
228
+ }, z.core.$strip>>;
229
+ }, z.core.$strip>;
230
+ };
231
+ readonly "findings.list": {
232
+ readonly description: string;
233
+ readonly args: z.ZodObject<{
234
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
235
+ baseline: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
236
+ scope: z.ZodOptional<z.ZodString>;
237
+ rule: z.ZodDefault<z.ZodArray<z.ZodString>>;
238
+ severity: z.ZodDefault<z.ZodArray<z.ZodString>>;
239
+ tool: z.ZodDefault<z.ZodArray<z.ZodString>>;
240
+ provenance: z.ZodDefault<z.ZodArray<z.ZodEnum<{
241
+ measured: "measured";
242
+ derived: "derived";
243
+ model: "model";
244
+ }>>>;
245
+ kind: z.ZodDefault<z.ZodArray<z.ZodString>>;
246
+ status: z.ZodDefault<z.ZodArray<z.ZodEnum<{
247
+ new: "new";
248
+ carryover: "carryover";
249
+ resolved: "resolved";
250
+ worsened: "worsened";
251
+ improved: "improved";
252
+ }>>>;
253
+ sort: z.ZodDefault<z.ZodEnum<{
254
+ severity: "severity";
255
+ value: "value";
256
+ path: "path";
257
+ rule: "rule";
258
+ excess: "excess";
259
+ }>>;
260
+ order: z.ZodDefault<z.ZodEnum<{
261
+ asc: "asc";
262
+ desc: "desc";
263
+ }>>;
264
+ offset: z.ZodDefault<z.ZodNumber>;
265
+ limit: z.ZodDefault<z.ZodNumber>;
266
+ facets: z.ZodDefault<z.ZodBoolean>;
267
+ }, z.core.$strip>;
268
+ readonly result: z.ZodObject<{
269
+ rows: z.ZodArray<z.ZodObject<{
270
+ id: z.ZodString;
271
+ snapshotId: z.ZodNumber;
272
+ rule: z.ZodString;
273
+ tool: z.ZodString;
274
+ severity: z.ZodString;
275
+ node: z.ZodObject<{
276
+ id: z.ZodString;
277
+ kind: z.ZodString;
278
+ name: z.ZodString;
279
+ path: z.ZodString;
280
+ span: z.ZodOptional<z.ZodObject<{
281
+ startLine: z.ZodNumber;
282
+ endLine: z.ZodNumber;
283
+ }, z.core.$strip>>;
284
+ }, z.core.$strip>;
285
+ destination: z.ZodOptional<z.ZodObject<{
286
+ id: z.ZodString;
287
+ kind: z.ZodString;
288
+ name: z.ZodString;
289
+ path: z.ZodString;
290
+ span: z.ZodOptional<z.ZodObject<{
291
+ startLine: z.ZodNumber;
292
+ endLine: z.ZodNumber;
293
+ }, z.core.$strip>>;
294
+ }, z.core.$strip>>;
295
+ range: z.ZodOptional<z.ZodObject<{
296
+ startLine: z.ZodNumber;
297
+ endLine: z.ZodNumber;
298
+ }, z.core.$strip>>;
299
+ metric: z.ZodOptional<z.ZodString>;
300
+ value: z.ZodOptional<z.ZodNumber>;
301
+ threshold: z.ZodOptional<z.ZodNumber>;
302
+ excess: z.ZodNullable<z.ZodNumber>;
303
+ status: z.ZodOptional<z.ZodEnum<{
304
+ new: "new";
305
+ carryover: "carryover";
306
+ resolved: "resolved";
307
+ worsened: "worsened";
308
+ improved: "improved";
309
+ }>>;
310
+ message: z.ZodString;
311
+ provenance: z.ZodObject<{
312
+ kind: z.ZodEnum<{
313
+ measured: "measured";
314
+ derived: "derived";
315
+ model: "model";
316
+ }>;
317
+ source: z.ZodString;
318
+ at: z.ZodOptional<z.ZodString>;
319
+ }, z.core.$strip>;
320
+ }, z.core.$strip>>;
321
+ total: z.ZodNumber;
322
+ facets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>>;
323
+ baselineSnapshotId: z.ZodOptional<z.ZodNumber>;
324
+ comparable: z.ZodOptional<z.ZodBoolean>;
325
+ snapshotId: z.ZodNumber;
326
+ }, z.core.$strip>;
327
+ };
328
+ readonly "finding.get": {
329
+ readonly description: string;
330
+ readonly args: z.ZodObject<{
331
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
332
+ id: z.ZodString;
333
+ baseline: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
334
+ context_lines: z.ZodDefault<z.ZodNumber>;
335
+ }, z.core.$strip>;
336
+ readonly result: z.ZodObject<{
337
+ finding: z.ZodObject<{
338
+ id: z.ZodString;
339
+ snapshotId: z.ZodNumber;
340
+ rule: z.ZodString;
341
+ tool: z.ZodString;
342
+ severity: z.ZodString;
343
+ node: z.ZodObject<{
344
+ id: z.ZodString;
345
+ kind: z.ZodString;
346
+ name: z.ZodString;
347
+ path: z.ZodString;
348
+ span: z.ZodOptional<z.ZodObject<{
349
+ startLine: z.ZodNumber;
350
+ endLine: z.ZodNumber;
351
+ }, z.core.$strip>>;
352
+ }, z.core.$strip>;
353
+ destination: z.ZodOptional<z.ZodObject<{
354
+ id: z.ZodString;
355
+ kind: z.ZodString;
356
+ name: z.ZodString;
357
+ path: z.ZodString;
358
+ span: z.ZodOptional<z.ZodObject<{
359
+ startLine: z.ZodNumber;
360
+ endLine: z.ZodNumber;
361
+ }, z.core.$strip>>;
362
+ }, z.core.$strip>>;
363
+ range: z.ZodOptional<z.ZodObject<{
364
+ startLine: z.ZodNumber;
365
+ endLine: z.ZodNumber;
366
+ }, z.core.$strip>>;
367
+ metric: z.ZodOptional<z.ZodString>;
368
+ value: z.ZodOptional<z.ZodNumber>;
369
+ threshold: z.ZodOptional<z.ZodNumber>;
370
+ excess: z.ZodNullable<z.ZodNumber>;
371
+ status: z.ZodOptional<z.ZodEnum<{
372
+ new: "new";
373
+ carryover: "carryover";
374
+ resolved: "resolved";
375
+ worsened: "worsened";
376
+ improved: "improved";
377
+ }>>;
378
+ message: z.ZodString;
379
+ provenance: z.ZodObject<{
380
+ kind: z.ZodEnum<{
381
+ measured: "measured";
382
+ derived: "derived";
383
+ model: "model";
384
+ }>;
385
+ source: z.ZodString;
386
+ at: z.ZodOptional<z.ZodString>;
387
+ }, z.core.$strip>;
388
+ }, z.core.$strip>;
389
+ rule: z.ZodObject<{
390
+ id: z.ZodString;
391
+ type: z.ZodString;
392
+ severity: z.ZodString;
393
+ text: z.ZodString;
394
+ }, z.core.$strip>;
395
+ measured: z.ZodObject<{
396
+ value: z.ZodNullable<z.ZodNumber>;
397
+ threshold: z.ZodNullable<z.ZodNumber>;
398
+ percentile: z.ZodNullable<z.ZodNumber>;
399
+ siblingMedian: z.ZodNullable<z.ZodNumber>;
400
+ baselineValue: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
401
+ }, z.core.$strip>;
402
+ why: z.ZodString;
403
+ excerpt: z.ZodNullable<z.ZodObject<{
404
+ path: z.ZodString;
405
+ startLine: z.ZodNumber;
406
+ endLine: z.ZodNumber;
407
+ text: z.ZodString;
408
+ contentHash: z.ZodString;
409
+ origin: z.ZodEnum<{
410
+ commit: "commit";
411
+ worktree: "worktree";
412
+ export: "export";
413
+ }>;
414
+ highlights: z.ZodArray<z.ZodObject<{
415
+ startLine: z.ZodNumber;
416
+ endLine: z.ZodNumber;
417
+ }, z.core.$strip>>;
418
+ truncated: z.ZodBoolean;
419
+ }, z.core.$strip>>;
420
+ excerptMissing: z.ZodOptional<z.ZodString>;
421
+ related: z.ZodArray<z.ZodObject<{
422
+ id: z.ZodString;
423
+ snapshotId: z.ZodNumber;
424
+ rule: z.ZodString;
425
+ tool: z.ZodString;
426
+ severity: z.ZodString;
427
+ node: z.ZodObject<{
428
+ id: z.ZodString;
429
+ kind: z.ZodString;
430
+ name: z.ZodString;
431
+ path: z.ZodString;
432
+ span: z.ZodOptional<z.ZodObject<{
433
+ startLine: z.ZodNumber;
434
+ endLine: z.ZodNumber;
435
+ }, z.core.$strip>>;
436
+ }, z.core.$strip>;
437
+ destination: z.ZodOptional<z.ZodObject<{
438
+ id: z.ZodString;
439
+ kind: z.ZodString;
440
+ name: z.ZodString;
441
+ path: z.ZodString;
442
+ span: z.ZodOptional<z.ZodObject<{
443
+ startLine: z.ZodNumber;
444
+ endLine: z.ZodNumber;
445
+ }, z.core.$strip>>;
446
+ }, z.core.$strip>>;
447
+ range: z.ZodOptional<z.ZodObject<{
448
+ startLine: z.ZodNumber;
449
+ endLine: z.ZodNumber;
450
+ }, z.core.$strip>>;
451
+ metric: z.ZodOptional<z.ZodString>;
452
+ value: z.ZodOptional<z.ZodNumber>;
453
+ threshold: z.ZodOptional<z.ZodNumber>;
454
+ excess: z.ZodNullable<z.ZodNumber>;
455
+ status: z.ZodOptional<z.ZodEnum<{
456
+ new: "new";
457
+ carryover: "carryover";
458
+ resolved: "resolved";
459
+ worsened: "worsened";
460
+ improved: "improved";
461
+ }>>;
462
+ message: z.ZodString;
463
+ provenance: z.ZodObject<{
464
+ kind: z.ZodEnum<{
465
+ measured: "measured";
466
+ derived: "derived";
467
+ model: "model";
468
+ }>;
469
+ source: z.ZodString;
470
+ at: z.ZodOptional<z.ZodString>;
471
+ }, z.core.$strip>;
472
+ }, z.core.$strip>>;
473
+ baselineSnapshotId: z.ZodOptional<z.ZodNumber>;
474
+ comparable: z.ZodOptional<z.ZodBoolean>;
475
+ snapshotId: z.ZodNumber;
476
+ }, z.core.$strip>;
477
+ };
478
+ readonly "node.neighbors": {
479
+ readonly description: string;
480
+ readonly args: z.ZodObject<{
481
+ snapshot: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
482
+ id: z.ZodString;
483
+ direction: z.ZodDefault<z.ZodEnum<{
484
+ out: "out";
485
+ in: "in";
486
+ both: "both";
487
+ }>>;
488
+ edge_kinds: z.ZodDefault<z.ZodArray<z.ZodString>>;
489
+ metrics: z.ZodDefault<z.ZodArray<z.ZodString>>;
490
+ offset: z.ZodDefault<z.ZodNumber>;
491
+ limit: z.ZodDefault<z.ZodNumber>;
492
+ }, z.core.$strip>;
493
+ readonly result: z.ZodObject<{
494
+ snapshotId: z.ZodNumber;
495
+ node: z.ZodObject<{
496
+ id: z.ZodString;
497
+ kind: z.ZodString;
498
+ name: z.ZodString;
499
+ path: z.ZodString;
500
+ span: z.ZodOptional<z.ZodObject<{
501
+ startLine: z.ZodNumber;
502
+ endLine: z.ZodNumber;
503
+ }, z.core.$strip>>;
504
+ }, z.core.$strip>;
505
+ inbound: z.ZodArray<z.ZodObject<{
506
+ node: z.ZodObject<{
507
+ id: z.ZodString;
508
+ kind: z.ZodString;
509
+ name: z.ZodString;
510
+ path: z.ZodString;
511
+ span: z.ZodOptional<z.ZodObject<{
512
+ startLine: z.ZodNumber;
513
+ endLine: z.ZodNumber;
514
+ }, z.core.$strip>>;
515
+ }, z.core.$strip>;
516
+ kind: z.ZodString;
517
+ weight: z.ZodNullable<z.ZodNumber>;
518
+ specifier: z.ZodOptional<z.ZodString>;
519
+ values: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>;
520
+ }, z.core.$strip>>;
521
+ outbound: z.ZodArray<z.ZodObject<{
522
+ node: z.ZodObject<{
523
+ id: z.ZodString;
524
+ kind: z.ZodString;
525
+ name: z.ZodString;
526
+ path: z.ZodString;
527
+ span: z.ZodOptional<z.ZodObject<{
528
+ startLine: z.ZodNumber;
529
+ endLine: z.ZodNumber;
530
+ }, z.core.$strip>>;
531
+ }, z.core.$strip>;
532
+ kind: z.ZodString;
533
+ weight: z.ZodNullable<z.ZodNumber>;
534
+ specifier: z.ZodOptional<z.ZodString>;
535
+ values: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodNumber>>;
536
+ }, z.core.$strip>>;
537
+ total: z.ZodObject<{
538
+ inbound: z.ZodNumber;
539
+ outbound: z.ZodNumber;
540
+ }, z.core.$strip>;
541
+ }, z.core.$strip>;
542
+ };
543
+ };
544
+ type CommandName = keyof typeof CONTRACT;
545
+ type CommandArgs<N extends CommandName> = z.output<(typeof CONTRACT)[N]["args"]>;
546
+ type CommandInput<N extends CommandName> = z.input<(typeof CONTRACT)[N]["args"]>;
547
+ type CommandResult<N extends CommandName> = z.output<(typeof CONTRACT)[N]["result"]>;
548
+ /** Name to input args and result: the shape a typed client (`rpc-protocol`'s `CommandMap`) needs. */
549
+ type CodeReadCommandMap = {
550
+ [N in CommandName]: {
551
+ args: CommandInput<N>;
552
+ result: CommandResult<N>;
553
+ };
554
+ };
555
+ declare const COMMAND_NAMES: CommandName[];
556
+ /** The agent-shaped commands the design puts on MCP; `hierarchy.get` is UI-shaped. A product filters with this until the registry can (P3). */
557
+ declare const AGENT_COMMANDS: readonly CommandName[];
558
+ interface SerializedContract {
559
+ api: string;
560
+ commands: Record<string, {
561
+ args: unknown;
562
+ result: unknown;
563
+ }>;
564
+ }
565
+ /** Args and results as JSON Schema in a stable key order; descriptions are docs, not contract, so they are left out. */
566
+ declare function serializeContract(): SerializedContract;
567
+
568
+ /** The row cap on `hierarchy.get`; past it the result says `truncated` and the shallowest rows are kept. */
569
+ declare const HIERARCHY_ROW_CAP = 5000;
570
+
571
+ /** Most rows one `findings.list` page returns; a table pages with `offset`. */
572
+ declare const FINDINGS_PAGE_MAX = 500;
573
+ /** Most lines one excerpt carries, whatever the flagged range and context ask for. */
574
+ declare const EXCERPT_LINE_CAP = 80;
575
+ declare const Finding: z.ZodObject<{
576
+ id: z.ZodString;
577
+ snapshotId: z.ZodNumber;
578
+ rule: z.ZodString;
579
+ tool: z.ZodString;
580
+ severity: z.ZodString;
581
+ node: z.ZodObject<{
582
+ id: z.ZodString;
583
+ kind: z.ZodString;
584
+ name: z.ZodString;
585
+ path: z.ZodString;
586
+ span: z.ZodOptional<z.ZodObject<{
587
+ startLine: z.ZodNumber;
588
+ endLine: z.ZodNumber;
589
+ }, z.core.$strip>>;
590
+ }, z.core.$strip>;
591
+ destination: z.ZodOptional<z.ZodObject<{
592
+ id: z.ZodString;
593
+ kind: z.ZodString;
594
+ name: z.ZodString;
595
+ path: z.ZodString;
596
+ span: z.ZodOptional<z.ZodObject<{
597
+ startLine: z.ZodNumber;
598
+ endLine: z.ZodNumber;
599
+ }, z.core.$strip>>;
600
+ }, z.core.$strip>>;
601
+ range: z.ZodOptional<z.ZodObject<{
602
+ startLine: z.ZodNumber;
603
+ endLine: z.ZodNumber;
604
+ }, z.core.$strip>>;
605
+ metric: z.ZodOptional<z.ZodString>;
606
+ value: z.ZodOptional<z.ZodNumber>;
607
+ threshold: z.ZodOptional<z.ZodNumber>;
608
+ excess: z.ZodNullable<z.ZodNumber>;
609
+ status: z.ZodOptional<z.ZodEnum<{
610
+ new: "new";
611
+ carryover: "carryover";
612
+ resolved: "resolved";
613
+ worsened: "worsened";
614
+ improved: "improved";
615
+ }>>;
616
+ message: z.ZodString;
617
+ provenance: z.ZodObject<{
618
+ kind: z.ZodEnum<{
619
+ measured: "measured";
620
+ derived: "derived";
621
+ model: "model";
622
+ }>;
623
+ source: z.ZodString;
624
+ at: z.ZodOptional<z.ZodString>;
625
+ }, z.core.$strip>;
626
+ }, z.core.$strip>;
627
+ type Finding = z.infer<typeof Finding>;
628
+ declare const FindingStatus: z.ZodEnum<{
629
+ new: "new";
630
+ carryover: "carryover";
631
+ resolved: "resolved";
632
+ worsened: "worsened";
633
+ improved: "improved";
634
+ }>;
635
+ type FindingStatus = z.infer<typeof FindingStatus>;
636
+ declare const SourceExcerpt: z.ZodObject<{
637
+ path: z.ZodString;
638
+ startLine: z.ZodNumber;
639
+ endLine: z.ZodNumber;
640
+ text: z.ZodString;
641
+ contentHash: z.ZodString;
642
+ origin: z.ZodEnum<{
643
+ commit: "commit";
644
+ worktree: "worktree";
645
+ export: "export";
646
+ }>;
647
+ highlights: z.ZodArray<z.ZodObject<{
648
+ startLine: z.ZodNumber;
649
+ endLine: z.ZodNumber;
650
+ }, z.core.$strip>>;
651
+ truncated: z.ZodBoolean;
652
+ }, z.core.$strip>;
653
+ type SourceExcerpt = z.infer<typeof SourceExcerpt>;
654
+
655
+ /** Open string: "repo" | "package" | "directory" | "file" | "symbol" today; consumers tolerate unknown kinds. */
656
+ declare const NodeKind: z.ZodString;
657
+ /** Open string: "error" | "warning" | "info" today. */
658
+ declare const Severity: z.ZodString;
659
+ /** Open string: "no-rollup" | "not-measured" | "not-in-snapshot" today; why a value is null. */
660
+ declare const MissingReason: z.ZodString;
661
+ declare const ProvenanceKind: z.ZodEnum<{
662
+ measured: "measured";
663
+ derived: "derived";
664
+ model: "model";
665
+ }>;
666
+ type ProvenanceKind = z.infer<typeof ProvenanceKind>;
667
+ declare const Provenance: z.ZodObject<{
668
+ kind: z.ZodEnum<{
669
+ measured: "measured";
670
+ derived: "derived";
671
+ model: "model";
672
+ }>;
673
+ source: z.ZodString;
674
+ at: z.ZodOptional<z.ZodString>;
675
+ }, z.core.$strip>;
676
+ type Provenance = z.infer<typeof Provenance>;
677
+ declare const SnapshotInfo: z.ZodObject<{
678
+ id: z.ZodNumber;
679
+ ref: z.ZodString;
680
+ commit: z.ZodNullable<z.ZodString>;
681
+ takenAt: z.ZodString;
682
+ indexVersion: z.ZodString;
683
+ }, z.core.$strip>;
684
+ type SnapshotInfo = z.infer<typeof SnapshotInfo>;
685
+ declare const MetricDescriptor: z.ZodObject<{
686
+ name: z.ZodString;
687
+ unit: z.ZodNullable<z.ZodString>;
688
+ appliesTo: z.ZodArray<z.ZodString>;
689
+ rollup: z.ZodEnum<{
690
+ sum: "sum";
691
+ max: "max";
692
+ mean: "mean";
693
+ none: "none";
694
+ }>;
695
+ direction: z.ZodEnum<{
696
+ "higher-worse": "higher-worse";
697
+ "lower-worse": "lower-worse";
698
+ neutral: "neutral";
699
+ }>;
700
+ absent: z.ZodEnum<{
701
+ zero: "zero";
702
+ exclude: "exclude";
703
+ }>;
704
+ window: z.ZodOptional<z.ZodString>;
705
+ description: z.ZodString;
706
+ provenance: z.ZodObject<{
707
+ kind: z.ZodEnum<{
708
+ measured: "measured";
709
+ derived: "derived";
710
+ model: "model";
711
+ }>;
712
+ source: z.ZodString;
713
+ at: z.ZodOptional<z.ZodString>;
714
+ }, z.core.$strip>;
715
+ }, z.core.$strip>;
716
+ type MetricDescriptor = z.infer<typeof MetricDescriptor>;
717
+ declare const RuleSummary: z.ZodObject<{
718
+ id: z.ZodString;
719
+ type: z.ZodString;
720
+ severity: z.ZodString;
721
+ }, z.core.$strip>;
722
+ type RuleSummary = z.infer<typeof RuleSummary>;
723
+ declare const Capabilities: z.ZodObject<{
724
+ findings: z.ZodEnum<{
725
+ none: "none";
726
+ "check-rules": "check-rules";
727
+ store: "store";
728
+ }>;
729
+ verdicts: z.ZodBoolean;
730
+ themes: z.ZodBoolean;
731
+ feedback: z.ZodBoolean;
732
+ embeddings: z.ZodNullable<z.ZodObject<{
733
+ model: z.ZodString;
734
+ embedded: z.ZodNumber;
735
+ symbols: z.ZodNumber;
736
+ }, z.core.$strip>>;
737
+ cochange: z.ZodBoolean;
738
+ sourceAtCommit: z.ZodBoolean;
739
+ excerpts: z.ZodEnum<{
740
+ any: "any";
741
+ none: "none";
742
+ flagged: "flagged";
743
+ }>;
744
+ }, z.core.$strip>;
745
+ type Capabilities = z.infer<typeof Capabilities>;
746
+ /** A snapshot id, a digit string, or a ref name meaning that ref's newest snapshot. Omitted means the newest overall. */
747
+ declare const SnapshotRef: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
748
+ type SnapshotRef = z.infer<typeof SnapshotRef>;
749
+ declare const Span: z.ZodObject<{
750
+ startLine: z.ZodNumber;
751
+ endLine: z.ZodNumber;
752
+ }, z.core.$strip>;
753
+ type Span = z.infer<typeof Span>;
754
+ /** How a node is addressed everywhere in the API; consumers treat `id` as opaque and read the other fields. */
755
+ declare const NodeRef: z.ZodObject<{
756
+ id: z.ZodString;
757
+ kind: z.ZodString;
758
+ name: z.ZodString;
759
+ path: z.ZodString;
760
+ span: z.ZodOptional<z.ZodObject<{
761
+ startLine: z.ZodNumber;
762
+ endLine: z.ZodNumber;
763
+ }, z.core.$strip>>;
764
+ }, z.core.$strip>;
765
+ type NodeRef = z.infer<typeof NodeRef>;
766
+
767
+ /** A graph node as the read API holds it; mirrors code-graph's `GraphNode` without importing it. */
768
+ interface ModelNode {
769
+ id: string;
770
+ kind: string;
771
+ name: string;
772
+ parentId: string | null;
773
+ language?: string;
774
+ role?: string;
775
+ attrs: Record<string, unknown>;
776
+ }
777
+ interface ModelEdge {
778
+ srcId: string;
779
+ dstId: string;
780
+ kind: string;
781
+ attrs: Record<string, unknown>;
782
+ }
783
+ interface ModelAlias {
784
+ oldId: string;
785
+ newId: string;
786
+ reason: string;
787
+ }
788
+ interface ModelMetric {
789
+ nodeId: string;
790
+ name: string;
791
+ value: number | null;
792
+ unit?: string;
793
+ }
794
+ /** A rule as findings cite it: `text` is a plain-language statement of what the rule demands. */
795
+ interface ModelRule {
796
+ id: string;
797
+ type: string;
798
+ severity: string;
799
+ text: string;
800
+ }
801
+ /** One check-rule violation, keyed by the ratchet's `violationKey`; `ranges` are the flagged lines, absent for a whole-node finding. */
802
+ interface ModelFinding {
803
+ id: string;
804
+ rule: string;
805
+ severity: string;
806
+ nodeId: string;
807
+ destinationId?: string;
808
+ metric?: string;
809
+ value?: number;
810
+ threshold?: number;
811
+ message: string;
812
+ ranges?: readonly Span[];
813
+ }
814
+ /** A catalogue entry as code-graph's `describeMetric` returns it; provenance is added here. */
815
+ interface CatalogueEntry {
816
+ name: string;
817
+ unit: string;
818
+ appliesTo: readonly string[];
819
+ rollup: MetricDescriptor["rollup"];
820
+ direction: MetricDescriptor["direction"];
821
+ absent: MetricDescriptor["absent"];
822
+ source: string;
823
+ description: string;
824
+ window?: string;
825
+ }
826
+ /** Everything one snapshot holds, indexed for reads. Snapshots are immutable, so a model never goes stale. */
827
+ interface ReadModel {
828
+ snapshot: SnapshotInfo;
829
+ nodes: readonly ModelNode[];
830
+ nodeById: ReadonlyMap<string, ModelNode>;
831
+ edges: readonly ModelEdge[];
832
+ aliases: readonly ModelAlias[];
833
+ /** Metric name to node id to value. */
834
+ metrics: ReadonlyMap<string, ReadonlyMap<string, number | null>>;
835
+ /** One descriptor per metric name present in the snapshot, sorted by name. */
836
+ metricCatalogue: readonly MetricDescriptor[];
837
+ /** Derived on load from the product's rules; a changed rule set means a different model. */
838
+ findings: readonly ModelFinding[];
839
+ rules: readonly ModelRule[];
840
+ }
841
+ interface ReadModelParts {
842
+ snapshot: SnapshotInfo;
843
+ nodes: readonly ModelNode[];
844
+ edges: readonly ModelEdge[];
845
+ aliases: readonly ModelAlias[];
846
+ metrics: readonly ModelMetric[];
847
+ /** The catalogue lookup, injected so this module never imports code-graph's Node-only root. */
848
+ describe: (name: string) => CatalogueEntry | null;
849
+ findings?: readonly ModelFinding[];
850
+ rules?: readonly ModelRule[];
851
+ }
852
+ declare function buildReadModel(parts: ReadModelParts): ReadModel;
853
+
854
+ /** What a source can serve, independent of any one snapshot. */
855
+ interface SourceFacts {
856
+ dataset: "live" | "static";
857
+ commands: readonly CommandName[];
858
+ capabilities: Capabilities;
859
+ rules: readonly RuleSummary[];
860
+ }
861
+ /** Where excerpt text came from: the snapshot's commit, a working tree proven to match it, or a static export. */
862
+ type SourceOrigin = "commit" | "worktree" | "export";
863
+ /** Some or all of one file's lines as they were at the snapshot; `startLine` is the first line held. */
864
+ interface SourceWindow {
865
+ path: string;
866
+ contentHash: string;
867
+ origin: SourceOrigin;
868
+ startLine: number;
869
+ lines: readonly string[];
870
+ /** Lines in the whole file, so a window can be clipped at the file's end. */
871
+ lineCount: number;
872
+ }
873
+ /** Open string: "no-source" | "changed-since-snapshot" | "not-in-export" | "unreadable" today. */
874
+ type SourceRead = SourceWindow | {
875
+ unavailable: string;
876
+ };
877
+ /**
878
+ * The seam every query function reads through. The daemon implements it over SQLite with an
879
+ * LRU of models; a static export implements it over a decoded dataset. Same queries, same answers.
880
+ */
881
+ interface ReadSource {
882
+ facts(): SourceFacts;
883
+ /** Every snapshot, newest first. */
884
+ snapshots(): readonly SnapshotInfo[];
885
+ /** Throws a `ReadError` with `EXIT.NOINPUT` when the snapshot does not exist. */
886
+ model(snapshotId: number): ReadModel;
887
+ /** A file's text at the snapshot; absent when the source holds no source text at all. */
888
+ readSource?(snapshotId: number, path: string): SourceRead;
889
+ }
890
+ /** A failure carrying the sysexits code every surface reports, so the registry's `describeError` maps it as is. */
891
+ declare class ReadError extends Error {
892
+ readonly code: number;
893
+ constructor(message: string, code: number);
894
+ }
895
+ declare function snapshotNotFound(snapshotId: number): ReadError;
896
+ declare function nodeNotFound(id: string, snapshotId: number): ReadError;
897
+ declare function findingNotFound(id: string, snapshotId: number): ReadError;
898
+ /** Bad arguments the schema cannot express, such as "exactly one of"; same code as a schema failure. */
899
+ declare function invalidArgs(message: string): ReadError;
900
+
901
+ /** An id, a digit string, or a ref name (its newest snapshot); omitted means the newest overall. */
902
+ declare function resolveSnapshot(source: ReadSource, ref: SnapshotRef | undefined): SnapshotInfo;
903
+
904
+ /** Why a value is null: the rollup rule forbids one, the node has no measurement, the metric does not describe the node, or the snapshot lacks the metric. */
905
+ type Missing = "no-rollup" | "not-measured" | "not-applicable" | "not-in-snapshot";
906
+ interface MetricValue {
907
+ value: number | null;
908
+ missing?: Missing;
909
+ }
910
+
911
+ type QueryFn<N extends CommandName> = (source: ReadSource, args: CommandArgs<N>) => CommandResult<N>;
912
+ declare function describeApi(source: ReadSource): CommandResult<"api.describe">;
913
+ declare function listSnapshots(source: ReadSource, args: CommandArgs<"snapshot.list">): CommandResult<"snapshot.list">;
914
+ /** One pure function per command; the registry commands and the static resolver both dispatch here. */
915
+ declare const QUERIES: {
916
+ [N in CommandName]: QueryFn<N>;
917
+ };
918
+
919
+ type HierarchyResult = CommandResult<"hierarchy.get">;
920
+ /** `hierarchy.get`: a flat, shallowest-first slice of the synthesized tree with per-row metric values. */
921
+ declare function getHierarchy(source: ReadSource, args: CommandArgs<"hierarchy.get">): HierarchyResult;
922
+
923
+ type NodeGetResult = CommandResult<"node.get">;
924
+ /** `node.get`: one node of the synthesized hierarchy with its numbers in context. */
925
+ declare function getNode(source: ReadSource, args: CommandArgs<"node.get">): NodeGetResult;
926
+
927
+ /** `node.resolve`: a path, path:line, symbol name, or qualified id to ranked candidate nodes. */
928
+ declare function resolveNode(source: ReadSource, args: CommandArgs<"node.resolve">): CommandResult<"node.resolve">;
929
+
930
+ type ListArgs = CommandArgs<"findings.list">;
931
+ type ListResult = CommandResult<"findings.list">;
932
+ /** `findings.list`: a snapshot's findings, filtered, ordered by a total order, and cut to one page. */
933
+ declare function listFindings(source: ReadSource, args: ListArgs): ListResult;
934
+
935
+ type GetResult = CommandResult<"finding.get">;
936
+ /** Findings shown beside the one asked for: the same node's, then the same rule's on graph neighbours. */
937
+ declare const RELATED_CAP = 10;
938
+ /** `finding.get`: one finding with its rule, numbers in context, the flagged source, and related findings. */
939
+ declare function getFinding(source: ReadSource, args: CommandArgs<"finding.get">): GetResult;
940
+
941
+ type NeighborsResult = CommandResult<"node.neighbors">;
942
+ /** `node.neighbors`: a stored node's inbound and outbound edges, each side paged on its own. */
943
+ declare function getNeighbors(source: ReadSource, args: CommandArgs<"node.neighbors">): NeighborsResult;
944
+
945
+ /** Larger is worse for every rule: value over threshold for a maximum, threshold over value for a minimum. */
946
+ declare function excessOf(ruleType: string | undefined, value?: number, threshold?: number): number | null;
947
+
948
+ /** rpc-client's static `resolve` option: raw args in, an envelope out, never a throw. */
949
+ type QueryResolver = (name: string, args: unknown) => JsonEnvelope<unknown>;
950
+ /** Validate, run, and envelope one command against a source, exactly as the daemon's registry does. */
951
+ declare function createQueryResolver(source: ReadSource): QueryResolver;
952
+
953
+ export { AGENT_COMMANDS, CODE_READ_API_VERSION, COMMAND_NAMES, CONTRACT, Capabilities, type CatalogueEntry, type CodeReadCommandMap, type CommandArgs, type CommandContract, type CommandInput, type CommandName, type CommandResult, EXCERPT_LINE_CAP, FINDINGS_PAGE_MAX, Finding, FindingStatus, HIERARCHY_ROW_CAP, MetricDescriptor, type MetricValue, type Missing, MissingReason, type ModelAlias, type ModelEdge, type ModelFinding, type ModelMetric, type ModelNode, type ModelRule, NodeKind, NodeRef, Provenance, ProvenanceKind, QUERIES, type QueryFn, type QueryResolver, RELATED_CAP, ReadError, type ReadModel, type ReadModelParts, type ReadSource, RuleSummary, type SerializedContract, Severity, SnapshotInfo, SnapshotRef, SourceExcerpt, type SourceFacts, type SourceOrigin, type SourceRead, type SourceWindow, Span, buildReadModel, createQueryResolver, describeApi, excessOf, findingNotFound, getFinding, getHierarchy, getNeighbors, getNode, invalidArgs, listFindings, listSnapshots, nodeNotFound, resolveNode, resolveSnapshot, serializeContract, snapshotNotFound };