lobstah 0.8.5 → 0.8.6
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/dist/main.js +2445 -1859
- package/dist/runner.js +258 -258
- package/docs/design.md +30 -16
- package/docs/man.md +7 -1
- package/package.json +1 -1
package/dist/runner.js
CHANGED
|
@@ -75,7 +75,7 @@ function evidencePath(id, lane) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// packages/core/dist/config.js
|
|
78
|
-
import * as
|
|
78
|
+
import * as fs29 from "node:fs";
|
|
79
79
|
|
|
80
80
|
// packages/core/dist/configured-traps.js
|
|
81
81
|
import * as fs2 from "node:fs";
|
|
@@ -133,7 +133,7 @@ function parseConfiguredTraps(raw, grounds) {
|
|
|
133
133
|
|
|
134
134
|
// packages/core/dist/config.js
|
|
135
135
|
import * as os4 from "node:os";
|
|
136
|
-
import * as
|
|
136
|
+
import * as path25 from "node:path";
|
|
137
137
|
|
|
138
138
|
// node_modules/.pnpm/smol-toml@1.8.0/node_modules/smol-toml/dist/date.js
|
|
139
139
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
@@ -826,8 +826,8 @@ function firstMeaningfulLine(...outputs) {
|
|
|
826
826
|
}
|
|
827
827
|
|
|
828
828
|
// packages/core/dist/pr-poll.js
|
|
829
|
-
import * as
|
|
830
|
-
import * as
|
|
829
|
+
import * as fs28 from "node:fs";
|
|
830
|
+
import * as path24 from "node:path";
|
|
831
831
|
|
|
832
832
|
// packages/core/dist/dir-lock.js
|
|
833
833
|
import fs3 from "node:fs";
|
|
@@ -991,12 +991,12 @@ function readPrs() {
|
|
|
991
991
|
}
|
|
992
992
|
|
|
993
993
|
// packages/core/dist/watch.js
|
|
994
|
-
import
|
|
995
|
-
import * as
|
|
994
|
+
import fs27 from "node:fs";
|
|
995
|
+
import * as path23 from "node:path";
|
|
996
996
|
|
|
997
997
|
// packages/core/dist/notices.js
|
|
998
|
-
import
|
|
999
|
-
import * as
|
|
998
|
+
import fs25 from "node:fs";
|
|
999
|
+
import * as path21 from "node:path";
|
|
1000
1000
|
|
|
1001
1001
|
// packages/core/dist/attachments.js
|
|
1002
1002
|
function attachmentBlock(attachments) {
|
|
@@ -1009,6 +1009,47 @@ function attachmentBlock(attachments) {
|
|
|
1009
1009
|
].join("\n");
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
|
+
// packages/core/dist/reports.js
|
|
1013
|
+
import * as fs5 from "node:fs";
|
|
1014
|
+
import * as path5 from "node:path";
|
|
1015
|
+
var REPORT_MD = "report.md";
|
|
1016
|
+
var REPORT_JSON = "report.json";
|
|
1017
|
+
function helmReportsRoot() {
|
|
1018
|
+
return path5.join(lobstahHome(), "reports");
|
|
1019
|
+
}
|
|
1020
|
+
function dispatchReportKey(id, lane) {
|
|
1021
|
+
return `report:${lane}:${id}`;
|
|
1022
|
+
}
|
|
1023
|
+
var GROUNDS_RE = /^[A-Za-z0-9._-]+$/;
|
|
1024
|
+
var RID_RE = /^[a-f0-9]{8}$/;
|
|
1025
|
+
function reportDir(key) {
|
|
1026
|
+
const d = /^report:(work|chore):([A-Za-z0-9-]+)$/.exec(key);
|
|
1027
|
+
if (d)
|
|
1028
|
+
return path5.join(laneDirs(d[1]).state, d[2]);
|
|
1029
|
+
const h = /^report:helm:([^:]+):([^:]+)$/.exec(key);
|
|
1030
|
+
if (h && GROUNDS_RE.test(h[1]) && !h[1].startsWith(".") && RID_RE.test(h[2]))
|
|
1031
|
+
return path5.join(helmReportsRoot(), h[1], h[2]);
|
|
1032
|
+
return void 0;
|
|
1033
|
+
}
|
|
1034
|
+
function readReportAt(dir) {
|
|
1035
|
+
try {
|
|
1036
|
+
const meta = JSON.parse(fs5.readFileSync(path5.join(dir, REPORT_JSON), "utf8"));
|
|
1037
|
+
return typeof meta.key === "string" && typeof meta.filedAt === "string" ? meta : void 0;
|
|
1038
|
+
} catch {
|
|
1039
|
+
return void 0;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
function readReport(key) {
|
|
1043
|
+
const dir = reportDir(key);
|
|
1044
|
+
const meta = dir ? readReportAt(dir) : void 0;
|
|
1045
|
+
return meta?.key === key ? meta : void 0;
|
|
1046
|
+
}
|
|
1047
|
+
function reportMarkdownPath(key) {
|
|
1048
|
+
const dir = reportDir(key);
|
|
1049
|
+
const file2 = dir && path5.join(dir, REPORT_MD);
|
|
1050
|
+
return file2 && readReport(key) && fs5.existsSync(file2) ? file2 : void 0;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1012
1053
|
// packages/core/dist/decisions.js
|
|
1013
1054
|
var DECISION_DETAIL_MAX = 64 * 1024;
|
|
1014
1055
|
var ANSWER_TYPES = {
|
|
@@ -1033,19 +1074,19 @@ var ANSWER_TYPES = {
|
|
|
1033
1074
|
var ANSWER_EXTENSIONS = Object.keys(ANSWER_TYPES);
|
|
1034
1075
|
|
|
1035
1076
|
// packages/core/dist/roster.js
|
|
1036
|
-
import * as
|
|
1037
|
-
import * as
|
|
1077
|
+
import * as fs6 from "node:fs";
|
|
1078
|
+
import * as path6 from "node:path";
|
|
1038
1079
|
function rosterDir() {
|
|
1039
|
-
return
|
|
1080
|
+
return path6.join(lobstahHome(), "roster");
|
|
1040
1081
|
}
|
|
1041
1082
|
function rosterPath(trapId) {
|
|
1042
|
-
return
|
|
1083
|
+
return path6.join(rosterDir(), `${trapId}.json`);
|
|
1043
1084
|
}
|
|
1044
1085
|
function readRoster(trapId) {
|
|
1045
1086
|
if (!/^[a-z0-9-]+$/.test(trapId))
|
|
1046
1087
|
return void 0;
|
|
1047
1088
|
try {
|
|
1048
|
-
const parsed = JSON.parse(
|
|
1089
|
+
const parsed = JSON.parse(fs6.readFileSync(rosterPath(trapId), "utf8"));
|
|
1049
1090
|
return parsed.trapId === trapId && typeof parsed.name === "string" ? parsed : void 0;
|
|
1050
1091
|
} catch {
|
|
1051
1092
|
return void 0;
|
|
@@ -1054,7 +1095,7 @@ function readRoster(trapId) {
|
|
|
1054
1095
|
function listRoster() {
|
|
1055
1096
|
let files;
|
|
1056
1097
|
try {
|
|
1057
|
-
files =
|
|
1098
|
+
files = fs6.readdirSync(rosterDir()).filter((f) => f.endsWith(".json"));
|
|
1058
1099
|
} catch {
|
|
1059
1100
|
return [];
|
|
1060
1101
|
}
|
|
@@ -1062,14 +1103,14 @@ function listRoster() {
|
|
|
1062
1103
|
}
|
|
1063
1104
|
|
|
1064
1105
|
// packages/core/dist/desktop-lease.js
|
|
1065
|
-
import
|
|
1066
|
-
import
|
|
1106
|
+
import fs7 from "node:fs";
|
|
1107
|
+
import path7 from "node:path";
|
|
1067
1108
|
function desktopLeaseFile() {
|
|
1068
|
-
return
|
|
1109
|
+
return path7.join(lobstahHome(), "desktop-lease.json");
|
|
1069
1110
|
}
|
|
1070
1111
|
function readDesktopLease() {
|
|
1071
1112
|
try {
|
|
1072
|
-
return JSON.parse(
|
|
1113
|
+
return JSON.parse(fs7.readFileSync(desktopLeaseFile(), "utf8"));
|
|
1073
1114
|
} catch {
|
|
1074
1115
|
return void 0;
|
|
1075
1116
|
}
|
|
@@ -1079,7 +1120,7 @@ function withDesktopLeaseLock(action) {
|
|
|
1079
1120
|
}
|
|
1080
1121
|
function writeDesktopLease(registration, now2) {
|
|
1081
1122
|
const file2 = desktopLeaseFile(), temporary = uniqueTempPath(file2);
|
|
1082
|
-
|
|
1123
|
+
fs7.writeFileSync(temporary, JSON.stringify({ trapId: registration.trapId, sessionId: registration.sessionId, expiresAt: now2 + loadConfig().soak.ttlSecs * 1e3 }));
|
|
1083
1124
|
atomicRenameSync(temporary, file2);
|
|
1084
1125
|
}
|
|
1085
1126
|
function acquireDesktopLease(registration, now2 = Date.now()) {
|
|
@@ -1099,18 +1140,18 @@ function acquireDesktopLease(registration, now2 = Date.now()) {
|
|
|
1099
1140
|
function releaseDesktopLease(trapId) {
|
|
1100
1141
|
withDesktopLeaseLock(() => {
|
|
1101
1142
|
if (readDesktopLease()?.trapId === trapId)
|
|
1102
|
-
|
|
1143
|
+
fs7.rmSync(desktopLeaseFile(), { force: true });
|
|
1103
1144
|
});
|
|
1104
1145
|
}
|
|
1105
1146
|
|
|
1106
1147
|
// packages/core/dist/soak.js
|
|
1107
|
-
import * as
|
|
1108
|
-
import * as
|
|
1148
|
+
import * as fs21 from "node:fs";
|
|
1149
|
+
import * as path18 from "node:path";
|
|
1109
1150
|
|
|
1110
1151
|
// packages/core/dist/heavy.js
|
|
1111
1152
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
1112
|
-
import
|
|
1113
|
-
import * as
|
|
1153
|
+
import fs8 from "node:fs";
|
|
1154
|
+
import * as path8 from "node:path";
|
|
1114
1155
|
|
|
1115
1156
|
// packages/core/dist/harness-process.js
|
|
1116
1157
|
import { execFileSync } from "node:child_process";
|
|
@@ -1134,12 +1175,12 @@ var HEAVY_WAITER_GRACE_MS = 5 * 6e4;
|
|
|
1134
1175
|
var UNVERIFIED_SEEN_MS = 30 * 6e4;
|
|
1135
1176
|
var START_CACHE_MS = 2e4;
|
|
1136
1177
|
var HISTORY_MAX_BYTES = 1024 * 1024;
|
|
1137
|
-
var heavyDir = () =>
|
|
1138
|
-
var lineDir = () =>
|
|
1139
|
-
var ticketFile = (seq) =>
|
|
1178
|
+
var heavyDir = () => path8.join(lobstahHome(), "heavy");
|
|
1179
|
+
var lineDir = () => path8.join(heavyDir(), "line");
|
|
1180
|
+
var ticketFile = (seq) => path8.join(lineDir(), `${String(seq).padStart(10, "0")}.json`);
|
|
1140
1181
|
function withLine(action) {
|
|
1141
|
-
|
|
1142
|
-
return withDirLock(
|
|
1182
|
+
fs8.mkdirSync(lineDir(), { recursive: true });
|
|
1183
|
+
return withDirLock(path8.join(heavyDir(), "lock"), action, {
|
|
1143
1184
|
staleMs: 3e4,
|
|
1144
1185
|
waitMs: 15e3,
|
|
1145
1186
|
pauseMs: 25,
|
|
@@ -1149,27 +1190,27 @@ function withLine(action) {
|
|
|
1149
1190
|
function writeTicket(ticket) {
|
|
1150
1191
|
const file2 = ticketFile(ticket.seq);
|
|
1151
1192
|
const tmp = uniqueTempPath(file2);
|
|
1152
|
-
|
|
1193
|
+
fs8.writeFileSync(tmp, JSON.stringify(ticket, null, 2));
|
|
1153
1194
|
atomicRenameSync(tmp, file2);
|
|
1154
1195
|
}
|
|
1155
1196
|
function readLine() {
|
|
1156
1197
|
let names;
|
|
1157
1198
|
try {
|
|
1158
|
-
names =
|
|
1199
|
+
names = fs8.readdirSync(lineDir());
|
|
1159
1200
|
} catch {
|
|
1160
1201
|
return [];
|
|
1161
1202
|
}
|
|
1162
1203
|
const out = [];
|
|
1163
1204
|
for (const name of names.filter((n) => n.endsWith(".json"))) {
|
|
1164
|
-
const file2 =
|
|
1205
|
+
const file2 = path8.join(lineDir(), name);
|
|
1165
1206
|
try {
|
|
1166
|
-
const t = JSON.parse(
|
|
1207
|
+
const t = JSON.parse(fs8.readFileSync(file2, "utf8"));
|
|
1167
1208
|
if (!Number.isInteger(t.seq) || !Number.isInteger(t.pid))
|
|
1168
1209
|
throw new Error("not a ticket");
|
|
1169
1210
|
out.push(t);
|
|
1170
1211
|
} catch (err) {
|
|
1171
1212
|
if (err.code !== "ENOENT")
|
|
1172
|
-
|
|
1213
|
+
fs8.rmSync(file2, { force: true });
|
|
1173
1214
|
}
|
|
1174
1215
|
}
|
|
1175
1216
|
return out.sort((a, b) => a.seq - b.seq);
|
|
@@ -1244,11 +1285,11 @@ function liveHeavyTickets(match, now2 = Date.now()) {
|
|
|
1244
1285
|
var CHUNK = 1 << 20;
|
|
1245
1286
|
|
|
1246
1287
|
// packages/core/dist/status.js
|
|
1247
|
-
import * as
|
|
1288
|
+
import * as fs19 from "node:fs";
|
|
1248
1289
|
|
|
1249
1290
|
// packages/core/dist/activity.js
|
|
1250
|
-
import * as
|
|
1251
|
-
import * as
|
|
1291
|
+
import * as fs9 from "node:fs";
|
|
1292
|
+
import * as path9 from "node:path";
|
|
1252
1293
|
var ACTIVITY_KINDS = ["tool", "message", "thinking", "waiting"];
|
|
1253
1294
|
var ACTIVITY_SUMMARY_MAX = 80;
|
|
1254
1295
|
var SECRET_PATTERNS = [
|
|
@@ -1302,7 +1343,7 @@ function relativeTarget(p, root) {
|
|
|
1302
1343
|
if (!root)
|
|
1303
1344
|
return baseName(p);
|
|
1304
1345
|
const win = isWindowsPath(p) || isWindowsPath(root);
|
|
1305
|
-
const lib = win ?
|
|
1346
|
+
const lib = win ? path9.win32 : path9.posix;
|
|
1306
1347
|
if (!lib.isAbsolute(p))
|
|
1307
1348
|
return p.replace(/\\/g, "/");
|
|
1308
1349
|
const rel = lib.relative(win ? root : root.replace(/\\/g, "/"), p);
|
|
@@ -1371,7 +1412,7 @@ function activityFromEvent(ev, root) {
|
|
|
1371
1412
|
}
|
|
1372
1413
|
function atomicWrite(file2, content) {
|
|
1373
1414
|
const tmp = uniqueTempPath(file2);
|
|
1374
|
-
|
|
1415
|
+
fs9.writeFileSync(tmp, content);
|
|
1375
1416
|
atomicRenameSync(tmp, file2);
|
|
1376
1417
|
}
|
|
1377
1418
|
function writeActivity(id, lane, a) {
|
|
@@ -1380,7 +1421,7 @@ function writeActivity(id, lane, a) {
|
|
|
1380
1421
|
}
|
|
1381
1422
|
function readActivity(id, lane) {
|
|
1382
1423
|
try {
|
|
1383
|
-
const parsed = JSON.parse(
|
|
1424
|
+
const parsed = JSON.parse(fs9.readFileSync(activityPath(id, lane), "utf8"));
|
|
1384
1425
|
if (typeof parsed.at !== "string" || typeof parsed.summary !== "string")
|
|
1385
1426
|
return void 0;
|
|
1386
1427
|
if (!ACTIVITY_KINDS.includes(parsed.kind))
|
|
@@ -1454,8 +1495,8 @@ var ActivityTracker = class {
|
|
|
1454
1495
|
};
|
|
1455
1496
|
|
|
1456
1497
|
// packages/core/dist/stats.js
|
|
1457
|
-
import * as
|
|
1458
|
-
import * as
|
|
1498
|
+
import * as fs16 from "node:fs";
|
|
1499
|
+
import * as path14 from "node:path";
|
|
1459
1500
|
|
|
1460
1501
|
// packages/core/dist/worker-metadata.js
|
|
1461
1502
|
var WORKER_EFFORTS = ["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"];
|
|
@@ -1548,18 +1589,18 @@ function sanitizeWorker(value) {
|
|
|
1548
1589
|
}
|
|
1549
1590
|
|
|
1550
1591
|
// packages/core/dist/catch-context.js
|
|
1551
|
-
import * as
|
|
1552
|
-
import * as
|
|
1592
|
+
import * as fs15 from "node:fs";
|
|
1593
|
+
import * as path13 from "node:path";
|
|
1553
1594
|
|
|
1554
1595
|
// packages/core/dist/helm.js
|
|
1555
|
-
import * as
|
|
1556
|
-
import * as
|
|
1596
|
+
import * as fs14 from "node:fs";
|
|
1597
|
+
import * as path12 from "node:path";
|
|
1557
1598
|
|
|
1558
1599
|
// packages/core/dist/disk.js
|
|
1559
|
-
import * as
|
|
1600
|
+
import * as fs10 from "node:fs";
|
|
1560
1601
|
var GB = 1024 ** 3;
|
|
1561
1602
|
var statfsFreeBytes = (dir) => {
|
|
1562
|
-
const s =
|
|
1603
|
+
const s = fs10.statfsSync(dir);
|
|
1563
1604
|
return Number(s.bavail) * Number(s.bsize);
|
|
1564
1605
|
};
|
|
1565
1606
|
function formatGB(bytes) {
|
|
@@ -1567,18 +1608,18 @@ function formatGB(bytes) {
|
|
|
1567
1608
|
}
|
|
1568
1609
|
|
|
1569
1610
|
// packages/core/dist/pools.js
|
|
1570
|
-
import * as
|
|
1571
|
-
import * as
|
|
1611
|
+
import * as fs13 from "node:fs";
|
|
1612
|
+
import * as path11 from "node:path";
|
|
1572
1613
|
|
|
1573
1614
|
// packages/core/dist/worktrees.js
|
|
1574
|
-
import * as
|
|
1575
|
-
import * as
|
|
1615
|
+
import * as fs12 from "node:fs";
|
|
1616
|
+
import * as path10 from "node:path";
|
|
1576
1617
|
|
|
1577
1618
|
// packages/core/dist/evidence.js
|
|
1578
|
-
import * as
|
|
1619
|
+
import * as fs11 from "node:fs";
|
|
1579
1620
|
function readEvidence(id, lane) {
|
|
1580
1621
|
try {
|
|
1581
|
-
return JSON.parse(
|
|
1622
|
+
return JSON.parse(fs11.readFileSync(evidencePath(id, lane), "utf8"));
|
|
1582
1623
|
} catch {
|
|
1583
1624
|
return {};
|
|
1584
1625
|
}
|
|
@@ -1586,26 +1627,26 @@ function readEvidence(id, lane) {
|
|
|
1586
1627
|
function mergeEvidence(id, lane, patch) {
|
|
1587
1628
|
const file2 = evidencePath(id, lane);
|
|
1588
1629
|
const tmp = uniqueTempPath(file2);
|
|
1589
|
-
|
|
1630
|
+
fs11.writeFileSync(tmp, JSON.stringify({ ...readEvidence(id, lane), ...patch }, null, 2));
|
|
1590
1631
|
atomicRenameSync(tmp, file2);
|
|
1591
1632
|
}
|
|
1592
1633
|
|
|
1593
1634
|
// packages/core/dist/worktrees.js
|
|
1594
1635
|
var LANES = ["work", "chore"];
|
|
1595
1636
|
function worktreePath(id) {
|
|
1596
|
-
return
|
|
1637
|
+
return path10.join(lobstahHome(), "worktrees", id);
|
|
1597
1638
|
}
|
|
1598
1639
|
function readRecord(file2) {
|
|
1599
1640
|
try {
|
|
1600
|
-
const r = JSON.parse(
|
|
1641
|
+
const r = JSON.parse(fs12.readFileSync(file2, "utf8"));
|
|
1601
1642
|
return typeof r.path === "string" ? r : void 0;
|
|
1602
1643
|
} catch {
|
|
1603
1644
|
return void 0;
|
|
1604
1645
|
}
|
|
1605
1646
|
}
|
|
1606
1647
|
function ownerOfPath(p) {
|
|
1607
|
-
const rel =
|
|
1608
|
-
if (!rel || rel.startsWith("..") ||
|
|
1648
|
+
const rel = path10.relative(path10.join(lobstahHome(), "worktrees"), p);
|
|
1649
|
+
if (!rel || rel.startsWith("..") || path10.isAbsolute(rel))
|
|
1609
1650
|
return void 0;
|
|
1610
1651
|
return rel.split(/[\\/]/)[0];
|
|
1611
1652
|
}
|
|
@@ -1618,7 +1659,7 @@ function dispatchWorktree(id, lane) {
|
|
|
1618
1659
|
}
|
|
1619
1660
|
const dirs = laneDirs(l);
|
|
1620
1661
|
for (const dir of [dirs.active, dirs.done]) {
|
|
1621
|
-
const rec = readRecord(
|
|
1662
|
+
const rec = readRecord(path10.join(dir, id, "worktree.json"));
|
|
1622
1663
|
if (rec) {
|
|
1623
1664
|
const owner = rec.of ?? ownerOfPath(rec.path) ?? id;
|
|
1624
1665
|
return { path: rec.path, owner, reused: owner !== id };
|
|
@@ -1630,7 +1671,7 @@ function dispatchWorktree(id, lane) {
|
|
|
1630
1671
|
function laneOf(id) {
|
|
1631
1672
|
for (const l of LANES) {
|
|
1632
1673
|
const d = laneDirs(l);
|
|
1633
|
-
if (
|
|
1674
|
+
if (fs12.existsSync(path10.join(d.queue, `${id}.json`)) || fs12.existsSync(path10.join(d.active, id)) || fs12.existsSync(path10.join(d.done, id))) {
|
|
1634
1675
|
return l;
|
|
1635
1676
|
}
|
|
1636
1677
|
}
|
|
@@ -1650,7 +1691,7 @@ function followUpAncestors(id, lane) {
|
|
|
1650
1691
|
function chainWorktree(followUp) {
|
|
1651
1692
|
for (const id of [followUp, ...followUpAncestors(followUp)]) {
|
|
1652
1693
|
const wt = dispatchWorktree(id, laneOf(id));
|
|
1653
|
-
if (
|
|
1694
|
+
if (fs12.existsSync(wt.path))
|
|
1654
1695
|
return { ...wt, from: id };
|
|
1655
1696
|
}
|
|
1656
1697
|
return void 0;
|
|
@@ -1665,27 +1706,27 @@ function processAlive(pid) {
|
|
|
1665
1706
|
}
|
|
1666
1707
|
}
|
|
1667
1708
|
function worktreeGitDir(wt) {
|
|
1668
|
-
const dotGit =
|
|
1709
|
+
const dotGit = path10.join(wt, ".git");
|
|
1669
1710
|
try {
|
|
1670
|
-
const st =
|
|
1711
|
+
const st = fs12.statSync(dotGit);
|
|
1671
1712
|
if (st.isDirectory())
|
|
1672
1713
|
return dotGit;
|
|
1673
|
-
const m = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
1674
|
-
return m ?
|
|
1714
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(fs12.readFileSync(dotGit, "utf8"));
|
|
1715
|
+
return m ? path10.resolve(wt, m[1]) : void 0;
|
|
1675
1716
|
} catch {
|
|
1676
1717
|
return void 0;
|
|
1677
1718
|
}
|
|
1678
1719
|
}
|
|
1679
1720
|
function worktreeLockFile(wt) {
|
|
1680
1721
|
const gitDir = worktreeGitDir(wt);
|
|
1681
|
-
return gitDir ?
|
|
1722
|
+
return gitDir ? path10.join(gitDir, "lobstah.lock") : void 0;
|
|
1682
1723
|
}
|
|
1683
1724
|
function readWorktreeLock(wt) {
|
|
1684
1725
|
const file2 = worktreeLockFile(wt);
|
|
1685
1726
|
if (!file2)
|
|
1686
1727
|
return void 0;
|
|
1687
1728
|
try {
|
|
1688
|
-
return JSON.parse(
|
|
1729
|
+
return JSON.parse(fs12.readFileSync(file2, "utf8"));
|
|
1689
1730
|
} catch {
|
|
1690
1731
|
return void 0;
|
|
1691
1732
|
}
|
|
@@ -1693,7 +1734,7 @@ function readWorktreeLock(wt) {
|
|
|
1693
1734
|
function lockIsLive(lock) {
|
|
1694
1735
|
if (lock.kind === "warm")
|
|
1695
1736
|
return processAlive(lock.pid) && Date.now() - (Date.parse(lock.at) || 0) < WARM_LOCK_MAX_MS;
|
|
1696
|
-
return
|
|
1737
|
+
return fs12.existsSync(path10.join(laneDirs(lock.lane).active, lock.id));
|
|
1697
1738
|
}
|
|
1698
1739
|
function worktreeHolder(wt) {
|
|
1699
1740
|
const lock = readWorktreeLock(wt);
|
|
@@ -1706,7 +1747,7 @@ function acquireWorktreeLock(wt, id, lane, kind) {
|
|
|
1706
1747
|
return { id: "(no git dir)", lane, pid: 0, at: mine.at };
|
|
1707
1748
|
for (let attempt2 = 0; attempt2 < 3; attempt2++) {
|
|
1708
1749
|
try {
|
|
1709
|
-
|
|
1750
|
+
fs12.writeFileSync(file2, JSON.stringify(mine, null, 2), { flag: "wx" });
|
|
1710
1751
|
return void 0;
|
|
1711
1752
|
} catch (err) {
|
|
1712
1753
|
if (err.code !== "EEXIST")
|
|
@@ -1714,7 +1755,7 @@ function acquireWorktreeLock(wt, id, lane, kind) {
|
|
|
1714
1755
|
}
|
|
1715
1756
|
let raw;
|
|
1716
1757
|
try {
|
|
1717
|
-
raw =
|
|
1758
|
+
raw = fs12.readFileSync(file2, "utf8");
|
|
1718
1759
|
} catch {
|
|
1719
1760
|
continue;
|
|
1720
1761
|
}
|
|
@@ -1725,14 +1766,14 @@ function acquireWorktreeLock(wt, id, lane, kind) {
|
|
|
1725
1766
|
held2 = void 0;
|
|
1726
1767
|
}
|
|
1727
1768
|
if (held2?.id === id) {
|
|
1728
|
-
|
|
1769
|
+
fs12.writeFileSync(file2, JSON.stringify(mine, null, 2));
|
|
1729
1770
|
return void 0;
|
|
1730
1771
|
}
|
|
1731
1772
|
if (held2 && lockIsLive(held2))
|
|
1732
1773
|
return held2;
|
|
1733
1774
|
try {
|
|
1734
|
-
if (
|
|
1735
|
-
|
|
1775
|
+
if (fs12.readFileSync(file2, "utf8") === raw)
|
|
1776
|
+
fs12.rmSync(file2, { force: true });
|
|
1736
1777
|
} catch {
|
|
1737
1778
|
}
|
|
1738
1779
|
}
|
|
@@ -1744,7 +1785,7 @@ function releaseWorktreeLock(wt, id) {
|
|
|
1744
1785
|
if (!file2)
|
|
1745
1786
|
return;
|
|
1746
1787
|
if (readWorktreeLock(wt)?.id === id)
|
|
1747
|
-
|
|
1788
|
+
fs12.rmSync(file2, { force: true });
|
|
1748
1789
|
}
|
|
1749
1790
|
|
|
1750
1791
|
// packages/core/dist/slots.js
|
|
@@ -1758,28 +1799,28 @@ function isFinished(id, lane) {
|
|
|
1758
1799
|
|
|
1759
1800
|
// packages/core/dist/pools.js
|
|
1760
1801
|
function poolsRoot() {
|
|
1761
|
-
return
|
|
1802
|
+
return path11.join(lobstahHome(), "pools");
|
|
1762
1803
|
}
|
|
1763
1804
|
function poolDir(pool) {
|
|
1764
|
-
return
|
|
1805
|
+
return path11.join(poolsRoot(), pool);
|
|
1765
1806
|
}
|
|
1766
1807
|
function poolSlotPath(pool, slot) {
|
|
1767
|
-
return
|
|
1808
|
+
return path11.join(poolDir(pool), String(slot));
|
|
1768
1809
|
}
|
|
1769
1810
|
function slotsDir(pool) {
|
|
1770
|
-
return
|
|
1811
|
+
return path11.join(poolDir(pool), ".slots");
|
|
1771
1812
|
}
|
|
1772
1813
|
function poolSlotOf(p) {
|
|
1773
1814
|
const real = (x) => {
|
|
1774
1815
|
try {
|
|
1775
|
-
return
|
|
1816
|
+
return fs13.realpathSync.native(x);
|
|
1776
1817
|
} catch {
|
|
1777
|
-
return
|
|
1818
|
+
return path11.resolve(x);
|
|
1778
1819
|
}
|
|
1779
1820
|
};
|
|
1780
|
-
for (const [rootDir, dir] of [[poolsRoot(),
|
|
1781
|
-
const rel =
|
|
1782
|
-
if (!rel || rel.startsWith("..") ||
|
|
1821
|
+
for (const [rootDir, dir] of [[poolsRoot(), path11.resolve(p)], [real(poolsRoot()), real(p)]]) {
|
|
1822
|
+
const rel = path11.relative(rootDir, dir);
|
|
1823
|
+
if (!rel || rel.startsWith("..") || path11.isAbsolute(rel))
|
|
1783
1824
|
continue;
|
|
1784
1825
|
const parts = rel.split(/[\\/]/);
|
|
1785
1826
|
if (parts.length !== 2 || !/^[1-9][0-9]*$/.test(parts[1]))
|
|
@@ -1793,20 +1834,20 @@ function poolSlotLabel(pool, slot) {
|
|
|
1793
1834
|
}
|
|
1794
1835
|
function readJson(file2) {
|
|
1795
1836
|
try {
|
|
1796
|
-
return JSON.parse(
|
|
1837
|
+
return JSON.parse(fs13.readFileSync(file2, "utf8"));
|
|
1797
1838
|
} catch {
|
|
1798
1839
|
return void 0;
|
|
1799
1840
|
}
|
|
1800
1841
|
}
|
|
1801
1842
|
function writeJson(file2, value) {
|
|
1802
|
-
|
|
1843
|
+
fs13.mkdirSync(path11.dirname(file2), { recursive: true });
|
|
1803
1844
|
const tmp = uniqueTempPath(file2);
|
|
1804
|
-
|
|
1845
|
+
fs13.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
1805
1846
|
atomicRenameSync(tmp, file2);
|
|
1806
1847
|
}
|
|
1807
|
-
var metaFile = (pool, slot) =>
|
|
1808
|
-
var claimFile = (pool, slot) =>
|
|
1809
|
-
var outFile = (pool, slot) =>
|
|
1848
|
+
var metaFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.json`);
|
|
1849
|
+
var claimFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.claim.json`);
|
|
1850
|
+
var outFile = (pool, slot) => path11.join(slotsDir(pool), `${slot}.out.json`);
|
|
1810
1851
|
function readSlotMeta(pool, slot) {
|
|
1811
1852
|
return readJson(metaFile(pool, slot)) ?? {};
|
|
1812
1853
|
}
|
|
@@ -1826,7 +1867,7 @@ function writeSlotOut(pool, slot, out) {
|
|
|
1826
1867
|
writeJson(outFile(pool, slot), out);
|
|
1827
1868
|
}
|
|
1828
1869
|
function clearSlotOut(pool, slot) {
|
|
1829
|
-
|
|
1870
|
+
fs13.rmSync(outFile(pool, slot), { force: true });
|
|
1830
1871
|
}
|
|
1831
1872
|
function dispatchHolder(dir) {
|
|
1832
1873
|
const lock = readWorktreeLock(dir);
|
|
@@ -1836,7 +1877,7 @@ function poolSlotView(pool, slot) {
|
|
|
1836
1877
|
const dir = poolSlotPath(pool, slot);
|
|
1837
1878
|
const lastClaim = readSlotClaim(pool, slot)?.id;
|
|
1838
1879
|
const base = { slot, path: dir, ...lastClaim ? { lastClaim } : {} };
|
|
1839
|
-
if (!
|
|
1880
|
+
if (!fs13.existsSync(dir)) {
|
|
1840
1881
|
const meta2 = readSlotMeta(pool, slot);
|
|
1841
1882
|
return { ...base, state: "missing", ...meta2.error ? { reason: meta2.error } : {} };
|
|
1842
1883
|
}
|
|
@@ -1851,8 +1892,8 @@ function poolSlotView(pool, slot) {
|
|
|
1851
1892
|
return { ...base, state: "warming", ...meta.error ? { reason: meta.error } : {} };
|
|
1852
1893
|
return { ...base, state: "free" };
|
|
1853
1894
|
}
|
|
1854
|
-
var warmStateFile = (pool) =>
|
|
1855
|
-
var warmLockFile = (pool) =>
|
|
1895
|
+
var warmStateFile = (pool) => path11.join(poolDir(pool), ".warm-state.json");
|
|
1896
|
+
var warmLockFile = (pool) => path11.join(poolDir(pool), ".warm.lock");
|
|
1856
1897
|
var POOL_WARM_MAX_MS = 60 * 6e4;
|
|
1857
1898
|
function readPoolWarmState(pool) {
|
|
1858
1899
|
return readJson(warmStateFile(pool)) ?? {};
|
|
@@ -1874,15 +1915,15 @@ function poolWarmRunning(pool, now2 = Date.now()) {
|
|
|
1874
1915
|
}
|
|
1875
1916
|
function takePoolWarmLock(pool) {
|
|
1876
1917
|
const file2 = warmLockFile(pool);
|
|
1877
|
-
|
|
1918
|
+
fs13.mkdirSync(path11.dirname(file2), { recursive: true });
|
|
1878
1919
|
const mine = JSON.stringify({ pid: process.pid, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
1879
1920
|
for (let attempt2 = 0; attempt2 < 2; attempt2++) {
|
|
1880
1921
|
try {
|
|
1881
|
-
|
|
1922
|
+
fs13.writeFileSync(file2, mine, { flag: "wx" });
|
|
1882
1923
|
return () => {
|
|
1883
1924
|
try {
|
|
1884
|
-
if (
|
|
1885
|
-
|
|
1925
|
+
if (fs13.readFileSync(file2, "utf8") === mine)
|
|
1926
|
+
fs13.rmSync(file2, { force: true });
|
|
1886
1927
|
} catch {
|
|
1887
1928
|
}
|
|
1888
1929
|
};
|
|
@@ -1892,7 +1933,7 @@ function takePoolWarmLock(pool) {
|
|
|
1892
1933
|
}
|
|
1893
1934
|
if (poolWarmRunning(pool))
|
|
1894
1935
|
return void 0;
|
|
1895
|
-
|
|
1936
|
+
fs13.rmSync(file2, { force: true });
|
|
1896
1937
|
}
|
|
1897
1938
|
return void 0;
|
|
1898
1939
|
}
|
|
@@ -1902,11 +1943,11 @@ var POOL_RECHECK_MS = 5 * 6e4;
|
|
|
1902
1943
|
|
|
1903
1944
|
// packages/core/dist/helm.js
|
|
1904
1945
|
function helmDir() {
|
|
1905
|
-
return
|
|
1946
|
+
return path12.join(lobstahHome(), "helm");
|
|
1906
1947
|
}
|
|
1907
1948
|
function listHelms() {
|
|
1908
1949
|
try {
|
|
1909
|
-
return
|
|
1950
|
+
return fs14.readdirSync(helmDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs14.readFileSync(path12.join(helmDir(), f), "utf8")));
|
|
1910
1951
|
} catch {
|
|
1911
1952
|
return [];
|
|
1912
1953
|
}
|
|
@@ -1918,7 +1959,7 @@ function liveHelms(ttlMs, now2 = Date.now()) {
|
|
|
1918
1959
|
// packages/core/dist/catch-context.js
|
|
1919
1960
|
function readCatchContext(dir, id) {
|
|
1920
1961
|
try {
|
|
1921
|
-
return JSON.parse(
|
|
1962
|
+
return JSON.parse(fs15.readFileSync(path13.join(dir, `${id}.catch-context`), "utf8"));
|
|
1922
1963
|
} catch {
|
|
1923
1964
|
return {};
|
|
1924
1965
|
}
|
|
@@ -1931,19 +1972,19 @@ function observeLocalCatch(id, lane, phase, now2 = Date.now()) {
|
|
|
1931
1972
|
const helms = liveHelms(cfg.helm.ttlSecs * 1e3, now2);
|
|
1932
1973
|
const present = descriptor?.target ? helms.some((helm) => helm.grounds === descriptor.target.grounds) : repo ? helms.some((h) => h.repos.includes(repo)) : null;
|
|
1933
1974
|
const next = phase === "claim" ? { claimHelm: present, location: "local" } : { ...old, location: "local", helm: old.claimHelm === true || present === true ? true : old.claimHelm === false && present === false ? false : null };
|
|
1934
|
-
const file2 =
|
|
1975
|
+
const file2 = path13.join(dir, `${id}.catch-context`), tmp = uniqueTempPath(file2);
|
|
1935
1976
|
try {
|
|
1936
|
-
|
|
1937
|
-
|
|
1977
|
+
fs15.writeFileSync(tmp, JSON.stringify(next));
|
|
1978
|
+
fs15.renameSync(tmp, file2);
|
|
1938
1979
|
} finally {
|
|
1939
|
-
|
|
1980
|
+
fs15.rmSync(tmp, { force: true });
|
|
1940
1981
|
}
|
|
1941
1982
|
}
|
|
1942
1983
|
|
|
1943
1984
|
// packages/core/dist/stats.js
|
|
1944
1985
|
var DAILY_RETENTION_DAYS = 400;
|
|
1945
1986
|
function statsPath() {
|
|
1946
|
-
return
|
|
1987
|
+
return path14.join(lobstahHome(), "stats.json");
|
|
1947
1988
|
}
|
|
1948
1989
|
function shiftDay(day, days) {
|
|
1949
1990
|
const [y, m, d] = day.split("-").map(Number);
|
|
@@ -1956,7 +1997,7 @@ function localDay(at = Date.now()) {
|
|
|
1956
1997
|
function readCatchFacts(stateDir, id) {
|
|
1957
1998
|
let last;
|
|
1958
1999
|
try {
|
|
1959
|
-
for (const line of
|
|
2000
|
+
for (const line of fs16.readFileSync(path14.join(stateDir, `${id}.status`), "utf8").split("\n")) {
|
|
1960
2001
|
if (!line.trim())
|
|
1961
2002
|
continue;
|
|
1962
2003
|
try {
|
|
@@ -1972,7 +2013,7 @@ function readCatchFacts(stateDir, id) {
|
|
|
1972
2013
|
let trap;
|
|
1973
2014
|
let worker = workerProfile();
|
|
1974
2015
|
try {
|
|
1975
|
-
const evidence = JSON.parse(
|
|
2016
|
+
const evidence = JSON.parse(fs16.readFileSync(path14.join(stateDir, `${id}.evidence`), "utf8"));
|
|
1976
2017
|
const to = evidence.deliveredTo;
|
|
1977
2018
|
if (typeof to === "string" && to.startsWith("wt:"))
|
|
1978
2019
|
trap = to;
|
|
@@ -2055,7 +2096,7 @@ function add(store, facts, now2) {
|
|
|
2055
2096
|
}
|
|
2056
2097
|
function backfillSources() {
|
|
2057
2098
|
const live = ["work", "chore"].map((lane) => ({ dir: laneDirs(lane).state, live: true }));
|
|
2058
|
-
const backups = readDirIfPresent(lobstahHome()).filter((name) => name.startsWith("state-backup-")).sort().map((name) => ({ dir:
|
|
2099
|
+
const backups = readDirIfPresent(lobstahHome()).filter((name) => name.startsWith("state-backup-")).sort().map((name) => ({ dir: path14.join(lobstahHome(), name), live: false })).filter((s) => fs16.statSync(s.dir).isDirectory());
|
|
2059
2100
|
return [...live, ...backups];
|
|
2060
2101
|
}
|
|
2061
2102
|
function backfillStats(now2 = Date.now(), alreadyCounted) {
|
|
@@ -2127,13 +2168,13 @@ function parseStore(text) {
|
|
|
2127
2168
|
var complete = (s) => !!s && s.daily !== void 0;
|
|
2128
2169
|
function writeStore(store) {
|
|
2129
2170
|
const file2 = statsPath();
|
|
2130
|
-
|
|
2171
|
+
fs16.mkdirSync(path14.dirname(file2), { recursive: true });
|
|
2131
2172
|
const tmp = uniqueTempPath(file2);
|
|
2132
|
-
|
|
2173
|
+
fs16.writeFileSync(tmp, JSON.stringify(store));
|
|
2133
2174
|
atomicRenameSync(tmp, file2);
|
|
2134
2175
|
}
|
|
2135
2176
|
function withStatsLock(action) {
|
|
2136
|
-
|
|
2177
|
+
fs16.mkdirSync(lobstahHome(), { recursive: true });
|
|
2137
2178
|
return withDirLock(`${statsPath()}.lock`, action, {
|
|
2138
2179
|
staleMs: 12e4,
|
|
2139
2180
|
waitMs: 1e4,
|
|
@@ -2143,7 +2184,7 @@ function withStatsLock(action) {
|
|
|
2143
2184
|
function loadOrBackfill(now2) {
|
|
2144
2185
|
let text;
|
|
2145
2186
|
try {
|
|
2146
|
-
text =
|
|
2187
|
+
text = fs16.readFileSync(statsPath(), "utf8");
|
|
2147
2188
|
} catch (err) {
|
|
2148
2189
|
if (err.code !== "ENOENT")
|
|
2149
2190
|
throw err;
|
|
@@ -2170,7 +2211,7 @@ function loadOrBackfill(now2) {
|
|
|
2170
2211
|
return store2;
|
|
2171
2212
|
}
|
|
2172
2213
|
if (text !== void 0)
|
|
2173
|
-
|
|
2214
|
+
fs16.renameSync(statsPath(), `${statsPath()}.unreadable-${now2}`);
|
|
2174
2215
|
const store = backfillStats(now2);
|
|
2175
2216
|
writeStore(store);
|
|
2176
2217
|
return store;
|
|
@@ -2190,18 +2231,18 @@ function recordCatch(id, lane, now2 = Date.now()) {
|
|
|
2190
2231
|
}
|
|
2191
2232
|
|
|
2192
2233
|
// packages/core/dist/cache-paths.js
|
|
2193
|
-
import * as
|
|
2194
|
-
import * as
|
|
2234
|
+
import * as fs17 from "node:fs";
|
|
2235
|
+
import * as path15 from "node:path";
|
|
2195
2236
|
var heldCacheLocks = /* @__PURE__ */ new Set();
|
|
2196
2237
|
function validCacheGlob(pattern) {
|
|
2197
|
-
return pattern.length > 0 && !/[\\\0:]/.test(pattern) && !
|
|
2238
|
+
return pattern.length > 0 && !/[\\\0:]/.test(pattern) && !path15.posix.isAbsolute(pattern) && !pattern.split("/").some((part) => !part || part === "." || part === ".." || part.toLowerCase() === ".git");
|
|
2198
2239
|
}
|
|
2199
2240
|
function withTrapCacheLock(trapId, action) {
|
|
2200
2241
|
if (heldCacheLocks.has(trapId))
|
|
2201
2242
|
return action();
|
|
2202
|
-
const dir =
|
|
2203
|
-
|
|
2204
|
-
return withDirLock(
|
|
2243
|
+
const dir = path15.join(lobstahHome(), "cache-locks");
|
|
2244
|
+
fs17.mkdirSync(dir, { recursive: true });
|
|
2245
|
+
return withDirLock(path15.join(dir, `trap-${encodeURIComponent(trapId)}`), () => {
|
|
2205
2246
|
heldCacheLocks.add(trapId);
|
|
2206
2247
|
try {
|
|
2207
2248
|
return action();
|
|
@@ -2244,10 +2285,10 @@ function cacheDirectories(root, patterns) {
|
|
|
2244
2285
|
if (part === "**")
|
|
2245
2286
|
walk(dir, parts, index + 1);
|
|
2246
2287
|
const matcher = segmentPattern(part);
|
|
2247
|
-
for (const entry of
|
|
2288
|
+
for (const entry of fs17.readdirSync(dir, { withFileTypes: true })) {
|
|
2248
2289
|
if (!entry.isDirectory() || entry.isSymbolicLink() || entry.name.toLowerCase() === ".git")
|
|
2249
2290
|
continue;
|
|
2250
|
-
const child =
|
|
2291
|
+
const child = path15.join(dir, entry.name);
|
|
2251
2292
|
if (part === "**")
|
|
2252
2293
|
walk(child, parts, index);
|
|
2253
2294
|
else if (matcher.test(entry.name))
|
|
@@ -2259,12 +2300,12 @@ function cacheDirectories(root, patterns) {
|
|
|
2259
2300
|
continue;
|
|
2260
2301
|
walk(root, pattern.split("/"), 0);
|
|
2261
2302
|
}
|
|
2262
|
-
return [...matches].sort().filter((dir, _i, dirs) => !dirs.some((parent) => dir !== parent && dir.startsWith(parent +
|
|
2303
|
+
return [...matches].sort().filter((dir, _i, dirs) => !dirs.some((parent) => dir !== parent && dir.startsWith(parent + path15.sep)));
|
|
2263
2304
|
}
|
|
2264
2305
|
|
|
2265
2306
|
// packages/core/dist/cache-cleanup.js
|
|
2266
|
-
import * as
|
|
2267
|
-
import * as
|
|
2307
|
+
import * as fs18 from "node:fs";
|
|
2308
|
+
import * as path16 from "node:path";
|
|
2268
2309
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
2269
2310
|
var git = (dir, args) => execFileSync3("git", ["-C", dir, ...args], {
|
|
2270
2311
|
encoding: "utf8",
|
|
@@ -2290,52 +2331,52 @@ function cacheTrapIdle(trap) {
|
|
|
2290
2331
|
}
|
|
2291
2332
|
function cacheWorktree(root, repoPath) {
|
|
2292
2333
|
const canonical = (dir) => {
|
|
2293
|
-
const real =
|
|
2334
|
+
const real = fs18.realpathSync.native(dir);
|
|
2294
2335
|
return process.platform === "win32" ? real.toLowerCase() : real;
|
|
2295
2336
|
};
|
|
2296
|
-
if (
|
|
2337
|
+
if (fs18.lstatSync(root).isSymbolicLink())
|
|
2297
2338
|
return false;
|
|
2298
2339
|
const top = git(root, ["rev-parse", "--show-toplevel"]).trim();
|
|
2299
|
-
const common =
|
|
2340
|
+
const common = path16.resolve(root, git(root, ["rev-parse", "--git-common-dir"]).trim());
|
|
2300
2341
|
const privateGit = git(root, ["rev-parse", "--absolute-git-dir"]).trim();
|
|
2301
|
-
const repoCommon =
|
|
2342
|
+
const repoCommon = path16.resolve(repoPath, git(repoPath, ["rev-parse", "--git-common-dir"]).trim());
|
|
2302
2343
|
return canonical(root) === canonical(top) && canonical(common) !== canonical(privateGit) && canonical(common) === canonical(repoCommon);
|
|
2303
2344
|
}
|
|
2304
2345
|
function safeCacheTarget(root, target, tracked) {
|
|
2305
|
-
const relative7 =
|
|
2306
|
-
if (
|
|
2346
|
+
const relative7 = path16.relative(root, target);
|
|
2347
|
+
if (fs18.lstatSync(root).isSymbolicLink())
|
|
2307
2348
|
return false;
|
|
2308
|
-
if (!relative7 || relative7.startsWith("..") ||
|
|
2349
|
+
if (!relative7 || relative7.startsWith("..") || path16.isAbsolute(relative7))
|
|
2309
2350
|
return false;
|
|
2310
2351
|
let current = root;
|
|
2311
|
-
for (const part of relative7.split(
|
|
2312
|
-
current =
|
|
2313
|
-
if (part.toLowerCase() === ".git" ||
|
|
2352
|
+
for (const part of relative7.split(path16.sep)) {
|
|
2353
|
+
current = path16.join(current, part);
|
|
2354
|
+
if (part.toLowerCase() === ".git" || fs18.lstatSync(current).isSymbolicLink())
|
|
2314
2355
|
return false;
|
|
2315
2356
|
}
|
|
2316
|
-
const name = relative7.split(
|
|
2357
|
+
const name = relative7.split(path16.sep).join("/").toLowerCase();
|
|
2317
2358
|
return !tracked.some((trackedPath) => {
|
|
2318
2359
|
const file2 = trackedPath.toLowerCase();
|
|
2319
2360
|
return file2 === name || file2.startsWith(name + "/") || name.startsWith(file2 + "/");
|
|
2320
2361
|
});
|
|
2321
2362
|
}
|
|
2322
2363
|
function cacheBytes(target) {
|
|
2323
|
-
const stat =
|
|
2364
|
+
const stat = fs18.lstatSync(target);
|
|
2324
2365
|
if (stat.isSymbolicLink())
|
|
2325
2366
|
return 0;
|
|
2326
2367
|
if (!stat.isDirectory())
|
|
2327
2368
|
return process.platform === "win32" || stat.blocks === void 0 ? stat.size : stat.blocks * 512;
|
|
2328
|
-
const entries =
|
|
2369
|
+
const entries = fs18.readdirSync(target);
|
|
2329
2370
|
if (entries.some((name) => name.toLowerCase() === ".git"))
|
|
2330
2371
|
throw new Error("nested repository is not a cache");
|
|
2331
|
-
return entries.reduce((bytes, name) => bytes + cacheBytes(
|
|
2372
|
+
return entries.reduce((bytes, name) => bytes + cacheBytes(path16.join(target, name)), 0);
|
|
2332
2373
|
}
|
|
2333
2374
|
function planTrapCache(trap, cfg) {
|
|
2334
2375
|
const repo = trap.repo ? cfg.repos[trap.repo] : void 0;
|
|
2335
2376
|
if (!repo?.cacheDirs?.length || !cacheTrapIdle(trap))
|
|
2336
2377
|
return void 0;
|
|
2337
2378
|
try {
|
|
2338
|
-
const root =
|
|
2379
|
+
const root = fs18.realpathSync.native(trap.worktree);
|
|
2339
2380
|
if (!cacheWorktree(trap.worktree, repo.path))
|
|
2340
2381
|
return void 0;
|
|
2341
2382
|
const tracked = git(root, ["ls-files", "-z"]).split("\0").filter(Boolean);
|
|
@@ -2377,7 +2418,7 @@ function clearTrapCaches(trap, cfg = loadConfig()) {
|
|
|
2377
2418
|
if (!cacheTrapIdle(trap) || !safeCacheTarget(plan.worktree, target, tracked))
|
|
2378
2419
|
continue;
|
|
2379
2420
|
const size = cacheBytes(target);
|
|
2380
|
-
|
|
2421
|
+
fs18.rmSync(target, { recursive: true, force: true });
|
|
2381
2422
|
bytes += size;
|
|
2382
2423
|
} catch {
|
|
2383
2424
|
}
|
|
@@ -2426,12 +2467,12 @@ function recoverTrapCaches(cfg, volume, readFree = statfsFreeBytes, log = () =>
|
|
|
2426
2467
|
return 0;
|
|
2427
2468
|
let bytes = 0;
|
|
2428
2469
|
let traps = 0;
|
|
2429
|
-
const device =
|
|
2470
|
+
const device = fs18.statSync(volume).dev;
|
|
2430
2471
|
for (const plan of planTrapCaches(cfg)) {
|
|
2431
2472
|
if (readFree(volume) >= threshold)
|
|
2432
2473
|
break;
|
|
2433
2474
|
try {
|
|
2434
|
-
if (
|
|
2475
|
+
if (fs18.statSync(plan.worktree).dev !== device)
|
|
2435
2476
|
continue;
|
|
2436
2477
|
const removed = clearTrapCaches(plan, cfg);
|
|
2437
2478
|
if (removed > 0) {
|
|
@@ -2528,7 +2569,7 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
|
|
|
2528
2569
|
if (trap?.configured?.surface === "claude-desktop" && verb === "working" && !acquireDesktopLease(trap))
|
|
2529
2570
|
throw new Error("another configured desk owns the host UI; retry working when it finishes");
|
|
2530
2571
|
const write = () => {
|
|
2531
|
-
|
|
2572
|
+
fs19.appendFileSync(statusPath(id, lane), `${JSON.stringify(entry)}
|
|
2532
2573
|
`);
|
|
2533
2574
|
};
|
|
2534
2575
|
if (trap && repoCachesConfigured(trap.repo))
|
|
@@ -2551,9 +2592,9 @@ function appendStatus(id, lane, verb, note, at, waiting, reported = false) {
|
|
|
2551
2592
|
}
|
|
2552
2593
|
function readStatusLog(id, lane) {
|
|
2553
2594
|
const file2 = statusPath(id, lane);
|
|
2554
|
-
if (!
|
|
2595
|
+
if (!fs19.existsSync(file2))
|
|
2555
2596
|
return [];
|
|
2556
|
-
return
|
|
2597
|
+
return fs19.readFileSync(file2, "utf8").split("\n").filter(Boolean).flatMap((line) => {
|
|
2557
2598
|
try {
|
|
2558
2599
|
const parsed = JSON.parse(line);
|
|
2559
2600
|
return isVerb(parsed.verb) ? [parsed] : [];
|
|
@@ -2567,8 +2608,8 @@ function pausedWaiting(entry) {
|
|
|
2567
2608
|
}
|
|
2568
2609
|
|
|
2569
2610
|
// packages/core/dist/pushes.js
|
|
2570
|
-
import * as
|
|
2571
|
-
import * as
|
|
2611
|
+
import * as fs20 from "node:fs";
|
|
2612
|
+
import * as path17 from "node:path";
|
|
2572
2613
|
var MAX_PUSHES = 20;
|
|
2573
2614
|
var PUSH_HEAD = "HEAD";
|
|
2574
2615
|
var VALUE_OPTIONS = /* @__PURE__ */ new Set(["-o", "--push-option", "--repo", "--receive-pack", "--exec"]);
|
|
@@ -2623,18 +2664,18 @@ function gitPushTargets(command) {
|
|
|
2623
2664
|
return found ? [...new Set(targets)] : void 0;
|
|
2624
2665
|
}
|
|
2625
2666
|
function gitDirAt(dir) {
|
|
2626
|
-
let at =
|
|
2667
|
+
let at = path17.resolve(dir);
|
|
2627
2668
|
for (; ; ) {
|
|
2628
|
-
const dotGit =
|
|
2669
|
+
const dotGit = path17.join(at, ".git");
|
|
2629
2670
|
try {
|
|
2630
|
-
const stat =
|
|
2671
|
+
const stat = fs20.statSync(dotGit);
|
|
2631
2672
|
if (stat.isDirectory())
|
|
2632
2673
|
return dotGit;
|
|
2633
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
2634
|
-
return m ?
|
|
2674
|
+
const m = /^gitdir:\s*(.+)$/m.exec(fs20.readFileSync(dotGit, "utf8"));
|
|
2675
|
+
return m ? path17.resolve(at, m[1].trim()) : void 0;
|
|
2635
2676
|
} catch {
|
|
2636
2677
|
}
|
|
2637
|
-
const up =
|
|
2678
|
+
const up = path17.dirname(at);
|
|
2638
2679
|
if (up === at)
|
|
2639
2680
|
return void 0;
|
|
2640
2681
|
at = up;
|
|
@@ -2645,7 +2686,7 @@ function currentBranchAt(dir) {
|
|
|
2645
2686
|
if (!gitDir)
|
|
2646
2687
|
return void 0;
|
|
2647
2688
|
try {
|
|
2648
|
-
const m = /^ref:\s*refs\/heads\/(.+)$/m.exec(
|
|
2689
|
+
const m = /^ref:\s*refs\/heads\/(.+)$/m.exec(fs20.readFileSync(path17.join(gitDir, "HEAD"), "utf8"));
|
|
2649
2690
|
return m ? m[1].trim() : void 0;
|
|
2650
2691
|
} catch {
|
|
2651
2692
|
return void 0;
|
|
@@ -2665,28 +2706,28 @@ function recordPush(id, lane, branches, at = (/* @__PURE__ */ new Date()).toISOS
|
|
|
2665
2706
|
|
|
2666
2707
|
// packages/core/dist/soak.js
|
|
2667
2708
|
function regPath(trapId) {
|
|
2668
|
-
return
|
|
2709
|
+
return path18.join(soakingDir(), `${trapId}.json`);
|
|
2669
2710
|
}
|
|
2670
2711
|
function readTrap(trapId) {
|
|
2671
2712
|
try {
|
|
2672
|
-
return JSON.parse(
|
|
2713
|
+
return JSON.parse(fs21.readFileSync(regPath(trapId), "utf8"));
|
|
2673
2714
|
} catch {
|
|
2674
2715
|
return void 0;
|
|
2675
2716
|
}
|
|
2676
2717
|
}
|
|
2677
2718
|
function listTraps() {
|
|
2678
2719
|
try {
|
|
2679
|
-
return
|
|
2720
|
+
return fs21.readdirSync(soakingDir()).filter((f) => f.endsWith(".json")).map((f) => JSON.parse(fs21.readFileSync(path18.join(soakingDir(), f), "utf8"))).filter((r) => typeof r.trapId === "string");
|
|
2680
2721
|
} catch {
|
|
2681
2722
|
return [];
|
|
2682
2723
|
}
|
|
2683
2724
|
}
|
|
2684
2725
|
function claimPath(id, lane) {
|
|
2685
|
-
return
|
|
2726
|
+
return path18.join(laneDirs(lane).active, id, "claim.json");
|
|
2686
2727
|
}
|
|
2687
2728
|
function readSessionClaim(id, lane) {
|
|
2688
2729
|
try {
|
|
2689
|
-
return JSON.parse(
|
|
2730
|
+
return JSON.parse(fs21.readFileSync(claimPath(id, lane), "utf8"));
|
|
2690
2731
|
} catch {
|
|
2691
2732
|
return void 0;
|
|
2692
2733
|
}
|
|
@@ -2695,46 +2736,46 @@ function hasOpenCatch(reg) {
|
|
|
2695
2736
|
if (!reg.claimed)
|
|
2696
2737
|
return false;
|
|
2697
2738
|
const lane = laneOf(reg.claimed);
|
|
2698
|
-
if (!lane || !
|
|
2739
|
+
if (!lane || !fs21.existsSync(path18.join(laneDirs(lane).active, reg.claimed)))
|
|
2699
2740
|
return false;
|
|
2700
2741
|
const last = readStatusLog(reg.claimed, lane).at(-1)?.verb;
|
|
2701
2742
|
return last === void 0 || !TERMINAL_VERBS.includes(last);
|
|
2702
2743
|
}
|
|
2703
2744
|
|
|
2704
2745
|
// packages/core/dist/events.js
|
|
2705
|
-
import * as
|
|
2746
|
+
import * as fs22 from "node:fs";
|
|
2706
2747
|
function appendEvent(id, lane, ev) {
|
|
2707
|
-
|
|
2748
|
+
fs22.appendFileSync(eventsPath(id, lane), `${JSON.stringify(ev)}
|
|
2708
2749
|
`);
|
|
2709
2750
|
}
|
|
2710
2751
|
function touchEvents(id, lane, at = /* @__PURE__ */ new Date()) {
|
|
2711
2752
|
const file2 = eventsPath(id, lane);
|
|
2712
2753
|
try {
|
|
2713
|
-
|
|
2754
|
+
fs22.utimesSync(file2, at, at);
|
|
2714
2755
|
} catch {
|
|
2715
|
-
|
|
2716
|
-
|
|
2756
|
+
fs22.appendFileSync(file2, "");
|
|
2757
|
+
fs22.utimesSync(file2, at, at);
|
|
2717
2758
|
}
|
|
2718
2759
|
}
|
|
2719
2760
|
|
|
2720
2761
|
// packages/core/dist/inbox.js
|
|
2721
|
-
import * as
|
|
2722
|
-
import * as
|
|
2762
|
+
import * as fs23 from "node:fs";
|
|
2763
|
+
import * as path19 from "node:path";
|
|
2723
2764
|
var metaName = (file2) => file2.replace(/\.msg$/, ".meta.json");
|
|
2724
2765
|
function inboxDir(id, lane) {
|
|
2725
|
-
return
|
|
2766
|
+
return path19.join(laneDirs(lane).inbox, id);
|
|
2726
2767
|
}
|
|
2727
2768
|
function withInboxWrite(id, lane, action) {
|
|
2728
2769
|
const directory = inboxDir(id, lane);
|
|
2729
|
-
|
|
2730
|
-
return withDirLock(
|
|
2770
|
+
fs23.mkdirSync(directory, { recursive: true });
|
|
2771
|
+
return withDirLock(path19.join(directory, ".write-lock"), action, { staleMs: 3e4, waitMs: 1e3, busy: () => new Error(`inbox ${id} is busy; retry`) });
|
|
2731
2772
|
}
|
|
2732
2773
|
function sendMessageOnce(id, lane, deliveryId, text, from, attachments = []) {
|
|
2733
2774
|
if (!/^[A-Za-z0-9_-]{1,128}$/.test(deliveryId))
|
|
2734
2775
|
throw new Error("invalid inbox delivery id");
|
|
2735
2776
|
return withInboxWrite(id, lane, () => {
|
|
2736
2777
|
const directory = inboxDir(id, lane);
|
|
2737
|
-
for (const folder of [directory,
|
|
2778
|
+
for (const folder of [directory, path19.join(directory, "handled")])
|
|
2738
2779
|
for (const file2 of readDirIfPresent(folder).filter((name) => name.endsWith(".msg"))) {
|
|
2739
2780
|
const metadata = readMessageMeta(id, lane, file2, folder !== directory);
|
|
2740
2781
|
if (metadata?.deliveryId === deliveryId)
|
|
@@ -2745,47 +2786,47 @@ function sendMessageOnce(id, lane, deliveryId, text, from, attachments = []) {
|
|
|
2745
2786
|
}
|
|
2746
2787
|
function appendMessage(id, lane, text, from, attachments = [], deliveryId) {
|
|
2747
2788
|
const dir = inboxDir(id, lane);
|
|
2748
|
-
|
|
2749
|
-
const existing =
|
|
2750
|
-
const handled =
|
|
2789
|
+
fs23.mkdirSync(path19.join(dir, "handled"), { recursive: true });
|
|
2790
|
+
const existing = fs23.readdirSync(dir).filter((f) => f.endsWith(".msg")).length;
|
|
2791
|
+
const handled = fs23.readdirSync(path19.join(dir, "handled")).filter((f) => f.endsWith(".msg")).length;
|
|
2751
2792
|
const name = `${String(existing + handled + 1).padStart(3, "0")}.msg`;
|
|
2752
|
-
const tmp = uniqueTempPath(
|
|
2793
|
+
const tmp = uniqueTempPath(path19.join(dir, name));
|
|
2753
2794
|
if (from !== void 0 || attachments.length > 0) {
|
|
2754
2795
|
const meta = { ...deliveryId ? { deliveryId } : {}, from: from ?? "unknown", at: (/* @__PURE__ */ new Date()).toISOString(), ...attachments.length ? { attachments } : {} };
|
|
2755
2796
|
const metaTmp = `${tmp}.meta`;
|
|
2756
|
-
|
|
2757
|
-
atomicRenameSync(metaTmp,
|
|
2797
|
+
fs23.writeFileSync(metaTmp, JSON.stringify(meta, null, 2));
|
|
2798
|
+
atomicRenameSync(metaTmp, path19.join(dir, metaName(name)));
|
|
2758
2799
|
}
|
|
2759
|
-
|
|
2760
|
-
atomicRenameSync(tmp,
|
|
2800
|
+
fs23.writeFileSync(tmp, text);
|
|
2801
|
+
atomicRenameSync(tmp, path19.join(dir, name));
|
|
2761
2802
|
return name;
|
|
2762
2803
|
}
|
|
2763
2804
|
function readMessageMeta(id, lane, file2, handled = false) {
|
|
2764
|
-
const dir =
|
|
2805
|
+
const dir = path19.join(inboxDir(id, lane), ...handled ? ["handled"] : []);
|
|
2765
2806
|
try {
|
|
2766
|
-
return JSON.parse(
|
|
2807
|
+
return JSON.parse(fs23.readFileSync(path19.join(dir, metaName(file2)), "utf8"));
|
|
2767
2808
|
} catch {
|
|
2768
2809
|
return void 0;
|
|
2769
2810
|
}
|
|
2770
2811
|
}
|
|
2771
2812
|
function unhandled(id, lane) {
|
|
2772
2813
|
const dir = inboxDir(id, lane);
|
|
2773
|
-
return readDirIfPresent(dir).filter((f) => f.endsWith(".msg")).sort().map((f) => ({ file: f, text:
|
|
2814
|
+
return readDirIfPresent(dir).filter((f) => f.endsWith(".msg")).sort().map((f) => ({ file: f, text: fs23.readFileSync(path19.join(dir, f), "utf8") }));
|
|
2774
2815
|
}
|
|
2775
2816
|
function acknowledge(id, lane, file2) {
|
|
2776
2817
|
const dir = inboxDir(id, lane);
|
|
2777
|
-
|
|
2778
|
-
|
|
2818
|
+
fs23.mkdirSync(path19.join(dir, "handled"), { recursive: true });
|
|
2819
|
+
fs23.renameSync(path19.join(dir, file2), path19.join(dir, "handled", file2));
|
|
2779
2820
|
try {
|
|
2780
|
-
|
|
2821
|
+
fs23.renameSync(path19.join(dir, metaName(file2)), path19.join(dir, "handled", metaName(file2)));
|
|
2781
2822
|
} catch {
|
|
2782
2823
|
}
|
|
2783
2824
|
}
|
|
2784
2825
|
|
|
2785
2826
|
// packages/core/dist/resume.js
|
|
2786
|
-
import * as
|
|
2827
|
+
import * as fs24 from "node:fs";
|
|
2787
2828
|
import * as os3 from "node:os";
|
|
2788
|
-
import * as
|
|
2829
|
+
import * as path20 from "node:path";
|
|
2789
2830
|
import { spawnSync } from "node:child_process";
|
|
2790
2831
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-([0-9a-f])[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
2791
2832
|
function harnessFromSessionId(sessionId) {
|
|
@@ -2796,7 +2837,7 @@ function claimOf(id, lane) {
|
|
|
2796
2837
|
const dirs = laneDirs(lane);
|
|
2797
2838
|
for (const dir of [dirs.active, dirs.done]) {
|
|
2798
2839
|
try {
|
|
2799
|
-
return JSON.parse(
|
|
2840
|
+
return JSON.parse(fs24.readFileSync(path20.join(dir, id, "claim.json"), "utf8"));
|
|
2800
2841
|
} catch {
|
|
2801
2842
|
}
|
|
2802
2843
|
}
|
|
@@ -2846,7 +2887,7 @@ function isUnresumable(error) {
|
|
|
2846
2887
|
return error !== void 0 && UNRESUMABLE.test(error);
|
|
2847
2888
|
}
|
|
2848
2889
|
function worktreeProgress(worktree, trunk) {
|
|
2849
|
-
if (!worktree || !
|
|
2890
|
+
if (!worktree || !fs24.existsSync(worktree))
|
|
2850
2891
|
return "No worktree progress recorded.";
|
|
2851
2892
|
const git3 = (...a) => spawnSync("git", a, { cwd: worktree, encoding: "utf8" }).stdout?.trim() ?? "";
|
|
2852
2893
|
const commits = trunk ? git3("log", "--oneline", `origin/${trunk}..HEAD`) : git3("log", "--oneline", "-15");
|
|
@@ -2879,31 +2920,31 @@ function handoffNote(fromHarness, progress, why) {
|
|
|
2879
2920
|
${progress}`;
|
|
2880
2921
|
}
|
|
2881
2922
|
function codexHome(env = process.env) {
|
|
2882
|
-
return env.CODEX_HOME ??
|
|
2923
|
+
return env.CODEX_HOME ?? path20.join(os3.homedir(), ".codex");
|
|
2883
2924
|
}
|
|
2884
2925
|
function codexRolloutFile(threadId, home = codexHome()) {
|
|
2885
2926
|
const suffix = `-${threadId}.jsonl`;
|
|
2886
2927
|
const walk = (dir, depth) => {
|
|
2887
2928
|
let entries;
|
|
2888
2929
|
try {
|
|
2889
|
-
entries =
|
|
2930
|
+
entries = fs24.readdirSync(dir, { withFileTypes: true });
|
|
2890
2931
|
} catch {
|
|
2891
2932
|
return void 0;
|
|
2892
2933
|
}
|
|
2893
2934
|
for (const e of entries) {
|
|
2894
2935
|
if (e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(suffix))
|
|
2895
|
-
return
|
|
2936
|
+
return path20.join(dir, e.name);
|
|
2896
2937
|
}
|
|
2897
2938
|
if (depth === 0)
|
|
2898
2939
|
return void 0;
|
|
2899
2940
|
for (const e of entries.filter((x) => x.isDirectory()).sort((a, b) => b.name.localeCompare(a.name))) {
|
|
2900
|
-
const hit = walk(
|
|
2941
|
+
const hit = walk(path20.join(dir, e.name), depth - 1);
|
|
2901
2942
|
if (hit)
|
|
2902
2943
|
return hit;
|
|
2903
2944
|
}
|
|
2904
2945
|
return void 0;
|
|
2905
2946
|
};
|
|
2906
|
-
return walk(
|
|
2947
|
+
return walk(path20.join(home, "sessions"), 3) ?? walk(path20.join(home, "archived_sessions"), 0);
|
|
2907
2948
|
}
|
|
2908
2949
|
function codexDesktopThread(threadId, home = codexHome()) {
|
|
2909
2950
|
const file2 = codexRolloutFile(threadId, home);
|
|
@@ -2911,12 +2952,12 @@ function codexDesktopThread(threadId, home = codexHome()) {
|
|
|
2911
2952
|
return void 0;
|
|
2912
2953
|
let head = "";
|
|
2913
2954
|
try {
|
|
2914
|
-
const fd =
|
|
2955
|
+
const fd = fs24.openSync(file2, "r");
|
|
2915
2956
|
try {
|
|
2916
2957
|
const buf = Buffer.alloc(4096);
|
|
2917
|
-
head = buf.subarray(0,
|
|
2958
|
+
head = buf.subarray(0, fs24.readSync(fd, buf, 0, buf.length, 0)).toString("utf8");
|
|
2918
2959
|
} finally {
|
|
2919
|
-
|
|
2960
|
+
fs24.closeSync(fd);
|
|
2920
2961
|
}
|
|
2921
2962
|
} catch {
|
|
2922
2963
|
return void 0;
|
|
@@ -2930,16 +2971,16 @@ var CODEX_DESKTOP_THREAD = "Codex desktop thread; not resumable from the CLI";
|
|
|
2930
2971
|
|
|
2931
2972
|
// packages/core/dist/notices.js
|
|
2932
2973
|
function noticesDir() {
|
|
2933
|
-
return
|
|
2974
|
+
return path21.join(lobstahHome(), "notices");
|
|
2934
2975
|
}
|
|
2935
2976
|
var counter = 0;
|
|
2936
2977
|
function postNotice(n) {
|
|
2937
2978
|
const dir = noticesDir();
|
|
2938
|
-
|
|
2979
|
+
fs25.mkdirSync(dir, { recursive: true });
|
|
2939
2980
|
if (n.dedupeKey) {
|
|
2940
|
-
const marker =
|
|
2981
|
+
const marker = path21.join(dir, `.dedupe-${n.dedupeKey.replace(/[^A-Za-z0-9_-]/g, "_")}`);
|
|
2941
2982
|
try {
|
|
2942
|
-
|
|
2983
|
+
fs25.writeFileSync(marker, "", { flag: "wx" });
|
|
2943
2984
|
} catch {
|
|
2944
2985
|
return void 0;
|
|
2945
2986
|
}
|
|
@@ -2958,20 +2999,20 @@ function postNotice(n) {
|
|
|
2958
2999
|
...n.quiet ? { quiet: true } : {},
|
|
2959
3000
|
...n.stateHash ? { stateHash: n.stateHash } : {}
|
|
2960
3001
|
};
|
|
2961
|
-
const file2 =
|
|
3002
|
+
const file2 = path21.join(dir, `${seq}.json`);
|
|
2962
3003
|
const tmp = uniqueTempPath(file2);
|
|
2963
|
-
|
|
3004
|
+
fs25.writeFileSync(tmp, JSON.stringify(notice, null, 2));
|
|
2964
3005
|
atomicRenameSync(tmp, file2);
|
|
2965
3006
|
return notice;
|
|
2966
3007
|
}
|
|
2967
3008
|
|
|
2968
3009
|
// packages/core/dist/github-budget.js
|
|
2969
|
-
import * as
|
|
2970
|
-
import * as
|
|
2971
|
-
var file = () =>
|
|
3010
|
+
import * as fs26 from "node:fs";
|
|
3011
|
+
import * as path22 from "node:path";
|
|
3012
|
+
var file = () => path22.join(lobstahHome(), "github-budget.json");
|
|
2972
3013
|
function read() {
|
|
2973
3014
|
try {
|
|
2974
|
-
return JSON.parse(
|
|
3015
|
+
return JSON.parse(fs26.readFileSync(file(), "utf8"));
|
|
2975
3016
|
} catch {
|
|
2976
3017
|
return { resources: {} };
|
|
2977
3018
|
}
|
|
@@ -2985,27 +3026,27 @@ function githubBlockedUntil(now2 = Date.now()) {
|
|
|
2985
3026
|
|
|
2986
3027
|
// packages/core/dist/watch.js
|
|
2987
3028
|
function watchesDir() {
|
|
2988
|
-
return
|
|
3029
|
+
return path23.join(lobstahHome(), "watches");
|
|
2989
3030
|
}
|
|
2990
3031
|
function slug(key) {
|
|
2991
3032
|
return key.replace(/[^A-Za-z0-9._-]+/g, "-");
|
|
2992
3033
|
}
|
|
2993
3034
|
function watchPath(key) {
|
|
2994
|
-
return
|
|
3035
|
+
return path23.join(watchesDir(), `${slug(key)}.json`);
|
|
2995
3036
|
}
|
|
2996
3037
|
function readWatch(key) {
|
|
2997
3038
|
try {
|
|
2998
|
-
return JSON.parse(
|
|
3039
|
+
return JSON.parse(fs27.readFileSync(watchPath(key), "utf8"));
|
|
2999
3040
|
} catch {
|
|
3000
3041
|
return void 0;
|
|
3001
3042
|
}
|
|
3002
3043
|
}
|
|
3003
3044
|
|
|
3004
3045
|
// packages/core/dist/pr-poll.js
|
|
3005
|
-
var cycleFile = (repo) =>
|
|
3046
|
+
var cycleFile = (repo) => path24.join(lobstahHome(), "pr-polls", `${repo.replace(/[^\w.-]/g, "_")}.json`);
|
|
3006
3047
|
var readCycle = (repo) => {
|
|
3007
3048
|
try {
|
|
3008
|
-
return JSON.parse(
|
|
3049
|
+
return JSON.parse(fs28.readFileSync(cycleFile(repo), "utf8"));
|
|
3009
3050
|
} catch {
|
|
3010
3051
|
return void 0;
|
|
3011
3052
|
}
|
|
@@ -3449,14 +3490,14 @@ function withConfigPath(parse2) {
|
|
|
3449
3490
|
}
|
|
3450
3491
|
}
|
|
3451
3492
|
function configPath() {
|
|
3452
|
-
return
|
|
3493
|
+
return path25.join(lobstahHome(), "config.toml");
|
|
3453
3494
|
}
|
|
3454
3495
|
function expandHome(p) {
|
|
3455
|
-
return p.startsWith("~/") ?
|
|
3496
|
+
return p.startsWith("~/") ? path25.join(os4.homedir(), p.slice(2)) : p;
|
|
3456
3497
|
}
|
|
3457
3498
|
function loadConfig() {
|
|
3458
3499
|
const file2 = configPath();
|
|
3459
|
-
const raw =
|
|
3500
|
+
const raw = fs29.existsSync(file2) ? parse(fs29.readFileSync(file2, "utf8")) : {};
|
|
3460
3501
|
const cacheMinFreeGB = raw.limits?.cacheMinFreeGB ?? DEFAULT_LIMITS.cacheMinFreeGB;
|
|
3461
3502
|
if (typeof cacheMinFreeGB !== "number" || !Number.isFinite(cacheMinFreeGB) || cacheMinFreeGB < 0)
|
|
3462
3503
|
throw new Error("[limits].cacheMinFreeGB must be a non-negative number");
|
|
@@ -3587,47 +3628,6 @@ function resolveDispatch(d, cfg) {
|
|
|
3587
3628
|
};
|
|
3588
3629
|
}
|
|
3589
3630
|
|
|
3590
|
-
// packages/core/dist/reports.js
|
|
3591
|
-
import * as fs29 from "node:fs";
|
|
3592
|
-
import * as path25 from "node:path";
|
|
3593
|
-
var REPORT_MD = "report.md";
|
|
3594
|
-
var REPORT_JSON = "report.json";
|
|
3595
|
-
function helmReportsRoot() {
|
|
3596
|
-
return path25.join(lobstahHome(), "reports");
|
|
3597
|
-
}
|
|
3598
|
-
function dispatchReportKey(id, lane) {
|
|
3599
|
-
return `report:${lane}:${id}`;
|
|
3600
|
-
}
|
|
3601
|
-
var GROUNDS_RE = /^[A-Za-z0-9._-]+$/;
|
|
3602
|
-
var RID_RE = /^[a-f0-9]{8}$/;
|
|
3603
|
-
function reportDir(key) {
|
|
3604
|
-
const d = /^report:(work|chore):([A-Za-z0-9-]+)$/.exec(key);
|
|
3605
|
-
if (d)
|
|
3606
|
-
return path25.join(laneDirs(d[1]).state, d[2]);
|
|
3607
|
-
const h = /^report:helm:([^:]+):([^:]+)$/.exec(key);
|
|
3608
|
-
if (h && GROUNDS_RE.test(h[1]) && !h[1].startsWith(".") && RID_RE.test(h[2]))
|
|
3609
|
-
return path25.join(helmReportsRoot(), h[1], h[2]);
|
|
3610
|
-
return void 0;
|
|
3611
|
-
}
|
|
3612
|
-
function readReportAt(dir) {
|
|
3613
|
-
try {
|
|
3614
|
-
const meta = JSON.parse(fs29.readFileSync(path25.join(dir, REPORT_JSON), "utf8"));
|
|
3615
|
-
return typeof meta.key === "string" && typeof meta.filedAt === "string" ? meta : void 0;
|
|
3616
|
-
} catch {
|
|
3617
|
-
return void 0;
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
function readReport(key) {
|
|
3621
|
-
const dir = reportDir(key);
|
|
3622
|
-
const meta = dir ? readReportAt(dir) : void 0;
|
|
3623
|
-
return meta?.key === key ? meta : void 0;
|
|
3624
|
-
}
|
|
3625
|
-
function reportMarkdownPath(key) {
|
|
3626
|
-
const dir = reportDir(key);
|
|
3627
|
-
const file2 = dir && path25.join(dir, REPORT_MD);
|
|
3628
|
-
return file2 && readReport(key) && fs29.existsSync(file2) ? file2 : void 0;
|
|
3629
|
-
}
|
|
3630
|
-
|
|
3631
3631
|
// packages/core/dist/assistance.js
|
|
3632
3632
|
function assistanceDirectory() {
|
|
3633
3633
|
return path26.join(lobstahHome(), "assistance");
|