/**
 * olam ask — interactive assistant for olam usage + setup questions.
 *
 *   olam ask "<question>"   answer once and exit (script-friendly)
 *   olam ask                open an interactive multi-turn REPL
 *
 * Powered by the Claude Agent SDK on the operator's LOCAL Claude Code
 * subscription, pinned to Sonnet (`claude-sonnet-4-6`). No extra API cost on
 * top of the operator's existing Claude Code login. Grounded in a knowledge
 * pack bundled at build time, plus live repo files when run inside a checkout.
 *
 * Read-only: the assistant never mutates files or creates worlds.
 */
import { runOneShot } from '../ask/one-shot.js';
import { runRepl } from '../ask/repl.js';
/**
 * Route invocation to one-shot vs REPL based on argument presence. Pure
 * relative to the injected runners so the routing decision is unit-testable
 * without spinning up the SDK (Rule 9 — the WHY: a regression that routed a
 * bare `olam ask` to one-shot, or an arg to the REPL, breaks both the script
 * contract and the interactive contract silently).
 */
export async function routeAsk(question, runners) {
    if (typeof question === 'string' && question.trim().length > 0) {
        return runners.oneShot(question);
    }
    return runners.repl();
}
export function registerAsk(program) {
    program
        .command('ask')
        .description('Ask olam about its own usage, setup, and CLI (local Claude subscription)')
        .argument('[question...]', 'Question to answer once; omit to open an interactive REPL')
        .addHelpText('after', [
        '',
        'Modes:',
        '  olam ask "how do I create a world?"   Answer once and exit (script-friendly)',
        '  olam ask                               Open an interactive multi-turn REPL',
        '',
        'In the REPL, type /exit (or Ctrl-D) to quit. Conversation context is kept',
        'across turns.',
        '',
        'Auth & cost:',
        '  Uses your LOCAL Claude Code subscription via the Claude Agent SDK, pinned',
        '  to Sonnet (claude-sonnet-4-6). No extra API cost beyond your Claude Code',
        '  login. If Claude Code is not installed or not logged in, olam ask exits',
        '  with instructions.',
        '',
        'Grounding:',
        '  Answers come from a knowledge pack bundled into the CLI. Inside an olam',
        '  checkout, the assistant can also read live repo files for fresher answers.',
    ].join('\n'))
        .action(async (questionParts) => {
        // commander gives variadic args as an array; join into one question.
        const question = questionParts.join(' ').trim();
        const code = await routeAsk(question.length > 0 ? question : undefined, {
            oneShot: (q) => runOneShot(q),
            repl: () => runRepl(),
        });
        process.exitCode = code;
    });
}
//# sourceMappingURL=ask.js.map