// tools/resolve-sync-conflict.ts — resolve_sync_conflict handler
import { syncLogStore } from '../storage/index.js';
import { createSyncLogEntry } from '../engine/living-spec/index.js';
export async function handleResolveSyncConflict(args) {
    const { projectId, conflictId, resolution, manualResolution } = args;
    const resolutionText = resolution === 'manual'
        ? (manualResolution ?? 'Manual resolution (no details provided)')
        : `Auto-resolved: ${resolution}`;
    const conflict = await syncLogStore.resolveConflict(projectId, conflictId, resolutionText);
    if (!conflict) {
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify({
                        message: `Conflict ${conflictId} not found. Use sync_spec_to_code or sync_code_to_spec to detect conflicts first.`,
                    }, null, 2),
                },
            ],
            isError: true,
        };
    }
    // Log the resolution
    const logEntry = createSyncLogEntry(conflict.direction, conflict.specId, 'resolve-conflict', `Resolved conflict ${conflictId}: ${resolutionText}`);
    await syncLogStore.appendSyncLog(projectId, [logEntry]);
    return {
        content: [
            {
                type: 'text',
                text: JSON.stringify({
                    conflict,
                    message: `Conflict ${conflictId} resolved: ${resolutionText}`,
                }, null, 2),
            },
        ],
    };
}
//# sourceMappingURL=resolve-sync-conflict.js.map