StructuredPrompt interface exported
Last updated: 2026-03-03T11:04:37.489Z
Metrics
LOC: 34
Complexity: 1
Params: 0
Signature
interface StructuredPrompt
Summary
Structured prompt definition — JSON-based, reusable, and self-documenting. All AI prompts in the project implement this interface to guarantee: - Consistent structure (role, task, rules, schema, examples) - Type-safe input/output via generics - Self-contained parsing and validation - Easy maintenance and versioning
Tags
#@typeParam TInput - Shape of the context passed to `buildPrompt()`#@typeParam TOutput - Parsed response type returned by `parseResponse()`
Source Code
export interface StructuredPrompt<TInput, TOutput> {
/** Unique identifier for this prompt (e.g. "field-classifier"). */
readonly id: string;
/** Semver-like version for auditing and cache-busting. */
readonly version: string;
/** Standard LLM role for this prompt (system, user, assistant). */
readonly role: PromptRole;
/** Persona/identity description the AI should adopt. */
readonly persona: string;
/** Concise task description — what the AI must accomplish. */
readonly task: string;
/** Ordered constraints the AI must follow (rendered as numbered rules). */
readonly rules: readonly string[];
/**
* JSON output schema definition (field name, type, constraints).
* Omit for prompts that expect plain-text responses (e.g. value generation).
*/
readonly outputSchema?: readonly PromptOutputField[];
/** Few-shot examples — (input context → expected output). */
readonly examples?: readonly PromptExample[];
/** Assembles the final prompt string from the given input context. */
buildPrompt(input: TInput, userContext?: string): string;
/** Parses raw AI text into TOutput, returning null on failure. */
parseResponse(raw: string): TOutput | null;
}
Members
| Name | Kind | Visibility | Status | Signature |
|---|---|---|---|---|
| buildPrompt | method | - | buildPrompt(input: TInput, userContext?: string): : string | |
| parseResponse | method | - | parseResponse(raw: string): : TOutput | null |
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| FieldClassifierInput | uses |
| FieldValueInput | uses |
| FormContextFieldInput | uses |
| renderOutputSchema | uses |
| ScriptOptimizerInput | uses |
| makePrompt | uses |