CONSUME-AS-DATA-11: Read a real task into typed data
What it demonstrates
Section titled “What it demonstrates”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()
How it’s done
Section titled “How it’s done”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; // typedconst 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}`);Surfaces exercised
Section titled “Surfaces exercised”contract.read end-to-endDoc.frontmatterpromoted TableView iterationSectionView.listsabsent-optional postMortem