feat(local): protocol 2 — tabs in a folder or running a preset #1

Merged
dozken merged 1 commit from feat/terminal-cwd-presets into main 2026-09-23 18:13:07 +02:00
Owner

Summary

Protocol 2 for local plugins, for RKD #968 phase C1: terminal tabs that open in a chosen folder, run a preset command, and pick from recent folders and git worktrees.

  • Negotiation: PROTOCOL = 2, MIN_PROTOCOL = 1. The plugin answers a client in the client's own version, so an RKD app that speaks 1 keeps working unchanged.
  • open gains optional cwd and argv (v2 only). cwd must be an absolute, existing folder. argv runs as a program with its arguments, never through a shell, and the program is looked up like execvp. Every check runs before anything is spawned.
  • New dirs → dir_list: home, recent folders (most recent first, max 20, in <config>/recent.json under the store lock), then git worktrees of those repos (git worktree list --porcelain, 2 s timeout, no prompt).
  • test-vectors.json gains a messages section with byte-exact control-message bodies, each tagged with the protocol that added it.
  • Both crates go to 0.2.0. Tag v0.2.0 after merge; the RKD app pins it.

Tests

  • cargo fmt --all --check, cargo clippy --workspace --all-targets --locked -- -D warnings, cargo test --workspace --locked (terminal suite 3x; integration suite 12x after a test-only flake fix).
  • New tests cover:
    • v1 compatibility: a v1 client can still open a shell; a v1 connection gets refusals for v2 fields and dirs
    • cwd: runs in the requested folder
    • argv: /bin/echo "a;b" prints literally, and PATH lookup works
    • every refusal path
    • recent: most recent first, cap, persisted across restart
    • a real git worktree add
  • 28 hand-applied mutations, all killed.

Not tested directly: the git env vars, spawn_blocking placement, and "record recent only after a successful spawn" when a spawn fails after the checks pass (it can't be triggered).

https://claude.ai/code/session_01P4hUduqyzHTYckP7dX5fXV

## Summary Protocol 2 for local plugins, for RKD #968 phase C1: terminal tabs that open in a chosen folder, run a preset command, and pick from recent folders and git worktrees. - **Negotiation:** `PROTOCOL = 2`, `MIN_PROTOCOL = 1`. The plugin answers a client in the client's own version, so an RKD app that speaks 1 keeps working unchanged. - **`open` gains optional `cwd` and `argv`** (v2 only). `cwd` must be an absolute, existing folder. `argv` runs as a program with its arguments, never through a shell, and the program is looked up like execvp. Every check runs before anything is spawned. - **New `dirs` → `dir_list`:** home, recent folders (most recent first, max 20, in `<config>/recent.json` under the store lock), then git worktrees of those repos (`git worktree list --porcelain`, 2 s timeout, no prompt). - **`test-vectors.json`** gains a `messages` section with byte-exact control-message bodies, each tagged with the protocol that added it. - Both crates go to 0.2.0. Tag `v0.2.0` after merge; the RKD app pins it. ## Tests - `cargo fmt --all --check`, `cargo clippy --workspace --all-targets --locked -- -D warnings`, `cargo test --workspace --locked` (terminal suite 3x; integration suite 12x after a test-only flake fix). - New tests cover: - v1 compatibility: a v1 client can still open a shell; a v1 connection gets refusals for v2 fields and `dirs` - `cwd`: runs in the requested folder - `argv`: `/bin/echo "a;b"` prints literally, and PATH lookup works - every refusal path - recent: most recent first, cap, persisted across restart - a real `git worktree add` - 28 hand-applied mutations, all killed. Not tested directly: the git env vars, `spawn_blocking` placement, and "record recent only after a successful spawn" when a spawn fails after the checks pass (it can't be triggered). https://claude.ai/code/session_01P4hUduqyzHTYckP7dX5fXV
feat(local): protocol 2, tabs in a folder or running a preset
All checks were successful
CI / rust (pull_request) Successful in 35s
27fd5e3f41
rkd-local-link PROTOCOL is 2, and MIN_PROTOCOL = 1: a plugin accepts a
client hello in MIN_PROTOCOL..=PROTOCOL and answers with the client's
number, so an RKD app built for protocol 1 keeps working. What protocol 2
added is refused on a protocol 1 connection.

Protocol 2 (#968 phase C1):
- open gains optional cwd (absolute, existing folder, canonicalized) and
  argv (a program and its arguments, run directly, never via a shell).
  A bad folder, empty argv/argument, NUL or a program that cannot be
  found is open_failed with the reason, before anything is spawned.
- dirs { req } -> dir_list { req, dirs }: home, then the folders tabs
  were opened in (MRU, max 20, <config>/recent.json), then the git
  worktrees of their repositories with branch and repo. git runs as an
  argv with GIT_TERMINAL_PROMPT=0 and a 2 s timeout, off the connection
  task.

Both crates are 0.2.0. test-vectors.json gains control-message bodies
for the new shapes. The stale-socket server test now waits until nothing
listens: a concurrent spawn forking between its bind and drop briefly
kept a copy of the listener.

Claude-Session: https://claude.ai/code/session_01P4hUduqyzHTYckP7dX5fXV
dozken merged commit e541910e7a into main 2026-09-23 18:13:07 +02:00
dozken deleted branch feat/terminal-cwd-presets 2026-09-23 18:13:07 +02:00
Sign in to join this conversation.
No reviewers
No labels
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
rkd/plugins!1
No description provided.