@@ -190,6 +190,16 @@ function requireCommand<T extends { name: string }>(commands: T[], name: string)
|
190 | 190 | return command; |
191 | 191 | } |
192 | 192 | |
| 193 | +function collectBuiltinNames(commands: readonly { name: string; source: string }[]): string[] { |
| 194 | +const names: string[] = []; |
| 195 | +for (const command of commands) { |
| 196 | +if (command.source !== "plugin") { |
| 197 | +names.push(command.name); |
| 198 | +} |
| 199 | +} |
| 200 | +return names; |
| 201 | +} |
| 202 | + |
193 | 203 | describe("commands.list handler", () => { |
194 | 204 | beforeEach(() => { |
195 | 205 | vi.clearAllMocks(); |
@@ -286,7 +296,7 @@ describe("commands.list handler", () => {
|
286 | 296 | it("filters built-in commands by scope=native (excludes text-only)", () => { |
287 | 297 | const { payload } = callHandler({ scope: "native" }); |
288 | 298 | const { commands } = payload as { commands: Array<{ name: string; source: string }> }; |
289 | | -const builtinNames = commands.filter((c) => c.source !== "plugin").map((c) => c.name); |
| 299 | +const builtinNames = collectBuiltinNames(commands); |
290 | 300 | expect(builtinNames).not.toContain("commands"); |
291 | 301 | expect(builtinNames).toContain("model"); |
292 | 302 | expect(builtinNames).toContain("debug_prompt"); |
@@ -295,7 +305,7 @@ describe("commands.list handler", () => {
|
295 | 305 | it("filters built-in commands by scope=text (excludes native-only)", () => { |
296 | 306 | const { payload } = callHandler({ scope: "text" }); |
297 | 307 | const { commands } = payload as { commands: Array<{ name: string; source: string }> }; |
298 | | -const builtinNames = commands.filter((c) => c.source !== "plugin").map((c) => c.name); |
| 308 | +const builtinNames = collectBuiltinNames(commands); |
299 | 309 | expect(builtinNames).toContain("commands"); |
300 | 310 | expect(builtinNames).not.toContain("debug_prompt"); |
301 | 311 | }); |
|