import json
import os

data = {
    "skill_name": "keping-advanced",
    "version": "2.2.0",
    "description": "高级课评生成Skill v2.2 - 支持学期周数自动计算（仅用于后端课程主题匹配）、课程主题自动匹配、三段式课评生成、自动双轨保存（班级汇总+个人档案）",
    "triggers": ["/课评", "/keping", "/写课评", "生成课评"],
    "semester_config": {
        "baseline_date": "2026-03-02",
        "week_calculation": "Floor((current_date - baseline) / 7) + 1",
        "total_weeks": 20,
        "current_week": 10,
        "current_date": "2026-05-09"
    },
    "course_mapping": {
        "发现世界": {"prefix": "DISC", "week_mapping": {str(i): f"DISC-{i:03d}" for i in range(1, 21)}},
        "SPIKE": {"prefix": "SPIKE", "week_mapping": {str(i): f"SPIKE-{i:03d}" for i in range(1, 21)}},
        "AI03": {"prefix": "AI03", "week_mapping": {str(i): f"AI03-{i:03d}" for i in range(1, 21)}}
    },
    "workflow": {"steps": [
        {"id": "step1", "name": "读取学生用户画像并确定称呼方式", "action": "read_student_profile", "input": ["学生姓名", "班级"], "output": ["气质类型", "学习风格", "核心优势", "待发展能力", "历史表现模式", "display_name(课评用称呼)"], "file_pattern": "memory/student/{班级}/{学生名}/用户画像.md", "name_processing": {"priority": ["小名/昵称", "去姓称名", "叠字称呼", "全名"], "rules": {"小名/昵称": "画像中有填写则优先使用", "去姓称名": "双字名且无小名时，去掉姓氏（如：梁昕乔→昕乔）", "叠字称呼": "单字名且无小名时，叠字化（如：张昊→昊昊）", "全名": "特殊要求时使用"}}},
        {"id": "step2", "name": "读取课评风格规则（全年龄段统一）", "action": "read_style_rules", "input": ["年龄段"], "output": ["字数要求", "三段式结构", "语言风格", "禁用词汇", "Emoji规范"], "file_mapping": {"all_ages": ".claude/rules/10-style.md"}},
        {"id": "step3", "name": "计算周数并读取本节课教案内容", "action": "read_lesson_content_with_week", "input": ["日期", "班级", "课程代码(可选)"], "output": ["周数", "课程代码", "课程主题", "核心知识点", "教学目标"], "week_calculation": {"baseline": "2026-03-02", "formula": "Floor((date - baseline) / 7) + 1"}, "auto_mapping": True, "file_pattern": "memory/lesson/**/{课程代码}.md"},
        {"id": "step4", "name": "读取该学生近10次历史课评", "action": "read_history_reviews", "input": ["学生姓名", "班级"], "output": ["最近10次课评", "能力发展趋势", "进步轨迹", "反复问题"], "file_pattern": "memory/student/{班级}/{学生名}/历史课评记录.md", "limit": 10},
        {"id": "step5", "name": "结合教师提供的本节课表现", "action": "parse_current_performance", "input": ["表现描述", "情绪", "对比"], "output": ["关键行为词", "情绪状态", "与常态差异"]},
        {"id": "step6", "name": "生成180-350字三段式个性化课评（使用display_name称呼，不显示周数）", "action": "generate_evaluation", "input": ["step1-5的所有数据", "display_name(课评用称呼)", "课程主题", "核心知识点"], "output": ["课评文本"], "theme_association": True, "rules": {"word_count": {"min": 180, "max": 350, "target": 250, "note": "弹性范围：精简版180-220字，标准版220-280字，详细版280-350字"}, "paragraph_count": 3, "structure": {"paragraph_1": {"name": "课程知识点", "word_range": "30-55字", "emoji_count": 1}, "paragraph_2": {"name": "课堂细节（掌握+环节+亮点）", "word_range": "100-220字（弹性）", "emoji_count": "1-3"}, "paragraph_3": {"name": "课后建议", "word_range": "30-55字", "emoji_count": 1}}, "modules": ["课程知识点（兴趣度）", "掌握程度（学习表现）", "课程环节与目标达成", "成长亮点", "课后建议"], "week_number_in_content": False, "name_usage": {"use_display_name": True, "display_name_source": "step1确定的称呼（小名/去姓/叠字）", "full_name_forbidden": True}, "emoji_usage": {"enabled": True, "total_count": {"min": 3, "max": 5, "ideal": "3-5"}, "rules": {"paragraph_1_课程知识点": {"count": 1, "recommended": ["🔍", "💡", "⚙️"], "note": "根据课程主题自动适配"}, "paragraph_2_课堂细节": {"count": "1-3", "recommended": ["💪", "✨", "📈", "🌟", "😊", "🤝"], "note": "根据课堂情节亮点数量灵活适配"}, "paragraph_3_课后建议": {"count": 1, "recommended": ["🏠", "🔧"], "note": "根据建议内容适配"}}, "principles": ["每段末尾添加emoji", "表情与内容情绪一致", "总计3-5个", "第2段可根据亮点数量使用2-3个表情"]}, "personalization": {"活泼型": "突出创意和参与热情", "谨慎型": "肯定尝试勇气", "平和型": "强调稳定进步", "敏感型": "强调支持和情绪管理", "慢热型": "认可渐入佳境的过程"}}},
        {"id": "step7", "name": "自动双轨保存（班级汇总+个人档案）", "action": "save_evaluation_dual_track", "outputs": {"class_summary": {"path": "memory/class-evaluation-summary/第{周数}周/{班级}.md", "priority": 1, "required": True, "content": "本周所有学生课评汇总（含出勤统计）"}, "personal_archive": {"path": "memory/student/{班级}/{学生名}/历史课评记录.md", "priority": 2, "required": False, "content": "个人课评记录（时间倒序，最新在上）", "on_failure": "加入待补存队列，下次生成前自动补存"}}, "student_type_handling": {"正式学生": "双轨保存（班级汇总+个人档案）", "本班补课": "双轨保存（班级汇总+个人档案）", "跨班级补课": "自动双轨保存（补课班级汇总+原班级个人档案）", "体验学生": "仅班级汇总", "缺课学生": "仅记录缺席"}, "auto_save": True, "no_confirmation_needed": True}
    ]},
    "input_templates": {"single_quick": {"format": "日期:{date} 班级:{class} {name}:{performance} [情绪:{emotion}]", "example": "日期:4月2日 班级:发现世界-周四19点 乔乔:知道这个主题，话题多，搭建快 情绪:开心"}, "single_detailed": {"format": "yaml", "fields": ["日期", "班级", "学生", "表现", "情绪", "对比"]}, "batch": {"format": "markdown_table", "header": ["学生", "核心表现", "情绪"]}},
    "quality_standards": {"word_count": {"min": 180, "max": 350, "ranges": {"精简版": {"min": 180, "max": 220, "trigger": "输入简洁，仅包含基本行为描述"}, "标准版": {"min": 220, "max": 280, "trigger": "输入有具体细节或1-2个亮点"}, "详细版": {"min": 280, "max": 350, "trigger": "输入有精彩瞬间、多个亮点或特殊表现"}}}, "paragraph_count": {"min": 3, "max": 3, "note": "三段式结构：课程知识点+课堂细节+课后建议"}, "emoji_usage": {"enabled": True, "count": {"min": 3, "max": 5, "ideal": "3-5"}, "style_mapping": {"幼儿(2.5-6岁)": "温暖活泼（🔍💪✨🏠）", "小学低(6-8岁)": "简洁专业（💡📈🏠）", "小学中高(8-10岁)": "专业竞技感（⚙️📈🏠）"}, "check_items": ["第1段末尾有1个课程主题相关emoji", "第2段末尾有1-3个课堂情节相关emoji", "第3段末尾有1个家庭延伸相关emoji", "总计3-5个emoji", "表情与内容情绪匹配"]}, "forbidden_words": ["宝贝", "小天才", "最棒", "无敌", "超级厉害", "完美", "秒杀", "碾压", "大神"], "forbidden_patterns": ["比.*小朋友.*", "其他.*不好", "最差", "最慢", "最笨"], "name_usage_check": {"priority": ["小名/昵称", "去姓称名", "叠字称呼"], "forbidden": ["全名（除非家长要求）"], "check_items": ["课评中使用的是display_name（小名/去姓/叠字）", "未使用全名（除非有特殊要求）", "谐音姓名已纠正", "单字名已叠字化"]}, "required_elements": ["课程知识点（体现兴趣度）", "掌握程度（体现学习表现）", "课程环节与目标达成", "成长亮点（纵向对比）", "课后建议（可操作的家庭活动）"]},
    "data_sources": {"student_profile": "memory/student/{班级}/{学生名}/用户画像.md", "history_reviews": "memory/student/{班级}/{学生名}/历史课评记录.md", "lesson_content": "memory/lesson/**/{课程代码}.md", "semester_weeks": ".claude/rules/15-semester-weeks.md", "style_rules": ".claude/rules/10-style.md", "workflow_rules": ".claude/rules/20-workflow.md", "shorthand_rules": ".claude/rules/21-shorthand.md", "student_mgmt_rules": ".claude/rules/22-student-mgmt.md", "student_rules": ".claude/rules/30-student.md", "output_format_preschool": ".claude/rules/50-output-format-preschool.md", "output_format_elementary": ".claude/rules/51-output-format-elementary.md"},
    "output_paths": {"class_summary": "memory/class-evaluation-summary/第{周数}周/{班级}.md", "personal_archive": "memory/student/{班级}/{学生名}/历史课评记录.md"},
    "error_handling": {"date_not_found": {"message": "请输入日期，如：4月2日", "action": "prompt_for_date"}, "profile_not_found": {"message": "未找到学生画像，使用通用模板继续。建议后续建立画像以获得更个性化课评。", "action": "continue_with_default"}, "name_not_found": {"message": "无法识别学生姓名，请检查姓名是否正确或建立画像档案。", "action": "prompt_for_name", "homophone_correction": {"enabled": True, "confidence_threshold": 0.8, "message": "检测到可能的谐音输入 '{输入}'，是否纠正为 '{建议}'？"}}, "nickname_not_set": {"message": "学生画像中未设置小名/昵称，将使用去姓称名或叠字称呼。", "action": "use_fallback_name", "fallback_order": ["去姓称名", "叠字称呼", "全名"]}, "lesson_not_found": {"message": "未找到课程教案，请手动输入知识点或补充教案。", "action": "prompt_for_manual_input"}, "insufficient_history": {"message": "历史课评不足10次，使用全部可用记录。", "action": "use_available_records"}, "word_count_short": {"message": "字数偏短，建议补充具体事例。", "action": "suggest_expansion"}, "class_summary_save_failed": {"message": "班级汇总保存失败，正在重试...", "action": "retry_3_times", "fallback": "显示错误提示，提供手动重试按钮"}, "personal_archive_save_failed": {"message": "个人档案保存失败，已加入待补存队列。", "action": "add_to_compensation_queue", "fallback": "下次生成课评前自动补存，或教师输入'补存'手动触发"}},
    "created_at": "2026-03-25",
    "updated_at": "2026-05-09"
}

def main():
    base_dir = os.path.dirname(os.path.abspath(__file__))
    config_path = os.path.join(base_dir, '..', '.claude', 'skills', 'keping-advanced', 'config.json')
    with open(config_path, 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=2)
    print("config.json updated successfully")

if __name__ == '__main__':
    main()
