Skip to content

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

Python

feat: add WaveTone CLI harness

Shuhan Zhang9974ad260226
diff --git a/.gitignore b/.gitignore
index 842522adb..85070db1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -208,6 +208,8 @@
!/blender/agent-harness/
!/inkscape/agent-harness/
!/audacity/agent-harness/
+!/wavetone/
+!/wavetone/agent-harness/
!/libreoffice/agent-harness/
!/zotero/agent-harness/
!/mubu/agent-harness/
diff --git a/README.md b/README.md
index 17a93d0dd..808468c94 100644
--- a/README.md
+++ b/README.md
@@ -667,7 +667,7 @@ The meta-skill points agents to the live CLI-Hub catalog, where they can choose
| **๐Ÿค– AI/ML Platforms** | Automate model training, inference pipelines, and hyperparameter tuning through structured commands | Stable Diffusion WebUI, ComfyUI, Ollama, InvokeAI, Text-generation-webui, Open WebUI, Fooocus, Kohya_ss, AnythingLLM, SillyTavern |
| **๐Ÿ“Š Data & Analytics** | Enable programmatic data processing, visualization, and statistical analysis workflows | JupyterLab, Apache Superset, Metabase, Redash, DBeaver, KNIME, Orange, OpenSearch Dashboards, Lightdash |
| **๐Ÿ’ป Development Tools** | Streamline code editing, building, testing, and deployment processes via command interfaces | Jenkins, Gitea, Hoppscotch, Portainer, pgAdmin, SonarQube, ArgoCD, OpenLens, Insomnia, Beekeeper Studio, **[iTerm2](https://iterm2.com)** |
-| **๐ŸŽจ Creative & Media** | Control content creation, editing, and rendering workflows programmatically | Blender, GIMP, OBS Studio, Audacity, Krita, Kdenlive, Shotcut, Inkscape, Darktable, LMMS, Ardour |
+| **๐ŸŽจ Creative & Media** | Control content creation, editing, and rendering workflows programmatically | Blender, GIMP, OBS Studio, Audacity, WaveTone, Krita, Kdenlive, Shotcut, Inkscape, Darktable, LMMS, Ardour |
| **๐ŸŽฎ Game Development** | Manage game projects, scenes, exports, and scripting through headless engine interfaces | **[Godot Engine](https://godotengine.org)**, **[s&box](https://sbox.game)** |
| **๐Ÿ”ฌ Scientific Computing** | Automate research workflows, simulations, and complex calculations | ImageJ, FreeCAD, QGIS, ParaView, Gephi, LibreCAD, Stellarium, KiCad, JASP, Jamovi |
| **๐Ÿข Enterprise & Office** | Convert business applications and productivity tools into agent-accessible systems | NextCloud, GitLab, Grafana, Mattermost, LibreOffice, AppFlowy, NocoDB, Odoo (Community), Plane, ERPNext |
@@ -943,6 +943,13 @@ Each application received complete, production-ready CLI interfaces โ€” not demo
<td align="center">โœ… 161</td>
</tr>
<tr>
+<td align="center"><strong>WaveTone</strong></td>
+<td>Audio Transcription</td>
+<td><code>cli-anything-wavetone</code></td>
+<td>JSON manifest + real WaveTone launch</td>
+<td align="center"><a href="wavetone/agent-harness/">New</a></td>
+</tr>
+<tr>
<td align="center"><strong>๐ŸŒ Browser</strong></td>
<td>Browser Automation</td>
<td><code>cli-anything-browser</code></td>
@@ -1221,6 +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 13 passed โœ… (8 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)
@@ -1300,6 +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 (13 tests: 8 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.md
index ffac02dd9..c8bc5712b 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -368,7 +368,7 @@ cli-anything-gimp
| **๐Ÿค– AI/ML ๅนณๅฐ** | ็”จ็ป“ๆž„ๅŒ–ๅ‘ฝไปค้ฉฑๅŠจๆจกๅž‹่ฎญ็ปƒใ€ๆŽจ็†ๆตๆฐด็บฟๅ’Œ่ถ…ๅ‚ๆœ็ดข | Stable Diffusion WebUIใ€ComfyUIใ€InvokeAIใ€Text-generation-webuiใ€Open WebUIใ€Fooocusใ€Kohya_ssใ€AnythingLLMใ€SillyTavern |
| **๐Ÿ“Š ๆ•ฐๆฎไธŽๅˆ†ๆž** | ไปฅ็ผ–็จ‹ๆ–นๅผๅฎŒๆˆๆ•ฐๆฎๅค„็†ใ€ๅฏ่ง†ๅŒ–ๅ’Œ็ปŸ่ฎกๅˆ†ๆžๅทฅไฝœๆต | JupyterLabใ€Apache Supersetใ€Metabaseใ€Redashใ€DBeaverใ€KNIMEใ€Orangeใ€OpenSearch Dashboardsใ€Lightdash |
| **๐Ÿ’ป ๅผ€ๅ‘ๅทฅๅ…ท** | ้€š่ฟ‡ CLI ไธฒ่”ไปฃ็ ็ผ–่พ‘ใ€ๆž„ๅปบใ€ๆต‹่ฏ•ไธŽ้ƒจ็ฝฒๆต็จ‹ | Jenkinsใ€Giteaใ€Hoppscotchใ€Portainerใ€pgAdminใ€SonarQubeใ€ArgoCDใ€OpenLensใ€Insomniaใ€Beekeeper Studio |
-| **๐ŸŽจ ๅˆ›ๆ„ไธŽๅช’ไฝ“** | ไปฅ็ผ–็จ‹ๆ–นๅผๆŽงๅˆถๅ†…ๅฎนๅˆ›ไฝœใ€็ผ–่พ‘ๅ’ŒๆธฒๆŸ“ๅทฅไฝœๆต | Blenderใ€GIMPใ€OBS Studioใ€Audacityใ€Kritaใ€Kdenliveใ€Shotcutใ€Inkscapeใ€Darktableใ€LMMSใ€Ardour |
+| **๐ŸŽจ ๅˆ›ๆ„ไธŽๅช’ไฝ“** | ไปฅ็ผ–็จ‹ๆ–นๅผๆŽงๅˆถๅ†…ๅฎนๅˆ›ไฝœใ€็ผ–่พ‘ๅ’ŒๆธฒๆŸ“ๅทฅไฝœๆต | Blenderใ€GIMPใ€OBS Studioใ€Audacityใ€WaveToneใ€Kritaใ€Kdenliveใ€Shotcutใ€Inkscapeใ€Darktableใ€LMMSใ€Ardour |
| **๐Ÿ“ ๅ›พ่กจไธŽๅฏ่ง†ๅŒ–** | ไปฅ็ผ–็จ‹ๆ–นๅผๅˆ›ๅปบๅ’Œๆ“ไฝœๆต็จ‹ๅ›พใ€ๆžถๆž„ๅ›พใ€ER ๅ›พ็ญ‰ๅ„็ฑปๅ›พ่กจ | Draw.io (diagrams.net)ใ€Mermaidใ€PlantUMLใ€Excalidrawใ€yEd |
| **๐Ÿ”ฌ ็ง‘ๅญฆ่ฎก็ฎ—** | ่‡ชๅŠจๅŒ–็ง‘็ ”ๅทฅไฝœๆตใ€ไปฟ็œŸๆจกๆ‹Ÿๅ’Œๅคๆ‚่ฎก็ฎ— | ImageJใ€FreeCADใ€QGISใ€ParaViewใ€Gephiใ€LibreCADใ€Stellariumใ€KiCadใ€JASPใ€Jamovi |
| **๐Ÿข ไผไธšไธŽๅŠžๅ…ฌ** | ๅฐ†ๅ•†ไธšๅบ”็”จๅ’Œ็”ŸไบงๅŠ›ๅทฅๅ…ท่ฝฌๅŒ–ไธบ Agent ๅฏ่ฎฟ้—ฎ็š„็ณป็ปŸ | NextCloudใ€GitLabใ€Grafanaใ€Mattermostใ€LibreOfficeใ€AppFlowyใ€NocoDBใ€Odoo (Community)ใ€Planeใ€ERPNext |
@@ -534,6 +534,13 @@ CLI-Anything ้€‚็”จไบŽไปปไฝ•ๆœ‰ไปฃ็ ๅบ“็š„่ฝฏไปถ โ€”โ€” ไธ้™้ข†ๅŸŸ๏ผŒไธ้™
<td align="center">โœ… 161</td>
</tr>
<tr>
+<td align="center"><strong>WaveTone</strong></td>
+<td>้Ÿณ้ข‘ๆ‰’่ฐฑ่พ…ๅŠฉ</td>
+<td><code>cli-anything-wavetone</code></td>
+<td>JSON manifest + real WaveTone launch</td>
+<td align="center"><a href="wavetone/agent-harness/">ๆ–ฐๅขž</a></td>
+</tr>
+<tr>
<td align="center"><strong>๐Ÿ“„ LibreOffice</strong></td>
<td>ๅŠžๅ…ฌๅฅ—ไปถ๏ผˆWriterใ€Calcใ€Impress๏ผ‰</td>
<td><code>cli-anything-libreoffice</code></td>
@@ -672,6 +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 13 passed โœ… (8 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)
@@ -745,6 +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๏ผˆ13 ้กนๆต‹่ฏ•๏ผš8 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/registry.json b/registry.json
index 3f3e8ce34..77041f8b8 100644
--- a/registry.json
+++ b/registry.json
@@ -100,6 +100,25 @@
}
]
},
+ {
+ "name": "wavetone",
+ "display_name": "WaveTone",
+ "version": "1.0.0",
+ "description": "Prepare WaveTone 2.61 audio transcription manifests, probe audio files, and launch the real Windows WaveTone executable",
+ "requires": "WaveTone 2.61 extracted on Windows; set WAVETONE_EXE or WAVETONE_HOME",
+ "homepage": "http://ackiesound.ifdef.jp/",
+ "source_url": null,
+ "install_cmd": "pip install git+https://github.com/HKUDS/CLI-Anything.git#subdirectory=wavetone/agent-harness",
+ "entry_point": "cli-anything-wavetone",
+ "skill_md": "skills/cli-anything-wavetone/SKILL.md",
+ "category": "audio",
+ "contributors": [
+ {
+ "name": "Shuhan Zhang",
+ "url": "https://github.com/Manifold68575"
+ }
+ ]
+ },
{
"name": "blender",
"display_name": "Blender",
diff --git a/skills/cli-anything-wavetone/SKILL.md b/skills/cli-anything-wavetone/SKILL.md
new file mode 100644
index 000000000..a565109ed
--- /dev/null
+++ b/skills/cli-anything-wavetone/SKILL.md
@@ -0,0 +1,53 @@
+---
+name: "cli-anything-wavetone"
+description: "Control WaveTone 2.61 workflows through a JSON manifest and launch the real Windows WaveTone executable."
+---
+
+# cli-anything-wavetone
+
+Use this skill when an agent needs to prepare, inspect, and launch WaveTone 2.61
+audio transcription workflows.
+
+## Requirements
+
+- Windows host.
+- WaveTone 2.61 extracted locally.
+- Set `WAVETONE_EXE` to `wavetone.exe` or `WAVETONE_HOME` to the extracted
+ WaveTone directory when the default portable path is not used.
+
+## Core Commands
+
+All commands support the top-level `--json` flag.
+
+```bash
+cli-anything-wavetone --json wavetone doctor
+cli-anything-wavetone --json project new input.wav -o project.wt.json
+cli-anything-wavetone --project project.wt.json --json audio probe
+cli-anything-wavetone --project project.wt.json --json project set-tempo --bpm 120 --meter 4/4
+cli-anything-wavetone --project project.wt.json --json project add-label chorus --time 64.0
+cli-anything-wavetone --project project.wt.json --json wavetone launch
+```
+
+## Command Groups
+
+- `project`: create manifests, set tempo, add labels, update intended analysis
+ settings, and attach a WFD saved from WaveTone.
+- `audio`: probe audio metadata before opening it in WaveTone.
+- `wavetone`: run `doctor`, list supported formats, or launch the real GUI.
+- `session`: record lightweight event logs for multi-step agent workflows.
+- `defaults`: show default analysis settings.
+
+## Agent Guidance
+
+The JSON project manifest is not a WaveTone WFD file. It is an agent-facing plan
+for the source audio, intended analysis settings, labels, and tempo metadata.
+Use WaveTone itself to perform analysis and save WFD/MIDI/text/WAVE outputs.
+
+When running in automated checks, use:
+
+```bash
+cli-anything-wavetone --json wavetone launch input.wav --wait 1 --terminate
+```
+
+This confirms that the real backend can be started without leaving a persistent
+GUI process behind.
diff --git a/wavetone/agent-harness/WAVETONE.md b/wavetone/agent-harness/WAVETONE.md
new file mode 100644
index 000000000..112080e0c
--- /dev/null
+++ b/wavetone/agent-harness/WAVETONE.md
@@ -0,0 +1,60 @@
+# WaveTone Harness SOP
+
+## Target Software
+
+WaveTone 2.61 is a Windows freeware application for transcription support. It
+opens audio files, analyzes spectrograms and fundamental frequency, detects keys
+and chords, edits notes, and exports MIDI, text, and processed WAVE output from
+GUI menu actions.
+
+The local application layout inspected for this harness:
+
+- `wavetone.exe`: main GUI application.
+- `data/asdecoder.exe` plus BASS DLLs: bundled decoder support files.
+- `wthelp/*.html`: Shift-JIS help files documenting audio analysis and export.
+- No documented console help, batch mode, scripting API, or headless export
+ command was found.
+
+## Backend Strategy
+
+This harness does not reimplement WaveTone analysis. The real backend remains
+`wavetone.exe`, and `cli-anything-wavetone wavetone launch` starts that binary
+with an optional audio file argument.
+
+Because WaveTone 2.61 exposes analysis settings, MIDI/text export, and WAVE
+export through modal GUI flows, this harness provides an agent-facing project
+manifest rather than pretending to generate native WFD data. The JSON manifest
+tracks the source audio, intended analysis settings, labels, tempo metadata,
+and any WFD path saved later from WaveTone itself.
+
+## Command Groups
+
+- `project`: create and edit the JSON manifest.
+- `audio`: inspect source audio metadata before opening it in WaveTone.
+- `wavetone`: check and launch the real WaveTone executable.
+- `session`: keep lightweight event logs for agent workflows.
+- `defaults`: show the default analysis settings used for new manifests.
+
+## Required Dependency
+
+WaveTone is a hard runtime dependency. Set one of:
+
+- `WAVETONE_EXE=C:\path\to\wavetone.exe`
+- `WAVETONE_HOME=C:\path\to\wavetone2.6.1`
+
+The backend finder also checks common portable extraction locations such as
+`%USERPROFILE%\Desktop\wavetone2.6.1\wavetone.exe`.
+
+## Known Limits
+
+- WFD is not generated by this harness because the format is not documented.
+- Real analysis and export still occur in the WaveTone GUI.
+- Headless export evidence is therefore limited to launch smoke coverage and
+ audio/project file verification until a stable automation or scripting
+ interface is discovered.
+
+## Validation Notes
+
+The tests include unit coverage for manifests and audio probing, CLI subprocess
+coverage, and a real-backend smoke test that launches `wavetone.exe` with a WAV
+file and terminates it after a short wait.
diff --git a/wavetone/agent-harness/cli_anything/wavetone/README.md b/wavetone/agent-harness/cli_anything/wavetone/README.md
new file mode 100644
index 000000000..8f30b1c42
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/README.md
@@ -0,0 +1,56 @@
+# cli-anything-wavetone
+
+Agent-native CLI harness for WaveTone 2.61 on Windows.
+
+WaveTone is a transcription support tool for audio files. It analyzes
+spectrograms and fundamental frequency, supports key and chord detection, note
+editing, and GUI-driven MIDI/text/WAVE export. This harness creates a structured
+project manifest, probes audio files, records labels and tempo metadata, and
+launches the real WaveTone executable.
+
+## Install
+
+```bash
+cd wavetone/agent-harness
+pip install -e .
+```
+
+Set the backend path if WaveTone is not on the default portable path:
+
+```powershell
+$env:WAVETONE_HOME = "C:\Users\you\Desktop\wavetone2.6.1"
+# or
+$env:WAVETONE_EXE = "C:\Users\you\Desktop\wavetone2.6.1\wavetone.exe"
+```
+
+## Usage
+
+```bash
+cli-anything-wavetone --json wavetone doctor
+cli-anything-wavetone --json project new song.wav -o song.wt.json
+cli-anything-wavetone --project song.wt.json --json audio probe
+cli-anything-wavetone --project song.wt.json --json project set-tempo --bpm 128
+cli-anything-wavetone --project song.wt.json --json project add-label verse --time 32.5
+cli-anything-wavetone --project song.wt.json --json wavetone launch
+```
+
+Running `cli-anything-wavetone` with no subcommand opens the REPL.
+
+## Backend Truthfulness
+
+This harness calls the actual `wavetone.exe`. It does not reimplement
+WaveTone's analysis, transcription, or export engine. WaveTone 2.61 does not
+document a headless scripting interface, so analysis and export remain GUI menu
+flows. The JSON project is an agent-facing control and planning layer around the
+real application.
+
+## Tests
+
+```bash
+cd wavetone/agent-harness
+python -m pytest cli_anything/wavetone/tests/ -v
+```
+
+The full E2E test launches the real WaveTone executable. It requires Windows and
+a WaveTone 2.61 extraction with `wavetone.exe` and the bundled `data` directory.
+Use `WAVETONE_EXE` or `WAVETONE_HOME` to point the test at the installation.
diff --git a/wavetone/agent-harness/cli_anything/wavetone/__init__.py b/wavetone/agent-harness/cli_anything/wavetone/__init__.py
new file mode 100644
index 000000000..4400b4980
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/__init__.py
@@ -0,0 +1,3 @@
+"""WaveTone CLI-Anything harness."""
+
+__version__ = "1.0.0"
diff --git a/wavetone/agent-harness/cli_anything/wavetone/__main__.py b/wavetone/agent-harness/cli_anything/wavetone/__main__.py
new file mode 100644
index 000000000..0c84960b3
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/__main__.py
@@ -0,0 +1,7 @@
+"""Run cli-anything-wavetone as a module."""
+
+from .wavetone_cli import main
+
+
+if __name__ == "__main__":
+ main()
diff --git a/wavetone/agent-harness/cli_anything/wavetone/core/__init__.py b/wavetone/agent-harness/cli_anything/wavetone/core/__init__.py
new file mode 100644
index 000000000..4bb5f2a41
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/core/__init__.py
@@ -0,0 +1 @@
+"""Core modules for cli-anything-wavetone."""
diff --git a/wavetone/agent-harness/cli_anything/wavetone/core/audio.py b/wavetone/agent-harness/cli_anything/wavetone/core/audio.py
new file mode 100644
index 000000000..210071219
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/core/audio.py
@@ -0,0 +1,96 @@
+"""Audio probing utilities for WaveTone projects."""
+
+from __future__ import annotations
+
+import json
+import shutil
+import subprocess
+import wave
+from pathlib import Path
+from typing import Any
+
+from .project import normalize_audio_path
+
+
+def _probe_wav_stdlib(path: Path) -> dict[str, Any]:
+ with wave.open(str(path), "rb") as handle:
+ frames = handle.getnframes()
+ sample_rate = handle.getframerate()
+ channels = handle.getnchannels()
+ sample_width = handle.getsampwidth()
+ duration = frames / sample_rate if sample_rate else 0.0
+ return {
+ "path": str(path),
+ "format": "wav",
+ "codec": "pcm",
+ "duration_seconds": round(duration, 6),
+ "sample_rate": sample_rate,
+ "channels": channels,
+ "sample_width_bytes": sample_width,
+ "size_bytes": path.stat().st_size,
+ "probe_method": "python-wave",
+ }
+
+
+def _probe_ffprobe(path: Path) -> dict[str, Any]:
+ ffprobe = shutil.which("ffprobe")
+ if not ffprobe:
+ raise RuntimeError("ffprobe not found")
+ result = subprocess.run(
+ [
+ ffprobe,
+ "-v",
+ "error",
+ "-show_entries",
+ "stream=codec_type,codec_name,sample_rate,channels",
+ "-show_entries",
+ "format=duration,format_name,bit_rate,size",
+ "-of",
+ "json",
+ str(path),
+ ],
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+ data = json.loads(result.stdout)
+ audio_stream = next(
+ (stream for stream in data.get("streams", []) if stream.get("codec_type") == "audio"),
+ {},
+ )
+ fmt = data.get("format", {})
+ duration = float(fmt.get("duration") or 0.0)
+ return {
+ "path": str(path),
+ "format": fmt.get("format_name"),
+ "codec": audio_stream.get("codec_name"),
+ "duration_seconds": round(duration, 6),
+ "sample_rate": int(audio_stream["sample_rate"]) if audio_stream.get("sample_rate") else None,
+ "channels": audio_stream.get("channels"),
+ "bit_rate": int(fmt["bit_rate"]) if fmt.get("bit_rate") else None,
+ "size_bytes": int(fmt.get("size") or path.stat().st_size),
+ "probe_method": "ffprobe",
+ }
+
+
+def probe_audio(audio_path: str | Path) -> dict[str, Any]:
+ path = normalize_audio_path(audio_path)
+ if path.suffix.lower() in {".wav", ".wave"}:
+ try:
+ return _probe_wav_stdlib(path)
+ except wave.Error:
+ pass
+ try:
+ return _probe_ffprobe(path)
+ except (RuntimeError, subprocess.CalledProcessError, json.JSONDecodeError):
+ return {
+ "path": str(path),
+ "format": path.suffix.lower().lstrip(".") or None,
+ "codec": None,
+ "duration_seconds": None,
+ "sample_rate": None,
+ "channels": None,
+ "size_bytes": path.stat().st_size,
+ "probe_method": "stat",
+ "warning": "Install ffprobe for detailed metadata on this format.",
+ }
diff --git a/wavetone/agent-harness/cli_anything/wavetone/core/project.py b/wavetone/agent-harness/cli_anything/wavetone/core/project.py
new file mode 100644
index 000000000..fa5ea36e2
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/core/project.py
@@ -0,0 +1,172 @@
+"""Project manifest helpers for the WaveTone harness."""
+
+from __future__ import annotations
+
+import json
+from copy import deepcopy
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Any
+
+
+SCHEMA_VERSION = "wavetone-project/v1"
+SOFTWARE_VERSION = "2.61"
+SUPPORTED_AUDIO_EXTENSIONS = {
+ ".wav",
+ ".wave",
+ ".aif",
+ ".aiff",
+ ".mp3",
+ ".wma",
+ ".aac",
+ ".ogg",
+ ".oga",
+ ".flac",
+ ".wv",
+ ".ape",
+ ".alac",
+ ".tta",
+}
+
+DEFAULT_ANALYSIS_SETTINGS: dict[str, Any] = {
+ "blocks_per_second": 12,
+ "blocks_per_semitone": 5,
+ "note_range": "C1-B7",
+ "reference_frequency_hz": 440.0,
+ "analyze_fundamental_frequency": True,
+ "channel": "Stereo",
+ "skip_analysis_dialog": False,
+}
+
+
+def now_iso() -> str:
+ return datetime.now(timezone.utc).replace(microsecond=0).isoformat()
+
+
+def normalize_audio_path(audio_path: str | Path) -> Path:
+ path = Path(audio_path).expanduser().resolve()
+ if not path.exists():
+ raise FileNotFoundError(f"Audio file not found: {path}")
+ if not path.is_file():
+ raise ValueError(f"Audio path is not a file: {path}")
+ if path.suffix.lower() not in SUPPORTED_AUDIO_EXTENSIONS:
+ supported = ", ".join(sorted(SUPPORTED_AUDIO_EXTENSIONS))
+ raise ValueError(f"Unsupported audio extension {path.suffix!r}. Supported: {supported}")
+ return path
+
+
+def create_project(
+ audio_path: str | Path,
+ name: str | None = None,
+ analysis_settings: dict[str, Any] | None = None,
+) -> dict[str, Any]:
+ audio = normalize_audio_path(audio_path)
+ created_at = now_iso()
+ settings = deepcopy(DEFAULT_ANALYSIS_SETTINGS)
+ if analysis_settings:
+ settings.update(analysis_settings)
+
+ return {
+ "schema_version": SCHEMA_VERSION,
+ "software": {"name": "WaveTone", "version": SOFTWARE_VERSION, "backend": "wavetone.exe"},
+ "project": {"name": name or audio.stem, "created_at": created_at, "modified_at": created_at},
+ "audio": {
+ "path": str(audio),
+ "filename": audio.name,
+ "extension": audio.suffix.lower(),
+ "size_bytes": audio.stat().st_size,
+ },
+ "analysis": settings,
+ "tempo": {"bpm": None, "first_bar_time_seconds": 0.0, "meter": "4/4"},
+ "labels": [],
+ "notes": [],
+ "wfd_path": None,
+ "limitations": [
+ "WaveTone 2.61 exposes analysis, MIDI/text export, and WAVE export through GUI menus.",
+ "This manifest is an agent-facing plan; WFD analysis data must be saved by WaveTone itself.",
+ ],
+ }
+
+
+def touch(project: dict[str, Any]) -> dict[str, Any]:
+ project.setdefault("project", {})["modified_at"] = now_iso()
+ return project
+
+
+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")
+ return path
+
+
+def load_project(project_path: str | Path) -> dict[str, Any]:
+ path = Path(project_path).expanduser().resolve()
+ if not path.exists():
+ raise FileNotFoundError(f"Project file not found: {path}")
+ data = json.loads(path.read_text(encoding="utf-8"))
+ if data.get("schema_version") != SCHEMA_VERSION:
+ raise ValueError(f"Unsupported WaveTone project schema: {data.get('schema_version')!r}")
+ return data
+
+
+def add_label(
+ project: dict[str, Any],
+ name: str,
+ time_seconds: float,
+ note: str | None = None,
+) -> dict[str, Any]:
+ if time_seconds < 0:
+ raise ValueError("Label time must be >= 0")
+ label: dict[str, Any] = {"name": name, "time_seconds": round(float(time_seconds), 6)}
+ if note:
+ label["note"] = note
+ project.setdefault("labels", []).append(label)
+ project["labels"].sort(key=lambda item: item["time_seconds"])
+ return touch(project)
+
+
+def set_tempo(
+ project: dict[str, Any],
+ bpm: float,
+ first_bar_time_seconds: float = 0.0,
+ meter: str = "4/4",
+) -> dict[str, Any]:
+ if bpm <= 0:
+ raise ValueError("BPM must be > 0")
+ if first_bar_time_seconds < 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),
+ "meter": meter,
+ }
+ return touch(project)
+
+
+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:
+ analysis[key] = value
+ return touch(project)
+
+
+def set_wfd_path(project: dict[str, Any], wfd_path: str | Path | None) -> dict[str, Any]:
+ project["wfd_path"] = None if wfd_path is None else str(Path(wfd_path).expanduser().resolve())
+ return touch(project)
+
+
+def project_summary(project: dict[str, Any]) -> dict[str, Any]:
+ return {
+ "schema_version": project.get("schema_version"),
+ "name": project.get("project", {}).get("name"),
+ "audio": project.get("audio"),
+ "tempo": project.get("tempo"),
+ "label_count": len(project.get("labels", [])),
+ "labels": project.get("labels", []),
+ "analysis": project.get("analysis"),
+ "wfd_path": project.get("wfd_path"),
+ "limitations": project.get("limitations", []),
+ }
diff --git a/wavetone/agent-harness/cli_anything/wavetone/core/session.py b/wavetone/agent-harness/cli_anything/wavetone/core/session.py
new file mode 100644
index 000000000..e03e925dd
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/core/session.py
@@ -0,0 +1,30 @@
+"""Small session event log for WaveTone CLI runs."""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+from typing import Any
+
+from .project import now_iso
+
+
+def append_event(session_path: str | Path, event: str, payload: dict[str, Any]) -> dict[str, Any]:
+ path = Path(session_path).expanduser().resolve()
+ if path.exists():
+ data = json.loads(path.read_text(encoding="utf-8"))
+ else:
+ data = {"schema_version": "wavetone-session/v1", "events": []}
+ record = {"time": now_iso(), "event": event, "payload": payload}
+ data.setdefault("events", []).append(record)
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text(json.dumps(data, indent=2, sort_keys=True) + "\n", encoding="utf-8")
+ return record
+
+
+def load_events(session_path: str | Path) -> list[dict[str, Any]]:
+ path = Path(session_path).expanduser().resolve()
+ if not path.exists():
+ return []
+ data = json.loads(path.read_text(encoding="utf-8"))
+ return list(data.get("events", []))
diff --git a/wavetone/agent-harness/cli_anything/wavetone/skills/SKILL.md b/wavetone/agent-harness/cli_anything/wavetone/skills/SKILL.md
new file mode 100644
index 000000000..a565109ed
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/skills/SKILL.md
@@ -0,0 +1,53 @@
+---
+name: "cli-anything-wavetone"
+description: "Control WaveTone 2.61 workflows through a JSON manifest and launch the real Windows WaveTone executable."
+---
+
+# cli-anything-wavetone
+
+Use this skill when an agent needs to prepare, inspect, and launch WaveTone 2.61
+audio transcription workflows.
+
+## Requirements
+
+- Windows host.
+- WaveTone 2.61 extracted locally.
+- Set `WAVETONE_EXE` to `wavetone.exe` or `WAVETONE_HOME` to the extracted
+ WaveTone directory when the default portable path is not used.
+
+## Core Commands
+
+All commands support the top-level `--json` flag.
+
+```bash
+cli-anything-wavetone --json wavetone doctor
+cli-anything-wavetone --json project new input.wav -o project.wt.json
+cli-anything-wavetone --project project.wt.json --json audio probe
+cli-anything-wavetone --project project.wt.json --json project set-tempo --bpm 120 --meter 4/4
+cli-anything-wavetone --project project.wt.json --json project add-label chorus --time 64.0
+cli-anything-wavetone --project project.wt.json --json wavetone launch
+```
+
+## Command Groups
+
+- `project`: create manifests, set tempo, add labels, update intended analysis
+ settings, and attach a WFD saved from WaveTone.
+- `audio`: probe audio metadata before opening it in WaveTone.
+- `wavetone`: run `doctor`, list supported formats, or launch the real GUI.
+- `session`: record lightweight event logs for multi-step agent workflows.
+- `defaults`: show default analysis settings.
+
+## Agent Guidance
+
+The JSON project manifest is not a WaveTone WFD file. It is an agent-facing plan
+for the source audio, intended analysis settings, labels, and tempo metadata.
+Use WaveTone itself to perform analysis and save WFD/MIDI/text/WAVE outputs.
+
+When running in automated checks, use:
+
+```bash
+cli-anything-wavetone --json wavetone launch input.wav --wait 1 --terminate
+```
+
+This confirms that the real backend can be started without leaving a persistent
+GUI process behind.
diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md b/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md
new file mode 100644
index 000000000..138f49968
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/TEST.md
@@ -0,0 +1,100 @@
+# WaveTone Harness Test Plan and Results
+
+## Test Inventory Plan
+
+- `test_core.py`: 8 unit tests for project manifests, audio probing, session logs,
+ and backend discovery.
+- `test_full_e2e.py`: 5 E2E tests covering CLI subprocess workflows and real
+ WaveTone launch smoke coverage.
+
+## Unit Test Plan
+
+- Create a manifest from a supported WAV file.
+- Reject missing files and unsupported extensions.
+- Save and load schema-compatible JSON.
+- Add labels in sorted time order.
+- Set tempo and analysis options.
+- Probe a generated WAV file with the Python stdlib.
+- Append and reload session events.
+- Resolve `WAVETONE_EXE` from the environment.
+
+## E2E Test Plan
+
+### CLI Project Workflow
+
+Simulates an agent preparing an audio file before opening it in WaveTone.
+
+Operations:
+
+1. Generate a real WAV fixture.
+2. Run `cli-anything-wavetone --json project new`.
+3. Run `project set-tempo`.
+4. Run `project add-label`.
+5. Run `audio probe`.
+
+Verified:
+
+- CLI JSON is parseable.
+- Project file exists.
+- Labels and tempo persist.
+- Audio metadata is correct.
+
+### CLI Backend Workflow
+
+Simulates an agent validating the installed WaveTone backend.
+
+Operations:
+
+1. Run `wavetone doctor`.
+2. Run `wavetone formats`.
+3. Launch the real `wavetone.exe` with a generated WAV and terminate it after a
+ short wait.
+
+Verified:
+
+- Doctor reports all bundled files.
+- Formats include documented WaveTone audio extensions.
+- Real WaveTone process starts and is terminated by the smoke test.
+
+## Test Results
+
+Command:
+
+```bash
+$env:PATH = "$env:APPDATA\Python\Python313\Scripts;$env:PATH"
+python -m pytest cli_anything\wavetone\tests\ -v -s
+```
+
+Result:
+
+```text
+collected 13 items
+
+cli_anything/wavetone/tests/test_core.py::test_create_project_manifest PASSED
+cli_anything/wavetone/tests/test_core.py::test_rejects_unsupported_audio PASSED
+cli_anything/wavetone/tests/test_core.py::test_save_load_project_roundtrip PASSED
+cli_anything/wavetone/tests/test_core.py::test_labels_are_sorted PASSED
+cli_anything/wavetone/tests/test_core.py::test_update_analysis_settings PASSED
+cli_anything/wavetone/tests/test_core.py::test_probe_wav_metadata PASSED
+cli_anything/wavetone/tests/test_core.py::test_session_event_log PASSED
+cli_anything/wavetone/tests/test_core.py::test_find_wavetone_from_env PASSED
+cli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_help PASSED
+cli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_project_audio_workflow_json PASSED
+cli_anything/wavetone/tests/test_full_e2e.py::TestCLISubprocess::test_formats_json PASSED
+cli_anything/wavetone/tests/test_full_e2e.py::TestRealWaveToneBackend::test_doctor_real_backend PASSED
+cli_anything/wavetone/tests/test_full_e2e.py::TestRealWaveToneBackend::test_launch_real_backend_with_wav PASSED
+
+13 passed in 4.64s
+```
+
+## Coverage Notes
+
+- Unit tests cover manifest creation, validation, persistence, labels, tempo,
+ analysis settings, audio probing, session logs, and backend discovery.
+- 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`
+ with a generated WAV and terminates it after a short wait.
+- WaveTone 2.61 has no documented headless analysis/export API. Export
+ verification remains a known gap until a stable non-GUI automation surface is
+ discovered.
diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/__init__.py b/wavetone/agent-harness/cli_anything/wavetone/tests/__init__.py
new file mode 100644
index 000000000..8a3970792
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/__init__.py
@@ -0,0 +1 @@
+"""Tests for cli-anything-wavetone."""
diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py b/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py
new file mode 100644
index 000000000..66d871a7f
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/test_core.py
@@ -0,0 +1,111 @@
+from __future__ import annotations
+
+import math
+import struct
+import wave
+from pathlib import Path
+
+import pytest
+
+from cli_anything.wavetone.core.audio import probe_audio
+from cli_anything.wavetone.core.project import (
+ DEFAULT_ANALYSIS_SETTINGS,
+ add_label,
+ create_project,
+ load_project,
+ save_project,
+ set_tempo,
+ update_analysis,
+)
+from cli_anything.wavetone.core.session import append_event, load_events
+from cli_anything.wavetone.utils import wavetone_backend
+
+
+def make_wav(path: Path, freq: float = 440.0, duration: float = 0.25, sample_rate: int = 8000) -> Path:
+ frames = int(duration * sample_rate)
+ with wave.open(str(path), "wb") as handle:
+ handle.setnchannels(1)
+ handle.setsampwidth(2)
+ handle.setframerate(sample_rate)
+ for idx in range(frames):
+ sample = int(16000 * math.sin(2 * math.pi * freq * idx / sample_rate))
+ handle.writeframes(struct.pack("<h", sample))
+ return path
+
+
+def test_create_project_manifest(tmp_path: Path) -> None:
+ wav = make_wav(tmp_path / "tone.wav")
+ project = create_project(wav, name="Tone Test")
+
+ assert project["schema_version"] == "wavetone-project/v1"
+ assert project["project"]["name"] == "Tone Test"
+ assert project["audio"]["path"] == str(wav.resolve())
+ assert project["analysis"] == DEFAULT_ANALYSIS_SETTINGS
+
+
+def test_rejects_unsupported_audio(tmp_path: Path) -> None:
+ txt = tmp_path / "not-audio.txt"
+ txt.write_text("x", encoding="utf-8")
+
+ with pytest.raises(ValueError):
+ create_project(txt)
+
+
+def test_save_load_project_roundtrip(tmp_path: Path) -> None:
+ wav = make_wav(tmp_path / "tone.wav")
+ project = create_project(wav)
+ add_label(project, "chorus", 12.5)
+ set_tempo(project, 128, first_bar_time_seconds=0.2)
+ output = save_project(project, tmp_path / "project.json")
+
+ loaded = load_project(output)
+ assert loaded["labels"][0]["name"] == "chorus"
+ assert loaded["tempo"]["bpm"] == 128
+ assert loaded["tempo"]["first_bar_time_seconds"] == 0.2
+
+
+def test_labels_are_sorted(tmp_path: Path) -> None:
+ wav = make_wav(tmp_path / "tone.wav")
+ project = create_project(wav)
+ add_label(project, "late", 4.0)
+ add_label(project, "early", 1.0)
+
+ assert [label["name"] for label in project["labels"]] == ["early", "late"]
+
+
+def test_update_analysis_settings(tmp_path: Path) -> None:
+ wav = make_wav(tmp_path / "tone.wav")
+ project = create_project(wav)
+ update_analysis(project, channel="L+R", blocks_per_second=24, analyze_fundamental_frequency=False)
+
+ assert project["analysis"]["channel"] == "L+R"
+ assert project["analysis"]["blocks_per_second"] == 24
+ assert project["analysis"]["analyze_fundamental_frequency"] is False
+
+
+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)
+
+ assert info["probe_method"] == "python-wave"
+ assert info["sample_rate"] == 16000
+ assert info["channels"] == 1
+ assert info["duration_seconds"] == 0.5
+ assert info["size_bytes"] > 0
+
+
+def test_session_event_log(tmp_path: Path) -> None:
+ session_path = tmp_path / "session.json"
+ append_event(session_path, "created", {"project": "demo"})
+ append_event(session_path, "launched", {"pid": 123})
+
+ events = load_events(session_path)
+ assert [event["event"] for event in events] == ["created", "launched"]
+
+
+def test_find_wavetone_from_env(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ fake = tmp_path / "wavetone.exe"
+ fake.write_bytes(b"MZ")
+ monkeypatch.setenv("WAVETONE_EXE", str(fake))
+
+ assert wavetone_backend.find_wavetone() == fake.resolve()
diff --git a/wavetone/agent-harness/cli_anything/wavetone/tests/test_full_e2e.py b/wavetone/agent-harness/cli_anything/wavetone/tests/test_full_e2e.py
new file mode 100644
index 000000000..436856efe
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/tests/test_full_e2e.py
@@ -0,0 +1,118 @@
+from __future__ import annotations
+
+import json
+import math
+import os
+import shutil
+import struct
+import subprocess
+import sys
+import wave
+from pathlib import Path
+
+from cli_anything.wavetone.utils import wavetone_backend
+
+
+def make_wav(path: Path, freq: float = 440.0, duration: float = 0.5, sample_rate: int = 8000) -> Path:
+ frames = int(duration * sample_rate)
+ with wave.open(str(path), "wb") as handle:
+ handle.setnchannels(1)
+ handle.setsampwidth(2)
+ handle.setframerate(sample_rate)
+ for idx in range(frames):
+ sample = int(16000 * math.sin(2 * math.pi * freq * idx / sample_rate))
+ handle.writeframes(struct.pack("<h", sample))
+ return path
+
+
+def _resolve_cli(name: str) -> list[str]:
+ """Resolve installed CLI command; fall back to python -m for development."""
+ 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.wavetone.wavetone_cli"
+ print(f"[_resolve_cli] Falling back to: {sys.executable} -m {module}")
+ return [sys.executable, "-m", module]
+
+
+class TestCLISubprocess:
+ CLI_BASE = _resolve_cli("cli-anything-wavetone")
+
+ def _run(self, args: list[str], check: bool = True) -> subprocess.CompletedProcess[str]:
+ return subprocess.run(self.CLI_BASE + args, capture_output=True, text=True, check=check)
+
+ def test_help(self) -> None:
+ result = self._run(["--help"])
+ assert "Agent-native CLI harness for WaveTone" in result.stdout
+
+ def test_project_audio_workflow_json(self, tmp_path: Path) -> None:
+ wav = make_wav(tmp_path / "tone.wav")
+ project = tmp_path / "tone.wt.json"
+
+ result = self._run(["--json", "project", "new", str(wav), "-o", str(project)])
+ data = json.loads(result.stdout)
+ assert data["ok"] is True
+ assert project.exists()
+
+ result = self._run(
+ ["--project", str(project), "--json", "project", "set-tempo", "--bpm", "132.5", "--first-bar", "0.1"]
+ )
+ assert json.loads(result.stdout)["tempo"]["bpm"] == 132.5
+
+ result = self._run(["--project", str(project), "--json", "project", "add-label", "intro", "--time", "0.25"])
+ assert json.loads(result.stdout)["labels"][0]["name"] == "intro"
+
+ result = self._run(["--project", str(project), "--json", "audio", "probe"])
+ audio = json.loads(result.stdout)["audio"]
+ assert audio["duration_seconds"] == 0.5
+ assert audio["channels"] == 1
+ print(f"\n Project: {project}")
+ print(f" Audio: {wav} ({wav.stat().st_size:,} bytes)")
+
+ def test_formats_json(self) -> None:
+ result = self._run(["--json", "wavetone", "formats"])
+ data = json.loads(result.stdout)
+ assert ".wav" in data["formats"]["extensions"]
+ assert "MP3" in data["formats"]["from_readme"]
+
+
+class TestRealWaveToneBackend:
+ CLI_BASE = _resolve_cli("cli-anything-wavetone")
+
+ def _run(self, args: list[str], check: bool = True) -> subprocess.CompletedProcess[str]:
+ return subprocess.run(self.CLI_BASE + args, capture_output=True, text=True, check=check)
+
+ def test_doctor_real_backend(self) -> None:
+ result = self._run(["--json", "wavetone", "doctor"])
+ data = json.loads(result.stdout)
+ assert data["ready"] is True
+ assert any(check["name"] == "data/asdecoder.exe" and check["ok"] for check in data["checks"])
+ print(f"\n WaveTone root: {data['root']}")
+
+ def test_launch_real_backend_with_wav(self, tmp_path: Path) -> None:
+ exe = wavetone_backend.find_wavetone()
+ wav = make_wav(tmp_path / "launch.wav")
+ result = self._run(
+ [
+ "--json",
+ "wavetone",
+ "launch",
+ str(wav),
+ "--exe",
+ str(exe),
+ "--wait",
+ "1",
+ "--terminate",
+ ]
+ )
+ data = json.loads(result.stdout)["launch"]
+ assert data["backend"] == "wavetone.exe"
+ assert data["audio_path"] == str(wav.resolve())
+ assert data["running_after_wait"] is True
+ assert data["terminated"] is True
+ print(f"\n Launched WaveTone PID: {data['pid']}")
+ print(f" WAV: {wav} ({wav.stat().st_size:,} bytes)")
diff --git a/wavetone/agent-harness/cli_anything/wavetone/utils/__init__.py b/wavetone/agent-harness/cli_anything/wavetone/utils/__init__.py
new file mode 100644
index 000000000..4e1504df1
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/utils/__init__.py
@@ -0,0 +1 @@
+"""Utility modules for cli-anything-wavetone."""
diff --git a/wavetone/agent-harness/cli_anything/wavetone/utils/repl_skin.py b/wavetone/agent-harness/cli_anything/wavetone/utils/repl_skin.py
new file mode 100644
index 000000000..bc1fb6d1d
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/utils/repl_skin.py
@@ -0,0 +1,567 @@
+"""cli-anything REPL Skin โ€” Unified terminal interface for all CLI harnesses.
+
+Copy this file into your CLI package at:
+ cli_anything/<software>/utils/repl_skin.py
+
+Usage:
+ from cli_anything.<software>.utils.repl_skin import ReplSkin
+
+ skin = ReplSkin("shotcut", version="1.0.0")
+ skin.print_banner() # auto-detects repo-root or packaged SKILL.md
+ prompt_text = skin.prompt(project_name="my_video.mlt", modified=True)
+ skin.success("Project saved")
+ skin.error("File not found")
+ skin.warning("Unsaved changes")
+ skin.info("Processing 24 clips...")
+ skin.status("Track 1", "3 clips, 00:02:30")
+ skin.table(headers, rows)
+ skin.print_goodbye()
+"""
+
+import os
+import sys
+from pathlib import Path
+
+# โ”€โ”€ ANSI color codes (no external deps for core styling) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+_RESET = "\033[0m"
+_BOLD = "\033[1m"
+_DIM = "\033[2m"
+_ITALIC = "\033[3m"
+_UNDERLINE = "\033[4m"
+
+# Brand colors
+_CYAN = "\033[38;5;80m" # cli-anything brand cyan
+_CYAN_BG = "\033[48;5;80m"
+_WHITE = "\033[97m"
+_GRAY = "\033[38;5;245m"
+_DARK_GRAY = "\033[38;5;240m"
+_LIGHT_GRAY = "\033[38;5;250m"
+
+# Software accent colors โ€” each software gets a unique accent
+_ACCENT_COLORS = {
+ "gimp": "\033[38;5;214m", # warm orange
+ "blender": "\033[38;5;208m", # deep orange
+ "inkscape": "\033[38;5;39m", # bright blue
+ "audacity": "\033[38;5;33m", # navy blue
+ "libreoffice": "\033[38;5;40m", # green
+ "obs_studio": "\033[38;5;55m", # purple
+ "kdenlive": "\033[38;5;69m", # slate blue
+ "shotcut": "\033[38;5;35m", # teal green
+}
+_DEFAULT_ACCENT = "\033[38;5;75m" # default sky blue
+
+# Status colors
+_GREEN = "\033[38;5;78m"
+_YELLOW = "\033[38;5;220m"
+_RED = "\033[38;5;196m"
+_BLUE = "\033[38;5;75m"
+_MAGENTA = "\033[38;5;176m"
+
+_SKILL_SOURCE_REPO = os.environ.get("CLI_ANYTHING_SKILL_REPO", "HKUDS/CLI-Anything")
+
+# โ”€โ”€ Brand icon โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+# The cli-anything icon: a small colored diamond/chevron mark
+_ICON = f"{_CYAN}{_BOLD}โ—†{_RESET}"
+_ICON_SMALL = f"{_CYAN}โ–ธ{_RESET}"
+
+# โ”€โ”€ Box drawing characters โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+_H_LINE = "โ”€"
+_V_LINE = "โ”‚"
+_TL = "โ•ญ"
+_TR = "โ•ฎ"
+_BL = "โ•ฐ"
+_BR = "โ•ฏ"
+_T_DOWN = "โ”ฌ"
+_T_UP = "โ”ด"
+_T_RIGHT = "โ”œ"
+_T_LEFT = "โ”ค"
+_CROSS = "โ”ผ"
+
+
+def _strip_ansi(text: str) -> str:
+ """Remove ANSI escape codes for length calculation."""
+ import re
+ return re.sub(r"\033\[[^m]*m", "", text)
+
+
+def _visible_len(text: str) -> int:
+ """Get visible length of text (excluding ANSI codes)."""
+ return len(_strip_ansi(text))
+
+
+def _display_home_path(path: str) -> str:
+ """Display a path relative to the home directory when possible."""
+ expanded = Path(path).expanduser().resolve()
+ home = Path.home().resolve()
+ try:
+ relative = expanded.relative_to(home)
+ return f"~/{relative.as_posix()}"
+ except ValueError:
+ return str(expanded)
+
+
+class ReplSkin:
+ """Unified REPL skin for cli-anything CLIs.
+
+ Provides consistent branding, prompts, and message formatting
+ across all CLI harnesses built with the cli-anything methodology.
+ """
+
+ def __init__(self, software: str, version: str = "1.0.0",
+ history_file: str | None = None, skill_path: str | None = None):
+ """Initialize the REPL skin.
+
+ Args:
+ software: Software name (e.g., "gimp", "shotcut", "blender").
+ version: CLI version string.
+ history_file: Path for persistent command history.
+ Defaults to ~/.cli-anything-<software>/history
+ skill_path: Path to the SKILL.md file for agent discovery.
+ Auto-detected from the repo-root skills/ tree when present,
+ otherwise from the package's skills/ directory.
+ Displayed in banner for AI agents to know where to read skill info.
+ """
+ self.software = software.lower().replace("-", "_")
+ self.display_name = software.replace("_", " ").title()
+ self.version = version
+ software_aliases = {"iterm2_ctl": "iterm2"}
+ self.skill_slug = software_aliases.get(self.software, self.software).replace("_", "-")
+ self.skill_id = f"cli-anything-{self.skill_slug}"
+ self.skill_install_cmd = (
+ f"npx skills add {_SKILL_SOURCE_REPO} --skill {self.skill_id} -g -y"
+ )
+ global_skill_root = Path(
+ os.environ.get("CLI_ANYTHING_GLOBAL_SKILLS_DIR", str(Path.home() / ".agents" / "skills"))
+ ).expanduser()
+ self.global_skill_path = str(global_skill_root / self.skill_id / "SKILL.md")
+
+ # Prefer repo-root canonical skills/<skill-id>/SKILL.md when running
+ # inside the CLI-Anything monorepo. Fall back to the packaged
+ # cli_anything/<software>/skills/SKILL.md for installed harnesses.
+ if skill_path is None:
+ package_skill = Path(__file__).resolve().parent.parent / "skills" / "SKILL.md"
+ repo_skill = None
+ for parent in Path(__file__).resolve().parents:
+ candidate = parent / "skills" / self.skill_id / "SKILL.md"
+ if candidate.is_file():
+ repo_skill = candidate
+ break
+ if repo_skill and repo_skill.is_file():
+ skill_path = str(repo_skill)
+ elif package_skill.is_file():
+ skill_path = str(package_skill)
+ self.skill_path = skill_path
+ self.accent = _ACCENT_COLORS.get(self.software, _DEFAULT_ACCENT)
+
+ # History file
+ if history_file is None:
+ hist_dir = Path.home() / f".cli-anything-{self.software}"
+ hist_dir.mkdir(parents=True, exist_ok=True)
+ self.history_file = str(hist_dir / "history")
+ else:
+ self.history_file = history_file
+
+ # Detect terminal capabilities
+ self._color = self._detect_color_support()
+
+ def _detect_color_support(self) -> bool:
+ """Check if terminal supports color."""
+ if os.environ.get("NO_COLOR"):
+ return False
+ if os.environ.get("CLI_ANYTHING_NO_COLOR"):
+ return False
+ if not hasattr(sys.stdout, "isatty"):
+ return False
+ return sys.stdout.isatty()
+
+ def _c(self, code: str, text: str) -> str:
+ """Apply color code if colors are supported."""
+ if not self._color:
+ return text
+ return f"{code}{text}{_RESET}"
+
+ # โ”€โ”€ Banner โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def print_banner(self):
+ """Print the startup banner with branding."""
+ import textwrap
+
+ inner = 72
+
+ def _box_line(content: str) -> str:
+ """Wrap content in box drawing, padding to inner width."""
+ pad = inner - _visible_len(content)
+ vl = self._c(_DARK_GRAY, _V_LINE)
+ return f"{vl}{content}{' ' * max(0, pad)}{vl}"
+
+ def _meta_lines(label: str, value: str) -> list[str]:
+ """Wrap a metadata line for the banner box."""
+ icon = self._c(_MAGENTA, "โ—‡")
+ label_text = self._c(_DARK_GRAY, label)
+ prefix = f" {icon} {label_text} "
+ available = max(12, inner - _visible_len(prefix))
+ wrapped = textwrap.wrap(
+ value,
+ width=available,
+ break_long_words=True,
+ break_on_hyphens=False,
+ ) or [""]
+ lines = [f"{prefix}{self._c(_LIGHT_GRAY, wrapped[0])}"]
+ continuation_prefix = " " * _visible_len(prefix)
+ for chunk in wrapped[1:]:
+ lines.append(f"{continuation_prefix}{self._c(_LIGHT_GRAY, chunk)}")
+ return lines
+
+ top = self._c(_DARK_GRAY, f"{_TL}{_H_LINE * inner}{_TR}")
+ bot = self._c(_DARK_GRAY, f"{_BL}{_H_LINE * inner}{_BR}")
+
+ # Title: โ—† cli-anything ยท Shotcut
+ icon = self._c(_CYAN + _BOLD, "โ—†")
+ brand = self._c(_CYAN + _BOLD, "cli-anything")
+ dot = self._c(_DARK_GRAY, "ยท")
+ name = self._c(self.accent + _BOLD, self.display_name)
+ title = f" {icon} {brand} {dot} {name}"
+
+ ver = f" {self._c(_DARK_GRAY, f' v{self.version}')}"
+ tip = f" {self._c(_DARK_GRAY, ' Type help for commands, quit to exit')}"
+ empty = ""
+
+ meta_lines: list[str] = []
+ meta_lines.extend(_meta_lines("Install:", self.skill_install_cmd))
+ meta_lines.extend(_meta_lines("Global skill:", _display_home_path(self.global_skill_path)))
+ print(top)
+ print(_box_line(title))
+ print(_box_line(ver))
+ for line in meta_lines:
+ print(_box_line(line))
+ print(_box_line(empty))
+ print(_box_line(tip))
+ print(bot)
+ print()
+
+ # โ”€โ”€ Prompt โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def prompt(self, project_name: str = "", modified: bool = False,
+ context: str = "") -> str:
+ """Build a styled prompt string for prompt_toolkit or input().
+
+ Args:
+ project_name: Current project name (empty if none open).
+ modified: Whether the project has unsaved changes.
+ context: Optional extra context to show in prompt.
+
+ Returns:
+ Formatted prompt string.
+ """
+ parts = []
+
+ # Icon
+ if self._color:
+ parts.append(f"{_CYAN}โ—†{_RESET} ")
+ else:
+ parts.append("> ")
+
+ # Software name
+ parts.append(self._c(self.accent + _BOLD, self.software))
+
+ # Project context
+ if project_name or context:
+ ctx = context or project_name
+ mod = "*" if modified else ""
+ parts.append(f" {self._c(_DARK_GRAY, '[')}")
+ parts.append(self._c(_LIGHT_GRAY, f"{ctx}{mod}"))
+ parts.append(self._c(_DARK_GRAY, ']'))
+
+ parts.append(self._c(_GRAY, " โฏ "))
+
+ return "".join(parts)
+
+ def prompt_tokens(self, project_name: str = "", modified: bool = False,
+ context: str = ""):
+ """Build prompt_toolkit formatted text tokens for the prompt.
+
+ Use with prompt_toolkit's FormattedText for proper ANSI handling.
+
+ Returns:
+ list of (style, text) tuples for prompt_toolkit.
+ """
+ accent_hex = _ANSI_256_TO_HEX.get(self.accent, "#5fafff")
+ tokens = []
+
+ tokens.append(("class:icon", "โ—† "))
+ tokens.append(("class:software", self.software))
+
+ if project_name or context:
+ ctx = context or project_name
+ mod = "*" if modified else ""
+ tokens.append(("class:bracket", " ["))
+ tokens.append(("class:context", f"{ctx}{mod}"))
+ tokens.append(("class:bracket", "]"))
+
+ tokens.append(("class:arrow", " โฏ "))
+
+ return tokens
+
+ def get_prompt_style(self):
+ """Get a prompt_toolkit Style object matching the skin.
+
+ Returns:
+ prompt_toolkit.styles.Style
+ """
+ try:
+ from prompt_toolkit.styles import Style
+ except ImportError:
+ return None
+
+ accent_hex = _ANSI_256_TO_HEX.get(self.accent, "#5fafff")
+
+ return Style.from_dict({
+ "icon": "#5fdfdf bold", # cyan brand color
+ "software": f"{accent_hex} bold",
+ "bracket": "#585858",
+ "context": "#bcbcbc",
+ "arrow": "#808080",
+ # Completion menu
+ "completion-menu.completion": "bg:#303030 #bcbcbc",
+ "completion-menu.completion.current": f"bg:{accent_hex} #000000",
+ "completion-menu.meta.completion": "bg:#303030 #808080",
+ "completion-menu.meta.completion.current": f"bg:{accent_hex} #000000",
+ # Auto-suggest
+ "auto-suggest": "#585858",
+ # Bottom toolbar
+ "bottom-toolbar": "bg:#1c1c1c #808080",
+ "bottom-toolbar.text": "#808080",
+ })
+
+ # โ”€โ”€ Messages โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def success(self, message: str):
+ """Print a success message with green checkmark."""
+ icon = self._c(_GREEN + _BOLD, "โœ“")
+ print(f" {icon} {self._c(_GREEN, message)}")
+
+ def error(self, message: str):
+ """Print an error message with red cross."""
+ icon = self._c(_RED + _BOLD, "โœ—")
+ print(f" {icon} {self._c(_RED, message)}", file=sys.stderr)
+
+ def warning(self, message: str):
+ """Print a warning message with yellow triangle."""
+ icon = self._c(_YELLOW + _BOLD, "โš ")
+ print(f" {icon} {self._c(_YELLOW, message)}")
+
+ def info(self, message: str):
+ """Print an info message with blue dot."""
+ icon = self._c(_BLUE, "โ—")
+ print(f" {icon} {self._c(_LIGHT_GRAY, message)}")
+
+ def hint(self, message: str):
+ """Print a subtle hint message."""
+ print(f" {self._c(_DARK_GRAY, message)}")
+
+ def section(self, title: str):
+ """Print a section header."""
+ print()
+ print(f" {self._c(self.accent + _BOLD, title)}")
+ print(f" {self._c(_DARK_GRAY, _H_LINE * len(title))}")
+
+ # โ”€โ”€ Status display โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def status(self, label: str, value: str):
+ """Print a key-value status line."""
+ lbl = self._c(_GRAY, f" {label}:")
+ val = self._c(_WHITE, f" {value}")
+ print(f"{lbl}{val}")
+
+ def status_block(self, items: dict[str, str], title: str = ""):
+ """Print a block of status key-value pairs.
+
+ Args:
+ items: Dict of label -> value pairs.
+ title: Optional title for the block.
+ """
+ if title:
+ self.section(title)
+
+ max_key = max(len(k) for k in items) if items else 0
+ for label, value in items.items():
+ lbl = self._c(_GRAY, f" {label:<{max_key}}")
+ val = self._c(_WHITE, f" {value}")
+ print(f"{lbl}{val}")
+
+ def progress(self, current: int, total: int, label: str = ""):
+ """Print a simple progress indicator.
+
+ Args:
+ current: Current step number.
+ total: Total number of steps.
+ label: Optional label for the progress.
+ """
+ pct = int(current / total * 100) if total > 0 else 0
+ bar_width = 20
+ filled = int(bar_width * current / total) if total > 0 else 0
+ bar = "โ–ˆ" * filled + "โ–‘" * (bar_width - filled)
+ text = f" {self._c(_CYAN, bar)} {self._c(_GRAY, f'{pct:3d}%')}"
+ if label:
+ text += f" {self._c(_LIGHT_GRAY, label)}"
+ print(text)
+
+ # โ”€โ”€ Table display โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def table(self, headers: list[str], rows: list[list[str]],
+ max_col_width: int = 40):
+ """Print a formatted table with box-drawing characters.
+
+ Args:
+ headers: Column header strings.
+ rows: List of rows, each a list of cell strings.
+ max_col_width: Maximum column width before truncation.
+ """
+ if not headers:
+ return
+
+ # Calculate column widths
+ col_widths = [min(len(h), max_col_width) for h in headers]
+ for row in rows:
+ for i, cell in enumerate(row):
+ if i < len(col_widths):
+ col_widths[i] = min(
+ max(col_widths[i], len(str(cell))), max_col_width
+ )
+
+ def pad(text: str, width: int) -> str:
+ t = str(text)[:width]
+ return t + " " * (width - len(t))
+
+ # Header
+ header_cells = [
+ self._c(_CYAN + _BOLD, pad(h, col_widths[i]))
+ for i, h in enumerate(headers)
+ ]
+ sep = self._c(_DARK_GRAY, f" {_V_LINE} ")
+ header_line = f" {sep.join(header_cells)}"
+ print(header_line)
+
+ # Separator
+ sep_parts = [self._c(_DARK_GRAY, _H_LINE * w) for w in col_widths]
+ sep_line = self._c(_DARK_GRAY, f" {'โ”€โ”€โ”€'.join([_H_LINE * w for w in col_widths])}")
+ print(sep_line)
+
+ # Rows
+ for row in rows:
+ cells = []
+ for i, cell in enumerate(row):
+ if i < len(col_widths):
+ cells.append(self._c(_LIGHT_GRAY, pad(str(cell), col_widths[i])))
+ row_sep = self._c(_DARK_GRAY, f" {_V_LINE} ")
+ print(f" {row_sep.join(cells)}")
+
+ # โ”€โ”€ Help display โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def help(self, commands: dict[str, str]):
+ """Print a formatted help listing.
+
+ Args:
+ commands: Dict of command -> description pairs.
+ """
+ self.section("Commands")
+ max_cmd = max(len(c) for c in commands) if commands else 0
+ for cmd, desc in commands.items():
+ cmd_styled = self._c(self.accent, f" {cmd:<{max_cmd}}")
+ desc_styled = self._c(_GRAY, f" {desc}")
+ print(f"{cmd_styled}{desc_styled}")
+ print()
+
+ # โ”€โ”€ Goodbye โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def print_goodbye(self):
+ """Print a styled goodbye message."""
+ print(f"\n {_ICON_SMALL} {self._c(_GRAY, 'Goodbye!')}\n")
+
+ # โ”€โ”€ Prompt toolkit session factory โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def create_prompt_session(self):
+ """Create a prompt_toolkit PromptSession with skin styling.
+
+ Returns:
+ A configured PromptSession, or None if prompt_toolkit unavailable.
+ """
+ try:
+ from prompt_toolkit import PromptSession
+ from prompt_toolkit.history import FileHistory
+ from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
+ from prompt_toolkit.formatted_text import FormattedText
+
+ style = self.get_prompt_style()
+
+ session = PromptSession(
+ history=FileHistory(self.history_file),
+ auto_suggest=AutoSuggestFromHistory(),
+ style=style,
+ enable_history_search=True,
+ )
+ return session
+ except ImportError:
+ return None
+
+ def get_input(self, pt_session, project_name: str = "",
+ modified: bool = False, context: str = "") -> str:
+ """Get input from user using prompt_toolkit or fallback.
+
+ Args:
+ pt_session: A prompt_toolkit PromptSession (or None).
+ project_name: Current project name.
+ modified: Whether project has unsaved changes.
+ context: Optional context string.
+
+ Returns:
+ User input string (stripped).
+ """
+ if pt_session is not None:
+ from prompt_toolkit.formatted_text import FormattedText
+ tokens = self.prompt_tokens(project_name, modified, context)
+ return pt_session.prompt(FormattedText(tokens)).strip()
+ else:
+ raw_prompt = self.prompt(project_name, modified, context)
+ return input(raw_prompt).strip()
+
+ # โ”€โ”€ Toolbar builder โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+ def bottom_toolbar(self, items: dict[str, str]):
+ """Create a bottom toolbar callback for prompt_toolkit.
+
+ Args:
+ items: Dict of label -> value pairs to show in toolbar.
+
+ Returns:
+ A callable that returns FormattedText for the toolbar.
+ """
+ def toolbar():
+ from prompt_toolkit.formatted_text import FormattedText
+ parts = []
+ for i, (k, v) in enumerate(items.items()):
+ if i > 0:
+ parts.append(("class:bottom-toolbar.text", " โ”‚ "))
+ parts.append(("class:bottom-toolbar.text", f" {k}: "))
+ parts.append(("class:bottom-toolbar", v))
+ return FormattedText(parts)
+ return toolbar
+
+
+# โ”€โ”€ ANSI 256-color to hex mapping (for prompt_toolkit styles) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
+
+_ANSI_256_TO_HEX = {
+ "\033[38;5;33m": "#0087ff", # audacity navy blue
+ "\033[38;5;35m": "#00af5f", # shotcut teal
+ "\033[38;5;39m": "#00afff", # inkscape bright blue
+ "\033[38;5;40m": "#00d700", # libreoffice green
+ "\033[38;5;55m": "#5f00af", # obs purple
+ "\033[38;5;69m": "#5f87ff", # kdenlive slate blue
+ "\033[38;5;75m": "#5fafff", # default sky blue
+ "\033[38;5;80m": "#5fd7d7", # brand cyan
+ "\033[38;5;208m": "#ff8700", # blender deep orange
+ "\033[38;5;214m": "#ffaf00", # gimp warm orange
+}
diff --git a/wavetone/agent-harness/cli_anything/wavetone/utils/wavetone_backend.py b/wavetone/agent-harness/cli_anything/wavetone/utils/wavetone_backend.py
new file mode 100644
index 000000000..d0fdbdea3
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/utils/wavetone_backend.py
@@ -0,0 +1,159 @@
+"""Backend wrapper for the real WaveTone 2.61 executable."""
+
+from __future__ import annotations
+
+import os
+import platform
+import subprocess
+import time
+from pathlib import Path
+from typing import Any
+
+from cli_anything.wavetone.core.project import SUPPORTED_AUDIO_EXTENSIONS, normalize_audio_path
+
+
+REQUIRED_DATA_FILES = [
+ "awlib.dll",
+ "bass.dll",
+ "bassflac.dll",
+ "basswma.dll",
+ "basswv.dll",
+ "bass_aac.dll",
+ "bass_alac.dll",
+ "bass_ape.dll",
+ "bass_tta.dll",
+ "asdecoder.exe",
+]
+
+
+def default_candidates() -> list[Path]:
+ candidates: list[Path] = []
+ env_exe = os.environ.get("WAVETONE_EXE")
+ if env_exe:
+ candidates.append(Path(env_exe))
+ env_home = os.environ.get("WAVETONE_HOME")
+ if env_home:
+ candidates.append(Path(env_home) / "wavetone.exe")
+ candidates.append(Path(env_home) / "WaveTone.exe")
+ home = Path.home()
+ candidates.extend(
+ [
+ home / "Desktop" / "wavetone2.6.1" / "wavetone.exe",
+ home / "Downloads" / "wavetone2.6.1" / "wavetone.exe",
+ Path("C:/Program Files/WaveTone/wavetone.exe"),
+ Path("C:/Program Files (x86)/WaveTone/wavetone.exe"),
+ ]
+ )
+ return candidates
+
+
+def find_wavetone(executable: str | Path | None = None) -> Path:
+ candidates = [Path(executable)] if executable else default_candidates()
+ checked: list[str] = []
+ for candidate in candidates:
+ path = candidate.expanduser()
+ checked.append(str(path))
+ if path.exists() and path.is_file():
+ return path.resolve()
+ raise FileNotFoundError(
+ "WaveTone executable not found. Set WAVETONE_EXE to wavetone.exe or "
+ "WAVETONE_HOME to the extracted WaveTone directory. Checked: "
+ + "; ".join(checked)
+ )
+
+
+def doctor(executable: str | Path | None = None) -> dict[str, Any]:
+ checks: list[dict[str, Any]] = []
+ try:
+ exe = find_wavetone(executable)
+ root = exe.parent
+ checks.append({"name": "wavetone executable", "ok": True, "path": str(exe)})
+ except FileNotFoundError as exc:
+ return {
+ "ready": False,
+ "platform": platform.system(),
+ "checks": [{"name": "wavetone executable", "ok": False, "error": str(exc)}],
+ }
+
+ data_dir = root / "data"
+ checks.append({"name": "data directory", "ok": data_dir.is_dir(), "path": str(data_dir)})
+ for filename in REQUIRED_DATA_FILES:
+ path = data_dir / filename
+ checks.append({"name": f"data/{filename}", "ok": path.exists(), "path": str(path)})
+ help_dir = root / "wthelp"
+ checks.append({"name": "help directory", "ok": help_dir.is_dir(), "path": str(help_dir)})
+ checks.append(
+ {
+ "name": "windows host",
+ "ok": platform.system().lower() == "windows",
+ "platform": platform.platform(),
+ }
+ )
+ return {
+ "ready": all(check["ok"] for check in checks),
+ "platform": platform.system(),
+ "root": str(root),
+ "checks": checks,
+ }
+
+
+def launch_wavetone(
+ audio_path: str | Path | None = None,
+ executable: str | Path | None = None,
+ wait_seconds: float = 0.0,
+ terminate: bool = False,
+) -> dict[str, Any]:
+ exe = find_wavetone(executable)
+ args = [str(exe)]
+ audio: Path | None = None
+ if audio_path:
+ audio = normalize_audio_path(audio_path)
+ args.append(str(audio))
+
+ process = subprocess.Popen(args, cwd=str(exe.parent))
+ if wait_seconds > 0:
+ time.sleep(wait_seconds)
+ running_after_wait = process.poll() is None
+ exit_code = process.poll()
+ terminated = False
+ if terminate and running_after_wait:
+ process.terminate()
+ try:
+ process.wait(timeout=3)
+ except subprocess.TimeoutExpired:
+ process.kill()
+ process.wait(timeout=3)
+ terminated = True
+ exit_code = process.returncode
+
+ return {
+ "backend": "wavetone.exe",
+ "executable": str(exe),
+ "cwd": str(exe.parent),
+ "pid": process.pid,
+ "args": args,
+ "audio_path": str(audio) if audio else None,
+ "running_after_wait": running_after_wait,
+ "terminated": terminated,
+ "exit_code": exit_code,
+ "note": "WaveTone analysis and export dialogs are GUI driven in version 2.61.",
+ }
+
+
+def supported_formats() -> dict[str, Any]:
+ return {
+ "extensions": sorted(SUPPORTED_AUDIO_EXTENSIONS),
+ "from_readme": [
+ "WAVE",
+ "AIFF",
+ "MP3",
+ "WMA",
+ "AAC",
+ "Vorbis",
+ "FLAC",
+ "WavPack",
+ "Monkey's Audio",
+ "ALAC",
+ "TTA",
+ ],
+ }
diff --git a/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py b/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py
new file mode 100644
index 000000000..9ca90f51f
--- /dev/null
+++ b/wavetone/agent-harness/cli_anything/wavetone/wavetone_cli.py
@@ -0,0 +1,339 @@
+"""Click CLI for WaveTone 2.61."""
+
+from __future__ import annotations
+
+import json
+import os
+import shlex
+from pathlib import Path
+from typing import Any
+
+import click
+
+from cli_anything.wavetone import __version__
+from cli_anything.wavetone.core.audio import probe_audio
+from cli_anything.wavetone.core.project import (
+ DEFAULT_ANALYSIS_SETTINGS,
+ add_label,
+ create_project,
+ load_project,
+ project_summary,
+ save_project,
+ set_tempo,
+ set_wfd_path,
+ update_analysis,
+)
+from cli_anything.wavetone.core.session import append_event, load_events
+from cli_anything.wavetone.utils import wavetone_backend
+from cli_anything.wavetone.utils.repl_skin import ReplSkin
+
+
+def emit(data: dict[str, Any], json_mode: bool) -> None:
+ if json_mode:
+ click.echo(json.dumps(data, indent=2, sort_keys=True))
+ return
+ for key, value in data.items():
+ if isinstance(value, (dict, list)):
+ click.echo(f"{key}: {json.dumps(value, sort_keys=True)}")
+ else:
+ click.echo(f"{key}: {value}")
+
+
+def ctx_json(ctx: click.Context) -> bool:
+ return bool(ctx.obj and ctx.obj.get("json"))
+
+
+def ctx_project(ctx: click.Context) -> Path | None:
+ value = ctx.obj.get("project") if ctx.obj else None
+ return Path(value).expanduser().resolve() if value else None
+
+
+def load_ctx_project(ctx: click.Context, explicit_path: str | Path | None = None) -> tuple[dict[str, Any], Path]:
+ path = Path(explicit_path).expanduser().resolve() if explicit_path else ctx_project(ctx)
+ if not path:
+ raise click.ClickException("Project path required. Use --project PATH or pass a project argument.")
+ return load_project(path), path
+
+
[email protected](invoke_without_command=True)
[email protected]("--project", "project_path", type=click.Path(dir_okay=False), help="WaveTone project JSON path.")
[email protected]("--json", "json_mode", is_flag=True, help="Emit machine-readable JSON.")
[email protected]_option(version=__version__, prog_name="cli-anything-wavetone")
+def cli(ctx: click.Context, project_path: str | None, json_mode: bool) -> None:
+ """Agent-native CLI harness for WaveTone 2.61."""
+ ctx.ensure_object(dict)
+ ctx.obj["project"] = project_path
+ ctx.obj["json"] = json_mode
+ if ctx.invoked_subcommand is None:
+ ctx.invoke(repl)
+
+
+def repl(ctx: click.Context) -> None:
+ """Start an interactive command loop."""
+ skin = ReplSkin("wavetone", version=__version__)
+ skin.print_banner()
+ skin.info("Type 'help' for commands, 'exit' to quit.")
+ prompt_session = skin.create_prompt_session()
+ while True:
+ try:
+ line = skin.get_input(prompt_session, project_name="wavetone", modified=False)
+ except (EOFError, KeyboardInterrupt):
+ break
+ line = line.strip()
+ if not line:
+ continue
+ if line in {"exit", "quit"}:
+ break
+ if line == "help":
+ click.echo(cli.get_help(ctx))
+ continue
+ try:
+ args = shlex.split(line, posix=(os.name != "nt"))
+ cli.main(args=args, prog_name="cli-anything-wavetone", standalone_mode=False, obj=ctx.obj)
+ except Exception as exc: # pragma: no cover
+ skin.error(str(exc))
+ skin.print_goodbye()
+
+
[email protected](name="project")
+def project_group() -> None:
+ """Create and edit WaveTone project manifests."""
+
+
+@project_group.command("new")
[email protected]("audio_path", type=click.Path(exists=True, dir_okay=False))
[email protected]("-o", "--output", "output_path", type=click.Path(dir_okay=False), required=True)
[email protected]("--name", help="Project name. Defaults to the audio file stem.")
+def project_new(ctx: click.Context, audio_path: str, output_path: str, name: str | None) -> None:
+ """Create a WaveTone project manifest for an audio file."""
+ try:
+ project = create_project(audio_path, name=name)
+ path = save_project(project, output_path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "project": project_summary(project)}, ctx_json(ctx))
+
+
+@project_group.command("info")
[email protected]("project_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def project_info(ctx: click.Context, project_path: str | None) -> None:
+ """Inspect a WaveTone project manifest."""
+ try:
+ project, path = load_ctx_project(ctx, project_path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "project": project_summary(project)}, ctx_json(ctx))
+
+
+@project_group.command("add-label")
[email protected]("--time", "time_seconds", type=float, required=True, help="Label time in seconds.")
[email protected]("--note", help="Optional label note.")
[email protected]("project_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def project_add_label(ctx: click.Context, name: str, time_seconds: float, note: str | None, project_path: str | None) -> None:
+ """Add a navigation label to the manifest."""
+ try:
+ project, path = load_ctx_project(ctx, project_path)
+ add_label(project, name=name, time_seconds=time_seconds, note=note)
+ save_project(project, path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "labels": project.get("labels", [])}, ctx_json(ctx))
+
+
+@project_group.command("set-tempo")
[email protected]("--bpm", type=float, required=True)
[email protected]("--first-bar", "first_bar_time_seconds", type=float, default=0.0, show_default=True)
[email protected]("--meter", default="4/4", show_default=True)
[email protected]("project_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def project_set_tempo(ctx: click.Context, bpm: float, first_bar_time_seconds: float, meter: str, project_path: str | None) -> None:
+ """Set the tempo plan WaveTone should use before chord or note work."""
+ try:
+ project, path = load_ctx_project(ctx, project_path)
+ set_tempo(project, bpm=bpm, first_bar_time_seconds=first_bar_time_seconds, meter=meter)
+ save_project(project, path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "tempo": project.get("tempo")}, ctx_json(ctx))
+
+
+@project_group.command("analysis")
[email protected]("--blocks-per-second", type=int)
[email protected]("--blocks-per-semitone", type=int)
[email protected]("--note-range")
[email protected]("--reference-frequency-hz", type=float)
[email protected]("--channel", type=click.Choice(["Stereo", "L-R", "L+R", "L", "R"]))
[email protected]("--fundamental/--no-fundamental", default=None)
[email protected]("--skip-dialog/--show-dialog", default=None)
[email protected]("project_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def project_analysis(
+ ctx: click.Context,
+ blocks_per_second: int | None,
+ blocks_per_semitone: int | None,
+ note_range: str | None,
+ reference_frequency_hz: float | None,
+ channel: str | None,
+ fundamental: bool | None,
+ skip_dialog: bool | None,
+ project_path: str | None,
+) -> None:
+ """Update intended WaveTone analysis settings."""
+ try:
+ project, path = load_ctx_project(ctx, project_path)
+ update_analysis(
+ project,
+ blocks_per_second=blocks_per_second,
+ blocks_per_semitone=blocks_per_semitone,
+ note_range=note_range,
+ reference_frequency_hz=reference_frequency_hz,
+ channel=channel,
+ analyze_fundamental_frequency=fundamental,
+ skip_analysis_dialog=skip_dialog,
+ )
+ save_project(project, path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "analysis": project.get("analysis")}, ctx_json(ctx))
+
+
+@project_group.command("attach-wfd")
[email protected]("wfd_path", type=click.Path(dir_okay=False))
[email protected]("project_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def project_attach_wfd(ctx: click.Context, wfd_path: str, project_path: str | None) -> None:
+ """Attach a WFD analysis file saved by WaveTone."""
+ try:
+ project, path = load_ctx_project(ctx, project_path)
+ set_wfd_path(project, wfd_path)
+ save_project(project, path)
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "project_path": str(path), "wfd_path": project.get("wfd_path")}, ctx_json(ctx))
+
+
[email protected](name="audio")
+def audio_group() -> None:
+ """Probe audio files before opening them in WaveTone."""
+
+
+@audio_group.command("probe")
[email protected]("audio_path", required=False, type=click.Path(exists=True, dir_okay=False))
+def audio_probe(ctx: click.Context, audio_path: str | None) -> None:
+ """Return duration, sample rate, channel, codec, and size metadata."""
+ try:
+ if audio_path:
+ target = audio_path
+ else:
+ project, _ = load_ctx_project(ctx)
+ target = project["audio"]["path"]
+ data = probe_audio(target)
+ except (OSError, ValueError, RuntimeError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "audio": data}, ctx_json(ctx))
+
+
[email protected](name="wavetone")
+def wavetone_group() -> None:
+ """Inspect and launch the real WaveTone executable."""
+
+
+@wavetone_group.command("doctor")
[email protected]("--exe", "executable", type=click.Path(dir_okay=False), help="Path to wavetone.exe.")
+def wavetone_doctor(ctx: click.Context, executable: str | None) -> None:
+ """Check whether WaveTone and its bundled decoder files are available."""
+ data = wavetone_backend.doctor(executable)
+ emit(data, ctx_json(ctx))
+ if not data.get("ready"):
+ raise click.exceptions.Exit(1)
+
+
+@wavetone_group.command("formats")
+def wavetone_formats(ctx: click.Context) -> None:
+ """List audio formats documented by WaveTone 2.61."""
+ emit({"ok": True, "formats": wavetone_backend.supported_formats()}, ctx_json(ctx))
+
+
+@wavetone_group.command("launch")
[email protected]("audio_path", required=False, type=click.Path(exists=True, dir_okay=False))
[email protected]("--exe", "executable", type=click.Path(dir_okay=False), help="Path to wavetone.exe.")
[email protected]("--wait", "wait_seconds", type=float, default=0.0, show_default=True)
[email protected]("--terminate", is_flag=True, help="Terminate after the wait period, useful for smoke tests.")
+def wavetone_launch(ctx: click.Context, audio_path: str | None, executable: str | None, wait_seconds: float, terminate: bool) -> None:
+ """Launch the real WaveTone GUI, optionally with an audio file."""
+ try:
+ target = audio_path
+ if not target:
+ project_path = ctx_project(ctx)
+ if project_path:
+ project = load_project(project_path)
+ target = project["audio"]["path"]
+ data = wavetone_backend.launch_wavetone(
+ audio_path=target,
+ executable=executable,
+ wait_seconds=wait_seconds,
+ terminate=terminate,
+ )
+ except (OSError, ValueError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "launch": data}, ctx_json(ctx))
+
+
[email protected](name="session")
+def session_group() -> None:
+ """Record lightweight CLI session events."""
+
+
+@session_group.command("record")
[email protected]("session_path", type=click.Path(dir_okay=False))
[email protected]("--payload", default="{}", help="JSON object payload.")
+def session_record(ctx: click.Context, session_path: str, event: str, payload: str) -> None:
+ """Append an event to a session log."""
+ try:
+ payload_data = json.loads(payload)
+ if not isinstance(payload_data, dict):
+ raise ValueError("Payload must be a JSON object")
+ record = append_event(session_path, event, payload_data)
+ except (OSError, ValueError, json.JSONDecodeError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "event": record}, ctx_json(ctx))
+
+
+@session_group.command("events")
[email protected]("session_path", type=click.Path(dir_okay=False))
+def session_events(ctx: click.Context, session_path: str) -> None:
+ """List session events."""
+ try:
+ events = load_events(session_path)
+ except (OSError, ValueError, json.JSONDecodeError) as exc:
+ raise click.ClickException(str(exc)) from exc
+ emit({"ok": True, "events": events}, ctx_json(ctx))
+
+
[email protected]("defaults")
+def defaults(ctx: click.Context) -> None:
+ """Show default WaveTone analysis settings used in new manifests."""
+ emit({"ok": True, "analysis_defaults": DEFAULT_ANALYSIS_SETTINGS}, ctx_json(ctx))
+
+
+def main() -> None:
+ cli(obj={})
+
+
+if __name__ == "__main__":
+ main()
diff --git a/wavetone/agent-harness/setup.py b/wavetone/agent-harness/setup.py
new file mode 100644
index 000000000..9c6047d9a
--- /dev/null
+++ b/wavetone/agent-harness/setup.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+"""Setup for cli-anything-wavetone."""
+
+from pathlib import Path
+
+from setuptools import find_namespace_packages, setup
+
+
+readme = Path(__file__).parent / "cli_anything" / "wavetone" / "README.md"
+
+setup(
+ name="cli-anything-wavetone",
+ version="1.0.0",
+ author="cli-anything contributors",
+ description=(
+ "Agent-native CLI harness for WaveTone 2.61. Creates structured audio "
+ "analysis manifests and launches the real WaveTone Windows executable."
+ ),
+ long_description=readme.read_text(encoding="utf-8") if readme.exists() else "",
+ long_description_content_type="text/markdown",
+ url="https://github.com/HKUDS/CLI-Anything",
+ packages=find_namespace_packages(include=["cli_anything.*"]),
+ classifiers=[
+ "Development Status :: 4 - Beta",
+ "Intended Audience :: Developers",
+ "Topic :: Multimedia :: Sound/Audio :: Analysis",
+ "Topic :: Multimedia :: Sound/Audio :: Editors",
+ "License :: OSI Approved :: MIT License",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
+ "Operating System :: Microsoft :: Windows",
+ ],
+ python_requires=">=3.10",
+ install_requires=["click>=8.0.0", "prompt-toolkit>=3.0.0"],
+ extras_require={"dev": ["pytest>=7.0.0"]},
+ entry_points={
+ "console_scripts": [
+ "cli-anything-wavetone=cli_anything.wavetone.wavetone_cli:main",
+ ],
+ },
+ package_data={"cli_anything.wavetone": ["skills/*.md"]},
+ include_package_data=True,
+ zip_safe=False,
+)