@darkrymit/crunes-cli 0.4.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.
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/dist/cli.js +17699 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tamerlan Hurbanov (DarkRymit)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# @darkrymit/crunes-cli
|
|
2
|
+
|
|
3
|
+
CLI tool for managing and querying crunes. Part of the [crunes](https://github.com/darkrymit/context-runes) ecosystem.
|
|
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 <key> [-a <key>...] Use one or more runes and output the result (use --fail-fast to stop on error)
|
|
19
|
+
crunes bench [key] Time rune execution and report performance (use --runs <n> to average)
|
|
20
|
+
crunes list List all registered runes
|
|
21
|
+
crunes version Print the installed version and check for updates
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Template management:**
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
crunes template list [source] List available templates
|
|
28
|
+
crunes template use <key> Copy a template into the project as a new rune
|
|
29
|
+
crunes template create [name] Scaffold a new template file
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Plugin management:**
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
crunes plugin install <marketplace>@<plugin> Install a plugin from a configured marketplace
|
|
36
|
+
crunes plugin uninstall <name> Uninstall a plugin
|
|
37
|
+
crunes plugin list List installed plugins
|
|
38
|
+
crunes plugin update [name] Update one or all installed plugins
|
|
39
|
+
crunes plugin enable <name> Enable a disabled plugin
|
|
40
|
+
crunes plugin disable <name> Disable a plugin without uninstalling it
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Marketplace sources:**
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
crunes marketplace add <url> Add a marketplace source (URL or local path)
|
|
47
|
+
crunes marketplace remove <url> Remove a marketplace source
|
|
48
|
+
crunes marketplace list List configured sources
|
|
49
|
+
crunes marketplace search <query> Search for plugins across all sources
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Global flags:**
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
-v, --version Print version number (or --verbose / -v if a command is present)
|
|
56
|
+
-y, --yes Assume yes to all prompts (also auto-detected in non-TTY environments)
|
|
57
|
+
-p, --plain Plain output: no colors, no box-drawing — optimised for AI/pipe use
|
|
58
|
+
--cwd <path> Project root to use instead of the current working directory
|
|
59
|
+
--verbose, -v Print full stack traces on errors (contextual: -v acts as --verbose when a command is given)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Output formats** (for `use` and `list`):
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
--format md Human-readable markdown output (default)
|
|
66
|
+
--format json Machine-readable JSON — used by the Claude Code plugin hook
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Project Setup
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cd your-project
|
|
73
|
+
crunes init # creates .crunes/config.json
|
|
74
|
+
crunes create docs # scaffolds .crunes/runes/docs.js
|
|
75
|
+
crunes use docs # runs the rune and prints output
|
|
76
|
+
crunes use docs -a api=v2 # runs multiple runes in batch
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Key Syntax
|
|
80
|
+
|
|
81
|
+
Commands that accept a `<key>` (like `crunes use` and `crunes bench`) support the following syntax:
|
|
82
|
+
|
|
83
|
+
`[source:]name[=arg1,arg2][::section1,section2]`
|
|
84
|
+
|
|
85
|
+
- `name`: The name of the rune (auto-resolved from project config first, then plugins).
|
|
86
|
+
- `source:`: Forces resolution from a specific source.
|
|
87
|
+
- `local:name` resolves strictly from `.crunes/config.json`.
|
|
88
|
+
- `my-plugin:name` resolves strictly from an installed plugin.
|
|
89
|
+
- `=arg1,arg2`: Passes arguments to the rune (available as `args` in the API).
|
|
90
|
+
- `::section1,section2`: Filters the output to only return specific sections.
|
|
91
|
+
|
|
92
|
+
## Rune API
|
|
93
|
+
|
|
94
|
+
A rune is an ES module that exports a `generate` function:
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
export async function generate(dir, args, utils, opts) { ... }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Parameter | Description |
|
|
101
|
+
|---|---|
|
|
102
|
+
| `dir` | Absolute path to the project root |
|
|
103
|
+
| `args` | `string[]` parsed from `$key=arg1,arg2` tokens |
|
|
104
|
+
| `utils` | Injected utilities — see below |
|
|
105
|
+
| `opts` | Config options (e.g. `opts.sections` for performance hinting) |
|
|
106
|
+
|
|
107
|
+
### Return values
|
|
108
|
+
|
|
109
|
+
**Single section (Shape A):**
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
return { type: 'markdown', content: '...' };
|
|
113
|
+
// or
|
|
114
|
+
return { type: 'tree', root: utils.tree.node('src', 'Source root') };
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Multiple sections (Shape B):**
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
return [
|
|
121
|
+
utils.section('context', { type: 'markdown', content: '...' }, { title: 'Setup', attrs: { id: 'setup' } }),
|
|
122
|
+
utils.section('context', { type: 'tree', root: ... }, { title: 'Structure', attrs: { id: 'structure' } }),
|
|
123
|
+
];
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `utils.md` — Markdown builders
|
|
127
|
+
|
|
128
|
+
| Function | Output |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `md.h1(text)` | `# text\n` |
|
|
131
|
+
| `md.h2(text)` | `## text\n` |
|
|
132
|
+
| `md.h3(text)` | `### text\n` |
|
|
133
|
+
| `md.bold(text)` | `**text**` |
|
|
134
|
+
| `md.italic(text)` | `_text_` |
|
|
135
|
+
| `md.code(text)` | `` `text` `` |
|
|
136
|
+
| `md.codeBlock(text, lang?)` | fenced code block |
|
|
137
|
+
| `md.ul(items)` | unordered list |
|
|
138
|
+
| `md.ol(items)` | ordered list |
|
|
139
|
+
| `md.link(text, url)` | `[text](url)` |
|
|
140
|
+
| `md.table(headers, rows)` | GFM table |
|
|
141
|
+
|
|
142
|
+
### `utils.tree` — Tree builders
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
utils.tree.node(name, description, children?)
|
|
146
|
+
// → { name, description, children: [] }
|
|
147
|
+
|
|
148
|
+
utils.tree.format(root, { style: 'tree' | 'list', bullet: '-' | '*' | '+' }?)
|
|
149
|
+
// → formatted string
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### `utils.section` — Section builder
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
utils.section(name, data, { title?, attrs? }?)
|
|
156
|
+
// → { name, title, attrs, data }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `utils.fs` — Filesystem access
|
|
160
|
+
|
|
161
|
+
All paths are relative to `dir` and are sandboxed to the project root.
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
await utils.fs.read(relPath, { throw: true }?)
|
|
165
|
+
// → string | null (null only when throw: false and file missing)
|
|
166
|
+
|
|
167
|
+
await utils.fs.exists(relPath)
|
|
168
|
+
// → boolean
|
|
169
|
+
|
|
170
|
+
await utils.fs.glob(pattern, { ignore?: string[], onlyDirectories?: boolean }?)
|
|
171
|
+
// → string[] (forward-slash paths)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### `utils.shell` — Shell commands
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
await utils.shell(cmd, { throw: true, trim: true, timeout: 30000, env }?)
|
|
178
|
+
// → string (stdout) when trim: true (default)
|
|
179
|
+
// → { stdout, stderr, exitCode } when trim: false
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Throws `ShellError` (with `.stdout`, `.stderr`, `.exitCode`) on non-zero exit unless `throw: false`.
|
|
183
|
+
|
|
184
|
+
> **Plugin runes:** `utils.fs` and `utils.shell` are permission-gated. Allowed patterns are declared in `plugin.json` and shown during consent. Local runes have unrestricted access.
|
|
185
|
+
|
|
186
|
+
## Plugins
|
|
187
|
+
|
|
188
|
+
Plugins extend crunes with third-party runes. They run inside a V8 isolate (via `isolated-vm`) with explicit permission grants.
|
|
189
|
+
|
|
190
|
+
### Installing a plugin
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Add a marketplace source first
|
|
194
|
+
crunes marketplace add https://example.com/marketplace.json
|
|
195
|
+
# or a local path for development
|
|
196
|
+
crunes marketplace add ./my-plugin/.crunes-plugin
|
|
197
|
+
|
|
198
|
+
# Install from the marketplace
|
|
199
|
+
crunes plugin install my-marketplace@my-plugin
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Using a plugin rune
|
|
203
|
+
|
|
204
|
+
Plugin runes are addressed as `pluginName:runeKey`:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
crunes use my-plugin:some-rune
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Plugin manifest (`plugin.json`)
|
|
211
|
+
|
|
212
|
+
Plugins declare their runes and permissions in `.crunes-plugin/plugin.json`:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"format": "1",
|
|
217
|
+
"name": "my-plugin",
|
|
218
|
+
"version": "1.0.0",
|
|
219
|
+
"dependencies": { "semver": "^7.0.0" },
|
|
220
|
+
"runes": {
|
|
221
|
+
"some-rune": {
|
|
222
|
+
"permissions": {
|
|
223
|
+
"allow": ["fs.read:**", "shell:git log *"]
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Project-level permission overrides
|
|
231
|
+
|
|
232
|
+
Narrow or extend a plugin's permissions in `.crunes/config.json`:
|
|
233
|
+
|
|
234
|
+
```json
|
|
235
|
+
{
|
|
236
|
+
"plugins": ["my-plugin"],
|
|
237
|
+
"permissions": {
|
|
238
|
+
"my-plugin:some-rune": {
|
|
239
|
+
"allow": ["fs.read:src/**"],
|
|
240
|
+
"deny": ["shell:*"]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## CLI Output (`--format md`)
|
|
247
|
+
|
|
248
|
+
Each section renders as:
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
## {title or name}
|
|
252
|
+
[k: v] [k: v] ← omitted if no attrs
|
|
253
|
+
{rendered data}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Sections are separated by a blank line.
|
|
257
|
+
|
|
258
|
+
## Changelog
|
|
259
|
+
|
|
260
|
+
See [CHANGELOG.md](./CHANGELOG.md) for the full version history.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
MIT — [Tamerlan Hurbanov (DarkRymit)](https://github.com/darkrymit)
|