Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion packages/cli-box-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion packages/cli-box-electron-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
33 changes: 32 additions & 1 deletion packages/cli-box-skill/installer/shared.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand All @@ -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 = [];
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-box-skill/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Expand Down
Loading