swe-swe 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +32 -719
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -1,16 +1,18 @@
1
1
  # swe-swe
2
2
 
3
- Your agent: containerized with its own browser for manual testing. Your terminal: pair live or share recordings with teammates. Your sessions: run multiple in parallel, each on its own git worktree.
3
+ **Your agent:** containerized with its own browser for agentic testing.<br>
4
+ **Your terminal:** pair live or share recordings with teammates.<br>
5
+ **Your sessions:** run multiple in parallel, each on its own git worktree.
4
6
 
5
- Works with Claude, Aider, Goose, Gemini, Codex, OpenCode. Not listed? [Let us know](https://github.com/choonkeat/swe-swe/issues)!
7
+ Works with Claude, Codex, OpenCode, Gemini, Aider, Goose. Not listed? [Let us know](https://github.com/choonkeat/swe-swe/issues)!
6
8
 
7
9
  ## Quick Start
8
10
 
9
11
  1. **Install swe-swe**
10
12
 
11
- Option A: run via npx (recommended, no install needed)
13
+ Option A: run via npx (requires Node.js)
12
14
  ```bash
13
- alias swe-swe='npx --prefer-online --yes swe-swe'
15
+ alias swe-swe='npx -y swe-swe'
14
16
  ```
15
17
 
16
18
  Option B: install via curl
@@ -18,31 +20,18 @@ Works with Claude, Aider, Goose, Gemini, Codex, OpenCode. Not listed? [Let us kn
18
20
  curl -fsSL https://raw.githubusercontent.com/choonkeat/swe-swe/main/install.sh | sh
19
21
  ```
20
22
 
21
- 2. **Initialize a project**
23
+ 2. **Go to your project**
22
24
  ```bash
23
- swe-swe init --project-directory /path/to/your/project
25
+ cd /path/to/your/project
24
26
  ```
25
27
 
26
- 3. **Start the environment**
28
+ 3. **Initialize and start**
27
29
  ```bash
28
- swe-swe up --project-directory /path/to/your/project
30
+ swe-swe init
31
+ swe-swe up
29
32
  ```
30
33
 
31
- 4. **Access the services** (use `https://` if initialized with `--ssl=selfsign`)
32
- - **swe-swe terminal**: http://0.0.0.0:1977
33
- - **VSCode**: http://0.0.0.0:1977/vscode
34
- - **Chrome Browser**: http://0.0.0.0:1977/chrome (browser screencast viewer)
35
- - **Traefik dashboard**: http://0.0.0.0:1977/dashboard/
36
-
37
- 5. **View all initialized projects**
38
- ```bash
39
- swe-swe list
40
- ```
41
-
42
- 6. **Stop the environment**
43
- ```bash
44
- swe-swe down --project-directory /path/to/your/project
45
- ```
34
+ 4. **Open** http://localhost:1977
46
35
 
47
36
  ### Requirements
48
37
 
@@ -51,716 +40,40 @@ Works with Claude, Aider, Goose, Gemini, Codex, OpenCode. Not listed? [Let us kn
51
40
 
52
41
  ## Commands
53
42
 
54
- swe-swe has three native commands (`init`, `list`, and `proxy`). All other commands are passed directly to `docker compose` with the project's configuration.
55
-
56
- ### Native Commands
57
-
58
- #### `swe-swe init [options]`
59
-
60
- Initializes a new swe-swe project at the specified path. Creates metadata directory at `$HOME/.swe-swe/projects/{sanitized-path}/` (see [Directory Structure](#directory-structure) for full layout).
61
-
62
- **Options**:
63
- - `--project-directory PATH`: Project directory (defaults to current directory)
64
- - `--previous-init-flags=reuse`: Reapply saved configuration from previous init (cannot be combined with other flags)
65
- - `--previous-init-flags=ignore`: Ignore saved configuration, use provided flags for fresh init
66
- - `--agents AGENTS`: Comma-separated list of agents to include (default: all)
67
- - `--exclude-agents AGENTS`: Comma-separated list of agents to exclude
68
- - `--apt-get-install PACKAGES`: Additional apt packages to install
69
- - `--npm-install PACKAGES`: Additional npm packages to install globally
70
- - `--with-docker`: Mount Docker socket to allow container to run Docker commands on host
71
- - `--with-slash-commands REPOS`: Git repos to clone as slash commands for Claude, Codex, and OpenCode (space-separated, format: `[alias@]<git-url>`)
72
- - `--ssl MODE`: SSL/TLS mode - `no` (default, HTTP), `selfsign` (HTTPS with self-signed certificate), `selfsign@<hostname>` (includes hostname/IP in cert for remote access), `letsencrypt@domain` (HTTPS with Let's Encrypt), or `letsencrypt-staging@domain` (internal testing)
73
- - `--email EMAIL`: Email for Let's Encrypt certificate expiry notifications (required with letsencrypt)
74
- - `--copy-home-paths PATHS`: Comma-separated paths relative to `$HOME` to copy into the container's home directory (e.g., `.gitconfig,.ssh/config`)
75
- - `--preview-ports RANGE`: App preview port range (default: `3000-3019`). Each session gets its own preview port from this range.
76
- - `--status-bar-color COLOR`: Status bar background color (default: `#007acc`). Use `--status-bar-color=list` to see available preset colors.
77
- - `--terminal-font-size SIZE`: Terminal font size in pixels (default: `14`)
78
- - `--terminal-font-family FONT`: Terminal font family (default: `Menlo, Monaco, "Courier New", monospace`)
79
- - `--status-bar-font-size SIZE`: Status bar font size in pixels (default: `12`)
80
- - `--status-bar-font-family FONT`: Status bar font family (default: system sans-serif)
81
-
82
- **Available Agents**: `claude`, `gemini`, `codex`, `aider`, `goose`, `opencode`
83
-
84
- **Examples**:
85
- ```bash
86
- # Initialize current directory with all agents (default)
87
- swe-swe init
88
-
89
- # Initialize current directory with Claude only (minimal, fastest build)
90
- swe-swe init --agents=claude
91
-
92
- # Initialize current directory with Claude and Gemini
93
- swe-swe init --agents=claude,gemini
94
-
95
- # Initialize current directory without Python-based agents (no aider)
96
- swe-swe init --exclude-agents=aider
97
-
98
- # Initialize current directory with additional system packages
99
- swe-swe init --apt-get-install="vim htop tmux"
100
-
101
- # Initialize current directory with Docker access
102
- swe-swe init --with-docker
103
-
104
- # Initialize current directory with custom slash commands for Claude/Codex/OpenCode
105
- swe-swe init --with-slash-commands=ck@https://github.com/choonkeat/slash-commands.git
106
-
107
- # Initialize with HTTPS (self-signed certificate)
108
- swe-swe init --ssl=selfsign
109
-
110
- # Initialize with HTTPS (Let's Encrypt - requires public domain + port 80 access)
111
- swe-swe init --ssl=letsencrypt@mydomain.com --email=admin@mydomain.com
112
-
113
- # Initialize with Let's Encrypt staging (for testing - certs not browser-trusted)
114
- swe-swe init --ssl=letsencrypt-staging@mydomain.com --email=admin@mydomain.com
115
-
116
- # Initialize with git and SSH config copied from host
117
- swe-swe init --copy-home-paths=.gitconfig,.ssh/config
118
-
119
- # Initialize a specific directory
120
- swe-swe init --project-directory ~/my-project
121
-
122
- # Reinitialize with same configuration (after updates)
123
- swe-swe init --previous-init-flags=reuse
124
-
125
- # Reinitialize with new configuration (overwrite previous)
126
- swe-swe init --previous-init-flags=ignore --agents=claude
127
- ```
128
-
129
- **Security Note on `--with-docker`**: Mounting the Docker socket grants the container effective root access to the host. The container can mount host filesystems, run privileged containers, and access other containers. Only use this flag when you trust the code running inside the container (e.g., for your own projects, not untrusted third-party code).
130
-
131
- **Dependency Optimization**: The Dockerfile is automatically optimized based on selected agents:
132
- - Python/pip is only installed if `aider` is included
133
- - Node.js/npm is only installed if `claude`, `gemini`, `codex`, or `opencode` is included
134
- - This can significantly reduce image size and build time
135
-
136
- Services are accessible via path-based routing on `localhost` (or `0.0.0.0`) at the configured port.
137
-
138
- **Note on Port**: The port defaults to `1977` and can be customized via the `SWE_PORT` environment variable (e.g., `SWE_PORT=8080 swe-swe up`). Services are routed based on request paths (e.g., `/vscode`, `/chrome`) rather than subdomains, making it compatible with ngrok, cloudflared, and other tunnel services.
139
-
140
- **Enterprise Certificate Support**: If you're behind a corporate firewall or VPN, the init command automatically detects and copies certificates from:
141
- - `NODE_EXTRA_CA_CERTS`
142
- - `SSL_CERT_FILE`
143
- - `NODE_EXTRA_CA_CERTS_BUNDLE`
144
-
145
- These are copied to `.swe-swe/certs/` and mounted into all containers.
146
-
147
- #### `swe-swe list`
148
-
149
- Lists all initialized swe-swe projects and automatically prunes stale ones.
150
-
151
- **What it does:**
152
- 1. Scans `$HOME/.swe-swe/projects/` directory
153
- 2. For each project, reads `.path` file to get original path
154
- 3. Checks if original path still exists
155
- 4. Auto-removes metadata directories for deleted projects (pruning)
156
- 5. Displays remaining active projects with count
157
- 6. Shows summary of pruned projects
158
-
159
- **When to use:**
160
- - Discover what projects you have initialized
161
- - Clean up metadata for deleted projects
162
- - Verify project paths before cleanup
163
-
164
- Example:
165
- ```bash
166
- swe-swe list
167
- # Output:
168
- # Initialized projects (2):
169
- # /Users/alice/projects/myapp
170
- # /Users/alice/projects/anotherapp
171
- #
172
- # Removed 1 stale project(s)
173
- ```
174
-
175
- #### `swe-swe proxy <command>`
176
-
177
- Bridges the container-host boundary by letting containers execute specific host commands with real-time output streaming. This is the **secure alternative to `--with-docker`** when you only need access to specific commands rather than full Docker socket access.
178
-
179
- **When to use proxy vs `--with-docker`:**
180
-
181
- | Scenario | Solution |
182
- |----------|----------|
183
- | AI agent needs to run `make` with host toolchain | `swe-swe proxy make` |
184
- | Need `docker build` without exposing full Docker socket | `swe-swe proxy docker` |
185
- | Access host's SSH agent for git operations | `swe-swe proxy git` |
186
- | Full Docker/container management needed | `--with-docker` flag |
187
-
188
- **How it works:**
189
- 1. Host runs `swe-swe proxy <command>` which watches `.swe-swe/proxy/` for requests
190
- 2. A container script is generated at `.swe-swe/proxy/<command>`
191
- 3. Container runs `.swe-swe/proxy/<command> [args...]` to submit a request
192
- 4. Host executes the command and streams stdout/stderr back to container in real-time
193
- 5. Container exits with the command's exit code
194
-
195
- **Key features:**
196
- - **Real-time streaming**: Output appears immediately, not after command completes
197
- - **Exit code propagation**: Container script exits with the host command's exit code
198
- - **Stdin forwarding**: Piped/redirected input is forwarded to the host command (e.g., `echo "data" | .swe-swe/proxy/cat`)
199
- - **Concurrent requests**: Multiple container processes can use the same proxy simultaneously
200
- - **Efficient file watching**: Uses inotify when available, falls back to polling
201
-
202
- **Examples:**
203
- ```bash
204
- # Terminal 1: Start proxy for 'make' command
205
- swe-swe proxy make
206
- # [proxy] Listening for 'make' commands... (Ctrl+C to stop)
207
-
208
- # Terminal 2 (inside container): Run make with arguments
209
- .swe-swe/proxy/make build TARGET=hello
210
- # Output streams in real-time, exits with make's exit code
211
-
212
- # Multiple proxies (run each in separate terminals)
213
- swe-swe proxy make
214
- swe-swe proxy docker
215
- swe-swe proxy npm
216
- ```
217
-
218
- **Real-world use cases:**
219
- ```bash
220
- # Cross-compile with host toolchain
221
- swe-swe proxy make
222
- # In container: .swe-swe/proxy/make build-linux-arm64
223
-
224
- # Run Docker commands without --with-docker
225
- swe-swe proxy docker
226
- # In container: .swe-swe/proxy/docker build -t myapp .
227
-
228
- # Use host's authenticated npm registry
229
- swe-swe proxy npm
230
- # In container: .swe-swe/proxy/npm publish
231
- ```
232
-
233
- **Environment Variables:**
234
- - `PROXY_TIMEOUT`: Timeout in seconds for container script (default: 300)
235
- - `PROXY_DIR`: Override proxy directory (default: `.swe-swe/proxy`)
43
+ For the full command reference all flags, examples, environment variables, and architecture details see [docs/cli-commands-and-binary-management.md](docs/cli-commands-and-binary-management.md). For configuration options, see [docs/configuration.md](docs/configuration.md).
236
44
 
237
- **File protocol:**
238
- ```
239
- .swe-swe/proxy/
240
- ├── <command> # Generated container script (executable)
241
- ├── <command>.pid # Host PID file (prevents duplicate proxies)
242
- ├── <uuid>.req # Request file (NUL-delimited args)
243
- ├── <uuid>.stdin # Request stdin (if piped/redirected input)
244
- ├── <uuid>.stdout # Response stdout (streamed)
245
- ├── <uuid>.stderr # Response stderr (streamed)
246
- └── <uuid>.exit # Exit code (signals completion)
247
- ```
248
-
249
- **Cleanup responsibilities:**
250
-
251
- | File | Cleaned up by | When |
252
- |------|---------------|------|
253
- | `<uuid>.req` | Host | After reading (claims the request) |
254
- | `<uuid>.stdout/stderr/exit` | Container | On script exit (via trap) |
255
- | `<command>`, `<command>.pid` | Host | On proxy shutdown (Ctrl+C) |
256
- | Orphan response files | Host | On startup (files older than 5 min) |
257
-
258
- ### Docker Compose Pass-through
259
-
260
- All commands other than `init`, `list`, and `proxy` are passed directly to `docker compose` using the project's generated `docker-compose.yml`. This means you can use any docker compose command:
45
+ **Quick reference:**
261
46
 
262
47
  ```bash
263
- swe-swe up # docker compose up
264
- swe-swe down # docker compose down
265
- swe-swe build # docker compose build
266
- swe-swe ps # docker compose ps
267
- swe-swe logs -f swe-swe # docker compose logs -f swe-swe
268
- swe-swe exec swe-swe bash # docker compose exec swe-swe bash
269
- swe-swe restart chrome # docker compose restart chrome
270
- ```
48
+ # Native commands
49
+ swe-swe init [options] # Initialize a project
50
+ swe-swe list # List initialized projects
51
+ swe-swe proxy <command> # Bridge host commands into containers
271
52
 
272
- Use `--project-directory` to specify which project (defaults to current directory):
273
- ```bash
274
- swe-swe up --project-directory ~/my-project
275
- swe-swe logs -f --project-directory ~/my-project
276
- ```
277
-
278
- #### `swe-swe up [--project-directory PATH]`
279
-
280
- Starts the swe-swe environment using `docker compose up`. The environment includes:
281
-
282
- 1. **swe-swe**: WebSocket-based AI terminal with session management
283
- 2. **chrome**: Headless Chromium with CDP screencast for browser automation (used by MCP Playwright)
284
- 3. **code-server**: VS Code IDE running in a container
285
- 4. **vscode-proxy**: Nginx proxy for VSCode path routing
286
- 5. **traefik**: HTTP reverse proxy with path-based routing rules
287
- 6. **auth**: ForwardAuth service for unified password protection
288
-
289
- The workspace is mounted at `/workspace` inside containers, allowing bidirectional file access.
290
-
291
- Example:
292
- ```bash
293
- swe-swe up --project-directory ~/my-project
294
- # Press Ctrl+C to stop
53
+ # Docker Compose pass-through (all other commands)
54
+ swe-swe up # Start the environment
55
+ swe-swe down # Stop the environment
56
+ swe-swe build # Rebuild Docker images
57
+ swe-swe ps / logs / exec ... # Any docker compose command
295
58
  ```
296
59
 
297
- **Environment Variables** (passed through automatically):
298
- - `ANTHROPIC_API_KEY`: Claude API key (passed by default)
299
- - `SWE_SWE_PASSWORD`: Authentication password for all services (defaults to `changeme`)
300
- - `SWE_PORT`: External port (defaults to 1977)
301
- - `NODE_EXTRA_CA_CERTS`: Enterprise CA certificate path (auto-copied during init)
302
- - `SSL_CERT_FILE`: SSL certificate file path (auto-copied during init)
303
- - `BROWSER_WS_ENDPOINT`: WebSocket endpoint for browser automation (auto-configured to `ws://chrome:9223`)
304
-
305
- **Additional API keys** (uncomment in docker-compose.yml if needed):
306
- - `OPENAI_API_KEY`: OpenAI API key (for Codex)
307
- - `GEMINI_API_KEY`: Google Gemini API key
308
-
309
- #### `swe-swe down [--project-directory PATH]`
310
-
311
- Stops and removes the running Docker containers for the project.
312
-
313
- Example:
314
- ```bash
315
- swe-swe down --project-directory ~/my-project
316
- ```
317
-
318
- #### `swe-swe build [--project-directory PATH]`
319
-
320
- Rebuilds the Docker image from scratch (clears cache). Useful when:
321
- - Updating the base image
322
- - Installing new dependencies in Dockerfile
323
- - Testing fresh builds
324
-
325
- Example:
326
- ```bash
327
- swe-swe build --project-directory ~/my-project
328
- ```
329
-
330
- #### `swe-swe -h` / `swe-swe --help`
331
-
332
- Displays the help message with all available commands.
333
-
334
- ## Architecture
60
+ Use `--project-directory` to specify which project (defaults to current directory). The port defaults to `1977` and can be customized via `SWE_PORT`.
335
61
 
336
- ### Directory Structure
62
+ ## Documentation
337
63
 
338
- Project metadata is stored in `$HOME/.swe-swe/projects/{sanitized-path}/`:
339
-
340
- ```
341
- $HOME/.swe-swe/projects/{sanitized-path}/
342
- ├── Dockerfile # Container image definition (multi-stage build)
343
- ├── docker-compose.yml # Service orchestration
344
- ├── traefik-dynamic.yml # HTTP routing rules
345
- ├── .dockerignore # Docker build exclusions
346
- ├── .path # Original project path (for discovery)
347
- ├── init.json # Saved init flags (for --previous-init-flags=reuse)
348
- ├── entrypoint.sh # Container entrypoint script
349
- ├── nginx-vscode.conf # Nginx config for VSCode proxy
350
- ├── swe-swe-server/ # Server source code (built at docker-compose time)
351
- │ ├── go.mod, go.sum
352
- │ ├── main.go
353
- │ └── static/
354
- ├── auth/ # ForwardAuth service source code
355
- ├── chrome-screencast/ # Chrome screencast service (Dockerfile, configs)
356
- ├── home/ # Persistent VSCode/shell home (volume)
357
- ├── certs/ # Enterprise certificates (if detected)
358
- ├── tls/ # Self-signed TLS certificates (if --ssl=selfsign)
359
- └── acme/ # Let's Encrypt ACME storage (if --ssl=letsencrypt@domain)
360
- ```
361
-
362
- **Why metadata is stored outside the project:**
363
- - Prevents container access to infrastructure configuration
364
- - Allows metadata cleanup via `swe-swe list` command
365
- - Centralizes all metadata in one location
366
-
367
- **Note**: A `.swe-swe/` directory is created inside your project for runtime data (worktrees, repos, proxy, uploads). This is separate from the metadata directory above.
368
-
369
- ### Services
370
-
371
- #### swe-swe-server
372
- - **Port**: 9898 (inside container)
373
- - **Purpose**: WebSocket-based AI coding assistant terminal
374
- - **Features**:
375
- - Real-time terminal with PTY support
376
- - Session management (sessions persist until process exits)
377
- - Multiple AI assistant detection (claude, gemini, codex, goose, aider, opencode)
378
- - All process exits end the session (process replacement only via YOLO toggle)
379
- - File upload via drag-and-drop (saved to `.swe-swe/uploads/` on tmpfs — files do not persist across container restarts)
380
- - In-session chat for collaboration
381
- - YOLO mode toggle for supported agents (auto-approve actions)
382
- - **Split-pane UI**: Side panel with Preview, Browser, and Shell tabs for app preview and debugging
383
- - **Session recordings**: Automatic terminal recording with playback (streaming mode for large recordings)
384
- - **Debug channel**: Agents can receive console logs, errors, and network requests from the App Preview via `swe-swe-server --debug-listen`
385
-
386
- #### chrome
387
- - **Ports**: 9223 (CDP), 6080 (screencast)
388
- - **Purpose**: Headless Chromium browser for AI-driven browser automation
389
- - **Features**:
390
- - Chrome DevTools Protocol (CDP) access via nginx proxy
391
- - CDP screencast viewer at `/chrome` path (e.g., http://0.0.0.0:1977/chrome)
392
- - Used by MCP Playwright for browser automation tasks
393
- - Enterprise SSL certificate support via NSS database
394
- - **Documentation**: See `docs/browser-automation.md`
395
-
396
- #### code-server
397
- - **Port**: 8080 (inside container)
398
- - **Purpose**: Full VS Code IDE in the browser
399
- - **Features**:
400
- - Syntax highlighting, extensions support
401
- - Direct file editing in `/workspace`
402
- - Terminal integration
403
-
404
- #### traefik
405
- - **Port**: 7000 HTTP or 7443 HTTPS (external port 1977)
406
- - **Purpose**: Reverse proxy and routing with path-based request matching
407
- - **Routing Rules**:
408
- - `/swe-swe-auth/*` path: Auth service for ForwardAuth (priority 200)
409
- - `/vscode` path: Routes to code-server with path prefix stripped (priority 100)
410
- - `/chrome` path: Routes to chrome service with path prefix stripped (priority 100)
411
- - `/dashboard` path: Traefik dashboard (priority 100)
412
- - `/` path: Routes to swe-swe-server (priority 10, catch-all)
413
- - **Authentication**: All routes (except auth) protected by ForwardAuth middleware
414
-
415
- #### auth
416
- - **Port**: 4180 (internal)
417
- - **Purpose**: ForwardAuth service for unified authentication
418
- - **Features**:
419
- - Cookie-based session management
420
- - Redirect to original URL after login
421
- - Mobile-responsive login page
422
-
423
- ### Network
424
-
425
- Each project gets its own isolated Docker network (`{PROJECT_NAME}_swe-network`). This provides:
426
- - Service discovery by container name within each project
427
- - True network isolation between projects (no DNS conflicts)
428
- - Multiple stacks can run simultaneously without interference
429
-
430
- ## Configuration
431
-
432
- ### Customizing the Dockerfile
433
-
434
- The Dockerfile is located in `$HOME/.swe-swe/projects/{sanitized-path}/Dockerfile`. Edit it to:
435
- - Add Python: `apt-get install -y python3 python3-pip`
436
- - Add Rust: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y`
437
- - Add other tools via `apt-get`
438
-
439
- **UID:GID Placeholders**: The Dockerfile supports `{{UID}}` and `{{GID}}` placeholders that are replaced with the host user's UID/GID at init time. This ensures files created in the container have matching permissions on the host, eliminating permission conflicts when editing files from both sides.
440
-
441
- ### API Keys
442
-
443
- **Claude** (passed through by default):
444
- ```bash
445
- export ANTHROPIC_API_KEY=sk-ant-...
446
- swe-swe up --project-directory ~/my-project
447
- ```
448
-
449
- **Gemini/Codex** (requires editing docker-compose.yml to uncomment the env vars):
450
- ```bash
451
- # First, edit $HOME/.swe-swe/projects/{sanitized-path}/docker-compose.yml
452
- # Uncomment the GEMINI_API_KEY and/or OPENAI_API_KEY lines in the swe-swe service
453
-
454
- export GEMINI_API_KEY=...
455
- export OPENAI_API_KEY=sk-...
456
- swe-swe up --project-directory ~/my-project
457
- ```
458
-
459
- Alternatively, create a `.env` file in `$HOME/.swe-swe/projects/{sanitized-path}/`:
460
- ```
461
- ANTHROPIC_API_KEY=sk-ant-...
462
- GEMINI_API_KEY=...
463
- OPENAI_API_KEY=sk-...
464
- ```
465
-
466
- ### Resource Limits
467
-
468
- Edit `$HOME/.swe-swe/projects/{sanitized-path}/docker-compose.yml` to adjust resource constraints:
469
-
470
- ```yaml
471
- code-server:
472
- deploy:
473
- resources:
474
- limits:
475
- cpus: '2'
476
- memory: 2G
477
- ```
478
-
479
- ### VSCode Password
480
-
481
- The default VSCode password is `changeme`. To use a custom password, set the `SWE_SWE_PASSWORD` environment variable:
482
-
483
- ```bash
484
- # Default password (changeme)
485
- swe-swe up --project-directory ~/my-project
486
-
487
- # Custom password
488
- SWE_SWE_PASSWORD='my-secure-password' swe-swe up --project-directory ~/my-project
489
- ```
64
+ - [Configuration Reference](docs/configuration.md) all init flags, environment variables, and config files
65
+ - [CLI Commands and Build Architecture](docs/cli-commands-and-binary-management.md) — full command reference, troubleshooting, build system
66
+ - [Browser Automation](docs/browser-automation.md) — Chrome CDP and MCP Playwright
67
+ - [WebSocket Protocol](docs/websocket-protocol.md) — terminal communication protocol
490
68
 
491
69
  ## Development
492
70
 
493
- > For detailed build architecture and troubleshooting, see [docs/cli-commands-and-binary-management.md](docs/cli-commands-and-binary-management.md).
494
-
495
- ### Building from Source
496
-
497
71
  ```bash
498
- # Build CLI binaries for all platforms
499
- make build
500
-
501
- # Run tests
502
- make test
72
+ make build # Build CLI binaries for all platforms
73
+ make test # Run tests
503
74
  ```
504
75
 
505
- The swe-swe-server is built from source at `docker-compose build` time using a multi-stage Dockerfile. This means:
506
- - No pre-compiled server binaries are embedded in the CLI
507
- - The server is always compiled fresh when the Docker image is built
508
- - Changes to server source code in `cmd/swe-swe/templates/host/swe-swe-server/` are reflected after `swe-swe build`
509
-
510
- ### Project Structure
511
-
512
- ```
513
- .
514
- ├── cmd/
515
- │ └── swe-swe/ # CLI tool
516
- │ ├── *.go # main, init, docker, templates, certs, paths, list, proxy, color, ansi
517
- │ └── templates/ # Embedded Docker/server files
518
- │ └── host/
519
- │ ├── Dockerfile, docker-compose.yml, etc.
520
- │ └── swe-swe-server/ # WebSocket server source
521
- ├── docs/ # Technical documentation
522
- ├── Makefile # Build targets
523
- ├── go.mod, go.sum # Go dependencies
524
- └── README.md # This file
525
- ```
526
-
527
- ### Key Dependencies
528
-
529
- - **gorilla/websocket**: WebSocket support for real-time terminal
530
- - **creack/pty**: PTY (pseudo-terminal) for shell sessions
531
- - **vt10x**: VT100 terminal emulation
532
- - **uuid**: Session ID generation
533
-
534
- ## Troubleshooting
535
-
536
- ### Binary Architecture Error
537
-
538
- **Error**: `exec format error`
539
-
540
- **Solution**: Rebuild the container image which compiles the server from source:
541
- ```bash
542
- swe-swe build --project-directory ~/my-project
543
- ```
544
-
545
- ### Port Already in Use
546
-
547
- **Error**: `port 1977 already allocated`
548
-
549
- **Solution**: Stop other projects or use a custom port via environment variable:
550
- ```bash
551
- # Use a different port
552
- SWE_PORT=8080 swe-swe up --project-directory ~/my-project
553
- ```
554
-
555
- Alternatively, modify `$HOME/.swe-swe/projects/{sanitized-path}/docker-compose.yml` to change the port mapping.
556
-
557
- ### API Key Not Found
558
-
559
- **Error**: `no AI assistants available`
560
-
561
- **Solution**: The server didn't detect an installed assistant:
562
- 1. Set API keys: `ANTHROPIC_API_KEY` (Claude), `GEMINI_API_KEY` (Gemini), `OPENAI_API_KEY` (Codex)
563
- 2. Or install CLI tools: `claude`, `gemini`, `codex`, `goose`, `aider`, `opencode`
564
-
565
- ### Network Issues
566
-
567
- **Error**: Service not accessible at configured port (default 1977)
568
-
569
- **Solution**:
570
- 1. Verify Docker is running: `docker ps`
571
- 2. Check containers are healthy: `swe-swe ps --project-directory ~/my-project`
572
- 3. Check Traefik logs: `swe-swe logs traefik --project-directory ~/my-project`
573
- 4. Verify you're using correct paths: `http://0.0.0.0:1977/`, `http://0.0.0.0:1977/vscode`, `http://0.0.0.0:1977/chrome`
574
-
575
- ### Let's Encrypt Certificate Issues
576
-
577
- **Error**: `domain "example.com" does not resolve`
578
-
579
- **Solution**: Ensure your domain's DNS is configured and points to your server before running init:
580
- ```bash
581
- # Verify DNS resolution
582
- dig +short mydomain.com
583
- ```
584
-
585
- **Error**: ACME challenge fails / certificate not issued
586
-
587
- **Solutions**:
588
- 1. Ensure port 80 is accessible from the internet (firewall/security groups)
589
- 2. Verify domain resolves to this server's public IP
590
- 3. Try staging mode first to avoid rate limits: `--ssl=letsencrypt-staging@domain`
591
-
592
- **Error**: Rate limited by Let's Encrypt
593
-
594
- **Solution**: Let's Encrypt allows 50 certificates per domain per week. Use staging mode for testing, or wait before retrying.
595
-
596
- **Certificate not renewing**
597
-
598
- Let's Encrypt certs renew automatically via Traefik. If renewal fails:
599
- 1. Ensure the container is running: `swe-swe ps`
600
- 2. Check Traefik logs: `swe-swe logs traefik`
601
- 3. Verify port 80 is still accessible
602
-
603
- **iOS Safari works with Let's Encrypt**
604
-
605
- Unlike self-signed certificates, Let's Encrypt certs work in iOS Safari without issues. This is the recommended approach for mobile access.
606
-
607
- ### Persistent Home Issues
608
-
609
- If VSCode settings/extensions don't persist:
610
- 1. Verify `$HOME/.swe-swe/projects/{sanitized-path}/home/` exists and has correct permissions
611
- 2. Check that the metadata directory wasn't accidentally deleted
612
- 3. Reinitialize the project: `swe-swe init --project-directory /path/to/project`
613
-
614
- ## Advanced Usage
615
-
616
- ### Running Multiple Projects
617
-
618
- Each project gets its own isolated environment. No conflicts:
619
-
620
- ```bash
621
- # Terminal 1
622
- swe-swe init --project-directory ~/project1
623
- swe-swe up --project-directory ~/project1
624
-
625
- # Terminal 2
626
- swe-swe init --project-directory ~/project2
627
- swe-swe up --project-directory ~/project2
628
- # Use different ports if accessing locally
629
- ```
630
-
631
- ### Custom Shell
632
-
633
- Use a custom shell by modifying the Dockerfile CMD:
634
-
635
- ```dockerfile
636
- ENV SHELL=/bin/zsh
637
- CMD ["/usr/local/bin/swe-swe-server", "-shell", "zsh", "-working-directory", "/workspace", "-addr", "0.0.0.0:9898"]
638
- ```
639
-
640
- ### Session Persistence
641
-
642
- Sessions persist until the shell process exits. All exits (zero or non-zero) end the session. Process replacement only occurs via explicit user action (YOLO toggle).
643
-
644
- To customize the shell command, modify the Dockerfile CMD:
645
-
646
- ```dockerfile
647
- CMD ["/usr/local/bin/swe-swe-server", "-shell", "bash", "-working-directory", "/workspace", "-addr", "0.0.0.0:9898"]
648
- ```
649
-
650
- ### YOLO Mode
651
-
652
- YOLO mode allows agents to auto-approve actions without user confirmation. Toggle it via:
653
- - **Status bar**: Click "Connected" text (changes to "YOLO" when active)
654
- - **Settings panel**: Use the YOLO toggle switch
655
-
656
- **Supported agents and their YOLO commands:**
657
-
658
- | Agent | YOLO Command |
659
- |-------|--------------|
660
- | Claude | `--dangerously-skip-permissions` |
661
- | Gemini | `--approval-mode=yolo` |
662
- | Codex | `--yolo` |
663
- | Goose | `GOOSE_MODE=auto` |
664
- | Aider | `--yes-always` |
665
- | OpenCode | Not supported (toggle hidden) |
666
-
667
- When toggled, the agent restarts with the appropriate YOLO flag. The status bar shows "YOLO" with a border indicator when active.
668
-
669
- ### App Preview Debugging
670
-
671
- The App Preview (port 3000 by default) includes a debug channel that forwards browser events to agents. This lets agents debug what users see without needing visual access.
672
-
673
- **Listening for debug messages:**
674
- ```bash
675
- # Inside container - receive console logs, errors, fetch/XHR requests
676
- swe-swe-server --debug-listen
677
- ```
678
-
679
- Output is JSON lines:
680
- ```json
681
- {"t":"console","m":"log","args":["Hello!"],"ts":...}
682
- {"t":"error","msg":"Uncaught TypeError","stack":"...","ts":...}
683
- {"t":"fetch","url":"/api/users","method":"GET","status":200,"ms":45,"ts":...}
684
- ```
685
-
686
- **Querying DOM elements:**
687
- ```bash
688
- # Query element by CSS selector
689
- swe-swe-server --debug-query ".error-message"
690
- ```
691
-
692
- Response:
693
- ```json
694
- {"t":"queryResult","found":true,"text":"Invalid email","visible":true}
695
- ```
696
-
697
- **Prerequisites:**
698
- - User must have the Preview tab open in the split-pane UI
699
- - App must be running on port 3000 (or `SWE_PREVIEW_TARGET_PORT`)
700
-
701
- For detailed usage, see the `/debug-preview-page` slash command.
702
-
703
- ### Custom Session Environment Variables
704
-
705
- Create a `swe-swe/env` file in your project root to set custom environment variables for all sessions:
706
-
707
- ```bash
708
- # swe-swe/env
709
- MY_API_KEY=abc123
710
- DATABASE_URL=postgres://localhost/mydb
711
- ```
712
-
713
- These variables are loaded at session start and take precedence over defaults. Lines starting with `#` are comments. The `swe-swe/env` file is `@`-mentionable by agents.
714
-
715
- ### Authentication
716
-
717
- All services are protected by ForwardAuth by default. The authentication password is set via the `SWE_SWE_PASSWORD` environment variable (defaults to `changeme`).
718
-
719
- ```bash
720
- # Use default password
721
- swe-swe up --project-directory ~/my-project
722
-
723
- # Use custom password
724
- SWE_SWE_PASSWORD='my-secure-password' swe-swe up --project-directory ~/my-project
725
- ```
726
-
727
- The auth service provides:
728
- - Cookie-based session management (expires when browser closes)
729
- - Redirect to original URL after login
730
- - Mobile-responsive login page
731
-
732
- ## API Reference
733
-
734
- ### WebSocket Protocol
735
-
736
- The swe-swe-server provides a WebSocket endpoint at `/ws/{sessionId}` for terminal communication.
737
-
738
- **Message Format**:
739
- ```json
740
- {
741
- "type": "input" | "resize",
742
- "data": "shell input" | {"rows": 24, "cols": 80},
743
- "sessionId": "uuid"
744
- }
745
- ```
746
-
747
- See `docs/websocket-protocol.md` for detailed specification.
748
-
749
- ## Contributing
750
-
751
- ### Code Style
752
-
753
- Follow Go conventions:
754
- ```bash
755
- make fmt # Format code
756
- make test # Run tests
757
- ```
758
-
759
- ### Adding Features
760
-
761
- 1. Modify the appropriate component (CLI in `cmd/swe-swe`, server in `cmd/swe-swe/templates/host/swe-swe-server`)
762
- 2. Test locally: `make build && swe-swe init && swe-swe up`
763
- 3. Commit with conventional commits: `fix:`, `feat:`, `docs:`, etc.
76
+ See [docs/cli-commands-and-binary-management.md](docs/cli-commands-and-binary-management.md) for build architecture and troubleshooting.
764
77
 
765
78
  ## License
766
79
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swe-swe",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Your agent: containerized with browser, terminal, and parallel sessions",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,11 +15,11 @@
15
15
  },
16
16
  "license": "MIT",
17
17
  "optionalDependencies": {
18
- "@choonkeat/swe-swe-linux-x64": "0.1.2",
19
- "@choonkeat/swe-swe-linux-arm64": "0.1.2",
20
- "@choonkeat/swe-swe-darwin-x64": "0.1.2",
21
- "@choonkeat/swe-swe-darwin-arm64": "0.1.2",
22
- "@choonkeat/swe-swe-win32-x64": "0.1.2",
23
- "@choonkeat/swe-swe-win32-arm64": "0.1.2"
18
+ "@choonkeat/swe-swe-linux-x64": "0.1.4",
19
+ "@choonkeat/swe-swe-linux-arm64": "0.1.4",
20
+ "@choonkeat/swe-swe-darwin-x64": "0.1.4",
21
+ "@choonkeat/swe-swe-darwin-arm64": "0.1.4",
22
+ "@choonkeat/swe-swe-win32-x64": "0.1.4",
23
+ "@choonkeat/swe-swe-win32-arm64": "0.1.4"
24
24
  }
25
25
  }