smartreader
Read a PDF, EPUB, Word document or plain text file, highlight the part that lost you, and have it explained in plain English — by a model running on your own machine. Nothing you read, highlight or write leaves the computer, the app works with the network off, and everything it keeps on disk is encrypted under a password only you have. If you read on two computers, cloud sync will carry a library between them — optional, off by default, and sealed with that password before any of it leaves.
A Wails desktop app: Go backend, Svelte 5 frontend, and a local Qwen3.5 9B served by the model runtime every kumulativ app shares (kumulativ-core). It shares its stack and its design language with smartwriter and smartdiary.
What it does
Import. Point it at a file, or drop one — or a folder’s worth — anywhere on the window. It extracts the text once, works out the chapter structure, and stores the result — the original file is never modified and never needs to be present again.
Read. One column of serif text on paper, with a chapter list on the left.
The reading controls live on an Aa button floating at the bottom-right corner
of the page — not in the toolbar, because the moment you want them is the moment
you are looking at the text and finding it too small. It opens a panel of
sliders over the page: type size, line height, paragraph spacing, column width
(or fill the window), the source’s own look or the reader’s plain one, serif/sans
and justification, each applying as you drag.
Ctrl/⌘ with +, − and 0 change the size from the keyboard. The reading
position is remembered per book.
This is a reflowing reader, like an e-reader or a browser’s reader mode, not a page viewer: the text is set in your type at your width, which is what makes highlights, resizing and the model’s context all work on the same string. What it keeps from the original is its structure — chapter and section headings, italic and bold emphasis, footnotes, tables and pictures — and, from a PDF, its look; what it gives up is its layout: page images, columns and equations do not survive. A scanned page or a formula-heavy paper is better read elsewhere.
A PDF’s look is everything about a page that is not where things sit on it, and the importer reads it back from what the page painted. Text keeps the exact colour it was set in. A block keeps the box it sat in — its fill, its outline, the bar down its left edge — and the rule drawn under or over it; a heading keeps its size, its face and its letterspacing; a centred line stays centred. Headings are found by how they were set as well as how large: a short line in bold or in a colour, standing over text that is neither, is a heading at the body size. Bulleted and numbered lists come through as lists, a contents page as a list of its entries.
The typefaces are the document’s own. A PDF embeds the fonts it was set in, but not as fonts anything else can use: each is cut down to the glyphs the document drew and stripped of everything a PDF viewer does not need — which character a glyph is, what the face is called, how tall a line of it stands. The importer rebuilds each one as an ordinary font file, with a character map made from the PDF’s own account of what each glyph means, and keeps it with the book’s pictures, sealed like them. It does this for TrueType and CFF outlines, and for the Type 3 fonts a browser’s PDF export writes for a face it cannot embed, whose glyphs are drawing procedures and are written out as outlines. A font it cannot rebuild — a Type 1 program, a Type 3 font that draws with more than filled paths — is set in the reader’s own serif, sans or fixed-pitch face, whichever the original was; so is any character the document’s subset does not have.
None of it is copied blindly, because the reader has its own paper. A page set
light-on-dark is turned over at import, so every colour is kept as it would be on
white; the light theme uses it as it is, the dark theme turns it back, and in
both a colour is nudged until it can be read on what is behind it. Fills and
rules are kept as a distance from the source’s page rather than as colours of
their own, so a table cell a shade off its page is drawn a shade off the
reader’s. The colour of the page itself is not kept at all. Original look on
the Aa panel turns the whole of it off, for a book better read in plain type.
Tables come through as tables from EPUB and Word files, where the format states them. A PDF has no tables, only glyphs and strokes, and the importer reads one back in two ways. A ruled table — a line under every row, or a full grid of cell borders — is read from its rules: they say where the rows are with no guessing, a grid says where the columns are too, and the table keeps its rules, its grid and the fill behind its heading row. A table set with space alone leaves a shape behind — lines in one size whose pieces start at the same few positions, with gutters wider than any word space — and is read from that, in the order the file drew it. Either way a table that runs over a page break is joined back into one, and its cells keep their emphasis and colour. A table set without rules or gutters is not found. Pictures come through from all three formats. In an EPUB or a Word file each one sits where the author put it, with its caption. In a PDF only the page a picture was on is known, so it is set down after the paragraph that page was in the middle of, and a figure drawn with lines rather than embedded as an image is not a picture at all and is lost. Footnotes are kept out of the reading column and shown on the panel’s Footnotes tab, each with a way back to the sentence that cites it.
Because everything is set from the extracted text, the extraction has to be
faithful, and a PDF makes that hard: it holds glyphs and positions, not
paragraphs. The PDF library is carried in the tree (third_party/pdf, a copy of
ledongthuc/pdf) with two changes. Glyph widths are read for composite
(Identity-H) fonts, which upstream reads as zero, so that every position on a
page set by TeX or exported from a modern word processor is where the page put
it. And the interpreter reports what a page painted besides its text — every
fill and stroke, where it landed, in what colour, through what clip — and what
each font’s descriptor says of its name and cut, which is where the boxes,
rules, grids and faces above come from. The fonts themselves are rebuilt outside
it, in pdffonts.go. The importer reads the glyphs in the order the file draws them,
so a footnote number stays on its word (as a superscript) instead of being
sorted to the front of the line, and a two-column page reads column by
column. Paragraphs come from the page geometry — a first-line indent, or
extra space above — rather than from guessing at sentence endings, and a
paragraph that runs over the bottom of a page carries on at the top of the
next. Footnotes, which the page sets in the middle of whatever paragraph ran
over it, are moved to after that paragraph, one block per note. Running
heads and page numbers are dropped. A word hyphenated across a line break is
rejoined, unless the book itself shows it to be a compound the author
hyphenated. Word documents keep their footnotes, their numbering and the
emphasis carried by character styles; EPUBs pick up emphasis that lives in
the stylesheet rather than in <em> tags.
Highlight → explain. Select any words. A small bar appears with four things worth doing in the second after letting go of the mouse:
| Action | What it does |
|---|---|
| Explain | What the passage means, in plain English |
| Simpler | The same thing, as if to someone new to the subject |
| Define | The term as it is used here, not in general |
| ●●●●● | Keep the highlight, no model involved |
| Note | Keep it and write your own thought about it |
The answer streams into the study panel on the right, which also carries Why it matters and a free-form Ask about this passage box. Drag its left edge to resize it — a definition wants a narrow panel and the whole page, a long explanation beside the passage it is about wants a wide one. Double-click the edge to put it back. The width is remembered like the type size, and the panel never takes more than half the window, so the column it sits beside cannot be squeezed away.
Double-click a word and a small card opens over it with what the word means there — the plain meaning first, then what it is doing in that sentence. The definition is kept with the book: double-click the same word on page ninety and the card fills in at once from disk, without the model. A double-click is the lightest question the app answers and the one asked most often, so it is the one that never costs more than it has to.
Every explanation is kept. Asking about a passage is itself the act of marking it — it is the sentence that stopped you — so the answer is saved as soon as it lands and the passage carries a highlight from then on, with a firmer underline and a dot to say it has an explanation behind it. Click the mark, or select those words again, and the answer you already have comes back rather than a second one being generated. Nothing is kept when a request fails: a highlight over a passage with no explanation behind it would misreport what happened.
Notes. Every highlight, explanation and note across every document, grouped by book, searchable, with Open in context to jump back to the exact paragraph. Export a book’s notes as Markdown.
Study this. A button under each book on the shelf, and in the top bar while reading one. Press it once and the model reads the whole book — chapter by chapter, in stretches that fit its window — and writes a summary of each chapter and of the book. Those summaries are never shown as an answer to anything; they are background. From then on, every explanation of a passage in that book is given the book’s summary and the summary of the chapter the passage is in, ahead of the surrounding paragraphs, so a name introduced forty pages earlier or a pronoun pointing at the previous section can be resolved rather than guessed at. A book that has not been studied is explained exactly as before.
The pass takes a few seconds per chapter on a GPU and a good deal longer on a CPU, and it runs in the background: keep reading, open another book, write notes. Its progress — which chapter, how far — shows on the card, in the reader’s top bar, and in the nav bar from any screen, and it can be stopped from any of them; a stopped pass keeps nothing. Highlighting while it runs does not wait on it. The model serves one request at a time, so the summarising call in flight is cut short the moment a passage is asked about, the answer streams at once, and the study picks the same stretch up again when the answer is in. The bar says Paused for your question while that happens.
Ask about the book. Once a book is studied, the study panel grows an
Ask tab: a conversation about the book as a whole rather than about one
passage — its argument, its people, how one chapter leads to the next, “what
happened to him after the war?”. Each question is answered from the study’s
summary of the book and of every chapter, plus the handful of paragraphs of
the text itself that share the most rare words with the question (a plain
tf-idf over paragraphs — no second model, no index on disk), so a question
naming a person or a term is answered from the author’s own words. The
conversation is kept, sealed, with the book (docs/<id>.chat.enc); New
conversation forgets it.
Listen. The Listen button in the reader’s top bar turns the open book into audio, one chapter at a time, in one of two shapes:
- A podcast. Two hosts, Maya and Theo, talk each chapter through, one episode per chapter. The language model writes the conversation from the chapter’s own text, a stretch of about seven thousand characters at a time, with the study’s summaries for the shape of the whole book — so a podcast needs a studied book, and an unstudied one is studied first, in the same go. Each line is spoken in its host’s voice and the lines are mixed into one stereo episode, each host a little to one side. The transcript is kept and can be read in the panel.
- An audiobook. Every chapter read aloud as it is written, by one narrator — Arthur, a calm baritone, or Clara, a warm alto. Footnotes, tables, pictures and code are left out. No language model is involved.
The voices are Qwen3-TTS (1.7B, Apache-2.0), running on this machine like everything else. Each voice is designed once from a written description by the VoiceDesign model and kept as a reference clip; from then on every line is spoken by the Base model cloning that clip, so a host sounds the same in chapter twenty as in chapter one. Lines are generated six at a time, which on an RTX 4070 SUPER runs at about 1.3× real time: a ten-minute episode takes seven or eight minutes to record.
Recording runs in the background like a study — keep reading — and each
chapter can be played the moment it is done. Stopping keeps every chapter
finished so far, and a podcast script written but not yet spoken. The two
models take turns on the graphics card: the language model is let go
(engine.Runtime.Release) before the voices load, and the voices before the
next chapter’s script is written, because on a 12 GB card they do not fit
side by side. One book is recorded at a time.
The player sits along the bottom of the window and keeps playing across the library, the notes and other books; it goes on from chapter to chapter, remembers where you were in each book, skips fifteen seconds either way, and runs from 0.8× to 2×. Space pauses. The recordings are sealed like everything else and decrypted on the way to the player; Save as MP3s writes them, decrypted, to a folder of your choosing. They do not travel with cloud sync — they are large, and can be made again from what does.
The first recording installs the speech engine: about 3 GB of Python and PyTorch, built on the machine by uv because the right PyTorch depends on the graphics driver, and about 9 GB of voice models. After that nothing is downloaded, and it all runs offline.
Help. The ? button beside the theme toggle replays a guided tour of the screen you are on — a spotlight on each part with a line on what it is for — or has every tour play again. Each screen’s tour starts by itself the first time you arrive there.
Updates
smartreader knows its own version and looks, a few seconds after launch and
once a day while it runs, whether a newer one has been published. The look is
one GET of a small public file — smartreader/latest.json on the releases
bucket — with nothing about you or this computer in the request. It happens
before the library is unlocked, because it needs nothing from the library.
Settings has a switch to turn the automatic look off, and a button to look by
hand.
When there is a newer version, a card in the corner says so, with what changed. Update downloads the installer and checks it against the SHA-256 the manifest carries; then — on Windows — Restart to update starts the installer silently and quits: the installer waits for the process to be gone, replaces the files, and opens the new version (Windows asks permission once). On macOS the disk image opens and the drag to Applications is yours. Not now hides the card until the next launch; Skip this version in Settings hides that version for good. Nothing in the library is touched by any of this.
Books read again
A book’s text is read from its file once, when it is added, and kept. A fix to
the importer — a table read the way it was drawn, a stray mark taken out of a
word — reaches the books already on the shelf too (reread.go):
- Each book records the version of the importer that read it (
importVersion, raised with every fix that changes what a book reads as). - A book read by an older version is read again from its file: the sealed copy
the library keeps of every file it imports (
docs/<id>.source.enc; files over 256 MB are not copied), or, for a book added before the library kept copies, the file where it was imported from, if it is still there and still reads as the book. Found there, it is copied in for next time. - That happens when the book is opened, before its text is shown (“Bringing this book up to date…”, about a second for a long PDF), and, after the library is unlocked, in the background for the rest of the shelf.
- Every highlight and note is found again by its words and moved to where they now are, and the reading place with them. A book where any one of them cannot be found keeps its old text — a better reading is not worth a lost note — and so does a book whose chapters would change while a study or a recording is kept by them.
- A book whose new reading is the same as its old is only stamped with the new version. A changed one syncs to your other machines like any other change; the copy of its file stays on the machine that has it.
Where things live
<UserConfigDir>/smartreader/
profile.json the salt, the KDF parameters and the wrapped key
data.enc the library index, the notes, the settings
docs/<id>.enc one document's extracted text, written at import and again
when a newer importer reads the book again
docs/<id>.source.enc the file the book was imported from, to read it again from
docs/<id>.study.enc its book and chapter summaries, written by "Study this"
docs/<id>.words.enc the words looked up in it by double-click, and their definitions
docs/<id>/img-N.ext.enc the pictures the importer pulled out of it
docs/<id>.chat.enc the conversation about the book as a whole
docs/<id>.listen.enc what has been recorded of it, and the podcast scripts
docs/<id>/audio/*.mp3.enc the recordings themselves
<UserConfigDir>/kumulativ/ shared with every kumulativ app — see kumulativ-core
models/ the Qwen weights, one copy for every app
engines/ the llama.cpp build for this machine
run/ the one running server: registry, lock, presets
speech/ the voices: uv, a Python environment with PyTorch and
qwen-tts, the Qwen3-TTS models, the hosts' and
narrators' reference clips, and the worker script
Everything but profile.json is encrypted — see The lock. The
split between data.enc and docs/ is deliberate: the index is rewritten on
every mutation and a book’s text is megabytes, so saving a note never rewrites
a novel. Both are written through a temp file and a rename, so a crash cannot
leave a half-written library behind.
Environment variables
| Variable | Effect |
|---|---|
SMARTREADER_CONFIG_DIR |
Move the whole data directory (portable install, tests) |
SMARTREADER_GGUF |
Use this .gguf and download nothing — any architecture the engine supports |
KUMULATIV_HOME |
Move the shared model store |
KUMULATIV_BIN_DIR |
Look for llama-server here first |
KUMULATIV_IDLE_UNLOAD_MIN |
Minutes of quiet before the model is put to sleep (default 1; 0 = never) |
KUMULATIV_LLAMA_ASSET / KUMULATIV_LLAMA_RELEASE |
Pin a specific llama.cpp release asset |
KUMULATIV_LLAMA_EXTRA_ARGS |
Extra flags for the llama-server command line |
KUMULATIV_FORCE_CPU |
Never use the CUDA build |
KUMULATIV_NO_ENGINE_FETCH |
Refuse to download an engine |
KUMULATIV_DEBUG |
Forward the server’s output instead of swallowing it |
The lock
Everything the app keeps is encrypted on disk. On first run you choose a password; it is stretched with Argon2id and used to unwrap a random data key that seals the index, every book’s text, its summaries, its definitions and its pictures. Changing the password rewraps 48 bytes rather than re-encrypting a shelf.
The pictures matter here. A plate from a book is as much a part of what somebody is reading as the sentence beside it, so they are sealed too and decrypted on the way out to the page — which is why the asset handler reads and unseals rather than serving a file.
While the app is locked it holds nothing — not a hidden view, not a cached book. The store is empty until a password (or the OS keychain entry, which holds the data key and never the password) unlocks it.
Upgrading from a version without a lock. The first launch after the update offers to set a password, and says that the library you already have will be encrypted in place. Every file is written and read back before a single plaintext one is removed, so an interruption leaves everything exactly where it was and the next launch offers again.
There is no reset. Nothing about the password leaves the machine, so nobody can recover it.
Cloud sync
Off by default, and not needed. smartreader works on one machine with the network off, and always will. This is for people who read on two computers.
Settings → Cloud sync connects this computer to an account on
cloud.kumulativ.com. The connection is per machine and
has to be made from the account’s own userspace: a one-time code appears there,
lasts ten minutes, and is typed in here with the email address. Approval is by
hand — an account exists only because somebody let it.
What leaves is sealed under your password first. The service stores a revision, an edit time and a checksum per item, and a blob it cannot open; the lock profile travels with it, because without the salt no second machine could ever derive the key. Your password is not in it and never reaches the server.
A book travels whole — the index entry, the text, its pictures, its summaries and the words looked up in it, sealed together, because they are only ever true about each other. Notes travel separately, since those are written while reading and a book is not.
Where you are in a book does not travel. That is a fact about the machine you are reading on, not about the book, and syncing it would push a novel’s worth of text across the wire every time somebody turned a page. The position rides along with the next real change instead.
Connecting a second computer requires the password the first one uses, because a library has one data key and the second machine has to derive the same one. Revoking a machine from the Machines page stops it at its next attempt; disconnecting from Settings does the same from this side. Either way the library on disk is untouched.
How it is put together
Everything is a block
Each format lands in the same shape: chapters of blocks, where a block is one
paragraph-sized unit of text with an id assigned at import (c3-b17) that never
changes. The reader, the highlight anchors and the context the model is given are
all written against blocks and know nothing about PDFs or EPUBs.
A highlight is stored as (startBlock, startOffset) → (endBlock, endOffset) —
character offsets into the block’s text. That survives restarts, window resizing
and font changes, none of which a pixel or scroll-based anchor does.
This rests on one invariant, which BlockView.svelte exists to protect: the text
nodes inside a block element, concatenated in document order, are exactly that
block’s text. The segment loop in that component is written on one line with no
whitespace between nodes, because a newline in the template would become a real
text node and slide every offset after it.
What each format gives us
| Format | Structure comes from |
|---|---|
| EPUB | The spine (chapter order) and the nav document or NCX (titles) |
| DOCX | Heading 1 starts a chapter; the paragraph styles give block kinds |
| Markdown | # starts a chapter, ##/### are headings inside one |
| Inferred — see below |
A PDF has no chapters, only pages and glyph positions — and often not even words. Text is rebuilt from the geometry of individual characters: lines from baselines, words from horizontal gaps. Structure is rebuilt from the typography: the body type size is the size most of the book’s characters are set in, lines noticeably larger than it are headings (tiered by how much larger), lines noticeably smaller are footnotes, and the font name of each glyph says whether it is italic or bold. Running heads are dropped by finding lines that repeat at the edges of pages, hard-wrapped lines are rejoined into paragraphs, and a “CHAPTER 3” label set above its title in a smaller size is folded into the title. When a book carries no headings at all, it is cut into even sections, because a single chapter containing a whole book makes both the reader and its chapter list useless.
Emphasis rides through the repair pipeline as private-use characters and is
stripped into Block.Spans at the very end (markers.go). That ordering is the
point: every string operation runs on text that still carries the markers, so
the offsets recorded are offsets into exactly the text the reader sees — in
UTF-16 units, because JavaScript will be the one slicing.
Word reconstruction has to handle two opposite kinds of file, and getting either one wrong is very visible:
- Producers that emit real space glyphs. Their spaces are trusted as-is.
Inferring on top of them puts one between every letter (
W h o i s t h i s). - TeX and friends, which emit no spaces at all. Word gaps are numeric
offsets inside the
TJarray, so the text arrives asWhatoneissavedfromunless those offsets are read back out.
The page decides which it is by counting its own space glyphs, because a producer is consistent across a page whereas a single line may legitimately be one long word.
This is also why extraction goes through Page.Content() rather than the
library’s GetPlainText/GetTextByRow helpers. Both helpers walk a TJ array
taking only its strings and discarding the numbers between them — which is
precisely where the spaces are — and GetTextByRow additionally groups by a Y
coordinate it only updates on some operators, so a TeX file reports Y=0 for
every glyph on the page and the whole page collapses into one line.
Two PDFs are refused rather than imported badly:
- A scan. No text layer at all — the error says so and names OCR.
- A file with no usable character map. Subset fonts with no
ToUnicodetable decode to long runs of punctuation. That imports without error and looks like a real book right up until it is opened, soreadableTextcatches it: real prose is mostly letters and has a space about every sixth character.
The model
prompts.go builds every message the model sees, and the quality of a 4B model’s
answer is mostly a property of that file. The system prompt is short and
concrete; each lens is a single imperative rather than a list of things the model
might also cover. Context is assembled in the backend from the two blocks either
side of the highlighted one — the frontend sends the anchor, not the text, so the
selection handler never has to decide how much of the page to send.
study.go is the “Study this” pass, a plain map-reduce over the same blocks:
each chapter is cut into stretches of about ten thousand characters on
paragraph boundaries, each stretch is summarised, a chapter that needed several
stretches has them folded into one, and the book summary is written from the
chapter summaries — folded the same way if there are more than fit one call.
Chapters too short to be worth a call are kept verbatim as their own précis.
The result is a DocStudy beside the text, and Explain reads it on every
question: the book summary and the passage’s chapter summary go into the prompt
first, clamped to a small budget each, because they only place the passage and
the paragraphs around it are what the question is about. The pass runs under
the same cancellation map as explanations, so StopGeneration("study:<id>")
stops it; a stopped pass writes nothing and is not an error.
Frontend
api.ts is the only file that touches the Wails bridge. Outside the desktop app
it falls back to a mock backend with a sample book and canned, word-by-word
streamed answers, so the whole UI — including the selection, highlight and
streaming machinery — is workable in a plain browser.
Known limits
-
Listening needs a graphics card to be pleasant. On a CPU the voice model runs many times slower than real time; it works, but a chapter takes hours.
-
The voices speak English best. Qwen3-TTS reads ten languages, but the hosts and narrators were designed as English speakers, and a podcast of a book in another language is written in that language and read with an English accent.
-
Scanned PDFs need OCR first. There is no OCR in the app.
-
PDFs with broken font maps are refused. A subset font with no
ToUnicodetable decodes to glyph soup (9:·Fn¢9·¢²¢), and importing that produces a book that looks fine in the library and is unreadable when opened. Re-saving from a viewer usually fixes the file; the error message says so. Note that a file can be partly broken — a readable title page over an unreadable body — and is still refused, because the body is the book. -
Multi-column PDFs are not detected. Text is taken in the order the content stream emits it, which is usually column by column and therefore right, but a producer that interleaves columns would interleave them here too.
-
PDF paragraphs are inferred, not read. Some PDFs give up no line breaks at all, in which case oversized paragraphs are cut at sentence boundaries into readable pieces. They are not the author’s paragraph breaks and the app does not pretend otherwise.
-
Re-importing a file creates a second library entry, with its own notes. The original file’s path is recorded but not watched. There is no need to re-import to pick up a fix to the importer: see Books read again.