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 <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Gujiassh
2026-04-06 01:22:13 +09:00
committed by gujishh
parent 68d304a9d7
commit d0582516d5

View File

@@ -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');