@conloca/cli 0.2.4 → 0.2.6

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 CHANGED
@@ -515,6 +515,11 @@ conloca astro setup
515
515
  conloca doctor
516
516
  ```
517
517
 
518
+ ttsc compiles with native TypeScript 7, and only one the site declares: a TypeScript 5 or 6 already installed (a
519
+ workspace root's) keeps the package manager from adding 7 as ttsc's peer. Add `typescript@^7.0.2`, or, keeping
520
+ TypeScript 5 or 6 as `@astrojs/check` requires, an alias:
521
+ `npm install -D typescript@^6.0.3 '@typescript/native@npm:typescript@^7.0.2'`.
522
+
518
523
  ## Development
519
524
 
520
525
  ### Building
package/dist/conloca.js CHANGED
@@ -2718,6 +2718,7 @@ export default defineConfig({
2718
2718
  }
2719
2719
  var TYPIA_VITE_TEMPLATE = `import { fileURLToPath } from 'node:url';
2720
2720
  import ttsc from '@ttsc/unplugin/vite';
2721
+ import { TtscCompiler } from 'ttsc';
2721
2722
 
2722
2723
  const project = fileURLToPath(new URL('./tsconfig.typia.json', import.meta.url));
2723
2724
 
@@ -2729,6 +2730,9 @@ const project = fileURLToPath(new URL('./tsconfig.typia.json', import.meta.url))
2729
2730
  * @returns {import('vite').Plugin[]}
2730
2731
  */
