Skip to content

fix(hooks): widen track-slash regex to match SKILL_NAME_REGEX - #737

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
Dev-next-gen:fix/track-slash-dotted-skill-names
Sep 23, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
Dev-next-gen:fix/track-slash-dotted-skill-names

Conversation

@Dev-next-gen

@Dev-next-gen Dev-next-gen commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The trackSlashHandler hook handler extracted slash-command skill names with the regex [\w-]+ ([a-zA-Z0-9_-]+), which does not match dots (.) or colons (:) — both of which are valid skill name characters per SKILL_NAME_REGEX in types.ts (/^[a-zA-Z0-9_\-:.]{1,200}$/).

A user invoking /org.setup had the skill name silently truncated to org, and /ns:deploy to ns. The wrong (or nonexistent) skill was tracked, while the intended skill received no usage event.

The CLI counterpart trackSlashCommand in usage-tracker.ts already uses the full [a-zA-Z0-9_\-:.]+ character class. This PR aligns the hook handler's regex to match.

Before: /org.setup args → tracks skill org (truncated at the dot)
After: /org.setup args → tracks skill org.setup (full name)

Test plan

  • New test: tracks a skill name that contains a dot — fails before, passes after
  • New test: tracks a skill name that contains a colon — fails before, passes after
  • All 82 existing hook-handler tests pass (no regressions)

End-to-end verification (CLI build):

$ yarn run build
$ tsup
ESM dist/index.js     1.76 MB
ESM ⚡️ Build success in 633ms

$ yarn run test -- --reporter=verbose src/__tests__/hook-handlers.test.ts
 ✓ track-slash handler: dotted and colon skill names > tracks a skill name that contains a dot  1ms
 ✓ track-slash handler: dotted and colon skill names > tracks a skill name that contains a colon  0ms
 Test Files  1 passed (1)
       Tests  82 passed (82)
    Duration  642ms

Build produces a clean dist/index.js bundle; the two new tests exercise the handler through buildHandlerRegistry() → handler.execute() with real appendUsageEvent / updateKnownSkills calls, confirming the regex captures the full dotted/colon skill name end-to-end.

Found by a defect-hunting pipeline I build and run (Dev-next-gen), using Claude Code with Anthropic's Claude Opus 5.

The trackSlashHandler extracted the slash-command skill name with
`/^\/([\w-]+)/`, which does not match dots (`.`) or colons (`:`) —
both valid per `SKILL_NAME_REGEX` (`/^[a-zA-Z0-9_\-:.]{1,200}$/`).
A user invoking `/org.setup` or `/ns:deploy` had the name silently
truncated to `org` or `ns`, so the wrong (or nonexistent) skill was
tracked.

The CLI counterpart `trackSlashCommand` (usage-tracker.ts) already
uses the full `[a-zA-Z0-9_\-:.]+` set. Align the hook handler.
@jeff-r2026 jeff-r2026 self-assigned this Sep 23, 2026
@github-actions

Copy link
Copy Markdown

Findings

  • [P1 blocking] The PR description lists only unit-test results. Repository policy requires a documented end-to-end/real-CLI verification record after npm run build; add the executed command/scenario and result to the Test Plan.
  • [P2 non-blocking] src/__tests__/hook-handlers.test.ts:48 adds the real extractSkillName export to the mock, but the changed handler never calls it. Remove this unrelated mock change to keep the patch surgical.

The regex change itself correctly covers . and :. No earlier findings were provided to mark as resolved.

@jeff-r2026
jeff-r2026 merged commit 667aed0 into Tencent:main Sep 23, 2026
10 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…t#737)

The trackSlashHandler extracted the slash-command skill name with
`/^\/([\w-]+)/`, which does not match dots (`.`) or colons (`:`) —
both valid per `SKILL_NAME_REGEX` (`/^[a-zA-Z0-9_\-:.]{1,200}$/`).
A user invoking `/org.setup` or `/ns:deploy` had the name silently
truncated to `org` or `ns`, so the wrong (or nonexistent) skill was
tracked.

The CLI counterpart `trackSlashCommand` (usage-tracker.ts) already
uses the full `[a-zA-Z0-9_\-:.]+` set. Align the hook handler.
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.

2 participants