/**
 * Directory & file scaffolding utilities.
 *
 * Shared ensure/check functions extracted from init.ts for reuse
 * by init.ts, upgrade.ts, and doctor health checks.
 *
 * Rules:
 *   - All ensure functions are idempotent (safe to call multiple times)
 *   - All check functions are read-only (no side effects)
 *   - Uses imports from ./paths.js for path resolution
 */
/** Result of an ensure* scaffolding operation. */
export interface ScaffoldResult {
    action: 'created' | 'repaired' | 'skipped';
    path: string;
    details?: string;
}
/** Status of a check* diagnostic. */
export type CheckStatus = 'passed' | 'failed' | 'warning' | 'info';
/** Result of a check* diagnostic (compatible with doctor/checks.ts CheckResult). */
export interface CheckResult {
    id: string;
    category: string;
    status: CheckStatus;
    message: string;
    details: Record<string, unknown>;
    fix: string | null;
}
/** Required subdirectories under .cleo/. */
export declare const REQUIRED_CLEO_SUBDIRS: readonly ["backups/operational", "backups/safety", "agent-outputs", "logs", "rcasd", "adrs"];
/** Embedded fallback for .cleo/.gitignore content (deny-by-default). */
export declare const CLEO_GITIGNORE_FALLBACK = "# .cleo/.gitignore \u2014 Deny-by-default for CLEO project data\n# Ignore everything, then explicitly allow only tracked files.\n\n# Step 1: Ignore everything\n*\n\n# Allow list\n!.gitignore\n!config.json\n!project-context.json\n!project-info.json\n!setup-otel.sh\n!DATA-SAFETY-IMPLEMENTATION-SUMMARY.md\n!adrs/\n!adrs/**\n!rcasd/\n!rcasd/**\n!agent-outputs/\n!agent-outputs/**\n\n# Explicit deny safety net\n*.db\n*.db-shm\n*.db-wal\n*.db-journal\nlog.json\nbypass-log.json\nqa-log.json\n.deps-cache/\n.context-alert-state.json\n.context-state*.json\ncontext-states/\n.git-checkpoint-state\n.migration-state.json\nmigrations.json\nsync/\nmetrics/\n.backups/\nbackups/\n";
/**
 * Check if a file exists and is readable.
 */
export declare function fileExists(path: string): Promise<boolean>;
/**
 * Strip legacy <!-- CLEO:START -->...<!-- CLEO:END --> blocks from a file.
 * Called before CAAMP injection to prevent competing blocks.
 *
 * Handles both bare markers (<!-- CLEO:START -->) and versioned markers
 * (<!-- CLEO:START v0.53.4 -->, <!-- CLEO:START v1.2.3 -->).
 */
export declare function stripCLEOBlocks(filePath: string): Promise<void>;
/**
 * Remove .cleo/ or .cleo entries from the project root .gitignore.
 */
export declare function removeCleoFromRootGitignore(projectRoot: string): Promise<{
    removed: boolean;
}>;
export { generateProjectHash } from './nexus/hash.js';
/**
 * Resolve the package root directory (where schemas/ and templates/ live).
 * scaffold.ts lives in packages/core/src/, so 1 level up reaches the package root.
 */
export declare function getPackageRoot(): string;
/**
 * Load the gitignore template from the package's templates/ directory.
 * Falls back to embedded content if file not found.
 */
export declare function getGitignoreContent(): string;
/**
 * Read CLEO version from package.json.
 */
export declare function getCleoVersion(): string;
export declare function createDefaultConfig(): Record<string, unknown>;
/**
 * Create .cleo/ directory and all required subdirectories.
 * Idempotent: skips directories that already exist.
 */
