// engine/journey-guidance.ts — Journey guidance next steps (SPEC-026b)
// Computes a prioritized list of next steps from ProjectCompleteness + DX signals.
// === Step catalog ===
const STEP_TEMPLATES = [
    // === MVP blockers (critical) ===
    {
        gap: 'No README',
        description: 'Project has no README.md. Add one with setup instructions, usage examples, and contribution guidelines.',
        impact: 'high',
        phase: 'mvp',
        planuToolHint: 'generate_docs',
        effortHours: 1,
        predicate: (c) => !c.hasReadme,
    },
    {
        gap: 'No testing framework',
        description: 'No automated tests detected. Add vitest (TypeScript), pytest (Python), or Jest (JavaScript).',
        impact: 'high',
        phase: 'mvp',
        planuToolHint: 'generate_tests',
        effortHours: 4,
        predicate: (c) => !c.hasTesting,
    },
    {
        gap: 'No CI/CD pipeline',
        description: 'No continuous integration configured. Add GitHub Actions or GitLab CI to automate tests and deployments.',
        impact: 'high',
        phase: 'mvp',
        planuToolHint: 'suggest_tooling',
        effortHours: 3,
        predicate: (c) => !c.hasCiCd,
    },
    {
        gap: 'No .env.example',
        description: 'No .env.example found. Document required environment variables so contributors can set up the project.',
        impact: 'high',
        phase: 'mvp',
        planuToolHint: 'init_project',
        effortHours: 1,
        predicate: (c) => !c.hasEnvExample,
    },
    {
        gap: 'No linter configured',
        description: 'No linting tool detected. Add ESLint/Biome (TypeScript/JS) or ruff (Python).',
        impact: 'high',
        phase: 'mvp',
        planuToolHint: 'suggest_tooling',
        effortHours: 2,
        predicate: (c) => !c.hasLinting,
    },
    // === Production important ===
    {
        gap: 'No error tracking',
        description: 'No error tracking tool detected. Add Sentry, Bugsnag, or Rollbar to capture runtime errors in production.',
        impact: 'high',
        phase: 'production',
        planuToolHint: 'suggest_tooling',
        effortHours: 3,
        predicate: (c) => !c.hasErrorTracking,
    },
    {
        gap: 'No security scanning',
        description: 'No dependency vulnerability scanning. Add Dependabot, Snyk, or OWASP Dependency-Check.',
        impact: 'high',
        phase: 'production',
        planuToolHint: 'suggest_tooling',
        effortHours: 2,
        predicate: (c) => !c.hasSecurityScanning,
    },
    {
        gap: 'No type checking',
        description: 'No static type checking configured. Add TypeScript or mypy to catch bugs early.',
        impact: 'medium',
        phase: 'production',
        planuToolHint: 'suggest_tooling',
        effortHours: 4,
        predicate: (c) => !c.hasTypeChecking,
    },
    {
        gap: 'No documentation beyond README',
        description: 'No API or user documentation detected. Add an OpenAPI spec, docs/ folder, or wiki.',
        impact: 'medium',
        phase: 'production',
        planuToolHint: 'generate_docs',
        effortHours: 6,
        predicate: (c) => c.hasReadme && !c.hasDocumentation,
    },
    {
        gap: 'No changelog strategy',
        description: 'No CHANGELOG.md or conventional commits strategy detected. Add a changelog to track releases.',
        impact: 'medium',
        phase: 'production',
        planuToolHint: 'generate_docs',
        effortHours: 2,
        predicate: (c) => !c.hasChangelogStrategy,
    },
    // === Optional improvements ===
    {
        gap: 'No code formatting',
        description: 'No formatter configured. Add Prettier (JS/TS), black (Python), or similar to keep style consistent.',
        impact: 'low',
        phase: 'optional',
        planuToolHint: 'suggest_tooling',
        effortHours: 1,
        predicate: (c) => !c.hasFormatting,
    },
    {
        gap: 'No CONTRIBUTING guide',
        description: 'No CONTRIBUTING.md found. Add contribution guidelines to encourage collaboration.',
        impact: 'low',
        phase: 'optional',
        planuToolHint: 'generate_docs',
        effortHours: 2,
        predicate: (c) => !c.hasContributing,
    },
    {
        gap: 'No backup strategy',
        description: 'No database backup strategy detected. Define an automated backup plan.',
        impact: 'medium',
        phase: 'production',
        planuToolHint: 'suggest_tooling',
        effortHours: 4,
        predicate: (c) => !c.hasBackupStrategy,
    },
    {
        gap: 'Low DX health score',
        description: 'Overall Developer Experience health is low. Run suggest_tooling for detailed recommendations.',
        impact: 'medium',
        phase: 'production',
        planuToolHint: 'suggest_tooling',
        effortHours: 8,
        predicate: (_c, s) => s.score < 40,
    },
];
// === Public API ===
/**
 * Computes a prioritized list of journey next steps based on project completeness
 * and DX health score. Steps are ordered by impact then phase.
 */
export function computeJourneyGuidance(completeness, dxScore) {
    const applicable = STEP_TEMPLATES.filter((t) => t.predicate(completeness, dxScore));
    const nextSteps = applicable
        .map((t) => ({
        gap: t.gap,
        description: t.description,
        impact: t.impact,
        phase: t.phase,
        planuToolHint: t.planuToolHint,
        effortHours: t.effortHours,
    }))
        .sort(compareSteps);
    const criticalCount = nextSteps.filter((s) => s.impact === 'high').length;
    const mvpBlockers = nextSteps.filter((s) => s.phase === 'mvp');
    return { nextSteps, criticalCount, mvpBlockers };
}
// === Sorting ===
function compareSteps(a, b) {
    // Sort by impact: high > medium > low
    const impactOrder = { high: 0, medium: 1, low: 2 };
    const impactDiff = impactOrder[a.impact] - impactOrder[b.impact];
    if (impactDiff !== 0) {
        return impactDiff;
    }
    // Then by phase: mvp > production > optional
    const phaseOrder = { mvp: 0, production: 1, optional: 2 };
    return phaseOrder[a.phase] - phaseOrder[b.phase];
}
//# sourceMappingURL=journey-guidance.js.map