@beads/bd 0.43.0 → 0.44.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beads/bd",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Beads issue tracker - lightweight memory system for coding agents with native binary support",
5
5
  "main": "bin/bd.js",
6
6
  "bin": {
@@ -120,28 +120,53 @@ function extractTarGz(tarGzPath, destDir, binaryName) {
120
120
  }
121
121
  }
122
122
 
123
- // Extract zip file (for Windows)
124
- function extractZip(zipPath, destDir, binaryName) {
123
+ // Sleep helper for retry logic
124
+ function sleep(ms) {
125
+ return new Promise(resolve => setTimeout(resolve, ms));
126
+ }
127
+
128
+ // Extract zip file (for Windows) with retry logic
129
+ async function extractZip(zipPath, destDir, binaryName) {
125
130
  console.log(`Extracting ${zipPath}...`);
126
131
 
127
- try {
128
- // Use unzip command or powershell on Windows
129
- if (os.platform() === 'win32') {
130
- execSync(`powershell -command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
131
- } else {
132
- execSync(`unzip -o "${zipPath}" -d "${destDir}"`, { stdio: 'inherit' });
133
- }
132
+ const maxRetries = 5;
133
+ const baseDelayMs = 500;
134
134
 
135
- // The binary should now be in destDir
136
- const extractedBinary = path.join(destDir, binaryName);
135
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
136
+ try {
137
+ // Use unzip command or powershell on Windows
138
+ if (os.platform() === 'win32') {
139
+ execSync(`powershell -command "Expand-Archive -Path '${zipPath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
140
+ } else {
141
+ execSync(`unzip -o "${zipPath}" -d "${destDir}"`, { stdio: 'inherit' });
142
+ }
137
143
 
138
- if (!fs.existsSync(extractedBinary)) {
139
- throw new Error(`Binary not found after extraction: ${extractedBinary}`);
140
- }
144
+ // The binary should now be in destDir
145
+ const extractedBinary = path.join(destDir, binaryName);
141
146
 
142
- console.log(`Binary extracted to: ${extractedBinary}`);
143
- } catch (err) {
144
- throw new Error(`Failed to extract archive: ${err.message}`);
147
+ if (!fs.existsSync(extractedBinary)) {
148
+ throw new Error(`Binary not found after extraction: ${extractedBinary}`);
149
+ }
150
+
151
+ console.log(`Binary extracted to: ${extractedBinary}`);
152
+ return; // Success
153
+ } catch (err) {
154
+ const isFileLockError = err.message && (
155
+ err.message.includes('being used by another process') ||
156
+ err.message.includes('Access is denied') ||
157
+ err.message.includes('cannot access the file')
158
+ );
159
+
160
+ if (isFileLockError && attempt < maxRetries) {
161
+ const delayMs = baseDelayMs * Math.pow(2, attempt - 1);
162
+ console.log(`File may be locked (attempt ${attempt}/${maxRetries}). Retrying in ${delayMs}ms...`);
163
+ await sleep(delayMs);
164
+ } else if (attempt === maxRetries) {
165
+ throw new Error(`Failed to extract archive after ${maxRetries} attempts: ${err.message}`);
166
+ } else {
167
+ throw new Error(`Failed to extract archive: ${err.message}`);
168
+ }
169
+ }
145
170
  }
146
171
  }
147
172
 
@@ -175,7 +200,7 @@ async function install() {
175
200
 
176
201
  // Extract the archive based on platform
177
202
  if (platformName === 'windows') {
178
- extractZip(archivePath, binDir, binaryName);
203
+ await extractZip(archivePath, binDir, binaryName);
179
204
  } else {
180
205
  extractTarGz(archivePath, binDir, binaryName);
181
206
  }