@actionbookdev/cli 0.4.0-alpha.1 → 0.5.0

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actionbookdev/cli",
3
- "version": "0.4.0-alpha.1",
3
+ "version": "0.5.0",
4
4
  "description": "CLI for Actionbook - Browser automation and action manuals for AI agents",
5
5
  "private": false,
6
6
  "bin": {
@@ -3,20 +3,17 @@
3
3
  /**
4
4
  * Postinstall script for @actionbookdev/cli
5
5
  *
6
- * If the platform binary is missing (e.g., npm didn't include it),
7
- * downloads it from GitHub Releases as a fallback.
6
+ * Ensures the platform binary has executable permissions.
7
+ * (npm doesn't always preserve the execute bit)
8
8
  */
9
9
 
10
10
  "use strict";
11
11
 
12
12
  const fs = require("fs");
13
13
  const path = require("path");
14
- const https = require("https");
15
14
 
16
15
  const binDir = path.join(__dirname, "..", "bin");
17
16
 
18
- const GITHUB_REPO = "actionbook/actionbook";
19
-
20
17
  function getBinaryName() {
21
18
  const platformKey = `${process.platform}-${process.arch}`;
22
19
  const map = {
@@ -30,85 +27,11 @@ function getBinaryName() {
30
27
  return map[platformKey] || null;
31
28
  }
32
29
 
33
- function downloadFile(url, dest) {
34
- return new Promise((resolve, reject) => {
35
- const request = (url) => {
36
- https
37
- .get(url, (response) => {
38
- if (response.statusCode === 301 || response.statusCode === 302) {
39
- request(response.headers.location);
40
- return;
41
- }
42
- if (response.statusCode !== 200) {
43
- reject(new Error(`HTTP ${response.statusCode}`));
44
- return;
45
- }
46
- const file = fs.createWriteStream(dest);
47
- response.pipe(file);
48
- file.on("finish", () => {
49
- file.close();
50
- resolve();
51
- });
52
- file.on("error", (err) => {
53
- fs.unlinkSync(dest);
54
- reject(err);
55
- });
56
- })
57
- .on("error", reject);
58
- };
59
- request(url);
60
- });
61
- }
62
-
63
- async function main() {
64
- const binaryName = getBinaryName();
65
-
66
- if (!binaryName) {
67
- console.log(
68
- `⚠ Unsupported platform: ${process.platform}-${process.arch}. ` +
69
- "Install the Rust CLI directly: cargo install actionbook"
70
- );
71
- return;
72
- }
73
-
74
- const binaryPath = path.join(binDir, binaryName);
75
-
76
- // Binary already exists (shipped with npm package) — just fix permissions
77
- if (fs.existsSync(binaryPath)) {
78
- if (process.platform !== "win32") {
79
- fs.chmodSync(binaryPath, 0o755);
80
- }
81
- return;
82
- }
30
+ const binaryName = getBinaryName();
31
+ if (!binaryName) process.exit(0);
83
32
 
84
- // Fallback: download from GitHub Releases
85
- const packageJson = JSON.parse(
86
- fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf8")
87
- );
88
- const version = packageJson.version;
89
- const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/actionbook-cli-v${version}/${binaryName}`;
33
+ const binaryPath = path.join(binDir, binaryName);
90
34
 
91
- console.log(`Downloading actionbook binary for ${process.platform}-${process.arch}...`);
92
-
93
- try {
94
- if (!fs.existsSync(binDir)) {
95
- fs.mkdirSync(binDir, { recursive: true });
96
- }
97
-
98
- await downloadFile(downloadUrl, binaryPath);
99
-
100
- if (process.platform !== "win32") {
101
- fs.chmodSync(binaryPath, 0o755);
102
- }
103
-
104
- console.log(`✓ Downloaded: ${binaryName}`);
105
- } catch (err) {
106
- console.log(`⚠ Could not download binary: ${err.message}`);
107
- console.log("");
108
- console.log("To install manually:");
109
- console.log(" cargo install actionbook");
110
- console.log(" # or set ACTIONBOOK_BINARY_PATH env var");
111
- }
35
+ if (fs.existsSync(binaryPath) && process.platform !== "win32") {
36
+ fs.chmodSync(binaryPath, 0o755);
112
37
  }
113
-
114
- main().catch(console.error);