@hypernewbie/phi-code 0.5.4
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/phi +13 -0
- package/package.json +25 -0
- package/scripts/install.js +83 -0
package/bin/phi
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const binaryName = process.platform === 'win32' ? 'phi.exe' : 'phi';
|
|
6
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
7
|
+
|
|
8
|
+
const args = process.argv.slice(2);
|
|
9
|
+
const child = spawn(binaryPath, args, { stdio: 'inherit' });
|
|
10
|
+
|
|
11
|
+
child.on('close', (code) => {
|
|
12
|
+
process.exit(code);
|
|
13
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hypernewbie/phi-code",
|
|
3
|
+
"version": "0.5.4",
|
|
4
|
+
"description": "Terminal multiplexer & control center for AI coding assistants",
|
|
5
|
+
"bin": {
|
|
6
|
+
"phi": "./bin/phi"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/install.js"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/hypernewbie/phi.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"terminal",
|
|
17
|
+
"multiplexer",
|
|
18
|
+
"ai",
|
|
19
|
+
"opencode",
|
|
20
|
+
"claude",
|
|
21
|
+
"antigravity"
|
|
22
|
+
],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const https = require('https');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const version = require('../package.json').version;
|
|
7
|
+
const repo = 'hypernewbie/phi';
|
|
8
|
+
|
|
9
|
+
const platformMap = {
|
|
10
|
+
darwin: 'darwin',
|
|
11
|
+
linux: 'linux',
|
|
12
|
+
win32: 'windows'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const archMap = {
|
|
16
|
+
x64: 'amd64',
|
|
17
|
+
arm64: 'arm64'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const os = platformMap[process.platform];
|
|
21
|
+
const arch = archMap[process.arch];
|
|
22
|
+
|
|
23
|
+
if (!os || !arch) {
|
|
24
|
+
console.error(`Unsupported platform/architecture: ${process.platform}/${process.arch}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isWindows = process.platform === 'win32';
|
|
29
|
+
const ext = isWindows ? '.zip' : '.tar.gz';
|
|
30
|
+
const binaryName = isWindows ? 'phi.exe' : 'phi';
|
|
31
|
+
|
|
32
|
+
const assetName = `phi_${version}_${os}_${arch}${ext}`;
|
|
33
|
+
const downloadUrl = `https://github.com/${repo}/releases/download/v${version}/${assetName}`;
|
|
34
|
+
|
|
35
|
+
const binDir = path.join(__dirname, '../bin');
|
|
36
|
+
if (!fs.existsSync(binDir)) fs.mkdirSync(binDir);
|
|
37
|
+
|
|
38
|
+
const tempFile = path.join(binDir, `temp-${assetName}`);
|
|
39
|
+
|
|
40
|
+
console.log(`Downloading precompiled Phi binary from ${downloadUrl}...`);
|
|
41
|
+
|
|
42
|
+
function download(url, dest) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
https.get(url, (res) => {
|
|
45
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
46
|
+
download(res.headers.location, dest).then(resolve).catch(reject);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (res.statusCode !== 200) {
|
|
50
|
+
reject(new Error(`Failed to download binary: status code ${res.statusCode}`));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const file = fs.createWriteStream(dest);
|
|
54
|
+
res.pipe(file);
|
|
55
|
+
file.on('finish', () => {
|
|
56
|
+
file.close();
|
|
57
|
+
resolve();
|
|
58
|
+
});
|
|
59
|
+
}).on('error', (err) => {
|
|
60
|
+
reject(err);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
download(downloadUrl, tempFile)
|
|
66
|
+
.then(() => {
|
|
67
|
+
console.log('Extracting archive...');
|
|
68
|
+
const destBinaryPath = path.join(binDir, binaryName);
|
|
69
|
+
|
|
70
|
+
if (isWindows) {
|
|
71
|
+
execSync(`powershell -Command "Expand-Archive -Path '${tempFile}' -DestinationPath '${binDir}' -Force"`);
|
|
72
|
+
} else {
|
|
73
|
+
execSync(`tar -xzf "${tempFile}" -C "${binDir}"`);
|
|
74
|
+
fs.chmodSync(destBinaryPath, 0o755);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fs.unlinkSync(tempFile);
|
|
78
|
+
console.log('Phi binary successfully installed!');
|
|
79
|
+
})
|
|
80
|
+
.catch((err) => {
|
|
81
|
+
console.error('Failed to install Phi binary:', err);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|