codecane 1.0.398 → 1.0.399
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/index.js +51 -0
- package/package.json +12 -22
- package/scripts/codebuff-wrapper.js +0 -39
- package/scripts/install.js +0 -142
package/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Runtime loader – picks the platform package that npm just installed.
|
|
4
|
+
const { spawn } = require('child_process')
|
|
5
|
+
|
|
6
|
+
const triples = {
|
|
7
|
+
'linux-x64': 'codebuff-linux-x64',
|
|
8
|
+
'linux-arm64': 'codebuff-linux-arm64',
|
|
9
|
+
'darwin-x64': 'codebuff-darwin-x64',
|
|
10
|
+
'darwin-arm64': 'codebuff-darwin-arm64',
|
|
11
|
+
'win32-x64': 'codebuff-win32-x64'
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const triplet = `${process.platform}-${process.arch}`
|
|
15
|
+
const packageName = triples[triplet]
|
|
16
|
+
|
|
17
|
+
if (!packageName) {
|
|
18
|
+
console.error(
|
|
19
|
+
`codebuff: unsupported platform (${triplet}). ` +
|
|
20
|
+
`If you're on an exotic CPU/OS, ping us on Discord: https://discord.com/invite/mcWTGjgTj3`
|
|
21
|
+
)
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Try to resolve the platform-specific package
|
|
27
|
+
const binaryName = process.platform === 'win32' ? 'codebuff.exe' : 'codebuff'
|
|
28
|
+
const binaryPath = require.resolve(`${packageName}/${binaryName}`)
|
|
29
|
+
|
|
30
|
+
// Execute the binary with all arguments passed through
|
|
31
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
32
|
+
stdio: 'inherit',
|
|
33
|
+
cwd: process.cwd()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
child.on('exit', (code) => {
|
|
37
|
+
process.exit(code || 0)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
child.on('error', (error) => {
|
|
41
|
+
console.error(`Failed to execute codebuff: ${error.message}`)
|
|
42
|
+
process.exit(1)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(
|
|
47
|
+
`codebuff: platform package not found (${packageName}). ` +
|
|
48
|
+
`This usually means the installation failed. Try reinstalling: npm install -g codebuff`
|
|
49
|
+
)
|
|
50
|
+
process.exit(1)
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codecane",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "AI
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"codecane": "
|
|
3
|
+
"version": "1.0.399",
|
|
4
|
+
"description": "AI coding agent",
|
|
5
|
+
"optionalDependencies": {
|
|
6
|
+
"codecane-linux-x64": "1.0.399",
|
|
7
|
+
"codecane-linux-arm64": "1.0.399",
|
|
8
|
+
"codecane-darwin-x64": "1.0.399",
|
|
9
|
+
"codecane-darwin-arm64": "1.0.399",
|
|
10
|
+
"codecane-win32-x64": "1.0.399"
|
|
8
11
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
12
|
+
"bin": {
|
|
13
|
+
"codecane": "index.js"
|
|
11
14
|
},
|
|
12
15
|
"files": [
|
|
13
|
-
"
|
|
14
|
-
"scripts/install.js",
|
|
15
|
-
"README.md"
|
|
16
|
-
],
|
|
17
|
-
"os": [
|
|
18
|
-
"darwin",
|
|
19
|
-
"linux",
|
|
20
|
-
"win32"
|
|
21
|
-
],
|
|
22
|
-
"cpu": [
|
|
23
|
-
"x64",
|
|
24
|
-
"arm64"
|
|
16
|
+
"index.js"
|
|
25
17
|
],
|
|
18
|
+
"license": "MIT",
|
|
26
19
|
"engines": {
|
|
27
20
|
"node": ">=16"
|
|
28
21
|
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"tar": "^6.2.0"
|
|
31
|
-
},
|
|
32
22
|
"repository": {
|
|
33
23
|
"type": "git",
|
|
34
24
|
"url": "https://github.com/CodebuffAI/codebuff-community.git"
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs')
|
|
4
|
-
const path = require('path')
|
|
5
|
-
const os = require('os')
|
|
6
|
-
const { spawn } = require('child_process')
|
|
7
|
-
|
|
8
|
-
const homeDir = os.homedir()
|
|
9
|
-
const manicodeDir = path.join(homeDir, '.config', 'manicode')
|
|
10
|
-
const binaryName = process.platform === 'win32' ? 'codebuff.exe' : 'codebuff'
|
|
11
|
-
const binaryPath = path.join(manicodeDir, binaryName)
|
|
12
|
-
|
|
13
|
-
// Check if binary exists
|
|
14
|
-
if (!fs.existsSync(binaryPath)) {
|
|
15
|
-
console.error(`❌ Codebuff binary not found at ${binaryPath}`)
|
|
16
|
-
console.error('Please reinstall codebuff: npm install -g codebuff')
|
|
17
|
-
process.exit(1)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Check if binary is executable (Unix only)
|
|
21
|
-
if (process.platform !== 'win32') {
|
|
22
|
-
try {
|
|
23
|
-
fs.accessSync(binaryPath, fs.constants.X_OK)
|
|
24
|
-
} catch (error) {
|
|
25
|
-
console.error(`❌ Codebuff binary is not executable: ${binaryPath}`)
|
|
26
|
-
console.error('Please reinstall codebuff: npm install -g codebuff')
|
|
27
|
-
process.exit(1)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Execute the binary with all arguments passed through
|
|
32
|
-
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
33
|
-
stdio: 'inherit',
|
|
34
|
-
cwd: process.cwd()
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
child.on('exit', (code) => {
|
|
38
|
-
process.exit(code || 0)
|
|
39
|
-
})
|
package/scripts/install.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
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
|
-
|
|
9
|
-
const https = require('https')
|
|
10
|
-
const fs = require('fs')
|
|
11
|
-
const path = require('path')
|
|
12
|
-
const os = require('os')
|
|
13
|
-
const { platform, arch } = process
|
|
14
|
-
const packageJson = require('../package.json')
|
|
15
|
-
const ver = packageJson.version
|
|
16
|
-
|
|
17
|
-
const targets = {
|
|
18
|
-
'linux-x64': 'codebuff-linux-x64.tar.gz',
|
|
19
|
-
'linux-arm64': 'codebuff-linux-arm64.tar.gz',
|
|
20
|
-
'darwin-x64': 'codebuff-darwin-x64.tar.gz',
|
|
21
|
-
'darwin-arm64': 'codebuff-darwin-arm64.tar.gz',
|
|
22
|
-
'win32-x64': 'codebuff-win32-x64.zip'
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const key = `${platform}-${arch}`
|
|
26
|
-
const file = targets[key]
|
|
27
|
-
|
|
28
|
-
if (!file) {
|
|
29
|
-
console.error(`❌ Unsupported platform: ${platform} ${arch}`)
|
|
30
|
-
console.error('Supported platforms:', Object.keys(targets).join(', '))
|
|
31
|
-
process.exit(1)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const url = `https://github.com/CodebuffAI/codebuff-community/releases/download/v${ver}/${file}`
|
|
35
|
-
const homeDir = os.homedir()
|
|
36
|
-
const manicodeDir = path.join(homeDir, '.config', 'manicode')
|
|
37
|
-
|
|
38
|
-
// Create .config/manicode directory
|
|
39
|
-
fs.mkdirSync(manicodeDir, { recursive: true })
|
|
40
|
-
|
|
41
|
-
console.log(`⬇️ Downloading ${file} from GitHub releases...`)
|
|
42
|
-
console.log(`📍 Installing to: ${manicodeDir}`)
|
|
43
|
-
|
|
44
|
-
const request = https.get(url, (res) => {
|
|
45
|
-
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
46
|
-
// Follow redirect
|
|
47
|
-
return https.get(res.headers.location, handleResponse)
|
|
48
|
-
}
|
|
49
|
-
handleResponse(res)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
request.on('error', (err) => {
|
|
53
|
-
console.error(`❌ Download failed: ${err.message}`)
|
|
54
|
-
process.exit(1)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
function handleResponse(res) {
|
|
58
|
-
if (res.statusCode !== 200) {
|
|
59
|
-
console.error(`❌ Download failed: HTTP ${res.statusCode}`)
|
|
60
|
-
console.error(`URL: ${url}`)
|
|
61
|
-
process.exit(1)
|
|
62
|
-
}
|
|
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
|
-
|
|
91
|
-
if (file.endsWith('.zip')) {
|
|
92
|
-
// Handle zip files (Windows)
|
|
93
|
-
const zipPath = path.join(manicodeDir, file)
|
|
94
|
-
const writeStream = fs.createWriteStream(zipPath)
|
|
95
|
-
|
|
96
|
-
res.pipe(writeStream)
|
|
97
|
-
|
|
98
|
-
writeStream.on('finish', () => {
|
|
99
|
-
process.stderr.write('\n') // New line after progress
|
|
100
|
-
console.log('📦 Extracting...')
|
|
101
|
-
// Extract zip file
|
|
102
|
-
const { execSync } = require('child_process')
|
|
103
|
-
try {
|
|
104
|
-
execSync(`cd "${manicodeDir}" && unzip -o "${file}"`, { stdio: 'inherit' })
|
|
105
|
-
fs.unlinkSync(zipPath) // Clean up zip file
|
|
106
|
-
console.log('✅ codebuff installed successfully!')
|
|
107
|
-
} catch (error) {
|
|
108
|
-
console.error('❌ Failed to extract zip:', error.message)
|
|
109
|
-
process.exit(1)
|
|
110
|
-
}
|
|
111
|
-
})
|
|
112
|
-
} else {
|
|
113
|
-
// Handle tar.gz files (Unix)
|
|
114
|
-
const zlib = require('zlib')
|
|
115
|
-
const tar = require('tar')
|
|
116
|
-
|
|
117
|
-
res.pipe(zlib.createGunzip())
|
|
118
|
-
.pipe(tar.extract({ cwd: manicodeDir }))
|
|
119
|
-
.on('finish', () => {
|
|
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)
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
.on('error', (err) => {
|
|
138
|
-
console.error(`❌ Extraction failed: ${err.message}`)
|
|
139
|
-
process.exit(1)
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
}
|