skill

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 29 Imported by: 0 modules, 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

Index

Constants

View Source
const (
	// BucketSecretName is the tenant namespace Secret mounted by Agent init containers.
	BucketSecretName = "agentz-immutable-skills-bucket"

	// BucketSecretEndpointKey stores the S3-compatible endpoint URL.
	BucketSecretEndpointKey = "endpoint"
	// BucketSecretRegionKey stores the S3 region.
	BucketSecretRegionKey = "region"
	// BucketSecretBucketKey stores the bucket name.
	BucketSecretBucketKey = "bucket"
	// BucketSecretAccessKeyIDKey stores the S3 access key ID.
	BucketSecretAccessKeyIDKey = "access-key-id"
	// BucketSecretSecretAccessKeyKey stores the S3 secret access key.
	BucketSecretSecretAccessKeyKey = "secret-access-key"
)
View Source
const KubernetesDNSLabelMax = 63

KubernetesDNSLabelMax is the storage limit for immutable skill names.

Variables

View Source
var ErrVersionExists = errors.New("immutable skill version already exists")

ErrVersionExists indicates that an immutable version's first object already exists and the version cannot be created conditionally.

Functions

func Init

func Init(cfg InitConfig) (string, error)

Init creates a new skill directory and writes its initial SKILL.md.

func ParseStoragePath

func ParseStoragePath(storagePath string) (string, string, error)

ParseStoragePath splits an S3 storage URI into its bucket and object prefix.

func ReferencingConsumers

func ReferencingConsumers(ctx context.Context, reader client.Reader, key client.ObjectKey) ([]string, error)

ReferencingConsumers finds direct references before deletion or finalization. Namespace identity, rather than current sharing permissions, determines whether a reference still protects the skill's stored versions.

func Validate

func Validate(skillDir string) error

Validate checks one skill directory for opencode-compatible structure.

func ValidateName

func ValidateName(name string) error

ValidateName checks the Kubernetes DNS-label skill name contract.

func ValidateNames

func ValidateNames(names []string) error

ValidateNames checks the count, canonical syntax, and uniqueness of a skill name set used by batch operations.

func ValidateReferences

func ValidateReferences(ctx context.Context, reader client.Reader, namespace string, refs []agentzv1alpha1.ResourceReference) field.ErrorList

ValidateReferences prevents consumers from attaching missing or deleting skills.

Types

type Bundle

type Bundle struct {
	Skills []Tree
}

Bundle is a validated set of imported skills.

func Parse

func Parse(name string, r io.Reader) (_ Bundle, retErr error)

Parse reads and validates a Markdown or ZIP skill import.

func ParseCanonicalZIP

func ParseCanonicalZIP(r io.Reader) (_ Bundle, retErr error)

ParseCanonicalZIP revalidates a gateway-generated ZIP whose size may exceed the public upload limit after canonical re-encoding.

func (Bundle) Decide

func (b Bundle) Decide(decisions []Decision) (Bundle, error)

Decide validates a complete set of import decisions and rewrites renames.

func (Bundle) WriteZIP

func (b Bundle) WriteZIP(w io.Writer) error

WriteZIP writes a canonical, portable archive without buffering the output.

type Client

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

Client wraps object storage operations needed by immutable skills.

func New

func New(ctx context.Context, c Config) (*Client, error)

New creates an object storage client.

func (*Client) DeleteImmutableSkill

func (c *Client) DeleteImmutableSkill(ctx context.Context, namespace, name string) error

DeleteImmutableSkill deletes every stored version of one immutable skill.

func (*Client) DeleteVersion

func (c *Client) DeleteVersion(ctx context.Context, namespace, name string, version int64) error

DeleteVersion deletes one stored immutable skill version.

func (*Client) DownloadManifest

func (c *Client) DownloadManifest(ctx context.Context, manifestPath, targetDir string) error

DownloadManifest stages all immutable skills from manifestPath into targetDir.

func (*Client) UploadVersion

func (c *Client) UploadVersion(ctx context.Context, namespace string, tree Tree, version int64) error

UploadVersion conditionally creates one complete immutable skill version.

func (*Client) VersionSummary

func (c *Client) VersionSummary(ctx context.Context, namespace, name string, version int64) (Summary, error)

VersionSummary calculates file metadata for one immutable skill version.

func (*Client) Versions

func (c *Client) Versions(ctx context.Context, namespace, name string) ([]int64, error)

Versions returns sorted immutable skill versions present in object storage.

func (*Client) WriteVersionsZIP

func (c *Client) WriteVersionsZIP(ctx context.Context, w io.Writer, selections []VersionSelection) error

WriteVersionsZIP streams immutable skill versions into a portable ZIP.

type Config

type Config struct {
	Endpoint        string
	Region          string
	Bucket          string
	AccessKeyID     string
	SecretAccessKey string
}

Config contains S3-compatible object storage settings.

func ConfigFromDir

func ConfigFromDir(dir string) (Config, error)

ConfigFromDir reads a mounted Kubernetes Secret directory into Config.

func (Config) SecretData

func (c Config) SecretData() map[string][]byte

SecretData returns Kubernetes Secret data for immutable skill downloads.

func (Config) StoragePath

func (c Config) StoragePath(namespace, name string, version int64) string

StoragePath returns the full S3 URI for one immutable skill version.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether all required storage settings are present.

type Decision

type Decision struct {
	Action DecisionAction `json:"action"`
	Name   string         `json:"name"`
	Rename string         `json:"rename,omitempty"`
}

Decision selects the destination and precondition for one imported skill.

type DecisionAction

type DecisionAction string

DecisionAction describes how an imported skill is applied.

const (
	// DecisionCreate requires the destination not to exist.
	DecisionCreate DecisionAction = "create"
	// DecisionOverwrite requires the destination to exist.
	DecisionOverwrite DecisionAction = "overwrite"
	// DecisionRename creates a skill under a different name.
	DecisionRename DecisionAction = "rename"
)

type File

type File struct {
	Path    string
	Content []byte
}

File is one validated regular file in a skill tree.

type ImportIssue

type ImportIssue struct {
	Kind    ImportIssueKind
	Path    string
	Message string
}

ImportIssue describes one safe, path-specific import failure.

func (*ImportIssue) Error

func (i *ImportIssue) Error() string

Error returns the import diagnostic, including its archive path.

type ImportIssueKind

type ImportIssueKind string

ImportIssueKind identifies a stable skill-import failure category.

const (
	// ImportIssueUnsupportedFileType rejects unsupported upload formats.
	ImportIssueUnsupportedFileType ImportIssueKind = "unsupported_file_type"
	// ImportIssueInvalidArchive reports an unreadable ZIP archive.
	ImportIssueInvalidArchive ImportIssueKind = "invalid_archive"
	// ImportIssueInvalidTree reports invalid paths or skill directory structure.
	ImportIssueInvalidTree ImportIssueKind = "invalid_tree"
	// ImportIssueMalformedFrontmatter reports invalid SKILL.md YAML metadata.
	ImportIssueMalformedFrontmatter ImportIssueKind = "malformed_frontmatter"
	// ImportIssueInvalidName reports a name outside the skill naming contract.
	ImportIssueInvalidName ImportIssueKind = "invalid_name"
	// ImportIssueInvalidDescription reports missing or invalid trigger text.
	ImportIssueInvalidDescription ImportIssueKind = "invalid_description"
	// ImportIssueInvalidUTF8 reports skill content that is not valid UTF-8.
	ImportIssueInvalidUTF8 ImportIssueKind = "invalid_utf8"
	// ImportIssueLimitExceeded reports an upload that exceeds storage limits.
	ImportIssueLimitExceeded ImportIssueKind = "limit_exceeded"
)

type InitConfig

type InitConfig struct {
	Name      string
	Path      string
	Resources []string
	Examples  bool
}

InitConfig describes one skill scaffolding request.

type Manifest

type Manifest struct {
	Namespace string          `json:"namespace"`
	Skills    []ManifestSkill `json:"skills"`
}

Manifest lists immutable skill versions to stage for one Agent pod.

type ManifestSkill

type ManifestSkill struct {
	Namespace   string `json:"namespace,omitempty"`
	Name        string `json:"name"`
	Version     int64  `json:"version"`
	StoragePath string `json:"storagePath"`
}

ManifestSkill describes one immutable skill version in a pod bootstrap manifest.

type Summary

type Summary struct {
	FileCount int
	SizeBytes int64
	Modified  *time.Time
}

Summary describes the stored files for one immutable skill version.

type Tree

type Tree struct {
	Name        string
	Description string
	Files       []File
}

Tree is one validated skill directory.

type VersionSelection

type VersionSelection struct {
	Namespace string
	Name      string
	Version   int64
}

VersionSelection identifies one immutable skill version for export.

Jump to

Keyboard shortcuts

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