assets

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const TrackerFormatVersion = "3"

TrackerFormatVersion is the version of the tracker file format

Variables

This section is empty.

Functions

func DeleteTracker

func DeleteTracker() error

DeleteTracker removes the tracker file completely

func GetTrackerPath

func GetTrackerPath() (string, error)

GetTrackerPath returns the path to the single tracker file

func SaveTracker

func SaveTracker(tracker *Tracker) error

SaveTracker saves the tracker file

func ValidateDependencies

func ValidateDependencies(lockFile *lockfile.LockFile) error

ValidateDependencies checks that all dependencies are present and resolvable

Types

type AssetFetcher

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

AssetFetcher handles fetching assets from a vault

func NewAssetFetcher

func NewAssetFetcher(vault vaultpkg.Vault) *AssetFetcher

NewAssetFetcher creates a new asset fetcher

func (*AssetFetcher) FetchAsset

func (f *AssetFetcher) FetchAsset(ctx context.Context, asset *lockfile.Asset) (zipData []byte, meta *metadata.Metadata, err error)

FetchAsset downloads a single asset

func (*AssetFetcher) FetchAssetWithProgress

func (f *AssetFetcher) FetchAssetWithProgress(ctx context.Context, asset *lockfile.Asset, bar *progressbar.ProgressBar) (zipData []byte, meta *metadata.Metadata, err error)

FetchAssetWithProgress downloads a single asset with progress bar

func (*AssetFetcher) FetchAssets

func (f *AssetFetcher) FetchAssets(ctx context.Context, assets []*lockfile.Asset, concurrency int) ([]DownloadResult, error)

FetchAssets downloads multiple assets in parallel

type AssetKey

type AssetKey struct {
	Name       string
	Repository string
	Path       string
}

AssetKey uniquely identifies an asset by name + scope (formerly ArtifactKey)

func NewAssetKey

func NewAssetKey(name string, scopeType lockfile.ScopeType, repoURL, repoPath string) AssetKey

NewAssetKey creates a key from name and scope

type AssetWithMetadata

type AssetWithMetadata struct {
	Asset    *lockfile.Asset
	Metadata *metadata.Metadata
	ZipData  []byte
}

AssetWithMetadata combines lockfile asset with parsed metadata

type DependencyResolver

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

DependencyResolver resolves asset dependencies

func NewDependencyResolver

func NewDependencyResolver(lockFile *lockfile.LockFile) *DependencyResolver

NewDependencyResolver creates a new dependency resolver

func (*DependencyResolver) Resolve

func (r *DependencyResolver) Resolve(assets []*lockfile.Asset) ([]*lockfile.Asset, error)

Resolve resolves dependencies and returns assets in topological order

type DownloadResult

type DownloadResult struct {
	Asset    *lockfile.Asset
	ZipData  []byte
	Metadata *metadata.Metadata
	Error    error
	Index    int
}

DownloadResult represents the result of downloading an asset

type DownloadTask

type DownloadTask struct {
	Asset *lockfile.Asset
	Index int
}

DownloadTask represents a single asset download task

type Fetcher

type Fetcher interface {
	// FetchAsset downloads a single asset
	FetchAsset(ctx context.Context, asset *lockfile.Asset) (zipData []byte, meta *metadata.Metadata, err error)

	// FetchAssets downloads multiple assets in parallel
	FetchAssets(ctx context.Context, assets []*lockfile.Asset, concurrency int) ([]DownloadResult, error)
}

Fetcher defines the interface for fetching assets

type InstallRequest

type InstallRequest struct {
	LockFile    *lockfile.LockFile
	ClientName  string // Client to filter by (e.g., "claude-code")
	Scope       *Scope // Current scope context
	TargetBase  string // Base directory for installation (e.g., ~/.claude/)
	CacheDir    string // Cache directory for assets
	Concurrency int    // Max concurrent downloads (default: 10)
}

InstallRequest represents a request to install assets

type InstallResult

type InstallResult struct {
	Installed []string // Successfully installed assets
	Failed    []string // Failed assets
	Errors    []error  // Errors encountered
}

InstallResult represents the result of an installation

type InstallTask

