Documentation
¶
Overview ¶
Package harness declares harnesses.yaml, the repository file that defines where zip items are placed (see site/src/content/docs/guides/zip-items.md). Keep it free of agent dependencies, like pkg/catalog.
Index ¶
Constants ¶
const ( KindDirectory = "directory" KindMarketplace = "marketplace" KindSettings = "settings" )
Placement kinds.
const ( ScopeMachine = "machine" ScopeUser = "user" )
Scopes. An OS without a scope is ScopeMachine.
const ( Darwin = "darwin" Windows = "windows" )
OS keys of Placement.Paths and Placement.Scope.
const DefaultCatalogTemplate = `` /* 704-byte string literal not displayed */
DefaultCatalogTemplate renders a manifest_files entry written as a bare path: the Claude Code marketplace catalog (zip-items guide, "Marketplace and settings placements"). It is a template like any a brand writes, so a brand overrides it by copying it under {path, template}.
const DefaultSettingsTemplate = `` /* 422-byte string literal not displayed */
DefaultSettingsTemplate renders a settings placement that has no template: the Claude Code drop-in that registers the marketplace and enables its managed plugins, or nothing, which removes the file, when the marketplace holds no plugin.
Variables ¶
var DefaultManifestFiles = []string{".claude-plugin/marketplace.json"}
DefaultManifestFiles is where a marketplace's manifest is written when its block lists no manifest_files.
Functions ¶
This section is empty.
Types ¶
type ManifestFile ¶
ManifestFile is one manifest_files entry: a path, which gets DefaultCatalogTemplate, or {path, template}, which gets that template (render.FileContext). In YAML a bare string is a path.
func (*ManifestFile) UnmarshalYAML ¶
func (f *ManifestFile) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML accepts a string or a {path, template} mapping.
type Marketplace ¶
type Marketplace struct {
Name string `yaml:"name"`
Owner any `yaml:"owner"`
Renames any `yaml:"renames,omitempty"`
AllowCrossMarketplaceDependenciesOn any `yaml:"allowCrossMarketplaceDependenciesOn,omitempty"`
ManifestFiles []ManifestFile `yaml:"manifest_files,omitempty"`
}
Marketplace configures a marketplace placement's manifest. Owner, Renames and AllowCrossMarketplaceDependenciesOn are written to the manifest unchanged, so they stay untyped.
func (Marketplace) Files ¶
func (m Marketplace) Files() []string
Files returns the paths of Manifests.
func (Marketplace) Manifests ¶
func (m Marketplace) Manifests() []ManifestFile
Manifests returns the manifest files to write, relative to the placement root, each with its template: DefaultCatalogTemplate for an entry written as a path, and DefaultManifestFiles when the block lists none.
type Placement ¶
type Placement struct {
Kind string `yaml:"kind"`
// Paths maps an OS (darwin, windows) to the placement root on it.
Paths map[string]string `yaml:"paths,omitempty"`
// Scope maps an OS to machine or user. An OS left out is machine.
Scope map[string]string `yaml:"scope,omitempty"`
WorksIn []string `yaml:"works_in,omitempty"`
ActionLabels map[string]string `yaml:"action_labels,omitempty"`
Exclusive bool `yaml:"exclusive,omitempty"`
// Marketplace is set for KindMarketplace only.
Marketplace *Marketplace `yaml:"marketplace,omitempty"`
// Registers names the placement a KindSettings file registers: a
// marketplace, or with Template any directory or marketplace.
Registers string `yaml:"registers,omitempty"`
// Template renders a KindSettings file in place of
// DefaultSettingsTemplate (render.FileContext). An empty output removes
// the file.
Template string `yaml:"template,omitempty"`
}
Placement is a named destination for zip items.
func (Placement) Registered ¶
func (p Placement) Registered(name, root string) *render.Registered
Registered describes placement name, rooted at root, to the template of a settings placement that registers it.
func (Placement) SettingsTemplate ¶
SettingsTemplate returns the template a settings placement's file is rendered from: its own, or DefaultSettingsTemplate.
type Table ¶
type Table struct {
Placements map[string]Placement `yaml:"placements"`
// CheckFacts are the facts makecatalogs -check renders templates with,
// over the built-in samples (conditions.SampleFacts): the admin facts
// the templates read.
CheckFacts map[string]any `yaml:"check_facts,omitempty"`
// Order holds the placement names in file order. Parse fills it.
Order []string `yaml:"-"`
}
Table is a parsed harnesses.yaml.
func Parse ¶
Parse decodes harnesses.yaml, rejecting unknown fields, and validates it. An empty file is an empty table.
func (Table) Names ¶
Names returns the placement names in file order. This is the table's order wherever an order matters, such as label fallback.
func (Table) Storefront ¶
func (t Table) Storefront(item catalog.Item, goos string) (labels map[string]string, worksIn []string)
Storefront returns what the storefront shows for item on goos: its action labels and the harnesses it works in. A label comes from the item's custom_action_labels, else from the first of its placements with a variant on goos, in table order, that sets it; a key set nowhere is left out, for the UI's built-in label. worksIn is the union of those placements' works_in, in table order. Only a zip item has placements.