@modootoday/pmcp 0.25.0 → 0.26.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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/dist/{affected-IPFJM2KD.js → affected-4FILH743.js} +174 -77
- package/dist/{apply-6XLLYLJT.js → apply-HJUCYQDQ.js} +17 -15
- package/dist/{broadcast-34CEG2NQ.js → broadcast-U7ZYOJWE.js} +4 -4
- package/dist/{chunk-BG6TONJO.js → chunk-2GL5L2G5.js} +2 -2
- package/dist/{chunk-PGZZI42O.js → chunk-2JUHFM4V.js} +2 -2
- package/dist/{chunk-UKR64U7J.js → chunk-374AZ4J4.js} +2 -2
- package/dist/{chunk-ISWR2XIU.js → chunk-3JOFDNL4.js} +2 -2
- package/dist/{chunk-2TXVOHRS.js → chunk-3KISMGVP.js} +4 -4
- package/dist/{chunk-SRSKCFFS.js → chunk-6XE3WW7S.js} +3 -3
- package/dist/{chunk-5MUD7FHP.js → chunk-7FHOSWNQ.js} +2 -2
- package/dist/{chunk-QYHM6554.js → chunk-7PBWLYCO.js} +3 -3
- package/dist/{chunk-PECS47OL.js → chunk-C7Y2MBCN.js} +3 -3
- package/dist/chunk-D7IDT7OA.js +21 -0
- package/dist/chunk-E272CFPS.js +14 -0
- package/dist/chunk-FLG7VRTC.js +1 -0
- package/dist/{chunk-3P6Y2BAO.js → chunk-FXDGW2IH.js} +3 -3
- package/dist/{chunk-RF6RDJYH.js → chunk-GIL3RBRX.js} +26 -19
- package/dist/{chunk-ARXCYFFZ.js → chunk-GQRDEIQA.js} +22 -2
- package/dist/chunk-J43Z4O3G.js +7 -0
- package/dist/chunk-KLIYFD3W.js +32 -0
- package/dist/{chunk-UQHJUTDW.js → chunk-KQV2EPAP.js} +2 -2
- package/dist/{chunk-DWHM5BAY.js → chunk-LCPCRZ7N.js} +2 -2
- package/dist/{chunk-MBHI2TKQ.js → chunk-NQZMGQFG.js} +5 -5
- package/dist/{chunk-SSQ6EWNA.js → chunk-OBCBCLS2.js} +7 -7
- package/dist/{chunk-LZVHFPN6.js → chunk-OG2ESRQP.js} +5 -5
- package/dist/{chunk-NAHAESFV.js → chunk-OHCUPXU4.js} +18 -5
- package/dist/{chunk-3V37OZQH.js → chunk-PAY6HEEY.js} +2 -2
- package/dist/{chunk-DITIXBFB.js → chunk-PZ6D3WKD.js} +65 -1
- package/dist/{chunk-TJW4DP26.js → chunk-Q5BQIRM3.js} +2 -2
- package/dist/{chunk-VYQJPT27.js → chunk-S2FUWBLO.js} +18 -4
- package/dist/{chunk-OGCJO6HQ.js → chunk-TQRLWO4F.js} +2 -2
- package/dist/{chunk-EC5QLEZD.js → chunk-UVPIVSZB.js} +14 -6
- package/dist/{chunk-MHKY6TNF.js → chunk-VN34GLGJ.js} +3 -3
- package/dist/chunk-WUFNKK3U.js +71 -0
- package/dist/{chunk-TOR6SKRB.js → chunk-Y7FYCVUK.js} +508 -48
- package/dist/{chunk-C3KRMTIZ.js → chunk-YJVSN6UN.js} +2 -2
- package/dist/{chunk-EWYLWBKS.js → chunk-YKICVMF7.js} +22 -5
- package/dist/{cli-QDQYUHAP.js → cli-FVUHK2NB.js} +6 -6
- package/dist/{cli-5G2OYTIL.js → cli-ZOY2274X.js} +8 -8
- package/dist/cli.js +6 -5
- package/dist/{completion-3GVNPLZY.js → completion-ZKWGPMEK.js} +5 -4
- package/dist/{diagnostics-2W7QDQNG.js → diagnostics-IM2OPAPL.js} +7 -7
- package/dist/{doctor-3TDO5LJ5.js → doctor-VZTHEPVC.js} +31 -20
- package/dist/{entry-E62DZQJF.js → entry-Q4EI4PNO.js} +13 -13
- package/dist/{exec-mcp-4N7FLY52.js → exec-mcp-AWGUQVT2.js} +14 -12
- package/dist/{harness-E2AUZDLV.js → harness-L4C5XWKR.js} +3 -3
- package/dist/harness-launch-gate.js +5 -5
- package/dist/harness-worker.js +7 -7
- package/dist/{heavy-HZQVFI6P.js → heavy-OG3UVZNY.js} +181 -99
- package/dist/hook-body.js +548 -116
- package/dist/{hook-spec-Bd24eo2L.d.ts → hook-spec-u7hnz571.d.ts} +10 -0
- package/dist/{hooks-VAEAK2FY.js → hooks-2E6PJJQK.js} +4 -4
- package/dist/{host-4GJDGTLW.js → host-OQDBQJB2.js} +8 -8
- package/dist/{host-I2EMQ7UE.js → host-RJJGTKWA.js} +16 -14
- package/dist/{host-run-DDMKD3BU.js → host-run-PWCIXJDN.js} +6 -6
- package/dist/http.js +1 -1
- package/dist/{import-mcp-TNSAMJXI.js → import-mcp-2H2NRUCL.js} +13 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +17 -15
- package/dist/{init-UA7MDNTZ.js → init-O2UCU2WT.js} +2 -2
- package/dist/{invoke-HW7NBPGP.js → invoke-SJ3JHRJU.js} +9 -9
- package/dist/{list-A7VQJXE5.js → list-SJVXZGKK.js} +16 -14
- package/dist/{logout-HNPLUKJY.js → logout-ROKXWR3T.js} +14 -12
- package/dist/{logs-2JEMSNSG.js → logs-J4W6GFMK.js} +4 -4
- package/dist/{mailbox-MR6TPD3P.js → mailbox-6MHH6CUA.js} +4 -4
- package/dist/{mainline-MSLW3UFD.js → mainline-SWZPKA7U.js} +13 -9
- package/dist/{mcp-6C23GX2E.js → mcp-U7MVFAB4.js} +2 -2
- package/dist/owners-MPI22SFU.js +63 -0
- package/dist/{pause-H6ZYZF7C.js → pause-3IMVYXQQ.js} +4 -4
- package/dist/project/hook-adapter.d.ts +1 -1
- package/dist/{project-BX6NCGKB.js → project-MGUYHUF7.js} +4 -4
- package/dist/{report-43SFNNCF.js → report-MWXB5XKE.js} +4 -4
- package/dist/{resume-2BWGSTCN.js → resume-7LCSV4X3.js} +4 -4
- package/dist/{run-2UVAWBAF.js → run-DDWLS6FY.js} +13 -11
- package/dist/{run-7TRWZFEZ.js → run-TBO5JO4Y.js} +4 -4
- package/dist/{serve-4XZ5SKJJ.js → serve-RBQYB3FP.js} +3 -3
- package/dist/{setup-GRWLDBVB.js → setup-7JHWLV7K.js} +6 -4
- package/dist/{smoke-6X6IXQIQ.js → smoke-GZECLXOJ.js} +3 -3
- package/dist/{start-login-AR7ITWNV.js → start-login-SOTNDUP6.js} +14 -12
- package/dist/{status-VQCMJFVE.js → status-EBIUQIGY.js} +18 -16
- package/dist/{status-2GDYLIR3.js → status-QFMN7IUG.js} +4 -4
- package/dist/{status-ZY6LDQSF.js → status-TSTOFNZU.js} +14 -12
- package/dist/stdio.js +2 -2
- package/dist/{sweep-76BUOGEI.js → sweep-BS7HVSNP.js} +4 -4
- package/dist/{test-VWGNFSH5.js → test-4PZHHWOQ.js} +25 -15
- package/dist/{tui-TUMOQBE7.js → tui-QD2LMXHV.js} +4 -4
- package/dist/{unbroadcast-HJHYUHZL.js → unbroadcast-GRGX3F6T.js} +4 -4
- package/dist/{worker-NEEPJRVV.js → worker-SPJ4HFWV.js} +11 -11
- package/dist/{worktree-sync-MUVKK2CV.js → worktree-sync-BQZD4J73.js} +5 -2
- package/docs/commands.md +12 -3
- package/docs/git-workflow.md +40 -5
- package/docs/hooks.md +69 -14
- package/docs/project-configuration.md +63 -4
- package/docs/upgrading.md +13 -0
- package/gemini-extension.json +2 -2
- package/mcp.json +1 -1
- package/package.json +5 -5
- package/plugin.json +1 -1
- package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
- package/plugins/pmcp/.mcp.json +1 -1
- package/plugins/pmcp/gemini-extension.json +2 -2
- package/plugins/pmcp/mcp.json +1 -1
- package/plugins/pmcp/plugin.json +1 -1
- package/dist/chunk-7TD53M7L.js +0 -13
- package/dist/chunk-FQLCD4HU.js +0 -24
- package/dist/chunk-SMBU3QLE.js +0 -7
|
@@ -15,7 +15,7 @@ import "./chunk-NQCAKDRY.js";
|
|
|
15
15
|
import "./chunk-Z6WRFOFT.js";
|
|
16
16
|
import {
|
|
17
17
|
heavySpec
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-OHCUPXU4.js";
|
|
19
19
|
import "./chunk-JPYQDOEW.js";
|
|
20
20
|
import {
|
|
21
21
|
ArgumentError,
|
|
@@ -24,10 +24,13 @@ import {
|
|
|
24
24
|
} from "./chunk-Y6NFETNG.js";
|
|
25
25
|
import {
|
|
26
26
|
BUSY_EXIT,
|
|
27
|
+
DEFAULT_JOB_LOG_BYTES,
|
|
27
28
|
DISABLE_ENV,
|
|
29
|
+
JobLog,
|
|
28
30
|
NOW_ENV,
|
|
29
|
-
leaseSettingsFor
|
|
30
|
-
|
|
31
|
+
leaseSettingsFor,
|
|
32
|
+
readJobLog
|
|
33
|
+
} from "./chunk-PZ6D3WKD.js";
|
|
31
34
|
import {
|
|
32
35
|
LANES,
|
|
33
36
|
describeRecord,
|
|
@@ -57,6 +60,87 @@ import "./chunk-PMJG2CXF.js";
|
|
|
57
60
|
// src/commands/heavy.ts
|
|
58
61
|
import { dirname } from "path";
|
|
59
62
|
|
|
63
|
+
// src/lease/queue.ts
|
|
64
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
65
|
+
|
|
66
|
+
// src/lease/host.ts
|
|
67
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
68
|
+
function hostSources(env) {
|
|
69
|
+
return {
|
|
70
|
+
loadavg: env["PMCP_HEAVY_LOADAVG_FILE"] || "/proc/loadavg",
|
|
71
|
+
pressure: env["PMCP_HEAVY_PRESSURE_FILE"] || "/proc/pressure/io"
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function read(file) {
|
|
75
|
+
try {
|
|
76
|
+
return readFileSync(file, "utf8");
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function readHost(sources) {
|
|
82
|
+
const load = read(sources.loadavg)?.split(" ")[0]?.trim() || null;
|
|
83
|
+
const some = read(sources.pressure)?.match(/^some (.*)$/mu)?.[1] ?? "";
|
|
84
|
+
const pressure = {};
|
|
85
|
+
for (const [, key, value] of some.matchAll(/(avg\d+)=([0-9.]+)/gu))
|
|
86
|
+
pressure[key] = value;
|
|
87
|
+
return { load, io: pressure["avg10"] ?? null, pressure };
|
|
88
|
+
}
|
|
89
|
+
function hostNow(reading) {
|
|
90
|
+
return `load ${reading.load ?? "n/a"} io ${reading.io ?? "n/a"}`;
|
|
91
|
+
}
|
|
92
|
+
function below(value, max) {
|
|
93
|
+
return value === null || Number(value) < max;
|
|
94
|
+
}
|
|
95
|
+
function hostSettled(settings2, paths, sources) {
|
|
96
|
+
const reading = readHost(sources);
|
|
97
|
+
if (!below(reading.load, settings2.maxLoad)) return false;
|
|
98
|
+
const io2 = reading.pressure[settings2.ioWindow] ?? reading.io;
|
|
99
|
+
if (!below(io2, settings2.maxIo)) return false;
|
|
100
|
+
try {
|
|
101
|
+
writeFileSync(paths.settled, `${nowUtc()}
|
|
102
|
+
`);
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
function sleepSeconds(seconds) {
|
|
108
|
+
if (seconds <= 0) return;
|
|
109
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, seconds * 1e3);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/lease/queue.ts
|
|
113
|
+
function sessionOf(env, cwd) {
|
|
114
|
+
const inferred = inferSession(env, [], []).session;
|
|
115
|
+
if (inferred) return inferred;
|
|
116
|
+
try {
|
|
117
|
+
const stat = readFileSync2("/proc/self/stat", "utf8");
|
|
118
|
+
const group = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[2];
|
|
119
|
+
if (group) return `pgid:${group}`;
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
return `cwd:${cwd}`;
|
|
123
|
+
}
|
|
124
|
+
var CAPPED = ["interactive", "bulk"];
|
|
125
|
+
function parkForSession(park) {
|
|
126
|
+
if (park.cap === 0 || !CAPPED.includes(park.lane)) return 0;
|
|
127
|
+
const started = epoch();
|
|
128
|
+
const queued = () => liveWaiters(park.paths).filter(
|
|
129
|
+
(record2) => record2.session === park.session && record2.lane === park.lane
|
|
130
|
+
).length;
|
|
131
|
+
let count = queued();
|
|
132
|
+
if (count < park.cap) return 0;
|
|
133
|
+
park.say(
|
|
134
|
+
`parked outside the queue: this session already has ${count} queued ${park.lane} job(s) (per_session ${park.cap})`
|
|
135
|
+
);
|
|
136
|
+
for (; ; ) {
|
|
137
|
+
if (epoch() - started >= park.maxWait) return null;
|
|
138
|
+
sleepSeconds(1);
|
|
139
|
+
count = queued();
|
|
140
|
+
if (count < park.cap) return epoch() - started;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
60
144
|
// src/lease/run.ts
|
|
61
145
|
import { spawn } from "child_process";
|
|
62
146
|
import { constants } from "os";
|
|
@@ -68,12 +152,12 @@ import { join as join2 } from "path";
|
|
|
68
152
|
|
|
69
153
|
// src/lease/iocontrol.ts
|
|
70
154
|
import { spawnSync } from "child_process";
|
|
71
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
155
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
72
156
|
import { join } from "path";
|
|
73
157
|
function cgroupHost() {
|
|
74
158
|
let self = "";
|
|
75
159
|
try {
|
|
76
|
-
const line =
|
|
160
|
+
const line = readFileSync3("/proc/self/cgroup", "utf8").split("\n").find((entry) => entry.startsWith("0::"));
|
|
77
161
|
self = line?.slice(3) ?? "";
|
|
78
162
|
} catch {
|
|
79
163
|
}
|
|
@@ -81,7 +165,7 @@ function cgroupHost() {
|
|
|
81
165
|
}
|
|
82
166
|
function controllers(dir) {
|
|
83
167
|
try {
|
|
84
|
-
return
|
|
168
|
+
return readFileSync3(join(dir, "cgroup.controllers"), "utf8").trim().split(/\s+/u);
|
|
85
169
|
} catch {
|
|
86
170
|
return [];
|
|
87
171
|
}
|
|
@@ -96,8 +180,8 @@ function ioDelegated(host) {
|
|
|
96
180
|
function enable(dir) {
|
|
97
181
|
const file = join(dir, "cgroup.subtree_control");
|
|
98
182
|
try {
|
|
99
|
-
if (
|
|
100
|
-
|
|
183
|
+
if (readFileSync3(file, "utf8").split(/\s+/u).includes("io")) return;
|
|
184
|
+
writeFileSync2(file, "+io");
|
|
101
185
|
} catch {
|
|
102
186
|
}
|
|
103
187
|
}
|
|
@@ -110,7 +194,7 @@ function applyIo(host, scope, weight, max) {
|
|
|
110
194
|
return { weight: false, max: max ? "failed" : "unset" };
|
|
111
195
|
const write = (file, text) => {
|
|
112
196
|
try {
|
|
113
|
-
|
|
197
|
+
writeFileSync2(join(dir, file), text);
|
|
114
198
|
return true;
|
|
115
199
|
} catch {
|
|
116
200
|
return false;
|
|
@@ -288,85 +372,6 @@ function waiterFile(paths, pid) {
|
|
|
288
372
|
return join3(paths.waiters, String(pid));
|
|
289
373
|
}
|
|
290
374
|
|
|
291
|
-
// src/lease/host.ts
|
|
292
|
-
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
293
|
-
function hostSources(env) {
|
|
294
|
-
return {
|
|
295
|
-
loadavg: env["PMCP_HEAVY_LOADAVG_FILE"] || "/proc/loadavg",
|
|
296
|
-
pressure: env["PMCP_HEAVY_PRESSURE_FILE"] || "/proc/pressure/io"
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function read(file) {
|
|
300
|
-
try {
|
|
301
|
-
return readFileSync2(file, "utf8");
|
|
302
|
-
} catch {
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function readHost(sources) {
|
|
307
|
-
const load = read(sources.loadavg)?.split(" ")[0]?.trim() || null;
|
|
308
|
-
const some = read(sources.pressure)?.match(/^some (.*)$/mu)?.[1] ?? "";
|
|
309
|
-
const pressure = {};
|
|
310
|
-
for (const [, key, value] of some.matchAll(/(avg\d+)=([0-9.]+)/gu))
|
|
311
|
-
pressure[key] = value;
|
|
312
|
-
return { load, io: pressure["avg10"] ?? null, pressure };
|
|
313
|
-
}
|
|
314
|
-
function hostNow(reading) {
|
|
315
|
-
return `load ${reading.load ?? "n/a"} io ${reading.io ?? "n/a"}`;
|
|
316
|
-
}
|
|
317
|
-
function below(value, max) {
|
|
318
|
-
return value === null || Number(value) < max;
|
|
319
|
-
}
|
|
320
|
-
function hostSettled(settings2, paths, sources) {
|
|
321
|
-
const reading = readHost(sources);
|
|
322
|
-
if (!below(reading.load, settings2.maxLoad)) return false;
|
|
323
|
-
const io2 = reading.pressure[settings2.ioWindow] ?? reading.io;
|
|
324
|
-
if (!below(io2, settings2.maxIo)) return false;
|
|
325
|
-
try {
|
|
326
|
-
writeFileSync2(paths.settled, `${nowUtc()}
|
|
327
|
-
`);
|
|
328
|
-
} catch {
|
|
329
|
-
}
|
|
330
|
-
return true;
|
|
331
|
-
}
|
|
332
|
-
function sleepSeconds(seconds) {
|
|
333
|
-
if (seconds <= 0) return;
|
|
334
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, seconds * 1e3);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// src/lease/queue.ts
|
|
338
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
339
|
-
function sessionOf(env, cwd) {
|
|
340
|
-
const inferred = inferSession(env, [], []).session;
|
|
341
|
-
if (inferred) return inferred;
|
|
342
|
-
try {
|
|
343
|
-
const stat = readFileSync3("/proc/self/stat", "utf8");
|
|
344
|
-
const group = stat.slice(stat.lastIndexOf(")") + 2).split(" ")[2];
|
|
345
|
-
if (group) return `pgid:${group}`;
|
|
346
|
-
} catch {
|
|
347
|
-
}
|
|
348
|
-
return `cwd:${cwd}`;
|
|
349
|
-
}
|
|
350
|
-
var CAPPED = ["interactive", "bulk"];
|
|
351
|
-
function parkForSession(park) {
|
|
352
|
-
if (park.cap === 0 || !CAPPED.includes(park.lane)) return 0;
|
|
353
|
-
const started = epoch();
|
|
354
|
-
const queued = () => liveWaiters(park.paths).filter(
|
|
355
|
-
(record2) => record2.session === park.session && record2.lane === park.lane
|
|
356
|
-
).length;
|
|
357
|
-
let count = queued();
|
|
358
|
-
if (count < park.cap) return 0;
|
|
359
|
-
park.say(
|
|
360
|
-
`parked outside the queue: this session already has ${count} queued ${park.lane} job(s) (per_session ${park.cap})`
|
|
361
|
-
);
|
|
362
|
-
for (; ; ) {
|
|
363
|
-
if (epoch() - started >= park.maxWait) return null;
|
|
364
|
-
sleepSeconds(1);
|
|
365
|
-
count = queued();
|
|
366
|
-
if (count < park.cap) return epoch() - started;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
375
|
// src/lease/settle.ts
|
|
371
376
|
function io(settings2, reading) {
|
|
372
377
|
return reading.pressure[settings2.ioWindow] ?? reading.io;
|
|
@@ -977,6 +982,7 @@ var Sampler = class {
|
|
|
977
982
|
};
|
|
978
983
|
|
|
979
984
|
// src/lease/run.ts
|
|
985
|
+
var DRAIN_MS = 2e3;
|
|
980
986
|
var INVALID_EXIT = 2;
|
|
981
987
|
function prefixed(argv, prefix) {
|
|
982
988
|
const name = (word = "") => word.slice(word.lastIndexOf("/") + 1);
|
|
@@ -996,15 +1002,26 @@ var SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
|
996
1002
|
var HEAD = 2048;
|
|
997
1003
|
function execute(argv, run2, extra, watch) {
|
|
998
1004
|
const [bin, ...rest] = argv;
|
|
1005
|
+
const kept = run2.output;
|
|
1006
|
+
const echo = run2.echo !== false;
|
|
999
1007
|
return new Promise((resolve) => {
|
|
1000
1008
|
const child = spawn(bin ?? "true", rest, {
|
|
1001
1009
|
cwd: run2.cwd,
|
|
1002
1010
|
env: { ...run2.env, ...extra },
|
|
1003
|
-
stdio: [
|
|
1011
|
+
stdio: [
|
|
1012
|
+
"inherit",
|
|
1013
|
+
kept ? "pipe" : "inherit",
|
|
1014
|
+
kept || watch.stderrHead ? "pipe" : "inherit"
|
|
1015
|
+
]
|
|
1004
1016
|
});
|
|
1005
1017
|
let head = "";
|
|
1018
|
+
child.stdout?.on("data", (chunk) => {
|
|
1019
|
+
if (echo) process.stdout.write(chunk);
|
|
1020
|
+
kept?.write(chunk);
|
|
1021
|
+
});
|
|
1006
1022
|
child.stderr?.on("data", (chunk) => {
|
|
1007
|
-
process.stderr.write(chunk);
|
|
1023
|
+
if (echo) process.stderr.write(chunk);
|
|
1024
|
+
kept?.write(chunk);
|
|
1008
1025
|
if (head.length >= HEAD) return;
|
|
1009
1026
|
head += chunk.toString("utf8");
|
|
1010
1027
|
watch.stderrHead?.(head.slice(0, HEAD));
|
|
@@ -1013,7 +1030,10 @@ function execute(argv, run2, extra, watch) {
|
|
|
1013
1030
|
const forward = (signal) => child.kill(signal);
|
|
1014
1031
|
for (const signal of SIGNALS) process.on(signal, forward);
|
|
1015
1032
|
const timer = setInterval(() => watch.tick(child.pid), 1e3);
|
|
1033
|
+
let finished = false;
|
|
1016
1034
|
const done = (code) => {
|
|
1035
|
+
if (finished) return;
|
|
1036
|
+
finished = true;
|
|
1017
1037
|
clearInterval(timer);
|
|
1018
1038
|
for (const signal of SIGNALS) process.off(signal, forward);
|
|
1019
1039
|
resolve(code);
|
|
@@ -1023,8 +1043,13 @@ function execute(argv, run2, extra, watch) {
|
|
|
1023
1043
|
done(127);
|
|
1024
1044
|
});
|
|
1025
1045
|
child.on("exit", (code, signal) => {
|
|
1026
|
-
|
|
1027
|
-
|
|
1046
|
+
const exit = code ?? 128 + (signal && constants.signals[signal] || 15);
|
|
1047
|
+
if (!child.stdout && !child.stderr) return done(exit);
|
|
1048
|
+
const drained = setTimeout(() => done(exit), DRAIN_MS);
|
|
1049
|
+
child.on("close", () => {
|
|
1050
|
+
clearTimeout(drained);
|
|
1051
|
+
done(exit);
|
|
1052
|
+
});
|
|
1028
1053
|
});
|
|
1029
1054
|
});
|
|
1030
1055
|
}
|
|
@@ -1481,7 +1506,7 @@ function ticketOwner(dir, id) {
|
|
|
1481
1506
|
);
|
|
1482
1507
|
return typeof request?.session === "string" ? request.session : null;
|
|
1483
1508
|
}
|
|
1484
|
-
function
|
|
1509
|
+
function openTicket(request, blocking) {
|
|
1485
1510
|
prune(request.dir);
|
|
1486
1511
|
const id = `${Math.floor(Date.now() / 1e3)}-${randomBytes(3).toString("hex")}`;
|
|
1487
1512
|
const path = ticketDir(request.dir, id);
|
|
@@ -1492,9 +1517,24 @@ function submit(request) {
|
|
|
1492
1517
|
label: request.label,
|
|
1493
1518
|
cwd: request.cwd,
|
|
1494
1519
|
...request.session ? { session: request.session } : {},
|
|
1520
|
+
...blocking ? { blocking: true } : {},
|
|
1495
1521
|
created: (/* @__PURE__ */ new Date()).toISOString()
|
|
1496
1522
|
});
|
|
1497
|
-
|
|
1523
|
+
return id;
|
|
1524
|
+
}
|
|
1525
|
+
function blockingTicket(request) {
|
|
1526
|
+
const id = openTicket(request, true);
|
|
1527
|
+
writeFileSync4(join5(ticketDir(request.dir, id), "pid"), `${process.pid}
|
|
1528
|
+
`);
|
|
1529
|
+
return id;
|
|
1530
|
+
}
|
|
1531
|
+
function jobLogPath(dir, id) {
|
|
1532
|
+
return join5(ticketDir(dir, id), "log");
|
|
1533
|
+
}
|
|
1534
|
+
function submit(request) {
|
|
1535
|
+
const id = openTicket(request, false);
|
|
1536
|
+
const path = ticketDir(request.dir, id);
|
|
1537
|
+
const log = openSync4(join5(path, "runner.log"), "a");
|
|
1498
1538
|
const [bin, ...args] = request.runner(id);
|
|
1499
1539
|
const child = spawn2(bin, args, {
|
|
1500
1540
|
cwd: request.cwd,
|
|
@@ -1547,8 +1587,7 @@ function recentTickets(dir) {
|
|
|
1547
1587
|
}
|
|
1548
1588
|
function logTail(dir, id, lines = 20) {
|
|
1549
1589
|
try {
|
|
1550
|
-
|
|
1551
|
-
return text.split("\n").slice(-lines - 1).join("\n");
|
|
1590
|
+
return readJobLog(jobLogPath(dir, id)).split("\n").slice(-lines - 1).join("\n");
|
|
1552
1591
|
} catch {
|
|
1553
1592
|
return "";
|
|
1554
1593
|
}
|
|
@@ -1922,6 +1961,16 @@ function viewOf(settings2, id) {
|
|
|
1922
1961
|
}
|
|
1923
1962
|
function ticketResult(context, settings2, id) {
|
|
1924
1963
|
const view = viewOf(settings2, id);
|
|
1964
|
+
const tailText = one(context.args, "tail");
|
|
1965
|
+
if (tailText !== void 0 && !context.args.flags.has("log"))
|
|
1966
|
+
throw new ArgumentError("--tail goes with --log");
|
|
1967
|
+
if (context.args.flags.has("log")) {
|
|
1968
|
+
const tail2 = tailText === void 0 ? void 0 : Number(tailText);
|
|
1969
|
+
if (tail2 !== void 0 && !(Number.isInteger(tail2) && tail2 >= 1))
|
|
1970
|
+
throw new ArgumentError("--tail is a whole number of at least 1");
|
|
1971
|
+
context.ui.data(readJobLog(jobLogPath(settings2.dir, view.id), tail2));
|
|
1972
|
+
return EXIT.ok;
|
|
1973
|
+
}
|
|
1925
1974
|
if (context.args.flags.has("json"))
|
|
1926
1975
|
context.ui.data(`${JSON.stringify({ version: 1, ...view })}
|
|
1927
1976
|
`);
|
|
@@ -2085,7 +2134,9 @@ async function run(context) {
|
|
|
2085
2134
|
return submitTicket(context, lease, args.passthrough);
|
|
2086
2135
|
}
|
|
2087
2136
|
if (now) requireOperatorFor(context, "pmcp heavy --now");
|
|
2088
|
-
const
|
|
2137
|
+
const submitted = one(args, "ticket");
|
|
2138
|
+
const kept = keepOutput(context, lease, label, submitted);
|
|
2139
|
+
const ticket = submitted ?? kept?.id;
|
|
2089
2140
|
let result = null;
|
|
2090
2141
|
const config = one(args, "config") ?? findConfig(context.cwd);
|
|
2091
2142
|
const code = await runHeavy({
|
|
@@ -2101,13 +2152,19 @@ async function run(context) {
|
|
|
2101
2152
|
argv: args.passthrough,
|
|
2102
2153
|
cwd: context.cwd,
|
|
2103
2154
|
env: context.env,
|
|
2104
|
-
say
|
|
2155
|
+
say: (line) => {
|
|
2156
|
+
say(line);
|
|
2157
|
+
kept?.log.write(`pmcp heavy: ${line}
|
|
2158
|
+
`);
|
|
2159
|
+
},
|
|
2160
|
+
...kept ? { output: kept.log, echo: submitted === void 0 } : {},
|
|
2105
2161
|
...ticket ? {
|
|
2106
2162
|
onUsage: (usage) => {
|
|
2107
2163
|
result = { version: 1, ticket, ...usage };
|
|
2108
2164
|
}
|
|
2109
2165
|
} : {}
|
|
2110
2166
|
});
|
|
2167
|
+
kept?.log.close();
|
|
2111
2168
|
if (ticket)
|
|
2112
2169
|
writeResult(
|
|
2113
2170
|
lease.dir,
|
|
@@ -2115,10 +2172,35 @@ async function run(context) {
|
|
|
2115
2172
|
result ?? { version: 1, ticket, exit: code, outcome: "ran" },
|
|
2116
2173
|
true
|
|
2117
2174
|
);
|
|
2175
|
+
if (kept && submitted === void 0 && code !== 0)
|
|
2176
|
+
say(`output kept: pmcp heavy result ${kept.id} --log`);
|
|
2118
2177
|
return code;
|
|
2119
2178
|
}
|
|
2179
|
+
function keepOutput(context, lease, label, submitted) {
|
|
2180
|
+
const cap = lease.jobLogBytes ?? DEFAULT_JOB_LOG_BYTES;
|
|
2181
|
+
try {
|
|
2182
|
+
if (submitted !== void 0)
|
|
2183
|
+
return {
|
|
2184
|
+
id: submitted,
|
|
2185
|
+
log: new JobLog(
|
|
2186
|
+
jobLogPath(lease.dir, submitted),
|
|
2187
|
+
cap || DEFAULT_JOB_LOG_BYTES
|
|
2188
|
+
)
|
|
2189
|
+
};
|
|
2190
|
+
if (cap === 0 || !lease.enabled) return null;
|
|
2191
|
+
const id = blockingTicket({
|
|
2192
|
+
dir: lease.dir,
|
|
2193
|
+
label: label ?? context.args.passthrough.join(" "),
|
|
2194
|
+
cwd: context.cwd,
|
|
2195
|
+
session: sessionOf(context.env, context.cwd)
|
|
2196
|
+
});
|
|
2197
|
+
return { id, log: new JobLog(jobLogPath(lease.dir, id), cap) };
|
|
2198
|
+
} catch {
|
|
2199
|
+
return null;
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2120
2202
|
var heavyCommand = { ...heavySpec, run };
|
|
2121
2203
|
export {
|
|
2122
2204
|
heavyCommand
|
|
2123
2205
|
};
|
|
2124
|
-
//# sourceMappingURL=heavy-
|
|
2206
|
+
//# sourceMappingURL=heavy-OG3UVZNY.js.map
|