Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

raea bug: an agent reports a bug in raea itself to raea's server, headless and with no account

shinyobjectz9aee93e51824
diff --git a/docs/manual/reference/cli/bug.md b/docs/manual/reference/cli/bug.md
new file mode 100644
index 00000000..08583907
--- /dev/null
+++ b/docs/manual/reference/cli/bug.md
@@ -0,0 +1,45 @@
+---
+title: "raea bug"
+summary: "Report a bug in raea itself to raea's server: a line saying what's wrong and what happened, with raea's version and the OS added, no account needed."
+order: 129
+sources: ["engine/cli/src/bug.ts", "engine/cli/src/cli.rs"]
+---
+
+Report a bug in raea itself to raea's server: a line saying what's wrong and what happened, with raea's version and the OS added, no account needed.
+
+<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
+
+## Usage
+
+```sh
+raea bug TITLE... --text TEXT [--command CMD] [--error TEXT] [--agent NAME] [--dry-run] (a bug in raea itself, not in your own composition, sent to raea's server with raea's version and the OS, no account needed: words only, paths, emails and keys taken out before it goes; five a day from a machine, the same bug again counted on the first report; --dry-run prints what would go and sends nothing)
+```
+
+Headless: it needs nothing running and opens no window. Takes any number of arguments besides its flags.
+
+## Flags
+
+| Flag | Takes | What it does |
+| --- | --- | --- |
+| `--agent` | `NAME` | Who is reporting: the agent or harness's name (claude-code, codex, kimi). Unless said, `RAEA_AGENT`, else the harness raea finds it running under. |
+| `--command` | `CMD` | The raea command that went wrong, as you ran it (paths in it are taken out). |
+| `--dry-run` | – | Print exactly what would be sent, raea's version and the OS included, and send nothing. |
+| `--error` | `TEXT` | What the command printed when it went wrong, up to 4,000 characters (paths, emails and keys taken out). |
+| `--text` | `TEXT` | What you did, what you expected and what happened instead, up to 4,000 characters. Needed. |
+
+<!-- generated:end -->
+
+`raea bug` is how an agent tells raea about a bug it thinks it found in raea itself: a command that fails or hangs, a
+result that's wrong, or help that says one thing while raea does another. It's for raea's bugs, not the composition
+you're writing. It works in any shell, headless or in the app, and needs no account.
+
+The report is words only. raea adds its version and the OS, and takes out paths, emails and anything shaped like a
+key or token before it leaves the machine; raea's server takes them out again. A machine sends at most five a day,
+and the same bug sent again (by the same line, numbers and paths aside, on the same version) is counted on the first
+report instead of being kept twice. `--dry-run` prints exactly what would be sent and sends nothing.
+
+```sh
+raea bug "raea render stops at frame 12 with no error" \
+ --text "Rendered compositions/teaser.tsx to mp4; it printed frame 12 of 240 and exited 0 with no file." \
+ --command "raea render compositions/teaser.tsx -o out/teaser.mp4" --error "frame 12/240"
+```
diff --git a/docs/manual/reference/cli/index.md b/docs/manual/reference/cli/index.md
index f2e00bd3..8ee1ebf0 100644
--- a/docs/manual/reference/cli/index.md
+++ b/docs/manual/reference/cli/index.md
@@ -128,5 +128,6 @@ What an agent reads and shows the person, and the tools raea installs.
| [`raea skill`](skill.md) | Print the agent skill this raea ships, matched to its version, or one of its references. |
| [`raea skills`](skills.md) | Install raea's agent skill where Claude Code, Codex, Kimi or Gemini read skills, with its MCP server and hook. |
| [`raea setup`](setup.md) | Find Blender, or download its current LTS, and install raea's add-on and the MCP add-on. |
+| [`raea bug`](bug.md) | Report a bug in raea itself to raea's server: a line saying what's wrong and what happened, with raea's version and the OS added, no account needed. |
<!-- generated:end -->
diff --git a/engine/cli/conformance/bug.test.ts b/engine/cli/conformance/bug.test.ts
new file mode 100644
index 00000000..74104a48
--- /dev/null
+++ b/engine/cli/conformance/bug.test.ts
@@ -0,0 +1,55 @@
+// `raea bug`: what an agent's report of a bug in raea carries to the host, which sends it to raea's server
+// (raea.io/v1/bugs/agent): a line and words, scrubbed of paths, emails and keys before it leaves, the harness as the
+// agent, --dry-run sending nothing. The host (native.ts bug: raea's version, the OS, curl) is faked: this is the
+// command's side; the server has its own test.
+import { describe, expect, test } from "bun:test";
+import { bugVerb, scrub } from "../src/bug.ts";
+
+function run(args: string[], answer: Record<string, unknown> = { id: "bug_0123456789abcdef", count: 1, known: false }, env: Record<string, string> = {}) {
+ const ops: { op: string; b: Record<string, unknown> }[] = [];
+ const ask = (op: string, b: Record<string, unknown>) => {
+ ops.push({ op, b });
+ if (op === "harness") return { name: "claude-code" };
+ return b.dry ? { sent: { ...(b.report as object), raea: "0.1.5" } } : answer;
+ };
+ return { out: bugVerb(ask, args, env), ops, sent: () => ops.find((o) => o.op === "bug")!.b };
+}
+
+describe("raea bug", () => {
+ test("a report needs a line and --text", () => {
+ expect(() => run(["render hangs"])).toThrow(/--text/);
+ expect(() => run(["--text", "it hangs"])).toThrow(/a line saying what's wrong/);
+ });
+
+ test("it sends the line, the words, the command and the error, with the harness as the agent", () => {
+ const r = run(["render", "hangs", "at", "frame", "12", "--text", "Rendered a teaser; it stopped.", "--command", "raea render t.tsx", "--error", "frame 12/240"]);
+ expect(r.sent()).toEqual({ report: { title: "render hangs at frame 12", text: "Rendered a teaser; it stopped.", command: "raea render t.tsx", error: "frame 12/240", agent: "claude-code" }, dry: false });
+ expect(r.out).toContain("Sent to raea as bug_0123456789abcdef");
+ // RAEA_AGENT or --agent name it instead
+ expect((run(["x y", "--text", "z"], undefined, { RAEA_AGENT: "codex" }).sent().report as { agent: string }).agent).toBe("codex");
+ expect((run(["x y", "--text", "z", "--agent", "kimi"]).sent().report as { agent: string }).agent).toBe("kimi");
+ });
+
+ test("paths, emails and keys are taken out before it leaves", () => {
+ const r = run(["render of /Users/you/Client Work/cut.tsx hangs", "--text", "Mail [email protected]; key sk-live1234567890abcdefXYZ; file ~/Movies/a.mov", "--error", "panicked at /Users/you/raea/src/x.rs:12"]);
+ const sent = JSON.stringify(r.sent());
+ for (const s of ["/Users/", "[email protected]", "sk-live", "Client Work", "~/Movies"]) expect(sent).not.toContain(s);
+ expect(sent).toContain("<path>");
+ expect(sent).toContain("<email>");
+ expect(sent).toContain("<secret>");
+ // raea's own files keep where in raea they are
+ expect(scrub("at /Applications/raea.app/Contents/MacOS/raea")).toContain("raea.app/Contents/MacOS/raea");
+ });
+
+ test("--dry-run sends nothing and prints what would go", () => {
+ const r = run(["render hangs", "--text", "words", "--dry-run"]);
+ expect(r.sent().dry).toBe(true);
+ expect(r.out).toContain("nothing sent");
+ expect(r.out).toContain('"raea": "0.1.5"');
+ });
+
+ test("the same bug again says it was counted; a refusal says where else to report", () => {
+ expect(run(["a b", "--text", "c"], { id: "bug_0123456789abcdef", count: 3, known: true }).out).toContain("counted, 3 reports now");
+ expect(() => run(["a b", "--text", "c"], { status: 429, message: "This machine has sent 5 reports today" })).toThrow(/429.*5 reports today.*github.com/);
+ });
+});
diff --git a/engine/cli/src/bug.ts b/engine/cli/src/bug.ts
new file mode 100644
index 00000000..c34a65aa
--- /dev/null
+++ b/engine/cli/src/bug.ts
@@ -0,0 +1,64 @@
+// `raea bug`: an agent tells raea about a bug it thinks it found in raea itself (Shane 11-16: "a way for the agent to
+// safely submit bug reports to our server ... any time an agent using raea even headlessly outside the app can report
+// a bug it thinks it found in raea"). It goes to raea's own server (raea.io/v1/bugs/agent), words only, with no
+// account needed: raea's version and the Mac's OS are added, and paths, emails and anything shaped like a key are
+// taken out here, before it leaves (the server takes them out again). The same bug sent again is counted on the first
+// report. --dry-run prints what would go and sends nothing. The host (op "bug", native.ts) adds the version and sends.
+
+type Ask = (op: string, args: Record<string, unknown>) => any;
+
+export const BUG_USAGE = `raea bug TITLE... --text TEXT [--command CMD] [--error TEXT] [--agent NAME] [--dry-run]
+ TITLE: what's wrong, in a line. TEXT: what you did, what you expected, what happened. CMD: the raea command that
+ went wrong. --error: what it printed. A bug in raea itself (a command that fails or hangs, a wrong result, help that says one thing while raea does
+ another), not in your own composition. Words only; paths, emails and keys are taken out before it's sent. Five a day
+ from one machine; the same bug again is counted on the first report.
+`;
+
+/** What an agent wrote, safe to send: a path (/Users/..., ~/...) as <path>, an email as <email>, a key or token as
+ * <secret>. The server (apps/site/api src/bugs.ts scrubAgent) does the same again. */
+export function scrub(text: string): string {
+ return text
+ .replace(/\b(?:Bearer|token|key|secret|password)\s*[:=]?\s*["']?[A-Za-z0-9._~+/=-]{12,}["']?/gi, "<secret>")
+ .replace(/\b(?:sk|pk|rk|ghp|gho|ghs|github_pat|xox[abpr]|AKIA|AIza)[-_A-Za-z0-9]{10,}/g, "<secret>")
+ .replace(/\b[A-Za-z0-9+/_-]{32,}={0,2}/g, (m) => (/[0-9]/.test(m) && /[A-Za-z]/.test(m) ? "<secret>" : m))
+ .replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "<email>")
+ .replace(/(?:file:\/\/)?(?:~|\/(?:Users|home|private|var|tmp|Volumes|opt))\/[^\s'"`()<>,;]*(?: [^\s'"`()<>,;/]+\/[^\s'"`()<>,;]*)*/g, (p) => {
+ const i = p.indexOf("raea.app/Contents/");
+ return i >= 0 ? p.slice(i) : "<path>";
+ });
+}
+
+const flagOf = (args: string[], name: string) => {
+ const i = args.indexOf(name);
+ return i >= 0 ? args[i + 1] : undefined;
+};
+const BARE = new Set(["--dry-run"]);
+const plain = (args: string[]) => args.filter((a, i) => !a.startsWith("--") && (!args[i - 1]?.startsWith("--") || BARE.has(args[i - 1])));
+
+export function bugVerb(ask: Ask, args: string[], env: Record<string, string | undefined> = {}): string {
+ const title = plain(args).join(" ").trim();
+ const text = flagOf(args, "--text")?.trim();
+ if (!title || !text) throw new Error(`a report needs a line saying what's wrong and --text saying what you did, what you expected and what happened.\n${BUG_USAGE}`);
+ const harness = (() => {
+ try {
+ return (ask("harness", {}) as { name?: string } | undefined)?.name;
+ } catch {
+ return undefined;
+ }
+ })();
+ const opt = (s: string | undefined, n: number) => (s?.trim() ? scrub(s.trim()).slice(0, n) : undefined);
+ const report = {
+ title: scrub(title).slice(0, 160),
+ text: scrub(text).slice(0, 4000),
+ command: opt(flagOf(args, "--command"), 300),
+ error: opt(flagOf(args, "--error"), 4000),
+ agent: flagOf(args, "--agent") ?? env.RAEA_AGENT ?? harness,
+ };
+ const dry = args.includes("--dry-run");
+ const r = ask("bug", { report, dry }) as { sent?: Record<string, unknown>; id?: string; count?: number; known?: boolean; status?: number; message?: string };
+ if (dry) return `Would send to raea (nothing sent):\n${JSON.stringify(r.sent ?? report, null, 2)}\n`;
+ if (!r.id) throw new Error(`raea's server didn't take it${r.status ? ` (${r.status})` : ""}: ${r.message ?? "no answer"}. github.com/shinyobjectz/raea/issues takes it too.`);
+ return r.known
+ ? `Sent: raea already had this one (${r.id}); it's counted, ${r.count} reports now. Thank you.\n`
+ : `Sent to raea as ${r.id}. Thank you. What was sent:\n${JSON.stringify(r.sent ?? report, null, 2)}\n`;
+}
diff --git a/engine/cli/src/cli.rs b/engine/cli/src/cli.rs
index db2f68b8..3d31ecc8 100644
--- a/engine/cli/src/cli.rs
+++ b/engine/cli/src/cli.rs
@@ -138,6 +138,8 @@ pub fn run(args: &[String]) -> R<String> {
let usage = format!("{usage}\n raea clothes [make NAME [\"WHAT IT IS\"] [--plain] [--set PATH=VALUE,...] [--colour #RRGGBB] | settings | cover NAME --parts PART[:SHARE],... --colour #RRGGBB [--stand MM] [--over UNDER] [--hard [--sole MM] [--sole-colour #RRGGBB] [--panels #RRGGBB,...]] | wear OUT_DIR GARMENT... [--body DIR] [--head HEAD_DIR]] (clothes for SOMA's body from words: make sews a garment: a sewing pattern (GarmentCode, MIT) from the words, or the plain base with --plain, its settings changed by --set PATH=VALUE (settings lists them and what each may be), cut to SOMA's measurements, draped by raea's own cloth and baked, as assets/clothes/NAME.json and its .glb, in --colour or the palette's next; the first make sets up GarmentCode and its Python in raea's models folder; cover makes one by procedure in the same file, no picture: the skin of the parts named (hips, waist, torso, chest, neck, head, upperArm, foreArm, hand, thigh, shin, foot, toes; a limb's SHARE is how far along it from its top), in one colour, MM off the skin (6 unless said), --over a garment already made as the one under it; wear puts garments on a body, innermost first (each GARMENT a name or its .json): OUT_DIR/NAME.glb each, with OUT_DIR/body.glb the body without the skin wholly under cloth; --body DIR another SOMA body folder (a headless one for a head part); --head HEAD_DIR the head that joins it (head.json), whose skin the body's is graded to at the collar; alone, the project's garments. The first use fetches SOMA's body (NVlabs/SOMA-X, Apache-2.0) into raea's models folder and needs Blender: raea setup blender)");
// body motion made on this Mac by Kimodo on MLX (docs/character.feature CH15c): apps/tools/src/motion.rs
let usage = format!("{usage}\n {} ({})", tools::motion::USAGE, tools::motion::ABOUT);
+ // an agent's report of a bug in raea itself, to raea's server (engine/cli/src/bug.ts; Shane 11-16)
+ let usage = format!("{usage}\n raea bug TITLE... --text TEXT [--command CMD] [--error TEXT] [--agent NAME] [--dry-run] (a bug in raea itself, not in your own composition, sent to raea's server with raea's version and the OS, no account needed: words only, paths, emails and keys taken out before it goes; five a day from a machine, the same bug again counted on the first report; --dry-run prints what would go and sends nothing)");
// a workspace's files and specs (docs/projects.feature), listed under render's usage like library
let usage = format!("{usage}\n raea spec FILE.ts [--as brief|script|taste|plan|controller] (a spec's default export as JSON, checked against its schema: brief.ts, script.ts, taste.ts, plan.ts, controllers/ID.ts)\n raea workspace init [NAME] [--layout LAYOUT] | raea workspace adopt DIR [--name NAME] | raea workspace [--json] (a workspace: a git repo of projects and controllers under raea.root, ~/Documents/raea unless git config says)\n raea project new NAME [--storage inline|submodule] | raea project split NAME [--remote URL] | raea project join NAME | raea project [--json] (a project in the workspace: its folder, brief.ts, media/, out/; split and join keep its history)\n raea controller ls [--json] | raea controller get PATH [--json] | raea controller set PATH VALUE [--project] [--by NAME] | raea controller write FILE.ts [--by NAME] | raea controller rm ID [--by NAME] (the workspace's controllers, controllers/ID.ts; PATH is controller.group.field; every change a commit)\n raea check EDIT.tsx --quick [--shape S] [--platform P] [--taste T] [-o check.json] (three stills of a composition checked for text: clipped, cramped, safe areas, sizes; about a second)\n raea hook [claude|codex|gemini|kimi] (every agent's tool hooks, which raea skills install adds: before a shell command, media opened in the Mac's viewer while the raea app is installed is stopped once for raea show (the same command again goes through); after a save, the quick check on a composition)\n raea next [DIR] (the two or three useful next steps for the project, from its brief, compositions, renders and checks)\n raea doctor [--fix] [DIR] (what doesn't match this raea: old brief files, an older workspace format, an agent's skill from another version)\n raea app run|check|bundle APP.tsx [--target web|native] [--size WxH] [--script steps.json] [--png DIR] [-o App.app] (a TSX app on @raea/ui: its window, the headless check, a Mac app; web is Blitz on Bevy, native is Rune; the app's `export const app` sets the target, web when it doesn't; raea rune ... is --target native)\n {}\n {}\n {}\n {}\n {}", skill::USAGE, tools::blender::USAGE, raea_app_engines::godot::USAGE, raea_app_engines::shot::USAGE, raea_app_engines::round::USAGE);
let (export_game, capcut, scene, physics, splat) = (raea_app_game::USAGE, raea_app_capcut::USAGE, export::SCENE_USAGE, motion::physics::USAGE, tools::splat::USAGE);
diff --git a/engine/cli/src/index.ts b/engine/cli/src/index.ts
index 18615bdf..64969e6c 100644
--- a/engine/cli/src/index.ts
+++ b/engine/cli/src/index.ts
@@ -27,6 +27,8 @@ import { libraryVerb } from "./library";
import { showVerb } from "./show";
// `raea clothes` (clothes.ts): garments for SOMA's body from words
import { clothesVerb } from "./clothes";
+// `raea bug` (bug.ts): an agent's report of a bug in raea, to raea's server
+import { bugVerb } from "./bug";
function flag(args: string[], name: string): string | undefined {
const i = args.indexOf(name);
@@ -267,6 +269,8 @@ export function raeaHandler(host?: Host, engine?: Engine) {
return out(showVerb(ask, args.slice(1), c.cwd, (globalThis as { process?: { env: Record<string, string | undefined> } }).process?.env ?? {}));
case "clothes":
return out(clothesVerb(ask, args.slice(1)));
+ case "bug":
+ return out(bugVerb(ask, args.slice(1), (globalThis as { process?: { env: Record<string, string | undefined> } }).process?.env ?? {}));
default:
return await native();
}
diff --git a/engine/cli/src/native.ts b/engine/cli/src/native.ts
index 578c291f..15f0f20b 100644
--- a/engine/cli/src/native.ts
+++ b/engine/cli/src/native.ts
@@ -304,6 +304,27 @@ function frame(a: { take: string; at?: number }): string {
return lines.join("\n");
}
+/** `raea bug`'s report (bug.ts) to raea's server, with raea's version and the OS added; RAEA_API names the server
+ * (https://raea.io, where raea's server takes reports). No account: the server takes a report from anyone. */
+function bug(a: { report: Record<string, unknown>; dry?: boolean }) {
+ const version = (spawnSync(raea, ["--version"], { encoding: "utf8" }).stdout ?? "").trim().split(/\s+/).pop() || undefined;
+ const mac = process.platform === "darwin" ? (spawnSync("sw_vers", ["-productVersion"], { encoding: "utf8" }).stdout ?? "").trim() : "";
+ const sent = { ...a.report, raea: version, os: mac ? `macOS ${mac}` : `${process.platform} ${process.arch}` };
+ if (a.dry) return { sent };
+ const api = (process.env.RAEA_API ?? "https://raea.io").replace(/\/$/, "");
+ const r = spawnSync("curl", ["-sS", "--max-time", "20", "-X", "POST", "-H", "content-type: application/json", "--data-binary", "@-", "-w", "\n%{http_code}", `${api}/v1/bugs/agent`], { input: JSON.stringify(sent), encoding: "utf8" });
+ const text = r.stdout ?? "";
+ const cut = text.lastIndexOf("\n");
+ const status = Number(text.slice(cut + 1)) || 0;
+ let answer: { id?: string; count?: number; known?: boolean; message?: string } = {};
+ try {
+ answer = JSON.parse(text.slice(0, cut));
+ } catch {
+ answer = { message: (r.stderr ?? "").trim() || text.slice(0, 200) };
+ }
+ return { ...answer, status, sent };
+}
+
/** One request by curl (the host steps are synchronous): its body and where it ended up, or why it failed */
function curl(url: string, o: { out?: string; secs?: number } = {}): { body: string; url: string } {
// a browser's agent: some sites send a bare page, or none, to anything else
@@ -391,6 +412,8 @@ const host: Host = (op, a) => {
return show(a);
case "clothes":
return clothesHost(raea, cwd, process.env, a);
+ case "bug":
+ return bug(a as { report: Record<string, unknown>; dry?: boolean });
case "harness":
return harness();
case "task":
diff --git a/engine/cli/src/verbs.rs b/engine/cli/src/verbs.rs
index 13050d68..8bb5f698 100644
--- a/engine/cli/src/verbs.rs
+++ b/engine/cli/src/verbs.rs
@@ -96,7 +96,7 @@ pub fn mezz(args: &[String]) -> R<String> {
/// The agent shell's own verbs (engine/cli/src/index.ts) this binary runs; the rest come one by one (docs/agent-surfaces.md)
-pub const SHELL: &[&str] = &["init", "cut", "frame", "component", "part", "brand", "library", "show", "clothes"];
+pub const SHELL: &[&str] = &["init", "cut", "frame", "component", "part", "brand", "library", "show", "clothes", "bug"];
/// One of SHELL's verbs: @raea/cli's handler, run by engine/cli/src/native.ts on raea's JavaScriptCore with Node's core, so the
/// verb's one source is its TypeScript. native.ts answers the host's ops it needs, and runs this binary for the engine's verbs.
diff --git a/tools/manual-ref/cli.ts b/tools/manual-ref/cli.ts
index e5e3fb99..0c05f46b 100644
--- a/tools/manual-ref/cli.ts
+++ b/tools/manual-ref/cli.ts
@@ -31,7 +31,7 @@ const GROUPS: [string, string, string[]][] = [
["Footage", "Takes, cuts and the camera, from your own media.", ["media", "cut", "frame", "track", "splat", "mezz", "neural"]],
["Sound", "Music read, foley and instruments made on this machine.", ["song", "sounds", "sao", "tokensynth", "setup-audio"]],
["Generate and 3D tools", "Generated media, physics bakes, clothes and motion for SOMA's body, Blender and Godot.", ["gen", "physics", "clothes", "motion", "blender", "godot"]],
- ["Agents and setup", "What an agent reads and shows the person, and the tools raea installs.", ["guide", "context", "notes", "show", "skill", "skills", "setup"]],
+ ["Agents and setup", "What an agent reads and shows the person, and the tools raea installs.", ["guide", "context", "notes", "show", "skill", "skills", "setup", "bug"]],
]
/** A verb's page: VERB.md, but index.md is this section's own page, so raea index's is indexer.md */
const pageOf = (verb: string) => (verb === "index" ? "indexer.md" : `${verb}.md`)