bctx-bin 0.1.7 → 0.1.12
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 +26 -0
- package/package.json +3 -3
- package/postinstall.js +41 -27
- package/bin/bctx +0 -19
package/bin/bctx.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const { existsSync } = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const bin = path.join(
|
|
8
|
+
__dirname,
|
|
9
|
+
process.platform === 'win32' ? 'bctx.exe' : 'bctx-native'
|
|
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
|
+
|
|
22
|
+
try {
|
|
23
|
+
execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
24
|
+
} catch (e) {
|
|
25
|
+
process.exit(e.status ?? 1);
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bctx-bin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "bctx — context-aware execution runtime for LLM coding agents. Pre-built binary, no Rust required.",
|
|
5
5
|
"bin": {
|
|
6
|
-
"bctx": "bin/bctx"
|
|
6
|
+
"bctx": "bin/bctx.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
9
|
"postinstall": "node postinstall.js"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"directory": "packages/bctx-bin"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://betterctx.com",
|
|
25
|
-
"license": "
|
|
25
|
+
"license": "UNLICENSED",
|
|
26
26
|
"keywords": [
|
|
27
27
|
"mcp",
|
|
28
28
|
"llm",
|
package/postinstall.js
CHANGED
|
@@ -5,21 +5,21 @@ const https = require('https');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const { execSync } = require('child_process');
|
|
8
|
-
const zlib = require('zlib');
|
|
9
8
|
|
|
10
9
|
const REPO = 'better-ctx-org/better-ctx';
|
|
11
10
|
const BIN_DIR = path.join(__dirname, 'bin');
|
|
12
11
|
const PKG = require('./package.json');
|
|
13
12
|
const VERSION = PKG.version;
|
|
13
|
+
const IS_WINDOWS = process.platform === 'win32';
|
|
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';
|
|
14
16
|
|
|
15
17
|
function getTarget() {
|
|
16
18
|
const platform = process.platform;
|
|
17
19
|
const arch = process.arch;
|
|
18
20
|
|
|
19
21
|
if (platform === 'darwin') {
|
|
20
|
-
return arch === 'arm64'
|
|
21
|
-
? 'aarch64-apple-darwin'
|
|
22
|
-
: 'x86_64-apple-darwin';
|
|
22
|
+
return arch === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin';
|
|
23
23
|
}
|
|
24
24
|
if (platform === 'linux') {
|
|
25
25
|
const isMusl = (() => {
|
|
@@ -31,6 +31,9 @@ function getTarget() {
|
|
|
31
31
|
? `aarch64-unknown-linux-${suffix}`
|
|
32
32
|
: `x86_64-unknown-linux-${suffix}`;
|
|
33
33
|
}
|
|
34
|
+
if (platform === 'win32') {
|
|
35
|
+
return 'x86_64-pc-windows-msvc';
|
|
36
|
+
}
|
|
34
37
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -40,6 +43,10 @@ function fetch(url) {
|
|
|
40
43
|
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
41
44
|
return fetch(res.headers.location).then(resolve, reject);
|
|
42
45
|
}
|
|
46
|
+
if (res.statusCode !== 200) {
|
|
47
|
+
res.resume();
|
|
48
|
+
return reject(new Error(`HTTP ${res.statusCode} fetching ${url}`));
|
|
49
|
+
}
|
|
43
50
|
const chunks = [];
|
|
44
51
|
res.on('data', c => chunks.push(c));
|
|
45
52
|
res.on('end', () => resolve(Buffer.concat(chunks)));
|
|
@@ -56,36 +63,43 @@ async function main() {
|
|
|
56
63
|
console.log(`bctx-bin: downloading ${archive}...`);
|
|
57
64
|
const data = await fetch(url);
|
|
58
65
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}" bctx 2>/dev/null || tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: 'pipe' });
|
|
70
|
-
} catch {
|
|
71
|
-
// fallback: extract all
|
|
72
|
-
execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: 'pipe' });
|
|
73
|
-
}
|
|
66
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
67
|
+
|
|
68
|
+
const tmp = path.join(BIN_DIR, archive);
|
|
69
|
+
fs.writeFileSync(tmp, data);
|
|
70
|
+
|
|
71
|
+
// tar is available on macOS, Linux, and Windows 10+ (built-in since 1803)
|
|
72
|
+
try {
|
|
73
|
+
execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: 'pipe' });
|
|
74
|
+
} catch (e) {
|
|
74
75
|
fs.unlinkSync(tmp);
|
|
75
|
-
|
|
76
|
-
}
|
|
76
|
+
throw new Error(`Failed to extract archive: ${e.message}`);
|
|
77
|
+
}
|
|
78
|
+
fs.unlinkSync(tmp);
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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');
|
|
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
|
+
|
|
88
|
+
if (!fs.existsSync(binPath)) {
|
|
83
89
|
throw new Error(`Binary not found after extraction: ${binPath}`);
|
|
84
90
|
}
|
|
91
|
+
if (!IS_WINDOWS) {
|
|
92
|
+
fs.chmodSync(binPath, 0o755);
|
|
93
|
+
}
|
|
94
|
+
console.log(`bctx-bin: installed to ${binPath}`);
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
main().catch(err => {
|
|
88
98
|
console.error('bctx-bin postinstall failed:', err.message);
|
|
89
|
-
|
|
99
|
+
if (IS_WINDOWS) {
|
|
100
|
+
console.error('Manual install: download bctx.exe from https://github.com/better-ctx-org/better-ctx/releases');
|
|
101
|
+
} else {
|
|
102
|
+
console.error('Manual install: cargo install bctx');
|
|
103
|
+
}
|
|
90
104
|
// Non-fatal: do not fail npm install
|
|
91
105
|
});
|
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
|
-
}
|