Skip to content

feat(core): reactive hook events for CwdChanged and FileChanged (#2487)#2531

Merged
bug-ops merged 1 commit intomainfrom
reactive-hook-events-cwdchanged
Mar 31, 2026
Merged

feat(core): reactive hook events for CwdChanged and FileChanged (#2487)#2531
bug-ops merged 1 commit intomainfrom
reactive-hook-events-cwdchanged

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 31, 2026

Summary

  • Adds CwdChanged and FileChanged reactive hook events, providing parity with Claude Code v2.1.83 and Goose v1.27.x environment-change hooks
  • New [hooks] config section with [[hooks.cwd_changed]] and [hooks.file_changed] subsections
  • New set_working_directory tool calls std::env::set_current_dir on the agent process; post-tool cwd poll detects the change and fires hooks with ZEPH_OLD_CWD/ZEPH_NEW_CWD
  • FileChangeWatcher (notify + 500ms debounce) stored in LifecycleState — fires hooks with ZEPH_CHANGED_PATH/ZEPH_CHANGE_KIND
  • Hook execution reuses SEC-H-002 env-cleared shell pattern
  • Wired in all three entry points: runner, acp, daemon

Test plan

  • cargo nextest run --workspace --all-features --lib --bins — 7575/7575 pass
  • cargo clippy --workspace -- -D warnings — clean
  • cargo +nightly fmt --check — clean
  • Manual: configure [[hooks.cwd_changed]] in testing.toml, call set_working_directory, verify hook fires
  • Manual: configure [hooks.file_changed] with a watch path, modify a file, verify hook fires

Closes #2487

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate enhancement New feature or request size/XL Extra large PR (500+ lines) labels Mar 31, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 31, 2026 12:59
@bug-ops bug-ops force-pushed the reactive-hook-events-cwdchanged branch from f4b0f4f to 0267c01 Compare March 31, 2026 13:05
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
@bug-ops bug-ops force-pushed the reactive-hook-events-cwdchanged branch from 0267c01 to 23b2022 Compare March 31, 2026 13:14
@bug-ops bug-ops merged commit 5c008e3 into main Mar 31, 2026
27 checks passed
@bug-ops bug-ops deleted the reactive-hook-events-cwdchanged branch March 31, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation enhancement New feature or request rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement(core): reactive hook events for environment changes — CwdChanged, FileChanged

1 participant