buildCopilotArgs builds the Copilot CLI argument list based on workflow configuration.
(workflowData *WorkflowData)
| 174 | |
| 175 | // buildCopilotArgs builds the Copilot CLI argument list based on workflow configuration. |
| 176 | func (e *CopilotEngine) buildCopilotArgs(workflowData *WorkflowData) []string { |
| 177 | sandboxEnabled := isFirewallEnabled(workflowData) |
| 178 | isDetectionJob := workflowData.SafeOutputs == nil |
| 179 | copilotArgs := e.buildCopilotBaseArgs(sandboxEnabled) |
| 180 | |
| 181 | // Add --disable-builtin-mcps to disable built-in MCP servers |
| 182 | copilotArgs = append(copilotArgs, "--disable-builtin-mcps") |
| 183 | // Add --no-ask-user to enable fully autonomous runs (suppresses interactive prompts). |
| 184 | // Emitted for both agent and detection jobs when the Copilot CLI version supports it |
| 185 | // (v1.0.19+). Latest and unspecified versions always include the flag. |
| 186 | if copilotSupportsNoAskUser(workflowData.EngineConfig) { |
| 187 | copilotExecLog.Print("Adding --no-ask-user for fully autonomous run") |
| 188 | copilotArgs = append(copilotArgs, "--no-ask-user") |
| 189 | } |
| 190 | // Add --agent flag if specified via engine.agent |
| 191 | // Note: Agent imports (.github/agents/*.md) still work for importing markdown content, |
| 192 | // but they do NOT automatically set the --agent flag. Only engine.agent controls the flag. |
| 193 | if workflowData.EngineConfig != nil && workflowData.EngineConfig.Agent != "" { |
| 194 | agentIdentifier := workflowData.EngineConfig.Agent |
| 195 | copilotExecLog.Printf("Using agent from engine.agent: %s", agentIdentifier) |
| 196 | copilotArgs = append(copilotArgs, "--agent", agentIdentifier) |
| 197 | } |
| 198 | // Add --autopilot and --max-autopilot-continues when max-continuations > 1 |
| 199 | // Never apply autopilot flags to detection jobs; they are only meaningful for the agent run. |
| 200 | if !isDetectionJob && workflowData.EngineConfig != nil && workflowData.EngineConfig.MaxContinuations > 1 { |
| 201 | maxCont := workflowData.EngineConfig.MaxContinuations |
| 202 | copilotExecLog.Printf("Enabling autopilot mode with max-autopilot-continues=%d", maxCont) |
| 203 | copilotArgs = append(copilotArgs, "--autopilot", "--max-autopilot-continues", strconv.Itoa(maxCont)) |
| 204 | } |
| 205 | return e.buildCopilotFeatureArgs(workflowData, copilotArgs) |
| 206 | } |
| 207 | |
| 208 | func (e *CopilotEngine) buildCopilotBaseArgs(sandboxEnabled bool) []string { |
| 209 | if sandboxEnabled { |
no test coverage detected