The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(hermes_cli): AST-neutral bracket hug/pack in desktop/dashboard/web_build/tui_launch
Tekniumc9690e564a87
diff --git a/hermes_cli/main_dashboard.py b/hermes_cli/main_dashboard.pyindex 923784dc3df..eebc2103259 100644--- a/hermes_cli/main_dashboard.py+++ b/hermes_cli/main_dashboard.py@@ -70,10 +70,7 @@ _SYSTEMCTL_ERRORS = (FileNotFoundError, subprocess.TimeoutExpired, OSError)def _run_probe(cmd: list[str], *, timeout: int) -> subprocess.CompletedProcess:"""Captured, text-decoded ``subprocess.run`` for short local probes (systemctl, ps)."""return subprocess.run(- cmd,- capture_output=True,- text=True, encoding="utf-8", errors="replace",- timeout=timeout,+ cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=timeout)@@ -276,12 +273,8 @@ def _respawn_dashboard_processes(commands: list[list[str]]) -> list[list[str]]:command = [*command, "--no-open"]with open(log_path, "ab") as log_f:subprocess.Popen(- command,- stdin=subprocess.DEVNULL,- stdout=log_f,- stderr=subprocess.STDOUT,- start_new_session=True,- close_fds=True,+ command, stdin=subprocess.DEVNULL, stdout=log_f, stderr=subprocess.STDOUT,+ start_new_session=True, close_fds=True,)respawned.append(command)except (OSError, ValueError) as exc:@@ -367,10 +360,7 @@ def _install_hangup_protection(gateway_mode: bool = False):``_finalize_update_output`` consumes on exit."""state = {- "prev_stdout": sys.stdout,- "prev_stderr": sys.stderr,- "log_file": None,- "installed": False,+ "prev_stdout": sys.stdout, "prev_stderr": sys.stderr, "log_file": None, "installed": False}if gateway_mode:diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.pyindex b271e74e2fa..4d815844a5e 100644--- a/hermes_cli/main_desktop.py+++ b/hermes_cli/main_desktop.py@@ -815,10 +815,7 @@ def _desktop_macos_local_codesign(app: Path, *, desktop_dir: Path, identity: strraise FileNotFoundError(f"desktop entitlement plists missing under {desktop_dir / 'electron'}")def sign_path(- path: Path,- *,- entitlements: Optional[Path] = None,- identifier: Optional[str] = None,+ path: Path, *, entitlements: Optional[Path] = None, identifier: Optional[str] = None,runtime: bool = True,) -> None:args = [codesign, "--force", "--sign", identity, "--timestamp=none"]@@ -899,9 +896,7 @@ def _macos_legacy_adhoc_resign(codesign: str, app: Path) -> bool:def _desktop_macos_relaunchable_fixup(- desktop_dir: Path,- *,- publisher_signing_configured: Optional[bool] = None,+ desktop_dir: Path, *, publisher_signing_configured: Optional[bool] = None,release_dir: Optional[Path] = None,) -> bool:"""Make a locally-built macOS app survive in-place self-update without resetting TCC grants.diff --git a/hermes_cli/main_tui_launch.py b/hermes_cli/main_tui_launch.pyindex 1b931adcfe3..3be5c853d7f 100644--- a/hermes_cli/main_tui_launch.py+++ b/hermes_cli/main_tui_launch.py@@ -410,11 +410,8 @@ def _restore_tui_workspace(tui_dir: Path) -> bool:return Falsetry:subprocess.run(- [git, "restore", "--", tui_dir.name],- cwd=str(tui_dir.parent),- capture_output=True,- text=True, encoding="utf-8", errors="replace",- check=False,+ [git, "restore", "--", tui_dir.name], cwd=str(tui_dir.parent), capture_output=True,+ text=True, encoding="utf-8", errors="replace", check=False,)except OSError:return False@@ -501,13 +498,8 @@ def _exit_on_npm_failure(result: subprocess.CompletedProcess, message: str, *, sdef _run_tui_npm_build(npm: str, cwd: Path, failure_message: str) -> None:"""``npm run build`` in *cwd*; exit with *failure_message* + output tail on failure."""result = subprocess.run(- [npm, "run", "build"],- cwd=str(cwd),- capture_output=True,- text=True,- encoding="utf-8",- errors="replace",- env=_npm_lifecycle_env(),+ [npm, "run", "build"], cwd=str(cwd), capture_output=True, text=True, encoding="utf-8",+ errors="replace", env=_npm_lifecycle_env(),)_exit_on_npm_failure(result, failure_message, sep="")@@ -539,13 +531,8 @@ def _install_tui_dependencies(tui_dir: Path, *, termux_startup: bool) -> None:# Managed tree first on PATH: if the EBADENGINE repair provisioned a# managed Node, npm's shebang/lifecycle scripts must resolve that node.return subprocess.run(- npm_install_cmd,- cwd=str(npm_cwd),- stdout=subprocess.PIPE,- stderr=subprocess.PIPE,- text=True,- encoding="utf-8",- errors="replace",+ npm_install_cmd, cwd=str(npm_cwd), stdout=subprocess.PIPE, stderr=subprocess.PIPE,+ text=True, encoding="utf-8", errors="replace",env=_npm_lifecycle_env(with_hermes_node_path()),)@@ -763,21 +750,11 @@ def _setup_tui_worktree() -> dict:def _launch_tui(- resume_session_id: Optional[str] = None,- tui_dev: bool = False,- model: Optional[str] = None,- provider: Optional[str] = None,- toolsets: object = None,- skills: object = None,- verbose: Optional[bool] = None,- quiet: bool = False,- query: Optional[str] = None,- image: Optional[str] = None,- worktree: bool = False,- checkpoints: bool = False,- pass_session_id: bool = False,- max_turns: Optional[int] = None,- accept_hooks: bool = False,+ resume_session_id: Optional[str] = None, tui_dev: bool = False, model: Optional[str] = None,+ provider: Optional[str] = None, toolsets: object = None, skills: object = None,+ verbose: Optional[bool] = None, quiet: bool = False, query: Optional[str] = None,+ image: Optional[str] = None, worktree: bool = False, checkpoints: bool = False,+ pass_session_id: bool = False, max_turns: Optional[int] = None, accept_hooks: bool = False,):"""Replace current process with the TUI."""from hermes_cli.main import PROJECT_ROOT, _apply_tui_python_env, _make_tui_argv, _resolve_tui_heap_mb@@ -821,8 +798,7 @@ def _launch_tui(if value:env["HERMES_TUI_SKILLS"] = valuefor key, value in (- ("HERMES_TUI_QUERY", query),- ("HERMES_TUI_IMAGE", image),+ ("HERMES_TUI_QUERY", query), ("HERMES_TUI_IMAGE", image),("HERMES_TUI_CHECKPOINTS", "1" if checkpoints else None),("HERMES_TUI_PASS_SESSION_ID", "1" if pass_session_id else None),("HERMES_TUI_MAX_TURNS", str(max_turns) if max_turns is not None else None),diff --git a/hermes_cli/main_web_build.py b/hermes_cli/main_web_build.pyindex f74dc636cd5..027599a89fb 100644--- a/hermes_cli/main_web_build.py+++ b/hermes_cli/main_web_build.py@@ -20,9 +20,7 @@ import time as _timefrom pathlib import Pathfrom typing import Callablefrom hermes_cli.main_tui_launch import (- _npm_lifecycle_env,- _termux_workspace_install_context,- _workspace_root,+ _npm_lifecycle_env, _termux_workspace_install_context, _workspace_root)# Log-record parity with the origin module.@@ -217,11 +215,7 @@ def _console_print(text: str) -> None:def _run_with_idle_timeout(- cmd: list[str],- cwd: Path,- *,- idle_timeout_seconds: int = 180,- indent: str = " ",+ cmd: list[str], cwd: Path, *, idle_timeout_seconds: int = 180, indent: str = " ",env: dict[str, str] | None = None,) -> subprocess.CompletedProcess:"""Run a subprocess that streams output, killing it after *idle_timeout_seconds* of silence.@@ -328,11 +322,7 @@ def _nixos_build_env() -> dict[str, str] | None:def _run_npm_install_deterministic(- npm: str,- cwd: Path,- *,- extra_args: tuple[str, ...] = (),- capture_output: bool = True,+ npm: str, cwd: Path, *, extra_args: tuple[str, ...] = (), capture_output: bool = True,env: dict[str, str] | None = None,) -> subprocess.CompletedProcess:"""Deterministic npm install that never mutates ``package-lock.json``.@@ -378,11 +368,7 @@ def _run_npm_install_deterministic(def _run_npm_watching_for_engine_failure(- cmd: list[str],- *,- cwd: Path,- env: dict[str, str],- capture_output: bool,+ cmd: list[str], *, cwd: Path, env: dict[str, str], capture_output: bool) -> subprocess.CompletedProcess:"""Run *cmd*, always retaining stderr so ``EBADENGINE`` stays detectable.