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.3 KiB
Raw Permalink Blame History

TASK task-line-parser: parse and format Tasks-plugin lines in the new crate notescraft-tasks

Runs through OpenCode (specs/agents/opencode-runbook.md is attached automatically). Task 1 of specs/plugins-parity/tasks-view/tasks.md. Precondition (lead step 0, already done when this runs): crates/tasks exists with a Cargo.toml, registered at L3. If crates/tasks/Cargo.toml is missing, stop and say so.

OWNS

  • crates/tasks/src/lib.rs (module decls, pub use, crate //! doc), crates/tasks/src/error.rs (one thiserror Error, pub type Result<T>), crates/tasks/src/task.rs, crates/tasks/src/parse.rs
  • crates/tasks/tests/parse.rs, crates/tasks/tests/fixtures/lines.txt

FILES TO OPEN

  • specs/plugins-parity/tasks-view/spec.md D2 (line grammar and the Task struct, copy the field names)
  • crates/engine/src/calendar/tasks.rs (an existing, narrower parse_line: do not edit, do not depend on it)
  • crates/templates/src/date.rs (Date::new, FromStr/display for YYYY-MM-DD)
  • crates/markdown/src/scanning/scan.rs (all_tags: use it for Task.tags)

GOAL / API

Write crates/tasks/src/task.rs FIRST (types), as your first tool call, then parse.rs.

pub enum Priority { Lowest, Low, Normal, Medium, High, Highest }   // derive Ord, Default = Normal
pub enum OnCompletion { Keep, Delete }                              // Default = Keep
pub struct Task { /* all fields of spec D2, derive Debug, Clone, PartialEq, Default */ }
pub fn parse_line(line: &str) -> Option<Task>;   // path "", line 0, heading None until scan_note
pub fn format_line(task: &Task) -> String;       // indent + marker + [status] + description + signifiers in fixed order
  • Peel signifiers from the END of the line while the tail is <emoji> <value>; the rest is the description (trimmed). Emoji: created ➕, start 🛫, scheduled ⏳, due 📅, done ✅, cancelled ❌, priority 🔺 ⏫ 🔼 🔽 ⏬ (no value), recurrence 🔁 <rule text>, on completion 🏁 keep|delete, id 🆔 <id>, depends ⛔ a,b.
  • A date that does not parse (2026-13-40) is NOT a signifier: leave it in the description, set no date.
  • format_line fixed order: 🆔 ⛔ priority 🔁 🏁 ➕ 🛫 ⏳ 📅 ❌ ✅, single spaces.
  • Not a task (return None): no list marker, no [c] box, line over 2 000 chars.
  • No panics: use get(), strip_prefix, char_indices; never [i] or [a..b].

TESTS

crates/tasks/tests/parse.rs + fixtures/lines.txt (one case per line, input then expected fields): all lines from the Tasks Emoji Format page; round trip format_line(parse_line(x)) == x for lines already in fixed order; unknown emoji stays in description; 🔁 every week on Tuesday, Friday keeps the whole rule; priority emoji each; * [x], 1. [ ], + [-], indent of 4 spaces and a tab; empty description; 3 000-char line is None; invalid date stays text; tags #a/b collected.

VERIFY

export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-tasks
cargo clippy -p notescraft-tasks --all-targets -- -D warnings
rustfmt --edition 2024 crates/tasks/src/*.rs crates/tasks/tests/*.rs

DO NOT

Edit Cargo files, the calendar code or the engine; read files (scanning a note is task 5); handle toggle or recurrence (tasks 2 to 4); add a dependency; write a second tag regex.