# AGENTS.md Harmonia is a modern UI component library for [Alpine.js](https://alpinejs.dev/), built with Tailwind CSS v4 and bundled with esbuild. ## Commands - **Build library**: `npm run build` runs esbuild bundles, then the Tailwind CLI, then copies dist into the docs site. `npm run build:prod` skips the doc copy. - **Tailwind only**: `npm run tailwind` (one-shot) / `npm run tailwind:watch`. - **Tests**: `npm test` (vitest run), `npm run test:watch`, `npm run test:coverage`. - **Single test file**: `npx vitest run tests/components/accordion.test.js`. Single test by name: `npx vitest run -t "name substring"`. - **Lint / format**: `npm run lint` / `npm run lint:fix`; `npm run format` / `npm run format:check`. - **Docs** (VitePress): first run `npm run docs:install`, then **rebuild the library** (`npm run build`) so the freshly built dist is copied into the docs site, then `npm run docs:dev` (live) or `docs:build` + `docs:preview`. ## Architecture - **Component = Alpine plugin.** Each file in `src/components/*.js` default-exports `function (Alpine) { ... }` registering one or more `Alpine.directive('h-', ...)` directives. New components must be wired into **both** `src/index.js` (browser/CDN build, calls `Alpine.plugin(...)`) and `src/module.js` (ESM build: named `XxxComponent` export + a line in `registerComponents`). Forgetting one silently breaks that build target. A new component must also be added to the theme generator (see the "Keep the theme generator in sync" convention). - **Two build entry points / four bundles** (`scripts/build.cjs`): `src/index.js` → `harmonia.js` / `.min.js` (browser, `CDN:true`, auto-registers on the `alpine:init` event); `src/module.js` → `harmonia.esm.js` / `.min.js` (neutral platform, for consumers who register components manually). - **Opt-in plugins** live in `src/plugins/*` and must NOT load by default. Pattern (see `src/plugins/lucide.js`): the plugin file default-exports the `function (Alpine) {...}`; a dedicated browser entry (`src/lucide.js`) self-registers it on `alpine:init` and gets its own `scripts/build.cjs` bundle (e.g. `dist/harmonia-lucide.js` / `.min.js`) that CDN users add as an extra `