Skip to main content

Function: ensureMemoryDir()

ensureMemoryDir(workspaceDir): string

Defined in: packages/agentos/src/cognition/substrate/memory/wiki/migrateMemoryMd.ts:19

Guarantee a memory/ directory exists in the workspace and return its path.

  • If memory/ already exists, return it untouched (idempotent).
  • Else if MEMORY.md exists, seed memory/index.md from it. MEMORY.md is left on disk as a fallback.
  • Else create an empty memory/ with a stub index.md.

Always creates .meta/index.json if absent. Never modifies or deletes MEMORY.md.

Parameters

workspaceDir

string

The per-agent workspace directory.

Returns

string

Absolute path to the memory/ directory.