MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / extractAtMentionedFiles

Function extractAtMentionedFiles

src/utils/attachments.ts:2839–2872  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

2837// a feature-gated module so it doesn't leak into external builds.
2838
2839export function extractAtMentionedFiles(content: string): string[] {
2840 // Extract filenames mentioned with @ symbol, including line range syntax: @file.txt#L10-20
2841 // Also supports quoted paths for files with spaces: @"my/file with spaces.txt"
2842 // Example: "foo bar @baz moo" would extract "baz"
2843 // Example: 'check @"my file.txt" please' would extract "my file.txt"
2844
2845 // Two patterns: quoted paths and regular paths
2846 const quotedAtMentionRegex = /(^|\s)@"([^"]+)"/g
2847 const regularAtMentionRegex = /(^|\s)@([^\s]+)\b/g
2848
2849 const quotedMatches: string[] = []
2850 const regularMatches: string[] = []
2851
2852 // Extract quoted mentions first (skip agent mentions like @"code-reviewer (agent)")
2853 let match
2854 while ((match = quotedAtMentionRegex.exec(content)) !== null) {
2855 if (match[2] && !match[2].endsWith(' (agent)')) {
2856 quotedMatches.push(match[2]) // The content inside quotes
2857 }
2858 }
2859
2860 // Extract regular mentions
2861 const regularMatchArray: string[] = content.match(regularAtMentionRegex) ?? []
2862 regularMatchArray.forEach(match => {
2863 const filename = match.slice(match.indexOf('@') + 1)
2864 // Don't include if it starts with a quote (already handled as quoted)
2865 if (!filename.startsWith('"')) {
2866 regularMatches.push(filename)
2867 }
2868 })
2869
2870 // Combine and deduplicate
2871 return uniq([...quotedMatches, ...regularMatches])
2872}
2873
2874export function extractMcpResourceMentions(content: string): string[] {
2875 // Extract MCP resources mentioned with @ symbol in format @server:uri

Callers 1

processAtMentionedFilesFunction · 0.85

Calls 2

uniqFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected