slack-term 1.55.3 → 1.57.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.
- package/README.md +33 -717
- package/SKILL.md +9 -9
- package/dist/cli.js +269 -269
- package/locales/en.json +1 -1
- package/locales/ja.json +1 -1
- package/package.json +5 -5
- package/ts/ask.ts +3 -2
- package/ts/askPush.ts +5 -4
- package/ts/auth.ts +8 -8
- package/ts/brand.ts +50 -0
- package/ts/chromeCookieWin.ts +12 -12
- package/ts/cli.ts +33 -29
- package/ts/identity.ts +7 -7
- package/ts/inbox.ts +1 -1
- package/ts/locales.ts +1 -1
- package/ts/profiles.ts +10 -9
- package/ts/redact.ts +1 -1
- package/ts/relay.ts +5 -3
- package/ts/relayInit.ts +15 -15
- package/ts/scope.ts +23 -20
- package/ts/sentlog.ts +12 -10
- package/ts/stream.ts +1 -1
- package/worker/README.md +10 -10
- package/worker/src/hub.ts +6 -2
- package/worker/src/index.ts +4 -3
package/locales/en.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$comment": "slack-
|
|
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-
|
|
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.
|
|
3
|
+
"version": "1.57.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
|
-
"url": "https://github.com/snomiao/slack-
|
|
6
|
+
"url": "https://github.com/snomiao/slack-hub.git"
|
|
7
7
|
},
|
|
8
8
|
"bugs": {
|
|
9
|
-
"url": "https://github.com/snomiao/slack-
|
|
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-
|
|
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 `
|
|
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
|
|
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-
|
|
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-
|
|
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(
|
|
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(
|
|
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-
|
|
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-
|
|
43
|
-
features: { bot_user: { display_name: "slack-
|
|
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-
|
|
86
|
-
console.log(" 3) ~/.slack-
|
|
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-
|
|
91
|
-
else if (choice === "3") filePath = join(homedir(), ".slack-
|
|
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-
|
|
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,50 @@
|
|
|
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 still publishes each release as
|
|
42
|
+
* `slack-term` (toolchains may depend on the name), but it is NOT npm-deprecated,
|
|
43
|
+
* so installs stay quiet; instead the CLI says so on stderr, once per run.
|
|
44
|
+
* stdout is untouched; SLACK_HUB_NO_RENAME_NOTICE=1 silences it. */
|
|
45
|
+
export function renameNotice(pkgName: string, env: Record<string, string | undefined> = process.env): string | undefined {
|
|
46
|
+
if (pkgName !== LEGACY_NAME || /^(1|true|yes|on)$/i.test(hubEnv("NO_RENAME_NOTICE", env) ?? "")) return undefined;
|
|
47
|
+
return "slack: [deprecated] the slack-term npm package is now slack-hub and will stop being published. "
|
|
48
|
+
+ "Switch: npm uninstall -g slack-term && npm install -g slack-hub (same `slack` command, settings carry over). "
|
|
49
|
+
+ "Silence: SLACK_HUB_NO_RENAME_NOTICE=1";
|
|
50
|
+
}
|
package/ts/chromeCookieWin.ts
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
44
|
-
} catch { Set-Content 'C:\ProgramData\slack-
|
|
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-
|
|
62
|
-
} catch { Set-Content 'C:\ProgramData\slack-
|
|
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-
|
|
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-
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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 '
|
|
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-
|
|
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-
|
|
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
|
|
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: `
|
|
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(
|
|
2819
|
+
return /^(1|true|yes|on)$/i.test(hubEnv("ASK_EXPLAIN") ?? "");
|
|
2818
2820
|
}
|
|
2819
2821
|
|
|
2820
2822
|
const ASK_MAX_CONSECUTIVE_ERRORS = 8;
|
|
@@ -3805,7 +3807,7 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
|
|
|
3805
3807
|
: await Promise.all([...audience].map((id) => userLocale(mentionToken, id, args.mentionCookie)));
|
|
3806
3808
|
const picked = askResolveLang({ flag: args.lang, readerLocales, content: [question, body, ...reactable, ...overflow] });
|
|
3807
3809
|
if (!picked) {
|
|
3808
|
-
console.error(`Error: unsupported language "${stripTerminalControls(args.lang ??
|
|
3810
|
+
console.error(`Error: unsupported language "${stripTerminalControls(args.lang ?? hubEnv("LANG") ?? "")}" — use one of: ${ASK_LANGS.join(", ")}`);
|
|
3809
3811
|
process.exit(ASK_EXIT_ERROR);
|
|
3810
3812
|
}
|
|
3811
3813
|
const lang = picked.lang;
|
|
@@ -3863,7 +3865,7 @@ async function cmdAsk(token: string, args: AskArgs): Promise<void> {
|
|
|
3863
3865
|
` Via: ${threadOnly ? "reactions or thread replies" : "reactions or replies in this DM"}`,
|
|
3864
3866
|
...(explain ? [` Explain: ℹ️ pill offered — pressing it asks you to explain; it is never an answer`] : []),
|
|
3865
3867
|
...(args.voidAfter ? [` Then void: ${stripTerminalControls(args.voidAfter.link)} (reason: ${stripTerminalControls(args.voidAfter.reason || "none")}) — replaced by this question`] : []),
|
|
3866
|
-
` Language: ${lang} (${({ flag: "--lang", env: "
|
|
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)`,
|
|
3867
3869
|
`--------------------------------────────────`,
|
|
3868
3870
|
], recipientTz);
|
|
3869
3871
|
}
|
|
@@ -4294,7 +4296,7 @@ async function askFindIdentity(row: SentRow, botToken: string | undefined, known
|
|
|
4294
4296
|
let who: string | undefined;
|
|
4295
4297
|
if ((await canRead(botToken)) === false) {
|
|
4296
4298
|
for (const [name, id] of listIdentities()) {
|
|
4297
|
-
if (id.kind !== "bot" || name ===
|
|
4299
|
+
if (id.kind !== "bot" || name === hubEnv("IDENTITY")) continue;
|
|
4298
4300
|
const env = { ...process.env };
|
|
4299
4301
|
if ("error" in applyIdentity(name, env)) continue;
|
|
4300
4302
|
if (await canRead(env.SLACK_BOT_TOKEN)) { who = name; break; }
|
|
@@ -4307,7 +4309,7 @@ async function askFindIdentity(row: SentRow, botToken: string | undefined, known
|
|
|
4307
4309
|
/** The tokens a logged question is read with: those of the identity it was
|
|
4308
4310
|
* asked as, when that is not the one this run acts as. */
|
|
4309
4311
|
function askRowTokens(row: SentRow, tokens: { user?: string; bot?: string; cookie?: string }): { user?: string; bot?: string; cookie?: string } | string {
|
|
4310
|
-
if (!row.identity || row.identity ===
|
|
4312
|
+
if (!row.identity || row.identity === hubEnv("IDENTITY")) return tokens;
|
|
4311
4313
|
const env = { ...process.env };
|
|
4312
4314
|
const r = applyIdentity(row.identity, env);
|
|
4313
4315
|
if ("error" in r) return r.error;
|
|
@@ -4577,7 +4579,7 @@ async function askPushWatch(run: (only?: Set<string>) => Promise<unknown>, since
|
|
|
4577
4579
|
* question stays open, but that reply is not pushed again. An asker that is
|
|
4578
4580
|
* gone gets nothing: the answer stays on the list for a person. */
|
|
4579
4581
|
function askPushAll(items: AskPendingItem[], selfArgs: string[], problems: string[]): void {
|
|
4580
|
-
const release = acquirePushLock(join(process.env.XDG_STATE_HOME || join(homedir(), ".local", "state"), "
|
|
4582
|
+
const release = acquirePushLock(join(namedDir(process.env.XDG_STATE_HOME || join(homedir(), ".local", "state")), "ask-push.lock"));
|
|
4581
4583
|
if (!release) {
|
|
4582
4584
|
problems.push("another `ask --pending --push` pass is running: nothing pushed by this one");
|
|
4583
4585
|
return;
|
|
@@ -4618,7 +4620,7 @@ function askPushAll(items: AskPendingItem[], selfArgs: string[], problems: strin
|
|
|
4618
4620
|
markAskDelivered(r.channel, r.ts, it.answer, it.cursor ?? "");
|
|
4619
4621
|
} else {
|
|
4620
4622
|
const after = r.delivered_cursor ? [`--after=${r.delivered_cursor}`] : [];
|
|
4621
|
-
const who = r.identity && r.identity !==
|
|
4623
|
+
const who = r.identity && r.identity !== hubEnv("IDENTITY") ? [`@${r.identity}`] : [];
|
|
4622
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],
|
|
4623
4625
|
{ encoding: "utf8", timeout: 120_000, stdio: ["ignore", "pipe", "pipe"] });
|
|
4624
4626
|
collected = c.status === 0;
|
|
@@ -5929,6 +5931,8 @@ async function main(): Promise<void> {
|
|
|
5929
5931
|
// Before any output: Bun drops console writes that meet a full pipe (see stdout.ts).
|
|
5930
5932
|
installSyncConsole();
|
|
5931
5933
|
loadDotenvFiles();
|
|
5934
|
+
const notice = renameNotice(pkgJson.name);
|
|
5935
|
+
if (notice) console.error(notice);
|
|
5932
5936
|
|
|
5933
5937
|
type W = { workspace?: string };
|
|
5934
5938
|
const tok = (a: W) => resolveToken(a.workspace);
|
|
@@ -5942,7 +5946,7 @@ async function main(): Promise<void> {
|
|
|
5942
5946
|
"as-bot"?: boolean | undefined; broadcast?: boolean | undefined; mentions?: boolean | undefined;
|
|
5943
5947
|
json?: boolean | undefined;
|
|
5944
5948
|
};
|
|
5945
|
-
/** The `edit` handler, shared with `tick`. In a .slack-
|
|
5949
|
+
/** The `edit` handler, shared with `tick`. In a .slack-hub/ scope the
|
|
5946
5950
|
* lane's tag is kept; in a restricted one the message must sit in one of
|
|
5947
5951
|
* its subscriptions. */
|
|
5948
5952
|
type EditCli = {
|
|
@@ -6693,9 +6697,9 @@ async function main(): Promise<void> {
|
|
|
6693
6697
|
)
|
|
6694
6698
|
.command(
|
|
6695
6699
|
"init [dir]",
|
|
6696
|
-
"Create .slack-
|
|
6700
|
+
"Create .slack-hub/ in a directory: aliases, settings, inbox/outbox (never committed)",
|
|
6697
6701
|
(y) => y
|
|
6698
|
-
.positional("dir", { type: "string", default: ".", describe: "Directory to put .slack-
|
|
6702
|
+
.positional("dir", { type: "string", default: ".", describe: "Directory to put .slack-hub/ in" })
|
|
6699
6703
|
.option("prefix", { type: "string", describe: "Put in front of every `slack reply`, e.g. \"[design]\"" })
|
|
6700
6704
|
.option("channel", { type: "string", describe: "Default channel (id)" })
|
|
6701
6705
|
.option("as-bot", { type: "boolean", describe: "Reply as the bot by default" }),
|
|
@@ -6710,7 +6714,7 @@ async function main(): Promise<void> {
|
|
|
6710
6714
|
)
|
|
6711
6715
|
.command(
|
|
6712
6716
|
"alias",
|
|
6713
|
-
"Name channels and threads for this directory (the nearest .slack-
|
|
6717
|
+
"Name channels and threads for this directory (the nearest .slack-hub/)",
|
|
6714
6718
|
(y) => y
|
|
6715
6719
|
.command(
|
|
6716
6720
|
["ls", "list"],
|
|
@@ -6724,7 +6728,7 @@ async function main(): Promise<void> {
|
|
|
6724
6728
|
return;
|
|
6725
6729
|
}
|
|
6726
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}` : ""}`);
|
|
6727
|
-
if (!all.length) console.error(`no aliases in ${scope.dir}${scope.global ? " (no .slack-
|
|
6731
|
+
if (!all.length) console.error(`no aliases in ${scope.dir}${scope.global ? " (no .slack-hub/ above here: `slack init` makes one)" : ""}`);
|
|
6728
6732
|
},
|
|
6729
6733
|
)
|
|
6730
6734
|
.command(
|
|
@@ -6735,7 +6739,7 @@ async function main(): Promise<void> {
|
|
|
6735
6739
|
.positional("target", { type: "string", demandOption: true })
|
|
6736
6740
|
.option("note", { type: "string", describe: "Free text shown by `alias ls`" })
|
|
6737
6741
|
.option("shared", { type: "boolean", default: false, describe: "Write settings.yml (the allowlist owner's file) instead of settings.local.yml" })
|
|
6738
|
-
.option("dir", { type: "string", describe: "Use the .slack-
|
|
6742
|
+
.option("dir", { type: "string", describe: "Use the .slack-hub/ above this directory instead of the cwd's (with --shared: a lane's dir)" }),
|
|
6739
6743
|
async (argv) => {
|
|
6740
6744
|
const token = tok(argv as W);
|
|
6741
6745
|
const cookie = ck(argv as W);
|
|
@@ -6769,7 +6773,7 @@ async function main(): Promise<void> {
|
|
|
6769
6773
|
(yy) => yy
|
|
6770
6774
|
.positional("name", { type: "string", demandOption: true })
|
|
6771
6775
|
.option("shared", { type: "boolean", default: false, describe: "Allow removing one defined in settings.yml" })
|
|
6772
|
-
.option("dir", { type: "string", describe: "Use the .slack-
|
|
6776
|
+
.option("dir", { type: "string", describe: "Use the .slack-hub/ above this directory" }),
|
|
6773
6777
|
(argv) => {
|
|
6774
6778
|
const scope = findScope(argv.dir);
|
|
6775
6779
|
let r;
|
|
@@ -6786,7 +6790,7 @@ async function main(): Promise<void> {
|
|
|
6786
6790
|
)
|
|
6787
6791
|
.command(
|
|
6788
6792
|
"who <channel> <ts>",
|
|
6789
|
-
"Which registered .slack-
|
|
6793
|
+
"Which registered .slack-hub/ dirs subscribe this thread (or message): dir, alias",
|
|
6790
6794
|
(yy) => yy
|
|
6791
6795
|
.positional("channel", { type: "string", demandOption: true, describe: "Channel id" })
|
|
6792
6796
|
.positional("ts", { type: "string", demandOption: true, describe: "Thread root ts (a reply's own ts is not its thread)" })
|
|
@@ -6804,7 +6808,7 @@ async function main(): Promise<void> {
|
|
|
6804
6808
|
(yy) => yy
|
|
6805
6809
|
.positional("tsv", { type: "string", demandOption: true })
|
|
6806
6810
|
.option("channel", { type: "string", demandOption: true, describe: "The channel every thread is in (for a DM: the DM id)" })
|
|
6807
|
-
.option("lane-dir", { type: "array", string: true, demandOption: true, describe: "<lane>=<dir> (a directory holding .slack-
|
|
6811
|
+
.option("lane-dir", { type: "array", string: true, demandOption: true, describe: "<lane>=<dir> (a directory holding .slack-hub/, made if missing); repeatable" }),
|
|
6808
6812
|
(argv) => {
|
|
6809
6813
|
const dirs = new Map<string, string>();
|
|
6810
6814
|
for (const kv of argv["lane-dir"] ?? []) {
|
|
@@ -6884,7 +6888,7 @@ async function main(): Promise<void> {
|
|
|
6884
6888
|
)
|
|
6885
6889
|
.command(
|
|
6886
6890
|
"inbox",
|
|
6887
|
-
"This directory's .slack-
|
|
6891
|
+
"This directory's .slack-hub/inbox/: messages routed here by `slack stream --inbox`",
|
|
6888
6892
|
(y) => y
|
|
6889
6893
|
.command(
|
|
6890
6894
|
["ls", "list"],
|
|
@@ -6979,7 +6983,7 @@ async function main(): Promise<void> {
|
|
|
6979
6983
|
)
|
|
6980
6984
|
.command(
|
|
6981
6985
|
"outbox",
|
|
6982
|
-
"This directory's .slack-
|
|
6986
|
+
"This directory's .slack-hub/outbox/: replies queued as files, sent by `outbox flush`",
|
|
6983
6987
|
(y) => y
|
|
6984
6988
|
.command(
|
|
6985
6989
|
"add <dest> <message>",
|
|
@@ -7083,7 +7087,7 @@ async function main(): Promise<void> {
|
|
|
7083
7087
|
.option("code", { type: "string", describe: "Safety hash to confirm the ask" })
|
|
7084
7088
|
.option("allow-url-adjacent", { type: "boolean", default: false, describe: "Warn instead of refusing ambiguous bare URL boundaries" })
|
|
7085
7089
|
.option("body", { type: "string", describe: "Extra context shown under the question" })
|
|
7086
|
-
.option("lang", { type: "string", choices: [...ASK_LANGS], describe: "Language of the instructions in the posted body. Default: $
|
|
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" })
|
|
7087
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)." })
|
|
7088
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." })
|
|
7089
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." })
|
|
@@ -7103,7 +7107,7 @@ async function main(): Promise<void> {
|
|
|
7103
7107
|
.option("limit", { type: "number", default: 50, describe: "With --ls: how many recent asks to check" })
|
|
7104
7108
|
.option("reason", { type: "string", describe: "With --void: why it is void (written into the message)" })
|
|
7105
7109
|
.option("superseded-by", { type: "string", describe: "With --void: permalink of the question that replaces it" })
|
|
7106
|
-
.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: $
|
|
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." })
|
|
7107
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." })
|
|
7108
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." })
|
|
7109
7113
|
.option("timeout", { type: "number", default: 3600, describe: "Overall limit for --wait / --waitFor, in seconds (0 with --waitFor = check once)" })
|
|
@@ -8659,12 +8663,12 @@ async function main(): Promise<void> {
|
|
|
8659
8663
|
.positional("dir", { type: "string", default: DEFAULT_DIR, describe: "Folder to create" })
|
|
8660
8664
|
.option("name", { type: "string", describe: "Worker name (default: the folder's name)" })
|
|
8661
8665
|
.option("force", { type: "boolean", default: false, describe: "Overwrite files that already exist" })
|
|
8662
|
-
.option("slack-
|
|
8666
|
+
.option("slack-hub", { type: "string", describe: "slack-hub dependency spec (default: this CLI's version), e.g. latest or file:../slack-hub" }),
|
|
8663
8667
|
(argv) => {
|
|
8664
8668
|
const r = initRelay(argv.dir, {
|
|
8665
8669
|
force: argv.force,
|
|
8666
8670
|
...(argv.name !== undefined ? { name: argv.name } : {}),
|
|
8667
|
-
...(argv["slack-
|
|
8671
|
+
...(argv["slack-hub"] !== undefined ? { slackHub: argv["slack-hub"] } : {}),
|
|
8668
8672
|
});
|
|
8669
8673
|
if (!r.ok) {
|
|
8670
8674
|
console.error(`slack relay init: ${r.error}`);
|
|
@@ -8703,11 +8707,11 @@ async function main(): Promise<void> {
|
|
|
8703
8707
|
.option("thread-window", { type: "string", default: "3d", describe: "Watch replies in threads whose parent is at most this old" })
|
|
8704
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)" })
|
|
8705
8709
|
.option("calls-per-min", { type: "number", default: 40, describe: "Polling: pace conversations.history/replies to this many calls per minute (0 = unpaced)" })
|
|
8706
|
-
.option("state", { type: "string", describe: "Cursor file (default: one per identity+grep+channels under $XDG_STATE_HOME/slack-
|
|
8710
|
+
.option("state", { type: "string", describe: "Cursor file (default: one per identity+grep+channels under $XDG_STATE_HOME/slack-hub/stream/)" })
|
|
8707
8711
|
.option("as-user", { type: "boolean", default: false, describe: "Stream as the user identity (sees the user's DMs) instead of the bot" })
|
|
8708
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" })
|
|
8709
8713
|
.option("reconcile", { type: "string", default: "5m", describe: "While the relay is connected, poll this rarely as a safety net" })
|
|
8710
|
-
.option("inbox", { type: "boolean", default: false, describe: "Also write each match into the inbox/ of every .slack-
|
|
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)" })
|
|
8711
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)" }),
|
|
8712
8716
|
async (argv) => {
|
|
8713
8717
|
let re: RegExp;
|
|
@@ -8798,7 +8802,7 @@ async function main(): Promise<void> {
|
|
|
8798
8802
|
...(argv["replies-to"]?.length ? [[...argv["replies-to"].map(String)].sort()] : [])]))
|
|
8799
8803
|
.digest("hex").slice(0, 16);
|
|
8800
8804
|
const stateHome = process.env.XDG_STATE_HOME || join(homedir(), ".local", "state");
|
|
8801
|
-
const statePath = argv.state ?? join(stateHome, "
|
|
8805
|
+
const statePath = argv.state ?? join(namedDir(stateHome), "stream", `${key}.json`);
|
|
8802
8806
|
console.error(`slack stream: as ${asUser ? "user" : "bot"} @${me.user} (${me.userId}); state ${statePath}`);
|
|
8803
8807
|
// The relay rings for what the Slack app's bot can see, so it only
|
|
8804
8808
|
// stands in for polling when streaming as that bot.
|
package/ts/identity.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// `slack @<who> <command> …` — name the identity a command acts as (11-02):
|
|
2
2
|
// a bot (`@deploy-bot`, `@ops-bot`) or a person (`@alice`). Replaces --as-bot /
|
|
3
3
|
// --as-user and env-file juggling. The names map to WHERE a token lives (an
|
|
4
|
-
// env var, optionally in an env file, or a slack-
|
|
4
|
+
// env var, optionally in an env file, or a slack-hub profile) — never to the
|
|
5
5
|
// token itself, which stays in the env/vault:
|
|
6
6
|
//
|
|
7
|
-
// identities: # .slack-
|
|
7
|
+
// identities: # .slack-hub/settings.yml or ~/.config/slack-hub/settings.yml
|
|
8
8
|
// deploy-bot: { kind: bot, env_file: ~/.config/slack-cli/deploy-bot.env } # SLACK_BOT_TOKEN in it
|
|
9
9
|
// ops-bot: { kind: bot, env_file: ~/.config/slack-cli/ops-bot.env }
|
|
10
10
|
// alice: { kind: user, profile: acme } # slack auth profile
|
|
@@ -24,7 +24,7 @@ export type Identity = {
|
|
|
24
24
|
env?: string;
|
|
25
25
|
/** An env file to read that var from; else the process environment. */
|
|
26
26
|
env_file?: string;
|
|
27
|
-
/** A user: a slack-
|
|
27
|
+
/** A user: a slack-hub workspace profile (`slack auth ls`). */
|
|
28
28
|
profile?: string;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -89,13 +89,13 @@ function readEnvFile(path: string): Record<string, string> {
|
|
|
89
89
|
* error naming the known identities. */
|
|
90
90
|
export function applyIdentity(who: string, env: NodeJS.ProcessEnv = process.env, ids = listIdentities()): { kind: "bot" | "user" } | { error: string } {
|
|
91
91
|
const id = ids.get(who);
|
|
92
|
-
const known = [...ids.keys()].sort().map((n) => `@${n}`).join(", ") || "(none: add `identities:` to .slack-
|
|
92
|
+
const known = [...ids.keys()].sort().map((n) => `@${n}`).join(", ") || "(none: add `identities:` to .slack-hub/settings.yml)";
|
|
93
93
|
if (!id) return { error: `unknown identity @${who}. Known: ${known}` };
|
|
94
94
|
if (id.kind === "user" && id.profile && !id.env && !id.env_file) {
|
|
95
95
|
env.SLACK_WORKSPACE = id.profile;
|
|
96
96
|
delete env.SLACK_TOKEN;
|
|
97
97
|
delete env.SLACK_BOT_TOKEN;
|
|
98
|
-
env.
|
|
98
|
+
env.SLACK_HUB_IDENTITY = who;
|
|
99
99
|
return { kind: "user" };
|
|
100
100
|
}
|
|
101
101
|
const name = id.env ?? (id.kind === "bot" ? "SLACK_BOT_TOKEN" : "SLACK_TOKEN");
|
|
@@ -115,7 +115,7 @@ export function applyIdentity(who: string, env: NodeJS.ProcessEnv = process.env,
|
|
|
115
115
|
env.SLACK_TOKEN = token;
|
|
116
116
|
delete env.SLACK_BOT_TOKEN;
|
|
117
117
|
}
|
|
118
|
-
env.
|
|
118
|
+
env.SLACK_HUB_IDENTITY = who;
|
|
119
119
|
return { kind: id.kind };
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -139,7 +139,7 @@ export function userSessionRefusal(o: {
|
|
|
139
139
|
const users = o.userIdentities ?? [];
|
|
140
140
|
if (o.asUser && !o.agent) return null; // a person at a terminal: their own call
|
|
141
141
|
const names = o.identities.map((n) => `@${n}`).join(" | ");
|
|
142
|
-
const pick = names ? ` Name who acts: slack ${o.identities[0] ? `@${o.identities[0]}` : "@<who>"} ${o.cmd} … (${names})` : " Add identities to .slack-
|
|
142
|
+
const pick = names ? ` Name who acts: slack ${o.identities[0] ? `@${o.identities[0]}` : "@<who>"} ${o.cmd} … (${names})` : " Add identities to .slack-hub/settings.yml, then: slack @<who> " + o.cmd + " …";
|
|
143
143
|
if (o.agent) {
|
|
144
144
|
const person = users.length
|
|
145
145
|
? ` As a person, on purpose: slack @${users[0]} ${o.cmd} … (${users.map((n) => `@${n}`).join(" | ")})`
|
package/ts/inbox.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// .slack-
|
|
1
|
+
// .slack-hub/ inbox and outbox: one file per message, written tmp + rename.
|
|
2
2
|
//
|
|
3
3
|
// inbox/<channel>-<ts>.yml a text-only notification (who, where, text,
|
|
4
4
|
// permalink; attachments only counted). Secrets are redacted before it is
|
package/ts/locales.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Language packs: locales/<lang>.json in the package, overridden key by key by
|
|
2
|
-
// the nearest .slack-
|
|
2
|
+
// the nearest .slack-hub/locales/<lang>.json. They hold only what slack-hub
|
|
3
3
|
// posts to PEOPLE (slack ask's copy) and the patterns it looks for in their
|
|
4
4
|
// messages (the choice-question hint); the CLI's own text is English, in code.
|
|
5
5
|
//
|