跳到主要内容
Markdown DB Engine

Workspace 协作

Workspace 是可以交给 Obsidian、编辑器或 Agent 自由修改的 Markdown 目录。Runtime Database 不监听 Workspace;所有变更都需要先生成 Merge Plan,再显式 Apply。

创建 Workspace

Server 没有运行时,可以 Embedded Export:

md-db-engine workspace export \
  --database ./content.mddb \
  --workspace ./obsidian-workspace \
  --json

Server 正在运行时,使用同一命令的 Remote 形式,避免 Writer Lock:

md-db-engine workspace export \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --workspace ./obsidian-workspace \
  --json

迁移完成的 Vault 已经是 Based Workspace,不需要再次 Export。直接在 Obsidian 中打开它即可。

在 Obsidian 创建新文章

新文件只需要显式提供目标 collection

---
collection: documents
status: draft
---
 
# A new document

merge plan 会生成缺失的 UUIDv7 id,并从文件名生成 titlemerge apply 成功后,这两个字段会写回文件。没有 collection 的模板、日报和普通 Markdown 保持不受管理。

推荐把以下内容保存为 Obsidian Template,并按照自己的业务字段扩展:

---
collection: documents
status: draft
tags: []
---
 

查看和提交变化

Server 运行时,所有命令使用 Remote 入口:

md-db-engine workspace status \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --workspace ./obsidian-workspace \
  --json
 
md-db-engine merge plan \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --workspace ./obsidian-workspace \
  --json
 
md-db-engine merge apply \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --workspace ./obsidian-workspace \
  --yes \
  --json

Server 停止时,把 --endpoint--credentials 替换为 --database ./content.mddb

接收 Runtime 更新

应用或其他 Workspace 提交之后,执行 workspace update。没有冲突的 Runtime 变化会进入当前 Workspace;本地未提交修改不会被静默覆盖。

md-db-engine workspace update \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --workspace ./obsidian-workspace \
  --json

如果 Plan 返回冲突或诊断,先修改文件或选择冲突结果,然后重新生成 Plan。不要删除 .mddb/ 来绕过冲突;它保存删除判断和三方比较所需的签名基线。