#!/usr/bin/env ts-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;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.runYcmdTests = runYcmdTests;
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
const ycmd_1 = require("../../../src/agents/tools/ycmd");
async function runYcmdTests() {
    console.log('🚀 Starting ycmd integration tests...\n');
    try {
        console.log('1. Starting ycmd server...');
        const serverInfo = await (0, ycmd_1.ycmdStart)({
            workspaceRoot: process.cwd()
        });
        console.log('✅ Server started:', serverInfo);
        const tsTestFile = path.resolve('./test_ycmd_experiment.ts');
        const pyTestFile = path.resolve('./test_ycmd_usage.py');
        if (fs.existsSync(tsTestFile)) {
            console.log('\n2. Testing TypeScript completions...');
            const tsCompletion = await (0, ycmd_1.ycmdCompletion)({
                filepath: tsTestFile,
                line: 20,
                column: 10
            });
            console.log('✅ TypeScript completion:', JSON.stringify(tsCompletion, null, 2));
            console.log('\n3. Testing TypeScript diagnostics...');
            const tsDiagnostics = await (0, ycmd_1.ycmdDiagnostics)({
                filepath: tsTestFile
            });
            console.log('✅ TypeScript diagnostics:', JSON.stringify(tsDiagnostics, null, 2));
            console.log('\n4. Testing goto definition...');
            const gotoResult = await (0, ycmd_1.ycmdGoTo)({
                filepath: tsTestFile,
                line: 23,
                column: 15,
                command: 'GoTo'
            });
            console.log('✅ Goto definition:', JSON.stringify(gotoResult, null, 2));
        }
        else {
            console.log('⚠️  TypeScript test file not found, skipping TS tests');
        }
        if (fs.existsSync(pyTestFile)) {
            console.log('\n5. Testing Python completions...');
            const pyCompletion = await (0, ycmd_1.ycmdCompletion)({
                filepath: pyTestFile,
                line: 14,
                column: 15
            });
            console.log('✅ Python completion:', JSON.stringify(pyCompletion, null, 2));
            console.log('\n6. Testing Python diagnostics...');
            const pyDiagnostics = await (0, ycmd_1.ycmdDiagnostics)({
                filepath: pyTestFile
            });
            console.log('✅ Python diagnostics:', JSON.stringify(pyDiagnostics, null, 2));
            console.log('\n7. Testing signature help...');
            const signatureHelp = await (0, ycmd_1.ycmdSignatureHelp)({
                filepath: pyTestFile,
                line: 25,
                column: 30
            });
            console.log('✅ Signature help:', JSON.stringify(signatureHelp, null, 2));
        }
        else {
            console.log('⚠️  Python test file not found, skipping Python tests');
        }
        console.log('\n🎉 All ycmd tests completed successfully!');
        console.log('✅ ycmd tools are working correctly');
        process.exit(0);
    }
    catch (error) {
        console.error('❌ Test failed:', error);
        if (error instanceof Error) {
            console.error('Error message:', error.message);
            console.error('Stack trace:', error.stack);
        }
        process.exit(1);
    }
}
if (require.main === module) {
    runYcmdTests().catch((error) => {
        console.error(error);
        process.exit(1);
    });
}
//# sourceMappingURL=test_ycmd_integration.js.map