@openbuilder/cli 0.31.11

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 (78) hide show
  1. package/README.md +1053 -0
  2. package/bin/openbuilder.js +31 -0
  3. package/dist/chunks/Banner-D4tqKfzA.js +113 -0
  4. package/dist/chunks/Banner-D4tqKfzA.js.map +1 -0
  5. package/dist/chunks/auto-update-Dj3lWPWO.js +350 -0
  6. package/dist/chunks/auto-update-Dj3lWPWO.js.map +1 -0
  7. package/dist/chunks/build-D0qYqIq0.js +116 -0
  8. package/dist/chunks/build-D0qYqIq0.js.map +1 -0
  9. package/dist/chunks/cleanup-qVTsA3tk.js +141 -0
  10. package/dist/chunks/cleanup-qVTsA3tk.js.map +1 -0
  11. package/dist/chunks/cli-error-BjQwvWtK.js +140 -0
  12. package/dist/chunks/cli-error-BjQwvWtK.js.map +1 -0
  13. package/dist/chunks/config-BGP1jZJ4.js +167 -0
  14. package/dist/chunks/config-BGP1jZJ4.js.map +1 -0
  15. package/dist/chunks/config-manager-BkbjtN-H.js +133 -0
  16. package/dist/chunks/config-manager-BkbjtN-H.js.map +1 -0
  17. package/dist/chunks/database-BvAbD4sP.js +68 -0
  18. package/dist/chunks/database-BvAbD4sP.js.map +1 -0
  19. package/dist/chunks/database-setup-BYjIRAmT.js +253 -0
  20. package/dist/chunks/database-setup-BYjIRAmT.js.map +1 -0
  21. package/dist/chunks/exports-ij9sv4UM.js +7793 -0
  22. package/dist/chunks/exports-ij9sv4UM.js.map +1 -0
  23. package/dist/chunks/init-CZoN6soU.js +468 -0
  24. package/dist/chunks/init-CZoN6soU.js.map +1 -0
  25. package/dist/chunks/init-tui-BNzk_7Yx.js +1127 -0
  26. package/dist/chunks/init-tui-BNzk_7Yx.js.map +1 -0
  27. package/dist/chunks/logger-ZpJi7chw.js +38 -0
  28. package/dist/chunks/logger-ZpJi7chw.js.map +1 -0
  29. package/dist/chunks/main-tui-Cq1hLCx-.js +644 -0
  30. package/dist/chunks/main-tui-Cq1hLCx-.js.map +1 -0
  31. package/dist/chunks/manager-CvGX9qqe.js +1161 -0
  32. package/dist/chunks/manager-CvGX9qqe.js.map +1 -0
  33. package/dist/chunks/port-allocator-BRFzgH9b.js +749 -0
  34. package/dist/chunks/port-allocator-BRFzgH9b.js.map +1 -0
  35. package/dist/chunks/process-killer-CaUL7Kpl.js +87 -0
  36. package/dist/chunks/process-killer-CaUL7Kpl.js.map +1 -0
  37. package/dist/chunks/prompts-1QbE_bRr.js +128 -0
  38. package/dist/chunks/prompts-1QbE_bRr.js.map +1 -0
  39. package/dist/chunks/repo-cloner-CpOQjFSo.js +219 -0
  40. package/dist/chunks/repo-cloner-CpOQjFSo.js.map +1 -0
  41. package/dist/chunks/repo-detector-B_oj696o.js +66 -0
  42. package/dist/chunks/repo-detector-B_oj696o.js.map +1 -0
  43. package/dist/chunks/run-D23hg4xy.js +630 -0
  44. package/dist/chunks/run-D23hg4xy.js.map +1 -0
  45. package/dist/chunks/runner-logger-instance-nDWv2h2T.js +899 -0
  46. package/dist/chunks/runner-logger-instance-nDWv2h2T.js.map +1 -0
  47. package/dist/chunks/spinner-BJL9zWAJ.js +53 -0
  48. package/dist/chunks/spinner-BJL9zWAJ.js.map +1 -0
  49. package/dist/chunks/start-BygPCbvw.js +1708 -0
  50. package/dist/chunks/start-BygPCbvw.js.map +1 -0
  51. package/dist/chunks/start-traditional-uoLZXdxm.js +255 -0
  52. package/dist/chunks/start-traditional-uoLZXdxm.js.map +1 -0
  53. package/dist/chunks/status-cS8YwtUx.js +97 -0
  54. package/dist/chunks/status-cS8YwtUx.js.map +1 -0
  55. package/dist/chunks/theme-DhorI2Hb.js +44 -0
  56. package/dist/chunks/theme-DhorI2Hb.js.map +1 -0
  57. package/dist/chunks/upgrade-CT6w0lKp.js +323 -0
  58. package/dist/chunks/upgrade-CT6w0lKp.js.map +1 -0
  59. package/dist/chunks/useBuildState-CdBSu9y_.js +331 -0
  60. package/dist/chunks/useBuildState-CdBSu9y_.js.map +1 -0
  61. package/dist/cli/index.js +694 -0
  62. package/dist/cli/index.js.map +1 -0
  63. package/dist/index.js +14358 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/instrument.js +64226 -0
  66. package/dist/instrument.js.map +1 -0
  67. package/dist/templates.json +295 -0
  68. package/package.json +98 -0
  69. package/scripts/install-vendor-deps.js +34 -0
  70. package/scripts/install-vendor.js +167 -0
  71. package/scripts/prepare-release.js +71 -0
  72. package/templates/config.template.json +18 -0
  73. package/templates.json +295 -0
  74. package/vendor/ai-sdk-provider-claude-code-LOCAL.tgz +0 -0
  75. package/vendor/sentry-core-LOCAL.tgz +0 -0
  76. package/vendor/sentry-nextjs-LOCAL.tgz +0 -0
  77. package/vendor/sentry-node-LOCAL.tgz +0 -0
  78. package/vendor/sentry-node-core-LOCAL.tgz +0 -0
package/README.md ADDED
@@ -0,0 +1,1053 @@
1
+ # OpenBuilder CLI
2
+
3
+ The OpenBuilder CLI is a command-line tool for building AI-powered applications locally on your machine. It connects to the OpenBuilder server and uses Claude AI to generate and build projects in an isolated workspace.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Getting Started from Zero](#getting-started-from-zero)
9
+ - [CLI Reference](#cli-reference)
10
+ - [Configuration](#configuration)
11
+ - [Architecture](#architecture)
12
+ - [Development](#development)
13
+ - [Troubleshooting](#troubleshooting)
14
+
15
+ ## Installation
16
+
17
+ ### Quick Install (Recommended)
18
+
19
+ ```bash
20
+ # Install via curl
21
+ curl -fsSL https://openbuilder.app/install | bash
22
+
23
+ # Verify installation
24
+ openbuilder --version
25
+ ```
26
+
27
+ This installs the OpenBuilder CLI globally on your machine.
28
+
29
+ ### From Source (Development)
30
+
31
+ ```bash
32
+ # Clone the repository
33
+ git clone <repo-url>
34
+ cd openbuilder/apps/runner
35
+
36
+ # Install dependencies
37
+ pnpm install
38
+
39
+ # Build the CLI
40
+ pnpm run build
41
+
42
+ # Link globally for testing
43
+ npm link
44
+
45
+ # Verify
46
+ openbuilder-cli --version
47
+ ```
48
+
49
+ ## Getting Started from Zero
50
+
51
+ ### Prerequisites
52
+
53
+ Before you begin, ensure you have:
54
+
55
+ 1. **Node.js 18 or higher** installed
56
+ ```bash
57
+ node --version # Should be 18.0.0 or higher
58
+ ```
59
+
60
+ 2. **npm or pnpm** package manager
61
+ ```bash
62
+ npm --version
63
+ # or
64
+ pnpm --version
65
+ ```
66
+
67
+ 3. **Git** installed (for template downloads)
68
+ ```bash
69
+ git --version
70
+ ```
71
+
72
+ 4. **A shared secret** from your OpenBuilder deployment
73
+ - Get this from your Railway deployment environment variables
74
+ - Or from your local `.env.local` if running locally
75
+
76
+ ### Two Ways to Use OpenBuilder
77
+
78
+ **Option A: Full Stack (Local Development)**
79
+ - Runs web app, broker, and runner all locally
80
+ - Perfect for development and testing
81
+ - Command: `openbuilder run`
82
+
83
+ **Option B: Runner Only (Production Use)**
84
+ - Connects to remote broker (e.g., Railway)
85
+ - Just executes builds on your machine
86
+ - Command: `openbuilder --runner` or `openbuilder runner`
87
+
88
+ ### Step-by-Step Setup (Runner Only Mode)
89
+
90
+ #### 1. Install the CLI
91
+
92
+ ```bash
93
+ curl -fsSL https://openbuilder.app/install | bash
94
+ ```
95
+
96
+ #### 2. Initialize Your Runner
97
+
98
+ Run the interactive setup:
99
+
100
+ ```bash
101
+ openbuilder init
102
+ ```
103
+
104
+ You'll be asked:
105
+
106
+ **Workspace Location:**
107
+ ```
108
+ ? Where should projects be stored?
109
+ Default: ~/openbuilder-workspace
110
+
111
+ This is where all generated projects will be saved.
112
+ ```
113
+
114
+ **Broker URL:**
115
+ ```
116
+ ? Broker WebSocket URL:
117
+ Default: ws://localhost:4000/socket
118
+
119
+ For local development: Use default (localhost)
120
+ For remote (Railway): wss://broker.up.railway.app/socket
121
+ ```
122
+
123
+ **Shared Secret:**
124
+ ```
125
+ ? Shared secret:
126
+ Default: dev-secret
127
+
128
+ For local development: Use default (dev-secret)
129
+ For remote: Get from your Railway deployment environment variables
130
+ ```
131
+
132
+ **Runner ID:**
133
+ ```
134
+ ? Runner ID (identifier for this machine):
135
+ Default: local
136
+
137
+ For local development: Use default (local)
138
+ For multiple runners: Use descriptive names like "macbook-pro"
139
+ ```
140
+
141
+ #### 3. Verify Configuration
142
+
143
+ Check that everything is set up correctly:
144
+
145
+ ```bash
146
+ openbuilder-cli status
147
+ ```
148
+
149
+ You should see:
150
+ ```
151
+ OpenBuilder Runner Status
152
+
153
+ ℹ Status: Initialized
154
+
155
+ Config File:
156
+ ~/Library/Application Support/openbuilder/config.json
157
+
158
+ Workspace:
159
+ Path: ~/openbuilder-workspace
160
+ Exists: Yes
161
+ Projects: 0
162
+
163
+ Broker:
164
+ URL: wss://broker.up.railway.app/socket
165
+ Secret: Set
166
+
167
+ Runner:
168
+ ID: macbook-pro
169
+ Reconnect Attempts: 5
170
+ Heartbeat Interval: 15000ms
171
+
172
+ Validation:
173
+ ✓ Configuration is valid
174
+
175
+ Ready to run! Use:
176
+ openbuilder-cli run
177
+ or just openbuilder-cli
178
+ ```
179
+
180
+ #### 4. Start the Runner
181
+
182
+ **Runner only mode (connect to remote broker):**
183
+
184
+ ```bash
185
+ openbuilder --runner
186
+ ```
187
+
188
+ Or use the explicit command:
189
+ ```bash
190
+ openbuilder runner
191
+ ```
192
+
193
+ **Full stack mode (local development):**
194
+
195
+ ```bash
196
+ openbuilder run
197
+ ```
198
+
199
+ Or simply:
200
+ ```bash
201
+ openbuilder
202
+ ```
203
+
204
+ You should see (runner-only mode):
205
+ ```
206
+ Starting OpenBuilder Runner
207
+
208
+ ℹ Broker: wss://broker.up.railway.app/socket
209
+ ℹ Runner ID: macbook-pro
210
+ ℹ Workspace: ~/openbuilder-workspace
211
+
212
+ [runner] workspace root: /Users/yourname/openbuilder-workspace
213
+ [runner] connected to broker wss://broker.up.railway.app/socket...
214
+ ```
215
+
216
+ Or (full stack mode):
217
+ ```
218
+ Starting OpenBuilder Full Stack
219
+
220
+ ℹ Monorepo root: /Users/yourname/openbuilder
221
+ ℹ Web app port: 3000
222
+ ℹ Broker port: 4000
223
+
224
+ ℹ Starting services...
225
+
226
+ ℹ 1/3 Starting web app...
227
+ ℹ 2/3 Starting broker...
228
+ ℹ 3/3 Starting runner...
229
+
230
+ ✔ All services started!
231
+
232
+ Services running:
233
+ Web App: http://localhost:3000
234
+ Broker: http://localhost:4000
235
+ Runner: Connected to broker
236
+
237
+ Press Ctrl+C to stop all services
238
+ ```
239
+
240
+ #### 5. Create Your First Project
241
+
242
+ 1. Open the OpenBuilder web app in your browser
243
+ 2. Click "New Project"
244
+ 3. Enter a prompt like:
245
+ ```
246
+ Create a React app with TypeScript and Tailwind CSS
247
+ ```
248
+ 4. Watch the runner execute the build in your terminal
249
+ 5. Once complete, click "Start Dev Server" in the UI
250
+ 6. Preview your project via the tunnel URL
251
+
252
+ ### What Happens Behind the Scenes
253
+
254
+ 1. **Template Download**: Runner clones the appropriate starter template
255
+ 2. **AI Build**: Claude AI modifies the template based on your prompt
256
+ 3. **Workspace Storage**: Project is saved to `~/openbuilder-workspace/project-name/`
257
+ 4. **Dev Server**: Runner starts the dev server (e.g., `npm run dev`)
258
+ 5. **Tunnel Creation**: Cloudflare tunnel exposes your local dev server
259
+ 6. **Preview**: Web UI displays your project in an iframe
260
+
261
+ ## CLI Reference
262
+
263
+ ### Default Commands
264
+
265
+ **Start full stack:**
266
+ ```bash
267
+ openbuilder
268
+ # or
269
+ openbuilder run
270
+ ```
271
+
272
+ **Start runner only:**
273
+ ```bash
274
+ openbuilder --runner
275
+ # or
276
+ openbuilder runner
277
+ ```
278
+
279
+ ### `openbuilder init`
280
+
281
+ Initialize workspace and configuration.
282
+
283
+ ```bash
284
+ openbuilder init [options]
285
+ ```
286
+
287
+ **Options:**
288
+ - `--workspace <path>` - Set workspace directory without prompts
289
+ - `--broker <url>` - Set broker URL without prompts
290
+ - `--secret <secret>` - Set shared secret without prompts
291
+ - `--non-interactive` - Use all defaults (requires --secret)
292
+
293
+ **Examples:**
294
+
295
+ ```bash
296
+ # Interactive mode (recommended)
297
+ openbuilder init
298
+
299
+ # Non-interactive with all options
300
+ openbuilder init \
301
+ --workspace ~/my-projects \
302
+ --broker wss://broker.up.railway.app/socket \
303
+ --secret my-secret-key \
304
+ --non-interactive
305
+
306
+ # Reset existing config
307
+ openbuilder config reset
308
+ openbuilder init
309
+ ```
310
+
311
+ ---
312
+
313
+ ### `openbuilder run`
314
+
315
+ Start the full stack (web app + broker + runner) locally.
316
+
317
+ ```bash
318
+ openbuilder run [options]
319
+ openbuilder [options] # 'run' is the default command
320
+ ```
321
+
322
+ **Options:**
323
+ - `-p, --port <port>` - Web app port (default: 3000)
324
+ - `-b, --broker-port <port>` - Broker port (default: 4000)
325
+
326
+ **Examples:**
327
+
328
+ ```bash
329
+ # Start full stack with defaults
330
+ openbuilder run
331
+
332
+ # Just use default (same as run)
333
+ openbuilder
334
+
335
+ # Custom ports
336
+ openbuilder run --port 3001 --broker-port 4001
337
+ ```
338
+
339
+ **What starts:**
340
+ 1. **Web App** - Next.js app on port 3000
341
+ 2. **Broker** - WebSocket server on port 4000
342
+ 3. **Runner** - Connects to local broker
343
+
344
+ ---
345
+
346
+ ### `openbuilder runner`
347
+
348
+ Start runner only (connect to existing broker).
349
+
350
+ ```bash
351
+ openbuilder runner [options]
352
+ openbuilder --runner # Alternative: use --runner flag
353
+ ```
354
+
355
+ **Options:**
356
+ - `-b, --broker <url>` - Override broker WebSocket URL
357
+ - `-w, --workspace <path>` - Override workspace directory
358
+ - `-i, --runner-id <id>` - Override runner identifier
359
+ - `-s, --secret <secret>` - Override shared secret
360
+ - `-v, --verbose` - Enable verbose logging
361
+
362
+ **Examples:**
363
+
364
+ ```bash
365
+ # Use saved configuration
366
+ openbuilder runner
367
+
368
+ # Alternative syntax
369
+ openbuilder --runner
370
+
371
+ # Connect to local broker
372
+ openbuilder runner --broker ws://localhost:4000/socket
373
+
374
+ # Use custom workspace
375
+ openbuilder runner --workspace ~/custom-projects
376
+
377
+ # Override all settings
378
+ openbuilder runner \
379
+ --broker wss://broker.up.railway.app/socket \
380
+ --workspace ~/dev-projects \
381
+ --runner-id my-laptop \
382
+ --secret production-secret \
383
+ --verbose
384
+ ```
385
+
386
+ **Stopping the Runner:**
387
+
388
+ Press `Ctrl+C` to gracefully shutdown. The runner will:
389
+ 1. Close all active tunnels
390
+ 2. Stop dev servers
391
+ 3. Flush telemetry data
392
+ 4. Close broker connection
393
+
394
+ ---
395
+
396
+ ### `openbuilder status`
397
+
398
+ Show runner status and configuration.
399
+
400
+ ```bash
401
+ openbuilder status
402
+ ```
403
+
404
+ **Output includes:**
405
+ - Initialization status
406
+ - Config file location
407
+ - Workspace path and project count
408
+ - Broker connection details
409
+ - Runner settings
410
+ - Configuration validation
411
+
412
+ ---
413
+
414
+ ### `openbuilder config`
415
+
416
+ Manage runner configuration.
417
+
418
+ ```bash
419
+ openbuilder config <action> [key] [value]
420
+ ```
421
+
422
+ **Actions:**
423
+
424
+ **`list`** - Show all configuration:
425
+ ```bash
426
+ openbuilder config list
427
+ ```
428
+
429
+ **`get <key>`** - Get specific value:
430
+ ```bash
431
+ openbuilder config get workspace
432
+ openbuilder config get broker.url
433
+ ```
434
+
435
+ **`set <key> <value>`** - Update configuration:
436
+ ```bash
437
+ openbuilder config set workspace ~/new-workspace
438
+ openbuilder config set runner.id my-laptop
439
+ ```
440
+
441
+ **`path`** - Show config file location:
442
+ ```bash
443
+ openbuilder config path
444
+ ```
445
+
446
+ **`validate`** - Validate configuration:
447
+ ```bash
448
+ openbuilder config validate
449
+ ```
450
+
451
+ **`reset`** - Reset to defaults (requires confirmation):
452
+ ```bash
453
+ openbuilder config reset
454
+ ```
455
+
456
+ ---
457
+
458
+ ### `openbuilder cleanup`
459
+
460
+ Clean up projects and resources.
461
+
462
+ ```bash
463
+ openbuilder cleanup [options]
464
+ ```
465
+
466
+ **Options:**
467
+ - `--project <slug>` - Delete specific project
468
+ - `--all` - Delete all projects (requires confirmation)
469
+ - `--tunnels` - Close all tunnels (runner must be running)
470
+ - `--processes` - Kill all dev servers (runner must be running)
471
+
472
+ **Examples:**
473
+
474
+ ```bash
475
+ # Delete specific project
476
+ openbuilder cleanup --project my-react-app
477
+
478
+ # Delete all projects (with confirmation)
479
+ openbuilder cleanup --all
480
+
481
+ # Show cleanup help
482
+ openbuilder cleanup
483
+ ```
484
+
485
+ ---
486
+
487
+ ### `openbuilder --help`
488
+
489
+ Show help for any command.
490
+
491
+ ```bash
492
+ openbuilder --help
493
+ openbuilder init --help
494
+ openbuilder run --help
495
+ openbuilder runner --help
496
+ ```
497
+
498
+ ---
499
+
500
+ ### `openbuilder --version`
501
+
502
+ Show CLI version.
503
+
504
+ ```bash
505
+ openbuilder --version
506
+ ```
507
+
508
+ ## Configuration
509
+
510
+ ### Config File Location
511
+
512
+ Configuration is stored in a platform-specific location:
513
+
514
+ **macOS:**
515
+ ```
516
+ ~/Library/Application Support/openbuilder/config.json
517
+ ```
518
+
519
+ **Linux:**
520
+ ```
521
+ ~/.config/openbuilder/config.json
522
+ ```
523
+
524
+ ### Config File Structure
525
+
526
+ ```json
527
+ {
528
+ "version": "0.1.0",
529
+ "workspace": "/Users/yourname/openbuilder-workspace",
530
+ "broker": {
531
+ "url": "wss://broker.up.railway.app/socket",
532
+ "secret": "your-shared-secret"
533
+ },
534
+ "runner": {
535
+ "id": "macbook-pro",
536
+ "reconnectAttempts": 5,
537
+ "heartbeatInterval": 15000
538
+ },
539
+ "tunnel": {
540
+ "provider": "cloudflare",
541
+ "autoCreate": true
542
+ }
543
+ }
544
+ ```
545
+
546
+ ### Configuration Priority
547
+
548
+ Settings are resolved in this order (highest to lowest):
549
+
550
+ 1. **Command-line flags** (`--broker`, `--workspace`, etc.)
551
+ 2. **Config file** (`config.json`)
552
+ 3. **Environment variables** (when running from source)
553
+ 4. **Defaults**
554
+
555
+ ### Workspace Directory
556
+
557
+ The workspace directory stores all generated projects:
558
+
559
+ ```
560
+ ~/openbuilder-workspace/
561
+ ├── react-todo-app/
562
+ │ ├── package.json
563
+ │ ├── src/
564
+ │ └── ...
565
+ ├── nextjs-blog/
566
+ │ ├── package.json
567
+ │ ├── app/
568
+ │ └── ...
569
+ └── vite-portfolio/
570
+ ├── package.json
571
+ ├── src/
572
+ └── ...
573
+ ```
574
+
575
+ Each project is completely isolated with its own:
576
+ - Dependencies (`node_modules/`)
577
+ - Configuration files
578
+ - Git history (initialized)
579
+ - Dev server process
580
+
581
+ ## Architecture
582
+
583
+ ### Component Overview
584
+
585
+ ```
586
+ ┌─────────────────────────────────────┐
587
+ │ CLI Entry Point │
588
+ │ (src/cli/index.ts) │
589
+ └────────────┬────────────────────────┘
590
+
591
+ ┌──────┴───────┐
592
+ │ Commands │
593
+ └──────┬───────┘
594
+
595
+ ┌─────────┼─────────┐
596
+ │ │ │
597
+ ▼ ▼ ▼
598
+ ┌──────┐ ┌──────┐ ┌──────┐
599
+ │ init │ │ run │ │ ... │
600
+ └───┬──┘ └───┬──┘ └──────┘
601
+ │ │
602
+ ▼ ▼
603
+ ┌────────────────────┐
604
+ │ Utilities │
605
+ │ - Config Manager │
606
+ │ - Logger │
607
+ │ - Prompts │
608
+ │ - Spinner │
609
+ └────────────────────┘
610
+
611
+
612
+ ┌────────────────────┐
613
+ │ Runner Core │
614
+ │ (src/index.ts) │
615
+ │ - WebSocket │
616
+ │ - Build Engine │
617
+ │ - Process Manager │
618
+ │ - Tunnel Manager │
619
+ └────────────────────┘
620
+ ```
621
+
622
+ ### Key Components
623
+
624
+ **CLI Layer** (`src/cli/`):
625
+ - Commander.js-based command parser
626
+ - Interactive prompts with Inquirer
627
+ - Colored output with Chalk
628
+ - Progress indicators with Ora
629
+ - Configuration management with Conf
630
+
631
+ **Runner Core** (`src/`):
632
+ - WebSocket client for broker communication
633
+ - Claude AI integration for builds
634
+ - Dev server process management
635
+ - Cloudflare tunnel creation
636
+ - Project scoped file permissions
637
+
638
+ **Libraries** (`src/lib/`):
639
+ - `build/` - Build orchestration and streaming
640
+ - `templates/` - Template download and selection
641
+ - `tunnel/` - Tunnel management and auto-install
642
+ - `permissions/` - Project-scoped permission handlers
643
+ - `process-manager.ts` - Dev server lifecycle
644
+
645
+ ### Message Flow
646
+
647
+ ```
648
+ Web UI → OpenBuilder API → Broker → Runner CLI
649
+
650
+ 1. User submits prompt
651
+ 2. API creates build command
652
+ 3. Broker forwards via WebSocket
653
+ 4. Runner executes build
654
+ 5. Runner streams progress back
655
+ 6. UI shows real-time updates
656
+ ```
657
+
658
+ ### Security Model
659
+
660
+ The runner implements strict security controls:
661
+
662
+ 1. **Project Isolation**: Each project confined to its directory
663
+ 2. **Path Validation**: All file operations validated
664
+ 3. **Permission Scoping**: Claude restricted to project directory only
665
+ 4. **Secret Management**: Shared secret for authentication
666
+ 5. **WebSocket TLS**: Encrypted communication (wss://)
667
+
668
+ ## Development
669
+
670
+ ### Setup Development Environment
671
+
672
+ ```bash
673
+ # Clone repository
674
+ git clone <repo-url>
675
+ cd openbuilder/apps/runner
676
+
677
+ # Install dependencies
678
+ pnpm install
679
+
680
+ # Create environment file
681
+ cp .env.example .env.local
682
+ ```
683
+
684
+ ### Development Workflow
685
+
686
+ **Running in Development Mode:**
687
+
688
+ ```bash
689
+ # Start runner directly (no CLI)
690
+ pnpm run dev
691
+
692
+ # Test CLI in development
693
+ pnpm run dev:cli init
694
+ pnpm run dev:cli status
695
+
696
+ # Test full stack mode
697
+ pnpm run dev:cli run
698
+
699
+ # Test runner-only mode
700
+ pnpm run dev:cli runner
701
+ ```
702
+
703
+ **Building:**
704
+
705
+ ```bash
706
+ # Build TypeScript to JavaScript
707
+ pnpm run build
708
+
709
+ # Output goes to dist/
710
+ ```
711
+
712
+ **Testing CLI Locally:**
713
+
714
+ ```bash
715
+ # Build and link globally
716
+ pnpm run build
717
+ npm link
718
+
719
+ # Now use anywhere
720
+ openbuilder status
721
+ openbuilder --help
722
+ openbuilder --runner # Test runner mode
723
+ openbuilder run # Test full stack mode
724
+
725
+ # Unlink when done
726
+ npm unlink -g @openbuilder/cli
727
+ ```
728
+
729
+ ### Project Structure
730
+
731
+ ```
732
+ apps/runner/
733
+ ├── src/
734
+ │ ├── cli/ # CLI implementation
735
+ │ │ ├── index.ts # CLI entry point
736
+ │ │ ├── commands/ # Command implementations
737
+ │ │ │ ├── init.ts
738
+ │ │ │ ├── run.ts
739
+ │ │ │ ├── config.ts
740
+ │ │ │ ├── status.ts
741
+ │ │ │ └── cleanup.ts
742
+ │ │ └── utils/ # CLI utilities
743
+ │ │ ├── logger.ts
744
+ │ │ ├── spinner.ts
745
+ │ │ ├── prompts.ts
746
+ │ │ └── config-manager.ts
747
+ │ ├── lib/ # Runner core libraries
748
+ │ │ ├── build/
749
+ │ │ ├── templates/
750
+ │ │ ├── tunnel/
751
+ │ │ └── permissions/
752
+ │ ├── shared/ # Shared types
753
+ │ │ └── runner/
754
+ │ │ └── messages.ts
755
+ │ └── index.ts # Runner core
756
+ ├── templates/ # Config templates
757
+ │ └── config.template.json
758
+ ├── dist/ # Build output
759
+ ├── package.json
760
+ ├── tsconfig.json
761
+ └── README.md # This file
762
+ ```
763
+
764
+ ### Environment Variables (Development)
765
+
766
+ Create `.env.local`:
767
+
768
+ ```env
769
+ # Runner Configuration
770
+ RUNNER_ID=default
771
+ RUNNER_WS_URL=ws://localhost:3000/ws/runner
772
+ RUNNER_SHARED_SECRET=your-secret-here
773
+ WORKSPACE_ROOT=/Users/yourname/openbuilder-workspace
774
+ API_BASE_URL=http://localhost:3000
775
+
776
+ # Sentry Configuration
777
+ SENTRY_DSN=your-sentry-dsn
778
+ SENTRY_AUTH_TOKEN=your-sentry-token
779
+ ```
780
+
781
+ ### Adding New Commands
782
+
783
+ 1. Create command file in `src/cli/commands/`:
784
+
785
+ ```typescript
786
+ // src/cli/commands/mycommand.ts
787
+ import { logger } from '../utils/logger.js';
788
+
789
+ export async function myCommand(options: any) {
790
+ logger.info('Executing my command...');
791
+ // Implementation here
792
+ }
793
+ ```
794
+
795
+ 2. Register in `src/cli/index.ts`:
796
+
797
+ ```typescript
798
+ program
799
+ .command('mycommand')
800
+ .description('My new command')
801
+ .action(async (options) => {
802
+ const { myCommand } = await import('./commands/mycommand.js');
803
+ await myCommand(options);
804
+ });
805
+ ```
806
+
807
+ 3. Build and test:
808
+
809
+ ```bash
810
+ pnpm run build
811
+ node dist/cli/index.js mycommand
812
+ ```
813
+
814
+ ### Testing
815
+
816
+ ```bash
817
+ # Run type checking
818
+ pnpm run build
819
+
820
+ # Test specific command
821
+ node dist/cli/index.js status
822
+ node dist/cli/index.js config list
823
+
824
+ # Test with debugger
825
+ node --inspect dist/cli/index.js run
826
+ ```
827
+
828
+ ### Publishing
829
+
830
+ ```bash
831
+ # Update version
832
+ npm version patch # or minor, major
833
+
834
+ # Build
835
+ pnpm run build
836
+
837
+ # Publish to npm
838
+ npm publish --access public
839
+
840
+ # Create git tag
841
+ git tag v0.1.1
842
+ git push origin v0.1.1
843
+ ```
844
+
845
+ ## Troubleshooting
846
+
847
+ ### Common Issues
848
+
849
+ #### "Runner not initialized"
850
+
851
+ **Problem:** Running `openbuilder runner` before `init`.
852
+
853
+ **Solution:**
854
+ ```bash
855
+ openbuilder init
856
+ ```
857
+
858
+ #### "Cannot connect to broker"
859
+
860
+ **Problem:** Broker URL is incorrect or broker is down.
861
+
862
+ **Solutions:**
863
+ 1. Check broker URL:
864
+ ```bash
865
+ openbuilder config get broker.url
866
+ ```
867
+ 2. Test broker connectivity:
868
+ ```bash
869
+ curl https://broker.up.railway.app/status
870
+ ```
871
+ 3. Try local broker:
872
+ ```bash
873
+ openbuilder runner --broker ws://localhost:4000/socket
874
+ ```
875
+
876
+ #### "Shared secret is required"
877
+
878
+ **Problem:** Secret not set in config.
879
+
880
+ **Solution:**
881
+ ```bash
882
+ openbuilder config set broker.secret your-secret-here
883
+ # or
884
+ openbuilder init # Re-run setup
885
+ ```
886
+
887
+ #### "Workspace directory does not exist"
888
+
889
+ **Problem:** Workspace path is invalid or was deleted.
890
+
891
+ **Solution:**
892
+ ```bash
893
+ mkdir -p ~/openbuilder-workspace
894
+ # or
895
+ openbuilder config set workspace ~/new-workspace
896
+ ```
897
+
898
+ #### Build fails with template errors
899
+
900
+ **Problem:** Template download failed or git not installed.
901
+
902
+ **Solutions:**
903
+ 1. Verify git is installed:
904
+ ```bash
905
+ git --version
906
+ ```
907
+ 2. Check network connectivity
908
+ 3. Clear and retry:
909
+ ```bash
910
+ openbuilder cleanup --project failed-project
911
+ # Try build again in UI
912
+ ```
913
+
914
+ #### Tunnel creation fails
915
+
916
+ **Problem:** Cloudflared binary not installed or port not ready.
917
+
918
+ **Solutions:**
919
+ 1. Runner auto-installs cloudflared, check logs
920
+ 2. Verify port is listening:
921
+ ```bash
922
+ lsof -i :3000
923
+ ```
924
+ 3. Try manual tunnel:
925
+ ```bash
926
+ cloudflared tunnel --url localhost:3000
927
+ ```
928
+
929
+ #### Config corruption
930
+
931
+ **Problem:** Config file is invalid JSON.
932
+
933
+ **Solution:**
934
+ ```bash
935
+ # Show config location
936
+ openbuilder-cli config path
937
+
938
+ # Reset and reconfigure
939
+ openbuilder-cli config reset
940
+ openbuilder-cli init
941
+ ```
942
+
943
+ ### Debug Mode
944
+
945
+ Enable verbose logging:
946
+
947
+ ```bash
948
+ openbuilder-cli run --verbose
949
+ ```
950
+
951
+ Or set environment variable:
952
+
953
+ ```bash
954
+ DEBUG=* openbuilder-cli run
955
+ ```
956
+
957
+ ### Getting Help
958
+
959
+ 1. Check status:
960
+ ```bash
961
+ openbuilder-cli status
962
+ ```
963
+
964
+ 2. Validate config:
965
+ ```bash
966
+ openbuilder-cli config validate
967
+ ```
968
+
969
+ 3. View logs:
970
+ - Runner logs appear in terminal
971
+ - Check Sentry dashboard for errors
972
+
973
+ 4. Reset everything:
974
+ ```bash
975
+ openbuilder-cli config reset
976
+ openbuilder-cli cleanup --all
977
+ openbuilder-cli init
978
+ ```
979
+
980
+ ## FAQ
981
+
982
+ **Q: Can I run multiple runners?**
983
+ A: Yes! Each runner needs a unique `runner-id`. Set it during init or with:
984
+ ```bash
985
+ openbuilder runner --runner-id my-second-runner
986
+ ```
987
+
988
+ **Q: Where are my projects stored?**
989
+ A: In your workspace directory. Check with:
990
+ ```bash
991
+ openbuilder config get workspace
992
+ ```
993
+
994
+ **Q: Can I change the workspace location?**
995
+ A: Yes:
996
+ ```bash
997
+ openbuilder config set workspace ~/new-location
998
+ ```
999
+
1000
+ **Q: How do I update the CLI?**
1001
+ A: Reinstall from npm:
1002
+ ```bash
1003
+ npm update -g @openbuilder/cli
1004
+ ```
1005
+
1006
+ **Q: Does the runner need to stay running?**
1007
+ A: Yes, while you're using the web UI. It executes builds and manages dev servers.
1008
+
1009
+ **Q: Can I run the runner in the background?**
1010
+ A: Use a process manager like PM2:
1011
+ ```bash
1012
+ pm2 start openbuilder --name runner -- runner
1013
+ pm2 logs runner
1014
+ ```
1015
+
1016
+ **Q: How do I start just the runner vs full stack?**
1017
+ A:
1018
+ ```bash
1019
+ # Full stack (web + broker + runner)
1020
+ openbuilder run
1021
+
1022
+ # Runner only (connect to remote broker)
1023
+ openbuilder --runner
1024
+ # or
1025
+ openbuilder runner
1026
+ ```
1027
+
1028
+ **Q: How do I uninstall?**
1029
+ A:
1030
+ ```bash
1031
+ # Clean up projects
1032
+ openbuilder cleanup --all
1033
+
1034
+ # Uninstall CLI
1035
+ npm uninstall -g @openbuilder/cli
1036
+
1037
+ # Remove config (optional)
1038
+ rm -rf ~/Library/Application\ Support/openbuilder
1039
+ ```
1040
+
1041
+ ## Contributing
1042
+
1043
+ Contributions are welcome! Please:
1044
+
1045
+ 1. Fork the repository
1046
+ 2. Create a feature branch
1047
+ 3. Make your changes
1048
+ 4. Add tests if applicable
1049
+ 5. Submit a pull request
1050
+
1051
+ ## License
1052
+
1053
+ [License info here]