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.

The refusal's reason is read in one place (raea-app-judge's why_refused, which raea make uses): two copies put raea-app-make over its size limit

shinyobjectzafa6702c05ca
diff --git a/apps/judge/src/lib.rs b/apps/judge/src/lib.rs
index 7f87dcf3..7cacf0d9 100644
--- a/apps/judge/src/lib.rs
+++ b/apps/judge/src/lib.rs
@@ -229,7 +229,7 @@ mod tests;
/// Why `raea spec` refused a brief, in its own words: its refusal is the last line it printed, on whichever stream
/// (a REFUSED line goes to stdout, a thrown module's error to stderr). Reading stderr alone left the reason empty.
-fn why_refused(out: &std::process::Output) -> String {
+pub fn why_refused(out: &std::process::Output) -> String {
let last = |b: &[u8]| String::from_utf8_lossy(b).lines().rev().find(|l| !l.trim().is_empty()).map(|l| l.trim().trim_start_matches("REFUSED").trim().to_string());
last(&out.stderr).or_else(|| last(&out.stdout)).unwrap_or_else(|| "raea spec printed nothing".into())
}
diff --git a/apps/make/src/lib.rs b/apps/make/src/lib.rs
index fa1de4ca..4f7d2761 100644
--- a/apps/make/src/lib.rs
+++ b/apps/make/src/lib.rs
@@ -58,7 +58,7 @@ pub fn read_make(brief: &Path) -> Result<Option<Make>, String> {
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
let out = std::process::Command::new(exe).arg("spec").arg(brief).args(["--as", "brief"]).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
let text = String::from_utf8_lossy(&out.stdout);
- let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), why_refused(&out)))?;
+ let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), raea_app_judge::why_refused(&out)))?;
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("{}: {e}", brief.display()))?;
let b = v.get("brief").cloned().unwrap_or(v);
match b.get("make") {
@@ -212,10 +212,3 @@ pub fn cli(args: &[String]) -> Result<String, String> {
mod tests;
#[cfg(test)]
mod tests_steps;
-
-/// Why `raea spec` refused a brief, in its own words: its refusal is the last line it printed, on whichever stream
-/// (a REFUSED line goes to stdout, a thrown module's error to stderr). Reading stderr alone left the reason empty.
-fn why_refused(out: &std::process::Output) -> String {
- let last = |b: &[u8]| String::from_utf8_lossy(b).lines().rev().find(|l| !l.trim().is_empty()).map(|l| l.trim().trim_start_matches("REFUSED").trim().to_string());
- last(&out.stderr).or_else(|| last(&out.stdout)).unwrap_or_else(|| "raea spec printed nothing".into())
-}