@hmbown/minimax-cli 0.1.1

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.
Files changed (3) hide show
  1. package/cli.js +36 -0
  2. package/install.js +93 -0
  3. package/package.json +26 -0
package/cli.js ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI wrapper - executes the downloaded MiniMax binary.
4
+ */
5
+
6
+ const { spawn } = require("child_process");
7
+ const path = require("path");
8
+ const fs = require("fs");
9
+
10
+ const binDir = path.join(__dirname, "bin");
11
+ const binName = process.platform === "win32" ? "minimax.exe" : "minimax";
12
+ const binPath = path.join(binDir, binName);
13
+
14
+ // Check for override
15
+ const override = process.env.MINIMAX_CLI_PATH;
16
+ const effectivePath = override && fs.existsSync(override) ? override : binPath;
17
+
18
+ if (!fs.existsSync(effectivePath)) {
19
+ console.error("MiniMax CLI binary not found.");
20
+ console.error("Try reinstalling: npm install -g minimax-cli");
21
+ process.exit(1);
22
+ }
23
+
24
+ // Spawn the binary with all arguments
25
+ const child = spawn(effectivePath, process.argv.slice(2), {
26
+ stdio: "inherit",
27
+ });
28
+
29
+ child.on("error", (err) => {
30
+ console.error("Failed to start MiniMax CLI:", err.message);
31
+ process.exit(1);
32
+ });
33
+
34
+ child.on("exit", (code) => {
35
+ process.exit(code ?? 0);
36
+ });
package/install.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Postinstall script - downloads the MiniMax CLI binary for the current platform.
4
+ */
5
+
6
+ const https = require("https");
7
+ const fs = require("fs");
8
+ const path = require("path");
9
+ const { execSync } = require("child_process");
10
+
11
+ const VERSION = "0.1.0";
12
+ const REPO = "Hmbown/MiniMax-CLI";
13
+
14
+ const PLATFORMS = {
15
+ "linux-x64": "minimax-linux-x64",
16
+ "darwin-arm64": "minimax-macos-arm64",
17
+ "darwin-x64": "minimax-macos-x64",
18
+ "win32-x64": "minimax-windows-x64.exe",
19
+ };
20
+
21
+ async function main() {
22
+ const platform = `${process.platform}-${process.arch}`;
23
+ const assetName = PLATFORMS[platform];
24
+
25
+ if (!assetName) {
26
+ console.error(`Unsupported platform: ${platform}`);
27
+ console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
28
+ process.exit(1);
29
+ }
30
+
31
+ const binDir = path.join(__dirname, "bin");
32
+ const binName = process.platform === "win32" ? "minimax.exe" : "minimax";
33
+ const binPath = path.join(binDir, binName);
34
+
35
+ // Skip if already exists
36
+ if (fs.existsSync(binPath)) {
37
+ console.log(`MiniMax CLI already installed at ${binPath}`);
38
+ return;
39
+ }
40
+
41
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${assetName}`;
42
+ console.log(`Downloading MiniMax CLI v${VERSION}...`);
43
+
44
+ fs.mkdirSync(binDir, { recursive: true });
45
+
46
+ await download(url, binPath);
47
+
48
+ // Make executable on Unix
49
+ if (process.platform !== "win32") {
50
+ fs.chmodSync(binPath, 0o755);
51
+ }
52
+
53
+ console.log(`Installed MiniMax CLI to ${binPath}`);
54
+ }
55
+
56
+ function download(url, dest) {
57
+ return new Promise((resolve, reject) => {
58
+ const file = fs.createWriteStream(dest);
59
+
60
+ function doRequest(requestUrl) {
61
+ https
62
+ .get(requestUrl, (response) => {
63
+ // Handle redirects
64
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
65
+ doRequest(response.headers.location);
66
+ return;
67
+ }
68
+
69
+ if (response.statusCode !== 200) {
70
+ reject(new Error(`Download failed: HTTP ${response.statusCode}`));
71
+ return;
72
+ }
73
+
74
+ response.pipe(file);
75
+ file.on("finish", () => {
76
+ file.close();
77
+ resolve();
78
+ });
79
+ })
80
+ .on("error", (err) => {
81
+ fs.unlink(dest, () => {});
82
+ reject(err);
83
+ });
84
+ }
85
+
86
+ doRequest(url);
87
+ });
88
+ }
89
+
90
+ main().catch((err) => {
91
+ console.error("Failed to install MiniMax CLI:", err.message);
92
+ process.exit(1);
93
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@hmbown/minimax-cli",
3
+ "version": "0.1.1",
4
+ "description": "Unofficial MiniMax CLI - downloads and runs the Rust binary",
5
+ "keywords": ["minimax", "cli", "ai", "agent", "m2.1"],
6
+ "homepage": "https://github.com/Hmbown/MiniMax-CLI",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Hmbown/MiniMax-CLI.git"
10
+ },
11
+ "license": "MIT",
12
+ "author": "Hmbown",
13
+ "bin": {
14
+ "minimax": "./cli.js"
15
+ },
16
+ "scripts": {
17
+ "postinstall": "node install.js"
18
+ },
19
+ "files": [
20
+ "cli.js",
21
+ "install.js"
22
+ ],
23
+ "engines": {
24
+ "node": ">=16"
25
+ }
26
+ }