3.5 KiB
TASK kanban-parse: parse a kanban-plugin: board note into lanes and cards in the new crate notescraft-kanban
Runs through OpenCode (specs/agents/opencode-runbook.md is attached automatically). Task 1 of specs/plugins-parity/kanban/tasks.md.
Preconditions (lead step 0, done when this runs): crates/kanban exists with a Cargo.toml registered at L1, and crates/kanban/tests/fixtures/real-board.md (a board saved by the real Obsidian Kanban plugin) is committed. If either is missing, stop and say so; do NOT invent the fixture.
OWNS
crates/kanban/src/lib.rs(crate//!doc,mods,pub use),crates/kanban/src/error.rs(onethiserrorError,pub type Result<T>),crates/kanban/src/model.rs,crates/kanban/src/parse.rscrates/kanban/tests/parse.rs
FILES TO OPEN
specs/plugins-parity/kanban/spec.mdD1 (format), D2 (types and limits), D3 (fidelity)crates/kanban/tests/fixtures/real-board.md(the ground truth: read it before writing the parser)crates/markdown/src/frontmatter/mod.rs(where the frontmatter block ends, and how to read one key)
GOAL / API
Write crates/kanban/src/model.rs as your first tool call.
pub struct Board { pub front: String, pub lanes: Vec<Lane>, pub archive: Vec<Card>,
pub archive_extra: Vec<String>, pub settings_json: Option<String>, pub tail: Vec<String> }
pub struct Lane { pub title: String, pub max_items: Option<u32>, pub complete: bool,
pub cards: Vec<Card>, pub extra: Vec<String> }
pub struct Card { pub checked: bool, pub text: String, pub block_id: Option<String> }
pub fn parse(src: &str) -> Result<Board>;
All types derive Debug, Clone, PartialEq, Default.
- Frontmatter must contain
kanban-plugin: board(orbasic), elseError::NotABoard.frontkeeps the raw block text. ## Titlestarts a lane;## Title (5)setsmax_items = Some(5)andtitle = "Title".- The paragraph
**Complete**right under a lane heading setscomplete = trueand is not a card. - [ ] text/- [x] text(also*and+markers) are cards; indented continuation lines are appended totextwith the indent removed and a\nbetween lines. A trailing^abc123is split intoblock_id.***followed (after blank lines) by## Archivestarts the archive; its list items arearchive, other linesarchive_extra.- A line
%% kanban:settingsbegins the footer; the text inside the ``` fence issettings_json; lines after the closing%%aretail. - Any other line inside a lane section (not a card, not blank) goes to
Lane.extrain order. - Limits: 4 MiB file, 200 lanes, 5 000 cards per lane, 50 000 cards in all, 64 KiB per card:
Error::TooLarge. - Use
lines()/get()/strip_prefix; no[i]or[a..b].
TESTS
crates/kanban/tests/parse.rs: counts and titles from real-board.md; complete lane flagged; archive card count; extra paragraph between lanes lands in Lane.extra; multi-line card; block id split; (5) max items; * marker accepted; CRLF input; missing kanban-plugin is NotABoard; 201 lanes is TooLarge; an empty body after frontmatter parses to zero lanes.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-kanban
cargo clippy -p notescraft-kanban --all-targets -- -D warnings
rustfmt --edition 2024 crates/kanban/src/*.rs crates/kanban/tests/*.rs
DO NOT
Edit Cargo files; serialise (task 2); add serde_json or any dependency; drop unknown content (it goes in extra/tail); touch the engine or UI.