import { hashProjectPath } from '../storage/base-store.js';
import { previewDeleteProject, executeDeleteProject } from '../engine/deleter/core.js';
import { t, ti } from '../i18n/index.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: t('tools.delete_project.preview') }],
                structuredContent: preview,
            };
        }
        const result = await executeDeleteProject(projectId, force);
        if (!result.success) {
            return {
                content: [
                    {
                        type: 'text',
                        text: result.warnings.length > 0 ? result.warnings.join('\n') : 'Delete failed.',
                    },
                ],
                isError: true,
                structuredContent: result,
            };
        }
        return {
            content: [
                {
                    type: 'text',
                    text: ti('tools.delete_project.success', { count: String(result.itemsAffected) }),
                },
            ],
            structuredContent: result,
        };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : String(error);
        return {
            content: [{ type: 'text', text: ti('tools.delete_project.error', { message }) }],
            isError: true,
        };
    }
}
//# sourceMappingURL=delete-project.js.map