agentpkg

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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

Copyright 2026 Retail Cortex

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package agentpkg is agentic assets as packages (spec_065_packages): agents, skills, rules, guardrails, workflows and evals, each a versioned asset another may depend on by a version range, as Blitz, Blitz Enterprise's library and builders outside Blitz read them.

Index

Constants

View Source
const (
	MaxFile  = 1 << 20
	MaxTotal = 5 << 20
	MaxFiles = 200
)

The most of an asset that's read (an organization's service's limits).

View Source
const (
	SchemeBlitz  = "blitz"  // an organization's registry: blitz://<host>/<kind>/<name>[@<range>]
	SchemeGitHub = "github" // a repository's folder: github://<owner>/<repo>[@<ref>][/<path>]
	SchemeFile   = "file"   // a folder or file here: file://<path>
	SchemeCastor = "castor" // a Castor registry's skill: castor://<name>
	SchemeGo     = "mod"    // a Go module's folder: mod://<module>@<version>[/<path>]
	SchemeMaven  = "maven"  // a Maven artifact's folder: maven://<group>:<artifact>:<version>[/<path>]
)

The schemes a package's URI may have (PK-10), Castor's among them.

View Source
const LockFile = "blitz.lock"

LockFile is a workspace's lockfile, beside its assets (PK-12): .agents/blitz.lock.

View Source
const ManifestFile = "agents_manifest.json"

ManifestFile is a compiled manifest's name (PK-13), beside the assets.

Variables

View Source
var Folders = map[string]string{"agent": "agents", "skill": "skills", "workflow": "workflows", "rule": "rules", "guardrail": "guardrails", "eval": "evals"}

Folders are where each kind of asset lives under an assets folder (a workspace's .agents, or ~/.blitz): agents/<name>.md, skills/<name>/SKILL.md and its other files, workflows/<name>.flow.yaml, rules/<name>.md, guardrails/<name>.md, evals/<name>.md (PK-11).

View Source
var Kinds = []string{"agent", "skill", "workflow", "rule", "guardrail", "eval"}

Kinds are the kinds of asset a package is (PK-11).

Functions

func Digest

func Digest(files map[string]string) string

Digest is a version's files' digest (PK-05): for each path in order, the path, a zero byte, its text and a zero byte, hashed with SHA-256.

func MainFile

func MainFile(kind, name string) string

MainFile is an asset's main file under its assets folder.

func Owns

func Owns(kind, name, path string) bool

Owns reports whether path (under the assets folder) is one of the kind's asset name's files: its main file, or, for a skill, one in its folder.

func ReadAsset

func ReadAsset(root, kind, name string) (map[string]string, string)

ReadAsset is one asset's files under root, or why it can't be read.

func ReadAssets

func ReadAssets(root string, kinds ...string) (map[string]map[string]string, map[string]string)

ReadAssets are the assets of kinds under root, by "kind/name", each its files by path under root; skipped are those that can't be read as a package, and why: a name Blitz doesn't give, a file that isn't text or is over 1 MB, an asset over 5 MB or 200 files. Hidden files are left out, and a linked skill folder isn't read.

func RemoveAsset

func RemoveAsset(root, kind, name string) error

RemoveAsset removes an asset's files under root; a name Blitz doesn't give (ValidName) is refused, so nothing outside root is removed.

func ValidName

func ValidName(name string) bool

ValidName reports whether name is one Blitz gives an asset: lowercase letters, digits and single hyphens or underscores, up to 64.

func ValidVersion added in v1.2.0

func ValidVersion(version string) bool

ValidVersion reports whether version can name an asset's folder: never a path (no slash, no "..").

func WriteAsset

func WriteAsset(root, kind, name string, files map[string]string) error

WriteAsset writes an asset's files under root, replacing what it had; every path must be its own (Owns).

Types

type Dep

type Dep struct {
	Name    string `yaml:"name" json:"name"`
	Version string `yaml:"version,omitempty" json:"version,omitempty"`
}

Dep is one asset another depends on, by name and version range (PK-03): an agent's skills. In YAML it's "name", "name@range", or {name: …, version: …}.

func (Dep) Check

func (d Dep) Check() error

Check says what's wrong with d: a name Blitz can't have, a range that doesn't read.

func (Dep) MarshalYAML

func (d Dep) MarshalYAML() (any, error)

MarshalYAML writes d as "name" or "name@range".

func (Dep) Range

func (d Dep) Range() Range

Range is d's range (any when it doesn't read: Check says so).

