MCPcopy Create free account
hub / github.com/Noumena-Network/code / findThinkingTriggerPositions

Function findThinkingTriggerPositions

src/utils/thinking.ts:38–60  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

36 * Find positions of "ultrathink" keyword in text (for UI highlighting/notification)
37 */
38export function findThinkingTriggerPositions(text: string): Array<{
39 word: string
40 start: number
41 end: number
42}> {
43 const positions: Array<{ word: string; start: number; end: number }> = []
44 // Fresh /g literal each call — String.prototype.matchAll copies lastIndex
45 // from the source regex, so a shared instance would leak state from
46 // hasUltrathinkKeyword's .test() into this call on the next render.
47 const matches = text.matchAll(/\bultrathink\b/gi)
48
49 for (const match of matches) {
50 if (match.index !== undefined) {
51 positions.push({
52 word: match[0],
53 start: match.index,
54 end: match.index + match[0].length,
55 })
56 }
57 }
58
59 return positions
60}
61
62const RAINBOW_COLORS: Array<keyof Theme> = [
63 'rainbow_red',

Callers 2

HighlightedThinkingTextFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected