/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { Messages } from '@salesforce/core';
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
import { exportWorkspace } from '../../services/export-import.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@jterrats/setup-agents', 'setup-agents.export');
export default class Export extends SfCommand {
    static summary = messages.getMessage('summary');
    static description = messages.getMessage('description');
    static examples = messages.getMessages('examples');
    static flags = {
        output: Flags.string({
            summary: messages.getMessage('flags.output.summary'),
            description: messages.getMessage('flags.output.description'),
        }),
    };
    async run() {
        const { flags } = await this.parse(Export);
        const cwd = process.cwd();
        const bundle = exportWorkspace(cwd);
        const outputFile = flags.output ?? join(cwd, `setup-agents-export-${Date.now()}.json`);
        writeFileSync(outputFile, `${JSON.stringify(bundle, null, 2)}\n`, 'utf8');
        const { tasks, decisions, evidence, handoffs, reviews } = bundle.state;
        this.log(messages.getMessage('info.exported', [
            outputFile,
            String(tasks.length),
            String(decisions.length),
            String(evidence.length),
            String(handoffs.length),
            String(reviews.length),
        ]));
        return { outputFile, bundle };
    }
}
//# sourceMappingURL=export.js.map