@ols-cli/lightspeed 0.1.0 → 0.1.2
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/bin/ols.js +16 -24
- package/package.json +2 -5
package/bin/ols.js
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* ols config set <key> <val> Set config
|
|
11
11
|
* ols config show Show config
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
const { OLSClient, loadOLSConfig, saveOLSConfig } = require("@ols-cli/client");
|
|
14
14
|
|
|
15
|
-
// ─── Colors (zero deps) ───
|
|
16
15
|
const cyan = "\x1b[36m";
|
|
17
16
|
const green = "\x1b[32m";
|
|
18
17
|
const red = "\x1b[31m";
|
|
@@ -21,8 +20,7 @@ const bold = "\x1b[1m";
|
|
|
21
20
|
const reset = "\x1b[0m";
|
|
22
21
|
const dim = "\x1b[2m";
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
function configCmd(args: string[]): void {
|
|
23
|
+
function configCmd(args) {
|
|
26
24
|
const cmd = args[0];
|
|
27
25
|
if (!cmd || cmd === "show") {
|
|
28
26
|
const cfg = loadOLSConfig();
|
|
@@ -32,7 +30,7 @@ function configCmd(args: string[]): void {
|
|
|
32
30
|
if (cmd === "set" && args[1] && args[2] !== undefined) {
|
|
33
31
|
const cfg = loadOLSConfig();
|
|
34
32
|
const val = args[2] === "true" ? true : args[2] === "false" ? false : args[2];
|
|
35
|
-
|
|
33
|
+
cfg[args[1]] = val;
|
|
36
34
|
saveOLSConfig(cfg);
|
|
37
35
|
console.log(`${green}✓${reset} Set ${args[1]} = ${args[2]}`);
|
|
38
36
|
return;
|
|
@@ -47,8 +45,7 @@ function configCmd(args: string[]): void {
|
|
|
47
45
|
console.log("Usage: ols config [show|set|init]");
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
async function healthCmd(): Promise<void> {
|
|
48
|
+
async function healthCmd() {
|
|
52
49
|
try {
|
|
53
50
|
const client = new OLSClient(loadOLSConfig());
|
|
54
51
|
const h = await client.health();
|
|
@@ -59,14 +56,13 @@ async function healthCmd(): Promise<void> {
|
|
|
59
56
|
console.log(` ${icon}●${reset} ${name}: ${status}`);
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
|
-
} catch (e
|
|
59
|
+
} catch (e) {
|
|
63
60
|
console.error(`${red}✗${reset} ${e.message}`);
|
|
64
61
|
process.exit(1);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
async function conversationsCmd(): Promise<void> {
|
|
65
|
+
async function conversationsCmd() {
|
|
70
66
|
try {
|
|
71
67
|
const client = new OLSClient(loadOLSConfig());
|
|
72
68
|
const convos = await client.listConversations();
|
|
@@ -79,19 +75,18 @@ async function conversationsCmd(): Promise<void> {
|
|
|
79
75
|
const date = new Date(c.created_at).toLocaleDateString();
|
|
80
76
|
console.log(` ${cyan}${c.id}${reset} ${dim}${date}${reset} ${c.first_query || "(no query)"} [${c.message_count} msgs]`);
|
|
81
77
|
}
|
|
82
|
-
} catch (e
|
|
78
|
+
} catch (e) {
|
|
83
79
|
console.error(`${red}✗${reset} ${e.message}`);
|
|
84
80
|
process.exit(1);
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
async function queryCmd(question: string): Promise<void> {
|
|
84
|
+
async function queryCmd(question) {
|
|
90
85
|
try {
|
|
91
86
|
const client = new OLSClient(loadOLSConfig());
|
|
92
87
|
const resp = await client.query({ query: question });
|
|
93
88
|
console.log(`\n${resp.response}\n`);
|
|
94
|
-
if (resp.referenced_documents
|
|
89
|
+
if (resp.referenced_documents && resp.referenced_documents.length) {
|
|
95
90
|
console.log(`${dim}References:${reset}`);
|
|
96
91
|
for (const doc of resp.referenced_documents) {
|
|
97
92
|
console.log(` ${cyan}→${reset} ${doc.title} ${dim}(${doc.url})${reset}`);
|
|
@@ -101,20 +96,19 @@ async function queryCmd(question: string): Promise<void> {
|
|
|
101
96
|
if (resp.conversation_id) {
|
|
102
97
|
console.log(`${dim}Conversation: ${resp.conversation_id}${reset}`);
|
|
103
98
|
}
|
|
104
|
-
} catch (e
|
|
99
|
+
} catch (e) {
|
|
105
100
|
console.error(`${red}✗${reset} ${e.message}`);
|
|
106
101
|
process.exit(1);
|
|
107
102
|
}
|
|
108
103
|
}
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const readline = await import("readline");
|
|
105
|
+
async function interactiveMode() {
|
|
106
|
+
const readline = require("readline");
|
|
113
107
|
|
|
114
108
|
console.log(`\n${bold}${cyan}OpenShift Lightspeed CLI${reset} v0.1.0`);
|
|
115
109
|
console.log(`${dim}Type your question, or 'quit' to exit.${reset}\n`);
|
|
116
110
|
|
|
117
|
-
let conversationId
|
|
111
|
+
let conversationId;
|
|
118
112
|
|
|
119
113
|
const rl = readline.createInterface({
|
|
120
114
|
input: process.stdin,
|
|
@@ -139,22 +133,21 @@ async function interactiveMode(): Promise<void> {
|
|
|
139
133
|
const resp = await client.query({ query: input, conversation_id: conversationId });
|
|
140
134
|
conversationId = resp.conversation_id;
|
|
141
135
|
console.log(`\n${resp.response}\n`);
|
|
142
|
-
if (resp.referenced_documents
|
|
136
|
+
if (resp.referenced_documents && resp.referenced_documents.length) {
|
|
143
137
|
console.log(`${dim}References:${reset}`);
|
|
144
138
|
for (const doc of resp.referenced_documents) {
|
|
145
139
|
console.log(` ${cyan}→${reset} ${doc.title}`);
|
|
146
140
|
}
|
|
147
141
|
console.log();
|
|
148
142
|
}
|
|
149
|
-
} catch (e
|
|
143
|
+
} catch (e) {
|
|
150
144
|
console.error(`${red}✗${reset} ${e.message}`);
|
|
151
145
|
}
|
|
152
146
|
rl.prompt();
|
|
153
147
|
});
|
|
154
148
|
}
|
|
155
149
|
|
|
156
|
-
|
|
157
|
-
async function main(): Promise<void> {
|
|
150
|
+
async function main() {
|
|
158
151
|
const args = process.argv.slice(2);
|
|
159
152
|
|
|
160
153
|
if (args.length === 0) {
|
|
@@ -180,7 +173,6 @@ async function main(): Promise<void> {
|
|
|
180
173
|
return;
|
|
181
174
|
}
|
|
182
175
|
|
|
183
|
-
// Treat as query
|
|
184
176
|
return await queryCmd(args.join(" "));
|
|
185
177
|
}
|
|
186
178
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ols-cli/lightspeed",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "OpenShift Lightspeed CLI — AI-powered assistant for OpenShift from your terminal",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"bin": {
|
|
7
6
|
"ols": "./bin/ols.js"
|
|
8
7
|
},
|
|
9
|
-
"main": "./src/index.js",
|
|
10
8
|
"files": [
|
|
11
9
|
"bin",
|
|
12
|
-
"src",
|
|
13
10
|
"skills",
|
|
14
11
|
"README.md",
|
|
15
12
|
"CHANGELOG.md"
|
|
@@ -38,6 +35,6 @@
|
|
|
38
35
|
"access": "public"
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
|
-
"@ols-cli/client": "^0.1.
|
|
38
|
+
"@ols-cli/client": "^0.1.1"
|
|
42
39
|
}
|
|
43
40
|
}
|