obsidian-markdown
by Realtyxxx
README.md
# Obsidian Markdown for Antigravity
Antigravity 2.0 Desktop App plugin (`obsidian-markdown`) for viewing, navigating, and editing **Obsidian Flavored Markdown** (`.md`), **Excalidraw** (`.excalidraw.md` / `.excalidraw`), and **JSON Canvas 1.0** (`.canvas`) files via an MCP App (`ui://obsidian-markdown/viewer.html`).
为 Antigravity 2.0 桌面端提供 Obsidian Flavored Markdown、Excalidraw 绘图和 JSON Canvas 白板预览与源码编辑支持的 MCP App 插件。
---
## Features / 核心特性
- **Obsidian Flavored Markdown (`.md`)**
- Collapsible YAML Frontmatter **Properties** card (`tags`, `aliases`, `cssclasses`, dates, checkboxes, and clickable `[[wikilink]]` values)
- All 13 canonical **Callout** types + aliases (`> [!note]`, `> [!tip]+`, `> [!warning]-`), including foldable `<details>` callouts and nested callouts (`> > [!info]`)
- Code-safe `[[wikilinks]]`, `![[embeds]]`, `==highlights==`, `%%comments%%` stripping, `#tags`, and `^block-id` anchors (ignores fenced code blocks and inline backticks)
- Table-escaped modifiers (`[[Note#Heading\|Alias]]`, `![[image.png\|300]]`, `![[doc.pdf#page=2\|800]]`)
- Note / heading / block transclusions (`![[Note#Heading]]`, `![[Note#^block]]`) with recursion depth and cycle guards
- Inlined **KaTeX** math (`$...$` / `$$...$$`, `.woff2` fonts embedded), **Mermaid** diagrams with automatic light/dark theme sync, **PrismJS** syntax highlighting + copy button, and inline **PDF** rendering (`pdfjs-dist` in CSP-safe fake-worker main-thread mode)
- **Excalidraw (`.excalidraw.md` & `.excalidraw`)**
- Lightweight RoughJS SVG pan/zoom viewer supporting `json` and `compressed-json` (`lz-string`) drawing blocks, bound text, arrowheads, embedded images, and dark-mode stroke adaptation
- **JSON Canvas 1.0 (`.canvas`)**
- Interactive infinite pan/zoom canvas with dot grid, `group` / `text` / `file` / `link` nodes, preset colors `1`–`6`, cubic Bezier edges, and lazy file/image previews
- **Dual/Raw Editing & Vault Browser**
- CodeMirror 6 raw editor (`Preview | Split | Raw` for Markdown, `Drawing | Split | Source` for Excalidraw, `Canvas | JSON` for Canvas)
- `Save` button and `Cmd+S` / `Ctrl+S` write-back via `com.google.antigravity/resources/write` when permitted by the host
- **Antigravity-Native Quote & Comment**:
- Text selection floating pill (`Comment` `⌘⌥M` | `Quote` `⌘L`) in both Preview and Raw editor modes
- Component hover actions on Markdown blocks (callouts, Mermaid diagrams, code blocks, tables, images, PDFs, headings, properties), Canvas nodes, and Excalidraw drawings
- Anchored comment highlights and clickable comment badges (with edit/delete card popover) synced to the chat composer via `app.updateModelContext` (`Send to Chat` also available when `hostCapabilities.message` is present)
- Empty / `aux_pane` / `global` **Obsidian Vault Browser** with live search, type filters, vault root filter chips (`basename` + full wrapped path & copy button in Vaults modal), and inline preview drawer
---
## Build & Install / 构建与安装
```bash
git clone https://github.com/Realtyxxx/antigravity-obsidian-markdown.git
cd antigravity-obsidian-markdown
npm install
npm run typecheck
npm test
npm run build
npm run install:local
```
What each step does:
- `npm run build` (`scripts/build.mjs`):
- Bundles `src/server/mcp-server.ts` into `dist/server.mjs` (Node ESM)
- Bundles `src/app/main.ts`, `src/app/styles.css`, PrismJS light/dark themes, and KaTeX CSS (with `.woff2` fonts inlined as `data:` URIs) into a single self-contained `dist/viewer.html` and enforces the `< 10 MiB` Antigravity resource limit
- `npm run install:local` (`scripts/install-local.mjs`):
- Symlinks `~/.gemini/config/plugins/obsidian-markdown` to your local clone without modifying `~/.gemini/config/plugins/config.json`
- Verify the plugin manifest from the repository root with:
```bash
agy plugin validate .
```
- Reload Antigravity / refresh MCP servers, then open any `.md` or `.canvas` file and select **Obsidian Markdown**, or launch **Obsidian Vault** from the aux pane / global launcher.
---
## Vault Resolution / Vault 路径解析
Because Antigravity passes an opaque `antigravity-file://<uuid>/<basename>` URI on `file` launch, the MCP server resolves vault context and relative links across configured roots:
1. **Discovered default roots**:
- `OBSIDIAN_VAULT_PATHS` environment variable (path-delimited list)
- Registered Obsidian vaults in `~/Library/Application Support/obsidian/obsidian.json`
- MCP client `roots/list` workspace roots (when exposed by the host)
- Non-home / non-root `process.cwd()` fallback
2. **Custom roots**:
- Added/removed via the **Vaults** modal (`obsidian_manage_vaults`) and persisted in `${PLUGIN_DATA}/vaults.json`
3. **Context & target resolution order**:
- Context matching (`obsidian_resolve_context`): matches filename candidates using SHA-256 content hash (raw and `\r\n`-normalized), falling back to line-overlap scoring for edited/unsaved buffers
- Target resolution (`obsidian_resolve_targets`):
1. Relative to the current note's directory
2. Co-located `./assets/<basename>` and `./images/<basename>`
3. Relative to the matched Vault root
4. Shortest-path / closest-hop match across configured Vault roots
---
## Limitations (Antigravity 2.0) / 已知限制
- **`fileView` vs Chat & Artifacts**: The `file` entrypoint (`extensions: [".md", ".canvas"]`, which also captures `*.excalidraw.md`) applies when opening files in Antigravity `fileView`. Antigravity plugins cannot override the built-in Chat message markdown renderer or Artifacts preview cards.
- **Read-Only Contexts**: Saving (`com.google.antigravity/resources/write`) is enabled only when `hostContext["com.google.antigravity/resources"]?.write` is truthy (local, non-cloud conversations outside `/brain/`). When absent, the toolbar displays a **Read-only** badge and disables `Save`.
- **Sandbox & Bundle Constraints**: Antigravity enforces a strict iframe CSP (`default-src 'none'`, no `worker-src`, no `'unsafe-eval'`), blocks persistent `localStorage` / `IndexedDB` across frame closures (vault config lives server-side in `${PLUGIN_DATA}/vaults.json`), and caps `ui://` HTML resources at `10 MiB`.
---
## License
MIT License — see [LICENSE](./LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues