Skip to content

Add codesmith bridge init, and auth login --home/--to-file - #22

Merged
reka18 merged 5 commits into
mainfrom
feature/bridge-init
Nov 26, 2026
Merged

reka18 merged 5 commits into
mainfrom
feature/bridge-init

Conversation

@reka18

@reka18 reka18 commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Setting up a tailbus bridge for CodeSmith meant hand-assembling a bridge home, a key file and a [bridges.NAME] table. This adds a guided flow and the sign-in pieces it needs.

What's new

  • codesmith bridge init NAME:
    • Asks for headless or relay, then the provider (untested ones tagged), the sign-in, the model and the effort (only the model's real levels).
    • Writes a bridge home and a 0600 secrets file (O_NOFOLLOW, never through a symlink).
    • Test-runs the bridge the way tailbus would, then prints the [bridges.NAME] table.
    • Asks before adding it to tailbus's config, and again before tailbus bridge install.
    • Refuses with no terminal, in your own home or /, and when the bridge already exists.
  • codesmith auth login PROVIDER --home DIR saves a login into another home. --to-file PATH writes a key or Claude Code token to a 0600 file and prints the secrets line.
  • "For a bridge or another home…" in /login and the auth login picker.
  • /bus share points at bridge init, and a run with no key suggests auth login --home.
  • Docs: docs/tailbus.md leads with bridge init; the hand-made route stays under "By hand".

Choices to review

  • The chosen effort is stored as the model variant (provider/model#high), because tailbus has no per-bridge default effort.
  • Bridges are offered only sign-ins that work on their own: a key, a Claude Code token, or OAuth. Claude Code's own login, AWS profiles, Google ADC and the Azure CLI depend on your home, so they're left out.
  • No permission rules are written into the bridge home; the docs explain how to add them.
  • New dependency: toml_edit 0.25, already in the lockfile.

Tests

About 60 new tests, including 17 PTY-driven e2e tests in tests/e2e/bridge.rs. They cover modes, symlink refusal, declining, an existing table, no tailbus, no terminal, and a project config trying to steer secrets. Every test checks that no secret reaches the output.

Not done

  • Custom or local providers that exist only in your own config aren't offered for a bridge.
  • A relay can't check up front that its share exists.

codesmith_core::home names the folders a run with HOME=DIR uses (no XDG
or CODESMITH_CONFIG_DIR, as under a tailbus bridge), resolves a --home
folder (it must exist and can't be your own home), and writes a key or
token to a file of its own: 0600, O_NOFOLLOW, in an owner-only folder,
never through a symlink, replaced only when asked. config::load_home
reads that home's global config alone, never a project's.
A bridge's run with no key said to run `HOME=DIR codesmith auth login`,
which also moves the config and everything else that command reads. It
now names `codesmith auth login PROVIDER --home DIR` (shell-quoted) and
points at `codesmith bridge init`.
…re from /login

codesmith bridge init NAME asks in the terminal how a tailbus bridge runs
(headless or a relay to a shared session), then for a headless one where
it works, a provider (untested ones tagged), a sign-in made for the
bridge (a key pasted or taken from a named environment variable, a
Claude Code token, or the provider's OAuth into the bridge home), a
model, and an effort from that model's own levels. It writes the
bridge's folder and a 0600 key file, tries the bridge exactly as tailbus
runs it (cleared environment, secrets read from their files, message on
stdin, output redacted), prints the [bridges.NAME] table, and only after
a yes appends it to tailbus's config and runs tailbus bridge install. A
bridge already in the config, a symlinked config or one that isn't valid
TOML is left alone; without a terminal nothing is written.

codesmith auth login --home DIR saves a login in another home's auth
store, reading that home's config; --to-file PATH writes a key or Claude
Code token to a file of its own and prints the secrets line. Logins that
rest on your own home's files aren't offered for either.

The sign-in picker, in /login and in auth login, ends with "For a bridge
or another home", which runs bridge init, --home or --to-file (from the
UI, handing over the terminal). /bus share points at bridge init.
docs/tailbus.md now leads with codesmith bridge init, with the
hand-made tables kept as the manual route; cli.md, bus.md,
getting-started.md, interactive-ui.md and the CHANGELOG cover the new
command, auth login --home and --to-file, and the picker's new row.
The refusals (your own home, a missing folder, an existing or symlinked
file, flags --to-file can't take) exit before reading the key, so
writing it could hit a closed pipe and fail the test now and then.
@reka18
reka18 merged commit abf0d57 into main Nov 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant