MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / PsY

Function PsY

package/cli.js:16613–16613  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

16611`)),process.exit(1);z=YL6("claude-settings",".json",{contentHash:K}),$j(z,K,"utf8")}else{let{resolvedPath:Y}=F$(X8(),q);try{tA7(Y,"utf8")}catch($){if(_7($))process.stderr.write($8.red(`Error: Settings file not found: ${Y}
16612`)),process.exit(1);throw $}z=Y}Gi8(z),DW()}catch(K){if(K instanceof Error)H6(K);process.stderr.write($8.red(`Error processing settings: ${d6(K)}
16613`)),process.exit(1)}}function MsY(q){try{let K=Th7(q);bi8(K),DW()}catch(K){if(K instanceof Error)H6(K);process.stderr.write($8.red(`Error processing --setting-sources: ${d6(K)}
16614`)),process.exit(1)}}function XsY(){U4("eagerLoadSettings_start");let q=pA7("--settings");if(q)JsY(q);let K=pA7("--setting-sources");if(K!==void 0)MsY(K);U4("eagerLoadSettings_end")}function PsY(q){if(process.env.CLAUDE_CODE_ENTRYPOINT)return;let K=process.argv.slice(2),_=K.indexOf("mcp");if(_!==-1&&K[_+1]==="serve"){process.env.CLAUDE_CODE_ENTRYPOINT="mcp";return}if(i6(process.env.CLAUDE_CODE_ACTION)){process.env.CLAUDE_CODE_ENTRYPOINT="claude-code-github-action";return}process.env.CLAUDE_CODE_ENTRYPOINT=q?"sdk-cli":"cli"}async function WsY(){U4("main_function_start"),process.env.NoDefaultCurrentDirectoryInExePath="1",etK(),process.on("exit",()=>{GsY()}),process.on("SIGINT",()=>{if(process.argv.includes("-p")||process.argv.includes("--print"))return;process.exit(0)}),U4("main_warning_handler_initialized");{let w=process.argv.indexOf("--handle-uri");if(w!==-1&&process.argv[w+1]){let{enableConfigs:j}=await Promise.resolve().then(() => (V1(),G16));j();let H=process.argv[w+1],{handleDeepLinkUri:J}=await Promise.resolve().then(() => (UA7(),FA7)),M=await J(H);process.exit(M)}if(process.platform==="darwin"&&process.env.__CFBundleIdentifier==="com.anthropic.claude-code-url-handler"){let{enableConfigs:j}=await Promise.resolve().then(() => (V1(),G16));j();let{handleUrlSchemeLaunch:H}=await Promise.resolve().then(() => (UA7(),FA7)),J=await H();process.exit(J??1)}}let q=process.argv.slice(2),K=q.includes("-p")||q.includes("--print"),_=q.includes("--init-only"),z=q.some((w)=>w.startsWith("--sdk-url")),Y=K||_||z||!process.stdout.isTTY;if(Y)L16();Pi8(!Y),PsY(Y);let A=(()=>{if(i6(process.env.GITHUB_ACTIONS))return"github-action";if(process.env.CLAUDE_CODE_ENTRYPOINT==="sdk-ts")return"sdk-typescript";if(process.env.CLAUDE_CODE_ENTRYPOINT==="sdk-py")return"sdk-python";if(process.env.CLAUDE_CODE_ENTRYPOINT==="sdk-cli")return"sdk-cli";if(process.env.CLAUDE_CODE_ENTRYPOINT==="claude-vscode")return"claude-vscode";if(process.env.CLAUDE_CODE_ENTRYPOINT==="local-agent")return"local-agent";if(process.env.CLAUDE_CODE_ENTRYPOINT==="claude-desktop")return"claude-desktop";let w=process.env.CLAUDE_CODE_SESSION_ACCESS_TOKEN||process.env.CLAUDE_CODE_WEBSOCKET_AUTH_FILE_DESCRIPTOR;if(process.env.CLAUDE_CODE_ENTRYPOINT==="remote"||w)return"remote";return"cli"})();Wi8(A);let O=process.env.CLAUDE_CODE_QUESTION_PREVIEW_FORMAT;if(O==="markdown"||O==="html")O38(O);else if(!A.startsWith("sdk-")&&A!=="claude-desktop"&&A!=="local-agent"&&A!=="remote")O38("markdown");if(process.env.CLAUDE_CODE_ENVIRONMENT_KIND==="bridge")Zi8("remote-control");U4("main_client_type_determined"),XsY(),U4("main_before_run"),await fsY(),U4("main_after_run")}async function DsY(q,K){if(!process.stdin.isTTY&&!process.argv.includes("mcp")){if(K==="stream-json")return process.stdin;process.stdin.setEncoding("utf8");let _="",z=($)=>{_+=$};process.stdin.on("data",z);let Y=await Do8(process.stdin,3000);if(process.stdin.off("data",z),Y)process.stderr.write(`Warning: no stdin data received in 3s, proceeding without it. If piping from a slow command, redirect stdin explicitly: < /dev/null to skip, or wait longer.
16615`);return[q,_].filter(Boolean).join(`
16616`)}return q}async function fsY(){U4("run_function_start");function q(){let j=(H)=>H.long?.replace(/^--/,"")??H.short?.replace(/^-/,"")??"";return Object.assign({sortSubcommands:!0,sortOptions:!0},{compareOptions:(H,J)=>j(H).localeCompare(j(J))})}let K=new zUK().configureHelp(q()).enablePositionalOptions();if(U4("run_commander_initialized"),K.hook("preAction",async(j)=>{if(U4("preAction_start"),await Promise.all([hS7(),ICq()]),U4("preAction_after_mdm"),await NUK(),U4("preAction_after_init"),!i6(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE))process.title="claude";let{initSinks:H}=await Promise.resolve().then(() => (oq8(),lQ8));H(),U4("preAction_after_sinks");let J=j.getOptionValue("pluginDir");if(Array.isArray(J)&&J.length>0&&J.every((M)=>typeof M==="string"))xi8(J),Yk("preAction: --plugin-dir inline plugins");jsY(),U4("preAction_after_migrations"),AI4(),QF1(),U4("preAction_after_remote_settings"),U4("preAction_after_settings_sync")}),K.name("claude").description("Claude Code - starts an interactive session by default, use -p/--print for non-interactive output").argument("[prompt]","Your prompt",String).helpOption("-h, --help","Display help for command").option("-d, --debug [filter]",'Enable debug mode with optional category filtering (e.g., "api,hooks" or "!1p,!file")',(j)=>{return!0}).addOption(new G3("-d2e, --debug-to-stderr","Enable debug mode (to stderr)").argParser(Boolean).hideHelp()).option("--debug-file <path>","Write debug logs to a specific file path (implicitly enables debug mode)",()=>!0).option("--verbose","Override verbose mode setting from config",()=>!0).option("-p, --print","Print response and exit (useful for pipes). Note: The workspace trust dialog is skipped when Claude is run with the -p mode. Only use this flag in directories you trust.",()=>!0).option("--bare","Minimal mode: skip hooks, LSP, plugin sync, attribution, auto-memory, background prefetches, keychain reads, and CLAUDE.md auto-discovery. Sets CLAUDE_CODE_SIMPLE=1. Anthropic auth is strictly ANTHROPIC_API_KEY or apiKeyHelper via --settings (OAuth and keychain are never read). 3P providers (Bedrock/Vertex/Foundry) use their own credentials. Skills still resolve via /skill-name. Explicitly provide context via: --system-prompt[-file], --append-system-prompt[-file], --add-dir (CLAUDE.md dirs), --mcp-config, --settings, --agents, --plugin-dir.",()=>!0).addOption(new G3("--init","Run Setup hooks with init trigger, then continue").hideHelp()).addOption(new G3("--init-only","Run Setup and SessionStart:startup hooks, then exit").hideHelp()).addOption(new G3("--maintenance","Run Setup hooks with maintenance trigger, then continue").hideHelp()).addOption(new G3("--output-format <format>",'Output format (only works with --print): "text" (default), "json" (single result), or "stream-json" (realtime streaming)').choices(["text","json","stream-json"])).addOption(new G3("--json-schema <schema>",'JSON Schema for structured output validation. Example: {"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}').argParser(String)).option("--include-hook-events","Include all hook lifecycle events in the output stream (only works with --output-format=stream-json)",()=>!0).option("--include-partial-messages","Include partial message chunks as they arrive (only works with --print and --output-format=stream-json)",()=>!0).addOption(new G3("--input-format <format>",'Input format (only works with --print): "text" (default), or "stream-json" (realtime streaming input)').choices(["text","stream-json"])).option("--mcp-debug","[DEPRECATED. Use --debug instead] Enable MCP debug mode (shows MCP server errors)",()=>!0).option("--dangerously-skip-permissions","Bypass all permission checks. Recommended only for sandboxes with no internet access.",()=>!0).option("--allow-dangerously-skip-permissions","Enable bypassing all permission checks as an option, without it being enabled by default. Recommended only for sandboxes with no internet access.",()=>!0).addOption(new G3("--thinking <mode>","Thinking mode: enabled (equivalent to adaptive), disabled").choices(["enabled","adaptive","disabled"]).hideHelp()).addOption(new G3("--max-thinking-tokens <tokens>","[DEPRECATED. Use --thinking instead for newer models] Maximum number of thinking tokens (only works with --print)").argParser(Number).hideHelp()).addOption(new G3("--max-turns <turns>","Maximum number of agentic turns in non-interactive mode. This will early exit the conversation after the specified number of turns. (only works with --print)").argParser(Number).hideHelp()).addOption(new G3("--max-budget-usd <amount>","Maximum dollar amount to spend on API calls (only works with --print)").argParser((j)=>{let H=Number(j);if(isNaN(H)||H<=0)throw Error("--max-budget-usd must be a positive number greater than 0");return H})).addOption(new G3("--task-budget <tokens>","API-side task budget in tokens (output_config.task_budget)").argParser((j)=>{let H=Number(j);if(isNaN(H)||H<=0||!Number.isInteger(H))throw Error("--task-budget must be a positive integer");return H}).hideHelp()).option("--replay-user-messages","Re-emit user messages from stdin back on stdout for acknowledgment (only works with --input-format=stream-json and --output-format=stream-json)",()=>!0).addOption(new G3("--enable-auth-status","Enable auth status messages in SDK mode").default(!1).hideHelp()).option("--allowedTools, --allowed-tools <tools...>",'Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit")').option("--tools <tools...>",'Specify the list of available tools from the built-in set. Use "" to disable all tools, "default" to use all tools, or specify tool names (e.g. "Bash,Edit,Read").').option("--disallowedTools, --disallowed-tools <tools...>",'Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit")').option("--mcp-config <configs...>","Load MCP servers from JSON files or strings (space-separated)").addOption(new G3("--permission-prompt-tool <tool>","MCP tool to use for permission prompts (only works with --print)").argParser(String).hideHelp()).addOption(new G3("--system-prompt <prompt>","System prompt to use for the session").argParser(String)).addOption(new G3("--system-prompt-file <file>","Read system prompt from a file").argParser(String).hideHelp()).addOption(new G3("--append-system-prompt <prompt>","Append a system prompt to the default system prompt").argParser(String)).addOption(new G3("--append-system-prompt-file <file>","Read system prompt from a file and append to the default system prompt").argParser(String).hideHelp()).addOption(new G3("--permission-mode <mode>","Permission mode to use for the session").argParser(String).choices(pZ)).option("-c, --continue","Continue the most recent conversation in the current directory",()=>!0).option("-r, --resume [value]","Resume a conversation by session ID, or open interactive picker with optional search term",(j)=>j||!0).option("--fork-session","When resuming, create a new session ID instead of reusing the original (use with --resume or --continue)",()=>!0).addOption(new G3("--prefill <text>","Pre-fill the prompt input with text without submitting it").hideHelp()).addOption(new G3("--deep-link-origin","Signal that this session was launched from a deep link").hideHelp()).addOption(new G3("--deep-link-repo <slug>","Repo slug the deep link ?repo= parameter resolved to the current cwd").hideHelp()).addOption(new G3("--deep-link-last-fetch <ms>","FETCH_HEAD mtime in epoch ms, precomputed by the deep link trampoline").argParser((j)=>{let H=Number(j);return Number.isFinite(H)?H:void 0}).hideHelp()).option("--from-pr [value]","Resume a session linked to a PR by PR number/URL, or open interactive picker with optional search term",(j)=>j||!0).option("--no-session-persistence","Disable session persistence - sessions will not be saved to disk and cannot be resumed (only works with --print)").addOption(new G3("--resume-session-at <message id>","When resuming, only messages up to and including the assistant message with <message.id> (use with --resume in print mode)").argParser(String).hideHelp()).addOption(new G3("--rewind-files <user-message-id>","Restore files to state at the specified user message and exit (requires --resume)").hideHelp()).option("--model <model>","Model for the current session. Provide an alias for the latest model (e.g. 'sonnet' or 'opus') or a model's full name (e.g. 'claude-sonnet-4-6').").addOption(new G3("--effort <level>","Effort level for the current session (low, medium, high, max)").argParser((j)=>{let H=j.toLowerCase(),J=["low","medium","high","max"];if(!J.includes(H))throw new _UK(`It must be one of: ${J.join(", ")}`);return H})).option("--agent <agent>","Agent for the current session. Overrides the 'agent' setting.").option("--betas <betas...>","Beta headers to include in API requests (API key users only)").option("--fallback-model <model>","Enable automatic fallback to specified model when default model is overloaded (only works with --print)").addOption(new G3("--workload <tag>","Workload tag for billing-header attribution (cc_workload). Process-scoped; set by SDK daemon callers that spawn subprocesses for cron work. (only works with --print)").hideHelp()).option("--settings <file-or-json>","Path to a settings JSON file or a JSON string to load additional settings from").option("--add-dir <directories...>","Additional directories to allow tool access to").option("--ide","Automatically connect to IDE on startup if exactly one valid IDE is available",()=>!0).option("--strict-mcp-config","Only use MCP servers from --mcp-config, ignoring all other MCP configurations",()=>!0).option("--session-id <uuid>","Use a specific session ID for the conversation (must be a valid UUID)").option("-n, --name <name>","Set a display name for this session (shown in /resume and terminal title)").option("--agents <json>",`JSON object defining custom agents (e.g. '{"reviewer": {"description": "Reviews code", "prompt": "You are a code reviewer"}}')`).option("--setting-sources <sources>","Comma-separated list of setting sources to load (user, project, local).").option("--plugin-dir <path>","Load plugins from a directory for this session only (repeatable: --plugin-dir A --plugin-dir B)",(j,H)=>[...H,j],[]).option("--disable-slash-commands","Disable all skills",()=>!0).option("--chrome","Enable Claude in Chrome integration").option("--no-chrome","Disable Claude in Chrome integration").option("--file <specs...>","File resources to download at startup. Format: file_id:relative_path (e.g., --file file_abc:doc.txt file_def:img.png)").action(async(j,H)=>{if(U4("action_handler_start"),H.bare)process.env.CLAUDE_CODE_SIMPLE="1";if(j==="code")d("tengu_code_prompt_ignored",{}),console.warn($8.yellow("Tip: You can launch Claude Code with just `claude`")),j=void 0;if(j&&typeof j==="string"&&!/\s/.test(j)&&j.length>0)d("tengu_single_word_prompt",{length:j.length});let J=!1,M,{debug:X=!1,debugToStderr:P=!1,dangerouslySkipPermissions:W,allowDangerouslySkipPermissions:D=!1,tools:f=[],allowedTools:G=[],disallowedTools:Z=[],mcpConfig:T=[],permissionMode:v,addDir:V=[],fallbackModel:E,betas:S=[],ide:R=!1,sessionId:x,includeHookEvents:I,includePartialMessages:B}=H;if(H.prefill)QN1(H.prefill);let p,C=H.agents,g=H.agent,F=H.outputFormat,U=H.inputFormat,c=H.verbose??j8().verbose,K6=H.print,t=H.init??!1,q6=H.initOnly??!1,e=H.maintenance??!1,i=H.disableSlashCommands||!1,$6=!1,M6=$6?typeof $6==="string"?$6:ln1:void 0,j6=bR6()?H.worktree:void 0,G6=typeof j6==="string"?j6:void 0,w6=j6!==void 0,o;if(G6){let J1=xQ8(G6);if(J1!==null)o=J1,G6=void 0}let s=bR6()&&H.tmux===!0;if(s){if(!w6)process.stderr.write($8.red(`Error: --tmux requires --worktree

Callers 1

WsYFunction · 0.85

Calls 2

i6Function · 0.85
sliceMethod · 0.45

Tested by

no test coverage detected