Files
temp/robot/tui_help_command.robot
freemo a57728e3be fix(tui): make /help command list all catalogued slash commands from SLASH_COMMAND_SPECS
Replace the hardcoded help string in TuiCommandRouter.handle() with a
dynamic lookup against SLASH_COMMAND_SPECS from slash_catalog.py.

Changes:
- Add _help_command(), _help_list_all(), _help_for_command() methods to
  TuiCommandRouter
- /help (no args): iterates SLASH_COMMAND_SPECS, groups commands by
  namespace (sorted alphabetically), renders all 70 commands with
  descriptions in colon-namespaced format (e.g. persona:list)
- /help <command>: looks up the given command in SLASH_COMMAND_SPECS and
  renders its full help (group, description)
- /help <unknown>: returns 'Unknown command: /<cmd>' message
- /help /persona:list (with leading slash): strips the slash and resolves
  correctly
- Import defaultdict and SLASH_COMMAND_SPECS at module level

Tests:
- Update tui_commands_coverage.feature: replace old exact-match scenario
  for help text with new dynamic-listing assertions
- Add tui_commands_coverage_steps.py: new 'should contain' step definition
- Add tui_help_command_full_catalog.feature: 12 BDD scenarios covering
  /help no-args, /help <command>, /help <unknown>, namespace grouping,
  colon-namespaced format, and regression against old hardcoded string
- Add tui_help_command_full_catalog_steps.py: step definitions for the
  new feature (all-commands check, not-equal assertion)
- Add robot/tui_help_command.robot: 5 Robot Framework integration tests
  verifying the help command via direct Python invocation and headless
  TUI startup

Closes #3434

---
**Automated by CleverAgents Bot**
Supervisor: Implementation | Agent: ca-issue-worker
2026-04-05 17:46:00 +00:00

85 lines
4.8 KiB
Plaintext

*** Settings ***
Library Process
Library String
*** Test Cases ***
TUI Help Command Lists All Catalogued Commands
[Documentation] /help with no args must list all commands from SLASH_COMMAND_SPECS,
... not the old hardcoded 3-command string.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.slash_catalog import SLASH_COMMAND_SPECS
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help", session_id="default")
... assert "Available slash commands:" in result, f"Missing header: {result[:200]}"
... missing = [s.command for s in SLASH_COMMAND_SPECS if s.command not in result]
... assert not missing, f"Missing commands: {missing}"
... assert result != "Commands: /persona, /session, /help", "Old hardcoded string returned"
... print("tui-help-all-commands-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-all-commands-ok
TUI Help Command Groups By Namespace
[Documentation] /help output must include group headers for Session, Persona, Plan, Utility.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help", session_id="default")
... for group in ("Session:", "Persona:", "Plan:", "Utility:"):
... assert group in result, f"Missing group header {group!r} in output"
... print("tui-help-groups-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-groups-ok
TUI Help Command With Known Command Returns Specific Help
[Documentation] /help persona:list must return description for that specific command.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help persona:list", session_id="default")
... assert "/persona:list" in result, f"Missing command name in: {result}"
... assert "Display all personas" in result, f"Missing description in: {result}"
... assert "Persona" in result, f"Missing group in: {result}"
... print("tui-help-specific-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-specific-ok
TUI Help Command With Unknown Command Returns Not Found
[Documentation] /help nonexistent must return an "Unknown command" message.
${script}= Catenate SEPARATOR=\n
... from cleveragents.tui.commands import TuiCommandRouter
... from unittest.mock import MagicMock
... registry = MagicMock()
... registry.list_personas.return_value = []
... state = MagicMock()
... router = TuiCommandRouter(persona_registry=registry, persona_state=state)
... result = router.handle("help nonexistent:cmd", session_id="default")
... assert "Unknown command" in result, f"Expected not-found message, got: {result}"
... print("tui-help-unknown-ok")
${result}= Run Process ${PYTHON} -c ${script} shell=False stderr=STDOUT
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} tui-help-unknown-ok
TUI Headless Startup Help Payload Contains All Commands
[Documentation] run_tui --headless JSON payload help field must list all commands.
${result}= Run Process ${PYTHON} -m cleveragents tui --headless shell=False stderr=STDOUT env:CLEVERAGENTS_DATABASE_URL=sqlite:///:memory:
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} Available slash commands:
Should Contain ${result.stdout} persona:list
Should Contain ${result.stdout} session:create