gleamunison/prompt

Content-addressed prompts (gap analysis concept C).

Prompts are template strings stored as definitions in the codebase DAG: the ref is the hash of the domain-tagged content, so a prompt’s hash is immutable identity, audit tag, and deployment handle in one. Hash-pinned rollout = swap which ref your root points at; A/B = two refs; peer sync = the existing pull machinery, conflict-free by construction.

Rendering is RAW {{var}} substitution — deliberately NOT the web template engine, whose HTML escaping would corrupt prompt payloads.

Types

pub type PromptError {
  NotFound
  Unreadable
  MissingVar(String)
  Storage(reason: String)
}

Constructors

  • NotFound
  • Unreadable
  • MissingVar(String)
  • Storage(reason: String)

Values

pub fn get(
  cb: codebase.Codebase,
  ref: identity.DefinitionRef,
) -> Result(String, PromptError)

Fetch a prompt template by hash.

pub fn put(
  cb: codebase.Codebase,
  template: String,
) -> #(codebase.Codebase, identity.DefinitionRef)

Store a prompt template; returns the codebase and its content hash.

pub fn ref_hex(ref: identity.DefinitionRef) -> String

Displayable hash identity for traces and pins.

pub fn render(
  template: String,
  vars: List(#(String, String)),
) -> Result(String, PromptError)

Raw substitution of {{vars}} — no HTML escaping (prompts are not markup).

pub fn render_by_hash(
  cb: codebase.Codebase,
  ref: identity.DefinitionRef,
  vars: List(#(String, String)),
) -> Result(String, PromptError)
pub fn vars(template: String) -> List(String)

The {{var}} names a template expects, deduped in first-appearance order.

✨ Search Document