fix(slashcommand): exclude skills from tool description to avoid duplication with skill tool

This commit is contained in:
YeonGyu-Kim 2026-02-13 17:51:38 +09:00
parent e3924437ce
commit 9742f7d0b9
2 changed files with 10 additions and 12 deletions

View File

@ -31,14 +31,13 @@ export function createSlashcommandTool(options: SlashcommandToolOptions = {}): T
const buildDescription = async (): Promise<string> => { const buildDescription = async (): Promise<string> => {
if (cachedDescription) return cachedDescription if (cachedDescription) return cachedDescription
const allItems = await getAllItems() const commands = getCommands()
cachedDescription = buildDescriptionFromItems(allItems) cachedDescription = buildDescriptionFromItems(commands)
return cachedDescription return cachedDescription
} }
if (options.commands !== undefined && options.skills !== undefined) { if (options.commands !== undefined) {
const allItems = [...options.commands, ...options.skills.map(skillToCommandInfo)] cachedDescription = buildDescriptionFromItems(options.commands)
cachedDescription = buildDescriptionFromItems(allItems)
} else { } else {
void buildDescription() void buildDescription()
} }

View File

@ -29,7 +29,7 @@ function createMockSkill(name: string, description = ""): LoadedSkill {
} }
describe("slashcommand tool - synchronous description", () => { describe("slashcommand tool - synchronous description", () => {
it("includes available_skills immediately when commands and skills are pre-provided", () => { it("includes only commands in description, not skills", () => {
// given // given
const commands = [createMockCommand("commit", "Create a git commit")] const commands = [createMockCommand("commit", "Create a git commit")]
const skills = [createMockSkill("playwright", "Browser automation via Playwright MCP")] const skills = [createMockSkill("playwright", "Browser automation via Playwright MCP")]
@ -38,12 +38,11 @@ describe("slashcommand tool - synchronous description", () => {
const tool = createSlashcommandTool({ commands, skills }) const tool = createSlashcommandTool({ commands, skills })
// then // then
expect(tool.description).toContain("<available_skills>")
expect(tool.description).toContain("commit") expect(tool.description).toContain("commit")
expect(tool.description).toContain("playwright") expect(tool.description).not.toContain("playwright")
}) })
it("includes all pre-provided commands and skills in description immediately", () => { it("lists all commands but excludes skills from description", () => {
// given // given
const commands = [ const commands = [
createMockCommand("commit", "Git commit"), createMockCommand("commit", "Git commit"),
@ -61,9 +60,9 @@ describe("slashcommand tool - synchronous description", () => {
// then // then
expect(tool.description).toContain("commit") expect(tool.description).toContain("commit")
expect(tool.description).toContain("plan") expect(tool.description).toContain("plan")
expect(tool.description).toContain("playwright") expect(tool.description).not.toContain("playwright")
expect(tool.description).toContain("frontend-ui-ux") expect(tool.description).not.toContain("frontend-ui-ux")
expect(tool.description).toContain("git-master") expect(tool.description).not.toContain("git-master")
}) })
it("shows prefix-only description when both commands and skills are empty", () => { it("shows prefix-only description when both commands and skills are empty", () => {