Skip to main content

Class: MarkdownImporter

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

Imports Markdown files from a directory into a SqliteBrain.

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/memory/io/MarkdownImporter.ts:59

Parameters

brain

SqliteBrain

The target SqliteBrain to import into.

Returns

MarkdownImporter

Properties

brain

protected readonly brain: SqliteBrain

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

The target SqliteBrain to import into.

Methods

import()

import(sourceDir): Promise<ImportResult>

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

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.

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/memory/io/MarkdownImporter.ts:102

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>