(
input: string | null,
toolUseContext: ToolUseContext,
ideSelection: IDESelection | null,
queuedCommands: QueuedCommand[],
messages?: Message[],
querySource?: QuerySource,
options?: { skipSkillDiscovery?: boolean },
)
| 768 | * TODO: Generate attachments when we create messages |
| 769 | */ |
| 770 | export async function getAttachments( |
| 771 | input: string | null, |
| 772 | toolUseContext: ToolUseContext, |
| 773 | ideSelection: IDESelection | null, |
| 774 | queuedCommands: QueuedCommand[], |
| 775 | messages?: Message[], |
| 776 | querySource?: QuerySource, |
| 777 | options?: { skipSkillDiscovery?: boolean }, |
| 778 | ): Promise<Attachment[]> { |
| 779 | if ( |
| 780 | isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_ATTACHMENTS) || |
| 781 | isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE) |
| 782 | ) { |
| 783 | // query.ts:removeFromQueue dequeues these unconditionally after |
| 784 | // getAttachmentMessages runs — returning [] here silently drops them. |
| 785 | // Coworker runs with --bare and depends on task-notification for |
| 786 | // mid-tool-call notifications from Local*Task/Remote*Task. |
| 787 | return getQueuedCommandAttachments(queuedCommands) |
| 788 | } |
| 789 | |
| 790 | // This will slow down submissions |
| 791 | // TODO: Compute attachments as the user types, not here (though we use this |
| 792 | // function for slash command prompts too) |
| 793 | const abortController = createAbortController() |
| 794 | const timeoutId = setTimeout(ac => ac.abort(), 1000, abortController) |
| 795 | const context = { ...toolUseContext, abortController } |
| 796 | |
| 797 | const isMainThread = !toolUseContext.agentId |
| 798 | |
| 799 | // Attachments which are added in response to on user input |
| 800 | const userInputAttachments = input |
| 801 | ? [ |
| 802 | maybe('at_mentioned_files', () => |
| 803 | processAtMentionedFiles(input, context), |
| 804 | ), |
| 805 | maybe('mcp_resources', () => |
| 806 | processMcpResourceAttachments(input, context), |
| 807 | ), |
| 808 | maybe('agent_mentions', () => |
| 809 | Promise.resolve( |
| 810 | processAgentMentions( |
| 811 | input, |
| 812 | toolUseContext.options.agentDefinitions.activeAgents, |
| 813 | ), |
| 814 | ), |
| 815 | ), |
| 816 | // Skill discovery on turn 0 (user input as signal). Inter-turn |
| 817 | // discovery runs via startSkillDiscoveryPrefetch in query.ts, |
| 818 | // gated on write-pivot detection — see skillSearch/prefetch.ts. |
| 819 | // feature() here lets DCE drop the 'skill_discovery' string (and the |
| 820 | // function it calls) from external builds. |
| 821 | // |
| 822 | // skipSkillDiscovery gates out the SKILL.md-expansion path |
| 823 | // (getMessagesForPromptSlashCommand). When a skill is invoked, its |
| 824 | // SKILL.md content is passed as `input` here to extract @-mentions — |
| 825 | // but that content is NOT user intent and must not trigger discovery. |
| 826 | // Without this gate, a 110KB SKILL.md fires ~3.3s of chunked AKI |
| 827 | // queries on every skill invocation (session 13a9afae). |
no test coverage detected