@austinthesing/magic-shell 0.2.11 → 0.2.14

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 (5) hide show
  1. package/README.md +135 -79
  2. package/dist/cli.js +47436 -11188
  3. package/dist/index.js +37717 -918
  4. package/dist/tui.js +47436 -11188
  5. package/package.json +8 -3
package/README.md CHANGED
@@ -7,7 +7,8 @@ Magic Shell is an open-source CLI tool that translates plain English (or any nat
7
7
  ## Features
8
8
 
9
9
  - **Natural Language Translation**: Describe what you want to do in plain English
10
- - **Multiple AI Providers**: OpenCode Zen (with free models!) and OpenRouter
10
+ - **Multiple AI Providers**: OpenCode Zen (with free models!), OpenRouter, and custom models (LM Studio, Ollama, OpenAI-compatible)
11
+ - **Custom Model Support**: Add your own local or remote models with secure API key storage
11
12
  - **Project Context Aware**: Opt-in detection of package.json scripts, Makefile targets, etc.
12
13
  - **Interactive TUI Mode**: Full-featured terminal interface with themes
13
14
  - **Command Safety Analysis**: Multi-level safety checks before executing commands
@@ -88,23 +89,26 @@ mshell
88
89
 
89
90
  ### Command Reference
90
91
 
91
- | Command | Description |
92
- |---------|-------------|
93
- | `msh <query>` | Translate query to command and print it |
94
- | `msh -x <query>` | Translate and execute the command |
95
- | `msh -n <query>` | Dry run - show command with safety analysis |
96
- | `mshell` | Launch interactive TUI mode |
97
- | `msh --setup` | Configure API keys and provider |
98
- | `msh --models` | List available models |
99
- | `msh --model <id>` | Set default model |
100
- | `msh --provider <name>` | Set provider (opencode-zen or openrouter) |
101
- | `msh --themes` | List available themes |
102
- | `msh --theme <name>` | Set color theme |
103
- | `msh --repo-context` | Enable project context detection |
104
- | `msh -r <query>` | Use project context for single query |
105
- | `msh --version` | Show version |
106
- | `msh --check-update` | Check for updates |
107
- | `msh --help` | Show help |
92
+ | Command | Description |
93
+ | ------------------------- | ------------------------------------------- |
94
+ | `msh <query>` | Translate query to command and print it |
95
+ | `msh -x <query>` | Translate and execute the command |
96
+ | `msh -n <query>` | Dry run - show command with safety analysis |
97
+ | `mshell` | Launch interactive TUI mode |
98
+ | `msh --setup` | Configure API keys and provider |
99
+ | `msh --models` | List available models |
100
+ | `msh --model <id>` | Set default model (including custom models) |
101
+ | `msh --add-model` | Add custom model (LM Studio, Ollama, etc.) |
102
+ | `msh --list-custom` | List custom models |
103
+ | `msh --remove-model <id>` | Remove custom model |
104
+ | `msh --provider <name>` | Set provider (opencode-zen or openrouter) |
105
+ | `msh --themes` | List available themes |
106
+ | `msh --theme <name>` | Set color theme |
107
+ | `msh --repo-context` | Enable project context detection |
108
+ | `msh -r <query>` | Use project context for single query |
109
+ | `msh --version` | Show version |
110
+ | `msh --check-update` | Check for updates |
111
+ | `msh --help` | Show help |
108
112
 
109
113
  ### Examples
110
114
 
@@ -139,21 +143,21 @@ Launch with `mshell` for a full interactive experience.
139
143
 
140
144
  All shortcuts use the `Ctrl+X` chord (press Ctrl+X, then the key):
141
145
 
142
- | Shortcut | Action |
143
- |----------|--------|
144
- | `Ctrl+X P` | Open command palette |
145
- | `Ctrl+X M` | Change model |
146
- | `Ctrl+X S` | Switch provider |
147
- | `Ctrl+X D` | Toggle dry-run mode |
148
- | `Ctrl+X T` | Change theme |
146
+ | Shortcut | Action |
147
+ | ---------- | ---------------------- |
148
+ | `Ctrl+X P` | Open command palette |
149
+ | `Ctrl+X M` | Change model |
150
+ | `Ctrl+X S` | Switch provider |
151
+ | `Ctrl+X D` | Toggle dry-run mode |
152
+ | `Ctrl+X T` | Change theme |
149
153
  | `Ctrl+X R` | Toggle project context |
150
- | `Ctrl+X H` | Show history |
151
- | `Ctrl+X C` | Show config |
152
- | `Ctrl+X L` | Clear output |
153
- | `Ctrl+X ?` | Show help |
154
- | `Ctrl+X Q` | Exit |
155
- | `Ctrl+C` | Exit / Cancel |
156
- | `Esc` | Close dialogs |
154
+ | `Ctrl+X H` | Show history |
155
+ | `Ctrl+X C` | Show config |
156
+ | `Ctrl+X L` | Clear output |
157
+ | `Ctrl+X ?` | Show help |
158
+ | `Ctrl+X Q` | Exit |
159
+ | `Ctrl+C` | Exit / Cancel |
160
+ | `Esc` | Close dialogs |
157
161
 
158
162
  ### Direct Commands in TUI
159
163
 
@@ -174,15 +178,21 @@ You can also type commands directly in the TUI:
174
178
  OpenCode Zen provides curated models optimized for coding tasks, including **free models**.
175
179
 
176
180
  **Free Models:**
181
+
177
182
  - `big-pickle` - Stealth model (default)
178
- - `grok-code` - xAI's Grok Code Fast 1
179
183
  - `glm-4.7` - GLM 4.7
184
+ - `minimax-m2.1` - MiniMax's capable model
185
+ - `kimi-k2.5` - Moonshot's latest model
180
186
 
181
187
  **Premium Models:**
188
+
182
189
  - Claude Sonnet 4.5, Claude Opus 4.5
190
+ - Claude Haiku 4.5
183
191
  - Kimi K2, Kimi K2 Thinking
184
192
  - Qwen3 Coder 480B
185
193
  - GLM 4.6
194
+ - Gemini 3 Pro, Gemini 3 Flash
195
+ - GPT 5.2, GPT 5.2 Codex, GPT 5.1 series
186
196
  - And more...
187
197
 
188
198
  Get your API key at: https://opencode.ai/auth
@@ -192,29 +202,71 @@ Get your API key at: https://opencode.ai/auth
192
202
  Access to a wide variety of models from different providers.
193
203
 
194
204
  **Free Models:**
205
+
195
206
  - MiMo V2 Flash
196
207
  - DeepSeek V3
197
208
 
198
209
  **Premium Models:**
210
+
199
211
  - Claude Sonnet 4.5, Claude Opus 4.5
212
+ - Claude Haiku 4.5
200
213
  - DeepSeek R1
201
214
  - GLM 4.7
215
+ - Gemini 2.5 Pro, Gemini 2.5 Flash (stable until June 2026)
202
216
  - And many more...
203
217
 
204
218
  Get your API key at: https://openrouter.ai/keys
205
219
 
220
+ ### Custom Models
221
+
222
+ Magic Shell supports custom models for local or remote OpenAI-compatible endpoints, including:
223
+
224
+ - **LM Studio** - Run models locally
225
+ - **Ollama** - Local model management
226
+ - **Any OpenAI-compatible API** - Self-hosted or third-party endpoints
227
+
228
+ **Adding a Custom Model:**
229
+
230
+ ```bash
231
+ # Interactive setup
232
+ msh --add-model
233
+
234
+ # You'll be prompted for:
235
+ # - Model ID (for referencing, e.g., "my-local-llama")
236
+ # - Display name (e.g., "Local Llama 3.2")
237
+ # - API model ID (sent to server, e.g., "llama-3.2-3b")
238
+ # - Base URL (e.g., "http://localhost:1234/v1")
239
+ # - API key (optional, stored securely in keychain)
240
+ # - Category (fast/smart/reasoning)
241
+ ```
242
+
243
+ **Managing Custom Models:**
244
+
245
+ ```bash
246
+ # List all custom models
247
+ msh --list-custom
248
+
249
+ # Set a custom model as default
250
+ msh --model my-local-llama
251
+
252
+ # Remove a custom model
253
+ msh --remove-model my-local-llama
254
+ ```
255
+
256
+ Custom model API keys are securely stored in your system keychain, just like provider API keys.
257
+
206
258
  ## Safety System
207
259
 
208
260
  Magic Shell includes a comprehensive safety analysis system that categorizes commands by risk level:
209
261
 
210
262
  ### Severity Levels
211
263
 
212
- | Level | Description | Examples |
213
- |-------|-------------|----------|
264
+ | Level | Description | Examples |
265
+ | ------------ | -------------------------------------- | --------------------------------------- |
214
266
  | **Critical** | Could cause irreversible system damage | `rm -rf /`, fork bombs, disk overwrites |
215
- | **High** | Significant changes or data loss risk | `sudo rm`, `kill -9 -1`, `shutdown` |
216
- | **Medium** | Requires elevated privileges | `sudo`, `chmod`, package removal |
217
- | **Low** | Worth reviewing | `git checkout`, `npm install` |
267
+ | **High** | Significant changes or data loss risk | `sudo rm`, `kill -9 -1`, `shutdown` |
268
+ | **Medium** | Requires elevated privileges | `sudo`, `chmod`, package removal |
269
+ | **Low** | Worth reviewing | `git checkout`, `npm install` |
218
270
 
219
271
  ### Safety Levels
220
272
 
@@ -227,6 +279,7 @@ Configure your preferred safety level:
227
279
  ### Blocked Commands
228
280
 
229
281
  Certain dangerous patterns are always blocked:
282
+
230
283
  - Fork bombs
231
284
  - Direct disk writes (`> /dev/sda`)
232
285
  - Filesystem formatting (`mkfs`)
@@ -247,17 +300,27 @@ Configuration is stored in `~/.magic-shell/config.json`.
247
300
  "repoContext": false,
248
301
  "theme": "opencode",
249
302
  "blockedCommands": [...],
250
- "confirmedDangerousPatterns": [...]
303
+ "confirmedDangerousPatterns": [...],
304
+ "customModels": [
305
+ {
306
+ "id": "my-local-llama",
307
+ "name": "Local Llama 3.2",
308
+ "modelId": "llama-3.2-3b",
309
+ "baseUrl": "http://localhost:1234/v1",
310
+ "contextLength": 128000,
311
+ "category": "smart"
312
+ }
313
+ ]
251
314
  }
252
315
  ```
253
316
 
254
317
  ### Environment Variables
255
318
 
256
- | Variable | Description |
257
- |----------|-------------|
258
- | `OPENCODE_ZEN_API_KEY` | API key for OpenCode Zen |
259
- | `OPENROUTER_API_KEY` | API key for OpenRouter |
260
- | `DEBUG_API=1` | Enable API response debugging |
319
+ | Variable | Description |
320
+ | ---------------------- | ----------------------------- |
321
+ | `OPENCODE_ZEN_API_KEY` | API key for OpenCode Zen |
322
+ | `OPENROUTER_API_KEY` | API key for OpenRouter |
323
+ | `DEBUG_API=1` | Enable API response debugging |
261
324
 
262
325
  ## Themes
263
326
 
@@ -273,6 +336,7 @@ Magic Shell includes 8 beautiful themes:
273
336
  - `matrix` - Classic green terminal
274
337
 
275
338
  Change themes:
339
+
276
340
  ```bash
277
341
  # CLI
278
342
  msh --theme tokyonight
@@ -295,12 +359,12 @@ Magic Shell automatically detects and adapts to your shell:
295
359
 
296
360
  ## Platform Support
297
361
 
298
- | Platform | Shell Detection | Keychain Storage |
299
- |----------|-----------------|------------------|
300
- | macOS | Full | macOS Keychain |
301
- | Linux | Full | libsecret (secret-tool) |
302
- | Windows | Full | Credential Manager |
303
- | WSL | Full (detected) | libsecret |
362
+ | Platform | Shell Detection | Keychain Storage |
363
+ | -------- | --------------- | ----------------------- |
364
+ | macOS | Full | macOS Keychain |
365
+ | Linux | Full | libsecret (secret-tool) |
366
+ | Windows | Full | Credential Manager |
367
+ | WSL | Full (detected) | libsecret |
304
368
 
