@conloca/cli 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +13 -6
  2. package/dist/conloca.js +183 -35
  3. package/package.json +12 -6
package/README.md CHANGED
@@ -74,7 +74,8 @@ This command will generate:
74
74
  - `src/components/puck/Flex.tsx` - Flex layout component
75
75
  - `src/components/puck/Grid.tsx` - Grid layout component
76
76
  - `src/layouts/Layout.astro` - Bare page layout, meant to be replaced
77
- - `src/schemas/data.ts` - Example Zod schemas for data collections
77
+ - `src/schemas/data.ts` - Example Typia data-collection schemas (types plus generated validators and form metadata)
78
+ - `typia-vite.mjs` / `tsconfig.typia.json` - The native Typia transform `astro.config.mjs` runs over `src/schemas/`
78
79
  - `content/sites.json` - Site list, holding the site `default`
79
80
  - `.claude/skills/conloca/SKILL.md` - One-page Conloca guide for coding agents
80
81
 
@@ -111,7 +112,8 @@ conloca doctor [path] [--json] [--live]
111
112
 
112
113
  Content checks, always:
113
114
 
114
- - `sites.json` exists, parses, and declares `defaultLocale` plus a non-empty `locales` list for every site
115
+ - `sites.json` exists, parses, and declares `defaultLocale` plus a non-empty `locales` list for every site, each locale
116
+ one a content file name can carry: a two-letter language code, optionally with a region, like `en` or `en-US`
115
117
  - every configured site has its `pages/` directory on disk (site-shaped directories missing from `sites.json` are
116
118
  flagged too)
117
119
  - every content file indexes cleanly — each file reported is one the CMS would otherwise silently drop
@@ -122,7 +124,7 @@ Astro checks, when an `astro.config.mjs`/`.ts`/`.js` is present (the config is r
122
124
  - `conlocaCMS` is imported from `@conloca/astro-cms/node` and its options carry `contentRoot`, `puckConfigPath`, and a
123
125
  `routing` block or `layout`
124
126
  - `react()` is in `integrations` and comes before `conlocaCMS()`
125
- - the `zod` and `@vitejs/plugin-react` peers are declared in `package.json`
127
+ - the `@vitejs/plugin-react` peer is declared in `package.json`
126
128
  - `tsconfig.json` sets `compilerOptions.jsx` to `react-jsx` (advisory — a warning only)
127
129
  - with `output: 'server'`, every file under `src/pages` declares `prerender`
128
130
  - no static `src/pages/index.astro` shadows the CMS home page
@@ -189,8 +191,12 @@ conloca page create --site <site> --collection <collection> --pathname <pathname
189
191
  Writes a new `.vxjson` file under `<content root>/<site>/<collection>` with the same empty Puck payload the CMS writes
190
192
  for a new page, then prints the page id and the created file path. It exits 1 when the site is unknown, the pathname is
191
193
  invalid or already taken, or the write fails; validation failures name the offending option. `--json` prints
192
- `{ok, id, path}` on success and `{ok: false, error, field?}` on failure — stdout carries exactly that one object,
193
- progress lines go to stderr.
194
+ `{ok, id, path, warnings?}` on success and `{ok: false, error, field?}` on failure — stdout carries exactly that one
195
+ object, progress lines and warnings go to stderr.
196
+
197
+ A collection other than `pages` must be declared with `conlocaPages({ collection })` in the content config, or the build
198
+ fails on its pages, and given a route in `conlocaCMS({ routing })` to be served; `page create` warns when the config
199
+ plainly does not declare it.
194
200
 
195
201
  Example:
196
202
 
@@ -218,7 +224,8 @@ Adding Conloca to an existing Astro site instead? Install the packages, run `con
218
224
  prints to `astro.config.mjs`, create `src/content.config.ts` as printed, then run `conloca doctor`:
219
225
 
220
226
  ```bash
221
- npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react zod
227
+ npm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react typia
228
+ npm install -D ttsc @ttsc/unplugin
222
229
  conloca astro setup
223
230
  conloca doctor
224
231
  ```
package/dist/conloca.js CHANGED
@@ -2170,10 +2170,12 @@ var THIRD_PARTY_VERSIONS = {
2170
2170
  "@vitejs/plugin-react": "^5.2.0",
2171
2171
  react: "19.2.8",
2172
2172
  "react-dom": "19.2.8",
2173
- zod: "^4.5.4",
2174
- "@astrojs/check": "^0.9.10"
2173
+ typia: "^14.0.4",
2174
+ "@astrojs/check": "^0.9.10",
2175
+ "@ttsc/unplugin": "^0.30.4",
2176
+ ttsc: "0.30.4"
2175
2177
  };
2176
- var DEV_ONLY = new Set(["@astrojs/check"]);
2178
+ var DEV_ONLY = new Set(["@astrojs/check", "@ttsc/unplugin", "ttsc"]);
2177
2179
  var MANIFEST_CANDIDATES = ["../package.json", "../../package.json"];
2178
2180
  async function readCliManifest() {
2179
2181
  for (const candidate of MANIFEST_CANDIDATES) {
@@ -2277,6 +2279,7 @@ import node from '@astrojs/node';
2277
2279
  import react from '@astrojs/react';
2278
2280
  import { conlocaCMS } from '@conloca/astro-cms/node';
2279
2281
  import { defineConfig } from 'astro/config';
2282
+ import { schemaTypia } from './typia-vite.mjs';
2280
2283
 
2281
2284
  export default defineConfig({
2282
2285
  output: 'server',
@@ -2302,9 +2305,46 @@ export default defineConfig({
2302
2305
  },
2303
2306
  }),
2304
2307
  ],
2308
+ // Generates the validators and form metadata src/schemas/data.ts declares.
2309
+ vite: { plugins: [...schemaTypia()] },
2305
2310
  });
2306
2311
  `;
2307
2312
  }
2313
+ var TYPIA_VITE_TEMPLATE = `import { fileURLToPath } from 'node:url';
2314
+ import ttsc from '@ttsc/unplugin/vite';
2315
+
2316
+ const project = fileURLToPath(new URL('./tsconfig.typia.json', import.meta.url));
2317
+
2318
+ /**
2319
+ * Compiles the Typia call sites in src/schemas/ into generated validators and
2320
+ * JSON Schema metadata. Astro's content config and the CMS editor both load
2321
+ * those modules through this Vite pipeline.
2322
+ *
2323
+ * @returns {import('vite').Plugin[]}
2324
+ */
2325
+ export function schemaTypia() {
2326
+ const plugins = ttsc({ project });
2327
+ return (Array.isArray(plugins) ? plugins : [plugins]).map((plugin) => {
2328
+ const transform = plugin.transform;
2329
+ if (!transform) return plugin;
2330
+ const hook = typeof transform === 'function' ? { handler: transform } : transform;
2331
+ return { ...plugin, transform: { ...hook, filter: { ...hook.filter, id: /[\\\\/]src[\\\\/]schemas[\\\\/]/ } } };
2332
+ });
2333
+ }
2334
+ `;
2335
+ var TYPIA_TSCONFIG_TEMPLATE = `{
2336
+ "compilerOptions": {
2337
+ "target": "ES2022",
2338
+ "module": "ESNext",
2339
+ "moduleResolution": "Bundler",
2340
+ "strict": true,
2341
+ "skipLibCheck": true,
2342
+ "noEmit": true,
2343
+ "types": []
2344
+ },
2345
+ "include": ["src/schemas/**/*.ts"]
2346
+ }
2347
+ `;
2308
2348
  var TSCONFIG_TEMPLATE = `{
2309
2349
  "extends": "astro/tsconfigs/strict",
2310
2350
  "compilerOptions": {
@@ -2357,6 +2397,7 @@ Working with a coding agent? \`.claude/skills/conloca/SKILL.md\` teaches it Conl
2357
2397
  // src/commands/doctor.ts
2358
2398
  import { readdir as readdir2, readFile as readFile5, stat } from "node:fs/promises";
2359
2399
  import { join as join6, resolve as resolve3 } from "node:path";
2400
+ import { invalidLocaleMessage, isContentLocale } from "@conloca/content-api/content-path";
2360
2401
  import { ContentIndex, FileSystemReaderBackend } from "@conloca/content-api/node";
2361
2402
 
2362
2403
  // src/lib/content-root.ts
@@ -2417,7 +2458,7 @@ async function readProjectDependencies(projectDir) {
2417
2458
 
2418
2459
  // src/commands/doctor-astro.ts
2419
2460
  var ASTRO_CONFIG_NAMES = ["astro.config.mjs", "astro.config.ts", "astro.config.js"];
2420
- var CMS_PEERS = ["zod", "@vitejs/plugin-react"];
2461
+ var CMS_PEERS = ["@vitejs/plugin-react"];
2421
2462
  var PAGE_FILE_RE = /\.(?:astro|ts|md|mdx)$/;
2422
2463
  var OPENERS = { "(": ")", "{": "}", "[": "]" };
2423
2464
  var CLOSERS = new Set([")", "}", "]"]);
@@ -2565,6 +2606,64 @@ function extractCmsOptions(configText) {
2565
2606
  const parsed = objectText === null ? null : parseObjectEntries(objectText);
2566
2607
  return parsed === null ? { state: "dynamic" } : { state: "literal", ...parsed };
2567
2608
  }
2609
+ var IN_VIEW_COLLECTION_CALLS = new Set(["conlocaPages", "conlocaData", "conlocaFragments", "defineCollection"]);
2610
+ function isInViewCollectionCall(value) {
2611
+ const call = /^([$A-Za-z_][$\w]*)\s*\(/.exec(value);
2612
+ if (call === null || !IN_VIEW_COLLECTION_CALLS.has(call[1]))
2613
+ return false;
2614
+ const argsStart = call[0].length - 1;
2615
+ return balancedSlice(value, argsStart) === value.slice(argsStart);
2616
+ }
2617
+ function collectionsAllInView(text) {
2618
+ const declaration = /\b(?:const|let|var)\s+collections\s*=\s*/.exec(text);
2619
+ const start = declaration === null ? -1 : declaration.index + declaration[0].length;
2620
+ const objectText = text[start] === "{" ? balancedSlice(text, start) : null;
2621
+ if (objectText === null)
2622
+ return false;
2623
+ const body = objectText.slice(1, -1);
2624
+ for (let i = 0;i < body.length; ) {
2625
+ const end = skipValue(body, i);
2626
+ const member = body.slice(i, end).trim();
2627
+ i = end + 1;
2628
+ if (member === "")
2629
+ continue;
2630
+ const key = /^(?:\.\.\.|(?:[$A-Za-z_][$\w]*|'[^']*'|"[^"]*")\s*:)/.exec(member);
2631
+ if (key === null || !isInViewCollectionCall(member.slice(key[0].length).trim()))
2632
+ return false;
2633
+ }
2634
+ return true;
2635
+ }
2636
+ function declaredPageCollections(configText) {
2637
+ const text = stripComments(configText);
2638
+ if (["createConlocaCollections", "conlocaLoader"].some((marker) => containsOutsideStrings(text, marker))) {
2639
+ return null;
2640
+ }
2641
+ if (/\bconlocaPages\s+as\b/.test(text) || !collectionsAllInView(text))
2642
+ return null;
2643
+ const declared = new Set;
2644
+ for (const call of text.matchAll(/\bconlocaPages\s*\(/g)) {
2645
+ const args = balancedSlice(text, call.index + call[0].length - 1);
2646
+ if (args === null)
2647
+ return null;
2648
+ const inner = args.slice(1, -1).trim().replace(/,$/, "").trim();
2649
+ if (inner === "") {
2650
+ declared.add("pages");
2651
+ continue;
2652
+ }
2653
+ const objectText = inner.startsWith("{") ? balancedSlice(inner, 0) : null;
2654
+ const options = objectText === inner ? parseObjectEntries(objectText) : null;
2655
+ if (options === null || options.hasSpread)
2656
+ return null;
2657
+ const raw = options.entries.get("collection");
2658
+ if (raw === undefined && /\bcollection\b/.test(inner))
2659
+ return null;
2660
+ const name = raw === undefined ? "pages" : stringLiteral(raw);
2661
+ if (name === null)
2662
+ return null;
2663
+ declared.add(name);
2664
+ }
2665
+ return declared.size > 0 ? declared : null;
2666
+ }
2568
2667
  var ASTRO_CHECK_LABELS = {
2569
2668
  C1: "content config registers Conloca collections",
2570
2669
  C2: "siteName matches a sites.json entry",
@@ -3118,6 +3217,11 @@ var CONTENT_GLOB = "{**/*.{vxjson,mdx},data/**/*.json}";
3118
3217
  function isLocaleList(value) {
3119
3218
  return Array.isArray(value) && value.length > 0 && value.every((locale) => typeof locale === "string" && locale.trim() !== "");
3120
3219
  }
3220
+ function declaredLocales(parsed) {
3221
+ const sites = isRecord(parsed.sites) ? Object.values(parsed.sites).filter(isRecord) : [];
3222
+ const lists = [parsed.globalLocales, ...sites.flatMap((site) => [site.locales, [site.defaultLocale]])];
3223
+ return lists.flatMap((list) => Array.isArray(list) ? list : []).filter((locale) => typeof locale === "string" && locale.trim() !== "");
3224
+ }
3121
3225
  function counted(count, noun) {
3122
3226
  return count === 1 ? `1 ${noun}` : `${count} ${noun}s`;
3123
3227
  }
@@ -3183,7 +3287,13 @@ async function checkSitesFile(contentRoot) {
3183
3287
  if (Array.isArray(parsed.globalLocales) && parsed.globalLocales.length > 0 && !isLocaleList(parsed.globalLocales)) {
3184
3288
  problems.push({ check: "C3", level: "error", message: "globalLocales must contain only non-empty strings", path });
3185
3289
  }
3186
- if (problems.some((problem) => problem.level === "error")) {
3290
+ const unusable = problems.some((problem) => problem.level === "error");
3291
+ for (const locale of new Set(declaredLocales(parsed))) {
3292
+ if (!isContentLocale(locale)) {
3293
+ problems.push({ check: "C3", level: "error", message: invalidLocaleMessage(locale), path });
3294
+ }
3295
+ }
3296
+ if (unusable) {
3187
3297
  return { outcome, config: null };
3188
3298
  }
3189
3299
  const globalLocales = Array.isArray(parsed.globalLocales) && parsed.globalLocales.length > 0 ? parsed.globalLocales : ["en"];
@@ -3299,7 +3409,7 @@ import { join as join8, resolve as resolve4 } from "node:path";
3299
3409
  // src/lib/sites-config.ts
3300
3410
  import { readFile as readFile6, writeFile } from "node:fs/promises";
3301
3411
  import { join as join7 } from "node:path";
3302
- var DEFAULT_LOCALES = ["en", "nl", "de", "fr"];
3412
+ var DEFAULT_LOCALES = ["en"];
3303
3413
  async function ensureSiteInSitesConfig(contentPath, siteName) {
3304
3414
  const path = join7(contentPath, "sites.json");
3305
3415
  let sitesConfig = { sites: {}, globalLocales: [...DEFAULT_LOCALES] };
@@ -3323,7 +3433,7 @@ async function ensureSiteInSitesConfig(contentPath, siteName) {
3323
3433
  }
3324
3434
 
3325
3435
  // src/templates/conloca-skill.md
3326
- var conloca_skill_default = "---\nname: conloca\ndescription: Load when working on an Astro site using Conloca CMS — @conloca/* packages, .vxjson content, sites.json.\n---\n\n# Conloca CMS\n\nConloca stores pages as `.vxjson` files (visual pages built from Puck components) and `.mdx` files under `content/`, and\nrenders them through the `@conloca/astro-cms` Astro integration. The visual editor lives at `/__cms` on the dev server\nonly.\n\n## First move: `conloca doctor`\n\nFor any Conloca problem — blank page, 404 on a content page, editor not loading, build failure — run this before reading\nsource:\n\n```bash\nconloca doctor # human-readable report\nconloca doctor --json # single {ok, problems} object on stdout\n```\n\nThe `conloca` command ships in `@conloca/cli` — run it as `npx @conloca/cli doctor` (or `bunx`) when it is not\ninstalled.\n\nIt checks the content directory (sites.json complete, site directories present, every content file indexes cleanly) and,\nwhen an astro.config is present, the Astro wiring: content config, conlocaCMS import and options, react() order, peer\ndependencies, tsconfig jsx, prerender under server output, and home-page shadowing. Each problem names the broken file\nand the fix. It is read-only and exits 1 on errors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site;\n`conloca astro setup` is for adding Conloca to an existing Astro site.\n\n## The files a working site needs\n\n- `astro.config.mjs` — registers `react()` and `conlocaCMS(...)`\n- `src/content.config.ts` — declares the content collections (without it every content page 404s)\n- `content/sites.json` — sites with their `locales` and `defaultLocale`, plus `globalLocales`\n- `src/puck.config.tsx` — registers the Puck components pages are built from\n- `src/layouts/Layout.astro` — the page layout content pages render into\n- `src/components/puck/*` and `src/schemas/data.ts` — starter components and data-collection schemas\n\nRun `conloca astro setup` inside an existing Astro project. It scaffolds the content config, components, schemas, page\nlayout, and content directories, preserving existing generated files. It adds the default site to `sites.json` when\nmissing. It prints the `astro.config` wiring rather than writing that file: merge the printed options into the existing\nconfig, then run `conloca doctor` to verify the result. `conloca init . <site-name>` adds another site to sites.json.\n\n## Install: the exact package set\n\n```bash\nnpm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react zod\n```\n\n`@puckeditor/core` is what the generated components import — there is no other Puck package to install.\n\n## Canonical astro.config.mjs\n\nThe minimal working config, matching what `conloca astro setup` prints:\n\n```js\nimport react from '@astrojs/react';\nimport { conlocaCMS } from '@conloca/astro-cms/node';\nimport { defineConfig } from 'astro/config';\n\nexport default defineConfig({\n integrations: [\n react(),\n conlocaCMS({\n contentRoot: './content',\n puckConfigPath: './src/puck.config.tsx',\n schemasPath: './src/schemas/data.ts',\n layout: './src/layouts/Layout.astro',\n }),\n ],\n});\n```\n\n`react()` must come before `conlocaCMS()` — doctor checks the order. And `src/content.config.ts`:\n\n```ts\nimport { conlocaData, conlocaFragments, conlocaPages } from '@conloca/astro-cms/node/content';\nimport { dataSchemas } from './schemas/data';\n\nexport const collections = {\n pages: conlocaPages(),\n ...conlocaData({ dataSchemas }),\n ...conlocaFragments(),\n};\n```\n\nEvery collection is declared here by name — content the config does not name fails the build instead of silently not\nbuilding.\n\n## Where errors appear\n\n- `astro dev` runs in the foreground: config and integration errors print to the terminal running it, and page errors\n also show in the browser error overlay. There is no separate log command — read that terminal.\n- A page referencing a Puck component type missing from puck.config.tsx serves HTTP 200 with a blank region and a clean\n browser console. The only signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...`\n in the dev-server or build terminal.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Creating a page\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us'\n```\n\nWrites the `.vxjson` file with the same empty Puck payload the CMS writes for a new page, in the site's default locale;\nthe page is immediately editable at `/__cms`. `--json` prints `{ok, id, path}`. Do not hand-craft `.vxjson` files and do\nnot reach for HTTP endpoints — this command is the supported path.\n\n## Routing\n\n- `layout: './src/layouts/Layout.astro'` alone injects a catch-all `/[...slug]` route over the `pages` collection, with\n `prerender: true` and `fallback: '404'`.\n- Passing `routing` replaces that default route entirely and the top-level `layout` is then ignored — name it per route\n instead: `routing: { routes: { pages: { pattern: '/[...slug]', layout: './src/layouts/Layout.astro' } } }`.\n- `routing: true` is the same default catch-all with no layout.\n- `fallback: '404'` returns a bare 404 when no content matches the pattern; `'passthrough'` hands the miss back to Astro\n so the site's own `/404` page renders, with a real 404 status.\n- Trap: a static `src/pages/index.astro` shadows the CMS home page — the file wins over the catch-all and Astro says\n nothing. Doctor flags it; delete the file or manage the home page in the CMS.\n\n## Adding Conloca to an existing Astro site\n\n- Switching to `output: 'server'`: first add `export const prerender = true` to every existing file under `src/pages/`,\n then flip the output — otherwise those pages silently stop being static. Doctor errors on files that miss it.\n- Existing `.mdx` content: set the site's `mdxPages` path in `content/sites.json` (relative to the project root, e.g.\n `./src/content/docs`). `.mdx` files under it surface in the CMS as pages of that site; the default locale lives at\n `<mdxPages>/<slug>.mdx`, other locales at `<mdxPages>/<locale>/<slug>.mdx`.\n- Plain `.md` files are never adopted — only `.mdx` and `.vxjson` are recognized as pages. Rename `.md` to `.mdx` to\n bring a file under management.\n\n## Custom Puck components\n\nFollow the generated examples in `src/components/puck/` — that is the one proven path:\n\n1. Write a render component plus a `ComponentConfig` wrapped in `withLayout` from `src/components/ComponentLayout.tsx`,\n mirroring the generated `HeadingComponent.tsx` / `Heading.tsx` pair.\n2. Register the component and its Props type in `src/puck.config.tsx`: add it to the `Components` type and the\n `components` map (and optionally a `categories` entry).\n3. Types come from `@puckeditor/core`. If `.tsx` components misrender or fail typecheck, set tsconfig\n `\"jsx\": \"react-jsx\"` — doctor's advisory warning covers this.\n\nA component referenced by stored content but not registered renders blank — see \"Where errors appear\".\n\n## Known limits — by design, do not fight them\n\n- MDX fragments render prose only.\n `Unknown component <X>: fragments render as plain content and cannot use React components.` is intentional: fragment\n content is treated as untrusted, so `{...}` expressions and `import`/`export` statements are rejected too. Do not try\n to sneak components in.\n- Unknown Puck component types render as nothing; the dev-server or build console names them. The fix is registering the\n type in `puck.config.tsx`, not editing the stored content.\n";
3436
+ var conloca_skill_default = "---\nname: conloca\ndescription: Load when working on an Astro site using Conloca CMS — @conloca/* packages, .vxjson content, sites.json.\n---\n\n# Conloca CMS\n\nConloca stores pages as `.vxjson` files (visual pages built from Puck components) and `.mdx` files under `content/`, and\nrenders them through the `@conloca/astro-cms` Astro integration. The visual editor lives at `/__cms` on the dev server\nonly.\n\n## First move: `conloca doctor`\n\nFor any Conloca problem — blank page, 404 on a content page, editor not loading, build failure — run this before reading\nsource:\n\n```bash\nconloca doctor # human-readable report\nconloca doctor --json # single {ok, problems} object on stdout\n```\n\nThe `conloca` command ships in `@conloca/cli` — run it as `npx @conloca/cli doctor` (or `bunx`) when it is not\ninstalled.\n\nIt checks the content directory (sites.json complete, site directories present, every content file indexes cleanly) and,\nwhen an astro.config is present, the Astro wiring: content config, conlocaCMS import and options, react() order, peer\ndependencies, tsconfig jsx, prerender under server output, and home-page shadowing. Each problem names the broken file\nand the fix. It is read-only and exits 1 on errors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site;\n`conloca astro setup` is for adding Conloca to an existing Astro site.\n\n## The files a working site needs\n\n- `astro.config.mjs` — registers `react()` and `conlocaCMS(...)`\n- `src/content.config.ts` — declares the content collections (without it every content page 404s)\n- `content/sites.json` — sites with their `locales` and `defaultLocale`, plus `globalLocales`\n- `src/puck.config.tsx` — registers the Puck components pages are built from\n- `src/layouts/Layout.astro` — the page layout content pages render into\n- `src/components/puck/*` and `src/schemas/data.ts` — starter components and data-collection schemas\n\nRun `conloca astro setup` inside an existing Astro project. It scaffolds the content config, components, schemas, page\nlayout, and content directories, preserving existing generated files. It adds the default site to `sites.json` when\nmissing. It prints the `astro.config` wiring rather than writing that file: merge the printed options into the existing\nconfig, then run `conloca doctor` to verify the result. `conloca init . <site-name>` adds another site to sites.json.\n\n## Install: the exact package set\n\n```bash\nnpm install @conloca/astro-cms @conloca/content-api @conloca/mdx @puckeditor/core @astrojs/react @vitejs/plugin-react typia\nnpm install -D ttsc @ttsc/unplugin\n```\n\n`@puckeditor/core` is what the generated components import — there is no other Puck package to install.\n\n## Canonical astro.config.mjs\n\nThe minimal working config, matching what `conloca astro setup` prints:\n\n```js\nimport react from '@astrojs/react';\nimport { conlocaCMS } from '@conloca/astro-cms/node';\nimport { defineConfig } from 'astro/config';\nimport { schemaTypia } from './typia-vite.mjs';\n\nexport default defineConfig({\n integrations: [\n react(),\n conlocaCMS({\n contentRoot: './content',\n puckConfigPath: './src/puck.config.tsx',\n schemasPath: './src/schemas/data.ts',\n layout: './src/layouts/Layout.astro',\n }),\n ],\n vite: { plugins: [...schemaTypia()] },\n});\n```\n\n`react()` must come before `conlocaCMS()` — doctor checks the order. `src/schemas/data.ts` declares each data collection\nas a TypeScript type plus its generated Typia validator (`typia.plain.createValidatePrune<T>()`) and form metadata\n(`typia.json.schema<T>()`); `typia-vite.mjs` is the native transform that generates them, so it must stay in\n`vite.plugins`. And `src/content.config.ts`:\n\n```ts\nimport { conlocaData, conlocaFragments, conlocaPages } from '@conloca/astro-cms/node/content';\nimport { dataSchemas } from './schemas/data';\n\nexport const collections = {\n pages: conlocaPages(),\n ...conlocaData({ dataSchemas }),\n ...conlocaFragments(),\n};\n```\n\nEvery collection is declared here by name — content the config does not name fails the build instead of silently not\nbuilding.\n\n## Where errors appear\n\n- `astro dev` runs in the foreground: config and integration errors print to the terminal running it, and page errors\n also show in the browser error overlay. There is no separate log command — read that terminal.\n- A page referencing a Puck component type missing from puck.config.tsx serves HTTP 200 with a blank region and a clean\n browser console. The only signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...`\n in the dev-server or build terminal.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Creating a page\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us'\n```\n\nWrites the `.vxjson` file with the same empty Puck payload the CMS writes for a new page, in the site's default locale;\nthe page is immediately editable at `/__cms`. `--json` prints `{ok, id, path}`. Do not hand-craft `.vxjson` files and do\nnot reach for HTTP endpoints — this command is the supported path.\n\n## Routing\n\n- `layout: './src/layouts/Layout.astro'` alone injects a catch-all `/[...slug]` route over the `pages` collection, with\n `prerender: true` and `fallback: '404'`.\n- Passing `routing` replaces that default route entirely and the top-level `layout` is then ignored — name it per route\n instead: `routing: { routes: { pages: { pattern: '/[...slug]', layout: './src/layouts/Layout.astro' } } }`.\n- `routing: true` is the same default catch-all with no layout.\n- `fallback: '404'` returns a bare 404 when no content matches the pattern; `'passthrough'` hands the miss back to Astro\n so the site's own `/404` page renders, with a real 404 status.\n- Trap: a static `src/pages/index.astro` shadows the CMS home page — the file wins over the catch-all and Astro says\n nothing. Doctor flags it; delete the file or manage the home page in the CMS.\n\n## Adding Conloca to an existing Astro site\n\n- Switching to `output: 'server'`: first add `export const prerender = true` to every existing file under `src/pages/`,\n then flip the output — otherwise those pages silently stop being static. Doctor errors on files that miss it.\n- Existing `.mdx` content: set the site's `mdxPages` path in `content/sites.json` (relative to the project root, e.g.\n `./src/content/docs`). `.mdx` files under it surface in the CMS as pages of that site; the default locale lives at\n `<mdxPages>/<slug>.mdx`, other locales at `<mdxPages>/<locale>/<slug>.mdx`.\n- Plain `.md` files are never adopted — only `.mdx` and `.vxjson` are recognized as pages. Rename `.md` to `.mdx` to\n bring a file under management.\n\n## Custom Puck components\n\nFollow the generated examples in `src/components/puck/` — that is the one proven path:\n\n1. Write a render component plus a `ComponentConfig` wrapped in `withLayout` from `src/components/ComponentLayout.tsx`,\n mirroring the generated `HeadingComponent.tsx` / `Heading.tsx` pair.\n2. Register the component and its Props type in `src/puck.config.tsx`: add it to the `Components` type and the\n `components` map (and optionally a `categories` entry).\n3. Types come from `@puckeditor/core`. If `.tsx` components misrender or fail typecheck, set tsconfig\n `\"jsx\": \"react-jsx\"` — doctor's advisory warning covers this.\n\nA component referenced by stored content but not registered renders blank — see \"Where errors appear\".\n\n## Known limits — by design, do not fight them\n\n- MDX fragments render prose only.\n `Unknown component <X>: fragments render as plain content and cannot use React components.` is intentional: fragment\n content is treated as untrusted, so `{...}` expressions and `import`/`export` statements are rejected too. Do not try\n to sneak components in.\n- Unknown Puck component types render as nothing; the dev-server or build console names them. The fix is registering the\n type in `puck.config.tsx`, not editing the stored content.\n";
3327
3437
 
3328
3438
  // src/commands/setup.ts
3329
3439
  var DEFAULT_SITE_NAME = "default";
@@ -3927,37 +4037,55 @@ const puckConfig: Config<Components> = {
3927
4037
 
3928
4038
  export default puckConfig;
3929
4039
  `;
3930
- var DATA_SCHEMAS_TEMPLATE = `import { z } from 'zod';
4040
+ var DATA_SCHEMAS_TEMPLATE = `import { defineHostSchema } from '@conloca/astro-cms/page-schemas';
4041
+ import typia, { type tags } from 'typia';
3931
4042
 
3932
4043
  /**
3933
4044
  * Data collection schemas for the CMS.
3934
4045
  *
3935
- * Each key is a collection name (matching folders in content/data/).
3936
- * The CMS auto-generates forms from these Zod schemas.
4046
+ * Each key is a collection name (matching folders in content/data/). Each value
4047
+ * is a TypeScript type plus what Typia generates for it at build time (wired by
4048
+ * typia-vite.mjs in astro.config.mjs): \`validate\` checks every stored entry
4049
+ * when the collection loads, and \`metadata\` is the JSON Schema the CMS renders
4050
+ * the entry form from.
3937
4051
  *
3938
4052
  * Tips:
3939
- * - Use .describe() to add labels/hints shown in the form
3940
- * - Use .optional() for non-required fields
3941
- * - Supported types: string, number, boolean, date, email, url, arrays
4053
+ * - A JSDoc comment on a field becomes its help text in the form
4054
+ * - Optional properties (\`?\`) are optional fields
4055
+ * - Supported controls: string, number, boolean, date (\`string & tags.Format<'date-time'>\`),
4056
+ * email / url (\`tags.Format\`), string literal unions (select), arrays
3942
4057
  */
4058
+
4059
+ /** Authors collection - blog post authors, team members, etc. */
4060
+ export interface Author {
4061
+ /** Full name */
4062
+ name: string;
4063
+ /** Short biography */
4064
+ bio: string;
4065
+ /** Profile image URL */
4066
+ avatar?: string & tags.Format<'url'>;
4067
+ /** Twitter handle (e.g., @username) */
4068
+ twitter?: string;
4069
+ /** Contact email */
4070
+ email?: string & tags.Format<'email'>;
4071
+ }
4072
+
4073
+ /** Settings collection - site configuration, feature flags, etc. */
4074
+ export interface Settings {
4075
+ /** Site name */
4076
+ siteName?: string;
4077
+ /** Contact email address */
4078
+ contactEmail?: string & tags.Format<'email'>;
4079
+ }
4080
+
3943
4081
  export const dataSchemas = {
3944
- /**
3945
- * Authors collection - blog post authors, team members, etc.
3946
- */
3947
- authors: z.object({
3948
- name: z.string().describe('Full name'),
3949
- bio: z.string().describe('Short biography'),
3950
- avatar: z.string().url().optional().describe('Profile image URL'),
3951
- twitter: z.string().optional().describe('Twitter handle (e.g., @username)'),
3952
- email: z.string().email().optional().describe('Contact email'),
4082
+ authors: defineHostSchema<Author>({
4083
+ validate: typia.plain.createValidatePrune<Author>(),
4084
+ metadata: typia.json.schema<Author>(),
3953
4085
  }),
3954
-
3955
- /**
3956
- * Settings collection - site configuration, feature flags, etc.
3957
- */
3958
- settings: z.object({
3959
- siteName: z.string().optional().describe('Site name'),
3960
- contactEmail: z.string().email().optional().describe('Contact email address'),
4086
+ settings: defineHostSchema<Settings>({
4087
+ validate: typia.plain.createValidatePrune<Settings>(),
4088
+ metadata: typia.json.schema<Settings>(),
3961
4089
  }),
3962
4090
  };
3963
4091
  `;
@@ -4001,6 +4129,8 @@ async function setup(projectPath = ".", siteName = DEFAULT_SITE_NAME) {
4001
4129
  await writeIfNotExists(join8(srcDir, "components", "puck", "Grid.tsx"), GRID_TEMPLATE, "src/components/puck/Grid.tsx");
4002
4130
  await writeIfNotExists(join8(srcDir, "puck.config.tsx"), PUCK_CONFIG_TEMPLATE, "src/puck.config.tsx");
4003
4131
  await writeIfNotExists(join8(srcDir, "schemas", "data.ts"), DATA_SCHEMAS_TEMPLATE, "src/schemas/data.ts");
4132
+ await writeIfNotExists(join8(absolutePath, "typia-vite.mjs"), TYPIA_VITE_TEMPLATE, "typia-vite.mjs");
4133
+ await writeIfNotExists(join8(absolutePath, "tsconfig.typia.json"), TYPIA_TSCONFIG_TEMPLATE, "tsconfig.typia.json");
4004
4134
  await writeIfNotExists(join8(srcDir, "layouts", "Layout.astro"), PAGE_LAYOUT_TEMPLATE, "src/layouts/Layout.astro");
4005
4135
  await writeIfNotExists(join8(absolutePath, ".claude", "skills", "conloca", "SKILL.md"), conloca_skill_default, ".claude/skills/conloca/SKILL.md");
4006
4136
  const sites = await ensureSiteInSitesConfig(contentDir, siteName);
@@ -4039,6 +4169,7 @@ Next steps:`);
4039
4169
  `);
4040
4170
  console.log(` import react from '@astrojs/react';
4041
4171
  import { conlocaCMS } from '@conloca/astro-cms/node';
4172
+ import { schemaTypia } from './typia-vite.mjs';
4042
4173
 
4043
4174
  export default defineConfig({
4044
4175
  integrations: [
@@ -4050,7 +4181,11 @@ Next steps:`);
4050
4181
  layout: './src/layouts/Layout.astro',
4051
4182
  }),
4052
4183
  ],
4184
+ vite: { plugins: [...schemaTypia()] },
4053
4185
  });`);
4186
+ console.log(`
4187
+ The schemas file is generated code: add typia, and ttsc + @ttsc/unplugin as dev`);
4188
+ console.log(" dependencies, so typia-vite.mjs can compile it.");
4054
4189
  console.log("\n `layout` on its own turns on a catch-all /[...slug] route over the pages");
4055
4190
  console.log(" collection. Adding `routing` replaces that route, and the top-level `layout`");
4056
4191
  console.log(" is then ignored — name it under routing.routes.<name>.layout instead.");
@@ -4269,7 +4404,8 @@ Next steps:`);
4269
4404
  }
4270
4405
 
4271
4406
  // src/commands/page-create.ts
4272
- import { relative as relative2 } from "node:path";
4407
+ import { readFile as readFile8 } from "node:fs/promises";
4408
+ import { relative as relative2, resolve as resolve6 } from "node:path";
4273
4409
  function toCliMessage(error, directory, options) {
4274
4410
  switch (error.reason) {
4275
4411
  case "missing_leading_slash":
@@ -4280,6 +4416,15 @@ function toCliMessage(error, directory, options) {
4280
4416
  return error.message;
4281
4417
  }
4282
4418
  }
4419
+ async function undeclaredCollectionWarning(directory, collection) {
4420
+ const { findContentConfig } = await import("@conloca/astro-cms/checks");
4421
+ const configPath = findContentConfig(resolve6(directory));
4422
+ const text = configPath === null ? null : await readFile8(configPath, "utf-8").catch(() => null);
4423
+ const declared = text === null ? null : declaredPageCollections(text);
4424
+ if (configPath === null || declared === null || declared.has(collection))
4425
+ return null;
4426
+ return `${relative2(process.cwd(), configPath)} declares no page collection "${collection}", so the build fails on this page. Declare it with conlocaPages({ collection: '${collection}' }) and give it a route in conlocaCMS({ routing }).`;
4427
+ }
4283
4428
  async function pageCreate(directory, options) {
4284
4429
  try {
4285
4430
  await createPage(directory, options);
@@ -4306,13 +4451,16 @@ async function createPage(directory, options) {
4306
4451
  throw error;
4307
4452
  }
4308
4453
  const relPath = relative2(process.cwd(), written.filePath);
4454
+ const warning = await undeclaredCollectionWarning(directory, options.collection).catch(() => null);
4309
4455
  if (json) {
4310
- console.log(JSON.stringify({ ok: true, id: written.id, path: relPath }));
4311
- return;
4456
+ console.log(JSON.stringify({ ok: true, id: written.id, path: relPath, ...warning ? { warnings: [warning] } : {} }));
4457
+ } else {
4458
+ console.log(`✓ Created page ${written.pathname} (${written.id})`);
4459
+ console.log(` File: ${relPath}`);
4460
+ console.log("The page is now editable in the CMS.");
4312
4461
  }
4313
- console.log(`✓ Created page ${written.pathname} (${written.id})`);
4314
- console.log(` File: ${relPath}`);
4315
- console.log("The page is now editable in the CMS.");
4462
+ if (warning)
4463
+ console.error(`Warning: ${warning}`);
4316
4464
  }
4317
4465
 
4318
4466
  // src/cli.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conloca/cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,8 +10,8 @@
10
10
  "directory": "packages/cli"
11
11
  },
12
12
  "dependencies": {
13
- "@conloca/astro-cms": "0.2.0",
14
- "@conloca/content-api": "0.2.0"
13
+ "@conloca/astro-cms": "0.2.2",
14
+ "@conloca/content-api": "0.2.2"
15
15
  },
16
16
  "bin": {
17
17
  "conloca": "./dist/conloca.js"
@@ -50,10 +50,15 @@
50
50
  }
51
51
  },
52
52
  "build": {
53
+ "//": "The bundle inlines src/templates/conloca-skill.md. The default input excludes every Markdown file, and that exclusion wins over a file listed by name, so the project's own files are hashed in full.",
53
54
  "executor": "nx:run-commands",
54
55
  "dependsOn": [
55
56
  "^build"
56
57
  ],
58
+ "inputs": [
59
+ "{projectRoot}/**/*",
60
+ "^default"
61
+ ],
57
62
  "options": {
58
63
  "command": "bun run build.ts",
59
64
  "cwd": "{projectRoot}"
@@ -68,6 +73,7 @@
68
73
  ]
69
74
  },
70
75
  "test": {
76
+ "//": "test/skill.test.ts reads src/templates/conloca-skill.md, which the default input would exclude even when listed by name, so the project's own files are hashed in full.",
71
77
  "executor": "@smoothbricks/nx-plugin:bounded-exec",
72
78
  "dependsOn": [
73
79
  "build",
@@ -75,7 +81,7 @@
75
81
  "test-packed"
76
82
  ],
77
83
  "inputs": [
78
- "default",
84
+ "{projectRoot}/**/*",
79
85
  "^default",
80
86
  "{workspaceRoot}/example/website-with-cms/package.json",
81
87
  "{workspaceRoot}/tooling/test-setup.ts",
@@ -83,9 +89,9 @@
83
89
  "{workspaceRoot}/tooling/git-env-isolation.ts"
84
90
  ],
85
91
  "options": {
86
- "command": "bun test --timeout=30000",
92
+ "command": "bun test --timeout=0",
87
93
  "cwd": "{projectRoot}",
88
- "timeoutMs": 300000,
94
+ "idleTimeoutMs": 180000,
89
95
  "killAfterMs": 10000
90
96
  }
91
97
  },