Documentation
¶
Overview ¶
Package config loads ogcode's optional file-based configuration: provider base URLs and API keys, and the skill sources and permissions, so they can live in a committed/shared file instead of only environment variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureProjectFile ¶
EnsureProjectFile creates a blank project-local ogcode.json in dir if no ogcode.json is found in dir or any of its ancestors (see findProjectFile). An existing file — found anywhere in that search — is left untouched, and so is dir itself if creation fails for any reason (e.g. a read-only filesystem): this is a best-effort convenience, never a requirement for startup. Returns the path that was created, or "" if nothing was created.
Types ¶
type Config ¶
type Config struct {
Providers map[string]ProviderConfig `json:"providers,omitempty"`
Skills SkillsConfig `json:"skills,omitempty"`
MCP MCPConfig `json:"mcp,omitempty"`
}
Config is ogcode's file-based configuration.
func Load ¶
Load reads the global config (~/.config/ogcode/config.json) and the project-local config (ogcode.json, found by searching dir and its parents, stopping once the repo root — the directory holding .git — has been checked), merging them provider-by-provider with project-local values taking precedence. Missing or unreadable files are silently skipped; Load always returns a usable, non-nil Config.
Skill sources merge differently from provider settings: paths and urls are unioned rather than overridden, so a project adds its own skill directories to the user's global ones instead of replacing them. Permissions merge key-by-key, project-local last, so a project can override one rule without restating the rest.
type MCPAuthConfig ¶ added in v0.29.0
type MCPAuthConfig struct {
// ClientID is a pre-registered OAuth client identifier. When set, Dynamic
// Client Registration is skipped and this client is used directly. Leave
// empty to use DCR (the default).
ClientID string `json:"clientId,omitempty"`
// ClientSecret is the secret for a pre-registered confidential client.
// Only meaningful when ClientID is set. Leave empty for a public client.
ClientSecret string `json:"clientSecret,omitempty"`
// Scopes are requested beyond what the server advertises. Empty = the
// server's scopes_supported plus offline_access (when refresh tokens are
// requested).
Scopes []string `json:"scopes,omitempty"`
// SkipOAuth disables the OAuth handler for this server even with no
// Headers — for a server that returns 401 but is not an OAuth server.
SkipOAuth bool `json:"skipOAuth,omitempty"`
}
MCPAuthConfig configures OAuth authorization for a URL-based MCP server. It only applies to streamable-http servers without static Headers. Leave the whole block nil (or empty) for the default: Dynamic Client Registration with a loopback redirect, which works against servers like Cal.com with no pre-registered client.
type MCPConfig ¶ added in v0.29.0
type MCPConfig map[string]MCPServerConfig
MCPConfig holds the named MCP servers ogcode connects to at startup.
type MCPServerConfig ¶ added in v0.29.0
type MCPServerConfig struct {
// Transport forces the transport; empty auto-detects from Command/URL.
Transport string `json:"transport,omitempty"`
// Command is the executable run as a stdio subprocess server.
Command string `json:"command,omitempty"`
// Args are passed to Command.
Args []string `json:"args,omitempty"`
// Env augments (not replaces) the parent process environment for Command.
Env map[string]string `json:"env,omitempty"`
// URL is the endpoint for a streamable-http or sse server.
URL string `json:"url,omitempty"`
// Headers are sent with HTTP requests to a URL-based server. When set, the
// server uses the static-token path and no OAuth handler is attached.
Headers map[string]string `json:"headers,omitempty"`
// Auth configures OAuth for a URL-based server. When nil (the default for a
// server with a URL and no Headers), Dynamic Client Registration is used
// with a localhost redirect — the "just works" path. Setting any field
// opts into an explicit client. Has no effect for stdio servers or when
// Headers is set.
Auth *MCPAuthConfig `json:"auth,omitempty"`
}
MCPServerConfig configures a single Model Context Protocol server connection. A server is either a local subprocess (Command + Args + Env) or a remote HTTP endpoint (URL + Headers). Transport is one of "stdio", "streamable-http", or "sse" — when empty, it is inferred from whether Command or URL is set (stdio if Command, otherwise http).
Authorization: a server with a URL and no Headers gets an OAuth handler attached automatically — the first 401 triggers the authorization-code (with PKCE) flow, so servers like Cal.com connect with no extra config. A server with Headers keeps the static bearer-token path and no OAuth. The optional Auth block overrides the defaults (pre-registered client, custom scopes, or SkipOAuth to disable the handler entirely).
type ProviderConfig ¶
type ProviderConfig struct {
BaseURL string `json:"baseUrl,omitempty"`
APIKey string `json:"apiKey,omitempty"`
}
ProviderConfig holds per-provider connection overrides.
type SkillsConfig ¶ added in v0.27.0
type SkillsConfig struct {
// Paths are extra skill directories, relative to the project or absolute.
Paths []string `json:"paths,omitempty"`
// URLs are index.json manifests to fetch skills from.
URLs []string `json:"urls,omitempty"`
// Permissions maps a skill-name glob to "allow", "deny", or "ask".
Permissions map[string]string `json:"permissions,omitempty"`
}
SkillsConfig configures where skills come from and which of them an agent may use. Every field is optional: with none of them set, ogcode still scans the standard project and global skill directories.