@actionbookdev/cli 0.5.4 → 0.5.5

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
@@ -14,6 +14,16 @@ Or use directly with npx:
14
14
  npx @actionbookdev/cli search "airbnb search"
15
15
  ```
16
16
 
17
+ ## Platform Binaries
18
+
19
+ `@actionbookdev/cli` is the single public install package.
20
+ Platform-specific native binaries are shipped through internal optional dependencies
21
+ (`@actionbookdev/cli-*`), and npm automatically installs the matching package for
22
+ your OS/CPU.
23
+
24
+ If you install with `--omit=optional`, the native binary package may be skipped and
25
+ the CLI will not run until you reinstall without that flag.
26
+
17
27
  ## Quick Start
18
28
 
19
29
  ```bash
package/bin/actionbook.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Cross-platform CLI wrapper for actionbook
4
+ * Cross-platform CLI wrapper for actionbook.
5
5
  *
6
- * Detects the current platform and spawns the corresponding native Rust binary
7
- * from the same directory. Supports ACTIONBOOK_BINARY_PATH env var for development.
6
+ * Resolves the platform-specific binary package and spawns the native binary.
7
+ * Supports ACTIONBOOK_BINARY_PATH env var for development.
8
8
  */
9
9
 
10
10
  "use strict";
@@ -13,13 +13,13 @@ const { spawn } = require("child_process");
13
13
  const { existsSync, readFileSync } = require("fs");
14
14
  const path = require("path");
15
15
 
16
- const PLATFORMS = {
17
- "darwin-arm64": "actionbook-darwin-arm64",
18
- "darwin-x64": "actionbook-darwin-x64",
19
- "linux-x64": "actionbook-linux-x64",
20
- "linux-arm64": "actionbook-linux-arm64",
21
- "win32-x64": "actionbook-win32-x64.exe",
22
- "win32-arm64": "actionbook-win32-arm64.exe",
16
+ const PLATFORM_PACKAGES = {
17
+ "darwin-arm64": "@actionbookdev/cli-darwin-arm64",
18
+ "darwin-x64": "@actionbookdev/cli-darwin-x64",
19
+ "linux-x64": "@actionbookdev/cli-linux-x64-gnu",
20
+ "linux-arm64": "@actionbookdev/cli-linux-arm64-gnu",
21
+ "win32-x64": "@actionbookdev/cli-win32-x64",
22
+ "win32-arm64": "@actionbookdev/cli-win32-arm64",
23
23
  };
24
24
 
25
25
  function main() {
@@ -31,7 +31,7 @@ function main() {
31
31
  process.exit(0);
32
32
  }
33
33
 
34
- // Allow env var override for development
34
+ // Allow env var override for development.
35
35
  const envPath = process.env.ACTIONBOOK_BINARY_PATH;
36
36
  if (envPath) {
37
37
  run(envPath);
@@ -39,19 +39,52 @@ function main() {
39
39
  }
40
40
 
41
41
  const platformKey = `${process.platform}-${process.arch}`;
42
- const binaryName = PLATFORMS[platformKey];
42
+ const binaryPath = getBinaryPath(platformKey);
43
+ run(binaryPath);
44
+ }
45
+
46
+ function isVersionOnlyFlag(args) {
47
+ return args.length === 1 && (args[0] === "--version" || args[0] === "-V");
48
+ }
49
+
50
+ function getBinaryPath(platformKey) {
51
+ const packageName = PLATFORM_PACKAGES[platformKey];
43
52
 
44
- if (!binaryName) {
53
+ if (!packageName) {
45
54
  console.error(`Error: Unsupported platform: ${platformKey}`);
46
- console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
55
+ console.error(`Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}`);
47
56
  process.exit(1);
48
57
  }
49
58
 
50
- const binaryPath = path.join(__dirname, binaryName);
59
+ if (process.platform === "linux" && isLikelyMusl()) {
60
+ console.error(`Error: Unsupported libc for ${platformKey}`);
61
+ console.error("This release currently supports Linux glibc only.");
62
+ console.error("musl (for example Alpine Linux) is not supported yet.");
63
+ process.exit(1);
64
+ }
51
65
 
52
- if (!existsSync(binaryPath)) {
53
- console.error(`Error: No binary found for ${platformKey}`);
54
- console.error(`Expected: ${binaryPath}`);
66
+ const binaryName = process.platform === "win32" ? "actionbook.exe" : "actionbook";
67
+
68
+ try {
69
+ const packageDir = resolvePackageDir(packageName);
70
+ if (!packageDir) {
71
+ throw new Error("package not found");
72
+ }
73
+ const binaryPath = path.join(packageDir, "bin", binaryName);
74
+
75
+ if (!existsSync(binaryPath)) {
76
+ console.error(`Error: No binary found in ${packageName}`);
77
+ console.error(`Expected: ${binaryPath}`);
78
+ process.exit(1);
79
+ }
80
+
81
+ return binaryPath;
82
+ } catch {
83
+ console.error(`Error: Missing native package for ${platformKey}`);
84
+ console.error(`Expected package: ${packageName}`);
85
+ console.error("");
86
+ console.error("This usually happens when optional dependencies are skipped.");
87
+ console.error("Check if you installed with --omit=optional.");
55
88
  console.error("");
56
89
  console.error("Try reinstalling:");
57
90
  console.error(" npm install -g @actionbookdev/cli");
@@ -60,12 +93,40 @@ function main() {
60
93
  console.error(" cargo install actionbook");
61
94
  process.exit(1);
62
95
  }
96
+ }
63
97
 
64
- run(binaryPath);
98
+ function resolvePackageDir(packageName) {
99
+ try {
100
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
101
+ return path.dirname(packageJsonPath);
102
+ } catch {
103
+ // Fallback for workspace or non-hoisted layouts.
104
+ const unscoped = packageName.split("/")[1];
105
+ const packageDir = path.join(__dirname, "..", "..", unscoped);
106
+ const packageJsonPath = path.join(packageDir, "package.json");
107
+ if (existsSync(packageJsonPath)) {
108
+ return packageDir;
109
+ }
110
+ return null;
111
+ }
65
112
  }
66
113
 
67
- function isVersionOnlyFlag(args) {
68
- return args.length === 1 && (args[0] === "--version" || args[0] === "-V");
114
+ function isLikelyMusl() {
115
+ if (process.platform !== "linux") {
116
+ return false;
117
+ }
118
+
119
+ if (!process.report || typeof process.report.getReport !== "function") {
120
+ return false;
121
+ }
122
+
123
+ try {
124
+ const report = process.report.getReport();
125
+ const header = report && report.header ? report.header : {};
126
+ return !header.glibcVersionRuntime;
127
+ } catch {
128
+ return false;
129
+ }
69
130
  }
70
131
 
71
132
  function run(binaryPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actionbookdev/cli",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "CLI for Actionbook - Browser automation and action manuals for AI agents",
5
5
  "private": false,
6
6
  "bin": {
@@ -16,6 +16,14 @@
16
16
  "scripts": {
17
17
  "postinstall": "node scripts/postinstall.js"
18
18
  },
19
+ "optionalDependencies": {
20
+ "@actionbookdev/cli-darwin-arm64": "0.5.5",
21
+ "@actionbookdev/cli-darwin-x64": "0.5.5",
22
+ "@actionbookdev/cli-linux-x64-gnu": "0.5.5",
23
+ "@actionbookdev/cli-linux-arm64-gnu": "0.5.5",
24
+ "@actionbookdev/cli-win32-x64": "0.5.5",
25
+ "@actionbookdev/cli-win32-arm64": "0.5.5"
26
+ },
19
27
  "engines": {
20
28
  "node": ">=18"
21
29
  },
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Postinstall script for @actionbookdev/cli
4
+ * Postinstall script for @actionbookdev/cli.
5
5
  *
6
- * Ensures the platform binary has executable permissions.
7
- * (npm doesn't always preserve the execute bit)
6
+ * Ensures the installed platform binary keeps executable permissions.
8
7
  */
9
8
 
10
9
  "use strict";
@@ -12,25 +11,52 @@
12
11
  const fs = require("fs");
13
12
  const path = require("path");
14
13
 
15
- const binDir = path.join(__dirname, "..", "bin");
14
+ const PLATFORM_PACKAGES = {
15
+ "darwin-arm64": "@actionbookdev/cli-darwin-arm64",
16
+ "darwin-x64": "@actionbookdev/cli-darwin-x64",
17
+ "linux-x64": "@actionbookdev/cli-linux-x64-gnu",
18
+ "linux-arm64": "@actionbookdev/cli-linux-arm64-gnu",
19
+ "win32-x64": "@actionbookdev/cli-win32-x64",
20
+ "win32-arm64": "@actionbookdev/cli-win32-arm64",
21
+ };
16
22
 
17
- function getBinaryName() {
23
+ function getBinaryPath() {
18
24
  const platformKey = `${process.platform}-${process.arch}`;
19
- const map = {
20
- "darwin-arm64": "actionbook-darwin-arm64",
21
- "darwin-x64": "actionbook-darwin-x64",
22
- "linux-x64": "actionbook-linux-x64",
23
- "linux-arm64": "actionbook-linux-arm64",
24
- "win32-x64": "actionbook-win32-x64.exe",
25
- "win32-arm64": "actionbook-win32-arm64.exe",
26
- };
27
- return map[platformKey] || null;
25
+ const packageName = PLATFORM_PACKAGES[platformKey];
26
+
27
+ if (!packageName) {
28
+ return null;
29
+ }
30
+
31
+ const binaryName = process.platform === "win32" ? "actionbook.exe" : "actionbook";
32
+
33
+ const packageDir = resolvePackageDir(packageName);
34
+ if (!packageDir) {
35
+ return null;
36
+ }
37
+
38
+ return path.join(packageDir, "bin", binaryName);
28
39
  }
29
40
 
30
- const binaryName = getBinaryName();
31
- if (!binaryName) process.exit(0);
41
+ function resolvePackageDir(packageName) {
42
+ try {
43
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
44
+ return path.dirname(packageJsonPath);
45
+ } catch {
46
+ const unscoped = packageName.split("/")[1];
47
+ const packageDir = path.join(__dirname, "..", "..", unscoped);
48
+ const packageJsonPath = path.join(packageDir, "package.json");
49
+ if (fs.existsSync(packageJsonPath)) {
50
+ return packageDir;
51
+ }
52
+ return null;
53
+ }
54
+ }
32
55
 
33
- const binaryPath = path.join(binDir, binaryName);
56
+ const binaryPath = getBinaryPath();
57
+ if (!binaryPath) {
58
+ process.exit(0);
59
+ }
34
60
 
35
61
  if (fs.existsSync(binaryPath) && process.platform !== "win32") {
36
62
  fs.chmodSync(binaryPath, 0o755);
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file