aixlab-skills 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -6,4 +6,7 @@ AixLab 自有数字资产平台的 Agent Skill 安装器。它通过浏览器设
6
6
  npx aixlab-skills add xhs-creator -g -y
7
7
  ```
8
8
 
9
- 本地联调可设置 `AIXLAB_SKILLS_HOST=http://localhost:8180`。生产环境默认连接 `https://www.aixc4d.com`。本目录只包含待发布的 npm 包源码;发布属于独立操作。
9
+ 本地联调可设置 `AIXLAB_SKILLS_HOST=http://localhost:8180`。生产环境默认连接 `https://www.aixc4d.com`。
10
+
11
+ 该安装器已作为公开 npm 包发布。账户、版本、发布、验证和交接流程见
12
+ [`docs/agent/runbooks/AixLab-Skills-npm发布与交接手册.md`](../../../docs/agent/runbooks/AixLab-Skills-npm发布与交接手册.md)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aixlab-skills",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Secure installer for owned AixLab agent Skills",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { createWriteStream } from "node:fs";
3
3
  import { chmod, mkdir, mkdtemp, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform, tmpdir } from "node:os";
5
- import { dirname, join } from "node:path";
5
+ import { dirname, join, win32 as win32Path } from "node:path";
6
6
  import { pipeline } from "node:stream/promises";
7
7
  import { spawn } from "node:child_process";
8
8
  import yauzl from "yauzl";
@@ -122,15 +122,21 @@ async function requestJson(host, path, { method = "GET", token, body, statuses =
122
122
  return { status: response.status, payload };
123
123
  }
124
124
 
125
- function openBrowser(url) {
126
- const command = platform() === "win32"
125
+ export function openBrowser(url, {
126
+ platformName = platform(),
127
+ spawnProcess = spawn,
128
+ } = {}) {
129
+ const command = platformName === "win32"
127
130
  ? ["explorer.exe", [url]]
128
- : platform() === "darwin"
131
+ : platformName === "darwin"
129
132
  ? ["open", [url]]
130
133
  : ["xdg-open", [url]];
131
134
 
132
135
  try {
133
- const child = spawn(command[0], command[1], { detached: true, stdio: "ignore" });
136
+ const child = spawnProcess(command[0], command[1], { detached: true, stdio: "ignore" });
137
+ child.once("error", () => {
138
+ // Printing the URL is sufficient when the desktop opener is unavailable.
139
+ });
134
140
  child.unref();
135
141
  } catch {
136
142
  // Printing the URL is sufficient when the desktop opener is unavailable.
@@ -383,9 +389,33 @@ export function installerArguments(skillRoot) {
383
389
  ];
384
390
  }
385
391
 
392
+ export function installerCommand(skillRoot, {
393
+ platformName = platform(),
394
+ nodeExecutable = process.execPath,
395
+ npmExecutable = process.env.npm_execpath,
396
+ } = {}) {
397
+ const arguments_ = installerArguments(skillRoot);
398
+
399
+ if (platformName !== "win32") {
400
+ return { executable: "npx", arguments: arguments_ };
401
+ }
402
+
403
+ if (typeof npmExecutable !== "string" || npmExecutable.trim() === "") {
404
+ throw new Error("Windows 安装需要通过 npm 或 npx 启动 aixlab-skills。");
405
+ }
406
+
407
+ return {
408
+ executable: nodeExecutable,
409
+ arguments: [
410
+ win32Path.join(win32Path.dirname(npmExecutable), "npx-cli.js"),
411
+ ...arguments_,
412
+ ],
413
+ };
414
+ }
415
+
386
416
  async function installSkill(skillRoot) {
387
- const executable = platform() === "win32" ? "npx.cmd" : "npx";
388
- const child = spawn(executable, installerArguments(skillRoot), {
417
+ const command = installerCommand(skillRoot);
418
+ const child = spawn(command.executable, command.arguments, {
389
419
  stdio: ["inherit", "pipe", "pipe"],
390
420
  windowsHide: true,
391
421
  });