M14.4: scripting with an After Effects-style JavaScript object model

New crate effectcraft-script (L4): boa runtime with app/Project/CompItem/
Layer/PropertyGroup/Property/TextDocument/MarkerValue/RenderQueue/File
object model over engine commands (undoable, undo groups), AE match-name
table, file/network security gate. Entry points: script.run command,
File > Scripts > Run Script File (.jsx/.js), Window > Script Console,
effectcraft-cli script, MCP run_script. Engine: project.delete/duplicate,
prop.renameGroup/setGroupEnabled/removeGroup/duplicateGroup/moveGroup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-02 22:13:09 -04:00
co-authored by Claude Opus 5.5
parent e911cc5c93
commit 78cd313d3c
36 changed files with 4621 additions and 28 deletions
+24
View File
@@ -140,6 +140,15 @@ fn execute_command(b: &mut Backend, a: &Value) -> Result<Reply> {
json_reply(b.exec(id, params)?)
}
fn run_script(b: &mut Backend, a: &Value) -> Result<Reply> {
let code = get(a, "code").and_then(Value::as_str).ok_or_else(|| Error::BadArgs("missing `code` (JavaScript)".into()))?;
let mut p = json!({"code": code});
if let Some(n) = get(a, "name") {
p["name"] = n.clone();
}
json_reply(b.exec("script.run", p)?)
}
fn get_project(b: &mut Backend, _: &Value) -> Result<Reply> {
json_reply(b.exec("project.summary", json!({}))?)
}
@@ -386,6 +395,21 @@ static TOOLS: &[ToolDef] = &[
},
run: execute_command,
},
ToolDef {
name: "run_script",
description: "Run JavaScript with an After Effects-style scripting object model (app, app.project, items.addComp, comp.layers.addSolid/addText/addShape/addNull/addCamera/addLight, layer.property(\"ADBE Transform Group\").property(\"ADBE Position\").setValueAtTime(t, v), Effects.addProperty(\"ADBE Gaussian Blur 2\"), expressions, markers, renderQueue…). Every edit is an undoable engine command; app.beginUndoGroup/endUndoGroup make one undo step. Returns {ok, result (last expression value), output (writeLn/$.writeln/alert text), error: {message, line, column} | null}. File access is limited to the project folder unless the user allows scripts to write files.",
bridge_only: false,
schema: || {
schema(
json!({
"code": {"type": "string", "description": "JavaScript source, e.g. `var c = app.project.items.addComp(\"Main\", 1920, 1080, 1, 5, 30); c.layers.addText(\"Hi\"); c.numLayers`."},
"name": {"type": "string", "description": "Script name used in error messages (default `script`)."}
}),
&["code"],
)
},
run: run_script,
},
ToolDef {
name: "get_project",
description: "Project overview: file path, dirty flag, bit depth, every item (id, name, type Composition/Footage/Solid/Folder, size, duration, layer count), the active comp id, current time (s), selected layers and the undo stack.",