resources

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package builtin bundles embedded resources (skills, souls, sub-agents, templates) that Anna ships with its binary. Runtime code accesses them through Registry, not by walking the filesystem directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBuiltinSkills

func EnsureBuiltinSkills(skillsDir string) error

EnsureBuiltinSkills extracts builtin skills once per (process, skillsDir) for callers that need a lazy, idempotent fallback outside normal app startup.

func ExtractSkills

func ExtractSkills(skillsDir string) error

ExtractSkills writes every builtin skill directory into skillsDir. Each detected skill root (including nested paths like system/foo) is replaced atomically; other entries in skillsDir are preserved.

func ExtractSubAgents

func ExtractSubAgents(agentsDir string) error

ExtractSubAgents writes builtin sub-agent preset files into agentsDir. Individual files are overwritten; other content in agentsDir is preserved.

func FS

func FS() fs.FS

FS returns the full embedded filesystem rooted at the package directory. Prefer SubFS for kind-scoped access.

func SubFS

func SubFS(kind Kind) (fs.FS, bool)

SubFS returns the embedded filesystem scoped to a single Kind's subdirectory. Empty (nil, false) when the kind has no known subdir.

Types

type Kind

type Kind string

Kind identifies a builtin resource category.

const (
	KindSkill    Kind = "skill"
	KindSoul     Kind = "soul"
	KindSubAgent Kind = "subagent"
	KindTemplate Kind = "template"
)

func AllKinds

func AllKinds() []Kind

AllKinds lists every supported kind.

type Registry

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

Registry is the read-only catalog of builtin resources, keyed by Kind and ID.

func Default

func Default() (*Registry, error)

Default returns the process-wide registry, loaded lazily from the embedded FS.

func Load

func Load(sourceFS fs.FS) (*Registry, error)

Load walks sourceFS and parses every supported resource kind it finds. sourceFS must have subdirectories matching Kind.subdir() for each kind to load. Missing subdirectories are silently skipped (useful for tests with partial fixtures).

func (*Registry) Get

func (r *Registry) Get(kind Kind, id string) (Resource, bool)

Get fetches a single resource by kind and ID.

func (*Registry) Kinds

func (r *Registry) Kinds() []Kind

Kinds returns the set of kinds that have at least one loaded resource.

func (*Registry) List

func (r *Registry) List(kind Kind) []Resource

List returns all resources of the given kind, sorted by ID for determinism.

type Resource

type Resource struct {
	Kind        Kind
	ID          string
	Name        string
	Description string
	Tags        []string
	Metadata    map[string]any
	Content     string
	Hash        string
}

Resource is one builtin entry of a given Kind. Content is the markdown body with frontmatter stripped. Metadata holds kind-specific frontmatter fields (anything beyond name/description/tags).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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