mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-05 02:31:47 +00:00
fix(cli): CLI/TUI on local backend always uses launch directory, ignores terminal.cwd (#19242)
CLI/TUI sessions on the local backend now unconditionally use os.getcwd() as the working directory. The terminal.cwd config value is only consumed by gateway/cron/delegation modes (where there's no shell to cd from). Previously, 'hermes setup' would write an absolute path (e.g. $HOME) into terminal.cwd which then pinned the CLI to that directory regardless of where the user launched hermes from. This was a silent foot-gun — the user's 'cd' was being ignored. Changes: 1. cli.py: Restructured CWD resolution — if TERMINAL_CWD is not already set by the gateway, and the backend is local, always use os.getcwd(). Config terminal.cwd is irrelevant for interactive CLI/TUI sessions. 2. setup.py: Moved the cwd prompt from setup_terminal_backend() to setup_gateway(). It now only appears when configuring messaging platforms and is labeled 'Gateway working directory'. 3. Tests: Rewrote test_cwd_env_respect.py to validate the new behavior: explicit config paths are ignored for CLI, gateway pre-set values are preserved, non-local backends keep their config paths. 4. Docs: Updated configuration.md, profiles.md, and environment-variables.md to clarify that terminal.cwd only affects gateway/cron mode on local backend. Closes #19214
This commit is contained in:
parent
b8ae8cc801
commit
9eaddfafa3
6 changed files with 122 additions and 72 deletions
|
|
@ -1327,18 +1327,7 @@ def setup_terminal_backend(config: dict):
|
|||
if selected_backend == "local":
|
||||
print_success("Terminal backend: Local")
|
||||
print_info("Commands run directly on this machine.")
|
||||
|
||||
# CWD for messaging
|
||||
print()
|
||||
print_info("Working directory for messaging sessions:")
|
||||
print_info(" When using Hermes via Telegram/Discord, this is where")
|
||||
print_info(
|
||||
" the agent starts. CLI mode always starts in the current directory."
|
||||
)
|
||||
current_cwd = cfg_get(config, "terminal", "cwd", default="")
|
||||
cwd = prompt(" Messaging working directory", current_cwd or str(Path.home()))
|
||||
if cwd:
|
||||
config["terminal"]["cwd"] = cwd
|
||||
print_info(" CLI/TUI always uses your launch directory (wherever you run 'hermes').")
|
||||
|
||||
# Sudo support
|
||||
print()
|
||||
|
|
@ -2390,6 +2379,20 @@ def setup_gateway(config: dict):
|
|||
print_info("━" * 50)
|
||||
print_success("Messaging platforms configured!")
|
||||
|
||||
# Gateway working directory — where the agent starts when you chat
|
||||
# via Telegram/Discord/etc. CLI/TUI ignores this (uses launch dir).
|
||||
print()
|
||||
print_info("Gateway working directory:")
|
||||
print_info(" When using Hermes via messaging platforms, this is where")
|
||||
print_info(" the agent's terminal commands start.")
|
||||
print_info(" (CLI/TUI always uses wherever you launched 'hermes' from.)")
|
||||
current_cwd = cfg_get(config, "terminal", "cwd", default="")
|
||||
if current_cwd in (".", "auto", "cwd", ""):
|
||||
current_cwd = ""
|
||||
cwd = prompt(" Gateway working directory", current_cwd or str(Path.home()))
|
||||
if cwd:
|
||||
config.setdefault("terminal", {})["cwd"] = cwd
|
||||
|
||||
# Check if any home channels are missing
|
||||
missing_home = []
|
||||
if get_env_value("TELEGRAM_BOT_TOKEN") and not get_env_value(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue