"use strict";
/**
 * CLIProxy Help Display
 *
 * Handles:
 * - ccs cliproxy --help
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.showHelp = void 0;
const ui_1 = require("../../utils/ui");
const platform_detector_1 = require("../../cliproxy/binary/platform-detector");
const provider_capabilities_1 = require("../../cliproxy/provider-capabilities");
async function showHelp() {
    await (0, ui_1.initUI)();
    console.log('');
    console.log((0, ui_1.header)('CLIProxy Management'));
    console.log('');
    console.log((0, ui_1.subheader)('Usage:'));
    console.log(`  ${(0, ui_1.color)('ccs cliproxy', 'command')} <command> [options]`);
    console.log('');
    const sections = [
        [
            'Profile Commands:',
            [
                ['create [name]', 'Create new CLIProxy variant profile'],
                ['create --composite', 'Create composite variant (mix providers per tier)'],
                ['edit [name]', 'Edit an existing CLIProxy variant profile'],
                ['list', 'List all CLIProxy variant profiles'],
                ['remove <name>', 'Remove a CLIProxy variant profile'],
            ],
        ],
        [
            'Catalog Commands:',
            [
                ['catalog', 'Show catalog status, routing hints, and pinned short prefixes'],
                ['catalog refresh', 'Sync models from remote CLIProxy'],
                ['catalog reset', 'Clear cache, revert to static catalog'],
                ['catalog --json', 'Output full model catalog as minified JSON'],
            ],
        ],
        [
            'Local Sync:',
            [
                ['sync', 'Sync API profiles to local CLIProxy config'],
                ['sync --dry-run', 'Preview sync without applying'],
                ['sync --verbose', 'Show detailed sync information'],
            ],
        ],
        [
            'Quota Management:',
            [
                ['default <account>', 'Set default account for rotation'],
                ['pause <account>', 'Pause account (skip in rotation)'],
                ['resume <account>', 'Resume paused account'],
                ['quota', 'Show quota status for all providers (Codex/Claude include 5h + weekly reset)'],
                ['quota --provider <name>', `Filter by provider (${provider_capabilities_1.QUOTA_PROVIDER_HELP_TEXT})`],
                ['routing', 'Show current routing strategy and manual guidance'],
                ['routing explain', 'Explain strategy vs session-affinity and how sessions are recognized'],
                ['routing set <mode>', 'Explicitly set round-robin or fill-first'],
                ['routing affinity', 'Show local session-affinity status and TTL'],
                ['routing affinity <on|off> [--ttl <duration>]', 'Toggle local session-affinity settings'],
            ],
        ],
        [
            'Proxy Lifecycle:',
            [
                ['start', 'Start CLIProxy instance in background'],
                ['restart', 'Restart CLIProxy instance'],
                ['status', 'Show running CLIProxy status'],
                ['stop', 'Stop running CLIProxy instance'],
                ['doctor', 'Quota diagnostics and shared project detection'],
            ],
        ],
        [
            'Binary Commands:',
            [
                ['--install <version>', 'Install and pin a specific version'],
                ['--latest', 'Install the latest version (no pin)'],
                ['--update', 'Unpin and update to latest version'],
            ],
        ],
        [
            'Options:',
            [
                [
                    '--backend <type>',
                    'Use specific backend: original | plus (default: original; plus uses community fork)',
                ],
                ['--target <cli>', 'Default target for created/edited variants: claude | droid'],
                ['--verbose, -v', 'Show detailed diagnostics including routing hints and quota fetches'],
            ],
        ],
    ];
    for (const [title, cmds] of sections) {
        console.log((0, ui_1.subheader)(title));
        const maxLen = Math.max(...cmds.map(([cmd]) => cmd.length));
        for (const [cmd, desc] of cmds) {
            console.log(`  ${(0, ui_1.color)(cmd.padEnd(maxLen + 2), 'command')} ${desc}`);
        }
        console.log('');
    }
    console.log((0, ui_1.dim)('  Note: CLIProxy now persists by default. Use "stop" to terminate.'));
    console.log((0, ui_1.dim)('  Routing: use gcli/<model> or agy/<model> to keep overlapping models pinned.'));
    console.log((0, ui_1.dim)('  Backend: original is the default; plus is opt-in for plus-only providers.'));
    console.log('');
    console.log((0, ui_1.subheader)('Notes:'));
    console.log(`  Default fallback version: ${(0, ui_1.color)((0, platform_detector_1.getFallbackVersion)(), 'info')}`);
    console.log(`  Releases: ${(0, ui_1.color)(`https://github.com/${platform_detector_1.BACKEND_CONFIG[platform_detector_1.DEFAULT_BACKEND].repo}/releases`, 'path')}`);
    console.log('');
}
exports.showHelp = showHelp;
//# sourceMappingURL=help-subcommand.js.map