@darkrymit/crunes-cli 0.7.1 → 0.8.1

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 (75) hide show
  1. package/README.md +5 -4
  2. package/dist/chunks/{add-OWYVF3IE.js → add-CBHWFGCA.js} +2 -2
  3. package/dist/chunks/{apply-OMEVXCHC.js → apply-YC6JEPUN.js} +6 -5
  4. package/dist/chunks/args-repl-TX3YWUOO.js +81 -0
  5. package/dist/chunks/banner-repl-DD22Z33A.js +52 -0
  6. package/dist/chunks/benchmark-BJEAAFWG.js +234 -0
  7. package/dist/chunks/{browse-COH6IJEX.js → browse-JZFU52ET.js} +2 -2
  8. package/dist/chunks/{chunk-2Q24YPGL.js → chunk-2PBPDTRD.js} +2 -2
  9. package/dist/chunks/chunk-63H5VXZY.js +101 -0
  10. package/dist/chunks/{chunk-GHQOK4L7.js → chunk-65J65MAP.js} +1 -1
  11. package/dist/chunks/{chunk-HMU2J25D.js → chunk-6MRZXASS.js} +3 -3
  12. package/dist/chunks/{chunk-HOH7WZX4.js → chunk-ASZKAC24.js} +9 -1
  13. package/dist/chunks/{chunk-AIEWOUXT.js → chunk-DZJRYFOP.js} +104 -41
  14. package/dist/chunks/{chunk-QMWGQXEZ.js → chunk-G4ZAUHHA.js} +2 -4
  15. package/dist/chunks/{chunk-67I2J474.js → chunk-J3GZ3DXD.js} +14 -55
  16. package/dist/chunks/{chunk-XIXND2M4.js → chunk-JOAL437H.js} +5 -1
  17. package/dist/chunks/{chunk-6I7RHSAA.js → chunk-JU6FKUBY.js} +30394 -26055
  18. package/dist/chunks/{chunk-BVY5LN7X.js → chunk-NAEVMRNA.js} +22031 -13350
  19. package/dist/chunks/{chunk-NXSDVVTW.js → chunk-NDEYEYSU.js} +22 -69
  20. package/dist/chunks/{chunk-L72BG6DS.js → chunk-NYLRTAAA.js} +1 -1
  21. package/dist/chunks/{chunk-UGN3FFEF.js → chunk-V35LVVNV.js} +5113 -2117
  22. package/dist/chunks/chunk-ZJDKCC2Y.js +105 -0
  23. package/dist/chunks/{clear-Y5POLIMF.js → clear-YBDIPEEH.js} +5 -9
  24. package/dist/chunks/commands-repl-IPLJ4M7X.js +65 -0
  25. package/dist/chunks/complete-input-repl-IDSCMRYL.js +71 -0
  26. package/dist/chunks/{create-I6BNYZ5Q.js → create-ZFFV3Z2P.js} +2 -1
  27. package/dist/chunks/{delete-UB5SXO5I.js → delete-C4UJ7X5K.js} +5 -9
  28. package/dist/chunks/delete-E4TEBRPX.js +27 -0
  29. package/dist/chunks/{delete-7CQFYIXS.js → delete-LNOYM5KG.js} +5 -9
  30. package/dist/chunks/{disable-FCBW7WVG.js → disable-TMG2K3BF.js} +6 -6
  31. package/dist/chunks/{doctor-DS57HDLJ.js → doctor-N43QEMAH.js} +2 -2
  32. package/dist/chunks/{enable-IXRVUXJM.js → enable-327OMBPC.js} +6 -6
  33. package/dist/chunks/{globals-YCJ2DGWC.js → globals-H2WF344Y.js} +2 -2
  34. package/dist/chunks/{init-WGKQVAZE.js → init-HU5OMHEH.js} +1 -1
  35. package/dist/chunks/input-repl-ZBH6FVPV.js +87 -0
  36. package/dist/chunks/{install-BCTBOPBS.js → install-RRLUOYFO.js} +6 -6
  37. package/dist/chunks/intro-4CICBP2J.js +2727 -0
  38. package/dist/chunks/{kill-LWRXZVM5.js → kill-2UG7PHUV.js} +4 -10
  39. package/dist/chunks/list-4X3JFQGS.js +41 -0
  40. package/dist/chunks/{list-ZBYPMUID.js → list-7VHJIUDX.js} +2 -2
  41. package/dist/chunks/list-A5WVDBWF.js +53 -0
  42. package/dist/chunks/{list-NGOCMJXE.js → list-CK5X2YN3.js} +5 -4
  43. package/dist/chunks/{list-TTKLNJKI.js → list-FLAYJQKN.js} +2 -2
  44. package/dist/chunks/list-PTAWQYWG.js +35 -0
  45. package/dist/chunks/list-U7PAYNAH.js +47 -0
  46. package/dist/chunks/{list-OTOMCFLA.js → list-WH7KESMV.js} +12 -11
  47. package/dist/chunks/{query-NY4SCO77.js → query-AW7WYILM.js} +5 -9
  48. package/dist/chunks/{registry-W5XFI5T6.js → registry-3QIL5SVL.js} +2 -2
  49. package/dist/chunks/{remove-WEAZFZCO.js → remove-QUH2D3S5.js} +2 -2
  50. package/dist/chunks/repl-STBZC4P2.js +180 -0
  51. package/dist/chunks/repl-VGC5FUJG.js +378 -0
  52. package/dist/chunks/resolver-QMIY33FM.js +26 -0
  53. package/dist/chunks/run-T33CMCFZ.js +26 -0
  54. package/dist/chunks/{run-J2A5YTTY.js → run-Y4TG3EM3.js} +22 -3
  55. package/dist/chunks/rune-UBRVWG5A.js +139 -0
  56. package/dist/chunks/{search-XENXL3GC.js → search-MSSDGJTF.js} +2 -2
  57. package/dist/chunks/{uninstall-MX5PLGDI.js → uninstall-55YTHZRH.js} +5 -5
  58. package/dist/chunks/unset-YASSMSE5.js +24 -0
  59. package/dist/chunks/{update-7XDTVFZ3.js → update-EWWDROKW.js} +2 -2
  60. package/dist/chunks/{update-IEE54GPY.js → update-G6XO4RIM.js} +6 -6
  61. package/dist/chunks/{utils-PO3ZK53L.js → utils-XOWJQWNR.js} +2 -2
  62. package/dist/chunks/{version-V67W66HQ.js → version-I442SSH7.js} +10 -5
  63. package/dist/cli.js +114 -81
  64. package/package.json +9 -4
  65. package/dist/chunks/benchmark-ATSRQIDC.js +0 -164
  66. package/dist/chunks/check-G72VZKIP.js +0 -144
  67. package/dist/chunks/chunk-3TM6B4E5.js +0 -70
  68. package/dist/chunks/chunk-XXUNHQIB.js +0 -129
  69. package/dist/chunks/intro-RFWW5HIO.js +0 -1510
  70. package/dist/chunks/list-5DVVP7HX.js +0 -50
  71. package/dist/chunks/list-6WL5LGIZ.js +0 -80
  72. package/dist/chunks/list-YPI7YDKK.js +0 -80
  73. package/dist/chunks/run-AUAGELWL.js +0 -23
  74. package/dist/chunks/rune-D2FL547U.js +0 -87
  75. package/dist/chunks/unset-KQOZYVTE.js +0 -28
