import { Command } from 'commander';
import { RegistryClient, readCredentials } from '@expxagents/registry-client';
export const whoamiCommand = new Command('whoami')
    .description('Show current registry identity')
    .action(async () => {
    const creds = readCredentials();
    if (!creds) {
        console.error('Not logged in. Run: expxagents login');
        process.exit(1);
    }
    const client = new RegistryClient({ registryUrl: creds.registryUrl, apiKey: creds.apiKey });
    try {
        const { author } = await client.whoami();
        console.log(`@${author.scope}`);
        if (author.name)
            console.log(`  Name: ${author.name}`);
        console.log(`  Registry: ${creds.registryUrl}`);
    }
    catch {
        console.error('\u2717 Invalid credentials. Run: expxagents login');
        process.exit(1);
    }
});
