fix(hermes): align myhermes resume flags with myclaude UX

Hermes -r/--resume requires a session id and has no -c shorthand, so
bare 'myhermes -r' failed with an argparse error. Translate
myagents-style flags like the codex backend:

- bare -r/--resume -> 'hermes sessions browse' (interactive picker)
- -r/--resume <id> -> '--resume <id> --no-restore-cwd'
- -c/--continue/--last -> '--continue --no-restore-cwd'

--no-restore-cwd keeps resumed sessions in the launch cwd, matching
myclaude semantics instead of jumping to the session's original cwd.
This commit is contained in:
Zhengshou Lai
2026-07-15 10:34:01 +08:00
parent 78ca74152f
commit 20e22eafd4
3 changed files with 82 additions and 4 deletions
+49 -2
View File
@@ -473,11 +473,58 @@ class TestHermesPassthrough:
def test_resume_with_session_id(self, tmp_path: Path) -> None:
cmd = self._invoke(["--resume", "abc123"], tmp_path)
assert cmd == ["/usr/bin/hermes", "--yolo", "--resume", "abc123"]
assert cmd == [
"/usr/bin/hermes",
"--yolo",
"--resume",
"abc123",
"--no-restore-cwd",
]
def test_bare_r_flag_opens_session_picker(self, tmp_path: Path) -> None:
cmd = self._invoke(["-r"], tmp_path)
assert cmd == ["/usr/bin/hermes", "--yolo", "sessions", "browse"]
def test_bare_resume_flag_opens_session_picker(self, tmp_path: Path) -> None:
cmd = self._invoke(["--resume"], tmp_path)
assert cmd == ["/usr/bin/hermes", "--yolo", "sessions", "browse"]
def test_r_flag_with_session_id(self, tmp_path: Path) -> None:
cmd = self._invoke(["-r", "abc123"], tmp_path)
assert cmd == [
"/usr/bin/hermes",
"--yolo",
"--resume",
"abc123",
"--no-restore-cwd",
]
def test_c_flag_maps_to_continue(self, tmp_path: Path) -> None:
cmd = self._invoke(["-c"], tmp_path)
assert cmd == [
"/usr/bin/hermes",
"--yolo",
"--continue",
"--no-restore-cwd",
]
def test_continue_flag_passes_through(self, tmp_path: Path) -> None:
cmd = self._invoke(["--continue"], tmp_path)
assert cmd[-1] == "--continue"
assert cmd == [
"/usr/bin/hermes",
"--yolo",
"--continue",
"--no-restore-cwd",
]
def test_last_flag_maps_to_continue(self, tmp_path: Path) -> None:
cmd = self._invoke(["--last"], tmp_path)
assert cmd == [
"/usr/bin/hermes",
"--yolo",
"--continue",
"--no-restore-cwd",
]
class TestHermesListSessions: