@willjackson/claude-code-bridge 0.2.3 → 0.3.0
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.
- package/README.md +100 -144
- package/dist/{chunk-5HWFDZKH.js → chunk-LUL3SX2F.js} +1 -355
- package/dist/chunk-LUL3SX2F.js.map +1 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +38 -154
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +35 -290
- package/dist/index.js +1 -81
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/dist/chunk-5HWFDZKH.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@ A bidirectional communication system that enables two separate Claude Code insta
|
|
|
10
10
|
- [Quick Start](#quick-start)
|
|
11
11
|
- [CLI Reference](#cli-reference)
|
|
12
12
|
- [Configuration](#configuration)
|
|
13
|
-
- [Environment Setup](#environment-setup)
|
|
14
13
|
- [Programmatic Usage](#programmatic-usage)
|
|
15
14
|
- [Troubleshooting](#troubleshooting)
|
|
16
15
|
- [Development](#development)
|
|
@@ -18,7 +17,7 @@ A bidirectional communication system that enables two separate Claude Code insta
|
|
|
18
17
|
|
|
19
18
|
## Overview
|
|
20
19
|
|
|
21
|
-
Claude Code Bridge connects
|
|
20
|
+
Claude Code Bridge connects two Claude Code instances running on different machines, containers, or networks via WebSocket.
|
|
22
21
|
|
|
23
22
|
### Architecture
|
|
24
23
|
|
|
@@ -47,9 +46,9 @@ Claude Code Bridge connects a native macOS/Linux Claude Code instance with a Cla
|
|
|
47
46
|
## Features
|
|
48
47
|
|
|
49
48
|
- **WebSocket-based communication** with automatic reconnection
|
|
50
|
-
- **Environment auto-detection** for Docksal, DDEV, Lando, and Docker
|
|
51
49
|
- **Context synchronization** with configurable file patterns
|
|
52
50
|
- **Task delegation** with timeout handling
|
|
51
|
+
- **Remote file operations** - read, write, and delete files on connected peers
|
|
53
52
|
- **Peer-to-peer mode** allowing bidirectional communication
|
|
54
53
|
- **CLI and programmatic API** for flexible integration
|
|
55
54
|
|
|
@@ -99,33 +98,37 @@ claude-bridge start --port 8766
|
|
|
99
98
|
claude-bridge start --port 8765 --connect ws://host.docker.internal:8766
|
|
100
99
|
```
|
|
101
100
|
|
|
102
|
-
### Scenario 2:
|
|
101
|
+
### Scenario 2: Peer-to-Peer Mode
|
|
103
102
|
|
|
104
|
-
|
|
103
|
+
Both instances can initiate communication:
|
|
105
104
|
|
|
105
|
+
**Terminal 1 (Mac):**
|
|
106
106
|
```bash
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
claude-bridge start --port 8766
|
|
108
|
+
```
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
**Terminal 2 (Container):**
|
|
111
|
+
```bash
|
|
112
|
+
claude-bridge start --port 8765 --connect ws://host.docker.internal:8766
|
|
112
113
|
```
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
Once connected, either side can send context or delegate tasks to the other.
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
### Scenario 3: Remote File Operations
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
Enable file operations on the remote to allow reading, writing, and deleting files:
|
|
120
|
+
|
|
121
|
+
**Terminal 1 (Mac - relay mode, no handlers):**
|
|
119
122
|
```bash
|
|
120
123
|
claude-bridge start --port 8766
|
|
121
124
|
```
|
|
122
125
|
|
|
123
|
-
**Terminal 2 (Container):**
|
|
126
|
+
**Terminal 2 (Container - with file handlers):**
|
|
124
127
|
```bash
|
|
125
|
-
claude-bridge start --
|
|
128
|
+
claude-bridge start --with-handlers --connect ws://host.docker.internal:8766
|
|
126
129
|
```
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
Now you can read, write, and edit files on the remote container from your Mac.
|
|
129
132
|
|
|
130
133
|
## CLI Reference
|
|
131
134
|
|
|
@@ -149,11 +152,11 @@ Options:
|
|
|
149
152
|
claude-bridge start [options]
|
|
150
153
|
|
|
151
154
|
Options:
|
|
152
|
-
-p, --port <port> Port to listen on (default: 8765
|
|
155
|
+
-p, --port <port> Port to listen on (default: 8765)
|
|
153
156
|
-h, --host <host> Host to bind to (default: 0.0.0.0)
|
|
154
157
|
-c, --connect <url> URL to connect to on startup (e.g., ws://localhost:8765)
|
|
155
|
-
-a, --auto Auto-detect environment and configure
|
|
156
158
|
-d, --daemon Run in background
|
|
159
|
+
--with-handlers Enable file operations and task handling (read/write/delete files)
|
|
157
160
|
```
|
|
158
161
|
|
|
159
162
|
**Examples:**
|
|
@@ -170,6 +173,9 @@ claude-bridge start --connect ws://192.168.1.100:8765
|
|
|
170
173
|
|
|
171
174
|
# Start in daemon mode
|
|
172
175
|
claude-bridge start --daemon
|
|
176
|
+
|
|
177
|
+
# Start with file operation handlers enabled
|
|
178
|
+
claude-bridge start --with-handlers --connect ws://host.docker.internal:8766
|
|
173
179
|
```
|
|
174
180
|
|
|
175
181
|
#### `stop` - Stop the Running Bridge
|
|
@@ -210,27 +216,15 @@ claude-bridge connect ws://localhost:8765
|
|
|
210
216
|
claude-bridge connect ws://host.docker.internal:8766
|
|
211
217
|
```
|
|
212
218
|
|
|
213
|
-
#### `
|
|
214
|
-
|
|
215
|
-
```bash
|
|
216
|
-
claude-bridge discover
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
Searches for:
|
|
220
|
-
- Docker containers with `claude.bridge.enabled=true` label
|
|
221
|
-
- Running Docksal projects
|
|
222
|
-
- Running DDEV projects
|
|
223
|
-
|
|
224
|
-
#### `info` - Show Environment Information
|
|
219
|
+
#### `info` - Show System Information
|
|
225
220
|
|
|
226
221
|
```bash
|
|
227
222
|
claude-bridge info
|
|
228
223
|
```
|
|
229
224
|
|
|
230
225
|
Displays:
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
- Network configuration
|
|
226
|
+
- System information (Node version, OS, platform)
|
|
227
|
+
- Network interfaces
|
|
234
228
|
- Current configuration settings
|
|
235
229
|
|
|
236
230
|
## Configuration
|
|
@@ -299,95 +293,6 @@ interaction:
|
|
|
299
293
|
| `interaction.notifyOnActivity` | boolean | true | Show notifications on activity |
|
|
300
294
|
| `interaction.taskTimeout` | number | 300000 | Task timeout in ms |
|
|
301
295
|
|
|
302
|
-
## Environment Setup
|
|
303
|
-
|
|
304
|
-
### DDEV
|
|
305
|
-
|
|
306
|
-
**Option 1: Using the DDEV Addon**
|
|
307
|
-
|
|
308
|
-
Copy the addon files to your DDEV project:
|
|
309
|
-
|
|
310
|
-
```bash
|
|
311
|
-
cp -r addons/ddev/* .ddev/
|
|
312
|
-
ddev restart
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Then start the bridge:
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
ddev exec claude-bridge start --connect ws://host.docker.internal:8766
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
**Option 2: Add to docker-compose**
|
|
322
|
-
|
|
323
|
-
Create `.ddev/docker-compose.claude-bridge.yaml`:
|
|
324
|
-
|
|
325
|
-
```yaml
|
|
326
|
-
services:
|
|
327
|
-
web:
|
|
328
|
-
labels:
|
|
329
|
-
- "claude.bridge.enabled=true"
|
|
330
|
-
- "claude.bridge.port=8765"
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
### Docksal
|
|
334
|
-
|
|
335
|
-
**Option 1: Using the Docksal Addon**
|
|
336
|
-
|
|
337
|
-
```bash
|
|
338
|
-
# Copy addon to Docksal
|
|
339
|
-
cp -r addons/docksal/* ~/.docksal/addons/claude-bridge/
|
|
340
|
-
|
|
341
|
-
# Install in your project
|
|
342
|
-
fin addon install claude-bridge
|
|
343
|
-
|
|
344
|
-
# Start the bridge
|
|
345
|
-
fin claude-bridge start
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
**Option 2: Manual Setup**
|
|
349
|
-
|
|
350
|
-
Add to your project's `.docksal/docksal.yml`:
|
|
351
|
-
|
|
352
|
-
```yaml
|
|
353
|
-
services:
|
|
354
|
-
cli:
|
|
355
|
-
labels:
|
|
356
|
-
- "claude.bridge.enabled=true"
|
|
357
|
-
- "claude.bridge.port=8765"
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
### Lando
|
|
361
|
-
|
|
362
|
-
Lando support is coming soon. For now, you can manually install the bridge in your Lando container:
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
lando ssh
|
|
366
|
-
npm install -g claude-code-bridge
|
|
367
|
-
claude-bridge start --connect ws://host.docker.internal:8766
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
### Plain Docker
|
|
371
|
-
|
|
372
|
-
Add to your `docker-compose.yml`:
|
|
373
|
-
|
|
374
|
-
```yaml
|
|
375
|
-
services:
|
|
376
|
-
app:
|
|
377
|
-
labels:
|
|
378
|
-
- "claude.bridge.enabled=true"
|
|
379
|
-
- "claude.bridge.port=8765"
|
|
380
|
-
environment:
|
|
381
|
-
- NODE_ENV=development
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
Then inside the container:
|
|
385
|
-
|
|
386
|
-
```bash
|
|
387
|
-
npm install -g claude-code-bridge
|
|
388
|
-
claude-bridge start --auto
|
|
389
|
-
```
|
|
390
|
-
|
|
391
296
|
## Programmatic Usage
|
|
392
297
|
|
|
393
298
|
### Basic Usage
|
|
@@ -483,6 +388,79 @@ bridge.onTaskReceived(async (task) => {
|
|
|
483
388
|
});
|
|
484
389
|
```
|
|
485
390
|
|
|
391
|
+
### Remote File Operations
|
|
392
|
+
|
|
393
|
+
When connected to a peer running with `--with-handlers`, you can perform file operations:
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
// Read a file from the remote peer
|
|
397
|
+
const readResult = await bridge.delegateTask({
|
|
398
|
+
id: 'read-1',
|
|
399
|
+
description: 'Read config file',
|
|
400
|
+
scope: 'execute',
|
|
401
|
+
data: {
|
|
402
|
+
action: 'read_file',
|
|
403
|
+
path: 'config/settings.json',
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
if (readResult.success) {
|
|
408
|
+
console.log('File content:', readResult.data.content);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Write a file to the remote peer
|
|
412
|
+
const writeResult = await bridge.delegateTask({
|
|
413
|
+
id: 'write-1',
|
|
414
|
+
description: 'Create new file',
|
|
415
|
+
scope: 'execute',
|
|
416
|
+
data: {
|
|
417
|
+
action: 'write_file',
|
|
418
|
+
path: 'src/newfile.ts',
|
|
419
|
+
content: 'export const hello = "world";',
|
|
420
|
+
},
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
console.log('Bytes written:', writeResult.data.bytesWritten);
|
|
424
|
+
|
|
425
|
+
// Delete a file on the remote peer
|
|
426
|
+
const deleteResult = await bridge.delegateTask({
|
|
427
|
+
id: 'delete-1',
|
|
428
|
+
description: 'Remove temp file',
|
|
429
|
+
scope: 'execute',
|
|
430
|
+
data: {
|
|
431
|
+
action: 'delete_file',
|
|
432
|
+
path: 'temp/cache.json',
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
// Edit a file (read, modify, write back)
|
|
437
|
+
const file = await bridge.delegateTask({
|
|
438
|
+
id: 'edit-read',
|
|
439
|
+
description: 'Read file for editing',
|
|
440
|
+
scope: 'execute',
|
|
441
|
+
data: { action: 'read_file', path: 'README.md' },
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const newContent = file.data.content.replace('old text', 'new text');
|
|
445
|
+
|
|
446
|
+
await bridge.delegateTask({
|
|
447
|
+
id: 'edit-write',
|
|
448
|
+
description: 'Write edited file',
|
|
449
|
+
scope: 'execute',
|
|
450
|
+
data: { action: 'write_file', path: 'README.md', content: newContent },
|
|
451
|
+
});
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Available file operations:**
|
|
455
|
+
|
|
456
|
+
| Action | Data Fields | Description |
|
|
457
|
+
|--------|-------------|-------------|
|
|
458
|
+
| `read_file` | `path` | Read file content from remote |
|
|
459
|
+
| `write_file` | `path`, `content` | Create or overwrite a file |
|
|
460
|
+
| `delete_file` | `path` | Delete a file |
|
|
461
|
+
|
|
462
|
+
> **Security Note:** All file operations are restricted to the project directory where the bridge is running. Paths outside the project root are rejected.
|
|
463
|
+
|
|
486
464
|
### Environment Detection
|
|
487
465
|
|
|
488
466
|
```typescript
|
|
@@ -544,18 +522,6 @@ for (const change of delta.changes) {
|
|
|
544
522
|
2. Increase timeout settings in config
|
|
545
523
|
3. Enable verbose logging: `claude-bridge start -v`
|
|
546
524
|
|
|
547
|
-
### Environment Detection Issues
|
|
548
|
-
|
|
549
|
-
**Problem:** Bridge doesn't detect my environment correctly
|
|
550
|
-
|
|
551
|
-
**Solutions:**
|
|
552
|
-
1. Run `claude-bridge info` to see detected environment
|
|
553
|
-
2. Check environment variables are set correctly:
|
|
554
|
-
- Docksal: `DOCKSAL_STACK` should be set
|
|
555
|
-
- DDEV: `IS_DDEV_PROJECT=true` should be set
|
|
556
|
-
- Lando: `LANDO=ON` should be set
|
|
557
|
-
3. Use explicit configuration instead of auto-detection
|
|
558
|
-
|
|
559
525
|
### Port Conflicts
|
|
560
526
|
|
|
561
527
|
**Problem:** Port already in use
|
|
@@ -625,13 +591,7 @@ claude-code-bridge/
|
|
|
625
591
|
│ │ └── context.ts # Context manager
|
|
626
592
|
│ ├── transport/
|
|
627
593
|
│ │ ├── interface.ts # Transport abstraction
|
|
628
|
-
│ │
|
|
629
|
-
│ │ └── discovery.ts # Peer discovery
|
|
630
|
-
│ ├── environment/
|
|
631
|
-
│ │ ├── detect.ts # Environment detection
|
|
632
|
-
│ │ ├── docksal.ts # Docksal helpers
|
|
633
|
-
│ │ ├── ddev.ts # DDEV helpers
|
|
634
|
-
│ │ └── lando.ts # Lando helpers
|
|
594
|
+
│ │ └── websocket.ts # WebSocket implementation
|
|
635
595
|
│ ├── cli/
|
|
636
596
|
│ │ ├── index.ts # CLI entry point
|
|
637
597
|
│ │ └── commands/ # CLI commands
|
|
@@ -643,10 +603,6 @@ claude-code-bridge/
|
|
|
643
603
|
│ ├── unit/ # Unit tests
|
|
644
604
|
│ ├── integration/ # Integration tests
|
|
645
605
|
│ └── e2e/ # End-to-end tests
|
|
646
|
-
└── addons/
|
|
647
|
-
├── ddev/ # DDEV addon
|
|
648
|
-
├── docksal/ # Docksal addon
|
|
649
|
-
└── lando/ # Lando plugin
|
|
650
606
|
```
|
|
651
607
|
|
|
652
608
|
### Running Tests
|