hypercore-cli 1.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/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/api-XGC7D5AW.js +162 -0
- package/dist/auth-DNQWYQKT.js +21 -0
- package/dist/background-2EGCAAQH.js +14 -0
- package/dist/backlog-Q2NZCLNY.js +24 -0
- package/dist/chunk-2CMSCWQW.js +162 -0
- package/dist/chunk-2LJ2DVEB.js +167 -0
- package/dist/chunk-3RPFCQKJ.js +288 -0
- package/dist/chunk-43OLRXM5.js +263 -0
- package/dist/chunk-4DVYJAJL.js +57 -0
- package/dist/chunk-6OL3GA3P.js +173 -0
- package/dist/chunk-AUHU7ALH.js +2023 -0
- package/dist/chunk-B6A2AKLN.js +139 -0
- package/dist/chunk-BE46C7JW.js +46 -0
- package/dist/chunk-CUVAUOXL.js +58 -0
- package/dist/chunk-GH7E2OJE.js +223 -0
- package/dist/chunk-GOOTEPBK.js +271 -0
- package/dist/chunk-GPPMJYSM.js +133 -0
- package/dist/chunk-GU2FZQ6A.js +69 -0
- package/dist/chunk-IOPKN5GD.js +190 -0
- package/dist/chunk-IXOIOGR5.js +1505 -0
- package/dist/chunk-KRPOPWGA.js +251 -0
- package/dist/chunk-MGLJ53QN.js +219 -0
- package/dist/chunk-MV4TTRYX.js +533 -0
- package/dist/chunk-OPZYEVYR.js +150 -0
- package/dist/chunk-QTSLP47C.js +166 -0
- package/dist/chunk-R3GPQC7I.js +393 -0
- package/dist/chunk-RKB2JOV2.js +43 -0
- package/dist/chunk-RNG3K465.js +80 -0
- package/dist/chunk-TGTYKBGC.js +86 -0
- package/dist/chunk-U5SGAIMM.js +681 -0
- package/dist/chunk-V5UHPPSY.js +140 -0
- package/dist/chunk-WHLVZCQY.js +245 -0
- package/dist/chunk-XDRCBMZZ.js +66 -0
- package/dist/chunk-XOS6HPEF.js +134 -0
- package/dist/chunk-ZSBHUGWR.js +262 -0
- package/dist/claude-NSQ442XD.js +12 -0
- package/dist/commands-CK3WFAGI.js +128 -0
- package/dist/commands-U63OEO5J.js +1044 -0
- package/dist/commands-ZE6GD3WC.js +232 -0
- package/dist/config-4EW42BSF.js +8 -0
- package/dist/config-loader-SXO674TF.js +24 -0
- package/dist/diagnose-AFW3ZTZ4.js +12 -0
- package/dist/display-IIUBEYWN.js +58 -0
- package/dist/extractor-QV53W2YJ.js +129 -0
- package/dist/history-WMSCHERZ.js +180 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +406 -0
- package/dist/instance-registry-YSIJXSO7.js +15 -0
- package/dist/keybindings-JAAMLH3G.js +15 -0
- package/dist/loader-WHNTZTLP.js +58 -0
- package/dist/network-MM6YWPGO.js +279 -0
- package/dist/notify-HPTALZDC.js +14 -0
- package/dist/openai-compat-UQWJXBEK.js +12 -0
- package/dist/permissions-JUKXMNDH.js +10 -0
- package/dist/prompt-QV45TXRL.js +166 -0
- package/dist/quality-ST7PPNFR.js +16 -0
- package/dist/repl-RT3AHL7M.js +3375 -0
- package/dist/roadmap-5OBEKROY.js +17 -0
- package/dist/server-PORT7OEG.js +57 -0
- package/dist/session-4VUNDWLH.js +21 -0
- package/dist/skills-V4A35XKG.js +175 -0
- package/dist/store-Y4LU5QTO.js +25 -0
- package/dist/team-HO7Z4SIM.js +385 -0
- package/dist/telemetry-6R4EIE6O.js +30 -0
- package/dist/test-runner-ZQH5Y6OJ.js +619 -0
- package/dist/theme-3SYJ3UQA.js +14 -0
- package/dist/upgrade-7TGI3SXO.js +83 -0
- package/dist/verify-JUDKTPKZ.js +14 -0
- package/dist/web/static/app.js +562 -0
- package/dist/web/static/index.html +132 -0
- package/dist/web/static/mirror.css +1001 -0
- package/dist/web/static/mirror.html +184 -0
- package/dist/web/static/mirror.js +1125 -0
- package/dist/web/static/onboard.css +302 -0
- package/dist/web/static/onboard.html +140 -0
- package/dist/web/static/onboard.js +260 -0
- package/dist/web/static/style.css +602 -0
- package/dist/web/static/workspace.css +1568 -0
- package/dist/web/static/workspace.html +408 -0
- package/dist/web/static/workspace.js +1683 -0
- package/dist/web-Z5HSCQHW.js +39 -0
- package/package.json +67 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/repl/background.ts
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
var tasks = /* @__PURE__ */ new Map();
|
|
4
|
+
var processes = /* @__PURE__ */ new Map();
|
|
5
|
+
var counter = 0;
|
|
6
|
+
function spawnBackground(command) {
|
|
7
|
+
counter++;
|
|
8
|
+
const id = `bg-${String(counter).padStart(3, "0")}`;
|
|
9
|
+
const task = {
|
|
10
|
+
id,
|
|
11
|
+
command,
|
|
12
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
13
|
+
status: "running",
|
|
14
|
+
output: "",
|
|
15
|
+
error: ""
|
|
16
|
+
};
|
|
17
|
+
const child = spawn("sh", ["-c", command], {
|
|
18
|
+
cwd: process.cwd(),
|
|
19
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
20
|
+
env: { ...process.env }
|
|
21
|
+
});
|
|
22
|
+
task.pid = child.pid;
|
|
23
|
+
child.stdout?.on("data", (data) => {
|
|
24
|
+
task.output += data.toString();
|
|
25
|
+
if (task.output.length > 512 * 1024) {
|
|
26
|
+
task.output = task.output.slice(-256 * 1024);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
child.stderr?.on("data", (data) => {
|
|
30
|
+
task.error += data.toString();
|
|
31
|
+
if (task.error.length > 128 * 1024) {
|
|
32
|
+
task.error = task.error.slice(-64 * 1024);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
child.on("close", (code) => {
|
|
36
|
+
task.status = code === 0 ? "done" : "error";
|
|
37
|
+
task.exitCode = code;
|
|
38
|
+
processes.delete(id);
|
|
39
|
+
});
|
|
40
|
+
child.on("error", (err) => {
|
|
41
|
+
task.status = "error";
|
|
42
|
+
task.error += `
|
|
43
|
+
\u8FDB\u7A0B\u9519\u8BEF: ${err.message}`;
|
|
44
|
+
processes.delete(id);
|
|
45
|
+
});
|
|
46
|
+
tasks.set(id, task);
|
|
47
|
+
processes.set(id, child);
|
|
48
|
+
return task;
|
|
49
|
+
}
|
|
50
|
+
function getTaskOutput(id) {
|
|
51
|
+
return tasks.get(id);
|
|
52
|
+
}
|
|
53
|
+
function listBackgroundTasks() {
|
|
54
|
+
return [...tasks.values()];
|
|
55
|
+
}
|
|
56
|
+
function stopTask(id) {
|
|
57
|
+
const child = processes.get(id);
|
|
58
|
+
if (child) {
|
|
59
|
+
child.kill("SIGTERM");
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
if (processes.has(id)) {
|
|
62
|
+
child.kill("SIGKILL");
|
|
63
|
+
}
|
|
64
|
+
}, 3e3);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
function clearCompletedTasks() {
|
|
70
|
+
let count = 0;
|
|
71
|
+
for (const [id, task] of tasks) {
|
|
72
|
+
if (task.status !== "running") {
|
|
73
|
+
tasks.delete(id);
|
|
74
|
+
count++;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return count;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
spawnBackground,
|
|
82
|
+
getTaskOutput,
|
|
83
|
+
listBackgroundTasks,
|
|
84
|
+
stopTask,
|
|
85
|
+
clearCompletedTasks
|
|
86
|
+
};
|