@creator-notes/cnotes 0.125.5 → 0.125.6
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/commands/canvas.js
CHANGED
|
@@ -17,6 +17,7 @@ import { findOverlaps, findFrameSpills, layoutItemsFrom, parseSize, resolveAncho
|
|
|
17
17
|
import { canvasUrl, canvasLinkForRef } from "../lib/urls.js";
|
|
18
18
|
import { CANVAS_GOAL_DESCRIPTION } from "../lib/canvas-goal.js";
|
|
19
19
|
import { canvasActionPath, commentsListPath, parseCommentStatus, } from "../lib/canvas-paths.js";
|
|
20
|
+
import { buildSectionUpdateRequest, CLI_SECTION_WORDING } from "../lib/section-update.js";
|
|
20
21
|
import { registerCanvasMilestoneCommands } from "./canvas-milestone.js";
|
|
21
22
|
import { DISPLAY_ID_CORE } from "../lib/display-id.js";
|
|
22
23
|
import { resolveNoteBatchItems } from "../lib/note-batch.js";
|
|
@@ -2425,8 +2426,8 @@ Examples:
|
|
|
2425
2426
|
.argument("<canvasId>", "Canvas ID")
|
|
2426
2427
|
.requiredOption("--section <id>", "Section to update — SECTION-<n> display ID or a raw node ID")
|
|
2427
2428
|
.option("--name <name>", "New frame title (title case)")
|
|
2428
|
-
.option("--x <n>", "
|
|
2429
|
-
.option("--y <n>", "
|
|
2429
|
+
.option("--x <n>", "Move the frame and everything inside it: new X (top-left). Send with --y, on their own")
|
|
2430
|
+
.option("--y <n>", "Move the frame and everything inside it: new Y (top-left). Send with --x, on their own")
|
|
2430
2431
|
.option("--width <n>", "New frame width in px")
|
|
2431
2432
|
.option("--height <n>", "New frame height in px")
|
|
2432
2433
|
.option("--color <hex>", "New frame tint hex")
|
|
@@ -2445,6 +2446,9 @@ Examples:
|
|
|
2445
2446
|
|
|
2446
2447
|
# Rename without touching the id or anything inside it
|
|
2447
2448
|
$ cnotes canvas update-section CANVAS-250 --section SECTION-51 --name "Open Questions"
|
|
2449
|
+
|
|
2450
|
+
# Move the frame and the cards inside it (both axes, nothing else in the call)
|
|
2451
|
+
$ cnotes canvas update-section CANVAS-250 --section SECTION-51 --x 400 --y 2600
|
|
2448
2452
|
`)
|
|
2449
2453
|
.action(async (canvasId, opts) => {
|
|
2450
2454
|
const cfg = resolveConfig(program.opts());
|
|
@@ -2460,33 +2464,29 @@ Examples:
|
|
|
2460
2464
|
}
|
|
2461
2465
|
return n;
|
|
2462
2466
|
};
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
body.height = numeric("height", opts.height);
|
|
2477
|
-
// '' is the server's "clear the tint" sentinel.
|
|
2478
|
-
if (opts.clearColor)
|
|
2479
|
-
body.colorHex = "";
|
|
2480
|
-
else if (typeof opts.color === "string")
|
|
2481
|
-
body.colorHex = opts.color;
|
|
2482
|
-
if (opts.ripple === false)
|
|
2483
|
-
body.ripple = false;
|
|
2467
|
+
// x/y go to the move action, which carries the cards inside the
|
|
2468
|
+
// frame; every other field is an in-place update (lib/section-update.ts).
|
|
2469
|
+
const request = buildSectionUpdateRequest({
|
|
2470
|
+
sectionId: opts.section,
|
|
2471
|
+
name: typeof opts.name === "string" ? opts.name : undefined,
|
|
2472
|
+
x: opts.x !== undefined ? numeric("x", opts.x) : undefined,
|
|
2473
|
+
y: opts.y !== undefined ? numeric("y", opts.y) : undefined,
|
|
2474
|
+
width: opts.width !== undefined ? numeric("width", opts.width) : undefined,
|
|
2475
|
+
height: opts.height !== undefined ? numeric("height", opts.height) : undefined,
|
|
2476
|
+
// '' is the server's "clear the tint" sentinel.
|
|
2477
|
+
colorHex: opts.clearColor ? "" : typeof opts.color === "string" ? opts.color : undefined,
|
|
2478
|
+
ripple: opts.ripple === false ? false : undefined,
|
|
2479
|
+
}, CLI_SECTION_WORDING);
|
|
2484
2480
|
// workspaceId is what lets the server resolve a CANVAS-<n> handle (the
|
|
2485
2481
|
// form every example here uses) rather than demanding a raw Convex id.
|
|
2486
|
-
const data = await api.post(canvasActionPath(canvasId, cfg.workspaceId), body);
|
|
2482
|
+
const data = await api.post(canvasActionPath(canvasId, cfg.workspaceId), request.body);
|
|
2487
2483
|
if (cfg.json) {
|
|
2488
2484
|
outputJson(data);
|
|
2489
2485
|
}
|
|
2486
|
+
else if (request.kind === "move") {
|
|
2487
|
+
const moved = typeof data.movedNodeCount === "number" ? data.movedNodeCount : 0;
|
|
2488
|
+
console.log(`Moved section ${opts.section} with ${moved} item${moved === 1 ? "" : "s"} inside it`);
|
|
2489
|
+
}
|
|
2490
2490
|
else {
|
|
2491
2491
|
console.log(`Updated section ${opts.section}`);
|
|
2492
2492
|
printRippleSummary(data.ripple);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
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
|
+
* A move and every other edit are different server actions. Only
|
|
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.
|
|
10
|
+
*/
|
|
11
|
+
import { ValidationError } from "./errors.js";
|
|
12
|
+
export const CLI_SECTION_WORDING = {
|
|
13
|
+
x: "--x",
|
|
14
|
+
y: "--y",
|
|
15
|
+
size: "--width/--height",
|
|
16
|
+
label: "--name/--color",
|
|
17
|
+
};
|
|
18
|
+
export const MCP_SECTION_WORDING = {
|
|
19
|
+
x: "x",
|
|
20
|
+
y: "y",
|
|
21
|
+
size: "width/height",
|
|
22
|
+
label: "name/colorHex",
|
|
23
|
+
};
|
|
24
|
+
export function buildSectionUpdateRequest(input, wording) {
|
|
25
|
+
const { sectionId, name, x, y, width, height, colorHex, ripple } = input;
|
|
26
|
+
const isMove = x !== undefined || y !== undefined;
|
|
27
|
+
const isResize = width !== undefined || height !== undefined;
|
|
28
|
+
const isRelabel = name !== undefined || colorHex !== undefined;
|
|
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 };
|
|
58
|
+
}
|
package/dist/mcp-server.js
CHANGED
|
@@ -25,6 +25,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
25
25
|
import { z } from "zod";
|
|
26
26
|
import { ApiClient } from "./lib/api-client.js";
|
|
27
27
|
import { ApiError, CliError, NotFoundError } from "./lib/errors.js";
|
|
28
|
+
import { buildSectionUpdateRequest, MCP_SECTION_WORDING } from "./lib/section-update.js";
|
|
28
29
|
import { CANVAS_GOAL_DESCRIPTION } from "./lib/canvas-goal.js";
|
|
29
30
|
import { parseStart as parseFocusStart } from "./lib/focus-time.js";
|
|
30
31
|
import { resolveNoteId } from "./lib/resolve-note.js";
|
|
@@ -117,12 +118,15 @@ async function withErrorHandling(fn) {
|
|
|
117
118
|
* one call with this sentence as the timeline headline, or joins the run that
|
|
118
119
|
* is already open (lib/mcp-run.ts).
|
|
119
120
|
*/
|
|
121
|
+
// The server refuses a run headline over 80 characters (guardRunHeadline in
|
|
122
|
+
// convex/lib/titleGuard.ts), so the schema stops a longer one before the call.
|
|
123
|
+
const INTENT_MAX_CHARS = 80;
|
|
120
124
|
const intentArg = z
|
|
121
125
|
.string()
|
|
122
126
|
.trim()
|
|
123
127
|
.min(1)
|
|
124
|
-
.max(
|
|
125
|
-
.describe("One short past-tense sentence (
|
|
128
|
+
.max(INTENT_MAX_CHARS)
|
|
129
|
+
.describe("One short past-tense sentence (at most 80 characters) saying what this change does: the timeline headline. Name things by title, not raw ids. Example: 'Added the pricing risks to the Q1 roadmap'. Opens an agent run for this one call, or joins the run already open.");
|
|
126
130
|
const runContext = { api, serverUrl: CNOTES_SERVER, workspaceId };
|
|
127
131
|
/** Run a write tool's REST calls inside an agent run; pass canvasId when it removes canvas content. */
|
|
128
132
|
const inRun = (intent, fn, canvasId) => inToolRun(runContext, intent, fn, canvasId ? { canvasId } : {});
|
|
@@ -903,8 +907,8 @@ server.tool("cnotes_canvas_update_section", "Resize, rename, move, recolor or AR
|
|
|
903
907
|
.string()
|
|
904
908
|
.describe("Section to update — SECTION-<n> display ID or a raw node ID"),
|
|
905
909
|
name: z.string().optional().describe("New frame title: a plain noun phrase of at most six words, like 'Sources', never a teaser like 'What it rests on'"),
|
|
906
|
-
x: z.number().optional().describe("
|
|
907
|
-
y: z.number().optional().describe("
|
|
910
|
+
x: z.number().optional().describe("Move the frame and everything inside it: new X (top-left). Send x and y together, on their own"),
|
|
911
|
+
y: z.number().optional().describe("Move the frame and everything inside it: new Y (top-left). Send x and y together, on their own"),
|
|
908
912
|
width: z.number().optional().describe("New frame width in px"),
|
|
909
913
|
height: z.number().optional().describe("New frame height in px"),
|
|
910
914
|
colorHex: z
|
|
@@ -927,24 +931,12 @@ server.tool("cnotes_canvas_update_section", "Resize, rename, move, recolor or AR
|
|
|
927
931
|
...(arrange ? {} : { stop: true }),
|
|
928
932
|
}));
|
|
929
933
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
if (x !== undefined)
|
|
937
|
-
body.positionX = x;
|
|
938
|
-
if (y !== undefined)
|
|
939
|
-
body.positionY = y;
|
|
940
|
-
if (width !== undefined)
|
|
941
|
-
body.width = width;
|
|
942
|
-
if (height !== undefined)
|
|
943
|
-
body.height = height;
|
|
944
|
-
if (colorHex !== undefined)
|
|
945
|
-
body.colorHex = colorHex;
|
|
946
|
-
// workspaceId lets the server resolve a CANVAS-<n> handle, not just a raw id.
|
|
947
|
-
return inRun(intent, () => api.post(`/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`, body));
|
|
934
|
+
// x/y go to the move action, which carries the cards inside the frame;
|
|
935
|
+
// every other field is an in-place update (lib/section-update.ts).
|
|
936
|
+
const request = buildSectionUpdateRequest({ sectionId, name, x, y, width, height, colorHex }, MCP_SECTION_WORDING);
|
|
937
|
+
// A move rewrites where existing cards sit, so its run is bracketed
|
|
938
|
+
// with a canvas checkpoint.
|
|
939
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), request.body), request.kind === "move" ? canvasId : undefined);
|
|
948
940
|
}));
|
|
949
941
|
server.tool("cnotes_canvas_move_node", "LOW-LEVEL: move one node to raw x/y, with no collision check. To tidy or reorganize a canvas use cnotes_canvas_arrange; to see every item's box and any overlaps first use cnotes_canvas_status (it also suggests a free spot). The response carries layoutWarning when the node lands on another item.", {
|
|
950
942
|
canvasId: z.string().describe("Canvas ID"),
|
package/package.json
CHANGED
|
@@ -164,7 +164,9 @@ cnotes canvas add-section <canvasId> --name "<title>" [--width <n>] [--height <n
|
|
|
164
164
|
# re-adding a section mints a NEW id (SECTION-51 becomes SECTION-57) and silently
|
|
165
165
|
# breaks every [[SECTION-51]] mention pointing at the old one.
|
|
166
166
|
cnotes canvas update-section <canvasId> --section SECTION-51 --height 1800
|
|
167
|
-
cnotes canvas update-section <canvasId> --section SECTION-51 --name "Open Questions" [--
|
|
167
|
+
cnotes canvas update-section <canvasId> --section SECTION-51 --name "Open Questions" [--width <n>] [--color "<hex>"] [--clear-color]
|
|
168
|
+
# A move is its own call: both axes, nothing else. It carries every card inside the frame.
|
|
169
|
+
cnotes canvas update-section <canvasId> --section SECTION-51 --x <n> --y <n>
|
|
168
170
|
# Edit a Text card's words IN PLACE (same node id, edges and mentions survive). This is the
|
|
169
171
|
# only way to change a card's copy; never delete and re-add it.
|
|
170
172
|
# Card ids: the `id` on kind:richtext elements in `cnotes canvas read <canvasId> --json`.
|