@plitzi/sdk-mcp 0.38.6 → 0.38.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +397 -0
  2. package/README.md +9 -9
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +2 -3
  5. package/dist/modules/mcp/helpers/guide.js +74 -35
  6. package/dist/modules/mcp/index.d.ts +2 -2
  7. package/dist/modules/mcp/server.d.ts +4 -4
  8. package/dist/modules/mcp/server.js +10 -5
  9. package/dist/modules/mcp/tests/cheapMistakes.test.d.ts +1 -0
  10. package/dist/modules/mcp/tests/helpers.d.ts +9 -2
  11. package/dist/modules/mcp/tests/intents.test.d.ts +1 -0
  12. package/dist/modules/mcp/tests/look.test.d.ts +1 -0
  13. package/dist/modules/mcp/tools/apply/index.d.ts +706 -62
  14. package/dist/modules/mcp/tools/apply/index.js +70 -20
  15. package/dist/modules/mcp/tools/describeOperation.d.ts +11 -0
  16. package/dist/modules/mcp/tools/describeOperation.js +40 -0
  17. package/dist/modules/mcp/tools/describeOperation.test.d.ts +1 -0
  18. package/dist/modules/mcp/tools/index.d.ts +1 -6
  19. package/dist/modules/mcp/tools/index.js +12 -9
  20. package/dist/modules/mcp/tools/intents.d.ts +5 -0
  21. package/dist/modules/mcp/tools/intents.js +201 -0
  22. package/dist/modules/mcp/tools/look.d.ts +17 -0
  23. package/dist/modules/mcp/tools/look.js +32 -0
  24. package/dist/modules/mcp/tools/operations/closed.d.ts +7 -0
  25. package/dist/modules/mcp/tools/operations/closed.js +29 -0
  26. package/dist/modules/mcp/tools/operations/index.d.ts +2928 -359
  27. package/dist/modules/mcp/tools/operations/index.js +72 -51
  28. package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +1 -1
  29. package/dist/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +1 -1
  30. package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +1 -1
  31. package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +1 -1
  32. package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +1 -1
  33. package/dist/modules/mcp/tools/operations/schema/operations.d.ts +5 -5
  34. package/dist/modules/mcp/tools/operations/schema/shared.d.ts +3 -3
  35. package/dist/modules/mcp/tools/operations/schema/shared.js +7 -6
  36. package/dist/modules/mcp/tools/operations/schemaIds.js +11 -5
  37. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +90 -0
  38. package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +2 -1
  39. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +90 -0
  40. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +2 -1
  41. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +90 -0
  42. package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +8 -1
  43. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +90 -0
  44. package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +2 -1
  45. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +90 -0
  46. package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +2 -1
  47. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +90 -0
  48. package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +2 -1
  49. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +90 -0
  50. package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +2 -1
  51. package/dist/modules/mcp/tools/operations/style/operations.d.ts +639 -9
  52. package/dist/modules/mcp/tools/operations/style/shared.d.ts +394 -0
  53. package/dist/modules/mcp/tools/operations/style/shared.js +26 -8
  54. package/dist/modules/mcp/tools/operations/style/translator.js +26 -1
  55. package/dist/modules/mcp/tools/operations/style/validate.d.ts +4 -0
  56. package/dist/modules/mcp/tools/operations/style/validate.js +63 -0
  57. package/dist/modules/mcp/tools/operations/style/write.d.ts +1 -1
  58. package/dist/modules/mcp/tools/operations/style/write.js +88 -2
  59. package/dist/modules/mcp/tools/render.d.ts +675 -45
  60. package/dist/modules/mcp/tools/render.js +5 -1
  61. package/dist/modules/mcp/tools/shared/draftBatch.d.ts +3 -2
  62. package/dist/modules/mcp/tools/shared/draftBatch.js +16 -5
  63. package/dist/modules/mcp/tools/shared/effects.d.ts +2 -0
  64. package/dist/modules/mcp/tools/shared/effects.js +155 -0
  65. package/dist/modules/mcp/tools/shared/effects.test.d.ts +1 -0
  66. package/dist/modules/mcp/tools/shared/look.d.ts +32 -0
  67. package/dist/modules/mcp/tools/shared/look.js +128 -0
  68. package/dist/modules/mcp/tools/shared/normalizeOperations.d.ts +6 -0
  69. package/dist/modules/mcp/tools/shared/normalizeOperations.js +37 -0
  70. package/dist/modules/mcp/tools/shared/repeats.d.ts +13 -0
  71. package/dist/modules/mcp/tools/shared/repeats.js +38 -0
  72. package/dist/modules/mcp/tools/shared/tool.d.ts +9 -6
  73. package/dist/modules/mcp/tools/shared/tool.js +2 -1
  74. package/dist/modules/mcp/tools/shared/validator/context.d.ts +0 -1
  75. package/dist/modules/mcp/tools/shared/validator/elements.js +0 -1
  76. package/dist/modules/mcp/tools/shared/validator/index.js +25 -2
  77. package/dist/modules/mcp/types/aiSchema.d.ts +13 -1
  78. package/dist/modules/mcp/types/screenshotTypes.d.ts +3 -3
  79. package/dist/modules/mcp/types/toolTypes.d.ts +2 -4
  80. package/dist/options.d.ts +4 -5
  81. package/dist/preview/createPreview.js +9 -18
  82. package/package.json +7 -7
  83. package/skills/plitzi-render/SKILL.md +8 -184
  84. package/skills/plitzi-render/reference/good-call.md +88 -0
  85. package/skills/plitzi-render/reference/interactive.md +64 -0
  86. package/skills/plitzi-render/reference/looks.md +29 -0
  87. package/dist/modules/mcp/tools/preview.d.ts +0 -793
  88. package/dist/modules/mcp/tools/preview.js +0 -37
  89. package/dist/modules/mcp/tools/screenshot.d.ts +0 -1078
  90. package/dist/modules/mcp/tools/screenshot.js +0 -127
  91. package/dist/modules/mcp/tools/validate.d.ts +0 -1069
  92. package/dist/modules/mcp/tools/validate.js +0 -32
@@ -1,127 +0,0 @@
1
- import { operation } from "./operations/index.js";
2
- import { defineTool, imageResult } from "./shared/tool.js";
3
- import { unnamedControls } from "../accessibilityOutline.js";
4
- import { z } from "zod";
5
- //#region src/modules/mcp/tools/screenshot.ts
6
- var VIEWPORTS = {
7
- desktop: {
8
- label: "desktop",
9
- width: 1440,
10
- height: 900
11
- },
12
- mobile: {
13
- label: "mobile",
14
- width: 390,
15
- height: 844
16
- }
17
- };
18
- var resolveViewports = (choice) => {
19
- if (choice === "both") return [VIEWPORTS.desktop, VIEWPORTS.mobile];
20
- if (choice === "mobile") return [VIEWPORTS.mobile];
21
- return [VIEWPORTS.desktop];
22
- };
23
- var screenshotShape = {
24
- pageRef: z.string().optional().describe("The page to capture, by name; defaults to the space default page"),
25
- operations: z.array(operation).max(100).optional().describe("Unsaved edits to apply before rendering, so you can screenshot a proposed change WITHOUT persisting it (same op vocabulary as plitzi_apply). Omit to capture the current saved state."),
26
- viewport: z.enum([
27
- "desktop",
28
- "mobile",
29
- "both"
30
- ]).optional().describe("Which viewport(s) to capture. \"both\" catches responsive issues (e.g. overflow at one width). Default desktop."),
31
- fullPage: z.boolean().optional().describe("Capture the full scrollable page instead of only the visible viewport. Default false."),
32
- view: z.enum([
33
- "image",
34
- "accessibility",
35
- "both"
36
- ]).optional().describe("What to bring back. \"image\" (default) is the picture. \"accessibility\" is the page as a screen reader and a browser agent (Claude in Chrome) read it — its accessibility tree as an outline of roles and names — with every control and picture that has no name listed; text only, far cheaper than an image. \"both\" is both.")
37
- };
38
- var VIEWS = {
39
- image: ["image"],
40
- accessibility: ["accessibility"],
41
- both: ["image", "accessibility"]
42
- };
43
- /** Each viewport's outline, with what in it has no name — the part an agent acts on. */
44
- var readingOf = (outlines) => outlines.map(({ label, outline }) => ({
45
- viewport: label,
46
- outline,
47
- unnamed: unnamedControls(outline)
48
- }));
49
- var ACCESSIBILITY_HINT = "Every entry in `unnamed` is a control or picture announced by its role alone (\"button\") — nobody using a screen reader, and no browser agent, can tell what it does. Name it — a button: `title` or words inside; a link: `label`; a field: `label` (with `hideLabel` to keep it out of sight); an image: `alt`, or `decorative: true`; an icon that means something alone: `label`. `line` is where it sits in the outline.";
50
- var screenshotTool = defineTool({
51
- name: "plitzi_screenshot",
52
- title: "Screenshot",
53
- description: "Render a page to a real PNG image so you can SEE the visual result of your edits — overflow, misalignment and broken layout that data alone never reveals. Pass unsaved `operations` to screenshot a proposed change before committing, and viewport \"both\" to compare desktop and mobile. `view: \"accessibility\"` reads the page as a screen reader and a browser agent do instead, and lists every control with no name. Returns the image(s).",
54
- inputShape: screenshotShape,
55
- access: "read",
56
- requires: "screenshot",
57
- run: async (input, ctx) => {
58
- if (!ctx.preview || ctx.spaceId === void 0) return {
59
- error: "PREVIEW_UNAVAILABLE",
60
- message: "Visual preview is not enabled on this server.",
61
- hint: "Preview needs the SSR render service; it is unavailable in MCP-only mode."
62
- };
63
- const draft = {
64
- spaceId: ctx.spaceId,
65
- env: ctx.env,
66
- pageRef: input.pageRef,
67
- operations: input.operations
68
- };
69
- const pv = await ctx.preview.render({
70
- ...draft,
71
- includeHtml: !ctx.screenshot
72
- });
73
- if (!pv.ok) return pv;
74
- const viewports = resolveViewports(input.viewport);
75
- const view = input.view ?? "image";
76
- if (!ctx.screenshot) return {
77
- warning: "SCREENSHOT_DISABLED",
78
- message: view === "image" ? "The screenshot service is not configured; returning the HTML preview instead." : "No browser is configured, so the accessibility tree cannot be read; returning the HTML preview instead. Its roles and names are in the markup: every button, link and field needs words, every image an `alt`.",
79
- pageRef: input.pageRef ?? "default",
80
- pagePath: pv.pagePath,
81
- stateVersion: pv.stateVersion,
82
- html: pv.html
83
- };
84
- const shot = await ctx.screenshot.capture({
85
- pagePath: pv.pagePath,
86
- token: pv.token,
87
- viewports,
88
- fullPage: input.fullPage,
89
- views: VIEWS[view]
90
- });
91
- if (!shot.ok) {
92
- const fallback = await ctx.preview.render(draft);
93
- return {
94
- warning: "SCREENSHOT_UNAVAILABLE",
95
- message: `The screenshot service failed (${shot.message}); returning the HTML preview instead.`,
96
- hint: "The dedicated browser service is down or unreachable. Inspect the HTML, or retry later.",
97
- pageRef: input.pageRef ?? "default",
98
- pagePath: pv.pagePath,
99
- stateVersion: pv.stateVersion,
100
- html: fallback.ok ? fallback.html : ""
101
- };
102
- }
103
- const meta = {
104
- pageRef: input.pageRef ?? "default",
105
- pagePath: pv.pagePath,
106
- stateVersion: pv.stateVersion,
107
- viewports: viewports.map((v) => v.label)
108
- };
109
- const accessibility = view === "image" ? {} : shot.accessibility ? {
110
- accessibility: readingOf(shot.accessibility),
111
- hint: ACCESSIBILITY_HINT
112
- } : {
113
- warning: "ACCESSIBILITY_UNSUPPORTED",
114
- message: "The browser service answered without the accessibility tree — it predates the accessibility view. The image, if asked for, is still here."
115
- };
116
- if (view === "accessibility") return {
117
- ...meta,
118
- ...accessibility
119
- };
120
- return imageResult(shot.images, {
121
- ...meta,
122
- ...accessibility
123
- });
124
- }
125
- });
126
- //#endregion
127
- export { screenshotShape, screenshotTool };