Skip to content

API Reference parrot.knowledge.wiki.obsidian_sync

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.wiki.obsidian_sync

View source

Obsidian sync — mirror LLM Wiki planes into an Obsidian vault (one-way).

sync_obsidian projects wiki pages from one or more planes (the local project plane and/or declared federated namespaces) into an Obsidian vault as markdown notes with YAML frontmatter. What moves and where it lands is driven by :class:~parrot.knowledge.wiki.project.ObsidianSyncConfig (obsidian_sync in .parrot/wiki.json): the selected page categories and the vault folder each category maps onto.

Design points:

  • One-way, wiki -> vault. The vault-to-wiki direction already exists (wikitoolkit build vault mode / a vault-kind namespace); this module is the reverse projection, so agents' knowledge becomes browsable, linkable Obsidian notes.
  • Marker-guarded. Every synced note carries wiki_sync: <wiki_name> frontmatter. Prune only ever deletes notes carrying that marker — hand-written notes are never touched.
  • Deterministic and idempotent. Note rendering is stable; an unchanged page produces byte-identical text and is skipped, so a repeated run reports unchanged instead of rewriting the vault.
  • Edges become wikilinks. asserted/extracted edges between two synced pages render as a ## Related section of [[wikilinks]], so the wiki graph is visible in Obsidian's graph view.

Writes go through the shared vault interface (:func:parrot.interfaces.obsidian.create_vault_backend) — the same engine behind ObsidianToolkit — never raw file I/O.

Alias BaseWikiStore

Re-exported from parrot.knowledge.wiki.store.BaseWikiStore.

Attribute LOCAL_PLANE

Alias ObsidianSyncConfig

Re-exported from parrot.knowledge.wiki.project.ObsidianSyncConfig.

Class ObsidianSyncError

Raised when the sync cannot run (no vault, unbuilt plane, unknown namespace) — always before the first note is touched — or, wrapping an unexpected mid-apply failure, after the partial report has been audited to the bookkeeper.

Class ObsidianSyncReport

Outcome of one :func:sync_obsidian run.

Fields:

Field Type Default Description
vault str '' Resolved vault root the notes were written into.
root_folder str '' Vault folder holding the mirror.
namespaces list[str] Plane names actually synced (skips excluded).
created int 0 Notes written that did not exist in the vault.
updated int 0 Notes rewritten because the page changed.
unchanged int 0 Notes skipped because the rendered text was identical.
pruned int 0 Marker-carrying notes deleted for vanished/deselected pages.
skipped_namespaces list[str] Human-readable name: reason lines for requested namespaces that could not be opened.
dry_run bool False Whether this report describes a dry run (nothing applied).
details list[str] Per-note lines for verbose CLI output.

Attribute SYNC_ID_KEY

Attribute SYNC_MARKER_KEY

Attribute SYNC_NAMESPACE_KEY

Attribute SYNC_SCOPE_KEY

Alias WikiBookkeeper

Re-exported from parrot.knowledge.wiki.bookkeeper.WikiBookkeeper.

Alias WikiProjectConfig

Re-exported from parrot.knowledge.wiki.project.WikiProjectConfig.

Alias category_dir

Re-exported from parrot.knowledge.wiki.export.category_dir.

Alias flatten_concept_id_for_filename

Re-exported from parrot.knowledge.okf.utils.flatten_concept_id_for_filename.

Function folder_for_category

Vault folder a category maps onto.

An explicit override wins — including an EMPTY override, meaning "no per-category subfolder" (mirrors how an empty root_folder is honored). Otherwise the pluralized category directory (sanitized: the category value is page data, not config).

folder_for_category(category: str, sync_config: ObsidianSyncConfig) -> str

Parameter Type Default Description
category str
sync_config ObsidianSyncConfig

Returns: str

Alias load_effective_config

Re-exported from parrot.knowledge.wiki.project.load_effective_config.

Alias load_global_registry

Re-exported from parrot.knowledge.wiki.project.load_global_registry.

Attribute logger

Alias merge_namespaces

Re-exported from parrot.knowledge.wiki.project.merge_namespaces.

Function note_relpath

Vault-relative path of the note mirroring one page.

Layout: <root_folder>/[<namespace>/]<category folder>/<flat id>.md — the local plane writes directly under the root folder, foreign namespaces each get their own (sanitized) subtree; empty segments are skipped. Known caveat (shared with the OKF export convention): two distinct concept_ids whose flattened stems collide within one folder resolve to the same note path (last write wins), and a local page id equal to a namespace's folder name would clash file-vs-dir.

note_relpath(sync_config: ObsidianSyncConfig, namespace: str, category: str, concept_id: str) -> str

Parameter Type Default Description
sync_config ObsidianSyncConfig
namespace str
category str
concept_id str

Returns: str

Function project_scope

Stable scope identity written as :data:SYNC_SCOPE_KEY.

wiki_name alone is not unique (it defaults to "codebase"), so the resolved repo root is digested in. Moving the repo changes the scope, which fails SAFE: old notes are simply never pruned again.

project_scope(root: Path, wiki_name: str) -> str

Parameter Type Default Description
root Path
wiki_name str

Returns: str

Function render_note

Render one wiki page as a deterministic Obsidian note.

render_note(page: dict[str, Any], related: list[tuple[str, str, str]], *, wiki_name: str, scope: str, namespace: str) -> str

Parameter Type Default Description
page dict[str, Any] Full page dict (dump_pages shape, body included).
related list[tuple[str, str, str]] (link_target, display_title, rel) rows for the ## Related section; targets are vault paths sans .md.
wiki_name str Written as the :data:SYNC_MARKER_KEY marker value.
scope str Project scope identity (:func:project_scope) written as :data:SYNC_SCOPE_KEY — the prune ownership guard.
namespace str Source plane name (local or a namespace).

Returns: str — The full note text (frontmatter + body + related section).

Alias resolve_namespaces

Re-exported from parrot.knowledge.wiki.federation.resolve_namespaces.

Alias resolve_vault_dir

Re-exported from parrot.knowledge.wiki.project.resolve_vault_dir.

Function sync_obsidian

Mirror the selected wiki planes into the Obsidian vault.

sync_obsidian(root: Path, *, vault: str | Path | None = None, namespaces: Sequence[str] | None = None, categories: Sequence[str] | None = None, prune: bool | None = None, dry_run: bool = False, env: str | None = None) -> ObsidianSyncReport

Parameter Type Default Description
root Path Repository root.
vault str | Path | None None Vault root override; falls back to the obsidian_sync config, then the project vault_dir, then the project root when it is itself a vault.
namespaces Sequence[str] | None None Plane selector override (local, declared namespace names, or all); defaults to the configured obsidian_sync.namespaces.
categories Sequence[str] | None None Category filter override; defaults to the configured obsidian_sync.categories (empty = every category).
prune bool | None None Prune override; defaults to obsidian_sync.prune.
dry_run bool False Compute and return the report; write nothing.
env str | None None Wiki environment override (WIKI_ENV resolution otherwise).

Returns: ObsidianSyncReport — The sync report.

Raises:

  • ObsidianSyncError — No vault is configured (or the configured one does not exist), the local plane is not built, the selector names an undeclared namespace — or, wrapping the cause, a run aborted mid-apply (the partial report is audited first).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally