daily-color 4.0.1 → 4.1.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.
package/README.md CHANGED
@@ -91,6 +91,7 @@ Using the CLI:
91
91
  dailycolor # today's color
92
92
  dailycolor complementary # the color opposite it
93
93
  dailycolor triadic analogous # several, labeled
94
+ dailycolor --date tomorrow # tomorrow's color (or today, or yesterday)
94
95
  dailycolor all --date 2027-01-01 # everything, for another day
95
96
  dailycolor --help # all the options
96
97
  dailycolor --version
@@ -100,9 +101,9 @@ dailycolor --version
100
101
 
101
102
  daily-color comes with an [MCP](https://modelcontextprotocol.io) server, so an AI assistant can look up the color of any day and the colors that go with it. It has:
102
103
 
103
- - A tool, `get_daily_colors`, which the AI uses when it wants colors. It takes an optional `date` (like `2027-01-01`, today if left out) and `days` (up to 31 days in a row).
104
+ - A tool, `get_daily_colors`, which the AI uses when it wants colors. It takes an optional `date` (like `2027-01-01`, or `today`, `tomorrow` or `yesterday`; today if left out) and `days` (up to 31 days in a row).
104
105
  - Resources, which you can attach to a conversation yourself: `daily-color://today`, or any day, like `daily-color://2027-01-01`. Apps that subscribe to `daily-color://today` hear when it changes at midnight.
105
- - A prompt, `theme_from_daily_color`, which asks for a website color theme made from a day's colors. It takes an optional `date`, and `mode` (`light` or `dark`, or leave it out for both). In Claude Code it's the `/mcp__daily-color__theme_from_daily_color` command.
106
+ - A prompt, `theme_from_daily_color`, which asks for a website color theme made from a day's colors. It takes an optional `date`, and `mode` (`light` or `dark`, or leave it out for both). In Claude Code it's the `/mcp__daily-color__theme_from_daily_color` command, like `/mcp__daily-color__theme_from_daily_color tomorrow dark`.
106
107
 
107
108
  Apps that support it can suggest dates and modes as you type them.
108
109
 
@@ -56,6 +56,11 @@ const METHOD_NOT_FOUND = -32601;
56
56
  const INVALID_PARAMS = -32602;
57
57
  const RESOURCE_NOT_FOUND = -32002; // MCP's own code, for resources/read
58
58
 
59
+ // Days that can be named instead of written as a date, and how far they are from today
60
+ const NAMED_DAYS = { today: 0, tomorrow: 1, yesterday: -1 };
61
+ const NAMED_DAYS_PATTERN = Object.keys(NAMED_DAYS).join("|");
62
+ const DATE_HELP = "YYYY-MM-DD, or today, tomorrow or yesterday";
63
+
59
64
  const HEX = { type: "string", pattern: "^#[0-9a-f]{6}$" };
60
65
  const PAIR = { type: "array", items: HEX, minItems: 2, maxItems: 2 };
61
66
 
@@ -95,8 +100,8 @@ const TOOLS = [
95
100
  properties: {
96
101
  date: {
97
102
  type: "string",
98
- pattern: "^\\d{4}-\\d{2}-\\d{2}$",
99
- description: "The day, as YYYY-MM-DD. Leave it out for today.",
103
+ pattern: `^(\\d{4}-\\d{2}-\\d{2}|${NAMED_DAYS_PATTERN})$`,
104
+ description: `The day, as ${DATE_HELP}. Leave it out for today.`,
100
105
  },
101
106
  days: {
102
107
  type: "integer",
@@ -151,10 +156,16 @@ function today() {
151
156
  // 2027-02-30, would roll over into the next month, and Date reads years 0 to
152
157
  // 99 as 1900 to 1999, so the day has to come back as it went in.
153
158
  function parseDate(value) {
154
- const m = typeof value === "string" && /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
159
+ const name = typeof value === "string" ? value.trim().toLowerCase() : "";
160
+ if (Object.hasOwn(NAMED_DAYS, name)) {
161
+ const start = today();
162
+ return new Date(start.getFullYear(), start.getMonth(), start.getDate() + NAMED_DAYS[name]);
163
+ }
164
+
165
+ const m = typeof value === "string" && /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.trim());
155
166
  const day = m && new Date(+m[1], +m[2] - 1, +m[3]);
156
167
  if (!day || day.getFullYear() !== +m[1] || day.getMonth() !== +m[2] - 1) {
157
- throw new ArgumentError(`"${value}" isn't a date like 2027-01-01`);
168
+ throw new ArgumentError(`"${value}" isn't a date like 2027-01-01, or today, tomorrow or yesterday`);
158
169
  }
159
170
  return day;
160
171
  }
@@ -198,7 +209,7 @@ const RESOURCE_TEMPLATES = [
198
209
  uriTemplate: "daily-color://{date}",
199
210
  name: "day",
200
211
  title: "A day's colors",
201
- description: "The color for a date (YYYY-MM-DD) and the colors that go with it",
212
+ description: `The color for a day (${DATE_HELP}) and the colors that go with it`,
202
213
  mimeType: "application/json",
203
214
  },
204
215
  ];
@@ -208,7 +219,7 @@ function resourceDay(uri) {
208
219
  const m = /^daily-color:\/\/(.+)$/.exec(uri ?? "");
209
220
  try {
210
221
  if (!m) throw new ArgumentError(`There's no resource at ${uri}`);
211
- return m[1] === "today" ? today() : parseDate(m[1]);
222
+ return parseDate(m[1]);
212
223
  } catch (error) {
213
224
  if (error instanceof ArgumentError) throw rpcError(RESOURCE_NOT_FOUND, error.message);
214
225
  throw error;
@@ -220,8 +231,8 @@ function readResource({ uri } = {}) {
220
231
  return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify(colors, null, 2) }] };
221
232
  }
222
233
 
223
- // Subscriptions. Only daily-color://today ever changes, but subscribing to
224
- // a particular day is allowed too: it just never sends anything.
234
+ // Subscriptions. Only today, tomorrow and yesterday ever change, but
235
+ // subscribing to a particular date is allowed too: it just never sends anything.
225
236
  const subscriptions = new Set();
226
237
 
227
238
  function subscribe({ uri } = {}) {
@@ -249,8 +260,11 @@ function watchTheDate() {
249
260
  const day = formatDate(today());
250
261
  if (day !== lastDay) {
251
262
  lastDay = day;
252
- if (subscriptions.has("daily-color://today")) {
253
- send({ jsonrpc: "2.0", method: "notifications/resources/updated", params: { uri: "daily-color://today" } });
263
+ // Today, tomorrow and yesterday all move on a day
264
+ for (const name of Object.keys(NAMED_DAYS)) {
265
+ const uri = `daily-color://${name}`;
266
+ if (subscriptions.has(uri))
267
+ send({ jsonrpc: "2.0", method: "notifications/resources/updated", params: { uri } });
254
268
  }
255
269
  }
256
270
  watchTheDate();
@@ -268,7 +282,7 @@ const PROMPTS = [
268
282
  description:
269
283
  "Make a website color theme, as CSS custom properties, from a day's color and the colors that go with it",
270
284
  arguments: [
271
- { name: "date", description: "The day, as YYYY-MM-DD. Leave it out for today.", required: false },
285
+ { name: "date", description: `The day, as ${DATE_HELP}. Leave it out for today.`, required: false },
272
286
  { name: "mode", description: '"light", "dark", or leave it out for both', required: false },
273
287
  ],
274
288
  },
@@ -349,6 +363,7 @@ const METHODS = {
349
363
  serverInfo: { name: "daily-color", title: "Daily color", version, icons: [icon()] },
350
364
  instructions:
351
365
  "Look up the color of any day, and the colors that go with it, with get_daily_colors. " +
366
+ "Dates can be YYYY-MM-DD, or today, tomorrow or yesterday. " +
352
367
  "The same colors are resources at daily-color://YYYY-MM-DD and daily-color://today.",
353
368
  }),
354
369
  ping: () => ({}),
@@ -398,9 +413,9 @@ function getCompletions({ ref = {}, argument = {} } = {}) {
398
413
 
399
414
  if (ref.type === "ref/prompt" && ref.name === "theme_from_daily_color") {
400
415
  if (name === "mode") return complete(["light", "dark"], value);
401
- if (name === "date") return complete(dateSuggestions(value), value);
416
+ if (name === "date") return complete([...Object.keys(NAMED_DAYS), ...dateSuggestions(value)], value);
402
417
  } else if (ref.type === "ref/resource" && ref.uri === "daily-color://{date}") {
403
- if (name === "date") return complete(["today", ...dateSuggestions(value)], value);
418
+ if (name === "date") return complete([...Object.keys(NAMED_DAYS), ...dateSuggestions(value)], value);
404
419
  } else {
405
420
  throw rpcError(INVALID_PARAMS, `Nothing to complete for ${ref.name ?? ref.uri}`);
406
421
  }
package/bin/dailycolor.js CHANGED
@@ -4,7 +4,7 @@ import { readFileSync } from "node:fs";
4
4
 
5
5
  import { getDailyPalette } from "../index.js";
6
6
 
7
- const HELP = `Usage: dailycolor [colors...] [--date YYYY-MM-DD]
7
+ const HELP = `Usage: dailycolor [colors...] [--date YYYY-MM-DD|today|tomorrow|yesterday]
8
8
 
9
9
  Prints today's color as a hex code. Name other colors to print the ones that
10
10
  go with it instead.
@@ -20,13 +20,14 @@ Colors:
20
20
  all all of the above, labeled
21
21
 
22
22
  Options:
23
- -d, --date <date> another day, like 2027-01-01
23
+ -d, --date <date> another day, like 2027-01-01, tomorrow or yesterday
24
24
  -h, --help show this help
25
25
  -v, --version show the version number
26
26
 
27
27
  Examples:
28
28
  dailycolor
29
29
  dailycolor complementary
30
+ dailycolor --date tomorrow
30
31
  dailycolor all --date 2027-01-01`;
31
32
 
32
33
  // "split-complementary" on the command line, splitComplementary in the palette
@@ -40,6 +41,9 @@ const NAMES = {
40
41
  tetradic: "tetradic",
41
42
  };
42
43
 
44
+ // Days that can be named instead of written as a date, and how far they are from today
45
+ const NAMED_DAYS = { today: 0, tomorrow: 1, yesterday: -1 };
46
+
43
47
  function fail(message) {
44
48
  console.error(`dailycolor: ${message}\nRun "dailycolor --help" to see what it can do.`);
45
49
  process.exit(1);
@@ -72,10 +76,16 @@ for (let i = 0; i < args.length; i++) {
72
76
 
73
77
  // A day where you are, not UTC midnight
74
78
  function parseDate(value) {
79
+ const name = (value || "").trim().toLowerCase();
80
+ if (Object.hasOwn(NAMED_DAYS, name)) {
81
+ const now = new Date();
82
+ return new Date(now.getFullYear(), now.getMonth(), now.getDate() + NAMED_DAYS[name]);
83
+ }
84
+
75
85
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value || "");
76
86
  const day = m && new Date(+m[1], +m[2] - 1, +m[3]);
77
87
  if (!day || day.getFullYear() !== +m[1] || day.getMonth() !== +m[2] - 1)
78
- fail(`"${value ?? ""}" isn't a date like 2027-01-01`);
88
+ fail(`"${value ?? ""}" isn't a date like 2027-01-01, or today, tomorrow or yesterday`);
79
89
  return day;
80
90
  }
81
91
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daily-color",
3
- "version": "4.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Provides a unique hex code each day",
5
5
  "keywords": [
6
6
  "color",