/** * v2.15.0 follow-up — G11: fork sync state service. * * Tracks the local fork's relationship to its upstream: which tag the * fork is based on, how many commits / files it has diverged, and a * history of past syncs. Persistence: `.peaks/fork-state.json` in the * project root. * * Pure functions on top of a typed state object. The CLI surfaces 5 * commands (status / upstream-check / sync-plan / sync / sync-verify) * but the actual upstream fetch + merge is deferred to a follow-up * slice; this slice ships the model + the dry-run / plan / record path. */ export interface ForkBaseline { /** Upstream repo identifier (e.g. "github.com/xxx/hermes"). */ readonly upstream: string; /** Tag or commit the fork is currently based on. */ readonly basedOn: string; /** ISO timestamp when the baseline was recorded. */ readonly recordedAt: string; /** Number of commits the local fork is ahead of the baseline. */ readonly commitsAhead: number; /** Number of files the local fork has changed vs the baseline. */ readonly filesChanged: number; } export interface ForkSyncRecord { /** Sync plan id (e.g. "sync-2026-06-28-v1.20.0"). */ readonly syncId: string; /** Target upstream tag. */ readonly targetTag: string; /** ISO timestamp when the sync plan was created. */ readonly plannedAt: string; /** Predicted conflict points (file globs / paths). */ readonly predictedConflicts: readonly string[]; /** Business patches that need to be replayed after the sync. */ readonly businessPatches: readonly string[]; /** Sync status. */ readonly status: 'planned' | 'in-progress' | 'verified' | 'failed'; /** Optional verification notes. */ readonly verificationNotes?: string; } export interface ForkState { /** Schema version (currently 1). */ readonly version: 1; /** Current baseline (null when the project is not a fork). */ readonly baseline: ForkBaseline | null; /** History of sync plans + results. */ readonly history: readonly ForkSyncRecord[]; } export declare const EMPTY_FORK_STATE: ForkState; export declare function getForkStatePath(projectRoot: string): string; export declare function readForkState(projectRoot: string): ForkState; export declare function writeForkState(projectRoot: string, state: ForkState): void; /** * Record a new sync plan. The state is immutable; the returned state * has the new plan appended to `history`. */ export declare function appendSyncRecord(state: ForkState, record: ForkSyncRecord): ForkState; /** * Update an existing sync record's status (e.g. planned → verified). * Returns the state unchanged when the record is not found. */ export declare function updateSyncRecordStatus(state: ForkState, syncId: string, status: ForkSyncRecord['status'], notes?: string): ForkState; /** * Generate a sync plan id from a target tag. Format: * `sync--`. */ export declare function makeSyncId(targetTag: string, now?: Date): string; /** * Recommend stable tags to sync to, given a list of available tags. * "Stable" = no pre-release suffix (no `-alpha`, `-beta`, `-rc`). * Picks the latest stable tag that is NEWER than the current baseline. */ export declare function recommendStableTags(availableTags: readonly string[], currentBaseline: string | null): string[]; /** * Build a fork-status report from current state. */ export interface ForkStatusReport { readonly hasBaseline: boolean; readonly baseline: ForkBaseline | null; readonly syncCount: number; readonly lastSync: ForkSyncRecord | null; readonly driftWarning: boolean; } export declare function buildForkStatusReport(state: ForkState): ForkStatusReport;