From d0582516d572169db139273ac5f1e49066492998 Mon Sep 17 00:00:00 2001 From: Gujiassh Date: Mon, 6 Apr 2026 01:22:13 +0900 Subject: [PATCH] fix(installer): copy hooks lib modules during update Copy templates/hooks/lib into ~/.claude/hooks/lib for standalone installs and update reconciliation so .mjs hooks keep resolving stdin and atomic-write helpers after omc update. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- src/installer/index.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/installer/index.ts b/src/installer/index.ts index 8ce93519..8935213b 100644 --- a/src/installer/index.ts +++ b/src/installer/index.ts @@ -603,16 +603,24 @@ function ensureStandaloneHookScripts(log: (msg: string) => void): void { } } - for (const filename of readdirSync(templatesLibDir)) { - if (filename === 'config-dir.mjs') continue; // sourced from scripts/lib/ below - const sourcePath = join(templatesLibDir, filename); - const targetPath = join(hooksLibDir, filename); - copyFileSync(sourcePath, targetPath); - if (!isWindows()) { - chmodSync(targetPath, 0o755); + if (existsSync(templatesLibDir)) { + if (!existsSync(hooksLibDir)) { + mkdirSync(hooksLibDir, { recursive: true }); + } + + for (const filename of readdirSync(templatesLibDir)) { + if (!filename.endsWith('.mjs') || filename === 'config-dir.mjs') { + continue; + } + + const sourcePath = join(templatesLibDir, filename); + const targetPath = join(hooksLibDir, filename); + copyFileSync(sourcePath, targetPath); + if (!isWindows()) { + chmodSync(targetPath, 0o755); + } } } - // config-dir.mjs: canonical source is scripts/lib/, not templates (avoids duplication) const configDirHelperMjs = join(packageDir, 'scripts', 'lib', 'config-dir.mjs'); const configDirHelperMjsDest = join(hooksLibDir, 'config-dir.mjs'); @@ -620,7 +628,6 @@ function ensureStandaloneHookScripts(log: (msg: string) => void): void { if (!isWindows()) { chmodSync(configDirHelperMjsDest, 0o755); } - if (!isWindows()) { const findNodeSrc = join(packageDir, 'scripts', 'find-node.sh'); const findNodeDest = join(HOOKS_DIR, 'find-node.sh');