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.2.0.tar.gz (6.6 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.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file ymd_prompt-0.2.0.tar.gz.

File metadata

  • Download URL: ymd_prompt-0.2.0.tar.gz
  • Upload date:
  • Size: 6.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 02eda9edbd656fcf18e791ec4e6bfb8e9fc28aee6a0985a315e3572a3558e61b
MD5 e68b9e1060c4455383336e7497f79b2d
BLAKE2b-256 ca08815d3b6739c2dc455e8721baba9d0470b7a32b275e8b6f0015681047b999

See more details on using hashes here.

Provenance

The following attestation bundles were made for ymd_prompt-0.2.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: ymd_prompt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.7 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5e8a50b81c7cb9c3e57532dd6eef83ae31dff907d667e19e55a2ea8d7aae053
MD5 628b34dd10f4ce20d28014af362bc0a3
BLAKE2b-256 5c0420d4a6232f72aeda57592c9af022c6751ed59ccae2b3a15fccb3d7fcbde0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ymd_prompt-0.2.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