prunelle 0.1.1 → 0.6.0

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.
Files changed (120) hide show
  1. package/llms.txt +130 -38
  2. package/package.json +8 -2
  3. package/src/a11y/declaration.ts +335 -0
  4. package/src/a11y/index.ts +446 -0
  5. package/src/a11y/rgaa-map.ts +184 -0
  6. package/src/attrs.ts +11 -3
  7. package/src/build/bundle.ts +80 -36
  8. package/src/build/client-entries.ts +3 -2
  9. package/src/build/client-plugin.ts +8 -4
  10. package/src/build/client-prune.ts +56 -6
  11. package/src/build/compile.ts +11 -9
  12. package/src/build/ecoindex.ts +229 -0
  13. package/src/build/index.ts +174 -108
  14. package/src/build/islands.ts +2 -2
  15. package/src/build/manifest.ts +66 -5
  16. package/src/build/output.ts +2 -2
  17. package/src/build/plugin-host.ts +92 -33
  18. package/src/build/precompress.ts +15 -2
  19. package/src/build/prerender.ts +128 -46
  20. package/src/build/report.ts +23 -2
  21. package/src/build/resolve.ts +8 -6
  22. package/src/build/routes.ts +175 -10
  23. package/src/build/static.ts +137 -39
  24. package/src/build/status-pages.ts +127 -0
  25. package/src/build/style-bundles.ts +526 -0
  26. package/src/cli/check-forms.ts +561 -0
  27. package/src/cli/check-links.ts +632 -0
  28. package/src/cli/check.ts +75 -20
  29. package/src/cli/commands.ts +85 -4
  30. package/src/cli/docs.ts +402 -0
  31. package/src/cli/inspect.ts +103 -14
  32. package/src/cli/mcp-tools.ts +490 -0
  33. package/src/cli/mcp.ts +205 -0
  34. package/src/cli/new.ts +2 -2
  35. package/src/cli/render.ts +421 -0
  36. package/src/cli/upgrade-names.ts +73 -13
  37. package/src/cli/upgrade.ts +137 -16
  38. package/src/compiler/analyze.ts +42 -9
  39. package/src/compiler/browser-globals.ts +140 -17
  40. package/src/compiler/cacheability.ts +636 -0
  41. package/src/compiler/compliance-rgaa.ts +508 -0
  42. package/src/compiler/compliance.ts +241 -289
  43. package/src/compiler/data-keys.ts +199 -192
  44. package/src/compiler/dev-source.ts +87 -0
  45. package/src/compiler/dom-attrs.ts +138 -65
  46. package/src/compiler/dom.ts +517 -442
  47. package/src/compiler/expr-context.ts +167 -57
  48. package/src/compiler/mistakes.ts +4 -1
  49. package/src/compiler/props.ts +87 -36
  50. package/src/compiler/scope.ts +400 -333
  51. package/src/compiler/server-only.ts +190 -151
  52. package/src/compiler/shared.ts +40 -12
  53. package/src/compiler/signal-reads.ts +6 -2
  54. package/src/compiler/ssr-prunelle-tags.ts +27 -14
  55. package/src/compiler/ssr.ts +218 -87
  56. package/src/dev/error-log.ts +151 -0
  57. package/src/dev/index.ts +84 -34
  58. package/src/dev/open-editor.ts +204 -0
  59. package/src/dev/protocol.ts +1 -0
  60. package/src/dev/reload.ts +5 -3
  61. package/src/dev/supervisor.ts +42 -25
  62. package/src/dev/watchers.ts +47 -11
  63. package/src/dom/action.ts +43 -20
  64. package/src/dom/attrs.ts +15 -3
  65. package/src/dom/extras.ts +28 -12
  66. package/src/dom/index.ts +26 -8
  67. package/src/dom/island.ts +35 -28
  68. package/src/dom/loop.ts +10 -9
  69. package/src/plugins/config.ts +8 -7
  70. package/src/plugins/index.ts +2 -2
  71. package/src/plugins/load.ts +26 -7
  72. package/src/plugins/order.ts +38 -1
  73. package/src/plugins/public.ts +5 -2
  74. package/src/plugins/services.ts +81 -0
  75. package/src/plugins/types.ts +34 -0
  76. package/src/reactivity/graph.ts +10 -0
  77. package/src/reactivity/index.ts +24 -16
  78. package/src/reactivity/selector.ts +31 -4
  79. package/src/reactivity/store.ts +45 -13
  80. package/src/server/action-protect.ts +198 -0
  81. package/src/server/action-registry.ts +1 -1
  82. package/src/server/action.ts +82 -27
  83. package/src/server/assets.ts +34 -2
  84. package/src/server/compress.ts +91 -9
  85. package/src/server/document.ts +25 -10
  86. package/src/server/errors.ts +303 -65
  87. package/src/server/form-schema.ts +343 -0
  88. package/src/server/health.ts +244 -0
  89. package/src/server/http.ts +131 -32
  90. package/src/server/index.ts +231 -261
  91. package/src/server/loader.ts +5 -0
  92. package/src/server/param-matchers.ts +112 -0
  93. package/src/server/plugin-host.ts +123 -88
  94. package/src/server/public.ts +3 -3
  95. package/src/server/rate-limit.ts +58 -35
  96. package/src/server/request-body.ts +1 -1
  97. package/src/server/route-cache.ts +423 -0
  98. package/src/server/route-table.ts +339 -8
  99. package/src/server/router.ts +125 -40
  100. package/src/server/routing.ts +196 -63
  101. package/src/server/security.ts +208 -32
  102. package/src/server/serve-handlers.ts +21 -7
  103. package/src/server/start.ts +60 -16
  104. package/src/server/static-dir.ts +61 -8
  105. package/src/server/stream.ts +41 -22
  106. package/src/ssr/context.ts +85 -3
  107. package/src/ssr/index.ts +130 -3
  108. package/src/ssr/region.ts +31 -19
  109. package/src/test/browser.ts +28 -13
  110. package/src/test/index.ts +97 -12
  111. package/src/ts-plugin/diagnostics.ts +505 -0
  112. package/src/ts-plugin/fixes.ts +364 -0
  113. package/src/ts-plugin/index.ts +194 -0
  114. package/templates/_shared/AGENTS.md +2 -2
  115. package/templates/_shared/mcp.json +11 -0
  116. package/templates/_shared/src/routes/legal.tsx +5 -0
  117. package/templates/_shared/tsconfig.json +5 -0
  118. package/templates/blog/prunelle.config.ts +1 -1
  119. package/templates/blog/src/routes/index.tsx +4 -0
  120. package/ts-plugin.cjs +4277 -0
package/llms.txt CHANGED
@@ -1,49 +1,141 @@
1
1
  # Prunelle Reference (for humans & coding agents)
2
2
 
3
- > Prunelle is a Bun-native TSX web framework with zero-directive automatic islands, `.value` fine-grained signals, flat-string SSR, unified Standard-Schema actions, single-binary `--compile`, and a composable `PrunellePlugin` API.
4
-
5
- ## Core Rules (everything fits on one page)
6
-
7
- - **Imports**: `prunelle` (signals, `Head`, `Suspense`, `Catch`, `Region`, `ConsentGate`, `createContext`, `provideContext`, `useContext`, `useId`, `useAction`), `prunelle/server` (`action`, `getActionError`, `notFound`, `defineEnv`, `nodeEnv`, `raw`, `esc`, `escAttr`, `escJson` (JSON text for a `<script>`), `getClientIp`, `isHttpsRequest`, `isTrustedOrigin`, `verifyOrigin`, `safeRedirect`, `safeEqual` (constant-time secret compare), `wantsJson`, `readStringFields` (a body's string fields, on a null-prototype record), `createRateLimitStore({ maxKeys?, maxHits? })` (a standalone sliding-window store: `.limiter({ max, windowMs }).hit(key)` returns 0 or the seconds to wait; plugins use `api.rateLimiter()`), `validateSchema`, `validateSchemaSync`, `formatSchemaIssues`, `formatIssuePath`, route types, `createServer({ root })` to run a built app inside another program), `prunelle/config` (`defineConfig`, `definePlugin`, `serviceKey`, `isInside(dir, target, { orSame })`, plugin types), `prunelle/test` (`testApp`, `testBrowser`). An `@kayjs/*` import, prunelle's name when it was kay v2, fails the compile (`prunelle upgrade` rewrites them); `prunelle/internal/*` is compiler output, outside semver.
8
- - **Standard TSX & compiler guardrails**: `.tsx` files with `jsxImportSource: "prunelle"`. Use `class` or `className` (never both). Standard `.map()` (with `key={...}`), `&&`, ternaries, `{...spread}`, SVG elements, style strings or objects (`style={{ color: 'red' }}`), and CSS / `*.module.css` imports work natively. Compiler/runtime refuse common React/Solid/Astro habits: `innerHTML={html}` takes a string or `raw(html)` (never `{ __html }`, never `dangerouslySetInnerHTML`, never on void elements or with children); events are camelCase DOM names (`onClick`, `onDblClick`, `onKeyDown` — never lowercase `onclick`, `on:click`, `onDoubleClick`, `*Capture`, string handlers, or render-time assignments); `ref` is always a callback `ref={el => ...}` (never `{ current }`); SVG attrs use kebab-case (`stroke-width`, `fill-opacity`); entities in string attrs and props decode like text (`title="a &amp; b"` is `a & b`; an `innerHTML` string stays as written); use `value`/`checked` (not `defaultValue`/`defaultChecked`) and boolean `{false}` (not `"false"`); no `client:*`/`use:*`/`class:list`/`set:html` directives and no `'use client'`/`'use server'`; no Promises, functions, signals, or plain objects in JSX text/attrs. Spreads drop `on*`, `innerHTML`, `srcdoc`, and `javascript:`/`vbscript:` URLs.
9
- - **Signals, Context & IDs (`prunelle`)**: `const count = signal(0)` (`.value` read/write, `.peek()` untracked), `computed(() => ...)`, `effect(() => ...)` (return cleanup, never `async`; skipped while an island renders on the server, so derive values with `computed`; a local signal read without `.value` in JSX, an `if`/ternary/loop test or `!`, and `const { value } = count`, fail compile), `batch(() => ...)`, `untrack(() => ...)`, `root(dispose => ...)`, `onMount(() => ...)` (runs after DOM attach; return cleanup), `onCleanup(() => ...)`, `getOwner()`, `selector(() => id.value)` (O(1) selection), `store(obj)` + `snapshot(s)`. Context: `const Ctx = createContext(defaultValue)`, `<Ctx.Provider value={v}>` or `provideContext(Ctx, v, fn)`, `useContext(Ctx)`. Deterministic hydration-safe IDs: `useId(prefix = 'k')` (scoped per island or SSR request). To let a child mutate parent state, pass the signal directly (`<Modal open={isOpen} />`).
3
+ > Prunelle is a Bun-native TSX web framework with zero-directive automatic islands, `.value` fine-grained signals, flat-string SSR, unified Standard-Schema actions, single-binary `--compile`, and a composable `PrunellePlugin` API. Each first-party plugin ships its own reference at `node_modules/@prunellejs/<name>/llms.txt`.
4
+
5
+ ## Core Rules
6
+
7
+ - **Imports**:
8
+ - `prunelle`: signals, `Head`, `Suspense`, `Catch`, `Region`, `ConsentGate`, `createContext`, `provideContext`, `useContext`, `useId`, `useAction`.
9
+ - `prunelle/server`: `action`, `getActionError`, `notFound`, route types, `DEFAULT_CSP`, `extendCsp`, and the Server helpers below.
10
+ - `prunelle/config`: `defineConfig`, `definePlugin`, `serviceKey`, `I18N_CONFIG_SERVICE`, `CONTENT_IMAGE_RESOLVER_SERVICE`, `CONTENT_COLLECTIONS_SERVICE`, `JOBS_SERVICE`, `WEB_MANIFEST_SERVICE`, `isInside(dir, target, { orSame })`, `firstLoadUrls`, `distLocator`, `measureFirstLoad`, `brotliSize`, `minifyCss`, `a11y`, `auditAccessibility`, `draftAccessibilityStatement`, `formatA11yReport`, `rgaaCriteriaForAxeRule`, plugin types.
11
+ - `prunelle/build` (programmatic `build`, `createBuildCache`, `analyzeBundleWeights`, `computeEcoIndex`), `prunelle/test` (`testApp`, `testBrowser`), `prunelle/ts-plugin` (TS language-service plugin).
12
+ - An `@kayjs/*` import, prunelle's name when it was kay v2, fails the compile (`prunelle upgrade` rewrites them); `prunelle/internal/*` is compiler output, outside semver.
13
+ - **Standard TSX & compiler guardrails**: `.tsx` files with `jsxImportSource: "prunelle"`. The compiler and runtime refuse React/Solid/Astro habits.
14
+ - Works natively: `class` or `className` (never both), `.map()` with `key={...}`, `&&`, ternaries, `{...spread}`, SVG elements, style strings or objects (`style={{ color: 'red' }}`), CSS and `*.module.css` imports.
15
+ - `innerHTML={html}` takes a string or `raw(html)`: never `{ __html }`, never `dangerouslySetInnerHTML`, never on void elements or with children.
16
+ - Events are camelCase DOM names (`onClick`, `onDblClick`, `onKeyDown`), never lowercase `onclick`, `on:click`, `onDoubleClick`, `*Capture`, string handlers or render-time assignments. `onChange` on a text `<input>`/`<textarea>` fires on blur and warns to use `onInput` for every keystroke; `onFocus`/`onBlur` do not bubble, use `onFocusIn`/`onFocusOut`.
17
+ - `ref` is always a callback `ref={el => ...}`, never `{ current }`. SVG attributes are kebab-case (`stroke-width`, `fill-opacity`). Entities in string attrs and props decode like text (`title="a &amp; b"` is `a & b`; an `innerHTML` string stays as written). Use `value`/`checked` (not `defaultValue`/`defaultChecked`) and boolean `{false}` (not `"false"`).
18
+ - Refused: `client:*`/`use:*`/`class:list`/`set:html` directives, `'use client'`/`'use server'`, and Promises, functions, signals or plain objects in JSX text/attrs.
19
+ - Literal `javascript:`/`vbscript:`/non-image `data:` URLs warn and are stripped; spreads drop `on*`, `innerHTML`, `srcdoc` and `javascript:`/`vbscript:` URLs.
20
+ - **Signals, Context & IDs (`prunelle`)**:
21
+ - `const count = signal(0)` (`.value` read/write, `.peek()` untracked), `computed(() => ...)`, `effect(() => ...)` (return cleanup, never `async`; skipped while an island renders on the server, so derive values with `computed`), `batch(() => ...)`, `untrack(() => ...)`, `root(dispose => ...)`, `onMount(() => ...)` (runs after DOM attach; return cleanup), `onCleanup(() => ...)`, `getOwner()`, `selector(() => id.value)` (O(1) selection), `store(obj)` + `snapshot(s)`.
22
+ - A local signal read without `.value` in JSX, an `if`/ternary/loop test or `!`, and `const { value } = count`, fail compile. To let a child mutate parent state, pass the signal itself (`<Modal open={isOpen} />`).
23
+ - Context: `const Ctx = createContext(defaultValue)`, `<Ctx.Provider value={v}>` or `provideContext(Ctx, v, fn)`, `useContext(Ctx)`. `useId(prefix = 'k')` gives deterministic hydration-safe IDs, scoped per island or SSR request.
10
24
  - **Reactive props**: Destructuring props (`function Badge({ count = 0, ...rest }: Props)`) stays reactive in client components, and a default beyond a literal or a name (`items = []`, `id = useId()`) runs once per call; server-rendered children inside islands are preserved via `<pru-slot>`.
11
- - **Automatic islands**: Any component using reactive primitives (`signal`, `computed`, `effect`, `onMount`, `store`, `selector`), DOM `on*` handlers/`ref`, or imported reactive module state becomes an island automatically, decided per component: a static export beside an island stays static, a component that needs the browser is an island of its own wherever server code renders it as a tag, same file included (the page around it stays static; its chunk keeps only the code of the file it reaches, so an async page importing server code can render a local widget; its props cross the island boundary), a same-file helper that needs the browser makes each component calling it an island, and a primitive called at a file's top level makes every component of it one. Control hydration per call site with `$hydrate="load" | "visible" | "idle" | "interaction" | "media(...)" | "client"`, or the component file's default `export const hydrate = 'visible'` (unknown modes and `$hydrate` on non-islands fail compile); the loader carries only the strategies the app's islands can use, and a page modulepreloads its eager islands with every chunk they and the runtime import (a streamed page its route's eager islands only). `<Head>`/`<Suspense>` in an island fail compile (`<Catch>` works in both); an island reading a context provided outside it throws in SSR (pass the value as a prop); server children handed to an island render before it, in the page's scope. Hydration steps over a node an extension injected and redraws a part whose tag differs from the server's and drops the server rows past a list's last row, in production too (dev also warns). Island props crossing the server boundary must be serializable (JSON primitives + `Date`, `Map`, `Set`, `URL`, `RegExp` — functions, signals and JSX in a prop other than `children` are refused; only a page whose props hold one of those classes loads, and preloads, the small file that revives them); an `on*` function passed from server code to a component that is not an island fails build and check too, since it would never run. A browser global (`window`, `document`, `localStorage`, ...) read while a component renders or its module loads warns, since the server has none: read it in `onMount()`, an effect or a handler, or behind `typeof window !== 'undefined'`. Islands cannot import server-only modules (`bun:sqlite`, `node:*`, `prunelle/server`) or read `process.env` other than `process.env.PUBLIC_*` (inlined at build time); action files are stubbed on the client (non-action exports from them cannot be imported by islands).
25
+ - **Automatic islands**: a component using reactive primitives (`signal`, `computed`, `effect`, `onMount`, `store`, `selector`), DOM `on*` handlers/`ref`, or imported reactive module state becomes an island, decided per component.
26
+ - A static export beside an island stays static. A component that needs the browser is an island of its own wherever server code renders it as a tag, same file included: the page around it stays static, and its chunk keeps only the code of the file it reaches, so an async page importing server code can render a local widget.
27
+ - A same-file helper that needs the browser makes each component calling it an island; a primitive called at a file's top level makes every component of the file one.
28
+ - `<Head>`/`<Suspense>` in an island fail compile (`<Catch>` works in both). An island reading a context provided outside it throws in SSR: pass the value as a prop. Server children handed to an island render before it, in the page's scope.
29
+ - Hydration steps over a node an extension injected, redraws a part whose tag differs from the server's and drops the server rows past a list's last row, in production too (dev also warns).
30
+ - **Hydration**: `$hydrate="load" | "visible" | "idle" | "interaction" | "media(...)" | "client"` per call site, or the component file's default `export const hydrate = 'visible'`; unknown modes and `$hydrate` on a non-island fail compile.
31
+ - The loader carries only the strategies the app's islands can use. A page modulepreloads its eager islands with every chunk they import (a streamed page, its route's eager islands only); a page whose islands all hydrate later downloads the loader alone (about 1 KB gzip) until the first one does, each island bringing the DOM runtime.
32
+ - **Island boundary**: props crossing it must be serializable: JSON primitives plus `Date`, `Map`, `Set`, `URL`, `RegExp`. Functions, signals and JSX in a prop other than `children` are refused; only a page whose props hold one of those classes loads, and preloads, the small file that revives them.
33
+ - An `on*` function passed from server code to a component that is not an island fails build and check, since it would never run.
34
+ - A browser global (`window`, `document`, `localStorage`, ...) read while a component renders or its module loads warns, since the server has none: read it in `onMount()`, an effect or a handler, or behind `typeof window !== 'undefined'`.
35
+ - Islands cannot import server-only modules (`bun:sqlite`, `node:*`, `prunelle/server`) or read `process.env` other than `process.env.PUBLIC_*` (inlined at build time). Action files are stubbed on the client: islands can import their actions and nothing else from them.
12
36
  - **Routes (`src/routes/`)**:
13
37
  - `export default async function Page({ params, locals, url })`: strictly server-only (`0 KB` JS; cannot use signals/handlers directly).
14
- - Sync `export default function Page({ data, params, locals, url }: PageProps<typeof load>)`: static or auto-island; optional `export async function load(ctx)` runs server-only and returns data, `notFound()` (from `prunelle/server` — return or throw to render `_404.tsx` with HTTP `404`), or a `Response` (e.g. redirect).
15
- - Special files: `_layout.tsx` (nested outer→inner, receives `{ children, params, locals, url }`, server-only), `_middleware.ts` (`(ctx, next) => Response`, outer→inner), `_error.tsx` (receives `{ error }`, server-only, wrapped in root layout), `_404.tsx` (server-only, wrapped in root layout, also emitted as `404.html` in `--static`); each needs a default export. Any other file under `src/routes/` must export a page, a method handler or an action (guarded by its folder's `_middleware.ts`), else `prunelle build`/`prunelle check` fail: prefix helpers or their folder with `_`.
16
- - Params: `[slug].tsx` → `params.slug`; `[...path].tsx` → `params.path` (segments joined by `/`). Params arrive percent-decoded; a segment holding an encoded `/`, `\` or NUL, or a `.`/`..` segment, matches no dynamic route (404), so a param is safe to join into a path; static pages, `public/` files and `prunelle start --static` decode by the same rule (`/a%2fb.txt` never serves `a/b.txt`).
17
- - API routes: `.ts` files exporting `GET`, `POST`, `PUT`, `PATCH`, `DELETE` receiving `RequestContext` (`request`, `url`, `params`, `cookies`, `locals`, `ip`, `region`, `json()`, `text()`, `redirect()`, `deny()`). Optional `export const csrf = false` opts out of origin checks (e.g. webhooks/bearer APIs).
18
- - Prerendering: `export const prerender = true` (+ `export function paths() { return ['/posts/a'] }` required for dynamic routes, and for every dynamic page under `--static`, or `prunelle build` fails; unlisted params return `404`). Skipped in `prunelle dev`.
19
- - **Streaming & Head**: `<Head><title>...</title></Head>` (innermost `<title>` wins); `<Suspense fallback={<p>Loading</p>} error={<p>Failed</p>}><AsyncComp /></Suspense>` streams resolved HTML inline with 0 KB external JS (takes exactly one child; an async component anywhere but as the only child of `<Suspense>` fails build and check, even inside an async page; nested boundaries supported; times out after `streamTimeout`, default `30000` ms; errors also fire `onError`). `<Catch fallback={<p>Failed</p> | (error, retry) => ...}>` renders its fallback in place of children that throw or an awaited child that rejects, on the server (firing `onError`; nothing streams) and in an island, where it also catches a child effect's later throw and `retry()` renders the children again (there it is written as a tag: calling `Catch()` as a function throws); errors thrown by event handlers are not caught.
20
- - **Regions** (`@prunellejs/spa`, `regions()`): `<Region name="pane" as="section" ...attrs>children</Region>` (from `prunelle`, server-only like `Head`) renders `<div data-pru-region="pane">`; its children are read only when the page or the requested region needs them. `<a href data-pru-target="pane">` swaps that region in place: the browser sends `x-pru-region: pane`, the server answers with the region's inner HTML alone (no layouts, no document; `ctx.region` tells `load()` which, `vary: x-pru-region`), history is pushed and back/forward re-fetch it, focus moves to the region, its `aria-label` is announced, `aria-busy="true"` is set after 150 ms and cleared on swap or failure. Add `data-pru-append` and the response is appended and the clicked link removed (Load more; the history entry is replaced, not pushed). `<form method="get" data-pru-target="results">` swaps on submit; with `data-pru-live` also on input (debounced 200 ms; one history entry per typing burst, a 1 s pause ends it). `data-pru-sync="q icon"` on a link, or on an input/select (its `name`), copies those params of the current URL after every swap so links outside the region stay in step. A link inside `[data-pru-prefetch]` prefetches its region on hover/focus through the cache `spa()` shares. A region may sit inside another (give each its own name): asking for the inner one renders it alone (header `x-pru-region: results/sets`, the path outermost first, which the client computes), asking for the outer renders it with a fresh inner, and an outer swap drops in-flight fetches of the regions inside it. Every region swap also sets `document.title` from the page's `<Head><title>` at that URL (title template applied; the server sends it in `x-pru-title`), and back/forward restore it. `await refreshRegion(name)` from `@prunellejs/spa/regions` redraws a region of the current address from script (after a background `fetch` to an action): no history entry, focus left alone, prefetch cache skipped, `pru:region` fired; it rejects when the page has no such region, the fetch fails or the answer lacks it. `<form method="post" data-pru-target="x">` posts through fetch, follows the redirect and swaps region x (without JS it posts normally); empty fields are dropped from a GET form's URL. A swap runs in a view transition where supported and not under reduced motion; each history entry remembers the window's and the regions' scroll, a pushed swap resets the region's own scroll unless it has `data-pru-keep-scroll="<key>"`; links to the new URL get `aria-current="page"`; a `#hash` link to an element on the page scrolls with no fetch when its page and query are the ones shown or appended by Load more. The regions client ships only on routes whose tree renders a `<Region>`. Without JS, or when a fetch fails or the response lacks the region, the link loads the whole page. Mistakes: `<Region>` without `name`, `data-pru-target` off `<a>`/`<form>`, `data-pru-live` on a non-GET form, `data-pru-append`/`data-pru-live` without their target, a region inside a region of the same name (compile errors); a target naming no `<Region>` in `src/` (`prunelle check`); two regions of one name, a requested region the route does not render (runtime throws).
21
- - **Actions (`prunelle/server` & `useAction` from `prunelle`)**: `export const fn = action(standardSchema, async (input, ctx) => ..., options?)` or `action(async (ctx) => ...)` — must be a top-level named export so Prunelle can assign a URL. Works as zero-JS `<form action={fn} method="post">` (array fields auto-coerced from checkboxes/multi-selects; validation failures set an `HttpOnly` flash cookie readable via `getActionError(ctx.locals)` with sensitive fields stripped or `flashFields` allowlisted and `303` redirect to trusted Referer; `action(schema, fn, { rateLimit: { max, windowMs, key? } })` refuses a client past `max` per window the same way with `Too many requests`, or a `429` `ActionResult` and `Retry-After` from script) and as typed island RPC `const res = await fn(data)` (always resolves to `{ ok: true, data }` or `{ ok: false, status, error, fieldErrors?, issues? }`; accepts `FormData` for files; redirects navigate the page). In islands, `const form = useAction(fn, { reset?, onSuccess?, onError? })` returns `{ pending, error, fieldErrors, data, action, onSubmit, submit, reset }` (`pending`/`error`/`fieldErrors`/`data` are `ReadonlySignal`s; wire `<form action={form.action} method="post" onSubmit={form.onSubmit}>` for progressive enhancement). A route, `load()`, middleware or another action may also call it: it runs in that request, schema and folder `_middleware.ts` included, and resolves to the same result; called outside a request it throws. Server code is stripped from client bundles; CSRF `Origin`/`Sec-Fetch-Site` is checked before middleware and body parsing; folder `_middleware.ts` runs before the handler. `ctx` provides `redirect()` and `deny(status, message, fieldErrors?)`.
22
- - **Config, Security & Server Helpers (`prunelle.config.ts`, `prunelle/config`, `prunelle/server`)**: `defineConfig({ lang, port, routesDir, outDir, publicDir, assetPrefix, security, trustedOrigins, trustProxy, maxRequestBodySize, streamTimeout, consent, compliance, compress, onError, plugins })`. Default security headers (`security: false` to disable, or override `csp`, `hsts`, `frameOptions`, `referrerPolicy`, `contentTypeOptions`) attach strict `DEFAULT_CSP` (style attributes allowed) with automatic SHA-256 hashes for island/Suspense styles, the app's own `<style>` blocks and stream scripts, plus `HSTS` on HTTPS requests. `trustProxy: true | number` trusts that many right-most proxy hops for `X-Forwarded-*`. `maxRequestBodySize` defaults to `1 MiB`. `prunelle/server` also exports `defineEnv(standardSchema)` (validates env vars at startup), `nodeEnv()` (safe in `--compile`; server code reads it, never `process.env.NODE_ENV`, which `prunelle build` leaves unset for a prerendered page, and build and `prunelle check` warn on such a read outside island code), HTML escaping (`raw`, `esc`, `escAttr`), HTTP security helpers (`getClientIp`, `isHttpsRequest`, `isTrustedOrigin`, `verifyOrigin`, and `safeRedirect(target, fallback = '/')`, which returns the trimmed target only when it is a path on this site, refusing absolute and protocol-relative URLs, backslashes and control characters, and which `@prunellejs/auth` and the consent endpoint use), and Standard Schema helpers (`validateSchema`, `validateSchemaSync`, `formatSchemaIssues`, `formatIssuePath`).
23
- - **French web law & Consent (RGPD, CNIL, RGAA, LCEN — 0 B client JS)**: `prunelle check` and production `prunelle build` emit actionable warnings (never hard errors): `rgaa/img-alt` (`<img>` without `alt`), `rgaa/form-label` (unlabelled `<input>`/`<select>`/`<textarea>`), `rgaa/accessible-name` (empty or icon-only `<button>`/`<a>`), `rgpd/third-party-url` (third-party `<script src>`, `<link rel="stylesheet|preload|preconnect|dns-prefetch">`, `<iframe src>`, and CSS `@import`/`url(...)` outside `<ConsentGate>` or `site`), `lcen/legal-notice` (page app missing `/mentions-legales` or `/legal`), and `rgaa/accessibility-statement` (when `compliance: { publicBody: true }`, missing `/accessibilite`). Silence explicitly per rule via `compliance: { ignore: [...], legalNotice?: string | false, publicBody?: boolean }` in `prunelle.config.ts`, or `// prunelle-ignore <rule>` / `/* prunelle-ignore <rule> */` / `// prunelle-ignore-file <rule>`. One-declaration consent: configure `consent: { categories: ['analytics', 'media'], cookieName?: 'pru_consent', maxAge?: 15552000, endpoint?: '/_pru/consent' }` in `prunelle.config.ts` — Prunelle wires a CSRF-protected `POST /_pru/consent` endpoint (works with zero-JS HTML `<form method="post" action="/_pru/consent">` via `action="accept-all"|"reject-all"` or category checkboxes -> `303`, and JSON -> `200`), exposes `ctx.consent` (`decided`, `categories`, `has(cat)`, `all()`), refuses `ctx.cookies.set(name, val, { category })` before consent is granted, and exports server-only `<ConsentGate category="media" fallback={...}>` (0 KB browser JS, refused inside islands).
24
- - **Page changes (plain multi-page navigation, 0 B of JS)**: every page carries inline, CSP-hashed `@view-transition { navigation: auto }` (inside `@media (prefers-reduced-motion: no-preference)`) and a `<script type="speculationrules">` prefetching same-origin links on hover (`eagerness: moderate`); never links to another origin, `/_pru/*` (actions included), `[download]`, `[rel~=nofollow]`, nor a link or ancestor with `data-pru-no-prefetch`. Name an element that stays still with CSS `view-transition-name`. `defineConfig({ navigation: { viewTransitions?: boolean (true), prefetch?: 'conservative' | 'moderate' | 'eager' | false ('moderate'), prerender?: 'conservative' | 'moderate' | 'eager' | boolean (false; true is 'moderate'; it runs `load()` of pages nobody opens) } })`; a bad value throws `prunelle: navigation.<key> is ...`. `data-pru-keep-scroll="<key>"` on a scrolling element keeps its `scrollTop` across page loads (restored before first paint when the next page has the same key; per history entry on back/forward/reload; `sessionStorage` blocked = no-op): the page gets one inline hashed script at the end of `<body>` only when it uses the attribute. The key is a literal string without `"<>&` (compile error otherwise, also for a nested panel of the same key); the same key on two elements of one rendered page throws `prunelle: data-pru-keep-scroll="..." is on two elements of one page`. `@prunellejs/spa` keeps the same attribute across its swaps.
25
- - **Static files & CSS**: Files in `public/` are served at `/` with ETag/`304` (and `Cache-Control: no-cache` in `prunelle dev`; embedded in `--static` and `--compile`); prerendered pages and hashed assets answer an ETag, a `304` and a `HEAD` length too. `prunelle build` compresses hashed assets, `public/` files and prerendered pages of 256 B or more into `.br` and `.gz` files beside them, kept when smaller, and the server sends those as they are; it compresses on the fly (zstd, gzip) only what has none, such as pages rendered per request, and flushes a page streamed past `<Suspense>` with each part. A `public/x.css.br` the app ships is kept and sent as `x.css` in brotli. `prunelle start` on a `--static` export lists its files at startup (`x` serves `x.html` or `x/index.html`, a miss `404.html`), re-lists them when one changes in place, and loads a new export with no restart. Import `.css` or `*.module.css` directly from any component or layout.
26
- - **CLI**: `prunelle new <dir> [--template minimal|fullstack|blog|app] [--force]` (its `AGENTS.md` points agents at this file, installed at `node_modules/prunelle/llms.txt`; its `.gitignore` lists `node_modules/`, `dist/` and `.prunelle-cache/`), `prunelle check [dir] [--no-typecheck] [--json] [--strict]` (every compiler mistake of a file, each at its `file:line:col: error:`, warnings as `file:line:col: warning:`; `--json` prints `{ ok, checkedFiles, typecheck, errors, warnings }` with `file`/`line`/`col`/`severity`/`message`, `typecheck` being `{ ran: true, tool }` or `{ ran: false, reason }` (no tsconfig, `--no-typecheck`, no checker), which the summary line also names; `--strict` exits 1 on a warning; `prunelle build` refuses the same mistakes, without the typecheck; a plugin `check(ctx)` reports with `ctx.error()` or `ctx.warn()`), `prunelle inspect [dir] [--json]` (fast static report of routes, islands with interactivity `reason` and `hydrate` mode, actions with URLs and guarding `_middleware.ts`, and active plugins in resolved order without bundling; `--json` prints `{ routes, islands, actions, plugins }`), `prunelle dev [dir] [--port 3000] [--host [addr]]` (loopback `127.0.0.1` default; a `prunelle.config.ts` that fails to load stops it naming `prunelle.config.ts:<line>:<col>: <error>`; the app runs in a child process behind the port: a save rebuilds in it, an edit to `prunelle.config.ts` or a local file it imports, or the child passing 2 GB after a rebuild, starts a fresh one (module and plugin memory reset, requests wait, the reload stream stays open); a crash answers with its exit and stderr until the next save; an edited `public/` file reloads with no rebuild), `prunelle build [dir] [--static] [--compile [out]] [--analyze] [--json] [--max-js <size>]` (`--analyze` lists each route's eager JS (the runtime a plugin's `clientEntry` puts on every page included), CSS, fonts and first load (what a first visit downloads besides the HTML, brotli) and its islands with why each is one; `firstLoadUrls`, `distLocator` and `measureFirstLoad` from `prunelle/config` give a plugin the same figure for a page (`measureFirstLoad(urls, locate, htmlBytes, cacheable)` also returns `cached`, the bytes of the URLs `cacheable` accepts, such as the hashed `/_pru/` files a browser keeps for the next page), and `await brotliSize(html)` the page's own bytes as prunelle serves it, from the build's brotli cache, as the docs footer does; `--analyze --json` outputs `BundleReport` JSON on stdout without summary lines; `--max-js 40kb` fails on a route whose gzipped eager JS is over it, naming its eager islands), `prunelle start [dir] [--port 3000] [--host [addr]]`, `prunelle upgrade [dir] [--no-install]` (moves a kay v2 app onto prunelle: `@kayjs/*` dependencies and imports, `kay.config.ts`, every `Kay*` name it imports, the `kay` names the browser receives, build and CI files, in each package a bun workspace lists; a package on kay v1 is left as it is; a kay `sqliteAuthStore()` database keeps its accounts), plus plugin commands (`prunelle ui-eject <grammar> [dest]`, `prunelle mcp-footprint`, `prunelle i18n-check`, `prunelle icons-find <words> [--set <prefix>] [--limit <n>]`). `prunelle --help`, `prunelle <command> --help` and `prunelle --completions fish|bash|zsh` come from `@kaynooo/cli-kit`; a typo'd command or option names the one meant. Exit codes: 0 done, 1 a finding or failure (`prunelle check` found an error, `prunelle upgrade` has steps left by hand, a build failed), 2 a usage error (unknown command or option, bad port or `--max-js`). Plugin commands are read from `prunelle.config.ts` only when the first word is no built-in, and take `--root <dir>` and `--help`; a config that fails to load leaves `prunelle --help` and the built-ins working, and a plugin command typed then names the error (exit 1).
27
- - **Testing (`prunelle/test`)**: `const app = await testApp({ root, prebuilt?, outDir? })` (builds into its own `.prunelle-cache/test-*` folder, removed at exit, never into `dist/`; `prebuilt: true` reuses the latest testApp build of that root in the process, else `dist/`) — in-process `app.get()`, `app.post()`, `app.import(path)` (the app's bundled copy of a route, action file or `prunelle.config.ts`), `app.submit(action | url, fields)`, `app.fetch()`, `app.cookies`, `app.clearCookies()` with persistent cookie jar and zero port binding; `app.errors` lists unhandled route/action/plugin errors (`route GET /p: message`), and `testApp({ dev: true })` shows them in the 500 like `prunelle dev` does. Unhandled errors with `dev` (prunelle dev, `dev: true`): `console.error` unless an `onError` hook exists, and the 500 carries message and stack, each frame at its `src/` file and line (under `prunelle start` too, through the source maps `prunelle build` writes; a `--compile` binary names its own code) (JSON `{ ok: false, status: 500, error, stack }` when the request wants JSON, else text; `_error.tsx` still renders); production stays `Internal Server Error`. `prunelle dev` build errors also answer JSON/text per `Accept`. Islands: `const b = await testBrowser({ root, timeout?, browserPath? })` (needs `playwright-core` as a dev dependency and Chrome/Chromium; production build served on `b.origin`, a free 127.0.0.1 port) then `const page = await b.open(path)` (resolves once the page has loaded and its `load`/`client` islands have hydrated; `visible`, `idle` and `interaction` ones are the test's to trigger) (`b.open(path, { reducedMotion: true })` opens it for a visitor asking for less motion) with `page.click(sel)`, `page.hover(sel)`, `page.fill(sel, value)`, `page.text(sel)`, `page.waitFor(sel | fn)`, `page.evaluate(fn)`, `page.errors` (page errors, console errors, 4xx/5xx responses), `page.close()`, and `await b.close()` at the end.
38
+ - Sync `export default function Page({ data, params, locals, url }: PageProps<typeof load>)`: static or auto-island; optional `export async function load(ctx)` runs server-only and returns data, `notFound()` (from `prunelle/server`; return or throw it to render `_404.tsx` with HTTP `404`), or a `Response` (e.g. redirect).
39
+ - Special files: `_layout.tsx` (nested outer→inner, receives `{ children, params, locals, url }`, server-only), `_middleware.ts` (`(ctx, next) => Response`, outer→inner), `_error.tsx` (receives `{ error }`, server-only), `_404.tsx` (server-only; also emitted as `404.html`, and as `<folder>/404.html` for static non-group folders in `--static`), and status pages `_401.tsx`, `_403.tsx`, `_429.tsx`, `_503.tsx` (receive `{ status, message, url, params, locals }`). Each needs a default export; an unsupported `_NNN.tsx` (e.g. `_418.tsx`) fails `prunelle check` and `prunelle build`.
40
+ - `_404.tsx`, `_error.tsx` and status pages may live in any subfolder (including `(group)/`) and win over the root one for routes under it, wrapped in that folder's layouts. `ctx.deny(status, message, fieldErrors?)` renders the nearest status page (else the nearest `_error.tsx`, else clean HTML) when the request accepts HTML (`Accept: text/html`), and JSON otherwise (actions keep JSON for JS and flash + 303 for zero-JS forms).
41
+ - Any other file under `src/routes/` must export a page, a method handler or an action (guarded by its folder's `_middleware.ts`), else `prunelle build`/`prunelle check` fail: prefix helpers or their folder with `_`.
42
+ - Params, groups & optionals: `(name)/` groups routes under its `_layout.tsx` and `_middleware.ts` without adding a URL segment; `[[lang]]/about.tsx` matches `/about` and `/fr/about` (`params.lang` typed `string | undefined`); `[slug].tsx` → `params.slug`; `[...path].tsx` → `params.path` (segments joined by `/`).
43
+ - Matchers: `[id=integer].tsx` and `[...path=slug].tsx` match only accepted values and fall through on mismatch (built-ins: `integer` → `` `${number}` ``, `uuid` → `` `${string}-${string}-${string}-${string}-${string}` ``, `slug` → `string`; custom matchers live in `src/params/<name>.ts` exporting `match` or `default`). Unknown matchers or conflicting route patterns fail build and check naming both files; precedence is `static > matched param > param > optional > catch-all`.
44
+ - Params arrive percent-decoded; a segment holding an encoded `/`, `\` or NUL, or a `.`/`..` segment, matches no dynamic route (404) unless a plugin catch-all route sets `encodedSlashes`, so a param is safe to join into a path. Static pages, `public/` files and `prunelle start --static` decode by the same rule (`/a%2fb.txt` never serves `a/b.txt`).
45
+ - API routes: `.ts` files exporting standard `HTTP_METHOD_EXPORTS` (`GET`, `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE`, `OPTIONS`) receiving `RequestContext` (`request`, `url`, `params`, `cookies`, `locals`, `ip`, `requestId`, `region`, `json()`, `text()`, `redirect()`, `deny()`). CSRF checks run on every method outside the safe allowlist (`GET`, `HEAD`, `OPTIONS`), trusting only the forwarded origin when `trustProxy` resolves one (or `trustedOrigins`). `export const csrf = false` opts out of origin checks (webhooks, bearer APIs).
46
+ - Prerendering: `export const prerender = true` (+ `export function paths() { return ['/posts/a'] }`, required for dynamic routes and for every dynamic page under `--static`, or `prunelle build` fails; unlisted params return `404`). Skipped in `prunelle dev`. Static pages that read nothing from the request or clock are reported `cacheable` by `prunelle inspect` and prerender automatically with `autoPrerender: true` or `prunelle build --auto-prerender`.
47
+ - Route caching: `export const cache = '1h'` (or `{ maxAge: '1h', staleWhileRevalidate?: '1d' }`) serves a bounded in-memory LRU render (`routeCache: { maxEntries?, maxBytes? } | false`), re-renders in the background once stale, and sends `cache-control: public, s-maxage=..., stale-while-revalidate=...`. A cached route (or its layout `load()` or imported local modules) reading `ctx.cookies`, `ctx.locals`, `ctx.consent`, `ctx.ip`, `Cookie`/`Authorization` headers, `getActionError()`, or `<ConsentGate>` fails `prunelle check` and `prunelle build` naming the read.
48
+ - **Streaming & Head**: `<Head><title>...</title></Head>` (innermost `<title>` wins).
49
+ - `<Suspense fallback={<p>Loading</p>} error={<p>Failed</p>}><AsyncComp /></Suspense>` streams resolved HTML inline with 0 KB external JS. It takes exactly one child; an async component anywhere but as the only child of `<Suspense>` fails build and check, even inside an async page. Boundaries nest, time out after `streamTimeout` (default `30000` ms), and their errors also fire `onError`.
50
+ - `<Catch fallback={<p>Failed</p> | (error, retry) => ...}>` renders its fallback in place of children that throw or an awaited child that rejects, on the server (firing `onError`; nothing streams) and in an island, where it also catches a child effect's later throw and `retry()` renders the children again (there it is written as a tag: calling `Catch()` as a function throws); errors thrown by event handlers are not caught.
51
+ - **Regions** (`<Region>` from `prunelle`, swapped by `regions()` from `@prunellejs/spa`): `<Region name="pane" as="section" ...attrs>children</Region>` is server-only like `Head` and renders `<section data-pru-region="pane">`. `<a href data-pru-target="pane">` and `<form data-pru-target="pane">` swap that region in place with the server's answer; without JS the link or form loads the whole page. Load more, live search, nested regions, `refreshRegion()` and the mistakes it reports: `node_modules/@prunellejs/spa/llms.txt`.
52
+ - **Actions (`prunelle/server` & `useAction` from `prunelle`)**: `export const fn = action(standardSchema, async (input, ctx) => ..., options?)` or `action(async (ctx) => ...)`, a top-level named export so Prunelle can assign it a URL. `ctx` provides `redirect()` and `deny(status, message, fieldErrors?)`.
53
+ - Zero-JS form: `<form action={fn} method="post">`. Array fields are coerced from checkboxes/multi-selects. SSR adds `required`, `minlength`/`maxlength`, `min`/`max`/`step`, `pattern` and `type="email"|"url"|"number"` to `<input>`/`<select>`/`<textarea>` from the action's Standard Schema JSON Schema unless the app wrote that attribute (0 B client JS, no implicit `<option>` tags). A validation failure sets an `HttpOnly` flash cookie, read with `getActionError(ctx.locals)` (sensitive fields stripped, or `flashFields` allowlisted), and redirects `303` to the trusted Referer.
54
+ - `protect: { rateLimit?: { max, windowMs, key? }, honeypot?: boolean | string, minTime?: number }` (or top-level `rateLimit`) enforces `rateLimit` (`429` + `Retry-After` / flash+303) before body parsing, then honeypot/`minTime`, then schema validation. It renders a hidden honeypot and an action-URL-bound HMAC-signed `_pru_ts` timestamp into `<form action={fn}>` automatically and refuses bots and fast submits with `400` before the handler runs. Set `PRUNELLE_FORM_SECRET` or `AUTH_SECRET` in production when using `minTime`, else Prunelle logs a one-time production warning.
55
+ - `prunelle check` and `prunelle build` report unknown form fields with the closest name, missing required fields, invalid `<select>` enum options, unsupported schema libraries (once per vendor) and unguarded public form actions without `protect`.
56
+ - Island RPC: `const res = await fn(data)` always resolves to `{ ok: true, data }` or `{ ok: false, status, error, fieldErrors?, issues? }`; it accepts `FormData` for files, and redirects navigate the page.
57
+ - In islands, `const form = useAction(fn, { reset?, onSuccess?, onError? })` returns `{ pending, error, fieldErrors, data, action, onSubmit, submit, reset }` (`pending`/`error`/`fieldErrors`/`data` are `ReadonlySignal`s). Wire `<form action={form.action} method="post" onSubmit={form.onSubmit}>` for progressive enhancement; it keeps the SSR protection fields and HTML5 constraints.
58
+ - A route, `load()`, middleware or another action may also call it: it runs in that request, schema and folder `_middleware.ts` included, and resolves to the same result; called outside a request it throws.
59
+ - Server code is stripped from client bundles. CSRF `Origin`/`Sec-Fetch-Site` is checked before middleware and body parsing; the folder's `_middleware.ts` runs before the handler.
60
+ - **Config (`prunelle.config.ts`)**: `defineConfig({ site, lang, port, routesDir, outDir, publicDir, assetPrefix, security, trustedOrigins, trustProxy, maxRequestBodySize, navigation, routeCache, autoPrerender, streamTimeout, consent, compliance, compress, healthCheck, onError, plugins })`. `trustProxy: true | number` trusts that many right-most proxy hops for `X-Forwarded-*`; `maxRequestBodySize` defaults to `1 MiB`.
61
+ - **Security headers & CSP**: on by default (`security: false` disables them, or override `csp`, `hsts`, `frameOptions`, `referrerPolicy`, `contentTypeOptions`). The strict `DEFAULT_CSP` (style attributes allowed) gets automatic SHA-256 hashes for island/Suspense styles, the app's own `<style>` blocks and stream scripts; `HSTS` is sent on HTTPS requests.
62
+ - `security: { csp: { 'style-src': [...], 'font-src': [...] } }` (or `extendCsp()` / `DEFAULT_CSP` from `prunelle/server`) adds sources to single directives without copying the whole policy; a new `*-src` directive inherits `default-src`, and automatic hashes still land in the extended directives.
63
+ - A `--static` export embeds each page's and `404.html`'s hashed CSP in `<meta http-equiv="Content-Security-Policy">` with `frame-ancestors`, `report-uri` and `sandbox` stripped (browsers ignore them in `<meta>`): configure the static host to send `Content-Security-Policy: frame-ancestors 'self'` and the response headers (`X-Content-Type-Options`, `Referrer-Policy`, `HSTS`).
64
+ - **Observability**: `/_pru/health` (at `${assetPrefix}/health`) answers `200 { ok: true }`, or `503` when the app's `healthCheck` or a plugin's `api.healthCheck(name, fn)` fails; `./app --health` probes it for a container `HEALTHCHECK`. Every request gets `ctx.requestId` (honoring a safe incoming `x-request-id` when `trustProxy` is truthy), returned in `x-request-id` and passed to `onError` as `info.requestId`. `prunelle dev` sends `Server-Timing` (`middleware`, `load`, `render`, `stream`; zero overhead in production).
65
+ - **Server helpers (`prunelle/server`)**:
66
+ - `defineEnv(standardSchema)` validates env vars at startup. `nodeEnv()` is safe in `--compile`: server code reads it, never `process.env.NODE_ENV`, which `prunelle build` leaves unset for a prerendered page (build and `prunelle check` warn on such a read outside island code).
67
+ - HTML escaping: `raw`, `esc`, `escAttr`, `escJson` (JSON text for a `<script>`).
68
+ - HTTP: `getClientIp`, `isHttpsRequest`, `isTrustedOrigin`, `verifyOrigin`, `wantsJson`, `safeEqual` (constant-time secret compare), `readStringFields` (a body's string fields, on a null-prototype record), and `safeRedirect(target, fallback = '/')`, which returns the trimmed target only when it is a path on this site, refusing absolute and protocol-relative URLs, backslashes and control characters (`@prunellejs/auth` and the consent endpoint use it).
69
+ - `createRateLimitStore({ maxKeys?, maxHits? })`: a standalone sliding-window store whose `.limiter({ max, windowMs }).hit(key)` returns 0 or the seconds to wait; plugins use `api.rateLimiter()`.
70
+ - Standard Schema: `validateSchema`, `validateSchemaSync`, `formatSchemaIssues`, `formatIssuePath`.
71
+ - `declare module 'prunelle/server' { interface PrunelleLocals { ... } }` types `ctx.locals`; `createServer({ root })` runs a built app inside another program.
72
+ - **French web law & Consent (RGPD, CNIL, RGAA, LCEN - 0 B client JS)**: `prunelle check` and production `prunelle build` emit actionable warnings (never hard errors):
73
+ - RGAA: `rgaa/img-alt` (`<img>` without `alt`, or `alt={undefined}`/`alt={false}`), `rgaa/form-label` (unlabelled `<input>`/`<select>`/`<textarea>`), `rgaa/accessible-name` (empty or icon-only `<button>`/`<a>`), `rgaa/duplicate-id` (duplicate literal `id` in one component, or a static `id` inside `.map()`), `rgaa/positive-tabindex` (`tabindex > 0`).
74
+ - RGAA structure: `rgaa/nested-control` (interactive element inside `<a>`/`<button>`/`<summary>`), `rgaa/link-as-button` (`<a>` without `href` with `onClick`), `rgaa/unknown-role`, `rgaa/unknown-aria`, `rgaa/invalid-aria-value`, `rgaa/skipped-heading` (downward heading jump > 1 in one component), `rgaa/table-without-header` (`<table>` without `<th>`), `rgaa/fieldset-without-legend`, `rgaa/click-without-key` (`onClick` on a non-interactive element without a key handler), `rgaa/autofocus`, `rgaa/meta-refresh`, and `rgaa/accessibility-statement` (missing `/accessibilite` when `compliance: { publicBody: true }`).
75
+ - `rgpd/third-party-url`: a third-party `<script src>`, `<link rel="stylesheet|preload|preconnect|dns-prefetch|modulepreload|icon">`, `<iframe src>`, `<img src/srcset>`, `<video>`, `<audio>`, `<source>`, `<object data>`, `<embed>`, or CSS `@import`/`url(...)` outside `<ConsentGate>` or `site`.
76
+ - `lcen/legal-notice`: a page app missing `/mentions-legales`, `/legal`, or a localized variant (`/fr/mentions-legales`, `/[lang]/mentions-legales`).
77
+ - Silence per rule with `compliance: { ignore: [...], legalNotice?: string | false, publicBody?: boolean }`, or `// prunelle-ignore <rule>` / `/* prunelle-ignore <rule> */` / `// prunelle-ignore-file <rule>`.
78
+ - One-declaration consent: `consent: { categories: ['analytics', 'media'], cookieName?: 'pru_consent', maxAge?: 15552000, endpoint?: '/_pru/consent' }` wires a CSRF-protected `POST /_pru/consent` endpoint (a zero-JS `<form method="post" action="/_pru/consent">` with `action="accept-all"|"reject-all"` or category checkboxes gets a `303`, JSON a `200`), exposes `ctx.consent` (`decided`, `categories`, `has(cat)`, `all()`), refuses `ctx.cookies.set(name, val, { category })` before consent is granted, and exports server-only `<ConsentGate category="media" fallback={...}>` (0 KB browser JS, refused inside islands).
79
+ - **Page changes (plain multi-page navigation, 0 B of JS)**: every page carries inline, CSP-hashed `@view-transition { navigation: auto }` (inside `@media (prefers-reduced-motion: no-preference)`) and a `<script type="speculationrules">` prefetching same-origin links on hover (`eagerness: moderate`); it never links to another origin, `/_pru/*` (actions included), `[download]`, `[rel~=nofollow]`, nor a link or ancestor with `data-pru-no-prefetch`. Name an element that stays still with CSS `view-transition-name`.
80
+ - `defineConfig({ navigation: { viewTransitions?: boolean (true), prefetch?: 'conservative' | 'moderate' | 'eager' | false ('moderate'), prerender?: 'conservative' | 'moderate' | 'eager' | boolean (false; true is 'moderate'; it runs `load()` of pages nobody opens) } })`; a bad value throws `prunelle: navigation.<key> is ...`.
81
+ - `data-pru-keep-scroll="<key>"` on a scrolling element keeps its `scrollTop` across page loads (restored before first paint when the next page has the same key; per history entry on back/forward/reload; a no-op when `sessionStorage` is blocked), through one inline hashed script at the end of `<body>` on pages using the attribute. The key is a literal string without `"<>&` (compile error otherwise, also for a nested panel of the same key); the same key on two elements of one rendered page throws `prunelle: data-pru-keep-scroll="..." is on two elements of one page`. `@prunellejs/spa` keeps the same attribute across its swaps.
82
+ - **Static files & CSS**: Files in `public/` are served at `/` with ETag/`304` (`Cache-Control: no-cache` in `prunelle dev`; embedded in `--static` and `--compile`); prerendered pages and hashed assets answer an ETag, a `304` and a `HEAD` length too. Import `.css` or `*.module.css` directly from any component or layout.
83
+ - `prunelle build` consolidates local stylesheets into at most one site-wide hashed immutable sheet plus one per-route sheet when needed, preserving `@layer` and plugin-before-app cascade order.
84
+ - It compresses hashed assets, `public/` files and prerendered pages of 256 B or more into `.br` and `.gz` files beside them, kept when smaller, which the server sends as they are; it compresses on the fly (zstd, gzip) only what has none, such as pages rendered per request, and flushes a page streamed past `<Suspense>` with each part. A `public/x.css.br` the app ships is kept and sent as `x.css` in brotli.
85
+ - `prunelle start` on a `--static` export lists its files at startup (`x` serves `x.html` or `x/index.html`, a miss `404.html`), re-lists them when one changes in place, and loads a new export with no restart.
86
+ - **CLI (scaffold, check, build, start & upgrade)**: `--help` and `--completions fish|bash|zsh` come from `@kaynooo/cli-kit`. Exit codes: `0` done, `1` finding/failure, `2` usage error.
87
+ - `prunelle new <dir> [--template minimal|fullstack|blog|app] [--force]`: its `AGENTS.md` points agents at `node_modules/prunelle/llms.txt`; it writes `.mcp.json` registering `prunelle mcp`, `tsconfig.json` with `prunelle/ts-plugin`, and a `.gitignore` listing `node_modules/`, `dist/` and `.prunelle-cache/`.
88
+ - `prunelle check [dir] [--no-typecheck] [--json] [--strict]`: every compiler mistake at `file:line:col: error:`, warnings at `file:line:col: warning:` (RGAA/RGPD/LCEN compliance, broken internal links `[link/broken]` across JSX, `ctx.redirect()` and Markdown content bodies (`// prunelle-ignore` silences one), cached-route private reads, form-vs-schema field/option/protection checks, and plugin `check(ctx)` hooks such as `@prunellejs/seo`). `--json` prints `{ ok, checkedFiles, typecheck, errors, warnings }`; `--strict` exits 1 on a warning; `prunelle build` refuses the same mistakes and form-schema errors without the typecheck.
89
+ - `prunelle inspect [dir] [--json]`: fast static report, without bundling, of routes (groups, optional params, matchers, `cache`, accurate `autoPrerender` `cacheable`), `statusPages`, `paramMatchers`, islands with their interactivity `reason` and `hydrate` mode, actions with URLs and guarding `_middleware.ts`, and active plugins in resolved order; `--json` prints `{ routes, statusPages, paramMatchers, islands, actions, plugins }`.
90
+ - `prunelle build [dir] [--static] [--compile [out]] [--auto-prerender] [--analyze] [--json] [--max-js <size>]`: `--analyze` lists each route's eager JS, CSS, fonts, first load (brotli), EcoIndex grade/score/inputs for prerendered routes, and its islands with why each is one (`--analyze --json` outputs `BundleReport` JSON); `firstLoadUrls`, `distLocator` and `measureFirstLoad` from `prunelle/config` give plugins the same figure, and `await brotliSize(html)` reads the brotli cache. `--max-js 40kb` fails on a route whose gzipped eager JS is over it.
91
+ - `prunelle start [dir] [--port 3000] [--host [addr]]`; `prunelle upgrade [dir] [--no-install]` moves a kay v2 app or workspace onto prunelle (kay v1 left untouched; `sqliteAuthStore()` preserves accounts).
92
+ - Plugin commands: `prunelle a11y [--draft [dest]] [--json] [--routes /a,/b]` (via `a11y()` from `prunelle/config`), `prunelle ui-eject <grammar> [dest]`, `prunelle mcp-footprint`, `prunelle i18n-check`, `prunelle icons-find <words> [--set <prefix>] [--limit <n>]`, `prunelle pwa-vapid [--json]`. They load from `prunelle.config.ts` only when the first word is no built-in, and take `--root <dir>` and `--help`.
93
+ - **CLI (dev, editor & agent tooling)**:
94
+ - `prunelle dev [dir] [--port 3000] [--host [addr]]`: binds loopback `127.0.0.1` by default; marks rendered elements with `data-pru-src="file:line:col"` in dev only (production output is byte-identical), and Alt-click opens `$PRUNELLE_EDITOR` or `$VISUAL` in VS Code, Cursor, Zed, JetBrains, Sublime, Helix or a `{file}:{line}:{col}` template; records dev build, crash and runtime errors in `.prunelle-dev/last-errors.json`; runs the app in a child process recycled on `prunelle.config.ts` edits or past 2 GB; edits in `public/` reload without rebuilding.
95
+ - `prunelle render <url> [--method|-X <m>] [--body|-d <data>] [--header|-H "K: V"] [--cookie|-b "k=v"] [-i|--include] [--fresh]`: built on `testApp()`, it builds or reuses `.prunelle-cache/render-build` with no port bound and without touching `dist/`, and prints the body (status, headers and body with `-i`); exit `0` for `2xx`/`3xx`, `1` otherwise.
96
+ - `prunelle docs <words...> [--json] [--limit <n>]`: searches `llms.txt` of `prunelle` and every installed `@prunellejs/*` package at the installed versions; `--json` prints `{ query, words, packages, matches }`.
97
+ - `prunelle mcp [dir] [--allow-write]`: stdio MCP server for coding agents exposing `check`, `inspect`, `build_analyze`, `build` (requires `--allow-write`), `render`, `docs` and `dev_errors` tools, plus `prunelle://llms/<pkg>` resources; it reloads `prunelle.config.ts` fresh on every tool call, and paths stay inside the project.
98
+ - `prunelle/ts-plugin`, added to `tsconfig.json` `compilerOptions.plugins` as `{ "name": "prunelle/ts-plugin", "site"?: "...", "compliance"?: {...} }`, surfaces compiler mistakes, compliance warnings and 18 mechanical quick fixes in `tsserver` editors (select the workspace TypeScript version in VS Code; `tsserver`-only until `tsgo` supports plugins).
99
+ - **Testing (`prunelle/test`)**:
100
+ - `const app = await testApp({ root, prebuilt?, outDir? })` builds into its own `.prunelle-cache/test-*` folder, removed at exit, never into `dist/` (`prebuilt: true` reuses the latest testApp build of that root in the process, else `dist/`). In-process, with a persistent cookie jar and no port: `app.get()`, `app.post()`, `app.import(path)` (the app's bundled copy of a route, action file or `prunelle.config.ts`), `app.submit(action | url, fields)` (sends an empty honeypot and an aged signed timestamp for `protect`ed `ServerAction`s unless overridden), `app.fetch()`, `app.cookies`, `app.clearCookies()`, `app.dispose()` (`await using app = await testApp(...)`).
101
+ - Unhandled errors in routes, actions, plugin routes and streamed `<Suspense>` boundaries log their source, method, path and stack to stderr (`console.error`) under `prunelle start` and `prunelle dev` when no `onError` hook is configured (an `onError` handles them without doubling). `testApp()` captures them silently in `app.errors` (`route GET /p: message`); `testApp({ dev: true })` shows them in the 500 like `prunelle dev` does.
102
+ - With `dev` (`prunelle dev`, `testApp({ dev: true })`), the 500 carries message and stack, each frame at its `src/` file and line (under `prunelle start` too, through the source maps `prunelle build` writes; a `--compile` binary names its own code), as JSON `{ ok: false, status: 500, error, stack }` when the request wants JSON, else text; `_error.tsx` still renders. Production stays `Internal Server Error`. `prunelle dev` build errors also answer JSON/text per `Accept`.
103
+ - Islands: `const b = await testBrowser({ root, timeout?, browserPath? })` (needs `playwright-core` as a dev dependency and Chrome/Chromium; serves the production build on `b.origin`, a free 127.0.0.1 port), then `const page = await b.open(path)`, which resolves once the page has loaded and its `load`/`client` islands have hydrated (`visible`, `idle`, `interaction` and `media(...)` ones are the test's to trigger); `b.open(path, { reducedMotion: true })` asks for less motion.
104
+ - `page` has a live `page.url`, `page.click(sel)`, `page.hover(sel)`, `page.fill(sel, value)`, `page.press(key)`, `page.text(sel)`, `page.waitFor(sel | fn)`, `page.evaluate(fn)`, `page.errors` (page errors, console errors, 4xx/5xx responses) and `page.close()`; end with `await b.close()`.
28
105
  - **Plugins (`prunelle.config.ts`)**: `export default defineConfig({ plugins: [...] })` / `definePlugin(...)`. Order with `enforce: 'pre' | 'post'` and `after: ['@prunellejs/i18n']` (a name no plugin has is an optional dependency, unless it is one typo from one that is, which fails). Two plugins sharing a `name` fail, and so does an unknown config key, naming the closest one.
29
106
  - A stateful plugin's `createX()` returns the plugin and the app's handle in one object: `plugins: [auth, mail, rooms]`, with `auth.guard()`, `mail.send()`, `rooms.publish()` in routes. Stateless plugins are `x()`.
30
- - Hooks: `server(api)` (`use(mw, { scope? })` (`'all'` default, prerendered pages included; `'rendered'` skips prerendered pages, for middleware that only feeds rendering such as a session; `'dynamic'` also skips pages with no `load`; or a path prefix), `rewrite` (also run once per prerendered page at start, on an anonymous GET: no side effects), `route(method, path, handler, { csrf?, trustedOrigins?, trustProxy?, rateLimit? })` (`rateLimit: { max, windowMs, key? }` answers `429` with `Retry-After` before the handler past `max` per window, per `ctx.ip` or `key(ctx)`; responses get the security headers; an HTML one without its own CSP gets the app's, its `<style>` blocks hashed), `provide(key, value)`/`inject(key)` typed by `serviceKey<T>(name)` from `prunelle/config`, `getBuildData`), `onError(info)`, `build(ctx)` (`emitAsset`, `emitPublic`, `addStyle`, `addRouteStyle`, `addHead`, `addRouteHead`, `provide`, `inject`, `setData`, `routes`), `afterPrerender(ctx)` (`routes`, `publicFiles`, `emitAsset`, `emitPublic`, `setData`), `transform`, `bunPlugins` (array or `({ root, assetPrefix, minify, target }) => [...]`), `css`, `head(head, ctx)`, `transformHtml`, `inlineScripts` (the inline scripts the plugin writes into pages, each as it stands between its tags: the CSP of every page allows them by hash, since prunelle never hashes a script it finds in a page), `prerenderPaths`, `clientEntry`, `check(ctx)`, `requires({ root, site })` (one message per setting the plugin needs in production, naming it and its fix: a production start (`NODE_ENV=production`, not `prunelle dev`) refuses while any is unmet, listing them all; `prunelle dev`, tests and `prunelle check` warn once each; a throwing `requires` counts as unmet; first-party: auth refuses an in-memory store, mail a missing transport or `from`, mcp a missing `token`, seo and a content feed a missing `site`), `watchPaths`, `commands`.
107
+ - `server(api)`: `use(mw, { scope? })` (`'all'` default, prerendered pages included; `'rendered'` skips prerendered pages, for middleware that only feeds rendering such as a session; `'dynamic'` also skips pages with no `load`; or a path prefix), `rewrite` (also run once per prerendered page at start, on an anonymous GET: no side effects), `healthCheck(name, fn)` (feeds `/_pru/health`; returning `false` or throwing turns it `503`), `provide(key, value)`/`inject(key)` typed by `serviceKey<T>(name)` from `prunelle/config`, `getBuildData`.
108
+ - `api.route(method, path, handler, { csrf?, trustedOrigins?, trustProxy?, rateLimit?, encodedSlashes? })`: `rateLimit: { max, windowMs, key? }` answers `429` with `Retry-After` before the handler past `max` per window, per `ctx.ip` or `key(ctx)`; `encodedSlashes: true` lets a `*name` catch-all take a segment holding `%2F`, `%5C` or `%00`, left encoded in the param, for text such as a URL, never a file path (on a path with no catch-all it throws). Responses get the security headers; an HTML one without its own CSP gets the app's, its `<style>` blocks hashed.
31
109
  - `api.rateLimiter({ max, windowMs })` returns a limiter in the server's store (bounded to 10 000 keys and 1 000 000 hits, swept every minute, dropped with the server) for a limit a route option cannot key, such as per email: `hit(key)` returns 0, or the whole seconds to wait.
32
- - Runtime state (timers, connections, caches) is created in `server(api)` and released in `api.onShutdown()`, never in the plugin factory (a throwing `onShutdown` or `onError` hook is logged with its plugin's name; the others still run): `prunelle dev` starts the next server on the same instance before shutting the last one down, and a new process on a `prunelle.config.ts` edit.
33
- - First-party packages (13 total with `prunelle`; each ships its full reference at `node_modules/@prunellejs/<name>/llms.txt`):
34
- - `@prunellejs/ui` (`node_modules/@prunellejs/ui/llms.txt`): Zero-JS layout/form primitives (`Stack`, `Cluster`, `Grid`, `Sidebar`, `Split`, `Button`, `Card`, `Badge`, `Notice`, `Field`, `Switch`, `Checkbox`, `RadioGroup`, `Progress`, `Accordion`, `Popover`), island widgets (`Dialog`, `Drawer`, `Tabs`, `Menu`, `Select`, `CommandPalette`, `DataTable`, `Toaster` + `toast()`), `@layer kui` Style Grammars (`prunelle`, `orbit`, `editorial`, `workshop`, `console`, `soft`, `bare`), `prunelle ui-eject`.
35
- - `@prunellejs/auth` (`node_modules/@prunellejs/auth/llms.txt`): Argon2id passwords, hashed sessions, email verification (`requireEmailVerification: true`), magic links, OAuth 2.0 + PKCE, `auth.guard()`, RGPD helpers (`listSessions`, `exportUser`, `deleteUser`), `memoryAuthStore()` & `sqliteAuthStore()`.
36
- - `@prunellejs/content` (`node_modules/@prunellejs/content/llms.txt`): Zero-dep `Bun.markdown` + `Bun.YAML` collections, Standard Schema frontmatter, lazy `entry.render()` (`highlight`, MDX-lite `components`, `headingLinks`), auto-wired `@prunellejs/images`, localized collections, TOC, and RSS feeds (`content({ feeds })`).
37
- - `@prunellejs/live` (`node_modules/@prunellejs/live/llms.txt`): Typed SSE rooms (`createRooms()`), `publish()`, microtask `coalesce()`, `rooms.stream()`, and browser `useLive()` hook (`@prunellejs/live/client`).
38
- - `@prunellejs/mcp` (`node_modules/@prunellejs/mcp/llms.txt`): MCP Streamable HTTP (`2025-03-26`) exposing `action()`/handlers & compacted Standard JSON Schemas at `/mcp/tools` with bearer auth, `schemas`/`schemaRef`, `resources`, `formatLines`/`formatTable`, `budget`, and `prunelle mcp-footprint`.
39
- - `@prunellejs/images` (`node_modules/@prunellejs/images/llms.txt`): Build-time AVIF/WebP pipeline + disk cache (`images()`, `image()`, `<Picture>`, `optimizeImageFile()`) and 1200×630 PNG OG `shareCard()`.
40
- - `@prunellejs/seo` (`node_modules/@prunellejs/seo/llms.txt`): `titleTemplate`, localized `description`, canonical URLs, OG/Twitter/`jsonLd()`, i18n-aware `sitemap.xml`, redirects, manifest, favicons, and self-hosted fonts.
41
- - `@prunellejs/i18n` (`node_modules/@prunellejs/i18n/llms.txt`): Locale URL rewriting (`ctx.locals.locale`/`t`/`localize`/`alternates`), `<html lang>` + internal link prefixing (`data-no-localize`), `prerenderPaths`, `hreflang`, `Intl` formatters, `prunelle i18n-check`.
42
- - `@prunellejs/icons` (`node_modules/@prunellejs/icons/llms.txt`): Virtual `~icons/<set>/<name>` & `src/icons` (`~icons/local/<name>`) inline SVG imports + accessible `<Icon>`, `icons()` from `@prunellejs/icons/plugin`, `prunelle icons-find`, and server-only `@prunellejs/icons/search`.
43
- - `@prunellejs/mail` (`node_modules/@prunellejs/mail/llms.txt`): `createMailer()`, `resend()` HTTP or custom transport, and dev-only `/_pru/mail` (+ `.json`) outbox preview.
44
- - `@prunellejs/tailwind` (`node_modules/@prunellejs/tailwind/llms.txt`): Tailwind v4 via `tailwind()` (auto-loads `bun-plugin-tailwind`, defaults `css: 'src/app.css'`).
45
- - `@prunellejs/spa` (`node_modules/@prunellejs/spa/llms.txt`): `regions()` (`refreshRegion()` from `@prunellejs/spa/regions`) for `<Region>` swaps and opt-in `spa()` full-page navigation with `[data-persist]` islands and `[data-pru-prefetch]`.
46
- - **Server builds & `--compile`**: `prunelle build` writes a stage folder beside `outDir` and renames it in only once every step (bundles, plugin hooks, prerender, `--compile`) passed, so a failed build leaves the previous `outDir` byte-identical and a running `prunelle start` keeps serving it; once a build lands, `prunelle start` loads it in-process with no restart (requests arriving meanwhile wait for it, plugin `server()` runs again and the old build's `api.onShutdown()` hooks run, a build that fails to load is logged and the old one keeps answering, a new port/host/`maxRequestBodySize` needs a restart), and a file it can no longer read answers `404` `no-store`; the hashed client files the previous build made and this one dropped are hard-linked in (`manifest.carriedAssets`, never linked from a page) and served one more deploy, by `prunelle start`, a `--static` export and `--compile`, so a page loaded before the deploy still loads its deferred island chunks; each build is marked with `.prunelle-output`, and a folder holding files prunelle did not build is refused by name (an empty one or an unmarked older prunelle build is replaced). Server `Bun.build` keeps npm dependencies external (`packages: 'external'`) while compiling `@prunellejs/*` TSX packages; `prunelle build --compile` bundles everything + `public/` assets (`with { type: "file" }`) into one standalone Bun executable (`NODE_ENV` defaults to `production`). `prunelle start` and compiled binaries stop gracefully on `SIGTERM`/`SIGINT`/`SIGHUP`: no new connections, `api.onShutdown()` hooks run (`@prunellejs/live` ends its streams), exit 0 once in-flight requests answer, exit 1 after 10 s.
110
+ - Build hooks: `build(ctx)` (`emitAsset`, `emitPublic`, `addStyle`, `addRouteStyle`, `addHead`, `addRouteHead`, `provide`, `inject`, `setData`, `routes`), `afterPrerender(ctx)` (`routes`, `publicFiles`, `assets`, `emitAsset`, `emitPublic`, `setData`), `transform`, `bunPlugins` (array or `({ root, assetPrefix, minify, target }) => [...]`), `css`, `prerenderPaths`, `clientEntry`, `regionClientEntry`, `watchPaths`, `commands`.
111
+ - Page hooks: `head(head, ctx)`, `transformHtml`, `inlineScripts` (the inline scripts the plugin writes into pages, each as it stands between its tags: every page's CSP allows them by hash, since prunelle never hashes a script it finds in a page), `onError(info)` (`{ error, request, source, requestId }`), `check(ctx)`.
112
+ - `requires({ root, site })` returns one message per setting the plugin needs in production, naming it and its fix: a production start (`NODE_ENV=production`, not `prunelle dev`) refuses while any is unmet, listing them all; `prunelle dev`, tests and `prunelle check` warn once each; a throwing `requires` counts as unmet. First-party: auth refuses an in-memory store, jobs an in-memory DB, files `memoryFiles()` or a missing signing secret, mail a missing transport or `from`, mcp a missing `token`, seo and a content feed a missing `site`.
113
+ - Runtime state (timers, connections, caches) is created in `server(api)` and released in `api.onShutdown()`, never in the plugin factory: `prunelle dev` starts the next server on the same instance before shutting the last one down, and a new process on a `prunelle.config.ts` edit. A throwing `onShutdown` or `onError` hook is logged with its plugin's name; the others still run.
114
+ - First-party packages (19 total with `prunelle`), each with its full reference:
115
+ - `@prunellejs/ui` (`node_modules/@prunellejs/ui/llms.txt`): zero-JS layout, form and overlay primitives, island widgets (`Tabs`, `Menu`, `Select`, `CommandPalette`, `DataTable`, `toast()`), `@layer kui` Style Grammars, `prunelle ui-eject`.
116
+ - `@prunellejs/auth` (`node_modules/@prunellejs/auth/llms.txt`): Argon2id passwords, hashed sessions, email verification, magic links, OAuth 2.0 + PKCE, TOTP 2FA with recovery codes, passkeys (`@prunellejs/auth/passkey`), organizations & `auth.guard({ org, role })`, RGPD export and deletion, `sqliteAuthStore()`.
117
+ - `@prunellejs/jobs` (`node_modules/@prunellejs/jobs/llms.txt`): durable `bun:sqlite` job queues (`createJobs()`), Standard Schema input validation, dedup keys, retries/backoff, single-process cron `schedule()`, graceful `onShutdown()` drain, and `drainJobs()` test helper.
118
+ - `@prunellejs/files` (`node_modules/@prunellejs/files/llms.txt`): file upload storage (`diskFiles`, `s3Files` on Bun's S3Client, `memoryFiles`), magic-byte MIME sniffing, public & expiring HMAC signed URLs, RGPD `deleteWhere(prefix)`, traversal hardening.
119
+ - `@prunellejs/pwa` (`node_modules/@prunellejs/pwa/llms.txt`): offline service worker caching hashed `/_pru/` assets and pages with zero first-visit JS bundle overhead, RFC 8291/8292 Web Push (`pwa.push()`, `@prunellejs/pwa/client`), `prunelle pwa-vapid`, and manifest installability checks.
120
+ - `@prunellejs/content` (`node_modules/@prunellejs/content/llms.txt`): Markdown/YAML file and headless-CMS collections with Standard Schema validation, `entry.render()`, TOC and RSS feeds.
121
+ - `@prunellejs/cms` (`node_modules/@prunellejs/cms/llms.txt`): dev-only schema-driven CMS at `/_pru/cms` with in-page editing of content collections; 0 B in production.
122
+ - `@prunellejs/search` (`node_modules/@prunellejs/search/llms.txt`): build-time per-locale site search, a zero-JS `GET /search` page and a lazy client for `CommandPalette`.
123
+ - `@prunellejs/analytics` (`node_modules/@prunellejs/analytics/llms.txt`): CNIL-compliant cookie-free server-side audience measurement (Plausible, Umami, Matomo or custom), `trackEvent()`.
124
+ - `@prunellejs/live` (`node_modules/@prunellejs/live/llms.txt`): typed SSE rooms (`createRooms()`, `publish()`) and the browser `useLive()` hook.
125
+ - `@prunellejs/mcp` (`node_modules/@prunellejs/mcp/llms.txt`): MCP Streamable HTTP server exposing actions and handlers as tools, `prunelle mcp-footprint`.
126
+ - `@prunellejs/images` (`node_modules/@prunellejs/images/llms.txt`): build-time AVIF/WebP pipeline, `<Picture>`, `shareCard()` OG images.
127
+ - `@prunellejs/seo` (`node_modules/@prunellejs/seo/llms.txt`): title template, canonical URLs, OG/Twitter/`jsonLd()`, `sitemap.xml`, redirects, manifest, favicons, self-hosted fonts and SEO checks.
128
+ - `@prunellejs/i18n` (`node_modules/@prunellejs/i18n/llms.txt`): locale URLs (`ctx.locals.locale`/`t`/`localize`), `hreflang`, `Intl` formatters, `prunelle i18n-check`.
129
+ - `@prunellejs/icons` (`node_modules/@prunellejs/icons/llms.txt`): `~icons/<set>/<name>` inline SVG imports, accessible `<Icon>`, `prunelle icons-find`.
130
+ - `@prunellejs/mail` (`node_modules/@prunellejs/mail/llms.txt`): `createMailer()`, TSX email components, `MAIL_URL` (SMTP, Resend, Postmark), dev outbox at `/_pru/mail`.
131
+ - `@prunellejs/tailwind` (`node_modules/@prunellejs/tailwind/llms.txt`): Tailwind v4 via `tailwind()`.
132
+ - `@prunellejs/spa` (`node_modules/@prunellejs/spa/llms.txt`): `regions()` for `<Region>` swaps and opt-in `spa()` full-page navigation with `[data-persist]` islands.
133
+ - **Server builds & `--compile`**:
134
+ - `prunelle build` writes a stage folder beside `outDir` and renames it in only once every step (bundles, plugin hooks, prerender, `--compile`) passed, so a failed build leaves the previous `outDir` byte-identical and a running `prunelle start` keeps serving it. Each build is marked with `.prunelle-output`; a folder holding files prunelle did not build is refused by name (an empty one or an unmarked older prunelle build is replaced).
135
+ - Once a build lands, `prunelle start` loads it in-process with no restart: requests arriving meanwhile wait for it, plugin `server()` runs again and the old build's `api.onShutdown()` hooks run, a build that fails to load is logged while the old one keeps answering, and a new port/host/`maxRequestBodySize` needs a restart. A file it can no longer read answers `404` `no-store`.
136
+ - The hashed client files the previous build made and this one dropped are hard-linked in (`manifest.carriedAssets`, never linked from a page) and served one more deploy, by `prunelle start`, a `--static` export and `--compile`, so a page loaded before the deploy still loads its deferred island chunks.
137
+ - Server `Bun.build` keeps npm dependencies external (`packages: 'external'`) while compiling `@prunellejs/*` TSX packages; `prunelle build --compile` bundles everything + `public/` assets (`with { type: "file" }`) into one standalone Bun executable (`NODE_ENV` defaults to `production`).
138
+ - `prunelle start` and compiled binaries stop gracefully on `SIGTERM`/`SIGINT`/`SIGHUP`: no new connections, `api.onShutdown()` hooks run (`@prunellejs/live` ends its streams), exit 0 once in-flight requests answer, exit 1 after 10 s.
47
139
 
48
140
  ## Canonical Snippets
49
141
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prunelle",
3
- "version": "0.1.1",
3
+ "version": "0.6.0",
4
4
  "description": "Bun-native TSX web framework with zero-directive automatic islands, fine-grained signals, and single-binary deploys",
5
5
  "license": "MIT",
6
6
  "homepage": "https://prunelle.kaynooo.fr",
@@ -12,7 +12,8 @@
12
12
  "files": [
13
13
  "src",
14
14
  "templates",
15
- "llms.txt"
15
+ "llms.txt",
16
+ "ts-plugin.cjs"
16
17
  ],
17
18
  "exports": {
18
19
  ".": "./src/index.ts",
@@ -20,6 +21,7 @@
20
21
  "./config": "./src/plugins/public.ts",
21
22
  "./test": "./src/test/index.ts",
22
23
  "./build": "./src/build/index.ts",
24
+ "./ts-plugin": "./ts-plugin.cjs",
23
25
  "./jsx-runtime": "./src/jsx-runtime.ts",
24
26
  "./jsx-dev-runtime": "./src/jsx-runtime.ts",
25
27
  "./internal/dom": "./src/dom/index.ts",
@@ -45,9 +47,13 @@
45
47
  "oxc-parser": "^0.155.0"
46
48
  },
47
49
  "peerDependencies": {
50
+ "axe-core": "^4.14.0",
48
51
  "playwright-core": "^1.64.0"
49
52
  },
50
53
  "peerDependenciesMeta": {
54
+ "axe-core": {
55
+ "optional": true
56
+ },
51
57
  "playwright-core": {
52
58
  "optional": true
53
59
  }