(message: UserMessage)
| 179 | } |
| 180 | |
| 181 | function extractUserPromptText(message: UserMessage): string { |
| 182 | return ( |
| 183 | stripNestedSystemReminders(collectUserPromptParts(message)) |
| 184 | // HTML comments — covers temporal markers, OMO/ALFONSO internal |
| 185 | // initiators, and any other commented-out extension markup. |
| 186 | .replace(/<!--[\s\S]*?-->/g, "") |
| 187 | // Plugin-owned injected blocks should be removed with their content. |
| 188 | .replace(/<ctx-search-hint>[\s\S]*?<\/ctx-search-hint>/g, "") |
| 189 | .replace(/<ctx-search-auto>[\s\S]*?<\/ctx-search-auto>/g, "") |
| 190 | .replace(/<instruction[^>]*>[\s\S]*?<\/instruction>/g, "") |
| 191 | .replace(/<sidekick-augmentation>[\s\S]*?<\/sidekick-augmentation>/g, "") |
| 192 | // Generic XML/HTML tags — opening, closing, and self-closing. |
| 193 | // Preserve text between paired tags so pasted content still embeds. |
| 194 | .replace(/<\/?[a-zA-Z][^<>]*>/g, "") |
| 195 | // Magic Context tag prefix: "§123§ " at any position. |
| 196 | .replace(/§\d+§\s*/g, "") |
| 197 | // Collapse whitespace runs that the strippings may leave behind. |
| 198 | .replace(/[ \t]+\n/g, "\n") |
| 199 | .replace(/\n{3,}/g, "\n\n") |
| 200 | .trim() |
| 201 | ); |
| 202 | } |
| 203 | |
| 204 | function findLatestMeaningfulUserMessage( |
| 205 | messages: AgentMessage[], |
no test coverage detected