UNPKG

llms-txt-generator

Version:

A powerful CLI tool and MCP server for generating standardized llms.txt and llms-full.txt documentation files to help AI models better understand project structures

80 lines (76 loc) 2.45 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const path_1 = require("path"); const init_1 = require("./init"); const build_1 = require("./build"); /** * 显示帮助信息 */ function showHelp() { console.log(` llms-txt-generator - Generate standardized documentation files for AI models Usage: llms-txt-generator [command] Commands: init Initialize configuration file (llms-txt-generator.yaml) build Generate llms.txt and llms-full.txt files help Show this help message If no command is provided: - If llms-txt-generator.yaml exists: run build - If llms-txt-generator.yaml doesn't exist: run init, then build Examples: llms-txt-generator init llms-txt-generator build llms-txt-generator `); } /** * 主函数 */ async function main() { const args = process.argv.slice(2); const command = args[0]; try { switch (command) { case 'init': await (0, init_1.init)(); break; case 'build': await (0, build_1.build)(); break; case 'help': case '--help': case '-h': showHelp(); break; case undefined: // 无参数调用:检查配置文件是否存在 const configPath = (0, path_1.join)(process.cwd(), 'llms-txt-generator.yaml'); if ((0, fs_1.existsSync)(configPath)) { console.log('📄 Configuration file found, generating documentation...'); await (0, build_1.build)(); } else { console.log('⚙️ No configuration file found, initializing...'); await (0, init_1.init)(); console.log('📄 Now generating documentation...'); await (0, build_1.build)(); } break; default: console.error(`❌ Unknown command: ${command}`); console.error('Run "llms-txt-generator help" for usage information.'); process.exit(1); } } catch (error) { console.error('❌ Error:', error instanceof Error ? error.message : String(error)); process.exit(1); } } // 运行主函数 main(); // export { main }; //# sourceMappingURL=index.js.map