openhorizon-cli 1.0.6 → 1.0.7
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/dist/index.js +23 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -82,6 +82,14 @@ function getHistoryEntries() {
|
|
|
82
82
|
return [];
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
function clearHistory() {
|
|
86
|
+
try {
|
|
87
|
+
if (fs2.existsSync(HISTORY_FILE)) {
|
|
88
|
+
fs2.unlinkSync(HISTORY_FILE);
|
|
89
|
+
}
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
85
93
|
function printHistoryEntries(entries, limit, isRaw = false) {
|
|
86
94
|
if (entries.length === 0) {
|
|
87
95
|
console.log(chalk.gray("\n No history found.\n"));
|
|
@@ -222,7 +230,7 @@ async function* streamCompletion(baseUrl, apiKey, model, messages) {
|
|
|
222
230
|
Authorization: `Bearer ${apiKey}`,
|
|
223
231
|
"x-api-key": apiKey,
|
|
224
232
|
"x-client": "openhorizon-cli",
|
|
225
|
-
"x-client-version": "1.0.
|
|
233
|
+
"x-client-version": "1.0.7"
|
|
226
234
|
},
|
|
227
235
|
body: JSON.stringify({ model, messages, stream: true })
|
|
228
236
|
});
|
|
@@ -298,24 +306,31 @@ async function runChatLoop(options) {
|
|
|
298
306
|
console.log(chalk3.gray("\n /model \u2013 show current model"));
|
|
299
307
|
console.log(chalk3.gray(" /version \u2013 show current CLI version"));
|
|
300
308
|
console.log(chalk3.gray(" /update \u2013 check for and install updates"));
|
|
301
|
-
console.log(chalk3.gray(" /history \u2013
|
|
302
|
-
console.log(chalk3.gray(" /clear \u2013 clear
|
|
309
|
+
console.log(chalk3.gray(" /history \u2013 guide on how to view chat history"));
|
|
310
|
+
console.log(chalk3.gray(" /clear \u2013 permanently clear all chat history"));
|
|
303
311
|
console.log(chalk3.gray(" exit \u2013 quit\n"));
|
|
304
312
|
console.log(chalk3.dim(" Tip: Use 'openhorizon history --help' for full history viewer.\n"));
|
|
305
313
|
continue;
|
|
306
314
|
}
|
|
307
315
|
if (trimmed === "/version") {
|
|
308
316
|
console.log(chalk3.blue(`
|
|
309
|
-
OpenHorizon CLI version: ${chalk3.bold("1.0.
|
|
317
|
+
OpenHorizon CLI version: ${chalk3.bold("1.0.7")}
|
|
310
318
|
`));
|
|
311
319
|
continue;
|
|
312
320
|
}
|
|
313
321
|
if (trimmed === "/update") {
|
|
314
|
-
await runUpdate("1.0.
|
|
322
|
+
await runUpdate("1.0.7");
|
|
315
323
|
continue;
|
|
316
324
|
}
|
|
317
325
|
if (trimmed.startsWith("/history")) {
|
|
318
326
|
const args = trimmed.split(" ").slice(1);
|
|
327
|
+
if (args.length === 0) {
|
|
328
|
+
console.log(chalk3.blue("\n History Usage Guide:"));
|
|
329
|
+
console.log(chalk3.gray(" /history <number> \u2013 show last N messages (e.g. /history 10)"));
|
|
330
|
+
console.log(chalk3.gray(" /history --raw \u2013 output history in raw JSONL format\n"));
|
|
331
|
+
console.log(chalk3.dim(" Tip: Use 'openhorizon history' outside as a standalone command.\n"));
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
319
334
|
const limit = args.find((a) => !isNaN(Number(a))) || 5;
|
|
320
335
|
const isRaw = args.includes("--raw");
|
|
321
336
|
const entries = getHistoryEntries();
|
|
@@ -330,7 +345,8 @@ async function runChatLoop(options) {
|
|
|
330
345
|
}
|
|
331
346
|
if (trimmed === "/clear") {
|
|
332
347
|
messages.length = 0;
|
|
333
|
-
|
|
348
|
+
clearHistory();
|
|
349
|
+
console.log(chalk3.gray("\n \u2713 History and conversation persistently cleared.\n"));
|
|
334
350
|
continue;
|
|
335
351
|
}
|
|
336
352
|
messages.push({ role: "user", content: trimmed });
|
|
@@ -395,7 +411,7 @@ async function runChatLoop(options) {
|
|
|
395
411
|
// src/index.ts
|
|
396
412
|
dotenv.config();
|
|
397
413
|
var program = new Command();
|
|
398
|
-
var version = "1.0.
|
|
414
|
+
var version = "1.0.7";
|
|
399
415
|
program.name("openhorizon").description("CLI to interact with OpenHorizon AI Models").version(version, "-v, --version", "Output the current version");
|
|
400
416
|
program.command("version").description("Show the current CLI version").action(() => {
|
|
401
417
|
console.log(chalk4.blue(`OpenHorizon CLI version: ${chalk4.bold(version)}`));
|