@open-artifacts/bus 0.240.0 → 0.242.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/assets/oa-bus.ts +1 -1
- package/assets/openclaw/index.js +1 -1
- package/assets/openclaw/package.json +1 -1
- package/dist/index.js +775 -396
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32905,7 +32905,7 @@ var init_frames = __esm({
|
|
|
32905
32905
|
late = { late: external_exports.array(external_exports.string().min(1)).optional() };
|
|
32906
32906
|
isWellFormed2 = (s) => s.isWellFormed();
|
|
32907
32907
|
WELL_FORMED = { message: "text is not well-formed unicode" };
|
|
32908
|
-
CLIENT_VERSION = true ? "0.
|
|
32908
|
+
CLIENT_VERSION = true ? "0.242.0" : "0.0.0";
|
|
32909
32909
|
clientVersion = {
|
|
32910
32910
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32911
32911
|
};
|
|
@@ -44690,7 +44690,7 @@ import {
|
|
|
44690
44690
|
lstatSync as lstatSync10,
|
|
44691
44691
|
realpathSync as realpathSync10,
|
|
44692
44692
|
unlinkSync as unlinkSync4,
|
|
44693
|
-
writeFileSync as
|
|
44693
|
+
writeFileSync as writeFileSync14
|
|
44694
44694
|
} from "node:fs";
|
|
44695
44695
|
import { basename as basename7, isAbsolute as isAbsolute8, join as join27 } from "node:path";
|
|
44696
44696
|
|
|
@@ -44778,6 +44778,157 @@ var AgentTable = class {
|
|
|
44778
44778
|
}
|
|
44779
44779
|
};
|
|
44780
44780
|
|
|
44781
|
+
// ../bus-daemon/src/announced.ts
|
|
44782
|
+
init_src();
|
|
44783
|
+
init_zod();
|
|
44784
|
+
import { renameSync as renameSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
44785
|
+
|
|
44786
|
+
// ../bus-daemon/src/own-file.ts
|
|
44787
|
+
import {
|
|
44788
|
+
closeSync,
|
|
44789
|
+
constants,
|
|
44790
|
+
fstatSync,
|
|
44791
|
+
openSync,
|
|
44792
|
+
readFileSync as readFileSync2
|
|
44793
|
+
} from "node:fs";
|
|
44794
|
+
import { userInfo } from "node:os";
|
|
44795
|
+
function isPrivateGroup(gid, user, read2 = () => readFileSync2("/etc/group", "utf8"), readPasswd = () => readFileSync2("/etc/passwd", "utf8")) {
|
|
44796
|
+
let text3;
|
|
44797
|
+
let passwd;
|
|
44798
|
+
try {
|
|
44799
|
+
text3 = read2();
|
|
44800
|
+
passwd = readPasswd();
|
|
44801
|
+
} catch {
|
|
44802
|
+
return false;
|
|
44803
|
+
}
|
|
44804
|
+
for (const line of passwd.split("\n")) {
|
|
44805
|
+
const f = line.split(":");
|
|
44806
|
+
if (f[3] === String(gid) && f[0] !== user) return false;
|
|
44807
|
+
}
|
|
44808
|
+
for (const line of text3.split("\n")) {
|
|
44809
|
+
const [name, , id, members2] = line.split(":");
|
|
44810
|
+
if (id === String(gid))
|
|
44811
|
+
return name === user && (members2 ?? "").trim() === "";
|
|
44812
|
+
}
|
|
44813
|
+
return false;
|
|
44814
|
+
}
|
|
44815
|
+
var ownGroup = () => ({
|
|
44816
|
+
gid: process.getgid?.(),
|
|
44817
|
+
isPrivate: (gid) => {
|
|
44818
|
+
if (process.platform !== "linux") return false;
|
|
44819
|
+
try {
|
|
44820
|
+
return isPrivateGroup(gid, userInfo().username);
|
|
44821
|
+
} catch {
|
|
44822
|
+
return false;
|
|
44823
|
+
}
|
|
44824
|
+
}
|
|
44825
|
+
});
|
|
44826
|
+
function readOwnFile(file2, uid = process.getuid?.(), opts = {}) {
|
|
44827
|
+
let fd;
|
|
44828
|
+
try {
|
|
44829
|
+
fd = openSync(
|
|
44830
|
+
file2,
|
|
44831
|
+
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
44832
|
+
);
|
|
44833
|
+
} catch (e) {
|
|
44834
|
+
const code2 = e.code;
|
|
44835
|
+
if (code2 === "ENOENT" || code2 === "ENOTDIR") return { state: "none" };
|
|
44836
|
+
return {
|
|
44837
|
+
state: "unsafe",
|
|
44838
|
+
why: code2 === "ELOOP" ? "is a symlink" : `cannot be read (${code2})`
|
|
44839
|
+
};
|
|
44840
|
+
}
|
|
44841
|
+
try {
|
|
44842
|
+
const st = fstatSync(fd);
|
|
44843
|
+
if (!st.isFile()) return { state: "unsafe", why: "is not a regular file" };
|
|
44844
|
+
if (uid !== void 0 && st.uid !== uid)
|
|
44845
|
+
return { state: "unsafe", why: "belongs to another user" };
|
|
44846
|
+
if (opts.maxBytes !== void 0 && st.size > opts.maxBytes)
|
|
44847
|
+
return { state: "unsafe", why: "is too large" };
|
|
44848
|
+
if (opts.allowGroupWrite) {
|
|
44849
|
+
if (st.mode & 2)
|
|
44850
|
+
return { state: "unsafe", why: "is writable by everyone" };
|
|
44851
|
+
let note;
|
|
44852
|
+
if (st.mode & 16) {
|
|
44853
|
+
const g = opts.group ?? ownGroup();
|
|
44854
|
+
if (st.gid !== g.gid || !g.isPrivate(st.gid))
|
|
44855
|
+
return {
|
|
44856
|
+
state: "unsafe",
|
|
44857
|
+
why: "is writable by a group others share"
|
|
44858
|
+
};
|
|
44859
|
+
note = "is writable by its group";
|
|
44860
|
+
}
|
|
44861
|
+
return {
|
|
44862
|
+
state: "ok",
|
|
44863
|
+
text: readFileSync2(fd, "utf8"),
|
|
44864
|
+
...note ? { note } : {}
|
|
44865
|
+
};
|
|
44866
|
+
}
|
|
44867
|
+
if (st.mode & 18)
|
|
44868
|
+
return { state: "unsafe", why: "is writable by others" };
|
|
44869
|
+
return { state: "ok", text: readFileSync2(fd, "utf8") };
|
|
44870
|
+
} catch (e) {
|
|
44871
|
+
return {
|
|
44872
|
+
state: "unsafe",
|
|
44873
|
+
why: `cannot be read (${e.code ?? String(e)})`
|
|
44874
|
+
};
|
|
44875
|
+
} finally {
|
|
44876
|
+
closeSync(fd);
|
|
44877
|
+
}
|
|
44878
|
+
}
|
|
44879
|
+
|
|
44880
|
+
// ../bus-daemon/src/announced.ts
|
|
44881
|
+
var ANNOUNCED_MAX = 256;
|
|
44882
|
+
var EntrySchema = external_exports.strictObject({
|
|
44883
|
+
ref: AgentRefSchema,
|
|
44884
|
+
/** The harness kind, so a restored close keeps its row's kind (status, roster). */
|
|
44885
|
+
kind: external_exports.string().regex(/^[a-z][a-z0-9-]{0,31}$/),
|
|
44886
|
+
/** #2793: the instance (lane) it was registered on; absent means main. */
|
|
44887
|
+
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/).optional()
|
|
44888
|
+
});
|
|
44889
|
+
var FileSchema = external_exports.strictObject({
|
|
44890
|
+
v: external_exports.literal(1),
|
|
44891
|
+
refs: external_exports.array(external_exports.unknown())
|
|
44892
|
+
});
|
|
44893
|
+
function readAnnounced(file2, uid = process.getuid?.(), log = () => {
|
|
44894
|
+
}) {
|
|
44895
|
+
try {
|
|
44896
|
+
const f = readOwnFile(file2, uid);
|
|
44897
|
+
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
44898
|
+
if (f.state !== "ok") return [];
|
|
44899
|
+
const top = FileSchema.safeParse(JSON.parse(f.text));
|
|
44900
|
+
if (!top.success) {
|
|
44901
|
+
log(`ignoring ${file2}: not the expected shape`);
|
|
44902
|
+
return [];
|
|
44903
|
+
}
|
|
44904
|
+
const out = [];
|
|
44905
|
+
for (const raw of top.data.refs) {
|
|
44906
|
+
if (out.length >= ANNOUNCED_MAX) break;
|
|
44907
|
+
const one3 = EntrySchema.safeParse(raw);
|
|
44908
|
+
if (one3.success) out.push(one3.data);
|
|
44909
|
+
}
|
|
44910
|
+
return out;
|
|
44911
|
+
} catch (e) {
|
|
44912
|
+
log(`ignoring ${file2}: ${e instanceof Error ? e.message : String(e)}`);
|
|
44913
|
+
return [];
|
|
44914
|
+
}
|
|
44915
|
+
}
|
|
44916
|
+
function writeAnnounced(file2, refs) {
|
|
44917
|
+
const tmp = `${file2}.${process.pid}.tmp`;
|
|
44918
|
+
rmSync2(tmp, { force: true });
|
|
44919
|
+
try {
|
|
44920
|
+
writeFileSync(
|
|
44921
|
+
tmp,
|
|
44922
|
+
JSON.stringify({ v: 1, refs: refs.slice(-ANNOUNCED_MAX) }),
|
|
44923
|
+
{ mode: 384, flag: "wx" }
|
|
44924
|
+
);
|
|
44925
|
+
renameSync2(tmp, file2);
|
|
44926
|
+
} catch (e) {
|
|
44927
|
+
rmSync2(tmp, { force: true });
|
|
44928
|
+
throw e;
|
|
44929
|
+
}
|
|
44930
|
+
}
|
|
44931
|
+
|
|
44781
44932
|
// ../bus-daemon/src/attest.ts
|
|
44782
44933
|
init_src3();
|
|
44783
44934
|
init_src2();
|
|
@@ -44788,12 +44939,12 @@ import { basename as basename3, isAbsolute as isAbsolute2 } from "node:path";
|
|
|
44788
44939
|
init_src2();
|
|
44789
44940
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
44790
44941
|
import {
|
|
44791
|
-
closeSync,
|
|
44792
|
-
fstatSync,
|
|
44942
|
+
closeSync as closeSync2,
|
|
44943
|
+
fstatSync as fstatSync2,
|
|
44793
44944
|
lstatSync as lstatSync3,
|
|
44794
|
-
openSync,
|
|
44945
|
+
openSync as openSync2,
|
|
44795
44946
|
readdirSync as readdirSync2,
|
|
44796
|
-
readFileSync as
|
|
44947
|
+
readFileSync as readFileSync5,
|
|
44797
44948
|
readSync,
|
|
44798
44949
|
realpathSync as realpathSync2,
|
|
44799
44950
|
statSync as statSync4
|
|
@@ -44802,7 +44953,7 @@ import { homedir as homedir2 } from "node:os";
|
|
|
44802
44953
|
import { basename as basename2, isAbsolute, join as join5 } from "node:path";
|
|
44803
44954
|
|
|
44804
44955
|
// ../bus-daemon/src/presence/opencode.ts
|
|
44805
|
-
import { readdirSync, readFileSync as
|
|
44956
|
+
import { readdirSync, readFileSync as readFileSync4, statSync as statSync3 } from "node:fs";
|
|
44806
44957
|
import { join as join4 } from "node:path";
|
|
44807
44958
|
|
|
44808
44959
|
// ../bus-daemon/src/config.ts
|
|
@@ -44813,7 +44964,7 @@ import {
|
|
|
44813
44964
|
chmodSync as chmodSync2,
|
|
44814
44965
|
existsSync as existsSync2,
|
|
44815
44966
|
mkdirSync as mkdirSync3,
|
|
44816
|
-
readFileSync as
|
|
44967
|
+
readFileSync as readFileSync3,
|
|
44817
44968
|
statSync as statSync2
|
|
44818
44969
|
} from "node:fs";
|
|
44819
44970
|
import { join as join3 } from "node:path";
|
|
@@ -44823,7 +44974,7 @@ function procBusHome(pid) {
|
|
|
44823
44974
|
if (process.platform !== "linux") return null;
|
|
44824
44975
|
let env2;
|
|
44825
44976
|
try {
|
|
44826
|
-
env2 =
|
|
44977
|
+
env2 = readFileSync3(`/proc/${pid}/environ`, "utf8");
|
|
44827
44978
|
} catch {
|
|
44828
44979
|
return null;
|
|
44829
44980
|
}
|
|
@@ -44913,7 +45064,7 @@ function revokedFor(token, h = home()) {
|
|
|
44913
45064
|
function markerHolds(file2, token) {
|
|
44914
45065
|
if (!existsSync2(file2)) return false;
|
|
44915
45066
|
try {
|
|
44916
|
-
const m = JSON.parse(
|
|
45067
|
+
const m = JSON.parse(readFileSync3(file2, "utf8"));
|
|
44917
45068
|
if (typeof m.token_sha256 === "string")
|
|
44918
45069
|
return m.token_sha256 === tokenHash(token);
|
|
44919
45070
|
} catch {
|
|
@@ -44922,7 +45073,7 @@ function markerHolds(file2, token) {
|
|
|
44922
45073
|
}
|
|
44923
45074
|
function savedToken(h = home()) {
|
|
44924
45075
|
try {
|
|
44925
|
-
const r = JSON.parse(
|
|
45076
|
+
const r = JSON.parse(readFileSync3(join3(h, "machine.json"), "utf8"));
|
|
44926
45077
|
return typeof r.machine_token === "string" ? r.machine_token : void 0;
|
|
44927
45078
|
} catch {
|
|
44928
45079
|
return void 0;
|
|
@@ -44938,7 +45089,7 @@ function readConfig(h = home()) {
|
|
|
44938
45089
|
`${file2} is readable by other users: run \`chmod 600 ${file2}\``
|
|
44939
45090
|
);
|
|
44940
45091
|
}
|
|
44941
|
-
text3 =
|
|
45092
|
+
text3 = readFileSync3(file2, "utf8");
|
|
44942
45093
|
} catch (e) {
|
|
44943
45094
|
const code2 = e.code;
|
|
44944
45095
|
if (code2 === "ENOENT") throw notLoggedIn();
|
|
@@ -45004,7 +45155,7 @@ function openSessions(dir, deps2) {
|
|
|
45004
45155
|
let mtime;
|
|
45005
45156
|
try {
|
|
45006
45157
|
mtime = statSync3(join4(dir, fn)).mtimeMs / 1e3;
|
|
45007
|
-
data = JSON.parse(
|
|
45158
|
+
data = JSON.parse(readFileSync4(join4(dir, fn), "utf8"));
|
|
45008
45159
|
} catch {
|
|
45009
45160
|
continue;
|
|
45010
45161
|
}
|
|
@@ -45039,7 +45190,7 @@ function openState(dir, deps2, ref) {
|
|
|
45039
45190
|
let mtime;
|
|
45040
45191
|
try {
|
|
45041
45192
|
mtime = statSync3(join4(dir, fn)).mtimeMs / 1e3;
|
|
45042
|
-
data = JSON.parse(
|
|
45193
|
+
data = JSON.parse(readFileSync4(join4(dir, fn), "utf8"));
|
|
45043
45194
|
} catch (e) {
|
|
45044
45195
|
if (e.code !== "ENOENT") unknown2 = true;
|
|
45045
45196
|
continue;
|
|
@@ -45082,7 +45233,7 @@ var CODEX_PROXY_ENTRY_FILE = "codex-mcp-entry.json";
|
|
|
45082
45233
|
function codexProxyNamespaces(busHome2) {
|
|
45083
45234
|
try {
|
|
45084
45235
|
const v = JSON.parse(
|
|
45085
|
-
|
|
45236
|
+
readFileSync5(`${busHome2}/${CODEX_PROXY_ENTRY_FILE}`, "utf8")
|
|
45086
45237
|
);
|
|
45087
45238
|
const name = v?.name;
|
|
45088
45239
|
if (typeof name !== "string" || name === "") return [];
|
|
@@ -45361,12 +45512,12 @@ function codexAttestor(deps2 = {}) {
|
|
|
45361
45512
|
function advance(scan2, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
45362
45513
|
let fd;
|
|
45363
45514
|
try {
|
|
45364
|
-
fd =
|
|
45515
|
+
fd = openSync2(scan2.rollout, "r");
|
|
45365
45516
|
} catch {
|
|
45366
45517
|
return;
|
|
45367
45518
|
}
|
|
45368
45519
|
try {
|
|
45369
|
-
const size =
|
|
45520
|
+
const size = fstatSync2(fd).size;
|
|
45370
45521
|
if (scan2.offset > size) {
|
|
45371
45522
|
scan2.offset = -1;
|
|
45372
45523
|
Object.assign(scan2, seen());
|
|
@@ -45381,7 +45532,7 @@ function advance(scan2, namespaces = [CODEX_TOOL_NAMESPACE]) {
|
|
|
45381
45532
|
return false;
|
|
45382
45533
|
});
|
|
45383
45534
|
} finally {
|
|
45384
|
-
|
|
45535
|
+
closeSync2(fd);
|
|
45385
45536
|
}
|
|
45386
45537
|
}
|
|
45387
45538
|
function readLines(fd, from, size, skipFirst, visit3, cap = LINE_CAP) {
|
|
@@ -45554,13 +45705,13 @@ function globRollout(home2, thread) {
|
|
|
45554
45705
|
function sessionMeta(path, thread) {
|
|
45555
45706
|
let fd;
|
|
45556
45707
|
try {
|
|
45557
|
-
fd =
|
|
45708
|
+
fd = openSync2(path, "r");
|
|
45558
45709
|
} catch {
|
|
45559
45710
|
return void 0;
|
|
45560
45711
|
}
|
|
45561
45712
|
try {
|
|
45562
45713
|
let first;
|
|
45563
|
-
const size = Math.min(
|
|
45714
|
+
const size = Math.min(fstatSync2(fd).size, META_CAP + 1);
|
|
45564
45715
|
readLines(
|
|
45565
45716
|
fd,
|
|
45566
45717
|
0,
|
|
@@ -45581,7 +45732,7 @@ function sessionMeta(path, thread) {
|
|
|
45581
45732
|
} catch {
|
|
45582
45733
|
return void 0;
|
|
45583
45734
|
} finally {
|
|
45584
|
-
|
|
45735
|
+
closeSync2(fd);
|
|
45585
45736
|
}
|
|
45586
45737
|
}
|
|
45587
45738
|
var exitedOne = (e) => {
|
|
@@ -45700,7 +45851,7 @@ function holdingLinux(pairs, procRoot = "/proc") {
|
|
|
45700
45851
|
let locks;
|
|
45701
45852
|
try {
|
|
45702
45853
|
locks = new Set(
|
|
45703
|
-
|
|
45854
|
+
readFileSync5(join5(procRoot, "locks"), "utf8").split("\n").flatMap((l) => {
|
|
45704
45855
|
const [maj, min, ino] = (l.trim().split(/\s+/)[5] ?? "").split(":");
|
|
45705
45856
|
if (!maj || !min || !ino) return [];
|
|
45706
45857
|
if (!/^[0-9a-f]+$/i.test(maj + min) || !/^\d+$/.test(ino)) return [];
|
|
@@ -45787,7 +45938,7 @@ function fdHoldsLock(procRoot, pid, fd, st) {
|
|
|
45787
45938
|
try {
|
|
45788
45939
|
const { major, minor } = devParts(st.dev);
|
|
45789
45940
|
const want = `${major}:${minor}:${st.ino}`;
|
|
45790
|
-
return
|
|
45941
|
+
return readFileSync5(join5(procRoot, String(pid), "fdinfo", fd), "utf8").split("\n").some((l) => {
|
|
45791
45942
|
if (!l.startsWith("lock:")) return false;
|
|
45792
45943
|
const f = l.trim().split(/\s+/);
|
|
45793
45944
|
if (!REAL_LOCKS.has(f[2] ?? "")) return false;
|
|
@@ -45805,7 +45956,7 @@ function fdHoldsLock(procRoot, pid, fd, st) {
|
|
|
45805
45956
|
init_src3();
|
|
45806
45957
|
init_src();
|
|
45807
45958
|
import { createHash as createHash4 } from "node:crypto";
|
|
45808
|
-
import { readdirSync as readdirSync3, readFileSync as
|
|
45959
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6 } from "node:fs";
|
|
45809
45960
|
import { join as join6 } from "node:path";
|
|
45810
45961
|
var sha256Of = (s) => createHash4("sha256").update(s).digest("hex");
|
|
45811
45962
|
function scanSessions(dir) {
|
|
@@ -45822,7 +45973,7 @@ function scanSessions(dir) {
|
|
|
45822
45973
|
if (!m) continue;
|
|
45823
45974
|
let rec;
|
|
45824
45975
|
try {
|
|
45825
|
-
rec = JSON.parse(
|
|
45976
|
+
rec = JSON.parse(readFileSync6(join6(dir, fn), "utf8"));
|
|
45826
45977
|
} catch {
|
|
45827
45978
|
unreadable.add(Number(m[1]));
|
|
45828
45979
|
continue;
|
|
@@ -45907,7 +46058,7 @@ function claudeTargetState(ref, pid, deps2) {
|
|
|
45907
46058
|
if (f.socketPath === "") return "unreachable";
|
|
45908
46059
|
try {
|
|
45909
46060
|
const key2 = JSON.parse(
|
|
45910
|
-
|
|
46061
|
+
readFileSync6(
|
|
45911
46062
|
join6(deps2.dir, `${pid}.${(deps2.sha256 ?? sha256Of)(f.socketPath)}.key`),
|
|
45912
46063
|
"utf8"
|
|
45913
46064
|
)
|
|
@@ -45961,7 +46112,7 @@ function isRunning(pid) {
|
|
|
45961
46112
|
// ../bus-daemon/src/presence/attached.ts
|
|
45962
46113
|
init_src2();
|
|
45963
46114
|
import { execFileSync as execFileSync3, spawnSync } from "node:child_process";
|
|
45964
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
46115
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync7, readlinkSync } from "node:fs";
|
|
45965
46116
|
var READ_TIMEOUT_MS = 1500;
|
|
45966
46117
|
var exePath = (exe) => exe === null ? null : exe.replace(/ \(deleted\)$/, "");
|
|
45967
46118
|
function attachedTo(service, deps2) {
|
|
@@ -46053,8 +46204,8 @@ function socketInodes(pid) {
|
|
|
46053
46204
|
function tcpRows() {
|
|
46054
46205
|
try {
|
|
46055
46206
|
return [
|
|
46056
|
-
...parseProcNetTcp(
|
|
46057
|
-
...parseProcNetTcp(
|
|
46207
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp", "utf8")),
|
|
46208
|
+
...parseProcNetTcp(readFileSync7("/proc/net/tcp6", "utf8"))
|
|
46058
46209
|
];
|
|
46059
46210
|
} catch {
|
|
46060
46211
|
return null;
|
|
@@ -46100,6 +46251,33 @@ function lsofEstablished(text3) {
|
|
|
46100
46251
|
}
|
|
46101
46252
|
return out;
|
|
46102
46253
|
}
|
|
46254
|
+
function exeFromLsof(text3) {
|
|
46255
|
+
let fd = "";
|
|
46256
|
+
for (const line of text3.split("\n")) {
|
|
46257
|
+
if (line.startsWith("f")) {
|
|
46258
|
+
fd = line.slice(1).trim();
|
|
46259
|
+
continue;
|
|
46260
|
+
}
|
|
46261
|
+
if (!line.startsWith("n")) continue;
|
|
46262
|
+
const path = line.slice(1).trim();
|
|
46263
|
+
if (fd === "cwd" || !path.startsWith("/")) continue;
|
|
46264
|
+
return path;
|
|
46265
|
+
}
|
|
46266
|
+
return null;
|
|
46267
|
+
}
|
|
46268
|
+
function macExeOf(pid, runLsof = spawnSync) {
|
|
46269
|
+
const r = runLsof(
|
|
46270
|
+
systemTool("lsof"),
|
|
46271
|
+
["-a", "-d", "txt", "-Ffn", "-p", String(pid)],
|
|
46272
|
+
{
|
|
46273
|
+
encoding: "utf8",
|
|
46274
|
+
timeout: READ_TIMEOUT_MS,
|
|
46275
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
46276
|
+
}
|
|
46277
|
+
);
|
|
46278
|
+
if (r.error !== void 0 || r.signal !== null) return null;
|
|
46279
|
+
return exeFromLsof(r.stdout ?? "");
|
|
46280
|
+
}
|
|
46103
46281
|
var defaultAttachDeps = {
|
|
46104
46282
|
exeOf(pid) {
|
|
46105
46283
|
if (process.platform === "linux") {
|
|
@@ -46109,8 +46287,7 @@ var defaultAttachDeps = {
|
|
|
46109
46287
|
return null;
|
|
46110
46288
|
}
|
|
46111
46289
|
}
|
|
46112
|
-
|
|
46113
|
-
return out?.startsWith("/") ? out : null;
|
|
46290
|
+
return macExeOf(pid);
|
|
46114
46291
|
},
|
|
46115
46292
|
ppidOf(pid) {
|
|
46116
46293
|
const out = run2("ps", ["-o", "ppid=", "-p", String(pid)])?.trim();
|
|
@@ -46249,119 +46426,23 @@ import {
|
|
|
46249
46426
|
existsSync as existsSync3,
|
|
46250
46427
|
readdirSync as readdirSync5,
|
|
46251
46428
|
readFileSync as readFileSync8,
|
|
46252
|
-
renameSync as
|
|
46253
|
-
rmSync as
|
|
46254
|
-
writeFileSync
|
|
46429
|
+
renameSync as renameSync3,
|
|
46430
|
+
rmSync as rmSync3,
|
|
46431
|
+
writeFileSync as writeFileSync2
|
|
46255
46432
|
} from "node:fs";
|
|
46256
46433
|
import { homedir as homedir3 } from "node:os";
|
|
46257
46434
|
import { join as join7 } from "node:path";
|
|
46258
46435
|
import { createInterface } from "node:readline";
|
|
46259
|
-
|
|
46260
|
-
// ../bus-daemon/src/own-file.ts
|
|
46261
|
-
import {
|
|
46262
|
-
closeSync as closeSync2,
|
|
46263
|
-
constants,
|
|
46264
|
-
fstatSync as fstatSync2,
|
|
46265
|
-
openSync as openSync2,
|
|
46266
|
-
readFileSync as readFileSync7
|
|
46267
|
-
} from "node:fs";
|
|
46268
|
-
import { userInfo } from "node:os";
|
|
46269
|
-
function isPrivateGroup(gid, user, read2 = () => readFileSync7("/etc/group", "utf8"), readPasswd = () => readFileSync7("/etc/passwd", "utf8")) {
|
|
46270
|
-
let text3;
|
|
46271
|
-
let passwd;
|
|
46272
|
-
try {
|
|
46273
|
-
text3 = read2();
|
|
46274
|
-
passwd = readPasswd();
|
|
46275
|
-
} catch {
|
|
46276
|
-
return false;
|
|
46277
|
-
}
|
|
46278
|
-
for (const line of passwd.split("\n")) {
|
|
46279
|
-
const f = line.split(":");
|
|
46280
|
-
if (f[3] === String(gid) && f[0] !== user) return false;
|
|
46281
|
-
}
|
|
46282
|
-
for (const line of text3.split("\n")) {
|
|
46283
|
-
const [name, , id, members2] = line.split(":");
|
|
46284
|
-
if (id === String(gid))
|
|
46285
|
-
return name === user && (members2 ?? "").trim() === "";
|
|
46286
|
-
}
|
|
46287
|
-
return false;
|
|
46288
|
-
}
|
|
46289
|
-
var ownGroup = () => ({
|
|
46290
|
-
gid: process.getgid?.(),
|
|
46291
|
-
isPrivate: (gid) => {
|
|
46292
|
-
if (process.platform !== "linux") return false;
|
|
46293
|
-
try {
|
|
46294
|
-
return isPrivateGroup(gid, userInfo().username);
|
|
46295
|
-
} catch {
|
|
46296
|
-
return false;
|
|
46297
|
-
}
|
|
46298
|
-
}
|
|
46299
|
-
});
|
|
46300
|
-
function readOwnFile(file2, uid = process.getuid?.(), opts = {}) {
|
|
46301
|
-
let fd;
|
|
46302
|
-
try {
|
|
46303
|
-
fd = openSync2(
|
|
46304
|
-
file2,
|
|
46305
|
-
constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0)
|
|
46306
|
-
);
|
|
46307
|
-
} catch (e) {
|
|
46308
|
-
const code2 = e.code;
|
|
46309
|
-
if (code2 === "ENOENT" || code2 === "ENOTDIR") return { state: "none" };
|
|
46310
|
-
return {
|
|
46311
|
-
state: "unsafe",
|
|
46312
|
-
why: code2 === "ELOOP" ? "is a symlink" : `cannot be read (${code2})`
|
|
46313
|
-
};
|
|
46314
|
-
}
|
|
46315
|
-
try {
|
|
46316
|
-
const st = fstatSync2(fd);
|
|
46317
|
-
if (!st.isFile()) return { state: "unsafe", why: "is not a regular file" };
|
|
46318
|
-
if (uid !== void 0 && st.uid !== uid)
|
|
46319
|
-
return { state: "unsafe", why: "belongs to another user" };
|
|
46320
|
-
if (opts.maxBytes !== void 0 && st.size > opts.maxBytes)
|
|
46321
|
-
return { state: "unsafe", why: "is too large" };
|
|
46322
|
-
if (opts.allowGroupWrite) {
|
|
46323
|
-
if (st.mode & 2)
|
|
46324
|
-
return { state: "unsafe", why: "is writable by everyone" };
|
|
46325
|
-
let note;
|
|
46326
|
-
if (st.mode & 16) {
|
|
46327
|
-
const g = opts.group ?? ownGroup();
|
|
46328
|
-
if (st.gid !== g.gid || !g.isPrivate(st.gid))
|
|
46329
|
-
return {
|
|
46330
|
-
state: "unsafe",
|
|
46331
|
-
why: "is writable by a group others share"
|
|
46332
|
-
};
|
|
46333
|
-
note = "is writable by its group";
|
|
46334
|
-
}
|
|
46335
|
-
return {
|
|
46336
|
-
state: "ok",
|
|
46337
|
-
text: readFileSync7(fd, "utf8"),
|
|
46338
|
-
...note ? { note } : {}
|
|
46339
|
-
};
|
|
46340
|
-
}
|
|
46341
|
-
if (st.mode & 18)
|
|
46342
|
-
return { state: "unsafe", why: "is writable by others" };
|
|
46343
|
-
return { state: "ok", text: readFileSync7(fd, "utf8") };
|
|
46344
|
-
} catch (e) {
|
|
46345
|
-
return {
|
|
46346
|
-
state: "unsafe",
|
|
46347
|
-
why: `cannot be read (${e.code ?? String(e)})`
|
|
46348
|
-
};
|
|
46349
|
-
} finally {
|
|
46350
|
-
closeSync2(fd);
|
|
46351
|
-
}
|
|
46352
|
-
}
|
|
46353
|
-
|
|
46354
|
-
// ../bus-daemon/src/claude-guests.ts
|
|
46355
46436
|
var CLAUDE_GUESTS_MAX = 64;
|
|
46356
46437
|
var CLAUDE_STASH_MAX = 64;
|
|
46357
|
-
var
|
|
46438
|
+
var EntrySchema2 = external_exports.strictObject({
|
|
46358
46439
|
pid: external_exports.number().int().positive(),
|
|
46359
46440
|
procStart: external_exports.string().min(1).max(100),
|
|
46360
46441
|
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/),
|
|
46361
46442
|
/** The opaque ref this guest has on that instance only; random, never derived from the session. */
|
|
46362
46443
|
ref: external_exports.string().regex(/^[A-Za-z0-9_-]{16,64}$/).optional()
|
|
46363
46444
|
});
|
|
46364
|
-
var
|
|
46445
|
+
var FileSchema2 = external_exports.strictObject({
|
|
46365
46446
|
v: external_exports.literal(1),
|
|
46366
46447
|
guests: external_exports.array(external_exports.unknown())
|
|
46367
46448
|
});
|
|
@@ -46371,7 +46452,7 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46371
46452
|
const f = readOwnFile(file2, uid);
|
|
46372
46453
|
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
46373
46454
|
if (f.state !== "ok") return [];
|
|
46374
|
-
const top =
|
|
46455
|
+
const top = FileSchema2.safeParse(JSON.parse(f.text));
|
|
46375
46456
|
if (!top.success) {
|
|
46376
46457
|
log(`ignoring ${file2}: not the expected shape`);
|
|
46377
46458
|
return [];
|
|
@@ -46379,7 +46460,7 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46379
46460
|
const out = [];
|
|
46380
46461
|
for (const raw of top.data.guests) {
|
|
46381
46462
|
if (out.length >= CLAUDE_GUESTS_MAX) break;
|
|
46382
|
-
const one3 =
|
|
46463
|
+
const one3 = EntrySchema2.safeParse(raw);
|
|
46383
46464
|
if (one3.success) out.push(one3.data);
|
|
46384
46465
|
}
|
|
46385
46466
|
return out;
|
|
@@ -46390,16 +46471,16 @@ function readClaudeGuests(file2, uid = process.getuid?.(), log = () => {
|
|
|
46390
46471
|
}
|
|
46391
46472
|
function writeClaudeGuests(file2, guests) {
|
|
46392
46473
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46393
|
-
|
|
46474
|
+
rmSync3(tmp, { force: true });
|
|
46394
46475
|
try {
|
|
46395
|
-
|
|
46476
|
+
writeFileSync2(
|
|
46396
46477
|
tmp,
|
|
46397
46478
|
JSON.stringify({ v: 1, guests: guests.slice(0, CLAUDE_GUESTS_MAX) }),
|
|
46398
46479
|
{ mode: 384, flag: "wx" }
|
|
46399
46480
|
);
|
|
46400
|
-
|
|
46481
|
+
renameSync3(tmp, file2);
|
|
46401
46482
|
} catch (e) {
|
|
46402
|
-
|
|
46483
|
+
rmSync3(tmp, { force: true });
|
|
46403
46484
|
throw e;
|
|
46404
46485
|
}
|
|
46405
46486
|
}
|
|
@@ -46522,16 +46603,16 @@ async function usedToolOf(transcript, prefixes) {
|
|
|
46522
46603
|
|
|
46523
46604
|
// ../bus-daemon/src/claude-links.ts
|
|
46524
46605
|
init_zod();
|
|
46525
|
-
import { renameSync as
|
|
46606
|
+
import { renameSync as renameSync4, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
46526
46607
|
var CLAUDE_LINKS_MAX = 64;
|
|
46527
|
-
var
|
|
46608
|
+
var EntrySchema3 = external_exports.strictObject({
|
|
46528
46609
|
pid: external_exports.number().int().positive(),
|
|
46529
46610
|
procStart: external_exports.string().min(1).max(100),
|
|
46530
46611
|
hashes: external_exports.array(external_exports.string().regex(/^[0-9a-f]{64}$/)).min(1),
|
|
46531
46612
|
/** #2793 S4: the instance the hashes are for; absent means main. */
|
|
46532
46613
|
instance: external_exports.string().regex(/^[a-z0-9-]{1,32}$/).optional()
|
|
46533
46614
|
});
|
|
46534
|
-
var
|
|
46615
|
+
var FileSchema3 = external_exports.strictObject({
|
|
46535
46616
|
v: external_exports.literal(1),
|
|
46536
46617
|
links: external_exports.array(external_exports.unknown())
|
|
46537
46618
|
});
|
|
@@ -46541,7 +46622,7 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46541
46622
|
const f = readOwnFile(file2, uid);
|
|
46542
46623
|
if (f.state === "unsafe") log(`ignoring ${file2}: ${f.why}`);
|
|
46543
46624
|
if (f.state !== "ok") return [];
|
|
46544
|
-
const top =
|
|
46625
|
+
const top = FileSchema3.safeParse(JSON.parse(f.text));
|
|
46545
46626
|
if (!top.success) {
|
|
46546
46627
|
log(`ignoring ${file2}: not the expected shape`);
|
|
46547
46628
|
return [];
|
|
@@ -46549,7 +46630,7 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46549
46630
|
const out = [];
|
|
46550
46631
|
for (const raw of top.data.links) {
|
|
46551
46632
|
if (out.length >= CLAUDE_LINKS_MAX) break;
|
|
46552
|
-
const one3 =
|
|
46633
|
+
const one3 = EntrySchema3.safeParse(raw);
|
|
46553
46634
|
if (one3.success)
|
|
46554
46635
|
out.push({
|
|
46555
46636
|
...one3.data,
|
|
@@ -46564,16 +46645,16 @@ function readClaudeLinks(file2, uid = process.getuid?.(), log = () => {
|
|
|
46564
46645
|
}
|
|
46565
46646
|
function writeClaudeLinks(file2, links) {
|
|
46566
46647
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46567
|
-
|
|
46648
|
+
rmSync4(tmp, { force: true });
|
|
46568
46649
|
try {
|
|
46569
|
-
|
|
46650
|
+
writeFileSync3(
|
|
46570
46651
|
tmp,
|
|
46571
46652
|
JSON.stringify({ v: 1, links: links.slice(0, CLAUDE_LINKS_MAX) }),
|
|
46572
46653
|
{ mode: 384, flag: "wx" }
|
|
46573
46654
|
);
|
|
46574
|
-
|
|
46655
|
+
renameSync4(tmp, file2);
|
|
46575
46656
|
} catch (e) {
|
|
46576
|
-
|
|
46657
|
+
rmSync4(tmp, { force: true });
|
|
46577
46658
|
throw e;
|
|
46578
46659
|
}
|
|
46579
46660
|
}
|
|
@@ -46581,7 +46662,7 @@ function writeClaudeLinks(file2, links) {
|
|
|
46581
46662
|
// ../bus-daemon/src/codex-agents.ts
|
|
46582
46663
|
init_src();
|
|
46583
46664
|
init_zod();
|
|
46584
|
-
import { chmodSync as chmodSync3, renameSync as
|
|
46665
|
+
import { chmodSync as chmodSync3, renameSync as renameSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
46585
46666
|
var CodexAgentSchema = external_exports.strictObject({
|
|
46586
46667
|
/** Joined into the thread's lock path: a real ref, never `../`. */
|
|
46587
46668
|
ref: AgentRefSchema,
|
|
@@ -46592,7 +46673,7 @@ var CodexAgentSchema = external_exports.strictObject({
|
|
|
46592
46673
|
sentName: external_exports.string().max(200).optional(),
|
|
46593
46674
|
busName: external_exports.string().min(1).max(200)
|
|
46594
46675
|
});
|
|
46595
|
-
var
|
|
46676
|
+
var FileSchema4 = external_exports.strictObject({
|
|
46596
46677
|
v: external_exports.literal(1),
|
|
46597
46678
|
agents: external_exports.array(external_exports.unknown())
|
|
46598
46679
|
});
|
|
@@ -46600,7 +46681,7 @@ function readCodexAgents(file2, uid = process.getuid?.()) {
|
|
|
46600
46681
|
try {
|
|
46601
46682
|
const f = readOwnFile(file2, uid);
|
|
46602
46683
|
if (f.state !== "ok") return [];
|
|
46603
|
-
const top =
|
|
46684
|
+
const top = FileSchema4.safeParse(JSON.parse(f.text));
|
|
46604
46685
|
if (!top.success) return [];
|
|
46605
46686
|
const seen2 = /* @__PURE__ */ new Set();
|
|
46606
46687
|
const out = [];
|
|
@@ -46618,15 +46699,15 @@ function readCodexAgents(file2, uid = process.getuid?.()) {
|
|
|
46618
46699
|
}
|
|
46619
46700
|
function writeCodexAgents(file2, agents) {
|
|
46620
46701
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46621
|
-
|
|
46702
|
+
writeFileSync4(tmp, JSON.stringify({ v: 1, agents }), { mode: 384 });
|
|
46622
46703
|
chmodSync3(tmp, 384);
|
|
46623
|
-
|
|
46704
|
+
renameSync5(tmp, file2);
|
|
46624
46705
|
}
|
|
46625
46706
|
|
|
46626
46707
|
// ../bus-daemon/src/codex-away.ts
|
|
46627
46708
|
init_src();
|
|
46628
46709
|
init_zod();
|
|
46629
|
-
import { chmodSync as chmodSync4, renameSync as
|
|
46710
|
+
import { chmodSync as chmodSync4, renameSync as renameSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
46630
46711
|
var AWAY_IDLE_MS = 24 * 36e5;
|
|
46631
46712
|
var AWAY_MAX = 64;
|
|
46632
46713
|
var CodexAwaySchema = external_exports.strictObject({
|
|
@@ -46636,7 +46717,7 @@ var CodexAwaySchema = external_exports.strictObject({
|
|
|
46636
46717
|
/** When the thread was last live (ms), to the hour. */
|
|
46637
46718
|
lastLive: external_exports.number().int().nonnegative()
|
|
46638
46719
|
});
|
|
46639
|
-
var
|
|
46720
|
+
var FileSchema5 = external_exports.strictObject({
|
|
46640
46721
|
v: external_exports.literal(1),
|
|
46641
46722
|
rows: external_exports.array(external_exports.unknown())
|
|
46642
46723
|
});
|
|
@@ -46647,7 +46728,7 @@ function readCodexAway(file2, now, uid = process.getuid?.()) {
|
|
|
46647
46728
|
try {
|
|
46648
46729
|
const f = readOwnFile(file2, uid);
|
|
46649
46730
|
if (f.state !== "ok") return [];
|
|
46650
|
-
const top =
|
|
46731
|
+
const top = FileSchema5.safeParse(JSON.parse(f.text));
|
|
46651
46732
|
if (!top.success) return [];
|
|
46652
46733
|
const seen2 = /* @__PURE__ */ new Set();
|
|
46653
46734
|
const out = [];
|
|
@@ -46664,9 +46745,9 @@ function readCodexAway(file2, now, uid = process.getuid?.()) {
|
|
|
46664
46745
|
}
|
|
46665
46746
|
function writeCodexAway(file2, rows) {
|
|
46666
46747
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
46667
|
-
|
|
46748
|
+
writeFileSync5(tmp, JSON.stringify({ v: 1, rows }), { mode: 384 });
|
|
46668
46749
|
chmodSync4(tmp, 384);
|
|
46669
|
-
|
|
46750
|
+
renameSync6(tmp, file2);
|
|
46670
46751
|
}
|
|
46671
46752
|
|
|
46672
46753
|
// ../bus-daemon/src/codex-names.ts
|
|
@@ -46740,8 +46821,8 @@ import {
|
|
|
46740
46821
|
openSync as openSync4,
|
|
46741
46822
|
readFileSync as readFileSync9,
|
|
46742
46823
|
readSync as readSync3,
|
|
46743
|
-
renameSync as
|
|
46744
|
-
writeFileSync as
|
|
46824
|
+
renameSync as renameSync7,
|
|
46825
|
+
writeFileSync as writeFileSync6
|
|
46745
46826
|
} from "node:fs";
|
|
46746
46827
|
import { dirname as dirname3, join as join9 } from "node:path";
|
|
46747
46828
|
var NOTICE_WATCH_MS = 6 * 60 * 60 * 1e3;
|
|
@@ -47159,11 +47240,11 @@ var TakenWatch = class {
|
|
|
47159
47240
|
#save() {
|
|
47160
47241
|
const tmp = `${this.opts.file}.${process.pid}.tmp`;
|
|
47161
47242
|
try {
|
|
47162
|
-
|
|
47243
|
+
writeFileSync6(tmp, JSON.stringify(Object.fromEntries(this.#recs)), {
|
|
47163
47244
|
mode: 384
|
|
47164
47245
|
});
|
|
47165
47246
|
chmodSync5(tmp, 384);
|
|
47166
|
-
|
|
47247
|
+
renameSync7(tmp, this.opts.file);
|
|
47167
47248
|
return true;
|
|
47168
47249
|
} catch (e) {
|
|
47169
47250
|
this.opts.log?.(
|
|
@@ -47188,7 +47269,7 @@ import {
|
|
|
47188
47269
|
mkdirSync as mkdirSync4,
|
|
47189
47270
|
openSync as openSync5,
|
|
47190
47271
|
realpathSync as realpathSync3,
|
|
47191
|
-
renameSync as
|
|
47272
|
+
renameSync as renameSync8,
|
|
47192
47273
|
statSync as statSync5,
|
|
47193
47274
|
unlinkSync,
|
|
47194
47275
|
writeSync
|
|
@@ -47275,7 +47356,7 @@ function writeGlobalDirs(dirs, h = home()) {
|
|
|
47275
47356
|
closeSync5(fd);
|
|
47276
47357
|
try {
|
|
47277
47358
|
chmodSync6(tmp, 384);
|
|
47278
|
-
|
|
47359
|
+
renameSync8(tmp, globalFile(h));
|
|
47279
47360
|
} catch (e) {
|
|
47280
47361
|
unlinkSync(tmp);
|
|
47281
47362
|
throw e;
|
|
@@ -47303,7 +47384,7 @@ import {
|
|
|
47303
47384
|
closeSync as closeSync7,
|
|
47304
47385
|
mkdirSync as mkdirSync6,
|
|
47305
47386
|
openSync as openSync7,
|
|
47306
|
-
renameSync as
|
|
47387
|
+
renameSync as renameSync9,
|
|
47307
47388
|
unlinkSync as unlinkSync3,
|
|
47308
47389
|
writeSync as writeSync3
|
|
47309
47390
|
} from "node:fs";
|
|
@@ -47649,7 +47730,7 @@ function writePrivate(h, name, body) {
|
|
|
47649
47730
|
closeSync7(fd);
|
|
47650
47731
|
try {
|
|
47651
47732
|
chmodSync8(tmp, 384);
|
|
47652
|
-
|
|
47733
|
+
renameSync9(tmp, join12(h, name));
|
|
47653
47734
|
} catch (e) {
|
|
47654
47735
|
unlinkSync3(tmp);
|
|
47655
47736
|
throw e;
|
|
@@ -49799,9 +49880,9 @@ init_src();
|
|
|
49799
49880
|
import {
|
|
49800
49881
|
chmodSync as chmodSync9,
|
|
49801
49882
|
readFileSync as readFileSync11,
|
|
49802
|
-
renameSync as
|
|
49803
|
-
rmSync as
|
|
49804
|
-
writeFileSync as
|
|
49883
|
+
renameSync as renameSync10,
|
|
49884
|
+
rmSync as rmSync5,
|
|
49885
|
+
writeFileSync as writeFileSync7
|
|
49805
49886
|
} from "node:fs";
|
|
49806
49887
|
var metaOf = ({
|
|
49807
49888
|
at: _,
|
|
@@ -50090,13 +50171,13 @@ var SentStore = class {
|
|
|
50090
50171
|
if (!this.file) return;
|
|
50091
50172
|
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
50092
50173
|
try {
|
|
50093
|
-
|
|
50094
|
-
|
|
50174
|
+
rmSync5(tmp, { force: true });
|
|
50175
|
+
writeFileSync7(tmp, JSON.stringify(Object.fromEntries(this.#all)), {
|
|
50095
50176
|
mode: 384,
|
|
50096
50177
|
flag: "wx"
|
|
50097
50178
|
});
|
|
50098
50179
|
chmodSync9(tmp, 384);
|
|
50099
|
-
|
|
50180
|
+
renameSync10(tmp, this.file);
|
|
50100
50181
|
} catch (e) {
|
|
50101
50182
|
this.#log?.(
|
|
50102
50183
|
`sent file write failed: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -50292,16 +50373,16 @@ import {
|
|
|
50292
50373
|
lstatSync as lstatSync6,
|
|
50293
50374
|
mkdirSync as mkdirSync7,
|
|
50294
50375
|
readFileSync as readFileSync13,
|
|
50295
|
-
renameSync as
|
|
50296
|
-
rmSync as
|
|
50297
|
-
writeFileSync as
|
|
50376
|
+
renameSync as renameSync12,
|
|
50377
|
+
rmSync as rmSync6,
|
|
50378
|
+
writeFileSync as writeFileSync9
|
|
50298
50379
|
} from "node:fs";
|
|
50299
50380
|
import { createServer as createServer2 } from "node:net";
|
|
50300
50381
|
import { dirname as dirname9, join as join16 } from "node:path";
|
|
50301
50382
|
import { createInterface as createInterface2 } from "node:readline";
|
|
50302
50383
|
|
|
50303
50384
|
// ../bus-daemon/src/transports/held.ts
|
|
50304
|
-
import { chmodSync as chmodSync10, readFileSync as readFileSync12, renameSync as
|
|
50385
|
+
import { chmodSync as chmodSync10, readFileSync as readFileSync12, renameSync as renameSync11, writeFileSync as writeFileSync8 } from "node:fs";
|
|
50305
50386
|
var HeldStore = class {
|
|
50306
50387
|
constructor(file2, opts = {}) {
|
|
50307
50388
|
this.file = file2;
|
|
@@ -50343,9 +50424,9 @@ var HeldStore = class {
|
|
|
50343
50424
|
}
|
|
50344
50425
|
#write(all) {
|
|
50345
50426
|
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
50346
|
-
|
|
50427
|
+
writeFileSync8(tmp, JSON.stringify(all), { mode: 384 });
|
|
50347
50428
|
chmodSync10(tmp, 384);
|
|
50348
|
-
|
|
50429
|
+
renameSync11(tmp, this.file);
|
|
50349
50430
|
}
|
|
50350
50431
|
};
|
|
50351
50432
|
|
|
@@ -50700,7 +50781,7 @@ var ClaudeTransport = class {
|
|
|
50700
50781
|
mkdirSync7(this.opts.socketsDir, { recursive: true, mode: 448 });
|
|
50701
50782
|
chmodSync11(this.opts.socketsDir, 448);
|
|
50702
50783
|
}
|
|
50703
|
-
|
|
50784
|
+
rmSync6(path, { force: true });
|
|
50704
50785
|
this.#paths.set(key2, path);
|
|
50705
50786
|
const conns = /* @__PURE__ */ new Set();
|
|
50706
50787
|
const sink = {
|
|
@@ -50770,9 +50851,9 @@ var ClaudeTransport = class {
|
|
|
50770
50851
|
const out = /* @__PURE__ */ Object.create(null);
|
|
50771
50852
|
for (const [k, v] of keep) out[k] = v;
|
|
50772
50853
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
50773
|
-
|
|
50854
|
+
writeFileSync9(tmp, JSON.stringify(out), { mode: 384 });
|
|
50774
50855
|
chmodSync11(tmp, 384);
|
|
50775
|
-
|
|
50856
|
+
renameSync12(tmp, file2);
|
|
50776
50857
|
return out;
|
|
50777
50858
|
} catch (e) {
|
|
50778
50859
|
this.opts.log?.(
|
|
@@ -50844,7 +50925,7 @@ var ClaudeTransport = class {
|
|
|
50844
50925
|
async function shut(sink) {
|
|
50845
50926
|
for (const c of sink.conns) c.destroy();
|
|
50846
50927
|
await new Promise((r) => sink.server.close(() => r()));
|
|
50847
|
-
|
|
50928
|
+
rmSync6(sink.path, { force: true });
|
|
50848
50929
|
}
|
|
50849
50930
|
|
|
50850
50931
|
// ../bus-daemon/src/transports/codex.ts
|
|
@@ -51567,10 +51648,10 @@ import {
|
|
|
51567
51648
|
readFileSync as readFileSync15,
|
|
51568
51649
|
readlinkSync as readlinkSync2,
|
|
51569
51650
|
realpathSync as realpathSync7,
|
|
51570
|
-
renameSync as
|
|
51571
|
-
rmSync as
|
|
51651
|
+
renameSync as renameSync13,
|
|
51652
|
+
rmSync as rmSync7,
|
|
51572
51653
|
symlinkSync,
|
|
51573
|
-
writeFileSync as
|
|
51654
|
+
writeFileSync as writeFileSync10
|
|
51574
51655
|
} from "node:fs";
|
|
51575
51656
|
import { join as join20, relative as relative3, sep as sep3 } from "node:path";
|
|
51576
51657
|
var SAFE_VERSION = /^[0-9A-Za-z][0-9A-Za-z._+-]{0,63}$/;
|
|
@@ -51636,12 +51717,12 @@ function writeState(home2, state) {
|
|
|
51636
51717
|
else next[k] = state[k];
|
|
51637
51718
|
const tmp = `${stateFile(home2)}.${process.pid}.tmp`;
|
|
51638
51719
|
try {
|
|
51639
|
-
|
|
51720
|
+
writeFileSync10(tmp, `${JSON.stringify(next, null, 2)}
|
|
51640
51721
|
`, { mode: 384 });
|
|
51641
51722
|
chmodSync12(tmp, 384);
|
|
51642
|
-
|
|
51723
|
+
renameSync13(tmp, stateFile(home2));
|
|
51643
51724
|
} catch (e) {
|
|
51644
|
-
|
|
51725
|
+
rmSync7(tmp, { force: true });
|
|
51645
51726
|
throw e;
|
|
51646
51727
|
}
|
|
51647
51728
|
}
|
|
@@ -51665,8 +51746,8 @@ function migrate(home2, now = Date.now) {
|
|
|
51665
51746
|
v ??= `unknown-${now()}`;
|
|
51666
51747
|
ensureVersions(home2);
|
|
51667
51748
|
if (lstat2(versionDir(home2, v)))
|
|
51668
|
-
|
|
51669
|
-
|
|
51749
|
+
rmSync7(versionDir(home2, v), { recursive: true, force: true });
|
|
51750
|
+
renameSync13(bin, versionDir(home2, v));
|
|
51670
51751
|
chmodSync12(versionDir(home2, v), 448);
|
|
51671
51752
|
return v;
|
|
51672
51753
|
}
|
|
@@ -51675,7 +51756,7 @@ function stage(home2, version2, fill) {
|
|
|
51675
51756
|
ensureVersions(home2);
|
|
51676
51757
|
const dest = versionDir(home2, version2);
|
|
51677
51758
|
const tmp = join20(versionsDir(home2), `.stage.${process.pid}`);
|
|
51678
|
-
|
|
51759
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51679
51760
|
mkdirSync8(tmp, { mode: 448 });
|
|
51680
51761
|
try {
|
|
51681
51762
|
fill(tmp);
|
|
@@ -51683,13 +51764,13 @@ function stage(home2, version2, fill) {
|
|
|
51683
51764
|
mustBeSafe(tmp);
|
|
51684
51765
|
if (lstat2(dest)) {
|
|
51685
51766
|
const old = join20(versionsDir(home2), `.old.${process.pid}`);
|
|
51686
|
-
|
|
51687
|
-
|
|
51688
|
-
|
|
51689
|
-
|
|
51690
|
-
} else
|
|
51767
|
+
rmSync7(old, { recursive: true, force: true });
|
|
51768
|
+
renameSync13(dest, old);
|
|
51769
|
+
renameSync13(tmp, dest);
|
|
51770
|
+
rmSync7(old, { recursive: true, force: true });
|
|
51771
|
+
} else renameSync13(tmp, dest);
|
|
51691
51772
|
} catch (e) {
|
|
51692
|
-
|
|
51773
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51693
51774
|
throw e;
|
|
51694
51775
|
}
|
|
51695
51776
|
return dest;
|
|
@@ -51701,7 +51782,7 @@ function swap(home2, version2) {
|
|
|
51701
51782
|
mustBeSafe(target2);
|
|
51702
51783
|
const bin = binPath(home2);
|
|
51703
51784
|
const tmp = `${bin}.${process.pid}.new`;
|
|
51704
|
-
|
|
51785
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51705
51786
|
try {
|
|
51706
51787
|
symlinkSync(
|
|
51707
51788
|
join20("versions", version2),
|
|
@@ -51709,10 +51790,10 @@ function swap(home2, version2) {
|
|
|
51709
51790
|
process.platform === "win32" ? "junction" : void 0
|
|
51710
51791
|
);
|
|
51711
51792
|
if (process.platform === "win32")
|
|
51712
|
-
|
|
51713
|
-
|
|
51793
|
+
rmSync7(bin, { recursive: true, force: true });
|
|
51794
|
+
renameSync13(tmp, bin);
|
|
51714
51795
|
} catch (e) {
|
|
51715
|
-
|
|
51796
|
+
rmSync7(tmp, { recursive: true, force: true });
|
|
51716
51797
|
throw e;
|
|
51717
51798
|
}
|
|
51718
51799
|
}
|
|
@@ -51733,10 +51814,10 @@ function inUse(versionPath, alive3 = pidAlive) {
|
|
|
51733
51814
|
if (!/^\d+$/.test(n)) continue;
|
|
51734
51815
|
const f = join20(dir, n);
|
|
51735
51816
|
const k = lstat2(f);
|
|
51736
|
-
if (k?.isSymbolicLink())
|
|
51817
|
+
if (k?.isSymbolicLink()) rmSync7(f, { force: true });
|
|
51737
51818
|
else if (!k?.isFile()) continue;
|
|
51738
51819
|
else if (alive3(Number(n))) live = true;
|
|
51739
|
-
else
|
|
51820
|
+
else rmSync7(f, { force: true });
|
|
51740
51821
|
}
|
|
51741
51822
|
return live;
|
|
51742
51823
|
}
|
|
@@ -51751,8 +51832,8 @@ function markLive(entryFile, home2, pid = process.pid) {
|
|
|
51751
51832
|
const vdir = join20(root, v);
|
|
51752
51833
|
mkdirSync8(liveDir(vdir), { recursive: true, mode: 448 });
|
|
51753
51834
|
const marker = join20(liveDir(vdir), String(pid));
|
|
51754
|
-
|
|
51755
|
-
process.once("exit", () =>
|
|
51835
|
+
writeFileSync10(marker, "", { mode: 384 });
|
|
51836
|
+
process.once("exit", () => rmSync7(marker, { force: true }));
|
|
51756
51837
|
return marker;
|
|
51757
51838
|
} catch {
|
|
51758
51839
|
return void 0;
|
|
@@ -51769,14 +51850,14 @@ function prune(home2, keep, opts = {}) {
|
|
|
51769
51850
|
const st = lstat2(join20(dir, name));
|
|
51770
51851
|
if (!st) continue;
|
|
51771
51852
|
if (st.isSymbolicLink()) {
|
|
51772
|
-
|
|
51853
|
+
rmSync7(join20(dir, name), { force: true });
|
|
51773
51854
|
removed.push(name);
|
|
51774
51855
|
continue;
|
|
51775
51856
|
}
|
|
51776
51857
|
if (!st.isDirectory()) continue;
|
|
51777
51858
|
const m = /^\.(stage|old)\.(\d+)$/.exec(name);
|
|
51778
51859
|
if (m ? alive3(Number(m[2])) : inUse(join20(dir, name), alive3)) continue;
|
|
51779
|
-
|
|
51860
|
+
rmSync7(join20(dir, name), { recursive: true, force: true });
|
|
51780
51861
|
removed.push(name);
|
|
51781
51862
|
}
|
|
51782
51863
|
return removed;
|
|
@@ -51844,7 +51925,7 @@ function treeMatches(dir, manifest) {
|
|
|
51844
51925
|
}
|
|
51845
51926
|
|
|
51846
51927
|
// ../bus-daemon/src/update/login-flag.ts
|
|
51847
|
-
import { readFileSync as readFileSync16, rmSync as
|
|
51928
|
+
import { readFileSync as readFileSync16, rmSync as rmSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
51848
51929
|
import { join as join21 } from "node:path";
|
|
51849
51930
|
var loginFlagFile = (home2) => join21(home2, "login.active");
|
|
51850
51931
|
var LOGIN_FLAG_MAX_MS = 15 * 6e4;
|
|
@@ -51858,7 +51939,7 @@ var alive2 = (pid) => {
|
|
|
51858
51939
|
};
|
|
51859
51940
|
function markLoginActive(home2, now = Date.now) {
|
|
51860
51941
|
try {
|
|
51861
|
-
|
|
51942
|
+
writeFileSync11(loginFlagFile(home2), `${process.pid} ${now()}
|
|
51862
51943
|
`, {
|
|
51863
51944
|
mode: 384
|
|
51864
51945
|
});
|
|
@@ -51866,7 +51947,7 @@ function markLoginActive(home2, now = Date.now) {
|
|
|
51866
51947
|
return () => {
|
|
51867
51948
|
};
|
|
51868
51949
|
}
|
|
51869
|
-
return () =>
|
|
51950
|
+
return () => rmSync8(loginFlagFile(home2), { force: true });
|
|
51870
51951
|
}
|
|
51871
51952
|
function loginActive(home2, now = Date.now, isAlive = alive2) {
|
|
51872
51953
|
try {
|
|
@@ -52003,9 +52084,9 @@ function label(s, now) {
|
|
|
52003
52084
|
import {
|
|
52004
52085
|
chmodSync as chmodSync13,
|
|
52005
52086
|
readFileSync as readFileSync17,
|
|
52006
|
-
renameSync as
|
|
52007
|
-
rmSync as
|
|
52008
|
-
writeFileSync as
|
|
52087
|
+
renameSync as renameSync14,
|
|
52088
|
+
rmSync as rmSync9,
|
|
52089
|
+
writeFileSync as writeFileSync12
|
|
52009
52090
|
} from "node:fs";
|
|
52010
52091
|
import { join as join22 } from "node:path";
|
|
52011
52092
|
var MAX_REPORTS = 50;
|
|
@@ -52034,12 +52115,12 @@ function queueReport(home2, r) {
|
|
|
52034
52115
|
const tmp = `${reportFile(home2)}.${process.pid}.tmp`;
|
|
52035
52116
|
try {
|
|
52036
52117
|
const list = [...readReports(home2), r].slice(-MAX_REPORTS);
|
|
52037
|
-
|
|
52118
|
+
writeFileSync12(tmp, `${JSON.stringify(list)}
|
|
52038
52119
|
`, { mode: 384 });
|
|
52039
52120
|
chmodSync13(tmp, 384);
|
|
52040
|
-
|
|
52121
|
+
renameSync14(tmp, reportFile(home2));
|
|
52041
52122
|
} catch {
|
|
52042
|
-
|
|
52123
|
+
rmSync9(tmp, { force: true });
|
|
52043
52124
|
}
|
|
52044
52125
|
}
|
|
52045
52126
|
function removeReports(home2, sent) {
|
|
@@ -52053,12 +52134,12 @@ function removeReports(home2, sent) {
|
|
|
52053
52134
|
);
|
|
52054
52135
|
if (i >= 0) left.splice(i, 1);
|
|
52055
52136
|
}
|
|
52056
|
-
|
|
52137
|
+
writeFileSync12(tmp, `${JSON.stringify(left)}
|
|
52057
52138
|
`, { mode: 384 });
|
|
52058
52139
|
chmodSync13(tmp, 384);
|
|
52059
|
-
|
|
52140
|
+
renameSync14(tmp, reportFile(home2));
|
|
52060
52141
|
} catch {
|
|
52061
|
-
|
|
52142
|
+
rmSync9(tmp, { force: true });
|
|
52062
52143
|
}
|
|
52063
52144
|
}
|
|
52064
52145
|
function readRescueVersion(home2) {
|
|
@@ -52079,9 +52160,9 @@ import {
|
|
|
52079
52160
|
chmodSync as chmodSync14,
|
|
52080
52161
|
lstatSync as lstatSync8,
|
|
52081
52162
|
readFileSync as readFileSync18,
|
|
52082
|
-
renameSync as
|
|
52083
|
-
rmSync as
|
|
52084
|
-
writeFileSync as
|
|
52163
|
+
renameSync as renameSync15,
|
|
52164
|
+
rmSync as rmSync10,
|
|
52165
|
+
writeFileSync as writeFileSync13
|
|
52085
52166
|
} from "node:fs";
|
|
52086
52167
|
import { join as join23 } from "node:path";
|
|
52087
52168
|
function load(home2) {
|
|
@@ -52174,12 +52255,12 @@ function readPolicy(home2) {
|
|
|
52174
52255
|
function put(home2, next) {
|
|
52175
52256
|
const tmp = `${stateFile(home2)}.${process.pid}.policy.tmp`;
|
|
52176
52257
|
try {
|
|
52177
|
-
|
|
52258
|
+
writeFileSync13(tmp, `${JSON.stringify(next, null, 2)}
|
|
52178
52259
|
`, { mode: 384 });
|
|
52179
52260
|
chmodSync14(tmp, 384);
|
|
52180
|
-
|
|
52261
|
+
renameSync15(tmp, stateFile(home2));
|
|
52181
52262
|
} catch (e) {
|
|
52182
|
-
|
|
52263
|
+
rmSync10(tmp, { force: true });
|
|
52183
52264
|
throw e;
|
|
52184
52265
|
}
|
|
52185
52266
|
}
|
|
@@ -52290,13 +52371,13 @@ function requestInstall(home2, version2, at) {
|
|
|
52290
52371
|
`;
|
|
52291
52372
|
for (let i = 0; i < 2; i++) {
|
|
52292
52373
|
try {
|
|
52293
|
-
|
|
52374
|
+
writeFileSync13(requestFile(home2), body, { mode: 384, flag: "wx" });
|
|
52294
52375
|
return true;
|
|
52295
52376
|
} catch (e) {
|
|
52296
52377
|
if (e.code !== "EEXIST") throw e;
|
|
52297
52378
|
const waiting = readInstallRequest(home2);
|
|
52298
52379
|
if (waiting && Math.abs(at - waiting.at) < REQUEST_STALE_MS) return false;
|
|
52299
|
-
|
|
52380
|
+
rmSync10(requestFile(home2), { force: true });
|
|
52300
52381
|
}
|
|
52301
52382
|
}
|
|
52302
52383
|
return false;
|
|
@@ -52332,7 +52413,7 @@ function readInstallRequest(home2) {
|
|
|
52332
52413
|
function takeInstallRequest(home2) {
|
|
52333
52414
|
const taken = `${requestFile(home2)}.taken.${process.pid}`;
|
|
52334
52415
|
try {
|
|
52335
|
-
|
|
52416
|
+
renameSync15(requestFile(home2), taken);
|
|
52336
52417
|
} catch {
|
|
52337
52418
|
return void 0;
|
|
52338
52419
|
}
|
|
@@ -52342,11 +52423,11 @@ function takeInstallRequest(home2) {
|
|
|
52342
52423
|
} catch {
|
|
52343
52424
|
return void 0;
|
|
52344
52425
|
} finally {
|
|
52345
|
-
|
|
52426
|
+
rmSync10(taken, { force: true });
|
|
52346
52427
|
}
|
|
52347
52428
|
}
|
|
52348
52429
|
function clearInstallRequest(home2) {
|
|
52349
|
-
|
|
52430
|
+
rmSync10(requestFile(home2), { force: true });
|
|
52350
52431
|
}
|
|
52351
52432
|
var releaseAttempt = (home2) => editPolicy(home2, (s) => {
|
|
52352
52433
|
if (s.pending && s.pending.attempts > 0) s.pending.attempts -= 1;
|
|
@@ -52507,7 +52588,7 @@ import {
|
|
|
52507
52588
|
copyFileSync,
|
|
52508
52589
|
existsSync as existsSync7,
|
|
52509
52590
|
readFileSync as readFileSync19,
|
|
52510
|
-
rmSync as
|
|
52591
|
+
rmSync as rmSync11
|
|
52511
52592
|
} from "node:fs";
|
|
52512
52593
|
import { join as join25 } from "node:path";
|
|
52513
52594
|
|
|
@@ -53515,7 +53596,7 @@ var Updater = class {
|
|
|
53515
53596
|
if (version2 === this.d.running || version2 === s.current || version2 === s.previous)
|
|
53516
53597
|
return;
|
|
53517
53598
|
if (isSafeVersion(version2))
|
|
53518
|
-
|
|
53599
|
+
rmSync11(versionDir(this.d.home, version2), {
|
|
53519
53600
|
recursive: true,
|
|
53520
53601
|
force: true
|
|
53521
53602
|
});
|
|
@@ -53597,7 +53678,7 @@ var Updater = class {
|
|
|
53597
53678
|
reason: "staged_changed",
|
|
53598
53679
|
at: now
|
|
53599
53680
|
});
|
|
53600
|
-
|
|
53681
|
+
rmSync11(versionDir(home2, version2), { recursive: true, force: true });
|
|
53601
53682
|
clearStaged(home2);
|
|
53602
53683
|
return { kind: "proof_refused", code: "staged_changed" };
|
|
53603
53684
|
}
|
|
@@ -54089,7 +54170,27 @@ async function runDaemon(deps2 = {}) {
|
|
|
54089
54170
|
closed: agents.closedRefs().filter(mine)
|
|
54090
54171
|
};
|
|
54091
54172
|
};
|
|
54173
|
+
const announcedFile = deps2.announcedFile ?? join27(home(), "announced.json");
|
|
54174
|
+
let announcedWritten;
|
|
54175
|
+
const persistAnnounced = () => {
|
|
54176
|
+
const rows = agents.all().map((a) => ({
|
|
54177
|
+
ref: a.ref,
|
|
54178
|
+
kind: a.kind,
|
|
54179
|
+
...a.instance !== void 0 && a.instance !== MAIN_INSTANCE ? { instance: a.instance } : {}
|
|
54180
|
+
}));
|
|
54181
|
+
const text3 = JSON.stringify(rows);
|
|
54182
|
+
if (text3 === announcedWritten) return;
|
|
54183
|
+
try {
|
|
54184
|
+
writeAnnounced(announcedFile, rows);
|
|
54185
|
+
announcedWritten = text3;
|
|
54186
|
+
} catch (e) {
|
|
54187
|
+
log(
|
|
54188
|
+
`could not save ${announcedFile}: ${e instanceof Error ? e.message : e}`
|
|
54189
|
+
);
|
|
54190
|
+
}
|
|
54191
|
+
};
|
|
54092
54192
|
const announceSessions = () => {
|
|
54193
|
+
persistAnnounced();
|
|
54093
54194
|
for (const ref of limited.keys())
|
|
54094
54195
|
if (!agents.byRef(ref)?.live) clearLimited(ref);
|
|
54095
54196
|
for (const m of [renameFrames, renameHeldUntil])
|
|
@@ -54105,6 +54206,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
54105
54206
|
const limited = /* @__PURE__ */ new Map();
|
|
54106
54207
|
const caps = /* @__PURE__ */ new Map();
|
|
54107
54208
|
const announceUp = (rec) => {
|
|
54209
|
+
persistAnnounced();
|
|
54108
54210
|
const lane = laneOfRef(rec.ref);
|
|
54109
54211
|
if (!lane) return false;
|
|
54110
54212
|
if (rec.replaces !== void 0 && !lane.helloed) return false;
|
|
@@ -55392,7 +55494,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
55392
55494
|
linkDown(lane);
|
|
55393
55495
|
lane.hub.stop();
|
|
55394
55496
|
try {
|
|
55395
|
-
|
|
55497
|
+
writeFileSync14(
|
|
55396
55498
|
revokedMarkerFile(lane),
|
|
55397
55499
|
revokedMarker(lane.cfg.machine_token),
|
|
55398
55500
|
{ mode: 384 }
|
|
@@ -55416,7 +55518,7 @@ async function runDaemon(deps2 = {}) {
|
|
|
55416
55518
|
log(`this machine was revoked; run \`${BUS_CMD} install\``);
|
|
55417
55519
|
process.exitCode = 1;
|
|
55418
55520
|
try {
|
|
55419
|
-
|
|
55521
|
+
writeFileSync14(
|
|
55420
55522
|
deps2.revokedFile ?? join27(home(), "revoked"),
|
|
55421
55523
|
revokedMarker(cfg.machine_token),
|
|
55422
55524
|
{ mode: 384 }
|
|
@@ -56464,8 +56566,26 @@ async function runDaemon(deps2 = {}) {
|
|
|
56464
56566
|
);
|
|
56465
56567
|
}
|
|
56466
56568
|
};
|
|
56569
|
+
const savedAnnounced = readAnnounced(announcedFile, void 0, log);
|
|
56467
56570
|
restoreCodex();
|
|
56468
56571
|
sync();
|
|
56572
|
+
for (const e of savedAnnounced) {
|
|
56573
|
+
if (agents.byRef(e.ref) !== void 0) continue;
|
|
56574
|
+
agents.up({
|
|
56575
|
+
ref: e.ref,
|
|
56576
|
+
kind: e.kind,
|
|
56577
|
+
proposedName: "",
|
|
56578
|
+
busName: "",
|
|
56579
|
+
namespace: "",
|
|
56580
|
+
global: false,
|
|
56581
|
+
instance: e.instance ?? MAIN_INSTANCE,
|
|
56582
|
+
pid: 0,
|
|
56583
|
+
cwd: "",
|
|
56584
|
+
live: false,
|
|
56585
|
+
closedBy: "liveness"
|
|
56586
|
+
});
|
|
56587
|
+
}
|
|
56588
|
+
persistAnnounced();
|
|
56469
56589
|
const watcher = setInterval(sync, cl.syncMs ?? 2e3);
|
|
56470
56590
|
watcher.unref();
|
|
56471
56591
|
const retry = setInterval(() => {
|
|
@@ -57820,9 +57940,9 @@ import {
|
|
|
57820
57940
|
readdirSync as readdirSync9,
|
|
57821
57941
|
readFileSync as readFileSync22,
|
|
57822
57942
|
realpathSync as realpathSync11,
|
|
57823
|
-
renameSync as
|
|
57824
|
-
rmSync as
|
|
57825
|
-
writeFileSync as
|
|
57943
|
+
renameSync as renameSync18,
|
|
57944
|
+
rmSync as rmSync13,
|
|
57945
|
+
writeFileSync as writeFileSync17
|
|
57826
57946
|
} from "node:fs";
|
|
57827
57947
|
import { tmpdir } from "node:os";
|
|
57828
57948
|
import {
|
|
@@ -58850,8 +58970,8 @@ function upsert(path, text3, doc, entry) {
|
|
|
58850
58970
|
);
|
|
58851
58971
|
const eol2 = eolOf(lines);
|
|
58852
58972
|
const ended = lines.at(-1)?.text === "" && lines.length > 1;
|
|
58853
|
-
const
|
|
58854
|
-
next = `${text3}${
|
|
58973
|
+
const sep8 = text3 === "" ? "" : ended ? blank(lines.at(-2)) ? "" : eol2 : eol2 + eol2;
|
|
58974
|
+
next = `${text3}${sep8}${block.join(eol2)}${eol2}`;
|
|
58855
58975
|
}
|
|
58856
58976
|
return checked(path, doc, next, entry);
|
|
58857
58977
|
}
|
|
@@ -58887,9 +59007,9 @@ async function readCodexVersion(o) {
|
|
|
58887
59007
|
import {
|
|
58888
59008
|
chmodSync as chmodSync16,
|
|
58889
59009
|
mkdirSync as mkdirSync10,
|
|
58890
|
-
renameSync as
|
|
58891
|
-
rmSync as
|
|
58892
|
-
writeFileSync as
|
|
59010
|
+
renameSync as renameSync16,
|
|
59011
|
+
rmSync as rmSync12,
|
|
59012
|
+
writeFileSync as writeFileSync15
|
|
58893
59013
|
} from "node:fs";
|
|
58894
59014
|
import { join as join29 } from "node:path";
|
|
58895
59015
|
var RESCUE_VERSION = 1;
|
|
@@ -59001,11 +59121,11 @@ function writeRescue(home2, launcher) {
|
|
|
59001
59121
|
const path = join29(home2, name);
|
|
59002
59122
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59003
59123
|
try {
|
|
59004
|
-
|
|
59124
|
+
writeFileSync15(tmp, text3, { mode: 448 });
|
|
59005
59125
|
chmodSync16(tmp, 448);
|
|
59006
|
-
|
|
59126
|
+
renameSync16(tmp, path);
|
|
59007
59127
|
} catch (e) {
|
|
59008
|
-
|
|
59128
|
+
rmSync12(tmp, { force: true });
|
|
59009
59129
|
throw e;
|
|
59010
59130
|
}
|
|
59011
59131
|
};
|
|
@@ -59019,8 +59139,8 @@ import {
|
|
|
59019
59139
|
chmodSync as chmodSync17,
|
|
59020
59140
|
mkdirSync as mkdirSync11,
|
|
59021
59141
|
readFileSync as readFileSync21,
|
|
59022
|
-
renameSync as
|
|
59023
|
-
writeFileSync as
|
|
59142
|
+
renameSync as renameSync17,
|
|
59143
|
+
writeFileSync as writeFileSync16
|
|
59024
59144
|
} from "node:fs";
|
|
59025
59145
|
import { dirname as dirname13 } from "node:path";
|
|
59026
59146
|
function readInstallFile(path) {
|
|
@@ -59036,10 +59156,10 @@ function updateInstallFile(path, patch) {
|
|
|
59036
59156
|
const next = { ...readInstallFile(path), ...patch };
|
|
59037
59157
|
mkdirSync11(dirname13(path), { recursive: true, mode: 448 });
|
|
59038
59158
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59039
|
-
|
|
59159
|
+
writeFileSync16(tmp, `${JSON.stringify(next, null, 2)}
|
|
59040
59160
|
`, { mode: 384 });
|
|
59041
59161
|
chmodSync17(tmp, 384);
|
|
59042
|
-
|
|
59162
|
+
renameSync17(tmp, path);
|
|
59043
59163
|
}
|
|
59044
59164
|
async function runSteps(steps, ctx, record7) {
|
|
59045
59165
|
for (const step2 of steps) {
|
|
@@ -59231,14 +59351,14 @@ function installCli(home2, src, node2) {
|
|
|
59231
59351
|
for (const name of ["dist", "assets", "package.json"])
|
|
59232
59352
|
if (existsSync9(join30(pkg, name)))
|
|
59233
59353
|
cpSync(join30(pkg, name), join30(tmp, name), { recursive: true });
|
|
59234
|
-
} else
|
|
59354
|
+
} else writeFileSync17(join30(tmp, entryName(src)), shim(src));
|
|
59235
59355
|
chmodSync18(tmp, 448);
|
|
59236
59356
|
if (node2 !== void 0) {
|
|
59237
|
-
|
|
59357
|
+
writeFileSync17(join30(tmp, "node"), launcherText(node2), { mode: 448 });
|
|
59238
59358
|
chmodSync18(join30(tmp, "node"), 448);
|
|
59239
59359
|
}
|
|
59240
59360
|
if (!existsSync9(join30(tmp, "package.json")))
|
|
59241
|
-
|
|
59361
|
+
writeFileSync17(join30(tmp, "package.json"), '{ "type": "module" }\n');
|
|
59242
59362
|
},
|
|
59243
59363
|
// Without the rescue shim (win32, or no launcher) a failed update could
|
|
59244
59364
|
// not be undone: such an install never arms auto-update (#2552).
|
|
@@ -59259,10 +59379,10 @@ function writeReplacing(path, text3) {
|
|
|
59259
59379
|
mkdirSync12(dirname14(path), { recursive: true });
|
|
59260
59380
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
59261
59381
|
try {
|
|
59262
|
-
|
|
59263
|
-
|
|
59382
|
+
writeFileSync17(tmp, text3, { mode: 420 });
|
|
59383
|
+
renameSync18(tmp, path);
|
|
59264
59384
|
} catch (e) {
|
|
59265
|
-
|
|
59385
|
+
rmSync13(tmp, { force: true });
|
|
59266
59386
|
throw e;
|
|
59267
59387
|
}
|
|
59268
59388
|
}
|
|
@@ -59368,7 +59488,7 @@ function systemService(d) {
|
|
|
59368
59488
|
return "started";
|
|
59369
59489
|
await d.sleep(1e3);
|
|
59370
59490
|
}
|
|
59371
|
-
|
|
59491
|
+
rmSync13(f, { force: true });
|
|
59372
59492
|
return "failed";
|
|
59373
59493
|
}
|
|
59374
59494
|
async function startSystemd(f, u) {
|
|
@@ -59382,7 +59502,7 @@ function systemService(d) {
|
|
|
59382
59502
|
]) {
|
|
59383
59503
|
if ((await systemctl(...args)).code === 0) continue;
|
|
59384
59504
|
if (args[0] !== "daemon-reload") await systemctl("disable", unit);
|
|
59385
|
-
|
|
59505
|
+
rmSync13(f, { force: true });
|
|
59386
59506
|
if (args[0] !== "daemon-reload") await systemctl("daemon-reload");
|
|
59387
59507
|
return "failed";
|
|
59388
59508
|
}
|
|
@@ -59443,7 +59563,7 @@ function systemService(d) {
|
|
|
59443
59563
|
const old = recorded();
|
|
59444
59564
|
if (!skipped && old && old !== f) {
|
|
59445
59565
|
if (manager === "systemd") await systemctl("disable", names2().unit);
|
|
59446
|
-
|
|
59566
|
+
rmSync13(old, { force: true });
|
|
59447
59567
|
}
|
|
59448
59568
|
const started = skipped ? "failed" : manager === "launchd" ? await startLaunchd(f, unit) : manager === "systemd" ? await startSystemd(f, unit) : "failed";
|
|
59449
59569
|
if (started === "started") {
|
|
@@ -59488,7 +59608,7 @@ function systemService(d) {
|
|
|
59488
59608
|
if (manager === "launchd")
|
|
59489
59609
|
await d.exec("launchctl", ["bootout", `${domain2}/${label2}`]);
|
|
59490
59610
|
else await systemctl("disable", "--now", unit);
|
|
59491
|
-
|
|
59611
|
+
rmSync13(f, { force: true });
|
|
59492
59612
|
if (manager === "systemd") await systemctl("daemon-reload");
|
|
59493
59613
|
const left = await quiet();
|
|
59494
59614
|
if (left !== void 0) return { unit: manager, running: left };
|
|
@@ -59599,7 +59719,7 @@ var noService = {
|
|
|
59599
59719
|
remove: async () => ({}),
|
|
59600
59720
|
cli: () => ["oa-bus"]
|
|
59601
59721
|
};
|
|
59602
|
-
var VERSION = true ? "0.
|
|
59722
|
+
var VERSION = true ? "0.242.0" : JSON.parse(
|
|
59603
59723
|
readFileSync23(new URL("../package.json", import.meta.url), "utf8")
|
|
59604
59724
|
).version;
|
|
59605
59725
|
var which = (cmd) => {
|
|
@@ -59785,10 +59905,10 @@ import {
|
|
|
59785
59905
|
mkdirSync as mkdirSync15,
|
|
59786
59906
|
readFileSync as readFileSync32,
|
|
59787
59907
|
readlinkSync as readlinkSync5,
|
|
59788
|
-
renameSync as
|
|
59789
|
-
rmSync as
|
|
59908
|
+
renameSync as renameSync21,
|
|
59909
|
+
rmSync as rmSync21,
|
|
59790
59910
|
statSync as statSync9,
|
|
59791
|
-
writeFileSync as
|
|
59911
|
+
writeFileSync as writeFileSync20
|
|
59792
59912
|
} from "node:fs";
|
|
59793
59913
|
import { dirname as dirname18, isAbsolute as isAbsolute14, join as join37, relative as relative7, resolve as resolve13 } from "node:path";
|
|
59794
59914
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -60338,11 +60458,11 @@ function parseTree(text3, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
60338
60458
|
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
60339
60459
|
ensurePropertyComplete(offset + length);
|
|
60340
60460
|
},
|
|
60341
|
-
onSeparator: (
|
|
60461
|
+
onSeparator: (sep8, offset, length) => {
|
|
60342
60462
|
if (currentParent.type === "property") {
|
|
60343
|
-
if (
|
|
60463
|
+
if (sep8 === ":") {
|
|
60344
60464
|
currentParent.colonOffset = offset;
|
|
60345
|
-
} else if (
|
|
60465
|
+
} else if (sep8 === ",") {
|
|
60346
60466
|
ensurePropertyComplete(offset);
|
|
60347
60467
|
}
|
|
60348
60468
|
}
|
|
@@ -61370,7 +61490,7 @@ function addInstanceProof(io, target2, busBin, busHome2) {
|
|
|
61370
61490
|
// src/steps/codex-proof.ts
|
|
61371
61491
|
init_src3();
|
|
61372
61492
|
init_src();
|
|
61373
|
-
import { existsSync as existsSync10, readFileSync as readFileSync25, rmSync as
|
|
61493
|
+
import { existsSync as existsSync10, readFileSync as readFileSync25, rmSync as rmSync14 } from "node:fs";
|
|
61374
61494
|
import { isAbsolute as isAbsolute11 } from "node:path";
|
|
61375
61495
|
var CODEX_MIN_VERSION = "0.123.0";
|
|
61376
61496
|
var PROXY_CMD = "mcp-proxy";
|
|
@@ -61670,7 +61790,7 @@ ${m.lines.join("\n")}
|
|
|
61670
61790
|
put2 = true;
|
|
61671
61791
|
}
|
|
61672
61792
|
}
|
|
61673
|
-
|
|
61793
|
+
rmSync14(io.moved, { force: true });
|
|
61674
61794
|
return put2;
|
|
61675
61795
|
}
|
|
61676
61796
|
function linesOf(text3) {
|
|
@@ -61701,7 +61821,7 @@ import {
|
|
|
61701
61821
|
lstatSync as lstatSync17,
|
|
61702
61822
|
readFileSync as readFileSync29,
|
|
61703
61823
|
realpathSync as realpathSync15,
|
|
61704
|
-
rmSync as
|
|
61824
|
+
rmSync as rmSync18
|
|
61705
61825
|
} from "node:fs";
|
|
61706
61826
|
import { join as join35, resolve as resolve11, sep as sep5 } from "node:path";
|
|
61707
61827
|
|
|
@@ -61715,10 +61835,10 @@ import {
|
|
|
61715
61835
|
readFileSync as readFileSync26,
|
|
61716
61836
|
readlinkSync as readlinkSync3,
|
|
61717
61837
|
realpathSync as realpathSync12,
|
|
61718
|
-
renameSync as
|
|
61838
|
+
renameSync as renameSync19,
|
|
61719
61839
|
rmdirSync,
|
|
61720
|
-
rmSync as
|
|
61721
|
-
writeFileSync as
|
|
61840
|
+
rmSync as rmSync15,
|
|
61841
|
+
writeFileSync as writeFileSync18
|
|
61722
61842
|
} from "node:fs";
|
|
61723
61843
|
import {
|
|
61724
61844
|
basename as basename9,
|
|
@@ -61780,7 +61900,7 @@ function sweepStaging(staging, own2, o = {}) {
|
|
|
61780
61900
|
const m = STAGE_NAME.exec(name);
|
|
61781
61901
|
if (m ? old || !alive3(Number(m[1])) : old) {
|
|
61782
61902
|
try {
|
|
61783
|
-
|
|
61903
|
+
rmSync15(path, { recursive: true, force: true });
|
|
61784
61904
|
} catch {
|
|
61785
61905
|
}
|
|
61786
61906
|
}
|
|
@@ -61973,19 +62093,19 @@ async function installHermes(deps2) {
|
|
|
61973
62093
|
mkdirSync13(join32(tmp, f, ".."), { recursive: true });
|
|
61974
62094
|
cpSync2(join32(shipped, f), join32(tmp, f));
|
|
61975
62095
|
}
|
|
61976
|
-
|
|
62096
|
+
writeFileSync18(
|
|
61977
62097
|
join32(tmp, HERMES_MARKER),
|
|
61978
62098
|
`managed by the Open Artifacts bus installer: edits are replaced on reinstall. ${pluginHash(shipped)}
|
|
61979
62099
|
`
|
|
61980
62100
|
);
|
|
61981
62101
|
if (keepHabits)
|
|
61982
|
-
|
|
62102
|
+
writeFileSync18(join32(tmp, HERMES_HABITS_MARKER), HABITS_MARKER_TEXT);
|
|
61983
62103
|
if (keepRoots !== void 0)
|
|
61984
|
-
|
|
61985
|
-
if (state === "stale")
|
|
61986
|
-
|
|
62104
|
+
writeFileSync18(join32(tmp, HERMES_ROOTS_FILE), keepRoots, { mode: 384 });
|
|
62105
|
+
if (state === "stale") rmSync15(dest, { recursive: true, force: true });
|
|
62106
|
+
renameSync19(tmp, dest);
|
|
61987
62107
|
} catch (e) {
|
|
61988
|
-
|
|
62108
|
+
rmSync15(tmp, { recursive: true, force: true });
|
|
61989
62109
|
throw e;
|
|
61990
62110
|
} finally {
|
|
61991
62111
|
try {
|
|
@@ -62020,7 +62140,7 @@ async function uninstallHermes(deps2, notes) {
|
|
|
62020
62140
|
`\`hermes plugins disable ${HERMES_PLUGIN_NAME}\` failed (${firstLine(r.stderr) || firstLine(r.stdout) || `exit ${r.code}`}); left the plugin folder, rerun once Hermes works`
|
|
62021
62141
|
);
|
|
62022
62142
|
} else notes.push(HERMES_NO_CLI);
|
|
62023
|
-
|
|
62143
|
+
rmSync15(dest, { recursive: true, force: true });
|
|
62024
62144
|
return "done";
|
|
62025
62145
|
}
|
|
62026
62146
|
async function hermesEnabled(deps2) {
|
|
@@ -62043,7 +62163,7 @@ import {
|
|
|
62043
62163
|
readdirSync as readdirSync12,
|
|
62044
62164
|
readFileSync as readFileSync28,
|
|
62045
62165
|
realpathSync as realpathSync14,
|
|
62046
|
-
rmSync as
|
|
62166
|
+
rmSync as rmSync17
|
|
62047
62167
|
} from "node:fs";
|
|
62048
62168
|
import { join as join34, resolve as resolve10 } from "node:path";
|
|
62049
62169
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
@@ -62058,11 +62178,11 @@ import {
|
|
|
62058
62178
|
readFileSync as readFileSync27,
|
|
62059
62179
|
readlinkSync as readlinkSync4,
|
|
62060
62180
|
realpathSync as realpathSync13,
|
|
62061
|
-
renameSync as
|
|
62181
|
+
renameSync as renameSync20,
|
|
62062
62182
|
rmdirSync as rmdirSync2,
|
|
62063
|
-
rmSync as
|
|
62183
|
+
rmSync as rmSync16,
|
|
62064
62184
|
statSync as statSync8,
|
|
62065
|
-
writeFileSync as
|
|
62185
|
+
writeFileSync as writeFileSync19
|
|
62066
62186
|
} from "node:fs";
|
|
62067
62187
|
import { dirname as dirname16, join as join33, resolve as resolve9 } from "node:path";
|
|
62068
62188
|
var SKILL_MARKER = "<!-- managed by the Open Artifacts bus installer: edits are replaced on reinstall. -->";
|
|
@@ -62222,12 +62342,12 @@ var writeAtomic = (path, text3) => {
|
|
|
62222
62342
|
mode = statSync8(path).mode & 4095;
|
|
62223
62343
|
} catch {
|
|
62224
62344
|
}
|
|
62225
|
-
|
|
62345
|
+
writeFileSync19(tmp, text3);
|
|
62226
62346
|
if (mode !== void 0) chmodSync19(tmp, mode);
|
|
62227
|
-
|
|
62347
|
+
renameSync20(tmp, path);
|
|
62228
62348
|
} catch (e) {
|
|
62229
62349
|
try {
|
|
62230
|
-
|
|
62350
|
+
rmSync16(tmp, { force: true });
|
|
62231
62351
|
} catch {
|
|
62232
62352
|
}
|
|
62233
62353
|
throw e;
|
|
@@ -62365,7 +62485,7 @@ var installCodex = (deps2, folder, text3, written, notes) => {
|
|
|
62365
62485
|
written.push(agentsPath);
|
|
62366
62486
|
if (ourFile && !shared) {
|
|
62367
62487
|
try {
|
|
62368
|
-
|
|
62488
|
+
rmSync16(targetOf(filePath), { force: true });
|
|
62369
62489
|
try {
|
|
62370
62490
|
rmdirSync2(dirname16(filePath));
|
|
62371
62491
|
} catch {
|
|
@@ -62471,7 +62591,7 @@ var uninstallSkill = (deps2, harnesses = [
|
|
|
62471
62591
|
);
|
|
62472
62592
|
continue;
|
|
62473
62593
|
}
|
|
62474
|
-
|
|
62594
|
+
rmSync16(targetOf(file2), { force: true });
|
|
62475
62595
|
try {
|
|
62476
62596
|
rmdirSync2(dir);
|
|
62477
62597
|
} catch {
|
|
@@ -62722,7 +62842,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
62722
62842
|
);
|
|
62723
62843
|
const habitsFile = join34(dest, OPENCLAW_HABITS_MARKER);
|
|
62724
62844
|
const dropHabitsIfOptedOut = () => {
|
|
62725
|
-
if (optedOut && kind2(dest) === "dir")
|
|
62845
|
+
if (optedOut && kind2(dest) === "dir") rmSync17(habitsFile, { force: true });
|
|
62726
62846
|
};
|
|
62727
62847
|
if (state === "current") {
|
|
62728
62848
|
rememberInstall(deps2);
|
|
@@ -62758,7 +62878,7 @@ async function installOpenclaw(deps2, notes, optedOut) {
|
|
|
62758
62878
|
`
|
|
62759
62879
|
);
|
|
62760
62880
|
rememberInstall(deps2);
|
|
62761
|
-
|
|
62881
|
+
rmSync17(habitsFile, { force: true });
|
|
62762
62882
|
restore2();
|
|
62763
62883
|
}
|
|
62764
62884
|
const en = await exec2(deps2, ["plugins", "enable", OPENCLAW_PLUGIN_ID]);
|
|
@@ -62808,7 +62928,7 @@ async function uninstallOpenclaw(deps2, notes) {
|
|
|
62808
62928
|
`\`openclaw plugins uninstall ${OPENCLAW_PLUGIN_ID}\` failed (${why(r)}); left the plugin folder, rerun once OpenClaw works`
|
|
62809
62929
|
);
|
|
62810
62930
|
} else notes.push(OPENCLAW_NO_CLI);
|
|
62811
|
-
|
|
62931
|
+
rmSync17(dest, { recursive: true, force: true });
|
|
62812
62932
|
forgetInstall(deps2);
|
|
62813
62933
|
return "done";
|
|
62814
62934
|
}
|
|
@@ -62899,10 +63019,10 @@ function blockState(existing) {
|
|
|
62899
63019
|
var separatorFor = (existing) => {
|
|
62900
63020
|
if (existing === "") return "";
|
|
62901
63021
|
const eol2 = existing.includes("\r\n") ? "\r\n" : "\n";
|
|
62902
|
-
let
|
|
62903
|
-
if (!existing.endsWith("\n"))
|
|
62904
|
-
if (!/\n\r?\n$/.test(existing +
|
|
62905
|
-
return
|
|
63022
|
+
let sep8 = "";
|
|
63023
|
+
if (!existing.endsWith("\n")) sep8 += eol2;
|
|
63024
|
+
if (!/\n\r?\n$/.test(existing + sep8)) sep8 += eol2;
|
|
63025
|
+
return sep8;
|
|
62906
63026
|
};
|
|
62907
63027
|
function withHabits(existing, block, added) {
|
|
62908
63028
|
const lines = existing.split("\n");
|
|
@@ -62973,6 +63093,7 @@ var pluginDirsOf = (v) => {
|
|
|
62973
63093
|
out[name] = list.filter((d) => typeof d === "string");
|
|
62974
63094
|
return out;
|
|
62975
63095
|
};
|
|
63096
|
+
var projectRecord = (busHome2) => record6(busHome2).project;
|
|
62976
63097
|
var saveRecord = (busHome2, patch) => {
|
|
62977
63098
|
if (!busHome2) return;
|
|
62978
63099
|
const cur = record6(busHome2);
|
|
@@ -62987,6 +63108,10 @@ var PROJECT_HABITS_FILE = {
|
|
|
62987
63108
|
opencode: "AGENTS.md"
|
|
62988
63109
|
};
|
|
62989
63110
|
var projectHabitsTarget = (cwd, h) => join35(cwd, PROJECT_HABITS_FILE[h]);
|
|
63111
|
+
var gitignoreLiteral = (path) => (
|
|
63112
|
+
// Spaces are escaped as well: git ignores a trailing one unless it is.
|
|
63113
|
+
path.replace(/[\\*?[\]! ]/g, (c) => `\\${c}`)
|
|
63114
|
+
);
|
|
62990
63115
|
var projectOf = (v) => {
|
|
62991
63116
|
const p = typeof v === "object" && v !== null ? v : {};
|
|
62992
63117
|
const exclude = [];
|
|
@@ -63001,6 +63126,16 @@ var projectOf = (v) => {
|
|
|
63001
63126
|
}
|
|
63002
63127
|
return { files: p.files ?? {}, exclude };
|
|
63003
63128
|
};
|
|
63129
|
+
function projectHabitsFileState(cwd, h) {
|
|
63130
|
+
const path = projectHabitsTarget(cwd, h);
|
|
63131
|
+
try {
|
|
63132
|
+
if (brokenLink(path)) return { state: "broken", path };
|
|
63133
|
+
if (!existsSync13(path)) return { state: "absent", path };
|
|
63134
|
+
return { ...blockState(readFileSync29(path, "utf8")), path };
|
|
63135
|
+
} catch {
|
|
63136
|
+
return { state: "broken", path };
|
|
63137
|
+
}
|
|
63138
|
+
}
|
|
63004
63139
|
function writeProjectHabits(deps2, harnesses, io = {}) {
|
|
63005
63140
|
const files2 = [];
|
|
63006
63141
|
const notes = [];
|
|
@@ -63046,7 +63181,7 @@ function writeProjectHabits(deps2, harnesses, io = {}) {
|
|
|
63046
63181
|
files_[path] = { added: separatorFor(before), created: true };
|
|
63047
63182
|
files2.push(path);
|
|
63048
63183
|
if (!exists3 && io.excludeFile !== void 0 && io.exclude !== void 0) {
|
|
63049
|
-
const line = `/${rel}`;
|
|
63184
|
+
const line = `/${gitignoreLiteral(rel)}`;
|
|
63050
63185
|
if (io.exclude(line))
|
|
63051
63186
|
exclude.push({ file: io.excludeFile, line, for: path });
|
|
63052
63187
|
}
|
|
@@ -63065,27 +63200,26 @@ function removeProjectHabits(deps2, only) {
|
|
|
63065
63200
|
const cur = record6(deps2.busHome).project;
|
|
63066
63201
|
const kept = { ...cur.files };
|
|
63067
63202
|
const exclude = [...cur.exclude];
|
|
63203
|
+
const cleaned = /* @__PURE__ */ new Set();
|
|
63068
63204
|
for (const [path, rec] of Object.entries(cur.files)) {
|
|
63069
63205
|
if (only !== void 0 && !only(path)) continue;
|
|
63070
63206
|
try {
|
|
63071
|
-
if (brokenLink(path) || !existsSync13(path)) {
|
|
63072
|
-
delete kept[path];
|
|
63073
|
-
continue;
|
|
63074
|
-
}
|
|
63075
|
-
if (isLink(path)) {
|
|
63076
|
-
notes.push(`Left ${path} alone: it is now a symlink.`);
|
|
63207
|
+
if (brokenLink(path) || !existsSync13(path) || isLink(path)) {
|
|
63077
63208
|
delete kept[path];
|
|
63209
|
+
cleaned.add(path);
|
|
63078
63210
|
continue;
|
|
63079
63211
|
}
|
|
63080
63212
|
const before = readFileSync29(path, "utf8");
|
|
63081
63213
|
if (blockState(before).state === "absent") {
|
|
63082
63214
|
delete kept[path];
|
|
63215
|
+
cleaned.add(path);
|
|
63083
63216
|
continue;
|
|
63084
63217
|
}
|
|
63085
63218
|
const after = withHabits(before, null, rec?.added);
|
|
63086
|
-
if (rec?.created && after.trim() === "")
|
|
63219
|
+
if (rec?.created && after.trim() === "") rmSync18(path, { force: true });
|
|
63087
63220
|
else writeAtomic(path, after);
|
|
63088
63221
|
delete kept[path];
|
|
63222
|
+
cleaned.add(path);
|
|
63089
63223
|
files2.push(path);
|
|
63090
63224
|
} catch (e) {
|
|
63091
63225
|
notes.push(
|
|
@@ -63095,6 +63229,7 @@ function removeProjectHabits(deps2, only) {
|
|
|
63095
63229
|
}
|
|
63096
63230
|
for (const e of [...exclude]) {
|
|
63097
63231
|
if (only !== void 0 && (e.for === void 0 || !only(e.for))) continue;
|
|
63232
|
+
if (e.for !== void 0 && !cleaned.has(e.for)) continue;
|
|
63098
63233
|
try {
|
|
63099
63234
|
const text3 = readFileSync29(e.file, "utf8");
|
|
63100
63235
|
const lines = text3.split("\n");
|
|
@@ -63181,7 +63316,7 @@ function removeHabits(deps2, harnesses = HABITS_HARNESSES) {
|
|
|
63181
63316
|
const rec = kept[path];
|
|
63182
63317
|
const after = withHabits(before, null, rec?.added);
|
|
63183
63318
|
if (rec?.created && !isLink(path) && after.trim() === "")
|
|
63184
|
-
|
|
63319
|
+
rmSync18(real3, { force: true });
|
|
63185
63320
|
else writeAtomic(real3, after);
|
|
63186
63321
|
delete kept[path];
|
|
63187
63322
|
files2.push(path);
|
|
@@ -63359,7 +63494,7 @@ function setPluginHabits(deps2, plugins2, on) {
|
|
|
63359
63494
|
continue;
|
|
63360
63495
|
}
|
|
63361
63496
|
try {
|
|
63362
|
-
|
|
63497
|
+
rmSync18(marker, { force: true });
|
|
63363
63498
|
} catch (e) {
|
|
63364
63499
|
left(
|
|
63365
63500
|
`Could not remove ${marker} (${reason(e)}): ${p.label} habits are still on there. Delete it, then rerun.`
|
|
@@ -63405,11 +63540,24 @@ var probe = (path) => {
|
|
|
63405
63540
|
var habitsOptedOut = (busHome2) => record6(busHome2).optedOut;
|
|
63406
63541
|
var setHabitsOptOut = (busHome2, optedOut, at) => saveRecord(busHome2, { optedOut, at });
|
|
63407
63542
|
var OMP_NOTE = "omp: not supported yet";
|
|
63543
|
+
var HABITS_GLOBAL_UPDATE_TEXT = "The habits for every project on this machine changed in this release, in {files}:";
|
|
63544
|
+
var HABITS_QUESTION_TEXT = "The bus would add {count} habits to this project only, in {files}:";
|
|
63408
63545
|
var habitsQuestion = (shownFiles, bus = BUS_CMD) => {
|
|
63409
|
-
const yes2 = `${bus} install --habits`;
|
|
63410
|
-
const no2 = `${bus} install --no-habits`;
|
|
63411
|
-
const text3 =
|
|
63412
|
-
|
|
63546
|
+
const yes2 = `${bus} install --habits-project`;
|
|
63547
|
+
const no2 = `${bus} install --no-habits-project`;
|
|
63548
|
+
const text3 = HABITS_QUESTION_TEXT.replace(
|
|
63549
|
+
"{count}",
|
|
63550
|
+
String(HABITS_LINES.length)
|
|
63551
|
+
).replace("{files}", shownFiles.join(" and "));
|
|
63552
|
+
return {
|
|
63553
|
+
text: text3,
|
|
63554
|
+
lines: HABITS_LINES.slice(),
|
|
63555
|
+
note: OMP_NOTE,
|
|
63556
|
+
yes: yes2,
|
|
63557
|
+
no: no2,
|
|
63558
|
+
global: `${bus} install --habits`,
|
|
63559
|
+
never: `${bus} install --no-habits`
|
|
63560
|
+
};
|
|
63413
63561
|
};
|
|
63414
63562
|
var habitsQuestionLines = (q) => [
|
|
63415
63563
|
"Installed. One question for your user before you finish:",
|
|
@@ -63419,11 +63567,13 @@ var habitsQuestionLines = (q) => [
|
|
|
63419
63567
|
...q.lines.map((l) => ` ${l}`),
|
|
63420
63568
|
` ${q.note}`,
|
|
63421
63569
|
`Yes: ${q.yes}`,
|
|
63422
|
-
`No: ${q.no}
|
|
63570
|
+
`No: ${q.no}`,
|
|
63571
|
+
...q.global ? [`All projects (invasive): ${q.global}`] : [],
|
|
63572
|
+
...q.never ? [`Never ask again on this machine: ${q.never}`] : []
|
|
63423
63573
|
];
|
|
63424
63574
|
|
|
63425
63575
|
// src/steps/opencode-proof.ts
|
|
63426
|
-
import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as
|
|
63576
|
+
import { existsSync as existsSync14, readFileSync as readFileSync30, rmSync as rmSync19 } from "node:fs";
|
|
63427
63577
|
import { dirname as dirname17, isAbsolute as isAbsolute13, join as join36, resolve as resolve12 } from "node:path";
|
|
63428
63578
|
init_src();
|
|
63429
63579
|
var OPENCODE_ENTRY_FILE = "opencode-mcp-entry.json";
|
|
@@ -63592,7 +63742,7 @@ function restoreEntry2(io) {
|
|
|
63592
63742
|
put2 = true;
|
|
63593
63743
|
}
|
|
63594
63744
|
}
|
|
63595
|
-
|
|
63745
|
+
rmSync19(io.moved, { force: true });
|
|
63596
63746
|
return put2;
|
|
63597
63747
|
}
|
|
63598
63748
|
function proxyProgramMissing2(entry, origin, which2) {
|
|
@@ -63637,7 +63787,7 @@ function skippedNotes(files2, read2, origin) {
|
|
|
63637
63787
|
}
|
|
63638
63788
|
|
|
63639
63789
|
// src/steps/pi-proof.ts
|
|
63640
|
-
import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as
|
|
63790
|
+
import { existsSync as existsSync15, readFileSync as readFileSync31, rmSync as rmSync20 } from "node:fs";
|
|
63641
63791
|
var PI_ENTRY_FILE = "pi-mcp-entry.json";
|
|
63642
63792
|
var OMP_ORIGIN_FILE = "omp-mcp-origin.json";
|
|
63643
63793
|
var PI_MIN_VERSION = "1.5.0";
|
|
@@ -63732,7 +63882,7 @@ function restoreEntry3(io) {
|
|
|
63732
63882
|
);
|
|
63733
63883
|
put2 = true;
|
|
63734
63884
|
}
|
|
63735
|
-
|
|
63885
|
+
rmSync20(io.moved, { force: true });
|
|
63736
63886
|
return put2;
|
|
63737
63887
|
}
|
|
63738
63888
|
|
|
@@ -63873,11 +64023,11 @@ function writeAtomic2(path, data, mode) {
|
|
|
63873
64023
|
}
|
|
63874
64024
|
const tmp = `${dest}.${process.pid}.${randomBytes8(4).toString("hex")}.tmp`;
|
|
63875
64025
|
try {
|
|
63876
|
-
|
|
64026
|
+
writeFileSync20(tmp, data, { mode: m, flag: "wx" });
|
|
63877
64027
|
chmodSync20(tmp, m);
|
|
63878
|
-
|
|
64028
|
+
renameSync21(tmp, dest);
|
|
63879
64029
|
} catch (e) {
|
|
63880
|
-
|
|
64030
|
+
rmSync21(tmp, { force: true });
|
|
63881
64031
|
throw e;
|
|
63882
64032
|
}
|
|
63883
64033
|
}
|
|
@@ -64276,7 +64426,7 @@ var install = {
|
|
|
64276
64426
|
}
|
|
64277
64427
|
if (had !== pin) writeAtomic2(p.codexBin, pin, 384);
|
|
64278
64428
|
} else {
|
|
64279
|
-
|
|
64429
|
+
rmSync21(p.codexBin, { force: true });
|
|
64280
64430
|
notes.push(CODEX_NO_BIN);
|
|
64281
64431
|
}
|
|
64282
64432
|
await codexEntryStep(deps2, notes);
|
|
@@ -64356,7 +64506,7 @@ var uninstall = {
|
|
|
64356
64506
|
for (const { file: file2 } of edits) delete left[file2];
|
|
64357
64507
|
writeRecord2(p.record, record7, left);
|
|
64358
64508
|
const hadPlugin = existsSync16(p.opencodePlugin);
|
|
64359
|
-
|
|
64509
|
+
rmSync21(p.opencodePlugin, { recursive: true, force: true });
|
|
64360
64510
|
if (!saved.some(Boolean) && !hadPlugin && !restored) return "none";
|
|
64361
64511
|
if (deps2.which("opencode")) await restartOpencode(deps2, notes, true);
|
|
64362
64512
|
return saved.some(Boolean) || restored ? "done" : "folder";
|
|
@@ -64374,16 +64524,16 @@ var uninstall = {
|
|
|
64374
64524
|
}
|
|
64375
64525
|
const path = paths(deps2).pi;
|
|
64376
64526
|
if (!existsSync16(path)) return restored ? "done" : "none";
|
|
64377
|
-
|
|
64527
|
+
rmSync21(path, { force: true });
|
|
64378
64528
|
return "done";
|
|
64379
64529
|
},
|
|
64380
64530
|
async omp(deps2, _notes, done) {
|
|
64381
|
-
|
|
64531
|
+
rmSync21(paths(deps2).ompOrigin, { force: true });
|
|
64382
64532
|
if (sharedFile(deps2) && done.includes("pi")) return "done";
|
|
64383
64533
|
if (sharedFile(deps2) && existsSync16(paths(deps2).piEntry)) return "none";
|
|
64384
64534
|
const path = paths(deps2).omp;
|
|
64385
64535
|
if (!existsSync16(path)) return "none";
|
|
64386
|
-
|
|
64536
|
+
rmSync21(path, { force: true });
|
|
64387
64537
|
return "done";
|
|
64388
64538
|
},
|
|
64389
64539
|
async codex(deps2, notes) {
|
|
@@ -64406,7 +64556,7 @@ var uninstall = {
|
|
|
64406
64556
|
}
|
|
64407
64557
|
}
|
|
64408
64558
|
const pinned = present2(p.codexBin);
|
|
64409
|
-
|
|
64559
|
+
rmSync21(p.codexBin, { force: true });
|
|
64410
64560
|
return saved || pinned ? "done" : "none";
|
|
64411
64561
|
},
|
|
64412
64562
|
async hermes(deps2, notes) {
|
|
@@ -64620,9 +64770,9 @@ import {
|
|
|
64620
64770
|
mkdirSync as mkdirSync16,
|
|
64621
64771
|
readFileSync as readFileSync33,
|
|
64622
64772
|
readlinkSync as readlinkSync6,
|
|
64623
|
-
renameSync as
|
|
64624
|
-
rmSync as
|
|
64625
|
-
writeFileSync as
|
|
64773
|
+
renameSync as renameSync22,
|
|
64774
|
+
rmSync as rmSync22,
|
|
64775
|
+
writeFileSync as writeFileSync21
|
|
64626
64776
|
} from "node:fs";
|
|
64627
64777
|
import { delimiter as delimiter3, dirname as dirname19, join as join38, resolve as resolve14, sep as sep6 } from "node:path";
|
|
64628
64778
|
var SHIM_MARKER = "# oa-bus shim: written by oa-bus install";
|
|
@@ -64673,13 +64823,13 @@ function ownerOf(file2, busHome2) {
|
|
|
64673
64823
|
var sameHome = (owner, busHome2) => owner?.ours === true && (owner.home === void 0 || owner.home === resolve14(busHome2));
|
|
64674
64824
|
function writeShim(path, text3) {
|
|
64675
64825
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
64676
|
-
|
|
64826
|
+
rmSync22(tmp, { force: true });
|
|
64677
64827
|
try {
|
|
64678
|
-
|
|
64828
|
+
writeFileSync21(tmp, text3, { mode: 493, flag: "wx" });
|
|
64679
64829
|
chmodSync21(tmp, 493);
|
|
64680
|
-
|
|
64830
|
+
renameSync22(tmp, path);
|
|
64681
64831
|
} catch (e) {
|
|
64682
|
-
|
|
64832
|
+
rmSync22(tmp, { force: true });
|
|
64683
64833
|
throw e;
|
|
64684
64834
|
}
|
|
64685
64835
|
}
|
|
@@ -64717,7 +64867,7 @@ function removeShim(o) {
|
|
|
64717
64867
|
const owner = ownerOf(file2, o.busHome);
|
|
64718
64868
|
if (!owner?.ours) continue;
|
|
64719
64869
|
if (owner.home !== void 0 && owner.home !== resolve14(o.busHome)) continue;
|
|
64720
|
-
|
|
64870
|
+
rmSync22(file2, { force: true });
|
|
64721
64871
|
removed = file2;
|
|
64722
64872
|
}
|
|
64723
64873
|
return removed;
|
|
@@ -64811,8 +64961,8 @@ import {
|
|
|
64811
64961
|
closeSync as closeSync10,
|
|
64812
64962
|
mkdirSync as mkdirSync17,
|
|
64813
64963
|
openSync as openSync10,
|
|
64814
|
-
renameSync as
|
|
64815
|
-
rmSync as
|
|
64964
|
+
renameSync as renameSync23,
|
|
64965
|
+
rmSync as rmSync23,
|
|
64816
64966
|
unlinkSync as unlinkSync5,
|
|
64817
64967
|
writeSync as writeSync5
|
|
64818
64968
|
} from "node:fs";
|
|
@@ -64879,7 +65029,7 @@ function writeMachineFile(home2, body) {
|
|
|
64879
65029
|
closeSync10(fd);
|
|
64880
65030
|
try {
|
|
64881
65031
|
chmodSync22(tmp, 384);
|
|
64882
|
-
|
|
65032
|
+
renameSync23(tmp, join40(home2, "machine.json"));
|
|
64883
65033
|
} catch (e) {
|
|
64884
65034
|
unlinkSync5(tmp);
|
|
64885
65035
|
throw e;
|
|
@@ -65029,7 +65179,7 @@ async function loginInner(args) {
|
|
|
65029
65179
|
`${JSON.stringify({ hub, label: label2, machine_token: poll.machine_token }, null, 2)}
|
|
65030
65180
|
`
|
|
65031
65181
|
);
|
|
65032
|
-
|
|
65182
|
+
rmSync23(join40(args.home, "revoked"), { force: true });
|
|
65033
65183
|
}
|
|
65034
65184
|
if (!events?.code) print(`Approved this machine as ${label2}.`);
|
|
65035
65185
|
return {
|
|
@@ -65493,7 +65643,7 @@ import {
|
|
|
65493
65643
|
readdirSync as readdirSync13,
|
|
65494
65644
|
readFileSync as readFileSync36,
|
|
65495
65645
|
rmdirSync as rmdirSync3,
|
|
65496
|
-
rmSync as
|
|
65646
|
+
rmSync as rmSync24
|
|
65497
65647
|
} from "node:fs";
|
|
65498
65648
|
import { dirname as dirname20, join as join44 } from "node:path";
|
|
65499
65649
|
var OUTPUT_STYLE_FILE = "artifacts-teammate.md";
|
|
@@ -65595,7 +65745,7 @@ function selectOutputStyle(deps2) {
|
|
|
65595
65745
|
} else {
|
|
65596
65746
|
try {
|
|
65597
65747
|
if (exists(path) && isOurs2(readFileSync36(path, "utf8"))) {
|
|
65598
|
-
|
|
65748
|
+
rmSync24(path);
|
|
65599
65749
|
removed = true;
|
|
65600
65750
|
if (readdirSync13(dir).length === 0) rmdirSync3(dir);
|
|
65601
65751
|
} else if (exists(path)) {
|
|
@@ -65644,7 +65794,7 @@ function turnOff(deps2, out) {
|
|
|
65644
65794
|
const was = rec?.set ? rec.before : void 0;
|
|
65645
65795
|
const next = was?.state === "null" ? setJsoncValue(cur.text, ["outputStyle"], null) : was?.state === "empty" ? setJsoncValue(cur.text, ["outputStyle"], was.value) : removeJsoncValue(cur.text, ["outputStyle"]);
|
|
65646
65796
|
if (rec?.set && rec.createdFile && (cur.text === createdText() || cur.text === createdText(OUTPUT_STYLE_NAME)))
|
|
65647
|
-
|
|
65797
|
+
rmSync24(path);
|
|
65648
65798
|
else writeAtomic(path, next);
|
|
65649
65799
|
}
|
|
65650
65800
|
if (busHome2 && rec) writeRecord3(busHome2, void 0);
|
|
@@ -65671,7 +65821,7 @@ function uninstallOutputStyle(deps2) {
|
|
|
65671
65821
|
`Left ${path} alone: it has no Open Artifacts marker, so it is not ours to replace.`
|
|
65672
65822
|
);
|
|
65673
65823
|
} else {
|
|
65674
|
-
|
|
65824
|
+
rmSync24(path);
|
|
65675
65825
|
out.written.push(path);
|
|
65676
65826
|
gone = true;
|
|
65677
65827
|
if (readdirSync13(dir).length === 0) rmdirSync3(dir);
|
|
@@ -66355,8 +66505,8 @@ var sseCheck = (ctx, name) => ({
|
|
|
66355
66505
|
|
|
66356
66506
|
// src/commands/habits.ts
|
|
66357
66507
|
init_src();
|
|
66358
|
-
import { mkdirSync as mkdirSync18, readFileSync as readFileSync39, realpathSync as realpathSync16, writeFileSync as
|
|
66359
|
-
import { dirname as dirname21, join as join47, resolve as resolve15 } from "node:path";
|
|
66508
|
+
import { mkdirSync as mkdirSync18, readFileSync as readFileSync39, realpathSync as realpathSync16, writeFileSync as writeFileSync22 } from "node:fs";
|
|
66509
|
+
import { dirname as dirname21, join as join47, resolve as resolve15, sep as sep7 } from "node:path";
|
|
66360
66510
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
66361
66511
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
66362
66512
|
var deps = (ctx) => ({
|
|
@@ -66457,6 +66607,82 @@ function disclosure(ctx, pending) {
|
|
|
66457
66607
|
...HABITS_LINES.map((l) => ` ${l}`)
|
|
66458
66608
|
];
|
|
66459
66609
|
}
|
|
66610
|
+
async function isRepoTop(ctx) {
|
|
66611
|
+
if (!ctx.which("git")) return "no";
|
|
66612
|
+
const r = await ctx.exec("git", ["-C", ctx.cwd, "rev-parse", "--show-toplevel"], {
|
|
66613
|
+
timeoutMs: 5e3
|
|
66614
|
+
}).catch(() => void 0);
|
|
66615
|
+
if (r?.code !== 0) return "no";
|
|
66616
|
+
const root = realpathOr(r.stdout.trim());
|
|
66617
|
+
if (root === realpathOr(ctx.userHome)) return "home";
|
|
66618
|
+
return { root };
|
|
66619
|
+
}
|
|
66620
|
+
var readBlocked = (busHome2) => {
|
|
66621
|
+
const raw = readInstallFile(join47(busHome2, "install.json")).habits ?? {};
|
|
66622
|
+
const out = {};
|
|
66623
|
+
if (typeof raw.projectBlocked === "object" && raw.projectBlocked !== null) {
|
|
66624
|
+
for (const [root, list] of Object.entries(
|
|
66625
|
+
raw.projectBlocked
|
|
66626
|
+
))
|
|
66627
|
+
if (Array.isArray(list))
|
|
66628
|
+
out[root] = list.filter((h) => typeof h === "string");
|
|
66629
|
+
}
|
|
66630
|
+
return out;
|
|
66631
|
+
};
|
|
66632
|
+
var saveBlocked = (busHome2, map2) => {
|
|
66633
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66634
|
+
habits: { ...habitsRecord(busHome2), projectBlocked: map2 }
|
|
66635
|
+
});
|
|
66636
|
+
};
|
|
66637
|
+
var habitsRecord = (busHome2) => readInstallFile(join47(busHome2, "install.json")).habits ?? {};
|
|
66638
|
+
var pluginLineSaid = (busHome2) => habitsRecord(busHome2).pluginLineSaid === true;
|
|
66639
|
+
var markPluginLineSaid = (busHome2) => {
|
|
66640
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66641
|
+
habits: { ...habitsRecord(busHome2), pluginLineSaid: true }
|
|
66642
|
+
});
|
|
66643
|
+
};
|
|
66644
|
+
var noteBlocked = (ctx, folder, blocked, json4) => {
|
|
66645
|
+
const said = readBlocked(ctx.home);
|
|
66646
|
+
const fresh = blocked.filter((h) => !(said[folder] ?? []).includes(h));
|
|
66647
|
+
if (fresh.length === 0) return "";
|
|
66648
|
+
const why2 = `${fresh.join(", ")} read this project's AGENTS.md, but git tracks it, so the habits cannot go there without committing them. \`--habits\` adds them for all projects.`;
|
|
66649
|
+
saveBlocked(ctx.home, {
|
|
66650
|
+
...said,
|
|
66651
|
+
[folder]: [...said[folder] ?? [], ...fresh]
|
|
66652
|
+
});
|
|
66653
|
+
if (!json4) say(ctx, why2);
|
|
66654
|
+
return why2;
|
|
66655
|
+
};
|
|
66656
|
+
var readDeclined = (busHome2) => {
|
|
66657
|
+
const raw = habitsRecord(busHome2).projectDeclined;
|
|
66658
|
+
const out = {};
|
|
66659
|
+
if (typeof raw === "object" && raw !== null) {
|
|
66660
|
+
for (const [root, v] of Object.entries(raw))
|
|
66661
|
+
if (v === true) out[root] = true;
|
|
66662
|
+
}
|
|
66663
|
+
return out;
|
|
66664
|
+
};
|
|
66665
|
+
var setDeclined = (busHome2, root, off) => {
|
|
66666
|
+
const cur = readDeclined(busHome2);
|
|
66667
|
+
if (off) cur[root] = true;
|
|
66668
|
+
else delete cur[root];
|
|
66669
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66670
|
+
habits: { ...habitsRecord(busHome2), projectDeclined: cur }
|
|
66671
|
+
});
|
|
66672
|
+
};
|
|
66673
|
+
var moveOffered = (busHome2) => habitsRecord(busHome2).projectMoveOffered === true;
|
|
66674
|
+
var markMoveOffered = (busHome2) => {
|
|
66675
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66676
|
+
habits: { ...habitsRecord(busHome2), projectMoveOffered: true }
|
|
66677
|
+
});
|
|
66678
|
+
};
|
|
66679
|
+
var realpathOr = (p) => {
|
|
66680
|
+
try {
|
|
66681
|
+
return realpathSync16(p);
|
|
66682
|
+
} catch {
|
|
66683
|
+
return resolve15(p);
|
|
66684
|
+
}
|
|
66685
|
+
};
|
|
66460
66686
|
async function projectIo(ctx) {
|
|
66461
66687
|
if (!ctx.which("git")) return {};
|
|
66462
66688
|
const git3 = (args) => ctx.exec("git", ["-C", ctx.cwd, ...args], { timeoutMs: 5e3 });
|
|
@@ -66496,15 +66722,15 @@ async function projectIo(ctx) {
|
|
|
66496
66722
|
}
|
|
66497
66723
|
const lines = text3.split("\n");
|
|
66498
66724
|
if (lines.includes(line)) return false;
|
|
66499
|
-
const
|
|
66500
|
-
|
|
66725
|
+
const sep8 = text3 === "" || text3.endsWith("\n") ? "" : "\n";
|
|
66726
|
+
writeFileSync22(excludeFile, `${text3}${sep8}${line}
|
|
66501
66727
|
`);
|
|
66502
66728
|
return true;
|
|
66503
66729
|
},
|
|
66504
66730
|
unexclude: (line) => {
|
|
66505
66731
|
try {
|
|
66506
66732
|
const lines = readFileSync39(excludeFile, "utf8").split("\n");
|
|
66507
|
-
|
|
66733
|
+
writeFileSync22(excludeFile, lines.filter((l) => l !== line).join("\n"));
|
|
66508
66734
|
} catch {
|
|
66509
66735
|
}
|
|
66510
66736
|
}
|
|
@@ -66518,10 +66744,24 @@ async function habitsProject(ctx) {
|
|
|
66518
66744
|
question: null,
|
|
66519
66745
|
plugins: pluginStates(ctx)
|
|
66520
66746
|
};
|
|
66521
|
-
if (targets.length === 0
|
|
66522
|
-
|
|
66747
|
+
if (targets.length === 0) {
|
|
66748
|
+
say(
|
|
66749
|
+
ctx,
|
|
66750
|
+
"No harness here has a project instruction file to put the habits in, so nothing was written. Install a harness first (Claude Code, Codex, pi or OpenCode), then run this again."
|
|
66751
|
+
);
|
|
66752
|
+
return none2;
|
|
66753
|
+
}
|
|
66754
|
+
const repo = await isRepoTop(ctx);
|
|
66755
|
+
if (repo === "home" || repo === "no") {
|
|
66756
|
+
say(
|
|
66757
|
+
ctx,
|
|
66758
|
+
repo === "home" ? "This is your home folder, not a project: habits written here would reach every project under it. Run the install at the top of a project instead." : "This folder is not inside a git repository, so there is no project to write the habits to."
|
|
66759
|
+
);
|
|
66760
|
+
return none2;
|
|
66761
|
+
}
|
|
66762
|
+
const io = await projectIo({ ...ctx, cwd: repo.root });
|
|
66523
66763
|
const r = writeProjectHabits(
|
|
66524
|
-
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home, cwd:
|
|
66764
|
+
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home, cwd: repo.root },
|
|
66525
66765
|
targets,
|
|
66526
66766
|
io
|
|
66527
66767
|
);
|
|
@@ -66529,6 +66769,7 @@ async function habitsProject(ctx) {
|
|
|
66529
66769
|
r.notes.push(
|
|
66530
66770
|
`The ${plugins2.map((p) => p.label).join(", ")} plugin carries the habits machine-wide, so this command leaves it alone. Turn those on or off with ${ctx.busCmd} install --habits and --no-habits.`
|
|
66531
66771
|
);
|
|
66772
|
+
setDeclined(ctx.home, repo.root, false);
|
|
66532
66773
|
if (r.files.length > 0)
|
|
66533
66774
|
say(ctx, `Habits on in this folder: ${shown2(ctx, r.files)}`);
|
|
66534
66775
|
for (const n of r.notes) say(ctx, n);
|
|
@@ -66539,7 +66780,7 @@ async function habitsProject(ctx) {
|
|
|
66539
66780
|
plugins: pluginStates(ctx)
|
|
66540
66781
|
};
|
|
66541
66782
|
}
|
|
66542
|
-
function habitsProjectOff(ctx) {
|
|
66783
|
+
async function habitsProjectOff(ctx) {
|
|
66543
66784
|
const real3 = (p) => {
|
|
66544
66785
|
try {
|
|
66545
66786
|
return realpathSync16(p);
|
|
@@ -66547,11 +66788,20 @@ function habitsProjectOff(ctx) {
|
|
|
66547
66788
|
return resolve15(p);
|
|
66548
66789
|
}
|
|
66549
66790
|
};
|
|
66550
|
-
const
|
|
66791
|
+
const repo = await isRepoTop(ctx);
|
|
66792
|
+
if (repo === "home" || repo === "no") {
|
|
66793
|
+
say(
|
|
66794
|
+
ctx,
|
|
66795
|
+
repo === "home" ? "This is your home folder, not a project, so there are no project habits to turn off here." : "This folder is not inside a git repo, so there are no project habits to turn off here."
|
|
66796
|
+
);
|
|
66797
|
+
return 0;
|
|
66798
|
+
}
|
|
66799
|
+
const cwd = repo.root;
|
|
66551
66800
|
const r = removeProjectHabits(
|
|
66552
66801
|
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home },
|
|
66553
66802
|
(path) => dirname21(real3(path)) === cwd
|
|
66554
66803
|
);
|
|
66804
|
+
setDeclined(ctx.home, cwd, true);
|
|
66555
66805
|
if (r.files.length === 0 && r.notes.length === 0) {
|
|
66556
66806
|
say(ctx, `No bus habits here to remove in ${tilde(ctx, cwd)}.`);
|
|
66557
66807
|
return 0;
|
|
@@ -66572,32 +66822,142 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66572
66822
|
if (habitsOptedOut(ctx.home))
|
|
66573
66823
|
return { ...none2, state: "off", question: null };
|
|
66574
66824
|
if (targets.length === 0 && plugins2.length === 0) return none2;
|
|
66575
|
-
|
|
66576
|
-
|
|
66577
|
-
|
|
66578
|
-
|
|
66579
|
-
|
|
66580
|
-
|
|
66581
|
-
|
|
66582
|
-
|
|
66583
|
-
|
|
66584
|
-
|
|
66585
|
-
|
|
66825
|
+
if (plugins2.length > 0 && !json4 && !pluginLineSaid(ctx.home)) {
|
|
66826
|
+
say(
|
|
66827
|
+
ctx,
|
|
66828
|
+
`The ${plugins2.map((p) => p.label).join(", ")} plugin carries the habits machine-wide; change that with install --habits and --no-habits.`
|
|
66829
|
+
);
|
|
66830
|
+
markPluginLineSaid(ctx.home);
|
|
66831
|
+
}
|
|
66832
|
+
const repoTop = await isRepoTop(ctx);
|
|
66833
|
+
const folder = repoTop === "home" || repoTop === "no" ? ctx.cwd : repoTop.root;
|
|
66834
|
+
const io = await projectIo({ ...ctx, cwd: folder });
|
|
66835
|
+
const nameOf2 = (h) => io.rel?.(PROJECT_HABITS_FILE[h]) ?? PROJECT_HABITS_FILE[h];
|
|
66836
|
+
const writable = targets.filter((h) => io.tracked?.(nameOf2(h)) !== true);
|
|
66837
|
+
const blocked = targets.filter((h) => io.tracked?.(nameOf2(h)) === true);
|
|
66838
|
+
const globalStates = targets.map((h) => habitsFileState(deps(ctx), h));
|
|
66839
|
+
const globalPending = globalStates.filter(
|
|
66840
|
+
(st) => st.state === "changed" || st.state === "broken"
|
|
66841
|
+
);
|
|
66842
|
+
const globalOn = globalStates.filter((st) => st.state === "current");
|
|
66843
|
+
if (globalOn.length > 0 && globalPending.length === 0) {
|
|
66844
|
+
if (!json4 && !moveOffered(ctx.home)) {
|
|
66845
|
+
say(
|
|
66846
|
+
ctx,
|
|
66847
|
+
"Habits are on for every project on this machine. To keep them in projects only, run install --habits-project in a project and install --no-habits for these global ones."
|
|
66848
|
+
);
|
|
66849
|
+
markMoveOffered(ctx.home);
|
|
66850
|
+
}
|
|
66851
|
+
return {
|
|
66852
|
+
...none2,
|
|
66853
|
+
state: "on",
|
|
66854
|
+
files: globalStates.map((st) => st.path),
|
|
66855
|
+
question: null
|
|
66856
|
+
};
|
|
66857
|
+
}
|
|
66858
|
+
if (globalPending.length > 0) {
|
|
66859
|
+
const changedGlobals = targets.filter(
|
|
66860
|
+
(h) => habitsFileState(deps(ctx), h).state === "changed"
|
|
66861
|
+
);
|
|
66862
|
+
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66863
|
+
say(
|
|
66864
|
+
ctx,
|
|
66865
|
+
"",
|
|
66866
|
+
disclosure(
|
|
66867
|
+
ctx,
|
|
66868
|
+
globalPending.map((st) => ({ path: st.path, s: st }))
|
|
66869
|
+
)
|
|
66870
|
+
);
|
|
66871
|
+
const a = (await ctx.readLine("Update them? [Y/n] ")).trim().toLowerCase();
|
|
66872
|
+
if (a === "" || a === "y" || a === "yes") {
|
|
66873
|
+
writeHabits(deps(ctx), changedGlobals, { explicit: a !== "" });
|
|
66874
|
+
say(ctx, "Habits updated for every project on this machine.");
|
|
66586
66875
|
}
|
|
66587
|
-
|
|
66876
|
+
return {
|
|
66877
|
+
...none2,
|
|
66878
|
+
state: "changed",
|
|
66879
|
+
files: globalStates.map((st) => st.path),
|
|
66880
|
+
question: null
|
|
66881
|
+
};
|
|
66882
|
+
}
|
|
66883
|
+
const bus = json4 ? BUS_CMD : ctx.busCmd;
|
|
66884
|
+
const files2 = globalStates.map((st) => one2(ctx, st.path)).join(" and ");
|
|
66885
|
+
const q = {
|
|
66886
|
+
...habitsQuestion([files2], bus),
|
|
66887
|
+
text: HABITS_GLOBAL_UPDATE_TEXT.replace("{files}", files2),
|
|
66888
|
+
yes: `${bus} install --habits`,
|
|
66889
|
+
// Declining a global update is not a project answer: nothing here may
|
|
66890
|
+
// mark the current folder declined.
|
|
66891
|
+
no: `${bus} install --no-habits`,
|
|
66892
|
+
never: void 0,
|
|
66893
|
+
note: `These are for every project on this machine. ${OMP_NOTE}`
|
|
66894
|
+
};
|
|
66895
|
+
q.global = void 0;
|
|
66896
|
+
return {
|
|
66897
|
+
...none2,
|
|
66898
|
+
state: "changed",
|
|
66899
|
+
files: globalStates.map((st) => st.path),
|
|
66900
|
+
question: q
|
|
66901
|
+
};
|
|
66902
|
+
}
|
|
66903
|
+
if (repoTop !== "home" && repoTop !== "no" && readDeclined(ctx.home)[folder]) {
|
|
66904
|
+
return { ...none2, state: "off", files: [], question: null };
|
|
66905
|
+
}
|
|
66906
|
+
const states = [
|
|
66907
|
+
...writable.map((h) => {
|
|
66908
|
+
const st = projectHabitsFileState(folder, h);
|
|
66909
|
+
return { path: st.path, s: st };
|
|
66910
|
+
})
|
|
66588
66911
|
];
|
|
66912
|
+
const whyBlocked = (list) => `${list.join(", ")} read this project's AGENTS.md, but git tracks it, so the habits cannot go there without committing them. \`--habits\` adds them for all projects.`;
|
|
66589
66913
|
const pending = states.filter((p) => p.s.state !== "current");
|
|
66590
66914
|
const have = states.filter((p) => p.s.state === "current").map((p) => p.path);
|
|
66591
|
-
if (pending.length === 0)
|
|
66915
|
+
if (pending.length === 0) {
|
|
66916
|
+
if (writable.length === 0 && blocked.length > 0) {
|
|
66917
|
+
const whyBlockedNow = noteBlocked(ctx, folder, blocked, json4);
|
|
66918
|
+
return {
|
|
66919
|
+
...none2,
|
|
66920
|
+
state: "undecided",
|
|
66921
|
+
files: have,
|
|
66922
|
+
question: null,
|
|
66923
|
+
...whyBlockedNow ? { note: whyBlockedNow } : {}
|
|
66924
|
+
};
|
|
66925
|
+
}
|
|
66592
66926
|
return { ...none2, state: "on", files: have, question: null };
|
|
66927
|
+
}
|
|
66593
66928
|
const changed = pending.some((p) => p.s.state === "changed");
|
|
66594
66929
|
const state = changed ? "changed" : "undecided";
|
|
66930
|
+
if (repoTop === "home" || repoTop === "no") {
|
|
66931
|
+
const why2 = repoTop === "home" ? "This is your home folder, not a project: habits written here would reach every project under it. Run the install at the top of a project instead." : "This folder is not inside a git repository, so there is no project to write the habits to.";
|
|
66932
|
+
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66933
|
+
say(ctx, why2);
|
|
66934
|
+
return { ...none2, state, files: have, question: null };
|
|
66935
|
+
}
|
|
66936
|
+
if (!json4) say(ctx, why2);
|
|
66937
|
+
return { ...none2, state, files: have, question: null, note: why2 };
|
|
66938
|
+
}
|
|
66595
66939
|
const asked = pending.map((p) => p.path);
|
|
66596
66940
|
const question = habitsQuestion(
|
|
66597
66941
|
pending.map((p) => p.label ?? one2(ctx, p.path)),
|
|
66598
66942
|
// --json goes to an agent that may hand the commands to its user's own shell.
|
|
66599
66943
|
json4 ? BUS_CMD : ctx.busCmd
|
|
66600
66944
|
);
|
|
66945
|
+
if (blocked.length > 0) {
|
|
66946
|
+
const said = readBlocked(ctx.home);
|
|
66947
|
+
const root = folder;
|
|
66948
|
+
const fresh = blocked.filter((h) => !(said[root] ?? []).includes(h));
|
|
66949
|
+
if (fresh.length > 0) {
|
|
66950
|
+
question.note = `${whyBlocked(fresh)} ${question.note}`;
|
|
66951
|
+
saveBlocked(ctx.home, {
|
|
66952
|
+
...said,
|
|
66953
|
+
[root]: [...said[root] ?? [], ...fresh]
|
|
66954
|
+
});
|
|
66955
|
+
}
|
|
66956
|
+
}
|
|
66957
|
+
if (plugins2.length > 0)
|
|
66958
|
+
question.note = `${question.note} The ${plugins2.map((p) => p.label).join(
|
|
66959
|
+
", "
|
|
66960
|
+
)} plugin carries them machine-wide; change that with install --habits and --no-habits.`;
|
|
66601
66961
|
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66602
66962
|
say(ctx, "", disclosure(ctx, pending));
|
|
66603
66963
|
const outside = pending.some(
|
|
@@ -66614,22 +66974,21 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66614
66974
|
return { ...none2, state, files: have, question };
|
|
66615
66975
|
}
|
|
66616
66976
|
if (a === "" || a === "y" || a === "yes") {
|
|
66617
|
-
const r =
|
|
66618
|
-
|
|
66619
|
-
|
|
66620
|
-
(h) => asked.includes(
|
|
66621
|
-
),
|
|
66622
|
-
{ explicit: a !== "" }
|
|
66623
|
-
);
|
|
66624
|
-
const pl = setPluginHabits(
|
|
66625
|
-
deps(ctx),
|
|
66626
|
-
plugins2.filter(
|
|
66627
|
-
(p) => asked.includes(join47(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
66977
|
+
const r = writeProjectHabits(
|
|
66978
|
+
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home, cwd: folder },
|
|
66979
|
+
writable.filter(
|
|
66980
|
+
(h) => asked.includes(projectHabitsFileState(folder, h).path)
|
|
66628
66981
|
),
|
|
66629
|
-
|
|
66982
|
+
io
|
|
66630
66983
|
);
|
|
66631
|
-
|
|
66984
|
+
const pl = { changed: [], notes: [], pluginFiles: [], incomplete: false };
|
|
66985
|
+
if (!changed) setDeclined(ctx.home, folder, false);
|
|
66632
66986
|
if (r.files.length > 0) say(ctx, `Habits on in ${shown2(ctx, r.files)}`);
|
|
66987
|
+
if (plugins2.length > 0)
|
|
66988
|
+
say(
|
|
66989
|
+
ctx,
|
|
66990
|
+
`The ${plugins2.map((p) => p.label).join(", ")} plugin carries the habits machine-wide, so it was left as it is. Change it with install --habits and --no-habits.`
|
|
66991
|
+
);
|
|
66633
66992
|
for (const p of pl.changed) say(ctx, pluginOn(p));
|
|
66634
66993
|
for (const n of [...r.notes, ...pl.notes]) say(ctx, n);
|
|
66635
66994
|
return {
|
|
@@ -66642,17 +67001,11 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66642
67001
|
}
|
|
66643
67002
|
if (a === "n" || a === "no") {
|
|
66644
67003
|
if (!changed) {
|
|
66645
|
-
|
|
66646
|
-
|
|
66647
|
-
|
|
66648
|
-
|
|
66649
|
-
|
|
66650
|
-
"Habits are still on in some places (see below). Your opt-out is saved, so a reinstall won't add them back."
|
|
66651
|
-
);
|
|
66652
|
-
for (const n of off.notes) say(ctx, n);
|
|
66653
|
-
return { ...none2, state: "on", plugins: pluginStates(ctx) };
|
|
66654
|
-
}
|
|
66655
|
-
say(ctx, "Habits off. A reinstall will not add them back.");
|
|
67004
|
+
setDeclined(ctx.home, folder, true);
|
|
67005
|
+
say(
|
|
67006
|
+
ctx,
|
|
67007
|
+
"Habits stay off in this project. Other projects will still be asked; install --no-habits turns them off everywhere and never asks again."
|
|
67008
|
+
);
|
|
66656
67009
|
return { ...none2, state: "off", plugins: pluginStates(ctx) };
|
|
66657
67010
|
}
|
|
66658
67011
|
say(ctx, "Left the habits as they were.");
|
|
@@ -66667,7 +67020,7 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66667
67020
|
async function habitsCommand(mode, ctx) {
|
|
66668
67021
|
say(ctx, ctx.copy.header(ctx.version), "");
|
|
66669
67022
|
if (mode === "show") return show(ctx);
|
|
66670
|
-
if (mode === "project-off") return habitsProjectOff(ctx);
|
|
67023
|
+
if (mode === "project-off") return await habitsProjectOff(ctx);
|
|
66671
67024
|
if (mode === "project") {
|
|
66672
67025
|
try {
|
|
66673
67026
|
const r = await habitsProject(ctx);
|
|
@@ -66679,6 +67032,28 @@ async function habitsCommand(mode, ctx) {
|
|
|
66679
67032
|
}
|
|
66680
67033
|
return mode === "yes" ? turnOn2(ctx) : turnOff2(ctx);
|
|
66681
67034
|
}
|
|
67035
|
+
var projectHere = (ctx) => {
|
|
67036
|
+
const base3 = realpathOr(ctx.cwd);
|
|
67037
|
+
const atOrBelow = (p) => {
|
|
67038
|
+
const dir = realpathOr(dirname21(p));
|
|
67039
|
+
return dir === base3 || base3.startsWith(`${dir}${sep7}`);
|
|
67040
|
+
};
|
|
67041
|
+
const rec = projectRecord(deps(ctx).busHome);
|
|
67042
|
+
const files2 = Object.keys(rec.files).filter(atOrBelow);
|
|
67043
|
+
const changed = files2.some((f) => {
|
|
67044
|
+
try {
|
|
67045
|
+
return blockState(readFileSync39(f, "utf8")).state === "changed";
|
|
67046
|
+
} catch {
|
|
67047
|
+
return false;
|
|
67048
|
+
}
|
|
67049
|
+
});
|
|
67050
|
+
const declined = Object.keys(readDeclined(ctx.home)).some((root) => {
|
|
67051
|
+
const dir = realpathOr(root);
|
|
67052
|
+
return dir === base3 || base3.startsWith(`${dir}${sep7}`);
|
|
67053
|
+
});
|
|
67054
|
+
return { files: files2, changed, declined };
|
|
67055
|
+
};
|
|
67056
|
+
var habitsWhere = (ctx, files2) => `on in this project, ${shown2(ctx, files2)}`;
|
|
66682
67057
|
function habitsLine(ctx) {
|
|
66683
67058
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
66684
67059
|
if (habitsOptedOut(ctx.home)) return "Habits: off (you opted out)";
|
|
@@ -66688,6 +67063,10 @@ function habitsLine(ctx) {
|
|
|
66688
67063
|
);
|
|
66689
67064
|
const states = used.map((p) => pluginStateText(ctx, p));
|
|
66690
67065
|
const tail2 = states.length > 0 ? `; ${states.join("; ")}` : "";
|
|
67066
|
+
const here = projectHere(ctx);
|
|
67067
|
+
if (here.files.length > 0)
|
|
67068
|
+
return here.changed ? `Habits: out of date in this project, ${shown2(ctx, here.files)}. Run ${ctx.busCmd} install to update them${tail2}` : `Habits: ${habitsWhere(ctx, here.files)}${tail2}`;
|
|
67069
|
+
if (here.declined) return `Habits: off in this project${tail2}`;
|
|
66691
67070
|
if (on.length > 0) return `Habits: on in ${shown2(ctx, on)}${tail2}`;
|
|
66692
67071
|
if (used.some((p) => pluginHabitsState(deps(ctx), p) === "on"))
|
|
66693
67072
|
return `Habits: ${states.join("; ")}`;
|
|
@@ -66903,7 +67282,7 @@ import {
|
|
|
66903
67282
|
readdirSync as readdirSync14,
|
|
66904
67283
|
readFileSync as readFileSync40,
|
|
66905
67284
|
rmdirSync as rmdirSync4,
|
|
66906
|
-
rmSync as
|
|
67285
|
+
rmSync as rmSync25
|
|
66907
67286
|
} from "node:fs";
|
|
66908
67287
|
import { join as join49 } from "node:path";
|
|
66909
67288
|
function leftoverTargets(deps2) {
|
|
@@ -66980,7 +67359,7 @@ function removeMade(made) {
|
|
|
66980
67359
|
const gone = [];
|
|
66981
67360
|
for (const path of made) {
|
|
66982
67361
|
if (!emptyFile(path)) continue;
|
|
66983
|
-
|
|
67362
|
+
rmSync25(path, { force: true });
|
|
66984
67363
|
gone.push(path);
|
|
66985
67364
|
}
|
|
66986
67365
|
for (const path of made.filter((x) => !gone.includes(x)).sort((a, b) => b.length - a.length)) {
|
|
@@ -68529,7 +68908,7 @@ import { join as join56 } from "node:path";
|
|
|
68529
68908
|
|
|
68530
68909
|
// src/steps/purge.ts
|
|
68531
68910
|
init_src3();
|
|
68532
|
-
import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as
|
|
68911
|
+
import { lstatSync as lstatSync23, readdirSync as readdirSync15, rmdirSync as rmdirSync5, rmSync as rmSync26 } from "node:fs";
|
|
68533
68912
|
import { join as join55 } from "node:path";
|
|
68534
68913
|
var FILES = [
|
|
68535
68914
|
"machine.json",
|
|
@@ -68589,7 +68968,7 @@ function kind3(path) {
|
|
|
68589
68968
|
return void 0;
|
|
68590
68969
|
}
|
|
68591
68970
|
}
|
|
68592
|
-
var remove2 = (path, k) =>
|
|
68971
|
+
var remove2 = (path, k) => rmSync26(path, { recursive: k === "dir", force: true });
|
|
68593
68972
|
var rmdirIfEmpty = (path) => {
|
|
68594
68973
|
try {
|
|
68595
68974
|
rmdirSync5(path);
|
|
@@ -68884,8 +69263,8 @@ import {
|
|
|
68884
69263
|
copyFileSync as copyFileSync2,
|
|
68885
69264
|
existsSync as existsSync20,
|
|
68886
69265
|
mkdirSync as mkdirSync19,
|
|
68887
|
-
rmSync as
|
|
68888
|
-
writeFileSync as
|
|
69266
|
+
rmSync as rmSync27,
|
|
69267
|
+
writeFileSync as writeFileSync23
|
|
68889
69268
|
} from "node:fs";
|
|
68890
69269
|
import { join as join57 } from "node:path";
|
|
68891
69270
|
var realUpgradeDeps = (ctx) => ({
|
|
@@ -69017,7 +69396,7 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
|
|
|
69017
69396
|
const marker = join57(dest, ".live", String(process.pid));
|
|
69018
69397
|
try {
|
|
69019
69398
|
mkdirSync19(join57(dest, ".live"), { recursive: true, mode: 448 });
|
|
69020
|
-
|
|
69399
|
+
writeFileSync23(marker, "", { mode: 384 });
|
|
69021
69400
|
} catch {
|
|
69022
69401
|
}
|
|
69023
69402
|
deps2.beforeInstall?.(dest);
|
|
@@ -69033,7 +69412,7 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
|
|
|
69033
69412
|
args.push("--no-service");
|
|
69034
69413
|
setPending(ctx.home, { from: runBase, to: target2, startedAt: ctx.now() });
|
|
69035
69414
|
const code2 = deps2.runInstaller(entry, args);
|
|
69036
|
-
|
|
69415
|
+
rmSync27(marker, { force: true });
|
|
69037
69416
|
if (code2 !== 0) {
|
|
69038
69417
|
clearPending(ctx.home);
|
|
69039
69418
|
sayErr(ctx, c.upgradeInstallFailed(target2, code2));
|