Skip to main content

Module bootstrap

Module bootstrap 

Source
Expand description

First-run automation.

The installer cannot set Paper up: install.sh, cargo install and the Claude plugin have no common post-install hook, and an installer should not start a long-lived service. So the work happens here, on the first ordinary command, and only once.

Effects, in order:

  1. register the background indexer as a user service (launchd/systemd), or fall back to a detached daemon for this login session;
  2. the daemon downloads the default models in the background (the embedding model first, then the optional reranker);
  3. the daemon indexes the auto-discovered roots immediately (instead of waiting for the first five-minute scheduler tick).

Escape hatches: PAPER_NO_AUTOSTART=1 (never), PAPER_OFFLINE=1 (no network at all), PAPER_FORCE_BOOTSTRAP=1 (run even when PAPER_HOME is set), and paper daemon-control uninstall (turn it off afterwards).

CI suppresses it too: a build machine must never index its own files.

Functions§

clear_setup_status
ensure_models
Download the default models if they are missing. Runs inside the daemon, so the user’s command has already returned. Failure is not fatal: keyword search keeps working and the next daemon start tries again.
ensure_reranker
Download the effective reranker (up to ~1.1 GB) if missing. Only search processes use it and it only improves ordering, so the daemon spawns this instead of delaying the first index pass. A failed or skipped download costs accuracy, never functionality. PAPER_NO_RERANKER=1 keeps it off disk entirely.
index_is_empty
True when the index holds no chunks yet, which is the moment to index immediately rather than wait for the five-minute incremental tick.
is_offline
PAPER_OFFLINE is set: nothing may touch the network.
maybe_autostart
Called from main before dispatching command. Never fails the command and never blocks on the network: the daemon does the slow work.
set_setup_status
Record what the daemon is doing in the background so searches can say so. Best effort: a failed write only loses the hint.
setup_status
The current background phase, if setup is in progress.