mirror of
https://github.com/cline/cline.git
synced 2026-09-14 02:29:17 +08:00
* feat(cli): make plan/act mode switches visible to the model The mode signal already rides on every user message via the <user_input mode="..."> wrapper, but nothing ever told the model what the attribute means, and a manual plan/act toggle produced no inline signal at all -- only an invisible system prompt swap the model cannot diff. Two additions: - The CLI system prompt now explains the mode attribute (both modes, since after a switch the transcript still contains messages tagged with the other mode) and that the newest message's mode governs. - A user-initiated toggle stamps the next user message with a <mode_notice> block marking the switch, e.g. "The user switched from act mode to plan mode before sending this message." Round trips that return to the mode the model last saw cancel out. The model-initiated switch_to_act_mode path is excluded: its continuation prompt already announces the switch. The notice vocabulary lives in @cline/shared next to the user_input wrapper it extends, and normalizeUserInput hides the whole element from transcript display the same structural way it strips the wrapper tags. * fix(shared): strip mode_notice elements without polynomial regex CodeQL flagged the lazy dot-all pattern (js/polynomial-redos): with the global flag, every unmatched opening tag re-scans to the end of the string, which is quadratic on adversarial transcript content. Replace it with an indexOf-based splice that removes matched elements in linear time and leaves unclosed tags intact, with a regression test on 50k repeated open tags.