// engine/plugins/doc-generator.ts — Plugin documentation generator (SPEC-085 AC-14)
function generateMetadataSection(manifest) {
    return [
        `# ${manifest.name}`,
        '',
        `> ${manifest.description}`,
        '',
        '## Metadata',
        '',
        `- **ID**: ${manifest.id}`,
        `- **Version**: ${manifest.version}`,
        `- **Author**: ${manifest.author}`,
        `- **License**: ${manifest.license}`,
        `- **Planu Version**: ${manifest.planuVersion}`,
        `- **Permissions**: ${manifest.permissions.join(', ') || 'none'}`,
        '',
    ];
}
function generateToolsSection(tools) {
    const lines = ['## Tools', ''];
    for (const tool of tools) {
        lines.push(`### ${tool.name}`, '', tool.description, '');
        if (Object.keys(tool.inputSchema).length > 0) {
            lines.push('**Input Schema:**', '```json', JSON.stringify(tool.inputSchema, null, 2), '```', '');
        }
    }
    return lines;
}
function generateWorkersSection(workers) {
    const lines = ['## Workers', ''];
    for (const worker of workers) {
        lines.push(`### ${worker.name}`, '', `- **Trigger**: ${worker.trigger}`);
        if (worker.interval) {
            lines.push(`- **Interval**: ${String(worker.interval)}ms`);
        }
        if (worker.eventName) {
            lines.push(`- **Event**: ${worker.eventName}`);
        }
        lines.push('');
    }
    return lines;
}
function generateAnalyzersSection(analyzers) {
    const lines = ['## Analyzers', ''];
    for (const analyzer of analyzers) {
        lines.push(`### ${analyzer.name}`, '', `- **File Patterns**: ${analyzer.filePatterns.join(', ')}`, '');
    }
    return lines;
}
function generateTemplatesSection(templates) {
    const lines = ['## Templates', ''];
    for (const template of templates) {
        lines.push(`### ${template.name}`, '', `- **Domain**: ${template.domain}`, '');
    }
    return lines;
}
/**
 * Generates Markdown documentation for a plugin based on its manifest and module.
 */
export function generatePluginDocs(manifest, mod) {
    const lines = [...generateMetadataSection(manifest)];
    if (mod?.tools && mod.tools.length > 0) {
        lines.push(...generateToolsSection(mod.tools));
    }
    if (mod?.workers && mod.workers.length > 0) {
        lines.push(...generateWorkersSection(mod.workers));
    }
    if (mod?.analyzers && mod.analyzers.length > 0) {
        lines.push(...generateAnalyzersSection(mod.analyzers));
    }
    if (mod?.templates && mod.templates.length > 0) {
        lines.push(...generateTemplatesSection(mod.templates));
    }
    if (manifest.i18n && Object.keys(manifest.i18n).length > 0) {
        lines.push('## Supported Languages', '', Object.keys(manifest.i18n).join(', '), '');
    }
    return lines.join('\n');
}
//# sourceMappingURL=doc-generator.js.map