feat(core): reactive hook events for CwdChanged and FileChanged (#2487)#2531
Merged
feat(core): reactive hook events for CwdChanged and FileChanged (#2487)#2531
Conversation
f4b0f4f to
0267c01
Compare
Add CwdChanged and FileChanged hook events to Zeph's lifecycle system, providing competitive parity with Claude Code and Goose environment-change hooks. - New `[hooks]` config section with `cwd_changed` and `file_changed` entries - `FileChangeWatcher` in zeph-core uses notify + 500ms debounce; stored in LifecycleState to live for the agent's full lifetime - `SetCwdExecutor` new tool (`set_working_directory`) that calls `std::env::set_current_dir`, making cwd changes intentional and observable - Post-tool-execution cwd poll detects changes and fires `cwd_changed` hooks with ZEPH_OLD_CWD / ZEPH_NEW_CWD env vars - FileChanged events fire hooks with ZEPH_CHANGED_PATH / ZEPH_CHANGE_KIND - Hook execution reuses SEC-H-002 env-cleared shell pattern - `with_hooks_config` wired in all three entry points: runner, acp, daemon
0267c01 to
23b2022
Compare
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
CwdChangedandFileChangedreactive hook events, providing parity with Claude Code v2.1.83 and Goose v1.27.x environment-change hooks[hooks]config section with[[hooks.cwd_changed]]and[hooks.file_changed]subsectionsset_working_directorytool callsstd::env::set_current_diron the agent process; post-tool cwd poll detects the change and fires hooks withZEPH_OLD_CWD/ZEPH_NEW_CWDFileChangeWatcher(notify + 500ms debounce) stored inLifecycleState— fires hooks withZEPH_CHANGED_PATH/ZEPH_CHANGE_KINDTest plan
cargo nextest run --workspace --all-features --lib --bins— 7575/7575 passcargo clippy --workspace -- -D warnings— cleancargo +nightly fmt --check— clean[[hooks.cwd_changed]]in testing.toml, callset_working_directory, verify hook fires[hooks.file_changed]with a watch path, modify a file, verify hook firesCloses #2487