agents

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSystemPrompt added in v0.2.0

func BuildSystemPrompt(persona *Persona, projectContext string) string

BuildSystemPrompt constructs a full system prompt by combining the persona's configuration with project-specific context.

func DefaultDir

func DefaultDir() string

DefaultDir returns the user's agent directory (~/.hawk/agents/).

func RenderPersonaFile added in v0.2.0

func RenderPersonaFile(persona *Persona) string

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/agents/.

func Get

func Get(name string) (*Agent, error)

Get finds an agent by name from all known directories.

func ListAll

func ListAll() ([]*Agent, error)

ListAll discovers all agent definitions from the standard directories. Search order: ~/.hawk/agents/, .hawk/agents/ (project-local).

func Load

func Load(path string) (*Agent, error)

Load reads an agent definition from a markdown file. Format:

---
name: reviewer
description: Code review specialist
model: inherit
---
You are a code reviewer...

func Parse

func Parse(content, filePath string) (*Agent, error)

Parse extracts agent metadata and prompt from markdown content.

type Persona added in v0.2.0

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"`
	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"`
}

Persona represents an enhanced agent definition with specific skills, model preferences, and behavioral configuration.

func BuiltinPersonas added in v0.2.0

func BuiltinPersonas() []*Persona

BuiltinPersonas returns the set of built-in personas that are auto-created on first run.

func ParsePersonaFile added in v0.2.0

func ParsePersonaFile(path string) (*Persona, error)

ParsePersonaFile reads a persona definition from a markdown file with YAML frontmatter.

type PersonaExample added in v0.2.0

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 PersonaRegistry added in v0.2.0

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 added in v0.2.0

func NewPersonaRegistry(dir string) *PersonaRegistry

NewPersonaRegistry creates a new registry with the given storage directory. If dir is empty, it defaults to ~/.hawk/agents/.

func (*PersonaRegistry) Create added in v0.2.0

func (r *PersonaRegistry) Create(persona *Persona) error

Create saves a new persona to disk and adds it to the registry.

func (*PersonaRegistry) Delete added in v0.2.0

func (r *PersonaRegistry) Delete(name string) error

Delete removes a persona from the registry and disk.

func (*PersonaRegistry) EnsureBuiltins added in v0.2.0

func (r *PersonaRegistry) EnsureBuiltins() error

EnsureBuiltins creates the built-in personas in the directory if they do not exist.

func (*PersonaRegistry) Get added in v0.2.0

func (r *PersonaRegistry) Get(name string) (*Persona, error)

Get retrieves a persona by name.

func (*PersonaRegistry) List added in v0.2.0

func (r *PersonaRegistry) List() []*Persona

List returns all personas sorted by name.

func (*PersonaRegistry) LoadAll added in v0.2.0

func (r *PersonaRegistry) LoadAll() error

LoadAll reads all .md files from the registry directory and populates the Personas map.

func (*PersonaRegistry) SelectPersona added in v0.2.0

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.

Jump to

Keyboard shortcuts

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