bctx-bin 0.1.0

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/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # bctx-bin
2
+
3
+ Pre-built binaries for [bctx](https://bctx.dev) — context-aware execution runtime for LLM coding agents.
4
+
5
+ Installs `bctx` without requiring Rust.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install -g bctx-bin
11
+ ```
12
+
13
+ Or use once without installing:
14
+
15
+ ```sh
16
+ npx bctx-bin git log --oneline -20
17
+ ```
18
+
19
+ ## Platforms
20
+
21
+ | Platform | Arch | Notes |
22
+ |----------|------|-------|
23
+ | macOS | x86_64 / aarch64 | Intel + Apple Silicon |
24
+ | Linux | x86_64 / aarch64 | glibc (Ubuntu, Debian, Fedora) |
25
+ | Linux | x86_64 / aarch64 | musl (Alpine) |
26
+
27
+ ## Other install methods
28
+
29
+ ```sh
30
+ # Homebrew
31
+ brew tap better-ctx-org/bctx && brew install bctx
32
+
33
+ # curl installer
34
+ curl -fsSL https://bctx.dev/install.sh | sh
35
+
36
+ # From source
37
+ cargo install bctx
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ After install, `bctx` is available in your PATH:
43
+
44
+ ```sh
45
+ bctx init --agent claude # register MCP server with Claude Code
46
+ bctx git log --oneline -40 # compressed git log
47
+ bctx cargo test # compressed test output
48
+ bctx doctor # verify installation
49
+ ```
50
+
51
+ See the [full documentation](https://github.com/better-ctx-org/better-ctx#readme) for all commands and domains.
package/bin/bctx.js ADDED
@@ -0,0 +1,19 @@
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
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "bctx-bin",
3
+ "version": "0.1.0",
4
+ "description": "bctx — context-aware execution runtime for LLM coding agents. Pre-built binary, no Rust required.",
5
+ "bin": {
6
+ "bctx": "./bin/bctx.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node postinstall.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "postinstall.js",
14
+ "README.md"
15
+ ],
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/better-ctx-org/better-ctx",
22
+ "directory": "packages/bctx-bin"
23
+ },
24
+ "homepage": "https://bctx.dev",
25
+ "license": "MIT",
26
+ "keywords": [
27
+ "mcp",
28
+ "llm",
29
+ "claude",
30
+ "tokens",
31
+ "ai",
32
+ "compression",
33
+ "cli"
34
+ ]
35
+ }
package/postinstall.js ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const https = require('https');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+ const { execSync } = require('child_process');
8
+ const zlib = require('zlib');
9
+
10
+ const REPO = 'better-ctx-org/better-ctx';
11
+ const BIN_DIR = path.join(__dirname, 'bin');
12
+ const PKG = require('./package.json');
13
+ const VERSION = PKG.version;
14
+
15
+ function getTarget() {
16
+ const platform = process.platform;
17
+ const arch = process.arch;
18
+
19
+ if (platform === 'darwin') {
20
+ return arch === 'arm64'
21
+ ? 'aarch64-apple-darwin'
22
+ : 'x86_64-apple-darwin';
23
+ }
24
+ if (platform === 'linux') {
25
+ const isMusl = (() => {
26
+ try { return execSync('ldd --version 2>&1').toString().includes('musl'); }
27
+ catch { return false; }
28
+ })();
29
+ const suffix = isMusl ? 'musl' : 'gnu';
30
+ return arch === 'arm64'
31
+ ? `aarch64-unknown-linux-${suffix}`
32
+ : `x86_64-unknown-linux-${suffix}`;
33
+ }
34
+ throw new Error(`Unsupported platform: ${platform}`);
35
+ }
36
+
37
+ function fetch(url) {
38
+ return new Promise((resolve, reject) => {
39
+ https.get(url, { headers: { 'User-Agent': 'bctx-bin-postinstall' } }, res => {
40
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
41
+ return fetch(res.headers.location).then(resolve, reject);
42
+ }
43
+ const chunks = [];
44
+ res.on('data', c => chunks.push(c));
45
+ res.on('end', () => resolve(Buffer.concat(chunks)));
46
+ res.on('error', reject);
47
+ }).on('error', reject);
48
+ });
49
+ }
50
+
51
+ async function main() {
52
+ const target = getTarget();
53
+ const archive = `bctx-${VERSION}-${target}.tar.gz`;
54
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${archive}`;
55
+
56
+ console.log(`bctx-bin: downloading ${archive}...`);
57
+ const data = await fetch(url);
58
+
59
+ // Extract bctx binary from tar.gz using Node built-ins
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
+ });
77
+
78
+ const binPath = path.join(BIN_DIR, 'bctx');
79
+ if (fs.existsSync(binPath)) {
80
+ fs.chmodSync(binPath, 0o755);
81
+ console.log(`bctx-bin: installed bctx to ${binPath}`);
82
+ } else {
83
+ throw new Error(`Binary not found after extraction: ${binPath}`);
84
+ }
85
+ }
86
+
87
+ main().catch(err => {
88
+ console.error('bctx-bin postinstall failed:', err.message);
89
+ console.error('You can install manually: cargo install bctx');
90
+ // Non-fatal: do not fail npm install
91
+ });