#!/usr/bin/env python3
"""
Simple conversation import using your existing working memory system
No virtual environment dependencies required
"""
import json
import os
import sys
from pathlib import Path
from datetime import datetime
def simple_import():
"""Import conversations using direct file operations (no MCP dependencies)"""
print("š Simple Conversation Import")
print("============================")
# Check the conversations file
conversations_file = Path("data/conversations.json")
if not conversations_file.exists():
print(f"ā File not found: {conversations_file}")
return
# Get file info
file_size = conversations_file.stat().st_size
print(f"š File: {conversations_file}")
print(f"š Size: {file_size:,} bytes ({file_size/1024/1024:.1f} MB)")
# Read and analyze the JSON
print(f"\nš Analyzing JSON structure...")
try:
with open(conversations_file, 'r', encoding='utf-8') as f:
# Read first 1000 characters to understand structure
sample = f.read(1000)
print(f"š First 1000 characters:")
print("-" * 50)
print(sample)
print("-" * 50)
# Reset and parse the JSON
f.seek(0)
data = json.load(f)
print(f"\nā
JSON parsed successfully!")
print(f"š Root type: {type(data).__name__}")
if isinstance(data, list):
print(f"š¦ Array with {len(data)} items")
if len(data) > 0:
first_item = data[0]
print(f"š First item keys: {list(first_item.keys())}")
# Check if this looks like conversation data
if any(key in first_item for key in ['content', 'messages', 'conversation', 'text']):
print("ā
Looks like conversation data!")
print(f"š¬ Ready to import {len(data)} conversations")
elif 'uuid' in first_item and 'email_address' in first_item:
print("ā ļø This appears to be user profile data, not conversations")
print("š” Look for a different file with conversation content")
else:
print("š¤ Unknown data structure")
elif isinstance(data, dict):
print(f"š Object keys: {list(data.keys())}")
# Look for conversation arrays
conversation_keys = ['conversations', 'chats', 'messages', 'data']
found_conversations = None
for key in conversation_keys:
if key in data and isinstance(data[key], list):
found_conversations = data[key]
print(f"š¦ Found {len(found_conversations)} items in '{key}' key")
break
if found_conversations:
print(f"š¬ Ready to import {len(found_conversations)} conversations")
else:
print("š¤ No conversation arrays found")
except json.JSONDecodeError as e:
print(f"ā JSON parsing failed: {e}")
return
except Exception as e:
print(f"ā Error reading file: {e}")
return
print(f"\nš Analysis complete!")
def check_working_system():
"""Check if the memory system components are available"""
print("\nš§ Checking existing system...")
# Check for key files
key_files = [
"server_fastmcp.py",
"run_server.sh",
"mcp-config.json"
]
for file in key_files:
if Path(file).exists():
print(f"ā
{file} found")
else:
print(f"ā {file} missing")
# Check if MCP server is running
print(f"\nš” To import conversations into your working system:")
print(f" 1. Ensure MCP server is running: ./run_server.sh")
print(f" 2. Use Claude with MCP tools to add conversations")
print(f" 3. Or manually process the JSON data")
if __name__ == "__main__":
simple_import()
check_working_system()