Skip to content

feat(remote): Tailscale key injection and --open/--yes flags - #233

Merged
gerchowl merged 5 commits into
feature/70-remote-devc-orchestrationfrom
feature/230-tailscale-key-injection
Mar 7, 2026
Merged

gerchowl merged 5 commits into
feature/70-remote-devc-orchestrationfrom
feature/230-tailscale-key-injection

Conversation

@gerchowl

@gerchowl gerchowl commented Mar 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add --open <ide>|none flag to decouple IDE from infra (--open none for headless/scripted use)
  • Add --yes flag for non-interactive mode
  • Add inject_tailscale_key() — generates ephemeral Tailscale auth keys via OAuth API and injects into remote docker-compose.local.yaml
  • Key injection is fully opt-in: silent no-op when TS_CLIENT_ID/TS_CLIENT_SECRET are absent

How it works

Local: TS_CLIENT_ID + TS_CLIENT_SECRET
  → OAuth token from api.tailscale.com
  → Ephemeral auth key (tag:devcontainer)
  → SSH inject into remote docker-compose.local.yaml
  → compose up → container joins tailnet

Test plan

  • BATS: --open none skips editor detection
  • BATS: --open code fails when code not in PATH
  • BATS: --open invalid rejected
  • BATS: --yes accepted
  • BATS: inject_tailscale_key skips when OAuth creds unset
  • BATS: function defined and called in main
  • All 34 existing + new tests pass
  • Manual: test with real Tailscale OAuth creds on remote host

Part of

Epic: #232
Closes: #230
Depends on: #208 (Tailscale SSH in workspace template)

References

gerchowl added 2 commits March 6, 2026 21:54
- Add --open cursor|code|none flag to control IDE opening (default: cursor)
- Add --yes flag for non-interactive mode (reuse running containers)
- Add inject_tailscale_key() that generates ephemeral auth keys via
  Tailscale OAuth API when TS_CLIENT_ID/TS_CLIENT_SECRET are set locally,
  then injects TAILSCALE_AUTHKEY into remote docker-compose.local.yaml
- Key injection is opt-in: silent no-op when OAuth creds are absent
- Add BATS tests for new flags and tailscale key injection

Refs: #230
…output

- Add --open ssh: waits for container to appear on tailnet (polls up to
  60s), then prints connection commands for ssh, Cursor, and VS Code
- Extract read_workspace_folder() helper from open_editor()
- Add wait_for_tailscale() that discovers the container via local
  tailscale status --json, matching devcontainer.json name field
- Refactor main() to use case/esac for cleaner mode dispatch
- Add BATS tests for --open ssh and new function definitions

Refs: #231
gerchowl and others added 3 commits March 6, 2026 22:38
Default --open mode is now 'auto' instead of hardcoding 'cursor'.
Detection chain: TERM_PROGRAM env var → CLI availability → ssh fallback.
Terminal apps (WezTerm, iTerm, tmux) resolve directly to ssh mode.

Refs: #231
Co-Authored-By: Claude Opus 4.6 <[email protected]>
The PR title check was false-positiving on legitimate references to
.cursor/, .claude/ directories and CLAUDE.md. Add allow_patterns to
agent-blocklist.toml that strip path-like occurrences before matching.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

Refs: #231
## Summary

Adds `--open ssh` mode to `devc-remote.sh` that decouples the script
from any specific IDE. After compose up, it polls the local tailnet for
the container, then prints connection commands for any client.

## What changed

- **`--open ssh`**: waits up to 60s for the container to appear on the
tailnet, then outputs:
  ```
  Connect via:
    ssh root@fd5-devc-sdsc
    ssh [email protected]

  Cursr:  cursr --remote ssh-remote+root@fd5-devc-sdsc /workspace/fd5
  VS Code: code --remote ssh-remote+root@fd5-devc-sdsc /workspace/fd5
  ```
- **`read_workspace_folder()`**: extracted from `open_editor()`, reused
by both devcontainer-protocol and SSH modes
- **`wait_for_tailscale()`**: polls `tailscale status --json` locally,
matches container by `devcontainer.json` name field
- **`main()` refactored**: clean `case/esac` dispatch for
cursr/code/ssh/none

## `--open` modes summary

| Mode | Behavior |
|------|----------|
| `cursr` (default) | Open Cursr via devcontainer protocol URI |
| `code` | Open VS Code via devcontainer protocol URI |
| `ssh` | Wait for Tailscale, print connection commands |
| `none` | Infra only, no IDE |

## Test plan

- [x] BATS: `--open ssh` skips editor detection
- [x] BATS: `--open invalid` rejects with updated error message
- [x] BATS: `wait_for_tailscale` and `read_workspace_folder` defined
- [x] All 37 tests pass
- [ ] Manual: test with real Tailscale container on remote host

## Part of

Epic: #232
Closes: #231
Stacked on: #233 (Tailscale key injection)
@gerchowl
gerchowl merged commit b041afa into feature/70-remote-devc-orchestration Mar 7, 2026
1 check passed
@gerchowl
gerchowl deleted the feature/230-tailscale-key-injection branch March 7, 2026 13:18
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