@gmickel/gno 1.20.0 → 1.22.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.
Files changed (55) hide show
  1. package/README.md +29 -5
  2. package/assets/skill/SKILL.md +46 -15
  3. package/package.json +2 -1
  4. package/spec/cli.md +144 -0
  5. package/spec/db/schema.sql +170 -0
  6. package/spec/evals-agentic.md +48 -0
  7. package/spec/mcp.md +22 -0
  8. package/spec/output-schemas/capsule-reverified-event.schema.json +47 -0
  9. package/spec/output-schemas/changes.schema.json +280 -0
  10. package/spec/output-schemas/document-diff.schema.json +185 -0
  11. package/spec/output-schemas/impact.schema.json +122 -0
  12. package/spec/output-schemas/publish-artifact.schema.json +284 -0
  13. package/spec/output-schemas/saved-capsule-list.schema.json +16 -0
  14. package/spec/output-schemas/saved-capsule-registration.schema.json +172 -0
  15. package/spec/output-schemas/saved-capsule-reverification.schema.json +59 -0
  16. package/spec/output-schemas/saved-capsule-unwatch.schema.json +16 -0
  17. package/spec/output-schemas/saved-capsule-watch.schema.json +17 -0
  18. package/src/cli/commands/changes.ts +160 -0
  19. package/src/cli/commands/context-saved.ts +189 -0
  20. package/src/cli/options.ts +8 -0
  21. package/src/cli/program.ts +195 -0
  22. package/src/core/capsule-registry.ts +279 -0
  23. package/src/core/capsule-reverification-scheduler.ts +218 -0
  24. package/src/core/capsule-reverification.ts +289 -0
  25. package/src/core/change-diff.ts +182 -0
  26. package/src/core/change-journal.ts +228 -0
  27. package/src/core/knowledge-delta.ts +395 -0
  28. package/src/core/knowledge-impact.ts +202 -0
  29. package/src/ingestion/sync.ts +214 -165
  30. package/src/mcp/tools/changes.ts +80 -0
  31. package/src/mcp/tools/index.ts +29 -0
  32. package/src/publish/artifact-validation.ts +259 -0
  33. package/src/publish/artifact.ts +234 -118
  34. package/src/publish/export-service.ts +5 -9
  35. package/src/publish/metadata.ts +195 -0
  36. package/src/sdk/client.ts +42 -0
  37. package/src/sdk/index.ts +7 -0
  38. package/src/sdk/types.ts +22 -0
  39. package/src/serve/doc-events.ts +12 -1
  40. package/src/serve/resident-runtime.ts +22 -0
  41. package/src/serve/routes/api.ts +13 -0
  42. package/src/serve/routes/changes.ts +102 -0
  43. package/src/serve/server.ts +34 -0
  44. package/src/serve/watch-service.ts +9 -0
  45. package/src/store/index.ts +21 -0
  46. package/src/store/migrations/015-document-change-journal.ts +85 -0
  47. package/src/store/migrations/016-saved-capsules.ts +131 -0
  48. package/src/store/migrations/017-document-change-retention-counters.ts +33 -0
  49. package/src/store/migrations/018-saved-capsule-registration-epoch.ts +24 -0
  50. package/src/store/migrations/019-saved-capsule-registration-generation.ts +53 -0
  51. package/src/store/migrations/index.ts +10 -0
  52. package/src/store/sqlite/adapter.ts +291 -7
  53. package/src/store/sqlite/capsule-registry-store.ts +534 -0
  54. package/src/store/sqlite/change-journal-store.ts +473 -0
  55. package/src/store/types.ts +262 -0
@@ -0,0 +1,284 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/publish-artifact@1.0",
4
+ "title": "GNO publish artifact",
5
+ "oneOf": [
6
+ { "$ref": "#/definitions/artifactV1" },
7
+ { "$ref": "#/definitions/artifactV2" }
8
+ ],
9
+ "definitions": {
10
+ "artifactV1": {
11
+ "type": "object",
12
+ "additionalProperties": false,
13
+ "required": ["version", "source", "exportedAt", "spaces"],
14
+ "properties": {
15
+ "version": { "const": 1 },
16
+ "source": { "$ref": "#/definitions/slug" },
17
+ "exportedAt": { "type": "string", "format": "date-time" },
18
+ "spaces": {
19
+ "type": "array",
20
+ "minItems": 1,
21
+ "items": {
22
+ "oneOf": [
23
+ { "$ref": "#/definitions/publicSpace" },
24
+ { "$ref": "#/definitions/restrictedSpace" }
25
+ ]
26
+ }
27
+ }
28
+ }
29
+ },
30
+ "artifactV2": {
31
+ "type": "object",
32
+ "additionalProperties": false,
33
+ "required": ["version", "source", "exportedAt", "spaces"],
34
+ "properties": {
35
+ "version": { "const": 2 },
36
+ "source": { "$ref": "#/definitions/slug" },
37
+ "exportedAt": { "type": "string", "format": "date-time" },
38
+ "spaces": {
39
+ "type": "array",
40
+ "minItems": 1,
41
+ "items": { "$ref": "#/definitions/encryptedSpace" }
42
+ }
43
+ }
44
+ },
45
+ "slug": {
46
+ "type": "string",
47
+ "pattern": "^[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?$",
48
+ "maxLength": 80
49
+ },
50
+ "hash": {
51
+ "type": "string",
52
+ "pattern": "^[a-f0-9]{64}$"
53
+ },
54
+ "docid": {
55
+ "type": "string",
56
+ "pattern": "^#[a-f0-9]{8}$"
57
+ },
58
+ "metadata": {
59
+ "type": "object",
60
+ "additionalProperties": {
61
+ "oneOf": [
62
+ { "type": "string" },
63
+ {
64
+ "type": "array",
65
+ "items": { "type": "string" }
66
+ }
67
+ ]
68
+ }
69
+ },
70
+ "note": {
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "required": ["markdown", "slug", "summary", "title"],
74
+ "properties": {
75
+ "markdown": { "type": "string" },
76
+ "metadata": { "$ref": "#/definitions/metadata" },
77
+ "slug": { "$ref": "#/definitions/slug" },
78
+ "summary": { "type": "string" },
79
+ "title": { "type": "string", "minLength": 1 }
80
+ }
81
+ },
82
+ "publicSpace": {
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "required": [
86
+ "notes",
87
+ "routeSlug",
88
+ "sourceType",
89
+ "summary",
90
+ "title",
91
+ "visibility",
92
+ "manifest"
93
+ ],
94
+ "properties": {
95
+ "homeNoteSlug": { "$ref": "#/definitions/slug" },
96
+ "notes": {
97
+ "type": "array",
98
+ "minItems": 1,
99
+ "items": { "$ref": "#/definitions/note" }
100
+ },
101
+ "routeSlug": { "$ref": "#/definitions/slug" },
102
+ "sourceType": { "enum": ["note", "collection"] },
103
+ "summary": { "type": "string" },
104
+ "title": { "type": "string", "minLength": 1 },
105
+ "visibility": { "const": "public" },
106
+ "manifest": { "$ref": "#/definitions/publicManifest" }
107
+ }
108
+ },
109
+ "restrictedSpace": {
110
+ "type": "object",
111
+ "additionalProperties": false,
112
+ "required": [
113
+ "notes",
114
+ "routeSlug",
115
+ "sourceType",
116
+ "summary",
117
+ "title",
118
+ "visibility"
119
+ ],
120
+ "properties": {
121
+ "homeNoteSlug": { "$ref": "#/definitions/slug" },
122
+ "notes": {
123
+ "type": "array",
124
+ "minItems": 1,
125
+ "items": { "$ref": "#/definitions/note" }
126
+ },
127
+ "routeSlug": { "$ref": "#/definitions/slug" },
128
+ "sourceType": { "enum": ["note", "collection"] },
129
+ "summary": { "type": "string" },
130
+ "title": { "type": "string", "minLength": 1 },
131
+ "visibility": { "enum": ["secret-link", "invite-only"] }
132
+ }
133
+ },
134
+ "publicManifest": {
135
+ "type": "object",
136
+ "additionalProperties": false,
137
+ "required": [
138
+ "schemaVersion",
139
+ "projectionRevision",
140
+ "generatedAt",
141
+ "visibility",
142
+ "capabilities",
143
+ "documents"
144
+ ],
145
+ "properties": {
146
+ "schemaVersion": { "const": "1.0" },
147
+ "projectionRevision": { "$ref": "#/definitions/hash" },
148
+ "generatedAt": { "type": "string", "format": "date-time" },
149
+ "visibility": { "const": "public" },
150
+ "capabilities": {
151
+ "type": "object",
152
+ "additionalProperties": false,
153
+ "required": [
154
+ "capsuleEvidence",
155
+ "exactLineCitations",
156
+ "llmsTxt",
157
+ "markdownDocuments"
158
+ ],
159
+ "properties": {
160
+ "capsuleEvidence": { "const": true },
161
+ "exactLineCitations": { "const": true },
162
+ "llmsTxt": { "const": true },
163
+ "markdownDocuments": { "const": true }
164
+ }
165
+ },
166
+ "documents": {
167
+ "type": "array",
168
+ "minItems": 1,
169
+ "items": { "$ref": "#/definitions/publicDocument" }
170
+ }
171
+ }
172
+ },
173
+ "publicDocument": {
174
+ "type": "object",
175
+ "additionalProperties": false,
176
+ "required": [
177
+ "slug",
178
+ "title",
179
+ "summary",
180
+ "markdownPath",
181
+ "contentHash",
182
+ "byteLength",
183
+ "lineCount",
184
+ "evidence"
185
+ ],
186
+ "properties": {
187
+ "slug": { "$ref": "#/definitions/slug" },
188
+ "title": { "type": "string", "minLength": 1 },
189
+ "summary": { "type": "string" },
190
+ "markdownPath": {
191
+ "type": "string",
192
+ "pattern": "^\\./[a-z0-9](?:[a-z0-9-]{0,78}[a-z0-9])?\\.md$"
193
+ },
194
+ "contentHash": { "$ref": "#/definitions/hash" },
195
+ "byteLength": { "type": "integer", "minimum": 0 },
196
+ "lineCount": { "type": "integer", "minimum": 1 },
197
+ "evidence": { "$ref": "#/definitions/publicEvidence" }
198
+ }
199
+ },
200
+ "publicEvidence": {
201
+ "type": "object",
202
+ "additionalProperties": false,
203
+ "required": [
204
+ "evidenceId",
205
+ "uri",
206
+ "docid",
207
+ "startLine",
208
+ "endLine",
209
+ "sourceHash",
210
+ "mirrorHash",
211
+ "passageHash",
212
+ "locator"
213
+ ],
214
+ "properties": {
215
+ "evidenceId": { "$ref": "#/definitions/hash" },
216
+ "uri": {
217
+ "type": "string",
218
+ "pattern": "^gno://public/[a-z0-9][a-z0-9-]{0,79}/[a-z0-9][a-z0-9-]{0,79}\\.md$"
219
+ },
220
+ "docid": { "$ref": "#/definitions/docid" },
221
+ "startLine": { "const": 1 },
222
+ "endLine": { "type": "integer", "minimum": 1 },
223
+ "sourceHash": { "$ref": "#/definitions/hash" },
224
+ "mirrorHash": { "$ref": "#/definitions/hash" },
225
+ "passageHash": { "$ref": "#/definitions/hash" },
226
+ "locator": {
227
+ "type": "string",
228
+ "pattern": "^\\./[a-z0-9][a-z0-9-]{0,79}\\.md#L1-L[1-9][0-9]*$"
229
+ }
230
+ }
231
+ },
232
+ "encryptedSpace": {
233
+ "type": "object",
234
+ "additionalProperties": false,
235
+ "required": [
236
+ "encryptedPayload",
237
+ "routeSlug",
238
+ "secretToken",
239
+ "sourceType",
240
+ "visibility"
241
+ ],
242
+ "properties": {
243
+ "encryptedPayload": {
244
+ "type": "object",
245
+ "additionalProperties": false,
246
+ "required": ["ciphertext", "iterations", "iv", "salt"],
247
+ "properties": {
248
+ "ciphertext": {
249
+ "type": "string",
250
+ "minLength": 1,
251
+ "maxLength": 67108864,
252
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
253
+ },
254
+ "iterations": {
255
+ "type": "integer",
256
+ "minimum": 1,
257
+ "maximum": 9007199254740991
258
+ },
259
+ "iv": {
260
+ "type": "string",
261
+ "minLength": 1,
262
+ "maxLength": 1024,
263
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
264
+ },
265
+ "salt": {
266
+ "type": "string",
267
+ "minLength": 1,
268
+ "maxLength": 1024,
269
+ "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
270
+ }
271
+ }
272
+ },
273
+ "routeSlug": { "$ref": "#/definitions/slug" },
274
+ "secretToken": {
275
+ "type": "string",
276
+ "minLength": 1,
277
+ "maxLength": 512
278
+ },
279
+ "sourceType": { "enum": ["note", "collection"] },
280
+ "visibility": { "const": "encrypted" }
281
+ }
282
+ }
283
+ }
284
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/saved-capsule-list@1.0",
4
+ "title": "GNO Saved Context Capsule List",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "registrations"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "1.0" },
10
+ "registrations": {
11
+ "type": "array",
12
+ "maxItems": 10000,
13
+ "items": { "$ref": "gno://schemas/saved-capsule-registration@1.0" }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,172 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/saved-capsule-registration@1.0",
4
+ "title": "GNO Saved Context Capsule Registration",
5
+ "description": "Metadata-only registration for one caller-owned Context Capsule file. Capsule and passage bytes are never embedded in this payload.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "registrationId",
10
+ "filePath",
11
+ "fileHash",
12
+ "capsuleId",
13
+ "indexName",
14
+ "question",
15
+ "label",
16
+ "notificationPreference",
17
+ "registeredAtMs",
18
+ "updatedAtMs",
19
+ "lastAttemptedSequence",
20
+ "evidence",
21
+ "verification"
22
+ ],
23
+ "properties": {
24
+ "registrationId": {
25
+ "type": "string",
26
+ "pattern": "^capsule-[a-f0-9]{40}$"
27
+ },
28
+ "filePath": { "type": "string", "minLength": 1, "maxLength": 8192 },
29
+ "fileHash": { "$ref": "#/definitions/sha256" },
30
+ "capsuleId": { "$ref": "#/definitions/sha256" },
31
+ "indexName": { "type": "string", "minLength": 1, "maxLength": 128 },
32
+ "question": {
33
+ "type": ["string", "null"],
34
+ "minLength": 1,
35
+ "maxLength": 8192
36
+ },
37
+ "label": {
38
+ "type": ["string", "null"],
39
+ "minLength": 1,
40
+ "maxLength": 512
41
+ },
42
+ "notificationPreference": { "enum": ["none", "local"] },
43
+ "registeredAtMs": { "type": "integer", "minimum": 0 },
44
+ "updatedAtMs": { "type": "integer", "minimum": 0 },
45
+ "lastAttemptedSequence": { "type": "integer", "minimum": 0 },
46
+ "evidence": {
47
+ "type": "array",
48
+ "maxItems": 10000,
49
+ "items": { "$ref": "#/definitions/evidenceReference" }
50
+ },
51
+ "verification": {
52
+ "anyOf": [{ "$ref": "#/definitions/verification" }, { "type": "null" }]
53
+ }
54
+ },
55
+ "definitions": {
56
+ "sha256": {
57
+ "type": "string",
58
+ "pattern": "^[a-f0-9]{64}$"
59
+ },
60
+ "evidenceReference": {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "required": [
64
+ "evidenceId",
65
+ "canonicalUri",
66
+ "collection",
67
+ "sourceHash",
68
+ "mirrorHash",
69
+ "passageHash"
70
+ ],
71
+ "properties": {
72
+ "evidenceId": { "$ref": "#/definitions/sha256" },
73
+ "canonicalUri": { "type": "string", "pattern": "^gno://.+" },
74
+ "collection": { "type": "string", "minLength": 1, "maxLength": 256 },
75
+ "sourceHash": { "$ref": "#/definitions/sha256" },
76
+ "mirrorHash": { "$ref": "#/definitions/sha256" },
77
+ "passageHash": { "$ref": "#/definitions/sha256" }
78
+ }
79
+ },
80
+ "verification": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": [
84
+ "registrationId",
85
+ "triggerKind",
86
+ "fromSequence",
87
+ "throughSequence",
88
+ "operationStatus",
89
+ "affectedQuestionState",
90
+ "affectedReasons",
91
+ "receiptJson",
92
+ "receiptHash",
93
+ "errorCode",
94
+ "errorMessage",
95
+ "verifiedAtMs"
96
+ ],
97
+ "properties": {
98
+ "registrationId": {
99
+ "type": "string",
100
+ "pattern": "^capsule-[a-f0-9]{40}$"
101
+ },
102
+ "triggerKind": { "enum": ["manual", "journal"] },
103
+ "fromSequence": { "type": "integer", "minimum": 0 },
104
+ "throughSequence": { "type": "integer", "minimum": 0 },
105
+ "operationStatus": { "enum": ["completed", "failed"] },
106
+ "affectedQuestionState": {
107
+ "enum": ["unaffected", "affected", "unknown"]
108
+ },
109
+ "affectedReasons": {
110
+ "type": "array",
111
+ "maxItems": 4,
112
+ "uniqueItems": true,
113
+ "items": {
114
+ "enum": [
115
+ "content_stale",
116
+ "content_missing",
117
+ "ranking_changed",
118
+ "fingerprint_changed"
119
+ ]
120
+ }
121
+ },
122
+ "receiptJson": {
123
+ "type": ["string", "null"],
124
+ "maxLength": 16777216
125
+ },
126
+ "receiptHash": {
127
+ "anyOf": [{ "$ref": "#/definitions/sha256" }, { "type": "null" }]
128
+ },
129
+ "errorCode": {
130
+ "type": ["string", "null"],
131
+ "minLength": 1,
132
+ "maxLength": 256
133
+ },
134
+ "errorMessage": {
135
+ "type": ["string", "null"],
136
+ "minLength": 1,
137
+ "maxLength": 4096
138
+ },
139
+ "verifiedAtMs": { "type": "integer", "minimum": 0 }
140
+ },
141
+ "allOf": [
142
+ {
143
+ "if": {
144
+ "properties": { "operationStatus": { "const": "completed" } },
145
+ "required": ["operationStatus"]
146
+ },
147
+ "then": {
148
+ "properties": {
149
+ "affectedQuestionState": {
150
+ "enum": ["unaffected", "affected"]
151
+ },
152
+ "receiptJson": { "type": "string", "minLength": 1 },
153
+ "receiptHash": { "$ref": "#/definitions/sha256" },
154
+ "errorCode": { "type": "null" },
155
+ "errorMessage": { "type": "null" }
156
+ }
157
+ },
158
+ "else": {
159
+ "properties": {
160
+ "affectedQuestionState": { "const": "unknown" },
161
+ "affectedReasons": { "type": "array", "maxItems": 0 },
162
+ "receiptJson": { "type": "null" },
163
+ "receiptHash": { "type": "null" },
164
+ "errorCode": { "type": "string", "minLength": 1 },
165
+ "errorMessage": { "type": "string", "minLength": 1 }
166
+ }
167
+ }
168
+ }
169
+ ]
170
+ }
171
+ }
172
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/saved-capsule-reverification@1.0",
4
+ "title": "GNO Saved Context Capsule Reverification Result",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "registration", "verification", "receipt"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "1.0" },
10
+ "registration": {
11
+ "$ref": "gno://schemas/saved-capsule-registration@1.0"
12
+ },
13
+ "verification": {
14
+ "$ref": "gno://schemas/saved-capsule-registration@1.0#/definitions/verification"
15
+ },
16
+ "receipt": {
17
+ "anyOf": [
18
+ { "$ref": "gno://schemas/context-capsule-verification@1.0" },
19
+ { "type": "null" }
20
+ ]
21
+ }
22
+ },
23
+ "allOf": [
24
+ {
25
+ "if": {
26
+ "properties": {
27
+ "verification": {
28
+ "type": "object",
29
+ "properties": { "operationStatus": { "const": "completed" } },
30
+ "required": ["operationStatus"]
31
+ }
32
+ },
33
+ "required": ["verification"]
34
+ },
35
+ "then": {
36
+ "properties": {
37
+ "verification": {
38
+ "type": "object",
39
+ "properties": { "triggerKind": { "const": "manual" } },
40
+ "required": ["triggerKind"]
41
+ },
42
+ "receipt": {
43
+ "$ref": "gno://schemas/context-capsule-verification@1.0"
44
+ }
45
+ }
46
+ },
47
+ "else": {
48
+ "properties": {
49
+ "verification": {
50
+ "type": "object",
51
+ "properties": { "triggerKind": { "const": "manual" } },
52
+ "required": ["triggerKind"]
53
+ },
54
+ "receipt": { "type": "null" }
55
+ }
56
+ }
57
+ }
58
+ ]
59
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/saved-capsule-unwatch@1.0",
4
+ "title": "GNO Saved Context Capsule Unwatch Receipt",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "registrationId", "removed"],
8
+ "properties": {
9
+ "schemaVersion": { "const": "1.0" },
10
+ "registrationId": {
11
+ "type": "string",
12
+ "pattern": "^capsule-[a-f0-9]{40}$"
13
+ },
14
+ "removed": { "const": true }
15
+ }
16
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/saved-capsule-watch@1.0",
4
+ "title": "GNO Saved Context Capsule Watch Result",
5
+ "allOf": [
6
+ {
7
+ "$ref": "gno://schemas/saved-capsule-registration@1.0"
8
+ },
9
+ {
10
+ "type": "object",
11
+ "properties": {
12
+ "verification": { "type": "null" }
13
+ },
14
+ "required": ["verification"]
15
+ }
16
+ ]
17
+ }