caroushell 0.1.18 → 0.1.19

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.
@@ -10,6 +10,7 @@ const config_1 = require("./config");
10
10
  class HistorySuggester {
11
11
  constructor(filePath) {
12
12
  this.prefix = "⌛";
13
+ // `items` is the history as a list of commands, with the most recent at index 0
13
14
  this.items = [];
14
15
  this.filteredItems = [];
15
16
  this.maxItems = 1000;
@@ -71,18 +72,19 @@ class HistorySuggester {
71
72
  carousel.render();
72
73
  }
73
74
  descriptionForAi() {
75
+ // This goes into the prompt
74
76
  const lines = [];
75
77
  const maxHistoryLines = 20;
76
- const start = Math.max(0, this.items.length - maxHistoryLines);
77
- const end = this.items.length - 1;
78
- const reverseSlice = this.items.slice(start, end).reverse();
79
- if (reverseSlice.length > 0) {
80
- lines.push(`The most recent command is: "${reverseSlice[0]}"`);
78
+ const start = 0;
79
+ const end = maxHistoryLines;
80
+ const newToOldSlice = this.items.slice(start, end);
81
+ if (newToOldSlice.length > 0) {
82
+ lines.push(`The most recent command is: "${newToOldSlice[0]}"`);
81
83
  }
82
- if (reverseSlice.length > 1) {
84
+ if (newToOldSlice.length > 1) {
83
85
  lines.push("The most recent commands are (from recent to oldest):");
84
- for (let i = 0; i < reverseSlice.length; i++) {
85
- lines.push(` ${i + 1}. ${reverseSlice[i]}`);
86
+ for (let i = 0; i < newToOldSlice.length; i++) {
87
+ lines.push(` ${i + 1}. ${newToOldSlice[i]}`);
86
88
  }
87
89
  }
88
90
  return lines.join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caroushell",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Terminal carousel that suggests commands from history, config, and AI.",
5
5
  "type": "commonjs",
6
6
  "main": "dist/main.js",
@@ -17,6 +17,7 @@
17
17
  "build": "tsc -p tsconfig.release.json",
18
18
  "prepare": "npm run build",
19
19
  "start": "node dist/main.js",
20
+ "test": "node --import tsx --test tests/history-suggester.test.ts",
20
21
  "test:generate": "tsx src/test-generate.ts",
21
22
  "lint": "eslint . --ext .ts",
22
23
  "release": "tsx scripts/release.ts"