@youngfine/hapi 0.29.0-youngfine.1
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/README.md +20 -0
- package/bin/hapi.cjs +162 -0
- package/package.json +33 -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/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# HAPI Personal Fork
|
|
2
|
+
|
|
3
|
+
## 来源
|
|
4
|
+
|
|
5
|
+
本项目 fork 自 [tiann/hapi](https://github.com/tiann/hapi)。
|
|
6
|
+
|
|
7
|
+
## 我的改动
|
|
8
|
+
|
|
9
|
+
- 增加独立的“临时上下文”入口,长文本可以作为 `.txt` 附件与输入框中的问题一起发送。
|
|
10
|
+
- 粘贴文本达到默认 `3000` 字符或超过 `60` 行时自动转换为附件,两个阈值可以在“设置 → 聊天 → 输入”中自定义。
|
|
11
|
+
- 支持直接粘贴普通文件,不再只处理图片。
|
|
12
|
+
- User 消息超过 `15` 行时默认折叠,展开后立即显示完整内容。
|
|
13
|
+
|
|
14
|
+
## 使用
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g @youngfine/hapi --registry=https://registry.npmjs.org
|
|
18
|
+
hapi hub
|
|
19
|
+
hapi runner start --workspace-root ~/git-repository
|
|
20
|
+
```
|
package/bin/hapi.cjs
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
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 NPM_SCOPE = '@youngfine';
|
|
9
|
+
const MAIN_PACKAGE = `${NPM_SCOPE}/hapi`;
|
|
10
|
+
const RELEASE_URL = 'https://github.com/Conanxy/hapi/releases';
|
|
11
|
+
const OFFICIAL_NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
12
|
+
const SUPPORTED_PLATFORMS = [
|
|
13
|
+
{
|
|
14
|
+
key: 'darwin-arm64',
|
|
15
|
+
label: 'darwin-arm64 (macOS Apple Silicon)',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
key: 'darwin-x64',
|
|
19
|
+
label: 'darwin-x64 (macOS Intel)',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
key: 'linux-arm64',
|
|
23
|
+
label: 'linux-arm64',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
key: 'linux-x64',
|
|
27
|
+
label: 'linux-x64',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
key: 'win32-x64',
|
|
31
|
+
label: 'win32-x64',
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
function getPlatformKey(platformName = platform, archName = arch) {
|
|
36
|
+
return `${platformName}-${archName}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isSupportedPlatform(platformName = platform, archName = arch) {
|
|
40
|
+
return SUPPORTED_PLATFORMS.some((item) => item.key === getPlatformKey(platformName, archName));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getBinaryPath(platformName = platform, archName = arch) {
|
|
44
|
+
const pkgName = `${NPM_SCOPE}/hapi-${platformName}-${archName}`;
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
// Try to find the platform-specific package
|
|
48
|
+
const pkgPath = require.resolve(`${pkgName}/package.json`);
|
|
49
|
+
const binName = platformName === 'win32' ? 'hapi.exe' : 'hapi';
|
|
50
|
+
return path.join(path.dirname(pkgPath), 'bin', binName);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function formatCommand(binPath, args) {
|
|
57
|
+
return [binPath, ...args].map((arg) => JSON.stringify(String(arg))).join(' ');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function normalizeExecError(error) {
|
|
61
|
+
return {
|
|
62
|
+
status: typeof error?.status === 'number' ? error.status : null,
|
|
63
|
+
signal: typeof error?.signal === 'string' ? error.signal : null,
|
|
64
|
+
message: error?.message ? String(error.message) : null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function reportExecutionFailure(error, binPath, args, log = console.error) {
|
|
69
|
+
const { status, signal, message } = normalizeExecError(error);
|
|
70
|
+
|
|
71
|
+
log(`Failed to execute: ${formatCommand(binPath, args)}`);
|
|
72
|
+
|
|
73
|
+
if (signal) {
|
|
74
|
+
log(`Binary terminated by signal ${signal}.`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (status !== null) {
|
|
78
|
+
log(`Binary exited with status ${status}.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (message) {
|
|
82
|
+
log(message);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { status, signal };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function reportUnsupportedPlatform(platformName = platform, archName = arch, log = console.error) {
|
|
89
|
+
log(`Unsupported platform: ${platformName}-${archName}`);
|
|
90
|
+
log('');
|
|
91
|
+
log('Supported platforms:');
|
|
92
|
+
for (const item of SUPPORTED_PLATFORMS) {
|
|
93
|
+
log(` - ${item.label}`);
|
|
94
|
+
}
|
|
95
|
+
log('');
|
|
96
|
+
log('You can download the binary manually from:');
|
|
97
|
+
log(` ${RELEASE_URL}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function reportMissingPlatformPackage(platformName = platform, archName = arch, log = console.error) {
|
|
101
|
+
const platformPackage = `${NPM_SCOPE}/hapi-${platformName}-${archName}`;
|
|
102
|
+
log(`Missing platform package: ${platformPackage}`);
|
|
103
|
+
log('');
|
|
104
|
+
log(`Detected platform ${platformName}-${archName} is supported, but the platform binary package was not installed.`);
|
|
105
|
+
log('This may happen when using a registry mirror that has not synced all optionalDependencies.');
|
|
106
|
+
log('');
|
|
107
|
+
log('Try reinstalling with the official npm registry:');
|
|
108
|
+
log(` npm install -g ${MAIN_PACKAGE} --registry=${OFFICIAL_NPM_REGISTRY}`);
|
|
109
|
+
log('');
|
|
110
|
+
log('Or download the binary manually from:');
|
|
111
|
+
log(` ${RELEASE_URL}`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function main() {
|
|
115
|
+
if (!isSupportedPlatform()) {
|
|
116
|
+
reportUnsupportedPlatform();
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const binPath = getBinaryPath();
|
|
121
|
+
if (!binPath) {
|
|
122
|
+
reportMissingPlatformPackage();
|
|
123
|
+
process.exit(1);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const args = process.argv.slice(2);
|
|
127
|
+
|
|
128
|
+
try {
|
|
129
|
+
execFileSync(binPath, args, { stdio: 'inherit' });
|
|
130
|
+
} catch (error) {
|
|
131
|
+
const { status, signal } = reportExecutionFailure(error, binPath, args);
|
|
132
|
+
|
|
133
|
+
if (status !== null) {
|
|
134
|
+
process.exit(status);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (signal) {
|
|
138
|
+
try {
|
|
139
|
+
process.kill(process.pid, signal);
|
|
140
|
+
} catch {
|
|
141
|
+
// ignore unsupported/invalid signal names on this platform
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (require.main === module) {
|
|
150
|
+
main();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
module.exports = {
|
|
154
|
+
formatCommand,
|
|
155
|
+
getPlatformKey,
|
|
156
|
+
getBinaryPath,
|
|
157
|
+
isSupportedPlatform,
|
|
158
|
+
normalizeExecError,
|
|
159
|
+
reportExecutionFailure,
|
|
160
|
+
reportMissingPlatformPackage,
|
|
161
|
+
reportUnsupportedPlatform,
|
|
162
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@youngfine/hapi",
|
|
3
|
+
"version": "0.29.0-youngfine.1",
|
|
4
|
+
"description": "Unofficial personal fork of HAPI with custom remote-agent workflow improvements",
|
|
5
|
+
"author": "youngfine (fork maintainer); Kirill Dubovitskiy & weishu (upstream)",
|
|
6
|
+
"license": "AGPL-3.0-only",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"homepage": "https://github.com/Conanxy/hapi",
|
|
9
|
+
"bugs": "https://github.com/Conanxy/hapi/issues",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Conanxy/hapi.git",
|
|
13
|
+
"directory": "cli"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"hapi": "bin/hapi.cjs"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin/hapi.cjs",
|
|
20
|
+
"NOTICE",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@youngfine/hapi-darwin-arm64": "0.29.0-youngfine.1",
|
|
25
|
+
"@youngfine/hapi-darwin-x64": "0.29.0-youngfine.1",
|
|
26
|
+
"@youngfine/hapi-linux-arm64": "0.29.0-youngfine.1",
|
|
27
|
+
"@youngfine/hapi-linux-x64": "0.29.0-youngfine.1",
|
|
28
|
+
"@youngfine/hapi-win32-x64": "0.29.0-youngfine.1"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
}
|
|
33
|
+
}
|