PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Use the real Gaussian Blur id in the docs and MCP schema (#390)
floflo7779ae984c0aea9
diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rsindex 69a55a34d..6c9952336 100644--- a/crates/automation/src/server.rs+++ b/crates/automation/src/server.rs@@ -114,7 +114,7 @@ pub struct ListParams {#[derive(Debug, Deserialize, JsonSchema)]pub struct RunParams {- /// Command id, e.g. `layer.new.layer`, `filter.blur.gaussian`.+ /// Command id, e.g. `layer.new.layer`, `filter.blur.gaussianBlur`.pub id: String,/// Command parameters as a JSON object (see the `params` doc in `command_list`).#[serde(default)]diff --git a/crates/automation/tests/mcp.rs b/crates/automation/tests/mcp.rsindex 8468e5d49..7915cf3e6 100644--- a/crates/automation/tests/mcp.rs+++ b/crates/automation/tests/mcp.rs@@ -169,6 +169,39 @@ async fn command_list_filters() {client.cancel().await.unwrap();}+/// The backticked examples in every `id` property description of a schema.+fn id_examples(schema: &Value, out: &mut Vec<String>) {+ match schema {+ Value::Object(m) => {+ if let Some(d) = m.get("properties").and_then(|p| p["id"]["description"].as_str()) {+ out.extend(d.split('`').skip(1).step_by(2).map(str::to_owned));+ }+ m.values().for_each(|v| id_examples(v, out));+ }+ Value::Array(a) => a.iter().for_each(|v| id_examples(v, out)),+ _ => {}+ }+}++#[tokio::test(flavor = "multi_thread")]+async fn command_ids_in_tool_schemas_exist() {+ // Agents copy these examples verbatim (#378).+ let client = connect(PhotocraftMcp::headless()).await;+ let all = json_of(&call(&client, "command_list", json!({})).await);+ let ids: Vec<&str> = all.as_array().unwrap().iter().filter_map(|c| c["id"].as_str()).collect();+ let tools = client.list_all_tools().await.unwrap();+ for name in ["command_run", "command_batch"] {+ let tool = tools.iter().find(|t| t.name == name).unwrap();+ let mut examples = Vec::new();+ id_examples(&Value::Object((*tool.input_schema).clone()), &mut examples);+ assert!(!examples.is_empty(), "{name}: no example ids");+ for id in examples {+ assert!(ids.contains(&id.as_str()), "{name}: `{id}` is not a registered command");+ }+ }+ client.cancel().await.unwrap();+}+#[tokio::test(flavor = "multi_thread")]async fn errors_are_tool_errors_not_crashes() {let client = connect(PhotocraftMcp::headless()).await;diff --git a/docs/architecture.md b/docs/architecture.mdindex df1f89af9..af0c10607 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -21,7 +21,7 @@ This plan sets out:**Principles**1. **Engine-first, headless-first.** Every feature is reachable without a GUI: from tests, the CLI and MCP. The GUI is one client of the engine.-2. **Everything is a command.** Each user-visible action has a stable `CommandId` (such as `filter.blur.gaussian`) with typed, serializable parameters. The menu, command palette, shortcuts, recorded actions/macros, CLI, MCP and plugins all dispatch the same commands.+2. **Everything is a command.** Each user-visible action has a stable `CommandId` (such as `filter.blur.gaussianBlur`) with typed, serializable parameters. The menu, command palette, shortcuts, recorded actions/macros, CLI, MCP and plugins all dispatch the same commands.3. **Data describes the UI; toolkits draw it.** Tools produce *overlay primitives* (lines, handles, marching-ants paths) as data. Filter and adjustment dialogs are generated from *parameter schemas*. A new toolkit implements one renderer for each, not about 150 bespoke dialogs.4. **One algorithm, one parameter struct.** Every algorithm has a CPU reference implementation (Rust + rayon, deterministic). Some also get a GPU implementation (WGSL). Both read the same `#[repr(C)]` `bytemuck::Pod` parameter struct. We never keep hand-synced copies of an algorithm in several languages.5. **Immutable snapshots, copy-on-write tiles.** Pixel data is stored in `Arc`-shared 256² tiles. Taking a document snapshot is O(layers), which makes undo, background jobs, autosave and UI reads cheap and lock-free.@@ -180,7 +180,7 @@ pub struct CommandInvocation { pub id: CommandId, pub params: serde_json::Value### 4.2 `CommandRegistry`: the menu, palette and automation catalogueEach command registers the following:-- `id` (`"filter.blur.gaussian"`), `label`, `menu_path` (`["Filter","Blur"]`), and a `default_shortcut`.+- `id` (`"filter.blur.gaussianBlur"`), `label`, `menu_path` (`["Filter","Blur"]`), and a `default_shortcut`.- `params: schemars::Schema`, plus optional `ui_hints` (slider ranges, units, log scale, grouping).- `enabled(&DocSnapshot, &ToolState) -> bool` and `checked(...) -> Option<bool>`.- `preview: PreviewMode` (None / Live / Proxy). This lets dialogs show on-canvas preview generically.@@ -189,7 +189,7 @@ Each command registers the following:**Consumers:**- The GUI builds the menu bar, the ⌘K palette and the shortcut editor from it.- `automation` exposes the registry as MCP tools.-- `photocraft-cli` exposes `photocraft run --cmd filter.blur.gaussian --param radius=4 in.psd out.png`.+- `photocraft-cli` exposes `photocraft-cli run in.psd --cmd filter.blur.gaussianBlur --params '{"radius":4}' --out out.png`.- Action recording is simply `Vec<CommandInvocation>`.### 4.3 Tools: pointer events in, ops and overlays outdiff --git a/docs/development.md b/docs/development.mdindex 6d7b09e79..d343d0ee3 100644--- a/docs/development.md+++ b/docs/development.md@@ -94,7 +94,7 @@ See `docs/control-protocol.md` for every method. Tips:cargo run -p photocraft-cli -- convert in.psd out.pcraft # any supported format -> anycargo run -p photocraft-cli -- info out.pcraft # JSON: size, mode, depth, layer treecargo run -p photocraft-cli -- run in.png --cmd layer.new.layer --params '{"name":"Ink"}' \- --cmd filter.blur.gaussian --params '{"radius":3}' --out out.psd+ --cmd filter.blur.gaussianBlur --params '{"radius":3}' --out out.psdcargo run -p photocraft-cli -- run --new '{"width":800,"height":600}' --cmd document.inspectcargo run -p photocraft-cli -- batch --actions actions.json --in photos/ --out done/ --format jpgcargo run -p photocraft-cli -- commands --filter blur # the command registry@@ -164,7 +164,7 @@ A typical agent loop:1. `doc_open {path}`2. `command_list {filter:"blur"}`-3. `command_run {id:"filter.blur.gaussian", params:{radius:4}}`+3. `command_run {id:"filter.blur.gaussianBlur", params:{radius:4}}`4. `doc_render_preview` to check the result5. `doc_save {path:"out.pcraft"}`