oh-my-opencode-medium 0.8.2 → 0.8.3
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 +57 -24
- package/dist/cli/index.js +177 -2518
- package/dist/config/schema.d.ts +3 -0
- package/dist/index.js +100 -48
- package/dist/utils/internal-initiator.d.ts +1 -1
- package/oh-my-opencode-slim.schema.json +448 -0
- package/package.json +8 -6
- package/src/skills/cartography/SKILL.md +23 -0
package/dist/cli/index.js
CHANGED
|
@@ -10,74 +10,6 @@ var __export = (target, all) => {
|
|
|
10
10
|
set: (newValue) => all[name] = () => newValue
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
// src/cli/install.ts
|
|
15
|
-
import * as readline from "readline/promises";
|
|
16
|
-
|
|
17
|
-
// src/cli/model-selection.ts
|
|
18
|
-
function defaultTieBreaker(left, right) {
|
|
19
|
-
return left.model.localeCompare(right.model);
|
|
20
|
-
}
|
|
21
|
-
function rankModels(models, scoreFn, options = {}) {
|
|
22
|
-
const excluded = new Set(options.excludeModels ?? []);
|
|
23
|
-
const tieBreaker = options.tieBreaker ?? defaultTieBreaker;
|
|
24
|
-
return models.filter((model) => !excluded.has(model.model)).map((candidate) => ({
|
|
25
|
-
candidate,
|
|
26
|
-
score: scoreFn(candidate)
|
|
27
|
-
})).sort((left, right) => {
|
|
28
|
-
if (left.score !== right.score)
|
|
29
|
-
return right.score - left.score;
|
|
30
|
-
return tieBreaker(left.candidate, right.candidate);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
function pickBestModel(models, scoreFn, options = {}) {
|
|
34
|
-
return rankModels(models, scoreFn, options)[0]?.candidate ?? null;
|
|
35
|
-
}
|
|
36
|
-
function pickPrimaryAndSupport(models, scoring, preferredPrimaryModel) {
|
|
37
|
-
if (models.length === 0)
|
|
38
|
-
return { primary: null, support: null };
|
|
39
|
-
const preferredPrimary = preferredPrimaryModel ? models.find((candidate) => candidate.model === preferredPrimaryModel) : undefined;
|
|
40
|
-
const primary = preferredPrimary ?? pickBestModel(models, scoring.primary);
|
|
41
|
-
if (!primary)
|
|
42
|
-
return { primary: null, support: null };
|
|
43
|
-
const support = pickBestModel(models, scoring.support, {
|
|
44
|
-
excludeModels: [primary.model]
|
|
45
|
-
}) ?? pickBestModel(models, scoring.support);
|
|
46
|
-
return { primary, support };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/cli/chutes-selection.ts
|
|
50
|
-
function speedBonus(modelName) {
|
|
51
|
-
const lower = modelName.toLowerCase();
|
|
52
|
-
let score = 0;
|
|
53
|
-
if (lower.includes("nano"))
|
|
54
|
-
score += 60;
|
|
55
|
-
if (lower.includes("flash"))
|
|
56
|
-
score += 45;
|
|
57
|
-
if (lower.includes("mini"))
|
|
58
|
-
score += 30;
|
|
59
|
-
if (lower.includes("lite"))
|
|
60
|
-
score += 20;
|
|
61
|
-
if (lower.includes("small"))
|
|
62
|
-
score += 15;
|
|
63
|
-
return score;
|
|
64
|
-
}
|
|
65
|
-
var scoreChutesPrimaryForCoding = (model) => {
|
|
66
|
-
return (model.reasoning ? 120 : 0) + (model.toolcall ? 80 : 0) + (model.attachment ? 20 : 0) + Math.min(model.contextLimit, 1e6) / 9000 + Math.min(model.outputLimit, 300000) / 1e4 + (model.status === "active" ? 10 : 0);
|
|
67
|
-
};
|
|
68
|
-
var scoreChutesSupportForCoding = (model) => {
|
|
69
|
-
return (model.toolcall ? 90 : 0) + (model.reasoning ? 35 : 0) + speedBonus(model.model) + Math.min(model.contextLimit, 400000) / 20000 + (model.status === "active" ? 8 : 0);
|
|
70
|
-
};
|
|
71
|
-
function pickBestCodingChutesModel(models) {
|
|
72
|
-
return pickBestModel(models, scoreChutesPrimaryForCoding);
|
|
73
|
-
}
|
|
74
|
-
function pickSupportChutesModel(models, primaryModel) {
|
|
75
|
-
const { support } = pickPrimaryAndSupport(models, {
|
|
76
|
-
primary: scoreChutesPrimaryForCoding,
|
|
77
|
-
support: scoreChutesSupportForCoding
|
|
78
|
-
}, primaryModel);
|
|
79
|
-
return support;
|
|
80
|
-
}
|
|
81
13
|
// src/cli/config-io.ts
|
|
82
14
|
import {
|
|
83
15
|
copyFileSync as copyFileSync2,
|
|
@@ -13740,10 +13672,12 @@ var BackgroundTaskConfigSchema = exports_external.object({
|
|
|
13740
13672
|
var FailoverConfigSchema = exports_external.object({
|
|
13741
13673
|
enabled: exports_external.boolean().default(true),
|
|
13742
13674
|
timeoutMs: exports_external.number().min(0).default(15000),
|
|
13675
|
+
retryDelayMs: exports_external.number().min(0).default(500),
|
|
13743
13676
|
chains: FallbackChainsSchema.default({})
|
|
13744
13677
|
});
|
|
13745
13678
|
var PluginConfigSchema = exports_external.object({
|
|
13746
13679
|
preset: exports_external.string().optional(),
|
|
13680
|
+
setDefaultAgent: exports_external.boolean().optional(),
|
|
13747
13681
|
scoringEngineVersion: exports_external.enum(["v1", "v2-shadow", "v2"]).optional(),
|
|
13748
13682
|
balanceProviderUsage: exports_external.boolean().optional(),
|
|
13749
13683
|
manualPlan: ManualPlanSchema.optional(),
|
|
@@ -14397,145 +14331,6 @@ function disableDefaultAgents() {
|
|
|
14397
14331
|
};
|
|
14398
14332
|
}
|
|
14399
14333
|
}
|
|
14400
|
-
function addAntigravityPlugin() {
|
|
14401
|
-
const configPath = getExistingConfigPath();
|
|
14402
|
-
try {
|
|
14403
|
-
const { config: parsedConfig, error: error48 } = parseConfig(configPath);
|
|
14404
|
-
if (error48) {
|
|
14405
|
-
return {
|
|
14406
|
-
success: false,
|
|
14407
|
-
configPath,
|
|
14408
|
-
error: `Failed to parse config: ${error48}`
|
|
14409
|
-
};
|
|
14410
|
-
}
|
|
14411
|
-
const config2 = parsedConfig ?? {};
|
|
14412
|
-
const plugins = config2.plugin ?? [];
|
|
14413
|
-
const pluginName = "opencode-antigravity-auth@latest";
|
|
14414
|
-
if (!plugins.includes(pluginName)) {
|
|
14415
|
-
plugins.push(pluginName);
|
|
14416
|
-
}
|
|
14417
|
-
config2.plugin = plugins;
|
|
14418
|
-
writeConfig(configPath, config2);
|
|
14419
|
-
return { success: true, configPath };
|
|
14420
|
-
} catch (err) {
|
|
14421
|
-
return {
|
|
14422
|
-
success: false,
|
|
14423
|
-
configPath,
|
|
14424
|
-
error: `Failed to add antigravity plugin: ${err}`
|
|
14425
|
-
};
|
|
14426
|
-
}
|
|
14427
|
-
}
|
|
14428
|
-
function addGoogleProvider() {
|
|
14429
|
-
const configPath = getExistingConfigPath();
|
|
14430
|
-
try {
|
|
14431
|
-
const { config: parsedConfig, error: error48 } = parseConfig(configPath);
|
|
14432
|
-
if (error48) {
|
|
14433
|
-
return {
|
|
14434
|
-
success: false,
|
|
14435
|
-
configPath,
|
|
14436
|
-
error: `Failed to parse config: ${error48}`
|
|
14437
|
-
};
|
|
14438
|
-
}
|
|
14439
|
-
const config2 = parsedConfig ?? {};
|
|
14440
|
-
const providers = config2.provider ?? {};
|
|
14441
|
-
providers.google = {
|
|
14442
|
-
models: {
|
|
14443
|
-
"antigravity-gemini-3.1-pro": {
|
|
14444
|
-
name: "Gemini 3.1 Pro (Antigravity)",
|
|
14445
|
-
limit: { context: 1048576, output: 65535 },
|
|
14446
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
14447
|
-
variants: {
|
|
14448
|
-
low: { thinkingLevel: "low" },
|
|
14449
|
-
high: { thinkingLevel: "high" }
|
|
14450
|
-
}
|
|
14451
|
-
},
|
|
14452
|
-
"antigravity-gemini-3-flash": {
|
|
14453
|
-
name: "Gemini 3 Flash (Antigravity)",
|
|
14454
|
-
limit: { context: 1048576, output: 65536 },
|
|
14455
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
14456
|
-
variants: {
|
|
14457
|
-
minimal: { thinkingLevel: "minimal" },
|
|
14458
|
-
low: { thinkingLevel: "low" },
|
|
14459
|
-
medium: { thinkingLevel: "medium" },
|
|
14460
|
-
high: { thinkingLevel: "high" }
|
|
14461
|
-
}
|
|
14462
|
-
},
|
|
14463
|
-
"antigravity-claude-sonnet-4-5": {
|
|
14464
|
-
name: "Claude Sonnet 4.5 (Antigravity)",
|
|
14465
|
-
limit: { context: 200000, output: 64000 },
|
|
14466
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
14467
|
-
},
|
|
14468
|
-
"antigravity-claude-sonnet-4-5-thinking": {
|
|
14469
|
-
name: "Claude Sonnet 4.5 Thinking (Antigravity)",
|
|
14470
|
-
limit: { context: 200000, output: 64000 },
|
|
14471
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
14472
|
-
variants: {
|
|
14473
|
-
low: { thinkingConfig: { thinkingBudget: 8192 } },
|
|
14474
|
-
max: { thinkingConfig: { thinkingBudget: 32768 } }
|
|
14475
|
-
}
|
|
14476
|
-
},
|
|
14477
|
-
"antigravity-claude-opus-4-5-thinking": {
|
|
14478
|
-
name: "Claude Opus 4.5 Thinking (Antigravity)",
|
|
14479
|
-
limit: { context: 200000, output: 64000 },
|
|
14480
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] },
|
|
14481
|
-
variants: {
|
|
14482
|
-
low: { thinkingConfig: { thinkingBudget: 8192 } },
|
|
14483
|
-
max: { thinkingConfig: { thinkingBudget: 32768 } }
|
|
14484
|
-
}
|
|
14485
|
-
},
|
|
14486
|
-
"gemini-2.5-flash": {
|
|
14487
|
-
name: "Gemini 2.5 Flash (Gemini CLI)",
|
|
14488
|
-
limit: { context: 1048576, output: 65536 },
|
|
14489
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
14490
|
-
},
|
|
14491
|
-
"gemini-2.5-pro": {
|
|
14492
|
-
name: "Gemini 2.5 Pro (Gemini CLI)",
|
|
14493
|
-
limit: { context: 1048576, output: 65536 },
|
|
14494
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
14495
|
-
},
|
|
14496
|
-
"gemini-3-flash-preview": {
|
|
14497
|
-
name: "Gemini 3 Flash Preview (Gemini CLI)",
|
|
14498
|
-
limit: { context: 1048576, output: 65536 },
|
|
14499
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
14500
|
-
},
|
|
14501
|
-
"gemini-3.1-pro-preview": {
|
|
14502
|
-
name: "Gemini 3.1 Pro Preview (Gemini CLI)",
|
|
14503
|
-
limit: { context: 1048576, output: 65535 },
|
|
14504
|
-
modalities: { input: ["text", "image", "pdf"], output: ["text"] }
|
|
14505
|
-
}
|
|
14506
|
-
}
|
|
14507
|
-
};
|
|
14508
|
-
config2.provider = providers;
|
|
14509
|
-
writeConfig(configPath, config2);
|
|
14510
|
-
return { success: true, configPath };
|
|
14511
|
-
} catch (err) {
|
|
14512
|
-
return {
|
|
14513
|
-
success: false,
|
|
14514
|
-
configPath,
|
|
14515
|
-
error: `Failed to add google provider: ${err}`
|
|
14516
|
-
};
|
|
14517
|
-
}
|
|
14518
|
-
}
|
|
14519
|
-
function addChutesProvider() {
|
|
14520
|
-
const configPath = getExistingConfigPath();
|
|
14521
|
-
try {
|
|
14522
|
-
const { error: error48 } = parseConfig(configPath);
|
|
14523
|
-
if (error48) {
|
|
14524
|
-
return {
|
|
14525
|
-
success: false,
|
|
14526
|
-
configPath,
|
|
14527
|
-
error: `Failed to parse config: ${error48}`
|
|
14528
|
-
};
|
|
14529
|
-
}
|
|
14530
|
-
return { success: true, configPath };
|
|
14531
|
-
} catch (err) {
|
|
14532
|
-
return {
|
|
14533
|
-
success: false,
|
|
14534
|
-
configPath,
|
|
14535
|
-
error: `Failed to validate chutes provider config: ${err}`
|
|
14536
|
-
};
|
|
14537
|
-
}
|
|
14538
|
-
}
|
|
14539
14334
|
function detectCurrentConfig() {
|
|
14540
14335
|
const result = {
|
|
14541
14336
|
isInstalled: false,
|
|
@@ -14590,1549 +14385,133 @@ function detectCurrentConfig() {
|
|
|
14590
14385
|
}
|
|
14591
14386
|
return result;
|
|
14592
14387
|
}
|
|
14593
|
-
// src/cli/model-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
}
|
|
14633
|
-
}
|
|
14634
|
-
}
|
|
14635
|
-
function buildModelKeyAliases(input) {
|
|
14636
|
-
const normalized = input.trim().toLowerCase();
|
|
14637
|
-
if (!normalized)
|
|
14638
|
-
return [];
|
|
14639
|
-
const aliases = new Set;
|
|
14640
|
-
const slashIndex = normalized.indexOf("/");
|
|
14641
|
-
const afterProvider = slashIndex >= 0 ? normalized.slice(slashIndex + 1) : normalized;
|
|
14642
|
-
addDerivedAliases(normalized, aliases);
|
|
14643
|
-
addDerivedAliases(afterProvider, aliases);
|
|
14644
|
-
return [...aliases].filter((alias) => alias.length > 0);
|
|
14388
|
+
// src/cli/dynamic-model-selection.ts
|
|
14389
|
+
var FREE_BIASED_PROVIDERS = new Set(["opencode"]);
|
|
14390
|
+
// src/utils/logger.ts
|
|
14391
|
+
import * as os from "os";
|
|
14392
|
+
import * as path from "path";
|
|
14393
|
+
var logFile = path.join(os.tmpdir(), "oh-my-opencode-medium.log");
|
|
14394
|
+
// src/cli/system.ts
|
|
14395
|
+
import { statSync as statSync3 } from "fs";
|
|
14396
|
+
var cachedOpenCodePath = null;
|
|
14397
|
+
function getOpenCodePaths() {
|
|
14398
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
14399
|
+
return [
|
|
14400
|
+
"opencode",
|
|
14401
|
+
`${home}/.local/bin/opencode`,
|
|
14402
|
+
`${home}/.opencode/bin/opencode`,
|
|
14403
|
+
`${home}/bin/opencode`,
|
|
14404
|
+
"/usr/local/bin/opencode",
|
|
14405
|
+
"/opt/opencode/bin/opencode",
|
|
14406
|
+
"/usr/bin/opencode",
|
|
14407
|
+
"/bin/opencode",
|
|
14408
|
+
"/Applications/OpenCode.app/Contents/MacOS/opencode",
|
|
14409
|
+
`${home}/Applications/OpenCode.app/Contents/MacOS/opencode`,
|
|
14410
|
+
"/opt/homebrew/bin/opencode",
|
|
14411
|
+
"/home/linuxbrew/.linuxbrew/bin/opencode",
|
|
14412
|
+
`${home}/homebrew/bin/opencode`,
|
|
14413
|
+
`${home}/Library/Application Support/opencode/bin/opencode`,
|
|
14414
|
+
"/snap/bin/opencode",
|
|
14415
|
+
"/var/snap/opencode/current/bin/opencode",
|
|
14416
|
+
"/var/lib/flatpak/exports/bin/ai.opencode.OpenCode",
|
|
14417
|
+
`${home}/.local/share/flatpak/exports/bin/ai.opencode.OpenCode`,
|
|
14418
|
+
"/nix/store/opencode/bin/opencode",
|
|
14419
|
+
`${home}/.nix-profile/bin/opencode`,
|
|
14420
|
+
"/run/current-system/sw/bin/opencode",
|
|
14421
|
+
`${home}/.cargo/bin/opencode`,
|
|
14422
|
+
`${home}/.npm-global/bin/opencode`,
|
|
14423
|
+
"/usr/local/lib/node_modules/opencode/bin/opencode",
|
|
14424
|
+
`${home}/.yarn/bin/opencode`,
|
|
14425
|
+
`${home}/.pnpm-global/bin/opencode`
|
|
14426
|
+
];
|
|
14645
14427
|
}
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
const
|
|
14651
|
-
for (const
|
|
14652
|
-
if (
|
|
14428
|
+
function resolveOpenCodePath() {
|
|
14429
|
+
if (cachedOpenCodePath) {
|
|
14430
|
+
return cachedOpenCodePath;
|
|
14431
|
+
}
|
|
14432
|
+
const paths = getOpenCodePaths();
|
|
14433
|
+
for (const opencodePath of paths) {
|
|
14434
|
+
if (opencodePath === "opencode")
|
|
14653
14435
|
continue;
|
|
14654
|
-
|
|
14655
|
-
|
|
14436
|
+
try {
|
|
14437
|
+
const stat = statSync3(opencodePath);
|
|
14438
|
+
if (stat.isFile()) {
|
|
14439
|
+
cachedOpenCodePath = opencodePath;
|
|
14440
|
+
return opencodePath;
|
|
14441
|
+
}
|
|
14442
|
+
} catch {}
|
|
14656
14443
|
}
|
|
14657
|
-
return
|
|
14444
|
+
return "opencode";
|
|
14658
14445
|
}
|
|
14659
|
-
function
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14666
|
-
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
}
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
models: input.dynamicRecommendation ?? []
|
|
14676
|
-
},
|
|
14677
|
-
{
|
|
14678
|
-
layer: "provider-fallback-policy",
|
|
14679
|
-
models: input.providerFallbackPolicy ?? []
|
|
14680
|
-
},
|
|
14681
|
-
{
|
|
14682
|
-
layer: "system-default",
|
|
14683
|
-
models: input.systemDefault
|
|
14684
|
-
}
|
|
14685
|
-
];
|
|
14446
|
+
async function isOpenCodeInstalled() {
|
|
14447
|
+
const paths = getOpenCodePaths();
|
|
14448
|
+
for (const opencodePath of paths) {
|
|
14449
|
+
try {
|
|
14450
|
+
const proc = Bun.spawn([opencodePath, "--version"], {
|
|
14451
|
+
stdout: "pipe",
|
|
14452
|
+
stderr: "pipe"
|
|
14453
|
+
});
|
|
14454
|
+
await proc.exited;
|
|
14455
|
+
if (proc.exitCode === 0) {
|
|
14456
|
+
cachedOpenCodePath = opencodePath;
|
|
14457
|
+
return true;
|
|
14458
|
+
}
|
|
14459
|
+
} catch {}
|
|
14460
|
+
}
|
|
14461
|
+
return false;
|
|
14686
14462
|
}
|
|
14687
|
-
function
|
|
14688
|
-
const
|
|
14689
|
-
|
|
14690
|
-
|
|
14691
|
-
|
|
14692
|
-
|
|
14693
|
-
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
winnerLayer: winnerLayer?.layer ?? "system-default",
|
|
14699
|
-
winnerModel: model
|
|
14463
|
+
async function getOpenCodeVersion() {
|
|
14464
|
+
const opencodePath = resolveOpenCodePath();
|
|
14465
|
+
try {
|
|
14466
|
+
const proc = Bun.spawn([opencodePath, "--version"], {
|
|
14467
|
+
stdout: "pipe",
|
|
14468
|
+
stderr: "pipe"
|
|
14469
|
+
});
|
|
14470
|
+
const output = await new Response(proc.stdout).text();
|
|
14471
|
+
await proc.exited;
|
|
14472
|
+
if (proc.exitCode === 0) {
|
|
14473
|
+
return output.trim();
|
|
14700
14474
|
}
|
|
14701
|
-
}
|
|
14702
|
-
|
|
14703
|
-
|
|
14704
|
-
// src/cli/scoring-v2/features.ts
|
|
14705
|
-
function modelLookupKeys(model) {
|
|
14706
|
-
return buildModelKeyAliases(model.model);
|
|
14707
|
-
}
|
|
14708
|
-
function findSignal(model, externalSignals) {
|
|
14709
|
-
if (!externalSignals)
|
|
14710
|
-
return;
|
|
14711
|
-
return modelLookupKeys(model).map((key) => externalSignals[key]).find((item) => item !== undefined);
|
|
14712
|
-
}
|
|
14713
|
-
function statusValue(status) {
|
|
14714
|
-
if (status === "active")
|
|
14715
|
-
return 1;
|
|
14716
|
-
if (status === "beta")
|
|
14717
|
-
return 0.4;
|
|
14718
|
-
if (status === "alpha")
|
|
14719
|
-
return -0.25;
|
|
14720
|
-
return -1;
|
|
14721
|
-
}
|
|
14722
|
-
function capability(value) {
|
|
14723
|
-
return value ? 1 : 0;
|
|
14724
|
-
}
|
|
14725
|
-
function blendedPrice(signal) {
|
|
14726
|
-
if (!signal)
|
|
14727
|
-
return 0;
|
|
14728
|
-
if (signal.inputPricePer1M !== undefined && signal.outputPricePer1M !== undefined) {
|
|
14729
|
-
return signal.inputPricePer1M * 0.75 + signal.outputPricePer1M * 0.25;
|
|
14730
|
-
}
|
|
14731
|
-
return signal.inputPricePer1M ?? signal.outputPricePer1M ?? 0;
|
|
14732
|
-
}
|
|
14733
|
-
function kimiVersionBonus(agent, model) {
|
|
14734
|
-
const lowered = `${model.model} ${model.name}`.toLowerCase();
|
|
14735
|
-
const isChutes = model.providerID === "chutes";
|
|
14736
|
-
const isQwen3 = isChutes && /qwen3/.test(lowered);
|
|
14737
|
-
const isKimiK25 = /kimi-k2\.5|k2\.5/.test(lowered);
|
|
14738
|
-
const isMinimaxM21 = isChutes && /minimax[-_ ]?m2\.1/.test(lowered);
|
|
14739
|
-
const qwenPenalty = {
|
|
14740
|
-
orchestrator: -6,
|
|
14741
|
-
oracle: -6,
|
|
14742
|
-
designer: -8,
|
|
14743
|
-
explorer: -6,
|
|
14744
|
-
librarian: -12,
|
|
14745
|
-
fixer: -12
|
|
14746
|
-
};
|
|
14747
|
-
const kimiBonus = {
|
|
14748
|
-
orchestrator: 1,
|
|
14749
|
-
oracle: 1,
|
|
14750
|
-
designer: 3,
|
|
14751
|
-
explorer: 2,
|
|
14752
|
-
librarian: 2,
|
|
14753
|
-
fixer: 3
|
|
14754
|
-
};
|
|
14755
|
-
const minimaxBonus = {
|
|
14756
|
-
orchestrator: 1,
|
|
14757
|
-
oracle: 1,
|
|
14758
|
-
designer: 2,
|
|
14759
|
-
explorer: 4,
|
|
14760
|
-
librarian: 4,
|
|
14761
|
-
fixer: 4
|
|
14762
|
-
};
|
|
14763
|
-
if (isQwen3)
|
|
14764
|
-
return qwenPenalty[agent];
|
|
14765
|
-
if (isKimiK25)
|
|
14766
|
-
return kimiBonus[agent];
|
|
14767
|
-
if (isMinimaxM21)
|
|
14768
|
-
return minimaxBonus[agent];
|
|
14769
|
-
return 0;
|
|
14475
|
+
} catch {}
|
|
14476
|
+
return null;
|
|
14770
14477
|
}
|
|
14771
|
-
function
|
|
14772
|
-
const
|
|
14773
|
-
|
|
14774
|
-
const normalizedContext = Math.min(model.contextLimit, 1e6) / 1e5;
|
|
14775
|
-
const normalizedOutput = Math.min(model.outputLimit, 300000) / 30000;
|
|
14776
|
-
const designerOutputScore = model.outputLimit < 64000 ? -1 : 0;
|
|
14777
|
-
const versionBonus = kimiVersionBonus(agent, model);
|
|
14778
|
-
const quality = (signal?.qualityScore ?? 0) / 100;
|
|
14779
|
-
const coding = (signal?.codingScore ?? 0) / 100;
|
|
14780
|
-
const pricePenalty = Math.min(blendedPrice(signal), 50) / 10;
|
|
14781
|
-
const explorerLatencyMultiplier = agent === "explorer" ? 1.4 : 1;
|
|
14782
|
-
return {
|
|
14783
|
-
status: statusValue(model.status),
|
|
14784
|
-
context: normalizedContext,
|
|
14785
|
-
output: agent === "designer" ? designerOutputScore : normalizedOutput,
|
|
14786
|
-
versionBonus,
|
|
14787
|
-
reasoning: capability(model.reasoning),
|
|
14788
|
-
toolcall: capability(model.toolcall),
|
|
14789
|
-
attachment: capability(model.attachment),
|
|
14790
|
-
quality,
|
|
14791
|
-
coding,
|
|
14792
|
-
latencyPenalty: Math.min(latency, 20) * explorerLatencyMultiplier,
|
|
14793
|
-
pricePenalty
|
|
14794
|
-
};
|
|
14478
|
+
function getOpenCodePath() {
|
|
14479
|
+
const path2 = resolveOpenCodePath();
|
|
14480
|
+
return path2 === "opencode" ? null : path2;
|
|
14795
14481
|
}
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
var
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
};
|
|
14811
|
-
var AGENT_WEIGHT_OVERRIDES = {
|
|
14812
|
-
orchestrator: {
|
|
14813
|
-
reasoning: 22,
|
|
14814
|
-
toolcall: 22,
|
|
14815
|
-
quality: 16,
|
|
14816
|
-
coding: 16,
|
|
14817
|
-
latencyPenalty: -2
|
|
14818
|
-
},
|
|
14819
|
-
oracle: {
|
|
14820
|
-
reasoning: 26,
|
|
14821
|
-
quality: 20,
|
|
14822
|
-
coding: 18,
|
|
14823
|
-
latencyPenalty: -2,
|
|
14824
|
-
output: 7
|
|
14825
|
-
},
|
|
14826
|
-
designer: {
|
|
14827
|
-
attachment: 12,
|
|
14828
|
-
output: 10,
|
|
14829
|
-
quality: 16,
|
|
14830
|
-
coding: 10
|
|
14831
|
-
},
|
|
14832
|
-
explorer: {
|
|
14833
|
-
latencyPenalty: -8,
|
|
14834
|
-
toolcall: 24,
|
|
14835
|
-
reasoning: 2,
|
|
14836
|
-
context: 4,
|
|
14837
|
-
output: 4
|
|
14838
|
-
},
|
|
14839
|
-
librarian: {
|
|
14840
|
-
context: 14,
|
|
14841
|
-
output: 10,
|
|
14842
|
-
quality: 18,
|
|
14843
|
-
coding: 14
|
|
14844
|
-
},
|
|
14845
|
-
fixer: {
|
|
14846
|
-
coding: 28,
|
|
14847
|
-
toolcall: 22,
|
|
14848
|
-
reasoning: 12,
|
|
14849
|
-
output: 10
|
|
14850
|
-
}
|
|
14482
|
+
// src/cli/install.ts
|
|
14483
|
+
var GREEN = "\x1B[32m";
|
|
14484
|
+
var BLUE = "\x1B[34m";
|
|
14485
|
+
var RED = "\x1B[31m";
|
|
14486
|
+
var BOLD = "\x1B[1m";
|
|
14487
|
+
var DIM = "\x1B[2m";
|
|
14488
|
+
var RESET = "\x1B[0m";
|
|
14489
|
+
var SYMBOLS = {
|
|
14490
|
+
check: `${GREEN}\u2713${RESET}`,
|
|
14491
|
+
cross: `${RED}\u2717${RESET}`,
|
|
14492
|
+
arrow: `${BLUE}\u2192${RESET}`,
|
|
14493
|
+
bullet: `${DIM}\u2022${RESET}`,
|
|
14494
|
+
info: `${BLUE}\u2139${RESET}`,
|
|
14495
|
+
star: `${BLUE}\u2605${RESET}`
|
|
14851
14496
|
};
|
|
14852
|
-
function
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
|
|
14497
|
+
function printHeader(isUpdate) {
|
|
14498
|
+
console.log();
|
|
14499
|
+
console.log(`${BOLD}oh-my-opencode-medium ${isUpdate ? "Update" : "Install"}${RESET}`);
|
|
14500
|
+
console.log("=".repeat(30));
|
|
14501
|
+
console.log();
|
|
14857
14502
|
}
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
function weightedFeatures(features, weights) {
|
|
14861
|
-
return {
|
|
14862
|
-
status: features.status * weights.status,
|
|
14863
|
-
context: features.context * weights.context,
|
|
14864
|
-
output: features.output * weights.output,
|
|
14865
|
-
versionBonus: features.versionBonus * weights.versionBonus,
|
|
14866
|
-
reasoning: features.reasoning * weights.reasoning,
|
|
14867
|
-
toolcall: features.toolcall * weights.toolcall,
|
|
14868
|
-
attachment: features.attachment * weights.attachment,
|
|
14869
|
-
quality: features.quality * weights.quality,
|
|
14870
|
-
coding: features.coding * weights.coding,
|
|
14871
|
-
latencyPenalty: features.latencyPenalty * weights.latencyPenalty,
|
|
14872
|
-
pricePenalty: features.pricePenalty * weights.pricePenalty
|
|
14873
|
-
};
|
|
14874
|
-
}
|
|
14875
|
-
function sumFeatures(features) {
|
|
14876
|
-
return features.status + features.context + features.output + features.versionBonus + features.reasoning + features.toolcall + features.attachment + features.quality + features.coding + features.latencyPenalty + features.pricePenalty;
|
|
14877
|
-
}
|
|
14878
|
-
function withStableTieBreak(left, right) {
|
|
14879
|
-
if (left.totalScore !== right.totalScore) {
|
|
14880
|
-
return right.totalScore - left.totalScore;
|
|
14881
|
-
}
|
|
14882
|
-
const providerDelta = left.model.providerID.localeCompare(right.model.providerID);
|
|
14883
|
-
if (providerDelta !== 0) {
|
|
14884
|
-
return providerDelta;
|
|
14885
|
-
}
|
|
14886
|
-
return left.model.model.localeCompare(right.model.model);
|
|
14887
|
-
}
|
|
14888
|
-
function scoreCandidateV2(model, agent, externalSignals) {
|
|
14889
|
-
const features = extractFeatureVector(model, agent, externalSignals);
|
|
14890
|
-
const weights = getFeatureWeights(agent);
|
|
14891
|
-
const weighted = weightedFeatures(features, weights);
|
|
14892
|
-
return {
|
|
14893
|
-
model,
|
|
14894
|
-
totalScore: Math.round(sumFeatures(weighted) * 1000) / 1000,
|
|
14895
|
-
scoreBreakdown: {
|
|
14896
|
-
features,
|
|
14897
|
-
weighted
|
|
14898
|
-
}
|
|
14899
|
-
};
|
|
14503
|
+
function printStep(step, total, message) {
|
|
14504
|
+
console.log(`${DIM}[${step}/${total}]${RESET} ${message}`);
|
|
14900
14505
|
}
|
|
14901
|
-
function
|
|
14902
|
-
|
|
14506
|
+
function printSuccess(message) {
|
|
14507
|
+
console.log(`${SYMBOLS.check} ${message}`);
|
|
14903
14508
|
}
|
|
14904
|
-
|
|
14905
|
-
|
|
14906
|
-
"orchestrator",
|
|
14907
|
-
"oracle",
|
|
14908
|
-
"designer",
|
|
14909
|
-
"explorer",
|
|
14910
|
-
"librarian",
|
|
14911
|
-
"fixer"
|
|
14912
|
-
];
|
|
14913
|
-
var FREE_BIASED_PROVIDERS = new Set(["opencode"]);
|
|
14914
|
-
var PRIMARY_ASSIGNMENT_ORDER = [
|
|
14915
|
-
"oracle",
|
|
14916
|
-
"orchestrator",
|
|
14917
|
-
"fixer",
|
|
14918
|
-
"designer",
|
|
14919
|
-
"librarian",
|
|
14920
|
-
"explorer"
|
|
14921
|
-
];
|
|
14922
|
-
var ROLE_VARIANT = {
|
|
14923
|
-
orchestrator: undefined,
|
|
14924
|
-
oracle: "high",
|
|
14925
|
-
designer: "medium",
|
|
14926
|
-
explorer: "low",
|
|
14927
|
-
librarian: "low",
|
|
14928
|
-
fixer: "low"
|
|
14929
|
-
};
|
|
14930
|
-
function getEnabledProviders(config2) {
|
|
14931
|
-
const providers = [];
|
|
14932
|
-
if (config2.hasOpenAI)
|
|
14933
|
-
providers.push("openai");
|
|
14934
|
-
if (config2.hasAnthropic)
|
|
14935
|
-
providers.push("anthropic");
|
|
14936
|
-
if (config2.hasCopilot)
|
|
14937
|
-
providers.push("github-copilot");
|
|
14938
|
-
if (config2.hasZaiPlan)
|
|
14939
|
-
providers.push("zai-coding-plan");
|
|
14940
|
-
if (config2.hasKimi)
|
|
14941
|
-
providers.push("kimi-for-coding");
|
|
14942
|
-
if (config2.hasAntigravity)
|
|
14943
|
-
providers.push("google");
|
|
14944
|
-
if (config2.hasChutes)
|
|
14945
|
-
providers.push("chutes");
|
|
14946
|
-
if (config2.useOpenCodeFreeModels)
|
|
14947
|
-
providers.push("opencode");
|
|
14948
|
-
return providers;
|
|
14949
|
-
}
|
|
14950
|
-
function tokenScore(name, re, points) {
|
|
14951
|
-
return re.test(name) ? points : 0;
|
|
14952
|
-
}
|
|
14953
|
-
function statusScore(status) {
|
|
14954
|
-
if (status === "active")
|
|
14955
|
-
return 20;
|
|
14956
|
-
if (status === "beta")
|
|
14957
|
-
return 8;
|
|
14958
|
-
if (status === "alpha")
|
|
14959
|
-
return -5;
|
|
14960
|
-
return -40;
|
|
14961
|
-
}
|
|
14962
|
-
function toVersionTuple(major, minor, patch) {
|
|
14963
|
-
return [
|
|
14964
|
-
Number.parseInt(major, 10) || 0,
|
|
14965
|
-
Number.parseInt(minor ?? "0", 10) || 0,
|
|
14966
|
-
Number.parseInt(patch ?? "0", 10) || 0
|
|
14967
|
-
];
|
|
14968
|
-
}
|
|
14969
|
-
function compareVersionTuple(a, b) {
|
|
14970
|
-
if (a[0] !== b[0])
|
|
14971
|
-
return a[0] - b[0];
|
|
14972
|
-
if (a[1] !== b[1])
|
|
14973
|
-
return a[1] - b[1];
|
|
14974
|
-
return a[2] - b[2];
|
|
14975
|
-
}
|
|
14976
|
-
function extractVersionFamily(model) {
|
|
14977
|
-
const text = `${model.model} ${model.name}`.toLowerCase();
|
|
14978
|
-
const gpt = text.match(/\bgpt[-_ ]?(\d+)(?:[.-](\d+))?(?:[.-](\d+))?\b/);
|
|
14979
|
-
if (gpt) {
|
|
14980
|
-
return {
|
|
14981
|
-
family: "gpt",
|
|
14982
|
-
version: toVersionTuple(gpt[1] ?? "0", gpt[2], gpt[3]),
|
|
14983
|
-
confidence: 1,
|
|
14984
|
-
prereleasePenalty: /preview|experimental|exp|\brc\b/.test(text) ? -2 : 0
|
|
14985
|
-
};
|
|
14986
|
-
}
|
|
14987
|
-
const gemini = text.match(/\bgemini[-_ ]?(\d+)(?:[.-](\d+))?(?:[.-](\d+))?\b/);
|
|
14988
|
-
if (gemini) {
|
|
14989
|
-
return {
|
|
14990
|
-
family: "gemini",
|
|
14991
|
-
version: toVersionTuple(gemini[1] ?? "0", gemini[2], gemini[3]),
|
|
14992
|
-
confidence: 1,
|
|
14993
|
-
prereleasePenalty: /preview|experimental|exp|\brc\b/.test(text) ? -2 : 0
|
|
14994
|
-
};
|
|
14995
|
-
}
|
|
14996
|
-
const kimi = text.match(/\bkimi[-_ ]?k(\d+)(?:[.-]?(\d+))?(?:[.-](\d+))?\b/);
|
|
14997
|
-
if (kimi) {
|
|
14998
|
-
return {
|
|
14999
|
-
family: "kimi-k",
|
|
15000
|
-
version: toVersionTuple(kimi[1] ?? "0", kimi[2], kimi[3]),
|
|
15001
|
-
confidence: 1,
|
|
15002
|
-
prereleasePenalty: /preview|experimental|exp|\brc\b/.test(text) ? -2 : 0
|
|
15003
|
-
};
|
|
15004
|
-
}
|
|
15005
|
-
const generic = text.match(/\b([a-z][a-z0-9-]{1,20})[-_ ](\d+)(?:[.-](\d+))?(?:[.-](\d+))?\b/);
|
|
15006
|
-
if (generic) {
|
|
15007
|
-
return {
|
|
15008
|
-
family: generic[1] ?? "generic",
|
|
15009
|
-
version: toVersionTuple(generic[2] ?? "0", generic[3], generic[4]),
|
|
15010
|
-
confidence: 0.7,
|
|
15011
|
-
prereleasePenalty: /preview|experimental|exp|\brc\b/.test(text) ? -2 : 0
|
|
15012
|
-
};
|
|
15013
|
-
}
|
|
15014
|
-
return null;
|
|
15015
|
-
}
|
|
15016
|
-
function getVersionRecencyMap(models) {
|
|
15017
|
-
const familyVersions = new Map;
|
|
15018
|
-
const modelInfo = new Map;
|
|
15019
|
-
for (const model of models) {
|
|
15020
|
-
const info = extractVersionFamily(model);
|
|
15021
|
-
if (!info)
|
|
15022
|
-
continue;
|
|
15023
|
-
modelInfo.set(model.model, info);
|
|
15024
|
-
const current = familyVersions.get(info.family) ?? [];
|
|
15025
|
-
current.push(info.version);
|
|
15026
|
-
familyVersions.set(info.family, current);
|
|
15027
|
-
}
|
|
15028
|
-
const recencyMap = {};
|
|
15029
|
-
for (const model of models) {
|
|
15030
|
-
const info = modelInfo.get(model.model);
|
|
15031
|
-
if (!info) {
|
|
15032
|
-
recencyMap[model.model] = 0;
|
|
15033
|
-
continue;
|
|
15034
|
-
}
|
|
15035
|
-
const versions2 = familyVersions.get(info.family) ?? [];
|
|
15036
|
-
const unique = versions2.map((tuple2) => `${tuple2[0]}.${tuple2[1]}.${tuple2[2]}`).filter((value, index2, arr) => arr.indexOf(value) === index2).map((value) => {
|
|
15037
|
-
const [major, minor, patch] = value.split(".").map((v) => Number.parseInt(v, 10) || 0);
|
|
15038
|
-
return [major, minor, patch];
|
|
15039
|
-
}).sort(compareVersionTuple);
|
|
15040
|
-
if (unique.length === 0) {
|
|
15041
|
-
recencyMap[model.model] = 0;
|
|
15042
|
-
continue;
|
|
15043
|
-
}
|
|
15044
|
-
const index = unique.findIndex((tuple2) => compareVersionTuple(tuple2, info.version) === 0);
|
|
15045
|
-
const percentile = unique.length === 1 ? 0.5 : index / (unique.length - 1);
|
|
15046
|
-
const raw = -3 + percentile * (12 - -3);
|
|
15047
|
-
const final = Math.max(-3, Math.min(12, raw * info.confidence + info.prereleasePenalty));
|
|
15048
|
-
recencyMap[model.model] = final;
|
|
15049
|
-
}
|
|
15050
|
-
return recencyMap;
|
|
15051
|
-
}
|
|
15052
|
-
function baseScore(model, versionRecencyBoost = 0) {
|
|
15053
|
-
const lowered = `${model.model} ${model.name}`.toLowerCase();
|
|
15054
|
-
const context = Math.min(model.contextLimit, 1e6) / 50000;
|
|
15055
|
-
const output = Math.min(model.outputLimit, 300000) / 30000;
|
|
15056
|
-
const deep = tokenScore(lowered, /(opus|pro|thinking|reason|r1|gpt-5|k2\.5)/i, 12);
|
|
15057
|
-
const fast = tokenScore(lowered, /(nano|flash|mini|lite|fast|turbo|haiku|small)/i, 4);
|
|
15058
|
-
const code = tokenScore(lowered, /(codex|coder|code|dev|program)/i, 12);
|
|
15059
|
-
return statusScore(model.status) + context + output + deep + fast + code + versionRecencyBoost + (model.toolcall ? 25 : 0);
|
|
15060
|
-
}
|
|
15061
|
-
function hasFlashToken(model) {
|
|
15062
|
-
return /flash/i.test(`${model.model} ${model.name}`);
|
|
15063
|
-
}
|
|
15064
|
-
function isZai47Model(model) {
|
|
15065
|
-
return model.providerID === "zai-coding-plan" && /glm-4\.7/i.test(`${model.model} ${model.name}`);
|
|
15066
|
-
}
|
|
15067
|
-
function isKimiK25Model(model) {
|
|
15068
|
-
return /kimi-k2\.?5|k2\.?5/i.test(`${model.model} ${model.name}`);
|
|
15069
|
-
}
|
|
15070
|
-
function geminiPreferenceAdjustment(_agent, model) {
|
|
15071
|
-
const lowered = `${model.model} ${model.name}`.toLowerCase();
|
|
15072
|
-
const isGemini25Pro = /gemini-2\.5-pro/.test(lowered);
|
|
15073
|
-
return isGemini25Pro ? -14 : 0;
|
|
15074
|
-
}
|
|
15075
|
-
function chutesPreferenceAdjustment(agent, model) {
|
|
15076
|
-
if (model.providerID !== "chutes")
|
|
15077
|
-
return 0;
|
|
15078
|
-
const lowered = `${model.model} ${model.name}`.toLowerCase();
|
|
15079
|
-
const isQwen3 = /qwen3/.test(lowered);
|
|
15080
|
-
const isKimiK25 = /kimi-k2\.5|k2\.5/.test(lowered);
|
|
15081
|
-
const isMinimaxM21 = /minimax[-_ ]?m2\.1/.test(lowered);
|
|
15082
|
-
const qwenPenalty = {
|
|
15083
|
-
oracle: -12,
|
|
15084
|
-
orchestrator: -10,
|
|
15085
|
-
fixer: -22,
|
|
15086
|
-
designer: -14,
|
|
15087
|
-
librarian: -18,
|
|
15088
|
-
explorer: -10
|
|
15089
|
-
};
|
|
15090
|
-
const kimiBonus = {
|
|
15091
|
-
oracle: 0,
|
|
15092
|
-
orchestrator: 0,
|
|
15093
|
-
fixer: 8,
|
|
15094
|
-
designer: 6,
|
|
15095
|
-
librarian: 5,
|
|
15096
|
-
explorer: 4
|
|
15097
|
-
};
|
|
15098
|
-
const minimaxBonus = {
|
|
15099
|
-
oracle: 0,
|
|
15100
|
-
orchestrator: 0,
|
|
15101
|
-
fixer: 10,
|
|
15102
|
-
designer: 3,
|
|
15103
|
-
librarian: 9,
|
|
15104
|
-
explorer: 12
|
|
15105
|
-
};
|
|
15106
|
-
return (isQwen3 ? qwenPenalty[agent] : 0) + (isKimiK25 ? kimiBonus[agent] : 0) + (isMinimaxM21 ? minimaxBonus[agent] : 0);
|
|
15107
|
-
}
|
|
15108
|
-
function modelLookupKeys2(model) {
|
|
15109
|
-
return buildModelKeyAliases(model.model);
|
|
15110
|
-
}
|
|
15111
|
-
function roleScore(agent, model, versionRecencyBoost = 0) {
|
|
15112
|
-
const lowered = `${model.model} ${model.name}`.toLowerCase();
|
|
15113
|
-
const reasoning = model.reasoning ? 1 : 0;
|
|
15114
|
-
const toolcall = model.toolcall ? 1 : 0;
|
|
15115
|
-
const attachment = model.attachment ? 1 : 0;
|
|
15116
|
-
const context = Math.min(model.contextLimit, 1e6) / 60000;
|
|
15117
|
-
const output = Math.min(model.outputLimit, 300000) / 40000;
|
|
15118
|
-
const deep = tokenScore(lowered, /(opus|pro|thinking|reason|r1|gpt-5|k2\.5)/i, 1);
|
|
15119
|
-
const fast = tokenScore(lowered, /(nano|flash|mini|lite|fast|turbo|haiku|small)/i, 1);
|
|
15120
|
-
const code = tokenScore(lowered, /(codex|coder|code|dev|program)/i, 1);
|
|
15121
|
-
if ((agent === "orchestrator" || agent === "explorer" || agent === "librarian" || agent === "fixer") && !model.toolcall) {
|
|
15122
|
-
return -1e4;
|
|
15123
|
-
}
|
|
15124
|
-
if (model.status === "deprecated") {
|
|
15125
|
-
return -5000;
|
|
15126
|
-
}
|
|
15127
|
-
const score = baseScore(model, versionRecencyBoost);
|
|
15128
|
-
const flash = hasFlashToken(model);
|
|
15129
|
-
const isZai47 = isZai47Model(model);
|
|
15130
|
-
const zai47Flash = isZai47 && flash;
|
|
15131
|
-
const zai47NonFlash = isZai47 && !flash;
|
|
15132
|
-
const providerBias = model.providerID === "openai" ? 3 : model.providerID === "anthropic" ? 3 : model.providerID === "kimi-for-coding" ? 2 : model.providerID === "google" ? 2 : model.providerID === "github-copilot" ? 1 : model.providerID === "zai-coding-plan" ? 0 : model.providerID === "chutes" ? 2 : model.providerID === "opencode" ? -2 : 0;
|
|
15133
|
-
const geminiAdjustment = geminiPreferenceAdjustment(agent, model);
|
|
15134
|
-
const chutesAdjustment = chutesPreferenceAdjustment(agent, model);
|
|
15135
|
-
if (agent === "orchestrator") {
|
|
15136
|
-
const flashAdjustment2 = flash ? -22 : 0;
|
|
15137
|
-
const zaiAdjustment2 = zai47NonFlash ? 16 : zai47Flash ? -18 : 0;
|
|
15138
|
-
const nonReasoningFlashPenalty2 = flash && !model.reasoning ? -16 : 0;
|
|
15139
|
-
return score + reasoning * 40 + toolcall * 25 + deep * 10 + code * 8 + context + flashAdjustment2 + zaiAdjustment2 + nonReasoningFlashPenalty2 + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15140
|
-
}
|
|
15141
|
-
if (agent === "oracle") {
|
|
15142
|
-
const flashAdjustment2 = flash ? -34 : 0;
|
|
15143
|
-
const zaiAdjustment2 = zai47NonFlash ? 16 : zai47Flash ? -18 : 0;
|
|
15144
|
-
const nonReasoningFlashPenalty2 = flash && !model.reasoning ? -16 : 0;
|
|
15145
|
-
return score + reasoning * 55 + deep * 18 + context * 1.2 + toolcall * 10 + flashAdjustment2 + zaiAdjustment2 + nonReasoningFlashPenalty2 + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15146
|
-
}
|
|
15147
|
-
if (agent === "designer") {
|
|
15148
|
-
const flashAdjustment2 = flash ? -8 : 0;
|
|
15149
|
-
const zaiAdjustment2 = zai47NonFlash ? 10 : zai47Flash ? -8 : 0;
|
|
15150
|
-
return score + attachment * 25 + reasoning * 18 + toolcall * 15 + context * 0.8 + output + flashAdjustment2 + zaiAdjustment2 + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15151
|
-
}
|
|
15152
|
-
if (agent === "explorer") {
|
|
15153
|
-
const flashAdjustment2 = flash ? 26 : -10;
|
|
15154
|
-
const zaiAdjustment2 = zai47NonFlash ? 2 : zai47Flash ? 6 : 0;
|
|
15155
|
-
const deepPenalty = deep * -18;
|
|
15156
|
-
return score + fast * 68 + toolcall * 28 + reasoning * 2 + context * 0.2 + flashAdjustment2 + zaiAdjustment2 + deepPenalty + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15157
|
-
}
|
|
15158
|
-
if (agent === "librarian") {
|
|
15159
|
-
const flashAdjustment2 = flash ? -12 : 0;
|
|
15160
|
-
const zaiAdjustment2 = zai47NonFlash ? 16 : zai47Flash ? -18 : 0;
|
|
15161
|
-
return score + context * 30 + toolcall * 22 + reasoning * 15 + output * 10 + flashAdjustment2 + zaiAdjustment2 + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15162
|
-
}
|
|
15163
|
-
const flashAdjustment = flash ? -18 : 0;
|
|
15164
|
-
const zaiAdjustment = zai47NonFlash ? 16 : zai47Flash ? -18 : 0;
|
|
15165
|
-
const nonReasoningFlashPenalty = flash && !model.reasoning ? -16 : 0;
|
|
15166
|
-
return score + code * 28 + toolcall * 24 + fast * 18 + reasoning * 14 + output * 8 + flashAdjustment + zaiAdjustment + nonReasoningFlashPenalty + geminiAdjustment + chutesAdjustment + providerBias;
|
|
15167
|
-
}
|
|
15168
|
-
function getExternalSignalBoost(agent, model, externalSignals) {
|
|
15169
|
-
if (!externalSignals)
|
|
15170
|
-
return 0;
|
|
15171
|
-
const signal = modelLookupKeys2(model).map((key) => externalSignals[key]).find((item) => item !== undefined);
|
|
15172
|
-
if (!signal)
|
|
15173
|
-
return 0;
|
|
15174
|
-
const qualityScore = signal.qualityScore ?? 0;
|
|
15175
|
-
const codingScore = signal.codingScore ?? 0;
|
|
15176
|
-
const latencySeconds = signal.latencySeconds;
|
|
15177
|
-
const blendedPrice2 = signal.inputPricePer1M !== undefined && signal.outputPricePer1M !== undefined ? signal.inputPricePer1M * 0.75 + signal.outputPricePer1M * 0.25 : signal.inputPricePer1M ?? signal.outputPricePer1M ?? 0;
|
|
15178
|
-
if (agent === "explorer") {
|
|
15179
|
-
const qualityBoost2 = qualityScore * 0.05;
|
|
15180
|
-
const codingBoost2 = codingScore * 0.08;
|
|
15181
|
-
const latencyPenalty2 = typeof latencySeconds === "number" && Number.isFinite(latencySeconds) ? Math.min(latencySeconds, 12) * 3.2 + (latencySeconds > 7 ? 16 : latencySeconds > 4 ? 10 : 0) : 0;
|
|
15182
|
-
const pricePenalty2 = Math.min(blendedPrice2, 30) * 0.03;
|
|
15183
|
-
const qualityFloorPenalty = qualityScore > 0 && qualityScore < 35 ? (35 - qualityScore) * 0.8 : 0;
|
|
15184
|
-
const boost2 = qualityBoost2 + codingBoost2 - latencyPenalty2 - pricePenalty2 - qualityFloorPenalty;
|
|
15185
|
-
return Math.max(-90, Math.min(25, boost2));
|
|
15186
|
-
}
|
|
15187
|
-
const qualityBoost = qualityScore * 0.16;
|
|
15188
|
-
const codingBoost = codingScore * 0.24;
|
|
15189
|
-
const latencyPenalty = typeof latencySeconds === "number" && Number.isFinite(latencySeconds) ? Math.min(latencySeconds, 25) * 0.22 : 0;
|
|
15190
|
-
const pricePenalty = Math.min(blendedPrice2, 30) * 0.08;
|
|
15191
|
-
const boost = qualityBoost + codingBoost - latencyPenalty - pricePenalty;
|
|
15192
|
-
return Math.max(-30, Math.min(45, boost));
|
|
15193
|
-
}
|
|
15194
|
-
function rankModels2(models, agent, externalSignals) {
|
|
15195
|
-
const versionRecencyMap = getVersionRecencyMap(models);
|
|
15196
|
-
return [...models].sort((a, b) => {
|
|
15197
|
-
const scoreA = roleScore(agent, a, versionRecencyMap[a.model] ?? 0) + getExternalSignalBoost(agent, a, externalSignals);
|
|
15198
|
-
const scoreB = roleScore(agent, b, versionRecencyMap[b.model] ?? 0) + getExternalSignalBoost(agent, b, externalSignals);
|
|
15199
|
-
const scoreDelta = scoreB - scoreA;
|
|
15200
|
-
if (scoreDelta !== 0)
|
|
15201
|
-
return scoreDelta;
|
|
15202
|
-
const providerTieBreak = a.providerID.localeCompare(b.providerID);
|
|
15203
|
-
if (providerTieBreak !== 0)
|
|
15204
|
-
return providerTieBreak;
|
|
15205
|
-
return a.model.localeCompare(b.model);
|
|
15206
|
-
});
|
|
15207
|
-
}
|
|
15208
|
-
function combinedScore(agent, model, externalSignals, versionRecencyMap) {
|
|
15209
|
-
return roleScore(agent, model, versionRecencyMap?.[model.model] ?? 0) + getExternalSignalBoost(agent, model, externalSignals);
|
|
15210
|
-
}
|
|
15211
|
-
function effectiveEngine(engineVersion) {
|
|
15212
|
-
return engineVersion === "v2" ? "v2" : "v1";
|
|
15213
|
-
}
|
|
15214
|
-
function scoreForEngine(engineVersion, agent, model, externalSignals, versionRecencyMap) {
|
|
15215
|
-
if (effectiveEngine(engineVersion) === "v2") {
|
|
15216
|
-
return scoreCandidateV2(model, agent, externalSignals).totalScore;
|
|
15217
|
-
}
|
|
15218
|
-
return combinedScore(agent, model, externalSignals, versionRecencyMap);
|
|
15219
|
-
}
|
|
15220
|
-
function selectTopModelsPerProvider(models, engineVersion, externalSignals, versionRecencyMap) {
|
|
15221
|
-
const byProvider = new Map;
|
|
15222
|
-
for (const model of models) {
|
|
15223
|
-
const current = byProvider.get(model.providerID) ?? [];
|
|
15224
|
-
current.push(model);
|
|
15225
|
-
byProvider.set(model.providerID, current);
|
|
15226
|
-
}
|
|
15227
|
-
const selected = [];
|
|
15228
|
-
for (const providerModels of byProvider.values()) {
|
|
15229
|
-
if (providerModels.length <= 2) {
|
|
15230
|
-
selected.push(...providerModels);
|
|
15231
|
-
continue;
|
|
15232
|
-
}
|
|
15233
|
-
const ranked = [...providerModels].map((model) => {
|
|
15234
|
-
const total = AGENTS.reduce((sum, agent) => {
|
|
15235
|
-
return sum + scoreForEngine(engineVersion, agent, model, externalSignals, versionRecencyMap);
|
|
15236
|
-
}, 0);
|
|
15237
|
-
return {
|
|
15238
|
-
model,
|
|
15239
|
-
score: total / AGENTS.length
|
|
15240
|
-
};
|
|
15241
|
-
}).sort((a, b) => {
|
|
15242
|
-
if (a.score !== b.score)
|
|
15243
|
-
return b.score - a.score;
|
|
15244
|
-
return a.model.model.localeCompare(b.model.model);
|
|
15245
|
-
}).slice(0, 2).map((entry) => entry.model);
|
|
15246
|
-
selected.push(...ranked);
|
|
15247
|
-
}
|
|
15248
|
-
return selected;
|
|
15249
|
-
}
|
|
15250
|
-
function countProviderUsage(agents) {
|
|
15251
|
-
const counts = new Map;
|
|
15252
|
-
for (const assignment of Object.values(agents)) {
|
|
15253
|
-
const provider = assignment.model.split("/")[0];
|
|
15254
|
-
if (!provider)
|
|
15255
|
-
continue;
|
|
15256
|
-
counts.set(provider, (counts.get(provider) ?? 0) + 1);
|
|
15257
|
-
}
|
|
15258
|
-
return counts;
|
|
15259
|
-
}
|
|
15260
|
-
function rebalanceForSubscriptionMode(agents, chains, provenance, paidProviders, getRankedModels, getPinnedModelForProvider, targetByProvider, externalSignals, versionRecencyMap, engineVersion) {
|
|
15261
|
-
if (paidProviders.length <= 1)
|
|
15262
|
-
return;
|
|
15263
|
-
const MAX_ALLOWED_SCORE_LOSS = 20;
|
|
15264
|
-
while (true) {
|
|
15265
|
-
const providerUsage = countProviderUsage(agents);
|
|
15266
|
-
const underProviders = paidProviders.filter((providerID) => (providerUsage.get(providerID) ?? 0) < (targetByProvider[providerID] ?? 0));
|
|
15267
|
-
const overProviders = paidProviders.filter((providerID) => (providerUsage.get(providerID) ?? 0) > (targetByProvider[providerID] ?? 0));
|
|
15268
|
-
if (underProviders.length === 0 || overProviders.length === 0)
|
|
15269
|
-
break;
|
|
15270
|
-
let bestSwap;
|
|
15271
|
-
for (const agent of PRIMARY_ASSIGNMENT_ORDER) {
|
|
15272
|
-
const currentModelID = agents[agent]?.model;
|
|
15273
|
-
if (!currentModelID)
|
|
15274
|
-
continue;
|
|
15275
|
-
const currentProvider = currentModelID.split("/")[0];
|
|
15276
|
-
if (!currentProvider || !overProviders.includes(currentProvider))
|
|
15277
|
-
continue;
|
|
15278
|
-
const ranked = getRankedModels(agent);
|
|
15279
|
-
const currentModel = ranked.find((model) => model.model === currentModelID) ?? ranked.find((model) => model.providerID === currentProvider);
|
|
15280
|
-
if (!currentModel)
|
|
15281
|
-
continue;
|
|
15282
|
-
const currentScore = scoreForEngine(engineVersion, agent, currentModel, externalSignals, versionRecencyMap);
|
|
15283
|
-
for (const underProvider of underProviders) {
|
|
15284
|
-
const pinned = getPinnedModelForProvider(agent, underProvider);
|
|
15285
|
-
const candidate = ranked.find((model) => model.model === pinned) ?? ranked.find((model) => model.providerID === underProvider);
|
|
15286
|
-
if (!candidate)
|
|
15287
|
-
continue;
|
|
15288
|
-
const candidateScore = scoreForEngine(engineVersion, agent, candidate, externalSignals, versionRecencyMap);
|
|
15289
|
-
const loss = currentScore - candidateScore;
|
|
15290
|
-
if (loss > MAX_ALLOWED_SCORE_LOSS)
|
|
15291
|
-
continue;
|
|
15292
|
-
if (!bestSwap || loss < bestSwap.loss) {
|
|
15293
|
-
bestSwap = { agent, candidate, loss };
|
|
15294
|
-
}
|
|
15295
|
-
}
|
|
15296
|
-
}
|
|
15297
|
-
if (!bestSwap)
|
|
15298
|
-
break;
|
|
15299
|
-
agents[bestSwap.agent].model = bestSwap.candidate.model;
|
|
15300
|
-
chains[bestSwap.agent] = dedupe2([
|
|
15301
|
-
bestSwap.candidate.model,
|
|
15302
|
-
...chains[bestSwap.agent] ?? []
|
|
15303
|
-
]).slice(0, 10);
|
|
15304
|
-
provenance[bestSwap.agent] = {
|
|
15305
|
-
winnerLayer: "provider-fallback-policy",
|
|
15306
|
-
winnerModel: bestSwap.candidate.model
|
|
15307
|
-
};
|
|
15308
|
-
}
|
|
15309
|
-
}
|
|
15310
|
-
function chooseProviderRepresentative(providerModels, agent, externalSignals, versionRecencyMap) {
|
|
15311
|
-
if (providerModels.length === 0)
|
|
15312
|
-
return null;
|
|
15313
|
-
const flashBest = providerModels.find((model) => hasFlashToken(model));
|
|
15314
|
-
const nonFlashBest = providerModels.find((model) => !hasFlashToken(model));
|
|
15315
|
-
if (!nonFlashBest)
|
|
15316
|
-
return providerModels[0] ?? null;
|
|
15317
|
-
if (!flashBest)
|
|
15318
|
-
return nonFlashBest;
|
|
15319
|
-
const flashScore = combinedScore(agent, flashBest, externalSignals, versionRecencyMap);
|
|
15320
|
-
const nonFlashScore = combinedScore(agent, nonFlashBest, externalSignals, versionRecencyMap);
|
|
15321
|
-
const threshold = agent === "explorer" ? -6 : 12;
|
|
15322
|
-
return flashScore >= nonFlashScore + threshold ? flashBest : nonFlashBest;
|
|
15323
|
-
}
|
|
15324
|
-
function getQualityWindow(agent) {
|
|
15325
|
-
if (agent === "oracle" || agent === "orchestrator")
|
|
15326
|
-
return 12;
|
|
15327
|
-
if (agent === "fixer")
|
|
15328
|
-
return 15;
|
|
15329
|
-
if (agent === "designer")
|
|
15330
|
-
return 16;
|
|
15331
|
-
if (agent === "librarian")
|
|
15332
|
-
return 18;
|
|
15333
|
-
return 22;
|
|
15334
|
-
}
|
|
15335
|
-
function getProviderBundle(providerModels, agent, externalSignals, versionRecencyMap) {
|
|
15336
|
-
if (providerModels.length === 0)
|
|
15337
|
-
return [];
|
|
15338
|
-
const representative = chooseProviderRepresentative(providerModels, agent, externalSignals, versionRecencyMap);
|
|
15339
|
-
if (!representative)
|
|
15340
|
-
return [];
|
|
15341
|
-
const second = providerModels.find((m) => m.model !== representative.model);
|
|
15342
|
-
if (!second)
|
|
15343
|
-
return [representative.model];
|
|
15344
|
-
const score1 = combinedScore(agent, representative, externalSignals, versionRecencyMap);
|
|
15345
|
-
const score2 = combinedScore(agent, second, externalSignals, versionRecencyMap);
|
|
15346
|
-
const gap = Math.abs(score1 - score2);
|
|
15347
|
-
const includeSecond = representative.providerID === "chutes" || gap <= (agent === "oracle" || agent === "orchestrator" ? 8 : agent === "designer" || agent === "librarian" ? 12 : agent === "fixer" ? 15 : 18);
|
|
15348
|
-
return includeSecond ? [representative.model, second.model] : [representative.model];
|
|
15349
|
-
}
|
|
15350
|
-
function selectPrimaryWithDiversity(candidates, agent, providerUsage, targetByProvider, remainingSlots, externalSignals, versionRecencyMap) {
|
|
15351
|
-
if (candidates.length === 0)
|
|
15352
|
-
return null;
|
|
15353
|
-
const candidateScores = candidates.map((model) => {
|
|
15354
|
-
const usage = providerUsage.get(model.providerID) ?? 0;
|
|
15355
|
-
const target = targetByProvider[model.providerID] ?? 1;
|
|
15356
|
-
const softCap = target;
|
|
15357
|
-
const hardCap = Math.min(target + 1, 4);
|
|
15358
|
-
const deficit = Math.max(0, target - usage);
|
|
15359
|
-
const softOverflow = Math.max(0, usage + 1 - softCap);
|
|
15360
|
-
const hardOverflow = Math.max(0, usage + 1 - hardCap);
|
|
15361
|
-
const rawScore = combinedScore(agent, model, externalSignals, versionRecencyMap);
|
|
15362
|
-
const adjustedScore = rawScore + deficit * 14 - softOverflow * 18 - hardOverflow * 100;
|
|
15363
|
-
return {
|
|
15364
|
-
model,
|
|
15365
|
-
usage,
|
|
15366
|
-
target,
|
|
15367
|
-
rawScore,
|
|
15368
|
-
adjustedScore: Math.round(adjustedScore * 1000) / 1000
|
|
15369
|
-
};
|
|
15370
|
-
});
|
|
15371
|
-
const bestRaw = Math.max(...candidateScores.map((item) => item.rawScore));
|
|
15372
|
-
const window = getQualityWindow(agent);
|
|
15373
|
-
let eligible = candidateScores.filter((item) => item.rawScore >= bestRaw - window);
|
|
15374
|
-
const mustFillProviders = Object.entries(targetByProvider).filter(([providerID, target]) => {
|
|
15375
|
-
const usage = providerUsage.get(providerID) ?? 0;
|
|
15376
|
-
return Math.max(0, target - usage) >= remainingSlots;
|
|
15377
|
-
}).map(([providerID]) => providerID);
|
|
15378
|
-
if (mustFillProviders.length > 0) {
|
|
15379
|
-
const forced = eligible.filter((item) => mustFillProviders.includes(item.model.providerID));
|
|
15380
|
-
if (forced.length > 0)
|
|
15381
|
-
eligible = forced;
|
|
15382
|
-
}
|
|
15383
|
-
eligible.sort((a, b) => {
|
|
15384
|
-
const delta = b.adjustedScore - a.adjustedScore;
|
|
15385
|
-
if (delta !== 0)
|
|
15386
|
-
return delta;
|
|
15387
|
-
const ratioA = a.target > 0 ? a.usage / a.target : a.usage;
|
|
15388
|
-
const ratioB = b.target > 0 ? b.usage / b.target : b.usage;
|
|
15389
|
-
if (ratioA !== ratioB)
|
|
15390
|
-
return ratioA - ratioB;
|
|
15391
|
-
if (a.rawScore !== b.rawScore)
|
|
15392
|
-
return b.rawScore - a.rawScore;
|
|
15393
|
-
const providerTie = a.model.providerID.localeCompare(b.model.providerID);
|
|
15394
|
-
if (providerTie !== 0)
|
|
15395
|
-
return providerTie;
|
|
15396
|
-
return a.model.model.localeCompare(b.model.model);
|
|
15397
|
-
});
|
|
15398
|
-
let chosen = eligible[0] ?? candidateScores[0];
|
|
15399
|
-
if (!chosen)
|
|
15400
|
-
return null;
|
|
15401
|
-
if (chosen.usage >= 2) {
|
|
15402
|
-
const bestUnused = candidateScores.find((item) => item.usage === 0);
|
|
15403
|
-
if (bestUnused && bestUnused.adjustedScore >= chosen.adjustedScore - 9) {
|
|
15404
|
-
chosen = bestUnused;
|
|
15405
|
-
}
|
|
15406
|
-
}
|
|
15407
|
-
if (agent !== "explorer" && isZai47Model(chosen.model) && hasFlashToken(chosen.model)) {
|
|
15408
|
-
const kimiCandidate = candidateScores.find((item) => isKimiK25Model(item.model));
|
|
15409
|
-
if (kimiCandidate && kimiCandidate.rawScore >= chosen.rawScore - 2) {
|
|
15410
|
-
chosen = kimiCandidate;
|
|
15411
|
-
}
|
|
15412
|
-
}
|
|
15413
|
-
return chosen.model;
|
|
15414
|
-
}
|
|
15415
|
-
function dedupe2(models) {
|
|
15416
|
-
const seen = new Set;
|
|
15417
|
-
const result = [];
|
|
15418
|
-
for (const model of models) {
|
|
15419
|
-
if (!model || seen.has(model))
|
|
15420
|
-
continue;
|
|
15421
|
-
seen.add(model);
|
|
15422
|
-
result.push(model);
|
|
15423
|
-
}
|
|
15424
|
-
return result;
|
|
15425
|
-
}
|
|
15426
|
-
function finalizeChainWithTail(prefix, preferredTail) {
|
|
15427
|
-
if (!preferredTail) {
|
|
15428
|
-
return dedupe2([...prefix, "opencode/big-pickle"]).slice(0, 10);
|
|
15429
|
-
}
|
|
15430
|
-
const withoutTail = prefix.filter((model) => model !== preferredTail).slice(0, 9);
|
|
15431
|
-
return [...withoutTail, preferredTail];
|
|
15432
|
-
}
|
|
15433
|
-
function ensureSyntheticModel(models, fullModelID) {
|
|
15434
|
-
if (!fullModelID)
|
|
15435
|
-
return models;
|
|
15436
|
-
if (models.some((model) => model.model === fullModelID))
|
|
15437
|
-
return models;
|
|
15438
|
-
const [providerID, modelID] = fullModelID.split("/");
|
|
15439
|
-
if (!providerID || !modelID)
|
|
15440
|
-
return models;
|
|
15441
|
-
return [
|
|
15442
|
-
...models,
|
|
15443
|
-
{
|
|
15444
|
-
providerID,
|
|
15445
|
-
model: fullModelID,
|
|
15446
|
-
name: modelID,
|
|
15447
|
-
status: "active",
|
|
15448
|
-
contextLimit: 200000,
|
|
15449
|
-
outputLimit: 32000,
|
|
15450
|
-
reasoning: true,
|
|
15451
|
-
toolcall: true,
|
|
15452
|
-
attachment: false
|
|
15453
|
-
}
|
|
15454
|
-
];
|
|
15455
|
-
}
|
|
15456
|
-
function buildDynamicModelPlan(catalog, config2, externalSignals, options) {
|
|
15457
|
-
const catalogWithSelectedModels = [
|
|
15458
|
-
config2.selectedChutesPrimaryModel,
|
|
15459
|
-
config2.selectedChutesSecondaryModel,
|
|
15460
|
-
config2.selectedOpenCodePrimaryModel,
|
|
15461
|
-
config2.selectedOpenCodeSecondaryModel
|
|
15462
|
-
].reduce((acc, modelID) => ensureSyntheticModel(acc, modelID), catalog);
|
|
15463
|
-
const enabledProviders = new Set(getEnabledProviders(config2));
|
|
15464
|
-
const providerUniverse = catalogWithSelectedModels.filter((m) => {
|
|
15465
|
-
if (!enabledProviders.has(m.providerID))
|
|
15466
|
-
return false;
|
|
15467
|
-
if (m.providerID === "chutes" && /qwen/i.test(m.model)) {
|
|
15468
|
-
return false;
|
|
15469
|
-
}
|
|
15470
|
-
return true;
|
|
15471
|
-
});
|
|
15472
|
-
const engineVersion = options?.scoringEngineVersion ?? config2.scoringEngineVersion ?? "v1";
|
|
15473
|
-
const versionRecencyMap = getVersionRecencyMap(providerUniverse);
|
|
15474
|
-
const providerCandidates = selectTopModelsPerProvider(providerUniverse, engineVersion, externalSignals, versionRecencyMap);
|
|
15475
|
-
if (providerCandidates.length === 0) {
|
|
15476
|
-
return null;
|
|
15477
|
-
}
|
|
15478
|
-
const hasPaidProviderEnabled = config2.hasOpenAI || config2.hasAnthropic || config2.hasCopilot || config2.hasZaiPlan || config2.hasKimi || config2.hasAntigravity;
|
|
15479
|
-
const paidProviders = dedupe2(providerCandidates.map((model) => model.providerID).filter((providerID) => providerID !== "opencode")).sort((a, b) => a.localeCompare(b));
|
|
15480
|
-
const targetByProvider = {};
|
|
15481
|
-
if (paidProviders.length > 0) {
|
|
15482
|
-
const baseTarget = Math.floor(AGENTS.length / paidProviders.length);
|
|
15483
|
-
const extra = AGENTS.length % paidProviders.length;
|
|
15484
|
-
for (const [index, providerID] of paidProviders.entries()) {
|
|
15485
|
-
targetByProvider[providerID] = baseTarget + (index < extra ? 1 : 0);
|
|
15486
|
-
}
|
|
15487
|
-
}
|
|
15488
|
-
const providerUsage = new Map;
|
|
15489
|
-
const rankCache = new Map;
|
|
15490
|
-
const shadowDiffs = {};
|
|
15491
|
-
const agents = {};
|
|
15492
|
-
const chains = {};
|
|
15493
|
-
const provenance = {};
|
|
15494
|
-
const getSelectedChutesForAgent = (agent) => {
|
|
15495
|
-
if (!config2.hasChutes)
|
|
15496
|
-
return;
|
|
15497
|
-
return agent === "explorer" || agent === "librarian" || agent === "fixer" ? config2.selectedChutesSecondaryModel ?? config2.selectedChutesPrimaryModel : config2.selectedChutesPrimaryModel;
|
|
15498
|
-
};
|
|
15499
|
-
const getSelectedOpenCodeForAgent = (agent) => {
|
|
15500
|
-
if (!config2.useOpenCodeFreeModels)
|
|
15501
|
-
return;
|
|
15502
|
-
return agent === "explorer" || agent === "librarian" || agent === "fixer" ? config2.selectedOpenCodeSecondaryModel ?? config2.selectedOpenCodePrimaryModel : config2.selectedOpenCodePrimaryModel;
|
|
15503
|
-
};
|
|
15504
|
-
const getPinnedModelForProvider = (agent, providerID) => {
|
|
15505
|
-
if (providerID === "chutes")
|
|
15506
|
-
return getSelectedChutesForAgent(agent);
|
|
15507
|
-
if (providerID === "opencode")
|
|
15508
|
-
return getSelectedOpenCodeForAgent(agent);
|
|
15509
|
-
return;
|
|
15510
|
-
};
|
|
15511
|
-
const getRankedModels = (agent) => {
|
|
15512
|
-
const cached2 = rankCache.get(agent);
|
|
15513
|
-
if (cached2)
|
|
15514
|
-
return cached2;
|
|
15515
|
-
const rankedV1 = rankModels2(providerCandidates, agent, externalSignals);
|
|
15516
|
-
if (engineVersion === "v1") {
|
|
15517
|
-
rankCache.set(agent, rankedV1);
|
|
15518
|
-
return rankedV1;
|
|
15519
|
-
}
|
|
15520
|
-
const rankedV2 = rankModelsV2(providerCandidates, agent, externalSignals).map((candidate) => candidate.model);
|
|
15521
|
-
if (engineVersion === "v2-shadow") {
|
|
15522
|
-
shadowDiffs[agent] = {
|
|
15523
|
-
v1TopModel: rankedV1[0]?.model,
|
|
15524
|
-
v2TopModel: rankedV2[0]?.model
|
|
15525
|
-
};
|
|
15526
|
-
rankCache.set(agent, rankedV1);
|
|
15527
|
-
return rankedV1;
|
|
15528
|
-
}
|
|
15529
|
-
rankCache.set(agent, rankedV2);
|
|
15530
|
-
return rankedV2;
|
|
15531
|
-
};
|
|
15532
|
-
for (const [agentIndex, agent] of PRIMARY_ASSIGNMENT_ORDER.entries()) {
|
|
15533
|
-
const ranked = getRankedModels(agent);
|
|
15534
|
-
const primaryPool = hasPaidProviderEnabled ? ranked.filter((model) => !FREE_BIASED_PROVIDERS.has(model.providerID)) : ranked;
|
|
15535
|
-
const remainingSlots = PRIMARY_ASSIGNMENT_ORDER.length - agentIndex;
|
|
15536
|
-
const primary = selectPrimaryWithDiversity(primaryPool.length > 0 ? primaryPool : ranked, agent, providerUsage, targetByProvider, remainingSlots, externalSignals, versionRecencyMap) ?? ranked[0];
|
|
15537
|
-
if (!primary)
|
|
15538
|
-
continue;
|
|
15539
|
-
providerUsage.set(primary.providerID, (providerUsage.get(primary.providerID) ?? 0) + 1);
|
|
15540
|
-
const providerOrder = dedupe2(ranked.map((m) => m.providerID));
|
|
15541
|
-
const perProviderBest = providerOrder.flatMap((providerID) => {
|
|
15542
|
-
const providerModels = ranked.filter((m) => m.providerID === providerID);
|
|
15543
|
-
const pinned = getPinnedModelForProvider(agent, providerID);
|
|
15544
|
-
if (pinned && providerModels.some((m) => m.model === pinned)) {
|
|
15545
|
-
return [pinned];
|
|
15546
|
-
}
|
|
15547
|
-
return getProviderBundle(providerModels, agent, externalSignals, versionRecencyMap);
|
|
15548
|
-
});
|
|
15549
|
-
const nonFreePerProviderBest = perProviderBest.filter((model) => !model.startsWith("opencode/"));
|
|
15550
|
-
const freePerProviderBest = perProviderBest.filter((model) => model.startsWith("opencode/"));
|
|
15551
|
-
const selectedOpencode = getSelectedOpenCodeForAgent(agent);
|
|
15552
|
-
const selectedChutes = getSelectedChutesForAgent(agent);
|
|
15553
|
-
const chain = dedupe2([
|
|
15554
|
-
primary.model,
|
|
15555
|
-
...nonFreePerProviderBest,
|
|
15556
|
-
selectedChutes,
|
|
15557
|
-
selectedOpencode,
|
|
15558
|
-
...freePerProviderBest
|
|
15559
|
-
]);
|
|
15560
|
-
const deterministicFreeTail = selectedOpencode ?? freePerProviderBest[0] ?? ranked.find((model) => model.model.startsWith("opencode/"))?.model;
|
|
15561
|
-
const finalizedChain = finalizeChainWithTail(chain, deterministicFreeTail);
|
|
15562
|
-
const providerPolicyChain = dedupe2([selectedChutes, selectedOpencode]);
|
|
15563
|
-
const systemDefaultModel = selectedOpencode ?? "opencode/big-pickle";
|
|
15564
|
-
const resolved = resolveAgentWithPrecedence({
|
|
15565
|
-
agentName: agent,
|
|
15566
|
-
dynamicRecommendation: finalizedChain,
|
|
15567
|
-
providerFallbackPolicy: providerPolicyChain,
|
|
15568
|
-
systemDefault: [systemDefaultModel]
|
|
15569
|
-
});
|
|
15570
|
-
let finalModel = resolved.model;
|
|
15571
|
-
let finalChain = resolved.chain;
|
|
15572
|
-
const selectedChutesForAgent = getSelectedChutesForAgent(agent);
|
|
15573
|
-
const selectedOpenCodeForAgent = getSelectedOpenCodeForAgent(agent);
|
|
15574
|
-
const forceChutes = finalModel.startsWith("chutes/") && Boolean(selectedChutesForAgent);
|
|
15575
|
-
const forceOpenCode = finalModel.startsWith("opencode/") && Boolean(selectedOpenCodeForAgent);
|
|
15576
|
-
if (forceOpenCode && selectedOpenCodeForAgent) {
|
|
15577
|
-
finalModel = selectedOpenCodeForAgent;
|
|
15578
|
-
finalChain = dedupe2([selectedOpenCodeForAgent, ...finalChain]);
|
|
15579
|
-
}
|
|
15580
|
-
if (forceChutes && selectedChutesForAgent) {
|
|
15581
|
-
finalModel = selectedChutesForAgent;
|
|
15582
|
-
finalChain = dedupe2([selectedChutesForAgent, ...finalChain]);
|
|
15583
|
-
}
|
|
15584
|
-
const wasForced = forceChutes || forceOpenCode;
|
|
15585
|
-
agents[agent] = {
|
|
15586
|
-
model: finalModel,
|
|
15587
|
-
variant: ROLE_VARIANT[agent]
|
|
15588
|
-
};
|
|
15589
|
-
chains[agent] = finalChain;
|
|
15590
|
-
provenance[agent] = {
|
|
15591
|
-
winnerLayer: wasForced ? "manual-user-plan" : resolved.provenance.winnerLayer,
|
|
15592
|
-
winnerModel: finalModel
|
|
15593
|
-
};
|
|
15594
|
-
}
|
|
15595
|
-
if (hasPaidProviderEnabled) {
|
|
15596
|
-
for (const providerID of paidProviders) {
|
|
15597
|
-
if ((providerUsage.get(providerID) ?? 0) > 0)
|
|
15598
|
-
continue;
|
|
15599
|
-
let bestSwap;
|
|
15600
|
-
for (const agent of PRIMARY_ASSIGNMENT_ORDER) {
|
|
15601
|
-
const currentModel = agents[agent]?.model;
|
|
15602
|
-
if (!currentModel)
|
|
15603
|
-
continue;
|
|
15604
|
-
const ranked = getRankedModels(agent);
|
|
15605
|
-
const pinned = getPinnedModelForProvider(agent, providerID);
|
|
15606
|
-
const candidate = ranked.find((model) => model.model === pinned) ?? ranked.find((model) => model.providerID === providerID);
|
|
15607
|
-
const current = ranked.find((model) => model.model === currentModel);
|
|
15608
|
-
if (!candidate || !current)
|
|
15609
|
-
continue;
|
|
15610
|
-
const currentScore = combinedScore(agent, current, externalSignals, versionRecencyMap);
|
|
15611
|
-
const candidateScore = combinedScore(agent, candidate, externalSignals, versionRecencyMap);
|
|
15612
|
-
const loss = currentScore - candidateScore;
|
|
15613
|
-
if (!bestSwap || loss < bestSwap.loss) {
|
|
15614
|
-
bestSwap = {
|
|
15615
|
-
agent,
|
|
15616
|
-
candidateModel: candidate.model,
|
|
15617
|
-
loss
|
|
15618
|
-
};
|
|
15619
|
-
}
|
|
15620
|
-
}
|
|
15621
|
-
if (!bestSwap)
|
|
15622
|
-
continue;
|
|
15623
|
-
const existingProvider = agents[bestSwap.agent]?.model.split("/")[0] ?? providerID;
|
|
15624
|
-
agents[bestSwap.agent].model = bestSwap.candidateModel;
|
|
15625
|
-
chains[bestSwap.agent] = dedupe2([
|
|
15626
|
-
bestSwap.candidateModel,
|
|
15627
|
-
...chains[bestSwap.agent] ?? []
|
|
15628
|
-
]).slice(0, 10);
|
|
15629
|
-
provenance[bestSwap.agent] = {
|
|
15630
|
-
winnerLayer: "provider-fallback-policy",
|
|
15631
|
-
winnerModel: bestSwap.candidateModel
|
|
15632
|
-
};
|
|
15633
|
-
providerUsage.set(providerID, (providerUsage.get(providerID) ?? 0) + 1);
|
|
15634
|
-
providerUsage.set(existingProvider, Math.max(0, (providerUsage.get(existingProvider) ?? 1) - 1));
|
|
15635
|
-
}
|
|
15636
|
-
}
|
|
15637
|
-
if (config2.balanceProviderUsage && hasPaidProviderEnabled) {
|
|
15638
|
-
rebalanceForSubscriptionMode(agents, chains, provenance, paidProviders, getRankedModels, getPinnedModelForProvider, targetByProvider, externalSignals, versionRecencyMap, engineVersion);
|
|
15639
|
-
}
|
|
15640
|
-
if (Object.keys(agents).length === 0) {
|
|
15641
|
-
return null;
|
|
15642
|
-
}
|
|
15643
|
-
return {
|
|
15644
|
-
agents,
|
|
15645
|
-
chains,
|
|
15646
|
-
provenance,
|
|
15647
|
-
scoring: {
|
|
15648
|
-
engineVersionApplied: engineVersion === "v2" ? "v2" : "v1",
|
|
15649
|
-
shadowCompared: engineVersion === "v2-shadow",
|
|
15650
|
-
diffs: engineVersion === "v2-shadow" ? shadowDiffs : undefined
|
|
15651
|
-
}
|
|
15652
|
-
};
|
|
15653
|
-
}
|
|
15654
|
-
// src/utils/logger.ts
|
|
15655
|
-
import * as os from "os";
|
|
15656
|
-
import * as path from "path";
|
|
15657
|
-
var logFile = path.join(os.tmpdir(), "oh-my-opencode-medium.log");
|
|
15658
|
-
// src/utils/env.ts
|
|
15659
|
-
function getEnv(name) {
|
|
15660
|
-
const bunValue = globalThis.Bun?.env?.[name];
|
|
15661
|
-
if (typeof bunValue === "string" && bunValue.length > 0)
|
|
15662
|
-
return bunValue;
|
|
15663
|
-
const processValue = globalThis.process?.env?.[name];
|
|
15664
|
-
return typeof processValue === "string" && processValue.length > 0 ? processValue : undefined;
|
|
15665
|
-
}
|
|
15666
|
-
// src/cli/external-rankings.ts
|
|
15667
|
-
function normalizeKey(input) {
|
|
15668
|
-
return input.trim().toLowerCase();
|
|
15669
|
-
}
|
|
15670
|
-
function baseAliases(key) {
|
|
15671
|
-
return buildModelKeyAliases(normalizeKey(key));
|
|
15672
|
-
}
|
|
15673
|
-
function providerScopedAlias(alias, providerPrefix) {
|
|
15674
|
-
if (!providerPrefix || alias.includes("/"))
|
|
15675
|
-
return alias;
|
|
15676
|
-
return `${providerPrefix}/${alias}`;
|
|
15677
|
-
}
|
|
15678
|
-
function mergeSignal(existing, incoming) {
|
|
15679
|
-
if (!existing)
|
|
15680
|
-
return incoming;
|
|
15681
|
-
return {
|
|
15682
|
-
qualityScore: incoming.qualityScore ?? existing.qualityScore,
|
|
15683
|
-
codingScore: incoming.codingScore ?? existing.codingScore,
|
|
15684
|
-
latencySeconds: incoming.latencySeconds ?? existing.latencySeconds,
|
|
15685
|
-
inputPricePer1M: incoming.inputPricePer1M ?? existing.inputPricePer1M,
|
|
15686
|
-
outputPricePer1M: incoming.outputPricePer1M ?? existing.outputPricePer1M,
|
|
15687
|
-
source: "merged"
|
|
15688
|
-
};
|
|
15689
|
-
}
|
|
15690
|
-
function providerPrefixFromCreator(creatorSlug) {
|
|
15691
|
-
if (!creatorSlug)
|
|
15692
|
-
return;
|
|
15693
|
-
const slug = creatorSlug.toLowerCase();
|
|
15694
|
-
if (slug.includes("openai"))
|
|
15695
|
-
return "openai";
|
|
15696
|
-
if (slug.includes("anthropic"))
|
|
15697
|
-
return "anthropic";
|
|
15698
|
-
if (slug.includes("google"))
|
|
15699
|
-
return "google";
|
|
15700
|
-
if (slug.includes("chutes"))
|
|
15701
|
-
return "chutes";
|
|
15702
|
-
if (slug.includes("copilot") || slug.includes("github"))
|
|
15703
|
-
return "github-copilot";
|
|
15704
|
-
if (slug.includes("zai") || slug.includes("z-ai"))
|
|
15705
|
-
return "zai-coding-plan";
|
|
15706
|
-
if (slug.includes("kimi"))
|
|
15707
|
-
return "kimi-for-coding";
|
|
15708
|
-
if (slug.includes("opencode"))
|
|
15709
|
-
return "opencode";
|
|
15710
|
-
return;
|
|
15711
|
-
}
|
|
15712
|
-
function parseOpenRouterPrice(value) {
|
|
15713
|
-
if (!value)
|
|
15714
|
-
return;
|
|
15715
|
-
const parsed = Number.parseFloat(value);
|
|
15716
|
-
if (!Number.isFinite(parsed))
|
|
15717
|
-
return;
|
|
15718
|
-
return parsed * 1e6;
|
|
15719
|
-
}
|
|
15720
|
-
async function fetchJsonWithTimeout(url2, init, timeoutMs) {
|
|
15721
|
-
const controller = new AbortController;
|
|
15722
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
15723
|
-
try {
|
|
15724
|
-
return await fetch(url2, {
|
|
15725
|
-
...init,
|
|
15726
|
-
signal: controller.signal
|
|
15727
|
-
});
|
|
15728
|
-
} finally {
|
|
15729
|
-
clearTimeout(timer);
|
|
15730
|
-
}
|
|
15731
|
-
}
|
|
15732
|
-
async function fetchArtificialAnalysisSignals(apiKey) {
|
|
15733
|
-
const response = await fetchJsonWithTimeout("https://artificialanalysis.ai/api/v2/data/llms/models", {
|
|
15734
|
-
headers: {
|
|
15735
|
-
"x-api-key": apiKey
|
|
15736
|
-
}
|
|
15737
|
-
}, 8000);
|
|
15738
|
-
if (!response.ok) {
|
|
15739
|
-
throw new Error(`Artificial Analysis request failed (${response.status} ${response.statusText})`);
|
|
15740
|
-
}
|
|
15741
|
-
const parsed = await response.json();
|
|
15742
|
-
const map2 = {};
|
|
15743
|
-
for (const model of parsed.data ?? []) {
|
|
15744
|
-
const baseSignal = {
|
|
15745
|
-
qualityScore: model.evaluations?.artificial_analysis_intelligence_index,
|
|
15746
|
-
codingScore: model.evaluations?.artificial_analysis_coding_index ?? model.evaluations?.livecodebench,
|
|
15747
|
-
latencySeconds: model.median_time_to_first_token_seconds,
|
|
15748
|
-
inputPricePer1M: model.pricing?.price_1m_input_tokens ?? model.pricing?.price_1m_blended_3_to_1,
|
|
15749
|
-
outputPricePer1M: model.pricing?.price_1m_output_tokens ?? model.pricing?.price_1m_blended_3_to_1,
|
|
15750
|
-
source: "artificial-analysis"
|
|
15751
|
-
};
|
|
15752
|
-
const id = model.id ? normalizeKey(model.id) : undefined;
|
|
15753
|
-
const slug = model.slug ? normalizeKey(model.slug) : undefined;
|
|
15754
|
-
const name = model.name ? normalizeKey(model.name) : undefined;
|
|
15755
|
-
const providerPrefix = providerPrefixFromCreator(model.model_creator?.slug);
|
|
15756
|
-
for (const key of [id, slug, name]) {
|
|
15757
|
-
if (!key)
|
|
15758
|
-
continue;
|
|
15759
|
-
for (const alias of baseAliases(key)) {
|
|
15760
|
-
if (!providerPrefix || alias.includes("/")) {
|
|
15761
|
-
map2[alias] = mergeSignal(map2[alias], baseSignal);
|
|
15762
|
-
}
|
|
15763
|
-
const scopedAlias = providerScopedAlias(alias, providerPrefix);
|
|
15764
|
-
map2[scopedAlias] = mergeSignal(map2[scopedAlias], baseSignal);
|
|
15765
|
-
}
|
|
15766
|
-
}
|
|
15767
|
-
}
|
|
15768
|
-
return map2;
|
|
15769
|
-
}
|
|
15770
|
-
async function fetchOpenRouterSignals(apiKey) {
|
|
15771
|
-
const response = await fetchJsonWithTimeout("https://openrouter.ai/api/v1/models", {
|
|
15772
|
-
headers: {
|
|
15773
|
-
Authorization: `Bearer ${apiKey}`
|
|
15774
|
-
}
|
|
15775
|
-
}, 8000);
|
|
15776
|
-
if (!response.ok) {
|
|
15777
|
-
throw new Error(`OpenRouter request failed (${response.status} ${response.statusText})`);
|
|
15778
|
-
}
|
|
15779
|
-
const parsed = await response.json();
|
|
15780
|
-
const map2 = {};
|
|
15781
|
-
for (const model of parsed.data ?? []) {
|
|
15782
|
-
if (!model.id)
|
|
15783
|
-
continue;
|
|
15784
|
-
const key = normalizeKey(model.id);
|
|
15785
|
-
const providerPrefix = key.split("/")[0];
|
|
15786
|
-
const signal = {
|
|
15787
|
-
inputPricePer1M: parseOpenRouterPrice(model.pricing?.prompt),
|
|
15788
|
-
outputPricePer1M: parseOpenRouterPrice(model.pricing?.completion),
|
|
15789
|
-
source: "openrouter"
|
|
15790
|
-
};
|
|
15791
|
-
for (const alias of baseAliases(key)) {
|
|
15792
|
-
if (alias.includes("/")) {
|
|
15793
|
-
map2[alias] = mergeSignal(map2[alias], signal);
|
|
15794
|
-
}
|
|
15795
|
-
const scopedAlias = providerScopedAlias(alias, providerPrefix);
|
|
15796
|
-
map2[scopedAlias] = mergeSignal(map2[scopedAlias], signal);
|
|
15797
|
-
}
|
|
15798
|
-
}
|
|
15799
|
-
return map2;
|
|
15800
|
-
}
|
|
15801
|
-
async function fetchExternalModelSignals(options) {
|
|
15802
|
-
const warnings = [];
|
|
15803
|
-
const aggregate = {};
|
|
15804
|
-
const aaKey = options?.artificialAnalysisApiKey ?? getEnv("ARTIFICIAL_ANALYSIS_API_KEY");
|
|
15805
|
-
const orKey = options?.openRouterApiKey ?? getEnv("OPENROUTER_API_KEY");
|
|
15806
|
-
const aaPromise = aaKey ? fetchArtificialAnalysisSignals(aaKey) : Promise.resolve({});
|
|
15807
|
-
const orPromise = orKey ? fetchOpenRouterSignals(orKey) : Promise.resolve({});
|
|
15808
|
-
const [aaResult, orResult] = await Promise.allSettled([aaPromise, orPromise]);
|
|
15809
|
-
if (aaResult.status === "fulfilled") {
|
|
15810
|
-
for (const [key, signal] of Object.entries(aaResult.value)) {
|
|
15811
|
-
aggregate[key] = mergeSignal(aggregate[key], signal);
|
|
15812
|
-
}
|
|
15813
|
-
} else if (aaKey) {
|
|
15814
|
-
warnings.push(`Artificial Analysis unavailable: ${aaResult.reason instanceof Error ? aaResult.reason.message : String(aaResult.reason)}`);
|
|
15815
|
-
}
|
|
15816
|
-
if (orResult.status === "fulfilled") {
|
|
15817
|
-
for (const [key, signal] of Object.entries(orResult.value)) {
|
|
15818
|
-
aggregate[key] = mergeSignal(aggregate[key], signal);
|
|
15819
|
-
}
|
|
15820
|
-
} else if (orKey) {
|
|
15821
|
-
warnings.push(`OpenRouter unavailable: ${orResult.reason instanceof Error ? orResult.reason.message : String(orResult.reason)}`);
|
|
15822
|
-
}
|
|
15823
|
-
return { signals: aggregate, warnings };
|
|
15824
|
-
}
|
|
15825
|
-
// src/cli/system.ts
|
|
15826
|
-
import { statSync as statSync3 } from "fs";
|
|
15827
|
-
var cachedOpenCodePath = null;
|
|
15828
|
-
function getOpenCodePaths() {
|
|
15829
|
-
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
15830
|
-
return [
|
|
15831
|
-
"opencode",
|
|
15832
|
-
`${home}/.local/bin/opencode`,
|
|
15833
|
-
`${home}/.opencode/bin/opencode`,
|
|
15834
|
-
`${home}/bin/opencode`,
|
|
15835
|
-
"/usr/local/bin/opencode",
|
|
15836
|
-
"/opt/opencode/bin/opencode",
|
|
15837
|
-
"/usr/bin/opencode",
|
|
15838
|
-
"/bin/opencode",
|
|
15839
|
-
"/Applications/OpenCode.app/Contents/MacOS/opencode",
|
|
15840
|
-
`${home}/Applications/OpenCode.app/Contents/MacOS/opencode`,
|
|
15841
|
-
"/opt/homebrew/bin/opencode",
|
|
15842
|
-
"/home/linuxbrew/.linuxbrew/bin/opencode",
|
|
15843
|
-
`${home}/homebrew/bin/opencode`,
|
|
15844
|
-
`${home}/Library/Application Support/opencode/bin/opencode`,
|
|
15845
|
-
"/snap/bin/opencode",
|
|
15846
|
-
"/var/snap/opencode/current/bin/opencode",
|
|
15847
|
-
"/var/lib/flatpak/exports/bin/ai.opencode.OpenCode",
|
|
15848
|
-
`${home}/.local/share/flatpak/exports/bin/ai.opencode.OpenCode`,
|
|
15849
|
-
"/nix/store/opencode/bin/opencode",
|
|
15850
|
-
`${home}/.nix-profile/bin/opencode`,
|
|
15851
|
-
"/run/current-system/sw/bin/opencode",
|
|
15852
|
-
`${home}/.cargo/bin/opencode`,
|
|
15853
|
-
`${home}/.npm-global/bin/opencode`,
|
|
15854
|
-
"/usr/local/lib/node_modules/opencode/bin/opencode",
|
|
15855
|
-
`${home}/.yarn/bin/opencode`,
|
|
15856
|
-
`${home}/.pnpm-global/bin/opencode`
|
|
15857
|
-
];
|
|
15858
|
-
}
|
|
15859
|
-
function resolveOpenCodePath() {
|
|
15860
|
-
if (cachedOpenCodePath) {
|
|
15861
|
-
return cachedOpenCodePath;
|
|
15862
|
-
}
|
|
15863
|
-
const paths = getOpenCodePaths();
|
|
15864
|
-
for (const opencodePath of paths) {
|
|
15865
|
-
if (opencodePath === "opencode")
|
|
15866
|
-
continue;
|
|
15867
|
-
try {
|
|
15868
|
-
const stat = statSync3(opencodePath);
|
|
15869
|
-
if (stat.isFile()) {
|
|
15870
|
-
cachedOpenCodePath = opencodePath;
|
|
15871
|
-
return opencodePath;
|
|
15872
|
-
}
|
|
15873
|
-
} catch {}
|
|
15874
|
-
}
|
|
15875
|
-
return "opencode";
|
|
15876
|
-
}
|
|
15877
|
-
async function isOpenCodeInstalled() {
|
|
15878
|
-
const paths = getOpenCodePaths();
|
|
15879
|
-
for (const opencodePath of paths) {
|
|
15880
|
-
try {
|
|
15881
|
-
const proc = Bun.spawn([opencodePath, "--version"], {
|
|
15882
|
-
stdout: "pipe",
|
|
15883
|
-
stderr: "pipe"
|
|
15884
|
-
});
|
|
15885
|
-
await proc.exited;
|
|
15886
|
-
if (proc.exitCode === 0) {
|
|
15887
|
-
cachedOpenCodePath = opencodePath;
|
|
15888
|
-
return true;
|
|
15889
|
-
}
|
|
15890
|
-
} catch {}
|
|
15891
|
-
}
|
|
15892
|
-
return false;
|
|
15893
|
-
}
|
|
15894
|
-
async function getOpenCodeVersion() {
|
|
15895
|
-
const opencodePath = resolveOpenCodePath();
|
|
15896
|
-
try {
|
|
15897
|
-
const proc = Bun.spawn([opencodePath, "--version"], {
|
|
15898
|
-
stdout: "pipe",
|
|
15899
|
-
stderr: "pipe"
|
|
15900
|
-
});
|
|
15901
|
-
const output = await new Response(proc.stdout).text();
|
|
15902
|
-
await proc.exited;
|
|
15903
|
-
if (proc.exitCode === 0) {
|
|
15904
|
-
return output.trim();
|
|
15905
|
-
}
|
|
15906
|
-
} catch {}
|
|
15907
|
-
return null;
|
|
15908
|
-
}
|
|
15909
|
-
function getOpenCodePath() {
|
|
15910
|
-
const path2 = resolveOpenCodePath();
|
|
15911
|
-
return path2 === "opencode" ? null : path2;
|
|
15912
|
-
}
|
|
15913
|
-
|
|
15914
|
-
// src/cli/opencode-models.ts
|
|
15915
|
-
function isFreeModel(record2) {
|
|
15916
|
-
const inputCost = record2.cost?.input ?? 0;
|
|
15917
|
-
const outputCost = record2.cost?.output ?? 0;
|
|
15918
|
-
const cacheReadCost = record2.cost?.cache?.read ?? 0;
|
|
15919
|
-
const cacheWriteCost = record2.cost?.cache?.write ?? 0;
|
|
15920
|
-
return inputCost === 0 && outputCost === 0 && cacheReadCost === 0 && cacheWriteCost === 0;
|
|
15921
|
-
}
|
|
15922
|
-
function parseDailyRequestLimit(record2) {
|
|
15923
|
-
const explicitLimit = record2.quota?.requestsPerDay ?? record2.meta?.requestsPerDay ?? record2.meta?.dailyLimit;
|
|
15924
|
-
if (typeof explicitLimit === "number" && Number.isFinite(explicitLimit)) {
|
|
15925
|
-
return explicitLimit;
|
|
15926
|
-
}
|
|
15927
|
-
const source = `${record2.id} ${record2.name ?? ""}`.toLowerCase();
|
|
15928
|
-
const match = source.match(/\b(300|2000|5000)\b(?:\s*(?:req|requests|rpd|\/day))?/);
|
|
15929
|
-
if (!match)
|
|
15930
|
-
return;
|
|
15931
|
-
const parsed = Number.parseInt(match[1], 10);
|
|
15932
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
15933
|
-
}
|
|
15934
|
-
function normalizeDiscoveredModel(record2, providerFilter) {
|
|
15935
|
-
if (providerFilter && record2.providerID !== providerFilter)
|
|
15936
|
-
return null;
|
|
15937
|
-
const fullModel = `${record2.providerID}/${record2.id}`;
|
|
15938
|
-
return {
|
|
15939
|
-
providerID: record2.providerID,
|
|
15940
|
-
model: fullModel,
|
|
15941
|
-
name: record2.name ?? record2.id,
|
|
15942
|
-
status: record2.status ?? "active",
|
|
15943
|
-
contextLimit: record2.limit?.context ?? 0,
|
|
15944
|
-
outputLimit: record2.limit?.output ?? 0,
|
|
15945
|
-
reasoning: record2.capabilities?.reasoning === true,
|
|
15946
|
-
toolcall: record2.capabilities?.toolcall === true,
|
|
15947
|
-
attachment: record2.capabilities?.attachment === true,
|
|
15948
|
-
dailyRequestLimit: parseDailyRequestLimit(record2),
|
|
15949
|
-
costInput: record2.cost?.input,
|
|
15950
|
-
costOutput: record2.cost?.output
|
|
15951
|
-
};
|
|
15952
|
-
}
|
|
15953
|
-
function parseOpenCodeModelsVerboseOutput(output, providerFilter, freeOnly = true) {
|
|
15954
|
-
const lines = output.split(/\r?\n/);
|
|
15955
|
-
const models = [];
|
|
15956
|
-
const modelHeaderPattern = /^[a-z0-9-]+\/.+$/i;
|
|
15957
|
-
for (let index = 0;index < lines.length; index++) {
|
|
15958
|
-
const line = lines[index]?.trim();
|
|
15959
|
-
if (!line || !line.includes("/"))
|
|
15960
|
-
continue;
|
|
15961
|
-
if (!modelHeaderPattern.test(line))
|
|
15962
|
-
continue;
|
|
15963
|
-
let jsonStart = -1;
|
|
15964
|
-
for (let search = index + 1;search < lines.length; search++) {
|
|
15965
|
-
if (lines[search]?.trim().startsWith("{")) {
|
|
15966
|
-
jsonStart = search;
|
|
15967
|
-
break;
|
|
15968
|
-
}
|
|
15969
|
-
if (modelHeaderPattern.test(lines[search]?.trim() ?? "")) {
|
|
15970
|
-
break;
|
|
15971
|
-
}
|
|
15972
|
-
}
|
|
15973
|
-
if (jsonStart === -1)
|
|
15974
|
-
continue;
|
|
15975
|
-
let braceDepth = 0;
|
|
15976
|
-
const jsonLines = [];
|
|
15977
|
-
let jsonEnd = -1;
|
|
15978
|
-
for (let cursor = jsonStart;cursor < lines.length; cursor++) {
|
|
15979
|
-
const current = lines[cursor] ?? "";
|
|
15980
|
-
jsonLines.push(current);
|
|
15981
|
-
for (const char of current) {
|
|
15982
|
-
if (char === "{")
|
|
15983
|
-
braceDepth++;
|
|
15984
|
-
if (char === "}")
|
|
15985
|
-
braceDepth--;
|
|
15986
|
-
}
|
|
15987
|
-
if (braceDepth === 0 && jsonLines.length > 0) {
|
|
15988
|
-
jsonEnd = cursor;
|
|
15989
|
-
break;
|
|
15990
|
-
}
|
|
15991
|
-
}
|
|
15992
|
-
if (jsonEnd === -1)
|
|
15993
|
-
continue;
|
|
15994
|
-
try {
|
|
15995
|
-
const parsed = JSON.parse(jsonLines.join(`
|
|
15996
|
-
`));
|
|
15997
|
-
const normalized = normalizeDiscoveredModel(parsed, providerFilter);
|
|
15998
|
-
if (!normalized)
|
|
15999
|
-
continue;
|
|
16000
|
-
if (freeOnly && !isFreeModel(parsed))
|
|
16001
|
-
continue;
|
|
16002
|
-
if (normalized)
|
|
16003
|
-
models.push(normalized);
|
|
16004
|
-
} catch {}
|
|
16005
|
-
index = jsonEnd;
|
|
16006
|
-
}
|
|
16007
|
-
return models;
|
|
16008
|
-
}
|
|
16009
|
-
async function discoverModelsByProvider(providerID, freeOnly = true) {
|
|
16010
|
-
try {
|
|
16011
|
-
const opencodePath = resolveOpenCodePath();
|
|
16012
|
-
const proc = Bun.spawn([opencodePath, "models", "--refresh", "--verbose"], {
|
|
16013
|
-
stdout: "pipe",
|
|
16014
|
-
stderr: "pipe"
|
|
16015
|
-
});
|
|
16016
|
-
const stdout = await new Response(proc.stdout).text();
|
|
16017
|
-
const stderr = await new Response(proc.stderr).text();
|
|
16018
|
-
await proc.exited;
|
|
16019
|
-
if (proc.exitCode !== 0) {
|
|
16020
|
-
return {
|
|
16021
|
-
models: [],
|
|
16022
|
-
error: stderr.trim() || "Failed to fetch OpenCode models."
|
|
16023
|
-
};
|
|
16024
|
-
}
|
|
16025
|
-
return {
|
|
16026
|
-
models: parseOpenCodeModelsVerboseOutput(stdout, providerID, freeOnly)
|
|
16027
|
-
};
|
|
16028
|
-
} catch {
|
|
16029
|
-
return {
|
|
16030
|
-
models: [],
|
|
16031
|
-
error: "Unable to run `opencode models --refresh --verbose`."
|
|
16032
|
-
};
|
|
16033
|
-
}
|
|
16034
|
-
}
|
|
16035
|
-
async function discoverModelCatalog() {
|
|
16036
|
-
try {
|
|
16037
|
-
const opencodePath = resolveOpenCodePath();
|
|
16038
|
-
const proc = Bun.spawn([opencodePath, "models", "--refresh", "--verbose"], {
|
|
16039
|
-
stdout: "pipe",
|
|
16040
|
-
stderr: "pipe"
|
|
16041
|
-
});
|
|
16042
|
-
const stdout = await new Response(proc.stdout).text();
|
|
16043
|
-
const stderr = await new Response(proc.stderr).text();
|
|
16044
|
-
await proc.exited;
|
|
16045
|
-
if (proc.exitCode !== 0) {
|
|
16046
|
-
return {
|
|
16047
|
-
models: [],
|
|
16048
|
-
error: stderr.trim() || "Failed to fetch OpenCode models."
|
|
16049
|
-
};
|
|
16050
|
-
}
|
|
16051
|
-
return {
|
|
16052
|
-
models: parseOpenCodeModelsVerboseOutput(stdout, undefined, false)
|
|
16053
|
-
};
|
|
16054
|
-
} catch {
|
|
16055
|
-
return {
|
|
16056
|
-
models: [],
|
|
16057
|
-
error: "Unable to run `opencode models --refresh --verbose`."
|
|
16058
|
-
};
|
|
16059
|
-
}
|
|
16060
|
-
}
|
|
16061
|
-
async function discoverOpenCodeFreeModels() {
|
|
16062
|
-
const result = await discoverModelsByProvider("opencode", true);
|
|
16063
|
-
return { models: result.models, error: result.error };
|
|
16064
|
-
}
|
|
16065
|
-
async function discoverProviderModels(providerID) {
|
|
16066
|
-
return discoverModelsByProvider(providerID, false);
|
|
16067
|
-
}
|
|
16068
|
-
// src/cli/opencode-selection.ts
|
|
16069
|
-
var scoreOpenCodePrimaryForCoding = (model) => {
|
|
16070
|
-
return (model.reasoning ? 100 : 0) + (model.toolcall ? 80 : 0) + (model.attachment ? 20 : 0) + Math.min(model.contextLimit, 1e6) / 1e4 + Math.min(model.outputLimit, 300000) / 1e4 + (model.status === "active" ? 10 : 0);
|
|
16071
|
-
};
|
|
16072
|
-
function speedBonus2(modelName) {
|
|
16073
|
-
const lower = modelName.toLowerCase();
|
|
16074
|
-
let score = 0;
|
|
16075
|
-
if (lower.includes("nano"))
|
|
16076
|
-
score += 60;
|
|
16077
|
-
if (lower.includes("flash"))
|
|
16078
|
-
score += 45;
|
|
16079
|
-
if (lower.includes("mini"))
|
|
16080
|
-
score += 25;
|
|
16081
|
-
if (lower.includes("preview"))
|
|
16082
|
-
score += 10;
|
|
16083
|
-
return score;
|
|
16084
|
-
}
|
|
16085
|
-
var scoreOpenCodeSupportForCoding = (model) => {
|
|
16086
|
-
return (model.toolcall ? 90 : 0) + (model.reasoning ? 50 : 0) + speedBonus2(model.model) + Math.min(model.contextLimit, 400000) / 20000 + (model.status === "active" ? 5 : 0);
|
|
16087
|
-
};
|
|
16088
|
-
function pickBestCodingOpenCodeModel(models) {
|
|
16089
|
-
return pickBestModel(models, scoreOpenCodePrimaryForCoding);
|
|
16090
|
-
}
|
|
16091
|
-
function pickSupportOpenCodeModel(models, primaryModel) {
|
|
16092
|
-
const { support } = pickPrimaryAndSupport(models, {
|
|
16093
|
-
primary: scoreOpenCodePrimaryForCoding,
|
|
16094
|
-
support: scoreOpenCodeSupportForCoding
|
|
16095
|
-
}, primaryModel);
|
|
16096
|
-
return support;
|
|
16097
|
-
}
|
|
16098
|
-
// src/cli/install.ts
|
|
16099
|
-
var GREEN = "\x1B[32m";
|
|
16100
|
-
var BLUE = "\x1B[34m";
|
|
16101
|
-
var YELLOW = "\x1B[33m";
|
|
16102
|
-
var RED = "\x1B[31m";
|
|
16103
|
-
var BOLD = "\x1B[1m";
|
|
16104
|
-
var DIM = "\x1B[2m";
|
|
16105
|
-
var RESET = "\x1B[0m";
|
|
16106
|
-
var SYMBOLS = {
|
|
16107
|
-
check: `${GREEN}\u2713${RESET}`,
|
|
16108
|
-
cross: `${RED}\u2717${RESET}`,
|
|
16109
|
-
arrow: `${BLUE}\u2192${RESET}`,
|
|
16110
|
-
bullet: `${DIM}\u2022${RESET}`,
|
|
16111
|
-
info: `${BLUE}\u2139${RESET}`,
|
|
16112
|
-
warn: `${YELLOW}\u26A0${RESET}`,
|
|
16113
|
-
star: `${YELLOW}\u2605${RESET}`
|
|
16114
|
-
};
|
|
16115
|
-
function printHeader(isUpdate) {
|
|
16116
|
-
console.log();
|
|
16117
|
-
console.log(`${BOLD}oh-my-opencode-medium ${isUpdate ? "Update" : "Install"}${RESET}`);
|
|
16118
|
-
console.log("=".repeat(30));
|
|
16119
|
-
console.log();
|
|
16120
|
-
}
|
|
16121
|
-
function printStep(step, total, message) {
|
|
16122
|
-
console.log(`${DIM}[${step}/${total}]${RESET} ${message}`);
|
|
16123
|
-
}
|
|
16124
|
-
function printSuccess(message) {
|
|
16125
|
-
console.log(`${SYMBOLS.check} ${message}`);
|
|
16126
|
-
}
|
|
16127
|
-
function printError(message) {
|
|
16128
|
-
console.log(`${SYMBOLS.cross} ${RED}${message}${RESET}`);
|
|
14509
|
+
function printError(message) {
|
|
14510
|
+
console.log(`${SYMBOLS.cross} ${RED}${message}${RESET}`);
|
|
16129
14511
|
}
|
|
16130
14512
|
function printInfo(message) {
|
|
16131
14513
|
console.log(`${SYMBOLS.info} ${message}`);
|
|
16132
14514
|
}
|
|
16133
|
-
function printWarning(message) {
|
|
16134
|
-
console.log(`${SYMBOLS.warn} ${YELLOW}${message}${RESET}`);
|
|
16135
|
-
}
|
|
16136
14515
|
async function checkOpenCodeInstalled() {
|
|
16137
14516
|
const installed = await isOpenCodeInstalled();
|
|
16138
14517
|
if (!installed) {
|
|
@@ -16158,687 +14537,67 @@ function handleStepResult(result, successMsg) {
|
|
|
16158
14537
|
printSuccess(`${successMsg} ${SYMBOLS.arrow} ${DIM}${result.configPath}${RESET}`);
|
|
16159
14538
|
return true;
|
|
16160
14539
|
}
|
|
16161
|
-
function formatConfigSummary(
|
|
16162
|
-
const liteConfig = generateLiteConfig(config2);
|
|
16163
|
-
const preset = liteConfig.preset || "unknown";
|
|
14540
|
+
function formatConfigSummary() {
|
|
16164
14541
|
const lines = [];
|
|
16165
14542
|
lines.push(`${BOLD}Configuration Summary${RESET}`);
|
|
16166
14543
|
lines.push("");
|
|
16167
|
-
lines.push(` ${BOLD}Preset:${RESET} ${BLUE}${
|
|
16168
|
-
lines.push(` ${
|
|
16169
|
-
lines.push(` ${
|
|
16170
|
-
lines.push(` ${
|
|
16171
|
-
lines.push(` ${
|
|
16172
|
-
lines.push(` ${config2.hasZaiPlan ? SYMBOLS.check : `${DIM}\u25CB${RESET}`} ZAI Coding Plan`);
|
|
16173
|
-
lines.push(` ${config2.hasAntigravity ? SYMBOLS.check : `${DIM}\u25CB${RESET}`} Antigravity (Google)`);
|
|
16174
|
-
lines.push(` ${config2.hasChutes ? SYMBOLS.check : `${DIM}\u25CB${RESET}`} Chutes`);
|
|
16175
|
-
lines.push(` ${SYMBOLS.check} Opencode Zen`);
|
|
16176
|
-
lines.push(` ${config2.balanceProviderUsage ? SYMBOLS.check : `${DIM}\u25CB${RESET}`} Balanced provider spend`);
|
|
16177
|
-
if (config2.useOpenCodeFreeModels && config2.selectedOpenCodePrimaryModel) {
|
|
16178
|
-
lines.push(` ${SYMBOLS.check} OpenCode Free Primary: ${BLUE}${config2.selectedOpenCodePrimaryModel}${RESET}`);
|
|
16179
|
-
}
|
|
16180
|
-
if (config2.useOpenCodeFreeModels && config2.selectedOpenCodeSecondaryModel) {
|
|
16181
|
-
lines.push(` ${SYMBOLS.check} OpenCode Free Support: ${BLUE}${config2.selectedOpenCodeSecondaryModel}${RESET}`);
|
|
16182
|
-
}
|
|
16183
|
-
if (config2.hasChutes && config2.selectedChutesPrimaryModel) {
|
|
16184
|
-
lines.push(` ${SYMBOLS.check} Chutes Primary: ${BLUE}${config2.selectedChutesPrimaryModel}${RESET}`);
|
|
16185
|
-
}
|
|
16186
|
-
if (config2.hasChutes && config2.selectedChutesSecondaryModel) {
|
|
16187
|
-
lines.push(` ${SYMBOLS.check} Chutes Support: ${BLUE}${config2.selectedChutesSecondaryModel}${RESET}`);
|
|
16188
|
-
}
|
|
16189
|
-
lines.push(` ${config2.hasTmux ? SYMBOLS.check : `${DIM}\u25CB${RESET}`} Tmux Integration`);
|
|
14544
|
+
lines.push(` ${BOLD}Preset:${RESET} ${BLUE}openai${RESET}`);
|
|
14545
|
+
lines.push(` ${SYMBOLS.check} OpenAI (default)`);
|
|
14546
|
+
lines.push(` ${DIM}\u25CB Kimi \u2014 see docs/provider-configurations.md${RESET}`);
|
|
14547
|
+
lines.push(` ${DIM}\u25CB GitHub Copilot \u2014 see docs/provider-configurations.md${RESET}`);
|
|
14548
|
+
lines.push(` ${DIM}\u25CB ZAI Coding Plan \u2014 see docs/provider-configurations.md${RESET}`);
|
|
16190
14549
|
return lines.join(`
|
|
16191
14550
|
`);
|
|
16192
14551
|
}
|
|
16193
|
-
function printAgentModels(config2) {
|
|
16194
|
-
const liteConfig = generateLiteConfig(config2);
|
|
16195
|
-
const presetName = liteConfig.preset || "unknown";
|
|
16196
|
-
const presets = liteConfig.presets;
|
|
16197
|
-
const agents = presets?.[presetName];
|
|
16198
|
-
if (!agents || Object.keys(agents).length === 0)
|
|
16199
|
-
return;
|
|
16200
|
-
console.log(`${BOLD}Agent Configuration (Preset: ${BLUE}${presetName}${RESET}):${RESET}`);
|
|
16201
|
-
console.log();
|
|
16202
|
-
const maxAgentLen = Math.max(...Object.keys(agents).map((a) => a.length));
|
|
16203
|
-
for (const [agent, info] of Object.entries(agents)) {
|
|
16204
|
-
const padding = " ".repeat(maxAgentLen - agent.length);
|
|
16205
|
-
const skillsStr = info.skills.length > 0 ? ` ${DIM}[${info.skills.join(", ")}]${RESET}` : "";
|
|
16206
|
-
console.log(` ${DIM}${agent}${RESET}${padding} ${SYMBOLS.arrow} ${BLUE}${info.model}${RESET}${skillsStr}`);
|
|
16207
|
-
}
|
|
16208
|
-
console.log();
|
|
16209
|
-
}
|
|
16210
|
-
function argsToConfig(args) {
|
|
16211
|
-
return {
|
|
16212
|
-
hasKimi: args.kimi === "yes",
|
|
16213
|
-
hasOpenAI: args.openai === "yes",
|
|
16214
|
-
hasAnthropic: args.anthropic === "yes",
|
|
16215
|
-
hasCopilot: args.copilot === "yes",
|
|
16216
|
-
hasZaiPlan: args.zaiPlan === "yes",
|
|
16217
|
-
hasAntigravity: args.antigravity === "yes",
|
|
16218
|
-
hasChutes: args.chutes === "yes",
|
|
16219
|
-
hasOpencodeZen: true,
|
|
16220
|
-
useOpenCodeFreeModels: args.opencodeFree === "yes",
|
|
16221
|
-
preferredOpenCodeModel: args.opencodeFreeModel && args.opencodeFreeModel !== "auto" ? args.opencodeFreeModel : undefined,
|
|
16222
|
-
artificialAnalysisApiKey: args.aaKey,
|
|
16223
|
-
openRouterApiKey: args.openrouterKey,
|
|
16224
|
-
balanceProviderUsage: args.balancedSpend === "yes",
|
|
16225
|
-
hasTmux: args.tmux === "yes",
|
|
16226
|
-
installSkills: args.skills === "yes",
|
|
16227
|
-
installCustomSkills: args.skills === "yes",
|
|
16228
|
-
setupMode: "quick",
|
|
16229
|
-
dryRun: args.dryRun,
|
|
16230
|
-
modelsOnly: args.modelsOnly
|
|
16231
|
-
};
|
|
16232
|
-
}
|
|
16233
|
-
async function askModelSelection(rl, models, defaultModel, prompt) {
|
|
16234
|
-
const defaultIndex = Math.max(0, models.findIndex((model) => model.model === defaultModel));
|
|
16235
|
-
for (const [index, model] of models.entries()) {
|
|
16236
|
-
const marker = model.model === defaultModel ? `${BOLD}(recommended)${RESET}` : "";
|
|
16237
|
-
console.log(` ${DIM}${index + 1}.${RESET} ${BLUE}${model.model}${RESET} ${DIM}${model.name}${RESET} ${marker}`);
|
|
16238
|
-
}
|
|
16239
|
-
const answer = (await rl.question(`${BLUE}${prompt}${RESET} ${DIM}[default: ${defaultIndex + 1}]${RESET}: `)).trim().toLowerCase();
|
|
16240
|
-
if (!answer)
|
|
16241
|
-
return defaultModel;
|
|
16242
|
-
const asNumber = Number.parseInt(answer, 10);
|
|
16243
|
-
if (Number.isFinite(asNumber)) {
|
|
16244
|
-
const chosen = models[asNumber - 1];
|
|
16245
|
-
if (chosen)
|
|
16246
|
-
return chosen.model;
|
|
16247
|
-
}
|
|
16248
|
-
const byId = models.find((model) => model.model.toLowerCase() === answer);
|
|
16249
|
-
return byId?.model ?? defaultModel;
|
|
16250
|
-
}
|
|
16251
|
-
async function askYesNo(rl, prompt, defaultValue = "no") {
|
|
16252
|
-
const hint = defaultValue === "yes" ? "[Y/n]" : "[y/N]";
|
|
16253
|
-
const answer = (await rl.question(`${BLUE}${prompt}${RESET} ${hint}: `)).trim().toLowerCase();
|
|
16254
|
-
if (answer === "")
|
|
16255
|
-
return defaultValue;
|
|
16256
|
-
if (answer === "y" || answer === "yes")
|
|
16257
|
-
return "yes";
|
|
16258
|
-
if (answer === "n" || answer === "no")
|
|
16259
|
-
return "no";
|
|
16260
|
-
return defaultValue;
|
|
16261
|
-
}
|
|
16262
|
-
async function askOptionalApiKey(rl, prompt, fromEnv) {
|
|
16263
|
-
const hint = fromEnv ? "[optional, Enter keeps env value]" : "[optional]";
|
|
16264
|
-
const answer = (await rl.question(`${BLUE}${prompt}${RESET} ${DIM}${hint}${RESET}: `)).trim();
|
|
16265
|
-
if (!answer)
|
|
16266
|
-
return fromEnv;
|
|
16267
|
-
return answer;
|
|
16268
|
-
}
|
|
16269
|
-
async function askSetupMode(rl) {
|
|
16270
|
-
console.log(`${BOLD}Choose setup mode:${RESET}`);
|
|
16271
|
-
console.log(` ${DIM}1.${RESET} Quick setup - you choose providers, we auto-pick models`);
|
|
16272
|
-
console.log(` ${DIM}2.${RESET} Manual setup - you choose providers and models per agent`);
|
|
16273
|
-
console.log();
|
|
16274
|
-
const answer = (await rl.question(`${BLUE}Selection${RESET} ${DIM}[default: 1]${RESET}: `)).trim().toLowerCase();
|
|
16275
|
-
if (answer === "2" || answer === "manual")
|
|
16276
|
-
return "manual";
|
|
16277
|
-
return "quick";
|
|
16278
|
-
}
|
|
16279
|
-
async function askModelByNumber(rl, models, prompt, allowEmpty = false) {
|
|
16280
|
-
let showAll = false;
|
|
16281
|
-
while (true) {
|
|
16282
|
-
console.log(`${BOLD}${prompt}${RESET}`);
|
|
16283
|
-
console.log(`${DIM}Available models:${RESET}`);
|
|
16284
|
-
const modelsToShow = showAll ? models : models.slice(0, 5);
|
|
16285
|
-
const remainingCount = models.length - modelsToShow.length;
|
|
16286
|
-
for (const [index, model] of modelsToShow.entries()) {
|
|
16287
|
-
const displayIndex = showAll ? index + 1 : index + 1;
|
|
16288
|
-
const name = model.name ? ` ${DIM}(${model.name})${RESET}` : "";
|
|
16289
|
-
console.log(` ${DIM}${displayIndex}.${RESET} ${BLUE}${model.model}${RESET}${name}`);
|
|
16290
|
-
}
|
|
16291
|
-
if (!showAll && remainingCount > 0) {
|
|
16292
|
-
console.log(`${DIM} ... and ${remainingCount} more${RESET}`);
|
|
16293
|
-
console.log(`${DIM} (type "all" to show the full list)${RESET}`);
|
|
16294
|
-
}
|
|
16295
|
-
console.log(`${DIM} (or type any model ID directly)${RESET}`);
|
|
16296
|
-
console.log();
|
|
16297
|
-
const answer = (await rl.question(`${BLUE}Selection${RESET}: `)).trim().toLowerCase();
|
|
16298
|
-
if (!answer) {
|
|
16299
|
-
if (allowEmpty)
|
|
16300
|
-
return;
|
|
16301
|
-
return models[0]?.model;
|
|
16302
|
-
}
|
|
16303
|
-
if (answer === "all") {
|
|
16304
|
-
showAll = true;
|
|
16305
|
-
console.log();
|
|
16306
|
-
continue;
|
|
16307
|
-
}
|
|
16308
|
-
const asNumber = Number.parseInt(answer, 10);
|
|
16309
|
-
if (Number.isFinite(asNumber) && asNumber >= 1 && asNumber <= models.length) {
|
|
16310
|
-
return models[asNumber - 1]?.model;
|
|
16311
|
-
}
|
|
16312
|
-
const byId = models.find((m) => m.model.toLowerCase() === answer);
|
|
16313
|
-
if (byId)
|
|
16314
|
-
return byId.model;
|
|
16315
|
-
if (answer.includes("/"))
|
|
16316
|
-
return answer;
|
|
16317
|
-
printWarning(`Invalid selection: "${answer}". Using first available model.`);
|
|
16318
|
-
return models[0]?.model;
|
|
16319
|
-
}
|
|
16320
|
-
}
|
|
16321
|
-
async function configureAgentManually(rl, agentName, allModels) {
|
|
16322
|
-
console.log();
|
|
16323
|
-
console.log(`${BOLD}Configure ${agentName}:${RESET}`);
|
|
16324
|
-
console.log();
|
|
16325
|
-
const selectedModels = new Set;
|
|
16326
|
-
const primary = await askModelByNumber(rl, allModels, "Primary model") ?? allModels[0]?.model ?? "opencode/big-pickle";
|
|
16327
|
-
selectedModels.add(primary);
|
|
16328
|
-
const availableForFallback1 = allModels.filter((m) => !selectedModels.has(m.model));
|
|
16329
|
-
const fallback1 = availableForFallback1.length > 0 ? await askModelByNumber(rl, availableForFallback1, "Fallback 1 (optional, press Enter to skip)", true) ?? primary : primary;
|
|
16330
|
-
if (fallback1 !== primary)
|
|
16331
|
-
selectedModels.add(fallback1);
|
|
16332
|
-
const availableForFallback2 = allModels.filter((m) => !selectedModels.has(m.model));
|
|
16333
|
-
const fallback2 = availableForFallback2.length > 0 ? await askModelByNumber(rl, availableForFallback2, "Fallback 2 (optional, press Enter to skip)", true) ?? fallback1 : fallback1;
|
|
16334
|
-
if (fallback2 !== fallback1)
|
|
16335
|
-
selectedModels.add(fallback2);
|
|
16336
|
-
const availableForFallback3 = allModels.filter((m) => !selectedModels.has(m.model));
|
|
16337
|
-
const fallback3 = availableForFallback3.length > 0 ? await askModelByNumber(rl, availableForFallback3, "Fallback 3 (optional, press Enter to skip)", true) ?? fallback2 : fallback2;
|
|
16338
|
-
return {
|
|
16339
|
-
primary,
|
|
16340
|
-
fallback1,
|
|
16341
|
-
fallback2,
|
|
16342
|
-
fallback3
|
|
16343
|
-
};
|
|
16344
|
-
}
|
|
16345
|
-
async function runManualSetupMode(rl, detected, modelsOnly = false) {
|
|
16346
|
-
console.log();
|
|
16347
|
-
console.log(`${BOLD}Manual Setup Mode${RESET}`);
|
|
16348
|
-
console.log("=".repeat(20));
|
|
16349
|
-
console.log();
|
|
16350
|
-
const existingAaKey = getEnv("ARTIFICIAL_ANALYSIS_API_KEY");
|
|
16351
|
-
const existingOpenRouterKey = getEnv("OPENROUTER_API_KEY");
|
|
16352
|
-
const artificialAnalysisApiKey = await askOptionalApiKey(rl, "Artificial Analysis API key for better ranking signals", existingAaKey);
|
|
16353
|
-
if (existingAaKey && !artificialAnalysisApiKey) {
|
|
16354
|
-
printInfo("Using existing ARTIFICIAL_ANALYSIS_API_KEY from environment.");
|
|
16355
|
-
}
|
|
16356
|
-
console.log();
|
|
16357
|
-
const openRouterApiKey = await askOptionalApiKey(rl, "OpenRouter API key for pricing/metadata signals", existingOpenRouterKey);
|
|
16358
|
-
if (existingOpenRouterKey && !openRouterApiKey) {
|
|
16359
|
-
printInfo("Using existing OPENROUTER_API_KEY from environment.");
|
|
16360
|
-
}
|
|
16361
|
-
console.log();
|
|
16362
|
-
const useOpenCodeFree = await askYesNo(rl, "Use Opencode Free models (opencode/*)?", "yes");
|
|
16363
|
-
console.log();
|
|
16364
|
-
let availableOpenCodeFreeModels;
|
|
16365
|
-
let availableChutesModels;
|
|
16366
|
-
if (useOpenCodeFree === "yes") {
|
|
16367
|
-
printInfo("Refreshing models with: opencode models --refresh --verbose");
|
|
16368
|
-
const discovery = await discoverOpenCodeFreeModels();
|
|
16369
|
-
if (discovery.models.length === 0) {
|
|
16370
|
-
printWarning(discovery.error ?? "No OpenCode free models found. Continuing without OpenCode free-model assignment.");
|
|
16371
|
-
} else {
|
|
16372
|
-
availableOpenCodeFreeModels = discovery.models;
|
|
16373
|
-
printSuccess(`Found ${discovery.models.length} OpenCode free models`);
|
|
16374
|
-
}
|
|
16375
|
-
console.log();
|
|
16376
|
-
}
|
|
16377
|
-
const kimi = await askYesNo(rl, "Enable Kimi provider?", detected.hasKimi ? "yes" : "no");
|
|
16378
|
-
console.log();
|
|
16379
|
-
const openai = await askYesNo(rl, "Enable OpenAI provider?", detected.hasOpenAI ? "yes" : "no");
|
|
16380
|
-
console.log();
|
|
16381
|
-
const anthropic = await askYesNo(rl, "Enable Anthropic provider?", detected.hasAnthropic ? "yes" : "no");
|
|
16382
|
-
console.log();
|
|
16383
|
-
const copilot = await askYesNo(rl, "Enable GitHub Copilot provider?", detected.hasCopilot ? "yes" : "no");
|
|
16384
|
-
console.log();
|
|
16385
|
-
const zaiPlan = await askYesNo(rl, "Enable ZAI Coding Plan provider?", detected.hasZaiPlan ? "yes" : "no");
|
|
16386
|
-
console.log();
|
|
16387
|
-
const antigravity = await askYesNo(rl, "Enable Antigravity (Google) provider?", detected.hasAntigravity ? "yes" : "no");
|
|
16388
|
-
console.log();
|
|
16389
|
-
const chutes = await askYesNo(rl, "Enable Chutes provider?", detected.hasChutes ? "yes" : "no");
|
|
16390
|
-
console.log();
|
|
16391
|
-
if (chutes === "yes") {
|
|
16392
|
-
printInfo("Refreshing Chutes model list with: opencode models --refresh --verbose");
|
|
16393
|
-
const discovery = await discoverProviderModels("chutes");
|
|
16394
|
-
if (discovery.models.length === 0) {
|
|
16395
|
-
printWarning(discovery.error ?? "No Chutes models found. Continuing without Chutes dynamic assignment.");
|
|
16396
|
-
} else {
|
|
16397
|
-
availableChutesModels = discovery.models;
|
|
16398
|
-
printSuccess(`Found ${discovery.models.length} Chutes models`);
|
|
16399
|
-
}
|
|
16400
|
-
console.log();
|
|
16401
|
-
}
|
|
16402
|
-
const availableModels = [];
|
|
16403
|
-
if (useOpenCodeFree === "yes" && availableOpenCodeFreeModels) {
|
|
16404
|
-
for (const model of availableOpenCodeFreeModels) {
|
|
16405
|
-
availableModels.push({ model: model.model, name: model.name });
|
|
16406
|
-
}
|
|
16407
|
-
}
|
|
16408
|
-
if (kimi === "yes") {
|
|
16409
|
-
availableModels.push({ model: "kimi-for-coding/k2p5", name: "Kimi K2.5" });
|
|
16410
|
-
}
|
|
16411
|
-
if (openai === "yes") {
|
|
16412
|
-
availableModels.push({
|
|
16413
|
-
model: "openai/gpt-5.3-codex",
|
|
16414
|
-
name: "GPT-5.3 Codex"
|
|
16415
|
-
});
|
|
16416
|
-
availableModels.push({
|
|
16417
|
-
model: "openai/gpt-5.1-codex-mini",
|
|
16418
|
-
name: "GPT-5.1 Codex Mini"
|
|
16419
|
-
});
|
|
16420
|
-
}
|
|
16421
|
-
if (anthropic === "yes") {
|
|
16422
|
-
availableModels.push({
|
|
16423
|
-
model: "anthropic/claude-opus-4-6",
|
|
16424
|
-
name: "Claude Opus 4.6"
|
|
16425
|
-
});
|
|
16426
|
-
availableModels.push({
|
|
16427
|
-
model: "anthropic/claude-sonnet-4-5",
|
|
16428
|
-
name: "Claude Sonnet 4.5"
|
|
16429
|
-
});
|
|
16430
|
-
availableModels.push({
|
|
16431
|
-
model: "anthropic/claude-haiku-4-5",
|
|
16432
|
-
name: "Claude Haiku 4.5"
|
|
16433
|
-
});
|
|
16434
|
-
}
|
|
16435
|
-
if (copilot === "yes") {
|
|
16436
|
-
availableModels.push({
|
|
16437
|
-
model: "github-copilot/grok-code-fast-1",
|
|
16438
|
-
name: "Grok Code Fast"
|
|
16439
|
-
});
|
|
16440
|
-
}
|
|
16441
|
-
if (zaiPlan === "yes") {
|
|
16442
|
-
availableModels.push({ model: "zai-coding-plan/glm-4.7", name: "GLM 4.7" });
|
|
16443
|
-
}
|
|
16444
|
-
if (antigravity === "yes") {
|
|
16445
|
-
availableModels.push({
|
|
16446
|
-
model: "google/antigravity-gemini-3.1-pro",
|
|
16447
|
-
name: "Gemini 3.1 Pro"
|
|
16448
|
-
});
|
|
16449
|
-
availableModels.push({
|
|
16450
|
-
model: "google/antigravity-gemini-3-flash",
|
|
16451
|
-
name: "Gemini 3 Flash"
|
|
16452
|
-
});
|
|
16453
|
-
}
|
|
16454
|
-
if (chutes === "yes" && availableChutesModels) {
|
|
16455
|
-
for (const model of availableChutesModels) {
|
|
16456
|
-
availableModels.push({ model: model.model, name: model.name });
|
|
16457
|
-
}
|
|
16458
|
-
}
|
|
16459
|
-
availableModels.push({
|
|
16460
|
-
model: "opencode/big-pickle",
|
|
16461
|
-
name: "OpenCode Big Pickle"
|
|
16462
|
-
});
|
|
16463
|
-
if (availableModels.length === 0) {
|
|
16464
|
-
printWarning("No models available. Please enable at least one provider.");
|
|
16465
|
-
availableModels.push({
|
|
16466
|
-
model: "opencode/big-pickle",
|
|
16467
|
-
name: "OpenCode Big Pickle"
|
|
16468
|
-
});
|
|
16469
|
-
}
|
|
16470
|
-
const manualAgentConfigs = {};
|
|
16471
|
-
const agentNames = [
|
|
16472
|
-
"orchestrator",
|
|
16473
|
-
"oracle",
|
|
16474
|
-
"designer",
|
|
16475
|
-
"explorer",
|
|
16476
|
-
"librarian",
|
|
16477
|
-
"fixer"
|
|
16478
|
-
];
|
|
16479
|
-
for (const agentName of agentNames) {
|
|
16480
|
-
manualAgentConfigs[agentName] = await configureAgentManually(rl, agentName, availableModels);
|
|
16481
|
-
}
|
|
16482
|
-
const balancedSpend = await askYesNo(rl, "Do you have subscriptions or pay per API? If yes, we will distribute assignments evenly across selected providers so your subscriptions last longer.", "no");
|
|
16483
|
-
console.log();
|
|
16484
|
-
let skills = "no";
|
|
16485
|
-
let customSkills = "no";
|
|
16486
|
-
if (!modelsOnly) {
|
|
16487
|
-
console.log(`${BOLD}Recommended Skills:${RESET}`);
|
|
16488
|
-
for (const skill of RECOMMENDED_SKILLS) {
|
|
16489
|
-
console.log(` ${SYMBOLS.bullet} ${BOLD}${skill.name}${RESET}: ${skill.description}`);
|
|
16490
|
-
}
|
|
16491
|
-
console.log();
|
|
16492
|
-
skills = await askYesNo(rl, "Install recommended skills?", "yes");
|
|
16493
|
-
console.log();
|
|
16494
|
-
console.log(`${BOLD}Custom Skills:${RESET}`);
|
|
16495
|
-
for (const skill of CUSTOM_SKILLS) {
|
|
16496
|
-
console.log(` ${SYMBOLS.bullet} ${BOLD}${skill.name}${RESET}: ${skill.description}`);
|
|
16497
|
-
}
|
|
16498
|
-
console.log();
|
|
16499
|
-
customSkills = await askYesNo(rl, "Install custom skills?", "yes");
|
|
16500
|
-
console.log();
|
|
16501
|
-
} else {
|
|
16502
|
-
printInfo("Models-only mode: skipping plugin/auth setup and skills prompts.");
|
|
16503
|
-
console.log();
|
|
16504
|
-
}
|
|
16505
|
-
return {
|
|
16506
|
-
hasKimi: kimi === "yes",
|
|
16507
|
-
hasOpenAI: openai === "yes",
|
|
16508
|
-
hasAnthropic: anthropic === "yes",
|
|
16509
|
-
hasCopilot: copilot === "yes",
|
|
16510
|
-
hasZaiPlan: zaiPlan === "yes",
|
|
16511
|
-
hasAntigravity: antigravity === "yes",
|
|
16512
|
-
hasChutes: chutes === "yes",
|
|
16513
|
-
hasOpencodeZen: true,
|
|
16514
|
-
useOpenCodeFreeModels: useOpenCodeFree === "yes" && availableOpenCodeFreeModels !== undefined,
|
|
16515
|
-
availableOpenCodeFreeModels,
|
|
16516
|
-
availableChutesModels,
|
|
16517
|
-
artificialAnalysisApiKey,
|
|
16518
|
-
openRouterApiKey,
|
|
16519
|
-
balanceProviderUsage: balancedSpend === "yes",
|
|
16520
|
-
hasTmux: false,
|
|
16521
|
-
installSkills: skills === "yes",
|
|
16522
|
-
installCustomSkills: customSkills === "yes",
|
|
16523
|
-
setupMode: "manual",
|
|
16524
|
-
manualAgentConfigs,
|
|
16525
|
-
modelsOnly
|
|
16526
|
-
};
|
|
16527
|
-
}
|
|
16528
|
-
async function runInteractiveMode(detected, modelsOnly = false) {
|
|
16529
|
-
const rl = readline.createInterface({
|
|
16530
|
-
input: process.stdin,
|
|
16531
|
-
output: process.stdout
|
|
16532
|
-
});
|
|
16533
|
-
try {
|
|
16534
|
-
console.log();
|
|
16535
|
-
console.log(`${BOLD}oh-my-opencode-medium Setup${RESET}`);
|
|
16536
|
-
console.log("=".repeat(25));
|
|
16537
|
-
console.log();
|
|
16538
|
-
const setupMode = await askSetupMode(rl);
|
|
16539
|
-
if (setupMode === "manual") {
|
|
16540
|
-
const config2 = await runManualSetupMode(rl, detected, modelsOnly);
|
|
16541
|
-
rl.close();
|
|
16542
|
-
return config2;
|
|
16543
|
-
}
|
|
16544
|
-
const totalQuestions = 11;
|
|
16545
|
-
const existingAaKey = getEnv("ARTIFICIAL_ANALYSIS_API_KEY");
|
|
16546
|
-
const existingOpenRouterKey = getEnv("OPENROUTER_API_KEY");
|
|
16547
|
-
console.log(`${BOLD}Question 1/${totalQuestions}:${RESET}`);
|
|
16548
|
-
const artificialAnalysisApiKey = await askOptionalApiKey(rl, "Artificial Analysis API key for better ranking signals", existingAaKey);
|
|
16549
|
-
if (existingAaKey && !artificialAnalysisApiKey) {
|
|
16550
|
-
printInfo("Using existing ARTIFICIAL_ANALYSIS_API_KEY from environment.");
|
|
16551
|
-
}
|
|
16552
|
-
console.log();
|
|
16553
|
-
console.log(`${BOLD}Question 2/${totalQuestions}:${RESET}`);
|
|
16554
|
-
const openRouterApiKey = await askOptionalApiKey(rl, "OpenRouter API key for pricing/metadata signals", existingOpenRouterKey);
|
|
16555
|
-
if (existingOpenRouterKey && !openRouterApiKey) {
|
|
16556
|
-
printInfo("Using existing OPENROUTER_API_KEY from environment.");
|
|
16557
|
-
}
|
|
16558
|
-
console.log();
|
|
16559
|
-
console.log(`${BOLD}Question 3/${totalQuestions}:${RESET}`);
|
|
16560
|
-
const useOpenCodeFree = await askYesNo(rl, "Use Opencode Free models (opencode/*)?", "yes");
|
|
16561
|
-
console.log();
|
|
16562
|
-
let availableOpenCodeFreeModels;
|
|
16563
|
-
let selectedOpenCodePrimaryModel;
|
|
16564
|
-
let selectedOpenCodeSecondaryModel;
|
|
16565
|
-
let availableChutesModels;
|
|
16566
|
-
let selectedChutesPrimaryModel;
|
|
16567
|
-
let selectedChutesSecondaryModel;
|
|
16568
|
-
if (useOpenCodeFree === "yes") {
|
|
16569
|
-
printInfo("Refreshing models with: opencode models --refresh --verbose");
|
|
16570
|
-
const discovery = await discoverOpenCodeFreeModels();
|
|
16571
|
-
if (discovery.models.length === 0) {
|
|
16572
|
-
printWarning(discovery.error ?? "No OpenCode free models found. Continuing without OpenCode free-model assignment.");
|
|
16573
|
-
} else {
|
|
16574
|
-
availableOpenCodeFreeModels = discovery.models;
|
|
16575
|
-
const recommendedPrimary = pickBestCodingOpenCodeModel(discovery.models)?.model ?? discovery.models[0]?.model;
|
|
16576
|
-
if (recommendedPrimary) {
|
|
16577
|
-
printInfo("This step configures only OpenCode Free primary/support models.");
|
|
16578
|
-
console.log(`${BOLD}OpenCode Free Models:${RESET}`);
|
|
16579
|
-
selectedOpenCodePrimaryModel = await askModelSelection(rl, discovery.models, recommendedPrimary, "Choose primary model for orchestrator/oracle");
|
|
16580
|
-
}
|
|
16581
|
-
if (selectedOpenCodePrimaryModel) {
|
|
16582
|
-
const recommendedSecondary = pickSupportOpenCodeModel(discovery.models, selectedOpenCodePrimaryModel)?.model ?? selectedOpenCodePrimaryModel;
|
|
16583
|
-
const openCodeSupportList = discovery.models.filter((model) => model.model !== selectedOpenCodePrimaryModel);
|
|
16584
|
-
const openCodeSupportDefault = recommendedSecondary === selectedOpenCodePrimaryModel ? openCodeSupportList[0]?.model ?? recommendedSecondary : recommendedSecondary;
|
|
16585
|
-
selectedOpenCodeSecondaryModel = await askModelSelection(rl, openCodeSupportList, openCodeSupportDefault, "Choose support model for explorer/librarian/fixer");
|
|
16586
|
-
}
|
|
16587
|
-
console.log();
|
|
16588
|
-
}
|
|
16589
|
-
}
|
|
16590
|
-
console.log(`${BOLD}Question 4/${totalQuestions}:${RESET}`);
|
|
16591
|
-
const kimi = await askYesNo(rl, "Enable Kimi provider?", detected.hasKimi ? "yes" : "no");
|
|
16592
|
-
console.log();
|
|
16593
|
-
console.log(`${BOLD}Question 5/${totalQuestions}:${RESET}`);
|
|
16594
|
-
const openai = await askYesNo(rl, "Enable OpenAI provider?", detected.hasOpenAI ? "yes" : "no");
|
|
16595
|
-
console.log();
|
|
16596
|
-
console.log(`${BOLD}Question 6/${totalQuestions}:${RESET}`);
|
|
16597
|
-
const anthropic = await askYesNo(rl, "Enable Anthropic provider?", detected.hasAnthropic ? "yes" : "no");
|
|
16598
|
-
console.log();
|
|
16599
|
-
console.log(`${BOLD}Question 7/${totalQuestions}:${RESET}`);
|
|
16600
|
-
const copilot = await askYesNo(rl, "Enable GitHub Copilot provider?", detected.hasCopilot ? "yes" : "no");
|
|
16601
|
-
console.log();
|
|
16602
|
-
console.log(`${BOLD}Question 8/${totalQuestions}:${RESET}`);
|
|
16603
|
-
const zaiPlan = await askYesNo(rl, "Enable ZAI Coding Plan provider?", detected.hasZaiPlan ? "yes" : "no");
|
|
16604
|
-
console.log();
|
|
16605
|
-
console.log(`${BOLD}Question 9/${totalQuestions}:${RESET}`);
|
|
16606
|
-
const antigravity = await askYesNo(rl, "Enable Antigravity (Google) provider?", detected.hasAntigravity ? "yes" : "no");
|
|
16607
|
-
console.log();
|
|
16608
|
-
console.log(`${BOLD}Question 10/${totalQuestions}:${RESET}`);
|
|
16609
|
-
const chutes = await askYesNo(rl, "Enable Chutes provider?", detected.hasChutes ? "yes" : "no");
|
|
16610
|
-
console.log();
|
|
16611
|
-
if (chutes === "yes") {
|
|
16612
|
-
printInfo("Refreshing Chutes model list with: opencode models --refresh --verbose");
|
|
16613
|
-
const discovery = await discoverProviderModels("chutes");
|
|
16614
|
-
if (discovery.models.length === 0) {
|
|
16615
|
-
printWarning(discovery.error ?? "No Chutes models found. Continuing without Chutes dynamic assignment.");
|
|
16616
|
-
} else {
|
|
16617
|
-
availableChutesModels = discovery.models;
|
|
16618
|
-
const recommendedPrimary = pickBestCodingChutesModel(discovery.models)?.model ?? discovery.models[0]?.model;
|
|
16619
|
-
if (recommendedPrimary) {
|
|
16620
|
-
console.log(`${BOLD}Chutes Models:${RESET}`);
|
|
16621
|
-
selectedChutesPrimaryModel = await askModelSelection(rl, discovery.models, recommendedPrimary, "Choose Chutes primary model for orchestrator/oracle/designer");
|
|
16622
|
-
}
|
|
16623
|
-
if (selectedChutesPrimaryModel) {
|
|
16624
|
-
const recommendedSecondary = pickSupportChutesModel(discovery.models, selectedChutesPrimaryModel)?.model ?? selectedChutesPrimaryModel;
|
|
16625
|
-
const chutesSupportList = discovery.models.filter((model) => model.model !== selectedChutesPrimaryModel);
|
|
16626
|
-
const chutesSupportDefault = recommendedSecondary === selectedChutesPrimaryModel ? chutesSupportList[0]?.model ?? recommendedSecondary : recommendedSecondary;
|
|
16627
|
-
selectedChutesSecondaryModel = await askModelSelection(rl, chutesSupportList, chutesSupportDefault, "Choose Chutes support model for explorer/librarian/fixer");
|
|
16628
|
-
}
|
|
16629
|
-
console.log();
|
|
16630
|
-
}
|
|
16631
|
-
}
|
|
16632
|
-
console.log(`${BOLD}Question 11/${totalQuestions}:${RESET}`);
|
|
16633
|
-
const balancedSpend = await askYesNo(rl, "Do you have subscriptions or pay per API? If yes, we will distribute assignments evenly across selected providers so your subscriptions last longer.", "no");
|
|
16634
|
-
console.log();
|
|
16635
|
-
let skills = "no";
|
|
16636
|
-
let customSkills = "no";
|
|
16637
|
-
if (!modelsOnly) {
|
|
16638
|
-
console.log(`${BOLD}Recommended Skills:${RESET}`);
|
|
16639
|
-
for (const skill of RECOMMENDED_SKILLS) {
|
|
16640
|
-
console.log(` ${SYMBOLS.bullet} ${BOLD}${skill.name}${RESET}: ${skill.description}`);
|
|
16641
|
-
}
|
|
16642
|
-
console.log();
|
|
16643
|
-
skills = await askYesNo(rl, "Install recommended skills?", "yes");
|
|
16644
|
-
console.log();
|
|
16645
|
-
console.log(`${BOLD}Custom Skills:${RESET}`);
|
|
16646
|
-
for (const skill of CUSTOM_SKILLS) {
|
|
16647
|
-
console.log(` ${SYMBOLS.bullet} ${BOLD}${skill.name}${RESET}: ${skill.description}`);
|
|
16648
|
-
}
|
|
16649
|
-
console.log();
|
|
16650
|
-
customSkills = await askYesNo(rl, "Install custom skills?", "yes");
|
|
16651
|
-
console.log();
|
|
16652
|
-
} else {
|
|
16653
|
-
printInfo("Models-only mode: skipping plugin/auth setup and skills prompts.");
|
|
16654
|
-
console.log();
|
|
16655
|
-
}
|
|
16656
|
-
return {
|
|
16657
|
-
hasKimi: kimi === "yes",
|
|
16658
|
-
hasOpenAI: openai === "yes",
|
|
16659
|
-
hasAnthropic: anthropic === "yes",
|
|
16660
|
-
hasCopilot: copilot === "yes",
|
|
16661
|
-
hasZaiPlan: zaiPlan === "yes",
|
|
16662
|
-
hasAntigravity: antigravity === "yes",
|
|
16663
|
-
hasChutes: chutes === "yes",
|
|
16664
|
-
hasOpencodeZen: true,
|
|
16665
|
-
useOpenCodeFreeModels: useOpenCodeFree === "yes" && selectedOpenCodePrimaryModel !== undefined,
|
|
16666
|
-
selectedOpenCodePrimaryModel,
|
|
16667
|
-
selectedOpenCodeSecondaryModel,
|
|
16668
|
-
availableOpenCodeFreeModels,
|
|
16669
|
-
selectedChutesPrimaryModel,
|
|
16670
|
-
selectedChutesSecondaryModel,
|
|
16671
|
-
availableChutesModels,
|
|
16672
|
-
artificialAnalysisApiKey,
|
|
16673
|
-
openRouterApiKey,
|
|
16674
|
-
balanceProviderUsage: balancedSpend === "yes",
|
|
16675
|
-
hasTmux: false,
|
|
16676
|
-
installSkills: skills === "yes",
|
|
16677
|
-
installCustomSkills: customSkills === "yes",
|
|
16678
|
-
setupMode: "quick",
|
|
16679
|
-
modelsOnly
|
|
16680
|
-
};
|
|
16681
|
-
} finally {
|
|
16682
|
-
rl.close();
|
|
16683
|
-
}
|
|
16684
|
-
}
|
|
16685
14552
|
async function runInstall(config2) {
|
|
16686
|
-
const resolvedConfig = {
|
|
16687
|
-
...config2
|
|
16688
|
-
};
|
|
16689
14553
|
const detected = detectCurrentConfig();
|
|
16690
14554
|
const isUpdate = detected.isInstalled;
|
|
16691
14555
|
printHeader(isUpdate);
|
|
16692
|
-
|
|
16693
|
-
|
|
16694
|
-
let totalSteps = modelsOnly ? 2 : 4;
|
|
16695
|
-
if (resolvedConfig.useOpenCodeFreeModels)
|
|
16696
|
-
totalSteps += 1;
|
|
16697
|
-
if (!modelsOnly && resolvedConfig.hasAntigravity)
|
|
16698
|
-
totalSteps += 2;
|
|
16699
|
-
if (!modelsOnly && resolvedConfig.hasChutes)
|
|
16700
|
-
totalSteps += 1;
|
|
16701
|
-
if (hasAnyEnabledProvider)
|
|
14556
|
+
let totalSteps = 4;
|
|
14557
|
+
if (config2.installSkills)
|
|
16702
14558
|
totalSteps += 1;
|
|
16703
|
-
if (
|
|
16704
|
-
totalSteps += 1;
|
|
16705
|
-
if (!modelsOnly && resolvedConfig.installCustomSkills)
|
|
14559
|
+
if (config2.installCustomSkills)
|
|
16706
14560
|
totalSteps += 1;
|
|
16707
14561
|
let step = 1;
|
|
16708
|
-
if (modelsOnly) {
|
|
16709
|
-
printInfo("Models-only mode: updating model assignments without reinstalling plugins/skills.");
|
|
16710
|
-
}
|
|
16711
14562
|
printStep(step++, totalSteps, "Checking OpenCode installation...");
|
|
16712
|
-
if (
|
|
14563
|
+
if (config2.dryRun) {
|
|
16713
14564
|
printInfo("Dry run mode - skipping OpenCode check");
|
|
16714
14565
|
} else {
|
|
16715
14566
|
const { ok } = await checkOpenCodeInstalled();
|
|
16716
14567
|
if (!ok)
|
|
16717
14568
|
return 1;
|
|
16718
14569
|
}
|
|
16719
|
-
|
|
16720
|
-
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
|
|
16724
|
-
|
|
16725
|
-
|
|
16726
|
-
resolvedConfig.availableOpenCodeFreeModels = discovery.models;
|
|
16727
|
-
const selectedPrimary = resolvedConfig.preferredOpenCodeModel && discovery.models.some((model) => model.model === resolvedConfig.preferredOpenCodeModel) ? resolvedConfig.preferredOpenCodeModel : resolvedConfig.selectedOpenCodePrimaryModel ?? pickBestCodingOpenCodeModel(discovery.models)?.model;
|
|
16728
|
-
resolvedConfig.selectedOpenCodePrimaryModel = selectedPrimary ?? discovery.models[0]?.model;
|
|
16729
|
-
resolvedConfig.selectedOpenCodeSecondaryModel = resolvedConfig.selectedOpenCodeSecondaryModel ?? pickSupportOpenCodeModel(discovery.models, resolvedConfig.selectedOpenCodePrimaryModel)?.model ?? resolvedConfig.selectedOpenCodePrimaryModel;
|
|
16730
|
-
printSuccess(`OpenCode free models ready (${discovery.models.length} models found)`);
|
|
16731
|
-
}
|
|
16732
|
-
} else if (resolvedConfig.useOpenCodeFreeModels && (resolvedConfig.availableOpenCodeFreeModels?.length ?? 0) > 0) {
|
|
16733
|
-
const availableModels = resolvedConfig.availableOpenCodeFreeModels ?? [];
|
|
16734
|
-
resolvedConfig.selectedOpenCodePrimaryModel = resolvedConfig.selectedOpenCodePrimaryModel ?? pickBestCodingOpenCodeModel(availableModels)?.model;
|
|
16735
|
-
resolvedConfig.selectedOpenCodeSecondaryModel = resolvedConfig.selectedOpenCodeSecondaryModel ?? pickSupportOpenCodeModel(availableModels, resolvedConfig.selectedOpenCodePrimaryModel)?.model ?? resolvedConfig.selectedOpenCodePrimaryModel;
|
|
16736
|
-
printStep(step++, totalSteps, "Using previously refreshed OpenCode free model list...");
|
|
16737
|
-
printSuccess(`OpenCode free models ready (${availableModels.length} models found)`);
|
|
16738
|
-
}
|
|
16739
|
-
if (resolvedConfig.hasChutes && (resolvedConfig.availableChutesModels?.length ?? 0) === 0) {
|
|
16740
|
-
printStep(step++, totalSteps, "Refreshing Chutes models (chutes/*)...");
|
|
16741
|
-
const discovery = await discoverProviderModels("chutes");
|
|
16742
|
-
if (discovery.models.length === 0) {
|
|
16743
|
-
printWarning(discovery.error ?? "No Chutes models found. Continuing with fallback Chutes mapping.");
|
|
16744
|
-
} else {
|
|
16745
|
-
resolvedConfig.availableChutesModels = discovery.models;
|
|
16746
|
-
resolvedConfig.selectedChutesPrimaryModel = resolvedConfig.selectedChutesPrimaryModel ?? pickBestCodingChutesModel(discovery.models)?.model ?? discovery.models[0]?.model;
|
|
16747
|
-
resolvedConfig.selectedChutesSecondaryModel = resolvedConfig.selectedChutesSecondaryModel ?? pickSupportChutesModel(discovery.models, resolvedConfig.selectedChutesPrimaryModel)?.model ?? resolvedConfig.selectedChutesPrimaryModel;
|
|
16748
|
-
printSuccess(`Chutes models ready (${discovery.models.length} models found)`);
|
|
16749
|
-
}
|
|
16750
|
-
} else if (resolvedConfig.hasChutes && (resolvedConfig.availableChutesModels?.length ?? 0) > 0) {
|
|
16751
|
-
const availableChutes = resolvedConfig.availableChutesModels ?? [];
|
|
16752
|
-
resolvedConfig.selectedChutesPrimaryModel = resolvedConfig.selectedChutesPrimaryModel ?? pickBestCodingChutesModel(availableChutes)?.model;
|
|
16753
|
-
resolvedConfig.selectedChutesSecondaryModel = resolvedConfig.selectedChutesSecondaryModel ?? pickSupportChutesModel(availableChutes, resolvedConfig.selectedChutesPrimaryModel)?.model ?? resolvedConfig.selectedChutesPrimaryModel;
|
|
16754
|
-
printStep(step++, totalSteps, "Using previously refreshed Chutes model list...");
|
|
16755
|
-
printSuccess(`Chutes models ready (${availableChutes.length} models found)`);
|
|
16756
|
-
}
|
|
16757
|
-
if (!modelsOnly) {
|
|
16758
|
-
printStep(step++, totalSteps, "Adding oh-my-opencode-medium plugin...");
|
|
16759
|
-
if (resolvedConfig.dryRun) {
|
|
16760
|
-
printInfo("Dry run mode - skipping plugin installation");
|
|
16761
|
-
} else {
|
|
16762
|
-
const pluginResult = await addPluginToOpenCodeConfig();
|
|
16763
|
-
if (!handleStepResult(pluginResult, "Plugin added"))
|
|
16764
|
-
return 1;
|
|
16765
|
-
}
|
|
16766
|
-
}
|
|
16767
|
-
if (!modelsOnly && resolvedConfig.hasAntigravity) {
|
|
16768
|
-
printStep(step++, totalSteps, "Adding Antigravity plugin...");
|
|
16769
|
-
if (resolvedConfig.dryRun) {
|
|
16770
|
-
printInfo("Dry run mode - skipping Antigravity plugin");
|
|
16771
|
-
} else {
|
|
16772
|
-
const antigravityPluginResult = addAntigravityPlugin();
|
|
16773
|
-
if (!handleStepResult(antigravityPluginResult, "Antigravity plugin added"))
|
|
16774
|
-
return 1;
|
|
16775
|
-
}
|
|
16776
|
-
printStep(step++, totalSteps, "Configuring Google Provider...");
|
|
16777
|
-
if (resolvedConfig.dryRun) {
|
|
16778
|
-
printInfo("Dry run mode - skipping Google Provider setup");
|
|
16779
|
-
} else {
|
|
16780
|
-
const googleProviderResult = addGoogleProvider();
|
|
16781
|
-
if (!handleStepResult(googleProviderResult, "Google Provider configured"))
|
|
16782
|
-
return 1;
|
|
16783
|
-
}
|
|
16784
|
-
}
|
|
16785
|
-
if (!modelsOnly && resolvedConfig.hasChutes) {
|
|
16786
|
-
printStep(step++, totalSteps, "Enabling Chutes auth flow...");
|
|
16787
|
-
if (resolvedConfig.dryRun) {
|
|
16788
|
-
printInfo("Dry run mode - skipping Chutes auth flow");
|
|
16789
|
-
} else {
|
|
16790
|
-
const chutesProviderResult = addChutesProvider();
|
|
16791
|
-
if (!handleStepResult(chutesProviderResult, "Chutes auth flow ready"))
|
|
16792
|
-
return 1;
|
|
16793
|
-
}
|
|
16794
|
-
}
|
|
16795
|
-
if (hasAnyEnabledProvider) {
|
|
16796
|
-
printStep(step++, totalSteps, "Resolving dynamic model assignments...");
|
|
16797
|
-
const catalogDiscovery = await discoverModelCatalog();
|
|
16798
|
-
if (catalogDiscovery.models.length === 0) {
|
|
16799
|
-
printWarning(catalogDiscovery.error ?? "Unable to discover model catalog. Falling back to static mappings.");
|
|
16800
|
-
} else {
|
|
16801
|
-
const { signals, warnings } = await fetchExternalModelSignals({
|
|
16802
|
-
artificialAnalysisApiKey: resolvedConfig.artificialAnalysisApiKey,
|
|
16803
|
-
openRouterApiKey: resolvedConfig.openRouterApiKey
|
|
16804
|
-
});
|
|
16805
|
-
for (const warning of warnings) {
|
|
16806
|
-
printInfo(warning);
|
|
16807
|
-
}
|
|
16808
|
-
const dynamicPlan = buildDynamicModelPlan(catalogDiscovery.models, resolvedConfig, signals);
|
|
16809
|
-
if (!dynamicPlan) {
|
|
16810
|
-
printWarning("Dynamic planner found no suitable models. Using static mappings.");
|
|
16811
|
-
} else {
|
|
16812
|
-
resolvedConfig.dynamicModelPlan = dynamicPlan;
|
|
16813
|
-
printSuccess(`Dynamic assignments ready (${Object.keys(dynamicPlan.agents).length} agents)`);
|
|
16814
|
-
}
|
|
16815
|
-
}
|
|
14570
|
+
printStep(step++, totalSteps, "Adding oh-my-opencode-medium plugin...");
|
|
14571
|
+
if (config2.dryRun) {
|
|
14572
|
+
printInfo("Dry run mode - skipping plugin installation");
|
|
14573
|
+
} else {
|
|
14574
|
+
const pluginResult = await addPluginToOpenCodeConfig();
|
|
14575
|
+
if (!handleStepResult(pluginResult, "Plugin added"))
|
|
14576
|
+
return 1;
|
|
16816
14577
|
}
|
|
16817
|
-
|
|
16818
|
-
|
|
16819
|
-
|
|
16820
|
-
|
|
16821
|
-
|
|
16822
|
-
|
|
16823
|
-
|
|
16824
|
-
return 1;
|
|
16825
|
-
}
|
|
14578
|
+
printStep(step++, totalSteps, "Disabling OpenCode default agents...");
|
|
14579
|
+
if (config2.dryRun) {
|
|
14580
|
+
printInfo("Dry run mode - skipping agent disabling");
|
|
14581
|
+
} else {
|
|
14582
|
+
const agentResult = disableDefaultAgents();
|
|
14583
|
+
if (!handleStepResult(agentResult, "Default agents disabled"))
|
|
14584
|
+
return 1;
|
|
16826
14585
|
}
|
|
16827
14586
|
printStep(step++, totalSteps, "Writing oh-my-opencode-medium configuration...");
|
|
16828
|
-
if (
|
|
16829
|
-
const liteConfig = generateLiteConfig(
|
|
14587
|
+
if (config2.dryRun) {
|
|
14588
|
+
const liteConfig = generateLiteConfig(config2);
|
|
16830
14589
|
printInfo("Dry run mode - configuration that would be written:");
|
|
16831
14590
|
console.log(`
|
|
16832
14591
|
${JSON.stringify(liteConfig, null, 2)}
|
|
16833
14592
|
`);
|
|
16834
14593
|
} else {
|
|
16835
|
-
const liteResult = writeLiteConfig(
|
|
14594
|
+
const liteResult = writeLiteConfig(config2);
|
|
16836
14595
|
if (!handleStepResult(liteResult, "Config written"))
|
|
16837
14596
|
return 1;
|
|
16838
14597
|
}
|
|
16839
|
-
if (
|
|
14598
|
+
if (config2.installSkills) {
|
|
16840
14599
|
printStep(step++, totalSteps, "Installing recommended skills...");
|
|
16841
|
-
if (
|
|
14600
|
+
if (config2.dryRun) {
|
|
16842
14601
|
printInfo("Dry run mode - would install skills:");
|
|
16843
14602
|
for (const skill of RECOMMENDED_SKILLS) {
|
|
16844
14603
|
printInfo(` - ${skill.name}`);
|
|
@@ -16851,15 +14610,15 @@ ${JSON.stringify(liteConfig, null, 2)}
|
|
|
16851
14610
|
printSuccess(`Installed: ${skill.name}`);
|
|
16852
14611
|
skillsInstalled++;
|
|
16853
14612
|
} else {
|
|
16854
|
-
|
|
14613
|
+
printInfo(`Skipped: ${skill.name} (already installed)`);
|
|
16855
14614
|
}
|
|
16856
14615
|
}
|
|
16857
|
-
printSuccess(`${skillsInstalled}/${RECOMMENDED_SKILLS.length} skills
|
|
14616
|
+
printSuccess(`${skillsInstalled}/${RECOMMENDED_SKILLS.length} skills processed`);
|
|
16858
14617
|
}
|
|
16859
14618
|
}
|
|
16860
|
-
if (
|
|
14619
|
+
if (config2.installCustomSkills) {
|
|
16861
14620
|
printStep(step++, totalSteps, "Installing custom skills...");
|
|
16862
|
-
if (
|
|
14621
|
+
if (config2.dryRun) {
|
|
16863
14622
|
printInfo("Dry run mode - would install custom skills:");
|
|
16864
14623
|
for (const skill of CUSTOM_SKILLS) {
|
|
16865
14624
|
printInfo(` - ${skill.name}`);
|
|
@@ -16872,103 +14631,44 @@ ${JSON.stringify(liteConfig, null, 2)}
|
|
|
16872
14631
|
printSuccess(`Installed: ${skill.name}`);
|
|
16873
14632
|
customSkillsInstalled++;
|
|
16874
14633
|
} else {
|
|
16875
|
-
|
|
14634
|
+
printInfo(`Skipped: ${skill.name} (already installed)`);
|
|
16876
14635
|
}
|
|
16877
14636
|
}
|
|
16878
|
-
printSuccess(`${customSkillsInstalled}/${CUSTOM_SKILLS.length} custom skills
|
|
14637
|
+
printSuccess(`${customSkillsInstalled}/${CUSTOM_SKILLS.length} custom skills processed`);
|
|
16879
14638
|
}
|
|
16880
14639
|
}
|
|
16881
14640
|
console.log();
|
|
16882
|
-
console.log(formatConfigSummary(
|
|
14641
|
+
console.log(formatConfigSummary());
|
|
16883
14642
|
console.log();
|
|
16884
|
-
printAgentModels(resolvedConfig);
|
|
16885
|
-
if (!resolvedConfig.hasKimi && !resolvedConfig.hasOpenAI && !resolvedConfig.hasAnthropic && !resolvedConfig.hasCopilot && !resolvedConfig.hasZaiPlan && !resolvedConfig.hasAntigravity && !resolvedConfig.hasChutes) {
|
|
16886
|
-
printWarning("No providers configured. Zen Big Pickle models will be used as fallback.");
|
|
16887
|
-
}
|
|
16888
14643
|
console.log(`${SYMBOLS.star} ${BOLD}${GREEN}${isUpdate ? "Configuration updated!" : "Installation complete!"}${RESET}`);
|
|
16889
14644
|
console.log();
|
|
16890
14645
|
console.log(`${BOLD}Next steps:${RESET}`);
|
|
16891
14646
|
console.log();
|
|
16892
|
-
|
|
16893
|
-
if (resolvedConfig.hasKimi || resolvedConfig.hasOpenAI || resolvedConfig.hasAnthropic || resolvedConfig.hasCopilot || resolvedConfig.hasZaiPlan || resolvedConfig.hasAntigravity || resolvedConfig.hasChutes) {
|
|
16894
|
-
console.log(` ${nextStep++}. Authenticate with your providers:`);
|
|
16895
|
-
console.log(` ${BLUE}$ opencode auth login${RESET}`);
|
|
16896
|
-
if (resolvedConfig.hasKimi) {
|
|
16897
|
-
console.log();
|
|
16898
|
-
console.log(` Then select ${BOLD}Kimi For Coding${RESET} provider.`);
|
|
16899
|
-
}
|
|
16900
|
-
if (resolvedConfig.hasAntigravity) {
|
|
16901
|
-
console.log();
|
|
16902
|
-
console.log(` Then select ${BOLD}google${RESET} provider.`);
|
|
16903
|
-
}
|
|
16904
|
-
if (resolvedConfig.hasAnthropic) {
|
|
16905
|
-
console.log();
|
|
16906
|
-
console.log(` Then select ${BOLD}anthropic${RESET} provider.`);
|
|
16907
|
-
}
|
|
16908
|
-
if (resolvedConfig.hasCopilot) {
|
|
16909
|
-
console.log();
|
|
16910
|
-
console.log(` Then select ${BOLD}github-copilot${RESET} provider.`);
|
|
16911
|
-
}
|
|
16912
|
-
if (resolvedConfig.hasZaiPlan) {
|
|
16913
|
-
console.log();
|
|
16914
|
-
console.log(` Then select ${BOLD}zai-coding-plan${RESET} provider.`);
|
|
16915
|
-
}
|
|
16916
|
-
if (resolvedConfig.hasChutes) {
|
|
16917
|
-
console.log();
|
|
16918
|
-
console.log(` Then select ${BOLD}chutes${RESET} provider.`);
|
|
16919
|
-
}
|
|
16920
|
-
console.log();
|
|
16921
|
-
}
|
|
16922
|
-
console.log(` ${nextStep++}. Start OpenCode:`);
|
|
14647
|
+
console.log(` 1. Start OpenCode:`);
|
|
16923
14648
|
console.log(` ${BLUE}$ opencode${RESET}`);
|
|
16924
14649
|
console.log();
|
|
14650
|
+
console.log(`${BOLD}Default configuration uses OpenAI models (gpt-5.4 / gpt-5-codex).${RESET}`);
|
|
14651
|
+
console.log(`${BOLD}For alternative providers (Kimi, GitHub Copilot, ZAI Coding Plan), see:${RESET}`);
|
|
14652
|
+
console.log(` ${BLUE}https://github.com/SamWang32191/oh-my-opencode-medium/blob/main/docs/provider-configurations.md${RESET}`);
|
|
14653
|
+
console.log();
|
|
16925
14654
|
return 0;
|
|
16926
14655
|
}
|
|
16927
14656
|
async function install(args) {
|
|
16928
|
-
|
|
16929
|
-
|
|
16930
|
-
|
|
16931
|
-
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
if (errors3.length > 0) {
|
|
16944
|
-
printHeader(false);
|
|
16945
|
-
printError("Missing or invalid arguments:");
|
|
16946
|
-
for (const key of errors3) {
|
|
16947
|
-
const flagName = key === "zaiPlan" ? "zai-plan" : key;
|
|
16948
|
-
console.log(` ${SYMBOLS.bullet} --${flagName}=<yes|no>`);
|
|
16949
|
-
}
|
|
16950
|
-
console.log();
|
|
16951
|
-
printInfo("Usage: bunx oh-my-opencode-medium install --no-tui --kimi=<yes|no> --openai=<yes|no> --anthropic=<yes|no> --copilot=<yes|no> --zai-plan=<yes|no> --antigravity=<yes|no> --chutes=<yes|no> --balanced-spend=<yes|no> --tmux=<yes|no>");
|
|
16952
|
-
console.log();
|
|
16953
|
-
return 1;
|
|
16954
|
-
}
|
|
16955
|
-
const nonInteractiveConfig = argsToConfig(args);
|
|
16956
|
-
return runInstall(nonInteractiveConfig);
|
|
16957
|
-
}
|
|
16958
|
-
const detected = detectCurrentConfig();
|
|
16959
|
-
printHeader(detected.isInstalled);
|
|
16960
|
-
printStep(1, 1, "Checking OpenCode installation...");
|
|
16961
|
-
if (args.dryRun) {
|
|
16962
|
-
printInfo("Dry run mode - skipping OpenCode check");
|
|
16963
|
-
} else {
|
|
16964
|
-
const { ok } = await checkOpenCodeInstalled();
|
|
16965
|
-
if (!ok)
|
|
16966
|
-
return 1;
|
|
16967
|
-
}
|
|
16968
|
-
console.log();
|
|
16969
|
-
const config2 = await runInteractiveMode(detected, args.modelsOnly === true);
|
|
16970
|
-
config2.dryRun = args.dryRun;
|
|
16971
|
-
config2.modelsOnly = args.modelsOnly;
|
|
14657
|
+
const config2 = {
|
|
14658
|
+
hasKimi: false,
|
|
14659
|
+
hasOpenAI: true,
|
|
14660
|
+
hasAnthropic: false,
|
|
14661
|
+
hasCopilot: false,
|
|
14662
|
+
hasZaiPlan: false,
|
|
14663
|
+
hasAntigravity: false,
|
|
14664
|
+
hasChutes: false,
|
|
14665
|
+
hasOpencodeZen: false,
|
|
14666
|
+
hasTmux: args.tmux === "yes",
|
|
14667
|
+
installSkills: args.skills === "yes",
|
|
14668
|
+
installCustomSkills: args.skills === "yes",
|
|
14669
|
+
setupMode: "quick",
|
|
14670
|
+
dryRun: args.dryRun
|
|
14671
|
+
};
|
|
16972
14672
|
return runInstall(config2);
|
|
16973
14673
|
}
|
|
16974
14674
|
|
|
@@ -16980,38 +14680,12 @@ function parseArgs(args) {
|
|
|
16980
14680
|
for (const arg of args) {
|
|
16981
14681
|
if (arg === "--no-tui") {
|
|
16982
14682
|
result.tui = false;
|
|
16983
|
-
} else if (arg.startsWith("--kimi=")) {
|
|
16984
|
-
result.kimi = arg.split("=")[1];
|
|
16985
|
-
} else if (arg.startsWith("--openai=")) {
|
|
16986
|
-
result.openai = arg.split("=")[1];
|
|
16987
|
-
} else if (arg.startsWith("--anthropic=")) {
|
|
16988
|
-
result.anthropic = arg.split("=")[1];
|
|
16989
|
-
} else if (arg.startsWith("--copilot=")) {
|
|
16990
|
-
result.copilot = arg.split("=")[1];
|
|
16991
|
-
} else if (arg.startsWith("--zai-plan=")) {
|
|
16992
|
-
result.zaiPlan = arg.split("=")[1];
|
|
16993
|
-
} else if (arg.startsWith("--antigravity=")) {
|
|
16994
|
-
result.antigravity = arg.split("=")[1];
|
|
16995
|
-
} else if (arg.startsWith("--chutes=")) {
|
|
16996
|
-
result.chutes = arg.split("=")[1];
|
|
16997
14683
|
} else if (arg.startsWith("--tmux=")) {
|
|
16998
14684
|
result.tmux = arg.split("=")[1];
|
|
16999
14685
|
} else if (arg.startsWith("--skills=")) {
|
|
17000
14686
|
result.skills = arg.split("=")[1];
|
|
17001
|
-
} else if (arg.startsWith("--opencode-free=")) {
|
|
17002
|
-
result.opencodeFree = arg.split("=")[1];
|
|
17003
|
-
} else if (arg.startsWith("--balanced-spend=")) {
|
|
17004
|
-
result.balancedSpend = arg.split("=")[1];
|
|
17005
|
-
} else if (arg.startsWith("--opencode-free-model=")) {
|
|
17006
|
-
result.opencodeFreeModel = arg.split("=")[1];
|
|
17007
|
-
} else if (arg.startsWith("--aa-key=")) {
|
|
17008
|
-
result.aaKey = arg.slice("--aa-key=".length);
|
|
17009
|
-
} else if (arg.startsWith("--openrouter-key=")) {
|
|
17010
|
-
result.openrouterKey = arg.slice("--openrouter-key=".length);
|
|
17011
14687
|
} else if (arg === "--dry-run") {
|
|
17012
14688
|
result.dryRun = true;
|
|
17013
|
-
} else if (arg === "--models-only") {
|
|
17014
|
-
result.modelsOnly = true;
|
|
17015
14689
|
} else if (arg === "-h" || arg === "--help") {
|
|
17016
14690
|
printHelp();
|
|
17017
14691
|
process.exit(0);
|
|
@@ -17024,42 +14698,27 @@ function printHelp() {
|
|
|
17024
14698
|
oh-my-opencode-medium installer
|
|
17025
14699
|
|
|
17026
14700
|
Usage: bunx oh-my-opencode-medium install [OPTIONS]
|
|
17027
|
-
bunx oh-my-opencode-medium models [OPTIONS]
|
|
17028
14701
|
|
|
17029
14702
|
Options:
|
|
17030
|
-
--kimi=yes|no Kimi API access (yes/no)
|
|
17031
|
-
--openai=yes|no OpenAI API access (yes/no)
|
|
17032
|
-
--anthropic=yes|no Anthropic access (yes/no)
|
|
17033
|
-
--copilot=yes|no GitHub Copilot access (yes/no)
|
|
17034
|
-
--zai-plan=yes|no ZAI Coding Plan access (yes/no)
|
|
17035
|
-
--antigravity=yes|no Antigravity/Google models (yes/no)
|
|
17036
|
-
--chutes=yes|no Chutes models (yes/no)
|
|
17037
|
-
--opencode-free=yes|no Use OpenCode free models (opencode/*)
|
|
17038
|
-
--balanced-spend=yes|no Evenly spread usage across selected providers when score gaps are within tolerance
|
|
17039
|
-
--opencode-free-model Preferred OpenCode model id or "auto"
|
|
17040
|
-
--aa-key Artificial Analysis API key (optional)
|
|
17041
|
-
--openrouter-key OpenRouter API key (optional)
|
|
17042
14703
|
--tmux=yes|no Enable tmux integration (yes/no)
|
|
17043
14704
|
--skills=yes|no Install recommended skills (yes/no)
|
|
17044
|
-
--no-tui Non-interactive mode
|
|
17045
|
-
--dry-run Simulate install without writing files
|
|
17046
|
-
--models-only Update model assignments only (skip plugin/auth/skills)
|
|
14705
|
+
--no-tui Non-interactive mode
|
|
14706
|
+
--dry-run Simulate install without writing files
|
|
17047
14707
|
-h, --help Show this help message
|
|
17048
14708
|
|
|
14709
|
+
The installer generates an OpenAI configuration by default.
|
|
14710
|
+
For alternative providers, see docs/provider-configurations.md.
|
|
14711
|
+
|
|
17049
14712
|
Examples:
|
|
17050
14713
|
bunx oh-my-opencode-medium install
|
|
17051
|
-
bunx oh-my-opencode-medium
|
|
17052
|
-
bunx oh-my-opencode-medium install --no-tui --kimi=yes --openai=yes --anthropic=yes --copilot=no --zai-plan=no --antigravity=yes --chutes=no --opencode-free=yes --balanced-spend=yes --opencode-free-model=auto --aa-key=YOUR_AA_KEY --openrouter-key=YOUR_OR_KEY --tmux=no --skills=yes
|
|
14714
|
+
bunx oh-my-opencode-medium install --no-tui --tmux=no --skills=yes
|
|
17053
14715
|
`);
|
|
17054
14716
|
}
|
|
17055
14717
|
async function main() {
|
|
17056
14718
|
const args = process.argv.slice(2);
|
|
17057
|
-
if (args.length === 0 || args[0] === "install"
|
|
17058
|
-
const hasSubcommand = args[0] === "install"
|
|
14719
|
+
if (args.length === 0 || args[0] === "install") {
|
|
14720
|
+
const hasSubcommand = args[0] === "install";
|
|
17059
14721
|
const installArgs = parseArgs(args.slice(hasSubcommand ? 1 : 0));
|
|
17060
|
-
if (args[0] === "models") {
|
|
17061
|
-
installArgs.modelsOnly = true;
|
|
17062
|
-
}
|
|
17063
14722
|
const exitCode = await install(installArgs);
|
|
17064
14723
|
process.exit(exitCode);
|
|
17065
14724
|
} else if (args[0] === "-h" || args[0] === "--help") {
|