agent

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 an fs.FS.

func NewRegistry

func NewRegistry(fsys fs.FS) *Registry

NewRegistry creates a Registry that reads specs from fsys. The FS should be the agents directory (or a sub-FS of the project root at "agents"). For a local directory: agent.NewRegistry(os.DirFS(agentDir)) For GitHub: agent.NewRegistry(fs.Sub(githubFS, "agents"))

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 the FS root for *.md files and parses them as agent specs. README.md and directory entries 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 (*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(fsys fs.FS) (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 the FS root)
  2. inline spec body (Markdown after the frontmatter block)
  3. legacy constitutions/<id>.md (relative to the FS root)

The second return value names the source: "path", "body", or "legacy". fsys should be the project root FS (not the agents sub-FS).

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