Merge pull request #605 from pbakaus/codex/issue-604-claude-hook-migration

Fix Windows Claude hook migration dedupe
This commit is contained in:
Abdul Wahab
2026-08-22 04:30:41 +05:00
committed by GitHub
2 changed files with 31 additions and 1 deletions
+2 -1
View File
@@ -1534,7 +1534,8 @@ function hookInstalledForProvider(root, provider) {
function valueHasImpeccableHookMarker(value) {
if (typeof value === 'string') {
return IMPECCABLE_HOOK_COMMAND_MARKERS.some(marker => value.includes(marker));
const normalized = value.replace(/\\/g, '/');
return IMPECCABLE_HOOK_COMMAND_MARKERS.some(marker => normalized.includes(marker));
}
if (Array.isArray(value)) return value.some(valueHasImpeccableHookMarker);
if (value && typeof value === 'object') {
+29
View File
@@ -1649,6 +1649,35 @@ describe('hook manifest merge helpers', () => {
'node .cursor/skills/impeccable/scripts/hook-before-edit.mjs',
]);
});
test('mergeHookManifests replaces legacy Windows-path Claude hooks (#604)', () => {
const legacyPath = 'C:\\Users\\alice\\.claude\\skills\\impeccable\\scripts\\hook.mjs';
const legacyCommand = `[ ! -f "${legacyPath}" ] || node "${legacyPath}"`;
const freshCommand = `node -e "guard" "${legacyPath}"`;
const merged = mergeHookManifests(
{
hooks: {
PostToolUse: [{ matcher: 'Edit|Write|MultiEdit', hooks: [
{ type: 'command', command: legacyCommand },
] }],
Stop: [{ hooks: [{ type: 'command', command: legacyCommand }] }],
},
},
{
hooks: {
PostToolUse: [{ matcher: 'Edit|Write|MultiEdit', hooks: [
{ type: 'command', command: freshCommand },
] }],
Stop: [{ hooks: [{ type: 'command', command: freshCommand }] }],
},
},
);
expect(merged.hooks.PostToolUse).toHaveLength(1);
expect(merged.hooks.Stop).toHaveLength(1);
expect(merged.hooks.PostToolUse[0].hooks[0].command).toBe(freshCommand);
expect(merged.hooks.Stop[0].hooks[0].command).toBe(freshCommand);
});
});
// ─── Hook command path resolution (issue #399, part 1) ───────────────────────