2731
2732
  export function schemaTypia() {
2733
+ // Builds ttsc's typia plugin now, before Vite runs: a first build on a cold cache takes minutes, and Astro's content
2734
+ // sync gives the module that needs it 60 s. Warm, this only checks the cache.
2735
+ new TtscCompiler({ tsconfig: project }).prepare();
2732
2736
  const plugins = ttsc({ project });
2733
2737
  return (Array.isArray(plugins) ? plugins : [plugins]).map((plugin) => {
2734
2738
  const transform = plugin.transform;
@@ -2934,12 +2938,11 @@ var THIRD_PARTY_VERSIONS = {
2934
2938
  "@vitejs/plugin-react": "^5.2.0",
2935
2939
  react: "19.2.8",
2936
2940
  "react-dom": "19.2.8",
2937
- typia: "^14.0.4",
2938
- "@astrojs/check": "^0.9.10",
2939
- "@ttsc/unplugin": "0.34.1",
2940
- ttsc: "0.34.1"
2941
+ typia: "^14.0.6",
2942
+ "@ttsc/unplugin": "0.35.0",
2943
+ ttsc: "0.35.0"
2941
2944
  };
2942
- var DEV_ONLY = new Set(["@astrojs/check", "@ttsc/unplugin", "ttsc"]);
2945
+ var DEV_ONLY = new Set(["@ttsc/unplugin", "ttsc"]);
2943
2946
  var MANIFEST_CANDIDATES = ["../package.json", "../../package.json"];
2944
2947
  async function readCliManifest() {
2945
2948
  for (const candidate of MANIFEST_CANDIDATES) {
@@ -2981,6 +2984,7 @@ function renderPackageJson(input) {
2981
2984
  for (const [name, range] of Object.entries(THIRD_PARTY_VERSIONS)) {
2982
2985
  (DEV_ONLY.has(name) ? devDependencies : dependencies)[name] = range;
2983
2986
  }
2987
+ devDependencies.typescript = "^7.0.2";
2984
2988
  const sorted = (record) => Object.fromEntries(Object.entries(record).sort(([a], [b]) => a.localeCompare(b)));
2985
2989
  return `${JSON.stringify({
2986
2990
  name: input.name,
@@ -3038,6 +3042,18 @@ ${SETUP_STEPS[pm]} - run: ${commands.frozenInstall}
3038
3042
 
3039
3043
  // src/lib/connect/data-schemas.ts
3040
3044
  var TYPIA_PACKAGES = ["@ttsc/unplugin", "ttsc", "typia"];
3045
+ var NATIVE_TYPESCRIPT = ["@typescript/native", "npm:typescript@^7.0.2"];
3046
+ var LEGACY_TYPESCRIPT = ["typescript", "^6.0.3"];
3047
+ function typescriptPackages(declared) {
3048
+ const aliases = Object.values(declared).filter((spec) => spec.startsWith("npm:typescript@"));
3049
+ if (aliases.some((spec) => !(Number(spec.match(/^npm:typescript@\D*(\d+)/)?.[1]) < 7)))
3050
+ return [];
3051
+ const spec = declared.typescript;
3052
+ const major = spec !== undefined ? Number(spec.match(/\d+/)?.[0]) : ("@astrojs/check" in declared) ? 0 : Number.NaN;
3053
+ if (major >= 7)
3054
+ return [];
3055
+ return major < 6 ? [LEGACY_TYPESCRIPT, NATIVE_TYPESCRIPT] : [NATIVE_TYPESCRIPT];
3056
+ }
3041
3057
  var CONTENT_SOURCE = "@conloca/astro-cms/node/content";
3042
3058
  async function contentConfigStep(projectDir, schemasPath) {
3043
3059
  const { findContentConfig } = await import("@conloca/astro-cms/checks");
@@ -3108,11 +3124,19 @@ async function wireDataSchemas(projectDir) {
3108
3124
  if (schemasPath === DEFAULT_SCHEMAS_PATH) {
3109
3125
  scaffold.push([schemasPath, DATA_SCHEMAS_TEMPLATE], ["typia-vite.mjs", TYPIA_VITE_TEMPLATE], ["tsconfig.typia.json", TYPIA_TSCONFIG_TEMPLATE]);
3110
3126
  const manifest = JSON.parse(await readFile2(join3(projectDir, "package.json"), "utf8").catch(() => "{}"));
3111
- const declared = isRecord(manifest) ? [manifest.dependencies, manifest.devDependencies].filter(isRecord) : [];
3112
- packages = TYPIA_PACKAGES.filter((name) => !declared.some((list) => (name in list))).map((name) => [
3113
- name,
3114
- THIRD_PARTY_VERSIONS[name]
3115
- ]);
3127
+ const declared = {};
3128
+ const lists = isRecord(manifest) ? [manifest.dependencies, manifest.devDependencies].filter(isRecord) : [];
3129
+ for (const [name, range] of lists.flatMap((list) => Object.entries(list))) {
3130
+ if (typeof range === "string")
3131
+ declared[name] = range;
3132
+ }
3133
+ packages = [
3134
+ ...TYPIA_PACKAGES.filter((name) => !(name in declared)).map((name) => [
3135
+ name,
3136
+ THIRD_PARTY_VERSIONS[name]
3137
+ ]),
3138
+ ...typescriptPackages(declared)
3139
+ ];
3116
3140
  }
3117
3141
  const files = scaffold.map(([file, after]) => ({ path: resolve3(projectDir, file), before: null, after })).filter((edit) => !existsSync3(edit.path));
3118
3142
  const edits = [...options.edits, ...content.edits, ...files];
@@ -4123,7 +4147,7 @@ import { join as join12, resolve as resolve5 } from "node:path";
4123
4147
  import { stampSkill } from "@conloca/content-api/skill-stamp";
4124
4148
 
4125
4149
  // src/templates/conloca-skill.md
4126
- 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\n`conloca <command>` in this skill means `npx @conloca/cli@<version> <command>`: use the exact version a Conloca prompt\ngave you, `@latest` when none did. Never run a different version than the prompt names.\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, Conloca pages hidden behind a `src/pages` file, static pages\nwith no Conloca pages, and siteStyles. Each problem names the broken file and the fix. It is read-only and exits 1 on\nerrors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site. An existing Astro\nsite: `conloca connect` installs the packages, wires `astro.config` and writes the site's domain for the workspace\neditor; `conloca astro setup` only scaffolds the starter files.\n\n## Upgrading Conloca\n\nTo move a site to a newer Conloca release:\n\n1. In the site's folder run `npx @conloca/cli@latest upgrade` (or the exact version a Conloca prompt gave you). It\n raises each `@conloca/*` package to the version that CLI release pins in one install, applies the changes between\n versions, refreshes this skill and runs `conloca doctor`. `--dry-run` shows the diffs and changes nothing, `--json`\n prints one object on stdout, `--project <dir>` picks the site folder.\n2. Exit `2`: it lists what a person must change first; nothing was touched. Make those changes, then run it again.\n3. Exit `1`: it failed and put `package.json`, the lockfile and every changed file back. Fix what it names, run the\n install command its message gives when `node_modules` needs it, and run it again.\n4. A `SKILL.new.md` beside a skill means that skill had local edits, so the new text was written next to it: merge it\n into the skill by hand, then delete `SKILL.new.md`.\n5. Review `git diff`, run the build, then commit and push yourself — the command never commits or pushes.\n\nNever edit `@conloca/*` versions by hand: each package has its own version, and `upgrade` moves them to the versions one\nCLI release pins.\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 — or run `conloca connect`, which writes the wiring itself.\n`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 signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...` in\n the dev-server or build terminal.\n- `conloca doctor` finds them before a build: C14 warns about every component type or prop a page stores that the Puck\n config does not declare.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Writing content from the command line\n\nNever hand-write files under `content/`, and do not reach for HTTP endpoints: these commands write what the editor\nwrites, so the result is editable at `/__cms` right away. Each takes `--json` for a machine-readable result.\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us' --content about.json\nconloca page update /about --description 'Who we are' --image /media/hero.jpg\nconloca data create site --name contact --data contact.json\nconloca data update site contact --data - < contact.json\nconloca asset add ~/Pictures/hero.jpg --alt 'Fresh bread on the counter'\n```\n\n- `page create` — a new page. `--content` takes Puck data `{ root, content, zones }` from a file or `-` (stdin), never\n inline JSON; `--description`, `--image`, `--canonical` and `--robots` fill its page settings.\n- `page update` — change an existing page, found by id or pathname; only the flags given change, and an empty value\n (`--robots ''`) clears a field.\n- `data create` / `data update` — a shared entry (contact details, a header menu): a JSON object from a file or\n `--data -`. `data update` replaces the entry's whole object: send every field, not just the changed one. Declare the\n collection's type in `src/schemas/data.ts`; the first `data create` wires the data schemas.\n- `asset add` — an image into the media folder; it prints the reference an image field stores, e.g. `/media/hero.jpg`.\n\nA layout reads a shared entry by name:\n\n```ts\nimport { getCollection } from 'astro:content';\nimport { conlocaDataEntry } from '@conloca/astro-cms/collections';\nimport { dataSchemas } from '../schemas/data';\n\nconst contact = conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'contact', 'en');\ncontact.phone; // typed by the `site` schema\n```\n\nA missing name, or one saved in several locales with none given, throws and fails the build instead of rendering empty.\n\nEntries a page's blocks list (team, testimonials) bind to the route with\n`routing.routes.<name>.dataBindings.collections`; a block's Puck `resolveData` then reads them from\n`metadata.collections.<name>`.\n\nAfter writing content, run the build: it validates every entry against its schema.\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 `src/pages` file always wins over a Conloca page at the same path, and Astro says nothing. Doctor warns when\n one hides a page; delete the file in the same change that makes the Conloca page live.\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## Converting an existing Astro page\n\nUse this when the user names existing `src/pages` routes to make editable. Convert only those routes.\n\n1. Run `conloca upgrade` (with the version your prompt gave, as defined above). Stop and report if it or\n `conloca doctor` fails: the commands below ship in that release.\n2. Run `conloca routes` and check each named route is listed. Dynamic routes (`[slug].astro`, content collection pages)\n and non-default-locale routes are out of scope and never listed.\n3. Before changing anything, run `conloca compare --reset --routes /a,/b` with exactly the routes the user named; it\n builds the site and saves a fresh baseline.\n4. Run `conloca components --json` to see the components the site already has.\n5. Port each section of the page to a React component in `src/components/puck/` whose editable text and images are\n fields. `.astro` components cannot be Puck components: port, do not reuse. Scoped `<style>` moves into a stylesheet\n listed in `siteStyles`; `<script>` and `client:` islands keep working through `withHydration()`; links stay links;\n images that become fields go into the assets folder with `conloca asset add`.\n6. Render the page through the layout the original used: point `conlocaCMS` (or a per-route layout) at it and adapt it\n to the props Conloca passes (`title`, `description`, `page`).\n7. Text from data files (like `src/data/*.ts`): per-page text goes into the page; values shared across pages go into\n data entries, moved once, on the first conversion that needs them. Every importer of those values (pages, layout,\n endpoints, browser components through props) then reads the same data entries, so there is one copy. Pages the user\n did not name may change only there, and their output must stay identical.\n8. The shared header and footer stay code in the layout. Their texts and links (menu items, footer links, contact\n details) move into a data entry the layout reads. Fragments are for prose blocks placed inside pages.\n9. Read a shared entry by a fixed name and fail the build when it is missing or duplicated:\n `conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'header', 'en').menu` throws in both cases.\n10. Write all content through the CLI: `conloca page create` / `conloca page update` (with `--content` and the metadata\n flags), `conloca data create` / `conloca data update`, `conloca asset add`. Never hand-write content files.\n11. Delete the old `.astro` file in the same change that makes the Conloca page live. A `src/pages` file always wins\n over a Conloca page at the same path, so the page cannot be seen before that; `conloca compare` is the check, not\n the browser.\n12. Run `conloca compare` again. Every route you did not convert must be identical (its linked stylesheets too); every\n converted route must keep its text, links, `<head>` tags and status; a route that became a Conloca page without\n being named fails. Fix and rerun until it passes, then run `conloca doctor`.\n13. Report every changed file, every page you were not asked to convert whose code changed, every allowed change\n `conloca compare` listed (for example island props that now carry shared values), and anything that could not be\n converted faithfully.\n\nThe workspace also has an MCP server for editing content remotely: pages, fragments and data entries on pushed branches.\nIt cannot change code, upload media or publish. Use the address the editor's prompt gives you; never guess or hardcode\none. Setup and limits: https://conloca.com/workspace-mcp/.\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";
4150
+ 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\n`conloca <command>` in this skill means `npx @conloca/cli@<version> <command>`: use the exact version a Conloca prompt\ngave you, `@latest` when none did. Never run a different version than the prompt names.\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, Conloca pages hidden behind a `src/pages` file, static pages\nwith no Conloca pages, and siteStyles. Each problem names the broken file and the fix. It is read-only and exits 1 on\nerrors; warnings alone exit 0.\n\nNew project from an empty directory? `conloca create <dir>` writes and installs the whole wired site. An existing Astro\nsite: `conloca connect` installs the packages, wires `astro.config` and writes the site's domain for the workspace\neditor; `conloca astro setup` only scaffolds the starter files.\n\n## Upgrading Conloca\n\nTo move a site to a newer Conloca release:\n\n1. In the site's folder run `npx @conloca/cli@latest upgrade` (or the exact version a Conloca prompt gave you). It\n raises each `@conloca/*` package to the version that CLI release pins in one install, applies the changes between\n versions, refreshes this skill and runs `conloca doctor`. `--dry-run` shows the diffs and changes nothing, `--json`\n prints one object on stdout, `--project <dir>` picks the site folder.\n2. Exit `2`: it lists what a person must change first; nothing was touched. Make those changes, then run it again.\n3. Exit `1`: it failed and put `package.json`, the lockfile and every changed file back. Fix what it names, run the\n install command its message gives when `node_modules` needs it, and run it again.\n4. A `SKILL.new.md` beside a skill means that skill had local edits, so the new text was written next to it: merge it\n into the skill by hand, then delete `SKILL.new.md`.\n5. Review `git diff`, run the build, then commit and push yourself — the command never commits or pushes.\n\nNever edit `@conloca/*` versions by hand: each package has its own version, and `upgrade` moves them to the versions one\nCLI release pins.\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 — or run `conloca connect`, which writes the wiring itself.\n`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\nttsc compiles with native TypeScript 7, and only one the site declares: a TypeScript 5 or 6 already installed (a\nworkspace root's) keeps the package manager from adding 7 as ttsc's peer. Add `typescript@^7.0.2`, or, keeping\nTypeScript 5 or 6 as `@astrojs/check` requires, an alias:\n`npm install -D typescript@^6.0.3 '@typescript/native@npm:typescript@^7.0.2'`.\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 signal is `[Conloca] Page references N component type(s) missing from your Puck config: ...` in\n the dev-server or build terminal.\n- `conloca doctor` finds them before a build: C14 warns about every component type or prop a page stores that the Puck\n config does not declare.\n- The editor at `/__cms` exists only on the dev server. A production build without it is not a bug.\n\n## Writing content from the command line\n\nNever hand-write files under `content/`, and do not reach for HTTP endpoints: these commands write what the editor\nwrites, so the result is editable at `/__cms` right away. Each takes `--json` for a machine-readable result.\n\n```bash\nconloca page create --site default --collection pages --pathname /about --title 'About us' --content about.json\nconloca page update /about --description 'Who we are' --image /media/hero.jpg\nconloca data create site --name contact --data contact.json\nconloca data update site contact --data - < contact.json\nconloca asset add ~/Pictures/hero.jpg --alt 'Fresh bread on the counter'\n```\n\n- `page create` — a new page. `--content` takes Puck data `{ root, content, zones }` from a file or `-` (stdin), never\n inline JSON; `--description`, `--image`, `--canonical` and `--robots` fill its page settings.\n- `page update` — change an existing page, found by id or pathname; only the flags given change, and an empty value\n (`--robots ''`) clears a field.\n- `data create` / `data update` — a shared entry (contact details, a header menu): a JSON object from a file or\n `--data -`. `data update` replaces the entry's whole object: send every field, not just the changed one. Declare the\n collection's type in `src/schemas/data.ts`; the first `data create` wires the data schemas.\n- `asset add` — an image into the media folder; it prints the reference an image field stores, e.g. `/media/hero.jpg`.\n\nA layout reads a shared entry by name:\n\n```ts\nimport { getCollection } from 'astro:content';\nimport { conlocaDataEntry } from '@conloca/astro-cms/collections';\nimport { dataSchemas } from '../schemas/data';\n\nconst contact = conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'contact', 'en');\ncontact.phone; // typed by the `site` schema\n```\n\nA missing name, or one saved in several locales with none given, throws and fails the build instead of rendering empty.\n\nEntries a page's blocks list (team, testimonials) bind to the route with\n`routing.routes.<name>.dataBindings.collections`; a block's Puck `resolveData` then reads them from\n`metadata.collections.<name>`.\n\nAfter writing content, run the build: it validates every entry against its schema.\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 `src/pages` file always wins over a Conloca page at the same path, and Astro says nothing. Doctor warns when\n one hides a page; delete the file in the same change that makes the Conloca page live.\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## Converting an existing Astro page\n\nUse this when the user names existing `src/pages` routes to make editable. Convert only those routes.\n\n1. Run `conloca upgrade` (with the version your prompt gave, as defined above). Stop and report if it or\n `conloca doctor` fails: the commands below ship in that release.\n2. Run `conloca routes` and check each named route is listed. Dynamic routes (`[slug].astro`, content collection pages)\n and non-default-locale routes are out of scope and never listed.\n3. Before changing anything, run `conloca compare --reset --routes /a,/b` with exactly the routes the user named; it\n builds the site and saves a fresh baseline.\n4. Run `conloca components --json` to see the components the site already has.\n5. Port each section of the page to a React component in `src/components/puck/` whose editable text and images are\n fields. `.astro` components cannot be Puck components: port, do not reuse. Scoped `<style>` moves into a stylesheet\n listed in `siteStyles`; `<script>` and `client:` islands keep working through `withHydration()`; links stay links;\n images that become fields go into the assets folder with `conloca asset add`.\n6. Render the page through the layout the original used: point `conlocaCMS` (or a per-route layout) at it and adapt it\n to the props Conloca passes (`title`, `description`, `page`).\n7. Text from data files (like `src/data/*.ts`): per-page text goes into the page; values shared across pages go into\n data entries, moved once, on the first conversion that needs them. Every importer of those values (pages, layout,\n endpoints, browser components through props) then reads the same data entries, so there is one copy. Pages the user\n did not name may change only there, and their output must stay identical.\n8. The shared header and footer stay code in the layout. Their texts and links (menu items, footer links, contact\n details) move into a data entry the layout reads. Fragments are for prose blocks placed inside pages.\n9. Read a shared entry by a fixed name and fail the build when it is missing or duplicated:\n `conlocaDataEntry(dataSchemas, 'site', await getCollection('site'), 'header', 'en').menu` throws in both cases.\n10. Write all content through the CLI: `conloca page create` / `conloca page update` (with `--content` and the metadata\n flags), `conloca data create` / `conloca data update`, `conloca asset add`. Never hand-write content files.\n11. Delete the old `.astro` file in the same change that makes the Conloca page live. A `src/pages` file always wins\n over a Conloca page at the same path, so the page cannot be seen before that; `conloca compare` is the check, not\n the browser.\n12. Run `conloca compare` again. Every route you did not convert must be identical (its linked stylesheets too); every\n converted route must keep its text, links, `<head>` tags and status; a route that became a Conloca page without\n being named fails. Fix and rerun until it passes, then run `conloca doctor`.\n13. Report every changed file, every page you were not asked to convert whose code changed, every allowed change\n `conloca compare` listed (for example island props that now carry shared values), and anything that could not be\n converted faithfully.\n\nThe workspace also has an MCP server for editing content remotely: pages, fragments and data entries on pushed branches.\nIt cannot change code, upload media or publish. Use the address the editor's prompt gives you; never guess or hardcode\none. Setup and limits: https://conloca.com/workspace-mcp/.\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";
4127
4151
 
4128
4152
  // src/commands/setup.ts
4129
4153
  var DEFAULT_SITE_NAME = "default";
@@ -4826,7 +4850,8 @@ Next steps:`);
4826
4850
  });`);
4827
4851
  console.log(`
4828
4852
  The schemas file is generated code: add typia, and ttsc + @ttsc/unplugin as dev`);
4829
- console.log(" dependencies, so typia-vite.mjs can compile it.");
4853
+ console.log(" dependencies, so typia-vite.mjs can compile it. ttsc needs native TypeScript 7 declared by");
4854
+ console.log(" the site: typescript@^7.0.2, or '@typescript/native@npm:typescript@^7.0.2' beside a TypeScript 6.");
4830
4855
  console.log("\n `layout` on its own turns on a catch-all /[...slug] route over the pages");
4831
4856
  console.log(" collection. Adding `routing` replaces that route, and the top-level `layout`");
4832
4857
  console.log(" is then ignored — name it under routing.routes.<name>.layout instead.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@conloca/cli",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -10,18 +10,18 @@
10
10
  "directory": "packages/cli"
11
11
  },
12
12
  "dependencies": {
13
- "@conloca/astro-cms": "0.2.4",
14
- "@conloca/content-api": "0.2.4",
13
+ "@conloca/astro-cms": "0.2.5",
14
+ "@conloca/content-api": "0.2.5",
15
15
  "diff": "^9.0.0",
16
16
  "jsonc-parser": "^3.3.1",
17
17
  "linkedom": "^0.18.13",
18
18
  "magicast": "^0.5.5"
19
19
  },
20
20
  "peerDependencies": {
21
- "@conloca/cloud-astro": "0.2.4",
22
- "@conloca/cms-spa": "0.2.4",
23
- "@conloca/content-api-client": "0.2.4",
24
- "@conloca/mdx": "0.2.4"
21
+ "@conloca/cloud-astro": "0.2.5",
22
+ "@conloca/cms-spa": "0.2.5",
23
+ "@conloca/content-api-client": "0.2.5",
24
+ "@conloca/mdx": "0.2.5"
25
25
  },
26
26
  "peerDependenciesMeta": {
27
27
  "@conloca/cloud-astro": {
@@ -50,7 +50,7 @@
50
50
  "!**/*.tsbuildinfo"
51
51
  ],
52
52
  "devDependencies": {
53
- "@conloca/cloud-astro": "0.2.4",
53
+ "@conloca/cloud-astro": "0.2.5",
54
54
  "@types/bun": "1.4.2",
55
55
  "commander": "^15.0.0",
56
56
  "sharp": "^0.35.4"