@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,47 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/capsule-reverified-event@1.0",
4
+ "title": "GNO Metadata-only Saved Capsule Reverification Event",
5
+ "description": "Closed local event emitted only after a saved Capsule verification result commits.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "type",
10
+ "registrationId",
11
+ "capsuleId",
12
+ "operationStatus",
13
+ "affectedQuestionState",
14
+ "changedAt"
15
+ ],
16
+ "properties": {
17
+ "type": { "const": "capsule-reverified" },
18
+ "registrationId": {
19
+ "type": "string",
20
+ "pattern": "^capsule-[a-f0-9]{40}$"
21
+ },
22
+ "capsuleId": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
23
+ "operationStatus": { "enum": ["completed", "failed"] },
24
+ "affectedQuestionState": {
25
+ "enum": ["unaffected", "affected", "unknown"]
26
+ },
27
+ "changedAt": { "type": "string", "format": "date-time" }
28
+ },
29
+ "allOf": [
30
+ {
31
+ "if": {
32
+ "properties": { "operationStatus": { "const": "completed" } },
33
+ "required": ["operationStatus"]
34
+ },
35
+ "then": {
36
+ "properties": {
37
+ "affectedQuestionState": { "enum": ["unaffected", "affected"] }
38
+ }
39
+ },
40
+ "else": {
41
+ "properties": {
42
+ "affectedQuestionState": { "const": "unknown" }
43
+ }
44
+ }
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,280 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/changes@1.0",
4
+ "title": "GNO Knowledge Changes",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "changes", "page", "warnings"],
7
+ "properties": {
8
+ "schemaVersion": { "type": "string", "const": "1.0" },
9
+ "changes": {
10
+ "type": "array",
11
+ "maxItems": 1000,
12
+ "items": { "$ref": "#/definitions/change" }
13
+ },
14
+ "page": {
15
+ "type": "object",
16
+ "required": [
17
+ "nextCursor",
18
+ "earliestCursor",
19
+ "latestCursor",
20
+ "cursorExpired",
21
+ "truncated",
22
+ "retentionTruncated"
23
+ ],
24
+ "properties": {
25
+ "nextCursor": { "type": ["string", "null"], "maxLength": 512 },
26
+ "earliestCursor": {
27
+ "type": "string",
28
+ "minLength": 1,
29
+ "maxLength": 512
30
+ },
31
+ "latestCursor": { "type": "string", "minLength": 1, "maxLength": 512 },
32
+ "cursorExpired": { "type": "boolean" },
33
+ "truncated": { "type": "boolean" },
34
+ "retentionTruncated": { "type": "boolean" }
35
+ },
36
+ "additionalProperties": false
37
+ },
38
+ "warnings": { "type": "array", "items": { "type": "string" } }
39
+ },
40
+ "additionalProperties": false,
41
+ "allOf": [
42
+ {
43
+ "if": {
44
+ "properties": {
45
+ "page": {
46
+ "type": "object",
47
+ "properties": { "cursorExpired": { "const": true } },
48
+ "required": ["cursorExpired"]
49
+ }
50
+ },
51
+ "required": ["page"]
52
+ },
53
+ "then": {
54
+ "properties": {
55
+ "changes": { "type": "array", "maxItems": 0 },
56
+ "page": {
57
+ "type": "object",
58
+ "properties": {
59
+ "nextCursor": { "type": "null" },
60
+ "retentionTruncated": { "const": true }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ },
66
+ {
67
+ "if": {
68
+ "properties": {
69
+ "page": {
70
+ "type": "object",
71
+ "properties": { "truncated": { "const": true } },
72
+ "required": ["truncated"]
73
+ }
74
+ },
75
+ "required": ["page"]
76
+ },
77
+ "then": {
78
+ "properties": {
79
+ "page": {
80
+ "type": "object",
81
+ "properties": {
82
+ "nextCursor": { "type": "string", "minLength": 1 }
83
+ }
84
+ }
85
+ }
86
+ },
87
+ "else": {
88
+ "properties": {
89
+ "page": {
90
+ "type": "object",
91
+ "properties": { "nextCursor": { "type": "null" } }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ ],
97
+ "definitions": {
98
+ "snapshot": {
99
+ "type": "object",
100
+ "required": [
101
+ "relPath",
102
+ "docid",
103
+ "uri",
104
+ "sourceHash",
105
+ "mirrorHash",
106
+ "active"
107
+ ],
108
+ "properties": {
109
+ "relPath": { "type": "string" },
110
+ "docid": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
111
+ "uri": { "type": "string", "pattern": "^gno://.+" },
112
+ "sourceHash": { "$ref": "#/definitions/sha256" },
113
+ "mirrorHash": {
114
+ "anyOf": [{ "$ref": "#/definitions/sha256" }, { "type": "null" }]
115
+ },
116
+ "active": { "type": "boolean" }
117
+ },
118
+ "additionalProperties": false
119
+ },
120
+ "setDelta": {
121
+ "type": "object",
122
+ "required": ["added", "removed"],
123
+ "properties": {
124
+ "added": {
125
+ "type": "array",
126
+ "maxItems": 16,
127
+ "uniqueItems": true,
128
+ "items": { "type": "string", "minLength": 1, "maxLength": 256 }
129
+ },
130
+ "removed": {
131
+ "type": "array",
132
+ "maxItems": 16,
133
+ "uniqueItems": true,
134
+ "items": { "type": "string", "minLength": 1, "maxLength": 256 }
135
+ }
136
+ },
137
+ "additionalProperties": false
138
+ },
139
+ "dateDelta": {
140
+ "type": "object",
141
+ "required": ["added", "removed", "changed"],
142
+ "properties": {
143
+ "added": {
144
+ "type": "array",
145
+ "maxItems": 16,
146
+ "uniqueItems": true,
147
+ "items": { "type": "string", "minLength": 1, "maxLength": 256 }
148
+ },
149
+ "removed": {
150
+ "type": "array",
151
+ "maxItems": 16,
152
+ "uniqueItems": true,
153
+ "items": { "type": "string", "minLength": 1, "maxLength": 256 }
154
+ },
155
+ "changed": {
156
+ "type": "array",
157
+ "maxItems": 16,
158
+ "uniqueItems": true,
159
+ "items": { "type": "string", "minLength": 1, "maxLength": 256 }
160
+ }
161
+ },
162
+ "additionalProperties": false
163
+ },
164
+ "structureDelta": {
165
+ "type": "object",
166
+ "required": ["headings", "links", "typedEdges", "dates", "truncated"],
167
+ "properties": {
168
+ "headings": { "$ref": "#/definitions/setDelta" },
169
+ "links": { "$ref": "#/definitions/setDelta" },
170
+ "typedEdges": { "$ref": "#/definitions/setDelta" },
171
+ "dates": { "$ref": "#/definitions/dateDelta" },
172
+ "truncated": { "type": "boolean" }
173
+ },
174
+ "additionalProperties": false
175
+ },
176
+ "sha256": {
177
+ "type": "string",
178
+ "pattern": "^[a-f0-9]{64}$"
179
+ },
180
+ "change": {
181
+ "type": "object",
182
+ "required": [
183
+ "id",
184
+ "kind",
185
+ "collection",
186
+ "observedAt",
187
+ "previous",
188
+ "current",
189
+ "structureDelta"
190
+ ],
191
+ "properties": {
192
+ "id": { "type": "string", "minLength": 1, "maxLength": 512 },
193
+ "kind": {
194
+ "type": "string",
195
+ "enum": ["create", "update", "rename", "inactivate", "reactivate"]
196
+ },
197
+ "collection": { "type": "string", "minLength": 1 },
198
+ "observedAt": { "type": "string", "format": "date-time" },
199
+ "previous": {
200
+ "anyOf": [{ "$ref": "#/definitions/snapshot" }, { "type": "null" }]
201
+ },
202
+ "current": {
203
+ "anyOf": [{ "$ref": "#/definitions/snapshot" }, { "type": "null" }]
204
+ },
205
+ "structureDelta": { "$ref": "#/definitions/structureDelta" }
206
+ },
207
+ "additionalProperties": false,
208
+ "allOf": [
209
+ {
210
+ "if": {
211
+ "properties": { "kind": { "const": "create" } },
212
+ "required": ["kind"]
213
+ },
214
+ "then": {
215
+ "properties": {
216
+ "previous": { "type": "null" },
217
+ "current": {
218
+ "type": "object",
219
+ "properties": { "active": { "const": true } },
220
+ "required": ["active"]
221
+ }
222
+ }
223
+ }
224
+ },
225
+ {
226
+ "if": {
227
+ "properties": { "kind": { "enum": ["update", "rename"] } },
228
+ "required": ["kind"]
229
+ },
230
+ "then": {
231
+ "properties": {
232
+ "previous": { "$ref": "#/definitions/snapshot" },
233
+ "current": { "$ref": "#/definitions/snapshot" }
234
+ }
235
+ }
236
+ },
237
+ {
238
+ "if": {
239
+ "properties": { "kind": { "const": "inactivate" } },
240
+ "required": ["kind"]
241
+ },
242
+ "then": {
243
+ "properties": {
244
+ "previous": {
245
+ "type": "object",
246
+ "properties": { "active": { "const": true } },
247
+ "required": ["active"]
248
+ },
249
+ "current": {
250
+ "type": "object",
251
+ "properties": { "active": { "const": false } },
252
+ "required": ["active"]
253
+ }
254
+ }
255
+ }
256
+ },
257
+ {
258
+ "if": {
259
+ "properties": { "kind": { "const": "reactivate" } },
260
+ "required": ["kind"]
261
+ },
262
+ "then": {
263
+ "properties": {
264
+ "previous": {
265
+ "type": "object",
266
+ "properties": { "active": { "const": false } },
267
+ "required": ["active"]
268
+ },
269
+ "current": {
270
+ "type": "object",
271
+ "properties": { "active": { "const": true } },
272
+ "required": ["active"]
273
+ }
274
+ }
275
+ }
276
+ }
277
+ ]
278
+ }
279
+ }
280
+ }
@@ -0,0 +1,185 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/document-diff@1.0",
4
+ "title": "GNO Document Structural Diff",
5
+ "type": "object",
6
+ "required": [
7
+ "schemaVersion",
8
+ "status",
9
+ "document",
10
+ "change",
11
+ "content",
12
+ "history",
13
+ "warnings"
14
+ ],
15
+ "properties": {
16
+ "schemaVersion": { "type": "string", "const": "1.0" },
17
+ "status": {
18
+ "type": "string",
19
+ "enum": ["available", "expired", "unavailable"]
20
+ },
21
+ "document": {
22
+ "type": "object",
23
+ "required": ["id", "uri", "title", "collection", "relPath", "active"],
24
+ "properties": {
25
+ "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
26
+ "uri": { "type": "string", "pattern": "^gno://.+" },
27
+ "title": { "type": ["string", "null"] },
28
+ "collection": { "type": "string" },
29
+ "relPath": { "type": "string" },
30
+ "active": { "type": "boolean" }
31
+ },
32
+ "additionalProperties": false
33
+ },
34
+ "change": {
35
+ "anyOf": [
36
+ { "$ref": "gno://schemas/changes@1.0#/definitions/change" },
37
+ { "type": "null" }
38
+ ]
39
+ },
40
+ "content": {
41
+ "type": "object",
42
+ "required": ["status", "reason"],
43
+ "properties": {
44
+ "status": { "type": "string", "const": "not_retained" },
45
+ "reason": { "type": "string", "const": "journal_metadata_only" }
46
+ },
47
+ "additionalProperties": false
48
+ },
49
+ "history": {
50
+ "type": "object",
51
+ "required": ["status", "reason"],
52
+ "properties": {
53
+ "status": {
54
+ "type": "string",
55
+ "enum": ["available", "partial", "unavailable"]
56
+ },
57
+ "reason": {
58
+ "type": ["string", "null"],
59
+ "enum": [
60
+ null,
61
+ "structure_delta_truncated",
62
+ "change_expired",
63
+ "no_retained_change",
64
+ "change_not_found"
65
+ ]
66
+ }
67
+ },
68
+ "additionalProperties": false
69
+ },
70
+ "warnings": { "type": "array", "items": { "type": "string" } }
71
+ },
72
+ "additionalProperties": false,
73
+ "allOf": [
74
+ {
75
+ "if": {
76
+ "properties": { "status": { "const": "available" } },
77
+ "required": ["status"]
78
+ },
79
+ "then": {
80
+ "properties": {
81
+ "change": {
82
+ "$ref": "gno://schemas/changes@1.0#/definitions/change"
83
+ },
84
+ "history": {
85
+ "type": "object",
86
+ "properties": {
87
+ "status": { "enum": ["available", "partial"] }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ },
93
+ {
94
+ "if": {
95
+ "properties": { "status": { "const": "expired" } },
96
+ "required": ["status"]
97
+ },
98
+ "then": {
99
+ "properties": {
100
+ "change": { "type": "null" },
101
+ "history": {
102
+ "type": "object",
103
+ "properties": {
104
+ "status": { "const": "unavailable" },
105
+ "reason": { "const": "change_expired" }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ },
111
+ {
112
+ "if": {
113
+ "properties": { "status": { "const": "unavailable" } },
114
+ "required": ["status"]
115
+ },
116
+ "then": {
117
+ "properties": {
118
+ "change": { "type": "null" },
119
+ "history": {
120
+ "type": "object",
121
+ "properties": {
122
+ "status": { "const": "unavailable" },
123
+ "reason": {
124
+ "enum": ["no_retained_change", "change_not_found"]
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ },
131
+ {
132
+ "if": {
133
+ "properties": {
134
+ "history": {
135
+ "type": "object",
136
+ "properties": { "status": { "const": "available" } },
137
+ "required": ["status"]
138
+ }
139
+ },
140
+ "required": ["history"]
141
+ },
142
+ "then": {
143
+ "properties": {
144
+ "history": {
145
+ "type": "object",
146
+ "properties": { "reason": { "type": "null" } }
147
+ }
148
+ }
149
+ }
150
+ },
151
+ {
152
+ "if": {
153
+ "properties": {
154
+ "history": {
155
+ "type": "object",
156
+ "properties": { "status": { "const": "partial" } },
157
+ "required": ["status"]
158
+ }
159
+ },
160
+ "required": ["history"]
161
+ },
162
+ "then": {
163
+ "properties": {
164
+ "change": {
165
+ "type": "object",
166
+ "properties": {
167
+ "structureDelta": {
168
+ "type": "object",
169
+ "properties": { "truncated": { "const": true } },
170
+ "required": ["truncated"]
171
+ }
172
+ },
173
+ "required": ["structureDelta"]
174
+ },
175
+ "history": {
176
+ "type": "object",
177
+ "properties": {
178
+ "reason": { "const": "structure_delta_truncated" }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ ]
185
+ }
@@ -0,0 +1,122 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/impact@1.0",
4
+ "title": "GNO Knowledge Impact",
5
+ "type": "object",
6
+ "required": ["schemaVersion", "root", "impacted", "meta"],
7
+ "properties": {
8
+ "schemaVersion": { "type": "string", "const": "1.0" },
9
+ "root": { "$ref": "#/definitions/node" },
10
+ "impacted": {
11
+ "type": "array",
12
+ "maxItems": 999,
13
+ "items": {
14
+ "type": "object",
15
+ "required": ["document", "depth", "evidencePath"],
16
+ "properties": {
17
+ "document": { "$ref": "#/definitions/node" },
18
+ "depth": { "type": "integer", "minimum": 1, "maximum": 6 },
19
+ "evidencePath": {
20
+ "type": "array",
21
+ "minItems": 1,
22
+ "maxItems": 6,
23
+ "items": { "$ref": "#/definitions/step" }
24
+ }
25
+ },
26
+ "additionalProperties": false
27
+ }
28
+ },
29
+ "meta": {
30
+ "type": "object",
31
+ "required": [
32
+ "maxDepth",
33
+ "maxNodes",
34
+ "maxEdges",
35
+ "frontierLimit",
36
+ "visitedLimit",
37
+ "returnedNodes",
38
+ "returnedEdges",
39
+ "truncated",
40
+ "warnings"
41
+ ],
42
+ "properties": {
43
+ "maxDepth": { "type": "integer", "minimum": 1, "maximum": 6 },
44
+ "maxNodes": { "type": "integer", "minimum": 1, "maximum": 1000 },
45
+ "maxEdges": { "type": "integer", "minimum": 1, "maximum": 5000 },
46
+ "frontierLimit": {
47
+ "type": "integer",
48
+ "minimum": 1,
49
+ "maximum": 1000
50
+ },
51
+ "visitedLimit": {
52
+ "type": "integer",
53
+ "minimum": 1,
54
+ "maximum": 5000
55
+ },
56
+ "returnedNodes": {
57
+ "type": "integer",
58
+ "minimum": 1,
59
+ "maximum": 1000
60
+ },
61
+ "returnedEdges": {
62
+ "type": "integer",
63
+ "minimum": 0,
64
+ "maximum": 5000
65
+ },
66
+ "truncated": { "type": "boolean" },
67
+ "warnings": { "type": "array", "items": { "type": "string" } }
68
+ },
69
+ "additionalProperties": false
70
+ }
71
+ },
72
+ "additionalProperties": false,
73
+ "definitions": {
74
+ "node": {
75
+ "type": "object",
76
+ "required": ["id", "uri", "title", "collection", "relPath"],
77
+ "properties": {
78
+ "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
79
+ "uri": { "type": "string", "pattern": "^gno://.+" },
80
+ "title": { "type": ["string", "null"] },
81
+ "collection": { "type": "string" },
82
+ "relPath": { "type": "string" }
83
+ },
84
+ "additionalProperties": false
85
+ },
86
+ "endpoint": {
87
+ "type": "object",
88
+ "required": ["id", "uri"],
89
+ "properties": {
90
+ "id": { "type": "string", "pattern": "^#[a-f0-9]{6,}$" },
91
+ "uri": { "type": "string", "pattern": "^gno://.+" }
92
+ },
93
+ "additionalProperties": false
94
+ },
95
+ "step": {
96
+ "type": "object",
97
+ "required": [
98
+ "source",
99
+ "target",
100
+ "edgeType",
101
+ "relationType",
102
+ "confidence",
103
+ "edgeSource"
104
+ ],
105
+ "properties": {
106
+ "source": { "$ref": "#/definitions/endpoint" },
107
+ "target": { "$ref": "#/definitions/endpoint" },
108
+ "edgeType": { "type": "string", "minLength": 1 },
109
+ "relationType": { "type": "string", "minLength": 1 },
110
+ "confidence": {
111
+ "type": "string",
112
+ "enum": ["parsed", "configured", "manual", "inferred"]
113
+ },
114
+ "edgeSource": {
115
+ "type": "string",
116
+ "enum": ["wikilink", "markdown-link", "frontmatter-relation"]
117
+ }
118
+ },
119
+ "additionalProperties": false
120
+ }
121
+ }
122
+ }