obsidian-vault-crud
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseObsidian Vault CRUD
Obsidian Vault 增删改查(CRUD)
Status: Active
Author: Richard Fremmerlid
Domain: Obsidian Integration
Depends On: (WP05)
obsidian-markdown-mastery状态: 已启用
作者: Richard Fremmerlid
领域: Obsidian 集成
依赖: (WP05)
obsidian-markdown-masteryCore Mandate
核心使命
This skill provides the disk I/O layer for all agent interactions with the Obsidian Vault. It does NOT handle syntax parsing (that belongs to ). Instead, it ensures that every file write is:
obsidian-markdown-mastery- Atomic — via POSIX from a
os.rename()staging file.tmp - Locked — via an advisory file at the vault root
.agent-lock - Conflict-aware — via comparison before/after read
mtime - Lossless — via for frontmatter (never PyYAML)
ruamel.yaml
本技能为所有与Obsidian Vault交互的Agent提供磁盘I/O层支持。它不负责语法解析(该功能属于),而是确保每一次文件写入都满足以下要求:
obsidian-markdown-mastery- 原子性——通过POSIX的方法,从
os.rename()临时文件重命名实现.tmp - 锁定机制——通过库根目录下的建议性锁定文件实现
.agent-lock - 冲突感知——通过读取前后的(修改时间)对比实现
mtime - 无损性——使用处理前置元数据(绝不使用PyYAML)
ruamel.yaml
Available Commands
可用命令
Read a Note
读取笔记
bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py read --file <path>bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py read --file <path>Create a Note
创建笔记
bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py create --file <path> --content <text> [--frontmatter key=value ...]bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py create --file <path> --content <text> [--frontmatter key=value ...]Update a Note
更新笔记
bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py update --file <path> --content <text>bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py update --file <path> --content <text>Append to a Note
追加内容到笔记
bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py append --file <path> --content <text>bash
python plugins/obsidian-integration/skills/obsidian-vault-crud/scripts/vault_ops.py append --file <path> --content <text>Safety Guarantees
安全保障
Atomic Write Protocol
原子写入协议
- Write content to
<target>.agent-tmp - Verify the file was written completely
.agent-tmp - — atomic on POSIX
os.rename('<target>.agent-tmp', '<target>') - If any step fails, the is cleaned up
.agent-tmp
- 将内容写入临时文件
<target>.agent-tmp - 验证文件已完全写入
.agent-tmp - — 在POSIX系统上此操作是原子性的
os.rename('<target>.agent-tmp', '<target>') - 若任意步骤失败,自动清理文件
.agent-tmp
Advisory Lock Protocol
建议性锁定协议
- Before any write batch: create
<vault_root>/.agent-lock - After write batch completes: remove
.agent-lock - Other agents check for before writing
.agent-lock - This is advisory (does not block Obsidian UI)
- 在任意批量写入操作前:创建文件
<vault_root>/.agent-lock - 批量写入操作完成后:删除文件
.agent-lock - 其他Agent在写入前会检查文件
.agent-lock - 此为建议性锁定(不会阻塞Obsidian界面)
Concurrent Edit Detection
并发编辑检测
- Capture before reading
os.stat(file).st_mtime - Before writing, check again
st_mtime - If mtime changed → another process edited the file → ABORT
- 读取前记录(文件修改时间)
os.stat(file).st_mtime - 写入前再次检查
st_mtime - 若修改时间发生变化→说明其他进程已编辑该文件→终止操作
Frontmatter Handling
前置元数据处理
- Uses (NOT
ruamel.yaml) to preserve comments, indentation, and array stylesPyYAML - Ensures Dataview and Obsidian Properties remain intact
- 使用(而非
ruamel.yaml)来保留注释、缩进和数组格式PyYAML - 确保Dataview和Obsidian属性保持完整