/** * RestoreCommand - Restore project state (git-backed) * DD ยง17. Git-backed file/time/session granularity. */ import { execFileSync } from 'child_process' export function restoreCommand(options: { file?: string; time?: string; session?: string }): void { if (options.file) { console.log(`Restoring file: ${options.file}`) try { execFileSync('git', ['checkout', '--', options.file], { cwd: process.cwd(), stdio: 'pipe' }) console.log(' File restored from git.') } catch { console.log(' git checkout failed. Is this a git repository?') } } else if (options.time) { console.log(`Restoring to time: ${options.time}`) try { execFileSync('git', ['log', '--before', options.time, '--max-count=1', '--format=%H'], { cwd: process.cwd(), stdio: 'pipe' }) console.log(' Use "git checkout " to restore to that point.') } catch { console.log(' Unable to find commits before that time.') } } else if (options.session) { console.log(`Restoring session: ${options.session}`) console.log(` Session state lives in .air/local/sessions/${options.session}/`) console.log(' To restore, resume the session with: air resume ' + options.session) } else { console.log('Usage: air restore --file | --time | --session ') } }