nubos-pilot 0.2.0 → 0.2.1
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/install.js +2 -1
- package/lib/runtime/_readline.cjs +44 -9
- package/package.json +1 -1
package/bin/install.js
CHANGED
|
@@ -192,9 +192,10 @@ async function _runInitQuestions(detectedRuntime, askUser, flags) {
|
|
|
192
192
|
runtimes = [f.agent];
|
|
193
193
|
} else {
|
|
194
194
|
const labels = _runtimeSelectLabels();
|
|
195
|
+
const detectedIdx = Math.max(0, VALID_AGENTS.indexOf(detectedRuntime || 'claude'));
|
|
195
196
|
const picked = (await askUser({ type: 'multiselect',
|
|
196
197
|
question: yellow + 'Which runtime(s) would you like to install for?' + reset,
|
|
197
|
-
options: labels, default: [
|
|
198
|
+
options: labels, default: [labels[detectedIdx]] })).value;
|
|
198
199
|
runtimes = Array.isArray(picked) && picked.length && typeof picked[0] === 'string'
|
|
199
200
|
&& picked[0].includes('(')
|
|
200
201
|
? picked.map((label) => {
|
|
@@ -51,7 +51,7 @@ function _parseAnswer(type, rawLine, options, def) {
|
|
|
51
51
|
}
|
|
52
52
|
if (type === 'multiselect') {
|
|
53
53
|
if (line === '' && def != null) return def;
|
|
54
|
-
const parts = line.split(
|
|
54
|
+
const parts = line.split(/[\s,]+/).map((s) => s.trim()).filter(Boolean);
|
|
55
55
|
const picks = [];
|
|
56
56
|
for (const p of parts) {
|
|
57
57
|
const n = Number(p);
|
|
@@ -88,6 +88,36 @@ function _parseAnswer(type, rawLine, options, def) {
|
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
const NUBOS_BLUE = '\x1b[38;5;33m';
|
|
92
|
+
const ANSI_RESET = '\x1b[0m';
|
|
93
|
+
|
|
94
|
+
function _defaultDisplay(type, options, def) {
|
|
95
|
+
if (def == null) {
|
|
96
|
+
if (type === 'confirm') return '[y/n]';
|
|
97
|
+
return '';
|
|
98
|
+
}
|
|
99
|
+
if (type === 'confirm') {
|
|
100
|
+
if (def === true) return '[Y/n]';
|
|
101
|
+
if (def === false) return '[y/N]';
|
|
102
|
+
return '[y/n]';
|
|
103
|
+
}
|
|
104
|
+
if (type === 'select') {
|
|
105
|
+
if (options) {
|
|
106
|
+
const idx = options.indexOf(def);
|
|
107
|
+
if (idx >= 0) return '[' + (idx + 1) + ']';
|
|
108
|
+
}
|
|
109
|
+
return '[' + String(def) + ']';
|
|
110
|
+
}
|
|
111
|
+
if (type === 'multiselect') {
|
|
112
|
+
if (Array.isArray(def) && options) {
|
|
113
|
+
const idxs = def.map((v) => options.indexOf(v));
|
|
114
|
+
if (idxs.every((i) => i >= 0)) return '[' + idxs.map((i) => i + 1).join(',') + ']';
|
|
115
|
+
}
|
|
116
|
+
return '[' + (Array.isArray(def) ? def.join(',') : String(def)) + ']';
|
|
117
|
+
}
|
|
118
|
+
return '[' + String(def) + ']';
|
|
119
|
+
}
|
|
120
|
+
|
|
91
121
|
async function askUserReadline({ type, question, options, def }) {
|
|
92
122
|
const hasTTY = !!process.stdin.isTTY;
|
|
93
123
|
if (!hasTTY && !_readlineImpl) {
|
|
@@ -98,20 +128,25 @@ async function askUserReadline({ type, question, options, def }) {
|
|
|
98
128
|
{ question },
|
|
99
129
|
);
|
|
100
130
|
}
|
|
101
|
-
process.stderr.write(
|
|
131
|
+
process.stderr.write('\n');
|
|
132
|
+
process.stderr.write(' ' + question + '\n');
|
|
133
|
+
process.stderr.write('\n');
|
|
102
134
|
if (type === 'select' || type === 'multiselect') {
|
|
103
135
|
if (options) {
|
|
104
136
|
for (let i = 0; i < options.length; i++) {
|
|
105
|
-
process.stderr.write(
|
|
137
|
+
process.stderr.write(
|
|
138
|
+
' ' + NUBOS_BLUE + (i + 1) + ')' + ANSI_RESET + ' ' + String(options[i]) + '\n',
|
|
139
|
+
);
|
|
106
140
|
}
|
|
107
141
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
process.stderr.write('> ');
|
|
142
|
+
process.stderr.write('\n');
|
|
143
|
+
if (type === 'multiselect') {
|
|
144
|
+
process.stderr.write(' Select multiple: 1,2,6 or 1 2 6\n');
|
|
145
|
+
process.stderr.write('\n');
|
|
146
|
+
}
|
|
114
147
|
}
|
|
148
|
+
const marker = _defaultDisplay(type, options, def);
|
|
149
|
+
process.stderr.write(' Choice' + (marker ? ' ' + marker : '') + ': ');
|
|
115
150
|
const line = await _readOneLine();
|
|
116
151
|
return { value: _parseAnswer(type, line, options, def), source: 'readline' };
|
|
117
152
|
}
|