fix(server): attach explicit Codex $skill invocations #7196
Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/7196/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/provider/Layers/codexSkillInvocations.ts lines 22 to 24Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +2,21 @@2+import { collectComposerSkillInvocations } from "@t3tools/shared/composerInlineTokens";3+4+export type CodexSkillUserInput = {5+ readonly type: "skill";6+ readonly name: string;7+ readonly path: string;8+};9+10+export type BindCodexSkillInvocationsResult =11+ | { readonly ok: true; readonly inputs: ReadonlyArray<CodexSkillUserInput> }12+ | { readonly ok: false; readonly names: readonly string[] };13+14+function findCodexSkill(15+ name: string,16+ skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "path" | "enabled">>,17+): Pick<ServerProviderSkill, "name" | "path" | "enabled"> | undefined {18+ const lower = name.toLowerCase();19+ const matches = skills.filter(20+ (skill) => skill.name === name || skill.name.toLowerCase() === lower,21+ );22+ return matches.find((skill) => skill.enabled) ?? matches[0];packages/shared/src/composerInlineTokens.ts lines 26 to 26OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -18,4 +18,9 @@1818 readonly preserveTrailingFrom?: ReadonlyArray<ComposerInlineToken>;1919 }202021-const SKILL_TOKEN_REGEX = /(^|\s)\$([a-zA-Z][a-zA-Z0-9:_-]*)(?=\s)/g;21+const SKILL_NAME_PATTERN = "[a-zA-Z][a-zA-Z0-9:_-]*";22+// Trailing whitespace is required while typing so `$partial` does not become a chip.23+const SKILL_TOKEN_REGEX = new RegExp(`(^|\\s)\\$(${SKILL_NAME_PATTERN})(?=\\s)`, "g");24+// Submitted messages treat a token at end-of-input as complete.25+const COMPLETE_SKILL_INVOCATION_REGEX = new RegExp(26+ `(^|\\s)\\$(${SKILL_NAME_PATTERN})(?=\\s|$)`,
- apps/server/src/provider/Layers/codexSkillInvocations.ts line 54Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +27,21 @@27+ skills: ReadonlyArray<Pick<ServerProviderSkill, "name" | "path" | "enabled">>,28+): BindCodexSkillInvocationsResult {29+ const invocations = collectComposerSkillInvocations(prompt ?? "");30+ if (invocations.length === 0) {31+ return { ok: true, inputs: [] };32+ }33+34+ const inputs: CodexSkillUserInput[] = [];35+ const unknown: string[] = [];36+37+ for (const name of invocations) {38+ const skill = findCodexSkill(name, skills);39+ if (!skill) {40+ unknown.push(name);41+ continue;42+ }43+ inputs.push({44+ type: "skill",45+ name: skill.name,46+ path: skill.path,47+ });
- packages/shared/src/composerInlineTokens.ts line 27OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -18,4 +18,10 @@1818 readonly preserveTrailingFrom?: ReadonlyArray<ComposerInlineToken>;1919 }202021-const SKILL_TOKEN_REGEX = /(^|\s)\$([a-zA-Z][a-zA-Z0-9:_-]*)(?=\s)/g;21+const SKILL_NAME_PATTERN = "[a-zA-Z][a-zA-Z0-9:_-]*";22+// Trailing whitespace is required while typing so `$partial` does not become a chip.23+const SKILL_TOKEN_REGEX = new RegExp(`(^|\\s)\\$(${SKILL_NAME_PATTERN})(?=\\s)`, "g");24+// Submitted messages treat a token as complete when the next character is not25+// part of a skill name, so `$review.` and `$review,` still bind.26+const COMPLETE_SKILL_INVOCATION_REGEX = new RegExp(27+ `(^|\\s)\\$(${SKILL_NAME_PATTERN})(?![a-zA-Z0-9:_-])`,
- packages/shared/src/composerInlineTokens.ts lines 28 to 30OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -18,4 +18,13 @@1818 readonly preserveTrailingFrom?: ReadonlyArray<ComposerInlineToken>;1919 }202021-const SKILL_TOKEN_REGEX = /(^|\s)\$([a-zA-Z][a-zA-Z0-9:_-]*)(?=\s)/g;21+const SKILL_NAME_PATTERN = "[a-zA-Z][a-zA-Z0-9:_-]*";22+// Trailing whitespace is required while typing so `$partial` does not become a chip.23+const SKILL_TOKEN_REGEX = new RegExp(`(^|\\s)\\$(${SKILL_NAME_PATTERN})(?=\\s)`, "g");24+// Submitted messages also accept sentence punctuation so `$review.` / `$review,`25+// bind. A period only terminates when it is not an extension (`$review.md`).26+// Path-like `$HOME/.config` stays plain text — `/` is not a terminator.27+const COMPLETE_SKILL_INVOCATION_REGEX = new RegExp(28+ `(^|\\s)\\$(${SKILL_NAME_PATTERN})(?=\\s|$|[,!?;)"']|\\.(?![a-zA-Z0-9]))`,29+ "g",30+);
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
e683b00e-51bc-42d8-b835-0bd527f8ee5aYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share