clovie 0.1.44 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,77 @@
1
+ ---
2
+ description: Build and extend Clovie (static/server) projects — config, factories, APIs, routes, hooks, middleware.
3
+ globs: clovie.config.js,**/clovie.config.*,lib/**/*.js,templates/**/*
4
+ ---
5
+
6
+ # Working with Clovie
7
+
8
+ Clovie is a Node.js static site generator and server framework driven by `clovie.config.js` and `@jucie.io/engine` services.
9
+
10
+ ## Mental model
11
+
12
+ - **`type: 'static'`** — build outputs HTML under `outputDir`; dev server is for preview and live reload.
13
+ - **`type: 'server'`** — HTTP server registers **factories** in order: `hooks` → `middleware` → `api` → generated routes from `views` + `routes`.
14
+ - **Factories** — `api`, `routes` (SSR), `middleware`, and `hooks` accept plain objects/arrays **or** `define*` factory functions from `clovie` (re-exported from `@jucie.io/engine-server`). Factories receive `(useContext, opts)` so handlers can depend on engine context when needed.
15
+
16
+ ## Imports
17
+
18
+ ```javascript
19
+ import {
20
+ defineApi, // alias for defineRoutes; use for semantic clarity on api: []
21
+ defineRoutes,
22
+ defineMiddleware,
23
+ defineHooks,
24
+ } from 'clovie';
25
+ ```
26
+
27
+ `defineApi` and `defineRoutes` are the same function — use whichever reads clearer in your config.
28
+
29
+ ## API routes (`opts.api`)
30
+
31
+ - Items are **engine-server route definitions**: at minimum `method`, `path`, and **`handler`** `(ctx) => ...` using `ctx.respond.json()` / `.html()` / `.text()` / `.file()`.
32
+ - **Prefer factories** when routes need `useContext` (logging, DB, services) or you want to split APIs across modules.
33
+
34
+ ```javascript
35
+ import { defineRoutes } from 'clovie';
36
+
37
+ const adminApi = defineRoutes('admin', (useContext, opts) => {
38
+ const [log] = useContext('log');
39
+ return [
40
+ {
41
+ method: 'GET',
42
+ path: '/ping',
43
+ handler: (ctx) => ctx.respond.json({ ok: true }),
44
+ },
45
+ ];
46
+ });
47
+
48
+ export default {
49
+ type: 'server',
50
+ api: [
51
+ { method: 'GET', path: '/api/health', handler: (ctx) => ctx.respond.json({ status: 'up' }) },
52
+ adminApi,
53
+ ],
54
+ };
55
+ ```
56
+
57
+ You can mix **raw route objects** and **factories** in the same `api` array; Clovie normalizes them before `server.use(...)`.
58
+
59
+ ## SSR routes (`opts.routes`)
60
+
61
+ Same factory pattern applies to `routes` merged with auto-generated view routes: use `defineRoutes` when data or handlers need context.
62
+
63
+ ## Middleware and hooks
64
+
65
+ - **`middleware`**: `defineMiddleware(name, (useContext, opts) => [fn, ...])` or raw Express-style functions when using the Express adapter.
66
+ - **`hooks`**: `defineHooks(name, (useContext, opts) => ({ onRequest, preHandler, ... }))`.
67
+
68
+ ## Docs and CLI
69
+
70
+ - Full options: repository `docs/CONFIGURATION.md`.
71
+ - Bundled agent skill path: run `clovie skills path` from an install that includes the `clovie` package.
72
+
73
+ ## Common mistakes
74
+
75
+ - Using a nonexistent **`action`** field on API routes — use **`handler`** and `ctx.respond.*`.
76
+ - Forgetting **`type: 'server'`** when using `api` / server routes.
77
+ - Assuming factories run at import time — they are invoked with `(useContext, opts)` when the server registers routes.
package/AGENTS.md ADDED
@@ -0,0 +1,239 @@
1
+ # AGENTS — Clovie
2
+
3
+ Instructions for AI agents working with or on Clovie.
4
+
5
+ ## Part A: Using Clovie in your project
6
+
7
+ Clovie is a Node.js static site generator and server framework driven by a single `clovie.config.js` file, built on the `@jucie.io/engine` service architecture.
8
+
9
+ ### Two modes
10
+
11
+ - **`type: 'static'`** — generates static HTML under `outputDir`; dev server is for preview and live reload.
12
+ - **`type: 'server'`** — HTTP server registers factories in order: `hooks` -> `middleware` -> `api` -> view routes + `routes`.
13
+
14
+ ### Imports
15
+
16
+ ```javascript
17
+ import {
18
+ createClovie,
19
+ defineApi, // alias for defineRoutes; use for semantic clarity on api: []
20
+ defineRoutes,
21
+ defineMiddleware,
22
+ defineHooks,
23
+ } from 'clovie';
24
+ ```
25
+
26
+ `defineApi` and `defineRoutes` are the same function.
27
+
28
+ ### API route shape
29
+
30
+ Routes in the `api` array must use `method`, `path`, and `handler`:
31
+
32
+ ```javascript
33
+ {
34
+ method: 'GET',
35
+ path: '/api/status',
36
+ handler: (ctx) => ctx.respond.json({ status: 'ok' })
37
+ }
38
+ ```
39
+
40
+ Response methods on `ctx.respond`: `.json(data, status)`, `.html(html, status)`, `.text(text, status)`, `.file(path, status)`.
41
+
42
+ Request data: `ctx.body` (parsed body), `ctx.query` (query params), `ctx.params` (route params), `ctx.req` (raw request).
43
+
44
+ ### Factories
45
+
46
+ `api`, `routes`, `middleware`, and `hooks` accept plain objects/arrays **or** `define*` factory functions. Factories receive `(useContext, opts)` and are invoked lazily when the server registers routes, not at import time.
47
+
48
+ ```javascript
49
+ import { defineRoutes } from 'clovie';
50
+
51
+ const adminApi = defineRoutes('admin', (useContext, opts) => {
52
+ const [log] = useContext('log');
53
+ return [
54
+ { method: 'GET', path: '/ping', handler: (ctx) => ctx.respond.json({ ok: true }) },
55
+ ];
56
+ });
57
+
58
+ export default {
59
+ type: 'server',
60
+ api: [adminApi],
61
+ };
62
+ ```
63
+
64
+ You can mix raw route objects and factories in the same array.
65
+
66
+ ### CLI commands
67
+
68
+ ```
69
+ clovie create <name> [--template static|server]
70
+ clovie dev # development server with live reload
71
+ clovie build # production build
72
+ clovie serve # production server
73
+ clovie kill --port 3000
74
+ clovie skills show # dump bundled Cursor skill for pasting
75
+ ```
76
+
77
+ ### Common mistakes
78
+
79
+ - Using `action` instead of **`handler`** on API routes.
80
+ - Omitting **`type: 'server'`** when using `api` or server routes.
81
+ - Assuming factories run at import time — they run when the server starts.
82
+
83
+ ### Cursor skill
84
+
85
+ Clovie ships a Cursor skill at `.cursor/skills/clovie.mdc`. Run `clovie skills show` to print it, or copy it into your project's `.cursor/skills/`.
86
+
87
+ ---
88
+
89
+ ## Part B: Contributing to the Clovie source
90
+
91
+ ### Repository layout
92
+
93
+ ```
94
+ clovie/
95
+ ├── lib/ # Core source code
96
+ │ ├── services/ # ServiceProvider implementations
97
+ │ ├── factories/ # defineApi, defineRoutes, defineMiddleware, defineHooks
98
+ │ ├── utils/ # Shared utilities
99
+ │ ├── cli/ # CLI subcommands (e.g. skillsCommand.js)
100
+ │ ├── createClovie.js # Engine factory — wires all services
101
+ │ └── main.js # Package exports
102
+ ├── bin/ # CLI entry point
103
+ │ └── cli.js
104
+ ├── __tests__/ # Vitest test suite
105
+ ├── config/ # Default clovie.config.js fallback
106
+ ├── templates/ # Project templates (static, server)
107
+ ├── scripts/ # Build and publish scripts
108
+ ├── packages/ # Workspaces
109
+ │ ├── docs/ # @clovie/docs — Docusaurus documentation site
110
+ │ └── public/ # @clovie/public — Clovie-built static site
111
+ ├── __dev__/ # Development playground (server mode)
112
+ └── .cursor/skills/ # Bundled Cursor skill (ships with npm)
113
+ ```
114
+
115
+ ### Module format
116
+
117
+ ESM only (`"type": "module"` in package.json). Use `import`/`export` everywhere. Use `import.meta.url` instead of `__dirname`.
118
+
119
+ ### Service architecture
120
+
121
+ All services extend `ServiceProvider` from `@jucie.io/engine`. Each service declares:
122
+
123
+ ```javascript
124
+ import { ServiceProvider } from '@jucie.io/engine';
125
+
126
+ export class MyService extends ServiceProvider {
127
+ static manifest = {
128
+ name: 'Human Readable Name',
129
+ namespace: 'camelCaseKey', // becomes the engine accessor (clovie.camelCaseKey)
130
+ version: '1.0.0',
131
+ dependencies: [OtherService], // installed before this service
132
+ };
133
+
134
+ // Optional — runs once during install
135
+ async initialize(_, config) { }
136
+
137
+ // Optional — reactive read-only properties
138
+ getters() {
139
+ return { prop: () => this.#value };
140
+ }
141
+
142
+ // Required — public API exposed on the engine
143
+ actions(useContext) {
144
+ const [file, log] = useContext('file', 'log');
145
+ return {
146
+ doSomething: async (opts) => { /* ... */ },
147
+ };
148
+ }
149
+ }
150
+ ```
151
+
152
+ **`useContext` idioms:**
153
+ - Positional: `const [file, log] = useContext('file', 'log');` — resolves at action-construction time.
154
+ - Whole context: `const { cache } = useContext();` — returns the full context object.
155
+ - Late-bound: `this.useContext('server')` inside async methods for services that may not be installed yet.
156
+
157
+ Use `#private` fields for internal state.
158
+
159
+ ### Engine wiring (`createClovie`)
160
+
161
+ `createClovie({ optsPath, mode })` builds the engine in this order:
162
+
163
+ 1. `Configurator` — loads and watches `clovie.config.js`
164
+ 2. On `configurator.onReady(opts)`:
165
+ - `Compile` and `Run` (always)
166
+ - `EsBuild` (if `opts.scripts` exists)
167
+ - User `opts.setup(clovie)` hook
168
+ - `Server` (if `type: 'server'` or development mode)
169
+ - `LiveReload` (if development mode)
170
+ - User `opts.services` array
171
+
172
+ The resolved value is the engine instance, not a running server. The CLI calls `clovie.run.build()`, `.serve()`, or `.dev()` to execute.
173
+
174
+ ### Testing
175
+
176
+ - **Framework:** Vitest with `globals: true`.
177
+ - **Test files:** `__tests__/*.test.js`
178
+ - **Fixture configs:** `__tests__/clovie.<area>.config.js` (e.g. `clovie.middleware.config.js`)
179
+ - **Integration pattern:**
180
+
181
+ ```javascript
182
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
183
+ import { createClovie } from '../lib/createClovie.js';
184
+ import path from 'path';
185
+
186
+ const pause = async (ms = 10) => new Promise(resolve => setTimeout(resolve, ms));
187
+
188
+ describe('Feature', () => {
189
+ let clovie = null;
190
+
191
+ beforeEach(async () => {
192
+ clovie = await createClovie({
193
+ optsPath: path.resolve(process.cwd(), '__tests__', 'clovie.config.js'),
194
+ mode: 'production',
195
+ open: false,
196
+ });
197
+ await pause(50);
198
+ });
199
+
200
+ afterEach(async () => {
201
+ if (clovie?.server?.isRunning()) {
202
+ await clovie.server.stop();
203
+ }
204
+ clovie = null;
205
+ });
206
+
207
+ it('should work', async () => {
208
+ expect(clovie.configurator.opts.type).toBe('static');
209
+ });
210
+ });
211
+ ```
212
+
213
+ - Use `port: 0` for dynamic port allocation in HTTP tests.
214
+ - CLI tests use `child_process.spawn` with a `runCli` helper.
215
+
216
+ ### CLI structure (`bin/cli.js`)
217
+
218
+ Command branching order: `skills` -> `kill` -> `create` -> `command-line-args` main flow.
219
+
220
+ Main commands: `build` (production, exits after), `serve` (production, stays alive), `dev`/`watch` (development, stays alive).
221
+
222
+ Legacy aliases: `watch` -> `dev`, `server` -> `serve`.
223
+
224
+ Config resolution: dynamic `import(optsPath)`, fallback to `config/clovie.config.js`.
225
+
226
+ ### Templates
227
+
228
+ `templates/static/` and `templates/server/` are copied verbatim by `clovie create`. The placeholders `{{projectName}}` and `{{clovieVersion}}` are substituted at copy time. Keep these placeholders intact when editing template files.
229
+
230
+ ### Workspaces
231
+
232
+ - **`@clovie/docs`** — Docusaurus 3 site, content in `packages/docs/docs/`
233
+ - **`@clovie/public`** — Clovie static site (marketing/legacy docs surface)
234
+
235
+ Root scripts: `npm run docs:dev`, `npm run docs:build`, `npm run public:dev`, `npm run public:build`.
236
+
237
+ ### Publishing
238
+
239
+ `prepublishOnly` runs `npm test` — regressions block publish. Use `scripts/publish.js` for version bumps and releases. The package ships raw source (no build step for the library itself).
package/README.md CHANGED
@@ -4,6 +4,17 @@
4
4
 
