package sidekick import ( "bytes" "fmt" "text/template" "github.com/BurntSushi/toml" ) // LoadPrompts reads a TOML file containing multiline prompts and compiles them into a template registry. func LoadPrompts(path string) (*template.Template, error) { var prompts map[string]string if _, err := toml.DecodeFile(path, &prompts); err != nil { return nil, err } tmpl := template.New("prompts") for name, content := range prompts { _, err := tmpl.New(name).Parse(content) if err != nil { return nil, fmt.Errorf("failed to parse prompt template '%s': %w", name, err) } } return tmpl, nil } // RenderPrompt executes a specific prompt template by name. func RenderPrompt(tmpl *template.Template, name string) (string, error) { var buf bytes.Buffer if err := tmpl.ExecuteTemplate(&buf, name, nil); err != nil { return "", err } return buf.String(), nil }