config

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// AgentsConfigFile is the name of the agents configuration file
	AgentsConfigFile = "agents.json"
)
View Source
const (
	// ProjectsConfigFile is the name of the projects configuration file
	ProjectsConfigFile = "projects.json"
)
View Source
const (
	// WorkspaceConfigFile is the name of the workspace configuration file
	WorkspaceConfigFile = "workspace.json"
)

Variables

View Source
var (
	// ErrInvalidPath is returned when a configuration path is invalid or empty
	ErrInvalidPath = errors.New("invalid configuration path")
	// ErrConfigNotFound is returned when the workspace.json file is not found
	ErrConfigNotFound = errors.New("workspace configuration file not found")
	// ErrInvalidConfig is returned when the configuration validation fails
	ErrInvalidConfig = errors.New("invalid workspace configuration")
)
View Source
var (
	// ErrInvalidAgentConfig is returned when the agent configuration is invalid
	ErrInvalidAgentConfig = errors.New("invalid agent configuration")
)
View Source
var (
	// ErrInvalidProjectConfig is returned when the project configuration is invalid
	ErrInvalidProjectConfig = errors.New("invalid project configuration")
)

Functions

func DisplayModelName added in v0.6.0

func DisplayModelName(modelID string) string

DisplayModelName returns just the model name, stripping the provider:: and ::baseURL encoding for human-readable display.

func ParseModelID added in v0.6.0

func ParseModelID(modelID string) (provider, model, baseURL string)

ParseModelID splits a model ID encoded as "provider::model::baseURL" into its components. Returns (provider, model, baseURL). For plain model IDs, provider and baseURL are empty.

Types

type AgentConfigLoader

type AgentConfigLoader interface {
	// Load reads and returns the workspace configuration for the specified agent.
	// Returns an empty configuration (not an error) if the agents.json file doesn't exist.
	// Returns an error if the file exists but is invalid JSON or malformed.
	Load(agentName string) (*workspace.WorkspaceConfiguration, error)
}

AgentConfigLoader loads agent-specific workspace configurations

func NewAgentConfigLoader

func NewAgentConfigLoader(storageDir string) (AgentConfigLoader, error)

NewAgentConfigLoader creates a new agent configuration loader

type AgentConfigUpdater added in v0.11.0

type AgentConfigUpdater interface {
	// AddEnvVar adds or updates an environment variable in the agent's config.
	// If an entry with the same name already exists its value is replaced.
	AddEnvVar(agentName, name, value string) error

	// AddMount adds a mount entry to the agent's config.
	// The call is idempotent: if a mount with the same host and target already exists
	// it is not duplicated.
	AddMount(agentName, host, target string, ro bool) error
}

AgentConfigUpdater adds entries to the per-agent configuration file (agents.json).

func NewAgentConfigUpdater added in v0.11.0

func NewAgentConfigUpdater(storageDir string) (AgentConfigUpdater, error)

NewAgentConfigUpdater returns an AgentConfigUpdater backed by <storageDir>/config/agents.json.

type Config

type Config interface {
	// Load reads and parses the workspace configuration from workspace.json.
	// Returns ErrConfigNotFound if the workspace.json file doesn't exist.
	// Returns an error if the JSON is malformed or cannot be read.
	Load() (*workspace.WorkspaceConfiguration, error)
}

Config represents a workspace configuration manager. It manages the structure and contents of a workspace configuration directory (typically .kaiden). If the configuration directory does not exist, the config is considered empty.

func NewConfig

func NewConfig(configDir string) (Config, error)

NewConfig creates a new Config for the specified configuration directory. The configDir is converted to an absolute path.

type Merger

type Merger interface {
	// Merge combines two WorkspaceConfiguration objects.
	// The override config takes precedence over the base config.
	// Returns a new merged configuration without modifying the inputs.
	Merge(base, override *workspace.WorkspaceConfiguration) *workspace.WorkspaceConfiguration
}

Merger merges multiple WorkspaceConfiguration objects with proper precedence rules. When merging: - Environment variables: Later configs override earlier ones (by name) - Mounts: Deduplicated by host+target pair (preserves order, no duplicates)

func NewMerger

func NewMerger() Merger

NewMerger creates a new configuration merger

type ProjectConfigLoader

type ProjectConfigLoader interface {
	// Load reads and returns the workspace configuration for the specified project.
	// It first loads the global configuration (empty string "" key), then loads
	// the project-specific configuration, and merges them with project-specific
	// taking precedence.
	// Returns an empty configuration (not an error) if the projects.json file doesn't exist.
	// Returns an error if the file exists but is invalid JSON or malformed.
	Load(projectID string) (*workspace.WorkspaceConfiguration, error)
}

ProjectConfigLoader loads project-specific workspace configurations

func NewProjectConfigLoader

func NewProjectConfigLoader(storageDir string) (ProjectConfigLoader, error)

NewProjectConfigLoader creates a new project configuration loader

type ProjectConfigUpdater added in v0.9.0

type ProjectConfigUpdater interface {
	// AddSecret appends secretName to the Secrets list of the given project.
	// projectID is "" for the global configuration.
	// The call is idempotent: if the secret is already present it is not duplicated.
	AddSecret(projectID string, secretName string) error

	// AddMount adds a mount entry to the given project's config.
	// projectID is "" for the global configuration.
	// The call is idempotent: if a mount with the same host and target already exists
	// it is not duplicated.
	AddMount(projectID, host, target string, ro bool) error
}

ProjectConfigUpdater adds entries to the per-project configuration file.

func NewProjectConfigUpdater added in v0.9.0

func NewProjectConfigUpdater(storageDir string) (ProjectConfigUpdater, error)

NewProjectConfigUpdater returns a ProjectConfigUpdater backed by <storageDir>/config/projects.json.

type WorkspaceConfigUpdater added in v0.9.0

type WorkspaceConfigUpdater interface {
	// AddSecret appends secretName to the Secrets list of the workspace config,
	// creating the file and directory if they do not yet exist.
	// The call is idempotent: if the secret is already present it is not duplicated.
	AddSecret(secretName string) error

	// AddEnvVar adds or updates an environment variable in the workspace config.
	// If an entry with the same name already exists its value is replaced.
	AddEnvVar(name, value string) error

	// AddMount adds a mount entry to the workspace config.
	// The call is idempotent: if a mount with the same host and target already exists
	// it is not duplicated.
	AddMount(host, target string, ro bool) error

	// AddPort appends port to the Ports list of the workspace config.
	// The call is idempotent: if the port is already present it is not duplicated.
	AddPort(port int) error

	// AddFeature adds a feature entry to the Features map of the workspace config.
	// The call is idempotent: if the feature ID is already present it is not modified.
	AddFeature(featureID string, options map[string]interface{}) error
}

WorkspaceConfigUpdater manages the local workspace configuration file.

func NewWorkspaceConfigUpdater added in v0.9.0

func NewWorkspaceConfigUpdater(configDir string) (WorkspaceConfigUpdater, error)

NewWorkspaceConfigUpdater returns a WorkspaceConfigUpdater backed by <configDir>/workspace.json.

Jump to

Keyboard shortcuts

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