Principle:777genius Agent teams ai Local Provider Discovery
| Knowledge Sources | |
|---|---|
| Domains | Provider_Management, Configuration |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Pattern for discovering and listing locally configured provider entries (e.g., OpenCode's global or project-scoped provider configs) from the filesystem.
Description
Local Provider Discovery is the process of reading provider configuration files from well-known filesystem locations (e.g., `~/.config/opencode/` for global scope, or a project directory for project scope), parsing them into provider entries, and returning a structured list. The discovery validates the runtime ID (only 'opencode' is supported), the scope ('global' or 'project'), and optional provider ID filters.
Key aspects:
- Scope resolution: The config target is resolved based on scope (global vs. project) and an optional project path, with environment-aware home directory resolution.
- Provider ID filtering: An optional `providerId` filter restricts results to a single provider, validated against a pattern.
- Config writer serialization: Config read-modify-write operations are serialized through a single-chain queue to avoid config-path key subtleties.
- Private network approval: A store tracks which private network providers the user has approved for access.
Usage
Use this principle when designing a system that discovers provider configurations from the filesystem across multiple scopes, especially when the configurations may be modified concurrently and must be serialized.
Theoretical Basis
# Abstract algorithm (NOT real implementation)
async def list_local_providers(input):
if input.runtime_id != 'opencode':
return error('invalid-input', 'Only OpenCode supports local providers')
config_target = await read_config_target(
scope=input.scope,
project_path=input.project_path,
home_path=home
)
if not config_target.raw:
return empty_response(config_target)
providers = parse_providers(config_target.raw)
if input.provider_id:
providers = [p for p in providers if p.id == input.provider_id]
return {
schema_version: 1,
runtime_id: 'opencode',
scope: config_target.scope,
providers: providers
}