@lilmgenius/win-hooks 1.15.2 → 1.15.3

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/package.json +12 -2
  2. package/src/stale.mjs +25 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lilmgenius/win-hooks",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -39,5 +39,15 @@
39
39
  "bugs": {
40
40
  "url": "https://github.com/LilMGenius/win-hooks/issues"
41
41
  },
42
- "keywords": ["windows","hooks","claude-code","codex","plugin","compatibility","patch","cli","winux"]
42
+ "keywords": [
43
+ "windows",
44
+ "hooks",
45
+ "claude-code",
46
+ "codex",
47
+ "plugin",
48
+ "compatibility",
49
+ "patch",
50
+ "cli",
51
+ "winux"
52
+ ]
43
53
  }
package/src/stale.mjs CHANGED
@@ -130,11 +130,18 @@ function readRecords(host, now) {
130
130
  // host's cache - a checkout run by hand is nobody's session root. Written
131
131
  // through a rename, so a concurrent heal never reads half a file; two heals
132
132
  // racing can drop one entry, which that session's next prompt writes back.
133
+ //
134
+ // Every version of every plugin installed in the cache is noted as well, so a
135
+ // plugin other than win-hooks that an upgrade removes whole is also restored
136
+ // by the heal that runs next (CASE-36). The expiry sheds the names of versions
137
+ // nobody runs any more.
133
138
  export function recordRoot(host, root, now = Date.now()) {
134
- if (!placeOf(host, root)) return;
139
+ const roots = [...installedRoots(host)];
140
+ if (placeOf(host, root)) roots.push(root);
141
+ if (!roots.length) return;
135
142
  try {
136
143
  const records = readRecords(host, now);
137
- records[toPosix(resolve(root))] = new Date(now).toISOString();
144
+ for (const r of roots) records[toPosix(resolve(r))] = new Date(now).toISOString();
138
145
  mkdirSync(host.stateDir, { recursive: true });
139
146
  const tmp = recordsFile(host) + '.' + process.pid;
140
147
  writeFileSync(tmp, JSON.stringify(records, null, 2) + '\n');
@@ -142,6 +149,22 @@ export function recordRoot(host, root, now = Date.now()) {
142
149
  } catch { /* a missing record costs a restart, never a session */ }
143
150
  }
144
151
 
152
+ // Every version directory in the host's cache that is installed right now.
153
+ function installedRoots(host) {
154
+ const manifest = host.manifestDir;
155
+ if (!host.cacheDir || !manifest) return [];
156
+ const roots = [];
157
+ for (const marketplace of childNames(host.cacheDir)) {
158
+ for (const plugin of childNames(join(host.cacheDir, marketplace))) {
159
+ const base = join(host.cacheDir, marketplace, plugin);
160
+ for (const name of childNames(base).filter((n) => !n.startsWith('.'))) {
161
+ if (isInstalled(join(base, name), manifest)) roots.push(join(base, name));
162
+ }
163
+ }
164
+ }
165
+ return roots;
166
+ }
167
+
145
168
  // -- Finding and restoring ---------------------------------------------
146
169
 
147
170
  // Every root a live session may still run from that does not hold a working