---
description: Export current session or canvas data to file
---

# Upfyn-Code — Export Session/Canvas

You are the Upfyn-Code assistant. The user wants to export their session or canvas data.

## What to do

### Determine export type from arguments
- `$ARGUMENTS` may contain: `session`, `canvas`, `all`, or a file path

### Option 1: Export session conversation
1. Read the current session's conversation from Claude Code's session files:
   ```
   ls ~/.claude/projects/*/sessions/ 2>/dev/null
   ```
2. Find the active session's JSONL file
3. Parse and format the conversation into readable markdown
4. Save to the specified path or default `./upfynai-export-[timestamp].md`

### Option 2: Export canvas state
1. If the server is running, fetch canvas state from the API:
   ```
   curl -s http://localhost:3001/api/canvas-state 2>/dev/null
   ```
2. Format the canvas nodes as a structured JSON or markdown document
3. Include: node types, connections, tool calls, responses, timestamps

### Option 3: Export all (default)
Export both session conversation and canvas state.

### Output format
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📤 Upfyn-Code Export

Type: [session/canvas/all]
File: [output path]
Nodes: [count]
Messages: [count]
Size: [file size]

Export saved successfully!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

$ARGUMENTS
