chore: sync core lib and CLAUDE.md from agent-core#16
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 7e41029. 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 end produces oversized output
Medium Severity
When maxLength is 1 or 2, maxLength - 3 is negative, and Array.prototype.slice treats negative end indices as offsets from the array end (unlike String.prototype.substring, which clamped them to 0). The result keeps almost all of the original code points and appends '...', producing output far longer than maxLength and even longer than the input string.
Reviewed by Cursor Bugbot for commit 7e41029. Configure here.


Automated sync of lib/ and CLAUDE.md from agent-core.
Note
Low Risk
Low risk utility change limited to
truncate, adjusting string length semantics to Unicode code points and adding a guard formaxLength <= 0; potential minor behavior differences for callers relying on UTF-16 length.Overview
Updates
truncateinlib/cross-platform/index.jsto truncate by Unicode code points (avoiding broken surrogate pairs like emoji) instead of UTF-16 code units, and to return the input unchanged whenmaxLength <= 0. Documentation is updated to reflect the new semantics.Reviewed by Cursor Bugbot for commit 7e41029. Configure here.