Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix: address PR review feedback (4 items)

ndpvt-web3579c6d1b45b
diff --git a/openscreen/agent-harness/OPENSCREEN.md b/openscreen/agent-harness/OPENSCREEN.md
index 34c55595e..ebd6941a6 100644
--- a/openscreen/agent-harness/OPENSCREEN.md
+++ b/openscreen/agent-harness/OPENSCREEN.md
@@ -178,6 +178,6 @@ For speeds outside atempo's 0.5-2.0 range, filters are chained.
## Test Coverage
-**47 total tests** across two suites:
-- `test_core.py` (35 tests): Session, project, zoom, speed, trim, crop, annotation, integration
-- `test_full_e2e.py` (12 tests): Real ffmpeg rendering, CLI subprocess, media probing
+**101 total tests** across two suites:
+- `test_core.py` (78 tests): Session, project, zoom, speed, trim, crop, annotation, integration
+- `test_full_e2e.py` (23 tests): Real ffmpeg rendering, CLI subprocess, media probing
diff --git a/openscreen/agent-harness/TEST.md b/openscreen/agent-harness/TEST.md
index 10ce74d49..a677003ab 100644
--- a/openscreen/agent-harness/TEST.md
+++ b/openscreen/agent-harness/TEST.md
@@ -90,34 +90,35 @@
| 75 | TestIntegration::test_timeline_boundaries | PASSED |
| 76 | TestIntegration::test_active_regions_at | PASSED |
| 77 | TestIntegration::test_project_set_triggers_undo | PASSED |
+| 78 | TestProject::test_crop_region_overflow_raises | PASSED |
### test_full_e2e.py — End-to-End Tests (23 tests, requires ffmpeg)
| # | Test | Status |
|---|------|--------|
-| 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 |
+| 79 | TestMediaE2E::test_probe_real_video | PASSED |
+| 80 | TestMediaE2E::test_check_video | PASSED |
+| 81 | TestMediaE2E::test_check_invalid_video | PASSED |
+| 82 | TestMediaE2E::test_extract_thumbnail | PASSED |
+| 83 | TestMediaE2E::test_extract_thumbnail_at_zero | PASSED |
+| 84 | TestMediaE2E::test_extract_frames | PASSED |
+| 85 | TestMediaE2E::test_ffmpeg_and_ffprobe_found | PASSED |
+| 86 | TestExportE2E::test_basic_export | PASSED |
+| 87 | TestExportE2E::test_export_with_zoom | PASSED |
+| 88 | TestExportE2E::test_export_with_speed | PASSED |
+| 89 | TestExportE2E::test_export_with_trim | PASSED |
+| 90 | TestExportE2E::test_export_complex | PASSED |
+| 91 | TestExportE2E::test_export_no_video_raises | PASSED |
+| 92 | TestExportE2E::test_export_missing_video_raises | PASSED |
+| 93 | TestCLISubprocess::test_cli_help | PASSED |
+| 94 | TestCLISubprocess::test_cli_version | PASSED |
+| 95 | TestCLISubprocess::test_cli_export_presets | PASSED |
+| 96 | TestCLISubprocess::test_cli_media_probe | PASSED |
+| 97 | TestCLISubprocess::test_cli_project_new_json | PASSED |
+| 98 | TestCLISubprocess::test_cli_zoom_add | PASSED |
+| 99 | TestCLISubprocess::test_cli_full_workflow | PASSED |
+| 100 | TestCLISubprocess::test_cli_media_check_valid | PASSED |
+| 101 | TestCLISubprocess::test_cli_session_status | PASSED |
## Raw pytest output
diff --git a/openscreen/agent-harness/cli_anything/openscreen/openscreen_cli.py b/openscreen/agent-harness/cli_anything/openscreen/openscreen_cli.py
index 6476a4880..c893db712 100644
--- a/openscreen/agent-harness/cli_anything/openscreen/openscreen_cli.py
+++ b/openscreen/agent-harness/cli_anything/openscreen/openscreen_cli.py
@@ -6,6 +6,7 @@ trim, crop, annotations, backgrounds, and export polished demo videos.
Built on the Openscreen JSON project format with ffmpeg as the rendering backend.
"""
+import functools
import json
import os
import sys
@@ -71,6 +72,7 @@ def _print_list(items: list):
def handle_error(func):
"""Decorator to catch and format errors."""
+ @functools.wraps(func)
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
@@ -102,8 +104,6 @@ def handle_error(func):
click.echo(f"Unexpected error: {e}", err=True)
if not _repl_mode:
sys.exit(1)
- wrapper.__name__ = func.__name__
- wrapper.__doc__ = func.__doc__
return wrapper
@@ -168,7 +168,7 @@ def project_open(path):
@project.command("save")
[email protected]("-o", "--output", default=None, help="Save to path (default: current)")
[email protected]("-o", "--output", "output_path", default=None, help="Save to path (default: current)")
@handle_error
def project_save(output_path=None):
"""Save the current project."""
@@ -660,21 +660,21 @@ def repl():
skin.success(f"{parts[1]} = {val}")
elif cmd == "zoom":
- _repl_zoom(parts[1:], skin)
+ _repl_zoom(parts[1:], skin, pt_session)
elif cmd == "speed":
- _repl_speed(parts[1:], skin)
+ _repl_speed(parts[1:], skin, pt_session)
elif cmd == "trim":
- _repl_trim(parts[1:], skin)
+ _repl_trim(parts[1:], skin, pt_session)
elif cmd == "crop":
if len(parts) > 1 and parts[1] == "set":
skin.info("Enter crop (normalized 0-1):")
- x = float(input(" x: ") or "0")
- y = float(input(" y: ") or "0")
- w = float(input(" width: ") or "1")
- h = float(input(" height: ") or "1")
+ x = float(skin.sub_input(" x: ", pt_session) or "0")
+ y = float(skin.sub_input(" y: ", pt_session) or "0")
+ w = float(skin.sub_input(" width: ", pt_session) or "1")
+ h = float(skin.sub_input(" height: ", pt_session) or "1")
tl_mod.set_crop(_session, x, y, w, h)
skin.success("Crop updated")
else:
@@ -711,7 +711,7 @@ def repl():
skin.print_goodbye()
-def _repl_zoom(args, skin):
+def _repl_zoom(args, skin, pt_session=None):
"""Handle zoom subcommands in REPL."""
if not args:
skin.error("Usage: zoom list|add|rm <id>")
@@ -722,11 +722,11 @@ def _repl_zoom(args, skin):
output(result)
elif sub == "add":
skin.info("Add zoom region:")
- start = int(input(" start_ms: "))
- end = int(input(" end_ms: "))
- depth = int(input(" depth (1-6, default 3): ") or "3")
- fx = float(input(" focus_x (0-1, default 0.5): ") or "0.5")
- fy = float(input(" focus_y (0-1, default 0.5): ") or "0.5")
+ start = int(skin.sub_input(" start_ms: ", pt_session))
+ end = int(skin.sub_input(" end_ms: ", pt_session))
+ depth = int(skin.sub_input(" depth (1-6, default 3): ", pt_session) or "3")
+ fx = float(skin.sub_input(" focus_x (0-1, default 0.5): ", pt_session) or "0.5")
+ fy = float(skin.sub_input(" focus_y (0-1, default 0.5): ", pt_session) or "0.5")
result = tl_mod.add_zoom_region(_session, start, end, depth, fx, fy)
skin.success(f"Added zoom: {result['id']}")
elif sub == "rm" and len(args) > 1:
@@ -736,7 +736,7 @@ def _repl_zoom(args, skin):
skin.error("Usage: zoom list|add|rm <id>")
-def _repl_speed(args, skin):
+def _repl_speed(args, skin, pt_session=None):
"""Handle speed subcommands in REPL."""
if not args:
skin.error("Usage: speed list|add|rm <id>")
@@ -747,9 +747,9 @@ def _repl_speed(args, skin):
output(result)
elif sub == "add":
skin.info("Add speed region:")
- start = int(input(" start_ms: "))
- end = int(input(" end_ms: "))
- spd = float(input(" speed (0.25-2.0, default 1.5): ") or "1.5")
+ start = int(skin.sub_input(" start_ms: ", pt_session))
+ end = int(skin.sub_input(" end_ms: ", pt_session))
+ spd = float(skin.sub_input(" speed (0.25-2.0, default 1.5): ", pt_session) or "1.5")
result = tl_mod.add_speed_region(_session, start, end, spd)
skin.success(f"Added speed: {result['id']}")
elif sub == "rm" and len(args) > 1:
@@ -759,7 +759,7 @@ def _repl_speed(args, skin):
skin.error("Usage: speed list|add|rm <id>")
-def _repl_trim(args, skin):
+def _repl_trim(args, skin, pt_session=None):
"""Handle trim subcommands in REPL."""
if not args:
skin.error("Usage: trim list|add|rm <id>")
@@ -770,8 +770,8 @@ def _repl_trim(args, skin):
output(result)
elif sub == "add":
skin.info("Add trim region:")
- start = int(input(" start_ms: "))
- end = int(input(" end_ms: "))
+ start = int(skin.sub_input(" start_ms: ", pt_session))
+ end = int(skin.sub_input(" end_ms: ", pt_session))
result = tl_mod.add_trim_region(_session, start, end)
skin.success(f"Added trim: {result['id']}")
elif sub == "rm" and len(args) > 1:
diff --git a/openscreen/agent-harness/cli_anything/openscreen/utils/repl_skin.py b/openscreen/agent-harness/cli_anything/openscreen/utils/repl_skin.py
index 47260bebd..2feb59d1b 100644
--- a/openscreen/agent-harness/cli_anything/openscreen/utils/repl_skin.py
+++ b/openscreen/agent-harness/cli_anything/openscreen/utils/repl_skin.py
@@ -459,6 +459,26 @@ class ReplSkin:
raw_prompt = self.prompt(project_name, modified, context)
return input(raw_prompt).strip()
+ # ── Sub-prompt input ────────────────────────────────────────────
+
+ def sub_input(self, prompt_text: str, pt_session=None) -> str:
+ """Get input for a sub-prompt (e.g., parameter entry in add flows).
+
+ Uses prompt_toolkit if a session is available, otherwise falls back
+ to plain input(). This preserves history and styling consistency.
+
+ Args:
+ prompt_text: The prompt to display (e.g., " start_ms: ").
+ pt_session: An optional prompt_toolkit PromptSession.
+
+ Returns:
+ User input string (stripped).
+ """
+ if pt_session is not None:
+ return pt_session.prompt(prompt_text).strip()
+ else:
+ return input(prompt_text).strip()
+
# ── Toolbar builder ───────────────────────────────────────────────
def bottom_toolbar(self, items: dict[str, str]):