feat: hopx shell — create a sandbox and open a terminal in one step#1
Merged
Conversation
… step Connecting to a fresh sandbox took two commands — `sandbox create`, then `terminal <id>` with the printed ID. `hopx shell` (alias `sh`) does both: creates a sandbox and attaches an interactive terminal to the live object (no reconnect round-trip). It reuses create's provisioning options (--template/-t, --timeout, --env/-e) and prints the sandbox ID on connect. By default the sandbox persists after you exit and can be reattached with `hopx terminal <id>`; `--rm` makes it ephemeral (killed on exit, like `docker run --rm`). The interactive-terminal plumbing (stdin forwarding, resize, cleanup) is extracted into src/lib/terminal/session.ts and shared by both `terminal` and `shell` — no behavior change for `terminal`. Bumps 0.2.2 -> 0.3.0; updates README, CLAUDE.md, CHANGELOG; adds a unit test. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds a mise.toml pinning bun (the project's runtime) so contributors get a consistent toolchain, and gitignores mise.local.toml where local secrets such as HOPX_API_KEY / HOPX_BASE_URL live. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
attachInteractiveTerminal connects the terminal WebSocket as its first action; if that rejects (e.g. agent not ready) after the sandbox was already created, the onExit hook never ran and a `--rm` sandbox was left running and billable. Wrap the attach call and best-effort kill on `--rm` before rethrowing. The kill logic is shared with the onExit hook. Addresses review feedback on PR #1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Connecting to a fresh sandbox took two commands —
hopx sandbox create, then copying the printed ID intohopx terminal <id>. This PR addshopx shell(aliassh) that does both in one step.Sandbox.create()— no reconnect round-trip.create's provisioning options:--template/-t,--timeout,--env/-e.Lifecycle on exit
hopx terminal <id>.--rm: ephemeral — the sandbox is killed when the session ends (à ladocker run --rm).Refactor
The interactive-terminal plumbing (raw stdin forwarding, resize handling, cleanup) was extracted from
terminal.tsintosrc/lib/terminal/session.tsand is now shared by bothterminalandshell. No behavior change forhopx terminal(it's now a thin wrapper). The shared helper takes anonExithook, which--rmuses to kill the sandbox before exit.Changes
src/commands/shell.ts— new commandsrc/lib/terminal/session.ts— sharedattachInteractiveTerminal()helpersrc/commands/terminal.ts— refactored onto the helper (~70 fewer lines)src/index.ts— registershellCommand0.2.2 → 0.3.0(package.json + version.ts)shellcommand shapechorecommit: pin bun viamise.toml, gitignoremise.local.toml(local secrets)Testing
bun test(offline): 200 pass, 0 failSKIP_E2E=0, real key): 21 pass, 0 failhopx shell --help/--versionverified;tsc --noEmitclean for all touched files🤖 Generated with Claude Code