bctx-bin 0.1.6 → 0.1.8
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 +15 -0
- package/package.json +2 -2
- package/postinstall.js +29 -28
package/bin/bctx.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const bin = path.join(
|
|
7
|
+
__dirname,
|
|
8
|
+
process.platform === 'win32' ? 'bctx.exe' : 'bctx'
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });
|
|
13
|
+
} catch (e) {
|
|
14
|
+
process.exit(e.status ?? 1);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bctx-bin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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"
|
package/postinstall.js
CHANGED
|
@@ -5,21 +5,20 @@ 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
|
+
const BIN_NAME = IS_WINDOWS ? 'bctx.exe' : 'bctx';
|
|
14
15
|
|
|
15
16
|
function getTarget() {
|
|
16
17
|
const platform = process.platform;
|
|
17
18
|
const arch = process.arch;
|
|
18
19
|
|
|
19
20
|
if (platform === 'darwin') {
|
|
20
|
-
return arch === 'arm64'
|
|
21
|
-
? 'aarch64-apple-darwin'
|
|
22
|
-
: 'x86_64-apple-darwin';
|
|
21
|
+
return arch === 'arm64' ? 'aarch64-apple-darwin' : 'x86_64-apple-darwin';
|
|
23
22
|
}
|
|
24
23
|
if (platform === 'linux') {
|
|
25
24
|
const isMusl = (() => {
|
|
@@ -31,6 +30,9 @@ function getTarget() {
|
|
|
31
30
|
? `aarch64-unknown-linux-${suffix}`
|
|
32
31
|
: `x86_64-unknown-linux-${suffix}`;
|
|
33
32
|
}
|
|
33
|
+
if (platform === 'win32') {
|
|
34
|
+
return 'x86_64-pc-windows-msvc';
|
|
35
|
+
}
|
|
34
36
|
throw new Error(`Unsupported platform: ${platform}`);
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -56,36 +58,35 @@ async function main() {
|
|
|
56
58
|
console.log(`bctx-bin: downloading ${archive}...`);
|
|
57
59
|
const data = await fetch(url);
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
const gunzip = zlib.createGunzip();
|
|
61
|
-
const extracted = [];
|
|
62
|
-
await new Promise((resolve, reject) => {
|
|
63
|
-
const { PassThrough } = require('stream');
|
|
64
|
-
// Write to temp file and use tar command
|
|
65
|
-
const tmp = path.join(BIN_DIR, archive);
|
|
66
|
-
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
67
|
-
fs.writeFileSync(tmp, data);
|
|
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
|
-
}
|
|
74
|
-
fs.unlinkSync(tmp);
|
|
75
|
-
resolve();
|
|
76
|
-
});
|
|
61
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
77
62
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
const tmp = path.join(BIN_DIR, archive);
|
|
64
|
+
fs.writeFileSync(tmp, data);
|
|
65
|
+
|
|
66
|
+
// tar is available on macOS, Linux, and Windows 10+ (built-in since 1803)
|
|
67
|
+
try {
|
|
68
|
+
execSync(`tar -xzf "${tmp}" -C "${BIN_DIR}"`, { stdio: 'pipe' });
|
|
69
|
+
} catch (e) {
|
|
70
|
+
throw new Error(`Failed to extract archive: ${e.message}`);
|
|
71
|
+
}
|
|
72
|
+
fs.unlinkSync(tmp);
|
|
73
|
+
|
|
74
|
+
const binPath = path.join(BIN_DIR, BIN_NAME);
|
|
75
|
+
if (!fs.existsSync(binPath)) {
|
|
83
76
|
throw new Error(`Binary not found after extraction: ${binPath}`);
|
|
84
77
|
}
|
|
78
|
+
if (!IS_WINDOWS) {
|
|
79
|
+
fs.chmodSync(binPath, 0o755);
|
|
80
|
+
}
|
|
81
|
+
console.log(`bctx-bin: installed ${BIN_NAME} to ${binPath}`);
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
main().catch(err => {
|
|
88
85
|
console.error('bctx-bin postinstall failed:', err.message);
|
|
89
|
-
|
|
86
|
+
if (IS_WINDOWS) {
|
|
87
|
+
console.error('Manual install: download bctx.exe from https://github.com/better-ctx-org/better-ctx/releases');
|
|
88
|
+
} else {
|
|
89
|
+
console.error('Manual install: cargo install bctx');
|
|
90
|
+
}
|
|
90
91
|
// Non-fatal: do not fail npm install
|
|
91
92
|
});
|