Add bot <name> and trust the bots' dir #28

Manually merged
bryan merged 3 commits from w35-3-bot-alias into main 2026-11-11 19:44:20 +00:00
Owner

Part of bryan/dotfiles-workspace#35 (W35.3: the bot <name> alias generated from the bot directories, and trust for the bots' parent directory).

What

bot <name> (dot-config/shell/aliases.sh + dot-config/shell/bot-tab.py, bash and zsh): shows that bot's tab in the bots Rex session that pi-bots keeps (one tab per bot, named after it). bot alone lists the bots.

  • The bots are the directories under $PI_BOTS_DIR (default ~/code/pi-bots/bots) that hold an AGENTS.md and have a valid pi-bots name. They are read on every call and every completion, so a bot made or retired with pi-bots bot create/retire is picked up without a new shell. .retired/ is never listed.
  • bot bob makes Bob's tab the active tab of the bots session (rex window focus). It then asks one Rex app to show it (session.select): the calling pane's block owner, or else the only connected app. A refusal (Remote Control off) still leaves the tab active, and exits 0 with a note.
  • It never opens, closes or restarts a tab; pi-bots owns them. If there's no bots session, no tab yet or an unknown name, it says so and changes nothing.
  • It is defined only where the bot directories and python3 exist, so it does nothing on other hosts.

Pi trust for the bots' parent (scripts/reconcile-pi-bots-trust.mjs, run by setup-platform-configs.sh):

  • Pi ignores a project's .pi/settings.json until the project is trusted. This script saves a trust decision for the bots' parent through Pi's own exported ProjectTrustStore, found from the pi on PATH, so a Pi started in a bot's directory uses that bot's model settings. The bot service's own Pis already pass --approve.
  • Keys are real paths (the bots are reached through a symlink).
  • A saved "do not trust" on that directory is left alone. One on a parent is overridden for the bots only, and the script says so.
  • --check reports drift. It skips when the bots or Pi are missing.

Tests

bash tests/test-bot-alias.sh (82 checks, both shells): a fake rex records calls and answers from fixtures, and a stand-in Pi package mirrors the store's nearest-ancestor and real-path rules. The cases covered are:

  • listing, focusing, and which app is chosen (pane owner, unowned pane, a lost app, two apps);
  • refusals that call no rex;
  • no session, and no tab;
  • an app that refuses;
  • a bot added while the shell runs;
  • completion in both shells;
  • a checkout path with a space, $ and a backtick;
  • trust: check, apply, saved and inherited refusals, trust through a parent, a symlinked bots directory, and skips.

Every guard was mutated (21 mutations), and each mutation fails a test. The real Pi 1.5.2 store was checked in a scratch agent directory: after --apply, a Pi in a bot directory took that bot's thinking level. tests/test-pi-seat-wrapper.sh and tests/test-reconcile-shell-additions.sh still pass.

Review

A visible, read-only Pi reviewer requested changes:

  • two should-fixes:
    • the trust test could not catch the symlink case real hosts have;
    • the pane-owner rule was untested and its docs overstated it;
  • three nits:
    • completion offered names bot refuses;
    • eval expanded the checkout path;
    • an untested connection filter.

All are fixed with tests in the second commit. The re-review approved on correction 1, with one nit: zsh's nomatch printed an error when completing with no bots. That nit is fixed with a test in the third commit (mutation checked).

Part of bryan/dotfiles-workspace#35 (W35.3: the `bot <name>` alias generated from the bot directories, and trust for the bots' parent directory). ## What **`bot <name>`** (`dot-config/shell/aliases.sh` + `dot-config/shell/bot-tab.py`, bash and zsh): shows that bot's tab in the `bots` Rex session that pi-bots keeps (one tab per bot, named after it). `bot` alone lists the bots. - The bots are the directories under `$PI_BOTS_DIR` (default `~/code/pi-bots/bots`) that hold an `AGENTS.md` and have a valid pi-bots name. They are read on every call and every completion, so a bot made or retired with `pi-bots bot create`/`retire` is picked up without a new shell. `.retired/` is never listed. - `bot bob` makes Bob's tab the active tab of the `bots` session (`rex window focus`). It then asks one Rex app to show it (`session.select`): the calling pane's block owner, or else the only connected app. A refusal (Remote Control off) still leaves the tab active, and exits 0 with a note. - It never opens, closes or restarts a tab; pi-bots owns them. If there's no `bots` session, no tab yet or an unknown name, it says so and changes nothing. - It is defined only where the bot directories and `python3` exist, so it does nothing on other hosts. **Pi trust for the bots' parent** (`scripts/reconcile-pi-bots-trust.mjs`, run by `setup-platform-configs.sh`): - Pi ignores a project's `.pi/settings.json` until the project is trusted. This script saves a trust decision for the bots' parent through Pi's own exported `ProjectTrustStore`, found from the `pi` on `PATH`, so a Pi started in a bot's directory uses that bot's model settings. The bot service's own Pis already pass `--approve`. - Keys are real paths (the bots are reached through a symlink). - A saved "do not trust" on that directory is left alone. One on a parent is overridden for the bots only, and the script says so. - `--check` reports drift. It skips when the bots or Pi are missing. ## Tests `bash tests/test-bot-alias.sh` (82 checks, both shells): a fake `rex` records calls and answers from fixtures, and a stand-in Pi package mirrors the store's nearest-ancestor and real-path rules. The cases covered are: - listing, focusing, and which app is chosen (pane owner, unowned pane, a lost app, two apps); - refusals that call no `rex`; - no session, and no tab; - an app that refuses; - a bot added while the shell runs; - completion in both shells; - a checkout path with a space, `$` and a backtick; - trust: check, apply, saved and inherited refusals, trust through a parent, a symlinked bots directory, and skips. Every guard was mutated (21 mutations), and each mutation fails a test. The real Pi 1.5.2 store was checked in a scratch agent directory: after `--apply`, a Pi in a bot directory took that bot's thinking level. `tests/test-pi-seat-wrapper.sh` and `tests/test-reconcile-shell-additions.sh` still pass. ## Review A visible, read-only Pi reviewer requested changes: - two should-fixes: - the trust test could not catch the symlink case real hosts have; - the pane-owner rule was untested and its docs overstated it; - three nits: - completion offered names `bot` refuses; - `eval` expanded the checkout path; - an untested connection filter. All are fixed with tests in the second commit. The re-review approved on correction 1, with one nit: zsh's `nomatch` printed an error when completing with no bots. That nit is fixed with a test in the third commit (mutation checked).
bot <name> shows that bot's tab in the bots Rex session; bot lists
the bots, read from the bot directories on every call. A reconciler
saves Pi trust for the bots' parent so their settings apply.
Test trust through a symlinked bots dir, say when a parent's refusal is
overridden, define bot() without eval, filter completion to valid
names, and document whose app view bot switches.
bryan changed title from Add bot <name> and Pi trust for the bots' parent to WIP: Add bot <name> and Pi trust for the bots' parent 2026-11-11 19:39:51 +00:00
bryan changed title from WIP: Add bot <name> and Pi trust for the bots' parent to Add bot <name> and Pi trust for the bots' parent 2026-11-11 19:43:57 +00:00
bryan changed title from Add bot <name> and Pi trust for the bots' parent to Add bot <name> and trust the bots' dir 2026-11-11 19:44:09 +00:00
bryan manually merged commit b567e85942 into main 2026-11-11 19:44:20 +00:00
Sign in to join this conversation.
No reviewers
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bryan/dotfiles!28
No description provided.