"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
feat: fuse manual + auto-generated harness (50 -> 101 tests)
ndpvt-webe5db3582b97a
diff --git a/openscreen/agent-harness/TEST.md b/openscreen/agent-harness/TEST.mdindex c39bb46f4..10ce74d49 100644--- a/openscreen/agent-harness/TEST.md+++ b/openscreen/agent-harness/TEST.md@@ -2,14 +2,14 @@## Summary-- **Total tests**: 50-- **Passed**: 50+- **Total tests**: 101+- **Passed**: 101- **Failed**: 0- **Test suites**: 2 (unit + end-to-end)## Test Suites-### test_core.py — Unit Tests (37 tests, no ffmpeg required)+### test_core.py — Unit Tests (78 tests, no ffmpeg required)| # | Test | Status ||---|------|--------|@@ -23,63 +23,114 @@| 8 | TestSession::test_open_nonexistent | PASSED || 9 | TestSession::test_save_without_path | PASSED || 10 | TestSession::test_status | PASSED |-| 11 | TestProject::test_new_project | PASSED |-| 12 | TestProject::test_info | PASSED |-| 13 | TestProject::test_info_without_project | PASSED |-| 14 | TestProject::test_set_setting | PASSED |-| 15 | TestProject::test_set_invalid_setting | PASSED |-| 16 | TestZoom::test_add_zoom | PASSED |-| 17 | TestZoom::test_list_zoom | PASSED |-| 18 | TestZoom::test_remove_zoom | PASSED |-| 19 | TestZoom::test_remove_nonexistent_zoom | PASSED |-| 20 | TestZoom::test_invalid_depth | PASSED |-| 21 | TestZoom::test_invalid_focus | PASSED |-| 22 | TestZoom::test_invalid_time_range | PASSED |-| 23 | TestZoom::test_zoom_undo | PASSED |-| 24 | TestSpeed::test_add_speed | PASSED |-| 25 | TestSpeed::test_invalid_speed | PASSED |-| 26 | TestSpeed::test_list_and_remove | PASSED |-| 27 | TestTrim::test_add_trim | PASSED |-| 28 | TestTrim::test_list_and_remove | PASSED |-| 29 | TestCrop::test_default_crop | PASSED |-| 30 | TestCrop::test_set_crop | PASSED |-| 31 | TestCrop::test_invalid_crop | PASSED |-| 32 | TestCrop::test_crop_out_of_bounds | PASSED |-| 33 | TestAnnotation::test_add_text_annotation | PASSED |-| 34 | TestAnnotation::test_list_and_remove | PASSED |-| 35 | TestIntegration::test_full_workflow | PASSED |-| 36 | TestIntegration::test_export_presets | PASSED |+| 11 | TestSession::test_editor_raises_when_not_open | PASSED |+| 12 | TestSession::test_checkpoint_adds_to_undo | PASSED |+| 13 | TestSession::test_undo_stack_limit_50 | PASSED |+| 14 | TestSession::test_is_modified_after_checkpoint | PASSED |+| 15 | TestSession::test_open_invalid_json_raises | PASSED |+| 16 | TestProject::test_new_project | PASSED |+| 17 | TestProject::test_info | PASSED |+| 18 | TestProject::test_info_without_project | PASSED |+| 19 | TestProject::test_set_setting | PASSED |+| 20 | TestProject::test_set_invalid_setting | PASSED |+| 21 | TestProject::test_set_aspect_ratio_valid | PASSED |+| 22 | TestProject::test_set_aspect_ratio_invalid | PASSED |+| 23 | TestProject::test_set_export_quality_valid | PASSED |+| 24 | TestProject::test_set_export_quality_invalid | PASSED |+| 25 | TestProject::test_set_export_format_valid | PASSED |+| 26 | TestProject::test_set_export_format_invalid | PASSED |+| 27 | TestProject::test_set_padding_valid | PASSED |+| 28 | TestProject::test_set_padding_invalid | PASSED |+| 29 | TestProject::test_set_shadow_intensity_range | PASSED |+| 30 | TestProject::test_set_border_radius_negative | PASSED |+| 31 | TestZoom::test_add_zoom | PASSED |+| 32 | TestZoom::test_list_zoom | PASSED |+| 33 | TestZoom::test_remove_zoom | PASSED |+| 34 | TestZoom::test_remove_nonexistent_zoom | PASSED |+| 35 | TestZoom::test_invalid_depth | PASSED |+| 36 | TestZoom::test_invalid_focus | PASSED |+| 37 | TestZoom::test_invalid_time_range | PASSED |+| 38 | TestZoom::test_zoom_undo | PASSED |+| 39 | TestZoom::test_add_zoom_with_focus | PASSED |+| 40 | TestZoom::test_list_zoom_sorted | PASSED |+| 41 | TestZoom::test_update_zoom_region | PASSED |+| 42 | TestZoom::test_depth_map_values | PASSED |+| 43 | TestZoom::test_add_zoom_calls_checkpoint | PASSED |+| 44 | TestSpeed::test_add_speed | PASSED |+| 45 | TestSpeed::test_invalid_speed | PASSED |+| 46 | TestSpeed::test_list_and_remove | PASSED |+| 47 | TestSpeed::test_all_valid_speed_values | PASSED |+| 48 | TestSpeed::test_list_speed_sorted | PASSED |+| 49 | TestSpeed::test_remove_speed_nonexistent | PASSED |+| 50 | TestTrim::test_add_trim | PASSED |+| 51 | TestTrim::test_list_and_remove | PASSED |+| 52 | TestTrim::test_add_trim_zero_start | PASSED |+| 53 | TestTrim::test_list_trim_sorted | PASSED |+| 54 | TestTrim::test_remove_trim_nonexistent | PASSED |+| 55 | TestCrop::test_default_crop | PASSED |+| 56 | TestCrop::test_set_crop | PASSED |+| 57 | TestCrop::test_invalid_crop | PASSED |+| 58 | TestCrop::test_crop_out_of_bounds | PASSED |+| 59 | TestCrop::test_set_crop_overflow_x | PASSED |+| 60 | TestCrop::test_set_crop_overflow_y | PASSED |+| 61 | TestCrop::test_set_crop_negative_raises | PASSED |+| 62 | TestCrop::test_set_crop_calls_checkpoint | PASSED |+| 63 | TestCrop::test_crop_full_frame_valid | PASSED |+| 64 | TestAnnotation::test_add_text_annotation | PASSED |+| 65 | TestAnnotation::test_list_and_remove | PASSED |+| 66 | TestAnnotation::test_add_annotation_position | PASSED |+| 67 | TestAnnotation::test_list_annotations_sorted | PASSED |+| 68 | TestAnnotation::test_update_annotation_text | PASSED |+| 69 | TestAnnotation::test_update_annotation_nonexistent | PASSED |+| 70 | TestAnnotation::test_annotation_style_fields | PASSED |+| 71 | TestIntegration::test_full_workflow | PASSED |+| 72 | TestIntegration::test_export_presets | PASSED |+| 73 | TestIntegration::test_undo_redo_zoom_workflow | PASSED |+| 74 | TestIntegration::test_multiple_undo_levels | PASSED |+| 75 | TestIntegration::test_timeline_boundaries | PASSED |+| 76 | TestIntegration::test_active_regions_at | PASSED |+| 77 | TestIntegration::test_project_set_triggers_undo | PASSED |-### test_full_e2e.py — End-to-End Tests (14 tests, requires ffmpeg)+### test_full_e2e.py — End-to-End Tests (23 tests, requires ffmpeg)| # | Test | Status ||---|------|--------|-| 37 | TestMediaE2E::test_probe_real_video | PASSED |-| 38 | TestMediaE2E::test_check_video | PASSED |-| 39 | TestMediaE2E::test_check_invalid_video | PASSED |-| 40 | TestMediaE2E::test_extract_thumbnail | PASSED |-| 41 | TestMediaE2E::test_extract_frames | PASSED |-| 42 | TestExportE2E::test_basic_export | PASSED |-| 43 | TestExportE2E::test_export_with_zoom | PASSED |-| 44 | TestExportE2E::test_export_with_speed | PASSED |-| 45 | TestExportE2E::test_export_with_trim | PASSED |-| 46 | TestExportE2E::test_export_complex | PASSED |-| 47 | TestCLISubprocess::test_cli_help | PASSED |-| 48 | TestCLISubprocess::test_cli_version | PASSED |-| 49 | TestCLISubprocess::test_cli_export_presets | PASSED |-| 50 | TestCLISubprocess::test_cli_media_probe | PASSED |+| 78 | TestMediaE2E::test_probe_real_video | PASSED |+| 79 | TestMediaE2E::test_check_video | PASSED |+| 80 | TestMediaE2E::test_check_invalid_video | PASSED |+| 81 | TestMediaE2E::test_extract_thumbnail | PASSED |+| 82 | TestMediaE2E::test_extract_thumbnail_at_zero | PASSED |+| 83 | TestMediaE2E::test_extract_frames | PASSED |+| 84 | TestMediaE2E::test_ffmpeg_and_ffprobe_found | PASSED |+| 85 | TestExportE2E::test_basic_export | PASSED |+| 86 | TestExportE2E::test_export_with_zoom | PASSED |+| 87 | TestExportE2E::test_export_with_speed | PASSED |+| 88 | TestExportE2E::test_export_with_trim | PASSED |+| 89 | TestExportE2E::test_export_complex | PASSED |+| 90 | TestExportE2E::test_export_no_video_raises | PASSED |+| 91 | TestExportE2E::test_export_missing_video_raises | PASSED |+| 92 | TestCLISubprocess::test_cli_help | PASSED |+| 93 | TestCLISubprocess::test_cli_version | PASSED |+| 94 | TestCLISubprocess::test_cli_export_presets | PASSED |+| 95 | TestCLISubprocess::test_cli_media_probe | PASSED |+| 96 | TestCLISubprocess::test_cli_project_new_json | PASSED |+| 97 | TestCLISubprocess::test_cli_zoom_add | PASSED |+| 98 | TestCLISubprocess::test_cli_full_workflow | PASSED |+| 99 | TestCLISubprocess::test_cli_media_check_valid | PASSED |+| 100 | TestCLISubprocess::test_cli_session_status | PASSED |## Raw pytest output```============================= test session starts ==============================platform linux -- Python 3.11.2, pytest-9.0.2, pluggy-1.6.0-collected 50 items+collected 101 items-cli_anything/openscreen/tests/test_core.py .................................... [ 72%]-cli_anything/openscreen/tests/test_full_e2e.py .............. [100%]+cli_anything/openscreen/tests/test_core.py ............................................... [ 76%]+............................... [ 77%]+cli_anything/openscreen/tests/test_full_e2e.py ....................... [100%]-============================= 50 passed in 29.35s ==============================+============================= 101 passed in 35.19s =============================```## Environmentdiff --git a/openscreen/agent-harness/cli_anything/openscreen/__init__.py b/openscreen/agent-harness/cli_anything/openscreen/__init__.pyindex 1f4aa234a..8869b8447 100644--- a/openscreen/agent-harness/cli_anything/openscreen/__init__.py+++ b/openscreen/agent-harness/cli_anything/openscreen/__init__.py@@ -1 +1,3 @@"""Openscreen CLI package."""++__version__ = "1.0.0"diff --git a/openscreen/agent-harness/cli_anything/openscreen/core/project.py b/openscreen/agent-harness/cli_anything/openscreen/core/project.pyindex b7398653d..edb038f22 100644--- a/openscreen/agent-harness/cli_anything/openscreen/core/project.py+++ b/openscreen/agent-harness/cli_anything/openscreen/core/project.py@@ -113,12 +113,36 @@ def set_video(session: Session, video_path: str) -> dict:return {"status": "ok", "video": path}+def _validate_crop_region(region) -> None:+ """Validate a cropRegion dict.++ All four fields (x, y, width, height) must be present and in [0, 1].+ x + width must be <= 1 and y + height must be <= 1.++ Raises:+ ValueError: If validation fails.+ """+ if not isinstance(region, dict):+ raise ValueError("cropRegion must be a dict with x, y, width, height.")+ for field in ("x", "y", "width", "height"):+ if field not in region:+ raise ValueError(f"cropRegion missing field '{field}'")+ v = float(region[field])+ if not (0.0 <= v <= 1.0):+ raise ValueError(f"cropRegion.{field} must be 0.0-1.0, got {v}")+ if float(region["x"]) + float(region["width"]) > 1.0 + 1e-9:+ raise ValueError("cropRegion x + width must be <= 1.0")+ if float(region["y"]) + float(region["height"]) > 1.0 + 1e-9:+ raise ValueError("cropRegion y + height must be <= 1.0")++def set_setting(session: Session, key: str, value) -> dict:"""Set a project editor setting.Supported keys: aspectRatio, wallpaper, padding, borderRadius,shadowIntensity, motionBlurAmount, showBlur, exportQuality,- exportFormat, gifFrameRate, gifLoop, gifSizePreset.+ exportFormat, gifFrameRate, gifLoop, gifSizePreset,+ webcamLayoutPreset, webcamMaskShape, cropRegion."""if not session.is_open:raise RuntimeError("No project is open")@@ -130,10 +154,49 @@ def set_setting(session: Session, key: str, value) -> dict:"exportQuality", "exportFormat","gifFrameRate", "gifLoop", "gifSizePreset","webcamLayoutPreset", "webcamMaskShape",+ "cropRegion",}if key not in VALID_KEYS:raise ValueError(f"Unknown setting: {key}. Valid: {sorted(VALID_KEYS)}")+ if key == "aspectRatio" and value not in ASPECT_RATIOS:+ raise ValueError(+ f"Invalid aspectRatio '{value}'. Valid: {', '.join(ASPECT_RATIOS)}"+ )++ if key == "exportQuality" and value not in EXPORT_QUALITIES:+ raise ValueError(+ f"Invalid exportQuality '{value}'. Valid: {', '.join(EXPORT_QUALITIES)}"+ )++ if key == "exportFormat" and value not in EXPORT_FORMATS:+ raise ValueError(+ f"Invalid exportFormat '{value}'. Valid: {', '.join(EXPORT_FORMATS)}"+ )++ if key == "padding":+ v = int(value)+ if not (0 <= v <= 100):+ raise ValueError(f"padding must be 0-100, got {v}")++ if key == "shadowIntensity":+ v = float(value)+ if not (0.0 <= v <= 1.0):+ raise ValueError(f"shadowIntensity must be 0.0-1.0, got {v}")++ if key == "motionBlurAmount":+ v = float(value)+ if not (0.0 <= v <= 1.0):+ raise ValueError(f"motionBlurAmount must be 0.0-1.0, got {v}")++ if key == "borderRadius":+ v = int(value)+ if v < 0:+ raise ValueError(f"borderRadius must be >= 0, got {v}")++ if key == "cropRegion":+ _validate_crop_region(value)+session.checkpoint()editor[key] = valuereturn {"status": "ok", "key": key, "value": value}diff --git a/openscreen/agent-harness/cli_anything/openscreen/core/timeline.py b/openscreen/agent-harness/cli_anything/openscreen/core/timeline.pyindex 02f7eb9ab..7a6ca169b 100644--- a/openscreen/agent-harness/cli_anything/openscreen/core/timeline.py+++ b/openscreen/agent-harness/cli_anything/openscreen/core/timeline.py@@ -29,13 +29,22 @@ def _gen_id(prefix: str) -> str:return f"{prefix}_{uuid.uuid4().hex[:8]}"+def _validate_time_range(start_ms: int, end_ms: int) -> None:+ """Validate that start_ms >= 0 and end_ms > start_ms."""+ if start_ms < 0:+ raise ValueError(f"start_ms must be >= 0, got {start_ms}")+ if end_ms <= start_ms:+ raise ValueError(f"end_ms ({end_ms}) must be > start_ms ({start_ms})")++# ── Zoom regions ─────────────────────────────────────────────────────────def list_zoom_regions(session: Session) -> list[dict]:"""List all zoom regions."""if not session.is_open:raise RuntimeError("No project is open")- return session.editor.get("zoomRegions", [])+ regions = session.editor.get("zoomRegions", [])+ return sorted(regions, key=lambda r: r["startMs"])def add_zoom_region(@@ -54,8 +63,7 @@ def add_zoom_region(raise ValueError(f"Invalid depth {depth}. Valid: {list(ZOOM_DEPTHS.keys())}")if not 0 <= focus_x <= 1 or not 0 <= focus_y <= 1:raise ValueError("Focus coordinates must be 0.0-1.0")- if end_ms <= start_ms:- raise ValueError("end_ms must be > start_ms")+ _validate_time_range(start_ms, end_ms)session.checkpoint()region = {@@ -90,7 +98,8 @@ def list_speed_regions(session: Session) -> list[dict]:"""List all speed regions."""if not session.is_open:raise RuntimeError("No project is open")- return session.editor.get("speedRegions", [])+ regions = session.editor.get("speedRegions", [])+ return sorted(regions, key=lambda r: r["startMs"])def add_speed_region(@@ -104,8 +113,7 @@ def add_speed_region(raise RuntimeError("No project is open")if speed not in VALID_SPEEDS:raise ValueError(f"Invalid speed {speed}. Valid: {VALID_SPEEDS}")- if end_ms <= start_ms:- raise ValueError("end_ms must be > start_ms")+ _validate_time_range(start_ms, end_ms)session.checkpoint()region = {@@ -137,15 +145,15 @@ def list_trim_regions(session: Session) -> list[dict]:"""List all trim regions."""if not session.is_open:raise RuntimeError("No project is open")- return session.editor.get("trimRegions", [])+ regions = session.editor.get("trimRegions", [])+ return sorted(regions, key=lambda r: r["startMs"])def add_trim_region(session: Session, start_ms: int, end_ms: int) -> dict:"""Add a trim (cut) region to the timeline."""if not session.is_open:raise RuntimeError("No project is open")- if end_ms <= start_ms:- raise ValueError("end_ms must be > start_ms")+ _validate_time_range(start_ms, end_ms)session.checkpoint()region = {@@ -200,7 +208,8 @@ def list_annotations(session: Session) -> list[dict]:"""List all annotation regions."""if not session.is_open:raise RuntimeError("No project is open")- return session.editor.get("annotationRegions", [])+ regions = session.editor.get("annotationRegions", [])+ return sorted(regions, key=lambda r: r["startMs"])def add_text_annotation(@@ -217,8 +226,7 @@ def add_text_annotation("""Add a text annotation to the timeline."""if not session.is_open:raise RuntimeError("No project is open")- if end_ms <= start_ms:- raise ValueError("end_ms must be > start_ms")+ _validate_time_range(start_ms, end_ms)session.checkpoint()region = {@@ -257,3 +265,171 @@ def remove_annotation(session: Session, region_id: str) -> dict:if before - len(session.editor["annotationRegions"]) == 0:raise ValueError(f"Annotation not found: {region_id}")return {"status": "removed", "id": region_id}+++# ── Update / query helpers (added from auto version) ─────────────────────++def update_zoom_region(+ session: Session,+ region_id: str,+ start_ms: Optional[int] = None,+ end_ms: Optional[int] = None,+ depth: Optional[int] = None,+ focus_x: Optional[float] = None,+ focus_y: Optional[float] = None,+) -> dict:+ """Update an existing zoom region.++ Only the keyword arguments that are provided are changed; omitted arguments+ leave the corresponding field unchanged.++ Args:+ session: Active Session instance.+ region_id: ID of the zoom region to update.+ start_ms: New start time in milliseconds.+ end_ms: New end time in milliseconds.+ depth: New zoom depth (1-6).+ focus_x: New horizontal focus center (0.0-1.0).+ focus_y: New vertical focus center (0.0-1.0).++ Returns:+ The updated region dict.++ Raises:+ RuntimeError: If no project is open.+ ValueError: If region_id is not found or parameters are invalid.+ """+ if not session.is_open:+ raise RuntimeError("No project is open")+ regions = session.editor.get("zoomRegions", [])+ region = next((r for r in regions if r.get("id") == region_id), None)+ if region is None:+ raise ValueError(f"Zoom region not found: {region_id}")++ new_start = start_ms if start_ms is not None else region["startMs"]+ new_end = end_ms if end_ms is not None else region["endMs"]+ _validate_time_range(new_start, new_end)++ new_depth = depth if depth is not None else region["depth"]+ if new_depth not in ZOOM_DEPTHS:+ raise ValueError(f"Invalid depth {new_depth}. Valid: {list(ZOOM_DEPTHS.keys())}")++ new_fx = focus_x if focus_x is not None else region["focus"]["cx"]+ new_fy = focus_y if focus_y is not None else region["focus"]["cy"]+ if not 0 <= new_fx <= 1 or not 0 <= new_fy <= 1:+ raise ValueError("Focus coordinates must be 0.0-1.0")++ session.checkpoint()+ region["startMs"] = new_start+ region["endMs"] = new_end+ region["depth"] = new_depth+ region["focus"]["cx"] = new_fx+ region["focus"]["cy"] = new_fy+ return region+++def update_annotation(session: Session, region_id: str, **kwargs) -> dict:+ """Update fields on an existing annotation region.++ Supported kwargs: start_ms, end_ms, text_content, position_x, position_y,+ size, color, background_color, font_size, font_family.++ Args:+ session: Active Session instance.+ region_id: ID of the annotation to update.+ **kwargs: Fields to update (see above).++ Returns:+ The updated region dict.++ Raises:+ RuntimeError: If no project is open.+ ValueError: If region_id is not found.+ """+ if not session.is_open:+ raise RuntimeError("No project is open")+ regions = session.editor.get("annotationRegions", [])+ region = next((r for r in regions if r.get("id") == region_id), None)+ if region is None:+ raise ValueError(f"Annotation not found: {region_id}")++ session.checkpoint()++ if "start_ms" in kwargs:+ region["startMs"] = int(kwargs["start_ms"])+ if "end_ms" in kwargs:+ region["endMs"] = int(kwargs["end_ms"])+ if "text_content" in kwargs:+ region["textContent"] = str(kwargs["text_content"])+ region["content"] = str(kwargs["text_content"])+ if "position_x" in kwargs:+ region["position"]["x"] = float(kwargs["position_x"])+ if "position_y" in kwargs:+ region["position"]["y"] = float(kwargs["position_y"])+ if "size" in kwargs:+ region["size"] = kwargs["size"]+ if "color" in kwargs:+ region["style"]["color"] = str(kwargs["color"])+ if "background_color" in kwargs:+ region["style"]["backgroundColor"] = str(kwargs["background_color"])+ if "font_size" in kwargs:+ region["style"]["fontSize"] = int(kwargs["font_size"])+ if "font_family" in kwargs:+ region["style"]["fontFamily"] = str(kwargs["font_family"])++ return region+++def get_timeline_boundaries(session: Session) -> list[int]:+ """Return a sorted list of all unique time boundary points (in ms).++ Includes 0 and all startMs/endMs values from zoom, speed, trim, and+ annotation regions. Useful for computing rendering segments.++ Args:+ session: Active Session instance.++ Returns:+ Sorted list of unique boundary millisecond values.++ Raises:+ RuntimeError: If no project is open.+ """+ if not session.is_open:+ raise RuntimeError("No project is open")+ ed = session.editor+ boundaries = {0}+ for region_key in ("zoomRegions", "speedRegions", "trimRegions", "annotationRegions"):+ for region in ed.get(region_key, []):+ boundaries.add(region.get("startMs", 0))+ boundaries.add(region.get("endMs", 0))+ return sorted(boundaries)+++def get_active_regions_at(session: Session, time_ms: int) -> dict:+ """Return all regions active at a specific time (startMs <= time_ms < endMs).++ Args:+ session: Active Session instance.+ time_ms: Query time in milliseconds.++ Returns:+ Dict with keys "zoom", "speed", "trim", "annotation", each mapping to+ a list of region dicts active at that time.++ Raises:+ RuntimeError: If no project is open.+ """+ if not session.is_open:+ raise RuntimeError("No project is open")+ ed = session.editor++ def active(regions: list) -> list:+ return [r for r in regions if r.get("startMs", 0) <= time_ms < r.get("endMs", 0)]++ return {+ "zoom": active(ed.get("zoomRegions", [])),+ "speed": active(ed.get("speedRegions", [])),+ "trim": active(ed.get("trimRegions", [])),+ "annotation": active(ed.get("annotationRegions", [])),+ }diff --git a/openscreen/agent-harness/cli_anything/openscreen/tests/test_core.py b/openscreen/agent-harness/cli_anything/openscreen/tests/test_core.pyindex 5850024af..97e436870 100644--- a/openscreen/agent-harness/cli_anything/openscreen/tests/test_core.py+++ b/openscreen/agent-harness/cli_anything/openscreen/tests/test_core.py@@ -120,6 +120,41 @@ class TestSession:assert status["project_open"] is Trueassert status["zoom_region_count"] == 0+ # ── Extra tests from auto version ──────────────────────────────────++ def test_editor_raises_when_not_open(self):+ s = Session()+ with pytest.raises(RuntimeError):+ _ = s.editor++ def test_checkpoint_adds_to_undo(self):+ s = Session()+ s.new_project()+ before = len(s._undo_stack)+ s.checkpoint()+ assert len(s._undo_stack) == before + 1++ def test_undo_stack_limit_50(self):+ s = Session()+ s.new_project()+ for i in range(60):+ s.checkpoint()+ assert len(s._undo_stack) <= 50++ def test_is_modified_after_checkpoint(self):+ s = Session()+ s.new_project()+ assert not s.is_modified+ s.checkpoint()+ assert s.is_modified++ def test_open_invalid_json_raises(self, tmp_path):+ path = tmp_path / "bad.openscreen"+ path.write_text("not json at all")+ s = Session()+ with pytest.raises((RuntimeError, ValueError, Exception)):+ s.open_project(str(path))+# ── Project Tests ─────────────────────────────────────────────────────────@@ -156,6 +191,69 @@ class TestProject:with pytest.raises(ValueError, match="Unknown setting"):proj_mod.set_setting(s, "nonexistent_key", 42)+ # ── Extra tests from auto version ──────────────────────────────────++ def test_set_setting_aspectRatio(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "aspectRatio", "9:16")+ assert s.editor["aspectRatio"] == "9:16"++ def test_set_setting_invalid_aspectRatio(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ proj_mod.set_setting(s, "aspectRatio", "invalid")++ def test_set_setting_exportQuality(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "exportQuality", "source")+ assert s.editor["exportQuality"] == "source"++ def test_set_setting_exportFormat(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "exportFormat", "gif")+ assert s.editor["exportFormat"] == "gif"++ def test_set_setting_invalid_exportFormat(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ proj_mod.set_setting(s, "exportFormat", "avi")++ def test_set_setting_padding_valid(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "padding", 30)+ assert s.editor["padding"] == 30++ def test_set_setting_padding_too_large(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ proj_mod.set_setting(s, "padding", 101)++ def test_set_setting_calls_checkpoint(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "padding", 10)+ assert len(s._undo_stack) >= 1++ def test_crop_region_validation_in_settings(self):+ s = Session()+ s.new_project()+ valid_crop = {"x": 0.1, "y": 0.1, "width": 0.8, "height": 0.8}+ proj_mod.set_setting(s, "cropRegion", valid_crop)+ assert s.editor["cropRegion"] == valid_crop++ def test_crop_region_overflow_raises(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ proj_mod.set_setting(s, "cropRegion", {"x": 0.5, "y": 0.0, "width": 0.8, "height": 1.0})+# ── Zoom Tests ────────────────────────────────────────────────────────────@@ -204,7 +302,7 @@ class TestZoom:def test_invalid_time_range(self):s = Session()s.new_project()- with pytest.raises(ValueError, match="end_ms must be"):+ with pytest.raises(ValueError, match="end_ms.*must be"):tl_mod.add_zoom_region(s, 5000, 1000)def test_zoom_undo(self):@@ -215,6 +313,51 @@ class TestZoom:s.undo()assert len(tl_mod.list_zoom_regions(s)) == 0+ # ── Extra tests from auto version ──────────────────────────────────++ def test_add_zoom_focus(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_zoom_region(s, 0, 2000, depth=3, focus_x=0.3, focus_y=0.7)+ assert region["focus"]["cx"] == 0.3+ assert region["focus"]["cy"] == 0.7++ def test_list_zoom_sorted(self):+ s = Session()+ s.new_project()+ tl_mod.add_zoom_region(s, 5000, 8000, depth=1)+ tl_mod.add_zoom_region(s, 1000, 3000, depth=2)+ regions = tl_mod.list_zoom_regions(s)+ starts = [r["startMs"] for r in regions]+ assert starts == sorted(starts)++ def test_update_zoom_region(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_zoom_region(s, 1000, 3000, depth=1)+ updated = tl_mod.update_zoom_region(s, region["id"], depth=4, focus_x=0.8)+ assert updated["depth"] == 4+ assert updated["focus"]["cx"] == 0.8++ def test_update_zoom_nonexistent(self):+ s = Session()+ s.new_project()+ with pytest.raises((ValueError, KeyError)):+ tl_mod.update_zoom_region(s, "fake-id")++ def test_zoom_depth_map_values(self):+ # ZOOM_DEPTHS maps depth int -> scale factor+ from cli_anything.openscreen.core.timeline import ZOOM_DEPTHS+ assert ZOOM_DEPTHS[1] == 1.25+ assert ZOOM_DEPTHS[6] == 5.0++ def test_add_zoom_calls_checkpoint(self):+ s = Session()+ s.new_project()+ initial = len(s._undo_stack)+ tl_mod.add_zoom_region(s, 0, 1000, depth=2)+ assert len(s._undo_stack) > initial+# ── Speed Tests ───────────────────────────────────────────────────────────@@ -239,6 +382,31 @@ class TestSpeed:tl_mod.remove_speed_region(s, r["id"])assert len(tl_mod.list_speed_regions(s)) == 0+ # ── Extra tests from auto version ──────────────────────────────────++ def test_add_speed_all_valid_values(self):+ from cli_anything.openscreen.core.timeline import VALID_SPEEDS+ s = Session()+ s.new_project()+ for speed in VALID_SPEEDS:+ region = tl_mod.add_speed_region(s, 0, 1000, speed=speed)+ assert region["speed"] == speed++ def test_list_speed_sorted(self):+ s = Session()+ s.new_project()+ tl_mod.add_speed_region(s, 5000, 8000, speed=1.5)+ tl_mod.add_speed_region(s, 1000, 3000, speed=2.0)+ regions = tl_mod.list_speed_regions(s)+ starts = [r["startMs"] for r in regions]+ assert starts == sorted(starts)++ def test_remove_speed_nonexistent(self):+ s = Session()+ s.new_project()+ with pytest.raises((ValueError, KeyError)):+ tl_mod.remove_speed_region(s, "nonexistent")+# ── Trim Tests ────────────────────────────────────────────────────────────@@ -258,6 +426,29 @@ class TestTrim:tl_mod.remove_trim_region(s, r["id"])assert len(tl_mod.list_trim_regions(s)) == 0+ # ── Extra tests from auto version ──────────────────────────────────++ def test_add_trim_zero_start(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_trim_region(s, 0, 1000)+ assert region["startMs"] == 0++ def test_list_trim_sorted(self):+ s = Session()+ s.new_project()+ tl_mod.add_trim_region(s, 8000, 10000)+ tl_mod.add_trim_region(s, 1000, 3000)+ regions = tl_mod.list_trim_regions(s)+ starts = [r["startMs"] for r in regions]+ assert starts == sorted(starts)++ def test_remove_trim_nonexistent(self):+ s = Session()+ s.new_project()+ with pytest.raises((ValueError, KeyError)):+ tl_mod.remove_trim_region(s, "fake")+# ── Crop Tests ────────────────────────────────────────────────────────────@@ -287,6 +478,39 @@ class TestCrop:with pytest.raises(ValueError, match="beyond frame"):tl_mod.set_crop(s, 0.5, 0.5, 0.6, 0.6)+ # ── Extra tests from auto version ──────────────────────────────────++ def test_set_crop_overflow_x(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ tl_mod.set_crop(s, 0.5, 0.0, 0.6, 1.0)++ def test_set_crop_overflow_y(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ tl_mod.set_crop(s, 0.0, 0.5, 1.0, 0.6)++ def test_set_crop_negative_raises(self):+ s = Session()+ s.new_project()+ with pytest.raises(ValueError):+ tl_mod.set_crop(s, -0.1, 0.0, 1.0, 1.0)++ def test_set_crop_calls_checkpoint(self):+ s = Session()+ s.new_project()+ initial = len(s._undo_stack)+ tl_mod.set_crop(s, 0.0, 0.0, 0.5, 0.5)+ assert len(s._undo_stack) > initial++ def test_crop_full_frame_valid(self):+ s = Session()+ s.new_project()+ crop = tl_mod.set_crop(s, 0.0, 0.0, 1.0, 1.0)+ assert crop["x"] == 0.0+# ── Annotation Tests ──────────────────────────────────────────────────────@@ -306,6 +530,45 @@ class TestAnnotation:tl_mod.remove_annotation(s, a["id"])assert len(tl_mod.list_annotations(s)) == 0+ # ── Extra tests from auto version ──────────────────────────────────++ def test_add_annotation_position(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_text_annotation(s, 0, 2000, "Positioned", x=0.25, y=0.75)+ assert region["position"]["x"] == 0.25+ assert region["position"]["y"] == 0.75++ def test_list_annotations_sorted(self):+ s = Session()+ s.new_project()+ tl_mod.add_text_annotation(s, 5000, 8000, "Later")+ tl_mod.add_text_annotation(s, 1000, 3000, "Earlier")+ regions = tl_mod.list_annotations(s)+ starts = [r["startMs"] for r in regions]+ assert starts == sorted(starts)++ def test_update_annotation_text(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_text_annotation(s, 0, 2000, "original")+ tl_mod.update_annotation(s, region["id"], text_content="updated")+ regions = tl_mod.list_annotations(s)+ assert regions[0]["textContent"] == "updated"++ def test_update_annotation_nonexistent(self):+ s = Session()+ s.new_project()+ with pytest.raises((ValueError, KeyError)):+ tl_mod.update_annotation(s, "fake-id", text_content="x")++ def test_annotation_style_fields(self):+ s = Session()+ s.new_project()+ region = tl_mod.add_text_annotation(s, 0, 1000, "Styled", color="#ff0000", font_size=32)+ assert region["style"]["color"] == "#ff0000"+ assert region["style"]["fontSize"] == 32+# ── Integration Tests ─────────────────────────────────────────────────────@@ -355,3 +618,69 @@ class TestIntegration:presets = export_mod.list_presets()assert len(presets) > 0assert any(p["name"] == "mp4_good" for p in presets)++ # ── Extra tests from auto version ──────────────────────────────────++ def test_undo_redo_zoom_workflow(self):+ s = Session()+ s.new_project()+ tl_mod.add_zoom_region(s, 1000, 3000, depth=2)+ assert len(tl_mod.list_zoom_regions(s)) == 1++ s.undo()+ assert len(tl_mod.list_zoom_regions(s)) == 0++ s.redo()+ assert len(tl_mod.list_zoom_regions(s)) == 1++ def test_multiple_undo_levels(self):+ s = Session()+ s.new_project()+ for i in range(5):+ tl_mod.add_zoom_region(s, i * 1000, (i + 1) * 1000, depth=1)++ assert len(tl_mod.list_zoom_regions(s)) == 5+ for _ in range(5):+ s.undo()+ assert len(tl_mod.list_zoom_regions(s)) == 0++ def test_timeline_boundaries(self):+ s = Session()+ s.new_project()+ tl_mod.add_zoom_region(s, 1000, 3000, depth=1)+ tl_mod.add_speed_region(s, 2000, 5000, speed=1.5)+ tl_mod.add_trim_region(s, 4000, 6000)++ boundaries = tl_mod.get_timeline_boundaries(s)+ assert 0 in boundaries+ assert 1000 in boundaries+ assert 2000 in boundaries+ assert 3000 in boundaries+ assert 4000 in boundaries+ assert 5000 in boundaries+ assert 6000 in boundaries++ def test_active_regions_at(self):+ s = Session()+ s.new_project()+ tl_mod.add_zoom_region(s, 1000, 5000, depth=2)+ tl_mod.add_speed_region(s, 2000, 4000, speed=1.5)+ tl_mod.add_trim_region(s, 6000, 8000)++ active = tl_mod.get_active_regions_at(s, 3000)+ assert len(active["zoom"]) == 1+ assert len(active["speed"]) == 1+ assert len(active["trim"]) == 0++ active2 = tl_mod.get_active_regions_at(s, 7000)+ assert len(active2["trim"]) == 1+ assert len(active2["zoom"]) == 0++ def test_project_set_triggers_undo(self):+ s = Session()+ s.new_project()+ proj_mod.set_setting(s, "padding", 10)+ proj_mod.set_setting(s, "padding", 30)+ assert s.editor["padding"] == 30+ s.undo()+ assert s.editor["padding"] == 10diff --git a/openscreen/agent-harness/cli_anything/openscreen/tests/test_full_e2e.py b/openscreen/agent-harness/cli_anything/openscreen/tests/test_full_e2e.pyindex c50806eaf..cdb029f24 100644--- a/openscreen/agent-harness/cli_anything/openscreen/tests/test_full_e2e.py+++ b/openscreen/agent-harness/cli_anything/openscreen/tests/test_full_e2e.py@@ -2,11 +2,30 @@These tests create real video files, run the full export pipeline,and verify outputs with ffprobe.++Run with:+ python3 -m pytest cli_anything/openscreen/tests/test_full_e2e.py -v -s++Force installed CLI:+ CLI_ANYTHING_FORCE_INSTALLED=1 python3 -m pytest ... -v -s++Test classes:+ TestMediaE2E - probe_real_video, check_video, check_invalid_video,+ extract_thumbnail, extract_thumbnail_at_zero,+ extract_frames, ffmpeg_and_ffprobe_found+ TestExportE2E - basic_export, export_with_zoom, export_with_speed,+ export_with_trim, export_complex,+ export_no_video_raises, export_missing_video_raises+ TestCLISubprocess - cli_help, cli_version, cli_export_presets,+ cli_media_probe, cli_project_new_json, cli_zoom_add,+ cli_full_workflow, cli_media_check_valid,+ cli_session_status"""import jsonimport osimport subprocess+import sysimport tempfileimport pytest@@ -19,6 +38,28 @@ from cli_anything.openscreen.core import media as media_modfrom cli_anything.openscreen.utils import ffmpeg_backend+# ── CLI resolver ───────────────────────────────────────────────────────────++def _resolve_cli(name: str):+ """Resolve installed CLI command; falls back to python -m for dev.++ Set env CLI_ANYTHING_FORCE_INSTALLED=1 to require the installed command.+ """+ import shutil+ force = os.environ.get("CLI_ANYTHING_FORCE_INSTALLED", "").strip() == "1"+ path = shutil.which(name)+ if path:+ print(f"[_resolve_cli] Using installed command: {path}")+ return [path]+ if force:+ raise RuntimeError(+ f"{name} not found in PATH. Install with: pip install -e ."+ )+ module = "cli_anything.openscreen.openscreen_cli"+ print(f"[_resolve_cli] Falling back to: {sys.executable} -m {module}")+ return [sys.executable, "-m", module]++# ── Fixtures ──────────────────────────────────────────────────────────────@pytest.fixture(scope="module")@@ -87,6 +128,16 @@ class TestMediaE2E:finally:os.unlink(thumb_path)+ def test_extract_thumbnail_at_zero(self, test_video):+ with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as f:+ thumb_path = f.name+ try:+ result = media_mod.extract_thumbnail(test_video, thumb_path, time_s=0.0)+ assert os.path.exists(thumb_path)+ assert result["file_size"] > 0+ finally:+ os.unlink(thumb_path)+def test_extract_frames(self, test_video):tmpdir = tempfile.mkdtemp()try:@@ -98,6 +149,14 @@ class TestMediaE2E:import shutilshutil.rmtree(tmpdir)+ def test_ffmpeg_and_ffprobe_found(self):+ ffmpeg = ffmpeg_backend.find_ffmpeg()+ ffprobe = ffmpeg_backend.find_ffprobe()+ assert os.path.exists(ffmpeg)+ assert os.path.exists(ffprobe)+ print(f"\n ffmpeg: {ffmpeg}")+ print(f" ffprobe: {ffprobe}")+# ── Export Tests ──────────────────────────────────────────────────────────@@ -179,43 +238,165 @@ class TestExportE2E:finally:os.unlink(out_path)+ def test_export_no_video_raises(self):+ """Export fails if no source video is set."""+ s = Session()+ s.new_project()+ with pytest.raises(Exception):+ export_mod.render(s, "/tmp/out.mp4")++ def test_export_missing_video_raises(self):+ """Export fails if source video file is missing."""+ import tempfile as _tempfile+ with _tempfile.TemporaryDirectory() as tmp_dir:+ s = Session()+ s.new_project(video_path="/tmp/nonexistent_12345.mp4")+ with pytest.raises(Exception):+ export_mod.render(s, os.path.join(tmp_dir, "out.mp4"))+# ── CLI Subprocess Tests ──────────────────────────────────────────────────class TestCLISubprocess:- def test_cli_help(self):- result = subprocess.run(- ["python3", "-m", "cli_anything.openscreen.openscreen_cli", "--help"],+ CLI_BASE = _resolve_cli("cli-anything-openscreen")++ def _run(self, args, check=True):+ return subprocess.run(+ self.CLI_BASE + args,capture_output=True, text=True,+ check=check,)++ def test_cli_help(self):+ result = self._run(["--help"], check=False)assert result.returncode == 0assert "Openscreen CLI" in result.stdoutdef test_cli_version(self):- result = subprocess.run(- ["python3", "-m", "cli_anything.openscreen.openscreen_cli", "--version"],- capture_output=True, text=True,- )+ result = self._run(["--version"], check=False)assert result.returncode == 0assert "1.0.0" in result.stdoutdef test_cli_export_presets(self):- result = subprocess.run(- ["python3", "-m", "cli_anything.openscreen.openscreen_cli",- "--json", "export", "presets"],- capture_output=True, text=True,- )+ result = self._run(["--json", "export", "presets"], check=False)assert result.returncode == 0data = json.loads(result.stdout)assert isinstance(data, list)assert len(data) > 0def test_cli_media_probe(self, test_video):- result = subprocess.run(- ["python3", "-m", "cli_anything.openscreen.openscreen_cli",- "--json", "media", "probe", test_video],- capture_output=True, text=True,- )+ result = self._run(["--json", "media", "probe", test_video], check=False)assert result.returncode == 0data = json.loads(result.stdout)assert data["width"] == 1920++ def test_cli_project_new_json(self):+ """CLI project new --json returns project info."""+ with tempfile.TemporaryDirectory() as tmp_dir:+ proj_path = os.path.join(tmp_dir, "cli_test.openscreen")+ result = self._run(["--json", "project", "new", "-o", proj_path], check=False)+ assert result.returncode == 0++ data = json.loads(result.stdout)+ assert data.get("status") == "created"+ assert "saved_to" in data+ assert os.path.exists(proj_path)+ print(f"\n Project created: {proj_path}")++ def test_cli_zoom_add(self):+ """CLI zoom add works and persists to file."""+ with tempfile.TemporaryDirectory() as tmp_dir:+ proj_path = os.path.join(tmp_dir, "zoom_test.openscreen")+ # Create project+ self._run(["project", "new", "-o", proj_path], check=False)++ # Add zoom+ result = self._run([+ "--json", "--project", proj_path,+ "zoom", "add",+ "--start", "1000", "--end", "3000", "--depth", "3",+ ], check=False)+ assert result.returncode == 0+ data = json.loads(result.stdout)+ assert data["depth"] == 3+ assert data["startMs"] == 1000++ # Verify saved+ result2 = self._run(+ ["--json", "--project", proj_path, "zoom", "list"], check=False+ )+ assert result2.returncode == 0+ print(f"\n Zoom add result: depth={data['depth']}, id={data['id']}")++ def test_cli_full_workflow(self, test_video):+ """Full CLI workflow: create project, add regions, export."""+ with tempfile.TemporaryDirectory() as tmp_dir:+ proj_path = os.path.join(tmp_dir, "workflow.openscreen")+ output_path = os.path.join(tmp_dir, "workflow_output.mp4")++ # 1. Create project with video+ result = self._run(+ ["project", "new", "-v", test_video, "-o", proj_path], check=False+ )+ assert result.returncode == 0+ assert os.path.exists(proj_path)++ # 2. Add zoom region+ result = self._run([+ "--project", proj_path,+ "zoom", "add",+ "--start", "1000", "--end", "2000", "--depth", "2",+ ], check=False)+ assert result.returncode == 0++ # 3. Set quality+ result = self._run([+ "--project", proj_path,+ "project", "set", "exportQuality", "medium",+ ], check=False)+ assert result.returncode == 0++ # 4. Export+ result = self._run([+ "--json", "--project", proj_path,+ "export", "render", output_path,+ ], check=False)+ assert result.returncode == 0+ data = json.loads(result.stdout)+ assert os.path.exists(output_path)+ assert data["file_size"] > 1000++ # 5. Probe output+ result = self._run(+ ["--json", "media", "probe", output_path], check=False+ )+ assert result.returncode == 0+ probe_data = json.loads(result.stdout)+ assert probe_data["width"] > 0+ assert probe_data["duration"] > 0++ print(f"\n Full workflow output: {output_path}")+ print(f" Size: {data['file_size']:,} bytes")+ print(f" Duration: {data['duration']:.2f}s")+ print(f" Dimensions: {probe_data['width']}x{probe_data['height']}")++ def test_cli_media_check_valid(self, test_video):+ """CLI media check returns valid=True for a real video."""+ result = self._run(["--json", "media", "check", test_video], check=False)+ assert result.returncode == 0+ data = json.loads(result.stdout)+ assert data["valid"] is True++ def test_cli_session_status(self):+ """CLI session status works."""+ with tempfile.TemporaryDirectory() as tmp_dir:+ proj_path = os.path.join(tmp_dir, "status_test.openscreen")+ self._run(["project", "new", "-o", proj_path], check=False)++ result = self._run(+ ["--json", "--project", proj_path, "session", "status"], check=False+ )+ assert result.returncode == 0+ data = json.loads(result.stdout)+ assert "project_open" in data+ assert "undo_available" in data