Documentation
¶
Overview ¶
Package configvalue mirrors upstream pi's packages/coding-agent/src/core/resolve-config-value.ts (v0.78.1).
A configuration string value is one of:
- A "!cmd" prefix → strip the "!", run the rest as a shell command, return the trimmed stdout. Cached for the process lifetime.
- A template that may reference environment variables with "$VAR" or "${VAR}". "$$" escapes a literal "$" and "$!" escapes a literal "!". Any other text is literal. A template resolves to undefined (empty) if any referenced env var is unset or empty.
- A plain string with no "$" → a literal that resolves to itself.
IMPORTANT: unlike the pre-v0.78.1 contract, a bare identifier is NO LONGER implicitly matched against the environment. {"apiKey":"OPENAI_API_KEY"} now resolves to the literal string "OPENAI_API_KEY". Environment references require an explicit "$" sigil: {"apiKey":"$OPENAI_API_KEY"}.
Lives in its own package (rather than internal/codingagent/ where the plan named it) because ai/auth.go is a consumer and internal/codingagent already imports ai. A neutral package sidesteps the cycle while preserving the public API.
Index ¶
- func ClearCache()
- func GetConfigValueEnvVarName(config string) string
- func GetConfigValueEnvVarNames(config string) []string
- func GetMissingConfigValueEnvVarNames(config string, env map[string]string) []string
- func IsCommandConfigValue(config string) bool
- func IsConfigValueConfigured(config string, env map[string]string) bool
- func Resolve(s string, env map[string]string) string
- func ResolveHeaders(in map[string]string, env map[string]string) map[string]string
- func ResolveOrError(s, description string, env map[string]string) (string, error)
- func ResolveUncached(s string, env map[string]string) string
- func SetExecutorForTest(fn func(ctx context.Context, payload string) (string, bool)) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigValueEnvVarName ¶
GetConfigValueEnvVarName returns the single env-var name a config value references, or "" if it is a command, a literal, or a multi-part template.
func GetConfigValueEnvVarNames ¶
GetConfigValueEnvVarNames returns every distinct env-var name a config value references (empty for commands and literals).
func GetMissingConfigValueEnvVarNames ¶
GetMissingConfigValueEnvVarNames returns the referenced env-var names that are currently unset/empty. Provider-scoped overrides in env are consulted before the process environment.
func IsCommandConfigValue ¶
IsCommandConfigValue reports whether a config value is a "!cmd" command.
func IsConfigValueConfigured ¶
IsConfigValueConfigured reports whether all referenced env vars are set. Provider-scoped overrides in env are consulted before the process environment.
func Resolve ¶
Resolve returns the runtime value for a config string, or "" when a command fails or a referenced env var is unset. Mirrors upstream resolveConfigValue (string | undefined), collapsing undefined to "". Provider-scoped overrides in env take precedence over the process environment.
func ResolveHeaders ¶
ResolveHeaders maps each header value through Resolve and drops entries that resolve to empty strings. Returns nil if every entry drops out. Provider-scoped overrides in env take precedence over the process environment.
func ResolveOrError ¶
ResolveOrError mirrors upstream resolveConfigValueOrThrow: it errors when a command fails or a referenced env var is unset, with the same messages. A pure literal never errors (it resolves to itself). Provider-scoped overrides in env take precedence over the process environment.
func ResolveUncached ¶
ResolveUncached is Resolve but skips the !cmd cache.
Types ¶
This section is empty.