export type ProjectMemoryKind = 'project' | 'rule' | 'decision' | 'reference' | 'feedback' | 'convention' | 'module' | 'lesson'; export type ExtractedProjectMemory = { title: string; kind: ProjectMemoryKind; body: string; sourceArtifact: string; }; export type ProjectMemoryWrite = { memory: ExtractedProjectMemory; filePath: string; content: string; }; export type ProjectMemoryExtractPlan = { apply: boolean; projectRoot: string; primaryMemoryDir: string; backupPolicy: 'project-memory-primary-artifact-backup'; extractedMemories: ExtractedProjectMemory[]; plannedWrites: ProjectMemoryWrite[]; }; export type ProjectMemoryExtractResult = ProjectMemoryExtractPlan & { writtenFiles: string[]; }; export type ProjectMemoryExtractSummary = { apply: boolean; projectRoot: string; primaryMemoryDir: string; backupPolicy: 'project-memory-primary-artifact-backup'; extractedCount: number; plannedWrites: Array<{ filePath: string; title: string; kind: ProjectMemoryKind; sourceArtifact: string; }>; writtenFiles: string[]; }; export type ProjectMemoryBackupSummary = { apply: boolean; projectRoot: string; artifactWorkspacePath: string; primaryMemoryDir: string; backupMemoryDir: string; plannedCopies: ProjectMemoryCopy[]; copiedFiles: string[]; }; export type ProjectMemoryCopy = { sourcePath: string; targetPath: string; }; export type ProjectMemoryBackupPlan = { apply: boolean; projectRoot: string; artifactWorkspacePath: string; primaryMemoryDir: string; backupMemoryDir: string; plannedCopies: ProjectMemoryCopy[]; }; export type ProjectMemoryBackupResult = ProjectMemoryBackupPlan & { copiedFiles: string[]; }; export type StoredProjectMemory = { name: string; title: string; kind: ProjectMemoryKind; sourceArtifact: string | null; body: string; filePath: string; }; export type ProjectMemoryReadResult = { projectRoot: string; memoryDir: string; total: number; byKind: Record; memories: StoredProjectMemory[]; }; export type MemoryIndexEntry = { name: string; kind: ProjectMemoryKind; description: string; sourcePath: string; sourceArtifact: string | null; updatedAt: string; }; export type MemoryIndex = { version: 1; updatedAt: string; hot: Record; warm: Record; }; export type ExtractSessionMemoriesOptions = { projectRoot: string; sessionId: string; apply?: boolean; }; export type ExtractSessionMemoriesResult = { apply: boolean; projectRoot: string; sessionId: string; primaryMemoryDir: string; memoryIndexPath: string; scannedFiles: number; extractedCount: number; writtenFiles: string[]; updatedIndex: boolean; }; type ExtractPlanOptions = { projectRoot: string; artifactPaths: string[]; apply?: boolean; }; type BackupPlanOptions = { projectRoot: string; artifactWorkspacePath: string; apply?: boolean; }; /** Exported for guard tests + tooling that needs to enumerate the valid * set without duplicating the literal. Single source of truth. */ export declare const VALID_PROJECT_MEMORY_KINDS: readonly ProjectMemoryKind[]; export declare function readMemoryIndex(projectRoot: string): MemoryIndex | null; export declare function extractSessionMemories(options: ExtractSessionMemoriesOptions): ExtractSessionMemoriesResult; export declare function extractStableProjectMemories(content: string, sourceArtifact: string): ExtractedProjectMemory[]; export declare function createProjectMemoryExtractPlan(options: ExtractPlanOptions): ProjectMemoryExtractPlan; export declare function executeProjectMemoryExtract(options: ExtractPlanOptions): ProjectMemoryExtractResult; export declare function createProjectMemoryBackupPlan(options: BackupPlanOptions): ProjectMemoryBackupPlan; export declare function executeProjectMemoryBackup(options: BackupPlanOptions): ProjectMemoryBackupResult; export declare function summarizeProjectMemoryExtractResult(result: ProjectMemoryExtractResult): ProjectMemoryExtractSummary; export declare function summarizeProjectMemoryBackupResult(result: ProjectMemoryBackupResult): ProjectMemoryBackupSummary; /** * Ensure `.peaks/memory/` and its `index.json` exist for a project, with * the same full-shape empty index the generator emits when there are zero * memories. Idempotent — safe to call on every skill activation. * * Why this exists: before this helper, `.peaks/memory/` was only created * by `extractSessionMemories` when at least one memory markdown was being * written, and `index.json` was only emitted by the generator when at * least one markdown was on disk. Stock projects therefore had no * `.peaks/memory/` directory and no index, even after `peaks project * memories` was read. Bootstrap closes that cold-start gap. * * This function is fail-open for the same reason the rest of the * presence layer is fail-open: a failure here must NOT block skill * activation. Any error is swallowed and surfaced only via the returned * boolean. Callers that need the truth should check the result. */ export declare function ensureMemoryBootstrap(projectRoot: string): boolean; export declare function readProjectMemories(projectRoot: string): ProjectMemoryReadResult; export interface ProjectMemoryShowResult { projectRoot: string; memoryDir: string; name: string; body: string; filePath: string; updatedAt: string | null; kind: ProjectMemoryKind | null; title: string; /** Whether the on-disk body bytes are returned (true) or a compact form (false). */ pretty: boolean; } /** * Read a single project memory's full body by name. Returns null when * the memory does not exist. The on-disk body is returned verbatim * (pretty). The CLI layer applies `formatMdCompact` when `format: 'compact'` * is requested. Slice 023 (R3). */ export declare function readProjectMemoryBody(projectRoot: string, name: string): ProjectMemoryShowResult | null; export {};