CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Convergence Protocol is an interactive web-based experience composed of 40 philosophical/psychological scenarios accessible through a 3D hallway interface (βThe Motelβ). The project is pre-launch with complete content, requiring audio generation and guidebook population to reach full launch.
Status: Phase 2 - Content complete, audio & guidebook in progress
Location: ~/Public/convergence-protocol/
Size: ~3MB
Architecture
Core Components
-
The Motel (
index.html)- 3D Three.js hallway using vanilla JavaScript
- 40 numbered doors representing philosophical/cognitive topics
- WASD movement + mouse look (desktop) with mobile grid fallback
- AudioManager class for spatial audio integration
- Door states: available (cyan), preview (purple), locked (grey)
- Real-time progress tracking and completion state persistence
-
Experiences (
experiences/directory)- 40 self-contained HTML files (one per topic)
- Each is vanilla JS/CSS - no build tools required
- Topics: cognitive biases, existential threats, system failures, etc.
- File naming:
topic-name.html(maps to door title) - All experience files have βBack to Motelβ navigation
-
Audio System (
assets/audio/)- Generated via ElevenLabs API (
generate_audio.py) - Categories: door sounds, ambient loops, narration, UI feedback
- Spatial audio ready (Web Audio API mixing)
- Not yet generated - requires API key and script execution
- Generated via ElevenLabs API (
-
Guidebook (
guidebook/directory)- Wikipedia article summaries for each of the 40 topics
- Populated via
fetch_wiki.shscript - Currently empty - awaiting script execution
- Serves as primers before entering experience rooms
-
Documentation (
docs/)design-system/- Visual styles, typography, responsive designmotel/- 3D hallway architecture, door mechanics, navigationhero-moloch/- Special experience: The Well (epic narrative)convergence-protocol/- Framework, progression system, cookies
Development Commands
Audio Generation
export ELEVENLABS_API_KEY="your-key"
python3 generate_audio.pyThis generates all sound effects and narration to assets/audio/ using ElevenLabs APIs. No audio files exist yet.
Populate Guidebook
cd ~/Public/convergence-protocol
bash fetch_wiki.shThis downloads Wikipedia article summaries and creates JSON files in guidebook/ for each of the 40 topics.
Running the Project
# Open in browser (no server required for most features)
open index.html
# Or use a local server (needed for some AJAX/fetch operations)
python3 -m http.server 8000
# Then visit http://localhost:8000Configuration & Deployment
# Export settings for syncing across machines
tar -czf ~/openclaw_settings_backup.tar.gz ~/.openclaw
# Sync settings from Mac to Lenovo
~/Public/convergence-protocol/sync_openclaw_settings.sh nosos@home-server
# Sync from Lenovo back to Mac
~/Public/convergence-protocol/sync_from_legion.sh [email protected]
# Deploy to production server
rsync -avz ~/Public/convergence-protocol/ user@server:/var/www/convergence-protocol/Key Files & Structure
convergence-protocol/
βββ index.html # Main entry point - The Motel hallway (3D)
βββ experiences/ # 40 interactive experience rooms
β βββ the-well.html # Epic experience: Moloch (hero narrative)
β βββ black-swan.html
β βββ cognitive_bias_*.html # Various cognitive biases
β βββ ... (34 more experiences)
βββ guidebook/ # Wikipedia summaries (in progress)
β βββ fetch_wiki.sh # Script to populate this directory
β βββ (40 .json files - currently empty)
βββ assets/
β βββ audio/ # Audio files (not yet generated)
β β βββ generate_audio.py # ElevenLabs generation script
β β βββ doors/ # Door interaction sounds
β β βββ ambient/ # Hallway loops & atmosphere
β β βββ ui/ # UI feedback sounds
β β βββ narration/ # Welcome/completion narration
β βββ (empty - room for textures/assets)
βββ docs/
β βββ design-system/ # Visual system specs
β βββ motel/ # Hallway architecture & mechanics
β βββ hero-moloch/ # The Well narrative structure
β βββ convergence-protocol/ # Framework & progression system
βββ HANDOFF.md # Detailed handoff notes
βββ 3_NODE_STRATEGY.md # OpenClaw multi-node sync strategy
βββ SYNC_GUIDE.md # Sync workflows for config management
βββ 100_SAYINGS.md # Curated wisdom quotes (metadata)
βββ README files and scripts
Code Patterns & Conventions
HTML/JS Structure
- Vanilla JavaScript, no frameworks required
- Each experience is self-contained with embedded CSS and JS
- Bootstrap with
<meta charset="UTF-8">and viewport meta tag - CSS uses custom properties (
:root --variables) for theming - Dark theme with luminous accents (neon, gold, bioluminescence)
Three.js Hallway (index.html)
- FPV camera movement (WASD + mouse look)
- Door objects with clickable areas that trigger modal overlays
- Progress persistence using browser localStorage
- Mobile fallback: CSS grid of door cards instead of 3D hallway
- Responsive: switches to grid layout on small screens
Styling Patterns
- Design uses gradients, text-shadows, and glowing effects
- Animation utilities: fadeUp, fadeIn, slideReveal, pulseGlow, breathe
- Color scheme: void black background, cyan/purple/gold accents
- Typography: Courier New monospace for digital aesthetic
Audio Integration
- AudioManager class handles spatial audio mixing
- Hooks: door hover (available/preview/locked), door open, ambient loops, narration
- Lazy-loaded: audio files only play when relevant events occur
- Note: All audio files reference paths that donβt exist yet
Important Architectural Notes
Linear vs Branching
Currently a linear hallway with 40 sequential doors. Branching hallway (left/right splits) was proposed but deferred for launch. Keep linear for now.
Data Persistence
- Uses
localStorageto track visited rooms and completion state - Cookie system tracks user progression (see
cookie-architecture.md) - No server-side persistence required for MVP
Mobile Support
- Detection: if viewport < 768px or touch device
- Fallback: CSS grid of door cards replaces 3D hallway
- All experiences work on mobile (self-contained, responsive)
The Well Experience
experiences/the-well.htmlis special: the βheroβ experience- Epic narrative with multiple choice branching
- Represents Moloch (sacrifice, systems, inevitable structures)
- More complex than other experiences - careful when editing
Integration Points
Audio System (Not Yet Generated)
generate_audio.pyrequires ElevenLabs API key- Output directories are created but files are empty
- Categories: doors (metal/wood open/close, locked, hover states), ambient (hallway, void, neon), UI (check-in, complete, transition), narration
- Once generated, triggered by AudioManager on DOM events
Guidebook (Not Yet Populated)
fetch_wiki.shdownloads summaries for all 40 topics- Should create 40 JSON files in
guidebook/ - Each file contains Wikipedia summary for that roomβs topic
- Can be linked from mind map nodes or presented before entering rooms
Mind Map / Terminal UI (Future)
- Proposed:
pydo.html(terminal-like interface) andmindmap.html(node visualization) - Should link to guidebook articles and track node clicks
- Not yet implemented
Testing & Validation
Manual Testing Checklist
- Open
index.htmlin browser (or run local server) - WASD movement + mouse look should work smoothly
- Click doors to open room modals
- Verify all 40 experiences load correctly
- Check back button returns to motel
- Verify progress persistence (reload and check completed rooms)
- Test mobile fallback by shrinking window to <768px
Browser Requirements
- Modern browser with Three.js support (Chrome, Firefox, Safari, Edge)
- ES6 JavaScript (template literals, arrow functions)
- Web Audio API for spatial audio
- localStorage for persistence
Future Development
Immediate (Pre-Launch)
- Run
generate_audio.pywith ElevenLabs API key - Run
fetch_wiki.shto populate guidebook - Full integration testing
Short Term (2 Weeks)
- Implement
mindmap.htmlandpydo.html(terminal UI) - Add βBack to Motelβ buttons to any experiences missing them
- Optimize load times and Three.js performance
Medium Term (1 Month)
- Analytics: room completion rates, user paths, engagement heatmaps
- Production deployment and monitoring
- Optional: branching hallway implementation
Important Decisions & Context
Why No Build Tools?
- Experiences are meant to be portable, standalone HTML files
- Simplifies deployment and reduces dependencies
- Easier for users to remix/fork individual experiences
- Fast development iteration without build step
Audio Strategy
- Pre-generate audio via API (not runtime generation) to save costs
- Spatial Web Audio mixing in browser (no server-side processing)
- Ambient loops play continuously; effects are event-triggered
Content Strategy
- 40 topics chosen to represent cognitive biases, systemic risks, and philosophical paradoxes
- Each experience is 5-15 minute immersion
- The Well (Moloch) is the capstone experience with branching narrative
- Guidebook provides context without spoiling experience
OpenClaw Multi-Node Setup
- MacBook (primary dev, voice clone generation)
- Lenovo (24/7 always-on, syncs from Mac)
- China node (separate config, VPN-routed, different endpoints)
- See
3_NODE_STRATEGY.mdfor detailed sync and config management
Notes for Future Work
- Audio files are not checked into version control (generated on demand)
- Guidebook articles can be manually edited after script population if needed
- Three.js scene is optimized but may need LOD (level of detail) for lower-end devices
- Consider adding haptic feedback for mobile door interactions
- Social features deferred to post-launch phase