@twsxtd/hapi 0.15.3 → 0.16.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/hapi.cjs +138 -26
- package/package.json +6 -6
package/bin/hapi.cjs
CHANGED
|
@@ -5,44 +5,156 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
const platform = process.platform;
|
|
7
7
|
const arch = process.arch;
|
|
8
|
-
const
|
|
8
|
+
const RELEASE_URL = 'https://github.com/tiann/hapi/releases';
|
|
9
|
+
const OFFICIAL_NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
10
|
+
const SUPPORTED_PLATFORMS = [
|
|
11
|
+
{
|
|
12
|
+
key: 'darwin-arm64',
|
|
13
|
+
label: 'darwin-arm64 (macOS Apple Silicon)',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
key: 'darwin-x64',
|
|
17
|
+
label: 'darwin-x64 (macOS Intel)',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
key: 'linux-arm64',
|
|
21
|
+
label: 'linux-arm64',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 'linux-x64',
|
|
25
|
+
label: 'linux-x64',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
key: 'win32-x64',
|
|
29
|
+
label: 'win32-x64',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function getPlatformKey(platformName = platform, archName = arch) {
|
|
34
|
+
return `${platformName}-${archName}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isSupportedPlatform(platformName = platform, archName = arch) {
|
|
38
|
+
return SUPPORTED_PLATFORMS.some((item) => item.key === getPlatformKey(platformName, archName));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function getBinaryPath(platformName = platform, archName = arch) {
|
|
42
|
+
const pkgName = `@twsxtd/hapi-${platformName}-${archName}`;
|
|
9
43
|
|
|
10
|
-
function getBinaryPath() {
|
|
11
44
|
try {
|
|
12
45
|
// Try to find the platform-specific package
|
|
13
46
|
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
14
|
-
const binName =
|
|
47
|
+
const binName = platformName === 'win32' ? 'hapi.exe' : 'hapi';
|
|
15
48
|
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
16
49
|
} catch (e) {
|
|
17
50
|
return null;
|
|
18
51
|
}
|
|
19
52
|
}
|
|
20
53
|
|
|
21
|
-
|
|
54
|
+
function formatCommand(binPath, args) {
|
|
55
|
+
return [binPath, ...args].map((arg) => JSON.stringify(String(arg))).join(' ');
|
|
56
|
+
}
|
|
22
57
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
console.error(' - linux-arm64');
|
|
30
|
-
console.error(' - linux-x64');
|
|
31
|
-
console.error(' - win32-x64');
|
|
32
|
-
console.error('');
|
|
33
|
-
console.error('You can download the binary manually from:');
|
|
34
|
-
console.error(' https://github.com/tiann/hapi/releases');
|
|
35
|
-
process.exit(1);
|
|
58
|
+
function normalizeExecError(error) {
|
|
59
|
+
return {
|
|
60
|
+
status: typeof error?.status === 'number' ? error.status : null,
|
|
61
|
+
signal: typeof error?.signal === 'string' ? error.signal : null,
|
|
62
|
+
message: error?.message ? String(error.message) : null,
|
|
63
|
+
};
|
|
36
64
|
}
|
|
37
65
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
function reportExecutionFailure(error, binPath, args, log = console.error) {
|
|
67
|
+
const { status, signal, message } = normalizeExecError(error);
|
|
68
|
+
|
|
69
|
+
log(`Failed to execute: ${formatCommand(binPath, args)}`);
|
|
70
|
+
|
|
71
|
+
if (signal) {
|
|
72
|
+
log(`Binary terminated by signal ${signal}.`);
|
|
44
73
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
74
|
+
|
|
75
|
+
if (status !== null) {
|
|
76
|
+
log(`Binary exited with status ${status}.`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (message) {
|
|
80
|
+
log(message);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return { status, signal };
|
|
48
84
|
}
|
|
85
|
+
|
|
86
|
+
function reportUnsupportedPlatform(platformName = platform, archName = arch, log = console.error) {
|
|
87
|
+
log(`Unsupported platform: ${platformName}-${archName}`);
|
|
88
|
+
log('');
|
|
89
|
+
log('Supported platforms:');
|
|
90
|
+
for (const item of SUPPORTED_PLATFORMS) {
|
|
91
|
+
log(` - ${item.label}`);
|
|
92
|
+
}
|
|
93
|
+
log('');
|
|
94
|
+
log('You can download the binary manually from:');
|
|
95
|
+
log(` ${RELEASE_URL}`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function reportMissingPlatformPackage(platformName = platform, archName = arch, log = console.error) {
|
|
99
|
+
const platformPackage = `@twsxtd/hapi-${platformName}-${archName}`;
|
|
100
|
+
log(`Missing platform package: ${platformPackage}`);
|
|
101
|
+
log('');
|
|
102
|
+
log(`Detected platform ${platformName}-${archName} is supported, but the platform binary package was not installed.`);
|
|
103
|
+
log('This may happen when using a registry mirror that has not synced all optionalDependencies.');
|
|
104
|
+
log('');
|
|
105
|
+
log('Try reinstalling with the official npm registry:');
|
|
106
|
+
log(` npm install -g @twsxtd/hapi --registry=${OFFICIAL_NPM_REGISTRY}`);
|
|
107
|
+
log('');
|
|
108
|
+
log('Or download the binary manually from:');
|
|
109
|
+
log(` ${RELEASE_URL}`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function main() {
|
|
113
|
+
if (!isSupportedPlatform()) {
|
|
114
|
+
reportUnsupportedPlatform();
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const binPath = getBinaryPath();
|
|
119
|
+
if (!binPath) {
|
|
120
|
+
reportMissingPlatformPackage();
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const args = process.argv.slice(2);
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
execFileSync(binPath, args, { stdio: 'inherit' });
|
|
128
|
+
} catch (error) {
|
|
129
|
+
const { status, signal } = reportExecutionFailure(error, binPath, args);
|
|
130
|
+
|
|
131
|
+
if (status !== null) {
|
|
132
|
+
process.exit(status);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (signal) {
|
|
136
|
+
try {
|
|
137
|
+
process.kill(process.pid, signal);
|
|
138
|
+
} catch {
|
|
139
|
+
// ignore unsupported/invalid signal names on this platform
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (require.main === module) {
|
|
148
|
+
main();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = {
|
|
152
|
+
formatCommand,
|
|
153
|
+
getPlatformKey,
|
|
154
|
+
getBinaryPath,
|
|
155
|
+
isSupportedPlatform,
|
|
156
|
+
normalizeExecError,
|
|
157
|
+
reportExecutionFailure,
|
|
158
|
+
reportMissingPlatformPackage,
|
|
159
|
+
reportUnsupportedPlatform,
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twsxtd/hapi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "App for agentic coding - access coding agent anywhere",
|
|
5
5
|
"author": "Kirill Dubovitskiy & weishu",
|
|
6
6
|
"license": "AGPL-3.0-only",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"NOTICE"
|
|
21
21
|
],
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@twsxtd/hapi-darwin-arm64": "0.
|
|
24
|
-
"@twsxtd/hapi-darwin-x64": "0.
|
|
25
|
-
"@twsxtd/hapi-linux-arm64": "0.
|
|
26
|
-
"@twsxtd/hapi-linux-x64": "0.
|
|
27
|
-
"@twsxtd/hapi-win32-x64": "0.
|
|
23
|
+
"@twsxtd/hapi-darwin-arm64": "0.16.0",
|
|
24
|
+
"@twsxtd/hapi-darwin-x64": "0.16.0",
|
|
25
|
+
"@twsxtd/hapi-linux-arm64": "0.16.0",
|
|
26
|
+
"@twsxtd/hapi-linux-x64": "0.16.0",
|
|
27
|
+
"@twsxtd/hapi-win32-x64": "0.16.0"
|
|
28
28
|
}
|
|
29
29
|
}
|