305
369
  ## Development
306
370
 
@@ -351,18 +415,14 @@ src/
351
415
  ```json
352
416
  {
353
417
  "name": "@austinthesing/magic-shell",
354
- "version": "0.2.2",
418
+ "version": "0.2.13",
355
419
  "description": "Natural language to terminal commands with safety features",
356
420
  "main": "dist/index.js",
357
421
  "bin": {
358
- "msh": "./dist/index.js",
359
- "mshell": "./dist/tui.js"
422
+ "msh": "dist/index.js",
423
+ "mshell": "dist/tui.js"
360
424
  },
361
- "files": [
362
- "dist",
363
- "README.md",
364
- "LICENSE"
365
- ],
425
+ "files": ["dist", "README.md", "LICENSE"],
366
426
  "repository": {
367
427
  "type": "git",
368
428
  "url": "https://github.com/austin-thesing/magic-shell.git"
@@ -371,37 +431,30 @@ src/
371
431
  "bugs": {
372
432
  "url": "https://github.com/austin-thesing/magic-shell/issues"
373
433
  },
374
- "keywords": [
375
- "cli",
376
- "terminal",
377
- "natural-language",
378
- "shell",
379
- "ai",
380
- "openrouter",
381
- "opencode",
382
- "command-line"
383
- ],
434
+ "keywords": ["cli", "terminal", "natural-language", "shell", "ai", "openrouter", "opencode", "command-line"],
384
435
  "author": "Your Name <your@email.com>",
385
436
  "license": "MIT"
386
437
  }
387
438
  ```
