cascivo 1.8.0 → 1.8.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.
@@ -1,5 +1,5 @@
1
- import{a as e,r as t}from"./config-CTk7uDrh.mjs";import{i as n}from"./fs-B7O-fNID.mjs";import{n as r,r as i,t as a}from"./args-B4PN85cC.mjs";import{n as o}from"./mcp-CqX_Yi06.mjs";import{stdin as s,stdout as c}from"node:process";import{fileURLToPath as l}from"node:url";import{existsSync as u,readFileSync as d,readdirSync as f}from"node:fs";import{dirname as p,join as m,resolve as h}from"node:path";import{isSafeRelativePath as g}from"@cascivo/registry";import{createInterface as _}from"node:readline/promises";const v={"@cascivo/react":`1.9.0`,"@cascivo/themes":`1.0.3`,"@cascivo/charts":`1.9.0`,"@cascivo/icons":`1.1.1`,"@cascivo/eslint-config":`0.4.2`,"@cascivo/app":`1.9.0`,"@cascivo/render":`1.9.0`,"@cascivo/storage":`1.9.0`,"@cascivo/email":`0.6.1`},y=`>=3.0.0`,b=`1.8.0`;function x(e){let t=e.startsWith(`/`)?e:`/${e}`;return t.length>1?t.replace(/\/+$/,``)||`/`:t}function S(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function C(e){let t=x(e).split(`/`).filter(Boolean),n=[],r=[],i=``;return t.forEach((a,o)=>{if(a===`*`){if(o!==t.length-1)throw Error(`"*" must be the last segment of a path pattern: "${e}"`);n.push(`*`),r.push(1),i+=`(?:/(.*))?`}else if(a.startsWith(`:`)){let t=a.slice(1);if(!/^[A-Za-z_$][\w$]*$/.test(t))throw Error(`Invalid param name "${t}" in path pattern "${e}"`);n.push(t),r.push(2),i+=`/([^/]+)`}else r.push(3),i+=`/${S(a)}`}),{pattern:e,keys:n,regex:RegExp(`^${i||`/`}/?$`),score:r}}function w(e,t){let n=Math.max(e.score.length,t.score.length);for(let r=0;r<n;r++){let n=(t.score[r]??0)-(e.score[r]??0);if(n!==0)return n}return 0}var T=/\.(tsx|jsx)$/;function ee(e){if(!T.test(e)||/\.(test|spec)\.[jt]sx$/.test(e))return;let t=e.replace(T,``).split(`/`);if(!t.some(e=>e.startsWith(`_`)))return t.length===1&&t[0]===`404`?null:(t.at(-1)===`index`&&t.pop(),`/${t.map((n,r)=>{if(/^\[\.\.\.[A-Za-z_$][\w$]*\]$/.test(n)){if(r!==t.length-1)throw Error(`routes/${e}: a [...rest] segment must be last`);return`*`}let i=/^\[([A-Za-z_$][\w$]*)\]$/.exec(n);if(i)return`:${i[1]}`;if(/[[\]]/.test(n))throw Error(`routes/${e}: malformed segment "${n}"`);return n}).join(`/`)}`)}function te(e,t){let n=[],r=/* @__PURE__ */ new Map;for(let t of e){let e=ee(t);if(e===void 0)continue;let i=r.get(e);if(i)throw Error(`routes/${i} and routes/${t} both define ${e??`the 404 route`}`);r.set(e,t),n.push({file:t,path:e})}let i=e=>`${t}/${e.replace(T,``)}`,a=n.filter(e=>e.path!==null).map(e=>({...e,compiled:C(e.path)})).sort((e,t)=>w(e.compiled,t.compiled)||e.path.localeCompare(t.path)),o=n.find(e=>e.path===null);return[`// Generated by @cascivo/app/vite from the routes directory — do not edit.`,`// Add, rename or delete a route file and this file is rewritten.`,`import { lazyRoute } from '@cascivo/app'`,`import type { Route } from '@cascivo/app'`,``,`export const routes: Route[] = [`,...a.map(e=>` lazyRoute('${e.path}', () => import('${i(e.file)}')),`),`]`,``,o?`export const notFound: Route | undefined = lazyRoute('*', () => import('${i(o.file)}'))`:`export const notFound: Route | undefined = undefined`,``,"/** Every route pattern. Fill one with `buildPath` for a typed link. */",`export type AppPath = ${a.length>0?a.map(e=>`'${e.path}'`).join(` | `):`never`}`,``].join(`
2
- `)}const E=p(l(import.meta.url));function D(){for(let e of[m(E,`..`,`recipes`),m(E,`..`,`..`,`recipes`)])if(u(m(e,`cloudflare`,`recipe.json`)))return e;throw Error(`cascivo: the scaffold recipes are missing (looked beside ${E}).`)}function O(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`${t}: a recipe must be an object.`);let{name:n,files:r,nav:i=[],dependencies:a=[]}=e;if(typeof n!=`string`||!/^[a-z][a-z0-9-]*$/.test(n))throw Error(`${t}: "name" must be a lower-case kebab-case string.`);if(!Array.isArray(r)||r.length===0)throw Error(`${t}: "files" must be a non-empty array of paths.`);let o=[];for(let e of r){if(!g(e))throw Error(`${t}: "${String(e)}" is not a safe relative path.`);o.push(e)}if(!Array.isArray(i))throw Error(`${t}: "nav" must be an array.`);let s=[];for(let e of i){let{label:n,href:r}=typeof e==`object`&&e?e:{};if(typeof n!=`string`||n===``||typeof r!=`string`||!r.startsWith(`/`))throw Error(`${t}: each "nav" entry needs a "label" and an "href" starting with "/".`);s.push({label:n,href:r})}if(!Array.isArray(a)||!a.every(e=>typeof e==`string`&&/^@cascivo\/[a-z-]+$/.test(e)))throw Error(`${t}: "dependencies" must be an array of @cascivo/* package names.`);return{name:n,files:o,nav:s,dependencies:a.map(String)}}const k=/* @__PURE__ */ new Map;function ne(e){let t=k.get(e);if(t)return t;let n=m(D(),e,`recipe.json`),r=O(JSON.parse(d(n,`utf8`)),n);if(r.name!==e)throw Error(`${n}: "name" must be "${e}".`);return k.set(e,r),r}const re=/\{\{(brand|appName|usageDataset)\}\}/g;function ie(e,t){let n=m(D(),e);return ne(e).files.map(e=>({path:e,contents:d(m(n,e),`utf8`).replace(re,(e,n)=>t[n])}))}function ae(){return f(D()).filter(e=>e.startsWith(`block-`)).map(e=>e.slice(6)).sort()}const A=U;function oe(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cascivo: the scaffold wrote a package.json that is not an object`);return{...t}}function se(e){return typeof e!=`object`||!e?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}const ce=/* @__PURE__ */ new Set([`.mcp.json`]);function le(e){let t=`@${e.packageName}`,n=`${t}/ui`,r=[];for(let i of e.app)if(!ce.has(i.path)){if(i.path===`package.json`){let a=oe(i.contents),o=se(a.scripts),s=se(a.devDependencies);r.push({path:`apps/web/package.json`,contents:A({...a,name:`${t}/web`,scripts:e.testable?{...o,test:`vitest run`}:o,dependencies:{[n]:`workspace:*`,...se(a.dependencies)},devDependencies:e.testable?{...s,"@testing-library/react":`^16.3.0`,jsdom:`^30.0.0`,vitest:`^5.0.0`}:s})});continue}r.push({path:`apps/web/${i.path}`,contents:i.contents})}e.testable&&r.push({path:`apps/web/vitest.config.ts`,contents:`import { defineConfig } from 'vitest/config'
1
+ import{a as e,r as t}from"./config-CTk7uDrh.mjs";import{i as n}from"./fs-B7O-fNID.mjs";import{n as r,r as i,t as a}from"./args-B4PN85cC.mjs";import{n as o}from"./mcp-CqX_Yi06.mjs";import{stdin as s,stdout as c}from"node:process";import{fileURLToPath as l}from"node:url";import{existsSync as u,readFileSync as d,readdirSync as f}from"node:fs";import{dirname as p,join as m,resolve as h}from"node:path";import{isSafeRelativePath as g}from"@cascivo/registry";import{createInterface as _}from"node:readline/promises";const v={"@cascivo/react":`1.11.0`,"@cascivo/themes":`1.0.3`,"@cascivo/astro":`1.11.0`,"@cascivo/charts":`1.11.0`,"@cascivo/icons":`1.1.1`,"@cascivo/eslint-config":`0.4.2`,"@cascivo/app":`1.11.0`,"@cascivo/render":`1.11.0`,"@cascivo/storage":`1.11.0`,"@cascivo/email":`0.6.1`},y=`>=3.0.0`,b=`1.8.2`;function x(e){let t=e.startsWith(`/`)?e:`/${e}`;return t.length>1?t.replace(/\/+$/,``)||`/`:t}function S(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function C(e){let t=x(e).split(`/`).filter(Boolean),n=[],r=[],i=``;return t.forEach((a,o)=>{if(a===`*`){if(o!==t.length-1)throw Error(`"*" must be the last segment of a path pattern: "${e}"`);n.push(`*`),r.push(1),i+=`(?:/(.*))?`}else if(a.startsWith(`:`)){let t=a.slice(1);if(!/^[A-Za-z_$][\w$]*$/.test(t))throw Error(`Invalid param name "${t}" in path pattern "${e}"`);n.push(t),r.push(2),i+=`/([^/]+)`}else r.push(3),i+=`/${S(a)}`}),{pattern:e,keys:n,regex:RegExp(`^${i||`/`}/?$`),score:r}}function w(e,t){let n=Math.max(e.score.length,t.score.length);for(let r=0;r<n;r++){let n=(t.score[r]??0)-(e.score[r]??0);if(n!==0)return n}return 0}var T=/\.(tsx|jsx)$/;function ee(e){if(!T.test(e)||/\.(test|spec)\.[jt]sx$/.test(e))return;let t=e.replace(T,``).split(`/`);if(!t.some(e=>e.startsWith(`_`)))return t.length===1&&t[0]===`404`?null:(t.at(-1)===`index`&&t.pop(),`/${t.map((n,r)=>{if(/^\[\.\.\.[A-Za-z_$][\w$]*\]$/.test(n)){if(r!==t.length-1)throw Error(`routes/${e}: a [...rest] segment must be last`);return`*`}let i=/^\[([A-Za-z_$][\w$]*)\]$/.exec(n);if(i)return`:${i[1]}`;if(/[[\]]/.test(n))throw Error(`routes/${e}: malformed segment "${n}"`);return n}).join(`/`)}`)}function E(e,t){let n=[],r=/* @__PURE__ */ new Map;for(let t of e){let e=ee(t);if(e===void 0)continue;let i=r.get(e);if(i)throw Error(`routes/${i} and routes/${t} both define ${e??`the 404 route`}`);r.set(e,t),n.push({file:t,path:e})}let i=e=>`${t}/${e.replace(T,``)}`,a=n.filter(e=>e.path!==null).map(e=>({...e,compiled:C(e.path)})).sort((e,t)=>w(e.compiled,t.compiled)||e.path.localeCompare(t.path)),o=n.find(e=>e.path===null);return[`// Generated by @cascivo/app/vite from the routes directory — do not edit.`,`// Add, rename or delete a route file and this file is rewritten.`,`import { lazyRoute } from '@cascivo/app'`,`import type { Route } from '@cascivo/app'`,``,`export const routes: Route[] = [`,...a.map(e=>` lazyRoute('${e.path}', () => import('${i(e.file)}')),`),`]`,``,o?`export const notFound: Route | undefined = lazyRoute('*', () => import('${i(o.file)}'))`:`export const notFound: Route | undefined = undefined`,``,"/** Every route pattern. Fill one with `buildPath` for a typed link. */",`export type AppPath = ${a.length>0?a.map(e=>`'${e.path}'`).join(` | `):`never`}`,``].join(`
2
+ `)}const D=p(l(import.meta.url));function O(){for(let e of[m(D,`..`,`recipes`),m(D,`..`,`..`,`recipes`)])if(u(m(e,`cloudflare`,`recipe.json`)))return e;throw Error(`cascivo: the scaffold recipes are missing (looked beside ${D}).`)}function te(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`${t}: a recipe must be an object.`);let{name:n,files:r,nav:i=[],dependencies:a=[]}=e;if(typeof n!=`string`||!/^[a-z][a-z0-9-]*$/.test(n))throw Error(`${t}: "name" must be a lower-case kebab-case string.`);if(!Array.isArray(r)||r.length===0)throw Error(`${t}: "files" must be a non-empty array of paths.`);let o=[];for(let e of r){if(!g(e))throw Error(`${t}: "${String(e)}" is not a safe relative path.`);o.push(e)}if(!Array.isArray(i))throw Error(`${t}: "nav" must be an array.`);let s=[];for(let e of i){let{label:n,href:r}=typeof e==`object`&&e?e:{};if(typeof n!=`string`||n===``||typeof r!=`string`||!r.startsWith(`/`))throw Error(`${t}: each "nav" entry needs a "label" and an "href" starting with "/".`);s.push({label:n,href:r})}if(!Array.isArray(a)||!a.every(e=>typeof e==`string`&&/^@cascivo\/[a-z-]+$/.test(e)))throw Error(`${t}: "dependencies" must be an array of @cascivo/* package names.`);return{name:n,files:o,nav:s,dependencies:a.map(String)}}const k=/* @__PURE__ */ new Map;function ne(e){let t=k.get(e);if(t)return t;let n=m(O(),e,`recipe.json`),r=te(JSON.parse(d(n,`utf8`)),n);if(r.name!==e)throw Error(`${n}: "name" must be "${e}".`);return k.set(e,r),r}const re=/\{\{(brand|appName|usageDataset)\}\}/g;function ie(e,t){let n=m(O(),e);return ne(e).files.map(e=>({path:e,contents:d(m(n,e),`utf8`).replace(re,(e,n)=>t[n])}))}function ae(){return f(O()).filter(e=>e.startsWith(`block-`)).map(e=>e.slice(6)).sort()}const A=B;function oe(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw Error(`cascivo: the scaffold wrote a package.json that is not an object`);return{...t}}function j(e){return typeof e!=`object`||!e?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`string`))}const se=/* @__PURE__ */ new Set([`.mcp.json`]);function ce(e){let t=`@${e.packageName}`,n=`${t}/ui`,r=[];for(let i of e.app)if(!se.has(i.path)){if(i.path===`package.json`){let a=oe(i.contents),o=j(a.scripts),s=j(a.devDependencies);r.push({path:`apps/web/package.json`,contents:A({...a,name:`${t}/web`,scripts:e.testable?{...o,test:`vitest run`}:o,dependencies:{[n]:`workspace:*`,...j(a.dependencies)},devDependencies:e.testable?{...s,"@testing-library/react":`^16.3.0`,jsdom:`^30.0.0`,vitest:`^5.0.0`}:s})});continue}r.push({path:`apps/web/${i.path}`,contents:i.contents})}e.testable&&r.push({path:`apps/web/vitest.config.ts`,contents:`import { defineConfig } from 'vitest/config'
3
3
 
4
4
  export default defineConfig({
5
5
  test: { environment: 'jsdom' },
@@ -71,20 +71,20 @@ A pnpm workspace. Run every command from this directory unless a step says other
71
71
  \`src/index.ts\`.
72
72
  - Checks: \`pnpm typecheck\`, \`pnpm lint\`,${e.testable?" `pnpm test`,":``} \`pnpm build\`. CI runs the same.
73
73
  `},{path:`CLAUDE.md`,contents:`@AGENTS.md
74
- `});let i=e.app.find(e=>e.path===`.mcp.json`);return i&&r.push(i),r}const j=v;function M(e){return e===`yarn`?`yarn`:`${e} install`}function N(e,t){return e===`npm`?`npm run ${t}`:`${e} ${t}`}function P(e,t){return`${e} run ${t}`}const F=[`react-vite`,`astro`,`cloudflare`],I=[`preact`,`react`],L=[`board`,`agent`,`notes`,`import`,`files`,`export`,`usage`,`crud`,`live`,`voice`,`publish`,`webhooks`,`digest`,`search`,`checkout`,`newsletter`,`social`];function R(e){return L.includes(e)}function z(e){return I.includes(e)}function ue(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`}function B(e){let t=e.trim().split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)||`Section`;return/^[0-9]/.test(t)?`Section${t}`:t}function V(e){let t=e.trim().split(/[^a-zA-Z0-9]+/).filter(e=>e!==``&&!/^\d+$/.test(e)&&!/^v\d+$/i.test(e)),n=[];for(let e of t){if(n.length>=3||n.length>0&&n.join(` `).length+1+e.length>24)break;n.push(e.charAt(0).toUpperCase()+e.slice(1))}return n.join(` `)||`App`}function H(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`cascivo-app`}function de(e,t=[]){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=[];for(let[a,o]of e.entries()){let e=o.trim();if(!e)continue;let s=ue(e),c=B(e),l=2;for(;n.has(s)||r.has(c);)s=`${ue(e)}-${l}`,c=`${B(e)}${l}`,l++;n.add(s),r.add(c);let u=t[a];i.push({key:s,label:e,component:c,...u?{block:u}:{}})}return i.length>0?i:[{key:`home`,label:`Home`,component:`Home`}]}function fe(e){let t={name:H(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`vite`,build:`tsc && vite build`,preview:`vite preview`,typecheck:`tsc --noEmit`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{...xe(e),"@cascivo/react":j[`@cascivo/react`],"@cascivo/themes":j[`@cascivo/themes`],"@preact/signals-react":y,react:`^19.0.0`,"react-dom":`^19.0.0`},devDependencies:{"@cascivo/eslint-config":j[`@cascivo/eslint-config`],"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,"@vitejs/plugin-react":`^5.0.0`,eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`,vite:`^7.0.0`}};return JSON.stringify(t,null,2)+`
75
- `}function U(e){return JSON.stringify(e,null,2).replace(/\[\n\s+("[^"\n]*"(?:,\n\s+"[^"\n]*")*)\n\s*\]/g,(e,t)=>`[${t.split(/,\n\s+/).join(`, `)}]`)+`
76
- `}function pe(){return U({compilerOptions:{target:`ES2022`,useDefineForClassFields:!0,lib:[`ES2022`,`DOM`,`DOM.Iterable`],module:`ESNext`,skipLibCheck:!0,moduleResolution:`bundler`,allowImportingTsExtensions:!0,resolveJsonModule:!0,isolatedModules:!0,moduleDetection:`force`,noEmit:!0,jsx:`react-jsx`,strict:!0,noUnusedLocals:!0,noUnusedParameters:!0,noFallthroughCasesInSwitch:!0},include:[`src`]})}function me(){return`import react from '@vitejs/plugin-react'
74
+ `});let i=e.app.find(e=>e.path===`.mcp.json`);return i&&r.push(i),r}const M=v;function N(e){return e===`yarn`?`yarn`:`${e} install`}function P(e,t){return e===`npm`?`npm run ${t}`:`${e} ${t}`}function F(e,t){return`${e} run ${t}`}const I=[`react-vite`,`astro`,`cloudflare`],L=[`preact`,`react`],le=[`board`,`agent`,`notes`,`import`,`files`,`export`,`usage`,`crud`,`live`,`voice`,`publish`,`webhooks`,`digest`,`search`,`checkout`,`newsletter`,`social`];function ue(e){return le.includes(e)}function de(e){return L.includes(e)}function fe(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`section`}function pe(e){let t=e.trim().split(/[^a-zA-Z0-9]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)||`Section`;return/^[0-9]/.test(t)?`Section${t}`:t}function R(e){let t=e.trim().split(/[^a-zA-Z0-9]+/).filter(e=>e!==``&&!/^\d+$/.test(e)&&!/^v\d+$/i.test(e)),n=[];for(let e of t){if(n.length>=3||n.length>0&&n.join(` `).length+1+e.length>24)break;n.push(e.charAt(0).toUpperCase()+e.slice(1))}return n.join(` `)||`App`}function z(e){return e.trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^-+|-+$/g,``)||`cascivo-app`}function me(e,t=[]){let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=[];for(let[a,o]of e.entries()){let e=o.trim();if(!e)continue;let s=fe(e),c=pe(e),l=2;for(;n.has(s)||r.has(c);)s=`${fe(e)}-${l}`,c=`${pe(e)}${l}`,l++;n.add(s),r.add(c);let u=t[a];i.push({key:s,label:e,component:c,...u?{block:u}:{}})}return i.length>0?i:[{key:`home`,label:`Home`,component:`Home`}]}function he(e){let t={name:z(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`vite`,build:`tsc && vite build`,preview:`vite preview`,typecheck:`tsc --noEmit`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{...we(e),"@cascivo/react":M[`@cascivo/react`],"@cascivo/themes":M[`@cascivo/themes`],"@preact/signals-react":y,react:`^19.0.0`,"react-dom":`^19.0.0`},devDependencies:{"@cascivo/eslint-config":M[`@cascivo/eslint-config`],"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,"@vitejs/plugin-react":`^5.0.0`,eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`,vite:`^7.0.0`}};return JSON.stringify(t,null,2)+`
75
+ `}function B(e){return JSON.stringify(e,null,2).replace(/\[\n\s+("[^"\n]*"(?:,\n\s+"[^"\n]*")*)\n\s*\]/g,(e,t)=>`[${t.split(/,\n\s+/).join(`, `)}]`)+`
76
+ `}function ge(){return B({compilerOptions:{target:`ES2022`,useDefineForClassFields:!0,lib:[`ES2022`,`DOM`,`DOM.Iterable`],module:`ESNext`,skipLibCheck:!0,moduleResolution:`bundler`,allowImportingTsExtensions:!0,resolveJsonModule:!0,isolatedModules:!0,moduleDetection:`force`,noEmit:!0,jsx:`react-jsx`,strict:!0,noUnusedLocals:!0,noUnusedParameters:!0,noFallthroughCasesInSwitch:!0},include:[`src`]})}function _e(){return`import react from '@vitejs/plugin-react'
77
77
  import { defineConfig } from 'vite'
78
78
 
79
79
  export default defineConfig({
80
80
  plugins: [react()],
81
81
  })
82
- `}function he(e){return`<!doctype html>
82
+ `}function ve(e){return`<!doctype html>
83
83
  <html lang="en" data-theme="${e.theme}">
84
84
  <head>
85
85
  <meta charset="UTF-8" />
86
86
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
87
- <title>${V(e.name)}</title>
87
+ <title>${R(e.name)}</title>
88
88
  <style>
89
89
  @layer vendor, cascivo.reset, cascivo.base, cascivo.tokens, cascivo.component,
90
90
  cascivo.platform, cascivo.theme, cascivo.blocks, cascivo.example, cascivo.override;
@@ -118,7 +118,7 @@ export default defineConfig({
118
118
  <script type="module" src="/src/main.tsx"><\/script>
119
119
  </body>
120
120
  </html>
121
- `}function ge(){return`import React from 'react'
121
+ `}function ye(){return`import React from 'react'
122
122
  import ReactDOM from 'react-dom/client'
123
123
  import App from './App'
124
124
 
@@ -130,8 +130,8 @@ if (root) {
130
130
  </React.StrictMode>,
131
131
  )
132
132
  }
133
- `}function _e(){return`/// <reference types="vite/client" />
134
- `}function ve(e){let t=e.map(e=>`import { ${e.component} } from './sections/${e.component}'`).join(`
133
+ `}function be(){return`/// <reference types="vite/client" />
134
+ `}function xe(e){let t=e.map(e=>`import { ${e.component} } from './sections/${e.component}'`).join(`
135
135
  `),n=`type Section = ${e.map(e=>`'${e.key}'`).join(` | `)}`,r=n.length<=100?n:`type Section =\n${e.map(e=>` | '${e.key}'`).join(`
136
136
  `)}`,i=e.map(e=>` {
137
137
  label: '${e.label.replace(/'/g,`\\'`)}',
@@ -164,7 +164,7 @@ ${a}
164
164
  </Shell>
165
165
  )
166
166
  }
167
- `}function ye(e){return`'use client'
167
+ `}function Se(e){return`'use client'
168
168
  import { AppShell, ShellHeader, SideNav, type SideNavItem } from '@cascivo/react'
169
169
  import type { ReactNode } from 'react'
170
170
 
@@ -194,17 +194,17 @@ export interface ShellProps {
194
194
  */
195
195
  export function Shell({ navItems, children }: ShellProps) {
196
196
  return (
197
- ${Te(e,`navItems`)}
197
+ ${Oe(e,`navItems`)}
198
198
  {children}
199
199
  </AppShell>
200
200
  )
201
201
  }
202
- `}function be(e,t){let n=B(e.block),r=n===e.component?`${n}Block`:n;return`import { ${r===n?n:`${n} as ${r}`} } from '../blocks/${e.block}'
202
+ `}function Ce(e,t){let n=pe(e.block),r=n===e.component?`${n}Block`:n;return`import { ${r===n?n:`${n} as ${r}`} } from '../blocks/${e.block}'
203
203
 
204
204
  ${t} ${e.component}() {
205
205
  return <${r} />
206
206
  }
207
- `}function xe(e){let t=new Set((e.blocks??[]).flatMap(e=>e?ne(`block-${e}`).dependencies:[]));return Object.fromEntries([...t].sort().map(e=>{let t=j[e];if(!t)throw Error(`cascivo: no pinned version for ${e}`);return[e,t]}))}function Se(e,t){return[...new Set(e.flatMap(e=>e.block?[e.block]:[]))].flatMap(e=>ie(`block-${e}`,Ce(t)))}function Ce(e){return{brand:V(e.name),appName:e.name.replace(/[\\']/g,``),usageDataset:Qe(e)}}function we(e){return e.block?be(e,`export function`):`import { Card, CardContent, CardHeader, CardTitle, Flex, Heading, Text } from '@cascivo/react'
207
+ `}function we(e){let t=new Set((e.blocks??[]).flatMap(e=>e?ne(`block-${e}`).dependencies:[]));return Object.fromEntries([...t].sort().map(e=>{let t=M[e];if(!t)throw Error(`cascivo: no pinned version for ${e}`);return[e,t]}))}function Te(e,t){return[...new Set(e.flatMap(e=>e.block?[e.block]:[]))].flatMap(e=>ie(`block-${e}`,Ee(t)))}function Ee(e){return{brand:R(e.name),appName:e.name.replace(/[\\']/g,``),usageDataset:et(e)}}function De(e){return e.block?Ce(e,`export function`):`import { Card, CardContent, CardHeader, CardTitle, Flex, Heading, Text } from '@cascivo/react'
208
208
 
209
209
  export function ${e.component}() {
210
210
  return (
@@ -230,7 +230,7 @@ export function ${e.component}() {
230
230
  </Flex>
231
231
  )
232
232
  }
233
- `}function W(){return`import js from '@eslint/js'
233
+ `}function V(){return`import js from '@eslint/js'
234
234
  import tseslint from 'typescript-eslint'
235
235
  import reactHooks from 'eslint-plugin-react-hooks'
236
236
  import cascivo from '@cascivo/eslint-config'
@@ -252,27 +252,27 @@ export default [
252
252
  // see https://cascivo.com/docs/using-with-strict-eslint.md
253
253
  ...cascivo,
254
254
  ]
255
- `}function Te(e,t){let n=`header={<ShellHeader brand={{ name: '${V(e.name).replace(/'/g,`\\'`)}' }} />}`,r=`nav={<SideNav items={${t}} />}`,i=` <AppShell ${n} ${r}>`;return i.length<=100?i:` <AppShell\n ${n}\n ${r}\n >`}function G(){return JSON.stringify({semi:!1,singleQuote:!0,printWidth:100},null,2)+`
256
- `}function K(){return`dist
255
+ `}function Oe(e,t){let n=`header={<ShellHeader brand={{ name: '${R(e.name).replace(/'/g,`\\'`)}' }} />}`,r=`nav={<SideNav items={${t}} />}`,i=` <AppShell ${n} ${r}>`;return i.length<=100?i:` <AppShell\n ${n}\n ${r}\n >`}function H(){return JSON.stringify({semi:!1,singleQuote:!0,printWidth:100},null,2)+`
256
+ `}function U(){return`dist
257
257
  node_modules
258
258
  # Vendored cascivo source is formatted upstream — reformatting it makes every
259
259
  # \`cascivo add\` update a merge conflict.
260
260
  src/components/ui/
261
- `}function Ee(){return`node_modules
261
+ `}function ke(){return`node_modules
262
262
  dist
263
263
  *.local
264
264
  .DS_Store
265
- `}function De(e){return`
265
+ `}function Ae(e){return`
266
266
  ## Share a preview
267
267
 
268
- No Cloudflare account needed. Run \`${N(e.pm??`npm`,`build`)}\`, then either:
268
+ No Cloudflare account needed. Run \`${P(e.pm??`npm`,`build`)}\`, then either:
269
269
 
270
270
  - drag the \`dist/\` folder onto [Cloudflare Drop](https://www.cloudflare.com/drop/), or
271
- - from a terminal: \`npx wrangler deploy --temporary --assets dist --name ${H(e.name)} --compatibility-date ${He}\`
271
+ - from a terminal: \`npx wrangler deploy --temporary --assets dist --name ${z(e.name)} --compatibility-date ${We}\`
272
272
 
273
273
  Either way you get a public URL that lasts 60 minutes. Sign in to Cloudflare within that hour
274
274
  to keep it.
275
- `}function Oe(e){let t=e.pm??`npm`;return`# ${e.name}
275
+ `}function je(e){let t=e.pm??`npm`;return`# ${e.name}
276
276
 
277
277
  A [cascivo](https://cascivo.com) app — Vite + React + TypeScript, pre-wired with
278
278
  the cascivo app shell, side navigation, and the \`${e.theme}\` theme.
@@ -280,8 +280,8 @@ the cascivo app shell, side navigation, and the \`${e.theme}\` theme.
280
280
  ## Develop
281
281
 
282
282
  \`\`\`sh
283
- ${M(t)}
284
- ${N(t,`dev`)}
283
+ ${N(t)}
284
+ ${P(t,`dev`)}
285
285
  \`\`\`
286
286
 
287
287
  ## Structure
@@ -314,7 +314,7 @@ setLinkComponent(({ href, ...rest }: LinkComponentProps) => <Link to={href ?? '#
314
314
  That one call makes \`SideNav\`, \`ShellHeader\` and \`Breadcrumb\` render real router links.
315
315
  Links you write in page content use \`<Link asChild>\` instead — two kinds of link, two
316
316
  mechanisms. Full recipe: https://cascivo.com/docs/using-with-a-router.md
317
- ${De(e)}`}function ke(e){return`# Agent instructions — ${e.name}
317
+ ${Ae(e)}`}function W(e){return`# Agent instructions — ${e.name}
318
318
 
319
319
  This is a [cascivo](https://cascivo.com) app. When generating or editing CSS, follow
320
320
  the **layer contract** — cascivo styles live in cascade layers, and layer order beats
@@ -381,22 +381,37 @@ The vocabulary types are on a subpath: \`import type { Tone } from '@cascivo/rea
381
381
  add \`@cascivo/core\` to this app's dependencies — it is transitive here.
382
382
 
383
383
  More: cascivo's machine-readable guide is at https://cascivo.com/llms.txt.
384
- `}function Ae(e,t){return t===0?`/`:`/${e.key}`}function je(e,t){return t===0?`index.astro`:`${e.key}.astro`}function Me(e){let t={name:H(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`astro dev`,build:`astro build`,preview:`astro preview`,typecheck:`astro check`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{"@astrojs/react":`^5.0.0`,"@cascivo/react":j[`@cascivo/react`],"@cascivo/themes":j[`@cascivo/themes`],"@preact/signals-react":y,astro:`^7.0.0`,react:`^19.0.0`,"react-dom":`^19.0.0`},devDependencies:{"@astrojs/check":`^0.9.0`,"@cascivo/eslint-config":j[`@cascivo/eslint-config`],"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`}};return JSON.stringify(t,null,2)+`
385
- `}function Ne(){return`// @ts-check
384
+ `}function G(e,t){return t===0?`/`:`/${e.key}`}function Me(e,t){return t===0?`index.astro`:`${e.key}.astro`}function Ne(e){let t={name:z(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`astro dev`,build:`astro build`,preview:`astro preview`,typecheck:`astro check`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{"@astrojs/react":`^7.1.0`,"@cascivo/astro":M[`@cascivo/astro`],"@cascivo/react":M[`@cascivo/react`],"@cascivo/themes":M[`@cascivo/themes`],"@preact/signals-react":y,astro:`^7.0.0`,react:`^19.0.0`,"react-dom":`^19.0.0`},devDependencies:{"@astrojs/check":`^0.9.0`,"@cascivo/eslint-config":M[`@cascivo/eslint-config`],"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`}};return JSON.stringify(t,null,2)+`
385
+ `}function Pe(e){return`// @ts-check
386
386
  import { defineConfig } from 'astro/config'
387
387
  import react from '@astrojs/react'
388
+ import cascivo from '@cascivo/astro'
388
389
 
389
390
  export default defineConfig({
390
- integrations: [react()],
391
+ // @cascivo/astro injects, on every page and ahead of any other CSS, the layer order and then
392
+ // the theme, and inlines a no-flash theme script that survives <ClientRouter /> swaps.
393
+ // \`layers\` is the statement in src/styles/layers.css, this app's cascivo.example slot included.
394
+ // Both theme options name the app's theme: the defaults (light-dark.css and the OS
395
+ // preference) would repaint any other theme as plain light or dark.
396
+ integrations: [
397
+ react(),
398
+ cascivo({
399
+ layers:
400
+ '${Ie}',
401
+ theme: '@cascivo/themes/${e.theme}.css',
402
+ themeScript: { defaultTheme: '${e.theme}' },
403
+ }),
404
+ ],
391
405
  vite: {
392
406
  resolve: {
393
- // REQUIRED, and the single least obvious line in this app.
407
+ // Kept for @cascivo/react 1.9.0 and older; @cascivo/astro sets it too, and newer
408
+ // versions do not need it (their package carries the \`astro-component\` keyword).
394
409
  //
395
410
  // Vite externalizes node_modules packages in its server build, so an externalized
396
411
  // @cascivo/react is imported by Node at runtime and its module graph is never walked
397
- // — and Astro collects a page's CSS by walking that graph. Without this, SSR'd
398
- // islands (client:load, client:visible) render with correct class names and no rules
399
- // anywhere in the output. Nothing warns; it reads as a theming problem.
412
+ // — and Astro collects a page's CSS by walking that graph. On those versions, without
413
+ // it, SSR'd islands (client:load, client:visible) render with correct class names and no
414
+ // rules anywhere in the output. Nothing warns; it reads as a theming problem.
400
415
  //
401
416
  // It must be \`resolve.noExternal\`, NOT \`ssr.noExternal\`: Astro prerenders static
402
417
  // routes in its own Vite environment, which \`ssr.*\` does not reach.
@@ -405,17 +420,17 @@ export default defineConfig({
405
420
  },
406
421
  },
407
422
  })
408
- `}function Pe(){return JSON.stringify({extends:`astro/tsconfigs/strict`,include:[`.astro/types.d.ts`,`**/*`],exclude:[`dist`],compilerOptions:{jsx:`react-jsx`}},null,2)+`
409
- `}function Fe(){return`/* Cascade layer order. Must load before any cascivo CSS — see the note in
410
- src/layouts/Layout.astro. Later layers beat earlier ones regardless of specificity.
423
+ `}function Fe(){return JSON.stringify({extends:`astro/tsconfigs/strict`,include:[`.astro/types.d.ts`,`**/*`],exclude:[`dist`],compilerOptions:{jsx:`react-jsx`}},null,2)+`
424
+ `}const Ie=`@layer vendor, cascivo.reset, cascivo.base, cascivo.tokens, cascivo.component, cascivo.platform, cascivo.theme, cascivo.blocks, cascivo.example, cascivo.override;`;function Le(){return`/* Cascade layer order. Later layers beat earlier ones regardless of specificity.
425
+ @cascivo/astro injects this same statement first on every page (\`layers\` in
426
+ astro.config.mjs); keep the two identical. Repeating it here is harmless.
411
427
 
412
428
  cascivo.example is this app's own slot: above the component and blocks layers so your
413
429
  page styles win, below cascivo.override which stays free for one-off hotfixes.
414
430
  Third-party CSS goes in vendor so it cannot beat cascivo:
415
431
  @import url('some-lib/styles.css') layer(vendor);
416
432
  See https://cascivo.com/docs/third-party-css.md */
417
- @layer vendor, cascivo.reset, cascivo.base, cascivo.tokens, cascivo.component,
418
- cascivo.platform, cascivo.theme, cascivo.blocks, cascivo.example, cascivo.override;
433
+ ${Ie}
419
434
 
420
435
  @layer cascivo.reset {
421
436
  *,
@@ -433,14 +448,14 @@ export default defineConfig({
433
448
  block-size: 100%;
434
449
  }
435
450
  }
436
- `}function Ie(e){return`---
437
- // Import order matters: the layer statement must be established before any cascivo CSS.
451
+ `}function Re(e){return`---
452
+ // The layer order and the ${e.theme} theme come from @cascivo/astro in astro.config.mjs,
453
+ // injected ahead of this file on every page. This adds the reset and base rules.
438
454
  import '../styles/layers.css'
439
- import '@cascivo/themes/${e.theme}.css'
440
455
 
441
456
  // No '@cascivo/react/styles.css'. Each component brings its own CSS through the module
442
457
  // graph, so you ship only what your pages use. Import the aggregate ONLY if you drop the
443
- // bundler entirely. The theme import above is always required — themes are never automatic.
458
+ // bundler entirely.
444
459
 
445
460
  interface Props {
446
461
  title: string
@@ -454,17 +469,17 @@ const { title } = Astro.props
454
469
  <head>
455
470
  <meta charset="UTF-8" />
456
471
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
457
- <title>{title} · ${V(e.name)}</title>
472
+ <title>{title} · ${R(e.name)}</title>
458
473
  </head>
459
474
  <body>
460
475
  <slot />
461
476
  </body>
462
477
  </html>
463
- `}function Le(e,t){return`import { AppShell, ShellHeader, SideNav, type SideNavItem } from '@cascivo/react'
478
+ `}function ze(e,t){return`import { AppShell, ShellHeader, SideNav, type SideNavItem } from '@cascivo/react'
464
479
  import type { ReactNode } from 'react'
465
480
 
466
481
  const NAV: { label: string; href: string }[] = [
467
- ${t.map((e,t)=>` { label: '${e.label.replace(/'/g,`\\'`)}', href: '${Ae(e,t)}' },`).join(`
482
+ ${t.map((e,t)=>` { label: '${e.label.replace(/'/g,`\\'`)}', href: '${G(e,t)}' },`).join(`
468
483
  `)}
469
484
  ]
470
485
 
@@ -487,12 +502,12 @@ export function Shell({ activePath, children }: ShellProps) {
487
502
  }))
488
503
 
489
504
  return (
490
- ${Te(e,`items`)}
505
+ ${Oe(e,`items`)}
491
506
  {children}
492
507
  </AppShell>
493
508
  )
494
509
  }
495
- `}function Re(e){return`import { Card, CardContent, CardHeader, CardTitle, Flex, Heading, Text } from '@cascivo/react'
510
+ `}function Be(e){return`import { Card, CardContent, CardHeader, CardTitle, Flex, Heading, Text } from '@cascivo/react'
496
511
 
497
512
  export function ${e.component}() {
498
513
  return (
@@ -518,7 +533,7 @@ export function ${e.component}() {
518
533
  </Flex>
519
534
  )
520
535
  }
521
- `}function ze(e,t){return`---
536
+ `}function Ve(e,t){return`---
522
537
  import Layout from '../layouts/Layout.astro'
523
538
  import { Shell } from '../components/Shell'
524
539
  import { ${e.component} } from '../components/${e.component}'
@@ -527,16 +542,16 @@ import { ${e.component} } from '../components/${e.component}'
527
542
  <Layout title="${e.label}">
528
543
  {/* client:load hydrates the shell for its mobile nav drawer. The section below stays
529
544
  server-rendered HTML — it is slotted in as children and ships no JS. */}
530
- <Shell client:load activePath="${Ae(e,t)}">
545
+ <Shell client:load activePath="${G(e,t)}">
531
546
  <${e.component} />
532
547
  </Shell>
533
548
  </Layout>
534
- `}function Be(){return`node_modules
549
+ `}function He(){return`node_modules
535
550
  dist
536
551
  .astro
537
552
  *.local
538
553
  .DS_Store
539
- `}function Ve(e,t){let n=e.pm??`npm`,r=t.map((e,t)=>`- \`${Ae(e,t)}\` — \`src/pages/${je(e,t)}\``).join(`
554
+ `}function Ue(e,t){let n=e.pm??`npm`,r=t.map((e,t)=>`- \`${G(e,t)}\` — \`src/pages/${Me(e,t)}\``).join(`
540
555
  `);return`# ${e.name}
541
556
 
542
557
  A [cascivo](https://cascivo.com) app — Astro + React islands + TypeScript, pre-wired with
@@ -545,8 +560,8 @@ the cascivo app shell, side navigation, and the \`${e.theme}\` theme.
545
560
  ## Develop
546
561
 
547
562
  \`\`\`sh
548
- ${M(n)}
549
- ${N(n,`dev`)}
563
+ ${N(n)}
564
+ ${P(n,`dev`)}
550
565
  \`\`\`
551
566
 
552
567
  ## Routes
@@ -573,14 +588,15 @@ A component that reads \`signal.value\` during render must also call \`useSignal
573
588
 
574
589
  ## Styling
575
590
 
576
- \`src/styles/layers.css\` declares the cascade layer order and this app's own
577
- \`cascivo.example\` slot. It is imported **before** the theme in \`src/layouts/Layout.astro\`,
578
- and that order matters: layers take their position from first appearance, so a statement
579
- loaded after the theme cannot reorder anything.
591
+ \`@cascivo/astro\` (in \`astro.config.mjs\`) injects the cascade layer order, then the
592
+ \`${e.theme}\` theme, ahead of any other CSS on every page, and inlines a no-flash theme
593
+ script. Its \`layers\` option is the same statement as \`src/styles/layers.css\`, which adds
594
+ this app's own \`cascivo.example\` slot; keep the two identical. Layers take their position
595
+ from first appearance, so a statement loaded after the theme cannot reorder anything.
580
596
 
581
597
  Add more components with \`npx cascivo add <component>\`.
582
- ${De(e)}`}const He=`2026-09-01`;function Ue(e){let t=e.pm??`npm`,n=Q(e,`agent`),r=rt(e),i=it(e)===`preact`,a={name:H(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`vite`,build:r?`tsc && tsc -p tsconfig.worker.json && vite build`:`tsc && vite build`,preview:`vite preview`,deploy:`${N(t,`build`)} && wrangler deploy`,"deploy:preview":`${N(t,`build`)} && wrangler deploy --temporary`,typecheck:r?`tsc --noEmit && tsc --noEmit -p tsconfig.worker.json`:`tsc --noEmit`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{"@cascivo/app":j[`@cascivo/app`],...xe(e),"@cascivo/react":j[`@cascivo/react`],"@cascivo/themes":j[`@cascivo/themes`],"@preact/signals-react":y,...i?{preact:`^10.29.0`}:{react:`^19.0.0`,"react-dom":`^19.0.0`},...Q(e,`usage`)||Q(e,`live`)?{"@cascivo/charts":j[`@cascivo/charts`]}:{},...Q(e,`export`)?{"@cloudflare/puppeteer":`^1.4.0`}:{},...Q(e,`notes`)?{"@cascivo/storage":j[`@cascivo/storage`]}:{},...n?{"@ai-sdk/react":`^4.0.0`,"@cascivo/render":j[`@cascivo/render`],"@cloudflare/ai-chat":`^0.12.1`,agents:`^0.26.0`,ai:`^7.0.0`,"workers-ai-provider":`^4.0.0`,zod:`^4.0.0`}:{},...Q(e,`voice`)&&!n?{agents:`^0.26.0`}:{},...Q(e,`publish`)&&!n?{"@cascivo/render":j[`@cascivo/render`]}:{},...Q(e,`checkout`)||Q(e,`newsletter`)?{"@cascivo/email":j[`@cascivo/email`]}:{},...(Q(e,`publish`)||Q(e,`checkout`)||Q(e,`newsletter`))&&i?{"preact-render-to-string":`^6.5.0`}:{}},devDependencies:{"@cascivo/eslint-config":j[`@cascivo/eslint-config`],"@cloudflare/vite-plugin":`^1.62.0`,...r?{"@cloudflare/workers-types":`^5.0.0`}:{},"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,...i?{"@babel/core":`^7.0.0`,"@preact/preset-vite":`^2.10.0`,react:`^19.0.0`,"react-dom":`^19.0.0`}:{"@vitejs/plugin-react":`^6.0.0`},eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`,vite:`^8.0.0`,wrangler:`^4.143.0`}},o=xt(e);return JSON.stringify(Object.keys(o).length>0?{...a,cloudflare:{bindings:o}}:a,null,2)+`
583
- `}function We(e){let t=JSON.parse(pe());return t.include=rt(e)?[`src`]:[`src`,`worker`],U(t)}function Ge(){return U({extends:`./tsconfig.json`,compilerOptions:{lib:[`ES2022`],types:[`@cloudflare/workers-types`,`vite/client`]},include:[`worker`]})}function Ke(e,t){let n=Q(t,`agent`),r=tt(t),i=e===`preact`?`import preact from '@preact/preset-vite'`:`import react from '@vitejs/plugin-react'`,a=e===`preact`?`preact()`:`react()`;return`${i}
598
+ ${Ae(e)}`}const We=`2026-09-01`;function Ge(e){let t=e.pm??`npm`,n=Z(e,`agent`),r=$(e),i=at(e)===`preact`,a={name:z(e.name),private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`vite`,build:r?`tsc && tsc -p tsconfig.worker.json && vite build`:`tsc && vite build`,preview:`vite preview`,deploy:`${P(t,`build`)} && wrangler deploy`,"deploy:preview":`${P(t,`build`)} && wrangler deploy --temporary`,typecheck:r?`tsc --noEmit && tsc --noEmit -p tsconfig.worker.json`:`tsc --noEmit`,lint:`eslint .`,format:`prettier --write .`,"format:check":`prettier --check .`},dependencies:{"@cascivo/app":M[`@cascivo/app`],...we(e),"@cascivo/react":M[`@cascivo/react`],"@cascivo/themes":M[`@cascivo/themes`],"@preact/signals-react":y,...i?{preact:`^10.29.0`}:{react:`^19.0.0`,"react-dom":`^19.0.0`},...Z(e,`usage`)||Z(e,`live`)?{"@cascivo/charts":M[`@cascivo/charts`]}:{},...Z(e,`export`)?{"@cloudflare/puppeteer":`^1.4.0`}:{},...Z(e,`notes`)?{"@cascivo/storage":M[`@cascivo/storage`]}:{},...n?{"@ai-sdk/react":`^4.0.0`,"@cascivo/render":M[`@cascivo/render`],"@cloudflare/ai-chat":`^0.12.1`,agents:`^0.26.0`,ai:`^7.0.0`,"workers-ai-provider":`^4.0.0`,zod:`^4.0.0`}:{},...Z(e,`voice`)&&!n?{agents:`^0.26.0`}:{},...Z(e,`publish`)&&!n?{"@cascivo/render":M[`@cascivo/render`]}:{},...Z(e,`checkout`)||Z(e,`newsletter`)?{"@cascivo/email":M[`@cascivo/email`]}:{},...(Z(e,`publish`)||Z(e,`checkout`)||Z(e,`newsletter`))&&i?{"preact-render-to-string":`^6.5.0`}:{}},devDependencies:{"@cascivo/eslint-config":M[`@cascivo/eslint-config`],"@cloudflare/vite-plugin":`^1.62.0`,...r?{"@cloudflare/workers-types":`^5.0.0`}:{},"@eslint/js":`^9.0.0`,"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,...i?{"@babel/core":`^7.0.0`,"@preact/preset-vite":`^2.10.0`,react:`^19.0.0`,"react-dom":`^19.0.0`}:{"@vitejs/plugin-react":`^6.0.0`},eslint:`^9.0.0`,"eslint-plugin-react-hooks":`^7.0.0`,prettier:`^3.0.0`,typescript:`^5.7.0`,"typescript-eslint":`^8.0.0`,vite:`^8.0.0`,wrangler:`^4.143.0`}},o=St(e);return JSON.stringify(Object.keys(o).length>0?{...a,cloudflare:{bindings:o}}:a,null,2)+`
599
+ `}function Ke(e){let t=JSON.parse(ge());return t.include=$(e)?[`src`]:[`src`,`worker`],B(t)}function qe(){return B({extends:`./tsconfig.json`,compilerOptions:{lib:[`ES2022`],types:[`@cloudflare/workers-types`,`vite/client`]},include:[`worker`]})}function Je(e,t){let n=Z(t,`agent`),r=rt(t),i=e===`preact`?`import preact from '@preact/preset-vite'`:`import react from '@vitejs/plugin-react'`,a=e===`preact`?`preact()`:`react()`;return`${i}
584
600
  import { cascivoRoutes } from '@cascivo/app/vite'
585
601
  import { cloudflare } from '@cloudflare/vite-plugin'
586
602
  import { defineConfig } from 'vite'
@@ -598,7 +614,7 @@ ${e===`preact`?`// The source is written against React's types; @preact/preset-v
598
614
  // client, so dev and production execute the same runtime. Request routing is in wrangler.jsonc.${r?`
599
615
  //
600
616
  // Workers AI has no local mode: with remote bindings on, \`vite dev\` needs a Cloudflare login.
601
- // So they are off, ${Q(t,`search`)?`and:${[n?`the assistant answers from worker/scripted-model.ts`:``,Q(t,`voice`)?`the voice page uses the stand-ins in worker/scripted-voice.ts`:``,`search runs by keyword, on SQLite full-text search (worker/search.ts)`].filter(Boolean).map(e=>`\n// - ${e}`).join(``)}`:n&&Q(t,`voice`)?`the assistant answers from worker/scripted-model.ts, and the voice
617
+ // So they are off, ${Z(t,`search`)?`and:${[n?`the assistant answers from worker/scripted-model.ts`:``,Z(t,`voice`)?`the voice page uses the stand-ins in worker/scripted-voice.ts`:``,`search runs by keyword, on SQLite full-text search (worker/search.ts)`].filter(Boolean).map(e=>`\n// - ${e}`).join(``)}`:n&&Z(t,`voice`)?`the assistant answers from worker/scripted-model.ts, and the voice
602
618
  // page uses the stand-ins in worker/scripted-voice.ts`:n?`and the assistant answers from worker/scripted-model.ts`:`and the voice page uses the stand-ins in worker/scripted-voice.ts`}. Run
603
619
  // \`VITE_REAL_AI=1 vite dev\` (after \`wrangler login\`) to use Workers AI.`:``}
604
620
  export default defineConfig({
@@ -606,18 +622,18 @@ ${r?` plugins: [
606
622
  ${a},
607
623
  cascivoRoutes(),
608
624
  cloudflare({ remoteBindings: process.env['VITE_REAL_AI'] === '1' }),
609
- ],`:` plugins: [${a}, cascivoRoutes(), cloudflare()],`}${Q(t,`publish`)?`
625
+ ],`:` plugins: [${a}, cascivoRoutes(), cloudflare()],`}${Z(t,`publish`)?`
610
626
  // A published page's HTML links the stylesheets its route needs, found in this manifest
611
627
  // (worker/page-html.ts), so the page is styled for readers without JavaScript too.
612
628
  build: { manifest: 'asset-manifest.json' },`:``}
613
629
  })
614
- `}function q(e,t,n){let r=`${e}"${t}": [${n.join(`, `)}],`;return r.length<=100?r:`${e}"${t}": [\n${n.map(t=>`${e} ${t},`).join(`
615
- `)}\n${e}],`}function qe(e){let t=Q(e,`publish`),n=nt(e),r=Q(e,`agent`),i=$(e),a=[...n?[{name:`ROOMS`,className:`SyncRoom`}]:[],...r?[{name:`Assistant`,className:`Assistant`}]:[],...Q(e,`live`)?[{name:`LIVE`,className:`LiveRoom`}]:[],...Q(e,`voice`)?[{name:`Voice`,className:`Voice`}]:[]],o=[...n?[`// ROOMS: one SyncRoom per room (@cascivo/app/sync-server).`]:[],...r?[`// Assistant: one AIChatAgent per conversation; it stores the messages in SQLite.`]:[],...Q(e,`live`)?[`// LIVE: the /ops dashboard's per-second totals (@cascivo/app/live-server).`]:[],...Q(e,`voice`)?[`// Voice: one voice agent per conversation (agents/voice); it stores the transcript.`]:[]];return`// Cloudflare deploy config. \`${P(e.pm??`npm`,`deploy`)}\` builds and ships the SPA and
630
+ `}function K(e,t,n){let r=`${e}"${t}": [${n.join(`, `)}],`;return r.length<=100?r:`${e}"${t}": [\n${n.map(t=>`${e} ${t},`).join(`
631
+ `)}\n${e}],`}function Ye(e){let t=Z(e,`publish`),n=it(e),r=Z(e,`agent`),i=Q(e),a=[...n?[{name:`ROOMS`,className:`SyncRoom`}]:[],...r?[{name:`Assistant`,className:`Assistant`}]:[],...Z(e,`live`)?[{name:`LIVE`,className:`LiveRoom`}]:[],...Z(e,`voice`)?[{name:`Voice`,className:`Voice`}]:[]],o=[...n?[`// ROOMS: one SyncRoom per room (@cascivo/app/sync-server).`]:[],...r?[`// Assistant: one AIChatAgent per conversation; it stores the messages in SQLite.`]:[],...Z(e,`live`)?[`// LIVE: the /ops dashboard's per-second totals (@cascivo/app/live-server).`]:[],...Z(e,`voice`)?[`// Voice: one voice agent per conversation (agents/voice); it stores the transcript.`]:[]];return`// Cloudflare deploy config. \`${F(e.pm??`npm`,`deploy`)}\` builds and ships the SPA and
616
632
  // the Worker together. https://developers.cloudflare.com/workers/wrangler/configuration/
617
633
  {
618
- "name": "${H(e.name)}",
634
+ "name": "${z(e.name)}",
619
635
  "main": "./worker/index.ts",
620
- "compatibility_date": "${He}",
636
+ "compatibility_date": "${We}",
621
637
  "assets": {
622
638
  // Client-side app: an unknown path serves index.html, and the client renders it.
623
639
  "not_found_handling": "single-page-application",
@@ -631,48 +647,48 @@ ${r?` plugins: [
631
647
  ${o.join(`
632
648
  `)}
633
649
  "durable_objects": {
634
- ${q(` `,`bindings`,a.map(e=>`{ "name": "${e.name}", "class_name": "${e.className}" }`))}
650
+ ${K(` `,`bindings`,a.map(e=>`{ "name": "${e.name}", "class_name": "${e.className}" }`))}
635
651
  },
636
- ${q(` `,`migrations`,[`{ "tag": "v1", "new_sqlite_classes": [${a.map(e=>`"${e.className}"`).join(`, `)}] }`])}`:``}${Q(e,`files`)||Q(e,`social`)?`
637
- // ${[Q(e,`files`)?`Uploaded files, and Cloudflare Images for their resized previews`:``,Q(e,`social`)?`Images attached to social posts (worker/social.ts)`:``].filter(Boolean).join(`; `)}.
638
- ${q(` `,`r2_buckets`,[...Q(e,`files`)?[`{ "binding": "FILES", "bucket_name": "${H(e.name)}-files" }`]:[],...Q(e,`social`)?[`{ "binding": "SOCIAL_MEDIA", "bucket_name": "${H(e.name)}-social-media" }`]:[]])}${Q(e,`files`)?`
639
- "images": { "binding": "IMAGES" },`:``}`:``}${$e(e)?`
640
- // ${[Q(e,`files`)?`Uploads`:``,Q(e,`export`)?`exports`:``,Q(e,`publish`)?`published pages`:``,Q(e,`digest`)?`digests sent now`:``,Q(e,`search`)?`search indexing`:``,Q(e,`checkout`)?`checkouts started`:``,Q(e,`newsletter`)?`newsletter sign-ups and composer requests`:``,Q(e,`social`)?`connecting accounts, posts and image uploads`:``,X(e)?`sign-in emails`:``].filter(Boolean).join(`, `).replace(/^./,e=>e.toUpperCase())} per caller: 20 a minute.
652
+ ${K(` `,`migrations`,[`{ "tag": "v1", "new_sqlite_classes": [${a.map(e=>`"${e.className}"`).join(`, `)}] }`])}`:``}${Z(e,`files`)||Z(e,`social`)?`
653
+ // ${[Z(e,`files`)?`Uploaded files, and Cloudflare Images for their resized previews`:``,Z(e,`social`)?`Images attached to social posts (worker/social.ts)`:``].filter(Boolean).join(`; `)}.
654
+ ${K(` `,`r2_buckets`,[...Z(e,`files`)?[`{ "binding": "FILES", "bucket_name": "${z(e.name)}-files" }`]:[],...Z(e,`social`)?[`{ "binding": "SOCIAL_MEDIA", "bucket_name": "${z(e.name)}-social-media" }`]:[]])}${Z(e,`files`)?`
655
+ "images": { "binding": "IMAGES" },`:``}`:``}${tt(e)?`
656
+ // ${[Z(e,`files`)?`Uploads`:``,Z(e,`export`)?`exports`:``,Z(e,`publish`)?`published pages`:``,Z(e,`digest`)?`digests sent now`:``,Z(e,`search`)?`search indexing`:``,Z(e,`checkout`)?`checkouts started`:``,Z(e,`newsletter`)?`newsletter sign-ups and composer requests`:``,Z(e,`social`)?`connecting accounts, posts and image uploads`:``,Y(e)?`sign-in emails`:``].filter(Boolean).join(`, `).replace(/^./,e=>e.toUpperCase())} per caller: 20 a minute.
641
657
  // namespace_id is any number unique within your account:
642
658
  // https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
643
- ${q(` `,`ratelimits`,[`{ "name": "LIMITER", "namespace_id": "1001", "simple": { "limit": 20, "period": 60 } }`])}`:``}${Je(e)}${Q(e,`digest`)||Q(e,`social`)?`
644
- // ${[Q(e,`digest`)?`The weekly digest: Mondays at 08:00 UTC (worker/digest.ts)`:``,Q(e,`social`)?`Threads tokens renewed and reconnect reminders sent, daily at 04:17 UTC (worker/social.ts)`:``].filter(Boolean).join(`; `)}.
645
- "triggers": { "crons": [${[Q(e,`digest`)?`"0 8 * * 1"`:``,Q(e,`social`)?`"${ft}"`:``].filter(Boolean).join(`, `)}] },`:``}${et(e)?`
646
- // Tables for ${[Q(e,`crud`)?`customers`:``,Q(e,`publish`)?`published pages`:``,Q(e,`webhooks`)?`webhook deliveries`:``,Q(e,`digest`)?`digest runs`:``,Q(e,`search`)?`help articles`:``,Q(e,`checkout`)?`orders`:``,Q(e,`newsletter`)?`newsletter subscribers and issues`:``,Y(e)?`accounts`:``].filter(Boolean).join(`, `)}.
659
+ ${K(` `,`ratelimits`,[`{ "name": "LIMITER", "namespace_id": "1001", "simple": { "limit": 20, "period": 60 } }`])}`:``}${Xe(e)}${Z(e,`digest`)||Z(e,`social`)?`
660
+ // ${[Z(e,`digest`)?`The weekly digest: Mondays at 08:00 UTC (worker/digest.ts)`:``,Z(e,`social`)?`Threads tokens renewed and reconnect reminders sent, daily at 04:17 UTC (worker/social.ts)`:``].filter(Boolean).join(`; `)}.
661
+ "triggers": { "crons": [${[Z(e,`digest`)?`"0 8 * * 1"`:``,Z(e,`social`)?`"${pt}"`:``].filter(Boolean).join(`, `)}] },`:``}${nt(e)?`
662
+ // Tables for ${[Z(e,`crud`)?`customers`:``,Z(e,`publish`)?`published pages`:``,Z(e,`webhooks`)?`webhook deliveries`:``,Z(e,`digest`)?`digest runs`:``,Z(e,`search`)?`help articles`:``,Z(e,`checkout`)?`orders`:``,Z(e,`newsletter`)?`newsletter subscribers and issues`:``,J(e)?`accounts`:``].filter(Boolean).join(`, `)}.
647
663
  // No database_id: wrangler creates the database on first deploy, and the Worker applies its
648
664
  // own schema on its first query (\`migrate\`).
649
- ${q(` `,`d1_databases`,[`{ "binding": "DB", "database_name": "${H(e.name)}-db" }`])}`:``}${Q(e,`usage`)?`
665
+ ${K(` `,`d1_databases`,[`{ "binding": "DB", "database_name": "${z(e.name)}-db" }`])}`:``}${Z(e,`usage`)?`
650
666
  // Every API request is recorded here (worker/index.ts); /usage reads it back.
651
- "analytics_engine_datasets": [{ "binding": "USAGE", "dataset": "${Qe(e)}" }],`:``}${Ye(e)}${Q(e,`import`)||Q(e,`social`)?`
652
- // ${[Q(e,`import`)?`The CSV import runs as a Workflow (worker/import-job.ts); its progress is a room.`:``,Q(e,`social`)?`Each scheduled post is a Workflow that waits until it is due (worker/social-post.ts).`:``].filter(Boolean).join(`
667
+ "analytics_engine_datasets": [{ "binding": "USAGE", "dataset": "${et(e)}" }],`:``}${Ze(e)}${Z(e,`import`)||Z(e,`social`)?`
668
+ // ${[Z(e,`import`)?`The CSV import runs as a Workflow (worker/import-job.ts); its progress is a room.`:``,Z(e,`social`)?`Each scheduled post is a Workflow that waits until it is due (worker/social-post.ts).`:``].filter(Boolean).join(`
653
669
  // `)}
654
- ${q(` `,`workflows`,[...Q(e,`import`)?[`{ "name": "import-job", "binding": "IMPORT_JOB", "class_name": "ImportJob" }`]:[],...Q(e,`social`)?[`{ "name": "${H(e.name)}-social-post", "binding": "SOCIAL_POST", "class_name": "SocialPost" }`]:[]])}`:``}${tt(e)?`
655
- // Workers AI, which the ${[r?`assistant`:``,Q(e,`voice`)?`voice agent`:``,Q(e,`search`)?`search page`:``].filter(Boolean).join(` and `)} call${[r,Q(e,`voice`),Q(e,`search`)].filter(Boolean).length>1?``:`s`}.
656
- "ai": { "binding": "AI" },`:``}${Q(e,`search`)?`
670
+ ${K(` `,`workflows`,[...Z(e,`import`)?[`{ "name": "import-job", "binding": "IMPORT_JOB", "class_name": "ImportJob" }`]:[],...Z(e,`social`)?[`{ "name": "${z(e.name)}-social-post", "binding": "SOCIAL_POST", "class_name": "SocialPost" }`]:[]])}`:``}${rt(e)?`
671
+ // Workers AI, which the ${[r?`assistant`:``,Z(e,`voice`)?`voice agent`:``,Z(e,`search`)?`search page`:``].filter(Boolean).join(` and `)} call${[r,Z(e,`voice`),Z(e,`search`)].filter(Boolean).length>1?``:`s`}.
672
+ "ai": { "binding": "AI" },`:``}${Z(e,`search`)?`
657
673
  // The help articles' embeddings (worker/search.ts). Create it once before deploying (README).
658
- ${q(` `,`vectorize`,[`{ "binding": "ARTICLES_INDEX", "index_name": "${H(e.name)}-articles" }`])}`:``}${Q(e,`export`)?`
674
+ ${K(` `,`vectorize`,[`{ "binding": "ARTICLES_INDEX", "index_name": "${z(e.name)}-articles" }`])}`:``}${Z(e,`export`)?`
659
675
  // Browser Run: renders pages to PDF/PNG for /api/export.
660
- "browser": { "binding": "BROWSER" },`:``}${i||Q(e,`export`)?`
661
- // ${[i?`The Agents SDK`:``,Q(e,`export`)?`Cloudflare's puppeteer`:``].filter(Boolean).join(` and `)} use${i&&Q(e,`export`)?``:`s`} Node.js APIs.
676
+ "browser": { "binding": "BROWSER" },`:``}${i||Z(e,`export`)?`
677
+ // ${[i?`The Agents SDK`:``,Z(e,`export`)?`Cloudflare's puppeteer`:``].filter(Boolean).join(` and `)} use${i&&Z(e,`export`)?``:`s`} Node.js APIs.
662
678
  "compatibility_flags": ["nodejs_compat"],`:``}
663
679
  // Add bindings here (KV, D1, R2, Durable Objects, Workers AI) and read them from the
664
680
  // \`env\` argument of the Worker's fetch handler.
665
681
  }
666
- `}function Je(e){let t=Q(e,`digest`),n=Q(e,`social`),r=Q(e,`checkout`),i=Q(e,`newsletter`),a=X(e),o=[...e.auth===`access`?[`Cloudflare Access (README). Until both are set, the Worker refuses every request.`]:[],...a?[`Sign-in links go out through Email Service (README). AUTH_FROM must be an address on a`,`domain you have onboarded; until it is set, sign-in fails with a clear error.`]:[],...t?[`The weekly digest (README): who gets it, who sends it, and the deployed app's URL,`,`which the browser opens. Until they are set, each run is recorded as skipped.`]:[],...n?[`Reminders to connect LinkedIn again go out through Email Service from REMINDER_FROM, an`,`address on a domain you have onboarded, with links to APP_URL (README). Until both are`,`set, no reminder is sent.`]:[],...r?[`Receipts for paid orders go out through Email Service from RECEIPT_FROM, an address`,`on a domain you have onboarded (README). Until it is set, no receipt is sent.`]:[],...i?[`The newsletter sends through Amazon SES (README): the region your sending identity is`,`verified in, its From address, and the SNS topic SES reports bounces and complaints to.`]:[]],s=[...e.auth===`access`?[`ACCESS_TEAM_DOMAIN`,`ACCESS_AUD`]:[],...a?[`AUTH_FROM`]:[],...t?[`DIGEST_TO`,`DIGEST_FROM`,`APP_URL`]:[],...n?[`REMINDER_FROM`,...t?[]:[`APP_URL`]]:[],...r?[`RECEIPT_FROM`]:[],...i?[`AWS_REGION`,`NEWSLETTER_FROM`,`SNS_TOPIC_ARN`]:[]];if(s.length===0)return``;let c=s.map(e=>`"${e}": ""`),l=` "vars": { ${c.join(`, `)} },`,u=l.length<=100?l:` "vars": {\n${c.map(e=>` ${e},`).join(`
682
+ `}function Xe(e){let t=Z(e,`digest`),n=Z(e,`social`),r=Z(e,`checkout`),i=Z(e,`newsletter`),a=Y(e),o=[...e.auth===`access`?[`Cloudflare Access (README). Until both are set, the Worker refuses every request.`]:[],...a?[`Sign-in links go out through Email Service (README). AUTH_FROM must be an address on a`,`domain you have onboarded; until it is set, sign-in fails with a clear error.`]:[],...t?[`The weekly digest (README): who gets it, who sends it, and the deployed app's URL,`,`which the browser opens. Until they are set, each run is recorded as skipped.`]:[],...n?[`Reminders to connect LinkedIn again go out through Email Service from REMINDER_FROM, an`,`address on a domain you have onboarded, with links to APP_URL (README). Until both are`,`set, no reminder is sent.`]:[],...r?[`Receipts for paid orders go out through Email Service from RECEIPT_FROM, an address`,`on a domain you have onboarded (README). Until it is set, no receipt is sent.`]:[],...i?[`The newsletter sends through Amazon SES (README): the region your sending identity is`,`verified in, its From address, and the SNS topic SES reports bounces and complaints to.`]:[]],s=[...e.auth===`access`?[`ACCESS_TEAM_DOMAIN`,`ACCESS_AUD`]:[],...a?[`AUTH_FROM`]:[],...t?[`DIGEST_TO`,`DIGEST_FROM`,`APP_URL`]:[],...n?[`REMINDER_FROM`,...t?[]:[`APP_URL`]]:[],...r?[`RECEIPT_FROM`]:[],...i?[`AWS_REGION`,`NEWSLETTER_FROM`,`SNS_TOPIC_ARN`]:[]];if(s.length===0)return``;let c=s.map(e=>`"${e}": ""`),l=` "vars": { ${c.join(`, `)} },`,u=l.length<=100?l:` "vars": {\n${c.map(e=>` ${e},`).join(`
667
683
  `)}\n },`;return`
668
684
  ${o.map(e=>` // ${e}`).join(`
669
685
  `)}${a||t||r||n?`
670
686
  "send_email": [{ "name": "EMAIL" }],`:``}
671
- ${u}`}function Ye(e){let t=[...Q(e,`live`)?[{comment:[`Events for /ops: POST /api/events sends them, and the Worker's queue handler takes them in`,`batches of up to 100, or whatever arrived within a second.`],binding:`EVENTS`,queue:`${H(e.name)}-events`,consumer:[`"max_batch_size": 100`,`"max_batch_timeout": 1`]}]:[],...Q(e,`newsletter`)?[{comment:[`Newsletter sends (worker/newsletter.ts): one message of 25 readers at a time, so SES`,`is called at a steady pace. A throttled message is retried after 30 seconds.`],binding:`NEWSLETTER`,queue:Ze(e),consumer:[`"max_batch_size": 1`,`"max_concurrency": 1`,`"max_retries": 10`,`"retry_delay": 30`]}]:[]];return t.length===0?``:`
687
+ ${u}`}function Ze(e){let t=[...Z(e,`live`)?[{comment:[`Events for /ops: POST /api/events sends them, and the Worker's queue handler takes them in`,`batches of up to 100, or whatever arrived within a second.`],binding:`EVENTS`,queue:`${z(e.name)}-events`,consumer:[`"max_batch_size": 100`,`"max_batch_timeout": 1`]}]:[],...Z(e,`newsletter`)?[{comment:[`Newsletter sends (worker/newsletter.ts): one message of 25 readers at a time, so SES`,`is called at a steady pace. A throttled message is retried after 30 seconds.`],binding:`NEWSLETTER`,queue:$e(e),consumer:[`"max_batch_size": 1`,`"max_concurrency": 1`,`"max_retries": 10`,`"retry_delay": 30`]}]:[]];return t.length===0?``:`
672
688
  ${t.flatMap(e=>e.comment.map(e=>` // ${e}`)).join(`
673
689
  `)}
674
690
  "queues": {
675
- ${q(` `,`producers`,t.map(e=>`{ "binding": "${e.binding}", "queue": "${e.queue}" }`))}
691
+ ${K(` `,`producers`,t.map(e=>`{ "binding": "${e.binding}", "queue": "${e.queue}" }`))}
676
692
  "consumers": [
677
693
  ${t.map(e=>` {
678
694
  "queue": "${e.queue}",
@@ -681,7 +697,7 @@ ${e.consumer.map(e=>` ${e},`).join(`
681
697
  },`).join(`
682
698
  `)}
683
699
  ],
684
- },`}function J(e){return Q(e,`checkout`)&&Y(e)}function Y(e){return X(e)||Z(e)}function X(e){return e.auth===`email`||e.auth===`email,oauth`}function Xe(e){let t=[...new Set((e??``).toLowerCase().split(`,`).map(e=>e.trim()))].filter(Boolean);if(t.length===0)return null;let n=t.sort().join(`,`);return n===`access`||n===`email`||n===`oauth`||n===`email,oauth`?n:`invalid`}function Z(e){return e.auth===`oauth`||e.auth===`email,oauth`}function Ze(e){return`${H(e.name)}-newsletter`}function Q(e,t){return e.examples?.includes(t)??!1}function Qe(e){return`${H(e.name).replace(/[^a-z0-9_]/g,`_`).replace(/^[^a-z_]/,`_$&`)}_usage`}function $e(e){return Q(e,`files`)||Q(e,`export`)||Q(e,`publish`)||Q(e,`digest`)||Q(e,`search`)||Q(e,`checkout`)||Q(e,`newsletter`)||Q(e,`social`)||X(e)}function et(e){return Q(e,`crud`)||Q(e,`publish`)||Q(e,`webhooks`)||Q(e,`digest`)||Q(e,`search`)||Q(e,`checkout`)||Q(e,`newsletter`)||Y(e)}function tt(e){return $(e)||Q(e,`search`)}function $(e){return Q(e,`agent`)||Q(e,`voice`)}function nt(e){return Q(e,`board`)||Q(e,`notes`)||Q(e,`import`)||Q(e,`webhooks`)||Q(e,`checkout`)||Q(e,`newsletter`)}function rt(e){return $(e)||Q(e,`import`)||Q(e,`social`)}function it(e){return e.runtime??(Q(e,`agent`)?`react`:`preact`)}function at(e){let t=Q(e,`import`),n=Q(e,`files`),r=Q(e,`usage`),i=Q(e,`crud`),a=Q(e,`live`),o=Q(e,`publish`),s=Q(e,`webhooks`),c=Q(e,`digest`),l=Q(e,`search`),u=Q(e,`checkout`),d=Q(e,`newsletter`),f=J(e),p=Q(e,`social`);return`import { defineApi, ${t||n||r||i||a||o||s||c||l||u||d||p?`endpoint, `:``}stream } from '@cascivo/app/api'
700
+ },`}function q(e){return Z(e,`checkout`)&&J(e)}function J(e){return Y(e)||X(e)}function Y(e){return e.auth===`email`||e.auth===`email,oauth`}function Qe(e){let t=[...new Set((e??``).toLowerCase().split(`,`).map(e=>e.trim()))].filter(Boolean);if(t.length===0)return null;let n=t.sort().join(`,`);return n===`access`||n===`email`||n===`oauth`||n===`email,oauth`?n:`invalid`}function X(e){return e.auth===`oauth`||e.auth===`email,oauth`}function $e(e){return`${z(e.name)}-newsletter`}function Z(e,t){return e.examples?.includes(t)??!1}function et(e){return`${z(e.name).replace(/[^a-z0-9_]/g,`_`).replace(/^[^a-z_]/,`_$&`)}_usage`}function tt(e){return Z(e,`files`)||Z(e,`export`)||Z(e,`publish`)||Z(e,`digest`)||Z(e,`search`)||Z(e,`checkout`)||Z(e,`newsletter`)||Z(e,`social`)||Y(e)}function nt(e){return Z(e,`crud`)||Z(e,`publish`)||Z(e,`webhooks`)||Z(e,`digest`)||Z(e,`search`)||Z(e,`checkout`)||Z(e,`newsletter`)||J(e)}function rt(e){return Q(e)||Z(e,`search`)}function Q(e){return Z(e,`agent`)||Z(e,`voice`)}function it(e){return Z(e,`board`)||Z(e,`notes`)||Z(e,`import`)||Z(e,`webhooks`)||Z(e,`checkout`)||Z(e,`newsletter`)}function $(e){return Q(e)||Z(e,`import`)||Z(e,`social`)}function at(e){return e.runtime??(Z(e,`agent`)?`react`:`preact`)}function ot(e){let t=Z(e,`import`),n=Z(e,`files`),r=Z(e,`usage`),i=Z(e,`crud`),a=Z(e,`live`),o=Z(e,`publish`),s=Z(e,`webhooks`),c=Z(e,`digest`),l=Z(e,`search`),u=Z(e,`checkout`),d=Z(e,`newsletter`),f=q(e),p=Z(e,`social`);return`import { defineApi, ${t||n||r||i||a||o||s||c||l||u||d||p?`endpoint, `:``}stream } from '@cascivo/app/api'
685
701
  ${i?`import { parseTablePage, parseTableQuery } from '@cascivo/app/db'
686
702
  `:``}${n?`import { parseStoredFile } from '@cascivo/app/uploads'
687
703
  `:``}${t?`import { parseImportRequest, parseStarted } from './import-job'
@@ -877,7 +893,7 @@ export const api = defineApi({
877
893
  output: parseScheduledPost,
878
894
  }),`:``}
879
895
  })
880
- `}function ot(e){let t=nt(e),n=Q(e,`agent`),r=Q(e,`import`),i=Q(e,`files`),a=Q(e,`export`),o=Q(e,`usage`),s=Q(e,`crud`),c=Q(e,`live`),l=Q(e,`voice`),u=Q(e,`publish`),d=Q(e,`webhooks`),f=Q(e,`digest`),p=Q(e,`search`),m=Q(e,`checkout`),h=Q(e,`newsletter`),g=J(e),_=et(e),v=$(e),y=$e(e),b=e.auth===`access`,x=X(e),S=Z(e),C=Y(e),w=Q(e,`social`),T=[...b?[`requireAccess`]:[],...y?[`clientIp`,`rateLimit`]:[]],ee=t||v||i||a||b||c||y||u||C,te=v||i||a||b||y||d||u||m||h||C,E=[...r?[`job-`]:[],...d?[`webhooks$`]:[],...m?[`order-`]:[],...h?[`issue-`]:[]],D=[...d?[`/api/webhooks/`]:[],...m?[`/api/stripe/`]:[],...h?[`/api/sns/`]:[]],O=h?[`/api/newsletter/subscribe`,`/api/newsletter/confirm`,`/api/newsletter/unsubscribe`]:[],k=[...D,...O];return`${o?`import type { AnalyticsDataset } from '@cascivo/app/analytics'
896
+ `}function st(e){let t=it(e),n=Z(e,`agent`),r=Z(e,`import`),i=Z(e,`files`),a=Z(e,`export`),o=Z(e,`usage`),s=Z(e,`crud`),c=Z(e,`live`),l=Z(e,`voice`),u=Z(e,`publish`),d=Z(e,`webhooks`),f=Z(e,`digest`),p=Z(e,`search`),m=Z(e,`checkout`),h=Z(e,`newsletter`),g=q(e),_=nt(e),v=Q(e),y=tt(e),b=e.auth===`access`,x=Y(e),S=X(e),C=J(e),w=Z(e,`social`),T=[...b?[`requireAccess`]:[],...y?[`clientIp`,`rateLimit`]:[]],ee=t||v||i||a||b||c||y||u||C,E=v||i||a||b||y||d||u||m||h||C,D=[...r?[`job-`]:[],...d?[`webhooks$`]:[],...m?[`order-`]:[],...h?[`issue-`]:[]],O=[...d?[`/api/webhooks/`]:[],...m?[`/api/stripe/`]:[],...h?[`/api/sns/`]:[]],te=h?[`/api/newsletter/subscribe`,`/api/newsletter/confirm`,`/api/newsletter/unsubscribe`]:[],k=[...O,...te];return`${o?`import type { AnalyticsDataset } from '@cascivo/app/analytics'
881
897
  `:``}${_?`import type { Database } from '@cascivo/app/db'
882
898
  `:``}${a?`import { handleExport } from '@cascivo/app/export'
883
899
  `:``}import { createHandler${u?`, HttpError`:``} } from '@cascivo/app/api'
@@ -1160,7 +1176,7 @@ async function handleAndRecord(request: Request, env: Env): Promise<Response> {
1160
1176
  `:``}
1161
1177
  // wrangler.jsonc routes only ${v?`/api/* and /agents/*`:`/api/*`} here; everything else is a static asset or index.html.
1162
1178
  export default {
1163
- ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${te?``:` | Response`} {${b?`
1179
+ ${ee?` ${E?`async `:``}fetch(request: Request, env: Env): Promise<Response>${E?``:` | Response`} {${b?`
1164
1180
  // Cloudflare Access is in front of the app (README); this refuses a request that came
1165
1181
  // around it (straight to *.workers.dev, say). \`vite dev\` has no Access, so not there.
1166
1182
  if (!import.meta.env.DEV) {
@@ -1194,8 +1210,8 @@ ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${t
1194
1210
  errorPath: '/account',
1195
1211
  })(request)
1196
1212
  if (signInWith) return signInWith`:``}
1197
- // Every other API write needs a signed-in user; reads stay public.${D.length>0?`
1198
- // Webhooks carry a signature instead of a session, and are checked by it.`:``}${O.length>0?`
1213
+ // Every other API write needs a signed-in user; reads stay public.${O.length>0?`
1214
+ // Webhooks carry a signature instead of a session, and are checked by it.`:``}${te.length>0?`
1199
1215
  // Newsletter readers sign up, confirm and unsubscribe without an account.`:``}
1200
1216
  if (${k.length>0?`
1201
1217
  request.method !== 'GET' &&
@@ -1299,11 +1315,11 @@ ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${t
1299
1315
  const issueLive = /^\\/api\\/newsletter\\/issues\\/([^/]+)\\/live$/.exec(newsletterPath)
1300
1316
  if (issueLive && ISSUE_ID.test(issueLive[1]!)) {
1301
1317
  return roomResponse(request, env.ROOMS, issueRoom(issueLive[1]!), { readOnly: true })
1302
- }`:``}${Q(e,`board`)||Q(e,`notes`)?`
1303
- const room = /^\\/api\\/rooms\\/([^/]+)$/.exec(new URL(request.url).pathname)${E.length>0?`
1318
+ }`:``}${Z(e,`board`)||Z(e,`notes`)?`
1319
+ const room = /^\\/api\\/rooms\\/([^/]+)$/.exec(new URL(request.url).pathname)${D.length>0?`
1304
1320
  // Rooms only the server writes are watched read-only at their own routes, never opened
1305
1321
  // here: ${[r?`a job's progress`:``,d?`webhook deliveries`:``,m?`orders`:``,h?`newsletter issues`:``].filter(Boolean).join(`, `)}.
1306
- if (room && !/^(${E.join(`|`)})/.test(room[1]!)) {
1322
+ if (room && !/^(${D.join(`|`)})/.test(room[1]!)) {
1307
1323
  return roomResponse(request, env.ROOMS, room[1]!)
1308
1324
  }`:`
1309
1325
  if (room) return roomResponse(request, env.ROOMS, room[1]!)`}`:``}${r?`
@@ -1317,7 +1333,7 @@ ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${t
1317
1333
  // The Cron Triggers in wrangler.jsonc, told apart by their schedule.
1318
1334
  async scheduled(event: { cron: string }, env: Env): Promise<void> {
1319
1335
  // Threads tokens renewed, and reminders for those that cannot be (worker/social.ts).
1320
- if (event.cron === '${ft}') {
1336
+ if (event.cron === '${pt}') {
1321
1337
  await socialStore.renewConnections(env)
1322
1338
  return socialStore.remindExpiring(env)
1323
1339
  }
@@ -1337,7 +1353,7 @@ ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${t
1337
1353
  // Two queues, one handler: each batch says which queue it came from. A throw retries it.
1338
1354
  async queue(batch: LiveBatch & NewsletterBatch & { queue: string }, env: Env): Promise<void> {
1339
1355
  // NEWSLETTER: one message of readers at a time, through SES (worker/newsletter.ts).
1340
- if (batch.queue === '${Ze(e)}') return newsletterStore.deliver(env, batch)
1356
+ if (batch.queue === '${$e(e)}') return newsletterStore.deliver(env, batch)
1341
1357
  // EVENTS: into the dashboard's room.
1342
1358
  await recordLive(
1343
1359
  ops,
@@ -1361,12 +1377,12 @@ ${ee?` ${te?`async `:``}fetch(request: Request, env: Env): Promise<Response>${t
1361
1377
  await newsletterStore.deliver(env, batch)
1362
1378
  },`:``}
1363
1379
  }
1364
- `}function st(e,t){return t===0?`/`:`/${e.key}`}function ct(e,t){return t===0?`index.tsx`:`${e.key}.tsx`}function lt(e,t,n){let r=[...e.map((e,t)=>({label:e.label,href:st(e,t)})),...t.flatMap(e=>ne(e).nav)].map(e=>` {
1380
+ `}function ct(e,t){return t===0?`/`:`/${e.key}`}function lt(e,t){return t===0?`index.tsx`:`${e.key}.tsx`}function ut(e,t,n){let r=[...e.map((e,t)=>({label:e.label,href:ct(e,t)})),...t.flatMap(e=>ne(e).nav)].map(e=>` {
1365
1381
  label: '${e.label.replace(/'/g,`\\'`)}',
1366
1382
  href: '${e.href}',
1367
1383
  active: path === '${e.href}',
1368
1384
  },`).join(`
1369
- `),i=Q(n,`export`);return`import { RouterView } from '@cascivo/app'
1385
+ `),i=Z(n,`export`);return`import { RouterView } from '@cascivo/app'
1370
1386
  ${i?`import { isExporting } from '@cascivo/app/export'
1371
1387
  `:``}import { Spinner, useSignals, type SideNavItem } from '@cascivo/react'
1372
1388
  import { router } from './router'
@@ -1397,7 +1413,7 @@ ${i?`
1397
1413
  </Shell>
1398
1414
  )
1399
1415
  }
1400
- `}function ut(e){return`import { Flex, Heading, Text } from '@cascivo/react'
1416
+ `}function dt(e){return`import { Flex, Heading, Text } from '@cascivo/react'
1401
1417
  import { LiveCard } from '../LiveCard'
1402
1418
 
1403
1419
  export default function ${e.component}() {
@@ -1413,7 +1429,7 @@ export default function ${e.component}() {
1413
1429
  </Flex>
1414
1430
  )
1415
1431
  }
1416
- `}function dt(e,t){return we(e).replace(`export function ${e.component}()`,`export default function ${e.component}()`).replace(`src/sections/${e.component}.tsx`,`src/routes/${ct(e,t)}`)}const ft=`17 4 * * *`;function pt(e){let t=X(e),n=Z(e),r=t?n?`Continue with GitHub, Google or LinkedIn, or get a one-time link by email. No password.`:`No password: we email you a link that signs you in once.`:`Continue with GitHub, Google or LinkedIn. No password.`;return`import {
1432
+ `}function ft(e,t){return De(e).replace(`export function ${e.component}()`,`export default function ${e.component}()`).replace(`src/sections/${e.component}.tsx`,`src/routes/${lt(e,t)}`)}const pt=`17 4 * * *`;function mt(e){let t=Y(e),n=X(e),r=t?n?`Continue with GitHub, Google or LinkedIn, or get a one-time link by email. No password.`:`No password: we email you a link that signs you in once.`:`Continue with GitHub, Google or LinkedIn. No password.`;return`import {
1417
1433
  Alert,
1418
1434
  Button,
1419
1435
  Card,
@@ -1554,16 +1570,16 @@ export default function Account() {
1554
1570
  </Flex>
1555
1571
  )
1556
1572
  }
1557
- `}function mt(){return`${K()}# Rewritten by @cascivo/app/vite whenever a route file changes.
1573
+ `}function ht(){return`${U()}# Rewritten by @cascivo/app/vite whenever a route file changes.
1558
1574
  src/routes.gen.ts
1559
- `}function ht(){return`node_modules
1575
+ `}function gt(){return`node_modules
1560
1576
  dist
1561
1577
  .wrangler
1562
1578
  .dev.vars*
1563
1579
  !.dev.vars.example
1564
1580
  *.local
1565
1581
  .DS_Store
1566
- `}function gt(e){let t=e.pm??`npm`,n=it(e);return`# ${e.name}
1582
+ `}function _t(e){let t=e.pm??`npm`,n=at(e);return`# ${e.name}
1567
1583
 
1568
1584
  A [cascivo](https://cascivo.com) app on Cloudflare: a client-rendered
1569
1585
  ${n===`preact`?`Preact`:`React`} app and its API, deployed as one Worker.
@@ -1572,8 +1588,8 @@ There is no server rendering; the browser gets the app, and \`/api/*\` reaches t
1572
1588
  ## Develop
1573
1589
 
1574
1590
  \`\`\`sh
1575
- ${M(t)}
1576
- ${N(t,`dev`)}
1591
+ ${N(t)}
1592
+ ${P(t,`dev`)}
1577
1593
  \`\`\`
1578
1594
 
1579
1595
  \`vite dev\` runs \`worker/index.ts\` in workerd, the same runtime as production, via
@@ -1583,13 +1599,13 @@ ${N(t,`dev`)}
1583
1599
 
1584
1600
  \`\`\`sh
1585
1601
  npx wrangler login # once
1586
- ${P(t,`deploy`)}
1602
+ ${F(t,`deploy`)}
1587
1603
  \`\`\`
1588
1604
 
1589
1605
  ## Share a preview (no account)
1590
1606
 
1591
1607
  \`\`\`sh
1592
- ${P(t,`deploy:preview`)}
1608
+ ${F(t,`deploy:preview`)}
1593
1609
  \`\`\`
1594
1610
 
1595
1611
  This builds the app, then deploys it to a temporary Cloudflare account with
@@ -1600,7 +1616,7 @@ This builds the app, then deploys it to a temporary Cloudflare account with
1600
1616
 
1601
1617
  It works only while wrangler is logged out. If you are logged in, use \`deploy\` instead.
1602
1618
  A temporary account supports Workers, static assets, KV, D1 and Durable Objects. It does not
1603
- support Workers AI, R2, Workflows or Browser Run.${$(e)?` So a preview serves the app, but its ${Q(e,`agent`)?`assistant`:`voice page`} cannot reach the model: deploy it\nto your own account for that.`:``}
1619
+ support Workers AI, R2, Workflows or Browser Run.${Q(e)?` So a preview serves the app, but its ${Z(e,`agent`)?`assistant`:`voice page`} cannot reach the model: deploy it\nto your own account for that.`:``}
1604
1620
 
1605
1621
  ## Structure
1606
1622
 
@@ -1617,7 +1633,7 @@ support Workers AI, R2, Workflows or Browser Run.${$(e)?` So a preview serves th
1617
1633
  - \`src/Shell.tsx\` — the app shell (header + side nav + content slot).
1618
1634
 
1619
1635
  Persist client state with \`persistedSignal\` from \`@cascivo/storage\` (localStorage or
1620
- IndexedDB).${Q(e,`board`)?"\n\n## Board (multiplayer)\n\n`/board` is a shared board. Open it in two windows: notes, edits and cursors sync live.\n\n- `src/board.ts` — `connectRoom('/api/rooms/<name>')` from `@cascivo/app/sync`; `room.map('notes', parseNote)`\n is a signal every visitor shares, and `room.presence` carries cursors.\n- `worker/index.ts` — exports `SyncRoom`, one Durable Object per room, and routes\n `/api/rooms/:name` to it (bound as `ROOMS` in `wrangler.jsonc`).\n- `/board?room=team` is a separate board.\n\nEach path (one note) is last-writer-wins in the order the room receives writes, so two people\nediting the same note at once settle on one value; editing different notes never collides.\nDurable Objects work on a temporary account, so `deploy:preview` shares a live board with\nno Cloudflare account.":``}${Q(e,`notes`)?"\n\n## Notes (local-first)\n\n`/notes` keeps working when the connection drops. Edits are saved on this device and sync\nwhen the room is reachable again; a badge shows how many are still waiting.\n\n- `src/notes.ts` — `connectRoom(url, { storage: indexedDBDriver() })`: the room's last\n state and every unconfirmed edit are kept in IndexedDB, so offline edits survive a reload\n or a closed tab and go out on the next connection. `room.unsynced` counts them. (Opening\n the app with no network at all also needs its files cached, by a service worker.)\n- The list is `/notes?list=<name>`. Without one, each browser makes its own and remembers\n it; open the same `?list=` on another device to sync with it.\n- It uses the same `SyncRoom` Durable Object as any other room (`ROOMS` in\n `wrangler.jsonc`). To query notes across lists, override `SyncRoom.onWrite` and mirror\n each write into D1.\n\nA note is last-writer-wins: an edit made offline replaces whatever the note held when it\narrives. Edits to different notes never collide.":``}${Q(e,`import`)?"\n\n## Import (background job)\n\n`/import` runs a CSV import as a Cloudflare Workflow and shows its progress live.\n\n- `worker/import-job.ts` — `ImportJob`, the Workflow. Each `step.do` is retried on its own\n and its result kept, so a failure or a deploy resumes the job where it was. Put your writes\n in `importContacts`.\n- `src/import-job.ts` — the job (`defineJob` from `@cascivo/app/jobs`): its steps and the\n parser for its result, shared by both sides.\n- Progress is a read-only room: the Workflow reports with `jobReporter`\n (`@cascivo/app/jobs-server`), and the page watches `/api/jobs/:id` with `watchJob`. The job\n id is in the URL, so a reload or another tab picks the job back up.\n\nReport from inside a `step.do`: a Workflow replays `run()` from the top after each step, and\na report outside one would run again. Workflows run in `vite dev` locally, but not on a\ntemporary account, so `deploy:preview` serves the page without starting imports.":``}${Q(e,`files`)?`
1636
+ IndexedDB).${Z(e,`board`)?"\n\n## Board (multiplayer)\n\n`/board` is a shared board. Open it in two windows: notes, edits and cursors sync live.\n\n- `src/board.ts` — `connectRoom('/api/rooms/<name>')` from `@cascivo/app/sync`; `room.map('notes', parseNote)`\n is a signal every visitor shares, and `room.presence` carries cursors.\n- `worker/index.ts` — exports `SyncRoom`, one Durable Object per room, and routes\n `/api/rooms/:name` to it (bound as `ROOMS` in `wrangler.jsonc`).\n- `/board?room=team` is a separate board.\n\nEach path (one note) is last-writer-wins in the order the room receives writes, so two people\nediting the same note at once settle on one value; editing different notes never collides.\nDurable Objects work on a temporary account, so `deploy:preview` shares a live board with\nno Cloudflare account.":``}${Z(e,`notes`)?"\n\n## Notes (local-first)\n\n`/notes` keeps working when the connection drops. Edits are saved on this device and sync\nwhen the room is reachable again; a badge shows how many are still waiting.\n\n- `src/notes.ts` — `connectRoom(url, { storage: indexedDBDriver() })`: the room's last\n state and every unconfirmed edit are kept in IndexedDB, so offline edits survive a reload\n or a closed tab and go out on the next connection. `room.unsynced` counts them. (Opening\n the app with no network at all also needs its files cached, by a service worker.)\n- The list is `/notes?list=<name>`. Without one, each browser makes its own and remembers\n it; open the same `?list=` on another device to sync with it.\n- It uses the same `SyncRoom` Durable Object as any other room (`ROOMS` in\n `wrangler.jsonc`). To query notes across lists, override `SyncRoom.onWrite` and mirror\n each write into D1.\n\nA note is last-writer-wins: an edit made offline replaces whatever the note held when it\narrives. Edits to different notes never collide.":``}${Z(e,`import`)?"\n\n## Import (background job)\n\n`/import` runs a CSV import as a Cloudflare Workflow and shows its progress live.\n\n- `worker/import-job.ts` — `ImportJob`, the Workflow. Each `step.do` is retried on its own\n and its result kept, so a failure or a deploy resumes the job where it was. Put your writes\n in `importContacts`.\n- `src/import-job.ts` — the job (`defineJob` from `@cascivo/app/jobs`): its steps and the\n parser for its result, shared by both sides.\n- Progress is a read-only room: the Workflow reports with `jobReporter`\n (`@cascivo/app/jobs-server`), and the page watches `/api/jobs/:id` with `watchJob`. The job\n id is in the URL, so a reload or another tab picks the job back up.\n\nReport from inside a `step.do`: a Workflow replays `run()` from the top after each step, and\na report outside one would run again. Workflows run in `vite dev` locally, but not on a\ntemporary account, so `deploy:preview` serves the page without starting imports.":``}${Z(e,`files`)?`
1621
1637
 
1622
1638
  ## Files (uploads)
1623
1639
 
@@ -1632,8 +1648,8 @@ IndexedDB).${Q(e,`board`)?"\n\n## Board (multiplayer)\n\n`/board` is a shared bo
1632
1648
  - \`src/files.ts\` — \`startUpload\` gives each file progress and status signals.
1633
1649
 
1634
1650
  Each caller (by IP) may start 20 uploads a minute (\`ratelimits\` in \`wrangler.jsonc\`).${e.auth?``:"\n**It has no auth.** Anyone who can reach the app can upload: put Cloudflare Access in front of\nit (`--auth access`), add accounts (`--auth email`), or check who is asking in\n`worker/index.ts` before `handleUploads` runs."} Create the bucket once before deploying:
1635
- \`npx wrangler r2 bucket create ${H(e.name)}-files\`. R2 and Images do not run on a
1636
- temporary account.`:``}${Q(e,`export`)?'\n\n## Report (PDF and PNG export)\n\n`/report` has "Download PDF" and "Download PNG" buttons. The Worker renders the page in\nCloudflare\'s Browser Run and returns the file.\n\n- `worker/index.ts` — `handleExport` (`@cascivo/app/export`) serves\n `/api/export?page=/report&format=pdf`. It opens the page at this app\'s own origin with\n `?export=1`, waits for the network to go quiet, and prints it. Only paths of this app\n outside `/api/` can be exported.\n- `src/App.tsx` — `isExporting()` drops the shell, so the file holds the page alone.\n- For a scheduled report, call `exportPage` from a Cron Trigger and attach the PDF to an\n email (`sendEmail` from `@cascivo/email` takes `attachments`).\n\nThe browser opens the page without the visitor\'s cookies, so a page that needs a session\nrenders signed out. Each export starts a browser session, which is billed, so each caller\n(by IP) may start 20 a minute (`ratelimits` in `wrangler.jsonc`). In `vite dev` Browser Run starts a local Chrome (downloaded on\nfirst use); it does not run on a temporary account.':``}${Q(e,`live`)?`
1651
+ \`npx wrangler r2 bucket create ${z(e.name)}-files\`. R2 and Images do not run on a
1652
+ temporary account.`:``}${Z(e,`export`)?'\n\n## Report (PDF and PNG export)\n\n`/report` has "Download PDF" and "Download PNG" buttons. The Worker renders the page in\nCloudflare\'s Browser Run and returns the file.\n\n- `worker/index.ts` — `handleExport` (`@cascivo/app/export`) serves\n `/api/export?page=/report&format=pdf`. It opens the page at this app\'s own origin with\n `?export=1`, waits for the network to go quiet, and prints it. Only paths of this app\n outside `/api/` can be exported.\n- `src/App.tsx` — `isExporting()` drops the shell, so the file holds the page alone.\n- For a scheduled report, call `exportPage` from a Cron Trigger and attach the PDF to an\n email (`sendEmail` from `@cascivo/email` takes `attachments`).\n\nThe browser opens the page without the visitor\'s cookies, so a page that needs a session\nrenders signed out. Each export starts a browser session, which is billed, so each caller\n(by IP) may start 20 a minute (`ratelimits` in `wrangler.jsonc`). In `vite dev` Browser Run starts a local Chrome (downloaded on\nfirst use); it does not run on a temporary account.':``}${Z(e,`live`)?`
1637
1653
 
1638
1654
  ## Ops (live dashboard)
1639
1655
 
@@ -1653,7 +1669,7 @@ A new viewer, or one back from a dropped connection, starts with the whole windo
1653
1669
  at least once: a batch retried after a lost reply counts twice. \`/api/events\` has no auth, so
1654
1670
  anyone can move the numbers: check who is sending before real use (\`--auth access\` puts
1655
1671
  Cloudflare Access in front of the Worker). Create the queue once before deploying:
1656
- \`npx wrangler queues create ${H(e.name)}-events\`.`:``}${Q(e,`usage`)?"\n\n## Usage (analytics)\n\nEvery API request is recorded in Workers Analytics Engine, and `/usage` charts the last\n24 hours: requests per hour, the busiest routes, errors and latency.\n\n- `src/usage.ts` — `defineMetrics` (`@cascivo/app/analytics`) names the columns once\n (`path`, `method`, `status`, `duration_ms`), so writes and queries never disagree about\n which blob is which.\n- `worker/index.ts` — `handleAndRecord` writes one data point per API request.\n- `worker/usage.ts` — the queries, over Analytics Engine's SQL API.\n\nWriting needs only the binding. **Reading needs two secrets**, because the SQL API is HTTP\nwith an account token:\n\n```sh\nnpx wrangler secret put CF_ACCOUNT_ID\nnpx wrangler secret put CF_API_TOKEN # a token with Account Analytics: Read\n```\n\nFor `vite dev`, put both in `.dev.vars`. Data written locally is not in your account's\ndataset, so in development the charts show what your deployed app recorded. Until the secrets\nexist, the page says what to set.":``}${Q(e,`search`)?`
1672
+ \`npx wrangler queues create ${z(e.name)}-events\`.`:``}${Z(e,`usage`)?"\n\n## Usage (analytics)\n\nEvery API request is recorded in Workers Analytics Engine, and `/usage` charts the last\n24 hours: requests per hour, the busiest routes, errors and latency.\n\n- `src/usage.ts` — `defineMetrics` (`@cascivo/app/analytics`) names the columns once\n (`path`, `method`, `status`, `duration_ms`), so writes and queries never disagree about\n which blob is which.\n- `worker/index.ts` — `handleAndRecord` writes one data point per API request.\n- `worker/usage.ts` — the queries, over Analytics Engine's SQL API.\n\nWriting needs only the binding. **Reading needs two secrets**, because the SQL API is HTTP\nwith an account token:\n\n```sh\nnpx wrangler secret put CF_ACCOUNT_ID\nnpx wrangler secret put CF_API_TOKEN # a token with Account Analytics: Read\n```\n\nFor `vite dev`, put both in `.dev.vars`. Data written locally is not in your account's\ndataset, so in development the charts show what your deployed app recorded. Until the secrets\nexist, the page says what to set.":``}${Z(e,`search`)?`
1657
1673
 
1658
1674
  ## Search (by meaning)
1659
1675
 
@@ -1667,11 +1683,11 @@ and matched against it.
1667
1683
  every article; Vectorize applies writes a few seconds later.
1668
1684
 
1669
1685
  Create the index once before deploying, with the embedding model's dimensions:
1670
- \`npx wrangler vectorize create ${H(e.name)}-articles --dimensions=768 --metric=cosine\`.
1686
+ \`npx wrangler vectorize create ${z(e.name)}-articles --dimensions=768 --metric=cosine\`.
1671
1687
  Neither Vectorize nor Workers AI runs locally, so \`vite dev\` searches by keyword with SQLite's
1672
- full-text search instead, and the page says so. \`VITE_REAL_AI=1 ${N(t,`dev`)}\` uses the real ones
1688
+ full-text search instead, and the page says so. \`VITE_REAL_AI=1 ${P(t,`dev`)}\` uses the real ones
1673
1689
  (after \`npx wrangler login\`). Workers AI and Vectorize bill per use beyond their free
1674
- allocations, and a temporary account has neither.`:``}${Q(e,`digest`)?'\n\n## Weekly digest (Cron Trigger)\n\nEvery Monday at 08:00 UTC (`triggers.crons` in `wrangler.jsonc`), the Worker renders\n`/report` to a PDF with Browser Run and emails it. `/digest` lists each run — sent,\nskipped or failed, and why — and "Send now" runs one at once.\n\n- `worker/digest.ts` — `runDigest`: `exportPage` (`@cascivo/app/export`), then Email\n Service with the PDF attached. Every run is recorded in D1, so a digest that did not arrive\n says why.\n- `worker/index.ts` — the `scheduled` handler the Cron Trigger calls.\n\nSet `DIGEST_TO` (comma-separated), `DIGEST_FROM` (an address on a domain onboarded to Email\nService) and `APP_URL` (the deployed app\'s origin: a cron has no request to read it from) in\n`wrangler.jsonc`. Until they are set, runs are recorded as skipped. To fire the cron in\n`vite dev`, open `/cdn-cgi/handler/scheduled`; "Send now" uses the page\'s own origin, so it\nneeds no `APP_URL`. Browser Run starts a local Chrome in development.':``}${Q(e,`webhooks`)?"\n\n## Webhooks\n\n`/webhooks` lists GitHub webhook deliveries as they arrive. Point a repository's webhook at\n`https://<your app>/api/webhooks/github` (content type `application/json`) with a secret, and\ngive the Worker the same secret:\n`npx wrangler secret put WEBHOOK_SECRET`. Locally it is in `.dev.vars`, and \"Send a test\ndelivery\" signs one with it.\n\n- `worker/webhooks.ts` — `verifyWebhook` (`@cascivo/app/guard`) checks the\n `X-Hub-Signature-256` HMAC over the raw body before anything is parsed, and refuses a bad\n signature with a 401. Each delivery is stored in D1 under GitHub's delivery id, so a retry is ignored, and a\n new one is written to a read-only room the page watches.\n- `verifyWebhook` also checks Stripe (`scheme: 'stripe'`) and Standard Webhooks\n (`'standard'`: Svix, Clerk, Resend…), both with a five-minute timestamp window against\n replays.\n\nThe page answers within milliseconds, well inside GitHub's ten seconds. For slow work, send the\ndelivery to a Queue from `receiveGithub` and answer at once.":``}${Q(e,`checkout`)?`
1690
+ allocations, and a temporary account has neither.`:``}${Z(e,`digest`)?'\n\n## Weekly digest (Cron Trigger)\n\nEvery Monday at 08:00 UTC (`triggers.crons` in `wrangler.jsonc`), the Worker renders\n`/report` to a PDF with Browser Run and emails it. `/digest` lists each run — sent,\nskipped or failed, and why — and "Send now" runs one at once.\n\n- `worker/digest.ts` — `runDigest`: `exportPage` (`@cascivo/app/export`), then Email\n Service with the PDF attached. Every run is recorded in D1, so a digest that did not arrive\n says why.\n- `worker/index.ts` — the `scheduled` handler the Cron Trigger calls.\n\nSet `DIGEST_TO` (comma-separated), `DIGEST_FROM` (an address on a domain onboarded to Email\nService) and `APP_URL` (the deployed app\'s origin: a cron has no request to read it from) in\n`wrangler.jsonc`. Until they are set, runs are recorded as skipped. To fire the cron in\n`vite dev`, open `/cdn-cgi/handler/scheduled`; "Send now" uses the page\'s own origin, so it\nneeds no `APP_URL`. Browser Run starts a local Chrome in development.':``}${Z(e,`webhooks`)?"\n\n## Webhooks\n\n`/webhooks` lists GitHub webhook deliveries as they arrive. Point a repository's webhook at\n`https://<your app>/api/webhooks/github` (content type `application/json`) with a secret, and\ngive the Worker the same secret:\n`npx wrangler secret put WEBHOOK_SECRET`. Locally it is in `.dev.vars`, and \"Send a test\ndelivery\" signs one with it.\n\n- `worker/webhooks.ts` — `verifyWebhook` (`@cascivo/app/guard`) checks the\n `X-Hub-Signature-256` HMAC over the raw body before anything is parsed, and refuses a bad\n signature with a 401. Each delivery is stored in D1 under GitHub's delivery id, so a retry is ignored, and a\n new one is written to a read-only room the page watches.\n- `verifyWebhook` also checks Stripe (`scheme: 'stripe'`) and Standard Webhooks\n (`'standard'`: Svix, Clerk, Resend…), both with a five-minute timestamp window against\n replays.\n\nThe page answers within milliseconds, well inside GitHub's ten seconds. For slow work, send the\ndelivery to a Queue from `receiveGithub` and answer at once.":``}${Z(e,`checkout`)?`
1675
1691
 
1676
1692
  ## Checkout (Stripe)
1677
1693
 
@@ -1714,7 +1730,7 @@ browser cannot change it.
1714
1730
  - \`src/routes/checkout/[order].tsx\` — where Stripe sends the buyer back. It watches the
1715
1731
  order's read-only room, so it updates when the webhook arrives.
1716
1732
 
1717
- Each caller (by IP) may start 20 checkouts a minute.${J(e)?`
1733
+ Each caller (by IP) may start 20 checkouts a minute.${q(e)?`
1718
1734
 
1719
1735
  ### Subscriptions (\`/billing\`)
1720
1736
 
@@ -1742,7 +1758,7 @@ pause or cancel it in Stripe's hosted billing portal, so the app has no billing
1742
1758
 
1743
1759
  Subscriptions need an account to belong to: \`cascivo create --framework cloudflare
1744
1760
  --example checkout --auth email\` adds a \`/billing\` page with a monthly plan and Stripe's
1745
- billing portal.`}`:``}${Q(e,`newsletter`)?`
1761
+ billing portal.`}`:``}${Z(e,`newsletter`)?`
1746
1762
 
1747
1763
  ## Newsletter (Amazon SES)
1748
1764
 
@@ -1764,7 +1780,7 @@ To send for real:
1764
1780
  3. Bounces and complaints: create an SNS topic, set it as the SES identity's bounce and
1765
1781
  complaint notification topic, and subscribe \`https://<your app>/api/sns/ses\` to it (HTTPS).
1766
1782
  Put the topic's ARN in \`SNS_TOPIC_ARN\`. The Worker confirms the subscription itself.
1767
- 4. Create the queue once: \`npx wrangler queues create ${Ze(e)}\`.
1783
+ 4. Create the queue once: \`npx wrangler queues create ${$e(e)}\`.
1768
1784
 
1769
1785
  - \`worker/newsletter.ts\` — double opt-in: a sign-up gets a confirmation link (valid a day,
1770
1786
  resent at most every ten minutes) and gets no issue until it is opened. Sending stores the
@@ -1783,7 +1799,7 @@ To send for real:
1783
1799
 
1784
1800
  Sign-ups and every use of the newsletter key count against the rate limit (20 a minute per
1785
1801
  IP). Sending reads every confirmed address into memory; past a few hundred thousand readers,
1786
- page through them instead.`:``}${Q(e,`social`)?`
1802
+ page through them instead.`:``}${Z(e,`social`)?`
1787
1803
 
1788
1804
  ## Social posts
1789
1805
 
@@ -1830,7 +1846,7 @@ client). Each channel in a connected Buffer is an account in the composer, check
1830
1846
  its network's limit. Buffer counts every request against your plan's budget (100 per 15
1831
1847
  minutes on every plan), for all your users together, so the channel list is kept for an hour.
1832
1848
  Buffer cannot deduplicate, so its posts are never retried, like LinkedIn's. **LinkedIn** needs an app at https://www.linkedin.com/developers/apps with the
1833
- "Share on LinkedIn" product${Z(e)?` (the same app as sign-in works, with both products)`:``}; add
1849
+ "Share on LinkedIn" product${X(e)?` (the same app as sign-in works, with both products)`:``}; add
1834
1850
  \`…/api/connections/linkedin/callback\` as a redirect URL and set \`LINKEDIN_CLIENT_ID\` and
1835
1851
  \`LINKEDIN_CLIENT_SECRET\`. LinkedIn tokens last 60 days and cannot be renewed: the page shows
1836
1852
  "expires soon" a week ahead, and connecting again renews the account in place. The daily Cron
@@ -1845,28 +1861,28 @@ permissions, and \`…/api/connections/threads/callback\` as a redirect callback
1845
1861
  \`THREADS_APP_ID\` and \`THREADS_APP_SECRET\` (the Threads app id and secret, not the Meta
1846
1862
  app's). Until Meta's App Review and business verification pass, only people added as testers
1847
1863
  on the app can connect. A Threads token lasts 60 days and renews itself only while it still
1848
- works, so a daily Cron Trigger (\`${ft}\`, \`renewConnections\`) renews those in their last
1864
+ works, so a daily Cron Trigger (\`${pt}\`, \`renewConnections\`) renews those in their last
1849
1865
  30 days; try it in \`vite dev\` at \`/cdn-cgi/handler/scheduled\`. Threads takes 500 characters,
1850
1866
  counting an emoji as several, and cannot deduplicate either.
1851
1867
 
1852
1868
  Connecting an account and posting count against the rate limit (20 a minute per IP).
1853
- Workflows need a real Cloudflare account to deploy.`:``}${Y(e)?`
1869
+ Workflows need a real Cloudflare account to deploy.`:``}${J(e)?`
1854
1870
 
1855
- ## Accounts (${X(e)?Z(e)?`email, GitHub, Google and LinkedIn sign-in`:`email sign-in`:`GitHub, Google and LinkedIn sign-in`})
1871
+ ## Accounts (${Y(e)?X(e)?`email, GitHub, Google and LinkedIn sign-in`:`email sign-in`:`GitHub, Google and LinkedIn sign-in`})
1856
1872
 
1857
- ${X(e)&&Z(e)?"Anyone can create an account by continuing with GitHub, Google or LinkedIn, or with their email address, on `/account`.":Z(e)?"Anyone can create an account by continuing with GitHub, Google or LinkedIn on `/account`.":"Anyone can create an account with their email address: `/account` emails a one-time link, and opening it signs them in with a session cookie."} **Every API write needs a signed-in user; reads stay public.**
1873
+ ${Y(e)&&X(e)?"Anyone can create an account by continuing with GitHub, Google or LinkedIn, or with their email address, on `/account`.":X(e)?"Anyone can create an account by continuing with GitHub, Google or LinkedIn on `/account`.":"Anyone can create an account with their email address: `/account` emails a one-time link, and opening it signs them in with a session cookie."} **Every API write needs a signed-in user; reads stay public.**
1858
1874
 
1859
- - \`worker/index.ts\` — ${[X(e)?"`handleAuth` (`@cascivo/app/auth-server`)":``,Z(e)?"`handleOAuth` (`@cascivo/app/oauth-server`)":``].filter(Boolean).join(` and `)} answer${X(e)&&Z(e)?``:`s`} \`/api/auth/*\`, and
1875
+ - \`worker/index.ts\` — ${[Y(e)?"`handleAuth` (`@cascivo/app/auth-server`)":``,X(e)?"`handleOAuth` (`@cascivo/app/oauth-server`)":``].filter(Boolean).join(` and `)} answer${Y(e)&&X(e)?``:`s`} \`/api/auth/*\`, and
1860
1876
  \`requireUser\` refuses any other write without a session (401) or from another site (403).
1861
- Call \`requireUser(env.DB, request)\` in a handler to know who is asking.${X(e)?"\n- `worker/auth.ts` — sends the link through Email Service. Set `AUTH_FROM` in\n `wrangler.jsonc` to an address on a domain you have onboarded to Email Service.":``}
1877
+ Call \`requireUser(env.DB, request)\` in a handler to know who is asking.${Y(e)?"\n- `worker/auth.ts` — sends the link through Email Service. Set `AUTH_FROM` in\n `wrangler.jsonc` to an address on a domain you have onboarded to Email Service.":``}
1862
1878
  - \`src/auth.ts\` — \`auth.user\`, a signal every page can read. \`user.email\` is \`null\` for
1863
- someone whose provider shared no verified address.${X(e)?`
1879
+ someone whose provider shared no verified address.${Y(e)?`
1864
1880
  - \`src/routes/signin/verify.tsx\` — the page a link opens. It signs in on a button press,
1865
1881
  because mail scanners open every link in a message.`:``}
1866
1882
 
1867
- Users${X(e)?`, links`:``} and sessions live in D1, stored as hashes. ${X(e)?`Links expire after 15 minutes and work once; sessions`:`Sessions`} last 30 days.${X(e)?" Each caller (by IP) may request 20 links a minute. In `vite dev` no email is sent: the Account page shows the link instead.":``} WebSocket connections
1883
+ Users${Y(e)?`, links`:``} and sessions live in D1, stored as hashes. ${Y(e)?`Links expire after 15 minutes and work once; sessions`:`Sessions`} last 30 days.${Y(e)?" Each caller (by IP) may request 20 links a minute. In `vite dev` no email is sent: the Account page shows the link instead.":``} WebSocket connections
1868
1884
  (rooms, agents) are not covered by the write rule; check \`currentUser\` before forwarding them
1869
- if they need a user.${Z(e)?`
1885
+ if they need a user.${X(e)?`
1870
1886
 
1871
1887
  ### GitHub, Google and LinkedIn
1872
1888
 
@@ -1886,7 +1902,7 @@ if they need a user.${Z(e)?`
1886
1902
  People are matched by their account at the provider, not by email. A new sign-in joins an
1887
1903
  existing account only through an email the provider has verified (GitHub's primary verified
1888
1904
  address, Google's and LinkedIn's \`email_verified\`). A signed-in user who follows another provider's link
1889
- adds it to their account.`:``}`:``}${e.auth===`access`?'\n\n## Access (who may use the app)\n\nThe Worker refuses every request Cloudflare Access did not let through: `requireAccess`\n(`@cascivo/app/guard`) at the top of `worker/index.ts` verifies the token Access signs.\n\n1. In Cloudflare One (Zero Trust), add a self-hosted Access application for this app\'s\n hostname, with a policy saying who may sign in.\n2. Put your team domain (`<team>.cloudflareaccess.com`) and the application\'s Audience (AUD)\n tag in `vars` in `wrangler.jsonc`, and deploy.\n\nUntil both are set, every API request answers 500 ("Access is not configured"). Access guards\nthe pages at the edge; the Worker\'s check also refuses API calls that reach it around Access,\nat `*.workers.dev` for example (set `"workers_dev": false` if the app should have no public\naddress at all). `vite dev` skips the check. A temporary account has no Access, so an app made\nwith `--auth access` cannot use `deploy:preview`.':``}${Q(e,`crud`)?"\n\n## Customers (D1)\n\n`/customers` is a D1 table behind `DataTable`'s server mode: sorting, search, the name and\nseats filters, and paging all run as SQL in the Worker, and the page shows one page at a time.\n\n- `src/customers.ts` — `defineTable` (`@cascivo/app/db`) lists what may be sorted, searched and\n filtered. `queryTable` builds SQL from that list only, with every value a bound parameter:\n a query for any other column is refused with a 400.\n- `worker/migrations.ts` — the schema and 60 sample rows. The Worker applies them itself on its\n first query (`migrate`), so a fresh deploy, the Deploy button and `deploy:preview` need no\n migration step. Append migrations; never edit one that has shipped.\n- `worker/customers.ts` — create, update and delete, each checked by `parseCustomerInput`.\n\nD1 works on a temporary account, so `deploy:preview` shares the table with no sign-up. If you\nprefer wrangler's own migrations (`wrangler d1 migrations apply`), move the SQL into\n`migrations/` and drop the `migrate` call.":``}${Q(e,`agent`)?`
1905
+ adds it to their account.`:``}`:``}${e.auth===`access`?'\n\n## Access (who may use the app)\n\nThe Worker refuses every request Cloudflare Access did not let through: `requireAccess`\n(`@cascivo/app/guard`) at the top of `worker/index.ts` verifies the token Access signs.\n\n1. In Cloudflare One (Zero Trust), add a self-hosted Access application for this app\'s\n hostname, with a policy saying who may sign in.\n2. Put your team domain (`<team>.cloudflareaccess.com`) and the application\'s Audience (AUD)\n tag in `vars` in `wrangler.jsonc`, and deploy.\n\nUntil both are set, every API request answers 500 ("Access is not configured"). Access guards\nthe pages at the edge; the Worker\'s check also refuses API calls that reach it around Access,\nat `*.workers.dev` for example (set `"workers_dev": false` if the app should have no public\naddress at all). `vite dev` skips the check. A temporary account has no Access, so an app made\nwith `--auth access` cannot use `deploy:preview`.':``}${Z(e,`crud`)?"\n\n## Customers (D1)\n\n`/customers` is a D1 table behind `DataTable`'s server mode: sorting, search, the name and\nseats filters, and paging all run as SQL in the Worker, and the page shows one page at a time.\n\n- `src/customers.ts` — `defineTable` (`@cascivo/app/db`) lists what may be sorted, searched and\n filtered. `queryTable` builds SQL from that list only, with every value a bound parameter:\n a query for any other column is refused with a 400.\n- `worker/migrations.ts` — the schema and 60 sample rows. The Worker applies them itself on its\n first query (`migrate`), so a fresh deploy, the Deploy button and `deploy:preview` need no\n migration step. Append migrations; never edit one that has shipped.\n- `worker/customers.ts` — create, update and delete, each checked by `parseCustomerInput`.\n\nD1 works on a temporary account, so `deploy:preview` shares the table with no sign-up. If you\nprefer wrangler's own migrations (`wrangler d1 migrations apply`), move the SQL into\n`migrations/` and drop the `migrate` call.":``}${Z(e,`agent`)?`
1890
1906
 
1891
1907
  ## Assistant (generative UI)
1892
1908
 
@@ -1902,10 +1918,10 @@ again. The page renders the result with \`<CascivoView>\`: real components, no g
1902
1918
  - \`src/assistant.ts\` — \`checkView\`, the one check both sides run on a view.
1903
1919
  - \`src/routes/assistant.tsx\` — \`useAgent\` + \`useAgentChat\`; one conversation per browser.
1904
1920
  - \`worker/scripted-model.ts\` — \`vite dev\` answers from this scripted model, so the page works
1905
- offline and without an account. \`VITE_REAL_AI=1 ${N(t,`dev`)}\` uses Workers AI instead
1921
+ offline and without an account. \`VITE_REAL_AI=1 ${P(t,`dev`)}\` uses Workers AI instead
1906
1922
  (after \`npx wrangler login\`); a deployed Worker always does.
1907
1923
 
1908
- Workers AI bills per use beyond its free daily allocation.`:``}${Q(e,`publish`)?`
1924
+ Workers AI bills per use beyond its free daily allocation.`:``}${Z(e,`publish`)?`
1909
1925
 
1910
1926
  ## Publish (views as pages)
1911
1927
 
@@ -1923,10 +1939,10 @@ code of its author's and needs no sandbox.
1923
1939
  - \`src/routes/p/[slug].tsx\` — a published page.
1924
1940
  - \`worker/page-html.ts\` — the Worker answers \`/p/<slug>\` with index.html carrying the
1925
1941
  page's title, description and Open Graph tags, so a shared link previews properly, and the
1926
- rendered page in a \`<noscript>\` for readers without JavaScript.${Q(e,`export`)?"\n- `worker/page-preview.ts` — the preview image (`og:image`, 1200 × 630): Browser Run\n renders the page once, and D1 keeps the PNG.":``}
1942
+ rendered page in a \`<noscript>\` for readers without JavaScript.${Z(e,`export`)?"\n- `worker/page-preview.ts` — the preview image (`og:image`, 1200 × 630): Browser Run\n renders the page once, and D1 keeps the PNG.":``}
1927
1943
 
1928
1944
  ${e.auth?``:"**Anyone who can reach the app can publish**, and a page is served from your domain: put\nCloudflare Access in front (`--auth access`), add accounts (`--auth email`), or check who\nis publishing in `worker/index.ts`. "}Each caller (by IP) may publish 20 pages a minute (\`ratelimits\` in
1929
- \`wrangler.jsonc\`). D1 works on a temporary account.`:``}${Q(e,`voice`)?`
1945
+ \`wrangler.jsonc\`). D1 works on a temporary account.`:``}${Z(e,`voice`)?`
1930
1946
 
1931
1947
  ## Voice
1932
1948
 
@@ -1941,7 +1957,7 @@ reply to interrupt it. Typed messages work too.
1941
1957
  it, and plays the replies; its events become signals the page reads.
1942
1958
  - \`worker/scripted-voice.ts\` — \`vite dev\` stand-ins, because Workers AI has no local mode:
1943
1959
  the transcriber "hears" a fixed question for every three seconds of sound, and the replies
1944
- are text only. \`VITE_REAL_AI=1 ${N(t,`dev`)}\` uses Workers AI instead (after
1960
+ are text only. \`VITE_REAL_AI=1 ${P(t,`dev`)}\` uses Workers AI instead (after
1945
1961
  \`npx wrangler login\`); a deployed Worker always does.
1946
1962
 
1947
1963
  Browsers allow the microphone only on a secure origin: \`localhost\` or HTTPS. Workers AI
@@ -1951,10 +1967,10 @@ Add more components with \`npx cascivo add <component>\`.
1951
1967
 
1952
1968
  ## ${n===`preact`?`Preact or React`:`React or Preact`}
1953
1969
 
1954
- ${Q(e,`agent`)?`This app runs on React. The Agents SDK's hooks call React 19's \`use()\`, which
1970
+ ${Z(e,`agent`)?`This app runs on React. The Agents SDK's hooks call React 19's \`use()\`, which
1955
1971
  Preact's compat layer does not implement, so the assistant page needs React. (The other pages
1956
1972
  would run on Preact unchanged: the source is typed against React either way.)`:"The source is typed against React. The runtime is one plugin in `vite.config.ts`:\n`@preact/preset-vite` runs it on Preact, `@vitejs/plugin-react` on React. Switching\nneeds no source changes; swap the plugin and the matching dependencies. For this starter,\nPreact ships about a third of the client JS (~27 KB gzip against ~85 KB)."}
1957
- `}function _t(e){return`${ke(e)}
1973
+ `}function vt(e){return`${W(e)}
1958
1974
  ## Server
1959
1975
 
1960
1976
  The API contract is \`src/api.ts\` (\`defineApi\` from \`@cascivo/app/api\`); its handlers are
@@ -1972,20 +1988,20 @@ and build a path with \`buildPath('/c/:id', { id })\`, both from \`@cascivo/app\
1972
1988
 
1973
1989
  ## Sharing
1974
1990
 
1975
- To show the user a running version, run \`${P(e.pm??`npm`,`deploy:preview`)}\`.
1991
+ To show the user a running version, run \`${F(e.pm??`npm`,`deploy:preview`)}\`.
1976
1992
  It needs no Cloudflare account. Give the user both URLs it prints: the live one, and the
1977
1993
  claim URL. The deployment is public, and it is deleted after 60 minutes unless the user
1978
1994
  opens the claim URL and signs in.
1979
- `}function vt(e){let t=ye(e),n=t.indexOf(` * Adding a router?`),r=t.indexOf(` */
1995
+ `}function yt(e){let t=Se(e),n=t.indexOf(` * Adding a router?`),r=t.indexOf(` */
1980
1996
  export function Shell`);return t.slice(0,n)+` * Routing lives in src/router.ts; nav items carry \`href\`s, and main.tsx registers the
1981
1997
  * router's Link so they navigate client-side.
1982
- `+t.slice(r)}function yt(e){return[...Q(e,`webhooks`)?[`# The secret vite dev signs and checks test webhook deliveries with.`,`WEBHOOK_SECRET=dev-only-webhook-secret`]:[],...Q(e,`checkout`)?[`# Stripe, in test mode (README): the secret key from the dashboard, and the signing`,"# secret `stripe listen` prints.",`STRIPE_SECRET_KEY=`,`STRIPE_WEBHOOK_SECRET=`]:[],...Q(e,`newsletter`)?[`# The key /newsletter/send asks for. Deployed, choose a long random one.`,`NEWSLETTER_KEY=dev-only-newsletter-key`,`# An IAM user allowed ses:SendEmail (README). Without them, vite dev logs each email.`,`AWS_ACCESS_KEY_ID=`,`AWS_SECRET_ACCESS_KEY=`]:[],...Z(e)?[`# Seals the sign-in state between the redirect and the callback. Deployed, a random one:`,`# openssl rand -base64 32`,`AUTH_SECRET=dev-only-auth-secret-0123456789abcdef`,`# A GitHub OAuth App, a Google OAuth client and a LinkedIn app (README).`,`# Each provider is offered once both its id and secret are set.`,`GITHUB_CLIENT_ID=`,`GITHUB_CLIENT_SECRET=`,`GOOGLE_CLIENT_ID=`,`GOOGLE_CLIENT_SECRET=`,`LINKEDIN_CLIENT_ID=`,`LINKEDIN_CLIENT_SECRET=`]:Q(e,`social`)?[`# Seals connected accounts' tokens. Deployed, a random one: openssl rand -base64 32`,`AUTH_SECRET=dev-only-auth-secret-0123456789abcdef`,`# A LinkedIn app with "Share on LinkedIn" (README). Mastodon needs nothing.`,`LINKEDIN_CLIENT_ID=`,`LINKEDIN_CLIENT_SECRET=`]:[],...Q(e,`social`)?[`# Optional: an ES256 private JWK with a kid, so Bluesky sessions last (README).`,`BLUESKY_PRIVATE_JWK=`,`# Optional: a Buffer app client (publish.buffer.com/settings/api), to post to its channels.`,`BUFFER_CLIENT_ID=`,`BUFFER_CLIENT_SECRET=`,`# Optional: a Meta app with the Threads use case (README), to post to Threads.`,`THREADS_APP_ID=`,`THREADS_APP_SECRET=`]:[]].map(e=>`${e}\n`).join(``)}function bt(e){return yt(e).split(`
1998
+ `+t.slice(r)}function bt(e){return[...Z(e,`webhooks`)?[`# The secret vite dev signs and checks test webhook deliveries with.`,`WEBHOOK_SECRET=dev-only-webhook-secret`]:[],...Z(e,`checkout`)?[`# Stripe, in test mode (README): the secret key from the dashboard, and the signing`,"# secret `stripe listen` prints.",`STRIPE_SECRET_KEY=`,`STRIPE_WEBHOOK_SECRET=`]:[],...Z(e,`newsletter`)?[`# The key /newsletter/send asks for. Deployed, choose a long random one.`,`NEWSLETTER_KEY=dev-only-newsletter-key`,`# An IAM user allowed ses:SendEmail (README). Without them, vite dev logs each email.`,`AWS_ACCESS_KEY_ID=`,`AWS_SECRET_ACCESS_KEY=`]:[],...X(e)?[`# Seals the sign-in state between the redirect and the callback. Deployed, a random one:`,`# openssl rand -base64 32`,`AUTH_SECRET=dev-only-auth-secret-0123456789abcdef`,`# A GitHub OAuth App, a Google OAuth client and a LinkedIn app (README).`,`# Each provider is offered once both its id and secret are set.`,`GITHUB_CLIENT_ID=`,`GITHUB_CLIENT_SECRET=`,`GOOGLE_CLIENT_ID=`,`GOOGLE_CLIENT_SECRET=`,`LINKEDIN_CLIENT_ID=`,`LINKEDIN_CLIENT_SECRET=`]:Z(e,`social`)?[`# Seals connected accounts' tokens. Deployed, a random one: openssl rand -base64 32`,`AUTH_SECRET=dev-only-auth-secret-0123456789abcdef`,`# A LinkedIn app with "Share on LinkedIn" (README). Mastodon needs nothing.`,`LINKEDIN_CLIENT_ID=`,`LINKEDIN_CLIENT_SECRET=`]:[],...Z(e,`social`)?[`# Optional: an ES256 private JWK with a kid, so Bluesky sessions last (README).`,`BLUESKY_PRIVATE_JWK=`,`# Optional: a Buffer app client (publish.buffer.com/settings/api), to post to its channels.`,`BUFFER_CLIENT_ID=`,`BUFFER_CLIENT_SECRET=`,`# Optional: a Meta app with the Threads use case (README), to post to Threads.`,`THREADS_APP_ID=`,`THREADS_APP_SECRET=`]:[]].map(e=>`${e}\n`).join(``)}function xt(e){return bt(e).split(`
1983
1999
  `).map(e=>e.startsWith(`#`)?e:e.replace(/=.*$/,`=`)).join(`
1984
- `)}function xt(e){let t=e=>Object.fromEntries(e.map(([e,t])=>[e,{description:t}]));return{...Q(e,`webhooks`)?t([[`WEBHOOK_SECRET`,"The secret of the GitHub webhook that posts to `/api/webhooks/github`."]]):{},...Q(e,`checkout`)?t([[`STRIPE_SECRET_KEY`,"Your Stripe secret key, from the [API keys page](https://dashboard.stripe.com/test/apikeys). A test key (`sk_test_…`) takes test cards only."],[`STRIPE_WEBHOOK_SECRET`,"The signing secret (`whsec_…`) of a Stripe webhook endpoint at `https://<this app>/api/stripe/webhook`. No endpoint yet? Enter `later`: orders are confirmed on their own page without it. Set the real one with `npx wrangler secret put STRIPE_WEBHOOK_SECRET`."],[`RECEIPT_FROM`,`The From address of receipts, on a domain onboarded to Cloudflare Email Service. Leave it empty to send none.`]]):{},...Q(e,`newsletter`)?t([[`NEWSLETTER_KEY`,"The key `/newsletter/send` asks for. Make a long random one: `openssl rand -hex 32`."],[`AWS_ACCESS_KEY_ID`,"An IAM user allowed `ses:SendEmail` and nothing else (README)."],[`AWS_SECRET_ACCESS_KEY`,`That IAM user's secret access key.`],[`AWS_REGION`,"The SES region your sending domain is verified in, e.g. `eu-west-1`."],[`NEWSLETTER_FROM`,`The From address of issues, on your SES-verified domain.`],[`SNS_TOPIC_ARN`,"The SNS topic SES reports bounces and complaints to, subscribed to `https://<this app>/api/sns/ses`."]]):{},...Z(e)?t([[`AUTH_SECRET`,"Seals the sign-in state between the redirect to GitHub, Google or LinkedIn and the way back. Make a random one: `openssl rand -base64 32`."],[`GITHUB_CLIENT_ID`,"The client id of a [GitHub OAuth App](https://github.com/settings/developers) whose callback URL is `https://<this app>/api/auth/oauth/github/callback`. Leave it empty to offer no GitHub sign-in."],[`GITHUB_CLIENT_SECRET`,`That OAuth App's client secret.`],[`GOOGLE_CLIENT_ID`,"The client id of a Google OAuth client (Web application) with the redirect URI `https://<this app>/api/auth/oauth/google/callback`. Leave it empty to offer no Google sign-in."],[`GOOGLE_CLIENT_SECRET`,`That OAuth client's secret.`],[`LINKEDIN_CLIENT_ID`,'The client id of a LinkedIn app with the "Sign In with LinkedIn using OpenID Connect" product and the redirect URL `https://<this app>/api/auth/oauth/linkedin/callback`. Leave it empty to offer no LinkedIn sign-in.'],[`LINKEDIN_CLIENT_SECRET`,`That LinkedIn app's primary client secret.`]]):Q(e,`social`)?t([[`AUTH_SECRET`,"Seals the tokens of the accounts people connect. Make a random one: `openssl rand -base64 32`."],[`LINKEDIN_CLIENT_ID`,'The client id of a LinkedIn app with the "Share on LinkedIn" product and the redirect URL `https://<this app>/api/connections/linkedin/callback`. Leave it empty to offer no LinkedIn.'],[`LINKEDIN_CLIENT_SECRET`,`That LinkedIn app's primary client secret.`]]):{},...Q(e,`social`)?t([[`BLUESKY_PRIVATE_JWK`,"Optional. An ES256 private key as a JWK with a `kid` (README shows how to make one). With it, Bluesky sessions last until revoked; without it, two weeks."],[`BUFFER_CLIENT_ID`,"Optional. A Buffer app client (https://publish.buffer.com/settings/api) with the redirect URL `https://<this app>/api/connections/buffer/callback`. Leave it empty to offer no Buffer."],[`BUFFER_CLIENT_SECRET`,`That Buffer app client's secret (none for a public client).`],[`THREADS_APP_ID`,"Optional. The Threads app id of a Meta app with the Threads use case, and `https://<this app>/api/connections/threads/callback` as its redirect callback URL. Leave it empty to offer no Threads."],[`THREADS_APP_SECRET`,`That Threads app's secret.`]]):{}}}const St=[`agent`,`board`,`notes`,`import`,`files`,`export`,`usage`,`crud`,`live`,`voice`,`publish`,`publish-preview`,`webhooks`,`digest`,`search`,`checkout`,`billing`,`newsletter`,`social`,`accounts`,`auth-email`];function Ct(e,t){switch(e){case`publish-preview`:return Q(t,`publish`)&&Q(t,`export`);case`billing`:return J(t);case`accounts`:return Y(t);case`auth-email`:return X(t);default:return Q(t,e)}}function wt(e){return[`cloudflare`,...St.filter(t=>Ct(t,e))]}function Tt(e,t){let n=it(e),r=wt(e),i=r.flatMap(t=>ie(t,Ce(e))),a=[...t.map((e,t)=>({file:ct(e,t),contents:e.block?be(e,`export default function`):t===0?ut(e):dt(e,t)})),...Y(e)?[{file:`account.tsx`,contents:pt(e)}]:[]],o=[...a.map(e=>e.file),...i.filter(e=>e.path.startsWith(`src/routes/`)).map(e=>e.path.slice(11))];return[{path:`package.json`,contents:Ue(e)},{path:`tsconfig.json`,contents:We(e)},...rt(e)?[{path:`tsconfig.worker.json`,contents:Ge()}]:[],{path:`vite.config.ts`,contents:Ke(n,e)},{path:`wrangler.jsonc`,contents:qe(e)},{path:`index.html`,contents:he(e)},{path:`eslint.config.js`,contents:W()},{path:`.prettierrc`,contents:G()},{path:`.prettierignore`,contents:mt()},{path:`.gitignore`,contents:ht()},{path:`README.md`,contents:gt(e)},{path:`AGENTS.md`,contents:_t(e)},{path:`worker/index.ts`,contents:ot(e)},{path:`src/api.ts`,contents:at(e)},{path:`src/vite-env.d.ts`,contents:_e()},{path:`src/App.tsx`,contents:lt(t,r,e)},{path:`src/Shell.tsx`,contents:vt(e)},...Q(e,`webhooks`)||Q(e,`checkout`)||Q(e,`newsletter`)||Q(e,`social`)||Z(e)?[{path:`.dev.vars`,contents:yt(e)},{path:`.dev.vars.example`,contents:bt(e)}]:[],...i,...Se(t,e),...a.map(({file:e,contents:t})=>({path:`src/routes/${e}`,contents:t})),{path:`src/routes.gen.ts`,contents:te(o,`./routes`)}]}function Et(e,t){return U({name:e.name,framework:e.framework??`react-vite`,theme:e.theme,pages:t.map(e=>({title:e.label,...e.block?{block:e.block}:{}})),...e.runtime?{runtime:e.runtime}:{},...e.examples&&e.examples.length>0?{examples:e.examples}:{},...e.auth?{auth:e.auth}:{},cascivo:b})}function Dt(e){let t=de(e.sections,e.blocks),n=[...kt(e,t),{path:`cascivo.app.json`,contents:Et(e,t)},...Ot()];return e.workspace?le({packageName:H(e.name),app:n,firstLabel:t[0].label,testable:(e.framework??`react-vite`)===`react-vite`,reactVersion:j[`@cascivo/react`]}):n}function Ot(){let e=o(void 0,`claude`);if(e.kind!==`added`)throw Error(`cascivo: could not build .mcp.json`);return[{path:`CLAUDE.md`,contents:`@AGENTS.md
1985
- `},{path:`.mcp.json`,contents:U(e.config)}]}function kt(e,t){if(e.framework===`astro`)return At(e,t);if(e.framework===`cloudflare`){let n=e.examples?.includes(`digest`)&&!e.examples.includes(`export`)?[...e.examples,`export`]:e.examples,r=e.auth??(n?.includes(`social`)?`oauth`:void 0);return Tt({...e,...n?{examples:n}:{},...r?{auth:r}:{}},t)}return[{path:`package.json`,contents:fe(e)},{path:`tsconfig.json`,contents:pe()},{path:`vite.config.ts`,contents:me()},{path:`index.html`,contents:he(e)},{path:`eslint.config.js`,contents:W()},{path:`.prettierrc`,contents:G()},{path:`.prettierignore`,contents:K()},{path:`.gitignore`,contents:Ee()},{path:`README.md`,contents:Oe(e)},{path:`AGENTS.md`,contents:ke(e)},{path:`src/main.tsx`,contents:ge()},{path:`src/vite-env.d.ts`,contents:_e()},{path:`src/App.tsx`,contents:ve(t)},{path:`src/Shell.tsx`,contents:ye(e)},...t.map(e=>({path:`src/sections/${e.component}.tsx`,contents:we(e)})),...Se(t,e)]}function At(e,t){return[{path:`package.json`,contents:Me(e)},{path:`tsconfig.json`,contents:Pe()},{path:`astro.config.mjs`,contents:Ne()},{path:`eslint.config.js`,contents:W()},{path:`.prettierrc`,contents:G()},{path:`.prettierignore`,contents:K()},{path:`.gitignore`,contents:Be()},{path:`README.md`,contents:Ve(e,t)},{path:`AGENTS.md`,contents:ke(e)},{path:`src/styles/layers.css`,contents:Fe()},{path:`src/layouts/Layout.astro`,contents:Ie(e)},{path:`src/components/Shell.tsx`,contents:Le(e,t)},...t.map((e,t)=>({path:`src/pages/${je(e,t)}`,contents:ze(e,t)})),...t.map(e=>({path:`src/components/${e.component}.tsx`,contents:Re(e)}))]}const jt=[`Dashboard`,`Reports`,`Settings`];function Mt(e){let t=e.examples??[];return t.length>0&&e.framework!==`cloudflare`?`--example needs --framework cloudflare (it adds a Worker-backed page).`:t.includes(`social`)&&e.auth===`access`?`--example social needs accounts (posts belong to a user): use --auth email, oauth or email,oauth, or leave --auth out to get oauth.`:e.auth&&e.framework!==`cloudflare`?`--auth needs --framework cloudflare (it guards the Worker).`:e.workspace&&e.framework===`astro`?`--workspace needs --framework react-vite or cloudflare.`:t.includes(`agent`)&&e.runtime===`preact`?`--example agent needs --runtime react: the Agents SDK's hooks call React 19's use(), which Preact does not implement.`:null}async function Nt(e,t){let{readFileSync:n}=await import(`node:fs`),{parseBlueprint:r,blueprintOptions:i}=await import(`./blueprint-eOLGuyAi.mjs`);try{return i(r(JSON.parse(n(h(t,e),`utf8`)),e))}catch(e){return console.error(e instanceof Error?e.message:String(e)),null}}async function Pt(o,l=process.cwd()){let d=o.includes(`--yes`)||o.includes(`-y`),p=r(o,[`pm`,`package-manager`,`theme`,`sections`,`template`,`framework`,`runtime`,`example`,`auth`,`from`])[0],h=a(o,`theme`),g=a(o,`sections`),v=(a(o,`framework`)??``).toLowerCase();if(v&&!F.includes(v)){console.error(`Unknown framework "${v}". Expected one of: ${F.join(`, `)}.`),process.exitCode=1;return}let y=(a(o,`runtime`)??``).toLowerCase();if(y&&!z(y)){console.error(`Unknown runtime "${y}". Expected one of: ${I.join(`, `)}.`),process.exitCode=1;return}let b=(a(o,`example`)??``).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),x=b.find(e=>!R(e));if(x){console.error(`Unknown example "${x}". Expected one of: ${L.join(`, `)}.`),process.exitCode=1;return}let S=Xe(a(o,`auth`));if(S===`invalid`){console.error(`Unknown auth "${a(o,`auth`)??``}". Expected: access, email, oauth or email,oauth.`),process.exitCode=1;return}let C=i(o);if(`error`in C){console.error(C.error),process.exitCode=1;return}let w=e(l,{preferLockfileOverUserAgent:!0,...C.pm?{override:C.pm}:{}}),T=!d&&s.isTTY?_({input:s,output:c}):null,ee=async()=>{let e=p;!e&&T&&(e=(await T.question(`Project name? [my-cascivo-app]: `)).trim()),e||=`my-cascivo-app`;let n=(h??``).toLowerCase();!t.includes(n)&&T&&(n=(await T.question(`Theme? (${t.join(`/`)}) [light]: `)).trim().toLowerCase());let r=t.includes(n)?n:`light`,i=g;!i&&T&&(i=(await T.question(`Nav sections? (comma-separated) [${jt.join(`, `)}]: `)).trim());let a=(i??``).split(`,`).map(e=>e.trim()).filter(Boolean),o=v;!o&&T&&(o=(await T.question(`Framework? (${F.join(`/`)}) [react-vite]: `)).trim().toLowerCase());let s=F.includes(o)?o:`react-vite`;return{name:e,framework:s,theme:r,sections:a.length>0?a:jt,...z(y)?{runtime:y}:{},...b.length>0?{examples:b.filter(R)}:{},...S?{auth:S}:{}}};try{let e=a(o,`from`),t=e?await Nt(e,l):await ee();if(!t){process.exitCode=1;return}let r=o.includes(`--workspace`),i={...t,...e&&p?{name:p}:{},pm:r?`pnpm`:w,...r?{workspace:r}:{}},s=Mt(i);if(s){console.error(s),process.exitCode=1;return}let c=i.name,d=i.framework??`react-vite`,h=i.theme,g=m(l,c);if(u(g)&&f(g).length>0){console.error(`Target directory "${c}" already exists and is not empty.`),process.exitCode=1;return}let _=Dt(i);for(let e of _)await n(m(g,e.path),e.contents);console.log(`\nCreated ${c} (${d}) with the ${h} theme (${_.length} files).`);let v=a(o,`template`);if(v){let{add:e}=await import(`./index.mjs`).then(e=>e.t),{loadConfig:t}=await import(`./config-CTk7uDrh.mjs`).then(e=>e.i);console.log(`\nInstalling template "${v}"…`),await e([v],await t(),{cwd:g,pm:w})}console.log(`
1986
- Next steps:`),console.log(` cd ${c}`),console.log(` ${M(w)}`),console.log(` ${N(w,`dev`)}`),console.log(`
1987
- Good to know:`),console.log(` No cascivo.config.ts is written — this app uses the prebuilt @cascivo/react`),console.log(" packages and never copies source. `cascivo add <component>` writes the"),console.log(` config itself the first time you vendor a component.`),d===`cloudflare`?(console.log("\n worker/index.ts is the API (wrangler.jsonc routes /api/* to it); `dev`"),console.log(" runs it in workerd. Deploy with `npx wrangler login` once, then the"),console.log(` deploy script: ${P(w,`deploy`)}`),console.log(`
1988
- No account yet? Share a 60-minute preview, claimable into a free account:`),console.log(` ${P(w,`deploy:preview`)}`)):d===`astro`?(console.log(`
2000
+ `)}function St(e){let t=e=>Object.fromEntries(e.map(([e,t])=>[e,{description:t}]));return{...Z(e,`webhooks`)?t([[`WEBHOOK_SECRET`,"The secret of the GitHub webhook that posts to `/api/webhooks/github`."]]):{},...Z(e,`checkout`)?t([[`STRIPE_SECRET_KEY`,"Your Stripe secret key, from the [API keys page](https://dashboard.stripe.com/test/apikeys). A test key (`sk_test_…`) takes test cards only."],[`STRIPE_WEBHOOK_SECRET`,"The signing secret (`whsec_…`) of a Stripe webhook endpoint at `https://<this app>/api/stripe/webhook`. No endpoint yet? Enter `later`: orders are confirmed on their own page without it. Set the real one with `npx wrangler secret put STRIPE_WEBHOOK_SECRET`."],[`RECEIPT_FROM`,`The From address of receipts, on a domain onboarded to Cloudflare Email Service. Leave it empty to send none.`]]):{},...Z(e,`newsletter`)?t([[`NEWSLETTER_KEY`,"The key `/newsletter/send` asks for. Make a long random one: `openssl rand -hex 32`."],[`AWS_ACCESS_KEY_ID`,"An IAM user allowed `ses:SendEmail` and nothing else (README)."],[`AWS_SECRET_ACCESS_KEY`,`That IAM user's secret access key.`],[`AWS_REGION`,"The SES region your sending domain is verified in, e.g. `eu-west-1`."],[`NEWSLETTER_FROM`,`The From address of issues, on your SES-verified domain.`],[`SNS_TOPIC_ARN`,"The SNS topic SES reports bounces and complaints to, subscribed to `https://<this app>/api/sns/ses`."]]):{},...X(e)?t([[`AUTH_SECRET`,"Seals the sign-in state between the redirect to GitHub, Google or LinkedIn and the way back. Make a random one: `openssl rand -base64 32`."],[`GITHUB_CLIENT_ID`,"The client id of a [GitHub OAuth App](https://github.com/settings/developers) whose callback URL is `https://<this app>/api/auth/oauth/github/callback`. Leave it empty to offer no GitHub sign-in."],[`GITHUB_CLIENT_SECRET`,`That OAuth App's client secret.`],[`GOOGLE_CLIENT_ID`,"The client id of a Google OAuth client (Web application) with the redirect URI `https://<this app>/api/auth/oauth/google/callback`. Leave it empty to offer no Google sign-in."],[`GOOGLE_CLIENT_SECRET`,`That OAuth client's secret.`],[`LINKEDIN_CLIENT_ID`,'The client id of a LinkedIn app with the "Sign In with LinkedIn using OpenID Connect" product and the redirect URL `https://<this app>/api/auth/oauth/linkedin/callback`. Leave it empty to offer no LinkedIn sign-in.'],[`LINKEDIN_CLIENT_SECRET`,`That LinkedIn app's primary client secret.`]]):Z(e,`social`)?t([[`AUTH_SECRET`,"Seals the tokens of the accounts people connect. Make a random one: `openssl rand -base64 32`."],[`LINKEDIN_CLIENT_ID`,'The client id of a LinkedIn app with the "Share on LinkedIn" product and the redirect URL `https://<this app>/api/connections/linkedin/callback`. Leave it empty to offer no LinkedIn.'],[`LINKEDIN_CLIENT_SECRET`,`That LinkedIn app's primary client secret.`]]):{},...Z(e,`social`)?t([[`BLUESKY_PRIVATE_JWK`,"Optional. An ES256 private key as a JWK with a `kid` (README shows how to make one). With it, Bluesky sessions last until revoked; without it, two weeks."],[`BUFFER_CLIENT_ID`,"Optional. A Buffer app client (https://publish.buffer.com/settings/api) with the redirect URL `https://<this app>/api/connections/buffer/callback`. Leave it empty to offer no Buffer."],[`BUFFER_CLIENT_SECRET`,`That Buffer app client's secret (none for a public client).`],[`THREADS_APP_ID`,"Optional. The Threads app id of a Meta app with the Threads use case, and `https://<this app>/api/connections/threads/callback` as its redirect callback URL. Leave it empty to offer no Threads."],[`THREADS_APP_SECRET`,`That Threads app's secret.`]]):{}}}const Ct=[`agent`,`board`,`notes`,`import`,`files`,`export`,`usage`,`crud`,`live`,`voice`,`publish`,`publish-preview`,`webhooks`,`digest`,`search`,`checkout`,`billing`,`newsletter`,`social`,`accounts`,`auth-email`];function wt(e,t){switch(e){case`publish-preview`:return Z(t,`publish`)&&Z(t,`export`);case`billing`:return q(t);case`accounts`:return J(t);case`auth-email`:return Y(t);default:return Z(t,e)}}function Tt(e){return[`cloudflare`,...Ct.filter(t=>wt(t,e))]}function Et(e,t){let n=at(e),r=Tt(e),i=r.flatMap(t=>ie(t,Ee(e))),a=[...t.map((e,t)=>({file:lt(e,t),contents:e.block?Ce(e,`export default function`):t===0?dt(e):ft(e,t)})),...J(e)?[{file:`account.tsx`,contents:mt(e)}]:[]],o=[...a.map(e=>e.file),...i.filter(e=>e.path.startsWith(`src/routes/`)).map(e=>e.path.slice(11))];return[{path:`package.json`,contents:Ge(e)},{path:`tsconfig.json`,contents:Ke(e)},...$(e)?[{path:`tsconfig.worker.json`,contents:qe()}]:[],{path:`vite.config.ts`,contents:Je(n,e)},{path:`wrangler.jsonc`,contents:Ye(e)},{path:`index.html`,contents:ve(e)},{path:`eslint.config.js`,contents:V()},{path:`.prettierrc`,contents:H()},{path:`.prettierignore`,contents:ht()},{path:`.gitignore`,contents:gt()},{path:`README.md`,contents:_t(e)},{path:`AGENTS.md`,contents:vt(e)},{path:`worker/index.ts`,contents:st(e)},{path:`src/api.ts`,contents:ot(e)},{path:`src/vite-env.d.ts`,contents:be()},{path:`src/App.tsx`,contents:ut(t,r,e)},{path:`src/Shell.tsx`,contents:yt(e)},...Z(e,`webhooks`)||Z(e,`checkout`)||Z(e,`newsletter`)||Z(e,`social`)||X(e)?[{path:`.dev.vars`,contents:bt(e)},{path:`.dev.vars.example`,contents:xt(e)}]:[],...i,...Te(t,e),...a.map(({file:e,contents:t})=>({path:`src/routes/${e}`,contents:t})),{path:`src/routes.gen.ts`,contents:E(o,`./routes`)}]}function Dt(e,t){return B({name:e.name,framework:e.framework??`react-vite`,theme:e.theme,pages:t.map(e=>({title:e.label,...e.block?{block:e.block}:{}})),...e.runtime?{runtime:e.runtime}:{},...e.examples&&e.examples.length>0?{examples:e.examples}:{},...e.auth?{auth:e.auth}:{},cascivo:b})}function Ot(e){let t=me(e.sections,e.blocks),n=[...At(e,t),{path:`cascivo.app.json`,contents:Dt(e,t)},...kt()];return e.workspace?ce({packageName:z(e.name),app:n,firstLabel:t[0].label,testable:(e.framework??`react-vite`)===`react-vite`,reactVersion:M[`@cascivo/react`]}):n}function kt(){let e=o(void 0,`claude`);if(e.kind!==`added`)throw Error(`cascivo: could not build .mcp.json`);return[{path:`CLAUDE.md`,contents:`@AGENTS.md
2001
+ `},{path:`.mcp.json`,contents:B(e.config)}]}function At(e,t){if(e.framework===`astro`)return jt(e,t);if(e.framework===`cloudflare`){let n=e.examples?.includes(`digest`)&&!e.examples.includes(`export`)?[...e.examples,`export`]:e.examples,r=e.auth??(n?.includes(`social`)?`oauth`:void 0);return Et({...e,...n?{examples:n}:{},...r?{auth:r}:{}},t)}return[{path:`package.json`,contents:he(e)},{path:`tsconfig.json`,contents:ge()},{path:`vite.config.ts`,contents:_e()},{path:`index.html`,contents:ve(e)},{path:`eslint.config.js`,contents:V()},{path:`.prettierrc`,contents:H()},{path:`.prettierignore`,contents:U()},{path:`.gitignore`,contents:ke()},{path:`README.md`,contents:je(e)},{path:`AGENTS.md`,contents:W(e)},{path:`src/main.tsx`,contents:ye()},{path:`src/vite-env.d.ts`,contents:be()},{path:`src/App.tsx`,contents:xe(t)},{path:`src/Shell.tsx`,contents:Se(e)},...t.map(e=>({path:`src/sections/${e.component}.tsx`,contents:De(e)})),...Te(t,e)]}function jt(e,t){return[{path:`package.json`,contents:Ne(e)},{path:`tsconfig.json`,contents:Fe()},{path:`astro.config.mjs`,contents:Pe(e)},{path:`eslint.config.js`,contents:V()},{path:`.prettierrc`,contents:H()},{path:`.prettierignore`,contents:U()},{path:`.gitignore`,contents:He()},{path:`README.md`,contents:Ue(e,t)},{path:`AGENTS.md`,contents:W(e)},{path:`src/styles/layers.css`,contents:Le()},{path:`src/layouts/Layout.astro`,contents:Re(e)},{path:`src/components/Shell.tsx`,contents:ze(e,t)},...t.map((e,t)=>({path:`src/pages/${Me(e,t)}`,contents:Ve(e,t)})),...t.map(e=>({path:`src/components/${e.component}.tsx`,contents:Be(e)}))]}const Mt=[`Dashboard`,`Reports`,`Settings`];function Nt(e){let t=e.examples??[];return t.length>0&&e.framework!==`cloudflare`?`--example needs --framework cloudflare (it adds a Worker-backed page).`:t.includes(`social`)&&e.auth===`access`?`--example social needs accounts (posts belong to a user): use --auth email, oauth or email,oauth, or leave --auth out to get oauth.`:e.auth&&e.framework!==`cloudflare`?`--auth needs --framework cloudflare (it guards the Worker).`:e.workspace&&e.framework===`astro`?`--workspace needs --framework react-vite or cloudflare.`:t.includes(`agent`)&&e.runtime===`preact`?`--example agent needs --runtime react: the Agents SDK's hooks call React 19's use(), which Preact does not implement.`:null}async function Pt(e,t){let{readFileSync:n}=await import(`node:fs`),{parseBlueprint:r,blueprintOptions:i}=await import(`./blueprint-B6Z8NrCr.mjs`);try{return i(r(JSON.parse(n(h(t,e),`utf8`)),e))}catch(e){return console.error(e instanceof Error?e.message:String(e)),null}}async function Ft(o,l=process.cwd()){let d=o.includes(`--yes`)||o.includes(`-y`),p=r(o,[`pm`,`package-manager`,`theme`,`sections`,`template`,`framework`,`runtime`,`example`,`auth`,`from`])[0],h=a(o,`theme`),g=a(o,`sections`),v=(a(o,`framework`)??``).toLowerCase();if(v&&!I.includes(v)){console.error(`Unknown framework "${v}". Expected one of: ${I.join(`, `)}.`),process.exitCode=1;return}let y=(a(o,`runtime`)??``).toLowerCase();if(y&&!de(y)){console.error(`Unknown runtime "${y}". Expected one of: ${L.join(`, `)}.`),process.exitCode=1;return}let b=(a(o,`example`)??``).split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),x=b.find(e=>!ue(e));if(x){console.error(`Unknown example "${x}". Expected one of: ${le.join(`, `)}.`),process.exitCode=1;return}let S=Qe(a(o,`auth`));if(S===`invalid`){console.error(`Unknown auth "${a(o,`auth`)??``}". Expected: access, email, oauth or email,oauth.`),process.exitCode=1;return}let C=i(o);if(`error`in C){console.error(C.error),process.exitCode=1;return}let w=e(l,{preferLockfileOverUserAgent:!0,...C.pm?{override:C.pm}:{}}),T=!d&&s.isTTY?_({input:s,output:c}):null,ee=async()=>{let e=p;!e&&T&&(e=(await T.question(`Project name? [my-cascivo-app]: `)).trim()),e||=`my-cascivo-app`;let n=(h??``).toLowerCase();!t.includes(n)&&T&&(n=(await T.question(`Theme? (${t.join(`/`)}) [light]: `)).trim().toLowerCase());let r=t.includes(n)?n:`light`,i=g;!i&&T&&(i=(await T.question(`Nav sections? (comma-separated) [${Mt.join(`, `)}]: `)).trim());let a=(i??``).split(`,`).map(e=>e.trim()).filter(Boolean),o=v;!o&&T&&(o=(await T.question(`Framework? (${I.join(`/`)}) [react-vite]: `)).trim().toLowerCase());let s=I.includes(o)?o:`react-vite`;return{name:e,framework:s,theme:r,sections:a.length>0?a:Mt,...de(y)?{runtime:y}:{},...b.length>0?{examples:b.filter(ue)}:{},...S?{auth:S}:{}}};try{let e=a(o,`from`),t=e?await Pt(e,l):await ee();if(!t){process.exitCode=1;return}let r=o.includes(`--workspace`),i={...t,...e&&p?{name:p}:{},pm:r?`pnpm`:w,...r?{workspace:r}:{}},s=Nt(i);if(s){console.error(s),process.exitCode=1;return}let c=i.name,d=i.framework??`react-vite`,h=i.theme,g=m(l,c);if(u(g)&&f(g).length>0){console.error(`Target directory "${c}" already exists and is not empty.`),process.exitCode=1;return}let _=Ot(i);for(let e of _)await n(m(g,e.path),e.contents);console.log(`\nCreated ${c} (${d}) with the ${h} theme (${_.length} files).`);let v=a(o,`template`);if(v){let{add:e}=await import(`./index.mjs`).then(e=>e.t),{loadConfig:t}=await import(`./config-CTk7uDrh.mjs`).then(e=>e.i);console.log(`\nInstalling template "${v}"…`),await e([v],await t(),{cwd:g,pm:w})}console.log(`
2002
+ Next steps:`),console.log(` cd ${c}`),console.log(` ${N(w)}`),console.log(` ${P(w,`dev`)}`),console.log(`
2003
+ Good to know:`),console.log(` No cascivo.config.ts is written — this app uses the prebuilt @cascivo/react`),console.log(" packages and never copies source. `cascivo add <component>` writes the"),console.log(` config itself the first time you vendor a component.`),d===`cloudflare`?(console.log("\n worker/index.ts is the API (wrangler.jsonc routes /api/* to it); `dev`"),console.log(" runs it in workerd. Deploy with `npx wrangler login` once, then the"),console.log(` deploy script: ${F(w,`deploy`)}`),console.log(`
2004
+ No account yet? Share a 60-minute preview, claimable into a free account:`),console.log(` ${F(w,`deploy:preview`)}`)):d===`astro`?(console.log(`
1989
2005
  Pages are real Astro routes — no client router to add. Only src/`),console.log(` components/Shell.tsx hydrates (client:load, for the mobile nav drawer);`),console.log(` page content is server-rendered and ships no JS. See`),console.log(` https://cascivo.com/docs/using-with-astro.md`)):(console.log(`
1990
- Adding a router? Keep src/Shell.tsx, delete src/App.tsx + src/sections/,`),console.log(` and register your Link once with setLinkComponent — see`),console.log(` https://cascivo.com/docs/using-with-a-router.md`))}finally{T?.close()}}export{L as EXAMPLES,F as FRAMEWORKS,I as RUNTIMES,Dt as buildScaffold,Pt as create,R as isExample,z as isRuntime,b as n,Mt as optionsError,Xe as parseAuth,ae as t};
1991
- //# sourceMappingURL=create-BA9GQ8nl.mjs.map
2006
+ Adding a router? Keep src/Shell.tsx, delete src/App.tsx + src/sections/,`),console.log(` and register your Link once with setLinkComponent — see`),console.log(` https://cascivo.com/docs/using-with-a-router.md`))}finally{T?.close()}}export{le as EXAMPLES,I as FRAMEWORKS,L as RUNTIMES,Ot as buildScaffold,Ft as create,ue as isExample,de as isRuntime,b as n,Nt as optionsError,Qe as parseAuth,ae as t};
2007
+ //# sourceMappingURL=create-DIaknp48.mjs.map