agent

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package agent loads and validates Prism agent specifications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry loads and caches agent specs from a directory.

func NewRegistry

func NewRegistry(dir string) *Registry

NewRegistry creates a Registry that reads specs from dir.

func (*Registry) Get

func (r *Registry) Get(agentID string) (*Spec, error)

Get returns the Spec for agentID or a descriptive error.

func (*Registry) List

func (r *Registry) List() []Summary

List returns all agent summaries sorted by ID.

func (*Registry) Load

func (r *Registry) Load() error

Load scans dir for *.md files and parses them as agent specs. README.md and directories are silently skipped. Any parsing or validation error causes Load to return immediately.

type Spec

type Spec struct {
	// Required frontmatter fields.
	ID              string   `yaml:"id"               json:"id"`
	Name            string   `yaml:"name"             json:"name"`
	Description     string   `yaml:"description"      json:"description"`
	Model           string   `yaml:"model"            json:"model"`
	ContextBudget   int      `yaml:"context_budget"   json:"context_budget"`
	AllowedSkills   []string `yaml:"allowed_skills"   json:"allowed_skills"`
	LatencyBudgetMS int      `yaml:"latency_budget_ms" json:"latency_budget_ms"`

	// Recommended frontmatter fields.
	Temperature      float64  `yaml:"temperature"       json:"temperature,omitempty"`
	Tools            []string `yaml:"tools"             json:"tools,omitempty"`
	Outputs          string   `yaml:"outputs"           json:"outputs,omitempty"`
	ConstitutionPath string   `yaml:"constitution_path" json:"constitution_path,omitempty"`

	// Optional frontmatter fields.
	Models      []string          `yaml:"models"      json:"models,omitempty"`
	TokenBudget int               `yaml:"token_budget" json:"token_budget,omitempty"`
	Metadata    map[string]string `yaml:"metadata"    json:"metadata,omitempty"`

	// Body is the Markdown text after the closing frontmatter delimiter.
	// It serves as the inline constitution when ConstitutionPath is empty.
	Body string `yaml:"-" json:"body,omitempty"`
}

Spec holds the parsed YAML frontmatter and Markdown body of an agent file.

func Parse

func Parse(data []byte, sourcePath string) (*Spec, error)

Parse parses raw bytes that begin with a YAML frontmatter block delimited by "---". The sourcePath is used only for error messages and id-stem validation.

func ParseFile

func ParseFile(path string) (*Spec, error)

ParseFile reads a Markdown+frontmatter agent spec file from path.

func (*Spec) AllowsSkill

func (s *Spec) AllowsSkill(name string) bool

AllowsSkill reports whether the named skill is in the agent's allowed_skills.

func (*Spec) ResolveConstitution

func (s *Spec) ResolveConstitution(rootDir string) (text, source string, err error)

ResolveConstitution returns the constitution text for this agent following a three-priority chain:

  1. constitution_path field (resolved relative to rootDir)
  2. inline spec body (Markdown after the frontmatter block)
  3. legacy constitutions/<id>.md (relative to rootDir)

The second return value names the source: "path", "body", or "legacy".

func (*Spec) ToSummary

func (s *Spec) ToSummary() Summary

ToSummary returns a lightweight view of the spec.

type Summary

type Summary struct {
	ID              string   `json:"id"`
	Name            string   `json:"name"`
	Description     string   `json:"description"`
	Model           string   `json:"model"`
	AllowedSkills   []string `json:"allowed_skills,omitempty"`
	LatencyBudgetMS int      `json:"latency_budget_ms,omitempty"`
}

Summary is a lightweight agent descriptor suitable for list output.

Jump to

Keyboard shortcuts

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