free-coding-models 0.1.49 → 0.1.51
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/bin/free-coding-models.js +272 -132
- package/package.json +1 -1
|
@@ -810,88 +810,87 @@ function checkNvidiaNimConfig() {
|
|
|
810
810
|
}
|
|
811
811
|
|
|
812
812
|
// ─── Start OpenCode ────────────────────────────────────────────────────────────
|
|
813
|
-
// 📖 Launches OpenCode with the selected
|
|
814
|
-
// 📖
|
|
815
|
-
// 📖
|
|
813
|
+
// 📖 Launches OpenCode with the selected model.
|
|
814
|
+
// 📖 Handles all 3 providers: nvidia (needs custom provider config), groq & cerebras (built-in in OpenCode).
|
|
815
|
+
// 📖 For nvidia: checks if NIM is configured, sets provider.models entry, spawns with nvidia/model-id.
|
|
816
|
+
// 📖 For groq/cerebras: OpenCode has built-in support — just sets model in config and spawns.
|
|
817
|
+
// 📖 Model format: { modelId, label, tier, providerKey }
|
|
816
818
|
async function startOpenCode(model) {
|
|
817
|
-
const
|
|
819
|
+
const providerKey = model.providerKey ?? 'nvidia'
|
|
820
|
+
// 📖 Full model reference string used in OpenCode config and --model flag
|
|
821
|
+
const modelRef = `${providerKey}/${model.modelId}`
|
|
818
822
|
|
|
819
|
-
if (
|
|
820
|
-
// 📖 NVIDIA NIM
|
|
821
|
-
|
|
822
|
-
console.log(chalk.dim(` Model: nvidia/${model.modelId}`))
|
|
823
|
-
console.log()
|
|
823
|
+
if (providerKey === 'nvidia') {
|
|
824
|
+
// 📖 NVIDIA NIM needs a custom provider block in OpenCode config (not built-in)
|
|
825
|
+
const hasNim = checkNvidiaNimConfig()
|
|
824
826
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
+
if (hasNim) {
|
|
828
|
+
console.log(chalk.green(` 🚀 Setting ${chalk.bold(model.label)} as default…`))
|
|
829
|
+
console.log(chalk.dim(` Model: ${modelRef}`))
|
|
830
|
+
console.log()
|
|
827
831
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
831
|
-
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
832
|
-
}
|
|
832
|
+
const config = loadOpenCodeConfig()
|
|
833
|
+
const backupPath = `${getOpenCodeConfigPath()}.backup-${Date.now()}`
|
|
833
834
|
|
|
834
|
-
|
|
835
|
-
|
|
835
|
+
if (existsSync(getOpenCodeConfigPath())) {
|
|
836
|
+
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
837
|
+
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
config.model = modelRef
|
|
836
841
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
name: model.label,
|
|
842
|
+
// 📖 Register the model in the nvidia provider's models section
|
|
843
|
+
// 📖 OpenCode requires models to be explicitly listed in provider.models
|
|
844
|
+
// 📖 to recognize them — without this, it falls back to the previous default
|
|
845
|
+
if (config.provider?.nvidia) {
|
|
846
|
+
if (!config.provider.nvidia.models) config.provider.nvidia.models = {}
|
|
847
|
+
config.provider.nvidia.models[model.modelId] = { name: model.label }
|
|
844
848
|
}
|
|
845
|
-
}
|
|
846
849
|
|
|
847
|
-
|
|
850
|
+
saveOpenCodeConfig(config)
|
|
848
851
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
console.log()
|
|
854
|
-
|
|
855
|
-
if (savedConfig.model === config.model) {
|
|
856
|
-
console.log(chalk.green(` ✓ Default model set to: nvidia/${model.modelId}`))
|
|
857
|
-
} else {
|
|
858
|
-
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
859
|
-
}
|
|
860
|
-
console.log()
|
|
861
|
-
console.log(chalk.dim(' Starting OpenCode…'))
|
|
862
|
-
console.log()
|
|
852
|
+
const savedConfig = loadOpenCodeConfig()
|
|
853
|
+
console.log(chalk.dim(` 📝 Config saved to: ${getOpenCodeConfigPath()}`))
|
|
854
|
+
console.log(chalk.dim(` 📝 Default model in config: ${savedConfig.model || 'NOT SET'}`))
|
|
855
|
+
console.log()
|
|
863
856
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
857
|
+
if (savedConfig.model === config.model) {
|
|
858
|
+
console.log(chalk.green(` ✓ Default model set to: ${modelRef}`))
|
|
859
|
+
} else {
|
|
860
|
+
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
861
|
+
}
|
|
862
|
+
console.log()
|
|
863
|
+
console.log(chalk.dim(' Starting OpenCode…'))
|
|
864
|
+
console.log()
|
|
872
865
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
console.error(chalk.red('\n ✗ Could not find "opencode" — is it installed and in your PATH?'))
|
|
879
|
-
console.error(chalk.dim(' Install: npm i -g opencode or see https://opencode.ai'))
|
|
880
|
-
resolve(1)
|
|
881
|
-
} else {
|
|
882
|
-
reject(err)
|
|
883
|
-
}
|
|
866
|
+
const { spawn } = await import('child_process')
|
|
867
|
+
const child = spawn('opencode', ['--model', modelRef], {
|
|
868
|
+
stdio: 'inherit',
|
|
869
|
+
shell: true,
|
|
870
|
+
detached: false
|
|
884
871
|
})
|
|
885
|
-
})
|
|
886
|
-
} else {
|
|
887
|
-
// 📖 NVIDIA NIM not configured - show install prompt and launch
|
|
888
|
-
console.log(chalk.yellow(' ⚠ NVIDIA NIM not configured in OpenCode'))
|
|
889
|
-
console.log()
|
|
890
|
-
console.log(chalk.dim(' Starting OpenCode with installation prompt…'))
|
|
891
|
-
console.log()
|
|
892
872
|
|
|
893
|
-
|
|
894
|
-
|
|
873
|
+
await new Promise((resolve, reject) => {
|
|
874
|
+
child.on('exit', resolve)
|
|
875
|
+
child.on('error', (err) => {
|
|
876
|
+
if (err.code === 'ENOENT') {
|
|
877
|
+
console.error(chalk.red('\n ✗ Could not find "opencode" — is it installed and in your PATH?'))
|
|
878
|
+
console.error(chalk.dim(' Install: npm i -g opencode or see https://opencode.ai'))
|
|
879
|
+
resolve(1)
|
|
880
|
+
} else {
|
|
881
|
+
reject(err)
|
|
882
|
+
}
|
|
883
|
+
})
|
|
884
|
+
})
|
|
885
|
+
} else {
|
|
886
|
+
// 📖 NVIDIA NIM not configured — show install prompt
|
|
887
|
+
console.log(chalk.yellow(' ⚠ NVIDIA NIM not configured in OpenCode'))
|
|
888
|
+
console.log()
|
|
889
|
+
console.log(chalk.dim(' Starting OpenCode with installation prompt…'))
|
|
890
|
+
console.log()
|
|
891
|
+
|
|
892
|
+
const configPath = getOpenCodeConfigPath()
|
|
893
|
+
const installPrompt = `Please install NVIDIA NIM provider in OpenCode by adding this to ${configPath}:
|
|
895
894
|
|
|
896
895
|
{
|
|
897
896
|
"provider": {
|
|
@@ -908,21 +907,101 @@ async function startOpenCode(model) {
|
|
|
908
907
|
|
|
909
908
|
${isWindows ? 'set NVIDIA_API_KEY=your_key_here' : 'export NVIDIA_API_KEY=your_key_here'}
|
|
910
909
|
|
|
911
|
-
After installation, you can use: opencode --model
|
|
910
|
+
After installation, you can use: opencode --model ${modelRef}`
|
|
911
|
+
|
|
912
|
+
console.log(chalk.cyan(installPrompt))
|
|
913
|
+
console.log()
|
|
914
|
+
console.log(chalk.dim(' Starting OpenCode…'))
|
|
915
|
+
console.log()
|
|
916
|
+
|
|
917
|
+
const { spawn } = await import('child_process')
|
|
918
|
+
const child = spawn('opencode', [], {
|
|
919
|
+
stdio: 'inherit',
|
|
920
|
+
shell: true,
|
|
921
|
+
detached: false
|
|
922
|
+
})
|
|
923
|
+
|
|
924
|
+
await new Promise((resolve, reject) => {
|
|
925
|
+
child.on('exit', resolve)
|
|
926
|
+
child.on('error', (err) => {
|
|
927
|
+
if (err.code === 'ENOENT') {
|
|
928
|
+
console.error(chalk.red('\n ✗ Could not find "opencode" — is it installed and in your PATH?'))
|
|
929
|
+
console.error(chalk.dim(' Install: npm i -g opencode or see https://opencode.ai'))
|
|
930
|
+
resolve(1)
|
|
931
|
+
} else {
|
|
932
|
+
reject(err)
|
|
933
|
+
}
|
|
934
|
+
})
|
|
935
|
+
})
|
|
936
|
+
}
|
|
937
|
+
} else {
|
|
938
|
+
// 📖 Groq: built-in OpenCode provider — needs provider block with apiKey in opencode.json.
|
|
939
|
+
// 📖 Cerebras: NOT built-in — needs @ai-sdk/openai-compatible + baseURL, like NVIDIA.
|
|
940
|
+
// 📖 Both need the model registered in provider.<key>.models so OpenCode can find it.
|
|
941
|
+
console.log(chalk.green(` 🚀 Setting ${chalk.bold(model.label)} as default…`))
|
|
942
|
+
console.log(chalk.dim(` Model: ${modelRef}`))
|
|
943
|
+
console.log()
|
|
944
|
+
|
|
945
|
+
const config = loadOpenCodeConfig()
|
|
946
|
+
const backupPath = `${getOpenCodeConfigPath()}.backup-${Date.now()}`
|
|
947
|
+
|
|
948
|
+
if (existsSync(getOpenCodeConfigPath())) {
|
|
949
|
+
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
950
|
+
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
// 📖 Ensure the provider block exists in config — create it if missing
|
|
954
|
+
if (!config.provider) config.provider = {}
|
|
955
|
+
if (!config.provider[providerKey]) {
|
|
956
|
+
if (providerKey === 'groq') {
|
|
957
|
+
// 📖 Groq is a built-in OpenCode provider — just needs apiKey options, no npm package
|
|
958
|
+
config.provider.groq = {
|
|
959
|
+
options: { apiKey: '{env:GROQ_API_KEY}' },
|
|
960
|
+
models: {}
|
|
961
|
+
}
|
|
962
|
+
} else if (providerKey === 'cerebras') {
|
|
963
|
+
// 📖 Cerebras is OpenAI-compatible — needs npm package and baseURL like NVIDIA
|
|
964
|
+
config.provider.cerebras = {
|
|
965
|
+
npm: '@ai-sdk/openai-compatible',
|
|
966
|
+
name: 'Cerebras',
|
|
967
|
+
options: {
|
|
968
|
+
baseURL: 'https://api.cerebras.ai/v1',
|
|
969
|
+
apiKey: '{env:CEREBRAS_API_KEY}'
|
|
970
|
+
},
|
|
971
|
+
models: {}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
912
975
|
|
|
913
|
-
|
|
976
|
+
// 📖 Register the model in the provider's models section
|
|
977
|
+
// 📖 OpenCode requires models to be explicitly listed to recognize them
|
|
978
|
+
if (!config.provider[providerKey].models) config.provider[providerKey].models = {}
|
|
979
|
+
config.provider[providerKey].models[model.modelId] = { name: model.label }
|
|
980
|
+
|
|
981
|
+
config.model = modelRef
|
|
982
|
+
saveOpenCodeConfig(config)
|
|
983
|
+
|
|
984
|
+
const savedConfig = loadOpenCodeConfig()
|
|
985
|
+
console.log(chalk.dim(` 📝 Config saved to: ${getOpenCodeConfigPath()}`))
|
|
986
|
+
console.log(chalk.dim(` 📝 Default model in config: ${savedConfig.model || 'NOT SET'}`))
|
|
987
|
+
console.log()
|
|
988
|
+
|
|
989
|
+
if (savedConfig.model === config.model) {
|
|
990
|
+
console.log(chalk.green(` ✓ Default model set to: ${modelRef}`))
|
|
991
|
+
} else {
|
|
992
|
+
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
993
|
+
}
|
|
914
994
|
console.log()
|
|
915
995
|
console.log(chalk.dim(' Starting OpenCode…'))
|
|
916
996
|
console.log()
|
|
917
997
|
|
|
918
998
|
const { spawn } = await import('child_process')
|
|
919
|
-
const child = spawn('opencode', [], {
|
|
999
|
+
const child = spawn('opencode', ['--model', modelRef], {
|
|
920
1000
|
stdio: 'inherit',
|
|
921
1001
|
shell: true,
|
|
922
1002
|
detached: false
|
|
923
1003
|
})
|
|
924
1004
|
|
|
925
|
-
// 📖 Wait for OpenCode to exit
|
|
926
1005
|
await new Promise((resolve, reject) => {
|
|
927
1006
|
child.on('exit', resolve)
|
|
928
1007
|
child.on('error', (err) => {
|
|
@@ -941,67 +1020,25 @@ After installation, you can use: opencode --model nvidia/${model.modelId}`
|
|
|
941
1020
|
// ─── Start OpenCode Desktop ─────────────────────────────────────────────────────
|
|
942
1021
|
// 📖 startOpenCodeDesktop: Same config logic as startOpenCode, but opens the Desktop app.
|
|
943
1022
|
// 📖 OpenCode Desktop shares config at the same location as CLI.
|
|
1023
|
+
// 📖 Handles all 3 providers: nvidia (needs custom provider config), groq & cerebras (built-in).
|
|
944
1024
|
// 📖 No need to wait for exit — Desktop app stays open independently.
|
|
945
1025
|
async function startOpenCodeDesktop(model) {
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
console.log(chalk.green(` 🖥 Setting ${chalk.bold(model.label)} as default for OpenCode Desktop…`))
|
|
950
|
-
console.log(chalk.dim(` Model: nvidia/${model.modelId}`))
|
|
951
|
-
console.log()
|
|
952
|
-
|
|
953
|
-
const config = loadOpenCodeConfig()
|
|
954
|
-
const backupPath = `${getOpenCodeConfigPath()}.backup-${Date.now()}`
|
|
955
|
-
|
|
956
|
-
if (existsSync(getOpenCodeConfigPath())) {
|
|
957
|
-
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
958
|
-
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
config.model = `nvidia/${model.modelId}`
|
|
962
|
-
|
|
963
|
-
if (config.provider?.nvidia) {
|
|
964
|
-
if (!config.provider.nvidia.models) config.provider.nvidia.models = {}
|
|
965
|
-
config.provider.nvidia.models[model.modelId] = {
|
|
966
|
-
name: model.label,
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
saveOpenCodeConfig(config)
|
|
971
|
-
|
|
972
|
-
// 📖 Verify config was saved correctly
|
|
973
|
-
const savedConfig = loadOpenCodeConfig()
|
|
974
|
-
console.log(chalk.dim(` 📝 Config saved to: ${getOpenCodeConfigPath()}`))
|
|
975
|
-
console.log(chalk.dim(` 📝 Default model in config: ${savedConfig.model || 'NOT SET'}`))
|
|
976
|
-
console.log()
|
|
977
|
-
|
|
978
|
-
if (savedConfig.model === config.model) {
|
|
979
|
-
console.log(chalk.green(` ✓ Default model set to: nvidia/${model.modelId}`))
|
|
980
|
-
} else {
|
|
981
|
-
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
982
|
-
}
|
|
983
|
-
console.log()
|
|
984
|
-
console.log(chalk.dim(' Opening OpenCode Desktop…'))
|
|
985
|
-
console.log()
|
|
1026
|
+
const providerKey = model.providerKey ?? 'nvidia'
|
|
1027
|
+
// 📖 Full model reference string used in OpenCode config and --model flag
|
|
1028
|
+
const modelRef = `${providerKey}/${model.modelId}`
|
|
986
1029
|
|
|
987
|
-
|
|
1030
|
+
// 📖 Helper to open the Desktop app based on platform
|
|
1031
|
+
const launchDesktop = async () => {
|
|
988
1032
|
const { exec } = await import('child_process')
|
|
989
|
-
|
|
990
1033
|
let command
|
|
991
1034
|
if (isMac) {
|
|
992
1035
|
command = 'open -a OpenCode'
|
|
993
1036
|
} else if (isWindows) {
|
|
994
|
-
// 📖 On Windows, try common installation paths
|
|
995
|
-
// 📖 User installation: %LOCALAPPDATA%\Programs\OpenCode\OpenCode.exe
|
|
996
|
-
// 📖 System installation: C:\Program Files\OpenCode\OpenCode.exe
|
|
997
1037
|
command = 'start "" "%LOCALAPPDATA%\\Programs\\OpenCode\\OpenCode.exe" 2>nul || start "" "%PROGRAMFILES%\\OpenCode\\OpenCode.exe" 2>nul || start OpenCode'
|
|
998
1038
|
} else if (isLinux) {
|
|
999
|
-
|
|
1000
|
-
// 📖 Check if opencode-desktop exists, otherwise try xdg-open
|
|
1001
|
-
command = `opencode-desktop --model nvidia/${model.modelId} 2>/dev/null || flatpak run ai.opencode.OpenCode --model nvidia/${model.modelId} 2>/dev/null || snap run opencode --model nvidia/${model.modelId} 2>/dev/null || xdg-open /usr/share/applications/opencode.desktop 2>/dev/null || echo "OpenCode not found"`
|
|
1039
|
+
command = `opencode-desktop --model ${modelRef} 2>/dev/null || flatpak run ai.opencode.OpenCode --model ${modelRef} 2>/dev/null || snap run opencode --model ${modelRef} 2>/dev/null || xdg-open /usr/share/applications/opencode.desktop 2>/dev/null || echo "OpenCode not found"`
|
|
1002
1040
|
}
|
|
1003
|
-
|
|
1004
|
-
exec(command, (err, stdout, stderr) => {
|
|
1041
|
+
exec(command, (err) => {
|
|
1005
1042
|
if (err) {
|
|
1006
1043
|
console.error(chalk.red(' ✗ Could not open OpenCode Desktop'))
|
|
1007
1044
|
if (isWindows) {
|
|
@@ -1014,13 +1051,56 @@ async function startOpenCodeDesktop(model) {
|
|
|
1014
1051
|
}
|
|
1015
1052
|
}
|
|
1016
1053
|
})
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
if (providerKey === 'nvidia') {
|
|
1057
|
+
// 📖 NVIDIA NIM needs a custom provider block in OpenCode config (not built-in)
|
|
1058
|
+
const hasNim = checkNvidiaNimConfig()
|
|
1059
|
+
|
|
1060
|
+
if (hasNim) {
|
|
1061
|
+
console.log(chalk.green(` 🖥 Setting ${chalk.bold(model.label)} as default for OpenCode Desktop…`))
|
|
1062
|
+
console.log(chalk.dim(` Model: ${modelRef}`))
|
|
1063
|
+
console.log()
|
|
1064
|
+
|
|
1065
|
+
const config = loadOpenCodeConfig()
|
|
1066
|
+
const backupPath = `${getOpenCodeConfigPath()}.backup-${Date.now()}`
|
|
1067
|
+
|
|
1068
|
+
if (existsSync(getOpenCodeConfigPath())) {
|
|
1069
|
+
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
1070
|
+
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
config.model = modelRef
|
|
1074
|
+
|
|
1075
|
+
if (config.provider?.nvidia) {
|
|
1076
|
+
if (!config.provider.nvidia.models) config.provider.nvidia.models = {}
|
|
1077
|
+
config.provider.nvidia.models[model.modelId] = { name: model.label }
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
saveOpenCodeConfig(config)
|
|
1081
|
+
|
|
1082
|
+
const savedConfig = loadOpenCodeConfig()
|
|
1083
|
+
console.log(chalk.dim(` 📝 Config saved to: ${getOpenCodeConfigPath()}`))
|
|
1084
|
+
console.log(chalk.dim(` 📝 Default model in config: ${savedConfig.model || 'NOT SET'}`))
|
|
1085
|
+
console.log()
|
|
1086
|
+
|
|
1087
|
+
if (savedConfig.model === config.model) {
|
|
1088
|
+
console.log(chalk.green(` ✓ Default model set to: ${modelRef}`))
|
|
1089
|
+
} else {
|
|
1090
|
+
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
1091
|
+
}
|
|
1092
|
+
console.log()
|
|
1093
|
+
console.log(chalk.dim(' Opening OpenCode Desktop…'))
|
|
1094
|
+
console.log()
|
|
1095
|
+
|
|
1096
|
+
await launchDesktop()
|
|
1097
|
+
} else {
|
|
1098
|
+
console.log(chalk.yellow(' ⚠ NVIDIA NIM not configured in OpenCode'))
|
|
1099
|
+
console.log(chalk.dim(' Please configure it first. Config is shared between CLI and Desktop.'))
|
|
1100
|
+
console.log()
|
|
1101
|
+
|
|
1102
|
+
const configPath = getOpenCodeConfigPath()
|
|
1103
|
+
const installPrompt = `Add this to ${configPath}:
|
|
1024
1104
|
|
|
1025
1105
|
{
|
|
1026
1106
|
"provider": {
|
|
@@ -1036,8 +1116,68 @@ async function startOpenCodeDesktop(model) {
|
|
|
1036
1116
|
}
|
|
1037
1117
|
|
|
1038
1118
|
${isWindows ? 'set NVIDIA_API_KEY=your_key_here' : 'export NVIDIA_API_KEY=your_key_here'}`
|
|
1039
|
-
|
|
1119
|
+
console.log(chalk.cyan(installPrompt))
|
|
1120
|
+
console.log()
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
// 📖 Groq: built-in OpenCode provider — needs provider block with apiKey in opencode.json.
|
|
1124
|
+
// 📖 Cerebras: NOT built-in — needs @ai-sdk/openai-compatible + baseURL, like NVIDIA.
|
|
1125
|
+
// 📖 Both need the model registered in provider.<key>.models so OpenCode can find it.
|
|
1126
|
+
console.log(chalk.green(` 🖥 Setting ${chalk.bold(model.label)} as default for OpenCode Desktop…`))
|
|
1127
|
+
console.log(chalk.dim(` Model: ${modelRef}`))
|
|
1128
|
+
console.log()
|
|
1129
|
+
|
|
1130
|
+
const config = loadOpenCodeConfig()
|
|
1131
|
+
const backupPath = `${getOpenCodeConfigPath()}.backup-${Date.now()}`
|
|
1132
|
+
|
|
1133
|
+
if (existsSync(getOpenCodeConfigPath())) {
|
|
1134
|
+
copyFileSync(getOpenCodeConfigPath(), backupPath)
|
|
1135
|
+
console.log(chalk.dim(` 💾 Backup: ${backupPath}`))
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// 📖 Ensure the provider block exists in config — create it if missing
|
|
1139
|
+
if (!config.provider) config.provider = {}
|
|
1140
|
+
if (!config.provider[providerKey]) {
|
|
1141
|
+
if (providerKey === 'groq') {
|
|
1142
|
+
config.provider.groq = {
|
|
1143
|
+
options: { apiKey: '{env:GROQ_API_KEY}' },
|
|
1144
|
+
models: {}
|
|
1145
|
+
}
|
|
1146
|
+
} else if (providerKey === 'cerebras') {
|
|
1147
|
+
config.provider.cerebras = {
|
|
1148
|
+
npm: '@ai-sdk/openai-compatible',
|
|
1149
|
+
name: 'Cerebras',
|
|
1150
|
+
options: {
|
|
1151
|
+
baseURL: 'https://api.cerebras.ai/v1',
|
|
1152
|
+
apiKey: '{env:CEREBRAS_API_KEY}'
|
|
1153
|
+
},
|
|
1154
|
+
models: {}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// 📖 Register the model in the provider's models section
|
|
1160
|
+
if (!config.provider[providerKey].models) config.provider[providerKey].models = {}
|
|
1161
|
+
config.provider[providerKey].models[model.modelId] = { name: model.label }
|
|
1162
|
+
|
|
1163
|
+
config.model = modelRef
|
|
1164
|
+
saveOpenCodeConfig(config)
|
|
1165
|
+
|
|
1166
|
+
const savedConfig = loadOpenCodeConfig()
|
|
1167
|
+
console.log(chalk.dim(` 📝 Config saved to: ${getOpenCodeConfigPath()}`))
|
|
1168
|
+
console.log(chalk.dim(` 📝 Default model in config: ${savedConfig.model || 'NOT SET'}`))
|
|
1040
1169
|
console.log()
|
|
1170
|
+
|
|
1171
|
+
if (savedConfig.model === config.model) {
|
|
1172
|
+
console.log(chalk.green(` ✓ Default model set to: ${modelRef}`))
|
|
1173
|
+
} else {
|
|
1174
|
+
console.log(chalk.yellow(` ⚠ Config might not have been saved correctly`))
|
|
1175
|
+
}
|
|
1176
|
+
console.log()
|
|
1177
|
+
console.log(chalk.dim(' Opening OpenCode Desktop…'))
|
|
1178
|
+
console.log()
|
|
1179
|
+
|
|
1180
|
+
await launchDesktop()
|
|
1041
1181
|
}
|
|
1042
1182
|
}
|
|
1043
1183
|
|
|
@@ -1673,7 +1813,7 @@ async function main() {
|
|
|
1673
1813
|
const sorted = sortResults(results, state.sortColumn, state.sortDirection)
|
|
1674
1814
|
const selected = sorted[state.cursor]
|
|
1675
1815
|
// 📖 Allow selecting ANY model (even timeout/down) - user knows what they're doing
|
|
1676
|
-
userSelected = { modelId: selected.modelId, label: selected.label, tier: selected.tier }
|
|
1816
|
+
userSelected = { modelId: selected.modelId, label: selected.label, tier: selected.tier, providerKey: selected.providerKey }
|
|
1677
1817
|
|
|
1678
1818
|
// 📖 Stop everything and act on selection immediately
|
|
1679
1819
|
clearInterval(ticker)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "free-coding-models",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"description": "Find the fastest coding LLM models in seconds — ping free models from multiple providers, pick the best one for OpenCode, Cursor, or any AI coding assistant.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nvidia",
|