@creator-notes/cnotes 0.146.0 → 0.148.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creator-notes-cli",
3
- "version": "0.146.0",
3
+ "version": "0.148.0",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
package/README.md CHANGED
@@ -216,7 +216,7 @@ The wrap form does begin → run-your-command → end automatically, even if you
216
216
 
217
217
  ### Declarative layout (`cnotes canvas place`)
218
218
 
219
- Most of the time you shouldn't be computing pixel coordinates by hand — agents and humans alike are bad at it. `cnotes canvas place` takes a layout document that describes **structure** (rows, columns, what's anchored to what) and the server measures every item, packs them with no overlaps, and inserts them in a single batch. The call is best-effort: per-item failures are reported in the response (HTTP 207) but successful items stay on the canvas.
219
+ Most of the time you shouldn't be computing pixel coordinates by hand — agents and humans alike are bad at it. `cnotes canvas place` takes a layout document that describes **structure** (rows, columns, what's anchored to what) and the server measures every item, packs them with no overlaps, and inserts them in a single batch. The call is best-effort: per-item failures are reported in the response (HTTP 207) but successful items stay on the canvas, and the command exits `3` (`PlacePartial` on stderr, each refused item under `failed`) so a refused card never reads as success.
220
220
 
221
221
  Four building blocks:
222
222
 
@@ -205,10 +205,10 @@ function reportPlacedNotes(data) {
205
205
  return createdRows;
206
206
  }
207
207
  /**
208
- * The server answers 207 with per-item results. Partial failure keeps exit 0
209
- * (the caller inspects items[].error, the documented contract), but when EVERY
210
- * item and edge failed, nothing was placed and exiting 0 would report success
211
- * to an agent that keys on the exit code.
208
+ * The server answers 207 with per-item results, and the exit code says how it
209
+ * went: 0 when everything landed, 3 when some items or edges were refused
210
+ * (placedSome), 1 when nothing was placed. An agent keys on the exit code,
211
+ * so a refused card must never exit 0.
212
212
  */
