@kvell007/embed-labs-cli 0.1.0-alpha.30 → 0.1.0-alpha.31

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/dist/index.js CHANGED
@@ -98,10 +98,11 @@ const IMAGE_BOOT_LOGO_COMPOSE_USAGE = "Usage: embed image boot-logo compose --pa
98
98
  const BUILD_IMAGE_DTB_USAGE = "Usage: embed build image dtb --dtb <local.dtb|local.dts> [--input-format auto|dtb|dts] [--account <account_id>] [--project <project_id>] [--board taishanpi] [--variant 1M-RK3566] [--output <package.json>] [--json]";
99
99
  const IMAGE_DTB_COMPOSE_USAGE = "Usage: embed image dtb compose --package <dtb-package.json> --base-image <boot.img|image.img> --output <image> [--manifest <manifest.json>] [--force] [--json]";
100
100
  const LOCAL_TOOLCHAIN_LIST_USAGE = "Usage: embed local toolchain list [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--install-root <path>] [--json]";
101
+ const LOCAL_TOOLCHAIN_INSTALLED_USAGE = "Usage: embed local toolchain installed [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--install-root <path>] [--json]";
101
102
  const LOCAL_TOOLCHAIN_LATEST_USAGE = "Usage: embed local toolchain latest [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--json]";
102
103
  const LOCAL_TOOLCHAIN_CURRENT_USAGE = "Usage: embed local toolchain current [--install-root <path>] [--json]";
103
- const LOCAL_TOOLCHAIN_INSTALL_USAGE = "Usage: embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--mode minimal|compile|qt|full|images] [--force] [--json]\nDefault source: the production download channel at download.embedboard.com.";
104
- const LOCAL_TOOLCHAIN_VALIDATE_USAGE = "Usage: embed local toolchain validate [--release-root <path>] [--mode minimal|compile|qt|full|images] [--json]";
104
+ const LOCAL_TOOLCHAIN_INSTALL_USAGE = "Usage: embed local toolchain install [--board taishanpi-1m-rk3566|pico2w-rp2350-monitor] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--mode minimal|runtime|compile|qt|firmware|full|images] [--force] [--json]\nDefault source: the production download channel at download.embedboard.com.";
105
+ const LOCAL_TOOLCHAIN_VALIDATE_USAGE = "Usage: embed local toolchain validate [--board taishanpi-1m-rk3566|pico2w-rp2350-monitor] [--release-root <path>] [--mode minimal|runtime|compile|qt|firmware|full|images] [--json]";
105
106
  const LOCAL_COMPILE_TAISHANPI_USAGE = "Usage: embed local compile taishanpi --source <main.c|main.cpp> --output <artifact> [--release-root <path>] [--account <account_id>] [--json]";
106
107
  const LOCAL_BUILD_QT_SMOKE_USAGE = "Usage: embed local build qt-smoke --build-dir <dir> [--source <qt-smoke-dir>] [--release-root <path>] [--account <account_id>] [--json]";
107
108
  const AUTH_DEVICE_STATUS_USAGE = "Usage: embed auth device status [--json]";
@@ -578,6 +579,13 @@ async function main(argv) {
578
579
  }
579
580
  return output(parsed, ok(await listLocalToolchainEnvironments(request)), renderLocalToolchainList);
580
581
  }
582
+ if (action === "toolchain" && parsed.command[2] === "installed") {
583
+ const request = localToolchainListRequest(parsed, LOCAL_TOOLCHAIN_INSTALLED_USAGE);
584
+ if (typeof request === "string") {
585
+ return output(parsed, fail("invalid_args", request), undefined, 2);
586
+ }
587
+ return output(parsed, ok(await listLocalToolchainEnvironments({ ...request, installedOnly: true })), renderLocalToolchainList);
588
+ }
581
589
  if (action === "toolchain" && parsed.command[2] === "latest") {
582
590
  const request = localToolchainLatestRequest(parsed);
583
591
  if (typeof request === "string") {
@@ -622,6 +630,7 @@ async function main(argv) {
622
630
  }
623
631
  return output(parsed, fail("invalid_args", [
624
632
  LOCAL_TOOLCHAIN_LIST_USAGE,
633
+ LOCAL_TOOLCHAIN_INSTALLED_USAGE,
625
634
  LOCAL_TOOLCHAIN_LATEST_USAGE,
626
635
  LOCAL_TOOLCHAIN_CURRENT_USAGE,
627
636
  LOCAL_TOOLCHAIN_INSTALL_USAGE,
@@ -5595,14 +5604,14 @@ function billingSnapshotListRequest(parsed) {
5595
5604
  }
5596
5605
  return { path: `/v1/accounts/${encodeURIComponent(accountResult.value)}/billing/snapshots` };
5597
5606
  }
5598
- function localToolchainListRequest(parsed) {
5607
+ function localToolchainListRequest(parsed, usage = LOCAL_TOOLCHAIN_LIST_USAGE) {
5599
5608
  const unknownFlag = firstUnknownFlag(parsed, ["json", "board", "board-id", "channel", "metadata-root", "install-root"]);
5600
5609
  if (unknownFlag) {
5601
- return `Unknown flag --${unknownFlag}. ${LOCAL_TOOLCHAIN_LIST_USAGE}`;
5610
+ return `Unknown flag --${unknownFlag}. ${usage}`;
5602
5611
  }
5603
5612
  const extra = parsed.command.slice(3);
5604
5613
  if (extra.length > 0) {
5605
- return `Unexpected argument: ${extra[0]}. ${LOCAL_TOOLCHAIN_LIST_USAGE}`;
5614
+ return `Unexpected argument: ${extra[0]}. ${usage}`;
5606
5615
  }
5607
5616
  const board = optionalTrimmedStringAliasFlag(parsed, ["board", "board-id"], "board or board-id");
5608
5617
  if (board.error)
@@ -5697,7 +5706,7 @@ function localToolchainInstallRequest(parsed) {
5697
5706
  };
5698
5707
  }
5699
5708
  function localToolchainValidateRequest(parsed) {
5700
- const unknownFlag = firstUnknownFlag(parsed, ["json", "release-root", "mode"]);
5709
+ const unknownFlag = firstUnknownFlag(parsed, ["json", "board", "board-id", "release-root", "mode"]);
5701
5710
  if (unknownFlag) {
5702
5711
  return `Unknown flag --${unknownFlag}. ${LOCAL_TOOLCHAIN_VALIDATE_USAGE}`;
5703
5712
  }
@@ -5709,11 +5718,15 @@ function localToolchainValidateRequest(parsed) {
5709
5718
  if (releaseRoot.error) {
5710
5719
  return releaseRoot.error;
5711
5720
  }
5721
+ const board = optionalTrimmedStringAliasFlag(parsed, ["board", "board-id"], "board or board-id");
5722
+ if (board.error) {
5723
+ return board.error;
5724
+ }
5712
5725
  const mode = optionalTrimmedStringFlag(parsed, "mode");
5713
5726
  if (mode.error) {
5714
5727
  return mode.error;
5715
5728
  }
5716
- return { releaseRoot: releaseRoot.value, mode: mode.value };
5729
+ return { releaseRoot: releaseRoot.value, mode: mode.value, boardId: board.value };
5717
5730
  }
5718
5731
  function localCompileTaishanPiRequest(parsed, auth) {
5719
5732
  const unknownFlag = firstUnknownFlag(parsed, ["json", "source", "output", "release-root", "account", "account-id"]);
@@ -6934,18 +6947,22 @@ function renderBuildWorkspaceSourcePatch(result) {
6934
6947
  return lines.join("\n");
6935
6948
  }
6936
6949
  function renderLocalToolchainList(result) {
6950
+ const installedCount = result.environments.filter((environment) => !!environment.installed).length;
6951
+ const availableCount = result.environments.filter((environment) => environment.status === "available").length;
6952
+ const updateCount = result.environments.filter((environment) => environment.status === "update_available").length;
6937
6953
  const lines = [
6938
6954
  `Local development environments: ${result.environments.length}`,
6955
+ `installed=${installedCount} available=${availableCount} updates=${updateCount}`,
6939
6956
  `host=${result.host}`,
6940
6957
  `channel=${result.channel}`,
6941
- result.metadata_root ? `metadata_root=${result.metadata_root}` : "metadata=built-in",
6958
+ result.metadata_source === "local_override" ? `metadata_override=${result.metadata_root}` : "metadata=production/built-in",
6942
6959
  `install_root=${result.install_root}`,
6943
6960
  `registry=${result.registry_path}`
6944
6961
  ];
6945
6962
  for (const environment of result.environments) {
6946
6963
  lines.push("");
6947
6964
  lines.push(`${environment.display_name} (${environment.board_id})`);
6948
- lines.push(` status=${environment.status}`);
6965
+ lines.push(` status=${localToolchainStatusLabel(environment.status)}`);
6949
6966
  lines.push(` latest=${environment.latest.version}`);
6950
6967
  if (environment.installed) {
6951
6968
  lines.push(` installed=${environment.installed.version ?? "unknown"} mode=${environment.installed.mode ?? "unknown"}`);
@@ -6959,7 +6976,9 @@ function renderLocalToolchainList(result) {
6959
6976
  lines.push(` update_command=${environment.update_command}`);
6960
6977
  }
6961
6978
  if (environment.components?.length) {
6962
- lines.push(` components=${environment.components.map((component) => `${component.id}@${component.version}`).join(", ")}`);
6979
+ lines.push(` package_summary=${localToolchainComponentSummary(environment.components)}`);
6980
+ lines.push(` package_groups=${localToolchainComponentGroups(environment.components).join(", ")}`);
6981
+ lines.push(` detail_command=embedlabs local toolchain latest --board ${environment.board_id}`);
6963
6982
  }
6964
6983
  if (environment.notes.length > 0) {
6965
6984
  for (const note of environment.notes) {
@@ -6969,6 +6988,56 @@ function renderLocalToolchainList(result) {
6969
6988
  }
6970
6989
  return lines.join("\n");
6971
6990
  }
6991
+ function localToolchainStatusLabel(status) {
6992
+ if (status === "installed")
6993
+ return "installed/已安装";
6994
+ if (status === "available")
6995
+ return "available/可安装";
6996
+ if (status === "update_available")
6997
+ return "update_available/可更新";
6998
+ if (status === "unsupported_host")
6999
+ return "unsupported_host/当前系统暂不支持";
7000
+ return status;
7001
+ }
7002
+ function localToolchainComponentSummary(components) {
7003
+ const totalBytes = components.reduce((total, component) => total + component.size_bytes, 0);
7004
+ return `${components.length} packages, ${formatByteSize(totalBytes)}`;
7005
+ }
7006
+ function localToolchainComponentGroups(components) {
7007
+ const groups = new Set();
7008
+ for (const component of components) {
7009
+ const text = `${component.id} ${component.role ?? ""}`.toLowerCase();
7010
+ if (text.includes("llvm") || text.includes("compiler"))
7011
+ groups.add("compiler/编译器包装");
7012
+ if (text.includes("sysroot") || text.includes("cross"))
7013
+ groups.add("sysroot/交叉运行库");
7014
+ if (text.includes("qt"))
7015
+ groups.add("qt/Qt 应用支持");
7016
+ if (text.includes("rockchip") || text.includes("boot") || text.includes("resource"))
7017
+ groups.add("boot-flash/启动与烧写工具");
7018
+ if (text.includes("image") || text.includes("rootfs"))
7019
+ groups.add("images/镜像资源");
7020
+ if (text.includes("rp2350") || text.includes("pico"))
7021
+ groups.add("rp2350/Pico2 监控工具");
7022
+ if (text.includes("meta"))
7023
+ groups.add("metadata/知识与脚本元数据");
7024
+ }
7025
+ return groups.size > 0 ? [...groups] : ["runtime/运行时工具"];
7026
+ }
7027
+ function formatByteSize(bytes) {
7028
+ if (!Number.isFinite(bytes) || bytes < 0) {
7029
+ return "unknown size";
7030
+ }
7031
+ const units = ["B", "KB", "MB", "GB", "TB"];
7032
+ let value = bytes;
7033
+ let unit = 0;
7034
+ while (value >= 1024 && unit < units.length - 1) {
7035
+ value /= 1024;
7036
+ unit += 1;
7037
+ }
7038
+ const fixed = unit === 0 || value >= 10 ? value.toFixed(0) : value.toFixed(1);
7039
+ return `${fixed} ${units[unit]}`;
7040
+ }
6972
7041
  function renderLocalToolchainLatest(result) {
6973
7042
  const lines = [
6974
7043
  `board=${result.board_id}`,
@@ -7834,6 +7903,7 @@ Main workflow:
7834
7903
  embed agent run --prompt "验证开发板状态"
7835
7904
  5. Validate or use the local TaishanPi toolchain:
7836
7905
  embed local toolchain list
7906
+ embed local toolchain installed
7837
7907
  embed local toolchain latest
7838
7908
  embed local toolchain install
7839
7909
  embed local toolchain validate
@@ -7883,6 +7953,7 @@ Local hardware:
7883
7953
  embed tool call qml.runtime.status --input-json '{"host":"198.19.77.2","user":"root","port":18130}'
7884
7954
  embed device list
7885
7955
  embed local toolchain list
7956
+ embed local toolchain installed
7886
7957
  embed local toolchain latest
7887
7958
  embed local toolchain current
7888
7959
  embed local toolchain install
@@ -8092,11 +8163,12 @@ Usage:
8092
8163
  embed build image boot-logo --logo <local_image> [--account <account_id>] [--project <project_id>] [--board taishanpi] [--variant 1M-RK3566] [--kernel-logo <local_image>] [--rotate -90] [--scale 100] [--output <package.json>] [--json]
8093
8164
  embed image boot-logo compose --package <boot-logo-package.json> --base-image <boot.img|image.img> --output <image> [--manifest <manifest.json>] [--force] [--json]
8094
8165
  embed local toolchain list [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--install-root <path>] [--json]
8166
+ embed local toolchain installed [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--install-root <path>] [--json]
8095
8167
  embed local toolchain latest [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--json]
8096
8168
  embed local toolchain current [--install-root <path>] [--json]
8097
- embed local toolchain install [--board taishanpi-1m-rk3566] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--mode minimal|compile|qt|full|images] [--force] [--json]
8169
+ embed local toolchain install [--board taishanpi-1m-rk3566|pico2w-rp2350-monitor] [--channel stable] [--metadata-root <path>] [--source-url <tar.gz-url>|--source-release-root <path>] [--install-root <path>] [--mode minimal|runtime|compile|qt|firmware|full|images] [--force] [--json]
8098
8170
  Defaults to the production download channel at download.embedboard.com.
8099
- embed local toolchain validate [--release-root <path>] [--mode minimal|compile|qt|full|images] [--json]
8171
+ embed local toolchain validate [--board taishanpi-1m-rk3566|pico2w-rp2350-monitor] [--release-root <path>] [--mode minimal|runtime|compile|qt|firmware|full|images] [--json]
8100
8172
  embed local compile taishanpi --source <main.c|main.cpp> --output <artifact> [--release-root <path>] [--account <account_id>] [--json]
8101
8173
  embed local build qt-smoke --build-dir <dir> [--source <qt-smoke-dir>] [--release-root <path>] [--account <account_id>] [--json]
8102
8174
  embed debug tools [--json]