import type { Project } from './project-types.js'; /** Result of a createProject attempt (local to the store; the ui-service handler maps it). */ export type CreateProjectResult = { ok: true; project: Project; } | { ok: false; code: 'invalid-name' | 'already-exists'; message: string; }; export interface ProjectStoreOptions { /** Overrideable for tests. Defaults to PROJECTS_DIR from @core/paths. */ projectsDir?: string; /** Disable fs.watch — for tests that manipulate dirs synchronously. Defaults to true. */ watchEnabled?: boolean; } export declare class ProjectStore { private readonly projectsDir; private readonly watchEnabled; private projects; private initialized; private watcher; private debounceTimer; constructor(opts?: ProjectStoreOptions); /** * Scan PROJECTS_DIR, scaffold general if absent, build cache, start watcher. * Idempotent — safe to call multiple times. */ initialize(): Promise; /** Return all known projects. Always includes "general". */ list(): Project[]; /** Look up a project by id. Returns undefined for unknown ids. */ get(id: string): Project | undefined; /** True if a project with the given id exists. */ exists(id: string): boolean; /** Return the "general" umbrella project. Always present. */ getDefault(): Project; /** * Resolve a project from a message string using heuristic patterns. * * Priority: * 1. [project:xxx] explicit tag — always wins * 2. Case-insensitive substring match against scanned project ids * (longest match wins when multiple project names appear in the message) * 3. 'general' fallback * * Returns the matching Project or the default general project. */ resolveFromMessage(msg: string | null | undefined): Project | null; /** Force a rescan of PROJECTS_DIR (e.g. after watcher event or manual trigger). */ refresh(): void; /** * Create a new user project directory under PROJECTS_DIR with a standard scaffold * (STATUS.md + CORTEX.md). Validates the name (rejects path traversal, separators, * empty/whitespace, leading-dot, and the reserved 'general'). Never overwrites an * existing project directory — returns an `already-exists` error instead. */ createProject(name: string): CreateProjectResult; /** Stop the fs.watch watcher and release resources. */ destroy(): void; /** Create general/ scaffold if the directory does not exist. */ private scaffoldGeneral; /** Create a project directory and write the standard scaffold files (STATUS.md + CORTEX.md). */ private scaffoldProject; /** Read PROJECTS_DIR and rebuild the in-memory cache. */ private scan; private makeGeneralProject; /** Watch PROJECTS_DIR for add/remove of subdirectories. */ private startWatcher; private debouncedRescan; } export declare const projectStore: ProjectStore;