@gmickel/gno 1.30.7 → 1.32.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 (71) hide show
  1. package/README.md +6 -5
  2. package/assets/skill/SKILL.md +25 -0
  3. package/assets/skill/mcp-reference.md +6 -0
  4. package/browser-extension/artifacts/{gno-browser-clipper-v1.30.7.zip → gno-browser-clipper-v1.32.0.zip} +0 -0
  5. package/browser-extension/artifacts/gno-browser-clipper-v1.32.0.zip.sha256 +1 -0
  6. package/browser-extension/dist/manifest.json +1 -1
  7. package/package.json +1 -1
  8. package/spec/cli.md +19 -0
  9. package/spec/db/schema.sql +55 -0
  10. package/spec/mcp.md +176 -11
  11. package/spec/output-schemas/file-refactor-apply-result.schema.json +305 -0
  12. package/spec/output-schemas/file-refactor-preview.schema.json +393 -0
  13. package/spec/output-schemas/section-target-create-result.schema.json +20 -0
  14. package/spec/output-schemas/section-target-resolve-result.schema.json +194 -0
  15. package/spec/output-schemas/section-target.schema.json +118 -0
  16. package/spec/output-schemas/section.schema.json +113 -0
  17. package/src/core/document-capabilities.ts +13 -0
  18. package/src/core/file-ops.ts +129 -1
  19. package/src/core/file-refactor-adapter.ts +329 -0
  20. package/src/core/file-refactor-apply-edits.ts +61 -0
  21. package/src/core/file-refactor-apply-fs.ts +512 -0
  22. package/src/core/file-refactor-apply-safety.ts +340 -0
  23. package/src/core/file-refactor-apply-validate.ts +401 -0
  24. package/src/core/file-refactor-contract.ts +486 -0
  25. package/src/core/file-refactor-destination.ts +123 -0
  26. package/src/core/file-refactor-from-snapshot.ts +148 -0
  27. package/src/core/file-refactor-journal-port.ts +150 -0
  28. package/src/core/file-refactor-journal.ts +347 -0
  29. package/src/core/file-refactor-paths.ts +60 -0
  30. package/src/core/file-refactor-plan-classify.ts +208 -0
  31. package/src/core/file-refactor-plan-validate.ts +169 -0
  32. package/src/core/file-refactor-planner-types.ts +62 -0
  33. package/src/core/file-refactor-planner.ts +423 -0
  34. package/src/core/file-refactor-resolve.ts +280 -0
  35. package/src/core/file-refactor-service.ts +468 -0
  36. package/src/core/file-refactors.ts +84 -56
  37. package/src/core/link-destination-parse.ts +275 -0
  38. package/src/core/link-inventory-markdown.ts +454 -0
  39. package/src/core/link-inventory-opaque.ts +244 -0
  40. package/src/core/link-inventory-types.ts +47 -0
  41. package/src/core/link-inventory.ts +182 -0
  42. package/src/core/link-relevance.ts +150 -0
  43. package/src/core/section-parse.ts +187 -0
  44. package/src/core/section-target-link.ts +154 -0
  45. package/src/core/section-target-resolve.ts +351 -0
  46. package/src/core/section-target-transport.ts +519 -0
  47. package/src/core/section-target.ts +263 -0
  48. package/src/core/sections.ts +60 -115
  49. package/src/mcp/AGENTS.md +1 -0
  50. package/src/mcp/CLAUDE.md +1 -0
  51. package/src/mcp/http-egress.ts +1 -0
  52. package/src/mcp/tools/index.ts +37 -17
  53. package/src/mcp/tools/sections.ts +512 -0
  54. package/src/mcp/tools/workspace-write.ts +215 -97
  55. package/src/sdk/client.ts +238 -116
  56. package/src/sdk/index.ts +12 -0
  57. package/src/sdk/types.ts +61 -3
  58. package/src/serve/file-refactor-http.ts +239 -0
  59. package/src/serve/public/components/RefactorImpactPreview.tsx +227 -0
  60. package/src/serve/public/globals.built.css +1 -1
  61. package/src/serve/public/lib/section-links.ts +189 -0
  62. package/src/serve/public/pages/DocView.tsx +395 -77
  63. package/src/serve/routes/api.ts +191 -104
  64. package/src/serve/routes/section-targets.ts +221 -0
  65. package/src/serve/server.ts +34 -0
  66. package/src/store/migrations/026-file-refactor-recovery-journal.ts +72 -0
  67. package/src/store/migrations/index.ts +2 -0
  68. package/src/store/sqlite/adapter.ts +452 -0
  69. package/src/store/sqlite/file-refactor-journal-store.ts +275 -0
  70. package/src/store/types.ts +84 -0
  71. package/browser-extension/artifacts/gno-browser-clipper-v1.30.7.zip.sha256 +0 -1
