The Open Standard for Generative UI
cli: add `openui feedback` for anonymous feedback (#1266)
devin-ai-integration[bot]17be4966d31a
diff --git a/.changeset/tidy-agents-feedback.md b/.changeset/tidy-agents-feedback.mdnew file mode 100644index 000000000..1653fab39--- /dev/null+++ b/.changeset/tidy-agents-feedback.md@@ -0,0 +1,5 @@+---+"@openuidev/cli": minor+---++Add `openui feedback` command for sending anonymous feedback.diff --git a/README.md b/README.mdindex cfc84a6ed..2d56d711a 100644--- a/README.md+++ b/README.md@@ -245,6 +245,16 @@ npx skills add thesysdev/skills --skill openuiThe skill covers component library design, OpenUI Lang syntax, system prompt generation, the Renderer, SDK packages, and debugging malformed LLM output.+## Feedback++Found a bug or have an idea? [Open an issue](https://github.com/thesysdev/openui/issues), or send anonymous feedback from your terminal:++```bash+npx @openuidev/cli feedback "Describe the problem or idea"+```++Coding agents using the [OpenUI skill](#agent-skill) can send feedback for you. They remove personal details and code from the message and ask for your approval before sending it.+## LicenseThis project is available under the terms described in [`LICENSE`](./LICENSE).diff --git a/packages/openui-cli/README.md b/packages/openui-cli/README.mdindex 7e26672ee..a2c3011f6 100644--- a/packages/openui-cli/README.md+++ b/packages/openui-cli/README.md@@ -15,6 +15,7 @@ It currently supports:- 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+- sending anonymous feedback to the OpenUI team- generating a system prompt or JSON Schema from a `createLibrary()` export- deploying a project with `openui deploy`@@ -248,6 +249,27 @@ openui generate-api-key --file .env.localopenui generate-api-key --file .env.local --key THESYS_API_KEY```+### `openui feedback`++Sends anonymous feedback about OpenUI to the OpenUI team.++```bash+openui feedback [options] <message...>+```++Options:++- `-c, --category <category>`: `bug`, `feature`, `docs`, or `other`++Feedback is anonymous: it isn't linked to your account, device, or IP address, and it's sent even when telemetry is disabled. Don't include personal data, secrets, or code.++Examples:++```bash+openui feedback "The streaming docs don't explain how to handle partial components"+openui --agent-name codex feedback --category bug "Renderer throws when a streamed component closes before its props"+```+### `openui generate`Generates a system prompt and serialized library spec from a file that exports a `createLibrary()` result. Use the spec with `generateSystemPrompt` in backend routes; the prompt file remains available for static or legacy integrations.diff --git a/packages/openui-cli/src/commands/create/lib/messages.ts b/packages/openui-cli/src/commands/create/lib/messages.tsindex 524b22582..c64d4bacd 100644--- a/packages/openui-cli/src/commands/create/lib/messages.ts+++ b/packages/openui-cli/src/commands/create/lib/messages.ts@@ -34,10 +34,20 @@ export function getStartedMessage(o: {].join("\n");const deployHint = "Share a preview:\n> npx @openuidev/cli@latest deploy";+ const feedbackHint =+ 'Found a bug or have an idea?\n> npx @openuidev/cli@latest feedback "<message>"';const frameworkNote = o.backendGettingStarted?.replaceAll("{{packageManager}}", o.devCmd) ?? "";- return `\n${[skillMessage.trim(), "Done!", envNote, frameworkNote, nextStep, deployHint]+ return `\n${[+ skillMessage.trim(),+ "Done!",+ envNote,+ frameworkNote,+ nextStep,+ deployHint,+ feedbackHint,+ ].filter(Boolean).join("\n\n")}\n`;}diff --git a/packages/openui-cli/src/commands/feedback/command.ts b/packages/openui-cli/src/commands/feedback/command.tsnew file mode 100644index 000000000..14364240f--- /dev/null+++ b/packages/openui-cli/src/commands/feedback/command.ts@@ -0,0 +1,33 @@+import { Command } from "commander";++import { context } from "../../lib/context";++import { runFeedback } from "./run";++type FeedbackOptions = {+ category?: string;+};++export const feedbackCommand = new Command("feedback")+ .description("Send anonymous feedback about OpenUI to the OpenUI team")+ .argument("<message...>")+ .option("-c, --category <category>", "bug | feature | docs | other")+ .addHelpText(+ "after",+ `+Examples:+ openui feedback "The streaming docs don't explain how to handle partial components"+ openui --agent-name codex feedback --category bug "Renderer throws when a streamed component closes before its props"+`,+ )+ .action(async (messageWords: string[], options: FeedbackOptions, command: Command) => {+ const globalOptions = command.optsWithGlobals<{ agentName?: string }>();+ await runFeedback(+ {+ messageWords,+ category: options.category,+ agentName: globalOptions.agentName,+ },+ context,+ );+ });diff --git a/packages/openui-cli/src/commands/feedback/run.ts b/packages/openui-cli/src/commands/feedback/run.tsnew file mode 100644index 000000000..680420f2d--- /dev/null+++ b/packages/openui-cli/src/commands/feedback/run.ts@@ -0,0 +1,74 @@+import type { CliContext } from "../../lib/context";+import { UNKNOWN_AGENT_NAME } from "../../lib/detect-agent";+import { CreateError } from "../../lib/errors";+import { createPostHogClient } from "../../lib/posthog";++export interface FeedbackOptions {+ messageWords: string[];+ category?: string;+ agentName?: string;+}++const FEEDBACK_CATEGORIES = new Set(["bug", "feature", "docs", "other"]);++export async function runFeedback(options: FeedbackOptions, ctx: CliContext): Promise<void> {+ const message = options.messageWords.join(" ").trim();+ if (!message) {+ throw new CreateError(+ "args_resolution",+ "Feedback message cannot be empty.",+ "invalid_input",+ "INVALID_FEEDBACK_MESSAGE",+ );+ }+ if (message.length > 2000) {+ throw new CreateError(+ "args_resolution",+ "Feedback message must be 2000 characters or fewer.",+ "invalid_input",+ "INVALID_FEEDBACK_MESSAGE",+ );+ }+ if (options.category && !FEEDBACK_CATEGORIES.has(options.category)) {+ throw new CreateError(+ "args_resolution",+ "Invalid feedback category. Use: bug | feature | docs | other.",+ "invalid_input",+ "INVALID_FEEDBACK_CATEGORY",+ );+ }++ const properties: Record<string, unknown> = {+ message,+ category: options.category ?? "other",+ cli_version: ctx.cliVersion ?? "",+ $process_person_profile: false,+ // placeholder so PostHog doesn't record the sender's IP+ $ip: "0.0.0.0",+ };+ if (options.agentName && options.agentName !== UNKNOWN_AGENT_NAME) {+ properties["agent_name"] = options.agentName;+ }+ const client = createPostHogClient({ disableGeoip: true });+ let failure: unknown;+ client.on("error", (error) => {+ failure = error;+ });+ await client.captureImmediate({+ distinctId: crypto.randomUUID(),+ event: "agent_feedback_submitted",+ properties,+ });+ await client.shutdown();+ if (failure) {+ const detail = failure instanceof Error ? failure.message : String(failure);+ throw new CreateError(+ "feedback_submission",+ `Could not send feedback: ${detail}`,+ "network",+ "FEEDBACK_REQUEST_FAILED",+ );+ }++ console.info("Thanks! Feedback sent.");+}diff --git a/packages/openui-cli/src/commands/index.ts b/packages/openui-cli/src/commands/index.tsindex e4c9686ab..259252450 100644--- a/packages/openui-cli/src/commands/index.ts+++ b/packages/openui-cli/src/commands/index.ts@@ -1,6 +1,13 @@import { createCommand } from "./create/command";import { deployCommand } from "./deploy/command";+import { feedbackCommand } from "./feedback/command";import { generateApiKeyCommand } from "./generate-api-key/command";import { generateCommand } from "./generate/command";-export const commands = [createCommand, deployCommand, generateApiKeyCommand, generateCommand];+export const commands = [+ createCommand,+ deployCommand,+ feedbackCommand,+ generateApiKeyCommand,+ generateCommand,+];diff --git a/packages/openui-cli/src/lib/context.ts b/packages/openui-cli/src/lib/context.tsindex 19c522f88..02eb89aa0 100644--- a/packages/openui-cli/src/lib/context.ts+++ b/packages/openui-cli/src/lib/context.ts@@ -5,6 +5,7 @@ export type CliContext = {argv: string[];telemetry: Telemetry;verbose: boolean;+ cliVersion?: string;};export const context: CliContext = {@@ -16,4 +17,5 @@ export const context: CliContext = {},telemetry,verbose: false,+ cliVersion: undefined,};diff --git a/packages/openui-cli/src/lib/posthog.ts b/packages/openui-cli/src/lib/posthog.tsnew file mode 100644index 000000000..09fb09347--- /dev/null+++ b/packages/openui-cli/src/lib/posthog.ts@@ -0,0 +1,15 @@+import { PostHog } from "posthog-node";++// Public ingestion key+const POSTHOG_KEY =+ process.env["OPENUI_POSTHOG_KEY"] ?? "phc_3OLW53x09ZTVZSV6BEpj5uycj3ooqR6KOemOjx04e3D";+const POSTHOG_HOST = process.env["OPENUI_POSTHOG_HOST"] ?? "https://us.i.posthog.com";++export function createPostHogClient(options: { disableGeoip?: boolean } = {}): PostHog {+ return new PostHog(POSTHOG_KEY, {+ host: POSTHOG_HOST,+ flushAt: 1,+ flushInterval: 0,+ ...options,+ });+}diff --git a/packages/openui-cli/src/lib/telemetry.ts b/packages/openui-cli/src/lib/telemetry.tsindex b7693b0bf..49c6b6866 100644--- a/packages/openui-cli/src/lib/telemetry.ts+++ b/packages/openui-cli/src/lib/telemetry.ts@@ -1,16 +1,13 @@import * as fs from "node:fs";import * as os from "node:os";import * as path from "node:path";-import { PostHog } from "posthog-node";+import type { PostHog } from "posthog-node";import { isTruthyEnv } from "./env";import { cliErrorProperties } from "./errors";+import { createPostHogClient } from "./posthog";import type { RetryAttemptInfo } from "./retry";-// Public ingestion key-const POSTHOG_KEY =- process.env["OPENUI_POSTHOG_KEY"] ?? "phc_3OLW53x09ZTVZSV6BEpj5uycj3ooqR6KOemOjx04e3D";-const POSTHOG_HOST = process.env["OPENUI_POSTHOG_HOST"] ?? "https://us.i.posthog.com";const SHUTDOWN_TIMEOUT_MS = 2000;const isTelemetryDebug = () => process.env["OPENUI_TELEMETRY_DEBUG"] === "1";@@ -97,11 +94,7 @@ export class Telemetry {is_interactive_terminal: interactiveTerminal,};try {- this.session.client = new PostHog(POSTHOG_KEY, {- host: POSTHOG_HOST,- flushAt: 1,- flushInterval: 0,- });+ this.session.client = createPostHogClient();// Telemetry is best-effort: swallow network/flush errors so an offline CLI// run never spams the user's console with PostHog stack traces.this.session.client.on("error", (error) => debugLogPostHogFailure("request", error));diff --git a/packages/openui-cli/src/program.ts b/packages/openui-cli/src/program.tsindex 4e31a1d8f..3c0d47c3b 100644--- a/packages/openui-cli/src/program.ts+++ b/packages/openui-cli/src/program.ts@@ -20,6 +20,7 @@ function buildProgram(): Command {version: string;}).version;+ ctx.cliVersion = cliVersion;program.name("openui").description("CLI for OpenUI").version(cliVersion);program.option("--no-telemetry", "Disable anonymous usage analytics");@@ -30,6 +31,7 @@ function buildProgram(): Command {UNKNOWN_AGENT_NAME,);program.configureHelp({ showGlobalOptions: true });+ program.addHelpText("after", '\nFound a bug or have an idea? Run: openui feedback "<message>"');program.hook("preAction", (_thisCommand, actionCommand) => {activeCommand = actionCommand.name();