mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-28 07:37:36 +09:00
This PR expands Webstudio MCP and CLI into a more complete agent authoring interface. Agents can discover project capabilities, edit real Webstudio content, use data/resources, verify visual output, and report useful issues when workflows fail. ## MCP User Capabilities - Create, update, duplicate, reorder, and delete pages. - Create pages from templates and manage reusable page templates. - Inspect project pages, instances, props, styles, assets, variables, resources, and metadata. - Insert Webstudio components and authored JSX fragments into pages. - Edit text, props, styles, breakpoints, design tokens, and CSS variables. - Update page metadata, SEO fields, redirects, marketplace metadata, and project settings. - Create and use static data variables. - Create and use dynamic resources fetched over HTTP. - Use REST, GraphQL, and built-in system resources in authored pages. - Bind data variables and resources to visible page content. - Create resource-backed pages such as sitemap XML, structured SEO data, and API-driven content sections. - Preview current project state without requiring a publish step. - Capture screenshots for visual verification. - Verify responsive designs across desktop, tablet, and mobile breakpoints. - Use screenshot diff and OCR-style checks to inspect rendered output. - Reset and refresh local MCP project state when needed. - Discover available CLI/MCP commands from generated manuals. - Use clearer examples for resources, data variables, JSX authoring, previewing, and visual checks. - Read marketplace product metadata without requiring a full project snapshot. - Get safer guidance when using low-level patch tools. - Get a ready-to-copy Discord report template when MCP/CLI behavior is confusing or broken.
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { promisify } from "node:util";
|
|
import { afterEach, beforeEach, expect, test } from "vitest";
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const scriptPath = fileURLToPath(
|
|
new URL("../../../scripts/check-clean-files.mjs", import.meta.url)
|
|
);
|
|
|
|
let tempDir: string;
|
|
|
|
const git = async (...args: string[]) =>
|
|
await execFileAsync("git", args, { cwd: tempDir });
|
|
|
|
const runCheck = async (path: string) =>
|
|
await execFileAsync("node", [scriptPath, path], { cwd: tempDir });
|
|
|
|
beforeEach(async () => {
|
|
tempDir = await mkdtemp(join(tmpdir(), "webstudio-check-clean-files-"));
|
|
await git("init");
|
|
await git("config", "user.email", "test@example.com");
|
|
await git("config", "user.name", "Test");
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await rm(tempDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test("passes for clean tracked files", async () => {
|
|
await writeFile(join(tempDir, "generated.ts"), "export const value = 1;\n");
|
|
await git("add", "generated.ts");
|
|
await git("commit", "-m", "add generated file");
|
|
|
|
await expect(runCheck("generated.ts")).resolves.toMatchObject({
|
|
stdout: "Generated files are clean.\n",
|
|
});
|
|
});
|
|
|
|
test("fails for modified tracked files", async () => {
|
|
await writeFile(join(tempDir, "generated.ts"), "export const value = 1;\n");
|
|
await git("add", "generated.ts");
|
|
await git("commit", "-m", "add generated file");
|
|
await writeFile(join(tempDir, "generated.ts"), "export const value = 2;\n");
|
|
|
|
await expect(runCheck("generated.ts")).rejects.toMatchObject({
|
|
stderr: expect.stringContaining("M generated.ts"),
|
|
});
|
|
});
|
|
|
|
test("fails for untracked files", async () => {
|
|
await writeFile(join(tempDir, "generated.ts"), "export const value = 1;\n");
|
|
|
|
await expect(runCheck("generated.ts")).rejects.toMatchObject({
|
|
stderr: expect.stringContaining("?? generated.ts"),
|
|
});
|
|
});
|