MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getDynamicSkillAttachments

Function getDynamicSkillAttachments

source code/utils/attachments.ts:2549–2603  ·  view source on GitHub ↗

* Processes skill directories that were discovered during file operations. * Uses dynamicSkillDirTriggers field from ToolUseContext

(
  toolUseContext: ToolUseContext,
)

Source from the content-addressed store, hash-verified

2547 * Uses dynamicSkillDirTriggers field from ToolUseContext
2548 */
2549async function getDynamicSkillAttachments(
2550 toolUseContext: ToolUseContext,
2551): Promise<Attachment[]> {
2552 const attachments: Attachment[] = []
2553
2554 if (
2555 toolUseContext.dynamicSkillDirTriggers &&
2556 toolUseContext.dynamicSkillDirTriggers.size > 0
2557 ) {
2558 // Parallelize: readdir all skill dirs concurrently
2559 const perDirResults = await Promise.all(
2560 Array.from(toolUseContext.dynamicSkillDirTriggers).map(async skillDir => {
2561 try {
2562 const entries = await readdir(skillDir, { withFileTypes: true })
2563 const candidates = entries
2564 .filter(e => e.isDirectory() || e.isSymbolicLink())
2565 .map(e => e.name)
2566 // Parallelize: stat all SKILL.md candidates concurrently
2567 const checked = await Promise.all(
2568 candidates.map(async name => {
2569 try {
2570 await stat(resolve(skillDir, name, 'SKILL.md'))
2571 return name
2572 } catch {
2573 return null // SKILL.md doesn't exist, skip this entry
2574 }
2575 }),
2576 )
2577 return {
2578 skillDir,
2579 skillNames: checked.filter((n): n is string => n !== null),
2580 }
2581 } catch {
2582 // Ignore errors reading skill directories (e.g., directory doesn't exist)
2583 return { skillDir, skillNames: [] }
2584 }
2585 }),
2586 )
2587
2588 for (const { skillDir, skillNames } of perDirResults) {
2589 if (skillNames.length > 0) {
2590 attachments.push({
2591 type: 'dynamic_skill',
2592 skillDir,
2593 skillNames,
2594 displayPath: relative(getCwd(), skillDir),
2595 })
2596 }
2597 }
2598
2599 toolUseContext.dynamicSkillDirTriggers.clear()
2600 }
2601
2602 return attachments
2603}
2604
2605// Track which skills have been sent to avoid re-sending. Keyed by agentId
2606// (empty string = main thread) so subagents get their own turn-0 listing —

Callers 1

getAttachmentsFunction · 0.85

Calls 5

readdirFunction · 0.85
statFunction · 0.85
getCwdFunction · 0.85
resolveFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected