Open
Conversation
…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>
|
commit: |
…age-lock conflict)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a summary of the changes:
Fix:
camelCaseToKebabCasenow handles acronyms correctlyProblem: The function at
packages/agents/src/utils.ts:6treated every uppercase letter as a word boundary, soAISessionAgentbecamea-i-session-agentinstead ofai-session-agent.Root cause: The old implementation used a simple
/[A-Z]/gregex that replaced each uppercase letter individually with-<lowercase>.Fix: Replaced the single regex with a two-pass approach:
/([A-Z]+)([A-Z][a-z])/g— splits before the last capital of consecutive uppercase letters (handles acronyms likeAI,API,HTTP)/([a-z])([A-Z])/g— splits between lowercase-to-uppercase transitions (standard camelCase boundaries)Results:
AISessionAgenta-i-session-agentai-session-agentAPIEndpointa-p-i-endpointapi-endpointMyUIComponentmy-u-i-componentmy-ui-componentTestStateAgenttest-state-agenttest-state-agent(unchanged)Files changed:
packages/agents/src/utils.ts— fixed the function with improved JSDocpackages/agents/src/tests/utils.test.ts— added 22 tests covering acronyms, basic camelCase, kebab-case passthrough, underscores, and edge casesVerification: All 552 existing workers tests pass, plus the 22 new unit tests. Typecheck and lint pass.
Closes #924
github run