forked from cleveragents/cleveragents-core
297823c291
Implement three new actor context subcommands as specified in the v3 CLI specification: - `agents actor context remove [--yes|-y] (--all|-a|<NAME>)`: Remove a named context or all contexts with interactive confirmation. Supports --all for bulk removal and --yes to skip prompts. - `agents actor context export (--output|-o) <FILE> <NAME>`: Export a named context to JSON or YAML (detected from file extension). Includes sha256 integrity checksum in output metadata. - `agents actor context import [--update] (--input|-i) <FILE> [<NAME>]`: Import a context from JSON or YAML. Name is inferred from file metadata if omitted. Refuses to overwrite existing contexts unless --update is specified. All commands: - Support 6 output formats (json, yaml, plain, table, rich, color) via the shared format_output framework - Use ContextManager for persistence (messages, metadata, state, global_context) - Follow existing error handling patterns (typer.Exit for user errors) - Are wired as `agents actor context` subcommand group via add_typer New files: - src/cleveragents/cli/commands/actor_context.py (command module) - features/actor_context_cmds.feature (Behave BDD scenarios) - features/steps/actor_context_cmds_steps.py (BDD step definitions) - robot/actor_context_export_import.robot (Robot integration test) ISSUES CLOSED: #869
101 lines
4.7 KiB
Gherkin
101 lines
4.7 KiB
Gherkin
Feature: Actor context remove, export, and import commands
|
|
As a CleverAgents user
|
|
I want to manage actor contexts via the CLI
|
|
So that I can remove, export, and import conversation contexts
|
|
|
|
Background:
|
|
Given a temporary context directory for actor context tests
|
|
|
|
# ── context remove ─────────────────────────────────────────
|
|
|
|
Scenario: Remove a named actor context
|
|
Given an actor context named "docs" exists
|
|
When I run actor context remove "docs" with --yes
|
|
Then the actor context remove command should succeed
|
|
And the context "docs" should no longer exist
|
|
|
|
Scenario: Remove all actor contexts
|
|
Given an actor context named "docs" exists
|
|
And an actor context named "notes" exists
|
|
When I run actor context remove --all with --yes
|
|
Then the actor context remove command should succeed
|
|
And no actor contexts should remain
|
|
|
|
Scenario: Remove non-existent context fails
|
|
When I run actor context remove "nonexistent" with --yes
|
|
Then the actor context remove command should fail with exit code 1
|
|
|
|
Scenario: Remove requires NAME or --all
|
|
When I run actor context remove without name or all
|
|
Then the actor context remove command should fail with exit code 1
|
|
|
|
Scenario: Remove rejects NAME with --all
|
|
When I run actor context remove "docs" with --all
|
|
Then the actor context remove command should fail with exit code 1
|
|
|
|
Scenario: Remove outputs JSON format
|
|
Given an actor context named "docs" exists
|
|
When I run actor context remove "docs" with --yes and format "json"
|
|
Then the actor context remove command should succeed
|
|
And the output should contain valid JSON with key "context_removed"
|
|
|
|
# ── context export ─────────────────────────────────────────
|
|
|
|
Scenario: Export a named actor context to JSON
|
|
Given an actor context named "docs" exists with messages
|
|
When I run actor context export "docs" to a JSON file
|
|
Then the actor context export command should succeed
|
|
And the exported file should exist and contain valid JSON
|
|
And the exported JSON should contain key "messages"
|
|
|
|
Scenario: Export a named actor context to YAML
|
|
Given an actor context named "docs" exists with messages
|
|
When I run actor context export "docs" to a YAML file
|
|
Then the actor context export command should succeed
|
|
And the exported YAML file should exist and be valid
|
|
|
|
Scenario: Export non-existent context fails
|
|
When I run actor context export "nonexistent" to a JSON file
|
|
Then the actor context export command should fail with exit code 1
|
|
|
|
Scenario: Export outputs JSON format metadata
|
|
Given an actor context named "docs" exists with messages
|
|
When I run actor context export "docs" to a JSON file with format "json"
|
|
Then the actor context export command should succeed
|
|
And the output should contain valid JSON with key "context_export"
|
|
|
|
# ── context import ─────────────────────────────────────────
|
|
|
|
Scenario: Import a context from a JSON file
|
|
Given a valid context JSON file named "imported-ctx.json"
|
|
When I run actor context import from that file as "imported-ctx"
|
|
Then the actor context import command should succeed
|
|
And the context "imported-ctx" should exist
|
|
|
|
Scenario: Import infers name from file metadata
|
|
Given a valid context JSON file with context_name "auto-named"
|
|
When I run actor context import from that file without a name
|
|
Then the actor context import command should succeed
|
|
And the context "auto-named" should exist
|
|
|
|
Scenario: Import refuses to overwrite without --update
|
|
Given an actor context named "existing" exists
|
|
And a valid context JSON file named "existing.json"
|
|
When I run actor context import from that file as "existing" without update
|
|
Then the actor context import command should fail with exit code 1
|
|
|
|
Scenario: Import with --update replaces existing context
|
|
Given an actor context named "existing" exists
|
|
And a valid context JSON file named "existing.json"
|
|
When I run actor context import from that file as "existing" with --update
|
|
Then the actor context import command should succeed
|
|
And the context "existing" should exist
|
|
|
|
Scenario: Export then import round-trip preserves data
|
|
Given an actor context named "roundtrip" exists with messages
|
|
When I export the context "roundtrip" to a JSON file
|
|
And I remove the context "roundtrip"
|
|
And I import the context from that JSON file as "roundtrip"
|
|
Then the context "roundtrip" should exist
|
|
And the imported context should have the same messages as the original
|