#!/usr/bin/env bash
# AnyFS Cross-Client Session Resume Examples
# Transfer sessions between different AI agent harnesses.

set -euo pipefail

# ── Example 1: Claude Code -> Codex CLI (Native Resume) ───────
# Full fidelity: Codex gets the complete tool call history

# Find your Claude Code session transcript
ls ~/.claude/projects/-home-user-myproject/
# -> abc123-def456.jsonl

# Resume in Codex CLI with native format
anyfs resume \
  ~/.claude/projects/-home-user-myproject/abc123-def456.jsonl \
  --target codex-cli \
  --source claude-code \
  --workspace /home/user/myproject

# ── Example 2: Codex CLI -> Claude Code (Native Resume) ───────

anyfs resume \
  codex-session.jsonl \
  --target claude-code \
  --workspace .

# ── Example 3: Claude Code -> Cursor (Context Injection) ──────
# Cursor doesn't support native transcript import
# Context summary is injected into .cursor/rules/resumed-session.mdc

anyfs resume \
  session.jsonl \
  --target cursor \
  --context-only \
  --workspace .

# ── Example 4: Claude Code -> Gemini CLI (Context Injection) ──
# Summary written to GEMINI.md

anyfs resume \
  session.jsonl \
  --target gemini-cli \
  --context-only \
  --workspace .

# ── Example 5: Full Cross-Client Collaboration Flow ───────────
# User A works in Claude Code, shares session with User B who continues in Codex

# User A: Capture and share the session transcript
anyfs quick-share \
  --workspace . \
  --namespaces process \
  --password "TeamPassword123"
# -> Returns: gateway_url + password

# User B: Download, decrypt, and resume
anyfs init
anyfs share open \
  "https://storage.anyfs.ai/raw/<cid>" \
  --password "TeamPassword123"
# -> Decrypts to process.json

# User B: Resume the session in their preferred harness
anyfs resume process.json \
  --target codex-cli \
  --workspace .

# ── Example 6: Auto-detect source format ──────────────────────
# Omit --source and let AnyFS detect the format automatically

anyfs resume transcript.jsonl --target claude-code --workspace .
