Skip to content

feat(v0.19.0): devkit_vault_export + data freedom - #38

Merged
juice094 merged 2 commits into
mainfrom
feat/v0.19.0-vault-export
May 14, 2026
Merged

juice094 merged 2 commits into
mainfrom
feat/v0.19.0-vault-export

Conversation

@juice094

Copy link
Copy Markdown
Owner

Sprint D — Vault 导出与可逃生性验证

消除"Vendor Lock-in"焦虑,让用户敢把 devbase 当主力知识库工具。

新增功能

功能 说明
devkit_vault_export MCP Tool 第 66 个 Tool,导出 Vault 到指定目录
devbase vault export [dir] CLI 命令行直接导出,默认带时间戳目录名
完整性校验 导出时自动检测断链 wikilink、 frontmatter 解析错误
资产复制 非 Markdown 文件(图片等)原样复制

返回结构示例

{
  "success": true,
  "exported_files": 42,
  "total_bytes": 128000,
  "broken_links": { "count": 3, "issues": [...] },
  "frontmatter_errors": { "count": 0, "issues": [] }
}

技术决策

  • 零外部依赖:复用已有 walkdir、devbase_vault_wikilink::extract_wikilinks、frontmatter::extract_frontmatter
  • PARA 结构保留:相对目录结构原样复制,Obsidian/Logseq 可直接打开
  • 安全路径:通过 VaultClient trait 暴露,不直接操作文件系统

验证

  • cargo test --all-targets → 464 passed
  • cargo clippy --all-targets -D warnings → 0 warnings
  • cargo fmt --check → clean

juice094 added 2 commits May 14, 2026 12:23
When repair=true:
- Deletes orphan Tantivy documents via sync_index_to_db_at
- Re-indexes missing repos one by one via KnowledgeClient::run_index
- Returns repair_actions summary (orphans_deleted, missing_reindexed, missing_failed)

Safety:
- Releases pool connection (drop(conn)) before reindexing to avoid r2d2 deadlock
- Gracefully handles reindex failures per-repo without aborting entire repair

Verification: cargo test --lib 446 passed, clippy clean
Adds devkit_vault_export MCP tool (66th tool) and CLI command:
- Copies all .md files preserving PARA directory structure
- Validates wikilink targets exist (reports broken links)
- Validates frontmatter YAML parseability
- Copies non-markdown assets as-is
- Returns statistics: exported_files, total_bytes, broken_links, frontmatter_errors

New module: src/vault/export.rs
- Zero external dependencies beyond walkdir (already in tree)
- Reuses devbase_vault_wikilink::extract_wikilinks and frontmatter::extract_frontmatter

CLI usage:
  devbase vault export                    → auto-named dir with timestamp
  devbase vault export ./my-backup        → explicit output directory

Also adds export_vault() to VaultClient trait and AppContext impl.

Verification: cargo test --all-targets 464 passed, clippy -D warnings clean
@juice094
juice094 force-pushed the feat/v0.19.0-vault-export branch from 6870f29 to 9e11c7d Compare May 14, 2026 04:54
@juice094
juice094 merged commit 88b57f2 into main May 14, 2026
6 checks passed
@juice094
juice094 deleted the feat/v0.19.0-vault-export branch June 6, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant