Refactor/cli command manager (#178)
* feat(cli): migrate command handling to CommandManager and enhance UI interactions * feat(cli): add /clear and /help commands to enhance user experience * feat(cli): implement /new and /resume commands with interactive session management * Refactor MCP and Skills Command Handling - Moved the interactive picker style to a centralized widget for consistency across MCP and Skills commands. - Updated the MCP command to remove the old command dispatch logic, delegating to the new InstallMCPCommand. - Enhanced the Skills command to utilize a new interactive picker for skill selection, improving user experience. - Implemented cancellation handling in the picker to differentiate between user cancellations and empty selections. - Added comprehensive tests for the new command structures and picker functionalities to ensure reliability. * refactor(cli): streamline CommandManager dispatch and remove deprecated command set * refactor(cli): enhance error handling and state management in ChannelCommand and RichCLICommandUI * refactor(cli): update lifecycle callback terminology and improve async prompt handling in RichCLICommandUI * refactor(cli): enhance SlashCommandCompleter to dynamically fetch workspace directory for autocompletion * refactor(cli): unify quit handling in RichCLICommandUI with shared _stop helper * refactor(cli): remove hardcoded slash commands and utilize command manager for dynamic completion * refactor(cli): update MCP and skills command files for improved clarity and organization * refactor(mcp_ui): remove unnecessary newline in _show_mcp_config function
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""Tests for the /new command."""
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from tests.conftest import run_async as _run
|
||||
|
||||
|
||||
class TestNewCommand:
|
||||
def test_execute_calls_start_new_session(self):
|
||||
from EvoScientist.commands.base import CommandContext
|
||||
from EvoScientist.commands.implementation.session import NewCommand
|
||||
|
||||
ui = MagicMock()
|
||||
ctx = CommandContext(
|
||||
agent=None,
|
||||
thread_id="old-tid",
|
||||
ui=ui,
|
||||
workspace_dir="/old/ws",
|
||||
)
|
||||
_run(NewCommand().execute(ctx, []))
|
||||
ui.start_new_session.assert_called_once()
|
||||
|
||||
def test_requires_agent_false(self):
|
||||
from EvoScientist.commands.implementation.session import NewCommand
|
||||
|
||||
assert NewCommand().requires_agent is False
|
||||
|
||||
def test_no_agent_access(self):
|
||||
"""Command body must not touch ctx.agent (it's still loading)."""
|
||||
from EvoScientist.commands.base import CommandContext
|
||||
from EvoScientist.commands.implementation.session import NewCommand
|
||||
|
||||
ui = MagicMock()
|
||||
ctx = CommandContext(agent=None, thread_id="tid", ui=ui)
|
||||
# No AttributeError even though ctx.agent is None
|
||||
_run(NewCommand().execute(ctx, []))
|
||||
Reference in New Issue
Block a user