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)

graph LR StructuredPrompt["StructuredPrompt"] FieldClassifierInput["FieldClassifierInput"] FieldValueInput["FieldValueInput"] FormContextFieldInput["FormContextFieldInput"] renderOutputSchema["renderOutputSchema"] ScriptOptimizerInput["ScriptOptimizerInput"] makePrompt["makePrompt"] FieldClassifierInput -->|uses| StructuredPrompt FieldValueInput -->|uses| StructuredPrompt FormContextFieldInput -->|uses| StructuredPrompt renderOutputSchema -->|uses| StructuredPrompt ScriptOptimizerInput -->|uses| StructuredPrompt makePrompt -->|uses| StructuredPrompt style StructuredPrompt fill:#dbeafe,stroke:#2563eb,stroke-width:2px click StructuredPrompt "a828ccf4d3eb7bb7.html" click FieldClassifierInput "20ede86d2d3727e6.html" click FieldValueInput "5ea70ce149b7f9cd.html" click FormContextFieldInput "6194fbe20dc11cf0.html" click renderOutputSchema "a94ee40c258cb1af.html" click ScriptOptimizerInput "426c217d515b02d0.html" click makePrompt "ea0597fcfc9fdb16.html"