Skip to content

chore: sync core lib and CLAUDE.md from agent-core#21

Merged
avifenesh merged 1 commit into
mainfrom
chore/sync-core-perf-20260426-145628
Apr 26, 2026
Merged

chore: sync core lib and CLAUDE.md from agent-core#21
avifenesh merged 1 commit into
mainfrom
chore/sync-core-perf-20260426-145628

Conversation

@avifenesh
Copy link
Copy Markdown
Contributor

@avifenesh avifenesh commented Apr 26, 2026

Automated sync of lib/ and CLAUDE.md from agent-core.


Note

Low Risk
Low risk utility change, but it alters truncate semantics (code-point counting and maxLength<=0 behavior) which could slightly change truncated output in consumers.

Overview
Updates truncate in lib/cross-platform/index.js to truncate by Unicode code points (via spreading into an array) instead of UTF-16 code units, preventing broken surrogate pairs (e.g., emoji) in truncated strings.

Also changes edge-case handling so non-positive maxLength returns the original text unchanged, and clarifies the JSDoc to document code-point length semantics.

Reviewed by Cursor Bugbot for commit 20b876a. Configure here.

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 20b876a. Configure here.

if (maxLength <= 0) return text;
const codePoints = [...text];
if (codePoints.length <= maxLength) return text;
return codePoints.slice(0, maxLength - 3).join('') + '...';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative slice index produces longer-than-original output

Medium Severity

When maxLength is 1 or 2, the expression maxLength - 3 becomes negative. Array.prototype.slice interprets a negative second argument as an offset from the end of the array, so it returns most of the array rather than an empty prefix. The resulting "truncated" string can be significantly longer than the input — the opposite of the function's purpose. The old code using substring didn't have this problem because substring clamps negatives to 0.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 20b876a. Configure here.

@avifenesh avifenesh merged commit 048a20a into main Apr 26, 2026
7 checks passed
@avifenesh avifenesh deleted the chore/sync-core-perf-20260426-145628 branch April 26, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant