@creator-notes/cnotes 0.125.6 → 0.125.7
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/.claude-plugin/plugin.json +1 -1
- package/dist/commands/canvas.js +6 -11
- package/dist/commands/notes.js +3 -9
- package/dist/lib/mcp-spec.js +636 -0
- package/dist/lib/section-update.js +9 -46
- package/dist/mcp-server.js +87 -316
- package/package.json +1 -1
|
@@ -1,58 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What `canvas update-section` and the MCP tool `cnotes_canvas_update_section`
|
|
3
|
-
* send for a frame edit, decided in one place for both.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `moveSectionWithContents` carries the cards inside the frame; x/y on
|
|
7
|
-
* `updateSectionNode` relocate the empty rectangle and leave its cards where
|
|
8
|
-
* they were (the server keeps that meaning for the browser's resize handles).
|
|
9
|
-
* So x/y always go to the move action, alone and as a pair.
|
|
3
|
+
* send for a frame edit, decided in one place for both. The rule itself lives
|
|
4
|
+
* in lib/mcp-spec.ts (planSectionUpdate), where the remote connector in the app
|
|
5
|
+
* reads it too; this wrapper turns a refusal into the CLI's ValidationError.
|
|
10
6
|
*/
|
|
11
7
|
import { ValidationError } from "./errors.js";
|
|
8
|
+
import { MCP_SECTION_WORDING, planSectionUpdate, } from "./mcp-spec.js";
|
|
9
|
+
export { MCP_SECTION_WORDING };
|
|
12
10
|
export const CLI_SECTION_WORDING = {
|
|
13
11
|
x: "--x",
|
|
14
12
|
y: "--y",
|
|
15
13
|
size: "--width/--height",
|
|
16
14
|
label: "--name/--color",
|
|
17
15
|
};
|
|
18
|
-
export const MCP_SECTION_WORDING = {
|
|
19
|
-
x: "x",
|
|
20
|
-
y: "y",
|
|
21
|
-
size: "width/height",
|
|
22
|
-
label: "name/colorHex",
|
|
23
|
-
};
|
|
24
16
|
export function buildSectionUpdateRequest(input, wording) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (isMove && (isResize || isRelabel)) {
|
|
30
|
-
const rest = [isResize ? wording.size : null, isRelabel ? wording.label : null]
|
|
31
|
-
.filter(Boolean)
|
|
32
|
-
.join(" and ");
|
|
33
|
-
throw new ValidationError(`A move is its own call: send ${wording.x} and ${wording.y} on their own, then ${rest} in a second call.`, "Only the move takes the cards inside the frame with it.");
|
|
34
|
-
}
|
|
35
|
-
if (x !== undefined && y !== undefined) {
|
|
36
|
-
return {
|
|
37
|
-
kind: "move",
|
|
38
|
-
body: { action: "moveSectionWithContents", nodeId: sectionId, positionX: x, positionY: y },
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (isMove) {
|
|
42
|
-
const got = x === undefined ? wording.y : wording.x;
|
|
43
|
-
const missing = x === undefined ? wording.x : wording.y;
|
|
44
|
-
throw new ValidationError(`A move needs both ${wording.x} and ${wording.y}: got ${got} only.`, `Read the frame's current position from the canvas status and pass it as ${missing} to keep that axis unchanged.`);
|
|
45
|
-
}
|
|
46
|
-
const body = { action: "updateSectionNode", nodeId: sectionId };
|
|
47
|
-
if (name !== undefined)
|
|
48
|
-
body.name = name;
|
|
49
|
-
if (width !== undefined)
|
|
50
|
-
body.width = width;
|
|
51
|
-
if (height !== undefined)
|
|
52
|
-
body.height = height;
|
|
53
|
-
if (colorHex !== undefined)
|
|
54
|
-
body.colorHex = colorHex;
|
|
55
|
-
if (ripple === false)
|
|
56
|
-
body.ripple = false;
|
|
57
|
-
return { kind: "update", body };
|
|
17
|
+
const plan = planSectionUpdate(input, wording);
|
|
18
|
+
if (!plan.ok)
|
|
19
|
+
throw new ValidationError(plan.message, plan.hint);
|
|
20
|
+
return plan.value;
|
|
58
21
|
}
|