Skip to content

Markdown ​

A plan reads and writes as a Markdown task list, for a person to paste or an agent to write.

tsx
import { createPlan, parsePlanMarkdown, renderPlanText } from '@adecore/plan';
import { ScrollArea, TextArea } from '@adecore/ui';
import { useState } from 'react';

const MARKDOWN = `# Ship the release

Everything that has to happen before a version goes out.

## Prepare

- [x] Write the changelog
- [ ] Run the checks
    - [x] Typecheck
    - [~] Tests
        > Two snapshots to update

## Release

> **Heads-up** A published version cannot be taken back.

- [ ] Approve the release
- [ ] Publish to npm
`;

function readPlan(markdown: string): string {
    const parsed = parsePlanMarkdown(markdown);

    if (!parsed.ok) {
        return `${parsed.code}: ${parsed.message}`;
    }

    let count = 0;
    const created = createPlan(parsed.draft, { id: 'release', now: '2026-10-05T09:00:00.000Z', mintId: () => `item-${++count}` });

    return created.ok ? renderPlanText(created.plan) : `${created.code}: ${created.message}`;
}

export default function PlanMarkdownDemo() {
    const [markdown, setMarkdown] = useState(MARKDOWN);

    return (
        <div className="grid w-full gap-4 md:grid-cols-2">
            <TextArea mono rows={18} value={markdown} onChange={(event) => setMarkdown(event.target.value)} aria-label="Plan as Markdown" />
            <ScrollArea
                axis="x"
                render={<pre />}
                className="rounded-md bg-surface-sunken"
                viewportClassName="p-3 font-mono text-code whitespace-pre-wrap text-text-muted"
            >
                {readPlan(markdown)}
            </ScrollArea>
        </div>
    );
}

The demo runs the Markdown on the left through parsePlanMarkdown and createPlan, and prints renderPlanText on the right.

The format ​

MarkdownPlan
# Title, once, before everything elseThe title
Text before the first itemThe summary
## SectionA section
Text right under a section headingThe section's description
- [ ] StepA step, with the state marker in the brackets
A list item indented under a stepA sub-step
Indented text under a stepThe step's description
An indented > note under a stepThe step's note
> **Title** textA text block
---Ends a section; what follows is at the top

Reading Markdown ​

ts
import { createPlan, parsePlanMarkdown } from '@adecore/plan';

const parsed = parsePlanMarkdown(`# Ship the release

- [ ] Run the tests
- [ ] Approve the release
`);

const created = parsed.ok ? createPlan(parsed.draft, { id: 'release', now: new Date().toISOString() }) : parsed;

parsePlanMarkdown(markdown) returns { ok: true, draft }, a draft for createPlan, or a plan-invalid refusal that names the line. It reads -, * and + items, and an item without a checkbox as an open step. It refuses an unknown marker, a ### heading and text that belongs to nothing. It drops a marker on a parent step. createPlan checks the limits.

Writing Markdown ​

planToMarkdown(plan) writes the same format, four spaces per level. A parent step gets the marker of its derived state. Text that would read as markup gets an escaping backslash.

ts
import { planToMarkdown } from '@adecore/plan';

planToMarkdown(plan);
// # Ship the release
//
// - [x] Run the tests
// - [x] Approve the release

stepToMarkdown(step, describe) writes one step as plain GFM for a clipboard that is not read back. The box is checked for done only, any other state but open follows the title in parentheses as describe(state) words it, and the note is quoted below. Sub-steps and the description stay out.

ts
import { stepToMarkdown } from '@adecore/plan';

stepToMarkdown(step, (state) => state);
// - [ ] Run the tests (failed)
//     > Two cases time out

What Markdown leaves out ​

Markdown carries content, not identity. It leaves out ids, rev, by and at, checks, unlocks, the kind and the status. A plan read back is a new plan with new ids and every state recorded as the agent's. Store plans as JSON.

Licenses and third-party notices are listed in each package.