PhotoCraft: An open-source, photo editor written by scratch in pure Rust
M11: ten more MCP acceptance tasks (11-20) for FILE-216-6 (#3562)
Reynold Hu857a4f7d8a1a
diff --git a/crates/automation/tests/agent_tasks.rs b/crates/automation/tests/agent_tasks.rsindex 8eb6ba725..b185e310a 100644--- a/crates/automation/tests/agent_tasks.rs+++ b/crates/automation/tests/agent_tasks.rs@@ -343,3 +343,102 @@ async fn agent_play_refuses_a_recorded_file_open() {shutdown(c, server).await;std::fs::remove_dir_all(dir).unwrap();}++/// The next ten acceptance tasks (11–20): strokes, inverse fills, duplication, merges,+/// flattening, adjustments, feathering, expand, renaming/deleting and an export/reopen round+/// trip — all through MCP tools and checked from outside the engine.+#[tokio::test(flavor = "multi_thread")]+async fn agent_completes_ten_more_scripted_tasks() {+ let dir = tmp("tasks2");+ let (c, server) = connect(&dir).await;++ // 11. Stroke a selection: a red square with a black outside stroke.+ tool(&c, "doc_new", json!({"width": 80, "height": 80, "background": "white"})).await;+ run(&c, "select.rect", json!({"x": 20, "y": 20, "width": 40, "height": 40})).await;+ run(&c, "edit.fill", json!({"color": "#ff0000"})).await;+ run(&c, "edit.stroke", json!({"width": 4, "color": "#000000", "location": "outside"})).await;+ let inside = pixel(&c, 40, 40).await;+ let edge = pixel(&c, 18, 40).await;+ let away = pixel(&c, 5, 5).await;+ assert!(inside[0] > 0.99 && inside[1] < 0.01, "task 11: the centre is red {inside:?}");+ assert!(edge[0] < 0.1 && edge[1] < 0.1, "task 11: the stroke is black {edge:?}");+ assert!(away[0] > 0.99 && away[1] > 0.99, "task 11: outside stays white {away:?}");+ run(&c, "select.deselect", json!({})).await;++ // 12. Inverse the selection: a blue frame around the red square.+ run(&c, "select.rect", json!({"x": 20, "y": 20, "width": 40, "height": 40})).await;+ run(&c, "select.inverse", json!({})).await;+ run(&c, "edit.fill", json!({"color": "#0000ff"})).await;+ let centre = pixel(&c, 40, 40).await;+ let frame = pixel(&c, 4, 4).await;+ assert!(centre[0] > 0.99 && centre[2] < 0.01, "task 12: the centre keeps red {centre:?}");+ assert!(frame[2] > 0.99 && frame[0] < 0.01, "task 12: the frame is blue {frame:?}");+ run(&c, "select.deselect", json!({})).await;++ // 13. Paint a green patch on a new layer and duplicate it (offset, as Photoshop's default).+ run(&c, "layer.new.layer", json!({"name": "Patch"})).await;+ run(&c, "select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20})).await;+ run(&c, "edit.fill", json!({"color": "#00ff00"})).await;+ run(&c, "select.deselect", json!({})).await;+ run(&c, "layer.duplicate", json!({})).await;+ let doc = inspect(&c).await;+ assert_eq!(doc["layers"].as_array().unwrap().len(), 3, "task 13: {doc}");+ let patches = doc["layers"].as_array().unwrap().iter().filter(|l| l["name"].as_str().is_some_and(|n| n.starts_with("Patch"))).count();+ assert_eq!(patches, 2, "task 13: {doc}");++ // 14. Merge the copy down; the two patches become one layer.+ run(&c, "layer.mergeDown", json!({})).await;+ assert_eq!(inspect(&c).await["layers"].as_array().unwrap().len(), 2, "task 14");++ // 15. Flatten the image; the patch survives.+ run(&c, "layer.flattenImage", json!({})).await;+ let doc = inspect(&c).await;+ assert_eq!(doc["layers"].as_array().unwrap().len(), 1, "task 15: {doc}");+ let green = pixel(&c, 20, 20).await;+ assert!(green[1] > 0.99 && green[0] < 0.01, "task 15: the patch survives {green:?}");++ // 16. A Hue/Saturation adjustment layer turns the red square green without touching pixels.+ run(&c, "layer.newAdjustmentLayer.hueSaturation", json!({"hue": 120})).await;+ assert_eq!(top_layer(&inspect(&c).await)["kind"], "Adjustment", "task 16");+ let shifted = pixel(&c, 40, 40).await;+ assert!(shifted[1] > 0.5 && shifted[0] < 0.5, "task 16: red turns green {shifted:?}");+ run(&c, "layer.delete", json!({})).await;++ // 17. Feather the selection and reveal a mask through it: the edge blends.+ run(&c, "select.rect", json!({"x": 20, "y": 20, "width": 40, "height": 40})).await;+ run(&c, "select.modify.feather", json!({"radius": 4})).await;+ run(&c, "layer.layerMask.revealSelection", json!({})).await;+ let doc = inspect(&c).await;+ assert_eq!(top_layer(&doc)["hasMask"], true, "task 17");+ let boundary = pixel(&c, 20, 40).await;+ assert!(boundary[3] > 0.05 && boundary[3] < 0.95, "task 17: the feathered edge keeps partial alpha {boundary:?}");+ run(&c, "select.deselect", json!({})).await;++ // 18. Expand a selection and read its bounds back.+ run(&c, "select.rect", json!({"x": 20, "y": 20, "width": 20, "height": 20})).await;+ run(&c, "select.modify.expand", json!({"radius": 5})).await;+ let bounds = inspect(&c).await["selectionBounds"].clone();+ let b = bounds.as_array().unwrap_or_else(|| panic!("task 18: {bounds}"));+ let (x, w) = (b[0].as_i64().unwrap(), b[2].as_i64().unwrap());+ assert!((13..=15).contains(&x) && (30..=32).contains(&w), "task 18: expanded outward {bounds}");+ run(&c, "select.deselect", json!({})).await;++ // 19. Rename a layer and delete it again.+ run(&c, "layer.new.layer", json!({"name": "Scratch"})).await;+ run(&c, "layer.renameLayer", json!({"name": "Delivery"})).await;+ assert_eq!(top_layer(&inspect(&c).await)["name"], "Delivery", "task 19");+ run(&c, "layer.delete", json!({})).await;+ assert_eq!(inspect(&c).await["layers"].as_array().unwrap().len(), 1, "task 19: deleted");++ // 20. Export the final image and reopen the PNG as a flat document.+ tool(&c, "doc_export", json!({"path": "final.png"})).await;+ tool(&c, "doc_close", json!({})).await;+ tool(&c, "doc_open", json!({"path": "final.png"})).await;+ let doc = inspect(&c).await;+ assert_eq!((doc["width"].as_u64(), doc["height"].as_u64()), (Some(80), Some(80)), "task 20");+ assert_eq!(doc["layers"].as_array().unwrap().len(), 1, "task 20: a flat reopen");+ tool(&c, "doc_close", json!({})).await;++ shutdown(c, server).await;+ std::fs::remove_dir_all(dir).unwrap();+}diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 0e8a58c75..5b6275f0e 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -124,7 +124,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t| FILE-216-3 | TIFF, RAW and EXR corpora read by tests; per-camera RAW coverage reported | partial | [#216](https://github.com/storytold/photocraft/issues/216) | EXR: corpus/exr (the OpenEXR deep test images, pinned) is read by codecs tests/deep_exr.rs in the CI corpus job, against the ID manifests of the upstream sidecars. corpus/tiff and corpus/raw are still copied in by hand and no test reads them; no per-camera RAW report || FILE-216-4 | Exports re-open in a third-party oracle editor | missing | [#216](https://github.com/storytold/photocraft/issues/216) | The round trip is our export -> our import || FILE-216-5 | Save-path tests: layered TIFF, PDF, SVG, ACO/ASE, .shc, Smart Filters, atomic-save failure | partial | [#216](https://github.com/storytold/photocraft/issues/216) | Every save path that exists is tested by saving and reading back: layered TIFF io tests/tiff_layers.rs (every_compression_keeps_the_layers, advanced_blending_survives_layered_tiff_in_both_byte_orders), print PDF engine print_cmds/tests.rs (print_dry_run_renders_a_pdf_and_reports_lp decodes the image back), ACO/ASE engine swatch_cmds/tests.rs (aco_round_trip_keeps_16_bit_values_and_books, ase_round_trip_keeps_groups_floats_and_kinds), .shc psd shc.rs shc_round_trips_and_rejects_hostile_input and engine layer_style.rs contour_presets_and_custom_curves_apply_in_one_undo_step, Smart Filters engine tests/smart_psd.rs (smart_filters_survive_psd_in_every_colour_model), atomic-save failure format/src/atomic/tests.rs (BUG-203-6). There is no SVG writer (SVG opens only) and no Photoshop PDF save (FILE-215-10), so those have nothing to test yet; the row stays partial until they exist |-| FILE-216-6 | 30-50 end-to-end workflow acceptance tasks driven through MCP or commands | partial | [#216](https://github.com/storytold/photocraft/issues/216) | automation/tests/agent_tasks.rs: 10 MCP tasks |+| FILE-216-6 | 30-50 end-to-end workflow acceptance tasks driven through MCP or commands | partial | [#216](https://github.com/storytold/photocraft/issues/216) | automation/tests/agent_tasks.rs: 20 MCP tasks |## Toolsdiff --git a/scorecard/file_compat.toml b/scorecard/file_compat.tomlindex 51f40c3a1..e6943b578 100644--- a/scorecard/file_compat.toml+++ b/scorecard/file_compat.toml@@ -192,4 +192,4 @@ id = "FILE-216-6"target = "30-50 end-to-end workflow acceptance tasks driven through MCP or commands"status = "partial"issue = 216-note = "automation/tests/agent_tasks.rs: 10 MCP tasks"+note = "automation/tests/agent_tasks.rs: 20 MCP tasks"