import sys
sys.path.insert(0, 'src')
sys.stdout.reconfigure(encoding='utf-8')

from unify_profiles import *

# Test 1: Old list format (余韫)
file_path = r'.claude\memory\class\发现世界-周六09点\余韫\profile.md'
print('=== 测试1: 旧版列表格式 ===')
with open(file_path, 'r', encoding='utf-8') as f:
    text = f.read()
fmt = detect_format(text)
print(f'检测格式: {fmt}')
data = parse_old_list_format(text, file_path)
print(f'姓名: {data["name"]}')
print(f'昵称: {data["nickname"]}')
print(f'气质: {data["temperament"]}')
print(f'优势: {data["strengths"]}')
print(f'弱点: {data["weaknesses"]}')
print(f'教学建议数: {len(data["teaching_tips"])}')
print(f'成长记录数: {len(data["growth_records"])}')
new_text = generate_new_profile(data, file_path)
print('新格式预览(前30行):')
for line in new_text.split('\n')[:30]:
    print(line)

print('\n\n=== 测试2: 新结构但标题错误 ===')
file_path2 = r'.claude\memory\class\发现世界-周六09点\胡翰铭\profile.md'
with open(file_path2, 'r', encoding='utf-8') as f:
    text2 = f.read()
fmt2 = detect_format(text2)
print(f'检测格式: {fmt2}')
new_text2 = fix_wrong_title(text2, file_path2)
print('新标题:', new_text2.split('\n')[0])

print('\n=== 测试3: 独特格式(赖韵恬) ===')
file_path3 = r'.claude\memory\class\发现世界-周六19点\赖韵恬\profile.md'
with open(file_path3, 'r', encoding='utf-8') as f:
    text3 = f.read()
fmt3 = detect_format(text3)
print(f'检测格式: {fmt3}')