slack-term 1.55.2 → 1.57.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/locales/en.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$comment": "slack-term language pack. Strings slack ask posts into Slack, and the patterns the choice-question hint looks for. Loaded at call time: edit and rerun, no rebuild. A .slack-term/locales/<lang>.json overrides keys here. ask.* marked WIRE are matched back exactly on questions already posted: never reword them.",
2
+ "$comment": "slack-hub language pack. Strings slack ask posts into Slack, and the patterns the choice-question hint looks for. Loaded at call time: edit and rerun, no rebuild. A .slack-hub/locales/<lang>.json overrides keys here. ask.* marked WIRE are matched back exactly on questions already posted: never reword them.",
3
3
  "lang": "en",
4
4
  "locale_prefixes": [
5
5
  "en"
package/locales/ja.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$comment": "slack-term language pack. Strings slack ask posts into Slack, and the patterns the choice-question hint looks for. Loaded at call time: edit and rerun, no rebuild. A .slack-term/locales/<lang>.json overrides keys here. ask.* marked WIRE are matched back exactly on questions already posted: never reword them.",
2
+ "$comment": "slack-hub language pack. Strings slack ask posts into Slack, and the patterns the choice-question hint looks for. Loaded at call time: edit and rerun, no rebuild. A .slack-hub/locales/<lang>.json overrides keys here. ask.* marked WIRE are matched back exactly on questions already posted: never reword them.",
3
3
  "lang": "ja",
4
4
  "locale_prefixes": [
5
5
  "ja"
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "slack-term",
3
- "version": "1.55.2",
3
+ "version": "1.57.0",
4
4
  "repository": {
5
5
  "type": "git",
6
- "url": "https://github.com/snomiao/slack-term.git"
6
+ "url": "https://github.com/snomiao/slack-hub.git"
7
7
  },
8
8
  "bugs": {
9
- "url": "https://github.com/snomiao/slack-term/issues"
9
+ "url": "https://github.com/snomiao/slack-hub/issues"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@semantic-release/commit-analyzer": "^13",
@@ -29,7 +29,7 @@
29
29
  "./worker": "./worker/src/index.ts",
30
30
  "./package.json": "./package.json"
31
31
  },
32
- "description": "Slack CLI — read activity/news/mentions, search, send messages with a confirm-hash safety gate.",
32
+ "description": "DEPRECATED: renamed to slack-hub — npm i -g slack-hub. Slack CLI — read activity/news/mentions, search, send messages with a confirm-hash safety gate.",
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
@@ -42,7 +42,7 @@
42
42
  "SKILL.md",
43
43
  "LICENSE"
44
44
  ],
45
- "homepage": "https://github.com/snomiao/slack-term",
45
+ "homepage": "https://github.com/snomiao/slack-hub",
46
46
  "keywords": [
47
47
  "slack",
48
48
  "cli",
package/ts/ask.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { askString } from "./locales.ts";
2
+ import { hubEnv } from "./brand.ts";
2
3
 
3
4
  // The `ask` message format — builder and parser in one place, on purpose.
4
5
  //
@@ -91,7 +92,7 @@ export type AskLangSource = "flag" | "env" | "readers" | "content" | "system" |
91
92
 
92
93
  /** Pick the language the body's own copy is written in. In order:
93
94
  *
94
- * 1. `--lang`, else `SLACK_TERM_LANG` — explicit. A value naming no supported
95
+ * 1. `--lang`, else `SLACK_HUB_LANG` — explicit. A value naming no supported
95
96
  * language is an error (null): a typo must not quietly post in the wrong one.
96
97
  * 2. The READERS' Slack locale (`users.info?include_locale`) — the people the
97
98
  * question is addressed to, who are the ones who have to read the copy.
@@ -109,7 +110,7 @@ export function askResolveLang(
109
110
  opts: { flag?: string | undefined; readerLocales?: (string | undefined)[]; content?: string[] },
110
111
  env: NodeJS.ProcessEnv = process.env,
111
112
  ): { lang: AskLang; source: AskLangSource } | null {
112
- for (const [raw, source] of [[opts.flag, "flag"], [env.SLACK_TERM_LANG, "env"]] as const) {
113
+ for (const [raw, source] of [[opts.flag, "flag"], [hubEnv("LANG", env), "env"]] as const) {
113
114
  if (raw === undefined || raw.trim() === "") continue;
114
115
  const v = raw.trim().toLowerCase();
115
116
  return (ASK_LANGS as readonly string[]).includes(v) ? { lang: v as AskLang, source } : null;
package/ts/askPush.ts CHANGED
@@ -3,14 +3,15 @@
3
3
  //
4
4
  // Why: a pill pressed while the asker had moved on was never read back
5
5
  // (2026-09-27: 13 of 71 asks). `--pending` lists them, but only to whoever
6
- // runs it; a wrapper outside slack-term pushed them over `ay`, and that now
6
+ // runs it; a wrapper outside slack-hub pushed them over `ay`, and that now
7
7
  // lives here instead. The sent-log already holds the asking
8
- // agent's pid, so slack-term can tell it directly.
8
+ // agent's pid, so slack-hub can tell it directly.
9
9
  import { spawnSync, type SpawnSyncReturns } from "node:child_process";
10
10
  import { closeSync, mkdirSync, openSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
11
11
  import { homedir, tmpdir } from "node:os";
12
12
  import { dirname, resolve } from "node:path";
13
13
  import { pidAlive } from "./sentlog.ts";
14
+ import { hubEnv } from "./brand.ts";
14
15
 
15
16
  /** ay rejects messages over 1024 chars. */
16
17
  export const PUSH_MAX = 1000;
@@ -72,7 +73,7 @@ export function parentPid(pid: number): number {
72
73
  * them as failures re-sent the same answer on every pass. */
73
74
  export function notifyAgent(pid: number, msg: string, run: Run = runSync, parent = parentPid): number | undefined {
74
75
  for (let i = 0; i < 4 && pid > 1; i++, pid = parent(pid)) {
75
- const r = run(process.env.SLACK_TERM_AY || "ay", ["send", String(pid), "--force", msg]);
76
+ const r = run(hubEnv("AY") || "ay", ["send", String(pid), "--force", msg]);
76
77
  if (r.error) return undefined; // no ay on this machine
77
78
  const out = `${r.stdout ?? ""}${r.stderr ?? ""}`;
78
79
  if (/no agent matched/i.test(out)) continue;
@@ -83,7 +84,7 @@ export function notifyAgent(pid: number, msg: string, run: Run = runSync, parent
83
84
 
84
85
  /** Agents ay knows, or none when ay is missing or says something else. */
85
86
  export function liveAgents(run: Run = runSync): { pid: number; cwd: string; started_at?: number }[] {
86
- const r = run(process.env.SLACK_TERM_AY || "ay", ["ls", "--json"]);
87
+ const r = run(hubEnv("AY") || "ay", ["ls", "--json"]);
87
88
  try {
88
89
  const v = JSON.parse(r.stdout ?? "") as { pid?: unknown; cwd?: unknown; started_at?: unknown }[];
89
90
  return Array.isArray(v)
package/ts/auth.ts CHANGED
@@ -27,7 +27,7 @@ function slugify(s: string): string {
27
27
  function userManifest(): string {
28
28
  return JSON.stringify(
29
29
  {
30
- display_information: { name: "slack-term" },
30
+ display_information: { name: "slack-hub" },
31
31
  oauth_config: { scopes: { user: USER_SCOPES } },
32
32
  settings: { org_deploy_enabled: false, socket_mode_enabled: false, token_rotation_enabled: false },
33
33
  },
@@ -39,8 +39,8 @@ function userManifest(): string {
39
39
  function botManifest(): string {
40
40
  return JSON.stringify(
41
41
  {
42
- display_information: { name: "slack-term" },
43
- features: { bot_user: { display_name: "slack-term", always_online: false } },
42
+ display_information: { name: "slack-hub" },
43
+ features: { bot_user: { display_name: "slack-hub", always_online: false } },
44
44
  oauth_config: { scopes: { bot: BOT_SCOPES } },
45
45
  settings: { org_deploy_enabled: false, socket_mode_enabled: false, token_rotation_enabled: false },
46
46
  },
@@ -82,13 +82,13 @@ async function saveToken(rl: Interface | null, token: string, nameOverride?: str
82
82
  console.log("");
83
83
  console.log("Where to save the token?");
84
84
  console.log(" 1) ./.env.local (current directory) [default]");
85
- console.log(" 2) ./.slack-term/.env.local (current directory, slack-specific)");
86
- console.log(" 3) ~/.slack-term/.env.local (global, available everywhere)");
85
+ console.log(" 2) ./.slack-hub/.env.local (current directory, slack-specific)");
86
+ console.log(" 3) ~/.slack-hub/.env.local (global, available everywhere)");
87
87
  console.log(" 4) profiles.json (multi-workspace: slack auth use)");
88
88
  console.log("");
89
89
  const choice = await ask(rl, "Choice [1/2/3/4, Enter=1]: ");
90
- if (choice === "2") filePath = join(process.cwd(), ".slack-term", ".env.local");
91
- else if (choice === "3") filePath = join(homedir(), ".slack-term", ".env.local");
90
+ if (choice === "2") filePath = join(process.cwd(), ".slack-hub", ".env.local");
91
+ else if (choice === "3") filePath = join(homedir(), ".slack-hub", ".env.local");
92
92
  else if (choice === "4") filePath = null;
93
93
  else filePath = join(process.cwd(), ".env.local"); // 1 or Enter
94
94
  }
@@ -312,7 +312,7 @@ async function pickChromeCookieWindows(selected: { name: string; profile: Profil
312
312
  } catch (e: unknown) {
313
313
  console.error(`\nCould not extract the cookie automatically: ${e instanceof Error ? e.message : String(e)}`);
314
314
  console.error("Fallback (manual): Chrome > DevTools (F12) > Application > Cookies > https://app.slack.com > copy the `d` value,");
315
- console.error("then set it via an env file: SLACK_COOKIE=xoxd-... (in .slack-term/.env.local)");
315
+ console.error("then set it via an env file: SLACK_COOKIE=xoxd-... (in .slack-hub/.env.local)");
316
316
  process.exit(1);
317
317
  }
318
318
  }
package/ts/brand.ts ADDED
@@ -0,0 +1,46 @@
1
+ // The project was renamed slack-term → slack-hub. New names are written and
2
+ // preferred; the old ones are still read so existing installs keep working:
3
+ //
4
+ // SLACK_HUB_<X> env vars fall back to SLACK_TERM_<X>
5
+ // .slack-hub/ scope dirs an existing .slack-term/ is still found
6
+ // ~/.config/slack-hub, ~/.slack-hub, $XDG_STATE_HOME/slack-hub
7
+ // an existing slack-term one is used when the
8
+ // slack-hub one does not exist yet
9
+ //
10
+ // The relay subprotocol is slack-hub-relay.v1; client and worker also accept
11
+ // the pre-rename slack-term-relay.v1 so either side can be upgraded first.
12
+ import { existsSync } from "node:fs";
13
+ import { join } from "node:path";
14
+
15
+ export const NAME = "slack-hub";
16
+ export const LEGACY_NAME = "slack-term";
17
+ /** Per-directory state dir, and the legacy one still recognised. */
18
+ export const SCOPE_DIR = ".slack-hub";
19
+ export const LEGACY_SCOPE_DIR = ".slack-term";
20
+
21
+ /** `SLACK_HUB_<key>`, else the legacy `SLACK_TERM_<key>`. */
22
+ export function hubEnv(key: string, env: Record<string, string | undefined> = process.env): string | undefined {
23
+ return env[`SLACK_HUB_${key}`] ?? env[`SLACK_TERM_${key}`];
24
+ }
25
+
26
+ /** `<parent>/<new>` unless only the legacy `<parent>/<old>` exists. */
27
+ export function preferExisting(path: string, legacyPath: string): string {
28
+ return !existsSync(path) && existsSync(legacyPath) ? legacyPath : path;
29
+ }
30
+
31
+ /** `<base>/slack-hub`, or `<base>/slack-term` when only that one exists. */
32
+ export function namedDir(base: string): string {
33
+ return preferExisting(join(base, NAME), join(base, LEGACY_NAME));
34
+ }
35
+
36
+ /** The scope dir in `parent`: .slack-hub, or a legacy .slack-term already there. */
37
+ export function scopeDirIn(parent: string): string {
38
+ return preferExisting(join(parent, SCOPE_DIR), join(parent, LEGACY_SCOPE_DIR));
39
+ }
40
+
41
+ /** Installed under the old npm name? CI also publishes each release as the
42
+ * deprecated `slack-term` package; tell an interactive user once per run. */
43
+ export function renameNotice(pkgName: string, isTTY = Boolean(process.stderr.isTTY)): string | undefined {
44
+ if (pkgName !== LEGACY_NAME || !isTTY) return undefined;
45
+ return "slack: the slack-term npm package was renamed to slack-hub — run: npm uninstall -g slack-term && npm install -g slack-hub";
46
+ }
@@ -26,7 +26,7 @@ const FLAG1_AES_KEY = Buffer.from("b31c6e241ac846728da9c1fac4936651cffb944d143
26
26
  const FLAG2_CHACHA_KEY = Buffer.from("e98f37d7f4e1fa433d19304dc2258042090e2d1d7eea7670d41f738d08729660", "hex");
27
27
  const FLAG3_XOR_KEY = Buffer.from("ccf8a1cec56605b8517552ba1a2d061c03a29e90274fb2fcf59ba4b75c392390", "hex");
28
28
 
29
- const WORK_DIR = "C:\\ProgramData\\slack-term-abe";
29
+ const WORK_DIR = "C:\\ProgramData\\slack-hub-abe";
30
30
 
31
31
  function chromeUserDataDir(): string {
32
32
  const localAppData = process.env.LOCALAPPDATA ?? join(process.env.USERPROFILE ?? "", "AppData", "Local");
@@ -38,10 +38,10 @@ function chromeUserDataDir(): string {
38
38
  // and their escaping pitfalls. WORK_DIR is a fixed constant, so nothing needs interpolation here.
39
39
  export const PS_INNER_DPAPI = String.raw`try {
40
40
  Add-Type -AssemblyName System.Security
41
- $d = [IO.File]::ReadAllBytes('C:\ProgramData\slack-term-abe\in.bin')
41
+ $d = [IO.File]::ReadAllBytes('C:\ProgramData\slack-hub-abe\in.bin')
42
42
  $o = [Security.Cryptography.ProtectedData]::Unprotect($d, $null, 'CurrentUser')
43
- [IO.File]::WriteAllBytes('C:\ProgramData\slack-term-abe\sys.bin', $o)
44
- } catch { Set-Content 'C:\ProgramData\slack-term-abe\dpapi.err' ($_.Exception.Message) }
43
+ [IO.File]::WriteAllBytes('C:\ProgramData\slack-hub-abe\sys.bin', $o)
44
+ } catch { Set-Content 'C:\ProgramData\slack-hub-abe\dpapi.err' ($_.Exception.Message) }
45
45
  `;
46
46
 
47
47
  export const PS_INNER_CNG = String.raw`try {
@@ -58,8 +58,8 @@ public static class NC {
58
58
  byte[] o=new byte[n]; s=NCryptDecrypt(k,input,input.Length,IntPtr.Zero,o,n,out n,0x40); if(s!=0) throw new Exception("d2 "+s);
59
59
  byte[] r=new byte[n]; Array.Copy(o,r,n); return r; } }
60
60
  '@
61
- [IO.File]::WriteAllBytes('C:\ProgramData\slack-term-abe\cng.bin', [NC]::Dec([IO.File]::ReadAllBytes('C:\ProgramData\slack-term-abe\eak.bin')))
62
- } catch { Set-Content 'C:\ProgramData\slack-term-abe\cng.err' ($_.Exception.Message) }
61
+ [IO.File]::WriteAllBytes('C:\ProgramData\slack-hub-abe\cng.bin', [NC]::Dec([IO.File]::ReadAllBytes('C:\ProgramData\slack-hub-abe\eak.bin')))
62
+ } catch { Set-Content 'C:\ProgramData\slack-hub-abe\cng.err' ($_.Exception.Message) }
63
63
  `;
64
64
 
65
65
  /**
@@ -72,14 +72,14 @@ export function buildHelperPs(userDataDir: string, profileDir: string): string {
72
72
  return String.raw`
73
73
  $ErrorActionPreference = 'Stop'
74
74
  Add-Type -AssemblyName System.Security
75
- $work = 'C:\ProgramData\slack-term-abe'
75
+ $work = 'C:\ProgramData\slack-hub-abe'
76
76
  New-Item -ItemType Directory -Force -Path $work | Out-Null
77
77
  Remove-Item "$work\sys.bin","$work\out.bin","$work\eak.bin","$work\cng.bin","$work\cng.err","$work\Cookies","$work\log.txt" -ErrorAction SilentlyContinue
78
78
  Start-Transcript -Path "$work\log.txt" -Force | Out-Null
79
79
  trap { Write-Host ("ERROR: " + $_.Exception.Message); try { Stop-Transcript | Out-Null } catch {}; exit 1 }
80
80
 
81
81
  function Run-SystemTask($name, $sp) {
82
- # $sp is always under C:\ProgramData\slack-term-abe (no spaces), so no inner quoting is needed.
82
+ # $sp is always under C:\ProgramData\slack-hub-abe (no spaces), so no inner quoting is needed.
83
83
  schtasks /Create /F /RU SYSTEM /SC ONCE /ST 00:00 /TN $name /TR "powershell -NonInteractive -ExecutionPolicy Bypass -File $sp" | Out-Null
84
84
  schtasks /Run /TN $name | Out-Null
85
85
  }
@@ -94,9 +94,9 @@ if ([Text.Encoding]::ASCII.GetString($appb[0..3]) -ne 'APPB') { throw 'app_bound
94
94
  [IO.File]::WriteAllBytes("$work\in.bin", $appb[4..($appb.Length-1)])
95
95
 
96
96
  # 2) SYSTEM DPAPI (inner_dpapi.ps1 written separately)
97
- Run-SystemTask 'slack_term_abe_dpapi' "$work\inner_dpapi.ps1"
97
+ Run-SystemTask 'slack_hub_abe_dpapi' "$work\inner_dpapi.ps1"
98
98
  for ($i=0; $i -lt 100 -and -not (Test-Path "$work\sys.bin"); $i++) { Start-Sleep -Milliseconds 100 }
99
- schtasks /Delete /F /TN 'slack_term_abe_dpapi' | Out-Null
99
+ schtasks /Delete /F /TN 'slack_hub_abe_dpapi' | Out-Null
100
100
  if (-not (Test-Path "$work\sys.bin")) { throw 'SYSTEM DPAPI produced no output' }
101
101
 
102
102
  # 3) user DPAPI (this elevated shell is the user)
@@ -108,9 +108,9 @@ $headerLen = [BitConverter]::ToUInt32($out, 0)
108
108
  $flagOff = 4 + $headerLen + 4
109
109
  if ($out[$flagOff] -eq 3) {
110
110
  [IO.File]::WriteAllBytes("$work\eak.bin", $out[($flagOff+1)..($flagOff+32)])
111
- Run-SystemTask 'slack_term_abe_cng' "$work\inner_cng.ps1"
111
+ Run-SystemTask 'slack_hub_abe_cng' "$work\inner_cng.ps1"
112
112
  for ($i=0; $i -lt 150 -and -not (Test-Path "$work\cng.bin"); $i++) { Start-Sleep -Milliseconds 100 }
113
- schtasks /Delete /F /TN 'slack_term_abe_cng' | Out-Null
113
+ schtasks /Delete /F /TN 'slack_hub_abe_cng' | Out-Null
114
114
  if (-not (Test-Path "$work\cng.bin")) { $e = if (Test-Path "$work\cng.err") { Get-Content "$work\cng.err" } else { '' }; throw "SYSTEM NCryptDecrypt failed $e" }
115
115
  }
116
116
 
package/ts/cli.ts CHANGED
@@ -19,6 +19,8 @@ import { relaySubscriber, relayTransport } from "./relay.ts";
19
19
  import { acquirePushLock, askPushMessage, askPushTag, laneAgent, liveAgents, notifyAgent } from "./askPush.ts";
20
20
  import { DEFAULT_DIR, initRelay, initReport, relayHealth } from "./relayInit.ts";
21
21
  import { agentCommands } from "./agent.ts";
22
+ import { hubEnv, namedDir, renameNotice } from "./brand.ts";
23
+ import pkgJson from "../package.json" with { type: "json" };
22
24
 
23
25
  import {
24
26
  ASK_KEYCAPS,
@@ -1335,7 +1337,7 @@ function parseTargetThread(s: string, permalinkThreads = true): { ref: string; t
1335
1337
  if (/^\d{10}\.\d{6}$/.test(maybeTs)) return { ref: s.slice(0, colon), threadTs: maybeTs };
1336
1338
  if (/^\d{4}-\d{2}-\d{2}T/.test(maybeTs)) return { ref: s.slice(0, colon), threadTs: isoToSlackTs(maybeTs) };
1337
1339
  }
1338
- // A bare name (no #, @ or :) that is an alias in the nearest .slack-term/.
1340
+ // A bare name (no #, @ or :) that is an alias in the nearest .slack-hub/.
1339
1341
  const alias = lookupAlias(s);
1340
1342
  if (alias) return alias.thread_ts ? { ref: alias.channel, threadTs: alias.thread_ts } : { ref: alias.channel };
1341
1343
  return { ref: s };
@@ -1360,7 +1362,7 @@ async function resolveReplyTarget(
1360
1362
  } else {
1361
1363
  let p = parseTargetThread(dest);
1362
1364
  if (!p.threadTs && /^\d{10}\.\d{6}$/.test(dest)) {
1363
- if (!settings.channel) return { error: `a bare ts needs a channel: set \`channel\` in .slack-term/settings.yml, or pass #chan:${dest}` };
1365
+ if (!settings.channel) return { error: `a bare ts needs a channel: set \`channel\` in .slack-hub/settings.yml, or pass #chan:${dest}` };
1364
1366
  p = { ref: settings.channel, threadTs: dest };
1365
1367
  }
1366
1368
  if (!p.threadTs) return { error: `"${dest}" is not a thread — reply only posts in threads. For a top-level post use \`slack send\`.` };
@@ -1473,7 +1475,7 @@ function selfLookup(token: string, cookie?: string): () => Promise<Self | null>
1473
1475
 
1474
1476
  /** Who is sending, captured once per write: the Slack `metadata` to attach to
1475
1477
  * the post, and `record` to append it to the local log once the ts is known.
1476
- * Both vanish under SLACK_TERM_ATTRIBUTION=off. */
1478
+ * Both vanish under SLACK_HUB_ATTRIBUTION=off. */
1477
1479
  function sentAttribution(kind: SentKind): {
1478
1480
  metadata?: MessageMetadata;
1479
1481
  record: (r: Omit<RecordSent, "kind" | "attribution">) => void;
@@ -2811,10 +2813,10 @@ const ASK_EXIT_EXPLAIN = 7;
2811
2813
  const ASK_EXPLAIN_NOTE_MAX_PAGES = 10;
2812
2814
 
2813
2815
  /** Whether a new question offers the ℹ️ explain pill when neither --explain nor
2814
- * --no-explain is given: `SLACK_TERM_ASK_EXPLAIN=1` turns it on for every ask
2816
+ * --no-explain is given: `SLACK_HUB_ASK_EXPLAIN=1` turns it on for every ask
2815
2817
  * from a fleet, without every caller having to remember the flag. */
2816
2818
  function askExplainDefault(): boolean {
2817
- return /^(1|true|yes|on)$/i.test(process.env.SLACK_TERM_ASK_EXPLAIN ?? "");
2819
+ return /^(1|true|yes|on)$/i.test(hubEnv("ASK_EXPLAIN") ?? "");
2818
2820
  }
2819
2821
 
2820
2822
  const ASK_MAX_CONSECUTIVE_ERRORS = 8;
@@ -3693,11 +3695,15 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
3693
3695
  // Same silent-delivery footgun as `send`: Slack never notifies you about your
3694
3696
  // own message, so a question asked in your own DM is delivered and then never
3695
3697
  // seen — and `--wait` would sit there until it timed out.
3698
+ // From an agent it is refused (11-12: an agent holding the person's session
3699
+ // posted it under their name); a person at a terminal is only warned.
3700
+ const agent = inAgent();
3696
3701
  if (!args.asBot && !!selfId && counterpart === selfId) {
3697
3702
  console.error(
3698
- `Warning: "${args.target}" is a DM to yourself — Slack will NOT notify you of your own message.\n` +
3699
- ` To reach yourself with a notification, ask as the bot: slack ask '${args.target}' '...' --as-bot`,
3703
+ `${agent ? "Error" : "Warning"}: "${args.target}" is a DM to yourself — Slack will NOT notify you of your own message.\n` +
3704
+ ` To reach yourself with a notification, ask as the bot: slack @<bot> ask '${args.target}' '...' (or --as-bot)`,
3700
3705
  );
3706
+ if (agent) process.exit(ASK_EXIT_ERROR);
3701
3707
  }
3702
3708
 
3703
3709
  // --- who may answer -------------------------------------------------------
@@ -3730,6 +3736,18 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
3730
3736
  // and posting anyway would silently drop someone the caller meant to ask.
3731
3737
  askRefuseUnresolved(unresolved);
3732
3738
 
3739
+ // An agent asking the person whose session it holds (11-12: it tagged that
3740
+ // person in the bot's DM, so the question went out under the name of the
3741
+ // one it asked). The bot asks the person; a person asks others.
3742
+ const taggedSelf = !!selfId && (resolved.some((r) => r.userId === selfId) || new RegExp(`<@${selfId}(?:\\|[^>]*)?>`).test(`${question}\n${body}`));
3743
+ if (agent && !args.asBot && taggedSelf) {
3744
+ console.error(
3745
+ `Error: \`ask\` would post as you (${selfId}) a question addressed to you — the asker and the one asked are the same person.\n` +
3746
+ ` To ask yourself, ask as the bot: slack @<bot> ask '${args.target}' '${args.question}' (or --as-bot)\n` +
3747
+ ` To ask someone else as yourself, tag them, not you.`,
3748
+ );
3749
+ process.exit(ASK_EXIT_ERROR);
3750
+ }
3733
3751
  const broadcast = broadcastKinds.size > 0;
3734
3752
  // Tagging yourself grants nothing — your own reactions are the seeds.
3735
3753
  const audience = new Set(resolved.map((r) => r.userId).filter((id) => id !== selfId));
@@ -3789,7 +3807,7 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
3789
3807
  : await Promise.all([...audience].map((id) => userLocale(mentionToken, id, args.mentionCookie)));
3790
3808
  const picked = askResolveLang({ flag: args.lang, readerLocales, content: [question, body, ...reactable, ...overflow] });
3791
3809
  if (!picked) {
3792
- console.error(`Error: unsupported language "${stripTerminalControls(args.lang ?? process.env.SLACK_TERM_LANG ?? "")}" — use one of: ${ASK_LANGS.join(", ")}`);
3810
+ console.error(`Error: unsupported language "${stripTerminalControls(args.lang ?? hubEnv("LANG") ?? "")}" — use one of: ${ASK_LANGS.join(", ")}`);
3793
3811
  process.exit(ASK_EXIT_ERROR);
3794
3812
  }
3795
3813
  const lang = picked.lang;
@@ -3847,7 +3865,7 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
3847
3865
  ` Via: ${threadOnly ? "reactions or thread replies" : "reactions or replies in this DM"}`,
3848
3866
  ...(explain ? [` Explain: ℹ️ pill offered — pressing it asks you to explain; it is never an answer`] : []),
3849
3867
  ...(args.voidAfter ? [` Then void: ${stripTerminalControls(args.voidAfter.link)} (reason: ${stripTerminalControls(args.voidAfter.reason || "none")}) — replaced by this question`] : []),
3850
- ` Language: ${lang} (${({ flag: "--lang", env: "SLACK_TERM_LANG", readers: "answerers' Slack locale", content: "the question's text", system: "system locale", default: "default" })[picked.source]}; override with --lang)`,
3868
+ ` Language: ${lang} (${({ flag: "--lang", env: "SLACK_HUB_LANG", readers: "answerers' Slack locale", content: "the question's text", system: "system locale", default: "default" })[picked.source]}; override with --lang)`,
3851
3869
  `--------------------------------────────────`,
3852
3870
  ], recipientTz);
3853
3871
  }
@@ -4278,7 +4296,7 @@ async function askFindIdentity(row: SentRow, botToken: string | undefined, known
4278
4296
  let who: string | undefined;
4279
4297
  if ((await canRead(botToken)) === false) {
4280
4298
  for (const [name, id] of listIdentities()) {
4281
- if (id.kind !== "bot" || name === process.env.SLACK_TERM_IDENTITY) continue;
4299
+ if (id.kind !== "bot" || name === hubEnv("IDENTITY")) continue;
4282
4300
  const env = { ...process.env };
4283
4301
  if ("error" in applyIdentity(name, env)) continue;
4284
4302
  if (await canRead(env.SLACK_BOT_TOKEN)) { who = name; break; }
@@ -4291,7 +4309,7 @@ async function askFindIdentity(row: SentRow, botToken: string | undefined, known
4291
4309
  /** The tokens a logged question is read with: those of the identity it was
4292
4310
  * asked as, when that is not the one this run acts as. */
4293
4311
  function askRowTokens(row: SentRow, tokens: { user?: string; bot?: string; cookie?: string }): { user?: string; bot?: string; cookie?: string } | string {
4294
- if (!row.identity || row.identity === process.env.SLACK_TERM_IDENTITY) return tokens;
4312
+ if (!row.identity || row.identity === hubEnv("IDENTITY")) return tokens;
4295
4313
  const env = { ...process.env };
4296
4314
  const r = applyIdentity(row.identity, env);
4297
4315
  if ("error" in r) return r.error;
@@ -4561,7 +4579,7 @@ async function askPushWatch(run: (only?: Set<string>) => Promise<unknown>, since
4561
4579
  * question stays open, but that reply is not pushed again. An asker that is
4562
4580
  * gone gets nothing: the answer stays on the list for a person. */
4563
4581
  function askPushAll(items: AskPendingItem[], selfArgs: string[], problems: string[]): void {
4564
- const release = acquirePushLock(join(process.env.XDG_STATE_HOME || join(homedir(), ".local", "state"), "slack-term", "ask-push.lock"));
4582
+ const release = acquirePushLock(join(namedDir(process.env.XDG_STATE_HOME || join(homedir(), ".local", "state")), "ask-push.lock"));
4565
4583
  if (!release) {
4566
4584
  problems.push("another `ask --pending --push` pass is running: nothing pushed by this one");
4567
4585
  return;
@@ -4602,7 +4620,7 @@ function askPushAll(items: AskPendingItem[], selfArgs: string[], problems: strin
4602
4620
  markAskDelivered(r.channel, r.ts, it.answer, it.cursor ?? "");
4603
4621
  } else {
4604
4622
  const after = r.delivered_cursor ? [`--after=${r.delivered_cursor}`] : [];
4605
- const who = r.identity && r.identity !== process.env.SLACK_TERM_IDENTITY ? [`@${r.identity}`] : [];
4623
+ const who = r.identity && r.identity !== hubEnv("IDENTITY") ? [`@${r.identity}`] : [];
4606
4624
  const c = spawnSync(process.execPath, [...process.argv.slice(1, 2), ...who, ...selfArgs, "ask", `--waitFor=${it.link}`, "--timeout", "0", ...(r.as_bot ? ["--as-bot"] : []), ...after],
4607
4625
  { encoding: "utf8", timeout: 120_000, stdio: ["ignore", "pipe", "pipe"] });
4608
4626
  collected = c.status === 0;
@@ -5913,6 +5931,8 @@ async function main(): Promise<void> {
5913
5931
  // Before any output: Bun drops console writes that meet a full pipe (see stdout.ts).
5914
5932
  installSyncConsole();
5915
5933
  loadDotenvFiles();
5934
+ const notice = renameNotice(pkgJson.name);
5935
+ if (notice) console.error(notice);
5916
5936
 
5917
5937
  type W = { workspace?: string };
5918
5938
  const tok = (a: W) => resolveToken(a.workspace);
@@ -5926,7 +5946,7 @@ async function main(): Promise<void> {
5926
5946
  "as-bot"?: boolean | undefined; broadcast?: boolean | undefined; mentions?: boolean | undefined;
5927
5947
  json?: boolean | undefined;
5928
5948
  };
5929
- /** The `edit` handler, shared with `tick`. In a .slack-term/ scope the
5949
+ /** The `edit` handler, shared with `tick`. In a .slack-hub/ scope the
5930
5950
  * lane's tag is kept; in a restricted one the message must sit in one of
5931
5951
  * its subscriptions. */
5932
5952
  type EditCli = {
@@ -6130,7 +6150,7 @@ async function main(): Promise<void> {
6130
6150
  process.exit(1);
6131
6151
  })
6132
6152
  .option("workspace", { alias: "w", type: "string", describe: "Workspace name" })
6133
- .option("as-user", { type: "boolean", describe: "Act as the user session on purpose (needed for writes from inside an agent, or when several identities exist)" })
6153
+ .option("as-user", { type: "boolean", describe: "Act as the user session on purpose (not accepted for writes from inside an agent: name the person with slack @<who>)" })
6134
6154
  .middleware(async (argv) => {
6135
6155
  const cmd = String((argv._ ?? [])[0] ?? "");
6136
6156
  // `@bot`: commands that have --as-bot act as the bot; `@user`: never.
@@ -6159,11 +6179,13 @@ async function main(): Promise<void> {
6159
6179
  console.error(refusal);
6160
6180
  process.exit(2);
6161
6181
  }
6182
+ const ids = listIdentities();
6162
6183
  const user = userSessionRefusal({
6163
6184
  isWrite: isWriteCommand(argv._ ?? []) && !isReadMode(argv._ ?? [], argv as Record<string, unknown>),
6164
6185
  who, asBot: argv["as-bot"] === true, asUser: argv["as-user"] === true,
6165
6186
  activeIsBot: active.startsWith("xoxb-"),
6166
- agent: inAgent(), identities: [...listIdentities().keys()].sort(),
6187
+ agent: inAgent(), identities: [...ids.keys()].sort(),
6188
+ userIdentities: [...ids].filter(([, id]) => id.kind === "user").map(([n]) => n).sort(),
6167
6189
  cmd: (argv._ ?? []).slice(0, 2).join(" "),
6168
6190
  });
6169
6191
  if (user) {
@@ -6675,9 +6697,9 @@ async function main(): Promise<void> {
6675
6697
  )
6676
6698
  .command(
6677
6699
  "init [dir]",
6678
- "Create .slack-term/ in a directory: aliases, settings, inbox/outbox (never committed)",
6700
+ "Create .slack-hub/ in a directory: aliases, settings, inbox/outbox (never committed)",
6679
6701
  (y) => y
6680
- .positional("dir", { type: "string", default: ".", describe: "Directory to put .slack-term/ in" })
6702
+ .positional("dir", { type: "string", default: ".", describe: "Directory to put .slack-hub/ in" })
6681
6703
  .option("prefix", { type: "string", describe: "Put in front of every `slack reply`, e.g. \"[design]\"" })
6682
6704
  .option("channel", { type: "string", describe: "Default channel (id)" })
6683
6705
  .option("as-bot", { type: "boolean", describe: "Reply as the bot by default" }),
@@ -6692,7 +6714,7 @@ async function main(): Promise<void> {
6692
6714
  )
6693
6715
  .command(
6694
6716
  "alias",
6695
- "Name channels and threads for this directory (the nearest .slack-term/)",
6717
+ "Name channels and threads for this directory (the nearest .slack-hub/)",
6696
6718
  (y) => y
6697
6719
  .command(
6698
6720
  ["ls", "list"],
@@ -6706,7 +6728,7 @@ async function main(): Promise<void> {
6706
6728
  return;
6707
6729
  }
6708
6730
  for (const a of all) console.log(`${a.name}\t${a.channel}\t${a.thread_ts ?? "-"}\t${a.file}${a.note ? `\t${a.note}` : ""}`);
6709
- if (!all.length) console.error(`no aliases in ${scope.dir}${scope.global ? " (no .slack-term/ above here: `slack init` makes one)" : ""}`);
6731
+ if (!all.length) console.error(`no aliases in ${scope.dir}${scope.global ? " (no .slack-hub/ above here: `slack init` makes one)" : ""}`);
6710
6732
  },
6711
6733
  )
6712
6734
  .command(
@@ -6717,7 +6739,7 @@ async function main(): Promise<void> {
6717
6739
  .positional("target", { type: "string", demandOption: true })
6718
6740
  .option("note", { type: "string", describe: "Free text shown by `alias ls`" })
6719
6741
  .option("shared", { type: "boolean", default: false, describe: "Write settings.yml (the allowlist owner's file) instead of settings.local.yml" })
6720
- .option("dir", { type: "string", describe: "Use the .slack-term/ above this directory instead of the cwd's (with --shared: a lane's dir)" }),
6742
+ .option("dir", { type: "string", describe: "Use the .slack-hub/ above this directory instead of the cwd's (with --shared: a lane's dir)" }),
6721
6743
  async (argv) => {
6722
6744
  const token = tok(argv as W);
6723
6745
  const cookie = ck(argv as W);
@@ -6751,7 +6773,7 @@ async function main(): Promise<void> {
6751
6773
  (yy) => yy
6752
6774
  .positional("name", { type: "string", demandOption: true })
6753
6775
  .option("shared", { type: "boolean", default: false, describe: "Allow removing one defined in settings.yml" })
6754
- .option("dir", { type: "string", describe: "Use the .slack-term/ above this directory" }),
6776
+ .option("dir", { type: "string", describe: "Use the .slack-hub/ above this directory" }),
6755
6777
  (argv) => {
6756
6778
  const scope = findScope(argv.dir);
6757
6779
  let r;
@@ -6768,7 +6790,7 @@ async function main(): Promise<void> {
6768
6790
  )
6769
6791
  .command(
6770
6792
  "who <channel> <ts>",
6771
- "Which registered .slack-term/ dirs subscribe this thread (or message): dir, alias",
6793
+ "Which registered .slack-hub/ dirs subscribe this thread (or message): dir, alias",
6772
6794
  (yy) => yy
6773
6795
  .positional("channel", { type: "string", demandOption: true, describe: "Channel id" })
6774
6796
  .positional("ts", { type: "string", demandOption: true, describe: "Thread root ts (a reply's own ts is not its thread)" })
@@ -6786,7 +6808,7 @@ async function main(): Promise<void> {
6786
6808
  (yy) => yy
6787
6809
  .positional("tsv", { type: "string", demandOption: true })
6788
6810
  .option("channel", { type: "string", demandOption: true, describe: "The channel every thread is in (for a DM: the DM id)" })
6789
- .option("lane-dir", { type: "array", string: true, demandOption: true, describe: "<lane>=<dir> (a directory holding .slack-term/, made if missing); repeatable" }),
6811
+ .option("lane-dir", { type: "array", string: true, demandOption: true, describe: "<lane>=<dir> (a directory holding .slack-hub/, made if missing); repeatable" }),
6790
6812
  (argv) => {
6791
6813
  const dirs = new Map<string, string>();
6792
6814
  for (const kv of argv["lane-dir"] ?? []) {
@@ -6866,7 +6888,7 @@ async function main(): Promise<void> {
6866
6888
  )
6867
6889
  .command(
6868
6890
  "inbox",
6869
- "This directory's .slack-term/inbox/: messages routed here by `slack stream --inbox`",
6891
+ "This directory's .slack-hub/inbox/: messages routed here by `slack stream --inbox`",
6870
6892
  (y) => y
6871
6893
  .command(
6872
6894
  ["ls", "list"],
@@ -6961,7 +6983,7 @@ async function main(): Promise<void> {
6961
6983
  )
6962
6984
  .command(
6963
6985
  "outbox",
6964
- "This directory's .slack-term/outbox/: replies queued as files, sent by `outbox flush`",
6986
+ "This directory's .slack-hub/outbox/: replies queued as files, sent by `outbox flush`",
6965
6987
  (y) => y
6966
6988
  .command(
6967
6989
  "add <dest> <message>",
@@ -7065,7 +7087,7 @@ async function main(): Promise<void> {
7065
7087
  .option("code", { type: "string", describe: "Safety hash to confirm the ask" })
7066
7088
  .option("allow-url-adjacent", { type: "boolean", default: false, describe: "Warn instead of refusing ambiguous bare URL boundaries" })
7067
7089
  .option("body", { type: "string", describe: "Extra context shown under the question" })
7068
- .option("lang", { type: "string", choices: [...ASK_LANGS], describe: "Language of the instructions in the posted body. Default: $SLACK_TERM_LANG, else the answerers' Slack locale, else the question's own language, else the system locale, else ja" })
7090
+ .option("lang", { type: "string", choices: [...ASK_LANGS], describe: "Language of the instructions in the posted body. Default: $SLACK_HUB_LANG, else the answerers' Slack locale, else the question's own language, else the system locale, else ja" })
7069
7091
  .option("wait", { type: "boolean", default: false, describe: "Block until answered; print ONLY the answer on stdout. Exit 0 = answered, 2 = nobody replied, 3 = transport failure, 4 = a reply matched several choices (stdout empty), 5 = a free-text reply that picked none of the choices (the reply is on stdout; NOT a decision — the question stays open), 6 = the question was voided (`slack ask void`) — stop waiting. 7 = only with --explain-exit: ℹ️ pressed, explain and collect again (the question stays open)." })
7070
7092
  .option("waitFor", { type: "string", describe: "Collect the answer to a question already posted: pass its permalink. Nothing is posted (except, on an --explain question someone pressed ℹ️ on, one thread note per question). Same stdout/exit contract as --wait; --timeout 0 checks once and exits 2 if still open." })
7071
7093
  .option("after", { type: "string", describe: "With --waitFor: the cursor — everything at or before this ts was already delivered. Text replies there are neither answers nor notes again (pass the `cursor` a previous --json result gave you, or the reply ts an exit 5 printed). Reactions still count." })
@@ -7085,7 +7107,7 @@ async function main(): Promise<void> {
7085
7107
  .option("limit", { type: "number", default: 50, describe: "With --ls: how many recent asks to check" })
7086
7108
  .option("reason", { type: "string", describe: "With --void: why it is void (written into the message)" })
7087
7109
  .option("superseded-by", { type: "string", describe: "With --void: permalink of the question that replaces it" })
7088
- .option("explain", { type: "boolean", describe: "Also offer an ℹ️ 'explain' pill (seeded after ➕): pressing it asks YOU to explain the question in its thread and is never an answer — the question stays open. --wait/--waitFor report it on stderr (and as `explain` in --json), and post one thread note per question. Default: $SLACK_TERM_ASK_EXPLAIN=1 turns it on; --no-explain turns it off." })
7110
+ .option("explain", { type: "boolean", describe: "Also offer an ℹ️ 'explain' pill (seeded after ➕): pressing it asks YOU to explain the question in its thread and is never an answer — the question stays open. --wait/--waitFor report it on stderr (and as `explain` in --json), and post one thread note per question. Default: $SLACK_HUB_ASK_EXPLAIN=1 turns it on; --no-explain turns it off." })
7089
7111
  .option("explain-exit", { type: "boolean", default: false, describe: "With --wait / --waitFor: exit 7 (stdout empty; --json status \"explain\") when someone presses ℹ️ — once per question, on the run that posts the thread note. The question stays open: explain, then collect again." })
7090
7112
  .option("json", { type: "boolean", default: false, describe: "With --pending: one JSON object per answered question (sender, answer, collect command). With --wait / --waitFor: print ONE JSON object on stdout — {status, answer, how, who, notes:[{ts,user,text,permalink}], cursor, permalink} — instead of the bare answer. `notes` are the audience's replies that are not the answer (thread replies; plain replies too in a 1:1 DM). Exit codes unchanged." })
7091
7113
  .option("timeout", { type: "number", default: 3600, describe: "Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)" })
@@ -8641,12 +8663,12 @@ async function main(): Promise<void> {
8641
8663
  .positional("dir", { type: "string", default: DEFAULT_DIR, describe: "Folder to create" })
8642
8664
  .option("name", { type: "string", describe: "Worker name (default: the folder's name)" })
8643
8665
  .option("force", { type: "boolean", default: false, describe: "Overwrite files that already exist" })
8644
- .option("slack-term", { type: "string", describe: "slack-term dependency spec (default: this CLI's version), e.g. latest or file:../slack-term" }),
8666
+ .option("slack-hub", { type: "string", describe: "slack-hub dependency spec (default: this CLI's version), e.g. latest or file:../slack-hub" }),
8645
8667
  (argv) => {
8646
8668
  const r = initRelay(argv.dir, {
8647
8669
  force: argv.force,
8648
8670
  ...(argv.name !== undefined ? { name: argv.name } : {}),
8649
- ...(argv["slack-term"] !== undefined ? { slackTerm: argv["slack-term"] } : {}),
8671
+ ...(argv["slack-hub"] !== undefined ? { slackHub: argv["slack-hub"] } : {}),
8650
8672
  });
8651
8673
  if (!r.ok) {
8652
8674
  console.error(`slack relay init: ${r.error}`);
@@ -8685,11 +8707,11 @@ async function main(): Promise<void> {
8685
8707
  .option("thread-window", { type: "string", default: "3d", describe: "Watch replies in threads whose parent is at most this old" })
8686
8708
  .option("thread-scan", { type: "string", default: "3m", describe: "Polling: re-read each channel's whole --thread-window this often (cycles in between read only what is new)" })
8687
8709
  .option("calls-per-min", { type: "number", default: 40, describe: "Polling: pace conversations.history/replies to this many calls per minute (0 = unpaced)" })
8688
- .option("state", { type: "string", describe: "Cursor file (default: one per identity+grep+channels under $XDG_STATE_HOME/slack-term/stream/)" })
8710
+ .option("state", { type: "string", describe: "Cursor file (default: one per identity+grep+channels under $XDG_STATE_HOME/slack-hub/stream/)" })
8689
8711
  .option("as-user", { type: "boolean", default: false, describe: "Stream as the user identity (sees the user's DMs) instead of the bot" })
8690
8712
  .option("relay", { type: "boolean", default: true, describe: "Use the doorbell relay (`slack relay init`) when SLACK_RELAY_URL and SLACK_RELAY_TOKEN are set; --no-relay polls only" })
8691
8713
  .option("reconcile", { type: "string", default: "5m", describe: "While the relay is connected, poll this rarely as a safety net" })
8692
- .option("inbox", { type: "boolean", default: false, describe: "Also write each match into the inbox/ of every .slack-term/ that subscribes its thread (redacted, text-only)" })
8714
+ .option("inbox", { type: "boolean", default: false, describe: "Also write each match into the inbox/ of every .slack-hub/ that subscribes its thread (redacted, text-only)" })
8693
8715
  .option("reactions", { type: "boolean", default: false, describe: "Relay only: also print reaction_added bells as {type: \"reaction\", channel, ts, user} (the emoji: reactions.get)" }),
8694
8716
  async (argv) => {
8695
8717
  let re: RegExp;
@@ -8780,7 +8802,7 @@ async function main(): Promise<void> {
8780
8802
  ...(argv["replies-to"]?.length ? [[...argv["replies-to"].map(String)].sort()] : [])]))
8781
8803
  .digest("hex").slice(0, 16);
8782
8804
  const stateHome = process.env.XDG_STATE_HOME || join(homedir(), ".local", "state");
8783
- const statePath = argv.state ?? join(stateHome, "slack-term", "stream", `${key}.json`);
8805
+ const statePath = argv.state ?? join(namedDir(stateHome), "stream", `${key}.json`);
8784
8806
  console.error(`slack stream: as ${asUser ? "user" : "bot"} @${me.user} (${me.userId}); state ${statePath}`);
8785
8807
  // The relay rings for what the Slack app's bot can see, so it only
8786
8808
  // stands in for polling when streaming as that bot.