Skip to content

fix(scripts): update copy-hook-metadata script to correct destination…#43223

Open
saurav470 wants to merge 1 commit intoopenclaw:mainfrom
saurav470:fix/hooks-session-memory-notfound-clean
Open

fix(scripts): update copy-hook-metadata script to correct destination…#43223
saurav470 wants to merge 1 commit intoopenclaw:mainfrom
saurav470:fix/hooks-session-memory-notfound-clean

Conversation

@saurav470
Copy link
Copy Markdown
Contributor

Fixes #43180

Problem
After installing OpenClaw globally (e.g. pnpm add -g openclaw@latest on Windows), openclaw hooks list showed "No hooks found" and openclaw hooks enable session-memory failed with Error: Hook "session-memory" not found. This is a regression: bundled hooks used to be discoverable.

Root cause
Path mismatch between build and runtime:

Runtime (src/hooks/bundled-dir.ts): resolveBundledHooksDir() resolves the directory of the compiled bundled-dir.js and appends "bundled". For a global install that is .../openclaw/dist/hooks/bundled-dir.js, so it looks for dist/hooks/bundled.
Build (scripts/copy-hook-metadata.ts): HOOK.md files were copied to dist/bundled, so the runtime never saw them.
Change
scripts/copy-hook-metadata.ts: Copy destination changed from dist/bundled to dist/hooks/bundled so HOOK.md files sit next to the compiled handlers and match what resolveBundledHooksDir() expects. Comment updated to reference that resolutio

@openclaw-barnacle openclaw-barnacle bot added scripts Repository scripts size: XS labels Mar 11, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 11, 2026

Greptile Summary

This PR fixes a regression where globally-installed openclaw hooks were not discoverable. The root cause was a path mismatch: the build script (scripts/copy-hook-metadata.ts) was copying HOOK.md files to dist/bundled, while the runtime (src/hooks/bundled-dir.ts) was resolving hooks from dist/hooks/bundled (the directory of dist/hooks/bundled-dir.js + "bundled"). The fix is a single-line change updating the destination from dist/bundled to dist/hooks/bundled, along with an explanatory comment that documents the coupling between build and runtime paths.

  • The fix correctly aligns the build output path with resolveBundledHooksDir() in src/hooks/bundled-dir.ts.
  • No remaining references to the old dist/bundled path exist anywhere else in the codebase.
  • The updated comment improves maintainability by explicitly documenting the dependency between this script and the runtime resolution logic.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted path correction with no side effects.
  • The change is a single-line fix to a build script destination path. The corrected path (dist/hooks/bundled) directly matches what resolveBundledHooksDir() expects, and no other references to the old path (dist/bundled) remain in the codebase. The logic is straightforward and the root cause analysis in the PR description is accurate.
  • No files require special attention.

Last reviewed commit: f5fbd2b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts Repository scripts size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: No hooks found. Windows下pnpm安装找不到hooks

1 participant