aether-shards/.agent/rules/RULE.md

1.7 KiB

description globs alwaysApply
High-level technical standards, file structure, and testing requirements for the Aether Shards project. src/*.js, test/*.js** true

General Project Standards

Tech Stack

  • Engine: Three.js + Vanilla JavaScript (ES Modules).
  • UI: LitElement (Web Components).
  • State: Custom State Managers (Singletons).
  • Persistence: IndexedDB (via Persistence.js).
  • Testing: @web/test-runner + @esm-bundle/chai + sinon.

File Structure

  • src/core/: The main loop, state management, and input handling.
  • src/grid/: Voxel data structures and rendering logic.
  • src/units/: Entity classes (Explorer, Enemy).
  • src/managers/: Logic controllers (UnitManager, MissionManager).
  • src/systems/: Gameplay logic (TurnSystem, EffectProcessor, AI).
  • src/generation/: Procedural algorithms.
  • src/ui/: LitElement components.
  • assets/data/: JSON definitions (Classes, Items, Missions).

Testing Mandate (TDD)

  1. Test First: All logic must have a corresponding test suite in test/.
  2. Conditions of Acceptance (CoA): Every feature must define CoAs, and tests must explicitely verify them.
  3. Headless WebGL: Tests involving Three.js/WebGL must handle headless contexts (SwiftShader) gracefully or use mocks.
  4. No Global Side Effects: Tests must clean up DOM elements and Three.js resources (dispose()) after execution.

Coding Style

  • Use ES6 Modules (import/export).
  • Lazy load at need, only staticly import if something is needed at load, prior to user interaction.
  • Prefer const over let. No var.
  • Use JSDoc for all public methods and complex algorithms.
  • No Circular Dependencies: Managers should not import GameLoop. GameLoop acts as the orchestrator.