Expand description
Prompt-template engine for .harn.prompt assets and the render /
render_prompt builtins.
§Surface
{{ name }} interpolation
{{ user.name }} / {{ items[0] }} nested path access
{{ name | upper | default: "anon" }} filter pipeline
{{ if expr }}..{{ elif expr }}..{{ else }}..{{ end }}
{{ for x in xs }}..{{ else }}..{{ end }} else = empty-iterable fallback
{{ for k, v in dict }}..{{ end }}
{{ include "partial.harn.prompt" }}
{{ include "partial.harn.prompt" with { x: name } }}
{{# comment — stripped at parse time #}}
{{ raw }}..literal {{braces}}..{{ endraw }}
{{- x -}} whitespace-trim markersBack-compat: bare {{ident}} resolves silently to the empty fallthrough
(writes back the literal text on miss) — preserving the pre-v2 contract.
All new constructs raise TemplateError on parse or evaluation failure.
Structs§
- Prompt
Source Span - One byte-range in a rendered prompt mapped back to its source
template. Foundation for the prompt-provenance UX (burin-code #93):
hover a chunk of the live prompt in the debugger and jump to the
.harn.promptline that produced it. - Registered
Prompt
Enums§
Functions§
- lookup_
prompt_ consumers - Return every span across every registered prompt that overlaps a template range. Powers the inverse “which rendered ranges consumed this template region?” navigation.
- lookup_
prompt_ span - Resolve an output byte offset to its originating template span.
Returns the innermost matching
Expr/LegacyBareInterpspan when one exists, falling back to broader structural spans (If / For / Include) so a click anywhere in a rendered loop iteration still navigates somewhere useful. - next_
prompt_ render_ ordinal - Produce the next monotonic ordinal for a render-mark. Pipelines
invoke the
prompt_mark_renderedbuiltin which calls this to obtain a sequence number without having to know about per-session event counters. The IDE scrubber orders matching consumers by this ordinal when the emitted_at_ms timestamps collide. - prompt_
render_ indices - Fetch every event index where
prompt_idwas rendered. Called by the DAP adapter to populate theeventIndiceslist in theburin/promptConsumersresponse. - record_
prompt_ render_ index - Record a render event index against a prompt_id (#106). The scrubber’s jump-to-render action walks this map to move the playhead to the AgentEvent where the template was consumed. Stored as a Vec so re-renders of the same prompt id accumulate.
- render_
template_ to_ string - Render a template for callers outside the VM crate that need the same
prompt-template semantics as
render(...)/render_prompt(...). - validate_
template_ syntax - Parse-only validation for lint/preflight. Returns a human-readable error
message when the template body is syntactically invalid;
Ok(())when the template would parse. Does not resolve{{ include }}targets — those are validated at render time with their own error reporting.