@enhance-eng/enhance 0.1.16 → 0.1.20
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.
- package/dist/{cli-output-identity.lib-F9-nlguI.mjs → cli-output-identity.lib-Du4_Ahcj.mjs} +2017 -1078
- package/dist/main.mjs +46 -19
- package/dist/{mcp-invocation.adapter-fYfIiCYu.mjs → mcp-invocation.adapter-CcSWERtl.mjs} +2 -2
- package/dist/mcp-main.mjs +7 -7
- package/dist/{mcp-server.adapter-C8plL5bs.mjs → mcp-server.adapter-DrbFMc01.mjs} +1 -1
- package/dist/mcp.mjs +2 -2
- package/dist/{mutation-key.adapter-Bc4p5ff4.mjs → mutation-key.adapter-B6dNFpWt.mjs} +88 -73
- package/dist/remote-mcp-main.mjs +5 -5
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as createOrganisationOutputSchema, A as parseCanvasReference,
|
|
3
|
-
import { a as createOauthLoopbackAdapter, c as createWriteHtmlCanvasComposite, d as createApplyCanvasComposite, f as createCanvasActivityComposite, l as createEditCanvasComposite, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, p as createRenderCanvasComposite, r as CLI_CONFIG, s as createRenderFileAdapter, t as createMutationKeyAdapter, u as sceneAtVersion } from "./mutation-key.adapter-
|
|
2
|
+
import { $ as createOrganisationOutputSchema, A as parseCanvasReference, D as assertCanvasReferenceOperations, Dt as canvasAxisStyleProperties, E as assertCanvasReferenceNodes, Et as canvasAuthoredStyleDeclarations, F as completeScreenOutputSchema, I as createScreenOutputSchema, L as appendRecordingChunkOutputSchema, M as CliError, O as canvasReferenceNodeIds, Ot as canvasLayoutMainAxisOf, P as appErrorSchema, R as completeRecordingOutputSchema, T as canvasEditsSchema, Tt as canvasAuthoredLayoutValueOf, a as toExitCode, at as canvasAgentActivityPhaseSchema, c as toSharedCapabilities, ct as saveCanvasDocumentOutputSchema, d as createCapabilityCatalogAdapter, et as emptyFixtureDocument, f as createRouterShapeAdapter, ft as canvasOperationSchema, g as PROCEDURE_DESCRIPTIONS, gt as RENDER_MIN_SCALE, h as OPTION_DESCRIPTIONS, i as toCanvasAuthoringResult, it as beginCanvasActivityOutputSchema, j as PartialBatchError, jt as canvasSchema, k as fromCanvasReference, kt as canvasLayoutPriorityDeclarations, l as createMcpCapabilityDiscoveryAdapter, lt as MAX_CANVAS_OPERATIONS, n as withCommandName, o as toFailurePayload, p as createCapabilityPolicyAdapter, st as getCanvasDocumentOutputSchema, t as withCommandInFailure, tt as withFixtureScreen, u as ProcessExitError, wt as canvasReadableSceneDocumentSchema, yt as canvasWorldBoundsSchema, z as startRecordingOutputSchema } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
|
+
import { a as createOauthLoopbackAdapter, c as createWriteHtmlCanvasComposite, d as createApplyCanvasComposite, f as createCanvasActivityComposite, l as createEditCanvasComposite, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, p as createRenderCanvasComposite, r as CLI_CONFIG, s as createRenderFileAdapter, t as createMutationKeyAdapter, u as sceneAtVersion } from "./mutation-key.adapter-B6dNFpWt.mjs";
|
|
4
4
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
5
5
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-rI5HpMEo.mjs";
|
|
6
6
|
import { Command } from "commander";
|
|
@@ -444,7 +444,8 @@ const selectMutationToken = (input, value) => {
|
|
|
444
444
|
const configureCanvasApply = (canvas, input) => {
|
|
445
445
|
canvas.command("apply").description("Apply an atomic canvas edit batch and return its affected bounds.").requiredOption("--canvas <url-or-id>", "Canvas URL or UUID to edit.").requiredOption("--base-version <integer>", "Exact version returned by canvas inspect or tree.").requiredOption("--operations <json-or-@path>", "JSON operation array inline, or @path to a JSON file.").option("--client-token <uuid>", "Stable UUID to reuse only when retrying this exact batch.").addHelpText("after", [
|
|
446
446
|
"",
|
|
447
|
-
"Supported operations: insertNode, insertText, insertPrototype, setText, setBox, setLabel, setVisibility, setLocked, setConstraints, setStyles, setAppearance, setLayout, setTypography, setAdditionalStyles, setProps, setParentage, move, remove.",
|
|
447
|
+
"Supported operations: insertNode, insertText, insertPrototype, setText, editText, setBox, setLabel, setVisibility, setLocked, setConstraints, setStyles, setAppearance, setLayout, patchTypography, setTypography, patchAdditionalStyles, setAdditionalStyles, setProps, setParentage, move, remove.",
|
|
448
|
+
"Use editText for revision-aware character or range changes. setText replaces the whole text and is rejected if it conflicts with a newer text edit.",
|
|
448
449
|
"Example:",
|
|
449
450
|
` enhance canvas apply --canvas <url-or-id> --base-version 3 --operations '[{"op":"insertText","nodeId":"txt_summary","parentId":"root","text":"Checkout needs an address.","box":{"x":120,"y":594,"width":720,"height":80},"styles":{"font-size":24}}]'`
|
|
450
451
|
].join("\n")).action(async (options) => {
|
|
@@ -866,18 +867,38 @@ const appearanceCss = (appearance) => {
|
|
|
866
867
|
...effectCss(appearance)
|
|
867
868
|
};
|
|
868
869
|
};
|
|
869
|
-
const
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
"
|
|
873
|
-
|
|
874
|
-
"
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
"
|
|
870
|
+
const typographyMetrics = (typography) => {
|
|
871
|
+
const result = {};
|
|
872
|
+
const height = typography.lineHeight;
|
|
873
|
+
if (height !== void 0) result["line-height"] = height.mode === "normal" ? "normal" : `${String(height.value)}${height.mode === "percent" ? "%" : "px"}`;
|
|
874
|
+
const spacing = typography.letterSpacing;
|
|
875
|
+
if (spacing !== void 0) result["letter-spacing"] = typeof spacing === "number" ? `${String(spacing)}px` : `${String(spacing.value / PERCENT)}em`;
|
|
876
|
+
return result;
|
|
877
|
+
};
|
|
878
|
+
const typographyCss = (node) => {
|
|
879
|
+
const typography = node.typography ?? {};
|
|
880
|
+
const result = {};
|
|
881
|
+
const families = String(canvasAuthoredStyleDeclarations(node)["font-family"] ?? "sans-serif").split(",");
|
|
882
|
+
if (typography.family !== void 0 || typography.fallbackFamilies !== void 0) result["font-family"] = [typography.family ?? families[0], ...typography.fallbackFamilies ?? families.slice(1)].join(", ");
|
|
883
|
+
if (typography.size !== void 0) result["font-size"] = `${String(typography.size)}px`;
|
|
884
|
+
for (const [field, property] of [
|
|
885
|
+
["weight", "font-weight"],
|
|
886
|
+
["style", "font-style"],
|
|
887
|
+
["align", "text-align"],
|
|
888
|
+
["transform", "text-transform"]
|
|
889
|
+
]) {
|
|
890
|
+
const value = typography[field];
|
|
891
|
+
if (value !== void 0) result[property] = value;
|
|
892
|
+
}
|
|
893
|
+
if (typography.decoration !== void 0) {
|
|
894
|
+
result["text-decoration-line"] = typography.decoration.line;
|
|
895
|
+
result["text-decoration-style"] = typography.decoration.style;
|
|
896
|
+
}
|
|
897
|
+
if (typography.wrapping !== void 0) result["white-space"] = typography.wrapping === "wrap" ? "normal" : typography.wrapping;
|
|
898
|
+
return {
|
|
899
|
+
...result,
|
|
900
|
+
...typographyMetrics(typography)
|
|
901
|
+
};
|
|
881
902
|
};
|
|
882
903
|
const computedCanvasNodeCss = (node, document) => ({
|
|
883
904
|
...Object.fromEntries(Object.entries(canvasAuthoredStyleDeclarations(node)).filter(([property]) => node.layout?.clipContent === void 0 || ![
|
|
@@ -885,7 +906,7 @@ const computedCanvasNodeCss = (node, document) => ({
|
|
|
885
906
|
"overflow-x",
|
|
886
907
|
"overflow-y"
|
|
887
908
|
].includes(property))),
|
|
888
|
-
...typographyCss(node
|
|
909
|
+
...typographyCss(node),
|
|
889
910
|
...appearanceCss(node.appearance),
|
|
890
911
|
...canvasStyleLayoutCss(node, document),
|
|
891
912
|
...node.visible === false && { display: "none" }
|
|
@@ -1349,10 +1370,11 @@ const COMMAND_SUMMARIES = {
|
|
|
1349
1370
|
"canvas.duplicate": "Copy a canvas into a shelf.",
|
|
1350
1371
|
"canvas.deletePermanently": "Permanently delete a binned canvas.",
|
|
1351
1372
|
"canvas.restore": "Restore a binned canvas.",
|
|
1352
|
-
"canvas.inspect": "Read
|
|
1373
|
+
"canvas.inspect": "Read canvas URL, structure, and next steps.",
|
|
1353
1374
|
"canvas.tree": "List canvas node ids, hierarchy, kinds, and boxes.",
|
|
1354
1375
|
"canvas.node": "Read one canvas node and its children.",
|
|
1355
1376
|
"canvas.selection": "Read the person’s current live browser selection.",
|
|
1377
|
+
"canvas text-style-library": "Discover and publish text styles.",
|
|
1356
1378
|
"canvas realtime": "Canvas presence and activity.",
|
|
1357
1379
|
"canvas document": "Read or replace a canvas document.",
|
|
1358
1380
|
"canvas version": "Retained canvas history.",
|
|
@@ -1391,6 +1413,7 @@ const createProcessAdapter = () => ({ exit: (code) => {
|
|
|
1391
1413
|
//#endregion
|
|
1392
1414
|
//#region src/infrastructure/cli-polish.lib.ts
|
|
1393
1415
|
const NAMESPACES = {
|
|
1416
|
+
"canvas text-style-library": "Find, read, and publish reusable text styles across canvases.",
|
|
1394
1417
|
canvas: "Canvases: create, find, share, and manage review surfaces.",
|
|
1395
1418
|
"canvas render": "Render production-faithful canvas pixels after inspecting exact structure and geometry.",
|
|
1396
1419
|
"canvas version": "Inspect and name retained canvas history.",
|
|
@@ -1526,7 +1549,11 @@ const polishCli = (command, input, path = []) => {
|
|
|
1526
1549
|
//#endregion
|
|
1527
1550
|
//#region src/infrastructure/cli-surface.lib.ts
|
|
1528
1551
|
const CLI_EXCLUDED_PROCEDURES = createCapabilityPolicyAdapter().excludedProcedures;
|
|
1529
|
-
const CLI_EXCLUDED_NAMESPACES = /* @__PURE__ */ new Set([
|
|
1552
|
+
const CLI_EXCLUDED_NAMESPACES = /* @__PURE__ */ new Set([
|
|
1553
|
+
"canvas thumbnail",
|
|
1554
|
+
"canvas font-catalog",
|
|
1555
|
+
"telemetry"
|
|
1556
|
+
]);
|
|
1530
1557
|
const procedurePathOf$1 = (command) => {
|
|
1531
1558
|
const details = Reflect.get(command, "__trpcCli");
|
|
1532
1559
|
if (typeof details !== "object" || details === null) return null;
|
|
@@ -2148,7 +2175,7 @@ const main = async () => {
|
|
|
2148
2175
|
const credentials = createFileCredentialAdapter(CLI_CONFIG.configDirectory);
|
|
2149
2176
|
const mutationKey = createMutationKeyAdapter();
|
|
2150
2177
|
const cli = createCliProgram({
|
|
2151
|
-
version: "0.1.
|
|
2178
|
+
version: "0.1.20",
|
|
2152
2179
|
credentials,
|
|
2153
2180
|
remote: createHttpRemoteAdapter(CLI_CONFIG.apiUrl, credentials, mutationKey),
|
|
2154
2181
|
mutationKey,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { o as toFailurePayload } from "./cli-output-identity.lib-
|
|
3
|
-
import { a as createOauthLoopbackAdapter, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-
|
|
2
|
+
import { o as toFailurePayload } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
|
+
import { a as createOauthLoopbackAdapter, m as createAuthUseCase, n as createHttpRemoteAdapter, o as createCapabilityInvocationAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-B6dNFpWt.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/infrastructure/mcp-auth.adapter.ts
|
package/dist/mcp-main.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as createCapabilityCatalogAdapter, m as toCapabilityDefinition } from "./cli-output-identity.lib-
|
|
3
|
-
import { r as CLI_CONFIG } from "./mutation-key.adapter-
|
|
2
|
+
import { d as createCapabilityCatalogAdapter, m as toCapabilityDefinition } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
|
+
import { r as CLI_CONFIG } from "./mutation-key.adapter-B6dNFpWt.mjs";
|
|
4
4
|
import { t as createFileCredentialAdapter } from "./file-credential.adapter-rI5HpMEo.mjs";
|
|
5
|
-
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
6
|
-
import { t as createMcpServerAdapter } from "./mcp-server.adapter-
|
|
5
|
+
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-CcSWERtl.mjs";
|
|
6
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-DrbFMc01.mjs";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
import process from "node:process";
|
|
9
9
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
@@ -152,7 +152,7 @@ const capabilities = [
|
|
|
152
152
|
exampleInput: {},
|
|
153
153
|
exampleOutput: {
|
|
154
154
|
status: "ok",
|
|
155
|
-
runtimeVersion: "0.1.
|
|
155
|
+
runtimeVersion: "0.1.20",
|
|
156
156
|
api: {
|
|
157
157
|
reachable: true,
|
|
158
158
|
status: 200
|
|
@@ -167,10 +167,10 @@ const createMcpTransportCapabilityAdapter = () => capabilities;
|
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/mcp-main.ts
|
|
169
169
|
const credentials = createFileCredentialAdapter(CLI_CONFIG.configDirectory);
|
|
170
|
-
const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.
|
|
170
|
+
const invocation = createMcpInvocationAdapter(CLI_CONFIG.apiUrl, credentials, CLI_CONFIG.configDirectory, "0.1.20");
|
|
171
171
|
const catalog = [...createCapabilityCatalogAdapter(), ...createMcpTransportCapabilityAdapter()];
|
|
172
172
|
serveStdio(() => createMcpServerAdapter({
|
|
173
|
-
version: "0.1.
|
|
173
|
+
version: "0.1.20",
|
|
174
174
|
name: CLI_CONFIG.mcpServiceName,
|
|
175
175
|
commandName: CLI_CONFIG.commandName,
|
|
176
176
|
invocation,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as parseCanvasReference, E as assertCanvasReferenceNodes, M as CliError,
|
|
2
|
+
import { A as parseCanvasReference, E as assertCanvasReferenceNodes, M as CliError, _t as canvasRenderSourceStateSchema, d as createCapabilityCatalogAdapter, i as toCanvasAuthoringResult, l as createMcpCapabilityDiscoveryAdapter, n as withCommandName, o as toFailurePayload, r as canvasRenderResultSchema, s as toPresentedCapabilities, st as getCanvasDocumentOutputSchema, t as withCommandInFailure, vt as canvasRenderTargetSchema, w as canvasEditCapabilityInputSchema, wt as canvasReadableSceneDocumentSchema, y as canvasWriteHtmlCapabilityInputSchema } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
5
|
import { readFile, rm } from "node:fs/promises";
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as toSharedCapabilities, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-
|
|
2
|
+
import { c as toSharedCapabilities, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
3
|
import { t as toCapabilityInventory } from "./capability-inventory.mapper-DyYXyVBJ.mjs";
|
|
4
|
-
import { t as createMcpServerAdapter } from "./mcp-server.adapter-
|
|
4
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-DrbFMc01.mjs";
|
|
5
5
|
|
|
6
6
|
export { createCapabilityCatalogAdapter, createMcpServerAdapter as createEnhanceMcpServer, toCapabilityInventory, toSharedCapabilities };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as parseCanvasReference, B as PROTOTYPE_ARTIFACT_MANIFEST_PATH, C as transcriptReadCapabilityInputSchema, Ct as
|
|
2
|
+
import { A as parseCanvasReference, At as canvasAdditionalStyleSchema, B as PROTOTYPE_ARTIFACT_MANIFEST_PATH, C as transcriptReadCapabilityInputSchema, Ct as getCanvasRenderOutputSchema, D as assertCanvasReferenceOperations, Dt as canvasAxisStyleProperties, E as assertCanvasReferenceNodes, G as getPrototypePublishStatusOutputSchema, H as createPrototypeArtifactOutputSchema, J as submitPrototypeArtifactOutputSchema, K as prototypeArtifactManifestSchema, M as CliError, N as transcriptOutputSchema, Q as createAgentTokenOutputSchema, S as recordingSnapshotCapabilityInputSchema, St as downloadCanvasRenderOutputSchema, U as foldPrototypeArtifactPath, V as attachPrototypeArtifactOutputSchema, W as getPrototypeArtifactCapabilitiesOutputSchema, Y as getMeOutputSchema, Z as cliAuthConfigurationSchema, _ as canvasApplyCapabilityInputSchema, b as commentAttentionCapabilityInputSchema, bt as createCanvasRenderOutputSchema, dt as applyCanvasOperationsOutputSchema, ht as getCanvasConversionOutputSchema, it as beginCanvasActivityOutputSchema, j as PartialBatchError, lt as MAX_CANVAS_OPERATIONS, mt as createCanvasConversionOutputSchema, nt as applyCanvasTypographyPatch, ot as canvasLayoutWithoutCssProperties, pt as canvasNodeStylePatchSchema, q as prototypeArtifactPathSchema, rt as canvasCssTypographyOwners, st as getCanvasDocumentOutputSchema, ut as applyCanvasOperationsInputSchema, v as canvasRenderCapabilityInputSchema, w as canvasEditCapabilityInputSchema, wt as canvasReadableSceneDocumentSchema, x as prototypePublishCapabilityInputSchema, xt as createRecordingSnapshotOutputSchema, y as canvasWriteHtmlCapabilityInputSchema } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { homedir, tmpdir } from "node:os";
|
|
5
5
|
import process from "node:process";
|
|
@@ -16,6 +16,56 @@ import { createTRPCUntypedClient, httpLink } from "@trpc/client";
|
|
|
16
16
|
import { spawn } from "node:child_process";
|
|
17
17
|
import { createServer } from "node:http";
|
|
18
18
|
|
|
19
|
+
//#region ../../packages/contract/src/canvas/canvas-additional-style-patch.lib.ts
|
|
20
|
+
const reorderedDeclarations = (declarations, order) => {
|
|
21
|
+
const ordered = new Set(order);
|
|
22
|
+
const prefix = [];
|
|
23
|
+
const groups = /* @__PURE__ */ new Map();
|
|
24
|
+
let group = prefix;
|
|
25
|
+
for (const declaration of declarations) {
|
|
26
|
+
if (ordered.has(declaration.id)) {
|
|
27
|
+
group = [];
|
|
28
|
+
groups.set(declaration.id, group);
|
|
29
|
+
}
|
|
30
|
+
group.push(declaration);
|
|
31
|
+
}
|
|
32
|
+
return [...prefix, ...order.flatMap((id) => groups.get(id) ?? [])];
|
|
33
|
+
};
|
|
34
|
+
/** Peer rows keep their preceding anchor when an explicitly ordered subset moves. */
|
|
35
|
+
const applyCanvasAdditionalStylePatch = (before, patch) => {
|
|
36
|
+
const removed = new Set(patch.clear);
|
|
37
|
+
const values = new Map((before?.declarations ?? []).filter((item) => !removed.has(item.id)).map((item) => [item.id, item]));
|
|
38
|
+
const updates = patch.set ?? [];
|
|
39
|
+
for (const declaration of updates) values.set(declaration.id, declaration);
|
|
40
|
+
const declarations = Array.from(values, ([, value]) => value);
|
|
41
|
+
if (declarations.length === 0 && (patch.empty === "remove" || before === void 0 && patch.empty !== "keep")) return null;
|
|
42
|
+
return { declarations: patch.order === void 0 ? declarations : reorderedDeclarations(declarations, patch.order) };
|
|
43
|
+
};
|
|
44
|
+
const canvasAdditionalStylePatchBetween = (before, after) => {
|
|
45
|
+
const previous = new Map(before?.declarations.map((item) => [item.id, item]));
|
|
46
|
+
const next = after?.declarations ?? [];
|
|
47
|
+
const nextIds = new Set(next.map((item) => item.id));
|
|
48
|
+
const clear = Array.from(previous, ([id]) => id).filter((id) => !nextIds.has(id));
|
|
49
|
+
const set = next.filter((item) => {
|
|
50
|
+
const held = previous.get(item.id);
|
|
51
|
+
return held?.property !== item.property || held.value !== item.value || held.enabled !== item.enabled;
|
|
52
|
+
});
|
|
53
|
+
const patch = {
|
|
54
|
+
...clear.length > 0 && { clear },
|
|
55
|
+
...set.length > 0 && { set }
|
|
56
|
+
};
|
|
57
|
+
const projected = applyCanvasAdditionalStylePatch(before, patch);
|
|
58
|
+
const order = next.map((item) => item.id);
|
|
59
|
+
const hasOrderChange = JSON.stringify(projected?.declarations.map((item) => item.id) ?? []) !== JSON.stringify(order);
|
|
60
|
+
const empty = after === void 0 && before !== void 0 ? "remove" : before === void 0 && after !== void 0 && next.length === 0 ? "keep" : void 0;
|
|
61
|
+
return empty === void 0 && !hasOrderChange && set.length === 0 && clear.length === 0 ? null : {
|
|
62
|
+
...patch,
|
|
63
|
+
...hasOrderChange && { order },
|
|
64
|
+
...empty !== void 0 && { empty }
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
19
69
|
//#region src/application/auth.use-case.ts
|
|
20
70
|
const TOKEN = /^enh_[\w-]{43}$/;
|
|
21
71
|
const authenticated = (value) => {
|
|
@@ -326,7 +376,7 @@ const union = (boxes) => {
|
|
|
326
376
|
const apply = async (remote, input) => {
|
|
327
377
|
const response = await remote.mutate(APPLY_PROCEDURE, {
|
|
328
378
|
...input,
|
|
329
|
-
documentFormatVersion:
|
|
379
|
+
documentFormatVersion: 5
|
|
330
380
|
});
|
|
331
381
|
const parsed = applyCanvasOperationsOutputSchema.safeParse(response);
|
|
332
382
|
if (!parsed.success) throw new CliError("INTERNAL", "The API returned an invalid canvas apply response.", "Run `enhance doctor`; report the API and CLI versions if they differ.");
|
|
@@ -604,76 +654,49 @@ const moveCanvasNodeOperations = (document, inputs) => {
|
|
|
604
654
|
|
|
605
655
|
//#endregion
|
|
606
656
|
//#region src/application/canvas-typography-operations.use-case.ts
|
|
607
|
-
const NORMAL_FONT_WEIGHT = 400;
|
|
608
|
-
const BOLD_FONT_WEIGHT = 700;
|
|
609
|
-
const fontSize = (value) => {
|
|
610
|
-
if (typeof value === "number") return value;
|
|
611
|
-
return /^(?:\d+(?:\.\d+)?|\.\d+)px$/u.test(String(value)) ? Number(String(value).replace("px", "")) : NaN;
|
|
612
|
-
};
|
|
613
|
-
const fontWeight = (value) => {
|
|
614
|
-
if (value === "normal") return NORMAL_FONT_WEIGHT;
|
|
615
|
-
return value === "bold" ? BOLD_FONT_WEIGHT : Number(value);
|
|
616
|
-
};
|
|
617
657
|
const canvasTypographyOperation = (node, styles) => {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
"
|
|
621
|
-
"font-size",
|
|
622
|
-
"font-weight",
|
|
623
|
-
"font-style"
|
|
624
|
-
];
|
|
625
|
-
if (keys.every((key) => !Object.hasOwn(styles, key))) return null;
|
|
626
|
-
if (keys.some((key) => styles[key] === null)) throw new CliError("BAD_REQUEST", "Imported typography needs an explicit font value.", "Replace the font family, pixel size, weight or style instead of clearing that field.");
|
|
627
|
-
const next = { ...node.typography };
|
|
628
|
-
const family = styles["font-family"];
|
|
629
|
-
if (family !== void 0) {
|
|
630
|
-
const families = String(family).split(",").map((held) => held.trim().replaceAll(/^(?:"|')|(?:"|')$/gu, "")).filter((held) => held !== "");
|
|
631
|
-
next.family = families[0] ?? "";
|
|
632
|
-
next.fallbackFamilies = families.slice(1);
|
|
633
|
-
}
|
|
634
|
-
if (styles["font-size"] !== void 0) next.size = fontSize(styles["font-size"]);
|
|
635
|
-
if (styles["font-weight"] !== void 0) next.weight = fontWeight(styles["font-weight"]);
|
|
636
|
-
const typography = canvasTypographySchema.safeParse({
|
|
637
|
-
...next,
|
|
638
|
-
...styles["font-style"] !== void 0 && { style: styles["font-style"] }
|
|
639
|
-
});
|
|
640
|
-
if (!typography.success) throw new CliError("BAD_REQUEST", "The font edit cannot be represented by editable typography.", "Use a font family list, numeric or pixel size, weight from 1 to 1000, and normal, italic or oblique style.");
|
|
641
|
-
return {
|
|
642
|
-
op: "setTypography",
|
|
658
|
+
const clear = canvasCssTypographyOwners(new Set(Object.keys(styles))).filter((property) => node.typography?.[property] !== void 0);
|
|
659
|
+
return clear.length === 0 ? null : {
|
|
660
|
+
op: "patchTypography",
|
|
643
661
|
nodeId: node.id,
|
|
644
|
-
typography:
|
|
662
|
+
typography: { clear }
|
|
645
663
|
};
|
|
646
664
|
};
|
|
647
665
|
|
|
648
666
|
//#endregion
|
|
649
667
|
//#region src/application/canvas-style-operations.use-case.ts
|
|
650
668
|
const ADDITIONAL_STYLE_ID_LENGTH = 200;
|
|
669
|
+
const ADDITIONAL_STYLE_SUFFIX_LENGTH = 10;
|
|
651
670
|
const camelToKebab = (property) => property.startsWith("--") ? property : property.replace(/^Webkit/u, "-webkit-").replace(/^Moz/u, "-moz-").replaceAll(/([a-z\d])([A-Z])/gu, "$1-$2").toLowerCase();
|
|
652
671
|
const additionalOperation = (node, styles) => {
|
|
653
|
-
const held = new Map((node.additionalStyles?.declarations ?? []).map((declaration) => [declaration.
|
|
672
|
+
const held = new Map((node.additionalStyles?.declarations ?? []).map((declaration) => [declaration.id, declaration]));
|
|
654
673
|
for (const [property, value] of Object.entries(styles)) {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
674
|
+
const replaced = Array.from(held, ([, item]) => item).filter((item) => item.property.toLowerCase() === property);
|
|
675
|
+
for (const item of replaced) held.delete(item.id);
|
|
676
|
+
if (value === null || canvasNodeStylePatchSchema.safeParse({ [property]: value }).success) continue;
|
|
677
|
+
const base = replaced[0]?.id ?? `css-${property}`.slice(0, ADDITIONAL_STYLE_ID_LENGTH - ADDITIONAL_STYLE_SUFFIX_LENGTH);
|
|
678
|
+
let id = base;
|
|
679
|
+
for (let suffix = 1; held.has(id); suffix += 1) id = `${base}-${String(suffix)}`;
|
|
659
680
|
const result = canvasAdditionalStyleSchema.safeParse({
|
|
660
|
-
id
|
|
681
|
+
id,
|
|
661
682
|
property,
|
|
662
683
|
value: String(value),
|
|
663
684
|
enabled: true
|
|
664
685
|
});
|
|
665
686
|
if (!result.success) throw new CliError("BAD_REQUEST", `Style ${property} is not safe CSS.`, "Use a valid CSS property without imports, expressions, or executable URLs.");
|
|
666
|
-
held.set(
|
|
687
|
+
held.set(id, result.data);
|
|
667
688
|
}
|
|
668
689
|
const declarations = [];
|
|
669
690
|
for (const declaration of held.values()) {
|
|
670
691
|
if (declarations.length === 128) throw new CliError("BAD_REQUEST", "Too many additional CSS declarations.", "Remove unused declarations before adding more; no styles were changed.");
|
|
671
692
|
declarations.push(declaration);
|
|
672
693
|
}
|
|
673
|
-
|
|
674
|
-
|
|
694
|
+
const requested = declarations.length === 0 && node.additionalStyles === void 0 ? void 0 : { declarations };
|
|
695
|
+
const patch = canvasAdditionalStylePatchBetween(node.additionalStyles, requested);
|
|
696
|
+
return patch === null ? null : {
|
|
697
|
+
op: "patchAdditionalStyles",
|
|
675
698
|
nodeId: node.id,
|
|
676
|
-
additionalStyles:
|
|
699
|
+
additionalStyles: patch
|
|
677
700
|
};
|
|
678
701
|
};
|
|
679
702
|
const layoutOperation = (document, node, next, styles) => {
|
|
@@ -709,7 +732,7 @@ const operationsForNode = (document, node, source) => {
|
|
|
709
732
|
const next = {
|
|
710
733
|
...node,
|
|
711
734
|
styles: { ...node.styles },
|
|
712
|
-
...additional !== null &&
|
|
735
|
+
...additional !== null && { additionalStyles: applyCanvasAdditionalStylePatch(node.additionalStyles, additional.additionalStyles) ?? void 0 }
|
|
713
736
|
};
|
|
714
737
|
for (const [property, value] of Object.entries(stylePatch)) if (value === null) Reflect.deleteProperty(next.styles, property);
|
|
715
738
|
else next.styles[property] = value;
|
|
@@ -761,22 +784,17 @@ const canvasStyleOperations = (document, updates) => {
|
|
|
761
784
|
|
|
762
785
|
//#endregion
|
|
763
786
|
//#region src/application/canvas-edit-operations.use-case.ts
|
|
764
|
-
const TEXT_LEADING = 1.35;
|
|
765
787
|
const projectStyles = (node, operation) => {
|
|
766
788
|
const styles = { ...node.styles };
|
|
767
789
|
for (const [name, value] of Object.entries(operation.styles)) if (value === null || value === void 0) Reflect.deleteProperty(styles, name);
|
|
768
790
|
else styles[name] = value;
|
|
769
791
|
const cleared = operation.clear ?? [];
|
|
770
792
|
for (const name of cleared) Reflect.deleteProperty(styles, name);
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (typeof size === "number") styles["line-height"] = `${String(Math.round(size * TEXT_LEADING))}px`;
|
|
774
|
-
else if (size === null) Reflect.deleteProperty(styles, "line-height");
|
|
775
|
-
}
|
|
776
|
-
return {
|
|
793
|
+
const typography = applyCanvasTypographyPatch(node.typography, { clear: [...canvasCssTypographyOwners(/* @__PURE__ */ new Set([...Object.keys(operation.styles), ...cleared]))] });
|
|
794
|
+
return projectPresentation({
|
|
777
795
|
...node,
|
|
778
796
|
styles
|
|
779
|
-
};
|
|
797
|
+
}, "typography", typography ?? "default");
|
|
780
798
|
};
|
|
781
799
|
const PLANNED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
782
800
|
"insertNode",
|
|
@@ -785,15 +803,17 @@ const PLANNED_OPERATIONS = /* @__PURE__ */ new Set([
|
|
|
785
803
|
"setStyles",
|
|
786
804
|
"setAppearance",
|
|
787
805
|
"setTypography",
|
|
806
|
+
"patchTypography",
|
|
788
807
|
"setLayout",
|
|
789
808
|
"setAdditionalStyles",
|
|
809
|
+
"patchAdditionalStyles",
|
|
790
810
|
"setParentage"
|
|
791
811
|
]);
|
|
792
812
|
const isPlannedOperation = (operation) => PLANNED_OPERATIONS.has(operation.op);
|
|
793
|
-
const
|
|
813
|
+
const projectPresentation = (node, field, value) => {
|
|
794
814
|
const next = { ...node };
|
|
795
|
-
if (
|
|
796
|
-
else next
|
|
815
|
+
if (value === "default") Reflect.deleteProperty(next, field);
|
|
816
|
+
else Reflect.set(next, field, value);
|
|
797
817
|
return next;
|
|
798
818
|
};
|
|
799
819
|
const projectNode = (node, operation) => {
|
|
@@ -824,19 +844,14 @@ const projectNode = (node, operation) => {
|
|
|
824
844
|
if (Object.keys(appearance).length === 0) Reflect.deleteProperty(next, "appearance");
|
|
825
845
|
return next;
|
|
826
846
|
}
|
|
827
|
-
case "
|
|
828
|
-
case "
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
return
|
|
833
|
-
}
|
|
834
|
-
case "setAdditionalStyles": {
|
|
835
|
-
const next = { ...node };
|
|
836
|
-
if (operation.additionalStyles === "default") Reflect.deleteProperty(next, "additionalStyles");
|
|
837
|
-
else next.additionalStyles = operation.additionalStyles;
|
|
838
|
-
return next;
|
|
847
|
+
case "patchTypography": return projectPresentation(node, "typography", applyCanvasTypographyPatch(node.typography, operation.typography) ?? "default");
|
|
848
|
+
case "setTypography": return projectPresentation(node, "typography", operation.typography);
|
|
849
|
+
case "setLayout": return projectPresentation(node, "layout", operation.layout);
|
|
850
|
+
case "patchAdditionalStyles": {
|
|
851
|
+
const additionalStyles = applyCanvasAdditionalStylePatch(node.additionalStyles, operation.additionalStyles);
|
|
852
|
+
return projectPresentation(node, "additionalStyles", additionalStyles ?? "default");
|
|
839
853
|
}
|
|
854
|
+
case "setAdditionalStyles": return projectPresentation(node, "additionalStyles", operation.additionalStyles);
|
|
840
855
|
}
|
|
841
856
|
};
|
|
842
857
|
const projectOperation = (scene, operation) => {
|
|
@@ -988,7 +1003,7 @@ const createEditCanvasComposite = (remote) => ({ execute: async (input) => {
|
|
|
988
1003
|
const parsed = applyCanvasOperationsInputSchema.safeParse({
|
|
989
1004
|
canvasId: input.canvasId,
|
|
990
1005
|
mutationId: input.mutationId,
|
|
991
|
-
documentFormatVersion:
|
|
1006
|
+
documentFormatVersion: 5,
|
|
992
1007
|
baseVersion: input.baseVersion,
|
|
993
1008
|
operations: plan.operations
|
|
994
1009
|
});
|
package/dist/remote-mcp-main.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { X as MCP_AUTH_SCOPE, Y as getMeOutputSchema, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-
|
|
3
|
-
import { i as readRemoteMcpEnvironment, n as createHttpRemoteAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-
|
|
4
|
-
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-
|
|
5
|
-
import { t as createMcpServerAdapter } from "./mcp-server.adapter-
|
|
2
|
+
import { X as MCP_AUTH_SCOPE, Y as getMeOutputSchema, d as createCapabilityCatalogAdapter } from "./cli-output-identity.lib-Du4_Ahcj.mjs";
|
|
3
|
+
import { i as readRemoteMcpEnvironment, n as createHttpRemoteAdapter, t as createMutationKeyAdapter } from "./mutation-key.adapter-B6dNFpWt.mjs";
|
|
4
|
+
import { t as createMcpInvocationAdapter } from "./mcp-invocation.adapter-CcSWERtl.mjs";
|
|
5
|
+
import { t as createMcpServerAdapter } from "./mcp-server.adapter-DrbFMc01.mjs";
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import path from "node:path";
|
|
@@ -145,7 +145,7 @@ const server = await createRemoteMcpHttpAdapter({
|
|
|
145
145
|
configDirectory: path.join(os.tmpdir(), "enhance-remote-mcp"),
|
|
146
146
|
allowedHosts: config.MCP_ALLOWED_HOSTS.split(",").map((value) => value.trim()),
|
|
147
147
|
allowedOrigins: config.MCP_ALLOWED_ORIGINS.split(",").map((value) => value.trim()),
|
|
148
|
-
version: "0.1.
|
|
148
|
+
version: "0.1.20",
|
|
149
149
|
onerror: (error) => process.stderr.write(`${error.message}\n`)
|
|
150
150
|
});
|
|
151
151
|
await server.listen(config.PORT, config.MCP_HOST);
|