feat(cli): enforce context:fork via Agent tool instruction in prompts/get
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

Claude Code's MCP prompts path doesn't support the context field
natively. When a skill has context:"fork", prepend an instruction
telling the model to use the Agent tool with the specified agent
type and model.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-09 02:16:00 +01:00
parent a7d9ecab15
commit c3dd4efe82

View File

@@ -336,6 +336,17 @@ Your message mode is "${messageMode}".
if (manifest.argument_hint) fm.push(`argument-hint: "${manifest.argument_hint}"`);
fm.push("---\n");
if (fm.length > 3) content = fm.join("\n") + content;
// Enforce context:fork via Agent tool instruction — Claude Code's MCP prompts
// path doesn't support the context field natively, so we instruct the model.
if (manifest.context === "fork") {
const agentType = manifest.agent || "general-purpose";
const modelHint = manifest.model ? `, model: "${manifest.model}"` : "";
const toolsHint = manifest.allowed_tools?.length
? `\nOnly use these tools: ${manifest.allowed_tools.join(", ")}.`
: "";
content = `IMPORTANT: Execute this skill in an isolated sub-agent. Use the Agent tool with subagent_type="${agentType}"${modelHint}. Pass the full instructions below as the agent prompt.${toolsHint}\n\n` + content;
}
}
return {