codecane 1.0.395 → 1.0.397

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": "codecane",
3
- "version": "1.0.395",
3
+ "version": "1.0.397",
4
4
  "description": "AI dev assistant",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -9,9 +9,20 @@
9
9
  "scripts": {
10
10
  "postinstall": "node scripts/install.js"
11
11
  },
12
- "files": ["scripts/codebuff-wrapper.js", "scripts/install.js", "README.md"],
13
- "os": ["darwin", "linux", "win32"],
14
- "cpu": ["x64", "arm64"],
12
+ "files": [
13
+ "scripts/codebuff-wrapper.js",
14
+ "scripts/install.js",
15
+ "README.md"
16
+ ],
17
+ "os": [
18
+ "darwin",
19
+ "linux",
20
+ "win32"
21
+ ],
22
+ "cpu": [
23
+ "x64",
24
+ "arm64"
25
+ ],
15
26
  "engines": {
16
27
  "node": ">=16"
17
28
  },
@@ -6,7 +6,7 @@ const os = require('os')
6
6
  const { spawn } = require('child_process')
7
7
 
8
8
  const homeDir = os.homedir()
9
- const manicodeDir = path.join(homeDir, '.manicode')
9
+ const manicodeDir = path.join(homeDir, '.config', 'manicode')
10
10
  const binaryName = process.platform === 'win32' ? 'codebuff.exe' : 'codebuff'
11
11
  const binaryPath = path.join(manicodeDir, binaryName)
12
12
 
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // Force output to show even when npm suppresses stdout
4
+ const originalLog = console.log
5
+ console.log = (...args) => {
6
+ process.stderr.write(args.join(' ') + '\n')
7
+ }
8
+
3
9
  const https = require('https')
4
10
  const fs = require('fs')
5
11
  const path = require('path')
@@ -27,12 +33,13 @@ if (!file) {
27
33
 
28
34
  const url = `https://github.com/CodebuffAI/codebuff-community/releases/download/v${ver}/${file}`
29
35
  const homeDir = os.homedir()
30
- const manicodeDir = path.join(homeDir, '.manicode')
36
+ const manicodeDir = path.join(homeDir, '.config', 'manicode')
31
37
 
32
- // Create .manicode directory
38
+ // Create .config/manicode directory
33
39
  fs.mkdirSync(manicodeDir, { recursive: true })
34
40
 
35
41
  console.log(`⬇️ Downloading ${file} from GitHub releases...`)
42
+ console.log(`📍 Installing to: ${manicodeDir}`)
36
43
 
37
44
  const request = https.get(url, (res) => {
38
45
  if (res.statusCode === 302 || res.statusCode === 301) {
@@ -54,6 +61,33 @@ function handleResponse(res) {
54
61
  process.exit(1)
55
62
  }
56
63
 
64
+ const totalSize = parseInt(res.headers['content-length'] || '0', 10)
65
+ let downloadedSize = 0
66
+ let lastProgressTime = Date.now()
67
+
68
+ // Show progress for downloads
69
+ const showProgress = (downloaded, total) => {
70
+ const now = Date.now()
71
+ // Update progress every 100ms to avoid too frequent updates
72
+ if (now - lastProgressTime < 100 && downloaded < total) return
73
+ lastProgressTime = now
74
+
75
+ if (total > 0) {
76
+ const percentage = Math.round((downloaded / total) * 100)
77
+ const downloadedMB = (downloaded / 1024 / 1024).toFixed(1)
78
+ const totalMB = (total / 1024 / 1024).toFixed(1)
79
+ process.stderr.write(`\r📥 Downloaded ${downloadedMB}MB / ${totalMB}MB (${percentage}%)`)
80
+ } else {
81
+ const downloadedMB = (downloaded / 1024 / 1024).toFixed(1)
82
+ process.stderr.write(`\r📥 Downloaded ${downloadedMB}MB`)
83
+ }
84
+ }
85
+
86
+ res.on('data', (chunk) => {
87
+ downloadedSize += chunk.length
88
+ showProgress(downloadedSize, totalSize)
89
+ })
90
+
57
91
  if (file.endsWith('.zip')) {
58
92
  // Handle zip files (Windows)
59
93
  const zipPath = path.join(manicodeDir, file)
@@ -62,12 +96,14 @@ function handleResponse(res) {
62
96
  res.pipe(writeStream)
63
97
 
64
98
  writeStream.on('finish', () => {
99
+ process.stderr.write('\n') // New line after progress
100
+ console.log('📦 Extracting...')
65
101
  // Extract zip file
66
102
  const { execSync } = require('child_process')
67
103
  try {
68
104
  execSync(`cd "${manicodeDir}" && unzip -o "${file}"`, { stdio: 'inherit' })
69
105
  fs.unlinkSync(zipPath) // Clean up zip file
70
- console.log('✅ codebuff installed')
106
+ console.log('✅ codebuff installed successfully!')
71
107
  } catch (error) {
72
108
  console.error('❌ Failed to extract zip:', error.message)
73
109
  process.exit(1)
@@ -81,13 +117,22 @@ function handleResponse(res) {
81
117
  res.pipe(zlib.createGunzip())
82
118
  .pipe(tar.extract({ cwd: manicodeDir }))
83
119
  .on('finish', () => {
84
- // Make executable
85
- const binaryName = platform === 'win32' ? 'codebuff.exe' : 'codebuff'
86
- const binaryPath = path.join(manicodeDir, binaryName)
87
- if (fs.existsSync(binaryPath)) {
88
- fs.chmodSync(binaryPath, 0o755)
120
+ process.stderr.write('\n') // New line after progress
121
+ // The extracted binary will have the platform/arch in the name
122
+ const extractedBinaryName = file.replace('.tar.gz', '').replace('.zip', '')
123
+ const finalBinaryName = platform === 'win32' ? 'codebuff.exe' : 'codebuff'
124
+ const extractedBinaryPath = path.join(manicodeDir, extractedBinaryName)
125
+ const finalBinaryPath = path.join(manicodeDir, finalBinaryName)
126
+
127
+ if (fs.existsSync(extractedBinaryPath)) {
128
+ fs.chmodSync(extractedBinaryPath, 0o755)
129
+ // Rename to the standard name
130
+ fs.renameSync(extractedBinaryPath, finalBinaryPath)
131
+ console.log('✅ codebuff installed successfully!')
132
+ } else {
133
+ console.error(`❌ Binary not found at ${extractedBinaryPath}`)
134
+ process.exit(1)
89
135
  }
90
- console.log('✅ codebuff installed')
91
136
  })
92
137
  .on('error', (err) => {
93
138
  console.error(`❌ Extraction failed: ${err.message}`)