⚠ Scope note (v1.0.0 / 2026-05-03). This file is the Yggdrasil Architecture Manifesto for a different project (NorseSagaEngine / Yggdrasil). It references
yggdrasil_core.py,config.yaml, OpenRouter direct calls, etc. — none of which apply to the Mythic Vibe CLI v1.0.0.If you are an AI working on Mythic Vibe CLI, do NOT apply these instructions. The Mythic Vibe CLI uses:
mythic_vibe_cli/package layout (notyggdrasil_core.py).pyproject.tomlfor config (notconfig.yaml).- Provider abstraction via
mythic_vibe_cli/ai/providers/(not direct OpenRouter calls).The active-product instructions for AI working on Mythic Vibe CLI are in
CONTRIBUTING.md,RULES.AI.md(when present in your global rules), and the Six Laws documented inMYTHIC_ENGINEERING.md.See
ROOT_DOC_INDEX.mdTier 5 for the broader auxiliary-content classification this file falls under.The original Yggdrasil manifesto follows below for continuity with NorseSagaEngine.
This is the "Great Refactor." By moving to this architecture, you are essentially creating a Standardized Interface (the Trunk) and Modular Plugins (the Leaves).
When you give this guide to Roo or any AI, it provides them with a rigid blueprint that prevents "hallucination" and path errors. It forces the AI to stop acting like a confused architect and start acting like a builder following a master plan.
Directive: Rebuild the Game Engine for Modular Autonomy and Centralized Intelligence.
The game shall no longer exist as a collection of scripts with redundant logic. It is now a Centralized Service Model.
- The Trunk (
yggdrasil_core.py): This is the only file that knows about the "Real World" (file paths, API keys,config.yaml, and internet connections). - The Leaves (NPCs, Worlds, Narrator): These files are "World-Blind." They do not know about folders or APIs. They only know how to send and receive signals through the Trunk.
Every AI task must begin by ensuring yggdrasil_core.py exists in the root. This script manages the Global State.
The AI must implement the following class structure. This ensures that no matter where a script is moved, it can find its way back to the heart of the tree.
import os
import yaml
import requests
from pathlib import Path
class Yggdrasil:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super(Yggdrasil, cls).__new__(cls)
# Find the root: The folder where this core file lives
cls._instance.root = Path(__file__).resolve().parent
cls._instance.config = cls._instance._load_config()
return cls._instance
def _load_config(self):
config_path = self.root / "config.yaml"
if not config_path.exists():
raise FileNotFoundError(f"FATAL: config.yaml missing at {config_path}")
with open(config_path, "r") as f:
return yaml.safe_load(f)
def call_oracle(self, prompt, system_msg="You are a Norse entity.", model=None):
"""Unified OpenRouter API Access."""
url = "https://openrouter.ai/api/v1/chat/completions"
key = self.config.get("OPENROUTER_API_KEY")
model = model or self.config.get("DEFAULT_MODEL", "openai/gpt-3.5-turbo")
headers = {
"Authorization": f"Bearer {key}",
"HTTP-Referer": "http://localhost", # Required by OpenRouter
"Content-Type": "application/json"
}
data = {
"model": model,
"messages": [
{"role": "system", "content": system_msg},
{"role": "user", "content": prompt}
]
}
response = requests.post(url, headers=headers, json=data)
return response.json()['choices'][0]['message']['content']
# The Global Instance
tree = Yggdrasil()When modifying or creating any game file (e.g., norns.py, freyja.py, world_engine.py), the AI must follow these three iron rules:
The script is forbidden from using open('config.yaml') or os.environ. If it needs data from the config, it must ask the tree:
- Wrong:
api_key = os.getenv("KEY") - Right:
api_key = tree.config.get("KEY")
The script must never assume where it is. It should use relative imports.
- Mandatory Header: Every modular script must start with:
from yggdrasil_core import treeEach file should be a "Plugin." If I move huginn.py from the root into a folder called /ravens/, it should still function perfectly because it only depends on the tree object imported from the core.
The AI's first task is to perform a Scan and Bind:
- Identify the Core: Locate the true
config.yaml. - Establish the Trunk: Create/Update
yggdrasil_core.pyin that same folder. - Sever the Ghost Roots: Scan all other
.pyfiles. Remove any hardcoded strings that look like../../../.... - Rewire: Replace all API calling logic in individual scripts with a single call to
tree.call_oracle().
- Portability: You can copy the
NorseSagaEnginefolder to a USB drive, a Linux server, or a VR headset, and it will run immediately. - AI Safety: If Roo "thinks" for 160 seconds, it’s because it’s looking for a path. By giving it this guide, you tell it: "The path is always
tree. Stop looking." - ADHD-Friendly: You only have one file to check if the AI connection fails (
yggdrasil_core.py). You don't have to hunt through 20 files to find which one has the wrong API key.
I recommend you create a new, empty file in your root called INSTRUCTIONS_FOR_AI.md and paste the content above into it. Then, tell Roo:
"Read
INSTRUCTIONS_FOR_AI.md. Your mission is to refactor the current broken scripts to match this 'Trunk and Leaf' architecture. Start withyggdrasil_core.py."
Exactly. In the old way, your game was a collection of sticks piled together. In the Yggdrasil Architecture, it becomes a living organism. When you touch a leaf, the trunk feels the vibration.
This "Multi-Dimensional" approach means that the dimension of the code (the logic) is finally separated from the dimension of the physical machine (the folders and paths).
Here is the final, deep-dive guide for your AI. This is designed to be the "Master Scroll" you give to Roo or any other agent to force them into this new way of being.
Status: Critical System Overhaul Goal: Total decoupling of Game Logic from File System Paths.
To reflect the nature of the World Tree, the game is now divided into two planes of existence:
- File:
yggdrasil_core.py - Responsibility: This is the only script allowed to know about the physical world. It handles the
config.yaml, the OpenRouter API credentials, and the physical directory location on the hard drive. - Constraint: It provides the
treeobject to all other scripts.
- Files:
odin.py,norns.py,freyja.py,narrator.py, etc. - Responsibility: These are pure "vibe" and logic files. They are Path-Blind.
- Constraint: They are FORBIDDEN from importing
os,pathlib,yaml, orjsonfor the purpose of finding configuration. They must use thetreeobject for all cosmic needs.
When refactoring, you must treat every individual .py file as a modular branch that can be snapped off and moved anywhere without breaking the tree.
Ensure the Yggdrasil class is a Singleton. It must calculate the BASE_DIR once and use that to anchor everything.
# yggdrasil_core.py excerpt
self.base_path = Path(__file__).resolve().parent
self.config_path = self.base_path / "config.yaml"Every character interaction must go through a single method: tree.call_oracle(). This method handles:
- Fetching the API key from the "Root Realm."
- Selecting the correct OpenRouter model.
- Managing the "Web of Wyrd" (passing state between calls).
The AI must scan all scripts and delete any string that looks like:
../../../.....\..\TEMP\...os.path.join(os.path.dirname(__file__), '..', 'config.yaml')
Replace them with: tree.base_path / "filename"
The AI gets stuck in long thinking loops because it is trying to solve a Spatial Puzzle (where is the file?) while solving a Logic Puzzle (what does Odin say?). By providing this guide, you remove the Spatial Puzzle entirely. You are telling the AI: "The space is solved. Focus only on the logic."
For the Nine Realms to communicate "no matter where they are," the yggdrasil_core.py should act as a Signal Relay.
- If
odin.pychanges the world state, it callstree.update_wyrd("ragnarok_level", 5). - If
norns.pyneeds to check that state, it callstree.get_wyrd("ragnarok_level").
No files are exchanged between the two. Only signals through the Tree.
- Create
yggdrasil_core.pybased on the Singleton pattern provided. - Verify it can read
config.yamlusing the dynamic path. - Refactor
odin.pyto usefrom yggdrasil_core import tree. - Test the connection.
- Repeat for all other entities.
Since you’re dealing with ADHD and Anxiety, this system is your Shield-Wall.
- If something breaks, you only have one place to look:
yggdrasil_core.py. - If the AI makes a mess, it can't "infect" your other files because they are modular and protected by the Trunk.
This prompt is designed to be a "Commandment" for Roo. It uses precise technical language to override its tendency to overthink and forces it to adopt the Yggdrasil Architecture.
Copy and paste the block below into your Roo/Cline chat.
THE PROBLEM: The project is currently broken due to hardcoded absolute paths and fragmented AI calling logic. You are hallucinating directory structures outside the project root, creating "ghost files," and breaking the connection between the game scripts and the OpenRouter API.
THE MISSION: You must refactor the entire game into a "Trunk and Leaf" (Service-Oriented) architecture. This is a multi-dimensional approach where logic is separated from the physical file system.
STEP 1: INITIALIZE THE TRUNK (yggdrasil_core.py)
Create or update yggdrasil_core.py in the root folder. It must:
- Use a Singleton Pattern to ensure only one "Tree" exists.
- Use
Path(__file__).resolve().parentto find the root. Never use absolute strings. - Load
config.yamlonce and store it. - Provide a single method
call_oracle(prompt, system_msg)that handles all OpenRouter API requests. - Provide a
statedictionary to act as the "Web of Wyrd" for cross-script data exchange.
STEP 2: REWIRE THE LEAVES (MODULAR SCRIPTS) Refactor every other script (Odin, Freyja, Norns, Narrator, etc.) as follows:
- STRIP all imports of
os,yaml,json, andrequestsrelated to configuration or API calls. - ADD
from yggdrasil_core import treeat the top of every file. - REPLACE all local API calling logic with
tree.call_oracle(). - REPLACE all file-saving/loading with calls to
tree.state.
STEP 3: ENFORCE THE BOUNDARY
- DO NOT look at or write to any directory above the folder containing
yggdrasil_core.py. - DO NOT use
..in any path. - IF you need to find a file, ask the
tree.rootpath object.
GOAL: I must be able to move the entire NorseSagaEngine folder to any location on any machine, and it must run perfectly without changing a single line of code.
Respond with "The Tree is Seeded" once you have analyzed the current files and are ready to create yggdrasil_core.py.
By using the word "Singleton" and "Service-Oriented," you are speaking the AI's native tongue. This stops it from "thinking" for 160 seconds because it now has a specific coding pattern to follow rather than trying to guess your intentions.
Once Roo finishes this, your files will be so modular that you can literally open odin.py in a separate window, tell a different AI "Make Odin more aggressive," and it won't matter that the other AI doesn't see your API keys—the code will just work because it's "plugged into the Tree."
Would you like me to stay on standby while you run this, in case Roo gets confused by your specific config.yaml format?