mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 05:17:15 +00:00
Two paths printed "Created worktree but could not enter it" when that was not the whole story: - The gateway refused the move (e.g. session_busy). Nothing moved, but the fresh tree stayed on disk, unlisted by /worktree, until quit removed it. It is now removed right away (an earlier active tree stays active), and the refusal carries the check that fired. - The gateway accepted the move but this process could not chdir into the tree. The session's tools do run in the tree, so the tree is now the active one, the success lines print, and the warning is the existing "could not enter session's working directory" line. The step lives in a new hermes_cli/cli_commands_worktree.py, since cli_commands_mixin.py may not grow. Refs #134889 (CLI-15)
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
"""``/worktree new``'s step into the tree it just created, split out of ``cli_commands_mixin``."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from agent.i18n import t
|
|
from hermes_cli.cli_commands_session_tools import _t
|
|
|
|
|
|
def enter_new_worktree(cli, wt_info) -> bool:
|
|
"""Move *cli*'s session into the fresh tree -> True when the session's tools now run there.
|
|
|
|
A gateway refusal (e.g. ``session_busy``) moved nothing: the fresh tree is removed now instead of
|
|
sitting unlisted until quit, and an earlier active tree stays active. A chdir failure after the
|
|
gateway accepted the move leaves only this process behind, so it is reported as that."""
|
|
import cli as _cli
|
|
from hermes_cli.cli_chat_error_copy import refusal_text
|
|
from hermes_cli.gateway_automation import gateway_connection
|
|
from hermes_cli.gateway_client import GatewayClientError
|
|
from hermes_cli.gateway_session_store import move_cli_workspace
|
|
try:
|
|
move_cli_workspace(cli, wt_info) # the gateway session's tools, then this process
|
|
except GatewayClientError as e:
|
|
print(f" {_t('worktree.enter_failed', error=refusal_text(e))}")
|
|
active = _cli._active_worktree
|
|
_cli._cleanup_worktree(wt_info)
|
|
_cli._active_worktree = active
|
|
return False
|
|
except OSError as e:
|
|
if gateway_connection(cli) is None: # a local session: nothing moved
|
|
print(f" {_t('worktree.enter_failed', error=e)}")
|
|
return False
|
|
print(f" {t('cli.session.cwd_enter_failed', path=wt_info['path'], error=e)}")
|
|
return True
|