prunelle 0.0.0-stage → 0.7.2

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 (222) hide show
  1. package/LICENSE +21 -0
  2. package/llms.txt +245 -0
  3. package/package.json +62 -4
  4. package/src/a11y/declaration.ts +373 -0
  5. package/src/a11y/index.ts +477 -0
  6. package/src/a11y/rgaa-map.ts +230 -0
  7. package/src/ambient.d.ts +6 -0
  8. package/src/attrs.ts +43 -0
  9. package/src/build/bundle.ts +661 -0
  10. package/src/build/byte-size.ts +11 -0
  11. package/src/build/carry.ts +57 -0
  12. package/src/build/client-entries.ts +107 -0
  13. package/src/build/client-plugin.ts +175 -0
  14. package/src/build/client-prune.ts +168 -0
  15. package/src/build/compile.ts +130 -0
  16. package/src/build/ecoindex.ts +238 -0
  17. package/src/build/files.ts +171 -0
  18. package/src/build/first-load.ts +235 -0
  19. package/src/build/graph.ts +237 -0
  20. package/src/build/index.ts +678 -0
  21. package/src/build/is-inside.ts +12 -0
  22. package/src/build/island-promote.ts +311 -0
  23. package/src/build/islands.ts +452 -0
  24. package/src/build/manifest.ts +204 -0
  25. package/src/build/output.ts +81 -0
  26. package/src/build/plugin-host.ts +294 -0
  27. package/src/build/precompress.ts +139 -0
  28. package/src/build/prerender.ts +288 -0
  29. package/src/build/reach.ts +200 -0
  30. package/src/build/render-rules.ts +205 -0
  31. package/src/build/report.ts +290 -0
  32. package/src/build/resolve.ts +52 -0
  33. package/src/build/routes.ts +342 -0
  34. package/src/build/server-entry.ts +38 -0
  35. package/src/build/static-headers.ts +112 -0
  36. package/src/build/static.ts +209 -0
  37. package/src/build/status-pages.ts +127 -0
  38. package/src/build/style-bundles.ts +526 -0
  39. package/src/cli/check-forms.ts +636 -0
  40. package/src/cli/check-imports.ts +31 -0
  41. package/src/cli/check-links.ts +632 -0
  42. package/src/cli/check-security.ts +64 -0
  43. package/src/cli/check.ts +409 -0
  44. package/src/cli/commands.ts +372 -0
  45. package/src/cli/docs.ts +403 -0
  46. package/src/cli/index.ts +70 -0
  47. package/src/cli/inspect.ts +406 -0
  48. package/src/cli/mcp-tools.ts +492 -0
  49. package/src/cli/mcp.ts +205 -0
  50. package/src/cli/new.ts +52 -0
  51. package/src/cli/render.ts +416 -0
  52. package/src/cli/upgrade-names.ts +209 -0
  53. package/src/cli/upgrade.ts +367 -0
  54. package/src/compiler/analyze.ts +651 -0
  55. package/src/compiler/ast.ts +82 -0
  56. package/src/compiler/browser-globals.ts +250 -0
  57. package/src/compiler/cacheability-private.ts +566 -0
  58. package/src/compiler/cacheability.ts +335 -0
  59. package/src/compiler/compliance-eco.ts +71 -0
  60. package/src/compiler/compliance-rgaa.ts +614 -0
  61. package/src/compiler/compliance-urls.ts +148 -0
  62. package/src/compiler/compliance.ts +653 -0
  63. package/src/compiler/data-keys.ts +302 -0
  64. package/src/compiler/dev-source.ts +87 -0
  65. package/src/compiler/dom-attrs.ts +452 -0
  66. package/src/compiler/dom.ts +641 -0
  67. package/src/compiler/emit.ts +131 -0
  68. package/src/compiler/expr-context.ts +587 -0
  69. package/src/compiler/foreign-imports.ts +88 -0
  70. package/src/compiler/index.ts +8 -0
  71. package/src/compiler/interactivity.ts +366 -0
  72. package/src/compiler/mistakes.ts +520 -0
  73. package/src/compiler/node-env.ts +50 -0
  74. package/src/compiler/patch.ts +97 -0
  75. package/src/compiler/props-body.ts +60 -0
  76. package/src/compiler/props.ts +511 -0
  77. package/src/compiler/scope.ts +635 -0
  78. package/src/compiler/server-only.ts +365 -0
  79. package/src/compiler/shared.ts +397 -0
  80. package/src/compiler/signal-reads.ts +246 -0
  81. package/src/compiler/slots.ts +227 -0
  82. package/src/compiler/spread-handlers.ts +295 -0
  83. package/src/compiler/ssr-helpers.ts +555 -0
  84. package/src/compiler/ssr-island.ts +90 -0
  85. package/src/compiler/ssr-prunelle-tags.ts +69 -0
  86. package/src/compiler/ssr.ts +525 -0
  87. package/src/context.ts +199 -0
  88. package/src/dev/child.ts +30 -0
  89. package/src/dev/error-log.ts +177 -0
  90. package/src/dev/host-check.ts +32 -0
  91. package/src/dev/index.ts +268 -0
  92. package/src/dev/modules.ts +68 -0
  93. package/src/dev/open-editor.ts +228 -0
  94. package/src/dev/protocol.ts +24 -0
  95. package/src/dev/queue.ts +79 -0
  96. package/src/dev/reload.ts +159 -0
  97. package/src/dev/supervisor.ts +212 -0
  98. package/src/dev/watchers.ts +276 -0
  99. package/src/dom/action.ts +187 -0
  100. package/src/dom/attrs.ts +84 -0
  101. package/src/dom/claim.ts +120 -0
  102. package/src/dom/extras.ts +579 -0
  103. package/src/dom/index.ts +329 -0
  104. package/src/dom/island.ts +318 -0
  105. package/src/dom/loop.ts +484 -0
  106. package/src/dom/revive.ts +36 -0
  107. package/src/eco/declaration.ts +328 -0
  108. package/src/eco/index.ts +69 -0
  109. package/src/index.ts +22 -0
  110. package/src/jsx-runtime.ts +566 -0
  111. package/src/plugins/config.ts +92 -0
  112. package/src/plugins/context.ts +109 -0
  113. package/src/plugins/index.ts +14 -0
  114. package/src/plugins/load.ts +90 -0
  115. package/src/plugins/order.ts +148 -0
  116. package/src/plugins/public.ts +15 -0
  117. package/src/plugins/requires.ts +47 -0
  118. package/src/plugins/services.ts +119 -0
  119. package/src/plugins/types.ts +278 -0
  120. package/src/reactivity/graph.ts +259 -0
  121. package/src/reactivity/index.ts +541 -0
  122. package/src/reactivity/selector.ts +78 -0
  123. package/src/reactivity/store.ts +252 -0
  124. package/src/server/action-flash.ts +158 -0
  125. package/src/server/action-protect.ts +199 -0
  126. package/src/server/action-registry.ts +78 -0
  127. package/src/server/action.ts +511 -0
  128. package/src/server/app-entry.ts +23 -0
  129. package/src/server/app-secret.ts +63 -0
  130. package/src/server/assets.ts +168 -0
  131. package/src/server/compress.ts +646 -0
  132. package/src/server/consent.ts +290 -0
  133. package/src/server/cookies.ts +153 -0
  134. package/src/server/document.ts +286 -0
  135. package/src/server/env.ts +47 -0
  136. package/src/server/errors.ts +396 -0
  137. package/src/server/form-schema.ts +337 -0
  138. package/src/server/health.ts +275 -0
  139. package/src/server/http.ts +588 -0
  140. package/src/server/index.ts +615 -0
  141. package/src/server/lifecycle.ts +75 -0
  142. package/src/server/loader.ts +131 -0
  143. package/src/server/page.ts +122 -0
  144. package/src/server/param-matchers.ts +112 -0
  145. package/src/server/plugin-host.ts +267 -0
  146. package/src/server/prerendered.ts +71 -0
  147. package/src/server/public.ts +20 -0
  148. package/src/server/rate-limit.ts +199 -0
  149. package/src/server/region.ts +96 -0
  150. package/src/server/request-body.ts +27 -0
  151. package/src/server/request-path.ts +73 -0
  152. package/src/server/request-scope.ts +22 -0
  153. package/src/server/route-cache.ts +541 -0
  154. package/src/server/route-table.ts +424 -0
  155. package/src/server/router.ts +261 -0
  156. package/src/server/routing.ts +388 -0
  157. package/src/server/sanitize-html.ts +309 -0
  158. package/src/server/security.ts +550 -0
  159. package/src/server/serve-handlers.ts +93 -0
  160. package/src/server/served-file.ts +128 -0
  161. package/src/server/standard-schema.ts +104 -0
  162. package/src/server/start.ts +143 -0
  163. package/src/server/static-dir.ts +246 -0
  164. package/src/server/stream.ts +233 -0
  165. package/src/ssr/consent-banner.ts +58 -0
  166. package/src/ssr/context.ts +399 -0
  167. package/src/ssr/index.ts +624 -0
  168. package/src/ssr/navigation.ts +96 -0
  169. package/src/ssr/region.ts +192 -0
  170. package/src/style.ts +96 -0
  171. package/src/test/browser.ts +201 -0
  172. package/src/test/index.ts +262 -0
  173. package/src/ts-plugin/diagnostics.ts +505 -0
  174. package/src/ts-plugin/fixes.ts +364 -0
  175. package/src/ts-plugin/index.ts +194 -0
  176. package/src/unrenderable.ts +35 -0
  177. package/templates/_shared/AGENTS.md +10 -0
  178. package/templates/_shared/CLAUDE.md +1 -0
  179. package/templates/_shared/gitignore +8 -0
  180. package/templates/_shared/mcp.json +11 -0
  181. package/templates/_shared/public/robots.txt +2 -0
  182. package/templates/_shared/src/routes/legal.tsx +22 -0
  183. package/templates/_shared/tsconfig.json +25 -0
  184. package/templates/app/.env.example +8 -0
  185. package/templates/app/package.json +22 -0
  186. package/templates/app/prunelle.config.ts +13 -0
  187. package/templates/app/src/auth.ts +12 -0
  188. package/templates/app/src/mail.ts +4 -0
  189. package/templates/app/src/routes/_layout.tsx +40 -0
  190. package/templates/app/src/routes/dashboard/_middleware.ts +3 -0
  191. package/templates/app/src/routes/dashboard/index.tsx +47 -0
  192. package/templates/app/src/routes/index.tsx +15 -0
  193. package/templates/app/src/routes/login.tsx +53 -0
  194. package/templates/app/src/routes/privacy.tsx +25 -0
  195. package/templates/app/src/styles/app.css +14 -0
  196. package/templates/app/tests/app.test.ts +73 -0
  197. package/templates/blog/content/posts/welcome.md +9 -0
  198. package/templates/blog/package.json +22 -0
  199. package/templates/blog/prunelle.config.ts +23 -0
  200. package/templates/blog/src/posts.ts +26 -0
  201. package/templates/blog/src/routes/_layout.tsx +25 -0
  202. package/templates/blog/src/routes/blog/[slug].tsx +31 -0
  203. package/templates/blog/src/routes/index.tsx +33 -0
  204. package/templates/blog/src/styles/app.css +15 -0
  205. package/templates/fullstack/package.json +19 -0
  206. package/templates/fullstack/prunelle.config.ts +6 -0
  207. package/templates/fullstack/src/actions/greet.ts +19 -0
  208. package/templates/fullstack/src/components/Counter.tsx +10 -0
  209. package/templates/fullstack/src/components/GreetForm.tsx +28 -0
  210. package/templates/fullstack/src/routes/_layout.tsx +18 -0
  211. package/templates/fullstack/src/routes/api/health.ts +5 -0
  212. package/templates/fullstack/src/routes/index.tsx +13 -0
  213. package/templates/fullstack/src/styles/app.css +39 -0
  214. package/templates/fullstack/tests/app.test.ts +37 -0
  215. package/templates/minimal/package.json +19 -0
  216. package/templates/minimal/prunelle.config.ts +6 -0
  217. package/templates/minimal/src/components/Counter.tsx +10 -0
  218. package/templates/minimal/src/routes/_layout.tsx +18 -0
  219. package/templates/minimal/src/routes/index.tsx +11 -0
  220. package/templates/minimal/src/styles/app.css +32 -0
  221. package/ts-plugin.cjs +4277 -0
  222. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kaynooo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/llms.txt ADDED
@@ -0,0 +1,245 @@
1
+ # Prunelle Reference (for humans & coding agents)
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. 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`, `ConsentBanner`, `ConsentPreferences`, `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' }}`; an object drops a value that would end its declaration, and `NaN`), 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, a hook or signal imported from `react`, `preact`, `solid-js`, `vue` or `svelte` (the fix names the prunelle form), an import that resolves to nothing (`prunelle check`), `<slot>` (take `children`), a leading `---` frontmatter block, `'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.
24
+ - **Reactive props**: Destructuring props (`function Badge({ count = 0, ...rest }: Props)`) stays reactive in client components (in the parameter list only: `const { a } = props` in the body reads once, and a browser component doing it is warned), 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>`.
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 removes the server nodes no list row claimed (mid-list or past the last row), in production too (dev also warns), and dispatches a bubbling `pru:hydration-mismatch` event (`detail: { removed, added }`) on the list's parent, which reaches the island.
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. `idle` islands hydrate within 2 s; an `interaction` island whose chunk fails to load logs the error and retries on the next interaction, replaying it; a chunk URL off this origin is refused with a console error. A delegated handler that throws is reported with `reportError` and the other handlers still run; `onTouchStart` is delegated from the document, which browsers make passive so scrolling never waits on it: a handler that must `preventDefault` adds its own listener in `onMount` with `{ passive: false }`.
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
+ - A page island receives only the `load()` keys it reads. When the compiler cannot tell which (`data` passed whole to a helper or a child), the whole result is sent and build and check warn: `export const clientData = ['key']` or `(data) => subset` picks what is sent.
34
+ - An `on*` function passed from server code to a component that is not an island fails build and check, since it would never run.
35
+ - 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'`.
36
+ - 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.
37
+ - **Routes (`src/routes/`)**:
38
+ - `export default async function Page({ params, locals, url })`: strictly server-only (`0 KB` JS; cannot use signals/handlers directly).
39
+ - 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).
40
+ - 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`.
41
+ - `_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).
42
+ - 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 `_`.
43
+ - 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 `/`).
44
+ - 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`.
45
+ - 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`).
46
+ - 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(location, status?, { external? })`, `deny()`). `redirect()` stays on this site: a target on another origin throws unless `{ external: true }`, so never pass one read from the request. 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).
47
+ - 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`, and so does a listed URL that answered other than `200` at build, which the build warns about). 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`.
48
+ - 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=...` (`private, no-cache` under an app `_middleware.ts`, which may gate it; the server cache still serves it behind the middleware), with a weak `ETag` that a matching `If-None-Match` turns into a `304`. Its key leaves out `utm_*`, `gclid`, `gbraid`, `wbraid`, `dclid`, `fbclid`, `msclkid`, `mc_cid` and `mc_eid`, so a campaign link reuses the entry (a page showing them reads them uncached). A cached route (or its layout `load()` or imported local modules) reading `ctx.cookies`, `ctx.locals`, `ctx.consent`, `ctx.ip`, `Cookie`/`Authorization` or dynamic/bulk headers, `getActionError()`, `<ConsentGate>`, or passing `ctx`/`props`/`request` to a helper that does (or cannot be followed) fails `prunelle check` and `prunelle build` naming the read; at runtime the route cache also refuses to store any render that reads private request data.
49
+ - **Streaming & Head**: `<Head><title>...</title></Head>` (innermost `<title>` wins). A page with no `<link rel="icon">` and no `public/favicon.ico` gets `<link rel="icon" href="data:,">`, so no `/favicon.ico` 404.
50
+ - `<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`.
51
+ - `<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.
52
+ - **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`.
53
+ - **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?)`.
54
+ - Zero-JS form: `<form action={fn} method="post">`. Array fields are coerced from checkboxes/multi-selects (`name="tags"` or `name="tags[]"` always parses as an array `tags`, and dotted names like `name="address.city"` parse into nested objects `{ address: { city } }`). 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)` (the flash is signed with `PRUNELLE_FORM_SECRET` or `AUTH_SECRET`; its `values` are the fields the action schema declares, minus secrets such as password, token, card or `format: "password"`, or exactly `flashFields`; a schema with no JSON Schema output declares none, so list `flashFields`), and redirects `303` to the trusted Referer.
55
+ - `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, fast submits and timestamps older than two hours with `400` and the one message `Submission rejected` before the handler runs. Set `PRUNELLE_FORM_SECRET` or `AUTH_SECRET` in production when using `minTime`, else Prunelle logs a warning when the action is defined (the key is derived from it with HKDF). A `minTime` form an island renders only in the browser has no timestamp and is refused (`prunelle dev` says so): render it on the first render, hidden until needed. The timestamp is signed per request, so a `minTime` form on a page exporting `prerender = true` or `cache` fails `prunelle check` and `prunelle build` (`action/min-time-frozen`), a `--static` export of one fails the build, and `autoPrerender` leaves such a page to render at request time.
56
+ - `prunelle check` and `prunelle build` report unknown form fields with the closest name (a schema taking extra keys through `additionalProperties` or `patternProperties` accepts those), missing required fields, invalid `<select>` enum options, unsupported schema libraries (once per vendor) and unguarded public form actions without `protect`.
57
+ - 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 (to another site only for `ctx.redirect(url, status, { external: true })`; any other cross-site target fails with `Redirect to another site refused`).
58
+ - 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.
59
+ - 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.
60
+ - 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.
61
+ - **Config (`prunelle.config.ts`)**: `defineConfig({ site, lang, port, routesDir, outDir, publicDir, assetPrefix, security, trustedOrigins, trustProxy, maxRequestBodySize, navigation, routeCache, autoPrerender, streamTimeout, consent, compliance, budget, compress, healthCheck, onError, plugins })`. `trustProxy: true | number` trusts that many right-most proxy hops for `X-Forwarded-*` (an https `site` makes cookies `Secure` and sends HSTS without it; production warns once on `X-Forwarded-Proto` while it is off, and once on the first POST refused as `untrusted origin`, naming the Origin, the origin the server computed, `trustProxy` and `trustedOrigins`); `prunelle start` in production notices when it binds loopback (the default; `HOST` or `--host 0.0.0.0` opens it for a container); `maxRequestBodySize` defaults to `1 MiB`. `lang` sets `<html lang>` and the language of `@prunellejs/ui`'s built-in labels (`'fr'` or `'fr-*'` gives French ones); with no `lang` and no `@prunellejs/i18n`, `prunelle check` warns `rgaa/document-lang`.
62
+ - **Security headers & CSP**: on by default (`security: false` disables them, or override `csp`, `hsts`, `frameOptions`, `referrerPolicy`, `contentTypeOptions`, `permissionsPolicy`, `crossOriginOpenerPolicy`, `crossOriginResourcePolicy`; the last two default to `same-origin`, and every header also goes on the build-swap `503`). `prunelle check` warns on `security: false`, `csp: false`, `'unsafe-inline'` in a script or style directive and `export const csrf = false` (`security/headers-off`, `csp-off`, `unsafe-inline`, `csrf-off`). 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.
63
+ - `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.
64
+ - 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>`): the build writes the headers that cannot live there from `security` into `dist/_headers` (Netlify, Cloudflare Pages), `dist/prunelle.caddy` (`import` it in a site block) and `dist/prunelle.nginx.conf` (`include` it in a server block), with the exact-path rules of `dist/_redirects` (written by `@prunellejs/seo` `redirects`, or shipped in `public/`) as `redir` and `location =` lines; a file the app ships under those names is kept, and `security: false` writes none.
65
+ - **Observability**: the Bun server (not a `--static` export served by `prunelle start`) answers `/_pru/health` (at `${assetPrefix}/health`): `200 { ok: true }`, or `503` when the app's `healthCheck` or a plugin's `api.healthCheck(name, fn)` fails or takes over 5 s (cached for 5 s; a failure reads `check failed`, the error goes to stderr, `prunelle dev` shows it); `./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).
66
+ - **Server helpers (`prunelle/server`)**:
67
+ - `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).
68
+ - HTML escaping: `raw`, `esc`, `escAttr`, `escJson` (JSON text for a `<script>`), `escXml` (text for a feed or sitemap: also drops the control characters XML forbids).
69
+ - 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).
70
+ - `createRateLimitStore({ maxKeys?, maxHits? })`: a standalone sliding-window store whose `.limiter({ max, windowMs }).hit(key)` returns 0 or the seconds to wait, and `.peek(key)` the same without counting; plugins use `api.rateLimiter()`. A `rateLimit` with no `key` counts the client's network: an IPv4 address without its port or `::ffff:` mapping, or an IPv6 address's /64; `rateLimitAddress(ip)` gives that key to a custom limiter.
71
+ - Standard Schema: `StandardSchemaV1` (including optional `'~standard'.jsonSchema: { input, output? }` Standard JSON Schema extension), `validateSchema`, `validateSchemaSync`, `formatSchemaIssues`, `formatIssuePath`.
72
+ - `declare module 'prunelle/server' { interface PrunelleLocals { ... } }` types `ctx.locals`; `createServer({ root })` runs a built app inside another program.
73
+ - **French web law & Consent (RGPD, CNIL, RGAA, RGESN, LCEN - 0 B client JS)**: `prunelle check` and production `prunelle build` emit actionable warnings (never hard errors):
74
+ - RGAA: `rgaa/img-alt` (`<img>` without `alt`, or `alt={undefined}`/`alt={false}`, unless `role="presentation"` or `aria-hidden`), `rgaa/form-label` (unlabelled `<input>`/`<select>`/`<textarea>`, or a ui `<Select>` with no `Field`, `<label for>` or `ariaLabel`; a `<Label>` component wraps like `<label>`, and `for={ids.name}` matches `id={ids.name}`), `rgaa/accessible-name` (empty or icon-only `<button>`/`<a>`, `<svg role="img">` without `aria-label` or `<title>`), `rgaa/duplicate-id` (duplicate literal `id` in one component, or a static `id` inside `.map()`), `rgaa/positive-tabindex` (`tabindex > 0`).
75
+ - RGAA structure: `rgaa/nested-control` (interactive element inside `<a>`/`<button>`/`<summary>`), `rgaa/link-as-button` (`<a>` without `href` with `onClick`, or `href="#"` / `javascript:`), `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/role-without-focus` (`role="button"` and other operable roles without `tabIndex`), `rgaa/mouse-only` (`onMouseEnter`/`onMouseOver` without `onFocus`/`onFocusIn`, `onMouseLeave`/`onMouseOut` without `onBlur`/`onFocusOut`), `rgaa/frame-title` (`<iframe>` without `title`), `rgaa/empty-heading`, `rgaa/autocomplete` (email, phone, name or address field without `autocomplete`), `rgaa/autofocus`, `rgaa/meta-refresh`, `rgaa/document-lang` (no `lang` in `prunelle.config.ts` and no `@prunellejs/i18n`, so pages say `<html lang="en">`), and `rgaa/accessibility-statement` (missing `/accessibilite` when `compliance: { publicBody: true }`; on any site, a statement still holding `[à compléter : ...]`).
76
+ - `rgpd/third-party-url`: a third-party `<script src>`, `<link rel="stylesheet|preload|preconnect|dns-prefetch|modulepreload|prefetch|prerender|icon|apple-touch-icon|manifest">`, `<iframe src>`, `<img src/srcset>`, `<video src/poster>`, `<audio>`, `<source>`, `<track>`, `<object data>`, `<embed>`, SVG `<image>`/`<use>`/`<feImage>` `href`, a `style` attribute's `url(...)`, or CSS `@import`/`url(...)` in `src/` or `public/`, outside `<ConsentGate>` or `site`. A string, template literal (its leading text), `a ? b : c` or `a ?? b` value is read; `<ConsentGate category="essential">` always renders, so it gates nothing.
77
+ - RGESN: `rgesn/autoplay` (`<video>`/`<audio>` with `autoplay`), `rgesn/img-size` (`<img>` without both `width` and `height`, unless spread), `rgesn/img-sizes` (a `srcset` of `w` descriptors without `sizes`), `rgesn/large-public-file` (a file in `public/` over 1 MB), `rgesn/declaration` (`/ecoconception` still holding a `[à compléter` placeholder), `rgesn/island-by-value` (an imported island read as a value, `const D = Counter`, `{ C: Counter }` or `c={Counter}`, which hydrates what holds it whole: render `<Counter />` itself).
78
+ - `lcen/legal-notice`: a page app missing `/mentions-legales`, `/legal`, or a localized variant (`/fr/mentions-legales`, `/[lang]/mentions-legales`), or a legal notice still holding a `[to fill in` placeholder.
79
+ - `rgpd/privacy-notice`: a `.tsx` file in `src/` with an `<input>` collecting an email or a phone number (`type="email|tel"` or `name="email|phone|tel"`) while the app has no `/privacy`, `/confidentialite`, `/politique-de-confidentialite` or localized variant, or a privacy notice still holding a `[to fill in` placeholder. The `app` template ships `/privacy` and links it under its sign-up form.
80
+ - Silence per rule with `compliance: { ignore: [...], legalNotice?: string | false, privacyNotice?: string | false, publicBody?: boolean }`, or `// prunelle-ignore <rule>` / `/* prunelle-ignore <rule> */` / `// prunelle-ignore-file <rule>`. The form check's warnings (`action/unguarded-public-form`, `form/invalid-option`, `form/schema-unsupported`, `form/unchecked` for an action module that fails to import) are silenced the same way, the comment going on the line above the `<form>` or `<option>`; its errors cannot be.
81
+ - One-declaration consent: `consent: { categories: ['analytics', 'media'] | { analytics: 'Audience measurement' }, cookieName?: 'pru_consent', maxAge?: 15552000, endpoint?: '/_pru/consent', version?: '2026-11' }` 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, `name="categories" value="analytics"` or `name="analytics"`, gets a `303`, JSON a `200`), exposes `ctx.consent` (`decided`, `decidedAt`, `categories`, `labels`, `endpoint`, `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). The cookie stores the time of the choice and `version`: changing `version` asks every visitor again. `prunelle check` warns (`rgpd/consent-retention`) when `maxAge` is past 180 days, and `prunelle dev` warns once per cookie set with no `category`, which counts as essential.
82
+ - `<ConsentBanner policyHref?="/cookies" title? accept? refuse? choose? save? legend?>{text?}</ConsentBanner>` renders, until the visitor decides, a form with Refuse all and Accept all side by side and the categories (by label) behind a `<details>`; `<ConsentPreferences />` renders the choice in force, to change or withdraw it (put it on the cookie policy page). Both are server-only, private on a cached route, and throw `prunelle: <ConsentBanner> has no consent category to ask about` without `consent.categories`. Markup: `data-ui="consent"` with `data-part` `title`, `body`, `form`, `actions`, `details`, `choices`, `choice`, `preferences`; buttons carry `data-ui="button"`.
83
+ - **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 press (`eagerness: conservative`); 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`.
84
+ - `defineConfig({ navigation: { viewTransitions?: boolean (true), prefetch?: 'conservative' | 'moderate' | 'eager' | false ('conservative'), prerender?: 'conservative' | 'moderate' | 'eager' | boolean (false; true is 'moderate'; it runs `load()` of pages nobody opens) } })`; a bad value throws `prunelle: navigation.<key> is ...`.
85
+ - `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.
86
+ - **Static files & CSS**: Files in `public/` are served at `/` (dotfiles and dot folders stay out of the build except `.well-known/`; `prunelle check` warns `security/public-dotfile`; a plugin `emitAsset`/`emitPublic` path that leaves the output folder throws, naming the plugin) with ETag/`304` (`Cache-Control: no-cache` in `prunelle dev`; embedded in `--static` and `--compile`); prerendered pages (sent with `Cache-Control: no-cache`, so a revisit revalidates) and hashed assets answer an ETag, a `304` and a `HEAD` length too. Import `.css` or `*.module.css` directly from any component or layout.
87
+ - `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.
88
+ - 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.
89
+ - `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.
90
+ - **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.
91
+ - `prunelle new <dir> [--template minimal|fullstack|blog|app] [--force]`: a folder holding only `.git` counts as empty, `--force` prints `prunelle new: overwrote <file>` for each file it replaces; 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/`, `.prunelle-cache/`, `.prunelle-dev/`, `.env` files (`.env.example` kept) and `data/`, where the `app` template's SQLite store lives. Every template's layout renders `<main id="main">` (with a skip link before any header) and a footer linking the legal notice and `src/routes/accessibilite.tsx`, the statement `prunelle new` drafts with its `[à compléter : ...]` for `prunelle check` to flag.
92
+ - `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.
93
+ - `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 }`.
94
+ - `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 (as `cnumr/ecoindex_python` computes them, every image and third-party request of the page counted), 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; `budget: { js?: '40kb', firstLoad?: '500kb' }` in `prunelle.config.ts` (bytes or KB) does the same on every build, `firstLoad` capping the brotli first load, and `--max-js` overrides `budget.js` for one run.
95
+ - `prunelle eco [dir] [--declaration [path]] [--service <name>] [--org <name>] [--contact <email>]`: builds the app and judges the RGESN 2024 criteria prunelle can measure (4.1 autoplay, 4.4 third parties, 6.1 weight cap from `budget.firstLoad`, 6.3 compression, 6.5 unused resources, 6.7 one domain); `--declaration` writes an editable French declaration page (default `src/routes/ecoconception.tsx`) with each prerendered page's EcoIndex, those verdicts and `[à compléter` placeholders for the rest.
96
+ - `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, a folder on neither refused, symbolic links never followed; `sqliteAuthStore()` preserves accounts).
97
+ - Plugin commands: `prunelle a11y [--draft [dest]] [--force] [--audit-date YYYY-MM-DD --rate <percent>] [--json] [--routes /a,/b]` (via `a11y()` from `prunelle/config`; axe-core tags `RGAAv4` + WCAG 2.1 A/AA, each result mapped to its RGAA criterion, axe's `incomplete` results reported as `toCheck`, to check by hand; `--draft` refuses to overwrite an existing statement unless `--force` is given; the draft's level comes from the manual audit only, "non conforme" without one, and `prunelle check` warns about `[à compléter : ...]` left in any published statement), `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`.
98
+ - **CLI (dev, editor & agent tooling)**:
99
+ - `prunelle dev [dir] [--port 3000] [--host [addr]]`: binds loopback `127.0.0.1` by default; answers `421` to a `Host` other than `localhost`, `*.localhost`, an IP address, its `--host` and the hosts of `site` and `trustedOrigins` (against DNS rebinding: add a tunnel's origin to `trustedOrigins`); 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.jsonl`; runs the app in a child process recycled on `prunelle.config.ts` edits or past 2 GB; edits in `public/` reload without rebuilding.
100
+ - `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.
101
+ - `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 }`.
102
+ - `prunelle mcp [dir] [--allow-write]`: stdio MCP server for coding agents exposing `check`, `inspect`, `build_analyze`, `build` (requires `--allow-write`), `render` (a method other than GET, HEAD or OPTIONS requires `--allow-write`), `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.
103
+ - `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).
104
+ - **Testing (`prunelle/test`)**:
105
+ - `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(...)`).
106
+ - 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.
107
+ - 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`, and `_error.tsx` receives that message too, never the thrown one. `prunelle dev` build errors also answer JSON/text per `Accept`.
108
+ - 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.
109
+ - `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()`.
110
+ - **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.
111
+ - 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()`.
112
+ - `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`. `api.dev` is true under `prunelle dev`, and `api.devExposed` when `prunelle dev --host` binds an address other machines reach: a dev-only route that writes or reveals data refuses to start unguarded then.
113
+ - `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.
114
+ - `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; `peek(key)` answers the same without counting, to check a limit that only some outcomes count.
115
+ - 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, lang }) => [...]`), `css`, `prerenderPaths`, `clientEntry`, `regionClientEntry`, `watchPaths`, `commands`.
116
+ - 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)`.
117
+ - `requires({ root, site, consentCategories })` 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`, analytics a consent category `consent.categories` does not declare.
118
+ - 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.
119
+ - First-party packages (19 total with `prunelle`), each with its full reference:
120
+ - `@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`.
121
+ - `@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()`.
122
+ - `@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.
123
+ - `@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.
124
+ - `@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.
125
+ - `@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.
126
+ - `@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.
127
+ - `@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`.
128
+ - `@prunellejs/analytics` (`node_modules/@prunellejs/analytics/llms.txt`): CNIL-compliant cookie-free server-side audience measurement (Plausible, Umami, Matomo or custom), `trackEvent()`.
129
+ - `@prunellejs/live` (`node_modules/@prunellejs/live/llms.txt`): typed SSE rooms (`createRooms()`, `publish()`) and the browser `useLive()` hook.
130
+ - `@prunellejs/mcp` (`node_modules/@prunellejs/mcp/llms.txt`): MCP Streamable HTTP server exposing actions and handlers as tools, `prunelle mcp-footprint`.
131
+ - `@prunellejs/images` (`node_modules/@prunellejs/images/llms.txt`): build-time AVIF/WebP pipeline, `<Picture>`, `shareCard()` OG images.
132
+ - `@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.
133
+ - `@prunellejs/i18n` (`node_modules/@prunellejs/i18n/llms.txt`): locale URLs (`ctx.locals.locale`/`t`/`localize`), `hreflang`, `Intl` formatters, `prunelle i18n-check`.
134
+ - `@prunellejs/icons` (`node_modules/@prunellejs/icons/llms.txt`): `~icons/<set>/<name>` inline SVG imports, accessible `<Icon>`, `prunelle icons-find`.
135
+ - `@prunellejs/mail` (`node_modules/@prunellejs/mail/llms.txt`): `createMailer()`, TSX email components, `MAIL_URL` (SMTP, Resend, Postmark), dev outbox at `/_pru/mail`.
136
+ - `@prunellejs/tailwind` (`node_modules/@prunellejs/tailwind/llms.txt`): Tailwind v4 via `tailwind()`.
137
+ - `@prunellejs/spa` (`node_modules/@prunellejs/spa/llms.txt`): `regions()` for `<Region>` swaps and opt-in `spa()` full-page navigation with `[data-persist]` islands.
138
+ - **Server builds & `--compile`**:
139
+ - `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).
140
+ - 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`.
141
+ - 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.
142
+ - 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`). The binary autoloads neither `.env` nor `bunfig.toml` from its cwd: the host passes the environment (systemd `EnvironmentFile=`, Compose `env_file:`). `PRUNELLE_DEV=1` throws at start inside a binary or with `NODE_ENV=production`.
143
+ - `prunelle start` and compiled binaries stop gracefully on `SIGTERM`/`SIGINT`/`SIGHUP`: no new connections, `api.onShutdown()` hooks run (`@prunellejs/live` ends its streams; a page still streaming `<Suspense>` boundaries ends with its document tail), exit 0 once in-flight requests answer, exit 1 after 10 s.
144
+
145
+ ## Canonical Snippets
146
+
147
+ ### 1. Route with `load()`, `notFound()`, and `<Head>`
148
+
149
+ ```tsx
150
+ // src/routes/posts/[slug].tsx
151
+ import type { PageProps, RouteContext } from 'prunelle'
152
+ import { Head } from 'prunelle'
153
+ import { notFound } from 'prunelle/server'
154
+ import { getPost } from '../../db'
155
+
156
+ export async function load(ctx: RouteContext<'/posts/[slug]'>) {
157
+ const post = await getPost(ctx.params.slug)
158
+ if (!post) return notFound()
159
+ return { post }
160
+ }
161
+
162
+ export default function PostPage({ data }: PageProps<typeof load>) {
163
+ return (
164
+ <article>
165
+ <Head><title>{data.post.title}</title></Head>
166
+ <h1>{data.post.title}</h1>
167
+ </article>
168
+ )
169
+ }
170
+ ```
171
+
172
+ ### 2. Automatic Island (`signal`, `computed`, `useId`)
173
+
174
+ ```tsx
175
+ // src/components/Counter.tsx — becomes an island automatically (no directive)
176
+ import { computed, signal, useId } from 'prunelle'
177
+
178
+ export function Counter({ initial = 0 }: { initial?: number }) {
179
+ const count = signal(initial)
180
+ const doubled = computed(() => count.value * 2)
181
+ const id = useId('counter')
182
+ return (
183
+ <div id={id}>
184
+ <button type="button" onClick={() => count.value++}>Count: {count.value}</button>
185
+ <span> (x2: {doubled.value})</span>
186
+ </div>
187
+ )
188
+ }
189
+ ```
190
+
191
+ ### 3. Server Action & Progressive `useAction()` Form
192
+
193
+ ```ts
194
+ // src/actions/subscribe.ts
195
+ import { action } from 'prunelle/server'
196
+ import { z } from 'zod'
197
+
198
+ export const subscribe = action(z.object({ email: z.string().email() }), async ({ email }) => {
199
+ return { subscribed: email }
200
+ })
201
+ ```
202
+
203
+ ```tsx
204
+ // src/components/SubscribeForm.tsx
205
+ import { useAction } from 'prunelle'
206
+ import { subscribe } from '../actions/subscribe'
207
+
208
+ export function SubscribeForm() {
209
+ const form = useAction(subscribe, { reset: true })
210
+ return (
211
+ <form action={form.action} method="post" onSubmit={form.onSubmit}>
212
+ <input name="email" type="email" required />
213
+ <button type="submit" disabled={form.pending.value}>Join</button>
214
+ {form.fieldErrors.value.email && <p role="alert">{form.fieldErrors.value.email}</p>}
215
+ {form.data.value && <p>Subscribed {form.data.value.subscribed}</p>}
216
+ </form>
217
+ )
218
+ }
219
+ ```
220
+
221
+ ### 4. Config (`prunelle.config.ts`) & In-Process Test (`prunelle/test`)
222
+
223
+ ```ts
224
+ // prunelle.config.ts
225
+ import { defineConfig } from 'prunelle/config'
226
+ import { seo } from '@prunellejs/seo'
227
+ import { auth } from './src/auth'
228
+
229
+ export default defineConfig({
230
+ site: 'https://example.com',
231
+ plugins: [auth, seo({ name: 'Acme', titleTemplate: '%s | Acme' })],
232
+ })
233
+ ```
234
+
235
+ ```ts
236
+ // tests/app.test.ts
237
+ import { expect, test } from 'bun:test'
238
+ import { testApp } from 'prunelle/test'
239
+
240
+ test('home renders', async () => {
241
+ const app = await testApp({ root: '.' })
242
+ const res = await app.get('/')
243
+ expect(res.status).toBe(200)
244
+ })
245
+ ```
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "prunelle",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.7.2",
4
+ "description": "Bun-native TSX web framework with zero-directive automatic islands, fine-grained signals, and single-binary deploys",
5
+ "license": "MIT",
6
+ "homepage": "https://prunelle.kaynooo.fr",
7
+ "type": "module",
8
+ "sideEffects": false,
9
+ "bin": {
10
+ "prunelle": "./src/cli/index.ts"
11
+ },
12
+ "files": [
13
+ "src",
14
+ "templates",
15
+ "!templates/**/node_modules",
16
+ "!templates/**/dist",
17
+ "!templates/**/.prunelle-cache",
18
+ "llms.txt",
19
+ "ts-plugin.cjs"
20
+ ],
21
+ "exports": {
22
+ ".": "./src/index.ts",
23
+ "./server": "./src/server/public.ts",
24
+ "./config": "./src/plugins/public.ts",
25
+ "./test": "./src/test/index.ts",
26
+ "./build": "./src/build/index.ts",
27
+ "./ts-plugin": "./ts-plugin.cjs",
28
+ "./jsx-runtime": "./src/jsx-runtime.ts",
29
+ "./jsx-dev-runtime": "./src/jsx-runtime.ts",
30
+ "./internal/dom": "./src/dom/index.ts",
31
+ "./internal/dom-attrs": "./src/dom/attrs.ts",
32
+ "./internal/dom-claim": "./src/dom/claim.ts",
33
+ "./internal/dom-extras": "./src/dom/extras.ts",
34
+ "./internal/dom-loop": "./src/dom/loop.ts",
35
+ "./internal/action": "./src/dom/action.ts",
36
+ "./internal/island": "./src/dom/island.ts",
37
+ "./internal/ssr": "./src/ssr/index.ts",
38
+ "./internal/server": "./src/server/index.ts"
39
+ },
40
+ "engines": {
41
+ "bun": ">=1.4.0"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/Kayno0o/prunelle",
46
+ "directory": "packages/prunelle"
47
+ },
48
+ "dependencies": {
49
+ "@kaynooo/cli-kit": "^0.52.0",
50
+ "oxc-parser": "^0.155.0"
51
+ },
52
+ "peerDependencies": {
53
+ "axe-core": "^4.14.0",
54
+ "playwright-core": "^1.64.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "axe-core": {
58
+ "optional": true
59
+ },
60
+ "playwright-core": {
61
+ "optional": true
62
+ }
63
+ }
64
+ }