cascivo 1.8.3 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{app-cT6z1jwO.mjs → app-Dt98v4Zq.mjs} +3 -3
- package/dist/{app-cT6z1jwO.mjs.map → app-Dt98v4Zq.mjs.map} +1 -1
- package/dist/{blueprint-J_OJuctJ.mjs → blueprint-BBrlwJhm.mjs} +2 -2
- package/dist/{blueprint-J_OJuctJ.mjs.map → blueprint-BBrlwJhm.mjs.map} +1 -1
- package/dist/cmdspec.json +310 -1
- package/dist/{create-BT3YoVp5.mjs → create-BMqDBB8r.mjs} +3 -3
- package/dist/{create-BT3YoVp5.mjs.map → create-BMqDBB8r.mjs.map} +1 -1
- package/dist/design-CYQqMPQB.mjs +3 -0
- package/dist/design-CYQqMPQB.mjs.map +1 -0
- package/dist/generated/audit-contract.json +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +70 -33
- package/dist/index.mjs.map +1 -1
- package/dist/skills/cascivo-design/SKILL.md +44 -0
- package/dist/skills/cascivo-design/references/check-rules.md +37 -0
- package/dist/skills/cascivo-design/references/critique-rubric.md +26 -0
- package/dist/skills/cascivo-design/references/direction.md +113 -0
- package/dist/skills/cascivo-design/references/without-cascivo.md +17 -0
- package/package.json +8 -3
- package/readme.body.md +1 -0
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ cascivo view owner/repo/dashboard # preview an item (or template) before instal
|
|
|
33
33
|
cascivo list # list available components
|
|
34
34
|
cascivo update # pull newer versions of copied components
|
|
35
35
|
cascivo audit --ai # flag hard-coded values, invented props, missing wiring
|
|
36
|
+
cascivo design plan "<brief>" # plan a page; also check, see, init, theme (@cascivo/design)
|
|
36
37
|
cascivo mcp init # add the cascivo MCP server to your agent's config
|
|
37
38
|
cascivo search <query> # search components across registries
|
|
38
39
|
cascivo theme add <name> # install a first-party theme (12 available)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e}from"./config-CTk7uDrh.mjs";import{i as t}from"./fs-B7O-fNID.mjs";import{n,t as r}from"./args-B4PN85cC.mjs";import{t as i}from"./merge-D332dc_m.mjs";import{buildScaffold as a,n as o,optionsError as s}from"./create-
|
|
1
|
+
import{a as e}from"./config-CTk7uDrh.mjs";import{i as t}from"./fs-B7O-fNID.mjs";import{n,t as r}from"./args-B4PN85cC.mjs";import{t as i}from"./merge-D332dc_m.mjs";import{buildScaffold as a,n as o,optionsError as s}from"./create-BMqDBB8r.mjs";import{blueprintOptions as c,parseBlueprint as l}from"./blueprint-BBrlwJhm.mjs";import{existsSync as u,mkdtempSync as d,readFileSync as f,readdirSync as p,rmSync as m,statSync as h,writeFileSync as g}from"node:fs";import{join as _,relative as v}from"node:path";import{spawnSync as y}from"node:child_process";import{tmpdir as b}from"node:os";const x=`cascivo.app.json`;function S(e,t){let n={...c(l(e,x)),pm:t};return new Map(a(n).map(e=>[e.path,e.contents]))}function C(e){let t=/* @__PURE__ */ new Map,n=r=>{for(let i of p(r)){let a=_(r,i);h(a).isDirectory()?n(a):t.set(v(e,a).replaceAll(`\\`,`/`),f(a,`utf8`))}};return n(e),t}function w(e,t){let{cascivo:n,name:r}=l(e,x);if(!n||n===`1.9.0`)return S(e,t);let i=d(_(b(),`cascivo-base-`));try{return g(_(i,x),JSON.stringify(e)),y(`npx`,[`-y`,`cascivo@${n}`,`create`,`--from`,x,`--pm`,t],{cwd:i,encoding:`utf8`}).status===0?C(_(i,r)):(console.warn(`Could not run cascivo@${n} to rebuild this app's original files; merging against cascivo@${o}'s instead, so its template changes may show up as conflicts.`),S(e,t))}finally{m(i,{recursive:!0,force:!0})}}async function T(n,r,o,d=w){let p=c(l(o,x)),m=s(p);if(m)throw Error(m);let h=e(n,{preferLockfileOverUserAgent:!0}),g=d(r,h),v=[],y=``;for(let{path:e,contents:r}of a({...p,pm:h})){if(e===x){y=r;continue}let a=g.get(e);if(a===r)continue;let o=_(n,e),s=u(o)?f(o,`utf8`):void 0;if(s===r)continue;if(s===void 0||s===a){await t(o,r),v.push({path:e,outcome:`written`});continue}let c=i(a??``,s,r);await t(o,c.text),v.push({path:e,outcome:c.conflicts>0?`conflict`:`merged`})}return await t(_(n,x),y),v}const E=`Usage:
|
|
2
2
|
cascivo app add page "<title>" [--block <name>]
|
|
3
3
|
cascivo app add example <name>
|
|
4
|
-
cascivo app upgrade`;function D(e,t){let[i,a,s]=n(t,[`block`]);if(i===`upgrade`&&a===void 0)return e.cascivo===`1.
|
|
5
|
-
//# sourceMappingURL=app-
|
|
4
|
+
cascivo app upgrade`;function D(e,t){let[i,a,s]=n(t,[`block`]);if(i===`upgrade`&&a===void 0)return e.cascivo===`1.9.0`?`Already generated by cascivo@${o}.`:{after:e,done:`Upgraded to cascivo@${o}.`};if(i!==`add`||!s)return E;if(a===`page`){let n=r(t,`block`),i=Array.isArray(e.pages)?e.pages:[];return{after:{...e,pages:[...i,{title:s,...n?{block:n}:{}}]},done:`Added the "${s}" page.`}}if(a===`example`){let t=Array.isArray(e.examples)?e.examples:[];return t.includes(s)?`The app already has the ${s} example.`:{after:{...e,examples:[...t,s]},done:`Added the ${s} example.`}}return E}async function O(e,t=process.cwd()){let n=_(t,x);if(!u(n)){console.error(`No ${x} here. \`cascivo app\` changes apps made with \`cascivo create\`; run it in the app's directory.`),process.exitCode=1;return}let r,i;try{let a=JSON.parse(f(n,`utf8`));if(l(a,x),typeof a!=`object`||!a||Array.isArray(a))throw Error(`${x} must be a JSON object.`);let o=D({...a},e);if(o===E){console.error(E),process.exitCode=1;return}if(typeof o==`string`){console.log(o);return}i=o.done,r=await T(t,a,o.after)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}console.log(i);for(let e of r){let t=e.outcome===`merged`?` (merged with your edits)`:e.outcome===`conflict`?` — CONFLICT: resolve the <<<<<<< markers`:``;console.log(` ${e.path}${t}`)}r.some(e=>e.outcome===`conflict`)&&(process.exitCode=1)}export{O as app};
|
|
5
|
+
//# sourceMappingURL=app-Dt98v4Zq.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-cT6z1jwO.mjs","names":["detectPackageManager","writeFileSafe","flagValue","merge","CLI_VERSION","BLUEPRINT","scaffoldOf","options","blueprintOptions","parseBlueprint","blueprint","buildScaffold","f","readTree","out","walk","entry","readdirSync","d","full","join","statSync","relative","dir","readFileSync","originalScaffold","version","pm","work","mkdtempSync","tmpdir","writeFileSync","spawnSync","name","rmSync","applyBlueprint","nextOptions","after","problem","optionsError","cwd","base","original","before","changes","path","contents","generated","target","current","existsSync","merged","USAGE","changed","action","kind","value","positionalArgs","args","block","pages","examples","app","file","done","request","change","note","c"],"sources":["../src/commands/app.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\nimport {\n existsSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join, relative } from 'node:path'\nimport { CLI_VERSION } from '../generated/versions.js'\nimport { blueprintOptions, parseBlueprint } from '../scaffold/blueprint.js'\nimport { flagValue, positionalArgs } from '../utils/args.js'\nimport { detectPackageManager } from '../utils/config.js'\nimport type { PackageManager } from '../utils/config.js'\nimport { writeFileSafe } from '../utils/fs.js'\nimport { merge } from '../utils/merge.js'\nimport { buildScaffold, optionsError } from './create.js'\n\nconst BLUEPRINT = 'cascivo.app.json'\n\nexport interface AppChange {\n path: string\n /** `written`: new or untouched since it was generated; `merged`: your edits kept. */\n outcome: 'written' | 'merged' | 'conflict'\n}\n\n/** The files a blueprint generates, as `path → contents`. */\nexport type Generate = (blueprint: unknown, pm: PackageManager) => Map<string, string>\n\nfunction scaffoldOf(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const options = { ...blueprintOptions(parseBlueprint(blueprint, BLUEPRINT)), pm }\n return new Map(buildScaffold(options).map((f) => [f.path, f.contents]))\n}\n\n/** Every file under `dir`, relative to it. */\nfunction readTree(dir: string): Map<string, string> {\n const out = new Map<string, string>()\n const walk = (d: string) => {\n for (const entry of readdirSync(d)) {\n const full = join(d, entry)\n if (statSync(full).isDirectory()) walk(full)\n else out.set(relative(dir, full).replaceAll('\\\\', '/'), readFileSync(full, 'utf8'))\n }\n }\n walk(dir)\n return out\n}\n\n/**\n * What the app's own CLI version generated from `blueprint`: the merge base. A newer CLI's\n * templates differ, and merging against them would read every template change as your edit.\n * With no `cascivo` stamp, or the same version, that is this CLI's output; otherwise the\n * recorded version is run (`npx cascivo@<version>`), falling back to this one with a warning.\n */\nexport function originalScaffold(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const { cascivo: version, name } = parseBlueprint(blueprint, BLUEPRINT)\n if (!version || version === CLI_VERSION) return scaffoldOf(blueprint, pm)\n const work = mkdtempSync(join(tmpdir(), 'cascivo-base-'))\n try {\n writeFileSync(join(work, BLUEPRINT), JSON.stringify(blueprint))\n const result = spawnSync(\n 'npx',\n // No name argument: it would override the blueprint's, and every file that spells the\n // app's name would then differ from what was really generated.\n ['-y', `cascivo@${version}`, 'create', '--from', BLUEPRINT, '--pm', pm],\n { cwd: work, encoding: 'utf8' },\n )\n if (result.status === 0) return readTree(join(work, name))\n console.warn(\n `Could not run cascivo@${version} to rebuild this app's original files; merging against ` +\n `cascivo@${CLI_VERSION}'s instead, so its template changes may show up as conflicts.`,\n )\n return scaffoldOf(blueprint, pm)\n } finally {\n rmSync(work, { recursive: true, force: true })\n }\n}\n\n/**\n * Change a blueprint app from `before` to `after`. Every file the new blueprint generates\n * differently from the original is merged three ways: what was generated, what is on disk now,\n * and what this CLI generates from `after`. A file nobody edited is replaced; an edited one\n * keeps the edits; a clash is left with conflict markers. The blueprint is rewritten last,\n * stamped with this CLI's version.\n */\nexport async function applyBlueprint(\n cwd: string,\n before: unknown,\n after: unknown,\n original: Generate = originalScaffold,\n): Promise<AppChange[]> {\n const nextOptions = blueprintOptions(parseBlueprint(after, BLUEPRINT))\n const problem = optionsError(nextOptions)\n if (problem) throw new Error(problem)\n const pm = detectPackageManager(cwd, { preferLockfileOverUserAgent: true })\n const base = original(before, pm)\n\n const changes: AppChange[] = []\n let blueprint = ''\n for (const { path, contents } of buildScaffold({ ...nextOptions, pm })) {\n if (path === BLUEPRINT) {\n blueprint = contents\n continue\n }\n const generated = base.get(path)\n if (generated === contents) continue\n const target = join(cwd, path)\n const current = existsSync(target) ? readFileSync(target, 'utf8') : undefined\n if (current === contents) continue\n if (current === undefined || current === generated) {\n await writeFileSafe(target, contents)\n changes.push({ path, outcome: 'written' })\n continue\n }\n const merged = merge(generated ?? '', current, contents)\n await writeFileSafe(target, merged.text)\n changes.push({ path, outcome: merged.conflicts > 0 ? 'conflict' : 'merged' })\n }\n await writeFileSafe(join(cwd, BLUEPRINT), blueprint)\n return changes\n}\n\nconst USAGE = `Usage:\n cascivo app add page \"<title>\" [--block <name>]\n cascivo app add example <name>\n cascivo app upgrade`\n\n/** The change a command line asks for, as the blueprint after it. */\nfunction changed(\n before: Record<string, unknown>,\n args: string[],\n): { after: Record<string, unknown>; done: string } | string {\n const [action, kind, value] = positionalArgs(args, ['block'])\n if (action === 'upgrade' && kind === undefined) {\n if (before.cascivo === CLI_VERSION) return `Already generated by cascivo@${CLI_VERSION}.`\n return { after: before, done: `Upgraded to cascivo@${CLI_VERSION}.` }\n }\n if (action !== 'add' || !value) return USAGE\n if (kind === 'page') {\n const block = flagValue(args, 'block')\n const pages = Array.isArray(before.pages) ? before.pages : []\n return {\n after: { ...before, pages: [...pages, { title: value, ...(block ? { block } : {}) }] },\n done: `Added the \"${value}\" page.`,\n }\n }\n if (kind === 'example') {\n const examples = Array.isArray(before.examples) ? before.examples : []\n if (examples.includes(value)) return `The app already has the ${value} example.`\n return {\n after: { ...before, examples: [...examples, value] },\n done: `Added the ${value} example.`,\n }\n }\n return USAGE\n}\n\n/** `cascivo app add page|example …` and `cascivo app upgrade`. */\nexport async function app(args: string[], cwd: string = process.cwd()): Promise<void> {\n const file = join(cwd, BLUEPRINT)\n if (!existsSync(file)) {\n console.error(\n `No ${BLUEPRINT} here. \\`cascivo app\\` changes apps made with \\`cascivo create\\`; run it in the app's directory.`,\n )\n process.exitCode = 1\n return\n }\n\n let changes: AppChange[]\n let done: string\n try {\n const before: unknown = JSON.parse(readFileSync(file, 'utf8'))\n parseBlueprint(before, BLUEPRINT) // the app's own blueprint must be valid before it changes\n if (typeof before !== 'object' || before === null || Array.isArray(before)) {\n throw new Error(`${BLUEPRINT} must be a JSON object.`)\n }\n const request = changed({ ...before }, args)\n if (request === USAGE) {\n console.error(USAGE)\n process.exitCode = 1\n return\n }\n if (typeof request === 'string') {\n console.log(request)\n return\n }\n done = request.done\n changes = await applyBlueprint(cwd, before, request.after)\n } catch (e) {\n console.error(e instanceof Error ? e.message : String(e))\n process.exitCode = 1\n return\n }\n\n console.log(done)\n for (const change of changes) {\n const note =\n change.outcome === 'merged'\n ? ' (merged with your edits)'\n : change.outcome === 'conflict'\n ? ' — CONFLICT: resolve the <<<<<<< markers'\n : ''\n console.log(` ${change.path}${note}`)\n }\n if (changes.some((c) => c.outcome === 'conflict')) process.exitCode = 1\n}\n"],"mappings":"ukBAqBA,MAAMK,EAAY,mBAWlB,SAASC,EAAW,EAAoB,EAAyC,CAC/E,IAAMC,EAAU,CAAE,GAAGC,EAAiBC,EAAeC,EAAWL,CAAS,CAAC,EAAG,IAAG,EAChF,OAAO,IAAI,IAAIM,EAAcJ,CAAO,CAAC,CAAC,IAAK,GAAM,CAACK,EAAE,KAAMA,EAAE,QAAQ,CAAC,CAAC,CACxE,CAGA,SAASC,EAAS,EAAkC,CAClD,IAAMC,kBAAM,IAAI,IACVC,EAAQ,GAAc,CAC1B,IAAK,IAAMC,KAASC,EAAYC,CAAC,EAAG,CAClC,IAAMC,EAAOC,EAAKF,EAAGF,CAAK,EACtBK,EAASF,CAAI,CAAC,CAAC,YAAY,EAAGJ,EAAKI,CAAI,EACtCL,EAAI,IAAIQ,EAASC,EAAKJ,CAAI,CAAC,CAAC,WAAW,K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AAQ,IAAI,KAAKA,EAAO,OAAOC,GAAM,CACvC,CACIvB,EAAQ,KAAM,GAAMwB,EAAE,UAAY,UAAU,IAAG,QAAQ,SAAW,EACxE"}
|
|
1
|
+
{"version":3,"file":"app-Dt98v4Zq.mjs","names":["detectPackageManager","writeFileSafe","flagValue","merge","CLI_VERSION","BLUEPRINT","scaffoldOf","options","blueprintOptions","parseBlueprint","blueprint","buildScaffold","f","readTree","out","walk","entry","readdirSync","d","full","join","statSync","relative","dir","readFileSync","originalScaffold","version","pm","work","mkdtempSync","tmpdir","writeFileSync","spawnSync","name","rmSync","applyBlueprint","nextOptions","after","problem","optionsError","cwd","base","original","before","changes","path","contents","generated","target","current","existsSync","merged","USAGE","changed","action","kind","value","positionalArgs","args","block","pages","examples","app","file","done","request","change","note","c"],"sources":["../src/commands/app.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\nimport {\n existsSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join, relative } from 'node:path'\nimport { CLI_VERSION } from '../generated/versions.js'\nimport { blueprintOptions, parseBlueprint } from '../scaffold/blueprint.js'\nimport { flagValue, positionalArgs } from '../utils/args.js'\nimport { detectPackageManager } from '../utils/config.js'\nimport type { PackageManager } from '../utils/config.js'\nimport { writeFileSafe } from '../utils/fs.js'\nimport { merge } from '../utils/merge.js'\nimport { buildScaffold, optionsError } from './create.js'\n\nconst BLUEPRINT = 'cascivo.app.json'\n\nexport interface AppChange {\n path: string\n /** `written`: new or untouched since it was generated; `merged`: your edits kept. */\n outcome: 'written' | 'merged' | 'conflict'\n}\n\n/** The files a blueprint generates, as `path → contents`. */\nexport type Generate = (blueprint: unknown, pm: PackageManager) => Map<string, string>\n\nfunction scaffoldOf(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const options = { ...blueprintOptions(parseBlueprint(blueprint, BLUEPRINT)), pm }\n return new Map(buildScaffold(options).map((f) => [f.path, f.contents]))\n}\n\n/** Every file under `dir`, relative to it. */\nfunction readTree(dir: string): Map<string, string> {\n const out = new Map<string, string>()\n const walk = (d: string) => {\n for (const entry of readdirSync(d)) {\n const full = join(d, entry)\n if (statSync(full).isDirectory()) walk(full)\n else out.set(relative(dir, full).replaceAll('\\\\', '/'), readFileSync(full, 'utf8'))\n }\n }\n walk(dir)\n return out\n}\n\n/**\n * What the app's own CLI version generated from `blueprint`: the merge base. A newer CLI's\n * templates differ, and merging against them would read every template change as your edit.\n * With no `cascivo` stamp, or the same version, that is this CLI's output; otherwise the\n * recorded version is run (`npx cascivo@<version>`), falling back to this one with a warning.\n */\nexport function originalScaffold(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const { cascivo: version, name } = parseBlueprint(blueprint, BLUEPRINT)\n if (!version || version === CLI_VERSION) return scaffoldOf(blueprint, pm)\n const work = mkdtempSync(join(tmpdir(), 'cascivo-base-'))\n try {\n writeFileSync(join(work, BLUEPRINT), JSON.stringify(blueprint))\n const result = spawnSync(\n 'npx',\n // No name argument: it would override the blueprint's, and every file that spells the\n // app's name would then differ from what was really generated.\n ['-y', `cascivo@${version}`, 'create', '--from', BLUEPRINT, '--pm', pm],\n { cwd: work, encoding: 'utf8' },\n )\n if (result.status === 0) return readTree(join(work, name))\n console.warn(\n `Could not run cascivo@${version} to rebuild this app's original files; merging against ` +\n `cascivo@${CLI_VERSION}'s instead, so its template changes may show up as conflicts.`,\n )\n return scaffoldOf(blueprint, pm)\n } finally {\n rmSync(work, { recursive: true, force: true })\n }\n}\n\n/**\n * Change a blueprint app from `before` to `after`. Every file the new blueprint generates\n * differently from the original is merged three ways: what was generated, what is on disk now,\n * and what this CLI generates from `after`. A file nobody edited is replaced; an edited one\n * keeps the edits; a clash is left with conflict markers. The blueprint is rewritten last,\n * stamped with this CLI's version.\n */\nexport async function applyBlueprint(\n cwd: string,\n before: unknown,\n after: unknown,\n original: Generate = originalScaffold,\n): Promise<AppChange[]> {\n const nextOptions = blueprintOptions(parseBlueprint(after, BLUEPRINT))\n const problem = optionsError(nextOptions)\n if (problem) throw new Error(problem)\n const pm = detectPackageManager(cwd, { preferLockfileOverUserAgent: true })\n const base = original(before, pm)\n\n const changes: AppChange[] = []\n let blueprint = ''\n for (const { path, contents } of buildScaffold({ ...nextOptions, pm })) {\n if (path === BLUEPRINT) {\n blueprint = contents\n continue\n }\n const generated = base.get(path)\n if (generated === contents) continue\n const target = join(cwd, path)\n const current = existsSync(target) ? readFileSync(target, 'utf8') : undefined\n if (current === contents) continue\n if (current === undefined || current === generated) {\n await writeFileSafe(target, contents)\n changes.push({ path, outcome: 'written' })\n continue\n }\n const merged = merge(generated ?? '', current, contents)\n await writeFileSafe(target, merged.text)\n changes.push({ path, outcome: merged.conflicts > 0 ? 'conflict' : 'merged' })\n }\n await writeFileSafe(join(cwd, BLUEPRINT), blueprint)\n return changes\n}\n\nconst USAGE = `Usage:\n cascivo app add page \"<title>\" [--block <name>]\n cascivo app add example <name>\n cascivo app upgrade`\n\n/** The change a command line asks for, as the blueprint after it. */\nfunction changed(\n before: Record<string, unknown>,\n args: string[],\n): { after: Record<string, unknown>; done: string } | string {\n const [action, kind, value] = positionalArgs(args, ['block'])\n if (action === 'upgrade' && kind === undefined) {\n if (before.cascivo === CLI_VERSION) return `Already generated by cascivo@${CLI_VERSION}.`\n return { after: before, done: `Upgraded to cascivo@${CLI_VERSION}.` }\n }\n if (action !== 'add' || !value) return USAGE\n if (kind === 'page') {\n const block = flagValue(args, 'block')\n const pages = Array.isArray(before.pages) ? before.pages : []\n return {\n after: { ...before, pages: [...pages, { title: value, ...(block ? { block } : {}) }] },\n done: `Added the \"${value}\" page.`,\n }\n }\n if (kind === 'example') {\n const examples = Array.isArray(before.examples) ? before.examples : []\n if (examples.includes(value)) return `The app already has the ${value} example.`\n return {\n after: { ...before, examples: [...examples, value] },\n done: `Added the ${value} example.`,\n }\n }\n return USAGE\n}\n\n/** `cascivo app add page|example …` and `cascivo app upgrade`. */\nexport async function app(args: string[], cwd: string = process.cwd()): Promise<void> {\n const file = join(cwd, BLUEPRINT)\n if (!existsSync(file)) {\n console.error(\n `No ${BLUEPRINT} here. \\`cascivo app\\` changes apps made with \\`cascivo create\\`; run it in the app's directory.`,\n )\n process.exitCode = 1\n return\n }\n\n let changes: AppChange[]\n let done: string\n try {\n const before: unknown = JSON.parse(readFileSync(file, 'utf8'))\n parseBlueprint(before, BLUEPRINT) // the app's own blueprint must be valid before it changes\n if (typeof before !== 'object' || before === null || Array.isArray(before)) {\n throw new Error(`${BLUEPRINT} must be a JSON object.`)\n }\n const request = changed({ ...before }, args)\n if (request === USAGE) {\n console.error(USAGE)\n process.exitCode = 1\n return\n }\n if (typeof request === 'string') {\n console.log(request)\n return\n }\n done = request.done\n changes = await applyBlueprint(cwd, before, request.after)\n } catch (e) {\n console.error(e instanceof Error ? e.message : String(e))\n process.exitCode = 1\n return\n }\n\n console.log(done)\n for (const change of changes) {\n const note =\n change.outcome === 'merged'\n ? ' (merged with your edits)'\n : change.outcome === 'conflict'\n ? ' — CONFLICT: resolve the <<<<<<< markers'\n : ''\n console.log(` ${change.path}${note}`)\n }\n if (changes.some((c) => c.outcome === 'conflict')) process.exitCode = 1\n}\n"],"mappings":"ukBAqBA,MAAMK,EAAY,mBAWlB,SAASC,EAAW,EAAoB,EAAyC,CAC/E,IAAMC,EAAU,CAAE,GAAGC,EAAiBC,EAAeC,EAAWL,CAAS,CAAC,EAAG,IAAG,EAChF,OAAO,IAAI,IAAIM,EAAcJ,CAAO,CAAC,CAAC,IAAK,GAAM,CAACK,EAAE,KAAMA,EAAE,QAAQ,CAAC,CAAC,CACxE,CAGA,SAASC,EAAS,EAAkC,CAClD,IAAMC,kBAAM,IAAI,IACVC,EAAQ,GAAc,CAC1B,IAAK,IAAMC,KAASC,EAAYC,CAAC,EAAG,CAClC,IAAMC,EAAOC,EAAKF,EAAGF,CAAK,EACtBK,EAASF,CAAI,CAAC,CAAC,YAAY,EAAGJ,EAAKI,CAAI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B,EACJD,EAAO,UAAY,SACf,4BACAA,EAAO,UAAY,WACjB,2CACA,GACR,QAAQ,IAAI,KAAKA,EAAO,OAAOC,GAAM,CACvC,CACIvB,EAAQ,KAAM,GAAMwB,EAAE,UAAY,UAAU,IAAG,QAAQ,SAAW,EACxE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./config-CTk7uDrh.mjs";import{EXAMPLES as t,FRAMEWORKS as n,RUNTIMES as r,isExample as i,isRuntime as a,parseAuth as o,t as s}from"./create-
|
|
2
|
-
//# sourceMappingURL=blueprint-
|
|
1
|
+
import{r as e}from"./config-CTk7uDrh.mjs";import{EXAMPLES as t,FRAMEWORKS as n,RUNTIMES as r,isExample as i,isRuntime as a,parseAuth as o,t as s}from"./create-BMqDBB8r.mjs";const c=/* @__PURE__ */ new Set([`$schema`,`name`,`framework`,`theme`,`pages`,`runtime`,`examples`,`auth`,`cascivo`]);function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e,t,n,r){if(typeof e==`string`&&t.includes(e))return e;throw Error(`${r}: "${n}" must be one of: ${t.join(`, `)}.`)}function d(d,f){if(!l(d))throw Error(`${f}: a blueprint must be a JSON object.`);let p=Object.keys(d).filter(e=>!c.has(e));if(p.length>0)throw Error(`${f}: unknown field ${p.map(e=>`"${e}"`).join(`, `)}. Fields: ${[...c].slice(1).join(`, `)}.`);let{name:m,framework:h=`react-vite`,theme:g=`light`,pages:_,runtime:v,examples:y,auth:b}=d;if(typeof m!=`string`||m.trim()===``||/[/\\\u0000-\u001f]/.test(m)||/^\.+$/.test(m.trim()))throw Error(`${f}: "name" must be a project directory name, not a path.`);let x={name:m,framework:u(h,n,`framework`,f),theme:u(g,e,`theme`,f),pages:[]};if(!Array.isArray(_)||_.length===0)throw Error(`${f}: "pages" must be a non-empty array of { "title", "block"? }.`);let S=s();for(let[e,t]of _.entries()){if(!l(t)||typeof t.title!=`string`||t.title.trim()===``)throw Error(`${f}: pages[${e}] needs a non-empty "title".`);let n=Object.keys(t).filter(e=>e!==`title`&&e!==`block`);if(n.length>0)throw Error(`${f}: pages[${e}] has unknown field "${n[0]}". Fields: title, block.`);let{block:r}=t;if(r!==void 0&&(typeof r!=`string`||!S.includes(r)))throw Error(`${f}: pages[${e}].block ${JSON.stringify(r)} is not a block. Blocks: ${S.join(`, `)}.`);x.pages.push({title:t.title,...r===void 0?{}:{block:r}})}if(x.framework===`astro`&&x.pages.some(e=>e.block))throw Error(`${f}: blocks need "framework" react-vite or cloudflare.`);if(v!==void 0){if(typeof v!=`string`||!a(v))throw Error(`${f}: "runtime" must be one of: ${r.join(`, `)}.`);x.runtime=v}if(y!==void 0){let e=Array.isArray(y)?y.filter(e=>typeof e==`string`&&i(e)):[];if(!Array.isArray(y)||e.length!==y.length)throw Error(`${f}: "examples" must be an array of: ${t.join(`, `)}.`);x.examples=e}if(b!==void 0){let e=o(typeof b==`string`?b:void 0);if(e===null||e===`invalid`)throw Error(`${f}: "auth" must be one of: access, email, oauth, email,oauth.`);x.auth=e}if(d.cascivo!==void 0){if(typeof d.cascivo!=`string`||!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(d.cascivo))throw Error(`${f}: "cascivo" must be the version of the CLI that generated the app.`);x.cascivo=d.cascivo}return x}function f(e){return{name:e.name,framework:e.framework,theme:e.theme,sections:e.pages.map(e=>e.title),blocks:e.pages.map(e=>e.block),...e.runtime?{runtime:e.runtime}:{},...e.examples?{examples:e.examples}:{},...e.auth?{auth:e.auth}:{}}}export{f as blueprintOptions,d as parseBlueprint};
|
|
2
|
+
//# sourceMappingURL=blueprint-BBrlwJhm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprint-
|
|
1
|
+
{"version":3,"file":"blueprint-BBrlwJhm.mjs","names":["THEMES","blockNames","KEYS","isRecord","value","oneOf","allowed","source","field","parseBlueprint","raw","unknown","key","k","name","blueprint","framework","FRAMEWORKS","theme","pages","blocks","i","page","extra","block","p","runtime","isRuntime","RUNTIMES","examples","valid","isExample","EXAMPLES","auth","parsed","parseAuth","blueprintOptions"],"sources":["../src/scaffold/blueprint.ts"],"sourcesContent":["import { THEMES } from '../utils/config.js'\nimport type { ThemeName } from '../utils/config.js'\nimport {\n EXAMPLES,\n FRAMEWORKS,\n RUNTIMES,\n isExample,\n isRuntime,\n parseAuth,\n} from '../commands/create.js'\nimport type { Auth, Example, Framework, Runtime, ScaffoldOptions } from '../commands/create.js'\nimport { blockNames } from './recipes.js'\n\n/**\n * A blueprint (`cascivo.app.json`) describes an app in the vocabulary of `cascivo create`'s\n * flags, plus one thing the flags cannot say: which registry block each page renders. An\n * agent writes a few hundred bytes of it instead of the app's source; the CLI compiles it.\n */\nexport interface Blueprint {\n name: string\n framework: Framework\n theme: ThemeName\n pages: BlueprintPage[]\n runtime?: Runtime\n examples?: Example[]\n auth?: Auth\n /** The CLI version that generated the app; `cascivo app` rebuilds its merge base with it. */\n cascivo?: string\n}\n\nexport interface BlueprintPage {\n /** The nav label and page heading. The first page is the app's home (`/`). */\n title: string\n /** A block from `blockNames()`; without one the page is a placeholder to build out. */\n block?: string\n}\n\nconst KEYS = new Set([\n '$schema',\n 'name',\n 'framework',\n 'theme',\n 'pages',\n 'runtime',\n 'examples',\n 'auth',\n 'cascivo',\n])\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction oneOf<T extends string>(\n value: unknown,\n allowed: readonly T[],\n field: string,\n source: string,\n): T {\n if (typeof value === 'string' && (allowed as readonly string[]).includes(value)) return value as T\n throw new Error(`${source}: \"${field}\" must be one of: ${allowed.join(', ')}.`)\n}\n\n/** Parse a blueprint. `source` names the file in errors; every error names the field. */\nexport function parseBlueprint(raw: unknown, source: string): Blueprint {\n if (!isRecord(raw)) throw new Error(`${source}: a blueprint must be a JSON object.`)\n const unknown = Object.keys(raw).filter((key) => !KEYS.has(key))\n if (unknown.length > 0) {\n throw new Error(\n `${source}: unknown field ${unknown.map((k) => `\"${k}\"`).join(', ')}. Fields: ${[...KEYS].slice(1).join(', ')}.`,\n )\n }\n const { name, framework = 'react-vite', theme = 'light', pages, runtime, examples, auth } = raw\n // The name becomes the directory the app is written to, so it must stay one plain segment:\n // no separators, no control characters, not \".\" or \"..\".\n // eslint-disable-next-line no-control-regex -- control characters are exactly what it rejects\n const unsafe = /[/\\\\\\u0000-\\u001f]/\n if (\n typeof name !== 'string' ||\n name.trim() === '' ||\n unsafe.test(name) ||\n /^\\.+$/.test(name.trim())\n ) {\n throw new Error(`${source}: \"name\" must be a project directory name, not a path.`)\n }\n const blueprint: Blueprint = {\n name,\n framework: oneOf(framework, FRAMEWORKS, 'framework', source),\n theme: oneOf(theme, THEMES, 'theme', source),\n pages: [],\n }\n\n if (!Array.isArray(pages) || pages.length === 0) {\n throw new Error(`${source}: \"pages\" must be a non-empty array of { \"title\", \"block\"? }.`)\n }\n const blocks = blockNames()\n for (const [i, page] of pages.entries()) {\n if (!isRecord(page) || typeof page.title !== 'string' || page.title.trim() === '') {\n throw new Error(`${source}: pages[${i}] needs a non-empty \"title\".`)\n }\n const extra = Object.keys(page).filter((key) => key !== 'title' && key !== 'block')\n if (extra.length > 0) {\n throw new Error(\n `${source}: pages[${i}] has unknown field \"${extra[0]}\". Fields: title, block.`,\n )\n }\n const { block } = page\n if (block !== undefined && (typeof block !== 'string' || !blocks.includes(block))) {\n throw new Error(\n `${source}: pages[${i}].block ${JSON.stringify(block)} is not a block. Blocks: ${blocks.join(', ')}.`,\n )\n }\n blueprint.pages.push({ title: page.title, ...(block !== undefined ? { block } : {}) })\n }\n if (blueprint.framework === 'astro' && blueprint.pages.some((p) => p.block)) {\n throw new Error(`${source}: blocks need \"framework\" react-vite or cloudflare.`)\n }\n\n if (runtime !== undefined) {\n if (typeof runtime !== 'string' || !isRuntime(runtime)) {\n throw new Error(`${source}: \"runtime\" must be one of: ${RUNTIMES.join(', ')}.`)\n }\n blueprint.runtime = runtime\n }\n if (examples !== undefined) {\n const valid = Array.isArray(examples)\n ? examples.filter((e): e is Example => typeof e === 'string' && isExample(e))\n : []\n if (!Array.isArray(examples) || valid.length !== examples.length) {\n throw new Error(`${source}: \"examples\" must be an array of: ${EXAMPLES.join(', ')}.`)\n }\n blueprint.examples = valid\n }\n if (auth !== undefined) {\n const parsed = parseAuth(typeof auth === 'string' ? auth : undefined)\n if (parsed === null || parsed === 'invalid') {\n throw new Error(`${source}: \"auth\" must be one of: access, email, oauth, email,oauth.`)\n }\n blueprint.auth = parsed\n }\n if (raw.cascivo !== undefined) {\n if (typeof raw.cascivo !== 'string' || !/^\\d+\\.\\d+\\.\\d+(-[\\w.]+)?$/.test(raw.cascivo)) {\n throw new Error(`${source}: \"cascivo\" must be the version of the CLI that generated the app.`)\n }\n blueprint.cascivo = raw.cascivo\n }\n return blueprint\n}\n\n/** The scaffold a blueprint compiles to. */\nexport function blueprintOptions(blueprint: Blueprint): Omit<ScaffoldOptions, 'pm'> {\n return {\n name: blueprint.name,\n framework: blueprint.framework,\n theme: blueprint.theme,\n sections: blueprint.pages.map((p) => p.title),\n blocks: blueprint.pages.map((p) => p.block),\n ...(blueprint.runtime ? { runtime: blueprint.runtime } : {}),\n ...(blueprint.examples ? { examples: blueprint.examples } : {}),\n ...(blueprint.auth ? { auth: blueprint.auth } : {}),\n }\n}\n"],"mappings":"6KAqCA,MAAME,kBAAO,IAAI,IAAI,CACnB,UACA,OACA,YACA,QACA,QACA,UACA,WACA,OACA,SACF,CAAC,EAED,SAASC,EAAS,EAAkD,CAClE,OAAO,OAAOC,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,CAC5E,CAEA,SAASC,EACP,EACA,EACA,EACA,EACG,CACH,GAAI,OAAOD,GAAU,UAAaE,EAA8B,SAASF,CAAK,EAAG,OAAOA,EACxF,MAAU,MAAM,GAAGG,EAAO,KAAKC,EAAM,oBAAoBF,EAAQ,KAAK,IAAI,EAAE,EAAE,CAChF,CAGA,SAAgBG,EAAe,EAA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A,GAAW,CAC7B,GAAI,OAAOA,EAAI,SAAY,UAAY,CAAC,4BAA4B,KAAKA,EAAI,OAAO,EAClF,MAAU,MAAM,GAAGH,EAAO,mEAAmE,EAE/F,EAAU,QAAUG,EAAI,OAC1B,CACA,OAAOK,CACT,CAGA,SAAgBqB,EAAiB,EAAmD,CAClF,MAAO,CACL,KAAMrB,EAAU,KAChB,UAAWA,EAAU,UACrB,MAAOA,EAAU,MACjB,SAAUA,EAAU,MAAM,IAAK,GAAMU,EAAE,KAAK,EAC5C,OAAQV,EAAU,MAAM,IAAK,GAAMU,EAAE,KAAK,EAC1C,GAAIV,EAAU,QAAU,CAAE,QAASA,EAAU,OAAQ,EAAI,CAAC,EAC1D,GAAIA,EAAU,SAAW,CAAE,SAAUA,EAAU,QAAS,EAAI,CAAC,EAC7D,GAAIA,EAAU,KAAO,CAAE,KAAMA,EAAU,IAAK,EAAI,CAAC,CACnD,CACF"}
|
package/dist/cmdspec.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"cmdspec": "0.1",
|
|
4
4
|
"info": {
|
|
5
5
|
"name": "cascivo",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.9.0",
|
|
7
7
|
"summary": "Add, update and audit cascivo components in your project",
|
|
8
8
|
"description": "The cascivo CLI. Components are copied into your project as source you own (the shadcn model); the CLI resolves their dependencies, installs the runtime packages they need, and checks your code against the cascivo contract.\n\nRun it without installing: `npx cascivo <command>`.",
|
|
9
9
|
"homepage": "https://cascivo.com",
|
|
@@ -753,6 +753,315 @@
|
|
|
753
753
|
}
|
|
754
754
|
]
|
|
755
755
|
},
|
|
756
|
+
{
|
|
757
|
+
"name": "design",
|
|
758
|
+
"summary": "Plan a page from a brief and audit the rendered result",
|
|
759
|
+
"description": "Deterministic; needs the optional @cascivo/design package.",
|
|
760
|
+
"subcommandRequired": true,
|
|
761
|
+
"stability": "experimental",
|
|
762
|
+
"commands": [
|
|
763
|
+
{
|
|
764
|
+
"name": "check",
|
|
765
|
+
"summary": "Audit a rendered page",
|
|
766
|
+
"arguments": [
|
|
767
|
+
{
|
|
768
|
+
"name": "target",
|
|
769
|
+
"required": true,
|
|
770
|
+
"summary": "A URL, or a path to an HTML file"
|
|
771
|
+
}
|
|
772
|
+
],
|
|
773
|
+
"options": [
|
|
774
|
+
{
|
|
775
|
+
"name": "--json",
|
|
776
|
+
"summary": "Machine-readable output"
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"name": "--max",
|
|
780
|
+
"summary": "Report at most this many findings",
|
|
781
|
+
"value": {
|
|
782
|
+
"name": "n",
|
|
783
|
+
"type": "integer"
|
|
784
|
+
}
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"name": "--design",
|
|
788
|
+
"summary": "The project's DESIGN.md; tokens in its front matter count as on-scale (default ./DESIGN.md when present)",
|
|
789
|
+
"value": {
|
|
790
|
+
"name": "path"
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
"name": "--storage-state",
|
|
795
|
+
"summary": "Playwright storageState JSON (cookies + localStorage) loaded into the browser, to audit a page behind a login",
|
|
796
|
+
"value": {
|
|
797
|
+
"name": "file",
|
|
798
|
+
"format": "file"
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
],
|
|
802
|
+
"effects": [
|
|
803
|
+
"read",
|
|
804
|
+
"network"
|
|
805
|
+
],
|
|
806
|
+
"stability": "experimental",
|
|
807
|
+
"exits": {
|
|
808
|
+
"1": {
|
|
809
|
+
"meaning": "an error-level finding, or the command failed"
|
|
810
|
+
}
|
|
811
|
+
},
|
|
812
|
+
"examples": [
|
|
813
|
+
{
|
|
814
|
+
"run": "npx cascivo design check http://localhost:5173 --json --max 20"
|
|
815
|
+
}
|
|
816
|
+
]
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
"name": "see",
|
|
820
|
+
"summary": "Save a small screenshot of a page and print a text digest of it",
|
|
821
|
+
"arguments": [
|
|
822
|
+
{
|
|
823
|
+
"name": "url",
|
|
824
|
+
"required": true,
|
|
825
|
+
"summary": "The page to capture",
|
|
826
|
+
"value": {
|
|
827
|
+
"format": "url"
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
],
|
|
831
|
+
"options": [
|
|
832
|
+
{
|
|
833
|
+
"name": "--width",
|
|
834
|
+
"summary": "Viewport width in CSS pixels",
|
|
835
|
+
"value": {
|
|
836
|
+
"name": "n",
|
|
837
|
+
"type": "integer"
|
|
838
|
+
}
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"name": "--out",
|
|
842
|
+
"summary": "Where to write the PNG (default: a stable path in the temp directory)",
|
|
843
|
+
"value": {
|
|
844
|
+
"name": "file"
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"name": "--storage-state",
|
|
849
|
+
"summary": "Playwright storageState JSON (cookies + localStorage) loaded into the browser, to audit a page behind a login",
|
|
850
|
+
"value": {
|
|
851
|
+
"name": "file",
|
|
852
|
+
"format": "file"
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
],
|
|
856
|
+
"effects": [
|
|
857
|
+
"network",
|
|
858
|
+
"write"
|
|
859
|
+
],
|
|
860
|
+
"stability": "experimental",
|
|
861
|
+
"examples": [
|
|
862
|
+
{
|
|
863
|
+
"run": "npx cascivo design see http://localhost:5173 --width 390"
|
|
864
|
+
}
|
|
865
|
+
]
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
"name": "plan",
|
|
869
|
+
"summary": "Turn a brief into a page plan",
|
|
870
|
+
"arguments": [
|
|
871
|
+
{
|
|
872
|
+
"name": "brief",
|
|
873
|
+
"required": true,
|
|
874
|
+
"summary": "What the page is for, in plain words"
|
|
875
|
+
}
|
|
876
|
+
],
|
|
877
|
+
"options": [
|
|
878
|
+
{
|
|
879
|
+
"name": "--format",
|
|
880
|
+
"summary": "Output format: .cv text or ViewConfig JSON",
|
|
881
|
+
"value": {
|
|
882
|
+
"name": "f",
|
|
883
|
+
"enum": [
|
|
884
|
+
"cv",
|
|
885
|
+
"view"
|
|
886
|
+
]
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"name": "--json",
|
|
891
|
+
"summary": "Machine-readable output"
|
|
892
|
+
}
|
|
893
|
+
],
|
|
894
|
+
"effects": [],
|
|
895
|
+
"idempotent": true,
|
|
896
|
+
"stability": "experimental",
|
|
897
|
+
"examples": [
|
|
898
|
+
{
|
|
899
|
+
"run": "npx cascivo design plan \"a pricing page with three tiers\" --format cv"
|
|
900
|
+
}
|
|
901
|
+
]
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
"name": "init",
|
|
905
|
+
"summary": "Write a DESIGN.md for the project; keeps an existing file",
|
|
906
|
+
"options": [
|
|
907
|
+
{
|
|
908
|
+
"name": "--theme",
|
|
909
|
+
"summary": "Theme whose token values to write (default light)",
|
|
910
|
+
"value": {
|
|
911
|
+
"name": "name"
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
"name": "--accent",
|
|
916
|
+
"summary": "Direction: the accent colour (hex or functional CSS colour)",
|
|
917
|
+
"value": {
|
|
918
|
+
"name": "colour"
|
|
919
|
+
}
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
"name": "--primary",
|
|
923
|
+
"summary": "Direction: the primary action colour",
|
|
924
|
+
"value": {
|
|
925
|
+
"name": "colour"
|
|
926
|
+
}
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
"name": "--background",
|
|
930
|
+
"summary": "Direction: the page background colour",
|
|
931
|
+
"value": {
|
|
932
|
+
"name": "colour"
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
"name": "--surface",
|
|
937
|
+
"summary": "Direction: the surface colour",
|
|
938
|
+
"value": {
|
|
939
|
+
"name": "colour"
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
"name": "--text",
|
|
944
|
+
"summary": "Direction: the text colour",
|
|
945
|
+
"value": {
|
|
946
|
+
"name": "colour"
|
|
947
|
+
}
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"name": "--font-display",
|
|
951
|
+
"summary": "Direction: font stack for display and headings",
|
|
952
|
+
"value": {
|
|
953
|
+
"name": "stack"
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
"name": "--font-body",
|
|
958
|
+
"summary": "Direction: font stack for everything else",
|
|
959
|
+
"value": {
|
|
960
|
+
"name": "stack"
|
|
961
|
+
}
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
"name": "--signature",
|
|
965
|
+
"summary": "Direction: the one signature element, in a sentence",
|
|
966
|
+
"value": {
|
|
967
|
+
"name": "text"
|
|
968
|
+
}
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
"name": "--composition",
|
|
972
|
+
"summary": "Direction: the one composition move, in a sentence",
|
|
973
|
+
"value": {
|
|
974
|
+
"name": "text"
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
"name": "--force",
|
|
979
|
+
"summary": "Replace an existing DESIGN.md"
|
|
980
|
+
}
|
|
981
|
+
],
|
|
982
|
+
"effects": [
|
|
983
|
+
"read",
|
|
984
|
+
"write"
|
|
985
|
+
],
|
|
986
|
+
"stability": "experimental",
|
|
987
|
+
"examples": [
|
|
988
|
+
{
|
|
989
|
+
"run": "npx cascivo design init --theme dark"
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
"run": "npx cascivo design init --accent \"#b4532a\" --font-display \"Georgia, serif\" --signature \"a ruled double line under the title\""
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
},
|
|
996
|
+
{
|
|
997
|
+
"name": "skill",
|
|
998
|
+
"summary": "Write the cascivo-design agent skill into the project (offline, matches this version)",
|
|
999
|
+
"options": [
|
|
1000
|
+
{
|
|
1001
|
+
"name": "--dir",
|
|
1002
|
+
"summary": "The skills directory to write into (default .claude/skills)",
|
|
1003
|
+
"value": {
|
|
1004
|
+
"name": "path",
|
|
1005
|
+
"format": "file"
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
"name": "--force",
|
|
1010
|
+
"summary": "Replace an existing cascivo-design skill folder"
|
|
1011
|
+
}
|
|
1012
|
+
],
|
|
1013
|
+
"effects": [
|
|
1014
|
+
"write"
|
|
1015
|
+
],
|
|
1016
|
+
"stability": "experimental",
|
|
1017
|
+
"examples": [
|
|
1018
|
+
{
|
|
1019
|
+
"run": "npx cascivo design skill"
|
|
1020
|
+
}
|
|
1021
|
+
]
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
"name": "theme",
|
|
1025
|
+
"summary": "Derive a theme from one seed colour and print its CSS",
|
|
1026
|
+
"options": [
|
|
1027
|
+
{
|
|
1028
|
+
"name": "--seed",
|
|
1029
|
+
"required": true,
|
|
1030
|
+
"summary": "The seed colour, as hex",
|
|
1031
|
+
"value": {
|
|
1032
|
+
"name": "hex"
|
|
1033
|
+
}
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
"name": "--mode",
|
|
1037
|
+
"summary": "Light or dark surfaces",
|
|
1038
|
+
"value": {
|
|
1039
|
+
"name": "m",
|
|
1040
|
+
"enum": [
|
|
1041
|
+
"light",
|
|
1042
|
+
"dark"
|
|
1043
|
+
]
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
"name": "--name",
|
|
1048
|
+
"summary": "The data-theme value the tokens attach to",
|
|
1049
|
+
"value": {
|
|
1050
|
+
"name": "name"
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
],
|
|
1054
|
+
"effects": [],
|
|
1055
|
+
"idempotent": true,
|
|
1056
|
+
"stability": "experimental",
|
|
1057
|
+
"examples": [
|
|
1058
|
+
{
|
|
1059
|
+
"run": "npx cascivo design theme --seed \"#0079bf\""
|
|
1060
|
+
}
|
|
1061
|
+
]
|
|
1062
|
+
}
|
|
1063
|
+
]
|
|
1064
|
+
},
|
|
756
1065
|
{
|
|
757
1066
|
"name": "mcp",
|
|
758
1067
|
"summary": "Configure the cascivo MCP server",
|
|
@@ -1,4 +1,4 @@
|
|
|
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.12.
|
|
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.12.1`,"@cascivo/themes":`1.0.3`,"@cascivo/astro":`1.12.1`,"@cascivo/charts":`1.12.1`,"@cascivo/icons":`1.1.1`,"@cascivo/eslint-config":`0.4.2`,"@cascivo/app":`1.12.1`,"@cascivo/render":`1.12.1`,"@cascivo/storage":`1.12.1`,"@cascivo/email":`0.6.1`},y=`>=3.0.0`,b=`1.9.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 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
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({
|
|
@@ -1998,10 +1998,10 @@ export function Shell`);return t.slice(0,n)+` * Routing lives in src/router.ts;
|
|
|
1998
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(`
|
|
1999
1999
|
`).map(e=>e.startsWith(`#`)?e:e.replace(/=.*$/,`=`)).join(`
|
|
2000
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-
|
|
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-BBrlwJhm.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
2002
|
Next steps:`),console.log(` cd ${c}`),console.log(` ${N(w)}`),console.log(` ${P(w,`dev`)}`),console.log(`
|
|
2003
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
2004
|
No account yet? Share a 60-minute preview, claimable into a free account:`),console.log(` ${F(w,`deploy:preview`)}`)):d===`astro`?(console.log(`
|
|
2005
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(`
|
|
2006
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-
|
|
2007
|
+
//# sourceMappingURL=create-BMqDBB8r.mjs.map
|