@hanzo/dev 2.1.0 → 3.0.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/bin/dev.js +420 -0
- package/package.json +39 -56
- package/postinstall.js +589 -0
- package/.eslintrc.json +0 -24
- package/README.md +0 -359
- package/dist/cli/dev.js +0 -24739
- package/src/cli/dev.ts +0 -946
- package/src/lib/agent-loop.ts +0 -552
- package/src/lib/benchmark-runner.ts +0 -431
- package/src/lib/code-act-agent.ts +0 -378
- package/src/lib/config.ts +0 -163
- package/src/lib/editor.ts +0 -395
- package/src/lib/function-calling.ts +0 -318
- package/src/lib/mcp-client.ts +0 -259
- package/src/lib/peer-agent-network.ts +0 -584
- package/src/lib/swarm-runner.ts +0 -379
- package/src/lib/unified-workspace.ts +0 -435
- package/test-swarm/file1.js +0 -6
- package/test-swarm/file2.ts +0 -12
- package/test-swarm/file3.py +0 -15
- package/test-swarm/file4.md +0 -13
- package/test-swarm/file5.json +0 -12
- package/test-swarm-demo.sh +0 -22
- package/tests/browser-integration.test.ts +0 -242
- package/tests/code-act-agent.test.ts +0 -305
- package/tests/editor.test.ts +0 -223
- package/tests/fixtures/sample-code.js +0 -13
- package/tests/fixtures/sample-code.py +0 -28
- package/tests/fixtures/sample-code.ts +0 -22
- package/tests/mcp-client.test.ts +0 -238
- package/tests/peer-agent-network.test.ts +0 -340
- package/tests/swarm-runner.test.ts +0 -301
- package/tests/swe-bench.test.ts +0 -357
- package/tsconfig.cli.json +0 -25
- package/tsconfig.json +0 -35
- package/vitest.config.ts +0 -37
package/bin/dev.js
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the Hanzo Dev CLI.
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { platform as nodePlatform, arch as nodeArch } from "os";
|
|
7
|
+
import { execSync } from "child_process";
|
|
8
|
+
import { get as httpsGet } from "https";
|
|
9
|
+
|
|
10
|
+
// __dirname equivalent in ESM
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
const { platform, arch } = process;
|
|
15
|
+
|
|
16
|
+
// Important: Never delegate to another system's `dev` binary.
|
|
17
|
+
// When users run via `npx @hanzo/dev`, we must always execute our
|
|
18
|
+
// packaged native binary by absolute path to avoid PATH collisions.
|
|
19
|
+
|
|
20
|
+
const isWSL = () => {
|
|
21
|
+
if (platform !== "linux") return false;
|
|
22
|
+
try {
|
|
23
|
+
const os = require("os");
|
|
24
|
+
const rel = os.release().toLowerCase();
|
|
25
|
+
if (rel.includes("microsoft")) return true;
|
|
26
|
+
const fs = require("fs");
|
|
27
|
+
const txt = fs.readFileSync("/proc/version", "utf8").toLowerCase();
|
|
28
|
+
return txt.includes("microsoft");
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
let targetTriple = null;
|
|
35
|
+
switch (platform) {
|
|
36
|
+
case "linux":
|
|
37
|
+
case "android":
|
|
38
|
+
switch (arch) {
|
|
39
|
+
case "x64":
|
|
40
|
+
targetTriple = "x86_64-unknown-linux-musl";
|
|
41
|
+
break;
|
|
42
|
+
case "arm64":
|
|
43
|
+
targetTriple = "aarch64-unknown-linux-musl";
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case "darwin":
|
|
50
|
+
switch (arch) {
|
|
51
|
+
case "x64":
|
|
52
|
+
targetTriple = "x86_64-apple-darwin";
|
|
53
|
+
break;
|
|
54
|
+
case "arm64":
|
|
55
|
+
targetTriple = "aarch64-apple-darwin";
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
break;
|
|
61
|
+
case "win32":
|
|
62
|
+
switch (arch) {
|
|
63
|
+
case "x64":
|
|
64
|
+
targetTriple = "x86_64-pc-windows-msvc.exe";
|
|
65
|
+
break;
|
|
66
|
+
case "arm64":
|
|
67
|
+
// We do not build this today, fall through...
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!targetTriple) {
|
|
77
|
+
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Use 'dev-*' binary names
|
|
81
|
+
let binaryPath = path.join(__dirname, "..", "bin", `dev-${targetTriple}`);
|
|
82
|
+
let legacyBinaryPath = path.join(__dirname, "..", "bin", `dev-${targetTriple}`);
|
|
83
|
+
|
|
84
|
+
// --- Bootstrap helper (runs if the binary is missing, e.g. Bun blocked postinstall) ---
|
|
85
|
+
import { existsSync, chmodSync, statSync, openSync, readSync, closeSync, mkdirSync, copyFileSync, readFileSync, unlinkSync } from "fs";
|
|
86
|
+
|
|
87
|
+
const validateBinary = (p) => {
|
|
88
|
+
try {
|
|
89
|
+
const st = statSync(p);
|
|
90
|
+
if (!st.isFile() || st.size === 0) {
|
|
91
|
+
return { ok: false, reason: "empty or not a regular file" };
|
|
92
|
+
}
|
|
93
|
+
const fd = openSync(p, "r");
|
|
94
|
+
try {
|
|
95
|
+
const buf = Buffer.alloc(4);
|
|
96
|
+
const n = readSync(fd, buf, 0, 4, 0);
|
|
97
|
+
if (n < 2) return { ok: false, reason: "too short" };
|
|
98
|
+
if (platform === "win32") {
|
|
99
|
+
if (!(buf[0] === 0x4d && buf[1] === 0x5a)) return { ok: false, reason: "invalid PE header (missing MZ)" };
|
|
100
|
+
} else if (platform === "linux" || platform === "android") {
|
|
101
|
+
if (!(buf[0] === 0x7f && buf[1] === 0x45 && buf[2] === 0x4c && buf[3] === 0x46)) return { ok: false, reason: "invalid ELF header" };
|
|
102
|
+
} else if (platform === "darwin") {
|
|
103
|
+
const isMachO = (buf[0] === 0xcf && buf[1] === 0xfa && buf[2] === 0xed && buf[3] === 0xfe) ||
|
|
104
|
+
(buf[0] === 0xca && buf[1] === 0xfe && buf[2] === 0xba && buf[3] === 0xbe);
|
|
105
|
+
if (!isMachO) return { ok: false, reason: "invalid Mach-O header" };
|
|
106
|
+
}
|
|
107
|
+
} finally {
|
|
108
|
+
closeSync(fd);
|
|
109
|
+
}
|
|
110
|
+
return { ok: true };
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return { ok: false, reason: e.message };
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const getCacheDir = (version) => {
|
|
117
|
+
const plt = nodePlatform();
|
|
118
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
119
|
+
let base = "";
|
|
120
|
+
if (plt === "win32") {
|
|
121
|
+
base = process.env.LOCALAPPDATA || path.join(home, "AppData", "Local");
|
|
122
|
+
} else if (plt === "darwin") {
|
|
123
|
+
base = path.join(home, "Library", "Caches");
|
|
124
|
+
} else {
|
|
125
|
+
base = process.env.XDG_CACHE_HOME || path.join(home, ".cache");
|
|
126
|
+
}
|
|
127
|
+
const dir = path.join(base, "hanzo", "dev", version);
|
|
128
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
129
|
+
return dir;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const getCachedBinaryPath = (version) => {
|
|
133
|
+
const isWin = nodePlatform() === "win32";
|
|
134
|
+
const ext = isWin ? ".exe" : "";
|
|
135
|
+
const cacheDir = getCacheDir(version);
|
|
136
|
+
return path.join(cacheDir, `dev-${targetTriple}${ext}`);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const httpsDownload = (url, dest) => new Promise((resolve, reject) => {
|
|
140
|
+
const req = httpsGet(url, (res) => {
|
|
141
|
+
const status = res.statusCode || 0;
|
|
142
|
+
if (status >= 300 && status < 400 && res.headers.location) {
|
|
143
|
+
// follow one redirect recursively
|
|
144
|
+
return resolve(httpsDownload(res.headers.location, dest));
|
|
145
|
+
}
|
|
146
|
+
if (status !== 200) {
|
|
147
|
+
return reject(new Error(`HTTP ${status}`));
|
|
148
|
+
}
|
|
149
|
+
const out = require("fs").createWriteStream(dest);
|
|
150
|
+
res.pipe(out);
|
|
151
|
+
out.on("finish", () => out.close(resolve));
|
|
152
|
+
out.on("error", (e) => {
|
|
153
|
+
try { unlinkSync(dest); } catch {}
|
|
154
|
+
reject(e);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
req.on("error", (e) => {
|
|
158
|
+
try { unlinkSync(dest); } catch {}
|
|
159
|
+
reject(e);
|
|
160
|
+
});
|
|
161
|
+
req.setTimeout(120000, () => {
|
|
162
|
+
req.destroy(new Error("download timed out"));
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const tryBootstrapBinary = async () => {
|
|
167
|
+
try {
|
|
168
|
+
// 1) Read our published version
|
|
169
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
|
170
|
+
const version = pkg.version;
|
|
171
|
+
|
|
172
|
+
const binDir = path.join(__dirname, "..", "bin");
|
|
173
|
+
if (!existsSync(binDir)) mkdirSync(binDir, { recursive: true });
|
|
174
|
+
|
|
175
|
+
// 2) Fast path: user cache
|
|
176
|
+
const cachePath = getCachedBinaryPath(version);
|
|
177
|
+
if (existsSync(cachePath)) {
|
|
178
|
+
const v = validateBinary(cachePath);
|
|
179
|
+
if (v.ok) {
|
|
180
|
+
copyFileSync(cachePath, binaryPath);
|
|
181
|
+
if (platform !== "win32") chmodSync(binaryPath, 0o755);
|
|
182
|
+
return existsSync(binaryPath);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 3) Try platform package (if present)
|
|
187
|
+
try {
|
|
188
|
+
const req = (await import("module")).createRequire(import.meta.url);
|
|
189
|
+
const name = (() => {
|
|
190
|
+
if (platform === "win32") return "@just-every/code-win32-x64"; // may be unpublished; falls through
|
|
191
|
+
const plt = nodePlatform();
|
|
192
|
+
const cpu = nodeArch();
|
|
193
|
+
if (plt === "darwin" && cpu === "arm64") return "@hanzo/dev-darwin-arm64";
|
|
194
|
+
if (plt === "darwin" && cpu === "x64") return "@hanzo/dev-darwin-x64";
|
|
195
|
+
if (plt === "linux" && cpu === "x64") return "@hanzo/dev-linux-x64-musl";
|
|
196
|
+
if (plt === "linux" && cpu === "arm64") return "@hanzo/dev-linux-arm64-musl";
|
|
197
|
+
return null;
|
|
198
|
+
})();
|
|
199
|
+
if (name) {
|
|
200
|
+
try {
|
|
201
|
+
const pkgJson = req.resolve(`${name}/package.json`);
|
|
202
|
+
const pkgDir = path.dirname(pkgJson);
|
|
203
|
+
const src = path.join(pkgDir, "bin", `dev-${targetTriple}${platform === "win32" ? ".exe" : ""}`);
|
|
204
|
+
if (existsSync(src)) {
|
|
205
|
+
copyFileSync(src, binaryPath);
|
|
206
|
+
if (platform !== "win32") chmodSync(binaryPath, 0o755);
|
|
207
|
+
// refresh cache
|
|
208
|
+
try { copyFileSync(binaryPath, cachePath); } catch {}
|
|
209
|
+
return existsSync(binaryPath);
|
|
210
|
+
}
|
|
211
|
+
} catch { /* ignore and fall back */ }
|
|
212
|
+
}
|
|
213
|
+
} catch { /* ignore */ }
|
|
214
|
+
|
|
215
|
+
// 4) Download from GitHub release
|
|
216
|
+
const isWin = platform === "win32";
|
|
217
|
+
const archiveName = isWin
|
|
218
|
+
? `dev-${targetTriple}.zip`
|
|
219
|
+
: (() => { try { execSync("zstd --version", { stdio: "ignore", shell: true }); return `dev-${targetTriple}.zst`; } catch { return `dev-${targetTriple}.tar.gz`; } })();
|
|
220
|
+
const url = `https://github.com/hanzoai/dev/releases/download/v${version}/${archiveName}`;
|
|
221
|
+
const tmp = path.join(binDir, `.${archiveName}.part`);
|
|
222
|
+
return httpsDownload(url, tmp)
|
|
223
|
+
.then(() => {
|
|
224
|
+
if (isWin) {
|
|
225
|
+
try {
|
|
226
|
+
const ps = `powershell -NoProfile -NonInteractive -Command "Expand-Archive -Path '${tmp}' -DestinationPath '${binDir}' -Force"`;
|
|
227
|
+
execSync(ps, { stdio: "ignore" });
|
|
228
|
+
} catch (e) {
|
|
229
|
+
throw new Error(`failed to unzip: ${e.message}`);
|
|
230
|
+
} finally { try { unlinkSync(tmp); } catch {} }
|
|
231
|
+
} else {
|
|
232
|
+
if (archiveName.endsWith(".zst")) {
|
|
233
|
+
try { execSync(`zstd -d '${tmp}' -o '${binaryPath}'`, { stdio: 'ignore', shell: true }); }
|
|
234
|
+
catch (e) { try { unlinkSync(tmp); } catch {}; throw new Error(`failed to decompress zst: ${e.message}`); }
|
|
235
|
+
try { unlinkSync(tmp); } catch {}
|
|
236
|
+
} else {
|
|
237
|
+
try { execSync(`tar -xzf '${tmp}' -C '${binDir}'`, { stdio: 'ignore', shell: true }); }
|
|
238
|
+
catch (e) { try { unlinkSync(tmp); } catch {}; throw new Error(`failed to extract tar.gz: ${e.message}`); }
|
|
239
|
+
try { unlinkSync(tmp); } catch {}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const v = validateBinary(binaryPath);
|
|
243
|
+
if (!v.ok) throw new Error(`invalid binary (${v.reason})`);
|
|
244
|
+
if (platform !== "win32") chmodSync(binaryPath, 0o755);
|
|
245
|
+
try { copyFileSync(binaryPath, cachePath); } catch {}
|
|
246
|
+
return true;
|
|
247
|
+
})
|
|
248
|
+
.catch((_e) => false);
|
|
249
|
+
} catch {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
// If missing, attempt to bootstrap into place (helps when Bun blocks postinstall)
|
|
255
|
+
if (!existsSync(binaryPath) && !existsSync(legacyBinaryPath)) {
|
|
256
|
+
const ok = await tryBootstrapBinary();
|
|
257
|
+
if (!ok) {
|
|
258
|
+
// retry legacy name in case archive provided coder-*
|
|
259
|
+
if (existsSync(legacyBinaryPath) && !existsSync(binaryPath)) {
|
|
260
|
+
binaryPath = legacyBinaryPath;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Fall back to legacy name if primary is still missing
|
|
266
|
+
if (!existsSync(binaryPath) && existsSync(legacyBinaryPath)) {
|
|
267
|
+
binaryPath = legacyBinaryPath;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Check if binary exists and try to fix permissions if needed
|
|
271
|
+
// fs imports are above; keep for readability if tree-shaken by bundlers
|
|
272
|
+
import { spawnSync } from "child_process";
|
|
273
|
+
if (existsSync(binaryPath)) {
|
|
274
|
+
try {
|
|
275
|
+
// Ensure binary is executable on Unix-like systems
|
|
276
|
+
if (platform !== "win32") {
|
|
277
|
+
chmodSync(binaryPath, 0o755);
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
// Ignore permission errors, will be caught below if it's a real problem
|
|
281
|
+
}
|
|
282
|
+
} else {
|
|
283
|
+
console.error(`Binary not found: ${binaryPath}`);
|
|
284
|
+
console.error(`Please try reinstalling the package:`);
|
|
285
|
+
console.error(` npm uninstall -g @hanzo/dev`);
|
|
286
|
+
console.error(` npm install -g @hanzo/dev`);
|
|
287
|
+
if (isWSL()) {
|
|
288
|
+
console.error("Detected WSL. Install inside WSL (Ubuntu) separately:");
|
|
289
|
+
console.error(" npx -y @hanzo/dev@latest (run inside WSL)");
|
|
290
|
+
console.error("If installed globally on Windows, those binaries are not usable from WSL.");
|
|
291
|
+
}
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Lightweight header validation to provide clearer errors before spawn
|
|
296
|
+
// Reuse the validateBinary helper defined above in the bootstrap section.
|
|
297
|
+
|
|
298
|
+
const validation = validateBinary(binaryPath);
|
|
299
|
+
if (!validation.ok) {
|
|
300
|
+
console.error(`The native binary at ${binaryPath} appears invalid: ${validation.reason}`);
|
|
301
|
+
console.error("This can happen if the download failed or was modified by antivirus/proxy.");
|
|
302
|
+
console.error("Please try reinstalling:");
|
|
303
|
+
console.error(" npm uninstall -g @hanzo/dev");
|
|
304
|
+
console.error(" npm install -g @hanzo/dev");
|
|
305
|
+
if (platform === "win32") {
|
|
306
|
+
console.error("If the issue persists, clear npm cache and disable antivirus temporarily:");
|
|
307
|
+
console.error(" npm cache clean --force");
|
|
308
|
+
}
|
|
309
|
+
if (isWSL()) {
|
|
310
|
+
console.error("Detected WSL. Ensure you install/run inside WSL, not Windows:");
|
|
311
|
+
console.error(" npx -y @hanzo/dev@latest (inside WSL)");
|
|
312
|
+
}
|
|
313
|
+
process.exit(1);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// If running under npx/npm, emit a concise notice about which binary path is used
|
|
317
|
+
try {
|
|
318
|
+
const ua = process.env.npm_config_user_agent || "";
|
|
319
|
+
const isNpx = ua.includes("npx");
|
|
320
|
+
if (isNpx && process.stderr && process.stderr.isTTY) {
|
|
321
|
+
// Best-effort discovery of another 'code' on PATH for user clarity
|
|
322
|
+
let otherCode = "";
|
|
323
|
+
try {
|
|
324
|
+
const cmd = process.platform === "win32" ? "where code" : "command -v code || which code || true";
|
|
325
|
+
const out = spawnSync(process.platform === "win32" ? "cmd" : "bash", [
|
|
326
|
+
process.platform === "win32" ? "/c" : "-lc",
|
|
327
|
+
cmd,
|
|
328
|
+
], { encoding: "utf8" });
|
|
329
|
+
const line = (out.stdout || "").split(/\r?\n/).map((s) => s.trim()).filter(Boolean)[0];
|
|
330
|
+
if (line && !line.includes("@hanzo/dev")) {
|
|
331
|
+
otherCode = line;
|
|
332
|
+
}
|
|
333
|
+
} catch {}
|
|
334
|
+
if (otherCode) {
|
|
335
|
+
console.error(`@hanzo/dev: running bundled binary -> ${binaryPath}`);
|
|
336
|
+
console.error(`Note: a different 'dev' exists at ${otherCode}; not delegating.`);
|
|
337
|
+
} else {
|
|
338
|
+
console.error(`@hanzo/dev: running bundled binary -> ${binaryPath}`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
} catch {}
|
|
342
|
+
|
|
343
|
+
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
344
|
+
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
345
|
+
// executing. This allows us to forward those signals to the child process
|
|
346
|
+
// and guarantees that when either the child terminates or the parent
|
|
347
|
+
// receives a fatal signal, both processes exit in a predictable manner.
|
|
348
|
+
const { spawn } = await import("child_process");
|
|
349
|
+
|
|
350
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
351
|
+
stdio: "inherit",
|
|
352
|
+
env: { ...process.env, CODER_MANAGED_BY_NPM: "1", CODEX_MANAGED_BY_NPM: "1" },
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
child.on("error", (err) => {
|
|
356
|
+
// Typically triggered when the binary is missing or not executable.
|
|
357
|
+
const code = err && err.code;
|
|
358
|
+
if (code === 'EACCES') {
|
|
359
|
+
console.error(`Permission denied: ${binaryPath}`);
|
|
360
|
+
console.error(`Try running: chmod +x "${binaryPath}"`);
|
|
361
|
+
console.error(`Or reinstall the package with: npm install -g @hanzo/dev`);
|
|
362
|
+
} else if (code === 'EFTYPE' || code === 'ENOEXEC') {
|
|
363
|
+
console.error(`Failed to execute native binary: ${binaryPath}`);
|
|
364
|
+
console.error("The file may be corrupt or of the wrong type. Reinstall usually fixes this:");
|
|
365
|
+
console.error(" npm uninstall -g @hanzo/dev && npm install -g @hanzo/dev");
|
|
366
|
+
if (platform === 'win32') {
|
|
367
|
+
console.error("On Windows, ensure the .exe downloaded correctly (proxy/AV can interfere).");
|
|
368
|
+
console.error("Try clearing cache: npm cache clean --force");
|
|
369
|
+
}
|
|
370
|
+
if (isWSL()) {
|
|
371
|
+
console.error("Detected WSL. Windows binaries cannot be executed from WSL.");
|
|
372
|
+
console.error("Install inside WSL and run there: npx -y @hanzo/dev@latest");
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
console.error(err);
|
|
376
|
+
}
|
|
377
|
+
process.exit(1);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// Forward common termination signals to the child so that it shuts down
|
|
381
|
+
// gracefully. In the handler we temporarily disable the default behavior of
|
|
382
|
+
// exiting immediately; once the child has been signaled we simply wait for
|
|
383
|
+
// its exit event which will in turn terminate the parent (see below).
|
|
384
|
+
const forwardSignal = (signal) => {
|
|
385
|
+
if (child.killed) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
child.kill(signal);
|
|
390
|
+
} catch {
|
|
391
|
+
/* ignore */
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
396
|
+
process.on(sig, () => forwardSignal(sig));
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// When the child exits, mirror its termination reason in the parent so that
|
|
400
|
+
// shell scripts and other tooling observe the correct exit status.
|
|
401
|
+
// Wrap the lifetime of the child process in a Promise so that we can await
|
|
402
|
+
// its termination in a structured way. The Promise resolves with an object
|
|
403
|
+
// describing how the child exited: either via exit code or due to a signal.
|
|
404
|
+
const childResult = await new Promise((resolve) => {
|
|
405
|
+
child.on("exit", (code, signal) => {
|
|
406
|
+
if (signal) {
|
|
407
|
+
resolve({ type: "signal", signal });
|
|
408
|
+
} else {
|
|
409
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
if (childResult.type === "signal") {
|
|
415
|
+
// Re-emit the same signal so that the parent terminates with the expected
|
|
416
|
+
// semantics (this also sets the correct exit code of 128 + n).
|
|
417
|
+
process.kill(process.pid, childResult.signal);
|
|
418
|
+
} else {
|
|
419
|
+
process.exit(childResult.exitCode);
|
|
420
|
+
}
|
package/package.json
CHANGED
|
@@ -1,73 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/dev",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Lightweight coding agent that runs in your terminal - Hanzo AI developer tools",
|
|
6
6
|
"bin": {
|
|
7
|
-
"dev": "
|
|
7
|
+
"dev": "bin/dev.js"
|
|
8
8
|
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=20"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"bin/dev.js",
|
|
15
|
+
"postinstall.js",
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
9
18
|
"scripts": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"test:watch": "vitest --watch",
|
|
16
|
-
"test:ui": "vitest --ui",
|
|
17
|
-
"test:coverage": "vitest --coverage",
|
|
18
|
-
"test:swe-bench": "vitest run --testNamePattern=SWE-bench",
|
|
19
|
-
"lint": "eslint src tests --ext .ts",
|
|
20
|
-
"type-check": "tsc --noEmit",
|
|
21
|
-
"prepublishOnly": "npm run build"
|
|
19
|
+
"postinstall": "node postinstall.js"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/hanzoai/dev.git"
|
|
22
24
|
},
|
|
23
25
|
"keywords": [
|
|
24
26
|
"ai",
|
|
25
|
-
"llm",
|
|
26
27
|
"cli",
|
|
28
|
+
"dev",
|
|
29
|
+
"developer-tools",
|
|
30
|
+
"coding-assistant",
|
|
31
|
+
"hanzo",
|
|
32
|
+
"llm",
|
|
33
|
+
"chatgpt",
|
|
27
34
|
"claude",
|
|
28
|
-
"
|
|
29
|
-
"gemini",
|
|
30
|
-
"aider",
|
|
31
|
-
"openhands",
|
|
32
|
-
"development",
|
|
33
|
-
"tools"
|
|
35
|
+
"code-generation"
|
|
34
36
|
],
|
|
35
37
|
"author": "Hanzo AI",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"chalk": "^5.3.0",
|
|
40
|
-
"commander": "^11.1.0",
|
|
41
|
-
"glob": "^10.3.10",
|
|
42
|
-
"inquirer": "^9.2.12",
|
|
43
|
-
"ora": "^7.0.1",
|
|
44
|
-
"uuid": "^9.0.1",
|
|
45
|
-
"ws": "^8.16.0"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@types/glob": "^8.1.0",
|
|
49
|
-
"@types/inquirer": "^9.0.8",
|
|
50
|
-
"@types/node": "^20.19.5",
|
|
51
|
-
"@types/uuid": "^9.0.7",
|
|
52
|
-
"@types/ws": "^8.5.10",
|
|
53
|
-
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
54
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
55
|
-
"@vitest/ui": "^3.2.4",
|
|
56
|
-
"esbuild": "^0.25.6",
|
|
57
|
-
"eslint": "^8.56.0",
|
|
58
|
-
"typescript": "^5.3.3",
|
|
59
|
-
"vitest": "^3.2.4"
|
|
38
|
+
"homepage": "https://github.com/hanzoai/dev#readme",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/hanzoai/dev/issues"
|
|
60
41
|
},
|
|
61
|
-
"
|
|
62
|
-
"
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
63
44
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"directory": "packages/dev"
|
|
45
|
+
"dependencies": {},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"prettier": "^3.3.3"
|
|
68
48
|
},
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
"
|
|
49
|
+
"optionalDependencies": {
|
|
50
|
+
"@hanzo/dev-darwin-arm64": "3.0.1",
|
|
51
|
+
"@hanzo/dev-darwin-x64": "3.0.1",
|
|
52
|
+
"@hanzo/dev-linux-x64": "3.0.1",
|
|
53
|
+
"@hanzo/dev-linux-arm64": "3.0.1",
|
|
54
|
+
"@hanzo/dev-win32-x64": "3.0.1"
|
|
72
55
|
}
|
|
73
56
|
}
|