(message: UserMessage, hint: string)
| 238 | } |
| 239 | |
| 240 | function appendHintToUserMessage(message: UserMessage, hint: string): boolean { |
| 241 | if (hint.length === 0) return false; |
| 242 | |
| 243 | const rawText = collectUserPromptParts(message); |
| 244 | if (rawText.includes(hint) || rawText.includes("<ctx-search-hint>")) { |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | if (typeof message.content === "string") { |
| 249 | message.content += hint; |
| 250 | return true; |
| 251 | } |
| 252 | |
| 253 | const firstTextIndex = message.content.findIndex( |
| 254 | (part) => part.type === "text", |
| 255 | ); |
| 256 | if (firstTextIndex >= 0) { |
| 257 | const part = message.content[firstTextIndex]; |
| 258 | if (part?.type !== "text") return false; |
| 259 | message.content[firstTextIndex] = { ...part, text: part.text + hint }; |
| 260 | return true; |
| 261 | } |
| 262 | |
| 263 | message.content.push({ type: "text", text: hint.trimStart() }); |
| 264 | return true; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Run Pi auto-search hinting against the latest meaningful user message. |
no test coverage detected