// tools/onboarding-handler.ts — SPEC-360: Interactive Onboarding & Guided Tours
import { hashProjectPath } from '../storage/base-store.js';
import { getOnboardingConfig, saveOnboardingConfig } from '../storage/onboarding-store.js';
import { buildRecommendations, formatRecommendationsMarkdown, getGuidedTour, formatTourMarkdown, buildOnboardingChecklist, formatChecklistMarkdown, getQuickStart, buildProgressSummary, } from '../engine/onboarding-engine.js';
export async function handleStartOnboarding(args) {
    const projectId = hashProjectPath(args.projectPath);
    const config = {
        role: args.role,
        projectType: args.projectType,
        teamSize: args.teamSize,
        completedSteps: [],
        startedAt: new Date().toISOString(),
    };
    await saveOnboardingConfig(projectId, config);
    const recommendations = buildRecommendations(args.role, args.projectType, args.teamSize);
    const markdown = formatRecommendationsMarkdown(config, recommendations);
    return { content: [{ type: 'text', text: markdown }] };
}
// eslint-disable-next-line @typescript-eslint/require-await -- sync logic, async signature required by safe() wrapper
export async function handleGuidedTour(args) {
    const tour = getGuidedTour(args.area);
    const markdown = formatTourMarkdown(tour);
    return { content: [{ type: 'text', text: markdown }] };
}
export async function handleOnboardingChecklist(args) {
    const checklist = await buildOnboardingChecklist(args.projectPath);
    const markdown = formatChecklistMarkdown(checklist);
    return { content: [{ type: 'text', text: markdown }] };
}
// eslint-disable-next-line @typescript-eslint/require-await -- sync logic, async signature required by safe() wrapper
export async function handleQuickStart(args) {
    const content = getQuickStart(args.template);
    return { content: [{ type: 'text', text: content }] };
}
export async function handleOnboardingProgress(args) {
    const projectId = hashProjectPath(args.projectPath);
    const config = await getOnboardingConfig(projectId);
    const summary = await buildProgressSummary(args.projectPath, config);
    const lines = [
        `# Onboarding Progress`,
        ``,
        `**Project:** ${args.projectPath}`,
        `**Progress:** ${String(summary.percentComplete)}% complete`,
        ``,
        `## Setup Checklist`,
        ``,
        `${String(summary.checklist.completedCount)}/${String(summary.checklist.totalCount)} steps done`,
        ``,
    ];
    if (config !== null) {
        lines.push(`## Your Profile`, ``, `- Role: ${config.role}`, `- Project type: ${config.projectType}`, `- Team size: ${config.teamSize}`, `- Started: ${config.startedAt}`, ``);
    }
    lines.push(`## Next Steps`, ``);
    for (const step of summary.nextSteps) {
        lines.push(`- ${step}`);
    }
    return { content: [{ type: 'text', text: lines.join('\n') }] };
}
//# sourceMappingURL=onboarding-handler.js.map