Documentation
¶
Overview ¶
Package skills contains the filesystem and validation logic for the folder-shaped Agent Skills format (agentskills.io): SKILL.md frontmatter validation, bundled-file discovery, and safe path handling for downloads.
Index ¶
- Constants
- func PlanReconstruct(dir string, b Bundle) (skillMDDest string, fileDests []string, err error)
- func ReadSkillMD(folder string) ([]byte, error)
- func SafeJoin(dir, relPath string) (string, error)
- func ValidateName(name string) error
- type Bundle
- type BundleFile
- type Downloader
- type File
- type Frontmatter
- type WrittenFile
Constants ¶
const ( // MaxSkillMDBytes is the backend limit for the literal SKILL.md payload. MaxSkillMDBytes = 1 << 20 // 1 MB // MaxFileBytes is the backend per-file limit for bundled resources. MaxFileBytes = 100 << 20 // 100 MB )
Variables ¶
This section is empty.
Functions ¶
func PlanReconstruct ¶ added in v0.6.0
PlanReconstruct validates every manifest path against dir using SafeJoin and returns the resolved destination for SKILL.md plus each bundled file. It writes nothing — callers use it for dry-run previews and to fail fast on a malicious path before any directory is created.
The returned slice is aligned with b.Files; the SKILL.md destination is returned separately as it is not part of the bundle manifest.
func ReadSkillMD ¶
ReadSkillMD reads the literal SKILL.md bytes from a skill folder root, returning friendly errors for the common failure modes.
func SafeJoin ¶
SafeJoin joins a server-supplied manifest path onto a local destination directory, refusing absolute paths, backslashes, and any path that would escape dir.
func ValidateName ¶
ValidateName checks the SKILL.md frontmatter `name` field against the backend rule and returns a friendly error when it does not conform.
Types ¶
type Bundle ¶ added in v0.6.0
type Bundle struct {
RawSkillMD string
Files []BundleFile
}
Bundle is the resolved content of a skill ready to be written to disk: the literal SKILL.md bytes plus its bundled files.
type BundleFile ¶ added in v0.6.0
BundleFile describes one bundled file in a skill's manifest as returned by the skills resolve endpoints: a relative forward-slash Path, a presigned DownloadURL, and the SizeBytes the server reported for it.
type Downloader ¶ added in v0.6.0
Downloader fetches the contents of a presigned URL into dest, creating parent directories as needed. Callers inject their own implementation so the skills package stays free of cobra/HTTP-context concerns.
type File ¶
type File struct {
// Path is the manifest path: relative to the skill folder root, with
// forward slashes.
Path string
// AbsPath is the on-disk location of the file.
AbsPath string
// Size is the file size in bytes.
Size int64
}
File is one bundled asset discovered inside a skill folder.
type Frontmatter ¶
Frontmatter holds the SKILL.md fields the CLI surfaces. Parsing never rewrites the markdown — the literal bytes are uploaded as-is.
func ParseFrontmatter ¶
func ParseFrontmatter(md []byte) (*Frontmatter, error)
ParseFrontmatter extracts the YAML frontmatter block from raw SKILL.md bytes. The file must start with a `---` line closed by another `---` line.
type WrittenFile ¶ added in v0.6.0
type WrittenFile struct {
// Dest is the absolute (or dir-relative) on-disk path written.
Dest string
// SizeBytes is the reported size of the file (0 for SKILL.md, where the
// literal byte length is used instead).
SizeBytes int64
}
WrittenFile records one file written to disk during a reconstruction.
func Reconstruct ¶ added in v0.6.0
func Reconstruct(dir string, b Bundle, download Downloader) ([]WrittenFile, error)
Reconstruct writes a skill bundle into dir: it creates dir, writes SKILL.md verbatim, and downloads every bundled file via download. Every manifest path is validated with SafeJoin before any write happens, so a malicious path aborts the whole operation instead of leaving a partial folder behind.
It returns the list of files written (SKILL.md first, then bundled files in manifest order) so callers can print a per-file summary.