From 7da1a8fb13a02e198b3605c33579924989b19f76 Mon Sep 17 00:00:00 2001 From: ZN-Ice Date: Fri, 19 Jun 2026 16:30:18 +0800 Subject: [PATCH 1/3] chore(npm): sync package.json versions to 0.2.8 The release workflow updates versions during CI but doesn't commit the changes back. This syncs the local package.json files to match the published npm versions. --- packages/cli-box-darwin-arm64/package.json | 2 +- packages/cli-box-electron-darwin-arm64/package.json | 2 +- packages/cli-box-skill/package.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/cli-box-darwin-arm64/package.json b/packages/cli-box-darwin-arm64/package.json index c652f0a..1cd453e 100644 --- a/packages/cli-box-darwin-arm64/package.json +++ b/packages/cli-box-darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "cli-box-darwin-arm64", - "version": "0.2.1", + "version": "0.2.8", "description": "cli-box binaries for macOS arm64", "os": ["darwin"], "cpu": ["arm64"], diff --git a/packages/cli-box-electron-darwin-arm64/package.json b/packages/cli-box-electron-darwin-arm64/package.json index 5e5fa69..dc8b265 100644 --- a/packages/cli-box-electron-darwin-arm64/package.json +++ b/packages/cli-box-electron-darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "cli-box-electron-darwin-arm64", - "version": "0.2.1", + "version": "0.2.8", "description": "cli-box Electron app for macOS arm64", "os": ["darwin"], "cpu": ["arm64"], diff --git a/packages/cli-box-skill/package.json b/packages/cli-box-skill/package.json index 5d1b1da..aae7b2f 100644 --- a/packages/cli-box-skill/package.json +++ b/packages/cli-box-skill/package.json @@ -1,6 +1,6 @@ { "name": "cli-box-skill", - "version": "0.2.2", + "version": "0.2.8", "description": "macOS desktop automation sandbox for AI agents", "main": "postinstall.mjs", "bin": { @@ -12,8 +12,8 @@ "test": "node --test" }, "optionalDependencies": { - "cli-box-darwin-arm64": "0.2.1", - "cli-box-electron-darwin-arm64": "0.2.1" + "cli-box-darwin-arm64": "0.2.8", + "cli-box-electron-darwin-arm64": "0.2.8" }, "files": [ "skill/SKILL.md", From 2e50ace0d01289d294ee1b36d87520da08495a40 Mon Sep 17 00:00:00 2001 From: ZN-Ice Date: Fri, 19 Jun 2026 16:30:36 +0800 Subject: [PATCH 2/3] ci(release): auto-commit version changes after npm publish Adds a step to the release workflow that commits the updated package.json versions back to the repository after publishing to npm. This prevents version mismatch between local files and published packages. --- .github/workflows/release.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01baec5..ddcd1b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -197,3 +197,14 @@ jobs: npm publish ./packages/cli-box-darwin-arm64 --access public npm publish ./packages/cli-box-electron-darwin-arm64 --access public npm publish ./packages/cli-box-skill --access public + + - name: Commit version changes + if: github.event_name == 'release' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add packages/cli-box-darwin-arm64/package.json \ + packages/cli-box-electron-darwin-arm64/package.json \ + packages/cli-box-skill/package.json + git diff --cached --quiet || git commit -m "chore(npm): bump package versions to ${GITHUB_REF_NAME#v}" + git push From 47b0cffcb7bf9761edd42e528970d2605c814343 Mon Sep 17 00:00:00 2001 From: ZN-Ice Date: Fri, 19 Jun 2026 16:41:46 +0800 Subject: [PATCH 3/3] fix(skill): fallback to npmjs.org when platform package not found in user's registry When the user's npm registry (e.g., npmmirror.com) doesn't have the required platform package version due to mirror sync lag, the postinstall now falls back to installing from the official npmjs.org registry. This fixes the issue where users with Chinese mirror registries couldn't install cli-box-skill when new versions were just published. --- packages/cli-box-skill/installer/shared.mjs | 33 ++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/cli-box-skill/installer/shared.mjs b/packages/cli-box-skill/installer/shared.mjs index 824d2e8..e0a764a 100644 --- a/packages/cli-box-skill/installer/shared.mjs +++ b/packages/cli-box-skill/installer/shared.mjs @@ -3,6 +3,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import { execSync } from "node:child_process"; import { createRequire } from "node:module"; const require = createRequire(import.meta.url); @@ -114,6 +115,27 @@ export function installSkillToTargets(ids, { home = os.homedir(), content } = {} // Symlinks the platform-package binaries into ~/.cli-box/bin. // Never throws: returns { ok:false, reason } if the platform package is absent. +// Try to install a platform package from the official npmjs.org registry. +// This is a fallback when the user's configured registry (e.g., npmmirror) +// doesn't have the required version due to mirror sync lag. +function tryInstallFromOfficialRegistry(pkgName) { + try { + // Read the expected version from this package's optionalDependencies + const selfPkg = require.resolve("../package.json"); + const { optionalDependencies } = JSON.parse(fs.readFileSync(selfPkg, "utf8")); + const version = optionalDependencies?.[pkgName]; + if (!version) return false; + + execSync( + `npm install ${pkgName}@${version} --registry=https://registry.npmjs.org --no-save`, + { stdio: "ignore", timeout: 60_000 } + ); + return true; + } catch { + return false; + } +} + export function ensureBinaries({ home = os.homedir() } = {}) { const binDir = path.join(home, ".cli-box", "bin"); fs.mkdirSync(binDir, { recursive: true }); @@ -127,7 +149,16 @@ export function ensureBinaries({ home = os.homedir() } = {}) { try { pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`)); } catch { - return { ok: false, reason: `platform package ${pkgName} not found`, binDir }; + // Fallback: try installing from the official npmjs.org registry + if (tryInstallFromOfficialRegistry(pkgName)) { + try { + pkgDir = path.dirname(require.resolve(`${pkgName}/package.json`)); + } catch { + return { ok: false, reason: `platform package ${pkgName} not found (fallback failed)`, binDir }; + } + } else { + return { ok: false, reason: `platform package ${pkgName} not found`, binDir }; + } } const linked = [];