Skip to content

Conversation

@nhorton
Copy link
Contributor

@nhorton nhorton commented Jan 26, 2026

Summary

Converts the DeepWork hook system from bash scripts to cross-platform Python modules, enabling hooks to work on Windows, macOS, and Linux without requiring bash or shell interpreters.

Key Changes

  • Removed bash hook scripts:

    • user_prompt_submit.shdeepwork.hooks.user_prompt_submit Python module
    • capture_prompt_work_tree.shdeepwork.hooks.capture_prompt Python module
    • Removed from both .deepwork/jobs/deepwork_rules/hooks/ and src/deepwork/standard_jobs/deepwork_rules/hooks/
  • Added Python hook implementations:

    • src/deepwork/hooks/user_prompt_submit.py: Captures work tree state on prompt submission
    • src/deepwork/hooks/capture_prompt.py: Git work tree state capture utility (cross-platform equivalent of bash script)
    • src/deepwork/hooks/hook_entry.py: Cross-platform hook entry point for direct Python invocation
  • Updated hook configuration:

    • global_hooks.yml now references Python modules instead of shell scripts
    • Updated both template and standard job hook configurations
  • Updated adapter permissions:

    • Removed Bash(./.deepwork/jobs/deepwork_jobs/make_new_job.sh:*) permission (no longer needed)
    • Reduced required permissions from 5 to 4 entries
  • Updated documentation:

    • doc/architecture.md: Updated hook system architecture diagrams and descriptions
    • CHANGELOG.md: Documented the conversion and cross-platform benefits
    • src/deepwork/hooks/__init__.py: Updated module docstring with new hook system description

Implementation Details

  • Cross-platform compatibility: All hooks now use Python with subprocess calls to git, avoiding bash dependencies
  • Forward slash paths: Script-based hooks (if any) use forward slashes for cross-platform compatibility in bash environments
  • Hook invocation: Hooks are invoked via deepwork hook <name> CLI command, which works on all platforms regardless of installation method (pip, pipx, uv, Windows EXE, etc.)
  • Error handling: Python hooks gracefully handle missing git or other errors without blocking user operations
  • Backward compatibility: Hook configuration uses module references that work across all platforms

Testing

  • Added tests/unit/test_cross_platform_hooks.py with tests for:
    • capture_work_tree() functionality
    • user_prompt_submit hook behavior
    • Hook command generation for cross-platform compatibility
  • Updated existing adapter tests to reflect reduced permission count

Replace bash hook scripts with Python module implementations that work
on Windows, macOS, and Linux without requiring bash. This is a general
improvement extracted from the Windows support work.

Changes:
- Add capture_prompt.py, user_prompt_submit.py, hook_entry.py modules
- Update global_hooks.yml to use module references instead of .sh scripts
- Update hooks_syncer.py to use forward slashes for cross-platform paths
- Remove deprecated bash scripts (capture_prompt_work_tree.sh, user_prompt_submit.sh)
- Remove make_new_job.sh bash permission (no longer needed)
- Add cross-platform hooks tests

https://claude.ai/code/session_011mvvEHLPHc8o9w6NwayWC6
@nhorton nhorton force-pushed the claude/extract-hook-refactoring-78xmr branch from c3a9483 to 0cffca3 Compare January 30, 2026 15:04
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.

3 participants