mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-06 05:33:38 -10:00
Compare commits
1
Commits
span-inks
...
forma-tool
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
917d41b12a |
No files matched your search
Generated
+10
@@ -13801,6 +13801,7 @@ name = "raea-app-engines"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dunce",
|
"dunce",
|
||||||
|
"raea-app-forma",
|
||||||
"raea-app-interchange",
|
"raea-app-interchange",
|
||||||
"raea-app-tools",
|
"raea-app-tools",
|
||||||
"raea-io-home",
|
"raea-io-home",
|
||||||
@@ -13829,6 +13830,14 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "raea-app-forma"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"raea-io-home",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "raea-app-game"
|
name = "raea-app-game"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -14064,6 +14073,7 @@ name = "raea-app-tools"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dunce",
|
"dunce",
|
||||||
|
"raea-app-forma",
|
||||||
"raea-app-motion",
|
"raea-app-motion",
|
||||||
"raea-io-assets",
|
"raea-io-assets",
|
||||||
"raea-io-gen",
|
"raea-io-gen",
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ members = [
|
|||||||
"apps/tools",
|
"apps/tools",
|
||||||
"apps/motion",
|
"apps/motion",
|
||||||
"apps/engines",
|
"apps/engines",
|
||||||
|
"apps/forma",
|
||||||
"apps/interchange",
|
"apps/interchange",
|
||||||
"apps/judge",
|
"apps/judge",
|
||||||
"apps/make",
|
"apps/make",
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ description = "The `raea` verbs that script other engines from TypeScript: Blend
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
# Blender found or downloaded, its scripts in Python, and the helpers Godot's setup shares (apps/tools/src/blender.rs)
|
# Blender found or downloaded, its scripts in Python, and the helpers Godot's setup shares (apps/tools/src/blender.rs)
|
||||||
raea-app-tools = { path = "../tools" }
|
raea-app-tools = { path = "../tools" }
|
||||||
|
# forma, a headless modeller (GPL-3.0-or-later), downloaded and run as its own program, its .glb fixed after (apps/forma)
|
||||||
|
raea-app-forma = { path = "../forma" }
|
||||||
raea-io-home = { path = "../../io/home" }
|
raea-io-home = { path = "../../io/home" }
|
||||||
# a TypeScript script bundled and run on raea's engine, posting raea/blender's batches to the bridge (blender.post)
|
# a TypeScript script bundled and run on raea's engine, posting raea/blender's batches to the bridge (blender.post)
|
||||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||||
|
|||||||
+10
-2
@@ -1,6 +1,8 @@
|
|||||||
//! The verbs that script other engines from TypeScript: Blender (`raea setup blender`, `raea blender run SCRIPT.py|.ts`;
|
//! The verbs that script other engines from TypeScript: Blender (`raea setup blender`, `raea blender run SCRIPT.py|.ts`;
|
||||||
//! finding and setting Blender up is apps/tools/src/blender.rs) and Godot with GodotJS (`raea setup godot`,
|
//! finding and setting Blender up is apps/tools/src/blender.rs) and Godot with GodotJS (`raea setup godot`,
|
||||||
//! `raea godot run|types|open`; sdk/blender and sdk/godot are their TypeScript sides).
|
//! `raea godot run|types|open`; sdk/blender and sdk/godot are their TypeScript sides). forma, a headless modeller for
|
||||||
|
//! hard-surface parts, runs the same way: downloaded, run as its own program, never linked (`raea setup forma`,
|
||||||
|
//! `raea forma`; apps/forma).
|
||||||
|
|
||||||
/// the Blender a TypeScript script drives (`raea blender run SCRIPT.ts`, sdk/blender)
|
/// the Blender a TypeScript script drives (`raea blender run SCRIPT.ts`, sdk/blender)
|
||||||
pub mod blender_bridge;
|
pub mod blender_bridge;
|
||||||
@@ -16,11 +18,16 @@ pub mod shot;
|
|||||||
pub mod round;
|
pub mod round;
|
||||||
|
|
||||||
use raea_app_tools::blender;
|
use raea_app_tools::blender;
|
||||||
|
/// `raea setup forma` and `raea forma`: forma (GPL-3.0-or-later) downloaded and run as its own program (apps/forma)
|
||||||
|
pub use raea_app_forma as forma;
|
||||||
|
|
||||||
type R<T> = Result<T, String>;
|
type R<T> = Result<T, String>;
|
||||||
|
|
||||||
/// The CLI's verbs here, or None for any other: `setup blender|godot`, `blender ...` and `godot ...`.
|
/// The CLI's verbs here, or None for any other: `setup blender|godot|forma`, `blender ...`, `godot ...` and `forma ...`.
|
||||||
pub fn cli(args: &[String]) -> Option<R<String>> {
|
pub fn cli(args: &[String]) -> Option<R<String>> {
|
||||||
|
if let Some(done) = forma::cli(args) {
|
||||||
|
return Some(done);
|
||||||
|
}
|
||||||
let second = args.get(1).map(String::as_str);
|
let second = args.get(1).map(String::as_str);
|
||||||
Some(match (args.first()?.as_str(), second) {
|
Some(match (args.first()?.as_str(), second) {
|
||||||
("setup", Some("blender")) => blender::setup(&args[2..]),
|
("setup", Some("blender")) => blender::setup(&args[2..]),
|
||||||
@@ -54,5 +61,6 @@ mod tests {
|
|||||||
assert!(cli(&args("render edit.tsx")).is_none());
|
assert!(cli(&args("render edit.tsx")).is_none());
|
||||||
assert!(cli(&[]).is_none());
|
assert!(cli(&[]).is_none());
|
||||||
assert!(cli(&args("godot")).unwrap().unwrap_err().contains(godot::USAGE));
|
assert!(cli(&args("godot")).unwrap().unwrap_err().contains(godot::USAGE));
|
||||||
|
assert!(cli(&args("forma")).is_some());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "raea-app-forma"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
license = "FSL-1.1-ALv2"
|
||||||
|
publish = false
|
||||||
|
description = "`raea setup forma` and `raea forma`: forma (GPL-3.0-or-later) downloaded and run as its own program, its .glb fixed after"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
raea-io-home = { path = "../../io/home" }
|
||||||
|
# the .glb forma writes, read and written back with its colours linear and its normals smoothed (glb.rs)
|
||||||
|
serde_json = "1"
|
||||||
@@ -0,0 +1,340 @@
|
|||||||
|
//! The .glb forma writes, fixed for a renderer that reads glTF as the spec says (docs/forma.feature FM3, FM4). forma
|
||||||
|
//! 0.4.4 writes a material's colour as it was typed (sRGB, as a person picks one) into baseColorFactor, which glTF reads
|
||||||
|
//! as linear, so every colour comes out pale; and it writes one normal per face, so a cylinder shows its facets. The fix
|
||||||
|
//! converts the colours, and gives each corner the mean of the faces around it that meet its own at under `smooth`
|
||||||
|
//! degrees, so a box keeps its edges and a cylinder's side turns round. Only the JSON's colours and the normals' bytes
|
||||||
|
//! change: positions, indices, UVs and the file's layout stay as forma wrote them. A fixed file is marked in
|
||||||
|
//! asset.extras and left alone after, so fixing twice never darkens it twice.
|
||||||
|
use serde_json::{Value, json};
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
type R<T> = Result<T, String>;
|
||||||
|
|
||||||
|
/// The mark a fixed file carries in asset.extras.
|
||||||
|
pub const MARK: &str = "raea_forma";
|
||||||
|
|
||||||
|
const JSON: u32 = 0x4E4F_534A;
|
||||||
|
const BIN: u32 = 0x004E_4942;
|
||||||
|
const FLOAT: u64 = 5126;
|
||||||
|
|
||||||
|
/// What a fix changed.
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct Fixed {
|
||||||
|
/// materials whose colour was made linear
|
||||||
|
pub colours: usize,
|
||||||
|
/// mesh primitives whose normals were smoothed
|
||||||
|
pub primitives: usize,
|
||||||
|
/// the file was fixed before and is unchanged
|
||||||
|
pub already: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fixes a .glb in place (written beside it, then renamed over it).
|
||||||
|
pub fn fix_file(path: &Path, smooth: Option<f32>) -> R<Fixed> {
|
||||||
|
let bytes = std::fs::read(path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||||
|
let (out, fixed) = fix(&bytes, smooth).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||||
|
if !fixed.already {
|
||||||
|
let tmp = path.with_extension("raea-tmp");
|
||||||
|
std::fs::write(&tmp, out).map_err(|e| format!("{}: {e}", tmp.display()))?;
|
||||||
|
std::fs::rename(&tmp, path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||||
|
}
|
||||||
|
Ok(fixed)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The fixed file's bytes. `smooth`: the largest angle in degrees between two faces whose shared corners are smoothed;
|
||||||
|
/// None keeps forma's normals.
|
||||||
|
pub fn fix(glb: &[u8], smooth: Option<f32>) -> R<(Vec<u8>, Fixed)> {
|
||||||
|
let (mut doc, mut bin) = read(glb)?;
|
||||||
|
if doc["asset"]["extras"][MARK].is_object() {
|
||||||
|
return Ok((glb.to_vec(), Fixed { colours: 0, primitives: 0, already: true }));
|
||||||
|
}
|
||||||
|
let colours = linear_colours(&mut doc);
|
||||||
|
let primitives = match smooth {
|
||||||
|
Some(deg) => smooth_normals(&doc, &mut bin, deg)?,
|
||||||
|
None => 0,
|
||||||
|
};
|
||||||
|
let asset = doc.as_object_mut().ok_or("the glTF JSON isn't an object")?.entry("asset").or_insert_with(|| json!({"version": "2.0"}));
|
||||||
|
let extras = asset.as_object_mut().ok_or("asset isn't an object")?.entry("extras").or_insert_with(|| json!({}));
|
||||||
|
if let Some(e) = extras.as_object_mut() {
|
||||||
|
e.insert(MARK.into(), json!({"colours": "linear", "smooth": smooth}));
|
||||||
|
}
|
||||||
|
Ok((write(&doc, &bin), Fixed { colours, primitives, already: false }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The JSON chunk and the BIN chunk (empty when there is none).
|
||||||
|
pub fn read(glb: &[u8]) -> R<(Value, Vec<u8>)> {
|
||||||
|
let u32_at = |at: usize| glb.get(at..at + 4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]]));
|
||||||
|
if glb.get(..4) != Some(b"glTF") || u32_at(4) != Some(2) {
|
||||||
|
return Err("not a glTF 2.0 binary (.glb)".into());
|
||||||
|
}
|
||||||
|
let (len, kind) = (u32_at(12).ok_or("no JSON chunk")? as usize, u32_at(16).ok_or("no JSON chunk")?);
|
||||||
|
let text = glb.get(20..20 + len).filter(|_| kind == JSON).ok_or("the first chunk isn't JSON")?;
|
||||||
|
let doc: Value = serde_json::from_slice(text).map_err(|e| format!("the glTF JSON: {e}"))?;
|
||||||
|
let at = 20 + len;
|
||||||
|
let bin = match (u32_at(at), u32_at(at + 4)) {
|
||||||
|
(Some(n), Some(BIN)) => glb.get(at + 8..at + 8 + n as usize).ok_or("the BIN chunk runs past the file")?.to_vec(),
|
||||||
|
_ => Vec::new(),
|
||||||
|
};
|
||||||
|
Ok((doc, bin))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A .glb of a JSON document and a BIN chunk, each padded to four bytes as glTF asks (the JSON with spaces).
|
||||||
|
pub fn write(doc: &Value, bin: &[u8]) -> Vec<u8> {
|
||||||
|
let mut text = serde_json::to_vec(doc).unwrap_or_default();
|
||||||
|
while !text.len().is_multiple_of(4) {
|
||||||
|
text.push(b' ');
|
||||||
|
}
|
||||||
|
let mut data = bin.to_vec();
|
||||||
|
while !data.len().is_multiple_of(4) {
|
||||||
|
data.push(0);
|
||||||
|
}
|
||||||
|
let total = 12 + 8 + text.len() + if data.is_empty() { 0 } else { 8 + data.len() };
|
||||||
|
let mut out = Vec::with_capacity(total);
|
||||||
|
out.extend_from_slice(b"glTF");
|
||||||
|
out.extend_from_slice(&2u32.to_le_bytes());
|
||||||
|
out.extend_from_slice(&(total as u32).to_le_bytes());
|
||||||
|
out.extend_from_slice(&(text.len() as u32).to_le_bytes());
|
||||||
|
out.extend_from_slice(&JSON.to_le_bytes());
|
||||||
|
out.extend_from_slice(&text);
|
||||||
|
if !data.is_empty() {
|
||||||
|
out.extend_from_slice(&(data.len() as u32).to_le_bytes());
|
||||||
|
out.extend_from_slice(&BIN.to_le_bytes());
|
||||||
|
out.extend_from_slice(&data);
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
|
/// sRGB's transfer undone: the linear value glTF's baseColorFactor holds.
|
||||||
|
pub fn srgb_to_linear(c: f64) -> f64 {
|
||||||
|
if c <= 0.04045 { c / 12.92 } else { ((c + 0.055) / 1.055).powf(2.4) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every material's baseColorFactor made linear (alpha kept); how many there were.
|
||||||
|
fn linear_colours(doc: &mut Value) -> usize {
|
||||||
|
let Some(mats) = doc.get_mut("materials").and_then(Value::as_array_mut) else { return 0 };
|
||||||
|
let mut n = 0;
|
||||||
|
for m in mats {
|
||||||
|
if let Some(c) = m.pointer_mut("/pbrMetallicRoughness/baseColorFactor").and_then(Value::as_array_mut) {
|
||||||
|
for v in c.iter_mut().take(3) {
|
||||||
|
if let Some(x) = v.as_f64() {
|
||||||
|
*v = json!(srgb_to_linear(x));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Where an accessor's elements are in the BIN chunk: the first's byte, the step between them, how many, the component
|
||||||
|
/// type, the components in each. None for one this fix doesn't read (sparse, another buffer, or past the chunk).
|
||||||
|
fn layout(doc: &Value, acc: u64, bin: &[u8]) -> Option<(usize, usize, usize, u64, usize)> {
|
||||||
|
let a = doc["accessors"].get(acc as usize)?;
|
||||||
|
if a.get("sparse").is_some() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let v = doc["bufferViews"].get(a["bufferView"].as_u64()? as usize)?;
|
||||||
|
if v["buffer"].as_u64().unwrap_or(0) != 0 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let comp = a["componentType"].as_u64()?;
|
||||||
|
let size = match comp {
|
||||||
|
5120 | 5121 => 1,
|
||||||
|
5122 | 5123 => 2,
|
||||||
|
5125 | 5126 => 4,
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
let n = match a["type"].as_str()? {
|
||||||
|
"SCALAR" => 1,
|
||||||
|
"VEC2" => 2,
|
||||||
|
"VEC3" => 3,
|
||||||
|
"VEC4" => 4,
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
let start = v["byteOffset"].as_u64().unwrap_or(0) as usize + a["byteOffset"].as_u64().unwrap_or(0) as usize;
|
||||||
|
let stride = v["byteStride"].as_u64().map_or(size * n, |s| s as usize);
|
||||||
|
let count = a["count"].as_u64()? as usize;
|
||||||
|
(count == 0 || start + stride * (count - 1) + size * n <= bin.len()).then_some((start, stride, count, comp, n))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f32_at(bin: &[u8], at: usize) -> f32 {
|
||||||
|
f32::from_le_bytes([bin[at], bin[at + 1], bin[at + 2], bin[at + 3]])
|
||||||
|
}
|
||||||
|
|
||||||
|
fn vec3s(doc: &Value, acc: u64, bin: &[u8]) -> Option<Vec<[f32; 3]>> {
|
||||||
|
let (start, stride, count, comp, n) = layout(doc, acc, bin)?;
|
||||||
|
(comp == FLOAT && n == 3).then(|| (0..count).map(|i| std::array::from_fn(|k| f32_at(bin, start + i * stride + 4 * k))).collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn indices(doc: &Value, prim: &Value, bin: &[u8], verts: usize) -> Option<Vec<usize>> {
|
||||||
|
let Some(acc) = prim.get("indices").and_then(Value::as_u64) else { return Some((0..verts).collect()) };
|
||||||
|
let (start, stride, count, comp, n) = layout(doc, acc, bin)?;
|
||||||
|
if n != 1 {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let at = |i: usize| start + i * stride;
|
||||||
|
let idx: Vec<usize> = match comp {
|
||||||
|
5121 => (0..count).map(|i| bin[at(i)] as usize).collect(),
|
||||||
|
5123 => (0..count).map(|i| u16::from_le_bytes([bin[at(i)], bin[at(i) + 1]]) as usize).collect(),
|
||||||
|
5125 => (0..count).map(|i| u32::from_le_bytes([bin[at(i)], bin[at(i) + 1], bin[at(i) + 2], bin[at(i) + 3]]) as usize).collect(),
|
||||||
|
_ => return None,
|
||||||
|
};
|
||||||
|
idx.iter().all(|&i| i < verts).then_some(idx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sub(a: [f32; 3], b: [f32; 3]) -> [f32; 3] {
|
||||||
|
[a[0] - b[0], a[1] - b[1], a[2] - b[2]]
|
||||||
|
}
|
||||||
|
fn cross(a: [f32; 3], b: [f32; 3]) -> [f32; 3] {
|
||||||
|
[a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
|
||||||
|
}
|
||||||
|
fn dot(a: [f32; 3], b: [f32; 3]) -> f32 {
|
||||||
|
a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
|
||||||
|
}
|
||||||
|
fn unit(a: [f32; 3]) -> Option<[f32; 3]> {
|
||||||
|
let l = dot(a, a).sqrt();
|
||||||
|
(l > 1e-20).then(|| [a[0] / l, a[1] / l, a[2] / l])
|
||||||
|
}
|
||||||
|
|
||||||
|
/// New normals for one primitive: each corner takes the area-weighted mean of the triangles at its position (corners
|
||||||
|
/// forma split per face are joined by position) whose facing is within `deg` of the corner's own normal.
|
||||||
|
pub fn smoothed(pos: &[[f32; 3]], normals: &[[f32; 3]], idx: &[usize], deg: f32) -> Vec<[f32; 3]> {
|
||||||
|
let lo = pos.iter().fold([f32::MAX; 3], |m, p| std::array::from_fn(|k| m[k].min(p[k])));
|
||||||
|
let hi = pos.iter().fold([f32::MIN; 3], |m, p| std::array::from_fn(|k| m[k].max(p[k])));
|
||||||
|
let eps = (dot(sub(hi, lo), sub(hi, lo)).sqrt() * 1e-6).max(1e-9);
|
||||||
|
let key = |p: [f32; 3]| p.map(|c| (c / eps).round() as i64);
|
||||||
|
let mut group: HashMap<[i64; 3], usize> = HashMap::new();
|
||||||
|
let gid: Vec<usize> = pos.iter().map(|&p| { let n = group.len(); *group.entry(key(p)).or_insert(n) }).collect();
|
||||||
|
let mut around: Vec<Vec<[f32; 3]>> = vec![Vec::new(); group.len()];
|
||||||
|
for t in idx.as_chunks::<3>().0 {
|
||||||
|
let f = cross(sub(pos[t[1]], pos[t[0]]), sub(pos[t[2]], pos[t[0]]));
|
||||||
|
if unit(f).is_none() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let mut seen = [usize::MAX; 3];
|
||||||
|
for (k, &v) in t.iter().enumerate() {
|
||||||
|
if !seen.contains(&gid[v]) {
|
||||||
|
around[gid[v]].push(f);
|
||||||
|
seen[k] = gid[v];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let cos = deg.to_radians().cos();
|
||||||
|
(0..pos.len())
|
||||||
|
.map(|v| {
|
||||||
|
let Some(own) = unit(normals[v]) else { return normals[v] };
|
||||||
|
let sum = around[gid[v]].iter().filter(|f| unit(**f).is_some_and(|u| dot(u, own) >= cos)).fold([0.0; 3], |s, f| [s[0] + f[0], s[1] + f[1], s[2] + f[2]]);
|
||||||
|
unit(sum).unwrap_or(own)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every triangle primitive's normals smoothed in the BIN chunk; how many primitives changed. A primitive with tangents
|
||||||
|
/// is left alone (smoothing would leave them stale), as is one whose data this fix doesn't read.
|
||||||
|
fn smooth_normals(doc: &Value, bin: &mut [u8], deg: f32) -> R<usize> {
|
||||||
|
let mut done: HashSet<u64> = HashSet::new();
|
||||||
|
let mut n = 0;
|
||||||
|
for mesh in doc["meshes"].as_array().into_iter().flatten() {
|
||||||
|
for prim in mesh["primitives"].as_array().into_iter().flatten() {
|
||||||
|
let attrs = &prim["attributes"];
|
||||||
|
let (Some(p), Some(nm)) = (attrs["POSITION"].as_u64(), attrs["NORMAL"].as_u64()) else { continue };
|
||||||
|
if prim["mode"].as_u64().unwrap_or(4) != 4 || attrs.get("TANGENT").is_some() || !done.insert(nm) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let (Some(pos), Some(normals)) = (vec3s(doc, p, bin), vec3s(doc, nm, bin)) else { continue };
|
||||||
|
let Some(idx) = indices(doc, prim, bin, pos.len()).filter(|_| pos.len() == normals.len()) else { continue };
|
||||||
|
let new = smoothed(&pos, &normals, &idx, deg);
|
||||||
|
let (start, stride, ..) = layout(doc, nm, bin).ok_or("the normals moved")?;
|
||||||
|
for (i, v) in new.iter().enumerate() {
|
||||||
|
for (k, c) in v.iter().enumerate() {
|
||||||
|
let at = start + i * stride + 4 * k;
|
||||||
|
bin[at..at + 4].copy_from_slice(&c.to_le_bytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Two triangles forma-style (corners split per face, flat normals) meeting along x at `fold` degrees, with
|
||||||
|
/// a red material typed as sRGB.
|
||||||
|
fn hinge(fold: f32) -> Vec<u8> {
|
||||||
|
let (s, c) = fold.to_radians().sin_cos();
|
||||||
|
let pos: [[f32; 3]; 6] = [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, -c, s], [1.0, 0.0, 0.0]];
|
||||||
|
let b = unit(cross(sub(pos[4], pos[3]), sub(pos[5], pos[3]))).unwrap();
|
||||||
|
let nrm: [[f32; 3]; 6] = [[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], b, b, b];
|
||||||
|
let mut bin = Vec::new();
|
||||||
|
for v in pos.iter().chain(nrm.iter()) {
|
||||||
|
for c in v {
|
||||||
|
bin.extend_from_slice(&c.to_le_bytes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i in 0u16..6 {
|
||||||
|
bin.extend_from_slice(&i.to_le_bytes());
|
||||||
|
}
|
||||||
|
let doc = json!({
|
||||||
|
"asset": {"version": "2.0", "generator": "forma"},
|
||||||
|
"materials": [{"pbrMetallicRoughness": {"baseColorFactor": [0.72, 0.36, 0.0, 0.5]}}],
|
||||||
|
"meshes": [{"primitives": [{"attributes": {"POSITION": 0, "NORMAL": 1}, "indices": 2, "material": 0}]}],
|
||||||
|
"accessors": [
|
||||||
|
{"bufferView": 0, "componentType": 5126, "count": 6, "type": "VEC3"},
|
||||||
|
{"bufferView": 0, "byteOffset": 72, "componentType": 5126, "count": 6, "type": "VEC3"},
|
||||||
|
{"bufferView": 1, "componentType": 5123, "count": 6, "type": "SCALAR"}
|
||||||
|
],
|
||||||
|
"bufferViews": [{"buffer": 0, "byteLength": 144}, {"buffer": 0, "byteOffset": 144, "byteLength": 12}],
|
||||||
|
"buffers": [{"byteLength": 156}]
|
||||||
|
});
|
||||||
|
write(&doc, &bin)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normals_of(glb: &[u8]) -> Vec<[f32; 3]> {
|
||||||
|
let (doc, bin) = read(glb).unwrap();
|
||||||
|
vec3s(&doc, 1, &bin).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn colours_become_linear_once() {
|
||||||
|
let (out, f) = fix(&hinge(10.0), None).unwrap();
|
||||||
|
assert_eq!(f, Fixed { colours: 1, primitives: 0, already: false });
|
||||||
|
let (doc, _) = read(&out).unwrap();
|
||||||
|
let c: Vec<f64> = doc["materials"][0]["pbrMetallicRoughness"]["baseColorFactor"].as_array().unwrap().iter().map(|v| v.as_f64().unwrap()).collect();
|
||||||
|
assert!((c[0] - 0.4770).abs() < 1e-3 && (c[1] - 0.1065).abs() < 1e-3 && c[2] == 0.0 && c[3] == 0.5, "{c:?}");
|
||||||
|
assert_eq!(doc["asset"]["generator"], "forma");
|
||||||
|
let (again, f2) = fix(&out, Some(40.0)).unwrap();
|
||||||
|
assert!(f2.already && again == out);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_shallow_fold_turns_round_and_a_sharp_one_stays() {
|
||||||
|
let (out, f) = fix(&hinge(10.0), Some(40.0)).unwrap();
|
||||||
|
assert_eq!(f.primitives, 1);
|
||||||
|
let n = normals_of(&out);
|
||||||
|
// the corners on the shared edge lean halfway; the corners on one face alone keep its facing
|
||||||
|
let tilt = |v: [f32; 3]| dot(v, [0.0, 0.0, 1.0]).acos().to_degrees();
|
||||||
|
assert!((tilt(n[0]) - 5.0).abs() < 0.01 && (tilt(n[1]) - 5.0).abs() < 0.01 && (tilt(n[3]) - 5.0).abs() < 0.01, "{n:?}");
|
||||||
|
assert!(tilt(n[2]) < 1e-3 && (tilt(n[4]) - 10.0).abs() < 0.01, "{n:?}");
|
||||||
|
for v in &n {
|
||||||
|
assert!((dot(*v, *v) - 1.0).abs() < 1e-5);
|
||||||
|
}
|
||||||
|
let (sharp, _) = fix(&hinge(60.0), Some(40.0)).unwrap();
|
||||||
|
assert_eq!(normals_of(&sharp), normals_of(&hinge(60.0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_file_keeps_its_layout() {
|
||||||
|
let src = hinge(10.0);
|
||||||
|
let (out, _) = fix(&src, Some(40.0)).unwrap();
|
||||||
|
assert_eq!(out.len() % 4, 0);
|
||||||
|
assert_eq!(u32::from_le_bytes([out[8], out[9], out[10], out[11]]) as usize, out.len());
|
||||||
|
let ((_, a), (_, b)) = (read(&src).unwrap(), read(&out).unwrap());
|
||||||
|
assert_eq!(a.len(), b.len());
|
||||||
|
assert_eq!(a[..72], b[..72], "positions untouched");
|
||||||
|
assert_eq!(a[144..], b[144..], "indices untouched");
|
||||||
|
assert!(fix(b"not a glb", None).is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,347 @@
|
|||||||
|
//! `raea setup forma` and `raea forma` (docs/forma.feature). forma (github.com/wrong-nebula/forma) is a headless
|
||||||
|
//! modeller for hard-surface parts: a few lines of its pipe language make a watertight mesh with exact sizes in
|
||||||
|
//! milliseconds (gears, brackets, threads, enclosures, a lathed vase, a table). forma is GPL-3.0-or-later and raea is
|
||||||
|
//! FSL, so raea never links forma or ships it: setup downloads forma's own release into ~/.raea/tools/forma, as
|
||||||
|
//! `raea setup blender` does Blender, and `raea forma` runs it as a program of its own, then fixes the .glb it wrote
|
||||||
|
//! (glb.rs). What forma makes belongs to whoever made it; the GPL covers forma alone.
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
|
/// the .glb forma writes, its colours made linear and its normals smoothed
|
||||||
|
pub mod glb;
|
||||||
|
|
||||||
|
type R<T> = Result<T, String>;
|
||||||
|
|
||||||
|
/// The forma raea downloads and is tested with.
|
||||||
|
pub const VERSION: &str = "0.4.4";
|
||||||
|
/// Linux: forma's static musl binary from its GitHub release, which needs no Node; each archive's sha256, pinned.
|
||||||
|
const LINUX: [(&str, &str); 2] = [
|
||||||
|
("x86_64", "52ffc3d60787a9aab9989064624729115e6b1b8d29e53540fde0188443af9470"),
|
||||||
|
("aarch64", "c4788352ce97c432a818d4c8e6f16d60e74e193909ac56ea5b1a066cf967bb5d"),
|
||||||
|
];
|
||||||
|
/// Elsewhere: the npm package forma-3d (forma built for WebAssembly, with its CLI and MCP server), run by Node 18+ or
|
||||||
|
/// Bun; the tarball's sha512, pinned (npm's own integrity for it, in hex).
|
||||||
|
const NPM_SHA512: &str = "676e7990b32dbc3a035079509c5ac9baa86bd24423a53e57e9b586f4b7ff45b07bda75842f58e795c7a128b8a35bc94bc1eafc8e2f94126bcc5f1c3200626a95";
|
||||||
|
/// The angle under which `raea forma` smooths a .glb's normals unless --smooth says.
|
||||||
|
pub const SMOOTH: f32 = 40.0;
|
||||||
|
|
||||||
|
pub const USAGE: &str = "raea setup forma [--check] [--download] (find forma or download it into ~/.raea/tools/forma: forma 0.4.4, a headless modeller for hard-surface parts (GPL-3.0-or-later, so raea runs it as its own program and never ships it), its static binary on Linux, else its npm package run by Node 18+ or Bun, each checked against its pinned hash)\n raea forma SCRIPT.forma -o OUT.glb|.stl|.obj|.3mf|.step [--unit m|cm|mm|um|in|ft] [--render PREVIEW.png] [--draw BLUEPRINT.svg] [--size PX] [--smooth DEG] [--flat] [--no-strict] (a forma script made into OUT, each named part its own node; a mesh that isn't watertight is refused with forma's reason unless --no-strict; a .glb's colours are made linear, as glTF reads them, and its normals smoothed where faces meet under DEG degrees (40 unless given; --flat keeps forma's faceted ones); --render's preview draws the last part, raea render draws them all)\n raea forma fix FILE.glb... [--smooth DEG] [--flat] (the same fix on a .glb forma wrote by itself (its MCP server's export, its own CLI): colours linear, normals smoothed; a file fixed before is left alone)\n raea forma spec [--topic deform|curves|uv|remesh|scene] [--gbnf] (forma's language reference, about 500 tokens: its primitives, operations and selectors)";
|
||||||
|
|
||||||
|
/// How forma is run: its own binary, or its npm package's CLI by a JavaScript runtime.
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub enum Forma {
|
||||||
|
Native(PathBuf),
|
||||||
|
Js { runtime: PathBuf, cli: PathBuf },
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Forma {
|
||||||
|
pub fn command(&self) -> Command {
|
||||||
|
match self {
|
||||||
|
Forma::Native(bin) => Command::new(bin),
|
||||||
|
Forma::Js { runtime, cli } => {
|
||||||
|
let mut c = Command::new(runtime);
|
||||||
|
c.arg(cli);
|
||||||
|
c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn path(&self) -> &Path {
|
||||||
|
match self {
|
||||||
|
Forma::Native(p) | Forma::Js { cli: p, .. } => p,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Where raea keeps its download of forma.
|
||||||
|
pub fn own_dir() -> R<PathBuf> {
|
||||||
|
Ok(raea_io_home::user_home().ok_or("no home folder (HOME)")?.join(".raea/tools/forma"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn on_path(name: &str) -> Option<PathBuf> {
|
||||||
|
let exe = if cfg!(windows) { format!("{name}.exe") } else { name.to_string() };
|
||||||
|
std::env::split_paths(&std::env::var_os("PATH")?).map(|d| d.join(&exe)).find(|p| p.is_file())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Node, else Bun: what runs forma's npm package.
|
||||||
|
fn js_runtime() -> R<PathBuf> {
|
||||||
|
on_path("node").or_else(|| on_path("bun")).ok_or_else(|| "forma runs here on Node.js 18 or later, or Bun, and neither is on PATH: install one (https://nodejs.org), then raea setup forma again".into())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A forma at a path: a .mjs or .js is forma's npm CLI, anything else its binary.
|
||||||
|
fn at(p: PathBuf) -> R<Forma> {
|
||||||
|
Ok(if p.extension().is_some_and(|x| x == "mjs" || x == "js") { Forma::Js { runtime: js_runtime()?, cli: p } } else { Forma::Native(p) })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn run(cmd: &mut Command, what: &str) -> R<String> {
|
||||||
|
let o = cmd.output().map_err(|e| format!("{what}: {e}"))?;
|
||||||
|
if !o.status.success() {
|
||||||
|
return Err(format!("{what} failed: {}{}", String::from_utf8_lossy(&o.stderr).trim(), String::from_utf8_lossy(&o.stdout).trim()));
|
||||||
|
}
|
||||||
|
Ok(String::from_utf8_lossy(&o.stdout).into_owned())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The forma to use and where it came from: `git config --global raea.forma` (a binary or forma's bin/forma.mjs),
|
||||||
|
/// raea's download, then a `forma` on PATH that says it is forma.
|
||||||
|
pub fn find() -> R<Option<(Forma, &'static str)>> {
|
||||||
|
let configured = run(Command::new("git").args(["config", "--global", "raea.forma"]), "git config").ok().map(|o| PathBuf::from(o.trim()));
|
||||||
|
if let Some(p) = configured.filter(|p| p.is_file()) {
|
||||||
|
return Ok(Some((at(p)?, "raea.forma in git config")));
|
||||||
|
}
|
||||||
|
let dir = own_dir()?;
|
||||||
|
for p in [dir.join(if cfg!(windows) { "forma.exe" } else { "forma" }), dir.join("package/bin/forma.mjs")] {
|
||||||
|
if p.is_file() {
|
||||||
|
return Ok(Some((at(p)?, "raea's download")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(on_path("forma").map(Forma::Native).filter(|f| version(f).is_ok()).map(|f| (f, "PATH")))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `forma --version`'s first line ("forma 0.4.4 (WASM)"); an error when the program isn't forma.
|
||||||
|
pub fn version(f: &Forma) -> R<String> {
|
||||||
|
let out = run(f.command().arg("--version"), "forma --version")?;
|
||||||
|
out.lines().map(str::trim).find(|l| l.starts_with("forma")).map(str::to_string).ok_or_else(|| format!("{} --version didn't say forma", f.path().display()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A file's sha256 or sha512 in hex, by the platform's own tool (as blender.rs and godot.rs check their downloads).
|
||||||
|
pub fn digest(file: &Path, bits: u32) -> R<String> {
|
||||||
|
let out = if cfg!(windows) {
|
||||||
|
run(Command::new("certutil").arg("-hashfile").arg(file).arg(format!("SHA{bits}")), "certutil")?.lines().nth(1).unwrap_or_default().replace(' ', "")
|
||||||
|
} else if on_path("shasum").is_some() {
|
||||||
|
run(Command::new("shasum").args(["-a", &bits.to_string()]).arg(file), "shasum")?.split_whitespace().next().unwrap_or_default().to_string()
|
||||||
|
} else {
|
||||||
|
run(Command::new(format!("sha{bits}sum")).arg(file), "sha sum")?.split_whitespace().next().unwrap_or_default().to_string()
|
||||||
|
};
|
||||||
|
Ok(out.to_lowercase())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Downloads forma into ~/.raea/tools/forma, checked against its pinned hash: Linux's binary, else the npm package.
|
||||||
|
fn download() -> R<(Forma, String)> {
|
||||||
|
let linux = LINUX.iter().find(|(arch, _)| cfg!(target_os = "linux") && *arch == std::env::consts::ARCH);
|
||||||
|
let (url, bits, want, file) = match linux {
|
||||||
|
Some((arch, sum)) => (format!("https://github.com/wrong-nebula/forma/releases/download/v{VERSION}/forma-linux-{arch}-musl.tar.gz"), 256, *sum, "forma.tar.gz"),
|
||||||
|
None => {
|
||||||
|
js_runtime()?; // before downloading what nothing here could run
|
||||||
|
(format!("https://registry.npmjs.org/forma-3d/-/forma-3d-{VERSION}.tgz"), 512, NPM_SHA512, "forma-3d.tgz")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let dir = own_dir()?;
|
||||||
|
let tmp = dir.with_file_name("forma.download");
|
||||||
|
let _ = std::fs::remove_dir_all(&tmp);
|
||||||
|
let unpacked = tmp.join("unpacked");
|
||||||
|
std::fs::create_dir_all(&unpacked).map_err(|e| format!("{}: {e}", unpacked.display()))?;
|
||||||
|
let got = tmp.join(file);
|
||||||
|
run(Command::new("curl").args(["-fL", "--retry", "3", "-o"]).arg(&got).arg(&url), "downloading forma")?;
|
||||||
|
if digest(&got, bits)? != want {
|
||||||
|
return Err(format!("{url} doesn't match its pinned sha{bits}; nothing installed (it's in {})", tmp.display()));
|
||||||
|
}
|
||||||
|
run(Command::new("tar").arg("-xzf").arg(&got).arg("-C").arg(&unpacked), "unpacking forma")?;
|
||||||
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
|
std::fs::rename(&unpacked, &dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||||
|
let _ = std::fs::remove_dir_all(&tmp);
|
||||||
|
let what = if linux.is_some() { "its Linux binary from github.com/wrong-nebula/forma" } else { "its npm package forma-3d" };
|
||||||
|
let f = find()?.filter(|(_, from)| *from == "raea's download").ok_or_else(|| format!("{url} held no forma"))?.0;
|
||||||
|
Ok((f, format!("downloaded forma {VERSION}, {what}")))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `raea setup forma [--check] [--download]`.
|
||||||
|
pub fn setup(args: &[String]) -> R<String> {
|
||||||
|
let check = args.iter().any(|a| a == "--check");
|
||||||
|
let fresh = args.iter().any(|a| a == "--download");
|
||||||
|
let (f, from) = match find()?.filter(|_| !fresh) {
|
||||||
|
Some((f, from)) => (f, from.to_string()),
|
||||||
|
None if check => return Ok(format!("CHECKED no forma found (raea.forma, {}, PATH): raea setup forma downloads forma {VERSION}", own_dir()?.display())),
|
||||||
|
None => download()?,
|
||||||
|
};
|
||||||
|
let v = version(&f)?;
|
||||||
|
let pinned = if v.contains(VERSION) { String::new() } else { format!(" (raea is tested with {VERSION}: raea setup forma --download fetches it)") };
|
||||||
|
let head = if check { "CHECKED " } else { "APPLIED " };
|
||||||
|
Ok(format!("{head} {v} ({from}){pinned}\n {}\n make: raea forma SCRIPT.forma -o OUT.glb; its language: raea forma spec; agents: the `forma` MCP server (raea skills install adds it)\n forma is GPL-3.0-or-later and runs as its own program; what it makes is yours", f.path().display()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `raea forma`'s arguments, read.
|
||||||
|
#[derive(Debug, Default, PartialEq)]
|
||||||
|
pub struct Make {
|
||||||
|
pub script: String,
|
||||||
|
pub out: String,
|
||||||
|
pub unit: Option<String>,
|
||||||
|
pub render: Option<String>,
|
||||||
|
pub draw: Option<String>,
|
||||||
|
pub size: Option<String>,
|
||||||
|
pub smooth: Option<f32>,
|
||||||
|
pub strict: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reads `raea forma SCRIPT -o OUT ...` (args without the verb).
|
||||||
|
pub fn parse(args: &[String]) -> R<Make> {
|
||||||
|
let mut m = Make { smooth: Some(SMOOTH), strict: true, ..Default::default() };
|
||||||
|
let mut it = args.iter();
|
||||||
|
while let Some(a) = it.next() {
|
||||||
|
let mut val = |flag: &str| it.next().cloned().ok_or_else(|| format!("{flag} takes a value: {USAGE}"));
|
||||||
|
match a.as_str() {
|
||||||
|
"-o" | "--out" => m.out = val(a)?,
|
||||||
|
"--unit" => m.unit = Some(val(a)?),
|
||||||
|
"--render" => m.render = Some(val(a)?),
|
||||||
|
"--draw" => m.draw = Some(val(a)?),
|
||||||
|
"--size" => m.size = Some(val(a)?),
|
||||||
|
"--smooth" => m.smooth = Some(val(a)?.parse().map_err(|_| "--smooth takes degrees, 40 say".to_string())?),
|
||||||
|
"--flat" => m.smooth = None,
|
||||||
|
"--no-strict" => m.strict = false,
|
||||||
|
f if f.starts_with('-') && f != "-" => return Err(format!("raea forma has no {f}: {USAGE}")),
|
||||||
|
s if m.script.is_empty() => m.script = s.to_string(),
|
||||||
|
s => return Err(format!("one script at a time ({} and {s})", m.script)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if m.script.is_empty() || m.out.is_empty() {
|
||||||
|
return Err(format!("usage: {USAGE}"));
|
||||||
|
}
|
||||||
|
Ok(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// forma's own arguments for a make: always one node per named part in a .glb.
|
||||||
|
pub fn forma_args(m: &Make) -> Vec<String> {
|
||||||
|
let mut a: Vec<String> = vec!["eval".into(), if m.strict { "--strict" } else { "--no-strict" }.into()];
|
||||||
|
if m.out.to_lowercase().ends_with(".glb") {
|
||||||
|
a.push("--scene".into());
|
||||||
|
}
|
||||||
|
a.extend(["--out".into(), m.out.clone()]);
|
||||||
|
for (flag, v) in [("--unit", &m.unit), ("--render", &m.render), ("--size", &m.size), ("--draw", &m.draw)] {
|
||||||
|
if let Some(v) = v {
|
||||||
|
a.extend([flag.to_string(), v.clone()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.push(m.script.clone());
|
||||||
|
a
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `raea forma fix FILE.glb... [--smooth DEG] [--flat]` (args after `fix`): needs no forma, only its files.
|
||||||
|
pub fn fix(args: &[String]) -> R<String> {
|
||||||
|
let mut smooth = Some(SMOOTH);
|
||||||
|
let mut files = Vec::new();
|
||||||
|
let mut it = args.iter();
|
||||||
|
while let Some(a) = it.next() {
|
||||||
|
match a.as_str() {
|
||||||
|
"--smooth" => smooth = Some(it.next().and_then(|v| v.parse().ok()).ok_or("--smooth takes degrees, 40 say")?),
|
||||||
|
"--flat" => smooth = None,
|
||||||
|
f if f.starts_with('-') => return Err(format!("raea forma fix has no {f}: {USAGE}")),
|
||||||
|
f if f.to_lowercase().ends_with(".glb") => files.push(f),
|
||||||
|
f => return Err(format!("{f} isn't a .glb: forma's .stl, .obj, .3mf and .step carry no colours to fix")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if files.is_empty() {
|
||||||
|
return Err(format!("which .glb: {USAGE}"));
|
||||||
|
}
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for f in files {
|
||||||
|
let fixed = glb::fix_file(Path::new(f), smooth)?;
|
||||||
|
out.push(if fixed.already { format!("CHECKED {f}: fixed before, left alone") } else { format!("APPLIED {f}: {} colours made linear, {} meshes' normals smoothed", fixed.colours, fixed.primitives) });
|
||||||
|
}
|
||||||
|
Ok(out.join("\n"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `raea forma ...` (args with the verb): `spec` passes through to forma; a make runs forma, then fixes the .glb.
|
||||||
|
pub fn forma(args: &[String]) -> R<String> {
|
||||||
|
if args.get(1).map(String::as_str) == Some("fix") {
|
||||||
|
return fix(&args[2..]);
|
||||||
|
}
|
||||||
|
let (f, _) = find()?.ok_or("no forma: raea setup forma finds or downloads it")?;
|
||||||
|
if args.get(1).map(String::as_str) == Some("spec") {
|
||||||
|
return run(f.command().arg("spec").args(&args[2..]), "forma spec");
|
||||||
|
}
|
||||||
|
let m = parse(&args[1..])?;
|
||||||
|
if m.script != "-" && !Path::new(&m.script).is_file() {
|
||||||
|
return Err(format!("no script {}", m.script));
|
||||||
|
}
|
||||||
|
let o = f.command().args(forma_args(&m)).stdin(Stdio::inherit()).output().map_err(|e| format!("{}: {e}", f.path().display()))?;
|
||||||
|
let (out, err) = (String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr));
|
||||||
|
if !o.status.success() {
|
||||||
|
let why = if o.status.code() == Some(3) { " (not watertight: --no-strict writes it anyway)" } else { "" };
|
||||||
|
return Err(format!("forma refused {}{why}: {}{}", m.script, err.trim(), if out.trim().is_empty() { String::new() } else { format!("\n{}", out.trim()) }));
|
||||||
|
}
|
||||||
|
let mut report = out.trim_end().to_string();
|
||||||
|
if m.out.to_lowercase().ends_with(".glb") {
|
||||||
|
let fixed = glb::fix_file(Path::new(&m.out), m.smooth)?;
|
||||||
|
let normals = match m.smooth {
|
||||||
|
Some(d) => format!("{} meshes' normals smoothed under {d}°", fixed.primitives),
|
||||||
|
None => "normals flat as forma wrote them".into(),
|
||||||
|
};
|
||||||
|
report += &format!("\nAPPLIED {}: {} colours made linear, {normals}", m.out, fixed.colours);
|
||||||
|
} else {
|
||||||
|
report += &format!("\nAPPLIED {}", m.out);
|
||||||
|
}
|
||||||
|
Ok(report)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The verbs here, or None for any other: `setup forma` and `forma ...`.
|
||||||
|
pub fn cli(args: &[String]) -> Option<R<String>> {
|
||||||
|
match (args.first()?.as_str(), args.get(1).map(String::as_str)) {
|
||||||
|
("setup", Some("forma")) => Some(setup(&args[2..])),
|
||||||
|
("forma", _) => Some(forma(args)),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn args(s: &str) -> Vec<String> {
|
||||||
|
s.split_whitespace().map(str::to_string).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_make_reads_its_flags_and_passes_forma_its_own() {
|
||||||
|
let m = parse(&args("bolt.forma -o bolt.glb --unit mm --render b.png --smooth 30")).unwrap();
|
||||||
|
assert_eq!((m.smooth, m.strict, m.unit.as_deref()), (Some(30.0), true, Some("mm")));
|
||||||
|
assert_eq!(forma_args(&m).join(" "), "eval --strict --scene --out bolt.glb --unit mm --render b.png bolt.forma");
|
||||||
|
let flat = parse(&args("p.forma -o p.stl --flat --no-strict")).unwrap();
|
||||||
|
assert_eq!((flat.smooth, flat.strict), (None, false));
|
||||||
|
assert_eq!(forma_args(&flat).join(" "), "eval --no-strict --out p.stl p.forma");
|
||||||
|
assert_eq!(parse(&args("p.forma -o p.glb")).unwrap().smooth, Some(SMOOTH));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_make_refuses_what_it_cant_read() {
|
||||||
|
assert!(parse(&args("p.forma")).unwrap_err().starts_with("usage:"));
|
||||||
|
assert!(parse(&args("p.forma -o p.glb --bogus")).unwrap_err().contains("no --bogus"));
|
||||||
|
assert!(parse(&args("a.forma b.forma -o p.glb")).unwrap_err().contains("one script"));
|
||||||
|
assert!(parse(&args("p.forma -o p.glb --smooth soft")).is_err());
|
||||||
|
assert!(parse(&args("p.forma -o")).unwrap_err().contains("takes a value"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn every_flag_is_in_the_usage() {
|
||||||
|
for f in ["--check", "--download", "--unit", "--render", "--draw", "--size", "--smooth", "--flat", "--no-strict", "--topic", "--gbnf"] {
|
||||||
|
assert!(USAGE.contains(&format!("[{f}")), "{f}");
|
||||||
|
}
|
||||||
|
assert!(cli(&args("setup blender")).is_none() && cli(&args("render x.tsx")).is_none() && cli(&[]).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn digests_of_a_known_file() {
|
||||||
|
let f = std::env::temp_dir().join(format!("raea-forma-digest-{}", std::process::id()));
|
||||||
|
std::fs::write(&f, b"abc").unwrap();
|
||||||
|
let (a, b) = (digest(&f, 256), digest(&f, 512));
|
||||||
|
let _ = std::fs::remove_file(&f);
|
||||||
|
assert_eq!(a.unwrap(), "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
|
||||||
|
assert!(b.unwrap().starts_with("ddaf35a193617aba"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn fix_takes_only_glb_files() {
|
||||||
|
assert!(fix(&args("part.stl")).unwrap_err().contains("isn't a .glb"));
|
||||||
|
assert!(fix(&args("--flat")).unwrap_err().starts_with("which .glb"));
|
||||||
|
assert!(fix(&args("a.glb --soft")).unwrap_err().contains("no --soft"));
|
||||||
|
let d = std::env::temp_dir().join(format!("raea-forma-fix-{}.glb", std::process::id()));
|
||||||
|
std::fs::write(&d, glb::write(&serde_json::json!({"asset": {"version": "2.0"}, "materials": [{"pbrMetallicRoughness": {"baseColorFactor": [0.5, 0.5, 0.5, 1.0]}}]}), &[])).unwrap();
|
||||||
|
let p = d.to_string_lossy().to_string();
|
||||||
|
let (first, again) = (fix(std::slice::from_ref(&p)), fix(&[p]));
|
||||||
|
let _ = std::fs::remove_file(&d);
|
||||||
|
assert!(first.unwrap().contains("1 colours made linear") && again.unwrap().contains("fixed before"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn a_path_names_its_kind() {
|
||||||
|
assert_eq!(at(PathBuf::from("/x/forma")).unwrap(), Forma::Native(PathBuf::from("/x/forma")));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,8 @@ raea-io-assets = { path = "../../io/assets" }
|
|||||||
# generation flows: made.app, fal, Replicate, OpenRouter, Modal, ComfyUI (`raea gen`)
|
# generation flows: made.app, fal, Replicate, OpenRouter, Modal, ComfyUI (`raea gen`)
|
||||||
raea-io-gen = { path = "../../io/gen" }
|
raea-io-gen = { path = "../../io/gen" }
|
||||||
raea-io-home = { path = "../../io/home" }
|
raea-io-home = { path = "../../io/home" }
|
||||||
|
# the forma version the `forma` MCP server is pinned to (agent_mcp.rs; forma itself is fetched by npx, never linked)
|
||||||
|
raea-app-forma = { path = "../forma" }
|
||||||
raea-io-media = { path = "../../io/media", default-features = false }
|
raea-io-media = { path = "../../io/media", default-features = false }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
# the verbs' flags read as a render reads its own
|
# the verbs' flags read as a render reads its own
|
||||||
|
|||||||
+56
-29
@@ -1,14 +1,26 @@
|
|||||||
//! The MCP servers `raea skills install` offers an agent (docs/skills.feature SK11): today `blender`, which drives a
|
//! The MCP servers `raea skills install` offers an agent (docs/skills.feature SK11): `blender`, which drives a running
|
||||||
//! running Blender through the MCP for Blender add-on (`raea setup blender` installs it). Each agent keeps MCP servers
|
//! Blender through the MCP for Blender add-on (`raea setup blender` installs it), and `forma`, forma's own server for
|
||||||
//! in its own place; a server already registered under the name is left as the person set it.
|
//! modelling hard-surface parts in a few lines (docs/forma.feature FM6). Each agent keeps MCP servers in its own place;
|
||||||
|
//! a server already registered under the name is left as the person set it.
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
/// The blender MCP server: uv runs it, so nothing is installed until an agent starts it.
|
/// An MCP server raea offers: its name, the program, its arguments.
|
||||||
const NAME: &str = "blender";
|
pub struct Server {
|
||||||
const CMD: &str = "uvx";
|
pub name: &'static str,
|
||||||
const ARGS: [&str; 1] = ["mcp-for-blender"];
|
pub cmd: &'static str,
|
||||||
|
pub args: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The servers raea offers. Each is fetched by its runner when an agent first starts it, so nothing is installed here:
|
||||||
|
/// blender by uv's uvx, forma (GPL-3.0-or-later, its own program) by npm's npx at the version raea is tested with.
|
||||||
|
/// Windows starts npx through cmd, as npx there is a .cmd script.
|
||||||
|
pub fn servers() -> Vec<Server> {
|
||||||
|
let forma = ["-y".to_string(), "-p".into(), format!("forma-3d@{}", raea_app_forma::VERSION), "forma-3d-mcp".into()];
|
||||||
|
let (cmd, args) = if cfg!(windows) { ("cmd", ["/c".to_string(), "npx".into()].into_iter().chain(forma).collect()) } else { ("npx", forma.to_vec()) };
|
||||||
|
vec![Server { name: "blender", cmd: "uvx", args: vec!["mcp-for-blender".into()] }, Server { name: "forma", cmd, args }]
|
||||||
|
}
|
||||||
|
|
||||||
type R<T> = Result<T, String>;
|
type R<T> = Result<T, String>;
|
||||||
|
|
||||||
@@ -28,18 +40,18 @@ fn json_file(agent: &str) -> R<Option<PathBuf>> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds `blender` to a JSON config's `mcpServers` unless one is there; true when it added.
|
/// Adds a server to a JSON config's `mcpServers` unless one of its name is there; true when it added.
|
||||||
pub fn add_json(path: &Path) -> R<bool> {
|
pub fn add_json(path: &Path, sv: &Server) -> R<bool> {
|
||||||
let mut doc: Value = match std::fs::read_to_string(path) {
|
let mut doc: Value = match std::fs::read_to_string(path) {
|
||||||
Ok(t) if !t.trim().is_empty() => serde_json::from_str(&t).map_err(|e| format!("{}: {e}", path.display()))?,
|
Ok(t) if !t.trim().is_empty() => serde_json::from_str(&t).map_err(|e| format!("{}: {e}", path.display()))?,
|
||||||
_ => json!({}),
|
_ => json!({}),
|
||||||
};
|
};
|
||||||
let servers = doc.as_object_mut().ok_or_else(|| format!("{} isn't a JSON object", path.display()))?.entry("mcpServers").or_insert_with(|| json!({}));
|
let servers = doc.as_object_mut().ok_or_else(|| format!("{} isn't a JSON object", path.display()))?.entry("mcpServers").or_insert_with(|| json!({}));
|
||||||
let servers = servers.as_object_mut().ok_or_else(|| format!("{}: mcpServers isn't an object", path.display()))?;
|
let servers = servers.as_object_mut().ok_or_else(|| format!("{}: mcpServers isn't an object", path.display()))?;
|
||||||
if servers.contains_key(NAME) {
|
if servers.contains_key(sv.name) {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
servers.insert(NAME.into(), json!({"command": CMD, "args": ARGS}));
|
servers.insert(sv.name.into(), json!({"command": sv.cmd, "args": sv.args}));
|
||||||
if let Some(dir) = path.parent() {
|
if let Some(dir) = path.parent() {
|
||||||
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||||
}
|
}
|
||||||
@@ -49,45 +61,52 @@ pub fn add_json(path: &Path) -> R<bool> {
|
|||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds a `[mcp_servers.blender]` table to Codex's config.toml unless one is there; true when it added.
|
/// Adds a `[mcp_servers.NAME]` table to Codex's config.toml unless one is there; true when it added.
|
||||||
pub fn add_toml(path: &Path) -> R<bool> {
|
pub fn add_toml(path: &Path, sv: &Server) -> R<bool> {
|
||||||
let text = std::fs::read_to_string(path).unwrap_or_default();
|
let text = std::fs::read_to_string(path).unwrap_or_default();
|
||||||
if text.lines().any(|l| l.trim() == format!("[mcp_servers.{NAME}]")) {
|
let (name, cmd) = (sv.name, sv.cmd);
|
||||||
|
if text.lines().any(|l| l.trim() == format!("[mcp_servers.{name}]")) {
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
let args = ARGS.iter().map(|a| format!("{a:?}")).collect::<Vec<_>>().join(", ");
|
let args = sv.args.iter().map(|a| format!("{a:?}")).collect::<Vec<_>>().join(", ");
|
||||||
let sep = if text.is_empty() || text.ends_with("\n\n") { "" } else if text.ends_with('\n') { "\n" } else { "\n\n" };
|
let sep = if text.is_empty() || text.ends_with("\n\n") { "" } else if text.ends_with('\n') { "\n" } else { "\n\n" };
|
||||||
if let Some(dir) = path.parent() {
|
if let Some(dir) = path.parent() {
|
||||||
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||||
}
|
}
|
||||||
std::fs::write(path, format!("{text}{sep}[mcp_servers.{NAME}]\ncommand = {CMD:?}\nargs = [{args}]\n")).map_err(|e| format!("{}: {e}", path.display()))?;
|
std::fs::write(path, format!("{text}{sep}[mcp_servers.{name}]\ncommand = {cmd:?}\nargs = [{args}]\n")).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers the blender MCP server for an agent; the line says what happened. Claude Code rewrites ~/.claude.json while
|
/// Registers every server raea offers for an agent, a line each saying what happened.
|
||||||
/// it runs, so its own `claude mcp add` is used when `claude` is on PATH.
|
|
||||||
pub fn offer(agent: &str) -> R<String> {
|
pub fn offer(agent: &str) -> R<String> {
|
||||||
let line = |added: bool, at: &Path| if added { format!("{}: MCP server {NAME} added", at.display()) } else { format!("{}: MCP server {NAME} already there", at.display()) };
|
servers().iter().map(|sv| offer_one(agent, sv)).collect::<R<Vec<_>>>().map(|l| l.join("\n"))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Registers one MCP server for an agent; the line says what happened. Claude Code rewrites ~/.claude.json while it
|
||||||
|
/// runs, so its own `claude mcp add` is used when `claude` is on PATH.
|
||||||
|
fn offer_one(agent: &str, sv: &Server) -> R<String> {
|
||||||
|
let name = sv.name;
|
||||||
|
let line = |added: bool, at: &Path| if added { format!("{}: MCP server {name} added", at.display()) } else { format!("{}: MCP server {name} already there", at.display()) };
|
||||||
if agent == "codex" {
|
if agent == "codex" {
|
||||||
let p = user_home()?.join(".codex/config.toml");
|
let p = user_home()?.join(".codex/config.toml");
|
||||||
return Ok(line(add_toml(&p)?, &p));
|
return Ok(line(add_toml(&p, sv)?, &p));
|
||||||
}
|
}
|
||||||
let p = json_file(agent)?.ok_or_else(|| format!("no agent {agent:?}"))?;
|
let p = json_file(agent)?.ok_or_else(|| format!("no agent {agent:?}"))?;
|
||||||
if agent == "claude" {
|
if agent == "claude" {
|
||||||
let listed = Command::new("claude").args(["mcp", "get", NAME]).output();
|
let listed = Command::new("claude").args(["mcp", "get", name]).output();
|
||||||
match listed {
|
match listed {
|
||||||
Ok(o) if o.status.success() => return Ok(line(false, &p)),
|
Ok(o) if o.status.success() => return Ok(line(false, &p)),
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
let o = Command::new("claude").args(["mcp", "add", "--scope", "user", NAME, "--", CMD]).args(ARGS).output().map_err(|e| e.to_string())?;
|
let o = Command::new("claude").args(["mcp", "add", "--scope", "user", name, "--", sv.cmd]).args(&sv.args).output().map_err(|e| e.to_string())?;
|
||||||
if !o.status.success() {
|
if !o.status.success() {
|
||||||
return Err(format!("claude mcp add {NAME}: {}", String::from_utf8_lossy(&o.stderr).trim()));
|
return Err(format!("claude mcp add {name}: {}", String::from_utf8_lossy(&o.stderr).trim()));
|
||||||
}
|
}
|
||||||
return Ok(line(true, &p));
|
return Ok(line(true, &p));
|
||||||
}
|
}
|
||||||
Err(_) => {} // no claude on PATH: write its file
|
Err(_) => {} // no claude on PATH: write its file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(line(add_json(&p)?, &p))
|
Ok(line(add_json(&p, sv)?, &p))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A move's guide as a skill of its own, named for the move: its description from the guide's first paragraph.
|
/// A move's guide as a skill of its own, named for the move: its description from the guide's first paragraph.
|
||||||
@@ -115,18 +134,26 @@ mod tests {
|
|||||||
let d = std::env::temp_dir().join(format!("raea-agent-mcp-{}", std::process::id()));
|
let d = std::env::temp_dir().join(format!("raea-agent-mcp-{}", std::process::id()));
|
||||||
let _ = std::fs::remove_dir_all(&d);
|
let _ = std::fs::remove_dir_all(&d);
|
||||||
let j = d.join("kimi/mcp.json");
|
let j = d.join("kimi/mcp.json");
|
||||||
assert!(add_json(&j).unwrap());
|
let all = servers();
|
||||||
assert!(!add_json(&j).unwrap());
|
let (blender, forma) = (&all[0], &all[1]);
|
||||||
|
assert!(add_json(&j, blender).unwrap());
|
||||||
|
assert!(!add_json(&j, blender).unwrap());
|
||||||
std::fs::write(&j, r#"{"theme":"dark","mcpServers":{"blender":{"command":"mine"}}}"#).unwrap();
|
std::fs::write(&j, r#"{"theme":"dark","mcpServers":{"blender":{"command":"mine"}}}"#).unwrap();
|
||||||
assert!(!add_json(&j).unwrap());
|
assert!(!add_json(&j, blender).unwrap());
|
||||||
|
assert!(add_json(&j, forma).unwrap());
|
||||||
let kept: Value = serde_json::from_str(&std::fs::read_to_string(&j).unwrap()).unwrap();
|
let kept: Value = serde_json::from_str(&std::fs::read_to_string(&j).unwrap()).unwrap();
|
||||||
assert_eq!(kept["mcpServers"]["blender"]["command"], "mine");
|
assert_eq!(kept["mcpServers"]["blender"]["command"], "mine");
|
||||||
|
assert_eq!(kept["theme"], "dark");
|
||||||
|
let pinned = format!("forma-3d@{}", raea_app_forma::VERSION);
|
||||||
|
assert!(kept["mcpServers"]["forma"]["args"].as_array().unwrap().iter().any(|a| a == pinned.as_str()), "{kept}");
|
||||||
let t = d.join("codex/config.toml");
|
let t = d.join("codex/config.toml");
|
||||||
std::fs::create_dir_all(t.parent().unwrap()).unwrap();
|
std::fs::create_dir_all(t.parent().unwrap()).unwrap();
|
||||||
std::fs::write(&t, "model = \"x\"\n").unwrap();
|
std::fs::write(&t, "model = \"x\"\n").unwrap();
|
||||||
assert!(add_toml(&t).unwrap());
|
assert!(add_toml(&t, blender).unwrap());
|
||||||
assert!(!add_toml(&t).unwrap());
|
assert!(!add_toml(&t, blender).unwrap());
|
||||||
assert_eq!(std::fs::read_to_string(&t).unwrap(), "model = \"x\"\n\n[mcp_servers.blender]\ncommand = \"uvx\"\nargs = [\"mcp-for-blender\"]\n");
|
assert_eq!(std::fs::read_to_string(&t).unwrap(), "model = \"x\"\n\n[mcp_servers.blender]\ncommand = \"uvx\"\nargs = [\"mcp-for-blender\"]\n");
|
||||||
|
assert!(add_toml(&t, forma).unwrap());
|
||||||
|
assert!(std::fs::read_to_string(&t).unwrap().contains(&format!("[mcp_servers.forma]\ncommand = {:?}\n", forma.cmd)));
|
||||||
let _ = std::fs::remove_dir_all(&d);
|
let _ = std::fs::remove_dir_all(&d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ pub mod song;
|
|||||||
pub mod sound;
|
pub mod sound;
|
||||||
pub mod splat;
|
pub mod splat;
|
||||||
|
|
||||||
/// the MCP servers `raea skills install` offers an agent (blender, for a running Blender)
|
/// the MCP servers `raea skills install` offers an agent (blender, for a running Blender; forma, for hard-surface parts)
|
||||||
pub mod agent_mcp;
|
pub mod agent_mcp;
|
||||||
pub mod agent_hooks;
|
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
|
/// Grok Bot as a `raea skills install` target: its copy staged on this Mac, and the links that finish it in Grok Bot
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
@spec
|
||||||
|
Feature: forma, a headless modeller for hard-surface parts, run as its own program
|
||||||
|
Shane, 2026-12-03, on github.com/wrong-nebula/forma: "can we make this an external package and integration we can
|
||||||
|
use or allow agents to download... its a gpl license so idk what that means for us". forma is a ~1 MB pure-Rust
|
||||||
|
modeller built for agents: a few lines of its pipe language (`box(4, 2, 0.4) | bevel(vertical, 0.25) | cut(cyl(0.5,
|
||||||
|
1))`) make a watertight mesh with exact sizes in milliseconds, with semantic edge and face selectors instead of vertex
|
||||||
|
indices. On 12-03 ten parts (gears, a flange, a threaded bolt, a mug, an enclosure, a lathed pawn, a lofted bottle,
|
||||||
|
a table, a desk lamp, a lettered plate) each built in about 0.2 s through its npm CLI, and loaded straight into raea
|
||||||
|
with <Model>. Two faults showed under raea's light: every colour pale (forma writes the sRGB value it was given into
|
||||||
|
baseColorFactor, which glTF reads as linear) and every curve faceted (one normal per face). Its text is a blocky
|
||||||
|
capitals-only face, and it can't make anything organic.
|
||||||
|
|
||||||
|
The licence: forma is GPL-3.0-or-later, raea is FSL-1.1, and the two can't be combined into one program. So raea
|
||||||
|
never links forma's crates or bundles its WebAssembly into the SDK, the CLI or the apps. raea downloads forma's own
|
||||||
|
release and runs it as a separate program, as it already does Blender (apps/tools/src/blender.rs), and works only
|
||||||
|
on the files forma writes. The GPL covers forma, not what it makes, and running it on raea cloud isn't distributing
|
||||||
|
it (GPLv3, not the AGPL).
|
||||||
|
|
||||||
|
Where it sits beside raea's own modelling (docs/blender.feature's framing): TSX is the scene; solids, sdf and grow
|
||||||
|
make what numbers or rules define inside raea; forma is a faster way to make a hard-surface part an agent can check
|
||||||
|
by its numbers (watertight, volume, box) before anyone looks; Blender stays the workshop for assets that are already
|
||||||
|
good; raea gen and CC0 libraries make what looks define.
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given raea pins one forma version (apps/forma VERSION, 0.4.4) with a hash for each download it makes
|
||||||
|
And forma lives in ~/.raea/tools/forma, or wherever `git config --global raea.forma` points
|
||||||
|
|
||||||
|
Rule: Getting forma
|
||||||
|
|
||||||
|
@done
|
||||||
|
Scenario: FM1. raea setup forma finds forma or downloads the pinned version
|
||||||
|
Given `raea setup forma [--check] [--download]`
|
||||||
|
When no forma is found (raea.forma, raea's download, a `forma` on PATH that says it is forma)
|
||||||
|
Then on Linux (x86_64, aarch64) forma's static musl binary is downloaded from its GitHub release and checked
|
||||||
|
against its pinned sha256: it needs no Node
|
||||||
|
And elsewhere forma's npm package (forma-3d) is downloaded from the npm registry and checked against its pinned
|
||||||
|
sha512, to be run by Node 18+ or Bun; with neither on PATH it says so before downloading anything
|
||||||
|
And a download that doesn't match its hash installs nothing and says where it left the file
|
||||||
|
And --check only says what would be used; --download replaces what is there
|
||||||
|
And the report names forma's version, where it came from, and that forma is GPL and runs as its own program
|
||||||
|
|
||||||
|
Rule: Making parts
|
||||||
|
|
||||||
|
@done
|
||||||
|
Scenario: FM2. raea forma makes a script's parts, strict by default
|
||||||
|
Given `raea forma SCRIPT.forma -o OUT.glb|.stl|.obj|.3mf|.step [--unit U] [--render P.png] [--draw B.svg]`
|
||||||
|
Then forma evaluates the script with --strict, and a .glb gets one node per named part (--scene)
|
||||||
|
And forma's report (each part's vertices, watertight, volume, box) is printed as it wrote it
|
||||||
|
And a part that isn't watertight is refused with forma's reason and nothing is written, unless --no-strict
|
||||||
|
And a flag raea forma doesn't know is refused with the usage
|
||||||
|
And `raea forma spec [--topic T] [--gbnf]` prints forma's own language reference
|
||||||
|
|
||||||
|
@done
|
||||||
|
Scenario: FM3. A .glb's colours are made linear, as glTF reads them
|
||||||
|
Given a .glb forma wrote, its baseColorFactor typed as sRGB
|
||||||
|
Then each material's colour is converted sRGB to linear (alpha kept), so terracotta reads terracotta under raea's
|
||||||
|
light and not pink
|
||||||
|
And the file is marked in asset.extras.raea_forma, and a marked file is never converted twice
|
||||||
|
And `raea forma fix FILE.glb... [--smooth DEG] [--flat]` does FM3 and FM4 to a .glb forma wrote by itself (its
|
||||||
|
MCP server's export), with no forma needed
|
||||||
|
|
||||||
|
@done
|
||||||
|
Scenario: FM4. A .glb's normals are smoothed where faces meet at under 40 degrees
|
||||||
|
Given forma's one normal per face
|
||||||
|
Then each corner takes the area-weighted mean of the faces at its position whose facing is within DEG of its own
|
||||||
|
(--smooth DEG, 40 unless given), so a box keeps its edges and a cylinder's side turns round
|
||||||
|
And positions, indices, UVs and the file's layout are kept byte for byte; only the normals' bytes change
|
||||||
|
And --flat keeps forma's normals; a primitive with tangents, or one in a layout the fix doesn't read, is left alone
|
||||||
|
|
||||||
|
Scenario: FM5. The fixed parts under raea's light match what the script asked for
|
||||||
|
Given the 12-03 table (scratchpad forma-try): ten parts made by `raea forma`, loaded with <Model>, one still
|
||||||
|
Then each part's lit colour is within a JND of its typed colour lit the same way in a raea <Cuboid>
|
||||||
|
And no curved part shows facets in a 4x crop
|
||||||
|
|
||||||
|
Rule: Agents
|
||||||
|
|
||||||
|
@done
|
||||||
|
Scenario: FM6. raea skills install adds forma's MCP server
|
||||||
|
Given `raea skills install --agent claude|codex|kimi|gemini`
|
||||||
|
Then beside `blender`, a `forma` MCP server is registered: `npx -y -p forma-3d@VERSION forma-3d-mcp` (through
|
||||||
|
`cmd /c` on Windows), fetched by npx when the agent first starts it
|
||||||
|
And a server the person already registered under the name is left as they set it; --no-mcp adds neither
|
||||||
|
|
||||||
|
Scenario: FM7. The raea skill says when forma is the tool and when it isn't
|
||||||
|
Given the raea skill (raea-skills, skills/raea/3d.md)
|
||||||
|
Then it names forma for hard-surface parts numbers define (mechanical parts, props with exact sizes, a blockout's
|
||||||
|
furniture) and `raea forma` over forma's own CLI, so the .glb comes out fixed
|
||||||
|
And it names what forma is wrong for: anything organic (people, animals, cloth, plants), textures, lettering
|
||||||
|
that has to look good, and the scene itself, which stays TSX
|
||||||
|
And it says the MCP server's exports aren't fixed: a part meant for a render goes through `raea forma`, or
|
||||||
|
`raea forma fix FILE.glb` after the server exported it
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
---
|
||||||
|
title: "raea forma"
|
||||||
|
summary: "Make hard-surface parts from a few lines of forma's language: watertight meshes with exact sizes, written as a .glb raea renders."
|
||||||
|
order: 117
|
||||||
|
sources: ["apps/forma/src/lib.rs", "apps/forma/src/glb.rs", "apps/tools/src/agent_mcp.rs"]
|
||||||
|
---
|
||||||
|
|
||||||
|
`raea forma` runs [forma](https://github.com/wrong-nebula/forma), a headless modeller for hard-surface parts, on a
|
||||||
|
script in its pipe language, and writes the parts it makes: gears, brackets, threaded bolts, enclosures, a lathed vase,
|
||||||
|
a table and its legs. Each named part is its own node in the .glb, every mesh is checked watertight, and a script
|
||||||
|
evaluates in milliseconds, so an agent can write a part, read forma's report (sizes, volume, whether it is watertight)
|
||||||
|
and change it in the same turn. Load the .glb with `<Model>` and light it in raea.
|
||||||
|
|
||||||
|
forma writes a material's colour as it was typed into the .glb, where glTF reads linear colour, so every part would
|
||||||
|
render pale; and it writes one normal per face, so a curved side shows its facets. `raea forma` fixes both in the file
|
||||||
|
after forma writes it: colours made linear, and corners smoothed where faces meet at under 40 degrees (a box keeps its
|
||||||
|
edges, a cylinder's side turns round). The file is marked as fixed and never fixed twice. `raea forma fix` does the
|
||||||
|
same to a .glb forma wrote by itself, through its MCP server or its own CLI.
|
||||||
|
|
||||||
|
forma is GPL-3.0-or-later, so raea never links it or ships it. [`raea setup forma`](setup.md) downloads forma's own
|
||||||
|
release into `~/.raea/tools/forma` and `raea forma` runs it as a program of its own. What forma makes is yours.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
raea setup forma
|
||||||
|
raea forma spec # the language, about 500 tokens
|
||||||
|
raea forma bracket.forma -o assets/bracket.glb # strict: refused with forma's reason unless watertight
|
||||||
|
raea forma gears.forma --unit mm -o assets/gears.glb --draw gears.svg
|
||||||
|
raea forma fix assets/vase.glb # one the MCP server exported
|
||||||
|
```
|
||||||
|
|
||||||
|
Use it for parts that numbers define: mechanical parts, props with exact sizes, a blockout's furniture. It is the wrong
|
||||||
|
tool for anything organic (people, animals, cloth, plants), for textures, and for the scene itself, which stays TSX.
|
||||||
|
`raea skills install` adds forma's own MCP server to an agent as `forma`, for modelling a part over several turns.
|
||||||
|
|
||||||
|
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
raea forma SCRIPT.forma -o OUT.glb|.stl|.obj|.3mf|.step [--unit m|cm|mm|um|in|ft] [--render PREVIEW.png] [--draw BLUEPRINT.svg] [--size PX] [--smooth DEG] [--flat] [--no-strict] (a forma script made into OUT, each named part its own node; a mesh that isn't watertight is refused with forma's reason unless --no-strict; a .glb's colours are made linear, as glTF reads them, and its normals smoothed where faces meet under DEG degrees (40 unless given; --flat keeps forma's faceted ones); --render's preview draws the last part, raea render draws them all)
|
||||||
|
raea forma fix FILE.glb... [--smooth DEG] [--flat] (the same fix on a .glb forma wrote by itself (its MCP server's export, its own CLI): colours linear, normals smoothed; a file fixed before is left alone)
|
||||||
|
raea forma spec [--topic deform|curves|uv|remesh|scene] [--gbnf] (forma's language reference, about 500 tokens: its primitives, operations and selectors)
|
||||||
|
```
|
||||||
|
|
||||||
|
Headless: it needs nothing running and opens no window. Takes any number of arguments besides its flags.
|
||||||
|
|
||||||
|
## Flags
|
||||||
|
|
||||||
|
| Flag | Takes | What it does |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| `--draw` | `BLUEPRINT.svg` | Also write a dimensioned SVG drawing of the parts. |
|
||||||
|
| `--flat` | – | Keep forma's normals, one per face, faceted. |
|
||||||
|
| `--gbnf` | – | With `spec`: print forma's GBNF grammar, for constrained decoding. |
|
||||||
|
| `--no-strict` | – | Write the mesh even when it isn't watertight. |
|
||||||
|
| `--render` | `PREVIEW.png` | Also write forma's own PNG preview (four views of the last part). |
|
||||||
|
| `--size` | `PX` | The preview's size in pixels (512 unless given). |
|
||||||
|
| `--smooth` | `DEG` | Smooth normals where faces meet at under DEG degrees (40 unless given). |
|
||||||
|
| `--topic` | `deform\|curves\|uv\|remesh\|scene` | With `spec`: one topic's reference. |
|
||||||
|
| `--unit` | `m\|cm\|mm\|um\|in\|ft` | The unit the script is written in (metres unless given); a .glb is always in metres. |
|
||||||
|
| `-o` | `OUT.glb\|.stl\|.obj\|.3mf\|.step` | Where to write the parts; a .glb gets its colours and normals fixed. |
|
||||||
|
|
||||||
|
<!-- generated:end -->
|
||||||
@@ -101,7 +101,7 @@ Music read, voices, and the audio setup.
|
|||||||
|
|
||||||
## raea make: the asset tools
|
## raea make: the asset tools
|
||||||
|
|
||||||
What a project is made from, each a `raea make TOOL`: components, solids, clothes and motion for SOMA's body, splats, physics, light and weathering bakes, foley and instruments; and generated media, Blender and Godot.
|
What a project is made from, each a `raea make TOOL`: components, solids, clothes and motion for SOMA's body, splats, physics, light and weathering bakes, foley and instruments; and generated media, Blender, Godot and forma.
|
||||||
|
|
||||||
| Verb | What it does |
|
| Verb | What it does |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
@@ -120,6 +120,7 @@ What a project is made from, each a `raea make TOOL`: components, solids, clothe
|
|||||||
| [`raea gen`](gen.md) | Generate images, video, music, sound, speech, 3D models and text through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI. |
|
| [`raea gen`](gen.md) | Generate images, video, music, sound, speech, 3D models and text through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI. |
|
||||||
| [`raea blender`](blender.md) | Run a Blender Python script headless, with raea's library of mesh scripts: convert, decimate, repair, split, bake, rig, cloth. |
|
| [`raea blender`](blender.md) | Run a Blender Python script headless, with raea's library of mesh scripts: convert, decimate, repair, split, bake, rig, cloth. |
|
||||||
| [`raea godot`](godot.md) | Run a TypeScript script against Godot's whole API in a headless Godot with GodotJS, record what it draws as frames, or open the editor on the project. |
|
| [`raea godot`](godot.md) | Run a TypeScript script against Godot's whole API in a headless Godot with GodotJS, record what it draws as frames, or open the editor on the project. |
|
||||||
|
| [`raea forma`](forma.md) | Make hard-surface parts from a few lines of forma's language: watertight meshes with exact sizes, written as a .glb raea renders. |
|
||||||
|
|
||||||
## Agents and setup
|
## Agents and setup
|
||||||
|
|
||||||
@@ -133,8 +134,8 @@ What an agent reads and shows the person, and the tools raea installs.
|
|||||||
| [`raea notes`](notes.md) | A person's notes as files the work is held to: each taken word for word, then restated as asks before anything changes. |
|
| [`raea notes`](notes.md) | A person's notes as files the work is held to: each taken word for word, then restated as asks before anything changes. |
|
||||||
| [`raea show`](show.md) | Show the person something in the raea app, as an item they can use and answer: stills, a video, a sound, a script, an interactive .tsx or a question. |
|
| [`raea show`](show.md) | Show the person something in the raea app, as an item they can use and answer: stills, a video, a sound, a script, an interactive .tsx or a question. |
|
||||||
| [`raea skill`](skill.md) | Print the agent skill this raea ships, matched to its version, or one of its references. |
|
| [`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 skills`](skills.md) | Install raea's agent skill where Claude Code, Codex, Kimi or Gemini read skills, with its MCP servers 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 setup`](setup.md) | Find Blender, or download its current LTS, and install raea's add-on and the MCP add-on; or download forma, Godot and the motion models. |
|
||||||
| [`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. |
|
| [`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. |
|
||||||
| [`raea ask`](ask.md) | Ask about a piece's picture and sound: clef-omni answers in words and a probability, paid from your raea plan, and every answer is kept so a question can be calibrated. |
|
| [`raea ask`](ask.md) | Ask about a piece's picture and sound: clef-omni answers in words and a probability, paid from your raea plan, and every answer is kept so a question can be calibrated. |
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
---
|
---
|
||||||
title: "raea setup"
|
title: "raea setup"
|
||||||
summary: "Find Blender, or download its current LTS, and install raea's add-on and the MCP add-on."
|
summary: "Find Blender, or download its current LTS, and install raea's add-on and the MCP add-on; or download forma, Godot and the motion models."
|
||||||
order: 129
|
order: 129
|
||||||
sources: ["apps/tools/src/blender.rs"]
|
sources: ["apps/tools/src/blender.rs", "apps/forma/src/lib.rs"]
|
||||||
---
|
---
|
||||||
|
|
||||||
`raea setup blender` finds the Blender on this machine (from `git config raea.blender`, raea's own copy, /Applications or the `PATH`), or downloads the current LTS from blender.org into `~/.raea/tools/blender`. It then installs the add-on that
|
`raea setup blender` finds the Blender on this machine (from `git config raea.blender`, raea's own copy, /Applications or the `PATH`), or downloads the current LTS from blender.org into `~/.raea/tools/blender`. It then installs the add-on that
|
||||||
lets an agent drive Blender over MCP. [`raea blender run`](blender.md) uses the Blender it found.
|
lets an agent drive Blender over MCP. [`raea blender run`](blender.md) uses the Blender it found.
|
||||||
|
|
||||||
|
`raea setup forma` finds forma (from `git config raea.forma`, raea's own copy or the `PATH`), or downloads forma
|
||||||
|
itself into `~/.raea/tools/forma`: its static binary on Linux, else its npm package, run by Node 18+ or Bun. Each is
|
||||||
|
checked against the hash raea pins. forma is GPL-3.0-or-later, so it is fetched from forma's own release and never
|
||||||
|
shipped with raea; [`raea forma`](forma.md) runs it as a program of its own.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
raea setup blender --check
|
raea setup blender --check
|
||||||
raea setup blender
|
raea setup blender
|
||||||
|
raea setup forma
|
||||||
```
|
```
|
||||||
|
|
||||||
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
|
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
|
||||||
@@ -19,6 +25,7 @@ raea setup blender
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
raea setup blender [--check] [--download] (find Blender or download the LTS into ~/.raea/tools/blender, and install raea's add-on and the MCP add-on)
|
raea setup blender [--check] [--download] (find Blender or download the LTS into ~/.raea/tools/blender, and install raea's add-on and the MCP add-on)
|
||||||
|
raea setup forma [--check] [--download] (find forma or download it into ~/.raea/tools/forma: forma 0.4.4, a headless modeller for hard-surface parts (GPL-3.0-or-later, so raea runs it as its own program and never ships it), its static binary on Linux, else its npm package run by Node 18+ or Bun, each checked against its pinned hash)
|
||||||
raea setup motion [--check] (what raea make motion runs on, made where missing (--check only says): on a Mac the MLX models in raea's models folder (the motion model 1.1 GB, the text encoder 8.8 GB); on Linux and Windows, in raea's models folder's kimodo-torch, a Python 3.11 environment made by uv (which it needs on PATH: https://docs.astral.sh/uv) with PyTorch (its CUDA build where there is an NVIDIA driver, about 8 GB, else CPU only, about 2 GB) and upstream Kimodo (nv-tlabs/kimodo at e1c219c, Apache-2.0), then the weights: Kimodo-SOMA-RP-v1 (1.1 GB, NVIDIA Open Model License), LLM2Vec's two adapters (0.3 GB, MIT) and Meta Llama 3 8B Instruct in bf16 (16 GB, Meta Llama 3 Community License, from NousResearch's ungated copy, checked file by file against Meta's SHA-256); about 26 GB in all. It says what this machine has and where each network runs: the denoiser on CUDA when there is an NVIDIA GPU, else the CPU; the text encoder beside it on a GPU of 18 GB or more, else the CPU)
|
raea setup motion [--check] (what raea make motion runs on, made where missing (--check only says): on a Mac the MLX models in raea's models folder (the motion model 1.1 GB, the text encoder 8.8 GB); on Linux and Windows, in raea's models folder's kimodo-torch, a Python 3.11 environment made by uv (which it needs on PATH: https://docs.astral.sh/uv) with PyTorch (its CUDA build where there is an NVIDIA driver, about 8 GB, else CPU only, about 2 GB) and upstream Kimodo (nv-tlabs/kimodo at e1c219c, Apache-2.0), then the weights: Kimodo-SOMA-RP-v1 (1.1 GB, NVIDIA Open Model License), LLM2Vec's two adapters (0.3 GB, MIT) and Meta Llama 3 8B Instruct in bf16 (16 GB, Meta Llama 3 Community License, from NousResearch's ungated copy, checked file by file against Meta's SHA-256); about 26 GB in all. It says what this machine has and where each network runs: the denoiser on CUDA when there is an NVIDIA GPU, else the CPU; the text encoder beside it on a GPU of 18 GB or more, else the CPU)
|
||||||
raea setup godot [--check] (download Godot 4.6.1 with GodotJS, its TypeScript bindings (MIT), into ~/.raea/tools/godot: JavaScriptCore on the Mac, QuickJS on Windows and Linux; raea's own build (the Mac's notarized), else GodotJS's, each checked against its pinned sha256)
|
raea setup godot [--check] (download Godot 4.6.1 with GodotJS, its TypeScript bindings (MIT), into ~/.raea/tools/godot: JavaScriptCore on the Mac, QuickJS on Windows and Linux; raea's own build (the Mac's notarized), else GodotJS's, each checked against its pinned sha256)
|
||||||
```
|
```
|
||||||
@@ -29,7 +36,7 @@ Headless: it needs nothing running and opens no window. Takes up to 1 argument b
|
|||||||
|
|
||||||
| Flag | Takes | What it does |
|
| Flag | Takes | What it does |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `--check` | – | Say which Blender would be used, without downloading or installing anything. |
|
| `--check` | – | Say which Blender (or forma) would be used, without downloading or installing anything. |
|
||||||
| `--download` | – | Download the LTS even when a Blender is already on this machine. |
|
| `--download` | – | Download the LTS (or forma's pinned version) even when one is already on this machine. |
|
||||||
|
|
||||||
<!-- generated:end -->
|
<!-- generated:end -->
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
title: "raea skills"
|
title: "raea skills"
|
||||||
summary: "Install raea's agent skill where Claude Code, Codex, Kimi or Gemini read skills, with its MCP server and hook."
|
summary: "Install raea's agent skill where Claude Code, Codex, Kimi or Gemini read skills, with its MCP servers and hook."
|
||||||
order: 128
|
order: 128
|
||||||
sources: ["engine/cli/src/skill.rs"]
|
sources: ["engine/cli/src/skill.rs"]
|
||||||
---
|
---
|
||||||
|
|
||||||
`raea skills install` copies the skill this raea ships into the folder an agent reads skills from, stamped with this
|
`raea skills install` copies the skill this raea ships into the folder an agent reads skills from, stamped with this
|
||||||
version: `~/.claude/skills` for Claude Code, `~/.agents/skills` for Codex, Kimi Code's skills folder, and
|
version: `~/.claude/skills` for Claude Code, `~/.agents/skills` for Codex, Kimi Code's skills folder, and
|
||||||
`~/.gemini/skills` for Gemini. It also adds the Blender MCP server to the agent, and raea's hooks to every agent
|
`~/.gemini/skills` for Gemini. It also adds the Blender and forma MCP servers to the agent, and raea's hooks to every agent
|
||||||
([`raea hook`](hook.md)): media opened in the Mac's viewer goes to `raea show`, and the quick check runs after each
|
([`raea hook`](hook.md)): media opened in the Mac's viewer goes to `raea show`, and the quick check runs after each
|
||||||
saved composition. A skill folder that's a link (a checkout of raea-skills) is left as it is.
|
saved composition. A skill folder that's a link (a checkout of raea-skills) is left as it is.
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ raea skills install --agent claude --pin quieter --pin bolder # /quieter and
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
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)
|
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 and forma MCP servers 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)
|
||||||
```
|
```
|
||||||
|
|
||||||
Headless: it needs nothing running and opens no window. Takes up to 1 argument besides its flags.
|
Headless: it needs nothing running and opens no window. Takes up to 1 argument besides its flags.
|
||||||
@@ -37,7 +37,7 @@ Headless: it needs nothing running and opens no window. Takes up to 1 argument b
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `--agent` | `claude\|codex\|kimi\|gemini\|grokbot` | Which agent to install for. |
|
| `--agent` | `claude\|codex\|kimi\|gemini\|grokbot` | Which agent to install for. |
|
||||||
| `--no-hooks` | – | Leave Claude Code's settings alone: don't add the quick-check hook. |
|
| `--no-hooks` | – | Leave Claude Code's settings alone: don't add the quick-check hook. |
|
||||||
| `--no-mcp` | – | Don't add the Blender MCP server to the agent. |
|
| `--no-mcp` | – | Don't add the Blender and forma MCP servers to the agent. |
|
||||||
| `--pin` | `MOVE` | Install a note's guide as a skill of its own, so `/MOVE` loads just it (`quieter`, `bolder`, `layout`, `adapt` and the rest). Repeatable. |
|
| `--pin` | `MOVE` | Install a note's guide as a skill of its own, so `/MOVE` loads just it (`quieter`, `bolder`, `layout`, `adapt` and the rest). Repeatable. |
|
||||||
| `--reference` | `cli\|feed\|files\|sdk` | Used by `raea skill`; see [`raea skill`](skill.md). |
|
| `--reference` | `cli\|feed\|files\|sdk` | Used by `raea skill`; see [`raea skill`](skill.md). |
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ pub fn run(args: &[String]) -> R<String> {
|
|||||||
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)");
|
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)");
|
||||||
let usage = format!("{usage}\n {} ({})\n {} ({})", raea_sys_fixes::USAGE, raea_sys_fixes::ABOUT, raea_app_voice::USAGE, raea_app_voice::ABOUT); // a problem looked up before it's guessed at (systems/fixes); speech to speech (apps/voice)
|
let usage = format!("{usage}\n {} ({})\n {} ({})", raea_sys_fixes::USAGE, raea_sys_fixes::ABOUT, raea_app_voice::USAGE, raea_app_voice::ABOUT); // a problem looked up before it's guessed at (systems/fixes); speech to speech (apps/voice)
|
||||||
// a workspace's files and specs (docs/projects.feature), listed under render's usage like library
|
// 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|parts] (a spec's default export as JSON, checked against its schema: brief.ts, script.ts, taste.ts, NAME.parts.ts)\n raea workspace init [NAME] [--layout LAYOUT] | raea workspace adopt DIR [--name NAME] | raea workspace [--json] (a workspace: a git repo of projects under raea.root, ~/Documents/raea unless git config says)\n raea project new NAME [--storage inline|submodule] [--client NAME] | raea project tag [NAME] [--client NAME] [--no-client] | raea project split NAME [--remote URL] | raea project join NAME | raea project [--json] (a project in the workspace: its folder, brief.ts, media/, out/; its client, what raea.app files every card shown from it under (raea cloud's tags: projects don't nest); split and join keep its history)\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 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 {}\n {}", skill::USAGE, tools::blender::USAGE, tools::motion::SETUP_USAGE, tools::motion::SETUP_ABOUT, raea_app_engines::godot::USAGE, raea_app_engines::shot::USAGE, raea_app_engines::round::USAGE);
|
let usage = format!("{usage}\n raea spec FILE.ts [--as brief|script|taste|parts] (a spec's default export as JSON, checked against its schema: brief.ts, script.ts, taste.ts, NAME.parts.ts)\n raea workspace init [NAME] [--layout LAYOUT] | raea workspace adopt DIR [--name NAME] | raea workspace [--json] (a workspace: a git repo of projects under raea.root, ~/Documents/raea unless git config says)\n raea project new NAME [--storage inline|submodule] [--client NAME] | raea project tag [NAME] [--client NAME] [--no-client] | raea project split NAME [--remote URL] | raea project join NAME | raea project [--json] (a project in the workspace: its folder, brief.ts, media/, out/; its client, what raea.app files every card shown from it under (raea cloud's tags: projects don't nest); split and join keep its history)\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 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 {}\n {}\n {}", skill::USAGE, tools::blender::USAGE, raea_app_engines::forma::USAGE, tools::motion::SETUP_USAGE, tools::motion::SETUP_ABOUT, raea_app_engines::godot::USAGE, raea_app_engines::shot::USAGE, raea_app_engines::round::USAGE);
|
||||||
let (export_game, capcut, layers, xml, scene, physics, splat, wear, bake) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, raea_app_scene::USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE, raea_app_lightbake::USAGE);
|
let (export_game, capcut, layers, xml, scene, physics, splat, wear, bake) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, raea_app_scene::USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE, raea_app_lightbake::USAGE);
|
||||||
let apps = format!(" {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n", raea_app_direction::check::USAGE, raea_app_check::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_ask::USAGE, format!("{GOAL_USAGE}\n {}", raea_app_make::USAGE), raea_app_direction::USAGE, raea_app_direction::findings::USAGE, raea_app_notes::USAGE, raea_app_fingerprint::USAGE, raea_sys_index::cli::USAGE);
|
let apps = format!(" {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n", raea_app_direction::check::USAGE, raea_app_check::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_ask::USAGE, format!("{GOAL_USAGE}\n {}", raea_app_make::USAGE), raea_app_direction::USAGE, raea_app_direction::findings::USAGE, raea_app_notes::USAGE, raea_app_fingerprint::USAGE, raea_sys_index::cli::USAGE);
|
||||||
return Ok(usage::under_make(&format!("raea: renders, plays and checks raea compositions (React and TypeScript) on the GPU.\n\nusage: {usage}\n raea init (a project's files where they're missing: edit.tsx, cuts.ts, components/, AGENTS.md)\n raea cut TAKE \"line\" ... | --at A-B ... [--append] (cuts.ts and words.json: a take under media/ cut in the pauses around each line it says, transcribed first if it has no TAKE.words.json; or at those seconds)\n raea words FILE [-o OUT.words.json] (what FILE says, word by word, into its words.json beside it: parakeet-mlx on a Mac, the farm's Whisper on a raea cloud box)\n raea frame TAKE [--at S] (how a take fits the edit: a talking take for <FaceFrame>, a screen for <ScreenFit>, from where its face is)\n raea make component list [WORDS] [--json] | raea make component show NAME [--json] | raea make component add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; WORDS search the library by use and by how people ask: text/reveal, \"count up\", \"chat input\", template; show tells one in full: what it draws, when to use it and when not, its props)\n raea brand DOMAIN|URL (the brand kit read from its website on this machine: brand/brand.css, brand/brand.json, BRAND.md, logos in media/brand; says when a plain fetch saw too little)\n raea guide [NAME] (craft, the floor read before any edit; the modes: pitch, explain, story, play, tool; motion, music, layout and the rest; bevy and bevy/NAME for 3D)\n raea context PROJECT (what to read before working on a project: taste, brief, look, the floor and its modes' guides)\n{apps} raea play EDIT.tsx [--input | --input-script KEYS.json] [--size WxH] [--seconds N|end] (a game, live; also: --input-log FILE --offscreen --snapshot T FILE --json FILE --seek F FILE --pick X,Y --view YAW,PITCH,DISTANCE --scrub N --baked --autoplay --no-vsync --master --3d)\n {export_game} (a game as a program of its own: a Mac app or a command)\n {} ({})\n {capcut}\n {layers}\n {xml}\n {scene} (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)\n {physics} (the bakes <Physics> and <Goo> make)\n {bake}\n {wear} (a .glb's weathering causes for raea/wear: the model with a second UV set and its cause maps, made once in the asset store)\n {splat} (footage trained into a Gaussian splat for <Splat>; setup installs its tools)\n raea run SCRIPT.ts (a TypeScript program on the engine, headless: its default export is called, what it prints is the answer; a check like a room's checkLayout; also: --timeout S)\n raea gen image|video|music|sfx|speech|mesh|text \"PROMPT\" | gen plan|run FLOW.ts|FLOW.json | gen comfy import|export|run|schema FILE | gen models | gen balance (generated media through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI; ComfyUI workflows both ways: raea gen alone lists its flags)\n {neural_usage} (DLSS 5 neural rendering on a `render --aov` folder, with its motion and depth: your own MLX-DLSS build and weights, RAEA_MLXDLSS and RAEA_DLSS_MODEL)\n {light_usage} (each scene on each light path against its path-traced reference: distance in stops, the worst tile, a moving shot's flicker, a frame's cost; DIR/report.json)\n {} (each case on each denoiser against its converged truth: FLIP, RMSE, bias, flicker, blotches, lag after a disocclusion or a light going out, a frame's cost, and how many of MetalFX's numbers each meets; DIR/report.json)\n raea mezz [--check] PATH... (an intra-only ProRes copy of each long-GOP source over 1080p, for smooth scrubbing; --check says which would get one)\n raea traces [show [N|last|DIR]] (the sessions raea left, newest first: how each ended, its glitches; show tells one in full)", raea_app_playable::USAGE, raea_app_playable::ABOUT, raea_denoise_bench::USAGE)));
|
return Ok(usage::under_make(&format!("raea: renders, plays and checks raea compositions (React and TypeScript) on the GPU.\n\nusage: {usage}\n raea init (a project's files where they're missing: edit.tsx, cuts.ts, components/, AGENTS.md)\n raea cut TAKE \"line\" ... | --at A-B ... [--append] (cuts.ts and words.json: a take under media/ cut in the pauses around each line it says, transcribed first if it has no TAKE.words.json; or at those seconds)\n raea words FILE [-o OUT.words.json] (what FILE says, word by word, into its words.json beside it: parakeet-mlx on a Mac, the farm's Whisper on a raea cloud box)\n raea frame TAKE [--at S] (how a take fits the edit: a talking take for <FaceFrame>, a screen for <ScreenFit>, from where its face is)\n raea make component list [WORDS] [--json] | raea make component show NAME [--json] | raea make component add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; WORDS search the library by use and by how people ask: text/reveal, \"count up\", \"chat input\", template; show tells one in full: what it draws, when to use it and when not, its props)\n raea brand DOMAIN|URL (the brand kit read from its website on this machine: brand/brand.css, brand/brand.json, BRAND.md, logos in media/brand; says when a plain fetch saw too little)\n raea guide [NAME] (craft, the floor read before any edit; the modes: pitch, explain, story, play, tool; motion, music, layout and the rest; bevy and bevy/NAME for 3D)\n raea context PROJECT (what to read before working on a project: taste, brief, look, the floor and its modes' guides)\n{apps} raea play EDIT.tsx [--input | --input-script KEYS.json] [--size WxH] [--seconds N|end] (a game, live; also: --input-log FILE --offscreen --snapshot T FILE --json FILE --seek F FILE --pick X,Y --view YAW,PITCH,DISTANCE --scrub N --baked --autoplay --no-vsync --master --3d)\n {export_game} (a game as a program of its own: a Mac app or a command)\n {} ({})\n {capcut}\n {layers}\n {xml}\n {scene} (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)\n {physics} (the bakes <Physics> and <Goo> make)\n {bake}\n {wear} (a .glb's weathering causes for raea/wear: the model with a second UV set and its cause maps, made once in the asset store)\n {splat} (footage trained into a Gaussian splat for <Splat>; setup installs its tools)\n raea run SCRIPT.ts (a TypeScript program on the engine, headless: its default export is called, what it prints is the answer; a check like a room's checkLayout; also: --timeout S)\n raea gen image|video|music|sfx|speech|mesh|text \"PROMPT\" | gen plan|run FLOW.ts|FLOW.json | gen comfy import|export|run|schema FILE | gen models | gen balance (generated media through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI; ComfyUI workflows both ways: raea gen alone lists its flags)\n {neural_usage} (DLSS 5 neural rendering on a `render --aov` folder, with its motion and depth: your own MLX-DLSS build and weights, RAEA_MLXDLSS and RAEA_DLSS_MODEL)\n {light_usage} (each scene on each light path against its path-traced reference: distance in stops, the worst tile, a moving shot's flicker, a frame's cost; DIR/report.json)\n {} (each case on each denoiser against its converged truth: FLIP, RMSE, bias, flicker, blotches, lag after a disocclusion or a light going out, a frame's cost, and how many of MetalFX's numbers each meets; DIR/report.json)\n raea mezz [--check] PATH... (an intra-only ProRes copy of each long-GOP source over 1080p, for smooth scrubbing; --check says which would get one)\n raea traces [show [N|last|DIR]] (the sessions raea left, newest first: how each ended, its glitches; show tells one in full)", raea_app_playable::USAGE, raea_app_playable::ABOUT, raea_denoise_bench::USAGE)));
|
||||||
@@ -196,7 +196,8 @@ pub fn run(args: &[String]) -> R<String> {
|
|||||||
if args[0] == "setup" && args.get(1).map(String::as_str) == Some("motion") {
|
if args[0] == "setup" && args.get(1).map(String::as_str) == Some("motion") {
|
||||||
return tools::motion::setup(&args[2..]);
|
return tools::motion::setup(&args[2..]);
|
||||||
}
|
}
|
||||||
// `setup blender|godot`, `blender ...` and `godot ...`: Blender and Godot scripted (SK11, apps/engines)
|
// `setup blender|godot|forma`, `blender ...`, `godot ...` and `forma ...`: Blender and Godot scripted, forma run (SK11,
|
||||||
|
// apps/engines, apps/forma)
|
||||||
if let Some(done) = raea_app_engines::cli(args) {
|
if let Some(done) = raea_app_engines::cli(args) {
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
//! `raea --version` the agent reads `raea skill` instead.
|
//! `raea --version` the agent reads `raea skill` instead.
|
||||||
use super::*;
|
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)";
|
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 and forma MCP servers 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)";
|
||||||
|
|
||||||
/// `raea doctor [--fix] [DIR]` (SK10): what doesn't match this raea, an agent's skill reinstalled by --fix.
|
/// `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> {
|
pub fn doctor(args: &[String]) -> R<String> {
|
||||||
@@ -117,7 +117,7 @@ pub fn install(args: &[String]) -> R<String> {
|
|||||||
if agent == "grokbot" { return tools::agent_grokbot::stage(&to, out); }
|
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
|
// 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)?; }
|
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
|
// the MCP servers raea offers (SK11): blender, for a running Blender, and forma (FM6); --no-mcp leaves the agent's servers alone
|
||||||
if !args.iter().any(|a| a == "--no-mcp") {
|
if !args.iter().any(|a| a == "--no-mcp") {
|
||||||
out += &tools::agent_mcp::offer(agent)?;
|
out += &tools::agent_mcp::offer(agent)?;
|
||||||
out += "\n";
|
out += "\n";
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ fn help_lists_every_verb() {
|
|||||||
let listed = |v: &str| [format!("raea {v} "), format!("raea {v}\n"), format!("| {v} ")].iter().any(|l| help.contains(l.as_str()));
|
let listed = |v: &str| [format!("raea {v} "), format!("raea {v}\n"), format!("| {v} ")].iter().any(|l| help.contains(l.as_str()));
|
||||||
let missing: Vec<_> = verbs.iter().filter(|v| !listed(v) && !unlisted.contains(&v.as_str())).collect();
|
let missing: Vec<_> = verbs.iter().filter(|v| !listed(v) && !unlisted.contains(&v.as_str())).collect();
|
||||||
assert!(missing.is_empty(), "not in raea help: {missing:?}");
|
assert!(missing.is_empty(), "not in raea help: {missing:?}");
|
||||||
for usage in [raea_app_check::USAGE, raea_app_ask::USAGE, raea_app_direction::check::USAGE, raea_app_direction::USAGE, raea_app_notes::USAGE, raea_app_game::USAGE, raea_app_playable::USAGE, raea_app_scene::USAGE, raea_app_voice::USAGE, motion::physics::USAGE, raea_runtime_wear::USAGE, tools::splat::USAGE, tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_make::USAGE, tools::blender::USAGE, raea_app_lightbake::USAGE] {
|
for usage in [raea_app_check::USAGE, raea_app_ask::USAGE, raea_app_direction::check::USAGE, raea_app_direction::USAGE, raea_app_notes::USAGE, raea_app_game::USAGE, raea_app_playable::USAGE, raea_app_scene::USAGE, raea_app_voice::USAGE, motion::physics::USAGE, raea_runtime_wear::USAGE, tools::splat::USAGE, tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_make::USAGE, tools::blender::USAGE, raea_app_engines::forma::USAGE, raea_app_lightbake::USAGE] {
|
||||||
assert!(help.contains(usage), "{usage}");
|
assert!(help.contains(usage), "{usage}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const GROUPS: [string, string, string[]][] = [
|
|||||||
["Goal and checks", "What the work is held to (brief.ts's `goal`, checked by `raea goal`), and what's wrong before anyone watches it.", ["goal", "check", "judge", "fingerprint", "findings", "scene", "light", "bench", "world", "doctor", "hook", "traces"]],
|
["Goal and checks", "What the work is held to (brief.ts's `goal`, checked by `raea goal`), and what's wrong before anyone watches it.", ["goal", "check", "judge", "fingerprint", "findings", "scene", "light", "bench", "world", "doctor", "hook", "traces"]],
|
||||||
["Footage", "Takes, cuts and the camera, from your own media.", ["media", "words", "cut", "frame", "track", "mezz", "neural"]],
|
["Footage", "Takes, cuts and the camera, from your own media.", ["media", "words", "cut", "frame", "track", "mezz", "neural"]],
|
||||||
["Sound", "Music read, voices, and the audio setup.", ["song", "setup-audio", "voice"]],
|
["Sound", "Music read, voices, and the audio setup.", ["song", "setup-audio", "voice"]],
|
||||||
["raea make: the asset tools", "What a project is made from, each a `raea make TOOL`: components, solids, clothes and motion for SOMA's body, splats, physics, light and weathering bakes, foley and instruments; and generated media, Blender and Godot.", ["make", "component", "solid", "clothes", "motion", "splat", "physics", "bake", "wear", "sao", "tokensynth", "sounds", "gen", "blender", "godot"]],
|
["raea make: the asset tools", "What a project is made from, each a `raea make TOOL`: components, solids, clothes and motion for SOMA's body, splats, physics, light and weathering bakes, foley and instruments; and generated media, Blender, Godot and forma.", ["make", "component", "solid", "clothes", "motion", "splat", "physics", "bake", "wear", "sao", "tokensynth", "sounds", "gen", "blender", "godot", "forma"]],
|
||||||
["Agents and setup", "What an agent reads and shows the person, and the tools raea installs.", ["guide", "fix", "context", "notes", "show", "skill", "skills", "setup", "bug", "ask"]],
|
["Agents and setup", "What an agent reads and shows the person, and the tools raea installs.", ["guide", "fix", "context", "notes", "show", "skill", "skills", "setup", "bug", "ask"]],
|
||||||
]
|
]
|
||||||
/** a verb as it is typed: an asset tool is under make (`make solid`), every other verb is itself */
|
/** a verb as it is typed: an asset tool is under make (`make solid`), every other verb is itself */
|
||||||
|
|||||||
Reference in new issue
Block a user