@creator-notes/cnotes 0.125.5 → 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 +30 -35
- package/dist/commands/notes.js +3 -9
- package/dist/lib/mcp-spec.js +636 -0
- package/dist/lib/section-update.js +21 -0
- package/dist/mcp-server.js +89 -326
- package/package.json +1 -1
- package/skills/cnotes/references/canvas.md +3 -1
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 { arrowToMarkers, buildMcpSpec, notesExpandQuery, notesUpdateBody, orderByDisplayId, planSectionTool, refusalText, } from "./lib/mcp-spec.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";
|
|
@@ -36,6 +37,7 @@ import { lintNarratedVerbMentions, lintPlainTextDisplayIds, lintPlainTextDisplay
|
|
|
36
37
|
import { DECISION_CARD_RULE } from "./lib/decision-citation.js";
|
|
37
38
|
import { parseReviewRef } from "./lib/review-helpers.js";
|
|
38
39
|
import { runQuery } from "./commands/query.js";
|
|
40
|
+
import { canvasActionPath } from "./lib/canvas-paths.js";
|
|
39
41
|
import { inToolRun } from "./lib/mcp-run.js";
|
|
40
42
|
import { isLocalDbEnabled } from "./lib/auth-store.js";
|
|
41
43
|
import { explainTruncation, listNotes, SERVER_LIST_CAP } from "./lib/notes-list.js";
|
|
@@ -67,26 +69,16 @@ const workspaceId = CNOTES_WORKSPACE;
|
|
|
67
69
|
function ok(data) {
|
|
68
70
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
69
71
|
}
|
|
70
|
-
function arrowToMarkers(arrow) {
|
|
71
|
-
switch (arrow) {
|
|
72
|
-
case "end":
|
|
73
|
-
return { arrowStart: false, arrowEnd: true };
|
|
74
|
-
case "start":
|
|
75
|
-
return { arrowStart: true, arrowEnd: false };
|
|
76
|
-
case "both":
|
|
77
|
-
return { arrowStart: true, arrowEnd: true };
|
|
78
|
-
case "none":
|
|
79
|
-
return { arrowStart: false, arrowEnd: false };
|
|
80
|
-
default:
|
|
81
|
-
return {};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
72
|
function err(message) {
|
|
85
73
|
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
86
74
|
}
|
|
87
|
-
|
|
75
|
+
/** `text: true` answers with the string as it is (a markdown read), not JSON-encoded. */
|
|
76
|
+
async function withErrorHandling(fn, opts = {}) {
|
|
88
77
|
try {
|
|
89
|
-
|
|
78
|
+
const data = await fn();
|
|
79
|
+
if (opts.text && typeof data === "string")
|
|
80
|
+
return { content: [{ type: "text", text: data }] };
|
|
81
|
+
return ok(data);
|
|
90
82
|
}
|
|
91
83
|
catch (e) {
|
|
92
84
|
// Keep the typed context the CLI errors carry — an MCP agent needs the
|
|
@@ -111,18 +103,25 @@ async function withErrorHandling(fn) {
|
|
|
111
103
|
return err(msg);
|
|
112
104
|
}
|
|
113
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* The tools this server shares with the remote connector (lib/mcp/tools.ts in
|
|
108
|
+
* the app): name, description and arguments come from lib/mcp-spec.ts, so the
|
|
109
|
+
* two accept the same call. Register one with sharedTool(), never with a bare
|
|
110
|
+
* server.tool(); __tests__/lib/mcp-shared-tools-guardrail.test.ts in the app
|
|
111
|
+
* fails otherwise.
|
|
112
|
+
*/
|
|
113
|
+
const SPEC = buildMcpSpec(z, {
|
|
114
|
+
surface: "stdio",
|
|
115
|
+
decisionCardRule: DECISION_CARD_RULE,
|
|
116
|
+
canvasGoalDescription: CANVAS_GOAL_DESCRIPTION,
|
|
117
|
+
});
|
|
114
118
|
/**
|
|
115
119
|
* Every write tool takes the model's intent: the server refuses a write from a
|
|
116
120
|
* key outside an agent run (FEEDBACK-6KQR), so the tool opens a run for its
|
|
117
121
|
* one call with this sentence as the timeline headline, or joins the run that
|
|
118
|
-
* is already open (lib/mcp-run.ts).
|
|
122
|
+
* is already open (lib/mcp-run.ts). The same field as the shared tools take.
|
|
119
123
|
*/
|
|
120
|
-
const intentArg =
|
|
121
|
-
.string()
|
|
122
|
-
.trim()
|
|
123
|
-
.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.");
|
|
124
|
+
const intentArg = SPEC.intent;
|
|
126
125
|
const runContext = { api, serverUrl: CNOTES_SERVER, workspaceId };
|
|
127
126
|
/** Run a write tool's REST calls inside an agent run; pass canvasId when it removes canvas content. */
|
|
128
127
|
const inRun = (intent, fn, canvasId) => inToolRun(runContext, intent, fn, canvasId ? { canvasId } : {});
|
|
@@ -133,6 +132,19 @@ const server = new McpServer({
|
|
|
133
132
|
name: "cnotes-mcp",
|
|
134
133
|
version: "0.4.0",
|
|
135
134
|
});
|
|
135
|
+
/** Register a tool the remote connector also has, from the shared spec. */
|
|
136
|
+
function sharedTool(name, handler) {
|
|
137
|
+
const { description, shape } = SPEC.tools[name];
|
|
138
|
+
return server.tool(name, description, shape, handler);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Every single-canvas request carries ?workspaceId=: on the key path the route
|
|
142
|
+
* resolves a CANVAS-<n> handle only against that param (resolveCanvasIdRef in
|
|
143
|
+
* lib/api/canvas-auth.ts); the X-Cnotes-Workspace header does not stand in for
|
|
144
|
+
* it. Some actions also read the canvas for their overlap and ripple checks
|
|
145
|
+
* through it.
|
|
146
|
+
*/
|
|
147
|
+
const canvasPath = (canvasId) => canvasActionPath(canvasId, workspaceId);
|
|
136
148
|
// ---------------------------------------------------------------------------
|
|
137
149
|
// Resources
|
|
138
150
|
// ---------------------------------------------------------------------------
|
|
@@ -157,16 +169,7 @@ server.resource("types", "cnotes://types", async () => ({
|
|
|
157
169
|
// ---------------------------------------------------------------------------
|
|
158
170
|
// Notes tools
|
|
159
171
|
// ---------------------------------------------------------------------------
|
|
160
|
-
|
|
161
|
-
"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. " +
|
|
162
|
-
"To count or group notes, use cnotes_query.", {
|
|
163
|
-
search: z.string().optional().describe("Text in the title or display id (for words inside notes, use cnotes_search)"),
|
|
164
|
-
type: z.string().optional().describe("Filter by note type (e.g. Meeting, PRD); comma-separated for several"),
|
|
165
|
-
tags: z.string().optional().describe("Filter by tags (comma-separated)"),
|
|
166
|
-
pinned: z.boolean().optional().describe("Only show pinned notes"),
|
|
167
|
-
limit: z.number().optional().default(20).describe("Max results"),
|
|
168
|
-
includeContent: z.boolean().optional().default(false).describe("Include full note content in results"),
|
|
169
|
-
}, async ({ search, type, tags, pinned, limit, includeContent }) => {
|
|
172
|
+
sharedTool("cnotes_notes_list", async ({ search, type, tags, pinned, limit, includeContent }) => {
|
|
170
173
|
const max = limit ?? 20;
|
|
171
174
|
if (includeContent) {
|
|
172
175
|
return withErrorHandling(async () => {
|
|
@@ -237,44 +240,9 @@ async ({ text, types, canvases, tags, madeBy, by, groupBy, limit, sql, rebuild }
|
|
|
237
240
|
const { kind: _kind, ...rest } = answer;
|
|
238
241
|
return rest;
|
|
239
242
|
}));
|
|
240
|
-
|
|
241
|
-
ids: z
|
|
242
|
-
.array(z.string())
|
|
243
|
-
.min(1)
|
|
244
|
-
.describe("Display IDs (e.g. ['MEETING-12','PRD-3','IDEA-7']). Pass an array even for a single ID."),
|
|
245
|
-
expand: z
|
|
246
|
-
.boolean()
|
|
247
|
-
.optional()
|
|
248
|
-
.describe("Also return notes these ids link to. Response becomes { notes, linked, truncated, cap, omitted, notice }."),
|
|
249
|
-
depth: z
|
|
250
|
-
.number()
|
|
251
|
-
.int()
|
|
252
|
-
.min(1)
|
|
253
|
-
.max(4)
|
|
254
|
-
.optional()
|
|
255
|
-
.describe("With expand, how many hops to follow. Default 1, max 4."),
|
|
256
|
-
rel: z
|
|
257
|
-
.string()
|
|
258
|
-
.optional()
|
|
259
|
-
.describe("With expand, comma-separated relation slugs to follow (e.g. 'assumes,depends-on')."),
|
|
260
|
-
summary: z
|
|
261
|
-
.boolean()
|
|
262
|
-
.optional()
|
|
263
|
-
.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."),
|
|
264
|
-
incoming: z
|
|
265
|
-
.boolean()
|
|
266
|
-
.optional()
|
|
267
|
-
.describe("With expand, also include notes that link to the targets."),
|
|
268
|
-
}, async ({ ids, expand, depth, rel, summary, incoming }) => withErrorHandling(async () => {
|
|
243
|
+
sharedTool("cnotes_notes_get", async ({ ids, expand, depth, rel, summary, incoming }) => withErrorHandling(async () => {
|
|
269
244
|
if (expand) {
|
|
270
|
-
return api.get("/api/notes/expand", {
|
|
271
|
-
workspaceId,
|
|
272
|
-
ids: ids.join(","),
|
|
273
|
-
depth: String(depth ?? 1),
|
|
274
|
-
rel,
|
|
275
|
-
summary: summary ? "true" : undefined,
|
|
276
|
-
incoming: incoming ? "true" : undefined,
|
|
277
|
-
});
|
|
245
|
+
return api.get("/api/notes/expand", notesExpandQuery({ ids, depth, rel, summary, incoming }, workspaceId));
|
|
278
246
|
}
|
|
279
247
|
const notesList = await api.get("/api/notes", {
|
|
280
248
|
workspaceId,
|
|
@@ -282,18 +250,11 @@ server.tool("cnotes_notes_get", "Get one or more notes by display ID (e.g. MEETI
|
|
|
282
250
|
excludeDrafts: "true",
|
|
283
251
|
format: "markdown",
|
|
284
252
|
});
|
|
285
|
-
const
|
|
286
|
-
const byDisplayId = new Map();
|
|
287
|
-
for (const n of found) {
|
|
288
|
-
if (typeof n.displayId === "string")
|
|
289
|
-
byDisplayId.set(n.displayId, n);
|
|
290
|
-
}
|
|
291
|
-
const missing = ids.filter((id) => !byDisplayId.has(id));
|
|
253
|
+
const { ordered, missing } = orderByDisplayId(ids, notesList);
|
|
292
254
|
if (missing.length > 0) {
|
|
293
255
|
throw new Error(`Notes not found: ${missing.join(", ")}`);
|
|
294
256
|
}
|
|
295
|
-
|
|
296
|
-
return ids.map((id) => byDisplayId.get(id));
|
|
257
|
+
return ordered;
|
|
297
258
|
}));
|
|
298
259
|
server.tool("cnotes_notes_delete", "Delete (archive) a note.", {
|
|
299
260
|
id: z.string().describe("Note display ID or Convex ID"),
|
|
@@ -324,56 +285,16 @@ server.tool("cnotes_notes_bulk_retype", "Retype multiple notes to a new type in
|
|
|
324
285
|
noteIds: ids,
|
|
325
286
|
targetType,
|
|
326
287
|
}))));
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
pin: z.boolean().optional().describe("Pin the note"),
|
|
332
|
-
unpin: z.boolean().optional().describe("Unpin the note"),
|
|
333
|
-
archive: z.boolean().optional().describe("Archive the note"),
|
|
334
|
-
unarchive: z.boolean().optional().describe("Unarchive the note"),
|
|
335
|
-
intent: intentArg,
|
|
336
|
-
}, async ({ id, type, tags, pin, unpin, archive, unarchive, intent }) => withErrorHandling(async () => {
|
|
337
|
-
const body = {};
|
|
338
|
-
if (type !== undefined)
|
|
339
|
-
body.type = type;
|
|
340
|
-
if (tags !== undefined) {
|
|
341
|
-
body.tags = tags === "" ? [] : tags.split(",").map((t) => t.trim()).filter(Boolean);
|
|
342
|
-
}
|
|
343
|
-
if (pin)
|
|
344
|
-
body.isPinned = true;
|
|
345
|
-
if (unpin)
|
|
346
|
-
body.isPinned = false;
|
|
347
|
-
if (archive)
|
|
348
|
-
body.isArchived = true;
|
|
349
|
-
if (unarchive)
|
|
350
|
-
body.isArchived = false;
|
|
351
|
-
if (Object.keys(body).length === 0) {
|
|
352
|
-
throw new Error("At least one of type, tags, pin, unpin, archive, or unarchive is required");
|
|
353
|
-
}
|
|
288
|
+
sharedTool("cnotes_notes_update", async ({ id, intent, ...args }) => withErrorHandling(async () => {
|
|
289
|
+
const body = notesUpdateBody(args);
|
|
290
|
+
if (!body.ok)
|
|
291
|
+
throw new CliError(body.message);
|
|
354
292
|
return inRun(intent, async () => {
|
|
355
293
|
const noteId = await resolveNoteId(api, workspaceId, id);
|
|
356
|
-
return api.patch(`/api/notes/${noteId}`, body);
|
|
294
|
+
return api.patch(`/api/notes/${noteId}`, body.value);
|
|
357
295
|
});
|
|
358
296
|
}));
|
|
359
|
-
|
|
360
|
-
key: z.string().describe("Unique key for this item, used in @key placeholder cross-references"),
|
|
361
|
-
type: z.string().describe("Note type (must be an existing supertag, e.g. 'Insight', 'Meeting')"),
|
|
362
|
-
markdown: z.string().describe("Note content as markdown (the first # h1 heading becomes the title)"),
|
|
363
|
-
tags: z.array(z.string()).optional().describe("Tags for this note"),
|
|
364
|
-
changeDescription: z
|
|
365
|
-
.string()
|
|
366
|
-
.optional()
|
|
367
|
-
.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."),
|
|
368
|
-
});
|
|
369
|
-
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. " +
|
|
370
|
-
DECISION_CARD_RULE +
|
|
371
|
-
" 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.", {
|
|
372
|
-
notes: z
|
|
373
|
-
.union([NoteCreateItem, z.array(NoteCreateItem).min(1)])
|
|
374
|
-
.describe("Either a single item object or a non-empty array of items."),
|
|
375
|
-
intent: intentArg,
|
|
376
|
-
}, async ({ notes, intent }) => withErrorHandling(async () => {
|
|
297
|
+
sharedTool("cnotes_notes_create", async ({ notes, intent }) => withErrorHandling(async () => {
|
|
377
298
|
const items = Array.isArray(notes) ? notes : [notes];
|
|
378
299
|
// The three pre-flight reads are independent of each other and of the
|
|
379
300
|
// create, so they run as one round trip instead of three in a row.
|
|
@@ -446,10 +367,7 @@ server.tool("cnotes_search_semantic", "Semantic (vector) search across NOTES onl
|
|
|
446
367
|
limit: limit ?? 10,
|
|
447
368
|
...(canvasId ? { canvasId } : {}),
|
|
448
369
|
})));
|
|
449
|
-
|
|
450
|
-
query: z.string().describe("Search query (use '*' or 'all' to list every canvas)"),
|
|
451
|
-
limit: z.number().optional().default(10).describe("Max results"),
|
|
452
|
-
}, async ({ query, limit }) => withErrorHandling(() => api.get("/api/canvas/search", {
|
|
370
|
+
sharedTool("cnotes_canvas_search", async ({ query, limit }) => withErrorHandling(() => api.get("/api/canvas/search", {
|
|
453
371
|
workspaceId,
|
|
454
372
|
q: query,
|
|
455
373
|
limit: String(limit ?? 10),
|
|
@@ -457,15 +375,11 @@ server.tool("cnotes_canvas_search", "Semantic + lexical search across CANVASES o
|
|
|
457
375
|
// ---------------------------------------------------------------------------
|
|
458
376
|
// Canvas tools
|
|
459
377
|
// ---------------------------------------------------------------------------
|
|
460
|
-
|
|
461
|
-
includeArchived: z.boolean().optional().default(false).describe("Include archived canvases"),
|
|
462
|
-
}, async ({ includeArchived }) => withErrorHandling(() => api.get("/api/canvas", {
|
|
378
|
+
sharedTool("cnotes_canvas_list", async ({ includeArchived }) => withErrorHandling(() => api.get("/api/canvas", {
|
|
463
379
|
workspaceId,
|
|
464
380
|
...(includeArchived ? { includeArchived: "true" } : {}),
|
|
465
381
|
})));
|
|
466
|
-
|
|
467
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
468
|
-
}, async ({ canvasId }) => withErrorHandling(() => api.get(`/api/canvas/${encodeURIComponent(canvasId)}`, { workspaceId, format: "markdown" })));
|
|
382
|
+
sharedTool("cnotes_canvas_get", async ({ canvasId }) => withErrorHandling(() => api.get(`/api/canvas/${encodeURIComponent(canvasId)}`, { workspaceId, format: "markdown" })));
|
|
469
383
|
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.", {
|
|
470
384
|
canvasId: z.string().describe("Canvas ID"),
|
|
471
385
|
near: z.string().optional().describe("Find a free spot next to this item (display id or node id) or point 'x,y'"),
|
|
@@ -483,59 +397,16 @@ server.tool("cnotes_canvas_status", "See a canvas's whole layout BEFORE placing
|
|
|
483
397
|
const spot = suggestFreeSpot(items, anchor, { width, height });
|
|
484
398
|
return { items, overlaps, freeSpot: spot ? { ...spot, width, height, near } : null };
|
|
485
399
|
}));
|
|
486
|
-
|
|
487
|
-
canvasId: z.string().describe("Canvas ID, or a share link (https://…/shared/<id>)"),
|
|
488
|
-
}, async ({ canvasId }) => withErrorHandling(async () => {
|
|
400
|
+
sharedTool("cnotes_canvas_read", async ({ canvasId }) => withErrorHandling(async () => {
|
|
489
401
|
// The server reads share links too (access=shared, no workspace).
|
|
490
402
|
const read = await api.get("/api/canvas/read", { canvas: canvasId, workspaceId });
|
|
491
|
-
return read.
|
|
492
|
-
}));
|
|
493
|
-
|
|
494
|
-
section: z.string().describe("Section handle — SECTION-<n> display ID, or a raw section node ID"),
|
|
495
|
-
}, async ({ section }) => withErrorHandling(async () => {
|
|
403
|
+
return read.markdown;
|
|
404
|
+
}, { text: true }));
|
|
405
|
+
sharedTool("cnotes_canvas_read_section", async ({ section }) => withErrorHandling(async () => {
|
|
496
406
|
const read = await api.get("/api/canvas/read", { section, workspaceId });
|
|
497
|
-
return read.
|
|
498
|
-
}));
|
|
499
|
-
|
|
500
|
-
const layoutDocArg = z
|
|
501
|
-
.object({
|
|
502
|
-
root: z
|
|
503
|
-
.unknown()
|
|
504
|
-
.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')."),
|
|
505
|
-
edges: z
|
|
506
|
-
.array(z.unknown())
|
|
507
|
-
.optional()
|
|
508
|
-
.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."),
|
|
509
|
-
origin: z
|
|
510
|
-
.object({ x: z.number(), y: z.number() })
|
|
511
|
-
.optional()
|
|
512
|
-
.describe("Top-left corner of the whole layout. Omit it and placement 'auto'/'append' pick a safe spot for you."),
|
|
513
|
-
placement: z
|
|
514
|
-
.enum(["auto", "append", "exact"])
|
|
515
|
-
.optional()
|
|
516
|
-
.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)."),
|
|
517
|
-
})
|
|
518
|
-
.passthrough()
|
|
519
|
-
.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.");
|
|
520
|
-
/** New notes a layout creates and places in the same call. */
|
|
521
|
-
const layoutNotesArg = z
|
|
522
|
-
.array(z.object({
|
|
523
|
-
key: z.string(),
|
|
524
|
-
type: z.string(),
|
|
525
|
-
markdown: z.string(),
|
|
526
|
-
tags: z.array(z.string()).optional(),
|
|
527
|
-
changeDescription: z.string().optional(),
|
|
528
|
-
}))
|
|
529
|
-
.min(1)
|
|
530
|
-
.describe("Notes to create and place in this call (cnotes_notes_create item shape); a note leaf places one with noteId '@<key>'");
|
|
531
|
-
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.", {
|
|
532
|
-
name: z.string().describe("Canvas name"),
|
|
533
|
-
goal: z.string().describe(`${CANVAS_GOAL_DESCRIPTION} Required.`),
|
|
534
|
-
targetAudience: z.string().describe("Target audience — who this canvas is meant to serve or inform, and what they do with it. Required."),
|
|
535
|
-
doc: layoutDocArg.optional(),
|
|
536
|
-
notes: layoutNotesArg.optional(),
|
|
537
|
-
intent: intentArg,
|
|
538
|
-
}, async ({ name, goal, targetAudience, doc, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post("/api/canvas", {
|
|
407
|
+
return read.markdown;
|
|
408
|
+
}, { text: true }));
|
|
409
|
+
sharedTool("cnotes_canvas_create", async ({ name, goal, targetAudience, doc, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post("/api/canvas", {
|
|
539
410
|
workspaceId,
|
|
540
411
|
title: name,
|
|
541
412
|
goal,
|
|
@@ -543,13 +414,7 @@ server.tool("cnotes_canvas_create", "Create a new canvas. Goal and target audien
|
|
|
543
414
|
...(doc ? { doc } : {}),
|
|
544
415
|
...(notes ? { notes } : {}),
|
|
545
416
|
}))));
|
|
546
|
-
|
|
547
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
548
|
-
title: z.string().optional().describe("New canvas title"),
|
|
549
|
-
goal: z.string().optional().describe(CANVAS_GOAL_DESCRIPTION),
|
|
550
|
-
targetAudience: z.string().optional().describe("Target audience — who this canvas is meant to serve or inform, and what they do with it"),
|
|
551
|
-
intent: intentArg,
|
|
552
|
-
}, async ({ canvasId, title, goal, targetAudience, intent }) => {
|
|
417
|
+
sharedTool("cnotes_canvas_update", async ({ canvasId, title, goal, targetAudience, intent }) => {
|
|
553
418
|
if (!title && !goal && !targetAudience) {
|
|
554
419
|
return err("at least one of title, goal, or targetAudience is required");
|
|
555
420
|
}
|
|
@@ -565,23 +430,22 @@ server.tool("cnotes_canvas_update", "Update canvas metadata: title, goal, and/or
|
|
|
565
430
|
server.tool("cnotes_canvas_delete", "Delete a canvas.", {
|
|
566
431
|
canvasId: z.string().describe("Canvas ID"),
|
|
567
432
|
intent: intentArg,
|
|
568
|
-
}, async ({ canvasId, intent }) => withErrorHandling(() => inRun(intent, () => api.delete(
|
|
433
|
+
}, async ({ canvasId, intent }) => withErrorHandling(() => inRun(intent, () => api.delete(canvasPath(canvasId)))));
|
|
569
434
|
server.tool("cnotes_canvas_archive", "Archive or unarchive a canvas. Archiving is a soft delete (sets archivedAt timestamp). Use unarchive=true to restore.", {
|
|
570
435
|
canvasId: z.string().describe("Canvas ID"),
|
|
571
436
|
unarchive: z.boolean().optional().default(false).describe("Set true to unarchive/restore instead of archive"),
|
|
572
437
|
intent: intentArg,
|
|
573
|
-
}, async ({ canvasId, unarchive, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
438
|
+
}, async ({ canvasId, unarchive, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
574
439
|
action: unarchive ? "unarchive" : "archive",
|
|
575
440
|
}))));
|
|
576
441
|
server.tool("cnotes_canvas_set_home", "Set a canvas as the workspace home/default canvas. Clears any previous home canvas.", {
|
|
577
442
|
canvasId: z.string().describe("Canvas ID to set as home"),
|
|
578
|
-
}, async ({ canvasId }) => withErrorHandling(() => api.post(
|
|
443
|
+
}, async ({ canvasId }) => withErrorHandling(() => api.post(canvasPath(canvasId), { action: "setAsHome" })));
|
|
579
444
|
// --- Deprecated single-item wrappers ---
|
|
580
445
|
// Kept for backward compatibility with existing MCP clients. Without x/y the
|
|
581
446
|
// item goes through the solver (placeLayout): clear of everything, or INTO a
|
|
582
447
|
// section, where it joins the section's layout and the section re-arranges.
|
|
583
448
|
// x/y place it raw, with no collision check.
|
|
584
|
-
const canvasPath = (canvasId) => `/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`;
|
|
585
449
|
const addOne = (canvasId, leaf, at, section, raw) => {
|
|
586
450
|
if (at.x !== undefined && at.y !== undefined)
|
|
587
451
|
return raw();
|
|
@@ -607,7 +471,7 @@ server.tool("cnotes_canvas_add_node", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
607
471
|
x: RAW_X,
|
|
608
472
|
y: RAW_Y,
|
|
609
473
|
intent: intentArg,
|
|
610
|
-
}, async ({ canvasId, noteId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "note", noteId }, { x, y }, section, () => api.post(
|
|
474
|
+
}, async ({ canvasId, noteId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "note", noteId }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
611
475
|
action: "bulkAddNodes",
|
|
612
476
|
items: [{ type: "note", noteId, positionX: x, positionY: y }],
|
|
613
477
|
})))));
|
|
@@ -626,7 +490,7 @@ const textElementSchema = {
|
|
|
626
490
|
y: RAW_Y,
|
|
627
491
|
intent: intentArg,
|
|
628
492
|
};
|
|
629
|
-
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(
|
|
493
|
+
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), {
|
|
630
494
|
action: "bulkAddNodes",
|
|
631
495
|
items: [{ type: "richtext", content, size, colorHex: color, positionX: x, positionY: y }],
|
|
632
496
|
}))));
|
|
@@ -643,7 +507,7 @@ server.tool("cnotes_canvas_add_list", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
643
507
|
intent: intentArg,
|
|
644
508
|
}, async ({ canvasId, description, noteIds, viewMode, section, x, y, intent }) => withErrorHandling(() => {
|
|
645
509
|
const ids = noteIds ? noteIds.split(",").map((id) => id.trim()) : undefined;
|
|
646
|
-
return inRun(intent, () => addOne(canvasId, { type: "list", description, viewMode, ...(ids ? { noteIds: ids } : {}) }, { x, y }, section, () => api.post(
|
|
510
|
+
return inRun(intent, () => addOne(canvasId, { type: "list", description, viewMode, ...(ids ? { noteIds: ids } : {}) }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
647
511
|
action: "bulkAddNodes",
|
|
648
512
|
items: [{ type: "list", description, viewMode, noteIds: ids, positionX: x, positionY: y }],
|
|
649
513
|
})));
|
|
@@ -655,7 +519,7 @@ server.tool("cnotes_canvas_add_link", "[Deprecated: use cnotes_canvas_place] Add
|
|
|
655
519
|
x: RAW_X,
|
|
656
520
|
y: RAW_Y,
|
|
657
521
|
intent: intentArg,
|
|
658
|
-
}, async ({ canvasId, targetCanvasId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "canvas", linkedCanvasId: targetCanvasId }, { x, y }, section, () => api.post(
|
|
522
|
+
}, async ({ canvasId, targetCanvasId, section, x, y, intent }) => withErrorHandling(() => inRun(intent, () => addOne(canvasId, { type: "canvas", linkedCanvasId: targetCanvasId }, { x, y }, section, () => api.post(canvasPath(canvasId), {
|
|
659
523
|
action: "bulkAddNodes",
|
|
660
524
|
items: [{ type: "canvas", linkedCanvasId: targetCanvasId, positionX: x, positionY: y }],
|
|
661
525
|
})))));
|
|
@@ -741,21 +605,12 @@ server.tool("cnotes_canvas_bulk_add", "LOW-LEVEL: add items at raw x/y that YOU
|
|
|
741
605
|
return { ...rest, positionX: x, positionY: y };
|
|
742
606
|
}),
|
|
743
607
|
];
|
|
744
|
-
return inRun(intent, () => api.post(
|
|
608
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
745
609
|
action: "bulkAddNodes",
|
|
746
610
|
items: allItems,
|
|
747
611
|
}));
|
|
748
612
|
}));
|
|
749
|
-
|
|
750
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
751
|
-
doc: layoutDocArg,
|
|
752
|
-
intoSection: z
|
|
753
|
-
.string()
|
|
754
|
-
.optional()
|
|
755
|
-
.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."),
|
|
756
|
-
notes: layoutNotesArg.optional(),
|
|
757
|
-
intent: intentArg,
|
|
758
|
-
}, async ({ canvasId, doc, intoSection, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post(`/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`, {
|
|
613
|
+
sharedTool("cnotes_canvas_place", async ({ canvasId, doc, intoSection, notes, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
759
614
|
action: "placeLayout",
|
|
760
615
|
doc,
|
|
761
616
|
...(intoSection ? { intoSection } : {}),
|
|
@@ -791,7 +646,7 @@ server.tool("cnotes_canvas_arrange", "Reflow EXISTING canvas nodes with the layo
|
|
|
791
646
|
.describe("Solve and preview without moving anything."),
|
|
792
647
|
intent: intentArg,
|
|
793
648
|
}, async ({ canvasId, doc, targetSectionId, autoResize, dryRun, intent }) => {
|
|
794
|
-
const arrange = () => api.post(
|
|
649
|
+
const arrange = () => api.post(canvasPath(canvasId), {
|
|
795
650
|
action: "arrangeLayout",
|
|
796
651
|
doc,
|
|
797
652
|
...(targetSectionId ? { targetSectionId } : {}),
|
|
@@ -810,7 +665,7 @@ server.tool("cnotes_canvas_bulk_move", "Move multiple nodes to new positions in
|
|
|
810
665
|
y: z.number().describe("New Y position"),
|
|
811
666
|
})).describe("Array of node moves"),
|
|
812
667
|
intent: intentArg,
|
|
813
|
-
}, async ({ canvasId, moves, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
668
|
+
}, async ({ canvasId, moves, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
814
669
|
action: "bulkMoveNodes",
|
|
815
670
|
moves: moves.map((m) => ({
|
|
816
671
|
nodeId: m.nodeId,
|
|
@@ -837,28 +692,14 @@ inRun(intent, () =>
|
|
|
837
692
|
// ?workspaceId= is not decoration: a "CANVAS-12" handle is only
|
|
838
693
|
// resolvable against a workspace on the Bearer path, so without it this
|
|
839
694
|
// 400s for exactly the callers the description tells to use display ids.
|
|
840
|
-
api.post(
|
|
695
|
+
api.post(canvasPath(canvasId), {
|
|
841
696
|
action: "bulkRemoveNodes",
|
|
842
697
|
nodeIds: nodeIds ?? [],
|
|
843
698
|
edgeIds: edgeIds ?? [],
|
|
844
699
|
}), canvasId)));
|
|
845
|
-
|
|
846
|
-
canvasId: z.string().describe("Canvas ID"),
|
|
847
|
-
sourceNodeId: z.string().describe("Source node ID"),
|
|
848
|
-
targetNodeId: z.string().describe("Target node ID"),
|
|
849
|
-
label: z.string().optional().describe("Edge label"),
|
|
850
|
-
arrow: z
|
|
851
|
-
.enum(["end", "start", "both", "none"])
|
|
852
|
-
.optional()
|
|
853
|
-
.describe("Arrow direction (default: end)"),
|
|
854
|
-
lineStyle: z
|
|
855
|
-
.enum(["solid", "dashed"])
|
|
856
|
-
.optional()
|
|
857
|
-
.describe("Line style (default: solid)"),
|
|
858
|
-
intent: intentArg,
|
|
859
|
-
}, async ({ canvasId, sourceNodeId, targetNodeId, label, arrow, lineStyle, intent }) => withErrorHandling(() => {
|
|
700
|
+
sharedTool("cnotes_canvas_add_edge", async ({ canvasId, sourceNodeId, targetNodeId, label, arrow, lineStyle, intent }) => withErrorHandling(() => {
|
|
860
701
|
const markers = arrowToMarkers(arrow);
|
|
861
|
-
return inRun(intent, () => api.post(
|
|
702
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
862
703
|
action: "addEdge",
|
|
863
704
|
sourceNodeId,
|
|
864
705
|
targetNodeId,
|
|
@@ -895,56 +736,17 @@ server.tool("cnotes_canvas_update_edge", "Update an edge: change its label, togg
|
|
|
895
736
|
body.lineStyle = lineStyle;
|
|
896
737
|
if (reverse !== undefined)
|
|
897
738
|
body.reverse = reverse;
|
|
898
|
-
return inRun(intent, () => api.post(
|
|
739
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), body));
|
|
899
740
|
}));
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
height: z.number().optional().describe("New frame height in px"),
|
|
910
|
-
colorHex: z
|
|
911
|
-
.string()
|
|
912
|
-
.optional()
|
|
913
|
-
.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"),
|
|
914
|
-
arrange: z
|
|
915
|
-
.boolean()
|
|
916
|
-
.optional()
|
|
917
|
-
.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."),
|
|
918
|
-
intent: intentArg,
|
|
919
|
-
}, async ({ canvasId, sectionId, name, x, y, width, height, colorHex, arrange, intent }) => withErrorHandling(() => {
|
|
920
|
-
if (arrange !== undefined) {
|
|
921
|
-
if ([name, x, y, width, height, colorHex].some((v) => v !== undefined)) {
|
|
922
|
-
throw new Error("Arrange is its own call: send arrange alone, then any other change in a second call.");
|
|
923
|
-
}
|
|
924
|
-
return inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
925
|
-
action: "arrangeSection",
|
|
926
|
-
sectionId,
|
|
927
|
-
...(arrange ? {} : { stop: true }),
|
|
928
|
-
}));
|
|
929
|
-
}
|
|
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));
|
|
741
|
+
sharedTool("cnotes_canvas_update_section", async ({ canvasId, intent, ...args }) => withErrorHandling(() => {
|
|
742
|
+
// arrange, a move (x/y, which carries the cards inside the frame) or an
|
|
743
|
+
// in-place update: the same rule as the remote connector (lib/mcp-spec.ts).
|
|
744
|
+
const plan = planSectionTool(args);
|
|
745
|
+
if (!plan.ok)
|
|
746
|
+
throw new CliError(refusalText(plan));
|
|
747
|
+
// A move rewrites where existing cards sit, so its run is bracketed
|
|
748
|
+
// with a canvas checkpoint.
|
|
749
|
+
return inRun(intent, () => api.post(canvasPath(canvasId), plan.value.body), plan.value.kind === "move" ? canvasId : undefined);
|
|
948
750
|
}));
|
|
949
751
|
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
752
|
canvasId: z.string().describe("Canvas ID"),
|
|
@@ -956,7 +758,7 @@ server.tool("cnotes_canvas_move_node", "LOW-LEVEL: move one node to raw x/y, wit
|
|
|
956
758
|
}, async ({ canvasId, nodeId, nodeType, x, y, intent }) => withErrorHandling(() => inRun(intent, () =>
|
|
957
759
|
// workspaceId lets the server resolve CANVAS-<n> and read the layout
|
|
958
760
|
// for its overlap check.
|
|
959
|
-
api.post(
|
|
761
|
+
api.post(canvasPath(canvasId), {
|
|
960
762
|
action: "moveNode",
|
|
961
763
|
nodeId,
|
|
962
764
|
nodeType,
|
|
@@ -967,7 +769,7 @@ server.tool("cnotes_canvas_remove_node", "Remove a node from a canvas.", {
|
|
|
967
769
|
canvasId: z.string().describe("Canvas ID"),
|
|
968
770
|
nodeId: z.string().describe("Canvas node ID"),
|
|
969
771
|
intent: intentArg,
|
|
970
|
-
}, async ({ canvasId, nodeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
772
|
+
}, async ({ canvasId, nodeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
971
773
|
action: "removeNode",
|
|
972
774
|
nodeId,
|
|
973
775
|
}), canvasId)));
|
|
@@ -975,7 +777,7 @@ server.tool("cnotes_canvas_remove_edge", "Remove an edge from a canvas.", {
|
|
|
975
777
|
canvasId: z.string().describe("Canvas ID"),
|
|
976
778
|
edgeId: z.string().describe("Canvas edge ID"),
|
|
977
779
|
intent: intentArg,
|
|
978
|
-
}, async ({ canvasId, edgeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(
|
|
780
|
+
}, async ({ canvasId, edgeId, intent }) => withErrorHandling(() => inRun(intent, () => api.post(canvasPath(canvasId), {
|
|
979
781
|
action: "removeEdge",
|
|
980
782
|
edgeId,
|
|
981
783
|
}), canvasId)));
|
|
@@ -1208,29 +1010,7 @@ server.tool("cnotes_review_complete", 'Record a review\'s one structured outcome
|
|
|
1208
1010
|
// overlays them on recorded attention; kept/missed is derived, so there is
|
|
1209
1011
|
// deliberately no "complete" tool.
|
|
1210
1012
|
// ---------------------------------------------------------------------------
|
|
1211
|
-
|
|
1212
|
-
start: z
|
|
1213
|
-
.string()
|
|
1214
|
-
.describe('Start time: ISO 8601 local (e.g. "2026-07-26T09:00") or "HH:MM" for the next occurrence of that time'),
|
|
1215
|
-
durationMinutes: z
|
|
1216
|
-
.number()
|
|
1217
|
-
.min(1)
|
|
1218
|
-
.max(720)
|
|
1219
|
-
.describe("Block length in minutes (e.g. 90). Quality flow blocks are typically 60-120."),
|
|
1220
|
-
goal: z
|
|
1221
|
-
.string()
|
|
1222
|
-
.min(1)
|
|
1223
|
-
.max(500)
|
|
1224
|
-
.describe("Why this block exists — shown goal-first in the user's calendar"),
|
|
1225
|
-
canvas: z
|
|
1226
|
-
.string()
|
|
1227
|
-
.optional()
|
|
1228
|
-
.describe('Prepared orientation canvas ("CANVAS-12" or a canvas id)'),
|
|
1229
|
-
target: z
|
|
1230
|
-
.string()
|
|
1231
|
-
.optional()
|
|
1232
|
-
.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.'),
|
|
1233
|
-
}, async ({ start, durationMinutes, goal, canvas, target }) => withErrorHandling(() => {
|
|
1013
|
+
sharedTool("cnotes_focus_plan", async ({ start, durationMinutes, goal, canvas, target }) => withErrorHandling(() => {
|
|
1234
1014
|
const startMs = parseFocusStart(start, Date.now());
|
|
1235
1015
|
return api.post("/api/focus", {
|
|
1236
1016
|
workspaceId,
|
|
@@ -1238,25 +1018,10 @@ server.tool("cnotes_focus_plan", "Plan a protected flow-state focus block for th
|
|
|
1238
1018
|
endMs: startMs + Math.round(durationMinutes * 60_000),
|
|
1239
1019
|
goal,
|
|
1240
1020
|
...(canvas ? { canvas } : {}),
|
|
1241
|
-
...(target ? { target
|
|
1021
|
+
...(target ? { target } : {}),
|
|
1242
1022
|
});
|
|
1243
1023
|
}));
|
|
1244
|
-
|
|
1245
|
-
days: z
|
|
1246
|
-
.number()
|
|
1247
|
-
.min(0)
|
|
1248
|
-
.max(90)
|
|
1249
|
-
.optional()
|
|
1250
|
-
.default(7)
|
|
1251
|
-
.describe("Days ahead to include"),
|
|
1252
|
-
pastDays: z
|
|
1253
|
-
.number()
|
|
1254
|
-
.min(0)
|
|
1255
|
-
.max(90)
|
|
1256
|
-
.optional()
|
|
1257
|
-
.default(0)
|
|
1258
|
-
.describe("Also include this many past days"),
|
|
1259
|
-
}, async ({ days, pastDays }) => withErrorHandling(() => {
|
|
1024
|
+
sharedTool("cnotes_focus_list", async ({ days, pastDays }) => withErrorHandling(() => {
|
|
1260
1025
|
const todayStart = new Date();
|
|
1261
1026
|
todayStart.setHours(0, 0, 0, 0);
|
|
1262
1027
|
const from = todayStart.getTime() - (pastDays ?? 0) * 86_400_000;
|
|
@@ -1267,9 +1032,7 @@ server.tool("cnotes_focus_list", "List the user's planned focus blocks (today on
|
|
|
1267
1032
|
to: String(to),
|
|
1268
1033
|
});
|
|
1269
1034
|
}));
|
|
1270
|
-
|
|
1271
|
-
planId: z.string().describe("Plan id (from cnotes_focus_list)"),
|
|
1272
|
-
}, async ({ planId }) => withErrorHandling(() => api.delete(`/api/focus?workspaceId=${encodeURIComponent(workspaceId)}&planId=${encodeURIComponent(planId)}`)));
|
|
1035
|
+
sharedTool("cnotes_focus_cancel", async ({ planId }) => withErrorHandling(() => api.delete(`/api/focus?workspaceId=${encodeURIComponent(workspaceId)}&planId=${encodeURIComponent(planId)}`)));
|
|
1273
1036
|
const DURATION_UNITS = {
|
|
1274
1037
|
m: 60_000,
|
|
1275
1038
|
h: 3_600_000,
|
|
@@ -1293,7 +1056,7 @@ function parseDuration(input) {
|
|
|
1293
1056
|
// ---------------------------------------------------------------------------
|
|
1294
1057
|
// Types (supertags)
|
|
1295
1058
|
// ---------------------------------------------------------------------------
|
|
1296
|
-
|
|
1059
|
+
sharedTool("cnotes_types_list", async () => withErrorHandling(() => api.get("/api/supertags", { workspaceId })));
|
|
1297
1060
|
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.", {
|
|
1298
1061
|
name: z.string().describe("Type name (e.g. 'Decision', 'Insight')"),
|
|
1299
1062
|
}, async ({ name }) => withErrorHandling(async () => {
|