userconfig

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package userconfig defines the schema and merge semantics for skill-up's optional user-level configuration file (typically ~/.config/skill-up/config.yaml).

The config provides defaults for OpenTelemetry-related environment variables and per-environment.type runtime kwargs that the `run` command consumes. The embedded defaults are intentionally empty: skill-up ships with no alibaba-specific (or any other vendor-specific) defaults; downstream consumers maintain their own config file.

Discovery and precedence are handled by LoadEffective in loader.go.

Index

Constants

View Source
const ConfigEnvVar = "SKILL_UP_CONFIG"

ConfigEnvVar overrides the user-layer config path.

View Source
const ProjectConfigFile = ".skill-up.yaml"

ProjectConfigFile is the per-project config file name (in WorkingDir).

View Source
const UserConfigDir = "skill-up"

UserConfigDir is the directory under $XDG_CONFIG_HOME / ~/.config.

View Source
const UserConfigFile = "config.yaml"

UserConfigFile is the default user-layer file name.

Variables

This section is empty.

Functions

func ApplyEnv

func ApplyEnv(c Config) ([]string, error)

ApplyEnv writes telemetry and arbitrary env defaults from c into the process environment, only setting keys that are currently unset. It returns the list of keys that were actually applied (sorted) for logging and debugging.

func FromContext

func FromContext(ctx context.Context) (Config, []Source, bool)

FromContext retrieves a Config attached via WithContext.

func LoadEffective

func LoadEffective(opts LoadOptions) (Config, []Source, error)

LoadEffective merges all discovery layers in order of increasing precedence and returns the merged Config and the list of layers that actually contributed.

func MergeKwargs

func MergeKwargs(c Config, envType string, evalKwargs map[string]string) map[string]string

MergeKwargs returns a kwargs map for envType where eval.yaml entries always win and user-config entries fill in any missing keys.

func WithContext

func WithContext(ctx context.Context, cfg Config, sources []Source) context.Context

WithContext attaches a Config and sources to ctx for downstream consumers.

Types

type Config

type Config struct {
	SchemaVersion string            `yaml:"schema_version,omitempty"`
	Kind          string            `yaml:"kind,omitempty"`
	Telemetry     Telemetry         `yaml:"telemetry,omitempty"`
	Env           map[string]string `yaml:"env,omitempty"`
	RuntimeKwargs map[string]Kwargs `yaml:"runtime_kwargs,omitempty"`
}

Config is the on-disk schema for a skill-up user-config file.

func LoadFile added in v0.1.2

func LoadFile(path string) (Config, error)

LoadFile reads and validates a single config file. Returns an error if the file is missing, unparseable, or fails Validate. Unlike LoadEffective it does not consult any discovery layers — it is meant for callers (e.g. the `init` subcommand) that want to vet a specific file in isolation.

func Redact

func Redact(c Config) Config

Redact returns a copy of c with every string field tagged `secret:"true"` masked. Values that match the ${ENV_VAR} pattern are preserved verbatim so that env references remain visible.

Currently no Config field carries the secret tag; this is forward-compatible for future fields and is exercised by tests with a small fixture struct.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns nil for an entirely empty Config. It only flags malformed values when fields are explicitly set.

type Kwargs

type Kwargs map[string]string

Kwargs is a map of runtime-kwarg key/value pairs for one environment type.

type LoadOptions

type LoadOptions struct {
	ExplicitPath string
	WorkingDir   string
	HomeDir      string
	Env          func(string) string
	// Warnings receives one line per non-fatal issue (e.g. a corrupt user or
	// project layer file). Defaults to os.Stderr when nil.
	Warnings io.Writer
}

LoadOptions controls config discovery.

type Source

type Source struct {
	Kind string
	Path string
}

Source identifies a discovery layer that contributed to the merged result.

type Telemetry

type Telemetry struct {
	ServiceName        string            `yaml:"service_name,omitempty"`
	TracesExporter     string            `yaml:"traces_exporter,omitempty"`
	Traces             TracesConfig      `yaml:"traces,omitempty"`
	ResourceAttributes map[string]string `yaml:"resource_attributes,omitempty"`
	// Verbose, when explicitly set to true, enables OTEL_LOG_USER_PROMPTS,
	// OTEL_LOG_TOOL_CONTENT, and OTEL_LOG_TOOL_DETAILS. A pointer is used so
	// higher-precedence layers can both enable (true) and disable (false) it;
	// a nil pointer means "inherit from lower-precedence layers".
	Verbose *bool `yaml:"verbose,omitempty"`
}

Telemetry holds OpenTelemetry-related defaults. Each non-empty field maps to a standard OTEL_* environment variable applied only when the corresponding variable is currently unset in the process environment.

type TracesConfig

type TracesConfig struct {
	Endpoint string `yaml:"endpoint,omitempty"`
	Protocol string `yaml:"protocol,omitempty"`
}

TracesConfig holds OTLP traces transport defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL