Documentation
¶
Overview ¶
Package scaffold renders embedded starter templates into a target directory so callers can bootstrap a SpeechKit integration without hand-copying boilerplate. The engine is invoked from speechkitctl init for humans and from speechkit-mcp's read-only scaffold tools for coding agents; both share the same template set.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownTemplate is returned when ScaffoldOptions.Template does // not match any embedded template directory. ErrUnknownTemplate = errors.New("scaffold: unknown template") // ErrMissingRequiredVar is returned when a non-optional VarSpec is // neither overridden nor satisfiable from EnvHint and Default and // Interactive is false. ErrMissingRequiredVar = errors.New("scaffold: missing required variable") )
Functions ¶
Types ¶
type GeneratedFile ¶
GeneratedFile is one file the scaffolder produced. AbsPath is set only when OutputDir was configured.
type HookResult ¶
HookResult records the outcome of one PostInitHook execution.
type PostInitHook ¶
PostInitHook is a command run after files are written. Hooks fire in declaration order; the first non-zero exit aborts the rest.
type Result ¶
type Result struct {
Template string
Vars map[string]string
Files []GeneratedFile
// Hooks reports which post-init hooks were executed (nil unless
// RunPostInit was set).
Hooks []HookResult
}
Result is returned by Scaffold and is also the response shape the MCP generate_integration tool serialises to JSON.
func Scaffold ¶
func Scaffold(opts ScaffoldOptions) (*Result, error)
Scaffold renders the named template with the supplied variables. When OutputDir is non-empty, the resulting files are written to disk and the returned GeneratedFile entries carry AbsPath. When OutputDir is empty the engine returns the rendered content in-memory only, used by the MCP scaffold tool to hand files back to the calling agent.
func ScaffoldContext ¶ added in v0.31.0
func ScaffoldContext(ctx context.Context, opts ScaffoldOptions) (*Result, error)
ScaffoldContext is Scaffold with caller-controlled cancellation for post-init hooks. ctx must be non-nil.
type ScaffoldOptions ¶
type ScaffoldOptions struct {
// Template is the directory name under templates/.
Template string
// OutputDir is the absolute path to write files into. If empty, the
// engine returns generated files in Result.Files without touching disk.
OutputDir string
// Vars are caller-provided variable overrides. They take precedence
// over template defaults and EnvHint lookups.
Vars map[string]string
// Interactive, when true, prompts on stdin for any required variable
// not satisfied by Vars / EnvHint / Default.
Interactive bool
// In and Out are used for interactive prompting and progress output.
// When nil they default to os.Stdin and os.Stdout.
In io.Reader
Out io.Writer
// RunPostInit, when true, executes PostInitHook commands after files
// are written. Disabled by default; hosts opt in.
RunPostInit bool
}
ScaffoldOptions configure a Scaffold call.
type TemplateMeta ¶
type TemplateMeta struct {
Name string `toml:"name"`
Description string `toml:"description"`
MinServerVersion string `toml:"min_server_version"`
Vars []VarSpec `toml:"vars"`
PostInit []PostInitHook `toml:"post_init"`
NextSteps []string `toml:"next_steps"`
}
TemplateMeta is the parsed template.toml.
func ListTemplates ¶
func ListTemplates() ([]TemplateMeta, error)
ListTemplates returns the metadata for every embedded template in alphabetical order by name.
func LookupTemplate ¶
func LookupTemplate(name string) (TemplateMeta, error)
LookupTemplate returns metadata for a single template, or ErrUnknownTemplate if the template is not a complete published template.