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. Validation is strict on plan-doc's own fields (loud failures
on bad values and typos) but lenient on foreign top-level fields a host
project carries alongside the schema (captured in .extra).
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: 1is required;template,disposal,phase,cleanup_trigger,ticket,branch,tdd_mode,dossierare plan-doc's own top-level keys. Foreign top-level keys (a host project's own frontmatter convention —id,title,status, …) are tolerated and captured inPlanDoc.extra, so a plan can carry both schemas at once. The typo guard survives: an unknown key within edit-distance 1 of a known field still raisesPlanDocError(dispozalfails loud), so a misspelling can't silently disable disposal/minimal handling. (Lenient policy since 0.1.1; 0.1.0 rejected every non-schema key.) - 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_schemaand no plan indicator fields raises the typed subclassNonDraftPrFrontmatterError, so callers can treat non-plan documents leniently without swallowing real validation errors. - No frontmatter at all raises
PlanDocErrorwith an actionable message (addplan_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
Originally extracted (code byte-identical, module docstring reframed) from the draft-pr skill of the m0j0d portfolio plugin. As of 2026-06-14 this package is the canonical source of truth: the plugin's vendored copy was deleted and plugin now consumes this package via editable install.
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
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 plan_doc-0.1.1.tar.gz.
File metadata
- Download URL: plan_doc-0.1.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51a8b2030a7f22b40da8c8c9c2134511b53deb02fd63e2432bb38feb3d3d0db4
|
|
| MD5 |
00561a5b270d7e0637d00891bbfc00c1
|
|
| BLAKE2b-256 |
29a582da215f1f81fa026e5ef2cfd54130f9351c1fc84dc94132eae5ce37b340
|
Provenance
The following attestation bundles were made for plan_doc-0.1.1.tar.gz:
Publisher:
release-plan-doc.yml on m0j0d/libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plan_doc-0.1.1.tar.gz -
Subject digest:
51a8b2030a7f22b40da8c8c9c2134511b53deb02fd63e2432bb38feb3d3d0db4 - Sigstore transparency entry: 2163050804
- Sigstore integration time:
-
Permalink:
m0j0d/libs@640174783225637aee9978b47d5ddcdd9eb249e5 -
Branch / Tag:
refs/tags/plan-doc-v0.1.1 - Owner: https://github.com/m0j0d
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-plan-doc.yml@640174783225637aee9978b47d5ddcdd9eb249e5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file plan_doc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: plan_doc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
daf404641d1393c9eaf2f48a80aae7898767cf894d099b8c8aeb7322fcdc231b
|
|
| MD5 |
1d33d4c9a029f2d92d516dbf06d78655
|
|
| BLAKE2b-256 |
77b2f7f1ee328f19046242e69ae8c886b8ffbf315649a816ad7be421f55cf157
|
Provenance
The following attestation bundles were made for plan_doc-0.1.1-py3-none-any.whl:
Publisher:
release-plan-doc.yml on m0j0d/libs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
plan_doc-0.1.1-py3-none-any.whl -
Subject digest:
daf404641d1393c9eaf2f48a80aae7898767cf894d099b8c8aeb7322fcdc231b - Sigstore transparency entry: 2163050814
- Sigstore integration time:
-
Permalink:
m0j0d/libs@640174783225637aee9978b47d5ddcdd9eb249e5 -
Branch / Tag:
refs/tags/plan-doc-v0.1.1 - Owner: https://github.com/m0j0d
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-plan-doc.yml@640174783225637aee9978b47d5ddcdd9eb249e5 -
Trigger Event:
push
-
Statement type: