Class ObsidianExporter

Exports memory traces as an Obsidian-compatible Markdown vault.

Usage:

const exporter = new ObsidianExporter(brain);
await exporter.export('/path/to/obsidian-vault');

Hierarchy (view full)

Constructors

Methods

  • The front-matter fields of a trace's file, which MarkdownImporter reads back: its id, type, scope, strength, tags and creation time, and its scope id as scopeId when the trace is filed under one. A trace filed under '' writes no scopeId, and its import files it under ''. A trace of a Brain that holds the encoded scope-id form writes scopeIdForm: encoded, so an import takes its scope id as it is written. A trace a second user filed on another user's session writes that user's id as turnUserId, so its import files it as that user's trace, which a delete of the user's traces finds.

    Parameters

    • trace: TraceRow

      The trace row.

    • tags: string[]

      The trace's tags, parsed.

    Returns Record<string, unknown>

  • Determine the relative file path for a trace within the output directory.

    Default: {scope}/{type}/{id}.md. Each of the three must be a safe file or folder name (see pathNameProblem), or the trace is refused. Whatever a subclass returns, the export writes the file only when its resolved path lies inside the output directory.

    Parameters

    • trace: TraceRow

      The trace row.

    Returns string

    Relative path string (no leading slash).

    Throws

    When the trace's scope, type or id is not a safe name; the export reports such a trace in its result instead of writing it.

  • Export all memory traces as Obsidian-flavoured .md files.

    Pre-fetches all knowledge-edge relationships into an in-memory cache, then delegates to the parent export() method. Directory creation, file writing and the checks on each trace's path are handled there; only buildFileContent is overridden.

    Parameters

    • outputDir: string

      Root directory to write the Obsidian vault into.

    • Optional options: ExportOptions

      Optional export configuration.

    Returns Promise<ExportResult>

    The traces left out, with the reason for each.

  • Build Obsidian-flavoured Markdown for a trace.

    Additions over the base implementation:

    • Tags are rendered as #tagName inline hashtags in the body.
    • Related knowledge nodes (found via knowledge_edges) are rendered as [[Node Label]] wikilinks appended at the bottom of the note.

    Parameters

    • trace: TraceRow

      Parsed trace row.

    Returns string

    Full Markdown file content with front-matter.

Properties

brain: Brain

The Brain instance to read from.