2.5 KiB
TASK web-capture-envelope: web-clipper first-task model
Runs through OpenCode (specs/agents/opencode-runbook.md attached automatically). Task 1 of specs/plugins-parity/web-clipper/tasks.md.
OWNS
crates/engine/src/capture/web_model.rs(new, first write), unit tests inside it.crates/engine/src/capture/mod.rs(one module declaration only).
FILES TO OPEN
specs/plugins-parity/web-clipper/spec.mdD1.crates/engine/src/capture/rules.rsandcrates/engine/src/capture/mod.rs.
GOAL / API
Write crates/engine/src/capture/web_model.rs in your SECOND tool call: compiling stub plus ONE failing test first. Batch at most three relevant reads in first call, then make test pass. Module declarations listed in OWNS make unit tests discoverable.
Expose crate-private WebCapture::parse(&str) -> Result<Self, CommandError> with metadata, Target, Asset and named caps exactly from spec D1. Envelope v1 accepts Markdown, not arbitrary HTML. Source http(s) without credentials, safe target, title/control validation; base64 decode bounded and PNG/JPEG signatures checked. Eight assets maximum, <=256 KiB each, <=512 KiB aggregate, text <=256 KiB and wire <=1 MiB. Reject duplicate/missing asset ids. Recognize placeholders only in Markdown image destination spans; retain prose/code literal asset text. Reuse existing base64 decoder and Markdown parser; no dependencies. All invalid values return structured errors, never clamp/truncate.
TESTS
Minimal roundtrip; unknown version/field; malformed JSON/types; boundary/+1 for each cap; UTF-8 bytes; credentials/control characters; reserved/traversal target; malformed base64/signature/type; duplicate ids/missing placeholder; asset text inside fenced/inline code unchanged; whitespace-only invalid; valid PNG/JPEG accepted.
VERIFY
export PATH="$HOME/.cargo/bin:$PATH"
cargo test -p notescraft-engine capture::web_model
cargo clippy -p notescraft-engine --all-targets -- -D warnings
rustfmt --edition 2024 crates/engine/src/capture/web_model.rs
Format other owned Rust files individually too; no cargo fmt --all. Verification commands apply when implementing brief; current request is docs only.
DO NOT
Register commands, do IO, open sockets, fetch URLs, convert HTML, touch Cargo or add dependencies. No UI. Owner questions Q1-Q5 remain in spec; pure model needs no dependency decision. Do not edit outside OWNS, change Git state, commit, use unsafe, panic, unwrap/expect or input-derived indexing. No shared craft-libs API changes.