// SPEC-597-EXEMPT: canonical mapping (npm-package↔framework, keyword catalogue)
// — must enumerate framework names by design; no detection logic to migrate.
// tools/deploy/deploy-status.ts — SPEC-478
import { listDeployments, getDeployConfig } from '../../storage/deploy-config-store.js';
import { getVercelDeploymentStatus } from '../../engine/deploy/providers/vercel.js';
import { trackCost } from '../../engine/cost-tracking/operation-tracker.js';
export async function handleDeployStatus(input) {
    return trackCost(input.projectPath, 'deploy_status', async () => {
        try {
            if (input.deploymentId && input.provider && input.refresh) {
                const config = await getDeployConfig(input.projectPath, input.provider);
                if (config && input.provider === 'vercel') {
                    const fresh = await getVercelDeploymentStatus(config, input.deploymentId);
                    return {
                        content: [
                            {
                                type: 'text',
                                text: `Deployment ${fresh.id}: ${fresh.status}${fresh.url ? ` — ${fresh.url}` : ''}`,
                            },
                        ],
                        structuredContent: fresh,
                    };
                }
            }
            const all = await listDeployments(input.projectPath, input.provider);
            if (all.length === 0) {
                return {
                    content: [{ type: 'text', text: 'No deployments recorded for this project yet.' }],
                };
            }
            const recent = all.slice(0, 10);
            const lines = recent.map((d) => `- [${d.status}] ${d.provider} ${d.id}${d.url ? ` → ${d.url}` : ''} (${d.createdAt})`);
            return {
                content: [
                    {
                        type: 'text',
                        text: `Recent deployments (${String(recent.length)} of ${String(all.length)}):\n${lines.join('\n')}`,
                    },
                ],
                structuredContent: { deployments: recent },
            };
        }
        catch (err) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `Failed to read deploy status: ${err instanceof Error ? err.message : String(err)}`,
                    },
                ],
                isError: true,
            };
        }
    }); // end trackCost
}
//# sourceMappingURL=deploy-status.js.map