metadata

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentMetadataVersion = "1.0"

CurrentMetadataVersion is the current version of the metadata format

Variables

This section is empty.

Functions

func Marshal

func Marshal(metadata *Metadata) ([]byte, error)

Marshal converts metadata to TOML bytes

func ParseDependency

func ParseDependency(dep string) (name string, constraint string, err error)

ParseDependency parses a dependency string (e.g., "package>=1.0.0,<2.0.0") Returns the package name and version constraint

func ValidateDependencyConstraint

func ValidateDependencyConstraint(constraint string) error

ValidateDependencyConstraint validates a version constraint string Supports: >=X.Y.Z, ~=X.Y.Z, ~X.Y.Z, and comma-separated constraints

func ValidateZip added in v0.11.0

func ValidateZip(zipData []byte, expectedType *asset.Type) error

ValidateZip validates that a zip contains valid asset contents. It checks metadata.toml exists and is parseable, referenced files exist, and the asset type matches.

func Write

func Write(metadata *Metadata, filePath string) error

Write writes metadata to a file path

Types

type AgentConfig

type AgentConfig struct {
	PromptFile string `toml:"prompt-file"`
}

AgentConfig represents the [agent] section

func (*AgentConfig) Validate

func (a *AgentConfig) Validate() error

Validate validates the [agent] section

type Asset

type Asset struct {
	Name          string     `toml:"name"`
	Version       string     `toml:"version"`
	Type          asset.Type `toml:"type"`
	Description   string     `toml:"description,omitempty"`
	License       string     `toml:"license,omitempty"`
	Authors       []string   `toml:"authors,omitempty"`
	Keywords      []string   `toml:"keywords,omitempty"`
	Homepage      string     `toml:"homepage,omitempty"`
	Repository    string     `toml:"repository,omitempty"`
	Documentation string     `toml:"documentation,omitempty"`
	Readme        string     `toml:"readme,omitempty"`
	Dependencies  []string   `toml:"dependencies,omitempty"`
}

Asset represents the asset section (formerly [artifact])

func (*Asset) Validate

func (a *Asset) Validate() error

Validate validates the asset section

type ClaudeCodePluginConfig added in v0.8.0

type ClaudeCodePluginConfig struct {
	ManifestFile string `toml:"manifest-file,omitempty"` // Default: .claude-plugin/plugin.json
	AutoEnable   *bool  `toml:"auto-enable,omitempty"`   // Default: true
	Marketplace  string `toml:"marketplace,omitempty"`   // Optional marketplace name
	Source       string `toml:"source,omitempty"`        // "marketplace" or "local" (default)
}

ClaudeCodePluginConfig represents the [claude-code-plugin] section

func (*ClaudeCodePluginConfig) Validate added in v0.8.0

func (c *ClaudeCodePluginConfig) Validate() error

Validate validates the [claude-code-plugin] section

type CommandConfig

type CommandConfig struct {
	PromptFile string `toml:"prompt-file"`
}

CommandConfig represents the [command] section

func (*CommandConfig) Validate

func (c *CommandConfig) Validate() error

Validate validates the [command] section

type HookConfig

type HookConfig struct {
	Event      string         `toml:"event"`
	ScriptFile string         `toml:"script-file,omitempty"`
	Command    string         `toml:"command,omitempty"`
	Args       []string       `toml:"args,omitempty"`
	Timeout    int            `toml:"timeout,omitempty"`
	Matcher    string         `toml:"matcher,omitempty"`
	Cursor     map[string]any `toml:"cursor,omitempty"`
	ClaudeCode map[string]any `toml:"claude-code,omitempty"`
	Copilot    map[string]any `toml:"copilot,omitempty"`
	Gemini     map[string]any `toml:"gemini,omitempty"`
}

HookConfig represents the [hook] section

func (*HookConfig) Validate

func (h *HookConfig) Validate() error

Validate validates the [hook] section

type MCPConfig

type MCPConfig struct {
	Transport string            `toml:"transport,omitempty"`
	Command   string            `toml:"command,omitempty"`
	Args      []string          `toml:"args,omitempty"`
	URL       string            `toml:"url,omitempty"`
	Env       map[string]string `toml:"env,omitempty"`
	Timeout   int               `toml:"timeout,omitempty"`
}

MCPConfig represents the [mcp] section (for both mcp and mcp-remote)

func (*MCPConfig) IsRemote added in v0.10.0

func (m *MCPConfig) IsRemote() bool

IsRemote returns true if the MCP config uses a remote transport (sse or http)

func (*MCPConfig) Validate

func (m *MCPConfig) Validate() error

Validate validates the [mcp] section

type Metadata

type Metadata struct {
	MetadataVersion string `toml:"metadata-version,omitempty"`
	Asset           Asset  `toml:"asset"`

	// Type-specific sections (only one should be present based on asset.type)
	Skill            *SkillConfig            `toml:"skill,omitempty"`
	Command          *CommandConfig          `toml:"command,omitempty"`
	Agent            *AgentConfig            `toml:"agent,omitempty"`
	Hook             *HookConfig             `toml:"hook,omitempty"`
	MCP              *MCPConfig              `toml:"mcp,omitempty"`
	ClaudeCodePlugin *ClaudeCodePluginConfig `toml:"claude-code-plugin,omitempty"`
	Rule             *RuleConfig             `toml:"rule,omitempty"`
	Custom           map[string]any          `toml:"custom,omitempty"`
}

Metadata represents the complete metadata.toml structure

func Parse

func Parse(data []byte) (*Metadata, error)

Parse parses metadata from bytes Supports both new asset and old [artifact] section names

func ParseFile

func ParseFile(filePath string) (*Metadata, error)

ParseFile parses metadata from a file path

func (*Metadata) GetTypeConfig

func (m *Metadata) GetTypeConfig() any

GetTypeConfig returns the type-specific configuration section

func (*Metadata) Validate

func (m *Metadata) Validate() error

Validate validates the entire metadata structure

func (*Metadata) ValidateWithFiles

func (m *Metadata) ValidateWithFiles(fileList []string) error

ValidateWithFiles validates metadata and checks that required files exist in the provided file list

type RuleConfig added in v0.9.0

type RuleConfig struct {
	Title       string         `toml:"title,omitempty"`       // Title/heading for the rule (defaults to asset name)
	PromptFile  string         `toml:"prompt-file,omitempty"` // Defaults to RULE.md
	Description string         `toml:"description,omitempty"` // Rule description (used in frontmatter)
	Globs       []string       `toml:"globs,omitempty"`       // File patterns this rule applies to
	Cursor      map[string]any `toml:"cursor,omitempty"`      // Cursor-specific settings
	ClaudeCode  map[string]any `toml:"claude-code,omitempty"` // Claude Code-specific settings
	Copilot     map[string]any `toml:"copilot,omitempty"`     // GitHub Copilot-specific settings
}

RuleConfig represents the [rule] section

func (*RuleConfig) Validate added in v0.9.0

func (r *RuleConfig) Validate() error

Validate validates the [rule] section

type SkillConfig

type SkillConfig struct {
	PromptFile string `toml:"prompt-file"`
}

SkillConfig represents the [skill] section

func (*SkillConfig) Validate

func (s *SkillConfig) Validate() error

Validate validates the [skill] section

Jump to

Keyboard shortcuts

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