feat(config): add custom provider configuration support and mcp error screen broken fix#5
Open
visitorise wants to merge 1 commit into
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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