Skip to content

terminal.cwd config is a foot-gun: CLI/TUI should always use launch directory #19214

@alt-glitch

Description

@alt-glitch

Problem

terminal.cwd is a single config key that controls the working directory for all modes (CLI, TUI, gateway, cron, delegation). This creates a silent foot-gun where running hermes setup terminal (or full setup) permanently pins the CLI to $HOME even though the user launched hermes from a project directory.

How users hit this

  1. Run hermes setup → choose "Full setup" (or hermes setup terminal)
  2. See this prompt:
    Working directory for messaging sessions:
      When using Hermes via Telegram/Discord, this is where
      the agent starts. CLI mode always starts in the current directory.
    
    Messaging working directory [/home/user]: 
    
  3. Hit Enter (accepting the default $HOME)
  4. Config now has terminal.cwd: /home/user
  5. Later: cd ~/my-project && hermes → agent runs pwd/home/user 🤔

The help text even says "CLI mode always starts in the current directory" — but then writes a value that prevents exactly that.

Root cause

The resolution logic in cli.py (lines 473-487) only uses os.getcwd() when terminal.cwd is a placeholder (".", "auto", "cwd"). Once setup writes an absolute path, it is used verbatim for CLI, TUI, gateway — everything.

_CWD_PLACEHOLDERS = (".", "auto", "cwd")
if terminal_config.get("cwd") in _CWD_PLACEHOLDERS:
    # Smart: resolves to os.getcwd() for local backend
else:
    # Dumb: uses the hardcoded path for ALL modes

Why this exists

The gateway runs as a systemd service where os.getcwd() would be / or the unit's WorkingDirectory=. So gateway/cron needs an explicit anchor directory. But that need is being conflated with CLI behavior via a single config key.

What quick setup does right

The "Quick setup" path (default for first-time users) does NOT ask about cwd — it leaves the default "." from DEFAULT_CONFIG. Only "Full setup" and hermes setup terminal trigger the problematic prompt. So users who picked quick setup are fine until they reconfigure.

Proposed fix

1. CLI and TUI always use os.getcwd() at launch — unconditionally

No config override, no flag. If I cd ~/project && hermes, pwd should say ~/project. Period.

2. Rename/reframe the config as a gateway-only concern

Either:

  • Rename to gateway.cwd or terminal.gateway_cwd (breaking but clear)
  • Or keep terminal.cwd but only consume it in gateway/cron/daemon mode (less breaking)

The config value should only be read when the source is gateway, cron, or delegation — never when it's an interactive CLI/TUI session.

3. Move the setup prompt to gateway configuration

Remove the "Messaging working directory" question from setup_terminal_backend() and move it to setup_gateway() where it belongs. It should only be asked when actually configuring messaging platforms.

Files involved

  • hermes_cli/setup.py line 1331-1341 — the problematic prompt
  • cli.py lines 473-487 — the resolution logic that respects placeholders but not explicit paths
  • hermes_cli/config.py line 471 — DEFAULT_CONFIG correctly defaults to "."
  • hermes_cli/config.py lines 2989-3031 — deprecated env var warning (related)

Impact

Every user who ran full setup or hermes setup terminal and hit Enter on the default has their CLI silently pinned to $HOME. They'd never know unless they pwd or try to work with relative paths in a project directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/cliCLI entry point, hermes_cli/, setup wizardcomp/tuiTerminal UI (ui-tui/ + tui_gateway/)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions