agentops

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSkillsDirName is the directory name for skills relative to .agents/.
	DefaultSkillsDirName = ".agents/skills"

	// DefaultGlobalSkillsDirName is the global skills directory path.
	DefaultGlobalSkillsDirName = "~/.config/agents/skills"

	// CatalogFileName is the name of the catalog spec file.
	CatalogFileName = "catalog.yaml"

	// CatalogLockFileName is the name of the catalog lock file.
	CatalogLockFileName = "catalog-lock.yaml"
)
View Source
const (

	// AnnotationCreated is the OCI annotation key for the image creation timestamp.
	AnnotationCreated = "org.opencontainers.image.created"

	// AnnotationSource is the OCI annotation key for the source repository URL.
	AnnotationSource = "org.opencontainers.image.source"

	// AnnotationRevision is the OCI annotation key for the source revision.
	AnnotationRevision = "org.opencontainers.image.revision"

	// AnnotationVersion is the OCI annotation key for the image version.
	AnnotationVersion = "org.opencontainers.image.version"
)
View Source
const (
	// SkillFileName is the name of the skill metadata file.
	SkillFileName = "SKILL.md"
)

Variables

View Source
var ErrDiffIdentical = errors.New("artifact contents are identical")

ErrDiffIdentical is returned by DiffArtifact when the local and remote content layers are identical.

Functions

func AgentIDs

func AgentIDs() []string

AgentIDs returns a sorted list of all known agent IDs.

func AppendGitMetadata

func AppendGitMetadata(repoPath string, annotations map[string]string)

AppendGitMetadata auto-populates OCI annotations from git metadata. It only sets annotations that are not already present in the map. Errors are silently ignored (git not installed, not a repo, etc.).

func BuildArtifact

func BuildArtifact(srcDir string, skillNames []string) ([]byte, error)

BuildArtifact creates a tar+gzip archive containing only the specified skill directories from srcDir. It strips environment metadata (uid, gid, timestamps) for reproducibility, and skips symlinks and non-regular files.

func CheckSkillConflicts

func CheckSkillConflicts(catalog *fluxcdv1.AgentCatalog, repo string, newSkillNames []string) error

CheckSkillConflicts checks if any skill name in newSkillNames is already installed by a different source in the catalog.

func CopySkillDir

func CopySkillDir(src, dst string) error

CopySkillDir performs a safe recursive directory copy. It skips symlinks and non-regular files to prevent symlink-based path traversal.

func DefaultSkillsDir

func DefaultSkillsDir() (string, error)

DefaultSkillsDir resolves the skills directory to an absolute path relative to the current working directory. If the path exists, it verifies that it is a real directory (not a symlink).

func DeriveGitHubOwner

func DeriveGitHubOwner(repo string) string

DeriveGitHubOwner extracts the GitHub owner from a ghcr.io repository URL.

func DiffArtifact

func DiffArtifact(ctx context.Context, repo string, tag string, localData []byte) error

DiffArtifact compares the local artifact data against the content layer of the remote artifact at the given tag. It fetches only the remote manifest and compares the Flux content layer digest. It returns ErrDiffIdentical if the content is the same, nil if different. Failures are treated as "different" (fail open).

func DiscoverSkills

func DiscoverSkills(dir string) ([]string, error)

DiscoverSkills walks top-level subdirectories of dir, finding those with a valid SKILL.md file. Returns the list of skill names.

func FilterSkillNames

func FilterSkillNames(discovered []string, targets []string) ([]string, error)

FilterSkillNames returns only the skill names present in the target list. If targets is empty, all discovered names are returned unchanged. Returns an error if any target name is not found in the discovered set.

func HashSkillDir

func HashSkillDir(dir string) (string, error)

HashSkillDir computes the SHA-256 directory hash of a skill directory.

func IsGitHubContainerRegistry

func IsGitHubContainerRegistry(repo string) bool

IsGitHubContainerRegistry checks if the repository host is ghcr.io.

func LoadCatalog

func LoadCatalog(dir string) (*fluxcdv1.AgentCatalog, error)

LoadCatalog builds a catalog by reading the spec from catalog.yaml and the status from catalog-lock.yaml. The spec in catalog.yaml is authoritative; the spec stored in the lock file is ignored.

func NormalizeGitURL

func NormalizeGitURL(url string) string

NormalizeGitURL converts git URLs to HTTPS format. It handles git://, git@host:path SSH URLs, and strips .git suffixes.

func NormalizeRepository

func NormalizeRepository(repo string) string

NormalizeRepository strips the oci:// prefix and trailing slashes from a repository URL.

func ParseAnnotations

func ParseAnnotations(args []string) (map[string]string, error)

ParseAnnotations parses a list of key=value strings into a map. It splits on the first '=' only, allowing values to contain '='.

func ProjectRoot

func ProjectRoot() (string, error)

ProjectRoot returns the current working directory, which is the root of the project where skills and agent symlinks are managed.

func PushArtifact

func PushArtifact(ctx context.Context, repo string, data []byte, opts PushArtifactOptions) (string, error)

PushArtifact creates a Flux OCI artifact from the pre-built data and pushes it to the specified repository. It returns the artifact digest.

func RemoveAgentSymlinks(projectRoot string, agents []string, skillNames []string) error

RemoveAgentSymlinks removes per-skill symlinks for each agent and cleans up empty agent skill directories and their parents.

func RemoveEmptyDir

func RemoveEmptyDir(dir string)

RemoveEmptyDir removes a directory if it is empty. Errors are silently ignored.

func ResolveDigest

func ResolveDigest(ctx context.Context, ociURL string) (string, error)

ResolveDigest resolves the digest of an OCI artifact without downloading it.

func SaveCatalog

func SaveCatalog(dir string, catalog *fluxcdv1.AgentCatalog) error

SaveCatalog atomically writes the catalog spec to catalog.yaml in the given directory.

func SaveCatalogLock

func SaveCatalogLock(dir string, catalog *fluxcdv1.AgentCatalog) error

SaveCatalogLock atomically writes the full catalog to catalog-lock.yaml in the given directory.

func SyncAgentSymlinks(projectRoot string, agents []string, skillNames []string) error

SyncAgentSymlinks creates per-skill symlinks for each agent that uses a custom skills directory. TargetAgents using the default skills directory are silently skipped. The symlinks are relative so they remain valid across machines. Existing correct symlinks are left in place; wrong targets are replaced. Returns an error if a target path exists as a non-symlink.

func SyncSkills

func SyncSkills(skillsDir, srcDir string, oldChecksums map[string]string, skillNames []string, restoring bool) ([]string, []fluxcdv1.AgentCatalogSkill, error)

SyncSkills computes checksums from a source directory, compares them against old checksums (from inventory) or installed checksums (when restoring), removes orphaned skills, and copies only changed skills to the install directory. Returns the list of changed skill names and the full skill metadata.

func UsesDefaultSkillsDir

func UsesDefaultSkillsDir(info *AgentInfo) bool

UsesDefaultSkillsDir returns true if the agent's project path is the default skills directory (no symlink needed).

func ValidateSkillName

func ValidateSkillName(name string) error

ValidateSkillName validates a skill name per the Agent Skills specification.

Types

type AgentInfo

type AgentInfo struct {
	// Name is the human-readable agent name.
	Name string

	// ID is the unique identifier used with the --agent flag.
	ID string

	// ProjectPath is the skills directory path relative to the project root.
	ProjectPath string

	// GlobalPath is the global skills directory path (~ is expanded at runtime).
	GlobalPath string
}

AgentInfo holds the configuration for an AI agent's skills directory.

func FindAgent

func FindAgent(id string) *AgentInfo

FindAgent returns the AgentInfo for the given ID, or nil if not found.

type ArtifactInfo

type ArtifactInfo struct {
	// Digest is the artifact digest string (e.g. "sha256:...").
	Digest string

	// Annotations holds the manifest annotations.
	Annotations map[string]string
}

ArtifactInfo holds metadata from a pulled OCI artifact.

func PullArtifact

func PullArtifact(ctx context.Context, ociURL, dstDir string) (*ArtifactInfo, error)

PullArtifact pulls a Flux OCI artifact, finds the content layer by media type, and extracts it to dstDir. It returns the artifact metadata.

type PushArtifactOptions

type PushArtifactOptions struct {
	// Tags is the list of tags to apply to the artifact.
	Tags []string

	// Annotations is the map of OCI manifest annotations.
	Annotations map[string]string
}

PushArtifactOptions holds configuration for pushing an OCI artifact.

type SkillDrift

type SkillDrift struct {
	// Name is the skill name.
	Name string

	// Reason is a human-readable description of the drift (e.g. "deleted", "modified").
	Reason string
}

SkillDrift describes a skill that has drifted from its expected state.

func CheckSkillIntegrity

func CheckSkillIntegrity(skillsDir string, skills []fluxcdv1.AgentCatalogSkill) []SkillDrift

CheckSkillIntegrity verifies that each installed skill directory exists and matches its stored checksum. Returns a list of drifted skills, or nil if all intact.

func (SkillDrift) String

func (d SkillDrift) String() string

String returns a formatted drift description.

Jump to

Keyboard shortcuts

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