mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-01 12:02:05 +00:00
refactor(windows): unify windowless spawn form across the touched sites
windows_hide_flags() already returns 0 on POSIX (and creationflags=0 is the no-op default there, exactly how server.py::_list_repo_files does it), so drop the IS_WINDOWS import + ternary/one-use-dict gating and just pass creationflags=windows_hide_flags() directly. Tests lose the now-pointless IS_WINDOWS monkeypatch.
This commit is contained in:
parent
ee22d853eb
commit
cb1bb1a48d
3 changed files with 9 additions and 11 deletions
|
|
@ -309,7 +309,6 @@ def test_checkpoint_manager_git_hides_windows(monkeypatch):
|
|||
captured.append((cmd, kwargs))
|
||||
return _Completed(stdout="clean\n")
|
||||
|
||||
monkeypatch.setattr(checkpoint_manager, "IS_WINDOWS", True)
|
||||
monkeypatch.setattr(checkpoint_manager, "windows_hide_flags", lambda: _CREATE_NO_WINDOW)
|
||||
monkeypatch.setattr(checkpoint_manager.subprocess, "run", fake_run)
|
||||
|
||||
|
|
@ -328,7 +327,6 @@ def test_skills_hub_gh_token_hides_windows(monkeypatch):
|
|||
captured.append((cmd, kwargs))
|
||||
return _Completed(stdout="gho_from_cli\n")
|
||||
|
||||
monkeypatch.setattr(skills_hub, "IS_WINDOWS", True)
|
||||
monkeypatch.setattr(skills_hub, "windows_hide_flags", lambda: _CREATE_NO_WINDOW)
|
||||
monkeypatch.setattr(skills_hub.subprocess, "run", fake_run)
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import subprocess
|
|||
import time
|
||||
from pathlib import Path
|
||||
from hermes_constants import get_hermes_home
|
||||
from hermes_cli._subprocess_compat import IS_WINDOWS, windows_hide_flags
|
||||
from hermes_cli._subprocess_compat import windows_hide_flags
|
||||
from typing import Dict, List, Optional, Set, Tuple
|
||||
|
||||
from utils import env_int
|
||||
|
|
@ -322,10 +322,7 @@ def _run_git(
|
|||
env = _git_env(store, str(normalized_working_dir), index_file=index_file)
|
||||
cmd = ["git"] + list(args)
|
||||
allowed_returncodes = allowed_returncodes or set()
|
||||
# Checkpoints run inside the console-less desktop/gateway backend; a bare
|
||||
# git spawn there pops a fresh conhost window per call (status, add,
|
||||
# commit, …) on Windows. No-op on POSIX.
|
||||
_popen_kwargs = {"creationflags": windows_hide_flags()} if IS_WINDOWS else {}
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
|
|
@ -335,7 +332,10 @@ def _run_git(
|
|||
env=env,
|
||||
cwd=str(normalized_working_dir),
|
||||
stdin=subprocess.DEVNULL,
|
||||
**_popen_kwargs,
|
||||
# Checkpoints fire several bare git calls per turn from the
|
||||
# console-less desktop/gateway backend; suppress the per-call
|
||||
# conhost flash on Windows (no-op on POSIX).
|
||||
creationflags=windows_hide_flags(),
|
||||
)
|
||||
ok = result.returncode == 0
|
||||
stdout = result.stdout.strip()
|
||||
|
|
@ -456,7 +456,7 @@ def _init_store(store: Path, working_dir: str) -> Optional[str]:
|
|||
capture_output=True, text=True,
|
||||
env=init_env, timeout=_GIT_TIMEOUT,
|
||||
stdin=subprocess.DEVNULL,
|
||||
**({"creationflags": windows_hide_flags()} if IS_WINDOWS else {}),
|
||||
creationflags=windows_hide_flags(),
|
||||
)
|
||||
if result.returncode != 0:
|
||||
return f"Shadow store init failed: {result.stderr.strip()}"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ from dataclasses import dataclass, field
|
|||
from datetime import datetime, timezone
|
||||
from pathlib import Path, PurePosixPath
|
||||
from hermes_constants import get_hermes_home
|
||||
from hermes_cli._subprocess_compat import IS_WINDOWS, windows_hide_flags
|
||||
from hermes_cli._subprocess_compat import windows_hide_flags
|
||||
from agent.skill_utils import is_excluded_skill_path
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
from urllib.parse import urljoin, urlparse, urlunparse
|
||||
|
|
@ -303,7 +303,7 @@ class GitHubAuth:
|
|||
["gh", "auth", "token"],
|
||||
capture_output=True, text=True, timeout=5,
|
||||
stdin=subprocess.DEVNULL,
|
||||
**({"creationflags": windows_hide_flags()} if IS_WINDOWS else {}),
|
||||
creationflags=windows_hide_flags(),
|
||||
)
|
||||
if result.returncode == 0 and result.stdout.strip():
|
||||
return result.stdout.strip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue