#!/usr/bin/env node
/**
* Script to generate example checklists for the examples/ directory
*/
import { handleGenerateChecklist } from '../dist/tools/handlers.js';
import { writeFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const examplesDir = join(__dirname, '..', 'examples');
const rfcs = [
{ rfc: 6455, filename: 'rfc6455-websocket-checklist.md', role: 'both' },
{ rfc: 9293, filename: 'rfc9293-tcp-checklist.md', role: 'both' },
{ rfc: 7540, filename: 'rfc7540-http2-checklist.md', role: 'both' },
];
async function generateChecklist(rfcNumber, role) {
const result = await handleGenerateChecklist({ rfc: rfcNumber, role });
return result;
}
function createFileContent(result, generatedDate) {
// Add meta header before the generated markdown
const metaHeader = `> 🤖 This file was auto-generated by rfcxml-mcp's \`generate_checklist\` tool.
>
> Generated: ${generatedDate}
> Tool: @shuji-bonji/rfcxml-mcp
> Source: ${result._source === 'xml' ? 'RFCXML (high accuracy)' : 'Text fallback (medium accuracy)'}
---
`;
let content = metaHeader + result.markdown;
// Add source note if from text fallback
if (result._source === 'text') {
content += `\n---\n\n> ⚠️ ${result._sourceNote}\n`;
}
return content;
}
async function main() {
const generatedDate = new Date().toISOString().split('T')[0];
for (const { rfc, filename, role } of rfcs) {
console.log(`Generating checklist for RFC ${rfc}...`);
try {
const result = await generateChecklist(rfc, role);
const content = createFileContent(result, generatedDate);
const filepath = join(examplesDir, filename);
writeFileSync(filepath, content, 'utf-8');
console.log(` ✓ Written to ${filename} (source: ${result._source}, ${result.stats.total} requirements)`);
} catch (error) {
console.error(` ✗ Failed: ${error.message}`);
}
}
console.log('\nDone!');
}
main();