Skip to content

Add sandbox sync command#97

Draft
michael-webster wants to merge 4 commits intomainfrom
webster/sandbox-push-code
Draft

Add sandbox sync command#97
michael-webster wants to merge 4 commits intomainfrom
webster/sandbox-push-code

Conversation

@michael-webster
Copy link
Contributor

Summary

  • Adds chunk sandboxes sync --org-id <id> --sandbox-id <id> to rsync the current working directory to a sandbox over SSH
  • Re-adds the SSH public key on each sync (idempotent) as a way to obtain the sandbox URL, then runs rsync through the socat/OPENSSL tunnel
  • Defaults: --public-key-file ~/.ssh/id_ed25519.pub, --dest /workspace

Changes

  • src/commands/sandbox.ts: new syncToSandbox function + buildRsyncArgs pure helper, registered as chunk sandboxes sync
  • Bug fix: resolvePublicKeyFile errors (missing file, private key) were previously uncaught and would propagate; now handled gracefully with exitCode: 2
  • src/__tests__/sandbox-sync.unit.test.ts: 10 unit tests covering rsync arg construction and all error paths

Test plan

  • bun test src/__tests__/sandbox-sync.unit.test.ts passes
  • chunk sandboxes sync --help shows expected flags and defaults
  • Manual smoke test: run sync against a real sandbox and verify files appear at --dest

@michael-webster michael-webster force-pushed the webster/sandbox-push-code branch 19 times, most recently from 902de9f to 7e9f4a8 Compare March 18, 2026 23:56
webster added 3 commits March 18, 2026 19:58
Replace Bun.spawn(["ssh"]) + socat ProxyCommand with the ssh2 npm
library connected over tls.connect() on port 2222, eliminating both
binary dependencies.

- execOverSsh: connects via TLS socket, runs a command, streams
  stdin/stdout/stderr, resolves with exit code
- verifyHostKey: TOFU implementation — accepts unknown hosts on first
  connect, rejects fingerprint mismatches on subsequent connects
- shellJoin: single-quote escapes args for safe shell interpolation
- Add core/sandboxes.ts: listSandboxes, createNewSandbox,
  execCommandInSandbox, addSshKeyToSandbox orchestrators
- Add core/sandboxes.steps.ts: pure helpers (validatePublicKey,
  resolvePublicKeyFile)
- Thin commands/sandbox.ts to command registration only; move business
  logic to core
- Add CommandError struct to types/index.ts so commands can carry
  structured error data through to the CLI layer
@michael-webster michael-webster force-pushed the webster/sandbox-push-code branch 3 times, most recently from 469a315 to 14ad2e0 Compare March 19, 2026 00:28
- Add core/sandbox-session.ts: manages the chunk_ai keypair and opens
  authenticated SSH sessions via the CircleCI access token API
- Add runOverSsh and syncToSandbox orchestrators to core/sandboxes.ts
- Add buildSandboxInitCommand to core/sandboxes.steps.ts
- sandboxes sync: generates a patch against the remote base and applies
  it on the sandbox; --bootstrap flag clones the repo first
- sandboxes ssh: runs an arbitrary command on the sandbox over SSH
@michael-webster michael-webster force-pushed the webster/sandbox-push-code branch from 14ad2e0 to f8001a6 Compare March 19, 2026 00:34
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