GeezerVison is showing github.com — perf(server): plain Claude question answers skip skill discovery · pingdotgg/t3code@6c3a3a1
File treeExpand file treeCollapse file tree Open diff view settings orchestration-v2/Adapters
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -160,6 +160,7 @@ import { resolveAttachmentPath } from "../../attachmentStore.ts"; | 160 | 160 | import { snapshotMcpApp } from "../../mcpApps/McpAppSnapshot.ts"; | 161 | 161 | import { resolveClaudeSdkExecutablePath } from "../../provider/Drivers/ClaudeExecutable.ts"; | 162 | 162 | import { | | 163 | + answerMayMentionClaudeSkill, | 163 | 164 | rewriteClaudeSkillMentionsInAnswer, | 164 | 165 | planClaudeSkillDispatch, | 165 | 166 | type ClaudeSkillTarget, | @@ -10438,7 +10439,11 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* ( | 10438 | 10439 | questions: toolInput.questions, | 10439 | 10440 | answers: claudeSdkUserInputAnswers( | 10440 | 10441 | resolvedAnswers, | 10441 | | - yield* userInvocableSkills(context.input.runtimePolicy.cwd), | | 10442 | + Object.values(claudeSdkUserInputAnswers(resolvedAnswers, new Map())).some( | | 10443 | + answerMayMentionClaudeSkill, | | 10444 | + ) | | 10445 | + ? yield* userInvocableSkills(context.input.runtimePolicy.cwd) | | 10446 | + : new Map(), | 10442 | 10447 | ), | 10443 | 10448 | }, | 10444 | 10449 | toolUseID: callbackOptions.toolUseID, | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeSkillDispatch.test.ts +17-1Lines changed: 17 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { describe, expect, it } from "vite-plus/test"; | 2 | 2 |
| 3 | | -import { planClaudeSkillDispatch, type ClaudeSkillTarget } from "./ClaudeSkillDispatch.ts"; | | 3 | +import { | | 4 | + answerMayMentionClaudeSkill, | | 5 | + planClaudeSkillDispatch, | | 6 | + rewriteClaudeSkillMentionsInAnswer, | | 7 | + type ClaudeSkillTarget, | | 8 | +} from "./ClaudeSkillDispatch.ts"; | 4 | 9 |
| 5 | 10 | const skillPath = (name: string) => `/home/me/.claude/skills/${name}/SKILL.md`; | 6 | 11 |
| @@ -83,4 +88,15 @@ describe("planClaudeSkillDispatch", () => { | 83 | 88 | commandText: "/implement the fixes", | 84 | 89 | }); | 85 | 90 | }); | | 91 | + | | 92 | + it("pre-check passes every answer the rewrite would change", () => { | | 93 | + const userOnly = new Map([["review", { path: skillPath("review"), userInvocationOnly: true }]]); | | 94 | + for (const answer of ["$review", "ok €review now", "/review", "\n /review it"]) { | | 95 | + expect(rewriteClaudeSkillMentionsInAnswer(answer, userOnly)).not.toBe(answer); | | 96 | + expect(answerMayMentionClaudeSkill(answer)).toBe(true); | | 97 | + } | | 98 | + for (const answer of ["Yes", "Simple, Safe", "see docs/review", ""]) { | | 99 | + expect(answerMayMentionClaudeSkill(answer)).toBe(false); | | 100 | + } | | 101 | + }); | 86 | 102 | }); |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Drivers/ClaudeSkillDispatch.ts +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -68,6 +68,11 @@ export function planClaudeSkillDispatch( | 68 | 68 | }; | 69 | 69 | } | 70 | 70 |
| | 71 | +/** Cheap pre-check so an answer with no skill syntax skips skill discovery. */ | | 72 | +export function answerMayMentionClaudeSkill(answer: string): boolean { | | 73 | + return /\p{Sc}|^\s*\//u.test(answer); | | 74 | +} | | 75 | + | 71 | 76 | /** Tool results never expand skills, so an answer only names them for the agent to run. */ | 72 | 77 | export function rewriteClaudeSkillMentionsInAnswer( | 73 | 78 | answer: string, | |
|