213
213
  function placedNothing(data) {
214
214
  const allItems = (data.items || []);
@@ -218,6 +218,69 @@ 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. */
222
+ function refusedRows(data) {
223
+ const allItems = (data.items || []);
224
+ const allEdges = (data.edges || []);
225
+ const reason = (r) => String(r.error ?? "not placed");
226
+ return {
227
+ items: allItems.filter((r) => !r.id || r.error).map((r) => ({ index: r.index, type: r.type, error: reason(r) })),
228
+ edges: allEdges.filter((e) => !e.id || e.error).map((e) => ({ from: e.from, to: e.to, error: reason(e) })),
229
+ total: allItems.length + allEdges.length,
230
+ };
231
+ }
232
+ /** True when some, not all, of a (non-dry-run) placeLayout's items and edges were refused. */
233
+ function placedSome(data) {
234
+ if (data.dryRun)
235
+ return false;
236
+ const refused = refusedRows(data);
237
+ const failed = refused.items.length + refused.edges.length;
238
+ return failed > 0 && failed < refused.total;
239
+ }
240
+ const PARTIAL_PLACE_HINT = "The rest were placed and any new notes exist: do not re-run the spec, it would duplicate them. " +
241
+ 'Fix each refused item on its own: a quote with `cnotes canvas add-quote <canvas> --note <id> --text "<words>" --title "<headline>"`, ' +
242
+ "an edge with `cnotes canvas add-edge`, anything else with `cnotes canvas place` holding only that item.";
243
+ function partialPlaceSummary(data) {
244
+ const refused = refusedRows(data);
245
+ const items = (data.items || []);
246
+ const edges = (data.edges || []);
247
+ const parts = [];
248
+ if (refused.items.length > 0)
249
+ parts.push(`${refused.items.length} of ${items.length} items`);
250
+ if (refused.edges.length > 0)
251
+ parts.push(`${refused.edges.length} of ${edges.length} edges`);
252
+ return parts.join(" and ");
253
+ }
254
+ function reportPartialPlaceJson(data) {
255
+ const refused = refusedRows(data);
256
+ console.error(JSON.stringify({
257
+ error: `placeLayout refused ${partialPlaceSummary(data)}; the rest were placed`,
258
+ code: "PlacePartial",
259
+ exitCode: EXIT_CODES.VALIDATION,
260
+ ...(refused.items.length > 0 ? { failed: refused.items } : {}),
261
+ ...(refused.edges.length > 0 ? { failedEdges: refused.edges } : {}),
262
+ hint: PARTIAL_PLACE_HINT,
263
+ }));
264
+ }
265
+ /** Set the exit code a placeLayout result earns: 1 when nothing was placed, 3 when some of it was refused. */
266
+ function setPlaceExitCode(data) {
267
+ if (placedNothing(data))
268
+ process.exitCode = EXIT_CODES.GENERIC;
269
+ else if (placedSome(data))
270
+ process.exitCode = EXIT_CODES.VALIDATION;
271
+ }
272
+ /** The stderr notice for a placeLayout that did not fully land, in the output mode in use. */
273
+ function reportPlaceShortfall(data, json) {
274
+ if (json) {
275
+ if (placedNothing(data))
276
+ reportNothingPlacedJson();
277
+ else if (placedSome(data))
278
+ reportPartialPlaceJson(data);
279
+ }
280
+ else if (placedSome(data)) {
281
+ console.error(`Error: ${partialPlaceSummary(data)} were not placed (see above). ${PARTIAL_PLACE_HINT}`);
282
+ }
283
+ }
221
284
  function reportNothingPlacedJson() {
222
285
  console.error(JSON.stringify({
223
286
  error: "placeLayout placed nothing: every item and edge failed",
@@ -1071,12 +1134,11 @@ spec and run the same command again.
1071
1134
  }
1072
1135
  const data = await api.post("/api/canvas", body);
1073
1136
  const createdRows = data.layout ? reportPlacedNotes(data.layout) : [];
1074
- const nothingPlaced = data.layout ? placedNothing(data.layout) : false;
1075
- if (nothingPlaced)
1076
- process.exitCode = EXIT_CODES.GENERIC;
1137
+ if (data.layout)
1138
+ setPlaceExitCode(data.layout);
1077
1139
  printCreatedCanvas(cfg, name, data, createdRows);
1078
- if (cfg.json && nothingPlaced)
1079
- reportNothingPlacedJson();
1140
+ if (data.layout)
1141
+ reportPlaceShortfall(data.layout, cfg.json);
1080
1142
  }
1081
1143
  catch (error) {
1082
1144
  handleError(error, cfg.json);
@@ -1853,15 +1915,18 @@ Examples:
1853
1915
  });
1854
1916
  const link = await resolveCanvasLink(api, cfg, canvasId);
1855
1917
  // The server answers 201/207 with per-item results
1856
- // ({index, type, id, error?}). Partial failure keeps exit 0 (the
1857
- // caller inspects results[].error — documented contract), but when
1858
- // EVERY item failed nothing was added and exiting 0 would report
1859
- // success to an agent that keys on the exit code.
1918
+ // ({index, type, id, error?}). An agent keys on the exit code, so a
1919
+ // refused note never exits 0: 3 when some were refused, 1 when every
1920
+ // one was and nothing was added.
1860
1921
  const results = (data.results || []);
1861
1922
  const failedResults = results.filter((r) => !r.id || r.error);
1862
1923
  const allFailed = results.length > 0 && failedResults.length === results.length;
1924
+ const someFailed = failedResults.length > 0 && !allFailed;
1863
1925
  if (allFailed)
1864
1926
  process.exitCode = EXIT_CODES.GENERIC;
1927
+ else if (someFailed)
1928
+ process.exitCode = EXIT_CODES.VALIDATION;
1929
+ const partialHint = "The rest were added. Re-run bulk-add with only the refused notes once each is fixed.";
1865
1930
  if (cfg.json) {
1866
1931
  if (link)
1867
1932
  data.url = link;
@@ -1874,6 +1939,19 @@ Examples:
1874
1939
  hint: "Inspect results[].error in the response above; fix the failing note refs and retry.",
1875
1940
  }));
1876
1941
  }
1942
+ else if (someFailed) {
1943
+ console.error(JSON.stringify({
1944
+ error: `bulk-add refused ${failedResults.length} of ${results.length} notes; the rest were added`,
1945
+ code: "BulkAddPartial",
1946
+ exitCode: EXIT_CODES.VALIDATION,
1947
+ failed: failedResults.map((r) => ({
1948
+ index: r.index,
1949
+ noteId: notes[typeof r.index === "number" ? r.index : -1]?.noteId,
1950
+ error: String(r.error ?? "not added"),
1951
+ })),
1952
+ hint: partialHint,
1953
+ }));
1954
+ }
1877
1955
  }
1878
1956
  else {
1879
1957
  const added = results.length - failedResults.length;
@@ -1887,6 +1965,9 @@ Examples:
1887
1965
  if (allFailed) {
1888
1966
  console.error("Error: no notes were added — every item failed (see above).");
1889
1967
  }
1968
+ else if (someFailed) {
1969
+ console.error(`Error: ${failedResults.length} of ${results.length} notes were not added (see above). ${partialHint}`);
1970
+ }
1890
1971
  if (link)
1891
1972
  console.log(`Link: ${link}`);
1892
1973
  }
@@ -1958,15 +2039,12 @@ Placement (relative to nodes already on the canvas):
1958
2039
  const link = opts.dryRun
1959
2040
  ? null
1960
2041
  : await resolveCanvasLink(api, cfg, canvasId);
1961
- const nothingPlaced = placedNothing(data);
1962
- if (nothingPlaced)
1963
- process.exitCode = EXIT_CODES.GENERIC;
2042
+ setPlaceExitCode(data);
1964
2043
  if (cfg.json) {
1965
2044
  if (link)
1966
2045
  data.url = link;
1967
2046
  outputJson(data);
1968
- if (nothingPlaced)
1969
- reportNothingPlacedJson();
2047
+ reportPlaceShortfall(data, true);
1970
2048
  }
1971
2049
  else {
1972
2050
  if (data.dryRun) {
@@ -1983,6 +2061,7 @@ Placement (relative to nodes already on the canvas):
1983
2061
  printPlaceSummary(data, createdRows);
1984
2062
  if (link)
1985
2063
  console.log(`Link: ${link}`);
2064
+ reportPlaceShortfall(data, false);
1986
2065
  }
1987
2066
  }
1988
2067
  catch (error) {
@@ -247,13 +247,13 @@ async function runInit(program, nonInteractive) {
247
247
  console.log(` ${WARN} ${dim("Connection")} could not reach API`);
248
248
  }
249
249
  }
250
- // ── Skill (Claude Code + Codex + Cursor) + global install ───
250
+ // ── Skill (Claude Code + Codex + Cursor + Grok) + global install ───
251
251
  await maybeInstallSkill();
252
252
  const installedGlobally = await maybeInstallGlobally();
253
253
  // ── Conversation capture (Claude Code SessionStart hook) ────
254
254
  await maybeInstallSessionHook(installedGlobally);
255
255
  // ── Optional: MCP for Claude Desktop ────────────────────────
256
- // Claude Code, Codex and Cursor use the cnotes skill (installed above), so they
256
+ // Claude Code, Codex, Cursor and Grok use the cnotes skill (installed above), so they
257
257
  // don't need MCP. Claude Desktop has no skill mechanism — MCP is how it reaches
258
258
  // CreatorNotes. Codex users who still want MCP can run `cnotes mcp setup-codex`.
259
259
  console.log();
