@darkrymit/crunes-cli 0.5.2 → 0.5.3

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 (3) hide show
  1. package/README.md +59 -578
  2. package/dist/cli.js +284 -32
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,625 +1,106 @@
1
1
  # @darkrymit/crunes-cli
2
2
 
3
- CLI tool for managing and querying crunes. Part of the [crunes](https://github.com/darkrymit/context-runes) ecosystem.
3
+ > Fast sandboxed scripting, isolated workspace execution, and dynamic context-ingestion framework.
4
4
 
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @darkrymit/crunes-cli
9
- ```
10
-
11
- Requires Node.js ≥ 20.
12
-
13
- ## Commands
14
-
15
- ```
16
- crunes init Create .crunes/config.json in the current project
17
- crunes create [key] Scaffold a new rune and register it in config
18
- crunes use [--section s] <key> [args...] [+ ...] Use one or more runes and output the result (use --fail-fast to stop on error)
19
- crunes check <key> Run a rune and validate its output shape
20
- crunes bench <key> Time rune execution and report fast/ok/slow (use --runs <n> to average, --warmup to add a discarded warm-up run)
21
- crunes list List all registered runes
22
- crunes job list List background jobs for the current project
23
- crunes job kill <id> Send SIGTERM to a job and remove its record (prefix match on id)
24
- crunes doctor Verify environment and project setup
25
- crunes version Print the installed version and check for updates
26
- crunes docs rune <key...> Show usage, argument schema, and examples for one or more runes
27
- crunes docs utils [namespaces...] Show function signatures and parameter docs for utils
28
- crunes completions install <shell> Install shell tab-completion hook (bash, zsh, fish, powershell)
29
- ```
30
-
31
- **Template management:**
32
-
33
- ```
34
- crunes template list [source] List available templates
35
- crunes template use [options] <template> Copy a template into the project as a new rune
36
- crunes template create [name] Scaffold a new template file
37
- ```
38
-
39
- **Plugin management:**
40
-
41
- ```
42
- crunes plugin install <marketplace>@<plugin> Install a plugin from a configured marketplace
43
- crunes plugin uninstall <name> Uninstall a plugin
44
- crunes plugin list List installed plugins
45
- crunes plugin update [name] Update one or all installed plugins
46
- crunes plugin enable <name> Enable a disabled plugin
47
- crunes plugin disable <name> Disable a plugin without uninstalling it
48
- ```
49
-
50
- **Marketplace sources:**
51
-
52
- ```
53
- crunes marketplace add <url> Add a marketplace source (URL or local path)
54
- crunes marketplace remove <url> Remove a marketplace source
55
- crunes marketplace list List configured sources
56
- crunes marketplace search <query> Search for plugins across all sources
57
- ```
58
-
59
- **Cache management:**
60
-
61
- ```
62
- crunes cache list List all registered cache buckets
63
- crunes cache clear <id> Remove expired keys from a cache bucket
64
- crunes cache delete <id> Delete a cache bucket and deregister it
65
- crunes cache unset <id> <key> Remove a single key from a cache bucket
66
- ```
67
-
68
- **SQLite management:**
69
-
70
- ```
71
- crunes sqlite list List all registered SQLite databases
72
- crunes sqlite delete <id> Delete a SQLite database and deregister it
73
- crunes sqlite query <id> <sql> Run a readonly SQL query against a registered database
74
- ```
75
-
76
- **Global flags:**
77
-
78
- ```
79
- -v, --version Print version number (or --verbose / -v if a command is present)
80
- -y, --yes Assume yes to all prompts (also auto-detected in non-TTY environments)
81
- -p, --plain Plain output: no colors, no box-drawing — optimised for AI/pipe use
82
- --cwd <path> Project root to use instead of the current working directory
83
- --verbose, -v Print full stack traces on errors (contextual: -v acts as --verbose when a command is given)
84
- ```
85
-
86
- **Output formats** (for `use` and `list`):
87
-
88
- ```
89
- --format md Human-readable markdown output (default)
90
- --format json Machine-readable JSON — used by the Claude Code plugin hook
91
- ```
92
-
93
- ## Project Setup
94
-
95
- ```bash
96
- cd your-project
97
- crunes init # creates .crunes/config.json
98
- crunes create docs # scaffolds .crunes/runes/docs.js
99
- crunes use docs # runs the rune and prints output
100
- crunes use -b docs + api v2 # runs multiple runes in batch
101
- ```
102
-
103
- ### The 3-Tier Parsing Boundary
104
-
105
- `crunes` parses arguments strictly from left to right in three tiers:
106
-
107
- 1. **Global Flags** (e.g. `--cwd`, `--verbose`, `-p`) MUST precede the command.
108
- 2. **Command Flags** (e.g. `-b`, `--format`) MUST immediately follow the command.
109
- 3. **Rune Arguments** (e.g. `--strict`, `src/`) MUST follow the rune key.
110
-
111
- ```bash
112
- # Correct: Global -> Command -> Command Flags -> Rune Key -> Rune Args
113
- crunes --cwd ./my-project use -b --format json myrune --strict
114
- ```
115
-
116
- If you misplace a global flag *after* the command (e.g. `crunes use --cwd ./dir myrune`), the CLI will intercept it and throw a strict validation error to prevent confusing behaviors.
117
-
118
- ## Key Syntax
119
-
120
- Commands that accept a `<key>` (like `crunes use`, `crunes bench`, and `crunes check`) use this syntax:
121
-
122
- ```
123
- [-b] [--section s1,s2] [source:]name [rune-arg ...]
124
- ```
125
-
126
- - `name`: The name of the rune (auto-resolved from project config first, then plugins).
127
- - `source:`: Forces resolution from a specific source.
128
- - `local:name` resolves strictly from `.crunes/config.json`.
129
- - `my-plugin:name` resolves strictly from an installed plugin.
130
- - `rune-arg ...`: Everything after the key is passed verbatim to the rune as `args._` (or parsed against the rune's `args()` schema if it exports one). This includes flags — `--verbose`, `--format`, etc.
131
- - `--section s1,s2`: Filters the output to only include the named sections (must appear before the key).
132
-
133
- `crunes use` accepts multiple rune segments separated by `+` if you pass the `-b` (batch) flag. Without `-b`, the `+` character is treated as a literal argument passed to the rune!
134
-
135
- ```bash
136
- crunes use -b structure + api v2
137
- crunes use -b --section layout structure + --section files api
138
- ```
139
-
140
- **Command-level flags must come before the first key.** The `use` command's own flags (`-b`, `--format`, `--fail-fast`) and `bench`'s flags (`--runs`, `--warmup`) are only recognised at the start of the argument list. Once the parser hits the first key, all remaining tokens (including flags) belong to the rune:
141
-
142
- ```bash
143
- # correct — command flags before the key
144
- crunes use -b --format json mykey --rune-flag val
145
-
146
- # rune receives --format as its own arg (command format stays 'md')
147
- crunes use mykey --format custom
148
- ```
149
-
150
- ## Rune API
151
-
152
- A rune is an ES module that exports a `use` function and imports utilities via `@utils`:
153
-
154
- ```js
155
- import { md, section } from '@utils'
156
-
157
- export async function use(args) {
158
- // args._ — positional arguments (string[])
159
- // args.verbose — named flag value (if args() export is defined)
160
- return section.create('my-section', {
161
- type: 'markdown',
162
- content: md.h3('Hello!'),
163
- })
164
- }
165
- ```
166
-
167
- Every namespace is a named export from `@utils`:
168
-
169
- ```js
170
- import { md, tree, section, fs, shell, json, yaml, xml,
171
- fetch, env, vars, archive, cache, sqlite, crypto, ws, time, rune } from '@utils'
172
- ```
173
-
174
- **Typed arguments** — export an `args` function using the builder API:
175
-
176
- ```js
177
- export async function args(b) {
178
- return b
179
- .option('-v, --verbose', 'Verbose output', false)
180
- .option('-c, --count <number>', 'Max results', 10)
181
- .positional('<target>', 'Target path')
182
- .example('crunes use myrune foo', 'Basic use')
183
- .build()
184
- }
185
- ```
186
-
187
- ### Return values
188
-
189
- **Single section:**
190
-
191
- ```js
192
- return section.create('my-section', { type: 'markdown', content: '...' })
193
- // or
194
- return section.create('my-section', { type: 'tree', root: tree.node('src', 'Source root') })
195
- ```
196
-
197
- **Multiple sections:**
198
-
199
- ```js
200
- return [
201
- section.create('setup', { type: 'markdown', content: '...' }),
202
- section.create('structure', { type: 'tree', root: tree.node('src', 'Source root') }),
203
- ]
204
- ```
205
-
206
- ---
207
-
208
- ### `md` — Markdown builders
209
-
210
- All functions are pure (no I/O).
211
-
212
- | Function | Output |
213
- |---|---|
214
- | `md.h1(text)` | `# text\n` |
215
- | `md.h2(text)` | `## text\n` |
216
- | `md.h3(text)` | `### text\n` |
217
- | `md.p(text)` | `text\n` |
218
- | `md.bold(text)` | `**text**` |
219
- | `md.italic(text)` | `_text_` |
220
- | `md.code(text)` | `` `text` `` |
221
- | `md.codeBlock(text, lang?)` | fenced code block |
222
- | `md.ul(items)` | unordered list |
223
- | `md.ol(items)` | ordered list |
224
- | `md.link(text, url)` | `[text](url)` |
225
- | `md.table(headers, rows)` | GFM table |
226
-
227
- ---
228
-
229
- ### `tree` — Tree builders
230
-
231
- Pure — no I/O.
232
-
233
- ```js
234
- tree.node(name, description, children?)
235
- // → { name, description, children: [] }
236
-
237
- tree.format(root, { style: 'tree' | 'list', bullet: '-' | '*' | '+' }?)
238
- // → formatted string
239
- ```
5
+ Crunes allows developers and AI coding agents to write and run secure, sandboxed scripts (`runes`) directly inside a project workspace. Runes execute within isolated V8 environments (`isolated-vm`), utilizing a granular capability-based permission model to interact with the filesystem, databases, and network APIs safely.
240
6
 
241
7
  ---
242
8
 
243
- ### `section` — Section builder
9
+ ## Key Features
244
10
 
245
- ```js
246
- section.create(name, data, { title?, attrs? }?)
247
- // → { name, title, attrs, data }
248
- // name must be kebab-case; data must be { type: 'markdown', content } or { type: 'tree', root }
249
-
250
- section.match(name)
251
- // → boolean — true if name matches the active --section filter (use for early-exit optimisation)
252
-
253
- section.selected()
254
- // → string[] | null — the active section filter list, or null if no filter is active
255
- ```
11
+ * **V8 Sandbox Isolation:** Runes are evaluated inside secure `isolated-vm` sandboxes with zero direct access to Node.js builtins.
12
+ * **Capability-Based Security:** Fine-grained whitelist and blacklist rules (e.g. `fs.read:src/**`, `http.fetch:GET:api.github.com`) configured at the project level.
13
+ * **Premium Developer Experience:** Modern modular scripting (`import { fs, section } from '@utils'`) with native TypeScript types and autocompletion.
14
+ * **Interactive Tooling:** Shell sessions, background daemon jobs, built-in SQLite/JSON/YAML parsers, and custom templates.
15
+ * **AI-First Design:** Outputs cleanly formatted Markdown structures optimised for AI context window ingestion and pipe/CLI pipelines.
256
16
 
257
17
  ---
258
18
 
259
- ### `fs` — Filesystem access
260
-
261
- Permission token: `fs.read:`, `fs.write:`, `fs.glob:` (local runes: unrestricted; plugin runes: declared in `plugin.json`).
262
-
263
- ```js
264
- fs.cwd()
265
- // → string — absolute path to the project root
266
-
267
- await fs.read(relPath, { throw: true }?)
268
- // → string | null (null only when throw: false and file missing)
269
-
270
- await fs.exists(relPath)
271
- // → boolean
272
-
273
- await fs.glob(pattern, { ignore?: string[], onlyDirectories?: boolean, dot?: boolean, expandDirectories?: boolean }?)
274
- // → string[] (forward-slash paths, relative to project root)
275
-
276
- await fs.write(relPath, content)
277
- // → void — creates parent directories automatically
278
-
279
- await fs.copy(src, dest)
280
- // → void — creates parent directories automatically; copies a single file
281
-
282
- await fs.replace(relPath, regex, replacement)
283
- // → void — reads, applies String.replace(regex, replacement), writes back
284
- ```
285
-
286
- **Path prefixes:**
287
-
288
- | Prefix | Resolves to |
289
- |---|---|
290
- | `relative/path` | Project root |
291
- | `@project/path` | Project root (explicit alias) |
292
- | `@plugin/path` | Plugin install directory (plugin runes only) |
293
- | `~/path` | User home directory |
294
-
295
- ---
296
-
297
- ### `shell` — Shell execution
298
-
299
- Permission token: `shell:<cmd-prefix>` (exact-prefix match against the full command string).
300
-
301
- ```js
302
- await shell(cmd, { throw?: true, trim?: true, timeout?: 30000, env?: {} }?)
303
- // → string when trim: true (default) — trimmed stdout
304
- // → { stdout, stderr, exitCode } when trim: false
305
- ```
306
-
307
- Throws `ShellError` (with `.stdout`, `.stderr`, `.exitCode`) on non-zero exit unless `throw: false`.
308
-
309
- ---
310
-
311
- ### `json` — JSON files
312
-
313
- Inherits `fs.read:` / `fs.write:` permission tokens.
314
-
315
- ```js
316
- await json.read(relPath, { throw?: true }?)
317
- // → object | null
318
-
319
- await json.get(relPath, jsonPath, defaultValue?)
320
- // → any — first JSONPath match, or defaultValue
321
-
322
- await json.getAll(relPath, jsonPath, defaultValue?)
323
- // → any[] — all JSONPath matches, or defaultValue (default: [])
324
-
325
- await json.write(relPath, data, { spaces?: 2 }?)
326
- // → void
327
-
328
- await json.modify(relPath, async (data, { exists }) => { ... }, { initial?, spaces?: 2 }?)
329
- // → void — reads file (or uses initial if missing), calls callback, writes result back
330
- // callback may return a new value or mutate data in place (return undefined = use mutated data)
331
- // throws if file missing and initial is not provided
332
- ```
333
-
334
- ---
335
-
336
- ### `yaml` — YAML files
337
-
338
- Inherits `fs.read:` / `fs.write:` permission tokens. Preserves comments and formatting on round-trips.
339
-
340
- ```js
341
- await yaml.read(relPath, { throw?: true }?)
342
- // → object | null
343
-
344
- await yaml.write(relPath, data, { indent?: 2 }?)
345
- // → void
346
-
347
- await yaml.modify(relPath, async (data, { exists }) => { ... }, { initial?, indent?: 2 }?)
348
- // → void — same semantics as json.modify
349
- ```
350
-
351
- ---
352
-
353
- ### `xml` — XML files
354
-
355
- Inherits `fs.read:` / `fs.write:` permission tokens. Attributes use `@_` prefix; comments use `#comment`.
356
-
357
- ```js
358
- await xml.read(relPath, { throw?: true }?)
359
- // → object | null
360
-
361
- await xml.write(relPath, data, { indent?: 2 }?)
362
- // → void
363
-
364
- await xml.modify(relPath, async (data, { exists }) => { ... }, { initial?, indent?: 2 }?)
365
- // → void — same semantics as json.modify
366
- ```
367
-
368
- ---
369
-
370
- ### `fetch` — HTTP client
371
-
372
- Permission token: `fetch:<METHOD>:<url>` (e.g., `fetch:GET:https://api.example.com/*`).
373
-
374
- ```js
375
- const res = await fetch(url, { method?: 'GET', headers?: {}, body?, timeout?: 30000 }?)
376
- // res.ok — boolean
377
- // res.status — number
378
- // res.statusText — string
379
- // res.headers — object
380
- // await res.text() — string
381
- // await res.json() — any
382
- ```
383
-
384
- Throws `FetchError` on network errors or timeouts.
385
-
386
- ---
387
-
388
- ### `env` — Environment variables
389
-
390
- Permission token: `env:<source>:<key-glob>` where source is `process` or a `.env` filename (e.g., `env:process:API_*`, `env:.env:*`).
391
-
392
- ```js
393
- env.get(key, fallback?)
394
- // → string | fallback — reads from process.env or .env files per allowed patterns
395
-
396
- env.has(key)
397
- // → boolean
398
- ```
399
-
400
- ---
401
-
402
- ### `vars` — Static config values
403
-
404
- Values come from the `vars` field in `.crunes/config.json` for the rune entry. No permission gate.
405
-
406
- ```js
407
- vars.get(key, fallback?)
408
- // → any
409
-
410
- vars.has(key)
411
- // → boolean
412
- ```
413
-
414
- ---
415
-
416
- ### `archive` — Compression
417
-
418
- Permission tokens: `fs.read:<source>` and `fs.write:<dest>`.
419
-
420
- ```js
421
- await archive.unzip(source, dest) // extracts a .zip into dest directory
422
- await archive.zip(source, dest) // zips a file or directory into dest
423
- await archive.untar(source, dest) // extracts a .tar.gz into dest directory
424
- await archive.tar(source, dest) // creates a .tar.gz from a file or directory
425
- ```
426
-
427
- Paths are relative to the project root. Zip-slip is detected and rejected.
428
-
429
- ---
430
-
431
- ### `cache` — Persistent key-value cache
432
-
433
- Permission tokens: `cache.read:<location>:<name>` and `cache.write:<location>:<name>`.
19
+ ## Installation
434
20
 
435
- ```js
436
- const store = await cache.open(location, name?)
437
- // location — virtual store token (see below) or relative path
438
- // name — sub-namespace within the location (default: 'default')
21
+ Install globally via `npm`:
439
22
 
440
- await store.set(key, value, ttl?) // ttl in seconds; omit for no expiry
441
- await store.get(key) // → value | null (expired entries return null)
442
- await store.delete(key)
443
- await store.clear() // removes all keys in this store
23
+ ```bash
24
+ npm install -g @darkrymit/crunes-cli
444
25
  ```
445
26
 
446
- **Virtual locations:**
447
-
448
- | Token | Scope |
449
- |---|---|
450
- | `@project-cache` | Project-scoped; local runes |
451
- | `@project-plugin-cache` | Project + plugin scoped (plugin runes) |
452
- | `@plugin-cache` | Plugin-global across all projects (plugin runes) |
453
-
454
- Values must be JSON-serializable. Stored as individual `.json` files on disk.
27
+ *Requires Node.js ≥ 20.*
455
28
 
456
29
  ---
457
30
 
458
- ### `sqlite` — SQLite databases
31
+ ## Quick Start
459
32
 
460
- Permission tokens: `sqlite.read:<location>:<name>` and `sqlite.write:<location>:<name>`.
33
+ Initialize a project, scaffold a rune, and execute it:
461
34
 
462
- ```js
463
- const db = await sqlite.open(location, name?)
464
- // location — virtual store token or relative path
465
- // name — database filename without extension (default: 'default' → 'default.sqlite')
466
-
467
- db.query(sql, params?) // → any[] — all matching rows
468
- db.get(sql, params?) // → any | null — first matching row or null
469
- db.exec(sql, params?) // → { changes, lastInsertRowid }
470
- await db.transaction(async () => { ... }) // auto-commits; rolls back on throw
471
- db.close() // closes the connection (auto-closed at rune exit)
472
- ```
473
-
474
- **Virtual locations:**
475
-
476
- | Token | Scope |
477
- |---|---|
478
- | `@project-sqlite` | Project-scoped; local runes |
479
- | `@project-plugin-sqlite` | Project + plugin scoped (plugin runes) |
480
- | `@plugin-sqlite` | Plugin-global across all projects (plugin runes) |
481
-
482
- WAL mode is enabled automatically.
483
-
484
- ---
485
-
486
- ### `crypto` — Cryptographic utilities
35
+ ```bash
36
+ cd your-project
487
37
 
488
- No permission gate. Synchronous.
38
+ # Initialize .crunes/config.json
39
+ crunes init
489
40
 
490
- ```js
491
- crypto.hash.hex(algorithm, data) // → hex string (e.g. algorithm: 'sha256')
492
- crypto.hash.base64(algorithm, data) // → base64 string
41
+ # Scaffold a new rune (.crunes/runes/fetch-status.js)
42
+ crunes create fetch-status
493
43
 
494
- crypto.uuid() // → v4 UUID string
495
- crypto.hex(size) // → hex-encoded random bytes (size = byte count)
496
- crypto.base64(size) // → base64-encoded random bytes
44
+ # Run the rune and output the markdown sections
45
+ crunes use fetch-status
497
46
  ```
498
47
 
499
48
  ---
500
49
 
501
- ### `ws` — WebSocket Client
502
-
503
- Permission token: `ws:<url>`.
504
-
505
- ```js
506
- const session = utils.ws.client(url, opts?)
507
- // session.on(event, handler)
508
- // await session.open()
509
- // await session.send(msg)
510
- // await session.close()
511
- ```
50
+ ## Commands
512
51
 
513
- ---
52
+ ```bash
53
+ # Core Operations
54
+ crunes init # Create .crunes/config.json in current project
55
+ crunes create [key] # Scaffold a new rune and register it in config
56
+ crunes use <key> [args...] # Run a rune (use -b for batch execution)
57
+ crunes check <key> # Execute a rune and validate its return schema
58
+ crunes bench <key> # Profile execution time (fast/ok/slow)
59
+ crunes list # List all registered local and plugin runes
514
60
 
515
- ### `time` — Time Utilities
61
+ # Interactive Documentation (Dynamic CLI Help)
62
+ crunes docs intro # Compile workspace and ecosystem handbook
63
+ crunes docs rune <key...> # Show arguments schema, help, and usages
64
+ crunes docs utils [namespaces...] # Show detailed signatures for the @utils API
516
65
 
517
- No permission gate.
66
+ # Background Daemon Jobs
67
+ crunes job list # List background jobs for the project
68
+ crunes job kill <id> # Forcefully terminate a running background job
518
69
 
519
- ```js
520
- await time.after(ms) // → Promise that resolves after ms milliseconds
70
+ # Templates, Plugins, and Markets
71
+ crunes template list # List available rune templates
72
+ crunes template use <name> # Copy a template as a new local rune
73
+ crunes plugin install <pkg> # Install a secure plugin from marketplace
74
+ crunes plugin list # List active marketplace plugins
75
+ crunes marketplace add <url> # Register a marketplace source
521
76
  ```
522
77
 
523
78
  ---
524
79
 
525
- ### `rune` — Call other runes
526
-
527
- Inherits the target rune's permissions. Circular calls throw `CircularRuneError`.
528
-
529
- ```js
530
- const sections = await rune.use(key, args?)
531
- // key — bare key or plugin:key
532
- // args — string[] of positional arguments
533
- // → Section[]
534
-
535
- const job = await rune.spawn(key, args?)
536
- // → { id, projectKey } — spawns rune in the background
537
-
538
- await rune.kill(id, signal?)
539
- // → void — sends signal (default: SIGTERM) to the job
80
+ ## Ecosystem Documentation
540
81
 
541
- const exists = await rune.exists(id)
542
- // → boolean — true if job process is still running
543
- ```
544
-
545
- ## Plugins
546
-
547
- Plugins extend crunes with third-party runes. They run inside a V8 isolate (via `isolated-vm`) with explicit permission grants.
548
-
549
- ### Installing a plugin
82
+ Crunes features a fully dynamic documentation engine built directly into the CLI. Rather than keeping static, outdated markdown guides, you can compile up-to-date workspace handbooks containing precise types, active schemas, and active permissions:
550
83
 
84
+ ### 1. Compile the Ecosystem & Workspace Handbook
85
+ Generates a comprehensive `INTRO.md` containing sandboxed ESM recipes, permission tokens, active workspace settings, and current plugins:
551
86
  ```bash
552
- # Add a marketplace source first
553
- crunes marketplace add https://example.com/marketplace.json
554
- # or a local path for development
555
- crunes marketplace add ./my-plugin/.crunes-plugin
556
-
557
- # Install from the marketplace
558
- crunes plugin install my-marketplace@my-plugin
87
+ crunes docs intro --out INTRO.md
559
88
  ```
560
89
 
561
- ### Using a plugin rune
562
-
563
- Plugin runes are addressed as `pluginName:runeKey`:
564
-
90
+ ### 2. Query `@utils` Sandbox API Signatures
91
+ Read function parameters, return values, fields, and permission restrictions dynamically compiled from TypeScript declarations:
565
92
  ```bash
566
- crunes use my-plugin:some-rune
93
+ crunes docs utils fs sqlite
567
94
  ```
568
95
 
569
- ### Plugin manifest (`plugin.json`)
570
-
571
- Plugins declare their runes and permissions in `.crunes-plugin/plugin.json`:
572
-
573
- ```json
574
- {
575
- "format": "1",
576
- "name": "my-plugin",
577
- "version": "1.0.0",
578
- "dependencies": { "semver": "^7.0.0" },
579
- "runes": {
580
- "some-rune": {
581
- "permissions": {
582
- "use": {
583
- "allow": ["fs.read:**", "shell:git log *"]
584
- }
585
- }
586
- }
587
- }
588
- }
589
- ```
590
-
591
- ### Project-level permission overrides
592
-
593
- Narrow or extend a plugin's permissions in `.crunes/config.json`:
594
-
595
- ```json
596
- {
597
- "plugins": ["my-plugin"],
598
- "permissions": {
599
- "my-plugin:some-rune": {
600
- "allow": ["fs.read:src/**"],
601
- "deny": ["shell:*"]
602
- }
603
- }
604
- }
605
- ```
606
-
607
- ## CLI Output (`--format md`)
608
-
609
- Each section renders as:
610
-
611
- ```
612
- ## {title or name}
613
- [k: v] [k: v] ← omitted if no attrs
614
- {rendered data}
96
+ ### 3. Check Custom Rune Schemas
97
+ Read custom arguments, positional parameters, and examples for any of your local or plugin-registered runes:
98
+ ```bash
99
+ crunes docs rune fetch-status
615
100
  ```
616
101
 
617
- Sections are separated by a blank line.
618
-
619
- ## Changelog
620
-
621
- See [CHANGELOG.md](./CHANGELOG.md) for the full version history.
102
+ ---
622
103
 
623
104
  ## License
624
105
 
625
- MIT — [Tamerlan Hurbanov (DarkRymit)](https://github.com/darkrymit)
106
+ MIT © [Tamerlan Hurbanov (DarkRymit)](https://github.com/darkrymit)
package/dist/cli.js CHANGED
@@ -75941,7 +75941,23 @@ var init_utils_api = __esm({
75941
75941
  summary: [
75942
75942
  {
75943
75943
  kind: "text",
75944
- text: "Creates a .tar.gz archive from a file or directory."
75944
+ text: "Creates a .tar.gz archive from a file or directory.\nRequires "
75945
+ },
75946
+ {
75947
+ kind: "code",
75948
+ text: "`fs.read:<source>`"
75949
+ },
75950
+ {
75951
+ kind: "text",
75952
+ text: " and "
75953
+ },
75954
+ {
75955
+ kind: "code",
75956
+ text: "`fs.write:<dest>`"
75957
+ },
75958
+ {
75959
+ kind: "text",
75960
+ text: " permissions."
75945
75961
  }
75946
75962
  ]
75947
75963
  },
@@ -76021,7 +76037,23 @@ var init_utils_api = __esm({
76021
76037
  summary: [
76022
76038
  {
76023
76039
  kind: "text",
76024
- text: "Extracts a .tar.gz archive to a destination directory."
76040
+ text: "Extracts a .tar.gz archive to a destination directory.\nRequires "
76041
+ },
76042
+ {
76043
+ kind: "code",
76044
+ text: "`fs.read:<source>`"
76045
+ },
76046
+ {
76047
+ kind: "text",
76048
+ text: " and "
76049
+ },
76050
+ {
76051
+ kind: "code",
76052
+ text: "`fs.write:<dest>`"
76053
+ },
76054
+ {
76055
+ kind: "text",
76056
+ text: " permissions."
76025
76057
  }
76026
76058
  ]
76027
76059
  },
@@ -76101,7 +76133,23 @@ var init_utils_api = __esm({
76101
76133
  summary: [
76102
76134
  {
76103
76135
  kind: "text",
76104
- text: "Extracts a ZIP archive to a destination directory."
76136
+ text: "Extracts a ZIP archive to a destination directory.\nRequires "
76137
+ },
76138
+ {
76139
+ kind: "code",
76140
+ text: "`fs.read:<source>`"
76141
+ },
76142
+ {
76143
+ kind: "text",
76144
+ text: " and "
76145
+ },
76146
+ {
76147
+ kind: "code",
76148
+ text: "`fs.write:<dest>`"
76149
+ },
76150
+ {
76151
+ kind: "text",
76152
+ text: " permissions."
76105
76153
  }
76106
76154
  ]
76107
76155
  },
@@ -76181,7 +76229,23 @@ var init_utils_api = __esm({
76181
76229
  summary: [
76182
76230
  {
76183
76231
  kind: "text",
76184
- text: "Creates a ZIP archive from a file or directory."
76232
+ text: "Creates a ZIP archive from a file or directory.\nRequires "
76233
+ },
76234
+ {
76235
+ kind: "code",
76236
+ text: "`fs.read:<source>`"
76237
+ },
76238
+ {
76239
+ kind: "text",
76240
+ text: " and "
76241
+ },
76242
+ {
76243
+ kind: "code",
76244
+ text: "`fs.write:<dest>`"
76245
+ },
76246
+ {
76247
+ kind: "text",
76248
+ text: " permissions."
76185
76249
  }
76186
76250
  ]
76187
76251
  },
@@ -76313,7 +76377,15 @@ var init_utils_api = __esm({
76313
76377
  summary: [
76314
76378
  {
76315
76379
  kind: "text",
76316
- text: "Delete all entries in this cache"
76380
+ text: "Delete all entries in this cache.\nRequires "
76381
+ },
76382
+ {
76383
+ kind: "code",
76384
+ text: "`cache.write:<location>:<name>`"
76385
+ },
76386
+ {
76387
+ kind: "text",
76388
+ text: " permission."
76317
76389
  }
76318
76390
  ]
76319
76391
  },
@@ -76353,7 +76425,15 @@ var init_utils_api = __esm({
76353
76425
  summary: [
76354
76426
  {
76355
76427
  kind: "text",
76356
- text: "Delete a single entry"
76428
+ text: "Delete a single entry.\nRequires "
76429
+ },
76430
+ {
76431
+ kind: "code",
76432
+ text: "`cache.write:<location>:<name>`"
76433
+ },
76434
+ {
76435
+ kind: "text",
76436
+ text: " permission."
76357
76437
  }
76358
76438
  ]
76359
76439
  },
@@ -76406,7 +76486,15 @@ var init_utils_api = __esm({
76406
76486
  summary: [
76407
76487
  {
76408
76488
  kind: "text",
76409
- text: "Retrieve a value, or null if absent or expired"
76489
+ text: "Retrieve a value, or null if absent or expired.\nRequires "
76490
+ },
76491
+ {
76492
+ kind: "code",
76493
+ text: "`cache.read:<location>:<name>`"
76494
+ },
76495
+ {
76496
+ kind: "text",
76497
+ text: " permission."
76410
76498
  }
76411
76499
  ]
76412
76500
  },
@@ -76459,7 +76547,15 @@ var init_utils_api = __esm({
76459
76547
  summary: [
76460
76548
  {
76461
76549
  kind: "text",
76462
- text: "Store a value. ttl is time-to-live in seconds."
76550
+ text: "Store a value. ttl is time-to-live in seconds.\nRequires "
76551
+ },
76552
+ {
76553
+ kind: "code",
76554
+ text: "`cache.write:<location>:<name>`"
76555
+ },
76556
+ {
76557
+ kind: "text",
76558
+ text: " permission."
76463
76559
  }
76464
76560
  ]
76465
76561
  },
@@ -77012,7 +77108,15 @@ var init_utils_api = __esm({
77012
77108
  summary: [
77013
77109
  {
77014
77110
  kind: "text",
77015
- text: "Returns true if the environment variable exists and is permitted."
77111
+ text: "Returns true if the environment variable exists and is permitted.\nRequires "
77112
+ },
77113
+ {
77114
+ kind: "code",
77115
+ text: "`env.read:<source>:<key>`"
77116
+ },
77117
+ {
77118
+ kind: "text",
77119
+ text: " permission (where source is 'process' or a .env filename like '.env')."
77016
77120
  }
77017
77121
  ]
77018
77122
  },
@@ -77073,7 +77177,15 @@ var init_utils_api = __esm({
77073
77177
  summary: [
77074
77178
  {
77075
77179
  kind: "text",
77076
- text: "Returns the value of an environment variable, or fallback if absent."
77180
+ text: "Returns the value of an environment variable, or fallback if absent.\nRequires "
77181
+ },
77182
+ {
77183
+ kind: "code",
77184
+ text: "`env.read:<source>:<key>`"
77185
+ },
77186
+ {
77187
+ kind: "text",
77188
+ text: " permission (where source is 'process' or a .env filename like '.env')."
77077
77189
  }
77078
77190
  ]
77079
77191
  },
@@ -77198,7 +77310,23 @@ var init_utils_api = __esm({
77198
77310
  summary: [
77199
77311
  {
77200
77312
  kind: "text",
77201
- text: "Copies a file from src to dest."
77313
+ text: "Copies a file from src to dest.\nRequires "
77314
+ },
77315
+ {
77316
+ kind: "code",
77317
+ text: "`fs.read:<src>`"
77318
+ },
77319
+ {
77320
+ kind: "text",
77321
+ text: " and "
77322
+ },
77323
+ {
77324
+ kind: "code",
77325
+ text: "`fs.write:<dest>`"
77326
+ },
77327
+ {
77328
+ kind: "text",
77329
+ text: " permissions."
77202
77330
  }
77203
77331
  ]
77204
77332
  },
@@ -77306,7 +77434,15 @@ var init_utils_api = __esm({
77306
77434
  summary: [
77307
77435
  {
77308
77436
  kind: "text",
77309
- text: "Returns true if the path exists."
77437
+ text: "Returns true if the path exists.\nRequires "
77438
+ },
77439
+ {
77440
+ kind: "code",
77441
+ text: "`fs.read:<path>`"
77442
+ },
77443
+ {
77444
+ kind: "text",
77445
+ text: " permission."
77310
77446
  }
77311
77447
  ]
77312
77448
  },
@@ -77367,7 +77503,15 @@ var init_utils_api = __esm({
77367
77503
  summary: [
77368
77504
  {
77369
77505
  kind: "text",
77370
- text: "Returns file paths matching a glob pattern. Relative patterns only."
77506
+ text: "Returns file paths matching a glob pattern. Relative patterns only.\nRequires "
77507
+ },
77508
+ {
77509
+ kind: "code",
77510
+ text: "`fs.glob:<pattern>`"
77511
+ },
77512
+ {
77513
+ kind: "text",
77514
+ text: " permission."
77371
77515
  }
77372
77516
  ]
77373
77517
  },
@@ -77550,7 +77694,15 @@ var init_utils_api = __esm({
77550
77694
  summary: [
77551
77695
  {
77552
77696
  kind: "text",
77553
- text: "Reads a file as a UTF-8 string. Returns null if not found and throw is false."
77697
+ text: "Reads a file as a UTF-8 string. Returns null if not found and throw is false.\nRequires "
77698
+ },
77699
+ {
77700
+ kind: "code",
77701
+ text: "`fs.read:<path>`"
77702
+ },
77703
+ {
77704
+ kind: "text",
77705
+ text: " permission."
77554
77706
  }
77555
77707
  ]
77556
77708
  },
@@ -77661,7 +77813,23 @@ var init_utils_api = __esm({
77661
77813
  summary: [
77662
77814
  {
77663
77815
  kind: "text",
77664
- text: "Reads a file, applies a regex replacement, and writes it back."
77816
+ text: "Reads a file, applies a regex replacement, and writes it back.\nRequires "
77817
+ },
77818
+ {
77819
+ kind: "code",
77820
+ text: "`fs.read:<path>`"
77821
+ },
77822
+ {
77823
+ kind: "text",
77824
+ text: " and "
77825
+ },
77826
+ {
77827
+ kind: "code",
77828
+ text: "`fs.write:<path>`"
77829
+ },
77830
+ {
77831
+ kind: "text",
77832
+ text: " permissions."
77665
77833
  }
77666
77834
  ]
77667
77835
  },
@@ -77838,7 +78006,15 @@ var init_utils_api = __esm({
77838
78006
  summary: [
77839
78007
  {
77840
78008
  kind: "text",
77841
- text: "Writes content to a file, creating parent directories as needed."
78009
+ text: "Writes content to a file, creating parent directories as needed.\nRequires "
78010
+ },
78011
+ {
78012
+ kind: "code",
78013
+ text: "`fs.write:<path>`"
78014
+ },
78015
+ {
78016
+ kind: "text",
78017
+ text: " permission."
77842
78018
  }
77843
78019
  ]
77844
78020
  },
@@ -78142,7 +78318,15 @@ var init_utils_api = __esm({
78142
78318
  summary: [
78143
78319
  {
78144
78320
  kind: "text",
78145
- text: "Makes an HTTP request. Requires fetch:<METHOD>:<url> permission."
78321
+ text: "Makes an HTTP request. Requires "
78322
+ },
78323
+ {
78324
+ kind: "code",
78325
+ text: "`http.fetch:<METHOD>:<url>`"
78326
+ },
78327
+ {
78328
+ kind: "text",
78329
+ text: " permission."
78146
78330
  }
78147
78331
  ]
78148
78332
  },
@@ -80490,7 +80674,15 @@ var init_utils_api = __esm({
80490
80674
  summary: [
80491
80675
  {
80492
80676
  kind: "text",
80493
- text: "Executes a fire-and-forget shell command and returns the output."
80677
+ text: "Executes a fire-and-forget shell command and returns the output.\nRequires "
80678
+ },
80679
+ {
80680
+ kind: "code",
80681
+ text: "`shell.exec:<command>`"
80682
+ },
80683
+ {
80684
+ kind: "text",
80685
+ text: " permission."
80494
80686
  }
80495
80687
  ],
80496
80688
  blockTags: [
@@ -80730,7 +80922,15 @@ var init_utils_api = __esm({
80730
80922
  summary: [
80731
80923
  {
80732
80924
  kind: "text",
80733
- text: "Starts a shell session for interactive or background execution."
80925
+ text: "Starts a shell session for interactive or background execution.\nRequires "
80926
+ },
80927
+ {
80928
+ kind: "code",
80929
+ text: "`shell.exec:<command>`"
80930
+ },
80931
+ {
80932
+ kind: "text",
80933
+ text: " permission."
80734
80934
  }
80735
80935
  ],
80736
80936
  blockTags: [
@@ -80955,7 +81155,15 @@ var init_utils_api = __esm({
80955
81155
  summary: [
80956
81156
  {
80957
81157
  kind: "text",
80958
- text: "Run INSERT/UPDATE/DELETE. Returns { changes, lastInsertRowid }"
81158
+ text: "Run INSERT/UPDATE/DELETE. Returns { changes, lastInsertRowid }.\nRequires "
81159
+ },
81160
+ {
81161
+ kind: "code",
81162
+ text: "`sqlite.write:<location>:<name>`"
81163
+ },
81164
+ {
81165
+ kind: "text",
81166
+ text: " permission."
80959
81167
  }
80960
81168
  ]
80961
81169
  },
@@ -81063,7 +81271,15 @@ var init_utils_api = __esm({
81063
81271
  summary: [
81064
81272
  {
81065
81273
  kind: "text",
81066
- text: "Run a SELECT and return the first row, or null"
81274
+ text: "Run a SELECT and return the first row, or null.\nRequires "
81275
+ },
81276
+ {
81277
+ kind: "code",
81278
+ text: "`sqlite.read:<location>:<name>`"
81279
+ },
81280
+ {
81281
+ kind: "text",
81282
+ text: " permission."
81067
81283
  }
81068
81284
  ]
81069
81285
  },
@@ -81132,7 +81348,15 @@ var init_utils_api = __esm({
81132
81348
  summary: [
81133
81349
  {
81134
81350
  kind: "text",
81135
- text: "Run a SELECT and return all rows"
81351
+ text: "Run a SELECT and return all rows.\nRequires "
81352
+ },
81353
+ {
81354
+ kind: "code",
81355
+ text: "`sqlite.read:<location>:<name>`"
81356
+ },
81357
+ {
81358
+ kind: "text",
81359
+ text: " permission."
81136
81360
  }
81137
81361
  ]
81138
81362
  },
@@ -81204,7 +81428,15 @@ var init_utils_api = __esm({
81204
81428
  summary: [
81205
81429
  {
81206
81430
  kind: "text",
81207
- text: "Wrap multiple exec calls in a transaction. Rolls back on error."
81431
+ text: "Wrap multiple exec calls in a transaction. Rolls back on error.\nRequires "
81432
+ },
81433
+ {
81434
+ kind: "code",
81435
+ text: "`sqlite.write:<location>:<name>`"
81436
+ },
81437
+ {
81438
+ kind: "text",
81439
+ text: " permission."
81208
81440
  }
81209
81441
  ]
81210
81442
  },
@@ -82874,7 +83106,15 @@ var init_utils_api = __esm({
82874
83106
  summary: [
82875
83107
  {
82876
83108
  kind: "text",
82877
- text: "Creates a WebSocket client handle. Call open() before send()."
83109
+ text: "Creates a WebSocket client handle. Call open() before send().\nRequires "
83110
+ },
83111
+ {
83112
+ kind: "code",
83113
+ text: "`ws.client:<url>`"
83114
+ },
83115
+ {
83116
+ kind: "text",
83117
+ text: " permission."
82878
83118
  }
82879
83119
  ]
82880
83120
  },
@@ -86530,7 +86770,7 @@ async function compileIntro({ config, format: format3, projectRoot, configRoot,
86530
86770
  lines.push("The following utility namespaces are available to runes in the execution isolate:");
86531
86771
  lines.push("");
86532
86772
  for (const ns2 of namespaces) {
86533
- lines.push(`### \`utils.${ns2.namespace}\``);
86773
+ lines.push(`### \`${ns2.namespace}\``);
86534
86774
  lines.push("");
86535
86775
  if (ns2.description) {
86536
86776
  lines.push(ns2.description);
@@ -86616,17 +86856,22 @@ var init_intro_compiler = __esm({
86616
86856
  init_permissions();
86617
86857
  NAMESPACE_RECIPES = {
86618
86858
  fs: `\`\`\`javascript
86619
- import { fs } from '@utils'
86859
+ import { fs, section } from '@utils'
86620
86860
 
86621
86861
  export async function use() {
86622
86862
  // Read and write files relative to the project root
86623
86863
  const content = await fs.read('src/components/Button.jsx');
86624
86864
  await fs.write('dist/output.txt', 'Hello Sandbox!');
86625
- return 'File written successfully!';
86865
+ return [
86866
+ section.create('fs-result', {
86867
+ type: 'markdown',
86868
+ content: 'File written successfully!'
86869
+ })
86870
+ ];
86626
86871
  }
86627
86872
  \`\`\``,
86628
86873
  ws: `\`\`\`javascript
86629
- import { ws, section } from '@utils'
86874
+ import { ws, time, section } from '@utils'
86630
86875
 
86631
86876
  export async function use() {
86632
86877
  const socket = ws.client('ws://localhost:8080');
@@ -86641,6 +86886,7 @@ export async function use() {
86641
86886
  await socket.sendText(JSON.stringify({ type: 'PING' }));
86642
86887
 
86643
86888
  // Wait a moment for replies, then close
86889
+ await time.after(500);
86644
86890
  await socket.close();
86645
86891
 
86646
86892
  return [
@@ -86660,6 +86906,7 @@ export async function use() {
86660
86906
  await db.exec('CREATE TABLE IF NOT EXISTS logs (id TEXT PRIMARY KEY, msg TEXT)');
86661
86907
  await db.exec('INSERT INTO logs VALUES (?, ?)', [crypto.uuid(), 'Rune executed!']);
86662
86908
  const rows = await db.query('SELECT * FROM logs');
86909
+ await db.close();
86663
86910
 
86664
86911
  return [
86665
86912
  section.create('db-logs', {
@@ -86686,13 +86933,18 @@ export async function use() {
86686
86933
  }
86687
86934
  \`\`\``,
86688
86935
  cache: `\`\`\`javascript
86689
- import { cache } from '@utils'
86936
+ import { cache, section } from '@utils'
86690
86937
 
86691
86938
  export async function use() {
86692
86939
  const projectCache = await cache.open('@project-cache');
86693
86940
  await projectCache.set('last-run', Date.now(), 60); // 60s TTL
86694
86941
  const lastRun = await projectCache.get('last-run');
86695
- return \`Last run timestamp: \${lastRun}\`;
86942
+ return [
86943
+ section.create('cache-result', {
86944
+ type: 'markdown',
86945
+ content: \`Last run timestamp: \${lastRun}\`
86946
+ })
86947
+ ];
86696
86948
  }
86697
86949
  \`\`\``,
86698
86950
  shell: `\`\`\`javascript
@@ -86765,7 +87017,7 @@ var init_package = __esm({
86765
87017
  "package.json"() {
86766
87018
  package_default = {
86767
87019
  name: "@darkrymit/crunes-cli",
86768
- version: "0.5.2",
87020
+ version: "0.5.3",
86769
87021
  description: "CLI tool for querying crunes enrichers",
86770
87022
  type: "module",
86771
87023
  bin: {
@@ -92225,7 +92477,7 @@ var {
92225
92477
  init_output();
92226
92478
  function buildProgram() {
92227
92479
  const program3 = new Command();
92228
- program3.name("crunes").description("CLI tool for managing context runes").version("0.5.2", "-v, --version").enablePositionalOptions().option("-y, --yes", "assume yes to all prompts and skip interactive mode (also auto-detected in non-TTY environments)").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").option("--cwd <path>", "project root to use instead of the current working directory").option("--ccd <path>", "config directory \u2014 where .crunes/config.json and local rune files live (default: --cwd)").option("--verbose", "print full error stack traces and other verbose output");
92480
+ program3.name("crunes").description("CLI tool for managing context runes").version("0.5.3", "-v, --version").enablePositionalOptions().option("-y, --yes", "assume yes to all prompts and skip interactive mode (also auto-detected in non-TTY environments)").option("-p, --plain", "plain output: no colors, no box-drawing, plain symbols \u2014 optimised for AI/pipe use").option("--cwd <path>", "project root to use instead of the current working directory").option("--ccd <path>", "config directory \u2014 where .crunes/config.json and local rune files live (default: --cwd)").option("--verbose", "print full error stack traces and other verbose output");
92229
92481
  program3.hook("preAction", (_thisCommand, actionCommand) => {
92230
92482
  configure({ plain: !!program3.opts().plain, verbose: !!program3.opts().verbose });
92231
92483
  if (program3.opts().verbose) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkrymit/crunes-cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "CLI tool for querying crunes enrichers",
5
5
  "type": "module",
6
6
  "bin": {