happy-coder 0.10.0-1 → 0.10.0-3
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/happy-mcp.mjs +32 -0
- package/dist/codex/happyMcpStdioBridge.cjs +80 -0
- package/dist/codex/happyMcpStdioBridge.d.cts +2 -0
- package/dist/codex/happyMcpStdioBridge.d.mts +2 -0
- package/dist/codex/happyMcpStdioBridge.mjs +78 -0
- package/dist/index-DPVbp4Yx.mjs +6048 -0
- package/dist/index-tqOLc1Il.cjs +6056 -0
- package/dist/index.cjs +33 -6024
- package/dist/index.mjs +33 -6024
- package/dist/lib.cjs +2 -1
- package/dist/lib.d.cts +12 -2
- package/dist/lib.d.mts +12 -2
- package/dist/lib.mjs +2 -1
- package/dist/runCodex-BxLD6H6G.cjs +1155 -0
- package/dist/runCodex-C07HQlsW.mjs +1153 -0
- package/dist/{types-D9P2bndj.cjs → types-CsJGQvQ3.cjs} +145 -48
- package/dist/{types-BUXwivpV.mjs → types-xds_c-JJ.mjs} +109 -12
- package/package.json +21 -8
- package/scripts/ripgrep_launcher.cjs +2 -26
- package/scripts/unpack-tools.cjs +163 -0
- package/tools/archives/difftastic-LICENSE +21 -0
- package/tools/archives/difftastic-arm64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-arm64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-darwin.tar.gz +0 -0
- package/tools/archives/difftastic-x64-linux.tar.gz +0 -0
- package/tools/archives/difftastic-x64-win32.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-arm64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-darwin.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-linux.tar.gz +0 -0
- package/tools/archives/ripgrep-x64-win32.tar.gz +0 -0
- package/tools/licenses/difftastic-LICENSE +21 -0
- package/tools/licenses/ripgrep-LICENSE +3 -0
- package/tools/unpacked/difft +0 -0
- package/ripgrep/arm64-linux/rg +0 -0
- package/ripgrep/arm64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-darwin/rg +0 -0
- package/ripgrep/x64-darwin/ripgrep.node +0 -0
- package/ripgrep/x64-linux/rg +0 -0
- package/ripgrep/x64-linux/ripgrep.node +0 -0
- package/ripgrep/x64-win32/rg.exe +0 -0
- package/ripgrep/x64-win32/ripgrep.node +0 -0
- /package/{ripgrep/COPYING → tools/archives/ripgrep-LICENSE} +0 -0
- /package/{ripgrep/arm64-darwin → tools/unpacked}/rg +0 -0
- /package/{ripgrep/arm64-darwin → tools/unpacked}/ripgrep.node +0 -0
|
@@ -17,11 +17,12 @@ import { readFile as readFile$1, stat as stat$1, writeFile as writeFile$1, readd
|
|
|
17
17
|
import { createHash } from 'crypto';
|
|
18
18
|
import { dirname, resolve, join as join$1 } from 'path';
|
|
19
19
|
import { fileURLToPath } from 'url';
|
|
20
|
+
import { platform } from 'os';
|
|
20
21
|
import { Expo } from 'expo-server-sdk';
|
|
21
22
|
|
|
22
23
|
var name = "happy-coder";
|
|
23
|
-
var version = "0.10.0-
|
|
24
|
-
var description = "Claude Code
|
|
24
|
+
var version = "0.10.0-3";
|
|
25
|
+
var description = "Mobile and Web client for Claude Code and Codex";
|
|
25
26
|
var author = "Kirill Dubovitskiy";
|
|
26
27
|
var license = "MIT";
|
|
27
28
|
var type = "module";
|
|
@@ -29,7 +30,8 @@ var homepage = "https://github.com/slopus/happy-cli";
|
|
|
29
30
|
var bugs = "https://github.com/slopus/happy-cli/issues";
|
|
30
31
|
var repository = "slopus/happy-cli";
|
|
31
32
|
var bin = {
|
|
32
|
-
happy: "./bin/happy.mjs"
|
|
33
|
+
happy: "./bin/happy.mjs",
|
|
34
|
+
"happy-mcp": "./bin/happy-mcp.mjs"
|
|
33
35
|
};
|
|
34
36
|
var main = "./dist/index.cjs";
|
|
35
37
|
var module = "./dist/index.mjs";
|
|
@@ -54,13 +56,23 @@ var exports = {
|
|
|
54
56
|
types: "./dist/lib.d.mts",
|
|
55
57
|
"default": "./dist/lib.mjs"
|
|
56
58
|
}
|
|
59
|
+
},
|
|
60
|
+
"./codex/happyMcpStdioBridge": {
|
|
61
|
+
require: {
|
|
62
|
+
types: "./dist/codex/happyMcpStdioBridge.d.cts",
|
|
63
|
+
"default": "./dist/codex/happyMcpStdioBridge.cjs"
|
|
64
|
+
},
|
|
65
|
+
"import": {
|
|
66
|
+
types: "./dist/codex/happyMcpStdioBridge.d.mts",
|
|
67
|
+
"default": "./dist/codex/happyMcpStdioBridge.mjs"
|
|
68
|
+
}
|
|
57
69
|
}
|
|
58
70
|
};
|
|
59
71
|
var files = [
|
|
60
72
|
"dist",
|
|
61
73
|
"bin",
|
|
62
74
|
"scripts",
|
|
63
|
-
"
|
|
75
|
+
"tools",
|
|
64
76
|
"package.json"
|
|
65
77
|
];
|
|
66
78
|
var scripts = {
|
|
@@ -73,18 +85,19 @@ var scripts = {
|
|
|
73
85
|
"dev:local-server": "yarn build && tsx --env-file .env.dev-local-server src/index.ts",
|
|
74
86
|
"dev:integration-test-env": "yarn build && tsx --env-file .env.integration-test src/index.ts",
|
|
75
87
|
prepublishOnly: "yarn build && yarn test",
|
|
76
|
-
release: "release-it"
|
|
88
|
+
release: "release-it",
|
|
89
|
+
postinstall: "node scripts/unpack-tools.cjs"
|
|
77
90
|
};
|
|
78
91
|
var dependencies = {
|
|
79
|
-
"@anthropic-ai/claude-code": "^1.0.
|
|
92
|
+
"@anthropic-ai/claude-code": "^1.0.102",
|
|
80
93
|
"@anthropic-ai/sdk": "^0.56.0",
|
|
81
94
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
82
95
|
"@stablelib/base64": "^2.0.1",
|
|
96
|
+
"@types/cross-spawn": "^6.0.6",
|
|
83
97
|
"@types/http-proxy": "^1.17.16",
|
|
98
|
+
"@types/ps-list": "^6.2.1",
|
|
84
99
|
"@types/qrcode-terminal": "^0.12.2",
|
|
85
100
|
"@types/react": "^19.1.9",
|
|
86
|
-
"@types/ps-list": "^6.2.1",
|
|
87
|
-
"@types/cross-spawn": "^6.0.6",
|
|
88
101
|
axios: "^1.10.0",
|
|
89
102
|
chalk: "^5.4.1",
|
|
90
103
|
"cross-spawn": "^7.0.6",
|
|
@@ -99,6 +112,7 @@ var dependencies = {
|
|
|
99
112
|
"qrcode-terminal": "^0.12.0",
|
|
100
113
|
react: "^19.1.1",
|
|
101
114
|
"socket.io-client": "^4.8.1",
|
|
115
|
+
tar: "^7.4.3",
|
|
102
116
|
tweetnacl: "^1.0.3",
|
|
103
117
|
zod: "^3.23.8"
|
|
104
118
|
};
|
|
@@ -482,6 +496,13 @@ class Logger {
|
|
|
482
496
|
this.logToConsole("info", "[DEV]", message, ...args);
|
|
483
497
|
}
|
|
484
498
|
}
|
|
499
|
+
warn(message, ...args) {
|
|
500
|
+
this.logToConsole("warn", "", message, ...args);
|
|
501
|
+
this.debug(`[WARN] ${message}`, ...args);
|
|
502
|
+
}
|
|
503
|
+
getLogPath() {
|
|
504
|
+
return this.logFilePath;
|
|
505
|
+
}
|
|
485
506
|
logToConsole(level, prefix, message, ...args) {
|
|
486
507
|
switch (level) {
|
|
487
508
|
case "debug": {
|
|
@@ -673,7 +694,8 @@ z$1.object({
|
|
|
673
694
|
platform: z$1.string(),
|
|
674
695
|
happyCliVersion: z$1.string(),
|
|
675
696
|
homeDir: z$1.string(),
|
|
676
|
-
happyHomeDir: z$1.string()
|
|
697
|
+
happyHomeDir: z$1.string(),
|
|
698
|
+
happyLibDir: z$1.string()
|
|
677
699
|
});
|
|
678
700
|
z$1.object({
|
|
679
701
|
status: z$1.union([
|
|
@@ -937,7 +959,7 @@ function projectPath() {
|
|
|
937
959
|
return path;
|
|
938
960
|
}
|
|
939
961
|
|
|
940
|
-
function run(args, options) {
|
|
962
|
+
function run$1(args, options) {
|
|
941
963
|
const RUNNER_PATH = resolve(join$1(projectPath(), "scripts", "ripgrep_launcher.cjs"));
|
|
942
964
|
return new Promise((resolve2, reject) => {
|
|
943
965
|
const child = spawn("node", [RUNNER_PATH, JSON.stringify(args)], {
|
|
@@ -965,6 +987,44 @@ function run(args, options) {
|
|
|
965
987
|
});
|
|
966
988
|
}
|
|
967
989
|
|
|
990
|
+
function getBinaryPath() {
|
|
991
|
+
const platformName = platform();
|
|
992
|
+
const binaryName = platformName === "win32" ? "difft.exe" : "difft";
|
|
993
|
+
return resolve(join$1(projectPath(), "tools", "unpacked", binaryName));
|
|
994
|
+
}
|
|
995
|
+
function run(args, options) {
|
|
996
|
+
const binaryPath = getBinaryPath();
|
|
997
|
+
return new Promise((resolve2, reject) => {
|
|
998
|
+
const child = spawn(binaryPath, args, {
|
|
999
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1000
|
+
cwd: options?.cwd,
|
|
1001
|
+
env: {
|
|
1002
|
+
...process.env,
|
|
1003
|
+
// Force color output when needed
|
|
1004
|
+
FORCE_COLOR: "1"
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
let stdout = "";
|
|
1008
|
+
let stderr = "";
|
|
1009
|
+
child.stdout.on("data", (data) => {
|
|
1010
|
+
stdout += data.toString();
|
|
1011
|
+
});
|
|
1012
|
+
child.stderr.on("data", (data) => {
|
|
1013
|
+
stderr += data.toString();
|
|
1014
|
+
});
|
|
1015
|
+
child.on("close", (code) => {
|
|
1016
|
+
resolve2({
|
|
1017
|
+
exitCode: code || 0,
|
|
1018
|
+
stdout,
|
|
1019
|
+
stderr
|
|
1020
|
+
});
|
|
1021
|
+
});
|
|
1022
|
+
child.on("error", (err) => {
|
|
1023
|
+
reject(err);
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
|
|
968
1028
|
const execAsync = promisify(exec);
|
|
969
1029
|
function registerCommonHandlers(rpcHandlerManager) {
|
|
970
1030
|
rpcHandlerManager.registerHandler("bash", async (data) => {
|
|
@@ -1159,7 +1219,7 @@ function registerCommonHandlers(rpcHandlerManager) {
|
|
|
1159
1219
|
rpcHandlerManager.registerHandler("ripgrep", async (data) => {
|
|
1160
1220
|
logger.debug("Ripgrep request with args:", data.args, "cwd:", data.cwd);
|
|
1161
1221
|
try {
|
|
1162
|
-
const result = await run(data.args, { cwd: data.cwd });
|
|
1222
|
+
const result = await run$1(data.args, { cwd: data.cwd });
|
|
1163
1223
|
return {
|
|
1164
1224
|
success: true,
|
|
1165
1225
|
exitCode: result.exitCode,
|
|
@@ -1174,6 +1234,24 @@ function registerCommonHandlers(rpcHandlerManager) {
|
|
|
1174
1234
|
};
|
|
1175
1235
|
}
|
|
1176
1236
|
});
|
|
1237
|
+
rpcHandlerManager.registerHandler("difftastic", async (data) => {
|
|
1238
|
+
logger.debug("Difftastic request with args:", data.args, "cwd:", data.cwd);
|
|
1239
|
+
try {
|
|
1240
|
+
const result = await run(data.args, { cwd: data.cwd });
|
|
1241
|
+
return {
|
|
1242
|
+
success: true,
|
|
1243
|
+
exitCode: result.exitCode,
|
|
1244
|
+
stdout: result.stdout.toString(),
|
|
1245
|
+
stderr: result.stderr.toString()
|
|
1246
|
+
};
|
|
1247
|
+
} catch (error) {
|
|
1248
|
+
logger.debug("Failed to run difftastic:", error);
|
|
1249
|
+
return {
|
|
1250
|
+
success: false,
|
|
1251
|
+
error: error instanceof Error ? error.message : "Failed to run difftastic"
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1177
1255
|
}
|
|
1178
1256
|
|
|
1179
1257
|
class ApiSessionClient extends EventEmitter {
|
|
@@ -1337,6 +1415,24 @@ class ApiSessionClient extends EventEmitter {
|
|
|
1337
1415
|
}));
|
|
1338
1416
|
}
|
|
1339
1417
|
}
|
|
1418
|
+
sendCodexMessage(body) {
|
|
1419
|
+
let content = {
|
|
1420
|
+
role: "agent",
|
|
1421
|
+
content: {
|
|
1422
|
+
type: "codex",
|
|
1423
|
+
data: body
|
|
1424
|
+
// This wraps the entire Claude message
|
|
1425
|
+
},
|
|
1426
|
+
meta: {
|
|
1427
|
+
sentFrom: "cli"
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1430
|
+
const encrypted = encodeBase64(encrypt(content, this.secret));
|
|
1431
|
+
this.socket.emit("message", {
|
|
1432
|
+
sid: this.sessionId,
|
|
1433
|
+
message: encrypted
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1340
1436
|
sendSessionEvent(event, id) {
|
|
1341
1437
|
let content = {
|
|
1342
1438
|
role: "agent",
|
|
@@ -1461,6 +1557,7 @@ class ApiSessionClient extends EventEmitter {
|
|
|
1461
1557
|
});
|
|
1462
1558
|
}
|
|
1463
1559
|
async close() {
|
|
1560
|
+
logger.debug("[API] socket.close() called");
|
|
1464
1561
|
this.socket.close();
|
|
1465
1562
|
}
|
|
1466
1563
|
}
|
|
@@ -1996,4 +2093,4 @@ const RawJSONLinesSchema = z$1.discriminatedUnion("type", [
|
|
|
1996
2093
|
}).passthrough()
|
|
1997
2094
|
]);
|
|
1998
2095
|
|
|
1999
|
-
export { ApiClient as A, RawJSONLinesSchema as R, ApiSessionClient as a,
|
|
2096
|
+
export { ApiClient as A, RawJSONLinesSchema as R, ApiSessionClient as a, packageJson as b, configuration as c, backoff as d, delay as e, AsyncLock as f, readDaemonState as g, clearDaemonState as h, readCredentials as i, encodeBase64 as j, encodeBase64Url as k, logger as l, decodeBase64 as m, acquireDaemonLock as n, writeDaemonState as o, projectPath as p, releaseDaemonLock as q, readSettings as r, clearCredentials as s, clearMachineId as t, updateSettings as u, getLatestDaemonLog as v, writeCredentials as w };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "happy-coder",
|
|
3
|
-
"version": "0.10.0-
|
|
4
|
-
"description": "Claude Code
|
|
3
|
+
"version": "0.10.0-3",
|
|
4
|
+
"description": "Mobile and Web client for Claude Code and Codex",
|
|
5
5
|
"author": "Kirill Dubovitskiy",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"bugs": "https://github.com/slopus/happy-cli/issues",
|
|
10
10
|
"repository": "slopus/happy-cli",
|
|
11
11
|
"bin": {
|
|
12
|
-
"happy": "./bin/happy.mjs"
|
|
12
|
+
"happy": "./bin/happy.mjs",
|
|
13
|
+
"happy-mcp": "./bin/happy-mcp.mjs"
|
|
13
14
|
},
|
|
14
15
|
"main": "./dist/index.cjs",
|
|
15
16
|
"module": "./dist/index.mjs",
|
|
@@ -34,13 +35,23 @@
|
|
|
34
35
|
"types": "./dist/lib.d.mts",
|
|
35
36
|
"default": "./dist/lib.mjs"
|
|
36
37
|
}
|
|
38
|
+
},
|
|
39
|
+
"./codex/happyMcpStdioBridge": {
|
|
40
|
+
"require": {
|
|
41
|
+
"types": "./dist/codex/happyMcpStdioBridge.d.cts",
|
|
42
|
+
"default": "./dist/codex/happyMcpStdioBridge.cjs"
|
|
43
|
+
},
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/codex/happyMcpStdioBridge.d.mts",
|
|
46
|
+
"default": "./dist/codex/happyMcpStdioBridge.mjs"
|
|
47
|
+
}
|
|
37
48
|
}
|
|
38
49
|
},
|
|
39
50
|
"files": [
|
|
40
51
|
"dist",
|
|
41
52
|
"bin",
|
|
42
53
|
"scripts",
|
|
43
|
-
"
|
|
54
|
+
"tools",
|
|
44
55
|
"package.json"
|
|
45
56
|
],
|
|
46
57
|
"scripts": {
|
|
@@ -53,18 +64,19 @@
|
|
|
53
64
|
"dev:local-server": "yarn build && tsx --env-file .env.dev-local-server src/index.ts",
|
|
54
65
|
"dev:integration-test-env": "yarn build && tsx --env-file .env.integration-test src/index.ts",
|
|
55
66
|
"prepublishOnly": "yarn build && yarn test",
|
|
56
|
-
"release": "release-it"
|
|
67
|
+
"release": "release-it",
|
|
68
|
+
"postinstall": "node scripts/unpack-tools.cjs"
|
|
57
69
|
},
|
|
58
70
|
"dependencies": {
|
|
59
|
-
"@anthropic-ai/claude-code": "^1.0.
|
|
71
|
+
"@anthropic-ai/claude-code": "^1.0.102",
|
|
60
72
|
"@anthropic-ai/sdk": "^0.56.0",
|
|
61
73
|
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
62
74
|
"@stablelib/base64": "^2.0.1",
|
|
75
|
+
"@types/cross-spawn": "^6.0.6",
|
|
63
76
|
"@types/http-proxy": "^1.17.16",
|
|
77
|
+
"@types/ps-list": "^6.2.1",
|
|
64
78
|
"@types/qrcode-terminal": "^0.12.2",
|
|
65
79
|
"@types/react": "^19.1.9",
|
|
66
|
-
"@types/ps-list": "^6.2.1",
|
|
67
|
-
"@types/cross-spawn": "^6.0.6",
|
|
68
80
|
"axios": "^1.10.0",
|
|
69
81
|
"chalk": "^5.4.1",
|
|
70
82
|
"cross-spawn": "^7.0.6",
|
|
@@ -79,6 +91,7 @@
|
|
|
79
91
|
"qrcode-terminal": "^0.12.0",
|
|
80
92
|
"react": "^19.1.1",
|
|
81
93
|
"socket.io-client": "^4.8.1",
|
|
94
|
+
"tar": "^7.4.3",
|
|
82
95
|
"tweetnacl": "^1.0.3",
|
|
83
96
|
"zod": "^3.23.8"
|
|
84
97
|
},
|
|
@@ -6,33 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const path = require('path');
|
|
9
|
-
const os = require('os');
|
|
10
9
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
const platform = os.platform();
|
|
14
|
-
const arch = os.arch();
|
|
15
|
-
const platformKey = `${arch}-${platform}`;
|
|
16
|
-
|
|
17
|
-
const platformMap = {
|
|
18
|
-
'arm64-darwin': 'arm64-darwin',
|
|
19
|
-
'x64-darwin': 'x64-darwin',
|
|
20
|
-
'arm64-linux': 'arm64-linux',
|
|
21
|
-
'x64-linux': 'x64-linux',
|
|
22
|
-
'x64-win32': 'x64-win32'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return platformMap[platformKey];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Load the native module
|
|
29
|
-
const platformDir = getPlatformDir();
|
|
30
|
-
if (!platformDir) {
|
|
31
|
-
console.error(`Unsupported platform: ${os.arch()}-${os.platform()}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const modulePath = path.join(__dirname, '..', 'ripgrep', platformDir, 'ripgrep.node');
|
|
10
|
+
// Load the native module from unpacked directory
|
|
11
|
+
const modulePath = path.join(__dirname, '..', 'tools', 'unpacked', 'ripgrep.node');
|
|
36
12
|
const ripgrepNative = require(modulePath);
|
|
37
13
|
|
|
38
14
|
// Get arguments from command line (skip node and script name)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Unpacks platform-specific binaries from compressed archives
|
|
5
|
+
* This script extracts the necessary tools for the current platform
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const zlib = require('zlib');
|
|
11
|
+
const tar = require('tar');
|
|
12
|
+
const os = require('os');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get the platform-specific directory name
|
|
16
|
+
*/
|
|
17
|
+
function getPlatformDir() {
|
|
18
|
+
const platform = os.platform();
|
|
19
|
+
const arch = os.arch();
|
|
20
|
+
|
|
21
|
+
if (platform === 'darwin') {
|
|
22
|
+
if (arch === 'arm64') return 'arm64-darwin';
|
|
23
|
+
if (arch === 'x64') return 'x64-darwin';
|
|
24
|
+
} else if (platform === 'linux') {
|
|
25
|
+
if (arch === 'arm64') return 'arm64-linux';
|
|
26
|
+
if (arch === 'x64') return 'x64-linux';
|
|
27
|
+
} else if (platform === 'win32') {
|
|
28
|
+
if (arch === 'x64') return 'x64-win32';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
throw new Error(`Unsupported platform: ${arch}-${platform}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the root tools directory
|
|
36
|
+
*/
|
|
37
|
+
function getToolsDir() {
|
|
38
|
+
// Handle both direct execution and require() calls
|
|
39
|
+
const scriptDir = __dirname;
|
|
40
|
+
return path.resolve(scriptDir, '..', 'tools');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if tools are already unpacked for current platform
|
|
45
|
+
*/
|
|
46
|
+
function areToolsUnpacked(toolsDir) {
|
|
47
|
+
const unpackedPath = path.join(toolsDir, 'unpacked');
|
|
48
|
+
|
|
49
|
+
if (!fs.existsSync(unpackedPath)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check for expected binaries
|
|
54
|
+
const isWin = os.platform() === 'win32';
|
|
55
|
+
const difftBinary = isWin ? 'difft.exe' : 'difft';
|
|
56
|
+
const rgBinary = isWin ? 'rg.exe' : 'rg';
|
|
57
|
+
|
|
58
|
+
const expectedFiles = [
|
|
59
|
+
path.join(unpackedPath, difftBinary),
|
|
60
|
+
path.join(unpackedPath, rgBinary),
|
|
61
|
+
path.join(unpackedPath, 'ripgrep.node')
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
return expectedFiles.every(file => fs.existsSync(file));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Unpack a tar.gz archive to a destination directory
|
|
69
|
+
*/
|
|
70
|
+
async function unpackArchive(archivePath, destDir) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
// Ensure destination directory exists
|
|
73
|
+
if (!fs.existsSync(destDir)) {
|
|
74
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Create read stream and extract
|
|
78
|
+
fs.createReadStream(archivePath)
|
|
79
|
+
.pipe(zlib.createGunzip())
|
|
80
|
+
.pipe(tar.extract({
|
|
81
|
+
cwd: destDir,
|
|
82
|
+
preserveMode: true,
|
|
83
|
+
preserveOwner: false
|
|
84
|
+
}))
|
|
85
|
+
.on('finish', () => {
|
|
86
|
+
// Set executable permissions for Unix systems
|
|
87
|
+
if (os.platform() !== 'win32') {
|
|
88
|
+
const files = fs.readdirSync(destDir);
|
|
89
|
+
files.forEach(file => {
|
|
90
|
+
const filePath = path.join(destDir, file);
|
|
91
|
+
const stats = fs.statSync(filePath);
|
|
92
|
+
if (stats.isFile() && !file.endsWith('.node')) {
|
|
93
|
+
// Make binary files executable
|
|
94
|
+
fs.chmodSync(filePath, 0o755);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
resolve();
|
|
99
|
+
})
|
|
100
|
+
.on('error', reject);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Main unpacking function
|
|
106
|
+
*/
|
|
107
|
+
async function unpackTools() {
|
|
108
|
+
try {
|
|
109
|
+
const platformDir = getPlatformDir();
|
|
110
|
+
const toolsDir = getToolsDir();
|
|
111
|
+
const archivesDir = path.join(toolsDir, 'archives');
|
|
112
|
+
const unpackedPath = path.join(toolsDir, 'unpacked');
|
|
113
|
+
|
|
114
|
+
// Check if already unpacked
|
|
115
|
+
if (areToolsUnpacked(toolsDir)) {
|
|
116
|
+
console.log(`Tools already unpacked for ${platformDir}`);
|
|
117
|
+
return { success: true, alreadyUnpacked: true };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
console.log(`Unpacking tools for ${platformDir}...`);
|
|
121
|
+
|
|
122
|
+
// Create unpacked directory
|
|
123
|
+
if (!fs.existsSync(unpackedPath)) {
|
|
124
|
+
fs.mkdirSync(unpackedPath, { recursive: true });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Unpack difftastic
|
|
128
|
+
const difftasticArchive = path.join(archivesDir, `difftastic-${platformDir}.tar.gz`);
|
|
129
|
+
if (!fs.existsSync(difftasticArchive)) {
|
|
130
|
+
throw new Error(`Archive not found: ${difftasticArchive}`);
|
|
131
|
+
}
|
|
132
|
+
await unpackArchive(difftasticArchive, unpackedPath);
|
|
133
|
+
|
|
134
|
+
// Unpack ripgrep
|
|
135
|
+
const ripgrepArchive = path.join(archivesDir, `ripgrep-${platformDir}.tar.gz`);
|
|
136
|
+
if (!fs.existsSync(ripgrepArchive)) {
|
|
137
|
+
throw new Error(`Archive not found: ${ripgrepArchive}`);
|
|
138
|
+
}
|
|
139
|
+
await unpackArchive(ripgrepArchive, unpackedPath);
|
|
140
|
+
|
|
141
|
+
console.log(`Tools unpacked successfully to ${unpackedPath}`);
|
|
142
|
+
return { success: true, alreadyUnpacked: false };
|
|
143
|
+
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error('Failed to unpack tools:', error.message);
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Export for use as module
|
|
151
|
+
module.exports = { unpackTools, getPlatformDir, getToolsDir };
|
|
152
|
+
|
|
153
|
+
// Run if executed directly
|
|
154
|
+
if (require.main === module) {
|
|
155
|
+
unpackTools()
|
|
156
|
+
.then(result => {
|
|
157
|
+
process.exit(0);
|
|
158
|
+
})
|
|
159
|
+
.catch(error => {
|
|
160
|
+
console.error('Error:', error);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2025 Wilfred Hughes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2025 Wilfred Hughes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
Binary file
|
package/ripgrep/arm64-linux/rg
DELETED
|
Binary file
|
|
Binary file
|
package/ripgrep/x64-darwin/rg
DELETED
|
Binary file
|
|
Binary file
|
package/ripgrep/x64-linux/rg
DELETED
|
Binary file
|
|
Binary file
|
package/ripgrep/x64-win32/rg.exe
DELETED
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|