Skip to content

[Feature] Export chat history to JSON with full tool call and token metadata (/export --json) #1309

Description

@akramcodez

Description

Extend the /export command to support exporting conversation transcripts as structured JSON (/export --json or /export <filename>.json).

Use Case

Currently, /export only writes a Markdown representation (.md). In the Markdown export, tool execution structures, parameter JSON, image attachments, reasoning blocks, and provider token usage snapshots are flattened or omitted. Developers and researchers benchmarking models or evaluating agents often need the complete, unaltered message history in JSON format for replays, evaluations, or test harness integration.

Proposed Solution

  1. In source/commands/export.tsx:
    • Inspect args for --json or a filename ending in .json.
    • When JSON format is requested, serialize the Message[] array with session metadata (session date, provider, model, total tokens, session cwd).
    • Use atomic write to save the JSON export file.
  2. Example usage:
    • /export --json -> exports to nanocoder-chat-YYYY-MM-DD.json
    • /export benchmark-run.json

Alternatives Considered

Manually locating the internal .nanocoder-sessions storage files, but users often work with unsaved/ephemeral sessions or want to export directly from the active TUI.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • This feature aligns with the project's goals (local-first AI assistance)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions