sysprom 1.0.0 → 1.0.6

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 (148) hide show
  1. package/README.md +207 -0
  2. package/dist/schema.json +510 -0
  3. package/dist/src/canonical-json.d.ts +23 -0
  4. package/dist/src/canonical-json.js +120 -0
  5. package/dist/src/cli/commands/add.d.ts +22 -0
  6. package/dist/src/cli/commands/add.js +95 -0
  7. package/dist/src/cli/commands/check.d.ts +10 -0
  8. package/dist/src/cli/commands/check.js +33 -0
  9. package/dist/src/cli/commands/graph.d.ts +15 -0
  10. package/dist/src/cli/commands/graph.js +32 -0
  11. package/dist/src/cli/commands/init.d.ts +2 -0
  12. package/dist/src/cli/commands/init.js +44 -0
  13. package/dist/src/cli/commands/json2md.d.ts +2 -0
  14. package/dist/src/cli/commands/json2md.js +60 -0
  15. package/dist/src/cli/commands/md2json.d.ts +2 -0
  16. package/dist/src/cli/commands/md2json.js +29 -0
  17. package/dist/src/cli/commands/plan.d.ts +2 -0
  18. package/dist/src/cli/commands/plan.js +227 -0
  19. package/dist/src/cli/commands/query.d.ts +2 -0
  20. package/dist/src/cli/commands/query.js +275 -0
  21. package/dist/src/cli/commands/remove.d.ts +13 -0
  22. package/dist/src/cli/commands/remove.js +50 -0
  23. package/dist/src/cli/commands/rename.d.ts +14 -0
  24. package/dist/src/cli/commands/rename.js +34 -0
  25. package/dist/src/cli/commands/search.d.ts +11 -0
  26. package/dist/src/cli/commands/search.js +37 -0
  27. package/dist/src/cli/commands/speckit.d.ts +2 -0
  28. package/dist/src/cli/commands/speckit.js +318 -0
  29. package/dist/src/cli/commands/stats.d.ts +10 -0
  30. package/dist/src/cli/commands/stats.js +51 -0
  31. package/dist/src/cli/commands/task.d.ts +2 -0
  32. package/dist/src/cli/commands/task.js +162 -0
  33. package/dist/src/cli/commands/update.d.ts +2 -0
  34. package/dist/src/cli/commands/update.js +219 -0
  35. package/dist/src/cli/commands/validate.d.ts +10 -0
  36. package/dist/src/cli/commands/validate.js +30 -0
  37. package/dist/src/cli/define-command.d.ts +34 -0
  38. package/dist/src/cli/define-command.js +237 -0
  39. package/dist/src/cli/index.d.ts +2 -0
  40. package/dist/src/cli/index.js +3 -0
  41. package/dist/src/cli/program.d.ts +4 -0
  42. package/dist/src/cli/program.js +46 -0
  43. package/dist/src/cli/shared.d.ts +26 -0
  44. package/dist/src/cli/shared.js +41 -0
  45. package/dist/src/generate-schema.d.ts +1 -0
  46. package/dist/src/generate-schema.js +9 -0
  47. package/dist/src/index.d.ts +48 -0
  48. package/dist/src/index.js +99 -0
  49. package/dist/src/io.d.ts +22 -0
  50. package/dist/src/io.js +66 -0
  51. package/dist/src/json-to-md.d.ts +26 -0
  52. package/dist/src/json-to-md.js +498 -0
  53. package/dist/src/md-to-json.d.ts +22 -0
  54. package/dist/src/md-to-json.js +548 -0
  55. package/dist/src/operations/add-node.d.ts +887 -0
  56. package/dist/src/operations/add-node.js +21 -0
  57. package/dist/src/operations/add-plan-task.d.ts +594 -0
  58. package/dist/src/operations/add-plan-task.js +25 -0
  59. package/dist/src/operations/add-relationship.d.ts +635 -0
  60. package/dist/src/operations/add-relationship.js +25 -0
  61. package/dist/src/operations/check.d.ts +301 -0
  62. package/dist/src/operations/check.js +66 -0
  63. package/dist/src/operations/define-operation.d.ts +14 -0
  64. package/dist/src/operations/define-operation.js +21 -0
  65. package/dist/src/operations/graph.d.ts +303 -0
  66. package/dist/src/operations/graph.js +71 -0
  67. package/dist/src/operations/index.d.ts +38 -0
  68. package/dist/src/operations/index.js +45 -0
  69. package/dist/src/operations/init-document.d.ts +299 -0
  70. package/dist/src/operations/init-document.js +26 -0
  71. package/dist/src/operations/json-to-markdown.d.ts +298 -0
  72. package/dist/src/operations/json-to-markdown.js +13 -0
  73. package/dist/src/operations/mark-task-done.d.ts +594 -0
  74. package/dist/src/operations/mark-task-done.js +26 -0
  75. package/dist/src/operations/mark-task-undone.d.ts +594 -0
  76. package/dist/src/operations/mark-task-undone.js +26 -0
  77. package/dist/src/operations/markdown-to-json.d.ts +298 -0
  78. package/dist/src/operations/markdown-to-json.js +13 -0
  79. package/dist/src/operations/next-id.d.ts +322 -0
  80. package/dist/src/operations/next-id.js +29 -0
  81. package/dist/src/operations/node-history.d.ts +313 -0
  82. package/dist/src/operations/node-history.js +55 -0
  83. package/dist/src/operations/plan-add-task.d.ts +595 -0
  84. package/dist/src/operations/plan-add-task.js +18 -0
  85. package/dist/src/operations/plan-gate.d.ts +351 -0
  86. package/dist/src/operations/plan-gate.js +41 -0
  87. package/dist/src/operations/plan-init.d.ts +299 -0
  88. package/dist/src/operations/plan-init.js +17 -0
  89. package/dist/src/operations/plan-progress.d.ts +313 -0
  90. package/dist/src/operations/plan-progress.js +23 -0
  91. package/dist/src/operations/plan-status.d.ts +349 -0
  92. package/dist/src/operations/plan-status.js +41 -0
  93. package/dist/src/operations/query-node.d.ts +1065 -0
  94. package/dist/src/operations/query-node.js +27 -0
  95. package/dist/src/operations/query-nodes.d.ts +594 -0
  96. package/dist/src/operations/query-nodes.js +23 -0
  97. package/dist/src/operations/query-relationships.d.ts +343 -0
  98. package/dist/src/operations/query-relationships.js +27 -0
  99. package/dist/src/operations/remove-node.d.ts +895 -0
  100. package/dist/src/operations/remove-node.js +58 -0
  101. package/dist/src/operations/remove-relationship.d.ts +622 -0
  102. package/dist/src/operations/remove-relationship.js +26 -0
  103. package/dist/src/operations/rename.d.ts +594 -0
  104. package/dist/src/operations/rename.js +113 -0
  105. package/dist/src/operations/search.d.ts +593 -0
  106. package/dist/src/operations/search.js +39 -0
  107. package/dist/src/operations/speckit-diff.d.ts +330 -0
  108. package/dist/src/operations/speckit-diff.js +89 -0
  109. package/dist/src/operations/speckit-export.d.ts +300 -0
  110. package/dist/src/operations/speckit-export.js +17 -0
  111. package/dist/src/operations/speckit-import.d.ts +299 -0
  112. package/dist/src/operations/speckit-import.js +39 -0
  113. package/dist/src/operations/speckit-sync.d.ts +900 -0
  114. package/dist/src/operations/speckit-sync.js +116 -0
  115. package/dist/src/operations/state-at.d.ts +309 -0
  116. package/dist/src/operations/state-at.js +53 -0
  117. package/dist/src/operations/stats.d.ts +324 -0
  118. package/dist/src/operations/stats.js +85 -0
  119. package/dist/src/operations/task-list.d.ts +305 -0
  120. package/dist/src/operations/task-list.js +44 -0
  121. package/dist/src/operations/timeline.d.ts +312 -0
  122. package/dist/src/operations/timeline.js +46 -0
  123. package/dist/src/operations/trace-from-node.d.ts +1197 -0
  124. package/dist/src/operations/trace-from-node.js +36 -0
  125. package/dist/src/operations/update-metadata.d.ts +593 -0
  126. package/dist/src/operations/update-metadata.js +18 -0
  127. package/dist/src/operations/update-node.d.ts +957 -0
  128. package/dist/src/operations/update-node.js +24 -0
  129. package/dist/src/operations/update-plan-task.d.ts +595 -0
  130. package/dist/src/operations/update-plan-task.js +31 -0
  131. package/dist/src/operations/validate.d.ts +310 -0
  132. package/dist/src/operations/validate.js +82 -0
  133. package/dist/src/schema.d.ts +891 -0
  134. package/dist/src/schema.js +356 -0
  135. package/dist/src/speckit/generate.d.ts +7 -0
  136. package/dist/src/speckit/generate.js +546 -0
  137. package/dist/src/speckit/index.d.ts +4 -0
  138. package/dist/src/speckit/index.js +4 -0
  139. package/dist/src/speckit/parse.d.ts +11 -0
  140. package/dist/src/speckit/parse.js +712 -0
  141. package/dist/src/speckit/plan.d.ts +125 -0
  142. package/dist/src/speckit/plan.js +636 -0
  143. package/dist/src/speckit/project.d.ts +39 -0
  144. package/dist/src/speckit/project.js +141 -0
  145. package/dist/src/text.d.ts +23 -0
  146. package/dist/src/text.js +32 -0
  147. package/package.json +86 -8
  148. package/schema.json +510 -0
