Skip to content

Feature Request: Add /export command to export chat history to markdown #6

@will-lamerton

Description

@will-lamerton

Use Case

Users often want to save their chat sessions for reference, documentation, or sharing with colleagues. Currently, there's no built-in way to export the conversation history from Nanocoder, requiring users to manually copy-paste from the terminal or use external tools.

Proposed Solution

Add a new built-in command /export that exports the current chat history to a markdown file with the following features:

  • Command syntax: /export [filename] (defaults to nanocoder-chat-YYYY-MM-DD-HH-MM-SS.md if no filename provided)
  • Format: Clean markdown with proper syntax highlighting for code blocks
  • Content: Include user messages, assistant responses, and tool outputs in a readable format
  • Metadata: Add session timestamp, provider/model used, and token counts as frontmatter
  • File location: Save to current working directory or allow specifying a path

Example output structure:

---
session_date: 2024-01-15T10:30:00Z
provider: ollama
model: llama2:7b
total_tokens: 1250
---

# Nanocoder Chat Export

## User
How do I add a new feature to this project?

## Assistant
I'll help you add a new feature. Let me first examine the project structure...

[tool_use: read_file]
...

Alternatives Considered

  • Manual copy-paste (current workaround, but loses formatting and is tedious)
  • External terminal logging tools (doesn't integrate with the chat flow)
  • Auto-saving all sessions (privacy concerns, storage overhead)

Additional Context

This would complement the existing command system in src/core/commands/ and could be implemented as a built-in command similar to /help or /models. The export functionality could leverage the existing message history that's already maintained by the ChatSession class.

Implementation Notes

  • Should respect the existing message types defined in src/types/core.ts
  • Could integrate with the configuration system for default export paths
  • Should handle large chat histories gracefully
  • Consider adding options for filtering (e.g., exclude tool outputs, only code blocks)

This feature would enhance Nanocoder's usability for documentation workflows and knowledge sharing, making it easier for users to preserve and share their AI-assisted coding sessions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions