skill-atlas-cli 0.2.2 → 0.2.3

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.
Files changed (2) hide show
  1. package/lib/index.js +38 -17
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1191,7 +1191,7 @@ async function resolveInstallScope(options, targetAgents, nonInteractive) {
1191
1191
  return scope;
1192
1192
  }
1193
1193
  /** 非 TTY 下使用静态输出替代 spinner,避免动画帧被逐行打印造成刷屏 */
1194
- function createProgressReporter(nonInteractive) {
1194
+ function createProgressReporter$1(nonInteractive) {
1195
1195
  if (nonInteractive) return {
1196
1196
  start: (msg) => p.log.message(msg),
1197
1197
  stop: (msg) => {
@@ -1208,7 +1208,7 @@ const run$1 = async (args, options = {}) => {
1208
1208
  const nonInteractive = options.yes || isNonInteractiveEnv();
1209
1209
  p.intro(chalk.bold("skill-atlas install"));
1210
1210
  const skill = await resolveSkillName(args[0], nonInteractive);
1211
- const progress = createProgressReporter(nonInteractive);
1211
+ const progress = createProgressReporter$1(nonInteractive);
1212
1212
  progress.start(`Searching for ${chalk.bold(skill)}...`);
1213
1213
  try {
1214
1214
  const asset = await findAsset(skill);
@@ -1382,6 +1382,27 @@ function logKnownError(errorMessage) {
1382
1382
  p.log.info("请检查网络连接后重试");
1383
1383
  }
1384
1384
  }
1385
+ /**
1386
+ * 非 TTY 或显式要求时使用静态日志替代 spinner,避免动画帧在 OpenClaw/CI/管道中被逐行记录并夹杂转义序列。
1387
+ * 需要时可设置环境变量 SKILLATLAS_PLAIN_PROGRESS=1
1388
+ */
1389
+ function shouldUsePlainProgress() {
1390
+ if (process.env.SKILLATLAS_PLAIN_PROGRESS === "1" || process.env.SKILLATLAS_PLAIN_PROGRESS === "true") return true;
1391
+ return !process.stdout.isTTY || !process.stdin.isTTY;
1392
+ }
1393
+ function createProgressReporter(plain) {
1394
+ if (plain) return {
1395
+ start: (msg) => p.log.message(msg),
1396
+ stop: (msg) => {
1397
+ if (msg) p.log.message(msg);
1398
+ }
1399
+ };
1400
+ const s = p.spinner();
1401
+ return {
1402
+ start: (msg) => s.start(msg),
1403
+ stop: (msg) => s.stop(msg ?? "")
1404
+ };
1405
+ }
1385
1406
  const run = async (options = {}) => {
1386
1407
  p.intro(import_picocolors.default.bold("skill-atlas agent-register"));
1387
1408
  if (options.pre) {
@@ -1402,13 +1423,13 @@ const run = async (options = {}) => {
1402
1423
  }
1403
1424
  }
1404
1425
  }
1405
- const spinner = p.spinner();
1406
- spinner.start("正在生成密钥对...");
1426
+ const progress = createProgressReporter(shouldUsePlainProgress());
1427
+ progress.start("正在生成密钥对...");
1407
1428
  try {
1408
1429
  const { privateKey, publicKey } = loadOrGenerateKeyPair();
1409
1430
  const agentId = deriveAgentId(publicKey);
1410
- spinner.stop("密钥对已就绪");
1411
- spinner.start("步骤 1/3: 正在注册 Agent...");
1431
+ progress.stop("密钥对已就绪");
1432
+ progress.start("步骤 1/3: 正在注册 Agent...");
1412
1433
  const registerTimestamp = Math.floor(Date.now() / 1e3);
1413
1434
  const registerRequest = {
1414
1435
  agentId,
@@ -1429,9 +1450,9 @@ const run = async (options = {}) => {
1429
1450
  if (!res.success) if (isAgentExistsError({
1430
1451
  message: res.message,
1431
1452
  code: res.code
1432
- })) spinner.stop("步骤 1/3: Agent 已存在,跳过注册直接进行认证");
1453
+ })) progress.stop("步骤 1/3: Agent 已存在,跳过注册直接进行认证");
1433
1454
  else {
1434
- spinner.stop("注册失败");
1455
+ progress.stop("注册失败");
1435
1456
  p.log.error(res.message || "注册失败");
1436
1457
  process.exit(1);
1437
1458
  }
@@ -1439,10 +1460,10 @@ const run = async (options = {}) => {
1439
1460
  registeredAgentId = res.data?.agentId;
1440
1461
  registeredAt = res.data?.registeredAt || registeredAt;
1441
1462
  registerStatus = res.data?.status || "active";
1442
- spinner.stop("步骤 1/3: Agent 注册成功");
1463
+ progress.stop("步骤 1/3: Agent 注册成功");
1443
1464
  }
1444
1465
  } catch (err) {
1445
- if (isAgentExistsError(err)) spinner.stop("步骤 1/3: Agent 已存在,跳过注册直接进行认证");
1466
+ if (isAgentExistsError(err)) progress.stop("步骤 1/3: Agent 已存在,跳过注册直接进行认证");
1446
1467
  else throw err;
1447
1468
  }
1448
1469
  const agentIdForAuth = registeredAgentId?.trim();
@@ -1450,16 +1471,16 @@ const run = async (options = {}) => {
1450
1471
  p.log.error("注册响应中缺少有效的 agentId,无法继续获取挑战与认证");
1451
1472
  process.exit(1);
1452
1473
  }
1453
- spinner.start("步骤 2/3: 正在获取登录挑战...");
1474
+ progress.start("步骤 2/3: 正在获取登录挑战...");
1454
1475
  const challengeResponse = await getChallenge(agentIdForAuth);
1455
1476
  if (!challengeResponse.success || !challengeResponse.data) {
1456
- spinner.stop("获取挑战失败");
1477
+ progress.stop("获取挑战失败");
1457
1478
  p.log.error(challengeResponse.message || "无法获取登录挑战");
1458
1479
  process.exit(1);
1459
1480
  }
1460
1481
  const { nonce, timestamp: challengeTimestamp } = challengeResponse.data;
1461
- spinner.stop("步骤 2/3: 获取挑战成功");
1462
- spinner.start("步骤 3/3: 正在认证...");
1482
+ progress.stop("步骤 2/3: 获取挑战成功");
1483
+ progress.start("步骤 3/3: 正在认证...");
1463
1484
  const authResponse = await authenticateAgent({
1464
1485
  agentId: agentIdForAuth,
1465
1486
  signature: createAuthSignature(privateKey, agentIdForAuth, nonce, challengeTimestamp),
@@ -1467,13 +1488,13 @@ const run = async (options = {}) => {
1467
1488
  timestamp: challengeTimestamp
1468
1489
  });
1469
1490
  if (!authResponse.success || !authResponse.data) {
1470
- spinner.stop("认证失败");
1491
+ progress.stop("认证失败");
1471
1492
  p.log.error(authResponse.message || "认证失败");
1472
1493
  process.exit(1);
1473
1494
  }
1474
1495
  const { token, expiresAt } = authResponse.data;
1475
1496
  config_default.saveAgentCredentials(agentIdForAuth, token, registeredAt, expiresAt);
1476
- spinner.stop("步骤 3/3: 认证成功");
1497
+ progress.stop("步骤 3/3: 认证成功");
1477
1498
  p.note([
1478
1499
  ` ${import_picocolors.default.green("Agent ID:")} ${agentIdForAuth}`,
1479
1500
  ` ${import_picocolors.default.green("状态:")} ${registerStatus}`,
@@ -1482,7 +1503,7 @@ const run = async (options = {}) => {
1482
1503
  ].join("\n"), import_picocolors.default.green("Agent 注册完成"));
1483
1504
  p.outro(import_picocolors.default.green("完成!") + import_picocolors.default.dim(" 您的 Agent 已成功注册并认证。"));
1484
1505
  } catch (error) {
1485
- spinner.stop("注册失败");
1506
+ progress.stop("注册失败");
1486
1507
  logKnownError(error instanceof Error ? error.message : String(error));
1487
1508
  process.exit(1);
1488
1509
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skill-atlas-cli",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "skill-atlas CLI - 虾小宝 命令行工具",
5
5
  "homepage": "https://ai.skillatlas.cn/",
6
6
  "type": "module",