@creator-notes/cnotes 0.149.0 → 0.149.2

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.149.0",
3
+ "version": "0.149.2",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -218,24 +218,36 @@ function placedNothing(data) {
218
218
  allItems.every((r) => !r.id || r.error) &&
219
219
  allEdges.every((e) => !e.id || e.error));
220
220
  }
221
- /** The items and edges the server refused, each with its reason. */
221
+ /**
222
+ * The items and edges the server refused, each with its reason, and the
223
+ * sections that could not arrange themselves after the placement. A failed
224
+ * section names only its raw id: the route gives a display id on success.
225
+ */
222
226
  function refusedRows(data) {
223
227
  const allItems = (data.items || []);
224
228
  const allEdges = (data.edges || []);
229
+ const arranged = (data.arrangedSections || []);
225
230
  const reason = (r) => String(r.error ?? "not placed");
226
231
  return {
227
232
  items: allItems.filter((r) => !r.id || r.error).map((r) => ({ index: r.index, type: r.type, error: reason(r) })),
228
233
  edges: allEdges.filter((e) => !e.id || e.error).map((e) => ({ from: e.from, to: e.to, error: reason(e) })),
234
+ sections: arranged
235
+ .filter((a) => a.error)
236
+ .map((a) => ({ sectionId: String(a.displayId ?? a.sectionId), error: String(a.error) })),
229
237
  total: allItems.length + allEdges.length,
230
238
  };
231
239
  }
232
- /** True when some, not all, of a (non-dry-run) placeLayout's items and edges were refused. */
240
+ /**
241
+ * True when a (non-dry-run) placeLayout landed only in part: some, not all,
242
+ * of its items and edges were refused, or a section it framed or placed into
243
+ * could not arrange itself (a framed one will not re-lay itself as cards
244
+ * change; one placed INTO leaves the new cards outside it).
245
+ */
233
246
  function placedSome(data) {
234
- if (data.dryRun)
247
+ if (data.dryRun || placedNothing(data))
235
248
  return false;
236
249
  const refused = refusedRows(data);
237
- const failed = refused.items.length + refused.edges.length;
238
- return failed > 0 && failed < refused.total;
250
+ return refused.items.length + refused.edges.length > 0 || refused.sections.length > 0;
239
251
  }
240
252
  const PARTIAL_PLACE_HINT = "The rest were placed and any new notes exist: do not re-run the spec, it would duplicate them. " +
241
253
  'Fix each refused item on its own: a quote with `cnotes canvas add-quote <canvas> --note <id> --text "<words>" --title "<headline>"`, ' +
@@ -246,23 +258,40 @@ function partialPlaceSummary(data) {
246
258
  const edges = (data.edges || []);
247
259
  const parts = [];
248
260
  if (refused.items.length > 0)
249
- parts.push(`${refused.items.length} of ${items.length} items`);
261
+ parts.push(`${refused.items.length} of ${items.length} items were refused`);
250
262
  if (refused.edges.length > 0)
251
- parts.push(`${refused.edges.length} of ${edges.length} edges`);
252
- return parts.join(" and ");
263
+ parts.push(`${refused.edges.length} of ${edges.length} edges were refused`);
264
+ for (const section of refused.sections) {
265
+ parts.push(`section ${section.sectionId} could not arrange itself (${section.error})`);
266
+ }
267
+ return parts.join(", and ");
268
+ }
269
+ /** The fix for this shortfall: the refused items one by one, each unarranged section by arrange. */
270
+ function partialPlaceHint(data) {
271
+ const refused = refusedRows(data);
272
+ const parts = [];
273
+ if (refused.items.length + refused.edges.length > 0)
274
+ parts.push(PARTIAL_PLACE_HINT);
275
+ else
276
+ parts.push("Every card landed: do not re-run the spec, it would duplicate them.");
277
+ for (const section of refused.sections) {
278
+ parts.push(`Arrange ${section.sectionId} with \`cnotes canvas arrange <canvas> --section ${section.sectionId}\` once the cause is fixed.`);
279
+ }
280
+ return parts.join(" ");
253
281
  }
