claude-slack-channel-bots 0.6.6 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,7 +38,7 @@ See the sections below for manual configuration details if you prefer not to use
38
38
 
39
39
  - [Bun](https://bun.sh) `>= 1.0.21` (agent-director minimum)
40
40
  - [Claude Code](https://claude.ai/code) installed and authenticated
41
- - [`agent-director`](https://github.com/gabemahoney/agent-director) **runtime dependency** — pulled in transitively when you install this package. Hard required at server boot: CSCB refuses to start if the library is missing, the host platform is unsupported, Bun is too old, or the installed version is below `MIN_AD_VERSION` (`^0.5.5`). agent-director itself requires [tmux](https://github.com/tmux/tmux) on the operator's PATH; CSCB no longer probes for it directly.
41
+ - [`agent-director`](https://github.com/gabemahoney/agent-director) **installed system-wide** as a prerequisite like `git` or `docker`. CSCB no longer vendors the AD binary. The npm `agent-director` package CSCB depends on is now a thin TypeScript shim that locates the system-installed binary at startup via `resolveSystemBinary()` / `Client.create()` and refuses to start when the binary is missing, too old, or unreachable. The startup gate enforces AD's required version (declared by AD in `dist/version-floor.json`) and reports the required version on mismatch. agent-director itself requires [tmux](https://github.com/tmux/tmux) on the operator's PATH; CSCB no longer probes for it directly.
42
42
  - Slack workspace admin access (to create and configure the Slack app)
43
43
  - **cozempic** (optional) — Python 3.10+ and `pip install cozempic` — used by JSONL path resolution helpers retained for downstream callers.
44
44
 
@@ -52,9 +52,74 @@ See the sections below for manual configuration details if you prefer not to use
52
52
  | `darwin-x64` (Intel Mac) | **Not supported** by agent-director |
53
53
  | Windows | **Not supported** by agent-director |
54
54
 
55
- If the host is unsupported, the SR-5.1 startup gate exits non-zero at server boot with a typed error from agent-director (`ErrPlatformPackageMissing` or `ErrUnsupportedPlatform`) and writes the failure to `~/.claude/channels/slack/startup-errors.log` and stderr. See [Startup errors](#startup-errors) below.
55
+ If the host is unsupported, the system-installed `agent-director` itself will refuse to install or run; CSCB's startup gate then exits non-zero with one of the `ad-system-install-*` class labels (see [Startup errors](#startup-errors)) and writes the failure to `~/.claude/channels/slack/startup-errors.log` and stderr. Consult [agent-director's documentation](https://github.com/gabemahoney/agent-director) for the canonical platform support list.
56
56
 
57
- > **Note on agent-director versions.** v0.4.1 is a zombie release (the published tarball is missing `dist/` and cannot be imported). v0.4.2 lacks the `MakeTemplateParams.overwrite` field CSCB needs for the boot-time template refresh. v0.5.4 and earlier lack `allow_pending` on `readPane`/`sendKeys`, causing `ErrSpawnNotInteractive` during dev-channels dialog approval on freshly-spawned bots. CSCB pins `^0.5.5` to get past all three.
57
+ > **Note on agent-director versions.** v0.4.1 is a zombie release (the published tarball is missing `dist/` and cannot be imported). v0.4.2 lacks the `MakeTemplateParams.overwrite` field CSCB needs for the boot-time template refresh. v0.5.4 and earlier lack `allow_pending` on `readPane`/`sendKeys`, causing `ErrSpawnNotInteractive` during dev-channels dialog approval on freshly-spawned bots. v0.6.0 shipped a stale TS shim whose `Client` dropped `getPermission`, whose `buildDecide()` dropped `--request-token`, and whose error catalog omitted `ErrInvalidFlags` / `ErrPermissionRequestNotFound` / `ErrAmbiguousRequest` — each silently breaks the disambiguation relay. v0.6.1–0.6.2 still lack the full `permission_requests` plural projection + composite-key disambiguation surface CSCB depends on for concurrent open requests. From v0.7.0 onward, AD ships as a thin npm shim around a system-installed binary, and CSCB defers the minimum-AD-version decision to AD itself via `dist/version-floor.json` (AD's library-side `Client.create()` reads it). CSCB's `package.json` caret-pin on `agent-director` governs npm resolution of AD's TypeScript shim only — not the runtime floor, which is owned by the AD release the system binary belongs to.
58
+
59
+ ### Checking your agent-director install
60
+
61
+ Before starting the server, you can confirm `agent-director` is installed system-wide and meets the declared minimum with:
62
+
63
+ ```sh
64
+ bun run install-check
65
+ ```
66
+
67
+ The script calls the same discovery + floor-comparison pipeline the startup gate uses (it reads AD's `dist/version-floor.json`, calls `resolveSystemBinary()`, and compares versions via `semver.gte`). It exits 0 on success with a single-line block naming `agent-director`, the absolute resolved binary path, the detected version, and the floor. On failure it writes one of the canonical class labels to stderr and exits non-zero:
68
+
69
+ - `ad-system-install-not-found` — no agent-director on PATH or at the standard install path. Install AD and retry. The stderr also points at the install-cscb skill for interactive remediation.
70
+ - `ad-system-install-too-old` — AD binary is below the floor. Upgrade AD and retry. The stderr points at the skill.
71
+ - `ad-system-install-unreachable` — AD discovered but the probe could not invoke it (eight `.reason` values exposed verbatim). The stderr points at the skill.
72
+ - `ad-version-floor-unreadable` — `dist/version-floor.json` is missing, malformed, or lacks `min_binary_version`. The remediation is to reinstall `agent-director` from npm; the install-cscb skill cannot fix a corrupt AD package, so this case does NOT append the skill instructions block.
73
+
74
+ The script is purely diagnostic — it never prompts, never runs an install command, never fetches the skill. The startup gate enforces the same floor automatically at server boot via AD's `Client.create()`; `install-check` is for operators who want to confirm their setup ahead of time.
75
+
76
+ ### Installing the install-cscb skill
77
+
78
+ If `bun run install-check` (or the startup gate) reports one of the
79
+ `ad-system-install-*` failure classes, you can install the `install-cscb`
80
+ Claude skill for an interactive walkthrough. The skill drives the same
81
+ shared check module but walks you through install/upgrade and a
82
+ per-reason remediation flow for each of the eight
83
+ `ErrSystemInstallUnreachable.reason` values.
84
+
85
+ The skill is NOT auto-installed by `bun install` — fetch it manually
86
+ from CSCB's GitHub repo and place it in your local Claude skills
87
+ folder:
88
+
89
+ 1. **Fetch** `SKILL.md` from:
90
+
91
+ ```
92
+ https://github.com/gabemahoney/claude-slack-channel-bots/blob/main/skills/install-cscb/SKILL.md
93
+ ```
94
+
95
+ (The startup gate's `ad-system-install-*` error log line includes
96
+ this URL automatically.)
97
+
98
+ 2. **Place** it at:
99
+
100
+ ```
101
+ ~/.claude/skills/install-cscb/SKILL.md
102
+ ```
103
+
104
+ 3. **Invoke** the skill from Claude Code:
105
+
106
+ ```
107
+ /install-cscb
108
+ ```
109
+
110
+ The skill calls `bun run install-check` on each iteration, surfaces
111
+ `agent-director`'s published install/upgrade command verbatim (no
112
+ CSCB-owned install command — AD's documentation is the source of
113
+ truth), prompts before running, and loops until the check passes or
114
+ you decline. The `ad-version-floor-unreadable` class is handled
115
+ separately: the skill prints reinstall-from-npm guidance and does NOT
116
+ loop on it (the skill cannot fix a corrupt AD npm package).
117
+
118
+ The published CSCB npm tarball includes `skills/install-cscb/SKILL.md`
119
+ under its `files` array, so the skill source is also available via
120
+ `node_modules/claude-slack-channel-bots/skills/install-cscb/SKILL.md`
121
+ after `bun install`. The manual GitHub-fetch step above is for users
122
+ who haven't yet installed CSCB at all.
58
123
 
59
124
  ---
60
125
 
@@ -433,12 +498,15 @@ CSCB writes fatal startup errors to `~/.claude/channels/slack/startup-errors.log
433
498
 
434
499
  Classes you may see:
435
500
 
436
- - `ad-platform-package-missing` — agent-director's platform-native peer dependency is absent. The host is unsupported by agent-director.
437
- - `ad-unsupported-platform` — agent-director's runtime check rejected the host's `process.platform`/`process.arch` tuple.
501
+ - `ad-system-install-not-found` — `Client.create()` could not locate an `agent-director` binary on PATH or at the standard install path. Install agent-director system-wide and retry. The log line appends a manual-skill-install instructions block pointing at `skills/install-cscb/SKILL.md` (URL, target path under `~/.claude/skills/`, and invocation command `/install-cscb`) for the interactive install/upgrade flow.
502
+ - `ad-system-install-too-old` — the system-installed agent-director binary is below the floor declared in `dist/version-floor.json`. The log line names the detected and required versions, and appends the manual-skill-install instructions block.
503
+ - `ad-system-install-unreachable` — agent-director was discovered but the probe could not execute it (e.g. permission bits, broken symlink, runtime crash). The log line surfaces AD's supplied `err.reason` value verbatim (one of `not-executable`, `not-a-regular-file`, `probe-timeout`, `probe-nonzero-exit`, `probe-killed-by-signal`, `unparseable-version`, `spawn-failed`, `other`) and appends the manual-skill-install instructions block.
438
504
  - `ad-bun-version-too-old` — agent-director needs Bun `>= 1.0.21`. Upgrade Bun.
439
- - `ad-cli-not-executable` — the resolved agent-director CLI binary exists but is not executable. Run `chmod +x` on the binary referenced in the log line.
440
505
  - `ad-version-probe` — `agent-director` was loaded but the `version()` probe failed (subprocess invocation, platform binary, etc.).
441
- - `ad-version-stale` — installed `agent-director` is below the minimum version this CSCB requires. Run `bun add agent-director@^<minimum>`.
506
+ - `ad-shim-missing-get-permission` — the installed `agent-director` TS shim's `Client` does not expose `getPermission`. The npm-published package is out of sync with the system-installed binary. Reinstall a matching `agent-director` version and confirm the resolved package actually ships the method.
507
+ - `ad-shim-catalog-incomplete` — the installed `agent-director` TS error catalog is missing one or more of `ErrInvalidFlags`, `ErrPermissionRequestNotFound`, `ErrAmbiguousRequest`. The log line lists the missing names. Same remediation as `ad-shim-missing-get-permission`.
508
+ - `ad-shim-decide-drops-token` — the installed `agent-director` dist does not include `--request-token` in its bundled JS, meaning `buildDecide()` would resolve permission clicks against the wrong row. Reinstall a matching `agent-director` version and confirm `buildDecide` carries the flag.
509
+ - `ad-version-floor-unreadable` — `node_modules/agent-director/dist/version-floor.json` could not be read, parsed, or is missing `.min_binary_version`. This is a packaging defect — reinstall `agent-director` from npm. Surfaced by `bun run install-check`; the startup gate itself does not emit this label (it relies on `Client.create()`, which fails differently when the AD package is corrupt).
442
510
  - `ad-call-timeout` — an agent-director verb call exceeded the configured `callTimeoutMs` (default 30 s). Investigate the subprocess or increase the timeout.
443
511
  - `ad-same-user` — `~/.agent-director/state.db` is owned by a different UID than the CSCB process. Reinstall agent-director as the correct user or remove the mismatched file.
444
512
  - `ad-same-user-stat` — Non-ENOENT stat error on the state DB (permissions, I/O). Investigate the file before re-launching.
@@ -501,11 +569,7 @@ This gracefully exits the managed Claude Code sessions, stops and restarts the s
501
569
  For operators upgrading from a pre-`agent-director` install:
502
570
 
503
571
  1. **Install the new CSCB**: `bun remove claude-director` (if present) and `bun install -g claude-slack-channel-bots@^<new>`. The `agent-director` library is pulled in transitively — no separate install step.
504
- 2. **Delete any old relay hooks** (CSCB no longer ships them agent-director's relay machinery owns the tool-permission flow):
505
- ```sh
506
- rm -f ~/.claude/hooks/permission-relay.sh ~/.claude/hooks/ask-relay.sh
507
- ```
508
- Also remove their entries from `~/.claude/settings.json` if you wired them in by hand previously.
572
+ 2. **Delete any old relay hooks** see [Upgrading from pre-Epic-2 (v0.5.x → v0.6.x)](#upgrading-from-pre-epic-2-v05x--v06x) for the cleanup commands.
509
573
  3. **Configure agent-director's `find-missing` sweep**. CSCB does NOT call `client.findMissing(...)`; reconciling stuck rows is the operator's responsibility. Add a cron entry (or systemd timer) that runs `agent-director find-missing` on a cadence that matches your tolerance — e.g. every minute on a busy host:
510
574
  ```cron
511
575
  * * * * * /usr/local/bin/agent-director find-missing --timeout 30s
@@ -518,5 +582,41 @@ For operators upgrading from a pre-`agent-director` install:
518
582
  6. **Optional cleanup**: `~/.claude/channels/slack/sessions.json` and `sessions.json.last` are no longer read or written. CSCB ignores them; you can safely `rm` them after a successful boot.
519
583
  7. **`tmux` is no longer a CSCB-direct prereq** but is still required transitively via agent-director — keep it installed.
520
584
 
521
- After step 1, every CSCB bot is spawned through `client.spawn(...)` with `relay_mode='on'`. The green/red Slack button UX is byte-identical to the pre-migration behavior; the action_id shape changes from `perm_(allow|deny)_<uuid>` to `perm_(allow|deny)_cscb_<channelId>_<request_id>` but this is invisible to end users.
585
+ After step 1, every CSCB bot is spawned through `client.spawn(...)` with `relay_mode='on'`. The green/red Slack button UX is byte-identical to the pre-migration behavior; the action_id shape changes from `perm_(allow|deny)_<uuid>` to `perm_(allow|deny)_cscb_<channelId>_<request_token>` (where `<request_token>` is a UUIDv4 minted by agent-director) but this is invisible to end users.
586
+
587
+ ---
588
+
589
+ ## Upgrading from pre-Epic-2 (v0.5.x → v0.6.x)
590
+
591
+ If you installed CSCB before v0.6.0 you may have legacy artifacts on disk that are no longer needed. Clean them up manually — automatic postinstall migration is tracked under idea b.irf and not yet implemented.
592
+
593
+ ### 1. Remove old relay hook files
594
+
595
+ The `.sh` relay hooks are no longer shipped by CSCB. Delete them if present:
596
+
597
+ ```sh
598
+ rm -f ~/.claude/hooks/permission-relay.sh ~/.claude/hooks/ask-relay.sh
599
+ ```
600
+
601
+ ### 2. Remove orphan settings.json hook entries
602
+
603
+ If you wired the hooks into `~/.claude/settings.json` by hand, remove the stale entries. Use this `jq` filter to check whether any are present:
604
+
605
+ ```sh
606
+ jq '
607
+ (.hooks.PermissionRequest // [] | map(select(.hooks[]?.command | strings | test("\\.sh$")))),
608
+ (.hooks.PreToolUse // [] | map(select(.matcher == "AskUserQuestion" and (.hooks[]?.command | strings | test("\\.sh$")))))
609
+ ' ~/.claude/settings.json 2>/dev/null
610
+ ```
611
+
612
+ Any non-empty arrays in the output are orphan entries. Remove:
613
+
614
+ - Any object inside `hooks.PermissionRequest` whose `hooks[].command` ends in `permission-relay.sh`.
615
+ - Any object inside `hooks.PreToolUse` with `"matcher": "AskUserQuestion"` whose `hooks[].command` ends in `ask-relay.sh`.
616
+
617
+ The modern permission relay runs automatically via agent-director — no `PermissionRequest` or `PreToolUse` hook entries for `.sh` files are needed.
618
+
619
+ ### 3. Note on automated migration
620
+
621
+ A postinstall step that performs this cleanup automatically is tracked under idea b.irf. Until that lands, the steps above are manual.
522
622
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-slack-channel-bots",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "Multi-session Slack-to-Claude bridge — run multiple Claude Code bots across Slack channels via Socket Mode",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,6 @@
9
9
  "files": [
10
10
  "src/*.ts",
11
11
  "!src/*.test.ts",
12
- "hooks/",
13
12
  "scripts/fixup-bun-cache.ts",
14
13
  "slack-app-manifest.yml",
15
14
  "README.md",
@@ -23,6 +22,7 @@
23
22
  "start": "bun install --no-summary && bun src/server.ts",
24
23
  "pretest": "bun scripts/fixup-bun-cache.ts && bun scripts/check-no-toplevel-mock-module.ts",
25
24
  "check:mocks": "bun scripts/check-no-toplevel-mock-module.ts",
25
+ "install-check": "bun scripts/install-check.ts",
26
26
  "test": "bun test",
27
27
  "typecheck": "tsc --noEmit"
28
28
  },
@@ -30,11 +30,12 @@
30
30
  "@modelcontextprotocol/sdk": "^1.0.0",
31
31
  "@slack/socket-mode": "^2.0.0",
32
32
  "@slack/web-api": "^7.0.0",
33
- "agent-director": "^0.5.5"
33
+ "agent-director": "^0.7.0",
34
+ "semver": "^7.6.0"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/bun": "^1.0.0",
37
- "semver": "^7.6.0",
38
+ "@types/semver": "^7.7.1",
38
39
  "typescript": "^5.4.0"
39
40
  },
40
41
  "license": "MIT",
@@ -0,0 +1,209 @@
1
+ ---
2
+ name: install-cscb
3
+ description: Interactive walkthrough that installs or upgrades the system-installed `agent-director` so claude-slack-channel-bots can boot. Drives Epic 2's bun run install-check and per-reason remediation.
4
+ version: 1.0.0
5
+ author: Gabe Mahoney
6
+ license: MIT
7
+ user-invocable: true
8
+ argument-hint: "(no arguments)"
9
+ allowed-tools: [Bash, Read]
10
+ ---
11
+
12
+ # /install-cscb
13
+
14
+ Diagnose and fix a broken or missing `agent-director` system install so
15
+ `claude-slack-channel-bots` (CSCB) can boot. This skill is the interactive
16
+ counterpart to the diagnostic `bun run install-check` script — same shared
17
+ check module, but with a guided remediation loop for each failure class.
18
+
19
+ ## When to invoke
20
+
21
+ Invoke this skill when CSCB's startup gate emits one of these class labels
22
+ in `~/.claude/channels/slack/startup-errors.log`:
23
+
24
+ - `ad-system-install-not-found`
25
+ - `ad-system-install-too-old`
26
+ - `ad-system-install-unreachable`
27
+
28
+ The gate appends a pointer to this skill on those three classes. Other
29
+ failure classes (`ad-bun-version-too-old`, `ad-shim-*`, `ad-same-user`,
30
+ `ad-version-floor-unreadable`) are NOT remediated by this skill — see
31
+ the README's Startup-errors section for those.
32
+
33
+ ## Step 1 — Run the shared check
34
+
35
+ From the CSCB project root, run:
36
+
37
+ ```sh
38
+ bun run install-check
39
+ ```
40
+
41
+ This is the same command you can run directly from the shell. It calls
42
+ the shared check module (`src/install-check.ts`) which is also what this
43
+ skill drives internally on every iteration.
44
+
45
+ Read the output carefully:
46
+
47
+ - **Exit 0 + "OK"**: agent-director is satisfied. Print the resolved
48
+ binary path, detected version, and floor from the success output, then
49
+ exit cleanly. No further action required.
50
+
51
+ - **Exit non-zero**: identify the class label on stderr (one of
52
+ `ad-system-install-not-found`, `ad-system-install-too-old`,
53
+ `ad-system-install-unreachable`, `ad-version-floor-unreadable`) and
54
+ branch on it as documented below.
55
+
56
+ ## Step 2 — Identify the user's platform
57
+
58
+ Detect the platform via `uname -sm`. CSCB supports two platforms:
59
+
60
+ - **linux-x64** — `Linux x86_64`
61
+ - **darwin-arm64** — `Darwin arm64` (Apple Silicon Mac)
62
+
63
+ Any other platform is unsupported by `agent-director` itself and the
64
+ skill cannot proceed; surface the platform mismatch to the user and
65
+ exit non-zero.
66
+
67
+ ## Step 3 — Branch on the class label
68
+
69
+ ### `ad-system-install-not-found` — agent-director missing
70
+
71
+ Surface the install command published by `agent-director` verbatim for
72
+ the detected platform. Do NOT invent or maintain a CSCB-owned command —
73
+ consult agent-director's documentation
74
+ (<https://github.com/gabemahoney/agent-director>) for the canonical
75
+ install procedure. The current installer is `install.sh` from
76
+ agent-director's repo; recommend running it.
77
+
78
+ Prompt the user (using AskUserQuestion or an equivalent) — the literal
79
+ command must be visible:
80
+
81
+ > agent-director is not installed system-wide. Run the AD-published install
82
+ > command? `<command>`
83
+ >
84
+ > - **Yes** — run the command via Bash and continue.
85
+ > - **No** — install manually then continue.
86
+
87
+ - **Yes**: run the command via Bash. Capture stdout/stderr for the user
88
+ to see. Return to Step 1.
89
+ - **No**: instruct the user to install manually. Wait for confirmation.
90
+ Return to Step 1.
91
+
92
+ If the user declines to proceed at any point, exit non-zero with a
93
+ one-line summary: "Aborted by user — agent-director still not installed."
94
+
95
+ ### `ad-system-install-too-old` — agent-director below floor
96
+
97
+ Same flow as `ad-system-install-not-found` but with the upgrade command
98
+ instead of the install command. Surface the detected version and the
99
+ required floor from the stderr block so the user understands what they
100
+ are upgrading from and to.
101
+
102
+ Prompt:
103
+
104
+ > agent-director is installed but at version `<detected>`, below the
105
+ > required floor `<required>`. Run the AD-published upgrade command?
106
+ > `<command>`
107
+ >
108
+ > - **Yes** — run the command via Bash and continue.
109
+ > - **No** — upgrade manually then continue.
110
+
111
+ - **Yes**: run via Bash. Return to Step 1.
112
+ - **No**: wait for manual upgrade. Return to Step 1.
113
+
114
+ ### `ad-system-install-unreachable` — exhaustive reason switch
115
+
116
+ The stderr block carries an `err.reason` value verbatim. Branch on it
117
+ explicitly — every reason has a named branch, no `default:`-only
118
+ fallthrough.
119
+
120
+ 1. **`not-executable`** — the agent-director file exists but lacks the
121
+ executable bit. Show the user the binary path from the stderr block
122
+ and suggest:
123
+ ```sh
124
+ chmod +x <binary_path>
125
+ ```
126
+ Re-run Step 1.
127
+
128
+ 2. **`not-a-regular-file`** — the path resolved by `resolveSystemBinary()`
129
+ is a directory, broken symlink, or other non-file. Recommend
130
+ inspection (`ls -la <binary_path>`) and removal of the bad entry,
131
+ then re-installation via the AD install command. Re-run Step 1.
132
+
133
+ 3. **`probe-timeout`** — `agent-director --version` did not return within
134
+ the probe window. Likely the binary is hanging on startup
135
+ (corrupted, mismatched architecture, missing shared library).
136
+ Recommend a manual `<binary_path> --version` invocation to confirm,
137
+ then reinstall via the AD install command. Re-run Step 1.
138
+
139
+ 4. **`probe-nonzero-exit`** — `agent-director --version` exited with a
140
+ non-zero code. The stderr block surfaces `exitCode` and any
141
+ `diagnostic` from AD. Show the user the values and recommend a
142
+ manual reproduction (`<binary_path> --version`), then reinstall.
143
+ Re-run Step 1.
144
+
145
+ 5. **`probe-killed-by-signal`** — `agent-director --version` was killed
146
+ by a signal (SIGSEGV, SIGBUS, etc.). The stderr block surfaces
147
+ `signal`. The binary is likely corrupted or built for a different
148
+ architecture. Recommend a full reinstall via the AD install command.
149
+ Re-run Step 1.
150
+
151
+ 6. **`unparseable-version`** — `agent-director --version` returned but
152
+ the output could not be parsed as semver. The stderr's `diagnostic`
153
+ field carries the raw output. Likely the installed binary is from
154
+ a pre-release line that uses non-semver tags (e.g. `v0.6.3-dev`
155
+ without sentinel handling). Recommend upgrading to a release AD
156
+ version via the AD install command. Re-run Step 1.
157
+
158
+ 7. **`spawn-failed`** — the OS rejected the spawn before the subprocess
159
+ ran (ENOENT after stat succeeded, EACCES, EPERM, etc.). The stderr's
160
+ `diagnostic` field carries the underlying OS error. Recommend
161
+ checking filesystem permissions, then reinstalling. Re-run Step 1.
162
+
163
+ 8. **`other`** — an unexpected failure mode AD's `resolveSystemBinary()`
164
+ could not classify. Print the raw underlying error message from
165
+ `detail.underlying` (or `diagnostic`) and direct the user to file
166
+ a bug against `agent-director`:
167
+ <https://github.com/gabemahoney/agent-director/issues>
168
+
169
+ This is the only branch that recommends bug-filing rather than a
170
+ local remediation step.
171
+
172
+ After rendering the per-reason remediation, ask the user to confirm
173
+ they have applied it, then return to Step 1.
174
+
175
+ ### `ad-version-floor-unreadable` — corrupt agent-director npm package
176
+
177
+ This class is NOT a system-install problem — it indicates the
178
+ `node_modules/agent-director/dist/version-floor.json` file is missing,
179
+ malformed, or lacks `.min_binary_version`. The skill cannot walk the
180
+ user through fixing a corrupt AD npm package.
181
+
182
+ Print the reinstall guidance:
183
+
184
+ > The agent-director npm package appears corrupted. Reinstall it from
185
+ > npm in CSCB's project root:
186
+ >
187
+ > ```sh
188
+ > bun add agent-director@latest
189
+ > ```
190
+
191
+ Then exit. Do NOT loop on this class — the user must manually verify
192
+ the AD package is intact before re-invoking the skill.
193
+
194
+ ## Step 4 — Loop or exit
195
+
196
+ After each remediation step, re-run Step 1. The skill keeps looping
197
+ until the check passes (exit cleanly with the success output) or the
198
+ user declines to proceed (exit non-zero with the abort summary).
199
+
200
+ ## Notes
201
+
202
+ - This skill does not maintain its own list of agent-director install
203
+ commands. AD's documentation is the source of truth; the skill
204
+ surfaces AD's published command verbatim.
205
+ - This skill does not touch `~/.claude/channels/slack/` or CSCB's
206
+ routing configuration. It only acts on the system-wide
207
+ `agent-director` install.
208
+ - The skill is callable repeatedly; each invocation re-runs Step 1
209
+ from a clean state.
@@ -343,104 +343,53 @@ Do not modify `access.json` during setup unless the user asks to.
343
343
 
344
344
  ---
345
345
 
346
- ### Step 7 — Check hooks
346
+ ### Step 7 — Verify agent-director is installed
347
347
 
348
- Check whether the relay hooks exist and are executable:
348
+ The modern permission relay runs automatically via agent-director — no
349
+ operator action is required for permission-relay or ask-handling.
350
+ `AskUserQuestion` is denied at the agent-director template level (SR-3.1).
349
351
 
350
- ```bash
351
- ls -la ~/.claude/hooks/permission-relay.sh ~/.claude/hooks/ask-relay.sh 2>/dev/null || echo "NOT_FOUND"
352
- ```
353
-
354
- **If either hook is missing:**
355
-
356
- Provide the copy and chmod commands. The source path depends on how the
357
- package was installed. Try to detect it:
358
-
359
- ```bash
360
- # Attempt to find the package hooks directory
361
- bun pm ls -g 2>/dev/null | grep -o "claude-slack-channel-bots.*" | head -1 || true
362
- ```
363
-
364
- Show the user the exact commands:
365
-
366
- ```bash
367
- mkdir -p ~/.claude/hooks
368
-
369
- # Copy from the installed package (adjust path if needed):
370
- cp "$(npm root -g)/claude-slack-channel-bots/hooks/permission-relay.sh" ~/.claude/hooks/
371
- cp "$(npm root -g)/claude-slack-channel-bots/hooks/ask-relay.sh" ~/.claude/hooks/
372
- chmod +x ~/.claude/hooks/permission-relay.sh ~/.claude/hooks/ask-relay.sh
373
- ```
374
-
375
- Or, to keep them in sync with future package updates, symlink instead:
352
+ Check that agent-director is installed and the `slack-channel-bot` template
353
+ is registered:
376
354
 
377
355
  ```bash
378
- HOOKS_DIR="$(npm root -g)/claude-slack-channel-bots/hooks"
379
- ln -sf "$HOOKS_DIR/permission-relay.sh" ~/.claude/hooks/permission-relay.sh
380
- ln -sf "$HOOKS_DIR/ask-relay.sh" ~/.claude/hooks/ask-relay.sh
356
+ agent-director --version
381
357
  ```
382
358
 
383
- Also remind the user that `curl` and `jq` must be on `PATH` for the hooks to
384
- work.
359
+ The `slack-channel-bot` template is registered automatically at CSCB startup
360
+ via `client.makeTemplate(...)`. Confirm the template exists after a successful
361
+ `claude-slack-channel-bots start` by checking the agent-director template
362
+ registry. If the startup log shows `ad-template-install` in
363
+ `$STATE_DIR/startup-errors.log`, the template registration
364
+ failed — investigate that error before proceeding.
385
365
 
386
- **If both hooks exist**, confirm they are executable (`-x`). If not, show:
387
-
388
- ```bash
389
- chmod +x ~/.claude/hooks/permission-relay.sh ~/.claude/hooks/ask-relay.sh
390
- ```
366
+ If `agent-director` is not on `PATH`, postinstall did not complete successfully.
367
+ Re-run `bun postinstall.ts` from the installed package directory, or reinstall
368
+ CSCB with `bun install -g claude-slack-channel-bots`.
391
369
 
392
370
  ---
393
371
 
394
- ### Step 8 — Check Claude Code settings.json for hook entries
395
-
396
- Read `~/.claude/settings.json` and check whether the `PermissionRequest` and
397
- `PreToolUse` hook entries for the relay scripts are present.
372
+ ### Step 8 — Check settings.json for orphan legacy hook entries
398
373
 
399
- **Check for `PermissionRequest` entry:**
400
-
401
- Look for an entry inside `hooks.PermissionRequest` with:
402
- ```json
403
- { "type": "command", "command": "~/.claude/hooks/permission-relay.sh" }
404
- ```
374
+ Operators upgrading from pre-Epic-2 (v0.5.x) may have `PermissionRequest` or
375
+ `PreToolUse` `AskUserQuestion` entries in `~/.claude/settings.json` that point
376
+ at the old `.sh` files. These are harmless but stale — the `.sh` files no
377
+ longer exist and agent-director owns the relay machinery now.
405
378
 
406
- **Check for `PreToolUse` entry:**
379
+ Check for orphan entries:
407
380
 
408
- Look for an entry inside `hooks.PreToolUse` with:
409
- ```json
410
- { "matcher": "AskUserQuestion", "hooks": [{ "type": "command", "command": "~/.claude/hooks/ask-relay.sh" }] }
411
- ```
412
-
413
- **If either entry is missing OR exists but is missing `"timeout": 2000000`**,
414
- show the user the exact JSON to add or fix. The timeout is critical — without
415
- it Claude Code uses a short default timeout, kills the hook before the
416
- long-poll completes, and falls back to TUI approval. This is the complete
417
- block for both entries:
418
-
419
- ```jsonc
420
- "PermissionRequest": [
421
- {
422
- "matcher": ".*",
423
- "timeout": 2000000,
424
- "hooks": [{ "type": "command", "command": "~/.claude/hooks/permission-relay.sh" }]
425
- }
426
- ],
427
- "PreToolUse": [
428
- {
429
- "matcher": "AskUserQuestion",
430
- "timeout": 2000000,
431
- "hooks": [{ "type": "command", "command": "~/.claude/hooks/ask-relay.sh" }]
432
- }
433
- ]
381
+ ```bash
382
+ jq '
383
+ (.hooks.PermissionRequest // [] | map(select(.hooks[]?.command | strings | test("\\.sh$")))),
384
+ (.hooks.PreToolUse // [] | map(select(.matcher == "AskUserQuestion" and (.hooks[]?.command | strings | test("\\.sh$")))))
385
+ ' ~/.claude/settings.json 2>/dev/null
434
386
  ```
435
387
 
436
- Add these under the top-level `"hooks"` key in `settings.json`. Existing
437
- entries in those arrays should be preserved append, do not replace.
438
-
439
- If `settings.json` does not exist or does not have a `"hooks"` key, show the
440
- user the full minimal structure to add.
441
-
442
- Offer to write the missing entries automatically to `~/.claude/settings.json`.
443
- If the user agrees, make the targeted edits, preserving all existing content.
388
+ If either output array is non-empty, orphan entries are present. Show the user
389
+ the relevant block from `settings.json` and advise manual removal of any
390
+ `PermissionRequest` entries whose `hooks[].command` ends in `permission-relay.sh`,
391
+ and any `PreToolUse` entries with `matcher: "AskUserQuestion"` whose
392
+ `hooks[].command` ends in `ask-relay.sh`.
444
393
 
445
394
  ---
446
395
 
@@ -450,13 +399,13 @@ Print a final summary of what was checked and configured:
450
399
 
451
400
  - Environment variables: set / missing
452
401
  - Token format: valid / invalid
453
- - config.json: populated (N routes) / skeleton
402
+ - ~/.claude/channels/slack/config.json: present and valid (N routes) / missing or skeleton
454
403
  - append_system_prompt_file: configured / skipped
455
404
  - access.json: present / missing
456
- - permission-relay.sh hook: present and executable / missing
457
- - ask-relay.sh hook: present and executable / missing
458
- - settings.json PermissionRequest hook: present / missing
459
- - settings.json PreToolUse hook: present / missing
405
+ - agent-director: installed (version X) / missing
406
+ - slack-channel-bot template: registered (confirmed at startup) / unconfirmed
407
+ - settings.json orphan PermissionRequest (.sh) hooks: none / found (needs cleanup)
408
+ - settings.json orphan PreToolUse AskUserQuestion (.sh) hooks: none / found (needs cleanup)
460
409
 
461
410
  Remind the user:
462
411