oh-aicoding-tool 0.1.5 → 0.1.6
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/cli.js +61 -24
- package/package.json +3 -3
package/bin/cli.js
CHANGED
|
@@ -83,11 +83,48 @@ function runPackageBin(packageName, binName, args) {
|
|
|
83
83
|
return result.status ?? (result.error ? 1 : 0);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
function emailIsValid(value) {
|
|
87
|
-
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value || "").trim());
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function
|
|
86
|
+
function emailIsValid(value) {
|
|
87
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(value || "").trim());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function keySeq(raw, key = {}) {
|
|
91
|
+
return String(key.sequence ?? raw ?? "");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function isCtrlC(raw, key = {}) {
|
|
95
|
+
return Boolean(key.ctrl && key.name === "c") || keySeq(raw, key) === "\x03";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function isEscape(raw, key = {}) {
|
|
99
|
+
const seq = keySeq(raw, key);
|
|
100
|
+
return key.name === "escape" || seq === "\x1b";
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function isUpKey(raw, key = {}) {
|
|
104
|
+
const seq = keySeq(raw, key);
|
|
105
|
+
return key.name === "up" || seq === "\x1b[A" || seq === "\x1bOA";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isDownKey(raw, key = {}) {
|
|
109
|
+
const seq = keySeq(raw, key);
|
|
110
|
+
return key.name === "down" || seq === "\x1b[B" || seq === "\x1bOB";
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isEnterKey(raw, key = {}) {
|
|
114
|
+
const seq = keySeq(raw, key);
|
|
115
|
+
return key.name === "return" || key.name === "enter" || seq === "\r" || seq === "\n";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isSpaceKey(raw, key = {}) {
|
|
119
|
+
return key.name === "space" || keySeq(raw, key) === " ";
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function numberKey(raw, key = {}) {
|
|
123
|
+
const seq = keySeq(raw, key);
|
|
124
|
+
return /^[1-9]$/.test(seq) ? Number.parseInt(seq, 10) : Number.NaN;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function renderMultiChoice(title, choices, index, selected, subtitle) {
|
|
91
128
|
renderHeader(subtitle);
|
|
92
129
|
console.log("");
|
|
93
130
|
console.log(paint(title, t.bold, t.blue));
|
|
@@ -128,25 +165,25 @@ async function askMultiChoice(rl, title, choices, subtitle) {
|
|
|
128
165
|
renderMultiChoice(title, choices, index, selected, subtitle);
|
|
129
166
|
}
|
|
130
167
|
|
|
131
|
-
function onKeypress(
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (key
|
|
145
|
-
if (
|
|
146
|
-
const number =
|
|
147
|
-
if (Number.isInteger(number) && choices[number - 1]) {
|
|
148
|
-
index = number - 1;
|
|
149
|
-
toggle();
|
|
168
|
+
function onKeypress(raw, key = {}) {
|
|
169
|
+
if (isCtrlC(raw, key)) return cleanup([]);
|
|
170
|
+
if (isUpKey(raw, key)) {
|
|
171
|
+
index = (index - 1 + choices.length) % choices.length;
|
|
172
|
+
renderMultiChoice(title, choices, index, selected, subtitle);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (isDownKey(raw, key)) {
|
|
176
|
+
index = (index + 1) % choices.length;
|
|
177
|
+
renderMultiChoice(title, choices, index, selected, subtitle);
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (keySeq(raw, key).toLowerCase() === "q" || isEscape(raw, key)) return cleanup([]);
|
|
181
|
+
if (isSpaceKey(raw, key)) return toggle();
|
|
182
|
+
if (isEnterKey(raw, key)) return cleanup([...selected]);
|
|
183
|
+
const number = numberKey(raw, key);
|
|
184
|
+
if (Number.isInteger(number) && choices[number - 1]) {
|
|
185
|
+
index = number - 1;
|
|
186
|
+
toggle();
|
|
150
187
|
}
|
|
151
188
|
}
|
|
152
189
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oh-aicoding-tool",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Interactive installer for AI coding tools: Langfuse tracing and oh-ai-report.",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "UNLICENSED",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"oh-langfuse": "^0.1.
|
|
29
|
-
"oh-aireport": "^0.1.1"
|
|
28
|
+
"oh-langfuse": "^0.1.9",
|
|
29
|
+
"oh-aireport": "^0.1.1"
|
|
30
30
|
}
|
|
31
31
|
}
|