@autotask/atools-tool 0.1.10 → 0.1.11

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.
@@ -240,22 +240,31 @@ function canUseArrowMenu() {
240
240
  function askChoiceArrow(question, options, defaultIndex = 0) {
241
241
  return new Promise((resolve, reject) => {
242
242
  let index = defaultIndex;
243
-
243
+ process.stdout.write("\n" + question + "\n");
244
+ let firstDraw = true;
244
245
  const draw = () => {
245
- readline.clearLine(process.stdout, 0);
246
- readline.cursorTo(process.stdout, 0);
247
- const label = `${index + 1}. ${options[index]}`;
248
- const line = withColor(`> ${label}`, ANSI.cyan, ANSI.bold);
249
- process.stdout.write(`${line} (↑/↓, Enter; 数字直接跳转)`);
246
+ if (!firstDraw) {
247
+ readline.moveCursor(process.stdout, 0, -options.length);
248
+ } else {
249
+ firstDraw = false;
250
+ }
251
+ for (let i = 0; i < options.length; i += 1) {
252
+ readline.clearLine(process.stdout, 0);
253
+ const prefix = i === index ? '> ' : ' ';
254
+ const label = String(i + 1) + ". " + String(options[i]);
255
+ let line = prefix + label;
256
+ if (i === index) {
257
+ line = withColor(line, ANSI.cyan, ANSI.bold) + ' (↑/↓, Enter; 数字直接跳转)';
258
+ }
259
+ process.stdout.write(line + "\n");
260
+ }
250
261
  };
251
-
252
262
  const cleanup = () => {
253
263
  process.stdin.off('keypress', onKeyPress);
254
- if (process.stdin.isTTY && typeof process.stdin.setRawMode === 'function') {
264
+ if (process.stdin.isTTY && typeof process.stdin.setRawMode === "function") {
255
265
  process.stdin.setRawMode(false);
256
266
  }
257
267
  };
258
-
259
268
  const onKeyPress = (str, key = {}) => {
260
269
  if (key.ctrl && key.name === 'c') {
261
270
  cleanup();
@@ -274,9 +283,7 @@ function askChoiceArrow(question, options, defaultIndex = 0) {
274
283
  }
275
284
  if (key.name === 'return' || key.name === 'enter') {
276
285
  cleanup();
277
- readline.clearLine(process.stdout, 0);
278
- readline.cursorTo(process.stdout, 0);
279
- process.stdout.write(`已选择: ${options[index]}\n`);
286
+ process.stdout.write("已选择: " + String(options[index]) + "\n");
280
287
  resolve(options[index]);
281
288
  return;
282
289
  }
@@ -286,9 +293,7 @@ function askChoiceArrow(question, options, defaultIndex = 0) {
286
293
  draw();
287
294
  }
288
295
  };
289
-
290
296
  try {
291
- process.stdout.write(`\n${question}\n`);
292
297
  readline.emitKeypressEvents(process.stdin);
293
298
  process.stdin.setRawMode(true);
294
299
  process.stdin.resume();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autotask/atools-tool",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "ATools CLI for OpenClaw proxy compatibility and interactive model configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",