@creator-notes/cnotes 0.131.0 → 0.132.1

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.131.0",
3
+ "version": "0.132.1",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -0,0 +1,110 @@
1
+ import { ApiClient } from "../lib/api-client.js";
2
+ import { themesPath } from "../lib/canvas-paths.js";
3
+ import { resolveConfig } from "../lib/config.js";
4
+ import { handleError } from "../lib/errors.js";
5
+ import { outputJson, outputQuiet } from "../lib/output.js";
6
+ import { formatThemeLines } from "../lib/canvas-themes.js";
7
+ /**
8
+ * `cnotes canvas theme`: read and set a canvas's themes, the topics its notes
9
+ * group into. A theme you add stays through every summary. The others are the
10
+ * summary's suggestions: keep one by adding it under the same name, or dismiss
11
+ * it so it is never suggested again.
12
+ */
13
+ export function registerCanvasThemeCommands(canvas, program) {
14
+ const theme = canvas
15
+ .command("theme")
16
+ .description("Read and set a canvas's themes: the topics its notes group into, at most five. " +
17
+ "A theme you add is kept through every summary; the rest are the summary's suggestions. " +
18
+ "A theme is a label of one to four words that names a specific subject of the board (\"Wallet order\"), " +
19
+ "not a category that fits any board (\"User experience\"). Search finds a canvas by its themes.");
20
+ const print = (data, json, quiet, lead) => {
21
+ if (json)
22
+ return outputJson(data);
23
+ const rows = data.themes ?? [];
24
+ if (quiet)
25
+ return outputQuiet(rows.map((row) => row.label).join("\n"));
26
+ if (lead)
27
+ console.log(lead);
28
+ for (const line of formatThemeLines(rows, data.dismissed ?? []))
29
+ console.log(line);
30
+ };
31
+ theme
32
+ .command("list")
33
+ .description("List the canvas's themes, added ones first, each with the notes it covers.")
34
+ .argument("<canvasId>", "Canvas ID or CANVAS-<n> display id")
35
+ .addHelpText("after", `
36
+ Examples:
37
+ $ cnotes canvas theme list CANVAS-212
38
+ $ cnotes canvas theme list CANVAS-212 --json
39
+ `)
40
+ .action(async (canvasId) => {
41
+ const cfg = resolveConfig(program.opts());
42
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
43
+ try {
44
+ print(await api.get(themesPath(canvasId, cfg.workspaceId)), cfg.json, cfg.quiet);
45
+ }
46
+ catch (error) {
47
+ handleError(error, cfg.json);
48
+ }
49
+ });
50
+ theme
51
+ .command("add")
52
+ .description("Add a theme to the canvas, or keep one the summary suggested by adding it under the same name. " +
53
+ "One to four words, at most 40 characters, no closing punctuation; the server refuses anything else. " +
54
+ "The notes it covers are matched the next time the summary is written, within about a minute.")
55
+ .argument("<canvasId>", "Canvas ID or CANVAS-<n> display id")
56
+ .argument("<label>", "The theme, quoted when it has a space")
57
+ .addHelpText("after", `
58
+ Examples:
59
+ $ cnotes canvas theme add CANVAS-212 "Wallet order"
60
+ $ cnotes canvas theme add CANVAS-212 "Saved-card consent" # keeps a suggestion
61
+ `)
62
+ .action(async (canvasId, label) => {
63
+ const cfg = resolveConfig(program.opts());
64
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
65
+ try {
66
+ const data = await api.post(themesPath(canvasId, cfg.workspaceId), { label });
67
+ print(data, cfg.json, cfg.quiet, `Added the theme "${label.trim()}"`);
68
+ }
69
+ catch (error) {
70
+ handleError(error, cfg.json);
71
+ }
72
+ });
73
+ theme
74
+ .command("remove")
75
+ .description("Take a theme you or someone added off the canvas. The summary may suggest it again; " +
76
+ "use `dismiss` to stop that.")
77
+ .argument("<canvasId>", "Canvas ID or CANVAS-<n> display id")
78
+ .argument("<label>", "The theme, quoted when it has a space")
79
+ .action(async (canvasId, label) => {
80
+ const cfg = resolveConfig(program.opts());
81
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
82
+ try {
83
+ const data = await api.delete(themesPath(canvasId, cfg.workspaceId), { label });
84
+ print(data, cfg.json, cfg.quiet, `Removed the theme "${label.trim()}"`);
85
+ }
86
+ catch (error) {
87
+ handleError(error, cfg.json);
88
+ }
89
+ });
90
+ theme
91
+ .command("dismiss")
92
+ .description("Take a theme off the canvas and tell the summary never to suggest it again. " +
93
+ "Works on a suggestion and on an added theme. Adding it back later undoes the dismissal.")
94
+ .argument("<canvasId>", "Canvas ID or CANVAS-<n> display id")
95
+ .argument("<label>", "The theme, quoted when it has a space")
96
+ .action(async (canvasId, label) => {
97
+ const cfg = resolveConfig(program.opts());
98
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
99
+ try {
100
+ const data = await api.delete(themesPath(canvasId, cfg.workspaceId), {
101
+ label,
102
+ dismiss: true,
103
+ });
104
+ print(data, cfg.json, cfg.quiet, `Dismissed the theme "${label.trim()}"`);
105
+ }
106
+ catch (error) {
107
+ handleError(error, cfg.json);
108
+ }
109
+ });
110
+ }
@@ -21,6 +21,7 @@ import { canvasActionPath, commentsListPath, parseCommentStatus, } from "../lib/
21
21
  import { buildSectionUpdateRequest, CLI_SECTION_WORDING } from "../lib/section-update.js";
