feat(config): add custom provider configuration support and mcp error screen broken fix#5
Conversation
- Add CustomModelConfig and CustomProviderConfig structs for user-defined providers - Implement parse_custom_providers() to extract provider config from crabcode.json - Add custom_providers field to MergedConfig and Discovery struct - Implement overlay logic in fetch_providers() with priority: models.dev → extensions → custom - Update App::new_with_model_override() to pass custom providers via new_with_custom() - Fix load_config_value() to use json5 for all .json files (lenient parsing) - Suppress MCP child process stderr output using TokioChildProcess::builder().stderr(Stdio::null()) Custom provider format is compatible with OpenCode's configuration.
|
Wow cool! I really appreciate the contribution. I'll be reviewing it when I become free this week. Thank you! |
# Conflicts: # src/llm/client.rs
|
Pushed maintainer fixes directly to this branch ( What changed:
Validation:
GitHub now reports the PR as mergeable with current |
|
Thank you for the quick fixes and test coverage! I am happy to contribute to Crabcode. :) |
|
Follow-up pushed in This also covers:
Validation:
Manual happy path:
|
Add Custom Provider Configuration and Fix Startup Issues
Summary
This PR introduces three key improvements:
crabcode.jsonunder the"provider"section (e.g., local llama.cpp, Ollama instances). These overlay on top of existing discovery data from models.dev and extensions..jsonconfig files are now parsed with json5 for lenient handling (trailing commas, etc.), fixing the issue where a malformed config prevented the entire app from loading.react-devtools-bridgeport conflicts) into the terminal during startup.Files Changed
src/config/configuration.rsAdded
CustomModelConfig,CustomProviderConfigstructs,parse_custom_providers()function.custom_providersfield onMergedConfig.simplified
load_config_value()to use json5 for all.jsonfiles.src/config/mod.rsRe-exported
CustomProviderConfig,CustomModelConfigsrc/model/discovery.rsAdded
custom_providers: Option<HashMap<...>>field toDiscovery.new_with_custom()constructor; overlay logic in fetch_providers().Discovery::new()` now auto-loads custom providers from config.src/app.rs,App::new_with_model_override()passes custom providers via
Discovery::new_with_custom(Some(...)).src/mcp.rsReplaced
TokioChildProcess::new()withbuilder().stderr(Stdio::null()).spawn()for local MCP server spawning, suppressing child process stderr output.Custom Provider Config Format
{ "provider": { "llama_cpp": { "name": "llama.cpp", "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://127.0.0.1:11400/v1" }, "models": { "my-model": { "name": "My Model Display Name", "contextWindow": 262140, "maxTokens": 32000 } } } }Note: This format is fully compatible with OpenCode's custom provider/model configuration. The same JSON structure and field names (
name,npm,options.baseURL,models) are used, so any config written for OpenCode works directly in crabcode without modification.Overlay Priority Order
Custom providers are overlaid after all other discovery sources:
This means models.dev data and extension-provided models are preserved; user config only adds or overrides.
Testing
cargo build— succeedscargo test— 1009 passed, 4 pre-existing failures (unrelated: Ollama cache lock, chat diff rendering)crabcode.jsonand appear in/modeldialog