(state: SyncState)
| 1149 | * Push uses conflict resolution (retries on 412) via pushTeamMemory. |
| 1150 | */ |
| 1151 | export async function syncTeamMemory(state: SyncState): Promise<{ |
| 1152 | success: boolean |
| 1153 | filesPulled: number |
| 1154 | filesPushed: number |
| 1155 | error?: string |
| 1156 | }> { |
| 1157 | // 1. Pull remote → local (skip ETag cache for full sync) |
| 1158 | const pullResult = await pullTeamMemory(state, { skipEtagCache: true }) |
| 1159 | if (!pullResult.success) { |
| 1160 | return { |
| 1161 | success: false, |
| 1162 | filesPulled: 0, |
| 1163 | filesPushed: 0, |
| 1164 | error: pullResult.error, |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | // 2. Push local → remote (with conflict resolution) |
| 1169 | const pushResult = await pushTeamMemory(state) |
| 1170 | if (!pushResult.success) { |
| 1171 | return { |
| 1172 | success: false, |
| 1173 | filesPulled: pullResult.filesWritten, |
| 1174 | filesPushed: 0, |
| 1175 | error: pushResult.error, |
| 1176 | } |
| 1177 | } |
| 1178 | |
| 1179 | logForDebugging( |
| 1180 | `team-memory-sync: synced (pulled ${pullResult.filesWritten}, pushed ${pushResult.filesUploaded})`, |
| 1181 | { level: 'info' }, |
| 1182 | ) |
| 1183 | |
| 1184 | return { |
| 1185 | success: true, |
| 1186 | filesPulled: pullResult.filesWritten, |
| 1187 | filesPushed: pushResult.filesUploaded, |
| 1188 | } |
| 1189 | } |
| 1190 | |
| 1191 | // ─── Telemetry helpers ─────────────────────────────────────── |
| 1192 |
nothing calls this directly
no test coverage detected