MCPcopy
hub / github.com/superagent-ai/grok-cli / buildSystemPrompt

Function buildSystemPrompt

src/agent/agent.ts:327–352  ·  view source on GitHub ↗
(
  cwd: string,
  mode: AgentMode,
  sandboxMode: SandboxMode,
  planContext?: string | null,
  subagents?: CustomSubagentConfig[],
  sandboxSettings?: SandboxSettings,
)

Source from the content-addressed store, hash-verified

325}
326
327function 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
351Current working directory: ${cwd}`;
352}
353
354function buildSubagentPrompt(
355 request: TaskRequest,

Callers 3

buildSubagentPromptFunction · 0.85
getContextStatsMethod · 0.85
processMessageMethod · 0.85

Calls 6

loadCustomInstructionsFunction · 0.90
formatSkillsForPromptFunction · 0.90
discoverSkillsFunction · 0.90
loadValidSubAgentsFunction · 0.90

Tested by

no test coverage detected