|
1 | | -# Workspace CLI |
| 1 | +# Workspace |
2 | 2 |
|
3 | 3 | [](https://github.com/subroutinecom/workspace/actions/workflows/test.yml) |
4 | 4 | [](https://www.npmjs.com/package/@subroutinecom/workspace) |
5 | 5 | [](https://opensource.org/licenses/MIT) |
6 | 6 |
|
7 | | -Containerized development environments with Docker-in-Docker, SSH access, and persistent storage. |
| 7 | +Isolated, self-hosted workspaces accessible over Tailscale. AI coding agents, web UI, and remote terminal access. |
8 | 8 |
|
9 | | -## Install |
| 9 | +## Features |
| 10 | + |
| 11 | +- **AI Coding Agents** - Claude Code, OpenCode, GitHub Copilot pre-installed |
| 12 | +- **Self-Hosted** - Run on your own hardware, full control |
| 13 | +- **Remote Access** - Use from anywhere via Tailscale, CLI, web, or SSH |
| 14 | +- **Web UI** - Manage workspaces from your browser |
| 15 | +- **Isolated Environments** - Each workspace runs in its own container |
| 16 | + |
| 17 | +## Setup |
| 18 | + |
| 19 | +### Install |
10 | 20 |
|
11 | 21 | ```bash |
12 | 22 | npm install -g @subroutinecom/workspace |
13 | 23 | ``` |
14 | 24 |
|
15 | | -## Quick Start |
| 25 | +Or with curl: |
16 | 26 |
|
17 | 27 | ```bash |
18 | | -# Initialize in your project |
19 | | -cd myproject |
20 | | -workspace init |
21 | | - |
22 | | -# Edit .workspace.yml, then start |
23 | | -workspace start |
24 | | -workspace shell # SSH into container |
25 | | -workspace proxy # Port forwarding (separate terminal) |
| 28 | +curl -fsSL https://workspace.subroutine.com/install.sh | sh |
26 | 29 | ``` |
27 | 30 |
|
28 | | -## Configuration |
| 31 | +### Build Base Image |
29 | 32 |
|
30 | | -### Project Configuration |
| 33 | +```bash |
| 34 | +ws build |
| 35 | +``` |
31 | 36 |
|
32 | | -`.workspace.yml` in your project: |
| 37 | +### Start Agent |
33 | 38 |
|
34 | | -```yaml |
35 | | -repo: |
36 | | - remote: git@github.com:user/repo.git |
37 | | - branch: main |
38 | | - |
39 | | -bootstrap: |
40 | | - scripts: |
41 | | - - scripts/install-deps.sh |
42 | | - |
43 | | -forwards: |
44 | | - - 3000 |
45 | | - - 5173 |
46 | | - - "8000-8010" |
47 | | - |
48 | | -mounts: |
49 | | - - ./local:/home/workspace/otherLocalData |
50 | | - - ~/data:/data:ro |
| 39 | +```bash |
| 40 | +ws agent start |
51 | 41 | ``` |
52 | 42 |
|
53 | | -### User Configuration |
| 43 | +Web UI: **http://localhost:7391** |
54 | 44 |
|
55 | | -`~/.workspaces/config.yml` for user-specific settings across all workspaces: |
| 45 | +The agent runs on port 7391 by default. For remote access: |
56 | 46 |
|
57 | | -```yaml |
58 | | -ssh: |
59 | | - # Default SSH key (optional - uses heuristic if not specified) |
60 | | - defaultKey: ~/.ssh/id_ed25519 |
61 | | -
|
62 | | - # Per-repository key overrides (supports wildcards) |
63 | | - repos: |
64 | | - "git@github.com:user/private-repo.git": ~/.ssh/id_github_personal |
65 | | - "git@github.com:company/*": ~/.ssh/id_github_work |
66 | | -
|
67 | | -bootstrap: |
68 | | - scripts: |
69 | | - - userscripts # Directory: runs all executable files alphabetically |
| 47 | +```bash |
| 48 | +ws agent start --host 0.0.0.0 |
70 | 49 | ``` |
71 | 50 |
|
72 | | -User config is automatically created on first run with `userscripts` directory reference. Paths are relative to `~/.workspaces/`. Directories auto-expand to run all executable files. Configuration is merged with project config - user bootstrap scripts run **after** project scripts. |
| 51 | +### Create & Use Workspaces |
73 | 52 |
|
74 | | -**SSH Configuration:** |
| 53 | +**Via CLI:** |
75 | 54 |
|
76 | | -- All SSH keys from `~/.ssh/` are copied to containers |
77 | | -- Specify `defaultKey` to set which key is used by default for git operations |
78 | | -- Per-repository overrides support exact matches and wildcard patterns |
79 | | -- If no `defaultKey` is specified, the CLI uses SSH agent keys or falls back to `id_ed25519`, `id_ecdsa`, or `id_rsa` |
80 | | -- The selected key is automatically configured in git and SSH config inside containers |
| 55 | +```bash |
| 56 | +# Create workspace |
| 57 | +ws create myproject |
81 | 58 |
|
82 | | -**Bootstrap scripts** run as `workspace` user with passwordless sudo. |
| 59 | +# Or clone a repo |
| 60 | +ws create myproject --clone git@github.com:user/repo.git |
83 | 61 |
|
84 | | -**Mounts** format: `source:target[:mode]`. Relative paths resolve from config directory. Tilde expands to home. By default workspace mounts your host $HOME at `/host/home` (read-only). |
| 62 | +# SSH into workspace |
| 63 | +ws list # Find SSH port |
| 64 | +ssh -p 2201 workspace@localhost |
85 | 65 |
|
86 | | -**Forwards** creates SSH tunnels when running `workspace proxy <name>`. |
| 66 | +# Manage workspaces |
| 67 | +ws start myproject |
| 68 | +ws stop myproject |
| 69 | +ws delete myproject |
| 70 | +``` |
87 | 71 |
|
88 | | -## Commands |
| 72 | +**Via Web UI:** |
89 | 73 |
|
90 | | -```bash |
91 | | -# Lifecycle |
92 | | -workspace start [name] # Start workspace (auto-builds image) |
93 | | -workspace stop [name] # Stop workspace |
94 | | -workspace destroy [name...] [-f] # Remove container + volumes |
95 | | -workspace status [name] # Show state (CPU, memory, ports) |
96 | | -
|
97 | | -# Development |
98 | | -workspace shell [name] [-c "cmd"] # SSH into container |
99 | | -workspace proxy [name] # Port forwarding tunnel |
100 | | -workspace logs [name] [-f] # Container logs |
101 | | -
|
102 | | -# Discovery |
103 | | -workspace list # Find all .workspace.yml files |
104 | | -workspace config [name] # Show resolved configuration |
105 | | -workspace doctor # Check prerequisites |
106 | | -
|
107 | | -# Image/BuildKit |
108 | | -workspace build [--no-cache] # Build base image |
109 | | -workspace buildkit [--status] # Manage shared BuildKit |
110 | | -``` |
| 74 | +Open http://localhost:7391 and click "+" to create a workspace. |
111 | 75 |
|
112 | | -Commands run from project directory use that workspace. Or specify name from anywhere. |
| 76 | +## Security |
113 | 77 |
|
114 | | -## What's Inside |
| 78 | +Workspace is designed for use within **secure networks** like [Tailscale](https://tailscale.com). The web UI and API have no authentication, making them ideal for private networks where you can safely access workspaces remotely without additional security concerns. |
115 | 79 |
|
116 | | -- **OS**: Ubuntu 24.04 LTS |
117 | | -- **Docker**: CE + Compose + BuildKit |
118 | | -- **Languages**: Node.js 22, Python 3 |
119 | | -- **Editor**: Neovim v0.11.4 + LazyVim |
120 | | -- **Tools**: Git, GitHub CLI, ripgrep, fd-find, jq, curl, wget, rsync |
121 | | -- **User**: `workspace` with passwordless sudo |
| 80 | +For public internet exposure, place behind a reverse proxy with authentication. |
122 | 81 |
|
123 | | -## User Scripts |
| 82 | +## Configuration |
124 | 83 |
|
125 | | -Add executable scripts to `~/.workspaces/userscripts/` - they run automatically in all workspaces: |
| 84 | +Configure credentials and environment variables via Web UI → Settings or edit `~/.workspace-agent/config.yaml`: |
126 | 85 |
|
127 | 86 | ```yaml |
128 | | -# ~/.workspaces/config.yml (auto-created on first run) |
129 | | -bootstrap: |
130 | | - scripts: |
131 | | - - userscripts # Runs all executable files in directory |
| 87 | +credentials: |
| 88 | + env: |
| 89 | + ANTHROPIC_API_KEY: "sk-ant-..." |
| 90 | + OPENAI_API_KEY: "sk-..." |
| 91 | + GITHUB_TOKEN: "ghp_..." |
| 92 | + files: |
| 93 | + ~/.ssh/id_ed25519: ~/.ssh/id_ed25519 |
| 94 | + ~/.gitconfig: ~/.gitconfig |
132 | 95 | ``` |
133 | 96 |
|
134 | | -Example script: |
| 97 | +Restart workspaces to apply changes. |
| 98 | +
|
| 99 | +## What's Inside Each Workspace |
| 100 | +
|
| 101 | +- Ubuntu 24.04 LTS |
| 102 | +- Node.js 22, Python 3, Go |
| 103 | +- Docker (for containerized development) |
| 104 | +- Neovim + LazyVim |
| 105 | +- Git, GitHub CLI, ripgrep, fd-find, jq |
| 106 | +- Claude Code, OpenCode, Codex CLI |
| 107 | +
|
| 108 | +## Commands |
135 | 109 |
|
136 | 110 | ```bash |
137 | | -# ~/.workspaces/userscripts/setup-shell.sh |
138 | | -#!/bin/bash |
139 | | -echo "Setting up shell configuration..." |
140 | | -cp /host/home/.zshrc ~/.zshrc |
| 111 | +# Agent |
| 112 | +ws agent start [--port PORT] [--host HOST] |
| 113 | +ws agent stop |
| 114 | +ws agent status |
| 115 | + |
| 116 | +# Workspaces |
| 117 | +ws create <name> [--clone URL] |
| 118 | +ws start <name> |
| 119 | +ws stop <name> |
| 120 | +ws delete <name> |
| 121 | +ws list |
| 122 | +ws logs <name> [-f] |
| 123 | + |
| 124 | +# Build |
| 125 | +ws build [--no-cache] |
| 126 | +ws doctor |
141 | 127 | ``` |
142 | 128 |
|
143 | | -Make scripts executable: `chmod +x ~/.workspaces/userscripts/setup-shell.sh` |
| 129 | +## Documentation |
144 | 130 |
|
145 | | -**Directory expansion**: Point at a directory to run all executable files alphabetically. Or specify individual scripts for precise control. |
| 131 | +Full docs at https://workspace.subroutine.com/docs |
146 | 132 |
|
147 | | -User scripts execute after project bootstrap scripts in the order listed. |
| 133 | +Or run locally: |
148 | 134 |
|
149 | | -## Testing |
| 135 | +```bash |
| 136 | +cd docs |
| 137 | +npm install |
| 138 | +npm start |
| 139 | +``` |
| 140 | + |
| 141 | +## Development |
150 | 142 |
|
151 | 143 | ```bash |
152 | | -npm test |
| 144 | +git clone https://github.com/subroutinecom/workspace.git |
| 145 | +cd workspace |
| 146 | +bun install |
| 147 | +bun run build |
153 | 148 | ``` |
154 | 149 |
|
155 | | -## Prerequisites |
| 150 | +Run tests: |
| 151 | + |
| 152 | +```bash |
| 153 | +bun run validate # Lint, typecheck, build, test |
| 154 | +bun run test # Tests only |
| 155 | +``` |
156 | 156 |
|
157 | | -- Docker Desktop or Engine |
158 | | -- SSH client + ssh-keygen |
159 | | -- Node.js 18+ |
| 157 | +## License |
160 | 158 |
|
161 | | -Run `workspace doctor` to verify. |
| 159 | +MIT |
0 commit comments