@austinthesing/magic-shell 0.2.29 → 1.0.1

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 +95 -590
  2. package/dist/cli.js +762 -425
  3. package/dist/index.js +229 -50
  4. package/dist/tui.js +762 -425
  5. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2111,7 +2111,7 @@ var require_src = __commonJS((exports) => {
2111
2111
  });
2112
2112
 
2113
2113
  // src/index.ts
2114
- import { spawn } from "child_process";
2114
+ import { spawn as spawn2 } from "child_process";
2115
2115
  import { cwd as getCwd } from "process";
2116
2116
 
2117
2117
  // src/lib/models.ts
@@ -2119,7 +2119,7 @@ var OPENROUTER_MODELS = [
2119
2119
  {
2120
2120
  id: "deepseek/deepseek-v4-flash:free",
2121
2121
  name: "DeepSeek V4 Flash (Free)",
2122
- description: "DeepSeek's fast open-source model on OpenRouter's free tier (rate-limited)",
2122
+ description: "Fast DeepSeek coding model on OpenRouter's free tier.",
2123
2123
  category: "fast",
2124
2124
  provider: "openrouter",
2125
2125
  contextLength: 1048576,
@@ -2128,7 +2128,7 @@ var OPENROUTER_MODELS = [
2128
2128
  {
2129
2129
  id: "deepseek/deepseek-v4-flash",
2130
2130
  name: "DeepSeek V4 Flash",
2131
- description: "DeepSeek's latest fast open-source model",
2131
+ description: "Fast DeepSeek coding model with a large context window.",
2132
2132
  category: "fast",
2133
2133
  provider: "openrouter",
2134
2134
  contextLength: 1048576,
@@ -2137,7 +2137,7 @@ var OPENROUTER_MODELS = [
2137
2137
  {
2138
2138
  id: "z-ai/glm-5.2",
2139
2139
  name: "GLM 5.2",
2140
- description: "Z.ai's latest fast GLM model",
2140
+ description: "Fast GLM model for low-cost command generation.",
2141
2141
  category: "fast",
2142
2142
  provider: "openrouter",
2143
2143
  contextLength: 202752,
@@ -2146,7 +2146,7 @@ var OPENROUTER_MODELS = [
2146
2146
  {
2147
2147
  id: "moonshotai/kimi-k2.7-code",
2148
2148
  name: "Kimi K2.7 Code",
2149
- description: "Moonshot's latest open-weight coding model",
2149
+ description: "Open-weight coding model for larger code tasks.",
2150
2150
  category: "smart",
2151
2151
  provider: "openrouter",
2152
2152
  contextLength: 262144,
@@ -2155,7 +2155,7 @@ var OPENROUTER_MODELS = [
2155
2155
  {
2156
2156
  id: "deepseek/deepseek-v4-pro",
2157
2157
  name: "DeepSeek V4 Pro",
2158
- description: "DeepSeek's latest high-context open-source model",
2158
+ description: "High-context DeepSeek model for larger code tasks.",
2159
2159
  category: "smart",
2160
2160
  provider: "openrouter",
2161
2161
  contextLength: 1048576,
@@ -2164,7 +2164,7 @@ var OPENROUTER_MODELS = [
2164
2164
  {
2165
2165
  id: "anthropic/claude-sonnet-4.6",
2166
2166
  name: "Claude Sonnet 4.6",
2167
- description: "Anthropic's latest Sonnet model",
2167
+ description: "Balanced Claude model for harder coding tasks.",
2168
2168
  category: "smart",
2169
2169
  provider: "openrouter",
2170
2170
  contextLength: 1e6,
@@ -2173,7 +2173,7 @@ var OPENROUTER_MODELS = [
2173
2173
  {
2174
2174
  id: "openai/gpt-5.5",
2175
2175
  name: "GPT 5.5",
2176
- description: "OpenAI's latest flagship GPT model",
2176
+ description: "Flagship GPT model for complex shell tasks.",
2177
2177
  category: "smart",
2178
2178
  provider: "openrouter",
2179
2179
  contextLength: 1050000,
@@ -2182,7 +2182,7 @@ var OPENROUTER_MODELS = [
2182
2182
  {
2183
2183
  id: "anthropic/claude-opus-4.8",
2184
2184
  name: "Claude Opus 4.8",
2185
- description: "Anthropic's latest Opus model",
2185
+ description: "Top Claude reasoning model for complex tasks.",
2186
2186
  category: "reasoning",
2187
2187
  provider: "openrouter",
2188
2188
  contextLength: 1e6,
@@ -2193,7 +2193,7 @@ var VERCEL_AI_GATEWAY_MODELS = [
2193
2193
  {
2194
2194
  id: "openai/gpt-5.5",
2195
2195
  name: "GPT 5.5",
2196
- description: "OpenAI's latest flagship GPT model",
2196
+ description: "Flagship GPT model for complex shell tasks.",
2197
2197
  category: "smart",
2198
2198
  provider: "vercel-ai-gateway",
2199
2199
  contextLength: 1050000,
@@ -2202,7 +2202,7 @@ var VERCEL_AI_GATEWAY_MODELS = [
2202
2202
  {
2203
2203
  id: "anthropic/claude-sonnet-4.6",
2204
2204
  name: "Claude Sonnet 4.6",
2205
- description: "Anthropic's latest Sonnet model",
2205
+ description: "Balanced Claude model for harder coding tasks.",
2206
2206
  category: "smart",
2207
2207
  provider: "vercel-ai-gateway",
2208
2208
  contextLength: 1e6,
@@ -2211,7 +2211,7 @@ var VERCEL_AI_GATEWAY_MODELS = [
2211
2211
  {
2212
2212
  id: "anthropic/claude-opus-4.8",
2213
2213
  name: "Claude Opus 4.8",
2214
- description: "Anthropic's latest Opus model",
2214
+ description: "Top Claude reasoning model for complex tasks.",
2215
2215
  category: "reasoning",
2216
2216
  provider: "vercel-ai-gateway",
2217
2217
  contextLength: 1e6,
@@ -2231,7 +2231,7 @@ var CLOUDFLARE_AI_GATEWAY_MODELS = [
2231
2231
  {
2232
2232
  id: "openai/gpt-5.5",
2233
2233
  name: "GPT 5.5",
2234
- description: "OpenAI's latest flagship GPT model through Cloudflare AI Gateway",
2234
+ description: "Flagship GPT model for complex shell tasks. through Cloudflare AI Gateway",
2235
2235
  category: "smart",
2236
2236
  provider: "cloudflare-ai-gateway",
2237
2237
  contextLength: 1050000,
@@ -2240,7 +2240,7 @@ var CLOUDFLARE_AI_GATEWAY_MODELS = [
2240
2240
  {
2241
2241
  id: "anthropic/claude-sonnet-4-6",
2242
2242
  name: "Claude Sonnet 4.6",
2243
- description: "Anthropic's latest Sonnet model through Cloudflare AI Gateway",
2243
+ description: "Balanced Claude model for harder coding tasks. through Cloudflare AI Gateway",
2244
2244
  category: "smart",
2245
2245
  provider: "cloudflare-ai-gateway",
2246
2246
  contextLength: 1e6,
@@ -2249,7 +2249,7 @@ var CLOUDFLARE_AI_GATEWAY_MODELS = [
2249
2249
  {
2250
2250
  id: "anthropic/claude-opus-4-8",
2251
2251
  name: "Claude Opus 4.8",
2252
- description: "Anthropic's latest Opus model through Cloudflare AI Gateway",
2252
+ description: "Top Claude reasoning model for complex tasks. through Cloudflare AI Gateway",
2253
2253
  category: "reasoning",
2254
2254
  provider: "cloudflare-ai-gateway",
2255
2255
  contextLength: 1e6,
@@ -2289,7 +2289,7 @@ var OPENCODE_ZEN_MODELS = [
2289
2289
  {
2290
2290
  id: "deepseek-v4-flash-free",
2291
2291
  name: "DeepSeek V4 Flash Free",
2292
- description: "DeepSeek's free fast open-source model (limited time)",
2292
+ description: "Free DeepSeek coding model with a large context window.",
2293
2293
  category: "fast",
2294
2294
  provider: "opencode-zen",
2295
2295
  zenApiType: "openai-compatible",
@@ -2299,7 +2299,7 @@ var OPENCODE_ZEN_MODELS = [
2299
2299
  {
2300
2300
  id: "gpt-5-nano",
2301
2301
  name: "GPT 5 Nano",
2302
- description: "OpenAI's lightweight GPT model",
2302
+ description: "Lowest-cost GPT for quick edits and simple commands.",
2303
2303
  category: "fast",
2304
2304
  provider: "opencode-zen",
2305
2305
  zenApiType: "openai-responses",
@@ -2309,7 +2309,7 @@ var OPENCODE_ZEN_MODELS = [
2309
2309
  {
2310
2310
  id: "claude-haiku-4-5",
2311
2311
  name: "Claude Haiku 4.5",
2312
- description: "Anthropic's latest fast model",
2312
+ description: "Fast Claude model for quick command generation.",
2313
2313
  category: "fast",
2314
2314
  provider: "opencode-zen",
2315
2315
  zenApiType: "anthropic",
@@ -2319,7 +2319,7 @@ var OPENCODE_ZEN_MODELS = [
2319
2319
  {
2320
2320
  id: "gemini-3.5-flash",
2321
2321
  name: "Gemini 3.5 Flash",
2322
- description: "Google's latest fast Gemini model",
2322
+ description: "Fast Gemini model with a large context window.",
2323
2323
  category: "fast",
2324
2324
  provider: "opencode-zen",
2325
2325
  zenApiType: "google",
@@ -2329,7 +2329,7 @@ var OPENCODE_ZEN_MODELS = [
2329
2329
  {
2330
2330
  id: "claude-sonnet-4-6",
2331
2331
  name: "Claude Sonnet 4.6",
2332
- description: "Anthropic's latest Sonnet model",
2332
+ description: "Balanced Claude model for harder coding tasks.",
2333
2333
  category: "smart",
2334
2334
  provider: "opencode-zen",
2335
2335
  zenApiType: "anthropic",
@@ -2339,7 +2339,7 @@ var OPENCODE_ZEN_MODELS = [
2339
2339
  {
2340
2340
  id: "gpt-5.5",
2341
2341
  name: "GPT 5.5",
2342
- description: "OpenAI's latest flagship GPT model",
2342
+ description: "Flagship GPT model for complex shell tasks.",
2343
2343
  category: "smart",
2344
2344
  provider: "opencode-zen",
2345
2345
  zenApiType: "openai-responses",
@@ -2349,7 +2349,7 @@ var OPENCODE_ZEN_MODELS = [
2349
2349
  {
2350
2350
  id: "claude-opus-4-8",
2351
2351
  name: "Claude Opus 4.8",
2352
- description: "Anthropic's latest Opus model",
2352
+ description: "Top Claude reasoning model for complex tasks.",
2353
2353
  category: "reasoning",
2354
2354
  provider: "opencode-zen",
2355
2355
  zenApiType: "anthropic",
@@ -2817,6 +2817,8 @@ var DEFAULT_CONFIG = {
2817
2817
  ],
2818
2818
  confirmedDangerousPatterns: [],
2819
2819
  repoContext: false,
2820
+ checkForUpdates: true,
2821
+ autoUpdate: false,
2820
2822
  customModels: []
2821
2823
  };
2822
2824
  function ensureConfigDir() {
@@ -44994,6 +44996,8 @@ var DEFAULT_CONFIG2 = {
44994
44996
  ],
44995
44997
  confirmedDangerousPatterns: [],
44996
44998
  repoContext: false,
44999
+ checkForUpdates: true,
45000
+ autoUpdate: false,
44997
45001
  customModels: []
44998
45002
  };
44999
45003
  function ensureConfigDir2() {
@@ -46125,6 +46129,7 @@ function getAnsiColors() {
46125
46129
  loadTheme();
46126
46130
 
46127
46131
  // src/lib/update-checker.ts
46132
+ import { spawn } from "child_process";
46128
46133
  import { homedir as homedir4 } from "os";
46129
46134
  import { join as join4 } from "path";
46130
46135
  import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
@@ -46202,6 +46207,30 @@ async function fetchLatestVersion() {
46202
46207
  return null;
46203
46208
  }
46204
46209
  }
46210
+ function commandExists(command) {
46211
+ return new Promise((resolve2) => {
46212
+ const checker = process.platform === "win32" ? spawn("where", [command], { stdio: "ignore" }) : spawn("command", ["-v", command], { stdio: "ignore", shell: true });
46213
+ checker.on("close", (code) => resolve2(code === 0));
46214
+ checker.on("error", () => resolve2(false));
46215
+ });
46216
+ }
46217
+ async function resolveUpdateCommand() {
46218
+ if (await commandExists("bun")) {
46219
+ return `bun update -g ${PACKAGE_NAME}`;
46220
+ }
46221
+ if (await commandExists("npm")) {
46222
+ return `npm install -g ${PACKAGE_NAME}@latest`;
46223
+ }
46224
+ return `bun update -g ${PACKAGE_NAME}`;
46225
+ }
46226
+ async function buildUpdateInfo(latestVersion) {
46227
+ return {
46228
+ hasUpdate: true,
46229
+ currentVersion: getCurrentVersion(),
46230
+ latestVersion,
46231
+ updateCommand: await resolveUpdateCommand()
46232
+ };
46233
+ }
46205
46234
  async function checkForUpdates() {
46206
46235
  const state = loadUpdateState();
46207
46236
  const currentVersion = getCurrentVersion();
@@ -46211,12 +46240,7 @@ async function checkForUpdates() {
46211
46240
  if (state.dismissed === state.latestVersion) {
46212
46241
  return null;
46213
46242
  }
46214
- return {
46215
- hasUpdate: true,
46216
- currentVersion,
46217
- latestVersion: state.latestVersion,
46218
- updateCommand: `bun update -g ${PACKAGE_NAME}`
46219
- };
46243
+ return await buildUpdateInfo(state.latestVersion);
46220
46244
  }
46221
46245
  return null;
46222
46246
  }
@@ -46230,21 +46254,98 @@ async function checkForUpdates() {
46230
46254
  if (state.dismissed === latestVersion) {
46231
46255
  return null;
46232
46256
  }
46233
- return {
46234
- hasUpdate: true,
46235
- currentVersion,
46236
- latestVersion,
46237
- updateCommand: `bun update -g ${PACKAGE_NAME}`
46238
- };
46257
+ return await buildUpdateInfo(latestVersion);
46239
46258
  }
46240
46259
  return null;
46241
46260
  }
46261
+ function dismissUpdate(version2) {
46262
+ const state = loadUpdateState();
46263
+ state.dismissed = version2;
46264
+ saveUpdateState(state);
46265
+ }
46242
46266
  async function forceCheckForUpdates() {
46243
46267
  const state = loadUpdateState();
46244
46268
  state.lastCheck = 0;
46245
46269
  saveUpdateState(state);
46246
46270
  return checkForUpdates();
46247
46271
  }
46272
+ async function performUpdate() {
46273
+ const updateCommand = await resolveUpdateCommand();
46274
+ return new Promise((resolve2) => {
46275
+ const child = spawn(updateCommand, {
46276
+ shell: true,
46277
+ stdio: ["ignore", "pipe", "pipe"],
46278
+ env: process.env
46279
+ });
46280
+ let stdout = "";
46281
+ let stderr = "";
46282
+ child.stdout?.on("data", (data) => {
46283
+ stdout += data.toString();
46284
+ });
46285
+ child.stderr?.on("data", (data) => {
46286
+ stderr += data.toString();
46287
+ });
46288
+ child.on("error", (error40) => {
46289
+ resolve2({
46290
+ success: false,
46291
+ output: error40 instanceof Error ? error40.message : String(error40)
46292
+ });
46293
+ });
46294
+ child.on("close", (code) => {
46295
+ const output = (stdout + stderr).trim() || updateCommand;
46296
+ resolve2({
46297
+ success: code === 0,
46298
+ output
46299
+ });
46300
+ });
46301
+ });
46302
+ }
46303
+ function formatUpdateBannerLines(update) {
46304
+ return [
46305
+ `Update available! ${update.currentVersion} → ${update.latestVersion}`,
46306
+ `Run: ${update.updateCommand}`
46307
+ ];
46308
+ }
46309
+ async function processUpdateCheck(options) {
46310
+ const { checkForUpdates: updatesEnabled, autoUpdate, force = false, install = false } = options;
46311
+ if (!updatesEnabled && !force && !install) {
46312
+ return { action: "none" };
46313
+ }
46314
+ const update = force || install ? await forceCheckForUpdates() : await checkForUpdates();
46315
+ if (!update?.hasUpdate || !update.latestVersion) {
46316
+ if (force || install) {
46317
+ return { action: "up-to-date", currentVersion: getCurrentVersion() };
46318
+ }
46319
+ return { action: "none" };
46320
+ }
46321
+ if (install || autoUpdate) {
46322
+ const result = await performUpdate();
46323
+ if (result.success) {
46324
+ dismissUpdate(update.latestVersion);
46325
+ }
46326
+ return {
46327
+ action: "updated",
46328
+ update,
46329
+ success: result.success,
46330
+ output: result.output
46331
+ };
46332
+ }
46333
+ return { action: "notified", update };
46334
+ }
46335
+ function shouldRunStartupUpdateCheck(args) {
46336
+ if (args.length === 0)
46337
+ return false;
46338
+ const skipFlags = new Set([
46339
+ "--version",
46340
+ "-v",
46341
+ "--check-update",
46342
+ "--auto-update",
46343
+ "--no-auto-update",
46344
+ "--no-update-check",
46345
+ "--enable-update-check"
46346
+ ]);
46347
+ return !skipFlags.has(args[0]);
46348
+ }
46248
46349
 
46249
46350
  // src/lib/format.ts
46250
46351
  function formatExecutedCommand(command, colors) {
@@ -46290,6 +46391,10 @@ ${colors.bold}USAGE${colors.reset}
46290
46391
  msh --safety <level> Set safety level (strict, moderate, relaxed)
46291
46392
  msh --version Show version
46292
46393
  msh --check-update Check for updates
46394
+ msh --auto-update Enable automatic updates
46395
+ msh --no-auto-update Disable automatic updates
46396
+ msh --no-update-check Disable update checking
46397
+ msh --enable-update-check Enable update checking
46293
46398
  msh --help Show this help
46294
46399
 
46295
46400
  ${colors.bold}TUI MODE${colors.reset}
@@ -46532,7 +46637,7 @@ Try: ${colors.cyan}msh "list all files"${colors.reset}
46532
46637
  }
46533
46638
  function executeCommand(command) {
46534
46639
  return new Promise((resolve2) => {
46535
- const child = spawn(command, {
46640
+ const child = spawn2(command, {
46536
46641
  shell: true,
46537
46642
  cwd: getCwd(),
46538
46643
  env: process.env,
@@ -46720,21 +46825,46 @@ async function translate(query, options) {
46720
46825
  process.exit(1);
46721
46826
  }
46722
46827
  }
46723
- async function showUpdateNotification() {
46828
+ async function handleStartupUpdateCheck() {
46724
46829
  try {
46725
- const update = await checkForUpdates();
46726
- if (update?.hasUpdate) {
46727
- console.error(`${colors.cyan}\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510${colors.reset}`);
46728
- console.error(`${colors.cyan}\u2502${colors.reset} ${colors.bold}Update available!${colors.reset} ${colors.dim}${update.currentVersion}${colors.reset} \u2192 ${colors.green}${update.latestVersion}${colors.reset} ${colors.cyan}\u2502${colors.reset}`);
46729
- console.error(`${colors.cyan}\u2502${colors.reset} Run: ${colors.yellow}${update.updateCommand}${colors.reset} ${colors.cyan}\u2502${colors.reset}`);
46730
- console.error(`${colors.cyan}\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518${colors.reset}`);
46731
- console.error();
46830
+ const config2 = loadConfig();
46831
+ const result = await processUpdateCheck({
46832
+ checkForUpdates: config2.checkForUpdates !== false,
46833
+ autoUpdate: config2.autoUpdate === true
46834
+ });
46835
+ switch (result.action) {
46836
+ case "notified":
46837
+ printUpdateBanner(result.update);
46838
+ break;
46839
+ case "updated":
46840
+ if (result.success) {
46841
+ console.error(`${colors.green}\u2713 Updated to v${result.update.latestVersion}${colors.reset} Restart your shell or run msh again.`);
46842
+ console.error();
46843
+ } else {
46844
+ console.error(`${colors.yellow}Auto-update failed:${colors.reset} ${result.output}`);
46845
+ printUpdateBanner(result.update);
46846
+ }
46847
+ break;
46732
46848
  }
46733
46849
  } catch {}
46734
46850
  }
46851
+ function printUpdateBanner(update) {
46852
+ const lines = formatUpdateBannerLines({
46853
+ hasUpdate: true,
46854
+ currentVersion: update.currentVersion,
46855
+ latestVersion: update.latestVersion,
46856
+ updateCommand: update.updateCommand
46857
+ });
46858
+ console.error(`${colors.cyan}\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510${colors.reset}`);
46859
+ for (const line of lines) {
46860
+ console.error(`${colors.cyan}\u2502${colors.reset} ${line.padEnd(47)} ${colors.cyan}\u2502${colors.reset}`);
46861
+ }
46862
+ console.error(`${colors.cyan}\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518${colors.reset}`);
46863
+ console.error();
46864
+ }
46735
46865
  async function main() {
46736
46866
  const args = process.argv.slice(2);
46737
- const updatePromise = args.length > 0 && !args[0].startsWith("-i") ? showUpdateNotification() : Promise.resolve();
46867
+ const updatePromise = shouldRunStartupUpdateCheck(args) ? handleStartupUpdateCheck() : Promise.resolve();
46738
46868
  if (args.length === 0) {
46739
46869
  console.log(`${colors.bold}${colors.primary}magic-shell${colors.reset} - Natural language to terminal commands
46740
46870
  `);
@@ -46760,13 +46890,62 @@ async function main() {
46760
46890
  return;
46761
46891
  }
46762
46892
  if (args[0] === "--check-update") {
46763
- const update = await forceCheckForUpdates();
46764
- if (update?.hasUpdate) {
46765
- console.log(`${colors.green}Update available!${colors.reset} ${update.currentVersion} \u2192 ${update.latestVersion}`);
46766
- console.log(`Run: ${colors.cyan}${update.updateCommand}${colors.reset}`);
46767
- } else {
46768
- console.log(`${colors.green}\u2713 You're running the latest version (${getCurrentVersion()})${colors.reset}`);
46893
+ const config2 = loadConfig();
46894
+ const result = await processUpdateCheck({
46895
+ checkForUpdates: true,
46896
+ autoUpdate: config2.autoUpdate === true,
46897
+ force: true
46898
+ });
46899
+ if (result.action === "up-to-date") {
46900
+ console.log(`${colors.green}\u2713 You're running the latest version (${result.currentVersion})${colors.reset}`);
46901
+ return;
46769
46902
  }
46903
+ if (result.action === "updated") {
46904
+ if (result.success) {
46905
+ console.log(`${colors.green}\u2713 Updated to v${result.update.latestVersion}${colors.reset}`);
46906
+ } else {
46907
+ console.log(`${colors.yellow}Update failed:${colors.reset} ${result.output}`);
46908
+ console.log(`Try manually: ${colors.cyan}${result.update.updateCommand}${colors.reset}`);
46909
+ process.exit(1);
46910
+ }
46911
+ return;
46912
+ }
46913
+ if (result.action === "notified") {
46914
+ console.log(`${colors.green}Update available!${colors.reset} ${result.update.currentVersion} \u2192 ${result.update.latestVersion}`);
46915
+ console.log(`Run: ${colors.cyan}${result.update.updateCommand}${colors.reset}`);
46916
+ console.log(`Or enable auto-update: ${colors.cyan}msh --auto-update${colors.reset}`);
46917
+ return;
46918
+ }
46919
+ console.log(`${colors.yellow}Could not check for updates.${colors.reset}`);
46920
+ return;
46921
+ }
46922
+ if (args[0] === "--auto-update") {
46923
+ const config2 = loadConfig();
46924
+ config2.autoUpdate = true;
46925
+ config2.checkForUpdates = true;
46926
+ saveConfig(config2);
46927
+ console.log(`${colors.success}\u2713 Auto-update enabled${colors.reset}`);
46928
+ return;
46929
+ }
46930
+ if (args[0] === "--no-auto-update") {
46931
+ const config2 = loadConfig();
46932
+ config2.autoUpdate = false;
46933
+ saveConfig(config2);
46934
+ console.log(`${colors.success}\u2713 Auto-update disabled${colors.reset}`);
46935
+ return;
46936
+ }
46937
+ if (args[0] === "--no-update-check") {
46938
+ const config2 = loadConfig();
46939
+ config2.checkForUpdates = false;
46940
+ saveConfig(config2);
46941
+ console.log(`${colors.success}\u2713 Update checking disabled${colors.reset}`);
46942
+ return;
46943
+ }
46944
+ if (args[0] === "--enable-update-check") {
46945
+ const config2 = loadConfig();
46946
+ config2.checkForUpdates = true;
46947
+ saveConfig(config2);
46948
+ console.log(`${colors.success}\u2713 Update checking enabled${colors.reset}`);
46770
46949
  return;
46771
46950
  }
46772
46951
  if (args[0] === "--setup") {