Skip to content

EMBED-AND-CI-01: Run the corpus in-process

Calling runCorpus once with a defineConfig config and reading back {findings, exitCode}.

Builds on: nothing — this is the first rung of Embed and Automate: the Runner Library and CI Gates.

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

import { contract, sections, defineConfig, runCorpus } from "markdown-contract";
const config = defineConfig({
rules: [{ include: ["**/*.md"], contract: contract({ body: sections() }) }],
});
const { findings, exitCode } = runCorpus(config, { cwd: "docs" });
console.log(`${findings.length} finding(s); exit ${exitCode}`);
  • runner: defineConfig, runCorpus
  • core: contract, sections
  • the {findings, exitCode} return