chore: sync core lib and CLAUDE.md from agent-core#20
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 01d7166. 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
The truncate function doesn't correctly truncate when maxLength is 1 or 2. When maxLength - 3 is negative, Array.prototype.slice treats it as an offset from the end of the array, unlike String.prototype.substring. This returns nearly the entire original string plus an ellipsis, violating the truncation contract.
Reviewed by Cursor Bugbot for commit 01d7166. Configure here.


Automated sync of lib/ and CLAUDE.md from agent-core.
Note
Low Risk
Low risk utility change:
truncatenow handles non-positive lengths and avoids breaking surrogate pairs when truncating emoji/Unicode, but could slightly change truncation behavior/perf for callers.Overview
Updates
truncateinlib/cross-platform/index.jsto truncate by Unicode code points (avoiding orphan surrogate pairs for emoji) and to treatmaxLength <= 0as a no-op.Also clarifies the function’s JSDoc to document code-point semantics and the new edge-case behavior.
Reviewed by Cursor Bugbot for commit 01d7166. Configure here.