Documentation
¶
Overview ¶
Package validator provides config validation utilities.
Index ¶
- func APIKeyForProvider(provider string) string
- func AllEnvKeyStatus() string
- func ApplyOutputStyle(content string, style OutputStyle) string
- func BashCompletion() string
- func BoolPtr(b bool) *bool
- func BuildContext() string
- func BuildContextWithDirs(addDirs []string) string
- func DefaultAliases() map[string]string
- func DefaultIgnorePatterns() []string
- func DefaultModelConfigs() map[string]*ModelConfig
- func DetectVersion(data map[string]interface{}) int
- func DiffConfigs(old, new map[string]interface{}) string
- func EnvKeyStatus(provider string) string
- func EstimateCost(pack *ModelPack, tokensPerSession int) float64
- func FetchModelsForProvider(provider string) ([]catalog.ModelCatalogEntry, error)
- func FishCompletion() string
- func FormatActiveRules(rules []Rule) string
- func FormatBudgetStatus(status BudgetStatus, spent, max float64) string
- func FormatConfig(config *ModelConfig) string
- func FormatPack(pack *ModelPack) string
- func FormatTemplate(template *ConfigTemplate) string
- func GenerateAgentsmd(template *ConfigTemplate, vars map[string]string) string
- func GenerateHawkConfig(template *ConfigTemplate, vars map[string]string) string
- func GenerateRules(template *ConfigTemplate) string
- func GetAPIKey(provider string) string
- func GitContext() string
- func InstallCompletions(shell string) string
- func LoadAPIKeysFromEnv() map[string]string
- func LoadAgentDir() string
- func LoadAgentsMD() string
- func LoadAgentsMDFrom(start string) string
- func LoadAliases() map[string]string
- func LoadDotEnv()
- func LoadEnvFile() error
- func LoadIgnorePatterns() []string
- func MaskAPIKey(key string) string
- func NormalizeProviderForEngine(provider string) string
- func OutputStyleModTime() time.Time
- func ParseEnvFile(path string) (map[string]string, error)
- func ProviderAPIKeyEnv(provider string) string
- func RemoveEnvFile(key string) error
- func ResolveAlias(input string, aliases map[string]string) string
- func RollbackMigration(configPath, backupPath string) error
- func SaveAliases(aliases map[string]string) error
- func SaveEnvFile(key, value string) error
- func SaveGlobal(s Settings) error
- func SaveProject(s Settings) error
- func SetGlobalSetting(key, value string) error
- func SettingValue(s Settings, key string) (string, bool)
- func ShouldIgnore(path string, patterns []string) bool
- func ValidateAPIKey(provider string) (string, bool)
- func ValidateConfig(data map[string]interface{}) []string
- func ZshCompletion() string
- type Attribution
- type BudgetConfig
- type BudgetStatus
- type ConfigTemplate
- type CustomProviderConfig
- type Distribution
- type DistroBranding
- type DistroDefaults
- type DistroExtension
- type DistroProvider
- type EnvManager
- func (em *EnvManager) Diff(other *EnvManager) []string
- func (em *EnvManager) Export(format string) string
- func (em *EnvManager) Get(key string) string
- func (em *EnvManager) GetRequired(key string) (string, error)
- func (em *EnvManager) ListForDisplay() string
- func (em *EnvManager) Load(sources ...string) error
- func (em *EnvManager) LoadProfile(name string) error
- func (em *EnvManager) MaskSecrets(text string) string
- func (em *EnvManager) SaveProfile(name string, vars []string) error
- func (em *EnvManager) Set(key, value string, secret bool)
- func (em *EnvManager) Validate() []string
- type EnvVar
- type MCPServerConfig
- type Migration
- type MigrationRegistry
- type ModelConfig
- type ModelMessage
- type ModelPack
- type ModelPackRegistry
- func (r *ModelPackRegistry) Compare(packA, packB string) string
- func (r *ModelPackRegistry) GetModel(role string) ModelRole
- func (r *ModelPackRegistry) List() []*ModelPack
- func (r *ModelPackRegistry) Load() error
- func (r *ModelPackRegistry) Register(pack *ModelPack)
- func (r *ModelPackRegistry) Save() error
- func (r *ModelPackRegistry) SetActive(packName string) error
- type ModelRole
- type ModelfileParser
- func (p *ModelfileParser) MergeConfigs(base, override *ModelConfig) *ModelConfig
- func (p *ModelfileParser) Parse(content string) (*ModelConfig, error)
- func (p *ModelfileParser) ParseFile(path string) (*ModelConfig, error)
- func (p *ModelfileParser) Render(config *ModelConfig) string
- func (p *ModelfileParser) ToProviderConfig(config *ModelConfig) map[string]interface{}
- func (p *ModelfileParser) Validate(config *ModelConfig) []string
- type OutputStyle
- type PromptTemplate
- type Rule
- type Settings
- type TemplateRegistry
- func (r *TemplateRegistry) DetectAndGenerate(projectDir string) (map[string]string, error)
- func (r *TemplateRegistry) Generate(templateName string, vars map[string]string) (map[string]string, error)
- func (r *TemplateRegistry) List() []*ConfigTemplate
- func (r *TemplateRegistry) Preview(templateName string, vars map[string]string) string
- func (r *TemplateRegistry) Register(template *ConfigTemplate)
- type ValidationError
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIKeyForProvider ¶
APIKeyForProvider reads the API key for a provider from the environment.
func AllEnvKeyStatus ¶
func AllEnvKeyStatus() string
AllEnvKeyStatus returns a comma-separated summary of all known API key env vars.
func ApplyOutputStyle ¶
func ApplyOutputStyle(content string, style OutputStyle) string
ApplyOutputStyle wraps content with the style template. The template may contain {{content}} as a placeholder for the actual content.
func BashCompletion ¶
func BashCompletion() string
BashCompletion returns a bash completion script for hawk.
func BuildContext ¶
func BuildContext() string
BuildContext assembles the full context string for the system prompt.
func BuildContextWithDirs ¶
BuildContextWithDirs assembles context including additional user-specified directories.
func DefaultAliases ¶
DefaultAliases returns the built-in command aliases.
func DefaultIgnorePatterns ¶
func DefaultIgnorePatterns() []string
DefaultIgnorePatterns returns the built-in ignore patterns.
func DefaultModelConfigs ¶ added in v0.2.0
func DefaultModelConfigs() map[string]*ModelConfig
DefaultModelConfigs returns built-in configurations for common use cases.
func DetectVersion ¶ added in v0.2.0
DetectVersion uses heuristics to determine the config version when no config_version field is present.
func DiffConfigs ¶ added in v0.2.0
DiffConfigs returns a human-readable diff showing what changed during migration.
func EnvKeyStatus ¶
EnvKeyStatus returns "set" or "empty" for a provider's API key in the environment.
func EstimateCost ¶ added in v0.2.0
EstimateCost estimates the cost of a session with the given pack based on approximate tokens per session distributed evenly across roles.
func FetchModelsForProvider ¶
func FetchModelsForProvider(provider string) ([]catalog.ModelCatalogEntry, error)
FetchModelsForProvider fetches live models from the provider's API (if key available) or returns embedded catalog models. This is the runtime model discovery boundary.
func FishCompletion ¶
func FishCompletion() string
FishCompletion returns a fish completion script for hawk.
func FormatActiveRules ¶
FormatActiveRules formats active rules for injection into the system prompt.
func FormatBudgetStatus ¶
func FormatBudgetStatus(status BudgetStatus, spent, max float64) string
FormatBudgetStatus returns a human-readable string describing the budget status.
func FormatConfig ¶ added in v0.2.0
func FormatConfig(config *ModelConfig) string
FormatConfig produces a human-readable summary of a ModelConfig.
func FormatPack ¶ added in v0.2.0
FormatPack returns a human-readable formatted string for a model pack.
func FormatTemplate ¶ added in v0.2.0
func FormatTemplate(template *ConfigTemplate) string
FormatTemplate returns a human-readable summary of a template.
func GenerateAgentsmd ¶ added in v0.2.0
func GenerateAgentsmd(template *ConfigTemplate, vars map[string]string) string
GenerateAgentsmd generates AGENTS.md content from a template.
func GenerateHawkConfig ¶ added in v0.2.0
func GenerateHawkConfig(template *ConfigTemplate, vars map[string]string) string
GenerateHawkConfig generates .hawk/settings.json content from a template.
func GenerateRules ¶ added in v0.2.0
func GenerateRules(template *ConfigTemplate) string
GenerateRules generates .hawk/rules permission file content from a template.
func GetAPIKey ¶
GetAPIKey returns the API key for a provider, checking multiple sources. Delegates to ProviderAPIKeyEnv (settings.go) as the single source of truth for provider→env-var mappings, with fallback aliases for compatibility.
func InstallCompletions ¶
InstallCompletions returns instructions for installing shell completions.
func LoadAPIKeysFromEnv ¶
LoadAPIKeysFromEnv reads all known API keys from environment variables.
func LoadAgentDir ¶
func LoadAgentDir() string
LoadAgentDir returns the path to .hawk/ or .agent/ directory, whichever exists. .hawk/ takes priority. Returns empty string if neither exists.
func LoadAgentsMD ¶
func LoadAgentsMD() string
LoadAgentsMD reads AGENTS.md (or AGENTS.md for backward compatibility) from the current directory or parents.
func LoadAgentsMDFrom ¶
LoadAgentsMDFrom reads AGENTS.md (or AGENTS.md fallback) from start or its parents.
func LoadAliases ¶
LoadAliases reads command aliases from ~/.hawk/aliases.json. Returns default aliases if the file does not exist.
func LoadDotEnv ¶
func LoadDotEnv()
LoadDotEnv loads environment variables from .env files. Checks in order: .env, .env.local (project), then ~/.hawk/.env (global). Does NOT override existing environment variables.
func LoadEnvFile ¶
func LoadEnvFile() error
LoadEnvFile reads ~/.hawk/env and applies export lines to the process.
func LoadIgnorePatterns ¶
func LoadIgnorePatterns() []string
LoadIgnorePatterns reads ignore patterns from .hawkignore or .hawk/ignore. Falls back to default patterns if neither file exists.
func MaskAPIKey ¶
MaskAPIKey returns a masked version of an API key for display.
func NormalizeProviderForEngine ¶
NormalizeProviderForEngine maps hawk provider aliases to eyrie canonical names. This is the boundary where hawk names become engine/eyrie names.
func OutputStyleModTime ¶
OutputStyleModTime returns the latest modification time of any style file, useful for cache invalidation.
func ParseEnvFile ¶ added in v0.2.0
ParseEnvFile parses a .env file and returns a map of key-value pairs. Supports: KEY=value, KEY="quoted value", KEY='single quoted', comments (#), empty lines, export prefix, and multiline values with \.
func ProviderAPIKeyEnv ¶
ProviderAPIKeyEnv returns the environment variable name for a provider's API key.
func RemoveEnvFile ¶
RemoveEnvFile removes an export line from ~/.hawk/env.
func ResolveAlias ¶
ResolveAlias checks if the first word of input matches an alias key. If found, it replaces the alias with its expansion and appends the rest of the input. If not found, returns the input unchanged.
func RollbackMigration ¶ added in v0.2.0
RollbackMigration restores a config file from its backup.
func SaveAliases ¶
SaveAliases writes command aliases to ~/.hawk/aliases.json.
func SaveEnvFile ¶
SaveEnvFile writes an export line to ~/.hawk/env, deduplicating existing entries.
func SaveGlobal ¶
SaveGlobal saves settings to the global config file.
func SaveProject ¶
SaveProject saves settings to the project config file.
func SetGlobalSetting ¶
SetGlobalSetting updates a supported scalar/list setting in ~/.hawk/settings.json. Herm-style: API keys are NOT stored in settings.json. Use environment variables.
func SettingValue ¶
SettingValue returns a display-safe value for a supported setting key.
func ShouldIgnore ¶
ShouldIgnore checks if a path matches any of the given ignore patterns. Supports gitignore-style matching:
- Simple names match any path component (e.g., "node_modules" matches "a/node_modules/b")
- Glob patterns with * are matched against the base name (e.g., "*.pyc" matches "foo.pyc")
- Paths with / are matched against the full path
func ValidateAPIKey ¶
ValidateAPIKey checks if an API key is set for the provider.
func ValidateConfig ¶ added in v0.2.0
ValidateConfig checks that a migrated config has required fields and correct types. Returns a list of warnings (empty list means valid).
func ZshCompletion ¶
func ZshCompletion() string
ZshCompletion returns a zsh completion script for hawk.
Types ¶
type Attribution ¶
type Attribution struct {
TrailerStyle string `json:"trailer_style,omitempty"` // "none", "co-authored-by", "assisted-by" (default)
GeneratedWith bool `json:"generated_with,omitempty"` // append "Generated with Hawk" line
}
Attribution controls how hawk identifies itself in git commits.
type BudgetConfig ¶
type BudgetConfig struct {
MaxCostUSD float64 `json:"max_cost_usd"`
MaxTokensPerSession int `json:"max_tokens_per_session"`
WarnAtPercent float64 `json:"warn_at_percent"` // 0-100, default 80
}
BudgetConfig holds cost and token budget settings.
func DefaultBudgetConfig ¶
func DefaultBudgetConfig() BudgetConfig
DefaultBudgetConfig returns a BudgetConfig with sensible defaults.
func LoadBudget ¶
func LoadBudget() BudgetConfig
LoadBudget loads budget configuration from settings. It reads MaxBudgetUSD from the global settings and applies defaults.
type BudgetStatus ¶
type BudgetStatus int
BudgetStatus represents the current budget state.
const ( BudgetOK BudgetStatus = iota // within budget BudgetWarning // approaching limit BudgetExceeded // over limit )
func CheckBudget ¶
func CheckBudget(spent float64, config BudgetConfig) BudgetStatus
CheckBudget evaluates current spending against the budget config. Returns BudgetOK, BudgetWarning, or BudgetExceeded.
func (BudgetStatus) String ¶
func (s BudgetStatus) String() string
String returns a human-readable budget status.
type ConfigTemplate ¶ added in v0.2.0
type ConfigTemplate struct {
Name string `json:"name"`
Description string `json:"description"`
Language string `json:"language"`
Framework string `json:"framework"`
Content map[string]interface{} `json:"content"`
Files map[string]string `json:"files"` // additional files to generate
Tags []string `json:"tags"`
}
ConfigTemplate defines a project configuration template that generates hawk-specific files based on detected project characteristics.
type CustomProviderConfig ¶
type CustomProviderConfig struct {
Name string `json:"name"`
BaseURL string `json:"base_url"`
APIKeyEnv string `json:"api_key_env,omitempty"`
Model string `json:"model,omitempty"`
}
CustomProviderConfig defines a user-specified OpenAI-compatible provider.
type Distribution ¶ added in v0.2.0
type Distribution struct {
Name string `yaml:"name"`
DisplayName string `yaml:"display_name"`
Version string `yaml:"version"`
Provider DistroProvider `yaml:"provider"`
Extensions []DistroExtension `yaml:"extensions"`
Branding DistroBranding `yaml:"branding"`
Defaults DistroDefaults `yaml:"defaults"`
Recipes []string `yaml:"recipes"`
}
Distribution defines a custom hawk distribution (white-label configuration).
func FindDistribution ¶ added in v0.2.0
func FindDistribution() *Distribution
FindDistribution looks for a distribution config in standard locations.
func LoadDistribution ¶ added in v0.2.0
func LoadDistribution(path string) (*Distribution, error)
LoadDistribution reads a distribution config from a YAML file.
type DistroBranding ¶ added in v0.2.0
type DistroBranding struct {
Prompt string `yaml:"prompt"`
WelcomeMsg string `yaml:"welcome_message"`
AgentName string `yaml:"agent_name"`
Color string `yaml:"color"`
}
DistroBranding customizes the UI appearance.
type DistroDefaults ¶ added in v0.2.0
type DistroDefaults struct {
PermissionMode string `yaml:"permission_mode"`
AllowedTools []string `yaml:"allowed_tools"`
MaxTurns int `yaml:"max_turns"`
SystemPrompt string `yaml:"system_prompt"`
}
DistroDefaults sets default behavior.
type DistroExtension ¶ added in v0.2.0
type DistroExtension struct {
Name string `yaml:"name"`
Command string `yaml:"command"`
Args []string `yaml:"args"`
}
DistroExtension defines a bundled extension.
type DistroProvider ¶ added in v0.2.0
type DistroProvider struct {
Name string `yaml:"name"`
Model string `yaml:"model"`
EnvKey string `yaml:"env_key"`
}
DistroProvider configures the default LLM provider.
type EnvManager ¶ added in v0.2.0
type EnvManager struct {
Vars map[string]*EnvVar `json:"vars"`
Profiles map[string][]string `json:"profiles"`
ActiveProfile string `json:"active_profile"`
// contains filtered or unexported fields
}
EnvManager manages environment variables, profiles, and secrets.
func NewEnvManager ¶ added in v0.2.0
func NewEnvManager() *EnvManager
NewEnvManager creates a new EnvManager with initialized maps.
func (*EnvManager) Diff ¶ added in v0.2.0
func (em *EnvManager) Diff(other *EnvManager) []string
Diff returns a list of differences between this EnvManager and another.
func (*EnvManager) Export ¶ added in v0.2.0
func (em *EnvManager) Export(format string) string
Export returns the environment variables in the specified format. Supported formats: "env" (KEY=value), "json" (JSON object), "shell" (export KEY=value).
func (*EnvManager) Get ¶ added in v0.2.0
func (em *EnvManager) Get(key string) string
Get returns the value of an environment variable, or empty string if not found.
func (*EnvManager) GetRequired ¶ added in v0.2.0
func (em *EnvManager) GetRequired(key string) (string, error)
GetRequired returns the value of a required environment variable. Returns an error if the variable is not set or is empty.
func (*EnvManager) ListForDisplay ¶ added in v0.2.0
func (em *EnvManager) ListForDisplay() string
ListForDisplay returns a formatted string showing all environment variables. Secret values are partially masked; the source is displayed for each variable.
func (*EnvManager) Load ¶ added in v0.2.0
func (em *EnvManager) Load(sources ...string) error
Load reads environment variables from multiple sources in priority order. Sources are checked in order: OS environment (highest), .env, .env.local, ~/.hawk/env, then default values (lowest). Custom source paths can be provided to override the default file search order.
func (*EnvManager) LoadProfile ¶ added in v0.2.0
func (em *EnvManager) LoadProfile(name string) error
LoadProfile activates a named profile, setting its variables as active.
func (*EnvManager) MaskSecrets ¶ added in v0.2.0
func (em *EnvManager) MaskSecrets(text string) string
MaskSecrets replaces known secret values in the given text with "***".
func (*EnvManager) SaveProfile ¶ added in v0.2.0
func (em *EnvManager) SaveProfile(name string, vars []string) error
SaveProfile saves a named profile with the given list of variable keys.
func (*EnvManager) Set ¶ added in v0.2.0
func (em *EnvManager) Set(key, value string, secret bool)
Set sets an environment variable with the given key and value. If secret is true, the value will be masked in display output.
func (*EnvManager) Validate ¶ added in v0.2.0
func (em *EnvManager) Validate() []string
Validate checks that all required variables are set and returns warnings for missing optional but recommended variables.
type EnvVar ¶ added in v0.2.0
type EnvVar struct {
Key string `json:"key"`
Value string `json:"value"`
Source string `json:"source"` // "env", "file", "profile", "default"
Secret bool `json:"secret"`
Required bool `json:"required"`
Description string `json:"description,omitempty"`
}
EnvVar represents a single environment variable with metadata.
type MCPServerConfig ¶
type MCPServerConfig struct {
Name string `json:"name"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Type string `json:"type,omitempty"` // "stdio" (default), "sse", "http"
URL string `json:"url,omitempty"` // for sse/http transports
Headers map[string]string `json:"headers,omitempty"` // custom headers for sse/http
}
MCPServerConfig defines an MCP server to connect at startup.
type Migration ¶ added in v0.2.0
type Migration struct {
FromVersion int
ToVersion int
Description string
Migrate func(data map[string]interface{}) (map[string]interface{}, error)
}
Migration represents a single config version upgrade step.
type MigrationRegistry ¶ added in v0.2.0
MigrationRegistry holds all registered migrations and the current target version.
func NewMigrationRegistry ¶ added in v0.2.0
func NewMigrationRegistry() *MigrationRegistry
NewMigrationRegistry returns a registry with all default migrations registered.
func (*MigrationRegistry) Backup ¶ added in v0.2.0
func (r *MigrationRegistry) Backup(configPath string) (string, error)
Backup creates a timestamped backup of the config file before migration. Returns the path to the backup file.
func (*MigrationRegistry) MigrateFile ¶ added in v0.2.0
func (r *MigrationRegistry) MigrateFile(path string) error
MigrateFile reads a config JSON file, checks if migration is needed, creates a backup, applies migrations, and writes the updated config.
func (*MigrationRegistry) NeedsMigration ¶ added in v0.2.0
func (r *MigrationRegistry) NeedsMigration(data map[string]interface{}) bool
NeedsMigration returns true if the config data is at a version below CurrentVersion.
func (*MigrationRegistry) Run ¶ added in v0.2.0
func (r *MigrationRegistry) Run(data map[string]interface{}) (map[string]interface{}, error)
Run applies all relevant migrations sequentially from the config's current version to the registry's CurrentVersion. Each migration is atomic: if one fails, we return the error without applying further migrations.
type ModelConfig ¶ added in v0.2.0
type ModelConfig struct {
From string
Parameters map[string]interface{}
System string
Template string
Messages []ModelMessage
License string
Adapters []string
}
ModelConfig holds the parsed configuration from a Modelfile.
type ModelMessage ¶ added in v0.2.0
ModelMessage represents a conversation example in a Modelfile.
type ModelPack ¶ added in v0.2.0
type ModelPack struct {
Name string `json:"name"`
Description string `json:"description"`
Models map[string]ModelRole `json:"models"`
DefaultProvider string `json:"default_provider"`
Settings map[string]interface{} `json:"settings"`
Tags []string `json:"tags"`
Author string `json:"author"`
}
ModelPack is a named configuration that bundles model + provider + settings for different use cases.
type ModelPackRegistry ¶ added in v0.2.0
type ModelPackRegistry struct {
Packs map[string]*ModelPack `json:"packs"`
ActivePack string `json:"active_pack"`
// contains filtered or unexported fields
}
ModelPackRegistry holds all registered packs and tracks the active one.
func NewModelPackRegistry ¶ added in v0.2.0
func NewModelPackRegistry() *ModelPackRegistry
NewModelPackRegistry creates a registry pre-loaded with built-in packs.
func (*ModelPackRegistry) Compare ¶ added in v0.2.0
func (r *ModelPackRegistry) Compare(packA, packB string) string
Compare produces a side-by-side comparison of two packs.
func (*ModelPackRegistry) GetModel ¶ added in v0.2.0
func (r *ModelPackRegistry) GetModel(role string) ModelRole
GetModel returns the ModelRole for the given role from the active pack. If the role is not found, it returns a zero-value ModelRole.
func (*ModelPackRegistry) List ¶ added in v0.2.0
func (r *ModelPackRegistry) List() []*ModelPack
List returns all registered packs sorted by name.
func (*ModelPackRegistry) Load ¶ added in v0.2.0
func (r *ModelPackRegistry) Load() error
Load reads the registry from disk, merging with built-in packs.
func (*ModelPackRegistry) Register ¶ added in v0.2.0
func (r *ModelPackRegistry) Register(pack *ModelPack)
Register adds a new pack to the registry. If a pack with the same name already exists it will be overwritten.
func (*ModelPackRegistry) Save ¶ added in v0.2.0
func (r *ModelPackRegistry) Save() error
Save persists the registry to disk as JSON.
func (*ModelPackRegistry) SetActive ¶ added in v0.2.0
func (r *ModelPackRegistry) SetActive(packName string) error
SetActive switches the active pack. Returns an error if the pack does not exist.
type ModelRole ¶ added in v0.2.0
type ModelRole struct {
Provider string `json:"provider"`
Model string `json:"model"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
Purpose string `json:"purpose"`
}
ModelRole defines a model configuration for a specific role within a pack.
type ModelfileParser ¶ added in v0.2.0
type ModelfileParser struct {
// contains filtered or unexported fields
}
ModelfileParser parses Modelfile DSL content into ModelConfig.
func NewModelfileParser ¶ added in v0.2.0
func NewModelfileParser() *ModelfileParser
NewModelfileParser creates a new ModelfileParser instance.
func (*ModelfileParser) MergeConfigs ¶ added in v0.2.0
func (p *ModelfileParser) MergeConfigs(base, override *ModelConfig) *ModelConfig
MergeConfigs merges override into base. Override takes precedence for same parameters.
func (*ModelfileParser) Parse ¶ added in v0.2.0
func (p *ModelfileParser) Parse(content string) (*ModelConfig, error)
Parse parses Modelfile DSL content and returns a ModelConfig.
func (*ModelfileParser) ParseFile ¶ added in v0.2.0
func (p *ModelfileParser) ParseFile(path string) (*ModelConfig, error)
ParseFile reads a Modelfile from disk and parses it.
func (*ModelfileParser) Render ¶ added in v0.2.0
func (p *ModelfileParser) Render(config *ModelConfig) string
Render converts a ModelConfig back into Modelfile format.
func (*ModelfileParser) ToProviderConfig ¶ added in v0.2.0
func (p *ModelfileParser) ToProviderConfig(config *ModelConfig) map[string]interface{}
ToProviderConfig converts a ModelConfig into an eyrie-compatible provider configuration map.
func (*ModelfileParser) Validate ¶ added in v0.2.0
func (p *ModelfileParser) Validate(config *ModelConfig) []string
Validate checks the ModelConfig for errors and returns a list of issues.
type OutputStyle ¶
OutputStyle defines a custom output format loaded from a markdown file.
func LoadOutputStyles ¶
func LoadOutputStyles() []OutputStyle
LoadOutputStyles loads .md files from .hawk/output-styles/ (project-local) and ~/.hawk/output-styles/ (global), merging both. Project-local styles take priority over global styles with the same name.
type PromptTemplate ¶
type PromptTemplate struct {
Name string `json:"name"`
Template string `json:"template"`
Args []string `json:"args,omitempty"`
}
PromptTemplate is a reusable prompt template.
func LoadTemplates ¶
func LoadTemplates() []PromptTemplate
LoadTemplates loads prompt templates from ~/.hawk/templates/.
type Rule ¶
type Rule struct {
Name string
Content string
Paths []string // glob patterns; empty = always active
}
Rule represents a project rule loaded from .hawk/rules/*.md.
func ActiveRules ¶
ActiveRules filters rules to those whose Paths match any of the touchedPaths. Rules with empty Paths are always active.
func LoadRules ¶
func LoadRules() []Rule
LoadRules reads all .md files from .hawk/rules/ in the current directory. Each file can have optional YAML frontmatter with a paths field.
func LoadRulesFrom ¶
LoadRulesFrom reads rules from .hawk/rules/ under the given directory.
type Settings ¶
type Settings struct {
Model string `json:"model,omitempty"`
Provider string `json:"provider,omitempty"`
Theme string `json:"theme,omitempty"`
AutoAllow []string `json:"auto_allow,omitempty"` // tools to always allow
AllowedTools []string `json:"allowedTools,omitempty"` // archive-compatible allow rules
DisallowedTools []string `json:"disallowedTools,omitempty"` // archive-compatible deny rules
MaxBudgetUSD float64 `json:"max_budget_usd,omitempty"` // cost cap per session
CustomHeaders map[string]string `json:"custom_headers,omitempty"`
MCPServers []MCPServerConfig `json:"mcp_servers,omitempty"`
CustomProviders []CustomProviderConfig `json:"custom_providers,omitempty"`
RepoMap *bool `json:"repo_map,omitempty"`
RepoMapMaxTokens int `json:"repo_map_max_tokens,omitempty"`
Sandbox string `json:"sandbox,omitempty"` // sandbox mode: strict, workspace, off
AutoCommit *bool `json:"auto_commit,omitempty"` // auto-commit file changes
Autonomy int `json:"autonomy,omitempty"` // autonomy level 0-4
ModelRoles *routing.ModelRoles `json:"model_roles,omitempty"` // per-role model overrides
AutoCompactThresholdPct int `json:"auto_compact_threshold_pct,omitempty"` // token % to trigger auto-compact (default 85)
Frugal bool `json:"frugal,omitempty"` // aggressive cost optimization: cascade to cheap models, lower max_tokens, earlier compaction
Attribution *Attribution `json:"attribution,omitempty"`
}
Settings holds hawk configuration. Herm-style: no API keys stored here. Secrets come from environment variables only.
func LoadGlobalSettings ¶
func LoadGlobalSettings() Settings
LoadGlobalSettings loads only ~/.hawk/settings.json.
func LoadSettings ¶
func LoadSettings() Settings
LoadSettings loads settings from global + project, with project overriding global.
func LoadSettingsWithOverride ¶
LoadSettingsWithOverride loads normal settings plus a JSON object or JSON file override.
func MergeSettings ¶
MergeSettings applies override fields on top of base using project-style precedence.
func (*Settings) UnmarshalJSON ¶
UnmarshalJSON accepts both Go-era snake_case keys and archive-style camelCase keys.
type TemplateRegistry ¶ added in v0.2.0
type TemplateRegistry struct {
Templates map[string]*ConfigTemplate
// contains filtered or unexported fields
}
TemplateRegistry manages configuration templates.
func NewTemplateRegistry ¶ added in v0.2.0
func NewTemplateRegistry() *TemplateRegistry
NewTemplateRegistry creates a registry pre-loaded with built-in templates.
func (*TemplateRegistry) DetectAndGenerate ¶ added in v0.2.0
func (r *TemplateRegistry) DetectAndGenerate(projectDir string) (map[string]string, error)
DetectAndGenerate auto-detects the project type from projectDir, selects the best matching template, and generates configs.
func (*TemplateRegistry) Generate ¶ added in v0.2.0
func (r *TemplateRegistry) Generate(templateName string, vars map[string]string) (map[string]string, error)
Generate creates all config files from the named template with variable substitution.
func (*TemplateRegistry) List ¶ added in v0.2.0
func (r *TemplateRegistry) List() []*ConfigTemplate
List returns all registered templates sorted by name.
func (*TemplateRegistry) Preview ¶ added in v0.2.0
func (r *TemplateRegistry) Preview(templateName string, vars map[string]string) string
Preview shows what files would be generated without writing them.
func (*TemplateRegistry) Register ¶ added in v0.2.0
func (r *TemplateRegistry) Register(template *ConfigTemplate)
Register adds a new template to the registry.
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Message string `json:"message"`
Value string `json:"value,omitempty"`
}
ValidationError represents a config validation error.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type ValidationResult ¶
type ValidationResult struct {
Errors []ValidationError `json:"errors"`
Valid bool `json:"valid"`
}
ValidationResult contains all validation errors.
func ValidateSettings ¶
func ValidateSettings(s Settings) ValidationResult
ValidateSettings validates a Settings object.
func (ValidationResult) Error ¶
func (r ValidationResult) Error() string
Error returns a formatted error string.