Skip to content

CONSUME-AS-DATA-11: Read a real task into typed data

One contract reads a live Task end-to-end — frontmatter, a TableView, a list, and absent optionals — then does work with the typed result.

Builds on: CONSUME-AS-DATA-10: Contrast validate() with read()

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const doc = TaskContract.read(src, { path: "docs/planning/tasks/T-AB12.md" });
const { id, status } = doc.frontmatter; // typed
const changed = [...doc.body.filesToTouch] // promoted TableView
.filter(r => r.Kind !== "delete").map(r => r.Location);
const acs = doc.body.acceptanceCriteria.lists[0].items.length;
const worked = doc.body.postMortem !== undefined; // absent on an open task
console.log(`${id} [${status}] touches ${changed.length} files, ${acs} ACs, worked=${worked}`);
  • contract.read end-to-end
  • Doc.frontmatter
  • promoted TableView iteration
  • SectionView.lists
  • absent-optional postMortem