import type { KyroLocalProjectState, KyroManifest, KyroProjectState, KyroSharedProjectState, KyroInstalledAdapter, KyroScopeEntry, Convention, Principle, TeamPolicy } from './types'; /** Backup name after monolito → layers split (dual-read no longer prefers monolito when layers exist). */ export declare const KYRO_STATE_MIGRATED_PATH = ".agents/kyro/kyro.json.migrated"; export declare function readSharedProjectState(): KyroSharedProjectState | null; export declare function readLocalProjectState(): KyroLocalProjectState | null; /** True when local.json sets execution.delegationEnabled to true; false when absent or false. */ export declare function resolveDelegationEnabled(): boolean; /** Raw legacy monolito file only — does not merge layers. */ export declare function readMonolitoProjectState(): KyroProjectState | null; /** Refuse to discard the only persisted identity of a legacy scope during migration. */ export declare function assertLegacyScopeCacheMigratable(source: unknown, path: string): void; export declare function assertPersistedLegacyScopeCachesMigratable(): void; export declare function hasLayeredProjectStateOnDisk(): boolean; export declare function hasMonolitoProjectStateOnDisk(): boolean; /** True when any persisted project state file exists (layers or legacy monolito). */ export declare function hasPersistedProjectStateOnDisk(): boolean; /** * One-line install/bootstrap remedy for missing or incomplete project state (D7a / R5). * Read-only commands surface this string; they never create the files themselves. */ export declare const PROJECT_STATE_BOOTSTRAP_REMEDY = "Run: npm install -g kyro-ai; from the project root run kyro install --init-workspace --yes (writes project.json + local.json; rehydrates on-disk scopes)."; /** * Format a one-line actionable bootstrap remedy. Optional reason prefixes the install line. * Never creates files. */ export declare function formatBootstrapRemedy(reason?: string): string; /** * Detect whether a read-only command should surface a bootstrap remedy. * Callers pass on-disk scope ids when project state is absent. Never writes. * * @returns one-line remedy, or null when persisted state exists */ export declare function detectProjectStateBootstrapNeed(unregisteredScopeIds?: string[]): string | null; /** * Effective project state façade used by all CLI/MCP readers. * * Resolution order (deterministic, read-only — never creates files): * 1. If either layer file exists → merge shared + local (defaults fill missing layer). * 2. Else if legacy monolito exists → return sanitized monolito as effective state. * 3. Else → null. * * Layered state derives its effective scopes from disk without writing files. */ export declare function readProjectState(): KyroProjectState | null; export declare function readManifest(): KyroManifest | null; /** * Deterministic merge: shared owns principles/conventions/team/scopes/artifactRoot; * local owns activeScope/installedAdapters (+ optional runtimePath). */ export declare function mergeProjectLayers(sharedRaw: KyroSharedProjectState | null, localRaw: KyroLocalProjectState | null): KyroProjectState; export declare function effectiveFromMonolito(monolito: KyroProjectState): KyroProjectState; export interface SplitMonolitoResult { shared: KyroSharedProjectState; local: KyroLocalProjectState; } /** * Pure split of a legacy effective/monolito state into layer payloads. * Shared scopes are omitted; each sprint file is authoritative. */ export declare function splitMonolitoToLayers(monolito: KyroProjectState): SplitMonolitoResult; export interface MigrateMonolitoOptions { /** * When true (default), rename `.agents/kyro/kyro.json` → `kyro.json.migrated` after a successful * layer write so dual-read prefers layers and writers stop targeting monolito. */ archiveMonolito?: boolean; /** Optional source; defaults to on-disk monolito. */ monolito?: KyroProjectState; } export interface MigrateMonolitoResult extends SplitMonolitoResult { archivedMonolitoPath: string | null; } /** * Split monolito into layers and persist under the state-writer lock. * Does not write monolito. Callers (install/sync/repair) own when to invoke this. */ export declare function migrateMonolitoToLayers(options?: MigrateMonolitoOptions): MigrateMonolitoResult; /** Assumes the caller already holds the state-writer lock (re-entrant safe via withStateWriterLock). */ export declare function migrateMonolitoToLayersUnlocked(options?: MigrateMonolitoOptions): MigrateMonolitoResult; /** * Persist shared project state only. Never writes activeScope / installedAdapters / monolito. * Acquires the state-writer lock (re-entrant). */ export declare function writeSharedProjectState(shared: KyroSharedProjectState): void; /** Persist local overlay only. Never writes principles / team / monolito. */ export declare function writeLocalProjectState(local: KyroLocalProjectState): void; export interface ProjectLayerWrite { shared?: KyroSharedProjectState; local?: KyroLocalProjectState; } /** * Multi-file layer write in one lock critical section (R11). * Does not write monolito KYRO_STATE_PATH. */ export declare function writeProjectLayers(layers: ProjectLayerWrite): void; export declare function writeSharedProjectStateUnlocked(shared: KyroSharedProjectState): void; export declare function writeLocalProjectStateUnlocked(local: KyroLocalProjectState): void; export declare function writeProjectLayersUnlocked(layers: ProjectLayerWrite): void; /** Partial update applied on top of the current effective project state. */ export interface ProjectStateLayerUpdate { scopes?: KyroScopeEntry[]; activeScope?: string | null; installedAdapters?: KyroInstalledAdapter[]; principles?: Principle[]; conventions?: Convention[]; team?: TeamPolicy; artifactRoot?: string; runtimePath?: string; } /** * Apply a partial update to the correct layer(s). Never writes monolito. * * - When layered files are missing but monolito exists: split the merged next state into layers, * write both, archive monolito. * - When layers exist: write only the layers touched by the update (shared for scopes/principles/team/ * artifactRoot; local for activeScope/installedAdapters/runtimePath). * - When neither exists: create both layers from the update merged with defaults. */ export declare function updateProjectStateLayers(update: ProjectStateLayerUpdate): void; export declare function updateProjectStateLayersUnlocked(update: ProjectStateLayerUpdate): void; export declare function sanitizeSharedForWrite(shared: KyroSharedProjectState): KyroSharedProjectState; export declare function sanitizeLocalForWrite(local: KyroLocalProjectState): KyroLocalProjectState; /** Remove global-only / retired fields from any project-state-shaped object. */ export declare function stripLegacyProjectFields(value: T): T; /** * Names the entries whose required text could not be recovered from any known alias, so callers can * warn instead of writing a hollow record. Empty means nothing was lost. */ export declare function collectUnnormalizableState(shared: KyroSharedProjectState): string[]; //# sourceMappingURL=state.d.ts.map