Class: TemplateExpander
Defined in: packages/core/src/application/template-expander.ts:43
Encapsulates {{namespace.key}} template expansion logic.
Receives built-in variables at construction time (e.g. project.root).
Each expansion call merges contextual variables with built-ins, where
built-in keys take precedence on collision.
Constructors
Constructor
new TemplateExpander(
builtins,onUnknown?):TemplateExpander
Defined in: packages/core/src/application/template-expander.ts:53
Creates a new TemplateExpander with the given built-in variables.
Parameters
builtins
Variables always present in every expansion (e.g. { project: { root: '...' } })
onUnknown?
OnUnknownVariable
Optional callback invoked when a token cannot be resolved
Returns
TemplateExpander
Methods
expand()
expand(
template,variables?):string
Defined in: packages/core/src/application/template-expander.ts:67
Expands {{namespace.key}} tokens with verbatim substitution.
Used for instruction text consumed by agents — no shell escaping.
Parameters
template
string
The template string containing optional {{namespace.key}} tokens
variables?
Contextual variables merged with built-ins (built-ins win on collision)
Returns
string
The expanded string
expandForShell()
expandForShell(
template,variables?):string
Defined in: packages/core/src/application/template-expander.ts:80
Expands {{namespace.key}} tokens with shell-escaped substitution.
Used for run: hook commands — all values are shell-escaped to prevent injection.
Parameters
template
string
The command string containing optional {{namespace.key}} tokens
variables?
Contextual variables merged with built-ins (built-ins win on collision)
Returns
string
The expanded and shell-escaped string