Load, validate, and render YMD (YAML + Markdown) prompt files with Pydantic + Jinja2.
Project description
YMD Prompt
YMD Prompt is a small Python library + CLI to load, validate, and render
.ymd / .yamd files — a hybrid format where YAML holds metadata and Markdown holds prompt text.
✨ Features
- ✅ Pydantic models for strict validation (
id,kind,version,title, sections) - 📥 Loader:
load(path)andloads(text)usingyaml.safe_load - 🧩 Rendering with Jinja2:
render(prompt, context)replaces{{var}} - 🔎 Placeholder discovery:
list_placeholders() - 🔒
strict_placeholders=Trueto enforce completeness - 🖥️ CLI:
ymdfor rendering and placeholder inspection
🚀 Install
pip install ymd
📚 Library usage
from ymd import load, render, list_placeholders
p = load("examples/sample.ymd")
needed = list_placeholders(p.sections())
print("placeholders:", needed)
out = render(p, {"diff": "+++ simulated diff +++"})
print(out["user"])
🖥️ CLI usage
# Render and print JSON with all sections
ymd render examples/sample.ymd --var diff="@examples/diff.txt"
# Render a single section to stdout
ymd render examples/sample.ymd --var diff="+++diff+++" --section user
# Render all sections into separate files under out/
ymd render examples/sample.ymd --var diff="+++diff+++" --outdir out
# List placeholders
ymd placeholders examples/sample.ymd
Options
--var KEY=VALUE # add a single variable (use @path to read from file)
--vars-json PATH # load a JSON file with variables
--section NAME # only print given section (system|instructions|user...)
--outdir DIR # write rendered sections to files (NAME.md)
--no-strict # allow missing placeholders (render empty string)
--format json|md # output format (default: json; md prints a combined document)
📂 Example
See examples/sample.ymd.
⚖️ License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ymd_prompt-0.3.0.tar.gz.
File metadata
- Download URL: ymd_prompt-0.3.0.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b76a941705b0ae91ca2fea925a9f6d627f35aafa746eee8f0baba803ffa58626
|
|
| MD5 |
e620926fff976d2018bca83c673fe276
|
|
| BLAKE2b-256 |
1575e298243c387ffc6dfe4e90278458f9261436d8dca0bedb83c4e4013b3264
|
Provenance
The following attestation bundles were made for ymd_prompt-0.3.0.tar.gz:
Publisher:
publish-pypi.yml on daviguides/ymd-prompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ymd_prompt-0.3.0.tar.gz -
Subject digest:
b76a941705b0ae91ca2fea925a9f6d627f35aafa746eee8f0baba803ffa58626 - Sigstore transparency entry: 516709828
- Sigstore integration time:
-
Permalink:
daviguides/ymd-prompt@8d479dfe74eff64a534abfa512843ab1302b4054 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/daviguides
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8d479dfe74eff64a534abfa512843ab1302b4054 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ymd_prompt-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ymd_prompt-0.3.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d108b3b902509f80fc297745111df821a5c52f342199b687c6dcab01e0a5486c
|
|
| MD5 |
30ae7271a5b246247fe4d9dcd09b8e37
|
|
| BLAKE2b-256 |
168d41aa1df6b90b13bfb1b2796325e165d543a48267003bae1fe7968eb27f55
|
Provenance
The following attestation bundles were made for ymd_prompt-0.3.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on daviguides/ymd-prompt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ymd_prompt-0.3.0-py3-none-any.whl -
Subject digest:
d108b3b902509f80fc297745111df821a5c52f342199b687c6dcab01e0a5486c - Sigstore transparency entry: 516709871
- Sigstore integration time:
-
Permalink:
daviguides/ymd-prompt@8d479dfe74eff64a534abfa512843ab1302b4054 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/daviguides
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8d479dfe74eff64a534abfa512843ab1302b4054 -
Trigger Event:
push
-
Statement type: