# WeChat Viewer — 项目词典 面向 AI Agent 的领域术语定义。Agent 加载此文件以快速理解项目上下文,减少重复解释和 token 消耗。 ## 核心概念 - **wechat-viewer**: Flask Web 应用,运行在 Android/Termux 上,通过 sqlcipher 直接读取微信 EnMicroMsg.db,提供消息浏览、群聊日报、文章管线、自学习闭环等功能。 - **EnMicroMsg.db**: 微信本地加密数据库,通过 sqlcipher + 密钥解密访问。每个微信账号一个 DB。 - **sqlcipher**: SQLite 加密扩展,安装在 Termux 中。连接时需 PRAGMA key + cipher_compatibility=1 + cipher_page_size=1024。 ## 数据层 - **local_db.py**: 本地 SQLite 管理层(`config.LOCAL_DB`),存储加工后的数据:processed_messages, chat_summaries, articles/article_shares, daily_reports, report_images, hermes_jobs, learn_queue, learning_results, reply_whitelist。 - **wechat_db.py**: 原始微信 DB 读取层,通过 sqlcipher 直接查询 EnMicroMsg.db。 - **config.py**: 账号发现、密钥管理、DB 路径配置。多账号通过 `/data/data/com.tencent.mm/MicroMsg//EnMicroMsg.db` 自动发现。 ## Hermes 集成 - **_spawn_hermes_job()**: 统一子进程启动函数,所有 Hermes CLI 调用必须通过此函数。强制要求 `-s` 指定 skill。返回 task_id 追踪。 - **hermes_jobs 表**: 追踪所有 Hermes 子进程任务(task_id, job_type, job_name, status, log_file)。 - **子进程工具集**: hermes 子进程必须包含 `-t terminal,web,file` 三个工具集。 ## 学习管线 (6步闭环) - **learn_queue 表**: 学习队列,每篇待学习文章一行。status: pending_review → pending_learn → learning → learned/failed。 - **learning_results 表**: 学习结果记录,含 result_type (skill/memory/reference/todo/apply_audit)、verification_result、auto_applied 标记。 - **分类器** (`/api/learn/classify`): 对文章摘要评分(1-10),决定 learn_type 和路由。 - **学习执行器** (`/api/learn/execute`): Cron 每30分钟触发,扫描 pending_learn,执行 6步吸收 Loop。 - **_run_absorb()**: Step1-4(摘要→消化→验证→报告)。 - **_verify_and_apply()**: Step5 确定性验证。 - **_run_apply()**: Step6 知识应用审计。 ## 路由规则 - **/api/*** : JSON API - **/*** : HTML 页面模板 - 关键页面: `/` 首页, `/learn` 管线页, `/jobs` 任务追踪, `/reports` 日报, `/articles` 文章, `/chat/` 聊天详情, `/cron` 定时任务 ## 关键约束 - **Jinja2 反斜杠 Bug**: `