codecane 1.0.420-beta.13 → 1.0.420-beta.130

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 +15 -56
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -22,10 +22,9 @@ function createConfig(packageName) {
22
22
  configDir,
23
23
  binaryName,
24
24
  binaryPath: path.join(configDir, binaryName),
25
- githubRepo: 'CodebuffAI/codebuff-community',
25
+
26
26
  userAgent: `${packageName}-cli`,
27
27
  requestTimeout: 20000,
28
- isPrerelease: true, // codecane always looks for prereleases
29
28
  }
30
29
  }
31
30
 
@@ -70,13 +69,6 @@ function httpGet(url, options = {}) {
70
69
  },
71
70
  }
72
71
 
73
- // Add GitHub token if available
74
- const token = process.env.GITHUB_TOKEN
75
- if (token) {
76
- console.log('Using your GITHUB_TOKEN to download the latest version.')
77
- reqOptions.headers.Authorization = `Bearer ${token}`
78
- }
79
-
80
72
  const req = https.get(reqOptions, (res) => {
81
73
  if (res.statusCode === 302 || res.statusCode === 301) {
82
74
  return httpGet(new URL(res.headers.location, url).href, options)
@@ -98,44 +90,17 @@ function httpGet(url, options = {}) {
98
90
 
99
91
  async function getLatestVersion() {
100
92
  try {
93
+ // Use the direct /latest endpoint for stable releases
101
94
  const res = await httpGet(
102
- `https://github.com/${CONFIG.githubRepo}/releases.atom`
95
+ `https://registry.npmjs.org/${packageName}/latest`
103
96
  )
104
97
 
105
98
  if (res.statusCode !== 200) return null
106
99
 
107
100
  const body = await streamToString(res)
101
+ const packageData = JSON.parse(body)
108
102
 
109
- // Parse the Atom XML to extract releases
110
- const tagMatches = body.match(
111
- /<id>tag:github\.com,2008:Repository\/\d+\/([^<]+)<\/id>/g
112
- )
113
-
114
- if (!tagMatches) return null
115
-
116
- // Extract all version tags
117
- const versions = tagMatches
118
- .map((match) => {
119
- const tagMatch = match.match(
120
- /<id>tag:github\.com,2008:Repository\/\d+\/([^<]+)<\/id>/
121
- )
122
- return tagMatch ? tagMatch[1].replace(/^v/, '') : null
123
- })
124
- .filter(Boolean)
125
-
126
- if (versions.length === 0) return null
127
-
128
- // Filter versions based on whether we want prereleases or stable releases
129
- const filteredVersions = versions.filter((version) => {
130
- const isPrerelease = version.includes('-')
131
- return CONFIG.isPrerelease === isPrerelease
132
- })
133
-
134
- if (filteredVersions.length === 0) return null
135
-
136
- // Sort and return the latest version
137
- filteredVersions.sort(compareVersions)
138
- return filteredVersions[filteredVersions.length - 1]
103
+ return packageData.version || null
139
104
  } catch (error) {
140
105
  return null
141
106
  }
@@ -284,7 +249,9 @@ async function downloadBinary(version) {
284
249
  throw new Error(`Unsupported platform: ${process.platform} ${process.arch}`)
285
250
  }
286
251
 
287
- const downloadUrl = `https://github.com/${CONFIG.githubRepo}/releases/download/v${version}/${fileName}`
252
+ // For now, we get version info from npm but still download binaries from GitHub
253
+ // TODO: This assumes GitHub releases still exist with the same naming convention
254
+ const downloadUrl = `https://github.com/CodebuffAI/codebuff-community/releases/download/v${version}/${fileName}`
288
255
 
289
256
  // Ensure config directory exists
290
257
  fs.mkdirSync(CONFIG.configDir, { recursive: true })
@@ -413,14 +380,10 @@ async function checkForUpdates(runningProcess, exitListener) {
413
380
  await downloadBinary(latestVersion)
414
381
 
415
382
  // Restart with new binary - this replaces the current process
416
- const newChild = spawn(
417
- CONFIG.binaryPath,
418
- [packageName, ...process.argv.slice(2)],
419
- {
420
- stdio: 'inherit',
421
- detached: false,
422
- }
423
- )
383
+ const newChild = spawn(CONFIG.binaryPath, process.argv.slice(2), {
384
+ stdio: 'inherit',
385
+ detached: false,
386
+ })
424
387
 
425
388
  // Set up exit handler for the new process
426
389
  newChild.on('exit', (code) => {
@@ -448,13 +411,9 @@ async function main() {
448
411
  await ensureBinaryExists()
449
412
 
450
413
  // Start the binary with codecane argument
451
- const child = spawn(
452
- CONFIG.binaryPath,
453
- [packageName, ...process.argv.slice(2)],
454
- {
455
- stdio: 'inherit',
456
- }
457
- )
414
+ const child = spawn(CONFIG.binaryPath, process.argv.slice(2), {
415
+ stdio: 'inherit',
416
+ })
458
417
 
459
418
  // Store reference to the exit listener so we can remove it during updates
460
419
  const exitListener = (code) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codecane",
3
- "version": "1.0.420-beta.13",
3
+ "version": "1.0.420-beta.130",
4
4
  "description": "AI coding agent (staging)",
5
5
  "license": "MIT",
6
6
  "bin": {