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.

SK13: raea-cli stays under its 2000 lines (origin/main had it at 1999). Where each agent reads skills moves to apps/tools agent_skills.rs (folder, agents, AGENTS), beside agent_mcp, agent_hooks and agent_grokbot; raea skills install and raea doctor read it there. Grok Bot's install step is agent_grokbot::stage: the preface in the staged SKILL.md, refused over the 256 KB Grok Bot's Add new skill takes (MAX_SKILL), and the links; its test moves with it, and raea-cli's skill test checks the shipped SKILL.md with its preface fits. The preface is written in with_preface, its one caller, and ask takes the folder (both were structural twins of other code: dupes). raea-cli 1975 lines; cargo check -p raea-app-tools -p raea-cli --tests passes; the unit tests weren't run here (a debug test build of apps/tools needs the whole engine, about 15 GB, and filled the disk)

shinyobjectz0ed836095e74
diff --git a/apps/tools/src/agent_grokbot.rs b/apps/tools/src/agent_grokbot.rs
index 808f22ee..b2202fd1 100644
--- a/apps/tools/src/agent_grokbot.rs
+++ b/apps/tools/src/agent_grokbot.rs
@@ -30,20 +30,34 @@ pub fn app() -> Option<PathBuf> {
[Some(PathBuf::from("/Applications")), home.map(|h| h.join("Applications"))].into_iter().flatten().map(|d| d.join("Grok Bot.app")).find(|a| a.join("Contents/Info.plist").is_file())
}
-/// What the staged SKILL.md says first, after its front matter: raea runs on the person's Mac, not on the Bot's computer.
-pub fn preface(dir: &Path) -> String {
- format!(
- "> **On Grok Bot.** raea runs on the person's Mac, not on your computer. Run every `raea` command there, and read\n> every file this skill links (3d.md, reference/cli.md and the rest) from its copy there, in {}, both\n> with Run a command on your local computer (the person turns on Settings → Computer → Execution on this computer).\n> No raea MCP server or hook is set up for you: after saving a composition run `raea check EDIT.tsx --quick` yourself,\n> and `raea show FILE` puts media in front of the person.\n",
- dir.join("raea").display()
- )
+/// The largest SKILL.md Grok Bot's Skills → Add new skill → Upload file takes, in bytes (256 KB).
+pub const MAX_SKILL: usize = 256_000;
+
+/// After `raea skills install --agent grokbot` has copied raea's skills into `dir` (`said`, what it said doing so): the
+/// preface in raea's SKILL.md, and the links that finish it. A linked folder is the person's, left as it is. Grok Bot
+/// gets no hooks (it has none) and no MCP server (its command would run on the Bot's own computer, not this Mac).
+pub fn stage(dir: &Path, said: String) -> R<String> {
+ let md = dir.join("raea/SKILL.md");
+ if !dir.join("raea").is_symlink() && let Ok(text) = std::fs::read_to_string(&md) {
+ let text = with_preface(&text, dir);
+ if text.len() >= MAX_SKILL {
+ return Err(format!("{}: {} KB, more than the 256 KB Grok Bot's Add new skill takes", md.display(), text.len() / 1000));
+ }
+ std::fs::write(&md, text).map_err(|e| format!("{}: {e}", md.display()))?;
+ }
+ Ok(format!("{said}{}", finish(dir)))
}
-/// SKILL.md with the preface after its front matter (or first, when it has none); a copy that has one keeps only one.
+/// SKILL.md with the preface after its front matter (or first, when it has none): raea runs on the person's Mac, not on
+/// the Bot's computer. A copy that has one keeps only one.
pub fn with_preface(text: &str, dir: &Path) -> String {
- let p = preface(dir);
if text.contains("> **On Grok Bot.**") {
return text.to_string();
}
+ let p = format!(
+ "> **On Grok Bot.** raea runs on the person's Mac, not on your computer. Run every `raea` command there, and read\n> every file this skill links (3d.md, reference/cli.md and the rest) from its copy there, in {}, both\n> with Run a command on your local computer (the person turns on Settings → Computer → Execution on this computer).\n> No raea MCP server or hook is set up for you: after saving a composition run `raea check EDIT.tsx --quick` yourself,\n> and `raea show FILE` puts media in front of the person.\n",
+ dir.join("raea").display()
+ );
let Some(rest) = text.strip_prefix("---\n") else { return format!("{p}\n{text}") };
let Some(end) = rest.find("\n---\n") else { return format!("{p}\n{text}") };
let (front, body) = (&rest[..end], rest[end + 5..].trim_start_matches('\n'));
@@ -60,9 +74,11 @@ pub fn link(route: &str, key: &str, value: &str) -> String {
format!("grokbot://app/v1/{route}?{key}={}", encode(value))
}
-/// The message to the Bot that makes the skill: at most 1000 characters, as its prompt link takes.
-pub fn ask(skill_md: &Path) -> String {
- format!("Please make a private skill named raea from the file {} on my Mac: read it with Run a command on your local computer and keep its text as it is. raea runs on my Mac, so run every raea command there.", skill_md.display())
+/// The message to the Bot that makes the skill from the copy staged in `dir`: at most 1000 characters, as its prompt
+/// link takes.
+fn ask(dir: &Path) -> String {
+ let md = dir.join("raea/SKILL.md");
+ format!("Please make a private skill named raea from the file {} on my Mac: read it with Run a command on your local computer and keep its text as it is. raea runs on my Mac, so run every raea command there.", md.display())
}
/// What `raea skills install --agent grokbot` says once the copy is staged: where it is, and the links that finish it.
@@ -76,7 +92,7 @@ pub fn finish(dir: &Path) -> String {
"{here} It keeps its skills on its own computer and its MCP servers on your account, so the copy waits here: {}. No hooks, and no MCP server: Grok Bot runs a server's command on its computer, where the blender server can't reach this Mac's Blender.\nTo finish, in Grok Bot, signed in:\n 1. turn on Execution on this computer: {}\n 2. send the message this fills in, and the Bot makes the skill from the copy: {}\n or by hand: Skills → Add new skill → Upload file → {}\n`open LINK` opens a link in Grok Bot",
dir.display(),
link("settings", "id", "local-execution"),
- link("prompt", "text", &ask(&md)),
+ link("prompt", "text", &ask(dir)),
md.display()
)
}
@@ -101,11 +117,27 @@ mod tests {
assert_eq!(link("settings", "id", "local-execution"), "grokbot://app/v1/settings?id=local-execution");
assert_eq!(link("prompt", "text", "a b/ü&+=?#'()"), "grokbot://app/v1/prompt?text=a%20b%2F%C3%BC%26%2B%3D%3F%23'()");
// its prompt route takes at most 1000 characters of text in a link of at most 2048, with no format characters
- let a = ask(Path::new("/h/a-home-folder-with-a-rather-long-name/.raea/grokbot/skills/raea/SKILL.md"));
+ let a = ask(Path::new("/h/a-home-folder-with-a-rather-long-name/.raea/grokbot/skills"));
assert!(a.chars().count() <= 1000 && link("prompt", "text", &a).len() <= 2048, "{a}");
assert!(a.chars().all(|c| !c.is_control() && !('\u{200B}'..='\u{200F}').contains(&c) && !('\u{202A}'..='\u{202E}').contains(&c)));
}
+ #[test]
+ fn stage_prefaces_the_copy_once_and_refuses_one_too_big_to_upload() {
+ let d = std::env::temp_dir().join(format!("raea-grokbot-stage-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&d);
+ std::fs::create_dir_all(d.join("raea")).unwrap();
+ std::fs::write(d.join("raea/SKILL.md"), "---\nname: raea\nversion: 1\n---\n\n# raea\n").unwrap();
+ let out = stage(&d, "copied\n".into()).unwrap();
+ assert!(out.starts_with("copied\n") && out.contains("grokbot://app/v1/prompt?text="), "{out}");
+ stage(&d, String::new()).unwrap();
+ let md = std::fs::read_to_string(d.join("raea/SKILL.md")).unwrap();
+ assert_eq!(md.matches("> **On Grok Bot.**").count(), 1, "{md}");
+ std::fs::write(d.join("raea/SKILL.md"), "x".repeat(MAX_SKILL)).unwrap();
+ assert!(stage(&d, String::new()).unwrap_err().contains("256 KB"));
+ let _ = std::fs::remove_dir_all(&d);
+ }
+
#[test]
fn finish_says_where_the_copy_is_and_both_links() {
let f = finish(Path::new("/h/.raea/grokbot/skills"));
diff --git a/apps/tools/src/agent_skills.rs b/apps/tools/src/agent_skills.rs
new file mode 100644
index 00000000..ca791174
--- /dev/null
+++ b/apps/tools/src/agent_skills.rs
@@ -0,0 +1,43 @@
+//! Where each agent `raea skills install` knows reads a person's skills, one folder per skill holding SKILL.md. Checked
+//! by hand on 11-05: claude: ~/.claude/skills (Claude Code's docs); codex: ~/.agents/skills
+//! (developers.openai.com/codex/skills, the user scope; older builds read ~/.codex/skills); kimi: $KIMI_CODE_HOME/skills,
+//! else ~/.kimi-code/skills (kimi 2.3.3's own binary; it also reads ~/.agents/skills and ~/.claude/skills); gemini:
+//! ~/.gemini/skills (geminicli.com/docs/cli/skills). grokbot (11-14): Grok Bot reads no folder here, so its copy is
+//! staged in raea's own (agent_grokbot.rs).
+use std::path::PathBuf;
+
+/// The agents, in the order `raea doctor` and the usage name them.
+pub const AGENTS: [&str; 5] = ["claude", "codex", "kimi", "gemini", "grokbot"];
+
+/// The folder `agent` reads skills from.
+pub fn folder(agent: &str) -> Result<PathBuf, String> {
+ let home = crate::agent_mcp::user_home()?;
+ Ok(match agent {
+ "claude" => home.join(".claude/skills"),
+ "codex" => home.join(".agents/skills"),
+ "kimi" => std::env::var_os("KIMI_CODE_HOME").filter(|v| !v.is_empty()).map(PathBuf::from).unwrap_or_else(|| home.join(".kimi-code")).join("skills"),
+ "gemini" => home.join(".gemini/skills"),
+ "grokbot" => crate::agent_grokbot::skills_dir()?,
+ a => return Err(format!("no agent {a:?}: claude, codex, kimi, gemini or grokbot")),
+ })
+}
+
+/// Each agent and the folder it reads skills from, for `raea doctor` (an agent with no folder is skipped).
+pub fn agents() -> Vec<(&'static str, PathBuf)> {
+ AGENTS.into_iter().filter_map(|a| folder(a).ok().map(|t| (a, t))).collect()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn each_agent_has_its_folder() {
+ assert!(folder("claude").unwrap().ends_with(".claude/skills"));
+ assert!(folder("codex").unwrap().ends_with(".agents/skills"));
+ assert!(folder("gemini").unwrap().ends_with(".gemini/skills"));
+ assert_eq!(folder("grokbot").unwrap(), crate::agent_grokbot::skills_dir().unwrap());
+ assert!(folder("cursor").is_err());
+ assert_eq!(agents().len(), AGENTS.len());
+ }
+}
diff --git a/apps/tools/src/lib.rs b/apps/tools/src/lib.rs
index 93eb3504..280caf4b 100644
--- a/apps/tools/src/lib.rs
+++ b/apps/tools/src/lib.rs
@@ -13,5 +13,7 @@ pub mod agent_mcp;
pub mod agent_hooks;
/// Grok Bot as a `raea skills install` target: its copy staged on this Mac, and the links that finish it in Grok Bot
pub mod agent_grokbot;
+/// where each agent reads a person's skills
+pub mod agent_skills;
/// `raea setup blender` and `raea blender run`
pub mod blender;
diff --git a/engine/cli/src/guide.rs b/engine/cli/src/guide.rs
index 61d41334..eb54ace7 100644
--- a/engine/cli/src/guide.rs
+++ b/engine/cli/src/guide.rs
@@ -64,7 +64,7 @@ pub fn context(project: Option<&str>) -> R<String> {
let dir = brief_path.parent().unwrap_or(Path::new(".")).to_path_buf();
let taste_dir = raea_app_direction::check::taste_dir();
// a cheap doctor (file reads and git config): CONTEXT_STALE when this project or the agent's skill is from another raea
- let stale = raea_app_workspace::doctor::findings(&dir, &skill::agents(), &skill::version());
+ let stale = raea_app_workspace::doctor::findings(&dir, &tools::agent_skills::agents(), &skill::version());
let stale = match stale.first() {
Some(f) => format!("CONTEXT_STALE raea doctor finds {} thing(s), first: {} (raea doctor --fix)\n\n", stale.len(), f.says),
None => String::new(),
@@ -82,7 +82,7 @@ pub fn next(args: &[String]) -> R<String> {
let brief_path = brief_at(args.first().map(String::as_str).unwrap_or("."))?;
let l = spec::load_brief_ts(&brief_path)?;
let dir = brief_path.parent().unwrap_or(Path::new(".")).to_path_buf();
- let stale = raea_app_workspace::doctor::findings(&dir, &skill::agents(), &skill::version()).len();
+ let stale = raea_app_workspace::doctor::findings(&dir, &tools::agent_skills::agents(), &skill::version()).len();
Ok(raea_app_workspace::next::text(&dir, &raea_app_workspace::next::Brief { needs: l.missing, modes: l.modes }, stale))
}
diff --git a/engine/cli/src/skill.rs b/engine/cli/src/skill.rs
index 0600a222..208bcb45 100644
--- a/engine/cli/src/skill.rs
+++ b/engine/cli/src/skill.rs
@@ -6,32 +6,10 @@ use super::*;
pub const USAGE: &str = "raea skill [NAME] [--reference cli|feed|files|sdk] | raea skills install --agent claude|codex|kimi|gemini|grokbot [--pin MOVE]... [--no-mcp] [--no-hooks] (the agent skill this raea ships, for its version, which raea --version prints: an agent whose copy names another version reads this; install puts raea's skills where that agent reads skills, adds the blender MCP server unless --no-mcp, makes each --pin MOVE a /MOVE of its own, and adds raea's hooks to that agent unless --no-hooks (raea hook AGENT: media opened in the Mac's viewer goes to raea show, and the quick check after a composition is saved); a skill folder that's a link is left as it is; grokbot, the Grok Bot app, keeps its skills on its own computer, so its copy is staged on this Mac (RAEA_GROKBOT_HOME moves it) with the grokbot:// links that finish it in Grok Bot, and gets no hooks or MCP server)";
-/// Where each agent reads a person's skills, one folder per skill holding SKILL.md. Checked by hand on 11-05:
-/// claude: ~/.claude/skills (Claude Code's docs); codex: ~/.agents/skills (developers.openai.com/codex/skills, the user
-/// scope; older builds read ~/.codex/skills); kimi: $KIMI_CODE_HOME/skills, else ~/.kimi-code/skills (kimi 2.3.3's own
-/// binary; it also reads ~/.agents/skills and ~/.claude/skills); gemini: ~/.gemini/skills (geminicli.com/docs/cli/skills).
-/// grokbot (11-14): Grok Bot reads no folder here (apps/tools agent_grokbot.rs), so its copy is staged in raea's own.
-fn target(agent: &str) -> R<PathBuf> {
- let home = tools::agent_mcp::user_home()?;
- Ok(match agent {
- "claude" => home.join(".claude/skills"),
- "codex" => home.join(".agents/skills"),
- "kimi" => std::env::var_os("KIMI_CODE_HOME").filter(|v| !v.is_empty()).map(PathBuf::from).unwrap_or_else(|| home.join(".kimi-code")).join("skills"),
- "gemini" => home.join(".gemini/skills"),
- "grokbot" => tools::agent_grokbot::skills_dir()?,
- a => return Err(format!("no agent {a:?}: claude, codex, kimi, gemini or grokbot")),
- })
-}
-
-/// Each agent and the folder it reads skills from, for `raea doctor` (an agent with no folder is skipped).
-pub fn agents() -> Vec<(&'static str, PathBuf)> {
- ["claude", "codex", "kimi", "gemini", "grokbot"].into_iter().filter_map(|a| target(a).ok().map(|t| (a, t))).collect()
-}
-
/// `raea doctor [--fix] [DIR]` (SK10): what doesn't match this raea, an agent's skill reinstalled by --fix.
pub fn doctor(args: &[String]) -> R<String> {
let again = |agent: &str| install(&["install".into(), "--agent".into(), agent.into(), "--no-mcp".into()]);
- raea_app_workspace::doctor::doctor(args, &agents(), &version(), &again)
+ raea_app_workspace::doctor::doctor(args, &tools::agent_skills::agents(), &version(), &again)
}
/// This raea's version: the release's (share/raea/VERSION), or the crate's for a build from a checkout.
@@ -111,11 +89,7 @@ pub fn install(args: &[String]) -> R<String> {
return Err(format!("usage: {USAGE}"));
}
let agent = args.iter().position(|a| a == "--agent").and_then(|i| args.get(i + 1)).ok_or("which agent: --agent claude|codex|kimi|gemini|grokbot")?;
- install_into(agent, &target(agent)?, args)
-}
-
-/// `skills install` for one agent into its skills folder `to`.
-fn install_into(agent: &str, to: &Path, args: &[String]) -> R<String> {
+ let to = tools::agent_skills::folder(agent)?;
let (from, v) = (shipped()?, version());
let mut out = String::new();
for name in installed_names()? {
@@ -136,18 +110,11 @@ fn install_into(agent: &str, to: &Path, args: &[String]) -> R<String> {
for (i, a) in args.iter().enumerate() {
if a == "--pin" {
let m = args.get(i + 1).ok_or("--pin takes a move: quieter, bolder, layout, adapt...")?;
- out += &tools::agent_mcp::pin(to, m, &v)?;
- }
- }
- // Grok Bot (SK13): its copy says where raea runs, and the links finish it there; it has no hooks, and an MCP
- // server's command would run on its own computer, not this Mac. A linked folder is the person's: left as it is.
- if agent == "grokbot" {
- let md = to.join("raea/SKILL.md");
- if !to.join("raea").is_symlink() && let Ok(text) = std::fs::read_to_string(&md) {
- std::fs::write(&md, tools::agent_grokbot::with_preface(&text, to)).map_err(|e| format!("{}: {e}", md.display()))?;
+ out += &tools::agent_mcp::pin(&to, m, &v)?;
}
- return Ok(format!("{out}{}", tools::agent_grokbot::finish(to)));
}
+ // Grok Bot (SK13): no hooks or MCP server; its copy gets a preface and the links that finish it (agent_grokbot.rs)
+ if agent == "grokbot" { return tools::agent_grokbot::stage(&to, out); }
// every agent's hooks (A5d, SK10), in its own config: --no-hooks leaves it alone
if !args.iter().any(|a| a == "--no-hooks") { out += &tools::agent_hooks::install(agent)?; }
// the MCP servers raea offers (SK11): blender, for a running Blender; --no-mcp leaves the agent's servers alone
@@ -177,33 +144,7 @@ mod tests {
assert!(skill(&["raea-bevy".into()]).unwrap_err().contains("3d.md") && installed_names().unwrap() == ["raea"]);
assert!(skill(&["../x".into()]).is_err());
assert!(skill(&["--reference".into(), "../../x".into()]).is_err());
- }
-
- #[test]
- fn install_targets_each_agents_folder() {
- assert!(target("claude").unwrap().ends_with(".claude/skills"));
- assert!(target("codex").unwrap().ends_with(".agents/skills"));
- assert!(target("gemini").unwrap().ends_with(".gemini/skills"));
- assert_eq!(target("grokbot").unwrap(), tools::agent_grokbot::skills_dir().unwrap());
- assert!(target("cursor").is_err());
- assert!(agents().iter().any(|(a, _)| *a == "grokbot"));
- }
-
- #[test]
- fn grokbot_gets_a_staged_copy_with_its_preface_and_no_hooks_or_mcp() {
- let d = std::env::temp_dir().join(format!("raea-grokbot-skills-{}", std::process::id()));
- let _ = std::fs::remove_dir_all(&d);
- let args: Vec<String> = ["install", "--agent", "grokbot", "--pin", "quieter"].map(String::from).to_vec();
- let out = install_into("grokbot", &d, &args).unwrap();
- let md = std::fs::read_to_string(d.join("raea/SKILL.md")).unwrap();
- assert!(md.starts_with("---\nname: raea\n") && md.contains(&format!("\nversion: {}\n---\n\n> **On Grok Bot.**", version())), "{}", &md[..400.min(md.len())]);
- assert!(md.len() < 256_000, "Grok Bot's Add new skill takes a file of at most 256 KB");
- assert!(d.join("raea/reference/cli.md").is_file() && d.join("quieter/SKILL.md").is_file());
- assert!(out.contains("grokbot://app/v1/settings?id=local-execution") && out.contains("grokbot://app/v1/prompt?text="), "{out}");
- assert!(!out.contains("hooks `raea hook") && !out.contains("MCP server blender added"), "{out}");
- // again: the copy is replaced, and its preface is there once
- install_into("grokbot", &d, &args).unwrap();
- assert_eq!(std::fs::read_to_string(d.join("raea/SKILL.md")).unwrap().matches("> **On Grok Bot.**").count(), 1);
- let _ = std::fs::remove_dir_all(&d);
+ // Grok Bot's Add new skill takes a file of at most 256 KB: the shipped SKILL.md with its preface fits
+ assert!(tools::agent_grokbot::with_preface(&core, Path::new("/h")).len() < tools::agent_grokbot::MAX_SKILL);
}
}