|
| 1 | +# Shadow Objects Framework - Agent Guide |
| 2 | + |
| 3 | +This document provides context and guidelines for AI agents working on the **Shadow Objects Framework**. |
| 4 | + |
| 5 | +## 1. Project Overview |
| 6 | + |
| 7 | +The **Shadow Objects Framework** is a reactive library designed to decouple business logic and state management from the UI rendering layer. It runs application logic "in the dark" (e.g., in a web worker), mirroring the view hierarchy of the application. |
| 8 | + |
| 9 | +**Goal:** Separate concerns by running logic in a separate thread/context from the UI, using a reactive architecture. |
| 10 | + |
| 11 | +## 2. Architecture & Core Concepts |
| 12 | + |
| 13 | +### Entities |
| 14 | +The fundamental unit representing a node in the hierarchy, mirroring a view component (like a DOM element or Web Component). Entities form a tree structure and hold reactive properties that sync with the view. |
| 15 | + |
| 16 | +### Shadow Objects |
| 17 | +Functional units of logic attached to an Entity. They contain state, effects, and business logic. |
| 18 | +- **Lifecycle:** Automatically created/destroyed based on Entity lifecycle and Registry configuration. |
| 19 | +- **Reactivity:** Uses Signals and Effects (via `@spearwolf/signalize`). |
| 20 | + |
| 21 | +### The Kernel |
| 22 | +The brain of the framework. |
| 23 | +- Manages Entity lifecycle (creation, destruction, hierarchy). |
| 24 | +- Orchestrates Shadow Objects instantiation. |
| 25 | +- Handles communication (Message Dispatch) between View (UI) and Shadow World. |
| 26 | + |
| 27 | +### The Registry |
| 28 | +Maps **Tokens** (strings) to **Shadow Object Constructors**. |
| 29 | +- Defines routing rules (composition, conditional routing). |
| 30 | + |
| 31 | +## 3. Monorepo Structure |
| 32 | + |
| 33 | +- **`packages/shadow-objects/`**: The main framework library. Deployment package: `@spearwolf/shadow-objects`. |
| 34 | +- **`packages/shae-offscreen-canvas/`**: An offscreen canvas as custom HTML element based on shadow-objects. |
| 35 | +- **`packages/shadow-objects-testing/`**: Functional tests. |
| 36 | +- **`packages/shadow-objects-e2e/`**: Blackbox / E2E tests. |
| 37 | + |
| 38 | +## 4. Coding Guidelines |
| 39 | + |
| 40 | +### General |
| 41 | +- **Clean Code:** Follow standard clean code principles. Keep functions small, focused, and well-named. |
| 42 | +- **Consistency:** Orient yourself to the existing source code style and patterns. |
| 43 | +- **Language:** Use TypeScript for the core library. |
| 44 | + |
| 45 | +### Documentation |
| 46 | +- **Public API Changes:** If you modify any publicly exported code interface, you **MUST** update: |
| 47 | + 1. The `README.md` in the relevant package. |
| 48 | + 2. The `CHANGELOG.md`. |
| 49 | +- **Language:** Always use **English** for documentation and comments. |
| 50 | +- **Format:** Use **Markdown**. |
| 51 | + |
| 52 | +### Development Workflow |
| 53 | +- **TODOs:** If you add, modify, or delete a TODO comment, run `pnpm make:todo` to update `TODO.md`. |
| 54 | +- **Testing:** |
| 55 | + - Check `packages/shadow-objects-testing/` for functional/integration tests. |
| 56 | + - Check `packages/shadow-objects-e2e/` for end-to-end tests. |
| 57 | + - Any public API change must be tested in E2E if possible. |
| 58 | + |
1 | 59 | <!-- nx configuration start--> |
2 | 60 | <!-- Leave the start & end comments to automatically receive updates. --> |
3 | 61 |
|
|
11 | 69 | - If the user needs help with an Nx configuration or project graph error, use the `nx_workspace` tool to get any errors |
12 | 70 |
|
13 | 71 | <!-- nx configuration end--> |
| 72 | + |
| 73 | +# Generial Context Information for the AI assistent |
| 74 | + |
| 75 | +You are a professional developer advocate from google. |
| 76 | +When you write, you speak in a friendly tone. |
| 77 | +You don’t add extra emojis or em dashes. |
| 78 | +You write to developers as if they are your buddy. |
| 79 | +You are technical and aren’t afraid of including code samples. |
| 80 | +Don’t assume too much knowledge, and include quotable short lines that people could post on social media when they share your content. |
0 commit comments