import { type SyncAgent, type SyncMarker } from "./agent-sync.js"; import type { PortableSkillOptions } from "./portable-skills.js"; export declare const CONFLICTS_LEDGER_FILE = "conflicts.json"; export declare const ROLLBACK_DIRNAME = "rollback"; export interface HomeSkillEntry { agent: SyncAgent; skill: string; /** The agent home skills directory (e.g. ~/.claude/skills). */ home: string; /** The skill's own directory under the agent home. */ path: string; hash: string; /** SKILL.md mtime (ISO). */ mtime: string; } export interface HomeConflict extends HomeSkillEntry { canonicalHash: string; } export interface UnknownHomeSkill extends HomeSkillEntry { } export interface AdoptionScan { /** Unmarked home dirs whose SKILL.md hash matches the canonical corpus entry. */ adoptable: HomeSkillEntry[]; /** Unmarked home dirs whose content differs from canonical; never touched. */ conflicts: HomeConflict[]; /** Unmarked home dirs with no canonical corpus entry; reported and skipped. */ unknown: UnknownHomeSkill[]; /** Already-marked dirs, counted only. */ managed: number; } export interface AdoptionOptions extends PortableSkillOptions { agents?: SyncAgent[]; /** Optional selected home/corpus names; omitted means all names. */ names?: string[]; /** Write markers and the conflicts ledger. Without it, scan only. */ apply?: boolean; } export interface AdoptionResult extends AdoptionScan { applied: boolean; /** Rollback record path, when markers were written. */ rollbackFile?: string; } export interface RollbackMarker { agent: SyncAgent; skill: string; path: string; hash: string; marker: SyncMarker; } export interface RollbackRecord { version: 1; mode: "adopt" | "prune"; timestamp: string; entries: RollbackMarker[]; } export interface PruneCandidate extends RollbackMarker { /** The agent home skills directory. */ home: string; } export interface PruneResult { candidates: PruneCandidate[]; pruned: number; dryRun: boolean; rollbackFile?: string; } /** * Canonical corpus index: skill name -> canonical SKILL.md hash. A skill is * canonical when the corpus cache holds a directory with a SKILL.md. */ export declare function indexCanonicalCorpus(corpusRoot: string): Map; /** * Census of unmarked home skill dirs against the canonical corpus. Read-only. */ export declare function scanUnmarkedHomes(options?: AdoptionOptions): AdoptionScan; /** * Write one rollback record listing every marker written (mode "adopt") or * every directory removed (mode "prune"), so both operations are auditable * from a single machine-readable file. Deleted resource bytes are not stored. */ export declare function writeRollbackRecord(mode: "adopt" | "prune", entries: RollbackMarker[], appDir?: string): string; /** * Adopt unmarked home skills whose content exactly matches the canonical * corpus. Without `apply` this is a pure scan; with `apply` it writes one * marker per exact match, appends diverging dirs to the conflicts ledger, and * records every written marker in a rollback file. Never deletes anything. */ export declare function adoptUnmarkedHomes(options?: AdoptionOptions): AdoptionResult; export declare function pruneStrayHomes(options?: AdoptionOptions): PruneResult;