claudecode

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package claudecode publishes the pinned Claude Code native-output target descriptor: a stable target/component identity, one immutable, content- addressed artifact.Bundle per installable component (skills, agents, hooks), and the RuntimeContractID the target was compiled under. The descriptor is the upstream input a downstream installer binds to an activation strategy; this package carries no ActivationContractID, performs no installation, and owns no native trust state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindModuleRootFrom

func FindModuleRootFrom(start string) (string, error)

FindModuleRootFrom walks upward from start until it finds the directory holding go.mod, returning that module (repository) root. The asset generator and the drift test both run with a working directory inside the module, so they can locate the canonical skills/ and agents/ trees this way without a hardcoded path.

func RenderGeneratedAssets

func RenderGeneratedAssets(repoRoot string) (map[string][]byte, error)

RenderGeneratedAssets renders, in memory, every codegen-driven Claude Code plugin file the embedded assets tree must carry, keyed by its assets-relative path (for example "pasture-skills/skills/worker/SKILL.md" or "pasture-agents/agents/reviewer.md").

It drives the same live pipeline the repository's canonical skills/ and agents/ trees come from — codegen.EmitHarness for the pinned claude-code target — so the returned bytes are exactly what a fresh generation produces. repoRoot is the module root that contains the canonical skills/ and agents/ trees; the claude-code target reads those (its skills are marker-merged) to produce full-file output. The result is the single source of truth shared by the asset generator (tools/claudecode-assets) and the drift test, so they can never disagree about what "correct" means.

func ReviewedNativeCalls

func ReviewedNativeCalls(contract runtime.RuntimeContract) ([]string, error)

ReviewedNativeCalls returns the sorted set of native host call names the pinned contract actually lowers core orchestration operations to. It is derived from the contract's bindings, never hardcoded, so it always reflects exactly what the reviewed runtime profile declares.

func SortedAssetKeys

func SortedAssetKeys(m map[string][]byte) []string

SortedAssetKeys returns the map's keys in lexicographic order, for deterministic iteration in the generator and test.

func StaleGeneratedAssets

func StaleGeneratedAssets(assetsDir string, generated map[string][]byte) ([]string, error)

StaleGeneratedAssets walks the on-disk embedded assets directory and returns the absolute paths of every codegen-managed file the live pipeline no longer emits (its assets-relative path is absent from generated). It enumerates only the codegen-driven surface: generated skills, agents, hooks.json, and the lifecycle adapter, verbatim skill trees and Git discipline payload. Plugin scaffolding is never reported or removed. The retired legacy context payload path is managed so any reintroduced embedded copy is reported and pruned.

func ValidateAgentFidelity

func ValidateAgentFidelity(d TargetDescriptor) error

ValidateAgentFidelity proves the target's agent artifacts grant only native orchestration tools the pinned contract declares. It parses each agent's `tools:` frontmatter and rejects any granted tool that is in the orchestration vocabulary but is not a reviewed native call — in particular a removed team-lifecycle call. General host tools are ignored, so the check operates on the contract's binding vocabulary rather than scanning free-text guidance.

Types

type Component

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

Component is one published Claude Code extension: its stable identity, immutable content-addressed artifact bundle, and whether it is enabled by default. Hooks are published default-off because they carry side effects the user must opt into; the descriptor states this policy, while a downstream installer owns the actual activation transition.

func NewComponent

func NewComponent(id artifact.ComponentID, bundle artifact.Bundle, defaultEnabled bool) (Component, error)

NewComponent validates and constructs a published component from the sole canonical identity authority and an immutable bundle.

func (Component) Bundle

func (c Component) Bundle() artifact.Bundle

Bundle returns the component's immutable content-addressed artifact bundle.

func (Component) DefaultEnabled

func (c Component) DefaultEnabled() bool

DefaultEnabled reports whether the component is enabled by default. Hooks are published false so their side effects require an explicit opt-in.

func (Component) Extension

func (c Component) Extension() artifact.Extension

Extension returns the canonical extension derived from ID.

func (Component) ID

ID returns the component's stable identity.

func (Component) IsValid

func (c Component) IsValid() bool

IsValid reports whether the component was produced by NewComponent.

type TargetDescriptor

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

TargetDescriptor is the Claude Code target's published, opaque descriptor. It exposes exactly three components (skills, agents, hooks), the RuntimeContractID the target was compiled under, and its harness identity. It deliberately does not carry an ActivationContractID or any installation state: a downstream installer consumes this descriptor and binds each component to a closed activation strategy.

func Descriptor

func Descriptor() (TargetDescriptor, error)

Descriptor builds the pinned Claude Code target descriptor from the embedded generated plugin trees and the runtime.ClaudeCode2_1_261 contract. It is the single production entry point: it constructs one immutable content-addressed bundle per component and publishes the exact contract identity the artifacts were reviewed against. Skills and agents are published default-off alongside hooks so no component activates without an explicit selection; hooks are additionally side-effecting and must be opted into.

func NewTargetDescriptor

func NewTargetDescriptor(contract ir.RuntimeContractID, skills, agents, hooks Component) (TargetDescriptor, error)

NewTargetDescriptor validates and constructs a Claude Code target descriptor. It requires exactly one skills, one agents, and one hooks component, each with the matching canonical extension, and a valid RuntimeContractID bound to the Claude Code harness. There is no mutable component map: the three slots are the only shape a descriptor can take, so an invalid missing, duplicate, or wrong-extension combination cannot be constructed.

func (TargetDescriptor) Agents

func (d TargetDescriptor) Agents() Component

Agents returns the published agents component.

func (TargetDescriptor) Component

func (d TargetDescriptor) Component(extension artifact.Extension) (Component, error)

Component returns the published component for an extension, or an actionable error for a zero or unknown extension.

func (TargetDescriptor) Components

func (d TargetDescriptor) Components() []Component

Components returns the three published components in canonical order: skills, agents, hooks.

func (TargetDescriptor) Harness

func (d TargetDescriptor) Harness() ir.HarnessID

Harness returns the target's harness identity.

func (TargetDescriptor) Hooks

func (d TargetDescriptor) Hooks() Component

Hooks returns the published, default-off hooks component.

func (TargetDescriptor) IsValid

func (d TargetDescriptor) IsValid() bool

IsValid reports whether the descriptor was produced by NewTargetDescriptor.

func (TargetDescriptor) RuntimeContractID

func (d TargetDescriptor) RuntimeContractID() ir.RuntimeContractID

RuntimeContractID returns the exact version-bounded contract the target's artifacts were compiled and reviewed against.

func (TargetDescriptor) Skills

func (d TargetDescriptor) Skills() Component

Skills returns the published skills component.

Jump to

Keyboard shortcuts

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