5.0 KiB
Tasks: rich link bookmark cards (roadmap 30)
One task = one agent (specs/agents/opencode-runbook.md). Spec: spec.md. Rules: AGENTS.md, docs/CODE-MAP.md. No new crate.
First tool call rule: after at most three reads, write the first OWNS file in your SECOND tool call (compiling stub + ONE failing test), then make it pass.
Standing VERIFY: export PATH="$HOME/.cargo/bin:$PATH"; cargo test -p <pkg>; cargo clippy -p <pkg> --all-targets -- -D warnings; rustfmt --edition 2024 <owned files>; UI tasks add cargo xtask i18n; last task adds cargo xtask layers and cargo xtask tree.
Standing DO NOT: edit Cargo files (except where OWNS lists them), files outside OWNS, git state, cargo fmt --all; add allow; unwrap/expect/panic/[i]/[a..b] on input-derived data; add a dependency; make any network call outside linkcard/fetch.rs.
Owner/lead step 0
Answer Q1 to Q3. Tasks 2+ need clean-paste task 1 merged (crate notescraft-htmlmd); task 1 does not.
Phase 1 - pure engine pieces
- 1. URL guard, normalisation and cache key (brief
briefs/17-linkcard-url-guard.md). OWNS:crates/engine/src/linkcard/url.rs,crates/engine/src/linkcard/mod.rs, onemod linkcard;incrates/engine/src/lib.rs, unit tests insideurl.rs. - 2. OpenGraph extraction.
OWNS:
crates/engine/Cargo.toml(one dep linenotescraft-htmlmd = { workspace = true }),crates/engine/src/linkcard/og.rs,crates/engine/src/linkcard/mod.rs(onemod og;), unit tests inog.rs. FILES TO OPEN:spec.mdD3 and acceptance 6,crates/htmlmd/src/tokens.rs. GOAL:pub(crate) fn parse_card(html_head: &str, final_url: &str) -> Cardwith clipped fields; relative favicon/image URLs resolved againstfinal_url(kept as strings, never fetched);og:*preferred, thentwitter:*,<title>,meta description. TESTS: full OG page; only<title>; relative favicon; attribute order variants; entities in title; 1 MiB title clipped; 10 000 metas bounded; garbage input -> empty card. VERIFY: standing-p notescraft-engine. DO NOT: network; DOM building. - 3. Cache store.
OWNS:
crates/engine/src/linkcard/cache.rs, tests inside. FILES TO OPEN:spec.mdD2,crates/engine/src/bases/tiles/mod.rs(cache folder pattern),crates/engine/src/activity/outbox.rs(write_private),sha2use:git grep -n "sha2" crates/engine/src | head. GOAL:get(&Session, &str) -> Option<Card>,put,clear, eviction beyond 2 000 byfetched_ms; corrupt entry ignored and removed. TESTS: round trip, eviction, corrupt file, path stays inside.notescraft/cache/web/. VERIFY: standing. DO NOT: write outside the cache folder.
Phase 2 - fetch and commands
- 4.
fetch, commands, setting. OWNS:crates/engine/src/linkcard/fetch.rs,.../commands.rs, oneregister_linkcard(reg)call incommands.rs::register_core,crates/engine/src/prefs/web_config.rs,crates/engine/src/prefs/catalog/entry,crates/engine/src/ai/assistant_gate.rs(linkcard.getREAD,linkcard.clearWRITE;linkcard.fetchdeliberately absent, add a comment saying so),crates/engine/tests/core_commands.rs,crates/engine/tests/linkcard.rs. FILES TO OPEN:spec.mdD1 and D3,crates/engine/src/bases/tiles/(the existing opt-in fetcher: copy its switch, timeouts and test stub),crates/engine/tests/publish_stub/(in-process HTTP stub). GOAL: D1 rules exactly, redirects re-checked by hand (ureqagent with redirects 0, loop of 3). TESTS: acceptance 1, 3, 4, 5 against the stub (including a redirect to 127.0.0.1 and a 5 MiB body); concurrency cap;network_disablederror code; assistant gate test proveslinkcard.fetchis not callable by the assistant. VERIFY: standing +--test linkcard --test core_commands. DO NOT: fetch images; fetch fromget.
Phase 3 - UI
- 5. Card block, fetch action, settings.
OWNS:
crates/ui-egui/src/views/note_view/blocks/link_card.rs,crates/ui-egui/src/shell/app/link_cards.rs(worker + memory snapshot),crates/ui-egui/src/views/settings_view/categories/web.rs,crates/ui-egui/src/text/views/link_cards.rs,[ui.link_cards]at END ofen.toml,crates/ui-egui/tests/link_cards.rs. FILES TO OPEN:spec.mdD4,crates/ui-egui/src/views/note_view/blocks/(a finished block, e.g.embed_data.rs),crates/ui-egui/src/views/settings_view/categories/maps.rs(opt-in card to copy),crates/ui-egui/src/views/share_dialog/mod.rs(worker),.claude/skills/notescraft-egui-screen/. GOAL: D4; standalone-URL detection is a pure fn with tests; hook lines in the block dispatcher and the context menu are listed for the lead. TESTS: kittest: cached URL paints card; uncached paints plain link; disabled setting shows notice andFetchsends nothing; 50 URLs -> 0fetchcalls; click opens URL. VERIFY: standing +cargo xtask i18n tree; snapshot PNG read. DO NOT: auto-fetch; hardcode strings; raw widgets. - 6. Docs and status. OWNS:
ROADMAP.md,docs/ARCHITECTURE.md,docs/CODE-MAP.md,specs/plugins-parity/roadmap.md(mark 30 and update the Network policy reminder). VERIFY:cargo xtask ci.