Files
Marcos Paulo de3ec375ae
ci / ci (macos-latest) (push) Has been cancelled
ci / ci (ubuntu-latest) (push) Has been cancelled
ci / ci (windows-latest) (push) Has been cancelled
docs: specs and briefs for Tasks, Templater, Kanban and icons/banners
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 06:06:54 -03:00

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 (one thiserror Error, pub type Result<T>), crates/kanban/src/model.rs, crates/kanban/src/parse.rs
  • crates/kanban/tests/parse.rs

FILES TO OPEN

  • specs/plugins-parity/kanban/spec.md D1 (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 (or basic), else Error::NotABoard. front keeps the raw block text.
  • ## Title starts a lane; ## Title (5) sets max_items = Some(5) and title = "Title".
  • The paragraph **Complete** right under a lane heading sets complete = true and is not a card.
  • - [ ] text / - [x] text (also * and + markers) are cards; indented continuation lines are appended to text with the indent removed and a \n between lines. A trailing ^abc123 is split into block_id.
  • *** followed (after blank lines) by ## Archive starts the archive; its list items are archive, other lines archive_extra.
  • A line %% kanban:settings begins the footer; the text inside the ``` fence is settings_json; lines after the closing %% are tail.
  • Any other line inside a lane section (not a card, not blank) goes to Lane.extra in 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.