agentskill

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package agentskill installs and inspects the bundled Korbit Agent Skill on disk. The skill content travels inside the binary as an embedded fs.FS (rooted at the skill directory, with SKILL.md at the top); this package writes it into an agent's skills directory and reports whether an on-disk copy matches the embedded one.

It is deliberately frontend-agnostic — no cobra, no output contract, no program name. It takes an fs.FS plus target directories and returns plain data and errors; the cli layer resolves directories, dispatches, and formats (the same split the sandbox command group uses). Drift is detected by a content hash over the file set, so there is no version field to bump and no sidecar marker file to keep in sync: the embedded copy in the running binary is the single source of truth.

Index

Constants

View Source
const SkillBinary = "korbit"

SkillBinary is the command name the bundled skill tells agents to run. It is intentionally separate from the running executable name: the binary can be invoked through another filename such as "korbit-cli", while the installed skill contains literal `korbit ...` commands. Doctor and command metadata must describe the command the skill actually executes.

View Source
const SkillName = "korbit"

SkillName is the directory name the skill installs under inside an agent's skills directory (…/skills/korbit). It matches the embedded source's root dir.

Variables

View Source
var Agents = []Agent{
	{ID: "claude", Name: "Claude", SkillRel: []string{".claude", "skills"}, ConfigRel: []string{".claude"}},
	{ID: "codex", Name: "Codex", SkillRel: []string{".agents", "skills"}, ConfigRel: []string{".codex"}},
}

Agents is the supported set, in display order.

Functions

func ContentHash

func ContentHash(fsys fs.FS) (string, error)

ContentHash is a stable digest over a skill file tree (the embedded source or an installed copy): every regular file's path, length, and bytes, in sorted path order. Two trees with identical files hash equal regardless of walk order or timestamps, so it is the drift check between the embedded copy and an on-disk one. Returned short (16 hex chars) — collision risk is irrelevant for "are these the same files".

func DirHash

func DirHash(dir string) (string, error)

DirHash is ContentHash over an installed copy on disk.

func GuideContent

func GuideContent(fsys fs.FS, topic string) (string, error)

GuideContent returns the readable guide text for a topic: the empty topic is the SKILL.md overview with its skill-system YAML frontmatter stripped (that block is trigger metadata for the skill loader, not guidance), and any other topic t is references/<t>.md verbatim. The topic must be one that GuideTopics advertises — anything else is an error naming the valid topics, so the caller (or the model) can recover. Validating against the discovered set (rather than constructing a path from the raw input) keeps "advertised == served" true by construction and leaves no room for a path to escape the references directory.

func GuideTopics

func GuideTopics(fsys fs.FS) ([]string, error)

GuideTopics returns the focused-playbook topic names available in the skill, sorted — one per references/<topic>.md. The overview (SKILL.md) is always available via the empty topic and is not listed here. A nil fsys (no skill embedded in this build) is an error.

func InspectDir

func InspectDir(dir string) (installed bool, hash string, err error)

InspectDir reports whether a skill is installed at dir and, if so, its content hash (for comparison against the embedded ContentHash). A missing directory is installed=false with no error.

Types

type Agent

type Agent struct {
	ID        string // stable identifier: "claude" | "codex"
	Name      string // display name
	SkillRel  []string
	ConfigRel []string
}

Agent is a target agent runtime whose skills directory we install into. SkillRel is the path of its skills directory relative to a root (the user's home for a user-wide install, the working directory for a project install) — e.g. {".claude","skills"}. ConfigRel is the agent's config root relative to the user's home, used only as a cheap "is this agent installed?" signal for doctor. Codex intentionally differs: its skills live in .agents/skills, while its app/config state lives under .codex.

func AgentByID

func AgentByID(id string) (Agent, bool)

AgentByID returns the agent with the given id.

func (Agent) ConfigRoot

func (a Agent) ConfigRoot(root string) string

ConfigRoot is the agent's top-level config directory under root (e.g. root/.claude or root/.codex). Its presence is a cheap signal that the agent is installed, so doctor can stay quiet about an agent the user doesn't use.

func (Agent) SkillDir

func (a Agent) SkillDir(root string) string

SkillDir is the absolute skill directory under root (…/skills/korbit).

type Outcome

type Outcome struct {
	Dir    string   `json:"dir"`
	Action string   `json:"action"` // "created" | "updated" | "unchanged"
	Files  int      `json:"files"`
	Pruned []string `json:"pruned,omitempty"` // stale files removed (renamed/removed in a newer skill)
	Hash   string   `json:"contentHash"`
}

Outcome is the result of installing into one directory.

func Install

func Install(src fs.FS, dir string) (Outcome, error)

Install writes the skill from src into dir (the skill directory, …/korbit), then prunes any file there that the embedded skill no longer ships — so a renamed or removed reference file from an older binary can't linger. It is idempotent: an on-disk copy already matching the embedded one is left untouched and reported as "unchanged" (no rewrite, no mtime churn).

Jump to

Keyboard shortcuts

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