renderPromptBase function exported ✓ 100.0%
Last updated: 2026-03-01T23:25:47.071Z
Metrics
LOC: 25
Complexity: 4
Params: 3
Coverage: 100.0% (11/11 lines, 83x executed)
Signature
renderPromptBase(
prompt: StructuredPrompt<TInput, TOutput>,
): : string
Summary
Renders the static (non-input) sections of a structured prompt into a single text block optimised for token economy. Sections rendered (in order): role → task → output format → rules → examples. Use this inside buildPrompt() implementations and then append the per-invocation input context.
Source Code
export function renderPromptBase<TInput, TOutput>(
prompt: StructuredPrompt<TInput, TOutput>,
): string {
const sections: string[] = [];
sections.push(prompt.persona);
sections.push(prompt.task);
if (prompt.outputSchema?.length) {
const schema = renderOutputSchema(prompt.outputSchema);
sections.push(
`Respond ONLY with a JSON object in this exact format — no other text, no markdown, no explanation:\n${schema}`,
);
}
if (prompt.rules.length) {
sections.push(`Rules:\n${renderRules(prompt.rules)}`);
}
if (prompt.examples?.length) {
sections.push(`Examples:\n${renderExamples(prompt.examples)}`);
}
return sections.join("\n\n");
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| renderOutputSchema | calls |
| renderRules | calls |
| renderExamples | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| FieldClassifierInput | uses |
| buildPrompt | calls |
| FieldValueInput | uses |
| buildPrompt | calls |
| renderSystemPrompt | calls |
| ScriptOptimizerInput | uses |
| buildPrompt | calls |
| makePrompt | uses |