The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(files): treat a placeholder terminal.cwd as unset
emozilla20ea355f5861
diff --git a/hermes_cli/web_routers/files.py b/hermes_cli/web_routers/files.pyindex 97cfff4b616..cff600c4992 100644--- a/hermes_cli/web_routers/files.py+++ b/hermes_cli/web_routers/files.py@@ -244,8 +244,11 @@ def _fs_find_git_root(start: Path) -> str | None:def _fs_default_cwd() -> str:cfg_terminal = load_config().get("terminal") or {}- raw = str(cfg_terminal.get("cwd") or os.environ.get("TERMINAL_CWD") or "").strip()- if raw and raw not in {".", "auto", "cwd"}:+ # A placeholder terminal.cwd counts as unset, so TERMINAL_CWD names the folder.+ for raw in (cfg_terminal.get("cwd"), os.environ.get("TERMINAL_CWD")):+ raw = str(raw or "").strip()+ if raw in {"", ".", "auto", "cwd"}:+ continuetry:candidate = Path(raw).expanduser().resolve(strict=False)if candidate.is_dir():diff --git a/tests/hermes_cli/test_web_server_fs.py b/tests/hermes_cli/test_web_server_fs.pyindex 32eb088d34b..5aa60f8493c 100644--- a/tests/hermes_cli/test_web_server_fs.py+++ b/tests/hermes_cli/test_web_server_fs.py@@ -372,6 +372,19 @@ def test_fs_endpoints_require_auth(tmp_path):assert default_response.status_code == 401+def test_fs_default_cwd_leaves_a_placeholder_terminal_cwd_to_terminal_cwd(client, monkeypatch, tmp_path):+ """A placeholder terminal.cwd ("." is the default) counts as unset, so TERMINAL_CWD names the folder."""+ home = tmp_path / "home"+ home.mkdir()+ monkeypatch.setattr(file_routes, "load_config", lambda: {"terminal": {"cwd": "."}})+ monkeypatch.setenv("TERMINAL_CWD", str(home))++ response = client.get("/api/fs/default-cwd")++ assert response.status_code == 200+ assert response.json()["cwd"] == str(home.resolve())++def test_fs_read_text_decodes_double_encoded_non_ascii_path(client, tmp_path):target = tmp_path / "半导体行业运营分享会纪要.md"target.write_text("hello")