UNPKG

vibe-coder-mcp

Version:

Production-ready MCP server with complete agent integration, multi-transport support, and comprehensive development automation tools for AI-assisted workflows.

59 lines (58 loc) 2.44 kB
import { initializeParser, loadLanguageGrammar } from './parser.js'; import path from 'path'; import fs from 'fs/promises'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const GRAMMARS_DIR = path.join(__dirname, 'grammars'); async function testGrammarLoading(extension, wasmFile) { console.log(`\n=== Testing grammar loading for ${extension} (${wasmFile}) ===`); const fullPath = path.join(GRAMMARS_DIR, wasmFile); try { await fs.access(fullPath, fs.constants.F_OK); console.log(`✅ Grammar file exists: ${fullPath}`); const loaded = await loadLanguageGrammar(extension, { name: extension, wasmPath: wasmFile }); if (loaded) { console.log(`✅ Successfully loaded grammar`); return true; } else { console.error(`❌ Failed to load grammar`); return false; } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); console.error(`❌ Error accessing grammar file: ${errorMessage}`); return false; } } async function runTests() { try { console.log("Initializing Tree-sitter parser..."); await initializeParser(); console.log("✅ Parser initialized successfully"); console.log(`\nGrammar directory: ${GRAMMARS_DIR}`); const testCases = [ { extension: '.js', wasmFile: 'tree-sitter-javascript.wasm' }, { extension: '.ts', wasmFile: 'tree-sitter-typescript.wasm' }, { extension: '.py', wasmFile: 'tree-sitter-python.wasm' }, { extension: '.html', wasmFile: 'tree-sitter-html.wasm' }, { extension: '.css', wasmFile: 'tree-sitter-css.wasm' }, { extension: '.json', wasmFile: 'tree-sitter-json.wasm' } ]; let successCount = 0; for (const testCase of testCases) { const success = await testGrammarLoading(testCase.extension, testCase.wasmFile); if (success) successCount++; } console.log(`\n=== Test Summary ===`); console.log(`Tested ${testCases.length} languages`); console.log(`${successCount}/${testCases.length} succeeded`); } catch (error) { console.error("❌ Test failed with error:", error); } } runTests().catch(console.error);