test(system_prompt): cover surface-aware context-file cwd contract

Updates TestContextFileCwd for the #64590 rework: the CLI now receives its
launch dir explicitly (previously None), daemon surfaces receive None, and
a configured TERMINAL_CWD wins on every surface.
This commit is contained in:
Teknium 2026-07-16 02:32:34 -07:00
parent e7d6840989
commit e89d56e48d
No known key found for this signature in database

View file

@ -46,15 +46,29 @@ def _captured_context_cwd(agent):
class TestContextFileCwd:
def test_none_when_terminal_cwd_unset(self, monkeypatch):
# Unset → None, so discovery falls back to the launch dir inside
# build_context_files_prompt (the local-CLI #19242 contract).
def test_cli_launch_dir_when_terminal_cwd_unset(self, monkeypatch, tmp_path):
# Unset → the interactive CLI (empty/None platform defaults to it)
# promotes its launch dir to an explicit choice, so discovery loads
# context files from it even inside the Hermes checkout (#64590).
monkeypatch.delenv("TERMINAL_CWD", raising=False)
assert _captured_context_cwd(_make_agent()) is None
monkeypatch.chdir(tmp_path)
assert _captured_context_cwd(_make_agent()) == str(tmp_path)
def test_daemon_none_when_terminal_cwd_unset(self, monkeypatch, tmp_path):
# Daemon surfaces pass None so build_context_files_prompt's
# install-tree fallback guard applies — their process cwd is an
# accident of spawning, not a user choice (#64590).
monkeypatch.delenv("TERMINAL_CWD", raising=False)
monkeypatch.chdir(tmp_path)
assert _captured_context_cwd(_make_agent(platform="tui")) is None
def test_configured_dir_when_terminal_cwd_set(self, monkeypatch, tmp_path):
monkeypatch.setenv("TERMINAL_CWD", str(tmp_path))
assert _captured_context_cwd(_make_agent()) == tmp_path
assert _captured_context_cwd(_make_agent()) == str(tmp_path)
def test_configured_dir_wins_on_daemon_surface(self, monkeypatch, tmp_path):
monkeypatch.setenv("TERMINAL_CWD", str(tmp_path))
assert _captured_context_cwd(_make_agent(platform="telegram")) == str(tmp_path)
def _stable_prompt(agent):