@creator-notes/cnotes 0.137.0 → 0.139.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.137.0",
3
+ "version": "0.139.0",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -2,7 +2,7 @@ import { ApiClient } from "../lib/api-client.js";
2
2
  import { resolveBaseConfig } from "../lib/config.js";
3
3
  import { AuthError, ValidationError, handleError } from "../lib/errors.js";
4
4
  import { outputJson, outputTable } from "../lib/output.js";
5
- import { PRESETS, PRESET_IDS, EDITABLE_TOKEN_NAMES, EDITABLE_TOKEN_NAME_SET, hslTripleToHex, parseColorInput, } from "../lib/themes.js";
5
+ import { PRESETS, PRESET_IDS, EDITABLE_TOKEN_NAMES, EDITABLE_TOKEN_NAME_SET, hslTripleToHex, parseColorInput, SYSTEM_THEME_ID, describeSystemThemes, systemHalfError, } from "../lib/themes.js";
6
6
  function requireAuthedConfig(program) {
7
7
  const cfg = resolveBaseConfig(program.opts());
8
8
  if (!cfg.token)
@@ -25,6 +25,7 @@ export function registerThemeCommands(program) {
25
25
  outputJson({
26
26
  current: current.themeId,
27
27
  customBaseId: current.customBaseId,
28
+ systemThemes: current.systemThemes,
28
29
  presets: PRESETS.map((p) => ({
29
30
  id: p.id,
30
31
  name: p.name,
@@ -45,6 +46,10 @@ export function registerThemeCommands(program) {
45
46
  if (current.themeId === "custom") {
46
47
  console.log(`\nActive: custom (based on ${current.customBaseId}, ${Object.keys(current.customColors).length} overrides)`);
47
48
  }
49
+ else if (current.themeId === SYSTEM_THEME_ID && current.systemThemes) {
50
+ console.log(`\nActive: ${describeSystemThemes(current.systemThemes)}`);
51
+ }
52
+ console.log("Follow the operating system with `cnotes theme set system --light <id> --dark <id>`.");
48
53
  }
49
54
  catch (error) {
50
55
  handleError(error, cfg.json);
@@ -63,7 +68,16 @@ export function registerThemeCommands(program) {
63
68
  return;
64
69
  }
65
70
  console.log(`themeId: ${data.themeId}`);
66
- console.log(`mode: ${data.isDark ? "dark" : "light"}`);
71
+ if (data.themeId === SYSTEM_THEME_ID) {
72
+ console.log("mode: follows the operating system");
73
+ if (data.systemThemes) {
74
+ console.log(`light: ${data.systemThemes.light}`);
75
+ console.log(`dark: ${data.systemThemes.dark}`);
76
+ }
77
+ }
78
+ else {
79
+ console.log(`mode: ${data.isDark ? "dark" : "light"}`);
80
+ }
67
81
  if (data.themeId === "custom") {
68
82
  console.log(`customBaseId: ${data.customBaseId}`);
69
83
  }
@@ -89,11 +103,42 @@ export function registerThemeCommands(program) {
89
103
  });
90
104
  theme
91
105
  .command("set")
92
- .description("Switch to a built-in theme preset")
93
- .argument("<id>", "Preset ID (run `cnotes theme list` to see all)")
94
- .action(async (id) => {
106
+ .description("Switch to a built-in theme preset, or to `system` to follow the operating system")
107
+ .argument("<id>", "Preset ID, or `system` (run `cnotes theme list` to see all)")
108
+ .option("--light <id>", "With `system`: the light theme to use while the operating system is light")
109
+ .option("--dark <id>", "With `system`: the dark theme to use while the operating system is dark")
110
+ .action(async (id, opts) => {
95
111
  const cfg = requireAuthedConfig(program);
96
112
  const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
113
+ if (id === SYSTEM_THEME_ID) {
114
+ for (const half of ["light", "dark"]) {
115
+ const chosen = opts[half];
116
+ const problem = chosen === undefined ? null : systemHalfError(half, chosen);
117
+ if (problem)
118
+ throw new ValidationError(problem);
119
+ }
120
+ try {
121
+ const data = await api.put("/api/theme", {
122
+ themeId: SYSTEM_THEME_ID,
123
+ ...(opts.light ? { systemLightThemeId: opts.light } : {}),
124
+ ...(opts.dark ? { systemDarkThemeId: opts.dark } : {}),
125
+ });
126
+ if (cfg.json) {
127
+ outputJson(data);
128
+ }
129
+ else {
130
+ console.log(`Theme set to ${data.systemThemes ? describeSystemThemes(data.systemThemes) : "Match system"}.`);
131
+ console.log("Reload an open browser tab to see the change.");
132
+ }
133
+ }
134
+ catch (error) {
135
+ handleError(error, cfg.json);
136
+ }
137
+ return;
138
+ }
139
+ if (opts.light !== undefined || opts.dark !== undefined) {
140
+ throw new ValidationError("--light and --dark only go with `cnotes theme set system`.");
141
+ }
97
142
  if (id === "custom") {
98
143
  throw new ValidationError("`cnotes theme set custom` is not supported. Use `cnotes theme set-color <token> <color>` to enter custom mode (it seeds the base palette atomically).");
99
144
  }
@@ -119,7 +164,8 @@ export function registerThemeCommands(program) {
119
164
  .description("Override a single token color (switches theme to 'custom')")
120
165
  .argument("<token>", "Editable token name (e.g. primary, background)")
121
166
  .argument("<color>", 'HSL ("310 85% 67%"), HSL with alpha ("310 85% 67% / 0.5"), hex ("#ff00aa"), or "transparent"')
122
- .action(async (token, color) => {
167
+ .option("--base <id>", "Preset to start the custom theme from (needed under Match system)")
168
+ .action(async (token, color, opts) => {
123
169
  const cfg = requireAuthedConfig(program);
124
170
  const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
125
171
  if (!EDITABLE_TOKEN_NAME_SET.has(token)) {
@@ -135,8 +181,16 @@ export function registerThemeCommands(program) {
135
181
  // We still need the current themeId to seed customBaseId on the
136
182
  // first transition into custom — once we're already custom, the
137
183
  // server preserves the existing base.
184
+ if (opts.base !== undefined && !PRESET_IDS.has(opts.base)) {
185
+ throw new ValidationError(`Unknown theme id: ${opts.base}. Run \`cnotes theme list\` to see available presets.`);
186
+ }
138
187
  const current = await api.get("/api/theme");
139
- const customBaseId = current.themeId === "custom" ? undefined : current.themeId;
188
+ // Match system paints a different theme on each device, so there is
189
+ // no one theme to fork: the caller names it.
190
+ if (current.themeId === SYSTEM_THEME_ID && opts.base === undefined) {
191
+ throw new ValidationError("Your theme follows the operating system, so there is no single theme to start from. Pass --base <id>, for example --base light.");
192
+ }
193
+ const customBaseId = opts.base ?? (current.themeId === "custom" ? undefined : current.themeId);
140
194
  const data = await api.patch("/api/theme/colors", {
141
195
  customColors: { [token]: normalized },
142
196
  ...(customBaseId ? { customBaseId } : {}),
@@ -23,6 +23,8 @@ export const PRESETS = [
23
23
  { id: "dracula", name: "Dracula", isDark: true, description: "Iconic high-contrast dark with purple accent." },
24
24
  { id: "solarized-dark", name: "Solarized Dark", isDark: true, description: "Ethan Schoonover's classic teal-on-navy palette." },
25
25
  { id: "rose-pine", name: "Rosé Pine", isDark: true, description: "Soho-vibes for the pastel-loving developer." },
26
+ { id: "cursor-light", name: "Cursor Light", isDark: false, description: "Cursor's own light theme: near-white panels, one soft-black ink at set strengths, a dark send button and a blue focus." },
27
+ { id: "claude-light", name: "Claude Light", isDark: false, description: "Claude's ivory panels stepping lighter from the rail to the canvas to the note, warm ink in three tiers, and a quiet blue for links and focus." },
26
28
  { id: "sage", name: "Sage", isDark: false, description: "Muted greenish-grey, easy on the eyes." },
27
29
  { id: "sage-2", name: "Sage 2", isDark: false, description: "Sage's green-grey in quiet steps: dark green ink in three tiers, cards lifted toward the light, and one blue for focus." },
28
30
  { id: "light", name: "Light", isDark: false, description: "Clean classic light." },
@@ -44,6 +46,29 @@ export const EDITABLE_TOKEN_NAMES = [
44
46
  export const EDITABLE_TOKEN_NAME_SET = new Set(EDITABLE_TOKEN_NAMES);
45
47
  /** All known preset ids — kept in sync with lib/themes/presets.ts PRESET_IDS. */
46
48
  export const PRESET_IDS = new Set(PRESETS.map((p) => p.id));
49
+ /**
50
+ * Match system: the theme that follows the operating system's light or dark
51
+ * setting, with one light and one dark preset. Mirrors lib/themes/system.ts;
52
+ * the server checks the halves too.
53
+ */
54
+ export const SYSTEM_THEME_ID = "system";
55
+ /** Why `id` cannot be this half, or null when it can. */
56
+ export function systemHalfError(half, id) {
57
+ const preset = PRESETS.find((p) => p.id === id);
58
+ if (!preset)
59
+ return `Unknown theme id: ${id}. Run \`cnotes theme list\` to see available presets.`;
60
+ const wantDark = half === "dark";
61
+ if (preset.isDark !== wantDark) {
62
+ const allowed = PRESETS.filter((p) => p.isDark === wantDark).map((p) => p.id).join(", ");
63
+ return `${id} is a ${preset.isDark ? "dark" : "light"} theme, so it cannot be the ${half} one. ${half === "light" ? "Light" : "Dark"} themes: ${allowed}`;
64
+ }
65
+ return null;
66
+ }
67
+ /** "Match system (light: Light, dark: Cursor)". */
68
+ export function describeSystemThemes(themes) {
69
+ const name = (id) => PRESETS.find((p) => p.id === id)?.name ?? id;
70
+ return `Match system (light: ${name(themes.light)}, dark: ${name(themes.dark)})`;
71
+ }
47
72
  const HEX3 = /^#?([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])$/;
48
73
  const HEX6 = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;
49
74
  export function parseHex(hex) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.137.0",
3
+ "version": "0.139.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {