/**
 * @license
 * Copyright 2025 HopCode Team
 * SPDX-License-Identifier: Apache-2.0
 */
import fs from 'node:fs/promises';
import * as os from 'node:os';
import path from 'node:path';
import { canUseRipgrep } from '@hoptrendy/hopcode-core';
// Individual warning checks
const homeDirectoryCheck = {
    id: 'home-directory',
    check: async (options) => {
        try {
            const [workspaceRealPath, homeRealPath] = await Promise.all([
                fs.realpath(options.workspaceRoot),
                fs.realpath(os.homedir()),
            ]);
            if (workspaceRealPath === homeRealPath) {
                return 'You are running HopCode in your home directory. It is recommended to run in a project-specific directory.';
            }
            return null;
        }
        catch (_err) {
            return 'Could not verify the current directory due to a file system error.';
        }
    },
};
const rootDirectoryCheck = {
    id: 'root-directory',
    check: async (options) => {
        try {
            const workspaceRealPath = await fs.realpath(options.workspaceRoot);
            const errorMessage = 'Warning: You are running HopCode in the root directory. Your entire folder structure will be used for context. It is strongly recommended to run in a project-specific directory.';
            // Check for Unix root directory
            if (path.dirname(workspaceRealPath) === workspaceRealPath) {
                return errorMessage;
            }
            return null;
        }
        catch (_err) {
            return 'Could not verify the current directory due to a file system error.';
        }
    },
};
const ripgrepAvailabilityCheck = {
    id: 'ripgrep-availability',
    check: async (options) => {
        if (!options.useRipgrep) {
            return null;
        }
        try {
            const isAvailable = await canUseRipgrep(options.useBuiltinRipgrep);
            if (!isAvailable) {
                return 'Ripgrep not available: Please install ripgrep globally to enable faster file content search. Falling back to built-in grep.';
            }
            return null;
        }
        catch (error) {
            return `Ripgrep not available: ${error instanceof Error ? error.message : 'Unknown error'}. Falling back to built-in grep.`;
        }
    },
};
// All warning checks
const WARNING_CHECKS = [
    homeDirectoryCheck,
    rootDirectoryCheck,
    ripgrepAvailabilityCheck,
];
export async function getUserStartupWarnings(options) {
    const results = await Promise.all(WARNING_CHECKS.map((check) => check.check(options)));
    return results.filter((msg) => msg !== null);
}
//# sourceMappingURL=userStartupWarnings.js.map