Skip to main content

Class: MarkdownImporter

Defined in: packages/agentos/src/cognition/memory/io/MarkdownImporter.ts:53

Imports Markdown files from a directory into a Brain.

Usage:

const importer = new MarkdownImporter(brain);
const result = await importer.import('/path/to/vault');
console.log(result.imported, result.skipped);

Extended by

Constructors

Constructor

new MarkdownImporter(brain): MarkdownImporter

Defined in: packages/agentos/src/cognition/memory/io/MarkdownImporter.ts:57

Parameters

brain

Brain

The target Brain to import into.

Returns

MarkdownImporter

Properties

brain

protected readonly brain: Brain

Defined in: packages/agentos/src/cognition/memory/io/MarkdownImporter.ts:57

The target Brain to import into.

Methods

import()

import(sourceDir, options?): Promise<ImportResult>

Defined in: packages/agentos/src/cognition/memory/io/MarkdownImporter.ts:72

Recursively walk sourceDir, parse every .md file, and insert traces.

Non-Markdown files are silently ignored. Files that fail to parse are recorded in result.errors and processing continues.

Parameters

sourceDir

string

Directory to recursively scan for .md files.

options?

Pick<ImportOptions, "dedup">

Returns

Promise<ImportResult>

ImportResult with counts of imported, skipped, and errored items.


postProcess()

protected postProcess(_filePath, _frontmatter, _body, _result, _traceId): Promise<void>

Defined in: packages/agentos/src/cognition/memory/io/MarkdownImporter.ts:100

Post-process a parsed file before it is inserted into the database.

The base implementation is a no-op. ObsidianImporter overrides this to extract [[wikilinks]] and #tags.

Parameters

_filePath

string

Absolute path of the source file.

_frontmatter

TraceFrontmatter

Parsed front-matter data.

_body

string

Markdown body content.

_result

ImportResult

Mutable result accumulator.

_traceId

string

The ID assigned (or taken from front-matter) for this trace.

Returns

Promise<void>