Skip to content

Commit 552ca30

Browse files
committed
fix(claude): dispatch native plugin names with punctuation
1 parent 8d43a80 commit 552ca30

2 files changed

Lines changed: 40 additions & 14 deletions

File tree

‎apps/server/src/provider/Drivers/ClaudeSkillDispatch.test.ts‎

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@ import { describe, expect, it } from "vite-plus/test";
22

33
import { planClaudeSkillDispatch } from "./ClaudeSkillDispatch.ts";
44

5-
const SKILLS = new Set(["2spec", "implement", "review", "re-release-version"]);
5+
const SKILLS = new Set([
6+
"2spec",
7+
"implement",
8+
"review",
9+
"re-release-version",
10+
"native-proof:dot.alias_Upper",
11+
]);
612

713
describe("planClaudeSkillDispatch", () => {
814
it("leaves a prompt without a known skill untouched", () => {
915
expect(planClaudeSkillDispatch("fix the build", SKILLS)).toBeUndefined();
1016
// Not a discovered skill, so it stays prose rather than becoming a command.
1117
expect(planClaudeSkillDispatch("echo $HOME then $unknown", SKILLS)).toBeUndefined();
18+
expect(planClaudeSkillDispatch("$native-proof:unknown.dot use this", SKILLS)).toBeUndefined();
19+
expect(
20+
planClaudeSkillDispatch(
21+
"$native-proof:space alias_Upper use this",
22+
new Set(["native-proof:space alias_Upper"]),
23+
),
24+
).toBeUndefined();
1225
});
1326

1427
it("moves a mid-prompt mention into a trailing slash command", () => {
@@ -27,20 +40,33 @@ describe("planClaudeSkillDispatch", () => {
2740
});
2841
});
2942

30-
it("dispatches a known skill whose name begins with a digit", () => {
31-
expect(planClaudeSkillDispatch("use $2spec for this", SKILLS)).toEqual({
32-
leadingText: "use",
33-
commandText: "/2spec for this",
34-
skillName: "2spec",
35-
});
36-
});
43+
it.each(["2spec", "native-proof:dot.alias_Upper"])(
44+
"dispatches the exact known skill %s with arguments intact",
45+
(name) => {
46+
expect(planClaudeSkillDispatch(`use $${name} for this\nand that`, SKILLS)).toEqual({
47+
leadingText: "use",
48+
commandText: `/${name} for this\nand that`,
49+
skillName: name,
50+
});
51+
},
52+
);
3753

3854
it("dispatches the last mention and rewrites earlier ones inline", () => {
3955
expect(planClaudeSkillDispatch("$review the diff, then $implement the fixes", SKILLS)).toEqual({
4056
leadingText: "/review the diff, then",
4157
commandText: "/implement the fixes",
4258
skillName: "implement",
4359
});
60+
expect(
61+
planClaudeSkillDispatch(
62+
"$native-proof:dot.space alias_Upper argument one\nnext",
63+
new Set(["native-proof:dot.space", "native-proof:dot.space alias_Upper"]),
64+
),
65+
).toEqual({
66+
leadingText: undefined,
67+
commandText: "/native-proof:dot.space alias_Upper argument one\nnext",
68+
skillName: "native-proof:dot.space",
69+
});
4470
});
4571

4672
it("dispatches currency-prefixed mentions and preserves their source boundaries", () => {
@@ -69,11 +95,11 @@ describe("planClaudeSkillDispatch", () => {
6995
});
7096

7197
it("ignores currency amounts and compact monetary expressions", () => {
72-
const skillsWithCurrency = new Set([...SKILLS, "20", "20k", "100M", "1e6"]);
98+
const skillsWithCurrency = new Set([...SKILLS, "20", "20k", "100M", "1e6", "20.5k"]);
7399
for (const symbol of ["$", "€", "£", "¥", "₹", "₩", "₿", "𑿝"]) {
74100
expect(
75101
planClaudeSkillDispatch(
76-
`pay ${symbol}20 ${symbol}20k ${symbol}100M ${symbol}1e6 tomorrow`,
102+
`pay ${symbol}20 ${symbol}20k ${symbol}100M ${symbol}1e6 ${symbol}20.5k tomorrow`,
77103
skillsWithCurrency,
78104
),
79105
).toBeUndefined();

‎apps/server/src/provider/Drivers/ClaudeSkillDispatch.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
*/
2626

2727
/**
28-
* Same token shape the composer and timeline chips recognise
29-
* (`packages/shared/src/composerInlineTokens.ts`), so a rendered chip and a
30-
* dispatched skill are always the same set.
28+
* Composer tokens plus namespaced plugin names, checked against the discovered
29+
* catalog below. Native plugin names can contain punctuation; whitespace ends
30+
* the command name and starts its arguments.
3131
*/
3232
const SKILL_MENTION_PATTERN =
33-
/(^|\s)\p{Sc}(?![0-9][0-9_]*(?:[kKmMbBtT]|[eE][0-9]+)?(?:\s|$))(?=[a-zA-Z0-9:_-]*[a-zA-Z])([a-zA-Z0-9][a-zA-Z0-9:_-]*)(?=\s|$)/gu;
33+
/(^|\s)\p{Sc}((?![0-9][0-9_]*(?:[kKmMbBtT]|[eE][0-9]+)?(?:\s|$))(?=[a-zA-Z0-9:_-]*[a-zA-Z])[a-zA-Z0-9][a-zA-Z0-9:_-]*|[^\s:]+:[^\s]+)(?=\s|$)/gu;
3434

3535
export interface ClaudeSkillDispatch {
3636
/** Text before the dispatched mention, or `undefined` when it opens the prompt. */

0 commit comments

Comments
 (0)