Skip to content

export: CLI script produces minimal, low-detail Markdown compared to the API export #5

@wpak-ai

Description

@wpak-ai

Bug

The scripts/export.py CLI export produced Markdown files that were
significantly less detailed than those produced by the API (api/export_api.py).
The following information was entirely absent or incorrect.

1. Frontmatter was sparse and inaccurate

The frontmatter contained only log_id, log_type, title, created_at,
updated_at, workspace_id, workspace_path, storage_kind,
message_count, and optionally tool_calls_count / thinking_count.

Missing fields:

  • workspace and workspace_name (human-readable workspace slug/name)
  • model
  • total_tool_calls with tool_call_breakdown per tool name
  • wall_clock_seconds
  • total_response_time_sec
  • total_thinking_time_sec
  • max_context_tokens_used and context_token_limit
  • lines_added / lines_removed
  • files_read / files_written / commands_run counts

Fix: Frontmatter now includes all of the above fields wherever the
underlying data is available.

2. No session header line

The body contained no human-readable header line summarising the session
(creation date, model, tool call count, duration).

Fix: A _Created: ... | Model: ... | Tool calls: ... | Duration: ..._
header line is now rendered immediately after the title heading.

3. No Session Summary block

The exported Markdown had no ## Session Summary section. Readers had
to scan every message to understand what files were touched and what
commands were run.

Fix: A ## Session Summary block is now generated containing:

  • ### Files Touched — table of edited and read files
  • ### Commands Run — numbered list of terminal commands
  • ### Tool Results — aggregate counts of terminal successes/errors,
    file reads, file edits, searches, and web fetches

4. Role labels were lower-case

Messages used ### user and ### assistant headings.

Fix: Labels are now ### User and ### Assistant to match
consistent capitalisation across all export paths.

5. No per-message metadata line

Assistant messages contained no inline metadata about which model
responded, how long it took, how much thinking was used, or the current
context window occupancy.

Fix: Each bubble now renders a metadata line:
_Model: X | Response: Ys | Thinking: Zs | Context: A / B tokens (C% used)_
whenever the respective fields are available from modelInfo,
thinkingDurationMs, and contextWindowStatusAtCreation.

6. Thinking blocks had no duration in the summary

<details><summary>Thinking</summary> blocks did not include the
thinking duration.

Fix: The summary now reads Thinking (2.3s) when thinkingDurationMs
is present.

7. Tool calls rendered raw instead of via the shared parser

Tool calls read directly from toolFormerData fields (name, params,
result, status) as unstructured strings, bypassing parse_tool_call
from utils/tool_parser.py which produces human-readable summary,
input, and output representations.

Fix: All tool calls in the CLI export now go through parse_tool_call,
producing the same rich, structured > **Tool: ...** / > **INPUT:** /
> **OUTPUT:** blocks as the API export.

8. Content capping in session summary

Commands in the commands_run_list were capped at 120 characters.
The files-read list was capped at 20 entries; commands were capped at 30.

Fix: All caps removed. Full command strings and complete file lists
are preserved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions