feat(assistant): optimize MCP and custom widget authoring (#6743)
* feat(assistant): optimize MCP and custom widget authoring * fix(assistant): isolate server-safe JSX analyzer * refactor(assistant): generate MCP tool staging * fix(assistant): preserve widget placement follow-up * fix(ci): allow fast gate to finish * fix(custom-widgets): address review findings * fix(custom-widgets): split preview evidence module * style: format assistant custom widget files * fix(custom-widgets): sync formatted skill schema
This commit is contained in:
1 parent
38f4b0e1f8
commit
5e23659d99
95 files changed
+6799
-1778
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { createAssistantMcpToolGroups } from "./assistant-tool-groups";
|
||||
|
||||
const createTool = (name: string, group: string) => ({
|
||||
name,
|
||||
description: `${name} description`,
|
||||
pathInRouter: [group, name],
|
||||
});
|
||||
|
||||
describe("Assistant MCP tool groups", () => {
|
||||
test("derives deterministic groups from router paths", () => {
|
||||
const groups = createAssistantMcpToolGroups([
|
||||
createTool("board_search", "board"),
|
||||
createTool("mediaRequests_search", "mediaRequests"),
|
||||
createTool("board_getAll", "board"),
|
||||
]);
|
||||
|
||||
expect(groups.ids).toEqual(["board", "mediaRequests"]);
|
||||
expect(groups.resolve(["board"])[0]?.tools.map(({ name }) => name)).toEqual(["board_getAll", "board_search"]);
|
||||
});
|
||||
|
||||
test("deduplicates requested groups while preserving request order", () => {
|
||||
const groups = createAssistantMcpToolGroups([
|
||||
createTool("board_getAll", "board"),
|
||||
createTool("docker_getContainers", "docker"),
|
||||
]);
|
||||
|
||||
expect(groups.resolve(["docker", "board", "docker"]).map(({ id }) => id)).toEqual(["docker", "board"]);
|
||||
});
|
||||
|
||||
test("rejects tools without a router group and unknown group IDs", () => {
|
||||
expect(() => createAssistantMcpToolGroups([{ ...createTool("info_get", "info"), pathInRouter: [] }])).toThrow(
|
||||
"has no router group",
|
||||
);
|
||||
|
||||
const groups = createAssistantMcpToolGroups([createTool("info_get", "info")]);
|
||||
expect(() => groups.resolve(["missing"])).toThrow("Unknown Assistant MCP tool group 'missing'");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user