@creator-notes/cnotes 0.140.0 → 0.145.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.140.0",
3
+ "version": "0.145.0",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -58,15 +58,17 @@ export function registerAuthCommands(program) {
58
58
  if (!res.ok) {
59
59
  throw new Error(`Token validation failed: HTTP ${res.status}`);
60
60
  }
61
- // We don't know the email without a dedicated endpoint, store what we have
62
- setServerConfig(config, serverUrl, { token, email: "unknown" });
61
+ // Whose key this is, so `init` and `whoami` name the person, not "unknown".
62
+ const who = await fetchKeyIdentity(serverUrl, token, null);
63
+ const email = "identity" in who && who.identity.email ? who.identity.email : "unknown";
64
+ setServerConfig(config, serverUrl, { token, email });
63
65
  config.currentServer = serverUrl;
64
66
  saveConfig(config);
65
67
  if (json) {
66
- outputJson({ status: "authenticated", server: serverUrl });
68
+ outputJson({ status: "authenticated", server: serverUrl, ...(email !== "unknown" && { email }) });
67
69
  }
68
70
  else {
69
- console.log(`Authenticated with ${serverUrl}`);
71
+ console.log(`Authenticated with ${serverUrl}${email !== "unknown" ? ` as ${email}` : ""}`);
70
72
  }
71
73
  return;
72
74
  }
@@ -133,7 +135,7 @@ function registerAuthStatus(command, program) {
133
135
  });
134
136
  }
135
137
  /** Ask the server which key this is; a short wait, so `whoami` stays quick offline. */
136
- async function fetchKeyIdentity(serverUrl, token, workspaceId) {
138
+ export async function fetchKeyIdentity(serverUrl, token, workspaceId) {
137
139
  let timer;
138
140
  const timeout = new Promise((_, reject) => {
139
141
  timer = setTimeout(() => reject(new Error("no answer within 2 s")), 2_000);
@@ -1246,7 +1246,12 @@ spec and run the same command again.
1246
1246
  if (arrangeError) {
1247
1247
  console.error(`⚠ Placed below ${intoSection}, but the section could not arrange itself: ${arrangeError}`);
1248
1248
  }
1249
- return { data, item };
1249
+ // The canvas's link, on every reply: it is what the agent hands its person
1250
+ // to look at (the raw --x/--y path always carried it; this one did not).
1251
+ const link = await resolveCanvasLink(api, { serverUrl: resolveConfig(program.opts()).serverUrl, workspaceId }, canvasId);
1252
+ if (link)
1253
+ data.url = link;
1254
+ return { data, item, link };
1250
1255
  };
1251
1256
  const placedWhere = (section) => section ? `into ${section} (the section re-arranged itself)` : "below existing content, clear of everything";
1252
1257
  canvas
@@ -1271,7 +1276,7 @@ Examples:
1271
1276
  try {
1272
1277
  const position = rawPosition(opts);
1273
1278
  if (!position) {
1274
- const { data, item } = await placeSingleItem(api, canvasId, cfg.workspaceId, { type: "note", noteId: opts.note }, opts.section);
1279
+ const { data, item, link } = await placeSingleItem(api, canvasId, cfg.workspaceId, { type: "note", noteId: opts.note }, opts.section);
1275
1280
  if (cfg.quiet) {
1276
1281
  outputQuiet(String(item.id));
1277
1282
  }
@@ -1280,6 +1285,8 @@ Examples:
1280
1285
  }
1281
1286
  else {
1282
1287
  console.log(`Added note ${opts.note} ${placedWhere(opts.section)}`);
1288
+ if (link)
1289
+ console.log(`Link: ${link}`);
1283
1290
  }
1284
1291
  return;
1285
1292
  }
@@ -1437,7 +1444,7 @@ and only warns.
1437
1444
  defineAddTextCommand("add-richtext", "[DEPRECATED — use `add-text`] Alias of `add-text`: adds the same Text element (richtext) with the same flags. Kept for existing scripts; prefer `add-text`.");
1438
1445
  canvas
1439
1446
  .command("add-section")
1440
- .description("Add a section frame — a named background region (Miro-style). Whatever sits inside moves with the frame when dragged; notes inside stay individually draggable. Mints a SECTION-<n> id: mention it from notes as [[SECTION-<n>]] to deep-link readers to that region, so name frames like places (\"Shaping\", \"Open Questions\"), not sentences. With --notes the frame is created WITH those notes laid out inside it (collision-aware, no coordinate math — the preferred way to build a populated section), and it stays ARRANGED: adding, editing, moving or removing its cards re-lays it out, until someone resizes the frame by hand.")
1447
+ .description("Add a section frame — a named background region (Miro-style). Whatever sits inside moves with the frame when dragged; notes inside stay individually draggable. Mints a SECTION-<n> id: mention it from notes as [[SECTION-<n>]] to deep-link readers to that region, so name frames like places (\"Shaping\", \"Open Questions\"), not sentences. With --notes the frame is created WITH those notes laid out inside it (collision-aware, no coordinate math — the preferred way to build a populated section), and it stays ARRANGED: adding, editing or removing its cards re-lays it out, until someone moves a card by hand.")
1441
1448
  .argument("<canvasId>", "Canvas ID")
1442
1449
  .requiredOption("--name <name>", "Frame title (shown on the floating chip; title case)")
1443
1450
  .option("--notes <ids>", "Note IDs (comma-separated, display IDs like TASK-6 or Convex IDs) to lay out INSIDE the frame; the frame sizes itself around them")
@@ -1921,8 +1928,8 @@ nothing.
1921
1928
 
1922
1929
  Sections: a section container in the spec ({"kind":"section","name":…,"child":…})
1923
1930
  creates an ARRANGED section (every new section is). It keeps its cards laid out
1924
- as they are added, edited, moved or removed; a card moved inside the frame takes
1925
- the spot it was dropped on. Put more cards in it later with
1931
+ as they are added, edited or removed, until someone moves a card by hand. Put
1932
+ more cards in it later with
1926
1933
  --into SECTION-<n>; never by picking coordinates inside the frame.
1927
1934
 
1928
1935
  Placement (relative to nodes already on the canvas):
@@ -1987,8 +1994,8 @@ Placement (relative to nodes already on the canvas):
1987
1994
  .description("Reflow EXISTING canvas nodes with the layout solver (no coordinate math). " +
1988
1995
  "`arrange --section SECTION-<n>` on its own tidies everything already inside that frame " +
1989
1996
  "(keeping the columns and rows it is roughly in), sizes the frame to fit, and leaves the " +
1990
- "section ARRANGED: it re-lays itself out as cards are added, edited, moved or removed, until " +
1991
- "someone resizes the frame by hand. With --nodes or --spec, packs exactly those nodes (mixed kinds welcome) " +
1997
+ "section ARRANGED: it re-lays itself out as cards are added, edited or removed, until someone " +
1998
+ "moves a card by hand. With --nodes or --spec, packs exactly those nodes (mixed kinds welcome) " +
1992
1999
  "into the frame, which then stays arranged the same way.")
1993
2000
  .argument("<canvasId>", "Canvas ID")
1994
2001
  .option("--section <id>", "Target SECTION-<n> (or raw id) to pack into; auto-resizes the frame around the new layout")
@@ -2055,7 +2062,7 @@ Examples:
2055
2062
  console.log(`Arranged ${data.cardCount} card${data.cardCount === 1 ? "" : "s"} in ${data.displayId ?? opts.section}: ` +
2056
2063
  `${data.movedCount} moved, frame ${data.width} × ${data.height}px` +
2057
2064
  (data.rippledCount ? `, ${data.rippledCount} item${data.rippledCount === 1 ? "" : "s"} below pushed down` : "") +
2058
- ". It keeps itself laid out until the frame is resized by hand.");
2065
+ ". It keeps itself laid out until a card is moved by hand.");
2059
2066
  }
2060
2067
  return;
2061
2068
  }
@@ -1,10 +1,11 @@
1
1
  import { spawnSync } from "child_process";
2
- import { loadConfig, getServerConfig, setWorkspaceId, } from "../lib/auth-store.js";
2
+ import { loadConfig, getServerConfig, setServerConfig, setWorkspaceId, } from "../lib/auth-store.js";
3
3
  import { ApiClient } from "../lib/api-client.js";
4
4
  import { CliError, EXIT_CODES, handleError } from "../lib/errors.js";
5
5
  import { BRAND } from "../lib/brand.js";
6
- import { browserLogin } from "./auth.js";
6
+ import { browserLogin, fetchKeyIdentity } from "./auth.js";
7
7
  import { fetchAndSelectWorkspace } from "./workspace.js";
8
+ import { canWrite, chooseWorkspace, firstWriteLines, workspaceId, workspaceName } from "../lib/workspace-choice.js";
8
9
  import { buildClaudeConfig } from "./mcp.js";
9
10
  import { bold, dim, green, cyan, CHECK, ARROW, WARN } from "../lib/style.js";
10
11
  import { installMcpConfig, getConfigPath } from "../lib/install-mcp.js";
@@ -117,8 +118,9 @@ Agent path (no terminal, or --non-interactive):
117
118
  Keep the key on stdin. Do not pass it as --token.
118
119
  Then run \`cnotes init\` again.
119
120
 
120
- One workspace is selected for you. Several workspaces: init prints
121
- \`cnotes workspace select <id>\` for each and exits 1.
121
+ One workspace is selected for you, and so is the only one the key can
122
+ write to when the others are read-only. Several writable workspaces: init
123
+ prints \`cnotes workspace select <id>\` for each and exits 1.
122
124
 
123
125
  Exit 0 and the line "You're all set." means setup is finished.
124
126
  Next, run \`cnotes brief "<what you are here to do>"\`.
@@ -337,46 +339,72 @@ async function runInitNonInteractive() {
337
339
  process.exitCode = EXIT_CODES.AUTH;
338
340
  return;
339
341
  }
342
+ // A key login that could not ask whose key it is (a slow first answer)
343
+ // stored "unknown": ask once more here, and keep the answer.
344
+ if (!sc.email || sc.email === "unknown") {
345
+ const who = await fetchKeyIdentity(serverUrl, sc.token, sc.workspaceId ?? null);
346
+ if ("identity" in who && who.identity.email) {
347
+ sc.email = who.identity.email;
348
+ setServerConfig(config, serverUrl, sc);
349
+ }
350
+ }
340
351
  console.log(` ${CHECK} Authenticated as ${bold(sc.email || "unknown")}`);
341
- // ── Authenticated but no workspace: auto-select the only one, else list ──
342
- if (!sc.workspaceId) {
343
- try {
344
- const api = new ApiClient(serverUrl, sc.token);
345
- const data = await api.get("/api/workspaces");
346
- const workspaces = data.workspaces || data;
347
- const list = Array.isArray(workspaces) ? workspaces : [];
352
+ // ── The workspace: the only one, or the only one this key can write to, is
353
+ // chosen; several are the person's to choose between (workspace-choice.ts) ──
354
+ let active = null;
355
+ let others = [];
356
+ try {
357
+ const api = new ApiClient(serverUrl, sc.token);
358
+ const data = await api.get("/api/workspaces");
359
+ const workspaces = data.workspaces || data;
360
+ const list = Array.isArray(workspaces) ? workspaces : [];
361
+ const choice = chooseWorkspace(list);
362
+ if (!sc.workspaceId) {
348
363
  if (list.length === 0) {
349
364
  console.log(` ${WARN} No workspaces yet. Create one at ${cyan(serverUrl)}, then re-run ${cyan(`${cli} init`)}.`);
350
365
  process.exitCode = 1;
351
366
  return;
352
367
  }
353
- if (list.length === 1) {
354
- const id = String(list[0]._id || list[0].id || "");
355
- const name = String(list[0].name || "(unnamed)");
356
- setWorkspaceId(config, serverUrl, id);
357
- console.log(` ${CHECK} Workspace ${bold(`"${name}"`)} selected`);
358
- }
359
- else {
360
- console.log(` ${WARN} You have multiple workspaces — pick one and run it:`);
361
- for (const w of list) {
362
- const id = String(w._id || w.id || "");
363
- console.log(` ${cyan(`${cli} workspace select ${id}`)} ${dim(String(w.name || ""))}`);
368
+ if (!choice.pick) {
369
+ console.log(` ${WARN} You have several workspaces. Ask your user which one, then run its line:`);
370
+ for (const w of choice.ordered) {
371
+ const note = canWrite(w) ? "" : " (read-only: this key cannot write here)";
372
+ console.log(` ${cyan(`${cli} workspace select ${workspaceId(w)}`)} ${dim(workspaceName(w) + note)}`);
364
373
  }
365
374
  process.exitCode = 1;
366
375
  return;
367
376
  }
377
+ active = choice.pick;
378
+ setWorkspaceId(config, serverUrl, workspaceId(active));
379
+ const why = list.length > 1 && canWrite(active) ? dim(" (the one this key can write to)") : "";
380
+ console.log(` ${CHECK} Workspace ${bold(`"${workspaceName(active)}"`)} selected${why}`);
368
381
  }
369
- catch (err) {
370
- console.log(` ${WARN} Could not reach the workspace API: ${dim(err instanceof Error ? err.message : String(err))}`);
371
- // Preserve the typed exit code when we have one — e.g. an expired token
372
- // surfaces as HTTP 401 → AUTH (2), so the agent knows to re-run the
373
- // sign-in handoff rather than retry blindly.
374
- process.exitCode = err instanceof CliError ? err.exitCode : 1;
375
- return;
382
+ else {
383
+ active = list.find((w) => workspaceId(w) === sc.workspaceId) ?? null;
384
+ console.log(` ${CHECK} Workspace ${active ? `${bold(`"${workspaceName(active)}"`)} is active` : "is active"}`);
385
+ }
386
+ others = choice.ordered.filter((w) => w !== active);
387
+ }
388
+ catch (err) {
389
+ console.log(` ${WARN} Could not reach the workspace API: ${dim(err instanceof Error ? err.message : String(err))}`);
390
+ // Preserve the typed exit code when we have one — e.g. an expired token
391
+ // surfaces as HTTP 401 → AUTH (2), so the agent knows to re-run the
392
+ // sign-in handoff rather than retry blindly.
393
+ process.exitCode = err instanceof CliError ? err.exitCode : 1;
394
+ return;
395
+ }
396
+ // The active workspace can only be read: say so before anything is written,
397
+ // with the one that can be written if there is one.
398
+ if (active && !canWrite(active)) {
399
+ console.log(` ${WARN} ${bold(`"${workspaceName(active)}"`)} is read-only for you: this key cannot write to it.`);
400
+ for (const w of others.filter(canWrite)) {
401
+ console.log(` To write, switch to ${bold(`"${workspaceName(w)}"`)}: ${cyan(`${cli} workspace select ${workspaceId(w)}`)}`);
376
402
  }
377
403
  }
378
404
  else {
379
- console.log(` ${CHECK} Workspace is active`);
405
+ for (const w of others.filter((o) => !canWrite(o))) {
406
+ console.log(` ${dim(`Also yours to read (read-only): "${workspaceName(w)}". Add`)} ${cyan(`-w ${workspaceId(w)}`)} ${dim("to a command to read it.")}`);
407
+ }
380
408
  }
381
409
  // ── Install the agent skill(s) (best-effort, no prompt) ──
382
410
  for (const target of SKILL_TARGETS.filter(hasAgentConfigDir)) {
@@ -404,7 +432,10 @@ async function runInitNonInteractive() {
404
432
  console.log(` ${dim("Tip: run")} ${cyan("npm install -g @creator-notes/cnotes")} ${dim("once to drop the npx prefix.")}`);
405
433
  }
406
434
  console.log();
407
- printNextSteps(cli);
435
+ // What the first write needs, said before it is refused for lacking it.
436
+ for (const line of firstWriteLines(cli, active))
437
+ console.log(line ? ` ${line}` : "");
438
+ console.log();
408
439
  }
409
440
  // ── Skill install ───────────────────────────────────────────
410
441
  async function maybeInstallSkill() {
@@ -1,4 +1,5 @@
1
1
  import { ApiClient, resolveActiveAgentRun } from "../lib/api-client.js";
2
+ import { noteUrl, placeNextLine } from "../lib/urls.js";
2
3
  import { resolveConfig } from "../lib/config.js";
3
4
  import { CliError, handleError, NotFoundError, ValidationError, EXIT_CODES } from "../lib/errors.js";
4
5
  import { parseJsonOption } from "../lib/fs-utils.js";
@@ -751,7 +752,10 @@ Output (--json):
751
752
  const rubricMap = await loadRubricMap(api, cfg.workspaceId);
752
753
  const typeByKey = new Map(notes.map((n) => [n.key, n.type]));
753
754
  const rawResults = (data.results || []);
754
- const results = attachRubricsToResults(rawResults, typeByKey, rubricMap);
755
+ // Each new note's link, and what is left to do for a person to see it:
756
+ // a note just created is on no canvas (the first-run walk, 29 Nov 2026).
757
+ const results = attachRubricsToResults(rawResults, typeByKey, rubricMap).map((r) => r.displayId ? { ...r, url: noteUrl(cfg.serverUrl, cfg.workspaceId, String(r.displayId)) } : r);
758
+ const next = alreadyExists ? null : placeNextLine(results.filter((r) => r.displayId).map((r) => String(r.displayId)));
755
759
  const rubrics = rubricsForTypes(notes.map((n) => n.type), rubricMap);
756
760
  // The self-check closes the loop the rubric echo opens. The command
757
761
  // does not grade and does not spend credits: it returns a
@@ -768,6 +772,7 @@ Output (--json):
768
772
  results,
769
773
  ...(rubrics.length > 0 ? { rubrics } : {}),
770
774
  ...(selfCheck ? { selfCheck } : {}),
775
+ ...(next ? { next } : {}),
771
776
  ...(mentionWarnings.length > 0 ? { mentionWarnings } : {}),
772
777
  ...(plainTextIdWarnings.length > 0 ? { plainTextIdWarnings } : {}),
773
778
  };
@@ -786,7 +791,11 @@ Output (--json):
786
791
  }
787
792
  for (const r of results) {
788
793
  console.log(` ${r.displayId}: ${r.title || "(untitled)"}`);
794
+ if ("url" in r && r.url)
795
+ console.log(` ${r.url}`);
789
796
  }
797
+ if (next)
798
+ console.log(`\n${next}`);
790
799
  if (rubrics.length > 0) {
791
800
  console.log("");
792
801
  for (const { type, rubric } of rubrics) {
@@ -4,6 +4,7 @@ import { clearProposalById, loadConfig, setWorkspaceId } from "../lib/auth-store
4
4
  import { handleError, ApiError, AuthError, CliError, EXIT_CODES, NetworkError, ValidationError } from "../lib/errors.js";
5
5
  import { outputJson, outputTable, timeAgo } from "../lib/output.js";
6
6
  import { blockedWorkspaceNotes, workspaceListState } from "../lib/billing-block.js";
7
+ import { chooseWorkspace, workspaceRole } from "../lib/workspace-choice.js";
7
8
  import { isNotFound } from "../lib/proposal-in-place.js";
8
9
  import { draftLink, draftOfLine, spokenDetail } from "../lib/draft-view.js";
9
10
  import { registerWorkspaceCheck } from "./workspace-check.js";
@@ -104,8 +105,9 @@ export async function fetchAndSelectWorkspace(serverUrl, token, currentWorkspace
104
105
  const { select } = await import("@inquirer/prompts");
105
106
  chosenId = await select({
106
107
  message: "Select a workspace to activate:",
107
- choices: list.map((w) => {
108
- const state = workspaceListState(w);
108
+ // Writable first; one the key can only read says so.
109
+ choices: chooseWorkspace(list).ordered.map((w) => {
110
+ const state = [workspaceListState(w), workspaceRole(w)].filter(Boolean).join(" · ");
109
111
  const active = (w._id || w.id) === currentWorkspaceId ? " (active)" : "";
110
112
  return {
111
113
  name: `${String(w.name || "(unnamed)")}${state ? ` · ${state}` : ""}${active}`,
@@ -203,7 +205,7 @@ Examples:
203
205
  return [
204
206
  String(w._id || w.id || ""),
205
207
  String(w.name || ""),
206
- [active, state].filter(Boolean).join(" "),
208
+ [active, state, workspaceRole(w)].filter(Boolean).join(" "),
207
209
  ];
208
210
  });
209
211
  outputTable(["ID", "NAME", "STATE"], rows);
@@ -1,5 +1,6 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { ApiError, asCliError, CliError, EXIT_CODES, isPermanentNetworkError, isRefusedBeforeSend } from "./errors.js";
3
+ import { noteTrialStarted } from "./trial-notice.js";
3
4
  import { loadConfig, getActiveAgentRunId, getServerConfig } from "./auth-store.js";
4
5
  import { inPlaceProposalId, resolveProposal } from "./config.js";
5
6
  import { detectAgentClient } from "./agent-client.js";
@@ -187,6 +188,8 @@ export class ApiClient {
187
188
  }
188
189
  const res = await fetch(url, init);
189
190
  if (res.ok || !isRetryable(res.status) || (!replaySafe && res.status !== 429)) {
191
+ // A write that started the workspace's free trial says so (trial-notice.ts).
192
+ noteTrialStarted(res.headers);
190
193
  return res;
191
194
  }
192
195
  // Retryable server error — wait and retry
@@ -439,8 +439,9 @@ function hintForStatus(status, message, resource) {
439
439
  // re-auth — not the full `cnotes init` setup that AuthError suggests.
440
440
  if (status === 401)
441
441
  return "Run `cnotes auth login` to authenticate.";
442
- if (status === 403)
443
- return "Check workspace membership with `cnotes workspace current`.";
442
+ if (status === 403) {
443
+ return "This key cannot do that in the active workspace. `cnotes workspace list` shows each workspace and marks the read-only ones; `cnotes workspace select <id>` switches.";
444
+ }
444
445
  if (status === 404) {
445
446
  // Prefer a server-provided `resource` field; fall back to regex on the
446
447
  // error message. Regex is best-effort because server messages vary.
@@ -256,7 +256,7 @@ export function buildMcpSpec(z, opts) {
256
256
  "Edges resolve endpoints in priority order: '@<key>' of an item placed in this call, the noteId of a note placed in this call, or the displayId / id of a node already on the canvas.\n\n" +
257
257
  "NEW NOTES IN THE SAME CALL: pass `notes` (the cnotes_notes_create item shape, rubric rules included) and place each with a note leaf whose noteId is '@<key>'. Bodies cross-link with [@<key>: Title](relationship:<verb>); edges and anchors say '@<key>'. One call replaces notes_create then place. The notes are created only if the layout solves, and come back under `notes`.\n\n" +
258
258
  "placement: 'auto' (default, drops into a clear band below existing nodes and slides down to de-collide), 'append' (always below everything), 'exact' (honor origin verbatim).\n\n" +
259
- "SECTIONS ARRANGE THEMSELVES. Every new section is ARRANGED: it keeps its cards laid out as cards are added, edited, moved or removed, and a card moved inside the frame takes the spot it was dropped on. To add cards to an existing section, pass `intoSection: 'SECTION-<n>'` with a doc of just those items: they are appended to its layout and the frame resizes to fit. Never aim `origin` inside a frame.\n\n" +
259
+ "SECTIONS ARRANGE THEMSELVES. Every new section is ARRANGED: it keeps its cards laid out as cards are added, edited or removed, until someone moves a card by hand. To add cards to an existing section, pass `intoSection: 'SECTION-<n>'` with a doc of just those items: they are appended to its layout and the frame resizes to fit. Never aim `origin` inside a frame.\n\n" +
260
260
  "The schema is strict server-side: a typo'd key anywhere in the doc is rejected with the offending path named. If a large layout is refused as a whole, place it in two or three smaller calls — each is independent.",
261
261
  shape: {
262
262
  intent,
@@ -308,7 +308,7 @@ export function buildMcpSpec(z, opts) {
308
308
  "MOVING CARRIES THE CONTENTS. Pass BOTH x and y and the frame travels with everything sitting inside it, exactly as dragging it in the app does — so 'put this section where that one is' is one call. Frame membership is geometric (a card belongs to whichever frame its centre is in), and the response's `movedNodeCount` tells you how many travelled.\n\n" +
309
309
  "A MOVE IS ITS OWN CALL: send x/y alone, never alongside name, width/height or colorHex, and never one axis without the other. To shift a frame along one axis, read the other axis off cnotes_canvas_get and pass it unchanged. Resizing and renaming keep the frame's contents where they are; only a move takes them along. GROWING TALLER RIPPLES: the band below the frame's old bottom edge shifts down by the growth delta so the layout beneath survives (see `ripple` to opt out).\n\n" +
310
310
  `To reorder a canvas — 'the last section should replace section 7' — move the new frame onto the old one's position (read it off cnotes_canvas_get) and then remove the old frame with ${names.removeNodes}.\n\n` +
311
- "ARRANGE: `arrange: true` (on its own) tidies everything inside the frame, keeping the rows and columns the cards are roughly in, sizes the frame to fit, and leaves the section ARRANGED: it re-lays itself out as its cards are added, edited, moved or removed, until someone resizes the frame by hand. Use it whenever a section's contents overlap or spill out of the frame. `arrange: false` stops arranging; nothing moves.",
311
+ "ARRANGE: `arrange: true` (on its own) tidies everything inside the frame, keeping the rows and columns the cards are roughly in, sizes the frame to fit, and leaves the section ARRANGED: it re-lays itself out as its cards are added, edited or removed, until someone moves a card by hand. Use it whenever a section's contents overlap or spill out of the frame. `arrange: false` stops arranging; nothing moves.",
312
312
  shape: {
313
313
  intent,
314
314
  canvasId: canvasRef,
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The one line the CLI prints when a write started the workspace's free trial.
3
+ *
4
+ * The owner's first CLI or API write to a free workspace starts its 7-day Pro
5
+ * trial on the server and goes through (lib/auth/server.ts,
6
+ * startTrialOnFirstWrite); the response says so in a header whose value is
7
+ * when the trial ends. Nobody asked for that trial, so the agent is told on
8
+ * stderr, in words it can pass to its person, and stdout stays the command's
9
+ * own output.
10
+ */
11
+ /** Must match TRIAL_STARTED_HEADER in lib/auth/server.ts. */
12
+ export const TRIAL_STARTED_HEADER = "X-CN-Trial-Started";
13
+ /** The stderr line for a response that started a trial, or null when it did not. */
14
+ export function trialStartedNotice(headerValue) {
15
+ if (!headerValue)
16
+ return null;
17
+ const ends = new Date(headerValue);
18
+ const when = Number.isNaN(ends.getTime()) ? "in 7 days" : `on ${ends.toISOString().slice(0, 10)}`;
19
+ return (`note: this write started the workspace's free 7-day Pro trial (no card needed). It ends ${when}. ` +
20
+ "After that, CLI and API writes need Pro; reading always works. Tell your user. " +
21
+ "`cnotes upgrade` shows where to subscribe.");
22
+ }
23
+ /** Print the notice once per process: one command can make several writes. */
24
+ let printed = false;
25
+ export function noteTrialStarted(headers) {
26
+ if (printed)
27
+ return;
28
+ const line = trialStartedNotice(headers.get(TRIAL_STARTED_HEADER));
29
+ if (!line)
30
+ return;
31
+ printed = true;
32
+ process.stderr.write(`${line}\n`);
33
+ }
package/dist/lib/urls.js CHANGED
@@ -15,6 +15,30 @@ export function canvasUrl(serverUrl, workspaceId, canvasId) {
15
15
  const origin = serverUrl.replace(/\/+$/, "");
16
16
  return `${origin}/${workspaceId}?canvasId=${canvasId}`;
17
17
  }
18
+ /**
19
+ * Where a person opens one note: the workspace with the note open over it.
20
+ *
21
+ * <origin>/<workspaceId>?noteId=<displayId>
22
+ *
23
+ * A note just created is on no canvas, so this is the only link there is to
24
+ * give for it (the app's own shape: components/mention-shared/open-far-note.ts).
25
+ */
26
+ export function noteUrl(serverUrl, workspaceId, displayId) {
27
+ const origin = serverUrl.replace(/\/+$/, "");
28
+ return `${origin}/${encodeURIComponent(workspaceId)}?noteId=${encodeURIComponent(displayId)}`;
29
+ }
30
+ /**
31
+ * What `notes create` says next: the notes exist and are on no canvas, which
32
+ * is where a person looks. Null when nothing was created.
33
+ */
34
+ export function placeNextLine(displayIds) {
35
+ if (displayIds.length === 0)
36
+ return null;
37
+ const many = displayIds.length > 1;
38
+ return (`${many ? "These notes are" : "This note is"} on no canvas yet. To put ${many ? "one" : "it"} where a person will see it: ` +
39
+ `cnotes canvas add-node <canvasId> --note ${displayIds[0]} --intent "<past-tense headline>" ` +
40
+ "(`cnotes canvas list` shows the canvases; `cnotes canvas place` lays out several at once). Its reply carries the canvas link.");
41
+ }
18
42
  /**
19
43
  * True when `ref` is a canvas *display id* (e.g. "CANVAS-12") rather than a raw
20
44
  * Convex id. Only the Convex id resolves in `?canvasId`, so a click-through
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Which workspace a fresh key works in, and what `init` says about it.
3
+ *
4
+ * A key's workspaces (GET /api/workspaces) are not alike: a person who read a
5
+ * public workspace is a reader there and owns an Inbox of their own. Listing
6
+ * the two side by side left an agent to guess, and the one its person had been
7
+ * looking at was the one it could not write to (the first-run walk, 29 Nov
8
+ * 2026). The key's one writable workspace is chosen for it, a read-only one
9
+ * is labelled, and init's closing lines say what the first write needs.
10
+ */
11
+ export function workspaceId(row) {
12
+ return String(row._id || row.id || "");
13
+ }
14
+ export function workspaceName(row) {
15
+ return String(row.name || "(unnamed)");
16
+ }
17
+ /** A key's rows say `permission`; a session's say `userPermission`. */
18
+ function role(row) {
19
+ return row.userPermission ?? row.permission;
20
+ }
21
+ /** Whether this key can write there: an editor or an admin. A row with no role is taken as writable, as before roles were listed. */
22
+ export function canWrite(row) {
23
+ const r = role(row);
24
+ return r === undefined || r === null || r === "editor" || r === "admin";
25
+ }
26
+ /** The label a list shows beside a workspace the key can only read. */
27
+ export function workspaceRole(row) {
28
+ return canWrite(row) ? "" : "read-only";
29
+ }
30
+ /**
31
+ * The only workspace, or the only one the key can write to, is chosen.
32
+ * Several writable ones (or several read-only and none writable) are the
33
+ * person's to choose between. A draft is written through its parent and is
34
+ * never a choice.
35
+ */
36
+ export function chooseWorkspace(rows) {
37
+ const choices = rows.filter((row) => !row.draftOfWorkspaceId);
38
+ const writable = choices.filter(canWrite);
39
+ const readOnly = choices.filter((row) => !canWrite(row));
40
+ const pick = writable.length === 1 ? writable[0] : choices.length === 1 ? choices[0] : null;
41
+ return { pick, writable, readOnly, ordered: [...writable, ...readOnly] };
42
+ }
43
+ /**
44
+ * Whether the first write to this workspace starts its free trial: a free
45
+ * workspace the key can write to whose one-time trial is unused. The server
46
+ * decides (it also needs the key's owner to own the workspace); this is only
47
+ * what init says ahead of time.
48
+ */
49
+ export function freePlanStartsTrial(row) {
50
+ if (!canWrite(row))
51
+ return false;
52
+ if (row.plan !== "free")
53
+ return false;
54
+ if (row.subscriptionStatus === "trialing" || row.subscriptionStatus === "grandfathered")
55
+ return false;
56
+ return !row.trialStartedAt;
57
+ }
58
+ /**
59
+ * Init's closing lines: what the first write needs and the two commands that
60
+ * put a first note on a canvas, or for a read-only workspace the commands
61
+ * that read it. Plain text; the caller indents and colours.
62
+ */
63
+ export function firstWriteLines(cli, row) {
64
+ if (row && !canWrite(row)) {
65
+ return [
66
+ `You can read "${workspaceName(row)}" and cannot write to it.`,
67
+ "",
68
+ `${cli} canvas list its canvases`,
69
+ `${cli} canvas read <canvasId> one canvas as markdown`,
70
+ `${cli} search semantic "<words>" find notes by meaning`,
71
+ ];
72
+ }
73
+ const lines = [
74
+ "Before the first write:",
75
+ ` Every write takes --intent "<past-tense headline>" (for example --intent "Added the first notes").`,
76
+ " It lands on the timeline as one change a person can undo.",
77
+ ];
78
+ if (row && freePlanStartsTrial(row)) {
79
+ lines.push(" This workspace is on the free plan. If you own it, your first write starts its free 7-day Pro trial", " (no card) and goes through; the CLI prints a note when it does. Tell your user.");
80
+ }
81
+ lines.push("", "A first note on a canvas:", ` ${cli} notes create --notes '{"key":"A","type":"Note","markdown":"# Title\\n\\nBody"}' --intent "Added a first note"`, ` ${cli} canvas list canvas ids (Home is the default canvas)`, ` ${cli} canvas add-node <canvasId> --note <displayId> --intent "Placed the first note"`, `Each reply carries a "url": give it to your user to open.`, "", `${cli} brief this workspace's standing rules and what it holds`, `${cli} --help every command`);
82
+ return lines;
83
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.140.0",
3
+ "version": "0.145.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -61,7 +61,7 @@ When the writes belong together but cannot be one command (several notes and new
61
61
  6. **Place declaratively, edit in place.** `canvas place` / `canvas arrange`, never hand-computed x/y. Add to a section with `place --into SECTION-n`; tidy one with `arrange --section SECTION-n`. Change a text card with `canvas update-text` and a frame with `canvas update-section`: deleting and re-adding mints new ids and drops edges and `[[SECTION-n]]` mentions.
62
62
  7. **Content changes are versions.** `cnotes versions create` changes a note's body; fetch the current body first and edit that, since people edit between sessions. `notes update` changes metadata only (type, tags, pin, archive).
63
63
  8. **Inside a draft, propose and stop.** Shared notes change through `cnotes draft propose`; the hand-over is `cnotes draft ask`, then stop. Never merge or approve work you built ([references/drafts.md](references/drafts.md)).
64
- 9. **Ask before spending something the user cannot get back:** `cnotes upgrade` uses the workspace's one-time trial, `cnotes feedback submit` files a report in their name, `cnotes types dimension backfill --yes` spends one model call per existing note.
64
+ 9. **Ask before spending something the user cannot get back:** `cnotes feedback submit` files a report in their name, `cnotes types dimension backfill --yes` spends one model call per existing note. The owner's first write to a free workspace starts its one-time 7-day trial by itself (no card): when a write prints `note: this write started … trial` on stderr, say so in your reply, with the date it ends ([references/billing.md](references/billing.md)).
65
65
  10. **Timeline headlines start with a past-tense verb and name the object** ("Shipped the public comic canvas", never "V1"): the `--intent`, an `operations begin --prompt`, a version `--description`, a milestone. A run headline (`--intent`, `--prompt`) is also a title: at most 80 characters, no ", so…" clause, detail after a blank line. The server refuses a run or milestone headline that breaks this. A milestone body, the lines after the headline, is at most 280 characters.
66
66
 
67
67
  ### Decisions
@@ -1,25 +1,22 @@
1
1
  # Paid actions and workspaces
2
2
 
3
- Read this when a write fails with exit `8` (`subscription_required`) or the user wants another workspace.
3
+ Read this when a write fails with exit `8` (`subscription_required`), a write prints `note: this write started … trial`, or the user wants another workspace.
4
4
 
5
5
  ## Paid actions (writes need Pro)
6
6
 
7
- Reads work on any plan. **CLI/API writes require the target workspace to be on Pro**, this is the most common wall you will hit (exit `8`, `serverCode: "subscription_required"`). There are three distinct walls, and only two of them need a human. Do not collapse them into "tell the user to go pay."
7
+ Reads work on any plan. **CLI/API writes need the target workspace on Pro or in its free trial**; a refused write is exit `8`, `serverCode: "subscription_required"`. There are three distinct cases, and only two of them need a human. Do not collapse them into "tell the user to go pay."
8
8
 
9
- **Wall 1: free workspace, write blocked. You can fix this yourself.**
9
+ **Wall 1: a free workspace. The owner's first write starts the trial by itself.**
10
10
 
11
- If the caller owns the workspace and hasn't used its one-time trial, `cnotes upgrade` starts a free 7-day Pro trial and writes unlock immediately. **No credit card, no browser, no human hand-off**, it's a single command you can run.
11
+ When the key's owner owns the workspace and its one-time trial is unused, the first CLI or API write **goes through and starts the free 7-day Pro trial** (no credit card). You do nothing and nothing is refused. The CLI prints one line on stderr when that happens:
12
12
 
13
- ```bash
14
- cnotes upgrade # start the free trial on the ACTIVE workspace, then retry the write
15
- cnotes upgrade -w <id> # target a specific workspace
13
+ ```
14
+ note: this write started the workspace's free 7-day Pro trial (no card needed). It ends on 2026-12-06. ...
16
15
  ```
17
16
 
18
- **Ask before running it.** The trial is one-time and cannot be restarted, so never fire it unprompted. Offer it in one line and wait for a yes:
19
-
20
- > "This workspace is on the free plan, so I can't write to it. Want me to start your free 7-day Pro trial (no credit card)?"
17
+ **Tell the user in your reply** when you see it: nobody asked for the trial, it is one-time, and after it ends CLI and API writes need Pro. Say when it ends.
21
18
 
22
- On yes: run `cnotes upgrade`, then retry the write. That's the whole flow.
19
+ `cnotes upgrade` still exists and starts the same trial without writing anything (`-w <id>` targets a workspace). You only meet exit `8` on a free workspace when the caller is not its owner (below) or the trial is used (Wall 2).
23
20
 
24
21
  **Wall 2: trial already used. A human must pay.**
25
22
 
@@ -27,7 +24,7 @@ On yes: run `cnotes upgrade`, then retry the write. That's the whole flow.
27
24
 
28
25
  **Wall 3: they want an ADDITIONAL workspace. Human pays at checkout.**
29
26
 
30
- `cnotes workspace create` **buys a new workspace**, it is not the fix for a blocked write on the current one (that's Wall 1). Only reach for it when the user actually asks for another workspace.
27
+ `cnotes workspace create` **buys a new workspace**, it is not the fix for a blocked write on the current one (that's Wall 1 or 2). Only reach for it when the user actually asks for another workspace.
31
28
 
32
29
  ```bash
33
30
  cnotes workspace create "Acme Research" --json # returns { checkoutUrl, sessionId }
@@ -136,11 +136,8 @@ frame drawn around another frame starts freeform. An arranged section:
136
136
  in, and sizes the frame to fit (what sits below is pushed down if it grows);
137
137
  - re-lays itself out when one of its cards is added, edited or removed: a text
138
138
  card that grows pushes the cards under it down, a deleted card's gap closes;
139
- - stays arranged when a card is MOVED (drag, `move-node`, `bulk-move`): a card
140
- moved inside the frame takes the spot it was dropped on, a card moved out of
141
- it leaves the section and its gap closes, a card moved in joins it there, and
142
- moving every card at once re-reads the layout from where they landed;
143
- - becomes freeform only when someone RESIZES THE FRAME by hand. Nothing moves.
139
+ - stays arranged until someone MOVES A CARD BY HAND (drag, `move-node`,
140
+ `bulk-move`) or resizes the frame. Then it is freeform again and nothing moves.
144
141
  `arrange --section SECTION-<n> --stop` does the same on purpose.
145
142
 
146
143
  Put new cards into a section with the section, never with coordinates inside