@@ -306,7 +306,7 @@ async function runInit(program, nonInteractive) {
306
306
  * - hand the agent a sign-in handoff when unauthenticated
307
307
  * (open URL, user signs in, paste the key into the `auth login --token-stdin` heredoc),
308
308
  * - auto-select the workspace when there's exactly one (or list IDs to pick),
309
- * - install the cnotes skill for whichever agents are present (Claude Code, Codex, Cursor),
309
+ * - install the cnotes skill for whichever agents are present (Claude Code, Codex, Cursor, Grok),
310
310
  * and set a non-zero exit code whenever setup is NOT yet complete so the agent
311
311
  * never reports false success.
312
312
  */
@@ -439,7 +439,7 @@ async function runInitNonInteractive() {
439
439
  }
440
440
  // ── Skill install ───────────────────────────────────────────
441
441
  async function maybeInstallSkill() {
442
- // Install for whichever agents the user actually has (Claude Code, Codex, Cursor).
442
+ // Install for whichever agents the user actually has (Claude Code, Codex, Cursor, Grok).
443
443
  const targets = SKILL_TARGETS.filter(hasAgentConfigDir);
444
444
  if (targets.length === 0)
445
445
  return;
@@ -24,7 +24,7 @@ function resolveTargets(agentOpt) {
24
24
  export function registerSkillsCommands(program) {
25
25
  const skills = program
26
26
  .command("skills")
27
- .description("Install bundled agent skills (e.g. fat-marker flows, how-to filmstrips, wayfind, goal tree, shaping, attention planner, transcript timeline, teach a workspace) into Claude Code, Codex, or Cursor");
27
+ .description("Install bundled agent skills (e.g. fat-marker flows, how-to filmstrips, wayfind, goal tree, shaping, attention planner, transcript timeline, teach a workspace) into Claude Code, Codex, Cursor or Grok");
28
28
  skills
29
29
  .command("list")
30
30
  .description("List the skills this CLI can install, and whether each agent's copy is current")
@@ -66,7 +66,7 @@ export function registerSkillsCommands(program) {
66
66
  skills
67
67
  .command("install <name>")
68
68
  .description("Install a bundled skill into your agent's skills dir")
69
- .option("--agent <agent>", "Which agent to install for: claude, codex, cursor, or all (default: auto-detect)")
69
+ .option("--agent <agent>", "Which agent to install for: claude, codex, cursor, grok, or all (default: auto-detect)")
70
70
  .option("--force", "Replace a folder of the same name that is not a cnotes skill (by default it is left alone)")
71
71
  .addHelpText("after", `
72
72
  Examples:
@@ -5,6 +5,7 @@
5
5
  * - Claude Code → ~/.claude/skills/cnotes/SKILL.md
6
6
  * - OpenAI Codex → ~/.codex/skills/cnotes/SKILL.md
7
7
  * - Cursor → ~/.cursor/skills/cnotes/SKILL.md
8
+ * - Grok → ~/.grok/skills/cnotes/SKILL.md
8
9
  *
9
10
  * The skill ships inside the published package at <package>/skills/cnotes/SKILL.md.
10
11
  * At runtime this file lives at <package>/dist/lib/install-skill.js, so the
@@ -39,11 +40,20 @@ function skillsRootDir() {
39
40
  * a Cursor user who already installed for Claude Code sees the skill anyway.
40
41
  * The explicit target is for Cursor-only setups, and so `--agent cursor` names
41
42
  * the thing the user actually runs.
43
+ *
44
+ * `grok` is xAI's directory, ~/.grok/skills. xAI documents it as the
45
+ * user-level skills directory of Grok Build, its terminal agent
46
+ * (docs.x.ai/build/features/skills-plugins-marketplaces). xAI documents no
47
+ * directory for Grok Bot: a Bot's skills live in a library inside the app
48
+ * (docs.x.ai/grok-bot/skills-routines-and-automations), and whether a Bot's
49
+ * computer also reads ~/.grok/skills is not stated there. So the label is the
50
+ * directory's owner, "Grok", not one product.
42
51
  */
43
52
  const AGENTS = {
44
53
  claude: { dir: ".claude", label: "Claude Code" },
45
54
  codex: { dir: ".codex", label: "Codex" },
46
55
  cursor: { dir: ".cursor", label: "Cursor" },
56
+ grok: { dir: ".grok", label: "Grok" },
47
57
  };
48
58
  export const SKILL_TARGETS = Object.keys(AGENTS);
49
59
  /** Human-facing label for a target (used in init/output messages). */
@@ -274,8 +284,8 @@ export function installSkillFolder(name, target, options = {}) {
274
284
  * Runs on every CLI invocation (cheap: one file compare per installed skill
275
285
  * per target). It never installs for an agent the user hasn't opted into — it
276
286
  * only updates a skill that already exists, so a plain `npm update -g
277
- * @creator-notes/cnotes` is enough to get the latest skills for Claude, Codex
278
- * and Cursor without re-running `cnotes init` or `cnotes skills install`.
287
+ * @creator-notes/cnotes` is enough to get the latest skills for Claude, Codex,
288
+ * Cursor and Grok without re-running `cnotes init` or `cnotes skills install`.
279
289
  * Every catalog skill is refreshed, not only the core one: the catalog copies
280
290
  * used to be installed once and never again, so an agent could run a wayfind
281
291
  * or attention-planner from months earlier that taught a rule the core had
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.146.0",
3
+ "version": "0.148.0",
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. Always inspect `items[].error` and `edges[].error` before assuming success.
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).
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
 
@@ -66,7 +66,7 @@ The schema is strict: an unknown or typo'd key anywhere in the doc (e.g. `gapp`,
66
66
  { "kind": "item", "type": "section", "name": "Open Questions", "width": 800, "height": 500 }
67
67
  ```
68
68
 
69
- A `quote` leaf is a note's face (canvas-elements.md rules 4 and 8): `text` is the exact words from the note's saved version, `noteId` a display id or the `@<key>` of a note the same call creates, `style` (`pull` default, `highlight`, `evidence`), `size` (`small` default, `medium`, `large`), `colorHex` a role hex, `title` your own words for why the line matters. The server makes or reuses the Quote note (`QUOTE-<n>`, the same one `canvas add-quote` would make) and places its card where the solver put the leaf, inside its frame, measured from its words. The response item carries `quoteNoteDisplayId`, `noteDisplayId` and `versionNumber`; `placed: false` means that quote was already on the board. Put the face under or beside its note in the same stack; an edge may name it by `@<key>`. `add-quote` is for a board that already exists.
69
+ A `quote` leaf is a note's face (canvas-elements.md rules 4 and 8): `text` is the exact words from the note's saved version, `noteId` a display id or the `@<key>` of a note the same call creates, `style` (`pull` default, `highlight`, `evidence`), `size` (`small` default, `medium`, `large`), `colorHex` a role hex, `title` your own words for why the line matters. Without a `title` the Quote note is titled with the quoted words up to their first full stop, semicolon or consequence clause, so a claim sentence passes the title rule; words that still fail it (a banned word, a display id) are refused until you pass a `title`. The server makes or reuses the Quote note (`QUOTE-<n>`, the same one `canvas add-quote` would make) and places its card where the solver put the leaf, inside its frame, measured from its words. The response item carries `quoteNoteDisplayId`, `noteDisplayId` and `versionNumber`; `placed: false` means that quote was already on the board. Put the face under or beside its note in the same stack; an edge may name it by `@<key>`. `add-quote` is for a board that already exists.
70
70
 
71
71
  `richtext` IS the **text** element (the CLI's `add-text`), the only free-form text leaf. A heading is a `richtext` leaf whose content is `"# Title"` with no `colorHex`. There is no `"type": "text"` leaf: the old heading node kind is retired and the layout engine rejects it.
72
72
 
@@ -221,7 +221,7 @@ What makes a board readable at fit zoom:
221
221
  { "kind": "stack", "axis": "vertical", "gap": 20, "items": [
222
222
  { "kind": "item", "type": "richtext", "content": "# 1 · What goes wrong" },
223
223
  { "kind": "item", "type": "note", "noteId": "@problem" },
224
- { "kind": "item", "type": "quote", "noteId": "@problem", "text": "Every review waits on Ana", "size": "medium", "key": "f1" },
224
+ { "kind": "item", "type": "quote", "noteId": "@problem", "text": "Every review waits on Ana", "title": "One reviewer gates every ship", "size": "medium", "key": "f1" },
225
225
  { "kind": "item", "type": "richtext", "size": "small", "key": "c1",
226
226
  "content": "Four late ships in one month is the cost of one reviewer, not of slow reviewers. So the fix is who reviews, not how fast." }
227
227
  ] },
@@ -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): read `items[].error` and `edges[].error` before assuming success. 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 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. 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