@austinthesing/magic-shell 0.2.5 → 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/dist/cli.js +68 -9
- package/dist/index.js +17 -0
- package/dist/tui.js +68 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -22376,16 +22376,18 @@ function createMainUI() {
|
|
|
22376
22376
|
function getStatusBarContent() {
|
|
22377
22377
|
const theme = getTheme();
|
|
22378
22378
|
const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
|
|
22379
|
-
const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") :
|
|
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}]`);
|
|
22380
22382
|
const repoContextIndicator = config.repoContext ? fg(theme.colors.info)("[Repo]") : "";
|
|
22381
|
-
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}`;
|
|
22382
22384
|
}
|
|
22383
22385
|
function getHelpBarContent() {
|
|
22384
22386
|
const theme = getTheme();
|
|
22385
22387
|
if (awaitingConfirmation) {
|
|
22386
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")}`;
|
|
22387
22389
|
}
|
|
22388
|
-
return t`${fg(theme.colors.
|
|
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")}`;
|
|
22389
22391
|
}
|
|
22390
22392
|
function getWelcomeMessage() {
|
|
22391
22393
|
const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
|
|
@@ -22850,16 +22852,22 @@ function clearChat() {
|
|
|
22850
22852
|
addSystemMessage(getWelcomeMessage());
|
|
22851
22853
|
}
|
|
22852
22854
|
function showHelp() {
|
|
22853
|
-
const helpText = `
|
|
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...):
|
|
22854
22861
|
P Command palette M Change model
|
|
22855
22862
|
S Switch provider D Toggle dry-run
|
|
22856
22863
|
T Change theme R Toggle repo context
|
|
22857
22864
|
H Show history L Clear chat
|
|
22858
22865
|
C Show config ? This help
|
|
22859
|
-
Q Exit
|
|
22860
22866
|
|
|
22861
|
-
|
|
22862
|
-
|
|
22867
|
+
Safety Levels:
|
|
22868
|
+
- strict: Confirm ALL potentially dangerous commands
|
|
22869
|
+
- moderate: Confirm high/critical severity commands (default)
|
|
22870
|
+
- relaxed: Only confirm critical commands
|
|
22863
22871
|
|
|
22864
22872
|
Tips:
|
|
22865
22873
|
- Type naturally: "list all files" -> ls -la
|
|
@@ -23148,6 +23156,26 @@ function getCommandPaletteOptions() {
|
|
|
23148
23156
|
addSystemMessage(`Dry-run mode: ${dryRunMode ? "ON" : "OFF"}`);
|
|
23149
23157
|
}
|
|
23150
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
|
+
},
|
|
23151
23179
|
{
|
|
23152
23180
|
name: "Toggle Project Context",
|
|
23153
23181
|
description: config.repoContext ? "Currently ON (sends script names to AI)" : "Currently OFF",
|
|
@@ -23270,6 +23298,25 @@ function closeCommandPalette() {
|
|
|
23270
23298
|
}
|
|
23271
23299
|
function handleKeypress(key) {
|
|
23272
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
|
+
}
|
|
23273
23320
|
if (key.ctrl && key.name === "x") {
|
|
23274
23321
|
chordMode = "ctrl-x";
|
|
23275
23322
|
return;
|
|
@@ -23308,12 +23355,24 @@ function handleKeypress(key) {
|
|
|
23308
23355
|
inputField.focus();
|
|
23309
23356
|
return;
|
|
23310
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
|
+
}
|
|
23311
23370
|
if (providerSelector) {
|
|
23312
23371
|
renderer.destroy();
|
|
23313
23372
|
process.exit(0);
|
|
23314
23373
|
}
|
|
23315
|
-
|
|
23316
|
-
|
|
23374
|
+
addSystemMessage("Press Ctrl+Z to exit.");
|
|
23375
|
+
return;
|
|
23317
23376
|
}
|
|
23318
23377
|
if (key.name === "escape") {
|
|
23319
23378
|
chordMode = "none";
|
package/dist/index.js
CHANGED
|
@@ -1898,6 +1898,7 @@ ${colors.bold}USAGE${colors.reset}
|
|
|
1898
1898
|
msh --theme <name> Set color theme
|
|
1899
1899
|
msh --repo-context Enable project context detection
|
|
1900
1900
|
msh --no-repo-context Disable project context detection
|
|
1901
|
+
msh --safety <level> Set safety level (strict, moderate, relaxed)
|
|
1901
1902
|
msh --version Show version
|
|
1902
1903
|
msh --check-update Check for updates
|
|
1903
1904
|
msh --help Show this help
|
|
@@ -2331,6 +2332,22 @@ ${colors.bold}Available Themes${colors.reset}
|
|
|
2331
2332
|
console.log(`${colors.success}\u2713 Project context disabled${colors.reset}`);
|
|
2332
2333
|
return;
|
|
2333
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
|
+
}
|
|
2334
2351
|
let execute = false;
|
|
2335
2352
|
let dryRun = false;
|
|
2336
2353
|
let repoContext = undefined;
|
package/dist/tui.js
CHANGED
|
@@ -22376,16 +22376,18 @@ function createMainUI() {
|
|
|
22376
22376
|
function getStatusBarContent() {
|
|
22377
22377
|
const theme = getTheme();
|
|
22378
22378
|
const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
|
|
22379
|
-
const safeModeIndicator = dryRunMode ? fg(theme.colors.warning)("[DRY RUN]") :
|
|
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}]`);
|
|
22380
22382
|
const repoContextIndicator = config.repoContext ? fg(theme.colors.info)("[Repo]") : "";
|
|
22381
|
-
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}`;
|
|
22382
22384
|
}
|
|
22383
22385
|
function getHelpBarContent() {
|
|
22384
22386
|
const theme = getTheme();
|
|
22385
22387
|
if (awaitingConfirmation) {
|
|
22386
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")}`;
|
|
22387
22389
|
}
|
|
22388
|
-
return t`${fg(theme.colors.
|
|
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")}`;
|
|
22389
22391
|
}
|
|
22390
22392
|
function getWelcomeMessage() {
|
|
22391
22393
|
const providerName = config.provider === "opencode-zen" ? "OpenCode Zen" : "OpenRouter";
|
|
@@ -22850,16 +22852,22 @@ function clearChat() {
|
|
|
22850
22852
|
addSystemMessage(getWelcomeMessage());
|
|
22851
22853
|
}
|
|
22852
22854
|
function showHelp() {
|
|
22853
|
-
const helpText = `
|
|
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...):
|
|
22854
22861
|
P Command palette M Change model
|
|
22855
22862
|
S Switch provider D Toggle dry-run
|
|
22856
22863
|
T Change theme R Toggle repo context
|
|
22857
22864
|
H Show history L Clear chat
|
|
22858
22865
|
C Show config ? This help
|
|
22859
|
-
Q Exit
|
|
22860
22866
|
|
|
22861
|
-
|
|
22862
|
-
|
|
22867
|
+
Safety Levels:
|
|
22868
|
+
- strict: Confirm ALL potentially dangerous commands
|
|
22869
|
+
- moderate: Confirm high/critical severity commands (default)
|
|
22870
|
+
- relaxed: Only confirm critical commands
|
|
22863
22871
|
|
|
22864
22872
|
Tips:
|
|
22865
22873
|
- Type naturally: "list all files" -> ls -la
|
|
@@ -23148,6 +23156,26 @@ function getCommandPaletteOptions() {
|
|
|
23148
23156
|
addSystemMessage(`Dry-run mode: ${dryRunMode ? "ON" : "OFF"}`);
|
|
23149
23157
|
}
|
|
23150
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
|
+
},
|
|
23151
23179
|
{
|
|
23152
23180
|
name: "Toggle Project Context",
|
|
23153
23181
|
description: config.repoContext ? "Currently ON (sends script names to AI)" : "Currently OFF",
|
|
@@ -23270,6 +23298,25 @@ function closeCommandPalette() {
|
|
|
23270
23298
|
}
|
|
23271
23299
|
function handleKeypress(key) {
|
|
23272
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
|
+
}
|
|
23273
23320
|
if (key.ctrl && key.name === "x") {
|
|
23274
23321
|
chordMode = "ctrl-x";
|
|
23275
23322
|
return;
|
|
@@ -23308,12 +23355,24 @@ function handleKeypress(key) {
|
|
|
23308
23355
|
inputField.focus();
|
|
23309
23356
|
return;
|
|
23310
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
|
+
}
|
|
23311
23370
|
if (providerSelector) {
|
|
23312
23371
|
renderer.destroy();
|
|
23313
23372
|
process.exit(0);
|
|
23314
23373
|
}
|
|
23315
|
-
|
|
23316
|
-
|
|
23374
|
+
addSystemMessage("Press Ctrl+Z to exit.");
|
|
23375
|
+
return;
|
|
23317
23376
|
}
|
|
23318
23377
|
if (key.name === "escape") {
|
|
23319
23378
|
chordMode = "none";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@austinthesing/magic-shell",
|
|
3
|
-
"version": "0.2.
|
|
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",
|