(input: RunMigrationInput)
| 32 | } |
| 33 | |
| 34 | export async function runMigration(input: RunMigrationInput): Promise<MigrationReport> { |
| 35 | const startedAt = new Date().toISOString(); |
| 36 | const version = input.migratorVersion ?? DEFAULT_MIGRATOR_VERSION; |
| 37 | const log = (m: string): void => { |
| 38 | input.onProgress?.(m); |
| 39 | }; |
| 40 | |
| 41 | const config = input.scope.config |
| 42 | ? await migrateConfigStep({ sourceHome: input.source, targetHome: input.target }) |
| 43 | : { |
| 44 | migrated: false, |
| 45 | tuiExtracted: false, |
| 46 | droppedProviders: [], |
| 47 | droppedModels: [], |
| 48 | droppedKeys: [], |
| 49 | configConflicts: [], |
| 50 | wroteSiblingDueToConflict: false, |
| 51 | wroteTuiSibling: false, |
| 52 | migratedHooks: 0, |
| 53 | droppedHooks: 0, |
| 54 | siblingContents: { providers: [], models: [], hooks: 0 }, |
| 55 | }; |
| 56 | log('config done'); |
| 57 | |
| 58 | const mcp = input.scope.mcp |
| 59 | ? await migrateMcpStep({ sourceHome: input.source, targetHome: input.target }) |
| 60 | : { mergedServers: [], keptNewForConflicts: [], droppedServers: [], wroteSiblingDueToConflict: false }; |
| 61 | log('mcp done'); |
| 62 | |
| 63 | const userHistory = input.scope.userHistory |
| 64 | ? await migrateUserHistoryStep({ sourceHome: input.source, targetHome: input.target }) |
| 65 | : { copied: 0, skippedExisting: 0 }; |
| 66 | log('user-history done'); |
| 67 | |
| 68 | const skills = input.scope.skills |
| 69 | ? await migrateSkillsStep({ sourceHome: input.source, targetHome: input.target }) |
| 70 | : { copied: 0, skippedExisting: 0 }; |
| 71 | log('skills done'); |
| 72 | |
| 73 | const sessions: SessionsSummary = input.scope.sessions |
| 74 | ? await migrateSessionsStep({ |
| 75 | sourceHome: input.source, |
| 76 | targetHome: input.target, |
| 77 | onSessionProgress: input.onSessionProgress, |
| 78 | }) |
| 79 | : emptyConfigOnlySessions(); |
| 80 | log('sessions done'); |
| 81 | |
| 82 | const completedAt = new Date().toISOString(); |
| 83 | |
| 84 | const report: MigrationReport = { |
| 85 | startedAt, |
| 86 | completedAt, |
| 87 | migratorVersion: version, |
| 88 | source: input.source, |
| 89 | target: input.target, |
| 90 | summary: { |
| 91 | config, |
no test coverage detected