UNPKG

il2cpp-dump-analyzer-mcp

Version:

Agentic RAG system for analyzing IL2CPP dump.cs files from Unity games

173 lines 6.68 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const dotenv_1 = __importDefault(require("dotenv")); const hash_manager_factory_1 = require("./hash-manager-factory"); const yargs_1 = __importDefault(require("yargs")); const helpers_1 = require("yargs/helpers"); const fs = __importStar(require("fs")); const path = __importStar(require("path")); // Load environment variables dotenv_1.default.config(); /** * CLI utility for managing processed dump file hashes */ const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)) .command('list', 'List all processed file hashes', {}, async (args) => { const hashManager = (0, hash_manager_factory_1.createHashManagerFromEnv)(args.hashFile); // Wait for initialization if it's a Supabase hash manager if ('initialize' in hashManager) { await hashManager.initialize(); } const info = hashManager.getInfo(); const hashes = hashManager.getAllHashes(); console.log(`Hash storage: ${info.hashFilePath || 'Supabase database'}`); console.log(`Processed files: ${info.processedCount}`); console.log(''); if (hashes.length === 0) { console.log('No files have been processed yet.'); } else { console.log('Processed file hashes:'); hashes.forEach((hash, index) => { console.log(`${index + 1}. ${hash}`); }); } }) .command('clear', 'Clear all processed file hashes', {}, async (args) => { const hashManager = (0, hash_manager_factory_1.createHashManagerFromEnv)(args.hashFile); const info = hashManager.getInfo(); console.log(`Clearing all hashes from: ${info.hashFilePath || 'Supabase database'}`); if ('clearAllHashesAsync' in hashManager) { await hashManager.clearAllHashesAsync(); } else { hashManager.clearAllHashes(); } console.log('All processed file hashes have been cleared.'); }) .command('check <file>', 'Check if a file has been processed', { file: { describe: 'Path to the dump.cs file to check', type: 'string', demandOption: true } }, async (args) => { const hashManager = (0, hash_manager_factory_1.createHashManagerFromEnv)(args.hashFile); const filePath = args.file; if (!fs.existsSync(filePath)) { console.error(`Error: File not found: ${filePath}`); process.exit(1); } let isProcessed = hashManager.isFileProcessed(filePath); // For Supabase, also check the database if ('isFileProcessedAsync' in hashManager) { isProcessed = await hashManager.isFileProcessedAsync(filePath); } const hash = hashManager.getFileHash(filePath); const fileName = path.basename(filePath); console.log(`File: ${fileName}`); console.log(`Path: ${filePath}`); console.log(`Hash: ${hash}`); console.log(`Processed: ${isProcessed ? 'Yes' : 'No'}`); }) .command('remove <file>', 'Remove a file from the processed list', { file: { describe: 'Path to the dump.cs file to remove', type: 'string', demandOption: true } }, async (args) => { const hashManager = (0, hash_manager_factory_1.createHashManagerFromEnv)(args.hashFile); const filePath = args.file; if (!fs.existsSync(filePath)) { console.error(`Error: File not found: ${filePath}`); process.exit(1); } const fileName = path.basename(filePath); const hash = hashManager.getFileHash(filePath); let wasRemoved; if ('removeFileHashAsync' in hashManager) { wasRemoved = await hashManager.removeFileHashAsync(filePath); } else { wasRemoved = hashManager.removeFileHash(filePath); } if (wasRemoved) { console.log(`Removed ${fileName} (hash: ${hash.substring(0, 8)}...) from processed list.`); console.log('The file will be reprocessed on next run.'); } else { console.log(`File ${fileName} was not in the processed list.`); } }) .command('add <file>', 'Add a file to the processed list without processing', { file: { describe: 'Path to the dump.cs file to add', type: 'string', demandOption: true } }, async (args) => { const hashManager = (0, hash_manager_factory_1.createHashManagerFromEnv)(args.hashFile); const filePath = args.file; if (!fs.existsSync(filePath)) { console.error(`Error: File not found: ${filePath}`); process.exit(1); } const fileName = path.basename(filePath); let hash; if ('markFileAsProcessedAsync' in hashManager) { hash = await hashManager.markFileAsProcessedAsync(filePath); } else { hash = hashManager.markFileAsProcessed(filePath); } console.log(`Added ${fileName} (hash: ${hash.substring(0, 8)}...) to processed list.`); console.log('The file will be skipped on future runs unless forced.'); }) .option('hash-file', { type: 'string', description: 'Path to hash file (default: .processed_dumps)', global: true }) .help() .alias('help', 'h') .demandCommand(1, 'You need to specify a command') .parse(); //# sourceMappingURL=hash-cli.js.map