feat(cli): show BitFun's own Hooks under /hooks - #1814
Merged
Conversation
The CLI `/hooks` command showed the read-only catalog of Hooks configured for other AI applications, which predates BitFun having native hooks. Once BitFun could run a user's own commands at lifecycle events, `/hooks` named the one thing it did not show, and BitFun's own hooks had no CLI surface at all — the only way to check them was reading hooks.json and the backend log. Give the two views their own commands. `/hooks` now reports BitFun's native hooks; the external catalog moves to `/hooks_external` (alias `/hooks-external`), unchanged in behavior. Both help texts point at the other, so neither view can be mistaken for the other. - `bitfun-core::native_hooks::overview` returns a read-only snapshot: both gates, every candidate configuration file with whether it exists and whether a dispatch would load it, the matcher groups per event with their handlers and effective timeouts, and any parse issues. It re-reads the files instead of consulting the dispatch cache, so it always reflects what is on disk. - The view never reads as "nothing is configured" when something is configured but inert: a gated-off project file is still listed, a disabled master switch is stated, and skipped oversized files, unknown event names, and never-matching matchers are reported as issues. - A matcher whose pattern fails to compile parses into `Pattern` with no regex rather than `Invalid`; both report as invalid, since both never match. - Native hooks stay outside the Shared TUI preview slice, matching the other management surfaces. Documented in docs/features/agent-hooks.md and its Chinese translation. AI-assisted; fully tested at the unit level (`cargo test -p bitfun-cli --bin bitfun`, `cargo test -p bitfun-core --lib native_hooks`), not exercised interactively in a live TUI session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLI
/hooksnow reports BitFun's own agent lifecycle hooks. The read-only catalog of hooks configured for other AI applications moves to/hooks_external(alias/hooks-external), with its behavior unchanged.Fixes #
Type and Areas
Type: Feature (plus a UX fix for a command-name collision)
Areas: CLI/TUI, Rust core (
bitfun-core::native_hooks), docsMotivation / Impact
/hookswas introduced by the static external Hook catalog (#b770f03a), before BitFun had native hooks. Since #1785 added Codex-compatible hooks that actually execute,/hooksnamed the one thing it did not show:/hookslisted hooks belonging to Claude Code / Codex / OpenCode, which BitFun never runs.hooks.jsonby hand and raising the backend log level./hooksmanages their own hooks, the meaning was inverted.After this change each view has its own command and each help text points at the other, so neither can be mistaken for the other.
/hooksoutput:Breaking for anyone typing
/hooksexpecting the external catalog; they need/hooks_external. Both help texts and the design docs were updated accordingly.Reviewer Notes
bitfun-core::native_hooks::overviewis a new read-only snapshot API: both gates, every candidate configuration file with whether it exists and whether a dispatch would load it, matcher groups per event with handlers and effective timeouts, and parse issues. It re-reads the files rather than consulting the dispatch cache, so it always reflects what is on disk. Nothing in this path executes a handler.AgentHookMatcher::Patternwith no compiled regex, notInvalid. Reporting only the latter would miss the common case, so both report as invalid — they never match either way.ActionHandler::Hookssplits intoNativeHooks/ExternalHooks. Both stay outside the Shared TUI preview slice, matching how the other management surfaces are gated today. Happy to let/hooksinto that slice if you'd prefer — it is a local read-only report — but I kept the existing posture./hooks-externalis registered alongside/hooks_externalbecause the repo's existing multiword command is kebab-case (/reload-skills); the underscore form is the primary name.Verification
New tests: 3 in
native_hooks_tests.rscovering layer gating, issue reporting, and the oversized-file case; 4 in the CLI covering rendering, the empty/disabled states, the never-matching matcher, and the command registration for both aliases.Not verified: the rendered view was checked through its unit tests, not by driving a live TUI session interactively.
Checklist
AI-assisted (Claude Code). Testing level: fully tested at the unit level, not exercised interactively in a live TUI.