Skip to main content

render_subagents

Function render_subagents 

Source
pub fn render_subagents(
    compose: &Compose,
    h: AgentHandle<'_>,
) -> Result<Option<String>>
Expand description

#383 Phase 3a: build Claude Code’s --agents inline JSON for one agent from its declared subagents: list. Each list entry is a compose-root-relative markdown file with standard sub-agent frontmatter (name, description, optional tools, model) and a body that becomes the sub-agent’s system prompt. The result is the { "<name>": { description, prompt, [tools], [model] } } object the --agents flag consumes — the only cwd-stationary way to scope sub-agents per agent (no arbitrary-path flag exists; see the Phase-1 spike). Returns Ok(None) when none are declared (→ no --agents flag) or the runtime isn’t claude-code (logs an “unsupported” warning, claude-only v1); Err if a source is unreadable or its frontmatter is invalid, so a typo fails the apply loudly rather than dropping a sub-agent silently.