OpenCode


opencode session list -n 1 --format json
opencode export <sessionID> > "opencode-conversation-$(date +%Y-%m-%d_%H-%M-%S).json"



SESSION_ID=$(opencode session list -n 1 --format json | jq -r '.[0].id // empty')
if [ -z "$SESSION_ID" ]; then
  echo "No sessions found" >&2
  exit 1
fi
opencode export "$SESSION_ID" > "opencode-conversation-$(date +%Y-%m-%d_%H-%M-%S).json"
echo "Exported session $SESSION_ID"