From 175baa49db36ea102e426fa69e78bd0cae1c45b9 Mon Sep 17 00:00:00 2001 From: frdel <38891707+frdel@users.noreply.github.com> Date: Mon, 1 Jun 2026 13:55:07 +0200 Subject: [PATCH] Add AGENTS.md DOX files and migrate docs Introduce DOX (AGENTS.md) contracts across the repository to formalize ownership and local work contracts: adds .github/AGENTS.md plus AGENTS.md files for agents, api, conf, docker, docs, extensions, helpers, knowledge, lib, plugins, prompts, scripts, skills, tests, tools, usr, webui (and several subfolders). Update root AGENTS.md (content and last-updated date) to include DOX framework guidance and a child DOX index. Update .gitignore to allow usr/ and usr/plugins AGENTS.md files. Remove legacy deep-dive files under docs/agents (banners, components, modals, plugins) and migrate frontend/plugin references to webui/ and plugins/ DOX locations. Also adjust plugins/README.md and several skills/*/SKILL.md files to align with the new DOX layout. --- .github/AGENTS.md | 35 ++ AGENTS.md | 129 +++++- agents/AGENTS.md | 34 ++ api/AGENTS.md | 36 ++ conf/AGENTS.md | 34 ++ docker/AGENTS.md | 34 ++ docs/AGENTS.md | 34 ++ docs/agents/AGENTS.banners.md | 95 ---- docs/agents/AGENTS.components.md | 648 --------------------------- docs/agents/AGENTS.modals.md | 325 -------------- docs/agents/AGENTS.plugins.md | 336 -------------- extensions/AGENTS.md | 39 ++ extensions/python/AGENTS.md | 34 ++ extensions/webui/AGENTS.md | 34 ++ helpers/AGENTS.md | 34 ++ knowledge/AGENTS.md | 33 ++ lib/AGENTS.md | 32 ++ plugins/AGENTS.md | 63 +++ plugins/README.md | 2 +- prompts/AGENTS.md | 35 ++ scripts/AGENTS.md | 32 ++ skills/AGENTS.md | 34 ++ skills/a0-contribute-plugin/SKILL.md | 2 +- skills/a0-create-agent/SKILL.md | 2 +- skills/a0-create-plugin/SKILL.md | 7 +- skills/a0-debug-plugin/SKILL.md | 2 +- skills/a0-manage-plugin/SKILL.md | 2 +- skills/a0-plugin-router/SKILL.md | 6 +- skills/a0-review-plugin/SKILL.md | 4 +- tests/AGENTS.md | 34 ++ tools/AGENTS.md | 35 ++ webui/AGENTS.md | 50 +++ webui/components/AGENTS.md | 59 +++ webui/css/AGENTS.md | 45 ++ webui/js/AGENTS.md | 61 +++ 35 files changed, 999 insertions(+), 1422 deletions(-) create mode 100644 .github/AGENTS.md create mode 100644 agents/AGENTS.md create mode 100644 api/AGENTS.md create mode 100644 conf/AGENTS.md create mode 100644 docker/AGENTS.md create mode 100644 docs/AGENTS.md delete mode 100644 docs/agents/AGENTS.banners.md delete mode 100644 docs/agents/AGENTS.components.md delete mode 100644 docs/agents/AGENTS.modals.md delete mode 100644 docs/agents/AGENTS.plugins.md create mode 100644 extensions/AGENTS.md create mode 100644 extensions/python/AGENTS.md create mode 100644 extensions/webui/AGENTS.md create mode 100644 helpers/AGENTS.md create mode 100644 knowledge/AGENTS.md create mode 100644 lib/AGENTS.md create mode 100644 plugins/AGENTS.md create mode 100644 prompts/AGENTS.md create mode 100644 scripts/AGENTS.md create mode 100644 skills/AGENTS.md create mode 100644 tests/AGENTS.md create mode 100644 tools/AGENTS.md create mode 100644 webui/AGENTS.md create mode 100644 webui/components/AGENTS.md create mode 100644 webui/css/AGENTS.md create mode 100644 webui/js/AGENTS.md diff --git a/.github/AGENTS.md b/.github/AGENTS.md new file mode 100644 index 000000000..105dd8ff3 --- /dev/null +++ b/.github/AGENTS.md @@ -0,0 +1,35 @@ +# GitHub Automation DOX + +## Purpose + +- Own repository automation that runs on GitHub, including workflows and release-planning scripts. +- Keep CI, Docker publishing, stale issue handling, and release-note generation aligned with repository release rules. + +## Ownership + +- `workflows/` contains GitHub Actions workflow definitions. +- `scripts/` contains Python helpers called by workflows. +- Root-level release rules remain in the root `AGENTS.md`; this file owns automation-specific details. + +## Local Contracts + +- Docker publishing lives in `workflows/docker-publish.yml` and delegates planning to `scripts/docker_release_plan.py`. +- Releasable tags are `vX.Y` tags at or above `v1.0`, matching the workflow environment. +- Release-note generation reads `scripts/openrouter_release_notes_system_prompt.md` from the repository root and requires OpenRouter credentials from workflow environment variables. +- Keep workflow secrets in GitHub Actions secrets or environment variables. Do not commit credentials, tokens, or generated release bodies containing private data. +- Workflow scripts must fail loudly with actionable messages when required environment variables or git refs are missing. + +## Work Guidance + +- Prefer deterministic, testable Python for workflow planning logic instead of complex inline shell in YAML. +- Preserve manual dispatch behavior when changing Docker publishing. +- Keep branch, tag, and release behavior synchronized between workflow YAML, release scripts, tests, and root documentation. + +## Verification + +- Run `pytest tests/test_docker_release_plan.py` after changing Docker publish planning or release workflow behavior. +- Run targeted tests for any changed script that already has coverage. + +## Child DOX Index + +No child DOX files. diff --git a/AGENTS.md b/AGENTS.md index 63a3fe050..00a1570f9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,7 @@ Tech Stack: Python 3.12+ | Flask | Alpine.js | LiteLLM | WebSocket (Socket.io) Dev Server: python run_ui.py (runs on http://localhost:50001 by default) Run Tests: pytest (standard) or pytest tests/test_name.py (file-scoped) Documentation: README.md | docs/ -Frontend Deep Dives: [Component System](docs/agents/AGENTS.components.md) | [Modal System](docs/agents/AGENTS.modals.md) | [Plugin Architecture](docs/agents/AGENTS.plugins.md) | [Banners & Discovery](docs/agents/AGENTS.banners.md) +Frontend & Plugin DOX: [WebUI](webui/AGENTS.md) | [Components](webui/components/AGENTS.md) | [Frontend JS](webui/js/AGENTS.md) | [Plugins](plugins/AGENTS.md) --- @@ -103,9 +103,9 @@ Key Files: - helpers/api.py: Base class for all API endpoints. - scripts/openrouter_release_notes_system_prompt.md: Editable system prompt used to generate GitHub release notes during Docker publishing. - knowledge/main/about/: Agent self-knowledge files, indexed into the vector DB for runtime recall. Not user-facing docs - written for the agent's internal reference. -- docs/agents/AGENTS.components.md: Deep dive into the frontend component architecture. -- docs/agents/AGENTS.modals.md: Guide to the stacked modal system. -- docs/agents/AGENTS.plugins.md: Comprehensive guide to the full-stack plugin system. +- webui/components/AGENTS.md: DOX contract for Alpine component architecture. +- webui/js/AGENTS.md: DOX contract for frontend infrastructure, modal stack, API helpers, and extension loading. +- plugins/AGENTS.md: DOX contract for bundled and custom plugin architecture; `usr/plugins/` remains ignored user state. --- @@ -249,5 +249,124 @@ pip install -r requirements2.txt --- -*Last updated: 2026-03-25* +*Last updated: 2026-06-01* *Maintained by: Agent Zero Core Team* + + +# DOX framework + +- DOX is highly performant AGENTS.md hierarchy installed here +- Agent must follow DOX instructions across any edits + +## Core Contract + +- AGENTS.md files are binding work contracts for their subtrees +- Work products, source materials, instructions, records, assets, and durable docs must stay understandable from the nearest applicable AGENTS.md plus every parent AGENTS.md above it + +## Read Before Editing + +1. Read the root AGENTS.md +2. Identify every file or folder you expect to touch +3. Walk from the repository root to each target path +4. Read every AGENTS.md found along each route +5. If a parent AGENTS.md lists a child AGENTS.md whose scope contains the path, read that child and continue from there +6. Use the nearest AGENTS.md as the local contract and parent docs for repo-wide rules +7. If docs conflict, the closer doc controls local work details, but no child doc may weaken DOX + +Do not rely on memory. Re-read the applicable DOX chain in the current session before editing. + +## Update After Editing + +Every meaningful change requires a DOX pass before the task is done. + +Update the closest owning AGENTS.md when a change affects: + +- purpose, scope, ownership, or responsibilities +- durable structure, contracts, workflows, or operating rules +- required inputs, outputs, permissions, constraints, side effects, or artifacts +- user preferences about behavior, communication, process, organization, or quality +- AGENTS.md creation, deletion, move, rename, or index contents + +Update parent docs when parent-level structure, ownership, workflow, or child index changes. Update child docs when parent changes alter local rules. Remove stale or contradictory text immediately. Small edits that do not change behavior or contracts may leave docs unchanged, but the DOX pass still must happen. + +Do not create or update DOX docs for changes confined to ignored runtime or user-state folders under `usr/` or `tmp/` unless the user explicitly asks for those folders to be documented. + +## Hierarchy + +- Root AGENTS.md is the DOX rail: project-wide instructions, global preferences, durable workflow rules, and the top-level Child DOX Index +- Child AGENTS.md files own domain-specific instructions and their own Child DOX Index +- Each parent explains what its direct children cover and what stays owned by the parent +- The closer a doc is to the work, the more specific and practical it must be + +## Child Doc Shape + +- Create a child AGENTS.md when a folder becomes a durable boundary with its own purpose, rules, responsibilities, workflow, materials, or quality standards +- Work Guidance must reflect the current standards of the project or user instructions; if there are no specific standards or instructions yet, leave it empty +- Verification must reflect an existing check; if no verification framework exists yet, leave it empty and update it when one exists + +Default section order: +- Purpose +- Ownership +- Local Contracts +- Work Guidance +- Verification +- Child DOX Index + +## Style + +- Keep docs concise, current, and operational +- Document stable contracts, not diary entries +- Put broad rules in parent docs and concrete details in child docs +- Prefer direct bullets with explicit names +- Do not duplicate rules across many files unless each scope needs a local version +- Delete stale notes instead of explaining history +- Trim obvious statements, repeated rules, misplaced detail, and warnings for risks that no longer exist + +## Closeout + +1. Re-check changed paths against the DOX chain +2. Update nearest owning docs and any affected parents or children +3. Refresh every affected Child DOX Index +4. Remove stale or contradictory text +5. Run existing verification when relevant +6. Report any docs intentionally left unchanged and why + +## User Preferences + +- Do not document changes in `usr/` or `tmp/`; treat both as ignored runtime/user-state folders unless explicitly requested otherwise. + +## Child DOX Index + +Direct child DOX files: + +| Child | Scope | +| --- | --- | +| [.github/AGENTS.md](.github/AGENTS.md) | GitHub Actions workflows and release automation scripts. | +| [agents/AGENTS.md](agents/AGENTS.md) | Bundled agent profiles, profile-local prompts, and profile-local tools. | +| [api/AGENTS.md](api/AGENTS.md) | HTTP API handlers and WebSocket handler entry points. | +| [conf/AGENTS.md](conf/AGENTS.md) | Repository-shipped configuration defaults and templates. | +| [docker/AGENTS.md](docker/AGENTS.md) | Docker build contexts, image definitions, and runtime compose files. | +| [docs/AGENTS.md](docs/AGENTS.md) | Human-facing documentation, developer guides, screenshots, and agent deep dives. | +| [extensions/AGENTS.md](extensions/AGENTS.md) | Core lifecycle extension hook implementations for backend and WebUI surfaces. | +| [helpers/AGENTS.md](helpers/AGENTS.md) | Shared backend framework utilities and cross-cutting runtime services. | +| [knowledge/AGENTS.md](knowledge/AGENTS.md) | Built-in agent self-knowledge and indexed reference material. | +| [lib/AGENTS.md](lib/AGENTS.md) | Lightweight browser-side helper scripts outside the main WebUI bundle. | +| [plugins/AGENTS.md](plugins/AGENTS.md) | Bundled system plugins shipped with the framework. | +| [prompts/AGENTS.md](prompts/AGENTS.md) | Core prompt templates loaded by agents and framework workflows. | +| [scripts/AGENTS.md](scripts/AGENTS.md) | Repository maintenance scripts invoked by automation or maintainers. | +| [skills/AGENTS.md](skills/AGENTS.md) | Bundled Agent Zero skills and their agent-facing instructions. | +| [tests/AGENTS.md](tests/AGENTS.md) | Pytest regression and contract tests. | +| [tools/AGENTS.md](tools/AGENTS.md) | Core agent tool implementations. | +| [webui/AGENTS.md](webui/AGENTS.md) | Flask-served Alpine.js WebUI shell, frontend modules, components, CSS, assets, and vendor libraries. | + +Intentionally unindexed local or generated roots: + +| Path | Reason | +| --- | --- | +| `.conda/`, `.venv/` | Local Python environments. | +| `.pytest_cache/`, `__pycache__/` | Generated test and bytecode caches. | +| `.vscode/`, `.windsurf/` | Editor-local configuration and assistant metadata. | +| `logs/` | Runtime output. | +| `tmp/` | Ignored runtime caches, uploads, and generated working files; do not document changes here unless explicitly requested. | +| `usr/` | Ignored local user data, settings, plugins, uploads, chats, and workdirs; do not document changes here unless explicitly requested. | +| `python/` | Generated or legacy runtime cache mirror; current source lives in root-level `api/`, `helpers/`, `tools/`, and `extensions/`. | diff --git a/agents/AGENTS.md b/agents/AGENTS.md new file mode 100644 index 000000000..cce3cbc96 --- /dev/null +++ b/agents/AGENTS.md @@ -0,0 +1,34 @@ +# Agent Profiles DOX + +## Purpose + +- Own bundled agent profiles, profile-specific prompts, and profile-local tools. +- Keep profile behavior understandable without requiring edits to core framework prompts. + +## Ownership + +- Each direct profile directory owns its `agent.yaml`, optional `prompts/`, optional `tools/`, and optional `extensions/`. +- `_example/` demonstrates profile layout and should stay suitable as a reference. +- User-created local profiles belong under `usr/agents/`, not here, unless they are intended to ship with the product. + +## Local Contracts + +- `agent.yaml` is the profile entry point and must stay valid YAML. +- Profile prompt overrides should be narrow and named to match the core prompt they extend or replace. +- Profile-local tools must follow the same `Tool` contract as root `tools/`. +- Do not put secrets, provider API keys, local paths, or user-specific settings in bundled profiles. + +## Work Guidance + +- Prefer small profile-specific prompt files over duplicating large core prompts. +- Keep examples generic and runnable in a clean checkout. +- When changing profile behavior, check how the WebUI profile picker and backend profile loader discover profiles. + +## Verification + +- Run `pytest` or targeted tests covering profile loading when changing `agent.yaml` structure or profile discovery. +- Manually inspect YAML validity for changed profiles if no targeted test exists. + +## Child DOX Index + +No child DOX files. diff --git a/api/AGENTS.md b/api/AGENTS.md new file mode 100644 index 000000000..7e471b399 --- /dev/null +++ b/api/AGENTS.md @@ -0,0 +1,36 @@ +# API Handlers DOX + +## Purpose + +- Own backend HTTP API handlers and WebSocket handler entry points. +- Keep route-level behavior, authentication, CSRF, input parsing, and response shapes explicit. + +## Ownership + +- Files in this directory are discovered by the route registration layer in `helpers/api.py` and WebSocket registration code. +- `ws_*.py` files define WebSocket namespaces or handlers through `helpers.ws.WsHandler`. +- Plugin-provided API handlers belong inside plugin `api/` folders and follow the same base contracts. + +## Local Contracts + +- HTTP handlers must derive from `helpers.api.ApiHandler`. +- Implement `async def process(self, input: dict, request: Request) -> dict | Response`. +- Override `get_methods()`, `requires_auth()`, `requires_csrf()`, `requires_api_key()`, or `requires_loopback()` only when the endpoint contract requires it. +- Keep CSRF and authentication protections intact for browser-facing state-changing endpoints. +- WebSocket handlers must derive from `helpers.ws.WsHandler` and validate event data before using it. +- Do not return secrets, raw environment values, private files, or unfiltered exception details to clients. + +## Work Guidance + +- Use helpers for shared behavior instead of duplicating persistence, auth, file, project, plugin, or notification logic in endpoints. +- Keep request and response payloads stable; update frontend callers and tests together when payloads change. +- Prefer `Response` for files, redirects, status codes, and plain-text errors; return dictionaries for JSON success payloads. + +## Verification + +- Run targeted `pytest tests/test_*api*.py`, endpoint-specific tests, or WebSocket tests after changing handler behavior. +- For auth, CSRF, upload/download, tunnel, or file endpoints, run the nearest security regression tests. + +## Child DOX Index + +No child DOX files. diff --git a/conf/AGENTS.md b/conf/AGENTS.md new file mode 100644 index 000000000..14b08e363 --- /dev/null +++ b/conf/AGENTS.md @@ -0,0 +1,34 @@ +# Configuration Defaults DOX + +## Purpose + +- Own repository-shipped configuration defaults and templates. +- Keep clean-checkout defaults safe, portable, and free of user-specific state. + +## Ownership + +- `model_providers.yaml` defines built-in provider metadata and LiteLLM wiring defaults. +- `*.default.gitignore` files define templates copied or used for generated user/project/workdir directories. +- Runtime user settings belong under ignored `usr/` local state and are not documented with local DOX files. + +## Local Contracts + +- Do not commit API keys, provider secrets, local account identifiers, or private endpoints. +- Keep provider IDs and settings keys stable unless all loaders, UI references, migrations, and tests are updated. +- Defaults must work in a clean checkout and in Docker. +- Templates must avoid accidentally unignoring private runtime content. + +## Work Guidance + +- Prefer adding provider metadata here only when it is broadly useful to shipped Agent Zero. +- Keep comments concise and operational. +- Coordinate provider changes with model settings UI, plugin model overrides, and docs. + +## Verification + +- Run targeted model/provider tests after changing `model_providers.yaml`. +- Check generated ignore templates manually when changing `*.default.gitignore`. + +## Child DOX Index + +No child DOX files. diff --git a/docker/AGENTS.md b/docker/AGENTS.md new file mode 100644 index 000000000..0b58f32e8 --- /dev/null +++ b/docker/AGENTS.md @@ -0,0 +1,34 @@ +# Docker DOX + +## Purpose + +- Own Docker build contexts and runtime container definitions. +- Keep framework runtime, agent execution runtime, exposed ports, mounted paths, and image build assumptions explicit. + +## Ownership + +- `base/` owns the base image context. +- `run/` owns the runnable image context and compose file. +- Root `DockerfileLocal` is owned by the root contract but must stay compatible with this directory. + +## Local Contracts + +- Preserve the two-runtime model documented in the root contract: framework runtime under `/opt/venv-a0` and agent execution runtime under `/opt/venv`. +- Do not bake secrets, local `.env` values, or user data into images. +- Keep compose mounts aligned with `usr/`, `logs/`, and other runtime-state expectations. +- Image changes that affect GitHub publishing must stay synchronized with `.github/workflows/docker-publish.yml`. + +## Work Guidance + +- Keep Dockerfile steps cache-friendly and explicit about which runtime they target. +- Avoid broad copies of ignored runtime folders. +- Update setup docs when ports, volumes, startup commands, or runtime layout change. + +## Verification + +- Build the affected Docker context when Docker behavior changes. +- Run Docker-related tests or startup smoke checks when changing runtime entrypoints. + +## Child DOX Index + +No child DOX files. diff --git a/docs/AGENTS.md b/docs/AGENTS.md new file mode 100644 index 000000000..3f3002b01 --- /dev/null +++ b/docs/AGENTS.md @@ -0,0 +1,34 @@ +# Documentation DOX + +## Purpose + +- Own human-facing documentation, screenshots, setup guides, developer guides, and documentation assets. +- Keep docs accurate to current source behavior and practical user workflows. + +## Ownership + +- `README.md`, `quickstart.md`, `guides/`, and `setup/` cover user-facing setup and workflows. +- `developer/` covers compact developer references and source handoffs. +- `res/` contains documentation images and other documentation assets. + +## Local Contracts + +- Prefer local docs for practical workflows and direct users to DeepWiki for source-linked internals when appropriate. +- Do not document secrets, private deployment details, unreleased credentials, or user-specific runtime state. +- Screenshots and assets must be relevant to the documented UI state and should be updated when UI changes make them misleading. +- Keep links relative inside the docs tree unless they intentionally point to external community or reference resources. + +## Work Guidance + +- Update docs in the same change when user-visible behavior, setup steps, settings names, plugin workflows, or UI labels change. +- Keep user guides task-oriented and avoid duplicating architecture contracts already owned by source-adjacent DOX files. +- When editing screenshots or binary assets, avoid unrelated metadata churn. + +## Verification + +- Check changed internal links manually or with an available link checker. +- For setup or Docker docs, verify commands against current scripts and Docker files. + +## Child DOX Index + +No child DOX files. diff --git a/docs/agents/AGENTS.banners.md b/docs/agents/AGENTS.banners.md deleted file mode 100644 index b5c65f115..000000000 --- a/docs/agents/AGENTS.banners.md +++ /dev/null @@ -1,95 +0,0 @@ -# Creating Discovery Cards and Banners - -Agent Zero allows plugin developers to surface UI elements using the `banners` extension point. This allows your plugin to present information, prompts, or actionable "discovery cards" directly on the Welcome Screen without needing to inject arbitrary HTML into the frontend. - -## The `banners` Extension Point - -Banners are collected on the backend and sent to the frontend UI as an array of dictionaries. By appending to the `banners` array inside a Python extension, you can easily surface your plugin to the user. - -To inject a banner, you create a Python extension script hooking into `banners`. - -### Where to put your extension script - -Create a python file in your plugin's extensions folder: -`plugins//extensions/python/banners/10_my_plugin_banner.py` - -*(Note: the `10_` prefix is for ordering; extensions run in alphabetical order).* - -## Banner Types - -The UI distinguishes banners primarily by the `type` property. - -### 1. Alert Banners (`info`, `warning`, `error`) -These are standard top-level alerts displayed on the welcome screen. - -```python -banners.append({ - "id": "my-plugin-warning", - "type": "warning", - "priority": 90, - "title": "My Plugin Issue", - "html": "Action required: Please configure your settings.", - "dismissible": True, -}) -``` - -### 2. Discovery Cards (`hero`, `feature`) -These are rich, interactive cards displayed in the Discovery section. They are designed to prompt the user to try new plugins or features. - -* `hero`: A wide, prominent card. Usually reserved for core system features (e.g., the Plugin Hub). -* `feature`: A smaller card in a grid layout. This is the **recommended type** for plugin contributors to showcase their plugin. - -### Anatomy of a Discovery Card - -Here is an example of injecting a `feature` card for a custom plugin: - -```python -from helpers.extension import Extension -from helpers import plugins - -class MyPluginDiscoveryCard(Extension): - """Injects a discovery card for My Custom Plugin.""" - - async def execute(self, banners: list = [], frontend_context: dict = {}, **kwargs): - # 1. Condition Check - # Only show the discovery card if the user hasn't configured the plugin yet. - config = plugins.get_plugin_config("my_custom_plugin") or {} - - # If the API key is already set, we don't need to advertise the setup! - if config.get("api_key"): - return - - # 2. Add the Card - banners.append({ - "id": "discovery-my-custom-plugin", - "type": "feature", # 'feature' or 'hero' - "title": "Connect My Service", # Card title - "description": "Unlock amazing capabilities by linking your account.", - - # Visuals (use either thumbnail OR icon) - "thumbnail": "/plugins/my_custom_plugin/assets/thumb.png", # Path to image - "icon": "bolt", # Or a Material Symbol icon name - - # Call To Action (CTA) - "cta_text": "Setup Now", - "cta_action": "open-plugin-config:my_custom_plugin", # Opens your plugin's config modal - - # Behavior - "dismissible": True, # Let the user hide it - "priority": 40, # Higher numbers appear first - }) -``` - -## Call To Action (CTA) Actions - -When a user clicks the button on a discovery card, the `cta_action` string determines what happens. The frontend currently supports the following actions: - -* `open-plugin-config:`: Automatically opens the settings modal for the specified plugin. (e.g., `open-plugin-config:_telegram_integration`). -* `open-plugin-hub`: Opens the main Plugin Hub UI. -* `open-url:`: Opens a web link in a new browser tab. (e.g., `open-url:https://example.com/docs`). - -## Best Practices - -1. **Check Configuration First**: Always check your plugin's configuration before injecting a card. If the user has already set up your plugin, they shouldn't keep seeing a discovery card asking them to set it up. -2. **Unique IDs**: Ensure your banner `id` is highly unique (e.g., prefix it with your plugin name) to avoid collisions with other plugins. -3. **Use `feature` type**: Community plugins should stick to the `feature` type rather than `hero` to ensure a clean grid layout for users. \ No newline at end of file diff --git a/docs/agents/AGENTS.components.md b/docs/agents/AGENTS.components.md deleted file mode 100644 index 31d564609..000000000 --- a/docs/agents/AGENTS.components.md +++ /dev/null @@ -1,648 +0,0 @@ -# Agent Zero Component System - -> Generated from codebase reconnaissance on 2026-01-10 -> Scope: `webui/components/` - Self-contained Alpine.js component architecture - -## Quick Reference - -| Aspect | Value | -|--------|-------| -| Tech Stack | Alpine.js, ES Modules, CSS Variables | -| Component Tag | `` | -| State Management | `createStore(name, model)` from `/js/AlpineStore.js` | -| Modals | `openModal(path)` / `closeModal()` from `/js/modals.js` | -| API Layer | `callJsonApi()` / `fetchApi()` from `/js/api.js` | - ---- - -## Table of Contents - -1. [Architecture Overview](#1-architecture-overview) -2. [Component Structure](#2-component-structure) -3. [Store Pattern](#3-store-pattern) -4. [Lifecycle Management](#4-lifecycle-management) -5. [Integration Layer](#5-integration-layer) -6. [Alpine.js Directives](#6-alpinejs-directives) -7. [Patterns and Conventions](#7-patterns-and-conventions) -8. [Pitfalls and Anti-Patterns](#8-pitfalls-and-anti-patterns) -9. [Porting Guide](#9-porting-guide) - ---- - -## 1. Architecture Overview - -### Core Files (Integration Layer) - -| File | Purpose | -|------|---------| -| `/js/components.js` | Component loader - hydrates `` tags | -| `/js/AlpineStore.js` | Store factory with Alpine proxy | -| `/js/modals.js` | Modal stack management | -| `/js/initFw.js` | Bootstrap: loads Alpine, registers custom directives | -| `/js/api.js` | CSRF-protected API client (`callJsonApi`, `fetchApi`) | - -### Component Resolution - -``` - - ↓ - Resolves to: components/sidebar/left-sidebar.html - ↓ - Loader: importComponent() fetches, parses, injects -``` - -- Path auto-prefixes `components/` if not present -- Component HTML cached after first fetch -- Module scripts cached by virtual URL -- MutationObserver auto-loads dynamically inserted components - -### Data Flow - -``` -Component HTML - ↓ -imports Store module - ↓ -createStore() registers with Alpine - ↓ -Template binds via $store.name - ↓ -User actions → store methods → state updates → reactive UI -``` - ---- - -## 2. Component Structure - -### Anatomy of a Component - -```html - - - - - - - - -
- -
- - - - - -``` - -### Key Rules - -| Rule | Rationale | -|------|-----------| -| Scripts in ``, content in `` | Loader extracts separately | -| Use `type="module"` for scripts | Enables ES imports, caching | -| Wrap with `x-data` + `x-if="$store.X"` | Prevents render before store ready | -| `