fix(plugins): use mergeHooksSettings in marketplace supplement path (#1055)#1167
fix(plugins): use mergeHooksSettings in marketplace supplement path (#1055)#11670xghost42 wants to merge 1 commit into
Conversation
…itlawb#1055) `finishLoadingPluginFromPath` supplemented `plugin.hooksConfig` with the marketplace entry's hooks via object spread: plugin.hooksConfig = { ...(plugin.hooksConfig || {}), ...(entry.hooks as HooksSettings), } `HooksSettings` values are matcher arrays keyed by event name. Object spread replaced the entire per-event array from `plugin.json` with the marketplace entry's array, silently dropping any matchers the manifest already registered for the same event (e.g. both contributed `PreToolUse` matchers — only the marketplace ones survived). `mergeHooksSettings` already exists in this file and concatenates per-event arrays correctly; it is the helper used in `createPluginFromPath` for the analogous merge. Use it in the marketplace supplement path too, and export it so the concat-not-replace contract is locked in by a unit test.
gnanam1990
left a comment
There was a problem hiding this comment.
Local: bun test src/utils/plugins/pluginLoader.test.ts → 16/0 pass.
Clean, focused fix. Object-spread on HooksSettings (matcher arrays keyed by event name) was dropping the manifest's matchers whenever the marketplace entry had a matcher for the same event — mergeHooksSettings is exactly the right helper, and it's already the established pattern at lines 1888 and 1925 in the same file. Exporting it for the test is fine.
No red flags. LGTM.
BlockersNone. Non-BlockingNone. Looks Good
Verdict: Approve — clean plugin hook merge fix. |
Vasanthdev2004
left a comment
There was a problem hiding this comment.
Clean plugin hook merge fix. No blockers.
techbrewboss
left a comment
There was a problem hiding this comment.
Review summary
No blocking or actionable issues found.
This is a focused, useful fix for marketplace plugin hook loading. The change reuses the existing hook merge helper instead of object-spreading HooksSettings, preserving both manifest and marketplace matchers for the same event. The added tests cover the regression and adjacent merge behavior.
Findings
No findings.
Value
The PR adds clear project value: it fixes the hook matcher loss described in #1055 without broadening scope or changing unrelated plugin loading behavior.
Maliciousness / Risk
No suspicious behavior found. The PR adds no dependencies, network calls, shell execution, install hooks, credential access, or permission broadening. bun run security:pr-scan reported: PR intent scan: no suspicious additions found.
Validation
bun test src/utils/plugins/pluginLoader.test.tspassed: 16 pass, 0 fail.git diff --check main...HEADpassed.bun run security:pr-scanpassed.bun run typecheckfailed with many repo-wide errors outside this two-file patch; I did not see changed-line evidence tying those failures to this PR.
Recommendation: Approve. The PR is small, tested, valuable, and low risk.
techbrewboss
left a comment
There was a problem hiding this comment.
Approved. No blocking or actionable issues found; the fix is focused, tested, valuable, and low risk.
Fixes #1055.
Problem
In
finishLoadingPluginFromPath, the marketplace supplement path was buildingplugin.hooksConfigwith an object spread:```ts
if (entry.hooks) {
plugin.hooksConfig = {
...(plugin.hooksConfig || {}),
...(entry.hooks as HooksSettings),
}
}
```
`HooksSettings` values are matcher arrays keyed by event name (`PreToolUse`, `PostToolUse`, ...). Object spread replaces the entire per-event array from `plugin.json` with the marketplace entry's array, silently dropping any matchers the manifest already registered for that event.
`mergeHooksSettings` already exists in this file (used by `createPluginFromPath` for the analogous merge) and concatenates per-event matcher arrays correctly. It was just never wired into the marketplace supplement path.
Fix
Tests
Added three unit tests in `pluginLoader.test.ts`:
```
bun test src/utils/plugins/pluginLoader.test.ts
16 pass
0 fail
```