/*
 * 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 { Messages } from '@salesforce/core';
import { SfCommand } from '@salesforce/sf-plugins-core';
import { isValidRecordId, listRecords } from '../../../services/orchestration-records.js';
import { resolveWorkspaceRoot } from '../../../services/workspace-root.js';
import { workspaceFlags } from '../../../util/task-flags.js';
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
const messages = Messages.loadMessages('@jterrats/setup-agents', 'setup-agents.evidence.validate');
export default class EvidenceValidate extends SfCommand {
    static summary = messages.getMessage('summary');
    static description = messages.getMessage('description');
    static examples = messages.getMessages('examples');
    static enableJsonFlag = true;
    static flags = { ...workspaceFlags };
    async run() {
        const { flags } = await this.parse(EvidenceValidate);
        const cwd = resolveWorkspaceRoot(flags);
        const records = listRecords(cwd, 'evidence');
        if (records.length === 0) {
            this.log(messages.getMessage('info.noRecords'));
            return { total: 0, valid: 0, invalid: [] };
        }
        const invalid = records.filter((r) => !isValidRecordId(r.id)).map((r) => ({ id: r.id, summary: r.summary }));
        if (invalid.length === 0) {
            this.log(messages.getMessage('info.valid', [String(records.length)]));
        }
        else {
            this.log(messages.getMessage('info.invalid', [String(invalid.length), String(records.length)]));
            for (const entry of invalid) {
                this.log(`  ${entry.id}  →  ${entry.summary}`);
            }
        }
        return { total: records.length, valid: records.length - invalid.length, invalid };
    }
}
//# sourceMappingURL=validate.js.map