chore: sync core lib and CLAUDE.md from agent-core#30
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1b912a5. Configure here.
| if (maxLength <= 0) return text; | ||
| const codePoints = [...text]; | ||
| if (codePoints.length <= maxLength) return text; | ||
| return codePoints.slice(0, maxLength - 3).join('') + '...'; |
There was a problem hiding this comment.
Negative slice index causes output longer than input
High Severity
The truncate function can return strings longer than the original when maxLength is 1 or 2. This happens because maxLength - 3 becomes negative, causing Array.prototype.slice to interpret the end index as an offset from the array's end. The previous String.prototype.substring clamped negative values, avoiding this issue, and the maxLength <= 0 guard doesn't cover these small positive values.
Reviewed by Cursor Bugbot for commit 1b912a5. Configure here.


Automated sync of lib/ and CLAUDE.md from agent-core.
Note
Low Risk
Low risk utility change limited to
truncate, but it may slightly alter truncated output for strings containing emoji/surrogate pairs and formaxLength <= 0inputs.Overview
Improves
truncateinlib/cross-platform/index.jsto truncate by Unicode code points instead of UTF-16 code units, preventing broken surrogate pairs (e.g., emoji) in ellipsized text.Adds a guard to leave strings unchanged when
maxLength <= 0, and updates the function’s documentation to reflect the new behavior and length semantics.Reviewed by Cursor Bugbot for commit 1b912a5. Configure here.