"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 serverManager_1 = require("../../../src/agents/tools/ycmd/serverManager");
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
async function testWorkspaceConfiguration() {
    console.log("=== Workspace Configuration Diagnostic Test ===\n");
    const cwd = process.cwd();
    console.log("Current working directory:", cwd);
    const tsconfigPath = path.join(cwd, "tsconfig.json");
    const tsconfigExists = fs.existsSync(tsconfigPath);
    console.log("tsconfig.json exists:", tsconfigExists);
    if (tsconfigExists) {
        const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, "utf8"));
        console.log("tsconfig.json compilerOptions.rootDir:", tsconfig.compilerOptions?.rootDir);
        console.log("tsconfig.json include patterns:", tsconfig.include);
    }
    const testFiles = [
        "./src/index.ts",
        "./src/agents/tools/ycmd/utils/pathUtils.ts",
    ];
    for (const filepath of testFiles) {
        console.log(`\n--- Testing file: ${filepath} ---`);
        const absolutePath = path.resolve(filepath);
        console.log("Absolute path:", absolutePath);
        console.log("File exists:", fs.existsSync(absolutePath));
        if (!fs.existsSync(absolutePath)) {
            console.log("❌ File does not exist, skipping...");
            continue;
        }
        try {
            console.log("\nStarting fresh ycmd server...");
            const setupResult = await serverManager_1.ycmdServerManager.setupClientAndNotifyFile({
                filepath
            });
            if (!setupResult.success) {
                console.error("❌ Setup failed:", setupResult.message);
                continue;
            }
            console.log("✅ File notification successful");
            console.log("Resolved file path:", setupResult.resolvedFilePath);
            console.log("File types:", setupResult.filetypes);
            console.log("\nTesting diagnostics...");
            try {
                const diagnostics = await setupResult.client.getDiagnostics(setupResult.resolvedFilePath, setupResult.contents, setupResult.filetypes);
                console.log("✅ Diagnostics successful");
                console.log("Diagnostic count:", diagnostics?.length || 0);
            }
            catch (diagError) {
                console.error("❌ Diagnostics failed:", diagError.message);
            }
        }
        catch (error) {
            console.error("❌ Test failed for", filepath, ":", error.message);
        }
        await serverManager_1.ycmdServerManager.stop();
        console.log("Server stopped for next test");
    }
    console.log("\n=== Workspace Configuration Test Complete ===");
}
testWorkspaceConfiguration()
    .catch(console.error)
    .finally(() => {
    process.exit(0);
});
//# sourceMappingURL=test_workspace_config.js.map