opencrater 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/cli.js +9 -9
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -133,17 +133,17 @@ function enableIn(file, host) {
133
133
  matcher: "",
134
134
  hooks: [{ type: "command", command: cmdFor(event, host) }],
135
135
  };
136
- const idx = list.findIndex(isOurs);
137
- if (idx >= 0) {
138
- if (JSON.stringify(list[idx]) !== JSON.stringify(desired)) {
139
- list[idx] = desired;
140
- changed = true;
141
- }
142
- } else {
143
- list.push(desired);
136
+ // Remove EVERY entry of ours, then add exactly one. findIndex+replace only
137
+ // fixed the first match, so repeated installs / older command shapes left
138
+ // duplicate opencrater-hook entries piling up. Filtering collapses them.
139
+ const others = list.filter((r) => !isOurs(r));
140
+ const mine = list.filter(isOurs);
141
+ const alreadyCorrect =
142
+ mine.length === 1 && JSON.stringify(mine[0]) === JSON.stringify(desired);
143
+ if (!alreadyCorrect) {
144
+ settings.hooks[event] = [...others, desired];
144
145
  changed = true;
145
146
  }
146
- settings.hooks[event] = list;
147
147
  }
148
148
  if (changed) writeJson(file, settings);
149
149
  return changed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencrater",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "OpenCrater — sponsor cards in Claude Code and Codex. Free, one command, opt out anytime.",
5
5
  "keywords": [
6
6
  "opencrater",