The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
install.ps1: emit the -Json failure frame when Fail ends a stage
ethernet3c53fbdc8bd7
diff --git a/scripts/install.ps1 b/scripts/install.ps1index 420e41fc3e5..24baec11b0d 100644--- a/scripts/install.ps1+++ b/scripts/install.ps1@@ -468,7 +468,13 @@ function Ensure-Git {}function Log([string]$msg) { Write-Host "[hermes] $msg" -ForegroundColor Blue }-function Fail([string]$msg) { Write-Host "[hermes] $msg" -ForegroundColor Red; exit 1 }+function Fail([string]$msg) {+ Write-Host "[hermes] $msg" -ForegroundColor Red+ # `exit` unwinds past the stage dispatcher's try/catch, so a -Json caller+ # would otherwise get NO frame at all; emit the failure frame here.+ if ($Json -and $Stage) { Emit-Frame $false $Stage $false $msg }+ exit 1+}function Emit-Frame([bool]$ok, [string]$name, [bool]$skipped, [string]$reason = "") {$frame = [ordered]@{ ok = $ok; stage = $name; skipped = $skipped }diff --git a/tests/scripts/install/test_install_ps1_json_failure_frame.py b/tests/scripts/install/test_install_ps1_json_failure_frame.pynew file mode 100644index 00000000000..c890bed3a23--- /dev/null+++ b/tests/scripts/install/test_install_ps1_json_failure_frame.py@@ -0,0 +1,28 @@+"""A fatal stage under -Stage -Json yields exactly one failure frame carrying the reason."""+import json+import os+from pathlib import Path+import shutil+import subprocess++import pytest++pytestmark = pytest.mark.platforms("windows")+INSTALLER = Path(__file__).resolve().parents[3] / "scripts" / "install.ps1"+++def test_fail_inside_a_stage_emits_one_json_frame_with_the_reason(tmp_path):+ powershell = shutil.which("powershell")+ assert powershell+ # A clone from a path that does not exist makes the repository stage hit+ # the installer's own Fail helper (not a thrown exception).+ env = dict(os.environ, HERMES_REPO_URL=str(tmp_path / "no-such-repo"),+ HERMES_INSTALL_DIR=str(tmp_path / "install"), HERMES_HOME=str(tmp_path / "home"))+ result = subprocess.run(+ [powershell, "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", str(INSTALLER), "-Stage", "repository", "-Json"],+ env=env, capture_output=True, text=True, timeout=120)+ frames = [json.loads(line) for line in result.stdout.splitlines() if line.startswith("{")]+ assert result.returncode == 1+ assert len(frames) == 1, result.stdout+ assert frames[0]["ok"] is False and frames[0]["stage"] == "repository"+ assert "git clone failed" in frames[0]["reason"]