hermes-agent/tests/cli
Teknium ff85af3fc7
feat(goals): /goal wait <pid> — park the loop on a background process (#50503)
* feat(goals): add /goal wait <pid> barrier to park the loop on a background process

The /goal loop re-pokes the agent every turn via the post-turn judge. When a
goal is gated on a long-running background process (CI poller, build, test
matrix, deploy) that produces nothing to judge yet, this spins the agent into
'is it done?' busy-work and burns the turn budget.

/goal wait <pid> [reason] parks the loop: while the PID is alive, the judge is
skipped, no turn is consumed, no continuation fires, and /goal status shows a
parked indicator. The barrier auto-clears the moment the process exits (the
agent's notify_on_complete watcher is the natural wake signal), then the next
turn resumes normal judging. /goal unwait clears it manually; pause/resume/clear
drop it; a dead/stale PID can never wedge the loop.

Wired across CLI, gateway, and the mid-run command guard for parity. Barrier
persists in SessionDB.state_meta (survives /resume); GoalState gains
backward-compatible waiting_on_pid/waiting_reason/waiting_since fields. 12 new
tests; docs updated.

* fix(goals): use gateway.status._pid_exists for liveness, not os.kill(pid,0)

The Windows-footguns CI guard flagged os.kill(pid, 0) in _pid_alive — on
Windows that's not a no-op, it routes to CTRL_C_EVENT and hard-kills the
target's console process group (bpo-14484). Delegate to the canonical
footgun-safe gateway.status._pid_exists (psutil + ctypes/POSIX fallback)
instead, with a direct-psutil last resort.

* feat(goals): judge-driven auto-wait — the loop parks itself, no manual /goal wait

Makes the wait barrier automatic. Every turn the judge is shown the agent's
live background processes (pid, command, uptime, output tail from the
process_registry) alongside the goal + response, and can return a new 'wait'
verdict instead of continue:
  {"verdict":"wait","wait_on_pid":N}      → park until that process exits
  {"verdict":"wait","wait_for_seconds":N} → park until the deadline passes
evaluate_after_turn acts on the directive (sets the barrier, parks the loop)
so the agent isn't re-poked into busy-work while CI/builds/deploys run. Adds a
time-based waiting_until barrier alongside the pid barrier; both auto-clear and
can never wedge the loop. Drivers (CLI, gateway, tui_gateway) feed the live
registry in via gather_background_processes(). Manual /goal wait stays as an
override. Judge verdict contract widened to (verdict, reason, parse_failed,
wait_directive); legacy {"done":bool} shape still accepted.

* test(goals): update kanban _fake_judge to the 4-tuple judge contract

CI test(3) caught it: test_kanban_goal_mode's _fake_judge still returned the
3-tuple (verdict, reason, parse_failed), but the kanban loop now unpacks the
4-tuple (+ wait_directive). Update the fake to return None for the directive
and accept the background_processes kwarg.

* feat(goals): trigger-based wait — park on a process's own signal, not just exit

Addresses two gaps in the judge-driven wait: (1) the judge could only express
'wait until PID exits' or 'wait N seconds', so a long-lived watcher/server that
fires a trigger MID-RUN (and may never exit) couldn't be waited on; (2) the
process's own watch_patterns/notify_on_complete trigger was invisible to the judge.

Adds a session-based barrier (waiting_on_session) that releases on the process's
OWN trigger via process_registry.is_session_waiting(): the session exits, OR (if
started with watch_patterns) its pattern matches — even while the process keeps
running. list_sessions() now surfaces session_id + watch_patterns/watch_hit/
notify_on_complete so the judge sees the trigger and is told to prefer
wait_on_session for trigger processes. Judge verdict gains a {wait_on_session}
directive (preferred over pid). Backward-compatible GoalState field; pid + time
barriers unchanged.

Tests: TestSessionTriggerBarrier (release on mid-run pattern match while alive,
release on exit, unknown-session, full park→trigger→resume, parse, validation,
backcompat load). 105 goal-surface + 85 process_registry tests green.
2026-06-22 06:27:29 -07:00
..
__init__.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_bracketed_paste_timeout.py fix(cli): bracketed-paste timeout prevents permanent input freeze (#16263) 2026-05-25 05:07:11 -07:00
test_branch_command.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_busy_input_mode_command.py feat(busy): add 'steer' as a third display.busy_input_mode option (#16279) 2026-04-26 18:21:29 -07:00
test_cli_active_agent_ref_wiring.py fix(cli): publish agent ref to cli module so memory on_session_end fires on exit 2026-06-19 16:59:43 -07:00
test_cli_approval_ui.py feat(cli): persist resolved approval/clarify prompts in scrollback (#44702) 2026-06-12 01:14:35 -07:00
test_cli_background_status_indicator.py feat(cli): show live background terminal-process count in status bar (#32061) 2026-05-25 05:35:02 -07:00
test_cli_background_tui_refresh.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_cli_bracketed_paste_sanitizer.py fix(cli): strip leaked bracketed-paste wrappers 2026-04-26 21:47:40 -07:00
test_cli_browser_connect.py refactor(cli): extract 32 slash-command handlers into CLICommandsMixin (god-file Phase 4) 2026-06-08 02:13:07 -07:00
test_cli_context_warning.py fix(context): align guidance with 64k minimum 2026-05-24 23:23:12 -07:00
test_cli_copy_command.py feat: add /copy and /agents 2026-04-09 17:19:36 -05:00
test_cli_extension_hooks.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_external_editor.py feat(cli): add editor workflow for drafts 2026-04-20 02:53:40 -07:00
test_cli_file_drop.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_cli_force_redraw.py fix(cli): clear viewport on width-change resize so the status bar can't duplicate (#49120) 2026-06-19 08:43:42 -07:00
test_cli_goal_interrupt.py feat(goals): /goal wait <pid> — park the loop on a background process (#50503) 2026-06-22 06:27:29 -07:00
test_cli_image_command.py fix(termux): harden execute_code and mobile browser/audio UX 2026-04-09 16:24:53 -07:00
test_cli_init.py fix(config): alias model.api_base -> model.base_url for custom providers (#50385) 2026-06-21 13:33:41 -07:00
test_cli_insights_command.py fix(cli): parse positional insights days 2026-05-12 14:56:47 -07:00
test_cli_interrupt_subagent.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_cli_light_mode.py fix(cli): stop OSC 11 bg probe from trapping users in a stray editor (#35441) 2026-05-30 11:55:12 -05:00
test_cli_loading_indicator.py fix: clean up defensive shims and finish CI stabilization from #17660 (#17801) 2026-04-29 23:53:17 -07:00
test_cli_markdown_rendering.py fix(cli): preserve cron asterisks in strip mode 2026-05-18 20:08:36 -07:00
test_cli_mcp_config_watch.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_new_session.py fix(cli): synchronize HERMES_SESSION_ID across environment and contextvar during session switches 2026-05-23 17:46:55 -07:00
test_cli_prefix_matching.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_preloaded_skills.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_provider_resolution.py fix(model): clear stale endpoint credentials across switches 2026-06-19 19:58:26 -07:00
test_cli_reload_skills.py refactor(reload-skills): queue note for next turn, drop cache invalidation + agent tool 2026-04-29 21:07:47 -07:00
test_cli_resume_command.py fix(cli): use Rich [dim] tag instead of ANSI escape in _restore_session_cwd 2026-06-05 10:00:21 +08:00
test_cli_retry.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_cli_save_config_value.py fix(cli): preserve config comments on setting writes 2026-05-09 17:55:12 -07:00
test_cli_secret_capture.py fix(cli): show masked feedback for secret prompts 2026-05-25 01:20:33 -07:00
test_cli_shift_enter_newline.py feat(cli): recognise Shift+Enter as a newline key 2026-05-08 16:26:51 -07:00
test_cli_shutdown_memory_messages.py fix(cli): persist sessions before shutdown 2026-06-21 07:25:56 -07:00
test_cli_skin_integration.py fix(tui): restore macOS copy behavior and theme polish (#17131) 2026-04-28 18:47:14 -05:00
test_cli_status_bar.py fix(cli): status bar no longer stays hidden after resize during idle (#49105) 2026-06-19 07:53:58 -07:00
test_cli_status_command.py fix(profile): use existing get_active_profile_name() for /profile command 2026-04-15 17:52:03 -07:00
test_cli_steer_busy_path.py fix(cli): dispatch /steer inline while agent is running (#13354) 2026-04-20 23:05:38 -07:00
test_cli_terminal_response_sanitizer.py fix(cli): tighten mouse leak sanitizer 2026-04-29 22:10:18 -05:00
test_cli_terminal_shortcuts.py fix(cli): ignore terminal focus reports (salvage of #16780) 2026-05-29 00:31:44 -07:00
test_cli_tools_command.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_cli_user_message_preview.py feat(cli): improve multiline previews 2026-04-20 02:53:40 -07:00
test_cli_yolo_toggle.py fix(cli): /yolo in chat must enable session bypass, not just set env var 2026-05-28 12:10:21 -07:00
test_compress_focus.py feat: /compress <focus> — guided compression with focus topic (#8017) 2026-04-11 19:23:29 -07:00
test_compress_here.py Inspired by Claude Code: /compress here [N] — boundary-aware 'summarize up to here' (#35048) 2026-05-29 17:49:15 -07:00
test_cprint_bg_thread.py fix: preserve ansi output history on resize replay 2026-05-14 15:14:29 -07:00
test_ctrl_enter_newline.py fix: preserve Ctrl+J newlines in Ghostty 2026-05-28 23:30:39 -07:00
test_cwd_env_respect.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_destructive_slash_confirm.py fix(cli): add inline --yes/now skip for destructive slash commands (#30768) 2026-05-24 16:13:03 -07:00
test_destructive_slash_inline_skip_e2e.py fix(cli): add inline --yes/now skip for destructive slash commands (#30768) 2026-05-24 16:13:03 -07:00
test_exit_delete_session.py feat(cli): add /exit --delete flag to remove session on quit (#27101) 2026-05-16 12:51:08 -07:00
test_exit_summary_resume_hint.py test(cli): cover exit resume hint -p flag across profiles 2026-05-25 01:41:54 -07:00
test_fast_command.py feat(desktop): inline model picker in the status bar 2026-06-02 19:09:41 -05:00
test_manual_compress.py fix(cli): persist manual compress handoff 2026-05-05 04:42:48 -07:00
test_partial_compress.py Inspired by Claude Code: /compress here [N] — boundary-aware 'summarize up to here' (#35048) 2026-05-29 17:49:15 -07:00
test_personality_none.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_prefill_config.py fix(config): align prefill messages key handling 2026-06-03 23:51:44 -06:00
test_prepend_note_to_message.py refactor(cli): normalize note and avoid blank lines in prepend helper 2026-06-01 20:30:08 -07:00
test_prompt_text_input_thread_safety.py feat(billing): /billing terminal billing — interactive TUI + CLI client (#45449) 2026-06-19 01:53:32 +05:30
test_quick_commands.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_reasoning_command.py chore: ruff auto-fix PLR6201 resweep — tuple → set in membership tests (#27355) 2026-05-17 02:29:41 -07:00
test_resume_display.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_resume_quiet_stderr.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_save_conversation_location.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_session_boundary_hooks.py feat(observability): observer-grade telemetry hooks + NeMo-Relay plugin 2026-06-03 06:36:46 -07:00
test_single_query_session_finalize.py fix(cli): prevent duplicate one-shot finalize on interrupted cleanup (#43320) 2026-06-09 22:41:04 -07:00
test_slash_command_interrupt.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_slash_confirm_windows.py test(cli): exercise real _prompt_text_input for native-Windows confirm deadlock 2026-06-08 15:53:28 -07:00
test_steer_inline_repaint_34569.py fix(cli): repaint input area after inline /steer and /model submit (#34839) 2026-05-29 19:04:40 -07:00
test_stream_delta_think_tag.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_surrogate_sanitization.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_tool_progress_scrollback.py fix(cli): decouple tool_progress=verbose from global DEBUG logging (#31379) 2026-05-24 02:19:20 -07:00
test_tui_terminal_reset_on_exit.py fix(cli): reset terminal input modes on TUI exit to stop focus/mouse leaks 2026-06-01 23:27:44 +08:00
test_update_command.py feat(cli): add /update slash command to CLI and TUI (#23854) 2026-05-18 20:10:46 -04:00
test_version_command.py Add /version slash command across CLI, gateway, TUI, and desktop. 2026-06-05 18:05:05 -07:00
test_worktree.py chore: prune unused imports and duplicate import redefinitions 2026-05-28 22:26:25 -07:00
test_worktree_security.py refactor(tests): re-architect tests + fix CI failures (#5946) 2026-04-07 17:19:07 -07:00
test_worktree_sync_base.py fix(cli): branch new worktrees from the fresh remote tip, not stale local HEAD (#50355) 2026-06-21 12:42:11 -07:00