@morehao/trendradar-contract 0.0.0-stage → 0.3.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,1644 @@
1
+ // Code generated by scripts/generate.mjs; DO NOT EDIT.
2
+ import Ajv from 'ajv/dist/2020.js'
3
+ import addFormats from 'ajv-formats'
4
+
5
+ export const contractVersion = "0.3.0"
6
+
7
+ export const errorCatalog = {
8
+ "INTERNAL": {
9
+ "retriable": true,
10
+ "description": "Unexpected internal error (transient panic/IO); retry may succeed."
11
+ },
12
+ "CONFIG_INVALID": {
13
+ "retriable": false,
14
+ "description": "Configuration is invalid or unreadable."
15
+ },
16
+ "PAYLOAD_TOO_LARGE": {
17
+ "retriable": false,
18
+ "description": "Input payload exceeds the allowed size."
19
+ },
20
+ "FETCH_FAILED": {
21
+ "retriable": false,
22
+ "description": "Fetching trending data failed terminally (retries exhausted)."
23
+ },
24
+ "FETCH_RATE_LIMITED": {
25
+ "retriable": true,
26
+ "description": "Fetching was rate limited; retry later."
27
+ },
28
+ "PARSE_FAILED": {
29
+ "retriable": false,
30
+ "description": "Parsing fetched HTML/JSON failed."
31
+ },
32
+ "MODEL_UNAUTHORIZED": {
33
+ "retriable": false,
34
+ "description": "Model provider rejected the credentials."
35
+ },
36
+ "MODEL_RATE_LIMITED": {
37
+ "retriable": true,
38
+ "description": "Model provider rate limited the request."
39
+ },
40
+ "MODEL_TIMEOUT": {
41
+ "retriable": true,
42
+ "description": "Model request timed out."
43
+ },
44
+ "MODEL_FAILED": {
45
+ "retriable": true,
46
+ "description": "Model request failed."
47
+ },
48
+ "MODEL_BAD_OUTPUT": {
49
+ "retriable": false,
50
+ "description": "Model returned output that violates the expected shape."
51
+ },
52
+ "GIT_NOT_INSTALLED": {
53
+ "retriable": false,
54
+ "description": "git executable was not found."
55
+ },
56
+ "REPO_NOT_GIT": {
57
+ "retriable": false,
58
+ "description": "Target directory is not a git repository."
59
+ },
60
+ "REPO_DIRTY": {
61
+ "retriable": false,
62
+ "description": "Git working tree has uncommitted changes."
63
+ },
64
+ "GIT_OPERATION_FAILED": {
65
+ "retriable": true,
66
+ "description": "A git operation (commit/push) failed."
67
+ },
68
+ "PR_FAILED": {
69
+ "retriable": true,
70
+ "description": "Opening or updating the pull request failed."
71
+ },
72
+ "NOT_MERGEABLE": {
73
+ "retriable": false,
74
+ "description": "Pull request is not mergeable."
75
+ }
76
+ }
77
+
78
+ export const fixtures = {
79
+ "normal": {
80
+ "schema": 2,
81
+ "date": "2026-10-30",
82
+ "period": "daily",
83
+ "languages": [
84
+ "all",
85
+ "go",
86
+ "python",
87
+ "rust"
88
+ ],
89
+ "count": 6,
90
+ "degraded": false,
91
+ "contentHash": "sha256:a4769ff29cd41f2f85703c20faf9104a7f8b34500295d991f0b87786719544b2",
92
+ "contentHashAlgo": "jcs-sha256-v1",
93
+ "coreVersion": "0.1.0",
94
+ "generatedAt": "2026-10-30T00:05:00Z",
95
+ "repos": [
96
+ {
97
+ "fullName": "golang/go",
98
+ "url": "https://github.com/golang/go",
99
+ "description": "The Go programming language",
100
+ "language": "go",
101
+ "stars": 126000,
102
+ "starsInPeriod": 320,
103
+ "forks": 17800,
104
+ "rank": 1,
105
+ "source": "trending-html",
106
+ "summaryZh": "Go 官方仓库,今日新增 star 位居榜单前列。",
107
+ "summarySource": "model"
108
+ },
109
+ {
110
+ "fullName": "gin-gonic/gin",
111
+ "url": "https://github.com/gin-gonic/gin",
112
+ "description": "HTTP web framework written in Go",
113
+ "language": "go",
114
+ "stars": 80200,
115
+ "starsInPeriod": 210,
116
+ "forks": 8100,
117
+ "rank": 2,
118
+ "source": "trending-html",
119
+ "summaryZh": "流行的 Go Web 框架,热度持续。",
120
+ "summarySource": "model"
121
+ },
122
+ {
123
+ "fullName": "python/cpython",
124
+ "url": "https://github.com/python/cpython",
125
+ "description": "The Python programming language",
126
+ "language": "python",
127
+ "stars": 64500,
128
+ "starsInPeriod": 180,
129
+ "forks": 30500,
130
+ "rank": 3,
131
+ "source": "trending-html",
132
+ "summaryZh": "CPython 官方实现,今日关注度上升。",
133
+ "summarySource": "model"
134
+ },
135
+ {
136
+ "fullName": "psf/requests",
137
+ "url": "https://github.com/psf/requests",
138
+ "description": "A simple, yet elegant HTTP library",
139
+ "language": "python",
140
+ "stars": 52500,
141
+ "starsInPeriod": 95,
142
+ "forks": 9400,
143
+ "rank": 4,
144
+ "source": "trending-html",
145
+ "summaryZh": "经典 Python HTTP 库,稳居热榜。",
146
+ "summarySource": "model"
147
+ },
148
+ {
149
+ "fullName": "rust-lang/rust",
150
+ "url": "https://github.com/rust-lang/rust",
151
+ "description": "Empowering everyone to build reliable and efficient software",
152
+ "language": "rust",
153
+ "stars": 102000,
154
+ "starsInPeriod": 260,
155
+ "forks": 13200,
156
+ "rank": 5,
157
+ "source": "trending-html",
158
+ "summaryZh": "Rust 语言主仓库,社区活跃。",
159
+ "summarySource": "model"
160
+ },
161
+ {
162
+ "fullName": "tokio-rs/tokio",
163
+ "url": "https://github.com/tokio-rs/tokio",
164
+ "description": "A runtime for writing reliable asynchronous applications with Rust",
165
+ "language": "rust",
166
+ "stars": 28600,
167
+ "starsInPeriod": 120,
168
+ "forks": 2650,
169
+ "rank": 6,
170
+ "source": "trending-html",
171
+ "summaryZh": "Rust 异步运行时,性能方向关注度高。",
172
+ "summarySource": "model"
173
+ }
174
+ ]
175
+ },
176
+ "degraded": {
177
+ "schema": 2,
178
+ "date": "2026-10-30",
179
+ "period": "daily",
180
+ "languages": [
181
+ "all",
182
+ "go"
183
+ ],
184
+ "count": 2,
185
+ "degraded": true,
186
+ "contentHash": "sha256:a21dfa56cbd2fe611c9e7b9844d672b3608922156bf8e998f49f4293ab5ce3e3",
187
+ "contentHashAlgo": "jcs-sha256-v1",
188
+ "coreVersion": "0.1.0",
189
+ "generatedAt": "2026-10-30T00:05:00Z",
190
+ "repos": [
191
+ {
192
+ "fullName": "golang/go",
193
+ "url": "https://github.com/golang/go",
194
+ "description": "The Go programming language",
195
+ "language": "go",
196
+ "stars": 126000,
197
+ "starsInPeriod": 0,
198
+ "forks": 17800,
199
+ "rank": 1,
200
+ "source": "search-api",
201
+ "summaryZh": "[原文] The Go programming language",
202
+ "summarySource": "original"
203
+ },
204
+ {
205
+ "fullName": "gin-gonic/gin",
206
+ "url": "https://github.com/gin-gonic/gin",
207
+ "description": "HTTP web framework written in Go",
208
+ "language": "go",
209
+ "stars": 80200,
210
+ "starsInPeriod": 0,
211
+ "forks": 8100,
212
+ "rank": 2,
213
+ "source": "search-api",
214
+ "summaryZh": "[原文] HTTP web framework written in Go",
215
+ "summarySource": "original"
216
+ }
217
+ ]
218
+ },
219
+ "emptyLang": {
220
+ "schema": 2,
221
+ "date": "2026-10-30",
222
+ "period": "daily",
223
+ "languages": [
224
+ "all",
225
+ "unknown"
226
+ ],
227
+ "count": 2,
228
+ "degraded": false,
229
+ "contentHash": "sha256:84a5ef479995ae104544dfc0869227442f3d8968c0d27b5f76410040d4c8b2e4",
230
+ "contentHashAlgo": "jcs-sha256-v1",
231
+ "coreVersion": "0.1.0",
232
+ "generatedAt": "2026-10-30T00:05:00Z",
233
+ "repos": [
234
+ {
235
+ "fullName": "someorg/no-language",
236
+ "url": "https://github.com/someorg/no-language",
237
+ "description": "A repo whose primary language could not be detected",
238
+ "language": "unknown",
239
+ "stars": 1200,
240
+ "starsInPeriod": 40,
241
+ "forks": 30,
242
+ "rank": 1,
243
+ "source": "trending-html",
244
+ "summaryZh": "语言未知的仓库,热度进入榜单。",
245
+ "summarySource": "model"
246
+ },
247
+ {
248
+ "fullName": "someorg/aggregate-only",
249
+ "url": "https://github.com/someorg/aggregate-only",
250
+ "description": "Repo surfaced only in the all-languages list",
251
+ "language": "unknown",
252
+ "stars": 980,
253
+ "starsInPeriod": 33,
254
+ "forks": 12,
255
+ "rank": 2,
256
+ "source": "trending-html",
257
+ "summaryZh": "仅在全局榜单出现的仓库。",
258
+ "summarySource": "model"
259
+ }
260
+ ]
261
+ },
262
+ "missingOptional": {
263
+ "schema": 2,
264
+ "date": "2026-10-30",
265
+ "period": "daily",
266
+ "languages": [
267
+ "all",
268
+ "go",
269
+ "python",
270
+ "rust"
271
+ ],
272
+ "count": 2,
273
+ "degraded": false,
274
+ "contentHash": "sha256:38c38188602424014a7fdd8a3bfd0408690ce8a5db21be9c8559ac3ca85b2b4c",
275
+ "contentHashAlgo": "jcs-sha256-v1",
276
+ "coreVersion": "0.1.0",
277
+ "generatedAt": "2026-10-30T00:05:00Z",
278
+ "repos": [
279
+ {
280
+ "fullName": "golang/go",
281
+ "url": "https://github.com/golang/go",
282
+ "language": "go",
283
+ "stars": 126000,
284
+ "starsInPeriod": 320,
285
+ "rank": 1,
286
+ "source": "trending-html",
287
+ "summaryZh": "Go 官方仓库,今日新增 star 位居榜单前列。",
288
+ "summarySource": "model"
289
+ },
290
+ {
291
+ "fullName": "gin-gonic/gin",
292
+ "url": "https://github.com/gin-gonic/gin",
293
+ "language": "go",
294
+ "stars": 80200,
295
+ "starsInPeriod": 210,
296
+ "rank": 2,
297
+ "source": "trending-html",
298
+ "summaryZh": "流行的 Go Web 框架,热度持续。",
299
+ "summarySource": "model"
300
+ }
301
+ ]
302
+ },
303
+ "releaseNormal": {
304
+ "schema": 1,
305
+ "date": "2026-10-31",
306
+ "period": "daily",
307
+ "contentHash": "sha256:6ffddcbca4448be9db6dcdfcc407183516c35ed78001b32c3d567ad8a4b4ff42",
308
+ "contentHashAlgo": "jcs-sha256-v1",
309
+ "coreVersion": "0.5.0",
310
+ "generatedAt": "2026-10-31T13:04:00Z",
311
+ "count": 2,
312
+ "degraded": false,
313
+ "repos": [
314
+ {
315
+ "fullName": "infiniflow/ragflow",
316
+ "url": "https://github.com/infiniflow/ragflow",
317
+ "latestTag": "v1.0.0-rc3",
318
+ "newCount": 1,
319
+ "releases": [
320
+ {
321
+ "id": 428974489,
322
+ "tag": "v1.0.0-rc3",
323
+ "name": "v1.0.0-rc3",
324
+ "kind": "release",
325
+ "publishedAt": "2026-10-30T11:53:15Z",
326
+ "url": "https://github.com/infiniflow/ragflow/releases/tag/v1.0.0-rc3",
327
+ "prerelease": false,
328
+ "draft": false,
329
+ "bodyExcerpt": "1.0.0-rc3 fixes several issues found in rc2.",
330
+ "summaryZh": "新增证据充分性决策模型与 Categorize 组件,兼容 rc2 schema,可直接升级。",
331
+ "summarySource": "model"
332
+ }
333
+ ]
334
+ },
335
+ {
336
+ "fullName": "deepseek-ai/deepseek-harness",
337
+ "url": "https://github.com/deepseek-ai/deepseek-harness",
338
+ "latestTag": "dsh-v0.2.2-alpha.2",
339
+ "newCount": 1,
340
+ "releases": [
341
+ {
342
+ "id": 0,
343
+ "tag": "dsh-v0.2.2-alpha.2",
344
+ "name": "dsh-v0.2.2-alpha.2",
345
+ "kind": "tag",
346
+ "url": "https://github.com/deepseek-ai/deepseek-harness/tree/dsh-v0.2.2-alpha.2",
347
+ "prerelease": false,
348
+ "draft": false,
349
+ "summaryZh": "发布说明缺失,已回退到 commit 信息。",
350
+ "summarySource": "model"
351
+ }
352
+ ]
353
+ }
354
+ ]
355
+ },
356
+ "releaseDegraded": {
357
+ "schema": 1,
358
+ "date": "2026-10-31",
359
+ "period": "daily",
360
+ "contentHash": "sha256:f952f1607ff1708120c35e7a9551f0691ae747edf2ee959445edcd53bc0edf25",
361
+ "contentHashAlgo": "jcs-sha256-v1",
362
+ "count": 1,
363
+ "degraded": true,
364
+ "repos": [
365
+ {
366
+ "fullName": "acme/widget",
367
+ "url": "https://github.com/acme/widget",
368
+ "latestTag": "v2.0.0",
369
+ "newCount": 1,
370
+ "releases": [
371
+ {
372
+ "id": 0,
373
+ "tag": "v2.0.0",
374
+ "name": "v2.0.0",
375
+ "kind": "release",
376
+ "url": "https://github.com/acme/widget/releases/tag/v2.0.0",
377
+ "prerelease": false,
378
+ "draft": false,
379
+ "summaryZh": "版本 v2.0.0(未获取到变更说明)",
380
+ "summarySource": "original"
381
+ }
382
+ ]
383
+ }
384
+ ]
385
+ },
386
+ "releaseEmpty": {
387
+ "schema": 1,
388
+ "date": "2026-10-31",
389
+ "period": "daily",
390
+ "contentHash": "sha256:501d8c4be30af9d1dacdf15b2e48ccd3134cbe439695f7685deea11e00c24de8",
391
+ "contentHashAlgo": "jcs-sha256-v1",
392
+ "count": 0,
393
+ "degraded": false,
394
+ "repos": []
395
+ }
396
+ }
397
+
398
+ const model = {
399
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
400
+ "$id": "https://github.com/morehao/trendradar/contract/schema/model.v2.json",
401
+ "title": "trendradar model v2",
402
+ "description": "Domain model: a scraped repository snapshot (RepoSnapshot) and its digested form (RepoDigest). RepoDigest composes RepoSnapshot via allOf instead of flattening.",
403
+ "$ref": "#/$defs/RepoDigest",
404
+ "$defs": {
405
+ "RepoSnapshot": {
406
+ "type": "object",
407
+ "additionalProperties": true,
408
+ "required": [
409
+ "fullName",
410
+ "url",
411
+ "language",
412
+ "stars",
413
+ "starsInPeriod",
414
+ "rank",
415
+ "source"
416
+ ],
417
+ "properties": {
418
+ "fullName": {
419
+ "type": "string",
420
+ "pattern": "^[^/]+/[^/]+$"
421
+ },
422
+ "url": {
423
+ "type": "string",
424
+ "format": "uri"
425
+ },
426
+ "description": {
427
+ "type": "string"
428
+ },
429
+ "language": {
430
+ "type": "string"
431
+ },
432
+ "stars": {
433
+ "type": "integer",
434
+ "minimum": 0
435
+ },
436
+ "starsInPeriod": {
437
+ "type": "integer",
438
+ "minimum": 0
439
+ },
440
+ "forks": {
441
+ "type": "integer",
442
+ "minimum": 0
443
+ },
444
+ "rank": {
445
+ "type": "integer",
446
+ "minimum": 1
447
+ },
448
+ "source": {
449
+ "type": "string",
450
+ "enum": [
451
+ "trending-html",
452
+ "search-api"
453
+ ]
454
+ }
455
+ }
456
+ },
457
+ "RepoDigest": {
458
+ "description": "RepoSnapshot plus the digest-only summary fields; the two sub-schemas are merged with allOf.",
459
+ "allOf": [
460
+ {
461
+ "$ref": "#/$defs/RepoSnapshot"
462
+ },
463
+ {
464
+ "type": "object",
465
+ "additionalProperties": true,
466
+ "required": [
467
+ "summaryZh",
468
+ "summarySource"
469
+ ],
470
+ "properties": {
471
+ "summaryZh": {
472
+ "type": "string"
473
+ },
474
+ "summarySource": {
475
+ "type": "string",
476
+ "enum": [
477
+ "model",
478
+ "original"
479
+ ]
480
+ }
481
+ }
482
+ }
483
+ ]
484
+ }
485
+ }
486
+ }
487
+ const ipc = {
488
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
489
+ "$id": "https://github.com/morehao/trendradar/contract/schema/ipc.v2.json",
490
+ "title": "trendradar ipc v2",
491
+ "description": "Envelope exchanged between the trendradar core binary and the DSH plugin. Only RunRequest forbids extra fields. ipcSchema is const 2.",
492
+ "oneOf": [
493
+ {
494
+ "$ref": "#/$defs/RunRequest"
495
+ },
496
+ {
497
+ "$ref": "#/$defs/RunResult"
498
+ }
499
+ ],
500
+ "$defs": {
501
+ "ErrorCode": {
502
+ "type": "string",
503
+ "enum": [
504
+ "INTERNAL",
505
+ "CONFIG_INVALID",
506
+ "PAYLOAD_TOO_LARGE",
507
+ "FETCH_FAILED",
508
+ "FETCH_RATE_LIMITED",
509
+ "PARSE_FAILED",
510
+ "MODEL_UNAUTHORIZED",
511
+ "MODEL_RATE_LIMITED",
512
+ "MODEL_TIMEOUT",
513
+ "MODEL_FAILED",
514
+ "MODEL_BAD_OUTPUT",
515
+ "GIT_NOT_INSTALLED",
516
+ "REPO_NOT_GIT",
517
+ "REPO_DIRTY",
518
+ "GIT_OPERATION_FAILED",
519
+ "PR_FAILED",
520
+ "NOT_MERGEABLE"
521
+ ]
522
+ },
523
+ "ErrorInfo": {
524
+ "type": "object",
525
+ "additionalProperties": true,
526
+ "required": [
527
+ "code",
528
+ "message",
529
+ "retriable"
530
+ ],
531
+ "properties": {
532
+ "code": {
533
+ "$ref": "#/$defs/ErrorCode"
534
+ },
535
+ "message": {
536
+ "type": "string"
537
+ },
538
+ "retriable": {
539
+ "type": "boolean"
540
+ },
541
+ "details": {
542
+ "type": "object",
543
+ "additionalProperties": true
544
+ }
545
+ }
546
+ },
547
+ "FileArtifact": {
548
+ "type": "object",
549
+ "additionalProperties": true,
550
+ "required": [
551
+ "path",
552
+ "bytes",
553
+ "sha256"
554
+ ],
555
+ "properties": {
556
+ "path": {
557
+ "type": "string"
558
+ },
559
+ "bytes": {
560
+ "type": "integer",
561
+ "minimum": 0
562
+ },
563
+ "sha256": {
564
+ "type": "string"
565
+ }
566
+ }
567
+ },
568
+ "RunRequest": {
569
+ "type": "object",
570
+ "additionalProperties": false,
571
+ "required": [
572
+ "ipcSchema",
573
+ "command"
574
+ ],
575
+ "properties": {
576
+ "ipcSchema": {
577
+ "const": 2
578
+ },
579
+ "command": {
580
+ "type": "string",
581
+ "enum": [
582
+ "run",
583
+ "serve",
584
+ "config",
585
+ "version",
586
+ "subscribe"
587
+ ]
588
+ },
589
+ "configPath": {
590
+ "type": "string"
591
+ },
592
+ "date": {
593
+ "type": "string",
594
+ "format": "date"
595
+ },
596
+ "dryRun": {
597
+ "type": "boolean"
598
+ },
599
+ "outputDir": {
600
+ "type": "string"
601
+ },
602
+ "action": {
603
+ "type": "string",
604
+ "enum": [
605
+ "list",
606
+ "add",
607
+ "remove"
608
+ ]
609
+ },
610
+ "repo": {
611
+ "type": "string",
612
+ "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
613
+ }
614
+ },
615
+ "description": "Strict request envelope. command=subscribe manages the repo subscription list: action=list needs no repo; action=add/remove require exactly one repo.",
616
+ "allOf": [
617
+ {
618
+ "if": {
619
+ "properties": {
620
+ "command": {
621
+ "const": "subscribe"
622
+ }
623
+ },
624
+ "required": [
625
+ "command"
626
+ ]
627
+ },
628
+ "then": {
629
+ "required": [
630
+ "action"
631
+ ],
632
+ "properties": {
633
+ "action": {
634
+ "enum": [
635
+ "list",
636
+ "add",
637
+ "remove"
638
+ ]
639
+ }
640
+ },
641
+ "allOf": [
642
+ {
643
+ "if": {
644
+ "properties": {
645
+ "action": {
646
+ "const": "list"
647
+ }
648
+ },
649
+ "required": [
650
+ "action"
651
+ ]
652
+ },
653
+ "then": {
654
+ "not": {
655
+ "required": [
656
+ "repo"
657
+ ]
658
+ }
659
+ }
660
+ },
661
+ {
662
+ "if": {
663
+ "properties": {
664
+ "action": {
665
+ "enum": [
666
+ "add",
667
+ "remove"
668
+ ]
669
+ }
670
+ },
671
+ "required": [
672
+ "action"
673
+ ]
674
+ },
675
+ "then": {
676
+ "required": [
677
+ "repo"
678
+ ]
679
+ }
680
+ }
681
+ ]
682
+ }
683
+ },
684
+ {
685
+ "if": {
686
+ "properties": {
687
+ "command": {
688
+ "enum": [
689
+ "run",
690
+ "serve",
691
+ "config",
692
+ "version"
693
+ ]
694
+ }
695
+ },
696
+ "required": [
697
+ "command"
698
+ ]
699
+ },
700
+ "then": {
701
+ "not": {
702
+ "anyOf": [
703
+ {
704
+ "required": [
705
+ "action"
706
+ ]
707
+ },
708
+ {
709
+ "required": [
710
+ "repo"
711
+ ]
712
+ }
713
+ ]
714
+ }
715
+ }
716
+ }
717
+ ]
718
+ },
719
+ "RunResult": {
720
+ "type": "object",
721
+ "additionalProperties": true,
722
+ "required": [
723
+ "ipcSchema",
724
+ "ok",
725
+ "command",
726
+ "startedAt",
727
+ "finishedAt",
728
+ "skipped",
729
+ "files"
730
+ ],
731
+ "properties": {
732
+ "ipcSchema": {
733
+ "const": 2
734
+ },
735
+ "ok": {
736
+ "type": "boolean"
737
+ },
738
+ "command": {
739
+ "type": "string",
740
+ "enum": [
741
+ "run",
742
+ "serve",
743
+ "config",
744
+ "version"
745
+ ]
746
+ },
747
+ "startedAt": {
748
+ "type": "string",
749
+ "format": "date-time"
750
+ },
751
+ "finishedAt": {
752
+ "type": "string",
753
+ "format": "date-time"
754
+ },
755
+ "skipped": {
756
+ "type": "boolean"
757
+ },
758
+ "files": {
759
+ "type": "array",
760
+ "items": {
761
+ "$ref": "#/$defs/FileArtifact"
762
+ }
763
+ },
764
+ "branch": {
765
+ "type": "string"
766
+ },
767
+ "commit": {
768
+ "type": "string"
769
+ },
770
+ "prUrl": {
771
+ "type": "string",
772
+ "format": "uri"
773
+ },
774
+ "contentHash": {
775
+ "type": "string",
776
+ "pattern": "^sha256:[0-9a-f]{64}$"
777
+ },
778
+ "error": {
779
+ "$ref": "#/$defs/ErrorInfo"
780
+ },
781
+ "warnings": {
782
+ "type": "array",
783
+ "items": {
784
+ "type": "string"
785
+ }
786
+ },
787
+ "usage": {
788
+ "$ref": "#/$defs/Usage"
789
+ },
790
+ "releases": {
791
+ "$ref": "releases.v2.json#/$defs/ReleasesReport"
792
+ }
793
+ }
794
+ },
795
+ "Usage": {
796
+ "type": "object",
797
+ "additionalProperties": true,
798
+ "required": [
799
+ "promptTokens",
800
+ "completionTokens",
801
+ "totalTokens",
802
+ "cachedTokens",
803
+ "usageKnown",
804
+ "calls",
805
+ "retries",
806
+ "batches",
807
+ "cacheHits"
808
+ ],
809
+ "properties": {
810
+ "promptTokens": {
811
+ "type": "integer",
812
+ "minimum": 0
813
+ },
814
+ "completionTokens": {
815
+ "type": "integer",
816
+ "minimum": 0
817
+ },
818
+ "totalTokens": {
819
+ "type": "integer",
820
+ "minimum": 0
821
+ },
822
+ "cachedTokens": {
823
+ "type": "integer",
824
+ "minimum": 0
825
+ },
826
+ "usageKnown": {
827
+ "type": "boolean"
828
+ },
829
+ "calls": {
830
+ "type": "integer",
831
+ "minimum": 0
832
+ },
833
+ "retries": {
834
+ "type": "integer",
835
+ "minimum": 0
836
+ },
837
+ "batches": {
838
+ "type": "integer",
839
+ "minimum": 0
840
+ },
841
+ "cacheHits": {
842
+ "type": "integer",
843
+ "minimum": 0
844
+ }
845
+ }
846
+ },
847
+ "StateRun": {
848
+ "type": "object",
849
+ "additionalProperties": true,
850
+ "required": [
851
+ "date",
852
+ "contentHash",
853
+ "runAt"
854
+ ],
855
+ "properties": {
856
+ "date": {
857
+ "type": "string",
858
+ "format": "date"
859
+ },
860
+ "contentHash": {
861
+ "type": "string"
862
+ },
863
+ "outputDir": {
864
+ "type": "string"
865
+ },
866
+ "runAt": {
867
+ "type": "string",
868
+ "format": "date-time"
869
+ }
870
+ }
871
+ },
872
+ "State": {
873
+ "type": "object",
874
+ "additionalProperties": true,
875
+ "required": [
876
+ "ipcSchema",
877
+ "stateSchema"
878
+ ],
879
+ "properties": {
880
+ "ipcSchema": {
881
+ "const": 2
882
+ },
883
+ "stateSchema": {
884
+ "const": 2
885
+ },
886
+ "lastRun": {
887
+ "$ref": "#/$defs/StateRun"
888
+ }
889
+ }
890
+ }
891
+ }
892
+ }
893
+ const digest = {
894
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
895
+ "$id": "https://github.com/morehao/trendradar/contract/schema/digest.v2.json",
896
+ "title": "trendradar digest v2",
897
+ "description": "One day's rendered digest document. contentHash is stable across runs (generatedAt/coreVersion excluded); contentHashAlgo records which algorithm produced it.",
898
+ "type": "object",
899
+ "additionalProperties": true,
900
+ "required": [
901
+ "schema",
902
+ "date",
903
+ "period",
904
+ "languages",
905
+ "count",
906
+ "degraded",
907
+ "contentHash",
908
+ "contentHashAlgo",
909
+ "repos"
910
+ ],
911
+ "properties": {
912
+ "schema": {
913
+ "const": 2
914
+ },
915
+ "date": {
916
+ "type": "string",
917
+ "format": "date"
918
+ },
919
+ "period": {
920
+ "type": "string",
921
+ "enum": [
922
+ "daily",
923
+ "weekly",
924
+ "monthly"
925
+ ]
926
+ },
927
+ "languages": {
928
+ "type": "array",
929
+ "minItems": 1,
930
+ "items": {
931
+ "type": "string"
932
+ }
933
+ },
934
+ "count": {
935
+ "type": "integer",
936
+ "minimum": 0
937
+ },
938
+ "degraded": {
939
+ "type": "boolean"
940
+ },
941
+ "contentHash": {
942
+ "type": "string",
943
+ "pattern": "^sha256:[0-9a-f]{64}$"
944
+ },
945
+ "contentHashAlgo": {
946
+ "type": "string",
947
+ "enum": [
948
+ "jcs-sha256-v1",
949
+ "legacy-struct-marshal-v1"
950
+ ]
951
+ },
952
+ "coreVersion": {
953
+ "type": "string"
954
+ },
955
+ "generatedAt": {
956
+ "type": "string",
957
+ "format": "date-time"
958
+ },
959
+ "repos": {
960
+ "type": "array",
961
+ "items": {
962
+ "$ref": "https://github.com/morehao/trendradar/contract/schema/model.v2.json#/$defs/RepoDigest"
963
+ }
964
+ }
965
+ }
966
+ }
967
+ const releases = {
968
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
969
+ "$id": "https://github.com/morehao/trendradar/contract/schema/releases.v2.json",
970
+ "title": "trendradar releases v2",
971
+ "description": "Repo release subscription documents. ReleaseDigest is the rendered on-disk document; ReleasesReport is the per-run diagnostic carried in RunResult.releases. Token cost lives in ReleasesReport.usage (always present), never in ReleaseDigest, because cost is a property of one run and cannot be reproduced from a stored document.",
972
+ "type": "object",
973
+ "additionalProperties": true,
974
+ "required": [
975
+ "schema",
976
+ "date",
977
+ "period",
978
+ "contentHash",
979
+ "contentHashAlgo",
980
+ "count",
981
+ "degraded",
982
+ "repos"
983
+ ],
984
+ "properties": {
985
+ "schema": {
986
+ "const": 1
987
+ },
988
+ "date": {
989
+ "type": "string",
990
+ "format": "date"
991
+ },
992
+ "period": {
993
+ "type": "string",
994
+ "enum": [
995
+ "daily",
996
+ "weekly",
997
+ "monthly"
998
+ ]
999
+ },
1000
+ "contentHash": {
1001
+ "type": "string",
1002
+ "pattern": "^sha256:[0-9a-f]{64}$"
1003
+ },
1004
+ "contentHashAlgo": {
1005
+ "type": "string",
1006
+ "enum": [
1007
+ "jcs-sha256-v1"
1008
+ ]
1009
+ },
1010
+ "coreVersion": {
1011
+ "type": "string"
1012
+ },
1013
+ "generatedAt": {
1014
+ "type": "string",
1015
+ "format": "date-time"
1016
+ },
1017
+ "count": {
1018
+ "type": "integer",
1019
+ "minimum": 0
1020
+ },
1021
+ "degraded": {
1022
+ "type": "boolean"
1023
+ },
1024
+ "repos": {
1025
+ "type": "array",
1026
+ "items": {
1027
+ "$ref": "#/$defs/RepoReleases"
1028
+ }
1029
+ }
1030
+ },
1031
+ "$defs": {
1032
+ "ReleaseItem": {
1033
+ "type": "object",
1034
+ "additionalProperties": true,
1035
+ "description": "One release or tag. kind distinguishes a GitHub release (has notes) from a tag fallback (commit message used as the summary basis).",
1036
+ "required": [
1037
+ "id",
1038
+ "tag",
1039
+ "name",
1040
+ "kind",
1041
+ "url",
1042
+ "prerelease",
1043
+ "draft",
1044
+ "summaryZh",
1045
+ "summarySource"
1046
+ ],
1047
+ "properties": {
1048
+ "id": {
1049
+ "type": "integer",
1050
+ "minimum": 0,
1051
+ "x-go-type": "int64",
1052
+ "description": "GitHub release id; 0 when the item comes from a tag fallback."
1053
+ },
1054
+ "tag": {
1055
+ "type": "string"
1056
+ },
1057
+ "name": {
1058
+ "type": "string"
1059
+ },
1060
+ "kind": {
1061
+ "type": "string",
1062
+ "enum": [
1063
+ "release",
1064
+ "tag"
1065
+ ]
1066
+ },
1067
+ "publishedAt": {
1068
+ "type": "string",
1069
+ "format": "date-time"
1070
+ },
1071
+ "url": {
1072
+ "type": "string"
1073
+ },
1074
+ "prerelease": {
1075
+ "type": "boolean"
1076
+ },
1077
+ "draft": {
1078
+ "type": "boolean"
1079
+ },
1080
+ "bodyExcerpt": {
1081
+ "type": "string",
1082
+ "description": "Truncated raw release notes. Untrusted text: display only, never execute."
1083
+ },
1084
+ "summaryZh": {
1085
+ "type": "string"
1086
+ },
1087
+ "summarySource": {
1088
+ "type": "string",
1089
+ "enum": [
1090
+ "model",
1091
+ "original"
1092
+ ]
1093
+ }
1094
+ }
1095
+ },
1096
+ "RepoReleases": {
1097
+ "type": "object",
1098
+ "additionalProperties": true,
1099
+ "required": [
1100
+ "fullName",
1101
+ "url",
1102
+ "latestTag",
1103
+ "newCount",
1104
+ "releases"
1105
+ ],
1106
+ "properties": {
1107
+ "fullName": {
1108
+ "type": "string",
1109
+ "pattern": "^[^/]+/[^/]+$"
1110
+ },
1111
+ "url": {
1112
+ "type": "string",
1113
+ "format": "uri"
1114
+ },
1115
+ "latestTag": {
1116
+ "type": "string"
1117
+ },
1118
+ "newCount": {
1119
+ "type": "integer",
1120
+ "minimum": 0
1121
+ },
1122
+ "releases": {
1123
+ "type": "array",
1124
+ "items": {
1125
+ "$ref": "#/$defs/ReleaseItem"
1126
+ }
1127
+ }
1128
+ }
1129
+ },
1130
+ "ReleasesReport": {
1131
+ "type": "object",
1132
+ "additionalProperties": true,
1133
+ "description": "Per-run diagnostic for the releases stage. usage is required and always serialized so a consumer can tell 'nothing spent' (calls=0) from 'spent but not reported' (calls>0 with usageKnown=false).",
1134
+ "required": [
1135
+ "enabled",
1136
+ "repos",
1137
+ "newReleases",
1138
+ "durationMs",
1139
+ "usage"
1140
+ ],
1141
+ "properties": {
1142
+ "enabled": {
1143
+ "type": "boolean"
1144
+ },
1145
+ "repos": {
1146
+ "type": "integer",
1147
+ "minimum": 0
1148
+ },
1149
+ "newReleases": {
1150
+ "type": "integer",
1151
+ "minimum": 0
1152
+ },
1153
+ "summarized": {
1154
+ "type": "integer",
1155
+ "minimum": 0
1156
+ },
1157
+ "degraded": {
1158
+ "type": "integer",
1159
+ "minimum": 0
1160
+ },
1161
+ "failed": {
1162
+ "type": "integer",
1163
+ "minimum": 0
1164
+ },
1165
+ "rateLimited": {
1166
+ "type": "integer",
1167
+ "minimum": 0
1168
+ },
1169
+ "skipped": {
1170
+ "type": "integer",
1171
+ "minimum": 0
1172
+ },
1173
+ "truncated": {
1174
+ "type": "integer",
1175
+ "minimum": 0
1176
+ },
1177
+ "historyTruncated": {
1178
+ "type": "integer",
1179
+ "minimum": 0
1180
+ },
1181
+ "durationMs": {
1182
+ "type": "integer",
1183
+ "minimum": 0
1184
+ },
1185
+ "usage": {
1186
+ "$ref": "https://github.com/morehao/trendradar/contract/schema/ipc.v2.json#/$defs/Usage"
1187
+ }
1188
+ }
1189
+ },
1190
+ "ReleaseManifestEntry": {
1191
+ "type": "object",
1192
+ "additionalProperties": true,
1193
+ "description": "One row of GET /api/v2/releases. Cost is intentionally absent: manifests describe stored documents, which carry no run cost.",
1194
+ "required": [
1195
+ "date",
1196
+ "period",
1197
+ "count",
1198
+ "contentHash"
1199
+ ],
1200
+ "properties": {
1201
+ "date": {
1202
+ "type": "string",
1203
+ "format": "date"
1204
+ },
1205
+ "period": {
1206
+ "type": "string",
1207
+ "enum": [
1208
+ "daily",
1209
+ "weekly",
1210
+ "monthly"
1211
+ ]
1212
+ },
1213
+ "count": {
1214
+ "type": "integer",
1215
+ "minimum": 0
1216
+ },
1217
+ "degraded": {
1218
+ "type": "boolean"
1219
+ },
1220
+ "contentHash": {
1221
+ "type": "string",
1222
+ "pattern": "^sha256:[0-9a-f]{64}$"
1223
+ }
1224
+ }
1225
+ },
1226
+ "SubscriptionList": {
1227
+ "type": "object",
1228
+ "additionalProperties": true,
1229
+ "description": "Response of GET /api/v2/subscriptions.",
1230
+ "required": [
1231
+ "repos"
1232
+ ],
1233
+ "properties": {
1234
+ "repos": {
1235
+ "type": "array",
1236
+ "items": {
1237
+ "type": "string",
1238
+ "pattern": "^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$"
1239
+ }
1240
+ }
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ const versionInfo = {
1246
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1247
+ "$id": "https://github.com/morehao/trendradar/contract/schema/version-info.v2.json",
1248
+ "title": "trendradar version info v2",
1249
+ "description": "Handshake payload returned by `trendradar version --json`. The plugin requires ipcSchema===2 && digestSchema===2 && contractVersion major===2.",
1250
+ "type": "object",
1251
+ "additionalProperties": true,
1252
+ "required": [
1253
+ "version",
1254
+ "commit",
1255
+ "ipcSchema",
1256
+ "digestSchema",
1257
+ "contractVersion",
1258
+ "supportedProviders"
1259
+ ],
1260
+ "properties": {
1261
+ "version": {
1262
+ "type": "string"
1263
+ },
1264
+ "commit": {
1265
+ "type": "string"
1266
+ },
1267
+ "ipcSchema": {
1268
+ "const": 2
1269
+ },
1270
+ "digestSchema": {
1271
+ "const": 2
1272
+ },
1273
+ "contractVersion": {
1274
+ "type": "string"
1275
+ },
1276
+ "supportedProviders": {
1277
+ "type": "array",
1278
+ "items": {
1279
+ "type": "string"
1280
+ }
1281
+ }
1282
+ }
1283
+ }
1284
+ const errors = {
1285
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
1286
+ "$id": "https://github.com/morehao/trendradar/contract/schema/errors.v2.json",
1287
+ "title": "trendradar errors v2",
1288
+ "description": "Canonical error-code catalog. Each property is one error code whose retriable/description are consts, so this file is the single source of truth for retriability. ipc.v2.json ErrorCode enum must match these keys exactly.",
1289
+ "type": "object",
1290
+ "additionalProperties": false,
1291
+ "required": [
1292
+ "INTERNAL",
1293
+ "CONFIG_INVALID",
1294
+ "PAYLOAD_TOO_LARGE",
1295
+ "FETCH_FAILED",
1296
+ "FETCH_RATE_LIMITED",
1297
+ "PARSE_FAILED",
1298
+ "MODEL_UNAUTHORIZED",
1299
+ "MODEL_RATE_LIMITED",
1300
+ "MODEL_TIMEOUT",
1301
+ "MODEL_FAILED",
1302
+ "MODEL_BAD_OUTPUT",
1303
+ "GIT_NOT_INSTALLED",
1304
+ "REPO_NOT_GIT",
1305
+ "REPO_DIRTY",
1306
+ "GIT_OPERATION_FAILED",
1307
+ "PR_FAILED",
1308
+ "NOT_MERGEABLE"
1309
+ ],
1310
+ "properties": {
1311
+ "INTERNAL": {
1312
+ "type": "object",
1313
+ "additionalProperties": false,
1314
+ "required": [
1315
+ "retriable",
1316
+ "description"
1317
+ ],
1318
+ "properties": {
1319
+ "retriable": {
1320
+ "const": true
1321
+ },
1322
+ "description": {
1323
+ "const": "Unexpected internal error (transient panic/IO); retry may succeed."
1324
+ }
1325
+ }
1326
+ },
1327
+ "CONFIG_INVALID": {
1328
+ "type": "object",
1329
+ "additionalProperties": false,
1330
+ "required": [
1331
+ "retriable",
1332
+ "description"
1333
+ ],
1334
+ "properties": {
1335
+ "retriable": {
1336
+ "const": false
1337
+ },
1338
+ "description": {
1339
+ "const": "Configuration is invalid or unreadable."
1340
+ }
1341
+ }
1342
+ },
1343
+ "PAYLOAD_TOO_LARGE": {
1344
+ "type": "object",
1345
+ "additionalProperties": false,
1346
+ "required": [
1347
+ "retriable",
1348
+ "description"
1349
+ ],
1350
+ "properties": {
1351
+ "retriable": {
1352
+ "const": false
1353
+ },
1354
+ "description": {
1355
+ "const": "Input payload exceeds the allowed size."
1356
+ }
1357
+ }
1358
+ },
1359
+ "FETCH_FAILED": {
1360
+ "type": "object",
1361
+ "additionalProperties": false,
1362
+ "required": [
1363
+ "retriable",
1364
+ "description"
1365
+ ],
1366
+ "properties": {
1367
+ "retriable": {
1368
+ "const": false
1369
+ },
1370
+ "description": {
1371
+ "const": "Fetching trending data failed terminally (retries exhausted)."
1372
+ }
1373
+ }
1374
+ },
1375
+ "FETCH_RATE_LIMITED": {
1376
+ "type": "object",
1377
+ "additionalProperties": false,
1378
+ "required": [
1379
+ "retriable",
1380
+ "description"
1381
+ ],
1382
+ "properties": {
1383
+ "retriable": {
1384
+ "const": true
1385
+ },
1386
+ "description": {
1387
+ "const": "Fetching was rate limited; retry later."
1388
+ }
1389
+ }
1390
+ },
1391
+ "PARSE_FAILED": {
1392
+ "type": "object",
1393
+ "additionalProperties": false,
1394
+ "required": [
1395
+ "retriable",
1396
+ "description"
1397
+ ],
1398
+ "properties": {
1399
+ "retriable": {
1400
+ "const": false
1401
+ },
1402
+ "description": {
1403
+ "const": "Parsing fetched HTML/JSON failed."
1404
+ }
1405
+ }
1406
+ },
1407
+ "MODEL_UNAUTHORIZED": {
1408
+ "type": "object",
1409
+ "additionalProperties": false,
1410
+ "required": [
1411
+ "retriable",
1412
+ "description"
1413
+ ],
1414
+ "properties": {
1415
+ "retriable": {
1416
+ "const": false
1417
+ },
1418
+ "description": {
1419
+ "const": "Model provider rejected the credentials."
1420
+ }
1421
+ }
1422
+ },
1423
+ "MODEL_RATE_LIMITED": {
1424
+ "type": "object",
1425
+ "additionalProperties": false,
1426
+ "required": [
1427
+ "retriable",
1428
+ "description"
1429
+ ],
1430
+ "properties": {
1431
+ "retriable": {
1432
+ "const": true
1433
+ },
1434
+ "description": {
1435
+ "const": "Model provider rate limited the request."
1436
+ }
1437
+ }
1438
+ },
1439
+ "MODEL_TIMEOUT": {
1440
+ "type": "object",
1441
+ "additionalProperties": false,
1442
+ "required": [
1443
+ "retriable",
1444
+ "description"
1445
+ ],
1446
+ "properties": {
1447
+ "retriable": {
1448
+ "const": true
1449
+ },
1450
+ "description": {
1451
+ "const": "Model request timed out."
1452
+ }
1453
+ }
1454
+ },
1455
+ "MODEL_FAILED": {
1456
+ "type": "object",
1457
+ "additionalProperties": false,
1458
+ "required": [
1459
+ "retriable",
1460
+ "description"
1461
+ ],
1462
+ "properties": {
1463
+ "retriable": {
1464
+ "const": true
1465
+ },
1466
+ "description": {
1467
+ "const": "Model request failed."
1468
+ }
1469
+ }
1470
+ },
1471
+ "MODEL_BAD_OUTPUT": {
1472
+ "type": "object",
1473
+ "additionalProperties": false,
1474
+ "required": [
1475
+ "retriable",
1476
+ "description"
1477
+ ],
1478
+ "properties": {
1479
+ "retriable": {
1480
+ "const": false
1481
+ },
1482
+ "description": {
1483
+ "const": "Model returned output that violates the expected shape."
1484
+ }
1485
+ }
1486
+ },
1487
+ "GIT_NOT_INSTALLED": {
1488
+ "type": "object",
1489
+ "additionalProperties": false,
1490
+ "required": [
1491
+ "retriable",
1492
+ "description"
1493
+ ],
1494
+ "properties": {
1495
+ "retriable": {
1496
+ "const": false
1497
+ },
1498
+ "description": {
1499
+ "const": "git executable was not found."
1500
+ }
1501
+ }
1502
+ },
1503
+ "REPO_NOT_GIT": {
1504
+ "type": "object",
1505
+ "additionalProperties": false,
1506
+ "required": [
1507
+ "retriable",
1508
+ "description"
1509
+ ],
1510
+ "properties": {
1511
+ "retriable": {
1512
+ "const": false
1513
+ },
1514
+ "description": {
1515
+ "const": "Target directory is not a git repository."
1516
+ }
1517
+ }
1518
+ },
1519
+ "REPO_DIRTY": {
1520
+ "type": "object",
1521
+ "additionalProperties": false,
1522
+ "required": [
1523
+ "retriable",
1524
+ "description"
1525
+ ],
1526
+ "properties": {
1527
+ "retriable": {
1528
+ "const": false
1529
+ },
1530
+ "description": {
1531
+ "const": "Git working tree has uncommitted changes."
1532
+ }
1533
+ }
1534
+ },
1535
+ "GIT_OPERATION_FAILED": {
1536
+ "type": "object",
1537
+ "additionalProperties": false,
1538
+ "required": [
1539
+ "retriable",
1540
+ "description"
1541
+ ],
1542
+ "properties": {
1543
+ "retriable": {
1544
+ "const": true
1545
+ },
1546
+ "description": {
1547
+ "const": "A git operation (commit/push) failed."
1548
+ }
1549
+ }
1550
+ },
1551
+ "PR_FAILED": {
1552
+ "type": "object",
1553
+ "additionalProperties": false,
1554
+ "required": [
1555
+ "retriable",
1556
+ "description"
1557
+ ],
1558
+ "properties": {
1559
+ "retriable": {
1560
+ "const": true
1561
+ },
1562
+ "description": {
1563
+ "const": "Opening or updating the pull request failed."
1564
+ }
1565
+ }
1566
+ },
1567
+ "NOT_MERGEABLE": {
1568
+ "type": "object",
1569
+ "additionalProperties": false,
1570
+ "required": [
1571
+ "retriable",
1572
+ "description"
1573
+ ],
1574
+ "properties": {
1575
+ "retriable": {
1576
+ "const": false
1577
+ },
1578
+ "description": {
1579
+ "const": "Pull request is not mergeable."
1580
+ }
1581
+ }
1582
+ }
1583
+ },
1584
+ "$defs": {
1585
+ "ErrorCode": {
1586
+ "type": "string",
1587
+ "enum": [
1588
+ "INTERNAL",
1589
+ "CONFIG_INVALID",
1590
+ "PAYLOAD_TOO_LARGE",
1591
+ "FETCH_FAILED",
1592
+ "FETCH_RATE_LIMITED",
1593
+ "PARSE_FAILED",
1594
+ "MODEL_UNAUTHORIZED",
1595
+ "MODEL_RATE_LIMITED",
1596
+ "MODEL_TIMEOUT",
1597
+ "MODEL_FAILED",
1598
+ "MODEL_BAD_OUTPUT",
1599
+ "GIT_NOT_INSTALLED",
1600
+ "REPO_NOT_GIT",
1601
+ "REPO_DIRTY",
1602
+ "GIT_OPERATION_FAILED",
1603
+ "PR_FAILED",
1604
+ "NOT_MERGEABLE"
1605
+ ]
1606
+ },
1607
+ "ErrorMeta": {
1608
+ "type": "object",
1609
+ "additionalProperties": false,
1610
+ "required": [
1611
+ "retriable",
1612
+ "description"
1613
+ ],
1614
+ "properties": {
1615
+ "retriable": {
1616
+ "type": "boolean"
1617
+ },
1618
+ "description": {
1619
+ "type": "string"
1620
+ }
1621
+ }
1622
+ }
1623
+ }
1624
+ }
1625
+ const api = "openapi: 3.1.0\ninfo:\n title: trendradar serve API\n version: 0.3.0\n description: |\n Read-only HTTP surface exposed by `trendradar serve`. All payloads reuse the\n contract schemas, so the plugin and any web UI consume the same shapes\n whether data comes from the filesystem or over HTTP. Historical v1 digests\n read from disk are normalized to the v2 shape with\n contentHashAlgo=legacy-struct-marshal-v1.\n\n Release endpoints are read-only. Token cost for a releases run is NOT part of\n a stored document (it describes one run and cannot be reproduced); it is\n reported in `releases.usage` of `trendradar run --json` and appended to\n `<repo>/.git/trendradar-usage.jsonl` with stage=\"releases\".\nservers:\n - url: http://127.0.0.1:8787\npaths:\n /api/v2/digests/{date}:\n get:\n operationId: getDigest\n summary: Fetch one day's digest\n parameters:\n - name: date\n in: path\n required: true\n schema:\n type: string\n format: date\n responses:\n \"200\":\n description: The digest document\n content:\n application/json:\n schema:\n $ref: \"./digest.v2.json\"\n \"404\":\n description: No digest for that date\n /api/v2/manifest:\n get:\n operationId: getManifest\n summary: List available dates and their content identity\n responses:\n \"200\":\n description: Manifest of available digests\n content:\n application/json:\n schema:\n type: object\n required: [entries]\n properties:\n coreVersion:\n type: string\n entries:\n type: array\n items:\n type: object\n required: [date, contentHash, schema, contentHashAlgo]\n properties:\n date:\n type: string\n format: date\n contentHash:\n type: string\n schema:\n type: integer\n contentHashAlgo:\n type: string\n enum: [jcs-sha256-v1, legacy-struct-marshal-v1]\n degraded:\n type: boolean\n /api/v2/releases:\n get:\n operationId: listReleases\n summary: List available release digests (newest first)\n description: |\n Returns an empty array (not 404) when no release digest exists yet.\n Entries carry no token cost because stored documents do not record it.\n parameters:\n - name: period\n in: query\n required: false\n schema:\n type: string\n enum: [daily, weekly, monthly]\n responses:\n \"200\":\n description: Manifest of release digests\n content:\n application/json:\n schema:\n type: array\n items:\n $ref: \"./releases.v2.json#/$defs/ReleaseManifestEntry\"\n /api/v2/releases/{date}:\n get:\n operationId: getReleases\n summary: Fetch one period's release digest\n parameters:\n - name: date\n in: path\n required: true\n schema:\n type: string\n format: date\n - name: period\n in: query\n required: false\n schema:\n type: string\n enum: [daily, weekly, monthly]\n responses:\n \"200\":\n description: The release digest document\n content:\n application/json:\n schema:\n $ref: \"./releases.v2.json\"\n \"404\":\n description: No release digest for that date\n /api/v2/subscriptions:\n get:\n operationId: listSubscriptions\n summary: List the repo subscriptions the core will poll\n description: |\n Read-only. Returns an empty array when the subscription file is missing\n or empty. Writing subscriptions stays on the CLI / IPC subscribe command.\n responses:\n \"200\":\n description: Current subscription list\n content:\n application/json:\n schema:\n $ref: \"./releases.v2.json#/$defs/SubscriptionList\"\n /feed.xml:\n get:\n operationId: getFeed\n summary: RSS feed of the most recent digests\n responses:\n \"200\":\n description: RSS 2.0 feed\n content:\n application/rss+xml:\n schema:\n type: string\n"
1626
+
1627
+ export const rawSchema = { model, ipc, digest, releases, errors, versionInfo, api }
1628
+
1629
+ const ajv = new Ajv({ allErrors: true, strict: false })
1630
+ addFormats(ajv)
1631
+ ajv.addSchema(model)
1632
+ ajv.addSchema(ipc)
1633
+ ajv.addSchema(digest)
1634
+ ajv.addSchema(releases)
1635
+ ajv.addSchema(versionInfo)
1636
+
1637
+ export const validators = {
1638
+ runRequest: ajv.compile({ $ref: ipc.$id + '#/$defs/RunRequest' }),
1639
+ runResult: ajv.compile({ $ref: ipc.$id + '#/$defs/RunResult' }),
1640
+ digest: ajv.getSchema(digest.$id),
1641
+ releases: ajv.getSchema(releases.$id),
1642
+ releasesReport: ajv.compile({ $ref: releases.$id + '#/$defs/ReleasesReport' }),
1643
+ versionInfo: ajv.getSchema(versionInfo.$id),
1644
+ }