import { join } from 'node:path';
import { mkdir } from 'node:fs/promises';

const TOPICS = ['project', 'user', 'reference'] as const;
export type MemoryTopic = (typeof TOPICS)[number];

export function getMemoryRoot(projectRoot: string): string {
  return join(projectRoot, '.boocode', 'memory');
}

export function getTopicDir(root: string, topic: MemoryTopic): string {
  return join(root, topic);
}

export async function ensureMemoryScaffold(root: string): Promise<void> {
  await Promise.all(TOPICS.map((t) => mkdir(join(root, t), { recursive: true })));
}
