# BMXt > **English** documentation is first; the complete **Japanese** version follows below ([jump to 日本語](#japanese)). ## Table of contents - [Acknowledgements](#acknowledgements) - [Introduction](#introduction) - [🛠 Seed Project](#seed-project) - [📺 Demo Video](#demo-video) - [♿️ Universal Design Intent](#universal-design-intent) - [Technical Overview](#technical-overview) - [Key Specs](#key-specs) - [Permissions (`wxt.config.ts` manifest)](#permissions-manifest) - [Reproducible builds](#reproducible-builds) - [pnpm dependencies and security](#pnpm-dependencies) - [Command-line token model (first / second commands)](#command-line-token-model) - [Command List](#command-list) - [BMXt process lifecycle (`clear` / window close / `exit`)](#bmxt-process-lifecycle) - [Terminal session state (UI source of truth)](#terminal-session-state) - [`aboutbmxt`](#aboutbmxt) - [Nav mode (`nav -enter` / `nav -exit`)](#nav-mode) - [`translate` (`translate -on` / `translate -off` / `translate -setting`)](#translate) - [`setting` (`setting -list` / `setting -set` / `setting -exit -list`)](#setting) - [`session` (terminal sessions)](#session) - [`sync` (Family local sync)](#sync) - [`bookmark`](#bookmark-command) - [`history`](#history-command) - [Terminal CLI peer (`hosts/cli`)](#terminal-cli-peer) - [Using BMXtCLI with an LLM](#bmxt-cli-llm) - [BMXtCLI GitHub Releases (prebuilt binaries + checksums)](#bmxt-cli-releases) - [`tab` (subcommands)](#tabs-man-tabs) - [Picker UI (side columns)](#picker-ui) - [Tab Picker (`tab -list | browse` / `tab -list -url | browse`)](#tabs-tab-picker) - [Tab picker `:edit` (window & tab group)](#tabs-tab-picker-edit) - [Tab picker — implementation (keyboard & reducer)](#tabs-tab-picker-impl) - [URL Lines (`http` / `https`)](#url-lines) - [Command Execution Architecture (Current)](#command-execution-architecture) - [Prompt semantics (Rust SoT)](#prompt-semantics-sot) - [Inter-command vocabulary (closed IR)](#inter-command-vocabulary) - [`-list` output registry](#list-commands-registry) - [bmxtRule (inter-command stream)](#bmxt-rule) - [bmxtCandidate (prompt candidate menu)](#bmxt-candidate) - [Job execution (background work)](#job-execution) - [Add a New Built-in Command](#add-new-built-in-command) - [Command add procedure](#command-add-procedure) - [Prompt Key Bindings](#prompt-key-bindings) - [Development](#development) - [Development startup (step-by-step)](#development-startup) - [Testing](#testing) - [How to run](#testing-how-to-run) - [What E2E covers](#testing-e2e-coverage) - [pnpm dependencies and security](#pnpm-dependencies) - [Project layout (WXT)](#project-layout) - [Main Sources](#main-sources) - [Version upgrade banner & release notes](#version-upgrade-banner) - [Production Build](#production-build) - [Store Submission (Reference)](#store-submission) - [License](#license) - [Roadmap](#roadmap) - [日本語](#japanese) ## Acknowledgements BMXt stands on the work of communities and tools that made keyboard-centric browsing and modern extension development possible. * Deep gratitude to the **Vim/Neovim community** for modal editing standards that remain unmatched, and to pioneers such as **[Vim](https://www.vim.org/)** and **[Vimium](https://github.com/philc/vimium)** for keyboard-first web navigation. * Special thanks to the open-source ecosystems powering this project: **React**, **TypeScript**, **Rust** and **WebAssembly**, **[WXT](https://wxt.dev/)** / **Vite**, and the broader web extension developer community. * Thanks also to the **[Chrome Web Store](https://chromewebstore.google.com/)** for providing a place to distribute the extension, and to **[Vivaldi](https://vivaldi.com/)** for making Chrome Web Store extensions usable directly on **Android**. * Thanks to **[Cursor](https://cursor.com/)** for serving as an amplifier that helps turn a developer’s ideals into working software. ## Introduction **BMXt** is a UI for **keyboard-centric browser control** in Chrome. It exists because the author is not satisfied with today’s out-of-the-box browser experience. It has a **terminal-style** prompt and log, but it is designed as a **command surface for manipulating the whole browser**—broader than a classic terminal emulator—and it aims to keep your hands on the keyboard in a relaxed posture while reducing how often you reach for tabs and windows. **About the name** — a play on **Browser Manipulator X Terminal**: - **X** - **UX** improvement - Inclusive “cross-over” use for many kinds of people - Open-ended, command-driven growth (exponential / unbounded feel) - **t** - **T**erminal (first letter) - The extension as a **plus** layered on your browser (the idea in the letter **t**) The project is still in its early days, but **BMXt is available on the [Chrome Web Store](https://chromewebstore.google.com/detail/bmxtdemo/ljadfdncbodcdkmhfneeopomipanafil)**. The author believes the keyboard can take you “anywhere,” will keep adding features, and wants to keep building BMXt as a **tool that stays human-centered**. The sections below describe what BMXt can do today. Please also take a look at the demo video. ## 🛠 Seed Project This repository is a dedicated shell built with **Chrome Extension (Manifest V3) + [WXT](https://wxt.dev/)**. It runs in its own dedicated popup window (tab bar–less single-page chrome via `chrome.windows.create({ type: "popup" })`), not the toolbar action popup. The author handles technical decision-making and verification/design/testing, while implementation is done 100% with an AI assistant (Cursor). At this stage, the project is positioned as a validation and seeding phase focused on eliminating behavioral breakage and polishing UX. ## 📺 Demo Video Note: The demo video currently covers the group creation part of the available features. https://github.com/user-attachments/assets/2e418356-cfce-479a-9880-185e542c5fad ## ♿️ Universal Design Intent BMXt is not only an efficiency tool for engineers; it also aims to build reliable, low-effort interaction paths by reducing mouse dependency, keeping key operations consistent, and coexisting well with IME input. ## Technical Overview The following is a technical overview. From the toolbar icon, you can open/focus the BMXt window and run tab/window/group operations plus one-line URL navigation from the command line. Built with [WXT](https://wxt.dev/) (Manifest V3). **Repository layout (multi-browser):** | Path | Role | |------|------| | **`shared/`** | Browser-agnostic source — entrypoints, `lib/`, Rust/`bmxt-core` WASM, `public/`, command `manifest/` | | **`hosts/chrome/`** | Chrome MV3 WXT config (**`pnpm run build:chrome`**; **`verify`** / CWS) | | **`hosts/firefox/`** | Firefox MV3 WXT config + **[AMO source kit](hosts/firefox/AMO_SOURCE.md)** | | **`hosts/cli/`** | Terminal Family peer (`bmxt` binary; WebRTC DataChannel) — **[Terminal CLI peer](#terminal-cli-peer)** · [`hosts/cli/README.md`](hosts/cli/README.md) | **Layout:** Command **semantics** (parse / registry / options / pipe·compound plans / tabs-picker plans) live in **Rust → WASM** (`shared/crates/bmxt-core/`, packaged under **`shared/lib/wasm/bmxt-core/`**). TypeScript owns host API effects (`shared/lib/features/dispatch/`), content scripts, and React UI (`shared/lib/features//`). Thin host glue is in **`shared/lib/features/bmxt-core/`** (`runDispatch`, `ensureBmxtCore`, UiAction apply). See also `.cursorrules` and **[`hosts/README.md`](hosts/README.md)**. **Terminal sessions** (tmux-style: one visible, several in the background) share one BMXt window — see **[`session`](#session)**. List pickers open as **side columns** beside the terminal in the same session pane (**[Picker UI](#picker-ui)**). **Command-line conventions** (first/second commands, Tab completion, Enter when a second token is required) are summarized in **[Command-line token model](#command-line-token-model)**. **Toolchain (since 0.6.9):** the extension shell is built with **[WXT](https://wxt.dev/)** and **[pnpm](https://pnpm.io/)** only. Do **not** use **`npm`**, **`npm ci`**, **`npx`**, or **`package-lock.json`** — the lockfile is **`pnpm-lock.yaml`**. Host manifests live under **`hosts/*/wxt.config.ts`** (WXT `root` = **`shared/`**). Entrypoints are under **`shared/entrypoints/`**; static assets under **`shared/public/`**; build output under **`.output/`** (Chrome prod: **`.output/chrome-mv3`**, Firefox: **`.output/firefox-mv3`**). Since **0.8.0**, TypeScript is **6.x** and command interpretation runs in a bundled **Rust → WASM** core (`shared/crates/bmxt-core/`). | Former (Plasmo / npm) | Current (WXT / pnpm) | |-----------------------|----------------------| | **`tabs/bmxt.tsx`** | **`shared/entrypoints/bmxt/main.tsx`** (+ **`index.html`** → **`bmxt.html`**) | | **`background.ts`** (repo root) | **`shared/entrypoints/background/index.ts`** | | **`contents/bmxt-nav-overlay.ts`** | **`shared/entrypoints/bmxt-nav-overlay.content/index.ts`** | | **`locales/`** | **`shared/public/_locales/`** | | **`build/chrome-mv3`** | **`.output/chrome-mv3`** | | Manifest in **`package.json`** | **`hosts/chrome/wxt.config.ts`** / **`hosts/firefox/wxt.config.ts`** (+ **`version`** still in root **`package.json`**) | | **`npm ci`** / **`package-lock.json`** | **`pnpm install --frozen-lockfile`** / **`pnpm-lock.yaml`** | ## Key Specs - **UI**: Extension page opened in a dedicated popup window without a tab bar (WXT unlisted page `entrypoints/bmxt`; `chrome.windows.create({ type: "popup" })`). The window UI is implemented in **`lib/features/bmxt-window/`** (`BmxtTerminal`); **`entrypoints/bmxt/main.tsx`** is a thin entry that mounts it. - **Input**: Prompt line is rendered with a transparent `textarea` + mirror layer. Supports Japanese IME composition/commit. **Keyboard-first** interaction drives commands, picker focus, and nav on **desktop** **host-ui**; the **mouse** can still **select and copy** displayed text in the log, prompt mirror, picker lists, hints, and the version-upgrade block (`user-select: text` in **`bmxt-ui.css`**). Clicks on picker rows activate a column without moving filter typing focus away from the tab picker search field. **mobile** **host-ui** (since **0.8.2**, default on Android / Android Vivaldi): soft key bar plus pointer select / outside-tap dismiss for prompt candidate menus. - **State**: **Terminal session logs** (`logsById`, `order`, `activeId`, `namesById`), **open picker columns**, and **pane focus** live in the **BMXt UI page** (React) for the window lifetime — see **[Terminal session state (UI source of truth)](#terminal-session-state)**. **Prompt command history** is stored in **`chrome.storage.local`** (`bmxt_cmd_history`, cap **300** entries). **UI settings**, **page-active** picker prefs, and similar user metadata use other **`chrome.storage.local`** keys (**`lib/features/extension-storage/keys.ts`**). - **Background**: Service Worker (`entrypoints/background/index.ts`) opens the window on icon click and handles command execution and tab operations. - **Global shortcuts** (configurable under `chrome://extensions/shortcuts`): **`launch-bmxt`** (default **Shift+Alt+C**) opens BMXt or focuses an existing window; **`reset-bmxt`** (default **Shift+Alt+R**) clears process-scoped session state **and** command history, then opens or focuses BMXt (see **[BMXt process lifecycle](#bmxt-process-lifecycle)**). ### Permissions (host `wxt.config.ts` manifest) Manifest overrides live in **`hosts/chrome/wxt.config.ts`** / **`hosts/firefox/wxt.config.ts`** (via **`hosts/create-host-wxt-config.ts`**; WXT merges them into the built **`manifest.json`**). Chrome declares **`favicon`**, **`tabs`**, **`tabGroups`**, **`storage`**, **`unlimitedStorage`**, **`windows`**, **`scripting`**, **`history`**, and **`bookmarks`**. Firefox omits **`favicon`** and does not set **`commands.*.global`** (unsupported). **Since 0.8.5:** required **`host_permissions`** include **`https://*/*`** so install/update can inject the content script into already-open **https** tabs **without a page reload** (`shared/lib/features/page-scripting/`). **Todo §11:** also **`http://127.0.0.1:17653/*`** and **`http://localhost:17653/*`** for the optional CLI localhost HTTP listener only (Family-authenticated connection setup) (not general `http://` page scripting). In-page scripting (**nav**, **`dom`**, **`search -list --page`**, **`snapshot -save`**) remains **https-only**; opening / listing / matching **http://** URLs in tabs, history, and bookmarks stays allowed without a broad http host grant. Privileged Service Worker messages **`RUN_CMD`** and **`NAV_CONTROL`** are accepted only from the extension UI pages **`bmxt.html`** (not from content scripts or other extensions). If site access is later turned off under the browser’s extension settings, in-page commands explain how to re-enable it. **Data handling (aligned with the privacy policy and store text):** **Terminal session output and picker UI** stay in the **BMXt UI page memory** while the window is open (not in the Service Worker). **Prompt command history** and **UI settings** use capped **`chrome.storage.local`** fields (**`lib/features/extension-storage/keys.ts`**). Legacy keys such as **`bmxt_terminal_sessions_v1`** may still be **removed on process exit** for cleanup but are **not** the runtime source of truth for logs. The extension page and service worker are not designed to call **`fetch()`** against arbitrary third-party HTTPS URLs; CI runs **`pnpm run check:no-fetch`** (allowlist: **`shared/lib/features/sync/handshake/localhost/`** only) to guard that policy, and the packaged manifest’s **Content Security Policy** is an additional guardrail—Chrome Web Store delivery and browser updates are separate. The manifest sets **`content_security_policy.extension_pages`** with **`default-src 'self'`**, **`script-src 'self' 'wasm-unsafe-eval'`** (WASM compile), **`connect-src 'self' http://127.0.0.1:17653 http://localhost:17653`**, **`object-src 'self'`**, **`style-src 'self'`**, **`img-src 'self' data: blob:`**, **`font-src 'self' data:`**, and **`worker-src 'self'`**. Extension UI uses external CSS and Constructable Stylesheets for dynamic layout (no `'unsafe-inline'`). See **`hosts/manifest-base.ts`** / host **`wxt.config.ts`** for the exact string. ### Reproducible builds Official releases are tagged in Git (`git tag`). To reproduce a store submission from source, check out that tag and run **`pnpm install --frozen-lockfile`** (uses **`pnpm-lock.yaml`**; do **not** use **`pnpm install`** in CI or when you want an exact tree) then **`pnpm run codegen`** and **`pnpm run build`** (or **`pnpm run package`**) so the same dependency tree and codegen path apply. See **[pnpm dependencies and security](#pnpm-dependencies)** for lockfile policy, audit policy, and maintainer checks. ### pnpm dependencies and security This repository uses **pnpm only** (`package.json` → **`packageManager`**, lockfile **`pnpm-lock.yaml`**). Do **not** run **`npm install`**, **`npm run …`**, **`npx …`**, or create **`package-lock.json`**. CI and README scripts use **`pnpm`** exclusively. **Direct dependencies** (see **`package.json`**) are **`react@18.2.0`**, **`react-dom@18.2.0`**, and **`sql.js@1.12.0`**. **WXT** (`wxt`, `@wxt-dev/module-react`) and other tooling are **devDependencies**. Almost all other packages are **transitive** (WXT uses Vite and related tooling). **Install for reproducibility** | Command | When to use | |---------|-------------| | **`pnpm install --frozen-lockfile`** | **Default** after clone, in CI, and before release builds. Installs **exactly** what **`pnpm-lock.yaml`** records. | | **`pnpm install`** | Only when you intentionally change **`package.json`** (new devDependency, bump a direct dependency, etc.) and will commit the updated lockfile. | **Lockfile policy** — transitive versions are **not** overridden in **`package.json`**. The full tree is pinned in **`pnpm-lock.yaml`**. Project **`.npmrc`** sets **`save-exact=true`** (do not commit registry tokens). When adding a direct dependency with **`pnpm add`**, pin the version in **`package.json`** (no **`^`**) or rely on **`save-exact=true`**. Recommended local flow after pulling lockfile changes: ```bash rm -rf node_modules pnpm install --frozen-lockfile pnpm run build ``` **Node.js version** — use **`.nvmrc`** (recommended Node for this repo). **`packageManager`** in **`package.json`** pins the pnpm version via Corepack. On first clone, run **`corepack enable`** once so the pinned pnpm version is available. **CI** (**.github/workflows/ci.yml`**) runs **`pnpm install --frozen-lockfile`**, **`pnpm exec wxt prepare`**, **`pnpm audit --audit-level=critical`**, then **`pnpm run verify`**. **`pnpm audit fix --force`** must **not** be used without review. **Known residual audit items** — **`pnpm audit`** may report **high** (and **moderate**) issues in WXT’s build-time toolchain (Vite, esbuild, etc.). These are **not shipped** in the extension bundle; CI gates on **critical** only. Do not “fix” them with **`pnpm audit fix --force`**. **Local verification (match CI):** **`pnpm run verify`** (same gate as GitHub Actions after install / `wxt prepare` / audit). **After any dependency change**, run **`pnpm install --frozen-lockfile`**, **`pnpm run build`**, **`pnpm test`**, and **`pnpm audit --audit-level=critical`**, and commit **`package.json`** and **`pnpm-lock.yaml`** together. ## Command-line token model (first / second commands) BMXt’s shell is **command-line driven**. Specs and implementations should use a consistent token model: 1. **First command, then second command** — Name the **first command** (e.g. `tab`, `session`) and, when applicable, the **second command** next (e.g. `-list`, `-new`). Documentation and parsing follow that order. 2. **No abbreviated spellings for first/second commands** — Do not register alternate short forms for either tier (e.g. do **not** map `-l` to `-list`). **Tab completion** should offer **canonical full tokens** only for this pattern. Older top-level aliases in the README (e.g. `help`/`?`) may remain for backward compatibility; **do not** add new short aliases when introducing **new** first/second families. 3. **Enter when a second command is required** — If the first command is **not actionable** without a configured second command, pressing **Enter** with only the first token must show **usage or a placeholder** for the missing second token, then **restore the prompt** to `firstCommand ` (first command plus one trailing ASCII space) with the **cursor at the end**, ready to type the rest. **Rust** returns `msgs` + `promptPrefix` (e.g. via `require_second_token` / `msgs_with_prompt`); the TS host only expands i18n and calls `setContinuationPrompt`. Do **not** invent Enter continuation in TypeScript (see **[Prompt semantics (Rust SoT)](#prompt-semantics-sot)** and **[Command add procedure](#command-add-procedure)**). ## Command List `help` or `?` shows the same command overview as in-app help. | Command | Description | |----------|------| | `help` / `?` | Show help | | `aboutbmxt` | Open the welcome page, or **`aboutbmxt -system`** for API capability check (see **[`aboutbmxt`](#aboutbmxt)**) | | `tutorial` | Interactive coach for `tab -list \| browse` (`tutorial` / `tutorial -start` / `tutorial -skip`; auto-starts on first launch) (**since 0.8.7**) | | `clear` | Clear logs | | `exit` | Close the **active terminal session**; when it is the **last** session, close the BMXt window and **end the BMXt process** (all persisted process state is cleared — see [BMXt process lifecycle](#bmxt-process-lifecycle)) | | `tab` | Show available options, then restore prompt to `tab ` for option input | | `tab -list [-url] [--device \|--peers]` | List open tabs as a plain tree (IDs included); `-url` adds URLs; `--peers` merges connected Family peers | | `tab -list [-url] | browse` | Open tab picker column; supports search, multi-select marker `#`, and bulk modes | | `tab -list \| tab -send [--close]` | Copy listed tabs (group titles preserved) to a connected peer; `--close` closes only successfully opened **local** source tabs | | `tab -send [--group ] [--close]` | Send URLs to a connected Family peer (command bus); `--close` closes successful local sources | | `tab -exit -list` | Close tab picker column in this session (including `group new` picker) | | `tab -setting -page-active --auto \| --manual` | Tab picker: toggle whether moving the highlight auto-activates the tab (`--auto` default; `--manual` uses Alt+↑↓); saved in `chrome.storage.local` | | `tab -moveurl <url>` | Focus matching URL tab or open new tab (http/https) | | `tab -nowurl` | Print current tab URL | | `tab help` | Show the `tab` manual section | | `dom` | Print usage and restore the prompt to `dom ` (trailing space) so you can enter `-list` | | `dom -list [--normal\|--with] [--html\|--react] [--tag] [<pattern>]` | List DOM nodes from the active tab as plain lines (default **`--normal --html`**); optional case-insensitive substring filter; scriptable **https** only | | `dom -list … | browse` | Open a read-only DOM picker column (same picker chrome as `search -list … | browse`); mode **`--normal`** or **`--with`**; flavor **`--html`** or **`--react`** | | `dom -exit -list` | Close DOM list picker column in this session | | `search` | Print usage and restore the prompt to `search ` for `-list` | | `search -list [--all\|--history\|--bookmark\|--page\|--snapshot] [--device <id>\|--peers] [<pattern>]` | Plain search hit list (default scopes = **`--all`** when no scope token). `--peers` merges connected Family peers. Case-insensitive substring (no regex in v1) | | `search -list … | browse` | Open a search picker column with in-picker progress, detail view (**→**), and **`[history]` / `[bookmark]`** open-target tree. **`--all`** (default when you run **`search -list `** with no scope token) searches history, bookmarks, open **https** tab text, and saved snapshots in parallel | | `search -exit -list` | Close search list picker column in this session (cancels an in-flight **`search-list`** job via the session job runner) | | `bookmark -list [--folder <id>] [--device <id>\|--peers]` | Local: folder-tree list (`open_plain_list`); `| browse` opens bookmark picker. Peers: `search -list --bookmark` path | | `bookmark -add` / `-folder` / `-remove` / `-move` | Create URL or folder; remove/move by bookmark id (pipe: `… \| bookmark -remove` / `… \| bookmark -move --parent <id>`) | | `bookmark -send <deviceId> [--open\|--save\|--both]` | Family send: open tabs (`open_tabs`), save as bookmarks (`bookmarks_import`), or both (default **`--open`**) | | `bookmark -backup` / `-restore` | ZIP backup / restore of the bookmark tree (versioned JSON under `bmxt-browser-backup/`) | | `history -list [<pattern>] [--device <id>\|--peers]` | Local: date-tree list (`open_plain_list`); `| browse` opens history picker. Peers: `search -list --history` path | | `history -delete` / `-delete-range` | Delete history by URL(s) or time range (`--from` / `--to` ISO or epoch ms); pipe: `… \| history -delete` | | `history -backup` / `-restore [--as-bookmarks]` | ZIP export; restore cannot rewrite Chrome history DB — loads list or creates bookmarks | | `nav` | Print usage and restore the prompt to `nav ` (trailing space) for `-enter`, `-exit`, or `-windowclose` | | `nav -enter` | Arm **nav mode** in this BMXt pane (see **[Nav mode](#nav-mode)**); does not show the page overlay until you press **Alt** (detail bar or prompt) | | `nav -exit` | Disarm nav mode (turn Alt overlay **off** first) | | `back` | History back on the **target** active tab (immediate). Batch: `tab -list \| back` | | `forward` | History forward on the target active tab (immediate). Batch: `tab -list \| forward` | | `reload` | Reload the target active tab (immediate). Batch: `tab -list \| reload` | | `close` | Close the target tab after **y/n** confirm; `close <tabId>` closes that id without confirm. Batch: `tab -list \| close` | | `nav -windowclose` | Close the **window that contains the target tab** after **y/n** confirm (never the BMXt window) | | `translate` | Print usage and restore the prompt to `translate ` for `-on`, `-off`, or `-setting` | | `translate -on` | Enable translation assist (nav typing preview under the prompt; see **[`translate`](#translate)**) | | `translate -off` | Disable translation assist | | `translate -setting` | Restore `translate -setting ` and show `--ja-en` / `--en-ja` choices (Tab menu) | | `translate -setting --ja-en` | Save **ja → en** pair (default); round-trip preview and nav commit use English on Alt hold | | `translate -setting --en-ja` | Save **en → ja** pair; round-trip preview and nav commit use Japanese on Alt hold | | `setting` | Print usage and restore the prompt to `setting ` for `-list` | | `setting -list` | Plain list of current UI settings (locale, appearance, storage mode summary) | | `setting -list | browse` | Open the **settings picker** column (UI locale, appearance, **storage** internal/external, **snapshot storage** bundled/Obsidian vault, **Family sync** display name + setup guide, export/import zip); **each apply submits a one-shot `setting …` line and saves immediately** | | `setting -set <key> <value>` | Save one setting immediately (closed key set: locale / toggles / appearance scalars / highlight colors / sync timing; image **clear** via `-set`, image **import** via `setting -bg-import`) | | `setting -export` / `-import` / `-bg-import` / `-reset-default` / `-storage` / `-pick-dir` / `-reload` / `-snapshot-storage` / `-snapshot-pick-dir` / `-sync-guide` | One-shot setting ops (same path as picker applies; see **[`setting`](#setting)**) | | `snapshot -save [<tabId>]` | Save the active tab (or given tab) as a Markdown snapshot with YAML frontmatter (Obsidian-compatible); storage destination follows **setting** snapshot storage | | `setting -exit -list` | Close the settings picker column in this session | | `session` | Print usage and restore the prompt to `session ` for second tokens (see **[`session`](#session)**) | | `session -new [name]` | Create a new **terminal session** and switch to it; optional display name | | `session -list` | Plain list of terminal sessions (index, display name, active marker) | | `session -list | browse` | Inline session picker on the prompt (↑↓ · **Enter** / **1–9** switches immediately by index) | | `session -switch [name]` | Inline session picker by **display name** (type to filter · **Enter** inserts `session -switch <name>` · **Enter** again runs switch); direct `session -switch <name>` also works | | `session -next` / `session -prev` | Cycle the active terminal session | | `session -setting-name [name]` | Rename the current session (bare: prompt pre-filled with current display name) | | `session <n>` | Switch to terminal session number **n** (1-based) | | `sync` | Print usage and restore the prompt to `sync ` (Family local sync — see **[`sync`](#sync)**; **since 0.9.0**) | | `sync -setup` | Guided **wizard**: Family → role → COPY / paste handshake codes (recommended for first join) | | `sync -connect <deviceId>` | Reconnect to a roster member (auto offer/answer role; same wizard COPY / paste) | | `sync -status` | Device id, Family, members, WebRTC connection state | | `sync -pair` / `sync -pair <invite>` | Show Family invite (QR payload) or join from invite | | `sync -members` | List Family roster + discovered devices | | `sync -offer` / `sync -answer <code>` / `sync -accept <code>` | Advanced CLI handshake (`bmxt-rtc1.`); prefer the setup/connect wizard COPY + paste | | `sync -ping <deviceId>` | Ping a connected peer over the DataChannel | | `close` / `c <tabId>` | Close tab by id (no confirm) | | `close` / `c` (pipe) | With pipe input from `tab -list`, close every listed tab (see **Pipes** below) | | `back` / `forward` / `reload` (pipe) | Same producer → batch history / reload on listed tabs | | `group new` / `group new <tabId> …` | Create tab group — interactive tab picker when no tab ids, or non-interactive with explicit ids | | `move --window <id> […]` | Move tabs (pipe or explicit ids). Optional `--before-tab`, `--group` (join dest group), `--ungroup`, or **`--as-group <gid>…`** (move each Chrome tab group as a unit via `chrome.tabGroups.move`; not with `--group` / `--ungroup`) | | `new-window […]` | Move tabs into a new window (pipe or explicit ids). Optional **`--as-group <gid>…`** preserves those groups (sequential `tabGroups.move`) | **Compound commands (`&&` / `||` / `;`):** Join multiple commands on one line with **`&&`**, **`||`**, or **`;`** (quoted regions and `\&&` / `\||` / `\;` escapes are respected). Segments run **left to right** with shell-style short-circuit: **`&&`** runs the next segment only after exit status **0**, **`||`** only after a non-zero status, **`;`** always. Each segment returns a numeric **exit status** (0 = success; usage/parse = 2; unknown command = 127; other failures = 1). Continuation-only inputs (e.g. bare `dom`) and interactive pickers (`<list> | browse` after any `-list`, bare `session -switch`, bare `session -setting-name`) cannot be used inside a compound line. **Pipes (`|`):** Within each list-operator segment (or on a standalone line), chain a **producer** and a consumer with **`|`**. Producers: plain **`tab -list`** (and other `-list` commands), or **`#t:<id>…` tab chips** built with **`tab:`** / **`tab::{needle}`** (see below). Example: **`tab -list | close`** or **`#t:12 #t:34 | back`**. Between stages BMXt passes a **`bmxtRule`** stream (**`bmxt-rule/1`**). Consumers (see **`pipe/consumers/registry.ts`**): **`browse`** (picker from producer **`ListResult`**), **`open`** / **`open --window`** / **`open --into-window`** / **`open --into-group`** (URLs), **`jump`** (`page.open` / `search.hit` / `dom.node`), **`move`** / **`new-window`** (tabs), **`back`**, **`forward`**, **`reload`**, **`close`** / **`c`** (accept **`page.open`**), **`tab -send <deviceId>`** (Family open), **`bookmark -remove`** / **`bookmark -move`** / **`bookmark -send`**, and **`history -delete`**. Kind mismatches and unsupported consumers fail with exit status **1** on **stderr**. Picker Enter for search / DOM / session / setting save·cancel / tab move·group·new-window builds the same typed lines and re-enters via **`submitLine`** (CUI parity). **Tab chips (`tab:`):** Type **`tab:`** to open open-tab candidates (favicon + title). Pick inserts a **`#t:<id>`** chip and **closes** the menu. **Enter** with exactly one chip activates that tab and focuses its window; two or more chips without a pipe is an error (use **`|`** for batch ops). Type a **Space** before Enter to reopen candidates and pick more tabs for a pipe. After **`|`**, press **Tab** for pipe consumers (**`browse`** / **`open`** / **`jump`** / **`back`** / **`forward`** / **`reload`** / **`close`** / **`c`** / **`tab`**). **`tab:{needle}`** (or plain text after Space) filters by title; **`tab::{needle}`** filters by URL. Then pipe: **`#t:… | back`** / **`reload`** / etc. A trailing incomplete **`tab:`** is stripped when the pipe runs. **Redirects (`>` / `>>` / `2>` / `2>>`):** Within a segment, redirect **stdout** (`>` / `>>`) or **stderr** (`2>` / `2>>`) to a **null sink** only: **`null`** or **`/dev/null`** (quoted regions and `\>` escapes are respected). The redirected channel is discarded from the terminal log. Other targets are rejected (exit status **2**). OS file paths are out of scope. **BMXt POSIX Profile:** BMXt is **not** a full IEEE Std 1003.1 shell. The interactive terminal follows a documented profile: argv-style segments, numeric exit status (**0 / 1 / 2 / 127** · `EXIT_*` constants only), stdout/stderr channels (stderr lines render in a distinct color), `|` with a **closed** producer/consumer registry + **`bmxtRule`**, list operators **`&&` / `||` / `;`**, null-sink redirects, and a single **`CommandEntry`** registry for compound/pipe segment dispatch (`lib/features/command-line/commands/`). Background commands fall through to Service Worker **`RUN_CMD`** (effects remain Chrome adapters; `SessionPatch.appendLog` may carry `channel`). **The Terminal CLI peer (`bmxt` / `bmxt exec`) uses the same I/O meaning** (completion buffer of UTF-8 lines → OS FDs or IPC); see todo §13–§15 and [`_context/cli-peer/CONTRACT.md`](_context/cli-peer/CONTRACT.md). Delivery is a **completion buffer** today (not true incremental streaming). **Profile discipline (todo §15 — required when adding commands):** (1) exit via `EXIT_*` only · (2) success → stdout, diagnostics → stderr · (3) browse / TUI / handshake ask only under **Interactive** · (4) CLI command output via **`CommandIo`** (`pnpm run check:cli-command-io`) · (5) pipes = closed consumers / `bmxtRule` only. Checklist: [`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md) · skill `bmxt-add-command`. Out of scope: job control, subshells, command substitution, OS file path redirects, and external process launch. **Note — `clear` vs `exit` vs closing the window:** `clear` only clears the **on-screen log of the active terminal session**; the BMXt window and other in-memory session/picker state stay as they are. **Closing the BMXt window** (× button) or **`exit`** on the **last** session closes the window and **discards** all UI-held session logs and picker state (legacy **`chrome.storage.local`** process keys are cleaned up by the Service Worker). **Command history is kept** unless you use the **`reset-bmxt`** shortcut. **`exit`** with **multiple sessions** removes only the active session and switches to another. See **[BMXt process lifecycle](#bmxt-process-lifecycle)** and **[Terminal session state](#terminal-session-state)**. <a id="bmxt-process-lifecycle"></a> ### BMXt process lifecycle (`clear` / window close / `exit`) **Closing the BMXt window** (×) or **`exit`** on the **last** terminal session closes the window and **ends the in-memory BMXt UI state** (session logs, picker columns, tab-picker fold in the UI). The Service Worker also **removes legacy process-scoped keys** from **`chrome.storage.local`** when appropriate. **Prompt command history** (`bmxt_cmd_history`) survives and is available in the next session. Use the **`reset-bmxt`** shortcut to clear history too. Reopening BMXt (toolbar, **`launch-bmxt`**, etc.) starts a **fresh empty terminal** while history remains. | Action | Session logs (UI) | Open picker columns & `paneFocus` | Tab picker tree fold | Command history | |--------|-------------------|-------------------------------------|----------------------|-----------------| | **`clear`** | Cleared (active session) | Kept | Kept | Kept | | **Close BMXt window** | **All cleared** (UI destroyed) | **Cleared** | **Cleared** | **Kept** | | **Reopen BMXt window** | Fresh empty | Cleared | Cleared | **Restored** | | **`exit`** (multiple sessions) | Active session removed; switches to another | That session’s pickers cleared | Kept | Kept | | **`exit`** (last session) | **All cleared** | **Cleared** | **Cleared** | **Kept** | | **`reset-bmxt` shortcut** | Cleared (UI notified) | Cleared | Cleared | **Cleared** | **Legacy process-scoped storage keys** (removed on **last** **`exit`** or BMXt window close — **cleanup only**; runtime logs are **not** read from these keys while the window is open): | Key | Legacy role (cleanup) | |-----|------------------------| | `bmxt_terminal_sessions_v1` | Former on-disk session blob (v5); no longer authoritative at runtime | | `bmxt_process_ui_v1` | Former picker / `paneFocus` snapshot | | `bmxt_tab_picker_fold_v1` | Former tab-picker tree fold snapshot | **Not cleared on process exit** (user / browser metadata): prompt command history (`bmxt_cmd_history`) — cleared only by **`reset-bmxt`** — custom window display names, UI settings (`bmxt_ui_settings_v1` — locale and appearance; always written on save), UI settings **storage mode** (`bmxt_ui_settings_storage_v1` — internal vs external), translation assist settings, tab/search picker settings (`page-active`), last normal window id, welcome/version tracking keys. Legacy SQLite cache keys (`bmxt_search_cache_db_v1`, `bmxt_job_db_v1`) from versions before **0.6.9** may remain in `chrome.storage.local` until extension uninstall; they are no longer written. **Implementation:** UI session store — **`lib/features/bmxt-window/terminal-sessions/use-terminal-sessions.ts`**, **`session-state-ops.ts`**, **`session-patches.ts`**; legacy storage cleanup — **`removeAllTerminalSessionsFromStorage`** in **`state-storage.ts`**; picker / pane UI — **`use-process-ui-persistence.ts`**; tab-picker fold — **`tab-picker-fold-state.ts`** (in-memory while the window is open). **Note:** **`tab -exit -list`** (and other **`* -exit -list`**) only closes a picker column in the current session; it does **not** end the BMXt process or clear tab-picker fold state. **Terminal sessions and picker columns:** With **two or more** terminal sessions, **Ctrl+← / Ctrl+→** (BMXt window focused) cycles the active session. Inside the active session, **Ctrl+Left / Ctrl+Right** moves focus along **terminal → tabs → search → dom → setting** (only among open columns). See **[Picker UI (side columns)](#picker-ui)** and **[`session`](#session)**. <a id="terminal-session-state"></a> ### Terminal session state (UI source of truth) While a BMXt window is open, **the extension page owns terminal session state**. The Service Worker runs Chrome API effects and returns **patches**; it does **not** keep session logs in memory across idle restarts. | Data | Authority | Lifetime | |------|-----------|----------| | Session logs, `order`, `activeId`, `namesById` | **BMXt UI** (`useTerminalSessions`) | BMXt window open | | Open picker slots, `paneFocus`, detail bars, nav armed | **BMXt UI** (`useProcessUiPersistence`) | BMXt window open | | Tab-picker fold / highlight (in-session) | **BMXt UI** (in-memory helpers) | BMXt window open | | Prompt command history | **`chrome.storage.local`** (`bmxt_cmd_history`) | Survives window close | | UI settings, page-active prefs | **`chrome.storage.local`** | Survives window close | **Why:** Service Workers can stop after idle time (Manifest V3). Keeping logs in the **long-lived UI page** avoids losing state when the worker cold-starts. This also keeps a clear boundary for future **multi-window** support (one UI instance per window). **`RUN_CMD` flow (fallback commands — e.g. `close`, `help`, `session -new`):** 1. UI sends **`RUN_CMD`** with `{ line, sessionId, sessionOrderLength }`. 2. Service Worker runs **`runDispatch`** / **`applyHostEffects`** (tabs, scripting, etc.). 3. SW returns **`{ ok: true, patches: SessionPatch[], closeWindow? }`** — no session snapshot push. 4. UI applies patches locally via **`applyRunCmdPatches`** (`appendLog`, `setLog`, `createSession`, `exitSession`, …). **UI-local commands** (handled in **`bmxt-shell.tsx`** before **`RUN_CMD`**) — e.g. **`<list-command> | browse`**, **`* -exit -list`**, **`session -list`** / **`setting -list`** (plain), **`session -switch`**, **`translate -on`**, **`nav -enter`** — append logs and change pickers **directly** in React state. **Plain** **`tab -list`**, **`dom -list`**, and **`search -list`** go through **`RUN_CMD`** and the **`-list` registry** (see **[`-list` output registry](#list-commands-registry)**). **Messages:** **`SESSION_INIT`**, **`SESSION_SNAPSHOT`**, and **`SESSION_UI_*`** are **removed**. The only SW → UI session notification is **`SESSION_CLEAR`** with **`host`**: **`"popup"`** | **`"all"`** (popup window close clears popup only; **`reset-bmxt`** uses **`"all"`**). **Modules:** **`session-state-ops.ts`** (pure transforms), **`session-patches.ts`** (patch types + apply), **`use-terminal-sessions.ts`** (React store), **`session-runtime-client.ts`** (`runCommandFromUiAsync`), **`entrypoints/background/background-services.ts`** (patch collection in dispatch context). **Service Worker idle:** UI state is unchanged when the worker restarts; the next **`RUN_CMD`** still returns patches applied to the **existing** UI session ids. <a id="aboutbmxt"></a> ### `aboutbmxt` **`aboutbmxt`** opens the welcome page; **`aboutbmxt -system`** re-runs the browser API capability check (same terminal report as after install/update). | Input | Effect | |-------|--------| | **`aboutbmxt`** | Opens **`https://unrsports.github.io/bmxt/welcome.html`** via **`open_welcome_page`** (Service Worker → **`openWelcomePageTab`** / **`chrome.tabs.create`**). Query parameters **`lang`** (UI locale from settings) and **`v`** (installed manifest version) are appended. The terminal logs a short confirmation line. | | **`aboutbmxt -system`** | Probes usable browser APIs (tabs / windows / tabGroups / bookmarks / history / scripting+host / WebRTC / FSA / Translator) and prints OK/NG lines in the terminal. After **install/update**, the same report is queued and shown once when the BMXt prompt next opens. | **Page content** is served from the repo’s **`docs/`** tree (GitHub Pages). Edit **`docs/welcome-content.json`** only (version history, optional **`heroImage`** / **`heroImageMaxWidth`** / **`additionalImages`** per entry; images under **`docs/welcome/`**). The extension does not bundle this file—it opens the hosted **`welcome.html`** URL. **Related behavior (not this command):** on extension **install** or **update**, **`openWelcomePageOnUpdateIfNeeded`** opens the same URL **once per version** in a **normal tab** (tracked by **`LAST_SEEN_WELCOME_VERSION_KEY`**). For manual preview: **`https://unrsports.github.io/bmxt/welcome.html?lang=ja&v=0.96.1`** — see **[Version upgrade banner & release notes](#version-upgrade-banner)**. **Implementation:** Rust **`cmd/aboutbmxt.rs`**, effects **`open-welcome-page.ts`** / **`probe-capabilities.ts`**, capability probe **`lib/features/capability/`**, URL builder **`lib/features/welcome/welcome-external-url.ts`**, tab opener **`lib/features/welcome/open-welcome-page-tab.ts`**. <a id="dom-command"></a> ### `dom` - Bare `dom` + **Enter** prints the usage block and restores the prompt to **`dom `** so you can type `-list` (same continuation pattern as other first commands with manifest `subcommands`). - **`dom -list`** + **Enter** (plain, default **`--normal --html`**) runs via **`RUN_CMD`** → **`dom_list`** effect → **`ListResult`** plain lines in the session log (full output + scroll; summary footer). **Scriptable https** only (declared required **`host_permissions`**; if site access was turned off under `chrome://extensions`, re-enable it). - **`dom -list … | browse`** + **Enter** opens the DOM picker column (UI path). Bare **`dom -list … | browse`** may show the **`--normal` / `--with` / `--html` / `--react` option menu** before the column opens; see **[How columns open](#picker-ui)**. - **`dom -list [--normal|--with] [--html|--react] [--tag] [<pattern>]`** (with or (plain; use **`<list> | browse`** for the column)) resolve the **active tab of the last-focused normal browser window**, inject a read-only helper via `chrome.scripting`, and produce DOM rows. **`chrome://`**, the Chrome Web Store, `chrome-extension://`, etc. are rejected with error lines. - **`--normal`** (default when omitted) — full DOM tree; **`↑`/`↓`** (or **`j`/`k`**) focus jumpable element rows; the target tab scrolls to the highlighted node (debounced). **`Alt+↑`/`↓`** preview page jump when **`--manual`** page-active is set. - **`--with`** — **`↑`/`↓`** (or **`j`/`k`**) scroll the page; viewport-visible elements are shown in a flat list; **`Alt+↑`/`↓`** move element highlight inside the picker. **`→`** opens a feature menu (links, tags, etc.). - **`--html`** (default flavor) vs **`--react`** only changes how nodes are labeled in the picker UI. - Any tokens after the optional flavor flag are joined into a single **substring** filter on the printed lines (ASCII case fold); **not** a regular expression. ASCII `"…"` / `'…'` around the pattern are stripped once. <a id="search-command"></a> ### `search` - Bare `search` + **Enter** prints the usage block and restores **`search `**. - **`search -list` only** (no trailing space) + **Enter** restores the prompt to **`search -list `** (continuation). **`search -list `** + **Enter** runs a cross-scope search (**`--all`**) as **plain** output via **`RUN_CMD`** → **`search_list`** effect (or use **`search -list … | browse`** for the picker column). - **`search -list [--all|--history|--bookmark|--page|--snapshot] [<pattern>]`** (plain) prints **`search.hit`** rows via the **`-list` registry**. **`search -list … | browse`** opens the search picker column; **`--all`** dispatches all effect scopes in parallel inside the picker job. Repeat **`--history`** / **`--bookmark`** scans may use an in-process memory cache (`search-cache-store`). **`--page`** reads each open **https** tab **live** (bounded concurrency via **`page-scan-pool.ts`**). **`--snapshot`** searches saved Markdown snapshots (see **[`snapshot`](#snapshot)**). Picker progress lines are rAF-batched and hidden when results arrive. **Since 0.8.4:** **`--page`** hits carry subdivided matches via ListResult field **`pageMatchesJson`** (`search-page-matches-list-field.ts`) so the picker can jump/scroll to in-page snippets more reliably. - **Google Sheets (`--page`):** open **`docs.google.com/spreadsheets/…`** tabs are scanned with a Sheets-specific collector (`page-extract/sheets/`). Hits are **cell-level** (A1-style). In the picker, **Enter** / preview on a detail row jumps the sheet to that cell (`navigate-sheets-to-cell.ts`). Japanese and other non-ASCII needles use the same substring path as ordinary pages (keyword hand-off is not locale-special-cased beyond normal Unicode text). - **`Ctrl+C`** on the prompt or **`search -exit -list`** cancels an in-flight **`search-list`** job for this session (see **[Job execution](#job-execution)**). - In the results list, **`→`** opens **detail** when the URL is **already open** in a tab and the row has subdivided hits; otherwise **`→`** on **`[history]`** / **`[bookmark]`** rows opens **open-target** when the tab is **not** open (regardless of detail hits). **`←`** or **`Esc`** steps back one level. **`Enter`** on a results row opens in a new tab (or jumps when a page hit applies); **`Enter`** on a detail row activates the source tab and scrolls to the hit (or Sheets cell); **`Enter`** on an open-target row opens the URL at the chosen target. - **`--auto` page-active:** **`↑` / `↓`** (and **`j` / `k`**) preview open-tab result rows and detail in-page hits on highlight move (detail uses a longer debounce and reuses a warmed Range session so GitHub-scale DOMs stay responsive). **`Enter`** still jumps / brings the tab forward. - **Open-tab rows only:** **`Ctrl+↑` / `Ctrl+↓`** jump among rows whose URL is already open in a tab (with animated list scroll). In **`--auto`** page-active mode, preview runs on each jump. - **`Alt+↑` / `Alt+↓`** ( **`--manual`** page-active only): preview the highlighted row in the background tab without changing normal **`↑`/`↓`** highlight rules. - **Detail bar** (status strip under the prompt while the search picker is open): with the caret at **end-of-line**, **`→`** selects the bar; **`←`** returns to the prompt; **`Tab`** / **`Shift+Tab`** cycle visible detail bars; **`Alt`** toggles **`--auto` / `--manual`** page-active (saved in **`chrome.storage.local`**); **`→`** from the bar enters the search picker column. Open-tab result rows show **favicons** when available. - Patterns use the same **case-insensitive substring** rules as `dom` (no regex v1); optional ASCII quotes are stripped. **`search -list … --page`** walks non-discarded **https** tabs on demand (visible `innerText` per tab via content script / `executeScript`, or Sheets cell text for spreadsheet tabs; **not** persisted to any search cache) using the extension’s declared https **`host_permissions`** (if site access was turned off under `chrome://extensions`, re-enable it). <a id="bookmark-command"></a> ### `bookmark` Dedicated first command for bookmark **CRUD**, Family send, and local ZIP backup/restore. Discovery across peers still uses **`search -list --bookmark [--device|--peers]`** (or **`bookmark -list --peers`**, which reuses the same `search_query` path). | Form | Effect | |------|--------| | `bookmark -list [--folder <id>] [--device <id>\|--peers]` | Local folder tree via `open_plain_list` (`bookmark.folder` / `bookmark.item`). `| browse` → tree picker (open / remove / move / send). Peers → `search_list --bookmark`. | | `bookmark -add <url> [--title …] [--parent <id>]` | HostEffect `bookmark_create` (on a connected peer from CLI → **`bookmarks_ops`**) | | `bookmark -folder <title> [--parent <id>]` | HostEffect `bookmark_create_folder` (CLI → **`bookmarks_ops`**) | | `bookmark -remove <id…>` / `… \| bookmark -remove` | HostEffect `bookmark_remove` (pipe needs `bookmarkId` on `bookmark` / `bookmark.folder` rows; CLI → **`bookmarks_ops`**) | | `bookmark -move <id…> --parent <id> [--index n]` / pipe | HostEffect `bookmark_move` (CLI → **`bookmarks_ops`**) | | `bookmark -send <deviceId> [--open\|--save\|--both] …` / pipe | UiAction `sync_bookmark_send`. **`--open`** → peer `open_tabs` (default). **`--save`** → peer `bookmarks_import`. **`--both`** runs both (reports each side). Picker send mode picks the same flags, then a peer. | | `bookmark -backup` / `bookmark -restore` | UiAction ZIP under `bmxt-browser-backup/` (`manifest.json` + `bookmarks.json`). Restore recreates via `bookmarks.create`. Extension-only (not on CLI). | `tab -send` remains **URL open only**. Use **`bookmark -send`** when the peer should also store bookmarks. Tree-picker keys and close: **[Picker UI — Tree pickers](#picker-ui)**. <a id="history-command"></a> ### `history` Dedicated first command for history **list**, **delete**, and ZIP backup. Cross-peer list uses **`search -list --history [--device|--peers]`** (or **`history -list …`** → same `search_list` path). | Form | Effect | |------|--------| | `history -list [<pattern>] [--device <id>\|--peers]` | Local date tree via `open_plain_list` (month → day → visit). `| browse` → tree picker (open / delete / delete-range). Peers → `search_list --history`. | | `history -delete <url…>` / `… \| history -delete` | HostEffect `history_delete_url` (local extension only) | | `history -delete-range --from <iso\|ms> --to <iso\|ms>` | HostEffect `history_delete_range` (local extension only) | | `history -backup` | UiAction ZIP (`manifest.json` + `history.json`). Extension-only. | | `history -restore [--as-bookmarks]` | UiAction file picker. **Cannot rewrite** the browser history DB (`chrome.history` has no insert API). Default loads/export-shaped restore; **`--as-bookmarks`** creates bookmarks instead. Extension-only. | Peer-side history **delete** is out of scope (CLI returns misuse / unsupported). Tree-picker keys and close: **[Picker UI — Tree pickers](#picker-ui)**. <a id="snapshot"></a> ### `snapshot` (`snapshot -save`) Save a scriptable **https** tab as a **Markdown snapshot** with **YAML frontmatter** (`title`, `url`, `savedAt`, `source: bmxt`) for **Obsidian** and similar tools. The Service Worker **`run`** for **`snapshot`** prints usage only; **`snapshot -save`** is **UI-handled** in **`bmxt-shell.tsx`**. | Input | Effect | |-------|--------| | Bare **`snapshot`** + **Enter** | Prints usage and restores **`snapshot `** (continuation). Tab completes **`-save`**. | | **`snapshot -save`** + **Enter** | Saves the **active tab of the last-focused normal browser window** (same target resolution as **`dom -list`**). | | **`snapshot -save <tabId>`** + **Enter** | Saves the given tab id. | You can also start a save from the **tabs picker** action menu (`:snapshot`). **Storage destination** (configured in **`setting -list`**, not draft-only): | Mode | Location | |------|----------| | **Bundled with settings** (default) | **`chrome.storage.local`** (`bmxt_snapshots_v1`) when settings are internal; **`bmxt-ui-settings/snapshots/`** under the external settings bundle when external mode is on | | **Obsidian vault** | User-picked vault folder → **`BMXt/snapshots/`** inside the vault (independent of settings bundle path) | **Notes:** - **Uninstall:** With the default (bundled + internal settings), snapshots live only in **`chrome.storage.local`** and are **removed when the extension is uninstalled**. Snapshots written to an **external settings bundle** or an **Obsidian vault** remain on disk. - **No in-app management yet:** The command surface is **`snapshot -save`** only (no edit/delete). **`search -list --snapshot`** can find saved files but does not manage them. To edit or delete, use a filesystem destination — **Obsidian vault** or **settings external** (`bmxt-ui-settings/snapshots/`) — and manage the Markdown files outside BMXt. Saved snapshots are searchable with **`search -list --snapshot`** (included in **`--all`**). **Implementation:** **`lib/features/snapshot/`** (`snapshot-save-tab.ts`, `snapshot-markdown.ts`, `snapshot-storage.ts`, `snapshot-vault-store.ts`), effect **`search_snapshot`** for the search picker, config key **`bmxt_snapshot_storage_v1`**. <a id="nav-mode"></a> ### Nav mode (`nav -enter` / `nav -exit`) **Nav mode** drives a **virtual pointer overlay** on the **active tab of the last-focused normal browser window** (same target resolution as **`dom -list`**). It is **not** a side picker column; state lives in the BMXt window UI and a **tmux-style status strip** under the prompt shows **`nav`**, **ON/OFF**, and the **target tab title**. **Commands (second token required)** | Input | Effect | |-------|--------| | Bare `nav` + **Enter** | Prints usage and restores the prompt to **`nav `** (continuation; Tab completes **`-enter`** / **`-exit`** only — no short aliases). | | **`nav -enter`** | **Arms** nav in this session pane. Uses the extension’s declared https **`host_permissions`** (same family as `dom -list`). The page overlay is **not** shown yet. | | **`nav -exit`** | **Disarms** nav (clears per-tab position memory and removes overlays). Fails with an error if the overlay is still **ON** — press **Alt** to turn it **OFF** first. | **After `nav -enter` — Alt toggles overlay ON/OFF** - Requires the **BMXt window** to be active and focus on this pane’s **terminal** or **detail bar** strip. **Ctrl+← / Ctrl+→** to a **tabs / search / dom** picker column **suspends** nav keys until you return. - Each **Alt** press toggles overlay **ON** or **OFF** (from the **nav detail bar**, or from the prompt while armed). - **ON:** injects or updates the overlay on the target tab. The cursor appears at the **viewport center** on each **ON** (not at the OS mouse position). **Keyboard focus stays on the nav detail bar** while the overlay is **ON** (so further detail-bar operations can be added later). **↑ / ↓ / ← / →** jump between interactive elements (spatial snap). **Shift+↑ / ↓ / ← / →** free-move the pointer by **12px** per step (`NAV_ARROW_STEP_PX` in `lib/features/nav/nav-config.ts`). Releasing **Shift** after a free-move **re-scans** targets at the current pointer (no rollback to the previous snap). **Enter** activates the target under the cursor, or enters **typing mode** when the target is editable (see below). - **OFF:** removes the overlay from the current tab; nav stays **armed** until **`nav -exit`**. Focus remains on the **nav detail bar**. **Overlay keys (ON, nav detail bar focused)** | Key | Effect | |-----|--------| | **↑ / ↓ / ← / →** | Jump to the next interactive target in that direction (spatial snap; viewport auto-scrolls as needed) | | **Shift+↑ / ↓ / ← / →** | Free-move the pointer by **12px** (no per-step target recollect); on **Shift** release, re-scan and highlight the nearest target at the pointer | | **/** | Start **incremental attribute jump** (type fragments of link text / `alt` / URL path / accessible name; see below) | | **Enter** | Activate the resolved target under the cursor (`click()` once for links/buttons; **typing mode** for editables) | | **Ctrl** (tap) | Open the on-page **context menu** at the cursor | | **Alt** (tap) | Toggle overlay **OFF** (ignored while **typing mode** is active) | While **ON**, **←** does **not** leave the detail bar for the prompt (arrows belong to the page cursor). **Tab** / vertical bar cycling is also suspended. **Typing mode** temporarily moves focus to the prompt for IME input; leaving typing restores the nav detail bar. **Target identity (explore → reuse)** - While the overlay is **ON**, the cursor shows a short HUD label such as **`link:/docs`** or **`button-like:Save`**, and the status strip repeats the same **`kind:key`**. - Classification is heuristic (`link` / `button-like` / `editable` / `media` / `maybe-interactive` / `inert`) from the real target (ancestor `<a>` / button when you land on an inner span). - After a **successful** activate, BMXt **learns** the identity key for that **page origin** (`chrome.storage.local` key **`bmxt_nav_learned_targets_v1`**) so later **`/`** jumps can prefer familiar targets. Stale keys (zero matches or failed activate) are dropped. **Incremental jump (`/`)** | Key | Effect | |-----|--------| | **/** | Enter jump mode (overlay stays **ON**; status shows **`jump`**) | | printable / IME | Narrow candidates in the **detail-bar** search field (Japanese IME composition supported) | | **↑ / ↓** | Cycle among current matches | | **Enter** | Activate the highlighted match (ignored while IME is composing) | | **Esc** | Leave jump mode (overlay stays **ON**) | This is **not** a Vimium-style full-page hint overlay; it is explore-with-HUD then reuse-by-attribute. **Context menu** (**Ctrl**): **↑ / ↓** choose a row, **Enter** run, **← / →** browser **back** / **forward**, **Ctrl** or **Esc** close without running. | Item | Action | |------|--------| | Select text | Range pick: **↑ / ↓** (or **Shift+arrows** free-move) move, **Enter** set **start**, move again, **Enter** set **end**; selection is applied and a **Copy** row appears | | Save image under cursor | Download the image at the pointer (http(s) URL) | | Reload page | Reload the target tab | After text selection, **Copy** + **Enter** writes the selection to the system clipboard. **Esc** clears the selection (and closes the copy menu when open). **Typing mode** (after **Enter** on an editable field): the BMXt prompt shows a typing hint; text is mirrored into the page field. **Alt** **hold** (~500ms) **commits**; **Esc** **hold** **cancels** and restores the previous value. Multiline fields allow newlines (**Shift+Enter** on the prompt). Short **Alt** does not toggle the overlay while typing. When **`translate -on`** is active, typing mode also shows a **source → target → source** round-trip preview strip under the prompt (completed sentences end with `。` `.` `!` `?` `!` `?`, etc.). **Alt hold** commit sends the **target language** for the saved pair (**English** with **`--ja-en`**, **Japanese** with **`--en-ja`**) assembled from translation blocks (see **[`translate`](#translate)**), not the raw buffer. The status strip under the prompt shows modes such as **`nav`**, **ON/OFF**, **jump**, **typing**, **menu**, **sel-start** / **sel-end**, **copy**, plus the target tab title, **`kind:key`**, or a short error. **Tab changes while armed** - Switching the active tab in the normal browser window **keeps nav armed**. The overlay is recreated on the new tab. **Position is remembered per tab**; switching back restores the last position. **Alt ON** on a tab always starts from the **center** again. **Pages and permissions** - **Scriptable https** only (plain **http://**, `chrome://`, Chrome Web Store, `chrome-extension://`, etc. are rejected). The status strip shows a short error (for example **`site access denied`**) when injection fails. - After installing or reloading the extension, open **https** tabs receive the WXT **content script** (`entrypoints/bmxt-nav-overlay.content/`) via **`onInstalled` reinject** / **`ensurePageContentScript`** — **no page reload required**. If the script is still missing, callers fall back to **`chrome.scripting.executeScript`**. - Nav does **not** use the **`debugger`** permission / CDP AOM. **Implementation** - **`lib/features/nav/`** — prompt parsing, status bar, session hook (`useNavMode`), target classify / jump match / learned keys, inject snippet, Service Worker runner (`run-nav-inject.ts`). - **`lib/features/bmxt-window/bmxt-shell.tsx`** — handles **`nav -enter` / `nav -exit`** before `RUN_CMD`; wires nav with the detail-bar focus controller. - **`lib/features/bmxt-window/shell/usePaneFocusController.ts`** / **`use-detail-bar-keyboard.ts`** — while overlay **ON**, keep focus on the **nav** detail bar; **Alt** toggles from the bar. - **`entrypoints/background/index.ts`** — `NAV_CONTROL` message runs inject on the target tab. - **`entrypoints/bmxt-nav-overlay.content/`** — content script listener on https pages. <a id="translate"></a> ### `translate` (`translate -on` / `translate -off` / `translate -setting`) **`translate`** enables Chrome’s built-in **`Translator` API** (Japanese ↔ English) for **nav typing mode** assist (preview under the BMXt prompt). The active direction is stored as a **translation pair** in **`chrome.storage.local`** (**`TYPING_TRANSLATE_KEY`**: `{ enabled, pair }`). | Input | Effect | |-------|--------| | Bare `translate` + **Enter** | Prints usage and restores **`translate `** (continuation). Tab completes **`-on`** / **`-off`** / **`-setting`** only — no short aliases. | | **`translate -on`** | Enables translation assist. Log line includes the current pair token (e.g. **`--ja-en`**). Nav typing shows a preview strip under the prompt. | | **`translate -off`** | Disables assist. | | **`translate -setting`** + **Enter** | Prints pair choices and restores **`translate -setting `** (continuation). Tab completes third tokens **`--ja-en`** / **`--en-ja`**. | | **`translate -setting --ja-en`** | Saves pair **`ja-en`** (source **JA** → target **EN**, back-translation to **JA**). Resets in-flight translation blocks. | | **`translate -setting --en-ja`** | Saves pair **`en-ja`** (source **EN** → target **JA**, back-translation to **EN**). Resets in-flight translation blocks. | **Translation pair (`-setting`)** - Pairs are defined in **`lib/features/translate/translation-pair.ts`** (`TRANSLATION_PAIRS`). Adding a language later means extending that table and manifest **`trailingTokens`** — not hard-coding ja/en in UI components. - **`--ja-en`** (default): round-trip **ja → en → ja**; nav **Alt hold** commit sends **English** (`forward` field). - **`--en-ja`**: round-trip **en → ja → en**; nav **Alt hold** commit sends **Japanese**. **Panel labels (原文 / 訳 / 再訳)** - Nav typing preview uses three sections: **source**, **forward** (訳), **back** (再訳). Headings are **bilingual** (Japanese line + English subline) and reflect the active pair, e.g. **`原文(JA)`** / **`Source (Japanese)`**, **`訳(EN)`** / **`Translation (English)`**, **`再訳(JA)`** / **`Back-translation (Japanese)`** for **`--ja-en`**; tags swap for **`--en-ja`** (`getTranslationFieldLabels`). **Status bar** - While assist is **ON**, the translate status strip shows the current pair token (e.g. **`--ja-en`**) plus mode hints (nav typing / busy). Commit hint text follows the pair (English vs Japanese on Alt hold). **Nav typing** - With assist **ON**, **nav typing mode** shows the preview strip under the BMXt prompt. Each **completed sentence** (closing punctuation such as `。` `.` `!` `?` `!` `?`) triggers **round-trip** preview blocks (訳 / 再訳) for the saved pair. - Requires a Chrome build with the **`Translator`** API and availability for the pair’s **source→target** languages; otherwise a short status line is shown. - **Alt hold** commit injects text built from completed blocks via **`buildEnglishCommitText`** (uses **`translateForward`** for the active pair — target language on commit). **Implementation:** **`lib/features/translate/`** (`translation-pair.ts`, `translator-service.ts`, `parse-translate-command.ts`), **`lib/features/bmxt-core/cmd/translate.ts`**, UI in **`bmxt-shell.tsx`** (handled before `RUN_CMD`; no side picker column). <a id="setting"></a> ### `setting` (`setting -list` / `setting -set` / `setting -exit -list`) UI locale and **terminal + picker appearance** are edited in a dedicated **settings picker** side column or via **one-shot `setting …` lines**. **Default persistence** is **`chrome.storage.local`** under **`bmxt_ui_settings_v1`** (`lib/features/extension-storage/keys.ts`). **Optional external storage** uses the File System Access API (user-chosen folder); mode is stored in **`bmxt_ui_settings_storage_v1`**. **Command path (since one-shot / CUI migration):** Rust **`cmd/setting.rs`** parses second tokens and returns **UiActions** (`setting_set`, `setting_export`, …). The settings picker does **not** mutate storage itself — it builds the same lines (`lib/features/picker/build-setting-command-line.ts`) and **`submitConstructedLine`**s them through normal command dispatch. Apply lives in **`apply-ui-action.ts`** → **`setting-cui-apply.ts`** / **`setting-cui-ops.ts`**. | Input | Effect | |-------|--------| | Bare **`setting`** + **Enter** | Prints usage and restores **`setting `** (continuation). Tab completes **`-list`** / **`-set`** / **`-export`** / **`-import`** / **`-exit`** (and related one-shots). | | **`setting -list`** + **Enter** | **Plain** list of current UI settings (`setting.field` rows via **`-list` registry**). | | **`setting -list | browse`** + **Enter** | Opens the **setting** picker column (mirror of committed settings). Applies submit one-shot lines. | | **`setting -set <key> <value>`** + **Enter** | Validates and **saves immediately** (closed key set below). | | **`setting -export`** / **`-import`** | Zip backup download / zip file picker → immediate save. | | **`setting -bg-import [--picker]`** | Background image file picker (optional **`--picker`** layer). | | **`setting -reset-default`** | Reset appearance to defaults and save. | | **`setting -storage internal\|external`** | Switch UI settings storage mode. | | **`setting -pick-dir`** / **`-reload`** | (External mode) re-pick parent folder / reload bundle and save. | | **`setting -snapshot-storage bundled\|vault`** / **`-snapshot-pick-dir`** | Snapshot destination; vault re-pick when vault mode is on. | | **`setting -sync-guide`** | Print Family sync setup guide lines (msgs only). | | **`setting -save`** / **`setting -cancel`** | Compat aliases: close the settings column only (nothing left to discard). | | **`setting -exit -list`** + **Enter** | Closes the setting picker column in this session. | **`setting -set` keys (closed)** | Key | Value | |-----|--------| | **`locale`** | **`ja`** / **`en`** (default **`en`** since **0.96.1**) | | **`edit-picker`**, **`ime-candidate-help`**, **`prompt-fire`** | **`on`** / **`off`** | | **`search-legend`** | **`text`** / **`emoji`** / **`text_emoji`** | | **`host-ui`** | **`auto`** / **`desktop`** / **`mobile`** / **`default`** | | **`fg`**, **`bg-color`**, **`picker-fg`**, **`picker-bg-color`**, **`search-hit-highlight`**, **`search-jump-highlight`** | Hex color, or **`default`** / **`reset`** to clear | | **`size`**, **`picker-size`** | e.g. **`14px`**, or clear tokens | | **`font`**, **`picker-font`** | Font family string, or clear tokens | | **`bg-image`**, **`picker-bg-image`** | Clear only (**`default`** / **`reset`**); import uses **`-bg-import`** | | **`sync-hold-ms`**, **`cli-door-retry-ms`** | Milliseconds, or **`default`** | **Immediate commit** - Each validated apply (picker choice, Enter on edit, image import/clear, reset, zip import, storage-reload) writes **`bmxt_ui_settings_v1`** and, in external mode, the **settings bundle**, then updates the live UI. - Inline color/font typing buffers in **`editDraft`** until Enter validates; partial hex is preview-only and is not written on every keystroke. - The **Preview** panel shows the current (committed) appearance, plus in-progress edit preview while typing. - **`prompt-fire: on`** paints typing/delete FX across the BMXt window canvas (not only the prompt caret). On **Firefox / Gecko**, when a prompt **candidate menu** is open, painting switches to a caret-local **menu-lite** path (`shared/lib/features/prompt-effects/`) so the menu stays responsive; Chromium keeps full quality with the menu open. **Storage (internal vs external)** | Mode | Behavior | |------|----------| | **Extension internal** (default) | Settings live only in **`bmxt_ui_settings_v1`**. No File System Access API. | | **External folder** | User picks a parent directory once. BMXt reads/writes a **settings bundle** under that parent (see below). **`bmxt_ui_settings_v1`** is still updated on every apply (cache + background locale). On startup, load prefers the external bundle when readable; otherwise falls back to internal storage. | **Picker rows (storage):** **storage** — choose internal or external; when external is active, **storage-pick-dir** (change folder) and **storage-reload** (load bundle and save). Switching storage mode commits immediately. **No new manifest permission** — folder access is granted at runtime via the browser picker. **Backup bundle format (zip export/import and external directory)** Zip **export**, zip **import**, and **external save** share one **canonical on-disk layout** (implemented in **`settings-export.ts`**, **`settings-bundle-layout.ts`**): ``` bmxt-ui-settings/ ← subdirectory under the picked parent (or the picked folder if it already contains settings.json) settings.json ← version field (currently 2); locale + appearance; image paths as relative file names background-image.png ← when global bg-image is set (jpg/webp extensions also used) picker-background-image.* ← when picker-specific bg-image is set ``` - **export** — downloads a zip with the same files (portable backup). - **import** — reads a zip and **saves immediately**. - **External save** — writes the same files into the bundle directory on each apply; removes stale `background-image.*` / `picker-background-image.*` files when images are cleared or replaced. **Backward compatibility** When changing UI settings shape or on-disk format in a release: 1. **`settings.json`:** Bump **`version`** only with an import branch in **`parseSettingsExportJson`**; **older versions must keep importing** (today: **v1** and **v2**). New JSON fields are optional; runtime uses **`normalizeUiAppearance`** and related normalizers. 2. **Bundle file names** (`settings.json`, `background-image`, `picker-background-image`, directory name **`bmxt-ui-settings`**) are stable contracts—rename only with a migration path and README update. 3. Bundles and zips saved by **older extension versions** must remain loadable via **import** or **storage-reload** on newer versions. 4. See **`.cursorrules`** § **UI settings persistence** for implementer rules (tests, docs). **Main list (picker)** | Row | Action | |-----|--------| | **language** | `--japanese` / `--english` (UI display language) | | **edit-picker** | **`on`** — show extra rows to customize picker columns separately; **`off`** — picker columns follow global appearance | | **ime-candidate-help** | **`on`** (default, **since 0.8.7**) — show command usage help beside IME candidate tokens; **`off`** — token column only | | **prompt-fire** | **`off`** (default) — no typing/delete FX; **`on`** — fire wrap while typing, glitter shatter when deleting (Firefox: **menu-lite** while the candidate menu is open) | | **search-legend** | **`text`** (default) — scope brackets as text only (`[history]`); **`emoji`** — emoji only (`[⏱️]`); **`text_emoji`** — both (`[⏱️ history]`). Icons: history ⏱️, bookmark 🔖, page 📄, snapshot 📷️. Applies to search picker and `search -list` plain labels | | **host-ui** | **`auto`** (default) — install/runtime detect (**Android → mobile**, else desktop); **`desktop`** / **`mobile`** — force layout. **mobile** (since **0.8.2**): soft key bar; prompt candidate menus support tap-to-select and outside-tap dismiss. **desktop**: keyboard-centric candidate close (**Esc** / **↑** at top), matching **0.8.0** | | **fg**, **bg-color**, **size**, **font**, **bg-image** | Global appearance (terminal **and** picker when `edit-picker` is **off**) | | **fg (picker)**, … | Shown only when **`edit-picker: on`**; override picker column theme (unset fields inherit global) | | **reset-default** | Confirm, then reset appearance to defaults and save | | **storage** | **Internal** (default) or **external folder** (File System Access API); see **Storage** above | | **storage-pick-dir** | (External mode) Re-pick the parent folder for the bundle | | **storage-reload** | (External mode) Load bundle (`settings.json` + images) and save | | **snapshot storage** | **Bundled with settings** (default) or **Obsidian vault** (File System Access API); **snapshot-vault-pick-dir** re-picks the vault when vault mode is active | | **export** | Download zip (`settings.json` v2 + `background-image.*`; optional `picker-background-image.*` when set) | | **import** | Load zip and save immediately | **Appearance rules** - **`edit-picker: off` (default):** one **global** theme. Background image is painted once on the **terminal + picker split row** so it **spans both columns** continuously (`data-bmxt-unified-bg` on `html`). - **`edit-picker: on`:** terminal and picker columns may differ (text/background/size/font/image). Preview shows **Terminal** and **Picker** side by side. **Picker keyboard (setting column)** | Key | Main list | Choice sub-lists (language, size, …) | Detail / edit (fg, colors, font) | |-----|-----------|--------------------------------------|----------------------------------| | **↑** / **↓** | Move highlight | Move highlight (current value pre-highlighted) | — | | **→** / **Enter** | Enter sub-view or run immediate action (export/import) | Apply choice (save) + return to main | Start inline edit / Enter saves | | **←** | Exit to detail bar / prompt strip (same as other pickers) | Back to main | Cancel edit, or back to main | | **Esc** | Return focus to **prompt** (column stays open) | Back to main | Cancel edit, or back to main | Shared contract for all side pickers: **←** = step back / leave column · **→** = step forward / select (`side-picker/interaction/picker-exit-to-detail-bar.ts`, `picker-key-event.ts`). Hex colors support live preview while typing in edit mode. **Implementation:** Rust **`cmd/setting.rs`**; TS apply **`setting-cui-apply.ts`** / **`setting-cui-ops.ts`** / **`setting-set-args.ts`**; picker → line builder **`build-setting-command-line.ts`**; persistence **`settings.ts`**, **`settings-export.ts`**, **`settings-external-storage.ts`**, **`settings-bundle-layout.ts`**; prompt FX **`lib/features/prompt-effects/`**; picker slot **`setting`** in **`lib/features/side-picker/`**; shell wiring **`bmxt-shell.tsx`** / **`useSettingPickerShell.ts`** / **`apply-ui-action.ts`**. <a id="session"></a> ### `session` (terminal sessions) BMXt supports **tmux-style terminal sessions** inside one BMXt window: several independent terminal contexts exist, but **only one is visible** at a time. Background sessions keep their own **log lines**, **open picker columns**, **nav armed** state, **detail bars**, and related per-session UI. **Command history** (`bmxt_cmd_history`) is **shared** across all terminal sessions so you can recall `session -switch <name>` lines with ↑/↓. Persistence while the BMXt window is open is **in the UI page** (React): **`useTerminalSessions`** holds **`TerminalSessionsStateV1`**; see **[Terminal session state (UI source of truth)](#terminal-session-state)**. The Service Worker **`run`** for **`session -list`**, **`session -switch`**, and **`session -setting-name`** prints guidance only; switching and rename UX are **UI-handled** in **`bmxt-shell.tsx`** before **`RUN_CMD`**. Commands such as **`session -new`**, **`session -next`**, and **`session -prev`** go through **`RUN_CMD`**; the SW returns **`SessionPatch`** entries and the UI applies them locally. | Input | Effect | |-------|--------| | Bare **`session`** + **Enter** | Prints usage and restores **`session `** (continuation). Tab completes second tokens. | | **`session -new [name]`** + **Enter** | Effect **`session_new`**: create session, switch to it. Name omitted → auto from open pickers or last non-session command in the source log. | | **`session -list`** + **Enter** | **Plain** numbered session list in the log (`session.row` via **`-list` registry**). | | **`session -list | browse`** + **Enter** | Opens an **inline floating candidate menu** on the prompt (not a side column). Labels `*n displayName`. **↑↓** · **Enter** / **1–9** switch **immediately**. | | **`session -switch`** (or Tab-pick **`-switch`**) | Opens the **inline name menu** with all sessions (`*displayName`). **Does not** auto-insert the active session name. | | **`session -switch`** menu | **Type** to filter (incremental **contains**, same model as the second-command token picker). Menu stays until **Enter** or **Esc** (even while filtering). **Enter** inserts the canonical line `session -switch <name>` into the prompt (picker closes). **Enter** again executes the switch and appends the full line to history. **Esc** dismisses the menu. | | **`session -switch <name>`** + **Enter** | Direct switch by display name (duplicate names use `name (index)` in the command line). | | **`session <n>`** + **Enter** | Direct switch by 1-based index. | | **`session -next`** / **`session -prev`** + **Enter** | Effects **`session_next`** / **`session_prev`**. | | Bare **`session -setting-name`** + **Enter** | Inline rename on the prompt (pre-filled with current display name). | | **`session -setting-name <name>`** + **Enter** | One-line rename. | **Session bar and shortcuts** - When **two or more** terminal sessions exist, a **session bar** at the top of the BMXt window lists them (`index` + display name). Click a tab to switch. - **Ctrl+←** / **Ctrl+→** (BMXt window focused, **2+** sessions) cycles the active session without closing background sessions. **Performance (switch / create):** Only the **active** session and **previously visited** sessions mount a full **`BmxtShell`**; never-visited background sessions use a lightweight placeholder until first visit. **`activeId`** updates optimistically on switch; unchanged log arrays are reused so inactive panes skip redundant re-renders (**`lib/features/bmxt-window/terminal-sessions/sessions-ui-equality.ts`**). Long-running picker work in one session does not block prompt input in another (separate job runners per session id — see **[Job execution](#job-execution)**). **Implementation:** **`lib/features/session/`** (`session-input.ts`, `session-summary.ts`, `session-list-candidate-panel.tsx`, `session-bar.tsx`), UI in **`bmxt-shell.tsx`** / **`bmxt-terminal.tsx`**, effects **`session_new`** / **`session_next`** / **`session_prev`** in **`lib/features/dispatch/handlers/effects/`**. <a id="sync"></a> ### `sync` (Family local sync · same PC · command bus) **Since 0.9.0.** **Goal:** Give each browser profile a unique **device id**, join a **Family** (shared seed / invite — zero custody: members hold plaintext; BMXt never uploads it), then run a low-latency **WebRTC DataChannel command bus** between peers (same PC today). | Stage | Scope | Transport | |-------|--------|-----------| | **6a** | Same PC · Chrome ↔ Firefox | Family invite (`sync -pair` / `-setup`) + roster in `chrome.storage.local` | | **6b** | Same LAN · Family members | Manual / QR discovery; direct connect preferred (future) | | **6c** | Same PC (protocol can extend later) | **Copy-paste / file handshake** (`bmxt-rtc1.`) + **WebRTC DataChannel** (host ICE only); sleep → in-memory queue only | | **§11 (CLI localhost listener)** | Same PC · CLI running | **Localhost HTTP listener** `http://127.0.0.1:17653/` (loopback only, Family-authenticated hello + offer/answer). Extension auto-retries when the BMXt prompt opens. Clipboard / file stay full fallbacks. | **Current capability after connect:** `sync -ping` on the peer; cross-browser **`tab -list` / `search -list`** (and **`bookmark -list` / `history -list`** via the same search scopes) with `--device <id>` / `--peers` (DataChannel RPC); send URLs with `tab -send` / `tab -list | tab -send <deviceId>` (group titles preserved) and optional **`--close`**; send bookmarks with **`bookmark -send <deviceId> [--open|--save|--both]`** (open tabs and/or **`bookmarks_import`** on the peer); peer bookmark mutate via **`bookmarks_ops`** (create / create_folder / remove / move — extension + CLI); tab picker **`:move`** to a **remote window/tab/group row** copies to that peer (default; **`move --close`** for copy-then-close); **`tab -list --peers | browse`** can also **move / close / Enter-activate / reload** remote rows over **`tabs_ops`** within the same peer (group create / new-window on remote rows are still local-only). The **Terminal CLI peer** can list from one browser and open/send to another with **independent source / destination** picks, and can remote-drive peer **`nav`** / **`dom`** via **`nav_control`** / **`dom_list`** / **`probe_capabilities`** (see **[Terminal CLI peer](#terminal-cli-peer)**). While a DataChannel is up, a vim-like status strip under the prompt lists connected peer display names; during final ICE/tunnel bring-up both sides show **Connecting...** and lock command input. **Cross-PC** DataChannel would need extra reachability (roughly: signaling such as Firebase + WebRTC STUN, TURN when needed). **Drive / FSA workdirs are not the sync mainline.** **Family list refresh (`tabs_changed`):** After a successful Family tab mutation (`open_tabs` / `tabs_ops`, and local `--close` when used), BMXt broadcasts a lightweight **`tabs_changed`** signal to **all currently connected** Family peers (including notifying the sender). The payload carries **`first`** — a **first-command selection code** (today always **`tab`**; missing `first` from an older peer is treated as **`tab`**). A peer refreshes an open picker only when that code matches (tab picker reacts to **`first: "tab"`** only). Disconnected peers are not notified; they re-pull on the next `--peers` / `--device` list. **Default is local.** Arbitrary third-party `fetch` stays forbidden (`check:no-fetch`, except the allowlisted **localhost listener client**). CSP **`connect-src`** is **`'self'`** plus the fixed CLI localhost-listener origins only (`http://127.0.0.1:17653` · `http://localhost:17653`). Firefox **`data_collection_permissions: none`** stays. In-page scripting (**nav** / **`dom`** / **`search --page`**) remains **https-only** — general `http://` DOM is still not scriptable; the localhost host grant is for connection setup only. **UX:** First Family join: **`sync -setup`** (or `-pair`). Handshake UI is a dedicated **wizard** under **`shared/lib/features/sync/wizard/`** (not a long terminal dump): **COPY** puts the Family invite (`bmxt1.…`) or handshake (`bmxt-rtc1.…`) on the clipboard; the peer pastes the code body in the wizard paste field. When the handshake completes, the wizard closes automatically. After disconnect: both sides **`sync -connect <peerDeviceId>`** with the same wizard flow, **or** reopen the BMXt prompt while the CLI localhost listener is up for Family-authenticated auto-reconnect. The setting picker sync panel only shows a setup guide and display-name edit. **Module layout:** **`shared/lib/features/sync/`** (wizard · link status · bus RPCs). Host UI applies Wasm **`UiAction`** kinds (`sync_setup` … `sync_open`, **`sync_bookmark_send`**) via a thin facade. I/O goes through **stabilizers** (discovery / peer host / command bus / memory queue). Bus RPCs include `tabs_list` / `search_query` / `open_tabs` / **`bookmarks_import`** / **`bookmarks_ops`** / **`tabs_ops`** / **`tabs_changed`** (`first` + `reason`) / **`probe_capabilities`** / **`dom_list`** / **`nav_control`**. **Peer host** is the **BMXt prompt window** (`bmxt.html`) only — no offscreen document and no dedicated peer tab. The DataChannel lasts while that window stays open (and until an explicit re-handshake replaces the session). ICE uses **host candidates only** (no public STUN/TURN on the local path). **Mesh:** User-facing connect stays “handshake with any one live Family member.” After that link is up, BMXt **automatically completes a full mesh** (in-band `mesh_peers` / `mesh_signal` over existing DataChannels) so every prompt can reach every other connected peer directly — no hub relay for tab ops. <a id="terminal-cli-peer"></a> ### Terminal CLI peer (`hosts/cli`) **Status (todo §10–§20):** A Rust-only Family peer binary **`bmxt`** under **[`hosts/cli/`](hosts/cli/README.md)** talks to the browser extension over the **same WebRTC DataChannel bus** (host ICE, `bmxt-rtc1.`). No native messaging / CDP. Shares the **BMXt POSIX Profile** I/O contract with the extension (todo §13); oneshot **`bmxt exec`** (todo §14); Profile gates when adding commands (todo §15); bookmark / history / cross-browser send parity (todo §16); peer **`aboutbmxt` / `dom` / `nav`** over RPC (todo §17); independent ratatui pickers (todo §18); command-base pickers + optional **`--focus`** (todo §19); main-screen candidate menu (todo §20). | Topic | Current behavior | |-------|------------------| | **Direct start** | `bmxt` or `bmxt repl` opens a REPL (**Interactive** · `CommandIo` → process FDs). With Family joined, CLI also serves a **localhost HTTP listener** on `http://127.0.0.1:17653/` (binds **127.0.0.1 only**, Family-authenticated `GET /v1/hello` · `POST /v1/handshake/offer` · `POST /v1/exec`). | | **One-shot (`exec`)** | With a resident REPL listening, `bmxt exec -- 'sync -status'` / `bmxt exec -- 'tab -list --peers'` runs **NonInteractive** on the resident (`POST /v1/exec`), prints **stdout/stderr**, and exits with the Profile status (LLM / scripts). No `| browse` / handshake ask / zenity. No resident → clear error, exit **1**, no hang. | | **Auto-connect** | Open the BMXt prompt in each browser — Family-authenticated connection setup to the CLI localhost listener retries in the background (todo §11). Unrelated localhost services that fail Family membership verification are ignored. Clipboard / file remain full fallbacks. | | **Prompt** | Family ready → **`BMXt>`** (accepting commands). Not in a Family → **`BMXt*>`**. | | **Connection logs** | Normal scrollback lines (`connection` / `datachannel` / `connected: …`). While `BMXt>` is waiting, async logs are **queued and drained above the prompt** (crossterm main-screen redraw; not rustyline). ICE `checking` noise is suppressed. | | **Peer drop vs exit** | Last peer tunnel closes while the REPL stays up → i18n “peer closed; listener keeps running” (`LANG=ja*` → Japanese). **`quit` / `exit` / EOF** ends the **`bmxt` process** (no “still listening” claim). | | **Connect (fallback)** | `bmxt sync-connect [--offer]`, or REPL `sync -offer` / `sync -accept` (Enter / `:pick` via `zenity` / `kdialog`). | | **Handshake files** | Offer/answer JSON under `~/.config/bmxt/`; OSC-8 `file://` when supported. Prefer `@path.json` over bare `bmxt-rtc1.` paste. | | **UI settings / i18n** | `~/.config/bmxt/bmxt-cli-ui-settings/settings.json` (export v2 layout). Locale: committed → env → `en`. REPL: `setting -list` / `-set` (immediate save); `-save` / `-cancel` close aliases (todo §12). `| browse` for settings is CLI-only unsupported. | | **Command grammar** | Same as the extension via **`bmxt-core`** (`default-features = false`, no WASM in the CLI link). Examples: `tab -list --peers \| browse`, `bookmark -list --device <id>`, `history -list --device \| browse`, `tab -send <deviceId> …`, `bookmark -send <deviceId> --open\|--save\|--both …`, `sync -ping <deviceId>`, `aboutbmxt` / `aboutbmxt -system`. | | **Line editor / Tab** | Main-screen line editor (**crossterm**; not rustyline). History (`↑↓`, `~/.config/bmxt/history`). **Ctrl+R** reverse incremental history search (same as the extension: type to filter · Ctrl+R/↓ older · ↑ newer · Enter accepts into the prompt without running · Esc cancels). **`setting -set prompt-fire on|off`** (immediate save, Tab-completable) toggles yellow text-cell particles from the caret on the **CLI-managed band only** (`BMXt>` row + overlays below; history above the prompt is left as-is). **Grey remainder hint** is visual only while the candidate menu is closed (**Right** moves the caret only — never commits, same as the extension). **Tab** opens a candidate **overlay** (empty line → all first tokens). **CLI-only:** typing a **non-empty partial token at EOL** also auto-opens when there are matches (e.g. `nav en` → `-enter`; empty typed stays Tab-only). **↑↓** / **Tab** move · **Enter** rewrites that same base `BMXt>` line and may offer the next tier (**does not run**) · **Esc** or **↑** at top dismisses until Tab · open **prefix** / open-while **contains** · replace span **reverse-video**. Prompt **Enter** (menu closed) runs the line. After a list producer `-list`, Tab offers **`\| browse`** (and other pipe consumers). After a typed **`\|`**, Tab completes bare consumer names (`browse`, `close`, …). | | **No local browser inventory** | CLI has no Chrome/Firefox APIs. Bare `bookmark -list` / `history -list` **fan out** to connected peers via **`search_query`** (flat hits). `bookmark -add` / `-folder` / `-remove` / `-move` go through peer **`bookmarks_ops`**. `history -delete*` is **unsupported** on CLI (peer history delete is out of scope). Backup/restore stay extension-only. | | **Source peer (`--device`)** | **`--device <id>`** lists that peer only (oneshot stdout). Bare **`--device`** (no id) is a valid plan: plain run → exit **2**; Interactive **`… --device \| browse`** → numbered connected-peer pick (auto-select when only one peer), then the existing URL/tab picker. Same for **`tab`** / **`bookmark`** / **`history`** / **`search -list`**. | | **Destination peer (open / send)** | Flat URL browse (`bookmark` / `history` / peer `search`): **Space** marks URLs → **Enter** → destination-peer list → **Tab** marks one or more peers → **Enter** opens on all marked (or the highlighted peer if none marked). **Source and destination are independent** (list from browser A, open/send to browser B). Typed CUI still uses **`tab -send <deviceId>`** / **`bookmark -send <deviceId> [--open\|--save\|--both]`** (and pipes). CLI **`--close`** is skipped (no local tabs). | | **Tab picker / `--focus`** | `tab -list --peers \| browse` opens a ratatui picker under **`hosts/cli/src/picker/`**. Pickers **assemble** typed lines (`tab -activate <tabId> --device <peerId> [--focus]`) and run them through **`run_line` / `DispatchBundle`** — no direct `tabs_ops` from Enter. One-time **y/N** before browse can add **`--focus`** (bring the peer browser window forward); oneshot `tab -activate … --focus` does the same. **Enter** activates on the owning peer (ids are per-browser); picker **stays open** until **q** / **Esc**. Open picker **follows Family `tabs_changed`** (same `first: "tab"` rule as the extension) and re-fetches the list while preserving selection when possible. | | **`aboutbmxt` / `dom` / `nav` (CLI)** | Shared grammar: **`aboutbmxt`** / **`aboutbmxt -system`** (welcome URL · CLI self-diag + peer **`probe_capabilities`**). **CLI-host only** (not shared extension grammar): oneshot **`dom -list --device <id> --tab <n> […]`** → stdout via **`dom_list`**; Interactive **`dom -wizard`** / **`nav -enter`** use peer→tab one-shot pickers, then drive the peer page overlay with **`nav_control`** (arrows = 24px free-move · Alt+arrows = 72px · Enter = `click` · **keeps terminal focus**; avoid Shift+arrows — many terminals steal them for scrollback). **`nav -exit`** disarms. Extension `dom` / `nav` display & local logic stay unchanged. | | **Mesh** | First peer via localhost listener or manual connection setup; additional Family peers join over in-band mesh (CLI acts as introducer; tab ops are not hub-relayed). | | **Build** | `cargo build -p bmxt-cli` → `target/debug/bmxt` (release: `cargo build --release -p bmxt-cli`). | | **Prebuilt** | GitHub Releases tagged **`cli-v*`** — see **[BMXtCLI GitHub Releases](#bmxt-cli-releases)** (binaries + `SHA256SUMS.txt`). | **Cold start (same PC):** (1) join the same Family on CLI + browsers · (2) start `bmxt` · (3) open each BMXt prompt window → Family-authenticated auto-reconnect. Stop the process with REPL **`quit`** / **`exit`**. <a id="bmxt-cli-llm"></a> #### Using BMXtCLI with an LLM Model: **one resident process + many oneshot clients** — same idea as **`docker exec`** against a running container (not `docker run` every time). | Role | Command | Binds `:17653`? | |------|---------|-----------------| | **Resident (server)** | `bmxt` or `bmxt repl` — start **once**, keep running | Yes (when Family is joined) | | **LLM / script (client)** | `bmxt exec -- '<grammar line>'` | **No** — `POST /v1/exec` only | **Setup (human or bootstrap, not per LLM turn):** 1. Join the same Family on CLI and browsers; open a BMXt prompt window so a peer can auto-connect. 2. Start **one** resident: `bmxt` (or `bmxt repl`). Confirm `BMXt>` and that the localhost listener is up (`http://127.0.0.1:17653/`). 3. Point the agent at the `bmxt` binary (e.g. `target/release/bmxt` or a PATH install). **Each LLM / tool turn** — run the **subcommand** `bmxt exec` as a normal oneshot shell command (do **not** start another `bmxt` / `bmxt repl`): ```bash # Quote the grammar line so the shell does not treat `|` as a pipe. ./path/to/bmxt exec -- 'sync -status' ./path/to/bmxt exec -- 'tab -list --peers' ./path/to/bmxt exec -- 'bookmark -list --device <id>' ./path/to/bmxt exec -- 'history -list --device <id>' ./path/to/bmxt exec -- 'tab -send <deviceId> https://example.com --group MyGroup' ./path/to/bmxt exec -- 'bookmark -send <deviceId> --save https://example.com' ./path/to/bmxt exec -- 'help' echo $? # Profile exit: 0 success · 1 failure · 2 misuse · 127 unknown ``` | Channel | Meaning for the agent | |---------|------------------------| | **stdout** | Command result lines only | | **stderr** | Diagnostics (usage, errors, “resident missing”) | | **exit** | Process status — same BMXt POSIX Profile as the extension | **Not the shell builtin `exec`:** Agents with `run_shell_command` (Gemini CLI, etc.) often refuse “exec” because they think it means attaching to an interactive TTY or replacing the shell process. **`bmxt exec` is unrelated** — it is a **CLI subcommand** that starts a **new short-lived process**, `POST`s `http://127.0.0.1:17653/v1/exec`, prints stdout/stderr, and exits. No stdin attach to the resident REPL is required. Always write the full argv (`bmxt exec -- '…'`), never bare shell `exec`. **Do not (common failure):** - Launch a **second** `bmxt` / `bmxt repl` from the agent — door bind fails with `Address already in use` (port **17653**), while the banner may still look “ready”. - Expect `| browse`, handshake ask, or zenity inside `bmxt exec` — NonInteractive refuses them (configure delivery / connection in the REPL first). - Assume cold-start self-contained peer bring-up inside one `bmxt exec` — that path is out of scope; keep the resident up. - Pass an unquoted `|` to the shell (`… | browse`) — bash looks for an external `browse` binary; quote the whole grammar line. **Tool-definition hint for agents (copy-paste):** “Resident `bmxt` is already listening on 127.0.0.1:17653. For each browser/Family action, run exactly one shell command of the form `./path/to/bmxt exec -- '<grammar line>'` via your normal shell tool. This is the BMXt oneshot client (HTTP POST), **not** the shell builtin `exec`, and it does **not** attach to the resident process stdin. Never start `bmxt` or `bmxt repl`. Never use bare `exec`.” **Out of scope for this host:** Painting `nav` / `dom` page overlays **inside the terminal** (peer overlay remote-control via `nav -enter` / `dom_*` RPC is in scope — todo §17); settings picker browse / FSA; peer history delete; CLI `bookmark|history -backup/-restore`; native messaging; public STUN/TURN on the default path; local CA / HTTPS CLI; true incremental chunk delivery over exec IPC; folder/date tree TUI on CLI (flat `search_query` only until todo §16.7). Contract: [`_context/cli-peer/CONTRACT.md`](_context/cli-peer/CONTRACT.md) · checklist: `_context/todo.md` §11–§20. <a id="bmxt-cli-releases"></a> #### BMXtCLI GitHub Releases (prebuilt binaries + checksums) Public maintainer / user manual for shipping and verifying the **`bmxt`** terminal peer. Binaries are **not** committed to git; they are attached only to [GitHub Releases](https://github.com/UNRsports/bmxt/releases). Workflow: [`.github/workflows/release-cli.yml`](.github/workflows/release-cli.yml). **Native per OS:** `bmxt` is a Rust native binary (ELF / Mach-O / PE). A Linux build does **not** run on macOS or Windows. Pick the asset that matches your OS and CPU. ##### Release assets | Asset | Platform | |-------|----------| | `bmxt-linux-x86_64` | Linux x86_64 (glibc) | | `bmxt-macos-aarch64` | macOS Apple Silicon | | `bmxt-windows-x86_64.exe` | Windows x86_64 | | `SHA256SUMS.txt` | SHA-256 digests for every binary asset above | Example download URL (replace the version): `https://github.com/UNRsports/bmxt/releases/download/cli-v0.1.0/bmxt-linux-x86_64` There is no stable “latest binary” URL for a named asset; use the Releases page or a versioned URL. Out of scope for now: Linux aarch64, macOS Intel (Rosetta covers many Intel Macs), code signing / notarization. ##### Download and install (users) 1. Open the latest **`cli-v*`** release on [Releases](https://github.com/UNRsports/bmxt/releases). 2. Download the matching binary **and** `SHA256SUMS.txt` from the **same** release. 3. Verify the checksum (next subsection), then make the file executable and put it on `PATH` if you want: ```bash # Linux / macOS (example) chmod +x bmxt-linux-x86_64 mv bmxt-linux-x86_64 ~/.local/bin/bmxt # or any directory on PATH bmxt --help ``` On Windows, rename `bmxt-windows-x86_64.exe` to `bmxt.exe` if you prefer, and place it on `PATH`. **Unsigned binaries:** builds are not Apple-notarized or Authenticode-signed. macOS Gatekeeper or Windows SmartScreen may warn on first run; allow the file only if you obtained it from this repository’s Releases and the checksum matches. ##### Checksums (what and why) A **checksum** is a fingerprint of the file bytes (here **SHA-256**). The same file always yields the same digest; any change yields a different digest. `SHA256SUMS.txt` lets you confirm that the file you downloaded is **byte-identical** to the asset CI attached to that release (corruption or substitution). It does **not** by itself prove the publisher is trustworthy — download **both** the binary and `SHA256SUMS.txt` from the official Releases page for that tag. **Verify (Linux):** ```bash sha256sum -c SHA256SUMS.txt --ignore-missing # or check one file: sha256sum bmxt-linux-x86_64 # compare the printed digest to the matching line in SHA256SUMS.txt ``` **Verify (macOS):** ```bash shasum -a 256 -c SHA256SUMS.txt --ignore-missing # or: shasum -a 256 bmxt-macos-aarch64 ``` **Verify (Windows, PowerShell):** ```powershell Get-FileHash .\bmxt-windows-x86_64.exe -Algorithm SHA256 # Compare Hash to the matching line in SHA256SUMS.txt ``` ##### Maintainer publish procedure Tags use the prefix **`cli-v*`** so CLI releases stay independent of extension store tags. The semver after `cli-v` must equal **`version`** in [`hosts/cli/Cargo.toml`](hosts/cli/Cargo.toml) (CI checks this). 1. Bump `version` in `hosts/cli/Cargo.toml` (e.g. `0.1.0` → `0.1.1`). 2. Commit on the branch you intend to ship from (usually `main`). 3. Create an annotated tag and push it: ```bash git tag -a cli-v0.1.0 -m "BMXtCLI 0.1.0" git push origin cli-v0.1.0 ``` 4. GitHub Actions workflow **Release BMXtCLI** builds on `ubuntu-latest`, `macos-latest`, and `windows-latest`, then publishes a Release for that tag with the three binaries and `SHA256SUMS.txt`. 5. Spot-check the Release page: asset names, `SHA256SUMS.txt` lines, and a quick `bmxt --help` / smoke on at least one OS. Do **not** commit `target/release/bmxt` (or platform copies) into the repository. Do **not** put store credentials (`SUBMIT_KEYS`) or signing secrets into this workflow. Manual re-run: Actions → **Release BMXtCLI** → **Run workflow** (same tag / `workflow_dispatch` as configured in the YAML). <a id="picker-ui"></a> ### Picker UI (side columns) When a list picker is opened from the prompt, **`lib/features/bmxt-window/bmxt-shell.tsx`** lays out the focused session leaf as a horizontal strip: **Terminal (log + prompt)** | **tabs** (if open) | **search** (if open) | **dom** (if open) | **setting** (if open) | **bookmark** (if open) | **history** (if open) Several picker columns may be open at once in the same pane. Session state is **`sessionPickers`** per leaf (`tabs` / `search` / `dom` / `setting` / **`bookmark`** / **`history`** slots). While the BMXt window is open, **open columns, `paneFocus`, tab-picker highlight/marks, and tree fold state** live in **UI memory** (not the Service Worker). Closing and reopening the BMXt window starts fresh (see **[BMXt process lifecycle](#bmxt-process-lifecycle)**). **`SessionPickerColumns`** in **`lib/features/side-picker/wrappers/session-picker-columns.tsx`** renders open columns (`PICKER_SLOT_ORDER`: tabs → search → dom → setting → **bookmark** → **history**). **Four layers (side picker)** | Layer | Role | Main paths | |-------|------|------------| | ① Parent terminal | Log, prompt, picker launch/close | `lib/features/bmxt-window/bmxt-shell.tsx`, `bmxt-terminal.tsx` | | ② Panel host | Column chrome, blue focus border, click-to-activate | `lib/features/side-picker/panel/picker-panel-host.tsx` | | ③ Command wrapper | Slot entry + keyboard wiring | `url-list-picker-wrapper.tsx`, `dom-picker-wrapper.tsx`, `tabs-picker-wrapper.tsx`, `setting-picker-wrapper.tsx`, **`bookmark-picker-wrapper.tsx`**, **`history-picker-wrapper.tsx`** | | ④ Command body | Flat lines vs hierarchical rows vs settings | `PlainTextPickerBody` (search/dom lines), `TabsUrlListPicker` + `TabPickerRowList` (tabs), **`TreePickerBody`** (bookmark / history trees), `dom/dom-prompt-render.tsx`, `setting-picker-body.tsx` | **Shared keyboard:** **`usePlainPickerKeyboard`** in `lib/features/side-picker/hooks/` drives `/`, `:`, `n`/`N`, **`Esc` → prompt**, vertical navigation, and **Ctrl+←/→** pane-strip navigation via the interaction kernel (`lib/features/side-picker/interaction/picker-*.ts`). **search** and **dom** line columns use it directly; **tabs** adds **`useTabPickerPlainExtensions`** (`lib/features/tabs/use-tab-picker-plain-extensions.ts`) for bulk/edit, `#` / `Tab`, Shift range, and layered **`Esc`**. **bookmark** / **history** use **`useTreePickerKeyboard`** (`lib/features/side-picker/tree/`) — fold with **←/→**, **Space** mark, **Enter** / **→** action menu, shared `/` / `n` / `N` / `:nohlsearch`. **Shared list chrome:** **`PickerListShell`** (`chrome/picker-list-shell.tsx`) — headline, invisible IME `textarea`, list slot, search/command footers. **tabs** render through **`TabsUrlListPicker`** on this shell. **bookmark** / **history** render through **`TreePickerBody`** on the same shell (folder or month→day→visit trees). **search** / **dom** line lists still use **`PlainTextPickerBody`** (same CSS classes, optional virtualization; may move to `PickerListShell` later). **`PickerEntry` (search)** Search hits are normalized to **`PickerEntry`** (`url`, `source`, display line) before render. **`[history]`** / **`[bookmark]`** rows: **`→`** opens the in-picker **open-target** tree; **`Enter`** on a results row dispatches **`open_url_new_tab`** (or in-tab jump when a page hit applies). Implementation: **`lib/features/search/search-open-destination.ts`**, **`open-search-picker-entry.ts`**, wired from **`bmxt-shell.tsx`**. **Focus and blue border** - **`paneFocus`** selects the active column: `terminal` → `tab` → `search` → `dom` → `setting` → **`bookmark`** → **`history`** (skipping columns that are not open). - The active column gets a **blue outline** (`.bmxt-split-pane--focused`). - When a column **newly opens** or receives focus from the **detail bar**, keyboard focus and the outline move to that column; the focused picker column **animates to the left** of other open columns (`usePickerColumnFlip`). - **Ctrl+Left / Ctrl+Right** walk the strip inside the active session. With **two or more** terminal sessions, **Ctrl+← / Ctrl+→** also cycles the active session (see **[`session`](#session)**). - Clicking a column activates it the same way. **Detail bars (mode status strips under the prompt)** While a picker is open (or nav / translate assist is active), a **detail bar** appears under the prompt for that mode (`tab`, `search`, `dom`, `setting`, **`bookmark`**, **`history`**, `nav`, `translate`). Common keys when the **terminal** column is focused: | Key | Effect | |-----|--------| | **`→`** (caret at **end-of-line**) | Select the leftmost visible detail bar | | **`←`** (from a detail bar) | Return focus to the prompt (**blocked while nav overlay is ON** — arrows drive the page cursor) | | **`Tab`** / **`Shift+Tab`** | Cycle among visible detail bars (**suspended while nav overlay is ON**) | | **`Alt`** (tab / search / dom detail bar) | Toggle **`--auto` / `--manual`** page-active (persisted) | | **`Alt`** (nav detail bar) | Toggle nav overlay **ON** / **OFF** | | **`→`** (from a detail bar) | Enter the matching picker column (column moves left with animation) | | **`Ctrl+C`** (from a detail bar) | Close the matching browse column (**tab** / **search** / **dom** / **setting** / **bookmark** / **history**), or **disarm nav** when the **nav** detail bar is selected | While the nav overlay is **ON**, focus **stays on the nav detail bar** (typing mode is the temporary exception). Each bar shows mode-specific hints. **`useDetailBarKeyboard`** in **`lib/features/bmxt-window/use-detail-bar-keyboard.ts`** wires these keys. **`Esc` vs closing** - **`Esc` does not close a picker column.** At the top level of any picker, **`Esc` returns focus to the BMXt prompt** in the session that launched the picker; columns stay visible. - **Tab picker only:** nested submodes unwind with **`Esc`** first (`#` marks → `:` command mode → `/` search → bulk submode → then **return to prompt**). See [Tab Picker (`tab -list`)](#tabs-tab-picker). - **Close a column** from the prompt in the **same session**: | Command | Closes | |---------|--------| | `tab -exit -list` | Tab picker (including interactive **`group new`**) | | `search -exit -list` | Search list picker | | `dom -exit -list` | DOM list picker (including the permission confirmation panel) | | `setting -exit -list` | Settings picker | | **detail bar `Ctrl+C`** | Also closes **bookmark** / **history** columns (no dedicated `*-exit -list` yet) | Service Worker **`run`** for `*-exit -list` prints usage hints only; the window UI performs the actual close. **How columns open (`<list> | browse` or picker-only flows)** | Input | Behavior | |-------|----------| | `tab -list | browse` / `tab -list -url | browse` | Opens the tab picker column | | `group new` (no tab ids) | Opens the tab picker in **group-new** variant | | `search -list` only (no trailing space) + **Enter** | Restores the prompt to **`search -list `** (continuation) | | `search -list … | browse` only + **Enter** | Restores **`search -list … | browse `** or shows scope menu (see **[`search`](#search-command)**) | | `search -list … | browse` + **Enter** | Runs search in the **search** picker column | | `dom -list … | browse` only + **Enter** | Shows `--normal` / `--with` / `--html` / `--react` option menu when mode/flavor unset | | `dom -list … [--normal|--with] [--html|--react] … | browse` + **Enter** | Fetches DOM output, opens the dom column | | `setting -list | browse` + **Enter** | Opens the settings picker column (see **[`setting`](#setting)**) | | `bookmark -list … \| browse` + **Enter** | Opens the **bookmark** tree picker (folder tree; actions → typed CUI lines) | | `history -list … \| browse` + **Enter** | Opens the **history** tree picker (month → day → visit; actions → typed CUI lines) | | `translate -on` + **Enter** | Enables translation assist (prompt stays focused) | **Plain `-list` (terminal log, no column)** — default for **`tab -list`**, **`dom -list`**, **`search -list`**, **`session -list`**, **`setting -list`**, **`bookmark -list`**, **`history -list`** (plain; use **`<list> | browse`** for the column). Output uses schema **`bmxt-list/1`**; see **[`-list` output registry](#list-commands-registry)**. **Tree pickers (`bookmark -list | browse` / `history -list | browse`)** Shared chrome: **`lib/features/side-picker/tree/`** (`TreePickerBody`, `useTreePickerKeyboard`, fold/search helpers). Actions always go through **`submitConstructedLine`** (same typed grammar as the prompt — no direct `chrome.bookmarks` / `chrome.history` calls from the picker). | Key / gesture | bookmark | history | |---------------|----------|---------| | **↑ / ↓** | Move highlight | Same | | **← / →** | Collapse / expand folder | Collapse / expand month or day | | **Space** | Mark leaves or folders (not mixed) | Mark visits, days, or months (not mixed) | | **Enter** / **→** (on row) | Action menu: open / remove / move / **send** (`--open` / `--save` / `--both` + peer pick) | Action menu: open / delete / delete-range | | **/** · **n** / **N** · **`:nohlsearch`** | Shared filter / next match | Same | | **Esc** | Return to prompt (column stays open) | Same | | Close column | Detail bar **`Ctrl+C`** | Same | **Settings picker column (`setting -list | browse`)** - Immediate commit on apply via one-shot **`setting …`** lines (`build-setting-command-line.ts`); preview mirrors committed settings — see **[`setting`](#setting)**. - **`Esc`** at the column top level returns to the **prompt** (column stays open); **`setting -exit -list`** closes it. - Keyboard: **`useSettingPickerKeyboard`** (`lib/features/setting/use-setting-picker-keyboard.ts`); not the plain-list `/` / `n` / `N` model. **Plain list columns (search / dom lines)** - **`/`** — incremental filter; **`Enter`** ends search mode (search: **`Enter`** on a row also opens the URL, or jumps to a page match when detail navigation applies). - **`:`** then **`nohlsearch`** — clear filter and search highlight. - **`n`** / **`N`** — jump among matches on the **results** row (when a row has multiple page matches). - **`→`** / **`←`** — **search only:** **`→`** opens **detail** when the tab is open (subdivided hits), else **`[history]`** / **`[bookmark]`** **open-target** when the tab is closed; **`←`** steps back. **`Esc`** in detail or open-target returns to results first. - **`Ctrl+Left` / `Ctrl+Right`** — move along the pane strip (see above). - **dom only:** **`--normal`:** **`↑` / `↓`** (or **`j` / `k`**) move focus among **jumpable** element rows; the **target tab scrolls** to the highlighted node (debounced). **`--with`:** **`↑` / `↓`** scroll the page; **`Alt+↑`/`↓`** move element highlight. Header/metadata lines without a DOM path are skipped. **Common picker keys (authoritative)** Headline strings in the UI come from **`lib/features/side-picker/interaction/picker-headlines.ts`** (search/dom) and **`lib/features/bmxt-core/tabs-picker/headline.ts`** (tabs, mode-dependent). Keep this table aligned when changing shortcuts. | Key / gesture | search / dom lines | Tab picker (`tab -list | browse`) | |---------------|------------------|---------------------------| | `j` / `k`, `↑` / `↓` | Move highlight; search **`--auto`**: preview open-tab rows on move | **`↑` / `↓`** only — move highlight (`moveHi`); **`--auto`**: also activates tab in background window | | `Ctrl+↑` / `Ctrl+↓` | **search only:** jump among **open-tab** result/detail rows (animated scroll; **`--auto`** previews) | — | | `Alt+↑` / `Alt+↓` | **search only, `--manual` page-active:** preview highlighted row in background tab | **`--manual` only:** activate highlighted tab in background window | | `/` | Search mode; `@` prefix matches URL substring | Same; filters visible rows | | `Enter` in `/` mode | End search (commit highlight pattern) | End search | | `Enter` in normal mode | search results: open URL or jump; search detail: jump; search open-target: open at chosen target | Focus highlighted tab (picker stays open) | | `:` → `nohlsearch` | Clear filter + highlight | Clear search highlight | | `n` / `N` | Next / previous match on results row | Next / previous match row | | `→` / `←` | search: detail (open tab) or **`[history]`** / **`[bookmark]`** open-target (closed tab); dom: **detail bar** when at prompt EOL | Collapse / expand highlighted **window** or **tab group** row (tab row: parent group) | | `Ctrl+←` / `Ctrl+→` | Pane strip (terminal ↔ open columns) | Same | | `Esc` | Prompt, or search detail → results first | Unwind `#` → `:` → `/` → bulk → prompt | | `#` / `Tab` | — | Toggle mark / multi-select | | `:` + bulk commands | — | `move`, `close`, `group`, `nw`, `nt`, `edit` (see [Tab Picker](#tabs-tab-picker)) | | `Shift+↑` / `Shift+↓` | — | Extend `#` range on tab rows | | `Ctrl+Shift+↑` / `Ctrl+Shift+↓` | — | Move highlight and force-activate tab in background window | | Close column | `search -exit -list` / `dom -exit -list` | `tab -exit -list` | **Translate assist (prompt / nav typing)** - **`translate -on`** enables assist only (no side editor column). **`translate -off`** disables it. - In **nav typing mode**, the prompt shows a live **原文 / 訳 / 再訳** preview strip under the input (bilingual headings; language tags follow **`translate -setting`**). See **[`translate`](#translate)**. **Adding a new side picker column** 1. Add a slot id to `PickerSlotId` in `lib/features/side-picker/session/session-pickers.ts` and session state fields. 2. Register a renderer in `lib/features/side-picker/wrappers/picker-slot-registry.tsx` (order in `PICKER_SLOT_ORDER`). 3. Add manifest subcommands: `<command> -list` to open, `<command> -exit -list` to close (UI-handled in `bmxt-shell.tsx`; Service Worker prints hints only). 4. Wire open/close in `bmxt-shell.tsx` and `setSessionPickerSlot` in `bmxt-terminal.tsx`. 5. Add a headline constant in `picker-headlines.ts` when using `PlainTextPickerBody` / `UrlListPickerWrapper` / `PickerListShell`. 6. For tabs-like bulk modes, extend **`PlainPickerKeyboardExtensions`** and keep reducer/execute logic in the feature module (see `use-tab-picker-plain-extensions.ts`). <a id="tabs-man-tabs"></a> ### `tab` (subcommands) - `tab` alone prints available options and restores the prompt to `tab ` so users can continue with the next token. - `tab -list` / `tab -list -url`: plain tab tree in the log (**`RUN_CMD`**). - `tab -list | browse` / `tab -list -url | browse`: open tab picker column (`-url` includes URL rows). - `tab -exit -list`: close tab picker column in this session. - `tab -setting -page-active --auto | --manual`: configure tab preview on highlight. **`--auto`** (default): moving highlight activates the tab in the background window. **`--manual`**: only **Alt+↑↓** (or holding **Alt**) activates; **Enter** still jumps to the highlighted tab and brings its window forward. Persisted in **`chrome.storage.local`**; a **tabs** status strip under the prompt shows the current mode while the tab picker is open. - `tab -nowurl`: print current tab URL. - `tab -moveurl <url>`: activate matching http(s) tab and bring its window to front, or open a new tab if none matches. After `tab -moveurl ` (trailing space), **Tab** cycles open http(s) tab URLs as completion candidates. - `tab help`: show the `tab` manual section (also listed in the second-command candidate menu). <a id="tabs-tab-picker"></a> ### Tab Picker (`tab -list | browse` / `tab -list -url | browse`) **Tree layout** - Rows are hierarchical: **`[window]`** → **`[tab group]`** (real Chrome tab groups only) → **tab rows**. **Tab rows** show a **favicon** when Chrome can resolve one for the page URL. - Tabs **not** in a Chrome group are listed **directly under their window** (there is no “(no group)” header row). - **Initially every window and group is expanded.** **←** on a highlighted **window** or **tab group** row collapses it (**→** expands). On a **tab** row, **←** moves focus to the detail bar; **→** opens the action menu. - Collapse/expand state is kept **while the BMXt window is open** (UI memory; discarded when the window closes — see [BMXt process lifecycle](#bmxt-process-lifecycle)). **Navigation and bulk** - On launch, highlight starts at the active tab of the last focused normal browser window. - Move with `j`/`k` (or `↑`/`↓`), toggle `#` on highlighted tab with `Tab` (multi-select supported). **Shift + `↑`/`↓`** extends a range selection anchored at the first mark. - **Bulk operations** — press `:` to open the command line, type a command, and press `Enter` to confirm. `Tab` cycles through completions from the current prefix. If no tab is marked yet, the highlighted tab is auto-marked when the command is confirmed. - Tab rows: `move` (`m`), `close` (`c`), `group` (`g`), `newwindow` (`nw`), `bookmark` (`bm`) - Window rows: `close` (`c`), `newtab` (`nt`), `edit`, `bookmark` (`bm`) - Group rows: `move` (`m`), `close` (`c`), `newwindow` (`nw`), `edit`, `bookmark` (`bm`) - In `:` command mode, pressing `Tab` or `Enter` with an empty command shows a dim placeholder of available commands for the current target (tab/window/group). - **[MOVE]** — destination mode depends on what you marked: - **Tab marks (`#` on tabs):** navigate the **insert slot between tabs** with `↑`/`↓` (purple gap line; not “onto” a tab), then `Enter`. A **tab** row = gap above that tab; a **group** row = gap above the first tab in that group (join the group); a **window** row = after the last tab in that window. Next to a **grouped** tab (or group row) → marked tabs join that group; next to an **ungrouped** tab → they leave their current group. Typed line uses `#t:… \| move --window … [--before-tab …]` / `--group` / `--ungroup`. - **Group marks (`#` on tab-group headers):** destinations are **window / group header rows only** (no tab-gap slots; ↑/↓ snap among headers). A **group** header appends the moved groups to the **end of that group**; a **window** header moves each marked Chrome tab group **as a unit** (`chrome.tabGroups.move`, one group per call). Typed line adds **`--as-group <gid>…`** (cannot combine with dest `--group` / `--ungroup`). - **[CLOSE]** — `Enter` to close. **[GROUP]** — select target group with `↑`/`↓`, then `Enter` to add `#` tabs without changing tab order (choose **new group** to open the name/color panel; **`Enter`** confirms creation; **`Esc`** returns to the tab list; **`Tab`** switches between name and color). **[NEW WINDOW]** — `Enter` to execute; with **group marks**, the typed line includes **`--as-group <gid>…`** so groups stay intact in the new window. **[NEW TAB]** — `Enter` to execute. **[EDIT]** — see [Tab picker `:edit`](#tabs-tab-picker-edit) below. - **Action menu target list:** when selected tabs belong to Chrome tab groups, the panel shows a **group-title header** (with group color accent) above each contiguous group of targets, then the tab rows. - **[BOOKMARK]** (action menu **Bookmark** or `:bookmark` / `:bm`; **local tabs only**) — windows and groups expand to their member tabs. **One tab:** edit **title** (default: tab title), **URL** (default: tab URL), and **folder** (`↑`/`↓` while the folder list is focused); **`Tab`** / **`Shift+Tab`** cycle title → URL → folder; **`Enter`** adds. **Several tabs:** pick a folder with `↑`/`↓` (first row is **new folder** → type a name), **`Enter`**, then edit each tab's title (`↑`/`↓` or **`Tab`** between titles) and **`Enter`** to add (tabs without an http(s) URL are skipped). If a URL is already bookmarked, a confirm step appears: **`y`** / **`Enter`** add anyway, **`n`** skip duplicates, **`Esc`** back to edit. **`Esc`** steps back one phase (confirm → edit → folder/new folder → list). Titles are capped at 512 characters. - **Interactive `group new`** (prompt command, no tab ids): opens the tab picker in **group-new** variant — `Tab` marks tabs, **`Enter`** opens the same name/color panel as **[GROUP]** → new group; **`Enter`** again creates the group. - Use `/` for incremental search (`@` prefix for URL match). While filtering, **keyboard focus stays on the filter field**; the list highlights matches without taking typing focus. `Enter` focuses the highlighted tab while keeping the picker column open. **`Esc`** unwinds submodes in order: clear `#` → cancel `:` command mode → end `/` search → exit bulk submode → **return to the BMXt prompt** (column stays open). Close the column with **`tab -exit -list`**. <a id="tabs-tab-picker-edit"></a> ### Tab picker `:edit` (window & tab group) `:edit` runs only inside the tab picker opened by **`tab -list | browse`** / **`tab -list -url | browse`**. Press **`:`**, type **`edit`**, then **`Enter`** (no short alias; `Tab` cycles completions including `edit` when the current target is a window or tab group row). **Valid targets** - Exactly **one window row** or **one tab group row** (a real Chrome tab group). - **Tab rows** and **ungrouped tabs** (no group header) are not supported. - Either mark the row with **`#`** on the window/group header, or highlight that row with **no `#` marks** — on confirm, the highlighted window/group row is auto-marked if needed. If the selection is invalid (tabs only, multiple windows/groups, etc.), an **`error:`** line is appended to the BMXt log and edit mode does not open. **Window — custom display name** - Opens **[EDIT] window name**. The field is prefilled with the saved custom name, or the **active tab title** in that window when no custom name exists. - **`Enter`** saves to **`chrome.storage.local`** (per-window display names; empty string clears the custom name and the list falls back to Chrome’s default title). - **`Esc`** cancels and returns to the picker list. **Tab group — menu, then rename or Chrome actions** - Opens **[EDIT] operation menu** with **`↑`/`↓`** and **`Enter`**: - **Rename** — title field; **`Enter`** applies via **`chrome.tabGroups.update`**; **`Esc`** returns to the menu. - **Ungroup tabs** — runs immediately on **`Enter`** (`chrome.tabGroups.ungroup`). - **Delete tab group** — runs immediately on **`Enter`** (closes tabs in the group). - After a successful save or group action, marks are cleared, edit mode ends, and the picker rows refresh. <a id="tabs-tab-picker-impl"></a> ### Tab picker — implementation (keyboard & reducer) **Entry:** **`TabsPickerWrapper`** → **`useTabPickerController`** → **`TabsUrlListPicker`** (`PickerListShell` + **`TabPickerRowList`** + bulk/edit panels). **`TabPickerOverlay`** remains a deprecated alias of the same stack. - **Global capture**: **`usePlainPickerKeyboard`** registers **`useWindowKeydownCapture`** so **↑/↓** (tabs picker: arrows only, no **`j`/`k`**), `/`, `:`, `n`/`N`, and **Enter** work even when focus is not on the picker’s invisible IME `textarea` (e.g. after clicking the list). The same chain runs from the textarea’s **`onInputKeyDown`** when the event reaches it. - **Tabs-only keys**: **`useTabPickerPlainExtensions`** supplies **`PlainPickerKeyboardExtensions`** — custom vertical nav (bulk move/group, Shift range, Ctrl+Shift preview), layered **`Esc`**, **`Tab`** / `#` toggle, **`:`** bulk commands (`parsePickerCommand` in `use-tab-picker-plain-extensions.ts`; short aliases e.g. `m` → `move`; **`edit`** has no alias), and tab-specific **Enter** intents (including **new-group meta** name/color confirmation via window capture **`onNormalEnter`**). Wired from **`use-tab-picker-keyboard.ts`**. - **Reducer (TypeScript)**: Transitions go through **`runTabsPickerReduce`** in **`lib/features/bmxt-core/tabs-picker/reducer.ts`**. State and events use **camelCase** keys (e.g. `kind: "moveHi"`, `visibleLen`). - **Shift + arrows**: **Range selection** applies **`moveHi` then `selectRange`** in one synchronous chain (**`applyReducedStateSequence`** in the controller/keyboard path). Two separate React updates in the same handler would read a **stale `hi`** for the second call and could break range extension. - **Group-unit MOVE / NEW WINDOW**: When **`markedKind === "group"`**, destination nav uses **`move-dest-navigable.ts`** (header-only snap/step). Slot resolution is **`resolve-move-insert-slot.ts`** with **`headerDestMode`**. Typed lines from **`build-picker-command-line.ts`** carry **`--as-group`**. Host effects **`tabs_move`** / **`tabs_new_window`** accept **`group_ids`** and call **`moveTabGroupsAsUnits`** (`chrome.tabGroups.move` sequentially). Core parse: **`move_cmd.rs`** / **`new_window.rs`**. - **`:edit` UI**: target resolution and error messages live in **`lib/features/tabs/resolve-edit-entry.ts`**; panels and Chrome/storage effects in **`use-tab-picker-edit.ts`**, **`controller/edit-actions.ts`**, and **`extension-storage/window-display-names.ts`** (see [Tab picker `:edit`](#tabs-tab-picker-edit)). - **Prompt coexisting with picker**: While the tab picker is open, **`lib/features/bmxt-window/bmxt-terminal.tsx`** suppresses **↑/↓/j/k** on the main prompt so they do **not** drive **command history**; navigation is handled only by the picker. <a id="url-lines"></a> ### URL Lines (`http` / `https`) - `https://example.com` — Open in a new tab - `https://example.com .` — Open in current tab (active tab in front window) - `https://example.com -nw` — Open in a new window <a id="command-execution-architecture"></a> ## Command Execution Architecture (Current) **Authoritative lists** live in **`manifest/bmxt-codegen.json`** (`commands[]`, `effects[]`, **`uiActions[]`**). **`pnpm run codegen`** regenerates TS metadata (`registry/table.gen.ts`, `effect-types.ts`, `ui-action-types.ts`, `apply-dispatch.gen.ts`, completion helpers) **and** Rust tables (`crates/bmxt-core/src/generated/` including **`ui_action.rs`**). Built-in command **`run`** logic is in **`crates/bmxt-core/src/cmd/*.rs`**. Chrome effects are applied in **`lib/features/dispatch/handlers/effects/`**. Host IR contract: **`bmxt-host/2`** (generic UiAction primitives; see `lib/features/command-line/inter-command/`). Command-name semantic branches in the TS host are gated by **`pnpm run verify:host-blind`**. **Host / extension URL boundary** | Layer | Owns | |-------|------| | **Core (WASM + shared TS)** | `HostEffect` / plans — browser-agnostic | | **Host adapters** | `chrome.*` (Chromium) and Firefox (`browser.*` / `chrome.*`) via the same IR (**since 0.8.7**) | | **Extension page URLs** | **`lib/features/extension-url/`** — `chrome-extension:` **and** `moz-extension:`. Prefer **`chrome.runtime.getURL`** / **`browser.runtime.getURL`** at runtime; use **`extensionPageUrl` / `parseExtensionPageUrl`** in trust checks, E2E, and tests (do **not** hard-code `chrome-extension://…`). | | **Privileged SW messages** | **`isTrustedBmxtUiSender`** (`lib/features/extension-permissions/`) — allowlists `bmxt.html` on either extension protocol | **Runtime boundary** ``` prompt / RUN_CMD → ensureBmxtCore() (lazy WASM init; budget: bmxt_core_bg.wasm ≤ 400 KiB) → run(line, locale) / classify (Rust WASM) → { ty: lines | effects | ui | msgs } msgs → TS expand-msgs (+ optional promptPrefix → setContinuationPrompt) effects → applyHostEffects (SW) or RUN_CMD round-trip ui → applyUiAction (React host; opaque kinds only — no grammar re-parse) ``` <a id="prompt-semantics-sot"></a> ### Prompt semantics (Rust SoT) **Current status (see `_context/todo.md` §14):** Phase **A**–**D** are **done**. Fixed-token Tab/IME content comes from WASM **`complete(line, cursor)`**; compound eligibility from WASM **`compound_segment_eligibility`**. Host keeps live UI overlays (`dom -list` remaining options, page-active modes, IME filter UX). **`manifest/bmxt-candidate.json`** is a **design/validate catalog** (not the fixed-token runtime engine). | Owner | Responsibility | |-------|----------------| | **Rust (WASM)** | usage/error **keys**, Enter **continuation** (`msgs.promptPrefix`), incomplete `-setting` plans, **`complete`**, compound eligibility, help section key lists, any prompt-facing *choice* of what to show | | **TypeScript** | `expand-msgs` / React paint, opaque `applyUiAction`, Chrome `handlers/effects/*` | | **Host-only OK** | Live UI state (picker open/closed, current page-active / translate pair tokens via sentinels), Chrome list row data / outcome→msgs mapping, IME *filter* UX | **Enter continuation:** lone first token (e.g. `tab`) → Rust `msgs` + `promptPrefix: "tab "` → host `setContinuationPrompt`. Generated `continuationPromptAfterLoneFirstToken` remains for **IME helpers** only — not for Enter or compound eligibility. **Incomplete `-setting`:** e.g. `tab -setting` / `dom -setting` / `translate -setting` → msgs + prefix; complete apply → UiAction with fields (`tabs_setting` `{ mode }`, `dom_setting` `{ mode }`, `translate_setting` `{ pair }`). Map: **`_context/map_command.csv`**. Inter-command channels: **[Inter-command vocabulary](#inter-command-vocabulary)**. **Tab / IME fixed tokens:** WASM **`complete(line, cursor)`** (tiers 1–3 from codegen subcommands). `resolveImeTokenPicker` calls it when WASM is ready and applies host filter UX + live overlays. **Caret offsets (since 0.8.3):** the JS prompt uses **UTF-16** indices; Rust/`complete` uses **UTF-8** byte offsets — the host converts via **`lib/features/bmxt-core/utf16-utf8-offset.ts`** before calling WASM (avoids wiping CJK prompt text). **Develop Rust/WASM:** install stable Rust + `wasm32-unknown-unknown` + **wasm-pack** (`bash scripts/install-wasm-pack.sh`, pins **0.15.0**; see [wasm-pack](https://wasm-bindgen.github.io/wasm-pack/)). Then **`pnpm run build:wasm`** (also runs before `dev` / `build` / `package`). Unit tests: **`cargo test -p bmxt-core`**. Golden Effect contracts: **[`scripts/fixtures/dispatch/effects.json`](scripts/fixtures/dispatch/effects.json)** — notes in **[`scripts/fixtures/dispatch/README.md`](scripts/fixtures/dispatch/README.md)**. The tab picker’s **`runTabsPickerReduce`** (and related planners) are WASM-backed wrappers under **`lib/features/bmxt-core/tabs-picker/`** (see **Tab picker — implementation** under **`tab`**). **UI host:** Enter in the BMXt window calls WASM first (`useCommandDispatch` → `applyUiAction`). Context-only gates remain: external settings recovery and session name typing. Compound / pipe **planning** is WASM; the **execution loop** stays in TypeScript (`command-line/`). Effect-producing lines still use **`RUN_CMD`** → Service Worker → **`SessionPatch[]`**. Picker layout, focus, **`Esc` → prompt**, and **`-exit -list`** are under **[Picker UI (side columns)](#picker-ui)**; sessions under **[`session`](#session)**; settings under **[`setting`](#setting)**; nav under **[Nav mode](#nav-mode)**; translation under **[`translate`](#translate)**. <a id="inter-command-vocabulary"></a> ### Inter-command vocabulary (closed IR) Commands must not wire to each other by name. They communicate only through a **closed vocabulary**: | Channel | Schema / type | Role | |---------|----------------|------| | **DispatchBundle** | `lines` \| `effects` \| `ui` \| `msgs` | Rust → host plan after `run` / `classify` | | **ListResult** | `bmxt-list/1` | Plain `-list` / picker projection | | **BmxtRuleStream** | `bmxt-rule/1` | Pipe `|` stage handoff (from ListResult via adapter) | | **Exit status** | `0` / `1` / `2` / `127` | Compound `&&` / `||` / `;` sequencing | **Index (code):** `lib/features/command-line/inter-command/` — `LIST_KIND_TO_BMXT_RULE_KIND`, `preferredCommandAddPath()`, channel constants. **Rule:** Prefer **reusing** an existing Effect, UiAction, ListRecordKind, or pipe `acceptsKinds`. **Extend** a catalog only when reuse is impossible (see **[Command add procedure](#command-add-procedure)** and **`manifest/templates/`**). <a id="list-commands-registry"></a> ### `-list` output registry All **plain** `-list` subcommands share one pipeline (POSIX-style: one schema, one formatter, pluggable producers): ``` token line → matcher (registry) → ListResult (bmxt-list/1) → plain lines (+ summary footer) ↓ bmxtRule stream (bmxt-rule/1) → pipe consumer (e.g. close) ``` | Module | Role | |--------|------| | **`lib/features/bmxt-rule/`** | **bmxtRule** inter-command stream (`BmxtRuleStream`, validate, NDJSON serialize, `from-list-result` adapter) | | **`manifest/bmxt-rule.json`** | Kind catalog and field hints (extensible; single source for the stream spec) | | **`lib/features/bmxt-candidate/`** | **bmxtCandidate** prompt menu spec (catalog loader, validate, runtime provider registry) | | **`manifest/bmxt-candidate.json`** | Candidate menu profile, compound/pipe segment contexts, per-command zones, data sources | | **`lib/features/command-line/list-output/`** | `ListResult` / `ListRecord` types, `formatListPlainLines`, legacy TSV (`format-pipe.ts`), summary line | | **`lib/features/command-line/list-commands/`** | Matcher table (`LIST_COMMAND_MATCHERS`), `matchPlainListCommand`, `tryRunPlainListCommand`, `runPlainListForCommandId`; heavy plugins loaded via **dynamic import** | | **`lib/features/<feature>/*-list-command.ts`** | Per-command plugin: parse match, `fetchListResult`, `formatPlainLines` | | **`lib/features/<feature>/*-list-result.ts`** | Domain data → `ListRecord[]` | | **`lib/features/dispatch/handlers/effects/*-list.ts`** | Service Worker: thin `runPlainListForCommandId` wrapper | **Who runs plain `-list`:** | Command | Plain path | `<list> | browse` path | |---------|------------|-----------------| | `tab -list` | `RUN_CMD` → `tabs_list` | UI (`handle-tabs-list.ts`) | | `dom -list` | `RUN_CMD` → `dom_list` | UI (`handle-dom.ts` → picker column + `dom-list` job) | | `search -list` | `RUN_CMD` → `search_list` | UI (`handle-search.ts` → `search-list` job) | | `session -list` | UI → `tryRunPlainListCommand` | UI inline picker | | `setting -list` | UI → `tryRunPlainListCommand` | UI settings picker column | **Pipes:** `lib/features/command-line/pipe/run-pipe-chain.ts` fetches **`ListResult`**, converts it to **`bmxtRule`** (`bmxtRuleStreamFromListResult`), and passes **`BmxtRuleStream`** between segments. Consumers are registered in **`pipe/consumers/registry.ts`** (**`browse`**, **`open`**, **`jump`**, **`move`**, **`new-window`**, **`back`**, **`forward`**, **`reload`**, **`close`**, **`tab -send`**, **`bookmark -remove`**, **`bookmark -move`**, **`bookmark -send`**, **`history -delete`**; kind-compatibility checks — navigation/close/`move`/`new-window` act on **`page.open`**; **`browse`** also needs the producer **`ListResult`**; **`open`**/`**jump`**/tab bulk cover CUI parity). <a id="bmxt-rule"></a> ### bmxtRule (inter-command stream) **bmxtRule** is BMXt’s structured stream for **pipe** and future inter-command handoff. Schema id: **`bmxt-rule/1`**. Catalog: **`manifest/bmxt-rule.json`**. Each record uses an **extensible entry array** — attributes are `[key, value]` pairs so kinds can gain or drop fields without breaking older consumers: ```json { "schema": "bmxt-rule/1", "producer": [["command", "tab"], ["subcommand", "-list"]], "records": [ { "kind": "page.open", "entries": [ ["url", "https://example.com"], ["pageTitle", "Example"], ["tabId", 42], ["windowId", 1], ["active", true] ] } ] } ``` | Kind | Domain | Typical keys | |------|--------|----------------| | **`page.open`** | Open http(s) tab | `url`, `pageTitle`, `tabId`, `windowId`, `groupId`, `active`, `favicon` | | **`page.window`** / **`page.group`** | Tab tree containers | `windowId`, `focused`, `label`, … | | **`bookmark`** | Bookmark | `url`, `pageTitle`, `bookmarkId`, `parentId`, `dateAdded`, … | | **`bookmark.folder`** | Bookmark folder | `pageTitle`, `bookmarkId`, `parentId`, … | | **`history`** | History visit | `url`, `pageTitle`, `lastVisitTime`, `visitCount`, … | | **`markdown.file`** | Saved snapshot | `url`, `pageTitle`, `fileName`, `savedAt`, … | | **`search.hit`** | Search hit (may remap by source) | `url`, `pageTitle`, `source`, … | | **`dom.node`** / **`dom.notice`** | DOM list rows | tag/path/notice fields, … | | **`session.row`** | Terminal session | session id / display name, … | | **`setting.field`** | UI settings row | field id / value, … | Canonical catalog: **`manifest/bmxt-rule.json`** (and **`LIST_KIND_TO_BMXT_RULE_KIND`** in **`inter-command/vocabulary.ts`**). **Runtime:** pipe stages pass **`BmxtRuleStream` in memory** (same shape as JSON). NDJSON projection is for fixtures, export, and tests (`lib/features/bmxt-rule/fixtures/`). **Plain `-list`** still prints human-oriented lines (**`bmxt-list/1`**); only **multi-stage `|`** uses bmxtRule between commands. Legacy **`ListResult`** remains for picker and plain formatters; adapters live in **`lib/features/bmxt-rule/adapters/from-list-result.ts`** and per-feature helpers (e.g. **`tabs-bmxt-rule.ts`**). **Adding a new `-list` producer** — see the checklist under **[Command add procedure](#command-add-procedure)**. <a id="bmxt-candidate"></a> ### bmxtCandidate (prompt candidate menu) **bmxtCandidate** is BMXt’s specification for the **inline floating candidate menu** on the prompt (Tab / continuation / real-time filtering). Schema id: **`bmxt-candidate/1`**. Catalog: **`manifest/bmxt-candidate.json`**. | Layer | Role | |-------|------| | **Profile** | Tier names (`first` / `second` / `third` / `rest`), filter modes (`prefix` while closed, `contains` while open), open/close triggers, selection keys | | **Segment contexts** | When **`&&`**, **`||`**, **`;`**, or **`|`** starts a fresh token span, which candidate set to show | | **Command zones** | Per-command tier bindings (manifest static tokens + runtime providers) | | **Data sources** | Browser/UI facts commands may read for dynamic candidates | **Compound & pipe:** After a **list operator** (`&&`, `||`, `;`), the **active compound segment** resets to **first-tier** commands (same as a new line). After **`|`** inside a segment, **pipe stage 0** follows normal command zones (e.g. `tab -list`); **pipe stage 1+** shows **`registry.pipeConsumers`** (`browse` / `back` / `forward` / `reload` / `close` / `c` / `tab`). Tab on an empty tail after an operator opens the menu (`scanCompoundSegmentSpans` + `resolveActiveCommandSegment`). **Runtime data sources** (commands declare which they use in `commands[].zones`): | Source id | Domain | Typical use | |-----------|--------|-------------| | **`browser.openTabUrls`** | Open http(s) tabs | `tab -moveurl`, `search -list` pattern, `dom -list` pattern | | **`browser.openTabTitles`** | Tab titles | Labels for tab ids; search pattern hints | | **`browser.tabIds`** | Tab tree ids | `group new`, `snapshot -save` | | **`browser.windowLabels`** | Window rows | `snapshot -save` picker labels | | **`browser.tabGroupLabels`** | Group rows | `snapshot -save` picker labels | | **`browser.historyUrls`** / **`browser.historyTitles`** | History | URL/title completion on rest tails | | **`ui.commandHistory`** | Prompt history | `search -list` pattern, `session -new` name hints | | **`ui.sessionNames`** | Session display names | `session -switch`, `-new`, `-setting-name` | **Merge rule:** For the cursor tier, matching **`commands[].zones`** are filtered by `when`, each **`sources[]`** entry contributes values, duplicates are removed in order, then the profile **filter** is applied on every keystroke while the menu is open. **Runtime:** Fixed tokens (tiers 1–3) come from WASM **`complete`**. **`resolveImeTokenPicker`** applies host filter UX and live overlays (`dom -list` remaining options, page-active modes). **`manifest/bmxt-candidate.json`** + **`lib/features/bmxt-candidate/`** are a **design/validate catalog** and optional live-provider stubs — **not** the fixed-token runtime engine. **`BMXT_CANDIDATE_PROVIDERS`** may later supply Chrome/UI dynamic candidates only. **Adding fixed-token candidates for a command** — extend **`manifest/bmxt-codegen.json`** `subcommands` (codegen → WASM registry + `command-subcommands.gen.ts` fallback). For catalog documentation of zones/dataSources, update **`manifest/bmxt-candidate.json`** in sync. **Main directories:** - **`manifest/bmxt-codegen.json`** — single source for command registry + **`commands[].subcommands`** (second/third fixed tokens, tail kinds) + Effect schema + TS handler wiring (see **`pnpm run codegen`**) - **`crates/bmxt-core/`** — Rust `cmd/*.rs` + plans; **`lib/features/bmxt-core/`** — TS WASM host, registry metadata, tabs-picker wrappers - **`lib/features/bmxt-window/`** — main BMXt window UI (log, prompt, IME, picker launch) - **`lib/features/side-picker/`** — shared side-column picker UI (panel host, `PickerListShell`, `usePlainPickerKeyboard`, interaction kernel, wrappers) - **`lib/features/extension-storage/`** — `chrome.storage.local` keys and log/history caps - **`lib/features/page-dom/`** — injected DOM helpers and formatters (`dom -list`) - **`lib/features/snapshot/`** — Markdown snapshots (`snapshot -save`), vault/bundled storage, **`search -list --snapshot`** - **`lib/features/bmxt-rule/`** — **bmxtRule** stream (`bmxt-rule/1`, validate, serialize, adapters) - **`manifest/bmxt-rule.json`** — bmxtRule kind catalog (extensible entry arrays) - **`lib/features/bmxt-candidate/`** — **bmxtCandidate** prompt menu spec (catalog loader, validate, provider registry) - **`manifest/bmxt-candidate.json`** — candidate menu profile, segment contexts, command zones, data sources - **`lib/features/command-line/list-output/`** — canonical **`-list`** plain output (`ListResult`, `bmxt-list/1`) - **`lib/features/command-line/inter-command/`** — closed vocabulary index (`LIST_KIND_TO_BMXT_RULE_KIND`, add-path helper) - **`manifest/templates/`** — new-command checklist and reuse / list / pipe templates - **`lib/features/command-line/list-commands/`** — **`-list` producer registry** and unified plain runner (`tryRunPlainListCommand`) - **`lib/features/command-line/commands/`** — **`CommandEntry`** registry (`runCommand`), null-sink redirects, plain-list composition - **`lib/features/command-line/command-output.ts`** — stdout/stderr channels and session-log encoding (Rust mirror: **`bmxt_core::CommandOutput`**) - **`hosts/cli/src/command_io.rs`** — CLI aggregated sink + **`InteractionMode`** (Interactive REPL / NonInteractive `exec`) - **`hosts/cli/src/shell.rs`** / **`picker/`** / **`dom_nav_host.rs`** — CLI REPL candidate overlay · ratatui pickers · peer `dom`/`nav` RPC (todo §17–§20) - **`lib/features/sync/bus/apply-remote-dom-list.ts`** / **`apply-remote-nav-control.ts`** / **`apply-remote-probe-capabilities.ts`** — peer handlers for CLI remote `dom` / `nav` / probe - **`lib/features/command-line/pipe/`** — **`|`** pipe chains (`run-pipe-chain.ts`, **`pipe/consumers/`** registry · closed vocabulary) - **`lib/features/command-line/compound/`** — list operators **`&&` / `||` / `;`**, exit status (`EXIT_*`), sequential execution - **`lib/features/nav/`** — nav overlay (`nav -enter` / Alt toggle); see **[Nav mode](#nav-mode)** - **`lib/features/translate/`** — translation assist (`translate -on` / `-off` / `-setting`, nav typing commit); see **[`translate`](#translate)** - **`lib/features/setting/`** — UI locale and appearance (`setting -list`, export/import zip, external bundle, `bmxt_ui_settings_v1`, `bmxt_ui_settings_storage_v1`); see **[`setting`](#setting)** - **`lib/features/session/`** — terminal sessions (`session -list` / `-switch` inline pickers, session bar); see **[`session`](#session)** - **`lib/features/job/`** — per-scope **`JobRunner`**, cancel handles, optional in-memory audit log; see **[Job execution](#job-execution)** - **`entrypoints/bmxt-nav-overlay.content/`** — WXT content script on https pages for nav overlay - **`lib/features/dispatch/`** — **`effect-types.ts`** / **`apply-dispatch.gen.ts`** (generated) + hand-written **`handlers/effects/*`** - **`lib/features/builtin-commands/`** — generated Tab / IME helpers (`completion-fallback.ts`, `command-subcommands.gen.ts`); Enter continuation SoT is Rust `promptPrefix` - **`entrypoints/background/index.ts`** — `RUN_CMD` wrapped in a **`run-cmd`** job (`persist: false`); `runDispatch` → lines / `applyHostEffects` → **`SessionPatch[]`** returned to the UI (`exit` → `exit_pane` patches; last session → `closeWindow` + legacy storage cleanup) <a id="job-execution"></a> ### Job execution (background work) Long-running or cancelable work runs through **`lib/features/job/`** — a **`JobRunner` per scope id** (each terminal session id in the BMXt UI, plus reserved scopes **`__background__`** for Service Worker dispatch and **`__terminal__`** for global tab-picker refresh). | Job kind | Typical scope | Supersede policy | Where started | |----------|---------------|------------------|---------------| | `search-list` | session id | cancel-previous | `bmxt-shell.tsx` (`search -list … | browse`) | | `dom-list` | session id | cancel-previous | `bmxt-shell.tsx` (`dom -list … | browse`) | | `run-cmd` | `__background__` | parallel | `entrypoints/background/index.ts` (most `RUN_CMD` lines) | | `tab-picker-refresh` | `__terminal__` | coalesce-latest | tab-picker follow-tab refresh | **Cancel:** **`Ctrl+C`** on the prompt, **`* -exit -list`** while a picker job is loading, or starting a new job of the same kind in the same scope (for **cancel-previous** kinds). **Optional audit log:** In the BMXt UI tab only, completed job records may be kept in an in-memory trail (`job-audit-memory`, pruned per scope). The Service Worker never loads this module — background **`run-cmd`** jobs use **`persist: false`**. **Search loading progress:** Progress lines for **`search -list`** are batched with **`requestAnimationFrame`** in the active shell (`use-batched-search-loading-progress.ts`) so heavy scans do not force every session pane to re-render; merged into the search picker when results arrive. **Implementation:** **`job-types.ts`**, **`job-runner.ts`**, **`job-handle.ts`**, **`use-session-job-runner.ts`**, **`dispatch-context-from-job.ts`**, optional audit under **`lib/features/job/db/job-audit-memory.ts`**. <a id="add-new-built-in-command"></a> ### Add a New Built-in Command Start with **[`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md)** (vocabulary-first). Template index: **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)**. For the full checklist (scaffold, reuse vs extend, verification), see **[Command add procedure](#command-add-procedure)** below. 1. Prefer **reusing** existing Effect / UiAction / list kinds (`manifest/templates/`). 2. Edit **`manifest/bmxt-codegen.json`** and/or run **`pnpm run new:command -- <module> <name> [aliases...]`**. 3. Implement **`run`** in **`crates/bmxt-core/src/cmd/<module>.rs`**. Extend TS executors **only** when the closed vocabulary cannot express the command. 4. Run **`pnpm run codegen`**, **`pnpm run build:wasm`**, then **`verify:manifest`** / **`check:generated`**. <a id="command-add-procedure"></a> ### Command add procedure - **Vocabulary first:** Follow **[Inter-command vocabulary](#inter-command-vocabulary)**. Start from **[`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md)** (decision tree + checklists; index **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)**). Examples: **`command-reuse-effects.example.rs`**, **`command-reuse-ui-action.example.rs`**, **`command-list-producer.steps.md`**, **`pipe-consumer.steps.md`**. - **Command-line token model:** When adding or changing commands, follow **[Command-line token model (first / second commands)](#command-line-token-model)** and **`.cursorrules`** (first → second ordering, **no** short aliases for first/second tokens). When a second token is required, **Enter** on the lone first token must return Rust **`msgs` + `promptPrefix`** (`require_second_token` / `msgs_with_prompt`) — do **not** add TS Enter continuation. Second-token **Tab** lists come from generated **`command-subcommands.gen.ts`** (manifest **`subcommands`**). See **[Prompt semantics (Rust SoT)](#prompt-semantics-sot)**. - **Single source of truth:** **`manifest/bmxt-codegen.json`**. Do **not** edit generated files by hand: **`registry/table.gen.ts`**, **`effect-types.ts`**, **`ui-action-types.ts`**, **`apply-dispatch.gen.ts`**, completion helpers, **`crates/bmxt-core/src/generated/*.rs`**. Regenerate with **`pnpm run codegen`**. - **Recommended:** `pnpm run new:command -- <module> <canonical_name> [aliases...]` — scaffolds **`crates/bmxt-core/src/cmd/<module>.rs`**, updates **`commands[]`**, runs **codegen**. Then implement **`run`** using a template under **`manifest/templates/`**. - **Manual path:** Add **`commands[]`** row + **`crates/bmxt-core/src/cmd/<module>.rs`** + wire **`cmd/mod.rs`**, then **`pnpm run codegen`** and **`pnpm run build:wasm`**. - **Reuse path (prefer):** Return only existing **`HostEffect`** / **`UiAction`** / list kinds — **no new TS executor**. Update i18n + README + **`_context/map_command.csv`**. - **Extend path (only if needed):** - **Effect:** `effects[]` → codegen → **`handlers/effects/<tsHandlerFile>.ts`** - **UiAction:** `uiActions[]` → codegen → **`crates/bmxt-core/src/generated/ui_action.rs`** / **`ui-action-types.ts`** + hand-written **`apply-ui-action.ts`** (`ir.rs` only re-exports generated `UiAction`; do **not** edit the enum there) - **List / pipe kinds:** `list-output/types.ts` + **`inter-command/vocabulary.ts`** + **`manifest/bmxt-rule.json`** + adapter / consumer registry - **Checks:** **`verify:manifest`**, **`verify:host-blind`**, **`check:generated`**, **`check:cli-command-io`** (todo §15.4), **`cargo test -p bmxt-core`**, **`build:wasm`**, **`tsc`**, **`pnpm test`**, **`pnpm run build`**. - **BMXt POSIX Profile (todo §15):** Use **`EXIT_*`** only; route success → stdout / diagnostics → stderr; keep browse / ask Interactive-only; CLI results via **`CommandIo`**; pipes = closed consumers + **`bmxtRule`**. See the **BMXt POSIX Profile** paragraph under Built-in Commands and [`new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md). - **Compound / pipe:** Planning is WASM; the host loop is **`command-line/`** (`runDispatch` per segment → UiAction apply or background `RUN_CMD`). Pipe handoff is **bmxtRule** only (not command-name coupling). #### Manifest `commands[].subcommands` (second / third tokens) Every command row **must** include **`subcommands`**: use **`[]`** when the command has no fixed second-token family (e.g. `clear`). Non-empty arrays declare **canonical second tokens** (`head`, normally starting with `-`; literal **`help`** is allowed for per-command manuals), optional **fixed third tokens** after that head (`trailingTokens`, e.g. `-u` after `tab -list`), and an optional **`tail`** hint for tooling: **`none`** | **`rest_http_url`** | **`rest`** (dispatch semantics live in **`crates/bmxt-core/src/cmd/<module>.rs`**; keep literals in sync—**`pnpm run verify:manifest`** checks each `head` appears in the Rust cmd file, except **`help`** which is handled in **`help_cmd.rs`**). **`pnpm run codegen`** emits **`lib/features/builtin-commands/command-subcommands.gen.ts`** (Tab completion + IME/eligibility helpers such as **`continuationPromptAfterLoneFirstToken`** / **`isSecondToken`**). **Enter** continuation itself is owned by Rust (`promptPrefix`). Copy from **`manifest/templates/command-with-subcommands.example.json`** when adding a new first+second family. ##### How to add second/third tokens (checklist) 1. Edit **`manifest/bmxt-codegen.json`**: set **`subcommands`** to **`[]`** or a list of **`{ head, trailingTokens?, tail? }`** (see **`manifest/templates/command-with-subcommands.example.json`**). 2. Run **`pnpm run codegen`** (regenerates **`command-subcommands.gen.ts`** and **`table.gen.ts`**). 3. In **`crates/bmxt-core/src/cmd/<module>.rs`**, implement **`run`** and reference **each `head` as the same string literal** as in the manifest (required for **`pnpm run verify:manifest`**). 4. If the prompt should Tab-complete **third** fixed tokens after a head, use generated **`listThirdTokenCandidates`** (and add a completion zone in the shell if needed). 5. Run **`pnpm run verify:manifest`**, **`pnpm run check:generated`**, **`pnpm exec tsc --noEmit`**, then **`pnpm run build`** as needed. **Hand-written browser logic (`handlers/effects/*.ts`) vs codegen:** Those files are **not** regenerated. After you change **`effects[]`** in the manifest and run codegen, **keep the corresponding handler** (`tsHandlerFile` / `tsHandlerExport`) aligned with the generated **`HostEffect`** types and **`apply-dispatch.gen.ts`** imports. For **`-list`** effects, call **`runPlainListForCommandId`** from **`lib/features/command-line/list-commands/`** instead of duplicating format logic. #### Adding a plain `-list` producer (registry plugin) Follow **`manifest/templates/command-list-producer.steps.md`**. Summary: 1. In **`lib/features/<feature>/`**, add **`*-list-result.ts`** (domain → `ListResult`) and **`*-list-command.ts`** (`ListCommandEntry`: `fetchListResult` + `formatPlainLines`). Reuse **`formatListPlainLines`** / **`appendListPlainSummary`** from **`list-output/`**. Prefer **existing** `ListRecordKind` values. 2. In **`lib/features/command-line/list-commands/registry.ts`**, append a **matcher** row to **`LIST_COMMAND_MATCHERS`** and a **`loadListCommandEntry`** case. 3. If the command needs Chrome APIs from the Service Worker, add manifest **`effects[]`** entry → **codegen** → **`handlers/effects/*.ts`** calling **`runPlainListForCommandId`**. If data lives only in the UI (like **`session`** / **`setting`**), use **`runtime: "ui"`** and **`tryRunPlainListCommand`**. 4. New kinds: extend **`ListRecordKind`**, **`inter-command/vocabulary.ts`**, **`manifest/bmxt-rule.json`**, and **`from-list-result.ts`**. 5. Update **`manifest/bmxt-codegen.json`**, **`crates/bmxt-core/src/cmd/<module>.rs`**, **`<list> | browse`** routing if needed, i18n, this README, and **`_context/map_command.csv`**. **Architecture reminder:** Prompt-facing meaning (usage keys, `promptPrefix`, incomplete `-setting` plans) is **Rust/WASM**; TypeScript is the paint host + Chrome executor. See **[Prompt semantics (Rust SoT)](#prompt-semantics-sot)**. <a id="prompt-key-bindings"></a> ## Prompt Key Bindings Applies when the prompt `textarea` is focused. - **Left / Right / Home / End** — Move cursor in line - **Tab** — Command completion (cycle candidates; IME-style token picker for fixed tokens; after **Enter** leaves a lone first command such as `tab `, a **second-command candidate list** may appear — ↑/↓, Tab, Enter, Esc) - **Up / Down** — Command history - **Ctrl+R** — Reverse incremental search - **Enter** — Execute command (when **nav** overlay is **ON** and the nav detail bar has focus, **Enter** sends a **click** to the page instead — see **[Nav mode](#nav-mode)**) - **Shift+Enter** — Insert newline - **Esc** — Cancel reverse search **While nav is armed** (`nav -enter`): - **Alt** — Toggle nav overlay **ON** / **OFF** on the target browser tab (from the **nav detail bar**, or from the prompt while armed). Short **Alt** is ignored during **typing mode**; **Alt hold** (~500ms) commits typed text instead. While **ON**, focus stays on the **nav detail bar**. - **↑ / ↓ / ← / →** — When overlay is **ON**, jump between interactive targets (spatial snap). **Shift+arrows** free-move by **12px**; releasing **Shift** re-scans at the pointer. When a **tabs / search / dom** picker column has focus (**Ctrl+← / Ctrl+→**), arrows operate the picker instead. - **/** — When overlay is **ON**, start incremental attribute jump (type to filter · **↑ / ↓** cycle · **Enter** activate · **Esc** leave jump). - **Enter** — When overlay is **ON**, activate the resolved target, or enter **typing mode** on editable fields. - **Ctrl** (tap, overlay **ON**) — Open the nav **context menu** at the cursor (**↑ / ↓** choose, **Enter** run, **← / →** history, **Ctrl** / **Esc** close). See **[Nav mode](#nav-mode)**. - **Esc hold** (~500ms, **typing mode**) — Cancel typing and restore the previous field value. During IME composition, composition events are prioritized to avoid conflicts with shortcuts until commit. <a id="development"></a> ## Development After installing dependencies, start the development build (see **Development startup** below for the full flow). ```bash pnpm install --frozen-lockfile # preferred when pnpm-lock.yaml is present pnpm run dev ``` `pnpm run dev` runs **`wxt`**: a watch build that updates **`.output/chrome-mv3-dev`**. Keep the terminal process running while you work. If you change **`shared/manifest/bmxt-codegen.json`**, run **`pnpm run codegen`** before reloading the extension so generated TypeScript stays in sync. <a id="development-startup"></a> ### Development startup (step-by-step) 1. **Install JS dependencies:** **`corepack enable`** (first time), then **`pnpm install --frozen-lockfile`** when **`pnpm-lock.yaml`** is present (preferred). Use **`pnpm install`** only when you are updating dependencies and will refresh the lockfile. **postinstall** runs **`wxt prepare -c hosts/chrome/wxt.config.ts`** (generates **`shared/.wxt/types/`**). See **[pnpm dependencies and security](#pnpm-dependencies)**. 2. **Rust toolchain (command core):** `rustup target add wasm32-unknown-unknown` and **`bash scripts/install-wasm-pack.sh`** (pinned **wasm-pack 0.15.0**; CI uses the same). Optional local check: **`cargo test -p bmxt-core`**. 3. **Codegen (when needed):** After editing **`shared/manifest/bmxt-codegen.json`**, run **`pnpm run codegen`** so TS + Rust generated files match the manifest. 4. **Start dev:** From the repo root, run **`pnpm run dev`** (runs **`build:wasm`** then background-services then WXT). Leave this process running; it rebuilds the extension on file changes. 5. **Load in Chrome:** Open `chrome://extensions`, enable **Developer mode**, **Load unpacked**, and select **`.output/chrome-mv3-dev`** (created by WXT dev). 6. **Open BMXt:** Click the extension toolbar icon to open the BMXt window. 7. **After edits:** When WXT finishes rebuilding, use **Reload** on the extension card (or reload the BMXt tab) so the Service Worker and UI pick up changes. <a id="testing"></a> ### Testing **JS/TS** tests live under **`tests/`** (not under `lib/` or the repo root). Layout details: **[`tests/README.md`](tests/README.md)**. **E2E browser lifecycle** (launch unpacked Chrome/Firefox extensions, resolve `extensionOrigin`, open extension pages) uses **[webxdriver](https://github.com/UNRsports/webxdriver)** (`devDependency`, pinned GitHub commit). BMXt-specific helpers (prompt / tutorial / `.bmxt-*` asserts, **`BMXT_E2E_BROWSER`**, `.output/{chrome,firefox}-mv3` paths) stay in **`tests/e2e/harness.ts`**. **Related docs (scattered READMEs):** | Doc | Topic | |-----|--------| | **[`tests/README.md`](tests/README.md)** | Unit / property / E2E layout and how to add tests | | **[`hosts/README.md`](hosts/README.md)** | Chrome / Firefox host packages and build/package scripts | | **[`hosts/firefox/AMO_SOURCE.md`](hosts/firefox/AMO_SOURCE.md)** | Firefox AMO source kit | | **[`scripts/fixtures/dispatch/README.md`](scripts/fixtures/dispatch/README.md)** | Golden Effect contracts (`effects.json`) for WASM `run` | | **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)** | Command-add templates (closed vocabulary) | | **[`shared/public/assets/wasm/bmxt-gaze/README.md`](shared/public/assets/wasm/bmxt-gaze/README.md)** | Optional gaze WASM module (build notes) | <a id="testing-how-to-run"></a> #### How to run | What | Command | Notes | |------|---------|--------| | **Unit + property (JS/TS)** | **`pnpm test`** | No browser. Fast. | | **Rust / WASM** | **`cargo test -p bmxt-core`** | Not included in `pnpm test`. | | **E2E (Chrome)** | **`pnpm run build:chrome`** → **`pnpm run test:e2e:chrome`** | Headless WebDriver + Chrome for Testing via **webxdriver**. Loads **`.output/chrome-mv3`**. | | **E2E (Firefox)** | **`pnpm run build:firefox`** → **`pnpm run test:e2e:firefox`** | Headless WebDriver + geckodriver via **webxdriver**. Loads **`.output/firefox-mv3`**. | | **E2E (both)** | **`pnpm run test:e2e:all`** | Chrome then Firefox (builds required separately or via **`verify`**). | | **Full CI gate** | **`pnpm run verify`** | Manifest / codegen / Rust / WASM / `tsc` / unit / **build** / E2E. | One-liner after a production build already exists: **Full gate (match CI):** **`pnpm run verify`** — manifest / no-fetch / generated → **`cargo test -p bmxt-core`** → **`build:wasm`** → **`tsc --noEmit`** → **`pnpm test`** → **`build:chrome`** + WebDriver E2E → **`build:firefox`** + WebDriver E2E. | Layer | Command | Location | |-------|---------|----------| | **TS unit** | **`pnpm test`** | **`tests/unit/`** — Node.js `node:test` / `node:assert`. Globs: `tests/unit/**/*.test.ts`, `tests/unit/**/*.test.mjs`. | | **Property** | (included in **`pnpm test`**) | **`tests/property/`** — **fast-check** + `node:test` (incl. UTF-16/UTF-8 caret conversion and **TS↔WASM** host entrypoints). | | **E2E** | **`pnpm run test:e2e:chrome`** / **`test:e2e:firefox`** / **`test:e2e:all`** | Headless **WebDriver** under **`tests/e2e/`** (**webxdriver** lifecycle + BMXt `harness.ts`). See **[`tests/README.md`](tests/README.md)**. | | **Rust / WASM** | **`cargo test -p bmxt-core`** | **`shared/crates/bmxt-core/`** only (Cargo convention; **not** under **`tests/`**). | **Adding a TS unit test:** **`tests/unit/features/<same-path-as-lib>/<name>.test.ts`**, import from **`lib/features/...`** with a **`.ts`** extension. Do **not** colocate `*.test.ts` under `lib/`. <a id="testing-e2e-coverage"></a> #### What E2E covers Shared specs under **`tests/e2e/`** run on both Chrome and Firefox: command smoke (`commands-smoke.test.ts` + `command-matrix.ts`), prompt integrity, and CJK caret behavior. Lifecycle details and env vars: **[`tests/README.md`](tests/README.md)**. Effect-level golden contracts (no browser): **[`scripts/fixtures/dispatch/`](scripts/fixtures/dispatch/)** — see **[`scripts/fixtures/dispatch/README.md`](scripts/fixtures/dispatch/README.md)**. <a id="project-layout"></a> ### Project layout (WXT) | Path | Role | |------|------| | **`shared/entrypoints/background/`** | Service Worker (`index.ts`) — window launch, `runDispatch`, effects | | **`shared/entrypoints/bmxt/`** | Extension UI page → built as **`bmxt.html`** (`main.tsx` + `index.html`) | | **`shared/entrypoints/bmxt-nav-overlay.content/`** | Nav content script on https pages | | **`shared/public/`** | Static assets: **`_locales/`**, **`icon.png`**, **`background-services.js`**, **`bmxt_core_bg.wasm`** (from **`build:wasm`**) | | **`shared/crates/bmxt-core/`** | Rust/WASM command core (parse, registry, cmd `run`, compound/pipe plan, tabs-picker plan) | | **`shared/lib/wasm/bmxt-core/`** | wasm-pack glue (`bmxt_core.js` + `.wasm`) | | **`hosts/chrome/`**, **`hosts/firefox/`**, **`hosts/cli/`** | Per-browser WXT configs (+ Firefox AMO kit) and the terminal Family peer — see **[`hosts/README.md`](hosts/README.md)** · **[Terminal CLI peer](#terminal-cli-peer)** | | **`shared/lib/features/`** | Feature modules (see table below) | | **`tests/`** | JS/TS tests only — unit, property (fast-check), headless WebDriver E2E (see **[Testing](#testing)** and **[`tests/README.md`](tests/README.md)**). Rust stays under **`shared/crates/bmxt-core/`**. | | **`shared/manifest/bmxt-codegen.json`** | Command registry + Effect schema (single source; run **`pnpm run codegen`**). Templates: **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)** | | **`scripts/fixtures/dispatch/`** | Golden Effect contracts for WASM `run` — **[`README`](scripts/fixtures/dispatch/README.md)** | | **`pnpm-lock.yaml`** | Lockfile — install with **`pnpm install --frozen-lockfile`** | | **`docs/`** | GitHub Pages — privacy policy (`index.html`), welcome page (`welcome.html`, `welcome-content.json`, `welcome/` images) | | **`.output/`** | Build output (gitignored): **`chrome-mv3`**, **`firefox-mv3`**, zips from **`package`** / **`package:chrome`** / **`package:firefox`** (`bmxt-<ver>-chrome.zip`, `bmxt-<ver>-firefox.zip`) | **Build scripts:** **`pnpm run build`** builds **both** Chrome and Firefox (wasm once). Prefer **`build:chrome`** / **`build:firefox`** for a single target. **`package`** zips **both**; **`package:chrome`** / **`package:firefox`** zip one host. **`verify`** uses **`build:chrome`** then Chromium e2e. **`postinstall`** runs **`wxt prepare -c hosts/chrome/wxt.config.ts`**. WASM binary budget: **≤ 400 KiB** (`scripts/build-wasm.mjs` / `benchmark:launch`). <a id="main-sources"></a> ### Main Sources - `entrypoints/bmxt/main.tsx` — Extension page entry (thin wrapper around `BmxtTerminal`) - `bmxt-ui.css` — Window styles at repo root (imported from `entrypoints/bmxt/main.tsx`) - `lib/features/bmxt-window/` — Main BMXt window UI (`bmxt-terminal.tsx`, session log/history hooks, etc.) - `lib/features/side-picker/` — Shared side-column picker UI (panels, keyboard kernel, wrappers, **`tree/`** for bookmark/history) - `lib/features/bookmark/` — Bookmark list / tree picker / send (`bookmark-picker-wrapper.tsx`, fold state, `submitConstructedLine` actions) - `lib/features/history/` — History list / tree picker (`history-picker-wrapper.tsx`, month→day→visit fold) - `lib/features/release-notes/release-notes.json` — In-app upgrade banner text (keys must match `package.json` `version`) - `lib/features/welcome/` — Welcome tab URL builder and update hook (opens hosted **`docs/welcome.html`**; content lives under **`docs/`** only) - `lib/features/support/` — In-window support links (official site / NotebookLM manual; friendly labels; open in a normal browser tab) - `lib/features/extension-storage/` — Storage keys and caps (used by Service Worker and UI) - `lib/features/tabs/` — Tab picker (`tabs-picker-wrapper.tsx`, `tabs-url-list-picker.tsx`, `use-tab-picker-controller.ts`, `picker-rows.ts`, keyboard extensions, etc.) - `lib/features/prompt-effects/` — Optional typing FX (`prompt-fire`); Firefox **menu-lite** when the candidate menu is open - `crates/bmxt-core/` — Rust command core (`src/cmd/*.rs`, compound/pipe, tabs_picker); WASM exports - `lib/features/bmxt-core/` — TS host: `wasm-host.ts`, `dispatch.ts` (WASM call + msgs expand), registry metadata, tabs-picker wrappers - `lib/features/dispatch/` — Generated Effect/UiAction types + hand-written **`handlers/effects/`** - `lib/features/bmxt-window/shell/apply-ui-action.ts` — Opaque `UiActionIR` → React/UI effects - `lib/features/builtin-commands/` — Generated Tab / IME helpers (`completion-fallback.ts`, `command-subcommands.gen.ts`); Enter continuation SoT is Rust `promptPrefix` - `lib/features/page-dom/` — DOM injection helpers (`dom -list`) - `lib/features/search/` — Search mode (`search -list`), cross-scope **`--all`**, in-memory metadata cache for **`--history`** / **`--bookmark`** (`search-cache-store`; rows carry `bookmarkId` / visit metadata) - `lib/features/sync/bus/apply-remote-bookmarks-ops.ts` — Peer **`bookmarks_ops`** handler - `lib/features/backup/` — Browser bookmark/history ZIP backup & restore (`bmxt-browser-backup/`) - `lib/features/snapshot/` — Markdown snapshots (`snapshot -save`), vault/bundled storage, **`search -list --snapshot`** - `lib/features/bmxt-rule/` — **bmxtRule** stream (`bmxt-rule/1`, validate, serialize, adapters) - `manifest/bmxt-rule.json` — bmxtRule kind catalog - `lib/features/command-line/list-output/` — `-list` schema and plain formatters (`ListResult`, `bmxt-list/1`) - `lib/features/command-line/inter-command/` — closed inter-command vocabulary index - `manifest/templates/` — new-command templates (checklist, reuse examples) - `lib/features/command-line/list-commands/` — `-list` producer registry (`*-list-command.ts` plugins, `tryRunPlainListCommand`) - `lib/features/command-line/commands/` — `CommandEntry` registry (`runCommand`), null-sink redirects - `lib/features/command-line/command-output.ts` — stdout/stderr channels and session-log encoding (Rust: `bmxt_core::CommandOutput`) - `hosts/cli/src/command_io.rs` — CLI `CommandIo` + `InteractionMode` (Interactive / NonInteractive `exec`) - `hosts/cli/src/shell.rs` — CLI REPL main-screen line editor + candidate overlay (todo §20) - `hosts/cli/src/picker/` — CLI ratatui pickers (tab / URL / peer / oneshot; mirrors extension `features/picker/` independently) - `hosts/cli/src/dom_nav_host.rs` — CLI peer `dom_list` / `nav_control` / `probe_capabilities` host - `lib/features/sync/bus/apply-remote-dom-list.ts` / `apply-remote-nav-control.ts` / `apply-remote-probe-capabilities.ts` — peer RPC handlers for CLI §17 - `lib/features/command-line/pipe/` — pipe (`|`) chains and closed consumer registry - `lib/features/command-line/compound/` — list operators (`&&` / `||` / `;`), exit status (`EXIT_*`), sequential execution - `lib/features/job/` — Per-scope **`JobRunner`**, cancel handles, optional in-memory audit log (`job-audit-memory`) - `lib/features/nav/` — Nav overlay feature package - `lib/features/translate/` — Translation assist (`translate -on` / `-off` / `-setting`, `translation-pair.ts`) - `lib/features/setting/` — UI settings picker (`setting -list`, `appearance.ts`, `settings-export.ts`, `settings-external-storage.ts`, `settings-bundle-layout.ts`) - `lib/features/session/` — Terminal sessions (`session-input.ts`, inline pickers, `session-bar.tsx`) - `scripts/build-background-services.mjs` — Bundles Service Worker helpers into **`public/background-services.js`** In development mode, edits trigger rebuilds. Reload the extension to verify updates. <a id="version-upgrade-banner"></a> ### Version upgrade banner & release notes **Welcome page on extension update** (normal browser tab, separate from the in-window block) When Chrome reports **`install`** or **`update`**, **`entrypoints/background/index.ts`** calls **`openWelcomePageOnUpdateIfNeeded`**, which opens **`https://unrsports.github.io/bmxt/welcome.html`** **once per version** via **`openWelcomePageTab`** (tracked by **`LAST_SEEN_WELCOME_VERSION_KEY`** in `lib/features/extension-storage/keys.ts`). The page loads **`docs/welcome-content.json`** from GitHub Pages. **Manual / preview URL:** `https://unrsports.github.io/bmxt/welcome.html?lang=ja&v=0.96.1` shows entries through that version. Query **`lang`**: `ja` or `en`. Query **`v`**: semver cap (invalid values are ignored). Omit **`v`** to show the full history. **`aboutbmxt`** and auto-open on update pass **`lang`** from UI settings and **`v`** from the installed manifest version. **In-window welcome hint** (empty session log, and again with the upgrade block) When the active session log is **empty** (typical fresh BMXt open), the terminal shows a **welcome hint** above the prompt: welcome copy, the `help` hint, **support links**, and the https injection notice (`shell.reloadHint` / i18n). The same hint also appears above the **version upgrade** block when that block is shown. **Support links** (**since 0.9.1**; friendly labels only; raw URLs are **not** shown in the UI). Click opens a **normal browser tab** (not the BMXt popup window) via allowlisted URLs in **`lib/features/support/`**: | Label (JA) | Destination | |------------|-------------| | **👉️公式サイト** | `https://bmxt.diozy.net/` | | **👉️マニュアルサポート(notebookLM)** | NotebookLM notebook (`https://notebook.google.com/notebook/…`) | EN labels: **👉️ Official site** / **👉️ Manual support (NotebookLM)**. Distinct from **`aboutbmxt`** (GitHub Pages welcome history). **In-window upgrade block** (first BMXt open after upgrade) When the extension **`version`** in **`package.json`** (and the built manifest) **does not match** the value stored in **`chrome.storage.local`** under **`bmxt_last_seen_extension_version`** (**`LAST_SEEN_EXTENSION_VERSION_KEY`**), the BMXt window shows **once**, on the **first open after that upgrade**: 1. The usual **welcome** hint (including support links). 2. A **version upgrade** block with the version number and bilingual release notes from **`release-notes.json`**. Existing **session log** lines are still rendered **below** that block. **Maintainer workflow** 1. Bump **`package.json`** → **`version`**. 2. Add a matching entry to **`lib/features/release-notes/release-notes.json`**. Keys must equal the version string exactly. Each entry has **`ja`** and **`en`** string arrays (used by the in-window upgrade banner). 3. Prepend a new object to **`docs/welcome-content.json`** (`version`, **`ja`** / **`en`** bullet arrays; optional image fields). Place image files under **`docs/welcome/`**. Publish **`docs/`** to GitHub Pages so the live welcome page matches the repo. Users open the page anytime with **`aboutbmxt`** or after install/update. 4. Build and ship. If no **`release-notes.json`** entry exists for the current version, placeholder copy is shown that points maintainers at that file. **Implementation:** welcome tab — **`open-welcome-page-tab.ts`**, **`open-welcome-on-update.ts`**, **`welcome-external-url.ts`**. **`aboutbmxt`** — **`cmd/aboutbmxt.ts`**, **`handlers/effects/open-welcome-page.ts`** (same **`openWelcomePageTab`**). In-window welcome / support links — **`lib/features/support/`** (`ShellSupportLinks`, allowlisted URLs → **`createTabInNormalBrowserWindow`**), i18n **`shell.support.*`**. In-window banner — **`use-version-upgrade-banner.ts`**; **`bmxt-terminal.tsx`** waits until the check finishes before rendering the shell (avoids a flash of log-only UI); **`bmxt-shell.tsx`** renders the blocks; styles in **`bmxt-ui.css`** (`.bmxt-hint a`, `.bmxt-version-upgrade*`). <a id="production-build"></a> ## Production Build ```bash pnpm run build # both → .output/chrome-mv3 + .output/firefox-mv3 pnpm run build:chrome # Chrome only → .output/chrome-mv3 pnpm run build:firefox # Firefox only → .output/firefox-mv3 ``` Store zips: **`pnpm run package`** (Chrome + Firefox) / **`pnpm run package:chrome`** / **`pnpm run package:firefox`** → `.output/bmxt-<version>-{chrome|firefox}.zip`. ### Firefox — load unpacked (temporary) WXT’s Firefox MV3 **dev** runner is limited; preferred local loop: 1. **`pnpm run build:firefox`** 2. Firefox → **`about:debugging#/runtime/this-firefox`** → **Load Temporary Add-on…** 3. Select **`.output/firefox-mv3/manifest.json`** 4. Open BMXt from the toolbar, or **Alt+Shift+C** while Firefox is focused (manifest uses Gecko key order; Chrome keeps **Shift+Alt+C**. Firefox has no OS-wide `commands.*.global` — check **about:addons** → gear → **Manage Extension Shortcuts** if it still does not fire) AMO reviewers: attach **`pnpm run package:firefox`** → **`.output/bmxt-<version>-firefox-sources.tar.gz`** and follow **[`hosts/firefox/AMO_SOURCE.md`](hosts/firefox/AMO_SOURCE.md)** (`gecko.id` **`bmxt@unrsports`**, `gecko.strict_min_version` **140.0**, `gecko_android.strict_min_version` **142.0**). <a id="store-submission"></a> ## Store Submission (Reference) **Chrome Web Store** — build and package locally: ```bash pnpm run build:chrome pnpm run package:chrome # writes .output/bmxt-<version>-chrome.zip ``` You can automate submission with the [WXT publishing guide](https://wxt.dev/guide/essentials/publishing) or [Browser Platform Publish (bpp)](https://bpp.browser.market). This repo includes **`.github/workflows/submit.yml`** (manual **`workflow_dispatch`**) which runs **`pnpm run build:chrome`**, **`pnpm run package:chrome`**, and uploads **`.output/bmxt-*-chrome.zip`** via **`PlasmoHQ/bpp@v3`**. Store credentials belong in the GitHub secret **`SUBMIT_KEYS`** only — never commit them. **Firefox (AMO)** — separate path (do not mix into the Chrome submit workflow): ```bash pnpm run build:firefox pnpm run package:firefox # → .output/bmxt-<version>-firefox.zip # → .output/bmxt-<version>-firefox-sources.tar.gz (AMO source review) ``` Both hosts at once: **`pnpm run package`**. See **[`hosts/firefox/AMO_SOURCE.md`](hosts/firefox/AMO_SOURCE.md)** (including how to clear the AMO **Experimental** listing flag in Developer Hub — it is not part of the XPI). <a id="license"></a> ## License This project is licensed under [Apache License 2.0](./LICENSE). <a id="roadmap"></a> ## Roadmap 1. UI and behavior: design, implementation, and testing 2. Refine key operations in the core **tab** command / picker flows 3. ~~Add history and bookmark operations~~ — **done** (`bookmark` / `history` commands, Family `--open|--save|--both`, ZIP backup; see **[`bookmark`](#bookmark-command)** · **[`history`](#history-command)** · todo §9) 4. Improve multi-terminal behavior 5. Support pure command-line operation and additional automation flows 6. **Terminal CLI peer (`hosts/cli`)** — Family DataChannel peer + localhost auto-connect + **`bmxt exec`** oneshot + Profile I/O gates + bookmark/history / cross-browser send + peer **`aboutbmxt`/`dom`/`nav`** + command-base pickers / **`--focus`** + main-screen candidate menu (see **[Terminal CLI peer](#terminal-cli-peer)** · todo §10–§20); polish packaging / same-PC smoke --- <a id="japanese"></a> # BMXt(日本語) > 英語版は上記 [English](#introduction) セクションを参照してください。 ## 目次 - [謝辞](#acknowledgements-ja) - [はじめに](#introduction-ja) - [🛠 シードプロジェクト](#seed-project-ja) - [📺 デモ動画](#demo-video-ja) - [♿️ ユニバーサルデザインの意図](#universal-design-intent-ja) - [技術概要](#technical-overview-ja) - [主要仕様](#key-specs-ja) - [権限(`wxt.config.ts` の manifest)](#permissions-manifest-ja) - [再現可能なビルド](#reproducible-builds-ja) - [pnpm 依存関係とセキュリティ](#pnpm-dependencies-ja) - [コマンドラインのトークン仕様(第一・第二コマンド)](#command-line-token-model-ja) - [コマンド一覧](#command-list-ja) - [BMXt プロセスのライフサイクル(`clear` / ウィンドウ閉じ / `exit`)](#bmxt-process-lifecycle-ja) - [ターミナルセッション状態(UI が正本)](#terminal-session-state-ja) - [`aboutbmxt`](#aboutbmxt-ja) - [Nav モード(`nav -enter` / `nav -exit`)](#nav-mode-ja) - [`translate`(`translate -on` / `translate -off` / `translate -setting`)](#translate-ja) - [`setting`(`setting -list` / `setting -set` / `setting -exit -list`)](#setting-ja) - [`session`(ターミナルセッション)](#session-ja) - [`sync`(Family ローカル同期)](#sync-ja) - [`bookmark`](#bookmark-command-ja) - [`history`](#history-command-ja) - [端末 CLI peer(`hosts/cli`)](#terminal-cli-peer-ja) - [BMXtCLI を LLM で使う](#bmxt-cli-llm-ja) - [BMXtCLI GitHub Releases(プレビルドバイナリ + チェックサム)](#bmxt-cli-releases-ja) - [`tab`(サブコマンド)](#tabs-man-tabs-ja) - [ピッカー UI(横並び列)](#picker-ui-ja) - [タブピッカー(`tab -list | browse` / `tab -list -url | browse`)](#tabs-tab-picker-ja) - [タブピッカー `:edit`(ウィンドウ名・タブグループ)](#tabs-tab-picker-edit-ja) - [タブピッカー — 実装(キー配信とリデューサ)](#tabs-tab-picker-impl-ja) - [URL(`http` / `https` 行)](#url-lines-ja) - [コマンド実行アーキテクチャ(現状)](#command-execution-architecture-ja) - [プロンプト意味の正本(Rust)](#prompt-semantics-sot-ja) - [コマンド間語彙(閉じた IR)](#inter-command-vocabulary-ja) - [`-list` 出力レジストリ](#list-commands-registry-ja) - [bmxtRule(コマンド間ストリーム)](#bmxt-rule-ja) - [bmxtCandidate(プロンプト候補メニュー)](#bmxt-candidate-ja) - [ジョブ実行(バックグラウンド処理)](#job-execution-ja) - [組み込みコマンドの追加](#add-new-built-in-command-ja) - [コマンド追加手順](#command-add-procedure-ja) - [プロンプトのキーバインド](#prompt-key-bindings-ja) - [開発](#development-ja) - [開発時の起動](#development-startup-ja) - [テスト](#testing-ja) - [実行方法](#testing-how-to-run-ja) - [E2E がカバーすること](#testing-e2e-coverage-ja) - [pnpm 依存関係とセキュリティ](#pnpm-dependencies-ja) - [プロジェクト構成(WXT)](#project-layout-ja) - [主なソース](#main-sources-ja) - [バージョンアップバナーとリリースノート](#version-upgrade-banner-ja) - [本番ビルド](#production-build-ja) - [ストア提出(参考)](#store-submission-ja) - [ライセンス](#license-ja) - [ロードマップ](#roadmap-ja) <a id="acknowledgements-ja"></a> ## 謝辞 BMXt は、キーボード中心のブラウジングと現代の拡張開発を可能にしてきたコミュニティとツールの上に立っています。 * いまなお比類ないモーダル編集の標準を築いた **Vim/Neovim コミュニティ**、およびキーボード優先の Web 操作を切り拓いた **[Vim](https://www.vim.org/)** や **[Vimium](https://github.com/philc/vimium)** などに深く感謝します。 * 本プロジェクトを支えるオープンソースのエコシステム — **React**、**TypeScript**、**Rust** と **WebAssembly**、**[WXT](https://wxt.dev/)** / **Vite**、そして Web 拡張の開発者コミュニティ — にも特別な謝意を表します。 * 拡張機能の配布の場を提供してくださる **[Chrome ウェブストア](https://chromewebstore.google.com/)**、および同ストアの拡張機能を **Android** 上で直接利用可能にしている **[Vivaldi](https://vivaldi.com/)** にも感謝します。 * 開発者の理想を実装へつなぐ増幅器として **[Cursor](https://cursor.com/)** にも感謝します。 <a id="introduction-ja"></a> ## はじめに **BMXt** は、Chrome 上で **キーボード中心のブラウザ操作** を実現するための UI です。 これを作ったのは、作者自身が既存のブラウザ体験に満足していないためです。 プロンプトとログという**ターミナル風**の見た目を持ちますが、古典的なターミナルエミュレータそのものというより、**ブラウザ全体を操るためのコマンド面**として幅広いイメージをもって設計しているものであり、楽な姿勢で手をキーボードに置いたまま、タブやウィンドウへ手を伸ばす回数を減らすことを目指しています。 **名称** — **Browser Manipulator X Terminal** をもじった **BMXt**: - **X** - **UX** の改善 - さまざまな人がクロスオーバーに扱える願い - コマンドの組み合わせによる倍々的拡張・無限性 - **t** - **T**erminal の頭文字 - ユーザーのブラウザにプラスされる拡張機能、という意味を **t** に込める いまはまだ道を作り始めたばかりですが、**[Chrome ウェブストア](https://chromewebstore.google.com/detail/bmxtdemo/ljadfdncbodcdkmhfneeopomipanafil)** からインストールできます。 目の前のキーボードから「どこへでも行ける」と信じ、これからも機能を積み上げて、しかし人間に寄り添う道具として作り続けていきたいと考えています。 ではまず、いまできることをご説明します。 ぜひ動作デモのビデオもご覧になってください。 <a id="seed-project-ja"></a> ## 🛠 シードプロジェクト このリポジトリは **Chrome 拡張(Manifest V3)+ [WXT](https://wxt.dev/)** で動く専用シェルです。BMXt は **タブバーなしの独立 popup ウィンドウ**(`chrome.windows.create({ type: "popup" })`)で動作します(ツールバーアイコン直下の action popup ではありません)。技術選定の判断と確認/設計/テストは作者自身が、実装には AI アシスタント(Cursor)を100%使用して進めており、現段階では「動作の破綻をなくし、手触りを磨く」ための検証・種まきのフェーズと位置づけています。 <a id="demo-video-ja"></a> ## 📺 デモ動画 ※デモムービーには全機能のうち、グループ作成に関する部分を収録しています。 https://github.com/user-attachments/assets/2e418356-cfce-479a-9880-185e542c5fad <a id="universal-design-intent-ja"></a> ## ♿️ ユニバーサルデザインの意図 BMXt は、エンジニア向けの効率ツールであるとともに、**できるだけ軽い操作負担で確実に操作できる導線**(マウス指向 UI への依存を減らす、キー操作の一貫性、IME との両立など)を重ねていくことを目指しています。 <a id="technical-overview-ja"></a> ## 技術概要 以下は技術仕様の概要です。ツールバーの拡張アイコンから BMXt ウィンドウを開き(既に開いていれば前面へ)、タブ・ウィンドウ・タブグループの操作や URL 一行ナビゲーションをコマンドラインから行えます。[WXT](https://wxt.dev/)(Manifest V3)でビルドしています。エントリは **`entrypoints/`**、静的アセットは **`public/`**(**`_locales/`** 含む)、manifest 上書きは **`wxt.config.ts`**、出力は **`.output/`** です。 **リポジトリ配置(マルチブラウザ):** **`shared/`**(ブラウザ非依存のソース)、**`hosts/chrome/`** / **`hosts/firefox/`**(各ホストの WXT 設定)、**`hosts/cli/`**(端末 Family peer)。詳細は **[`hosts/README.md`](hosts/README.md)**、AMO は **[`hosts/firefox/AMO_SOURCE.md`](hosts/firefox/AMO_SOURCE.md)**、CLI 現状は **[端末 CLI peer](#terminal-cli-peer-ja)**。 **配置:** コマンド意味論(parse / レジストリ / パイプ計画など)は **Rust → WASM**(`shared/crates/bmxt-core/`)。TypeScript はホスト Effect・content script・React UI と薄いホスト(`lib/features/bmxt-core/` の `runDispatch` / `ensureBmxtCore`、`apply-ui-action`)に徹します(**`.cursorrules`** と **[`hosts/README.md`](hosts/README.md)** も参照)。**ターミナルセッション**(tmux 風・1 つ表示・複数バックグラウンド)は 1 つの BMXt ウィンドウ内で共有 — **[`session`](#session-ja)** 参照。リストピッカーは同一ペイン内でターミナルの右に **横並び列** として開きます(**[ピッカー UI](#picker-ui-ja)**)。 **コマンドラインの約束事**(第一・第二コマンド、Tab 補完、第二必須時の Enter 挙動)は **[コマンドラインのトークン仕様](#command-line-token-model-ja)** にまとめています。 **ツールチェーン(0.6.9 以降):** 拡張シェルは **[WXT](https://wxt.dev/)** と **[pnpm](https://pnpm.io/)** のみでビルドします。**`npm`** / **`npm ci`** / **`npx`** / **`package-lock.json`** は**使わない** — lockfile は **`pnpm-lock.yaml`**。manifest 上書きは **`wxt.config.ts`**(**`package.json`** ではない)。エントリは **`entrypoints/`**、静的アセットは **`public/`**、出力は **`.output/`**(開発: **`.output/chrome-mv3-dev`**、本番: **`.output/chrome-mv3`**)。**0.8.0** 以降は TypeScript **6.x**、コマンド解釈は同梱の **Rust → WASM** コア(`crates/bmxt-core/`)で実行します。 | 旧(Plasmo / npm) | 現行(WXT / pnpm) | |--------------------|--------------------| | **`tabs/bmxt.tsx`** | **`entrypoints/bmxt/main.tsx`**(+ **`index.html`** → **`bmxt.html`**) | | **`background.ts`**(リポジトリ直下) | **`entrypoints/background/index.ts`** | | **`contents/bmxt-nav-overlay.ts`** | **`entrypoints/bmxt-nav-overlay.content/index.ts`** | | **`locales/`** | **`public/_locales/`** | | **`build/chrome-mv3`** | **`.output/chrome-mv3`** | | manifest を **`package.json`** に記述 | **`wxt.config.ts`**(**`version`** は **`package.json`** のまま) | | **`npm ci`** / **`package-lock.json`** | **`pnpm install --frozen-lockfile`** / **`pnpm-lock.yaml`** | <a id="key-specs-ja"></a> ## 主要仕様 - **UI**: タブバーなしの独立 popup ウィンドウで動く拡張ページ(WXT の unlisted page **`entrypoints/bmxt`**、`chrome.windows.create({ type: "popup" })`)。実装の本体は **`lib/features/bmxt-window/`**(`BmxtTerminal`)で、**`entrypoints/bmxt/main.tsx`** はそれをマウントする薄いエントリです。 - **入力**: プロンプト行は **透明な `textarea` + 下層ミラー** で描画。日本語 IME(変換・確定)に対応。**desktop** の **host-ui** では **キーボード中心**でコマンド・ピッカー・nav を操作しつつ、ログ・プロンプトミラー・ピッカー一覧・ヒント・バージョンアップブロックなどは **マウスで範囲選択・コピー**可能(**`bmxt-ui.css`** の `user-select: text`)。タブピッカーでは `/` 絞り込み中も **フィルタ入力にフォーカスが残り**、一覧が入力フォーカスを奪わない。**mobile** の **host-ui**(**0.8.2** 以降。Android/Android 版 Vivaldi では既定)では補助キーバーに加え、プロンプト候補のタップ確定/外タップで閉じる。 - **状態**: **ターミナルセッションのログ**(`logsById`、`order`、`activeId`、`namesById`)、**開いているピッカー列**、**ペインフォーカス**は **BMXt UI ページ**(React)が BMXt ウィンドウ存続中の正本 — **[ターミナルセッション状態(UI が正本)](#terminal-session-state-ja)** 参照。**プロンプトのコマンド履歴**は **`chrome.storage.local`**(`bmxt_cmd_history`、上限 **300** 件)。**UI 設定**・**page-active** 等は別の **`chrome.storage.local`** キー(**`lib/features/extension-storage/keys.ts`**)。 - **バックグラウンド**: Service Worker(`entrypoints/background/index.ts`)がアイコンクリックでウィンドウを開き、コマンド実行・タブ操作を処理します。 - **グローバルショートカット**(`chrome://extensions/shortcuts` で変更可): **`launch-bmxt`**(既定 **Shift+Alt+C**)で BMXt を開く/既存ウィンドウを最前面へ。**`reset-bmxt`**(既定 **Shift+Alt+R**)でプロセススコープのセッション状態 **と** コマンド履歴を消去してから BMXt を開く/最前面へ(**[BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja)** 参照)。 <a id="permissions-manifest-ja"></a> ### 権限(`wxt.config.ts` の manifest) manifest の上書きは **`wxt.config.ts`** にあります(WXT がビルド時に **`manifest.json`** にマージします)。宣言している権限: **`favicon`**, **`tabs`**, **`tabGroups`**, **`storage`**, **`unlimitedStorage`**, **`windows`**, **`scripting`**, **`history`**, **`bookmarks`**。**0.8.5 以降:** 必須 **`host_permissions`** に **`https://*/*`** を含め、インストール/更新時に既に開いている **https** タブへ **ページ再読み込みなし** でコンテンツスクリプトを注入できます(**`lib/features/page-scripting/`**)。**todo §11:** 同一 PC 上の BMXt CLI との Family 認証付き接続確立用に **`http://127.0.0.1:17653/*`** · **`http://localhost:17653/*`** も追加(一般 `http://` ページ操作には使わない)。ページ内操作(**nav**・**`dom`**・**`search -list --page`**・**`snapshot -save`**)は **https のみ**。タブを開く・履歴・ブックマーク上の **http://** URL の扱いは従来どおり。特権 SW メッセージ **`RUN_CMD`** / **`NAV_CONTROL`** は拡張 UI(**`bmxt.html`**)からのみ受け付けます(コンテンツスクリプトや他拡張は拒否)。`chrome://extensions` でサイトアクセスを後からオフにした場合は、ページ内コマンドが再有効化の案内を出します。 **データの扱い(プライバシーポリシー・ストア説明と揃えた一文):** **ターミナルセッションの出力とピッカー UI** は BMXt ウィンドウが開いている間 **拡張 UI ページのメモリ**に保持(Service Worker には載せない)。**コマンド履歴**と **UI 設定**は上限付き **`chrome.storage.local`**(**`lib/features/extension-storage/keys.ts`**)。**`bmxt_terminal_sessions_v1`** 等の旧プロセスキーは **終了時の掃除**で削除されうるが、**実行中のログ正本ではない**。拡張ページ・SW から **`fetch()`** で任意の第三者 HTTPS に取りに行く設計にはしておらず、**`pnpm run check:no-fetch`**(allowlist: **`shared/lib/features/sync/handshake/localhost/`** のみ)で CI からも固定し、manifest の **CSP** は補助線です(ストア配信・ブラウザ更新は別)。 **`content_security_policy.extension_pages`** では **`default-src 'self'`**、**`script-src 'self' 'wasm-unsafe-eval'`**(WASM コンパイル)、**`connect-src 'self' http://127.0.0.1:17653 http://localhost:17653`**、**`object-src 'self'`**、**`style-src 'self'`**、**`img-src 'self' data: blob:`**、**`font-src 'self' data:`**、**`worker-src 'self'`** を宣言しています。拡張 UI の動的レイアウトは外部 CSS と Constructable Stylesheet で行い、`'unsafe-inline'` は使いません。正確な文字列は **`hosts/manifest-base.ts`** / ホスト **`wxt.config.ts`** を参照してください。 <a id="reproducible-builds-ja"></a> ### 再現可能なビルド 公式リリースは Git のタグで指します(`git tag`)。ストア提出物をソースから再現するには、そのタグを checkout し、**`pnpm install --frozen-lockfile`**(**`pnpm-lock.yaml`** 固定。CI や厳密な再現では **`pnpm install`** を使わない)のあと **`pnpm run codegen`** と **`pnpm run build`**(または **`pnpm run package`**)を実行し、依存ツリーと codegen 経路を揃えます。lockfile 方針・監査・メンテ手順は **[pnpm 依存関係とセキュリティ](#pnpm-dependencies-ja)** を参照。 <a id="pnpm-dependencies-ja"></a> ### pnpm 依存関係とセキュリティ 本リポジトリは **pnpm のみ**(**`package.json`** → **`packageManager`**、lockfile **`pnpm-lock.yaml`**)。**`npm install`** / **`npm run`** / **`npx`** および **`package-lock.json`** の生成は**禁止**。CI と README の手順も **pnpm** のみです。 **直接依存**(**`package.json`**)は **`react@18.2.0`**、**`react-dom@18.2.0`**、**`sql.js@1.12.0`** です。**WXT**(`wxt`、`@wxt-dev/module-react`)等は **devDependencies**。その他は **間接依存**(Vite ツールチェーン等)です。 **再現性のあるインストール** | コマンド | 用途 | |---------|------| | **`pnpm install --frozen-lockfile`** | **通常はこちら**(clone 後・CI・リリースビルド前)。**`pnpm-lock.yaml`** どおりのツリーのみ入る。 | | **`pnpm install`** | **`package.json`** を意図的に変えるとき(devDependency・直接依存の版上げなど)のみ。更新した lockfile をコミットする。 | **Lockfile 方針** — **`package.json`** では **`overrides` を使わない**。推移依存の版は **`pnpm-lock.yaml`** に exact + integrity で固定する。プロジェクト **`.npmrc`** は **`save-exact=true`** のみコミット(registry トークンは含めない)。直接依存を足すときは **`pnpm add`** で **`package.json`** に **`^` なしで版を明示する。 lockfile 更新を pull したあとの推奨手順: ```bash rm -rf node_modules pnpm install --frozen-lockfile pnpm run build ``` **Node.js 版** — **`.nvmrc`** を参照。**`packageManager`** で pnpm 版を固定する。初回 clone 時は **`corepack enable`** を一度実行する。 **CI**(**.github/workflows/ci.yml`**)は **`pnpm install --frozen-lockfile`**、**`pnpm exec wxt prepare`**、**`pnpm audit --audit-level=critical`**、続けて **`pnpm run verify`** を実行する。**`pnpm audit fix --force`** は **使わない**(unsafe dependency bumpsを提案し、危険)。 **残る audit(high / moderate)** — WXT のビルド専用ツールチェーンに **high** が残ることがある。いずれも **拡張機能バンドルには同梱されない**。CI は **critical** のみで fail する。**`pnpm audit fix --force`** は安易に使わない。 **ローカル検証(CI と同一):** **`pnpm run verify`**(GitHub Actions の install / `wxt prepare` / audit 以降と同じゲート)。 **依存関係を変更したら** **`pnpm install --frozen-lockfile`** → **`pnpm run build`** → **`pnpm test`** → **`pnpm audit --audit-level=critical`** を実行し、**`package.json`** と **`pnpm-lock.yaml`** を **セットでコミット**する。 <a id="command-line-token-model-ja"></a> ## コマンドラインのトークン仕様(第一・第二コマンド) BMXt は **コマンドライン方式**で動作する。仕様・実装・ドキュメントでは次を徹底する。 1. **第一コマンド → 第二コマンド** — 先頭の **第一コマンド**(例: `tab`, `session`)に続き、サブコマンドやフラグ形式の **第二コマンド**(例: `-list`, `-new`)がある場合は、その順で表記・解釈する。 2. **第一・第二とも短縮形を設けない** — いずれの段でも `-list` を `-l` のように省略した別名は設けない。**Tab 補完**の対象は **正式な表記のトークン**に限る。README にある従来のトップレベル別名(例: `help`/`?`)は後方互換で残りうるが、**新規**の第一+第二コマンド族では第一・第二いずれにも短縮を増やさない。 3. **第二コマンドが必須のときの Enter** — 第二コマンドがないと第一コマンドを実質動かせない場合、**第一コマンドだけ**で **Enter** を押すと、不足している第二コマンドの **利用案内またはプレースホルダ**を表示したうえで、プロンプトを **`第一コマンド `**(末尾に半角スペース 1 つ)に戻し、**末尾にカーソル**を置いて続きの入力を待つ。**Rust** が `msgs` + `promptPrefix` を返す(`require_second_token` / `msgs_with_prompt` 等)。TS ホストは i18n 展開と `setContinuationPrompt` のみ。Enter 用 continuation を TypeScript で新設しない(**[プロンプト意味の正本(Rust)](#prompt-semantics-sot-ja)**・**[コマンド追加手順](#command-add-procedure-ja)**)。 <a id="command-list-ja"></a> ## コマンド一覧 `help` または `?` で拡張内ヘルプと同内容が表示されます。概要だけ以下にまとめます。 | コマンド | 説明 | |----------|------| | `help` / `?` | ヘルプ | | `aboutbmxt` | ウェルカムページを開く。**`aboutbmxt -system`** で API 機能チェック(**[`aboutbmxt`](#aboutbmxt-ja)** 参照) | | `tutorial` | `tab -list \| browse` の対話チュートリアル(`tutorial` / `tutorial -start` / `tutorial -skip`;初回起動で自動開始)(**0.8.7 以降**) | | `clear` | ログをクリア | | `exit` | **アクティブなターミナルセッション**を閉じる。**最後の 1 セッション**なら BMXt ウィンドウを閉じ **BMXt プロセスを終了**(永続化されたプロセス状態をすべて消去 — **[BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja)** 参照) | | `tab` | 利用可能オプションを表示し、続けて `tab `(末尾スペース付き)へ入力復元 | | `tab -list [-url] [--device <id>\|--peers]` | 開いているタブを ID 付きプレーン一覧(`-url` で URL)。`--peers` は接続ピア横断 | | `tab -list [-url] | browse` | タブピッカー列を開き、検索・複数選択 `#`・バルクモードに対応 | | `tab -list \| tab -send <deviceId> [--close]` | 一覧タブをグループ維持でピアへコピー。`--close` は open 成功した**ローカル**送信元だけ閉じる | | `tab -send <deviceId> <url…> [--group <title>] [--close]` | 接続 Family ピアへ URL 送信。`--close` は成功したローカル元を閉じる | | `tab -exit -list` | 当該セッションのタブピッカー列を閉じる(`group new` 含む) | | `tab -setting -page-active --auto \| --manual` | タブピッカー:ハイライト移動時のタブ自動アクティブ化を切替(`--auto` 既定、`--manual` は Alt+↑↓)。`chrome.storage.local` に保存 | | `tab -moveurl <url>` | 指定 URL タブがあれば前面化、なければ新規タブを開く(http/https)。 | | `tab -nowurl` | 現在タブの URL を表示。 | | `tab help` | `tab` のマニュアル節を表示 | | `dom` | 利用案内を表示し、続けて `dom `(末尾スペース付き)へ入力復元(`-list` など第二トークン入力用) | | `dom -list [--normal\|--with] [--html\|--react] [--tag] [<pattern>]` | アクティブタブの DOM をプレーン一覧(既定 **`--normal --html`**)。任意の部分一致フィルタ。scriptable な **https** のみ | | `dom -list … | browse` | DOM 読み取り専用ピッカー列(`search -list … | browse` と同系 UI)。mode **`--normal`**/**`--with`**、flavor **`--html`**/**`--react`** | | `dom -exit -list` | 当該セッションの DOM ピッカー列を閉じる | | `search` | 利用案内を表示し、続けて `search ` へ入力復元(`-list`) | | `search -list [--all\|--history\|--bookmark\|--page\|--snapshot] [--device <id>\|--peers] [<pattern>]` | 検索結果のプレーン一覧(スコープ無し時は **`--all`** 相当)。`--peers` は接続ピア横断。部分一致(v1 正規表現なし) | | `search -list … | browse` | 検索ピッカー列。走査進捗はピッカー内表示。**→** で詳細一覧または **`[history]` / `[bookmark]`** 開き先ツリー | | `search -exit -list` | 当該セッションの search ピッカー列を閉じる(走査中ならセッション job runner 経由で **`search-list`** をキャンセル) | | `bookmark -list [--folder <id>] [--device <id>\|--peers]` | ローカル: フォルダツリー一覧(`open_plain_list`)。`| browse` で bookmark picker。ピア: `search -list --bookmark` 経路 | | `bookmark -add` / `-folder` / `-remove` / `-move` | URL/フォルダ作成、id 指定の削除/移動(パイプ: `… \| bookmark -remove` / `… \| bookmark -move --parent <id>`) | | `bookmark -send <deviceId> [--open\|--save\|--both]` | Family 送信: タブ open(`open_tabs`)、ブックマーク保存(`bookmarks_import`)、または両方(既定 **`--open`**) | | `bookmark -backup` / `-restore` | ブックマークツリーの ZIP バックアップ/復元(`bmxt-browser-backup/` 配下の版付き JSON) | | `history -list [<pattern>] [--device <id>\|--peers]` | ローカル: 日付ツリー一覧(`open_plain_list`)。`| browse` で history picker。ピア: `search -list --history` 経路 | | `history -delete` / `-delete-range` | URL 列または時間範囲(`--from` / `--to` ISO または epoch ms)で履歴削除。パイプ: `… \| history -delete` | | `history -backup` / `-restore [--as-bookmarks]` | ZIP エクスポート。復元は Chrome 履歴 DB を書き換えられない — 一覧読込またはブックマーク作成 | | `nav` | 利用案内を表示し、続けて `nav `(末尾スペース付き)へ入力復元(`-enter` / `-exit` / `-windowclose` 用) | | `nav -enter` | 当該 BMXt ペインで **nav モード**を起動(**[Nav モード](#nav-mode-ja)**)。ページ上のオーバーレイは **Alt**(詳細バーまたはプロンプト)を押すまで表示しない | | `nav -exit` | nav モードを終了(先に Alt でオーバーレイ **OFF**) | | `back` | 操作先アクティブタブの履歴バック(即時)。一括: `tab -list \| back` | | `forward` | 操作先アクティブタブの履歴を進む(即時)。一括: `tab -list \| forward` | | `reload` | 操作先アクティブタブをリロード(即時)。一括: `tab -list \| reload` | | `close` | 操作先タブを閉じる(**y/n** 確認)。`close <tabId>` は確認なし。一括: `tab -list \| close` | | `nav -windowclose` | **操作先タブが含まれるウィンドウ**を閉じる(**y/n** 確認。BMXt 窓は閉じない) | | `translate` | 利用案内を表示し、続けて `translate ` へ入力復元(`-on` / `-off` / `-setting` 用) | | `translate -on` | 翻訳アシストを有効化(nav typing 時はプロンプト下に訳プレビュー。**[`translate`](#translate-ja)** 参照) | | `translate -off` | 翻訳アシストを無効化 | | `translate -setting` | `translate -setting ` に復帰し、`--ja-en` / `--en-ja` を案内(Tab 補完) | | `translate -setting --ja-en` | ペア **ja-en** を保存(既定)。往復プレビュー・nav Alt 確定は英語 | | `translate -setting --en-ja` | ペア **en-ja** を保存。往復プレビュー・nav Alt 確定は日本語 | | `setting` | 利用案内を表示し、続けて `setting ` へ入力復元(`-list` 用) | | `setting -list` | 現在の UI 設定をプレーン一覧 | | `setting -list | browse` | **設定ピッカー**列(UI 言語・外観・保存先・snapshot 保存先・**Family sync** 表示名+セットアップ案内・zip 入出力)。**適用のたびにワンショット `setting …` 行を submit して即保存** | | `setting -set <key> <value>` | 設定を1件即保存(閉集合キー: locale/トグル/外観スカラー/ハイライト色/sync タイミング。画像の**クリア**は `-set`、**取込**は `setting -bg-import`) | | `setting -export` / `-import` / `-bg-import` / `-reset-default` / `-storage` / `-pick-dir` / `-reload` / `-snapshot-storage` / `-snapshot-pick-dir` / `-sync-guide` | 設定ワンショット操作(ピッカー適用と同じ経路。**[`setting`](#setting-ja)** 参照) | | `snapshot -save [<tabId>]` | アクティブタブ(または指定 tabId)を YAML frontmatter 付き Markdown snapshot として保存(Obsidian 連携向け)。保存先は **setting** の snapshot 保存先設定に従う | | `setting -exit -list` | 当該セッションの設定ピッカー列を閉じる | | `session` | 利用案内を表示し、続けて `session ` へ入力復元(第二トークン用。**[`session`](#session-ja)** 参照) | | `session -new [name]` | 新しい **ターミナルセッション** を作成して切り替え。表示名は任意 | | `session -list` | ターミナルセッションのプレーン一覧 | | `session -list | browse` | プロンプト上のインライン候補(↑↓ · **Enter** / **1–9** で即時切り替え) | | `session -switch [name]` | 表示名によるインライン候補(入力で絞り込み · **Enter** で `session -switch <name>` を挿入 · もう一度 **Enter** で実行)。`session -switch <name>` 直打ちも可 | | `session -next` / `session -prev` | アクティブなターミナルセッションを循環 | | `session -setting-name [name]` | 現在セッションの表示名を変更(裸コマンドは現在名をプロンプトに事前入力) | | `sync` | 利用案内を表示し、続けて `sync ` へ入力復元(Family ローカル同期 — **[`sync`](#sync-ja)**;**0.9.0 以降**) | | `sync -setup` | **ウィザード**でセットアップ(Family → 役割 → COPY / 貼付・初回推奨) | | `sync -connect <deviceId>` | 名簿メンバーへ再握手(役割自動・同じウィザードの COPY / 貼付) | | `sync -status` | device id / Family / 名簿 / WebRTC 接続状態 | | `sync -pair` / `sync -pair <invite>` | Family 招待表示(QR ペイロード)または参加 | | `sync -members` | Family 名簿と発見済みデバイス | | `sync -offer` / `sync -answer <code>` / `sync -accept <code>` | 上級向け CLI 握手(`bmxt-rtc1.`)。通常は setup/connect ウィザードの COPY / 貼付 | | `sync -ping <deviceId>` | 接続済みピアへ DataChannel ping | | `session <n>` | ターミナルセッション番号 **n**(1 始まり)へ切り替え | | `close` / `c <tabId>` | タブを ID 指定で閉じる(確認なし) | | `close` / `c`(パイプ) | `tab -list` のパイプ入力から列挙されたタブをすべて閉じる(**パイプ** 参照) | | `back` / `forward` / `reload`(パイプ) | 同じ producer → 列挙タブの一括バック/進む/リロード | | `group new` / `group new <tabId> …` | タブグループ作成 — タブ ID なしは対話的タブピッカー、ID 列挙ありは非対話 | | `move --window <id> […]` | タブ移動(パイプまたは ID 列挙)。任意で `--before-tab`、`--group`(宛先グループ参加)、`--ungroup`、または **`--as-group <gid>…`**(Chrome タブグループを単位移動・`chrome.tabGroups.move`。`--group` / `--ungroup` と併用不可) | | `new-window […]` | タブを新規ウィンドウへ(パイプまたは ID 列挙)。任意の **`--as-group <gid>…`** でグループを維持(`tabGroups.move` を逐次) | **複合コマンド(`&&` / `||` / `;`):** 1 行に **`&&`**・**`||`**・**`;`** で複数コマンドを並べる(クォート内と `\&&` / `\||` / `\;` は演算子にしない)。**左から順**に実行し、シェル同様に短絡する(**`&&`** は終了状態 **0** のときのみ次へ、**`||`** は非 0 のときのみ、**`;`** は常に)。各セグメントは数値の **exit status** を返す(0 = 成功、usage/parse = 2、不明コマンド = 127、その他失敗 = 1)。continuation のみの入力(裸の `dom` 等)や対話ピッカー(`<list> | browse`、裸の `session -switch`、裸の `session -setting-name`)は compound 行に含められない。ピッカー列は **`<list> | browse`** で開く。 **パイプ(`|`):** 各リスト演算子セグメント内(または単独行)で **producer** と consumer を **`|`** で連結。producer: プレーン **`tab -list`**(他 `-list` も可)、または **`tab:`** / **`tab::{語句}`** で選んだ **`#t:<id>…` チップ**。例: **`tab -list | close`**、**`#t:12 #t:34 | back`**。段間は **`bmxtRule`**(**`bmxt-rule/1`**)。consumer(**`pipe/consumers/registry.ts`**): **`browse`**(producer の **`ListResult`** からピッカー)、**`open`** / **`open --window`** / **`open --into-window`** / **`open --into-group`**(URL)、**`jump`**(`page.open` / `search.hit` / `dom.node`)、**`move`** / **`new-window`**(タブ)、**`back`** / **`forward`** / **`reload`** / **`close`** / **`c`**(**`page.open`**)、**`tab -send <deviceId>`**(Family open)、**`bookmark -remove`** / **`bookmark -move`** / **`bookmark -send`**、**`history -delete`**。種別不一致・未対応は終了状態 **1** と **stderr**。search / DOM / session / setting の Save・Cancel / タブ move·group·new-window のピッカー Enter は同じ型付き行を組み立て **`submitLine`** に再入場する(CUI 同等化)。 **タブチップ(`tab:`):** **`tab:`** で開いているタブ候補(ファビコン+タイトル)。選択で **`#t:<id>`** チップに置換し、**候補は閉じる**。チップが1つのとき **Enter** でそのタブをアクティブ(ウィンドウもフォーカス)。2つ以上でパイプなしの Enter はエラー(一括操作は **`|`**)。追加選択は Enter 前に **半角スペース** で候補再表示。**`|` のあと Tab** でパイプ先候補(**`browse`** / **`open`** / **`jump`** / **`back`** / **`forward`** / **`reload`** / **`close`** / **`c`** / **`tab`**)。タイトル絞込は **`tab:{語句}`** またはスペース後の語句、URL は **`tab::{語句}`**。その後 **`#t:… | back`** / **`reload`** などでパイプ。末尾の未完成 **`tab:`** はパイプ実行時に無視される。 **リダイレクト(`>` / `>>` / `2>` / `2>>`):** セグメント内で **stdout**(`>` / `>>`)または **stderr**(`2>` / `2>>`)を **null シンク**(**`null`** または **`/dev/null`**)へだけ向けられる(クォート内と `\>` は演算子にしない)。向けたチャネルはターミナルログから捨てる。それ以外のターゲットは拒否(終了状態 **2**)。OS パスへの書き込みは対象外。 **BMXt POSIX Profile:** BMXt は IEEE Std 1003.1 シェルの完全実装ではない。対話ターミナルは文書化されたプロファイルに従う(argv 風セグメント、数値 exit status **0 / 1 / 2 / 127** · `EXIT_*` 定数のみ、stdout/stderr チャネル、**閉じた** producer/consumer レジストリ + **`bmxtRule`** 付き `|`、リスト演算子 **`&&` / `||` / `;`**、null シンクリダイレクト、compound/pipe 用 **`CommandEntry`** レジストリ)。background コマンドは Service Worker **`RUN_CMD`** にフォールバック(`SessionPatch.appendLog` は `channel` 可)。**端末 CLI(`bmxt` / `bmxt exec`)も同一の I/O 意味**(UTF-8 行の完了バッファ → OS FD / IPC)。todo §13–§15 · [`_context/cli-peer/CONTRACT.md`](_context/cli-peer/CONTRACT.md)。配信は当面完了バッファ。 **追加時の規律(todo §15):** (1) exit は `EXIT_*` のみ · (2) 成功→stdout / 診断→stderr · (3) browse / TUI / ask は **Interactive** のみ · (4) CLI は **`CommandIo`**(`pnpm run check:cli-command-io`)· (5) パイプは閉じた consumer / `bmxtRule` のみ。チェックリスト: [`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md)。 対象外: ジョブ制御、サブシェル、コマンド置換、OS パス redirect、外部プロセス起動。 **補足 — `clear` と `exit` とウィンドウを閉じる操作:** `clear` は **アクティブなターミナルセッションの画面ログだけ**を消します。**BMXt ウィンドウを閉じる**(×)または **最後の 1 セッション**で **`exit`** すると、**UI 上のセッション/ピッカー状態を破棄**し、Service Worker が **旧プロセス用 storage キーを掃除**します。**コマンド履歴は保持**され、**`reset-bmxt`** ショートカットを使ったときだけ消えます。**`exit`**(複数セッション)はアクティブなセッションだけを除去し、別セッションへ切り替えます。詳細は **[BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja)** と **[ターミナルセッション状態](#terminal-session-state-ja)**。 <a id="bmxt-process-lifecycle-ja"></a> ### BMXt プロセスのライフサイクル(`clear` / ウィンドウ閉じ / `exit`) **BMXt ウィンドウを閉じる**(×)または **最後の 1 セッション**で **`exit`** すると、**BMXt UI ページ上のメモリ状態**(セッションログ、ピッカー列、タブツリー開閉)が終了します。Service Worker は必要に応じ **旧プロセス用キー**を **`chrome.storage.local`** から削除します。**プロンプトのコマンド履歴**(`bmxt_cmd_history`)は残り、次回起動後も ↑/↓ で辿れます。履歴も消すには **`reset-bmxt`** ショートカットを使います。BMXt を再度開くと **空のターミナル** で始まり、履歴だけ復元されます。 | 操作 | セッションログ(UI) | 開いているピッカー列・`paneFocus` | タブツリー開閉 | コマンド履歴 | |------|----------------------|-----------------------------------|----------------|--------------| | **`clear`** | 消去(アクティブセッション) | 保持 | 保持 | 保持 | | **BMXt ウィンドウを閉じる** | **すべて消去**(UI 破棄) | **消去** | **消去** | **保持** | | **BMXt ウィンドウを再度開く** | 空の新規 | 消去 | 消去 | **復元** | | **`exit`**(複数セッション) | アクティブセッション除去・別セッションへ切替 | 当該セッションのピッカー消去 | 保持 | 保持 | | **`exit`**(最後の 1 セッション) | **すべて消去** | **消去** | **消去** | **保持** | | **`reset-bmxt` ショートカット** | 消去(UI に通知) | 消去 | 消去 | **消去** | **旧プロセススコープ storage キー**(**最後の 1 ペイン**の **`exit`** または BMXt ウィンドウ × — **掃除用**。実行中のログ正本**ではない**): | キー | 旧来の役割(掃除) | |------|---------------------| | `bmxt_terminal_sessions_v1` | 旧オンディスクセッションブロブ(v5) | | `bmxt_process_ui_v1` | 旧ピッカー/`paneFocus` スナップショット | | `bmxt_tab_picker_fold_v1` | 旧タブピッカーツリー開閉 | **プロセス終了時も消さないもの**(ユーザー/ブラウザメタデータ): コマンド履歴(`bmxt_cmd_history` — **`reset-bmxt`** 時のみ消去)、ウィンドウ表示名、UI 設定(`bmxt_ui_settings_v1` — 言語・外観;save 時に常に更新)、UI 設定**保存先モード**(`bmxt_ui_settings_storage_v1` — 拡張機能内/外部)、翻訳アシスト設定、タブ/search ピッカー設定(`page-active`)、最後の通常ウィンドウ id、welcome/バージョン追跡キー。**0.6.9** より前の旧 SQLite キャッシュキー(`bmxt_search_cache_db_v1`、`bmxt_job_db_v1`)は `chrome.storage.local` に残ることがあるが、新規書き込みはしない(拡張機能アンインストールで消去)。 **実装:** UI セッション — **`use-terminal-sessions.ts`**、**`session-state-ops.ts`**、**`session-patches.ts`**;storage 掃除 — **`state-storage.ts`** の `removeAllTerminalSessionsFromStorage`;ピッカー/ペイン — **`use-process-ui-persistence.ts`**;タブツリー開閉 — **`tab-picker-fold-state.ts`**(ウィンドウ存続中はメモリ)。 **補足:** **`tab -exit -list`**(および他の **`* -exit -list`**)は当該ピッカー列を閉じるだけで、BMXt プロセスを終了したりタブツリー開閉状態を消したりしません。 **ターミナルセッションとピッカー列:** **2 つ以上**のターミナルセッションがあるとき、BMXt ウィンドウにフォーカスがあれば **Ctrl+← / Ctrl+→** でアクティブセッションを循環します。アクティブセッション内では **Ctrl+← / Ctrl+→** で **ターミナル → tabs → search → dom → setting**(開いている列のみ)を移動します。詳細は **[ピッカー UI(横並び列)](#picker-ui-ja)** と **[`session`](#session-ja)**。 <a id="terminal-session-state-ja"></a> ### ターミナルセッション状態(UI が正本) BMXt ウィンドウが開いている間、**拡張 UI ページがターミナルセッション状態の正本**です。Service Worker は Chrome API 副作用を実行し **patch** を返すだけで、**アイドル停止後もログを保持しません**。 | データ | 正本 | 存続 | |--------|------|------| | ログ、`order`、`activeId`、`namesById` | **BMXt UI**(`useTerminalSessions`) | ウィンドウ存続中 | | 開いているピッカー、`paneFocus`、詳細バー、nav armed | **BMXt UI**(`useProcessUiPersistence`) | ウィンドウ存続中 | | タブピッカー開閉/ハイライト(セッション内) | **BMXt UI**(メモリヘルパ) | ウィンドウ存続中 | | プロンプトコマンド履歴 | **`chrome.storage.local`**(`bmxt_cmd_history`) | ウィンドウ close 後も保持 | | UI 設定、page-active | **`chrome.storage.local`** | ウィンドウ close 後も保持 | **理由:** Manifest V3 では Service Worker はアイドルで停止しうる。**長寿命の UI ページ**にログを置くことで、SW コールドスタート後も状態が消えません。将来の **マルチウィンドウ**化でも境界が明確になります。 **`RUN_CMD` フロー**(フォールバック — 例: `close`、`help`、`session -new`): 1. UI が **`RUN_CMD`**(`line`、`sessionId`、`sessionOrderLength`)を送信。 2. SW が **`runDispatch`** / **`applyHostEffects`** を実行。 3. SW が **`{ ok: true, patches: SessionPatch[], closeWindow? }`** を返す(`SESSION_SNAPSHOT` 推送なし)。 4. UI が **`applyRunCmdPatches`** でローカル適用(`appendLog`、`createSession`、`exitSession` 等)。 **UI ローカルコマンド**(**`RUN_CMD` より前**の **`bmxt-shell.tsx`**)— 例: **`<list-command> | browse`**、**`* -exit -list`**、**`session -list`** / **`setting -list`**(プレーン)、**`session -switch`**、**`translate -on`**、**`nav -enter`** — は React state を直接更新。**プレーン**の **`tab -list`**、**`dom -list`**、**`search -list`** は **`RUN_CMD`** と **`-list` レジストリ**経由(**[`-list` 出力レジストリ](#list-commands-registry-ja)** 参照)。 **メッセージ:** **`SESSION_INIT`** / **`SESSION_SNAPSHOT`** / **`SESSION_UI_*`** は**廃止**。SW → UI のセッション通知は **`SESSION_CLEAR`**(**`host`**: **`"popup"`** | **`"all"`**。ポップアップ閉鎖は popup のみ;**`reset-bmxt`** は **`"all"`**)。 **モジュール:** **`session-state-ops.ts`**、**`session-patches.ts`**、**`use-terminal-sessions.ts`**、**`session-runtime-client.ts`**、**`background-services.ts`**。 **SW アイドル:** UI 状態は変わらない。次の **`RUN_CMD`** も **既存の session id** に patch を適用する。 <a id="aboutbmxt-ja"></a> ### `aboutbmxt` **`aboutbmxt`** はウェルカムページを開き、**`aboutbmxt -system`** はブラウザ API 機能チェックを再実行します(install/update 後のプロンプト表示と同じレポート)。 | 入力 | 動作 | |------|------| | **`aboutbmxt`** | **`https://unrsports.github.io/bmxt/welcome.html`** を **`open_welcome_page`** 経由で開く(Service Worker → **`openWelcomePageTab`** / **`chrome.tabs.create`**)。クエリ **`lang`**(設定の UI ロケール)と **`v`**(インストール済み manifest 版)を付与。ターミナルには短い確認行が出る。 | | **`aboutbmxt -system`** | 使用可能なブラウザ API(tabs / windows / tabGroups / bookmarks / history / scripting+host / WebRTC / FSA / Translator)を検査し、ターミナルに OK/NG 行を出す。**install/update** 後は同じレポートを予約し、次にプロンプト窓を開いたときに一度表示する。 | **ページ内容**はリポジトリの **`docs/`**(GitHub Pages)のみが正本です。**`docs/welcome-content.json`** を編集します(バージョン履歴、任意の **`heroImage`** / **`heroImageMaxWidth`** / **`additionalImages`**;画像は **`docs/welcome/`**)。拡張機能はこの JSON を同梱せず、ホストされた **`welcome.html`** の URL を開きます。 **関連(本コマンド以外):** 拡張機能 **インストール** または **更新** 時は **`openWelcomePageOnUpdateIfNeeded`** が同じ URL を **バージョンごとに 1 回** **通常タブ** で開きます(**`LAST_SEEN_WELCOME_VERSION_KEY`** で記録)。手動プレビュー: **`https://unrsports.github.io/bmxt/welcome.html?lang=ja&v=0.96.1`** — 詳細は **[バージョンアップバナーとリリースノート](#version-upgrade-banner-ja)**。 **実装:** Rust **`cmd/aboutbmxt.rs`**、Effect **`open-welcome-page.ts`** / **`probe-capabilities.ts`**、能力検査 **`lib/features/capability/`**、URL 組み立て **`lib/features/welcome/welcome-external-url.ts`**、タブ起動 **`lib/features/welcome/open-welcome-page-tab.ts`**。 <a id="nav-mode-ja"></a> ### Nav モード(`nav -enter` / `nav -exit`) **Nav モード**は、**直前にフォーカスした通常ウィンドウのアクティブタブ**上に **仮想ポインタのオーバーレイ**を出し、キーで操作します(タブ解決は **`dom -list`** と同系)。横並びのピッカー列ではなく、BMXt ウィンドウ UI 内の状態と、プロンプト下の **tmux 風ステータス帯**(**`nav`**・**ON/OFF**・対象タブ名)で状態を示します。 **コマンド(第二トークン必須)** | 入力 | 動作 | |------|------| | 単独 `nav` + **Enter** | 利用案内を表示し、プロンプトを **`nav `** に復元(continuation)。Tab 補完は **`-enter`** / **`-exit`** のみ(短縮別名なし)。 | | **`nav -enter`** | 当該セッションペインで nav を **起動(armed)**。宣言済みの必須 https **`host_permissions`** を使う(`dom -list` と同系)。この時点ではページ上にオーバーレイは出ない。 | | **`nav -exit`** | nav を **完全終了**(タブごとの位置記憶を消し、オーバーレイを除去)。オーバーレイがまだ **ON** のときはエラー — 先に **Alt** で **OFF** にする。 | **`nav -enter` 後 — Alt でオーバーレイ ON/OFF** - **BMXt ウィンドウがアクティブ**で、当該ペインの **ターミナル**または**詳細バー**にフォーカスがあるとき。**Ctrl+← / Ctrl+→** で **tabs / search / dom** ピッカー列に移ると、nav のキーは無効(ピッカー操作に戻る)。 - **Alt** のたびにオーバーレイを **ON** / **OFF** 切替(**nav 詳細バー**から、または armed 中のプロンプトから)。 - **ON:** 対象タブにオーバーレイを注入・更新。カーソルは毎回 **ビューポート中央**から開始(OS のマウス位置ではない)。オーバーレイ **ON** 中は **キーボードフォーカスを nav 詳細バーに固定**(今後の詳細バー操作追加を想定)。**↑ / ↓ / ← / →** は操作可能要素間の **空間スナップ**。**Shift+↑ / ↓ / ← / →** は **12px** 刻みの自由移動(`NAV_ARROW_STEP_PX`、`lib/features/nav/nav-config.ts`)。自由移動後に **Shift を離す**と、現在ポインタ位置で候補を **再スキャン**し、旧スナップ位置へ戻らない。**Enter** でカーソル下を activate、または編集可能要素なら **typing モード**へ(下記)。 - **OFF:** 当該タブのオーバーレイを除去。nav は **armed** のまま **`nav -exit`** まで継続。フォーカスは **nav 詳細バー**に残る。 **オーバーレイ ON 時のキー(nav 詳細バーにフォーカス)** | キー | 動作 | |------|------| | **↑ / ↓ / ← / →** | その方向の次の操作可能要素へジャンプ(空間スナップ。必要に応じビューポート自動スクロール) | | **Shift+↑ / ↓ / ← / →** | ポインタを **12px** 自由移動(ステップごとの候補再収集なし)。**Shift 解放**で現在位置の最近傍ターゲットを再スキャン・ハイライト | | **/** | **属性インクリメンタルジャンプ**開始(リンクテキスト / `alt` / URL パス / accessible name の断片で絞込。下記) | | **Enter** | 解決済みターゲットを activate(リンク・ボタンは `click()` 1 回。編集可能なら **typing モード**) | | **Ctrl**(タップ) | カーソル位置に **コンテキストメニュー**を表示 | | **Alt**(タップ) | オーバーレイ **OFF**(**typing** 中は無視) | **ON** 中は **←** で詳細バーからプロンプトへ抜けない(矢印はページカーソル用)。**Tab** / 上下でのバー循環も停止。**typing モード**中のみ一時的にプロンプトへフォーカスし、終了後は nav 詳細バーへ戻る。 **対象の同定(探索 → 再利用)** - オーバーレイ **ON** 中、カーソル横に **`link:/docs`** や **`button-like:Save`** のような短い HUD、ステータス帯にも同じ **`kind:key`** を表示。 - 分類はヒューリスティック(`link` / `button-like` / `editable` / `media` / `maybe-interactive` / `inert`)。内側の span でも親の `<a>` / button を実ターゲットとして解決。 - **成功した activate** の識別キーを **ページ origin** 単位で学習(`chrome.storage.local` の **`bmxt_nav_learned_targets_v1`**)。以降の **`/`** ジャンプで馴染みのキーを優先。0 件一致や activate 失敗のキーは削除。 **インクリメンタルジャンプ(`/`)** | キー | 動作 | |------|------| | **/** | ジャンプモードへ(オーバーレイは **ON** のまま。ステータスは **`jump`**) | | 文字入力 / IME | **詳細バー**の検索欄で候補を絞込(日本語 IME の変換に対応) | | **↑ / ↓** | 一致候補を循環 | | **Enter** | ハイライト中の候補を activate(IME 変換中は無視) | | **Esc** | ジャンプ解除(オーバーレイは **ON** のまま) | Vimium 型の全画面ヒント撒きではない。**指して同定 → 属性で再到達**が目的。 **コンテキストメニュー**(**Ctrl**): **↑ / ↓** で項目選択、**Enter** で実行、**← / →** でブラウザ **戻る** / **進む**、**Ctrl** または **Esc** で閉じる。 | 項目 | 動作 | |------|------| | テキスト選択 | **↑ / ↓**(または **Shift+矢印** の自由移動)で移動、**Enter** で **開始**、再度移動して **Enter** で **終了** → 範囲選択後 **コピー** 行 | | カーソル下の画像を保存 | ポインタ下の画像をダウンロード(http(s) URL) | | ページを再読み込み | 対象タブを再読み込み | テキスト選択後は **コピー** + **Enter** でクリップボードへ。**Esc** で選択解除(コピーメニュー表示中も同様)。 **typing モード**(編集可能要素で **Enter** 後): BMXt プロンプトにヒント表示。入力はページ側フィールドへ反映。**Alt 長押し**(約 500ms)で **確定**、**Esc 長押し**で **取消**(元の値に戻す)。複数行フィールドは **Shift+Enter** で改行可。typing 中の短い **Alt** はオーバーレイ切替にならない。 **`translate -on`** 中は typing でもプロンプト下に **原文 → 訳 → 再訳** の往復プレビューが出ます(文の終わりは `。` `.` `!` `?` `!` `?` など)。**Alt 長押し**確定では生の入力ではなく、保存ペアの **訳(target 言語)** をブロックから組み立てて送ります(**`--ja-en`** は英語、**`--en-ja`** は日本語。詳細は **[`translate`](#translate-ja)**)。 プロンプト下のステータス帯は **`nav`**・**ON/OFF**・**jump**・**typing**・**menu**・**sel-start** / **sel-end**・**copy** などと、対象タブ名・**`kind:key`**・短いエラーを表示。**`debugger`** 権限 / CDP AOM は使わない。 **armed 中のタブ切替** - 通常ウィンドウでアクティブタブを変えても **armed は維持**。新タブにオーバーレイを再作成。**タブごとに位置を記憶**し、戻ったタブでは最後の位置を復元。**Alt で ON** したときはそのタブでは毎回 **中央**から開始。 **ページと権限** - **scriptable な https** のみ(平文 **http://**・`chrome://`・ウェブストア・`chrome-extension://` 等は拒否)。注入失敗時はステータス帯に短い理由(例: **`site access denied`**)。 - 拡張のインストール/再読み込み後は、開いている **https** タブへ **`onInstalled` 再注入** / **`ensurePageContentScript`** で WXT **コンテンツスクリプト**(`entrypoints/bmxt-nav-overlay.content/`)を載せる(**対象ページの再読み込みは不要**)。未注入時は **`chrome.scripting.executeScript`** にフォールバック。 **実装** - **`lib/features/nav/`** — プロンプト解析、ステータス帯、セッションフック(`useNavMode`)、注入スニペット、SW ランナー(`run-nav-inject.ts`)。 - **`lib/features/bmxt-window/bmxt-shell.tsx`** — **`nav -enter` / `nav -exit`** を `RUN_CMD` より前に処理。詳細バーフォーカス制御と接続。 - **`lib/features/bmxt-window/shell/usePaneFocusController.ts`** / **`use-detail-bar-keyboard.ts`** — オーバーレイ **ON** 中は **nav** 詳細バーにフォーカス固定。**Alt** で切替。 - **`entrypoints/background/index.ts`** — `NAV_CONTROL` メッセージで対象タブへ注入。 - **`entrypoints/bmxt-nav-overlay.content/`** — https ページ上のリスナー。 <a id="translate-ja"></a> ### `translate`(`translate -on` / `translate -off` / `translate -setting`) **`translate`** は Chrome 内蔵の **`Translator` API**(日本語 ↔ 英語)を **nav typing** 向けアシスト(BMXt プロンプト下のプレビュー)に使います。向きは **翻訳ペア** として **`chrome.storage.local`** の **`TYPING_TRANSLATE_KEY`**(`{ enabled, pair }`)に保存します。 | 入力 | 動作 | |------|------| | 単独 `translate` + **Enter** | 利用案内を表示し、**`translate `** に復元(continuation)。Tab 補完は **`-on`** / **`-off`** / **`-setting`** のみ(短縮別名なし)。 | | **`translate -on`** | 翻訳アシストを有効化。ログに現在のペア(例 **`--ja-en`**)を表示。nav typing 時はプロンプト下に訳プレビュー。 | | **`translate -off`** | アシストを無効化。 | | **`translate -setting`** + **Enter** | ペア候補を表示し、**`translate -setting `** に復帰。Tab で第三トークン **`--ja-en`** / **`--en-ja`** を補完。 | | **`translate -setting --ja-en`** | ペア **`ja-en`** を保存(原文 **JA** → 訳 **EN** → 再訳 **JA**)。進行中ブロックをリセット。 | | **`translate -setting --en-ja`** | ペア **`en-ja`** を保存(原文 **EN** → 訳 **JA** → 再訳 **EN**)。進行中ブロックをリセット。 | **翻訳ペア(`-setting`)** - 定義は **`lib/features/translate/translation-pair.ts`**(`TRANSLATION_PAIRS`)。言語追加時は同テーブルと manifest の **`trailingTokens`** を拡張する想定。 - **`--ja-en`**(既定): 往復 **ja → en → ja**。**nav Alt 長押し**確定は **英語**(`forward`)。 - **`--en-ja`**: 往復 **en → ja → en**。**nav Alt 長押し**確定は **日本語**。 **パネル見出し(原文 / 訳 / 再訳)** - nav 下プレビューは **原文・訳・再訳** の3段。見出しは **日英併記**(日本語行+英語サブ行)で、ペアに応じた言語タグ(例 **`--ja-en`**: **`原文(JA)`** / **`Source (Japanese)`**、`getTranslationFieldLabels`)。 **ステータスバー** - アシスト **ON** 中、translate 帯に現在ペア(例 **`--ja-en`**)とモード(nav typing 等)を表示。Alt 確定のヒントはペアに追従(英訳送信 / 和訳送信)。 **nav typing** - アシスト **ON** 時、**nav typing** でプロンプト下にプレビューを表示。**文が完結**(`。` `.` `!` `?` `!` `?` など)ごとに、保存ペアに応じた **訳 / 再訳** ブロックを更新。 - **`Translator` API** と、ペアの **source→target** の利用可否が必要。未対応の Chrome では短いステータス行を表示。 - **Alt 長押し**確定では **`buildEnglishCommitText`**(内部で **`translateForward`**)により、ペアの target 言語文を組み立てて注入。 **実装:** **`lib/features/translate/`**(`translation-pair.ts`、`translator-service.ts`、`parse-translate-command.ts`)、**`lib/features/bmxt-core/cmd/translate.ts`**、UI は **`bmxt-shell.tsx`**(`RUN_CMD` より前に処理)。 <a id="setting-ja"></a> ### `setting`(`setting -list` / `setting -set` / `setting -exit -list`) UI 表示言語と **ターミナル+ピッカー列の外観**は、専用の **設定ピッカー**列または **ワンショット `setting …` 行**で編集します。**既定の永続化**は **`chrome.storage.local`** の **`bmxt_ui_settings_v1`**(`lib/features/extension-storage/keys.ts`)。**任意の外部保存**は File System Access API(ユーザーが選んだフォルダ);モードは **`bmxt_ui_settings_storage_v1`** に保存。 **コマンド経路(ワンショット/CUI 移行後):** Rust **`cmd/setting.rs`** が第二トークンを解釈し **UiAction**(`setting_set`、`setting_export` など)を返す。設定ピッカーはストレージを直接書き換えず、同じ行を組み立て(`lib/features/picker/build-setting-command-line.ts`)て **`submitConstructedLine`** する。適用は **`apply-ui-action.ts`** → **`setting-cui-apply.ts`** / **`setting-cui-ops.ts`**。 | 入力 | 動作 | |------|------| | 単独 **`setting`** + **Enter** | 利用案内を表示し、**`setting `** に復帰(continuation)。Tab 補完は **`-list`** / **`-set`** / **`-export`** / **`-import`** / **`-exit`**(および関連ワンショット)。 | | **`setting -list`** + **Enter** | 現在 UI 設定の **プレーン一覧**(**`-list` レジストリ**の `setting.field` 行)。 | | **`setting -list | browse`** + **Enter** | **setting** ピッカー列を開く(committed 設定のミラー)。適用はワンショット行を submit。 | | **`setting -set <key> <value>`** + **Enter** | 検証のうえ **即保存**(下記の閉集合キー)。 | | **`setting -export`** / **`-import`** | zip バックアップ書き出し/zip ファイルピッカー→即保存。 | | **`setting -bg-import [--picker]`** | 背景画像ファイルピッカー(任意 **`--picker`** レイヤ)。 | | **`setting -reset-default`** | 外観を既定に戻して保存。 | | **`setting -storage internal\|external`** | UI 設定の保存先モード切替。 | | **`setting -pick-dir`** / **`-reload`** | (外部モード)親フォルダ再選択/バンドル再読込して保存。 | | **`setting -snapshot-storage bundled\|vault`** / **`-snapshot-pick-dir`** | snapshot 保存先;vault モード時の Vault 再選択。 | | **`setting -sync-guide`** | Family sync セットアップ案内行を表示(msgs のみ)。 | | **`setting -save`** / **`setting -cancel`** | 互換エイリアス: 設定列を閉じるのみ(破棄する下書きなし)。 | | **`setting -exit -list`** + **Enter** | 当該セッションの設定ピッカー列を閉じる。 | **`setting -set` キー(閉集合)** | キー | 値 | |------|-----| | **`locale`** | **`ja`** / **`en`**(**0.96.1** 以降の既定は **`en`**) | | **`edit-picker`**, **`ime-candidate-help`**, **`prompt-fire`** | **`on`** / **`off`** | | **`search-legend`** | **`text`** / **`emoji`** / **`text_emoji`** | | **`host-ui`** | **`auto`** / **`desktop`** / **`mobile`** / **`default`** | | **`fg`**, **`bg-color`**, **`picker-fg`**, **`picker-bg-color`**, **`search-hit-highlight`**, **`search-jump-highlight`** | hex 色、または **`default`** / **`reset`** でクリア | | **`size`**, **`picker-size`** | 例 **`14px`**、またはクリア用トークン | | **`font`**, **`picker-font`** | フォント名、またはクリア用トークン | | **`bg-image`**, **`picker-bg-image`** | クリアのみ(**`default`** / **`reset`**)。取込は **`-bg-import`** | | **`sync-hold-ms`**, **`cli-door-retry-ms`** | ミリ秒、または **`default`** | **即時確定** - 検証済み適用(ピッカー選択、編集 Enter、画像取込/削除、reset、zip import、storage-reload)のたびに **`bmxt_ui_settings_v1`**(外部モード時は設定バンドルも)へ書き込み、ライブ UI を更新する。 - 色/フォントのインライン入力は **`editDraft`** にバッファし、Enter で検証してから保存。途中の hex はプレビューのみで、キー入力ごとに書かない。 - 下部 **Preview** は現在の(committed)外観と、編集中のプレビューを表示。 - **`prompt-fire: on`** の打鍵/削除エフェクトは BMXt ウィンドウ全体のキャンバスに描画する(プロンプトキャレット付近のみではない)。**Firefox / Gecko** では、プロンプトの **候補メニュー** が開いているときキャレット近傍の **menu-lite** 経路(`shared/lib/features/prompt-effects/`)に切り替わり、メニューの応答性を保つ。Chromium はメニュー開でもフル品質のまま。 **保存先(拡張機能内/外部)** | モード | 動作 | |--------|------| | **拡張機能内**(既定) | 設定は **`bmxt_ui_settings_v1`** のみ。File System Access API は使わない。 | | **外部フォルダ** | ユーザーが親フォルダを一度選択。BMXt はその下の**設定バンドル**を読み書き(下記)。**`bmxt_ui_settings_v1`** も適用のたびに更新(キャッシュ+バックグラウンドの locale)。起動時は外部バンドルを優先読み込み;読めないときは内部にフォールバック。 | **ピッカー行(storage):** **storage** — 拡張機能内/外部を選択;外部有効時は **storage-pick-dir**(フォルダ選び直し)、**storage-reload**(バンドルを読み込み保存)。保存先の切り替えは即時確定。**manifest 権限の追加なし** — フォルダアクセスはブラウザのピッカーでランタイム許可。 **バックアップバンドル形式(zip export/import と外部ディレクトリ共通)** zip **export**、zip **import**、**外部 save** は**同一のオンディスクレイアウト**(**`settings-export.ts`**、**`settings-bundle-layout.ts`**): ``` bmxt-ui-settings/ ← 選んだ親フォルダの下(既に settings.json があるフォルダを選んだ場合はそのフォルダ自体) settings.json ← version フィールド(現行 2);locale・外観;画像は相対ファイル名 background-image.png ← 全体 bg-image 設定時(jpg/webp も可) picker-background-image.* ← ピッカー個別 bg-image 設定時 ``` - **export** — 同じファイル構成の zip をダウンロード(ポータブルバックアップ)。 - **import** — zip を読み込み **即保存**。 - **外部 save** — 適用のたびにバンドルディレクトリへ同じファイルを書き込み;画像削除・差し替え時は古い `background-image.*` / `picker-background-image.*` を削除。 **後方互換** リリースで UI 設定の形やオンディスク形式を変えるとき: 1. **`settings.json`:** **`version`** を上げる場合は **`parseSettingsExportJson`** に旧版分岐を残す(現状 **v1** / **v2**)。新しい JSON フィールドは任意とし、実行時は **`normalizeUiAppearance`** 等で正規化。 2. **バンドル内の定番ファイル名**(`settings.json`、`background-image`、`picker-background-image`、ディレクトリ名 **`bmxt-ui-settings`**)は安定した契約 — 変更する場合は移行経路と README 更新が必須。 3. **旧バージョンの拡張機能**が書いたバンドル/zip は、新版で **import** または **storage-reload** により読み込めること。 4. 実装者向けルール(テスト・ドキュメント)は **`.cursorrules`** の **UI 設定の永続化** 節を参照。 **メイン一覧(ピッカー)** | 行 | 内容 | |----|------| | **language** | `--japanese` / `--english`(UI 表示言語) | | **edit-picker** | **`on`** — ピッカー列専用の行を追加;**`off`** — ピッカー列は全体外観に従う | | **ime-candidate-help** | **`on`**(既定、**0.8.7 以降**)— 候補メニュー右にコマンド説明(usage)を表示;**`off`** — トークン列のみ | | **prompt-fire** | **`off`**(既定)— 入力/削除エフェクトなし;**`on`** — 入力は炎、削除はキラキラ砕け散り(Firefox: 候補メニュー開中は **menu-lite**) | | **search-legend** | **`text`**(既定)— スコープ凡例をテキストのみ(`[history]`);**`emoji`** — 絵文字のみ(`[⏱️]`);**`text_emoji`** — 併用(`[⏱️ history]`)。アイコン: 履歴 ⏱️、ブックマーク 🔖、ページ 📄、スナップショット 📷️。検索ピッカーおよび `search -list` プレーン出力に適用 | | **host-ui** | **`auto`**(既定)— インストール/実行時判定(**Android → mobile**、それ以外は desktop);**`desktop`** / **`mobile`** — 強制切替。**mobile**(**0.8.2** 以降): 補助キーバー、プロンプト候補のタップ確定/外タップで閉じる。**desktop**: **0.8.0** 相当のキーボード中心(**Esc** / 先頭で **↑**) | | **fg**, **bg-color**, **size**, **font**, **bg-image** | 全体外観(`edit-picker` **off** 時はターミナル+ピッカー共通) | | **fg (picker)** など | **`edit-picker: on`** のみ表示;ピッカー列の上書き(未設定は全体を継承) | | **reset-default** | 確認後、外観を既定に戻して保存 | | **storage** | **拡張機能内**(既定)または**外部フォルダ**(File System Access API);**保存先** 参照 | | **storage-pick-dir** | (外部モード)バンドル用の親フォルダを選び直す | | **storage-reload** | (外部モード)バンドル(`settings.json` + 画像)を読み込み保存 | | **snapshot 保存先** | **設定と同梱**(既定)または **Obsidian Vault**(File System Access API);Vault モード時は **snapshot-vault-pick-dir** で Vault を選び直す | | **export** | zip ダウンロード(`settings.json` v2 + `background-image.*`;設定時は `picker-background-image.*` も) | | **import** | zip を読み込み即保存 | **外観のルール** - **`edit-picker: off`(既定):** **全体**テーマ1つ。背景画像は **ターミナル+ピッカー列の split 行**に1枚で描画し、**両列をまたいで連続**(`html` の `data-bmxt-unified-bg`)。 - **`edit-picker: on`:** ターミナルとピッカー列で別テーマ可。プレビューは **Terminal** と **Picker** を横並び。 **ピッカーキー(setting 列)** | キー | メイン一覧 | 選択サブ一覧(言語・サイズ等) | 詳細/編集(fg・色・font) | |------|-----------|------------------------------|---------------------------| | **↑** / **↓** | ハイライト移動 | ハイライト移動(現在値を事前ハイライト) | — | | **→** / **Enter** | サブ画面へ/即時実行(export/import) | 選択を保存してメインへ | インライン編集開始/Enter で保存 | | **←** | 詳細バー/プロンプト帯へ戻る(他ピッカーと同じ) | メインへ戻る | 編集キャンセルまたはメインへ | | **Esc** | **プロンプト**へ(列は開いたまま) | メインへ戻る | 編集キャンセルまたはメインへ | 全サイドピッカー共通契約: **←** = 戻る/列を離れる · **→** = 進む/選択(`side-picker/interaction/picker-exit-to-detail-bar.ts`、`picker-key-event.ts`)。色(hex)は編集中にリアルタイムプレビュー(未確定のキー入力はストレージへ書かない)。 **実装:** Rust **`cmd/setting.rs`**;TS 適用 **`setting-cui-apply.ts`** / **`setting-cui-ops.ts`** / **`setting-set-args.ts`**;ピッカー→行組み立て **`build-setting-command-line.ts`**;永続化 **`settings.ts`**、**`settings-export.ts`**、**`settings-external-storage.ts`**、**`settings-bundle-layout.ts`**;打鍵 FX **`lib/features/prompt-effects/`**;ピッカースロット **`setting`**(**`lib/features/side-picker/`**);シェル配線 **`bmxt-shell.tsx`** / **`useSettingPickerShell.ts`** / **`apply-ui-action.ts`**。 <a id="session-ja"></a> ### `session`(ターミナルセッション) BMXt は **tmux 風のターミナルセッション**を1つの BMXt ウィンドウ内で扱います。複数の独立したターミナル文脈が存在しますが、**同時に表示されるのは1つだけ**です。非表示のセッションはそれぞれ **ログ行**・**開いているピッカー列**・**nav 起動**・**詳細バー** などの UI 状態を保持します。**コマンド履歴**(`bmxt_cmd_history`)は全ターミナルセッションで **共有** され、`session -switch <name>` のような行を ↑/↓ で呼び出せます。 BMXt ウィンドウが開いている間の保持は **UI ページ**(React)の **`useTerminalSessions`** — **[ターミナルセッション状態(UI が正本)](#terminal-session-state-ja)** 参照。Service Worker の **`run`** は **`session -list`** / **`session -switch`** / **`session -setting-name`** について利用案内のみ。**`session -new`** / **`-next`** / **`-prev`** は **`RUN_CMD`** → **`SessionPatch`** を UI が適用。 | 入力 | 動作 | |------|------| | 裸の **`session`** + **Enter** | 利用案内を表示し **`session `** に復帰(continuation)。Tab で第二トークンを補完。 | | **`session -new [name]`** + **Enter** | Effect **`session_new`**:セッション作成後に切り替え。名前省略時は元セッションの開いているピッカーまたは最後の非 session コマンドから自動命名。 | | **`session -list`** + **Enter** | ターミナルセッションの **プレーン一覧**(ログに `session.row` 行。**`-list` レジストリ**)。 | | **`session -list | browse`** + **Enter** | プロンプト上の **インライン浮動候補**(横並び列ではない)。表示は `*n 表示名`。**↑↓** · **Enter** / **1–9** で **即時切り替え**。 | | **`session -switch`**(または Tab で **`-switch`** 選択) | 全セッションの **名前候補メニュー**を表示(`*表示名`)。**アクティブセッション名の自動挿入はしない**。 | | **`session -switch` 候補メニュー** | **入力で絞り込み**(インクリメンタル **contains**。第二コマンドピッカーと同系)。**Enter** または **Esc** まで表示を維持(絞り込み中も同様)。**Enter** で `session -switch <name>` をプロンプトに挿入(メニュー閉じ)。**もう一度 Enter** で切り替え実行・履歴に完全行を記録。**Esc** でメニュー閉じ。 | | **`session -switch <name>`** + **Enter** | 表示名で直接切り替え(重複名はコマンド行で `名前 (番号)`)。 | | **`session <n>`** + **Enter** | 1 始まりの番号で直接切り替え。 | | **`session -next`** / **`session -prev`** + **Enter** | Effect **`session_next`** / **`session_prev`**。 | | 裸の **`session -setting-name`** + **Enter** | プロンプト上で改名(現在の表示名を事前入力)。 | | **`session -setting-name <name>`** + **Enter** | 1 行で改名。 | **セッションバーとショートカット** - **2 つ以上**のターミナルセッションがあるとき、BMXt ウィンドウ上部に **セッションバー**(番号 + 表示名)が表示されます。クリックで切り替え。 - **Ctrl+←** / **Ctrl+→**(BMXt ウィンドウにフォーカス、**2+** セッション)でアクティブセッションを循環(バックグラウンドのセッションは維持)。 **パフォーマンス(切り替え/作成):** **アクティブ**なセッションと **一度でも表示した** セッションだけがフル **`BmxtShell`** をマウントする。未訪問のバックグラウンドセッションは軽量プレースホルダーのみ。切り替え時は **`activeId`** を楽観的に更新し、変更のないログ配列は再利用して非アクティブペインの再描画を抑える(**`sessions-ui-equality.ts`**)。1 セッションの重いピッカー処理が別セッションのプロンプト入力をブロックしない(セッション id ごとの job runner — **[ジョブ実行](#job-execution-ja)** 参照)。 **実装:** **`lib/features/session/`**(`session-input.ts`、`session-summary.ts`、`session-list-candidate-panel.tsx`、`session-bar.tsx`)、UI は **`bmxt-shell.tsx`** / **`bmxt-terminal.tsx`**、Effect は **`session_new`** / **`session_next`** / **`session_prev`**(**`lib/features/dispatch/handlers/effects/`**)。 <a id="sync-ja"></a> ### `sync`(Family ローカル同期 · 同一 PC · コマンドバス) **0.9.0 以降。** **目標:** ブラウザ/プロファイルごとにユニークな **device id** を付け、**Family**(共有シード/招待。平文の預かり先は作らない)に参加し、同一 PC 上のピア間で低遅延の **WebRTC DataChannel コマンドバス**を載せる。 | 段 | 範囲 | 手段 | |----|------|------| | **6a** | 同一 PC · Chrome ↔ Firefox | Family 招待(`sync -pair` / `-setup`)+ `chrome.storage.local` 名簿 | | **6b** | 同一 LAN · Family | 手入力 / QR 発見。直結優先(将来) | | **6c** | 同一 PC(プロトコルは後から拡張可) | **コピペ/ファイル握手**(`bmxt-rtc1.`)+ **WebRTC DataChannel**(host ICE のみ)。休眠時はメモリキューのみ | | **§11(CLI localhost 待ち受け)** | 同一 PC · CLI 起動時 | **localhost HTTP 待ち受け** `http://127.0.0.1:17653/`(loopback のみ・Family 認証付き hello + offer/answer)。BMXt プロンプト起動で拡張が自動リトライ。コピペ/ファイルはフォールバックとして存続 | **接続後の現状:** ピアへの `sync -ping`。横断 **`tab -list` / `search -list`**(および同じ search スコープ経由の **`bookmark -list` / `history -list`**)を `--device` / `--peers` で。URL 送信は **`tab -send`** / `tab -list | tab -send <deviceId>`(`--close` 可)。ブックマーク送信は **`bookmark -send <deviceId> [--open|--save|--both]`**(タブ open および/またはピア側 **`bookmarks_import`**)。ピア側ブックマーク変更は **`bookmarks_ops`**(create / create_folder / remove / move — 拡張 + CLI)。tab picker の **`:move`** で **リモート窓/タブ/グループ行** を宛先にするとコピー送信(**`move --close`** で移動相当)。同一ピア内のリモート行操作は **`tabs_ops`**(リモートのグループ作成/新窓は未対応)。**端末 CLI peer** は取得元/送信先ブラウザを独立して選べ、**`nav_control`** / **`dom_list`** / **`probe_capabilities`** で peer の **`nav`** / **`dom`** を遠隔駆動できる(**[端末 CLI peer](#terminal-cli-peer-ja)**)。DataChannel 接続中はプロンプト下に接続ピア名の vim 風ステータス行を常時表示。最終の ICE/トンネル開通中は双方が **接続中...** を出しコマンド入力をロックする。**別 PC** で DataChannel 本線を維持するなら大枠はシグナリング(Firebase 等)+ WebRTC(STUN、不通時 TURN)。**Drive / FSA 作業ディレクトリは同期本線ではない。** **Family 一覧追従(`tabs_changed`):** Family 経由のタブ変更(`open_tabs` / `tabs_ops`、および `--close` によるローカル閉じ)が成功すると、**いま接続中の全 Family ピア**へ軽量シグナル **`tabs_changed`** を广播する(送信元自身の購読者にも通知)。ペイロードの **`first`** は **第一コマンド選別符号**(現状は常に **`tab`**。旧ピアが欠落させたら **`tab`** 扱い)。受信側は符号が一致する開中 picker だけを再取得する(tab picker は **`first: "tab"`** のみ反応)。未接続ピアには届かない(次の `--peers` / `--device` 一覧で再取得)。 **既定はローカル。** 任意第三者への `fetch` は禁止(`check:no-fetch`。例外は allowlist された **localhost 待ち受けクライアント**のみ)。CSP **`connect-src`** は **`'self'`** に加え CLI localhost 待ち受けの固定オリジンのみ(`http://127.0.0.1:17653` · `http://localhost:17653`)。Firefox **`data_collection_permissions: none`** は維持。ページ内操作(**nav** / **`dom`** / **`search --page`**)は従来どおり **https のみ**(一般 `http://` DOM は不可。localhost 向け host は接続確立専用)。 **UX:** 初回 Family 参加は **`sync -setup`**(または `-pair`)。握手 UI は **`shared/lib/features/sync/wizard/`** の専用ウィザード(長いログダンプは本線にしない)。**COPY** で Family 招待(`bmxt1.…`)または握手(`bmxt-rtc1.…`)をクリップボードへ。相手はウィザードの貼付欄へコード本体を入れる。握手完了でウィザードは自動で閉じる。切断後は両側 **`sync -connect <peerDeviceId>`** のウィザード往復、**または** CLI localhost 待ち受け起動中に BMXt プロンプトを開き直して Family 認証付き自動再接続。setting picker の sync は案内と表示名編集のみ。 **配置:** **`shared/lib/features/sync/`**(wizard · link status · bus RPC)。Wasm **`UiAction`**(`sync_setup` … `sync_open`、**`sync_bookmark_send`**)を薄い facade 経由で適用。I/O は **スタビライザー**(discovery / peer / bus / memory queue)経由。バス RPC は `tabs_list` / `search_query` / `open_tabs` / **`bookmarks_import`** / **`bookmarks_ops`** / **`tabs_ops`** / **`tabs_changed`**(`first` + `reason`)/ **`probe_capabilities`** / **`dom_list`** / **`nav_control`** など。 **peer 宿主**は **BMXt プロンプト窓**(`bmxt.html`)のみ(offscreen / 専用 peer タブなし)。DataChannel はその窓が開いている間(および明示的再握手で差し替えるまで)維持する。ICE は **ホスト候補のみ**(ローカル経路に公開 STUN/TURN なし)。 **メッシュ:** 接続 UX は「Family 内の生きている誰か1台と握手」のまま。直結後は既存 DataChannel 上の in-band(`mesh_peers` / `mesh_signal`)で **フルメッシュを自動補完**し、どのプロンプトからも他の接続済み peer へ直接届ける(タブ操作のハブ中継はしない)。 <a id="terminal-cli-peer-ja"></a> ### 端末 CLI peer(`hosts/cli`) **現状(todo §10–§20):** **[`hosts/cli/`](hosts/cli/README.md)** の Rust 専用 Family peer バイナリ **`bmxt`** が、拡張と同じ **WebRTC DataChannel バス**(host ICE · `bmxt-rtc1.`)でつながる。ネイティブメッセージング / CDP は使わない。拡張と同一の **BMXt POSIX Profile** I/O(todo §13)· **`bmxt exec`** ワンショット(todo §14)· 追加時ゲート(todo §15)· bookmark / history / ブラウザ間送信パリティ(todo §16)· peer **`aboutbmxt` / `dom` / `nav`** の RPC(todo §17)· 独立 ratatui picker(todo §18)· コマンド正本 + 任意 **`--focus`**(todo §19)· メイン画面候補メニュー(todo §20)。 | 項目 | 現状 | |------|------| | **直接起動** | `bmxt` / `bmxt repl`(**Interactive** · `CommandIo` → プロセス FD)。Family 参加済みなら **localhost 待ち受け** `http://127.0.0.1:17653/`(**127.0.0.1 のみ** bind · Family 認証付き `GET /v1/hello` · `POST /v1/handshake/offer` · `POST /v1/exec`)。 | | **ワンショット(exec)** | 常駐 REPL 待ち受け中に `bmxt exec -- 'sync -status'` 等。常駐側 **NonInteractive**(`POST /v1/exec`)で実行し **stdout/stderr** を印刷、Profile の exit で終了。`| browse` / 握手 ask / zenity は禁止。未常駐は明確なエラー + exit **1**(ハングしない)。 | | **自動接続** | 各ブラウザで BMXt プロンプトを開くと、Family 認証付きで CLI 待ち受けへバックグラウンド再接続(todo §11)。Family 参加情報による認証に失敗した無関係な localhost サービスは無視。コピペ/ファイルはフォールバックとして存続。 | | **プロンプト** | Family 準備済み → **`BMXt>`**(コマンド受付)。未参加 → **`BMXt*>`**。 | | **接続ログ** | 通常のスクロール行(`connection` / `datachannel` / `connected: …`)。`BMXt>` 待ち中の非同期ログは **キュー経由でプロンプト上に排出し描き直し**(crossterm メイン画面。rustyline 不使用)。ICE `checking` は抑制。 | | **ピア切断と終了** | REPL 継続中に最後のピアが切れたときのみ「ピア切断・待ち受け継続」案内(`LANG=ja*` なら日本語)。**`quit` / `exit` / EOF** で **`bmxt` プロセス自体が終了**(「待ち受け継続」は出さない)。 | | **接続(フォールバック)** | `bmxt sync-connect [--offer]`、または REPL の `sync -offer` / `sync -accept`(Enter / `:pick`)。 | | **握手ファイル** | `~/.config/bmxt/` の offer/answer JSON。OSC-8 `file://` 対応時あり。`@path.json` 推奨。 | | **UI 設定 / i18n** | `~/.config/bmxt/bmxt-cli-ui-settings/settings.json`(export v2 同形)。locale: committed → env → `en`。REPL: `setting -list` / `-set`(即保存);`-save` / `-cancel` は閉じる互換エイリアス(todo §12)。設定の `| browse` は CLI 非対応。 | | **コマンド文法** | 拡張と同じ(**`bmxt-core`** · CLI は WASM なし)。例: `tab -list --peers \| browse` · `bookmark -list --device <id>` · `history -list --device \| browse` · `tab -send <deviceId> …` · `bookmark -send <deviceId> --open\|--save\|--both …` · `sync -ping` · `aboutbmxt` / `aboutbmxt -system`。 | | **行編集 / Tab** | メイン画面の行編集(**crossterm** · rustyline 不使用)。履歴(`↑↓` · `~/.config/bmxt/history`)。**Ctrl+R** 逆方向インクリメンタル履歴検索(拡張と同じ: 入力で絞込 · Ctrl+R/↓ で古い一致 · ↑ で新しい一致 · Enter でプロンプトへ挿入のみ · Esc で取消)。**`setting -set prompt-fire on|off`**(即保存・Tab 補完可)でキャレットからの黄色い文字粒子を切替(**`BMXt>` 行と直下オーバーレイのみ**。プロンプトより上の端末ログはそのまま)。候補メニュー閉時の **灰色ヒント**は表示のみ(**Right は確定しない** · キャレット移動のみ=拡張同期)。**Tab** で候補オーバーレイ(空行→第一全件)。**CLI のみ:** 行末で非空の部分トークンを打つと一致時に自動オープン(例: `nav en` → `-enter` · 空 typed は Tab のみ)。**↑↓** / **Tab** 移動 · **Enter** で同じベース `BMXt>` 行を書き換え+次ティア再表示可(**実行しない**)· **Esc** / 先頭で **↑** で Tab まで抑制 · 開時 **prefix** / 開中 **contains** · 置換対象は反転。メニュー閉時の **Enter** で行を実行。list プロデューサーの `-list` 後は **`\| browse`** 等を候補化。既に **`\|`** を打った右辺では `browse` / `close` など consumer 名を補完。 | | **ローカル在庫なし** | CLI に Chrome/Firefox API は無い。裸の `bookmark -list` / `history -list` は接続 peer へ **`search_query`** で fan-out(flat)。`bookmark -add` / `-folder` / `-remove` / `-move` は peer **`bookmarks_ops`**。`history -delete*` は CLI **非対応**(ピア履歴削除は対象外)。backup/restore は拡張のみ。 | | **取得元ピア(`--device`)** | **`--device <id>`** はその1台のみ一覧(ワンショット stdout)。ID なしの裸 **`--device`** はプランとして有効: 単独実行 → exit **2**;Interactive の **`… --device \| browse`** → 接続 peer を番号選択(1台なら自動)→ 既存の URL/タブ picker。**`tab`** / **`bookmark`** / **`history`** / **`search -list`** で同じ。 | | **送信先ピア(open / send)** | flat URL browse(`bookmark` / `history` / peer `search`): **Space** で URL マーク → **Enter** → 送信先ピア一覧 → **Tab** で1台以上マーク → **Enter** で開く(未マーク時はハイライト peer)。**取得元と送信先は独立**(ブラウザ A から一覧し B へ開く/送る)。typed CUI は従来どおり **`tab -send <deviceId>`** / **`bookmark -send <deviceId> [--open\|--save\|--both]`**(パイプ可)。CLI の **`--close`** はローカルタブがないため無視。 | | **タブ picker / `--focus`** | `tab -list --peers \| browse` で **`hosts/cli/src/picker/`** 配下の ratatui picker。picker は typed 行(`tab -activate <tabId> --device <peerId> [--focus]`)を**組み立て**、**`run_line` / `DispatchBundle`** 経由で実行(Enter から直接 `tabs_ops` しない)。browse 開始時の **y/N** で **`--focus`**(peer ブラウザ前面化)を付けられる。oneshot `tab -activate … --focus` も同様。**Enter** で所有 peer へ activate(tab id はブラウザごと)。**q** / **Esc** まで開いたまま。開中は Family **`tabs_changed`**(拡張と同じ `first: "tab"`)で一覧を再取得し、可能なら選択位置を維持。 | | **`aboutbmxt` / `dom` / `nav`(CLI)** | 共有文法: **`aboutbmxt`** / **`aboutbmxt -system`**(welcome URL · CLI 自己診断 + peer **`probe_capabilities`**)。**CLI host 専用**(拡張の共有文法には載せない): ワンショット **`dom -list --device <id> --tab <n> […]`** → **`dom_list`** 経由で stdout。Interactive の **`dom -wizard`** / **`nav -enter`** は peer→tab ワンショット picker のあと、peer ページオーバーレイを **`nav_control`** で駆動(矢印=24px 移動 · Alt+矢印=72px · Enter=`click` · **端末フォーカス維持** · Shift+矢印は端末スクロールのため非使用)。**`nav -exit`** で解除。拡張側の `dom` / `nav` 表示・ローカル仕様は変えない。 | | **メッシュ** | 最初の peer は待ち受けまたは手動握手。以降は in-band メッシュ(CLI は紹介役。タブ操作のハブ中継はしない)。 | | **ビルド** | `cargo build -p bmxt-cli` → `target/debug/bmxt`。 | | **プレビルド** | GitHub Releases の **`cli-v*`** — **[BMXtCLI GitHub Releases](#bmxt-cli-releases-ja)**(バイナリ + `SHA256SUMS.txt`)。 | **コールドスタート(同一 PC):** (1) CLI と各ブラウザで同じ Family に参加 · (2) `bmxt` 起動 · (3) 各 BMXt プロンプト窓を開く → Family 認証付き自動再接続。停止は REPL **`quit`** / **`exit`**。 <a id="bmxt-cli-llm-ja"></a> #### BMXtCLI を LLM で使う モデルは **常駐 1 本 + ワンショット多数** — 稼働中コンテナへの **`docker exec`** と同型(毎回 `docker run` しない)。 | 役割 | コマンド | `:17653` を bind するか | |------|----------|-------------------------| | **常駐(サーバ)** | `bmxt` または `bmxt repl` — **一度だけ**起動して維持 | する(Family 参加済み時) | | **LLM / スクリプト(クライアント)** | `bmxt exec -- '<文法行>'` | **しない** — `POST /v1/exec` のみ | **準備(人またはブートストラップ。LLM の毎ターンではない):** 1. CLI とブラウザで同じ Family に参加し、BMXt プロンプト窓を開いて peer がつながる状態にする。 2. 常駐を **1 本**起動: `bmxt`(または `bmxt repl`)。`BMXt>` と localhost 待ち受け(`http://127.0.0.1:17653/`)を確認。 3. エージェントに `bmxt` バイナリのパスを渡す(例: `target/release/bmxt`)。 **LLM / ツールの各ターン** — サブコマンド **`bmxt exec`** を普通のワンショットシェルコマンドとして実行する(別の `bmxt` / `bmxt repl` を起動しない): ```bash # 文法行は必ず引用符で囲む(シェルが `|` をパイプと解釈しないように)。 ./path/to/bmxt exec -- 'sync -status' ./path/to/bmxt exec -- 'tab -list --peers' ./path/to/bmxt exec -- 'bookmark -list --device <id>' ./path/to/bmxt exec -- 'history -list --device <id>' ./path/to/bmxt exec -- 'tab -send <deviceId> https://example.com --group MyGroup' ./path/to/bmxt exec -- 'bookmark -send <deviceId> --save https://example.com' ./path/to/bmxt exec -- 'help' echo $? # Profile exit: 0 成功 · 1 失敗 · 2 misuse · 127 不明コマンド ``` | チャネル | エージェント向けの意味 | |----------|------------------------| | **stdout** | コマンド結果行のみ | | **stderr** | 診断(usage・エラー・「常駐なし」) | | **exit** | プロセス終了コード — 拡張と同じ BMXt POSIX Profile | **シェル組み込み `exec` ではない:** Gemini CLI などの `run_shell_command` は、「exec = 対話 TTY へのアタッチ/シェル置換」と誤解して拒否することがある。**`bmxt exec` は無関係** — **新しい短命プロセス**が `POST http://127.0.0.1:17653/v1/exec` し、stdout/stderr を出して終了する CLI サブコマンド。常駐 REPL の stdin に張り付く必要はない。必ずフル argv(`bmxt exec -- '…'`)を書き、裸のシェル `exec` は使わない。 **やってはいけないこと(よくある失敗):** - エージェントから **2 本目**の `bmxt` / `bmxt repl` を起動する — door が `Address already in use`(ポート **17653**)になり、バナーは「準備済み」に見えることがある。 - `bmxt exec` 内で `| browse`・握手 ask・zenity を期待する — NonInteractive では拒否(配送・接続は REPL で事前設定)。 - 1 回の `bmxt exec` でコールドスタートから peer まで自己完結させる — 対象外。常駐を上げたままにする。 - 引用なしの `|` をシェルに渡す(`… | browse`)— bash が外部 `browse` を探しに行く。文法行全体を引用する。 **エージェント向けツール定義のヒント(コピー用):** 「常駐 `bmxt` は 127.0.0.1:17653 で待ち受け済み。ブラウザ/Family 操作のたびに、通常のシェルツールで `./path/to/bmxt exec -- '<文法行>'` をちょうど1回実行せよ。これは BMXt ワンショットクライアント(HTTP POST)であり、**シェル組み込みの `exec` ではない**。常駐プロセスの stdin にアタッチする必要もない。`bmxt` / `bmxt repl` は起動するな。裸の `exec` は使うな。」 **この host の対象外:** **端末内**への `nav` / `dom` ページオーバーレイ描画(peer overlay の遠隔操作は todo §17 の範囲)、設定ピッカー browse / FSA、ピア履歴削除、CLI の `bookmark|history -backup/-restore`、ネイティブメッセージング、既定経路での公開 STUN/TURN、ローカル CA / HTTPS CLI、exec IPC の真のインクリメンタル配信、CLI 上のフォルダ/日付ツリー TUI(flat `search_query` のみ · todo §16.7 まで)。契約: [`_context/cli-peer/CONTRACT.md`](_context/cli-peer/CONTRACT.md) · チェックリスト: `_context/todo.md` §11–§20。 <a id="bmxt-cli-releases-ja"></a> #### BMXtCLI GitHub Releases(プレビルドバイナリ + チェックサム) 端末 peer **`bmxt`** を GitHub で配布・検証するための公開マニュアル(メンテ/利用者共通)。バイナリは **git にコミットしない**。[GitHub Releases](https://github.com/UNRsports/bmxt/releases) のアセットとしてだけ公開する。ワークフロー: [`.github/workflows/release-cli.yml`](.github/workflows/release-cli.yml)。 **OS ごとネイティブ:** `bmxt` は Rust ネイティブバイナリ(ELF / Mach-O / PE)。Linux 向けビルドを macOS / Windows では実行できない。OS と CPU に合うアセットを選ぶこと。 ##### リリースアセット | アセット | 対象 | |----------|------| | `bmxt-linux-x86_64` | Linux x86_64(glibc) | | `bmxt-macos-aarch64` | macOS Apple Silicon | | `bmxt-windows-x86_64.exe` | Windows x86_64 | | `SHA256SUMS.txt` | 上記バイナリの SHA-256 ダイジェスト一覧 | ダウンロード URL 例(バージョンを差し替え): `https://github.com/UNRsports/bmxt/releases/download/cli-v0.1.0/bmxt-linux-x86_64` 名前付きアセット向けの「常に最新」固定 URL はない。Releases ページかバージョン付き URL を使う。初回スコープ外: Linux aarch64、macOS Intel(Rosetta で足りる想定)、コード署名 / notarization。 ##### ダウンロードと配置(利用者) 1. [Releases](https://github.com/UNRsports/bmxt/releases) で最新の **`cli-v*`** を開く。 2. 合うバイナリと **`SHA256SUMS.txt` を同じ Release から** 両方ダウンロードする。 3. 次節でチェックサムを照合したうえで、実行権限を付け必要なら `PATH` へ置く: ```bash # Linux / macOS(例) chmod +x bmxt-linux-x86_64 mv bmxt-linux-x86_64 ~/.local/bin/bmxt # または PATH 上の任意の場所 bmxt --help ``` Windows では `bmxt-windows-x86_64.exe` を `bmxt.exe` にリネームしてもよい。`PATH` 上に置く。 **未署名:** Apple notarize / Authenticode 署名はしていない。初回実行で macOS Gatekeeper や Windows SmartScreen が警告することがある。本リポジトリの Releases から取得し、チェックサムが一致する場合にのみ許可すること。 ##### チェックサム(概念と理由) **チェックサム**はファイルのバイト列から計算した指紋(ここでは **SHA-256**)。同一ファイルなら毎回同じ値、1 バイトでも変われば別の値になる。 `SHA256SUMS.txt` により、ダウンロードしたファイルが **その Release に CI が添付したアセットとバイト一致**かを確認できる(破損や差し替えの検出)。作者の善意そのものは証明しない — **同じタグの公式 Releases からバイナリと SUMS の両方を取る**ことが前提。 **検証(Linux):** ```bash sha256sum -c SHA256SUMS.txt --ignore-missing # または 1 ファイルだけ: sha256sum bmxt-linux-x86_64 # 表示されたダイジェストを SHA256SUMS.txt の該当行と照合 ``` **検証(macOS):** ```bash shasum -a 256 -c SHA256SUMS.txt --ignore-missing # または: shasum -a 256 bmxt-macos-aarch64 ``` **検証(Windows · PowerShell):** ```powershell Get-FileHash .\bmxt-windows-x86_64.exe -Algorithm SHA256 # Hash を SHA256SUMS.txt の該当行と比較 ``` ##### メンテ用公開手順 タグ接頭辞は **`cli-v*`**(拡張のストア用タグと分離)。`cli-v` の直後の semver は [`hosts/cli/Cargo.toml`](hosts/cli/Cargo.toml) の **`version`** と一致させる(CI が検査する)。 1. `hosts/cli/Cargo.toml` の `version` を上げる(例: `0.1.0` → `0.1.1`)。 2. 出荷するブランチ(通常 `main`)にコミットする。 3. annotated タグを切って push する: ```bash git tag -a cli-v0.1.0 -m "BMXtCLI 0.1.0" git push origin cli-v0.1.0 ``` 4. GitHub Actions の **Release BMXtCLI** が `ubuntu-latest` / `macos-latest` / `windows-latest` でビルドし、そのタグの Release に 3 バイナリ + `SHA256SUMS.txt` を添付する。 5. Release ページでアセット名・`SHA256SUMS.txt`・少なくとも 1 OS で `bmxt --help` / スモークを確認する。 `target/release/bmxt`(や OS 別コピー)をリポジトリへコミットしない。このワークフローにストア認証(`SUBMIT_KEYS`)や署名鍵を載せない。 手動再実行: Actions → **Release BMXtCLI** → **Run workflow**(YAML の `workflow_dispatch` 設定に従う)。 <a id="picker-ui-ja"></a> ### ピッカー UI(横並び列) プロンプトからリストピッカーを開いたとき、**`lib/features/bmxt-window/bmxt-shell.tsx`** はフォーカス中のセッションリーフを次の横並びにします。 **ターミナル(ログ+プロンプト)** | **tabs**(表示時) | **search**(表示時) | **dom**(表示時) | **setting**(表示時) | **bookmark**(表示時) | **history**(表示時) 同一ペイン内で複数のピッカー列を同時に開けます。セッション状態はリーフごとの **`sessionPickers`**(`tabs` / `search` / `dom` / `setting` / **`bookmark`** / **`history`** スロット)。BMXt **ウィンドウが開いている間**、**開いている列・`paneFocus`・タブピッカーのハイライト/マーク・ツリー開閉**は **UI メモリ**に保持(Service Worker ではない)。ウィンドウを閉じて開き直すと新規状態(**[BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja)**)。列の描画は **`SessionPickerColumns`**(**`PICKER_SLOT_ORDER`**: tabs → search → dom → setting → **bookmark** → **history**)。 **4 層(サイドピッカー)** | 層 | 役割 | 主なパス | |----|------|----------| | ① 親ターミナル | ログ・プロンプト・ピッカー起動/閉じる | `lib/features/bmxt-window/bmxt-shell.tsx`, `bmxt-terminal.tsx` | | ② パネルホスト | 列クロム・青枠・クリックでアクティブ化 | `lib/features/side-picker/panel/picker-panel-host.tsx` | | ③ コマンドラッパ | スロット入口・keyboard 配線 | `url-list-picker-wrapper.tsx`, `dom-picker-wrapper.tsx`, `tabs-picker-wrapper.tsx`, `setting-picker-wrapper.tsx`, **`bookmark-picker-wrapper.tsx`**, **`history-picker-wrapper.tsx`** | | ④ コマンド本体 | フラット行 / 階層行 / 設定 | `PlainTextPickerBody`(search/dom 行), `TabsUrlListPicker` + `TabPickerRowList`(tabs), **`TreePickerBody`**(bookmark / history), `dom/dom-prompt-render.tsx`, `setting-picker-body.tsx` | **共有 keyboard:** **`usePlainPickerKeyboard`**(`lib/features/side-picker/hooks/`)が `/`, `:`, `n`/`N`, **`Esc` → プロンプト**, 縦移動, **Ctrl+←/→** 列ストリップを interaction kernel 経由で処理。**search** / **dom** 行一覧はそのまま利用。**tabs** は **`useTabPickerPlainExtensions`**(`lib/features/tabs/use-tab-picker-plain-extensions.ts`)で bulk/edit・`#` / `Tab`・Shift 範囲・段階 **`Esc`** を追加。**bookmark** / **history** は **`useTreePickerKeyboard`**(`lib/features/side-picker/tree/`)— **←/→** 折りたたみ、**Space** マーク、**Enter** / **→** 操作メニュー、共有の `/` / `n` / `N` / `:nohlsearch`。 **共有リスト chrome:** **`PickerListShell`**(`chrome/picker-list-shell.tsx`)— headline・不可視 IME・リストスロット・検索/コマンドフッタ。**tabs** は **`TabsUrlListPicker`** 経由。**bookmark** / **history** は同一シェル上の **`TreePickerBody`**(フォルダまたは月→日→訪問ツリー)。**search** / **dom** 行一覧は現状 **`PlainTextPickerBody`**(同一 CSS・仮想スクロールあり。将来 `PickerListShell` に寄せ可能)。 **`PickerEntry`(search)** search のヒットは描画前に **`PickerEntry`**(`url`, `source`, 表示行)に正規化します。**`[history]`** / **`[bookmark]`** 行は **`→`** でピッカー内 **開き先** ツリー、結果行の **`Enter`** は **`open_url_new_tab`**(または page ジャンプ)。実装は **`lib/features/search/search-open-destination.ts`**、**`open-search-picker-entry.ts`**、配線は **`bmxt-shell.tsx`**。 **フォーカスと青枠** - **`paneFocus`** がキー入力を受け取る列を表します: `terminal` → `tab` → `search` → `dom` → `setting` → **`bookmark`** → **`history`**(未表示の列は飛ばす)。 - フォーカス中の列に **青い枠**(`.bmxt-split-pane--focused`)が付きます。 - 列が **新しく開いた** とき、または **詳細バー** からフォーカスが移ったとき、キーボードフォーカスと青枠がその列へ移ります。フォーカスされたピッカー列は他列より **左へアニメーション** します(`usePickerColumnFlip`)。 - **Ctrl+← / Ctrl+→** でアクティブセッション内の列を移動します。**2 つ以上**のターミナルセッションがあるときは **Ctrl+← / Ctrl+→** でアクティブセッションも循環します(**[`session`](#session-ja)** 参照)。 - 列をクリックしても同様にアクティブ化されます。 **詳細バー(プロンプト下のモードステータス列)** ピッカーが開いている間(または nav / 翻訳アシストが有効な間)、各モード用の **詳細バー**(`tab` / `search` / `dom` / `setting` / **`bookmark`** / **`history`** / `nav` / `translate`)がプロンプト下に表示されます。**ターミナル**列フォーカス時の共通キー: | キー | 動作 | |------|------| | **`→`**(キャレットが **行末**) | 左端の表示中詳細バーを選択 | | **`←`**(詳細バーから) | プロンプトへ戻る(**nav オーバーレイ ON 中は無効** — 矢印はページカーソル用) | | **`Tab`** / **`Shift+Tab`** | 表示中の詳細バーを循環(**nav オーバーレイ ON 中は停止**) | | **`Alt`**(tab / search / dom 詳細バー) | **`--auto` / `--manual`** page-active を切替(保存される) | | **`Alt`**(nav 詳細バー) | nav オーバーレイ **ON** / **OFF** | | **`→`**(詳細バーから) | 対応するピッカー列へ入る(列は左へアニメーション) | | **`Ctrl+C`**(詳細バーから) | 対応する browse 列を閉じる(**tab** / **search** / **dom** / **setting** / **bookmark** / **history**)。**nav** 詳細バー選択時は **nav を disarm** | nav オーバーレイ **ON** 中はフォーカスを **nav 詳細バーに固定**(typing モードのみ一時例外)。各バーにはモード別ヒントが出ます。配線は **`lib/features/bmxt-window/use-detail-bar-keyboard.ts`** の **`useDetailBarKeyboard`**。 **`Esc` と閉じる操作** - **`Esc` ではピッカー列は閉じません。** 各ピッカーの最上位で **`Esc` を押すと、起動したセッションの BMXt プロンプトへ戻ります**(列は表示されたまま)。 - **タブピッカーのみ:** サブモードは **`Esc` で段階的に解除**(`#` → `:` コマンドモード → `/` 検索 → バルクサブモード → **プロンプトへ**)。詳細は [タブピッカー](#tabs-tab-picker-ja)。 - **列を閉じる**(同一セッションのプロンプトから): | コマンド | 閉じる対象 | |----------|------------| | `tab -exit -list` | タブピッカー(対話的 **`group new`** 含む) | | `search -exit -list` | search リストピッカー | | `dom -exit -list` | DOM リストピッカー(権限確認パネル含む) | | `setting -exit -list` | 設定ピッカー | | **詳細バー `Ctrl+C`** | **bookmark** / **history** 列も閉じる(専用 `*-exit -list` は未実装) | Service Worker の **`run`** は `*-exit -list` で案内行を返すだけで、実際の閉じる処理はウィンドウ UI が行います。 **列の開き方(UI 優先 — `<list> | browse` またはピッカー専用フロー)** | 入力 | 動作 | |------|------| | `tab -list | browse` / `tab -list -url | browse` | タブピッカー列を開く | | `group new`(タブ ID なし) | **group-new** variant のタブピッカー列 | | `search -list` のみ(末尾スペースなし)+ **Enter** | **`search -list `** に復帰(continuation) | | `search -list … | browse` + **Enter** | **search** ピッカー列で検索実行 | | `dom -list … | browse` のみ + **Enter** | mode/flavor 未確定時は `--normal` / `--with` / `--html` / `--react` のオプションメニュー | | `dom -list … [--normal|--with] [--html|--react] … | browse` + **Enter** | DOM 取得後、dom 列を開く | | `setting -list | browse` + **Enter** | 設定ピッカー列を開く(**[`setting`](#setting-ja)** 参照) | | `bookmark -list … \| browse` + **Enter** | **bookmark** ツリーピッカー(フォルダツリー。操作は typed CUI 行) | | `history -list … \| browse` + **Enter** | **history** ツリーピッカー(月→日→訪問。操作は typed CUI 行) | | `translate -on` + **Enter** | 翻訳アシストを有効化(プロンプトにフォーカス維持) | **プレーン `-list`(ターミナルログ・列なし)** — **`tab -list`** / **`dom -list`** / **`search -list`** / **`session -list`** / **`setting -list`** / **`bookmark -list`** / **`history -list`** が既定。対話列は **`<list> | browse`**。出力スキーマは **`bmxt-list/1`**(**[`-list` 出力レジストリ](#list-commands-registry-ja)** 参照)。 **ツリーピッカー(`bookmark -list | browse` / `history -list | browse`)** 共有 chrome: **`lib/features/side-picker/tree/`**(`TreePickerBody` · `useTreePickerKeyboard` · fold/search)。操作は必ず **`submitConstructedLine`**(プロンプトと同じ文法行。ピッカーから `chrome.bookmarks` / `chrome.history` を直接呼ばない)。 | キー / 操作 | bookmark | history | |-------------|----------|---------| | **↑ / ↓** | ハイライト移動 | 同左 | | **← / →** | フォルダの折りたたみ/展開 | 月・日の折りたたみ/展開 | | **Space** | 葉またはフォルダをマーク(混在不可) | 訪問・日・月をマーク(混在不可) | | **Enter** / **→**(行上) | 操作メニュー: open / remove / move / **send**(`--open` / `--save` / `--both` + ピア選択) | 操作メニュー: open / delete / delete-range | | **/** · **n** / **N** · **`:nohlsearch`** | 共有の絞り込み/次マッチ | 同左 | | **Esc** | プロンプトへ(列は開いたまま) | 同左 | | 列を閉じる | 詳細バー **`Ctrl+C`** | 同左 | **設定ピッカー列(`setting -list | browse`)** - 適用はワンショット **`setting …`** 行(`build-setting-command-line.ts`)経由で即保存;プレビューは committed 設定のミラー — **[`setting`](#setting-ja)** 参照。 - 列最上位の **`Esc`** は **プロンプト**へ(列は開いたまま)。閉じるは **`setting -exit -list`**。 - キー配信は **`useSettingPickerKeyboard`**(`lib/features/setting/use-setting-picker-keyboard.ts`)。search/dom の `/` / `n` / `N` モデルとは別。 **プレーンリスト列(search / dom の行一覧)** - **`/`** — インクリメンタル絞り込み。**`Enter`** で検索モード終了(search では行上の **`Enter`** で URL を開く、または詳細ジャンプが可能なときはページ内一致へ移動)。 - **`:`** → **`nohlsearch`** — フィルタと検索ハイライトを解除。 - **`n`** / **`N`** — 結果行上の複数マッチ間を移動(1 行に複数 page ヒットがあるとき)。 - **`→`** / **`←`** — **search のみ:** タブが開いていれば **詳細一覧**、閉じていれば **`[history]`** / **`[bookmark]`** の **開き先**(詳細ヒットの有無は不問)。**`←`** で戻る。詳細・開き先の **`Esc`** は先に結果一覧へ戻る。 - **`Ctrl+←` / `Ctrl+→`** — ペイン内の列ストリップ移動(上記フォーカス節)。 - **dom のみ:** **`--normal`:** **`↑` / `↓`**(または **`j` / `k`**)で **ジャンプ可能な要素行**にフォーカスを移すと、**対象タブがハイライトノードへスクロール**(debounce)。**`--with`:** **`↑` / `↓`** でページスクロール;**`Alt+↑`/`↓`** で要素ハイライト。DOM path のない行はスキップ。 **共通キー(正)** UI の一行ヒントは **`lib/features/side-picker/interaction/picker-headlines.ts`**(search/dom)と **`lib/features/bmxt-core/tabs-picker/headline.ts`**(tabs・モード別)。ショートカットを変えたらこの表も更新する。 | キー / 操作 | search / dom 行一覧 | タブピッカー(`tab -list | browse`) | |-------------|-------------------|------------------------------| | `j` / `k`, `↑` / `↓` | ハイライト移動;search **`--auto`**: 開き済みタブ行を移動時プレビュー | **`↑` / `↓`** のみ — ハイライト移動(`moveHi`);**`--auto`**: 背面ウィンドウ内タブもアクティブ化 | | `Ctrl+↑` / `Ctrl+↓` | **search のみ:** **開き済みタブ**の結果/詳細行のみジャンプ(アニメーションスクロール;**`--auto`** でプレビュー) | — | | `Alt+↑` / `Alt+↓` | **search のみ、`--manual` page-active:** 背面タブをプレビュー(通常の **`↑`/`↓`** ハイライトは維持) | **`--manual` のみ:** 背面ウィンドウ内でハイライトタブをアクティブ化 | | `/` | 検索モード(`@` で URL 部分一致) | 同左(可視行を絞る) | | `/` 中の `Enter` | 検索終了(ハイライト確定) | 検索終了 | | 通常時の `Enter` | search 結果: URL を開くまたは page ジャンプ;search 詳細: ページ内ジャンプ;search 開き先: 選択先へ開く | ハイライトタブをアクティブ化(列は開いたまま) | | `:` → `nohlsearch` | フィルタ・ハイライト解除 | 検索ハイライト解除 | | `n` / `N` | 結果行上の次/前マッチ | 次/前のマッチ行 | | `→` / `←` | search: タブ開=詳細/閉+`[history]`/`[bookmark]`=開き先;dom: プロンプト行末で **詳細バー** | **ウィンドウ** / **タブグループ** 行: 閉じる/開く;**タブ行**: **←** で詳細バー、**→** でアクションメニュー | | `Ctrl+←` / `Ctrl+→` | 列ストリップ(ターミナル ↔ 開列) | 同左 | | `Esc` | プロンプトへ、または search 詳細/開き先 → 結果一覧 | `#` → `:` → `/` → バルク → プロンプト | | `#` / `Tab` | — | マーク付け/複数選択 | | `:` + バルク | — | `move`, `close`, `group`, `nw`, `nt`, `edit`([タブピッカー](#tabs-tab-picker-ja)) | | `Shift+↑` / `Shift+↓` | — | タブ行の `#` 範囲拡張 | | `Ctrl+Shift+↑` / `Ctrl+Shift+↓` | — | ハイライト移動+背面ウィンドウ内タブを強制アクティブ化 | | 列を閉じる | `search -exit -list` / `dom -exit -list` | `tab -exit -list` | **翻訳アシスト(プロンプト / nav typing)** - **`translate -on`** でアシストのみ有効化(横並びエディタ列は開かない)。**`translate -off`** で無効化。nav typing 時はプロンプト下に **原文 / 訳 / 再訳** プレビュー。詳細は **[`translate`](#translate-ja)**。 **新しいサイド列ピッカーの追加** 1. `lib/features/side-picker/session/session-pickers.ts` の `PickerSlotId` とセッション状態にスロットを追加。 2. `lib/features/side-picker/wrappers/picker-slot-registry.tsx` にレンダラを登録(`PICKER_SLOT_ORDER` の順序)。 3. manifest に `<command> -list`(開く)と `<command> -exit -list`(閉じる)を追加(閉じる処理は `bmxt-shell.tsx` が実行;SW は案内のみ)。 4. `bmxt-shell.tsx` の起動処理と `bmxt-terminal.tsx` の `setSessionPickerSlot` を配線。 5. `PlainTextPickerBody` / `UrlListPickerWrapper` / `PickerListShell` を使う場合は `picker-headlines.ts` に headline 定数を追加。 6. tabs 相当の bulk サブモードが要る列は **`PlainPickerKeyboardExtensions`** を拡張し、reducer/実行は機能モジュール側に置く(`use-tab-picker-plain-extensions.ts` 参照)。 ### `dom` - **`dom` 単体 + Enter** で利用案内を表示し、プロンプトを **`dom `** に戻して第二トークン入力を待つ(manifest の `subcommands` がある第一コマンドと同じ continuation)。 - **`dom -list`** + **Enter**(プレーン、既定 **`--normal --html`**)は **`RUN_CMD`** → **`dom_list`** effect → **`ListResult`** プレーン行をログに出力(フル出力+スクロール、末尾サマリー)。scriptable な **https** のみ(必須 **`host_permissions`**。`chrome://extensions` でサイトアクセスをオフにしている場合は再有効化)。 - **`dom -list … | browse`** + **Enter** で DOM ピッカー列を開く(UI 経路)。裸の **`dom -list … | browse`** では mode/flavor 未確定時にオプションメニューを表示することがある(**[列の開き方](#picker-ui-ja)**)。 - **`dom -list [--normal|--with] [--html|--react] [--tag] [<pattern>]`**は直前にフォーカスした通常ウィンドウの**アクティブタブ**を対象に DOM 行を取得する。**`chrome://`** 等はエラー行。 - **`--normal`**(省略時は既定)— 全 DOM ツリー;**`↑`/`↓`**(または **`j`/`k`**)でジャンプ可能行にフォーカス;対象タブが該当ノードへスクロール。**`--manual`** page-active 時は **`Alt+↑`/`↓`** でページジャンププレビュー。 - **`--with`** — **`↑`/`↓`**(または **`j`/`k`**)でページスクロール;ビューポート内要素をフラット表示;**`Alt+↑`/`↓`** でピッカー内の要素ハイライト。**`→`** で機能メニュー(リンク等)。 - **`--html`**(既定 flavor)と **`--react`** はピッカー上のノード表示ラベルの違いのみ。 - flavor の後ろのトークンはすべて連結され、出力行に対する**部分一致**フィルタになる(大文字小文字は ASCII 範囲で折りたたみ)。**正規表現ではない**。パターンを ASCII の `"` / `'` で1重に囲んだ場合は外側を1回だけ除去する。 ### `search` - **`search` 単体 + Enter** で利用案内を表示し、**`search `** へ復帰する。 - **`search -list` のみ**(末尾スペースなし)+ **Enter** → **`search -list `** に復帰(continuation)。**`search -list `** + **Enter** → 横断検索 **`--all`** を **プレーン**出力(**`RUN_CMD`** → **`search_list`**)。ピッカー列は **`search -list … | browse`**。 - **`search -list [--all|--history|--bookmark|--page|--snapshot] [<pattern>]`**(プレーン)は **`search.hit`** 行を **`-list` レジストリ**で出力。**`search -list … | browse`** は search ピッカー列を開く。**`--page`** は開いている **https** タブをライブ走査(上限付き並行は **`page-scan-pool.ts`**)。キャッシュ・snapshot の詳細は英語節 **[`search`](#search-command)** と同様。**0.8.4 以降:** **`--page`** ヒットは ListResult の **`pageMatchesJson`**(`search-page-matches-list-field.ts`)で細分化マッチを渡し、ピッカーからのページ内ジャンプ/スクロールを安定化。 - **Google スプレッドシート(`--page`):** 開いている **`docs.google.com/spreadsheets/…`** タブは Sheets 専用コレクタ(`page-extract/sheets/`)で走査し、ヒットは **セル単位**(A1 形式)。ピッカー詳細行の **Enter**/プレビューで該当セルへジャンプ(`navigate-sheets-to-cell.ts`)。日本語など非 ASCII の針も通常ページと同じ部分一致経路(ロケール専用の別経路はない)。 - プロンプトの **`Ctrl+C`** または **`search -exit -list`** で、当該セッションの走査中 **`search-list`** ジョブをキャンセルできる(**[ジョブ実行](#job-execution-ja)**)。 - 結果一覧で **`→`** は、該当 URL のタブが **開いていれば** 細分化ヒットがある行のみ **詳細一覧** へ。**タブが開いていなければ**(詳細ヒットの有無を問わず)**`[history]`** / **`[bookmark]`** 行は **開き先** へ。**`←`** / **`Esc`** で 1 段戻る。結果行の **`Enter`** は新規タブ(または page ジャンプ)。詳細行の **`Enter`** はタブ前面化して該当箇所へスクロール(Sheets ならセルへジャンプ)。開き先行の **`Enter`** で選択先へ開く。 - **`--auto` page-active:** **`↑` / `↓`**(および **`j` / `k`**)で開き済み結果行と詳細のページ内ヒットをハイライト移動時にプレビュー(詳細は debounce を長くし、温めた Range セッションを再利用して GitHub 級 DOM でも固まりにくくする)。**`Enter`** は従来どおりジャンプ/前面化。 - **開き済みタブ行のみ:** **`Ctrl+↑` / `Ctrl+↓`** で URL が既に開いている行だけジャンプ(リストはアニメーションスクロール)。**`--auto`** page-active ではジャンプごとにプレビュー。 - **`Alt+↑` / `Alt+↓`**(**`--manual`** page-active のみ): 通常の **`↑`/`↓`** ハイライトを変えず、背面タブをプレビュー。 - **詳細バー**(search ピッカー表示中のプロンプト下ステータス列): キャレットが **行末** のとき **`→`** でバーを選択、**`←`** でプロンプトへ、**`Tab`** / **`Shift+Tab`** で詳細バーを循環、**`Alt`** で **`--auto` / `--manual`** page-active を切替(**`chrome.storage.local`** に保存)、詳細バーから **`→`** で search ピッカー列へ。開き済みタブの結果行には **ファビコン** を表示(取得可能な場合)。 - パターンの扱いは `dom` と同様(大文字小文字を区別しない部分一致、v1 は正規表現なし、ASCII 引用符の除去)。**`search -list … --page`** は非破棄の **https** タブを**実行時に**走査する(タブごとの可視 `innerText`、Sheets タブはセル文字。**search キャッシュには本文を保存しない**)。宣言済みの必須 https **`host_permissions`** を使う(`chrome://extensions` でサイトアクセスをオフにしている場合は再有効化)。 <a id="bookmark-command-ja"></a> ### `bookmark` ブックマークの **CRUD**、Family 送信、ローカル ZIP バックアップ/復元用の第一コマンド。ピア横断の発見は引き続き **`search -list --bookmark [--device|--peers]`**(または同じ `search_query` 経路の **`bookmark -list --peers`**)。 | 形式 | 効果 | |------|------| | `bookmark -list [--folder <id>] [--device <id>\|--peers]` | ローカルは `open_plain_list` のフォルダツリー(`bookmark.folder` / `bookmark.item`)。`| browse` → ツリー picker(open / remove / move / send)。ピアは `search_list --bookmark`。 | | `bookmark -add <url> [--title …] [--parent <id>]` | HostEffect `bookmark_create`(CLI から接続ピアへは **`bookmarks_ops`**) | | `bookmark -folder <title> [--parent <id>]` | HostEffect `bookmark_create_folder`(CLI → **`bookmarks_ops`**) | | `bookmark -remove <id…>` / `… \| bookmark -remove` | HostEffect `bookmark_remove`(パイプは `bookmark` / `bookmark.folder` 行の `bookmarkId` が必要。CLI → **`bookmarks_ops`**) | | `bookmark -move <id…> --parent <id> [--index n]` / パイプ | HostEffect `bookmark_move`(CLI → **`bookmarks_ops`**) | | `bookmark -send <deviceId> [--open\|--save\|--both] …` / パイプ | UiAction `sync_bookmark_send`。**`--open`** → ピア `open_tabs`(既定)。**`--save`** → ピア `bookmarks_import`。**`--both`** は両方(各側を報告)。ピッカーの send モードも同じフラグ → ピア選択。 | | `bookmark -backup` / `bookmark -restore` | UiAction ZIP(`bmxt-browser-backup/` 配下、`manifest.json` + `bookmarks.json`)。復元は `bookmarks.create` で再作成。拡張のみ(CLI 非対応)。 | `tab -send` は **URL を開くだけ**。ピア側にもブックマークを残すときは **`bookmark -send`** を使う。ツリーピッカーのキーと閉じ方: **[ピッカー UI — ツリーピッカー](#picker-ui-ja)**。 <a id="history-command-ja"></a> ### `history` 履歴の **一覧**・**削除**・ZIP バックアップ用の第一コマンド。ピア横断一覧は **`search -list --history [--device|--peers]`**(または同じ `search_list` 経路の **`history -list …`**)。 | 形式 | 効果 | |------|------| | `history -list [<pattern>] [--device <id>\|--peers]` | ローカルは `open_plain_list` の日付ツリー(月→日→訪問)。`| browse` → ツリー picker(open / delete / delete-range)。ピアは `search_list --history`。 | | `history -delete <url…>` / `… \| history -delete` | HostEffect `history_delete_url`(拡張ローカルのみ) | | `history -delete-range --from <iso\|ms> --to <iso\|ms>` | HostEffect `history_delete_range`(拡張ローカルのみ) | | `history -backup` | UiAction ZIP(`manifest.json` + `history.json`)。拡張のみ。 | | `history -restore [--as-bookmarks]` | UiAction ファイル選択。ブラウザ履歴 DB は **書き換え不可**(`chrome.history` に insert API なし)。既定は export 形の読込;**`--as-bookmarks`** はブックマーク作成。拡張のみ。 | ピア側の履歴 **削除** は対象外(CLI は misuse / unsupported)。ツリーピッカーのキーと閉じ方: **[ピッカー UI — ツリーピッカー](#picker-ui-ja)**。 <a id="snapshot-ja"></a> ### `snapshot`(`snapshot -save`) scriptable な **https** タブを **YAML frontmatter** 付き **Markdown snapshot**(`title` / `url` / `savedAt` / `source: bmxt`)として保存し、**Obsidian** 等と連携できる形式にします。Service Worker の **`run`** は usage のみ;**`snapshot -save`** は **`bmxt-shell.tsx`** が UI 処理します。 | 入力 | 動作 | |------|------| | 裸の **`snapshot`** + **Enter** | 利用案内を表示し **`snapshot `** に復帰(continuation)。Tab で **`-save`** を補完。 | | **`snapshot -save`** + **Enter** | **直前にフォーカスした通常ウィンドウのアクティブタブ**を保存(タブ解決は **`dom -list`** と同系)。 | | **`snapshot -save <tabId>`** + **Enter** | 指定 tabId を保存。 | **tabs ピッカー**のアクションメニュー(`:snapshot`)からも起動できます。 **保存先**(**`setting -list`** で設定。draft 待ちではない): | モード | 場所 | |--------|------| | **設定と同梱**(既定) | 設定が内部のとき **`chrome.storage.local`**(`bmxt_snapshots_v1`);外部モードのとき外部設定バンドル内 **`bmxt-ui-settings/snapshots/`** | | **Obsidian Vault** | ユーザー指定 Vault → Vault 内 **`BMXt/snapshots/`**(設定バンドルとは独立) | **注意:** - **アンインストール:** 既定(設定と同梱+設定が内部)では snapshot は **`chrome.storage.local`** のみにあり、**拡張機能をアンインストールすると消える**。**設定の外部モード**や **Obsidian Vault** へ書いたものはディスク上に残る。 - **アプリ内の管理機能は未実装:** コマンドは **`snapshot -save`** のみ(編集・削除なし)。**`search -list --snapshot`** は検索のみで管理はしない。編集・削除したい場合は **Obsidian Vault** または **設定の外部モード**(`bmxt-ui-settings/snapshots/`)などファイルとして触れる保存先にし、BMXt 外で Markdown を管理する。 保存済み snapshot は **`search -list --snapshot`**(**`--all`** に含む)で検索できます。 **実装:** **`lib/features/snapshot/`**(`snapshot-save-tab.ts`、`snapshot-markdown.ts`、`snapshot-storage.ts`、`snapshot-vault-store.ts`)、search 用 Effect **`search_snapshot`**、設定キー **`bmxt_snapshot_storage_v1`**。 <a id="tabs-man-tabs-ja"></a> ### `tab` (subcommands) - **`tab` 単体**は利用可能オプションを表示し、続けて **`tab `**(末尾スペース付き)へ入力を復元します。 - **`tab -list` / `tab -list -url`**:タブツリーをログにプレーン出力(**`RUN_CMD`**)。 - **`tab -list | browse` / `tab -list -url | browse`**:タブピッカー列を開く(`-url` で URL 行付き)。 - **`tab -exit -list`**:当該セッションのタブピッカー列を閉じます。 - **`tab -setting -page-active --auto | --manual`**:ハイライト移動時のタブプレビューを設定。**`--auto`**(既定): ハイライト移動で背面ウィンドウ内のタブをアクティブ化。**`--manual`**: **Alt+↑↓**(または **Alt** 押下)時のみアクティブ化。**Enter** は従来どおりハイライトタブへジャンプしてウィンドウを前面化。設定は **`chrome.storage.local`** に保存。タブピッカー表示中はプロンプト下の **tabs** ステータス列に現在モードを表示。 - **`tab -nowurl`**:現在タブの URL を表示します。 - **`tab -moveurl <url>`**:該当 http(s) タブをアクティブにしウィンドウを前面化。一致がなければ新規タブで開く。プロンプト上で `tab -moveurl ` の直後に **Tab** を押すと、開いている http(s) タブの URL を補完候補として循環します。 - **`tab help`**:`tab` のマニュアル節を表示(第二コマンド候補メニューにも掲載)。 <a id="tabs-tab-picker-edit-ja"></a> ### タブピッカー `:edit`(ウィンドウ名・タブグループ) `:edit` は **`tab -list | browse`** / **`tab -list -url | browse`** で開いたタブピッカー内でのみ使えます。**`:`** → **`edit`** → **`Enter`**(短縮別名なし。`Tab` で補完候補を循環し、対象がウィンドウ行またはタブグループ行のとき `edit` が候補に入る)。 **有効な対象** - **ウィンドウ行 1 つ**、または **タブグループ行 1 つ**(Chrome の実グループ)。 - **タブ行**および **未グループのタブ**(グループ見出しなし)は対象外。 - ウィンドウ/グループ見出しに **`#`** を付けるか、**`#` なし**でその行をハイライトして確定(未マーク時はハイライト行が自動マーク)。 選択が不正(タブのみ、複数ウィンドウ/グループなど)のときはログに **`error:`** 行が出て edit モードは開きません。 **ウィンドウ — 表示名** - **[EDIT] window name** を開く。保存済みのカスタム名、なければそのウィンドウの **アクティブタブタイトル** を初期値にする。 - **`Enter`** で **`chrome.storage.local`** に保存(ウィンドウごとの表示名。空文字でカスタム名を消し、一覧は Chrome 既定に戻る)。 - **`Esc`** でキャンセルし一覧へ戻る。 **タブグループ — メニュー → リネームまたは Chrome 操作** - **[EDIT] operation menu** を **`↑`/`↓`** + **`Enter`** で操作: - **Rename** — タイトル欄。**`Enter`** で **`chrome.tabGroups.update`**。**`Esc`** でメニューへ戻る。 - **Ungroup tabs** — **`Enter`** で即実行(`chrome.tabGroups.ungroup`)。 - **Delete tab group** — **`Enter`** で即実行(グループ内タブを閉じる)。 - 成功後はマーク解除、edit 終了、行を再取得。 <a id="tabs-tab-picker-ja"></a> <a id="tabs-tab-picker-impl-ja"></a> ### タブピッカー(`tab -list | browse` / `tab -list -url | browse`) **ツリー構造** - 行は階層表示: **`[ウィンドウ]`** → **`[タブグループ]`**(Chrome の実グループのみ)→ **タブ行**。**タブ行**にはページ URL から解決できる **ファビコン** を表示します。 - Chrome グループに属さないタブは **ウィンドウ行の直下**に並びます(「(グループなし)」見出し行はありません)。 - **初期状態はすべて展開**。**←** でハイライト中の **ウィンドウ** または **タブグループ** 行を閉じ、**→** で開きます。**タブ行**では **←** で詳細バーへ、**→** でアクションメニューを開きます。 - 開閉状態は **BMXt ウィンドウが開いている間** UI メモリに保持(ウィンドウを閉じると破棄 — [BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja))。 **移動とバルク操作** - 起動時は、直前にフォーカスしていた通常ブラウザウィンドウのアクティブタブ位置にハイライトを合わせます。 - `j`/`k`(または `↑`/`↓`)で移動、ピッカー内の `Tab` でハイライト中タブの `#` を付け外しします(複数選択可)。**Shift + `↑`/`↓`** で、ハイライトの移動に合わせて**連続したタブ行に `#` を一括付与**します(一覧上でアンカー行から現在行までの範囲)。**`#` が付いたタブは、同一ウィンドウ内では Chrome 本体のタブバー上でも複数選択(`chrome.tabs.highlight`)に合わせて表示**されます(BMXt を前面にしたまま操作できます)。 - **バルク操作の選択**: `:` を押してコマンドラインを開き、コマンドを入力して `Enter` で確定します。`Tab` でプレフィックスに一致する候補を循環補完できます。`#` が付いたタブがない場合、コマンド確定時にハイライト中のタブが自動的に `#` でマークされます。 - タブ行: `move`(`m`)、`close`(`c`)、`group`(`g`)、`newwindow`(`nw`) - ウィンドウ行: `close`(`c`)、`newtab`(`nt`)、`edit` - グループ行: `move`(`m`)、`close`(`c`)、`newwindow`(`nw`)、`edit` - `:` コマンドモードでは、コマンド未入力のまま `Tab` または `Enter` を押すと、現在の対象(タブ/ウィンドウ/グループ)に応じた利用可能コマンドを薄いプレースホルダーで表示します。 - **[MOVE]** の宛先はマーク種別で変わります: - **タブに `#`:** `↑`/`↓` で **タブ間の挿入スロット**(紫のギャップ線。タブ行そのものではない)を選び `Enter`。**タブ行**=その直前、**グループ行**=グループ先頭タブの直前(参加)、**ウィンドウ行**=ウィンドウ末尾。スロットが **グループ内** なら参加、**未グループ** なら外れます。組み立て行は `#t:… \| move --window … [--before-tab …]` / `--group` / `--ungroup`。 - **タブグループ行に `#`:** 宛先は **ウィンドウ/グループ見出し行のみ**(タブ間ギャップなし。↑/↓ は見出し間をスナップ)。**グループ見出し**=そのグループ末尾へ追加、**ウィンドウ見出し**=マークした Chrome タブグループを**単位移動**(`chrome.tabGroups.move` をグループごとに逐次)。組み立て行に **`--as-group <gid>…`** を付与(宛先 `--group` / `--ungroup` と併用不可)。 - **[CLOSE]** は `Enter` で `#` タブを一括で閉じます。**[GROUP]** は `↑`/`↓` でグループ選択後、`Enter` で `#` タブを追加します(**新しいグループ** を選ぶと名前・色パネルへ。**`Enter`** で作成確定、**`Esc`** でタブ一覧へ、**`Tab`** で名前↔色)。**[NEW WINDOW]** は `Enter` で実行;**グループ行マーク時**は組み立て行に **`--as-group <gid>…`** を付け、新規窓でもグループを維持します。**[NEW TAB]** は `Enter` で URL 入力パネルへ進みます。 - **アクションメニューの対象一覧:** 選択タブが Chrome タブグループに属する場合、連続する同一グループの直前に **グループ名ヘッダ**(グループ色アクセント付き)を表示し、その下にタブ行を並べます。 - **対話的 `group new`**(プロンプトで tabId なし): **group-new** variant のタブピッカー列を開く — `Tab` でタブ選択、**`Enter`** で **[GROUP]** → 新しいグループ と同じ名前・色パネルへ、再度 **`Enter`** で作成。 - `/` でインクリメンタル検索(`@` 接頭で URL 部分一致)。絞り込み中は **フィルタ欄にキーボードフォーカスが残り**、一覧側に入力フォーカスが移らない。**`Esc`** の解除順は `#` 全解除 → `:` コマンドモード終了 → `/` 検索終了 → バルクサブモード終了 → **BMXt プロンプトへ**(列は開いたまま)。列を閉じるには **`tab -exit -list`**。 - バルクモードでない `Enter` は、ハイライト中タブをアクティブ化して対象ウィンドウを前面化します(ピッカーは維持)。 ### タブピッカー — 実装(キー配信とリデューサ) **入口:** **`TabsPickerWrapper`** → **`useTabPickerController`** → **`TabsUrlListPicker`**(`PickerListShell` + **`TabPickerRowList`** + bulk/edit パネル)。**`TabPickerOverlay`** は同一スタックの非推奨エイリアス。 - **ウィンドウキャプチャ**: **`usePlainPickerKeyboard`** が **`useWindowKeydownCapture`** で **↑/↓**(tabs ピッカーは矢印のみ、**`j`/`k` なし**)、`/`, `:`, `n`/`N`, **Enter** を拾います(リストクリック後など IME `textarea` 以外にフォーカスがあっても動作)。textarea の **`onInputKeyDown`** でも同じチェーンを実行します。 - **tabs 固有キー**: **`useTabPickerPlainExtensions`** が **`PlainPickerKeyboardExtensions`** を供給 — バルク時の縦移動、Shift 範囲、Ctrl+Shift プレビュー、段階 **`Esc`**, **`Tab`** / `#`, **`:`** バルクコマンド(`use-tab-picker-plain-extensions.ts` の `parsePickerCommand`、短縮例 `m` → `move`、**`edit`** はエイリアスなし)、tabs 向け **Enter** 意図(**新規グループ meta** の名前・色確定は window capture の **`onNormalEnter`** 経由)。配線は **`use-tab-picker-keyboard.ts`**。 - **リデューサ(TypeScript)**: 状態遷移は **`runTabsPickerReduce`**(`lib/features/bmxt-core/tabs-picker/reducer.ts`)。イベント/状態は **`kind: "moveHi"`** や **`visibleLen`** など **camelCase**。 - **Shift + 矢印**: **`moveHi` の直後に `selectRange`** を **`applyReducedStateSequence`** で **1 チェーン**にまとめています。同一ハンドラ内で `setState` を二度叩くと、2 回目が **古い `hi`** を見て範囲が正しく伸びないことがありました。 - **グループ単位 MOVE / NEW WINDOW**: **`markedKind === "group"`** のとき宛先ナビは **`move-dest-navigable.ts`**(見出しのみ)。スロット解決は **`resolve-move-insert-slot.ts`** の **`headerDestMode`**。組み立て行は **`build-picker-command-line.ts`** が **`--as-group`** を付与。Effect **`tabs_move`** / **`tabs_new_window`** は **`group_ids`** を受け **`moveTabGroupsAsUnits`**(`chrome.tabGroups.move` を逐次)を呼ぶ。コア構文: **`move_cmd.rs`** / **`new_window.rs`**。 - **`:edit` UI**: 対象判定・エラー文は **`lib/features/tabs/resolve-edit-entry.ts`**。パネルと Chrome/storage 副作用は **`use-tab-picker-edit.ts`**、**`controller/edit-actions.ts`**、**`extension-storage/window-display-names.ts`**(仕様は [タブピッカー `:edit`](#tabs-tab-picker-edit-ja))。 - **ピッカー表示中のプロンプト**: **`lib/features/bmxt-window/bmxt-terminal.tsx`** でピッカー表示中はメイン textarea の **↑/↓/j/k をコマンド履歴に使わない**ようにし、ピッカーと競合しないようにしています。 <a id="url-lines-ja"></a> ### URL(行全体が `http` / `https` で始まる場合) - `https://example.com` — 新規タブで開く - `https://example.com .` — 現在のタブ(前面ウィンドウのアクティブタブ)で開く - `https://example.com -nw` — 新しいウィンドウで開く <a id="command-execution-architecture-ja"></a> ## コマンド実行アーキテクチャ(現状) **一覧の真実**は **`manifest/bmxt-codegen.json`**(`commands[]`・`effects[]`・**`uiActions[]`**)です。**`pnpm run codegen`** で TS メタデータ(`table.gen.ts`・`effect-types.ts`・`ui-action-types.ts`・`apply-dispatch.gen.ts`・補完ヘルパ)と Rust 生成物(`crates/bmxt-core/src/generated/`・**`ui_action.rs` 含む**)を再生成します。コマンド意味論の **`run`** は **`crates/bmxt-core/src/cmd/*.rs`**(WASM)、Chrome 副作用は **`lib/features/dispatch/handlers/effects/`**、UI は **`apply-ui-action.ts`**(`UiActionIR`)。Host IR 契約は **`bmxt-host/2`**(`lib/features/command-line/inter-command/`)。TS ホストのコマンド名意味分岐は **`pnpm run verify:host-blind`** で検査します。 **ホスト / 拡張 URL 境界** | 層 | 担当 | |----|------| | **コア(WASM + 共有 TS)** | `HostEffect` / 計画 — ブラウザ非依存 | | **ホストアダプタ** | Chromium の `chrome.*` と Firefox(`browser.*` / `chrome.*`)を同一 IR で接続(**0.8.7 以降**) | | **拡張ページ URL** | **`lib/features/extension-url/`** — `chrome-extension:` **と** `moz-extension:`。ランタイムは **`chrome.runtime.getURL`** / **`browser.runtime.getURL`** を優先。信頼判定・E2E・テストは **`extensionPageUrl` / `parseExtensionPageUrl`**(**`chrome-extension://…` の直書きはしない**) | | **特権 SW メッセージ** | **`isTrustedBmxtUiSender`**(`lib/features/extension-permissions/`)— いずれの拡張プロトコルでも `bmxt.html` のみ | **実行境界:** ``` Enter / RUN_CMD → ensureBmxtCore → WASM run / classify → { lines | effects | ui | msgs } msgs → TS expand-msgs(任意の promptPrefix → setContinuationPrompt) effects → Chrome 執行 ui → applyUiAction(描画/状態適用のみ・文法再解釈しない) ``` WASM 予算: **`bmxt_core_bg.wasm` ≤ 400 KiB**。 <a id="prompt-semantics-sot-ja"></a> ### プロンプト意味の正本(Rust) **現状(`_context/todo.md` §14):** Phase **A**–**D** は **完了**。固定トークンの Tab/IME 候補は WASM **`complete(line, cursor)`**、compound eligibility は WASM **`compound_segment_eligibility`**。ホストはライブ UI オーバーレイ(browse producer、`dom -list` 残オプション、page-active モード、IME フィルタ UX)のみ。**`manifest/bmxt-candidate.json`** は **設計・検証用カタログ**(固定トークンのランタイムエンジンではない)。 | 担当 | 責務 | |------|------| | **Rust(WASM)** | usage/error の **キー**、Enter **continuation**(`promptPrefix`)、不完全 `-setting` 計画、**`complete`**、compound eligibility、help セクションキー列、プロンプトに「何を出すか」の決定 | | **TypeScript** | `expand-msgs` / React 描画、不透明 `applyUiAction`、Chrome `handlers/effects/*` | | **ホストのみ許容** | ライブ UI 状態(ピッカー開閉、page-active / 翻訳ペアの現在値=センチネル埋め)、Chrome 列挙データ / 結果→msgs 対応、IME のフィルタ UX | **Enter continuation:** 単独第一トークン(例 `tab`)→ Rust の `msgs` + `promptPrefix: "tab "` → ホスト `setContinuationPrompt`。生成ヘルパ `continuationPromptAfterLoneFirstToken` は **IME 用**のみ(Enter / compound eligibility では使わない)。 **不完全 `-setting`:** 例 `tab -setting` / `dom -setting` / `translate -setting` → msgs + prefix;適用完了 → フィールド付き UiAction。対応表: **`_context/map_command.csv`**。コマンド間経路: **[コマンド間語彙](#inter-command-vocabulary-ja)**。 **Tab / IME 固定トークン:** WASM **`complete(line, cursor)`**(codegen `subcommands` の第一〜第三段)。`resolveImeTokenPicker` は WASM 準備後にこれを呼び、ホスト側フィルタ UX とライブオーバーレイを載せる。**キャレットオフセット(0.8.3 以降):** JS プロンプトは **UTF-16** インデックス、Rust/`complete` は **UTF-8** バイトオフセット — ホストが **`lib/features/bmxt-core/utf16-utf8-offset.ts`** で変換してから WASM に渡す(CJK でプロンプト表示が消える不具合の修正)。 開発: Rust + **`bash scripts/install-wasm-pack.sh`**(wasm-pack **0.15.0** 固定)、**`pnpm run build:wasm`**、**`cargo test -p bmxt-core`**。Golden Effect 契約: **[`scripts/fixtures/dispatch/effects.json`](scripts/fixtures/dispatch/effects.json)**(説明は **[`scripts/fixtures/dispatch/README.md`](scripts/fixtures/dispatch/README.md)**)。 タブピッカー計画は WASM 経由の **`runTabsPickerReduce`** 等(詳細は **`tab`** の **タブピッカー — 実装**)。 **UI ホスト:** Enter は WASM 分類が先(`useCommandDispatch`)。コンテキスト専用ゲート(外部設定復旧・session 名入力)のみ TS 側に残します。compound/pipe の**計画**は WASM、**実行ループ**は TS。Effect 系は従来どおり **`RUN_CMD`** → **`SessionPatch[]`**(**[ターミナルセッション状態](#terminal-session-state-ja)**)。 <a id="inter-command-vocabulary-ja"></a> ### コマンド間語彙(閉じた IR) コマンド同士は**名前で直結しない**。連絡は次の**閉じた語彙**のみ: | 経路 | スキーマ / 型 | 役割 | |------|----------------|------| | **DispatchBundle** | `lines` \| `effects` \| `ui` \| `msgs` | Rust → ホスト(`run` / `classify` の計画) | | **ListResult** | `bmxt-list/1` | プレーン `-list` / ピッカー投影 | | **BmxtRuleStream** | `bmxt-rule/1` | パイプ `|` 段間受け渡し(ListResult から変換) | | **終了状態** | `0` / `1` / `2` / `127` | compound `&&` / `||` / `;` | **索引(コード):** `lib/features/command-line/inter-command/` — 種類マップ・`preferredCommandAddPath()` など。 **原則:** 既存の Effect / UiAction / ListRecordKind / pipe `acceptsKinds` の**再利用を優先**。足りないときだけカタログを**拡張**(**[コマンド追加手順](#command-add-procedure-ja)** と **`manifest/templates/`**)。 <a id="list-commands-registry-ja"></a> ### `-list` 出力レジストリ **プレーン**の各 `-list` は次の単一パイプラインを共有します(POSIX 風: 1 スキーマ・1 整形・プラグイン式 producer): ``` トークン行 → matcher(registry)→ ListResult(bmxt-list/1)→ プレーン行(+ サマリー) ↓ bmxtRule ストリーム(bmxt-rule/1)→ パイプ consumer(例: close) ``` | モジュール | 役割 | |-----------|------| | **`lib/features/bmxt-rule/`** | **bmxtRule** コマンド間ストリーム(`BmxtRuleStream`、検証、NDJSON、`from-list-result` adapter) | | **`manifest/bmxt-rule.json`** | kind カタログとフィールドヒント(拡張可能・規格の単一ソース) | | **`lib/features/bmxt-candidate/`** | **bmxtCandidate** プロンプト候補メニュー規格(catalog loader、validate、provider registry) | | **`manifest/bmxt-candidate.json`** | 候補メニュー profile、compound/pipe コンテキスト、コマンド zone、data source 一覧 | | **`lib/features/command-line/list-output/`** | `ListResult` / `ListRecord` 型、`formatListPlainLines`、レガシー TSV、サマリー行 | | **`lib/features/command-line/list-commands/`** | matcher 表、`matchPlainListCommand`、`tryRunPlainListCommand`、`runPlainListForCommandId`(重い plugin は dynamic import) | | **`lib/features/<feature>/*-list-command.ts`** | コマンド別 plugin(`fetchListResult` / `formatPlainLines`) | | **`lib/features/<feature>/*-list-result.ts`** | ドメインデータ → `ListRecord[]` | | **`lib/features/dispatch/handlers/effects/*-list.ts`** | SW: `runPlainListForCommandId` の薄いラッパ | **プレーン `-list` の実行経路:** | コマンド | プレーン | `<list> | browse` | |---------|----------|------------| | `tab -list` | `RUN_CMD` → `tabs_list` | UI(`handle-tabs-list.ts`) | | `dom -list` | `RUN_CMD` → `dom_list` | UI(`handle-dom.ts` → ピッカー列 + `dom-list` ジョブ) | | `search -list` | `RUN_CMD` → `search_list` | UI(`handle-search.ts` → `search-list` ジョブ) | | `session -list` | UI → `tryRunPlainListCommand` | UI インライン候補 | | `setting -list` | UI → `tryRunPlainListCommand` | UI 設定ピッカー列 | **パイプ:** `lib/features/command-line/pipe/run-pipe-chain.ts` が **`ListResult`** を取得し **`bmxtRule`**(`bmxtRuleStreamFromListResult`)に変換してセグメント間受け渡し。consumer は **`pipe/consumers/registry.ts`** に登録(**`browse`** / **`open`** / **`jump`** / **`move`** / **`new-window`** / **`back`** / **`forward`** / **`reload`** / **`close`** / **`tab -send`** / **`bookmark -remove`** / **`bookmark -move`** / **`bookmark -send`** / **`history -delete`**。種別互換チェック付き — ナビ/close/`move`/`new-window` は **`page.open`**;**`browse`** は producer の **`ListResult`** も必要;**`open`**/**`jump`**/タブ一括は CUI 同等化)。 <a id="bmxt-rule-ja"></a> ### bmxtRule(コマンド間ストリーム) **bmxtRule** は **パイプ**および将来のコマンド間受け渡し用の構造化ストリーム規格です。スキーマ ID: **`bmxt-rule/1`**。カタログ: **`manifest/bmxt-rule.json`**。 各レコードは **拡張可能な entry 配列**(`[key, value]` の列)を持ち、kind ごとに属性の増減があっても古い consumer を壊しにくくします。 | kind | ドメイン | 主なキー | |------|----------|----------| | **`page.open`** | 開いている http(s) タブ | `url`, `pageTitle`, `tabId`, `windowId`, `groupId`, `active`, `favicon` | | **`page.window`** / **`page.group`** | タブツリー容器 | `windowId`, `focused`, `label`, … | | **`bookmark`** | ブックマーク | `url`, `pageTitle`, `bookmarkId`, `parentId`, `dateAdded`, … | | **`bookmark.folder`** | ブックマークフォルダ | `pageTitle`, `bookmarkId`, `parentId`, … | | **`history`** | 履歴 | `url`, `pageTitle`, `lastVisitTime`, `visitCount`, … | | **`markdown.file`** | 保存済み snapshot | `url`, `pageTitle`, `fileName`, `savedAt`, … | | **`search.hit`** | 検索ヒット(source で remap あり) | `url`, `pageTitle`, `source`, … | | **`dom.node`** / **`dom.notice`** | DOM 一覧行 | tag / path / notice など | | **`session.row`** | ターミナルセッション | session id / 表示名など | | **`setting.field`** | UI 設定行 | field id / value など | 正本カタログ: **`manifest/bmxt-rule.json`**(および **`inter-command/vocabulary.ts`** の **`LIST_KIND_TO_BMXT_RULE_KIND`**)。 **ランタイム:** パイプ段はメモリ上の **`BmxtRuleStream`**(JSON と同型)を渡します。NDJSON は fixture・export・テスト用(**`lib/features/bmxt-rule/fixtures/`**)。**単独 `-list`** は従来どおり人間向けプレーン行(**`bmxt-list/1`**);**複数段 `|`** のときだけ段間で bmxtRule を使います。ピッカー/プレーン整形用の **`ListResult`** は残し、**`lib/features/bmxt-rule/adapters/from-list-result.ts`** および feature 別ヘルパ(例: **`tabs-bmxt-rule.ts`**)で変換します。 **新規 `-list` producer** — **[コマンド追加手順](#command-add-procedure-ja)** のチェックリストを参照。 <a id="bmxt-candidate-ja"></a> ### bmxtCandidate(プロンプト候補メニュー) **bmxtCandidate** はプロンプト上の **インライン浮動候補メニュー**(Tab 補完・continuation・入力に連動した絞り込み)の規格です。スキーマ ID: **`bmxt-candidate/1`**。カタログ: **`manifest/bmxt-candidate.json`**。 | レイヤ | 役割 | |--------|------| | **Profile** | tier(`first` / `second` / `third` / `rest`)、filter(閉=`prefix`、開=`contains`)、開閉トリガ、確定キー | | **Segment contexts** | **`&&` / `||` / `;` / `|`** の直後にどの候補集合を出すか | | **Command zones** | コマンド別 tier 結び付け(manifest 固定トークン + runtime provider) | | **Data sources** | コマンドが参照してよいブラウザ/UI 事実 | **複合・パイプ:** **リスト演算子**(`&&` / `||` / `;`)の直後は **active compound segment** が **第一 tier** にリセット(新行と同様)。セグメント内の **`|`** では **pipe stage 0** は通常のコマンド zone(例: `tab -list`)、**stage 1+** は **`registry.pipeConsumers`**(`browse` / `back` / `forward` / `reload` / `close` / `c` / `tab`)。演算子直後の空 tail で Tab を押すとメニューを開く(`scanCompoundSegmentSpans` + `resolveActiveCommandSegment`)。 **ランタイム data source**(`commands[].zones` で宣言): | source id | ドメイン | 主な用途 | |-----------|----------|----------| | **`browser.openTabUrls`** | 開いている http(s) タブ | `tab -moveurl`、`search -list` pattern、`dom -list` pattern | | **`browser.openTabTitles`** | タブタイトル | tabId ラベル、search pattern ヒント | | **`browser.tabIds`** | タブツリー ID | `group new`、`snapshot -save` | | **`browser.windowLabels`** | ウィンドウ行 | `snapshot -save` ラベル | | **`browser.tabGroupLabels`** | グループ行 | `snapshot -save` ラベル | | **`browser.historyUrls`** / **`browser.historyTitles`** | 履歴 | rest tail の URL/タイトル補完 | | **`ui.commandHistory`** | プロンプト履歴 | `search -list` pattern、`session -new` 名前ヒント | | **`ui.sessionNames`** | セッション表示名 | `session -switch` / `-new` / `-setting-name` | **合成規則:** カーソル tier に対し `commands[].zones` を `when` で絞り、各 **`sources[]`** の値を **順序保持で重複除去**し、メニュー表示中は profile の **filter** を毎キー入力で適用。 **ランタイム:** 固定トークン(第一〜第三段)は WASM **`complete`**。**`resolveImeTokenPicker`** がホスト側フィルタ UX とライブオーバーレイ(browse producer、`dom -list` 残オプション、page-active)を載せる。**`manifest/bmxt-candidate.json`** と **`lib/features/bmxt-candidate/`** は **設計・検証用カタログ**と任意のライブ provider 差し込み口であり、固定トークンのランタイムエンジンではない。**`BMXT_CANDIDATE_PROVIDERS`** は将来 Chrome/UI 動的候補のみを供給しうる。 **固定トークン候補の追加** — **`manifest/bmxt-codegen.json`** の `subcommands` を更新(codegen → WASM レジストリ + `command-subcommands.gen.ts` フォールバック)。zone / dataSource の文書化は **`manifest/bmxt-candidate.json`** を同期更新。 **`exit`:** **`exit_pane`** Effect → **`exitSession`** / **`closeWindow`** patch。最後の 1 セッションでは BMXt ウィンドウ close + 旧 storage 掃除(**[BMXt プロセスのライフサイクル](#bmxt-process-lifecycle-ja)**)。 - **`manifest/bmxt-codegen.json`** — コマンド一覧・**`commands[].subcommands`**・Effect スキーマ・TS ハンドラ配線の単一ソース(**`pnpm run codegen`**) - **`lib/features/bmxt-core/`** — `dispatch.ts`、`registry/`、`cmd/*.ts`(**`CMD` + `run`**;**`table.gen.ts`** は生成)、`tabs-picker/` - **`lib/features/bmxt-window/`** — BMXt ウィンドウのメイン UI - **`lib/features/extension-storage/`** — ストレージキーと上限 - **`lib/features/page-dom/`** — DOM 注入ヘルパー(`dom -list`) - **`lib/features/bmxt-rule/`** — **bmxtRule** ストリーム(`bmxt-rule/1`、検証、serialize、adapter) - **`manifest/bmxt-rule.json`** — bmxtRule kind カタログ - **`lib/features/bmxt-candidate/`** — **bmxtCandidate** 規格(catalog、validate、provider registry) - **`manifest/bmxt-candidate.json`** — 候補メニュー profile・segment contexts・command zones - **`lib/features/command-line/list-output/`** — **`-list`** 出力規格(`ListResult`、`bmxt-list/1`)プレーン表示 - **`lib/features/command-line/inter-command/`** — 閉じたコマンド間語彙の索引 - **`manifest/templates/`** — 新コマンド checklist / 再利用例 - **`lib/features/command-line/list-commands/`** — **`-list` producer レジストリ**(`tryRunPlainListCommand`) - **`lib/features/command-line/commands/`** — **`CommandEntry`** レジストリ(`runCommand`)、null シンクリダイレクト、plain-list 合成 - **`lib/features/command-line/command-output.ts`** — stdout/stderr チャネルとセッションログ符号化(Rust: **`bmxt_core::CommandOutput`**) - **`hosts/cli/src/command_io.rs`** — CLI 集約シンク + **`InteractionMode`**(Interactive REPL / NonInteractive `exec`) - **`hosts/cli/src/shell.rs`** / **`picker/`** / **`dom_nav_host.rs`** — CLI REPL 候補オーバーレイ · ratatui picker · peer `dom`/`nav` RPC(todo §17–§20) - **`lib/features/sync/bus/apply-remote-dom-list.ts`** / **`apply-remote-nav-control.ts`** / **`apply-remote-probe-capabilities.ts`** — CLI 遠隔 `dom` / `nav` / probe 用 peer ハンドラ - **`lib/features/command-line/pipe/`** — パイプ(`|`)チェーン(**`pipe/consumers/`** レジストリ · 閉じた語彙) - **`lib/features/command-line/compound/`** — リスト演算子 **`&&` / `||` / `;`**、exit status(`EXIT_*`)、逐次実行 - **`lib/features/nav/`** — nav オーバーレイ(**[Nav モード](#nav-mode-ja)**) - **`lib/features/translate/`** — 翻訳アシスト(**[`translate`](#translate-ja)**) - **`lib/features/setting/`** — UI 言語・外観(`setting -list`、zip 入出力、外部バンドル、`bmxt_ui_settings_v1`、`bmxt_ui_settings_storage_v1`);**[`setting`](#setting-ja)** 参照 - **`lib/features/session/`** — ターミナルセッション(`session -list` / `-switch` インライン候補、セッションバー);**[`session`](#session-ja)** 参照 - **`lib/features/job/`** — スコープ別 **`JobRunner`**、キャンセルハンドル、任意のメモリ内監査ログ;**[ジョブ実行](#job-execution-ja)** 参照 - **`entrypoints/bmxt-nav-overlay.content/`** — https 向け nav 用 WXT コンテンツスクリプト - **`lib/features/dispatch/`** — 生成ディスパッチ + **`handlers/effects/`** - **`lib/features/builtin-commands/`** — Tab 補完・IME/eligibility 用生成物(Enter continuation の正本は Rust `promptPrefix`) - **`entrypoints/background/index.ts`** — **`run-cmd`** ジョブ(**`persist: false`**)で `RUN_CMD` → `runDispatch` / `applyHostEffects` → **`SessionPatch[]`** を UI に返す(`exit` → `exit_pane` patch;最後の 1 セッション → `closeWindow` + 旧 storage 掃除) manifest やコマンド実装を変えたら **`pnpm run codegen`** のあと **`pnpm run verify:manifest`** / **`pnpm run check:generated`** を実行し、必要なら **`pnpm run build`** してください。 <a id="job-execution-ja"></a> ### ジョブ実行(バックグラウンド処理) キャンセル可能な長時間処理は **`lib/features/job/`** の **`JobRunner`**(スコープ id ごと)で実行します。BMXt UI では各ターミナルセッション id がスコープ、Service Worker では予約スコープ **`__background__`**(ほとんどの `RUN_CMD`)、タブピッカー追従更新は **`__terminal__`** です。 | ジョブ種別 | 典型スコープ | 上書き方針 | 起動箇所 | |------------|--------------|------------|----------| | `search-list` | セッション id | cancel-previous | `bmxt-shell.tsx`(`search -list … | browse`) | | `dom-list` | セッション id | cancel-previous | `bmxt-shell.tsx`(`dom -list … | browse`) | | `run-cmd` | `__background__` | parallel | `entrypoints/background/index.ts` | | `tab-picker-refresh` | `__terminal__` | coalesce-latest | タブピッカー追従更新 | **キャンセル:** プロンプトの **`Ctrl+C`**、走査中の **`* -exit -list`**、同一スコープで同種ジョブを再開始(**cancel-previous** 種別)。 **任意の監査ログ:** BMXt UI タブでのみ、完了ジョブをメモリ内トレイル(`job-audit-memory`、スコープごとに間引き)へ保持することがある。Service Worker はこのモジュールを読み込まない — バックグラウンド **`run-cmd`** は **`persist: false`**。 **search 走査進捗:** **`search -list`** の進捗行はアクティブシェル内で **`requestAnimationFrame`** バッチ(`use-batched-search-loading-progress.ts`)し、全セッションペインの再描画を抑える。結果確定時に search ピッカーへマージする。 **実装:** **`job-types.ts`**、**`job-runner.ts`**、**`job-handle.ts`**、**`use-session-job-runner.ts`**、**`dispatch-context-from-job.ts`**、任意の監査は **`lib/features/job/db/job-audit-memory.ts`**。 <a id="add-new-built-in-command-ja"></a> ### 組み込みコマンドの追加 起点は **[`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md)**(語彙優先)。テンプレート一覧: **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)**。詳細は **[コマンド追加手順](#command-add-procedure-ja)**。 1. 既存 Effect / UiAction / list kind の**再利用を優先**(`manifest/templates/`)。 2. **`manifest/bmxt-codegen.json`** を編集、または **`pnpm run new:command -- <module> <name> [aliases...]`**。 3. **`crates/bmxt-core/src/cmd/<module>.rs`** に **`run`** を実装。閉じた語彙で足りないときだけ TS 実行器を拡張。 4. **`pnpm run codegen`** / **`build:wasm`** のあと **`verify:manifest`** / **`check:generated`**。 <a id="command-add-procedure-ja"></a> ### コマンド追加手順 - **語彙優先:** **[コマンド間語彙](#inter-command-vocabulary-ja)** に従う。起点は **[`shared/manifest/templates/new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md)**(決定木 + チェックリスト;一覧は **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)**)。例: **`command-reuse-effects.example.rs`**、**`command-reuse-ui-action.example.rs`**、**`command-list-producer.steps.md`**、**`pipe-consumer.steps.md`**。 - **コマンドラインのトークン仕様:** 追加・変更時は **[コマンドラインのトークン仕様(第一・第二コマンド)](#command-line-token-model-ja)** と **`.cursorrules`** に従う。第二トークン必須のとき、単独第一トークンの **Enter** は Rust の **`msgs` + `promptPrefix`**(`require_second_token` / `msgs_with_prompt`)で返す — TS 側に Enter continuation を足さない。第二トークンの **Tab** 候補は **`command-subcommands.gen.ts`**(manifest **`subcommands`**)。詳細: **[プロンプト意味の正本(Rust)](#prompt-semantics-sot-ja)**。 - **真実のデータは 1 箇所:** **`manifest/bmxt-codegen.json`**。生成物は手編集しない(**`pnpm run codegen`**)。 - **手順(推奨):** **`pnpm run new:command -- <module> <canonical_name> [aliases...]`** — **`crates/bmxt-core/src/cmd/<module>.rs`** と manifest を更新し codegen。続けて **`manifest/templates/`** の例で **`run`** を実装。 - **再利用パス(推奨):** 既存 **`HostEffect`** / **`UiAction`** / list kind のみ返す — **新しい TS 実行器は書かない**。i18n・README・**`_context/map_command.csv`** を更新。 - **拡張パス(必要なときだけ):** - **Effect:** `effects[]` → codegen → **`handlers/effects/<tsHandlerFile>.ts`** - **UiAction:** `uiActions[]` → codegen → **`crates/bmxt-core/src/generated/ui_action.rs`** / **`ui-action-types.ts`** + 手書き **`apply-ui-action.ts`**(`ir.rs` は生成 `UiAction` の re-export のみ。enum をそこに足さない) - **List / pipe kind:** `list-output/types.ts` + **`inter-command/vocabulary.ts`** + **`manifest/bmxt-rule.json`** + adapter / consumer - **検証:** **`verify:manifest`** / **`verify:host-blind`** / **`check:generated`** / **`check:cli-command-io`**(todo §15.4)/ **`cargo test -p bmxt-core`** / **`build:wasm`** / **`tsc`** / **`pnpm test`** / **`pnpm run build`**。 - **BMXt POSIX Profile(todo §15):** **`EXIT_*`** のみ · 成功→stdout / 診断→stderr · browse / ask は Interactive のみ · CLI は **`CommandIo`** · パイプは閉じた consumer + **`bmxtRule`**。Built-in Commands の Profile 節と [`new-command.checklist.md`](shared/manifest/templates/new-command.checklist.md) を参照。 - **compound / pipe:** 計画は WASM、実行ループは **`command-line/`**。パイプ段間は **bmxtRule のみ**(コマンド名直結禁止)。 各 **`commands[]`** 行に **`subcommands`** を必ず含める。dispatch は **`crates/bmxt-core/src/cmd/<module>.rs`** に書き、各 **`head`** を manifest と**同一の文字列リテラル**で参照する(**`pnpm run verify:manifest`**)。例外として第二トークン **`help`**(コマンド別マニュアル)は **`help_cmd.rs`** で中央処理する。`head` は通常 `-` 始まりだが、マニュアル用のリテラル **`help`** を許可する。 **手書きの `handlers/effects/*.ts`:** codegen の対象外。**`-list`** effect は **`runPlainListForCommandId`** を呼び、整形を重複させない。 #### プレーン `-list` producer の追加 詳細は **`manifest/templates/command-list-producer.steps.md`**。要点: 1. **`*-list-result.ts`** / **`*-list-command.ts`** を追加し **`list-commands/registry.ts`** に登録。既存 **`ListRecordKind`** を優先。 2. SW が要る場合は Effect + **`runPlainListForCommandId`**。UI のみなら **`runtime: "ui"`**。 3. 新 kind は vocabulary / **`bmxt-rule.json`** / adapter まで一式。 4. README / **`_context/map_command.csv`** / i18n を更新。 **アーキテクチャ:** コマンド意味論・プロンプト意味(usage キー / `promptPrefix` / 不完全 `-setting`)は **Rust/WASM(`crates/bmxt-core`)**、描画ホストと Chrome 執行は **TypeScript**。正本は **manifest + codegen**。詳細: **[プロンプト意味の正本(Rust)](#prompt-semantics-sot-ja)**。 <a id="prompt-key-bindings-ja"></a> ## プロンプトのキーバインド プロンプトの **`textarea` にフォーカス**があるときの操作です。 - **← / → / Home / End** — 行内カーソル移動(ブラウザ標準の挙動) - **Tab** — コマンド補完(繰り返しで候補循環。固定トークン用 IME 風ピッカー。`tab ` など第一コマンドのみで **Enter** したあとは **第二コマンド候補リスト** が出ることあり — ↑/↓・Tab・Enter・Esc) - **↑ / ↓** — コマンド履歴 - **Ctrl+R** — 逆方向インクリメンタルサーチ(続けて押すと古い一致へ) - **Enter** — コマンド実行(逆検索モードでは確定)。**nav** オーバーレイが **ON** で **nav 詳細バー**にフォーカスがあるときは、ページ上の **クリック**(**[Nav モード](#nav-mode-ja)**) - **Shift+Enter** — 改行を入力可能 - **Esc** — 逆検索のキャンセル **nav 起動中**(`nav -enter` 後): - **Alt** — 対象ブラウザタブの nav オーバーレイ **ON** / **OFF**(**nav 詳細バー**から、または armed 中のプロンプトから)。**typing** 中の短い **Alt** は無視。**Alt 長押し**(約 500ms)は入力確定。**ON** 中はフォーカスを **nav 詳細バー**に固定。 - **↑ / ↓ / ← / →** — オーバーレイ **ON** 時は操作可能要素間ジャンプ(空間スナップ)。**Shift+矢印** は **12px** 自由移動、**Shift 解放**で現在位置を再スキャン。**tabs / search / dom** ピッカー列にフォーカスがあるときはピッカー操作。 - **/** — オーバーレイ **ON** 時、属性インクリメンタルジャンプ(文字で絞込 · **↑ / ↓** 循環 · **Enter** 実行 · **Esc** 解除)。 - **Enter** — オーバーレイ **ON** 時、解決済みターゲットを activate、または編集可能要素で **typing モード**。 - **Ctrl**(タップ、オーバーレイ **ON**)— カーソル位置の **コンテキストメニュー**(**↑ / ↓** 選択、**Enter** 実行、**← / →** 履歴、**Ctrl** / **Esc** で閉じる)。詳細は **[Nav モード](#nav-mode-ja)**。 - **Esc 長押し**(約 500ms、**typing** 中)— 入力取消(フィールドを元に戻す)。 変換中は IME 用の `composition` イベントを優先し、変換確定までショートカットと競合しないようにしています。 <a id="development-ja"></a> ## 開発 依存関係のインストール後、開発ビルドを起動します(手順の全体像は **Development startup** / **開発時の起動** を参照)。 ```bash pnpm install --frozen-lockfile # pnpm-lock.yaml があるときはこちら pnpm run dev ``` `pnpm run dev` は **`wxt`**(ウォッチ付き開発ビルド)で、**`.output/chrome-mv3-dev`** を更新します。作業中はターミナル上のプロセスを止めずに置いておきます。 **`manifest/bmxt-codegen.json`** を編集したときは、拡張を再読み込みする前に **`pnpm run codegen`** を実行し、生成 TypeScript を揃えてください。 <a id="development-startup-ja"></a> ### 開発時の起動 1. **依存関係:** 初回は **`corepack enable`** のあと、リポジトリ直下で **`pnpm install --frozen-lockfile`**(**`pnpm-lock.yaml`** があるときはこちらを優先)。依存を更新して lockfile を書き換えるときだけ **`pnpm install`**。**postinstall** で sql.js WASM を **`public/`** へコピーし **`wxt prepare`** を実行(**`.wxt/types/`** を生成)。**[pnpm 依存関係とセキュリティ](#pnpm-dependencies-ja)** を参照。 2. **Codegen:** **`manifest/bmxt-codegen.json`** を編集したときは、**`pnpm run codegen`** で **`lib/features/bmxt-core/registry/`**・**`lib/features/dispatch/`**・**`lib/features/builtin-commands/`** の生成物を揃える。 3. **開発サーバ:** リポジトリ直下で **`pnpm run dev`** を実行する。これは **`wxt`** で、`.output/chrome-mv3-dev` をウォッチビルドする。**プロセスは終了させず**ターミナルに置いておく。 4. **Chrome に読み込み:** `chrome://extensions` を開き、**デベロッパーモード**をオンにして「パッケージ化されていない拡張機能を読み込む」から **`.output/chrome-mv3-dev`** を指定する(WXT dev が出力するディレクトリ)。 5. **BMXt を開く:** ツールバーの拡張機能アイコンから BMXt ウィンドウを開く。 6. **編集後:** WXT の再ビルドが終わったら、拡張機能カードの「再読み込み」(または BMXt タブの再読み込み)で Service Worker と UI に反映させる。 <a id="testing-ja"></a> ### テスト **JS/TS** の自動テストは **`tests/`** 配下(`lib/` やリポジトリ直下には置かない)。構成の詳細は **[`tests/README.md`](tests/README.md)**。 **E2E のブラウザライフサイクル**(アンパック拡張のロード、`extensionOrigin` 解決、拡張ページを開く)は **[webxdriver](https://github.com/UNRsports/webxdriver)**(`devDependency`、GitHub コミット固定)を使います。BMXt 固有(プロンプト/チュートリアル/`.bmxt-*` アサート、**`BMXT_E2E_BROWSER`**、`.output/{chrome,firefox}-mv3` パス)は **`tests/e2e/harness.ts`** に残します。 **関連ドキュメント(散在 README):** | ドキュメント | 内容 | |--------------|------| | **[`tests/README.md`](tests/README.md)** | unit / property / E2E の構成とテスト追加方法 | | **[`hosts/README.md`](hosts/README.md)** | Chrome / Firefox ホストと build/package | | **[`hosts/firefox/AMO_SOURCE.md`](hosts/firefox/AMO_SOURCE.md)** | Firefox AMO ソースキット | | **[`scripts/fixtures/dispatch/README.md`](scripts/fixtures/dispatch/README.md)** | WASM `run` 向け Effect の golden 契約(`effects.json`) | | **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)** | コマンド追加テンプレート(閉じた語彙) | | **[`shared/public/assets/wasm/bmxt-gaze/README.md`](shared/public/assets/wasm/bmxt-gaze/README.md)** | 任意の gaze WASM モジュール(ビルド手順) | <a id="testing-how-to-run-ja"></a> #### 実行方法 | 対象 | コマンド | 補足 | |------|----------|------| | **ユニット + プロパティ(JS/TS)** | **`pnpm test`** | ブラウザ不要。高速。 | | **Rust / WASM** | **`cargo test -p bmxt-core`** | `pnpm test` には含まれない。 | | **E2E(Chrome)** | **`pnpm run build:chrome`** → **`pnpm run test:e2e:chrome`** | Headless WebDriver + Chrome for Testing(**webxdriver**)。**`.output/chrome-mv3`** をロード。 | | **E2E(Firefox)** | **`pnpm run build:firefox`** → **`pnpm run test:e2e:firefox`** | Headless WebDriver + geckodriver(**webxdriver**)。**`.output/firefox-mv3`** をロード。 | | **E2E(両方)** | **`pnpm run test:e2e:all`** | Chrome → Firefox(ビルドは別途、または **`verify`**)。 | | **CI と同一の全体ゲート** | **`pnpm run verify`** | manifest / codegen / Rust / WASM / `tsc` / unit / **build** / E2E。 | ビルド済みなら次の順で十分です: **全体ゲート(CI と同一):** **`pnpm run verify`** — manifest / no-fetch / generated → **`cargo test -p bmxt-core`** → **`build:wasm`** → **`tsc --noEmit`** → **`pnpm test`** → **`build:chrome`** + WebDriver E2E → **`build:firefox`** + WebDriver E2E。 | 層 | コマンド | 場所 | |----|----------|------| | **TS ユニット** | **`pnpm test`** | **`tests/unit/`** — Node.js `node:test` / `node:assert`。グロブ: `tests/unit/**/*.test.ts`、`tests/unit/**/*.test.mjs`。 | | **プロパティ** |(**`pnpm test`** に含む) | **`tests/property/`** — **fast-check** + `node:test`(UTF-16/UTF-8 キャレット変換と **TS↔WASM** ホスト入口を含む)。 | | **E2E** | **`pnpm run test:e2e:chrome`** / **`test:e2e:firefox`** / **`test:e2e:all`** | Headless **WebDriver**(**`tests/e2e/`**、**webxdriver** ライフサイクル + BMXt `harness.ts`)。詳細は **[`tests/README.md`](tests/README.md)**。 | | **Rust / WASM** | **`cargo test -p bmxt-core`** | **`shared/crates/bmxt-core/`** のみ(Cargo 慣例。**`tests/` には置かない**)。 | **TS ユニットの追加:** **`tests/unit/features/<lib と同じパス>/<name>.test.ts`** に置き、本番コードは **`lib/features/...`** から **`.ts` 付き**で import する。`lib/` 隣へのコロケートはしない。 <a id="testing-e2e-coverage-ja"></a> #### E2E がカバーすること **`tests/e2e/`** の共有仕様を Chrome / Firefox の両方で実行します(command smoke、`command-matrix.ts`、prompt integrity、CJK キャレット)。ライフサイクルと環境変数は **[`tests/README.md`](tests/README.md)**。ブラウザを使わない Effect の golden 契約は **[`scripts/fixtures/dispatch/`](scripts/fixtures/dispatch/)**(**[`README`](scripts/fixtures/dispatch/README.md)**)。 <a id="project-layout-ja"></a> ### プロジェクト構成(WXT) | パス | 役割 | |------|------| | **`entrypoints/background/`** | Service Worker(`index.ts`)— ウィンドウ起動・`runDispatch`・Effect | | **`entrypoints/bmxt/`** | 拡張 UI ページ → ビルド後 **`bmxt.html`**(`main.tsx` + `index.html`) | | **`entrypoints/bmxt-nav-overlay.content/`** | https 向け Nav コンテンツスクリプト | | **`public/`** | 静的アセット(そのまま同梱): **`_locales/`**, **`icon.png`**, **`background-services.js`** | | **`wxt.config.ts`** | manifest 上書き(権限・CSP・ショートカット) | | **`lib/features/`** | 機能モジュール(下表参照) | | **`tests/`** | JS/TS テストのみ(unit / property / headless WebDriver E2E。**[テスト](#testing-ja)**・**[`tests/README.md`](tests/README.md)**)。Rust は **`shared/crates/bmxt-core/`** | | **`hosts/chrome/`**, **`hosts/firefox/`**, **`hosts/cli/`** | ホスト別 WXT と端末 Family peer — **[`hosts/README.md`](hosts/README.md)** · **[端末 CLI peer](#terminal-cli-peer-ja)** | | **`manifest/bmxt-codegen.json`** | コマンドレジストリ + Effect スキーマ(単一ソース。**`pnpm run codegen`**)。テンプレート: **[`shared/manifest/templates/README.md`](shared/manifest/templates/README.md)** | | **`scripts/fixtures/dispatch/`** | WASM `run` 向け Effect golden — **[`README`](scripts/fixtures/dispatch/README.md)** | | **`pnpm-lock.yaml`** | lockfile — **`pnpm install --frozen-lockfile`** でインストール | | **`docs/`** | GitHub Pages — プライバシーポリシー(`index.html`)、ウェルカム(`welcome.html`, `welcome-content.json`, `welcome/` 画像) | | **`.output/`** | ビルド出力(gitignore): **`chrome-mv3`** / **`firefox-mv3`**, **`bmxt-<ver>-chrome.zip`** / **`bmxt-<ver>-firefox.zip`**(**`package`** / **`package:chrome`** / **`package:firefox`**) | **ビルドスクリプト:** **`pnpm run dev`** / **`build`** / **`package`** は **`scripts/build-background-services.mjs`** → WXT の順。**`postinstall`** は **`wxt prepare`** のみ。 <a id="main-sources-ja"></a> ### 主なソース - `entrypoints/bmxt/` — 拡張ページ(`main.tsx` + `index.html`;`BmxtTerminal` をマウント) - `entrypoints/background/` — Service Worker - `entrypoints/bmxt-nav-overlay.content/` — https 向け content script - `bmxt-ui.css` — ウィンドウ用スタイル - `wxt.config.ts` — manifest オーバーライド - `lib/features/bmxt-window/` — BMXt ウィンドウのメイン UI(`bmxt-terminal.tsx`、セッションログ/履歴フックなど) - `lib/features/side-picker/` — 横並びピッカー列の共有 UI(パネルホスト・`PickerListShell`・`usePlainPickerKeyboard`・interaction kernel・ラッパ・**`tree/`**) - `lib/features/bookmark/` — ブックマーク一覧/ツリーピッカー/送信(`bookmark-picker-wrapper.tsx`、fold、`submitConstructedLine`) - `lib/features/history/` — 履歴一覧/ツリーピッカー(`history-picker-wrapper.tsx`、月→日→訪問 fold) - `lib/features/release-notes/release-notes.json` — アプリ内バージョンアップ通知の変更内容(キーは `package.json` の `version` と一致させてメンテ) - `lib/features/welcome/` — ウェルカムタブ URL 組み立てと更新フック(ホストされた **`docs/welcome.html`** を開く;コンテンツは **`docs/`** のみ) - `lib/features/support/` — ウィンドウ内サポートリンク(公式サイト / NotebookLM マニュアル;表示名のみ;通常ブラウザタブで開く) - `lib/features/extension-storage/` — ストレージキーと上限(Service Worker と UI の両方から参照) - `lib/features/tabs/` — タブピッカー(`tabs-picker-wrapper.tsx`、`tabs-url-list-picker.tsx`、`use-tab-picker-controller.ts`、`picker-rows.ts`、keyboard 拡張など) - `lib/features/prompt-effects/` — 任意の打鍵 FX(`prompt-fire`);Firefox は候補メニュー開中 **menu-lite** - `crates/bmxt-core/` — Rust/WASM コマンドコア;`lib/features/bmxt-core/` — TS ホスト(`wasm-host` / `dispatch` / tabs-picker ラッパ) - `lib/features/dispatch/` — **`effect-types.ts`** / 生成ディスパッチ・**`handlers/effects/`** で Chrome 実行 - `lib/features/builtin-commands/` — Tab / IME 用生成物(`completion-fallback.ts`・`command-subcommands.gen.ts`)。Enter continuation の正本は Rust `promptPrefix` - `lib/features/page-dom/` — DOM 注入ヘルパー(`dom -list`) - `lib/features/search/` — search モード(`search -list`)、横断 **`--all`**、**`--history`** / **`--bookmark`** 用のメモリ内メタデータキャッシュ(`search-cache-store`;行に `bookmarkId`/訪問メタデータを保持) - `lib/features/sync/bus/apply-remote-bookmarks-ops.ts` — ピア **`bookmarks_ops`** ハンドラ - `lib/features/backup/` — ブラウザのブックマーク/履歴 ZIP バックアップ&復元(`bmxt-browser-backup/`) - `lib/features/snapshot/` — Markdown snapshot(`snapshot -save`)、Vault/bundled 保存、**`search -list --snapshot`** - `lib/features/bmxt-rule/` — **bmxtRule** 規格(`bmxt-rule/1`)と adapter - `lib/features/command-line/list-output/` — **`-list`** 規格と plain 整形(`ListResult`、`bmxt-list/1`) - `lib/features/command-line/inter-command/` — 閉じたコマンド間語彙の索引 - `manifest/templates/` — 新コマンドテンプレート - `lib/features/command-line/list-commands/` — **`-list` producer レジストリ**(`*-list-command.ts` プラグイン、`tryRunPlainListCommand`) - `lib/features/command-line/commands/` — **`CommandEntry`** レジストリ(`runCommand`)、null シンクリダイレクト - `lib/features/command-line/command-output.ts` — stdout/stderr チャネルとセッションログ符号化(Rust: `bmxt_core::CommandOutput`) - `hosts/cli/src/command_io.rs` — CLI `CommandIo` + `InteractionMode`(Interactive / NonInteractive `exec`) - `hosts/cli/src/shell.rs` — CLI REPL メイン画面行編集 + 候補オーバーレイ(todo §20) - `hosts/cli/src/picker/` — CLI ratatui picker(tab / URL / peer / oneshot。拡張 `features/picker/` を独立ミラー) - `hosts/cli/src/dom_nav_host.rs` — CLI peer の `dom_list` / `nav_control` / `probe_capabilities` host - `lib/features/sync/bus/apply-remote-dom-list.ts` / `apply-remote-nav-control.ts` / `apply-remote-probe-capabilities.ts` — CLI §17 向け peer RPC ハンドラ - `lib/features/command-line/pipe/` — パイプ(`|`)チェーンと閉じた consumer レジストリ - `lib/features/command-line/compound/` — リスト演算子(`&&` / `||` / `;`)、exit status(`EXIT_*`)、逐次実行 - `lib/features/job/` — スコープ別 **`JobRunner`**、キャンセルハンドル、任意のメモリ内監査ログ(`job-audit-memory`) - `lib/features/nav/` — Nav オーバーレイ機能パッケージ - `lib/features/translate/` — 翻訳アシスト(`translate -on` / `-off` / `-setting`、`translation-pair.ts`) - `lib/features/setting/` — 設定ピッカー(`setting -list`、`appearance.ts`、`settings-export.ts`、`settings-external-storage.ts`、`settings-bundle-layout.ts`) - `lib/features/session/` — ターミナルセッション(`session-input.ts`、インライン候補、`session-bar.tsx`) - `scripts/build-background-services.mjs` — Service Worker ヘルパーを **`public/background-services.js`** にバンドル コードを編集すると、開発モードではビルドが更新されるので、拡張の「再読み込み」で反映を確認できます。 <a id="version-upgrade-banner-ja"></a> ### バージョンアップバナーとリリースノート **拡張機能更新時のウェルカムページ**(通常タブ。ウィンドウ内ブロックとは別) Chrome が **`install`** または **`update`** を報告したとき、**`entrypoints/background/index.ts`** が **`openWelcomePageOnUpdateIfNeeded`** を呼び、**`openWelcomePageTab`** で **`https://unrsports.github.io/bmxt/welcome.html`** を **バージョンごとに 1 回** 開きます(**`LAST_SEEN_WELCOME_VERSION_KEY`** で記録)。ページは GitHub Pages 上の **`docs/welcome-content.json`** を読み込みます。 **手動・プレビュー URL:** `https://unrsports.github.io/bmxt/welcome.html?lang=ja&v=0.96.1` でその版までのエントリを表示。クエリ **`lang`**: `ja` または `en`。クエリ **`v`**: 表示上限の semver(不正値は無視)。**`v`** を省略すると全履歴。**`aboutbmxt`** と更新時の自動表示は、UI 設定の **`lang`** と manifest の **`v`** を付与します。 **ウィンドウ内ウェルカムヒント**(セッションログが空のとき。アップグレードブロック表示時も併記) アクティブセッションのログが **空** のとき(典型的には BMXt を新規に開いた直後)、プロンプト上に **ウェルカムヒント** を出します。内容はウェルカム文言、`help` 案内、**サポートリンク**、https 注入の注意(`shell.reloadHint` / i18n)。**バージョンアップ** ブロックがある場合も、その **上** に同じヒントを出します。 **サポートリンク**(**0.9.1 以降**。わかりやすい表示のみ。UI に生 URL は出さない)。クリックで **通常ブラウザ窓の新規タブ** を開く(BMXt ポップアップ窓内ではない)。許可 URL は **`lib/features/support/`** に固定: | 表示(JA) | 行き先 | |------------|--------| | **👉️公式サイト** | `https://bmxt.diozy.net/` | | **👉️マニュアルサポート(notebookLM)** | NotebookLM(`https://notebook.google.com/notebook/…`) | EN 表示: **👉️ Official site** / **👉️ Manual support (NotebookLM)**。**`aboutbmxt`**(GitHub Pages のウェルカム履歴)とは別経路。 **ウィンドウ内のアップグレードブロック**(アップデート後、BMXt を初めて開いたとき) 拡張機能の **`version`**(**`package.json`**/ビルド後の manifest)が、**`chrome.storage.local`** の **`bmxt_last_seen_extension_version`**(**`LAST_SEEN_EXTENSION_VERSION_KEY`**)と **一致しない** とき、BMXt を開いた **そのバージョンへアップデートしたあとの初回だけ**、次を表示します。 1. 上記の **ウェルカム** ヒント(サポートリンクを含む)。 2. **バージョンアップ** 見出しと、**`release-notes.json`** の日英変更説明。 既存の **セッションログ** は、その **下** に続きます。 **リリース時の作業** 1. **`package.json`** の **`version`** を上げる。 2. **`lib/features/release-notes/release-notes.json`** に、**同じバージョン文字列** をキーとするオブジェクトを追加する(**`ja`** / **`en`** の文字列配列。ウィンドウ内アップグレードバナー用)。 3. **`docs/welcome-content.json`** の先頭に新オブジェクトを追加する(**`version`**, **`ja`** / **`en`** の配列;画像フィールドは任意)。画像ファイルは **`docs/welcome/`** に置く。**`docs/`** を GitHub Pages に公開して live と揃える。ユーザーは **`aboutbmxt`** または install/update 後にページを開ける。 4. ビルドして配布する。 **`release-notes.json`** に該当キーが無い場合は、メンテ向けプレースホルダが表示されます。 **実装:** ウェルカムタブ — **`open-welcome-page-tab.ts`**、**`open-welcome-on-update.ts`**、**`welcome-external-url.ts`**。**`aboutbmxt`** — **`cmd/aboutbmxt.ts`**、**`handlers/effects/open-welcome-page.ts`**(同一 **`openWelcomePageTab`**)。ウィンドウ内サポートリンク — **`lib/features/support/`**(`ShellSupportLinks`、許可 URL → **`createTabInNormalBrowserWindow`**)、i18n **`shell.support.*`**。ウィンドウ内バナー — **`use-version-upgrade-banner.ts`**、描画待ち **`bmxt-terminal.tsx`**、UI **`bmxt-shell.tsx`**、スタイル **`bmxt-ui.css`**(`.bmxt-hint a`、`.bmxt-version-upgrade*`)。 <a id="production-build-ja"></a> ## 本番ビルド ```bash pnpm run build ``` 成果物は `.output/chrome-mv3` / `.output/firefox-mv3` 配下に出力されます。ストア提出用 zip は **`pnpm run package`**(両ホスト)または **`package:chrome`** / **`package:firefox`**(`.output/bmxt-<version>-{chrome|firefox}.zip`)。 <a id="store-submission-ja"></a> ## ストア提出(参考) ローカルでビルド・zip: ```bash pnpm run build pnpm run package:chrome # .output/bmxt-<version>-chrome.zip を出力 ``` [WXT の公開ガイド](https://wxt.dev/guide/essentials/publishing) や [Browser Platform Publish (bpp)](https://bpp.browser.market) で自動提出できます。本リポジトリには **`.github/workflows/submit.yml`**(手動 **`workflow_dispatch`**)があり、**`pnpm run build:chrome`** → **`pnpm run package:chrome`** のあと **`.output/bmxt-*-chrome.zip`** を **`PlasmoHQ/bpp@v3`** でアップロードします。ストア認証情報は GitHub secret **`SUBMIT_KEYS`** のみに置き、コミットしないでください。 <a id="license-ja"></a> ## ライセンス このプロジェクトは [Apache License 2.0](./LICENSE) の下で公開しています。 <a id="roadmap-ja"></a> ## ロードマップ 1. UI および動作の設計/実装/テスト 2. 基本となる **tab** コマンド/ピッカー操作の見直し 3. ~~履歴、ブックマーク操作~~ — **完了**(`bookmark` / `history` コマンド、Family `--open|--save|--both`、ZIP バックアップ。**[`bookmark`](#bookmark-command-ja)** · **[`history`](#history-command-ja)** · todo §9) 4. 複数ターミナルでの動作 5. 純粋なコマンドラインでの動作や各種自動処理系への対応など 6. **端末 CLI peer(`hosts/cli`)** — Family DataChannel peer + localhost 自動接続 + **`bmxt exec`** ワンショット + Profile I/O ゲート + bookmark/history/ブラウザ間送信 + peer **`aboutbmxt`/`dom`/`nav`** + コマンド正本 picker / **`--focus`** + メイン画面候補メニュー(**[端末 CLI peer](#terminal-cli-peer-ja)** · todo §10–§20)。配布/同一 PC スモークの磨き込み