388
439
 
389
440
  2. **Build the project:**
441
+
390
442
  ```bash
391
443
  bun run build
392
444
  ```
393
445
 
394
446
  3. **Test locally before publishing:**
447
+
395
448
  ```bash
396
449
  # Create a tarball
397
450
  npm pack
398
-
451
+
399
452
  # Install it globally to test
400
453
  npm install -g ./magic-shell-0.1.0.tgz
401
-
454
+
402
455
  # Test it works
403
456
  msh --help
404
-
457
+
405
458
  # Uninstall test version
406
459
  npm uninstall -g magic-shell
407
460
  ```
@@ -419,18 +472,20 @@ npm publish --access public
419
472
  ### Releasing New Versions
420
473
 
421
474
  1. **Update version** (follows [semver](https://semver.org/)):
475
+
422
476
  ```bash
423
477
  # Patch release (bug fixes): 0.1.0 -> 0.1.1
424
478
  npm version patch
425
-
479
+
426
480
  # Minor release (new features): 0.1.0 -> 0.2.0
427
481
  npm version minor
428
-
482
+
429
483
  # Major release (breaking changes): 0.1.0 -> 1.0.0
430
484
  npm version major
431
485
  ```
432
486
 
433
487
  2. **Push tags to GitHub:**
488
+
434
489
  ```bash
435
490
  git push origin main --tags
436
491
  ```
@@ -450,29 +505,29 @@ name: Release
450
505
  on:
451
506
  push:
452
507
  tags:
453
- - 'v*'
508
+ - "v*"
454
509
 
455
510
  jobs:
456
511
  release:
457
512
  runs-on: ubuntu-latest
458
513
  steps:
459
514
  - uses: actions/checkout@v4
460
-
515
+
461
516
  - uses: oven-sh/setup-bun@v1
462
517
  with:
463
518
  bun-version: latest
464
-
519
+
465
520
  - name: Install dependencies
466
521
  run: bun install
467
-
522
+
468
523
  - name: Build
469
524
  run: bun run build
470
-
525
+
471
526
  - name: Publish to npm
472
527
  run: npm publish
473
528
  env:
474
529
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
475
-
530
+
476
531
  - name: Create GitHub Release
477
532
  uses: softprops/action-gh-release@v1
478
533
  with:
@@ -480,6 +535,7 @@ jobs:
480
535
  ```
481
536
 
482
537
  Add your npm token to GitHub:
538
+
483
539
  1. Generate token at https://www.npmjs.com/settings/tokens (use "Automation" type)
484
540
  2. Add to repository secrets as `NPM_TOKEN`
485
541