forked from HAL9000/cleveragents-core
9aa73cec03
Add Markdown export format to the session export/import system. - Add Session.as_markdown_export() domain method that renders a human-readable Markdown document (metadata table, messages, token usage, linked plans) - Extract render_session_markdown() and build_session_from_export_dict() into a dedicated session_markdown module to keep file sizes manageable - Extend 'agents session export' CLI command with --format/-f option accepting 'json' (default, re-importable) or 'markdown' (human-readable) - Add Behave BDD tests covering: Markdown export to stdout/file, --force overwrite, invalid format rejection, domain method structure, and JSON round-trip (export then import preserves actor, messages, namespace) JSON export/import round-trip fidelity is unchanged; Markdown format is intentionally read-only (not re-importable). ISSUES CLOSED: #1004
82 lines
4.0 KiB
Gherkin
82 lines
4.0 KiB
Gherkin
Feature: Session export in Markdown format
|
|
As a developer
|
|
I want to export sessions as human-readable Markdown
|
|
So that I can share and review session history outside the tool
|
|
|
|
Background:
|
|
Given a session CLI runner with mocked service
|
|
|
|
# ── Markdown export via CLI ──────────────────────────────────────────────
|
|
|
|
Scenario: Export session as Markdown to stdout
|
|
Given there is a mocked session for markdown export
|
|
When I run session CLI export with --format markdown
|
|
Then the session CLI export should succeed
|
|
And the session CLI output should contain "# Session"
|
|
And the session CLI output should contain "## Metadata"
|
|
And the session CLI output should contain "## Token Usage"
|
|
|
|
Scenario: Export session with messages as Markdown
|
|
Given there is a mocked session with messages for markdown export
|
|
When I run session CLI export with --format markdown
|
|
Then the session CLI export should succeed
|
|
And the session CLI output should contain "## Messages"
|
|
And the session CLI output should contain "[user]"
|
|
|
|
Scenario: Export session as Markdown to file
|
|
Given there is a mocked session for markdown export
|
|
When I run session CLI export with --format markdown to a temp file
|
|
Then the session CLI export should succeed
|
|
And the exported markdown file should exist
|
|
And the exported markdown file should contain "# Session"
|
|
|
|
Scenario: Export session as Markdown with --force overwrites file
|
|
Given there is a mocked session for markdown export
|
|
And there is an existing markdown export file
|
|
When I run session CLI export with --format markdown --force to existing file
|
|
Then the session CLI export should succeed
|
|
|
|
Scenario: Export session as Markdown refuses overwrite without --force
|
|
Given there is a mocked session for markdown export
|
|
And there is an existing markdown export file
|
|
When I run session CLI export with --format markdown to existing file without --force
|
|
Then the session CLI should exit with error
|
|
And the session CLI output should contain "File already exists"
|
|
|
|
Scenario: Export with invalid format is rejected
|
|
Given there is a mocked session for markdown export
|
|
When I run session CLI export with --format invalid
|
|
Then the session CLI should exit with error
|
|
And the session CLI output should contain "Invalid format"
|
|
|
|
# ── Session.as_markdown_export() domain method ───────────────────────────
|
|
|
|
Scenario: Session.as_markdown_export produces valid Markdown structure
|
|
Given a session domain object with actor and messages
|
|
When I call as_markdown_export on the session
|
|
Then the markdown output should start with "# Session"
|
|
And the markdown output should contain a metadata table
|
|
And the markdown output should contain a messages section
|
|
And the markdown output should contain a token usage section
|
|
|
|
Scenario: Session.as_markdown_export with no messages omits messages section
|
|
Given a session domain object with no messages
|
|
When I call as_markdown_export on the session
|
|
Then the markdown output should start with "# Session"
|
|
And the markdown output should not contain "## Messages"
|
|
|
|
Scenario: Session.as_markdown_export with linked plans includes plans section
|
|
Given a session domain object with linked plans
|
|
When I call as_markdown_export on the session
|
|
Then the markdown output should contain "## Linked Plans"
|
|
|
|
# ── Round-trip: JSON export then import preserves data ───────────────────
|
|
|
|
Scenario: Round-trip export then import preserves session data
|
|
Given a session with actor and messages for round-trip
|
|
When I export the session to JSON
|
|
And I import the exported JSON
|
|
Then the imported session should have the same actor name
|
|
And the imported session should have the same message count
|
|
And the imported session should have the same namespace
|