Skip to main content

Development Commands

Core Commands

Package-Specific

Build Pipeline

The server package includes automated tasks for collision footprint extraction:
This scans world/assets/models/**/*.glb and generates world/assets/manifests/model-bounds.json with bounding box data for automatic collision footprint calculation. Turbo Caching:
  • Only re-runs when GLB files or script changes
  • Outputs cached between builds
  • Configured in packages/server/turbo.json

Circular Dependency Handling

The build system handles circular dependencies between packages using resilient build patterns:
Circular Dependencies:
  • @hyperscape/shared@hyperscape/procgen (shared imports from procgen, procgen peer-depends on shared)
  • @hyperscape/shared@hyperscape/plugin-hyperscape (similar circular dependency)
Build Strategy:
  • When turbo runs a clean build, tsc fails because the other package’s dist/ doesn’t exist yet
  • The || echo pattern allows the build to exit 0 even with circular dep errors
  • Packages still produce partial output which is sufficient for downstream consumers
  • Shared package always uses --skipLibCheck in declaration generation to handle circular dependencies
This is a known limitation of the current architecture. The packages produce working output despite TypeScript errors during clean builds.

Port Allocation

Hot Reload

The dev server provides:
  • Client: Vite HMR for instant updates
  • Server: Auto-restart on file changes
  • Shared: Watch mode with rebuild

Asset Management

Hyperscape uses a separate assets repository to keep the main codebase lightweight and prevent manifest divergence.

Asset Repository Structure

  • Main repo (HyperscapeAI/hyperscape): Code only, no asset files
  • Assets repo (HyperscapeAI/assets): All game content (manifests, models, textures, audio) (~200MB with Git LFS)
Change (Feb 2026): Manifests are now sourced exclusively from the assets repo. The main repo no longer tracks any asset files, including JSON manifests.

Local Development

Assets are automatically cloned during bun install:
The ensure-assets.mjs script:
  1. Checks if packages/server/world/assets/ exists
  2. If missing, clones HyperscapeAI/assets repository
  3. Local dev: Full clone with LFS for models/textures/audio (~200MB)
  4. CI/Production: Shallow clone without LFS (manifests only, ~1MB)

CI/CD Asset Handling

In CI environments, assets are cloned without LFS (manifests only):
The entire packages/server/world/assets/ directory is gitignored. Never commit asset files to the main repository. All game content lives in the HyperscapeAI/assets repository.

Asset Updates

When assets are updated in the assets repository:
  1. Pull latest assets: bun run assets:sync
  2. Manifests and models are automatically updated
  3. Restart server to reload manifests
Benefits of Separate Assets Repo:
  • Single source of truth for all game content
  • Prevents manifest divergence between repos
  • Reduces main repo size (no binary commits)
  • Cleaner git history
  • Easier asset updates (PR to assets repo, not main repo)
  • CI gets manifests without downloading large binary files

Manifest Files

All manifest JSON files are sourced from the assets repo:
Manifest Loading: The server’s DataManager loads manifests from packages/server/world/assets/manifests/ which is populated by cloning the assets repo.

Docker Services

The CDN starts automatically with bun run dev. Only run manually if using services separately.

Testing

Tests use real Hyperscape instances with Playwright—no mocks allowed. The server must not be running before tests.

E2E Journey Tests (NEW - February 2026)

Comprehensive end-to-end tests validate the complete player journey from login to gameplay: Test File: packages/client/tests/e2e/complete-journey.spec.ts
1

Login Flow

Full authentication and character selection
2

Loading Screen

Uses waitForLoadingScreenHidden helper for reliable test synchronization
3

Spawn

Character spawns in world with proper initialization
4

Walk

Movement and pathfinding validation
5

Screenshot Comparison

Utilities to verify game is rendering correctly
Key Features:
  • Real Browser Testing: Uses Playwright with actual WebGPU rendering (no mocks)
  • Screenshot Comparison: Visual regression testing to verify rendering
  • Loading Screen Detection: Reliable synchronization helpers
  • Full Gameplay Flow: Tests complete user journey, not isolated features
Test Utilities:
Running Journey Tests:

Test Stability Improvements

Recent commits improved test reliability:
  • GoldClob Fuzz Tests: 120s timeout for randomized invariant tests (4 seeds × 140 operations)
  • Precision Fixes: Use larger amounts (10000n) to avoid gas cost precision issues
  • Dynamic Import Timeout: 60s timeout for EmbeddedHyperscapeService beforeEach hooks
  • Anchor Test Configuration: Use localnet instead of devnet for free SOL in anchor test
  • CI Build Order: Build impostors/procgen before shared (dependency fix)

Linting

GitHub Actions

The repository includes automated workflows for code quality and documentation:

Claude Code Integration

  • .github/workflows/claude.yml - Responds to @claude mentions in issues and PRs for automated assistance
  • .github/workflows/claude-code-review.yml - Automated code review on pull requests
  • .github/workflows/update-docs.yml - Automatically updates documentation when manifest files change
To use Claude Code:
  1. Comment @claude in any issue or PR
  2. Claude will analyze the context and provide assistance
  3. For code reviews, Claude automatically reviews new PRs
Requires CLAUDE_CODE_OAUTH_TOKEN and MINTLIFY_API_KEY secrets to be configured in repository settings.

Code Quality Improvements (February 2026)

Type Safety Audit (commit d9113595)

Eliminated explicit any types in core game logic: Files Updated:
  • tile-movement.ts - Removed 13 any casts by properly typing BuildingCollisionService
  • proxy-routes.ts - Replaced any with proper types (unknown, Buffer | string, Error)
  • ClientGraphics.ts - Added safe cast after WebGPU verification
Remaining any types:
  • TSL shader code (ProceduralGrass.ts) - @types/three limitation
  • Browser polyfills (polyfills.ts) - intentional mock implementations
  • Test files - acceptable for test fixtures

Memory Leak Fix (commit 3bc59db)

Fixed memory leak in InventoryInteractionSystem using AbortController:

Dead Code Removal (commit 7c3dc985)

Removed 3,098 lines of dead code:
  • Deleted PacketHandlers.ts (never imported, completely unused)
  • Updated audit TODOs to reflect actual codebase state
  • ServerNetwork is already decomposed into 30+ modules (not 116K lines)
  • ClientNetwork handlers are intentional thin wrappers (not bloated)

Build System Fixes

TypeScript Override Conflict (commit 113a85a): Removed conflicting TypeScript overrides from root package.json. The build system now relies on workspace protocol and Turbo’s dependency resolution. Windows Environment Variables (commit 3b7665d): Fixed native app builds on Windows by conditionally supplying secrets:
Linux/Windows Desktop Builds (commit f19a7042): Fixed unsigned builds for Linux and Windows:
CI Workflow Matrix Reference (commit a095ba1): Removed invalid matrix reference from job-level condition. Matrix variables are only available during job execution, not at job scheduling time.

Common Workflows

Adding a New Feature

  1. Make changes in packages/shared/src/
  2. Hot reload applies automatically
  3. Test in browser at localhost:3333

Updating Game Content

  1. Edit manifest files in world/assets/manifests/
  2. Restart server to reload manifests
  3. Documentation updates automatically via GitHub Actions

Debugging Server

  1. Check terminal output for errors
  2. Server logs show WebSocket activity
  3. Database queries logged in dev mode

Clean Rebuild