source dump of claude code
at main 46 lines 1.8 kB view raw
1import { isEnvDefinedFalsy, isEnvTruthy } from '../../utils/envUtils.js' 2import { AGENT_TOOL_NAME } from '../AgentTool/constants.js' 3import { BASH_TOOL_NAME } from '../BashTool/toolName.js' 4import { FILE_EDIT_TOOL_NAME } from '../FileEditTool/constants.js' 5import { FILE_READ_TOOL_NAME } from '../FileReadTool/prompt.js' 6import { FILE_WRITE_TOOL_NAME } from '../FileWriteTool/prompt.js' 7import { GLOB_TOOL_NAME } from '../GlobTool/prompt.js' 8import { GREP_TOOL_NAME } from '../GrepTool/prompt.js' 9import { NOTEBOOK_EDIT_TOOL_NAME } from '../NotebookEditTool/constants.js' 10 11export const REPL_TOOL_NAME = 'REPL' 12 13/** 14 * REPL mode is default-on for ants in the interactive CLI (opt out with 15 * CLAUDE_CODE_REPL=0). The legacy CLAUDE_REPL_MODE=1 also forces it on. 16 * 17 * SDK entrypoints (sdk-ts, sdk-py, sdk-cli) are NOT defaulted on — SDK 18 * consumers script direct tool calls (Bash, Read, etc.) and REPL mode 19 * hides those tools. USER_TYPE is a build-time --define, so the ant-native 20 * binary would otherwise force REPL mode on every SDK subprocess regardless 21 * of the env the caller passes. 22 */ 23export function isReplModeEnabled(): boolean { 24 if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_REPL)) return false 25 if (isEnvTruthy(process.env.CLAUDE_REPL_MODE)) return true 26 return ( 27 process.env.USER_TYPE === 'ant' && 28 process.env.CLAUDE_CODE_ENTRYPOINT === 'cli' 29 ) 30} 31 32/** 33 * Tools that are only accessible via REPL when REPL mode is enabled. 34 * When REPL mode is on, these tools are hidden from Claude's direct use, 35 * forcing Claude to use REPL for batch operations. 36 */ 37export const REPL_ONLY_TOOLS = new Set([ 38 FILE_READ_TOOL_NAME, 39 FILE_WRITE_TOOL_NAME, 40 FILE_EDIT_TOOL_NAME, 41 GLOB_TOOL_NAME, 42 GREP_TOOL_NAME, 43 BASH_TOOL_NAME, 44 NOTEBOOK_EDIT_TOOL_NAME, 45 AGENT_TOOL_NAME, 46])