@austinthesing/magic-shell 0.2.4 → 0.2.7

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/README.md CHANGED
@@ -176,7 +176,7 @@ OpenCode Zen provides curated models optimized for coding tasks, including **fre
176
176
  **Free Models:**
177
177
  - `big-pickle` - Stealth model (default)
178
178
  - `grok-code` - xAI's Grok Code Fast 1
179
- - `glm-4.7-free` - GLM 4.7
179
+ - `glm-4.7` - GLM 4.7
180
180
  - `minimax-m2.1-free` - MiniMax M2.1
181
181
 
182
182
  **Premium Models:**
package/dist/cli.js CHANGED
@@ -20569,13 +20569,12 @@ var OPENCODE_ZEN_MODELS = [
20569
20569
  free: true
20570
20570
  },
20571
20571
  {
20572
- id: "glm-4.7-free",
20572
+ id: "glm-4.7",
20573
20573
  name: "GLM 4.7",
20574
- description: "Free GLM model (limited time)",
20574
+ description: "GLM model",
20575
20575
  category: "fast",
20576
20576
  provider: "opencode-zen",
20577
- contextLength: 128000,
20578
- free: true
20577
+ contextLength: 128000
20579
20578
  },
20580
20579
  {
20581
20580
  id: "minimax-m2.1-free",
@@ -22377,21 +22376,23 @@ function createMainUI() {
22377
22376
  function getStatusBarContent() {
22378
22377
  const theme = getTheme();
22379
22378
  const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
22380
- const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") : fg(theme.colors.success)("Safe");
22379
+ const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") : "";
22380
+ const safetyLevelColor = config.safetyLevel === "strict" ? theme.colors.warning : config.safetyLevel === "relaxed" ? theme.colors.error : theme.colors.success;
22381
+ const safetyIndicator = fg(safetyLevelColor)(`[${config.safetyLevel}]`);
22381
22382
  const repoContextIndicator = config.repoContext ? fg(theme.colors.info)("[Repo]") : "";
22382
- return t`${fg(theme.colors.textMuted)("Provider:")} ${fg(theme.colors.text)(providerName)} ${fg(theme.colors.textMuted)("Model:")} ${fg(theme.colors.text)(currentModel.name)} ${safeModeIndicator}${repoContextIndicator ? " " : ""}${repoContextIndicator}`;
22383
+ return t`${fg(theme.colors.textMuted)("Provider:")} ${fg(theme.colors.text)(providerName)} ${fg(theme.colors.textMuted)("Model:")} ${fg(theme.colors.text)(currentModel.name)} ${safetyIndicator}${safeModeIndicator ? " " : ""}${safeModeIndicator}${repoContextIndicator ? " " : ""}${repoContextIndicator}`;
22383
22384
  }
22384
22385
  function getHelpBarContent() {
22385
22386
  const theme = getTheme();
22386
22387
  if (awaitingConfirmation) {
22387
22388
  return t`${fg(theme.colors.warning)(">>> Press Enter to execute command <<<")} ${fg(theme.colors.textMuted)("|")} ${fg(theme.colors.error)("Esc")}${fg(theme.colors.textMuted)(" Cancel")} ${fg(theme.colors.primary)("e")}${fg(theme.colors.textMuted)(" Edit")} ${fg(theme.colors.primary)("c")}${fg(theme.colors.textMuted)(" Copy")}`;
22388
22389
  }
22389
- return t`${fg(theme.colors.textMuted)("Ctrl+X")} ${fg(theme.colors.primary)("P")}${fg(theme.colors.textMuted)(" Palette")} ${fg(theme.colors.primary)("M")}${fg(theme.colors.textMuted)(" Model")} ${fg(theme.colors.primary)("T")}${fg(theme.colors.textMuted)(" Theme")} ${fg(theme.colors.primary)("D")}${fg(theme.colors.textMuted)(" Dry-run")} ${fg(theme.colors.primary)("?")}${fg(theme.colors.textMuted)(" Help")}`;
22390
+ return t`${fg(theme.colors.primary)("Ctrl+X P")}${fg(theme.colors.textMuted)(" Commands")} ${fg(theme.colors.primary)("Ctrl+Y")}${fg(theme.colors.textMuted)(" Safety")} ${fg(theme.colors.primary)("Ctrl+Z")}${fg(theme.colors.textMuted)(" Exit")}`;
22390
22391
  }
22391
22392
  function getWelcomeMessage() {
22392
22393
  const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
22393
22394
  const freeNote = config.provider === "opencode-zen" ? `
22394
- Free models: big-pickle, glm-4.7-free` : "";
22395
+ Free models: big-pickle` : "";
22395
22396
  return `Ready. Using ${providerName}.${freeNote}
22396
22397
  Type what you want to do, or press Ctrl+X P for command palette.`;
22397
22398
  }
@@ -22851,16 +22852,22 @@ function clearChat() {
22851
22852
  addSystemMessage(getWelcomeMessage());
22852
22853
  }
22853
22854
  function showHelp() {
22854
- const helpText = `Keyboard Shortcuts (Ctrl+X then...):
22855
+ const helpText = `Direct Shortcuts:
22856
+ Ctrl+Y Cycle safety level (strict/moderate/relaxed)
22857
+ Ctrl+Z Exit magic-shell
22858
+ Ctrl+C Cancel / Close popup
22859
+
22860
+ Chord Shortcuts (Ctrl+X then...):
22855
22861
  P Command palette M Change model
22856
22862
  S Switch provider D Toggle dry-run
22857
22863
  T Change theme R Toggle repo context
22858
22864
  H Show history L Clear chat
22859
22865
  C Show config ? This help
22860
- Q Exit
22861
22866
 
22862
- Other:
22863
- Ctrl+C Exit / Cancel Esc Close palette
22867
+ Safety Levels:
22868
+ - strict: Confirm ALL potentially dangerous commands
22869
+ - moderate: Confirm high/critical severity commands (default)
22870
+ - relaxed: Only confirm critical commands
22864
22871
 
22865
22872
  Tips:
22866
22873
  - Type naturally: "list all files" -> ls -la
@@ -23149,6 +23156,26 @@ function getCommandPaletteOptions() {
23149
23156
  addSystemMessage(`Dry-run mode: ${dryRunMode ? "ON" : "OFF"}`);
23150
23157
  }
23151
23158
  },
23159
+ {
23160
+ name: "Cycle Safety Level",
23161
+ description: `Current: ${config.safetyLevel}`,
23162
+ key: "y",
23163
+ chord: "y",
23164
+ action: () => {
23165
+ const levels = ["moderate", "strict", "relaxed"];
23166
+ const currentIndex = levels.indexOf(config.safetyLevel);
23167
+ const nextIndex = (currentIndex + 1) % levels.length;
23168
+ config.safetyLevel = levels[nextIndex];
23169
+ saveConfig(config);
23170
+ statusBarText.content = getStatusBarContent();
23171
+ const descriptions = {
23172
+ strict: "confirms ALL potentially dangerous commands",
23173
+ moderate: "confirms high/critical severity commands",
23174
+ relaxed: "only confirms critical commands"
23175
+ };
23176
+ addSystemMessage(`Safety level: ${config.safetyLevel} (${descriptions[config.safetyLevel]})`);
23177
+ }
23178
+ },
23152
23179
  {
23153
23180
  name: "Toggle Project Context",
23154
23181
  description: config.repoContext ? "Currently ON (sends script names to AI)" : "Currently OFF",
@@ -23271,6 +23298,25 @@ function closeCommandPalette() {
23271
23298
  }
23272
23299
  function handleKeypress(key) {
23273
23300
  const commands = getCommandPaletteOptions();
23301
+ if (key.ctrl && key.name === "y") {
23302
+ const levels = ["moderate", "strict", "relaxed"];
23303
+ const currentIndex = levels.indexOf(config.safetyLevel);
23304
+ const nextIndex = (currentIndex + 1) % levels.length;
23305
+ config.safetyLevel = levels[nextIndex];
23306
+ saveConfig(config);
23307
+ statusBarText.content = getStatusBarContent();
23308
+ const descriptions = {
23309
+ strict: "confirms ALL potentially dangerous commands",
23310
+ moderate: "confirms high/critical severity commands",
23311
+ relaxed: "only confirms critical commands"
23312
+ };
23313
+ addSystemMessage(`Safety level: ${config.safetyLevel} (${descriptions[config.safetyLevel]})`);
23314
+ return;
23315
+ }
23316
+ if (key.ctrl && key.name === "z") {
23317
+ renderer.destroy();
23318
+ process.exit(0);
23319
+ }
23274
23320
  if (key.ctrl && key.name === "x") {
23275
23321
  chordMode = "ctrl-x";
23276
23322
  return;
@@ -23309,12 +23355,24 @@ function handleKeypress(key) {
23309
23355
  inputField.focus();
23310
23356
  return;
23311
23357
  }
23358
+ if (themeSelector) {
23359
+ renderer.root.remove("theme-selector-container");
23360
+ themeSelector = null;
23361
+ inputField.focus();
23362
+ return;
23363
+ }
23364
+ if (awaitingConfirmation && pendingMessageId) {
23365
+ clearCommandState();
23366
+ addSystemMessage("Command cancelled.");
23367
+ inputField.focus();
23368
+ return;
23369
+ }
23312
23370
  if (providerSelector) {
23313
23371
  renderer.destroy();
23314
23372
  process.exit(0);
23315
23373
  }
23316
- renderer.destroy();
23317
- process.exit(0);
23374
+ addSystemMessage("Press Ctrl+Z to exit.");
23375
+ return;
23318
23376
  }
23319
23377
  if (key.name === "escape") {
23320
23378
  chordMode = "none";
package/dist/index.js CHANGED
@@ -112,13 +112,12 @@ var OPENCODE_ZEN_MODELS = [
112
112
  free: true
113
113
  },
114
114
  {
115
- id: "glm-4.7-free",
115
+ id: "glm-4.7",
116
116
  name: "GLM 4.7",
117
- description: "Free GLM model (limited time)",
117
+ description: "GLM model",
118
118
  category: "fast",
119
119
  provider: "opencode-zen",
120
- contextLength: 128000,
121
- free: true
120
+ contextLength: 128000
122
121
  },
123
122
  {
124
123
  id: "minimax-m2.1-free",
@@ -1899,6 +1898,7 @@ ${colors.bold}USAGE${colors.reset}
1899
1898
  msh --theme <name> Set color theme
1900
1899
  msh --repo-context Enable project context detection
1901
1900
  msh --no-repo-context Disable project context detection
1901
+ msh --safety <level> Set safety level (strict, moderate, relaxed)
1902
1902
  msh --version Show version
1903
1903
  msh --check-update Check for updates
1904
1904
  msh --help Show this help
@@ -2332,6 +2332,22 @@ ${colors.bold}Available Themes${colors.reset}
2332
2332
  console.log(`${colors.success}\u2713 Project context disabled${colors.reset}`);
2333
2333
  return;
2334
2334
  }
2335
+ if (args[0] === "--safety" && args[1]) {
2336
+ const level = args[1].toLowerCase();
2337
+ if (level !== "strict" && level !== "moderate" && level !== "relaxed") {
2338
+ console.error(`${colors.error}Unknown safety level: ${level}${colors.reset}`);
2339
+ console.error(`Valid levels: strict, moderate, relaxed`);
2340
+ console.error(` strict - Confirm all potentially dangerous commands`);
2341
+ console.error(` moderate - Confirm high/critical severity commands (default)`);
2342
+ console.error(` relaxed - Only confirm critical commands`);
2343
+ process.exit(1);
2344
+ }
2345
+ const config = loadConfig();
2346
+ config.safetyLevel = level;
2347
+ saveConfig(config);
2348
+ console.log(`${colors.success}\u2713 Safety level set to ${level}${colors.reset}`);
2349
+ return;
2350
+ }
2335
2351
  let execute = false;
2336
2352
  let dryRun = false;
2337
2353
  let repoContext = undefined;
package/dist/tui.js CHANGED
@@ -20569,13 +20569,12 @@ var OPENCODE_ZEN_MODELS = [
20569
20569
  free: true
20570
20570
  },
20571
20571
  {
20572
- id: "glm-4.7-free",
20572
+ id: "glm-4.7",
20573
20573
  name: "GLM 4.7",
20574
- description: "Free GLM model (limited time)",
20574
+ description: "GLM model",
20575
20575
  category: "fast",
20576
20576
  provider: "opencode-zen",
20577
- contextLength: 128000,
20578
- free: true
20577
+ contextLength: 128000
20579
20578
  },
20580
20579
  {
20581
20580
  id: "minimax-m2.1-free",
@@ -22377,21 +22376,23 @@ function createMainUI() {
22377
22376
  function getStatusBarContent() {
22378
22377
  const theme = getTheme();
22379
22378
  const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
22380
- const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") : fg(theme.colors.success)("Safe");
22379
+ const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") : "";
22380
+ const safetyLevelColor = config.safetyLevel === "strict" ? theme.colors.warning : config.safetyLevel === "relaxed" ? theme.colors.error : theme.colors.success;
22381
+ const safetyIndicator = fg(safetyLevelColor)(`[${config.safetyLevel}]`);
22381
22382
  const repoContextIndicator = config.repoContext ? fg(theme.colors.info)("[Repo]") : "";
22382
- return t`${fg(theme.colors.textMuted)("Provider:")} ${fg(theme.colors.text)(providerName)} ${fg(theme.colors.textMuted)("Model:")} ${fg(theme.colors.text)(currentModel.name)} ${safeModeIndicator}${repoContextIndicator ? " " : ""}${repoContextIndicator}`;
22383
+ return t`${fg(theme.colors.textMuted)("Provider:")} ${fg(theme.colors.text)(providerName)} ${fg(theme.colors.textMuted)("Model:")} ${fg(theme.colors.text)(currentModel.name)} ${safetyIndicator}${safeModeIndicator ? " " : ""}${safeModeIndicator}${repoContextIndicator ? " " : ""}${repoContextIndicator}`;
22383
22384
  }
22384
22385
  function getHelpBarContent() {
22385
22386
  const theme = getTheme();
22386
22387
  if (awaitingConfirmation) {
22387
22388
  return t`${fg(theme.colors.warning)(">>> Press Enter to execute command <<<")} ${fg(theme.colors.textMuted)("|")} ${fg(theme.colors.error)("Esc")}${fg(theme.colors.textMuted)(" Cancel")} ${fg(theme.colors.primary)("e")}${fg(theme.colors.textMuted)(" Edit")} ${fg(theme.colors.primary)("c")}${fg(theme.colors.textMuted)(" Copy")}`;
22388
22389
  }
22389
- return t`${fg(theme.colors.textMuted)("Ctrl+X")} ${fg(theme.colors.primary)("P")}${fg(theme.colors.textMuted)(" Palette")} ${fg(theme.colors.primary)("M")}${fg(theme.colors.textMuted)(" Model")} ${fg(theme.colors.primary)("T")}${fg(theme.colors.textMuted)(" Theme")} ${fg(theme.colors.primary)("D")}${fg(theme.colors.textMuted)(" Dry-run")} ${fg(theme.colors.primary)("?")}${fg(theme.colors.textMuted)(" Help")}`;
22390
+ return t`${fg(theme.colors.primary)("Ctrl+X P")}${fg(theme.colors.textMuted)(" Commands")} ${fg(theme.colors.primary)("Ctrl+Y")}${fg(theme.colors.textMuted)(" Safety")} ${fg(theme.colors.primary)("Ctrl+Z")}${fg(theme.colors.textMuted)(" Exit")}`;
22390
22391
  }
22391
22392
  function getWelcomeMessage() {
22392
22393
  const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
22393
22394
  const freeNote = config.provider === "opencode-zen" ? `
22394
- Free models: big-pickle, glm-4.7-free` : "";
22395
+ Free models: big-pickle` : "";
22395
22396
  return `Ready. Using ${providerName}.${freeNote}
22396
22397
  Type what you want to do, or press Ctrl+X P for command palette.`;
22397
22398
  }
@@ -22851,16 +22852,22 @@ function clearChat() {
22851
22852
  addSystemMessage(getWelcomeMessage());
22852
22853
  }
22853
22854
  function showHelp() {
22854
- const helpText = `Keyboard Shortcuts (Ctrl+X then...):
22855
+ const helpText = `Direct Shortcuts:
22856
+ Ctrl+Y Cycle safety level (strict/moderate/relaxed)
22857
+ Ctrl+Z Exit magic-shell
22858
+ Ctrl+C Cancel / Close popup
22859
+
22860
+ Chord Shortcuts (Ctrl+X then...):
22855
22861
  P Command palette M Change model
22856
22862
  S Switch provider D Toggle dry-run
22857
22863
  T Change theme R Toggle repo context
22858
22864
  H Show history L Clear chat
22859
22865
  C Show config ? This help
22860
- Q Exit
22861
22866
 
22862
- Other:
22863
- Ctrl+C Exit / Cancel Esc Close palette
22867
+ Safety Levels:
22868
+ - strict: Confirm ALL potentially dangerous commands
22869
+ - moderate: Confirm high/critical severity commands (default)
22870
+ - relaxed: Only confirm critical commands
22864
22871
 
22865
22872
  Tips:
22866
22873
  - Type naturally: "list all files" -> ls -la
@@ -23149,6 +23156,26 @@ function getCommandPaletteOptions() {
23149
23156
  addSystemMessage(`Dry-run mode: ${dryRunMode ? "ON" : "OFF"}`);
23150
23157
  }
23151
23158
  },
23159
+ {
23160
+ name: "Cycle Safety Level",
23161
+ description: `Current: ${config.safetyLevel}`,
23162
+ key: "y",
23163
+ chord: "y",
23164
+ action: () => {
23165
+ const levels = ["moderate", "strict", "relaxed"];
23166
+ const currentIndex = levels.indexOf(config.safetyLevel);
23167
+ const nextIndex = (currentIndex + 1) % levels.length;
23168
+ config.safetyLevel = levels[nextIndex];
23169
+ saveConfig(config);
23170
+ statusBarText.content = getStatusBarContent();
23171
+ const descriptions = {
23172
+ strict: "confirms ALL potentially dangerous commands",
23173
+ moderate: "confirms high/critical severity commands",
23174
+ relaxed: "only confirms critical commands"
23175
+ };
23176
+ addSystemMessage(`Safety level: ${config.safetyLevel} (${descriptions[config.safetyLevel]})`);
23177
+ }
23178
+ },
23152
23179
  {
23153
23180
  name: "Toggle Project Context",
23154
23181
  description: config.repoContext ? "Currently ON (sends script names to AI)" : "Currently OFF",
@@ -23271,6 +23298,25 @@ function closeCommandPalette() {
23271
23298
  }
23272
23299
  function handleKeypress(key) {
23273
23300
  const commands = getCommandPaletteOptions();
23301
+ if (key.ctrl && key.name === "y") {
23302
+ const levels = ["moderate", "strict", "relaxed"];
23303
+ const currentIndex = levels.indexOf(config.safetyLevel);
23304
+ const nextIndex = (currentIndex + 1) % levels.length;
23305
+ config.safetyLevel = levels[nextIndex];
23306
+ saveConfig(config);
23307
+ statusBarText.content = getStatusBarContent();
23308
+ const descriptions = {
23309
+ strict: "confirms ALL potentially dangerous commands",
23310
+ moderate: "confirms high/critical severity commands",
23311
+ relaxed: "only confirms critical commands"
23312
+ };
23313
+ addSystemMessage(`Safety level: ${config.safetyLevel} (${descriptions[config.safetyLevel]})`);
23314
+ return;
23315
+ }
23316
+ if (key.ctrl && key.name === "z") {
23317
+ renderer.destroy();
23318
+ process.exit(0);
23319
+ }
23274
23320
  if (key.ctrl && key.name === "x") {
23275
23321
  chordMode = "ctrl-x";
23276
23322
  return;
@@ -23309,12 +23355,24 @@ function handleKeypress(key) {
23309
23355
  inputField.focus();
23310
23356
  return;
23311
23357
  }
23358
+ if (themeSelector) {
23359
+ renderer.root.remove("theme-selector-container");
23360
+ themeSelector = null;
23361
+ inputField.focus();
23362
+ return;
23363
+ }
23364
+ if (awaitingConfirmation && pendingMessageId) {
23365
+ clearCommandState();
23366
+ addSystemMessage("Command cancelled.");
23367
+ inputField.focus();
23368
+ return;
23369
+ }
23312
23370
  if (providerSelector) {
23313
23371
  renderer.destroy();
23314
23372
  process.exit(0);
23315
23373
  }
23316
- renderer.destroy();
23317
- process.exit(0);
23374
+ addSystemMessage("Press Ctrl+Z to exit.");
23375
+ return;
23318
23376
  }
23319
23377
  if (key.name === "escape") {
23320
23378
  chordMode = "none";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@austinthesing/magic-shell",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
4
4
  "description": "Natural language to terminal commands with safety features. Supports OpenCode Zen (with free models) and OpenRouter.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",