func (*Dep) UnmarshalYAML

func (d *Dep) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML reads any of a Dep's forms.

type Lock

type Lock struct {
	Version string               `json:"version"`
	Assets  map[string]LockEntry `json:"assets"`
}

Lock is what a workspace added from elsewhere (PK-12): each asset by "kind/name", where it came from, the version it resolved to and its files' digest, so `blitz pkg verify` tells a change. A superset of Castor's .manifest.lock (its skills' URI and SHA-256).

func ReadLock

func ReadLock(path string) (Lock, error)

ReadLock reads the lockfile at path: an empty lock when there's none.

func (Lock) Keys

func (l Lock) Keys() []string

Keys are the lock's assets' keys, in order.

func (Lock) Write

func (l Lock) Write(path string) error

Write writes l at path.

type LockEntry

type LockEntry struct {
	Kind    string    `json:"kind"`
	Name    string    `json:"name"`
	URI     string    `json:"uri"`
	Version string    `json:"version,omitempty"`
	SHA256  string    `json:"sha256"`
	Added   time.Time `json:"added"`
}

LockEntry is one asset a lock holds.

type Manifest

type Manifest struct {
	Schema int                      `json:"schema"`
	Assets map[string]ManifestAsset `json:"assets"`
}

Manifest is a workspace's assets compiled into one file (PK-13), for loaders that read it rather than the folders: each asset by "kind/name", with its version, description, files' digest, where it came from, its dependencies and its files.

type ManifestAsset

type ManifestAsset struct {
	Kind        string            `json:"kind"`
	Name        string            `json:"name"`
	Version     string            `json:"version,omitempty"`
	Description string            `json:"description,omitempty"`
	SHA256      string            `json:"sha256"`
	SourceURI   string            `json:"source_uri"`
	Deps        []Dep             `json:"deps,omitempty"`
	Files       map[string]string `json:"files"`
}

ManifestAsset is one asset in a manifest.

type Range

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

Range is the versions a dependency accepts (PK-02):

""  "*"  "latest"   any
"1.4.2"             that one
"1"  "1.x"          any 1.y.z
"1.4"  "1.4.x"      any 1.4.z
"^1.4.2"            1.4.2 or later, before 2.0.0 (before 0.5.0 for 0.4.x)
"~1.4.2"            1.4.2 or later, before 1.5.0

func ParseRange

func ParseRange(s string) (Range, error)

ParseRange reads a range.

func (Range) Best

func (r Range) Best(versions []Version) (Version, bool)

Best is the latest of versions in the range, and whether there's one.

func (Range) Match

func (r Range) Match(v Version) bool

Match reports whether v is in the range.

func (Range) String

func (r Range) String() string

String is the range as written ("*" for any).

type URI

type URI struct {
	Scheme  string
	Host    string
	Target  string
	Ref     string
	Subpath string
	Kind    string
	Name    string
}

URI is where a package comes from (PK-10), parsed: its scheme; the registry's host (blitz); its target (the repository, module, artifact, path or name); the ref or range it pins (a branch, tag or version); the folder in it; and, for blitz, the asset's kind and name.

func ParseURI

func ParseURI(s string) (URI, error)

ParseURI reads a package's URI (PK-10): blitz://, github:// (or https://github.com/…, with @ref, :ref or /tree/ref, "main" when none), file:// (or a bare path), castor:// (and cstr://, castors://, skm://), mod:// (or go://) and maven:// (or mvn://), as Castor reads them.

func (URI) String

func (u URI) String() string

String is the URI as written: blitz://, github:// and file:// as Blitz writes them (a lockfile's), the others with their scheme.

type Version

type Version struct {
	Major, Minor, Patch int
}

Version is an asset's version: major.minor.patch (PK-01).

func Latest

func Latest(versions []Version) (Version, bool)

Latest is the latest of versions, and whether there's one.

func ParseVersion

func ParseVersion(s string) (Version, error)

ParseVersion reads "1.4.2" (a leading "v" allowed).

func (Version) Bump

func (v Version) Bump(part string) (Version, error)

Bump is the version after v: "major", "minor" or "patch".

func (Version) Compare

func (v Version) Compare(w Version) int

Compare is -1, 0 or 1 as v is before, the same as, or after w.

func (Version) String

func (v Version) String() string

String is v as major.minor.patch.

Jump to

Keyboard shortcuts

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