Skip to main content

Typed parser for plan-file YAML frontmatter (schema v1) — strict validation, first-block-only extraction, foreign-document discrimination

Project description

plan-doc

Typed parser for plan-file YAML frontmatter (schema v1). Extracts the machine-readable fields a plan-driven-PR workflow needs — template, disposal, branch, a planner-handoff dossier block — from markdown plan documents, with strict validation and loud failures.

from pathlib import Path
from plan_doc import PlanDoc, PlanDocError, NonDraftPrFrontmatterError

doc = PlanDoc.from_path(Path("docs/plans/my-plan.md"))
if doc.disposal == "delete-on-merge":
    ...
if doc.dossier is not None:
    files = doc.dossier.get("files", [])

What it enforces

  • Schema v1. plan_schema: 1 is required; template, disposal, phase, cleanup_trigger, ticket, branch, tdd_mode, dossier are the only other top-level keys. Unknown keys raise PlanDocError — this is the typo guard (dispozal fails loud).
  • First-block-only parsing. Only a ---...--- block at the very top of the file is frontmatter. Body-level --- horizontal rules are never split on.
  • Foreign-document discrimination. Valid frontmatter with no plan_schema and no plan indicator fields raises the typed subclass NonDraftPrFrontmatterError, so callers can treat non-plan documents leniently without swallowing real validation errors.
  • No frontmatter at all raises PlanDocError with an actionable message (add plan_schema: 1).

Dependency note

pyyaml is a hard dependency, and the module also keeps a minimal no-yaml fallback parser (_parse_yaml_minimal) for simple key: value frontmatter. Both halves are deliberate: the upstream source of this module runs in a zero-pip environment and relies on the fallback, while the package declares full functionality. The fallback is covered by tests here — don't remove either half.

Provenance

Extracted verbatim (code byte-identical, module docstring reframed) from the draft-pr skill of the m0j0d portfolio plugin, where the vendored copy remains the operational source of truth. This package mirrors it at release points.

Pool purity rule: transport-free, LLM-agnostic, no secrets. Pure parsing; the only I/O is Path.read_text in PlanDoc.from_path.

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

plan_doc-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

plan_doc-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file plan_doc-0.1.0.tar.gz.

File metadata

  • Download URL: plan_doc-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for plan_doc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ef316d2cbba550a0a0f2f243f371aa874bda25ee51ab3dd2f3f57d50a43f911
MD5 2b917a985533f2fa4d274d1960192dab
BLAKE2b-256 a55207e0a0f1541633d1aa81e7d0758efbc2652b6fc2d0c56742f2b0f577e165

See more details on using hashes here.

Provenance

The following attestation bundles were made for plan_doc-0.1.0.tar.gz:

Publisher: release-plan-doc.yml on m0j0d/libs

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

File details

Details for the file plan_doc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: plan_doc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for plan_doc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90e2c7db29696818113ea8f6ee80ede4afd54813e0c7caea32cb6608a6aa2624
MD5 1d2c559a187140e1d33df1e75b9c8c74
BLAKE2b-256 cb596c9103e75fef4eb5e5e2c82ee9655c9cbfde478967220623f9921871270e

See more details on using hashes here.

Provenance

The following attestation bundles were made for plan_doc-0.1.0-py3-none-any.whl:

Publisher: release-plan-doc.yml on m0j0d/libs

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