/** * Config-file scaffolding: .gitignore, worktree-include, config.json, * project-info.json, and related template/version utilities. */ import type { ScaffoldResult } from '@cleocode/contracts/scaffold-diagnostics'; import type { UpgradeFileJournal } from './upgrade-file-journal.js'; /** * Resolve the `.cleo` directory for scaffold steps. * * During first-time `cleo init`, `project-info.json` and nexus registration do * not exist yet, so the projectId-based resolver is intentionally unavailable. * Scaffold callers fall back to the local project root in that bootstrap window. * * @param projectRoot - Absolute path to the project root directory. * @returns Absolute path to the project's `.cleo` directory. */ export declare function resolveScaffoldCleoDir(projectRoot: string): string; /** * Embedded fallback for .cleo/.gitignore content (deny-by-default). * * ADR-013 §9: config.json / project-info.json are NOT re-included here. */ 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# ADR-013 \u00A79 (2026-04-07, T5158): config.json + project-info.json are\n# runtime snapshots regenerated by `cleo init`, not tracked in git.\n# Recovery for all four runtime files (tasks.db, brain.db, config.json,\n# project-info.json) is provided by `cleo backup add` snapshots under\n# .cleo/backups/. See .cleo/adrs/ADR-013 for the full recovery story.\n#\n# ADR-094 (amends ADR-013 \u00A79, T12325) + ADR-096 (T12716): project.json IS tracked \u2014 the\n# write-once portable project id plus the renamable display name \u2014 and so is\n# project-id, its legacy id-only mirror. CLEO never rewrites either id, so git\n# has nothing to overwrite.\n\n# Step 1: Ignore everything\n*\n\n# Allow list\n!.gitignore\n!project-context.json\n!project.json\n!project-id\n# T13787: the owner override enrollment and sealed cap (tracked so tampering shows).\n!owner-settings.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\nconfig.json\nproject-info.json\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\n# Session journals \u2014 T1263 PSYCHE E6 (sensitive session data \u2014 task IDs, notes, agent IDs)\n# Retain locally for meta-agent training; never commit to project git.\nsession-journals/\n"; /** * Embedded fallback for `.worktreeinclude` (canonical) content. * * The canonical location (T9983) is `/.worktreeinclude` — * matches Claude Code Desktop + worktrunk-core. The legacy location * `/.cleo/worktree-include` is still read for one deprecation * cycle; `cleo doctor --migrate-worktree-include` auto-migrates. * * @task T9983 */ export declare const WORKTREE_INCLUDE_FALLBACK = "# .worktreeinclude \u2014 files to copy into agent worktrees on provisioning.\n#\n# Syntax: gitignore-style globs (parsed by ignore::gitignore via\n# @cleocode/worktree-napi). Lines starting with `!` are negations.\n#\n# Local environment overrides (gitignored but required for dev)\n.env.local\n.env.development.local\n\n# Package-manager configuration (registry auth, resolution rules)\n.npmrc\n.yarnrc\n.pnpmrc\n"; /** * Resolve the package root directory (where schemas/ and templates/ live). * * @returns Absolute path to the @cleocode/core 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. * * @returns The .cleo/.gitignore template content string */ export declare function getGitignoreContent(): string; /** * Load the `.worktreeinclude` template from the package's templates/ * directory. * * Resolution order (T9983): * 1. `templates/worktreeinclude` — canonical (matches the file name we * write at the project root). * 2. `templates/worktree-include` — legacy template kept for one * deprecation cycle so partially-updated installations keep working. * 3. {@link WORKTREE_INCLUDE_FALLBACK} embedded constant. * * @returns The `.worktreeinclude` template content string * * @task T9983 */ export declare function getWorktreeIncludeContent(): string; /** * Read CLEO version from package.json. * * @returns Semver version string, or "0.0.0" if unavailable */ export declare function getCleoVersion(): string; /** * Create default config.json content. * * @returns A plain object with the default CLEO configuration structure */ export declare function createDefaultConfig(): Record; /** * Options for the repair of user-owned rule files * ({@link ensureGitignore}, {@link ensureWorktreeInclude}). */ export interface RuleFileRepairOptions { /** Journal that backs up the file before it changes and lists it (upgrade, T13409). */ journal?: UpgradeFileJournal; } /** * Create .cleo/.gitignore from the template, or append the template rules an * existing file lacks. Idempotent; never drops or reorders the user's lines (T13409). * * @param projectRoot - Absolute path to the project root directory * @param opts - Backup journal (upgrade) * @returns Scaffold result indicating whether the gitignore was created, repaired, or skipped */ export declare function ensureGitignore(projectRoot: string, opts?: RuleFileRepairOptions): Promise; /** * Create `.worktreeinclude` (canonical, at project root) from the shipped * template, or append the template entries an existing file lacks. * Idempotent; never drops or reorders the user's lines (T13409). * * Resolution rules (T9983): * - If `/.worktreeinclude` already exists → keep it and append * only the missing template entries. * - Else if legacy `/.cleo/worktree-include` exists → SKIP * (do not overwrite the legacy file in place; `cleo doctor * --migrate-worktree-include` is the explicit migration path). * - Else → write the canonical template. * * @param projectRoot - Absolute path to the project root directory * @param opts - Backup journal (upgrade) * @returns Scaffold result indicating whether `.worktreeinclude` was * created, repaired, or skipped. * * @task T9983 */ export declare function ensureWorktreeInclude(projectRoot: string, opts?: RuleFileRepairOptions): Promise; /** * Create default config.json if missing. * Idempotent: skips if file already exists. * * @param projectRoot - Absolute path to the project root directory * @param opts - Optional configuration * @param opts.force - When true, overwrite the existing config * @returns Scaffold result indicating the action taken */ export declare function ensureConfig(projectRoot: string, opts?: { force?: boolean; }): Promise; /** * Create or refresh project-info.json, and record the id in the tracked, * write-once `.cleo/project.json` (plus its legacy `.cleo/project-id` mirror) * when the project has no tracked identity yet (T12325 · T12716). * Idempotent: skips if file exists (unless force). * * The id is never minted while it can be re-linked: the tracked id wins, an * existing cached id is used when nothing is tracked, and otherwise the global * registry is searched before a new id is minted (see * {@link decideProjectIdentity}). * * `project-info.json` holds device-local state only; its `projectId` is a * cache of the tracked id. A cache that disagrees with the tracked id is * reported and left as-is: re-keying it (and the local state keyed by it) is * `cleo doctor project-identity --resolve`, never a side effect of init or * upgrade (T12716). A legacy project with only `.cleo/project-id` is likewise * reported, not migrated. * * @param projectRoot - Absolute path to the project root directory * @param opts - Optional configuration * @param opts.force - When true, regenerate even if the file exists * @param opts.mintNewIdentity - Explicitly mint a new id instead of re-linking * @returns Scaffold result indicating the action taken; `details` carries the * identity provenance and any conflict to report */ export declare function ensureProjectInfo(projectRoot: string, opts?: { force?: boolean; mintNewIdentity?: boolean; }): Promise; /** * No-op. Kept for API compatibility. * * @param projectRoot - Absolute path to the project root directory * @returns Scaffold result with action "skipped" */ export declare function ensureContributorMcp(projectRoot: string): Promise; //# sourceMappingURL=ensure-config.d.ts.map