Skip to main content

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) and loads(text) using yaml.safe_load
  • 🧩 Rendering with Jinja2: render(prompt, context) replaces {{var}}
  • 🔎 Placeholder discovery: list_placeholders()
  • 🔒 strict_placeholders=True to enforce completeness
  • 🖥️ CLI: ymd for 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ymd_prompt-0.3.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ymd_prompt-0.3.0-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

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

Hashes for ymd_prompt-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b76a941705b0ae91ca2fea925a9f6d627f35aafa746eee8f0baba803ffa58626
MD5 e620926fff976d2018bca83c673fe276
BLAKE2b-256 1575e298243c387ffc6dfe4e90278458f9261436d8dca0bedb83c4e4013b3264

See more details on using hashes here.

Provenance

The following attestation bundles were made for ymd_prompt-0.3.0.tar.gz:

Publisher: publish-pypi.yml on daviguides/ymd-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ymd_prompt-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d108b3b902509f80fc297745111df821a5c52f342199b687c6dcab01e0a5486c
MD5 30ae7271a5b246247fe4d9dcd09b8e37
BLAKE2b-256 168d41aa1df6b90b13bfb1b2796325e165d543a48267003bae1fe7968eb27f55

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page