Skip to content

The Open Standard for Generative UI

Front-load OpenUI Cloud setup in CLI (#742)

Zahle Khan0bebeeaf4868
diff --git a/docs/content/docs/agent/getting-started/quickstart.mdx b/docs/content/docs/agent/getting-started/quickstart.mdx
index d3a7640d0..7fb8f396e 100644
--- a/docs/content/docs/agent/getting-started/quickstart.mdx
+++ b/docs/content/docs/agent/getting-started/quickstart.mdx
@@ -7,7 +7,10 @@ The CLI scaffolds a complete Next.js app: a streaming chat with a sidebar, threa
## 1. Create
-Run the create command and answer the prompts. One prompt asks **OpenUI Cloud or self-hosted?** Your choice decides which backend the scaffold wires up.
+Run the create command and answer the prompts. One prompt asks you to choose your AI setup:
+**OpenUI Cloud** is the fastest setup with free hosted models, while
+**OpenAI-compatible provider** uses your own key and self-hosts the AI route in the
+generated app.
```bash tab="pnpm" tab-group="pkg"
pnpx @openuidev/cli@latest create
@@ -36,7 +39,7 @@ cd my-agent
<Tabs groupId="deploy" items={["OpenUI Cloud", "Self-hosted"]} persist>
<Tab value="OpenUI Cloud">
-The CLI will prompt you to sign in to Thesys and generate an API Key in your browser, or you can generate your own on the [Thesys console](https://console.thesys.dev/keys) and add it to `.env.local`:
+The CLI will prompt you to sign in to Thesys and create an API key in your browser, or you can generate your own on the [Thesys console](https://console.thesys.dev/keys) and add it to `.env`:
```bash
THESYS_API_KEY=sk-th-your-key-here
diff --git a/docs/content/docs/api-reference/cli.mdx b/docs/content/docs/api-reference/cli.mdx
index cea2b85b6..015a1a460 100644
--- a/docs/content/docs/api-reference/cli.mdx
+++ b/docs/content/docs/api-reference/cli.mdx
@@ -53,22 +53,28 @@ openui create [options]
**Options**
-| Flag | Description |
-| --------------------- | ------------------------------------------------------- |
-| `-n, --name <string>` | Project name (directory to create) |
-| `--skill` | Install the OpenUI agent skill for AI coding assistants |
-| `--no-skill` | Skip installing the OpenUI agent skill |
-| `--no-interactive` | Fail instead of prompting for missing input |
-
-When run interactively (default), the CLI prompts for any missing options. Pass `--no-interactive` in CI or scripted environments to surface missing required flags as errors instead.
+| Flag | Description |
+| --------------------------- | --------------------------------------------------------- |
+| `-n, --name <string>` | Project name (directory to create) |
+| `-t, --template <template>` | AI setup/template: `openui-cloud` or `openui-self-hosted` |
+| `--api-key <key>` | OpenUI Cloud API key; skips sign-in for the Cloud setup |
+| `--auth <method>` | Cloud auth method: `oauth`, `manual`, or `skip` |
+| `--skill` | Install the OpenUI agent skill for AI coding assistants |
+| `--no-skill` | Skip installing the OpenUI agent skill |
+| `--no-install` | Scaffold without running dependency installation |
+| `--no-interactive` | Fail instead of prompting for missing input |
+
+When run interactively (default), the CLI prompts for any missing options. It asks you to choose your AI setup: **OpenUI Cloud** is the fastest setup with free hosted models, while **OpenAI-compatible provider** uses your own key and self-hosts the AI route in the generated app. Pass `--no-interactive` in CI or scripted environments to surface missing required flags as errors instead.
**What it does**
-1. Copies the bundled `openui-chat` Next.js template into `<name>/`
-2. Rewrites `workspace:*` dependency versions to `latest`
-3. Auto-detects your package manager (npm, pnpm, yarn, bun)
-4. Installs dependencies
+1. Resolves the project name and AI setup
+2. Copies the selected Next.js template into `<name>/`
+3. Rewrites `workspace:*` dependency versions to `latest`
+4. Writes the relevant `.env` values, including Thesys sign-in/API-key setup for OpenUI Cloud
5. Optionally installs the [OpenUI agent skill](/docs/openui-lang/agent-skill) for AI coding assistants (e.g. Claude, Cursor, Copilot)
+6. Auto-detects your package manager (npm, pnpm, yarn, bun)
+7. Installs dependencies
The generated project includes a `generate:prompt` script that runs `openui generate` as part of `dev` and `build`.
@@ -81,12 +87,15 @@ Pass `--skill` or `--no-skill` to skip the prompt. In `--no-interactive` mode th
**Examples**
```bash
-# Interactive — prompts for project name and skill installation
+# Interactive — prompts for project name, AI setup, env setup, and skill installation
openui create
+# Select an AI setup explicitly
+openui create --name my-app --template openui-cloud
+openui create --name my-app --template openui-self-hosted
+
# Non-interactive
-openui create --name my-app
-openui create --no-interactive --name my-app
+openui create --no-interactive --name my-app --template openui-cloud --auth skip
# Explicitly install or skip the agent skill
openui create --name my-app --skill
diff --git a/packages/openui-cli/package.json b/packages/openui-cli/package.json
index 5b79fe35b..f9de9f6d1 100644
--- a/packages/openui-cli/package.json
+++ b/packages/openui-cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@openuidev/cli",
- "version": "0.1.4",
+ "version": "0.1.5",
"description": "CLI for OpenUI — scaffold generative UI chat apps and generate LLM system prompts from component libraries",
"bin": {
"openui": "dist/index.js"
diff --git a/packages/openui-cli/src/auth/mint.ts b/packages/openui-cli/src/auth/mint.ts
index bfcb90415..422cc1a3c 100644
--- a/packages/openui-cli/src/auth/mint.ts
+++ b/packages/openui-cli/src/auth/mint.ts
@@ -1,3 +1,4 @@
+import { createFunnelProps } from "../lib/create-telemetry";
import { telemetry } from "../lib/telemetry";
import { Authenticator } from "./authenticator";
@@ -15,7 +16,10 @@ export type ResolvedAuthMethod = CloudAuthMethod | "apikey-flag";
/** Sign in via the browser and mint an OpenUI Cloud API key for the user's org. */
export async function mintCloudApiKey(projectName: string): Promise<string> {
const auth = new Authenticator({ issuerUrl: THESYS_ISSUER_URL, clientId: THESYS_CLIENT_ID });
- telemetry.capture("cli_cloud_oidc_started");
+ telemetry.capture("cli_cloud_oidc_started", {
+ ...createFunnelProps("cloud_auth_started"),
+ auth_method: "oauth",
+ });
await auth.initialize();
const { accessToken, userInfo } = await auth.authenticate();
diff --git a/packages/openui-cli/src/commands/create-app.ts b/packages/openui-cli/src/commands/create-app.ts
index bc9e1bc13..c9c5a09df 100644
--- a/packages/openui-cli/src/commands/create-app.ts
+++ b/packages/openui-cli/src/commands/create-app.ts
@@ -3,25 +3,14 @@ import * as fs from "node:fs";
import * as os from "node:os";
import * as path from "node:path";
-import { resolveCloudApiKey, THESYS_KEYS_URL, type CloudAuthMethod } from "../auth/mint";
+import { resolveCloudApiKey, THESYS_KEYS_URL } from "../auth/mint";
+import { aiSetupFromTemplate, createFunnelProps } from "../lib/create-telemetry";
+import type { CreateAppOptions, EnvResult, TemplateName } from "../lib/create-types";
import { resolveInstallPackageManager } from "../lib/detect-package-manager";
import { runSkillInstall, shouldInstallSkill } from "../lib/install-skill";
import { resolveArgs } from "../lib/resolve-args";
import { CreateError, telemetry } from "../lib/telemetry";
-export type TemplateName = "openui-self-hosted" | "openui-cloud";
-
-export interface CreateAppOptions {
- name?: string;
- template?: TemplateName;
- skill?: boolean;
- noInteractive?: boolean;
- noInstall?: boolean;
- // cloud-only
- apiKey?: string;
- auth?: CloudAuthMethod;
-}
-
function shouldCopyTemplatePath(templateDir: string, src: string): boolean {
const rel = path.relative(templateDir, src);
if (!rel) return true;
@@ -30,10 +19,55 @@ function shouldCopyTemplatePath(templateDir: string, src: string): boolean {
return !["node_modules", ".next", ".turbo", "dist"].includes(top);
}
+function rewritePackageJson(projectDir: string, name: string) {
+ // package.json: set the project name and de-vendor monorepo-local deps
+ // (workspace:* / file: / catalog:) to the published "latest". link: deps are
+ // rewritten to an absolute file: path so locally-linked packages (e.g.
+ // @openuidev/thesys) keep resolving against the developer's checkout under any
+ // package manager — npm rejects link:, and ~ isn't expanded. Temporary, until
+ // these packages are published.
+ const pkgPath = path.join(projectDir, "package.json");
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as {
+ name: string;
+ dependencies?: Record<string, string>;
+ devDependencies?: Record<string, string>;
+ };
+ pkg.name = name;
+ for (const section of ["dependencies", "devDependencies"] as const) {
+ const deps = pkg[section];
+ if (!deps) continue;
+ for (const key of Object.keys(deps)) {
+ const v = deps[key];
+ if (!v) continue;
+ if (v.startsWith("link:")) {
+ const target = v.slice("link:".length);
+ const abs = target.startsWith("~")
+ ? path.join(os.homedir(), target.slice(1))
+ : path.resolve(target);
+ deps[key] = `file:${abs}`;
+ continue;
+ }
+ // workspace:/file:/catalog: are monorepo-only protocols npm/yarn/bun
+ // can't resolve standalone — pin them to the published "latest".
+ if (/^(workspace:|file:|catalog:)/.test(v)) deps[key] = "latest";
+ }
+ }
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
+}
+
export async function runCreateApp(options: CreateAppOptions): Promise<void> {
const interactive = !options.noInteractive;
const t0 = Date.now();
- telemetry.register({ is_interactive: interactive });
+ telemetry.register({ interactive });
+ telemetry.capture("cli_create_started", {
+ ...createFunnelProps("create_started"),
+ interactive,
+ has_name_arg: Boolean(options.name),
+ has_template_arg: Boolean(options.template),
+ has_api_key_arg: Boolean(options.apiKey),
+ has_auth_arg: Boolean(options.auth),
+ no_install: Boolean(options.noInstall),
+ });
const args = await resolveArgs(
{
@@ -45,15 +79,15 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
: {
prompt: {
type: "select",
- message: "Which template?",
+ message: "Choose your AI setup",
choices: [
{
value: "openui-cloud",
- name: "OpenUI Cloud — managed conversations, artifacts & streaming",
+ name: "OpenUI Cloud — fastest setup with free hosted models (recommended)",
},
{
value: "openui-self-hosted",
- name: "OpenUI Self Hosted — starter setup with OpenAI SDK",
+ name: "OpenAI-compatible provider — use your own key and self-host the AI route",
},
],
},
@@ -64,9 +98,13 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
);
const { name, template } = args as { name: string; template: TemplateName };
- telemetry.register({ template });
- telemetry.capture("cli_create_started", { interactive });
- telemetry.capture("cli_template_selected", { template });
+ const aiSetup = aiSetupFromTemplate(template);
+ telemetry.register({ template, ai_setup: aiSetup });
+ telemetry.capture("cli_ai_setup_selected", {
+ ...createFunnelProps("ai_setup_selected"),
+ template,
+ ai_setup: aiSetup,
+ });
const targetDir = path.resolve(process.cwd(), name);
if (fs.existsSync(targetDir)) {
@@ -74,7 +112,6 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
}
const packageManager = resolveInstallPackageManager();
- telemetry.register({ package_manager: packageManager.name });
const templateDir = path.join(__dirname, "..", "templates", template);
if (!fs.existsSync(templateDir)) {
throw new CreateError(
@@ -83,100 +120,156 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
);
}
+ const captureScaffoldFailed = () => {
+ telemetry.capture("cli_scaffold_failed", {
+ ...createFunnelProps("scaffold_failed"),
+ template,
+ ai_setup: aiSetup,
+ });
+ };
+
+ telemetry.capture("cli_env_resolution_started", {
+ ...createFunnelProps("env_resolution_started"),
+ template,
+ ai_setup: aiSetup,
+ });
+ const envResult =
+ template === "openui-self-hosted"
+ ? await resolveChatEnv(interactive)
+ : await resolveCloudEnv(name, options, interactive);
+
console.info(`\nScaffolding ${template} into "${name}"...\n`);
- fs.cpSync(templateDir, targetDir, {
- recursive: true,
- filter: (src) => shouldCopyTemplatePath(templateDir, src),
+ telemetry.capture("cli_scaffold_started", {
+ ...createFunnelProps("scaffold_started"),
+ template,
+ ai_setup: aiSetup,
+ });
+ try {
+ fs.cpSync(templateDir, targetDir, {
+ recursive: true,
+ filter: (src) => shouldCopyTemplatePath(templateDir, src),
+ });
+ rewritePackageJson(targetDir, name);
+ } catch (err) {
+ captureScaffoldFailed();
+ throw err;
+ }
+ telemetry.capture("cli_scaffold_succeeded", {
+ ...createFunnelProps("scaffold_succeeded"),
+ template,
+ ai_setup: aiSetup,
});
- // package.json: set the project name and de-vendor monorepo-local deps
- // (workspace:* / file: / catalog:) to the published "latest". link: deps are
- // rewritten to an absolute file: path so locally-linked packages (e.g.
- // @openuidev/thesys) keep resolving against the developer's checkout under any
- // package manager — npm rejects link:, and ~ isn't expanded. Temporary, until
- // these packages are published.
- const pkgPath = path.join(targetDir, "package.json");
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as {
- name: string;
- dependencies?: Record<string, string>;
- devDependencies?: Record<string, string>;
- };
- pkg.name = name;
- for (const section of ["dependencies", "devDependencies"] as const) {
- const deps = pkg[section];
- if (!deps) continue;
- for (const key of Object.keys(deps)) {
- const v = deps[key];
- if (!v) continue;
- if (v.startsWith("link:")) {
- const target = v.slice("link:".length);
- const abs = target.startsWith("~")
- ? path.join(os.homedir(), target.slice(1))
- : path.resolve(target);
- deps[key] = `file:${abs}`;
- continue;
- }
- // workspace:/file:/catalog: are monorepo-only protocols npm/yarn/bun
- // can't resolve standalone — pin them to the published "latest".
- if (/^(workspace:|file:|catalog:)/.test(v)) deps[key] = "latest";
- }
+ await writeEnv(targetDir, envResult);
+ telemetry.capture("cli_env_resolved", {
+ ...createFunnelProps("env_written"),
+ template,
+ ai_setup: aiSetup,
+ env_written: envResult.envWritten,
+ auth_method: envResult.authMethod,
+ auth_succeeded: envResult.authSucceeded,
+ });
+
+ const installSkill = await shouldInstallSkill(options.skill, interactive);
+ telemetry.capture("cli_skill_installed", {
+ ...createFunnelProps("skill_prompt_resolved"),
+ skill_installed: installSkill,
+ });
+ if (installSkill) {
+ telemetry.capture("cli_skill_install_started", {
+ ...createFunnelProps("skill_install_started"),
+ skill_installed: installSkill,
+ });
+ runSkillInstall(targetDir);
+ telemetry.capture("cli_skill_install_finished", {
+ ...createFunnelProps("skill_install_finished"),
+ skill_installed: installSkill,
+ });
}
- fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
const installCmd = packageManager.installCmd;
+ let dependencyInstalled = false;
if (options.noInstall) {
console.info(`Skipping dependency install (--no-install). Run \`${installCmd}\` later.\n`);
} else {
console.info(`Installing dependencies with: ${installCmd}\n`);
+ telemetry.capture("cli_dependency_install_started", {
+ ...createFunnelProps("dependency_install_started"),
+ template,
+ ai_setup: aiSetup,
+ });
try {
execSync(installCmd, { stdio: "inherit", cwd: targetDir });
+ dependencyInstalled = true;
+ telemetry.capture("cli_dependency_install_succeeded", {
+ ...createFunnelProps("dependency_install_succeeded"),
+ template,
+ ai_setup: aiSetup,
+ dependency_installed: dependencyInstalled,
+ });
} catch {
+ telemetry.capture("cli_dependency_install_failed", {
+ ...createFunnelProps("dependency_install_failed"),
+ template,
+ ai_setup: aiSetup,
+ dependency_installed: dependencyInstalled,
+ });
throw new CreateError("install_deps", "dependency install failed");
}
}
- const installSkill = await shouldInstallSkill(options.skill, interactive);
- telemetry.capture("cli_skill_installed", { installed: installSkill });
- if (installSkill) runSkillInstall(targetDir);
-
- const envWritten =
- template === "openui-self-hosted"
- ? await writeChatEnv(targetDir, interactive)
- : await writeCloudEnv(targetDir, name, options, interactive);
-
const devCmd = packageManager.runCmd;
telemetry.capture("cli_create_succeeded", {
+ ...createFunnelProps("create_succeeded"),
template,
+ ai_setup: aiSetup,
duration_ms: Date.now() - t0,
skill_installed: installSkill,
- env_written: envWritten,
+ env_written: envResult.envWritten,
+ dependency_installed: dependencyInstalled,
});
console.info(
- getStartedMessage({ name, devCmd, template, skillInstalled: installSkill, envWritten }),
+ getStartedMessage({
+ name,
+ devCmd,
+ template,
+ skillInstalled: installSkill,
+ envWritten: envResult.envWritten,
+ }),
);
}
-async function writeChatEnv(targetDir: string, interactive: boolean): Promise<boolean> {
- if (!interactive) return false;
+async function writeEnv(targetDir: string, result: EnvResult): Promise<void> {
+ if (!result.envContent) return;
+ await fs.promises.writeFile(path.join(targetDir, ".env"), result.envContent);
+}
+
+async function resolveChatEnv(interactive: boolean): Promise<EnvResult> {
+ if (!interactive) return { envWritten: false };
const { input } = await import("@inquirer/prompts");
const apiKey = (
- await input({ message: "Enter your OpenAI API key (leave blank to skip):" })
+ await input({
+ message: "Enter your OpenAI-compatible provider API key (leave blank to skip):",
+ })
).trim();
- if (!apiKey) return false;
- fs.writeFileSync(path.join(targetDir, ".env"), `OPENAI_API_KEY=${apiKey}\n`);
- return true;
+ if (!apiKey) return { envWritten: false };
+ return { envWritten: true, envContent: `OPENAI_API_KEY=${apiKey}\n` };
}
-async function writeCloudEnv(
- targetDir: string,
+async function resolveCloudEnv(
name: string,
options: CreateAppOptions,
interactive: boolean,
-): Promise<boolean> {
+): Promise<EnvResult> {
let apiKey: string | null = null;
+ let authMethod: EnvResult["authMethod"];
try {
+ telemetry.capture("cli_cloud_auth_started", {
+ ...createFunnelProps("cloud_auth_started"),
+ auth_method: options.auth ?? (options.apiKey ? "apikey-flag" : undefined),
+ });
const resolved = await resolveCloudApiKey({
apiKey: options.apiKey,
auth: options.auth,
@@ -184,18 +277,29 @@ async function writeCloudEnv(
interactive,
});
apiKey = resolved.key;
+ authMethod = resolved.method;
telemetry.capture("cli_cloud_auth_method", {
- method: resolved.method,
- succeeded: apiKey != null,
+ ...createFunnelProps("cloud_auth_resolved"),
+ auth_method: resolved.method,
+ auth_succeeded: apiKey != null,
});
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
+ telemetry.capture("cli_cloud_auth_failed", {
+ ...createFunnelProps("cloud_auth_resolved"),
+ auth_method: options.auth ?? (options.apiKey ? "apikey-flag" : undefined),
+ auth_succeeded: false,
+ });
console.error(`\n⚠ Could not obtain an API key: ${msg}`);
console.error(` Add THESYS_API_KEY to .env later (keys: ${THESYS_KEYS_URL}).\n`);
}
const lines = [`THESYS_API_KEY=${apiKey ?? ""}`, `DEMO_USER_ID=demo-user`];
- fs.writeFileSync(path.join(targetDir, ".env"), lines.join("\n") + "\n");
- return apiKey != null;
+ return {
+ envWritten: apiKey != null,
+ envContent: lines.join("\n") + "\n",
+ authMethod,
+ authSucceeded: apiKey != null,
+ };
}
function getStartedMessage(o: {
diff --git a/packages/openui-cli/src/index.ts b/packages/openui-cli/src/index.ts
index 3835c24dd..560e4e5c6 100644
--- a/packages/openui-cli/src/index.ts
+++ b/packages/openui-cli/src/index.ts
@@ -30,9 +30,9 @@ program.hook("preAction", (_thisCommand, actionCommand) => {
program
.command("create")
- .description("Scaffold a new Next.js app (OpenUI Self Hosted or OpenUI Cloud)")
+ .description("Scaffold a new Next.js app with OpenUI Cloud or your provider")
.option("-n, --name <string>", "Project name")
- .option("-t, --template <template>", "Template: openui-self-hosted | openui-cloud")
+ .option("-t, --template <template>", "AI setup: openui-cloud | openui-self-hosted")
.option("--api-key <key>", "OpenUI Cloud API key (cloud template; skips sign-in)")
.option("--auth <method>", "Cloud auth method: oauth | manual | skip")
.option("--skill", "Install the OpenUI agent skill for AI coding assistants")
diff --git a/packages/openui-cli/src/lib/create-telemetry.ts b/packages/openui-cli/src/lib/create-telemetry.ts
new file mode 100644
index 000000000..671b4aa82
--- /dev/null
+++ b/packages/openui-cli/src/lib/create-telemetry.ts
@@ -0,0 +1,40 @@
+import type { AiSetup, TemplateName } from "./create-types";
+
+const createFunnel = {
+ funnel: "cli_create",
+ funnel_version: "frontloaded_cloud_setup_v1",
+} as const;
+
+const createFunnelSteps = {
+ create_started: "0100",
+ ai_setup_selected: "0200",
+ scaffold_started: "0300",
+ scaffold_succeeded: "0310",
+ scaffold_failed: "0320",
+ env_resolution_started: "0400",
+ cloud_auth_started: "0410",
+ cloud_auth_resolved: "0420",
+ env_written: "0430",
+ skill_prompt_resolved: "0500",
+ skill_install_started: "0510",
+ skill_install_finished: "0520",
+ dependency_install_started: "0600",
+ dependency_install_succeeded: "0610",
+ dependency_install_failed: "0620",
+ create_succeeded: "0700",
+ create_failed: "9000",
+} as const;
+
+type CreateFunnelStep = keyof typeof createFunnelSteps;
+
+export function createFunnelProps(stepKey: CreateFunnelStep): Record<string, string> {
+ return {
+ ...createFunnel,
+ step_rank: createFunnelSteps[stepKey],
+ step_key: stepKey,
+ };
+}
+
+export function aiSetupFromTemplate(template: TemplateName): AiSetup {
+ return template === "openui-cloud" ? "openui_cloud" : "openai_compatible_provider";
+}
diff --git a/packages/openui-cli/src/lib/create-types.ts b/packages/openui-cli/src/lib/create-types.ts
new file mode 100644
index 000000000..4f57050b5
--- /dev/null
+++ b/packages/openui-cli/src/lib/create-types.ts
@@ -0,0 +1,22 @@
+import type { CloudAuthMethod, ResolvedAuthMethod } from "../auth/mint";
+
+export type TemplateName = "openui-self-hosted" | "openui-cloud";
+
+export interface CreateAppOptions {
+ name?: string;
+ template?: TemplateName;
+ skill?: boolean;
+ noInteractive?: boolean;
+ noInstall?: boolean;
+ apiKey?: string;
+ auth?: CloudAuthMethod;
+}
+
+export type AiSetup = "openui_cloud" | "openai_compatible_provider";
+
+export type EnvResult = {
+ envWritten: boolean;
+ envContent?: string;
+ authMethod?: ResolvedAuthMethod;
+ authSucceeded?: boolean;
+};
diff --git a/packages/openui-cli/src/lib/resolve-args.ts b/packages/openui-cli/src/lib/resolve-args.ts
index 8a7c28297..00fe8b5b7 100644
--- a/packages/openui-cli/src/lib/resolve-args.ts
+++ b/packages/openui-cli/src/lib/resolve-args.ts
@@ -1,3 +1,5 @@
+import { CreateError } from "./telemetry";
+
type InputPromptConfig = {
type: "input";
message: string;
@@ -39,8 +41,7 @@ export async function resolveArgs<T extends Record<string, ArgDef<unknown>>>(
}
if (!interactive) {
- console.error(`Error: Missing required argument --${key}`);
- process.exit(1);
+ throw new CreateError("missing_required_arg", `Missing required argument --${key}`);
}
try {
diff --git a/packages/openui-cli/src/lib/utils.ts b/packages/openui-cli/src/lib/utils.ts
index 17b4a2528..50e7b880f 100644
--- a/packages/openui-cli/src/lib/utils.ts
+++ b/packages/openui-cli/src/lib/utils.ts
@@ -1,14 +1,26 @@
-import { CloudAuthMethod } from "../auth/mint";
-import { TemplateName } from "../commands/create-app";
-import { CreateError, Telemetry } from "./telemetry";
+import type { CloudAuthMethod } from "../auth/mint";
+import { createFunnelProps } from "./create-telemetry";
+import type { TemplateName } from "./create-types";
+import { CreateError, telemetry as defaultTelemetry, type Telemetry } from "./telemetry";
-export function handleCliError(e: unknown, event: string, telemetry?: Telemetry): void {
+export function handleCliError(
+ e: unknown,
+ event: string,
+ telemetry: Telemetry = defaultTelemetry,
+): void {
const known = e instanceof CreateError;
const message = e instanceof Error ? e.message : String(e);
console.error(known ? `Error: ${message}` : message);
- if (telemetry) {
- telemetry.capture(event, { stage: known ? e.stage : "unknown", error: message.slice(0, 200) });
+ if (event === "cli_create_failed") {
+ // Do not send raw create error messages: they can include user-entered
+ // project names or paths. The funnel rank is enough to count this drop-off.
+ telemetry.capture(event, createFunnelProps("create_failed"));
+ } else {
+ telemetry.capture(event, {
+ stage: known ? e.stage : "unknown",
+ error: message.slice(0, 200),
+ });
}
process.exitCode = 1;