Codespace Manager
Manage isolated code-server development environments, similar to GitHub Codespaces. Each codespace runs in its own Docker container with a full VS Code editor accessible via browser through Cloudflare Tunnel.
Pre-installed Tools
The custom Docker image includes:
- - code-server (VS Code in browser)
- Bun — JS/TS runtime + package manager
- uv — Python package manager + virtual environments
- OpenCode — AI coding assistant (CLI)
- git, curl, wget, build-essential
First-Time Setup
Before creating any codespace, build the Docker image once:
CODEBLOCK0
This builds codespace-manager:latest from assets/Dockerfile.txt. Only needed once per host.
Commands
Script location: scripts/codespace.sh (relative to this skill's directory)
CODEBLOCK1
Password Management
- - Default password: INLINECODE3
- Set a custom default: INLINECODE4
- Override per-session via environment: INLINECODE5
- Each codespace saves its password at creation time
Natural Language → Command Mapping
| User says | Command |
|---|
| "create a codespace called myapp" | INLINECODE6 |
| "create a codespace with opencode" |
codespace create <name> --opencode |
| "set up a dev environment for this repo" |
codespace create <name> --git <url> --opencode |
| "start / launch / open myapp" |
codespace start myapp |
| "stop / shut down myapp" |
codespace stop myapp |
| "delete / remove myapp" |
codespace delete myapp (confirm with user first!) |
| "list my codespaces" / "show environments" |
codespace list |
| "get the URL for myapp" |
codespace url myapp |
| "set password to xyz" |
codespace password xyz |
| "create a python project" |
codespace create <name> --opencode (uv is pre-installed) |
| "create a node/bun project" |
codespace create <name> --opencode (bun is pre-installed) |
Architecture
- - Each codespace = isolated Docker container (
codespace-manager:latest) - Project files persist at
~/codespaces/<name>/project on the host - Exposed via Cloudflare Quick Tunnel (free, auto HTTPS, temporary URL)
- Each codespace gets a deterministic port (9000-9999, based on name hash)
Important Notes
- 1. Run
codespace setup before first use — it builds the Docker image - Quick Tunnel URLs are temporary — they change on restart
- INLINECODE20 is irreversible — confirm with user before executing
- Container data (outside
/home/coder/project) does not persist across delete/recreate - Requires: Docker, cloudflared, jq installed on the host
OpenCode Config
When --opencode is used, a opencode.json is created in the project root with:
CODEBLOCK2
Users can edit this file in code-server to change the model or add provider keys.
代码空间管理器
管理隔离的代码服务器开发环境,类似于 GitHub Codespaces。每个代码空间在其自己的 Docker 容器中运行,通过 Cloudflare Tunnel 可在浏览器中访问完整的 VS Code 编辑器。
预装工具
自定义 Docker 镜像包含:
- - code-server(浏览器中的 VS Code)
- Bun — JS/TS 运行时 + 包管理器
- uv — Python 包管理器 + 虚拟环境
- OpenCode — AI 编码助手(命令行界面)
- git、curl、wget、build-essential
首次设置
在创建任何代码空间之前,先构建一次 Docker 镜像:
bash
bash scripts/codespace.sh setup
这将从 assets/Dockerfile.txt 构建 codespace-manager:latest。每台主机只需执行一次。
命令
脚本位置:scripts/codespace.sh(相对于本技能目录)
bash
一次性镜像构建
codespace setup
创建代码空间(可选择克隆仓库和/或初始化 OpenCode 配置)
codespace create <名称>
codespace create <名称> --git <仓库地址>
codespace create <名称> --opencode
codespace create <名称> --git <仓库地址> --opencode
生命周期管理
codespace start <名称> # 启动并获取 Cloudflare Tunnel URL
codespace stop <名称> # 停止容器和隧道
codespace restart <名称> # 停止后启动(获取新 URL)
codespace delete <名称> # 删除容器和数据(不可逆!)
信息查询
codespace list # 列出所有代码空间及其状态
codespace status <名称> # 查看单个代码空间的详细状态
codespace logs <名称> # 查看容器日志
codespace url <名称> # 重新生成隧道 URL
配置
codespace password <密码> # 设置新代码空间的默认密码
密码管理
- - 默认密码:codespace
- 设置自定义默认密码:codespace password <你的密码>
- 通过环境变量覆盖每次会话的密码:CODESPACE_PASSWORD=mypass codespace create foo
- 每个代码空间在创建时保存其密码
自然语言 → 命令映射
| 用户说 | 命令 |
|---|
| 创建一个名为 myapp 的代码空间 | codespace create myapp |
| 创建一个带 opencode 的代码空间 |
codespace create <名称> --opencode |
| 为这个仓库设置开发环境 | codespace create <名称> --git <地址> --opencode |
| 启动/打开 myapp | codespace start myapp |
| 停止/关闭 myapp | codespace stop myapp |
| 删除/移除 myapp | codespace delete myapp(先与用户确认!) |
| 列出我的代码空间/显示环境 | codespace list |
| 获取 myapp 的 URL | codespace url myapp |
| 将密码设置为 xyz | codespace password xyz |
| 创建一个 Python 项目 | codespace create <名称> --opencode(已预装 uv) |
| 创建一个 node/bun 项目 | codespace create <名称> --opencode(已预装 bun) |
架构
- - 每个代码空间 = 隔离的 Docker 容器(codespace-manager:latest)
- 项目文件持久化存储在宿主机的 ~/codespaces/<名称>/project 目录
- 通过 Cloudflare Quick Tunnel 暴露(免费、自动 HTTPS、临时 URL)
- 每个代码空间分配一个确定的端口(9000-9999,基于名称哈希)
重要说明
- 1. 首次使用前运行 codespace setup — 它将构建 Docker 镜像
- Quick Tunnel URL 是临时的 — 重启后会变化
- codespace delete 不可逆 — 执行前请与用户确认
- 容器数据(/home/coder/project 之外)在删除/重新创建后不会持久化
- 需要宿主机安装:Docker、cloudflared、jq
OpenCode 配置
使用 --opencode 时,会在项目根目录创建 opencode.json,内容如下:
json
{
$schema: https://opencode.ai/config.json,
model: anthropic/claude-sonnet-4-5,
autoupdate: true
}
用户可以在 code-server 中编辑此文件以更改模型或添加提供商密钥。