lastbook README

项目的 README,来自 github.com/Immortal-Protocols/lastbook。合并为一个 markdown 文件:README.md。

Lastbook

Lastbook is an offline survival library for Mac, Windows and Linux. It puts manuals, videos, encyclopedias, an offline map and short practical guides on one computer. After setup, it works offline. The desktop sidebar opens Videos, Map and Chat. Chat answers questions using the library and links to its sources.

Website: https://lastbook.org. Contact: [email protected].

Lastbook’s original code and documentation are licensed under the MIT License. Contributions are welcome. See CONTRIBUTING.md to get started.

Release status

Platform Version Status
macOS (Apple Silicon, macOS 14 or later) 1.1.11 Live on lastbook.org, signed and notarized
Windows (64-bit, Windows 10 or later) 1.1.11 Live on lastbook.org, Authenticode signed
Linux (Ubuntu 24.04 or 26.04 LTS, x86_64) 1.1.11 Ubuntu packages; installation instructions below

iPad (development preview, source only)

A native iPad app (Videos, Map and Chat, offline, with optional on-device AI) is in mobile/ipad/.

Install on Linux

The Linux packages target Ubuntu 24.04 LTS and Ubuntu 26.04 LTS on Intel/AMD x86_64 computers, one package for each. Download Lastbook for Ubuntu 24.04 (or for Ubuntu 26.04), then install it with apt so Ubuntu resolves its dependencies.

sudo apt install ./Lastbook_1.1.11_amd64.deb                  # Ubuntu 24.04
sudo apt install ./Lastbook_1.1.11_ubuntu26.04_amd64.deb      # Ubuntu 26.04

Open Lastbook from the application menu. First-run setup downloads your chosen library, state map and optional local AI. The app uses Ubuntu's GTK, WebKitGTK and media codecs. Its own files install under /opt/lastbook, and your library and settings stay in your home folder. Removing the package leaves those downloaded files and settings in place.

The Linux release was tested on Ubuntu 24.04.5 in WSL2, including installation, setup, video playback, maps, address search, PDF reading, offline AI with citations, shutdown and uninstall. AI tests used the CPU. Native Linux GPU performance and other Linux distributions have not been validated for this release.

What it does

Privacy and network use

The setup contract, including state maps, is in docs/SETUP-API.md; the engine side is described in engine/setup/README.md.

What's where

Path What it is
app/ The desktop app: entry point (main.py), the no-port bridge, the macOS, Windows and Linux shells, and tests (app/tests/).
engine/ 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/setup/). engine/vendor-macos/ holds pypdfium2 for the Mac build.
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).
web/ 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.
content/ The curated guides (topics/*.json) and what curators looked for and did not find (gaps.json). Format: content/SCHEMA.md.
packaging/ App builds (macOS, Windows and Linux), the Windows installer and its front (setup_stub/), signing helper (sign_windows.ps1), icons (icon/), pack and state-map builders, release manifest, TLS roots tools, package scans, and packaging/llm/ (the local AI runner).
derived/packs/pack-spec.json What goes into each download pack (Small, Medium, All and add-ons) and each state map. Everything else under derived/ is generated and not kept here.
tools/ Builders for the offline map, addresses and place finder, plus curator helpers (libq.py, validate_topics.py).
website/, website-next/ The earlier website and the current static lastbook.org site, respectively.
docs/ 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).

Run from source

You need Python 3.11 or later and a data folder. A data folder holds library-data/catalog.json (the library) and gets a derived/ folder for indexes, caches and logs. Get one by running the app once and letting setup download a pack, or by unzipping a pack from lastbook.org.

python3 -m venv .venv
.venv/bin/pip install -r packaging/requirements_macos.txt     # on Windows: packaging/requirements_app.txt
.venv/bin/python app/main.py --data /path/to/LastbookData

Without --data, the app checks LASTBOOK_DATA, the folder chosen last time, and its own data folder. Existing libraries elsewhere are accessed when the person chooses them. If no library is available, it opens setup. The full order is in app/main.py.

The library server version runs the same engine in a browser and can share with phones on the same Wi-Fi:

LASTBOOK_DATA=/path/to/LastbookData python3 server.py          # then open http://127.0.0.1:8890/

See docs/LIBRARY-SERVER.md. It was written for the household library this project grew out of, so some of its paths and ports describe that setup. The desktop app does not use this port.

Build the apps

The builds write into derived/app-build/ and refuse to finish if the package scan finds something that must not ship: test code, a network call outside setup's downloader, a web address in our own pages, or a word from the private list (see below). The builds also run the TLS roots gate.

macOS (Apple Silicon, needs uv):

bash packaging/llm/build_llm_macos.sh    # optional: the local AI runner, llama.cpp at a pinned tag, Metal
bash packaging/build_app_macos.sh        # Lastbook.app

The build uses CPython 3.11.18 exactly (earlier 3.11 releases lack the block on the compromised eMudhra CA keys). It makes an ad-hoc signed app. Release copies are then signed with the project's Developer ID in a separate release step; its keys and settings are not in this repository. The build reads the release manifest from a release folder under derived/release/, which is not in this repository either; see packaging/release_manifest.py.

Windows (64-bit, in Git Bash):

TOOLS='C:\path\to\tools' bash packaging/llm/build_llm_windows.sh                 # the runner: llama.cpp with Vulkan, CPU fallbacks
PY=/c/path/to/python.exe OUT='C:\path\to\output' bash packaging/build_app_windows.sh
PY=/c/path/to/python.exe DIST='C:\path\to\output\dist\Lastbook' OUT='C:\path\to\output' bash packaging/build_setup_windows.sh

PY is CPython 3.14.10 or a later 3.14 (python.org's NuGet package) with packaging/requirements_app.txt installed. Each script header lists the tools it needs, with versions and checksums. The three WebView2 files come from the NuGet package Microsoft.Web.WebView2 1.0.3856.49 and are checked against the hashes in build_app_windows.sh. libzim is pinned to 3.13.0 on Windows because Smart App Control refuses 3.13.1's zim-9.dll.

build_setup_windows.sh makes a per-user installer (no administrator prompt). Its front, packaging/setup_stub/, is a small C program with no C runtime that loads DLLs from System32 only. Its payload reader supports the certificate table and alignment padding appended by Authenticode signing.

To sign during packaging, set SIGNTOOL, SIGNING_DLIB and SIGNING_METADATA to the Windows paths for SignTool, the Azure Artifact Signing client DLL and your signing metadata file. build_setup_windows.sh calls packaging/sign_windows.ps1 for the app folder, uninstaller, inner installer and final installer, in that order. The helper preserves valid vendor signatures and verifies timestamped signatures after signing. Signing credentials and account metadata stay in the release environment.

The published Windows 1.1.8 installer passed installation and startup checks, and all 90 installed EXE, DLL and PYD files had valid signatures. The release is 104,960,408 bytes with SHA-256 0b31eea87fa05523ca710575e5939754fe10a65eb44ee7d88fe975fbbd161d74.

Linux (build on Ubuntu 24.04 or 26.04, x86_64)

bash packaging/llm/build_llm_linux.sh
bash packaging/linux/build_app_linux.sh

The package uses the system Python and pinned wheels from packaging/linux/requirements_linux.txt, built for that Python only, so each Ubuntu release gets its own package. On 24.04 (Python 3.12) the app build creates derived/app-build/linux/<timestamp>/Lastbook_1.1.11_amd64.deb; on 26.04 (Python 3.14) it creates 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. It bundles the local AI runner when derived/llm/bin-linux/lastbook-llm exists. packaging/linux/smoke_deb.sh checks the package in a fresh container of the same Ubuntu release. Linux integration-test helpers live under app/tests/linux_*; set LASTBOOK_TEST_HOST to a Windows SSH host with WSL2 before running them. Their disposable test distro is named LastbookTest, with files under C:\LastbookTest.

Packs, state maps and the local AI

What is not in this repository, and why

Tests

python3 -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

test_bridge needs a data folder (LASTBOOK_DATA); the others run without a library. packaging/test_pack_tools.py SAMPLE WORK checks the pack tools against a pack sample (build_packs.py build <pack> --sample N). The mac_* and win_* scripts in app/tests/ drive a real build against a real data folder, and their paths are placeholders (/path/to/lastbook, C:\Users\you\app-test) to set for your own machine.

Contributing and licence

See CONTRIBUTING.md and CODE_OF_CONDUCT.md. Lastbook’s original code and documentation use the MIT License, permitting commercial use, modification and redistribution with the copyright and license notice. Third-party software, models, media and library content retain their own licenses, listed in THIRD_PARTY_NOTICES.md and each library pack. Distributed app bundles include GPL-covered components such as python-libzim and libzim and must also meet those components’ license obligations.

Website maintenance

website-next/ is the deployed site. Run python3 -I tools/build.py from that folder to rebuild the main pages. The current emergency buying guide is maintained directly in buying-guide/index.html and buying-guide.css, with image provenance in buying-guide/IMAGE-SOURCES.md. The older tools/buying_guide.py and data/buying-guide.json describe the preceding guide and will overwrite the current guide if run. The current guide contains 17 named products with matching photos. Deployment-specific Amazon Associates tags are omitted from this repository.

lastbook (Immortal-Protocols/lastbook)

正在搜索数据库…

这是什么?这是一个离线资料库,适用于 Mac、Windows 和 Linux,可以把手册、视频、百科全书、离线地图和简明实用指南都放在同一台电脑上。它的聊天功能可以根据这些资料回答问题,并附上来源链接。
它是桌面应用,还是要在浏览器里使用?它是桌面应用。iPad 版本只以源代码的形式提供,供贡献者自行编译和签名,没有 App Store、TestFlight 或可直接下载的安装包。
怎么才能让它运行起来?从 lastbook.org 下载适合你系统的版本并打开。首次运行时,安装程序会下载你选择的资料库(Small、Medium 或 All)、一份州级地图,并可选择是否下载本地 AI 模型。你也可以让安装程序指向你已有的资料库文件夹或资料包 zip 文件。
运行前还需要先安装别的东西吗?在 Linux 上,这个软件包依赖 Ubuntu 自带的 GTK、WebKitGTK 和媒体编解码器,所以安装 .deb 时 apt 会自动解决这些依赖。Mac 和 Windows 版本则是现成的安装程序。
AI 在所有电脑上都能用吗?只有在你的电脑能够运行的情况下才可以,而且安装程序只在条件允许时才会选择本地 AI。没有它的话,聊天功能仍然能找到正确的页面。Linux 上的 GPU 性能以及其他发行版尚未经过验证,Linux 测试中的 AI 是在 CPU 上运行的。
支持哪些系统?搭载 Apple 芯片、运行 macOS 14 或更高版本的 Mac,64 位的 Windows 10 或更高版本,以及搭载 Intel 或 AMD 处理器的 Ubuntu 24.04 或 26.04 LTS。每个 Ubuntu 版本都有单独的软件包。
安装完成后还需要联网吗?不需要。安装完成后,它可以离线使用。只有在你开始下载或点击“检查更新”时,才会使用网络。
我的提问会被发送到别处吗?本地 AI 在你自己的电脑上运行,桌面应用也不会开放任何网络端口。它没有遥测功能,也不需要账户。
离线地图包含哪些内容?包括全球和美国的基础地图,以及你在安装时所选州的详细地图。地图内容有街道、建筑、地形、农作物、水系,还有可以离线使用的地址搜索。Lastbook 从不检测你的位置。
怎样在资料库里查找内容?手册、PDF、视频和离线百科全书都可以按关键词搜索,Windows 版还提供基于语义的搜索。针对紧急需求整理的指南会链接到带页码的真实页面。
我能在手机上打开这个资料库吗?可以,通过资料库服务器版本即可实现。它可以在浏览器中运行,并能与同一 Wi-Fi 下的手机共享。桌面应用本身不使用该端口。
大小
27.8 MB
星标
1.8K
时长
6天
提交 · 90 天