数据目录

wescode 的数据目录结构与存储分层。


数据根目录

所有数据统一在一个根目录下(XDG 规范):

平台路径
macOS~/Library/Application Support/wescode/
Linux~/.local/share/wescode/
环境变量WESCODE_DATA_DIR

Dev 模式和正式构建共享同一目录,不分裂。


目录树

$XDG_DATA_HOME/wescode/
│
│ ── Go 引擎数据 ──────────────────
├── hypervisor.db          # Cell 注册表
├── cells/ws-{hash}/       # per-workspace Cell
│   ├── meta.db            # Cell 元数据
│   ├── sessions.db        # 会话(Memory / Sessions)
│   ├── state.db           # 运行时状态(Traces / Observe)
│   ├── index/             # CKG 代码知识图谱索引
│   ├── knowledge/         # KB 知识库文件
│   ├── skills/            # Tier C skill 包
│   ├── .scratch/          # 临时计算域(Run 结束后 GC)
│   └── .plans/            # plan artifact
├── db/wescode_auth.db     # 登录 session(跨 workspace 共享)
├── crashes/               # 崩溃日志
├── logs/wescode.log       # Go 后端日志
│
│ ── Electron UI 数据 ────────────
├── User/                  # 用户设置 / globalStorage
├── extensions/            # 已安装扩展
├── logs/{timestamp}/      # Electron 窗口日志
├── logs/wescode-chat.log  # Chat 管道诊断
├── Cache/                 # Chromium 缓存(可安全删除)
└── code.lock              # 单实例锁

配置目录

$XDG_CONFIG_HOME/wescode/
├── config.yaml            # 用户可编辑配置

配置文件按需创建——首次 saveConfig 时写入;不存在时用 DefaultConfig。


存储分层

引擎层(wesgine 管理)

文件内容隔离
hypervisor.dbCell 注册表全局
meta.dbCell 元数据per-Cell
sessions.dbMemory + Sessionsper-Cell
state.dbTraces + Observeper-Cell

应用层(wescode 管理)

文件内容隔离
wescode_auth.db登录 session跨 workspace
wescode-app.dbgroup 表per-workspace

CKG 索引

文件内容隔离
index/code.db代码知识图谱per-workspace

CKG 是可重建数据——有完善的 wipe-rebuild 策略。


Cell 与 Workspace 的映射

workspace 路径 → sha256(canonicalize(root))[:4] → "ws-a1b2c3d4"

切换 workspace = 换 Cell = 整个数据面一起换:


迁移策略

INV-MIGRATE-01

Schema 变更通过 MigrationStep 管理:


相关文档