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

from unify_class_summaries import *

# Test 1: V2 format (old)
file_path = r'.claude\memory\class\发现世界-周四19点\summaries\20260417_DISC-007_班级反馈.md'
print('=== 测试V2旧格式 ===')
file_info = extract_file_info(file_path)
print(f'文件信息: {file_info}')

with open(file_path, 'r', encoding='utf-8') as f:
    text = f.read()
fmt = detect_format(text)
print(f'检测格式: {fmt}')
print(f'周数: {extract_week(text)}')
print(f'主题: {extract_theme(text)}')

feedbacks = extract_v2_feedbacks(text)
print(f'学生课评数: {len(feedbacks)}')
for fb in feedbacks:
    print(f'  - {fb["name"]}: {fb["content"][:50]}...')

overall = extract_overall(text)
print(f'整体情况(前100字): {overall[:100]}')

new_text = v2_to_v1(text, file_info)
print('\n新格式预览(前40行):')
for line in new_text.split('\n')[:40]:
    print(line)

print('\n\n=== 测试V1最新格式(应跳过) ===')
file_path2 = r'.claude\memory\class\发现世界-周四19点\summaries\20260514_DISC-011_班级反馈.md'
with open(file_path2, 'r', encoding='utf-8') as f:
    text2 = f.read()
print(f'格式: {detect_format(text2)}')
print(f'应跳过: {is_new_format(text2)}')