abyss-cli 1.0.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/bin/abyss ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+
8
+ // Determine binary name based on platform
9
+ const platform = os.platform();
10
+ const ext = platform === 'win32' ? '.exe' : '';
11
+ const binName = `abyss${ext}`;
12
+
13
+ // Path to downloaded binary
14
+ const binPath = path.join(__dirname, '..', 'bin', binName);
15
+
16
+ if (!fs.existsSync(binPath)) {
17
+ console.error('\x1b[31mError: Abyss binary not found.\x1b[0m');
18
+ console.error(`Expected at: ${binPath}`);
19
+ console.error('Try running "npm install" again to trigger the postinstall script.');
20
+ process.exit(1);
21
+ }
22
+
23
+ // Spawn the binary, passing all arguments
24
+ const child = spawn(binPath, process.argv.slice(2), {
25
+ stdio: 'inherit',
26
+ env: process.env
27
+ });
28
+
29
+ child.on('close', (code) => {
30
+ process.exit(code);
31
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "abyss-cli",
3
+ "version": "1.0.0",
4
+ "description": "High-performance repository packer for LLM context generation (Proprietary)",
5
+ "bin": {
6
+ "abyss": "bin/abyss"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node scripts/install.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/kj/abyss.git"
14
+ },
15
+ "author": "KJ",
16
+ "license": "Proprietary",
17
+ "os": [
18
+ "darwin",
19
+ "linux",
20
+ "win32"
21
+ ],
22
+ "cpu": [
23
+ "x64",
24
+ "arm64"
25
+ ]
26
+ }
@@ -0,0 +1,132 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+ const os = require('os');
5
+ const { execSync } = require('child_process');
6
+
7
+ const VERSION = '1.0.0'; // Must match Cargo.toml
8
+ const BIN_NAME = 'abyss';
9
+ const REPO = 'kj/abyss';
10
+
11
+ // Map Node.js platform/arch to Rust targets
12
+ const PLATFORM_MAP = {
13
+ 'darwin': {
14
+ 'x64': 'x86_64-apple-darwin',
15
+ 'arm64': 'aarch64-apple-darwin'
16
+ },
17
+ 'linux': {
18
+ 'x64': 'x86_64-unknown-linux-gnu',
19
+ 'arm64': 'aarch64-unknown-linux-gnu'
20
+ },
21
+ 'win32': {
22
+ 'x64': 'x86_64-pc-windows-msvc',
23
+ 'arm64': 'aarch64-pc-windows-msvc'
24
+ }
25
+ };
26
+
27
+ function getTarget() {
28
+ const platform = os.platform();
29
+ const arch = os.arch();
30
+
31
+ if (!PLATFORM_MAP[platform] || !PLATFORM_MAP[platform][arch]) {
32
+ throw new Error(`Unsupported platform: ${platform}-${arch}`);
33
+ }
34
+
35
+ return PLATFORM_MAP[platform][arch];
36
+ }
37
+
38
+ function install() {
39
+ const target = getTarget();
40
+ const platform = os.platform();
41
+ const ext = platform === 'win32' ? '.exe' : '';
42
+ const archiveExt = platform === 'win32' ? '.zip' : '.tar.gz';
43
+
44
+ // URL Structure: https://github.com/USER/REPO/releases/download/vVERSION/abyss-vVERSION-TARGET.tar.gz
45
+ const url = `https://github.com/${REPO}/releases/download/v${VERSION}/${BIN_NAME}-v${VERSION}-${target}${archiveExt}`;
46
+
47
+ const binDir = path.join(__dirname, '..', 'bin');
48
+ const destPath = path.join(binDir, `${BIN_NAME}${ext}`);
49
+
50
+ if (!fs.existsSync(binDir)) {
51
+ fs.mkdirSync(binDir, { recursive: true });
52
+ }
53
+
54
+ console.log(`\x1b[36mDownloading Abyss v${VERSION} for ${target}...\x1b[0m`);
55
+ console.log(`Source: ${url}`);
56
+
57
+ // 1. Download to temp file
58
+ const tempFile = path.join(os.tmpdir(), `abyss-${Date.now()}${archiveExt}`);
59
+ const file = fs.createWriteStream(tempFile);
60
+
61
+ https.get(url, (response) => {
62
+ if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
63
+ // Handle redirect (GitHub Releases always redirect)
64
+ https.get(response.headers.location, (redirectResponse) => {
65
+ pipeResponse(redirectResponse, file, tempFile, destPath, archiveExt);
66
+ });
67
+ return;
68
+ }
69
+ pipeResponse(response, file, tempFile, destPath, archiveExt);
70
+ }).on('error', (err) => {
71
+ console.error('\x1b[31mDownload failed:\x1b[0m', err.message);
72
+ process.exit(1);
73
+ });
74
+ }
75
+
76
+ function pipeResponse(response, file, tempFile, destPath, archiveExt) {
77
+ if (response.statusCode !== 200) {
78
+ console.error(`\x1b[31mFailed to download binary. Status Code: ${response.statusCode}\x1b[0m`);
79
+ process.exit(1);
80
+ }
81
+
82
+ response.pipe(file);
83
+
84
+ file.on('finish', () => {
85
+ file.close(() => {
86
+ extract(tempFile, destPath, archiveExt);
87
+ });
88
+ });
89
+ }
90
+
91
+ function extract(tempFile, destPath, archiveExt) {
92
+ console.log('\x1b[36mExtracting...\x1b[0m');
93
+ const binDir = path.dirname(destPath);
94
+
95
+ try {
96
+ if (archiveExt === '.zip') {
97
+ // Basic unzip for windows (requires PowerShell or similar, keeping generic for now)
98
+ // For strict zero-dep unzip in Node, we might need a library, but simplest is system command
99
+ execSync(`tar -xf "${tempFile}" -C "${binDir}"`); // tar handles zip in modern bsdtar/gnu tar
100
+ } else {
101
+ execSync(`tar -xzf "${tempFile}" -C "${binDir}"`);
102
+ }
103
+
104
+ // Cleanup
105
+ fs.unlinkSync(tempFile);
106
+
107
+ // Move/Rename if nested? Usually releases are flattened or in a folder.
108
+ // Assuming release contains generic 'abyss' binary at root of tarball.
109
+
110
+ // If binary is not at destPath, find it (sometimes artifacts are versioned folder)
111
+ // Check directory contents
112
+ const files = fs.readdirSync(binDir);
113
+ // Find the 'abyss' or 'abyss.exe' executable in generated folder
114
+ // Simplified: Assume strictly packed as binary only.
115
+
116
+ // Chmod
117
+ if (os.platform() !== 'win32') {
118
+ // In case it extracted to a different name, or just to be safe set all to executable
119
+ // but let's assume 'abyss' exists
120
+ if(fs.existsSync(destPath)) {
121
+ fs.chmodSync(destPath, 0o755);
122
+ }
123
+ }
124
+
125
+ console.log('\x1b[32mAbyss installed successfully!\x1b[0m');
126
+ } catch (e) {
127
+ console.error('\x1b[31mExtraction failed:\x1b[0m', e.message);
128
+ process.exit(1);
129
+ }
130
+ }
131
+
132
+ install();