MCPcopy
hub / github.com/codeaashu/claude-code / buildInheritedCliFlags

Function buildInheritedCliFlags

src/tools/shared/spawnMultiAgent.ts:208–260  ·  view source on GitHub ↗

* Builds CLI flags to propagate from the current session to spawned teammates. * This ensures teammates inherit important settings like permission mode, * model selection, and plugin configuration from their parent. * * @param options.planModeRequired - If true, don't inherit bypass permissions

(options?: {
  planModeRequired?: boolean
  permissionMode?: PermissionMode
})

Source from the content-addressed store, hash-verified

206 * @param options.permissionMode - Permission mode to propagate
207 */
208function buildInheritedCliFlags(options?: {
209 planModeRequired?: boolean
210 permissionMode?: PermissionMode
211}): string {
212 const flags: string[] = []
213 const { planModeRequired, permissionMode } = options || {}
214
215 // Propagate permission mode to teammates, but NOT if plan mode is required
216 // Plan mode takes precedence over bypass permissions for safety
217 if (planModeRequired) {
218 // Don't inherit bypass permissions when plan mode is required
219 } else if (
220 permissionMode === 'bypassPermissions' ||
221 getSessionBypassPermissionsMode()
222 ) {
223 flags.push('--dangerously-skip-permissions')
224 } else if (permissionMode === 'acceptEdits') {
225 flags.push('--permission-mode acceptEdits')
226 } else if (permissionMode === 'auto') {
227 // Teammates inherit auto mode so the classifier auto-approves their tool
228 // calls too. The teammate's own startup (permissionSetup.ts) handles
229 // GrowthBook gate checks and setAutoModeActive(true) independently.
230 flags.push('--permission-mode auto')
231 }
232
233 // Propagate --model if explicitly set via CLI
234 const modelOverride = getMainLoopModelOverride()
235 if (modelOverride) {
236 flags.push(`--model ${quote([modelOverride])}`)
237 }
238
239 // Propagate --settings if set via CLI
240 const settingsPath = getFlagSettingsPath()
241 if (settingsPath) {
242 flags.push(`--settings ${quote([settingsPath])}`)
243 }
244
245 // Propagate --plugin-dir for each inline plugin
246 const inlinePlugins = getInlinePlugins()
247 for (const pluginDir of inlinePlugins) {
248 flags.push(`--plugin-dir ${quote([pluginDir])}`)
249 }
250
251 // Propagate --chrome / --no-chrome if explicitly set on the CLI
252 const chromeFlagOverride = getChromeFlagOverride()
253 if (chromeFlagOverride === true) {
254 flags.push('--chrome')
255 } else if (chromeFlagOverride === false) {
256 flags.push('--no-chrome')
257 }
258
259 return flags.join(' ')
260}
261
262/**
263 * Generates a unique teammate name by checking existing team members.

Callers 2

handleSpawnSplitPaneFunction · 0.70

Calls 7

getMainLoopModelOverrideFunction · 0.85
quoteFunction · 0.85
getFlagSettingsPathFunction · 0.85
getInlinePluginsFunction · 0.85
getChromeFlagOverrideFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected