@camox/cli 0.41.1 → 0.43.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camox/cli",
3
- "version": "0.41.1",
3
+ "version": "0.43.0",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "camox": "./dist/index.mjs"
@@ -31,7 +31,7 @@
31
31
  "@types/node": "^24.12.4",
32
32
  "@typescript/native-preview": "7.0.0-dev.20260412.1",
33
33
  "vite-plus": "^0.1.21",
34
- "@camox/api-contract": "0.41.1"
34
+ "@camox/api-contract": "0.43.0"
35
35
  },
36
36
  "nx": {
37
37
  "tags": [
@@ -42,6 +42,7 @@
42
42
  "build": "node scripts/sync-templates.mjs && vp pack",
43
43
  "dev": "node scripts/sync-templates.mjs --watch --build",
44
44
  "lint": "vp lint",
45
+ "test": "vp pack && node --test test/*.test.mjs",
45
46
  "check": "tsgo --noEmit && vp lint --fix"
46
47
  }
47
48
  }
@@ -8,6 +8,7 @@
8
8
  "dev": "vp dev --port 7400",
9
9
  "start": "node .output/server/index.mjs",
10
10
  "build": "vp build",
11
+ "test:production": "node scripts/production-smoke.mjs",
11
12
  "release": "camox release",
12
13
  "serve": "vp preview",
13
14
  "lint": "vp lint",
@@ -0,0 +1,35 @@
1
+ # Production runtime smoke test
2
+
3
+ From the repository root:
4
+
5
+ ```sh
6
+ pnpm exec nx run camox:build
7
+ pnpm --filter @camox/template-default test:production
8
+ ```
9
+
10
+ The test builds a temporary copy of the starter using Nitro's Node middleware
11
+ preset, moves only `.output` into an isolated deployment, removes build-time
12
+ `node_modules` links, and serves a real HTTP request. It asserts that React/Base UI
13
+ can render HTML and Camox's OG renderer can produce a PNG. No Camox API, real auth,
14
+ application-level dependency tracing overrides, or direct Takumi dependency is
15
+ needed. A temporary home directory supplies fake build authentication without
16
+ modifying the developer's credentials. CI runs this test after building the SDK.
17
+
18
+ ## Issue #106 investigation
19
+
20
+ - **Takumi:** the original `createRequire(import.meta.url).resolve(...)` survives
21
+ bundling, but the WASM package/asset is absent from the deployment. The isolated
22
+ smoke test reproduced `Cannot find module '@takumi-rs/wasm/takumi_wasm_bg.wasm'`
23
+ before the fix. Camox now uses a static module import so Nitro's WASM loader
24
+ owns asset inclusion, including when dependencies are fully bundled. The
25
+ server-only guard in `createLayout` prevents this import reaching client builds.
26
+ - **tslib:** a package containing only `package.json` and `tslib.es6.mjs`, as
27
+ reported, reproduces Node's missing `tslib/modules/index.js` error: Node selects
28
+ that entry from the package exports. The complete upstream package is valid;
29
+ the partial traced copy is not. The current starter build did not independently
30
+ reproduce that partial copy. Camox now adds `tslib` to Nitro's `noExternals`,
31
+ keeping its existing ESM alias and removing reliance on partial package tracing.
32
+ Plugin tests cover preservation of user options, including `noExternals: true`.
33
+
34
+ These are SDK integration fixes, not starter workarounds. Applications should not
35
+ need to add Takumi as a direct dependency or configure `traceDeps`/`noExternals`.
@@ -0,0 +1,124 @@
1
+ import assert from "node:assert/strict";
2
+ import { spawnSync } from "node:child_process";
3
+ import { cp, mkdir, mkdtemp, readFile, rm, symlink, writeFile } from "node:fs/promises";
4
+ import { createRequire } from "node:module";
5
+ import { tmpdir } from "node:os";
6
+ import { dirname, join, resolve } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const appRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
10
+ const temp = await mkdtemp(join(tmpdir(), "camox-production-"));
11
+
12
+ try {
13
+ const root = join(temp, "app");
14
+ const home = join(temp, "home");
15
+ await mkdir(join(home, ".camox"), { recursive: true });
16
+ await writeFile(
17
+ join(home, ".camox/auth.json"),
18
+ JSON.stringify({
19
+ "http://localhost:3274": { token: "smoke", name: "Smoke", email: "smoke@example.com" },
20
+ }),
21
+ );
22
+ await mkdir(root);
23
+ await mkdir(join(temp, "node_modules"));
24
+ // Nitro resolves its builder from the project root. Match Vite+'s own Vite
25
+ // dependency without relying on workspace hoisting in this temporary app.
26
+ const vitePackage = createRequire(import.meta.resolve("vite-plus")).resolve("vite/package.json");
27
+ await symlink(dirname(vitePackage), join(temp, "node_modules/vite"), "dir");
28
+ for (const file of ["src", "vite.config.ts", "tsconfig.json", "package.json"]) {
29
+ await cp(join(appRoot, file), join(root, file), { recursive: true });
30
+ }
31
+ await symlink(join(appRoot, "node_modules"), join(root, "node_modules"), "dir");
32
+ const configPath = join(root, "vite.config.ts");
33
+ await writeFile(
34
+ configPath,
35
+ (await readFile(configPath, "utf8")).replace(
36
+ "nitro()",
37
+ 'nitro({ routes: { "/smoke": "./routes/smoke.ts" } })',
38
+ ),
39
+ );
40
+ await mkdir(join(root, "routes"), { recursive: true });
41
+ await writeFile(
42
+ join(root, "routes/smoke.ts"),
43
+ `import { Dialog } from "@base-ui/react/dialog";
44
+ import { createElement } from "react";
45
+ import { renderToStaticMarkup } from "react-dom/server";
46
+ import { ImageResponse } from "camox/_internal/imageResponse";
47
+
48
+ export default async () => {
49
+ const element = createElement("div", { style: { color: "black", background: "white" } }, "Production smoke");
50
+ const image = new ImageResponse(element, { width: 320, height: 160 });
51
+ const bytes = new Uint8Array(await image.arrayBuffer());
52
+ const html = renderToStaticMarkup(createElement(Dialog.Root, null,
53
+ createElement(Dialog.Trigger, null, "Production smoke")));
54
+ return Response.json({ html, png: Array.from(bytes.slice(0, 8)) });
55
+ };
56
+ `,
57
+ );
58
+ const build = spawnSync(
59
+ process.execPath,
60
+ [
61
+ "--input-type=module",
62
+ "-e",
63
+ `
64
+ const { createBuilder } = await import(${JSON.stringify(import.meta.resolve("vite-plus"))});
65
+ const builder = await createBuilder({ root: ${JSON.stringify(root)} });
66
+ await builder.buildApp();
67
+ `,
68
+ ],
69
+ {
70
+ cwd: root,
71
+ env: {
72
+ ...process.env,
73
+ HOME: home,
74
+ CAMOX_INTERNAL_RELEASE: "0",
75
+ NITRO_PRESET: "node-middleware",
76
+ },
77
+ encoding: "utf8",
78
+ timeout: 180_000,
79
+ killSignal: "SIGKILL",
80
+ },
81
+ );
82
+ assert.equal(build.status, 0, `${build.stdout}\n${build.stderr}`);
83
+
84
+ // Move only the deployment artifact away from all workspace node_modules.
85
+ const deployment = join(temp, "deployment");
86
+ await cp(join(root, ".output"), deployment, { recursive: true });
87
+ await rm(root, { recursive: true, force: true });
88
+ await rm(join(temp, "node_modules"), { recursive: true, force: true });
89
+ const runtime = spawnSync(
90
+ process.execPath,
91
+ [
92
+ "--input-type=module",
93
+ "-e",
94
+ `
95
+ import assert from "node:assert/strict";
96
+ import { createServer } from "node:http";
97
+ const { middleware } = await import("./server/index.mjs");
98
+ const server = createServer(middleware);
99
+ await new Promise(resolve => server.listen(0, "127.0.0.1", resolve));
100
+ try {
101
+ const response = await fetch("http://127.0.0.1:" + server.address().port + "/smoke");
102
+ assert.equal(response.status, 200, await response.clone().text());
103
+ const result = await response.json();
104
+ assert.match(result.html, /Production smoke/);
105
+ assert.deepEqual(result.png, [137, 80, 78, 71, 13, 10, 26, 10]);
106
+ } finally {
107
+ server.closeAllConnections();
108
+ server.close();
109
+ }
110
+ `,
111
+ ],
112
+ {
113
+ cwd: deployment,
114
+ env: { ...process.env, NODE_PATH: "", NODE_ENV: "production" },
115
+ encoding: "utf8",
116
+ timeout: 30_000,
117
+ killSignal: "SIGKILL",
118
+ },
119
+ );
120
+ assert.equal(runtime.status, 0, `${runtime.stdout}\n${runtime.stderr}`);
121
+ console.log("Production server rendered HTML and a Takumi PNG from an isolated deployment.");
122
+ } finally {
123
+ await rm(temp, { recursive: true, force: true });
124
+ }
@@ -16,12 +16,12 @@ const faq = createBlock({
16
16
  items: Type.Repeater({
17
17
  content: {
18
18
  question: Type.String({
19
- default: "What is your refund policy?",
19
+ default: "How do I make this website my own?",
20
20
  title: "Question",
21
21
  }),
22
22
  answer: Type.String({
23
23
  default:
24
- "We offer a 30-day money-back guarantee. If you're not satisfied, contact support and we'll process your refund right away.",
24
+ "Tell your coding agent what you're building, who it's for, and the style you want. Your agent has access to the Camox skill and will use it to create your own blocks, update your content, and manage your pages.",
25
25
  title: "Answer",
26
26
  }),
27
27
  },
@@ -15,7 +15,7 @@ const hero = createBlock({
15
15
  title: "Title",
16
16
  }),
17
17
  description: Type.String({
18
- default: "Press ⌘+Enter to access Camox Studio and edit content.",
18
+ default: "Press ⌘+Enter to edit this page.",
19
19
  maxLength: 280,
20
20
  title: "Description",
21
21
  }),
@@ -4,8 +4,6 @@ import { block as faqBlock } from "../blocks/faq";
4
4
  import { block as footerBlock } from "../blocks/footer";
5
5
  import { block as heroBlock } from "../blocks/hero";
6
6
  import { block as navbarBlock } from "../blocks/navbar";
7
- import { block as statisticsBlock } from "../blocks/statistics";
8
- import { block as testimonialBlock } from "../blocks/testimonial";
9
7
 
10
8
  const defaultLayout = createLayout({
11
9
  id: "default",
@@ -14,7 +12,7 @@ const defaultLayout = createLayout({
14
12
  blocks: {
15
13
  before: [navbarBlock],
16
14
  after: [footerBlock],
17
- initial: [heroBlock, testimonialBlock, statisticsBlock, faqBlock],
15
+ initial: [heroBlock, faqBlock],
18
16
  },
19
17
  component: DefaultLayout,
20
18
  buildMetaTitle: ({ pageMetaTitle, projectName }) => `${pageMetaTitle} | ${projectName}`,
@@ -1,98 +0,0 @@
1
- import { Type, createBlock } from "camox/createBlock";
2
-
3
- const statistics = createBlock({
4
- id: "statistics",
5
- title: "Statistics",
6
- description:
7
- "Showcase key metrics, achievements, or performance indicators. Ideal for displaying platform statistics or company milestones.",
8
- content: {
9
- title: Type.String({
10
- default: "By the numbers",
11
- maxLength: 30,
12
- title: "Title",
13
- }),
14
- subtitle: Type.String({
15
- default: "Trusted by teams worldwide",
16
- title: "Subtitle",
17
- }),
18
- description: Type.String({
19
- default:
20
- "Our platform empowers teams to build and ship faster. Here are some numbers we're proud of.",
21
- title: "Description",
22
- }),
23
- statistics: Type.Repeater({
24
- content: {
25
- number: Type.String({
26
- default: "100+",
27
- maxLength: 7,
28
- title: "Number",
29
- }),
30
- label: Type.String({
31
- default: "projects launched",
32
- title: "Label",
33
- }),
34
- },
35
- minItems: 3,
36
- maxItems: 8,
37
- title: "Statistics",
38
- toMarkdown: (c) => [`**${c.number}** — ${c.label}`],
39
- }),
40
- },
41
- component: StatisticsComponent,
42
- toMarkdown: (c) => [`## ${c.subtitle}`, c.description, c.statistics],
43
- });
44
-
45
- function StatisticsComponent() {
46
- return (
47
- <section className="dark bg-background py-12 sm:py-16 md:py-20">
48
- <div className="container mx-auto">
49
- <div className="mb-16">
50
- <statistics.Field name="title">
51
- {(props) => (
52
- <div
53
- {...props}
54
- className="text-accent-foreground mb-4 text-sm font-semibold tracking-wider uppercase"
55
- />
56
- )}
57
- </statistics.Field>
58
- <statistics.Field name="subtitle">
59
- {(props) => (
60
- <h2 {...props} className="text-foreground mb-6 text-3xl font-bold sm:text-5xl" />
61
- )}
62
- </statistics.Field>
63
- <statistics.Field name="description">
64
- {(props) => (
65
- <p {...props} className="text-muted-foreground max-w-3xl text-lg leading-relaxed" />
66
- )}
67
- </statistics.Field>
68
- </div>
69
- <div className="grid grid-cols-1 gap-8 md:grid-cols-2 lg:grid-cols-4">
70
- <statistics.Repeater name="statistics">
71
- {(stat) => (
72
- <div className="flex gap-3">
73
- <div className="from-chart-1 to-chart-2 w-0.5 bg-linear-to-b" />
74
- <div className="flex flex-col">
75
- <stat.Field name="number">
76
- {(props) => (
77
- <div
78
- {...props}
79
- className="text-foreground mb-2 text-3xl font-bold sm:text-4xl"
80
- />
81
- )}
82
- </stat.Field>
83
- <stat.Field name="label">
84
- {(props) => (
85
- <p {...props} className="text-muted-foreground text-sm leading-relaxed" />
86
- )}
87
- </stat.Field>
88
- </div>
89
- </div>
90
- )}
91
- </statistics.Repeater>
92
- </div>
93
- </div>
94
- </section>
95
- );
96
- }
97
-
98
- export { statistics as block };
@@ -1,55 +0,0 @@
1
- import { Type, createBlock } from "camox/createBlock";
2
-
3
- const testimonial = createBlock({
4
- id: "testimonial",
5
- title: "Testimonial",
6
- description:
7
- "Display a customer testimonial or user review. Ideal for building trust and social proof.",
8
- content: {
9
- quote: Type.String({
10
- default:
11
- "This platform has transformed how we build and manage our website. The developer experience is exceptional.",
12
- title: "Quote",
13
- }),
14
- author: Type.String({ default: "Kai Doe", title: "Author" }),
15
- title: Type.String({ default: "Senior Developer", title: "Title" }),
16
- company: Type.String({ default: "E Corp", title: "Company" }),
17
- },
18
- component: TestimonialComponent,
19
- toMarkdown: (c) => [`> ${c.quote}`, `— ${c.author}, ${c.title}, ${c.company}`],
20
- });
21
-
22
- function TestimonialComponent() {
23
- return (
24
- <section className="bg-background py-12 sm:py-16 md:py-24">
25
- <div className="container mx-auto px-4">
26
- <div className="mx-auto max-w-4xl text-center">
27
- <testimonial.Field name="quote">
28
- {(props) => (
29
- <blockquote
30
- {...props}
31
- className="text-foreground mb-8 text-xl leading-relaxed font-medium sm:text-3xl"
32
- >
33
- "{props.children}"
34
- </blockquote>
35
- )}
36
- </testimonial.Field>
37
- <div className="flex flex-col items-center">
38
- <testimonial.Field name="author">
39
- {(props) => (
40
- <cite {...props} className="text-foreground text-lg font-semibold not-italic" />
41
- )}
42
- </testimonial.Field>
43
- <div className="text-muted-foreground flex flex-col sm:flex-row sm:items-center sm:gap-2">
44
- <testimonial.Field name="title">{(props) => <span {...props} />}</testimonial.Field>
45
- <span className="hidden sm:inline">&bull;</span>
46
- <testimonial.Field name="company">{(props) => <span {...props} />}</testimonial.Field>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
- </section>
52
- );
53
- }
54
-
55
- export { testimonial as block };