MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / extractThinking

Function extractThinking

src/llm/thinking.ts:37–45  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

35}
36
37export function extractThinking(text: string): ThinkingExtraction {
38 if (!text || !text.includes('<')) return { visibleText: text, thinkingBlocks: [] };
39 const blocks: string[] = [];
40 const visible = text.replace(THINKING_TAG_RE, (_match, _tag, inner: string) => {
41 blocks.push(inner.trim());
42 return '';
43 }).replace(/\n{3,}/g, '\n\n').trim();
44 return { visibleText: visible, thinkingBlocks: blocks };
45}
46
47/**
48 * Detect partial/streaming thinking — text that starts a tag but hasn't closed yet.

Callers 4

stripThinkingForDisplayFunction · 0.85
cleanForDisplayFunction · 0.85
runMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected