import{AGENTS as e}from"../definitions/agents.mjs";import{AGENT_BODIES as t}from"../definitions/bodies.mjs";import{HOOKS as n}from"../definitions/hooks.mjs";import{MCP_SERVER_ENTRY as r,SERVER_NAME as i}from"../definitions/mcp.mjs";import{getPlatformPrimaryModelMap as a}from"../definitions/models.mjs";import{PROMPTS as o}from"../definitions/prompts.mjs";import{AIKIT_INSTALL_HINT_SECTION as s,PLATFORM_OUTPUT_RULES_SECTION as c,PROTOCOLS as l}from"../definitions/protocols.mjs";import{AIKIT_TOOLS as u,CLAUDE_CODE_TOOL_MAP as d,IDE_CAPABILITIES as f}from"../definitions/tools.mjs";import{buildAgentTable as p,buildCompactAgentTable as m,buildHooksSection as h,buildMcpConfigJson as g,buildSkillsSection as _,lowerFirst as v}from"./_shared.mjs";import{generateHooks as y}from"./hooks.mjs";const b=[`## Flows`,``,"This project uses aikit's pluggable flow system. Check flow status with the `flow` MCP tool.","If a flow is active, follow the current step's skill instructions. Advance with `flow({ action: 'step', advance: 'next' })`.","Use `flow({ action: 'list' })` to see available flows and `flow({ action: 'start', name, topic })` to begin one."].join(`
`),x=[`## Flows`,``,"This project uses aikit's pluggable flow system. Check flow status with the `flow` MCP tool.","If a flow is active, follow the current step's skill instructions. Advance with `flow({ action: 'step', advance: 'next' })`.","Use `flow({ action: 'list' })` to see available flows and `flow({ action: 'start', name, topic })` to begin one."].join(`
`),S=[`## Flows`,``,"This project uses aikit's pluggable flow system. Use `flow({ action: 'status' })` to check if a flow is active.",`If dispatched as part of a flow, your work contributes to the current step. Do NOT advance or manage the flow — the Orchestrator handles flow lifecycle.`].join(`
`);function C(e){return e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``).toLowerCase()}function w(e){return`"${String(e).replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function T(e){let t=(f[e]||[]).flatMap(e=>d[e]||[]),n=u.map(e=>`mcp__aikit__${e}`);return[...new Set([...t,...n])].sort((e,t)=>e.localeCompare(t))}function E(e,t){let n=[];return n.push(`# aikit ${e}`),n.push(``),t.description&&(n.push(`> ${t.description}`),n.push(``)),n.push(t.content.trim()),n.push(``),n.join(`
`)}function D(e,n){let r=t[e];return typeof r==`function`?r(n):r||``}function O(e){let t=[];e.extraBody&&t.push(e.extraBody),e.sharedBase&&l[e.sharedBase]&&t.push(l[e.sharedBase]);for(let n of e.sharedProtocols||[])l[n]&&t.push(l[n]);return t}function k(){let t=[];for(let[n,r]of Object.entries(e)){if(r.variants){for(let[e,i]of Object.entries(r.variants))t.push({name:`${n}-${e}`,description:i.description||r.description});continue}t.push({name:n,description:r.description})}return t}function A(e){return k().map(({name:t,description:n})=>`- \`${e}/${t}.md\` — ${n}`).join(`
`)}function j(t=p(e,a(`claude-code`))){return[`# aikit — Claude Code Agents`,``,c,``,s,``,`## MCP Server`,``,"Server name: `aikit`","Configured in `.mcp.json` (already done if scaffold was deployed).",``,`## Agents`,``,t,``,`## Agent Files`,``,A(`.claude/agents`),``,`## Commands`,``,"Slash commands live under `.claude/commands/`.",``,`## Session Protocol`,``,h(n),``].join(`
`)}function M(){return[`# aikit — Claude Code Instructions`,``,"Detailed workspace instructions live in `AGENTS.md`.","Full sub-agent instructions live in `.claude/agents/`.","Slash commands live in `.claude/commands/`.","MCP server config lives in `.mcp.json`.",``,"Start with `AGENTS.md`, then open the specific sub-agent file you want to use.",``,c,``,s,``].join(`
`)}function N(e,t,n,r){let i=T(t.toolRole),a=O(t),o=_(t.skills),s=e===`Orchestrator`?[b,x]:[S],c=[n,...a,t.bodyAddendum,o,...s].filter(Boolean).join(`

`).trim(),l=t.identity?`You are the **${e}**${t.identity}`:`You are the **${e}**, ${v(t.description)}.`,u=[`---`,`name: ${C(e)}`,`description: ${w(t.description)}`,`allowedTools:`,...i.map(e=>`  - ${e}`),`---`,``,`# ${e} - ${t.title||e}`,``,l];return c&&u.push(``,c),u.push(``),u.join(`
`)}function P(){let t=[],n=p(e,a(`claude-code`)),s=m(e);t.push({path:`.mcp.json`,content:`${g({serverName:i,mcpEntry:r,configKey:`mcpServers`})}\n`}),t.push({path:`CLAUDE.md`,content:M()}),t.push({path:`AGENTS.md`,content:j(n)});let c=y(`claude`,`~/.copilot/hooks/scripts`);t.push(...c.map(e=>({path:e.path,content:e.content})));for(let[e,n]of Object.entries(o))t.push({path:`.claude/commands/aikit-${e}.md`,content:E(e,n)});for(let[r,i]of Object.entries(e)){let e=D(r,s);if(i.variants){for(let[a,o]of Object.entries(i.variants)){let s=`${r}-${a}`;t.push({path:`.claude/agents/${s}.md`,content:N(s,{...i,description:o.description||i.description,identity:o.identity,bodyAddendum:o.bodyAddendum},e,n)})}continue}t.push({path:`.claude/agents/${r}.md`,content:N(r,i,e,n)})}return t}export{b as CLAUDE_FLOWS_SECTION,x as CLAUDE_ORCHESTRATOR_FLOW_ROUTING_SECTION,P as generateClaudeCode};