slack-term 1.28.0 → 1.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slack-term",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/slack-term.git"
package/ts/cli.ts CHANGED
@@ -95,6 +95,7 @@ import {
95
95
  } from "./todo.ts";
96
96
  import { setCacheEnabled } from "./cache.ts";
97
97
  import { dayLabel, encodeMentions, encodeMentionsDetailed, findUntaggedMentions, formatYmdHm, mentionWarnings, resolveDateMarkup, resolveMentions, type MentionEncodeResult } from "./format.ts";
98
+ import { quietHoursNotice } from "./quietHours.ts";
98
99
 
99
100
  function loadDotenv(path: string): void {
100
101
  if (!existsSync(path)) return;
@@ -892,7 +893,14 @@ function friendlySlackError(e: unknown): string {
892
893
  /** Dry-run gate: print context, print required --code=, exit 1.
893
894
  * Call this when --code is absent or wrong. */
894
895
  function requireCode(provided: string | undefined, expected: string, contextLines: string[]): void {
896
+ // The clock goes to stdout with the rest of the preview, not to stderr with
897
+ // the code. The preview is what you are asked to LOOK at before committing,
898
+ // and "what time is it where they are" is part of that picture — a caller
899
+ // doing `send ... 2>/dev/null` to read the preview would otherwise drop the
900
+ // one line added to stop a 01:00 send.
895
901
  for (const line of contextLines) console.log(line);
902
+ const clock = quietHoursNotice();
903
+ if (clock) console.log(clock);
896
904
  if (provided !== undefined) {
897
905
  console.error(`Code mismatch (got ${provided}, expected ${expected})`);
898
906
  }
@@ -0,0 +1,43 @@
1
+ /** Quiet hours in the recipients' timezone: sending here makes a human's phone
2
+ * buzz while they're asleep. Default JST because this workspace is in Japan;
3
+ * override with SLACK_QUIET_TZ / SLACK_QUIET_START / SLACK_QUIET_END.
4
+ *
5
+ * WHY this lives in the confirm gate rather than in a doc: an agent driving
6
+ * this CLI has no reason to look at a clock — the moment work finishes IS the
7
+ * moment it sends, and in a long session it doesn't notice the date rolled
8
+ * over. A rule that must be remembered gets forgotten; a line printed on the
9
+ * path every send already takes does not. (Real incident 2026-08-26: messages
10
+ * sent to an external partner at 00:44 and 01:12 JST.)
11
+ *
12
+ * Deliberately a WARNING, not a block: pager-duty style P1 outage notices
13
+ * legitimately go out at 3am, and this CLI cannot tell those apart. Blocking
14
+ * would train people to bypass the gate entirely. */
15
+ export function quietHoursNotice(now: Date = new Date()): string | null {
16
+ const tz = process.env.SLACK_QUIET_TZ ?? "Asia/Tokyo";
17
+ const start = Number(process.env.SLACK_QUIET_START ?? 23); // inclusive
18
+ const end = Number(process.env.SLACK_QUIET_END ?? 8); // exclusive
19
+ let hour: number;
20
+ let stamp: string;
21
+ try {
22
+ const fmt = new Intl.DateTimeFormat("en-GB", {
23
+ timeZone: tz,
24
+ hour12: false,
25
+ weekday: "short",
26
+ year: "numeric",
27
+ month: "2-digit",
28
+ day: "2-digit",
29
+ hour: "2-digit",
30
+ minute: "2-digit",
31
+ });
32
+ stamp = fmt.format(now);
33
+ hour = Number(
34
+ fmt.formatToParts(now).find((p) => p.type === "hour")?.value ?? "12",
35
+ );
36
+ } catch {
37
+ return null; // bad TZ override — never let the clock break sending
38
+ }
39
+ const quiet = start > end ? hour >= start || hour < end : hour >= start && hour < end;
40
+ const label = `🕐 ${stamp} (${tz})`;
41
+ if (!quiet) return label;
42
+ return `${label}\n⚠ QUIET HOURS (${start}:00-${end}:00) — this will buzz a phone. Send only for a production incident; otherwise hold it until morning.`;
43
+ }