"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix: validate WaveTone manifest numbers and REPL paths
Shuhan Zhangb9922e92a64f
diff --git a/README.md b/README.mdindex f2b780932..58d99f1db 100644--- a/README.md+++ b/README.md@@ -1228,7 +1228,7 @@ gimp 107 passed ✅ (64 unit + 43 e2e)blender 208 passed ✅ (150 unit + 58 e2e)inkscape 202 passed ✅ (148 unit + 54 e2e)audacity 161 passed ✅ (107 unit + 54 e2e)-wavetone 20 passed ✅ (15 unit + 5 e2e)+wavetone 22 passed ✅ (17 unit + 5 e2e)libreoffice 158 passed ✅ (89 unit + 69 e2e)mubu 96 passed ✅ (85 unit + 11 e2e)obs-studio 153 passed ✅ (116 unit + 37 e2e)@@ -1308,7 +1308,7 @@ cli-anything/├── 🧊 blender/agent-harness/ # Blender CLI (208 tests)├── ✏️ inkscape/agent-harness/ # Inkscape CLI (202 tests)├── 🎵 audacity/agent-harness/ # Audacity CLI (161 tests)-├── wavetone/agent-harness/ # WaveTone CLI (20 tests: 15 unit + 5 e2e)+├── wavetone/agent-harness/ # WaveTone CLI (22 tests: 17 unit + 5 e2e)├── 🌐 browser/agent-harness/ # Browser CLI (DOMShell MCP, new)├── 📄 libreoffice/agent-harness/ # LibreOffice CLI (158 tests)├── 📧 mailchimp/agent-harness/ # Mailchimp Marketing API CLI (303 commands, 36 unit tests)diff --git a/README_CN.md b/README_CN.mdindex 71dfeb301..941ae4b29 100644--- a/README_CN.md+++ b/README_CN.md@@ -679,7 +679,7 @@ gimp 107 passed ✅ (64 unit + 43 e2e)blender 208 passed ✅ (150 unit + 58 e2e)inkscape 202 passed ✅ (148 unit + 54 e2e)audacity 161 passed ✅ (107 unit + 54 e2e)-wavetone 20 passed ✅ (15 unit + 5 e2e)+wavetone 22 passed ✅ (17 unit + 5 e2e)libreoffice 158 passed ✅ (89 unit + 69 e2e)obs-studio 153 passed ✅ (116 unit + 37 e2e)kdenlive 155 passed ✅ (111 unit + 44 e2e)@@ -753,7 +753,7 @@ cli-anything/├── 🧊 blender/agent-harness/ # Blender CLI(208 项测试)├── ✏️ inkscape/agent-harness/ # Inkscape CLI(202 项测试)├── 🎵 audacity/agent-harness/ # Audacity CLI(161 项测试)-├── wavetone/agent-harness/ # WaveTone CLI(20 项测试:15 unit + 5 e2e)+├── wavetone/agent-harness/ # WaveTone CLI(22 项测试:17 unit + 5 e2e)├── 📄 libreoffice/agent-harness/ # LibreOffice CLI(158 项测试)├── 📚 zotero/agent-harness/ # Zotero CLI(新增,支持文献导入)├── 📓 joplin/agent-harness/ # Joplin CLI(134 测试:107 单元 + 27 e2e)diff --git a/wavetone/agent-harness/cli_anything/wavetone/core/project.py b/wavetone/agent-harness/cli_anything/wavetone/core/project.pyindex fa5ea36e2..88bfa8391 100644--- a/wavetone/agent-harness/cli_anything/wavetone/core/project.py+++ b/wavetone/agent-harness/cli_anything/wavetone/core/project.py@@ -3,6 +3,7 @@from __future__ import annotationsimport json+import mathfrom copy import deepcopyfrom datetime import datetime, timezonefrom pathlib import Path@@ -55,6 +56,13 @@ def normalize_audio_path(audio_path: str | Path) -> Path:return path+def _finite_float(value: float, field_name: str) -> float:+ number = float(value)+ if not math.isfinite(number):+ raise ValueError(f"{field_name} must be finite")+ return number++def create_project(audio_path: str | Path,name: str | None = None,@@ -97,7 +105,7 @@ def save_project(project: dict[str, Any], output_path: str | Path) -> Path:path = Path(output_path).expanduser().resolve()path.parent.mkdir(parents=True, exist_ok=True)touch(project)- path.write_text(json.dumps(project, indent=2, sort_keys=True) + "\n", encoding="utf-8")+ path.write_text(json.dumps(project, indent=2, sort_keys=True, allow_nan=False) + "\n", encoding="utf-8")return path@@ -117,9 +125,10 @@ def add_label(time_seconds: float,note: str | None = None,) -> dict[str, Any]:+ time_value = _finite_float(time_seconds, "Label time")if time_seconds < 0:raise ValueError("Label time must be >= 0")- label: dict[str, Any] = {"name": name, "time_seconds": round(float(time_seconds), 6)}+ label: dict[str, Any] = {"name": name, "time_seconds": round(time_value, 6)}if note:label["note"] = noteproject.setdefault("labels", []).append(label)@@ -133,13 +142,15 @@ def set_tempo(first_bar_time_seconds: float = 0.0,meter: str = "4/4",) -> dict[str, Any]:- if bpm <= 0:+ bpm_value = _finite_float(bpm, "BPM")+ first_bar_value = _finite_float(first_bar_time_seconds, "First bar time")+ if bpm_value <= 0:raise ValueError("BPM must be > 0")- if first_bar_time_seconds < 0:+ if first_bar_value < 0:raise ValueError("First bar time must be >= 0")project["tempo"] = {- "bpm": round(float(bpm), 6),- "first_bar_time_seconds": round(float(first_bar_time_seconds), 6),+ "bpm": round(bpm_value, 6),+ "first_bar_time_seconds": round(first_bar_value, 6),"meter": meter,}return touch(project)@@ -149,6 +160,8 @@ def update_analysis(project: dict[str, Any], **settings: Any) -> dict[str, Any]:analysis = project.setdefault("analysis", deepcopy(DEFAULT_ANALYSIS_SETTINGS))for key, value in settings.items():if value is not None:+ if isinstance(value, float) and not math.isfinite(value):+ raise ValueError(f"{key} must be finite")analysis[key] = valuereturn touch(project)diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md b/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.mdindex dff7369ba..73ed7f5dd 100644--- a/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md@@ -2,7 +2,7 @@## Test Inventory Plan-- `test_core.py`: 15 unit tests for project manifests, audio probing, session logs,+- `test_core.py`: 17 unit tests for project manifests, audio probing, session logs,and backend discovery.- `test_full_e2e.py`: 5 E2E tests covering CLI subprocess workflows and realWaveTone launch smoke coverage.@@ -14,6 +14,7 @@- Save and load schema-compatible JSON.- Add labels in sorted time order.- Set tempo and analysis options.+- Reject non-finite numeric project values before JSON serialization.- Probe a generated WAV file with the Python stdlib.- Fall back to stat metadata for malformed WAV files.- Probe non-WAV audio with a single stable `ffprobe -show_entries` argument.@@ -26,6 +27,7 @@- Return a failing exit status for launch smoke checks when the backend exitsearly with a nonzero code.- Reject GUI launch attempts on non-Windows hosts with a clear error.+- Strip Windows REPL path quotes while preserving backslashes.## E2E Test Plan@@ -77,13 +79,14 @@ python -m pytest cli_anything\wavetone\tests\ -v -sResult:```text-collected 20 items+collected 22 itemscli_anything/wavetone/tests/test_core.py::test_create_project_manifest PASSEDcli_anything/wavetone/tests/test_core.py::test_rejects_unsupported_audio PASSEDcli_anything/wavetone/tests/test_core.py::test_save_load_project_roundtrip PASSEDcli_anything/wavetone/tests/test_core.py::test_labels_are_sorted PASSEDcli_anything/wavetone/tests/test_core.py::test_update_analysis_settings PASSED+cli_anything/wavetone/tests/test_core.py::test_rejects_non_finite_project_numbers PASSEDcli_anything/wavetone/tests/test_core.py::test_probe_wav_metadata PASSEDcli_anything/wavetone/tests/test_core.py::test_probe_malformed_wav_falls_back_to_stat PASSEDcli_anything/wavetone/tests/test_core.py::test_ffprobe_uses_single_show_entries_argument PASSED@@ -94,22 +97,24 @@ cli_anything/wavetone/tests/test_core.py::test_find_wavetone_from_env PASSEDcli_anything/wavetone/tests/test_core.py::test_cli_preserves_inherited_project_and_json_context PASSEDcli_anything/wavetone/tests/test_core.py::test_wavetone_launch_fails_on_early_nonzero_exit PASSEDcli_anything/wavetone/tests/test_core.py::test_launch_requires_windows PASSED+cli_anything/wavetone/tests/test_core.py::test_repl_split_strips_windows_quotes PASSEDcli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_help PASSEDcli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_project_audio_workflow_json PASSEDcli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_formats_json PASSEDcli_anything/wavetone/tests/test_full_e2e.py::TestRealWaveToneBackend::test_doctor_real_backend PASSEDcli_anything/wavetone/tests/test_full_e2e.py::TestRealWaveToneBackend::test_launch_real_backend_with_wav PASSED-20 passed in 3.09s+22 passed in 4.23s```## Coverage Notes- Unit tests cover manifest creation, validation, persistence, labels, tempo,- analysis settings, audio probing, malformed WAV fallback, session logs,- session schema validation, backend discovery, ffprobe argument construction,- ffprobe metadata parsing, inherited CLI project and JSON context, failed- launch smoke reporting, and Windows launch gating.+ analysis settings, finite numeric validation, audio probing, malformed WAV+ fallback, session logs, session schema validation, backend discovery,+ ffprobe argument construction, ffprobe metadata parsing, inherited CLI+ project and JSON context, failed launch smoke reporting, Windows launch+ gating, and REPL Windows path splitting.- CLI subprocess tests resolve and use the installed `cli-anything-wavetone`entry point.- Real backend coverage launches `C:\Users\Hp\Desktop\wavetone2.6.1\wavetone.exe`diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py b/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.pyindex ea82b63f5..b4518cd0d 100644--- a/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py@@ -21,7 +21,7 @@ from cli_anything.wavetone.core.project import (from cli_anything.wavetone.core.session import append_event, load_eventsfrom cli_anything.wavetone.tests.helpers import make_wavfrom cli_anything.wavetone.utils import wavetone_backend-from cli_anything.wavetone.wavetone_cli import cli+from cli_anything.wavetone.wavetone_cli import _split_repl_args, clidef test_create_project_manifest(tmp_path: Path) -> None:@@ -74,6 +74,17 @@ def test_update_analysis_settings(tmp_path: Path) -> None:assert project["analysis"]["analyze_fundamental_frequency"] is False+def test_rejects_non_finite_project_numbers(tmp_path: Path) -> None:+ wav = make_wav(tmp_path / "tone.wav")+ project = create_project(wav)++ with pytest.raises(ValueError, match="BPM.*finite"):+ set_tempo(project, float("nan"))++ with pytest.raises(ValueError, match="reference_frequency_hz.*finite"):+ update_analysis(project, reference_frequency_hz=float("inf"))++def test_probe_wav_metadata(tmp_path: Path) -> None:wav = make_wav(tmp_path / "tone.wav", duration=0.5, sample_rate=16000)info = probe_audio(wav)@@ -238,3 +249,15 @@ def test_launch_requires_windows(monkeypatch: pytest.MonkeyPatch) -> None:with pytest.raises(RuntimeError, match="requires Windows"):wavetone_backend.launch_wavetone()+++def test_repl_split_strips_windows_quotes() -> None:+ line = 'project new "C:\\Users\\me\\My Music\\song.wav" -o "C:\\Users\\me\\song.wt.json"'++ assert _split_repl_args(line) == [+ "project",+ "new",+ "C:\\Users\\me\\My Music\\song.wav",+ "-o",+ "C:\\Users\\me\\song.wt.json",+ ]diff --git a/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py b/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.pyindex da08c128c..a1edcc29b 100644--- a/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py+++ b/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py@@ -3,7 +3,6 @@from __future__ import annotationsimport json-import osimport shlexfrom pathlib import Pathfrom typing import Any@@ -55,6 +54,16 @@ def load_ctx_project(ctx: click.Context, explicit_path: str | Path | None = Nonereturn load_project(path), path+def _strip_matching_quotes(value: str) -> str:+ if len(value) >= 2 and value[0] == value[-1] and value[0] in {"'", '"'}:+ return value[1:-1]+ return value+++def _split_repl_args(line: str) -> list[str]:+ return [_strip_matching_quotes(arg) for arg in shlex.split(line, posix=False)]++@click.group(invoke_without_command=True)@click.option("--project", "project_path", type=click.Path(dir_okay=False), help="WaveTone project JSON path.")@click.option("--json", "json_mode", is_flag=True, help="Emit machine-readable JSON.")@@ -97,7 +106,7 @@ def repl(ctx: click.Context) -> None:click.echo(cli.get_help(ctx))continuetry:- args = shlex.split(line, posix=(os.name != "nt"))+ args = _split_repl_args(line)cli.main(args=args, prog_name="cli-anything-wavetone", standalone_mode=False, obj=ctx.obj)except click.ClickException as exc: # pragma: no coverskin.error(exc.format_message())