Documentation
¶
Index ¶
- Variables
- func BuildContext(steps []StepState) map[string]interface{}
- func ExpandAllComposites(ops []map[string]interface{}) ([]map[string]interface{}, error)
- func ExpandComposite(op map[string]interface{}) ([]map[string]interface{}, error)
- func FixBatchOps(data []byte) ([]byte, []string, error)
- func InterpolateParams(params map[string]interface{}, steps []StepState) (map[string]interface{}, error)
- func InterpolateValue(value interface{}, ctx map[string]interface{}) (interface{}, error)
- func IsComposite(command string) bool
- func NormalizeBatchParams(command string, params map[string]interface{}) map[string]interface{}
- func NormalizeCSSProps(params map[string]interface{}) map[string]interface{}
- func ResolveTokenAliases(ops []map[string]interface{}) (applied int, rootWidth int)
- func SanitizeStepName(name string) string
- func StripJSONComments(data []byte) []byte
- func StripMarkdownFences(data []byte) []byte
- type StepState
Constants ¶
This section is empty.
Variables ¶
var KnownTopLevelProps = []string{
"x", "y", "width", "height", "w", "h",
"color", "fillColor", "bg",
"fontSize", "fontFamily", "fontStyle", "sz", "ff", "fs",
"parentId", "pid",
"cornerRadius", "r",
"layoutMode", "itemSpacing", "padding", "opacity",
"text", "imageData", "stroke", "strokeWidth",
}
KnownTopLevelProps are design properties that belong inside "params", not at op root. Exported so validate.go can reference the same list.
Functions ¶
func BuildContext ¶
BuildContext creates an interpolation context from completed steps.
func ExpandAllComposites ¶ added in v0.10.0
ExpandAllComposites processes a batch array, expanding any composite ops.
func ExpandComposite ¶ added in v0.10.0
ExpandComposite expands a single composite op into primitive batch ops. Non-composite commands pass through as single-element slices.
func FixBatchOps ¶ added in v0.9.1
FixBatchOps applies auto-corrections to common LLM output drift. Returns: fixed JSON bytes, list of human-readable fix descriptions, error. Error is non-nil only if the input cannot be parsed at all.
func InterpolateParams ¶
func InterpolateParams(params map[string]interface{}, steps []StepState) (map[string]interface{}, error)
InterpolateParams resolves placeholders in params using prior step results.
func InterpolateValue ¶
InterpolateValue recursively resolves placeholders in arbitrary JSON-like data.
func IsComposite ¶ added in v0.10.0
IsComposite returns true if command is a composite that needs expansion.
func NormalizeBatchParams ¶ added in v0.6.0
NormalizeBatchParams expands shorthand keys for batch operations. It is intentionally command-aware to avoid key collisions.
func NormalizeCSSProps ¶ added in v0.10.5
NormalizeCSSProps maps CSS-like properties to Figma-native properties. It is called during batch parameter normalization so LLMs can write familiar CSS properties. CSS props are lower priority — they never overwrite Figma-native properties that are already set. The function modifies params in-place AND returns it.
func ResolveTokenAliases ¶ added in v0.10.6
ResolveTokenAliases resolves semantic token aliases (e.g. sz:"hero", padding:"side", w:"content") to numeric values based on the first root frame's canvas size. It mutates ops in place and returns:
- applied: number of alias replacements made
- rootWidth: detected root frame width (0 if none found)
func SanitizeStepName ¶ added in v0.7.0
SanitizeStepName normalizes a batch step name: lowercase, spaces→underscores, strip non-alphanumeric characters (except _).
func StripJSONComments ¶ added in v0.9.1
StripJSONComments removes // line comments and /* block comments */ from JSON-like input. Models occasionally emit JSONC-style comments which are not valid JSON.
func StripMarkdownFences ¶ added in v0.9.1
StripMarkdownFences removes ```json ... ``` or ``` ... ``` wrappers that models add even when explicitly told not to.