11# promptyst
22
3- A contract-first Typst DSL for structured AI prompts.
3+ A contract-first Typst DSL for structured AI prompts.
44Five primitives. Deterministic Markdown output. No runtime dependencies.
55
66---
@@ -19,13 +19,13 @@ Exactly five. No others.
1919
2020| Constructor | Returns |
2121| -------------| ---------|
22- | ` p-context(id, entries) ` | context dict |
23- | ` p-schema(id, fields) ` | schema dict |
24- | ` p-checkpoint(id, after-step, assertion, on-fail) ` | checkpoint dict |
25- | ` p-chat-mode(id, turns, state, prompt) ` | chat-mode dict |
26- | ` p-prompt(id, version, role, ctx, constraints, steps, inputs, schema, checkpoints?) ` | prompt dict |
22+ | ` p-context(id: str , entries: array ) ` | context dict |
23+ | ` p-schema(id: str , fields: array ) ` | schema dict |
24+ | ` p-checkpoint(id: str , after-step: int , assertion: str , on-fail: str ) ` | checkpoint dict |
25+ | ` p-chat-mode(id: str , turns: str , state: str , prompt: dict ) ` | chat-mode dict |
26+ | ` p-prompt(id: str , version: str , role: str , ctx: dict , constraints: array , steps: array , inputs: array , schema: dict , checkpoints?: array ) ` | prompt dict |
2727
28- All constructors return plain Typst dictionaries. No rendering occurs at construction time.
28+ All parameters are ** named ** (keyword arguments). All constructors return plain Typst dictionaries. No rendering occurs at construction time.
2929
3030---
3131
@@ -43,6 +43,56 @@ All renderers are pure functions. Same input always produces byte-identical outp
4343
4444---
4545
46+ ## TOML Ingestion
47+
48+ ``` typst
49+ #let result = from-toml(read("my-prompt.toml"))
50+ #raw(render-prompt(result.prompt), lang: "markdown")
51+ ```
52+
53+ ` from-toml(raw) ` parses a TOML string and returns a dictionary. If all required sections are present, the ` prompt ` key contains a fully assembled prompt dict. Partial TOML (e.g. only ` [context] ` ) returns only the sections found — no panic for missing sections.
54+
55+ Available keys in the result: ` aspect ` , ` context ` , ` schema ` , ` constraints ` , ` steps ` , ` inputs ` , ` checkpoints ` , ` prompt ` , ` meta ` , ` constraints-meta ` .
56+
57+ Metadata (` [rationale] ` , constraint ` severity ` ) is preserved in the result but never rendered.
58+
59+ See ` tests/fixtures/full-prompt.toml ` for the full TOML schema.
60+
61+ ---
62+
63+ ## Shorthand Helpers
64+
65+ Lighter syntax for building prompts in pure Typst. These are ` v0 ` — not under the immutable 10-symbol contract.
66+
67+ | Helper | Equivalent to |
68+ | --------| ---------------|
69+ | ` entry(key, value) ` | ` (key: key, value: value) ` |
70+ | ` field(name, typ, desc) ` | ` (name: name, type: typ, description: desc) ` |
71+ | ` ctx(id, ..entries) ` | ` p-context(id: id, entries: ...) ` |
72+ | ` schema(id, ..fields) ` | ` p-schema(id: id, fields: ...) ` |
73+ | ` checkpoint(id, after-step, assertion, on-fail) ` | ` p-checkpoint(id: ..., ...) ` |
74+
75+ ``` typst
76+ // Before (core constructors)
77+ #let my-ctx = p-context(
78+ id: "net-ctx",
79+ entries: (
80+ (key: "firewall", value: "443 + 22 open"),
81+ (key: "gateway", value: "18789 loopback"),
82+ ),
83+ )
84+
85+ // After (helpers)
86+ #let my-ctx = ctx("net-ctx",
87+ entry("firewall", "443 + 22 open"),
88+ entry("gateway", "18789 loopback"),
89+ )
90+ ```
91+
92+ ` ctx ` is named ` ctx ` not ` context ` — ` context ` is a Typst keyword.
93+
94+ ---
95+
4696## Usage
4797
4898``` typst
@@ -150,7 +200,7 @@ Checkpoints are sorted at construction by `(after-step ASC, id ASC)`. Declaratio
150200
151201## Output Schema: {schema.id}
152202
153- ## Checkpoint: {id} ← zero or more, sorted (after-step ASC, id ASC)
203+ ## Checkpoint: {id} <- zero or more, sorted (after-step ASC, id ASC)
154204```
155205
156206---
@@ -164,10 +214,10 @@ Every missing required field, out-of-range value, or type mismatch is a compile-
164214## Layering
165215
166216```
167- promptyst (this package) ← DSL scope only
168- → opinionated layers ← separate package
169- → vendor adapters ← separate package
170- → runtime ← external, not in scope
217+ promptyst (this package) <- DSL scope only
218+ -> opinionated layers <- separate package
219+ -> vendor adapters <- separate package
220+ -> runtime <- external, not in scope
171221```
172222
173223promptyst has no knowledge of runtimes, vendors, transports, agents, or evaluation pipelines.
0 commit comments