EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge M13.14 agent-interface audit + lazy open (worktree-agent-a5f8967ebd42ce98b)
Brandon Thomas081ce79de394
diff --cc crates/automation/src/tests.rsindex 947066651,7e5fe9509..f78447b9d--- a/crates/automation/src/tests.rs+++ b/crates/automation/src/tests.rs@@@ -318,23 -318,57 +318,78 @@@ fn run_script_round_trip()assert!(err && c[0]["text"].as_str().unwrap().contains("not available"), "{c:?}");}+#[test]+fn puppet_rigging_over_mcp() {+ let mut s = server();+ let ex = |s: &mut McpServer, command: &str, params: Value| call_json(s, "execute_command", json!({"command": command, "params": params}));+ ex(&mut s, "comp.new", json!({"name": "Rig", "width": 200, "height": 100, "duration": 2}));+ let id = ex(&mut s, "layer.newSolid", json!({"width": 100, "height": 60, "color": "#3060c0"}))["layer"].clone();+ let lead = ex(&mut s, "puppet.addPin", json!({"layer": id, "position": [10, 30]}))["pin"].clone();+ let tail = ex(&mut s, "puppet.addPin", json!({"layer": id, "position": [90, 30]}))["pin"].clone();+ let bend = ex(&mut s, "puppet.addPin", json!({"layer": id, "kind": "bend", "position": [50, 30]}))["pin"].clone();+ // Turn and scale the Bend pin, select pins, make the tail trail the leader, rig the leader.+ ex(&mut s, "puppet.setPin", json!({"layer": id, "pin": bend, "rotation": 45, "scale": 120}));+ assert_eq!(ex(&mut s, "puppet.selectPins", json!({"layer": id, "pins": [lead, tail]}))["pins"], json!([lead, tail]));+ assert_eq!(ex(&mut s, "puppet.follow", json!({"delay": 0.25}))["pins"], json!([{"pin": tail, "delay": 0.25}]));+ let r = ex(&mut s, "paths.pointsFollowNulls", json!({"layer": id, "pins": [lead]}));+ assert_eq!(r["nulls"].as_array().unwrap().len(), 1);+ // The new commands are listed for agents.+ let (c, _) = call(&mut s, "list_commands", json!({"filter": "puppet."}));+ let text = c[0]["text"].as_str().unwrap();+ assert!(text.contains("puppet.follow") && text.contains("puppet.selectPins"), "{text}");+}+++ /// The agent-interface audit (MCP side): every registered engine command is listed by+ /// `list_commands` with a label, params doc and JSON Schema, described by `describe_command`,+ /// and routed by `execute_command` (an unknown parameter is rejected by that very command+ /// without running it).+ #[test]+ fn every_engine_command_is_reachable_over_mcp() {+ let mut s = server();+ let tools = rpc(&mut s, 1, "tools/list", json!({}))["tools"].as_array().unwrap().clone();+ let names: Vec<&str> = tools.iter().map(|t| t["name"].as_str().unwrap()).collect();+ for want in ["list_commands", "describe_command", "execute_command", "add_effect", "list_effects", "get_state", "render_frame", "get_layer", "set_property"]+ {+ assert!(names.contains(&want), "{want}");+ }+ let listed = call_json(&mut s, "list_commands", json!({"schemas": true}));+ let listed: std::collections::HashMap<&str, &Value> = listed.as_array().unwrap().iter().map(|c| (c["id"].as_str().unwrap(), c)).collect();+ let specs = effectcraft_engine::command_specs();+ assert_eq!(listed.len(), specs.len());+ for spec in specs {+ let c = listed.get(spec.id).unwrap_or_else(|| panic!("{} not listed", spec.id));+ assert!(!spec.label.trim().is_empty(), "{}: no label", spec.id);+ assert!(spec.params.trim_start().starts_with('{'), "{}: params doc {:?}", spec.id, spec.params);+ assert_eq!(c["schema"]["type"], "object", "{}", spec.id);+ assert!(c["schema"]["properties"].is_object(), "{}", spec.id);+ let d = call_json(&mut s, "describe_command", json!({"command": spec.id}));+ assert_eq!(d["schema"], c["schema"], "{}", spec.id);+ let (content, err) = call(&mut s, "execute_command", json!({"command": spec.id, "params": {"__audit": 1}}));+ let text = content[0]["text"].as_str().unwrap_or_default();+ assert!(err && text.contains("unknown parameter") && text.contains(spec.id), "{}: {text}", spec.id);+ }+ }++ #[test]+ fn high_level_tools_add_effect_and_report_state() {+ let mut s = server();+ call_json(&mut s, "execute_command", json!({"command": "comp.new", "params": {"name": "A", "width": 64, "height": 48, "duration": 1}}));+ let l = call_json(&mut s, "execute_command", json!({"command": "layer.newSolid", "params": {"color": "#808080"}}))["layer"].clone();+ let fx = call_json(&mut s, "list_effects", json!({"filter": "gaussian"}));+ assert!(fx.as_array().unwrap().iter().any(|e| e["id"] == "ec.blur.gaussian" && e["gpu"].is_boolean()), "{fx}");+ let r = call_json(&mut s, "add_effect", json!({"layer": l, "effect": "Gaussian Blur", "values": {"blurriness": 7}}));+ assert_eq!(r["path"], "effects/#1", "{r}");+ assert!(r["params"].as_array().unwrap().iter().any(|p| p["path"] == "effects/#1/blurriness" && p["value"] == 7.0), "{r}");+ // A second effect lands at #2.+ let r = call_json(&mut s, "add_effect", json!({"layer": l, "effect": "ec.color.levels"}));+ assert_eq!(r["path"], "effects/#2", "{r}");+ let p = call_json(&mut s, "get_property", json!({"layer": l, "path": "effects/#1/blurriness"}));+ assert_eq!(p["value"], 7.0, "{p}");+ let st = call_json(&mut s, "get_state", json!({}));+ assert!(st["state"].is_object() && st["app"]["commands"].as_u64().unwrap() > 500, "{st}");+ assert!(st["app"]["effects"]["total"].as_u64().unwrap() > 200, "{st}");+ assert!(st["app"]["parity"]["summary"].as_str().unwrap().contains("parity"), "{st}");+ // Unknown effects fail cleanly.+ let (c, err) = call(&mut s, "add_effect", json!({"layer": l, "effect": "No Such Effect"}));+ assert!(err && c[0]["text"].as_str().unwrap().contains("unknown effect"), "{c:?}");+ }