( cwd: string, mode: AgentMode, sandboxMode: SandboxMode, planContext?: string | null, subagents?: CustomSubagentConfig[], sandboxSettings?: SandboxSettings, )
| 325 | } |
| 326 | |
| 327 | function buildSystemPrompt( |
| 328 | cwd: string, |
| 329 | mode: AgentMode, |
| 330 | sandboxMode: SandboxMode, |
| 331 | planContext?: string | null, |
| 332 | subagents?: CustomSubagentConfig[], |
| 333 | sandboxSettings?: SandboxSettings, |
| 334 | ): string { |
| 335 | const custom = loadCustomInstructions(cwd); |
| 336 | const customSection = custom |
| 337 | ? `\n\nCUSTOM INSTRUCTIONS:\n${custom}\n\nFollow the above alongside standard instructions.\n` |
| 338 | : ""; |
| 339 | |
| 340 | const skillsText = formatSkillsForPrompt(discoverSkills(cwd)); |
| 341 | const skillsSection = skillsText ? `\n\n${skillsText}\n` : ""; |
| 342 | const subagentsSection = formatCustomSubagentsPromptSection(subagents ?? loadValidSubAgents()); |
| 343 | const sandboxSection = formatSandboxPromptSection(sandboxMode, sandboxSettings); |
| 344 | |
| 345 | const planSection = planContext |
| 346 | ? `\n\nAPPROVED PLAN:\nThe following plan has been approved by the user. Execute it now.\n${planContext}\n` |
| 347 | : ""; |
| 348 | |
| 349 | return `${MODE_PROMPTS[mode]}${sandboxSection}${customSection}${skillsSection}${subagentsSection}${planSection} |
| 350 | |
| 351 | Current working directory: ${cwd}`; |
| 352 | } |
| 353 | |
| 354 | function buildSubagentPrompt( |
| 355 | request: TaskRequest, |
no test coverage detected