fix(hooks): resolve bundled hook dist paths and packaging checks#9914
fix(hooks): resolve bundled hook dist paths and packaging checks#9914zimmra wants to merge 6 commits intoopenclaw:mainfrom
Conversation
There was a problem hiding this comment.
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.
bfc1ccb to
f92900f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
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. 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. |
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
scripts/build-bundled-hooks.tsthat bundles each hook's handler usingesbuild, copiesHOOK.md, and cleans the output directory before building. This replaces the previous manual copying process and ensures handlers are built as JavaScript bundles.package.jsonto use the newbuild-bundled-hooks.tsscript instead of the oldcopy-hook-metadata.ts.esbuildas a dependency inpackage.jsonandpnpm-lock.yamlto support the new build process.scripts/copy-hook-metadata.tsscript, as its functionality is now integrated into the new bundling script.Hook Resolution and Validation Improvements
src/hooks/bundled-dir.tsto resolve bundled hooks directories more robustly, supporting both dev and production layouts, and added options for custom resolution contexts.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
src/scripts/build-bundled-hooks.test.ts, covering output correctness, cleaning of stale files, and error handling when handlers are missing.src/hooks/bundled-dir.test.tsand for handler selection logic insrc/hooks/workspace.test.ts.scripts/release-check.tsto ensure bothHOOK.mdandhandler.jsfiles for all bundled hooks are included in the package.Miscellaneous
src/hooks/bundled/session-memory/handler.tsto directly use thegenerateSlugViaLLMfunction, 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 emitsdist/hooks/bundled/<hook>/handler.jsand copiesHOOK.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
src/hooks/bundledisn’t present in the environment running the check. Both can cause unexpected behavior in real packaging/build scenarios.(2/5) Greptile learns from your feedback when you react with thumbs up/down!
Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)