Medlar/CLAUDE.md
2026-11-25 13:21:10 -06:00

7.6 KiB

Medlar

Medlar is a download manager for Linux in Rust and egui: all of Free Download Manager's features and more, downloads split into dynamic parts, limits, priorities, queues, video sites, a local port that takes downloads from browsers, and a Material You (M3 Expressive) interface with spring motion and wavy progress bars. What it must do: docs/FEATURES.md. Final deliverable: a tested AppImage and tar.gz, for the user and for release on Astar Hub. Vision: PLAN.md.

0. Session rules

  1. Started with one plan (Plans/<NN Category>/SNNN-*.md): read only your plan and what it names. Not other plans, ORCHESTRATOR.md or all of PLAN.md. Only the orchestrator reads docs/HANDOFF.md, docs/STATUS.md.
  2. Few steps, short output: batch reads and edits, cap command output, never read the same thing twice.
  3. No testing while building: no tests written or run, no screenshots, no app runs, no release builds, unless the plan says Phase: test. One compile check: nice cargo check -q -j 2 -p medlar. Write your test file docs/tests/SNNN-slug.md (checks in words, from docs/tests/_TEMPLATE.md).
  4. Stay in scope; ideas go to docs/PROGRESS.md (“Later”). Invent nothing: check the code or docs, else ask the orchestrator (the user if there is none).
  5. End: boxes ticked, PROGRESS entry (≤ 5 lines), docs/DECISIONS.md if a decision binds later plans, INDEX line ticked, commit SNNN: … and push to origin if it is set. Report what was not done and not tested. The orchestrator writes the tracker (https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H, collection plans).
  6. Languages: English, short.

1. Repository layout

Root: the folder holding this file

Keep this list true (tools/, assets/ and docs/CONNECTOR come with their plans):
crates/core/       engine, limits, queues, store, connector server; no UI code
crates/app/        egui app: theme, motion, widgets, views, dialogs, tray
crates/cli/        command line and headless mode, a library used by the `medlar` binary
crates/testserver/ local server with faults for tests (ranges, throttle, cuts, expiry, logins)
tools/             screenshot, hidden-run, icon and packaging scripts
assets/            icon, fonts, Material Symbols
docs/              FEATURES, PROGRESS, DECISIONS, STATUS, CONNECTOR, tests/ (one test file per plan); tracker.html is the tracker page's source
Plans/             one plan per session

Never modify: everything outside this folder. ~/Projects/* is read-only reference (copy code in, never edit there). ~/.abdm and the running AB Download Manager are the user's: never stop, read or reconfigure them.

2. Facts

  • Reuse (the user's own code, read-only): Damson src/motion.rs (spring presets), src/theme.rs (OKLCH roles from a seed); Mulberry src/ui/shape.rs (morphing shapes), src/ui/widgets.rs (wavy_slider, buttons, menus), src/tray.rs; Nacre tools/nested-session.sh, tools/hidden.sh (hidden nested niri runs) and src/net/dlm.rs (custom_body: the JSON Nacre posts).
  • Seen on crates.io 2026-11-24: eframe/egui_kittest 0.37.0, tokio 1.54.1, hyper 1.13.0, reqwest 0.13.5, axum 0.8.9, suppaftp 13.0.0, russh 0.65.4, rusqlite 0.43.0, ksni 0.3.7. Check the docs of the pinned version before using an API.
  • This PC: Arch Linux, niri (Wayland), 4 cores, 16 GB, Rust 1.99.1.
  • Download nothing but Rust crates (D-011). Here already: /usr/bin/yt-dlp, /usr/bin/ffmpeg, 7z, bsdtar, unzip, ~/Projects/Mulberry/dist/appimagetool. Not here: clamscan, node, docker.
  • The browser side is Nacre's POST / JSON (D-003, D-010). A built Nacre is at ~/Projects/Nacre/target/release/nacre; run it only hidden with a throwaway home.
  • The line is slow: never download large files for tests. All engine tests use crates/testserver on 127.0.0.1.
  • Ports: Medlar 17616 (D-006). 15151 and 38151 belong to the user's AB Download Manager.

3. Code rules

  • Write like the neighbouring code. KISS, DRY, YAGNI; no abstraction without ≥ 2 uses.
  • Test phase: new pure logic gets a test; a bug fix gets a regression test when feasible.
  • UI work reads ~/.claude/skills/app-taste/SKILL.md once; motion work also animate. Interface colours, radii, spacing, type and motion come from tokens only.
  • Wavy bars and other motion run only while something really changes; idle draws no frames.
  • core never depends on egui. Every engine behaviour and its failure paths get a check in the test file, run against testserver in the test phase.
  • Errors reach the user as plain words: what failed, then why. Every user string goes through the string catalogue (FEATURES 8.5).
  • Follow the pattern of real products only for mechanics; the look, name, icon and copy are Medlar's own.

4. Domain pitfalls (all agents)

  • Never connect to Tor or public proxies in tests. Proxies are tested against a local stub.
  • Any web page can reach 127.0.0.1: refuse any request with a web Origin or a foreign Host, send no CORS headers, and show the Add dialog unless the user turned that off. Remote control and REST need a token.
  • File names come from servers and pages: strip path parts, control characters and leading dots, cap the length, never overwrite silently.
  • Child processes (yt-dlp, ffmpeg) get user links: use --, never a shell. Cookies and logins never appear in logs or process arguments.
  • HTTP/2 puts all parts on one connection: force HTTP/1.1 for segments. A 200 answer to a range request means no resume; never write it at an offset.
  • Content-Encoding breaks ranges: ask for identity and check.
  • Run apps hidden (kittest or nested niri) with a throwaway XDG_* home unless the user asks to watch. Power actions are tested against a fake logind only.
  • DRM, captchas and paywalls are never worked around.

5. Verification tools (test phase only, except the compile check)

Tool Role Available after
nice cargo test -j 2 unit and engine tests 01 Foundation
MEDLAR_SHOTS=dir nice cargo test -j 2 -p medlar --test shots, then tools/contact.sh dir screenshots light and dark (SCENE, SIZES=WxH,…, HOVER=x,y, PRESS=1); add the view to SCENES S003
tools/hidden.sh <outdir> [driver.sh] [WxH] the release build in a hidden nested niri with a throwaway home: click, type, grab, cpu S003
MEDLAR_SEQUENCE=dir nice cargo test -j 2 -p medlar --test visuals sequence; cargo run -p medlar --example visuals progress widgets frame by frame; live with a scrubber S014
python3 tools/gen_assets.py icons adds icons: put the name in tools/icons.txt first S003
nice cargo build --release -j 2 release build (never at the same time as the tests) 01 Foundation
nice cargo test -j 2 -p medlar-testserver / cargo run -p medlar-testserver -- [--port N] [--tls] [--media] [--proxies] local server with faults and proxy stubs; API in the crates/testserver/src/lib.rs header S002
ssh root@192.168.1.71 hub-release release notes on Astar Hub (release only, after the user's yes) now

Don't assume a tool exists: check first. When your plan creates a tool, add its row here.

6. Git

Remote: Astar Hub only (forgejo:astar76/Medlar.git, see the user's global CLAUDE.md). Commit locally always; push only if origin is set. Never GitHub. Releases only through releases/v<version>/ after the user says yes. One commit per logical step, message SNNN: … in English. No reset --hard / force push without an explicit request.

7. Definition of done

A plan is done when it compiles, its boxes and INDEX line are ticked, its test file exists and it is committed. The project is done when the test phase has passed. Compiled is not tested: say so.