import { capableAgents } from '../../capabilities.js';
import { discoverPlugins, isPluginSynced } from '../../plugins/plugins.js';
import { lazyAgentMap } from '../writers/lazy-map.js';
function buildPluginsDetector(agent) {
    return {
        kind: 'plugins',
        agent,
        list({ versionHome }) {
            const synced = [];
            for (const plugin of discoverPlugins()) {
                if (isPluginSynced(plugin, agent, versionHome))
                    synced.push(plugin.name);
            }
            return synced;
        },
    };
}
export const pluginsDetectors = lazyAgentMap(() => {
    const m = {};
    for (const agent of capableAgents('plugins'))
        m[agent] = buildPluginsDetector(agent);
    return m;
});