@@ -0,0 +1,510 @@
1
+ {
2
+ "$id": "https://sysprom.org/schema.json",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "additionalProperties": false,
5
+ "description": "JSON Schema for SysProM — a recursive, decision-driven model for recording system provenance.",
6
+ "id": "SysProM",
7
+ "properties": {
8
+ "$schema": {
9
+ "description": "Schema URI for self-identification.",
10
+ "type": "string"
11
+ },
12
+ "external_references": {
13
+ "description": "References to resources outside the graph, declared at system level.",
14
+ "items": {
15
+ "additionalProperties": false,
16
+ "description": "A reference to a resource outside the SysProM graph.",
17
+ "properties": {
18
+ "description": {
19
+ "anyOf": [
20
+ {
21
+ "type": "string"
22
+ },
23
+ {
24
+ "items": {
25
+ "type": "string"
26
+ },
27
+ "type": "array"
28
+ }
29
+ ]
30
+ },
31
+ "identifier": {
32
+ "description": "Serialisation-specific identifier (URI, file path, DOI, etc.).",
33
+ "type": "string"
34
+ },
35
+ "internalised": {
36
+ "anyOf": [
37
+ {
38
+ "type": "string"
39
+ },
40
+ {
41
+ "items": {
42
+ "type": "string"
43
+ },
44
+ "type": "array"
45
+ }
46
+ ],
47
+ "description": "Inline content captured from the external resource. When present, the node is self-contained and does not depend on the external identifier being resolvable."
48
+ },
49
+ "node_id": {
50
+ "description": "ID of the node this reference belongs to. Used when the reference is declared at graph level rather than inline on the node.",
51
+ "type": "string"
52
+ },
53
+ "role": {
54
+ "enum": [
55
+ "input",
56
+ "output",
57
+ "context",
58
+ "evidence",
59
+ "source",
60
+ "standard",
61
+ "prior_art"
62
+ ],
63
+ "type": "string"
64
+ }
65
+ },
66
+ "required": [
67
+ "role",
68
+ "identifier"
69
+ ],
70
+ "type": "object"
71
+ },
72
+ "type": "array"
73
+ },
74
+ "metadata": {
75
+ "additionalProperties": {},
76
+ "description": "Document-level metadata. Analogous to front matter in Markdown.",
77
+ "properties": {
78
+ "doc_type": {
79
+ "description": "Document type. Use 'sysprom' for the root entry point. Subsystems and features may use other values.",
80
+ "type": "string"
81
+ },
82
+ "scope": {
83
+ "description": "The scope of this document (e.g. system, feature, component).",
84
+ "type": "string"
85
+ },
86
+ "status": {
87
+ "type": "string"
88
+ },
89
+ "title": {
90
+ "type": "string"
91
+ },
92
+ "version": {
93
+ "anyOf": [
94
+ {
95
+ "type": "string"
96
+ },
97
+ {
98
+ "maximum": 9007199254740991,
99
+ "minimum": -9007199254740991,
100
+ "type": "integer"
101
+ }
102
+ ]
103
+ }
104
+ },
105
+ "type": "object"
106
+ },
107
+ "nodes": {
108
+ "description": "All nodes in the graph.",
109
+ "items": {
110
+ "additionalProperties": {},
111
+ "description": "A uniquely identifiable entity within the system.",
112
+ "properties": {
113
+ "context": {
114
+ "anyOf": [
115
+ {
116
+ "type": "string"
117
+ },
118
+ {
119
+ "items": {
120
+ "type": "string"
121
+ },
122
+ "type": "array"
123
+ }
124
+ ],
125
+ "description": "Background context explaining why this node exists or why a decision was needed."
126
+ },
127
+ "description": {
128
+ "anyOf": [
129
+ {
130
+ "type": "string"
131
+ },
132
+ {
133
+ "items": {
134
+ "type": "string"
135
+ },
136
+ "type": "array"
137
+ }
138
+ ]
139
+ },
140
+ "external_references": {
141
+ "description": "External resources related to this node.",
142
+ "items": {
143
+ "additionalProperties": false,
144
+ "description": "A reference to a resource outside the SysProM graph.",
145
+ "properties": {
146
+ "description": {
147
+ "anyOf": [
148
+ {
149
+ "type": "string"
150
+ },
151
+ {
152
+ "items": {
153
+ "type": "string"
154
+ },
155
+ "type": "array"
156
+ }
157
+ ]
158
+ },
159
+ "identifier": {
160
+ "description": "Serialisation-specific identifier (URI, file path, DOI, etc.).",
161
+ "type": "string"
162
+ },
163
+ "internalised": {
164
+ "anyOf": [
165
+ {
166
+ "type": "string"
167
+ },
168
+ {
169
+ "items": {
170
+ "type": "string"
171
+ },
172
+ "type": "array"
173
+ }
174
+ ],
175
+ "description": "Inline content captured from the external resource. When present, the node is self-contained and does not depend on the external identifier being resolvable."
176
+ },
177
+ "node_id": {
178
+ "description": "ID of the node this reference belongs to. Used when the reference is declared at graph level rather than inline on the node.",
179
+ "type": "string"
180
+ },
181
+ "role": {
182
+ "enum": [
183
+ "input",
184
+ "output",
185
+ "context",
186
+ "evidence",
187
+ "source",
188
+ "standard",
189
+ "prior_art"
190
+ ],
191
+ "type": "string"
192
+ }
193
+ },
194
+ "required": [
195
+ "role",
196
+ "identifier"
197
+ ],
198
+ "type": "object"
199
+ },
200
+ "type": "array"
201
+ },
202
+ "id": {
203
+ "description": "Unique identifier for this node.",
204
+ "type": "string"
205
+ },
206
+ "includes": {
207
+ "description": "IDs of nodes included in this projection. Applicable to view nodes.",
208
+ "items": {
209
+ "type": "string"
210
+ },
211
+ "type": "array"
212
+ },
213
+ "input": {
214
+ "description": "ID of the input artefact. Applicable to artefact_flow nodes.",
215
+ "type": "string"
216
+ },
217
+ "lifecycle": {
218
+ "additionalProperties": {
219
+ "anyOf": [
220
+ {
221
+ "type": "boolean"
222
+ },
223
+ {
224
+ "type": "string"
225
+ }
226
+ ]
227
+ },
228
+ "description": "Map of lifecycle state names to completion status. Values may be boolean or an ISO date string indicating when the state was reached.",
229
+ "propertyNames": {
230
+ "type": "string"
231
+ },
232
+ "type": "object"
233
+ },
234
+ "name": {
235
+ "description": "Human-readable name.",
236
+ "type": "string"
237
+ },
238
+ "operations": {
239
+ "description": "Operations performed. Applicable to change nodes.",
240
+ "items": {
241
+ "additionalProperties": {},
242
+ "description": "An atomic operation within a change.",
243
+ "properties": {
244
+ "description": {
245
+ "anyOf": [
246
+ {
247
+ "type": "string"
248
+ },
249
+ {
250
+ "items": {
251
+ "type": "string"
252
+ },
253
+ "type": "array"
254
+ }
255
+ ]
256
+ },
257
+ "target": {
258
+ "description": "ID of the affected node.",
259
+ "type": "string"
260
+ },
261
+ "type": {
262
+ "enum": [
263
+ "add",
264
+ "update",
265
+ "remove",
266
+ "link"
267
+ ],
268
+ "type": "string"
269
+ }
270
+ },
271
+ "required": [
272
+ "type"
273
+ ],
274
+ "type": "object"
275
+ },
276
+ "type": "array"
277
+ },
278
+ "options": {
279
+ "description": "Alternatives considered. Applicable to decision nodes.",
280
+ "items": {
281
+ "additionalProperties": {},
282
+ "description": "An alternative considered as part of a decision.",
283
+ "properties": {
284
+ "description": {
285
+ "anyOf": [
286
+ {
287
+ "type": "string"
288
+ },
289
+ {
290
+ "items": {
291
+ "type": "string"
292
+ },
293
+ "type": "array"
294
+ }
295
+ ]
296
+ },
297
+ "id": {
298
+ "type": "string"
299
+ }
300
+ },
301
+ "required": [
302
+ "id",
303
+ "description"
304
+ ],
305
+ "type": "object"
306
+ },
307
+ "type": "array"
308
+ },
309
+ "output": {
310
+ "description": "ID of the output artefact. Applicable to artefact_flow nodes.",
311
+ "type": "string"
312
+ },
313
+ "plan": {
314
+ "description": "Execution plan as a sequence of tasks. Applicable to change nodes.",
315
+ "items": {
316
+ "additionalProperties": {},
317
+ "description": "A single task within a change's execution plan.",
318
+ "properties": {
319
+ "description": {
320
+ "anyOf": [
321
+ {
322
+ "type": "string"
323
+ },
324
+ {
325
+ "items": {
326
+ "type": "string"
327
+ },
328
+ "type": "array"
329
+ }
330
+ ]
331
+ },
332
+ "done": {
333
+ "default": false,
334
+ "type": "boolean"
335
+ }
336
+ },
337
+ "required": [
338
+ "description"
339
+ ],
340
+ "type": "object"
341
+ },
342
+ "type": "array"
343
+ },
344
+ "propagation": {
345
+ "additionalProperties": {
346
+ "type": "boolean"
347
+ },
348
+ "description": "Layer propagation status. Applicable to change nodes.",
349
+ "propertyNames": {
350
+ "type": "string"
351
+ },
352
+ "type": "object"
353
+ },
354
+ "rationale": {
355
+ "anyOf": [
356
+ {
357
+ "type": "string"
358
+ },
359
+ {
360
+ "items": {
361
+ "type": "string"
362
+ },
363
+ "type": "array"
364
+ }
365
+ ],
366
+ "description": "Reasoning for the choice. Applicable to decision nodes."
367
+ },
368
+ "scope": {
369
+ "description": "IDs of nodes affected by this change. Applicable to change nodes.",
370
+ "items": {
371
+ "type": "string"
372
+ },
373
+ "type": "array"
374
+ },
375
+ "selected": {
376
+ "description": "ID of the chosen option. Applicable to decision nodes.",
377
+ "type": "string"
378
+ },
379
+ "status": {
380
+ "enum": [
381
+ "proposed",
382
+ "accepted",
383
+ "active",
384
+ "implemented",
385
+ "adopted",
386
+ "defined",
387
+ "introduced",
388
+ "in_progress",
389
+ "complete",
390
+ "consolidated",
391
+ "experimental",
392
+ "deprecated",
393
+ "retired",
394
+ "superseded",
395
+ "abandoned",
396
+ "deferred"
397
+ ],
398
+ "type": "string"
399
+ },
400
+ "subsystem": {
401
+ "$ref": "#"
402
+ },
403
+ "type": {
404
+ "enum": [
405
+ "intent",
406
+ "concept",
407
+ "capability",
408
+ "element",
409
+ "realisation",
410
+ "invariant",
411
+ "principle",
412
+ "policy",
413
+ "protocol",
414
+ "stage",
415
+ "role",
416
+ "gate",
417
+ "mode",
418
+ "artefact",
419
+ "artefact_flow",
420
+ "decision",
421
+ "change",
422
+ "view",
423
+ "milestone",
424
+ "version"
425
+ ],
426
+ "type": "string"
427
+ }
428
+ },
429
+ "required": [
430
+ "id",
431
+ "type",
432
+ "name"
433
+ ],
434
+ "type": "object"
435
+ },
436
+ "type": "array"
437
+ },
438
+ "relationships": {
439
+ "description": "Typed, directed connections between nodes.",
440
+ "items": {
441
+ "additionalProperties": {},
442
+ "description": "A typed, directed connection between two nodes.",
443
+ "properties": {
444
+ "description": {
445
+ "anyOf": [
446
+ {
447
+ "type": "string"
448
+ },
449
+ {
450
+ "items": {
451
+ "type": "string"
452
+ },
453
+ "type": "array"
454
+ }
455
+ ]
456
+ },
457
+ "from": {
458
+ "description": "Source node ID.",
459
+ "type": "string"
460
+ },
461
+ "to": {
462
+ "description": "Target node ID.",
463
+ "type": "string"
464
+ },
465
+ "type": {
466
+ "enum": [
467
+ "refines",
468
+ "realises",
469
+ "implements",
470
+ "depends_on",
471
+ "constrained_by",
472
+ "affects",
473
+ "supersedes",
474
+ "must_preserve",
475
+ "performs",
476
+ "part_of",
477
+ "precedes",
478
+ "must_follow",
479
+ "blocks",
480
+ "routes_to",
481
+ "governed_by",
482
+ "modifies",
483
+ "triggered_by",
484
+ "applies_to",
485
+ "produces",
486
+ "consumes",
487
+ "transforms_into",
488
+ "selects",
489
+ "requires",
490
+ "disables"
491
+ ],
492
+ "type": "string"
493
+ }
494
+ },
495
+ "required": [
496
+ "from",
497
+ "to",
498
+ "type"
499
+ ],
500
+ "type": "object"
501
+ },
502
+ "type": "array"
503
+ }
504
+ },
505
+ "required": [
506
+ "nodes"
507
+ ],
508
+ "title": "SysProM: System Provenance Model",
509
+ "type": "object"
510
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @module canonical-json
3
+ *
4
+ * JSON serialisation with RFC 8785 key ordering and value semantics,
5
+ * optionally pretty-printed with configurable indentation.
6
+ *
7
+ * - Object keys sorted by Unicode code point order
8
+ * - Numbers formatted per ECMAScript toString()
9
+ * - Strings escaped per JSON spec
10
+ * - null, true, false as literals
11
+ * - undefined values omitted from objects
12
+ */
13
+ export interface FormatOptions {
14
+ indent?: string;
15
+ }
16
+ /**
17
+ * Serialise a value to canonical JSON with RFC 8785 key ordering.
18
+ *
19
+ * @param value - The value to serialise.
20
+ * @param options - Formatting options (e.g. indentation).
21
+ * @returns The canonical JSON string.
22
+ */
23
+ export declare function canonicalise(value: unknown, options?: FormatOptions): string;
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @module canonical-json
3
+ *
4
+ * JSON serialisation with RFC 8785 key ordering and value semantics,
5
+ * optionally pretty-printed with configurable indentation.
6
+ *
7
+ * - Object keys sorted by Unicode code point order
8
+ * - Numbers formatted per ECMAScript toString()
9
+ * - Strings escaped per JSON spec
10
+ * - null, true, false as literals
11
+ * - undefined values omitted from objects
12
+ */
13
+ /**
14
+ * Serialise a value to canonical JSON with RFC 8785 key ordering.
15
+ *
16
+ * @param value - The value to serialise.
17
+ * @param options - Formatting options (e.g. indentation).
18
+ * @returns The canonical JSON string.
19
+ */
20
+ export function canonicalise(value, options = {}) {
21
+ const indent = options.indent ?? "";
22
+ return serialise(value, indent, 0);
23
+ }
24
+ function isRecord(value) {
25
+ return typeof value === "object" && value !== null && !Array.isArray(value);
26
+ }
27
+ function serialise(value, indent, depth) {
28
+ if (value === null)
29
+ return "null";
30
+ if (value === true)
31
+ return "true";
32
+ if (value === false)
33
+ return "false";
34
+ if (typeof value === "number") {
35
+ if (!Number.isFinite(value)) {
36
+ throw new Error("Non-finite numbers are not serialisable");
37
+ }
38
+ return Object.is(value, -0) ? "0" : String(value);
39
+ }
40
+ if (typeof value === "string") {
41
+ return serialiseString(value);
42
+ }
43
+ if (Array.isArray(value)) {
44
+ return serialiseArray(value, indent, depth);
45
+ }
46
+ if (isRecord(value)) {
47
+ return serialiseObject(value, indent, depth);
48
+ }
49
+ throw new Error(`Unserialisable type: ${typeof value}`);
50
+ }
51
+ function serialiseArray(value, indent, depth) {
52
+ if (value.length === 0)
53
+ return "[]";
54
+ if (!indent) {
55
+ return "[" + value.map((v) => serialise(v, indent, depth)).join(",") + "]";
56
+ }
57
+ const inner = depth + 1;
58
+ const pad = indent.repeat(inner);
59
+ const items = value.map((v) => pad + serialise(v, indent, inner));
60
+ return "[\n" + items.join(",\n") + "\n" + indent.repeat(depth) + "]";
61
+ }
62
+ function serialiseObject(value, indent, depth) {
63
+ const keys = Object.keys(value)
64
+ .filter((k) => value[k] !== undefined)
65
+ .sort(compareCodePoints);
66
+ if (keys.length === 0)
67
+ return "{}";
68
+ if (!indent) {
69
+ const entries = keys.map((k) => serialiseString(k) + ":" + serialise(value[k], indent, depth));
70
+ return "{" + entries.join(",") + "}";
71
+ }
72
+ const inner = depth + 1;
73
+ const pad = indent.repeat(inner);
74
+ const entries = keys.map((k) => pad + serialiseString(k) + ": " + serialise(value[k], indent, inner));
75
+ return "{\n" + entries.join(",\n") + "\n" + indent.repeat(depth) + "}";
76
+ }
77
+ function compareCodePoints(a, b) {
78
+ if (a < b)
79
+ return -1;
80
+ if (a > b)
81
+ return 1;
82
+ return 0;
83
+ }
84
+ function serialiseString(value) {
85
+ let result = '"';
86
+ for (let i = 0; i < value.length; i++) {
87
+ const code = value.charCodeAt(i);
88
+ switch (code) {
89
+ case 0x08:
90
+ result += "\\b";
91
+ break;
92
+ case 0x09:
93
+ result += "\\t";
94
+ break;
95
+ case 0x0a:
96
+ result += "\\n";
97
+ break;
98
+ case 0x0c:
99
+ result += "\\f";
100
+ break;
101
+ case 0x0d:
102
+ result += "\\r";
103
+ break;
104
+ case 0x22:
105
+ result += '\\"';
106
+ break;
107
+ case 0x5c:
108
+ result += "\\\\";
109
+ break;
110
+ default:
111
+ if (code < 0x20) {
112
+ result += "\\u" + code.toString(16).padStart(4, "0");
113
+ }
114
+ else {
115
+ result += value[i];
116
+ }
117
+ }
118
+ }
119
+ return result + '"';
120
+ }
@@ -0,0 +1,22 @@
1
+ import * as z from "zod";
2
+ import type { CommandDef } from "../define-command.js";
3
+ declare const argsSchema: z.ZodObject<{
4
+ input: z.ZodString;
5
+ nodeType: z.ZodString;
6
+ }, z.core.$strip>;
7
+ declare const optsSchema: z.ZodObject<{
8
+ json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ dryRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
10
+ sync: z.ZodOptional<z.ZodString>;
11
+ id: z.ZodOptional<z.ZodString>;
12
+ name: z.ZodString;
13
+ description: z.ZodOptional<z.ZodString>;
14
+ status: z.ZodOptional<z.ZodString>;
15
+ context: z.ZodOptional<z.ZodString>;
16
+ rationale: z.ZodOptional<z.ZodString>;
17
+ scope: z.ZodOptional<z.ZodArray<z.ZodString>>;
18
+ selected: z.ZodOptional<z.ZodString>;
19
+ option: z.ZodOptional<z.ZodArray<z.ZodString>>;
20
+ }, z.core.$strip>;
21
+ export declare const addCommand: CommandDef<typeof argsSchema, typeof optsSchema>;
22
+ export {};