Overview
The /world command family allows you to select active worlds and attach lore dynamically during your storytelling sessions. Worlds define the setting, atmosphere, and context for your narratives.
Commands
/world select
Activates a specific world for your current session.
/world attach_lore
Adds lore text to the current active world’s RAG (Retrieval-Augmented Generation) system.
/world attach_lore <lore_text>
/world select
Syntax
Parameters
| Parameter | Type | Required | Description |
|---|
world_id | string | Yes | The unique identifier of the world to activate |
Behavior
- Sets
state.ACTIVE_WORLD_ID to the specified world ID
- Persists the change via
state.save_state()
- Sends a system update confirmation
- Broadcasts the state change to all connected clients
Selecting a world is a prerequisite for creating new sessions.
Examples
Select a Fantasy World
/world select eldoria-realm
Expected Output:
Active world set to eldoria-realm
Select a Sci-Fi World
/world select nova-station-2247
Expected Output:
Active world set to nova-station-2247
WebSocket Response
{
"event": "system_update",
"payload": {
"content": "Active world set to eldoria-realm",
"metadata": {
"world_id": "eldoria-realm"
}
}
}
After the system update, the engine calls broadcast_sync_state() to synchronize all clients.
/world attach_lore
Syntax
/world attach_lore <lore_text>
Parameters
| Parameter | Type | Required | Description |
|---|
lore_text | string | Yes | The lore text to attach (can contain spaces) |
Behavior
- Generates a unique UUID for the lore entry
- Adds the lore to the RAG system via
rag_manager.add_lore()
- Associates the lore with
state.ACTIVE_WORLD_ID
- Sends a confirmation message
Attached lore becomes immediately available for RAG retrieval during AI generation, enriching responses with world-specific context.
Examples
Attach Location Lore
/world attach_lore The Crystal Caves are ancient caverns filled with glowing blue crystals that hum with magical energy.
Expected Output:
Lore attached successfully.
Attach Historical Lore
/world attach_lore The Great Dragon War of 1247 devastated the northern kingdoms and led to the formation of the Mage Council.
Expected Output:
Lore attached successfully.
Attach Cultural Lore
/world attach_lore The Nomadic Tribes of Zephyr follow the Star Path, a ancient tradition of celestial navigation.
Expected Output:
Lore attached successfully.
WebSocket Response
{
"event": "system_update",
"payload": {
"content": "Lore attached successfully.",
"metadata": {}
}
}
Source Code Reference
Implemented in engine/commands.py:43-61:
elif cmd == "/world" and len(parts) >= 3:
sub = parts[1]
if sub == "attach_lore":
lore_text = parts[2]
rag_manager.add_lore(state.ACTIVE_WORLD_ID, str(uuid.uuid4()), lore_text)
await websocket.send_text(
build_ws_payload("system_update", "Lore attached successfully.")
)
elif sub == "select":
state.ACTIVE_WORLD_ID = parts[2].strip()
state.save_state()
await websocket.send_text(
build_ws_payload(
"system_update",
f"Active world set to {state.ACTIVE_WORLD_ID}",
{"world_id": state.ACTIVE_WORLD_ID},
)
)
await broadcast_sync_state(websocket)
Use Cases
Starting a New Adventure
/world select forgotten-isles
Select your world before creating a session.
Dynamic World Building
/world attach_lore The Lighthouse of Eternal Flame has burned for three centuries, maintained by the Silent Keepers.
Add lore on-the-fly as your story develops.
Enriching Existing Worlds
/world attach_lore Local legend speaks of a hidden vault beneath the old library, sealed since the Scholar's Rebellion.
Expand your world’s depth during gameplay.
Common Issues
Missing subcommand: The /world command requires either select or attach_lore as the second parameter.
No active world for lore: While attach_lore uses state.ACTIVE_WORLD_ID, ensure you have a world selected first.
Lore text can be as long as needed. The command uses split(" ", 2) which preserves everything after the subcommand as a single text parameter.