Skip to content

fix(hooks): resolve bundled hook dist paths and packaging checks#9914

Closed
zimmra wants to merge 6 commits intoopenclaw:mainfrom
zimmra:fix-bundled-hooks
Closed

fix(hooks): resolve bundled hook dist paths and packaging checks#9914
zimmra wants to merge 6 commits intoopenclaw:mainfrom
zimmra:fix-bundled-hooks

Conversation

@zimmra
Copy link

@zimmra zimmra commented Feb 5, 2026

This pull request introduces a new build process for bundled hooks, improves the way hooks are resolved and validated, and adds comprehensive tests to ensure reliability. The most significant changes are the addition of a script to bundle hooks using esbuild, removal of the old metadata copy script, updates to the build pipeline, and enhancements to hook resolution and validation logic.

Fixes #8732


Bundled Hooks Build Process

  • Added a new script scripts/build-bundled-hooks.ts that bundles each hook's handler using esbuild, copies HOOK.md, and cleans the output directory before building. This replaces the previous manual copying process and ensures handlers are built as JavaScript bundles.
  • Updated the build command in package.json to use the new build-bundled-hooks.ts script instead of the old copy-hook-metadata.ts.
  • Added esbuild as a dependency in package.json and pnpm-lock.yaml to support the new build process.
  • Removed the old scripts/copy-hook-metadata.ts script, as its functionality is now integrated into the new bundling script.

Hook Resolution and Validation Improvements

  • Enhanced src/hooks/bundled-dir.ts to resolve bundled hooks directories more robustly, supporting both dev and production layouts, and added options for custom resolution contexts.
  • Updated handler candidate ordering to prefer JavaScript files (handler.js, index.js) over TypeScript files, improving compatibility and alignment with the new build output. This change affects hook validation (src/hooks/install.ts) and workspace loading (src/hooks/workspace.ts).

Testing and Validation

  • Updated locally running instance to confirm changes work as intended
  • Added tests for the new bundled hooks build script in src/scripts/build-bundled-hooks.test.ts, covering output correctness, cleaning of stale files, and error handling when handlers are missing.
  • Added tests for hook directory resolution in src/hooks/bundled-dir.test.ts and for handler selection logic in src/hooks/workspace.test.ts.
  • Extended release checks in scripts/release-check.ts to ensure both HOOK.md and handler.js files for all bundled hooks are included in the package.

Miscellaneous

  • Simplified the import logic in src/hooks/bundled/session-memory/handler.ts to directly use the generateSlugViaLLM function, removing unnecessary dynamic imports.

These changes modernize the build and validation process for bundled hooks, improve reliability, and make the project easier to maintain and extend.

Greptile Overview

Greptile Summary

This PR replaces the previous bundled hook metadata copy step with an esbuild-based bundling script that emits dist/hooks/bundled/<hook>/handler.js and copies HOOK.md. It also hardens bundled hook directory resolution (resolveBundledHooksDir) to support different install/build layouts, updates hook validation and workspace hook loading to prefer JS handlers first, and extends release packaging checks and tests to ensure bundled hook assets are present and selected correctly.

Confidence Score: 3/5

  • This PR is close to safe to merge, but has a couple of concrete correctness pitfalls in the new build/release logic.
  • Most changes are straightforward and well-covered by tests, but (1) the new bundling script’s handler candidate order contradicts the runtime hook selection order, and (2) the release check can throw if src/hooks/bundled isn’t present in the environment running the check. Both can cause unexpected behavior in real packaging/build scenarios.
  • scripts/build-bundled-hooks.ts, scripts/release-check.ts

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

Copilot AI review requested due to automatic review settings February 5, 2026 21:39
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@openclaw-barnacle openclaw-barnacle bot added the scripts Repository scripts label Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a critical issue (#8732) where bundled hooks were missing after installation in OpenClaw 2026.2.2-3. The root cause was that hook metadata files and handlers weren't being properly packaged and resolved in production builds. The PR introduces a modern build process using esbuild to bundle hooks, improves hook directory resolution logic to handle both development and production layouts, and adds comprehensive tests and validation.

Changes:

  • Replaces manual metadata copying with an esbuild-based bundling process that compiles each hook's handler into a self-contained JavaScript bundle
  • Enhances hook resolution logic to support flattened dist layouts and multiple fallback strategies
  • Adds comprehensive tests for build script, directory resolution, and handler selection logic
  • Updates release validation to ensure bundled hooks are correctly packaged

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scripts/build-bundled-hooks.ts New build script that uses esbuild to bundle hook handlers and copy metadata
src/scripts/build-bundled-hooks.test.ts Comprehensive tests for the new build process
scripts/copy-hook-metadata.ts Removed old metadata copying script (functionality replaced by new build process)
package.json Updated build command to use new bundling script, added esbuild dependency
pnpm-lock.yaml Added esbuild 0.27.2 package resolution
src/hooks/workspace.ts Updated handler candidate ordering to prefer JS files
src/hooks/workspace.test.ts Added test to verify JS file preference
src/hooks/install.ts Updated handler candidate ordering for consistency
src/hooks/bundled-dir.ts Enhanced resolution logic with multiple fallback strategies
src/hooks/bundled-dir.test.ts Added tests for flattened dist layout resolution
src/hooks/bundled/session-memory/handler.ts Simplified imports by removing dynamic import workaround
scripts/release-check.ts Extended to validate both HOOK.md and handler.js for all bundled hooks
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 21, 2026
@steipete
Copy link
Contributor

Closing as AI-assisted stale-fix triage.

Linked issue #8732 ("[Bug]: Bundled hooks missing in OpenClaw 2026.2.2-3") is currently closed and was closed on 2026-02-09T02:35:49Z with state reason completed.
Given that issue is closed, this fix PR is no longer needed in the active queue and is being closed as stale.

If this specific implementation is still needed on current main, please reopen #9914 (or open a new focused fix PR) and reference #8732 for fast re-triage.

@steipete steipete closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Bundled hooks missing in OpenClaw 2026.2.2-3

3 participants