Documentation
¶
Index ¶
- Constants
- Variables
- func BridgePIDFile(containerID string) (string, error)
- func BridgesDir() (string, error)
- func BuildDir() (string, error)
- func ClawkerHome() (string, error)
- func DockerfilesDir() (string, error)
- func EnsureDir(path string) error
- func HostProxyLogFile() (string, error)
- func HostProxyPIDFile() (string, error)
- func IsConfigNotFound(err error) bool
- func IsKnownIPRangeSource(name string) bool
- func LogsDir() (string, error)
- func MonitorDir() (string, error)
- func ResolveAgentEnv(agent AgentConfig, projectDir string) (map[string]string, []string, error)
- func ShareDir() (string, error)
- func Slugify(name string) string
- func UniqueSlug(name string, existing map[string]bool) string
- type AgentConfig
- type ArgDefinition
- type BuildConfig
- type BuiltinIPRangeConfig
- type ClaudeCodeConfig
- type ClaudeCodeConfigOptions
- type Config
- type ConfigNotFoundError
- type CopyInstruction
- type DockerInstructions
- type ExposePort
- type FileSettingsLoader
- func (l *FileSettingsLoader) EnsureExists() (bool, error)
- func (l *FileSettingsLoader) Exists() bool
- func (l *FileSettingsLoader) Load() (*Settings, error)
- func (l *FileSettingsLoader) Path() string
- func (l *FileSettingsLoader) ProjectSettingsPath() string
- func (l *FileSettingsLoader) Save(s *Settings) error
- type FirewallConfig
- type GitCredentialsConfig
- type HealthcheckConfig
- type IPRangeSource
- type InjectConfig
- type Loader
- type LoaderOption
- type LoggingConfig
- type Mode
- type MultiValidationError
- type Project
- func (p *Project) DeleteWorktreeDir(name string) error
- func (p *Project) DisplayName() string
- func (p *Project) Found() bool
- func (p *Project) GetOrCreateWorktreeDir(name string) (string, error)
- func (p *Project) GetWorktreeDir(name string) (string, error)
- func (p *Project) Key() string
- func (p *Project) ListWorktreeDirs() ([]WorktreeDirInfo, error)
- func (p *Project) RootDir() string
- type ProjectEntry
- type ProjectHandle
- type ProjectRegistry
- type RalphConfig
- type Registry
- type RegistryLoader
- func (l *RegistryLoader) Exists() bool
- func (l *RegistryLoader) Load() (*ProjectRegistry, error)
- func (l *RegistryLoader) Path() string
- func (l *RegistryLoader) Project(key string) ProjectHandle
- func (l *RegistryLoader) Register(displayName, rootDir string) (string, error)
- func (l *RegistryLoader) Save(r *ProjectRegistry) error
- func (l *RegistryLoader) Unregister(key string) (bool, error)
- func (l *RegistryLoader) UpdateProject(key string, updateFn func(*ProjectEntry) error) error
- type Resolution
- type Resolver
- type RunInstruction
- type SecurityConfig
- type Settings
- type SettingsLoader
- type SettingsLoaderOption
- type ValidationError
- type Validator
- type WorkspaceConfig
- type WorktreeDirInfo
- type WorktreeHandle
- type WorktreeStatus
Constants ¶
const ( // ClawkerHomeEnv is the environment variable for the clawker home directory ClawkerHomeEnv = "CLAWKER_HOME" // DefaultClawkerDir is the default directory path under user home DefaultClawkerDir = ".local/clawker" // MonitorSubdir is the subdirectory for monitoring stack configuration MonitorSubdir = "monitor" // BuildSubdir is the subdirectory for build artifacts (versions.json, dockerfiles) BuildSubdir = "build" // DockerfilesSubdir is the subdirectory for generated Dockerfiles DockerfilesSubdir = "dockerfiles" // ClawkerNetwork is the name of the shared Docker network ClawkerNetwork = "clawker-net" // LogsSubdir is the subdirectory for log files LogsSubdir = "logs" // BridgesSubdir is the subdirectory for socket bridge PID files BridgesSubdir = "bridges" )
const ( // LabelPrefix is the prefix for all clawker labels (LabelDomain + "."). LabelPrefix = LabelDomain + "." // LabelManaged marks a resource as managed by clawker. LabelManaged = LabelPrefix + "managed" // LabelProject identifies the project name. LabelProject = LabelPrefix + "project" // LabelAgent identifies the agent name within a project. LabelAgent = LabelPrefix + "agent" // LabelVersion stores the clawker version that created the resource. LabelVersion = LabelPrefix + "version" // LabelImage stores the source image tag for containers. LabelImage = LabelPrefix + "image" // LabelCreated stores the creation timestamp. LabelCreated = LabelPrefix + "created" // LabelWorkdir stores the host working directory. LabelWorkdir = LabelPrefix + "workdir" // LabelPurpose identifies the purpose of a volume. LabelPurpose = LabelPrefix + "purpose" // LabelTestName identifies the test function that created a resource. LabelTestName = LabelPrefix + "test.name" // LabelBaseImage marks a built image as the base image. LabelBaseImage = LabelPrefix + "base-image" // LabelFlavor stores the Linux flavor used for a base image build. LabelFlavor = LabelPrefix + "flavor" // LabelTest marks a resource as created by a test. LabelTest = LabelPrefix + "test" // LabelE2ETest marks a resource as created by an E2E test. LabelE2ETest = LabelPrefix + "e2e-test" )
Label key constants for Docker/OCI labels. These are the canonical source of truth — internal/docker re-exports them so that packages needing labels without docker's heavy deps can import config directly.
const ( // ConfigFileName is the default configuration file name ConfigFileName = "clawker.yaml" // IgnoreFileName is the default ignore file name IgnoreFileName = ".clawkerignore" )
const ( // SettingsFileName is the name of the user settings file. SettingsFileName = "settings.yaml" // ProjectSettingsFileName is the name of the project-level settings override. ProjectSettingsFileName = ".clawker.settings.yaml" )
const ContainerGID = 1001
ContainerGID is the default GID for the non-root user inside clawker containers.
const ContainerUID = 1001
ContainerUID is the default UID for the non-root user inside clawker containers. Used by bundler (Dockerfile generation), docker (volume tar headers, chown), containerfs (onboarding tar), and test harness (test Dockerfiles).
const DefaultConfigYAML = `` /* 2259-byte string literal not displayed */
DefaultConfigYAML returns the default configuration as YAML for scaffolding
const DefaultIgnoreFile = `` /* 483-byte string literal not displayed */
DefaultIgnoreFile returns the default .clawkerignore content
const DefaultRegistryYAML = `# Clawker Project Registry
# Managed by 'clawker init' — do not edit manually
projects: {}
`
DefaultRegistryYAML returns the default registry template
const DefaultSettingsYAML = `` /* 197-byte string literal not displayed */
DefaultSettingsYAML returns the default settings template for new users
const Domain = "clawker.dev"
Domain is the actual domain name for clawker. Used in help text, URLs, and user-facing output.
const EngineLabelPrefix = LabelDomain
EngineLabelPrefix is the label prefix for whail.EngineOptions (without trailing dot). Use this when configuring the whail Engine; it adds its own dot separator.
const EngineManagedLabel = "managed"
EngineManagedLabel is the managed label key for whail.EngineOptions.
const LabelDomain = "dev.clawker"
LabelDomain is the reverse-DNS form of Domain, per Docker/OCI label conventions. Used as the prefix for Docker labels (dev.clawker.*).
const ManagedLabelValue = "true"
ManagedLabelValue is the value for the managed label.
const (
// RegistryFileName is the name of the project registry file.
RegistryFileName = "projects.yaml"
)
Variables ¶
var BuiltinIPRangeSources = map[string]BuiltinIPRangeConfig{
"github": {
URL: "https://api.github.com/meta",
JQFilter: `(.web + .api + .git + .copilot + .packages + .pages + .importer + .actions)[]`,
},
"google-cloud": {
URL: "https://www.gstatic.com/ipranges/cloud.json",
JQFilter: `.prefixes[].ipv4Prefix // empty`,
},
"google": {
URL: "https://www.gstatic.com/ipranges/goog.json",
JQFilter: `.prefixes[].ipv4Prefix // empty`,
},
"cloudflare": {
URL: "https://api.cloudflare.com/client/v4/ips",
JQFilter: `.result.ipv4_cidrs[]`,
},
"aws": {
URL: "https://ip-ranges.amazonaws.com/ip-ranges.json",
JQFilter: `.prefixes[].ip_prefix`,
},
}
BuiltinIPRangeSources maps known source names to their API URLs and jq filters. These sources provide authoritative IP CIDR ranges for cloud providers.
var DefaultFirewallDomains = []string{
"registry.npmjs.org",
"api.anthropic.com",
"sentry.io",
"statsig.anthropic.com",
"statsig.com",
"marketplace.visualstudio.com",
"vscode.blob.core.windows.net",
"update.code.visualstudio.com",
"registry-1.docker.io",
"production.cloudflare.docker.com",
"docker.io",
}
DefaultFirewallDomains is the default list of domains allowed through the firewall. These are essential for Claude Code and common development tools.
var ErrNotInProject = errors.New("not in a registered project directory")
ErrNotInProject is returned when an operation requires a registered project but the current working directory is not within a registered project.
var ErrWorktreeNotFound = errors.New("worktree not found")
ErrWorktreeNotFound is returned when a worktree is not found in the registry.
Functions ¶
func BridgePIDFile ¶
BridgePIDFile returns the path to a bridge PID file (~/.local/clawker/bridges/<containerID>.pid)
func BridgesDir ¶
BridgesDir returns the socket bridge PID files directory (~/.local/clawker/bridges)
func ClawkerHome ¶
ClawkerHome returns the clawker home directory. It checks CLAWKER_HOME environment variable first, then defaults to ~/.clawker
func DockerfilesDir ¶
DockerfilesDir returns the dockerfiles directory (~/.clawker/build/dockerfiles)
func HostProxyLogFile ¶
HostProxyLogFile returns the path to the host proxy log file (~/.local/clawker/logs/hostproxy.log)
func HostProxyPIDFile ¶
HostProxyPIDFile returns the path to the host proxy PID file (~/.local/clawker/hostproxy.pid)
func IsConfigNotFound ¶
IsConfigNotFound returns true if the error is a ConfigNotFoundError
func IsKnownIPRangeSource ¶
IsKnownIPRangeSource returns true if the given name is a known built-in source.
func MonitorDir ¶
MonitorDir returns the monitor stack directory (~/.clawker/monitor)
func ResolveAgentEnv ¶ added in v0.1.1
ResolveAgentEnv merges env_file, from_env, and env into a single map. Precedence (lowest to highest): env_file < from_env < env. The projectDir is used to resolve relative paths in env_file entries. Returns the merged env map, any warnings (e.g. unset from_env vars), and an error.
func ShareDir ¶
ShareDir returns the path to the shared directory for bind-mounting into containers. The directory is at $CLAWKER_HOME/.clawker-share and is mounted read-only at /home/claude/.clawker-share when agent.enable_shared_dir is true.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
Includes []string `yaml:"includes,omitempty" mapstructure:"includes"`
EnvFile []string `yaml:"env_file,omitempty" mapstructure:"env_file"`
FromEnv []string `yaml:"from_env,omitempty" mapstructure:"from_env"`
Env map[string]string `yaml:"env,omitempty" mapstructure:"env"`
Memory string `yaml:"memory,omitempty" mapstructure:"memory"`
Editor string `yaml:"editor,omitempty" mapstructure:"editor"`
Visual string `yaml:"visual,omitempty" mapstructure:"visual"`
Shell string `yaml:"shell,omitempty" mapstructure:"shell"`
ClaudeCode *ClaudeCodeConfig `yaml:"claude_code,omitempty" mapstructure:"claude_code"`
PostInit string `yaml:"post_init,omitempty" mapstructure:"post_init"`
}
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 ¶
type ArgDefinition struct {
Name string `yaml:"name" mapstructure:"name"`
Default string `yaml:"default,omitempty" mapstructure:"default"`
}
ArgDefinition represents an ARG instruction
type BuildConfig ¶
type BuildConfig struct {
Image string `yaml:"image" mapstructure:"image"`
Dockerfile string `yaml:"dockerfile,omitempty" mapstructure:"dockerfile"`
Packages []string `yaml:"packages,omitempty" mapstructure:"packages"`
Context string `yaml:"context,omitempty" mapstructure:"context"`
BuildArgs map[string]string `yaml:"build_args,omitempty" mapstructure:"build_args"`
Instructions *DockerInstructions `yaml:"instructions,omitempty" mapstructure:"instructions"`
Inject *InjectConfig `yaml:"inject,omitempty" mapstructure:"inject"`
}
BuildConfig defines the container build configuration
type BuiltinIPRangeConfig ¶
BuiltinIPRangeConfig holds the configuration for a built-in IP range source.
type ClaudeCodeConfig ¶
type ClaudeCodeConfig struct {
Config ClaudeCodeConfigOptions `yaml:"config" mapstructure:"config"`
UseHostAuth *bool `yaml:"use_host_auth,omitempty" mapstructure:"use_host_auth"`
}
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" mapstructure:"strategy"` // "copy" or "fresh"
}
ClaudeCodeConfigOptions controls how Claude Code config is initialized in containers.
type Config ¶
type Config struct {
// Project is the project configuration from clawker.yaml.
// Never nil - uses defaults if no config file exists.
// Contains runtime context (Key, RootDir, worktree methods) after loading.
Project *Project
// Settings is the user settings from settings.yaml.
// Never nil - uses defaults if no settings file exists.
Settings *Settings
// Resolution is the project resolution (project key, entry, workdir).
// Never nil - empty resolution if not in a registered project.
Resolution *Resolution
// Registry is the registry for write operations.
// May be nil if registry initialization failed. Check RegistryInitErr() for details.
Registry Registry
// contains filtered or unexported fields
}
Config is a facade providing access to all configuration. All fields are eagerly loaded from the current working directory.
func NewConfig ¶
func NewConfig() *Config
NewConfig creates a Config facade by loading all configuration from the current working directory. This function always succeeds - missing files result in default values, and errors are logged but don't prevent creation.
func NewConfigForTest ¶
NewConfigForTest creates a Config facade with pre-populated values. This is intended for unit tests that don't need real config file loading.
Limitations:
- Project.RootDir() returns "" (no registry entry)
- Worktree methods (GetOrCreateWorktreeDir, etc.) will fail without a registry
- Tests needing full runtime context should use NewConfig() with os.Chdir() to a temp directory containing clawker.yaml and a registered project
func NewConfigForTestWithEntry ¶
func NewConfigForTestWithEntry(project *Project, settings *Settings, entry *ProjectEntry, configDir string) *Config
NewConfigForTestWithEntry creates a Config facade with a full project entry. This is intended for integration tests that need worktree methods to work. The configDir is used for registry operations (worktree directory management).
func (*Config) ProjectLoader ¶
ProjectLoader returns the underlying project loader. May return nil if project loading was skipped.
func (*Config) RegistryInitErr ¶
RegistryInitErr returns the error that occurred during registry initialization, if any. This can be used to provide better error messages when Registry is nil.
func (*Config) SetSettingsLoader ¶
func (c *Config) SetSettingsLoader(sl SettingsLoader)
SetSettingsLoader sets the settings loader for write operations. Used by NewConfigForTest variants and fawker to inject a test-friendly loader.
func (*Config) SettingsLoader ¶
func (c *Config) SettingsLoader() SettingsLoader
SettingsLoader returns the underlying settings loader for write operations (e.g., saving updated default image). May return nil if settings failed to load.
type ConfigNotFoundError ¶
type ConfigNotFoundError struct {
Path string
}
ConfigNotFoundError is returned when the config file doesn't exist
func (*ConfigNotFoundError) Error ¶
func (e *ConfigNotFoundError) Error() string
type CopyInstruction ¶
type CopyInstruction struct {
Src string `yaml:"src" mapstructure:"src"`
Dest string `yaml:"dest" mapstructure:"dest"`
Chown string `yaml:"chown,omitempty" mapstructure:"chown"`
Chmod string `yaml:"chmod,omitempty" mapstructure:"chmod"`
}
CopyInstruction represents a COPY instruction with optional chown/chmod
type DockerInstructions ¶
type DockerInstructions struct {
Copy []CopyInstruction `yaml:"copy,omitempty" mapstructure:"copy"`
Env map[string]string `yaml:"env,omitempty" mapstructure:"env"`
Labels map[string]string `yaml:"labels,omitempty" mapstructure:"labels"`
Expose []ExposePort `yaml:"expose,omitempty" mapstructure:"expose"`
Args []ArgDefinition `yaml:"args,omitempty" mapstructure:"args"`
Volumes []string `yaml:"volumes,omitempty" mapstructure:"volumes"`
Workdir string `yaml:"workdir,omitempty" mapstructure:"workdir"`
Healthcheck *HealthcheckConfig `yaml:"healthcheck,omitempty" mapstructure:"healthcheck"`
Shell []string `yaml:"shell,omitempty" mapstructure:"shell"`
UserRun []RunInstruction `yaml:"user_run,omitempty" mapstructure:"user_run"`
RootRun []RunInstruction `yaml:"root_run,omitempty" mapstructure:"root_run"`
}
DockerInstructions represents type-safe Dockerfile instructions
type ExposePort ¶
type ExposePort struct {
Port int `yaml:"port" mapstructure:"port"`
Protocol string `yaml:"protocol,omitempty" mapstructure:"protocol"` // "tcp" or "udp", defaults to tcp
}
ExposePort represents an EXPOSE instruction
type FileSettingsLoader ¶
type FileSettingsLoader struct {
// contains filtered or unexported fields
}
FileSettingsLoader handles loading and saving of user settings from the filesystem. It supports a two-layer hierarchy:
$CLAWKER_HOME/settings.yaml (global, lower precedence) <project-root>/.clawker.settings.yaml (project override, higher precedence)
func NewSettingsLoaderForTest ¶
func NewSettingsLoaderForTest(dir string) *FileSettingsLoader
NewSettingsLoaderForTest creates a SettingsLoader pointing at the given directory. Intended for tests and fawker that need to control the settings path without relying on CLAWKER_HOME.
func (*FileSettingsLoader) EnsureExists ¶
func (l *FileSettingsLoader) EnsureExists() (bool, error)
EnsureExists creates the global settings file if it doesn't exist. Returns true if the file was created, false if it already existed.
func (*FileSettingsLoader) Exists ¶
func (l *FileSettingsLoader) Exists() bool
Exists checks if the global settings file exists.
func (*FileSettingsLoader) Load ¶
func (l *FileSettingsLoader) Load() (*Settings, error)
Load reads and parses the settings, merging project-level overrides if present. Loading order: defaults → $CLAWKER_HOME/settings.yaml → <project-root>/.clawker.settings.yaml If the global file doesn't exist, returns default settings (not an error).
func (*FileSettingsLoader) Path ¶
func (l *FileSettingsLoader) Path() string
Path returns the full path to the global settings file.
func (*FileSettingsLoader) ProjectSettingsPath ¶
func (l *FileSettingsLoader) ProjectSettingsPath() string
ProjectSettingsPath returns the full path to the project-level settings file, or empty string if no project root is set.
func (*FileSettingsLoader) Save ¶
func (l *FileSettingsLoader) Save(s *Settings) error
Save writes the settings to the global settings file. Creates the parent directory if it doesn't exist.
type FirewallConfig ¶
type FirewallConfig struct {
Enable bool `yaml:"enable" mapstructure:"enable"`
AddDomains []string `yaml:"add_domains,omitempty" mapstructure:"add_domains"`
RemoveDomains []string `yaml:"remove_domains,omitempty" mapstructure:"remove_domains"`
OverrideDomains []string `yaml:"override_domains,omitempty" mapstructure:"override_domains"`
IPRangeSources []IPRangeSource `yaml:"ip_range_sources,omitempty" mapstructure:"ip_range_sources"`
}
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(defaults []string) []string
GetFirewallDomains resolves the final domain list based on config mode. If OverrideDomains is set, returns it directly (complete replacement). Otherwise, applies AddDomains and RemoveDomains to the default list.
func (*FirewallConfig) GetIPRangeSources ¶
func (f *FirewallConfig) GetIPRangeSources() []IPRangeSource
GetIPRangeSources returns the IP range sources to use. If IPRangeSources is explicitly set (even to empty slice), returns it. If OverrideDomains is set (override mode), returns empty slice (user controls everything). Otherwise returns DefaultIPRangeSources().
func (*FirewallConfig) IsOverrideMode ¶
func (f *FirewallConfig) IsOverrideMode() bool
IsOverrideMode returns true if using override_domains (complete replacement mode).
type GitCredentialsConfig ¶
type GitCredentialsConfig struct {
ForwardHTTPS *bool `yaml:"forward_https,omitempty" mapstructure:"forward_https"` // Enable HTTPS credential forwarding (default: follows host_proxy)
ForwardSSH *bool `yaml:"forward_ssh,omitempty" mapstructure:"forward_ssh"` // Enable SSH agent forwarding (default: true)
ForwardGPG *bool `yaml:"forward_gpg,omitempty" mapstructure:"forward_gpg"` // Enable GPG agent forwarding (default: true)
CopyGitConfig *bool `yaml:"copy_git_config,omitempty" mapstructure:"copy_git_config"` // 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" mapstructure:"cmd"`
Interval string `yaml:"interval,omitempty" mapstructure:"interval"`
Timeout string `yaml:"timeout,omitempty" mapstructure:"timeout"`
StartPeriod string `yaml:"start_period,omitempty" mapstructure:"start_period"`
Retries int `yaml:"retries,omitempty" mapstructure:"retries"`
}
HealthcheckConfig represents HEALTHCHECK instruction
type IPRangeSource ¶
type IPRangeSource struct {
// Name is the identifier (e.g., "github", "google-cloud", "cloudflare")
Name string `yaml:"name" mapstructure:"name" json:"name"`
// URL is an optional custom URL (uses built-in URL if empty for known sources)
URL string `yaml:"url,omitempty" mapstructure:"url" json:"url,omitempty"`
// JQFilter extracts CIDR arrays from JSON response (optional, uses built-in if empty)
JQFilter string `yaml:"jq_filter,omitempty" mapstructure:"jq_filter" json:"jq_filter,omitempty"`
// Required determines if failure to fetch is fatal (default: false)
Required *bool `yaml:"required,omitempty" mapstructure:"required" 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 DefaultIPRangeSources ¶
func DefaultIPRangeSources() []IPRangeSource
DefaultIPRangeSources returns the default IP range sources when none are configured. Returns github only by default. The "google" source is NOT included due to security concerns (allows traffic to user-generated content on GCS/Firebase - see CLAUDE.md).
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" mapstructure:"after_from"`
AfterPackages []string `yaml:"after_packages,omitempty" mapstructure:"after_packages"`
AfterUserSetup []string `yaml:"after_user_setup,omitempty" mapstructure:"after_user_setup"`
AfterUserSwitch []string `yaml:"after_user_switch,omitempty" mapstructure:"after_user_switch"`
AfterClaudeInstall []string `yaml:"after_claude_install,omitempty" mapstructure:"after_claude_install"`
BeforeEntrypoint []string `yaml:"before_entrypoint,omitempty" mapstructure:"before_entrypoint"`
}
InjectConfig defines injection points for arbitrary Dockerfile instructions
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading and parsing of clawker configuration
func NewLoader ¶
func NewLoader(workDir string, opts ...LoaderOption) *Loader
NewLoader creates a new configuration loader for the given working directory.
func (*Loader) ConfigPath ¶
ConfigPath returns the full path to the project config file.
func (*Loader) IgnorePath ¶
IgnorePath returns the full path to the ignore file
type LoaderOption ¶
type LoaderOption func(*Loader)
LoaderOption configures a Loader.
func WithProjectKey ¶
func WithProjectKey(key string) LoaderOption
WithProjectKey sets the project key to inject into Config.Project after loading.
func WithProjectRoot ¶
func WithProjectRoot(projectRoot string) LoaderOption
WithProjectRoot sets the project root directory for loading the project-level clawker.yaml. This is typically resolved from the registry — the project root may differ from the working directory when the user is in a subdirectory. If not set, falls back to workDir.
func WithUserDefaults ¶
func WithUserDefaults(userConfigDir string) LoaderOption
WithUserDefaults enables loading user-level $CLAWKER_HOME/clawker.yaml as a base layer. The user config is loaded first, then project config overrides it. If userConfigDir is empty, ClawkerHome() is used.
type LoggingConfig ¶
type LoggingConfig struct {
// FileEnabled enables logging to file (default: true)
// Set to false in ~/.local/clawker/settings.yaml to disable
FileEnabled *bool `yaml:"file_enabled,omitempty"`
// MaxSizeMB is the max size in MB before rotation (default: 50)
MaxSizeMB int `yaml:"max_size_mb,omitempty"`
// MaxAgeDays is max days to retain old logs (default: 7)
MaxAgeDays int `yaml:"max_age_days,omitempty"`
// MaxBackups is max number of old log files to keep (default: 3)
MaxBackups int `yaml:"max_backups,omitempty"`
}
LoggingConfig configures file-based logging. File logging is ENABLED by default - users can disable via settings.yaml.
func (*LoggingConfig) GetMaxAgeDays ¶
func (c *LoggingConfig) GetMaxAgeDays() int
GetMaxAgeDays returns the max age in days, defaulting to 7 if not set.
func (*LoggingConfig) GetMaxBackups ¶
func (c *LoggingConfig) GetMaxBackups() int
GetMaxBackups returns the max backups, defaulting to 3 if not set.
func (*LoggingConfig) GetMaxSizeMB ¶
func (c *LoggingConfig) GetMaxSizeMB() int
GetMaxSizeMB returns the max size in MB, defaulting to 50 if not set.
func (*LoggingConfig) IsFileEnabled ¶
func (c *LoggingConfig) IsFileEnabled() bool
IsFileEnabled returns whether file logging is enabled. Defaults to true if not explicitly set.
type MultiValidationError ¶
type MultiValidationError struct {
Errors []error
}
MultiValidationError holds multiple validation errors
func (*MultiValidationError) Error ¶
func (e *MultiValidationError) Error() string
func (*MultiValidationError) ValidationErrors ¶
func (e *MultiValidationError) ValidationErrors() []error
ValidationErrors returns the individual errors
type Project ¶
type Project struct {
Version string `yaml:"version" mapstructure:"version"`
Project string `yaml:"-" mapstructure:"-"`
DefaultImage string `yaml:"default_image,omitempty" mapstructure:"default_image"`
Build BuildConfig `yaml:"build" mapstructure:"build"`
Agent AgentConfig `yaml:"agent" mapstructure:"agent"`
Workspace WorkspaceConfig `yaml:"workspace" mapstructure:"workspace"`
Security SecurityConfig `yaml:"security" mapstructure:"security"`
Ralph *RalphConfig `yaml:"ralph,omitempty" mapstructure:"ralph"`
// contains filtered or unexported fields
}
Project represents the root configuration structure for clawker.yaml.
In addition to YAML schema fields, it contains runtime context fields (projectEntry, registry, worktreeMu) that are injected after loading via setRuntimeContext(). These runtime fields enable worktree operations and project identity lookup.
func DefaultConfig ¶
func DefaultConfig() *Project
DefaultConfig returns a Config with sensible default values
func (*Project) DeleteWorktreeDir ¶
DeleteWorktreeDir removes a worktree directory and its registry entry. Returns an error if the directory doesn't exist. Returns ErrWorktreeNotFound (wrapped) if the worktree is not in the registry.
This method implements git.WorktreeDirProvider.
func (*Project) DisplayName ¶
DisplayName returns the project display name from the registry. Falls back to the project key if not available.
func (*Project) GetOrCreateWorktreeDir ¶
GetOrCreateWorktreeDir returns the path to a worktree directory, creating it if it doesn't exist. The name is typically a branch name which will be slugified for filesystem safety.
This method implements git.WorktreeDirProvider.
func (*Project) GetWorktreeDir ¶
GetWorktreeDir returns the path to an existing worktree directory. Returns an error if the worktree directory doesn't exist. Returns ErrWorktreeNotFound (wrapped) if the worktree is not in the registry.
This method implements git.WorktreeDirProvider.
func (*Project) ListWorktreeDirs ¶
func (p *Project) ListWorktreeDirs() ([]WorktreeDirInfo, error)
ListWorktreeDirs returns information about all worktree directories for this project.
type ProjectEntry ¶
type ProjectEntry struct {
Name string `yaml:"name"`
Root string `yaml:"root"`
Worktrees map[string]string `yaml:"worktrees,omitempty"`
}
ProjectEntry represents a registered project in the registry.
func (ProjectEntry) Valid ¶
func (e ProjectEntry) Valid() error
Valid returns an error if the entry is missing required fields or has invalid values.
type ProjectHandle ¶
type ProjectHandle interface {
// Key returns the project slug key.
Key() string
// Get returns the ProjectEntry, loading from disk if needed.
Get() (*ProjectEntry, error)
// Root returns the project root directory path.
Root() (string, error)
// Exists checks if the project exists in the registry.
Exists() (bool, error)
// Update atomically modifies the project entry.
Update(fn func(*ProjectEntry) error) error
// Delete removes the project from the registry.
Delete() (bool, error)
// Worktree returns a handle for operating on a specific worktree.
Worktree(name string) WorktreeHandle
// ListWorktrees returns handles for all worktrees in this project.
ListWorktrees() ([]WorktreeHandle, error)
}
ProjectHandle provides operations on a single project entry. Implemented by projectHandleImpl (file-based) and test fakes.
type ProjectRegistry ¶
type ProjectRegistry struct {
Projects map[string]ProjectEntry `yaml:"projects"`
}
ProjectRegistry holds the map of project slug keys to entries.
func (*ProjectRegistry) HasKey ¶
func (r *ProjectRegistry) HasKey(key string) bool
HasKey returns whether the registry contains the given key.
func (*ProjectRegistry) Lookup ¶
func (r *ProjectRegistry) Lookup(workDir string) (string, ProjectEntry)
Lookup finds the registry entry whose Root matches workDir or is a parent of workDir. Uses longest prefix match when multiple entries could match. Returns the key and entry, or empty key if not found.
func (*ProjectRegistry) LookupByKey ¶
func (r *ProjectRegistry) LookupByKey(key string) (ProjectEntry, bool)
LookupByKey returns the entry for the given key, or false if not found.
type RalphConfig ¶
type RalphConfig struct {
MaxLoops int `yaml:"max_loops,omitempty" mapstructure:"max_loops"`
StagnationThreshold int `yaml:"stagnation_threshold,omitempty" mapstructure:"stagnation_threshold"`
TimeoutMinutes int `yaml:"timeout_minutes,omitempty" mapstructure:"timeout_minutes"`
CallsPerHour int `yaml:"calls_per_hour,omitempty" mapstructure:"calls_per_hour"`
CompletionThreshold int `yaml:"completion_threshold,omitempty" mapstructure:"completion_threshold"`
SessionExpirationHours int `yaml:"session_expiration_hours,omitempty" mapstructure:"session_expiration_hours"`
SameErrorThreshold int `yaml:"same_error_threshold,omitempty" mapstructure:"same_error_threshold"`
OutputDeclineThreshold int `yaml:"output_decline_threshold,omitempty" mapstructure:"output_decline_threshold"`
MaxConsecutiveTestLoops int `yaml:"max_consecutive_test_loops,omitempty" mapstructure:"max_consecutive_test_loops"`
LoopDelaySeconds int `yaml:"loop_delay_seconds,omitempty" mapstructure:"loop_delay_seconds"`
SafetyCompletionThreshold int `yaml:"safety_completion_threshold,omitempty" mapstructure:"safety_completion_threshold"`
SkipPermissions bool `yaml:"skip_permissions,omitempty" mapstructure:"skip_permissions"`
}
RalphConfig defines configuration for autonomous ralph loops.
func (*RalphConfig) GetMaxLoops ¶
func (r *RalphConfig) GetMaxLoops() int
GetMaxLoops returns the max loops with default fallback.
func (*RalphConfig) GetStagnationThreshold ¶
func (r *RalphConfig) GetStagnationThreshold() int
GetStagnationThreshold returns the stagnation threshold with default fallback.
func (*RalphConfig) GetTimeoutMinutes ¶
func (r *RalphConfig) GetTimeoutMinutes() int
GetTimeoutMinutes returns the timeout in minutes with default fallback.
type Registry ¶
type Registry interface {
// Project returns a handle for operating on a specific project.
Project(key string) ProjectHandle
// Load reads and parses the registry file.
Load() (*ProjectRegistry, error)
// Save writes the registry to the file.
Save(r *ProjectRegistry) error
// Register adds a project to the registry, returns the slug key used.
Register(displayName, rootDir string) (string, error)
// Unregister removes a project from the registry by key.
Unregister(key string) (bool, error)
// UpdateProject atomically updates a project entry in the registry.
UpdateProject(key string, fn func(*ProjectEntry) error) error
// Path returns the full path to the registry file.
Path() string
// Exists checks if the registry file exists.
Exists() bool
}
Registry provides access to project registry operations. Implemented by RegistryLoader (file-based) and test fakes.
type RegistryLoader ¶
type RegistryLoader struct {
// contains filtered or unexported fields
}
RegistryLoader handles loading and saving of the project registry.
func NewRegistryLoader ¶
func NewRegistryLoader() (*RegistryLoader, error)
NewRegistryLoader creates a new RegistryLoader. It resolves the registry path from CLAWKER_HOME or the default location.
func NewRegistryLoaderWithPath ¶
func NewRegistryLoaderWithPath(dir string) *RegistryLoader
NewRegistryLoaderWithPath creates a RegistryLoader for a specific directory. This is used by tests and configtest that need to control the registry location. Note: No validation is performed; errors will occur at Load/Save time if the path is invalid.
func (*RegistryLoader) Exists ¶
func (l *RegistryLoader) Exists() bool
Exists checks if the registry file exists.
func (*RegistryLoader) Load ¶
func (l *RegistryLoader) Load() (*ProjectRegistry, error)
Load reads and parses the registry file. If the file doesn't exist, returns an empty registry (not an error).
func (*RegistryLoader) Path ¶
func (l *RegistryLoader) Path() string
Path returns the full path to the registry file.
func (*RegistryLoader) Project ¶
func (l *RegistryLoader) Project(key string) ProjectHandle
Project returns a handle for operating on a specific project.
func (*RegistryLoader) Register ¶
func (l *RegistryLoader) Register(displayName, rootDir string) (string, error)
Register adds a project to the registry. The slug is derived from the display name. If a collision occurs, a suffix is appended. Returns the slug key used.
func (*RegistryLoader) Save ¶
func (l *RegistryLoader) Save(r *ProjectRegistry) error
Save writes the registry to the file. Creates the parent directory if it doesn't exist.
func (*RegistryLoader) Unregister ¶
func (l *RegistryLoader) Unregister(key string) (bool, error)
Unregister removes a project from the registry by key. Returns true if the project was found and removed.
func (*RegistryLoader) UpdateProject ¶
func (l *RegistryLoader) UpdateProject(key string, updateFn func(*ProjectEntry) error) error
UpdateProject atomically updates a project entry in the registry. The updateFn receives a pointer to the entry which can be modified in place. If updateFn returns an error, the registry is not saved. Returns an error if the project is not found or if loading/saving fails.
type Resolution ¶
type Resolution struct {
ProjectKey string
ProjectEntry ProjectEntry
WorkDir string
}
Resolution holds the result of resolving the current working directory against the project registry.
func (*Resolution) Found ¶
func (r *Resolution) Found() bool
Found returns true if the working directory was resolved to a registered project.
func (*Resolution) ProjectRoot ¶
func (r *Resolution) ProjectRoot() string
ProjectRoot returns the project root directory, or empty string if not found.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves the current working directory against the project registry.
func NewResolver ¶
func NewResolver(registry *ProjectRegistry) *Resolver
NewResolver creates a new Resolver with the given registry. If registry is nil, all resolutions will return not-found.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(workDir string) *Resolution
Resolve looks up workDir in the registry and returns a Resolution.
type RunInstruction ¶
type RunInstruction struct {
Cmd string `yaml:"cmd,omitempty" mapstructure:"cmd"` // Generic command for both OS
Alpine string `yaml:"alpine,omitempty" mapstructure:"alpine"` // Alpine-specific command
Debian string `yaml:"debian,omitempty" mapstructure:"debian"` // Debian-specific command
}
RunInstruction represents a RUN command with OS-awareness
type SecurityConfig ¶
type SecurityConfig struct {
Firewall *FirewallConfig `yaml:"firewall,omitempty" mapstructure:"firewall"`
DockerSocket bool `yaml:"docker_socket" mapstructure:"docker_socket"`
CapAdd []string `yaml:"cap_add,omitempty" mapstructure:"cap_add"`
EnableHostProxy *bool `yaml:"enable_host_proxy,omitempty" mapstructure:"enable_host_proxy"` // defaults to true
GitCredentials *GitCredentialsConfig `yaml:"git_credentials,omitempty" mapstructure:"git_credentials"`
}
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 configures file-based logging.
// File logging is ENABLED by default - users can disable via settings.yaml.
Logging LoggingConfig `yaml:"logging,omitempty"`
// DefaultImage is the user's preferred default container image.
// Set by 'clawker init' after building the base image.
DefaultImage string `yaml:"default_image,omitempty"`
}
Settings represents user-level configuration stored in ~/.local/clawker/settings.yaml. Settings are global and apply across all clawker projects.
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns a Settings with sensible default values.
type SettingsLoader ¶
type SettingsLoader interface {
Path() string
ProjectSettingsPath() string
Exists() bool
Load() (*Settings, error)
Save(s *Settings) error
EnsureExists() (bool, error)
}
SettingsLoader handles loading and saving of user settings.
func NewSettingsLoader ¶
func NewSettingsLoader(opts ...SettingsLoaderOption) (SettingsLoader, error)
NewSettingsLoader creates a new SettingsLoader. It resolves the global settings path from CLAWKER_HOME or the default location.
type SettingsLoaderOption ¶
type SettingsLoaderOption func(*FileSettingsLoader)
SettingsLoaderOption configures a FileSettingsLoader.
func WithProjectSettingsRoot ¶
func WithProjectSettingsRoot(projectRoot string) SettingsLoaderOption
WithProjectSettingsRoot sets the project root directory for loading project-level .clawker.settings.yaml as an override layer.
type ValidationError ¶
ValidationError represents a configuration validation error
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates a Config for correctness
func NewValidator ¶
NewValidator creates a new validator for the given working directory
type WorkspaceConfig ¶
type WorkspaceConfig struct {
RemotePath string `yaml:"remote_path" mapstructure:"remote_path"`
DefaultMode string `yaml:"default_mode" mapstructure:"default_mode"`
}
WorkspaceConfig defines workspace mounting behavior
type WorktreeDirInfo ¶
type WorktreeDirInfo struct {
Name string // original branch name
Slug string // slugified directory name
Path string // full filesystem path
}
WorktreeDirInfo contains information about a worktree directory.
type WorktreeHandle ¶
type WorktreeHandle interface {
// Name returns the branch name that the worktree is tracking.
Name() string
// Slug returns the filesystem-safe slug.
Slug() string
// Path returns the worktree directory path.
Path() (string, error)
// DirExists returns true if the clawker-managed worktree directory exists
// at ~/.local/clawker/projects/<key>/worktrees/<slug>.
DirExists() bool
// GitExists returns true if git worktree metadata is valid.
// Reads <worktree-path>/.git file and validates it points to the correct location
// in the project's .git/worktrees/<slug> directory.
GitExists() bool
// Status returns the health status by calling DirExists() and GitExists().
Status() *WorktreeStatus
// Delete removes the worktree entry from the registry.
Delete() error
}
WorktreeHandle provides operations and queries on a single worktree. Implemented by worktreeHandleImpl (file-based) and test fakes.
type WorktreeStatus ¶
type WorktreeStatus struct {
Name string // Branch name that the worktree is tracking
Slug string // Filesystem-safe slug
Path string // Worktree directory path
DirExists bool // Worktree directory exists on filesystem
GitExists bool // .git file exists and points to valid git metadata
Error error // Non-nil if path resolution failed
}
WorktreeStatus holds the health check results for a worktree.
func (*WorktreeStatus) IsHealthy ¶
func (s *WorktreeStatus) IsHealthy() bool
IsHealthy returns true if both directory and git metadata exist.
func (*WorktreeStatus) IsPrunable ¶
func (s *WorktreeStatus) IsPrunable() bool
IsPrunable returns true if registry entry exists but both dir and git are missing. Returns false if there was an error checking status (we can't safely prune if we don't know the state).
func (*WorktreeStatus) Issues ¶
func (s *WorktreeStatus) Issues() []string
Issues returns a slice of issue descriptions, empty if healthy.
func (*WorktreeStatus) String ¶
func (s *WorktreeStatus) String() string
String returns "healthy" when all checks pass, or comma-separated issues. If Error is non-nil, returns the error message.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package configtest provides test fakes for config types.
|
Package configtest provides test fakes for config types. |