feat(tui): implement persona export/import (YAML format) #1338

Closed
freemo wants to merge 1 commits from feature/m8-tui-persona-export into master

1 Commits

Author SHA1 Message Date
freemo 2af4efe9ea feat(tui): implement persona export/import (YAML format)
CI / benchmark-publish (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 24m10s
CI / typecheck (pull_request) Successful in 3m53s
CI / e2e_tests (pull_request) Failing after 14m25s
CI / build (pull_request) Successful in 20s
CI / quality (pull_request) Successful in 3m58s
CI / helm (pull_request) Successful in 34s
CI / security (pull_request) Successful in 1m1s
CI / lint (pull_request) Successful in 3m23s
CI / unit_tests (pull_request) Failing after 6m12s
CI / coverage (pull_request) Successful in 12m45s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-regression (pull_request) Successful in 55m1s
Add persona export/import functionality in YAML format for the TUI interface.

## Changes

### New: src/cleveragents/cli/commands/persona.py
- CLI Typer app with 'export' and 'import' subcommands
- 'agents persona export <name> [--output path] [--force]' serialises a
  persona to YAML; defaults to <name>.yaml in the current directory
- 'agents persona import --input <path>' deserialises a YAML file and
  saves the persona to the registry
- Rich console output with Panel summaries on success
- Proper error handling for missing personas, missing files, invalid YAML,
  and pre-existing output files (guarded by --force)

### Modified: src/cleveragents/tui/commands.py
- TuiCommandRouter gains _persona_export / _persona_import handlers
- Colon-style alias routing: 'persona:export' and 'persona:import' are
  normalised before dispatch
- '/persona export <name> [path]' and '/persona import <path>' slash
  commands delegate to PersonaRegistry.export_persona / import_persona

### Modified: src/cleveragents/tui/persona/registry.py
- PersonaRegistry.export_persona(name, output_path) — resolves a safe
  relative path, serialises the persona via _atomic_write_yaml, returns
  the resolved Path
- PersonaRegistry.import_persona(input_path) — resolves a safe relative
  path, parses YAML, validates via Persona.model_validate, saves and
  returns the Persona
- resolve_export_path / resolve_import_path helpers enforce that paths
  stay within the current working directory (path-traversal guard)

### Modified: src/cleveragents/cli/main.py
- Registers the new 'persona' Typer sub-app under the main CLI
- Adds 'persona' to the valid-commands allow-list

### New: features/tui_persona_export_import.feature
### New: features/steps/tui_persona_export_import_steps.py
- 15 Behave scenarios covering:
  - TUI router export/import with default and explicit filenames
  - Error paths (missing persona, missing file, no argument)
  - Colon-style alias routing
  - Round-trip export → delete → import preserving all fields
  - CLI export (success, missing persona, file-exists-no-force)
  - CLI import (success, missing file)

ISSUES CLOSED: #1005
2026-04-02 16:54:43 +00:00