Documentation
¶
Overview ¶
Package config loads and validates the portable project configuration (.idea-harness/project.yaml and harness.yaml) against embedded JSON Schemas (§28, §30). It also enforces that secrets never live in the portable tree.
Index ¶
- Constants
- Variables
- func HasErrors(problems []Problem) bool
- func LoadDotEnv(dir string) map[string]string
- func ParseModelSpec(spec string) (provider, model string)
- func ValidateBaseURL(raw string) error
- func ValidateProvider(name string, pc ProviderConfig) error
- func WriteHarness(dir string, h HarnessConfig) error
- type CheckConfig
- type Config
- type ExecutorConfig
- type ExecutorKind
- type HarnessConfig
- type NetworkPolicy
- type Preset
- type Problem
- type ProjectConfig
- type ProviderConfig
- type ProviderType
- type ResearchConfig
- type ReviewConfig
- type Severity
Constants ¶
const Dir = ".idea-harness"
Dir is the portable config directory name inside a project.
Variables ¶
var Presets = []Preset{ {Key: "openai", Label: "OpenAI", Type: ProviderOpenAI, BaseURL: "https://api.openai.com/v1", DefaultKeyEnv: "OPENAI_API_KEY", NeedsKey: true}, {Key: "anthropic", Label: "Anthropic", Type: ProviderAnthropic, BaseURL: "https://api.anthropic.com/v1", DefaultKeyEnv: "ANTHROPIC_API_KEY", NeedsKey: true}, {Key: "gemini", Label: "Google Gemini", Type: ProviderGemini, BaseURL: "https://generativelanguage.googleapis.com/v1beta", DefaultKeyEnv: "GOOGLE_API_KEY", NeedsKey: true}, {Key: "deepseek", Label: "DeepSeek", Type: ProviderOpenAI, BaseURL: "https://api.deepseek.com/v1", DefaultKeyEnv: "DEEPSEEK_API_KEY", NeedsKey: true}, {Key: "openrouter", Label: "OpenRouter", Type: ProviderOpenAI, BaseURL: "https://openrouter.ai/api/v1", DefaultKeyEnv: "OPENROUTER_API_KEY", NeedsKey: true}, {Key: "ollama", Label: "Ollama (local)", Type: ProviderOpenAI, BaseURL: "http://localhost:11434/v1", DefaultKeyEnv: "", NeedsKey: false}, }
Presets are the built-in providers (§10, §41). OpenRouter and Ollama speak the OpenAI-compatible wire format with different endpoints; Gemini and Anthropic use native APIs.
Functions ¶
func LoadDotEnv ¶
LoadDotEnv reads a .env file (KEY=VALUE, with optional `export` prefix and quotes) and returns its values. Values are used only as a fallback to the real process environment for secret resolution (§47). No interpolation or shell expansion is performed.
func ParseModelSpec ¶
ParseModelSpec splits a "provider/model" default-model string into its provider and model parts. A model with no "/" returns ("", model); the caller applies the default provider. Splitting is on the FIRST slash so OpenRouter model ids like "anthropic/claude-3.7-sonnet" remain intact.
func ValidateBaseURL ¶
ValidateBaseURL requires https, except on loopback where http is the norm for local runtimes (ollama, LM Studio). Plain http to any other host puts the API key and the prompt on the wire in the clear.
func ValidateProvider ¶
func ValidateProvider(name string, pc ProviderConfig) error
ValidateProvider checks one provider entry on the WRITE path (and, via Problems, on a hand-edited harness.yaml). A provider entry decides where prompts and an API key are sent, so it is validated before it is stored, not when it is first used.
func WriteHarness ¶
func WriteHarness(dir string, h HarnessConfig) error
WriteHarness writes harness.yaml to dir, applying defaults first. It is the single write path for provider/model configuration (§47: no secrets written — only *_env references are permitted).
Types ¶
type CheckConfig ¶
type CheckConfig struct {
Image string `json:"image,omitempty" yaml:"image,omitempty"`
}
CheckConfig configures the deterministic build/test check sandbox (review H3). The image must contain the project's toolchain (e.g. golang:1.25, node:22).
type Config ¶
type Config struct {
Project ProjectConfig
Harness HarnessConfig
}
Config is the fully-loaded portable configuration for one project.
func Default ¶
func Default() Config
Default returns the default configuration. The network is disabled by default so research never silently exfiltrates local content (§15). The executor defaults to the deterministic internal executor.
func Load ¶
Load reads and validates project.yaml and harness.yaml from dir. Missing files fall back to Default(); present files are strictly validated against the raw document (so unknown fields and inline secrets are rejected, not silently dropped).
type ExecutorConfig ¶
type ExecutorConfig struct {
Kind ExecutorKind `json:"kind" yaml:"kind"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
Model string `json:"model,omitempty" yaml:"model,omitempty"`
}
ExecutorConfig selects and configures the execute-pipeline executor. Image is the container image for the container kind; Model is the coding model for the OMP kind. Neither is read by the internal kind.
type ExecutorKind ¶
type ExecutorKind string
ExecutorKind selects the coding executor the execute pipeline uses (§48–§52).
const ( ExecutorInternal ExecutorKind = "internal" ExecutorContainer ExecutorKind = "container" ExecutorOMP ExecutorKind = "omp" ExecutorHermes ExecutorKind = "hermes" )
func (ExecutorKind) Valid ¶
func (k ExecutorKind) Valid() bool
type HarnessConfig ¶
type HarnessConfig struct {
Network NetworkPolicy `json:"network" yaml:"network"`
Review ReviewConfig `json:"review" yaml:"review"`
Research ResearchConfig `json:"research" yaml:"research"`
Providers map[string]ProviderConfig `json:"providers" yaml:"providers"`
DefaultModel string `json:"default_model" yaml:"default_model"`
Executor ExecutorConfig `json:"executor" yaml:"executor"`
Check CheckConfig `json:"check" yaml:"check"`
// Models is the per-role model map: role name → "provider/model". Roles
// without an entry fall back to default_model (§40). The coding "implementer"
// role is a valid key here, letting OMP/Hermes run different models.
Models map[string]string `json:"models" yaml:"models"`
// BuildCmd/TestCmd are the deterministic check commands (review B5). They are
// config-supplied, never model/agent output; when empty the corresponding
// check is recorded not_applicable.
BuildCmd string `json:"build_cmd,omitempty" yaml:"build_cmd,omitempty"`
TestCmd string `json:"test_cmd,omitempty" yaml:"test_cmd,omitempty"`
// CheckTimeoutSeconds bounds each deterministic build/test check. Zero uses
// the default of 600s (10m) (review SRE).
CheckTimeoutSeconds int `json:"check_timeout_seconds,omitempty" yaml:"check_timeout_seconds,omitempty"`
// GitCommit opts into creating a git commit (with repo hooks disabled) for
// each applied change set (§M7). Off by default: a hook runs arbitrary code
// under the daemon's privileged environment, so this must never be implied.
GitCommit bool `json:"git_commit" yaml:"git_commit"`
}
HarnessConfig is harness.yaml (portable, committable).
type NetworkPolicy ¶
type NetworkPolicy string
NetworkPolicy is the v0.1 network mode (§46).
const ( NetworkDisabled NetworkPolicy = "disabled" NetworkEnabled NetworkPolicy = "enabled" )
func (NetworkPolicy) Valid ¶
func (n NetworkPolicy) Valid() bool
type Preset ¶
type Preset struct {
Key string
Label string
Type ProviderType
BaseURL string
DefaultKeyEnv string
NeedsKey bool
}
Preset is a well-known provider preset used for config resolution and UI.
type Problem ¶
type Problem struct {
Severity Severity `json:"severity"`
Field string `json:"field"`
Message string `json:"message"`
}
Problem is one configuration finding. Field is the harness.yaml path it came from so the operator knows which line to edit.
func UnknownModelProblems ¶
unknownModelProblems warns when the model half of a spec matches no catalog entry for a provider whose catalog is known.
Nothing validated the model half at all, so `idea model set anthropic/claude-3-7-sonnet` printed success and the first call came back a non-retryable 404 -- and nine such ids shipped in the documentation before an audit caught them by reading.
A warning, not an error: a valid model can postdate the bundled catalog, and refusing it would make the tool unusable the week a provider ships something. openrouter and ollama are skipped entirely: openrouter's ids are arbitrary upstream strings, and ollama serves whatever the operator has pulled locally. For both, the bundled catalog cannot be authoritative by construction, so a warning there would be noise on correct configurations.
type ProjectConfig ¶
type ProjectConfig struct {
Name string `json:"name" yaml:"name"`
}
ProjectConfig is project.yaml (portable, committable).
type ProviderConfig ¶
type ProviderConfig struct {
Type ProviderType `json:"type" yaml:"type"`
APIKeyEnv string `json:"api_key_env" yaml:"api_key_env"`
BaseURL string `json:"base_url" yaml:"base_url"`
Models []string `json:"models" yaml:"models"`
}
ProviderConfig describes one model provider (§40). API keys are resolved from the environment variable named by APIKeyEnv — never stored inline. Type and BaseURL are optional: when empty they are derived from the provider key's preset (see providers.go).
type ProviderType ¶
type ProviderType string
ProviderType is the wire protocol a provider speaks.
const ( ProviderOpenAI ProviderType = "openai" // OpenAI-compatible chat completions ProviderAnthropic ProviderType = "anthropic" // Anthropic messages API ProviderGemini ProviderType = "gemini" // Google generative-language API )
func ResolveProvider ¶
func ResolveProvider(key string, pc ProviderConfig) (ProviderType, string, string)
ResolveProvider derives the effective type, base URL, and key-env name for a provider entry, falling back to the preset for known keys (§40).
func (ProviderType) Valid ¶
func (t ProviderType) Valid() bool
type ResearchConfig ¶
type ResearchConfig struct {
URLs []string `json:"urls" yaml:"urls"`
}
ResearchConfig controls the research web tool (§46). URLs are seed sources fetched (public-address-only) during the research stage when network is enabled.
type ReviewConfig ¶
type ReviewConfig struct {
MaxCycles int `json:"max_cycles" yaml:"max_cycles"`
MaxTokens int64 `json:"max_tokens" yaml:"max_tokens"`
MaxCostUSD float64 `json:"max_cost_usd" yaml:"max_cost_usd"`
}
ReviewConfig is the review budget (§11, §16).
type Severity ¶
type Severity string
Severity classifies a Problem. An error means the configuration cannot do what it says (a model spec that resolves to no provider, an endpoint that would ship credentials off-box); a warn means it will work but degrade — most commonly demo mode, which is a legitimate way to run the product.