// tools/create-spec-hu/hu-body-generators.ts — Body section generators for HU.md
// SPEC-013: mobile accessibility criteria for ios/android targets.
/**
 * Generate the body section of HU.md based on spec type.
 * SPEC-013: includes mobile accessibility criteria for ios/android targets.
 */
export function generateHUBody(type, description, target, knowledge) {
    switch (type) {
        case 'bugfix':
            return [
                '## Bug Description',
                '',
                `Bug: ${description}`,
                '',
                '## Expected vs Actual',
                '',
                '**Expected behavior:** (Describe what should happen)',
                '',
                '**Actual behavior:** (Describe what actually happens)',
                '',
                '## Steps to Reproduce',
                '',
                '1. (Step 1)',
                '2. (Step 2)',
                '',
                '## Root Cause Analysis',
                '',
                '- (Analyze the root cause)',
                '',
                '## Fix Criteria',
                '',
                '- [ ] Bug is fixed as described',
                '- [ ] Root cause is addressed',
                '- [ ] Regression tests are written and passing',
                '- [ ] No regressions in existing functionality',
            ];
        case 'refactor':
            return [
                '## Refactoring Description',
                '',
                `Refactoring: ${description}`,
                '',
                '## Motivation',
                '',
                '- (Why is this refactoring needed?)',
                '',
                '## Current State',
                '',
                '- (Describe the current state)',
                '',
                '## Target State',
                '',
                '- (Describe the desired state after refactoring)',
                '',
                '## Acceptance Criteria',
                '',
                '- [ ] Refactoring is complete',
                '- [ ] All existing tests pass without modification',
                '- [ ] No behavioral changes',
                '- [ ] Code quality metrics improved',
            ];
        case 'infra':
            return [
                '## Infrastructure Description',
                '',
                description,
                '',
                '## Environments Affected',
                '',
                '- (List affected environments)',
                '',
                '## Schema Changes',
                '',
                '- (Database schema changes if applicable)',
                '',
                '## Acceptance Criteria',
                '',
                '- [ ] Infrastructure change is deployed',
                '- [ ] All environments are functional',
                '- [ ] Rollback plan is documented',
                '- [ ] No downtime during deployment',
                '',
                '## Rollback Plan',
                '',
                '- (Describe rollback procedure)',
            ];
        case 'docs':
            return [
                '## Documentation Description',
                '',
                description,
                '',
                '## Target Audience',
                '',
                '- (Who is this documentation for?)',
                '',
                '## Content Outline',
                '',
                '1. (Section 1)',
                '2. (Section 2)',
                '',
                '## Acceptance Criteria',
                '',
                '- [ ] Documentation is complete and accurate',
                '- [ ] Reviewed by target audience',
                '- [ ] All code examples are tested',
            ];
        // SPEC-027: tech-debt type — formal tracking with impact/risk/timeline
        case 'tech-debt':
            return [
                '## Tech Debt Description',
                '',
                description,
                '',
                '## Current Problem',
                '',
                '- (Describe the existing technical debt and how it manifests)',
                '',
                '## Impact on Productivity',
                '',
                '| Impact Area | Level | Notes |',
                '|-------------|-------|-------|',
                '| Developer velocity | High / Medium / Low | |',
                '| Onboarding friction | High / Medium / Low | |',
                '| Bug likelihood | High / Medium / Low | |',
                '',
                '## Risk of NOT Resolving',
                '',
                '| Risk | Probability | Notes |',
                '|------|-------------|-------|',
                '| Incident / outage | High / Medium / Low | |',
                '| Security exposure | High / Medium / Low | |',
                '| Team morale | High / Medium / Low | |',
                '',
                '## Debt Age',
                '',
                '- Exists since: (date or version)',
                '- Accumulated because: (reason — time pressure, unknown requirements, etc.)',
                '',
                '## Acceptance Criteria',
                '',
                '- [ ] Technical debt is resolved as described',
                '- [ ] All existing tests pass without modification',
                '- [ ] No new tech debt introduced',
                '- [ ] Estimated effort was tracked for future calibration',
                '',
                '## Estimated Effort',
                '',
                '| Phase | Hours |',
                '|-------|-------|',
                '| Analysis | |',
                '| Implementation | |',
                '| Testing | |',
                '| Review | |',
            ];
        case 'feature':
        case 'project':
        case 'agent':
        default: {
            // 'feature', 'project', and 'agent' use the standard format
            // If description is structured (multi-line or markdown), render as-is.
            // Short single-line descriptions get the standard user-story format.
            const isStructured = description.includes('\n') || description.startsWith('#') || description.length > 200;
            const descBody = isStructured
                ? description
                : `As a user, I want ${description}, so that I can achieve the expected outcome.`;
            const base = [
                '## Description',
                '',
                descBody,
                '',
                '## Acceptance Criteria',
                '',
                '- [ ] Feature is implemented as described',
                '- [ ] All edge cases are handled',
                '- [ ] Unit tests are written and passing',
                '- [ ] No regressions in existing functionality',
            ];
            // SPEC-013: inject mobile platform accessibility criteria
            if (target === 'ios') {
                base.push(...generateIosAccessibilityCriteria());
                base.push('');
                base.push('_Recommended sections: screens, navigation flow, state management');
                base.push('(SwiftUI/@State vs UIKit/delegates), lifecycle methods_');
            }
            else if (target === 'android') {
                const isCompose = knowledge?.apps.some((app) => app.framework === 'compose') ?? false;
                base.push(...generateAndroidAccessibilityCriteria(isCompose));
                base.push('');
                base.push('_Recommended sections: composables/fragments, navigation (NavController),');
                base.push('ViewModel_');
            }
            base.push('');
            base.push('## Out of Scope');
            base.push('');
            base.push('- (Define what is NOT included in this spec)');
            return base;
        }
    }
}
// SPEC-013: iOS accessibility and UI criteria
export function generateIosAccessibilityCriteria() {
    return [
        '',
        '### Accesibilidad iOS',
        '',
        '- [ ] Elementos interactivos tienen `accessibilityLabel` y `accessibilityHint` para VoiceOver',
        '- [ ] Fuentes usan Dynamic Type: `UIFont.preferredFont(forTextStyle:)` o `.scaledFont(for:)`',
        '- [ ] Touch targets son mínimo 44x44pt',
        '- [ ] Elementos interactivos tienen `accessibilityIdentifier` para XCUITests',
    ];
}
// SPEC-013: Android accessibility and UI criteria
export function generateAndroidAccessibilityCriteria(isCompose) {
    const lines = [
        '',
        '### Accesibilidad Android',
        '',
        '- [ ] Elementos no-texto tienen `contentDescription`',
        '- [ ] Touch targets son mínimo 48x48dp',
        '- [ ] Soporte TalkBack con `importantForAccessibility` correctamente configurado',
        '- [ ] Contraste WCAG AA verificable con AccessibilityChecker',
    ];
    if (isCompose) {
        lines.push('- [ ] Composables interactivos tienen `testTag` para Compose UI Tests');
    }
    else {
        lines.push('- [ ] Vistas interactivas tienen `android:contentDescription` para Espresso tests');
    }
    return lines;
}
// SPEC-025 tech-debt: conditional section builders
/** Linting Rules section — emitted when spec mentions lint/format/style/eslint/prettier */
export function buildLintingRulesSection() {
    return [
        '',
        '## Linting Rules',
        '',
        '- [ ] The new feature does not introduce `any` types',
        '- [ ] All new functions have explicit return types',
        '- [ ] No unused variables or imports',
        '- [ ] Run `pnpm lint` — zero warnings after implementation',
    ];
}
/** Environment Variables section — emitted when spec mentions env/api key/secret/token/config */
export function buildEnvVariablesSection() {
    return [
        '',
        '## Environment Variables',
        '',
        '- [ ] New env vars are documented in `.env.example`',
        '- [ ] New env vars have descriptions in `env-patterns.json` (if applicable)',
        '- [ ] No hardcoded secrets — all values come from `process.env.*`',
        '- [ ] `init_project` correctly detects the new variables',
    ];
}
//# sourceMappingURL=hu-body-generators.js.map