Skip to content

fix: add /whoami CLI handler so command no longer shows Unknown - #51190

Closed
ochsec wants to merge 7 commits into
NousResearch:mainfrom
ochsec:fix/issue-51009-whoami-cli-handler
Closed

ochsec wants to merge 7 commits into
NousResearch:mainfrom
ochsec:fix/issue-51009-whoami-cli-handler

Conversation

@ochsec

@ochsec ochsec commented Jun 23, 2026

Copy link
Copy Markdown

Fixes #51009

Problem

The /whoami slash command is registered in COMMAND_REGISTRY, listed in /help, offered by tab-completion, and advertised by the tips system — but process_command() in cli.py had no dispatch branch for it. Typing /whoami in the CLI, TUI, or Desktop app fell through to the prefix matcher and printed "Unknown command: /whoami".

The same command works correctly on gateway platforms (Telegram/Discord/Slack) because those route through gateway/slash_commands.py, which has a _handle_whoami_command handler.

Root Cause

/whoami has no gateway_only flag — it's a user-facing "Info" command that should work everywhere. But when the command registry was added (including the whoami entry), no corresponding elif canonical == "whoami" branch was added to the CLI dispatch chain in cli.py. The command definition exists, the help text exists, but the handler was never wired up.

Fix

  1. cli.py: Add elif canonical == "whoami" dispatch branch that calls self._handle_whoami_command().

  2. hermes_cli/cli_commands_mixin.py: Add _handle_whoami_command() method. In the CLI context there is no platform-mediated slash-access policy — the operator is always the owner. The handler mirrors the gateway's /whoami output shape (surface, profile, tier) so users see a familiar format regardless of which surface they're on.

  3. tests/cli/test_whoami_command.py: Tests covering:

    • Dispatch wiring (routes to handler, doesn't produce "Unknown command")
    • Handler output (contains "owner" tier, "CLI" surface, profile name)
    • Registry consistency (whoami is in registry, not gateway_only, category is "Info")

Changes

  • cli.py: Added elif canonical == "whoami" dispatch branch
  • hermes_cli/cli_commands_mixin.py: Added _handle_whoami_command() method
  • tests/cli/test_whoami_command.py: New test file (8 tests, all passing)

Impact

  • Fixes the /whoami command in CLI, TUI, and Desktop app surfaces
  • No change to gateway behavior (gateway already handles /whoami correctly)
  • Low risk: single new handler that only prints info, no state mutation

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jun 23, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #26047 (earliest open PR wiring /whoami into the classic-CLI process_command() dispatch — same mechanism: add the missing elif branch + handler). This PR additionally bundles an unrelated kanban blocked-event fix (hermes_cli/kanban_db.py). Related: #40052 (alternate approach — marks /whoami gateway_only instead of wiring a CLI handler) and the broader report #51009.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Overview

Adds the /whoami command dispatch to HermesCLI.process_command() and implements _handle_whoami_command() to show the active profile and owner-tier access level. Also fixes a kanban issue where tasks created with initial_status=blocked were incorrectly auto-promoted.

Analysis

  • Clean feature addition: /whoami was already registered in COMMAND_REGISTRY and advertised in help/completion, but had no dispatch branch
  • Handler mirrors the gateway /whoami output format for consistency
  • Shows profile name, access tier, and available slash command count
  • Comprehensive test file covering dispatch wiring, output format, and registry status
  • Kanban fix: create_task now emits a "blocked" event for created-blocked tasks so recompute_ready respects the sticky status

Tests

  • test_whoami_command.py: 6 tests covering dispatch, output content, registry status
  • Kanban: 3 new tests for created-blocked task behavior

Looks Good

  • Minimal, well-scoped feature
  • Good test coverage
  • Kanban fix is a separate concern but correctly implemented

Reviewed by Hermes Agent

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Adds a /whoami CLI command handler so the command returns the authenticated user identity instead of "Unknown".

Changes (5 files, +191/-0)

  • hermes_cli/cli_commands_mixin.py: +22/-0 for whoami handler
  • hermes_cli/kanban_db.py: +5/-0
  • tests/cli/test_whoami_command.py: +106 lines test coverage
  • tests/hermes_cli/test_kanban_blocked_sticky.py: +56 lines
  • cli.py: +2/-0

Quality

  • Good test coverage
  • Clear fix for missing command handler
  • No security concerns

Reviewed by Hermes Agent

@ochsec ochsec closed this Jul 14, 2026
blightbow pushed a commit to blightbow/hermes-agent that referenced this pull request Jul 17, 2026
Every non-gateway_only CommandDef must have a handler branch in
process_command().  Without this gate, commands can be added to
the registry — appearing in /help, autocomplete, and platform
surfaces — but returning "Unknown command" at runtime because no
one wired the dispatch.

Currently FAILS on main due to two pre-existing gaps:
  indicator — NousResearch#22960, NousResearch#50618 (5 open PRs)
  whoami    — NousResearch#51190

This PR is blocked until those handlers are merged.  Once they
land, the gate self-resolves and any future handler-less
CommandDef fails CI immediately.

Prior art in this codebase: test_commands_dict_includes_all_cli_commands
and tests/providers/test_provider_profiles.py use the same enumeration-
gate pattern against their respective registries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management comp/tui Terminal UI (ui-tui/ + tui_gateway/) duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] /whoami and other registered slash commands return unknown command in Desktop app and TUI

3 participants