/**
* Minimal macro engine for prompt text — replaces `{{name}}` tokens from a
* context map so directive/world text can stay declarative. Unknown macros are
* left intact rather than blanked.
*/
export type MacroContext = Record<string, string>;
/** Replace `{{name}}` tokens using `context`. */
export function renderMacros(template: string, context: MacroContext): string {
return template.replace(/\{\{\s*([\w.]+)\s*\}\}/g, (whole, name: string) =>
name in context ? context[name] : whole,
);
}