#!/usr/bin/env npx tsx
"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 });
const index_1 = require("../../../src/agents/tools/ycmd/index");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
async function simpleDebugTest() {
    console.log('\n=== Simple Debug Test ===\n');
    const testFile = path.resolve('./test-simple.ts');
    const testContent = `
const message = "Hello World";
console.log(message);
`.trim();
    let success = false;
    try {
        fs.writeFileSync(testFile, testContent);
        console.log(`✅ Created test file: ${testFile}`);
        console.log('\n1. Testing basic completion...');
        const completionResult = await (0, index_1.ycmdCompletion)({
            filepath: testFile,
            line: 2,
            column: 15,
            contents: testContent
        });
        console.log('Completion result:', JSON.stringify(completionResult, null, 2));
        if (completionResult.success) {
            console.log('✅ SUCCESS: No "No Project" error!');
            success = true;
        }
        else {
            console.log('❌ FAILED: Request failed');
            if (completionResult.message && completionResult.message.includes('No Project')) {
                console.log('❌ "No Project" error still occurring!');
            }
        }
    }
    catch (error) {
        console.error('❌ Test failed with error:', error);
        if (error instanceof Error && error.message.includes('No Project')) {
            console.log('❌ "No Project" error caught in exception!');
        }
    }
    finally {
        try {
            if (fs.existsSync(testFile)) {
                fs.unlinkSync(testFile);
                console.log(`\n🧹 Cleaned up test file: ${testFile}`);
            }
        }
        catch (err) {
            console.log('Could not clean up test file:', err);
        }
        console.log('\n=== Test Results ===');
        if (success) {
            console.log('✅ Test PASSED - "No Project" error resolved!');
            process.exit(0);
        }
        else {
            console.log('❌ Test FAILED - "No Project" error still exists');
            process.exit(1);
        }
    }
}
process.on('SIGINT', () => {
    console.log('\nForced shutdown...');
    process.exit(1);
});
process.on('SIGTERM', () => {
    console.log('\nTerminated...');
    process.exit(1);
});
simpleDebugTest().catch((error) => {
    console.error('Unhandled error:', error);
    process.exit(1);
});
//# sourceMappingURL=test_simple_debug.js.map