Test level system (LevelRoot, LevelTag, authored environment, scene hierarchy) against the poke example using the iwsdk CLI.
argument-hint
[--suite root|tags|lighting|hierarchy|all]
Level System Test
Run 5 test suites covering LevelRoot, LevelTag membership, authored environment, scene hierarchy, and stability.
Configuration:
EXAMPLE_DIR: $IWSDK_REPO_ROOT/examples/poke
Tool calls: every tool call is npx iwsdk <subcommand> [--input-json '<JSON>'] [--timeout <ms>], run from inside the example workspace (cwd $EXAMPLE_DIR). The CLI auto-discovers the IWSDK app root from cwd, so no path tricks are required. Run npx iwsdk mcp inspect from the example to discover available tools and their CLI subcommands.
<JSON> is a JSON object string. Omit --input-json if no arguments are needed.
Output is JSON on stdout: {ok, workspaceRoot, operation, result}. Parse it to check assertions.
Use --timeout 20000 for operations that may take longer (reload, xr enter, screenshot).
IMPORTANT: Run each Bash command one at a time. Parse the JSON output and verify assertions before moving to the next command. Do NOT chain multiple CLI commands together.
IMPORTANT: When the instructions say "wait N seconds", use sleep N as a separate Bash command.
Step 1: Install Dependencies
/examples/poke && npm run fresh:install
cd
$IWSDK_REPO_ROOT
Wait for this to complete before proceeding.
Step 2: Start Dev Server
Start the dev server as a background task using the Bash tool's run_in_background: true parameter:
cd$IWSDK_REPO_ROOT/examples/poke && npm run dev
IMPORTANT: This command MUST be run with run_in_background: true on the Bash tool — do NOT append & to the command itself.
Once the background task is launched, poll the output for Vite's ready message (up to 60s). You can also run npx iwsdk dev status from the example directory until state.running becomes true. You do not need to extract or manage the port yourself; subsequent commands resolve the active runtime through the CLI automatically.
If the server fails to start within 60 seconds, report FAIL for all suites and skip to Step 5.
Step 3: Verify Connectivity
npx iwsdk ecs systems 2>/dev/null
This must return JSON with a list of systems. If it fails:
Check the dev server output for errors
Try killing and restarting the server (Step 2)
If it still fails, report FAIL for all suites and skip to Step 5
Assert: Exactly 1 entity. Save its entityIndex as <root>.
Entity should have name "LevelRoot".
Entity should also have: Transform, LevelTag, DomeGradient, IBLGradient.
Assert: 10 entities — entity 0 (scene root) plus 9 persistent input-rig entities created by the world bootstrap (xrOrigin, head, ray/grip/indexTip spaces for left and right). None of these should carry LevelTag.
Suite 3: Authored Environment
Test 3.1: LevelRoot Has Both Environment Components
Assert: Both scene-authored components are present with the gradient values
declared in public/scenes/poke.iwsdk.scene.json. They are not synthesized by
LevelSystem.
Suite 4: Scene Hierarchy
Test 4.1: LevelRoot is Child of Scene Root
npx iwsdk scene runtime-hierarchy --input-json '{"maxDepth":2}' 2>/dev/null
Assert:
Scene root children include "LevelRoot"
LevelRoot children include all level entities (env mesh, robot, panel, logo, etc.)
If any suite fails, include which assertion failed and actual vs expected values.
Recovery
If at any point a transient error occurs (server crash, WebSocket timeout, connection refused, etc.) that is NOT caused by a source code bug:
Stop the dev server: cd $IWSDK_REPO_ROOT/examples/poke && npx iwsdk dev down
Restart: re-run Step 2 to start a fresh dev server
Re-run the Pre-test Setup (reload, accept session)
Retry the failed suite
Only give up after one retry attempt per suite. If the same suite fails twice, mark it FAIL and continue to the next suite.
Known Issues & Workarounds
LevelTag id for default level
When no GLXF level URL is provided, the level id is "level:default". All entities created via world.createTransformEntity() (without persistent: true) automatically receive LevelTag with this id.
Level root identity enforcement
LevelSystem.update() checks and resets the level root's transform to identity every frame. If you modify the level root's position via ecs set-component, it will be reset on the next frame.
Entity 0 is special
Entity 0 wraps the Three.js Scene object. It has Transform but no LevelTag — it's the persistent root that survives level changes.
Entity indices change on reload
Never cache entity indices across page reloads. Always re-discover via npx iwsdk ecs find.