5
5
  A powerful Node.js-based **static site generator** and **full-stack web framework** that bridges the gap between simple static sites and complex web applications. Built on the **@jucie.io/engine** service architecture for maximum flexibility and maintainability.
6
6
 
7
+ ## 📚 Documentation site
8
+
9
+ The docs website uses **Docusaurus** in [`website/`](website/). From the repo root:
10
+
11
+ ```bash
12
+ npm run website:dev # http://localhost:3000
13
+ npm run website:build # output in website/build/
14
+ ```
15
+
16
+ Authoritative markdown for the long-form guide remains [`docs/CONFIGURATION.md`](docs/CONFIGURATION.md); keep [`website/docs/configuration.md`](website/docs/configuration.md) in sync (or add a copy script). The older Clovie-built docs under [`docs/`](docs/) (`clovie.config.js`, `views/`) are optional legacy.
17
+
7
18
  ## 🚀 Quick Start
8
19
 
9
20
  ```bash
@@ -32,6 +43,14 @@ npm run dev
32
43
 
33
44
  Clovie uses a **service-oriented architecture** built on `@jucie.io/engine`. All functionality is provided by services that extend `ServiceProvider`, orchestrated through dependency injection with reactive state management.
34
45
 
46
+ ### Route factories (`api`, `routes`, `middleware`, `hooks`)
47
+
48
+ In **server** mode, HTTP behavior is registered through **factory definitions** from `@jucie.io/engine-server` (import `defineRoutes`, `defineApi`, `defineMiddleware`, and `defineHooks` from `clovie`). You can pass plain route objects or factories; factories receive `(useContext, opts)` so APIs and SSR routes can resolve engine services when the server starts. Registration order is **hooks → middleware → `api` → view and config routes**. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#factories-for-api-routes-middleware-and-hooks).
49
+
50
+ ### Cursor / AI agents
51
+
52
+ The npm package ships a Cursor skill at `.cursor/skills/clovie.mdc`. After installing Clovie, run **`clovie skills path`** to print its absolute path, **`clovie skills show`** to dump the file for pasting into a project, or copy that file into your repo’s `.cursor/skills/` so assistants load it automatically.
53
+
35
54
  ### Core Services
36
55
 
37
56
  - **🗂️ File** - File system operations with intelligent watching
package/bin/cli.js CHANGED
@@ -15,6 +15,13 @@ const CLOVIE_VERSION = packageJson.version;
15
15
  // Local - import from compiled dist for published package
16
16
  import { createClovie } from "../lib/createClovie.js";
17
17
  import { killPort, checkPorts, killCommonPorts } from "../scripts/killPort.js";
18
+ import { runSkillsCommand } from "../lib/cli/skillsCommand.js";
19
+
20
+ // Bundled Cursor skill / agent docs (`clovie skills`, `clovie skills path`, …)
21
+ if (process.argv[2] === 'skills') {
22
+ await runSkillsCommand(process.argv.slice(3));
23
+ process.exit(typeof process.exitCode === 'number' && process.exitCode !== 0 ? process.exitCode : 0);
24
+ }
18
25
 
19
26
  // Check for kill command first (before any argument parsing)
20
27
  if (process.argv.includes('kill')) {
@@ -335,7 +342,7 @@ async function executeCommand(clovie, command, options) {
335
342
 
336
343
  default:
337
344
  console.error(`❌ Unknown command: ${command}`);
338
- console.error('Available commands: build, serve, dev, watch');
345
+ console.error('Available commands: build, serve, dev, watch, skills');
339
346
  process.exit(1);
340
347
  }
341
348
  }
@@ -0,0 +1,59 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+ import { readFileSync, existsSync } from 'fs';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
7
+
8
+ /** Root of the published clovie package (parent of lib/). */
9
+ export function getCloviePackageRoot() {
10
+ return path.resolve(__dirname, '..', '..');
11
+ }
12
+
13
+ export function getBundledSkillPath() {
14
+ return path.join(getCloviePackageRoot(), '.cursor', 'skills', 'clovie.mdc');
15
+ }
16
+
17
+ /**
18
+ * @param {string[]} args Arguments after `clovie skills`
19
+ */
20
+ export async function runSkillsCommand(args) {
21
+ const skillPath = getBundledSkillPath();
22
+
23
+ if (args.includes('--help') || args.includes('-h')) {
24
+ printSkillsUsage(skillPath);
25
+ return;
26
+ }
27
+
28
+ if (args[0] === 'path' || args.includes('--path')) {
29
+ console.log(skillPath);
30
+ return;
31
+ }
32
+
33
+ if (args[0] === 'show' || args.includes('--show')) {
34
+ if (!existsSync(skillPath)) {
35
+ console.error(`Bundled skill file not found at:\n ${skillPath}`);
36
+ process.exitCode = 1;
37
+ return;
38
+ }
39
+ process.stdout.write(readFileSync(skillPath, 'utf8'));
40
+ return;
41
+ }
42
+
43
+ printSkillsUsage(skillPath);
44
+ }
45
+
46
+ function printSkillsUsage(skillPath) {
47
+ console.log('Clovie — bundled Cursor skill for AI agents');
48
+ console.log('');
49
+ console.log('Bundled skill file:');
50
+ console.log(` ${skillPath}`);
51
+ console.log('');
52
+ console.log('Commands:');
53
+ console.log(' clovie skills Show this help and the skill path');
54
+ console.log(' clovie skills path Print only the absolute path (for scripts)');
55
+ console.log(' clovie skills show Print the full skill file to stdout');
56
+ console.log('');
57
+ console.log('Best practice for agents: copy or symlink the file into your project under');
58
+ console.log(' .cursor/skills/ so Cursor loads it automatically, or paste `clovie skills show`.');
59
+ }
@@ -5,7 +5,7 @@ import { Run } from './services/Run.js';
5
5
  import { Configurator } from './services/Configurator.js';
6
6
  import { transformConfig } from './utils/transformConfig.js';
7
7
  import { Server } from '@jucie.io/engine-server';
8
- import { EsBuildCompiler } from '@jucie.io/engine-esbuild';
8
+ import { EsBuild } from '@jucie.io/engine-esbuild';
9
9
  import { LiveReload } from './services/LiveReload.js';
10
10
 
11
11
  export const createClovie = async (config = {}) => {
@@ -24,7 +24,7 @@ export const createClovie = async (config = {}) => {
24
24
  clovie.install(Run)
25
25
 
26
26
  if (opts.scripts) {
27
- clovie.install(EsBuildCompiler.configure({
27
+ clovie.install(EsBuild.configure({
28
28
  entryPoints: [`${opts.scripts}/**/*.js`],
29
29
  outdir: opts.outputDir,
30
30
  outbase: opts.scripts,
@@ -65,23 +65,23 @@ export class Compile extends ServiceProvider {
65
65
  return;
66
66
  }
67
67
 
68
- const esbuildCompiler = useContext('esbuildCompiler');
69
- if (!esbuildCompiler) {
68
+ const esBuild = useContext('esBuild');
69
+ if (!esBuild) {
70
70
  log.warn('No esbuild compiler available for scripts');
71
71
  return;
72
72
  }
73
73
 
74
74
  log.info('Compiling scripts...');
75
- await esbuildCompiler.build();
75
+ await esBuild.build();
76
76
  log.info('Scripts compiled');
77
77
  },
78
78
  watchScripts: async (opts) => {
79
79
  if (!opts.scripts) return;
80
80
 
81
- const esbuildCompiler = useContext('esbuildCompiler');
82
- if (!esbuildCompiler) return;
81
+ const esBuild = useContext('esBuild');
82
+ if (!esBuild) return;
83
83
 
84
- await esbuildCompiler.watch();
84
+ await esBuild.watch();
85
85
  },
86
86
  styles: async (opts) => {
87
87
  if (!opts.styles) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clovie",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Vintage web dev tooling with modern quality of life",
5
5
  "keywords": [
6
6
  "static-site-generator",
@@ -50,6 +50,8 @@
50
50
  "scripts/**/*",
51
51
  "config/**/*",
52
52
  "templates/**/*",
53
+ ".cursor/skills/**/*",
54
+ "AGENTS.md",
53
55
  "README.md",
54
56
  "LICENSE"
55
57
  ],
@@ -62,9 +64,13 @@
62
64
  "kill:3000": "node ./bin/kill-port.js 3000",
63
65
  "kill:common": "node ./bin/kill-port.js --common",
64
66
  "kill:check": "node ./bin/kill-port.js --check",
65
- "docs:build": "cd docs && npm install && npm run build",
66
- "docs:dev": "cd docs && npm install && npm run dev",
67
- "docs:serve": "cd docs && npm install && npm run serve",
67
+ "public:build": " npm run -w @clovie/public build",
68
+ "public:dev": "npm run -w @clovie/public dev",
69
+ "public:serve": "npm run -w @clovie/public serve",
70
+ "docs:dev": "npm run -w @clovie/docs dev",
71
+ "docs:build": "npm run -w @clovie/docs build",
72
+ "docs:serve": "npm run -w @clovie/docs serve",
73
+ "docs:start": "npm run -w @clovie/docs start",
68
74
  "prepublishOnly": "npm test",
69
75
  "publish:test": "node scripts/publish.js test",
70
76
  "publish:docs": "node scripts/publish.js docs",
@@ -74,13 +80,14 @@
74
80
  "publish:major": "node scripts/publish.js major",
75
81
  "publish:beta": "node scripts/publish.js beta",
76
82
  "publish:do": "node scripts/publish.js do",
77
- "publish:info": "node scripts/publish.js info"
83
+ "publish:info": "node scripts/publish.js info",
84
+ "update:jucie.io": "npx npm-check-updates '@jucie.io/*' --target latest -u && npm install"
78
85
  },
79
86
  "dependencies": {
80
87
  "@jucie.io/engine": "^1.1.68",
81
- "@jucie.io/engine-esbuild": "^1.0.2",
88
+ "@jucie.io/engine-esbuild": "^1.0.7",
82
89
  "@jucie.io/engine-server": "^1.0.26",
83
- "@jucie.io/reactive": "^1.0.26",
90
+ "@jucie.io/reactive": "^1.0.30",
84
91
  "chalk": "^5.6.2",
85
92
  "chokidar": "^3.5.3",
86
93
  "cli-progress": "^3.12.0",
@@ -109,6 +116,9 @@
109
116
  "type-detect": "^4.0.8",
110
117
  "vitest": "^1.0.4"
111
118
  },
119
+ "workspaces": [
120
+ "packages/*"
121
+ ],
112
122
  "engines": {
113
123
  "node": ">=18.0.0"
114
124
  }
@@ -72,8 +72,8 @@ function showPublishInfo() {
72
72
  }
73
73
 
74
74
  function buildDocs() {
75
- console.log('\n📚 Building documentation...');
76
- run('npm run docs:build');
75
+ console.log('\n📚 Building documentation (Docusaurus)...');
76
+ run('npm run website:build');
77
77
  }
78
78
 
79
79
  function main() {
@@ -1,11 +1,20 @@
1
1
  # AI Development Guide for Clovie Server Projects
2
2
 
3
- > **For AI Assistants**: This document explains how to work with Clovie server applications. Read this to understand the project structure, configuration, and development patterns.
3
+ > **For AI Assistants**: This document explains how to work with Clovie server applications. Read this to understand the project structure, configuration, and development patterns. For Cursor, you can also install `clovie` and run **`clovie skills show`** to paste the bundled project skill, or copy `node_modules/clovie/.cursor/skills/clovie.mdc` into `.cursor/skills/`.
4
4
 
5
5
  ## What is Clovie Server Mode?
6
6
 
7
7
  Clovie Server Mode creates full-stack web applications with Express-like functionality, API endpoints, and server-side rendering. It's built on a service-oriented architecture using `@jucie.io/engine`.
8
8
 
9
+ ## Factories (`api`, `routes`, `middleware`, `hooks`)
10
+
11
+ Prefer **`defineRoutes`** / **`defineApi`** (same function), **`defineMiddleware`**, and **`defineHooks`** from `clovie` when:
12
+
13
+ - Handlers need **`useContext`** (e.g. `log`, file service) at registration time.
14
+ - You split APIs across files and export small factory modules.
15
+
16
+ `api` and `routes` accept **plain objects**, **arrays**, **one factory**, or **arrays mixing factories and raw routes**; the engine normalizes them before `server.use(...)`. Registration order: **hooks → middleware → api → SSR routes (views + `routes`)**. See the upstream [CONFIGURATION.md](https://github.com/adrianjonmiller/clovie/blob/main/docs/CONFIGURATION.md) section *Factories for api, routes, middleware, and hooks*.
17
+
9
18
  ## Project Structure
10
19
 
11
20
  ```