MCPcopy
hub / github.com/codeaashu/claude-code / getTeamContextAttachment

Function getTeamContextAttachment

src/utils/attachments.ts:3775–3805  ·  view source on GitHub ↗

* Get team context attachment for teammates in a swarm. * Only injected on the first turn to provide team coordination instructions.

(messages: Message[])

Source from the content-addressed store, hash-verified

3773 * Only injected on the first turn to provide team coordination instructions.
3774 */
3775function getTeamContextAttachment(messages: Message[]): Attachment[] {
3776 const teamName = getTeamName()
3777 const agentId = getAgentId()
3778 const agentName = getAgentName()
3779
3780 // Only inject for teammates (not team lead or non-team sessions)
3781 if (!teamName || !agentId) {
3782 return []
3783 }
3784
3785 // Only inject on first turn - check if there are no assistant messages yet
3786 const hasAssistantMessage = messages.some(m => m.type === 'assistant')
3787 if (hasAssistantMessage) {
3788 return []
3789 }
3790
3791 const configDir = getClaudeConfigHomeDir()
3792 const teamConfigPath = `${configDir}/teams/${teamName}/config.json`
3793 const taskListPath = `${configDir}/tasks/${teamName}/`
3794
3795 return [
3796 {
3797 type: 'team_context',
3798 agentId,
3799 agentName: agentName || agentId,
3800 teamName,
3801 teamConfigPath,
3802 taskListPath,
3803 },
3804 ]
3805}
3806
3807function getTokenUsageAttachment(
3808 messages: Message[],

Callers 1

getAttachmentsFunction · 0.85

Calls 3

getTeamNameFunction · 0.85
getAgentIdFunction · 0.85
getAgentNameFunction · 0.85

Tested by

no test coverage detected