thorium-reader
AGENTS.md2.9k starsChanged 6 days agoBSD-3-ClauseView on GitHub
This project uses NPM (not PNPM, not Bun, not Yarn, etc.) If the ./node_modules folder does not exist, project dependencies can be installed by calling the shell command sfw --verbose npm install --ignore-scripts --min-release-age=2 --allow-git=root --foreground-scripts. Change the CLI argument install to ci in order to guarantee that an existing NPM lockfile will be respected, as opposed to the install variant which may update the ./package-lock.json if there are available minor version bumps compatible as per semantic versioning rules. The…
- Deletes or force-pushes
- Installs packages
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Keep changes compatible with all three operating systems, especially filesystem paths, keyboard shortcuts, shell commands, and native …
- Distinctive: line 19
Run the following shell commands verbatim in order to generate detailed reports in the console:
- Very specific: line 66
When CSS styling files are changed, the command npm run style-typed must be called in order to generate the TypeScript typings that are …
- Very specific: line 70
Use explicit quoted translation keys, e.g.
- Very specific: line 71
Before synchronization, run node scripts/translate-scan.js <temporary-json-path> and verify changed keys.
- Distinctive: line 72
Use only the required synchronization:
- Very specific: line 77
After locale edits, especially English key changes, run npm run i18n-typed and review src/typings/en.translation.d.ts and …
- Very specific: line 78
Verify changed labels in English and one translated locale, including missing and empty translations.
- Very specific: line 125
Prefer undefined over null for absent optional values when the existing type or runtime contract allows it.
- Distinctive: line 144
When changing a boundary, update the relevant Webpack config and this file together.
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Project stack and targets
- Desktop application targeting Windows, macOS, and Linux.
- TypeScript with Electron, Node.js, and Chromium/Web APIs.
- React UI; Redux state management and Redux Saga side effects.
- SCSS styles; Webpack builds; electron-builder packaging.
- Keep changes compatible with all three operating systems, especially filesystem paths, keyboard shortcuts, shell commands, and native integrations.
How to install software dependencies, SBOM (Software Bill Of Materials)
This project uses NPM (not PNPM, not Bun, not Yarn, etc.)
If the ./node_modules folder does not exist, project dependencies can be installed by calling the shell command sfw --verbose npm install --ignore-scripts --min-release-age=2 --allow-git=root --foreground-scripts. Change the CLI argument install to ci in order to guarantee that an existing NPM lockfile will be respected, as opposed to the install variant which may update the ./package-lock.json if there are available minor version bumps compatible as per semantic versioning rules.
The command line executable sfw (Socket Security Firewall) which prefixes the npm command for install and ci (and update too) is a utility that intercepts known malicious packages before they reach the computer. The command npm audit can also be used to display known security issues.
Taze is a more sophisticated alternative to the NPM built-in npm outdated shell command. We can check the semantic versions of installed NPM packages and detect available project dependencies upgrades. Then we can selectively apply safe updates from the software supply chain in order to maintain a secure SBOM (Software Bill Of Materials).
Run the following shell commands verbatim in order to generate detailed reports in the console:
First, to check "minor" updates:
npm exec --no --offline -- taze --maturity-period 2 --fail-on-outdated --all --force --include-locked --concurrency 10 --loglevel debug --cwd .
...then to check "major" updates:
npm exec --no --offline -- taze major --maturity-period 2 --fail-on-outdated --all --force --include-locked --concurrency 10 --loglevel debug --cwd .
At this point, do not edit ./package.json, do not actually install any updates, simply summarize and wait for user instructions. The user may explicitely ask you to update ./package.json after analysing the Taze report.
The user will need to ensure that updated package versions are safe to upgrade (major updates usually introduce breaking changes, while minor updates can introduce safety issues due to supply chain security breaches).
The user can manually verify published NPM artifacts by using the npmx.dev website, for example to show the differences for a package named react and between version 19.2.8 and version 19.3.0, the URL is: https://npmx.dev/diff/react/v/19.2.8...19.3.0.
Once semantic versions inside ./package.json are edited (by the user, yourself, or via the suggested Taze shell command), the file ./package-lock.json and the folder ./node_modules/ will be updated automatically by calling the shell command sfw --verbose npm install --ignore-scripts --min-release-age=2 --allow-git=root --foreground-scripts (note the "minimum age / maturity period" consistent between Taze and NPM commands). Alternatively the shell command sfw --verbose npm update --ignore-scripts --min-release-age=2 --allow-git=root --foreground-scripts [PACKAGE_NAME] can be used.
A full refresh of the NPM lockfile can be performed with the consecutive shell commands:
rm -rf ./node_modules/rm -f ./package-lock.jsonsfw --verbose npm install --ignore-scripts --min-release-age=2 --allow-git=root --foreground-scripts
The shell command to reset the global NPM cache is npm cache clear --force. This shouldn't be needed, but it can help troubleshoot rare issues.
- Important security note: the
npxshell command (which is an alias fornpm exec) is installed by/with NPM. This command executes arbitrary, potentially unsafe code pulled from the package registry. This code is imported into the global system-level cache of packages, including direct and transitive dependencies. This automatically-installed software is not subject to a vetted "lockfile" and as such it is an unmitigated "supply chain" security risk. Conversely, the local project-levelpackage-lock.jsonis derived from the semantic versions defined inpackage.jsonat a specific point in time, as approved / verified (as best as possible) by the project owner / lead developers. - Important security rule: never (ever) use
npxdirectly, because this executes random software payloads from the NPM registry. Instead, ask the user to decide what to do, and explain that when a NPM package is installed locally innode_module(and therefore vetted in the lockfile / included in the SBOM), the alternative tonpx [PACKAGE_NAME]isnpm exec --no --offline -- [PACKAGE_NAME](this is exactly howtazeis invoked).
Sometimes the --ignore-scripts NPM argument can cause warning messages such as "packages had install scripts blocked because they are not covered by allowScripts". In this case, run the command npm install-scripts ls to review packages and subsequently as the user to decide to run npm install-scripts [approve|deny] PACKAGE_NAME. The local .npmrc NPM configuration file can be edited to include allow-scripts=PACKAGE_NAME, or the command line argument --allow-scripts=PACKAGE_NAME can be added after --ignore-scripts.
How to build the software
- The shell command
npm run typescript-check-GOperforms fast TypeScript type-checking over the entire codebase, using the TypeScript version 7 compiler implemented in Go. Use this command to quickly check code changes. - The shell command
npm run typescript-checkperforms slow TypeScript type-checking over the entire codebase, using the TypeScript version 6 compiler implemented in Javascript. You do not need to use this command, use the fast one instead as there is now complete parity between the Go and Javascript capabilities. Only use the slow command if you need to compare the output or the performance timings. - The shell command
npm run buildperforms a full compilation (using Webpack) for the entire Electron codebase: main process, renderer processes and preload scripts. This is a computationally expensive operation, but it is only needed to validate the complete source tree before committing changes to the repository. The commandnpm run buildmust be invoked when files inside the following directories have changed:./src/common,./src/utils,./src/typings,./src/third_party,./src/resources.- MAIN PROCESS: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.main.jscan be used to check the compilation of only the source code of the Electron main process (i.e. files located inside the./src/maindirectory, and the entry point file./src/main.tsitself). - PRELOAD: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.preload.jscan be used to check the compilation of only the source code of the Electron webview preload script (i.e. files located inside the./src/r2-xxx-jsdirectory, and more specifically the entry point file./src/r2-xxx-js/r2-navigator-js/electron/renderer/webview/preload.ts). - RENDERER PROCESS LIBRARY: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.renderer-library.jscan be used to check the compilation of only the source code of the "library" Electron browser window (i.e. files located inside the./src/renderer/librarydirectory, more specifically the entry point file./src/renderer/library/index_library.ts, but also the./src/renderer/commonand./src/renderer/assetfolders which are shared). - RENDERER PROCESS READER: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.renderer-reader.jscan be used to check the compilation of only the source code of the "reader" Electron browser window (i.e. files located inside the./src/renderer/readerdirectory, more specifically the entry point file./src/renderer/library/index_reader.ts, but also the./src/renderer/commonand./src/renderer/assetfolders which are shared). - RENDERER PDF: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.pdf.jscan be used to check the compilation of only the source code of the PDF.js webview inside the "reader" Electron browser window (i.e. files located inside the./src/renderer/reader/pdf/webviewdirectory, including more specifically the entry point file./src/renderer/reader/pdf/webview/index_pdf.tsitself). - RENDERER PDF EXTRACT: The shell command
./node_modules/.bin/webpack-cli --config webpack.config.pdf-extract.jscan be used to check the compilation of only the source code of the PDF.js integration inside the "reader" Electron browser window used when importing PDF files (also files located inside the./src/renderer/reader/pdfdirectory, but more specifically the entry point file./src/renderer/reader/pdf/webview/index_pdf_extract.ts).
- MAIN PROCESS: The shell command
Important instruction: if in doubt about which compilation command to call when code is changed, ask the user.
- The shell command
npm run lintperforms linting over the entire source tree. This is a computationally expensive operation, and this is a prerequisite before committing code to the repository. However, linting is not necessary during fast programming iterations / active development of new features or bug fixes (only successful compilation is required). - When CSS styling files are changed, the command
npm run style-typedmust be called in order to generate the TypeScript typings that are used during compilation to validate the usage of CSS classes inside TypeScript JSX / TSX.
Localization
- Use explicit quoted translation keys, e.g.
__("catalog.userProfile.loans");scripts/translate-scan.jscannot discover dynamically constructed keys. - Before synchronization, run
node scripts/translate-scan.js <temporary-json-path>and verify changed keys. Its empty values are a key inventory, never replacement translations; plural siblings come fromsrc/resources/locales/en.json. - Use only the required synchronization:
npm run i18n-scan: scanned keys → English; supply meaningful English values afterward.npm run i18n-check: English → other locales.npm run i18n-json: scanned keys → all locales; required after locale JSON edits for canonical tab formatting, key ordering, and missing-key injection.
- These commands mutate locales and run
i18n-sort. Preserve translations, plural forms, and runtime-used keys even when scanning misses them; reviewsrc/resources/locales/*.jsondiffs for unintended changes. - After locale edits, especially English key changes, run
npm run i18n-typedand reviewsrc/typings/en.translation.d.tsandsrc/typings/en.translation-keys.d.ts. - Verify changed labels in English and one translated locale, including missing and empty translations. Confirm
src/common/services/translator.tsfalls back to meaningful English text, never raw keys or blank labels.
How to run the software
- The shell command
npm run start:dev:quicklaunches the application in debugging mode with a Webpack dev server that supports hot module reloading for the Electron renderer processes (including CSS styles). However the application must be restarted to take into account code changes in the main NodeJS process. - The shell command
npm run startlaunches the application in slow bundling mode (including full type checking and linting), without the fast dev server. This closely emulates a production packaged application. Recommendation: use the quick variant for most troubleshooting tasks.
Source code organisation
The Typescript source tree is located in the ./src directory, there are tests in a separate ./test folder.
You must ignore the ./.flox/, ./.git/, ./pi/ directories inside the current working directory, unless explicitly instructed by the user to do so.
You are not allowed to read or write files outside the project folder. Your access to the filesystem is strictly limited to the current working directory.
Runtime Boundaries
Thorium is split into separate Webpack/Electron runtime bundles. Treat each bundle as an isolated runtime island. Runtime code must not import source from another runtime directly. Shared contracts, types, actions, and utilities must be moved to a common/shared area first.
Type-only imports count as imports for this rule: if two runtimes need the same type, the type belongs in common code.
Runtimes
| Runtime | Entry point | Owned source | Webpack config | Output |
| Electron main | src/main.ts | src/main.ts, src/main/** | webpack.config.main.js | dist/main.js |
| Library renderer | src/renderer/library/index_library.ts | src/renderer/library/** | webpack.config.renderer-library.js | dist/index_library.js, dist/index_library.html |
| Reader renderer | src/renderer/reader/index_reader.ts | src/renderer/reader/**, except PDF webview files and PDF shared files listed below | webpack.config.renderer-reader.js | dist/index_reader.js, dist/index_reader.html |
| PDF webview renderer | src/renderer/reader/pdf/webview/index_pdf.ts, src/renderer/reader/pdf/webview/index_pdf_extract.ts | src/renderer/reader/pdf/webview/** | webpack.config.renderer-pdf.js, webpack.config.renderer-pdf-extract.js | dist/index_pdf.js, dist/index_pdf_extract.js |
| Webview preload | src/r2-xxx-js/r2-navigator-js/electron/renderer/webview/preload.ts | The preload entrypoint only; other src/r2-xxx-js/** files are vendored/shared dependency code | webpack.config.preload.js | dist/preload.js |
Common And Shared Code
New Thorium-owned code used by more than one runtime should go in one of these common areas:
src/common/**: runtime-neutral app contracts, models, IPC definitions, Redux action/state types, and utilities that do not depend on DOM, React, or Electron renderer APIs.src/renderer/common/**: renderer-only shared React, DOM, keyboard, hook, component, and Redux glue code.src/utils/**: small generic helpers that stay runtime-safe.
Existing shared/support areas:
src/renderer/reader/pdf/common/**are PDF-specific shared code used by the reader-side PDF host and the PDF webview.src/r2-xxx-js/**andsrc/third_party/**are vendored/support dependency code. Do not add Thorium runtime glue there just to bypass runtime boundaries.src/resources/**,src/typings/**, and asset/style imports may be shared where the relevant Webpack config allows them.
Code Style
- Prefer
undefinedovernullfor absent optional values when the existing type or runtime contract allows it.
Import Rules
src/main.tsandsrc/main/**may importsrc/common/**,src/utils/**, and vendored/support dependencies. They must not importsrc/renderer/**.src/renderer/library/**may import library-owned files,src/common/**,src/renderer/common/**,src/utils/**, assets/styles/resources, and vendored/support dependencies. It must not importsrc/renderer/reader/**orsrc/main/**.src/renderer/reader/**may import reader-owned files,src/common/**,src/renderer/common/**,src/utils/**, assets/styles/resources, and vendored/support dependencies. It must not importsrc/renderer/library/**,src/main/**, orsrc/renderer/reader/pdf/webview/**.src/renderer/reader/pdf/webview/**may import PDF webview-owned files, PDF-specific shared files, and vendored/support dependencies. Keep it independent from app renderer React components, app renderer Redux code,src/main/**, and general Thorium common modules unless the Webpack scope rules are intentionally changed.src/r2-xxx-js/r2-navigator-js/electron/renderer/webview/preload.tsmust stay isolated from Thorium app runtimes. It should not importsrc/main/**,src/renderer/library/**, reader React/Redux modules, or Thorium common/resources/typings unless the preload Webpack scope rules are intentionally changed.
Verification Notes
The current runtime separation is enforced during Webpack builds by scripts/webpack-loader-scope-checker.js:
webpack.config.main.jsforbidssrc/renderer.webpack.config.renderer-library.jsforbidssrc/renderer/readerandsrc/main.webpack.config.renderer-reader.jsforbidssrc/renderer/library,src/main, andsrc/renderer/reader/pdf/webview.webpack.config.renderer-pdf.js,webpack.config.renderer-pdf-extract.js, andwebpack.config.preload.jsapply stricter webview/preload isolation rules.
When changing a boundary, update the relevant Webpack config and this file together. After touching imports across runtime-adjacent code, run the relevant Webpack config so the scope checker can catch direct runtime-to-runtime imports.
Trending
Less talk lately.about the whole repository
Who's talking about edrlab/thorium-reader
- A Hacker News story“Help port Thorium Reader to mobile to fight freemium accessibility”Hacker News · Aug 19, 2026 · 3 points
- CachyOS/cachyos-aur-derived“[Package Request] Thorium Reader”GitHub · Oct 9, 2026 · 1 reactions
- NixOS/nixpkgs“thorium-reader: init at 3.2.2”GitHub · Sep 17, 2025 · 1 reactions
- Alex313031/Thorium-MacOS“There is another app called "Thorium"”GitHub · Jul 8, 2025 · 1 reactions
- electron/apps“feat: add thorium-reader”GitHub · Apr 9, 2021 · 1 reactions
The biggest 5 of 39 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 39
Talked about on GitHub, Hacker News and Stack Overflow (39 times).
On GitHub · 36
- Oct 9, 2026[Package Request] Thorium Reader — CachyOS/cachyos-aur-derived1 reaction
- Sep 17, 2025thorium-reader: init at 3.2.2 — NixOS/nixpkgs1 reaction · 14 comments
- Jul 8, 2025There is another app called "Thorium" — Alex313031/Thorium-MacOS1 reaction
- Apr 9, 2021feat: add thorium-reader — electron/apps1 reaction · 1 comment
- Oct 11, 2026Update Thorium_Reader — AppImage/appimage.github.io0 reactions · 1 comment
31 more on GitHub
- Sep 15, 2026Security architecture: sandbox untrusted PDF/EPUB parsing before release — tuunanet/tuxbooks0 reactions · 2 comments
- Aug 6, 2026Add a PDF Selector for Multi-Rectangle Annotations — readium/annotations0 reactions · 11 comments
- Jul 4, 2026Performance issues with large libraries (>200 books) — Fundaments-Work/Theorem0 reactions
- Jun 25, 2026apple-app-site-association (AASA) for Thorium Desktop please — edrlab/thorium-reader-website0 reactions · 4 comments
- Jun 17, 2026Proposal: Expose publication archive updates via LSD and refreshed LCPL — edrlab/lcp-server0 reactions
- Jun 15, 2026Test LCP license refresh when publication is updated — edrlab/lcp-server0 reactions
- May 21, 2026Support /download target redirection from query parameters — edrlab/thorium-reader-website0 reactions
- May 21, 2026Thorium apps should be able to open the website with a generic URL using a locale query parameter, without hardcoding localized paths in the app. — edrlab/thorium-reader-website0 reactions · 2 comments
- Mar 16, 2026thoriumreader_new_label — Installomator/Installomator0 reactions · 2 comments
- Feb 5, 2026Displaying image descriptions — edrlab/thorium-reader-doc0 reactions
- Dec 10, 2025thorium-reader: 3.2.2 -> 3.3.0 — NixOS/nixpkgs0 reactions · 3 comments
- Oct 1, 2025Error: read ECONNRESET — SocketDev/sfw-free0 reactions · 19 comments
- Sep 18, 2025PDF RWPM manifest missing pdf metadata information — readium/readium-lcp-server0 reactions
- Aug 19, 2025Update download links — edrlab/thorium-reader-doc0 reactions
- Aug 8, 2025Thorium Go back in history failing with NVDA — nvaccess/nvda0 reactions · 14 comments
- Aug 7, 2025Update links and references in README — readium/css0 reactions · 3 comments
- Jun 26, 2025Do not mark Traditional Chinese (zh-Hant and zh-TW) as a RTL language — edrlab/r2-shared-js0 reactions
- Jun 26, 2025Do not mark Traditional Chinese (zh-Hant and zh-TW) as a RTL language — edrlab/r2-navigator-js0 reactions
- Mar 12, 2025Footnotes in EPUB3 — w3c/epub-specs0 reactions · 14 comments
- Mar 10, 2025Annotating with a screen reader — edrlab/thorium-reader-doc0 reactions · 3 comments
- Dec 30, 2024Could we merge keyboard shortcut lists to have one only source. — edrlab/thorium-reader-doc0 reactions · 4 comments
- Sep 23, 2024Adds faq entry about transfer of a complete collection — edrlab/thorium-reader-doc0 reactions
- Jun 18, 2024GitHub notifications with a screen reader — GeorgeKerscher/Hello-World0 reactions
- May 29, 2024Fix japanese font settings — readium/css0 reactions · 5 comments
- May 17, 2024Catastrophic data loss (several translator pending Review Requests) after pushing JSON locale updates to GitHub — gitlocalize/feedback0 reactions · 3 comments
- May 16, 2024More often than not, "cover" images (first spine item in the reading order, full-page picture) cause excess blank before/after — readium/css0 reactions · 1 comment
- May 12, 2023Contents updates — edrlab/thorium-reader-doc0 reactions
- Feb 15, 2023I made a to-do list to maintain appimage.github.io — AppImage/appimage.github.io0 reactions · 13 comments
- Feb 28, 2022update in thorium — edrlab/ts_fetch0 reactions · 1 comment
- Dec 16, 2021dark mode with white images — readium/css0 reactions · 4 comments
- Jun 14, 2020Create Thorium_Reader — AppImage/appimage.github.io0 reactions
On Hacker News · 2
- Aug 19, 2026Help port Thorium Reader to mobile to fight freemium accessibility3 points
- May 19, 2020New ePub reader based on Electron/TypeScript/React1 point
On Stack Overflow · 1
- Jan 11, 2022How to build node.js projects against local versions of the dependencies?0 votes · 1 answer
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

