@jlovec/zhushen 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/NOTICE +52 -0
- package/bin/zs.cjs +160 -0
- package/package.json +29 -0
package/NOTICE
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
hapi CLI
|
|
2
|
+
Copyright (c) 2024-2025 weishu
|
|
3
|
+
|
|
4
|
+
This software contains code derived from happy-cli
|
|
5
|
+
(https://github.com/slopus/happy-cli), which is licensed
|
|
6
|
+
under the MIT License:
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2024 Kirill Dubovitskiy
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
The following files/directories are derived from happy-cli:
|
|
35
|
+
- src/api/
|
|
36
|
+
- src/claude/
|
|
37
|
+
- src/codex/
|
|
38
|
+
- src/runner/
|
|
39
|
+
- src/commands/
|
|
40
|
+
- src/ui/
|
|
41
|
+
- src/utils/
|
|
42
|
+
- src/modules/ripgrep/
|
|
43
|
+
- src/modules/difftastic/
|
|
44
|
+
- src/modules/watcher/
|
|
45
|
+
- src/modules/common/registerCommonHandlers.ts
|
|
46
|
+
- src/modules/common/pathSecurity.ts
|
|
47
|
+
- src/parsers/
|
|
48
|
+
- src/configuration.ts
|
|
49
|
+
- src/persistence.ts
|
|
50
|
+
- src/projectPath.ts
|
|
51
|
+
- src/lib.ts
|
|
52
|
+
- src/index.ts
|
package/bin/zs.cjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const platform = process.platform;
|
|
7
|
+
const arch = process.arch;
|
|
8
|
+
const RELEASE_URL = 'https://github.com/jlovec1024/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 = `@jlovec/zhushen-${platformName}-${archName}`;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
// Try to find the platform-specific package
|
|
46
|
+
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
47
|
+
const binName = platformName === 'win32' ? 'zs.exe' : 'zs';
|
|
48
|
+
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function formatCommand(binPath, args) {
|
|
55
|
+
return [binPath, ...args].map((arg) => JSON.stringify(String(arg))).join(' ');
|
|
56
|
+
}
|
|
57
|
+
|
|
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
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
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}.`);
|
|
73
|
+
}
|
|
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 };
|
|
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 = `@jlovec/zhushen-${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 @jlovec/zhushen --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
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jlovec/zhushen",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "App for agentic coding - access coding agent anywhere",
|
|
5
|
+
"author": "Kirill Dubovitskiy & weishu",
|
|
6
|
+
"license": "AGPL-3.0-only",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"homepage": "https://github.com/jlovec1024/hapi",
|
|
9
|
+
"bugs": "https://github.com/jlovec1024/hapi/issues",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/jlovec1024/hapi.git",
|
|
13
|
+
"directory": "cli"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"zs": "bin/zs.cjs"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin/zs.cjs",
|
|
20
|
+
"NOTICE"
|
|
21
|
+
],
|
|
22
|
+
"optionalDependencies": {
|
|
23
|
+
"@jlovec/zhushen-darwin-arm64": "0.1.0",
|
|
24
|
+
"@jlovec/zhushen-darwin-x64": "0.1.0",
|
|
25
|
+
"@jlovec/zhushen-linux-arm64": "0.1.0",
|
|
26
|
+
"@jlovec/zhushen-linux-x64": "0.1.0",
|
|
27
|
+
"@jlovec/zhushen-win32-x64": "0.1.0"
|
|
28
|
+
}
|
|
29
|
+
}
|