Documentation
¶
Index ¶
- func BuildSystemPrompt(persona *Persona, projectContext string) string
- func DefaultDir() string
- func ParseAgentsYAML(data []byte) (map[string]YAMLAgentSpec, error)
- func ParseTasksYAML(data []byte) (map[string]YAMLTaskSpec, error)
- func PersonasFromYAML(dir string) (map[string]*Persona, error)
- func RenderPersonaFile(persona *Persona) string
- type Agent
- type Persona
- type PersonaExample
- type PersonaHooks
- type PersonaRegistry
- func (r *PersonaRegistry) Create(persona *Persona) error
- func (r *PersonaRegistry) Delete(name string) error
- func (r *PersonaRegistry) EnsureBuiltins() error
- func (r *PersonaRegistry) EnsureCavecrew() error
- func (r *PersonaRegistry) Get(name string) (*Persona, error)
- func (r *PersonaRegistry) List() []*Persona
- func (r *PersonaRegistry) LoadAll() error
- func (r *PersonaRegistry) LoadYAMLInto(dir string, overwrite bool) (int, error)
- func (r *PersonaRegistry) SelectPersona(task string) *Persona
- type YAMLAgentSpec
- type YAMLConfig
- type YAMLTaskSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSystemPrompt ¶
BuildSystemPrompt constructs a full system prompt by combining the persona's configuration with project-specific context.
func ParseAgentsYAML ¶
func ParseAgentsYAML(data []byte) (map[string]YAMLAgentSpec, error)
ParseAgentsYAML parses the contents of an agents.yaml file.
func ParseTasksYAML ¶
func ParseTasksYAML(data []byte) (map[string]YAMLTaskSpec, error)
ParseTasksYAML parses the contents of a tasks.yaml file.
func PersonasFromYAML ¶
PersonasFromYAML loads agents.yaml from dir and returns the resulting personas keyed by name. Returns an empty map (not an error) when the file is absent.
func RenderPersonaFile ¶
RenderPersonaFile generates a markdown file with YAML frontmatter from a Persona.
Types ¶
type Agent ¶
type Agent struct {
Name string `json:"name"`
Description string `json:"description"`
Model string `json:"model,omitempty"`
Prompt string `json:"prompt"`
FilePath string `json:"file_path"`
}
Agent is a user-defined persona with a custom system prompt. Stored as markdown files with YAML frontmatter in Hawk user state.
type Persona ¶
type Persona struct {
Name string `json:"name"`
Description string `json:"description"`
Model string `json:"model"`
Provider string `json:"provider"`
SystemPrompt string `json:"system_prompt"`
Tools []string `json:"tools"`
ExcludedTools []string `json:"excluded_tools"`
// ReadOnly declares that this persona must never mutate the workspace. It is
// a machine-readable contract (stronger than listing Edit/Write in
// ExcludedTools, since it also forbids mutation via Bash): orchestrators
// should run a ReadOnly persona with a read-only tool registry. Used by the
// validation half of an implement-then-validate agent pair.
ReadOnly bool `json:"read_only,omitempty"`
Temperature float64 `json:"temperature"`
MaxTokens int `json:"max_tokens"`
Expertise []string `json:"expertise"`
CommunicationStyle string `json:"communication_style"`
Rules []string `json:"rules"`
Examples []PersonaExample `json:"examples"`
CreatedAt time.Time `json:"created_at"`
UsageCount int `json:"usage_count"`
SuccessRate float64 `json:"success_rate"`
// Color is an optional display color for the persona (e.g. "blue",
// "#ff8800"), used by UIs to distinguish agents. Mirrors Claude Code's
// per-agent color frontmatter field.
Color string `json:"color,omitempty"`
// Hooks maps lifecycle event names (e.g. "pre_run", "post_run") to a
// shell command or handler string to invoke for this agent. Mirrors
// Claude Code's per-agent hooks.
Hooks PersonaHooks `json:"hooks,omitempty"`
}
Persona represents an enhanced agent definition with specific skills, model preferences, and behavioral configuration.
func BuiltinPersonas ¶
func BuiltinPersonas() []*Persona
BuiltinPersonas returns the set of built-in personas that are auto-created on first run.
func CavecrewPersonas ¶
func CavecrewPersonas() []*Persona
CavecrewPersonas returns just the three cavecrew personas (investigator, builder, reviewer) built into GrayCode Hawk. These are a strict, format-driven subset of the full BuiltinPersonas list; callers that want only the cavecrew subset can use this function instead of BuiltinPersonas.
func ParsePersonaFile ¶
ParsePersonaFile reads a persona definition from a markdown file with YAML frontmatter.
type PersonaExample ¶
type PersonaExample struct {
Input string `json:"input"`
Output string `json:"output"`
Context string `json:"context"`
}
PersonaExample stores an input/output example for few-shot prompting.
type PersonaHooks ¶
PersonaHooks maps a lifecycle event name to the command/handler to run. Common keys include "pre_run", "post_run", and "on_error", but any key is permitted so the set can grow without breaking the loader.
type PersonaRegistry ¶
type PersonaRegistry struct {
Personas map[string]*Persona
Dir string
// contains filtered or unexported fields
}
PersonaRegistry manages a collection of personas loaded from disk.
func NewPersonaRegistry ¶
func NewPersonaRegistry(dir string) *PersonaRegistry
NewPersonaRegistry creates a new registry with the given storage directory. If dir is empty, it defaults to Hawk's user state agents directory.
func (*PersonaRegistry) Create ¶
func (r *PersonaRegistry) Create(persona *Persona) error
Create saves a new persona to disk and adds it to the registry.
func (*PersonaRegistry) Delete ¶
func (r *PersonaRegistry) Delete(name string) error
Delete removes a persona from the registry and disk.
func (*PersonaRegistry) EnsureBuiltins ¶
func (r *PersonaRegistry) EnsureBuiltins() error
EnsureBuiltins creates the built-in personas in the directory if they do not exist.
func (*PersonaRegistry) EnsureCavecrew ¶
func (r *PersonaRegistry) EnsureCavecrew() error
EnsureCavecrew creates just the three cavecrew personas (investigator, builder, reviewer) if they do not exist. Callers who want only the compact-format-driven subset can call this instead of EnsureBuiltins.
Cavecrew personas are already part of BuiltinPersonas, so calling this is a no-op after EnsureBuiltins has run.
func (*PersonaRegistry) Get ¶
func (r *PersonaRegistry) Get(name string) (*Persona, error)
Get retrieves a persona by name.
func (*PersonaRegistry) List ¶
func (r *PersonaRegistry) List() []*Persona
List returns all personas sorted by name.
func (*PersonaRegistry) LoadAll ¶
func (r *PersonaRegistry) LoadAll() error
LoadAll reads all .md files from the registry directory and populates the Personas map.
func (*PersonaRegistry) LoadYAMLInto ¶
func (r *PersonaRegistry) LoadYAMLInto(dir string, overwrite bool) (int, error)
LoadYAMLInto loads CrewAI-style agents.yaml from dir and merges the resulting personas into the registry. Existing personas with the same name are NOT overwritten unless overwrite is true, so markdown personas take precedence by default. Returns the number of personas added.
func (*PersonaRegistry) SelectPersona ¶
func (r *PersonaRegistry) SelectPersona(task string) *Persona
SelectPersona automatically selects the best persona for a given task by matching keywords in the task description against persona expertise.
type YAMLAgentSpec ¶
type YAMLAgentSpec struct {
Role string `yaml:"role"`
Goal string `yaml:"goal"`
Backstory string `yaml:"backstory"`
LLM string `yaml:"llm"`
Model string `yaml:"model"` // alias for LLM
Provider string `yaml:"provider"`
Tools []string `yaml:"tools"`
}
YAMLAgentSpec is the CrewAI-style description of a single agent. All fields are optional so partially specified files still load.
func (YAMLAgentSpec) ToPersona ¶
func (s YAMLAgentSpec) ToPersona(name string) *Persona
ToPersona converts a CrewAI-style YAML agent spec into a Persona. The agent key from the YAML map becomes the persona Name. role/goal/backstory are assembled into a SystemPrompt mirroring CrewAI's prompt template.
type YAMLConfig ¶
type YAMLConfig struct {
Agents map[string]YAMLAgentSpec
Tasks map[string]YAMLTaskSpec
}
YAMLConfig is the parsed result of loading agents.yaml and tasks.yaml.
func LoadYAMLConfig ¶
func LoadYAMLConfig(dir string) (*YAMLConfig, error)
LoadYAMLConfig loads agents.yaml and tasks.yaml from dir. Missing files are treated as empty (not an error); only malformed YAML is reported.