Ship shared plugin hooks
feat: ship shared plugin hooks (hooks/hooks.json) + docs
Merge gate cleared — release N shipped as stable v0.8.0 on 2026-08-03, and it is Latest.
This PR was held because a plugin installed from the default branch would have called agent-hook, a command the then-published v0.7.2 did not have. Verified against the shipped artifact rather than the source tree, since that is what users actually download: basecamp_0.8.0_darwin_arm64.tar.gz reports basecamp version 0.8.0 and exposes exactly the three subcommands hooks/hooks.json invokes (session-start, pre-commit-snapshot, post-commit). The full flow was then exercised end to end against that binary: snapshot → commit BC-4455 → nudge emitted with the reference and short hash.
Rebased onto main (was 45 commits behind); bin/ci exit 0.
What
One hooks/hooks.json at the plugin root serves both agents (both read the same location, same matcher semantics, same hookSpecificOutput wire):
- SessionStart (
startup|resume|clear|compact) →basecamp agent-hook session-start— auth status as model context, with a spinner label. - PreToolUse / PostToolUse (
Bash) →pre-commit-snapshot/post-commit— the paired HEAD-snapshot commit nudge. NostatusMessageon these: they run on every Bash call and stay visually silent. - PostToolUseFailure (
Bash) →post-commit— closes the old accepted asymmetry: on Claude,git commit && git pushwith a failed push still nudges (the commit is proven from repo state, not the tool result). Codex ignores unknown event names insidehooks(verified:HookEventsTomllacksdeny_unknown_fields), so this key is inert there; Codex's own PostToolUse fires regardless of exit status. No other top-level keys — Codex hard-errors on unknown top-level keys in hooks.json.
Commands are plain basecamp agent-hook <sub> strings — valid under all four hook shells (sh -lc, cmd.exe /C, Git Bash, PowerShell); no wrapper, no commandWindows, no per-agent split.
Docs/setup restoration (reverses the Phase 1 deferrals from cb139726):
- README + install.md: "hooks" back in the plugin feature lists; Codex sections regain "review and trust the plugin hooks with
/hooks" (Codex lists untrusted hooks but silently does not run them until trusted). Claude needs no trust step — install consent covers it. runCodexSetup: re-adds the muted "Review and trust the plugin hooks with /hooks." next-step line; the wizard test flips from proving/hooksabsent to proving it present.- AGENTS.md tree:
hooks/entry back (agent-neutral wording). .codex-plugin/plugin.jsonlongDescription: restores the connect-commits clause.
TestHooksFileCommandsInvokeBasecamp (dormant since #534) activates automatically now that hooks/hooks.json exists.
Compatibility floor
Hooks require CLI ≥ release N. Users of either agent with an older CLI may see non-blocking hook errors after their plugin payload refreshes (Codex: on marketplace upgrade; Claude: at the release N+1 manifest version bump, which can auto-update the plugin while the user still runs CLI < N). Remediation: basecamp upgrade. Codex additionally keeps new hooks inert until /hooks trust.
Rollout
- Codex users get the payload on
codex plugin marketplace upgrade 37signals(orbasecamp setup codex), then must trust via/hooks. - Claude users get it at release N+1's manifest version bump (plugin auto-update).
- Production verification happens after N+1: session-start context, the nudge matrix, doctor at matching versions. Staging passes before merge don't substitute.
Staging verification (pre-merge, candidate payload + dev-build CLI)
Both agents were verified against this branch's SHA (4f28a810) with production plugins isolated first (Codex: throwaway CODEX_HOME + staging marketplace 37signals-staging pinned to the SHA, install positively attributed; Claude: production basecamp@37signals disabled, candidate loaded via --plugin-dir), then production state restored.
- Codex 0.144.6 (
codex exec --dangerously-bypass-hook-trust, dev-buildbasecampon PATH): SessionStart context injected verbatim ("Basecamp is active and OAuth is ready…"); scratch repo commit withBC-123→ nudge delivered as developer context with the short hash; failed commit (nothing staged) → NONE./hookstrust flow itself not exercisable non-interactively — the bypass flag exercises the same execution path post-trust. - Claude Code 2.1.216:
PostToolUsenudge ontodo-456commit quoted back by the model;PostToolUseFailureon commit-then-failed-push quoted theBC-777nudge verbatim — the asymmetry this event closes, verified live. SessionStart verified at the transcript level: hook executed, stdout parsed, context attached ashook_additional_context(models don't always attribute it when asked, but injection is proven). TestHooksFileCommandsInvokeBasecampnow runs (not skipped) and passes; fullbin/cigreen on this branch.
Summary by cubic
Ships shared plugin hooks for Codex and Claude via hooks/hooks.json to add session-start status and Git commit-to-todo nudges. Widens hook timeouts and updates docs to require a CLI with agent-hook, plus trust-first guidance in Codex.
-
New Features
- Single
hooks/hooks.jsonfor both agents:SessionStartinjects auth status; BashPreToolUse/PostToolUsedrive commit nudges;PostToolUseFailure(Claude) also nudges after a failed push; timeouts set to 5s/10s/12s. - Hooks run
basecamp agent-hook <sub>across shells and stay silent on Bash. Codex ignores unknown hook event names and rejects unknown top-level keys. - Docs/setup: README/install document the
agent-hookCLI requirement; Codex setup now says “trust hooks with/hooks” before “start a new thread”;.codex-plugin/plugin.jsonmentions commit linking;AGENTS.mdlistshooks/.
- Single
-
Migration
- Requires
basecampCLI withagent-hook(release N+). If hook errors appear after install/refresh, runbasecamp upgrade, start a new session, and check withbasecamp agent-hook --help(“unknown command” means the CLI is too old). - Codex: trust hooks with
/hooks, then start a new thread. Claude needs no trust step.
- Requires