import { resolveClaudeBin } from './claudeBin' /** * Single source of truth for the `claude` (cc) terminal launch command. * * Every session entry point (brainstorm / implement / test / review / resume / * managed session) shells out `claude` with the same flags; building the * string in one place keeps those call sites from drifting apart. * * We deliberately pass no `--system-prompt`; cc runs with its own default * system prompt. */ export interface CcCommandOpts { /** Path passed to `--settings` (caller guarantees it contains no single quote). */ profilePath: string /** e.g. 'high' → `--effort high`; omitted means no `--effort`. */ effort?: string /** When set, append `--resume `. Mutually exclusive with prompt; resume wins. */ resumeSessionId?: string /** When set (and no resume), append the prompt as a positional `''` arg. */ prompt?: string } function quoteIfNeeded(bin: string): string { return bin.includes(' ') ? `'${bin}'` : bin } export function buildCcCommand(opts: CcCommandOpts): string { const parts = [quoteIfNeeded(resolveClaudeBin() ?? 'claude')] if (opts.effort) parts.push(`--effort ${opts.effort}`) parts.push('--dangerously-skip-permissions', `--settings '${opts.profilePath}'`) // resume and prompt are mutually exclusive; a resumed session restores its // own conversation, so a fresh prompt would be meaningless. if (opts.resumeSessionId) parts.push(`--resume ${opts.resumeSessionId}`) else if (opts.prompt) parts.push(`'${opts.prompt}'`) return parts.join(' ') }