@open-artifacts/bus 0.239.2 → 0.241.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 +658 -156
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -4586,7 +4586,7 @@ function isRef(value) {
|
|
|
4586
4586
|
function cloneIssues(issues) {
|
|
4587
4587
|
return issues.map((iss) => iss.path ? { ...iss, path: iss.path.slice() } : { ...iss });
|
|
4588
4588
|
}
|
|
4589
|
-
function isRecursive(inst, stack,
|
|
4589
|
+
function isRecursive(inst, stack, resolve20) {
|
|
4590
4590
|
const cached2 = recursive.get(inst);
|
|
4591
4591
|
if (cached2 !== void 0)
|
|
4592
4592
|
return cached2 ? PROVEN : NONE;
|
|
@@ -4596,7 +4596,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
4596
4596
|
let result = NONE;
|
|
4597
4597
|
const check2 = (child) => {
|
|
4598
4598
|
if (result !== PROVEN && child?._zod) {
|
|
4599
|
-
const answer = isRecursive(child, stack,
|
|
4599
|
+
const answer = isRecursive(child, stack, resolve20);
|
|
4600
4600
|
if (answer > result)
|
|
4601
4601
|
result = answer;
|
|
4602
4602
|
}
|
|
@@ -4607,7 +4607,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
4607
4607
|
const desc = Object.getOwnPropertyDescriptor(sh, key2);
|
|
4608
4608
|
if (spread && !desc.enumerable)
|
|
4609
4609
|
continue;
|
|
4610
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
4610
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve20) : NONE;
|
|
4611
4611
|
if (child > answer)
|
|
4612
4612
|
answer = child;
|
|
4613
4613
|
}
|
|
@@ -4671,7 +4671,7 @@ function isRecursive(inst, stack, resolve19) {
|
|
|
4671
4671
|
break;
|
|
4672
4672
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
4673
4673
|
case "lazy": {
|
|
4674
|
-
const inner = def._cachedInner ?? (
|
|
4674
|
+
const inner = def._cachedInner ?? (resolve20 ? inst._zod.innerType : void 0);
|
|
4675
4675
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
4676
4676
|
break;
|
|
4677
4677
|
}
|
|
@@ -23038,7 +23038,7 @@ var init_protocol = __esm({
|
|
|
23038
23038
|
return;
|
|
23039
23039
|
}
|
|
23040
23040
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
23041
|
-
await new Promise((
|
|
23041
|
+
await new Promise((resolve20) => setTimeout(resolve20, pollInterval));
|
|
23042
23042
|
options?.signal?.throwIfAborted();
|
|
23043
23043
|
}
|
|
23044
23044
|
} catch (error62) {
|
|
@@ -23055,7 +23055,7 @@ var init_protocol = __esm({
|
|
|
23055
23055
|
*/
|
|
23056
23056
|
request(request, resultSchema, options) {
|
|
23057
23057
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
23058
|
-
return new Promise((
|
|
23058
|
+
return new Promise((resolve20, reject) => {
|
|
23059
23059
|
const earlyReject = (error62) => {
|
|
23060
23060
|
reject(error62);
|
|
23061
23061
|
};
|
|
@@ -23133,7 +23133,7 @@ var init_protocol = __esm({
|
|
|
23133
23133
|
if (!parseResult.success) {
|
|
23134
23134
|
reject(parseResult.error);
|
|
23135
23135
|
} else {
|
|
23136
|
-
|
|
23136
|
+
resolve20(parseResult.data);
|
|
23137
23137
|
}
|
|
23138
23138
|
} catch (error62) {
|
|
23139
23139
|
reject(error62);
|
|
@@ -23395,12 +23395,12 @@ var init_protocol = __esm({
|
|
|
23395
23395
|
}
|
|
23396
23396
|
} catch {
|
|
23397
23397
|
}
|
|
23398
|
-
return new Promise((
|
|
23398
|
+
return new Promise((resolve20, reject) => {
|
|
23399
23399
|
if (signal.aborted) {
|
|
23400
23400
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
23401
23401
|
return;
|
|
23402
23402
|
}
|
|
23403
|
-
const timeoutId = setTimeout(
|
|
23403
|
+
const timeoutId = setTimeout(resolve20, interval);
|
|
23404
23404
|
signal.addEventListener("abort", () => {
|
|
23405
23405
|
clearTimeout(timeoutId);
|
|
23406
23406
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -26427,7 +26427,7 @@ var require_compile = __commonJS({
|
|
|
26427
26427
|
const schOrFunc = root.refs[ref];
|
|
26428
26428
|
if (schOrFunc)
|
|
26429
26429
|
return schOrFunc;
|
|
26430
|
-
let _sch =
|
|
26430
|
+
let _sch = resolve20.call(this, root, ref);
|
|
26431
26431
|
if (_sch === void 0) {
|
|
26432
26432
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
26433
26433
|
const { schemaId } = this.opts;
|
|
@@ -26454,7 +26454,7 @@ var require_compile = __commonJS({
|
|
|
26454
26454
|
function sameSchemaEnv(s1, s2) {
|
|
26455
26455
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
26456
26456
|
}
|
|
26457
|
-
function
|
|
26457
|
+
function resolve20(root, ref) {
|
|
26458
26458
|
let sch;
|
|
26459
26459
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
26460
26460
|
ref = sch;
|
|
@@ -27284,7 +27284,7 @@ var require_fast_uri = __commonJS({
|
|
|
27284
27284
|
}
|
|
27285
27285
|
return uri;
|
|
27286
27286
|
}
|
|
27287
|
-
function
|
|
27287
|
+
function resolve20(baseURI, relativeURI, options) {
|
|
27288
27288
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
27289
27289
|
const {
|
|
27290
27290
|
parsed: baseParsed,
|
|
@@ -27653,7 +27653,7 @@ var require_fast_uri = __commonJS({
|
|
|
27653
27653
|
var fastUri = {
|
|
27654
27654
|
SCHEMES,
|
|
27655
27655
|
normalize,
|
|
27656
|
-
resolve:
|
|
27656
|
+
resolve: resolve20,
|
|
27657
27657
|
resolveComponent,
|
|
27658
27658
|
equal,
|
|
27659
27659
|
serialize,
|
|
@@ -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.241.0" : "0.0.0";
|
|
32909
32909
|
clientVersion = {
|
|
32910
32910
|
client_version: external_exports.string().min(1).max(64).optional()
|
|
32911
32911
|
};
|
|
@@ -33425,8 +33425,8 @@ import { connect } from "node:net";
|
|
|
33425
33425
|
async function connectDaemon(opts) {
|
|
33426
33426
|
const sock = connect(opts.path);
|
|
33427
33427
|
if (opts.unref) sock.unref();
|
|
33428
|
-
await new Promise((
|
|
33429
|
-
sock.once("connect",
|
|
33428
|
+
await new Promise((resolve20, reject) => {
|
|
33429
|
+
sock.once("connect", resolve20);
|
|
33430
33430
|
sock.once("error", reject);
|
|
33431
33431
|
});
|
|
33432
33432
|
const decoder = new LineDecoder();
|
|
@@ -33493,8 +33493,8 @@ async function connectDaemon(opts) {
|
|
|
33493
33493
|
sock.on("error", (e) => failAll(e));
|
|
33494
33494
|
sock.on("close", () => failAll(new Error("daemon connection closed")));
|
|
33495
33495
|
let timer;
|
|
33496
|
-
const welcomeRaw = await new Promise((
|
|
33497
|
-
waiters.push({ resolve:
|
|
33496
|
+
const welcomeRaw = await new Promise((resolve20, reject) => {
|
|
33497
|
+
waiters.push({ resolve: resolve20, reject });
|
|
33498
33498
|
timer = setTimeout(() => {
|
|
33499
33499
|
reject(new Error("daemon did not answer hello"));
|
|
33500
33500
|
sock.destroy();
|
|
@@ -33516,7 +33516,7 @@ async function connectDaemon(opts) {
|
|
|
33516
33516
|
if (state === "closed")
|
|
33517
33517
|
return Promise.reject(new Error("daemon connection closed"));
|
|
33518
33518
|
const id = partial2.id ?? String(++seq2);
|
|
33519
|
-
return new Promise((
|
|
33519
|
+
return new Promise((resolve20, reject) => {
|
|
33520
33520
|
const ms = opts.requestTimeoutMs ?? 2e4;
|
|
33521
33521
|
const timer2 = setTimeout(() => {
|
|
33522
33522
|
if (pending.delete(id)) {
|
|
@@ -33533,7 +33533,7 @@ async function connectDaemon(opts) {
|
|
|
33533
33533
|
clearTimeout(timer2);
|
|
33534
33534
|
f(...a);
|
|
33535
33535
|
};
|
|
33536
|
-
pending.set(id, { resolve: done(
|
|
33536
|
+
pending.set(id, { resolve: done(resolve20), reject: done(reject) });
|
|
33537
33537
|
holdWhilePending();
|
|
33538
33538
|
sock.write(`${JSON.stringify({ v: 1, ...partial2, id })}
|
|
33539
33539
|
`);
|
|
@@ -33558,7 +33558,7 @@ async function connectDaemon(opts) {
|
|
|
33558
33558
|
};
|
|
33559
33559
|
}
|
|
33560
33560
|
function daemonStatus(opts) {
|
|
33561
|
-
return new Promise((
|
|
33561
|
+
return new Promise((resolve20, reject) => {
|
|
33562
33562
|
const sock = connect(opts.path);
|
|
33563
33563
|
const decoder = new LineDecoder();
|
|
33564
33564
|
const done = (f) => {
|
|
@@ -33595,7 +33595,7 @@ function daemonStatus(opts) {
|
|
|
33595
33595
|
try {
|
|
33596
33596
|
for (const raw of decoder.push(chunk)) {
|
|
33597
33597
|
const f = DaemonFrame.parse(raw);
|
|
33598
|
-
if (f.type === "status") return done(() =>
|
|
33598
|
+
if (f.type === "status") return done(() => resolve20(f));
|
|
33599
33599
|
if (f.type === "error")
|
|
33600
33600
|
return done(
|
|
33601
33601
|
() => reject(
|
|
@@ -33614,7 +33614,7 @@ function daemonStatus(opts) {
|
|
|
33614
33614
|
});
|
|
33615
33615
|
}
|
|
33616
33616
|
function daemonLinkProof(opts) {
|
|
33617
|
-
return new Promise((
|
|
33617
|
+
return new Promise((resolve20, reject) => {
|
|
33618
33618
|
const sock = connect(opts.path);
|
|
33619
33619
|
const decoder = new LineDecoder();
|
|
33620
33620
|
const done = (f) => {
|
|
@@ -33642,7 +33642,7 @@ function daemonLinkProof(opts) {
|
|
|
33642
33642
|
try {
|
|
33643
33643
|
for (const raw of decoder.push(chunk)) {
|
|
33644
33644
|
const f = DaemonFrame.parse(raw);
|
|
33645
|
-
if (f.type === "link_proofed") return done(() =>
|
|
33645
|
+
if (f.type === "link_proofed") return done(() => resolve20(f.bound));
|
|
33646
33646
|
if (f.type === "error")
|
|
33647
33647
|
return done(() => reject(new Error(f.message)));
|
|
33648
33648
|
}
|
|
@@ -34034,13 +34034,13 @@ async function clearStale(path) {
|
|
|
34034
34034
|
code: "ENOTSOCK"
|
|
34035
34035
|
});
|
|
34036
34036
|
}
|
|
34037
|
-
const live = await new Promise((
|
|
34037
|
+
const live = await new Promise((resolve20) => {
|
|
34038
34038
|
const probe2 = connect2(path);
|
|
34039
34039
|
probe2.once("connect", () => {
|
|
34040
34040
|
probe2.destroy();
|
|
34041
|
-
|
|
34041
|
+
resolve20(true);
|
|
34042
34042
|
});
|
|
34043
|
-
probe2.once("error", () =>
|
|
34043
|
+
probe2.once("error", () => resolve20(false));
|
|
34044
34044
|
});
|
|
34045
34045
|
if (live) {
|
|
34046
34046
|
throw Object.assign(new Error(`daemon already listening on ${path}`), {
|
|
@@ -34060,16 +34060,16 @@ async function serveDaemon(opts) {
|
|
|
34060
34060
|
sock.once("close", () => sockets.delete(sock));
|
|
34061
34061
|
handle(sock, opts);
|
|
34062
34062
|
});
|
|
34063
|
-
await new Promise((
|
|
34063
|
+
await new Promise((resolve20, reject) => {
|
|
34064
34064
|
server4.once("error", reject);
|
|
34065
|
-
server4.listen(opts.path, () =>
|
|
34065
|
+
server4.listen(opts.path, () => resolve20());
|
|
34066
34066
|
});
|
|
34067
34067
|
chmodSync(opts.path, 384);
|
|
34068
34068
|
const st = statSync(opts.path);
|
|
34069
34069
|
const mode = st.mode & 511;
|
|
34070
34070
|
return {
|
|
34071
34071
|
mode,
|
|
34072
|
-
close: () => new Promise((
|
|
34072
|
+
close: () => new Promise((resolve20) => {
|
|
34073
34073
|
for (const s of sockets) s.destroy();
|
|
34074
34074
|
let parked;
|
|
34075
34075
|
try {
|
|
@@ -34087,7 +34087,7 @@ async function serveDaemon(opts) {
|
|
|
34087
34087
|
} catch {
|
|
34088
34088
|
}
|
|
34089
34089
|
}
|
|
34090
|
-
|
|
34090
|
+
resolve20();
|
|
34091
34091
|
});
|
|
34092
34092
|
})
|
|
34093
34093
|
};
|
|
@@ -35136,7 +35136,7 @@ ${neutralize(a.text)}
|
|
|
35136
35136
|
};
|
|
35137
35137
|
}
|
|
35138
35138
|
function inject(a) {
|
|
35139
|
-
return new Promise((
|
|
35139
|
+
return new Promise((resolve20, reject) => {
|
|
35140
35140
|
const sock = connect3(a.socketPath);
|
|
35141
35141
|
let connected = false;
|
|
35142
35142
|
const fail3 = (e) => {
|
|
@@ -35160,7 +35160,7 @@ function inject(a) {
|
|
|
35160
35160
|
sock.once("finish", () => {
|
|
35161
35161
|
clearTimeout(timer);
|
|
35162
35162
|
sock.destroy();
|
|
35163
|
-
|
|
35163
|
+
resolve20();
|
|
35164
35164
|
});
|
|
35165
35165
|
sock.end(`${JSON.stringify(frameOf(a))}
|
|
35166
35166
|
`);
|
|
@@ -44265,12 +44265,12 @@ var init_stdio2 = __esm({
|
|
|
44265
44265
|
this.onclose?.();
|
|
44266
44266
|
}
|
|
44267
44267
|
send(message) {
|
|
44268
|
-
return new Promise((
|
|
44268
|
+
return new Promise((resolve20) => {
|
|
44269
44269
|
const json4 = serializeMessage(message);
|
|
44270
44270
|
if (this._stdout.write(json4)) {
|
|
44271
|
-
|
|
44271
|
+
resolve20();
|
|
44272
44272
|
} else {
|
|
44273
|
-
this._stdout.once("drain",
|
|
44273
|
+
this._stdout.once("drain", resolve20);
|
|
44274
44274
|
}
|
|
44275
44275
|
});
|
|
44276
44276
|
}
|
|
@@ -44529,13 +44529,13 @@ __export(codex_proxy_main_exports, {
|
|
|
44529
44529
|
readTokenFile: () => readTokenFile,
|
|
44530
44530
|
startCodexProxy: () => startCodexProxy
|
|
44531
44531
|
});
|
|
44532
|
-
import { readFileSync as
|
|
44532
|
+
import { readFileSync as readFileSync45 } from "node:fs";
|
|
44533
44533
|
import { homedir as homedir5 } from "node:os";
|
|
44534
44534
|
function readTokenFile(path) {
|
|
44535
44535
|
if (!path) return void 0;
|
|
44536
44536
|
try {
|
|
44537
44537
|
const p = path.startsWith("~/") ? `${homedir5()}${path.slice(1)}` : path;
|
|
44538
|
-
return
|
|
44538
|
+
return readFileSync45(p, "utf8").trim() || void 0;
|
|
44539
44539
|
} catch {
|
|
44540
44540
|
return void 0;
|
|
44541
44541
|
}
|
|
@@ -44585,13 +44585,13 @@ __export(proxy_main_exports, {
|
|
|
44585
44585
|
readTokenFile: () => readTokenFile2,
|
|
44586
44586
|
startProxy: () => startProxy
|
|
44587
44587
|
});
|
|
44588
|
-
import { readFileSync as
|
|
44588
|
+
import { readFileSync as readFileSync46 } from "node:fs";
|
|
44589
44589
|
import { homedir as homedir6 } from "node:os";
|
|
44590
44590
|
function readTokenFile2(path) {
|
|
44591
44591
|
if (!path) return void 0;
|
|
44592
44592
|
try {
|
|
44593
44593
|
const p = path.startsWith("~/") ? `${homedir6()}${path.slice(1)}` : path;
|
|
44594
|
-
return
|
|
44594
|
+
return readFileSync46(p, "utf8").trim() || void 0;
|
|
44595
44595
|
} catch {
|
|
44596
44596
|
return void 0;
|
|
44597
44597
|
}
|
|
@@ -44679,7 +44679,7 @@ var harnessSkills = {
|
|
|
44679
44679
|
var harnessNames = Object.keys(harnessSkills);
|
|
44680
44680
|
|
|
44681
44681
|
// src/main.ts
|
|
44682
|
-
import { resolve as
|
|
44682
|
+
import { resolve as resolve19 } from "node:path";
|
|
44683
44683
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
44684
44684
|
|
|
44685
44685
|
// ../bus-daemon/src/index.ts
|
|
@@ -50216,12 +50216,12 @@ var Receipts = class {
|
|
|
50216
50216
|
this.#waiting.delete(msgId);
|
|
50217
50217
|
return Promise.resolve(w.final);
|
|
50218
50218
|
}
|
|
50219
|
-
return new Promise((
|
|
50219
|
+
return new Promise((resolve20) => {
|
|
50220
50220
|
const cancel = this.#after(ms, () => w.done?.(void 0));
|
|
50221
50221
|
w.done = (f) => {
|
|
50222
50222
|
cancel();
|
|
50223
50223
|
this.#waiting.delete(msgId);
|
|
50224
|
-
|
|
50224
|
+
resolve20(f);
|
|
50225
50225
|
};
|
|
50226
50226
|
});
|
|
50227
50227
|
}
|
|
@@ -50561,22 +50561,22 @@ var ClaudeTransport = class {
|
|
|
50561
50561
|
return { ok: false, reason: "closed", cause: st };
|
|
50562
50562
|
}
|
|
50563
50563
|
#waitFor(msgId, ms) {
|
|
50564
|
-
return new Promise((
|
|
50564
|
+
return new Promise((resolve20) => {
|
|
50565
50565
|
const buffered = this.#buffered.get(msgId);
|
|
50566
50566
|
if (buffered !== void 0) {
|
|
50567
50567
|
this.#buffered.delete(msgId);
|
|
50568
|
-
|
|
50568
|
+
resolve20(buffered);
|
|
50569
50569
|
return;
|
|
50570
50570
|
}
|
|
50571
50571
|
const timer = setTimeout(() => {
|
|
50572
50572
|
this.#waiting.delete(msgId);
|
|
50573
|
-
|
|
50573
|
+
resolve20(void 0);
|
|
50574
50574
|
}, ms);
|
|
50575
50575
|
timer.unref();
|
|
50576
50576
|
this.#waiting.set(msgId, (s) => {
|
|
50577
50577
|
clearTimeout(timer);
|
|
50578
50578
|
this.#waiting.delete(msgId);
|
|
50579
|
-
|
|
50579
|
+
resolve20(s);
|
|
50580
50580
|
});
|
|
50581
50581
|
});
|
|
50582
50582
|
}
|
|
@@ -50726,9 +50726,9 @@ var ClaudeTransport = class {
|
|
|
50726
50726
|
);
|
|
50727
50727
|
})
|
|
50728
50728
|
};
|
|
50729
|
-
await new Promise((
|
|
50729
|
+
await new Promise((resolve20, reject) => {
|
|
50730
50730
|
sink.server.once("error", reject);
|
|
50731
|
-
sink.server.listen(path, () =>
|
|
50731
|
+
sink.server.listen(path, () => resolve20());
|
|
50732
50732
|
});
|
|
50733
50733
|
chmodSync11(path, 384);
|
|
50734
50734
|
return sink;
|
|
@@ -50922,7 +50922,7 @@ async function steerCodex(home2, thread, text3) {
|
|
|
50922
50922
|
} catch {
|
|
50923
50923
|
return "fallback";
|
|
50924
50924
|
}
|
|
50925
|
-
return new Promise((
|
|
50925
|
+
return new Promise((resolve20) => {
|
|
50926
50926
|
const ws = new wrapper_default("ws://localhost/", {
|
|
50927
50927
|
createConnection: () => connect4(path),
|
|
50928
50928
|
maxPayload: 128 * 1024,
|
|
@@ -50932,7 +50932,7 @@ async function steerCodex(home2, thread, text3) {
|
|
|
50932
50932
|
let turn;
|
|
50933
50933
|
const finish = (result) => {
|
|
50934
50934
|
clearTimeout(timer);
|
|
50935
|
-
|
|
50935
|
+
resolve20(result);
|
|
50936
50936
|
ws.terminate();
|
|
50937
50937
|
};
|
|
50938
50938
|
const disconnected = () => finish(step2 === 3 ? "uncertain" : "fallback");
|
|
@@ -51097,7 +51097,7 @@ function splitArgv0(args) {
|
|
|
51097
51097
|
});
|
|
51098
51098
|
return words(args.slice(real3 ?? ends[0]));
|
|
51099
51099
|
}
|
|
51100
|
-
var execText = (cmd, args) => new Promise((
|
|
51100
|
+
var execText = (cmd, args) => new Promise((resolve20) => {
|
|
51101
51101
|
execFile(
|
|
51102
51102
|
cmd,
|
|
51103
51103
|
args,
|
|
@@ -51106,7 +51106,7 @@ var execText = (cmd, args) => new Promise((resolve19) => {
|
|
|
51106
51106
|
timeout: 2e3,
|
|
51107
51107
|
env: { ...process.env, LC_ALL: "C" }
|
|
51108
51108
|
},
|
|
51109
|
-
(err, stdout) =>
|
|
51109
|
+
(err, stdout) => resolve20(err ? void 0 : stdout)
|
|
51110
51110
|
);
|
|
51111
51111
|
});
|
|
51112
51112
|
async function processArgs(pid) {
|
|
@@ -51129,17 +51129,17 @@ async function processArgs(pid) {
|
|
|
51129
51129
|
return args ? splitArgv0(args) : void 0;
|
|
51130
51130
|
}
|
|
51131
51131
|
var START_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOEXEC"]);
|
|
51132
|
-
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((
|
|
51132
|
+
var execCodex = (timeoutMs = CODEX_QUEUE_TIMEOUT_MS) => (bin, args, env2) => new Promise((resolve20, reject) => {
|
|
51133
51133
|
execFile(
|
|
51134
51134
|
bin,
|
|
51135
51135
|
args,
|
|
51136
51136
|
{ timeout: timeoutMs, maxBuffer: 64 * 1024, env: env2 },
|
|
51137
51137
|
(err, _stdout, stderr) => {
|
|
51138
|
-
if (!err) return
|
|
51138
|
+
if (!err) return resolve20({ code: 0, stderr });
|
|
51139
51139
|
const e = err;
|
|
51140
51140
|
if (typeof e.code === "string" && START_ERRORS.has(e.code))
|
|
51141
51141
|
return reject(err);
|
|
51142
|
-
|
|
51142
|
+
resolve20({
|
|
51143
51143
|
// A maxBuffer kill is SIGTERM too, but carries its own string code.
|
|
51144
51144
|
code: e.killed && e.signal === "SIGTERM" && typeof e.code !== "string" ? null : typeof e.code === "number" ? e.code : -1,
|
|
51145
51145
|
stderr: String(stderr ?? "")
|
|
@@ -51355,17 +51355,17 @@ var CODEX_WAKE_TEXT = `Open Artifacts bus: messages are waiting for this thread.
|
|
|
51355
51355
|
init_src2();
|
|
51356
51356
|
import { execFile as execFile2 } from "node:child_process";
|
|
51357
51357
|
var START_ERRORS2 = /* @__PURE__ */ new Set(["ENOENT", "EACCES"]);
|
|
51358
|
-
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((
|
|
51358
|
+
var execSpawn = (timeoutMs, maxBuffer = 1024 * 1024) => (cmd, args) => new Promise((resolve20, reject) => {
|
|
51359
51359
|
execFile2(
|
|
51360
51360
|
cmd,
|
|
51361
51361
|
args,
|
|
51362
51362
|
{ timeout: timeoutMs, maxBuffer },
|
|
51363
51363
|
(err, stdout, stderr) => {
|
|
51364
|
-
if (!err) return
|
|
51364
|
+
if (!err) return resolve20({ code: 0, stdout, stderr });
|
|
51365
51365
|
const e = err;
|
|
51366
51366
|
if (typeof e.code === "string" && START_ERRORS2.has(e.code))
|
|
51367
51367
|
return reject(err);
|
|
51368
|
-
|
|
51368
|
+
resolve20({
|
|
51369
51369
|
code: e.killed || typeof e.code !== "number" ? null : e.code,
|
|
51370
51370
|
stdout,
|
|
51371
51371
|
stderr
|
|
@@ -51483,18 +51483,18 @@ var PiTransport = class {
|
|
|
51483
51483
|
});
|
|
51484
51484
|
if (!pushed) return { ok: false, reason: "closed" };
|
|
51485
51485
|
this.#forget(mail.msg_id);
|
|
51486
|
-
return new Promise((
|
|
51486
|
+
return new Promise((resolve20) => {
|
|
51487
51487
|
const timer = setTimeout(() => {
|
|
51488
51488
|
this.#waiting.delete(mail.msg_id);
|
|
51489
51489
|
this.#remember(mail.msg_id, agent.ref);
|
|
51490
|
-
|
|
51490
|
+
resolve20({ ok: false, reason: "timeout" });
|
|
51491
51491
|
}, this.opts.ackTimeoutMs ?? 1e4);
|
|
51492
51492
|
timer.unref();
|
|
51493
51493
|
this.#waiting.set(mail.msg_id, {
|
|
51494
51494
|
ref: agent.ref,
|
|
51495
51495
|
done: (o) => {
|
|
51496
51496
|
clearTimeout(timer);
|
|
51497
|
-
|
|
51497
|
+
resolve20(o);
|
|
51498
51498
|
}
|
|
51499
51499
|
});
|
|
51500
51500
|
});
|
|
@@ -55538,30 +55538,30 @@ async function runDaemon(deps2 = {}) {
|
|
|
55538
55538
|
for (const lane of lanes.all()) lane.hub = buildHub(lane);
|
|
55539
55539
|
const hub = main2.hub;
|
|
55540
55540
|
const hubRoster = (ref) => new Promise(
|
|
55541
|
-
(
|
|
55541
|
+
(resolve20) => {
|
|
55542
55542
|
const id = pending.open(
|
|
55543
55543
|
"status",
|
|
55544
|
-
(f) =>
|
|
55544
|
+
(f) => resolve20(f.type === "roster" ? f.agents : void 0)
|
|
55545
55545
|
);
|
|
55546
55546
|
const timer = setTimeout(() => {
|
|
55547
55547
|
pending.cancel(id);
|
|
55548
55548
|
cancelOn(id);
|
|
55549
|
-
|
|
55549
|
+
resolve20(void 0);
|
|
55550
55550
|
}, deps2.statusRosterMs ?? 1500);
|
|
55551
55551
|
timer.unref();
|
|
55552
55552
|
if (!hubSend({ v: 1, id, type: "list", from_ref: ref })) {
|
|
55553
55553
|
clearTimeout(timer);
|
|
55554
55554
|
pending.cancel(id);
|
|
55555
|
-
|
|
55555
|
+
resolve20(void 0);
|
|
55556
55556
|
}
|
|
55557
55557
|
}
|
|
55558
55558
|
);
|
|
55559
|
-
const hubWaitingCounts = (refs) => new Promise((
|
|
55559
|
+
const hubWaitingCounts = (refs) => new Promise((resolve20) => {
|
|
55560
55560
|
const id = frameId();
|
|
55561
55561
|
const done = (c) => {
|
|
55562
55562
|
clearTimeout(timer);
|
|
55563
55563
|
waitingAsks.delete(id);
|
|
55564
|
-
|
|
55564
|
+
resolve20(c);
|
|
55565
55565
|
};
|
|
55566
55566
|
const timer = setTimeout(() => {
|
|
55567
55567
|
main2.hub.cancel(id);
|
|
@@ -57754,19 +57754,19 @@ init_src2();
|
|
|
57754
57754
|
import { execFile as execFile3, spawn } from "node:child_process";
|
|
57755
57755
|
import { promisify } from "node:util";
|
|
57756
57756
|
var browserCommand = (platform, url2) => platform === "darwin" ? { cmd: "open", args: [url2] } : platform === "win32" ? { cmd: "rundll32", args: ["url.dll,FileProtocolHandler", url2] } : { cmd: "xdg-open", args: [url2] };
|
|
57757
|
-
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((
|
|
57757
|
+
var openBrowser = (url2, launcher = browserCommand(process.platform, url2)) => new Promise((resolve20) => {
|
|
57758
57758
|
try {
|
|
57759
57759
|
const child = spawn(launcher.cmd, launcher.args, {
|
|
57760
57760
|
stdio: "ignore",
|
|
57761
57761
|
detached: true
|
|
57762
57762
|
});
|
|
57763
|
-
child.once("error", () =>
|
|
57763
|
+
child.once("error", () => resolve20(false));
|
|
57764
57764
|
child.once("spawn", () => {
|
|
57765
57765
|
child.unref();
|
|
57766
|
-
|
|
57766
|
+
resolve20(true);
|
|
57767
57767
|
});
|
|
57768
57768
|
} catch {
|
|
57769
|
-
|
|
57769
|
+
resolve20(false);
|
|
57770
57770
|
}
|
|
57771
57771
|
});
|
|
57772
57772
|
var EXEC_TIMEOUT_MS = 1e4;
|
|
@@ -59599,7 +59599,7 @@ var noService = {
|
|
|
59599
59599
|
remove: async () => ({}),
|
|
59600
59600
|
cli: () => ["oa-bus"]
|
|
59601
59601
|
};
|
|
59602
|
-
var VERSION = true ? "0.
|
|
59602
|
+
var VERSION = true ? "0.241.0" : JSON.parse(
|
|
59603
59603
|
readFileSync23(new URL("../package.json", import.meta.url), "utf8")
|
|
59604
59604
|
).version;
|
|
59605
59605
|
var which = (cmd) => {
|
|
@@ -59689,7 +59689,7 @@ function realCtx(noColor) {
|
|
|
59689
59689
|
});
|
|
59690
59690
|
try {
|
|
59691
59691
|
return await new Promise(
|
|
59692
|
-
(
|
|
59692
|
+
(resolve20) => rl.question(question, resolve20)
|
|
59693
59693
|
);
|
|
59694
59694
|
} finally {
|
|
59695
59695
|
rl.close();
|
|
@@ -62960,7 +62960,9 @@ var record6 = (busHome2) => {
|
|
|
62960
62960
|
optedOut: h.optedOut === true,
|
|
62961
62961
|
at: h.at,
|
|
62962
62962
|
files: h.files ?? {},
|
|
62963
|
-
pluginDirs: pluginDirsOf(h.pluginDirs)
|
|
62963
|
+
pluginDirs: pluginDirsOf(h.pluginDirs),
|
|
62964
|
+
// #2966: the per-project blocks, and the exclude lines added for them.
|
|
62965
|
+
project: projectOf(h.project)
|
|
62964
62966
|
};
|
|
62965
62967
|
};
|
|
62966
62968
|
var pluginDirsOf = (v) => {
|
|
@@ -62978,6 +62980,152 @@ var saveRecord = (busHome2, patch) => {
|
|
|
62978
62980
|
habits: { ...cur, ...patch }
|
|
62979
62981
|
});
|
|
62980
62982
|
};
|
|
62983
|
+
var PROJECT_HABITS_FILE = {
|
|
62984
|
+
claude: "CLAUDE.local.md",
|
|
62985
|
+
codex: "AGENTS.md",
|
|
62986
|
+
pi: "AGENTS.md",
|
|
62987
|
+
opencode: "AGENTS.md"
|
|
62988
|
+
};
|
|
62989
|
+
var projectHabitsTarget = (cwd, h) => join35(cwd, PROJECT_HABITS_FILE[h]);
|
|
62990
|
+
var gitignoreLiteral = (path) => (
|
|
62991
|
+
// Spaces are escaped as well: git ignores a trailing one unless it is.
|
|
62992
|
+
path.replace(/[\\*?[\]! ]/g, (c) => `\\${c}`)
|
|
62993
|
+
);
|
|
62994
|
+
var projectOf = (v) => {
|
|
62995
|
+
const p = typeof v === "object" && v !== null ? v : {};
|
|
62996
|
+
const exclude = [];
|
|
62997
|
+
if (Array.isArray(p.exclude)) {
|
|
62998
|
+
for (const e of p.exclude)
|
|
62999
|
+
if (typeof e === "object" && e !== null && typeof e.file === "string" && typeof e.line === "string")
|
|
63000
|
+
exclude.push({
|
|
63001
|
+
file: e.file,
|
|
63002
|
+
line: e.line,
|
|
63003
|
+
...typeof e.for === "string" ? { for: e.for } : {}
|
|
63004
|
+
});
|
|
63005
|
+
}
|
|
63006
|
+
return { files: p.files ?? {}, exclude };
|
|
63007
|
+
};
|
|
63008
|
+
function projectHabitsFileState(cwd, h) {
|
|
63009
|
+
const path = projectHabitsTarget(cwd, h);
|
|
63010
|
+
try {
|
|
63011
|
+
if (brokenLink(path)) return { state: "broken", path };
|
|
63012
|
+
if (!existsSync13(path)) return { state: "absent", path };
|
|
63013
|
+
return { ...blockState(readFileSync29(path, "utf8")), path };
|
|
63014
|
+
} catch {
|
|
63015
|
+
return { state: "broken", path };
|
|
63016
|
+
}
|
|
63017
|
+
}
|
|
63018
|
+
function writeProjectHabits(deps2, harnesses, io = {}) {
|
|
63019
|
+
const files2 = [];
|
|
63020
|
+
const notes = [];
|
|
63021
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
63022
|
+
const cur = record6(deps2.busHome).project;
|
|
63023
|
+
const files_ = { ...cur.files };
|
|
63024
|
+
const exclude = [...cur.exclude];
|
|
63025
|
+
for (const h of harnesses) {
|
|
63026
|
+
const name = PROJECT_HABITS_FILE[h];
|
|
63027
|
+
const path = projectHabitsTarget(deps2.cwd, h);
|
|
63028
|
+
if (seen2.has(path)) continue;
|
|
63029
|
+
seen2.add(path);
|
|
63030
|
+
const rel = io.rel?.(name) ?? name;
|
|
63031
|
+
if (io.tracked?.(rel) === true) {
|
|
63032
|
+
notes.push(
|
|
63033
|
+
`Left ${path} alone: git tracks it, so a habits block there would be committed. Habits stay off for ${h} in this project.`
|
|
63034
|
+
);
|
|
63035
|
+
continue;
|
|
63036
|
+
}
|
|
63037
|
+
try {
|
|
63038
|
+
if (brokenLink(path)) {
|
|
63039
|
+
notes.push(`Left ${path} alone: it is a broken symlink.`);
|
|
63040
|
+
continue;
|
|
63041
|
+
}
|
|
63042
|
+
if (isLink(path)) {
|
|
63043
|
+
notes.push(
|
|
63044
|
+
`Left ${path} alone: it is a symlink. Write that file yourself, or run the install without the link.`
|
|
63045
|
+
);
|
|
63046
|
+
continue;
|
|
63047
|
+
}
|
|
63048
|
+
const exists3 = existsSync13(path);
|
|
63049
|
+
const before = exists3 ? readFileSync29(path, "utf8") : "";
|
|
63050
|
+
const state = blockState(before).state;
|
|
63051
|
+
if (exists3 && state === "absent") {
|
|
63052
|
+
notes.push(
|
|
63053
|
+
`Left ${path} alone: it was already here and it is not a bus file. Add the block yourself if you want the habits in this project.`
|
|
63054
|
+
);
|
|
63055
|
+
continue;
|
|
63056
|
+
}
|
|
63057
|
+
const after = withHabits(before, habitsBlock());
|
|
63058
|
+
if (after !== before) writeAtomic(path, after);
|
|
63059
|
+
if (state === "absent")
|
|
63060
|
+
files_[path] = { added: separatorFor(before), created: true };
|
|
63061
|
+
files2.push(path);
|
|
63062
|
+
if (!exists3 && io.excludeFile !== void 0 && io.exclude !== void 0) {
|
|
63063
|
+
const line = `/${gitignoreLiteral(rel)}`;
|
|
63064
|
+
if (io.exclude(line))
|
|
63065
|
+
exclude.push({ file: io.excludeFile, line, for: path });
|
|
63066
|
+
}
|
|
63067
|
+
} catch (e) {
|
|
63068
|
+
notes.push(
|
|
63069
|
+
e instanceof Error && e.message === "unterminated" ? `Left ${path} alone: its Open Artifacts habits block has no END marker. Fix or remove the block, then rerun.` : `Could not write ${path}: ${reason(e)}`
|
|
63070
|
+
);
|
|
63071
|
+
}
|
|
63072
|
+
}
|
|
63073
|
+
saveRecord(deps2.busHome, { project: { files: files_, exclude } });
|
|
63074
|
+
return { files: files2, notes };
|
|
63075
|
+
}
|
|
63076
|
+
function removeProjectHabits(deps2, only) {
|
|
63077
|
+
const files2 = [];
|
|
63078
|
+
const notes = [];
|
|
63079
|
+
const cur = record6(deps2.busHome).project;
|
|
63080
|
+
const kept = { ...cur.files };
|
|
63081
|
+
const exclude = [...cur.exclude];
|
|
63082
|
+
const cleaned = /* @__PURE__ */ new Set();
|
|
63083
|
+
for (const [path, rec] of Object.entries(cur.files)) {
|
|
63084
|
+
if (only !== void 0 && !only(path)) continue;
|
|
63085
|
+
try {
|
|
63086
|
+
if (brokenLink(path) || !existsSync13(path) || isLink(path)) {
|
|
63087
|
+
delete kept[path];
|
|
63088
|
+
cleaned.add(path);
|
|
63089
|
+
continue;
|
|
63090
|
+
}
|
|
63091
|
+
const before = readFileSync29(path, "utf8");
|
|
63092
|
+
if (blockState(before).state === "absent") {
|
|
63093
|
+
delete kept[path];
|
|
63094
|
+
cleaned.add(path);
|
|
63095
|
+
continue;
|
|
63096
|
+
}
|
|
63097
|
+
const after = withHabits(before, null, rec?.added);
|
|
63098
|
+
if (rec?.created && after.trim() === "") rmSync17(path, { force: true });
|
|
63099
|
+
else writeAtomic(path, after);
|
|
63100
|
+
delete kept[path];
|
|
63101
|
+
cleaned.add(path);
|
|
63102
|
+
files2.push(path);
|
|
63103
|
+
} catch (e) {
|
|
63104
|
+
notes.push(
|
|
63105
|
+
e instanceof Error && e.message === "unterminated" ? `Left ${path} alone: its Open Artifacts habits block has no END marker. Fix or remove the block.` : `Could not update ${path}: ${reason(e)}`
|
|
63106
|
+
);
|
|
63107
|
+
}
|
|
63108
|
+
}
|
|
63109
|
+
for (const e of [...exclude]) {
|
|
63110
|
+
if (only !== void 0 && (e.for === void 0 || !only(e.for))) continue;
|
|
63111
|
+
if (e.for !== void 0 && !cleaned.has(e.for)) continue;
|
|
63112
|
+
try {
|
|
63113
|
+
const text3 = readFileSync29(e.file, "utf8");
|
|
63114
|
+
const lines = text3.split("\n");
|
|
63115
|
+
if (!lines.includes(e.line)) {
|
|
63116
|
+
exclude.splice(exclude.indexOf(e), 1);
|
|
63117
|
+
continue;
|
|
63118
|
+
}
|
|
63119
|
+
writeAtomic(e.file, lines.filter((l) => l !== e.line).join("\n"));
|
|
63120
|
+
exclude.splice(exclude.indexOf(e), 1);
|
|
63121
|
+
} catch {
|
|
63122
|
+
exclude.splice(exclude.indexOf(e), 1);
|
|
63123
|
+
}
|
|
63124
|
+
}
|
|
63125
|
+
if (deps2.busHome && existsSync13(join35(deps2.busHome, "install.json")))
|
|
63126
|
+
saveRecord(deps2.busHome, { project: { files: kept, exclude } });
|
|
63127
|
+
return { files: files2, notes };
|
|
63128
|
+
}
|
|
62981
63129
|
function habitsFileState(deps2, h) {
|
|
62982
63130
|
const path = habitsTarget(deps2, h);
|
|
62983
63131
|
try {
|
|
@@ -63271,11 +63419,24 @@ var probe = (path) => {
|
|
|
63271
63419
|
var habitsOptedOut = (busHome2) => record6(busHome2).optedOut;
|
|
63272
63420
|
var setHabitsOptOut = (busHome2, optedOut, at) => saveRecord(busHome2, { optedOut, at });
|
|
63273
63421
|
var OMP_NOTE = "omp: not supported yet";
|
|
63422
|
+
var HABITS_GLOBAL_UPDATE_TEXT = "The habits for every project on this machine changed in this release, in {files}:";
|
|
63423
|
+
var HABITS_QUESTION_TEXT = "The bus would add {count} habits to this project only, in {files}:";
|
|
63274
63424
|
var habitsQuestion = (shownFiles, bus = BUS_CMD) => {
|
|
63275
|
-
const yes2 = `${bus} install --habits`;
|
|
63276
|
-
const no2 = `${bus} install --no-habits`;
|
|
63277
|
-
const text3 =
|
|
63278
|
-
|
|
63425
|
+
const yes2 = `${bus} install --habits-project`;
|
|
63426
|
+
const no2 = `${bus} install --no-habits-project`;
|
|
63427
|
+
const text3 = HABITS_QUESTION_TEXT.replace(
|
|
63428
|
+
"{count}",
|
|
63429
|
+
String(HABITS_LINES.length)
|
|
63430
|
+
).replace("{files}", shownFiles.join(" and "));
|
|
63431
|
+
return {
|
|
63432
|
+
text: text3,
|
|
63433
|
+
lines: HABITS_LINES.slice(),
|
|
63434
|
+
note: OMP_NOTE,
|
|
63435
|
+
yes: yes2,
|
|
63436
|
+
no: no2,
|
|
63437
|
+
global: `${bus} install --habits`,
|
|
63438
|
+
never: `${bus} install --no-habits`
|
|
63439
|
+
};
|
|
63279
63440
|
};
|
|
63280
63441
|
var habitsQuestionLines = (q) => [
|
|
63281
63442
|
"Installed. One question for your user before you finish:",
|
|
@@ -63285,7 +63446,9 @@ var habitsQuestionLines = (q) => [
|
|
|
63285
63446
|
...q.lines.map((l) => ` ${l}`),
|
|
63286
63447
|
` ${q.note}`,
|
|
63287
63448
|
`Yes: ${q.yes}`,
|
|
63288
|
-
`No: ${q.no}
|
|
63449
|
+
`No: ${q.no}`,
|
|
63450
|
+
...q.global ? [`All projects (invasive): ${q.global}`] : [],
|
|
63451
|
+
...q.never ? [`Never ask again on this machine: ${q.never}`] : []
|
|
63289
63452
|
];
|
|
63290
63453
|
|
|
63291
63454
|
// src/steps/opencode-proof.ts
|
|
@@ -65306,7 +65469,7 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
65306
65469
|
},
|
|
65307
65470
|
(c) => events(PROOF_EVENT, { name: c.entry, kind: c.scope })
|
|
65308
65471
|
);
|
|
65309
|
-
return new Promise((
|
|
65472
|
+
return new Promise((resolve20) => {
|
|
65310
65473
|
let running;
|
|
65311
65474
|
let ended = false;
|
|
65312
65475
|
const end = (code2) => {
|
|
@@ -65314,7 +65477,7 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
65314
65477
|
ended = true;
|
|
65315
65478
|
signals.off("SIGINT", onSignal);
|
|
65316
65479
|
signals.off("SIGTERM", onSignal);
|
|
65317
|
-
void (running?.stop() ?? Promise.resolve()).finally(() =>
|
|
65480
|
+
void (running?.stop() ?? Promise.resolve()).finally(() => resolve20(code2));
|
|
65318
65481
|
};
|
|
65319
65482
|
const onSignal = () => end(0);
|
|
65320
65483
|
signals.once("SIGINT", onSignal);
|
|
@@ -65346,7 +65509,7 @@ async function daemon(ctx, run5 = runDaemon, signals = process) {
|
|
|
65346
65509
|
}
|
|
65347
65510
|
|
|
65348
65511
|
// src/commands/doctor.ts
|
|
65349
|
-
import { readFileSync as
|
|
65512
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
65350
65513
|
import { join as join51 } from "node:path";
|
|
65351
65514
|
|
|
65352
65515
|
// src/steps/claude-plugins.ts
|
|
@@ -66221,7 +66384,8 @@ var sseCheck = (ctx, name) => ({
|
|
|
66221
66384
|
|
|
66222
66385
|
// src/commands/habits.ts
|
|
66223
66386
|
init_src();
|
|
66224
|
-
import {
|
|
66387
|
+
import { mkdirSync as mkdirSync18, readFileSync as readFileSync39, realpathSync as realpathSync16, writeFileSync as writeFileSync21 } from "node:fs";
|
|
66388
|
+
import { dirname as dirname21, join as join47, resolve as resolve15 } from "node:path";
|
|
66225
66389
|
var pluginOn = (p) => `Habits on in the ${p.label} plugin.`;
|
|
66226
66390
|
var pluginOff = (p) => `Habits off in the ${p.label} plugin.`;
|
|
66227
66391
|
var deps = (ctx) => ({
|
|
@@ -66322,6 +66486,210 @@ function disclosure(ctx, pending) {
|
|
|
66322
66486
|
...HABITS_LINES.map((l) => ` ${l}`)
|
|
66323
66487
|
];
|
|
66324
66488
|
}
|
|
66489
|
+
async function isRepoTop(ctx) {
|
|
66490
|
+
if (!ctx.which("git")) return "no";
|
|
66491
|
+
const r = await ctx.exec("git", ["-C", ctx.cwd, "rev-parse", "--show-toplevel"], {
|
|
66492
|
+
timeoutMs: 5e3
|
|
66493
|
+
}).catch(() => void 0);
|
|
66494
|
+
if (r?.code !== 0) return "no";
|
|
66495
|
+
const root = realpathOr(r.stdout.trim());
|
|
66496
|
+
if (root === realpathOr(ctx.userHome)) return "home";
|
|
66497
|
+
return { root };
|
|
66498
|
+
}
|
|
66499
|
+
var readBlocked = (busHome2) => {
|
|
66500
|
+
const raw = readInstallFile(join47(busHome2, "install.json")).habits ?? {};
|
|
66501
|
+
const out = {};
|
|
66502
|
+
if (typeof raw.projectBlocked === "object" && raw.projectBlocked !== null) {
|
|
66503
|
+
for (const [root, list] of Object.entries(
|
|
66504
|
+
raw.projectBlocked
|
|
66505
|
+
))
|
|
66506
|
+
if (Array.isArray(list))
|
|
66507
|
+
out[root] = list.filter((h) => typeof h === "string");
|
|
66508
|
+
}
|
|
66509
|
+
return out;
|
|
66510
|
+
};
|
|
66511
|
+
var saveBlocked = (busHome2, map2) => {
|
|
66512
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66513
|
+
habits: { ...habitsRecord(busHome2), projectBlocked: map2 }
|
|
66514
|
+
});
|
|
66515
|
+
};
|
|
66516
|
+
var habitsRecord = (busHome2) => readInstallFile(join47(busHome2, "install.json")).habits ?? {};
|
|
66517
|
+
var pluginLineSaid = (busHome2) => habitsRecord(busHome2).pluginLineSaid === true;
|
|
66518
|
+
var markPluginLineSaid = (busHome2) => {
|
|
66519
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66520
|
+
habits: { ...habitsRecord(busHome2), pluginLineSaid: true }
|
|
66521
|
+
});
|
|
66522
|
+
};
|
|
66523
|
+
var noteBlocked = (ctx, folder, blocked, json4) => {
|
|
66524
|
+
const said = readBlocked(ctx.home);
|
|
66525
|
+
const fresh = blocked.filter((h) => !(said[folder] ?? []).includes(h));
|
|
66526
|
+
if (fresh.length === 0) return "";
|
|
66527
|
+
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.`;
|
|
66528
|
+
saveBlocked(ctx.home, {
|
|
66529
|
+
...said,
|
|
66530
|
+
[folder]: [...said[folder] ?? [], ...fresh]
|
|
66531
|
+
});
|
|
66532
|
+
if (!json4) say(ctx, why2);
|
|
66533
|
+
return why2;
|
|
66534
|
+
};
|
|
66535
|
+
var readDeclined = (busHome2) => {
|
|
66536
|
+
const raw = habitsRecord(busHome2).projectDeclined;
|
|
66537
|
+
const out = {};
|
|
66538
|
+
if (typeof raw === "object" && raw !== null) {
|
|
66539
|
+
for (const [root, v] of Object.entries(raw))
|
|
66540
|
+
if (v === true) out[root] = true;
|
|
66541
|
+
}
|
|
66542
|
+
return out;
|
|
66543
|
+
};
|
|
66544
|
+
var setDeclined = (busHome2, root, off) => {
|
|
66545
|
+
const cur = readDeclined(busHome2);
|
|
66546
|
+
if (off) cur[root] = true;
|
|
66547
|
+
else delete cur[root];
|
|
66548
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66549
|
+
habits: { ...habitsRecord(busHome2), projectDeclined: cur }
|
|
66550
|
+
});
|
|
66551
|
+
};
|
|
66552
|
+
var moveOffered = (busHome2) => habitsRecord(busHome2).projectMoveOffered === true;
|
|
66553
|
+
var markMoveOffered = (busHome2) => {
|
|
66554
|
+
updateInstallFile(join47(busHome2, "install.json"), {
|
|
66555
|
+
habits: { ...habitsRecord(busHome2), projectMoveOffered: true }
|
|
66556
|
+
});
|
|
66557
|
+
};
|
|
66558
|
+
var realpathOr = (p) => {
|
|
66559
|
+
try {
|
|
66560
|
+
return realpathSync16(p);
|
|
66561
|
+
} catch {
|
|
66562
|
+
return resolve15(p);
|
|
66563
|
+
}
|
|
66564
|
+
};
|
|
66565
|
+
async function projectIo(ctx) {
|
|
66566
|
+
if (!ctx.which("git")) return {};
|
|
66567
|
+
const git3 = (args) => ctx.exec("git", ["-C", ctx.cwd, ...args], { timeoutMs: 5e3 });
|
|
66568
|
+
const inside2 = await git3(["rev-parse", "--is-inside-work-tree"]).catch(
|
|
66569
|
+
() => void 0
|
|
66570
|
+
);
|
|
66571
|
+
if (inside2?.code !== 0 || inside2.stdout.trim() !== "true") return {};
|
|
66572
|
+
const prefixOut = await git3(["rev-parse", "--show-prefix"]).catch(
|
|
66573
|
+
() => void 0
|
|
66574
|
+
);
|
|
66575
|
+
if (prefixOut?.code !== 0) return {};
|
|
66576
|
+
const prefix2 = prefixOut.stdout.trim();
|
|
66577
|
+
const pathOut = await git3(["rev-parse", "--git-path", "info/exclude"]).catch(
|
|
66578
|
+
() => void 0
|
|
66579
|
+
);
|
|
66580
|
+
if (pathOut?.code !== 0) return {};
|
|
66581
|
+
const raw = pathOut.stdout.trim();
|
|
66582
|
+
const excludeFile = raw.startsWith("/") ? raw : join47(ctx.cwd, raw);
|
|
66583
|
+
const tracked = /* @__PURE__ */ new Map();
|
|
66584
|
+
for (const name of new Set(Object.values(PROJECT_HABITS_FILE))) {
|
|
66585
|
+
const rel = `${prefix2}${name}`;
|
|
66586
|
+
const r = await git3(["ls-files", "--error-unmatch", "--", rel]).catch(
|
|
66587
|
+
() => void 0
|
|
66588
|
+
);
|
|
66589
|
+
tracked.set(rel, r?.code === 0);
|
|
66590
|
+
}
|
|
66591
|
+
return {
|
|
66592
|
+
rel: (name) => `${prefix2}${name}`,
|
|
66593
|
+
tracked: (rel) => tracked.get(rel) === true,
|
|
66594
|
+
excludeFile,
|
|
66595
|
+
exclude: (line) => {
|
|
66596
|
+
let text3 = "";
|
|
66597
|
+
try {
|
|
66598
|
+
text3 = readFileSync39(excludeFile, "utf8");
|
|
66599
|
+
} catch {
|
|
66600
|
+
mkdirSync18(dirname21(excludeFile), { recursive: true });
|
|
66601
|
+
}
|
|
66602
|
+
const lines = text3.split("\n");
|
|
66603
|
+
if (lines.includes(line)) return false;
|
|
66604
|
+
const sep7 = text3 === "" || text3.endsWith("\n") ? "" : "\n";
|
|
66605
|
+
writeFileSync21(excludeFile, `${text3}${sep7}${line}
|
|
66606
|
+
`);
|
|
66607
|
+
return true;
|
|
66608
|
+
},
|
|
66609
|
+
unexclude: (line) => {
|
|
66610
|
+
try {
|
|
66611
|
+
const lines = readFileSync39(excludeFile, "utf8").split("\n");
|
|
66612
|
+
writeFileSync21(excludeFile, lines.filter((l) => l !== line).join("\n"));
|
|
66613
|
+
} catch {
|
|
66614
|
+
}
|
|
66615
|
+
}
|
|
66616
|
+
};
|
|
66617
|
+
}
|
|
66618
|
+
async function habitsProject(ctx) {
|
|
66619
|
+
const { targets, plugins: plugins2 } = wired(ctx);
|
|
66620
|
+
const none2 = {
|
|
66621
|
+
state: "none",
|
|
66622
|
+
files: [],
|
|
66623
|
+
question: null,
|
|
66624
|
+
plugins: pluginStates(ctx)
|
|
66625
|
+
};
|
|
66626
|
+
if (targets.length === 0) {
|
|
66627
|
+
say(
|
|
66628
|
+
ctx,
|
|
66629
|
+
"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."
|
|
66630
|
+
);
|
|
66631
|
+
return none2;
|
|
66632
|
+
}
|
|
66633
|
+
const repo = await isRepoTop(ctx);
|
|
66634
|
+
if (repo === "home" || repo === "no") {
|
|
66635
|
+
say(
|
|
66636
|
+
ctx,
|
|
66637
|
+
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."
|
|
66638
|
+
);
|
|
66639
|
+
return none2;
|
|
66640
|
+
}
|
|
66641
|
+
const io = await projectIo({ ...ctx, cwd: repo.root });
|
|
66642
|
+
const r = writeProjectHabits(
|
|
66643
|
+
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home, cwd: repo.root },
|
|
66644
|
+
targets,
|
|
66645
|
+
io
|
|
66646
|
+
);
|
|
66647
|
+
if (plugins2.length > 0)
|
|
66648
|
+
r.notes.push(
|
|
66649
|
+
`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.`
|
|
66650
|
+
);
|
|
66651
|
+
setDeclined(ctx.home, repo.root, false);
|
|
66652
|
+
if (r.files.length > 0)
|
|
66653
|
+
say(ctx, `Habits on in this folder: ${shown2(ctx, r.files)}`);
|
|
66654
|
+
for (const n of r.notes) say(ctx, n);
|
|
66655
|
+
return {
|
|
66656
|
+
...none2,
|
|
66657
|
+
state: r.files.length > 0 ? "on" : "off",
|
|
66658
|
+
files: r.files,
|
|
66659
|
+
plugins: pluginStates(ctx)
|
|
66660
|
+
};
|
|
66661
|
+
}
|
|
66662
|
+
async function habitsProjectOff(ctx) {
|
|
66663
|
+
const real3 = (p) => {
|
|
66664
|
+
try {
|
|
66665
|
+
return realpathSync16(p);
|
|
66666
|
+
} catch {
|
|
66667
|
+
return resolve15(p);
|
|
66668
|
+
}
|
|
66669
|
+
};
|
|
66670
|
+
const repo = await isRepoTop(ctx);
|
|
66671
|
+
if (repo === "home" || repo === "no") {
|
|
66672
|
+
say(
|
|
66673
|
+
ctx,
|
|
66674
|
+
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."
|
|
66675
|
+
);
|
|
66676
|
+
return 0;
|
|
66677
|
+
}
|
|
66678
|
+
const cwd = repo.root;
|
|
66679
|
+
const r = removeProjectHabits(
|
|
66680
|
+
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home },
|
|
66681
|
+
(path) => dirname21(real3(path)) === cwd
|
|
66682
|
+
);
|
|
66683
|
+
setDeclined(ctx.home, cwd, true);
|
|
66684
|
+
if (r.files.length === 0 && r.notes.length === 0) {
|
|
66685
|
+
say(ctx, `No bus habits here to remove in ${tilde(ctx, cwd)}.`);
|
|
66686
|
+
return 0;
|
|
66687
|
+
}
|
|
66688
|
+
if (r.files.length > 0)
|
|
66689
|
+
say(ctx, `Habits off in this folder: ${shown2(ctx, r.files)}`);
|
|
66690
|
+
for (const n of r.notes) say(ctx, n);
|
|
66691
|
+
return 0;
|
|
66692
|
+
}
|
|
66325
66693
|
async function habitsAfterInstall(ctx, json4) {
|
|
66326
66694
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
66327
66695
|
const none2 = {
|
|
@@ -66333,32 +66701,142 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66333
66701
|
if (habitsOptedOut(ctx.home))
|
|
66334
66702
|
return { ...none2, state: "off", question: null };
|
|
66335
66703
|
if (targets.length === 0 && plugins2.length === 0) return none2;
|
|
66336
|
-
|
|
66337
|
-
|
|
66338
|
-
|
|
66339
|
-
|
|
66340
|
-
|
|
66341
|
-
|
|
66342
|
-
|
|
66343
|
-
|
|
66344
|
-
|
|
66345
|
-
|
|
66346
|
-
|
|
66704
|
+
if (plugins2.length > 0 && !json4 && !pluginLineSaid(ctx.home)) {
|
|
66705
|
+
say(
|
|
66706
|
+
ctx,
|
|
66707
|
+
`The ${plugins2.map((p) => p.label).join(", ")} plugin carries the habits machine-wide; change that with install --habits and --no-habits.`
|
|
66708
|
+
);
|
|
66709
|
+
markPluginLineSaid(ctx.home);
|
|
66710
|
+
}
|
|
66711
|
+
const repoTop = await isRepoTop(ctx);
|
|
66712
|
+
const folder = repoTop === "home" || repoTop === "no" ? ctx.cwd : repoTop.root;
|
|
66713
|
+
const io = await projectIo({ ...ctx, cwd: folder });
|
|
66714
|
+
const nameOf2 = (h) => io.rel?.(PROJECT_HABITS_FILE[h]) ?? PROJECT_HABITS_FILE[h];
|
|
66715
|
+
const writable = targets.filter((h) => io.tracked?.(nameOf2(h)) !== true);
|
|
66716
|
+
const blocked = targets.filter((h) => io.tracked?.(nameOf2(h)) === true);
|
|
66717
|
+
const globalStates = targets.map((h) => habitsFileState(deps(ctx), h));
|
|
66718
|
+
const globalPending = globalStates.filter(
|
|
66719
|
+
(st) => st.state === "changed" || st.state === "broken"
|
|
66720
|
+
);
|
|
66721
|
+
const globalOn = globalStates.filter((st) => st.state === "current");
|
|
66722
|
+
if (globalOn.length > 0 && globalPending.length === 0) {
|
|
66723
|
+
if (!json4 && !moveOffered(ctx.home)) {
|
|
66724
|
+
say(
|
|
66725
|
+
ctx,
|
|
66726
|
+
"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."
|
|
66727
|
+
);
|
|
66728
|
+
markMoveOffered(ctx.home);
|
|
66729
|
+
}
|
|
66730
|
+
return {
|
|
66731
|
+
...none2,
|
|
66732
|
+
state: "on",
|
|
66733
|
+
files: globalStates.map((st) => st.path),
|
|
66734
|
+
question: null
|
|
66735
|
+
};
|
|
66736
|
+
}
|
|
66737
|
+
if (globalPending.length > 0) {
|
|
66738
|
+
const changedGlobals = targets.filter(
|
|
66739
|
+
(h) => habitsFileState(deps(ctx), h).state === "changed"
|
|
66740
|
+
);
|
|
66741
|
+
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66742
|
+
say(
|
|
66743
|
+
ctx,
|
|
66744
|
+
"",
|
|
66745
|
+
disclosure(
|
|
66746
|
+
ctx,
|
|
66747
|
+
globalPending.map((st) => ({ path: st.path, s: st }))
|
|
66748
|
+
)
|
|
66749
|
+
);
|
|
66750
|
+
const a = (await ctx.readLine("Update them? [Y/n] ")).trim().toLowerCase();
|
|
66751
|
+
if (a === "" || a === "y" || a === "yes") {
|
|
66752
|
+
writeHabits(deps(ctx), changedGlobals, { explicit: a !== "" });
|
|
66753
|
+
say(ctx, "Habits updated for every project on this machine.");
|
|
66347
66754
|
}
|
|
66348
|
-
|
|
66755
|
+
return {
|
|
66756
|
+
...none2,
|
|
66757
|
+
state: "changed",
|
|
66758
|
+
files: globalStates.map((st) => st.path),
|
|
66759
|
+
question: null
|
|
66760
|
+
};
|
|
66761
|
+
}
|
|
66762
|
+
const bus = json4 ? BUS_CMD : ctx.busCmd;
|
|
66763
|
+
const files2 = globalStates.map((st) => one2(ctx, st.path)).join(" and ");
|
|
66764
|
+
const q = {
|
|
66765
|
+
...habitsQuestion([files2], bus),
|
|
66766
|
+
text: HABITS_GLOBAL_UPDATE_TEXT.replace("{files}", files2),
|
|
66767
|
+
yes: `${bus} install --habits`,
|
|
66768
|
+
// Declining a global update is not a project answer: nothing here may
|
|
66769
|
+
// mark the current folder declined.
|
|
66770
|
+
no: `${bus} install --no-habits`,
|
|
66771
|
+
never: void 0,
|
|
66772
|
+
note: `These are for every project on this machine. ${OMP_NOTE}`
|
|
66773
|
+
};
|
|
66774
|
+
q.global = void 0;
|
|
66775
|
+
return {
|
|
66776
|
+
...none2,
|
|
66777
|
+
state: "changed",
|
|
66778
|
+
files: globalStates.map((st) => st.path),
|
|
66779
|
+
question: q
|
|
66780
|
+
};
|
|
66781
|
+
}
|
|
66782
|
+
if (repoTop !== "home" && repoTop !== "no" && readDeclined(ctx.home)[folder]) {
|
|
66783
|
+
return { ...none2, state: "off", files: [], question: null };
|
|
66784
|
+
}
|
|
66785
|
+
const states = [
|
|
66786
|
+
...writable.map((h) => {
|
|
66787
|
+
const st = projectHabitsFileState(folder, h);
|
|
66788
|
+
return { path: st.path, s: st };
|
|
66789
|
+
})
|
|
66349
66790
|
];
|
|
66791
|
+
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.`;
|
|
66350
66792
|
const pending = states.filter((p) => p.s.state !== "current");
|
|
66351
66793
|
const have = states.filter((p) => p.s.state === "current").map((p) => p.path);
|
|
66352
|
-
if (pending.length === 0)
|
|
66794
|
+
if (pending.length === 0) {
|
|
66795
|
+
if (writable.length === 0 && blocked.length > 0) {
|
|
66796
|
+
const whyBlockedNow = noteBlocked(ctx, folder, blocked, json4);
|
|
66797
|
+
return {
|
|
66798
|
+
...none2,
|
|
66799
|
+
state: "undecided",
|
|
66800
|
+
files: have,
|
|
66801
|
+
question: null,
|
|
66802
|
+
...whyBlockedNow ? { note: whyBlockedNow } : {}
|
|
66803
|
+
};
|
|
66804
|
+
}
|
|
66353
66805
|
return { ...none2, state: "on", files: have, question: null };
|
|
66806
|
+
}
|
|
66354
66807
|
const changed = pending.some((p) => p.s.state === "changed");
|
|
66355
66808
|
const state = changed ? "changed" : "undecided";
|
|
66809
|
+
if (repoTop === "home" || repoTop === "no") {
|
|
66810
|
+
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.";
|
|
66811
|
+
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66812
|
+
say(ctx, why2);
|
|
66813
|
+
return { ...none2, state, files: have, question: null };
|
|
66814
|
+
}
|
|
66815
|
+
if (!json4) say(ctx, why2);
|
|
66816
|
+
return { ...none2, state, files: have, question: null, note: why2 };
|
|
66817
|
+
}
|
|
66356
66818
|
const asked = pending.map((p) => p.path);
|
|
66357
66819
|
const question = habitsQuestion(
|
|
66358
66820
|
pending.map((p) => p.label ?? one2(ctx, p.path)),
|
|
66359
66821
|
// --json goes to an agent that may hand the commands to its user's own shell.
|
|
66360
66822
|
json4 ? BUS_CMD : ctx.busCmd
|
|
66361
66823
|
);
|
|
66824
|
+
if (blocked.length > 0) {
|
|
66825
|
+
const said = readBlocked(ctx.home);
|
|
66826
|
+
const root = folder;
|
|
66827
|
+
const fresh = blocked.filter((h) => !(said[root] ?? []).includes(h));
|
|
66828
|
+
if (fresh.length > 0) {
|
|
66829
|
+
question.note = `${whyBlocked(fresh)} ${question.note}`;
|
|
66830
|
+
saveBlocked(ctx.home, {
|
|
66831
|
+
...said,
|
|
66832
|
+
[root]: [...said[root] ?? [], ...fresh]
|
|
66833
|
+
});
|
|
66834
|
+
}
|
|
66835
|
+
}
|
|
66836
|
+
if (plugins2.length > 0)
|
|
66837
|
+
question.note = `${question.note} The ${plugins2.map((p) => p.label).join(
|
|
66838
|
+
", "
|
|
66839
|
+
)} plugin carries them machine-wide; change that with install --habits and --no-habits.`;
|
|
66362
66840
|
if (ctx.stdinIsTTY && ctx.readLine && !json4) {
|
|
66363
66841
|
say(ctx, "", disclosure(ctx, pending));
|
|
66364
66842
|
const outside = pending.some(
|
|
@@ -66375,22 +66853,21 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66375
66853
|
return { ...none2, state, files: have, question };
|
|
66376
66854
|
}
|
|
66377
66855
|
if (a === "" || a === "y" || a === "yes") {
|
|
66378
|
-
const r =
|
|
66379
|
-
|
|
66380
|
-
|
|
66381
|
-
(h) => asked.includes(
|
|
66382
|
-
),
|
|
66383
|
-
{ explicit: a !== "" }
|
|
66384
|
-
);
|
|
66385
|
-
const pl = setPluginHabits(
|
|
66386
|
-
deps(ctx),
|
|
66387
|
-
plugins2.filter(
|
|
66388
|
-
(p) => asked.includes(join47(p.dir(ctx.userHome, ctx.env), p.marker))
|
|
66856
|
+
const r = writeProjectHabits(
|
|
66857
|
+
{ home: ctx.userHome, env: ctx.env, busHome: ctx.home, cwd: folder },
|
|
66858
|
+
writable.filter(
|
|
66859
|
+
(h) => asked.includes(projectHabitsFileState(folder, h).path)
|
|
66389
66860
|
),
|
|
66390
|
-
|
|
66861
|
+
io
|
|
66391
66862
|
);
|
|
66392
|
-
|
|
66863
|
+
const pl = { changed: [], notes: [], pluginFiles: [], incomplete: false };
|
|
66864
|
+
if (!changed) setDeclined(ctx.home, folder, false);
|
|
66393
66865
|
if (r.files.length > 0) say(ctx, `Habits on in ${shown2(ctx, r.files)}`);
|
|
66866
|
+
if (plugins2.length > 0)
|
|
66867
|
+
say(
|
|
66868
|
+
ctx,
|
|
66869
|
+
`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.`
|
|
66870
|
+
);
|
|
66394
66871
|
for (const p of pl.changed) say(ctx, pluginOn(p));
|
|
66395
66872
|
for (const n of [...r.notes, ...pl.notes]) say(ctx, n);
|
|
66396
66873
|
return {
|
|
@@ -66403,17 +66880,11 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66403
66880
|
}
|
|
66404
66881
|
if (a === "n" || a === "no") {
|
|
66405
66882
|
if (!changed) {
|
|
66406
|
-
|
|
66407
|
-
|
|
66408
|
-
|
|
66409
|
-
|
|
66410
|
-
|
|
66411
|
-
"Habits are still on in some places (see below). Your opt-out is saved, so a reinstall won't add them back."
|
|
66412
|
-
);
|
|
66413
|
-
for (const n of off.notes) say(ctx, n);
|
|
66414
|
-
return { ...none2, state: "on", plugins: pluginStates(ctx) };
|
|
66415
|
-
}
|
|
66416
|
-
say(ctx, "Habits off. A reinstall will not add them back.");
|
|
66883
|
+
setDeclined(ctx.home, folder, true);
|
|
66884
|
+
say(
|
|
66885
|
+
ctx,
|
|
66886
|
+
"Habits stay off in this project. Other projects will still be asked; install --no-habits turns them off everywhere and never asks again."
|
|
66887
|
+
);
|
|
66417
66888
|
return { ...none2, state: "off", plugins: pluginStates(ctx) };
|
|
66418
66889
|
}
|
|
66419
66890
|
say(ctx, "Left the habits as they were.");
|
|
@@ -66425,9 +66896,20 @@ async function habitsAfterInstall(ctx, json4) {
|
|
|
66425
66896
|
if (!json4) say(ctx, "", habitsQuestionLines(question));
|
|
66426
66897
|
return { ...none2, state, files: have, question };
|
|
66427
66898
|
}
|
|
66428
|
-
function habitsCommand(mode, ctx) {
|
|
66899
|
+
async function habitsCommand(mode, ctx) {
|
|
66429
66900
|
say(ctx, ctx.copy.header(ctx.version), "");
|
|
66430
|
-
|
|
66901
|
+
if (mode === "show") return show(ctx);
|
|
66902
|
+
if (mode === "project-off") return await habitsProjectOff(ctx);
|
|
66903
|
+
if (mode === "project") {
|
|
66904
|
+
try {
|
|
66905
|
+
const r = await habitsProject(ctx);
|
|
66906
|
+
return r.files.length > 0 || r.state === "on" ? 0 : 1;
|
|
66907
|
+
} catch (e) {
|
|
66908
|
+
sayErr(ctx, `Could not set up the habits here: ${String(e)}`);
|
|
66909
|
+
return 1;
|
|
66910
|
+
}
|
|
66911
|
+
}
|
|
66912
|
+
return mode === "yes" ? turnOn2(ctx) : turnOff2(ctx);
|
|
66431
66913
|
}
|
|
66432
66914
|
function habitsLine(ctx) {
|
|
66433
66915
|
const { targets, plugins: plugins2 } = wired(ctx);
|
|
@@ -66447,20 +66929,20 @@ function habitsLine(ctx) {
|
|
|
66447
66929
|
}
|
|
66448
66930
|
|
|
66449
66931
|
// src/commands/namespace.ts
|
|
66450
|
-
import { realpathSync as
|
|
66451
|
-
import { join as join48, resolve as
|
|
66932
|
+
import { realpathSync as realpathSync17, statSync as statSync11 } from "node:fs";
|
|
66933
|
+
import { join as join48, resolve as resolve16 } from "node:path";
|
|
66452
66934
|
init_src();
|
|
66453
66935
|
function shown3(ctx, path) {
|
|
66454
66936
|
const t = tilde(ctx, path);
|
|
66455
66937
|
if (t !== path) return t;
|
|
66456
66938
|
try {
|
|
66457
|
-
return tilde({ userHome:
|
|
66939
|
+
return tilde({ userHome: realpathSync17(ctx.userHome) }, path);
|
|
66458
66940
|
} catch {
|
|
66459
66941
|
return path;
|
|
66460
66942
|
}
|
|
66461
66943
|
}
|
|
66462
66944
|
function approvalsInstance(ctx, dir) {
|
|
66463
|
-
const r = folderHomeLookup(ctx.home)(
|
|
66945
|
+
const r = folderHomeLookup(ctx.home)(resolve16(ctx.cwd, dir));
|
|
66464
66946
|
return "instance" in r ? r.instance : void 0;
|
|
66465
66947
|
}
|
|
66466
66948
|
function approvalsFileFor(ctx, dir) {
|
|
@@ -66492,7 +66974,7 @@ async function namespace(opts, ctx) {
|
|
|
66492
66974
|
);
|
|
66493
66975
|
return 0;
|
|
66494
66976
|
}
|
|
66495
|
-
const given =
|
|
66977
|
+
const given = resolve16(ctx.cwd, opts.dir);
|
|
66496
66978
|
let real3;
|
|
66497
66979
|
try {
|
|
66498
66980
|
real3 = canonicalPath(given);
|
|
@@ -66598,7 +67080,7 @@ init_src();
|
|
|
66598
67080
|
|
|
66599
67081
|
// src/commands/install.ts
|
|
66600
67082
|
init_src3();
|
|
66601
|
-
import { dirname as
|
|
67083
|
+
import { dirname as dirname22, join as join50 } from "node:path";
|
|
66602
67084
|
init_src2();
|
|
66603
67085
|
|
|
66604
67086
|
// src/live.ts
|
|
@@ -66651,7 +67133,7 @@ function spinner(ctx) {
|
|
|
66651
67133
|
import {
|
|
66652
67134
|
lstatSync as lstatSync21,
|
|
66653
67135
|
readdirSync as readdirSync14,
|
|
66654
|
-
readFileSync as
|
|
67136
|
+
readFileSync as readFileSync40,
|
|
66655
67137
|
rmdirSync as rmdirSync4,
|
|
66656
67138
|
rmSync as rmSync24
|
|
66657
67139
|
} from "node:fs";
|
|
@@ -66719,7 +67201,7 @@ function emptyFile(path) {
|
|
|
66719
67201
|
const st = lstatSync21(path);
|
|
66720
67202
|
if (!st.isFile()) return false;
|
|
66721
67203
|
if (st.size === 0) return true;
|
|
66722
|
-
const doc = JSON.parse(
|
|
67204
|
+
const doc = JSON.parse(readFileSync40(path, "utf8"));
|
|
66723
67205
|
return typeof doc === "object" && doc !== null && !Array.isArray(doc) && Object.keys(doc).length === 0;
|
|
66724
67206
|
} catch {
|
|
66725
67207
|
return false;
|
|
@@ -67135,7 +67617,7 @@ function reportShim(ctx) {
|
|
|
67135
67617
|
if (r.kind === "installed") {
|
|
67136
67618
|
say(ctx, ctx.copy.shimInstalled(tilde(ctx, r.path)));
|
|
67137
67619
|
if (!r.onPath && r.hint)
|
|
67138
|
-
say(ctx, ctx.copy.shimNotOnPath(tilde(ctx,
|
|
67620
|
+
say(ctx, ctx.copy.shimNotOnPath(tilde(ctx, dirname22(r.path)), r.hint));
|
|
67139
67621
|
} else if (r.kind === "other-home")
|
|
67140
67622
|
say(ctx, ctx.copy.shimOtherHome(tilde(ctx, r.path), tilde(ctx, r.home)));
|
|
67141
67623
|
else if (r.kind === "foreign")
|
|
@@ -67433,7 +67915,7 @@ async function healthz(ctx, hub) {
|
|
|
67433
67915
|
function claudeIsolates(path) {
|
|
67434
67916
|
let text3;
|
|
67435
67917
|
try {
|
|
67436
|
-
text3 =
|
|
67918
|
+
text3 = readFileSync41(path, "utf8");
|
|
67437
67919
|
} catch {
|
|
67438
67920
|
return void 0;
|
|
67439
67921
|
}
|
|
@@ -67734,13 +68216,13 @@ async function doctor(ctx) {
|
|
|
67734
68216
|
}
|
|
67735
68217
|
|
|
67736
68218
|
// src/commands/global.ts
|
|
67737
|
-
import { realpathSync as
|
|
67738
|
-
import { resolve as
|
|
68219
|
+
import { realpathSync as realpathSync18, statSync as statSync12 } from "node:fs";
|
|
68220
|
+
import { resolve as resolve17 } from "node:path";
|
|
67739
68221
|
function shown4(ctx, path) {
|
|
67740
68222
|
const t = tilde(ctx, path);
|
|
67741
68223
|
if (t !== path) return t;
|
|
67742
68224
|
try {
|
|
67743
|
-
return tilde({ userHome:
|
|
68225
|
+
return tilde({ userHome: realpathSync18(ctx.userHome) }, path);
|
|
67744
68226
|
} catch {
|
|
67745
68227
|
return path;
|
|
67746
68228
|
}
|
|
@@ -67761,7 +68243,7 @@ async function global(opts, ctx) {
|
|
|
67761
68243
|
);
|
|
67762
68244
|
return 0;
|
|
67763
68245
|
}
|
|
67764
|
-
const given =
|
|
68246
|
+
const given = resolve17(ctx.cwd, opts.dir);
|
|
67765
68247
|
let real3;
|
|
67766
68248
|
try {
|
|
67767
68249
|
real3 = canonicalPath(given);
|
|
@@ -67793,12 +68275,12 @@ async function global(opts, ctx) {
|
|
|
67793
68275
|
}
|
|
67794
68276
|
|
|
67795
68277
|
// src/commands/leads.ts
|
|
67796
|
-
import { readFileSync as
|
|
68278
|
+
import { readFileSync as readFileSync42 } from "node:fs";
|
|
67797
68279
|
import { join as join52 } from "node:path";
|
|
67798
68280
|
function hubOrigin2(ctx) {
|
|
67799
68281
|
try {
|
|
67800
68282
|
const raw = JSON.parse(
|
|
67801
|
-
|
|
68283
|
+
readFileSync42(join52(ctx.home, "machine.json"), "utf8")
|
|
67802
68284
|
);
|
|
67803
68285
|
return typeof raw?.hub === "string" ? new URL(raw.hub).origin : void 0;
|
|
67804
68286
|
} catch {
|
|
@@ -67857,10 +68339,10 @@ async function leads(opts, ctx) {
|
|
|
67857
68339
|
|
|
67858
68340
|
// src/commands/link.ts
|
|
67859
68341
|
import { statSync as statSync13 } from "node:fs";
|
|
67860
|
-
import { resolve as
|
|
68342
|
+
import { resolve as resolve18 } from "node:path";
|
|
67861
68343
|
init_src();
|
|
67862
68344
|
function side(ctx, dir) {
|
|
67863
|
-
const given =
|
|
68345
|
+
const given = resolve18(ctx.cwd, dir);
|
|
67864
68346
|
try {
|
|
67865
68347
|
const real3 = canonicalPath(given);
|
|
67866
68348
|
if (!statSync13(real3).isDirectory()) return void 0;
|
|
@@ -67895,7 +68377,7 @@ async function link(opts, ctx) {
|
|
|
67895
68377
|
for (const d of opts.dirs) {
|
|
67896
68378
|
const s = side(ctx, d);
|
|
67897
68379
|
if (!s) {
|
|
67898
|
-
sayErr(ctx, c.linkNotDir(shq(
|
|
68380
|
+
sayErr(ctx, c.linkNotDir(shq(resolve18(ctx.cwd, d))));
|
|
67899
68381
|
return 1;
|
|
67900
68382
|
}
|
|
67901
68383
|
sides.push(s);
|
|
@@ -67990,9 +68472,9 @@ import {
|
|
|
67990
68472
|
fstatSync as fstatSync6,
|
|
67991
68473
|
lstatSync as lstatSync22,
|
|
67992
68474
|
openSync as openSync11,
|
|
67993
|
-
readFileSync as
|
|
68475
|
+
readFileSync as readFileSync43
|
|
67994
68476
|
} from "node:fs";
|
|
67995
|
-
import { dirname as
|
|
68477
|
+
import { dirname as dirname23, join as join53 } from "node:path";
|
|
67996
68478
|
var TAIL = 50;
|
|
67997
68479
|
var checkDir2 = (dir) => {
|
|
67998
68480
|
let fd;
|
|
@@ -68026,10 +68508,10 @@ var tail = (path, dir) => {
|
|
|
68026
68508
|
constants8.O_RDONLY | constants8.O_NOFOLLOW | constants8.O_NONBLOCK
|
|
68027
68509
|
);
|
|
68028
68510
|
if (!fstatSync6(fd).isFile()) return "skipped";
|
|
68029
|
-
const after = lstatSync22(
|
|
68511
|
+
const after = lstatSync22(dirname23(path));
|
|
68030
68512
|
if (after.isSymbolicLink() || after.dev !== dir.dev || after.ino !== dir.ino)
|
|
68031
68513
|
return "skipped";
|
|
68032
|
-
return
|
|
68514
|
+
return readFileSync43(fd, "utf8").replace(/\n$/, "").split("\n").slice(-TAIL);
|
|
68033
68515
|
} catch (e) {
|
|
68034
68516
|
return e.code === "ELOOP" ? "skipped" : void 0;
|
|
68035
68517
|
} finally {
|
|
@@ -68081,7 +68563,7 @@ async function mcp(harness, ctx, load2 = (h) => MCP_SERVER[h]()) {
|
|
|
68081
68563
|
init_src3();
|
|
68082
68564
|
import { execFileSync as execFileSync8 } from "node:child_process";
|
|
68083
68565
|
import { createHash as createHash12, randomBytes as randomBytes10 } from "node:crypto";
|
|
68084
|
-
import { readFileSync as
|
|
68566
|
+
import { readFileSync as readFileSync44, readlinkSync as readlinkSync7 } from "node:fs";
|
|
68085
68567
|
import { basename as basename10, join as join54 } from "node:path";
|
|
68086
68568
|
init_src2();
|
|
68087
68569
|
init_src();
|
|
@@ -68095,14 +68577,14 @@ function parsePs(out) {
|
|
|
68095
68577
|
}
|
|
68096
68578
|
function readProc(pid) {
|
|
68097
68579
|
try {
|
|
68098
|
-
const stat =
|
|
68580
|
+
const stat = readFileSync44(`/proc/${pid}/stat`, "utf8");
|
|
68099
68581
|
const ppid = Number(stat.slice(stat.lastIndexOf(")") + 1).split(/\s+/)[2]);
|
|
68100
68582
|
let exe = "";
|
|
68101
68583
|
try {
|
|
68102
68584
|
exe = readlinkSync7(`/proc/${pid}/exe`);
|
|
68103
68585
|
} catch {
|
|
68104
68586
|
}
|
|
68105
|
-
const comm =
|
|
68587
|
+
const comm = readFileSync44(`/proc/${pid}/comm`, "utf8").trim();
|
|
68106
68588
|
return { ppid, name: isClaude(exe) ? exe : comm };
|
|
68107
68589
|
} catch {
|
|
68108
68590
|
}
|
|
@@ -68130,7 +68612,7 @@ function findClaude(from, proc) {
|
|
|
68130
68612
|
function tokenOf(file2) {
|
|
68131
68613
|
if (!file2) return void 0;
|
|
68132
68614
|
try {
|
|
68133
|
-
return
|
|
68615
|
+
return readFileSync44(file2, "utf8").trim() || void 0;
|
|
68134
68616
|
} catch {
|
|
68135
68617
|
return void 0;
|
|
68136
68618
|
}
|
|
@@ -68471,6 +68953,18 @@ async function unwire(ctx) {
|
|
|
68471
68953
|
`Could not remove the habits block: ${e instanceof Error ? e.message : String(e)}`
|
|
68472
68954
|
]);
|
|
68473
68955
|
}
|
|
68956
|
+
try {
|
|
68957
|
+
const project = removeProjectHabits({
|
|
68958
|
+
home: ctx.userHome,
|
|
68959
|
+
env: ctx.env,
|
|
68960
|
+
busHome: ctx.home
|
|
68961
|
+
});
|
|
68962
|
+
for (const n of project.notes) say(ctx, [n]);
|
|
68963
|
+
} catch (e) {
|
|
68964
|
+
say(ctx, [
|
|
68965
|
+
`Could not remove this project's habits block: ${e instanceof Error ? e.message : String(e)}`
|
|
68966
|
+
]);
|
|
68967
|
+
}
|
|
68474
68968
|
try {
|
|
68475
68969
|
const gone = removeShim({
|
|
68476
68970
|
userHome: ctx.userHome,
|
|
@@ -68621,9 +69115,9 @@ import {
|
|
|
68621
69115
|
chmodSync as chmodSync23,
|
|
68622
69116
|
copyFileSync as copyFileSync2,
|
|
68623
69117
|
existsSync as existsSync20,
|
|
68624
|
-
mkdirSync as
|
|
69118
|
+
mkdirSync as mkdirSync19,
|
|
68625
69119
|
rmSync as rmSync26,
|
|
68626
|
-
writeFileSync as
|
|
69120
|
+
writeFileSync as writeFileSync22
|
|
68627
69121
|
} from "node:fs";
|
|
68628
69122
|
import { join as join57 } from "node:path";
|
|
68629
69123
|
var realUpgradeDeps = (ctx) => ({
|
|
@@ -68754,8 +69248,8 @@ async function upgrade(ctx, opts, deps2 = realUpgradeDeps(ctx)) {
|
|
|
68754
69248
|
}
|
|
68755
69249
|
const marker = join57(dest, ".live", String(process.pid));
|
|
68756
69250
|
try {
|
|
68757
|
-
|
|
68758
|
-
|
|
69251
|
+
mkdirSync19(join57(dest, ".live"), { recursive: true, mode: 448 });
|
|
69252
|
+
writeFileSync22(marker, "", { mode: 384 });
|
|
68759
69253
|
} catch {
|
|
68760
69254
|
}
|
|
68761
69255
|
deps2.beforeInstall?.(dest);
|
|
@@ -68954,6 +69448,8 @@ var FLAGS = {
|
|
|
68954
69448
|
"no-service",
|
|
68955
69449
|
"alongside",
|
|
68956
69450
|
"habits",
|
|
69451
|
+
"habits-project",
|
|
69452
|
+
"no-habits-project",
|
|
68957
69453
|
"no-habits",
|
|
68958
69454
|
"show-habits",
|
|
68959
69455
|
"json"
|
|
@@ -68992,6 +69488,8 @@ function parse7(argv) {
|
|
|
68992
69488
|
"no-service": { type: "boolean", default: false },
|
|
68993
69489
|
alongside: { type: "boolean", default: false },
|
|
68994
69490
|
habits: { type: "boolean", default: false },
|
|
69491
|
+
"habits-project": { type: "boolean", default: false },
|
|
69492
|
+
"no-habits-project": { type: "boolean", default: false },
|
|
68995
69493
|
"no-habits": { type: "boolean", default: false },
|
|
68996
69494
|
"show-habits": { type: "boolean", default: false },
|
|
68997
69495
|
json: { type: "boolean", default: false },
|
|
@@ -69184,11 +69682,15 @@ function route(cmd, values, positionals) {
|
|
|
69184
69682
|
function habitsMode(v) {
|
|
69185
69683
|
const asked = [
|
|
69186
69684
|
v.habits && "yes",
|
|
69685
|
+
v["habits-project"] && "project",
|
|
69686
|
+
v["no-habits-project"] && "project-off",
|
|
69187
69687
|
v["no-habits"] && "no",
|
|
69188
69688
|
v["show-habits"] && "show"
|
|
69189
69689
|
].filter(Boolean);
|
|
69190
69690
|
if (asked.length > 1)
|
|
69191
|
-
throw new Error(
|
|
69691
|
+
throw new Error(
|
|
69692
|
+
"use only one of --habits, --habits-project, --no-habits-project, --no-habits, --show-habits"
|
|
69693
|
+
);
|
|
69192
69694
|
return asked[0] ? { habits: asked[0] } : {};
|
|
69193
69695
|
}
|
|
69194
69696
|
|
|
@@ -69221,7 +69723,7 @@ async function main(argv, makeCtx = realCtx) {
|
|
|
69221
69723
|
return 2;
|
|
69222
69724
|
}
|
|
69223
69725
|
const ctx = makeCtx(cmd.noColor);
|
|
69224
|
-
if (cmd.home) ctx.home =
|
|
69726
|
+
if (cmd.home) ctx.home = resolve19(cmd.home);
|
|
69225
69727
|
if (!TERMINAL.has(cmd.cmd) && cmd.cmd !== "install" && cmd.cmd !== "uninstall")
|
|
69226
69728
|
markLive(fileURLToPath7(import.meta.url), ctx.home);
|
|
69227
69729
|
ctx.copy = copyFor(ctx);
|