AgentSkillsCN

Storage Abstraction Layer

为 Obsidian、Notion 以及本地文件系统提供统一的存储接口。

SKILL.md
--- frontmatter
name: Storage Abstraction Layer
description: Unified storage interface for Obsidian, Notion, and local file systems

Storage Abstraction Layer

Unified interface for saving notes across different storage backends


Storage Selection

javascript
function get_storage_backend() {
  config = Read("km-config.json")
  return config?.storage?.primary || "local"
}

🛑 MCP 도구 우선 사용 규칙 (CRITICAL)

code
┌─────────────────────────────────────────────────────┐
│ 🛑 CRITICAL: MCP 도구 사용 강제                      │
│                                                      │
│ MCP 도구가 사용 가능한 환경에서는 반드시 MCP 사용!    │
│                                                      │
│ ❌ 잘못된 예:                                        │
│    - write_to_file("vault/note.md", content)         │
│                                                      │
│ ✅ 올바른 예:                                        │
│    - mcp_obsidian_create_note(path, content)         │
└─────────────────────────────────────────────────────┘

Backend Mapping (Antigravity/Gemini CLI)

FeatureObsidianNotionLocal
Createmcp_obsidian_create_notemcp_notion_API-post-pagewrite_to_file
Searchmcp_obsidian_search_vaultmcp_notion_API-post-searchN/A
Readmcp_obsidian_read_notemcp_notion_API-get-block-childrenread_file
Path formatRelative to vaultDatabase/Page IDFile system path
WikilinksSupportedConverted to mentionsSupported

참고: Antigravity는 MCP 도구 이름에 싱글 언더스코어(_)를 사용합니다.

MCP 도구 사용 가이드 (Obsidian)

작업도구명설명
노트 생성mcp_obsidian_create_note새 노트 생성
노트 검색mcp_obsidian_search_vaultVault 내 키워드 검색
노트 읽기mcp_obsidian_read_note노트 내용 읽기
노트 목록mcp_obsidian_list_notes폴더 내 노트 목록

Unified Save Function

javascript
// Antigravity/Gemini CLI용 (싱글 언더스코어 사용)
function save_note(relativePath, content) {
  backend = get_storage_backend()
  config = Read("km-config.json")

  switch (backend) {
    case "obsidian":
      // ⚠️ 반드시 MCP 도구 사용!
      return mcp_obsidian_create_note({
        path: relativePath,
        content: content
      })

    case "notion":
      return mcp_notion_API_post_page({
        parent: { page_id: config.storage.notion.parentPageId },
        properties: { title: [{ text: { content: getTitle(relativePath) } }] }
      })

    case "local":
    default:
      fullPath = `${config.storage.local.outputPath}/${relativePath}`
      return write_to_file(fullPath, content)
  }
}

Path Normalization

javascript
function normalize_path(path) {
  // Windows backslash → forward slash
  path = path.replace(/\\/g, '/')

  // Remove leading slash for relative paths
  path = path.replace(/^\//, '')

  return path
}

Verification (CRITICAL)

After every save operation:

code
□ Did the tool actually execute? (no JSON-only output!)
□ Did we receive a success response?
□ Verify with Glob that file exists