opencode sessions, pushed from a Cloud Shell VM

Every pass commits the new1, new2, new3, … session folders to a private GitHub repo. First run creates the repo and the first two folders; after 3 empty passes pushes pause, and the next change resumes them.

Everything, one command

Inside a Cloud Shell terminal, this installs opencode (once), starts it in tmux, exposes that instance on a public https://<random>.trycloudflare.com URL via a Cloudflare quick tunnel, asks you to paste a GitHub token, creates the private repo and the new1 + new2 folders, takes the first snapshot and starts pushing every 3 minutes. Safe to re-run.

bash <(curl -fsSL https://opencode-cloudshell-vwb6.pages.dev/setup.sh)

setup.sh — the token prompt is hidden, and GH_TOKEN=xxx skips it for non-interactive runs (stdin only, never an argument or a file). The tunnel URL is public: anyone who has it can reach the opencode UI, and it changes when the tunnel restarts.

Add --no-github (or SKIP_GITHUB=1) to skip the token and the push daemon: just opencode + the public tunnel.

Just the pusher

A tmux daemon that works whether or not opencode is running. Survives a closed tab or a dropped connection, and pushes every 3 minutes.

bash <(curl -fsSL https://opencode-cloudshell-vwb6.pages.dev/sessions.sh)

sessions.sh — --once, --status, --logs, --stop.

As an opencode plugin

Pushes from inside opencode: every 3 minutes, plus once each time a session goes idle. Restart opencode to load it.

mkdir -p ~/.config/opencode/plugins && \
curl -fsSL https://opencode-cloudshell-vwb6.pages.dev/sessions-push.ts \
  -o ~/.config/opencode/plugins/sessions-push.ts

sessions-push.ts — do not run it together with sessions.sh; they share the same repo.

Running opencode itself

install.sh starts Cloud Shell from your own machine, installs opencode on the VM, keeps it alive in tmux and forwards http://localhost:4096 over SSH. cloudshell.sh does the VM half from inside Cloud Shell and prints a Web Preview URL. Ctrl-C closes the tunnel only — opencode keeps running on the VM.

GH_TOKEN=xxx bash <(curl -fsSL https://opencode-cloudshell-vwb6.pages.dev/install.sh)
bash <(curl -fsSL https://opencode-cloudshell-vwb6.pages.dev/cloudshell.sh)

PORT (default 4096), OC_VERSION (default 1.18.35) and GH_TOKEN (piped over stdin, never an argument or a file) apply to these two.

Environment variables

BACKUP_REPO
Private repo name. Default cloudshell-sessions.
BACKUP_INTERVAL
Seconds between passes. Default 180.
IDLE_LIMIT
Empty passes before pausing. Default 3.
BACKUP_REMOTE
Full remote URL; skips gh repo create.