@@ -1,1510 +0,0 @@
1
- import {
2
- utils_api_default
3
- } from "./chunk-BVY5LN7X.js";
4
- import {
5
- globals_api_default
6
- } from "./chunk-UGN3FFEF.js";
7
- import {
8
- formatMembers,
9
- formatNode,
10
- walk
11
- } from "./chunk-XIXND2M4.js";
12
- import {
13
- formatHelp
14
- } from "./chunk-HOH7WZX4.js";
15
- import {
16
- computeEffectivePermissions,
17
- getArgsSchema
18
- } from "./chunk-6I7RHSAA.js";
19
- import "./chunk-67I2J474.js";
20
- import "./chunk-XXUNHQIB.js";
21
- import "./chunk-NXSDVVTW.js";
22
- import "./chunk-QMWGQXEZ.js";
23
- import "./chunk-3TM6B4E5.js";
24
- import {
25
- loadConfig
26
- } from "./chunk-H3BVJCIL.js";
27
- import {
28
- output
29
- } from "./chunk-6XLT25GS.js";
30
- import "./chunk-WCODTMDN.js";
31
- import "./chunk-GHQOK4L7.js";
32
- import "./chunk-HMU2J25D.js";
33
- import "./chunk-G3U4V32O.js";
34
- import {
35
- init_require_shim
36
- } from "./chunk-TPK5AGRA.js";
37
-
38
- // src/docs/commands/intro.js
39
- init_require_shim();
40
- import { writeFileSync } from "node:fs";
41
- import { resolve as resolve2 } from "node:path";
42
-
43
- // src/docs/intro-compiler.js
44
- init_require_shim();
45
-
46
- // src/docs/generated/lifecycle-api.json
47
- var lifecycle_api_default = {
48
- schemaVersion: "2.0",
49
- id: 0,
50
- name: "@darkrymit/crunes-cli",
51
- variant: "project",
52
- kind: 1,
53
- flags: {},
54
- children: [
55
- {
56
- id: 1,
57
- name: "lifecycle",
58
- variant: "declaration",
59
- kind: 4,
60
- flags: {},
61
- comment: {
62
- summary: [
63
- {
64
- kind: "text",
65
- text: "Rune Lifecycle Entrypoint Methods\n\nThese are the standard ES module exports required or supported by the Crunes execution engine."
66
- }
67
- ]
68
- },
69
- children: [
70
- {
71
- id: 8,
72
- name: "ArgBuilder",
73
- variant: "declaration",
74
- kind: 256,
75
- flags: {},
76
- comment: {
77
- summary: [
78
- {
79
- kind: "text",
80
- text: "Fluent builder for defining rune options, positionals, and examples."
81
- }
82
- ]
83
- },
84
- children: [
85
- {
86
- id: 30,
87
- name: "build",
88
- variant: "declaration",
89
- kind: 2048,
90
- flags: {},
91
- signatures: [
92
- {
93
- id: 31,
94
- name: "build",
95
- variant: "signature",
96
- kind: 4096,
97
- flags: {},
98
- comment: {
99
- summary: [
100
- {
101
- kind: "text",
102
- text: "Finalizes and builds the argument schema."
103
- }
104
- ]
105
- },
106
- type: {
107
- type: "intrinsic",
108
- name: "any"
109
- }
110
- }
111
- ]
112
- },
113
- {
114
- id: 22,
115
- name: "command",
116
- variant: "declaration",
117
- kind: 2048,
118
- flags: {},
119
- signatures: [
120
- {
121
- id: 23,
122
- name: "command",
123
- variant: "signature",
124
- kind: 4096,
125
- flags: {},
126
- comment: {
127
- summary: [
128
- {
129
- kind: "text",
130
- text: "Declares a nested command under the current command."
131
- }
132
- ]
133
- },
134
- parameters: [
135
- {
136
- id: 24,
137
- name: "name",
138
- variant: "param",
139
- kind: 32768,
140
- flags: {},
141
- comment: {
142
- summary: [
143
- {
144
- kind: "text",
145
- text: "Command name (e.g. 'create')."
146
- }
147
- ]
148
- },
149
- type: {
150
- type: "intrinsic",
151
- name: "string"
152
- }
153
- },
154
- {
155
- id: 25,
156
- name: "description",
157
- variant: "param",
158
- kind: 32768,
159
- flags: {},
160
- comment: {
161
- summary: [
162
- {
163
- kind: "text",
164
- text: "Command description."
165
- }
166
- ]
167
- },
168
- type: {
169
- type: "intrinsic",
170
- name: "string"
171
- }
172
- },
173
- {
174
- id: 26,
175
- name: "callback",
176
- variant: "param",
177
- kind: 32768,
178
- flags: {
179
- isOptional: true
180
- },
181
- comment: {
182
- summary: [
183
- {
184
- kind: "text",
185
- text: "Callback configured with a subcommand ArgBuilder."
186
- }
187
- ]
188
- },
189
- type: {
190
- type: "reflection",
191
- declaration: {
192
- id: 27,
193
- name: "__type",
194
- variant: "declaration",
195
- kind: 65536,
196
- flags: {},
197
- signatures: [
198
- {
199
- id: 28,
200
- name: "__type",
201
- variant: "signature",
202
- kind: 4096,
203
- flags: {},
204
- parameters: [
205
- {
206
- id: 29,
207
- name: "sub",
208
- variant: "param",
209
- kind: 32768,
210
- flags: {},
211
- type: {
212
- type: "reference",
213
- target: 8,
214
- name: "ArgBuilder",
215
- package: "@darkrymit/crunes-cli",
216
- qualifiedName: "lifecycle.ArgBuilder"
217
- }
218
- }
219
- ],
220
- type: {
221
- type: "intrinsic",
222
- name: "void"
223
- }
224
- }
225
- ]
226
- }
227
- }
228
- }
229
- ],
230
- type: {
231
- type: "intrinsic",
232
- name: "this"
233
- }
234
- }
235
- ]
236
- },
237
- {
238
- id: 18,
239
- name: "example",
240
- variant: "declaration",
241
- kind: 2048,
242
- flags: {},
243
- signatures: [
244
- {
245
- id: 19,
246
- name: "example",
247
- variant: "signature",
248
- kind: 4096,
249
- flags: {},
250
- comment: {
251
- summary: [
252
- {
253
- kind: "text",
254
- text: "Adds an example command showing how to call the rune."
255
- }
256
- ]
257
- },
258
- parameters: [
259
- {
260
- id: 20,
261
- name: "usage",
262
- variant: "param",
263
- kind: 32768,
264
- flags: {},
265
- comment: {
266
- summary: [
267
- {
268
- kind: "text",
269
- text: "Usage example string (e.g. 'crunes run hello world')."
270
- }
271
- ]
272
- },
273
- type: {
274
- type: "intrinsic",
275
- name: "string"
276
- }
277
- },
278
- {
279
- id: 21,
280
- name: "description",
281
- variant: "param",
282
- kind: 32768,
283
- flags: {},
284
- comment: {
285
- summary: [
286
- {
287
- kind: "text",
288
- text: "A brief description of the example."
289
- }
290
- ]
291
- },
292
- type: {
293
- type: "intrinsic",
294
- name: "string"
295
- }
296
- }
297
- ],
298
- type: {
299
- type: "intrinsic",
300
- name: "this"
301
- }
302
- }
303
- ]
304
- },
305
- {
306
- id: 9,
307
- name: "option",
308
- variant: "declaration",
309
- kind: 2048,
310
- flags: {},
311
- signatures: [
312
- {
313
- id: 10,
314
- name: "option",
315
- variant: "signature",
316
- kind: 4096,
317
- flags: {},
318
- comment: {
319
- summary: [
320
- {
321
- kind: "text",
322
- text: "Declares a named option/flag."
323
- }
324
- ]
325
- },
326
- parameters: [
327
- {
328
- id: 11,
329
- name: "flags",
330
- variant: "param",
331
- kind: 32768,
332
- flags: {},
333
- comment: {
334
- summary: [
335
- {
336
- kind: "text",
337
- text: "Flag specification (e.g., '--verbose' or '-n, --name <name>')."
338
- }
339
- ]
340
- },
341
- type: {
342
- type: "intrinsic",
343
- name: "string"
344
- }
345
- },
346
- {
347
- id: 12,
348
- name: "description",
349
- variant: "param",
350
- kind: 32768,
351
- flags: {},
352
- comment: {
353
- summary: [
354
- {
355
- kind: "text",
356
- text: "A brief description of this option."
357
- }
358
- ]
359
- },
360
- type: {
361
- type: "intrinsic",
362
- name: "string"
363
- }
364
- },
365
- {
366
- id: 13,
367
- name: "defaultValue",
368
- variant: "param",
369
- kind: 32768,
370
- flags: {
371
- isOptional: true
372
- },
373
- comment: {
374
- summary: [
375
- {
376
- kind: "text",
377
- text: "Optional default value for the option."
378
- }
379
- ]
380
- },
381
- type: {
382
- type: "intrinsic",
383
- name: "any"
384
- }
385
- }
386
- ],
387
- type: {
388
- type: "intrinsic",
389
- name: "this"
390
- }
391
- }
392
- ]
393
- },
394
- {
395
- id: 14,
396
- name: "positional",
397
- variant: "declaration",
398
- kind: 2048,
399
- flags: {},
400
- signatures: [
401
- {
402
- id: 15,
403
- name: "positional",
404
- variant: "signature",
405
- kind: 4096,
406
- flags: {},
407
- comment: {
408
- summary: [
409
- {
410
- kind: "text",
411
- text: "Declares a positional argument."
412
- }
413
- ]
414
- },
415
- parameters: [
416
- {
417
- id: 16,
418
- name: "spec",
419
- variant: "param",
420
- kind: 32768,
421
- flags: {},
422
- comment: {
423
- summary: [
424
- {
425
- kind: "text",
426
- text: "Positional argument specification (e.g., '<name>' for required, '[name]' for optional, '<targets...>' or '[targets...]' for variadic rest arrays)."
427
- }
428
- ]
429
- },
430
- type: {
431
- type: "intrinsic",
432
- name: "string"
433
- }
434
- },
435
- {
436
- id: 17,
437
- name: "description",
438
- variant: "param",
439
- kind: 32768,
440
- flags: {},
441
- comment: {
442
- summary: [
443
- {
444
- kind: "text",
445
- text: "A brief description of this positional argument."
446
- }
447
- ]
448
- },
449
- type: {
450
- type: "intrinsic",
451
- name: "string"
452
- }
453
- }
454
- ],
455
- type: {
456
- type: "intrinsic",
457
- name: "this"
458
- }
459
- }
460
- ]
461
- }
462
- ],
463
- groups: [
464
- {
465
- title: "Methods",
466
- children: [
467
- 30,
468
- 22,
469
- 18,
470
- 9,
471
- 14
472
- ]
473
- }
474
- ]
475
- },
476
- {
477
- id: 32,
478
- name: "ParsedArgs",
479
- variant: "declaration",
480
- kind: 256,
481
- flags: {},
482
- comment: {
483
- summary: [
484
- {
485
- kind: "text",
486
- text: "Parsed yargs-parser arguments passed to the rune's run() function."
487
- }
488
- ]
489
- },
490
- children: [
491
- {
492
- id: 33,
493
- name: "_",
494
- variant: "declaration",
495
- kind: 1024,
496
- flags: {},
497
- comment: {
498
- summary: [
499
- {
500
- kind: "text",
501
- text: "Positional arguments in order."
502
- }
503
- ]
504
- },
505
- type: {
506
- type: "array",
507
- elementType: {
508
- type: "intrinsic",
509
- name: "string"
510
- }
511
- }
512
- },
513
- {
514
- id: 36,
515
- name: "$command",
516
- variant: "declaration",
517
- kind: 1024,
518
- flags: {
519
- isOptional: true
520
- },
521
- comment: {
522
- summary: [
523
- {
524
- kind: "text",
525
- text: "Space-separated matched command path string (e.g. 'remote add'). Only present when a subcommand matched."
526
- }
527
- ]
528
- },
529
- type: {
530
- type: "intrinsic",
531
- name: "string"
532
- }
533
- },
534
- {
535
- id: 37,
536
- name: "$commands",
537
- variant: "declaration",
538
- kind: 1024,
539
- flags: {
540
- isOptional: true
541
- },
542
- comment: {
543
- summary: [
544
- {
545
- kind: "text",
546
- text: "Array of matched command path levels (e.g. ['remote', 'add']). Only present when a subcommand matched."
547
- }
548
- ]
549
- },
550
- type: {
551
- type: "array",
552
- elementType: {
553
- type: "intrinsic",
554
- name: "string"
555
- }
556
- }
557
- },
558
- {
559
- id: 35,
560
- name: "$raw",
561
- variant: "declaration",
562
- kind: 1024,
563
- flags: {},
564
- comment: {
565
- summary: [
566
- {
567
- kind: "text",
568
- text: "Original raw arguments passed to the rune."
569
- }
570
- ]
571
- },
572
- type: {
573
- type: "array",
574
- elementType: {
575
- type: "intrinsic",
576
- name: "string"
577
- }
578
- }
579
- },
580
- {
581
- id: 34,
582
- name: "$rest",
583
- variant: "declaration",
584
- kind: 1024,
585
- flags: {},
586
- comment: {
587
- summary: [
588
- {
589
- kind: "text",
590
- text: "Positional arguments not mapped to any named parameters."
591
- }
592
- ]
593
- },
594
- type: {
595
- type: "array",
596
- elementType: {
597
- type: "intrinsic",
598
- name: "string"
599
- }
600
- }
601
- }
602
- ],
603
- groups: [
604
- {
605
- title: "Properties",
606
- children: [
607
- 33,
608
- 36,
609
- 37,
610
- 35,
611
- 34
612
- ]
613
- }
614
- ],
615
- indexSignatures: [
616
- {
617
- id: 38,
618
- name: "__index",
619
- variant: "signature",
620
- kind: 8192,
621
- flags: {},
622
- parameters: [
623
- {
624
- id: 39,
625
- name: "key",
626
- variant: "param",
627
- kind: 32768,
628
- flags: {},
629
- type: {
630
- type: "intrinsic",
631
- name: "string"
632
- }
633
- }
634
- ],
635
- type: {
636
- type: "intrinsic",
637
- name: "any"
638
- }
639
- }
640
- ],
641
- extendedTypes: [
642
- {
643
- type: "reference",
644
- target: {
645
- packageName: "typescript",
646
- packagePath: "lib/lib.es5.d.ts",
647
- qualifiedName: "Record"
648
- },
649
- typeArguments: [
650
- {
651
- type: "intrinsic",
652
- name: "string"
653
- },
654
- {
655
- type: "intrinsic",
656
- name: "any"
657
- }
658
- ],
659
- name: "Record",
660
- package: "typescript"
661
- }
662
- ]
663
- },
664
- {
665
- id: 2,
666
- name: "args",
667
- variant: "declaration",
668
- kind: 64,
669
- flags: {},
670
- signatures: [
671
- {
672
- id: 3,
673
- name: "args",
674
- variant: "signature",
675
- kind: 4096,
676
- flags: {},
677
- comment: {
678
- summary: [
679
- {
680
- kind: "text",
681
- text: "Defines the argument and option schema for the rune.\nCalled by the runner in a minimal bootstrap isolate to compile usage specifications."
682
- }
683
- ]
684
- },
685
- parameters: [
686
- {
687
- id: 4,
688
- name: "builder",
689
- variant: "param",
690
- kind: 32768,
691
- flags: {},
692
- comment: {
693
- summary: [
694
- {
695
- kind: "text",
696
- text: "The schema builder to declare options, positionals, and examples."
697
- }
698
- ]
699
- },
700
- type: {
701
- type: "reference",
702
- target: 8,
703
- name: "ArgBuilder",
704
- package: "@darkrymit/crunes-cli",
705
- qualifiedName: "lifecycle.ArgBuilder"
706
- }
707
- }
708
- ],
709
- type: {
710
- type: "intrinsic",
711
- name: "any"
712
- }
713
- }
714
- ]
715
- },
716
- {
717
- id: 5,
718
- name: "run",
719
- variant: "declaration",
720
- kind: 64,
721
- flags: {},
722
- signatures: [
723
- {
724
- id: 6,
725
- name: "run",
726
- variant: "signature",
727
- kind: 4096,
728
- flags: {},
729
- comment: {
730
- summary: [
731
- {
732
- kind: "text",
733
- text: "The main execution lifecycle function of the rune."
734
- }
735
- ],
736
- blockTags: [
737
- {
738
- tag: "@returns",
739
- content: [
740
- {
741
- kind: "text",
742
- text: "A single section, an array of sections, a plain string, or void."
743
- }
744
- ]
745
- }
746
- ]
747
- },
748
- parameters: [
749
- {
750
- id: 7,
751
- name: "args",
752
- variant: "param",
753
- kind: 32768,
754
- flags: {},
755
- comment: {
756
- summary: [
757
- {
758
- kind: "text",
759
- text: "Parsed yargs-parser arguments."
760
- }
761
- ]
762
- },
763
- type: {
764
- type: "reference",
765
- target: 32,
766
- name: "ParsedArgs",
767
- package: "@darkrymit/crunes-cli",
768
- qualifiedName: "lifecycle.ParsedArgs"
769
- }
770
- }
771
- ],
772
- type: {
773
- type: "union",
774
- types: [
775
- {
776
- type: "intrinsic",
777
- name: "string"
778
- },
779
- {
780
- type: "intrinsic",
781
- name: "void"
782
- },
783
- {
784
- type: "reference",
785
- target: {
786
- packageName: "@darkrymit/crunes-cli",
787
- packagePath: "src/rune/api/types-globals/globals.d.ts",
788
- qualifiedName: "globals.RuneSection"
789
- },
790
- name: "RuneSection",
791
- package: "@darkrymit/crunes-cli",
792
- qualifiedName: "globals.RuneSection"
793
- },
794
- {
795
- type: "array",
796
- elementType: {
797
- type: "reference",
798
- target: {
799
- packageName: "@darkrymit/crunes-cli",
800
- packagePath: "src/rune/api/types-globals/globals.d.ts",
801
- qualifiedName: "globals.RuneSection"
802
- },
803
- name: "RuneSection",
804
- package: "@darkrymit/crunes-cli",
805
- qualifiedName: "globals.RuneSection"
806
- }
807
- },
808
- {
809
- type: "reference",
810
- target: {
811
- packageName: "typescript",
812
- packagePath: "lib/lib.es5.d.ts",
813
- qualifiedName: "Promise"
814
- },
815
- typeArguments: [
816
- {
817
- type: "union",
818
- types: [
819
- {
820
- type: "intrinsic",
821
- name: "string"
822
- },
823
- {
824
- type: "intrinsic",
825
- name: "void"
826
- },
827
- {
828
- type: "reference",
829
- target: {
830
- packageName: "@darkrymit/crunes-cli",
831
- packagePath: "src/rune/api/types-globals/globals.d.ts",
832
- qualifiedName: "globals.RuneSection"
833
- },
834
- name: "RuneSection",
835
- package: "@darkrymit/crunes-cli",
836
- qualifiedName: "globals.RuneSection"
837
- },
838
- {
839
- type: "array",
840
- elementType: {
841
- type: "reference",
842
- target: {
843
- packageName: "@darkrymit/crunes-cli",
844
- packagePath: "src/rune/api/types-globals/globals.d.ts",
845
- qualifiedName: "globals.RuneSection"
846
- },
847
- name: "RuneSection",
848
- package: "@darkrymit/crunes-cli",
849
- qualifiedName: "globals.RuneSection"
850
- }
851
- }
852
- ]
853
- }
854
- ],
855
- name: "Promise",
856
- package: "typescript"
857
- }
858
- ]
859
- }
860
- }
861
- ]
862
- }
863
- ],
864
- groups: [
865
- {
866
- title: "Interfaces",
867
- children: [
868
- 8,
869
- 32
870
- ]
871
- },
872
- {
873
- title: "Functions",
874
- children: [
875
- 2,
876
- 5
877
- ]
878
- }
879
- ]
880
- }
881
- ],
882
- groups: [
883
- {
884
- title: "Namespaces",
885
- children: [
886
- 1
887
- ]
888
- }
889
- ],
890
- packageName: "@darkrymit/crunes-cli",
891
- symbolIdMap: {
892
- "1": {
893
- packageName: "@darkrymit/crunes-cli",
894
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
895
- qualifiedName: "lifecycle"
896
- },
897
- "2": {
898
- packageName: "@darkrymit/crunes-cli",
899
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
900
- qualifiedName: "lifecycle.args"
901
- },
902
- "3": {
903
- packageName: "@darkrymit/crunes-cli",
904
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
905
- qualifiedName: "lifecycle.args"
906
- },
907
- "4": {
908
- packageName: "@darkrymit/crunes-cli",
909
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
910
- qualifiedName: "builder"
911
- },
912
- "5": {
913
- packageName: "@darkrymit/crunes-cli",
914
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
915
- qualifiedName: "lifecycle.run"
916
- },
917
- "6": {
918
- packageName: "@darkrymit/crunes-cli",
919
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
920
- qualifiedName: "lifecycle.run"
921
- },
922
- "7": {
923
- packageName: "@darkrymit/crunes-cli",
924
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
925
- qualifiedName: "args"
926
- },
927
- "8": {
928
- packageName: "@darkrymit/crunes-cli",
929
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
930
- qualifiedName: "lifecycle.ArgBuilder"
931
- },
932
- "9": {
933
- packageName: "@darkrymit/crunes-cli",
934
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
935
- qualifiedName: "lifecycle.ArgBuilder.option"
936
- },
937
- "10": {
938
- packageName: "@darkrymit/crunes-cli",
939
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
940
- qualifiedName: "lifecycle.ArgBuilder.option"
941
- },
942
- "11": {
943
- packageName: "@darkrymit/crunes-cli",
944
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
945
- qualifiedName: "flags"
946
- },
947
- "12": {
948
- packageName: "@darkrymit/crunes-cli",
949
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
950
- qualifiedName: "description"
951
- },
952
- "13": {
953
- packageName: "@darkrymit/crunes-cli",
954
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
955
- qualifiedName: "defaultValue"
956
- },
957
- "14": {
958
- packageName: "@darkrymit/crunes-cli",
959
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
960
- qualifiedName: "lifecycle.ArgBuilder.positional"
961
- },
962
- "15": {
963
- packageName: "@darkrymit/crunes-cli",
964
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
965
- qualifiedName: "lifecycle.ArgBuilder.positional"
966
- },
967
- "16": {
968
- packageName: "@darkrymit/crunes-cli",
969
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
970
- qualifiedName: "spec"
971
- },
972
- "17": {
973
- packageName: "@darkrymit/crunes-cli",
974
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
975
- qualifiedName: "description"
976
- },
977
- "18": {
978
- packageName: "@darkrymit/crunes-cli",
979
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
980
- qualifiedName: "lifecycle.ArgBuilder.example"
981
- },
982
- "19": {
983
- packageName: "@darkrymit/crunes-cli",
984
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
985
- qualifiedName: "lifecycle.ArgBuilder.example"
986
- },
987
- "20": {
988
- packageName: "@darkrymit/crunes-cli",
989
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
990
- qualifiedName: "usage"
991
- },
992
- "21": {
993
- packageName: "@darkrymit/crunes-cli",
994
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
995
- qualifiedName: "description"
996
- },
997
- "22": {
998
- packageName: "@darkrymit/crunes-cli",
999
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1000
- qualifiedName: "lifecycle.ArgBuilder.command"
1001
- },
1002
- "23": {
1003
- packageName: "@darkrymit/crunes-cli",
1004
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1005
- qualifiedName: "lifecycle.ArgBuilder.command"
1006
- },
1007
- "24": {
1008
- packageName: "@darkrymit/crunes-cli",
1009
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1010
- qualifiedName: "name"
1011
- },
1012
- "25": {
1013
- packageName: "@darkrymit/crunes-cli",
1014
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1015
- qualifiedName: "description"
1016
- },
1017
- "26": {
1018
- packageName: "@darkrymit/crunes-cli",
1019
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1020
- qualifiedName: "callback"
1021
- },
1022
- "27": {
1023
- packageName: "@darkrymit/crunes-cli",
1024
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1025
- qualifiedName: "__type"
1026
- },
1027
- "28": {
1028
- packageName: "@darkrymit/crunes-cli",
1029
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1030
- qualifiedName: "__type"
1031
- },
1032
- "29": {
1033
- packageName: "@darkrymit/crunes-cli",
1034
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1035
- qualifiedName: "sub"
1036
- },
1037
- "30": {
1038
- packageName: "@darkrymit/crunes-cli",
1039
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1040
- qualifiedName: "lifecycle.ArgBuilder.build"
1041
- },
1042
- "31": {
1043
- packageName: "@darkrymit/crunes-cli",
1044
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1045
- qualifiedName: "lifecycle.ArgBuilder.build"
1046
- },
1047
- "32": {
1048
- packageName: "@darkrymit/crunes-cli",
1049
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1050
- qualifiedName: "lifecycle.ParsedArgs"
1051
- },
1052
- "33": {
1053
- packageName: "@darkrymit/crunes-cli",
1054
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1055
- qualifiedName: "lifecycle.ParsedArgs._"
1056
- },
1057
- "34": {
1058
- packageName: "@darkrymit/crunes-cli",
1059
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1060
- qualifiedName: "lifecycle.ParsedArgs.$rest"
1061
- },
1062
- "35": {
1063
- packageName: "@darkrymit/crunes-cli",
1064
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1065
- qualifiedName: "lifecycle.ParsedArgs.$raw"
1066
- },
1067
- "36": {
1068
- packageName: "@darkrymit/crunes-cli",
1069
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1070
- qualifiedName: "lifecycle.ParsedArgs.$command"
1071
- },
1072
- "37": {
1073
- packageName: "@darkrymit/crunes-cli",
1074
- packagePath: "src/rune/api/types-lifecycle/lifecycle.d.ts",
1075
- qualifiedName: "lifecycle.ParsedArgs.$commands"
1076
- }
1077
- },
1078
- files: {
1079
- entries: {
1080
- "1": "src/rune/api/types-lifecycle/lifecycle.d.ts"
1081
- },
1082
- reflections: {
1083
- "1": 0
1084
- }
1085
- }
1086
- };
1087
-
1088
- // src/docs/intro-compiler.js
1089
- import { resolve } from "node:path";
1090
- var NAMESPACE_RECIPES = {
1091
- fs: `\`\`\`javascript
1092
- import { fs, section } from '@utils'
1093
-
1094
- export async function run() {
1095
- // Read and write files relative to the project root
1096
- const content = await fs.read('src/components/Button.jsx');
1097
- await fs.write('dist/output.txt', 'Hello Sandbox!');
1098
- return [
1099
- section.create('fs-result', {
1100
- type: 'markdown',
1101
- content: 'File written successfully!'
1102
- })
1103
- ];
1104
- }
1105
- \`\`\``,
1106
- ws: `\`\`\`javascript
1107
- import { http, ws, time, section } from '@utils'
1108
-
1109
- export async function run() {
1110
- // --- Client usage ---
1111
- const socket = ws.client('ws://localhost:8080')
1112
- const messages = []
1113
- socket.on('message', (msg) => { messages.push(msg) })
1114
- await socket.open()
1115
- await socket.sendText(JSON.stringify({ type: 'PING' }))
1116
- await time.after(500)
1117
- await socket.close()
1118
-
1119
- // --- Server usage (piggyback on http.server) ---
1120
- const srv = http.server(0) // OS-assigned port, loopback only
1121
- srv.on('request', (req) => new Response('ok'))
1122
-
1123
- const jobs = ws.server(srv, { path: '/jobs' }) // path routing
1124
- const logs = ws.server(srv, { path: '/logs/:jobId' }) // named path param
1125
-
1126
- jobs.on('connection', (conn) => {
1127
- conn.on('message', (msg) => conn.sendText(\`echo: \${msg}\`))
1128
- })
1129
-
1130
- logs.on('connection', (conn) => {
1131
- const jobId = conn.pathParams.get('jobId') // named param extraction
1132
- conn.sendText(\`streaming logs for job \${jobId}\`)
1133
- conn.on('close', () => {})
1134
- })
1135
-
1136
- await srv.open()
1137
- await jobs.open()
1138
- await logs.open()
1139
- await time.after(5_000)
1140
- await logs.close()
1141
- await jobs.close()
1142
- await srv.close()
1143
-
1144
- return [section.create('ws-result', { type: 'markdown', content: messages.join('\\n') })]
1145
- }
1146
- \`\`\``,
1147
- sqlite: `\`\`\`javascript
1148
- import { sqlite, crypto, section } from '@utils'
1149
-
1150
- export async function run() {
1151
- // Scoped SQLite operations
1152
- const db = await sqlite.open('@local-project-sqlite', 'my-database');
1153
- await db.exec('CREATE TABLE IF NOT EXISTS logs (id TEXT PRIMARY KEY, msg TEXT)');
1154
- await db.exec('INSERT INTO logs VALUES (?, ?)', [crypto.uuid(), 'Rune executed!']);
1155
- const rows = await db.query('SELECT * FROM logs');
1156
- await db.close();
1157
-
1158
- return [
1159
- section.create('db-logs', {
1160
- type: 'markdown',
1161
- content: rows.map(r => \`- [\${r.id}]: \${r.msg}\`).join('\\n')
1162
- })
1163
- ];
1164
- }
1165
- \`\`\``,
1166
- http: `\`\`\`javascript
1167
- import { http, section } from '@utils'
1168
-
1169
- export async function run() {
1170
- // --- Client: fetch ---
1171
- const res = await http.fetch('https://api.github.com/repos/darkrymit/crunes')
1172
- const repo = await res.json()
1173
-
1174
- // --- Server: loopback HTTP + WebSocket piggyback ---
1175
- const srv = http.server(0) // loopback, OS-assigned port \u2014 no permission needed
1176
- srv.on('request', (req) => {
1177
- if (req.method === 'GET' && req.pathname === '/health')
1178
- return new Response(JSON.stringify({ ok: true }), { headers: { 'content-type': 'application/json' } })
1179
- return new Response('Not Found', { status: 404 })
1180
- })
1181
- await srv.open()
1182
- // use srv.port here ...
1183
- await srv.close()
1184
-
1185
- return [
1186
- section.create('result', {
1187
- type: 'markdown',
1188
- content: \`**Repo**: \${repo.description}\\n**Server port was**: \${srv.port}\`
1189
- })
1190
- ]
1191
- }
1192
- \`\`\``,
1193
- cache: `\`\`\`javascript
1194
- import { cache, section } from '@utils'
1195
-
1196
- export async function run() {
1197
- const projectCache = await cache.open('@local-project-cache');
1198
- await projectCache.set('last-run', Date.now(), 60); // 60s TTL
1199
- const lastRun = await projectCache.get('last-run');
1200
- return [
1201
- section.create('cache-result', {
1202
- type: 'markdown',
1203
- content: \`Last run timestamp: \${lastRun}\`
1204
- })
1205
- ];
1206
- }
1207
- \`\`\``,
1208
- shell: `\`\`\`javascript
1209
- import { shell, section } from '@utils'
1210
-
1211
- export async function run() {
1212
- // Run command relative to the project directory
1213
- const stdout = await shell.exec('git status --short');
1214
- return [
1215
- section.create('git-status', {
1216
- type: 'markdown',
1217
- content: \`\\\`\\\`\\\`\\n\${stdout}\\n\\\`\\\`\\\`\`
1218
- })
1219
- ];
1220
- }
1221
- \`\`\``
1222
- };
1223
- async function compileIntro({ config, format, projectRoot, configRoot, hasProjectError }) {
1224
- const namespaces = walk(utils_api_default);
1225
- const activeRunes = [];
1226
- if (config && !hasProjectError) {
1227
- const runesList = Object.entries(config.runes ?? {});
1228
- for (const [key, entry] of runesList) {
1229
- const runeFile = resolve(configRoot, entry.path ?? `.crunes/runes/${key}.js`);
1230
- const basePerms = entry.permissions ?? { allow: [], deny: [] };
1231
- const effective = computeEffectivePermissions(basePerms, config.permissions?.[key], "args", configRoot);
1232
- let schema = null;
1233
- let schemaError = null;
1234
- try {
1235
- schema = await getArgsSchema(runeFile, effective, projectRoot, { vars: entry.vars ?? {} });
1236
- } catch (err) {
1237
- schemaError = err.message;
1238
- }
1239
- activeRunes.push({
1240
- key,
1241
- name: entry.name ?? key,
1242
- description: entry.description ?? null,
1243
- path: entry.path ?? `.crunes/runes/${key}.js`,
1244
- permissions: entry.permissions ?? { allow: [], deny: [] },
1245
- schema,
1246
- schemaError
1247
- });
1248
- }
1249
- }
1250
- if (format === "json") {
1251
- return JSON.stringify(
1252
- {
1253
- ecosystem: {
1254
- namespaces
1255
- },
1256
- workspace: config ? {
1257
- projectRoot,
1258
- configRoot,
1259
- runes: activeRunes,
1260
- plugins: config.plugins ?? []
1261
- } : null,
1262
- error: hasProjectError ?? null
1263
- },
1264
- null,
1265
- 2
1266
- );
1267
- }
1268
- const lines = [];
1269
- lines.push("# Crunes: Fast Sandboxed Scripting & Context Framework");
1270
- lines.push("");
1271
- lines.push("Crunes is designed as a way to rapidly draft useful scripts inside a project workspace, primarily utilized by AI coding agents to perform repeatable complex tasks such as context ingestion, application interaction, orchestration, and sandboxed file/command execution.");
1272
- lines.push("");
1273
- lines.push("## 1. Anatomy of a Rune");
1274
- lines.push("");
1275
- lines.push("Crunes execute inside an isolated sandbox (`isolated-vm`). Runes are ESM modules exporting a `run` method and an optional `args` method to declare schemas:");
1276
- lines.push("");
1277
- lines.push("```javascript");
1278
- lines.push("// Example Rune: git.js");
1279
- lines.push("export function args(builder) {");
1280
- lines.push(" return builder");
1281
- lines.push(" .option('--verbose', 'Verbose output', false)");
1282
- lines.push(" .command('remote', 'Manage git remotes', remote => {");
1283
- lines.push(" remote.command('add', 'Add remote', add => {");
1284
- lines.push(" add.positional('<name>', 'Remote name')");
1285
- lines.push(" .positional('<url>', 'Remote URL')");
1286
- lines.push(" })");
1287
- lines.push(" })");
1288
- lines.push("}");
1289
- lines.push("");
1290
- lines.push("export async function run(args) {");
1291
- lines.push(" if (args.$command === 'remote add') {");
1292
- lines.push(" return `Adding remote ${args.name} at ${args.url}`;");
1293
- lines.push(" }");
1294
- lines.push("}");
1295
- lines.push("```");
1296
- lines.push("");
1297
- lines.push("### Import System");
1298
- lines.push("");
1299
- lines.push("Rune files are ESM modules executed inside an isolated sandbox. The following import specifiers are supported:");
1300
- lines.push("");
1301
- lines.push("- **`from '@utils'`** \u2014 The standard utility namespace. Always available. Use this for all built-in capabilities (fs, shell, crypto, archive, etc.).");
1302
- lines.push("- **`from './relative'`** \u2014 Relative imports. Always available. Resolves relative to the current rune file. Ideal for shared helper modules within the same directory tree.");
1303
- lines.push("- **`from '@project/path'`** \u2014 Import from the project root. Requires `fs.read:<path>` in the rune's allow list.");
1304
- lines.push("- **`from '@plugin/path'`** \u2014 Plugin runes only. Resolves from the plugin's own root directory. Not available in project runes.");
1305
- lines.push("- **`from 'node:fs'` / `node:path` / etc.** \u2014 Always blocked. Node.js built-in modules are denied in the sandbox. Use the `@utils` equivalents: `utils.fs` for file I/O, `utils.shell` for process execution, `utils.crypto` for hashing/encryption.");
1306
- lines.push("");
1307
- lines.push("## 2. Rune Exports API Reference");
1308
- lines.push("");
1309
- lines.push("The sandboxed execution environment parses entrypoint exports to build schemas and run modules safely. Their dynamic type specification is detailed below:");
1310
- lines.push("");
1311
- const [lifecycleNs] = walk(lifecycle_api_default);
1312
- lines.push(formatMembers(lifecycleNs?.members ?? [], { indent: "" }));
1313
- lines.push("");
1314
- lines.push("## 3. Global Sandbox APIs");
1315
- lines.push("");
1316
- const [globalsNs] = walk(globals_api_default);
1317
- lines.push(formatMembers(globalsNs?.members ?? [], { indent: "" }));
1318
- lines.push("");
1319
- lines.push("## 4. CLI Calling & Argument Conventions");
1320
- lines.push("");
1321
- lines.push("Crunes enforces a strict 3-tier boundary when executing runes via the CLI. Misplacing flags will cause the parser to fail or misinterpret the arguments.");
1322
- lines.push("");
1323
- lines.push("### The Strict 3-Tier Parsing Boundary");
1324
- lines.push("All command invocations must follow this structural order exactly:");
1325
- lines.push("1. **Global Flags**: Options parsed by the core process (e.g. `--cwd <path>`, `-p` for plain output, `--verbose`).");
1326
- lines.push("2. **Command Flags**: Options parsed by the `use` command (e.g. `-b` / `--batch`, `--fail-fast`, `--format json`).");
1327
- lines.push("3. **Rune Arguments**: Config and positional values passed directly to the execution sandbox.");
1328
- lines.push("");
1329
- lines.push("```bash");
1330
- lines.push("# Correct Flag Placement");
1331
- lines.push('crunes --cwd ./project -p run --format json greeting "Alice"');
1332
- lines.push("```");
1333
- lines.push("");
1334
- lines.push("> [!WARNING]");
1335
- lines.push("> Placing a global flag after `run` (e.g. `crunes run --cwd ./project`) causes an instant error.");
1336
- lines.push("");
1337
- lines.push("### The Misplaced Flag Pitfall (Section Filters)");
1338
- lines.push("Section filtering flags (`-s` or `--section`) belong to the segment prefix *before* the rune key. If placed *after* the key, they are intercepted and treated as raw positional arguments inside the rune!");
1339
- lines.push("");
1340
- lines.push("```bash");
1341
- lines.push('# CORRECT: The filter is parsed successfully, outputting only the "endpoints" section');
1342
- lines.push("crunes run -s endpoints api v2");
1343
- lines.push("");
1344
- lines.push('# INCORRECT: Treated as positional args: args._ = ["--section", "endpoints"]');
1345
- lines.push("crunes run api v2 --section endpoints");
1346
- lines.push("```");
1347
- lines.push("");
1348
- lines.push("### Custom Commands & Nested Parameters Mapping");
1349
- lines.push("Runes can recursively nest commands using `.command()` on the builder. Inside `run(args)`, Crunes automatically exposes:");
1350
- lines.push('- **`args.$command`**: The space-separated matched command path string (e.g. `"remote add"`).');
1351
- lines.push('- **`args.$commands`**: The matched command path levels array (e.g. `["remote", "add"]`).');
1352
- lines.push("- **`args._`**: Data positionals only \u2014 command tokens are stripped, so `args._[0]` is always the first user-supplied value after the matched command.");
1353
- lines.push("- **Named Positionals**: Parameters like `<name>` or `[scope]` are automatically mapped to `args.name` or `args.scope`.");
1354
- lines.push("");
1355
- lines.push("### Batched Executions");
1356
- lines.push("Multiple runes can be run sequentially in one invocation using the `+` operator (requires the `-b` / `--batch` command flag):");
1357
- lines.push("```bash");
1358
- lines.push('crunes run -b -s endpoints api + greeting "World"');
1359
- lines.push("```");
1360
- lines.push("");
1361
- lines.push("### Hook Token Prompt Syntax");
1362
- lines.push("When using the Claude Code plugin (`crunes-aci`), prompt tokens are parsed automatically before submission:");
1363
- lines.push("- **`$key`**: Runs `key` with all sections.");
1364
- lines.push("- **`$key(arg1,arg2)`**: Passes positional arguments to `key`.");
1365
- lines.push("- **`$key::sec1,sec2`**: Section filters applied to `key`.");
1366
- lines.push("- **`$key(arg1)::sec1`**: Combination of positional argument and section filter.");
1367
- lines.push("");
1368
- lines.push("## 5. Configuration Reference");
1369
- lines.push("");
1370
- lines.push("Configuration properties in `.crunes/config.json` control permissions, default variables, mappings, and plugin registration.");
1371
- lines.push("");
1372
- lines.push("### Sandbox Security & Permissions");
1373
- lines.push("Runes do not have direct access to Node.js APIs. They declare specific lifecycle-scoped permission scopes in `.crunes/config.json`:");
1374
- lines.push("```json");
1375
- lines.push("{");
1376
- lines.push(' "runes": {');
1377
- lines.push(' "my-rune": {');
1378
- lines.push(' "name": "My Rune",');
1379
- lines.push(' "description": "Does something useful",');
1380
- lines.push(' "path": ".crunes/runes/my-rune.js",');
1381
- lines.push(' "vars": { "api_url": "https://example.com" }');
1382
- lines.push(" }");
1383
- lines.push(" },");
1384
- lines.push(' "permissions": {');
1385
- lines.push(' "my-rune": {');
1386
- lines.push(' "run": { "allow": ["fs.read:src/**", "fs.write:dist/**", "shell.run:git *"] }');
1387
- lines.push(" }");
1388
- lines.push(" }");
1389
- lines.push("}");
1390
- lines.push("```");
1391
- lines.push("");
1392
- lines.push("### Config File Fields Reference");
1393
- lines.push("- **`permissions`**: Mappings of permission templates scoped to specific runes.");
1394
- lines.push("- **`runes`**: Definition of project-registered runes, containing local filesystem paths, pre-declared vars, and metadata.");
1395
- lines.push("- **`vars`**: Key-value settings scoped to specific runes (accessible inside the isolate via `utils.vars.read(key)`).");
1396
- lines.push("- **`plugins`**: Mappings of enabled third-party marketplaces or plugins.");
1397
- lines.push("");
1398
- lines.push("## 6. Dynamic `@utils` Reference");
1399
- lines.push("");
1400
- lines.push("The following utility namespaces are available to runes in the execution isolate:");
1401
- lines.push("");
1402
- for (const ns of namespaces) {
1403
- lines.push(`### \`${ns.name}\``);
1404
- lines.push("");
1405
- if (ns.description) {
1406
- lines.push(ns.description);
1407
- lines.push("");
1408
- }
1409
- if (NAMESPACE_RECIPES[ns.name]) {
1410
- lines.push("**Usage Example:**");
1411
- lines.push(NAMESPACE_RECIPES[ns.name]);
1412
- lines.push("");
1413
- }
1414
- lines.push(formatNode(ns));
1415
- lines.push("");
1416
- lines.push("---");
1417
- lines.push("");
1418
- }
1419
- if (config) {
1420
- lines.push("## 7. Workspace Context");
1421
- lines.push("");
1422
- lines.push(`- **Project Root**: \`${projectRoot}\``);
1423
- lines.push(`- **Config Path**: \`${configRoot}\``);
1424
- lines.push("");
1425
- if (activeRunes.length > 0) {
1426
- lines.push("### Registered Project Runes");
1427
- lines.push("");
1428
- lines.push("| Key | Name | Path | Permissions (Allow) |");
1429
- lines.push("| --- | --- | --- | --- |");
1430
- for (const r of activeRunes) {
1431
- const allow = (r.permissions?.run?.allow ?? r.permissions?.allow ?? []).join(", ") || "*none*";
1432
- lines.push(`| \`${r.key}\` | ${r.name} | \`${r.path}\` | \`${allow}\` |`);
1433
- }
1434
- lines.push("");
1435
- lines.push("### Project Runes API & Usage");
1436
- lines.push("");
1437
- for (const r of activeRunes) {
1438
- lines.push(`#### Rune: \`${r.key}\``);
1439
- lines.push("");
1440
- if (r.schemaError) {
1441
- lines.push(`> [!WARNING]`);
1442
- lines.push(`> Could not load argument schema: ${r.schemaError}`);
1443
- } else if (r.schema) {
1444
- lines.push(formatHelp(r.schema, { key: r.key, name: r.name, description: r.description }));
1445
- } else {
1446
- lines.push("*No custom arguments registered.*");
1447
- }
1448
- lines.push("");
1449
- lines.push("---");
1450
- lines.push("");
1451
- }
1452
- }
1453
- const plugins = config.plugins ?? [];
1454
- if (plugins.length > 0) {
1455
- lines.push("### Enabled Plugins");
1456
- lines.push("");
1457
- for (const pluginName of plugins) {
1458
- lines.push(`- **${pluginName}**`);
1459
- }
1460
- lines.push("");
1461
- }
1462
- } else if (hasProjectError) {
1463
- lines.push("## 7. Workspace Context");
1464
- lines.push("");
1465
- lines.push(`> [!WARNING]`);
1466
- lines.push(`> Failed to resolve local project context: ${hasProjectError}`);
1467
- lines.push("");
1468
- } else {
1469
- lines.push("## 7. Workspace Context");
1470
- lines.push("");
1471
- lines.push("_No local project context loaded (global mode enabled)._");
1472
- lines.push("");
1473
- }
1474
- return lines.join("\n");
1475
- }
1476
-
1477
- // src/docs/commands/intro.js
1478
- async function handler({ global, out, format = "text", projectRoot = process.cwd(), configRoot = projectRoot }) {
1479
- let config = null;
1480
- let loadError = null;
1481
- if (!global) {
1482
- try {
1483
- config = loadConfig(configRoot);
1484
- } catch (err) {
1485
- loadError = err.message;
1486
- }
1487
- }
1488
- try {
1489
- const content = await compileIntro({
1490
- config,
1491
- format,
1492
- projectRoot,
1493
- configRoot,
1494
- hasProjectError: loadError
1495
- });
1496
- if (out) {
1497
- const targetPath = resolve2(process.cwd(), out);
1498
- writeFileSync(targetPath, content, "utf8");
1499
- output.info(`Successfully wrote Crunes intro to ${targetPath}`);
1500
- } else {
1501
- process.stdout.write(content + "\n");
1502
- }
1503
- } catch (err) {
1504
- output.error(`Failed to compile Crunes intro: ${err.message}`);
1505
- process.exit(1);
1506
- }
1507
- }
1508
- export {
1509
- handler
1510
- };