Export conversation to file.
| 15 | |
| 16 | |
| 17 | class ExportCommand(UnifiedCommand): |
| 18 | """Export conversation to file.""" |
| 19 | |
| 20 | @property |
| 21 | def name(self) -> str: |
| 22 | return "export" |
| 23 | |
| 24 | @property |
| 25 | def aliases(self) -> list[str]: |
| 26 | return ["save-chat"] |
| 27 | |
| 28 | @property |
| 29 | def description(self) -> str: |
| 30 | return "Export conversation to markdown or JSON" |
| 31 | |
| 32 | @property |
| 33 | def help_text(self) -> str: |
| 34 | return """ |
| 35 | Export the current conversation to a file. |
| 36 | |
| 37 | Usage: |
| 38 | /export markdown [filename] - Export as formatted Markdown |
| 39 | /export json [filename] - Export as structured JSON |
| 40 | |
| 41 | Default filenames: chat-<session_id>.md / .json |
| 42 | """ |
| 43 | |
| 44 | @property |
| 45 | def modes(self) -> CommandMode: |
| 46 | return CommandMode.CHAT |
| 47 | |
| 48 | @property |
| 49 | def parameters(self) -> list[CommandParameter]: |
| 50 | return [ |
| 51 | CommandParameter( |
| 52 | name="format", |
| 53 | type=str, |
| 54 | required=False, |
| 55 | help="Export format: markdown or json (default: markdown)", |
| 56 | ), |
| 57 | CommandParameter( |
| 58 | name="filename", |
| 59 | type=str, |
| 60 | required=False, |
| 61 | help="Output filename (optional)", |
| 62 | ), |
| 63 | ] |
| 64 | |
| 65 | async def execute(self, **kwargs) -> CommandResult: |
| 66 | """Execute the export command.""" |
| 67 | from mcp_cli.chat.exporters import MarkdownExporter, JSONExporter |
| 68 | |
| 69 | chat_context = kwargs.get("chat_context") |
| 70 | if not chat_context: |
| 71 | return CommandResult(success=False, error="No chat context available.") |
| 72 | |
| 73 | # Parse arguments |
| 74 | args = kwargs.get("args", "").strip().split() |
no outgoing calls