Skip to content

feat(hooks): support Bob Shell 2.1.0 hook events as an opt-in under bob.hooks - #3961

Merged
dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3074-bob-shell-hook-events
Nov 25, 2026
Merged

dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3074-bob-shell-hook-events

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Bob Shell 2.1.0, published to npm as @ibm/bob on 2026-11-09, adds four hook events: SessionEnd, PermissionRequest, PermissionResolved and Notification. This PR lets users write them through the bob.hooks override block. They are opt-in rather than mapped from the shared hooks block for one reason: Bob Shell before 2.1.0 validates hooks against a strict seven-key zod object. On any unknown key it logs "Ignoring invalid … hook settings" and replaces that file's whole hooks block with {}. Writing these events by default would make older Bob Shells drop every hook, PreToolUse guards included, without the user ever choosing that. Bob IDE shares the file and documents only the seven events.

I checked the published bundles myself:

  • 2.0.9: the hooks schema is .object({ ...seven keys }).strict(), and a failed parse falls back to {}.
  • 2.1.0: the runner has 11 events. The matcher is tested against reason on SessionEnd (clear, resume, prompt_input_exit, other), the tool name on PermissionRequest and PermissionResolved, and notification_type on Notification (permission_prompt, elicitation_dialog, elicitation_url_dialog, idle_prompt).
  • 2.1.0 PermissionRequest: it runs only when Bob would show an approval prompt. hookSpecificOutput.decision.behavior "deny" / "allow" is honoured, and an allow auto-approves the call. An allow with updatedInput is ignored. Exit code 2 does not deny; Bob falls back to its normal approval prompt.

What changed

  • CANONICAL_TO_BOB_EVENT_NAMES still holds the seven documented events.
  • New BOB_OPT_IN_HOOK_EVENTS maps sessionEnd → SessionEnd, permissionRequest → PermissionRequest and notification → Notification.
  • A canonical hook on one of those three events is still skipped for bob. A new processor field, overrideOptIn, swaps the generic "not supported" warning for one that names Bob Shell 2.1.0+, the whole-block-drop risk, and the native names to write under bob.hooks. The warning is left out when bob.hooks already sets that native name.
  • Bob 2.1.0's hooks schema is strict too, with 11 keys. So bob.hooks keys are now filtered through a new optional spec field on SettingsJsonHooksSpec, knownOverrideEvents. Only the canonical supported events and Bob's 11 native names (BOB_NATIVE_HOOK_EVENTS) are written. Any other key is skipped with a warning and the remaining hooks are kept. That covers typos and canonical opt-in names such as sessionEnd. The processor reports these keys through dropsUnknownOverrideEvents / overrideOnlyEvents.
  • Under bob.hooks, the native names (including PermissionResolved) are written verbatim with their matcher. Import puts them back under bob.hooks, so a generate → import → generate cycle keeps them opt-in. Tests cover both directions.
  • New BOB_MATCHER_HOOK_EVENTS drives the converter's no-matcher set and the processor's matcherEvents. The processor value used to be ["preToolUse", "postToolUse"], which no longer matched what the converter keeps since fix(bob): emit http webhook hooks and keep matchers on session/compaction events #3706.
  • The docs note in docs/reference/file-formats.md now covers the opt-in, the 2.1.0 requirement, the whole-block drop, and how PermissionRequest decides. I regenerated docs-content.ts. The hook-event matrix is unchanged from main.

Skipped

Refs #3074

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

dyoshikawa and others added 2 commits November 25, 2026 10:32
…tification events

Bob Shell 2.1.0 (@ibm/bob on npm) adds SessionEnd, PermissionRequest,
PermissionResolved and Notification to its hook runner and settings
schema. Map canonical sessionEnd, permissionRequest and notification to
them and keep their matcher (reason, tool name, notification_type).
PermissionResolved has no canonical event and stays authorable through
the bob.hooks override block.

Also align the processor's Bob matcherEvents with the converter, which
already kept matchers on SessionStart, PreCompact and PostCompact.

Refs #3074

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…ooks

Bob Shell before 2.1.0 validates the hooks object strictly against the
seven documented keys and ignores the whole hooks block of a settings
file with an unknown key, PreToolUse guards included. Writing SessionEnd,
PermissionRequest or Notification from the shared hooks block would make
those versions drop every hook, so keep skipping the canonical events
for bob and warn with the native names to author under bob.hooks. Those
are written verbatim with their matcher and imported back there.

Document the 2.1.0 requirement, the whole-block drop, and that a
PermissionRequest decides through decision.behavior (exit 2 does not
deny, and allow with updatedInput is ignored).

Refs #3074

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
@dyoshikawa dyoshikawa changed the title feat(hooks): map Bob Shell 2.1.0 SessionEnd, PermissionRequest and Notification events feat(hooks): support Bob Shell 2.1.0 hook events as an opt-in under bob.hooks Nov 25, 2026
dyoshikawa and others added 2 commits November 25, 2026 11:04
Bob Shell 2.1.0 also validates the hooks object strictly, so a single
unknown key under bob.hooks (a typo, or a canonical opt-in name such as
sessionEnd) made Bob ignore the file's whole hooks block. Keep only the
canonical supported events and Bob's eleven native event names from the
override, and report the rest as skipped.

Also stop pointing to the override for a shared opt-in event that
bob.hooks already authors under its native name.

Refs #3074

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
…b-shell-hook-events

# Conflicts:
#	src/generated/docs-content.ts
@dyoshikawa
dyoshikawa merged commit b866459 into main Nov 25, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3074-bob-shell-hook-events branch November 25, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant