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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
raea show --fyi/--group; notes reach closed sessions through raea's hook (#263)
shaneea5640de8f82
diff --git a/apps/check/inbox/src/lib.rs b/apps/check/inbox/src/lib.rsindex a462b979..5d7a8d3b 100644--- a/apps/check/inbox/src/lib.rs+++ b/apps/check/inbox/src/lib.rs@@ -55,6 +55,11 @@ fn said(l: &Value) -> String {"result" => format!("a result{on}: {text}"),"correction" => format!("a correction{on}: {text}"),"sign" => format!("a sign-off{on} (ask {})", l["ask"]),+ // a show only to be looked at (raea show --fyi), looked at: Got it, with a word or none+ "seen" => {+ let word = text.strip_prefix("Seen").unwrap_or(&text).trim_start_matches(':').trim();+ if word.is_empty() { format!("seen{on}") } else { format!("seen{on}: {word}") }+ }k => format!("{}{on}: {text}", if k.is_empty() { "something" } else { k }),};format!("- {what}")@@ -68,6 +73,17 @@ pub fn told(agent: &str, v: &Value) -> Option<String> {return None;}let list = lines.iter().map(said).collect::<Vec<_>>().join("\n");+ // only Got it on what was shown to look at: nothing to take up+ if !lines.iter().any(|l| l["kind"] != "seen") {+ return Some(format!("raea: the person has looked at what you showed them (your inbox, ~/.raea/inbox/{inbox}.jsonl):\n{list}\nNothing to do about it; carry on."));+ }+ // a session started again (resumed) after the person wrote to it while it was closed (Shane 11-28: "notes reach+ // closed sessions"): what waited is handed over before anything else+ if v["hook_event_name"].as_str() == Some("SessionStart") {+ return Some(format!(+ "raea: while this session was closed, the person sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up first, before anything else. Answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."+ ));+ }Some(format!("raea: the person just sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up now, before going on: it may change what you're doing. What you say next shows under your session in their feed; answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."))@@ -78,11 +94,17 @@ mod tests {use super::*;use serde_json::json;- #[test]- fn each_line_is_handed_over_once_and_a_half_written_one_waits() {- let d = std::env::temp_dir().join(format!("raea-inbox-{}", std::process::id()));+ /// an empty inbox folder of the test's own+ fn scratch(tag: &str) -> std::path::PathBuf {+ let d = std::env::temp_dir().join(format!("raea-inbox-{tag}-{}", std::process::id()));let _ = std::fs::remove_dir_all(&d);std::fs::create_dir_all(&d).unwrap();+ d+ }++ #[test]+ fn each_line_is_handed_over_once_and_a_half_written_one_waits() {+ let d = scratch("once");let f = d.join("claude-code-abcd1234.jsonl");std::fs::write(&f, "{\"kind\":\"message\",\"text\":\"more epic\"}\n{\"kind\":\"no").unwrap();let first = unread(&d, "claude-code-abcd1234");@@ -97,6 +119,25 @@ mod tests {let _ = std::fs::remove_dir_all(&d);}+ #[test]+ fn seen_is_said_as_seen_and_asks_nothing() {+ assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen"})), "- seen on item i-2 \"Lobby\"");+ assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen: lovely"})), "- seen on item i-2 \"Lobby\": lovely");+ }++ #[test]+ fn what_waited_while_it_was_closed_is_handed_over_as_it_starts_again() {+ let d = scratch("start");+ std::fs::write(d.join("claude-code-5e55a0ff.jsonl"), "{\"kind\":\"edits\",\"item\":\"i-9\",\"title\":\"Cut\",\"text\":\"tighter open\"}\n").unwrap();+ // SAFETY: tests in this crate don't read RAEA_INBOX_DIR concurrently+ unsafe { std::env::set_var("RAEA_INBOX_DIR", &d) };+ let start = told("claude", &json!({"hook_event_name": "SessionStart", "source": "resume", "session_id": "5e55a0ff-1"})).unwrap();+ assert!(start.starts_with("raea: while this session was closed") && start.contains("- edits on item i-9 \"Cut\":\ntighter open"), "{start}");+ assert_eq!(told("claude", &json!({"hook_event_name": "UserPromptSubmit", "session_id": "5e55a0ff-1"})), None, "handed over once");+ unsafe { std::env::remove_var("RAEA_INBOX_DIR") };+ let _ = std::fs::remove_dir_all(&d);+ }+#[test]fn the_inbox_is_named_as_raea_show_names_it() {assert_eq!(name("claude", &json!({"session_id": "15cd6bb0-8829-466f-a28a-bbca3d35be92"})).as_deref(), Some("claude-code-15cd6bb0"));diff --git a/apps/check/src/hook.rs b/apps/check/src/hook.rsindex a049abb8..4faf27b3 100644--- a/apps/check/src/hook.rs+++ b/apps/check/src/hook.rs@@ -148,7 +148,13 @@ pub fn hook(args: &[String]) -> R<String> {let event = v["hook_event_name"].as_str().unwrap_or("");// what the person sent from the raea app since the last look (inbox.rs): handed over after any tool, and a turn about// to end goes on to take it up- let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop") { crate::inbox::told(agent, &v) } else { None };+ let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop" | "SessionStart" | "UserPromptSubmit") { crate::inbox::told(agent, &v) } else { None };+ // a session starting again, or the person writing to it in its terminal: what they sent from raea while it was+ // closed or idle goes in as context first (Claude Code's and Codex's SessionStart and UserPromptSubmit read+ // hookSpecificOutput.additionalContext)+ if matches!(event, "SessionStart" | "UserPromptSubmit") {+ return Ok(sent.map(|t| json!({"hookSpecificOutput": {"hookEventName": event, "additionalContext": t}}).to_string()).unwrap_or_default());+ }if event == "Stop" {// what the person sent, and a `make` job that isn't done (docs/make.feature MK2): either keeps the turn goinglet reasons: Vec<String> = [sent, raea_app_check_make::stop(&v)].into_iter().flatten().collect();diff --git a/apps/tools/src/agent_hooks.rs b/apps/tools/src/agent_hooks.rsindex 394d5120..b405bc6b 100644--- a/apps/tools/src/agent_hooks.rs+++ b/apps/tools/src/agent_hooks.rs@@ -21,8 +21,10 @@ struct Hook {fn hooks(agent: &str) -> R<Vec<Hook>> {let h = |event, matcher, secs| Hook { event, matcher, secs };Ok(match agent {- "claude" => vec![h("PreToolUse", "Bash", 30), h("PostToolUse", "*", 60), h("Stop", "", 30)],- "codex" => vec![h("PreToolUse", "^(Bash|shell|shell_command|exec_command)$", 30), h("PostToolUse", "^(apply_patch|Edit|Write)$", 60)],+ // SessionStart and UserPromptSubmit: notes sent from raea while the session was closed or idle reach it when it+ // starts again or is next written to (Shane 11-28: "notes reach closed sessions")+ "claude" => vec![h("PreToolUse", "Bash", 30), h("PostToolUse", "*", 60), h("Stop", "", 30), h("SessionStart", "", 10), h("UserPromptSubmit", "", 10)],+ "codex" => vec![h("PreToolUse", "^(Bash|shell|shell_command|exec_command)$", 30), h("PostToolUse", "^(apply_patch|Edit|Write)$", 60), h("Stop", "", 30), h("SessionStart", "", 10), h("UserPromptSubmit", "", 10)],"gemini" => vec![h("BeforeTool", "run_shell_command", 30), h("AfterTool", "write_file|replace", 60)],"kimi" => vec![h("PreToolUse", "Bash|Shell", 30), h("PostToolUse", "Write|Edit|WriteFile|StrReplaceFile", 60)],a => return Err(format!("no agent {a:?}: claude, codex, kimi or gemini")),@@ -124,7 +126,8 @@ mod tests {let c = d.join("claude/settings.json");std::fs::create_dir_all(c.parent().unwrap()).unwrap();std::fs::write(&c, r#"{"model":"x","hooks":{"PostToolUse":[{"matcher":"Bash","hooks":[{"type":"command","command":"other"}]},{"matcher":"Write","hooks":[{"type":"command","command":"raea hook claude"}]}]}}"#).unwrap();- let [pre, post, stop] = <[Hook; 3]>::try_from(hooks("claude").unwrap()).ok().unwrap();+ let [pre, post, stop, start, prompt] = <[Hook; 5]>::try_from(hooks("claude").unwrap()).ok().unwrap();+ assert!(add_json(&c, "claude", &start).unwrap() && add_json(&c, "claude", &prompt).unwrap() && !add_json(&c, "claude", &start).unwrap());assert!(add_json(&c, "claude", &pre).unwrap() && !add_json(&c, "claude", &pre).unwrap());assert!(add_json(&c, "claude", &post).unwrap() && !add_json(&c, "claude", &post).unwrap(), "an older raea's after-save hook is widened to every tool, once");assert!(add_json(&c, "claude", &stop).unwrap() && !add_json(&c, "claude", &stop).unwrap());@@ -133,6 +136,9 @@ mod tests {assert_eq!((v["hooks"]["PostToolUse"][0]["matcher"].as_str(), v["hooks"]["PostToolUse"][1]["matcher"].as_str()), (Some("Bash"), Some("*")));assert_eq!(v["hooks"]["PreToolUse"][0]["hooks"][0]["command"], "raea hook claude");assert_eq!(v["hooks"]["Stop"][0]["hooks"][0]["command"], "raea hook claude");+ assert_eq!(v["hooks"]["SessionStart"][0]["hooks"][0]["command"], "raea hook claude");+ assert_eq!(v["hooks"]["UserPromptSubmit"][0]["hooks"][0]["command"], "raea hook claude");+ assert_eq!(hooks("codex").unwrap().iter().map(|h| h.event).collect::<Vec<_>>(), ["PreToolUse", "PostToolUse", "Stop", "SessionStart", "UserPromptSubmit"]);let g = d.join("gemini/settings.json");let [before, _] = <[Hook; 2]>::try_from(hooks("gemini").unwrap()).ok().unwrap();assert!(add_json(&g, "gemini", &before).unwrap());diff --git a/engine/cli/conformance/show.test.ts b/engine/cli/conformance/show.test.tsindex 26109a64..43d13f8e 100644--- a/engine/cli/conformance/show.test.ts+++ b/engine/cli/conformance/show.test.ts@@ -110,3 +110,41 @@ describe("labelsIn", () => {expect(() => labelsIn('{"text":"a"}', "l.json")).toThrow(/--labels l.json is a list of labels/);});});++// Shane 11-28: "some things I'm not approving, I'm just acknowledging"; "the agent can go 'let me add a label here'".+// --fyi and --group go to the host (apps/app host/show.ts ShowBody.intent, .groups), which hands them to the review.+describe("raea show --fyi and --group", () => {+ const run = (args: string[]) => {+ const ops: [string, Record<string, unknown>][] = [];+ const ask = (op: string, b: Record<string, unknown>) => {+ ops.push([op, b]);+ if (op === "harness") return { name: "Claude Code", pid: 7 };+ return { kind: "item", id: "i-1", type: "look", title: "Lobby", project: "shop", workspace: "Work", inbox: "/inbox.jsonl" };+ };+ const out = showVerb(ask, args, "/work/shop", { CLAUDECODE: "1", CLAUDE_CODE_SESSION_ID: "abcdef123" });+ return { out, body: ops.find(([op]) => op === "show")?.[1] };+ };++ test("--fyi sends a look-only show, and says nothing waits on it", () => {+ const { out, body } = run(["lobby.png", "--fyi"]);+ expect(body).toMatchObject({ intent: "fyi", files: ["/work/shop/lobby.png"] });+ expect(out).toContain(`{"kind":"seen"}`);+ expect(run(["lobby.png"]).body?.intent).toBeUndefined();+ });++ test("each --group holds the files after it, titled before the colon and said after it", () => {+ const { body } = run(["--group", "Day: sun through the doors", "a.png", "b.png", "--group", "Night", "c.png", "--title", "Lobby"]);+ expect(body?.files).toEqual(["/work/shop/a.png", "/work/shop/b.png", "/work/shop/c.png"]);+ expect(body?.groups).toEqual([+ { title: "Day", says: "sun through the doors", files: ["/work/shop/a.png", "/work/shop/b.png"] },+ { title: "Night", files: ["/work/shop/c.png"] },+ ]);+ expect(run(["a.png"]).body?.groups).toBeUndefined();+ });++ test("a group with no files, or --fyi on a question, is refused", () => {+ expect(() => run(["a.png", "--group", "Empty"])).toThrow(/has no files/);+ expect(() => run(["--group", ": no title", "a.png"])).toThrow(/is a title/);+ expect(() => run(["--question", "Which?", "--choice", "A", "--choice", "B", "--fyi"])).toThrow(/--fyi/);+ });+});diff --git a/engine/cli/src/show.ts b/engine/cli/src/show.tsindex 384b0ba6..11dc0240 100644--- a/engine/cli/src/show.ts+++ b/engine/cli/src/show.ts@@ -27,6 +27,12 @@ raea show [--title T] --question Q1 [--preview FILE] --choice A [--preview FILE]lists them), a folder in the project, or a Copy reference from the app; a title only when it's the only one andthis folder isn't in another project. Else the one this folder is in. Who's showing it: --as NAME [--role ROLE][--inbox NAME], else your harness's.+raea show FILE... --fyi+ Only for the person to look at, nothing to approve: they say Got it (you hear {"kind":"seen"}), and anything they+ want to say back comes through the chat. Without it a show is a version for them to approve or send notes on.+raea show --group "Day: sun through the doors" A.png B.png --group "Night: practicals only" C.png [--title T]+ Lay the files out in groups the person sees side by side, each titled before the colon and said after it in a plain+ line (never shorthand); the files after a --group are its own. Keep it short: enough to know what each group is.raea show FILE... --despite CHECK "why"A render that still holds an error (raea findings --open lists them) isn't shown: fix it and render again, or saywhy it goes anyway, once per check; the person reads the why on the item. One let through at the render (raea render@@ -50,8 +56,8 @@ raea show FILE... --replaces ITEM --done ID...closes when the person retires it, never with --done. raea notes post sends all of these from the notes.`;-const WITH_VALUE = new Set(["--despite", "--label", "--detail", "--labels", "--title", "--ask", "--project", "--replaces", "--as", "--role", "--inbox", "--question", "--choice", "--preview", "--on", "--working", "--done", "--note", "--sub", "--status", "--states", "--sign", "--clip", "--render"]);-const FLAGS = new Set(["--open"]);+const WITH_VALUE = new Set(["--group", "--despite", "--label", "--detail", "--labels", "--title", "--ask", "--project", "--replaces", "--as", "--role", "--inbox", "--question", "--choice", "--preview", "--on", "--working", "--done", "--note", "--sub", "--status", "--states", "--sign", "--clip", "--render"]);+const FLAGS = new Set(["--open", "--fyi"]);/** The harness an agent runs in, named as the feed shows it, from the program that started this command (native.ts* walks up its parents): any harness, not only the ones that mark their shells. */@@ -84,6 +90,8 @@ const hash = (s: string) => {return h.toString(36);};+const marking = (args: string[]) => args.includes("--working") || args.includes("--done");+export function parseShow(args: string[], cwd: string) {const one = (name: string) => {const i = args.lastIndexOf(name);@@ -95,7 +103,19 @@ export function parseShow(args: string[], cwd: string) {if (unknown) throw new Error(`no ${unknown} here\n${SHOW_USAGE}`);const abs = (f: string) => fromCwd(cwd, f);// --despite takes two: the check, then why- const files = args.filter((a, i) => !a.startsWith("--") && !WITH_VALUE.has(args[i - 1] ?? "") && args[i - 2] !== "--despite").map(abs);+ const isFile = (a: string, i: number) => !a.startsWith("--") && !WITH_VALUE.has(args[i - 1] ?? "") && args[i - 2] !== "--despite";+ const files = args.filter(isFile).map(abs);+ // the groups in order: each --group "Title: what it is" holds the files after it, up to the next --group+ const groups: { title: string; says?: string; files: string[] }[] = [];+ args.forEach((a, i) => {+ if (a === "--group" && args[i + 1] !== undefined) {+ const [title, ...rest] = args[i + 1].split(":");+ if (!title.trim()) throw new Error(`--group "${args[i + 1]}" is a title, then what it is after a colon: --group "Night: practicals only"\n${SHOW_USAGE}`);+ groups.push({ title: title.trim(), ...(rest.join(":").trim() ? { says: rest.join(":").trim() } : {}), files: [] });+ } else if (groups.length && isFile(a, i)) groups.at(-1)!.files.push(abs(a));+ });+ const empty = groups.find((g) => !g.files.length);+ if (empty) throw new Error(`the group "${empty.title}" has no files: put its files after its --group\n${SHOW_USAGE}`);const despite = args.flatMap((a, i) => {if (a !== "--despite") return [];const [check, why] = [args[i + 1], args[i + 2]];@@ -134,7 +154,8 @@ export function parseShow(args: string[], cwd: string) {if ((labels.length || args.includes("--labels")) && (!files.length || questions || asked.length)) throw new Error(`labels go on the files you show: raea show FILE --label "PLACE TAG"\n${SHOW_USAGE}`);if (labels.length && args.includes("--labels")) throw new Error(`--label or --labels, not both\n${SHOW_USAGE}`);if (questions && files.length) throw new Error(`with several questions or previews, each file is a --preview of the question or choice it shows\n${SHOW_USAGE}`);- return { labels, labelsFile: one("--labels"), files, despite, choices, questions, open: args.includes("--open"), title: one("--title"), ask: one("--ask"), asks: many("--ask"), project: one("--project"), replaces: one("--replaces"), question: questions ? undefined : one("--question"), as: one("--as"), role: one("--role"), inbox: one("--inbox"), on: one("--on"), working: many("--working"), done: many("--done"), note: one("--note"), sub: one("--sub"), status: one("--status"), states: one("--states")?.split(",").map((s) => s.trim()).filter(Boolean), sign: one("--sign"), clip: one("--clip"), render: one("--render") };+ if (args.includes("--fyi") && (asked.length || marking(args))) throw new Error(`--fyi shows files only to be looked at: a question, or marking comments, is answered\n${SHOW_USAGE}`);+ return { groups, fyi: args.includes("--fyi"), labels, labelsFile: one("--labels"), files, despite, choices, questions, open: args.includes("--open"), title: one("--title"), ask: one("--ask"), asks: many("--ask"), project: one("--project"), replaces: one("--replaces"), question: questions ? undefined : one("--question"), as: one("--as"), role: one("--role"), inbox: one("--inbox"), on: one("--on"), working: many("--working"), done: many("--done"), note: one("--note"), sub: one("--sub"), status: one("--status"), states: one("--states")?.split(",").map((s) => s.trim()).filter(Boolean), sign: one("--sign"), clip: one("--clip"), render: one("--render") };}/** A --labels file's labels, as feed_post takes them: a list, or { "labels": [...] } (raea media sheet's OUT.labels.json). */@@ -189,7 +210,7 @@ export function showVerb(ask: Ask, args: string[], cwd: string, env: Record<striif (a.done.length && !a.replaces) throw new Error(`--done with files settles comments on the item they replace: add --replaces ITEM\n${SHOW_USAGE}`);if (a.labelsFile !== undefined && !listed) throw new Error(`--labels ${a.labelsFile}: its labels weren't read (raea's own handler reads the file)`);const labels = a.labels.length ? a.labels : listed;- const r = ask("show", { ...(labels?.length ? { labels } : {}), files: a.files, despite: a.despite, title: a.title, ask: askWith(a.ask, a.despite), question: a.question, choices: a.choices, questions: a.questions, open: a.open, project: a.project, replaces: a.replaces, cwd, by }) as+ const r = ask("show", { ...(labels?.length ? { labels } : {}), ...(a.fyi ? { intent: "fyi" } : {}), ...(a.groups.length ? { groups: a.groups } : {}), files: a.files, despite: a.despite, title: a.title, ask: askWith(a.ask, a.despite), question: a.question, choices: a.choices, questions: a.questions, open: a.open, project: a.project, replaces: a.replaces, cwd, by }) as| { opened: string[] }| { kind: "item" | "composition"; id: string; type: string; title: string; project: string; workspace: string; inbox: string; brought?: boolean };if ("opened" in r) return `The raea app isn't on this Mac, so ${r.opened.length === 1 ? "it opened" : `${r.opened.length} files opened`} in the Mac's own viewer: nothing was posted and nothing comes back. Install raea (raea.io) to show work as items the person can answer.\n`;@@ -213,7 +234,9 @@ export function showVerb(ask: Ask, args: string[], cwd: string, env: Record<stri? `Shown in the raea app: "${r.title}" (${r.type}, item ${r.id}, project ${r.project} in ${r.workspace}); the window is on it.`: `Posted in the raea app: "${r.title}" (${r.type}, item ${r.id}, project ${r.project} in ${r.workspace}), with a notice; the window stayed where the person is.`,...settled,- `What the person sends on it (notes, edits, picks, answers, results) comes to ${inbox}, one JSON line each. Follow it (tail -n0 -F ${inbox}, or your harness's monitor) and answer each; a next version is raea show --replaces ${r.id} FILE.`,+ a.fyi+ ? `Only to look at: when they've seen it, {"kind":"seen"} comes to ${inbox}; nothing to wait for.`+ : `What the person sends on it (notes, edits, picks, answers, results) comes to ${inbox}, one JSON line each. Follow it (tail -n0 -F ${inbox}, or your harness's monitor) and answer each; a next version is raea show --replaces ${r.id} FILE.`,"",].join("\n");}