Real-time collaborative coding with zero infrastructure.
-
Open the editor:
# From the devswarm repo open pair-editor.html # Or just double-click the file
-
Configure connection:
- Sync Server:
wss://demos.yjs.dev(public test server) - Room Name:
devswarm-YOURNAME(pick unique name) - Your Name:
YourName - Click Connect
- Sync Server:
-
Share with others:
Tell them to: 1. Open pair-editor.html 2. Enter SAME room name: devswarm-YOURNAME 3. Connect -
Start coding together!
- Type code in the editor
- See each other's cursors in real-time
- Chat in the sidebar
- Changes sync instantly
More private, more control.
# Install Hocuspocus (Yjs sync server)
npm install -g @hocuspocus/server
# Run server
npx @hocuspocus/server \
--port 1234 \
--quiet
# Server running on: ws://localhost:1234Or with Docker:
docker run -d \
-p 1234:1234 \
--name hocuspocus \
hocuspocus/hocuspocusOption A: ngrok (easiest)
# Install: https://ngrok.com/download
ngrok http 1234
# You get URL like: https://abc123.ngrok.io
# Share this with othersOption B: Cloudflare Tunnel
# Install: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation/
cloudflared tunnel --url http://localhost:1234
# You get URL like: https://abc-123.trycloudflare.comOption C: Your own domain
# Nginx config
server {
listen 443 ssl;
server_name sync.yourdevswarm.com;
location / {
proxy_pass http://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}Share your sync server URL:
Sync Server: wss://abc123.ngrok.io
Room Name: devswarm-main
Everyone connects to the same room → instant collaboration!
Coming soon: Direct peer-to-peer via WebRTC (y-webrtc).
1. One person sets up sync server (or use public)
2. Everyone opens pair-editor.html
3. Enter SAME room name
4. Start coding together
Real-time Editing:
- See each other's cursors
- Colored by user
- Type anywhere, no conflicts
- CRDT ensures consistency
Chat:
- Side panel for discussion
- Persists in session
- All participants see messages
Awareness:
- See who's online
- Connection status indicator
- Peer count
Use your actual editor:
# Install Live Share (Microsoft)
code --install-extension ms-vsliveshare.vsliveshare
# Or use this Yjs VS Code extension
# https://github.com/yjs/y-vscodeBut for DevSwarm prototyping, the web editor is perfect.
┌─────────────┐ WebSocket ┌─────────────┐
│ Browser 1 │◄────────────────────►│ Hocus- │
│ (pair-editor│ │ pocus │
│ .html) │ Yjs CRDT │ Server │
└─────────────┘ └─────────────┘
▲ ▲
│ │
│ WebSocket + Yjs │
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Browser 2 │ │ Browser 3 │
│ │◄────────────────────►│ │
└─────────────┘ Direct P2P Sync └─────────────┘
(via awareness)
Key tech:
- Yjs: CRDT for conflict-free editing
- WebSocket Provider: Syncs state via server
- Monaco: VS Code's editor engine
- y-monaco: Binds Yjs to Monaco
⚠️ NOT ENCRYPTED⚠️ Anyone who knows room name can join⚠️ Do not share sensitive code- ✅ Fine for prototyping/demos
- ✅ You control the infrastructure
- ✅ Add authentication (Hocuspocus supports hooks)
- ✅ Add TLS/SSL (wss://)
- ✅ Can log/monitor sessions
Recommended: Always use unique room names like UUIDs
// Generate secure room name
const room = crypto.randomUUID()
// Share this with your team: devswarm-a1b2c3d4-e5f6-...Coming in Phase 4:
1. Generate room key (age/libsodium)
2. Share key out-of-band (QR code, 1Password)
3. Encrypt CRDT ops before sending to server
4. Server sees only ciphertext
5. Only key holders can decode
Check:
# Is server running?
curl http://localhost:1234
# Should return: Upgrade Required (that's OK)
# WebSocket test
wscat -c ws://localhost:1234
# Should connectFirewall:
- Allow port 1234
- Or use ngrok/cloudflare tunnel
Verify:
- Same sync server URL?
- Same room name? (case-sensitive!)
- Check browser console for errors
- Try refreshing
- Check connection indicator (should be green)
- Look at peer count (should be >0)
- Server might be overloaded (restart it)
Hocuspocus is production-ready but defaults are conservative:
# Increase limits
npx @hocuspocus/server \
--port 1234 \
--max-debounce 10000 \
--quiet# Copy editor to your repo
cp /tmp/devswarm/pair-editor.html ~/your-swarm/
# Commit
git add pair-editor.html
git commit -m "🐝 Add pair programming editor"
git push
# Now every fork has the editor
# Team members just open the HTML fileEnhancement idea:
// In pair-editor.html
// Auto-detect repo and use as room name
const repo = await fetch('/.git/config')
.then(r => r.text())
.then(text => text.match(/url = .*\/(.+?)\.git/)[1])
const defaultRoom = `devswarm-${repo}`In swarm-coordinator.sh:
# Start sync server on CI
if command -v npx >/dev/null 2>&1; then
log "Starting pair programming server..."
npx @hocuspocus/server --port 1234 --quiet &
# Update manifest with server info
jq '.sync_server = "ws://localhost:1234"' \
.swarm/manifest.json > .swarm/manifest.tmp
mv .swarm/manifest.tmp .swarm/manifest.json
fi- Real-time collaborative editing
- Chat functionality
- WebSocket sync
- Monaco editor integration
// Shared task list
const ytasks = ydoc.getArray('tasks')
// Agent reads tasks
ytasks.observe(() => {
const pending = ytasks.toArray().filter(t => t.status === 'pending')
if (pending.length > 0) {
executeTasks(pending)
}
})
// Human adds task
ytasks.push([{
id: crypto.randomUUID(),
type: 'implement',
description: 'Add IPFS fragment storage',
status: 'pending',
created: Date.now()
}])# Agent connects to same CRDT room
# Reads task queue
# Executes tasks
# Writes results back
# Human sees changes in real-time// Store code fragments in IPFS
// Reference CIDs in CRDT doc
// Bootstrap reconstructs from fragmentsQ: Why not Google Docs / Notion? A: Those are proprietary, centralized platforms. DevSwarm is about user sovereignty. Your code, your infrastructure.
Q: Why not VS Code Live Share? A: Live Share requires Microsoft account. DevSwarm works on any platform, even self-hosted Git forges.
Q: Can I use this for production? A: The editor is a prototype. For production, integrate Yjs into your actual tools (VS Code extension, CLI, etc.)
Q: What's the latency? A: With local server: <10ms. With ngrok: 50-200ms. With public server: 100-500ms. CRDT ensures consistency regardless.
Q: How many people can edit simultaneously? A: Yjs scales to 100+ concurrent editors. Server might need tuning.
Q: Does it work offline? A: Partially. Your edits are stored locally (IndexedDB). When you reconnect, they sync. But you won't see others' changes while offline.
Q: Can I integrate AI agents? A: YES. That's the next step. Agent connects as a "user", reads CRDT doc, writes results.
Alice (sets up server):
cd devswarm/
npx @hocuspocus/server --port 1234 --quiet &
ngrok http 1234
# Got: https://abc123.ngrok.ioAlice (shares with Bob and Claude):
Sync Server: wss://abc123.ngrok.io
Room: devswarm-ipfs-integration
Bob (joins):
open pair-editor.html
# Enters: wss://abc123.ngrok.io, devswarm-ipfs-integration, Bob
# Clicks ConnectClaude (AI agent, joins programmatically):
import y_py as Y
from ypy_websocket import WebsocketProvider
ydoc = Y.YDoc()
provider = WebsocketProvider(ydoc, "wss://abc123.ngrok.io", "devswarm-ipfs-integration")
# Read code
code = ydoc.get_text("monaco")
print(code.to_string())
# Make edits (Alice and Bob see in real-time)
code.insert(0, "// AI-generated IPFS integration\n")All three coding together in real-time. 🐝
- Yjs Docs: https://docs.yjs.dev/
- Hocuspocus: https://tiptap.dev/hocuspocus
- Monaco Editor: https://microsoft.github.io/monaco-editor/
- y-monaco: https://github.com/yjs/y-monaco
- y-websocket: https://github.com/yjs/y-websocket
MIT - Fork freely 🐝
Ready to pair program?
# 1. Open the editor
open pair-editor.html
# 2. Use public server (instant)
Server: wss://demos.yjs.dev
Room: devswarm-test-123
Name: YourName
# 3. Share room name with collaborators
# 4. Start coding together!🐝 The swarm is collaborative by default.