MCPcopy Create free account
hub / github.com/Noumena-Network/code / buildInheritedCliFlags

Function buildInheritedCliFlags

src/tools/shared/spawnMultiAgent.ts:197–249  ·  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

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

Callers 2

handleSpawnSplitPaneFunction · 0.70

Calls 6

getMainLoopModelOverrideFunction · 0.85
quoteFunction · 0.85
getFlagSettingsPathFunction · 0.85
getInlinePluginsFunction · 0.85
getChromeFlagOverrideFunction · 0.85

Tested by

no test coverage detected