Phase 0-2: Schema cleanup, typed relations, event-driven automation
- Phase 0: AGENTS.md cleanup (dedup quotes, renumber sections, merge qmd) - Phase 1: typed relations (manage-relations.py, graph-search.py, check-staleness.py, detect-conflicts.py) - Phase 2: frontmatter validator, weekly lint, knowledge promotion, git hooks - Fix .gitignore to track tools/ and .githooks/ - Fix git remote URL (remove plaintext token) - New wiki pages: 504 pages, 34 raw sources
This commit is contained in:
@@ -0,0 +1,296 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
教育AI研究项目自动化配置脚本
|
||||
用于配置WorkBuddy自动化任务
|
||||
"""
|
||||
|
||||
import sys
|
||||
import json
|
||||
import datetime
|
||||
from pathlib import Path
|
||||
|
||||
def create_automation_config():
|
||||
"""创建自动化任务配置"""
|
||||
|
||||
# 获取当前日期和下周日期
|
||||
today = datetime.date.today()
|
||||
next_monday = today + datetime.timedelta(days=(7 - today.weekday()))
|
||||
|
||||
# 基础配置
|
||||
base_config = {
|
||||
"project_name": "教育AI研究",
|
||||
"project_path": str(Path("D:/TC_UP/2023card/projects/教育AI研究").resolve()),
|
||||
"created_date": today.isoformat(),
|
||||
"automations": []
|
||||
}
|
||||
|
||||
# 自动化任务配置
|
||||
automations = [
|
||||
{
|
||||
"id": "edu-ai-weekly-start",
|
||||
"name": "教育AI-周一研究启动",
|
||||
"description": "每周一启动新一周的教育AI研究,生成研究计划",
|
||||
"schedule_type": "recurring",
|
||||
"rrule": "FREQ=WEEKLY;BYDAY=MO;BYHOUR=9;BYMINUTE=0",
|
||||
"status": "ACTIVE",
|
||||
"cwds": [str(Path("D:/TC_UP/2023card").resolve())],
|
||||
"prompt": """启动本周'AI在教育领域应用'专题研究:
|
||||
|
||||
1. 使用GLM Coding Plan生成本周研究计划
|
||||
2. 研究主题按月度轮换:
|
||||
- 第1周:个性化学习系统
|
||||
- 第2周:智能评测技术
|
||||
- 第3周:教育机器人应用
|
||||
- 第4周:产业动态与政策
|
||||
|
||||
3. 输出文件命名:projects/教育AI研究/每周报告/{year}-W{week}-研究计划.md
|
||||
4. 包含以下内容:
|
||||
- 本周研究目标(具体可衡量)
|
||||
- 详细时间安排(每日任务)
|
||||
- 信息源推荐(知网、万方、Arxiv等)
|
||||
- 风险评估与应对
|
||||
- 产出物清单""",
|
||||
"output_template": "projects/教育AI研究/每周报告/{year}-W{week}-研究计划.md",
|
||||
"model_preference": "glm-coding",
|
||||
"estimated_tokens": 5000,
|
||||
"estimated_duration": "30分钟"
|
||||
},
|
||||
{
|
||||
"id": "edu-ai-weekly-report",
|
||||
"name": "教育AI-周五报告生成",
|
||||
"description": "每周五生成教育AI研究周报,整合本周发现",
|
||||
"schedule_type": "recurring",
|
||||
"rrule": "FREQ=WEEKLY;BYDAY=FR;BYHOUR=18;BYMINUTE=0",
|
||||
"status": "ACTIVE",
|
||||
"cwds": [str(Path("D:/TC_UP/2023card").resolve())],
|
||||
"prompt": """生成教育AI研究周报:
|
||||
|
||||
输入数据:本周收集的文献、机构、技术进展信息
|
||||
使用模板:projects/教育AI研究/templates/04-周报生成.md
|
||||
|
||||
报告结构要求:
|
||||
1. 执行摘要(本周研究概述、关键指标)
|
||||
2. 详细研究发现(文献、技术、机构、产业)
|
||||
3. 深度分析(趋势预测、挑战机遇)
|
||||
4. 知识库更新统计
|
||||
5. 下周研究建议
|
||||
|
||||
质量要求:
|
||||
- 数据准确,有可靠来源
|
||||
- 分析深入,有逻辑依据
|
||||
- 建议具体,可操作执行
|
||||
- 格式规范,符合模板""",
|
||||
"output_template": "projects/教育AI研究/每周报告/{year}-W{week}-研究报告.md",
|
||||
"model_preference": "glm-coding",
|
||||
"estimated_tokens": 8000,
|
||||
"estimated_duration": "45分钟"
|
||||
},
|
||||
{
|
||||
"id": "edu-ai-monthly-review",
|
||||
"name": "教育AI-月度研究回顾",
|
||||
"description": "每月末进行教育AI研究回顾和优化",
|
||||
"schedule_type": "recurring",
|
||||
"rrule": "FREQ=MONTHLY;BYMONTHDAY=-1;BYHOUR=20;BYMINUTE=0",
|
||||
"status": "ACTIVE",
|
||||
"cwds": [str(Path("D:/TC_UP/2023card").resolve())],
|
||||
"prompt": """进行教育AI研究月度回顾:
|
||||
|
||||
回顾周期:过去一个月(4周)
|
||||
回顾内容:
|
||||
1. 研究产出统计(文献、卡片、报告数量)
|
||||
2. 质量评估(准确性、完整性、时效性)
|
||||
3. 成本分析(API使用量、费用统计)
|
||||
4. 效率评估(研究耗时、产出密度)
|
||||
5. 问题识别与改进建议
|
||||
|
||||
输出要求:
|
||||
1. 月度研究报告(详细分析)
|
||||
2. 质量改进计划(具体措施)
|
||||
3. 下月研究优化建议(调整方案)
|
||||
4. 模板和流程更新建议""",
|
||||
"output_template": "projects/教育AI研究/每月回顾/{year}-{month}-回顾报告.md",
|
||||
"model_preference": "glm-coding",
|
||||
"estimated_tokens": 6000,
|
||||
"estimated_duration": "40分钟"
|
||||
},
|
||||
{
|
||||
"id": "edu-ai-knowledge-sync",
|
||||
"name": "教育AI-知识库同步",
|
||||
"description": "每周日同步更新知识库,确保信息一致性",
|
||||
"schedule_type": "recurring",
|
||||
"rrule": "FREQ=WEEKLY;BYDAY=SU;BYHOUR=22;BYMINUTE=0",
|
||||
"status": "ACTIVE",
|
||||
"cwds": [str(Path("D:/TC_UP/2023card").resolve())],
|
||||
"prompt": """同步教育AI研究知识库:
|
||||
|
||||
同步任务:
|
||||
1. 检查知识卡片一致性(概念定义、关联关系)
|
||||
2. 更新机构档案信息(最新动态、研究成果)
|
||||
3. 整合本周新增文献到文献库
|
||||
4. 验证跨文档引用和链接
|
||||
5. 生成知识库健康报告
|
||||
|
||||
输出要求:
|
||||
1. 同步完成确认报告
|
||||
2. 发现问题列表(如有)
|
||||
3. 知识库统计更新
|
||||
4. 维护建议""",
|
||||
"output_template": "projects/教育AI研究/知识库同步/{year}-W{week}-同步报告.md",
|
||||
"model_preference": "deepseek",
|
||||
"estimated_tokens": 4000,
|
||||
"estimated_duration": "25分钟"
|
||||
}
|
||||
]
|
||||
|
||||
base_config["automations"] = automations
|
||||
|
||||
# 计算预计总成本
|
||||
total_tokens_per_month = sum([
|
||||
a["estimated_tokens"] * 4 for a in automations if a["id"] != "edu-ai-monthly-review"
|
||||
]) + automations[2]["estimated_tokens"] # 月度回顾
|
||||
|
||||
# GLM成本估算(假设0.003元/token)
|
||||
glm_cost = total_tokens_per_month * 0.003
|
||||
|
||||
# DeepSeek成本估算(假设0.002元/token)
|
||||
deepseek_cost = 4000 * 4 * 0.002 # 知识库同步任务
|
||||
|
||||
base_config["cost_estimation"] = {
|
||||
"total_tokens_per_month": total_tokens_per_month,
|
||||
"glm_estimated_cost": round(glm_cost, 2),
|
||||
"deepseek_estimated_cost": round(deepseek_cost, 2),
|
||||
"total_estimated_cost": round(glm_cost + deepseek_cost, 2),
|
||||
"estimated_hours_per_month": 15 * 4 # 15小时/周 * 4周
|
||||
}
|
||||
|
||||
return base_config
|
||||
|
||||
def generate_workbuddy_commands(config):
|
||||
"""生成WorkBuddy自动化配置命令"""
|
||||
|
||||
commands = []
|
||||
commands.append("# WorkBuddy自动化配置命令")
|
||||
commands.append("# 教育AI研究项目")
|
||||
commands.append(f"# 生成时间:{datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
commands.append("")
|
||||
|
||||
for automation in config["automations"]:
|
||||
commands.append(f"## {automation['name']} ({automation['id']})")
|
||||
commands.append(f"# 描述:{automation['description']}")
|
||||
commands.append(f"# 计划:{automation['rrule']}")
|
||||
commands.append(f"# 状态:{automation['status']}")
|
||||
commands.append(f"# 模型偏好:{automation['model_preference']}")
|
||||
commands.append("")
|
||||
|
||||
# 生成automation_update命令
|
||||
cmd = f'automation_update(mode="suggested create", '
|
||||
cmd += f'name="{automation["name"]}", '
|
||||
cmd += f'prompt="{automation["prompt"]}", '
|
||||
cmd += f'cwds="{",".join(automation["cwds"])}", '
|
||||
cmd += f'status="{automation["status"]}", '
|
||||
cmd += f'scheduleType="{automation["schedule_type"]}", '
|
||||
cmd += f'rrule="{automation["rrule"]}")'
|
||||
|
||||
commands.append(cmd)
|
||||
commands.append("")
|
||||
|
||||
# 添加成本信息
|
||||
commands.append("## 成本估算")
|
||||
cost = config["cost_estimation"]
|
||||
commands.append(f"月度总tokens:{cost['total_tokens_per_month']:,}")
|
||||
commands.append(f"GLM估算成本:¥{cost['glm_estimated_cost']}")
|
||||
commands.append(f"DeepSeek估算成本:¥{cost['deepseek_estimated_cost']}")
|
||||
commands.append(f"总计估算成本:¥{cost['total_estimated_cost']}")
|
||||
commands.append(f"月度预计耗时:{cost['estimated_hours_per_month']}小时")
|
||||
commands.append("")
|
||||
|
||||
return "\n".join(commands)
|
||||
|
||||
def generate_readme_summary(config):
|
||||
"""生成README摘要"""
|
||||
|
||||
summary = []
|
||||
summary.append("# 自动化工作流配置")
|
||||
summary.append("")
|
||||
summary.append("## 已配置的自动化任务")
|
||||
summary.append("")
|
||||
|
||||
for automation in config["automations"]:
|
||||
summary.append(f"### {automation['name']}")
|
||||
summary.append(f"- **ID**:`{automation['id']}`")
|
||||
summary.append(f"- **计划**:{automation['rrule']}")
|
||||
summary.append(f"- **状态**:{automation['status']}")
|
||||
summary.append(f"- **模型**:{automation['model_preference']}")
|
||||
summary.append(f"- **输出**:{automation['output_template']}")
|
||||
summary.append("")
|
||||
|
||||
summary.append("## 使用说明")
|
||||
summary.append("")
|
||||
summary.append("### 手动启动任务")
|
||||
summary.append("```bash")
|
||||
summary.append("# 查看所有自动化任务")
|
||||
summary.append("python -c \"import sqlite3; conn=sqlite3.connect(r'C:\\Users\\hhhh2024\\AppData\\Roaming\\WorkBuddy\\automations\\automations.db'); cursor=conn.cursor(); cursor.execute('SELECT id, name, status FROM automations'); print(cursor.fetchall())\"")
|
||||
summary.append("")
|
||||
summary.append("# 手动触发任务")
|
||||
summary.append("# 使用WorkBuddy的automation_update工具")
|
||||
summary.append("```")
|
||||
summary.append("")
|
||||
summary.append("### 监控与维护")
|
||||
summary.append("1. **成本监控**:定期检查API使用量和费用")
|
||||
summary.append("2. **质量检查**:每周审核产出物质量")
|
||||
summary.append("3. **流程优化**:每月回顾并优化工作流程")
|
||||
summary.append("4. **备份管理**:定期备份自动化配置和产出物")
|
||||
|
||||
return "\n".join(summary)
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
|
||||
print("正在生成教育AI研究项目自动化配置...")
|
||||
|
||||
# 创建配置
|
||||
config = create_automation_config()
|
||||
|
||||
# 生成配置文件
|
||||
config_file = Path(__file__).parent.parent / "automation_config.json"
|
||||
with open(config_file, 'w', encoding='utf-8') as f:
|
||||
json.dump(config, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"✓ 配置文件已生成:{config_file}")
|
||||
|
||||
# 生成WorkBuddy命令
|
||||
commands = generate_workbuddy_commands(config)
|
||||
commands_file = Path(__file__).parent.parent / "workbuddy_commands.txt"
|
||||
with open(commands_file, 'w', encoding='utf-8') as f:
|
||||
f.write(commands)
|
||||
|
||||
print(f"✓ WorkBuddy命令已生成:{commands_file}")
|
||||
|
||||
# 生成README摘要
|
||||
summary = generate_readme_summary(config)
|
||||
summary_file = Path(__file__).parent.parent / "AUTOMATION_README.md"
|
||||
with open(summary_file, 'w', encoding='utf-8') as f:
|
||||
f.write(summary)
|
||||
|
||||
print(f"✓ 自动化README已生成:{summary_file}")
|
||||
|
||||
# 输出关键信息
|
||||
print("\n" + "="*60)
|
||||
print("自动化配置摘要")
|
||||
print("="*60)
|
||||
print(f"项目路径:{config['project_path']}")
|
||||
print(f"配置时间:{config['created_date']}")
|
||||
print(f"自动化任务数量:{len(config['automations'])}")
|
||||
print(f"月度估算成本:¥{config['cost_estimation']['total_estimated_cost']}")
|
||||
print(f"月度估算耗时:{config['cost_estimation']['estimated_hours_per_month']}小时")
|
||||
print("="*60)
|
||||
|
||||
print("\n下一步操作:")
|
||||
print("1. 查看 workbuddy_commands.txt 文件中的自动化配置命令")
|
||||
print("2. 在WorkBuddy中执行这些命令来创建自动化任务")
|
||||
print("3. 定期检查 AUTOMATION_README.md 了解自动化任务状态")
|
||||
print("4. 监控 automation_config.json 中的成本估算")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user