@ace3-memory/ace 3.0.5 → 3.0.7

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 (2) hide show
  1. package/download-binary.js +105 -103
  2. package/package.json +1 -1
@@ -2,14 +2,13 @@
2
2
  /**
3
3
  * ACE Binary Downloader (npm postinstall script)
4
4
  * Downloads platform-specific ACE binary from GitHub releases
5
- * Similar to how Claude Code, GitHub CLI, and other modern tools work
5
+ * Dynamically fetches latest release - no hardcoded versions
6
6
  */
7
7
 
8
8
  const https = require('https');
9
9
  const fs = require('fs');
10
10
  const path = require('path');
11
11
 
12
- const VERSION = process.env.ACE_VERSION || 'v3.0.4';
13
12
  const GITHUB_REPO = 'AdyBrooks46/AutonomousContextEngine';
14
13
  const BINARY_DIR = path.join(__dirname, 'bin');
15
14
 
@@ -18,131 +17,134 @@ const platform = process.platform;
18
17
  const arch = process.arch;
19
18
 
20
19
  // Map to binary names
21
- // Note: macOS Intel (x64) uses ARM64 binary via Rosetta 2
22
20
  const BINARY_MAP = {
23
21
  'darwin-arm64': 'ace-macos-arm64',
24
- 'darwin-x64': 'ace-macos-arm64', // Intel Macs use ARM64 via Rosetta 2
22
+ 'darwin-x64': 'ace-macos-x64',
25
23
  'linux-x64': 'ace-linux-x64',
26
24
  'win32-x64': 'ace-windows-x64.exe'
27
25
  };
28
26
 
29
- const platformKey = `${platform}-${arch}`;
30
- const binaryName = BINARY_MAP[platformKey];
31
-
32
- if (!binaryName) {
33
- console.error(`❌ Unsupported platform: ${platform} ${arch}`);
34
- console.error(`Supported platforms: macOS (Intel/Apple Silicon), Linux x64, Windows x64`);
35
- process.exit(1);
27
+ // Fetch latest release version from GitHub API
28
+ function getLatestVersion() {
29
+ return new Promise((resolve) => {
30
+ const options = {
31
+ hostname: 'api.github.com',
32
+ path: `/repos/${GITHUB_REPO}/releases/latest`,
33
+ headers: { 'User-Agent': 'ace-installer' }
34
+ };
35
+
36
+ https.get(options, (res) => {
37
+ let data = '';
38
+ res.on('data', chunk => data += chunk);
39
+ res.on('end', () => {
40
+ try {
41
+ const release = JSON.parse(data);
42
+ resolve(release.tag_name);
43
+ } catch {
44
+ resolve(null);
45
+ }
46
+ });
47
+ }).on('error', () => resolve(null));
48
+ });
36
49
  }
37
50
 
38
- // GitHub release URL
39
- const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/${VERSION}/${binaryName}`;
40
- const binaryPath = path.join(BINARY_DIR, 'ace' + (platform === 'win32' ? '.exe' : ''));
51
+ // Download file with redirect support
52
+ function downloadFile(url, destPath) {
53
+ return new Promise((resolve, reject) => {
54
+ const file = fs.createWriteStream(destPath);
55
+ let downloadedBytes = 0;
56
+ let totalBytes = 0;
41
57
 
42
- console.log(`\n📦 Installing ACE ${VERSION} for ${platform} ${arch}...`);
43
- console.log(`📥 Downloading: ${binaryName}`);
58
+ const handleResponse = (response) => {
59
+ if (response.statusCode === 302 || response.statusCode === 301) {
60
+ https.get(response.headers.location, handleResponse).on('error', reject);
61
+ return;
62
+ }
44
63
 
45
- // Create bin directory
46
- if (!fs.existsSync(BINARY_DIR)) {
47
- fs.mkdirSync(BINARY_DIR, { recursive: true });
48
- }
64
+ if (response.statusCode !== 200) {
65
+ reject(new Error(`HTTP ${response.statusCode}`));
66
+ return;
67
+ }
49
68
 
50
- // Download binary
51
- const file = fs.createWriteStream(binaryPath);
52
- let downloadedBytes = 0;
53
- let totalBytes = 0;
69
+ totalBytes = parseInt(response.headers['content-length'], 10);
54
70
 
55
- https.get(downloadUrl, (response) => {
56
- if (response.statusCode === 302 || response.statusCode === 301) {
57
- // Follow redirect
58
- https.get(response.headers.location, (redirectResponse) => {
59
- totalBytes = parseInt(redirectResponse.headers['content-length'], 10);
60
-
61
- redirectResponse.on('data', (chunk) => {
71
+ response.on('data', (chunk) => {
62
72
  downloadedBytes += chunk.length;
63
- const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
64
- process.stdout.write(`\r⏳ Progress: ${percent}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB / ${(totalBytes / 1024 / 1024).toFixed(1)}MB)`);
73
+ if (totalBytes > 0) {
74
+ const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
75
+ process.stdout.write(`\r⏳ Progress: ${percent}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB)`);
76
+ }
65
77
  });
66
78
 
67
- redirectResponse.pipe(file);
79
+ response.pipe(file);
68
80
 
69
81
  file.on('finish', () => {
70
82
  file.close(() => {
71
83
  process.stdout.write('\n');
72
- console.log('✅ Download complete');
73
-
74
- // Make executable (Unix-like systems)
75
- if (platform !== 'win32') {
76
- try {
77
- fs.chmodSync(binaryPath, 0o755);
78
- console.log('✅ Binary made executable');
79
- } catch (err) {
80
- console.error('⚠️ Could not make binary executable:', err.message);
81
- }
82
- }
83
-
84
- console.log(`✅ ACE installed successfully!`);
85
- console.log(`\n🚀 Quick start:`);
86
- console.log(` 1. ace login # Authenticate`);
87
- console.log(` 2. ace start # Start server`);
88
- console.log(` 3. ace status # Check status\n`);
84
+ resolve();
89
85
  });
90
86
  });
91
- }).on('error', (err) => {
92
- fs.unlinkSync(binaryPath);
93
- console.error(`\n❌ Download failed:`, err.message);
94
- process.exit(1);
95
- });
96
- } else if (response.statusCode === 200) {
97
- totalBytes = parseInt(response.headers['content-length'], 10);
98
-
99
- response.on('data', (chunk) => {
100
- downloadedBytes += chunk.length;
101
- const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
102
- process.stdout.write(`\r⏳ Progress: ${percent}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB / ${(totalBytes / 1024 / 1024).toFixed(1)}MB)`);
103
- });
104
-
105
- response.pipe(file);
106
-
107
- file.on('finish', () => {
108
- file.close(() => {
109
- process.stdout.write('\n');
110
- console.log('✅ Download complete');
111
-
112
- // Make executable (Unix-like systems)
113
- if (platform !== 'win32') {
114
- try {
115
- fs.chmodSync(binaryPath, 0o755);
116
- console.log('✅ Binary made executable');
117
- } catch (err) {
118
- console.error('⚠️ Could not make binary executable:', err.message);
119
- }
120
- }
87
+ };
121
88
 
122
- console.log(`✅ ACE installed successfully!`);
123
- console.log(`\n🚀 Quick start:`);
124
- console.log(` 1. ace login # Authenticate`);
125
- console.log(` 2. ace start # Start server`);
126
- console.log(` 3. ace status # Check status\n`);
127
- });
128
- });
129
- } else {
130
- console.error(`\n❌ Failed to download: HTTP ${response.statusCode}`);
131
- console.error(`URL: ${downloadUrl}`);
89
+ https.get(url, handleResponse).on('error', reject);
90
+ file.on('error', reject);
91
+ });
92
+ }
93
+
94
+ // Main installation
95
+ async function install() {
96
+ const platformKey = `${platform}-${arch}`;
97
+ const binaryName = BINARY_MAP[platformKey];
98
+
99
+ if (!binaryName) {
100
+ console.error(`❌ Unsupported platform: ${platform} ${arch}`);
101
+ console.error(`Supported: macOS (Intel/Apple Silicon), Linux x64, Windows x64`);
132
102
  process.exit(1);
133
103
  }
134
- }).on('error', (err) => {
135
- if (fs.existsSync(binaryPath)) {
136
- fs.unlinkSync(binaryPath);
104
+
105
+ // Get latest version from GitHub
106
+ console.log('\n📦 Checking for latest ACE release...');
107
+ const version = process.env.ACE_VERSION || await getLatestVersion();
108
+
109
+ if (!version) {
110
+ console.error('❌ Could not determine latest version from GitHub');
111
+ process.exit(1);
112
+ }
113
+
114
+ const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/${version}/${binaryName}`;
115
+ const binaryPath = path.join(BINARY_DIR, 'ace' + (platform === 'win32' ? '.exe' : ''));
116
+
117
+ console.log(`📦 Installing ACE ${version} for ${platform} ${arch}...`);
118
+ console.log(`📥 Downloading: ${binaryName}`);
119
+
120
+ // Create bin directory
121
+ if (!fs.existsSync(BINARY_DIR)) {
122
+ fs.mkdirSync(BINARY_DIR, { recursive: true });
137
123
  }
138
- console.error(`\n❌ Download failed:`, err.message);
139
- process.exit(1);
140
- });
141
124
 
142
- file.on('error', (err) => {
143
- if (fs.existsSync(binaryPath)) {
144
- fs.unlinkSync(binaryPath);
125
+ try {
126
+ await downloadFile(downloadUrl, binaryPath);
127
+ console.log('✅ Download complete');
128
+
129
+ // Make executable (Unix-like systems)
130
+ if (platform !== 'win32') {
131
+ fs.chmodSync(binaryPath, 0o755);
132
+ console.log('✅ Binary made executable');
133
+ }
134
+
135
+ console.log(`✅ ACE ${version} installed successfully!`);
136
+ console.log(`\n🚀 Quick start:`);
137
+ console.log(` 1. ace login # Authenticate`);
138
+ console.log(` 2. ace start # Start server`);
139
+ console.log(` 3. ace status # Check status\n`);
140
+ } catch (err) {
141
+ if (fs.existsSync(binaryPath)) {
142
+ fs.unlinkSync(binaryPath);
143
+ }
144
+ console.error(`\n❌ Failed to download: ${err.message}`);
145
+ console.error(`URL: ${downloadUrl}`);
146
+ process.exit(1);
145
147
  }
146
- console.error(`\n❌ File write error:`, err.message);
147
- process.exit(1);
148
- });
148
+ }
149
+
150
+ install();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ace3-memory/ace",
3
- "version": "3.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "Your Logbook for AI - persistent memory for ChatGPT, Claude, Gemini, and more",
5
5
  "main": "index.js",
6
6
  "bin": {