Skip to content

Commit 8d7e08a

Browse files
committed
test(cli): cover thinking-first headless output
1 parent 26bc03c commit 8d7e08a

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

apps/cli/src/utils/ask.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,52 @@ describe('ask(): system prompt flags', () => {
9696
expect(captured?.systemPromptOverride).toBe('')
9797
expect(captured?.appendSystemPrompt).toBe('APPEND')
9898
})
99+
100+
test('returns text content when a thinking block comes first', async () => {
101+
const out = await ask(
102+
{
103+
commands: [] as any,
104+
tools: [] as any,
105+
hasPermissionsToUseTool: (() => ({ result: true })) as any,
106+
messageLogName: 'test',
107+
prompt: 'what is 2+2?',
108+
cwd: '/tmp',
109+
},
110+
{
111+
setCwd: async () => {},
112+
getCurrentOutputStyleDefinition: () => null,
113+
buildSystemPromptForSession: async () => ['DEFAULT'],
114+
getContext: async () => ({}),
115+
getMaxThinkingTokens: async () => 0,
116+
query: async function* () {
117+
yield {
118+
type: 'assistant',
119+
uuid: 'assistant-uuid',
120+
message: {
121+
content: [
122+
{
123+
type: 'thinking',
124+
thinking:
125+
'The user asked a simple arithmetic question; answer directly.',
126+
signature: '',
127+
},
128+
{ type: 'text', text: '4' },
129+
],
130+
},
131+
} as any
132+
},
133+
createUserMessage: (prompt: string) =>
134+
({
135+
type: 'user',
136+
uuid: 'user-uuid',
137+
message: { content: [{ type: 'text', text: prompt }] },
138+
}) as any,
139+
getMessagesPath: () => 'messages.json',
140+
overwriteLog: () => {},
141+
getTotalCost: () => 0,
142+
},
143+
)
144+
145+
expect(out.resultText).toBe('4')
146+
})
99147
})

0 commit comments

Comments
 (0)