-
Notifications
You must be signed in to change notification settings - Fork 0
Provider Integration
Devin edited this page Oct 5, 2026
·
3 revisions
How AI providers (Devin, Windsurf, Claude, etc.) integrate with the universal configuration system. Runtime dependencies are small (tomli on Python <3.11, tomli-w, pyyaml), so it is safe to add to any provider.
-
Single source of truth: all providers read
~/.agents/config/config.json -
Project-local overrides:
.ai/config.jsonand.ai/config.local.json - Shared resources: MCP servers and skills shared across providers
- Provider overrides: per-provider settings inside the same file
pip install universal-ai-configor add universal-ai-config to your requirements.txt / pyproject.toml.
from universal_ai_config import UnifiedConfig, AgentEnv
from pathlib import Path
env = AgentEnv()
config = UnifiedConfig(env)
# Provider-specific settings
provider_config = config.get_provider_config("your-provider")
# Merged user + project config
merged_config = config.get_merged_config(cwd=Path.cwd())model = provider_config.get("model", "default-model")
permissions = provider_config.get("permissions", {})
allow_rules = permissions.get("allow", [])
deny_rules = permissions.get("deny", [])
ask_rules = permissions.get("ask", [])
for name, server in provider_config.get("context_servers", {}).items():
initialize_mcp_server(name, server)
skills = provider_config.get("skills", {})
enabled = skills.get("enabled", [])
paths = skills.get("paths", [])Merge in precedence order: project local > project shared > provider > shared.
def get_effective_config(provider_name: str, cwd: Path) -> dict:
env = AgentEnv()
config = UnifiedConfig(env)
effective = config.get_provider_config(provider_name)
project_dir = env.project_config(cwd)
if project_dir:
for name in ("config.json", "config.local.json"):
path = project_dir / name
if path.exists():
effective = deep_merge(effective, load_json(path))
return effectiveIf the unified config does not exist, fall back to defaults instead of crashing:
from universal_ai_config import ConfigError
try:
cfg = config.get_provider_config("your-provider")
except ConfigError:
cfg = get_default_config()Register your provider in the registry (providers.py) so ai-config migrate
imports its config and ai-config sync can write back to it:
from universal_ai_config.providers import PROVIDERS, ProviderSpec, SyncTargets
PROVIDERS["your-provider"] = ProviderSpec(
name="your-provider",
display="Your Provider",
detect_paths=["~/.your-provider"], # any existing path = installed
read_paths={ # scanned during migration
"user_config": ["~/.your-provider/config.json"],
"user_mcp": ["~/.your-provider/mcp_config.json"],
"project_config": [".your-provider/config.json"],
"project_mcp": [".your-provider/mcp_config.json"],
},
user=SyncTargets( # where sync writes back
config_file="~/.your-provider/config.json",
mcp_file="~/.your-provider/mcp_config.json",
mcp_key="mcpServers",
mcp_style="map", # map | vscode | zed | list
rules_path="~/.your-provider/AGENTS.md",
rules_mode="file", # file | mdc_dir | md_dir
skills_dir="~/.your-provider/skills",
),
)- Do not duplicate config: read the unified file instead of maintaining your own.
-
Respect overrides: check
providers.<name>before falling back toshared. -
Auto-detect
.ai/: apply project config whenever the cwd is inside a project. - Document your keys: list which settings your provider honors and their defaults.
- No secrets in config: use keyrings or environment variables.
ai-config init
ai-config set-config my-provider model my-model
ai-config get-config my-provider
cd your-project
ai-config init-project
ai-config set-config my-provider model project-modelfrom universal_ai_config import UnifiedConfig, AgentEnv, ConfigError
from pathlib import Path
class MyAIProvider:
def __init__(self, cwd: Path = None):
self.env = AgentEnv()
self.config = UnifiedConfig(self.env)
self.cwd = cwd or Path.cwd()
self._config = self._load()
def _load(self) -> dict:
try:
return self.config.get_merged_config(cwd=self.cwd)
except ConfigError:
return {"model": "default-model", "permissions": {},
"context_servers": {}, "skills": {}}
@property
def model(self) -> str:
return self._config.get("model", "default-model")
@property
def mcp_servers(self) -> dict:
return self._config.get("context_servers", {})A longer worked example lives in PROVIDER_INTEGRATION.md in the repo.
DevArtsLab/tool-universal-ai-config | MIT License | pip install universal-ai-config