Skip to content

First-run UX: dpub doctor, dpub setup, auto-discovery, scripts/build.sh#30

Merged
roelvangils merged 1 commit into
mainfrom
feature/first-run-ux
May 6, 2026
Merged

First-run UX: dpub doctor, dpub setup, auto-discovery, scripts/build.sh#30
roelvangils merged 1 commit into
mainfrom
feature/first-run-ux

Conversation

@roelvangils
Copy link
Copy Markdown
Member

Summary

Closes the rough edges between `git clone` and a fully-working `dpub convert --transcribe ...`. Tier A + B from the approved plan.

Three new pieces, plus auto-discovery + an interactive prompt that ties them together:

  • `dpub doctor` — diagnostic showing build state (version + GPU acceleration: Metal / CUDA / CPU), every runtime prerequisite (`epubcheck`, `ace`, `ffmpeg`), and Whisper model cache contents. `--json` for CI use; same stable schema pattern as `dpub validate --json`.
  • `dpub setup --whisper-model ` — downloads `tiny` / `base` / `small` / `medium` / `large-v3` from huggingface.co with SHA256 verification, atomic `.partial` rename, skip-if-already-cached.
  • `scripts/build.sh` — host-aware release build that picks `--features metal` on Apple Silicon and `--features cuda` on Linux+nvcc.
  • `--transcribe` auto-discovery + interactive prompt — `dpub convert --transcribe nl` (no `--whisper-model`) auto-finds the most-recently-modified cached model. On a TTY with no cached model, prompts to download `ggml-medium.bin` rather than failing. `DPUB_NONINTERACTIVE=1` suppresses.
  • `dpub doctor --install` — opt-in installer for missing runtime tools via `brew` / `apt-get` / `dnf` with per-tool consent.

Why

A first-time clone today requires the user to discover `cmake`, `epubcheck`, `ffmpeg`, `ace`, plus a Whisper GGML model, plus the `--features metal` build flag. Each missing piece either fails the build with a confusing error or fails a runtime command after the user has already typed the wrong thing. This PR makes every step proactive: `dpub doctor` shows the state, `dpub setup` fetches what's missing, `scripts/build.sh` handles the GPU flag automatically.

What stays unchanged

  • Conversion pipeline (M0.5–M6.5) untouched. EPUBCheck-clean baseline (0/0/0 on reference book) preserved.
  • `dpub validate`, `dpub a11y`, `dpub batch`, `dpub convert` flags — all unchanged.
  • Release workflow at `.github/workflows/release.yml` — `dpub doctor` and `dpub setup` are part of the binary, no new release artefacts.

File-by-file

File What
`crates/dpub-cli/src/doctor.rs` NEW — Tool/Status/Report types, per-tool detectors, JSON serialisation, alignment-aware pretty printer.
`crates/dpub-cli/src/setup.rs` NEW — model URL+SHA table for 5 sizes, cache-dir helper, `HashingWriter` wrapper, streaming download with progress bar, atomic rename.
`crates/dpub-cli/src/install.rs` NEW — platform-branched installer plan, consent prompt, runs brew/apt-get/dnf via subprocess.
`crates/dpub-cli/src/main.rs` New `Doctor` and `Setup` subcommands wired through; auto-discovery in `cmd_convert`; interactive first-run prompt.
`crates/dpub-meta/src/lib.rs` New public `agent()` and `download_to_writer` helpers — reuses the existing ureq plumbing for non-Open-Library downloads.
`Cargo.toml` (workspace) Add `sha2 = "0.10"`.
`scripts/build.sh` NEW — host-aware build script.
`README.md` New "First-time setup" subsection at the top of Quickstart.
`CHANGELOG.md` `[Unreleased] ### Added` block.

No new crates. No new heavy deps.