@@ -0,0 +1,305 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/file-refactor-apply-result@1.0",
4
+ "title": "GNO File Refactor Apply Result",
5
+ "description": "Terminal result for reference-safe rename/move apply. Filesystem commit/rollback is modeled separately from post-commit index convergence; recovery metadata is content-free. Status discriminates valid filesystem/index/reason combinations.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "status",
11
+ "planDigest",
12
+ "operation",
13
+ "source",
14
+ "target",
15
+ "filesystem",
16
+ "indexConvergence"
17
+ ],
18
+ "properties": {
19
+ "schemaVersion": {
20
+ "const": "1.0"
21
+ },
22
+ "status": {
23
+ "type": "string",
24
+ "enum": [
25
+ "applied",
26
+ "applied_with_sync_pending",
27
+ "conflict",
28
+ "stale_plan",
29
+ "unsupported",
30
+ "failed_rolled_back"
31
+ ]
32
+ },
33
+ "planDigest": {
34
+ "type": "string",
35
+ "pattern": "^[a-f0-9]{64}$"
36
+ },
37
+ "operation": {
38
+ "type": "string",
39
+ "enum": ["rename", "move"]
40
+ },
41
+ "source": {
42
+ "$ref": "#/definitions/documentRef"
43
+ },
44
+ "target": {
45
+ "$ref": "#/definitions/documentRef"
46
+ },
47
+ "reasonCode": {
48
+ "$ref": "#/definitions/reasonCode"
49
+ },
50
+ "filesystem": {
51
+ "type": "object",
52
+ "additionalProperties": false,
53
+ "required": ["state"],
54
+ "properties": {
55
+ "state": {
56
+ "type": "string",
57
+ "enum": ["committed", "rolled_back", "unchanged", "recovery_required"]
58
+ },
59
+ "recoveryJournalId": {
60
+ "type": "string",
61
+ "minLength": 1,
62
+ "maxLength": 128,
63
+ "description": "Opaque journal id only — never embeds note content"
64
+ }
65
+ }
66
+ },
67
+ "indexConvergence": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "required": ["state"],
71
+ "properties": {
72
+ "state": {
73
+ "type": "string",
74
+ "enum": ["converged", "pending", "not_attempted", "skipped"]
75
+ },
76
+ "recoveryInstruction": {
77
+ "type": "string",
78
+ "minLength": 1,
79
+ "maxLength": 512,
80
+ "description": "Content-free instruction to finish index convergence"
81
+ }
82
+ }
83
+ }
84
+ },
85
+ "definitions": {
86
+ "documentRef": {
87
+ "type": "object",
88
+ "additionalProperties": false,
89
+ "required": ["uri", "relPath", "collection"],
90
+ "properties": {
91
+ "uri": {
92
+ "type": "string",
93
+ "minLength": 1,
94
+ "maxLength": 1024
95
+ },
96
+ "relPath": {
97
+ "type": "string",
98
+ "minLength": 1,
99
+ "maxLength": 1024
100
+ },
101
+ "collection": {
102
+ "type": "string",
103
+ "minLength": 1,
104
+ "maxLength": 256
105
+ }
106
+ }
107
+ },
108
+ "reasonCode": {
109
+ "type": "string",
110
+ "enum": [
111
+ "ambiguous_resolution",
112
+ "unsupported_syntax",
113
+ "malformed_syntax",
114
+ "stale_plan",
115
+ "capability_denied",
116
+ "occupied_target",
117
+ "sync_pending",
118
+ "cross_collection_unsupported",
119
+ "unsafe_target",
120
+ "external_destination",
121
+ "code_fence_context",
122
+ "inline_code_context",
123
+ "html_context",
124
+ "duplicate_basename_ambiguity",
125
+ "unicode_normalization_mismatch",
126
+ "destination_unchanged",
127
+ "read_only_document",
128
+ "relative_path_recalculated",
129
+ "reference_definition_site",
130
+ "filesystem_commit_failed",
131
+ "rollback_recovery_required"
132
+ ]
133
+ }
134
+ },
135
+ "allOf": [
136
+ {
137
+ "if": {
138
+ "type": "object",
139
+ "properties": {
140
+ "status": {
141
+ "const": "applied"
142
+ }
143
+ },
144
+ "required": ["status"]
145
+ },
146
+ "then": {
147
+ "type": "object",
148
+ "properties": {
149
+ "reasonCode": false,
150
+ "filesystem": {
151
+ "type": "object",
152
+ "properties": {
153
+ "state": {
154
+ "const": "committed"
155
+ }
156
+ }
157
+ },
158
+ "indexConvergence": {
159
+ "type": "object",
160
+ "additionalProperties": false,
161
+ "required": ["state"],
162
+ "properties": {
163
+ "state": {
164
+ "const": "converged"
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ },
171
+ {
172
+ "if": {
173
+ "type": "object",
174
+ "properties": {
175
+ "status": {
176
+ "const": "applied_with_sync_pending"
177
+ }
178
+ },
179
+ "required": ["status"]
180
+ },
181
+ "then": {
182
+ "type": "object",
183
+ "required": ["reasonCode"],
184
+ "properties": {
185
+ "reasonCode": {
186
+ "const": "sync_pending"
187
+ },
188
+ "filesystem": {
189
+ "type": "object",
190
+ "properties": {
191
+ "state": {
192
+ "const": "committed"
193
+ }
194
+ }
195
+ },
196
+ "indexConvergence": {
197
+ "type": "object",
198
+ "additionalProperties": false,
199
+ "required": ["state", "recoveryInstruction"],
200
+ "properties": {
201
+ "state": {
202
+ "const": "pending"
203
+ },
204
+ "recoveryInstruction": {
205
+ "type": "string",
206
+ "minLength": 1,
207
+ "maxLength": 512
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ },
214
+ {
215
+ "if": {
216
+ "type": "object",
217
+ "properties": {
218
+ "status": {
219
+ "enum": ["conflict", "stale_plan", "unsupported"]
220
+ }
221
+ },
222
+ "required": ["status"]
223
+ },
224
+ "then": {
225
+ "type": "object",
226
+ "required": ["reasonCode"],
227
+ "properties": {
228
+ "filesystem": {
229
+ "type": "object",
230
+ "properties": {
231
+ "state": {
232
+ "const": "unchanged"
233
+ }
234
+ }
235
+ },
236
+ "indexConvergence": {
237
+ "type": "object",
238
+ "additionalProperties": false,
239
+ "required": ["state"],
240
+ "properties": {
241
+ "state": {
242
+ "enum": ["not_attempted", "skipped"]
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ },
249
+ {
250
+ "if": {
251
+ "type": "object",
252
+ "properties": {
253
+ "status": {
254
+ "const": "stale_plan"
255
+ }
256
+ },
257
+ "required": ["status"]
258
+ },
259
+ "then": {
260
+ "type": "object",
261
+ "required": ["reasonCode"],
262
+ "properties": {
263
+ "reasonCode": {
264
+ "const": "stale_plan"
265
+ }
266
+ }
267
+ }
268
+ },
269
+ {
270
+ "if": {
271
+ "type": "object",
272
+ "properties": {
273
+ "status": {
274
+ "const": "failed_rolled_back"
275
+ }
276
+ },
277
+ "required": ["status"]
278
+ },
279
+ "then": {
280
+ "type": "object",
281
+ "required": ["reasonCode"],
282
+ "properties": {
283
+ "filesystem": {
284
+ "type": "object",
285
+ "properties": {
286
+ "state": {
287
+ "enum": ["rolled_back", "recovery_required"]
288
+ }
289
+ }
290
+ },
291
+ "indexConvergence": {
292
+ "type": "object",
293
+ "additionalProperties": false,
294
+ "required": ["state"],
295
+ "properties": {
296
+ "state": {
297
+ "enum": ["not_attempted", "skipped"]
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ ]
305
+ }
@@ -0,0 +1,393 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "gno://schemas/file-refactor-preview@1.0",
4
+ "title": "GNO File Refactor Preview Plan",
5
+ "description": "Transport-neutral, versioned preview plan for reference-safe rename and same-collection move. Destination-only edit spans; filesystem atomicity is separate from post-commit index convergence.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "schemaVersion",
10
+ "operation",
11
+ "conflictPolicy",
12
+ "source",
13
+ "target",
14
+ "affectedDocuments",
15
+ "examinedReferences",
16
+ "preconditions",
17
+ "planDigest",
18
+ "safety",
19
+ "canApply",
20
+ "mutationBoundary"
21
+ ],
22
+ "properties": {
23
+ "schemaVersion": {
24
+ "const": "1.0"
25
+ },
26
+ "operation": {
27
+ "type": "string",
28
+ "enum": ["rename", "move"]
29
+ },
30
+ "conflictPolicy": {
31
+ "type": "string",
32
+ "enum": ["fail"]
33
+ },
34
+ "source": {
35
+ "$ref": "#/definitions/documentRef"
36
+ },
37
+ "target": {
38
+ "$ref": "#/definitions/documentRef"
39
+ },
40
+ "affectedDocuments": {
41
+ "type": "array",
42
+ "maxItems": 10000,
43
+ "items": {
44
+ "$ref": "#/definitions/affectedDocument"
45
+ }
46
+ },
47
+ "examinedReferences": {
48
+ "type": "array",
49
+ "maxItems": 100000,
50
+ "items": {
51
+ "$ref": "#/definitions/examinedReference"
52
+ }
53
+ },
54
+ "preconditions": {
55
+ "$ref": "#/definitions/preconditions"
56
+ },
57
+ "planDigest": {
58
+ "$ref": "#/definitions/sha256"
59
+ },
60
+ "safety": {
61
+ "$ref": "#/definitions/safetySummary"
62
+ },
63
+ "canApply": {
64
+ "type": "boolean"
65
+ },
66
+ "mutationBoundary": {
67
+ "$ref": "#/definitions/mutationBoundary"
68
+ }
69
+ },
70
+ "definitions": {
71
+ "sha256": {
72
+ "type": "string",
73
+ "pattern": "^[a-f0-9]{64}$"
74
+ },
75
+ "reasonCode": {
76
+ "type": "string",
77
+ "enum": [
78
+ "ambiguous_resolution",
79
+ "unsupported_syntax",
80
+ "malformed_syntax",
81
+ "stale_plan",
82
+ "capability_denied",
83
+ "occupied_target",
84
+ "sync_pending",
85
+ "cross_collection_unsupported",
86
+ "unsafe_target",
87
+ "external_destination",
88
+ "code_fence_context",
89
+ "inline_code_context",
90
+ "html_context",
91
+ "duplicate_basename_ambiguity",
92
+ "unicode_normalization_mismatch",
93
+ "destination_unchanged",
94
+ "read_only_document",
95
+ "relative_path_recalculated",
96
+ "reference_definition_site",
97
+ "filesystem_commit_failed",
98
+ "rollback_recovery_required"
99
+ ]
100
+ },
101
+ "documentRef": {
102
+ "type": "object",
103
+ "additionalProperties": false,
104
+ "required": ["uri", "relPath", "collection"],
105
+ "properties": {
106
+ "uri": {
107
+ "type": "string",
108
+ "minLength": 1,
109
+ "maxLength": 1024
110
+ },
111
+ "relPath": {
112
+ "type": "string",
113
+ "minLength": 1,
114
+ "maxLength": 1024
115
+ },
116
+ "collection": {
117
+ "type": "string",
118
+ "minLength": 1,
119
+ "maxLength": 256
120
+ }
121
+ }
122
+ },
123
+ "destinationSpan": {
124
+ "type": "object",
125
+ "additionalProperties": false,
126
+ "required": [
127
+ "coordinateSpace",
128
+ "startOffset",
129
+ "endOffset",
130
+ "originalDestination",
131
+ "replacementDestination"
132
+ ],
133
+ "properties": {
134
+ "coordinateSpace": {
135
+ "const": "utf16_code_units"
136
+ },
137
+ "startOffset": {
138
+ "type": "integer",
139
+ "minimum": 0,
140
+ "maximum": 9007199254740991
141
+ },
142
+ "endOffset": {
143
+ "type": "integer",
144
+ "minimum": 0,
145
+ "maximum": 9007199254740991
146
+ },
147
+ "originalDestination": {
148
+ "type": "string",
149
+ "maxLength": 4096
150
+ },
151
+ "replacementDestination": {
152
+ "type": "string",
153
+ "maxLength": 4096
154
+ }
155
+ }
156
+ },
157
+ "examinedReference": {
158
+ "type": "object",
159
+ "additionalProperties": false,
160
+ "required": ["documentUri", "documentRelPath", "kind", "classification"],
161
+ "properties": {
162
+ "documentUri": {
163
+ "type": "string",
164
+ "minLength": 1,
165
+ "maxLength": 1024
166
+ },
167
+ "documentRelPath": {
168
+ "type": "string",
169
+ "minLength": 1,
170
+ "maxLength": 1024
171
+ },
172
+ "kind": {
173
+ "type": "string",
174
+ "enum": ["wiki", "markdown", "markdown_definition", "opaque"]
175
+ },
176
+ "classification": {
177
+ "type": "string",
178
+ "enum": [
179
+ "rewriteable",
180
+ "unchanged",
181
+ "ambiguous",
182
+ "unsupported",
183
+ "malformed",
184
+ "invalid"
185
+ ]
186
+ },
187
+ "reasonCode": {
188
+ "$ref": "#/definitions/reasonCode"
189
+ },
190
+ "originalDestination": {
191
+ "type": "string",
192
+ "maxLength": 4096
193
+ },
194
+ "proposedDestination": {
195
+ "type": "string",
196
+ "maxLength": 4096
197
+ },
198
+ "edit": {
199
+ "$ref": "#/definitions/destinationSpan"
200
+ },
201
+ "startLine": {
202
+ "type": "integer",
203
+ "minimum": 1,
204
+ "maximum": 9007199254740991
205
+ },
206
+ "startCol": {
207
+ "type": "integer",
208
+ "minimum": 1,
209
+ "maximum": 9007199254740991
210
+ },
211
+ "endLine": {
212
+ "type": "integer",
213
+ "minimum": 1,
214
+ "maximum": 9007199254740991
215
+ },
216
+ "endCol": {
217
+ "type": "integer",
218
+ "minimum": 1,
219
+ "maximum": 9007199254740991
220
+ }
221
+ }
222
+ },
223
+ "affectedDocument": {
224
+ "type": "object",
225
+ "additionalProperties": false,
226
+ "required": ["uri", "relPath", "contentFingerprint", "edits", "examined"],
227
+ "properties": {
228
+ "uri": {
229
+ "type": "string",
230
+ "minLength": 1,
231
+ "maxLength": 1024
232
+ },
233
+ "relPath": {
234
+ "type": "string",
235
+ "minLength": 1,
236
+ "maxLength": 1024
237
+ },
238
+ "contentFingerprint": {
239
+ "$ref": "#/definitions/sha256"
240
+ },
241
+ "edits": {
242
+ "type": "array",
243
+ "maxItems": 10000,
244
+ "items": {
245
+ "$ref": "#/definitions/destinationSpan"
246
+ }
247
+ },
248
+ "examined": {
249
+ "type": "array",
250
+ "maxItems": 100000,
251
+ "items": {
252
+ "$ref": "#/definitions/examinedReference"
253
+ }
254
+ }
255
+ }
256
+ },
257
+ "preconditions": {
258
+ "type": "object",
259
+ "additionalProperties": false,
260
+ "required": [
261
+ "sourceContentFingerprint",
262
+ "affectedContentFingerprints",
263
+ "targetPathFingerprint"
264
+ ],
265
+ "properties": {
266
+ "sourceContentFingerprint": {
267
+ "$ref": "#/definitions/sha256"
268
+ },
269
+ "affectedContentFingerprints": {
270
+ "type": "array",
271
+ "maxItems": 10000,
272
+ "items": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": ["uri", "fingerprint"],
276
+ "properties": {
277
+ "uri": {
278
+ "type": "string",
279
+ "minLength": 1,
280
+ "maxLength": 1024
281
+ },
282
+ "fingerprint": {
283
+ "$ref": "#/definitions/sha256"
284
+ }
285
+ }
286
+ }
287
+ },
288
+ "targetPathFingerprint": {
289
+ "$ref": "#/definitions/sha256"
290
+ }
291
+ }
292
+ },
293
+ "safetySummary": {
294
+ "type": "object",
295
+ "additionalProperties": false,
296
+ "required": [
297
+ "rewriteableCount",
298
+ "unchangedCount",
299
+ "ambiguousCount",
300
+ "unsupportedCount",
301
+ "malformedCount",
302
+ "invalidCount",
303
+ "blockingReasonCodes",
304
+ "warnings",
305
+ "backlinkCount",
306
+ "wikiLinkCount",
307
+ "markdownLinkCount"
308
+ ],
309
+ "properties": {
310
+ "rewriteableCount": {
311
+ "type": "integer",
312
+ "minimum": 0,
313
+ "maximum": 9007199254740991
314
+ },
315
+ "unchangedCount": {
316
+ "type": "integer",
317
+ "minimum": 0,
318
+ "maximum": 9007199254740991
319
+ },
320
+ "ambiguousCount": {
321
+ "type": "integer",
322
+ "minimum": 0,
323
+ "maximum": 9007199254740991
324
+ },
325
+ "unsupportedCount": {
326
+ "type": "integer",
327
+ "minimum": 0,
328
+ "maximum": 9007199254740991
329
+ },
330
+ "malformedCount": {
331
+ "type": "integer",
332
+ "minimum": 0,
333
+ "maximum": 9007199254740991
334
+ },
335
+ "invalidCount": {
336
+ "type": "integer",
337
+ "minimum": 0,
338
+ "maximum": 9007199254740991
339
+ },
340
+ "blockingReasonCodes": {
341
+ "type": "array",
342
+ "maxItems": 64,
343
+ "items": {
344
+ "$ref": "#/definitions/reasonCode"
345
+ }
346
+ },
347
+ "warnings": {
348
+ "type": "array",
349
+ "maxItems": 64,
350
+ "items": {
351
+ "type": "string",
352
+ "maxLength": 512
353
+ }
354
+ },
355
+ "backlinkCount": {
356
+ "type": "integer",
357
+ "minimum": 0,
358
+ "maximum": 9007199254740991
359
+ },
360
+ "wikiLinkCount": {
361
+ "type": "integer",
362
+ "minimum": 0,
363
+ "maximum": 9007199254740991
364
+ },
365
+ "markdownLinkCount": {
366
+ "type": "integer",
367
+ "minimum": 0,
368
+ "maximum": 9007199254740991
369
+ }
370
+ }
371
+ },
372
+ "mutationBoundary": {
373
+ "type": "object",
374
+ "additionalProperties": false,
375
+ "required": [
376
+ "filesystemCommit",
377
+ "indexConvergence",
378
+ "syncFailureDoesNotRollbackFilesystem"
379
+ ],
380
+ "properties": {
381
+ "filesystemCommit": {
382
+ "const": "atomic_all_or_rollback"
383
+ },
384
+ "indexConvergence": {
385
+ "const": "post_commit_separate"
386
+ },
387
+ "syncFailureDoesNotRollbackFilesystem": {
388
+ "const": true
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }