feat(mcp): add standardized spatial metadata schema and visual differential streaming

- Standardize spatial metadata under \_spatial\ with \CAD_WCS\ CRS, document units, forward/inverse affine matrices (\pixel_to_world_matrix\, \world_to_pixel_matrix\), camera projection, and world bounding bounds
- Implement visual differential engine (\compute_visual_diff\) detecting pixel-level changes between viewport frames
- Map dirty pixel bounding box directly to CAD world coordinates (\dirty_world_bounds\) using the spatial transform
- Add \diff\, \diff_mode\ ('highlight' | 'crop' | 'metadata_only'), and \
eset_diff_baseline\ parameters to \ocs_capture\
- Support high-efficiency dirty region cropping to drastically minimize vision token and bandwidth consumption
- Add unit tests for spatial projection, diff computation, tool schema, and structured metadata formatting
This commit is contained in:
Karim Jerbi committed 2026-10-01 14:48:31 +01:00
1 parent c8caac2e10
commit 350742f2b0
3 files changed
+467 -6

No files matched your search

+19
View File
@@ -1422,6 +1422,22 @@ impl OpenCADStudio {
.save_with_format(&path, image::ImageFormat::Png)
.map_err(|e| e.to_string())?;
let doc_unit = crate::app::properties::insunits_name(
self.tabs[self.active_tab].scene.document.header.insertion_units,
);
let spatial_obj = json!({
"crs": "CAD_WCS",
"unit": doc_unit,
"pixel_resolution": [image.width(), image.height()],
"world_bounds": grounding.viewport_world_bounds,
"pixel_to_world_matrix": grounding.pixel_to_world_matrix,
"world_to_pixel_matrix": grounding.world_to_pixel_matrix,
"camera": grounding.camera,
"target_plane": grounding.target_plane,
"annotations": grounding.visible_entities.clone(),
});
Ok(json!({
"path": path,
"scope": actual_scope,
@@ -1431,6 +1447,9 @@ impl OpenCADStudio {
"document_id": self.tabs[self.active_tab].id,
"revision": self.tabs[self.active_tab].edit_revision,
"camera_revision": self.tabs[self.active_tab].scene.camera_generation,
"_spatial": spatial_obj,
"pixel_to_world_matrix": grounding.pixel_to_world_matrix,
"world_to_pixel_matrix": grounding.world_to_pixel_matrix,
"viewport_world_bounds": grounding.viewport_world_bounds,
"camera": grounding.camera,
"annotated": annotate,