bf0b67f9af
New additive, nil-safe battery for subscribing to skill packages in the Anthropic agent-skills format (SKILL.md manifest + bundled files): - Manifest/ParseManifest: SKILL.md frontmatter+body parse & validation (name/description required, allowed-tools passthrough, kebab/length limits) - Tree/Pack/LoadPack: self-contained file set, order-independent content digest (the pin identity + change signal), bundled-file listing, traversal- safe staging - Source (DirSource, GitSource): Fetch returns tree + resolved ref; git clones to temp, reads subpath into memory, cleans up (self-contained tree) - Subscription + Store + content-addressed PackCache, with Memory defaults - Syncer: Subscribe pins; Check records a PENDING update but never moves the pin; Apply is the only re-pin (supply-chain guard — upstream can't silently change what an agent runs) - Activate: resolved packs -> majordomo agent.Skill (catalog instructions + one skill_use tool) for progressive disclosure; Stage materializes files Third distinct 'skill' concept, deliberately separate from executus/skill (saved-agent noun) and majordomo/skill (eager capability bundle). Mort-side wiring (convars, .skillpack commands, Agent.SkillPacks, allowed-tools shim) is a later, separate step. Full unit + hermetic local-git tests; gofmt/vet clean; race-tested. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
2.8 KiB
Go
55 lines
2.8 KiB
Go
// Package skillpack is the SKILL.md-subscription battery: it lets an agent host
|
|
// subscribe to skill packages published as directories/git repos in the
|
|
// Anthropic "agent skills" format (a SKILL.md manifest plus optional bundled
|
|
// scripts and reference files) and activate them for a run with progressive
|
|
// disclosure.
|
|
//
|
|
// It is a THIRD, distinct concept from the two "skill" nouns already in the
|
|
// stack — do not conflate them:
|
|
//
|
|
// - majordomo/skill — a lightweight capability bundle (instructions + tools)
|
|
// appended to an agent eagerly at construction.
|
|
// - executus/skill — a heavyweight persisted "saved agent" noun.
|
|
// - executus/skillpack (this package) — an externally-authored, versioned,
|
|
// on-demand-loaded instruction pack fetched from a Source and pinned by
|
|
// content digest.
|
|
//
|
|
// Progressive disclosure is the reason this is not just a majordomo/skill:
|
|
// majordomo skills inject their whole instruction text into the system prompt
|
|
// up front, which does not scale to a catalog of large third-party packs. Here
|
|
// only each pack's name+description sits in the prompt permanently (the
|
|
// Catalog); the full body is loaded lazily when the model calls the single
|
|
// skill_use tool (see Activate).
|
|
//
|
|
// Design shape (each piece is nil-safe / host-agnostic, mirroring the other
|
|
// executus batteries):
|
|
//
|
|
// - Manifest / ParseManifest — parse+validate a SKILL.md.
|
|
// - Tree / Pack / LoadPack — a fetched pack's files, content digest, and
|
|
// parsed manifest.
|
|
// - Source (Dir, Git) — where packs come from; Fetch returns the file
|
|
// tree and the source's resolved ref.
|
|
// - Subscription + Store — the persisted "this host tracks this pack at
|
|
// this pinned digest" record; Memory is the zero-dep default.
|
|
// - PackCache — content-addressed store of pinned pack trees
|
|
// so activation never re-fetches; Memory default.
|
|
// - Syncer — checks the tracked ref and records a PENDING
|
|
// update; applying it is an explicit, separate re-pin (supply-chain guard —
|
|
// upstream can never silently change what an agent runs).
|
|
// - Catalog / Activate / Stage — turn a set of resolved packs into a
|
|
// majordomo agent.Skill (catalog instructions + skill_use tool) and
|
|
// materialize a pack's files for a sandbox.
|
|
//
|
|
// The host (e.g. mort) supplies policy: which sources are allowed, who may
|
|
// subscribe, and where staged files are mounted. This package supplies only the
|
|
// mechanism.
|
|
package skillpack
|
|
|
|
import "errors"
|
|
|
|
// ErrNotFound is returned when a subscription or cached pack lookup misses.
|
|
var ErrNotFound = errors.New("skillpack: not found")
|
|
|
|
// ErrNoManifest is returned when a fetched tree has no SKILL.md at its root.
|
|
var ErrNoManifest = errors.New("skillpack: tree has no SKILL.md")
|