Skip to content

The Open Standard for Generative UI

Add featured examples to CLI (#1086)

AB4f7398cc1337
diff --git a/docs/content/docs/api-reference/cli.mdx b/docs/content/docs/api-reference/cli.mdx
index 6ce29b169..a7a15872f 100644
--- a/docs/content/docs/api-reference/cli.mdx
+++ b/docs/content/docs/api-reference/cli.mdx
@@ -58,6 +58,7 @@ openui create [options]
| `-n, --name <string>` | Project name (interactive default: `openui-agent`) |
| `-t, --template <template>` | AI backend: `openui-cloud` (Gateway; recommended) or `openui-self-hosted` |
| `--backend-framework <framework>` | Backend integration: `default`, `langgraph`, `vercel-ai-sdk`, or `vercel-eve` |
+| `-e, --example <example>` | Scaffold any example from the OpenUI Repository |
| `--api-key <key>` | OpenUI Gateway API key; skips sign-in for the Gateway setup |
| `--auth <method>` | Gateway auth method: `oauth` or `skip`; `manual` is deprecated |
| `--skill` | Install the OpenUI agent skill for AI coding assistants |
@@ -68,7 +69,7 @@ openui create [options]
| `--no-interactive` | Fail instead of prompting for missing input |
| `--agent-name <name>` | Declare the invoking coding-agent slug (default: `unknown`) |
-When run interactively (default), the CLI prompts for any missing options, including the backend framework, then asks whether to start the development server after installing dependencies with the detected package manager. The start prompt defaults to yes; answering no preserves the existing install-and-exit behavior and prints the `cd` and dev commands. For most prototypes and evaluations, start with **OpenUI Gateway, the recommended default**: hosted models, managed conversation history and streaming, built-in tools, and ready-to-use reports and presentations without operating the model, storage, or artifact infrastructure. Choose **self-hosted** when owning the OpenAI-compatible provider, AI route, and persistence is a requirement.
+When run interactively (default), the CLI prompts for any missing options, including the backend framework or an example, then asks whether to start the development server after installing dependencies with the detected package manager. The start prompt defaults to yes; answering no preserves the existing install-and-exit behavior and prints the `cd` and dev commands. For most prototypes and evaluations, start with **OpenUI Gateway, the recommended default**: hosted models, managed conversation history and streaming, built-in tools, and ready-to-use reports and presentations without operating the model, storage, or artifact infrastructure. Choose **self-hosted** when owning the OpenAI-compatible provider, AI route, and persistence is a requirement.
`openui-cloud` remains the CLI template identifier for the Gateway-backed setup.
@@ -78,8 +79,8 @@ In non-interactive mode, dependencies are installed without starting the long-ru
**What it does**
-1. Resolves the project name, AI setup, and backend framework
-2. Copies the selected Next.js template into `<name>/`
+1. Resolves the project name, picks a backend-framework overlay or an OpenUI example
+2. Copies the selected Next.js template or example into `<name>/`
3. Rewrites `workspace:*` dependency versions to `latest`
4. Writes the relevant `.env` values, including Thesys sign-in/API-key setup for OpenUI Gateway
5. Optionally installs the [OpenUI agent skill](/docs/mcp#install-via-the-skills-cli-recommended) for AI coding assistants (e.g. Claude, Cursor, Copilot)
@@ -101,6 +102,10 @@ For Gateway-backed LangGraph and Vercel AI SDK variants, the framework owns orch
Every framework overlay includes a `get_weather` example backed by Open-Meteo. Ask “What’s the weather in Berlin?” to verify the selected framework’s native multi-step tool loop.
+**OpenUI examples**
+
+Interactive `openui create` lists starter templates, and option to create an app from listed [OpenUI examples](https://github.com/thesysdev/openui/blob/main/examples). `--example <name>` skips both menus. `--example` cannot be combined with `--template` or `--backend-framework`. Any other folder name in the catalog works the same way.
+
**Conversation storage**
Every Gateway-backed variant uses Gateway as its durable conversation and artifact store. The browser connects directly through `useOpenuiCloudStorage()` with a short-lived frontend token. For default, LangGraph, and Vercel AI SDK routes, the `threadId` sent to `/api/chat` is the Gateway conversation ID, and each backend appends model turns to it with `conversation: threadId` and `store: true`. The Vercel AI SDK route does not create a second store. The Eve Gateway overlay keeps that Gateway thread store and maps each Gateway `threadId` to an Eve session cursor in the browser; it does not use `/api/chat`. The Gateway-backed LangGraph relay creates and deletes a temporary Agent Server thread for each run; configure a separate LangGraph checkpointer only when graph state, interrupts, or resumable runs must persist independently.
@@ -132,6 +137,11 @@ pnpx @openuidev/cli@latest create --name my-app --template openui-self-hosted --
pnpx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-ai-sdk
pnpx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-eve
+# Select an example
+pnpx @openuidev/cli@latest create --name my-app --example shadcn
+pnpx @openuidev/cli@latest create --name my-app --example mastra
+pnpx @openuidev/cli@latest create --name my-app --example vue
+
# Non-interactive
pnpx @openuidev/cli@latest create --no-interactive --name my-app --template openui-cloud --auth skip
@@ -156,6 +166,11 @@ bunx @openuidev/cli@latest create --name my-app --template openui-self-hosted --
bunx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-ai-sdk
bunx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-eve
+# Select an example
+bunx @openuidev/cli@latest create --name my-app --example shadcn
+bunx @openuidev/cli@latest create --name my-app --example mastra
+bunx @openuidev/cli@latest create --name my-app --example vue
+
# Non-interactive
bunx @openuidev/cli@latest create --no-interactive --name my-app --template openui-cloud --auth skip
@@ -180,6 +195,11 @@ yarn dlx @openuidev/cli@latest create --name my-app --template openui-self-hoste
yarn dlx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-ai-sdk
yarn dlx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-eve
+# Select an example
+yarn dlx @openuidev/cli@latest create --name my-app --example shadcn
+yarn dlx @openuidev/cli@latest create --name my-app --example mastra
+yarn dlx @openuidev/cli@latest create --name my-app --example vue
+
# Non-interactive
yarn dlx @openuidev/cli@latest create --no-interactive --name my-app --template openui-cloud --auth skip
@@ -204,6 +224,11 @@ npx @openuidev/cli@latest create --name my-app --template openui-self-hosted --b
npx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-ai-sdk
npx @openuidev/cli@latest create --name my-app --template openui-self-hosted --backend-framework vercel-eve
+# Select an example
+npx @openuidev/cli@latest create --name my-app --example shadcn
+npx @openuidev/cli@latest create --name my-app --example mastra
+npx @openuidev/cli@latest create --name my-app --example vue
+
# Non-interactive
npx @openuidev/cli@latest create --no-interactive --name my-app --template openui-cloud --auth skip
diff --git a/examples/examples.json b/examples/examples.json
index 3ffc40748..8d3b918e5 100644
--- a/examples/examples.json
+++ b/examples/examples.json
@@ -4,103 +4,103 @@
"title": "Google ADK",
"description": "A Google ADK TypeScript agent streaming OpenUI Lang to a Next.js client.",
"path": "agent-frameworks/google-adk",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "LangGraph Platform",
"description": "A DeepAgents graph on LangGraph Platform, streamed to OpenUI through the LangChain adapter.",
"path": "agent-frameworks/langgraph-platform",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Mastra",
"description": "A Mastra agent connected to OpenUI through AG-UI.",
"path": "agent-frameworks/mastra",
- "featured": true
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Vercel AI SDK",
"description": "AgentInterface over a Vercel AI SDK streamText backend.",
"path": "agent-frameworks/vercel-ai-sdk",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Vercel Eve",
"description": "An Eve agent rendered through Agent Interface.",
"path": "agent-frameworks/vercel-eve",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "FastAPI",
"description": "A Python FastAPI streaming backend with a React OpenUI client.",
"path": "app-frameworks/fastapi",
- "featured": true
+ "envKey": "THESYS_API_KEY"
},
{
"title": "React Native",
"description": "An Expo client rendering native OpenUI components from a Next.js backend stream.",
"path": "app-frameworks/react-native",
- "featured": true
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Svelte",
"description": "OpenUI Lang parsing and rendering in SvelteKit.",
"path": "app-frameworks/svelte",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Vue",
"description": "OpenUI Lang parsing and rendering in Nuxt and Vue.",
"path": "app-frameworks/vue",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Material UI",
"description": "A broad Material UI component library for generated interfaces.",
"path": "design-systems/material-ui",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "shadcn/ui",
"description": "A broad shadcn/ui component library for generated interfaces.",
"path": "design-systems/shadcn",
- "featured": true
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Grok Build",
"description": "Grok Build coding sessions rendered with OpenUI Cloud.",
"path": "harnesses/grok-build",
- "featured": false
+ "envKey": "XAI_API_KEY"
},
{
"title": "Pi",
"description": "A Pi coding-agent session on OpenUI Cloud.",
"path": "harnesses/pi",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Handsontable",
"description": "Generated spreadsheet interfaces backed by Handsontable.",
"path": "miscellaneous/handsontable",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "HTML artifact",
"description": "Sandboxed HTML artifacts as an OpenUI capability.",
"path": "miscellaneous/html-artifact",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "React Email",
"description": "Generating and previewing emails with the OpenUI React Email library.",
"path": "miscellaneous/react-email",
- "featured": false
+ "envKey": "THESYS_API_KEY"
},
{
"title": "Supabase",
"description": "Persisted OpenUI conversations and threads with Supabase.",
"path": "miscellaneous/supabase",
- "featured": false
+ "envKey": "THESYS_API_KEY"
}
]
}
diff --git a/packages/openui-cli/README.md b/packages/openui-cli/README.md
index 2d6231a57..7e26672ee 100644
--- a/packages/openui-cli/README.md
+++ b/packages/openui-cli/README.md
@@ -13,6 +13,7 @@ It currently supports:
- **OpenUI Cloud (recommended)** — hosted models with managed conversations, streaming, built-in tools, and ready-to-use report and presentation artifacts
- **Self-hosted** — bring an OpenAI-compatible model key and own the AI route and persistence
- keeping the default minimal SDK route or adding a LangGraph, Vercel AI SDK, or Vercel Eve backend to either template
+- scaffolding an example from [OpenUI Examples](https://github.com/thesysdev/openui/blob/main/examples)
- minting an OpenUI Cloud API key into an existing project's env file
- generating a system prompt or JSON Schema from a `createLibrary()` export
- deploying a project with `openui deploy`
@@ -51,6 +52,8 @@ npx @openuidev/cli@latest create --template openui-cloud --backend-framework ver
npx @openuidev/cli@latest create --template openui-self-hosted --backend-framework langgraph
npx @openuidev/cli@latest create --template openui-self-hosted --backend-framework vercel-ai-sdk
npx @openuidev/cli@latest create --template openui-self-hosted --backend-framework vercel-eve
+npx @openuidev/cli@latest create --example shadcn
+npx @openuidev/cli@latest create --example mastra
```
Mint an OpenUI Cloud API key into the current project's `.env`:
@@ -94,6 +97,7 @@ Options:
- `-n, --name <string>`: Project name (interactive default: `openui-agent`)
- `-t, --template <template>`: AI backend — `openui-cloud` (managed) or `openui-self-hosted` (bring your provider)
- `--backend-framework <framework>`: API route implementation — `default`, `langgraph`, `vercel-ai-sdk`, or `vercel-eve`
+- `-e, --example <example>`: Scaffold any example from `examples/examples.json`
- `--skill`: Install the OpenUI agent skill for AI coding assistants
- `--no-skill`: Skip installing the OpenUI agent skill
- `--no-install`: Scaffold without running the package install
@@ -110,8 +114,8 @@ What it does:
- prompts for the project name, defaulting to `openui-agent`, if you do not pass `--name`
- uses the `openui-cloud` template when you do not pass `--template` (interactive runs no longer ask; `--template openui-self-hosted` still works)
-- prompts for a backend framework after the template; non-interactive usage defaults to `default`
-- copies the bundled template into a new directory
+- prompts for a backend framework or example after the template; non-interactive usage defaults to `default`
+- copies the bundled template or example into a new directory
- rewrites monorepo-local dependencies (`workspace:`, `file:`, `catalog:`) in the generated `package.json` to `latest`
- installs dependencies automatically using the detected package manager (unless `--no-install`)
- in interactive sessions, starts the development server and opens its local URL in the default browser; pass `--no-immediate` to install and exit instead
@@ -143,6 +147,16 @@ The Cloud graph needs `THESYS_API_KEY`; the self-hosted graph needs the selected
Every framework overlay includes `get_weather` as its example app-owned function tool. Ask “What’s the weather in Berlin?” to exercise the selected backend’s native tool loop.
+#### OpenUI examples
+
+Interactive `openui create` offers to scaffold [OpenUI examples](https://github.com/thesysdev/openui/blob/main/examples). Pass `--example <name>` to skip the menus. `--example` cannot be combined with `--template` or `--backend-framework`.
+
+```bash
+openui create --example shadcn
+openui create --name my-mastra-app --example mastra
+openui create --example vue
+```
+
#### Conversation storage
Every OpenUI Cloud variant uses OpenUI Cloud as its only durable conversation and artifact store. The browser connects directly through `useOpenuiCloudStorage()` with a short-lived frontend token, and `/api/chat` appends each turn to the same Cloud conversation with `conversation: threadId` and `store: true`. Vercel does not add a second store. Configure a LangGraph checkpointer separately only when the graph itself needs durable state, interrupts, or resumable runs.
@@ -172,6 +186,7 @@ openui create --name my-app --template openui-cloud --auth oauth
openui create --name my-app --template openui-cloud --backend-framework langgraph --auth oauth
openui create --name my-app --template openui-cloud --backend-framework vercel-ai-sdk --auth oauth
openui create --name my-app --template openui-cloud --backend-framework vercel-eve --auth oauth
+openui create --name my-shadcn-app --example shadcn
openui create --name my-app --template openui-cloud --api-key tk_your_key
openui create --name my-app --template openui-self-hosted
openui create --name my-app --template openui-cloud --immediate
diff --git a/packages/openui-cli/src/commands/create-app.ts b/packages/openui-cli/src/commands/create-app.ts
index 812f7db62..e42a6c026 100644
--- a/packages/openui-cli/src/commands/create-app.ts
+++ b/packages/openui-cli/src/commands/create-app.ts
@@ -11,6 +11,13 @@ import {
type PackageManagerName,
} from "../lib/detect-package-manager";
import { runDevCommand } from "../lib/dev-server";
+import {
+ findExample,
+ groupedExampleChoices,
+ loadExamplesCatalog,
+ rejectConflictingScaffoldSelectors,
+ type ExampleProject,
+} from "../lib/examples-catalog";
import { runSkillInstall, shouldInstallSkill } from "../lib/install-skill";
import {
applyOverlay,
@@ -30,9 +37,13 @@ import {
findCatalogOverlay,
findCatalogTemplate,
loadTemplatesCatalog,
+ type CatalogOverlay,
+ type CatalogTemplate,
} from "../lib/templates-catalog";
import { cliErrorProperties, processErrorProperties } from "../lib/utils";
+import { runCreateExample } from "./create-example";
+
function shouldCopyTemplatePath(templateDir: string, src: string): boolean {
const rel = path.relative(templateDir, src);
if (!rel) return true;
@@ -164,15 +175,22 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
has_name_arg: Boolean(options.name),
has_template_arg: Boolean(options.template),
has_backend_framework_arg: Boolean(options.backendFramework),
+ has_example_arg: Boolean(options.example),
has_api_key_arg: Boolean(options.apiKey),
has_auth_arg: Boolean(options.auth),
no_install: Boolean(options.noInstall),
immediate_arg: options.immediate,
});
+ rejectConflictingScaffoldSelectors({
+ example: options.example,
+ backendFramework: options.backendFramework,
+ template: options.template,
+ });
+
// Interactive runs always scaffold the Cloud backend; openui-self-hosted stays
// available, but only when requested explicitly with --template.
- if (!options.template && !interactive) {
+ if (!interactive && !options.example && !options.template) {
throw new CreateError(
"args_resolution",
"Missing required argument --template",
@@ -181,11 +199,30 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
);
}
- const catalog = await loadTemplatesCatalog();
- const template: TemplateName = options.template ?? DEFAULT_TEMPLATE_KEY;
- const templateEntry = findCatalogTemplate(catalog, template);
- if (options.backendFramework) {
- findCatalogOverlay(templateEntry, options.backendFramework);
+ let examples: ExampleProject[] = [];
+ let template: TemplateName | undefined;
+ let templateEntry: CatalogTemplate | undefined;
+ if (options.example) {
+ examples = await loadExamplesCatalog();
+ findExample(options.example, examples);
+ } else if (interactive) {
+ const [catalog, loadedExamples] = await Promise.all([
+ loadTemplatesCatalog(),
+ loadExamplesCatalog(),
+ ]);
+ examples = loadedExamples;
+ template = options.template ?? DEFAULT_TEMPLATE_KEY;
+ templateEntry = findCatalogTemplate(catalog, template);
+ if (options.backendFramework) {
+ findCatalogOverlay(templateEntry, options.backendFramework);
+ }
+ } else {
+ const catalog = await loadTemplatesCatalog();
+ template = options.template ?? DEFAULT_TEMPLATE_KEY;
+ templateEntry = findCatalogTemplate(catalog, template);
+ if (options.backendFramework) {
+ findCatalogOverlay(templateEntry, options.backendFramework);
+ }
}
const nameArgs = await resolveArgs(
@@ -204,28 +241,35 @@ export async function runCreateApp(options: CreateAppOptions): Promise<void> {
interactive,
);
- const overlayChoices = templateEntry.overlays;
- const frameworkArgs = await resolveArgs(
- {
- backendFramework:
- options.backendFramework || !interactive
- ? { value: options.backendFramework ?? "default" }
- : {
- prompt: {
- type: "select",
- message: "Choose your backend framework",
- choices: overlayChoices.map((overlay) => ({
- value: overlay.key,
- name: overlay.name,
- description: overlay.description,
- })),
- },
- required: true,
- },
- },
+ const selected = await resolveCreateSelection({
+ backendFramework: options.backendFramework,
+ example: options.example,
+ examples,
+ overlays: templateEntry?.overlays ?? [],
interactive,
- );
- const backendFramework = (frameworkArgs as { backendFramework: OverlayName }).backendFramework;
+ });
+ if (selected.kind === "example") {
+ await runCreateExample({
+ options,
+ interactive,
+ packageManager,
+ t0,
+ name,
+ targetDir,
+ example: selected.example,
+ });
+ return;
+ }
+ if (!template || !templateEntry) {
+ throw new CreateError(
+ "args_resolution",
+ "Missing required argument --template",
+ "invalid_input",
+ "MISSING_REQUIRED_ARG",
+ );
+ }
+
+ const backendFramework = selected.overlay;
findCatalogOverlay(templateEntry, backendFramework);
const aiSetup = aiSetupFromTemplate(template);
@@ -773,3 +817,80 @@ function getStartedMessage(o: {
.filter(Boolean)
.join("\n\n")}\n`;
}
+
+const OPENUI_EXAMPLES_CHOICE = "openui-examples";
+const GO_BACK_CHOICE = "__back__";
+
+async function resolveCreateSelection(params: {
+ backendFramework?: OverlayName;
+ example?: string;
+ examples: ExampleProject[];
+ overlays: CatalogOverlay[];
+ interactive: boolean;
+}): Promise<
+ { kind: "overlay"; overlay: OverlayName } | { kind: "example"; example: ExampleProject }
+> {
+ const { backendFramework, example, examples, overlays, interactive } = params;
+ if (example) return { kind: "example", example: findExample(example, examples) };
+ if (backendFramework) return { kind: "overlay", overlay: backendFramework };
+ if (!interactive) return { kind: "overlay", overlay: "default" };
+
+ const { select, Separator } = await import("@inquirer/prompts");
+ const prompt = async <T extends string>(
+ message: string,
+ choices: unknown[],
+ pageSize: number,
+ ) => {
+ try {
+ return (await select({
+ message,
+ choices: choices as never,
+ pageSize,
+ loop: false,
+ })) as T;
+ } catch (err) {
+ const { ExitPromptError } = await import("@inquirer/core");
+ if (err instanceof ExitPromptError) {
+ throw new CliCancelledError("args_resolution");
+ }
+ throw err;
+ }
+ };
+
+ for (;;) {
+ const starterChoices: unknown[] = overlays.map((overlay) => ({
+ value: overlay.key,
+ name: overlay.name,
+ description: overlay.description,
+ }));
+ if (examples.length > 0) {
+ starterChoices.push(new Separator());
+ starterChoices.push({
+ value: OPENUI_EXAMPLES_CHOICE,
+ name: "Scaffold from OpenUI Examples",
+ description: "Browse examples from the OpenUI repo",
+ });
+ }
+
+ const selected = await prompt<string>(
+ "Choose your backend framework",
+ starterChoices,
+ starterChoices.length,
+ );
+ if (selected !== OPENUI_EXAMPLES_CHOICE) {
+ return { kind: "overlay", overlay: selected as OverlayName };
+ }
+
+ const exampleSelected = await prompt<string>(
+ "Select an OpenUI example",
+ [
+ { value: GO_BACK_CHOICE, name: "← Back" },
+ new Separator(),
+ ...groupedExampleChoices(examples, Separator),
+ ],
+ 10,
+ );
+ if (exampleSelected === GO_BACK_CHOICE) continue;
+ return { kind: "example", example: findExample(exampleSelected, examples) };
+ }
+}
diff --git a/packages/openui-cli/src/commands/create-example.ts b/packages/openui-cli/src/commands/create-example.ts
new file mode 100644
index 000000000..4133877db
--- /dev/null
+++ b/packages/openui-cli/src/commands/create-example.ts
@@ -0,0 +1,299 @@
+import * as path from "node:path";
+
+import { printLogTail, QUIET_COMMAND_CAPTURE_LIMIT } from "../lib/command-output";
+import { createFunnelProps } from "../lib/create-telemetry";
+import type { CreateAppOptions, EnvResult } from "../lib/create-types";
+import { resolveInstallPackageManager } from "../lib/detect-package-manager";
+import { upsertEnvVar } from "../lib/env";
+import type { ExampleProject } from "../lib/examples-catalog";
+import { runSkillInstall, shouldInstallSkill } from "../lib/install-skill";
+import {
+ exampleDevCommand,
+ exampleLayout,
+ isNestedExample,
+ scaffoldExample,
+ type ExampleLayout,
+} from "../lib/scaffold-example";
+import { withSpinner } from "../lib/spinner";
+import { CliCancelledError, CreateError, telemetry } from "../lib/telemetry";
+import { cliErrorProperties, processErrorProperties } from "../lib/utils";
+
+export async function runCreateExample(params: {
+ options: CreateAppOptions;
+ interactive: boolean;
+ packageManager: ReturnType<typeof resolveInstallPackageManager>;
+ t0: number;
+ name: string;
+ targetDir: string;
+ example: ExampleProject;
+}): Promise<void> {
+ const { options, interactive, packageManager, t0, name, targetDir, example } = params;
+
+ telemetry.register({ example: example.name, project_category: "example" });
+ telemetry.capture("cli_example_selected", {
+ ...createFunnelProps("example_selected"),
+ example: example.name,
+ example_source: options.example ? "flag" : interactive ? "prompt" : "default",
+ });
+
+ telemetry.capture("cli_env_resolution_started", {
+ ...createFunnelProps("env_resolution_started"),
+ example: example.name,
+ });
+ const envResult = await resolveExampleEnv(example, interactive);
+
+ const installSkill = await shouldInstallSkill(options.skill, false);
+ telemetry.capture("cli_skill_installed", {
+ ...createFunnelProps("skill_prompt_resolved"),
+ skill_installed: installSkill,
+ });
+ telemetry.capture("cli_immediate_selected", {
+ immediate: false,
+ dependency_install_requested: false,
+ selection_source: "no_install",
+ });
+
+ console.info();
+ telemetry.capture("cli_scaffold_started", {
+ ...createFunnelProps("scaffold_started"),
+ example: example.name,
+ });
+ let layout: ExampleLayout | undefined;
+ try {
+ const runScaffold = () =>
+ scaffoldExample({
+ example,
+ targetDir,
+ name,
+ packageManager: packageManager.name,
+ });
+ layout = options.verbose
+ ? await runScaffold()
+ : await withSpinner("Scaffolding...", runScaffold);
+ if (!options.verbose) {
+ console.info("✓ Scaffolded");
+ }
+ } catch (err) {
+ const properties = cliErrorProperties(err, {
+ failure_stage: "scaffold",
+ error_class: "filesystem",
+ error_code: "SCAFFOLD_FAILED",
+ });
+ telemetry.capture("cli_scaffold_failed", {
+ ...createFunnelProps("scaffold_failed"),
+ example: example.name,
+ ...properties,
+ });
+ throw new CreateError(
+ properties.failure_stage,
+ err instanceof Error ? err.message : String(err),
+ properties.error_class,
+ properties.error_code,
+ );
+ }
+ telemetry.capture("cli_scaffold_succeeded", {
+ ...createFunnelProps("scaffold_succeeded"),
+ example: example.name,
+ });
+
+ try {
+ if (envResult.envKeyValue && example.envKey) {
+ upsertEnvVar(path.join(targetDir, example.envFile), example.envKey, envResult.envKeyValue);
+ }
+ } catch (err) {
+ const properties = cliErrorProperties(err, {
+ failure_stage: "environment_write",
+ error_class: "filesystem",
+ error_code: "WRITE_FAILED",
+ });
+ throw new CreateError(
+ properties.failure_stage,
+ err instanceof Error ? err.message : String(err),
+ properties.error_class,
+ properties.error_code,
+ );
+ }
+ telemetry.capture("cli_env_resolved", {
+ ...createFunnelProps("env_written"),
+ example: example.name,
+ env_written: envResult.envWritten,
+ });
+
+ layout ??= exampleLayout(targetDir);
+ const installCmd = packageManager.installCmd;
+ telemetry.capture("cli_dependency_install_skipped", {
+ skip_reason: "example_scaffold_only",
+ });
+ telemetry.capture("cli_dev_command_skipped", {
+ skip_reason: "not_immediate",
+ });
+
+ const skillInstalled = await installExampleSkill(installSkill, options.verbose, targetDir);
+
+ telemetry.capture("cli_create_succeeded", {
+ ...createFunnelProps("create_succeeded"),
+ example: example.name,
+ duration_ms: Date.now() - t0,
+ skill_installed: skillInstalled,
+ env_written: envResult.envWritten,
+ dependency_installed: false,
+ });
+ const envKey = example.envKey;
+ const envNote = envKey
+ ? envResult.envWritten
+ ? `✅ ${example.envFile} updated with ${envKey}.`
+ : `Add ${envKey}=… to ${example.envFile} (see the example README).`
+ : `Add your API keys to ${example.envFile} (see the example README).`;
+ const skillMessage = skillInstalled
+ ? "The OpenUI agent skill was installed.\nAI coding assistants will use it to help you build with OpenUI.\n"
+ : "";
+ const nextStep = isNestedExample(layout)
+ ? nestedExampleNextSteps({
+ name,
+ targetDir,
+ layout,
+ runCmd: packageManager.runCmd,
+ installCmd,
+ })
+ : [`> cd ${name}`, `> ${installCmd}`, `> ${packageManager.runCmd} run dev`].join("\n");
+
+ console.info(
+ `\n${[skillMessage.trim(), "Done!", envNote, nextStep].filter(Boolean).join("\n\n")}\n`,
+ );
+}
+
+async function resolveExampleEnv(
+ example: ExampleProject,
+ interactive: boolean,
+): Promise<EnvResult & { envKeyValue?: string }> {
+ if (!example.envKey) {
+ return { envWritten: false };
+ }
+
+ const apiKey = interactive ? await promptForProviderKey(example.envKey) : null;
+ return {
+ envWritten: apiKey != null,
+ envKeyValue: apiKey ?? undefined,
+ };
+}
+
+async function promptForProviderKey(envKey: string): Promise<string | null> {
+ try {
+ const { input } = await import("@inquirer/prompts");
+ const apiKey = (
+ await input({
+ message: `Enter your ${envKey} (leave blank to skip):`,
+ })
+ ).trim();
+ return apiKey || null;
+ } catch (error) {
+ const { ExitPromptError } = await import("@inquirer/core");
+ if (error instanceof ExitPromptError) {
+ throw new CliCancelledError("environment_resolution");
+ }
+ throw error;
+ }
+}
+
+async function installExampleSkill(
+ enabled: boolean,
+ verbose: boolean | undefined,
+ targetDir: string,
+): Promise<boolean> {
+ if (!enabled) return false;
+
+ telemetry.capture("cli_skill_install_started", {
+ ...createFunnelProps("skill_install_started"),
+ skill_installed: true,
+ });
+ const runSkill = () =>
+ verbose
+ ? runSkillInstall(targetDir)
+ : runSkillInstall(targetDir, {
+ echo: false,
+ stdin: "ignore",
+ captureLimit: QUIET_COMMAND_CAPTURE_LIMIT,
+ });
+ if (verbose) {
+ console.info("Installing OpenUI agent skill...\n");
+ }
+ const skillResult = verbose
+ ? await runSkill()
+ : await withSpinner("Installing OpenUI agent skill...", runSkill);
+ const skillInstalled = !skillResult.error && skillResult.status === 0;
+ if (skillInstalled) {
+ if (!verbose) {
+ console.info("✓ OpenUI agent skill installed");
+ }
+ telemetry.capture("cli_skill_install_finished", {
+ ...createFunnelProps("skill_install_finished"),
+ skill_installed: true,
+ duration_ms: skillResult.durationMs,
+ exit_code: skillResult.status,
+ });
+ return true;
+ }
+
+ const properties = processErrorProperties(skillResult, "skill_install", {
+ error_class: "dependency",
+ error_code: "SKILL_INSTALL_FAILED",
+ });
+ if (properties.error_class === "user_cancelled") {
+ telemetry.capture("cli_skill_install_cancelled", {
+ ...createFunnelProps("skill_install_cancelled"),
+ skill_installed: false,
+ ...properties,
+ });
+ throw new CliCancelledError(
+ "skill_install",
+ properties.cancellation_exit_code ?? 0,
+ properties,
+ );
+ }
+ telemetry.capture("cli_skill_install_failed", {
+ ...createFunnelProps("skill_install_failed"),
+ skill_installed: false,
+ ...properties,
+ });
+ if (!verbose) {
+ printLogTail(skillResult.diagnosticTail, "skill install log (tail)");
+ }
+ console.warn(
+ "\nCould not install the OpenUI agent skill automatically.\n" +
+ "You can install it manually later with:\n\n" +
+ " npx skills add thesysdev/skills --skill openui\n",
+ );
+ return false;
+}
+
+function posixJoin(...parts: string[]): string {
+ return parts.filter((part) => part && part !== ".").join("/");
+}
+
+function nestedExampleNextSteps(params: {
+ name: string;
+ targetDir: string;
+ layout: ExampleLayout;
+ runCmd: string;
+ installCmd: string;
+}): string {
+ const blocks: string[] = [];
+ for (const relative of params.layout.jsPackages) {
+ const pkgDir = relative === "." ? params.targetDir : path.join(params.targetDir, relative);
+ blocks.push(
+ [
+ `> cd ${posixJoin(params.name, relative)}`,
+ `> ${params.installCmd}`,
+ `> ${exampleDevCommand(pkgDir, params.runCmd)}`,
+ ].join("\n"),
+ );
+ }
+ for (const relative of params.layout.pythonPackages) {
+ blocks.push(
+ [`> cd ${posixJoin(params.name, relative)}`, `> uv run uvicorn app.main:app --reload`].join(
+ "\n",
+ ),
+ );
+ }
+ return blocks.join("\n\n");
+}
diff --git a/packages/openui-cli/src/index.ts b/packages/openui-cli/src/index.ts
index ee3d0609f..9a27e3485 100644
--- a/packages/openui-cli/src/index.ts
+++ b/packages/openui-cli/src/index.ts
@@ -12,6 +12,7 @@ import { GenerateOptions, runGenerate } from "./commands/generate";
import { runGenerateApiKey } from "./commands/generate-api-key";
import { detectAgent, UNKNOWN_AGENT_NAME } from "./lib/detect-agent";
import { DEFAULT_ENV_FILE } from "./lib/env";
+import { rejectConflictingScaffoldSelectors } from "./lib/examples-catalog";
import { rejectConflictingImmediateFlags, resolveArgs } from "./lib/resolve-args";
import { telemetry } from "./lib/telemetry";
import {
@@ -67,6 +68,7 @@ program
"--backend-framework <framework>",
"Backend framework: default | langgraph | vercel-ai-sdk | vercel-eve",
)
+ .option("-e, --example <example>", "Create from an example in examples/examples.json")
.option("--api-key <key>", "OpenUI Cloud API key (cloud template; skips sign-in)")
.option("--auth <method>", "Cloud auth method: oauth | skip (manual is deprecated)")
.option("--skill", "Install the OpenUI agent skill for AI coding assistants")
@@ -95,6 +97,11 @@ Backend frameworks:
langgraph Bootstraps a LangGraph agent with the selected model backend.
vercel-ai-sdk Scaffolds a Vercel AI SDK agent with the selected model backend.
vercel-eve Scaffolds a Vercel Eve agent with the selected model backend.
+
+OpenUI examples:
+ Loaded at runtime from examples/examples.json in the OpenUI repo.
+ Pick "Scaffold from OpenUI Examples" in the interactive prompt, or pass
+ --example <name> with any catalog folder name.
`,
)
.action(
@@ -102,6 +109,7 @@ Backend frameworks:
name?: string;
template?: string;
backendFramework?: string;
+ example?: string;
apiKey?: string;
auth?: string;
skill?: boolean;
@@ -112,10 +120,16 @@ Backend frameworks:
}) => {
try {
rejectConflictingImmediateFlags(process.argv.slice(2));
+ rejectConflictingScaffoldSelectors({
+ example: options.example,
+ backendFramework: normalizeBackendFramework(options.backendFramework),
+ template: options.template,
+ });
await runCreateApp({
name: options.name,
template: normalizeTemplate(options.template),
backendFramework: normalizeBackendFramework(options.backendFramework),
+ example: options.example,
apiKey: options.apiKey,
auth: normalizeAuth(options.auth),
skill: options.skill,
diff --git a/packages/openui-cli/src/lib/create-telemetry.ts b/packages/openui-cli/src/lib/create-telemetry.ts
index 7e2758b99..a1e9fb24d 100644
--- a/packages/openui-cli/src/lib/create-telemetry.ts
+++ b/packages/openui-cli/src/lib/create-telemetry.ts
@@ -9,6 +9,7 @@ const createFunnelSteps = {
create_started: "0100",
ai_setup_selected: "0200",
backend_framework_selected: "0250",
+ example_selected: "0260",
scaffold_started: "0300",
scaffold_succeeded: "0310",
scaffold_failed: "0320",
diff --git a/packages/openui-cli/src/lib/create-types.ts b/packages/openui-cli/src/lib/create-types.ts
index db853defb..573cb040e 100644
--- a/packages/openui-cli/src/lib/create-types.ts
+++ b/packages/openui-cli/src/lib/create-types.ts
@@ -9,6 +9,7 @@ export interface CreateAppOptions {
name?: string;
template?: TemplateName;
backendFramework?: OverlayName;
+ example?: string;
skill?: boolean;
noInteractive?: boolean;
noInstall?: boolean;
diff --git a/packages/openui-cli/src/lib/examples-catalog.ts b/packages/openui-cli/src/lib/examples-catalog.ts
new file mode 100644
index 000000000..bf30efcc8
--- /dev/null
+++ b/packages/openui-cli/src/lib/examples-catalog.ts
@@ -0,0 +1,142 @@
+import { styleText } from "node:util";
+
+import { fetchSourceFile } from "./checkout";
+import { CreateError } from "./telemetry";
+
+export const EXAMPLES_CATALOG_PATH = "examples/examples.json";
+
+export type ExampleProject = {
+ name: string;
+ label: string;
+ description: string;
+ /** Path inside the OpenUI repo, e.g. `examples/app-frameworks/vue`. */
+ path: string;
+ envFile: ".env";
+ /** Primary env var to prompt for. Omit when the example needs several keys. */
+ envKey?: string;
+};
+
+function catalogError(message: string): CreateError {
+ return new CreateError("args_resolution", message, "invalid_input", "EXAMPLES_CATALOG_INVALID");
+}
+
+function parseCatalogEntry(item: unknown): ExampleProject {
+ const entry = item as {
+ title?: unknown;
+ description?: unknown;
+ path?: unknown;
+ envKey?: unknown;
+ };
+ if (
+ typeof entry.title !== "string" ||
+ typeof entry.description !== "string" ||
+ typeof entry.path !== "string"
+ ) {
+ throw catalogError(
+ `${EXAMPLES_CATALOG_PATH} has an example missing title, description, or path.`,
+ );
+ }
+ const relative = entry.path.replace(/^\/+/, "");
+ const name = relative.split("/").filter(Boolean).at(-1);
+ if (!name) {
+ throw catalogError(`${EXAMPLES_CATALOG_PATH} has an example with an empty path.`);
+ }
+ if (entry.envKey !== undefined) {
+ if (typeof entry.envKey !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(entry.envKey)) {
+ throw catalogError(`${EXAMPLES_CATALOG_PATH} example "${name}" has an invalid envKey.`);
+ }
+ }
+ return {
+ name,
+ label: entry.title,
+ description: entry.description,
+ path: relative.startsWith("examples/") ? relative : `examples/${relative}`,
+ envFile: ".env",
+ envKey: typeof entry.envKey === "string" ? entry.envKey : undefined,
+ };
+}
+
+function parseExamplesCatalog(raw: string): ExampleProject[] {
+ const parsed = JSON.parse(raw) as { examples?: unknown };
+ if (!Array.isArray(parsed.examples) || parsed.examples.length === 0) {
+ throw catalogError(`${EXAMPLES_CATALOG_PATH} must contain a non-empty "examples" array.`);
+ }
+ return parsed.examples.map(parseCatalogEntry);
+}
+
+/** Prefetch the examples catalog from GitHub. */
+export async function loadExamplesCatalog(): Promise<ExampleProject[]> {
+ const { content } = await fetchSourceFile(EXAMPLES_CATALOG_PATH);
+ return parseExamplesCatalog(content);
+}
+
+export function findExample(name: string, examples: ExampleProject[]): ExampleProject {
+ const normalized = name.toLowerCase();
+ const match = examples.find((entry) => entry.name.toLowerCase() === normalized);
+ if (!match) {
+ const available = examples.map((entry) => entry.name).join(" | ") || "(none loaded)";
+ throw new CreateError(
+ "args_resolution",
+ `unknown example "${name}". Use: ${available}.`,
+ "invalid_input",
+ "INVALID_EXAMPLE",
+ );
+ }
+ return match;
+}
+
+export function rejectConflictingScaffoldSelectors(opts: {
+ example?: string;
+ backendFramework?: string;
+ template?: string;
+}): void {
+ if (opts.example && opts.backendFramework) {
+ throw new CreateError(
+ "bad_args",
+ "Cannot use --example with --backend-framework. Choose one scaffold selector.",
+ "invalid_input",
+ "CONFLICTING_SCAFFOLD_SELECTORS",
+ );
+ }
+ if (opts.example && opts.template) {
+ throw new CreateError(
+ "bad_args",
+ "Cannot use --example with --template. Choose one scaffold selector.",
+ "invalid_input",
+ "CONFLICTING_SCAFFOLD_SELECTORS",
+ );
+ }
+}
+
+function categoryLabel(key: string): string {
+ return key
+ .split("-")
+ .map((part, index) => (index === 0 ? part.charAt(0).toUpperCase() + part.slice(1) : part))
+ .join(" ");
+}
+
+export function groupedExampleChoices(
+ examples: ExampleProject[],
+ Separator: new (heading?: string) => object,
+): unknown[] {
+ const groups = new Map<string, ExampleProject[]>();
+ for (const example of examples) {
+ const key = example.path.replace(/^examples\//, "").split("/")[0] ?? "miscellaneous";
+ const group = groups.get(key) ?? [];
+ group.push(example);
+ groups.set(key, group);
+ }
+
+ const choices: unknown[] = [];
+ for (const [key, group] of groups) {
+ choices.push(new Separator(styleText("bold", categoryLabel(key))));
+ for (const project of group) {
+ choices.push({
+ value: project.name,
+ name: project.label,
+ description: project.description,
+ });
+ }
+ }
+ return choices;
+}
diff --git a/packages/openui-cli/src/lib/scaffold-example.ts b/packages/openui-cli/src/lib/scaffold-example.ts
new file mode 100644
index 000000000..7532a75ee
--- /dev/null
+++ b/packages/openui-cli/src/lib/scaffold-example.ts
@@ -0,0 +1,201 @@
+import * as fs from "node:fs";
+import * as os from "node:os";
+import * as path from "node:path";
+
+import { checkoutSource } from "./checkout";
+import type { PackageManagerName } from "./detect-package-manager";
+import type { ExampleProject } from "./examples-catalog";
+import { CreateError } from "./telemetry";
+
+const ARTIFACT_DIRS = new Set(["node_modules", ".next", ".turbo", "dist", ".nuxt", ".svelte-kit"]);
+
+const GENERATE_SCRIPT_RE =
+ /pnpm --filter @openuidev\/cli build && node (?:\.\.\/)+packages\/openui-cli\/dist\/index\.js generate/;
+const GENERATE_SCRIPT_FALLBACK_RE =
+ /node (?:\.\.\/)+packages\/openui-cli\/dist\/index\.js generate/;
+
+export type ExampleLayout = {
+ /** Directories with a `package.json`, relative to the example root (`"."` = root). */
+ jsPackages: string[];
+ /** Directories with a `pyproject.toml`, relative to the example root. */
+ pythonPackages: string[];
+};
+
+function collectRelativeDirs(dir: string, fileName: string, root = dir): string[] {
+ const found: string[] = [];
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ if (ARTIFACT_DIRS.has(entry.name) || entry.name === ".git") continue;
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) {
+ found.push(...collectRelativeDirs(full, fileName, root));
+ continue;
+ }
+ if (entry.name !== fileName) continue;
+ const relative = path.relative(root, dir);
+ found.push(relative === "" ? "." : relative);
+ }
+ return found;
+}
+
+export function exampleLayout(projectDir: string): ExampleLayout {
+ return {
+ jsPackages: collectRelativeDirs(projectDir, "package.json"),
+ pythonPackages: collectRelativeDirs(projectDir, "pyproject.toml"),
+ };
+}
+
+export function isNestedExample(layout: ExampleLayout): boolean {
+ return layout.jsPackages.length > 0 && !layout.jsPackages.includes(".");
+}
+
+export function exampleDevCommand(pkgDir: string, runCmd: string): string {
+ const pkg = JSON.parse(fs.readFileSync(path.join(pkgDir, "package.json"), "utf8")) as {
+ scripts?: Record<string, string>;
+ };
+ if (pkg.scripts?.["dev"]) return `${runCmd} run dev`;
+ if (pkg.scripts?.["start"]) return `${runCmd} start`;
+ return `${runCmd} run dev`;
+}
+
+function rewriteGenerateScript(value: string): string {
+ if (GENERATE_SCRIPT_RE.test(value)) {
+ return value.replace(GENERATE_SCRIPT_RE, "npx @openuidev/cli generate");
+ }
+ if (GENERATE_SCRIPT_FALLBACK_RE.test(value)) {
+ return value.replace(GENERATE_SCRIPT_FALLBACK_RE, "npx @openuidev/cli generate");
+ }
+ return value;
+}
+
+function restoreDotfiles(projectDir: string): void {
+ const plain = path.join(projectDir, "gitignore");
+ if (fs.existsSync(plain)) {
+ fs.renameSync(plain, path.join(projectDir, ".gitignore"));
+ }
+}
+
+function rewriteExamplePackageJson(
+ pkgPath: string,
+ packageManager: PackageManagerName,
+ name?: string,
+): void {
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as {
+ name?: string;
+ scripts?: Record<string, string>;
+ dependencies?: Record<string, string>;
+ devDependencies?: Record<string, string>;
+ pnpm?: unknown;
+ };
+ if (name) pkg.name = name;
+ if (packageManager !== "pnpm") delete pkg.pnpm;
+
+ const pkgDir = path.dirname(pkgPath);
+ for (const section of ["dependencies", "devDependencies"] as const) {
+ const deps = pkg[section];
+ if (!deps) continue;
+ for (const key of Object.keys(deps)) {
+ const value = deps[key];
+ if (!value) continue;
+ if (value.startsWith("link:")) {
+ const target = value.slice("link:".length);
+ deps[key] = `file:${
+ target.startsWith("~")
+ ? path.join(os.homedir(), target.slice(1))
+ : path.resolve(pkgDir, target)
+ }`;
+ continue;
+ }
+ if (/^(workspace:|file:|catalog:)/.test(value)) deps[key] = "latest";
+ }
+ }
+
+ if (pkg.scripts) {
+ for (const [key, value] of Object.entries(pkg.scripts)) {
+ pkg.scripts[key] = rewriteGenerateScript(value);
+ }
+ }
+
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
+}
+
+function pruneLockfiles(pkgDir: string, packageManager: PackageManagerName): void {
+ if (packageManager !== "npm") {
+ fs.rmSync(path.join(pkgDir, "package-lock.json"), { force: true });
+ }
+ if (packageManager !== "pnpm") {
+ fs.rmSync(path.join(pkgDir, "pnpm-lock.yaml"), { force: true });
+ }
+}
+
+function copyEnvExamples(projectDir: string): void {
+ const mappings: Array<[string, string]> = [
+ [".env.example", ".env"],
+ [".env.local.example", ".env.local"],
+ ["env.example", ".env"],
+ ];
+
+ const visit = (dir: string) => {
+ for (const [fromName, toName] of mappings) {
+ const from = path.join(dir, fromName);
+ const to = path.join(dir, toName);
+ if (fs.existsSync(from)) {
+ if (!fs.existsSync(to)) {
+ fs.copyFileSync(from, to);
+ }
+ fs.unlinkSync(from);
+ }
+ }
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ if (!entry.isDirectory() || ARTIFACT_DIRS.has(entry.name)) continue;
+ visit(path.join(dir, entry.name));
+ }
+ };
+
+ visit(projectDir);
+}
+
+export async function scaffoldExample(params: {
+ example: ExampleProject;
+ targetDir: string;
+ name: string;
+ packageManager: PackageManagerName;
+}): Promise<ExampleLayout> {
+ const { example, targetDir, name, packageManager } = params;
+
+ try {
+ await checkoutSource(example.path, { dest: targetDir });
+ } catch (err) {
+ if (err instanceof CreateError) throw err;
+ throw new CreateError(
+ "scaffold",
+ err instanceof Error ? err.message : String(err),
+ "filesystem",
+ "EXAMPLE_SCAFFOLD_FAILED",
+ );
+ }
+
+ const layout = exampleLayout(targetDir);
+ if (layout.jsPackages.length === 0 && layout.pythonPackages.length === 0) {
+ throw new CreateError(
+ "scaffold",
+ `Example "${example.name}" was not found at ${example.path}.`,
+ "filesystem",
+ "EXAMPLE_MISSING",
+ );
+ }
+
+ restoreDotfiles(targetDir);
+
+ for (const relative of layout.jsPackages) {
+ const pkgDir = relative === "." ? targetDir : path.join(targetDir, relative);
+ rewriteExamplePackageJson(
+ path.join(pkgDir, "package.json"),
+ packageManager,
+ relative === "." ? name : undefined,
+ );
+ pruneLockfiles(pkgDir, packageManager);
+ }
+
+ copyEnvExamples(targetDir);
+ return layout;
+}