build: bundle native TUI in platform wheels

This commit is contained in:
Xubin Ren committed 2026-09-16 02:38:34 +08:00
1 parent 9fda51ec6b
commit d8efb852da
8 files changed
+431 -16

No files matched your search

+3 -1
View File
@@ -190,7 +190,9 @@ The default `--theme auto` mode paints first with the terminal's default backgro
`Enter` sends the current message. While nanobot is working, `Enter` sends immediately, `Tab` waits until the current response is finished, and `Option+Up` on macOS (`Alt+Up` on Windows/Linux) returns the latest waiting message to the composer. Press `Shift+Enter` to add a newline; `Ctrl+J` is the universal fallback when a terminal cannot distinguish modified Enter keys. `Alt+Enter` and `Ctrl+Enter` are also accepted when distinguishable. Use `Up`/`Down` at the composer edge to recall prompts from the current saved session. Large pastes appear as a compact placeholder in the composer but are sent unchanged. Type `/` to discover nanobot commands and terminal navigation in one palette, or type `@` to complete installed apps, configured MCP servers, and saved sessions. Use the arrow keys to choose an item and `Tab` to complete it. `/sessions` opens a searchable conversation picker, `/new-chat` preserves the current conversation and starts another one, and `/branch` forks from a completed reply. `/diff` opens a read-only unified diff for the newest turn; use `Left`/`Right` to switch edits and `Esc` to close it. The core `/new` command retains its cross-channel behavior and resets the current chat. `Ctrl+C` copies a selection, stops a running turn, clears a non-empty composer, or exits when idle. Use `PageUp`/`PageDown` to scroll, `Ctrl+Home`/`Ctrl+End` to jump to the transcript edges, and `Ctrl+O` to expand or collapse long tool traces. When you leave the bottom, the TUI shows a scrollbar and a `Ctrl+End` hint until you return. The footer reports provider token/cache usage when available. Selections copy through OSC 52 when the terminal supports it. The transcript reflows when the terminal is resized, and exiting restores the previous screen.
Packaged releases fetch a version-matched, checksummed terminal archive for macOS (Apple Silicon and Intel), Linux (x64 and ARM64), or Windows x64 on first use. The cache keeps the executable together with its licenses, third-party notices, source offer, relinking instructions, and corresponding TUI source. Windows ARM64 currently falls back to the classic prompt because the Bun runtime disables the FFI required by OpenTUI on that platform. Set `NANOBOT_TUI_NO_DOWNLOAD=1` or pass `--classic` to keep the Python-only path. A local source install requires Bun and runs its own `tui/` source while the original checkout remains available; it never silently falls back to a release binary.
Platform wheels bundle the matching native terminal executable for macOS 13+ (Apple Silicon and Intel), glibc 2.17+ Linux (x64 and ARM64), and Windows x64. The x64 runtime requires SSE4.2. Its licenses, third-party notices, source offer, relinking instructions, and corresponding TUI source are installed alongside it in `nanobot/tui/bin/`. The launcher uses this bundled executable without downloading from GitHub or requiring Bun.
Source-distribution builds do not contain a native executable; where supported, their launcher can still fetch the version-matched GitHub release archive. `NANOBOT_TUI_NO_DOWNLOAD=1` disables that fallback, not the bundled TUI. Use `--classic` to explicitly select the Python prompt. Windows ARM64 and musl-based Linux (such as Alpine) do not have a supported native TUI wheel; use the classic prompt or WebUI. In particular, Windows ARM64 cannot run OpenTUI because Bun disables the required FFI there. A local editable source install requires Bun and runs its own `tui/` source while the original checkout remains available; it never silently falls back to a release binary.
Non-interactive input/output, `--logs`, and `--no-markdown` automatically retain the classic prompt so existing scripts and diagnostic workflows do not acquire terminal control sequences or silently ignore their options.
+1 -1
View File
@@ -12,7 +12,7 @@ These repository docs describe `main`, which can be newer than the released pack
- Access to one supported AI provider, company endpoint, or local model server.
- The credential, endpoint URL, and model ID required by that service. Local providers such as Ollama may not require a key.
Git and [Bun](https://bun.sh/) are only needed for a source install. The published package already contains the WebUI and fetches a checksummed, version-matched TUI archive with its licenses, notices, corresponding application source, source offer, and relinking instructions on first use.
Git and [Bun](https://bun.sh/) are only needed for an editable source install. Platform wheels contain both the WebUI and the matching native TUI, including its licenses, notices, corresponding application source, source offer, and relinking instructions. They support macOS 13+ (Apple Silicon and Intel), glibc 2.17+ Linux (ARM64 and x64), and Windows x64. Pip selects the right wheel; first TUI launch does not download anything from GitHub. Other platforms and source-distribution builds can use the WebUI or `nanobot --classic`; see the [terminal requirements](./cli-reference.md#agent-cli) for native TUI availability.
## 1. Install nanobot
+35 -6
View File
@@ -18,7 +18,7 @@ uploading to PyPI, and deploying the documentation are separate operations.
5. Build in a clean output directory with `uv build --out-dir <artifact-directory>`.
Do not set `NANOBOT_SKIP_WEBUI_BUILD`. The build hook bundles the WebUI in the sdist and
wheel; the wheel is built from the sdist.
6. Check the two distributions with `twine check`, inspect their contents, and record SHA-256
6. Check the intermediate distributions with `twine check`, inspect their contents, and record SHA-256
hashes. Test installation in an isolated environment outside the source checkout, then
test upgrading from the previous stable version using disposable configuration and sessions.
Do not use a maintainer's live workspace for migration tests.
@@ -36,6 +36,10 @@ uploading to PyPI, and deploying the documentation are separate operations.
manifest, executable architecture, required notices/licenses, and embedded source contents.
Run platform-specific smoke tests where supported; record cross-compiled-only targets as
such and link exact-head CI evidence instead of claiming native execution everywhere.
Bundle these archives into the five platform wheels using the command below. Check all final
wheels with `twine check`, validate their RECORDs, tags and installed executable permissions,
and test first launch with an empty cache and `NANOBOT_TUI_NO_DOWNLOAD=1`. The installed
executable must come from `site-packages/nanobot/tui/bin/`, not the checkout or a cache.
10. Merge the release-preparation PR only after its current checks and reviews pass. Confirm the
merged source tree matches the tested candidate; if it does not, rebuild and recheck before
tagging. Reconcile the final changelog and documentation source references. The tag must
@@ -60,9 +64,33 @@ python3 scripts/package-release.py <target>
Repeat for `darwin-arm64`, `darwin-x64`, `linux-arm64`, `linux-x64`, and `win32-x64`.
On macOS, use `codesign --force --sign - <binary>` and verify the signature. The publication
workflow uses pinned `rcodesign` on Linux. Keep the ten `.zip`/`.zip.sha256` outputs in a
candidate-specific directory, alongside the two Python distributions and provenance manifest.
candidate-specific directory, alongside the Python build intermediates and provenance manifest.
Do not include local configuration, instance backups, or test environments in upload selections.
### Build the PyPI platform wheels
From the exact release checkout, after `uv build` and the native archive checks:
```bash
uv run python -m scripts.build_tui_wheels \
--wheel <intermediates>/nanobot_ai-X.Y.Z-py3-none-any.whl \
--tui-dir <verified-tui-archives> \
--out-dir <final-wheels>
```
The script verifies the Python version and RECORD, native checksums, architecture, notices and
embedded source against the checkout, then writes five wheels with complete TUI bundles and
regenerated RECORDs. It refuses to overwrite an existing candidate. `--target <target>` builds
one platform for a targeted check. Minimum tags are macOS 13, manylinux glibc 2.17 and Windows
x64; x64 builds use Bun's baseline (SSE4.2) runtime instead of requiring AVX2. Recheck both Bun
and OpenTUI when upgrading either dependency. No musl or Windows ARM64
wheel is provided. Native execution checks must still validate the actual binaries; tags alone
do not prove compatibility. Test pip selection for all five supported platforms.
The final PyPI upload set is **five platform wheels plus one source distribution**. Do not upload
the intermediate `py3-none-any.whl` or native ZIPs to PyPI. Keep the source distribution produced
by the same build; it remains usable for Python/classic and WebUI installations on other platforms.
Keep an artifact manifest with the source commit, version, filenames, hashes, checks performed,
and any remaining release gates. Rebuild and recheck if the packaged source changes.
@@ -79,11 +107,12 @@ and any remaining release gates. Rebuild and recheck if the packaged source chan
already completed compliance review. Wait for all five targets and repeat artifact checks
on those new outputs. Do not substitute their new bytes under the old artifact hashes.
5. Make the GitHub Release and all TUI attachments publicly available. Verify their public
downloads before publishing Python, since installed clients fetch version-matched assets.
6. Upload only the checked `nanobot_ai-X.Y.Z.tar.gz` and `nanobot_ai-X.Y.Z-py3-none-any.whl`
to PyPI. Do not upload stale files from a shared `dist/` directory. This repository has no
downloads for fallback/source-built installations. Supported platform-wheel installs do not
need these downloads to start the TUI.
6. Upload only the checked `nanobot_ai-X.Y.Z.tar.gz` and the five final platform wheels
to PyPI. Do not upload the intermediate universal wheel or stale files from a shared `dist/` directory. This repository has no
automatic PyPI publication workflow.
7. Verify installation from PyPI, bundled WebUI startup, and the matching TUI download in
7. Verify installation from PyPI, bundled WebUI startup, and bundled TUI startup without downloads in
clean environments. Merge the prepared wiki PR only when the stable package is available:
merging its `main` deploys the site automatically. Confirm all localized `/docs/latest/`
routes select the new version and old version links still work.