type InstallTask struct {
	Asset    *lockfile.Asset
	ZipData  []byte
	Metadata *metadata.Metadata
}

InstallTask represents a single asset installation task

type InstalledAsset

type InstalledAsset struct {
	Name       string            `json:"name"`
	Version    string            `json:"version"`
	Type       string            `json:"type,omitempty"`       // Asset type (skill, agent, mcp, etc) - added in v3
	Repository string            `json:"repository,omitempty"` // Empty for global scope
	Path       string            `json:"path,omitempty"`       // Path within repo (if path-scoped)
	Clients    []string          `json:"clients"`
	Config     map[string]string `json:"config,omitempty"` // Type-specific config (e.g., marketplace for plugins)
}

InstalledAsset represents a single installed asset with its scope (formerly InstalledArtifact)

func (*InstalledAsset) IsGlobal

func (a *InstalledAsset) IsGlobal() bool

IsGlobal returns true if this asset is installed globally

func (*InstalledAsset) Key

func (a *InstalledAsset) Key() AssetKey

Key returns the unique key for this asset

func (*InstalledAsset) ScopeDescription

func (a *InstalledAsset) ScopeDescription() string

ScopeDescription returns a human-readable scope description

type Installer

type Installer interface {
	// Install installs a single asset
	Install(ctx context.Context, asset *lockfile.Asset, zipData []byte, metadata *metadata.Metadata) error

	// InstallAll installs multiple assets in dependency order
	InstallAll(ctx context.Context, assets []*AssetWithMetadata) (*InstallResult, error)

	// Remove removes a single asset
	Remove(ctx context.Context, asset *lockfile.Asset) error
}

Installer defines the interface for installing assets

type Scope

type Scope struct {
	Type     string // "global", "repo", or "path"
	RepoURL  string // Repository URL (if in a repo)
	RepoPath string // Path relative to repo root (if applicable)
}

Scope represents the current working context for scope matching

type Tracker

type Tracker struct {
	Version string           `json:"version"`
	Assets  []InstalledAsset `json:"assets"`
}

Tracker tracks all installed assets across all scopes

func LoadTracker

func LoadTracker() (*Tracker, error)

LoadTracker loads the tracker file Supports both new "assets" and old "artifacts" field names

func (*Tracker) FindAsset

func (t *Tracker) FindAsset(key AssetKey) *InstalledAsset

FindAsset finds an asset by key in the tracker

func (*Tracker) FindAssetWithMatcher

func (t *Tracker) FindAssetWithMatcher(name, repoURL, path string, matchRepo func(a, b string) bool) *InstalledAsset

FindAssetWithMatcher finds an asset by name using a custom repo URL matcher function This is useful when the tracker URL format may differ from the search URL (e.g., SSH vs HTTPS)

func (*Tracker) FindByScope

func (t *Tracker) FindByScope(repository, path string) []InstalledAsset

FindByScope returns all assets matching a specific scope

func (*Tracker) FindForScope

func (t *Tracker) FindForScope(repoURL, repoPath string, matchRepo func(a, b string) bool) []InstalledAsset

FindForScope returns assets relevant to a given scope: - All global assets - Assets matching the repo (with URL normalization) - For path scopes, assets whose path contains or equals the current path

func (*Tracker) FindGlobal

func (t *Tracker) FindGlobal() []InstalledAsset

FindGlobal returns all globally-scoped assets

func (*Tracker) GroupByScope

func (t *Tracker) GroupByScope() map[string][]InstalledAsset

GroupByScope returns assets grouped by their scope

func (*Tracker) NeedsInstall

func (t *Tracker) NeedsInstall(key AssetKey, version string, targetClients []string) bool

NeedsInstall checks if an asset needs to be installed or updated Returns true if the asset is new, has a different version, or is missing clients

func (*Tracker) RemoveAsset

func (t *Tracker) RemoveAsset(key AssetKey) bool

RemoveAsset removes an asset from the tracker by key

func (*Tracker) RemoveByScope

func (t *Tracker) RemoveByScope(repository, path string) int

RemoveByScope removes all assets for a specific scope

func (*Tracker) UpsertAsset

func (t *Tracker) UpsertAsset(asset InstalledAsset)

UpsertAsset adds or updates an asset in the tracker

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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