/**
 * CLI helper functions
 *
 * Utility functions for option parsing and task classification.
 */
import { isIssueReference } from '../../infra/git/index.js';
const REMOVED_ROOT_COMMANDS = new Set(['switch']);
/**
 * Resolve --provider and --model options into TaskExecutionOptions.
 * Returns undefined if neither is specified.
 */
export function resolveAgentOverrides(program) {
    const opts = program.opts();
    const provider = opts.provider;
    const model = opts.model;
    if (!provider && !model) {
        return undefined;
    }
    return {
        ...(provider !== undefined ? { provider, providerSource: 'cli' } : {}),
        ...(model !== undefined ? { model, modelSource: 'cli' } : {}),
    };
}
/**
 * Check if the input is a task description that should execute directly
 * vs one that should enter interactive mode.
 *
 * Direct execution (returns true):
 * - Valid issue references (e.g., "#32", "#10 #20")
 *
 * Interactive mode (returns false):
 * - All other inputs (task descriptions, single words, slash-prefixed, etc.)
 *
 * Note: This simplified logic ensures that only explicit issue references
 * trigger direct execution. All other inputs go through interactive mode
 * for requirement clarification.
 */
export function isDirectTask(input) {
    return isIssueReference(input) || input.trim().split(/\s+/).every((t) => isIssueReference(t));
}
export function resolveSlashFallbackTask(args, knownCommands) {
    const firstArg = args[0];
    if (!firstArg?.startsWith('/')) {
        return null;
    }
    const commandName = firstArg.slice(1);
    if (knownCommands.includes(commandName)) {
        return null;
    }
    return args.join(' ');
}
export function resolveRemovedRootCommand(args) {
    const firstArg = args[0];
    if (!firstArg) {
        return null;
    }
    return REMOVED_ROOT_COMMANDS.has(firstArg) ? firstArg : null;
}
export function resolveWorkflowCliOption(opts) {
    return typeof opts.workflow === 'string' ? opts.workflow : undefined;
}
//# sourceMappingURL=helpers.js.map