codecane 1.0.407 → 1.0.409

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/index.js +23 -28
  2. package/package.json +2 -3
package/index.js CHANGED
@@ -27,7 +27,7 @@ const PLATFORM_TARGETS = {
27
27
  'linux-arm64': 'codebuff-linux-arm64.tar.gz',
28
28
  'darwin-x64': 'codebuff-darwin-x64.tar.gz',
29
29
  'darwin-arm64': 'codebuff-darwin-arm64.tar.gz',
30
- 'win32-x64': 'codebuff-win32-x64.zip',
30
+ 'win32-x64': 'codebuff-win32-x64.tar.gz',
31
31
  }
32
32
 
33
33
  // Terminal utilities
@@ -205,19 +205,8 @@ async function downloadBinary(version) {
205
205
 
206
206
  const buffer = Buffer.concat(chunks)
207
207
 
208
- if (fileName.endsWith('.zip')) {
209
- // Windows ZIP extraction
210
- const AdmZip = require('adm-zip')
211
- const zipPath = path.join(CONFIG.configDir, fileName)
212
-
213
- fs.writeFileSync(zipPath, buffer)
214
-
215
- const zip = new AdmZip(zipPath)
216
- zip.extractAllTo(CONFIG.configDir, true)
217
-
218
- fs.unlinkSync(zipPath)
219
- } else {
220
- // Unix tar.gz extraction
208
+ try {
209
+ // Unix tar.gz extraction for all platforms
221
210
  await new Promise((resolve, reject) => {
222
211
  const gunzip = zlib.createGunzip()
223
212
  const extract = tar.extract({ cwd: CONFIG.configDir })
@@ -226,23 +215,28 @@ async function downloadBinary(version) {
226
215
 
227
216
  gunzip.end(buffer)
228
217
  })
229
- }
230
218
 
231
- // Rename extracted binary to standard name
232
- const extractedName = fileName.replace(/\.(tar\.gz|zip)$/, '')
233
- const extractedPath = path.join(CONFIG.configDir, extractedName)
219
+ // Find the extracted binary - it should be named "codebuff" or "codebuff.exe"
220
+ const files = fs.readdirSync(CONFIG.configDir)
221
+ const extractedPath = path.join(CONFIG.configDir, CONFIG.binaryName)
234
222
 
235
- if (fs.existsSync(extractedPath)) {
236
- if (process.platform !== 'win32') {
237
- fs.chmodSync(extractedPath, 0o755)
223
+ if (fs.existsSync(extractedPath)) {
224
+ if (process.platform !== 'win32') {
225
+ fs.chmodSync(extractedPath, 0o755)
226
+ }
227
+ } else {
228
+ throw new Error(
229
+ `Binary not found after extraction. Expected: ${extractedPath}, Available files: ${files.join(', ')}`
230
+ )
238
231
  }
239
- fs.renameSync(extractedPath, CONFIG.binaryPath)
240
- } else {
241
- throw new Error(`Binary not found after extraction`)
242
- }
243
232
 
244
- // Clear the line after successful download
245
- term.clearLine()
233
+ // Clear the line after successful download
234
+ term.clearLine()
235
+ } catch (error) {
236
+ term.clearLine()
237
+ console.error(`Extraction failed: ${error.message}`)
238
+ process.exit(1)
239
+ }
246
240
  }
247
241
 
248
242
  async function ensureBinaryExists() {
@@ -286,7 +280,6 @@ async function checkForUpdates(runningProcess, exitListener) {
286
280
 
287
281
  if (compareVersions(currentVersion, latestVersion) < 0) {
288
282
  term.clearLine()
289
- console.log(`\nUpdate available: ${currentVersion} → ${latestVersion}`)
290
283
 
291
284
  // Remove the specific exit listener to prevent it from interfering with the update
292
285
  runningProcess.removeListener('exit', exitListener)
@@ -306,6 +299,8 @@ async function checkForUpdates(runningProcess, exitListener) {
306
299
  }, 5000)
307
300
  })
308
301
 
302
+ console.log(`Update available: ${currentVersion} → ${latestVersion}`)
303
+
309
304
  await downloadBinary(latestVersion)
310
305
 
311
306
  // Restart with new binary - this replaces the current process
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codecane",
3
- "version": "1.0.407",
3
+ "version": "1.0.409",
4
4
  "description": "AI coding agent",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -23,8 +23,7 @@
23
23
  "node": ">=16"
24
24
  },
25
25
  "dependencies": {
26
- "tar": "^6.2.0",
27
- "adm-zip": "^0.5.10"
26
+ "tar": "^6.2.0"
28
27
  },
29
28
  "repository": {
30
29
  "type": "git",