Show skill autocomplete anywhere in prompts

This commit is contained in:
Mohamed Boudra
2026-06-09 17:15:03 +07:00
parent 9f41904c6f
commit c5bcec5c71
15 changed files with 393 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, test } from "vitest";
import { SessionInboundMessageSchema } from "./messages.js";
import { SessionInboundMessageSchema, SessionOutboundMessageSchema } from "./messages.js";
describe("list_commands_request schema", () => {
test("accepts legacy agent-only payload", () => {
@@ -49,4 +49,61 @@ describe("list_commands_request schema", () => {
},
});
});
test("preserves command kind metadata in responses", () => {
const parsed = SessionOutboundMessageSchema.parse({
type: "list_commands_response",
payload: {
agentId: "agent-123",
requestId: "req-123",
error: null,
commands: [
{
name: "taste",
description: "Apply code taste",
argumentHint: "",
kind: "skill",
},
],
},
});
expect(parsed.type).toBe("list_commands_response");
if (parsed.type !== "list_commands_response") {
throw new Error("Expected list_commands_response message");
}
expect(parsed.payload.commands).toEqual([
{
name: "taste",
description: "Apply code taste",
argumentHint: "",
kind: "skill",
},
]);
});
test("falls back to command for unknown future command kinds", () => {
const parsed = SessionOutboundMessageSchema.parse({
type: "list_commands_response",
payload: {
agentId: "agent-123",
requestId: "req-123",
error: null,
commands: [
{
name: "future-command",
description: "Future command kind",
argumentHint: "",
kind: "future-kind",
},
],
},
});
expect(parsed.type).toBe("list_commands_response");
if (parsed.type !== "list_commands_response") {
throw new Error("Expected list_commands_response message");
}
expect(parsed.payload.commands[0]?.kind).toBe("command");
});
});

View File

@@ -3557,6 +3557,7 @@ const AgentSlashCommandSchema = z.object({
name: z.string(),
description: z.string(),
argumentHint: z.string(),
kind: z.enum(["command", "skill"]).optional().catch("command"),
});
export const ListCommandsResponseSchema = z.object({