custom

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Kind       = "Adapter"
	APIVersion = components.APIVersion
)

Variables

This section is empty.

Functions

func CompileTemplate

func CompileTemplate(id, body string) (*template.Template, error)

CompileTemplate parses one body using the same options custom adapter rendering will use later.

func ExecuteTemplate

func ExecuteTemplate(tmpl *template.Template, data TemplateData) ([]byte, error)

ExecuteTemplate renders a pre-validated template with the restricted data surface. It is available to planner work without exposing host callbacks.

func ValidateTemplates

func ValidateTemplates(manifest Manifest) error

ValidateTemplates compiles inline custom adapter templates with the locked missing-key policy and verifies that actions only reference approved data.

Types

type Detection

type Detection struct {
	Paths       []string `json:"paths,omitempty"`
	MarkerFiles []string `json:"markerFiles,omitempty"`
}

Detection describes read-only adapter discovery hints.

type Manifest

type Manifest struct {
	APIVersion string   `json:"apiVersion"`
	Kind       string   `json:"kind"`
	Metadata   Metadata `json:"metadata"`
	Spec       Spec     `json:"spec"`
}

Manifest is a declarative adapter definition. It deliberately contains no command, script, hook, or lifecycle fields.

func ParseJSON

func ParseJSON(data []byte) (Manifest, error)

ParseJSON parses and validates a custom adapter manifest.

func (Manifest) Normalize

func (m Manifest) Normalize() Manifest

Normalize fills deterministic defaults for optional schema fields.

func (Manifest) TargetEntries

func (m Manifest) TargetEntries() []TargetEntry

TargetEntries returns all declared targets in deterministic family order.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate checks the manifest schema without compiling templates.

type Metadata

type Metadata struct {
	ID          string   `json:"id"`
	Name        string   `json:"name,omitempty"`
	Description string   `json:"description,omitempty"`
	Tags        []string `json:"tags,omitempty"`
}

Metadata identifies the custom adapter.

type OutputFormat

type OutputFormat string

OutputFormat names the native output family for a custom adapter target.

const (
	FormatJSON                 OutputFormat = "json"
	FormatJSONC                OutputFormat = "jsonc"
	FormatTOML                 OutputFormat = "toml"
	FormatYAML                 OutputFormat = "yaml"
	FormatMarkdown             OutputFormat = "markdown"
	FormatManagedMarkdownBlock OutputFormat = "managed-markdown-block"
	FormatManagedLineBlock     OutputFormat = "managed-line-block"
	FormatSymlink              OutputFormat = "symlink"
	FormatCopy                 OutputFormat = "copy"
)

type Scope

type Scope string

Scope is the scope a custom adapter manifest is allowed to target.

const (
	ScopeProject Scope = "project"
	ScopeGlobal  Scope = "global"
)

type Spec

type Spec struct {
	Scope      Scope               `json:"scope"`
	Detection  Detection           `json:"detection,omitempty"`
	Targets    Targets             `json:"targets"`
	Support    map[string]string   `json:"support,omitempty"`
	TemplateID string              `json:"templateId,omitempty"`
	Templates  map[string]Template `json:"templates,omitempty"`
}

Spec defines detection metadata and all supported render targets.

type Target

type Target struct {
	Path         string       `json:"path"`
	OutputFormat OutputFormat `json:"outputFormat"`
	TemplateID   string       `json:"templateId,omitempty"`
	TargetKey    string       `json:"targetKey,omitempty"`
	InstallMode  string       `json:"installMode,omitempty"`
	Scope        Scope        `json:"scope,omitempty"`
	Support      string       `json:"support,omitempty"`
	WriteLevel   string       `json:"writeLevel,omitempty"`
	Notes        []string     `json:"notes,omitempty"`
}

Target defines one adapter-native output location.

type TargetEntry

type TargetEntry struct {
	Kind   string
	Target Target
}

TargetEntry is a flattened target annotated with its component family.

type Targets

type Targets struct {
	Rules       []Target `json:"rules,omitempty"`
	Skills      []Target `json:"skills,omitempty"`
	MCP         []Target `json:"mcp,omitempty"`
	Ignore      []Target `json:"ignore,omitempty"`
	Permissions []Target `json:"permissions,omitempty"`
}

Targets groups native output targets by normalized component family.

type Template

type Template struct {
	OutputFormat OutputFormat `json:"outputFormat,omitempty"`
	Body         string       `json:"body"`
}

Template is an inline custom adapter render template. Templates are inert text/template bodies; ContextCart never executes shell commands from them.

type TemplateData

type TemplateData struct {
	Component   any
	MCP         any
	Skill       any
	Rule        any
	Ignore      any
	Adapter     Manifest
	ProjectPath string
	TargetPath  string
	Env         map[string]string
	OperationID string
}

TemplateData is the complete data surface available to custom adapter templates. It intentionally exposes data only, not helper functions.

Jump to

Keyboard shortcuts

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