@creator-notes/cnotes 0.125.4 → 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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creator-notes-cli",
3
- "version": "0.125.4",
3
+ "version": "0.125.6",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -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>", "New X position (top-left)")
2429
- .option("--y <n>", "New Y position (top-left)")
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
- const body = {
2464
- action: "updateSectionNode",
2465
- nodeId: opts.section,
2466
- };
2467
- if (typeof opts.name === "string")
2468
- body.name = opts.name;
2469
- if (opts.x !== undefined)
2470
- body.positionX = numeric("x", opts.x);
2471
- if (opts.y !== undefined)
2472
- body.positionY = numeric("y", opts.y);
2473
- if (opts.width !== undefined)
2474
- body.width = numeric("width", opts.width);
2475
- if (opts.height !== undefined)
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
+ }
@@ -30,6 +30,7 @@ export const IDLE_STATUS = {
30
30
  persistent: false,
31
31
  counts: { notes: 0, canvases: 0, placements: 0, answers: 0, bytes: 0 },
32
32
  copied: 0,
33
+ step: null,
33
34
  syncedAt: null,
34
35
  lastPassMs: null,
35
36
  firstPassMs: null,
@@ -48,11 +49,13 @@ const FETCH_CHUNK = 200;
48
49
  /**
49
50
  * Canvases per `placements` call. A canvas can hold thousands of cards, list
50
51
  * nodes and list items, and one Convex query reads at most 16,384 documents,
51
- * so a small batch keeps a workspace of large canvases syncable.
52
+ * so a small batch keeps a workspace of large canvases syncable. No bigger
53
+ * than `MAX_CANVASES_PER_PLACEMENT_CALL` in convex/localDb.ts: the server
54
+ * answers only that many, and boards past it are skipped for the whole pass.
52
55
  */
53
- const PLACEMENT_CHUNK = 5;
56
+ const PLACEMENT_CHUNK = 3;
54
57
  const ANSWER_PAGE = 500;
55
- /** Parallel note fetches during a reconcile. */
58
+ /** Parallel reads from the server while copying notes and board layouts. */
56
59
  const FETCH_PARALLEL = 4;
57
60
  const now = () => (typeof performance !== "undefined" ? performance.now() : Date.now());
58
61
  const chunks = (items, size) => {
@@ -149,18 +152,20 @@ export class WorkspaceSync {
149
152
  try {
150
153
  if (!this.opened)
151
154
  await this.open(head);
152
- this.emit({ phase: "syncing", copied: 0 });
155
+ this.emit({ phase: "syncing", copied: 0, step: null });
153
156
  const full = !this.reconciled;
154
157
  const { canvasesToRefresh, dimensionsToRefresh } = await this.call("applyHead", head);
155
158
  const changedTypes = full ? await this.reconcile() : await this.pullChanged(head);
156
159
  this.reconciled = true;
157
160
  await this.pullPlacements(canvasesToRefresh);
161
+ this.emit({ step: { name: "answers", done: 0, total: null } });
158
162
  await this.pullAnswers(head, full ? null : changedTypes, dimensionsToRefresh);
159
163
  await this.call("setNewest", this.newest);
160
164
  const counts = await this.call("counts", null);
161
165
  const ms = now() - start;
162
166
  this.emit({
163
167
  phase: "ready",
168
+ step: null,
164
169
  counts,
165
170
  syncedAt: Date.now(),
166
171
  lastPassMs: ms,
@@ -193,6 +198,7 @@ export class WorkspaceSync {
193
198
  for (;;) {
194
199
  const page = await this.source.noteIds(cursor, ID_PAGE);
195
200
  ids.push(...page.page);
201
+ this.emit({ step: { name: "listing", done: ids.length, total: null } });
196
202
  if (page.isDone)
197
203
  break;
198
204
  cursor = page.continueCursor;
@@ -202,12 +208,16 @@ export class WorkspaceSync {
202
208
  const { toFetch } = await this.call("reconcile", ids);
203
209
  await this.call("markReconciled", Date.now());
204
210
  const types = new Set();
211
+ let done = 0;
212
+ this.emit({ step: { name: "notes", done, total: toFetch.length } });
205
213
  const batches = chunks(toFetch, FETCH_CHUNK);
206
214
  for (const group of chunks(batches, FETCH_PARALLEL)) {
207
215
  const results = await Promise.all(group.map((batch) => this.source.notesByIds(batch)));
208
216
  for (const rows of results) {
209
217
  this.track(rows, types);
210
218
  await this.call("applyNotes", rows);
219
+ done += rows.length;
220
+ this.emit({ step: { name: "notes", done, total: toFetch.length } });
211
221
  }
212
222
  }
213
223
  return types;
@@ -235,9 +245,15 @@ export class WorkspaceSync {
235
245
  return types;
236
246
  }
237
247
  async pullPlacements(canvasIds) {
238
- for (const batch of chunks(canvasIds, PLACEMENT_CHUNK)) {
239
- const rows = await this.source.placements(batch);
240
- await this.call("applyPlacements", rows);
248
+ let done = 0;
249
+ this.emit({ step: { name: "boards", done, total: canvasIds.length } });
250
+ for (const group of chunks(chunks(canvasIds, PLACEMENT_CHUNK), FETCH_PARALLEL)) {
251
+ const results = await Promise.all(group.map((batch) => this.source.placements(batch)));
252
+ for (const rows of results) {
253
+ await this.call("applyPlacements", rows);
254
+ done += rows.length;
255
+ this.emit({ step: { name: "boards", done, total: canvasIds.length } });
256
+ }
241
257
  }
242
258
  }
243
259
  /**
@@ -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(200)
125
- .describe("One short past-tense sentence (under 200 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.");
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("New X position (top-left)"),
907
- y: z.number().optional().describe("New Y position (top-left)"),
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
- const body = {
931
- action: "updateSectionNode",
932
- nodeId: sectionId,
933
- };
934
- if (name !== undefined)
935
- body.name = name;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.125.4",
3
+ "version": "0.125.6",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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" [--x <n>] [--y <n>] [--width <n>] [--color "<hex>"] [--clear-color]
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`.