@twsxtd/hapi 0.15.3 → 0.15.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/hapi.cjs +83 -27
- package/package.json +6 -6
package/bin/hapi.cjs
CHANGED
|
@@ -5,44 +5,100 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
const platform = process.platform;
|
|
7
7
|
const arch = process.arch;
|
|
8
|
-
const pkgName = `@twsxtd/hapi-${platform}-${arch}`;
|
|
9
8
|
|
|
10
|
-
function getBinaryPath() {
|
|
9
|
+
function getBinaryPath(platformName = platform, archName = arch) {
|
|
10
|
+
const pkgName = `@twsxtd/hapi-${platformName}-${archName}`;
|
|
11
|
+
|
|
11
12
|
try {
|
|
12
13
|
// Try to find the platform-specific package
|
|
13
14
|
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
14
|
-
const binName =
|
|
15
|
+
const binName = platformName === 'win32' ? 'hapi.exe' : 'hapi';
|
|
15
16
|
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
16
17
|
} catch (e) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
function formatCommand(binPath, args) {
|
|
23
|
+
return [binPath, ...args].map((arg) => JSON.stringify(String(arg))).join(' ');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizeExecError(error) {
|
|
27
|
+
return {
|
|
28
|
+
status: typeof error?.status === 'number' ? error.status : null,
|
|
29
|
+
signal: typeof error?.signal === 'string' ? error.signal : null,
|
|
30
|
+
message: error?.message ? String(error.message) : null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function reportExecutionFailure(error, binPath, args, log = console.error) {
|
|
35
|
+
const { status, signal, message } = normalizeExecError(error);
|
|
36
|
+
|
|
37
|
+
log(`Failed to execute: ${formatCommand(binPath, args)}`);
|
|
38
|
+
|
|
39
|
+
if (signal) {
|
|
40
|
+
log(`Binary terminated by signal ${signal}.`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (status !== null) {
|
|
44
|
+
log(`Binary exited with status ${status}.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (message) {
|
|
48
|
+
log(message);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return { status, signal };
|
|
36
52
|
}
|
|
37
53
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
function main() {
|
|
55
|
+
const binPath = getBinaryPath();
|
|
56
|
+
|
|
57
|
+
if (!binPath) {
|
|
58
|
+
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
59
|
+
console.error('');
|
|
60
|
+
console.error('Supported platforms:');
|
|
61
|
+
console.error(' - darwin-arm64 (macOS Apple Silicon)');
|
|
62
|
+
console.error(' - darwin-x64 (macOS Intel)');
|
|
63
|
+
console.error(' - linux-arm64');
|
|
64
|
+
console.error(' - linux-x64');
|
|
65
|
+
console.error(' - win32-x64');
|
|
66
|
+
console.error('');
|
|
67
|
+
console.error('You can download the binary manually from:');
|
|
68
|
+
console.error(' https://github.com/tiann/hapi/releases');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const args = process.argv.slice(2);
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
execFileSync(binPath, args, { stdio: 'inherit' });
|
|
76
|
+
} catch (error) {
|
|
77
|
+
const { status, signal } = reportExecutionFailure(error, binPath, args);
|
|
78
|
+
|
|
79
|
+
if (status !== null) {
|
|
80
|
+
process.exit(status);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (signal) {
|
|
84
|
+
try {
|
|
85
|
+
process.kill(process.pid, signal);
|
|
86
|
+
} catch {
|
|
87
|
+
// ignore unsupported/invalid signal names on this platform
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
process.exit(1);
|
|
44
92
|
}
|
|
45
|
-
// For other errors (e.g., binary not found), print and exit
|
|
46
|
-
console.error(`Failed to execute ${binPath}:`, e.message);
|
|
47
|
-
process.exit(1);
|
|
48
93
|
}
|
|
94
|
+
|
|
95
|
+
if (require.main === module) {
|
|
96
|
+
main();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
module.exports = {
|
|
100
|
+
formatCommand,
|
|
101
|
+
getBinaryPath,
|
|
102
|
+
normalizeExecError,
|
|
103
|
+
reportExecutionFailure,
|
|
104
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twsxtd/hapi",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.4",
|
|
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.15.
|
|
24
|
-
"@twsxtd/hapi-darwin-x64": "0.15.
|
|
25
|
-
"@twsxtd/hapi-linux-arm64": "0.15.
|
|
26
|
-
"@twsxtd/hapi-linux-x64": "0.15.
|
|
27
|
-
"@twsxtd/hapi-win32-x64": "0.15.
|
|
23
|
+
"@twsxtd/hapi-darwin-arm64": "0.15.4",
|
|
24
|
+
"@twsxtd/hapi-darwin-x64": "0.15.4",
|
|
25
|
+
"@twsxtd/hapi-linux-arm64": "0.15.4",
|
|
26
|
+
"@twsxtd/hapi-linux-x64": "0.15.4",
|
|
27
|
+
"@twsxtd/hapi-win32-x64": "0.15.4"
|
|
28
28
|
}
|
|
29
29
|
}
|