mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
- **Restore points for agent work**: Create named restore points before major edits, review changes with a dry run, and safely revert project content if needed. - **Shared Slot authoring**: Agents can turn existing sections into shared Slots and insert linked copies across pages, including valid nested Slots. - **DTCG and Figma token imports**: Import design tokens and CSS variables through CLI, MCP, or direct paste, with aliases, modes, composite values, and mappings supported. - **Consistent token conflict handling**: Every paste workflow now offers the same preserve, rename, or merge choices instead of silently overwriting existing design tokens. - **Draft-page previews**: Agents can generate and inspect previews of draft pages without publishing them or exposing drafts in production builds. - **Safer MCP mutations**: Destructive operations require explicit confirmation, invalid raw patches and invented record IDs are rejected, and restore operations commit atomically. - **More dependable agent contracts**: New tools have complete runtime schemas, clearer validation errors, and consistent behavior across CLI, MCP, Builder, and server APIs.
32 lines
967 B
TypeScript
32 lines
967 B
TypeScript
import type { WebstudioFragment } from "@webstudio-is/sdk";
|
|
import { detectFragmentTokenConflicts } from "@webstudio-is/project-build/runtime";
|
|
import { builderApi } from "./builder-api";
|
|
import { getWebstudioData } from "./instance-utils/data";
|
|
import type {
|
|
TokenConflictDialogConflict,
|
|
TokenConflictDialogResult,
|
|
} from "./token-conflict-dialog";
|
|
|
|
export const resolveTokenConflicts = async (
|
|
conflicts: TokenConflictDialogConflict[]
|
|
): Promise<TokenConflictDialogResult> =>
|
|
conflicts.length === 0
|
|
? "theirs"
|
|
: builderApi.showTokenConflictDialog(conflicts);
|
|
|
|
export const resolveFragmentTokenConflicts = (
|
|
fragment: WebstudioFragment
|
|
): Promise<TokenConflictDialogResult> => {
|
|
if (
|
|
fragment.styleSources.some((source) => source.type === "token") === false
|
|
) {
|
|
return Promise.resolve("theirs");
|
|
}
|
|
return resolveTokenConflicts(
|
|
detectFragmentTokenConflicts({
|
|
fragment,
|
|
targetData: getWebstudioData(),
|
|
})
|
|
);
|
|
};
|