254
282
  function reportPartialPlaceJson(data) {
255
283
  const refused = refusedRows(data);
256
284
  console.error(JSON.stringify({
257
- error: `placeLayout refused ${partialPlaceSummary(data)}; the rest were placed`,
285
+ error: `placeLayout landed only in part: ${partialPlaceSummary(data)}`,
258
286
  code: "PlacePartial",
259
287
  exitCode: EXIT_CODES.VALIDATION,
260
288
  ...(refused.items.length > 0 ? { failed: refused.items } : {}),
261
289
  ...(refused.edges.length > 0 ? { failedEdges: refused.edges } : {}),
262
- hint: PARTIAL_PLACE_HINT,
290
+ ...(refused.sections.length > 0 ? { failedSections: refused.sections } : {}),
291
+ hint: partialPlaceHint(data),
263
292
  }));
264
293
  }
265
- /** Set the exit code a placeLayout result earns: 1 when nothing was placed, 3 when some of it was refused. */
294
+ /** Set the exit code a placeLayout result earns: 1 when nothing was placed, 3 when it landed only in part. */
266
295
  function setPlaceExitCode(data) {
267
296
  if (placedNothing(data))
268
297
  process.exitCode = EXIT_CODES.GENERIC;
@@ -278,7 +307,7 @@ function reportPlaceShortfall(data, json) {
278
307
  reportPartialPlaceJson(data);
279
308
  }
280
309
  else if (placedSome(data)) {
281
- console.error(`Error: ${partialPlaceSummary(data)} were not placed (see above). ${PARTIAL_PLACE_HINT}`);
310
+ console.error(`Error: the layout landed only in part: ${partialPlaceSummary(data)} (see above). ${partialPlaceHint(data)}`);
282
311
  }
283
312
  }
284
313
  function arrangeShortfall(data) {
@@ -295,9 +324,10 @@ function arrangeShortfall(data) {
295
324
  const nothing = items.length > 0 && failed.length === items.length;
296
325
  return {
297
326
  nothing,
298
- partial: !nothing && (failed.length > 0 || rippleError !== undefined),
327
+ partial: !nothing && (failed.length > 0 || rippleError !== undefined || keepError !== undefined),
299
328
  failed,
300
329
  total: items.length,
330
+ section: typeof data.targetSectionDisplayId === "string" ? data.targetSectionDisplayId : "the section",
301
331
  ...(rippleError !== undefined ? { rippleError } : {}),
302
332
  ...(keepError !== undefined ? { keepError } : {}),
303
333
  };
@@ -312,6 +342,9 @@ function arrangePartialSummary(shortfall) {
312
342
  parts.push(`${shortfall.failed.length} of ${shortfall.total} items were refused`);
313
343
  if (shortfall.rippleError !== undefined)
314
344
  parts.push(`the band below was not pushed down (${shortfall.rippleError})`);
345
+ if (shortfall.keepError !== undefined) {
346
+ parts.push(`${shortfall.section} could not keep itself arranged (${shortfall.keepError}), so it will not re-lay itself as cards change`);
347
+ }
315
348
  return parts.join(", and ");
316
349
  }
317
350
  /** Set arrange's exit code and print its shortfall on stderr, in the output mode in use. */
@@ -319,11 +352,6 @@ function reportArrangeShortfall(data, json) {
319
352
  const shortfall = arrangeShortfall(data);
320
353
  if (!shortfall)
321
354
  return;
322
- if (shortfall.keepError !== undefined) {
323
- const section = String(data.targetSectionDisplayId ?? "The section");
324
- console.error(`⚠ ${section} could not keep itself arranged: ${shortfall.keepError}. ` +
325
- "The layout landed, but the frame will not re-lay itself as cards change.");
326
- }
327
355
  if (shortfall.nothing) {
328
356
  process.exitCode = EXIT_CODES.GENERIC;
329
357
  if (json) {
@@ -348,6 +376,7 @@ function reportArrangeShortfall(data, json) {
348
376
  exitCode: EXIT_CODES.VALIDATION,
349
377
  ...(shortfall.failed.length > 0 ? { failed: shortfall.failed } : {}),
350
378
  ...(shortfall.rippleError !== undefined ? { rippleError: shortfall.rippleError } : {}),
379
+ ...(shortfall.keepError !== undefined ? { keepError: shortfall.keepError } : {}),
351
380
  hint: ARRANGE_PARTIAL_HINT,
352
381
  }));
353
382
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.149.0",
3
+ "version": "0.149.2",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@ Read this before putting more than one item on a canvas. Describe structure; the
20
20
 
21
21
  The server measures every item, packs them into a no-overlap layout, and inserts them in a single batch. You describe **structure** (rows, columns, what's near what), the server resolves pixels. This is what `cnotes canvas place` is for, and you should reach for it whenever you're adding more than one item.
22
22
 
23
- The call is **best-effort, not transactional**: per-item failures are reported in the response (HTTP 207) but the items that succeeded stay on the canvas. The exit code says which happened: `0` everything landed, `3` some items or edges were refused (stderr carries `code: "PlacePartial"` and each refused one under `failed`), `1` nothing was placed. On `3`, never re-run the spec, since the notes it made already exist: fix each refused item on its own (`canvas add-quote` for a face, `canvas add-edge` for an edge, a one-item `place` for the rest).
23
+ The call is **best-effort, not transactional**: per-item failures are reported in the response (HTTP 207) but the items that succeeded stay on the canvas. The exit code says which happened: `0` everything landed, `3` it landed only in part: some items or edges were refused, or a section it framed or placed into could not arrange itself (stderr carries `code: "PlacePartial"`, each refused item under `failed`, each such section under `failedSections`), `1` nothing was placed. On `3`, never re-run the spec, since the notes it made already exist: fix each refused item on its own (`canvas add-quote` for a face, `canvas add-edge` for an edge, a one-item `place` for the rest, `canvas arrange <canvas> --section <id>` for a section that did not arrange itself).
24
24
 
25
25
  **You don't have to find a free coordinate.** `place` is collision-aware against content already on the canvas. By default (`placement: "auto"`) it drops your layout in a clear band **below everything that's already there**, and if you do pass an `origin` that would overlap, it slides the whole block straight down until it's clear. So appending a new section to a non-empty canvas Just Works, no need to read existing positions and guess a safe `origin` first. Use `--placement append` to force "below everything", or `--placement exact` (or `"placement": "exact"` in the doc) to honor your `origin` verbatim for pixel-perfect templates.
26
26
 
@@ -7,7 +7,7 @@ The one contract every command follows is in the core skill (the flag table and
7
7
  - `notes list`, `notes get` and `notes search` emit a bare array, so one note is `.[0]`. `notes get --expand` is the exception: an object `{ notes, linked, truncated, cap, omitted, notice }` (notes.md).
8
8
  - `notes create` returns `{ results, relationshipsCreated, rubrics?, hints? }`; read new notes from `results`. Each row carries `type`, `url`, and `quality` where the workspace grades on save; each used type's rubric is in `rubrics`, once.
9
9
  - `canvas create` returns `{ canvas: { id, displayId, url } }` with `id`, `displayId` and `url` mirrored at the top level; after `create --spec` the placement is under `layout`, and `displayId` can still be null until `canvas get` reads it.
10
- - `canvas place` returns `{ items, edges, bbox, successCount, notes?, arrangedSections? }`. It is best-effort, not transactional (HTTP 207): exit `3` means some items or edges were refused and the rest landed; stderr's `PlacePartial` error lists each under `failed` / `failedEdges`. `canvas create --spec` and `canvas bulk-add` (`BulkAddPartial`) exit the same way. `canvas arrange` exits `1` (`ArrangeFailed`) when no card moved and `3` (`ArrangePartial`) when the cards moved but the frame did not resize or the band below did not shift (`rippleError`); an arrange is safe to re-run. A section that could not keep itself arranged afterwards is a `⚠` line on stderr, exit `0`. A `quote` item adds `quoteNoteDisplayId`, `noteDisplayId`, `versionNumber` and `placed`.
10
+ - `canvas place` returns `{ items, edges, bbox, successCount, notes?, arrangedSections? }`. It is best-effort, not transactional (HTTP 207): exit `3` means it landed only in part: some items or edges were refused, or a section could not arrange itself; stderr's `PlacePartial` error lists each under `failed` / `failedEdges` / `failedSections`. `canvas create --spec` and `canvas bulk-add` (`BulkAddPartial`) exit the same way. `canvas arrange` exits `1` (`ArrangeFailed`) when no card moved and `3` (`ArrangePartial`) when the cards moved but the frame did not resize, the band below did not shift (`rippleError`) or the section could not keep itself arranged (`keepError`); an arrange is safe to re-run. A `quote` item adds `quoteNoteDisplayId`, `noteDisplayId`, `versionNumber` and `placed`.
11
11
  - A note body comes back under `markdown` from `canvas read` and under `content` from `notes get --json`; read the key for the command you ran. A `canvas read` whose JSON starts with `level: "cards"` or `"frames"` is a map of a long board: each frame lists its cards under `lines`, with no bodies; `next` names the commands that open a frame, chosen notes or (`--full`) every body. `notes get --content-only` prints the raw markdown with no envelope, the right read for a transcript.
12
12
 
13
13
  ## Errors and notices go to stderr