fix: resolve hook failures when CLAUDE_PLUGIN_ROOT is not injected (#1533)

The fallback path for CLAUDE_PLUGIN_ROOT was pointing to the old
marketplaces install location which no longer exists. Hooks now first
try to find the latest versioned cache directory
(~/.claude/plugins/cache/thedotmack/claude-mem/<version>/) using ls -dt,
with the marketplaces path kept as a final fallback.

This mirrors the self-resolution pattern already used in bun-runner.js
(resolve(__bun_runner_dirname, '..')) but at the shell level, so node
can find bun-runner.js in the first place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ousama Ben Younes
2026-04-01 07:01:37 +00:00
parent 3651a34e96
commit d8eb2fa9f9
2 changed files with 27 additions and 8 deletions
@@ -97,6 +97,25 @@ describe('Plugin Distribution - hooks.json Integrity', () => {
}
}
});
it('should try cache path before marketplaces fallback in all hook commands (#1533)', () => {
const hooksPath = path.join(projectRoot, 'plugin/hooks/hooks.json');
const parsed = JSON.parse(readFileSync(hooksPath, 'utf-8'));
const cachePath = '$HOME/.claude/plugins/cache/thedotmack/claude-mem';
const marketplacesPath = '$HOME/.claude/plugins/marketplaces/thedotmack/plugin';
for (const [eventName, matchers] of Object.entries(parsed.hooks)) {
for (const matcher of matchers as any[]) {
for (const hook of matcher.hooks) {
if (hook.type === 'command') {
expect(hook.command).toContain(cachePath);
// Cache lookup must appear before the final marketplaces fallback
expect(hook.command.indexOf(cachePath)).toBeLessThan(hook.command.indexOf(marketplacesPath));
}
}
}
}
});
});
describe('Plugin Distribution - package.json Files Field', () => {