import { hashProjectPath } from '../storage/base-store.js';
import { previewDeleteProject, executeDeleteProject } from '../engine/deleter/core.js';
/**
 * Handle delete_project tool invocation.
 * Requires confirm=true. Without it, shows preview only.
 */
export async function handleDeleteProject(params) {
    try {
        const projectId = hashProjectPath(params.projectRoot);
        const confirm = params.confirm ?? false;
        const force = params.force ?? false;
        if (!confirm) {
            const preview = await previewDeleteProject(projectId);
            return {
                content: [
                    {
                        type: 'text',
                        text: JSON.stringify({
                            ...preview,
                            message: 'Preview: Set confirm=true to proceed with deletion.',
                        }, null, 2),
                    },
                ],
            };
        }
        const result = await executeDeleteProject(projectId, force);
        if (!result.success) {
            return {
                content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
                isError: true,
            };
        }
        return {
            content: [
                {
                    type: 'text',
                    text: JSON.stringify({
                        ...result,
                        message: `Successfully deleted project data (${String(result.itemsAffected)} files).`,
                    }, null, 2),
                },
            ],
        };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return {
            content: [{ type: 'text', text: `Delete project failed: ${message}` }],
            isError: true,
        };
    }
}
//# sourceMappingURL=delete-project.js.map