caroushell 0.1.16 → 0.1.17

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.
@@ -11,6 +11,7 @@ class HistorySuggester {
11
11
  constructor(filePath) {
12
12
  this.prefix = "⌛";
13
13
  this.items = [];
14
+ this.filteredItems = [];
14
15
  this.maxItems = 1000;
15
16
  const home = process.env.HOME || process.env.USERPROFILE || process.cwd();
16
17
  // Default path: ~/.caroushell/history
@@ -24,9 +25,11 @@ class HistorySuggester {
24
25
  try {
25
26
  const data = await fs_1.promises.readFile(this.filePath, "utf8");
26
27
  this.items = this.parseHistory(data);
28
+ this.filteredItems = this.items;
27
29
  }
28
30
  catch {
29
31
  this.items = [];
32
+ this.filteredItems = [];
30
33
  }
31
34
  }
32
35
  async add(command) {
@@ -45,29 +48,26 @@ class HistorySuggester {
45
48
  await fs_1.promises.appendFile(this.filePath, this.serializeHistoryEntry(command), "utf8");
46
49
  }
47
50
  latest() {
48
- return this.items;
51
+ return this.filteredItems;
49
52
  }
50
53
  async refreshSuggestions(carousel, maxDisplayed) {
51
54
  const input = carousel.getCurrentRow();
52
- let results;
53
- if (!input) {
54
- // this.items 0 index is newest
55
- results = this.items;
56
- }
57
- else {
55
+ let suggestedItems = this.items;
56
+ if (input) {
57
+ // filter by input substring
58
58
  const q = input.toLowerCase();
59
- const matched = [];
59
+ suggestedItems = [];
60
60
  // iterate from newest to oldest so we skip older duplicates
61
61
  const seen = new Set();
62
62
  for (let i = 0; i < this.items.length; i++) {
63
63
  const it = this.items[i];
64
64
  if (it.toLowerCase().includes(q) && !seen.has(it)) {
65
65
  seen.add(it);
66
- matched.push(it);
66
+ suggestedItems.push(it);
67
67
  }
68
68
  }
69
- results = matched;
70
69
  }
70
+ this.filteredItems = suggestedItems;
71
71
  carousel.render();
72
72
  }
73
73
  descriptionForAi() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caroushell",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "Terminal carousel that suggests commands from history, config, and AI.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/main.js",