/** * NEXUS project registry - cross-project registration and management. * * SQLite-backed via nexus.db (Drizzle ORM). The global project registry * is stored in ~/.cleo/nexus.db in the project_registry table. * * Legacy JSON backend (projects-registry.json) is migrated on first init * via migrate-json-to-sqlite.ts. * * @task T5366 * @epic T4540 */ import { type NexusInitParams, type NexusListParams, type NexusPermissionSetParams, type NexusReconcileParams, type NexusRegisterParams, type NexusShowParams, type NexusSyncParams, type NexusUnregisterParams } from '@cleocode/contracts'; import { type EngineResult } from '../engine-result.js'; import { paginate } from '../pagination.js'; import { resetNexusDbState } from '../store/nexus-sqlite.js'; export type NexusPermissionLevel = 'read' | 'write' | 'execute'; export type NexusHealthStatus = 'unknown' | 'healthy' | 'degraded' | 'unreachable'; /** Per-project code intelligence statistics stored in stats_json. */ export interface NexusProjectStats { nodeCount: number; relationCount: number; fileCount: number; } /** Domain representation of a registered Nexus project. */ export interface NexusProject { hash: string; projectId: string; path: string; name: string; registeredAt: string; lastSeen: string; healthStatus: NexusHealthStatus; healthLastCheck: string | null; permissions: NexusPermissionLevel; lastSync: string; taskCount: number; labels: string[]; /** Absolute path to the project's brain.db. Null if not yet populated. */ brainDbPath: string | null; /** Absolute path to the project's tasks.db. Null if not yet populated. */ tasksDbPath: string | null; /** ISO 8601 timestamp of the last code intelligence index run. Null if never indexed. */ lastIndexed: string | null; /** Code intelligence stats from the last index run. */ stats: NexusProjectStats; } /** Legacy registry file shape (pre-SQLite). Retained for migration compatibility. */ export interface NexusRegistryFile { $schema?: string; schemaVersion: string; lastUpdated: string; projects: Record; } /** Get path to the NEXUS home directory (cache, etc.). */ export declare function getNexusHome(): string; /** Get path to the NEXUS cache directory. */ export declare function getNexusCacheDir(): string; /** * Get path to the legacy projects registry JSON file. * @deprecated Use nexus.db via getNexusDb() instead. Retained for JSON-to-SQLite migration. */ export declare function getRegistryPath(): string; /** * Read all projects from nexus.db and return as a NexusRegistryFile. * Compatibility wrapper for consumers that expect the legacy JSON shape. * Returns null if nexus.db has not been initialized yet. */ export declare function readRegistry(): Promise; /** * Read the global registry, throwing if not initialized. */ export declare function readRegistryRequired(): Promise; /** * Initialize the NEXUS directory structure and nexus.db. * Idempotent -- safe to call multiple times. * Migrates legacy JSON registry on first run if present. */ export declare function nexusInit(_projectRoot?: string, _params?: NexusInitParams): Promise; /** * Register a project in the global registry (nexus.db). * @returns The project hash. */ export declare function nexusRegister(_projectRoot: string, params: NexusRegisterParams): Promise; /** @deprecated Use `nexusRegister(projectRoot, params)` — ADR-057 D1 */ export declare function nexusRegister(projectPath: string, name?: string, permissions?: NexusPermissionLevel): Promise; /** * Unregister a project from the global registry. */ export declare function nexusUnregister(_projectRoot: string, params: NexusUnregisterParams): Promise; /** @deprecated Use `nexusUnregister(projectRoot, params)` — ADR-057 D1 */ export declare function nexusUnregister(nameOrHash: string): Promise; /** * List all registered projects. */ export declare function nexusList(_projectRoot?: string, _params?: NexusListParams): Promise; /** * Get a project by name or hash. * Returns null if not found. */ export declare function nexusGetProject(_projectRoot: string, params: NexusShowParams): Promise; /** @deprecated Use `nexusGetProject(projectRoot, params)` — ADR-057 D1 */ export declare function nexusGetProject(nameOrHash: string): Promise; /** * Check if a project exists in the registry. */ export declare function nexusProjectExists(nameOrHash: string): Promise; /** * Sync project metadata (task count, labels) for a registered project. */ export declare function nexusSync(_projectRoot: string, params: NexusSyncParams): Promise; /** @deprecated Use `nexusSync(projectRoot, params)` — ADR-057 D1 */ export declare function nexusSync(nameOrHash: string): Promise; /** * Sync all registered projects. * @returns Counts of synced and failed projects. */ export declare function nexusSyncAll(): Promise<{ synced: number; failed: number; }>; /** * Update code intelligence index stats for a registered project. * * Called after a successful `cleo nexus analyze` run to record the * latest node/relation/file counts and the indexed timestamp. * * @param projectPath - Absolute path to the project root. * @param stats - Results from the pipeline run. * @task T622 */ export declare function nexusUpdateIndexStats(projectPath: string, stats: NexusProjectStats): Promise; /** * Update a project's permission level in the registry. * Used by permissions.ts to avoid direct JSON file writes. */ export declare function nexusSetPermission(_projectRoot: string, params: NexusPermissionSetParams): Promise; /** @deprecated Use `nexusSetPermission(projectRoot, params)` — ADR-057 D1 */ export declare function nexusSetPermission(nameOrHash: string, permission: NexusPermissionLevel): Promise; /** * Reconcile the current project's identity with the global nexus registry. * * 4-scenario policy: * 1. projectId in registry + path matches → update lastSeen, return {status:'ok'} * 2. projectId in registry + path changed → update path+hash, return {status:'path_updated'} * 3. projectId not in registry → auto-register, return {status:'auto_registered'} * 4. projectHash matches but different projectId → throw CleoError (identity conflict) * * Uses projectId as the stable identifier across project moves, since * projectHash is derived from the absolute path and changes when moved. * * @task T5368 */ export declare function nexusReconcile(projectRoot: string, _params?: NexusReconcileParams): Promise<{ status: 'ok' | 'path_updated' | 'auto_registered'; oldPath?: string; newPath?: string; }>; /** * Update a project's registry entry after a filesystem move. @task T11024 */ export declare function nexusMoveProject(projectId: string, newPath: string): Promise; /** * Update a project's name in the registry after a rename. @task T11024 */ export declare function nexusRenameProject(projectId: string, newName: string): Promise; /** * Reset the nexus database singleton state. * Re-exported from nexus-sqlite for test convenience. */ export { resetNexusDbState }; /** * Get nexus status (initialized, project count, last updated). * * @task T1569 */ export declare function nexusStatus(): Promise>; /** * List all registered projects with pagination. * * @task T1569 */ export declare function nexusListProjects(limit?: number, offset?: number): Promise>; count: number; total: number; filtered: number; page: ReturnType['page']; }>>; /** * Show a single project by name. * * @task T1569 */ export declare function nexusShowProject(name: string): Promise>>>; /** * Initialize the nexus. * * @task T1569 */ export declare function nexusInitialize(): Promise>; /** * Register a project in the nexus. * * @task T1569 */ export declare function nexusRegisterProject(path: string, name?: string, permission?: NexusPermissionLevel): Promise>; /** * Unregister a project from the nexus. * * @task T1569 */ export declare function nexusUnregisterProject(name: string): Promise>; /** * Sync a specific project or all projects. * * @task T1569 */ export declare function nexusSyncProject(name?: string): Promise>; /** * Reconcile the nexus registry with the filesystem. * * @task T1569 */ export declare function nexusReconcileProject(projectRoot: string): Promise>>>; /** * List all projects in the global nexus registry (Phase 2 dispatch op). * * @task T1569 */ export declare function nexusProjectsList(): Promise>; /** * Register a project in the global nexus registry (Phase 2 dispatch op). * * @param repoPath - Absolute path to the project directory. * @param name - Custom project name (optional). * @task T1569 */ export declare function nexusProjectsRegister(repoPath: string, name?: string): Promise>; /** * Remove a project from the global nexus registry by name or hash (Phase 2 dispatch op). * * @param nameOrHash - Project name or hash to remove. * @task T1569 */ export declare function nexusProjectsRemove(nameOrHash: string): Promise>; //# sourceMappingURL=registry.d.ts.map