"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CuratorPreviewTool = void 0;
exports.setCuratorToolRuntime = setCuratorToolRuntime;
const curator_1 = require("../curator/curator");
let projectDir = process.cwd();
let getCuratorConfig = () => ({ ...curator_1.DEFAULT_CURATOR_CONFIG });
let getKillSwitch = () => false;
function setCuratorToolRuntime(options) {
    if (options.projectDir)
        projectDir = options.projectDir;
    if (options.getConfig)
        getCuratorConfig = options.getConfig;
    if (options.isKillSwitchActive)
        getKillSwitch = options.isKillSwitchActive;
}
/**
 * curator_preview — read-only tool that runs the curator's deterministic
 * phase in dry-run mode and returns the would-archive list as text. Safe to
 * call from a workflow because no files are mutated.
 */
exports.CuratorPreviewTool = {
    name: 'curator_preview',
    description: 'Preview which skills the curator would archive. Read-only, no files are changed. Returns counts and per-skill reasoning.',
    parameters: { type: 'object', properties: {} },
    isReadOnly: true,
    async execute() {
        try {
            const summary = await (0, curator_1.runDeterministicPhase)(projectDir, getCuratorConfig(), { isKillSwitchActive: getKillSwitch }, { dryRun: true });
            const wouldArchive = summary.staleCandidates.filter((c) => c.kind === 'archive');
            const skipped = summary.staleCandidates.filter((c) => c.kind !== 'archive');
            const lines = [];
            lines.push(`Curator preview at ${summary.startedAt}`);
            lines.push(`${summary.staleCandidates.length} candidate(s) total, ${wouldArchive.length} would be archived.`);
            if (wouldArchive.length > 0) {
                lines.push('');
                lines.push('Would archive:');
                for (const action of wouldArchive) {
                    lines.push(`  - ${action.skill}: ${action.reason}`);
                }
            }
            if (skipped.length > 0) {
                lines.push('');
                lines.push('Skipped:');
                for (const action of skipped.slice(0, 20)) {
                    lines.push(`  - ${action.skill} (${action.kind}): ${action.reason}`);
                }
            }
            return { success: true, output: lines.join('\n') };
        }
        catch (error) {
            const msg = error instanceof Error ? error.message : String(error);
            return { success: false, output: `Curator preview failed: ${msg}`, error: msg };
        }
    },
};
//# sourceMappingURL=curatorTools.js.map