(content: string)
| 2755 | // a feature-gated module so it doesn't leak into external builds. |
| 2756 | |
| 2757 | export function extractAtMentionedFiles(content: string): string[] { |
| 2758 | // Extract filenames mentioned with @ symbol, including line range syntax: @file.txt#L10-20 |
| 2759 | // Also supports quoted paths for files with spaces: @"my/file with spaces.txt" |
| 2760 | // Example: "foo bar @baz moo" would extract "baz" |
| 2761 | // Example: 'check @"my file.txt" please' would extract "my file.txt" |
| 2762 | |
| 2763 | // Two patterns: quoted paths and regular paths |
| 2764 | const quotedAtMentionRegex = /(^|\s)@"([^"]+)"/g |
| 2765 | const regularAtMentionRegex = /(^|\s)@([^\s]+)\b/g |
| 2766 | |
| 2767 | const quotedMatches: string[] = [] |
| 2768 | const regularMatches: string[] = [] |
| 2769 | |
| 2770 | // Extract quoted mentions first (skip agent mentions like @"code-reviewer (agent)") |
| 2771 | let match |
| 2772 | while ((match = quotedAtMentionRegex.exec(content)) !== null) { |
| 2773 | if (match[2] && !match[2].endsWith(' (agent)')) { |
| 2774 | quotedMatches.push(match[2]) // The content inside quotes |
| 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | // Extract regular mentions |
| 2779 | const regularMatchArray = content.match(regularAtMentionRegex) || [] |
| 2780 | regularMatchArray.forEach(match => { |
| 2781 | const filename = match.slice(match.indexOf('@') + 1) |
| 2782 | // Don't include if it starts with a quote (already handled as quoted) |
| 2783 | if (!filename.startsWith('"')) { |
| 2784 | regularMatches.push(filename) |
| 2785 | } |
| 2786 | }) |
| 2787 | |
| 2788 | // Combine and deduplicate |
| 2789 | return uniq([...quotedMatches, ...regularMatches]) |
| 2790 | } |
| 2791 | |
| 2792 | export function extractMcpResourceMentions(content: string): string[] { |
| 2793 | // Extract MCP resources mentioned with @ symbol in format @server:uri |
no test coverage detected