cline/.clinerules
Shravan Vadeghar 7d5d347cdd
feat: Add optimized V2 parser for assistant messages (#3425)
This commit introduces `parseAssistantMessageV2`, a new function designed to parse assistant message strings containing text and XML-like tool usage tags (`<tool_name>...</tool_name>`, `<param_name>...</param_name>`).

Motivation:
The original parser (`V1`) used a character-by-character accumulator, which could lead to performance overhead due to repeated string concatenations and checks (`endsWith`). V2 aims to improve parsing efficiency.

Implementation Details (V2 vs V1):
- V2 iterates through the string using an index and checks for tags using `startsWith` with calculated offsets, avoiding the V1 accumulator.
- It tracks start indices for text, tools, and parameters, performing `slice` operations only when a block is completed or the string ends.
- Known tool and parameter opening tags are precomputed into Maps for potentially faster lookups.
- Special handling for nested tags within `write_to_file`/`new_rule` content parameters is preserved using `indexOf`/`lastIndexOf`.

Other Changes:
- The original parser implementation has been renamed to `parseAssistantMessageV1`.
2025-05-12 12:21:44 -07:00
..
cline-overview.md feat: Add optimized V2 parser for assistant messages (#3425) 2025-05-12 12:21:44 -07:00