Feature: Context Commands Unit Tests As a developer I want unit tests for context command functionality So that context.py achieves high code coverage @phase1 Scenario: Context add command full execution path Given a mock context service is configured When the context add command is executed with valid paths Then files should be added successfully with output @phase1 Scenario: Context add with non-existent path error Given a mock context service is configured When the context add command is executed with non-existent path Then path does not exist error should be shown @phase1 Scenario: Context add with FileSystemError exception Given a mock context service that raises FileSystemError When the context add command is executed and fails Then FileSystemError should be displayed and command aborted @phase1 Scenario: Context add with CleverAgentsError exception Given a mock context service that raises CleverAgentsError When the context add command is executed and fails Then CleverAgentsError should be displayed and command aborted @phase1 Scenario: Context add aborts when no active project Given a mock context service is configured When the context add command is executed without an active project Then a no active project error should be shown @phase1 Scenario: Context add reports already tracked files Given a mock context service with already tracked files When the context add command processes already tracked paths Then already tracked file details should be reported @phase1 Scenario: Context add reports already tracked files without overflow summary Given a mock context service with a few already tracked files When the context add command processes already tracked paths Then already tracked file details should be reported without overflow summary @phase1 Scenario: Context load alias command Given a mock context service is configured When the context load alias is executed Then it should delegate to context add function @phase1 Scenario: Context remove command execution Given a mock context service with remove capability When the context remove command is executed Then files should be removed with confirmation message @phase1 Scenario: Context remove with no files removed Given a mock context service returning zero removals When the context remove command is executed Then no files removed message should be shown @phase1 Scenario: Context remove aborts when no active project Given a mock context service with remove capability When the context remove command is executed without an active project Then a no active project error should be shown @phase1 Scenario: Context remove reports missing files for relative paths Given a mock context service returning zero removals When the context remove command is executed for relative paths Then missing context files should trigger an abort @phase1 Scenario: Context remove errors when some files missing Given a mock context service with partial removals When the context remove command is executed Then missing context files should trigger an abort @phase1 Scenario: Context remove handles CleverAgentsError exceptions Given a mock context service that raises CleverAgentsError When the context remove command is executed with service failure Then CleverAgentsError should be displayed and command aborted @phase1 Scenario: Context list with files present Given a mock context service with files When the context list command is executed Then a formatted table of files should be displayed @phase1 Scenario: Context list with empty context Given a mock context service with no files When the context list command is executed Then empty context message should be shown with help @phase1 Scenario: Context list aborts when no active project Given a mock context service with files When the context list command is executed without an active project Then a no active project error should be shown @phase1 Scenario: Context list formats numeric sizes Given a mock context service with numeric file sizes When the context list command is executed Then numeric sizes should be rendered as bytes @phase1 Scenario: Context list handles CleverAgentsError exceptions Given a mock context service that raises CleverAgentsError When the context list command is executed with service failure Then CleverAgentsError should be displayed and command aborted @phase1 Scenario: Context show specific file Given a mock context service with file content When the context show command is executed with path Then file content should be displayed in panel @phase1 Scenario: Context show file not found Given a mock context service returning no content When the context show command is executed with path Then file not found message should be displayed @phase1 Scenario: Context show all summary Given a mock context service with multiple files When the context show command is executed without path Then context summary with stats should be displayed @phase1 Scenario: Context show aborts when no active project Given a mock context service with file content When the context show command is executed without an active project Then a no active project error should be shown @phase1 Scenario: Context show without path on empty context Given a mock context service with no files When the context show command is executed without path Then the show command should report an empty context @phase1 Scenario: Context show single file renders content Given a mock context service with single file content When the context show command is executed without path Then file content should be displayed in panel @phase1 Scenario: Context show single file without stored content Given a mock context service with single file lacking content When the context show command is executed without path Then the show command should report missing content @phase1 Scenario: Context show handles CleverAgentsError exceptions Given a mock context service that raises CleverAgentsError When the context show command is executed with service failure Then CleverAgentsError should be displayed and command aborted @phase1 Scenario: Context clear with confirmation Given a mock context service with clearable files When the context clear command is executed with yes flag Then context should be cleared with success message @phase1 Scenario: Context clear cancelled by user Given a mock context service with clearable files When the context clear command is executed and user cancels Then cancelled message should appear and context unchanged @phase1 Scenario: Context clear on already empty Given a mock context service with no files When the context clear command is executed Then already empty message should be shown @phase1 Scenario: Context clear aborts when no active project Given a mock context service with clearable files When the context clear command is executed without an active project Then a no active project error should be shown @phase1 Scenario: Context clear handles CleverAgentsError exceptions Given a mock context service that raises CleverAgentsError When the context clear command is executed with service failure Then CleverAgentsError should be displayed and command aborted @phase1 Scenario: Context default callback behavior Given a mock context service with files When context command is invoked without subcommand Then the list function should be called by default @phase1 Scenario: Normalize dictionary context entries for display Given a dictionary-style context entry with missing metadata When the normalization helper processes the context entry Then the normalized context tuple should include placeholder defaults @phase1 Scenario: Normalize Context model entries for display Given a domain Context model entry with metadata When the normalization helper processes the context entry Then the normalized context tuple should match the model attributes @phase1 Scenario: Programmatic add command skips nonexistent files Given a mock context service is configured When the programmatic add command runs with a missing file path Then no files are sent to the context service @phase1 Scenario: Programmatic add command requires an active project Given a mock context service is configured When the programmatic add command runs without an active project Then a CleverAgentsError is raised for programmatic add @phase1 Scenario: Programmatic list command returns context entries Given a mock context service with files When the programmatic list command is executed Then the programmatic list command should return those files @phase1 Scenario: Programmatic list command requires an active project Given a mock context service is configured When the programmatic list command runs without an active project Then a CleverAgentsError is raised for programmatic list @phase1 Scenario: Programmatic show command requires an active project Given a mock context service is configured When the programmatic show command runs without an active project Then a CleverAgentsError is raised for programmatic show @phase1 Scenario: Programmatic show command returns None for empty context Given a mock context service with no files When the programmatic show command runs without a path Then the programmatic show command should return no content summary @phase1 Scenario: Programmatic show command summarizes multiple files Given a mock context service with multiple files When the programmatic show command runs without a path Then the programmatic show command should return a summary string @phase1 Scenario: Programmatic show command retrieves specific file content Given a mock context service with file content When the programmatic show command runs for a specific path Then the programmatic show command should return that content @phase1 Scenario: Programmatic remove command requires an active project Given a mock context service is configured When the programmatic remove command runs without an active project Then a CleverAgentsError is raised for programmatic remove @phase1 Scenario: Programmatic remove command raises when files missing Given a mock context service returning zero removals When the programmatic remove command runs for files Then a CleverAgentsError is raised for programmatic remove @phase1 Scenario: Programmatic remove command succeeds when files are removed Given a mock context service with remove capability When the programmatic remove command runs with removable files Then the programmatic remove command should complete successfully @phase1 Scenario: Programmatic clear command requires an active project Given a mock context service is configured When the programmatic clear command runs without an active project Then a CleverAgentsError is raised for programmatic clear @phase1 Scenario: Programmatic clear command calls clear on service Given a mock context service with clearable files When the programmatic clear command runs with an active project Then the context service clear function should be called @phase1 Scenario: Context add summarizes when more than ten files are added Given a mock context service is configured When the context add command is executed with more than ten added files Then remaining added files should be summarized @phase1 Scenario: Context list with missing context directory Given a missing context directory for listing When the context list command is executed with the context directory Then no contexts found message should be shown for list @phase1 Scenario: Context list with empty context directory Given an empty context directory for listing When the context list command is executed with the context directory Then no contexts found message should be shown for list @phase1 Scenario: Context list with named contexts Given a context directory with named contexts When the context list command is executed with the context directory Then the context names should be listed @phase1 Scenario: Context export fails for missing context Given a missing named context for export When the context export command is executed Then the context export should fail for missing context @phase1 Scenario: Context export writes a JSON file Given a named context exists for export When the context export command is executed Then the context export should succeed @phase1 Scenario: Context import loads a context file Given a context import file is available When the context import command is executed Then the context should be imported successfully @phase1 Scenario: Context delete rejects name with --all When the context delete command is executed with both name and all Then the delete command should fail with a mutually exclusive options error @phase1 Scenario: Context delete requires name or --all When the context delete command is executed without required arguments Then the delete command should fail with a missing arguments error @phase1 Scenario: Context delete --all reports missing directory Given a missing context directory for deletion When the context delete command is executed for all contexts with yes Then the delete command should report no contexts to delete @phase1 Scenario: Context delete --all reports empty directory Given an empty context directory for deletion When the context delete command is executed for all contexts with yes Then the delete command should report no contexts to delete @phase1 Scenario: Context delete --all prompts and cancels Given a context directory with multiple contexts When the context delete command is executed for all contexts and user cancels Then the delete command should list contexts and cancel @phase1 Scenario: Context delete --all removes contexts with yes Given a context directory with multiple contexts When the context delete command is executed for all contexts with yes Then the delete command should remove all contexts @phase1 Scenario: Context delete reports missing named context Given a context directory without the named context When the context delete command is executed for a missing named context Then the delete command should fail for missing named context @phase1 Scenario: Context delete cancels named context removal Given a context directory with a named context When the context delete command is executed for a named context and user cancels Then the delete command should cancel deleting the named context @phase1 Scenario: Context delete removes named context with yes Given a context directory with a named context When the context delete command is executed for a named context with yes Then the delete command should delete the named context @phase1 Scenario: Context clear named context fails when missing Given a missing named context for clearing When the context clear command is executed for a missing named context Then the clear command should fail for missing named context @phase1 Scenario: Context clear named context prompts and cancels Given a named context directory with contents When the context clear command is executed for the named context and user cancels Then the clear command should report cancellation for named context @phase1 Scenario: Context clear named context removes contents Given a named context directory with contents When the context clear command is executed for the named context with yes Then the named context should be cleared