@morehao/trendradar-contract 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morehao/trendradar-contract",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Language-neutral contract (JSON Schema, fixtures, generated Go & TypeScript types) shared by the trendradar Go core and its DSH plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: trendradar serve API
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  description: |
6
6
  Read-only HTTP surface exposed by `trendradar serve`. All payloads reuse the
7
7
  contract schemas, so the plugin and any web UI consume the same shapes
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://github.com/morehao/trendradar/contract/schema/digest.v2.json",
4
- "title": "trendradar digest v2",
3
+ "$id": "https://github.com/morehao/trendradar/contract/schema/digest.v3.json",
4
+ "title": "trendradar digest v3",
5
5
  "description": "One day's rendered digest document. contentHash is stable across runs (generatedAt/coreVersion excluded); contentHashAlgo records which algorithm produced it.",
6
6
  "type": "object",
7
7
  "additionalProperties": true,
8
8
  "required": ["schema", "date", "period", "languages", "count", "degraded", "contentHash", "contentHashAlgo", "repos"],
9
9
  "properties": {
10
- "schema": { "const": 2 },
10
+ "schema": { "const": 3 },
11
11
  "date": { "type": "string", "format": "date" },
12
12
  "period": { "type": "string", "enum": ["daily", "weekly", "monthly"] },
13
13
  "languages": { "type": "array", "minItems": 1, "items": { "type": "string" } },
@@ -19,7 +19,7 @@
19
19
  "generatedAt": { "type": "string", "format": "date-time" },
20
20
  "repos": {
21
21
  "type": "array",
22
- "items": { "$ref": "model.v2.json#/$defs/RepoDigest" }
22
+ "items": { "$ref": "model.v3.json#/$defs/RepoDigest" }
23
23
  }
24
24
  }
25
25
  }
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://github.com/morehao/trendradar/contract/schema/errors.v2.json",
4
4
  "title": "trendradar errors v2",
5
- "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.",
5
+ "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.v3.json ErrorCode enum must match these keys exactly.",
6
6
  "type": "object",
7
7
  "additionalProperties": false,
8
8
  "required": [
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://github.com/morehao/trendradar/contract/schema/ipc.v2.json",
4
- "title": "trendradar ipc v2",
5
- "description": "Envelope exchanged between the trendradar core binary and the DSH plugin. Only RunRequest forbids extra fields. ipcSchema is const 2.",
3
+ "$id": "https://github.com/morehao/trendradar/contract/schema/ipc.v4.json",
4
+ "title": "trendradar ipc v4",
5
+ "description": "Envelope exchanged between the trendradar core binary and the DSH plugin. Only RunRequest forbids extra fields. ipcSchema is const 4.",
6
6
  "oneOf": [
7
7
  {
8
8
  "$ref": "#/$defs/RunRequest"
@@ -79,6 +79,35 @@
79
79
  }
80
80
  }
81
81
  },
82
+ "DigestArtifact": {
83
+ "type": "object",
84
+ "additionalProperties": true,
85
+ "description": "The digest document rendered by this run, inlined so the caller never reads the output repository. bytes/sha256 describe the UTF-8 bytes of text exactly as written to path.",
86
+ "required": [
87
+ "path",
88
+ "bytes",
89
+ "sha256",
90
+ "text"
91
+ ],
92
+ "properties": {
93
+ "path": {
94
+ "type": "string"
95
+ },
96
+ "bytes": {
97
+ "type": "integer",
98
+ "minimum": 0,
99
+ "maximum": 1048576
100
+ },
101
+ "sha256": {
102
+ "type": "string",
103
+ "pattern": "^sha256:[0-9a-f]{64}$"
104
+ },
105
+ "text": {
106
+ "type": "string",
107
+ "maxLength": 1048576
108
+ }
109
+ }
110
+ },
82
111
  "RunRequest": {
83
112
  "type": "object",
84
113
  "additionalProperties": false,
@@ -88,7 +117,7 @@
88
117
  ],
89
118
  "properties": {
90
119
  "ipcSchema": {
91
- "const": 2
120
+ "const": 4
92
121
  },
93
122
  "command": {
94
123
  "type": "string",
@@ -374,7 +403,7 @@
374
403
  ],
375
404
  "properties": {
376
405
  "ipcSchema": {
377
- "const": 2
406
+ "const": 4
378
407
  },
379
408
  "ok": {
380
409
  "type": "boolean"
@@ -406,6 +435,9 @@
406
435
  "$ref": "#/$defs/FileArtifact"
407
436
  }
408
437
  },
438
+ "digest": {
439
+ "$ref": "#/$defs/DigestArtifact"
440
+ },
409
441
  "branch": {
410
442
  "type": "string"
411
443
  },
@@ -433,13 +465,13 @@
433
465
  "$ref": "#/$defs/Usage"
434
466
  },
435
467
  "releases": {
436
- "$ref": "releases.v2.json#/$defs/ReleasesReport"
468
+ "$ref": "releases.v3.json#/$defs/ReleasesReport"
437
469
  },
438
470
  "subscriptions": {
439
- "$ref": "releases.v2.json#/$defs/SubscriptionList"
471
+ "$ref": "releases.v3.json#/$defs/SubscriptionList"
440
472
  },
441
473
  "subscriptionDoc": {
442
- "$ref": "releases.v2.json#/$defs/SubscriptionDoc"
474
+ "$ref": "releases.v3.json#/$defs/SubscriptionDoc"
443
475
  }
444
476
  }
445
477
  },
@@ -529,10 +561,10 @@
529
561
  ],
530
562
  "properties": {
531
563
  "ipcSchema": {
532
- "const": 2
564
+ "const": 4
533
565
  },
534
566
  "stateSchema": {
535
- "const": 2
567
+ "const": 3
536
568
  },
537
569
  "lastRun": {
538
570
  "$ref": "#/$defs/StateRun"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://github.com/morehao/trendradar/contract/schema/model.v2.json",
4
- "title": "trendradar model v2",
3
+ "$id": "https://github.com/morehao/trendradar/contract/schema/model.v3.json",
4
+ "title": "trendradar model v3",
5
5
  "description": "Domain model: a scraped repository snapshot (RepoSnapshot) and its digested form (RepoDigest). RepoDigest composes RepoSnapshot via allOf instead of flattening.",
6
6
  "$ref": "#/$defs/RepoDigest",
7
7
  "$defs": {
@@ -28,9 +28,10 @@
28
28
  {
29
29
  "type": "object",
30
30
  "additionalProperties": true,
31
- "required": ["summaryZh", "summarySource"],
31
+ "required": ["summary", "summaryLang", "summarySource"],
32
32
  "properties": {
33
- "summaryZh": { "type": "string" },
33
+ "summary": { "type": "string" },
34
+ "summaryLang": { "type": "string" },
34
35
  "summarySource": { "type": "string", "enum": ["model", "original"] }
35
36
  }
36
37
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "$id": "https://github.com/morehao/trendradar/contract/schema/releases.v2.json",
4
- "title": "trendradar releases v2",
5
- "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. schema=2 adds the per-repo weekly batch summary (repos[].summaryZh + periodStart/periodEnd); the per-item summaryZh stays readable for old documents but is no longer written.",
3
+ "$id": "https://github.com/morehao/trendradar/contract/schema/releases.v3.json",
4
+ "title": "trendradar releases v3",
5
+ "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. Older documents put one weekly summary per repo (repos[].summary); schema 3 cores write a per-version summary on each repos[].releases[].summary instead, and leave repos[].summary empty on new data (carrying summaryLang when non-empty). Both fields stay optional (readable old + new documents): consumers should prefer the per-item summary and fall back to the repo-level one for older documents.",
6
6
  "type": "object",
7
7
  "additionalProperties": true,
8
8
  "required": [
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "properties": {
19
19
  "schema": {
20
- "const": 2
20
+ "const": 3
21
21
  },
22
22
  "date": {
23
23
  "type": "string",
@@ -66,7 +66,7 @@
66
66
  "ReleaseItem": {
67
67
  "type": "object",
68
68
  "additionalProperties": true,
69
- "description": "One release or tag. kind distinguishes a GitHub release (has notes) from a tag fallback (commit message used as the summary basis). summaryZh is optional and no longer written by schema 2: the summary now lives once per repo per week in RepoReleases.summaryZh.",
69
+ "description": "One release or tag. kind distinguishes a GitHub release (has notes) from a tag fallback (commit message used as the summary basis). summary is this version's own summary in the configured output language, written per version by current cores (incremental). It stays optional so old documents (which only carry the repo-level RepoReleases.summary) remain valid; consumers should prefer this field and fall back to RepoReleases.summary.",
70
70
  "required": [
71
71
  "id",
72
72
  "tag",
@@ -114,9 +114,9 @@
114
114
  "type": "string",
115
115
  "description": "Truncated raw release notes. Untrusted text: display only, never execute."
116
116
  },
117
- "summaryZh": {
117
+ "summary": {
118
118
  "type": "string",
119
- "description": "Legacy per-item summary. Still accepted so documents written before schema 2 stay readable; schema 2 writers leave it empty."
119
+ "description": "This version's own summary in the configured output language (model or original text). Optional: older documents only carry the repo-level summary, and consumers should prefer this field and fall back to RepoReleases.summary."
120
120
  },
121
121
  "summarySource": {
122
122
  "type": "string",
@@ -130,7 +130,7 @@
130
130
  "RepoReleases": {
131
131
  "type": "object",
132
132
  "additionalProperties": true,
133
- "description": "One repo's release batch for one summary period. summaryZh covers the whole week in a single model call; periodStart/periodEnd bound that week so a consumer can label it without parsing dates.",
133
+ "description": "One repo's release batch for one summary period. periodStart/periodEnd bound the period (attributed to the versions' publish dates) so a consumer can label it without parsing dates. summary (repo-level, whole-week) plus optional summaryLang is kept for backward compatibility: current cores summarize per version (releases[].summary) and usually leave this empty on new data.",
134
134
  "required": [
135
135
  "fullName",
136
136
  "url",
@@ -162,9 +162,13 @@
162
162
  "type": "string",
163
163
  "format": "date"
164
164
  },
165
- "summaryZh": {
165
+ "summary": {
166
166
  "type": "string",
167
- "description": "One Chinese summary for every version in this period. Empty when no summary was produced."
167
+ "description": "Optional repo-level summary for the whole period. Current cores summarize per version (releases[].summary) and usually leave this empty. Kept optional for older documents; consumers should prefer releases[].summary and fall back to this."
168
+ },
169
+ "summaryLang": {
170
+ "type": "string",
171
+ "description": "BCP47 language of the repo-level summary above; present only when summary is. Item-level summaries inherit this / the configured output language."
168
172
  },
169
173
  "releases": {
170
174
  "type": "array",
@@ -240,7 +244,7 @@
240
244
  "minimum": 0
241
245
  },
242
246
  "usage": {
243
- "$ref": "ipc.v2.json#/$defs/Usage"
247
+ "$ref": "ipc.v4.json#/$defs/Usage"
244
248
  }
245
249
  }
246
250
  },
@@ -2,15 +2,15 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "$id": "https://github.com/morehao/trendradar/contract/schema/version-info.v2.json",
4
4
  "title": "trendradar version info v2",
5
- "description": "Handshake payload returned by `trendradar version --json`. The plugin requires ipcSchema===2 && digestSchema===2 && contractVersion major===2.",
5
+ "description": "Handshake payload returned by `trendradar version --json`. The plugin requires ipcSchema===4 && digestSchema===3 && contractVersion major===0.",
6
6
  "type": "object",
7
7
  "additionalProperties": true,
8
8
  "required": ["version", "commit", "ipcSchema", "digestSchema", "contractVersion", "supportedProviders"],
9
9
  "properties": {
10
10
  "version": { "type": "string" },
11
11
  "commit": { "type": "string" },
12
- "ipcSchema": { "const": 2 },
13
- "digestSchema": { "const": 2 },
12
+ "ipcSchema": { "const": 4 },
13
+ "digestSchema": { "const": 3 },
14
14
  "contractVersion": { "type": "string" },
15
15
  "supportedProviders": { "type": "array", "items": { "type": "string" } }
16
16
  }
package/version-map.json CHANGED
@@ -1,23 +1,15 @@
1
1
  {
2
- "ipc.v2.json": {
3
- "wireKey": "ipcSchema",
4
- "current": 2,
5
- "breakingBump": [
6
- "ipcSchema",
7
- "packageMajor"
8
- ]
9
- },
10
- "digest.v2.json": {
2
+ "digest.v3.json": {
11
3
  "wireKey": "digestSchema",
12
- "current": 2,
4
+ "current": 3,
13
5
  "breakingBump": [
14
6
  "digestSchema",
15
7
  "packageMajor"
16
8
  ]
17
9
  },
18
- "model.v2.json": {
10
+ "model.v3.json": {
19
11
  "wireKey": null,
20
- "current": 2,
12
+ "current": 3,
21
13
  "propagatesTo": [
22
14
  "digestSchema"
23
15
  ],
@@ -34,24 +26,32 @@
34
26
  },
35
27
  "version-info.v2.json": {
36
28
  "wireKey": "contractVersion",
37
- "current": "0.5.0",
29
+ "current": "0.7.0",
38
30
  "breakingBump": [
39
31
  "packageMajor"
40
32
  ]
41
33
  },
42
34
  "api.v2.yaml": {
43
35
  "wireKey": "info.version",
44
- "current": "0.5.0",
36
+ "current": "0.7.0",
45
37
  "breakingBump": [
46
38
  "packageMajor"
47
39
  ]
48
40
  },
49
- "releases.v2.json": {
41
+ "releases.v3.json": {
50
42
  "wireKey": null,
51
- "current": 2,
43
+ "current": 3,
52
44
  "propagatesTo": [],
53
45
  "breakingBump": [
54
46
  "packageMajor"
55
47
  ]
48
+ },
49
+ "ipc.v4.json": {
50
+ "wireKey": "ipcSchema",
51
+ "current": 4,
52
+ "breakingBump": [
53
+ "ipcSchema",
54
+ "packageMajor"
55
+ ]
56
56
  }
57
57
  }