shellwise 0.2.2 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shellwise",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Smart command history with inline auto-suggest and fuzzy search for your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,13 +21,13 @@ function initPreparedStatements() {
21
21
  suggestPrefix = db.prepare(
22
22
  `SELECT command FROM command_stats
23
23
  WHERE command LIKE ?1 || '%' ESCAPE '\\'
24
- ORDER BY frecency_score DESC
24
+ ORDER BY last_used_at DESC
25
25
  LIMIT ?2`
26
26
  );
27
27
  suggestContains = db.prepare(
28
28
  `SELECT command FROM command_stats
29
29
  WHERE command LIKE '%' || ?1 || '%' ESCAPE '\\' AND command != ?1
30
- ORDER BY frecency_score DESC
30
+ ORDER BY last_used_at DESC
31
31
  LIMIT ?2`
32
32
  );
33
33
  }
package/src/db/queries.ts CHANGED
@@ -151,7 +151,12 @@ export function pruneOlderThan(days: number): number {
151
151
  const db = getDb();
152
152
  const cutoff = Date.now() - days * 24 * 3600_000;
153
153
 
154
- const result = db.run("DELETE FROM commands WHERE created_at < ?", [cutoff]);
154
+ const result = db.run(
155
+ `DELETE FROM commands WHERE command_hash IN (
156
+ SELECT command_hash FROM command_stats WHERE last_used_at < ?
157
+ )`,
158
+ [cutoff]
159
+ );
155
160
 
156
161
  // Cleanup orphaned stats
157
162
  db.run(