22
22
  import { arrowToMarkers } from "../lib/mcp-spec.js";
23
23
  import { registerCanvasMilestoneCommands } from "./canvas-milestone.js";
24
+ import { registerCanvasThemeCommands } from "./canvas-theme.js";
24
25
  import { DISPLAY_ID_CORE } from "../lib/display-id.js";
25
26
  import { resolveNoteBatchItems } from "../lib/note-batch.js";
26
27
  import { describeUnresolvedMentions } from "../lib/mention-lint.js";
@@ -930,6 +931,7 @@ Examples:
930
931
  }
931
932
  });
932
933
  registerCanvasMilestoneCommands(canvas, program);
934
+ registerCanvasThemeCommands(canvas, program);
933
935
  canvas
934
936
  .command("read")
935
937
  .description("Read a canvas as one markdown document, in display order (top-to-bottom, " +
@@ -22,6 +22,10 @@ export function milestonesCollectionPath(canvasId, workspaceId, limit) {
22
22
  const base = `/api/canvas/${encodeURIComponent(canvasId)}/milestones?workspaceId=${encodeURIComponent(workspaceId)}`;
23
23
  return limit !== undefined ? `${base}&limit=${encodeURIComponent(String(limit))}` : base;
24
24
  }
25
+ /** Read and set one canvas's themes. `workspaceId` resolves CANVAS-<n>. */
26
+ export function themesPath(canvasId, workspaceId) {
27
+ return `/api/canvas/${encodeURIComponent(canvasId)}/themes?workspaceId=${encodeURIComponent(workspaceId)}`;
28
+ }
25
29
  /** Read one milestone by its canvasSnapshots id. */
26
30
  export function milestoneShowPath(milestoneId, workspaceId) {
27
31
  return `/api/canvas/milestones/${encodeURIComponent(milestoneId)}?workspaceId=${encodeURIComponent(workspaceId)}`;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * How `cnotes canvas theme` prints a canvas's themes. Pure, so the wording is
3
+ * tested without a server.
4
+ */
5
+ /** Notes named under one theme before the rest are counted. */
6
+ const NOTES_SHOWN = 8;
7
+ function origin(row) {
8
+ if (row.source === "generated")
9
+ return "suggested by the summary";
10
+ if (!row.addedBy)
11
+ return "added";
12
+ return row.via === "agent" ? `added by ${row.addedBy} through an agent` : `added by ${row.addedBy}`;
13
+ }
14
+ /**
15
+ * One block per theme: the label and where it came from, then the notes it
16
+ * covers. A theme with no notes yet says when they will appear.
17
+ */
18
+ export function formatThemeLines(rows, dismissed = []) {
19
+ if (rows.length === 0 && dismissed.length === 0) {
20
+ return ['No themes yet. Add one with `cnotes canvas theme add <canvasId> "<label>"`.'];
21
+ }
22
+ const lines = [];
23
+ for (const row of rows) {
24
+ const notes = row.notes ?? [];
25
+ const count = notes.length === 1 ? "1 note" : `${notes.length} notes`;
26
+ lines.push(`${row.label} · ${origin(row)} · ${count}`);
27
+ if (notes.length === 0) {
28
+ lines.push(" notes are matched the next time the summary is written");
29
+ continue;
30
+ }
31
+ for (const note of notes.slice(0, NOTES_SHOWN)) {
32
+ lines.push(` ${note.displayId}${note.title ? `: ${note.title}` : ""}`);
33
+ }
34
+ if (notes.length > NOTES_SHOWN)
35
+ lines.push(` and ${notes.length - NOTES_SHOWN} more`);
36
+ }
37
+ if (dismissed.length > 0)
38
+ lines.push(`Dismissed: ${dismissed.join(", ")}`);
39
+ return lines;
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.131.0",
3
+ "version": "0.132.1",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -62,7 +62,7 @@
62
62
  "@modelcontextprotocol/sdk": "^1.32.2",
63
63
  "commander": "^12.1.0",
64
64
  "open": "^10.1.0",
65
- "update-notifier": "^5.1.0",
65
+ "update-notifier": "^7.3.1",
66
66
  "zod": "^3.24.0"
67
67
  },
68
68
  "devDependencies": {
@@ -1,11 +1,12 @@
1
1
  # Canvas commands
2
2
 
3
- Read this for the canvas commands themselves: reading, creating, adding and editing elements, moving and removing, edges, templates, milestones and the digest. Which element to use is in [canvas-elements.md](canvas-elements.md); placing many items is in [canvas-layout.md](canvas-layout.md).
3
+ Read this for the canvas commands themselves: reading, creating, adding and editing elements, moving and removing, edges, templates, themes, milestones and the digest. Which element to use is in [canvas-elements.md](canvas-elements.md); placing many items is in [canvas-layout.md](canvas-layout.md).
4
4
 
5
5
  ## Contents
6
6
 
7
7
  - [Read, create and edit](#read-create-and-edit)
8
8
  - [Templates](#templates)
9
+ - [Themes](#themes)
9
10
  - [Milestones](#milestones)
10
11
  - [Canvas Orientation](#canvas-orientation)
11
12
 
@@ -259,6 +260,19 @@ cnotes canvas from-template <templateId> --populate # Auto-populat
259
260
  # Templates: sprint-retrospective, swot-analysis, kanban-board, feature-prioritization, meeting-notes, product-roadmap
260
261
  ```
261
262
 
263
+ ## Themes
264
+
265
+ ```bash
266
+ # Themes — the topics a canvas's notes group into, at most five. Search finds
267
+ # a canvas by them. A theme you add is kept through every summary; the rest are
268
+ # the summary's suggestions. One to four words naming a specific subject of the
269
+ # board ("Wallet order"), never a category that fits any board ("User experience").
270
+ cnotes canvas theme list <canvasId>
271
+ cnotes canvas theme add <canvasId> "Wallet order" # or keep a suggestion by its name
272
+ cnotes canvas theme dismiss <canvasId> "User experience" # off now, never suggested again
273
+ cnotes canvas theme remove <canvasId> "Wallet order" # an added theme; may be suggested again
274
+ ```
275
+
262
276
  ## Milestones
263
277
 
264
278
  ```bash