Files
cleveragents-core/robot/core_cli_commands.robot
CoreRasurae cc24d8c8ac fix(cli): remove legacy plan commands from help output
Completely removed all legacy plan commands from the CLI:
    - Removed tell, build, new, current, cd, continue CLI commands
    - Removed programmatic wrapper functions (tell_command, build_command, etc.)
    - Removed legacy deprecation message
    - Updated help text to indicate V3 Plan Lifecycle exclusively
    - Removed stale references to tell/build in help output and command validation

    Removes the legacy 'tell' and 'build' CLI shortcuts from main.py:
    - Removed echo lines advertising tell/build commands
    - Removed tell/build from valid_cmds list
    - Removed tell/build from _LIGHTWEIGHT_COMMANDS frozenset
    - These dead entries were preventing helpful error messages

    Test infrastructure improvements:
    - Event bus exception test: Patch the module-level logger during emit() so that
      structlog.testing.capture_logs() can capture the logs. Without patching, the
      module-level logger created at import time is not captured by the context manager.
    - Session create/list commands: Suppress cleveragents.mcp logger to CRITICAL level
      during JSON/YAML output formatting to prevent health check warnings with ANSI codes
      from being written to stdout before JSON output, which breaks JSON parsing.
    - Extended plan_cli_coverage_boost with scenarios for estimation_result,
      invariants, execution_environment, validation_summary, and checkpoint
      coverage in _plan_spec_dict

    Documentation:
    - Created docs/Legacy_to_V3_Guide.md with comprehensive migration instructions
    - Updated CONTRIBUTING.md to document removal of legacy workflow
    - Updated CHANGELOG.md to reference issue #4181 instead of PR #10800

ISSUES CLOSED: #4181
2026-05-05 02:01:49 +00:00

176 lines
9.3 KiB
Plaintext

*** Settings ***
Documentation Core CLI Commands Integration Tests for Project, Context and Plan Management
Library OperatingSystem
Library Process
Library String
Library Collections
Resource discovery_common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
Test Timeout 900 seconds
*** Variables ***
${TEST_DIR} ${TEMPDIR}${/}cleveragents_core_cli_test
${PROJECT_NAME} test-project
*** Test Cases ***
Test CLI Help Shows All Commands
[Documentation] Verify that CLI help displays all expected command groups
${result} = Run Process ${PYTHON} -m cleveragents --help timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} AI-powered development assistant
Should Contain ${result.stdout} project
Should Contain ${result.stdout} context
Should Contain ${result.stdout} plan
Should Contain ${result.stdout} init
Should Contain ${result.stdout} apply
Test Project Initialization
[Documentation] Test initializing a new CleverAgents project
Create Directory ${TEST_DIR}/project1
${result} = Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME}
... cwd=${TEST_DIR}/project1 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Project '${PROJECT_NAME}'
Should Contain ${result.stdout} initialized
Directory Should Exist ${TEST_DIR}/project1/.cleveragents
File Should Exist ${TEST_DIR}/project1/.cleveragents/db.sqlite
File Should Exist ${TEST_DIR}/project1/.cleveragents/config.yaml
File Should Exist ${TEST_DIR}/project1/.cleveragents/current
${current} = Get File ${TEST_DIR}/project1/.cleveragents/current
Should Be Equal ${current} main
Test Project Cannot Initialize Twice
[Documentation] Verify project cannot be initialized twice without force
Create Directory ${TEST_DIR}/project2
${first_init}= Run Process ${PYTHON} -m cleveragents init first-project cwd=${TEST_DIR}/project2 timeout=120s
Should Be Equal As Numbers ${first_init.rc} 0
${result} = Run Process ${PYTHON} -m cleveragents init second-project
... cwd=${TEST_DIR}/project2 timeout=120s
Should Not Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stderr} Project already initialized
Should Contain ${result.stderr} --force
Test Force Reinitialize Project
[Documentation] Test force reinitialization of a project
Create Directory ${TEST_DIR}/project3
${first_init}= Run Process ${PYTHON} -m cleveragents init first-project cwd=${TEST_DIR}/project3 timeout=120s
Should Be Equal As Numbers ${first_init.rc} 0
${result} = Run Process ${PYTHON} -m cleveragents init second-project --force
... cwd=${TEST_DIR}/project3 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Project 'second-project' initialized successfully
Test Context Add Files
[Documentation] Test adding files to context
Create Directory ${TEST_DIR}/project4
${init_result}= Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME} cwd=${TEST_DIR}/project4 timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
Create File ${TEST_DIR}/project4/test.py print('hello world')
${result} = Run Process ${PYTHON} -m cleveragents context add test.py
... cwd=${TEST_DIR}/project4 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Added 1 file(s) to context
Test Context List Files
[Documentation] Test listing context files
${unique_dir} = Set Variable ${TEST_DIR}/project5_${TEST NAME.replace(' ', '_')}
Create Directory ${unique_dir}
${init_result} = Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME}
... cwd=${unique_dir} timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
Create File ${unique_dir}/file1.py # File 1
Create File ${unique_dir}/file2.py # File 2
${add_result} = Run Process ${PYTHON} -m cleveragents context add file1.py file2.py
... cwd=${unique_dir} timeout=120s
Should Be Equal As Numbers ${add_result.rc} 0
Directory Should Exist ${unique_dir}
${result} = Run Process ${PYTHON} -m cleveragents context list
... cwd=${unique_dir} timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} file1.py
Should Contain ${result.stdout} file2.py
Test Context Clear
[Documentation] Test clearing context files
Create Directory ${TEST_DIR}/project6
${init_result}= Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME} cwd=${TEST_DIR}/project6 timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
Create File ${TEST_DIR}/project6/test.py # Test file
${add_result}= Run Process ${PYTHON} -m cleveragents context add test.py cwd=${TEST_DIR}/project6 timeout=120s
Should Be Equal As Numbers ${add_result.rc} 0
${result} = Run Process ${PYTHON} -m cleveragents context clear --yes
... cwd=${TEST_DIR}/project6 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Cleared all files from context
Test Plan Apply
[Documentation] Test v3 apply command help
Create Directory ${TEST_DIR}/project9
${init_result}= Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME} cwd=${TEST_DIR}/project9 timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
# The v3 'apply' requires a lifecycle plan.
# Verify the command help is accessible.
${result} = Run Process ${PYTHON} -m cleveragents apply --help cwd=${TEST_DIR}/project9 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Test Shortcut Commands Work
[Documentation] Test that shortcut commands work properly
Create Directory ${TEST_DIR}/project11
${init_result}= Run Process ${PYTHON} -m cleveragents init ${PROJECT_NAME} cwd=${TEST_DIR}/project11 timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
Create File ${TEST_DIR}/project11/test.txt Test content
# Test context-load shortcut
${result} = Run Process ${PYTHON} -m cleveragents context-load test.txt
... cwd=${TEST_DIR}/project11 timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Added 1 file(s) to context
Test Command Error Handling
[Documentation] Test error handling for invalid commands
${result} = Run Process ${PYTHON} -m cleveragents invalid-command timeout=120s
Should Not Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stderr} Invalid command
Test Project Status Without Project
[Documentation] Test project status command without initialized project
Create Directory ${TEST_DIR}/no_project
${result} = Run Process ${PYTHON} -m cleveragents project status
... cwd=${TEST_DIR}/no_project timeout=120s
Should Not Be Equal As Integers ${result.rc} 0
Should Contain ${result.stderr} No project found
Test Project Status With Project
[Documentation] Test project status command with initialized project
Create Directory ${TEST_DIR}/with_project
${init_result}= Run Process ${PYTHON} -m cleveragents init status-test cwd=${TEST_DIR}/with_project timeout=120s
Should Be Equal As Numbers ${init_result.rc} 0
${result} = Run Process ${PYTHON} -m cleveragents project status
... cwd=${TEST_DIR}/with_project timeout=120s
Should Be Equal As Numbers ${result.rc} 0
Should Contain ${result.stdout} Project: status-test
Should Contain ${result.stdout} Plans: 1
Should Contain ${result.stdout} Context Files: 0
*** Keywords ***
Setup Test Environment
[Documentation] Setup the test environment
${run_id}= Evaluate __import__('uuid').uuid4().hex
Set Suite Variable ${TEST_DIR} ${TEMPDIR}${/}cleveragents_core_cli_test_${run_id}
Set Suite Variable ${PROJECT_NAME} test-project-${run_id}
Set Environment Variable CLEVERAGENTS_TESTING_USE_MOCK_AI true
Create Directory ${TEST_DIR}
# Do NOT set CLEVERAGENTS_HOME here — individual test cases use
# separate project directories (cwd=...) and expect database files
# to be created relative to CWD, not a shared home directory.
Remove Environment Variable CLEVERAGENTS_HOME
Clean Core CLI Temp Dir
Run Keyword And Ignore Error Remove Directory ${TEST_DIR} recursive=True
Create Directory ${TEST_DIR}
Cleanup Test Environment
[Documentation] Clean up after tests
# Clean up test directory
Run Keyword And Ignore Error Remove Directory ${TEST_DIR} recursive=true