Documentation
¶
Overview ¶
Package config provides types for interacting with clawker configuration files. It loads clawker.yaml (project) and settings.yaml (user) into a typed Config backed by storage.Store[T], with separate stores for project and settings schemas.
Index ¶
- Constants
- Variables
- func ConfigDir() string
- func DataDir() string
- func ProjectRegistryFilePath() (string, error)
- func SettingsFilePath() (string, error)
- func StateDir() string
- func UserProjectConfigFilePath() (string, error)
- type AgentConfig
- type ArgDefinition
- type BuildConfig
- type ClaudeCodeConfig
- type ClaudeCodeConfigOptions
- type Config
- type CopyInstruction
- type DockerInstructions
- type ExposePort
- type FirewallConfig
- type GitCredentialsConfig
- type HealthcheckConfig
- type HostProxyConfig
- type HostProxyDaemonConfig
- type HostProxyManagerConfig
- type IPRangeSource
- type InjectConfig
- type KeyNotFoundError
- type LoggingConfig
- type LoopConfig
- type Mode
- type MonitoringConfig
- type OtelConfig
- type Project
- type ProjectEntry
- type ProjectRegistry
- type RunInstruction
- type SecurityConfig
- type Settings
- type TelemetryConfig
- type WorkspaceConfig
- type WorktreeEntry
Constants ¶
const DefaultConfigYAML = `` /* 2111-byte string literal not displayed */
DefaultConfigYAML is the commented template written to disk by clawker init. This is a user-facing scaffold — different from defaultProjectYAML which is the programmatic base layer. The template contains comments to guide users.
const DefaultIgnoreFile = `` /* 424-byte string literal not displayed */
DefaultIgnoreFile returns the default .clawkerignore content
const DefaultRegistryYAML = `# Clawker ProjectCfg Registry
# Managed by 'clawker init' — do not edit manually
projects: []
`
DefaultRegistryYAML is the commented template for the project registry.
const DefaultSettingsYAML = `` /* 1046-byte string literal not displayed */
DefaultSettingsYAML is the commented template written to disk by clawker init.
Variables ¶
var ErrNotInProject = errors.New("current directory is not within a configured project root")
Functions ¶
func ConfigDir ¶ added in v0.2.0
func ConfigDir() string
ConfigDir returns the clawker config directory.
func ProjectRegistryFilePath ¶ added in v0.2.0
ProjectRegistryFilePath returns the absolute path to the project registry file.
func SettingsFilePath ¶ added in v0.2.0
SettingsFilePath returns the absolute path to the global settings file.
func UserProjectConfigFilePath ¶ added in v0.2.0
UserProjectConfigFilePath returns the absolute path to the user-level clawker.yaml file.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
Includes []string `yaml:"includes,omitempty"` // TODO: these are added to the build context and image hash but never COPY'd into the image. Project root is already mounted at runtime. Do we still need this?
EnvFile []string `yaml:"env_file,omitempty"`
FromEnv []string `yaml:"from_env,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Memory string `yaml:"memory,omitempty"`
Editor string `yaml:"editor,omitempty"`
Visual string `yaml:"visual,omitempty"`
Shell string `yaml:"shell,omitempty"`
ClaudeCode *ClaudeCodeConfig `yaml:"claude_code,omitempty"`
PostInit string `yaml:"post_init,omitempty"`
}
AgentConfig defines Claude agent-specific settings.
func (*AgentConfig) SharedDirEnabled ¶
func (a *AgentConfig) SharedDirEnabled() bool
SharedDirEnabled returns whether the shared directory should be mounted (default: false).
type ArgDefinition ¶
ArgDefinition represents an ARG instruction
type BuildConfig ¶
type BuildConfig struct {
Image string `yaml:"image"`
Dockerfile string `yaml:"dockerfile,omitempty"`
Packages []string `yaml:"packages,omitempty"`
Context string `yaml:"context,omitempty"`
BuildArgs map[string]string `yaml:"build_args,omitempty"`
Instructions *DockerInstructions `yaml:"instructions,omitempty"`
Inject *InjectConfig `yaml:"inject,omitempty"`
}
BuildConfig defines the container build configuration
type ClaudeCodeConfig ¶
type ClaudeCodeConfig struct {
Config ClaudeCodeConfigOptions `yaml:"config"`
UseHostAuth *bool `yaml:"use_host_auth,omitempty"`
}
ClaudeCodeConfig controls Claude Code settings and authentication in containers.
func (*ClaudeCodeConfig) ConfigStrategy ¶
func (c *ClaudeCodeConfig) ConfigStrategy() string
ConfigStrategy returns the config strategy (default: "copy").
func (*ClaudeCodeConfig) UseHostAuthEnabled ¶
func (c *ClaudeCodeConfig) UseHostAuthEnabled() bool
UseHostAuthEnabled returns whether host auth should be used (default: true).
type ClaudeCodeConfigOptions ¶
type ClaudeCodeConfigOptions struct {
Strategy string `yaml:"strategy"` // "copy" or "fresh"
}
ClaudeCodeConfigOptions controls how Claude Code config is initialized in containers.
type Config ¶
type Config interface {
ClawkerIgnoreName() string
Project() *Project
Settings() *Settings
// ProjectStore returns the underlying project config store.
// Prefer this over SetProject/WriteProject for direct store access.
ProjectStore() *storage.Store[Project]
// SettingsStore returns the underlying settings store.
// Prefer this over SetSettings/WriteSettings for direct store access.
SettingsStore() *storage.Store[Settings]
// Deprecated: Use SettingsStore().Read().Logging instead.
LoggingConfig() LoggingConfig
// Deprecated: Use SettingsStore().Read().Monitoring instead.
MonitoringConfig() MonitoringConfig
// Deprecated: Use SettingsStore().Read().HostProxy instead.
HostProxyConfig() HostProxyConfig
Domain() string
LabelDomain() string
ConfigDirEnvVar() string
StateDirEnvVar() string
DataDirEnvVar() string
TestRepoDirEnvVar() string
MonitorSubdir() (string, error)
BuildSubdir() (string, error)
DockerfilesSubdir() (string, error)
ClawkerNetwork() string
LogsSubdir() (string, error)
BridgesSubdir() (string, error)
PidsSubdir() (string, error)
BridgePIDFilePath(containerID string) (string, error)
HostProxyLogFilePath() (string, error)
HostProxyPIDFilePath() (string, error)
WorktreesSubdir() (string, error)
LabelPrefix() string
LabelManaged() string
LabelMonitoringStack() string
LabelProject() string
LabelAgent() string
LabelVersion() string
LabelImage() string
LabelCreated() string
LabelWorkdir() string
LabelPurpose() string
LabelTestName() string
LabelBaseImage() string
LabelFlavor() string
LabelTest() string
LabelE2ETest() string
ManagedLabelValue() string
EngineLabelPrefix() string
EngineManagedLabel() string
ContainerUID() int
ContainerGID() int
GrafanaURL(host string, https bool) string
JaegerURL(host string, https bool) string
PrometheusURL(host string, https bool) string
RequiredFirewallDomains() []string
ProjectConfigFileName() string
SettingsFileName() string
ProjectRegistryFileName() string
GetProjectRoot() (string, error)
GetProjectIgnoreFile() (string, error)
}
Config is the public configuration contract. Add methods here as the config contract grows.
func NewBlankConfig ¶ added in v0.2.0
NewBlankConfig creates a Config with defaults but no file discovery. Useful as the default test double for consumers that don't care about specific config values.
func NewConfig ¶
NewConfig loads all clawker configuration files into a Config. The project store discovers clawker.yaml via walk-up (CWD → project root) and config dir. The settings store loads settings.yaml from config dir. Both stores use defaults as the lowest-priority base layer.
func NewFromString ¶ added in v0.2.0
NewFromString creates a Config from raw YAML strings without defaults. Empty strings produce empty structs. Useful for test fixtures that need precise control over values without defaults being merged.
type CopyInstruction ¶
type CopyInstruction struct {
Src string `yaml:"src"`
Dest string `yaml:"dest"`
Chown string `yaml:"chown,omitempty"`
Chmod string `yaml:"chmod,omitempty"`
}
CopyInstruction represents a COPY instruction with optional chown/chmod
type DockerInstructions ¶
type DockerInstructions struct {
Copy []CopyInstruction `yaml:"copy,omitempty"`
Env map[string]string `yaml:"env,omitempty"`
Labels map[string]string `yaml:"labels,omitempty"`
Expose []ExposePort `yaml:"expose,omitempty"`
Args []ArgDefinition `yaml:"args,omitempty"`
Volumes []string `yaml:"volumes,omitempty"`
Workdir string `yaml:"workdir,omitempty"`
Healthcheck *HealthcheckConfig `yaml:"healthcheck,omitempty"`
Shell []string `yaml:"shell,omitempty"`
UserRun []RunInstruction `yaml:"user_run,omitempty"`
RootRun []RunInstruction `yaml:"root_run,omitempty"`
}
DockerInstructions represents type-safe Dockerfile instructions
type ExposePort ¶
type ExposePort struct {
Port int `yaml:"port"`
Protocol string `yaml:"protocol,omitempty"` // "tcp" or "udp", defaults to tcp
}
ExposePort represents an EXPOSE instruction
type FirewallConfig ¶
type FirewallConfig struct {
Enable bool `yaml:"enable"`
AddDomains []string `yaml:"add_domains,omitempty"`
IPRangeSources []IPRangeSource `yaml:"ip_range_sources,omitempty"`
}
FirewallConfig defines network firewall settings
func (*FirewallConfig) FirewallEnabled ¶
func (f *FirewallConfig) FirewallEnabled() bool
FirewallEnabled returns whether the firewall should be enabled. Returns true only if Firewall config exists and Enable is true.
func (*FirewallConfig) GetFirewallDomains ¶
func (f *FirewallConfig) GetFirewallDomains(requiredDomains []string) []string
GetFirewallDomains returns required domains merged with user's add_domains.
type GitCredentialsConfig ¶
type GitCredentialsConfig struct {
ForwardHTTPS *bool `yaml:"forward_https,omitempty"` // Enable HTTPS credential forwarding (default: follows host_proxy)
ForwardSSH *bool `yaml:"forward_ssh,omitempty"` // Enable SSH agent forwarding (default: true)
ForwardGPG *bool `yaml:"forward_gpg,omitempty"` // Enable GPG agent forwarding (default: true)
CopyGitConfig *bool `yaml:"copy_git_config,omitempty"` // Copy host .gitconfig (default: true)
}
GitCredentialsConfig defines git credential forwarding settings
func (*GitCredentialsConfig) CopyGitConfigEnabled ¶
func (g *GitCredentialsConfig) CopyGitConfigEnabled() bool
CopyGitConfigEnabled returns whether host .gitconfig should be copied. Returns true by default.
func (*GitCredentialsConfig) GPGEnabled ¶
func (g *GitCredentialsConfig) GPGEnabled() bool
GPGEnabled returns whether GPG agent forwarding should be enabled. Returns true by default.
func (*GitCredentialsConfig) GitHTTPSEnabled ¶
func (g *GitCredentialsConfig) GitHTTPSEnabled(hostProxyEnabled bool) bool
GitHTTPSEnabled returns whether HTTPS credential forwarding should be enabled. Returns true if host proxy is enabled and not explicitly disabled.
func (*GitCredentialsConfig) GitSSHEnabled ¶
func (g *GitCredentialsConfig) GitSSHEnabled() bool
GitSSHEnabled returns whether SSH agent forwarding should be enabled. Returns true by default.
type HealthcheckConfig ¶
type HealthcheckConfig struct {
Cmd []string `yaml:"cmd"`
Interval string `yaml:"interval,omitempty"`
Timeout string `yaml:"timeout,omitempty"`
StartPeriod string `yaml:"start_period,omitempty"`
Retries int `yaml:"retries,omitempty"`
}
HealthcheckConfig represents HEALTHCHECK instruction
type HostProxyConfig ¶ added in v0.2.0
type HostProxyConfig struct {
Manager HostProxyManagerConfig `yaml:"manager,omitempty"`
Daemon HostProxyDaemonConfig `yaml:"daemon,omitempty"`
}
HostProxyConfig configures the host proxy.
type HostProxyDaemonConfig ¶ added in v0.2.0
type HostProxyDaemonConfig struct {
Port int `yaml:"port"`
PollInterval time.Duration `yaml:"poll_interval,omitempty"`
GracePeriod time.Duration `yaml:"grace_period,omitempty"`
MaxConsecutiveErrs int `yaml:"max_consecutive_errs,omitempty"`
}
HostProxyDaemonConfig defines configuration for the host proxy daemon.
type HostProxyManagerConfig ¶ added in v0.2.0
type HostProxyManagerConfig struct {
Port int `yaml:"port"`
}
HostProxyManagerConfig configures the host proxy manager.
type IPRangeSource ¶
type IPRangeSource struct {
// Name is the identifier (e.g., "github", "google-cloud", "cloudflare")
Name string `yaml:"name" json:"name"`
// URL is an optional custom URL (uses built-in URL if empty for known sources)
URL string `yaml:"url,omitempty" json:"url,omitempty"`
// JQFilter extracts CIDR arrays from JSON response (optional, uses built-in if empty)
JQFilter string `yaml:"jq_filter,omitempty" json:"jq_filter,omitempty"`
// Required determines if failure to fetch is fatal (default: false)
Required *bool `yaml:"required,omitempty" json:"required,omitempty"`
}
IPRangeSource defines a source of IP CIDR ranges for the firewall. Sources can be built-in (github, google-cloud, google, cloudflare, aws) or custom with explicit URL and jq filter.
func (*IPRangeSource) IsRequired ¶
func (s *IPRangeSource) IsRequired() bool
IsRequired returns whether this source is required (failure to fetch is fatal). For "github" source, defaults to true if not explicitly set.
type InjectConfig ¶
type InjectConfig struct {
AfterFrom []string `yaml:"after_from,omitempty"`
AfterPackages []string `yaml:"after_packages,omitempty"`
AfterUserSetup []string `yaml:"after_user_setup,omitempty"`
AfterUserSwitch []string `yaml:"after_user_switch,omitempty"`
AfterClaudeInstall []string `yaml:"after_claude_install,omitempty"`
BeforeEntrypoint []string `yaml:"before_entrypoint,omitempty"`
}
InjectConfig defines injection points for arbitrary Dockerfile instructions
type KeyNotFoundError ¶ added in v0.2.0
type KeyNotFoundError struct {
Key string
}
KeyNotFoundError indicates a configuration key was not found.
func (*KeyNotFoundError) Error ¶ added in v0.2.0
func (e *KeyNotFoundError) Error() string
type LoggingConfig ¶
type LoggingConfig struct {
FileEnabled *bool `yaml:"file_enabled,omitempty"`
MaxSizeMB int `yaml:"max_size_mb,omitempty"`
MaxAgeDays int `yaml:"max_age_days,omitempty"`
MaxBackups int `yaml:"max_backups,omitempty"`
Compress *bool `yaml:"compress,omitempty"`
Otel OtelConfig `yaml:"otel,omitempty"`
}
LoggingConfig configures file-based logging.
type LoopConfig ¶ added in v0.1.4
type LoopConfig struct {
MaxLoops int `yaml:"max_loops,omitempty"`
StagnationThreshold int `yaml:"stagnation_threshold,omitempty"`
TimeoutMinutes int `yaml:"timeout_minutes,omitempty"`
CallsPerHour int `yaml:"calls_per_hour,omitempty"`
CompletionThreshold int `yaml:"completion_threshold,omitempty"`
SessionExpirationHours int `yaml:"session_expiration_hours,omitempty"`
SameErrorThreshold int `yaml:"same_error_threshold,omitempty"`
OutputDeclineThreshold int `yaml:"output_decline_threshold,omitempty"`
MaxConsecutiveTestLoops int `yaml:"max_consecutive_test_loops,omitempty"`
LoopDelaySeconds int `yaml:"loop_delay_seconds,omitempty"`
SafetyCompletionThreshold int `yaml:"safety_completion_threshold,omitempty"`
SkipPermissions bool `yaml:"skip_permissions,omitempty"`
HooksFile string `yaml:"hooks_file,omitempty"`
AppendSystemPrompt string `yaml:"append_system_prompt,omitempty"`
}
LoopConfig defines configuration for autonomous agent loops.
func (*LoopConfig) GetAppendSystemPrompt ¶ added in v0.1.4
func (r *LoopConfig) GetAppendSystemPrompt() string
GetAppendSystemPrompt returns the additional system prompt (empty string if not configured).
func (*LoopConfig) GetHooksFile ¶ added in v0.1.4
func (r *LoopConfig) GetHooksFile() string
GetHooksFile returns the hooks file path (empty string if not configured).
func (*LoopConfig) GetMaxLoops ¶ added in v0.1.4
func (r *LoopConfig) GetMaxLoops() int
GetMaxLoops returns the max loops with default fallback.
func (*LoopConfig) GetStagnationThreshold ¶ added in v0.1.4
func (r *LoopConfig) GetStagnationThreshold() int
GetStagnationThreshold returns the stagnation threshold with default fallback.
func (*LoopConfig) GetTimeoutMinutes ¶ added in v0.1.4
func (r *LoopConfig) GetTimeoutMinutes() int
GetTimeoutMinutes returns the timeout in minutes with default fallback.
type MonitoringConfig ¶ added in v0.1.6
type MonitoringConfig struct {
OtelCollectorEndpoint string `yaml:"otel_collector_endpoint,omitempty"`
OtelCollectorPort int `yaml:"otel_collector_port,omitempty"`
OtelCollectorHost string `yaml:"otel_collector_host,omitempty"`
OtelCollectorInternal string `yaml:"otel_collector_internal,omitempty"`
OtelGRPCPort int `yaml:"otel_grpc_port,omitempty"`
LokiPort int `yaml:"loki_port,omitempty"`
PrometheusPort int `yaml:"prometheus_port,omitempty"`
JaegerPort int `yaml:"jaeger_port,omitempty"`
GrafanaPort int `yaml:"grafana_port,omitempty"`
PrometheusMetricsPort int `yaml:"prometheus_metrics_port,omitempty"`
Telemetry TelemetryConfig `yaml:"telemetry,omitempty"`
}
MonitoringConfig configures monitoring stack ports and OTEL endpoints.
type OtelConfig ¶ added in v0.1.6
type OtelConfig struct {
Enabled *bool `yaml:"enabled,omitempty"`
TimeoutSeconds int `yaml:"timeout_seconds,omitempty"`
MaxQueueSize int `yaml:"max_queue_size,omitempty"`
ExportIntervalSeconds int `yaml:"export_interval_seconds,omitempty"`
}
OtelConfig configures the OTEL zerolog bridge.
type Project ¶
type Project struct {
Build BuildConfig `yaml:"build"`
Agent AgentConfig `yaml:"agent"`
Workspace WorkspaceConfig `yaml:"workspace"`
Security SecurityConfig `yaml:"security"`
Loop *LoopConfig `yaml:"loop,omitempty"`
}
Project represents the root configuration structure for clawker.yaml.
Project is a pure persisted schema model for clawker.yaml.
type ProjectEntry ¶
type ProjectEntry struct {
Name string `yaml:"name"`
Root string `yaml:"root"`
Worktrees map[string]WorktreeEntry `yaml:"worktrees,omitempty"`
}
ProjectEntry represents a project in the registry.
type ProjectRegistry ¶
type ProjectRegistry struct {
Projects []ProjectEntry `yaml:"projects"`
}
ProjectRegistry is the on-disk structure for projects.yaml.
type RunInstruction ¶
type RunInstruction struct {
Cmd string `yaml:"cmd,omitempty"` // Generic command for both OS
Alpine string `yaml:"alpine,omitempty"` // Alpine-specific command
Debian string `yaml:"debian,omitempty"` // Debian-specific command
}
RunInstruction represents a RUN command with OS-awareness
type SecurityConfig ¶
type SecurityConfig struct {
Firewall *FirewallConfig `yaml:"firewall,omitempty"`
DockerSocket bool `yaml:"docker_socket"`
CapAdd []string `yaml:"cap_add,omitempty"`
EnableHostProxy *bool `yaml:"enable_host_proxy,omitempty"` // defaults to true
GitCredentials *GitCredentialsConfig `yaml:"git_credentials,omitempty"`
}
func (*SecurityConfig) FirewallEnabled ¶
func (s *SecurityConfig) FirewallEnabled() bool
FirewallEnabled returns whether the firewall should be enabled. Convenience method that delegates to FirewallConfig.
func (*SecurityConfig) HostProxyEnabled ¶
func (s *SecurityConfig) HostProxyEnabled() bool
HostProxyEnabled returns whether the host proxy should be enabled. Returns true if not explicitly set (defaults to enabled).
type Settings ¶
type Settings struct {
Logging LoggingConfig `yaml:"logging,omitempty"`
Monitoring MonitoringConfig `yaml:"monitoring,omitempty"`
HostProxy HostProxyConfig `yaml:"host_proxy,omitempty"`
}
Settings represents user-level configuration stored in ~/.config/clawker/settings.yaml.
type TelemetryConfig ¶ added in v0.1.6
type TelemetryConfig struct {
MetricsPath string `yaml:"metrics_path,omitempty"`
LogsPath string `yaml:"logs_path,omitempty"`
MetricExportIntervalMs int `yaml:"metric_export_interval_ms,omitempty"`
LogsExportIntervalMs int `yaml:"logs_export_interval_ms,omitempty"`
LogToolDetails *bool `yaml:"log_tool_details,omitempty"`
LogUserPrompts *bool `yaml:"log_user_prompts,omitempty"`
IncludeAccountUUID *bool `yaml:"include_account_uuid,omitempty"`
IncludeSessionID *bool `yaml:"include_session_id,omitempty"`
}
TelemetryConfig configures telemetry export paths and intervals.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
DefaultMode string `yaml:"default_mode"`
}
WorkspaceConfig defines workspace mounting behavior
type WorktreeEntry ¶ added in v0.2.0
WorktreeEntry represents a worktree within a project.