(content: string)
| 2800 | } |
| 2801 | |
| 2802 | export function extractAgentMentions(content: string): string[] { |
| 2803 | // Extract agent mentions in two formats: |
| 2804 | // 1. @agent-<agent-type> (legacy/manual typing) |
| 2805 | // Example: "@agent-code-elegance-refiner" → "agent-code-elegance-refiner" |
| 2806 | // 2. @"<agent-type> (agent)" (from autocomplete selection) |
| 2807 | // Example: '@"code-reviewer (agent)"' → "code-reviewer" |
| 2808 | // Supports colons, dots, and at-signs for plugin-scoped agents like "@agent-asana:project-status-updater" |
| 2809 | const results: string[] = [] |
| 2810 | |
| 2811 | // Match quoted format: @"<type> (agent)" |
| 2812 | const quotedAgentRegex = /(^|\s)@"([\w:.@-]+) \(agent\)"/g |
| 2813 | let match |
| 2814 | while ((match = quotedAgentRegex.exec(content)) !== null) { |
| 2815 | if (match[2]) { |
| 2816 | results.push(match[2]) |
| 2817 | } |
| 2818 | } |
| 2819 | |
| 2820 | // Match unquoted format: @agent-<type> |
| 2821 | const unquotedAgentRegex = /(^|\s)@(agent-[\w:.@-]+)/g |
| 2822 | const unquotedMatches = content.match(unquotedAgentRegex) || [] |
| 2823 | for (const m of unquotedMatches) { |
| 2824 | results.push(m.slice(m.indexOf('@') + 1)) |
| 2825 | } |
| 2826 | |
| 2827 | return uniq(results) |
| 2828 | } |
| 2829 | |
| 2830 | interface AtMentionedFileLines { |
| 2831 | filename: string |
no test coverage detected