render

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package render materialises the embedded defaults against a resolved selection. It renders skill templates (text/template with AST-level identifier validation against the catalog), prunes pipeline nodes whose agents have been deselected, and computes fingerprints used by the drift-detection path in `internal/workspace`.

Index

Constants

View Source
const FingerprintFileName = ".bender/.pipeline.fingerprint"

FingerprintFileName is the hidden sidecar where init records the SHA-256 of the last-generated `.bender/pipeline.yaml`, relative to workspace root.

View Source
const TemplateSuffix = ".tmpl"

TemplateSuffix identifies a file that must be rendered rather than copied verbatim. Shipped files under `defaults/claude/skills/**` are either `SKILL.md` (verbatim) or `SKILL.md.tmpl` (templated).

Variables

This section is empty.

Functions

func Fingerprint

func Fingerprint(data []byte) string

Fingerprint returns the lowercase-hex SHA-256 of the given bytes. Used to compare "what init would write now" against "what's on disk" to decide whether the user has edited the file.

func IsDrifted

func IsDrifted(workspaceRoot, pipelinePath string) (bool, error)

IsDrifted returns true when the pipeline.yaml at pipelinePath differs from the bytes whose fingerprint was recorded in the sidecar. A missing sidecar is treated as "user-edited" (safe default).

func Pipeline

func Pipeline(src []byte, cat *catalog.Catalog, sel map[string]bool) ([]byte, []string, error)

Pipeline re-renders pipeline.yaml against the resolved selection, dropping nodes whose agent belongs to a deselected component and pruning `depends_on` references to dropped nodes. Returns the marshalled bytes and the set of dropped node ids (for the init summary + conflict report).

func ReadFingerprint

func ReadFingerprint(workspaceRoot string) (string, error)

ReadFingerprint returns the sidecar's recorded hex (empty string if absent — callers treat "no sidecar" as "user-edited" by default).

func Skill

func Skill(src []byte, ctx Ctx, cat *catalog.Catalog) ([]byte, error)

Skill parses the given template source, validates that every referenced component id exists in the catalog (AST pre-pass; fails before any file is written), and renders the template against `ctx`. Returns the rendered bytes and a slice of WARNINGS: empty on a clean render; non-empty when the template parsed but referenced identifiers that should be surfaced.

func WriteFingerprint

func WriteFingerprint(workspaceRoot, hex string) error

WriteFingerprint writes the sidecar to workspaceRoot, creating the `.bender/` dir if needed.

Types

type ComponentCtx

type ComponentCtx struct {
	ID          string
	Selected    bool
	Description string
}

ComponentCtx is the per-component view exposed to templates.

type Ctx

type Ctx struct {
	Components map[string]ComponentCtx
}

Ctx is the root data passed to every skill template.

func BuildCtx

func BuildCtx(cat *catalog.Catalog, sel map[string]bool) Ctx

BuildCtx projects the resolved selection map into a template context.

Jump to

Keyboard shortcuts

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