@austinthesing/magic-shell 0.2.19 → 0.2.20
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 +10 -3
- package/dist/cli.js +219 -44
- package/dist/index.js +250 -48
- package/dist/tui.js +219 -44
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2349,21 +2349,66 @@ var WORKERS_AI_MODELS = [
|
|
|
2349
2349
|
];
|
|
2350
2350
|
var OPENCODE_ZEN_MODELS = [
|
|
2351
2351
|
{
|
|
2352
|
-
id: "
|
|
2353
|
-
name: "
|
|
2354
|
-
description: "
|
|
2352
|
+
id: "minimax-m2.5-free",
|
|
2353
|
+
name: "MiniMax M2.5 Free",
|
|
2354
|
+
description: "MiniMax's free model (limited time)",
|
|
2355
2355
|
category: "smart",
|
|
2356
2356
|
provider: "opencode-zen",
|
|
2357
|
-
contextLength:
|
|
2357
|
+
contextLength: 196608,
|
|
2358
2358
|
free: true
|
|
2359
2359
|
},
|
|
2360
2360
|
{
|
|
2361
|
-
id: "
|
|
2362
|
-
name: "
|
|
2363
|
-
description: "
|
|
2361
|
+
id: "ling-2.6-flash-free",
|
|
2362
|
+
name: "Ling 2.6 Flash Free",
|
|
2363
|
+
description: "Ling's free flash model (limited time)",
|
|
2364
2364
|
category: "fast",
|
|
2365
2365
|
provider: "opencode-zen",
|
|
2366
|
-
contextLength:
|
|
2366
|
+
contextLength: 131072,
|
|
2367
|
+
free: true
|
|
2368
|
+
},
|
|
2369
|
+
{
|
|
2370
|
+
id: "hy3-preview-free",
|
|
2371
|
+
name: "Hy3 Preview Free",
|
|
2372
|
+
description: "Hy3 preview model (free, limited time)",
|
|
2373
|
+
category: "smart",
|
|
2374
|
+
provider: "opencode-zen",
|
|
2375
|
+
contextLength: 131072,
|
|
2376
|
+
free: true
|
|
2377
|
+
},
|
|
2378
|
+
{
|
|
2379
|
+
id: "nemotron-3-super-free",
|
|
2380
|
+
name: "Nemotron 3 Super Free",
|
|
2381
|
+
description: "NVIDIA Nemotron free trial model",
|
|
2382
|
+
category: "smart",
|
|
2383
|
+
provider: "opencode-zen",
|
|
2384
|
+
contextLength: 131072,
|
|
2385
|
+
free: true
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
id: "trinity-large-preview-free",
|
|
2389
|
+
name: "Trinity Large Preview Free",
|
|
2390
|
+
description: "Trinity large preview model (free, limited time)",
|
|
2391
|
+
category: "smart",
|
|
2392
|
+
provider: "opencode-zen",
|
|
2393
|
+
contextLength: 131072,
|
|
2394
|
+
free: true
|
|
2395
|
+
},
|
|
2396
|
+
{
|
|
2397
|
+
id: "big-pickle",
|
|
2398
|
+
name: "Big Pickle",
|
|
2399
|
+
description: "OpenCode stealth model (free, limited time)",
|
|
2400
|
+
category: "smart",
|
|
2401
|
+
provider: "opencode-zen",
|
|
2402
|
+
contextLength: 131072,
|
|
2403
|
+
free: true
|
|
2404
|
+
},
|
|
2405
|
+
{
|
|
2406
|
+
id: "gpt-5-nano",
|
|
2407
|
+
name: "GPT 5 Nano",
|
|
2408
|
+
description: "OpenAI's free lightweight GPT model",
|
|
2409
|
+
category: "fast",
|
|
2410
|
+
provider: "opencode-zen",
|
|
2411
|
+
contextLength: 400000,
|
|
2367
2412
|
free: true
|
|
2368
2413
|
},
|
|
2369
2414
|
{
|
|
@@ -2929,7 +2974,8 @@ var DEFAULT_CONFIG = {
|
|
|
2929
2974
|
workersAiApiKey: "",
|
|
2930
2975
|
cloudflareAccountId: "",
|
|
2931
2976
|
cloudflareAiGatewayId: "default",
|
|
2932
|
-
defaultModel: "
|
|
2977
|
+
defaultModel: "minimax-m2.5-free",
|
|
2978
|
+
thinkingLevel: "low",
|
|
2933
2979
|
safetyLevel: "moderate",
|
|
2934
2980
|
dryRunByDefault: false,
|
|
2935
2981
|
blockedCommands: [
|
|
@@ -41595,21 +41641,66 @@ var WORKERS_AI_MODELS2 = [
|
|
|
41595
41641
|
];
|
|
41596
41642
|
var OPENCODE_ZEN_MODELS2 = [
|
|
41597
41643
|
{
|
|
41598
|
-
id: "
|
|
41599
|
-
name: "
|
|
41600
|
-
description: "
|
|
41644
|
+
id: "minimax-m2.5-free",
|
|
41645
|
+
name: "MiniMax M2.5 Free",
|
|
41646
|
+
description: "MiniMax's free model (limited time)",
|
|
41601
41647
|
category: "smart",
|
|
41602
41648
|
provider: "opencode-zen",
|
|
41603
|
-
contextLength:
|
|
41649
|
+
contextLength: 196608,
|
|
41604
41650
|
free: true
|
|
41605
41651
|
},
|
|
41606
41652
|
{
|
|
41607
|
-
id: "
|
|
41608
|
-
name: "
|
|
41609
|
-
description: "
|
|
41653
|
+
id: "ling-2.6-flash-free",
|
|
41654
|
+
name: "Ling 2.6 Flash Free",
|
|
41655
|
+
description: "Ling's free flash model (limited time)",
|
|
41610
41656
|
category: "fast",
|
|
41611
41657
|
provider: "opencode-zen",
|
|
41612
|
-
contextLength:
|
|
41658
|
+
contextLength: 131072,
|
|
41659
|
+
free: true
|
|
41660
|
+
},
|
|
41661
|
+
{
|
|
41662
|
+
id: "hy3-preview-free",
|
|
41663
|
+
name: "Hy3 Preview Free",
|
|
41664
|
+
description: "Hy3 preview model (free, limited time)",
|
|
41665
|
+
category: "smart",
|
|
41666
|
+
provider: "opencode-zen",
|
|
41667
|
+
contextLength: 131072,
|
|
41668
|
+
free: true
|
|
41669
|
+
},
|
|
41670
|
+
{
|
|
41671
|
+
id: "nemotron-3-super-free",
|
|
41672
|
+
name: "Nemotron 3 Super Free",
|
|
41673
|
+
description: "NVIDIA Nemotron free trial model",
|
|
41674
|
+
category: "smart",
|
|
41675
|
+
provider: "opencode-zen",
|
|
41676
|
+
contextLength: 131072,
|
|
41677
|
+
free: true
|
|
41678
|
+
},
|
|
41679
|
+
{
|
|
41680
|
+
id: "trinity-large-preview-free",
|
|
41681
|
+
name: "Trinity Large Preview Free",
|
|
41682
|
+
description: "Trinity large preview model (free, limited time)",
|
|
41683
|
+
category: "smart",
|
|
41684
|
+
provider: "opencode-zen",
|
|
41685
|
+
contextLength: 131072,
|
|
41686
|
+
free: true
|
|
41687
|
+
},
|
|
41688
|
+
{
|
|
41689
|
+
id: "big-pickle",
|
|
41690
|
+
name: "Big Pickle",
|
|
41691
|
+
description: "OpenCode stealth model (free, limited time)",
|
|
41692
|
+
category: "smart",
|
|
41693
|
+
provider: "opencode-zen",
|
|
41694
|
+
contextLength: 131072,
|
|
41695
|
+
free: true
|
|
41696
|
+
},
|
|
41697
|
+
{
|
|
41698
|
+
id: "gpt-5-nano",
|
|
41699
|
+
name: "GPT 5 Nano",
|
|
41700
|
+
description: "OpenAI's free lightweight GPT model",
|
|
41701
|
+
category: "fast",
|
|
41702
|
+
provider: "opencode-zen",
|
|
41703
|
+
contextLength: 400000,
|
|
41613
41704
|
free: true
|
|
41614
41705
|
},
|
|
41615
41706
|
{
|
|
@@ -41821,7 +41912,8 @@ var DEFAULT_CONFIG2 = {
|
|
|
41821
41912
|
workersAiApiKey: "",
|
|
41822
41913
|
cloudflareAccountId: "",
|
|
41823
41914
|
cloudflareAiGatewayId: "default",
|
|
41824
|
-
defaultModel: "
|
|
41915
|
+
defaultModel: "minimax-m2.5-free",
|
|
41916
|
+
thinkingLevel: "low",
|
|
41825
41917
|
safetyLevel: "moderate",
|
|
41826
41918
|
dryRunByDefault: false,
|
|
41827
41919
|
blockedCommands: [
|
|
@@ -42396,7 +42488,94 @@ function cleanCommand(command) {
|
|
|
42396
42488
|
}
|
|
42397
42489
|
return cleaned.trim();
|
|
42398
42490
|
}
|
|
42399
|
-
|
|
42491
|
+
function getThinkingLevel(config2) {
|
|
42492
|
+
return config2?.thinkingLevel || "low";
|
|
42493
|
+
}
|
|
42494
|
+
function supportsThinkingControl(modelId) {
|
|
42495
|
+
return modelId.includes("thinking") || modelId.includes("gpt-5") || modelId.includes("claude-") || modelId.includes("gemini-");
|
|
42496
|
+
}
|
|
42497
|
+
function buildOpenRouterThinkingOptions(modelId, thinkingLevel) {
|
|
42498
|
+
if (thinkingLevel === "off" || !supportsThinkingControl(modelId)) {
|
|
42499
|
+
return {};
|
|
42500
|
+
}
|
|
42501
|
+
return {
|
|
42502
|
+
reasoning: {
|
|
42503
|
+
effort: thinkingLevel
|
|
42504
|
+
}
|
|
42505
|
+
};
|
|
42506
|
+
}
|
|
42507
|
+
function buildOpenAICompatibleThinkingOptions(modelId, thinkingLevel) {
|
|
42508
|
+
if (thinkingLevel === "off" || !supportsThinkingControl(modelId)) {
|
|
42509
|
+
return {};
|
|
42510
|
+
}
|
|
42511
|
+
return {
|
|
42512
|
+
reasoning_effort: thinkingLevel
|
|
42513
|
+
};
|
|
42514
|
+
}
|
|
42515
|
+
function buildAiSdkProviderOptions(modelId, thinkingLevel, providerOptionsName) {
|
|
42516
|
+
if (thinkingLevel === "off" || !supportsThinkingControl(modelId)) {
|
|
42517
|
+
return;
|
|
42518
|
+
}
|
|
42519
|
+
if (modelId.startsWith("gpt-")) {
|
|
42520
|
+
const compatibleOptions = providerOptionsName && providerOptionsName !== "openai" ? {
|
|
42521
|
+
[providerOptionsName]: {
|
|
42522
|
+
reasoningEffort: thinkingLevel
|
|
42523
|
+
}
|
|
42524
|
+
} : {};
|
|
42525
|
+
return {
|
|
42526
|
+
openai: {
|
|
42527
|
+
reasoningEffort: thinkingLevel
|
|
42528
|
+
},
|
|
42529
|
+
openaiCompatible: {
|
|
42530
|
+
reasoningEffort: thinkingLevel
|
|
42531
|
+
},
|
|
42532
|
+
...compatibleOptions
|
|
42533
|
+
};
|
|
42534
|
+
}
|
|
42535
|
+
if (modelId.startsWith("gemini-")) {
|
|
42536
|
+
return {
|
|
42537
|
+
google: {
|
|
42538
|
+
thinkingConfig: {
|
|
42539
|
+
thinkingLevel
|
|
42540
|
+
}
|
|
42541
|
+
}
|
|
42542
|
+
};
|
|
42543
|
+
}
|
|
42544
|
+
if (modelId.startsWith("claude-")) {
|
|
42545
|
+
const budgetByLevel = {
|
|
42546
|
+
low: 1024,
|
|
42547
|
+
medium: 4096,
|
|
42548
|
+
high: 8192
|
|
42549
|
+
};
|
|
42550
|
+
return {
|
|
42551
|
+
anthropic: {
|
|
42552
|
+
thinking: {
|
|
42553
|
+
type: "enabled",
|
|
42554
|
+
budgetTokens: budgetByLevel[thinkingLevel]
|
|
42555
|
+
}
|
|
42556
|
+
}
|
|
42557
|
+
};
|
|
42558
|
+
}
|
|
42559
|
+
if (modelId.includes("thinking")) {
|
|
42560
|
+
return {
|
|
42561
|
+
openaiCompatible: {
|
|
42562
|
+
reasoningEffort: thinkingLevel
|
|
42563
|
+
},
|
|
42564
|
+
...providerOptionsName ? {
|
|
42565
|
+
[providerOptionsName]: {
|
|
42566
|
+
reasoningEffort: thinkingLevel
|
|
42567
|
+
}
|
|
42568
|
+
} : {}
|
|
42569
|
+
};
|
|
42570
|
+
}
|
|
42571
|
+
return;
|
|
42572
|
+
}
|
|
42573
|
+
function shouldOmitTemperature(modelId, thinkingLevel) {
|
|
42574
|
+
return thinkingLevel !== "off" && (modelId.startsWith("claude-") || modelId.includes("gpt-5"));
|
|
42575
|
+
}
|
|
42576
|
+
async function callOpenRouter(apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42577
|
+
const thinkingOptions = buildOpenRouterThinkingOptions(modelId, thinkingLevel);
|
|
42578
|
+
const temperatureOptions = shouldOmitTemperature(modelId, thinkingLevel) ? {} : { temperature: 0.1 };
|
|
42400
42579
|
const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
|
|
42401
42580
|
method: "POST",
|
|
42402
42581
|
headers: {
|
|
@@ -42412,7 +42591,8 @@ async function callOpenRouter(apiKey, modelId, systemPrompt, userInput) {
|
|
|
42412
42591
|
{ role: "user", content: userInput }
|
|
42413
42592
|
],
|
|
42414
42593
|
max_tokens: 500,
|
|
42415
|
-
|
|
42594
|
+
...temperatureOptions,
|
|
42595
|
+
...thinkingOptions
|
|
42416
42596
|
})
|
|
42417
42597
|
});
|
|
42418
42598
|
if (!response.ok) {
|
|
@@ -42432,7 +42612,9 @@ async function callOpenRouter(apiKey, modelId, systemPrompt, userInput) {
|
|
|
42432
42612
|
}
|
|
42433
42613
|
return data.choices[0]?.message?.content?.trim() || "";
|
|
42434
42614
|
}
|
|
42435
|
-
async function callOpenAICompatibleFetch(baseURL, apiKey, modelId, systemPrompt, userInput, headers = {}, includeAuthorization = true) {
|
|
42615
|
+
async function callOpenAICompatibleFetch(baseURL, apiKey, modelId, systemPrompt, userInput, thinkingLevel, headers = {}, includeAuthorization = true) {
|
|
42616
|
+
const thinkingOptions = buildOpenAICompatibleThinkingOptions(modelId, thinkingLevel);
|
|
42617
|
+
const temperatureOptions = shouldOmitTemperature(modelId, thinkingLevel) ? {} : { temperature: 0.1 };
|
|
42436
42618
|
const requestHeaders = {
|
|
42437
42619
|
"Content-Type": "application/json",
|
|
42438
42620
|
...headers
|
|
@@ -42450,8 +42632,9 @@ async function callOpenAICompatibleFetch(baseURL, apiKey, modelId, systemPrompt,
|
|
|
42450
42632
|
{ role: "user", content: userInput }
|
|
42451
42633
|
],
|
|
42452
42634
|
max_tokens: 500,
|
|
42453
|
-
|
|
42454
|
-
|
|
42635
|
+
stream: false,
|
|
42636
|
+
...temperatureOptions,
|
|
42637
|
+
...thinkingOptions
|
|
42455
42638
|
})
|
|
42456
42639
|
});
|
|
42457
42640
|
if (!response.ok) {
|
|
@@ -42483,42 +42666,45 @@ function getCloudflareAccountId(config2) {
|
|
|
42483
42666
|
function getCloudflareGatewayId(config2) {
|
|
42484
42667
|
return config2.cloudflareAiGatewayId || process.env.CLOUDFLARE_AI_GATEWAY_ID || process.env.CF_AIG_GATEWAY_ID || "default";
|
|
42485
42668
|
}
|
|
42486
|
-
async function callGatewayProvider(provider, apiKey, modelId, systemPrompt, userInput) {
|
|
42669
|
+
async function callGatewayProvider(provider, apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42487
42670
|
const config2 = loadConfig2();
|
|
42488
42671
|
switch (provider) {
|
|
42489
42672
|
case "vercel-ai-gateway":
|
|
42490
|
-
return await callOpenAICompatibleFetch("https://ai-gateway.vercel.sh/v1", apiKey, modelId, systemPrompt, userInput);
|
|
42673
|
+
return await callOpenAICompatibleFetch("https://ai-gateway.vercel.sh/v1", apiKey, modelId, systemPrompt, userInput, thinkingLevel);
|
|
42491
42674
|
case "cloudflare-ai-gateway": {
|
|
42492
42675
|
const accountId = getCloudflareAccountId(config2);
|
|
42493
42676
|
if (!accountId) {
|
|
42494
42677
|
throw new Error("Cloudflare account ID is required. Set cloudflareAccountId in config or CLOUDFLARE_ACCOUNT_ID.");
|
|
42495
42678
|
}
|
|
42496
42679
|
const gatewayId = getCloudflareGatewayId(config2);
|
|
42497
|
-
return await callOpenAICompatibleFetch(`https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`, apiKey, modelId, systemPrompt, userInput, { "cf-aig-authorization": `Bearer ${apiKey}` }, false);
|
|
42680
|
+
return await callOpenAICompatibleFetch(`https://gateway.ai.cloudflare.com/v1/${accountId}/${gatewayId}/compat`, apiKey, modelId, systemPrompt, userInput, thinkingLevel, { "cf-aig-authorization": `Bearer ${apiKey}` }, false);
|
|
42498
42681
|
}
|
|
42499
42682
|
case "workers-ai": {
|
|
42500
42683
|
const accountId = getCloudflareAccountId(config2);
|
|
42501
42684
|
if (!accountId) {
|
|
42502
42685
|
throw new Error("Cloudflare account ID is required. Set cloudflareAccountId in config or CLOUDFLARE_ACCOUNT_ID.");
|
|
42503
42686
|
}
|
|
42504
|
-
return await callOpenAICompatibleFetch(`https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1`, apiKey, modelId, systemPrompt, userInput);
|
|
42687
|
+
return await callOpenAICompatibleFetch(`https://api.cloudflare.com/client/v4/accounts/${accountId}/ai/v1`, apiKey, modelId, systemPrompt, userInput, thinkingLevel);
|
|
42505
42688
|
}
|
|
42506
42689
|
default:
|
|
42507
42690
|
throw new Error(`Unsupported gateway provider: ${provider}`);
|
|
42508
42691
|
}
|
|
42509
42692
|
}
|
|
42510
42693
|
var DEBUG_API = process.env.DEBUG_API === "1";
|
|
42511
|
-
async function generateZenText(model, systemPrompt, userInput) {
|
|
42694
|
+
async function generateZenText(model, modelId, systemPrompt, userInput, thinkingLevel, providerOptionsName) {
|
|
42695
|
+
const providerOptions = buildAiSdkProviderOptions(modelId, thinkingLevel, providerOptionsName);
|
|
42696
|
+
const temperatureOptions = shouldOmitTemperature(modelId, thinkingLevel) ? {} : { temperature: 0.1 };
|
|
42512
42697
|
const { text: text2 } = await generateText({
|
|
42513
42698
|
model,
|
|
42514
42699
|
system: systemPrompt,
|
|
42515
42700
|
prompt: userInput,
|
|
42516
42701
|
maxOutputTokens: 500,
|
|
42517
|
-
|
|
42702
|
+
...temperatureOptions,
|
|
42703
|
+
...providerOptions ? { providerOptions } : {}
|
|
42518
42704
|
});
|
|
42519
42705
|
return text2.trim();
|
|
42520
42706
|
}
|
|
42521
|
-
async function callZenOpenAIResponses(apiKey, modelId, systemPrompt, userInput) {
|
|
42707
|
+
async function callZenOpenAIResponses(apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42522
42708
|
if (DEBUG_API) {
|
|
42523
42709
|
console.error(`[DEBUG] Calling OpenAI Responses API`);
|
|
42524
42710
|
console.error(`[DEBUG] Model: ${modelId}`);
|
|
@@ -42529,7 +42715,7 @@ async function callZenOpenAIResponses(apiKey, modelId, systemPrompt, userInput)
|
|
|
42529
42715
|
baseURL: ZEN_BASE_URL
|
|
42530
42716
|
});
|
|
42531
42717
|
try {
|
|
42532
|
-
return await generateZenText(openai2(modelId), systemPrompt, userInput);
|
|
42718
|
+
return await generateZenText(openai2(modelId), modelId, systemPrompt, userInput, thinkingLevel);
|
|
42533
42719
|
} catch (error40) {
|
|
42534
42720
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
42535
42721
|
if (DEBUG_API) {
|
|
@@ -42538,7 +42724,7 @@ async function callZenOpenAIResponses(apiKey, modelId, systemPrompt, userInput)
|
|
|
42538
42724
|
throw new Error(message);
|
|
42539
42725
|
}
|
|
42540
42726
|
}
|
|
42541
|
-
async function callZenAnthropic(apiKey, modelId, systemPrompt, userInput) {
|
|
42727
|
+
async function callZenAnthropic(apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42542
42728
|
if (DEBUG_API) {
|
|
42543
42729
|
console.error(`[DEBUG] Calling Anthropic Messages API`);
|
|
42544
42730
|
console.error(`[DEBUG] Model: ${modelId}`);
|
|
@@ -42549,7 +42735,7 @@ async function callZenAnthropic(apiKey, modelId, systemPrompt, userInput) {
|
|
|
42549
42735
|
baseURL: ZEN_BASE_URL
|
|
42550
42736
|
});
|
|
42551
42737
|
try {
|
|
42552
|
-
return await generateZenText(anthropic2(modelId), systemPrompt, userInput);
|
|
42738
|
+
return await generateZenText(anthropic2(modelId), modelId, systemPrompt, userInput, thinkingLevel);
|
|
42553
42739
|
} catch (error40) {
|
|
42554
42740
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
42555
42741
|
if (DEBUG_API) {
|
|
@@ -42558,7 +42744,7 @@ async function callZenAnthropic(apiKey, modelId, systemPrompt, userInput) {
|
|
|
42558
42744
|
throw new Error(message);
|
|
42559
42745
|
}
|
|
42560
42746
|
}
|
|
42561
|
-
async function callZenOpenAICompatible(apiKey, modelId, systemPrompt, userInput) {
|
|
42747
|
+
async function callZenOpenAICompatible(apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42562
42748
|
if (DEBUG_API) {
|
|
42563
42749
|
console.error(`[DEBUG] Calling OpenAI-compatible Chat Completions API`);
|
|
42564
42750
|
console.error(`[DEBUG] Model: ${modelId}`);
|
|
@@ -42569,7 +42755,7 @@ async function callZenOpenAICompatible(apiKey, modelId, systemPrompt, userInput)
|
|
|
42569
42755
|
baseURL: ZEN_BASE_URL
|
|
42570
42756
|
});
|
|
42571
42757
|
try {
|
|
42572
|
-
return await generateZenText(openaiCompatible(modelId), systemPrompt, userInput);
|
|
42758
|
+
return await generateZenText(openaiCompatible(modelId), modelId, systemPrompt, userInput, thinkingLevel, "opencodeZen");
|
|
42573
42759
|
} catch (error40) {
|
|
42574
42760
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
42575
42761
|
if (DEBUG_API) {
|
|
@@ -42578,7 +42764,7 @@ async function callZenOpenAICompatible(apiKey, modelId, systemPrompt, userInput)
|
|
|
42578
42764
|
throw new Error(message);
|
|
42579
42765
|
}
|
|
42580
42766
|
}
|
|
42581
|
-
async function callCustomModel(model, systemPrompt, userInput) {
|
|
42767
|
+
async function callCustomModel(model, systemPrompt, userInput, thinkingLevel) {
|
|
42582
42768
|
if (DEBUG_API) {
|
|
42583
42769
|
console.error(`[DEBUG] Calling Custom Model`);
|
|
42584
42770
|
console.error(`[DEBUG] Model: ${model.modelId}`);
|
|
@@ -42590,7 +42776,7 @@ async function callCustomModel(model, systemPrompt, userInput) {
|
|
|
42590
42776
|
baseURL: model.baseUrl
|
|
42591
42777
|
});
|
|
42592
42778
|
try {
|
|
42593
|
-
return await generateZenText(openaiCompatible(model.modelId), systemPrompt, userInput);
|
|
42779
|
+
return await generateZenText(openaiCompatible(model.modelId), model.modelId, systemPrompt, userInput, thinkingLevel, "custom");
|
|
42594
42780
|
} catch (error40) {
|
|
42595
42781
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
42596
42782
|
if (DEBUG_API) {
|
|
@@ -42599,7 +42785,7 @@ async function callCustomModel(model, systemPrompt, userInput) {
|
|
|
42599
42785
|
throw new Error(message);
|
|
42600
42786
|
}
|
|
42601
42787
|
}
|
|
42602
|
-
async function callZenGoogle(apiKey, modelId, systemPrompt, userInput) {
|
|
42788
|
+
async function callZenGoogle(apiKey, modelId, systemPrompt, userInput, thinkingLevel) {
|
|
42603
42789
|
if (DEBUG_API) {
|
|
42604
42790
|
console.error(`[DEBUG] Calling Google Gemini API`);
|
|
42605
42791
|
console.error(`[DEBUG] Model: ${modelId}`);
|
|
@@ -42609,7 +42795,7 @@ async function callZenGoogle(apiKey, modelId, systemPrompt, userInput) {
|
|
|
42609
42795
|
baseURL: `https://opencode.ai/zen/v1/models/${modelId}`
|
|
42610
42796
|
});
|
|
42611
42797
|
try {
|
|
42612
|
-
return await generateZenText(google2(modelId), systemPrompt, userInput);
|
|
42798
|
+
return await generateZenText(google2(modelId), modelId, systemPrompt, userInput, thinkingLevel);
|
|
42613
42799
|
} catch (error40) {
|
|
42614
42800
|
const message = error40 instanceof Error ? error40.message : String(error40);
|
|
42615
42801
|
if (DEBUG_API) {
|
|
@@ -42625,30 +42811,31 @@ function getShellInfo() {
|
|
|
42625
42811
|
}
|
|
42626
42812
|
return cachedShellInfo;
|
|
42627
42813
|
}
|
|
42628
|
-
async function translateToCommand(apiKey, model, userInput, cwd, history = [], repoContextEnabled) {
|
|
42814
|
+
async function translateToCommand(apiKey, model, userInput, cwd, history = [], repoContextEnabled, config2) {
|
|
42629
42815
|
const shellInfo = getShellInfo();
|
|
42630
42816
|
const systemPrompt = buildSystemPrompt(cwd, history, shellInfo, repoContextEnabled);
|
|
42817
|
+
const thinkingLevel = getThinkingLevel(config2);
|
|
42631
42818
|
let rawCommand;
|
|
42632
42819
|
if (isCustomModel(model)) {
|
|
42633
|
-
rawCommand = await callCustomModel(model, systemPrompt, userInput);
|
|
42820
|
+
rawCommand = await callCustomModel(model, systemPrompt, userInput, "off");
|
|
42634
42821
|
} else if (model.provider === "openrouter") {
|
|
42635
|
-
rawCommand = await callOpenRouter(apiKey, model.id, systemPrompt, userInput);
|
|
42822
|
+
rawCommand = await callOpenRouter(apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42636
42823
|
} else if (model.provider === "vercel-ai-gateway" || model.provider === "cloudflare-ai-gateway" || model.provider === "workers-ai") {
|
|
42637
|
-
rawCommand = await callGatewayProvider(model.provider, apiKey, model.id, systemPrompt, userInput);
|
|
42824
|
+
rawCommand = await callGatewayProvider(model.provider, apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42638
42825
|
} else {
|
|
42639
42826
|
const apiType = getZenApiType(model.id);
|
|
42640
42827
|
switch (apiType) {
|
|
42641
42828
|
case "openai-responses":
|
|
42642
|
-
rawCommand = await callZenOpenAIResponses(apiKey, model.id, systemPrompt, userInput);
|
|
42829
|
+
rawCommand = await callZenOpenAIResponses(apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42643
42830
|
break;
|
|
42644
42831
|
case "anthropic":
|
|
42645
|
-
rawCommand = await callZenAnthropic(apiKey, model.id, systemPrompt, userInput);
|
|
42832
|
+
rawCommand = await callZenAnthropic(apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42646
42833
|
break;
|
|
42647
42834
|
case "google":
|
|
42648
|
-
rawCommand = await callZenGoogle(apiKey, model.id, systemPrompt, userInput);
|
|
42835
|
+
rawCommand = await callZenGoogle(apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42649
42836
|
break;
|
|
42650
42837
|
case "openai-compatible":
|
|
42651
|
-
rawCommand = await callZenOpenAICompatible(apiKey, model.id, systemPrompt, userInput);
|
|
42838
|
+
rawCommand = await callZenOpenAICompatible(apiKey, model.id, systemPrompt, userInput, thinkingLevel);
|
|
42652
42839
|
break;
|
|
42653
42840
|
}
|
|
42654
42841
|
}
|
|
@@ -43028,6 +43215,7 @@ ${colors.bold}USAGE${colors.reset}
|
|
|
43028
43215
|
msh --list-custom List custom models
|
|
43029
43216
|
msh --remove-model <id> Remove custom model
|
|
43030
43217
|
msh --provider <name> Set provider
|
|
43218
|
+
msh --thinking <level> Set thinking level (off, low, medium, high)
|
|
43031
43219
|
msh --themes List available themes
|
|
43032
43220
|
msh --theme <name> Set color theme
|
|
43033
43221
|
msh --repo-context Enable project context detection
|
|
@@ -43452,12 +43640,13 @@ async function translate(query, options) {
|
|
|
43452
43640
|
const useRepoContext = options.repoContext ?? config2.repoContext ?? false;
|
|
43453
43641
|
const spinner = createSpinner(`Translating with ${customModel ? customModel.name : model.name}`);
|
|
43454
43642
|
try {
|
|
43455
|
-
const command = await translateToCommand(apiKey, model, query, cwd, history, useRepoContext);
|
|
43643
|
+
const command = await translateToCommand(apiKey, model, query, cwd, history, useRepoContext, config2);
|
|
43456
43644
|
spinner.stop();
|
|
43457
43645
|
if (options.dryRun) {
|
|
43458
43646
|
const safety = analyzeCommand(command, config2);
|
|
43459
43647
|
console.log(`${colors.dim}Query:${colors.reset} ${query}`);
|
|
43460
43648
|
console.log(`${colors.dim}Model:${colors.reset} ${model.name}`);
|
|
43649
|
+
console.log(`${colors.dim}Thinking:${colors.reset} ${config2.thinkingLevel}`);
|
|
43461
43650
|
if (useRepoContext) {
|
|
43462
43651
|
console.log(`${colors.dim}Project context:${colors.reset} enabled`);
|
|
43463
43652
|
}
|
|
@@ -43692,6 +43881,19 @@ ${colors.bold}Available Themes${colors.reset}
|
|
|
43692
43881
|
console.log(`${colors.success}\u2713 Safety level set to ${level}${colors.reset}`);
|
|
43693
43882
|
return;
|
|
43694
43883
|
}
|
|
43884
|
+
if (args[0] === "--thinking" && args[1]) {
|
|
43885
|
+
const level = args[1].toLowerCase();
|
|
43886
|
+
if (level !== "off" && level !== "low" && level !== "medium" && level !== "high") {
|
|
43887
|
+
console.error(`${colors.error}Unknown thinking level: ${level}${colors.reset}`);
|
|
43888
|
+
console.error(`Valid levels: off, low, medium, high`);
|
|
43889
|
+
process.exit(1);
|
|
43890
|
+
}
|
|
43891
|
+
const config2 = loadConfig();
|
|
43892
|
+
config2.thinkingLevel = level;
|
|
43893
|
+
saveConfig(config2);
|
|
43894
|
+
console.log(`${colors.success}\u2713 Thinking level set to ${level}${colors.reset}`);
|
|
43895
|
+
return;
|
|
43896
|
+
}
|
|
43695
43897
|
let execute = false;
|
|
43696
43898
|
let dryRun = false;
|
|
43697
43899
|
let repoContext = undefined;
|