export declare function ensureCleoStructure(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Create or repair .cleo/.gitignore from template.
 * Idempotent: skips if file already exists with correct content.
 */
export declare function ensureGitignore(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Create default config.json if missing.
 * Idempotent: skips if file already exists.
 */
export declare function ensureConfig(projectRoot: string, opts?: {
    force?: boolean;
}): Promise<ScaffoldResult>;
/**
 * Create or refresh project-info.json.
 * Idempotent: skips if file already exists (unless force).
 */
export declare function ensureProjectInfo(projectRoot: string, opts?: {
    force?: boolean;
}): Promise<ScaffoldResult>;
/**
 * Ensure .mcp.json contains a cleo-dev server entry pointing to the local build.
 * Only runs when isCleoContributorProject() is true (ADR-029).
 *
 * Writes the server entry:
 *   cleo-dev → node <projectRoot>/dist/mcp/index.js
 *
 * This ensures Claude Code loads the LOCAL dev build MCP server for this project,
 * not the published @cleocode/cleo@latest. Idempotent: preserves other entries.
 */
export declare function ensureContributorMcp(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Detect and write project-context.json.
 * Idempotent: skips if file exists and is less than staleDays old (default: 30).
 */
export declare function ensureProjectContext(projectRoot: string, opts?: {
    force?: boolean;
    staleDays?: number;
}): Promise<ScaffoldResult>;
/**
 * Initialize isolated .cleo/.git checkpoint repository.
 * Idempotent: skips if .cleo/.git already exists.
 */
export declare function ensureCleoGitRepo(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Create SQLite database if missing.
 * Idempotent: skips if tasks.db already exists.
 */
export declare function ensureSqliteDb(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Verify all required .cleo/ subdirectories exist.
 */
export declare function checkCleoStructure(projectRoot: string): CheckResult;
/**
 * Verify .cleo/.gitignore exists and matches template.
 */
export declare function checkGitignore(projectRoot: string): CheckResult;
/**
 * Verify config.json exists and is valid JSON.
 */
export declare function checkConfig(projectRoot: string): CheckResult;
/**
 * Verify project-info.json exists with required fields.
 */
export declare function checkProjectInfo(projectRoot: string): CheckResult;
/**
 * Verify project-context.json exists and is not stale (default: 30 days).
 */
export declare function checkProjectContext(projectRoot: string, staleDays?: number): CheckResult;
/**
 * Verify .cleo/.git checkpoint repository exists.
 */
export declare function checkCleoGitRepo(projectRoot: string): CheckResult;
/**
 * Verify .cleo/tasks.db exists and is non-empty.
 */
export declare function checkSqliteDb(projectRoot: string): CheckResult;
/**
 * Create brain.db if missing.
 * Idempotent: skips if brain.db already exists.
 */
export declare function ensureBrainDb(projectRoot: string): Promise<ScaffoldResult>;
/**
 * Verify .cleo/brain.db exists and is non-empty.
 */
export declare function checkBrainDb(projectRoot: string): CheckResult;
/**
 * Verify .cleo/memory-bridge.md exists.
 * Warning level if missing (not failure) — it is auto-generated.
 */
export declare function checkMemoryBridge(projectRoot: string): CheckResult;
/**
 * Required subdirectories under the global ~/.cleo/ home.
 * These are infrastructure directories managed by CLEO itself,
 * not project-specific data.
 *
 * Truly global:
 *   - logs      — global log output
 *   - templates — CLEO-INJECTION.md symlink target
 *
 * Note: nexus.db lives directly in ~/.cleo/, not a subdir.
 * Schemas are read at runtime from getPackageRoot()/schemas/ — no copy needed.
 * Project-level dirs (adrs/, rcasd/, agent-outputs/, backups/) live in .cleo/ only.
 */
export declare const REQUIRED_GLOBAL_SUBDIRS: readonly ["logs", "templates"];
/**
 * Stale entries that must NOT exist at the global ~/.cleo/ level.
 * These were project-level artefacts accidentally placed in the global home
 * by old versions of CLEO. They are safe to remove because:
 *   - adrs/, rcasd/, agent-outputs/, backups/ — project-level, live in .cleo/
 *   - sandbox/                                — unused
 *   - tasks.db / tasks.db-shm / tasks.db-wal  — project-level database files
 *   - brain-worker.pid                         — stale PID file
 *   - VERSION                                  — redundant (read from package.json)
 *   - schemas/                                 — now read from npm binary at runtime
 *   - bin/                                     — stale dev symlink directory
 */
export declare const STALE_GLOBAL_ENTRIES: readonly ["adrs", "rcasd", "agent-outputs", "backups", "sandbox", "tasks.db", "tasks.db-shm", "tasks.db-wal", "brain-worker.pid", "VERSION", "schemas", "bin", ".install-state", "templates/templates"];
/**
 * Ensure the global ~/.cleo/ home directory and its required
 * subdirectories exist. Idempotent: skips directories that already exist.
 *
 * Also removes known stale project-level entries that old CLEO versions
 * incorrectly placed at the global level (see STALE_GLOBAL_ENTRIES).
 *
 * This is the SSoT for global home scaffolding, replacing raw mkdirSync
 * calls that were previously scattered across global-bootstrap.ts.
 */
export declare function ensureGlobalHome(): Promise<ScaffoldResult>;
/**
 * Ensure the global CLEO injection template is installed.
 * Delegates to injection.ts for the template content, but owns the
 * filesystem write to maintain SSoT for scaffolding.
 *
 * Idempotent: skips if the template already exists with correct content.
 */
export declare function ensureGlobalTemplates(): Promise<ScaffoldResult>;
/**
 * Perform a complete global scaffold operation: ensure home and templates
 * are all present and current. This is the single entry point for global
 * infrastructure scaffolding.
 *
 * Schemas are NOT copied here — they are read at runtime from the npm
 * package path (getPackageRoot() + '/schemas/'). Use ensureGlobalSchemas()
 * explicitly from init or upgrade if a copy is needed for a specific workflow.
 *
 * Used by:
 *   - MCP startup (via startupHealthCheck in health.ts)
 *   - init (for first-time global setup)
 *   - upgrade (for global repair)
 */
export declare function ensureGlobalScaffold(): Promise<{
    home: ScaffoldResult;
    templates: ScaffoldResult;
}>;
/**
 * Check that the global ~/.cleo/ home and its required subdirectories exist.
 * Read-only: no side effects.
 */
export declare function checkGlobalHome(): CheckResult;
/**
 * Check that the global injection template is present and current.
 * Read-only: no side effects.
 */
export declare function checkGlobalTemplates(): CheckResult;
/**
 * Check that the project log directory exists.
 * Read-only: no side effects.
 */
export declare function checkLogDir(projectRoot: string): CheckResult;
//# sourceMappingURL=scaffold.d.ts.map