feat(cli): add actor context remove, export, and import commands #869

Closed
opened 2026-03-13 22:55:54 +00:00 by freemo · 1 comment
Owner

Metadata

  • Commit Message: feat(cli): add actor context remove, export, and import commands
  • Branch: feature/m4-actor-context-cmds

Background and Context

The specification defines six agents actor context subcommands: remove, list, show, export, import, and clear. Issue #848 tracks the implementation of list, add, show, and clear, but three commands remain untracked: remove, export, and import.

These commands are specified in the CLI Command Synopsis (specification lines 282-287) and allow users to manage per-actor context snapshots — removing individual contexts, exporting them to files for sharing/backup, and importing them from previously exported files.

Expected Behavior

  • agents actor context remove [--yes|-y] (--all|-a|<NAME>) removes one or all saved actor contexts with a confirmation prompt.
  • agents actor context export (--output|-o) <FILE> <NAME> serializes a named actor context to a file (JSON or YAML).
  • agents actor context import [--update] (--input|-i) <FILE> [<NAME>] loads a context from a file, optionally overwriting an existing context with --update.

All three commands must integrate with the existing context persistence layer and emit structured output via the OutputSession rendering framework in all 6 formats (rich, table, color, plain, json, yaml).

Acceptance Criteria

  • agents actor context remove <NAME> removes the named context and displays confirmation
  • agents actor context remove --all removes all actor contexts with --yes bypass
  • agents actor context export --output file.json <NAME> writes the context to the specified file
  • agents actor context import --input file.json imports the context, rejecting duplicates unless --update is passed
  • All three commands produce correct output in all 6 format modes
  • Error handling for nonexistent contexts, permission errors, and malformed import files
  • All commands are registered in the Typer actor context sub-app

Subtasks

  • Add context_remove command to cli/commands/actor.py
  • Add context_export command to cli/commands/actor.py
  • Add context_import command to cli/commands/actor.py
  • Implement export serialization (JSON/YAML) in ContextService or ActorService
  • Implement import deserialization with validation in the service layer
  • Tests (Behave): Add scenarios for remove, export, import (success and error paths)
  • Tests (Robot): Add integration test for export-then-import round-trip
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
## Metadata - **Commit Message**: `feat(cli): add actor context remove, export, and import commands` - **Branch**: `feature/m4-actor-context-cmds` ## Background and Context The specification defines six `agents actor context` subcommands: `remove`, `list`, `show`, `export`, `import`, and `clear`. Issue #848 tracks the implementation of `list`, `add`, `show`, and `clear`, but three commands remain untracked: `remove`, `export`, and `import`. These commands are specified in the CLI Command Synopsis (specification lines 282-287) and allow users to manage per-actor context snapshots — removing individual contexts, exporting them to files for sharing/backup, and importing them from previously exported files. ## Expected Behavior - `agents actor context remove [--yes|-y] (--all|-a|<NAME>)` removes one or all saved actor contexts with a confirmation prompt. - `agents actor context export (--output|-o) <FILE> <NAME>` serializes a named actor context to a file (JSON or YAML). - `agents actor context import [--update] (--input|-i) <FILE> [<NAME>]` loads a context from a file, optionally overwriting an existing context with `--update`. All three commands must integrate with the existing context persistence layer and emit structured output via the OutputSession rendering framework in all 6 formats (rich, table, color, plain, json, yaml). ## Acceptance Criteria - [ ] `agents actor context remove <NAME>` removes the named context and displays confirmation - [ ] `agents actor context remove --all` removes all actor contexts with `--yes` bypass - [ ] `agents actor context export --output file.json <NAME>` writes the context to the specified file - [ ] `agents actor context import --input file.json` imports the context, rejecting duplicates unless `--update` is passed - [ ] All three commands produce correct output in all 6 format modes - [ ] Error handling for nonexistent contexts, permission errors, and malformed import files - [ ] All commands are registered in the Typer actor context sub-app ## Subtasks - [ ] Add `context_remove` command to `cli/commands/actor.py` - [ ] Add `context_export` command to `cli/commands/actor.py` - [ ] Add `context_import` command to `cli/commands/actor.py` - [ ] Implement export serialization (JSON/YAML) in `ContextService` or `ActorService` - [ ] Implement import deserialization with validation in the service layer - [ ] Tests (Behave): Add scenarios for remove, export, import (success and error paths) - [ ] Tests (Robot): Add integration test for export-then-import round-trip - [ ] Verify coverage >= 97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done.
freemo added this to the v3.4.0 milestone 2026-03-13 22:56:40 +00:00
freemo self-assigned this 2026-03-29 02:30:29 +00:00
Author
Owner

Implementation submitted as PR #1190.

Branch: feature/m4-actor-context-cmds
Commit: 12ac191dcec351bf63b1acde7b1b3d90636401db

What was implemented

Three new agents actor context subcommands in src/cleveragents/cli/commands/actor_context.py:

  1. remove [--yes|-y] (--all|-a|<NAME>) — Remove named or all actor contexts with confirmation
  2. export (--output|-o) <FILE> <NAME> — Export context to JSON/YAML with sha256 checksum
  3. import [--update] (--input|-i) <FILE> [<NAME>] — Import from JSON/YAML with overwrite protection

All commands support 6 output formats and use ContextManager for persistence.

Test coverage

  • features/actor_context_cmds.feature — 15 BDD scenarios (success + error paths)
  • features/steps/actor_context_cmds_steps.py — Step definitions
  • robot/actor_context_export_import.robot — Integration test for export-then-import round-trip

Nox results

Session Result
lint Passed
format Passed
typecheck Passed (0 errors)
build Passed
Implementation submitted as PR #1190. **Branch**: `feature/m4-actor-context-cmds` **Commit**: `12ac191dcec351bf63b1acde7b1b3d90636401db` ### What was implemented Three new `agents actor context` subcommands in `src/cleveragents/cli/commands/actor_context.py`: 1. **`remove [--yes|-y] (--all|-a|<NAME>)`** — Remove named or all actor contexts with confirmation 2. **`export (--output|-o) <FILE> <NAME>`** — Export context to JSON/YAML with sha256 checksum 3. **`import [--update] (--input|-i) <FILE> [<NAME>]`** — Import from JSON/YAML with overwrite protection All commands support 6 output formats and use ContextManager for persistence. ### Test coverage - `features/actor_context_cmds.feature` — 15 BDD scenarios (success + error paths) - `features/steps/actor_context_cmds_steps.py` — Step definitions - `robot/actor_context_export_import.robot` — Integration test for export-then-import round-trip ### Nox results | Session | Result | |---------|--------| | `lint` | Passed | | `format` | Passed | | `typecheck` | Passed (0 errors) | | `build` | Passed |
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#392 Epic: Actor YAML & Compiler
cleveragents/cleveragents-core
Depends on
Reference
cleveragents/cleveragents-core#869
No description provided.