/**
 * Clear Command
 *
 * Removes all Nori-managed configuration from the install directory
 * and clears the active skillset from config.
 */
import { log } from "@clack/prompts";
import { loadConfig, updateConfig, getDefaultAgents } from "../../../cli/config.js";
import { removeSkillset } from "../../../cli/features/agentOperations.js";
import { AgentRegistry } from "../../../cli/features/agentRegistry.js";
import { resolveInstallDir } from "../../../utils/path.js";
/**
 * Main function for the clear command
 * Removes all Nori-managed agent configs from the installDir
 * and clears the activeSkillset from the config.
 *
 * @param args - Configuration arguments
 * @param args.installDir - Custom installation directory override
 */
export const clearMain = async (args) => {
    const { installDir: cliInstallDir } = args ?? {};
    const config = await loadConfig();
    if (config == null) {
        log.info("No Nori configuration found. Nothing to clear.");
        return;
    }
    const effectiveInstallDir = resolveInstallDir({
        cliInstallDir,
        configInstallDir: config?.installDir,
        agentDirNames: AgentRegistry.getInstance().getAgentDirNames(),
    }).path;
    const agentNames = getDefaultAgents({ config });
    for (const agentName of agentNames) {
        const agentImpl = AgentRegistry.getInstance().get({ name: agentName });
        await removeSkillset({ agent: agentImpl, installDir: effectiveInstallDir });
    }
    await updateConfig({ activeSkillset: null });
    log.success("Cleared all Nori-managed configuration.");
};
//# sourceMappingURL=clear.js.map