@mandors/cli 0.0.1 → 0.0.3

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/.eslintrc.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "env": {
3
+ "node": true,
4
+ "es2022": true
5
+ },
6
+ "parserOptions": {
7
+ "ecmaVersion": "latest",
8
+ "sourceType": "module"
9
+ },
10
+ "rules": {
11
+ "no-unused-vars": "warn",
12
+ "no-console": "off"
13
+ }
14
+ }
Binary file
Binary file
Binary file
Binary file
@@ -7,10 +7,14 @@
7
7
  const { downloadBinary, getCurrentPlatform } = require('./download');
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
+ const os = require('os');
10
11
 
11
12
  /** @type {string} Cache directory for binaries */
12
13
  const CACHE_DIR = path.join(__dirname, '..', '.cache');
13
14
 
15
+ /** @type {string} Bundled binaries directory */
16
+ const BUNDLE_DIR = path.join(__dirname, '..', 'binaries');
17
+
14
18
  /**
15
19
  * Installs the Mandor binary for the current platform
16
20
  * @async
@@ -28,12 +32,56 @@ async function install(options = {}) {
28
32
 
29
33
  console.log(`Installing Mandor ${version} for ${platform}-${arch}...`);
30
34
 
31
- const binaryPath = await downloadBinary(version, platform, arch);
35
+ let binaryPath;
36
+
37
+ // Try bundled binary first
38
+ const bundledPath = useBundledBinary(platform, arch);
39
+ if (bundledPath) {
40
+ console.log(`✓ Using bundled binary`);
41
+ binaryPath = bundledPath;
42
+ } else {
43
+ // Download from GitHub releases
44
+ binaryPath = await downloadBinary(version, platform, arch);
45
+ }
46
+
32
47
  console.log(`✓ Mandor installed: ${binaryPath}`);
33
48
 
34
49
  return binaryPath;
35
50
  }
36
51
 
52
+ /**
53
+ * Uses bundled binary if available for current platform
54
+ * @param {string} platform - Target platform
55
+ * @param {string} arch - Target architecture
56
+ * @returns {string|null} Path to binary or null if not bundled
57
+ */
58
+ function useBundledBinary(platform, arch) {
59
+ const filename = `mandor-${platform}-${arch}`;
60
+ const tarball = path.join(BUNDLE_DIR, `${filename}.tar.gz`);
61
+
62
+ if (!fs.existsSync(tarball)) {
63
+ return null;
64
+ }
65
+
66
+ // Extract to cache
67
+ const cacheDir = path.join(os.homedir(), '.mandor', 'bin');
68
+ if (!fs.existsSync(cacheDir)) {
69
+ fs.mkdirSync(cacheDir, { recursive: true });
70
+ }
71
+
72
+ const dest = path.join(cacheDir, filename);
73
+
74
+ // Extract tarball
75
+ const { execSync } = require('child_process');
76
+ try {
77
+ execSync(`tar -xzf "${tarball}" -C "${cacheDir}"`);
78
+ fs.chmodSync(dest, '755');
79
+ return dest;
80
+ } catch (e) {
81
+ return null;
82
+ }
83
+ }
84
+
37
85
  /**
38
86
  * Cleans up old binary caches
39
87
  * @returns {number} Number of files removed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mandors/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Event-based task manager CLI for AI agent workflows",
5
5
  "main": "npm/lib/index.js",
6
6
  "bin": {