Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/__tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,36 @@ describe('Installer Constants', () => {
}
});
});

describe('Hook Scripts Installation (#2185 regression)', () => {
it('should have all required lib files in templates/hooks/lib', () => {
const templatesLibDir = join(getPackageDir(), 'templates', 'hooks', 'lib');
expect(existsSync(templatesLibDir)).toBe(true);

const libFiles = readdirSync(templatesLibDir);

// Required lib files that must be present
const requiredFiles = ['stdin.mjs', 'atomic-write.mjs', 'config-dir.mjs'];
for (const file of requiredFiles) {
expect(libFiles).toContain(file);
}
});

it('should have all standalone hook template files present', () => {
const templatesDir = join(getPackageDir(), 'templates', 'hooks');
const hookFiles = [
'keyword-detector.mjs',
'session-start.mjs',
'pre-tool-use.mjs',
'post-tool-use.mjs',
'post-tool-use-failure.mjs',
'persistent-mode.mjs',
'code-simplifier.mjs',
];

for (const file of hookFiles) {
expect(existsSync(join(templatesDir, file))).toBe(true);
}
});
});
});
12 changes: 0 additions & 12 deletions src/installer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,6 @@ function ensureStandaloneHookScripts(log: (msg: string) => void): void {
mkdirSync(hooksLibDir, { recursive: true });
}

// Copy shared lib modules (stdin.mjs, atomic-write.mjs) required by hook scripts
const libSourceDir = join(templatesDir, 'lib');
const libTargetDir = join(HOOKS_DIR, 'lib');
if (existsSync(libSourceDir)) {
if (!existsSync(libTargetDir)) {
mkdirSync(libTargetDir, { recursive: true });
}
for (const libFile of readdirSync(libSourceDir)) {
copyFileSync(join(libSourceDir, libFile), join(libTargetDir, libFile));
}
}

for (const filename of STANDALONE_HOOK_TEMPLATE_FILES) {
const sourcePath = join(templatesDir, filename);
const targetPath = join(HOOKS_DIR, filename);
Expand Down
Loading