@creator-notes/cnotes 0.125.6 → 0.126.0
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/README.md +1 -1
- package/dist/commands/brief.js +6 -3
- package/dist/commands/canvas.js +29 -15
- package/dist/commands/notes.js +3 -9
- package/dist/commands/operations.js +14 -3
- package/dist/lib/board-checks.js +149 -0
- package/dist/lib/mcp-spec.js +636 -0
- package/dist/lib/section-update.js +9 -46
- package/dist/lib/session-brief.js +12 -0
- package/dist/mcp-server.js +96 -320
- package/package.json +1 -1
- package/skills/cnotes/SKILL.md +7 -5
- package/skills/cnotes/references/canvas-elements.md +1 -1
- package/skills/cnotes/references/canvas-layout.md +24 -0
- package/skills/cnotes/references/canvas.md +8 -1
- package/skills/cnotes/references/notes.md +11 -0
- package/skills/cnotes/references/operations.md +14 -0
- package/skills/cnotes/references/output.md +1 -0
- package/skills/cnotes/references/situations.md +108 -0
package/dist/mcp-server.js
CHANGED
|
@@ -25,11 +25,12 @@ 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 {
|
|
28
|
+
import { arrowToMarkers, buildMcpSpec, notesExpandQuery, notesUpdateBody, orderByDisplayId, planSectionTool, refusalText, } from "./lib/mcp-spec.js";
|
|
29
29
|
import { CANVAS_GOAL_DESCRIPTION } from "./lib/canvas-goal.js";
|
|
30
30
|
import { parseStart as parseFocusStart } from "./lib/focus-time.js";
|
|
31
31
|
import { resolveNoteId } from "./lib/resolve-note.js";
|
|
32
32
|
import { findOverlaps, layoutItemsFrom, resolveAnchor, suggestFreeSpot } from "./lib/canvas-layout.js";
|
|
33
|
+
import { boardChecks } from "./lib/board-checks.js";
|
|
33
34
|
import { buildSchema } from "./lib/build-schema.js";
|
|
34
35
|
import { assertMcpLocalFileReadable, getMcpLocalFileRoots, } from "./lib/mcp-local-file.js";
|
|
35
36
|
import { attachRubricsToResults, loadRubricMap, rubricsForTypes, } from "./lib/rubrics.js";
|
|
@@ -37,6 +38,7 @@ import { lintNarratedVerbMentions, lintPlainTextDisplayIds, lintPlainTextDisplay
|
|
|
37
38
|
import { DECISION_CARD_RULE } from "./lib/decision-citation.js";
|
|
38
39
|
import { parseReviewRef } from "./lib/review-helpers.js";
|
|
39
40
|
import { runQuery } from "./commands/query.js";
|
|
41
|
+
import { canvasActionPath } from "./lib/canvas-paths.js";
|
|
40
42
|
import { inToolRun } from "./lib/mcp-run.js";
|
|
41
43
|
import { isLocalDbEnabled } from "./lib/auth-store.js";
|
|
42
44
|
import { explainTruncation, listNotes, SERVER_LIST_CAP } from "./lib/notes-list.js";
|
|
@@ -68,26 +70,16 @@ const workspaceId = CNOTES_WORKSPACE;
|
|
|
68
70
|
function ok(data) {
|
|
69
71
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
70
72
|
}
|
|
71
|
-
function arrowToMarkers(arrow) {
|
|
72
|
-
switch (arrow) {
|
|
73
|
-
case "end":
|
|
74
|
-
return { arrowStart: false, arrowEnd: true };
|
|
75
|
-
case "start":
|
|
76
|
-
return { arrowStart: true, arrowEnd: false };
|
|
77
|
-
case "both":
|
|
78
|
-
return { arrowStart: true, arrowEnd: true };
|
|
79
|
-
case "none":
|
|
80
|
-
return { arrowStart: false, arrowEnd: false };
|
|
81
|
-
default:
|
|
82
|
-
return {};
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
73
|
function err(message) {
|
|
86
74
|
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
87
75
|
}
|
|
88
|
-
|
|
76
|
+
/** `text: true` answers with the string as it is (a markdown read), not JSON-encoded. */
|
|
77
|
+
async function withErrorHandling(fn, opts = {}) {
|
|
89
78
|
try {
|
|
90
|
-
|
|
79
|
+
const data = await fn();
|
|
80
|
+
if (opts.text && typeof data === "string")
|
|
81
|
+
return { content: [{ type: "text", text: data }] };
|
|
82
|
+
return ok(data);
|
|
91
83
|
}
|
|
92
84
|
catch (e) {
|
|
93
85
|
// Keep the typed context the CLI errors carry — an MCP agent needs the
|
|
@@ -112,21 +104,25 @@ async function withErrorHandling(fn) {
|
|
|
112
104
|
return err(msg);
|
|
113
105
|
}
|
|
114
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The tools this server shares with the remote connector (lib/mcp/tools.ts in
|
|
109
|
+
* the app): name, description and arguments come from lib/mcp-spec.ts, so the
|
|
110
|
+
* two accept the same call. Register one with sharedTool(), never with a bare
|
|
111
|
+
* server.tool(); __tests__/lib/mcp-shared-tools-guardrail.test.ts in the app
|
|
112
|
+
* fails otherwise.
|
|
113
|
+
*/
|
|
114
|
+
const SPEC = buildMcpSpec(z, {
|
|
115
|
+
surface: "stdio",
|
|
116
|
+
decisionCardRule: DECISION_CARD_RULE,
|
|
117
|
+
canvasGoalDescription: CANVAS_GOAL_DESCRIPTION,
|
|
118
|
+
});
|
|
115
119
|
/**
|
|
116
120
|
* Every write tool takes the model's intent: the server refuses a write from a
|
|
117
121
|
* key outside an agent run (FEEDBACK-6KQR), so the tool opens a run for its
|
|
118
122
|
* one call with this sentence as the timeline headline, or joins the run that
|
|
119
|
-
* is already open (lib/mcp-run.ts).
|
|
123
|
+
* is already open (lib/mcp-run.ts). The same field as the shared tools take.
|
|
120
124
|
*/
|
|
121
|
-
|
|
122
|
-
// convex/lib/titleGuard.ts), so the schema stops a longer one before the call.
|
|
123
|
-
const INTENT_MAX_CHARS = 80;
|
|
124
|
-
const intentArg = z
|
|
125
|
-
.string()
|
|
126
|
-
.trim()
|
|
127
|
-
.min(1)
|
|
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.");
|
|
125
|
+
const intentArg = SPEC.intent;
|
|
130
126
|
const runContext = { api, serverUrl: CNOTES_SERVER, workspaceId };
|
|
131
127
|
/** Run a write tool's REST calls inside an agent run; pass canvasId when it removes canvas content. */
|
|
132
128
|
const inRun = (intent, fn, canvasId) => inToolRun(runContext, intent, fn, canvasId ? { canvasId } : {});
|
|
@@ -137,6 +133,19 @@ const server = new McpServer({
|
|
|
137
133
|
name: "cnotes-mcp",
|
|
138
134
|
version: "0.4.0",
|
|
139
135
|
});
|
|
136
|
+
/** Register a tool the remote connector also has, from the shared spec. */
|
|
137
|
+
function sharedTool(name, handler) {
|
|
138
|
+
const { description, shape } = SPEC.tools[name];
|
|
139
|
+
return server.tool(name, description, shape, handler);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Every single-canvas request carries ?workspaceId=: on the key path the route
|
|
143
|
+
* resolves a CANVAS-<n> handle only against that param (resolveCanvasIdRef in
|
|
144
|
+
* lib/api/canvas-auth.ts); the X-Cnotes-Workspace header does not stand in for
|
|
145
|
+
* it. Some actions also read the canvas for their overlap and ripple checks
|
|
146
|
+
* through it.
|
|
147
|
+
*/
|
|
148
|
+
const canvasPath = (canvasId) => canvasActionPath(canvasId, workspaceId);
|
|
140
149
|
// ---------------------------------------------------------------------------
|
|
141
150
|
// Resources
|
|
142
151
|
// ---------------------------------------------------------------------------
|
|
@@ -161,16 +170,7 @@ server.resource("types", "cnotes://types", async () => ({
|
|
|
161
170
|
// ---------------------------------------------------------------------------
|
|
162
171
|
// Notes tools
|
|
163
172
|
// ---------------------------------------------------------------------------
|
|
164
|
-
|
|
165
|
-
"With the local copy on, a list without content counts every note. A second text block says how many matched, which source answered, and whether the list may be short. " +
|
|
166
|
-
"To count or group notes, use cnotes_query.", {
|
|
167
|
-
search: z.string().optional().describe("Text in the title or display id (for words inside notes, use cnotes_search)"),
|
|
168
|
-
type: z.string().optional().describe("Filter by note type (e.g. Meeting, PRD); comma-separated for several"),
|
|
169
|
-
tags: z.string().optional().describe("Filter by tags (comma-separated)"),
|
|
170
|
-
pinned: z.boolean().optional().describe("Only show pinned notes"),
|
|
171
|
-
limit: z.number().optional().default(20).describe("Max results"),
|
|
172
|
-
includeContent: z.boolean().optional().default(false).describe("Include full note content in results"),
|
|
173
|
-
}, async ({ search, type, tags, pinned, limit, includeContent }) => {
|
|
173
|
+
sharedTool("cnotes_notes_list", async ({ search, type, tags, pinned, limit, includeContent }) => {
|
|
174
174
|
const max = limit ?? 20;
|
|
175
175
|
if (includeContent) {
|
|
176
176
|
return withErrorHandling(async () => {
|
|
@@ -241,44 +241,9 @@ async ({ text, types, canvases, tags, madeBy, by, groupBy, limit, sql, rebuild }
|
|
|
241
241
|
const { kind: _kind, ...rest } = answer;
|
|
242
242
|
return rest;
|
|
243
243
|
}));
|
|
244
|
-
|
|
245
|
-
ids: z
|
|
246
|
-
.array(z.string())
|
|
247
|
-
.min(1)
|
|
248
|
-
.describe("Display IDs (e.g. ['MEETING-12','PRD-3','IDEA-7']). Pass an array even for a single ID."),
|
|
249
|
-
expand: z
|
|
250
|
-
.boolean()
|
|
251
|
-
.optional()
|
|
252
|
-
.describe("Also return notes these ids link to. Response becomes { notes, linked, truncated, cap, omitted, notice }."),
|
|
253
|
-
depth: z
|
|
254
|
-
.number()
|
|
255
|
-
.int()
|
|
256
|
-
.min(1)
|
|
257
|
-
.max(4)
|
|
258
|
-
.optional()
|
|
259
|
-
.describe("With expand, how many hops to follow. Default 1, max 4."),
|
|
260
|
-
rel: z
|
|
261
|
-
.string()
|
|
262
|
-
.optional()
|
|
263
|
-
.describe("With expand, comma-separated relation slugs to follow (e.g. 'assumes,depends-on')."),
|
|
264
|
-
summary: z
|
|
265
|
-
.boolean()
|
|
266
|
-
.optional()
|
|
267
|
-
.describe("With expand, linked notes return title and the first real prose paragraph (skips leading headings, blanks, and chip-only lines). Requested notes stay whole."),
|
|
268
|
-
incoming: z
|
|
269
|
-
.boolean()
|
|
270
|
-
.optional()
|
|
271
|
-
.describe("With expand, also include notes that link to the targets."),
|
|
272
|
-
}, async ({ ids, expand, depth, rel, summary, incoming }) => withErrorHandling(async () => {
|
|
244
|
+
sharedTool("cnotes_notes_get", async ({ ids, expand, depth, rel, summary, incoming }) => withErrorHandling(async () => {
|
|
273
245
|
if (expand) {
|
|
274
|
-
return api.get("/api/notes/expand", {
|
|
275
|
-
workspaceId,
|
|
276
|
-
ids: ids.join(","),
|
|
277
|
-
depth: String(depth ?? 1),
|
|
278
|
-
rel,
|
|
279
|
-
summary: summary ? "true" : undefined,
|
|
280
|
-
incoming: incoming ? "true" : undefined,
|
|
281
|
-
});
|
|
246
|
+
return api.get("/api/notes/expand", notesExpandQuery({ ids, depth, rel, summary, incoming }, workspaceId));
|
|
282
247
|
}
|
|
283
248
|
const notesList = await api.get("/api/notes", {
|
|
284
249
|
workspaceId,
|
|
@@ -286,18 +251,11 @@ server.tool("cnotes_notes_get", "Get one or more notes by display ID (e.g. MEETI
|
|
|
286
251
|
excludeDrafts: "true",
|
|
287
252
|
format: "markdown",
|
|
288
253
|
});
|
|
289
|
-
const
|
|
290
|
-
const byDisplayId = new Map();
|
|
291
|
-
for (const n of found) {
|
|
292
|
-
if (typeof n.displayId === "string")
|
|
293
|
-
byDisplayId.set(n.displayId, n);
|
|
294
|
-
}
|
|
295
|
-
const missing = ids.filter((id) => !byDisplayId.has(id));
|
|
254
|
+
const { ordered, missing } = orderByDisplayId(ids, notesList);
|
|
296
255
|
if (missing.length > 0) {
|
|
297
256
|
throw new Error(`Notes not found: ${missing.join(", ")}`);
|
|
298
257
|
}
|
|
299
|
-
|
|
300
|
-
return ids.map((id) => byDisplayId.get(id));
|
|
258
|
+
return ordered;
|
|
301
259
|
}));
|
|
302
260
|
server.tool("cnotes_notes_delete", "Delete (archive) a note.", {
|
|
303
261
|
id: z.string().describe("Note display ID or Convex ID"),
|
|
@@ -328,56 +286,16 @@ server.tool("cnotes_notes_bulk_retype", "Retype multiple notes to a new type in
|
|
|
328
286
|
noteIds: ids,
|
|
329
287
|
targetType,
|
|
330
288
|
}))));
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
pin: z.boolean().optional().describe("Pin the note"),
|
|
336
|
-
unpin: z.boolean().optional().describe("Unpin the note"),
|
|
337
|
-
archive: z.boolean().optional().describe("Archive the note"),
|
|
338
|
-
unarchive: z.boolean().optional().describe("Unarchive the note"),
|
|
339
|
-
intent: intentArg,
|
|
340
|
-
}, async ({ id, type, tags, pin, unpin, archive, unarchive, intent }) => withErrorHandling(async () => {
|
|
341
|
-
const body = {};
|
|
342
|
-
if (type !== undefined)
|
|
343
|
-
body.type = type;
|
|
344
|
-
if (tags !== undefined) {
|
|
345
|
-
body.tags = tags === "" ? [] : tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
346
|
-
}
|
|
347
|
-
if (pin)
|
|
348
|
-
body.isPinned = true;
|
|
349
|
-
if (unpin)
|
|
350
|
-
body.isPinned = false;
|
|
351
|
-
if (archive)
|
|
352
|
-
body.isArchived = true;
|
|
353
|
-
if (unarchive)
|
|
354
|
-
body.isArchived = false;
|
|
355
|
-
if (Object.keys(body).length === 0) {
|
|
356
|
-
throw new Error("At least one of type, tags, pin, unpin, archive, or unarchive is required");
|
|
357
|
-
}
|
|
289
|
+
sharedTool("cnotes_notes_update", async ({ id, intent, ...args }) => withErrorHandling(async () => {
|
|
290
|
+
const body = notesUpdateBody(args);
|
|
291
|
+
if (!body.ok)
|
|
292
|
+
throw new CliError(body.message);
|
|
358
293
|
return inRun(intent, async () => {
|
|
359
294
|
const noteId = await resolveNoteId(api, workspaceId, id);
|
|
360
|
-
return api.patch(`/api/notes/${noteId}`, body);
|
|
295
|
+
return api.patch(`/api/notes/${noteId}`, body.value);
|
|
361
296
|
});
|
|
362
297
|
}));
|
|
363
|
-
|
|
364
|
-
key: z.string().describe("Unique key for this item, used in @key placeholder cross-references"),
|
|
365
|
-
type: z.string().describe("Note type (must be an existing supertag, e.g. 'Insight', 'Meeting')"),
|
|
366
|
-
markdown: z.string().describe("Note content as markdown (the first # h1 heading becomes the title)"),
|
|
367
|
-
tags: z.array(z.string()).optional().describe("Tags for this note"),
|
|
368
|
-
changeDescription: z
|
|
369
|
-
.string()
|
|
370
|
-
.optional()
|
|
371
|
-
.describe("Version 1's timeline line. Verb-first headline, optional blank line, then a body you own. {displayId} is filled in. A failing headline may be rewritten; the body is kept. headlineWarnings comes back on the result. Omit it and the platform later writes one."),
|
|
372
|
-
});
|
|
373
|
-
server.tool("cnotes_notes_create", "Create one or more interlinked notes in a single atomic transaction. FIRST call cnotes_types_show for each target type and author to that rubric — do not skip this. Pass `notes` as one item object or an array; each note's title is its first # h1 heading. Cross-reference in markdown with [@key: Title](relationship:type) (same-batch — @key resolves to the new display ID) or [NOTE-12: Title](relationship:type) (existing note). What you write is what the chip shows: ': Title' shows the note's title (the server keeps it current), [[type::NOTE-12]] shows the id alone, [[type::NOTE-12|your words]] shows your words. Title a note where the reader first meets it in a body; after that the id alone reads better than a run of titles. NEVER name another note as bare prose ('see DECISION-12') — plain text creates no chip, no relationship, no backlink; write the mention. Pick the relationship type from the verb your own prose uses ('blocks', 'depends-on', …; free-form — unknown types auto-create); reserve 'references' for pure citations — a verb narrated in prose around a 'references' chip is invisible to backlinks. A `mentionWarnings` array in the result flags narrated verbs it detects; a `plainTextIdWarnings` array flags bare IDs that name real notes, each with a paste-ready mention rewrite — treat both as fix instructions unless the prose genuinely isn't asserting a relationship. Each result item carries `type` + `rubric` (null when the type has no validationPrompt); a top-level `rubrics` array is also present. On validation failure, `details.items` pinpoints the bad item by index + key. " +
|
|
374
|
-
DECISION_CARD_RULE +
|
|
375
|
-
" A Decision must cite what it depends on with a typed verb (depends-on, grounded-in); a references chip does not. An uncited Decision still succeeds. That result carries `hint`, naming the displayId, and the same lines are in the top-level `hints` array, because no typed outgoing relationship was created.", {
|
|
376
|
-
notes: z
|
|
377
|
-
.union([NoteCreateItem, z.array(NoteCreateItem).min(1)])
|
|
378
|
-
.describe("Either a single item object or a non-empty array of items."),
|
|
379
|
-
intent: intentArg,
|
|
380
|
-
}, async ({ notes, intent }) => withErrorHandling(async () => {
|
|
298
|
+
sharedTool("cnotes_notes_create", async ({ notes, intent }) => withErrorHandling(async () => {
|
|
381
299
|
const items = Array.isArray(notes) ? notes : [notes];
|
|
382
300
|
// The three pre-flight reads are independent of each other and of the
|
|
383
301
|
// create, so they run as one round trip instead of three in a row.
|
|
@@ -450,10 +368,7 @@ server.tool("cnotes_search_semantic", "Semantic (vector) search across NOTES onl
|
|
|
450
368
|
limit: limit ?? 10,
|
|
451
369
|
...(canvasId ? { canvasId } : {}),
|
|
452
370
|
})));
|
|
453
|
-
|
|
454
|
-
query: z.string().describe("Search query (use '*' or 'all' to list every canvas)"),
|
|
455
|
-
limit: z.number().optional().default(10).describe("Max results"),
|
|
456
|
-
}, async ({ query, limit }) => withErrorHandling(() => api.get("/api/canvas/search", {
|
|
371
|
+
sharedTool("cnotes_canvas_search", async ({ query, limit }) => withErrorHandling(() => api.get("/api/canvas/search", {
|
|
457
372
|
workspaceId,
|
|
458
373
|
q: query,
|
|
459
374
|
limit: String(limit ?? 10),
|
|
@@ -461,85 +376,42 @@ server.tool("cnotes_canvas_search", "Semantic + lexical search across CANVASES o
|
|
|
461
376
|
// ---------------------------------------------------------------------------
|
|
462
377
|
// Canvas tools
|
|
463
378
|
// ---------------------------------------------------------------------------
|
|
464
|
-
|
|
465
|
-
includeArchived: z.boolean().optional().default(false).describe("Include archived canvases"),
|
|
466
|
-
}, async ({ includeArchived }) => withErrorHandling(() => api.get("/api/canvas", {
|
|
379
|
+
sharedTool("cnotes_canvas_list", async ({ includeArchived }) => withErrorHandling(() => api.get("/api/canvas", {
|
|
467
380
|
workspaceId,
|
|
468
381
|
...(includeArchived ? { includeArchived: "true" } : {}),
|
|
469
382
|
})));
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
}, async ({ canvasId }) => withErrorHandling(() => api.get(`/api/canvas/${encodeURIComponent(canvasId)}`, { workspaceId, format: "markdown" })));
|
|
473
|
-
server.tool("cnotes_canvas_status", "See a canvas's whole layout BEFORE placing or moving anything by x/y: every item (cards, text, lists, portals, sections) as one list of rectangles {kind, ref, x, y, width, height}, the pairs that overlap, and with `near` a free spot next to an anchor. Sections are containers, never overlaps. Read-only.", {
|
|
383
|
+
sharedTool("cnotes_canvas_get", async ({ canvasId }) => withErrorHandling(() => api.get(`/api/canvas/${encodeURIComponent(canvasId)}`, { workspaceId, format: "markdown" })));
|
|
384
|
+
server.tool("cnotes_canvas_status", "See a canvas's whole layout BEFORE placing or moving anything by x/y: every item (cards, text, lists, portals, sections) as one list of rectangles {kind, ref, x, y, width, height}, the pairs that overlap, and with `near` a free spot next to an anchor. Sections are containers, never overlaps. Also checks the board as an agent reads it: `read` is the size of the read and whether it fits one tool result (100,000 characters); `links` lists mentions showing a title their note no longer has, quote cards pinned to a version their note has moved past, arrows between two notes that no note body records, and mentions with no relationship type. Run it before calling a board done. Read-only.", {
|
|
474
385
|
canvasId: z.string().describe("Canvas ID"),
|
|
475
386
|
near: z.string().optional().describe("Find a free spot next to this item (display id or node id) or point 'x,y'"),
|
|
476
387
|
width: z.number().optional().default(340).describe("Width of the box to find room for (default: a note card)"),
|
|
477
388
|
height: z.number().optional().default(130).describe("Height of the box to find room for"),
|
|
478
389
|
}, async ({ canvasId, near, width, height }) => withErrorHandling(async () => {
|
|
479
|
-
const data = await
|
|
390
|
+
const [data, read] = await Promise.all([
|
|
391
|
+
api.get(`/api/canvas/${encodeURIComponent(canvasId)}`, { workspaceId }),
|
|
392
|
+
api.get("/api/canvas/read", { canvas: canvasId, workspaceId }),
|
|
393
|
+
]);
|
|
480
394
|
const items = layoutItemsFrom(data);
|
|
481
395
|
const overlaps = findOverlaps(items).map((o) => ({ a: o.a.ref, b: o.b.ref, area: o.area }));
|
|
396
|
+
const checks = boardChecks(read.result);
|
|
482
397
|
if (!near)
|
|
483
|
-
return { items, overlaps };
|
|
398
|
+
return { items, overlaps, ...checks };
|
|
484
399
|
const anchor = resolveAnchor(items, near);
|
|
485
400
|
if (!anchor)
|
|
486
401
|
throw new CliError(`No item "${near}" on this canvas.`);
|
|
487
402
|
const spot = suggestFreeSpot(items, anchor, { width, height });
|
|
488
|
-
return { items, overlaps, freeSpot: spot ? { ...spot, width, height, near } : null };
|
|
403
|
+
return { items, overlaps, ...checks, freeSpot: spot ? { ...spot, width, height, near } : null };
|
|
489
404
|
}));
|
|
490
|
-
|
|
491
|
-
canvasId: z.string().describe("Canvas ID, or a share link (https://…/shared/<id>)"),
|
|
492
|
-
}, async ({ canvasId }) => withErrorHandling(async () => {
|
|
405
|
+
sharedTool("cnotes_canvas_read", async ({ canvasId }) => withErrorHandling(async () => {
|
|
493
406
|
// The server reads share links too (access=shared, no workspace).
|
|
494
407
|
const read = await api.get("/api/canvas/read", { canvas: canvasId, workspaceId });
|
|
495
|
-
return read.
|
|
496
|
-
}));
|
|
497
|
-
|
|
498
|
-
section: z.string().describe("Section handle — SECTION-<n> display ID, or a raw section node ID"),
|
|
499
|
-
}, async ({ section }) => withErrorHandling(async () => {
|
|
408
|
+
return read.markdown;
|
|
409
|
+
}, { text: true }));
|
|
410
|
+
sharedTool("cnotes_canvas_read_section", async ({ section }) => withErrorHandling(async () => {
|
|
500
411
|
const read = await api.get("/api/canvas/read", { section, workspaceId });
|
|
501
|
-
return read.
|
|
502
|
-
}));
|
|
503
|
-
|
|
504
|
-
const layoutDocArg = z
|
|
505
|
-
.object({
|
|
506
|
-
root: z
|
|
507
|
-
.unknown()
|
|
508
|
-
.describe("Root LayoutNode. kind is one of: 'stack' (items flow along one axis, like CSS flexbox: {kind:'stack', axis:'vertical'|'horizontal', gap?, align?:'start'|'center'|'end', items:[LayoutNode...]}), 'grid' (N columns, items wrap to new rows: {kind:'grid', columns:<n>, gap?, items:[...]}), 'anchor' (place a sub-tree relative to an EXISTING canvas node: {kind:'anchor', to:'<displayId or node id>', direction:'right'|'left'|'above'|'below' — exactly these four, NOT top/bottom/up/down, gap?, child:LayoutNode}), 'section' (a named frame that sizes itself around its content: {kind:'section', name:'<title>', key?, child:LayoutNode}), or 'item' (a leaf — one per visible thing, NO x/y: {kind:'item', type:'note'|'richtext'|'list'|'canvas'|'quote'|'section', key?, ...type-specific fields}). gap accepts a preset 'tight'|'medium'|'spacious' or a raw pixel number (default 'medium')."),
|
|
509
|
-
edges: z
|
|
510
|
-
.array(z.unknown())
|
|
511
|
-
.optional()
|
|
512
|
-
.describe("Edges between placed/existing nodes: [{from, to, label?}]. Endpoints resolve in priority order: '@<key>' of an item placed in this call, the noteId of a note placed in this call (e.g. 'NOTE-7'), or the displayId/convex id of a node already on the canvas."),
|
|
513
|
-
origin: z
|
|
514
|
-
.object({ x: z.number(), y: z.number() })
|
|
515
|
-
.optional()
|
|
516
|
-
.describe("Top-left corner of the whole layout. Omit it and placement 'auto'/'append' pick a safe spot for you."),
|
|
517
|
-
placement: z
|
|
518
|
-
.enum(["auto", "append", "exact"])
|
|
519
|
-
.optional()
|
|
520
|
-
.describe("Where the layout lands vs existing content: 'auto' (default, collision-aware — drops into a clear band below existing nodes and slides down to de-collide), 'append' (always below everything), 'exact' (honor origin verbatim, pixel-perfect templates only)."),
|
|
521
|
-
})
|
|
522
|
-
.passthrough()
|
|
523
|
-
.describe("Layout document { root, edges?, origin?, placement? }. Describe STRUCTURE via the four node kinds (stack / grid / anchor / item, plus section frames) — the server resolves pixels. The schema is strict server-side: an unknown or typo'd key anywhere in the doc is rejected with the offending path named.");
|
|
524
|
-
/** New notes a layout creates and places in the same call. */
|
|
525
|
-
const layoutNotesArg = z
|
|
526
|
-
.array(z.object({
|
|
527
|
-
key: z.string(),
|
|
528
|
-
type: z.string(),
|
|
529
|
-
markdown: z.string(),
|
|
530
|
-
tags: z.array(z.string()).optional(),
|
|
531
|
-
changeDescription: z.string().optional(),
|
|
532
|
-
}))
|
|
533
|
-
.min(1)
|
|
534
|
-
.describe("Notes to create and place in this call (cnotes_notes_create item shape); a note leaf places one with noteId '@<key>'");
|
|
535
|
-
server.tool("cnotes_canvas_create", "Create a new canvas. Goal and target audience are required — every canvas must declare the result it exists to produce and who it serves. Write the goal FIRST, for a reader: a result sentence, then a \"Done when\" sentence (the server rejects a goal without one).\n\nLAY IT OUT IN THE SAME CALL: pass `doc` (and `notes`), exactly as cnotes_canvas_place takes them, and the server places the layout onto the new canvas before it answers, under `layout` in the result. One call replaces create then place. A layout the server refuses creates nothing: fix the doc and call this again.", {
|
|
536
|
-
name: z.string().describe("Canvas name"),
|
|
537
|
-
goal: z.string().describe(`${CANVAS_GOAL_DESCRIPTION} Required.`),
|
|
538
|
-
targetAudience: z.string().describe("Target audience — who this canvas is meant to serve or inform, and what they do with it. Required."),
|
|
539
|
-
doc: layoutDocArg.optional(),
|
|
540
|
-
notes: layoutNotesArg.optional(),
|
|
541
|
-
intent: intentArg,
|
|
542
|
-
}, async ({ name, goal, targetAudience, doc, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post("/api/canvas", {
|
|
412
|
+
return read.markdown;
|
|
413
|
+
}, { text: true }));
|
|
414
|
+
sharedTool("cnotes_canvas_create", async ({ name, goal, targetAudience, doc, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post("/api/canvas", {
|
|
543
415
|
workspaceId,
|
|
544
416
|
title: name,
|
|
545
417
|
goal,
|
|
@@ -547,13 +419,7 @@ server.tool("cnotes_canvas_create", "Create a new canvas. Goal and target audien
|
|
|
547
419
|
...(doc ? { doc } : {}),
|
|
548
420
|
...(notes ? { notes } : {}),
|
|
549
421
|
}))));
|
|
550
|
-
|
|
551
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
552
|
-
title: z.string().optional().describe("New canvas title"),
|
|
553
|
-
goal: z.string().optional().describe(CANVAS_GOAL_DESCRIPTION),
|
|
554
|
-
targetAudience: z.string().optional().describe("Target audience — who this canvas is meant to serve or inform, and what they do with it"),
|
|
555
|
-
intent: intentArg,
|
|
556
|
-
}, async ({ canvasId, title, goal, targetAudience, intent }) => {
|
|
422
|
+
sharedTool("cnotes_canvas_update", async ({ canvasId, title, goal, targetAudience, intent }) => {
|
|
557
423
|
if (!title && !goal && !targetAudience) {
|
|
558
424
|
return err("at least one of title, goal, or targetAudience is required");
|
|
559
425
|
}
|
|
@@ -569,23 +435,22 @@ server.tool("cnotes_canvas_update", "Update canvas metadata: title, goal, and/or
|
|
|
569
435
|
server.tool("cnotes_canvas_delete", "Delete a canvas.", {
|
|
570
436
|
canvasId: z.string().describe("Canvas ID"),
|
|
571
437
|
intent: intentArg,
|
|
572
|
-
}, async ({ canvasId, intent }) => withErrorHandling(() => inRun(intent, () => api.delete(
|
|
438
|
+
}, async ({ canvasId, intent }) => withErrorHandling(() => inRun(intent, () => api.delete(canvasPath(canvasId)))));
|
|
573
439
|
server.tool("cnotes_canvas_archive", "Archive or unarchive a canvas. Archiving is a soft delete (sets archivedAt timestamp). Use unarchive=true to restore.", {
|
|
574
440
|
canvasId: z.string().describe("Canvas ID"),
|
|
575
441
|
unarchive: z.boolean().optional().default(false).describe("Set true to unarchive/restore instead of archive"),
|
|
576
442
|
intent: intentArg,
|
|
577
|
-
}, async ({ canvasId, unarchive, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
443
|
+
}, async ({ canvasId, unarchive, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
578
444
|
action: unarchive ? "unarchive" : "archive",
|
|
579
445
|
}))));
|
|
580
446
|
server.tool("cnotes_canvas_set_home", "Set a canvas as the workspace home/default canvas. Clears any previous home canvas.", {
|
|
581
447
|
canvasId: z.string().describe("Canvas ID to set as home"),
|
|
582
|
-
}, async ({ canvasId }) => withErrorHandling(() => api.post(
|
|
448
|
+
}, async ({ canvasId }) => withErrorHandling(() => api.post(canvasPath(canvasId), { action: "setAsHome" })));
|
|
583
449
|
// --- Deprecated single-item wrappers ---
|
|
584
450
|
// Kept for backward compatibility with existing MCP clients. Without x/y the
|
|
585
451
|
// item goes through the solver (placeLayout): clear of everything, or INTO a
|
|
586
452
|
// section, where it joins the section's layout and the section re-arranges.
|
|
587
453
|
// x/y place it raw, with no collision check.
|
|
588
|
-
const canvasPath = (canvasId) => `/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`;
|
|
589
454
|
const addOne = (canvasId, leaf, at, section, raw) => {
|
|
590
455
|
if (at.x !== undefined && at.y !== undefined)
|
|
591
456
|
return raw();
|
|
@@ -611,7 +476,7 @@ server.tool("cnotes_canvas_add_node", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
611
476
|
x: RAW_X,
|
|
612
477
|
y: RAW_Y,
|
|
613
478
|
intent: intentArg,
|
|
614
|
-
}, async ({ canvasId, noteId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "note", noteId }, { x, y }, section, () => api.post(
|
|
479
|
+
}, async ({ canvasId, noteId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "note", noteId }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
615
480
|
action: "bulkAddNodes",
|
|
616
481
|
items: [{ type: "note", noteId, positionX: x, positionY: y }],
|
|
617
482
|
})))));
|
|
@@ -630,7 +495,7 @@ const textElementSchema = {
|
|
|
630
495
|
y: RAW_Y,
|
|
631
496
|
intent: intentArg,
|
|
632
497
|
};
|
|
633
|
-
const addTextElement = ({ canvasId, content, size, color, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "richtext", content, ...(size ? { size } : {}), ...(color ? { colorHex: color } : {}) }, { x, y }, section, () => api.post(
|
|
498
|
+
const addTextElement = ({ canvasId, content, size, color, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "richtext", content, ...(size ? { size } : {}), ...(color ? { colorHex: color } : {}) }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
634
499
|
action: "bulkAddNodes",
|
|
635
500
|
items: [{ type: "richtext", content, size, colorHex: color, positionX: x, positionY: y }],
|
|
636
501
|
}))));
|
|
@@ -647,7 +512,7 @@ server.tool("cnotes_canvas_add_list", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
647
512
|
intent: intentArg,
|
|
648
513
|
}, async ({ canvasId, description, noteIds, viewMode, section, x, y, intent }) => withErrorHandling(() => {
|
|
649
514
|
const ids = noteIds ? noteIds.split(",").map((id) => id.trim()) : undefined;
|
|
650
|
-
return inRun(intent, () => addOne(canvasId, { type: "list", description, viewMode, ...(ids ? { noteIds: ids } : {}) }, { x, y }, section, () => api.post(
|
|
515
|
+
return inRun(intent, () => addOne(canvasId, { type: "list", description, viewMode, ...(ids ? { noteIds: ids } : {}) }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
651
516
|
action: "bulkAddNodes",
|
|
652
517
|
items: [{ type: "list", description, viewMode, noteIds: ids, positionX: x, positionY: y }],
|
|
653
518
|
})));
|
|
@@ -659,7 +524,7 @@ server.tool("cnotes_canvas_add_link", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
659
524
|
x: RAW_X,
|
|
660
525
|
y: RAW_Y,
|
|
661
526
|
intent: intentArg,
|
|
662
|
-
}, async ({ canvasId, targetCanvasId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "canvas", linkedCanvasId: targetCanvasId }, { x, y }, section, () => api.post(
|
|
527
|
+
}, async ({ canvasId, targetCanvasId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "canvas", linkedCanvasId: targetCanvasId }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
663
528
|
action: "bulkAddNodes",
|
|
664
529
|
items: [{ type: "canvas", linkedCanvasId: targetCanvasId, positionX: x, positionY: y }],
|
|
665
530
|
})))));
|
|
@@ -745,21 +610,12 @@ server.tool("cnotes_canvas_bulk_add", "LOW-LEVEL: add items at raw x/y that YOU
|
|
|
745
610
|
return { ...rest, positionX: x, positionY: y };
|
|
746
611
|
}),
|
|
747
612
|
];
|
|
748
|
-
return inRun(intent, () => api.post(
|
|
613
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
749
614
|
action: "bulkAddNodes",
|
|
750
615
|
items: allItems,
|
|
751
616
|
}));
|
|
752
617
|
}));
|
|
753
|
-
|
|
754
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
755
|
-
doc: layoutDocArg,
|
|
756
|
-
intoSection: z
|
|
757
|
-
.string()
|
|
758
|
-
.optional()
|
|
759
|
-
.describe("SECTION-<n> to put the items INTO: appended to its layout (end of its shortest column, or the next grid cell); the section re-arranges and resizes. A section container in the doc creates an ARRANGED section that keeps its cards laid out until a card is moved by hand; add to it later with intoSection, never by aiming origin inside the frame. The doc may not contain sections when intoSection is set."),
|
|
760
|
-
notes: layoutNotesArg.optional(),
|
|
761
|
-
intent: intentArg,
|
|
762
|
-
}, async ({ canvasId, doc, intoSection, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post(`/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`, {
|
|
618
|
+
sharedTool("cnotes_canvas_place", async ({ canvasId, doc, intoSection, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
763
619
|
action: "placeLayout",
|
|
764
620
|
doc,
|
|
765
621
|
...(intoSection ? { intoSection } : {}),
|
|
@@ -795,7 +651,7 @@ server.tool("cnotes_canvas_arrange", "Reflow EXISTING canvas nodes with the layo
|
|
|
795
651
|
.describe("Solve and preview without moving anything."),
|
|
796
652
|
intent: intentArg,
|
|
797
653
|
}, async ({ canvasId, doc, targetSectionId, autoResize, dryRun, intent }) => {
|
|
798
|
-
const arrange = () => api.post(
|
|
654
|
+
const arrange = () => api.post(canvasPath(canvasId), {
|
|
799
655
|
action: "arrangeLayout",
|
|
800
656
|
doc,
|
|
801
657
|
...(targetSectionId ? { targetSectionId } : {}),
|
|
@@ -814,7 +670,7 @@ server.tool("cnotes_canvas_bulk_move", "Move multiple nodes to new positions in
|
|
|
814
670
|
y: z.number().describe("New Y position"),
|
|
815
671
|
})).describe("Array of node moves"),
|
|
816
672
|
intent: intentArg,
|
|
817
|
-
}, async ({ canvasId, moves, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
673
|
+
}, async ({ canvasId, moves, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
818
674
|
action: "bulkMoveNodes",
|
|
819
675
|
moves: moves.map((m) => ({
|
|
820
676
|
nodeId: m.nodeId,
|
|
@@ -841,28 +697,14 @@ inRun(intent, () =>
|
|
|
841
697
|
// ?workspaceId= is not decoration: a "CANVAS-12" handle is only
|
|
842
698
|
// resolvable against a workspace on the Bearer path, so without it this
|
|
843
699
|
// 400s for exactly the callers the description tells to use display ids.
|
|
844
|
-
api.post(
|
|
700
|
+
api.post(canvasPath(canvasId), {
|
|
845
701
|
action: "bulkRemoveNodes",
|
|
846
702
|
nodeIds: nodeIds ?? [],
|
|
847
703
|
edgeIds: edgeIds ?? [],
|
|
848
704
|
}), canvasId)));
|
|
849
|
-
|
|
850
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
851
|
-
sourceNodeId: z.string().describe("Source node ID"),
|
|
852
|
-
targetNodeId: z.string().describe("Target node ID"),
|
|
853
|
-
label: z.string().optional().describe("Edge label"),
|
|
854
|
-
arrow: z
|
|
855
|
-
.enum(["end", "start", "both", "none"])
|
|
856
|
-
.optional()
|
|
857
|
-
.describe("Arrow direction (default: end)"),
|
|
858
|
-
lineStyle: z
|
|
859
|
-
.enum(["solid", "dashed"])
|
|
860
|
-
.optional()
|
|
861
|
-
.describe("Line style (default: solid)"),
|
|
862
|
-
intent: intentArg,
|
|
863
|
-
}, async ({ canvasId, sourceNodeId, targetNodeId, label, arrow, lineStyle, intent }) => withErrorHandling(() => {
|
|
705
|
+
sharedTool("cnotes_canvas_add_edge", async ({ canvasId, sourceNodeId, targetNodeId, label, arrow, lineStyle, intent }) => withErrorHandling(() => {
|
|
864
706
|
const markers = arrowToMarkers(arrow);
|
|
865
|
-
return inRun(intent, () => api.post(
|
|
707
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
866
708
|
action: "addEdge",
|
|
867
709
|
sourceNodeId,
|
|
868
710
|
targetNodeId,
|
|
@@ -899,44 +741,17 @@ server.tool("cnotes_canvas_update_edge", "Update an edge: change its label, togg
|
|
|
899
741
|
body.lineStyle = lineStyle;
|
|
900
742
|
if (reverse !== undefined)
|
|
901
743
|
body.reverse = reverse;
|
|
902
|
-
return inRun(intent, () => api.post(
|
|
744
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), body));
|
|
903
745
|
}));
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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"),
|
|
912
|
-
width: z.number().optional().describe("New frame width in px"),
|
|
913
|
-
height: z.number().optional().describe("New frame height in px"),
|
|
914
|
-
colorHex: z
|
|
915
|
-
.string()
|
|
916
|
-
.optional()
|
|
917
|
-
.describe("New frame tint — a role hex (#3B82F6 evidence · #22C55E commitment · #EC4899 insight · #F59E0B warning · #EF4444 danger · #8B5CF6 people; anything else snaps to the nearest), or '' to reset to the default"),
|
|
918
|
-
arrange: z
|
|
919
|
-
.boolean()
|
|
920
|
-
.optional()
|
|
921
|
-
.describe("true: lay out the cards inside the frame, size it to fit, keep it arranged. false: stop arranging (nothing moves). Send on its own."),
|
|
922
|
-
intent: intentArg,
|
|
923
|
-
}, async ({ canvasId, sectionId, name, x, y, width, height, colorHex, arrange, intent }) => withErrorHandling(() => {
|
|
924
|
-
if (arrange !== undefined) {
|
|
925
|
-
if ([name, x, y, width, height, colorHex].some((v) => v !== undefined)) {
|
|
926
|
-
throw new Error("Arrange is its own call: send arrange alone, then any other change in a second call.");
|
|
927
|
-
}
|
|
928
|
-
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
929
|
-
action: "arrangeSection",
|
|
930
|
-
sectionId,
|
|
931
|
-
...(arrange ? {} : { stop: true }),
|
|
932
|
-
}));
|
|
933
|
-
}
|
|
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);
|
|
746
|
+
sharedTool("cnotes_canvas_update_section", async ({ canvasId, intent, ...args }) => withErrorHandling(() => {
|
|
747
|
+
// arrange, a move (x/y, which carries the cards inside the frame) or an
|
|
748
|
+
// in-place update: the same rule as the remote connector (lib/mcp-spec.ts).
|
|
749
|
+
const plan = planSectionTool(args);
|
|
750
|
+
if (!plan.ok)
|
|
751
|
+
throw new CliError(refusalText(plan));
|
|
937
752
|
// A move rewrites where existing cards sit, so its run is bracketed
|
|
938
753
|
// with a canvas checkpoint.
|
|
939
|
-
return inRun(intent, () => api.post(canvasPath(canvasId),
|
|
754
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), plan.value.body), plan.value.kind === "move" ? canvasId : undefined);
|
|
940
755
|
}));
|
|
941
756
|
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.", {
|
|
942
757
|
canvasId: z.string().describe("Canvas ID"),
|
|
@@ -948,7 +763,7 @@ server.tool("cnotes_canvas_move_node", "LOW-LEVEL: move one node to raw x/y, wit
|
|
|
948
763
|
}, async ({ canvasId, nodeId, nodeType, x, y, intent }) => withErrorHandling(() => inRun(intent, () =>
|
|
949
764
|
// workspaceId lets the server resolve CANVAS-<n> and read the layout
|
|
950
765
|
// for its overlap check.
|
|
951
|
-
api.post(
|
|
766
|
+
api.post(canvasPath(canvasId), {
|
|
952
767
|
action: "moveNode",
|
|
953
768
|
nodeId,
|
|
954
769
|
nodeType,
|
|
@@ -959,7 +774,7 @@ server.tool("cnotes_canvas_remove_node", "Remove a node from a canvas.", {
|
|
|
959
774
|
canvasId: z.string().describe("Canvas ID"),
|
|
960
775
|
nodeId: z.string().describe("Canvas node ID"),
|
|
961
776
|
intent: intentArg,
|
|
962
|
-
}, async ({ canvasId, nodeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
777
|
+
}, async ({ canvasId, nodeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
963
778
|
action: "removeNode",
|
|
964
779
|
nodeId,
|
|
965
780
|
}), canvasId)));
|
|
@@ -967,7 +782,7 @@ server.tool("cnotes_canvas_remove_edge", "Remove an edge from a canvas.", {
|
|
|
967
782
|
canvasId: z.string().describe("Canvas ID"),
|
|
968
783
|
edgeId: z.string().describe("Canvas edge ID"),
|
|
969
784
|
intent: intentArg,
|
|
970
|
-
}, async ({ canvasId, edgeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
785
|
+
}, async ({ canvasId, edgeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
971
786
|
action: "removeEdge",
|
|
972
787
|
edgeId,
|
|
973
788
|
}), canvasId)));
|
|
@@ -1200,29 +1015,7 @@ server.tool("cnotes_review_complete", 'Record a review\'s one structured outcome
|
|
|
1200
1015
|
// overlays them on recorded attention; kept/missed is derived, so there is
|
|
1201
1016
|
// deliberately no "complete" tool.
|
|
1202
1017
|
// ---------------------------------------------------------------------------
|
|
1203
|
-
|
|
1204
|
-
start: z
|
|
1205
|
-
.string()
|
|
1206
|
-
.describe('Start time: ISO 8601 local (e.g. "2026-07-26T09:00") or "HH:MM" for the next occurrence of that time'),
|
|
1207
|
-
durationMinutes: z
|
|
1208
|
-
.number()
|
|
1209
|
-
.min(1)
|
|
1210
|
-
.max(720)
|
|
1211
|
-
.describe("Block length in minutes (e.g. 90). Quality flow blocks are typically 60-120."),
|
|
1212
|
-
goal: z
|
|
1213
|
-
.string()
|
|
1214
|
-
.min(1)
|
|
1215
|
-
.max(500)
|
|
1216
|
-
.describe("Why this block exists — shown goal-first in the user's calendar"),
|
|
1217
|
-
canvas: z
|
|
1218
|
-
.string()
|
|
1219
|
-
.optional()
|
|
1220
|
-
.describe('Prepared orientation canvas ("CANVAS-12" or a canvas id)'),
|
|
1221
|
-
target: z
|
|
1222
|
-
.string()
|
|
1223
|
-
.optional()
|
|
1224
|
-
.describe('The exact place the block works on: a NOTE-… or SECTION-… display id ON that canvas (e.g. an Attention card). Requires canvas. Keep the durable clues — decisions, criteria, "complete when" — IN the target note; the plan row is just when.'),
|
|
1225
|
-
}, async ({ start, durationMinutes, goal, canvas, target }) => withErrorHandling(() => {
|
|
1018
|
+
sharedTool("cnotes_focus_plan", async ({ start, durationMinutes, goal, canvas, target }) => withErrorHandling(() => {
|
|
1226
1019
|
const startMs = parseFocusStart(start, Date.now());
|
|
1227
1020
|
return api.post("/api/focus", {
|
|
1228
1021
|
workspaceId,
|
|
@@ -1230,25 +1023,10 @@ server.tool("cnotes_focus_plan", "Plan a protected flow-state focus block for th
|
|
|
1230
1023
|
endMs: startMs + Math.round(durationMinutes * 60_000),
|
|
1231
1024
|
goal,
|
|
1232
1025
|
...(canvas ? { canvas } : {}),
|
|
1233
|
-
...(target ? { target
|
|
1026
|
+
...(target ? { target } : {}),
|
|
1234
1027
|
});
|
|
1235
1028
|
}));
|
|
1236
|
-
|
|
1237
|
-
days: z
|
|
1238
|
-
.number()
|
|
1239
|
-
.min(0)
|
|
1240
|
-
.max(90)
|
|
1241
|
-
.optional()
|
|
1242
|
-
.default(7)
|
|
1243
|
-
.describe("Days ahead to include"),
|
|
1244
|
-
pastDays: z
|
|
1245
|
-
.number()
|
|
1246
|
-
.min(0)
|
|
1247
|
-
.max(90)
|
|
1248
|
-
.optional()
|
|
1249
|
-
.default(0)
|
|
1250
|
-
.describe("Also include this many past days"),
|
|
1251
|
-
}, async ({ days, pastDays }) => withErrorHandling(() => {
|
|
1029
|
+
sharedTool("cnotes_focus_list", async ({ days, pastDays }) => withErrorHandling(() => {
|
|
1252
1030
|
const todayStart = new Date();
|
|
1253
1031
|
todayStart.setHours(0, 0, 0, 0);
|
|
1254
1032
|
const from = todayStart.getTime() - (pastDays ?? 0) * 86_400_000;
|
|
@@ -1259,9 +1037,7 @@ server.tool("cnotes_focus_list", "List the user's planned focus blocks (today on
|
|
|
1259
1037
|
to: String(to),
|
|
1260
1038
|
});
|
|
1261
1039
|
}));
|
|
1262
|
-
|
|
1263
|
-
planId: z.string().describe("Plan id (from cnotes_focus_list)"),
|
|
1264
|
-
}, async ({ planId }) => withErrorHandling(() => api.delete(`/api/focus?workspaceId=${encodeURIComponent(workspaceId)}&planId=${encodeURIComponent(planId)}`)));
|
|
1040
|
+
sharedTool("cnotes_focus_cancel", async ({ planId }) => withErrorHandling(() => api.delete(`/api/focus?workspaceId=${encodeURIComponent(workspaceId)}&planId=${encodeURIComponent(planId)}`)));
|
|
1265
1041
|
const DURATION_UNITS = {
|
|
1266
1042
|
m: 60_000,
|
|
1267
1043
|
h: 3_600_000,
|
|
@@ -1285,7 +1061,7 @@ function parseDuration(input) {
|
|
|
1285
1061
|
// ---------------------------------------------------------------------------
|
|
1286
1062
|
// Types (supertags)
|
|
1287
1063
|
// ---------------------------------------------------------------------------
|
|
1288
|
-
|
|
1064
|
+
sharedTool("cnotes_types_list", async () => withErrorHandling(() => api.get("/api/supertags", { workspaceId })));
|
|
1289
1065
|
server.tool("cnotes_types_show", "Show one note type's quality rubric (validationPrompt) — what a good instance of that type contains. Read this BEFORE authoring a note of this type so it lands well-formed.", {
|
|
1290
1066
|
name: z.string().describe("Type name (e.g. 'Decision', 'Insight')"),
|
|
1291
1067
|
}, async ({ name }) => withErrorHandling(async () => {
|