[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-114569":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":14,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":9,"rankLanguage":9,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":9,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},114569,"lastbook","Immortal-Protocols\u002Flastbook","Immortal-Protocols","Offline knowledge AI, maps and videos for survival and rebuilding",null,"Python",3025,370,8,66,0,2900,2910,419,109.69,"MIT License",false,"main",true,[],"2026-11-23 20:23:49","2026-11-23 20:32:11","# Lastbook\n\nLastbook is an offline survival library for Mac, Windows and Linux. It puts manuals, videos, encyclopedias, an offline map and\nshort practical guides on one computer. After setup, it works offline. The desktop sidebar opens Videos, Map and Chat.\nChat answers questions using the library and links to its sources.\n\nWebsite: \u003Chttps:\u002F\u002Flastbook.org>. Contact: hello@lastbook.org.\n\n> Lastbook’s original code and documentation are licensed under the [MIT License](LICENSE).\n> Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.\n\n## Release status\n\n| Platform | Version | Status |\n|---|---|---|\n| macOS (Apple Silicon, macOS 14 or later) | 1.1.11 | Live on lastbook.org, signed and notarized |\n| Windows (64-bit, Windows 10 or later) | 1.1.11 | Live on lastbook.org, Authenticode signed |\n| Linux (Ubuntu 24.04 or 26.04 LTS, x86_64) | 1.1.11 | Ubuntu packages; installation instructions below |\n\n## iPad (development preview, source only)\n\nA native iPad app (Videos, Map and Chat, offline, with optional on-device AI) is in [`mobile\u002Fipad\u002F`](mobile\u002Fipad\u002F).\n- It is source for contributors to build and sign themselves.\n- There is no App Store, TestFlight or downloadable iPad build.\n- See [mobile\u002Fipad\u002FREADME.md](mobile\u002Fipad\u002FREADME.md) for what works, the current limitations and how to build it.\n\n## Install on Linux\n\nThe Linux packages target **Ubuntu 24.04 LTS and Ubuntu 26.04 LTS on Intel\u002FAMD x86_64 computers**, one package for each. Download\n[Lastbook for Ubuntu 24.04](https:\u002F\u002Fdownloads.lastbook.org\u002FLastbook_1.1.11_amd64.deb) (or [for Ubuntu 26.04](https:\u002F\u002Fdownloads.lastbook.org\u002FLastbook_1.1.11_ubuntu26.04_amd64.deb)), then install it with apt so Ubuntu resolves its dependencies.\n\n```bash\nsudo apt install .\u002FLastbook_1.1.11_amd64.deb                  # Ubuntu 24.04\nsudo apt install .\u002FLastbook_1.1.11_ubuntu26.04_amd64.deb      # Ubuntu 26.04\n```\n\nOpen Lastbook from the application menu. First-run setup downloads your chosen library, state map and optional local AI.\nThe app uses Ubuntu's GTK, WebKitGTK and media codecs. Its own files install under `\u002Fopt\u002Flastbook`, and your library and\nsettings stay in your home folder. Removing the package leaves those downloaded files and settings in place.\n\nThe Linux release was tested on Ubuntu 24.04.5 in WSL2, including installation, setup, video playback, maps, address search,\nPDF reading, offline AI with citations, shutdown and uninstall. AI tests used the CPU. Native Linux GPU performance and\nother Linux distributions have not been validated for this release.\n\n## What it does\n\n- **Guides first.** Short, curated guides for urgent needs (`content\u002Ftopics\u002F`), each pointing to real pages in the library\n  with page numbers, plus what curators looked for and did not find (`content\u002Fgaps.json`).\n- **The full library.** Manuals and PDFs (with a whole-PDF view), videos, and offline encyclopedias (ZIM files), with\n  keyword search everywhere and meaning-based search on Windows.\n- **Offline map.** A base map of the world and the US, plus a detailed map for the state selected during setup: local streets,\n  buildings, terrain, crops, and water, help and resource points. Addresses in that state can be found offline. The person\n  picks the state; Lastbook never detects location.\n- **Optional local AI.** Ask questions in plain words and get answers that cite library pages, from a model that runs on\n  the computer itself (see \"The local AI\" below). Without it, Chat still finds the right pages.\n- **One-download setup.** On first run, setup defaults to Small and selects local AI when the computer can run it.\n  The person can choose Small, Medium or All, selects a state map, and starts the checked downloads. A library already on the\n  computer (a folder or a pack zip) can be used instead of downloading.\n- **Check for updates, only when asked.** About has a Check for updates button (and the Mac menu has Lastbook > Check for\n  Updates…). It only says whether a newer version is on the website; nothing is downloaded or installed.\n\n## Privacy and network use\n\n- **No listening port.** The desktop app opens no network port. The window and the engine talk through an in-memory bridge\n  (`app\u002Fbridge.py`): WKURLSchemeHandler on macOS (`app\u002Fshell_macos.py`), WebView2 `WebResourceRequested` on Windows\n  (`app\u002Fshell_windows.py`), and WebKitGTK `URISchemeRequest` on Linux (`app\u002Fshell_linux.py`). The local AI runner speaks JSON lines on standard input and output and opens no socket either.\n- **Two uses of the network, both started by the person.** (1) Setup's downloader (`engine\u002Fsetup\u002F`), when the person\n  starts or resumes a download. (2) The update check (`engine\u002Fupdate.py`, `web\u002Fupdate.js`), when the person presses\n  the button. Both go through `engine\u002Fsetup\u002Fdownload.py`, the only module that opens a connection: HTTPS on port 443 only,\n  to allow-listed hosts only (`downloads.lastbook.org` for packs, maps, the manifest and update information; Hugging Face's\n  download hosts for the AI model; the update check accepts `downloads.lastbook.org` alone), no proxy from the system, and a\n  redirect is followed only to another allowed host.\n- **Pinned trust.** The downloader trusts only the root certificates in `engine\u002Fsetup\u002Froots.pem` (11 roots from Mozilla's\n  bundle), never the system's trust store. The builds refuse to finish if those roots no longer cover the allowed hosts\n  (`packaging\u002Fcheck_tls_roots.py`).\n- **Checked files.** Every download is checked against the SHA-256 in the manifest before it is used. Zips are checked\n  for unsafe paths, links and sizes before anything is written.\n- **Nothing else.** The windows block all web loads, there is no telemetry, no account, and nothing runs on a timer or at\n  startup that reaches the network.\n- **A working library is never broken.** New data is unpacked beside the old one, checked, and then switched in with a\n  single rename. A failure at any step leaves the old library as it was.\n\nThe setup contract, including state maps, is in [docs\u002FSETUP-API.md](docs\u002FSETUP-API.md); the engine side is described in\n[engine\u002Fsetup\u002FREADME.md](engine\u002Fsetup\u002FREADME.md).\n\n## What's where\n\n| Path | What it is |\n|---|---|\n| `app\u002F` | The desktop app: entry point (`main.py`), the no-port bridge, the macOS, Windows and Linux shells, and tests (`app\u002Ftests\u002F`). |\n| `engine\u002F` | Paths and data-folder lookup, library access, saved pages, offline address search (`address_search.py`), the update check (`update.py`) and first-run setup (`engine\u002Fsetup\u002F`). `engine\u002Fvendor-macos\u002F` holds pypdfium2 for the Mac build. |\n| `server.py`, `assistant.py`, `retrieval.py`, `llm_local.py` | The engine: request handler, the assistant and its citation checks, keyword plus meaning-based search, and the local AI (model pins, fit check, runner control). |\n| `web\u002F` | The interface, in plain HTML, CSS and JavaScript with no build step and nothing loaded from the web. `setup.*` is the setup screen, `update.js` the update check in About. |\n| `content\u002F` | The curated guides (`topics\u002F*.json`) and what curators looked for and did not find (`gaps.json`). Format: `content\u002FSCHEMA.md`. |\n| `packaging\u002F` | App builds (macOS, Windows and Linux), the Windows installer and its front (`setup_stub\u002F`), signing helper (`sign_windows.ps1`), icons (`icon\u002F`), pack and state-map builders, release manifest, TLS roots tools, package scans, and `packaging\u002Fllm\u002F` (the local AI runner). |\n| `derived\u002Fpacks\u002Fpack-spec.json` | What goes into each download pack (Small, Medium, All and add-ons) and each state map. Everything else under `derived\u002F` is generated and not kept here. |\n| `tools\u002F` | Builders for the offline map, addresses and place finder, plus curator helpers (`libq.py`, `validate_topics.py`). |\n| `website\u002F`, `website-next\u002F` | The earlier website and the current static lastbook.org site, respectively. |\n| `docs\u002F` | The setup contract (`SETUP-API.md`), how the offline map is put together (`MAPS.md`) and notes on the library server version (`LIBRARY-SERVER.md`). |\n\n## Run from source\n\nYou need Python 3.11 or later and a **data folder**. A data folder holds `library-data\u002Fcatalog.json` (the library) and gets\na `derived\u002F` folder for indexes, caches and logs. Get one by running the app once and letting setup download a pack, or by\nunzipping a pack from lastbook.org.\n\n```bash\npython3 -m venv .venv\n.venv\u002Fbin\u002Fpip install -r packaging\u002Frequirements_macos.txt     # on Windows: packaging\u002Frequirements_app.txt\n.venv\u002Fbin\u002Fpython app\u002Fmain.py --data \u002Fpath\u002Fto\u002FLastbookData\n```\n\nWithout `--data`, the app checks `LASTBOOK_DATA`, the folder chosen last time, and its own data folder.\nExisting libraries elsewhere are accessed when the person chooses them. If no library is available, it opens setup.\nThe full order is in `app\u002Fmain.py`.\n\nThe **library server** version runs the same engine in a browser and can share with phones on the same Wi-Fi:\n\n```bash\nLASTBOOK_DATA=\u002Fpath\u002Fto\u002FLastbookData python3 server.py          # then open http:\u002F\u002F127.0.0.1:8890\u002F\n```\n\nSee [docs\u002FLIBRARY-SERVER.md](docs\u002FLIBRARY-SERVER.md). It was written for the household library this project grew out of,\nso some of its paths and ports describe that setup. The desktop app does not use this port.\n\n## Build the apps\n\nThe builds write into `derived\u002Fapp-build\u002F` and refuse to finish if the package scan finds something that must not ship:\ntest code, a network call outside setup's downloader, a web address in our own pages, or a word from the private list\n(see below). The builds also run the TLS roots gate.\n\n**macOS (Apple Silicon, needs [uv](https:\u002F\u002Fgithub.com\u002Fastral-sh\u002Fuv)):**\n\n```bash\nbash packaging\u002Fllm\u002Fbuild_llm_macos.sh    # optional: the local AI runner, llama.cpp at a pinned tag, Metal\nbash packaging\u002Fbuild_app_macos.sh        # Lastbook.app\n```\n\nThe build uses CPython 3.11.18 exactly (earlier 3.11 releases lack the block on the compromised eMudhra CA keys). It makes\nan ad-hoc signed app. Release copies are then signed with the project's Developer ID in a separate release step; its keys\nand settings are not in this repository. The build reads the release manifest from a release folder under\n`derived\u002Frelease\u002F`, which is not in this repository either; see `packaging\u002Frelease_manifest.py`.\n\n**Windows (64-bit, in Git Bash):**\n\n```bash\nTOOLS='C:\\path\\to\\tools' bash packaging\u002Fllm\u002Fbuild_llm_windows.sh                 # the runner: llama.cpp with Vulkan, CPU fallbacks\nPY=\u002Fc\u002Fpath\u002Fto\u002Fpython.exe OUT='C:\\path\\to\\output' bash packaging\u002Fbuild_app_windows.sh\nPY=\u002Fc\u002Fpath\u002Fto\u002Fpython.exe DIST='C:\\path\\to\\output\\dist\\Lastbook' OUT='C:\\path\\to\\output' bash packaging\u002Fbuild_setup_windows.sh\n```\n\n`PY` is CPython 3.14.10 or a later 3.14 (python.org's NuGet package) with `packaging\u002Frequirements_app.txt` installed. Each\nscript header lists the tools it needs, with versions and checksums. The three WebView2 files come from the NuGet package\n`Microsoft.Web.WebView2` 1.0.3856.49 and are checked against the hashes in `build_app_windows.sh`. libzim is pinned to\n3.13.0 on Windows because Smart App Control refuses 3.13.1's `zim-9.dll`.\n\n`build_setup_windows.sh` makes a per-user installer (no administrator prompt). Its front, `packaging\u002Fsetup_stub\u002F`, is a\nsmall C program with no C runtime that loads DLLs from System32 only. Its payload reader supports the certificate table\nand alignment padding appended by Authenticode signing.\n\nTo sign during packaging, set `SIGNTOOL`, `SIGNING_DLIB` and `SIGNING_METADATA` to the Windows paths for SignTool,\nthe Azure Artifact Signing client DLL and your signing metadata file. `build_setup_windows.sh` calls\n`packaging\u002Fsign_windows.ps1` for the app folder, uninstaller, inner installer and final installer, in that order.\nThe helper preserves valid vendor signatures and verifies timestamped signatures after signing. Signing credentials\nand account metadata stay in the release environment.\n\nThe published Windows 1.1.8 installer passed installation and startup checks, and all 90 installed EXE, DLL and PYD files\nhad valid signatures. The release is 104,960,408 bytes with SHA-256\n`0b31eea87fa05523ca710575e5939754fe10a65eb44ee7d88fe975fbbd161d74`.\n\n**Linux (build on Ubuntu 24.04 or 26.04, x86_64)**\n\n```bash\nbash packaging\u002Fllm\u002Fbuild_llm_linux.sh\nbash packaging\u002Flinux\u002Fbuild_app_linux.sh\n```\n\nThe package uses the system Python and pinned wheels from `packaging\u002Flinux\u002Frequirements_linux.txt`, built for that Python\nonly, so each Ubuntu release gets its own package. On 24.04 (Python 3.12) the app build creates\n`derived\u002Fapp-build\u002Flinux\u002F\u003Ctimestamp>\u002FLastbook_1.1.11_amd64.deb`; on 26.04 (Python 3.14) it creates\n`Lastbook_1.1.11_ubuntu26.04_amd64.deb`, with the version `1.1.11+ubuntu26.04`, which apt takes as newer than the 24.04 package.\nIt bundles the local AI runner when `derived\u002Fllm\u002Fbin-linux\u002Flastbook-llm` exists. `packaging\u002Flinux\u002Fsmoke_deb.sh` checks\nthe package in a fresh container of the same Ubuntu release.\nLinux integration-test helpers live under `app\u002Ftests\u002Flinux_*`; set `LASTBOOK_TEST_HOST` to a Windows SSH host with WSL2\nbefore running them. Their disposable test distro is named `LastbookTest`, with files under `C:\\LastbookTest`.\n\n## Packs, state maps and the local AI\n\n- **Packs** are data folders: a library plus its catalog, search index and map. `packaging\u002Fbuild_packs.py` builds them\n  from a frozen snapshot of a full library according to `derived\u002Fpacks\u002Fpack-spec.json`, and `packaging\u002Fverify_packs.py` and\n  `packaging\u002Fscan_pack.py` check them. The published packs are on `downloads.lastbook.org`. Setup downloads the one the\n  person picks and checks it against `setup\u002Fmanifest-v1.json`, which `packaging\u002Frelease_manifest.py` writes at build time\n  (a newer copy is fetched from `downloads.lastbook.org` when setup opens and used only if it validates).\n- **State maps** are one US state's detailed map set, built by `packaging\u002Fbuild_packs.py map \u003CST>` and published by\n  `packaging\u002Fstate_maps.py`, with per-state address indexes from `packaging\u002Faddress_indexes.py`. A state map replaces the\n  library's map set; it never merges with it. Medium already holds California and All the whole US.\n- **The local AI** is optional: Gemma 4 26B A4B (Unsloth's `gemma-4-26B-A4B-it-UD-Q4_K_M.gguf`, about 17 GB). The file\n  name, size, SHA-256 and Hugging Face revision are pinned in `llm_local.py`. Setup offers it only where the measured fit\n  says it fits (about 18 GB of memory for model and context, plus a reserve) and says why in plain words when it does not.\n  Setup downloads it directly from Hugging Face. The model is never part of the app or of this repository. The runner,\n  `lastbook-llm`, is our own small program (`packaging\u002Fllm\u002Flastbook_llm.cpp`) on llama.cpp tag b12032: Metal on a Mac,\n  Vulkan with CPU fallbacks on Windows and Linux.\n- **Meaning-based search** uses BAAI's bge-small-en-v1.5 (ONNX) through onnxruntime, on Windows only; the Mac build uses\n  keyword search.\n\n## What is not in this repository, and why\n\n- **The library** (`library-data\u002F`): hundreds of gigabytes of third-party manuals, videos and encyclopedias, each under\n  its own terms. It is distributed as packs, with a Sources and permissions page in each pack.\n- **Models and maps** (GGUF, ONNX, map data): large, and published by their makers or built from public data. Setup\n  fetches them, and the checksums and pins are here.\n- **Generated data** (`derived\u002F`, builds, installers): everything there can be rebuilt with the scripts here.\n- **Release and signing material**: signing keys and certificates, notarization and Azure settings, deploy settings and\n  the release folders.\n- **Private data**: the household's own home area (`web\u002Fhome-area.json`), the private word lists the scans use, machine\n  and user names, keys and internal security-audit notes. The guides here are already in their shipped, general wording.\n  To keep your own home-area words out of a build, put them in a local copy of `packaging\u002Fship_edits.json` (`forbidden`)\n  and never commit it.\n\n## Tests\n\n```bash\npython3 -B -m unittest app.tests.test_bridge app.tests.test_setup app.tests.test_data_folder app.tests.test_what_ships app.tests.test_update app.tests.test_address_search app.tests.test_topic_search app.tests.test_chat_steps app.tests.test_validate_topics app.tests.test_libq\n```\n\n`test_bridge` needs a data folder (`LASTBOOK_DATA`); the others run without a library. `packaging\u002Ftest_pack_tools.py SAMPLE\nWORK` checks the pack tools against a pack sample (`build_packs.py build \u003Cpack> --sample N`). The `mac_*` and `win_*`\nscripts in `app\u002Ftests\u002F` drive a real build against a real data folder, and their paths are placeholders\n(`\u002Fpath\u002Fto\u002Flastbook`, `C:\\Users\\you\\app-test`) to set for your own machine.\n\n## Contributing and licence\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md). Lastbook’s original code and\ndocumentation use the [MIT License](LICENSE), permitting commercial use, modification and redistribution with the\ncopyright and license notice. Third-party software, models, media and library content retain their own licenses,\nlisted in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) and each library pack. Distributed app bundles include\nGPL-covered components such as python-libzim and libzim and must also meet those components’ license obligations.\n\n## Website maintenance\n\n`website-next\u002F` is the deployed site. Run `python3 -I tools\u002Fbuild.py` from that folder to rebuild the main pages.\nThe current emergency buying guide is maintained directly in `buying-guide\u002Findex.html` and `buying-guide.css`,\nwith image provenance in `buying-guide\u002FIMAGE-SOURCES.md`. The older `tools\u002Fbuying_guide.py` and\n`data\u002Fbuying-guide.json` describe the preceding guide and will overwrite the current guide if run.\nThe current guide contains 17 named products with matching photos. Deployment-specific Amazon Associates tags\nare omitted from this repository.\n","Lastbook 是一款面向生存与灾后重建场景的离线知识库工具，支持 macOS、Windows 和 Linux 平台。它集成精选手册、实用指南、教学视频、离线地图（含地址搜索）及 ZIM 格式百科，并通过本地运行的轻量 AI 实现基于知识库的问答与来源引用。所有内容在首次配置后完全离线可用，桌面侧边栏提供视频、地图和聊天界面。适用于电力\u002F网络中断、偏远地区作业、应急培训、野外生存准备等无网或弱网环境。",2,"2026-11-24 04:49:03","CREATED_QUERY"]