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.

DR3: the record and raea findings find the project from a bare file name; a clip's span counts its last frame; gen check says a fitted copy's fix as what to run; raea next's page says what it reads from the record

shinyobjectzc98501a88ffb
diff --git a/apps/direction/src/findings.rs b/apps/direction/src/findings.rs
index 9969b2c6..d0afdd74 100644
--- a/apps/direction/src/findings.rs
+++ b/apps/direction/src/findings.rs
@@ -67,8 +67,12 @@ fn standing(reports: &[Value]) -> Vec<Finding> {
/// `raea findings ...` (args from "findings").
pub fn cli(args: &[String]) -> Result<String, String> {
+ if args.iter().any(|a| a == "--help" || a == "-h") {
+ return Ok(USAGE.into());
+ }
let target = args.get(1).filter(|a| !a.starts_with("--")).map_or_else(|| PathBuf::from("."), PathBuf::from);
- let from = if target.is_file() { target.parent().unwrap_or(Path::new(".")).to_path_buf() } else { target.clone() };
+ // made absolute first: a bare name's parent is "", which names no folder
+ let from = if target.is_file() { target.canonicalize().unwrap_or_else(|_| target.clone()).parent().map_or_else(|| PathBuf::from("."), Path::to_path_buf) } else { target.clone() };
let project = record::up(&from, ".raea/project").ok_or_else(|| format!("raea findings: {} isn't in a raea project (no .raea/project at or above it), so nothing is recorded\n{USAGE}", target.display()))?;
let (about, check, since) = (flag(args, "--about"), flag(args, "--check"), flag(args, "--since"));
let keep = |f: &Finding| about.as_deref().is_none_or(|n| f.about.iter().any(|a| a.name == n || a.key.as_deref() == Some(n))) && check.as_deref().is_none_or(|c| f.check == c);
diff --git a/core/facts/src/record.rs b/core/facts/src/record.rs
index 239fc89a..a79fc145 100644
--- a/core/facts/src/record.rs
+++ b/core/facts/src/record.rs
@@ -75,7 +75,8 @@ fn commit(project: &Path, of: &str) -> Option<String> {
/// What `by` found of `file` (writing `out`) kept in its project's record, named by `stamp` (UTC, 20261110-161530)
/// and the file's name: the entry, or None outside a project.
pub fn keep(by: &str, file: &Path, out: Option<&Path>, findings: &[Finding], despite: Vec<Despite>, stamp: &str) -> Option<Entry> {
- let project = up(file.parent().unwrap_or(Path::new(".")), ".raea/project")?;
+ // made absolute first: a bare name's parent is "", which names no folder
+ let project = up(real(file).parent()?, ".raea/project")?;
let dir = project.join(".raea/record");
std::fs::create_dir_all(&dir).ok()?;
let at = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs()).unwrap_or(0);
diff --git a/docs/manual/reference/cli/next.md b/docs/manual/reference/cli/next.md
index 51aa68ed..fd365672 100644
--- a/docs/manual/reference/cli/next.md
+++ b/docs/manual/reference/cli/next.md
@@ -2,13 +2,19 @@
title: "raea next"
summary: "The two or three most useful next steps for a project, read from its brief, compositions, renders and checks."
order: 47
-sources: ["apps/workspace/src/next.rs"]
+sources: ["apps/workspace/src/next.rs", "core/facts/src/record.rs"]
---
-`raea next` reads a project's files (what its brief still needs, the storyboard its modes want, its compositions,
-the renders in `out/` and their checks) and prints the two or three steps worth doing next. It's a menu for the agent
+`raea next` reads a project's files (what its brief still needs, the storyboard its modes want, its compositions)
+and its record of renders and checks, and prints the two or three steps worth doing next. It's a menu for the agent
or the person to pick from; nothing runs.
+The record (`.raea/record/`, which every `raea render` and `raea check` of a file in the project writes) decides the
+step after a composition exists. Never rendered: render stills first. Changed since its last render: render again.
+Its last render found an error: fix it, naming the error and the render that found it. Otherwise the video is next,
+then its `raea check`, then whatever that check found, and with nothing found, showing it to the person.
+[`raea findings`](findings.md) lists what each render found.
+
```sh
raea next
raea next ~/Documents/raea/acme/projects/spring-launch
diff --git a/io/gen/src/fit.rs b/io/gen/src/fit.rs
index 07fbd132..0a2893d2 100644
--- a/io/gen/src/fit.rs
+++ b/io/gen/src/fit.rs
@@ -35,6 +35,7 @@ fn as_findings(mut r: J) -> J {
if let Some(cut) = f.fix.as_ref().and_then(|x| f.says.strip_suffix(&format!("; fix: {x}"))) {
f.says = cut.to_string();
}
+ f.fix = f.fix.map(|x| fitted(&x).unwrap_or(x));
if f.about.is_empty() { f.about(&file, None) } else { f }
})
.collect(),
@@ -49,6 +50,19 @@ fn as_findings(mut r: J) -> J {
r
}
+/// A fix the fitted copy makes (meshcheck's `{"origin"}`, `{"scale"}`, `{"turn"}`), said as what to run.
+fn fitted(fix: &str) -> Option<String> {
+ let v: J = serde_json::from_str(fix).ok()?;
+ let does = if v.get("origin").is_some() {
+ "puts its origin at the bottom centre".to_string()
+ } else if let Some(s) = v["scale"].as_f64() {
+ format!("scales it by {s}")
+ } else {
+ format!("turns it {}° about y", v["turn"].as_f64()?)
+ };
+ Some(format!("run this check again with -o FIXED.glb, which {does}"))
+}
+
/// Whether a report holds an error.
fn failed(r: &J) -> bool {
r["findings"].as_array().into_iter().flatten().any(|f| f["level"] == "error")
@@ -146,3 +160,19 @@ pub fn after_run(flow: &Flow, result: &mut J) {
result["checks"] = J::Object(checks);
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn a_fix_the_fitted_copy_makes_is_said_as_what_to_run() {
+ let r = as_findings(json!({"file": "chair.glb", "found": [
+ {"check": "pivot", "level": "warning", "says": "its origin is off; fix: {\"origin\":\"bottom centre\"}", "fix": {"origin": "bottom centre"}},
+ {"check": "facing", "level": "ok", "says": "fine"}]}));
+ let f = &r["findings"][0];
+ assert_eq!((f["says"].as_str(), f["about"][0]["name"].as_str()), (Some("its origin is off"), Some("chair.glb")));
+ assert_eq!(f["fix"].as_str(), Some("run this check again with -o FIXED.glb, which puts its origin at the bottom centre"));
+ assert_eq!((r["count"].as_str(), r.get("found").is_none()), (Some("0 errors, 1 warn, 0 notes"), true));
+ }
+}
diff --git a/systems/contact/src/found.rs b/systems/contact/src/found.rs
index 8737065b..41ca82c1 100644
--- a/systems/contact/src/found.rs
+++ b/systems/contact/src/found.rs
@@ -37,7 +37,8 @@ pub fn clip_findings(found: &[Value], by: &str) -> Vec<Finding> {
.iter()
.map(|v| {
let at = |k: &str| v[k].as_i64().unwrap_or(0);
- let mut f = Finding::new("clips", Level::Error, v["says"].as_str().unwrap_or_default(), by).frames(at("from"), at("to"));
+ // the check's "to" is the last frame it clips on; a finding's span ends one past it
+ let mut f = Finding::new("clips", Level::Error, v["says"].as_str().unwrap_or_default(), by).frames(at("from"), at("to") + 1);
for k in ["part", "into"] {
if let Some(name) = v[k].as_str() {
f = f.about(name, None);
@@ -78,6 +79,7 @@ mod tests {
fn an_overlap_is_an_error_about_both_parts_over_its_frames() {
let found = vec![json!({"from": 40, "to": 52, "part": "rider", "into": "seat", "depth": 0.04, "share": 0.2, "move": {"axis": "y", "by": 0.05}, "says": "rider passes 40 mm into seat"})];
let f = &clip_findings(&found, "raea render")[0];
- assert_eq!(f.line(), "error clips frames 40-51 rider, seat: rider passes 40 mm into seat (fix: move it +0.050 m along y)");
+ // frames 40 to 52, the last included
+ assert_eq!(f.line(), "error clips frames 40-52 rider, seat: rider passes 40 mm into seat (fix: move it +0.050 m along y)");
}
}