Metadata-Version: 2.4
Name: colab-dev
Version: 0.1.0
Summary: Turn Google Colab runtimes into seamless, local-feeling dev environments for humans and coding agents.
Keywords: colab,google-colab,gpu,tpu,ssh,dev,ai-agents
Author: Boffee
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development
Requires-Dist: google-colab-cli>=0.8.0
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/Boffee/colab-dev
Project-URL: Repository, https://github.com/Boffee/colab-dev.git
Project-URL: Issues, https://github.com/Boffee/colab-dev/issues
Description-Content-Type: text/markdown

# colab-dev

Run commands on Google Colab runtimes (`cpu`, `t4`, `l4`, `g4`, `a100`, `h100`, `v5e1`, `v6e1`) as if they were local — built for both humans and coding agents (Antigravity, Claude Code, Codex, Cursor, etc.).

Keep your source code, Git branches, and AI agent sessions **permanently on your local machine**, and prefix any command with `colab-dev <target>` to run it on a live Colab runtime in ~150ms.

## Install & Uninstall

```bash
# Install (automatically bundles google-colab-cli)
uv tool install colab-dev  # or: pip install colab-dev

# Guided first-time setup (Google Colab sign-in, Ed25519 SSH key, optional agent skills & ~/.ssh/config)
# Or skip this and jump straight into `colab-dev t4 <cmd>` to sign in on first use.
colab-dev setup

# Verify Colab auth, SSH key, and tooling anytime (`--fix` auto-fixes missing login/key)
colab-dev doctor
```

Clean, complete removal (leaves zero stray config):

```bash
colab-dev clean --all
uv tool uninstall colab-dev
```

## Quick Start

> **Note:** Put `colab-dev` flags **before** the remote command: `colab-dev <target> [colab-dev-flags] <command> [command-flags]`.

```bash
# Run tests, benchmarks, or Nsight Compute on a T4 (auto-creates colab-t4)
colab-dev t4 pytest tests/ -k sm75
colab-dev t4 python benchmarks/bench.py
colab-dev t4 ncu --set basic --launch-count 1 python script.py

# Multiple concurrent runtimes (same or different hardware)
colab-dev t4:1 pytest tests/attention/
colab-dev t4:2 pytest tests/linear/
colab-dev a100 --idle 30m python train.py

# Hard timeout for kernels that might deadlock (kills remote process & frees VRAM; exits 124)
colab-dev t4 --timeout 5m pytest tests/test_kernel.py

# Persist session settings (extra repos/files, env vars, idle timer) — survives VM crashes until `stop`
colab-dev config t4 --add ../sibling-repo --idle 45m --env TRITON_DEFAULT_FP_FUSION=1
colab-dev config t4
colab-dev config t4 --remove sibling-repo

# Sync files explicitly or pull remote outputs back (sync is one-way: local -> /content/work/<repo>)
colab-dev push t4
colab-dev pull t4 outputs/report.json
colab-dev t4 --pull outputs/report.json python eval.py

# Open an interactive remote shell in your synced workspace
colab-dev shell t4

# View active runtimes, settings, and compute-unit balance; stop when done
colab-dev ls
colab-dev stop t4
colab-dev stop --all
```

## Project Config (Optional)

Define shared project defaults under `[tool.colab-dev]` in `pyproject.toml` (PEP 518) or `.colab-dev.toml`, and put machine-local untracked overrides (e.g., personal keys or preferred idle timer) in `.colab-dev.local.toml`:

```toml
[tool.colab-dev]
add = ["../sibling-repo"]
uv_args = ["--dev"]
idle = "30m"

[tool.colab-dev.env]
TRITON_DEFAULT_FP_FUSION = "1"
```

Precedence: CLI flags > persisted session `config` > `.colab-dev.local.toml` > `.colab-dev.toml` / `[tool.colab-dev]`.

## How It Works

1. **Zero `~/.ssh/config` edits required:** Uses an isolated SSH config under `~/.config/colab-dev/ssh_config` with automatic connection reuse and stale-connection recovery.
2. **Git-aware delta sync (~150ms):** Mirrors tracked + untracked non-ignored files to `/content/work/<repo>` over `rsync` (with `tar` fallback), leaving remote `.venv` and compiler caches untouched.
3. **Hash-stamped Python environments:** Hashes `pyproject.toml` + `uv.lock` (or `requirements.txt`) and runs `uv sync --dev` only when dependencies change (`--reinstall` to force). Keeps `UV_CACHE_DIR`, `TRITON_CACHE_DIR`, and `TORCHINDUCTOR_CACHE_DIR` on Colab's fast local SSD.
4. **Idle auto-stop vs. hang timeout:**
   - `--idle 30m` stops the runtime after 30 minutes with no active commands, interactive shells, or GPU compute processes (`nvidia-smi`) — never kills running work.
   - `--timeout 5m` enforces a wall-clock limit on a single command so wedged kernels terminate cleanly and release VRAM.