Test plan

  • `cargo test --workspace --no-fail-fast` — all 25 suites green (existing 22 + 8 new across the three new modules).
  • `cargo clippy --all-targets -- -D warnings` — clean.
  • Manual smoke on the maintainer's M2 Mac:
    • `dpub doctor` reports honest state.
    • `dpub setup --whisper-model tiny` downloads + SHA-verifies in ~10 s; `dpub doctor` flips to ✓ for Whisper.
    • `dpub convert --transcribe nl` (no `--whisper-model`) auto-discovers the cached model.
    • `./scripts/build.sh` produces a binary with `dpub doctor` reporting GPU: Metal (when on Apple Silicon).
  • Reference book `dpub convert --validate` (no `--transcribe`) still 0/0/0 — non-transcription path unaffected.
  • Interactive prompt path with `DPUB_NONINTERACTIVE=1` (planned manual test on a fresh `rm -rf ~/.cache/dpub/models/`).

Out of scope (filed separately if needed)

  • Resumable downloads (HTTP `Range`) — polish follow-up.
  • Bundled JVM EPUBCheck — GraalVM rabbit hole.
  • Cross-platform GUI installer.
  • Telemetry.

Closes the rough edges between `git clone` and a fully-working
`dpub convert --transcribe ...`. Tier A + B from the approved
plan in .claude/plans/can-you-look-at-quirky-allen.md.

What's new

  * `dpub doctor` — diagnostic showing build state (version + GPU
    acceleration), every runtime prerequisite (epubcheck, ace,
    ffmpeg), and Whisper model cache contents. Pretty output by
    default; --json for CI/pipeline use.

  * `dpub setup --whisper-model <size>` — downloads any of tiny,
    base, small, medium, large-v3 from huggingface.co/ggerganov/
    whisper.cpp into ~/.cache/dpub/models/ (or %LOCALAPPDATA% on
    Windows) with SHA256 verification. Atomic .partial rename;
    skips re-download when an existing file's hash matches.

  * `scripts/build.sh` — host-aware release build wrapper.
    Auto-picks --features metal on Apple Silicon, --features cuda
    on Linux+nvcc, CPU-only fallback. Pre-flights `cmake` with a
    platform-specific install hint.

  * `dpub convert --transcribe nl` (no --whisper-model) now
    auto-discovers the most-recently-modified ggml-*.bin in the
    cache. On a TTY with no cached model, prompts to download
    ggml-medium.bin instead of failing. Suppressed by
    DPUB_NONINTERACTIVE=1 or non-TTY stdin/stderr.

  * `dpub doctor --install` — opt-in best-effort installer that
    invokes brew (macOS) or apt-get / dnf (Linux) for each
    missing tool, with per-tool consent unless --yes is given.
    Never tries to install Java. Windows prints commands only.

Implementation

  * New crates/dpub-cli/src/doctor.rs — Tool/Status/Report types,
    one detector per tool, JSON serialisation.
  * New crates/dpub-cli/src/setup.rs — model URL+SHA table, cache
    dir helper, streaming download with hashing, progress bar.
  * New crates/dpub-cli/src/install.rs — platform-branched
    installer plan + runner with consent gate.
  * dpub-meta gains a public `agent()` and `download_to_writer`
    helper, reusing the existing ureq machinery for whisper
    model downloads.
  * Workspace adds sha2 (for verification) and walkdir (already
    pinned) — no new heavy deps.

Verification

  * cargo test --workspace --no-fail-fast — all 25 suites green
    (existing 22 + 8 new tests across doctor.rs, setup.rs,
    install.rs).
  * cargo clippy --all-targets -- -D warnings — clean.
  * Manual smoke: dpub doctor reports honest state on the
    maintainer's Mac. dpub setup --whisper-model tiny downloads
    + verifies in ~10s; doctor flips to ✓.
  * EPUBCheck baseline preserved — no edits to the conversion
    pipeline; reference book still 0/0/0.

README "First-time setup" section guides a fresh user from clone
to working binary in five commands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@roelvangils roelvangils merged commit b073c22 into main May 6, 2026
4 of 5 checks passed
@roelvangils roelvangils deleted the feature/first-run-ux branch May 6, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant