bctx-bin 0.1.8 → 0.1.13

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/bin/bctx.js CHANGED
@@ -1,13 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
  const { execFileSync } = require('child_process');
4
+ const { existsSync } = require('fs');
4
5
  const path = require('path');
5
6
 
6
7
  const bin = path.join(
7
8
  __dirname,
8
- process.platform === 'win32' ? 'bctx.exe' : 'bctx'
9
+ process.platform === 'win32' ? 'bctx.exe' : 'bctx-native'
9
10
  );
10
11
 
12
+ if (!existsSync(bin)) {
13
+ process.stderr.write(
14
+ 'bctx: native binary not found.\n' +
15
+ 'The postinstall script may have failed (no GitHub release for this version).\n' +
16
+ 'Install from source instead:\n' +
17
+ ' cargo install bctx\n'
18
+ );
19
+ process.exit(1);
20
+ }
21
+
11
22
  try {
12
23
  execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
13
24
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bctx-bin",
3
- "version": "0.1.8",
3
+ "version": "0.1.13",
4
4
  "description": "bctx — context-aware execution runtime for LLM coding agents. Pre-built binary, no Rust required.",
5
5
  "bin": {
6
6
  "bctx": "bin/bctx.js"
@@ -22,7 +22,7 @@
22
22
  "directory": "packages/bctx-bin"
23
23
  },
24
24
  "homepage": "https://betterctx.com",
25
- "license": "MIT",
25
+ "license": "UNLICENSED",
26
26
  "keywords": [
27
27
  "mcp",
28
28
  "llm",
package/postinstall.js CHANGED
@@ -6,12 +6,13 @@ const fs = require('fs');
6
6
  const path = require('path');
7
7
  const { execSync } = require('child_process');
8
8
 
9
- const REPO = 'better-ctx-org/better-ctx';
9
+ const REPO = 'better-ctx-org/bctx-releases';
10
10
  const BIN_DIR = path.join(__dirname, 'bin');
11
11
  const PKG = require('./package.json');
12
12
  const VERSION = PKG.version;
13
13
  const IS_WINDOWS = process.platform === 'win32';
14
- const BIN_NAME = IS_WINDOWS ? 'bctx.exe' : 'bctx';
14
+ // The extracted binary is named bctx-native to avoid conflicting with bctx.js wrapper
15
+ const BIN_NAME = IS_WINDOWS ? 'bctx.exe' : 'bctx-native';
15
16
 
16
17
  function getTarget() {
17
18
  const platform = process.platform;
@@ -42,6 +43,10 @@ function fetch(url) {
42
43
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
43
44
  return fetch(res.headers.location).then(resolve, reject);
44
45
  }
46
+ if (res.statusCode !== 200) {
47
+ res.resume();
48
+ return reject(new Error(`HTTP ${res.statusCode} fetching ${url}`));
49
+ }
45
50
  const chunks = [];
46
51
  res.on('data', c => chunks.push(c));
47
52
  res.on('end', () => resolve(Buffer.concat(chunks)));
@@ -67,18 +72,26 @@ async function main() {
67
72
  try {
68
73
  execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: 'pipe' });
69
74
  } catch (e) {
75
+ fs.unlinkSync(tmp);
70
76
  throw new Error(`Failed to extract archive: ${e.message}`);
71
77
  }
72
78
  fs.unlinkSync(tmp);
73
79
 
80
+ // The tarball extracts a binary named 'bctx'; rename to 'bctx-native' so it
81
+ // doesn't conflict with the bctx.js wrapper script in the same directory.
82
+ const extractedPath = path.join(BIN_DIR, IS_WINDOWS ? 'bctx.exe' : 'bctx');
74
83
  const binPath = path.join(BIN_DIR, BIN_NAME);
84
+ if (!IS_WINDOWS && fs.existsSync(extractedPath) && extractedPath !== binPath) {
85
+ fs.renameSync(extractedPath, binPath);
86
+ }
87
+
75
88
  if (!fs.existsSync(binPath)) {
76
89
  throw new Error(`Binary not found after extraction: ${binPath}`);
77
90
  }
78
91
  if (!IS_WINDOWS) {
79
92
  fs.chmodSync(binPath, 0o755);
80
93
  }
81
- console.log(`bctx-bin: installed ${BIN_NAME} to ${binPath}`);
94
+ console.log(`bctx-bin: installed to ${binPath}`);
82
95
  }
83
96
 
84
97
  main().catch(err => {
package/bin/bctx DELETED
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- const { execFileSync } = require('child_process');
5
- const path = require('path');
6
-
7
- const bin = path.join(__dirname, process.platform === 'win32' ? 'bctx.exe' : 'bctx');
8
-
9
- if (!require('fs').existsSync(bin)) {
10
- console.error('bctx binary not found. Run: npm install bctx-bin');
11
- console.error('Or install from source: cargo install bctx');
12
- process.exit(1);
13
- }
14
-
15
- try {
16
- execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
17
- } catch (err) {
18
- process.exit(err.status ?? 1);
19
- }