Replace OpenCode harness with Hermes, remove workspace dependency, and move vocabulary/corrections to app folder
This commit is contained in:
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CLI helper to list, get, and set AI models for VoiceAgent."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add VoiceAgent1 project root to sys.path
|
||||
project_root = Path("/Users/adolforeyna/Projects/VoiceAgent1")
|
||||
if str(project_root) not in sys.path:
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from model_manager import ModelManager
|
||||
|
||||
def main():
|
||||
app_dir = Path(__file__).resolve().parent.parent
|
||||
mm = ModelManager(app_dir)
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] in ("list", "ls", "--list"):
|
||||
print(mm.list_available_models())
|
||||
return
|
||||
|
||||
if sys.argv[1] in ("get", "current", "show"):
|
||||
print(f"Active Model: {mm._active_model}")
|
||||
return
|
||||
|
||||
action = sys.argv[1]
|
||||
if action in ("set", "change") and len(sys.argv) >= 3:
|
||||
target_model = sys.argv[2]
|
||||
ok, msg = mm.apply_model(target_model)
|
||||
print(msg)
|
||||
else:
|
||||
# Treat single argument as target model
|
||||
target_model = sys.argv[1]
|
||||
ok, msg = mm.apply_model(target_model)
|
||||
print(msg)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+2
-2
@@ -12,8 +12,8 @@ if str(project_root) not in sys.path:
|
||||
from voice_manager import KOKORO_VOICES, MACOS_VOICES, VoiceManager
|
||||
|
||||
def main():
|
||||
workspace = Path.home() / "Workspace"
|
||||
vm = VoiceManager(workspace)
|
||||
app_dir = Path(__file__).resolve().parent.parent
|
||||
vm = VoiceManager(app_dir)
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] in ("list", "ls", "--list"):
|
||||
print("Available Voices:\n")
|
||||
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CLI tool for VoiceAgent to interact with the Companion Web UI and Browser.
|
||||
|
||||
Commands:
|
||||
python bin/web_tool.py open [url] - Open a URL (or http://localhost:8888) in macOS default browser
|
||||
python bin/web_tool.py show <filepath> - Display a workspace file visually in the Web UI drawer
|
||||
python bin/web_tool.py launch - Launch the Companion Web UI in default browser
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib.request
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_WEB_URL = "http://localhost:8888"
|
||||
|
||||
|
||||
def open_browser(url: str = DEFAULT_WEB_URL):
|
||||
if not url.startswith("http://") and not url.startswith("https://"):
|
||||
url = "http://" + url
|
||||
try:
|
||||
os.system(f'open "{url}"')
|
||||
print(f"Opened {url} in default browser.")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Could not open browser: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def show_file_in_web_ui(filepath: str, web_url: str = DEFAULT_WEB_URL):
|
||||
try:
|
||||
req_url = f"{web_url}/api/show_file"
|
||||
data = json.dumps({"path": filepath}).encode("utf-8")
|
||||
req = urllib.request.Request(req_url, data=data, headers={"Content-Type": "application/json"})
|
||||
with urllib.request.urlopen(req, timeout=3.0) as resp:
|
||||
if resp.status == 200:
|
||||
print(f"File '{filepath}' sent to Web UI drawer.")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Could not notify Web UI server: {e}")
|
||||
|
||||
# Fall back to opening file directly
|
||||
abs_path = Path(filepath).expanduser().resolve()
|
||||
if abs_path.exists():
|
||||
os.system(f'open "{abs_path}"')
|
||||
print(f"Opened {abs_path} locally.")
|
||||
return True
|
||||
print(f"File not found: {filepath}")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
open_browser(DEFAULT_WEB_URL)
|
||||
return
|
||||
|
||||
cmd = sys.argv[1].lower()
|
||||
|
||||
if cmd in ("open", "browser", "launch"):
|
||||
target_url = sys.argv[2] if len(sys.argv) >= 3 else DEFAULT_WEB_URL
|
||||
open_browser(target_url)
|
||||
|
||||
elif cmd in ("show", "refer", "file", "view"):
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: python bin/web_tool.py show <filepath>")
|
||||
sys.exit(1)
|
||||
filepath = sys.argv[2]
|
||||
show_file_in_web_ui(filepath)
|
||||
|
||||
else:
|
||||
# Treat single argument as URL or Filepath
|
||||
arg = sys.argv[1]
|
||||
if arg.startswith("http://") or arg.startswith("https://") or "localhost" in arg:
|
||||
open_browser(arg)
|
||||
else:
|
||||
show_file_in_web_ui(arg)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user