3.5 KiB
3.5 KiB
知识图谱重组 + MegaMemory 嵌入模型部署
日期: 2026-05-26 变更摘要: 重组两个知识库,去重规则知识,补全项目架构知识;部署 Xenova 嵌入模型使 MegaMemory 语义搜索可用
动机
完美实现原则(全局CLAUDE.md)、Nexus实现原则、Nexus强制标准纪律三者 80% 内容重叠,知识图谱里再存一遍纯属冗余——规则已在 CLAUDE.md 每次session自动加载- 知识图谱完全缺少项目架构知识(模块、技术栈、数据流、部署拓扑),无法通过语义搜索快速定位模块
- MegaMemory 的
understand语义搜索一直报 "fetch failed"——嵌入模型未下载
变更内容
server-memory(全局跨项目)
- 删除 9 个重复规则实体: 完美实现原则、Nexus实现原则、Nexus强制标准纪律、ThreeIronRules、FourDimensionChecklist、ProblemReportFormat、AuditEnforcementMechanism、MandatoryFileModificationFlow、LineWalkAudit8Steps
- 保留 2 个非规则实体: uzuma(用户偏好)、Nexus-Production-Server(服务器信息)
MegaMemory(项目级架构知识)
- 创建 19 个概念节点: 项目顶层 + 9个架构模块 + 4个基础设施子模块 + 3个认证子模块 + 2个独立配置
- 创建 30 条关系边: 项目→模块(connects_to/depends_on)、模块→子模块(implements)、数据流→基础设施(connects_to/depends_on)
- 生成 384 维嵌入向量: 所有节点通过 Xenova/all-MiniLM-L6-v2 本地模型生成嵌入
嵌入模型部署
- 从 hf-mirror.com 下载 Xenova/all-MiniLM-L6-v2 量化 ONNX 模型(23MB)
- 先通过远程 Linux 服务器下载,再 SCP 传回本地
- 模型放置到
node_modules/@xenova/transformers/models/本地路径
知识图谱结构
nexus-project (feature)
├── nexus-backend (module) — FastAPI Clean Architecture 4层
├── nexus-frontend (module) — Tailwind+Alpine.js 12页面
├── nexus-infra (module) — SSH池+Redis+Telegram+WebSocket
│ ├── nexus-ssh-pool (component)
│ ├── nexus-redis (component)
│ ├── nexus-telegram (component)
│ └── nexus-websocket (component)
├── nexus-auth (feature) — JWT+TOTP+Agent API Key
│ ├── nexus-jwt (component)
│ ├── nexus-totp (component)
│ └── nexus-agent-auth (component)
├── nexus-dataflow (pattern) — 心跳→Redis→MySQL+WS+TG
├── nexus-gates (config) — 7门控部署
├── nexus-sync (feature) — 4种同步模式
├── nexus-database (module) — 14表+加密+脱敏
└── nexus-deploy (config) — 3层守护+SCP部署
nexus-production (config) — 服务器连接信息
uzuma (config) — 用户偏好
涉及文件
.megamemory/knowledge.db— MegaMemory SQLite 数据库(19节点+30边+19嵌入).megamemory/populate.py— 数据导入脚本(一次性使用)~/.cache/xenova/transformers/— Xenova 模型缓存node_modules/@xenova/transformers/models/Xenova/all-MiniLM-L6-v2/— 本地模型文件
是否需迁移/重启
- 重启 Claude Code 后 MegaMemory MCP 会自动连接并使用已下载的模型
验证方式
megamemory stats显示 19 nodes / 30 edgesmegamemory list_roots返回 3 个根节点megamemory understand "认证系统"返回 JWT/TOTP/Agent认证(相似度 >0.15)megamemory understand "心跳数据流转"返回数据流概念(相似度 >0.50)- server-memory
read_graph只剩 2 个实体(uzuma + Nexus-Production-Server)