@creator-notes/cnotes 0.121.3 → 0.121.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creator-notes-cli",
3
- "version": "0.121.3",
3
+ "version": "0.121.5",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -5,16 +5,9 @@ import { resolveConfig } from "../lib/config.js";
5
5
  import { handleError, ValidationError, ApiError, CliError, EXIT_CODES, } from "../lib/errors.js";
6
6
  import { outputJson, outputQuiet } from "../lib/output.js";
7
7
  import { extractStorageId } from "../lib/storage-id.js";
8
- import { unsupportedImageTypeMessage } from "../lib/image-types.js";
8
+ import { UPLOAD_MIME_BY_EXT, unsupportedImageTypeMessage } from "../lib/image-types.js";
9
9
  const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
10
- const MIME_MAP = {
11
- ".jpg": "image/jpeg",
12
- ".jpeg": "image/jpeg",
13
- ".png": "image/png",
14
- ".gif": "image/gif",
15
- ".webp": "image/webp",
16
- };
17
- // Reverse of MIME_MAP plus a few extra read-only types, for naming downloads.
10
+ // Reverse of UPLOAD_MIME_BY_EXT plus a few extra read-only types, for naming downloads.
18
11
  const EXT_BY_MIME = {
19
12
  "image/jpeg": "jpg",
20
13
  "image/png": "png",
@@ -24,7 +17,7 @@ const EXT_BY_MIME = {
24
17
  };
25
18
  function getMimeType(filePath) {
26
19
  const ext = path.extname(filePath).toLowerCase();
27
- return MIME_MAP[ext];
20
+ return UPLOAD_MIME_BY_EXT[ext];
28
21
  }
29
22
  function formatBytes(bytes) {
30
23
  if (bytes < 1024)
@@ -16,6 +16,8 @@ import { formatDoneParts } from "../lib/done-parts.js";
16
16
  * every run re-reads the graph, so the tree cannot drift from the notes.
17
17
  */
18
18
  const MAX_GOALS = 100;
19
+ /** Goals read side by side while walking the tree. */
20
+ const LOAD_AT_ONCE = 8;
19
21
  const isGoalType = (type) => typeof type === "string" && type.trim().toLowerCase() === "goal";
20
22
  async function loadGoal(api, workspaceId, displayId) {
21
23
  const [notes, rels, placed] = await Promise.all([
@@ -115,17 +117,23 @@ Examples:
115
117
  if (!isGoalType(root.type)) {
116
118
  throw new ValidationError(`${displayId} is a ${root.type || "untyped"} note. A goal tree starts at a Goal note; create one with \`cnotes notes create --type Goal\`.`);
117
119
  }
120
+ // Breadth first, a few goals at a time: each goal is three or four
121
+ // reads, so one at a time made a 20-goal tree 60+ round trips in a row.
118
122
  const nodes = new Map([[root.displayId, root]]);
119
- const queue = [...root.children];
123
+ let queue = [...root.children];
120
124
  while (queue.length > 0 && nodes.size < MAX_GOALS) {
121
- const id = queue.shift();
122
- if (nodes.has(id))
123
- continue;
124
- const node = await loadGoal(api, cfg.workspaceId, id);
125
- if (!node)
126
- continue;
127
- nodes.set(id, node);
128
- queue.push(...node.children.filter((c) => !nodes.has(c)));
125
+ const batch = [...new Set(queue.filter((id) => !nodes.has(id)))].slice(0, Math.min(LOAD_AT_ONCE, MAX_GOALS - nodes.size));
126
+ if (batch.length === 0)
127
+ break;
128
+ queue = queue.filter((id) => !nodes.has(id) && !batch.includes(id));
129
+ const loaded = await Promise.all(batch.map((id) => loadGoal(api, cfg.workspaceId, id)));
130
+ batch.forEach((id, i) => {
131
+ const node = loaded[i];
132
+ if (!node || nodes.has(id))
133
+ return;
134
+ nodes.set(id, node);
135
+ queue.push(...node.children.filter((c) => !nodes.has(c)));
136
+ });
129
137
  }
130
138
  const view = deriveGoalTree(root.displayId, nodes);
131
139
  if (nodes.size >= MAX_GOALS)
@@ -343,29 +343,6 @@ export function listOpenAgentRuns(config, serverUrl) {
343
343
  }))
344
344
  .sort((a, b) => a.startedAt - b.startedAt);
345
345
  }
346
- /**
347
- * Clear the active agent-run for a server. Called by `cnotes operations end` /
348
- * `cnotes canvas agent-run end` after a successful close, so the next cnotes
349
- * write reverts to "unattached" unless the user opens a new run.
350
- */
351
- export function clearActiveAgentRunId(config, serverUrl) {
352
- mutateServerConfig(config, serverUrl, (sc) => {
353
- if (!(sc.activeAgentRunId || sc.activeAgentRunStartedAt || sc.activeAgentBeforeSnapshotId)) {
354
- return false;
355
- }
356
- // The active run has ended, so it leaves the open-run registry with the
357
- // pointer. Detached runs in the registry are untouched: they are other
358
- // agents' business.
359
- if (sc.activeAgentRunId && sc.agentRuns && sc.activeAgentRunId in sc.agentRuns) {
360
- delete sc.agentRuns[sc.activeAgentRunId];
361
- if (Object.keys(sc.agentRuns).length === 0)
362
- delete sc.agentRuns;
363
- }
364
- delete sc.activeAgentRunId;
365
- delete sc.activeAgentRunStartedAt;
366
- delete sc.activeAgentBeforeSnapshotId;
367
- });
368
- }
369
346
  /**
370
347
  * Read the active agent-run for a server (if any). `beforeSnapshotId` is
371
348
  * present only for canvas runs (see the field docs on ServerConfig).
@@ -1,3 +1,11 @@
1
+ /** The image types the server stores, by extension: what `files upload` and `cnotes_files_upload` send. */
2
+ export const UPLOAD_MIME_BY_EXT = {
3
+ ".jpg": "image/jpeg",
4
+ ".jpeg": "image/jpeg",
5
+ ".png": "image/png",
6
+ ".gif": "image/gif",
7
+ ".webp": "image/webp",
8
+ };
1
9
  /**
2
10
  * The refusal `files upload` and the stdio MCP server's `cnotes_files_upload`
3
11
  * give for a file the server will not store. SVG gets its own reason because
@@ -11,5 +19,5 @@ export function unsupportedImageTypeMessage(ext) {
11
19
  return ("SVG isn't accepted, because an SVG file can carry scripts. Convert it to PNG first " +
12
20
  "(for example `rsvg-convert -o diagram.png diagram.svg`) and upload the PNG.");
13
21
  }
14
- return `Unsupported file type: ${ext}. Allowed: .jpg, .jpeg, .png, .gif, .webp`;
22
+ return `Unsupported file type: ${ext}. Allowed: ${Object.keys(UPLOAD_MIME_BY_EXT).join(", ")}`;
15
23
  }
@@ -168,29 +168,6 @@ export function gradeFromStored(note) {
168
168
  gradedBy: stored.gradedBy,
169
169
  };
170
170
  }
171
- /** @deprecated Server Check quality responses. Kept so a stored body still maps. */
172
- export function gradeFromResponse(body) {
173
- if (body.outcome === "graded" && typeof body.level === "number") {
174
- return {
175
- outcome: "graded",
176
- level: body.level,
177
- label: LADDER_LABELS[body.level] ?? `Level ${body.level}`,
178
- isTopRung: body.level >= LADDER_TOP,
179
- feedback: String(body.feedback ?? ""),
180
- nextStep: String(body.nextStep ?? ""),
181
- suggestions: Array.isArray(body.suggestions) ? body.suggestions.map(String) : [],
182
- criteria: readCriteria(body.criteria),
183
- gradedBy: typeof body.gradedBy === "string" ? body.gradedBy : null,
184
- };
185
- }
186
- if (body.outcome === "needs_agent") {
187
- return { outcome: "needs_agent", reason: String(body.reason ?? AGENT_GRADE_INSTRUCTION) };
188
- }
189
- return {
190
- outcome: "skipped",
191
- reason: String(body.reason ?? body.skipReason ?? "not graded"),
192
- };
193
- }
194
171
  /** The payload handed to the calling agent: rubric, note, and how to record. */
195
172
  export function gradeRequestFor(note, rubric) {
196
173
  const criteriaExample = JSON.stringify([{ criterion: "<name>", reason: "<why>" }]);
@@ -39,7 +39,7 @@ import { runQuery } from "./commands/query.js";
39
39
  import { inToolRun } from "./lib/mcp-run.js";
40
40
  import { isLocalDbEnabled } from "./lib/auth-store.js";
41
41
  import { explainTruncation, listNotes, SERVER_LIST_CAP } from "./lib/notes-list.js";
42
- import { unsupportedImageTypeMessage } from "./lib/image-types.js";
42
+ import { UPLOAD_MIME_BY_EXT, unsupportedImageTypeMessage } from "./lib/image-types.js";
43
43
  // ---------------------------------------------------------------------------
44
44
  // Environment
45
45
  // ---------------------------------------------------------------------------
@@ -1449,13 +1449,6 @@ api.post(`/api/workspaces/${workspaceId}/trial`, { source: "mcp-stdio" })));
1449
1449
  // ---------------------------------------------------------------------------
1450
1450
  // Files
1451
1451
  // ---------------------------------------------------------------------------
1452
- const FILE_MIME_MAP = {
1453
- ".jpg": "image/jpeg",
1454
- ".jpeg": "image/jpeg",
1455
- ".png": "image/png",
1456
- ".gif": "image/gif",
1457
- ".webp": "image/webp",
1458
- };
1459
1452
  server.tool("cnotes_files_upload", "Upload an image file to the workspace. Returns the public URL. Supports .jpg, .jpeg, .png, .gif, .webp (max 5MB). Convert an SVG to PNG first.", {
1460
1453
  filePath: z.string().describe("Absolute path to the image file on disk"),
1461
1454
  }, async ({ filePath }) => withErrorHandling(async () => {
@@ -1473,7 +1466,7 @@ server.tool("cnotes_files_upload", "Upload an image file to the workspace. Retur
1473
1466
  if (stat.size > 5 * 1024 * 1024)
1474
1467
  throw new Error(`File too large (${stat.size} bytes). Maximum is 5MB.`);
1475
1468
  const ext = path.extname(absPath).toLowerCase();
1476
- const mimeType = FILE_MIME_MAP[ext];
1469
+ const mimeType = UPLOAD_MIME_BY_EXT[ext];
1477
1470
  if (!mimeType)
1478
1471
  throw new Error(unsupportedImageTypeMessage(ext));
1479
1472
  const buffer = readFileSync(absPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.121.3",
3
+ "version": "0.121.5",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,9 +19,9 @@ Every note and canvas you write is context: what the next reader, a teammate or
19
19
  2. **Read before you write.** Past sessions and teammates left context for this task. `cnotes brief "<task>"` returns the notes, canvases and recent changes most relevant to the task. Search notes and canvases separately (they are different corpora): `cnotes search semantic "<topic>"` and `cnotes canvas search "<topic>"`. `cnotes notes get <id> --expand` loads a note with the notes it rests on. Before changing a canvas, `cnotes canvas read <canvasId>`. A Decision or Guide you find may already settle what you were about to propose.
20
20
  3. **Open a run.** `cnotes operations begin --prompt "<the change as a past-tense headline, e.g. Added a risks list to the Q1 roadmap>" --json`, as its own command; check its exit code before writing (a pipe hides it). Every write refuses to run without one. The response carries `typeRubrics`, the same brief, and the proposals waiting on you with any that reword the same note as another (read those first, [references/drafts.md](references/drafts.md) step 8); `-q` prints only the run id, with the proposals on stderr. One canvas per run: end it and begin another before writing to a second canvas.
21
21
  4. **Write to the type's rubric.** Pick the type, run `cnotes types show <Type>`, and author to its rubric. Audience-facing prose (note bodies, banners, pre-reads) goes through [references/humanizer.md](references/humanizer.md) first; transcripts, quotes and other raw capture are stored verbatim.
22
- 5. **Create notes in one batch.** `cnotes notes create --notes '[{"key":"A","type":"Insight","markdownFile":"./a.md"}, ...]'`. Each body starts with a `# h1` (the title). Cross-link inside the batch with `[@A: Title](relationship:<verb>)`. Detail: [references/notes.md](references/notes.md).
22
+ 5. **Create notes in one batch.** `cnotes notes create --notes '[{"key":"A","type":"Insight","markdownFile":"./a.md"}, ...]'`. Each body starts with a `# h1` (the title): a headline of at most 80 characters that names the claim or the object, with no ", so…" / ", because…" clause, no display id and no em dash; the body's first sentence carries the why. The server refuses a note or version whose title breaks this and says what to change. Cross-link inside the batch with `[@A: Title](relationship:<verb>)`. Detail: [references/notes.md](references/notes.md).
23
23
  6. **Grade what you wrote.** `cnotes quality <displayIds...> --fail-below 4`, then revise weak notes with `cnotes versions create <id> --description "<what changed>" --markdown-file <path>`.
24
- 7. **Lay out the canvas.** `cnotes canvas place <canvasId> --spec layout.json` packs items without overlap. A spec can carry the notes too (see the fast path below), which folds steps 5 and 7 into one call. For a new canvas, `canvas create --spec` takes the same spec, so creating the canvas, its notes and its layout is one call. Every canvas opens with a hero: one `large` untinted text card at the top-left, above everything, holding `# <the goal's result>` in under 50 characters, with the four-line banner under it at `medium`. It is the only text legible at zoom-to-fit. Read [references/canvas-elements.md](references/canvas-elements.md) (rules 7 and 9) before choosing elements and [references/canvas-layout.md](references/canvas-layout.md) before writing the spec.
24
+ 7. **Lay out the canvas.** `cnotes canvas place <canvasId> --spec layout.json` packs items without overlap. A spec can carry the notes too (see the fast path below), which folds steps 5 and 7 into one call. For a new canvas, `canvas create --spec` takes the same spec, so creating the canvas, its notes and its layout is one call; its name follows the title rule in step 5 (a short headline, `·` between its parts), and the server refuses one that does not. Every canvas opens with a hero: one `large` untinted text card at the top-left, above everything, holding `# <the goal's result>` in under 50 characters, with the four-line banner under it at `medium`. It is the only text legible at zoom-to-fit. Read [references/canvas-elements.md](references/canvas-elements.md) (rules 7 and 9) before choosing elements and [references/canvas-layout.md](references/canvas-layout.md) before writing the spec.
25
25
  8. **Read it back.** `cnotes canvas read <canvasId>`: every claim must appear in a note with a display ID, the hero must name the goal's result, and the banner must make sense to someone who was not in the session. A write that touches no canvas gets the same test: `cnotes notes get <id> --expand` on what you wrote, read as the next session will, without this conversation.
26
26
  9. **Close the run.** `cnotes operations end`.
27
27
  10. **Link the result.** End your reply with the canvas link (see [Surfacing the canvas link](#surfacing-the-canvas-link)).
@@ -260,7 +260,7 @@ each note is judged again; a new label alone keeps them.
260
260
  cnotes notes create --notes '[{"key":"A","type":"Note","markdownFile":"./note.md"}]'
261
261
  ```
262
262
  - Use inline `markdown` only for short, single-line content.
263
- - **Always start markdown content with a `# h1` heading.** This becomes the note title. Follow proper markdown structure: `## h2` for major sections, `### h3` for subsections. Well-structured heading hierarchy is expected for all notes.
263
+ - **Always start markdown content with a `# h1` heading.** This becomes the note title. **The title is a headline, not a sentence**: at most 80 characters, naming the claim or the object, with no consequence clause (", so…", ", because…", ", which…"), no display id and no em dash. The body's first sentence carries the why. The server refuses an agent's note or version whose title breaks this (`field: "title"` in a batch) and the message says what to change; a person typing in the editor is never refused. Follow proper markdown structure: `## h2` for major sections, `### h3` for subsections. Well-structured heading hierarchy is expected for all notes.
264
264
  - **Relationship mentions in markdown**: Use `[NOTE-123: Title](relationship:<type>)` — plain text "NOTE-123" does NOT create clickable mentions, and the title-less form renders as "Untitled". Match `<type>` to the verb your prose uses (`blocks`, `depends-on`, …); `references` is for pure citations. The typed wiki form `[[blocks::NOTE-123]]` is equivalent — it's how note bodies serialize mentions back to you, and an untyped `[[NOTE-123]]` is a plain reference.
265
265
  - **The classic miss: capturing an answer/outcome that lives in another note.** "The answer is the packaging decision in DECISION-24" saved as plain prose creates no chip, no relationship, no backlink — the graph never learns the question was answered. Write the mention with the verb as its type: `Answered by [DECISION-24: Title](relationship:answered-by)`. `notes create` and `versions create` detect bare IDs that name real notes and return them in `plainTextIdWarnings` (stderr + `--json`), each with a paste-ready rewrite carrying the note's actual title — treat every entry as a fix instruction (save a corrected version) unless the bare ID is deliberate prose.
266
266
  - **Quoting another note's exact words**: write a quote block, the words in a blockquote and a last line citing the version they came from with a `quotes` mention pinned to it. Read the version number and its time from `cnotes versions list <id>`; the words must be that version's, verbatim: