Skip to content

Comments

Fix kebab-case acronym splitting bug#941

Open
ask-bonk[bot] wants to merge 3 commits intomainfrom
opencode/issue924-20260218192155
Open

Fix kebab-case acronym splitting bug#941
ask-bonk[bot] wants to merge 3 commits intomainfrom
opencode/issue924-20260218192155

Conversation

@ask-bonk
Copy link
Contributor

@ask-bonk ask-bonk bot commented Feb 18, 2026

Here's a summary of the changes:

Fix: camelCaseToKebabCase now handles acronyms correctly

Problem: The function at packages/agents/src/utils.ts:6 treated every uppercase letter as a word boundary, so AISessionAgent became a-i-session-agent instead of ai-session-agent.

Root cause: The old implementation used a simple /[A-Z]/g regex that replaced each uppercase letter individually with -<lowercase>.

Fix: Replaced the single regex with a two-pass approach:

  1. /([A-Z]+)([A-Z][a-z])/g — splits before the last capital of consecutive uppercase letters (handles acronyms like AI, API, HTTP)
  2. /([a-z])([A-Z])/g — splits between lowercase-to-uppercase transitions (standard camelCase boundaries)

Results:

Input Before After
AISessionAgent a-i-session-agent ai-session-agent
APIEndpoint a-p-i-endpoint api-endpoint
MyUIComponent my-u-i-component my-ui-component
TestStateAgent test-state-agent test-state-agent (unchanged)

Files changed:

  • packages/agents/src/utils.ts — fixed the function with improved JSDoc
  • packages/agents/src/tests/utils.test.ts — added 22 tests covering acronyms, basic camelCase, kebab-case passthrough, underscores, and edge cases

Verification: All 552 existing workers tests pass, plus the 22 new unit tests. Typecheck and lint pass.

Closes #924

github run

ask-bonk bot and others added 2 commits February 18, 2026 19:28
…i-session-agent)

The previous implementation treated every uppercase letter as a word boundary,
breaking agent names with acronyms like AI, API, UI, DB. Now consecutive
uppercase letters are kept together as a single unit before splitting.

Fixes #924
Co-authored-by: whoiskatrin <whoiskatrin@users.noreply.github.com>
@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

⚠️ No Changeset found

Latest commit: 2e24c9d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/agents@941

commit: 2e24c9d

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.

camelCaseToKebabCase breaks acronyms in agent names (e.g., AISessionAgent → a-i-session-agent)

1 participant