UNPKG

@dollhousemcp/mcp-server

Version:

DollhouseMCP - A Model Context Protocol (MCP) server that enables dynamic AI persona management from markdown files, allowing Claude and other compatible AI assistants to activate and switch between different behavioral personas.

89 lines 3.59 kB
/** * MemoryStorageLayer - IStorageLayer implementation for multi-directory memory scanning. * * Memories use pure YAML across a multi-directory layout: * system/ — System-provided memories * adapters/ — Adapter-specific memories * YYYY-MM-DD/ — User-created date-folder memories * (root) — Legacy root-level memories * * Reuses the same internal components as ElementStorageLayer (MetadataIndex, * StorageManifest, FileStorageBackend) but with fundamentally different scan * logic: multi-directory enumeration + _index.json cold-start persistence. */ import type { IStorageLayer } from './IStorageLayer.js'; import type { IStorageBackend } from './IStorageBackend.js'; import type { ElementIndexEntry, ManifestDiffResult } from './types.js'; import type { FileOperationsService } from '../services/FileOperationsService.js'; export interface MemoryStorageLayerOptions { /** Absolute path to the memories directory */ memoriesDir: string; /** Minimum milliseconds between full scans (default: 1000) */ scanCooldownMs?: number; /** Override the storage backend (useful for testing) */ storageBackend?: IStorageBackend; /** Debounce interval for _index.json writes (default: 2000) */ indexDebounceMs?: number; /** File filter predicate (e.g., exclude backup files) */ fileFilter?: (filename: string) => boolean; } export declare class MemoryStorageLayer implements IStorageLayer { private readonly fileOps; private readonly backend; private readonly manifest; private readonly index; private readonly indexFile; private readonly memoriesDir; private readonly scanCooldownMs; private readonly fileFilter?; private lastScanTimestamp; private scanInProgress; private coldStartDone; constructor(fileOps: FileOperationsService, options: MemoryStorageLayerOptions); scan(): Promise<ManifestDiffResult>; listSummaries(): Promise<ElementIndexEntry[]>; getIndexedPaths(): Promise<string[]>; /** * Deduplicate index entries by normalized name. * When the same memory appears in multiple date folders, keep the one * with the highest mtimeMs (most recently modified). * * Issue #654: Same memory files duplicated across ~150 date folders * inflated counts from ~750 unique to ~3,100+ loaded memories. */ private deduplicateByName; getPathByName(name: string): string | undefined; hasCompletedScan(): boolean; notifySaved(relativePath: string, absolutePath: string): Promise<void>; notifyDeleted(relativePath: string): void; invalidate(): void; clear(): void; /** * Return index entries where autoLoad === true, sorted by priority ascending. * Pure in-memory — does NOT trigger a scan. */ getAutoLoadEntries(): ElementIndexEntry[]; /** * Full disk scan of all subdirectories + write _index.json. */ rebuildIndex(): Promise<void>; /** * Flush pending _index.json write and release resources. */ dispose(): Promise<void>; /** * Cold start: try to restore from _index.json, then run incremental scan. * Falls back to full rebuild if index is missing/corrupt. */ private coldStart; /** * Discover all subdirectories to scan. * Returns ['system', 'adapters', ...dateFolders, ''] where '' = root. */ private discoverSubdirectories; /** * Perform a full incremental scan across all subdirectories. */ private performScan; } //# sourceMappingURL=MemoryStorageLayer.d.ts.map