@inerrata-corporation/errata 2.0.23-dev.4826 → 2.0.23-dev.4863
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/errata.mjs
CHANGED
|
@@ -980,7 +980,7 @@ function lemma(token) {
|
|
|
980
980
|
}
|
|
981
981
|
return token;
|
|
982
982
|
}
|
|
983
|
-
function tokenize(text,
|
|
983
|
+
function tokenize(text, resolve11) {
|
|
984
984
|
const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
|
|
985
985
|
const out2 = /* @__PURE__ */ new Set();
|
|
986
986
|
for (const raw2 of matches) {
|
|
@@ -990,7 +990,7 @@ function tokenize(text, resolve10) {
|
|
|
990
990
|
out2.add(token);
|
|
991
991
|
continue;
|
|
992
992
|
}
|
|
993
|
-
const canonical =
|
|
993
|
+
const canonical = resolve11(token);
|
|
994
994
|
out2.add(canonical ?? lemma(token));
|
|
995
995
|
}
|
|
996
996
|
return [...out2].sort();
|
|
@@ -24309,7 +24309,7 @@ function ingestDesignProblem(store, flag, opts) {
|
|
|
24309
24309
|
...existing.attrs,
|
|
24310
24310
|
// An INDEPENDENT source re-deriving a resolved problem marks
|
|
24311
24311
|
// immediately — that is the strongest recurrence evidence there is.
|
|
24312
|
-
...resolvedUnretracted ? recurAttrs() : {},
|
|
24312
|
+
...resolvedUnretracted && !opts.replay ? recurAttrs() : {},
|
|
24313
24313
|
sources: [...sources, opts.source],
|
|
24314
24314
|
corroborations: corroborations2,
|
|
24315
24315
|
...promoted ? { provisional: false } : {},
|
|
@@ -24336,7 +24336,11 @@ function ingestDesignProblem(store, flag, opts) {
|
|
|
24336
24336
|
lastUpdatedAt: opts.ts
|
|
24337
24337
|
});
|
|
24338
24338
|
if (recurredResolved) reopenedFromRegression = maybeReopenFromRegression(store, problemId, opts.ts);
|
|
24339
|
-
} else if (resolvedUnretracted && opts.
|
|
24339
|
+
} else if (resolvedUnretracted && !opts.replay && // From the later of the last recurrence and the close itself: before the
|
|
24340
|
+
// first recurrence there is no recurredAt, and measuring from 0 booked the
|
|
24341
|
+
// resolving session's own turn-final restatement — seconds after its fix —
|
|
24342
|
+
// as the problem coming back (15 of 19 recurrences on the arena store).
|
|
24343
|
+
opts.ts - Math.max(Number(existing.attrs["recurredAt"]) || 0, Number(existing.attrs["resolvedAt"]) || 0) > RECURRENCE_DEBOUNCE_MS) {
|
|
24340
24344
|
store.updateNode(problemId, {
|
|
24341
24345
|
attrs: { ...existing.attrs, ...recurAttrs() },
|
|
24342
24346
|
lastUpdatedAt: opts.ts
|
|
@@ -37163,7 +37167,7 @@ async function waitForDaemonExit(lock, timeoutMs, pollMs = 200) {
|
|
|
37163
37167
|
for (; ; ) {
|
|
37164
37168
|
if (daemonLockState(lock, true) === "stale") return true;
|
|
37165
37169
|
if (Date.now() >= deadline) return false;
|
|
37166
|
-
await new Promise((
|
|
37170
|
+
await new Promise((resolve11) => setTimeout(resolve11, pollMs));
|
|
37167
37171
|
}
|
|
37168
37172
|
}
|
|
37169
37173
|
function releaseOwnLock(lockPath) {
|
|
@@ -41249,13 +41253,13 @@ async function Module2(moduleArg = {}) {
|
|
|
41249
41253
|
}
|
|
41250
41254
|
readAsync = /* @__PURE__ */ __name(async (url2) => {
|
|
41251
41255
|
if (isFileURI(url2)) {
|
|
41252
|
-
return new Promise((
|
|
41256
|
+
return new Promise((resolve11, reject) => {
|
|
41253
41257
|
var xhr = new XMLHttpRequest();
|
|
41254
41258
|
xhr.open("GET", url2, true);
|
|
41255
41259
|
xhr.responseType = "arraybuffer";
|
|
41256
41260
|
xhr.onload = () => {
|
|
41257
41261
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
41258
|
-
|
|
41262
|
+
resolve11(xhr.response);
|
|
41259
41263
|
return;
|
|
41260
41264
|
}
|
|
41261
41265
|
reject(xhr.status);
|
|
@@ -41451,9 +41455,9 @@ async function Module2(moduleArg = {}) {
|
|
|
41451
41455
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
41452
41456
|
var info2 = getWasmImports();
|
|
41453
41457
|
if (Module["instantiateWasm"]) {
|
|
41454
|
-
return new Promise((
|
|
41458
|
+
return new Promise((resolve11, reject) => {
|
|
41455
41459
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
41456
|
-
|
|
41460
|
+
resolve11(receiveInstance(mod, inst));
|
|
41457
41461
|
});
|
|
41458
41462
|
});
|
|
41459
41463
|
}
|
|
@@ -42784,8 +42788,8 @@ async function Module2(moduleArg = {}) {
|
|
|
42784
42788
|
if (runtimeInitialized) {
|
|
42785
42789
|
moduleRtn = Module;
|
|
42786
42790
|
} else {
|
|
42787
|
-
moduleRtn = new Promise((
|
|
42788
|
-
readyPromiseResolve =
|
|
42791
|
+
moduleRtn = new Promise((resolve11, reject) => {
|
|
42792
|
+
readyPromiseResolve = resolve11;
|
|
42789
42793
|
readyPromiseReject = reject;
|
|
42790
42794
|
});
|
|
42791
42795
|
}
|
|
@@ -48120,7 +48124,7 @@ async function findStaleFiles(store, rootPath, workspaceId2, lineageVerifiedAt)
|
|
|
48120
48124
|
}
|
|
48121
48125
|
if (++scanned % SCAN_YIELD_EVERY === 0) {
|
|
48122
48126
|
check2();
|
|
48123
|
-
await new Promise((
|
|
48127
|
+
await new Promise((resolve11) => setImmediate(resolve11));
|
|
48124
48128
|
}
|
|
48125
48129
|
}
|
|
48126
48130
|
check2();
|
|
@@ -48289,6 +48293,7 @@ __export(mcp_exports, {
|
|
|
48289
48293
|
SEARCH_CODE_SEEDS: () => SEARCH_CODE_SEEDS,
|
|
48290
48294
|
SEARCH_KNOWLEDGE_SEEDS: () => SEARCH_KNOWLEDGE_SEEDS,
|
|
48291
48295
|
createMcpHandler: () => createMcpHandler,
|
|
48296
|
+
lifecycleFields: () => lifecycleFields,
|
|
48292
48297
|
runMcpServer: () => runMcpServer,
|
|
48293
48298
|
runTool: () => runTool,
|
|
48294
48299
|
searchEntries: () => searchEntries,
|
|
@@ -48373,6 +48378,27 @@ function takeDiscriminatorNudge(path3) {
|
|
|
48373
48378
|
shared.close();
|
|
48374
48379
|
}
|
|
48375
48380
|
}
|
|
48381
|
+
function lifecycleFields(store, id, cloud) {
|
|
48382
|
+
const node2 = store.getNode(id);
|
|
48383
|
+
if (node2) {
|
|
48384
|
+
const l = lifecycleOf(store, node2);
|
|
48385
|
+
const rg = hitState(store, node2);
|
|
48386
|
+
const note = lifecycleNote(l);
|
|
48387
|
+
return {
|
|
48388
|
+
...rg.state ? { state: rg.state } : {},
|
|
48389
|
+
...rg.refutedWhy ? { refutedWhy: rg.refutedWhy } : {},
|
|
48390
|
+
...rg.supersededBy?.length ? { supersededBy: rg.supersededBy } : {},
|
|
48391
|
+
...note ? { lifecycle: note } : {}
|
|
48392
|
+
};
|
|
48393
|
+
}
|
|
48394
|
+
if (!cloud) return {};
|
|
48395
|
+
const held = (cloud.corroborationCount ?? 0) + (cloud.acceptedCount ?? 0);
|
|
48396
|
+
const refuted = cloud.failureReportCount ?? 0;
|
|
48397
|
+
if ((cloud.supersededBy ?? 0) > 0) return { state: "superseded", lifecycle: "superseded by a newer fix on the Network \u2014 prefer that fix" };
|
|
48398
|
+
if (refuted > held) return { state: "refuted", lifecycle: `refuted on the Network (${Math.round(refuted)}\xD7)` };
|
|
48399
|
+
if (held > 0) return { state: "held", lifecycle: "held \u2014 confirmed on the Network" };
|
|
48400
|
+
return {};
|
|
48401
|
+
}
|
|
48376
48402
|
function hitState(store, n) {
|
|
48377
48403
|
const l = lifecycleOf(store, n);
|
|
48378
48404
|
if (l.state === "superseded") return { state: "superseded", supersededBy: l.supersededBy, factor: supersessionFactor(l.supersededBy.length) };
|
|
@@ -49020,7 +49046,12 @@ var init_mcp = __esm({
|
|
|
49020
49046
|
await rankHits(store, query, pool.map((h) => ({ ...h, name: h.description, ...h.via?.text ? { viaText: h.via.text } : {}, ...parentOf.has(h.id) ? { parentId: parentOf.get(h.id) } : {}, hops: h.matched ? 0 : 1 }))),
|
|
49021
49047
|
isKnowledge,
|
|
49022
49048
|
limit
|
|
49023
|
-
).map(({ rank, ...h }) => ({
|
|
49049
|
+
).map(({ rank, ...h }) => ({
|
|
49050
|
+
...h,
|
|
49051
|
+
why: rankWhy(rank),
|
|
49052
|
+
...lifecycleFields(store, h.id),
|
|
49053
|
+
...isKnowledge(h.label) ? { cite: h.id } : {}
|
|
49054
|
+
}));
|
|
49024
49055
|
if (ctx.cloud && query.trim()) {
|
|
49025
49056
|
const localHits = pool.map((h) => ({
|
|
49026
49057
|
id: h.id,
|
|
@@ -49059,7 +49090,17 @@ var init_mcp = __esm({
|
|
|
49059
49090
|
count: formatted.length,
|
|
49060
49091
|
corroborated: dual.merged.corroboratedCount,
|
|
49061
49092
|
collective: dual.merged.collectiveCount,
|
|
49062
|
-
results: withLinks(
|
|
49093
|
+
results: withLinks(
|
|
49094
|
+
store,
|
|
49095
|
+
withCite(
|
|
49096
|
+
formatted.map((r) => ({
|
|
49097
|
+
...r,
|
|
49098
|
+
why: why.get(String(r["id"])),
|
|
49099
|
+
...lifecycleFields(store, String(r["id"]), dual.cloudEvidence.get(String(r["id"])))
|
|
49100
|
+
})),
|
|
49101
|
+
isKnowledge
|
|
49102
|
+
)
|
|
49103
|
+
)
|
|
49063
49104
|
};
|
|
49064
49105
|
}
|
|
49065
49106
|
const local = withLinks(store, await rankLocal());
|
|
@@ -58778,7 +58819,7 @@ function buildWebUi(deps) {
|
|
|
58778
58819
|
const transcriptPath = String(body2["transcript_path"] ?? "");
|
|
58779
58820
|
const sessionId = String(body2["session_id"] ?? "");
|
|
58780
58821
|
if (transcriptPath && deps.onTurn) {
|
|
58781
|
-
deps.onTurn({ sessionId, transcriptPath });
|
|
58822
|
+
deps.onTurn({ sessionId, transcriptPath, ...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {} });
|
|
58782
58823
|
}
|
|
58783
58824
|
if (body2["hook_event_name"] === "SubagentStop" && typeof body2["agent_id"] === "string" && body2["agent_id"]) {
|
|
58784
58825
|
deps.onSubagentStop?.(body2["agent_id"]);
|
|
@@ -58808,7 +58849,8 @@ function buildWebUi(deps) {
|
|
|
58808
58849
|
sessionId,
|
|
58809
58850
|
text: whole.text,
|
|
58810
58851
|
...messageId ? { messageId } : {},
|
|
58811
|
-
...agentId ? { agentId } : {}
|
|
58852
|
+
...agentId ? { agentId } : {},
|
|
58853
|
+
...typeof body2["cwd"] === "string" && body2["cwd"] ? { cwd: body2["cwd"] } : {}
|
|
58812
58854
|
});
|
|
58813
58855
|
}
|
|
58814
58856
|
return c.json({ ok: true, ...whole === null ? { buffered: true } : {} });
|
|
@@ -61477,9 +61519,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
61477
61519
|
}
|
|
61478
61520
|
close(callback) {
|
|
61479
61521
|
if (callback === void 0) {
|
|
61480
|
-
return new Promise((
|
|
61522
|
+
return new Promise((resolve11, reject) => {
|
|
61481
61523
|
this.close((err2, data) => {
|
|
61482
|
-
return err2 ? reject(err2) :
|
|
61524
|
+
return err2 ? reject(err2) : resolve11(data);
|
|
61483
61525
|
});
|
|
61484
61526
|
});
|
|
61485
61527
|
}
|
|
@@ -61517,12 +61559,12 @@ var require_dispatcher_base = __commonJS({
|
|
|
61517
61559
|
err2 = null;
|
|
61518
61560
|
}
|
|
61519
61561
|
if (callback === void 0) {
|
|
61520
|
-
return new Promise((
|
|
61562
|
+
return new Promise((resolve11, reject) => {
|
|
61521
61563
|
this.destroy(err2, (err3, data) => {
|
|
61522
61564
|
return err3 ? (
|
|
61523
61565
|
/* istanbul ignore next: should never error */
|
|
61524
61566
|
reject(err3)
|
|
61525
|
-
) :
|
|
61567
|
+
) : resolve11(data);
|
|
61526
61568
|
});
|
|
61527
61569
|
});
|
|
61528
61570
|
}
|
|
@@ -63789,8 +63831,8 @@ var require_util2 = __commonJS({
|
|
|
63789
63831
|
function createDeferredPromise() {
|
|
63790
63832
|
let res;
|
|
63791
63833
|
let rej;
|
|
63792
|
-
const promise2 = new Promise((
|
|
63793
|
-
res =
|
|
63834
|
+
const promise2 = new Promise((resolve11, reject) => {
|
|
63835
|
+
res = resolve11;
|
|
63794
63836
|
rej = reject;
|
|
63795
63837
|
});
|
|
63796
63838
|
return { promise: promise2, resolve: res, reject: rej };
|
|
@@ -65931,12 +65973,12 @@ upgrade: ${upgrade}\r
|
|
|
65931
65973
|
cb();
|
|
65932
65974
|
}
|
|
65933
65975
|
}
|
|
65934
|
-
const waitForDrain = () => new Promise((
|
|
65976
|
+
const waitForDrain = () => new Promise((resolve11, reject) => {
|
|
65935
65977
|
assert2(callback === null);
|
|
65936
65978
|
if (socket[kError]) {
|
|
65937
65979
|
reject(socket[kError]);
|
|
65938
65980
|
} else {
|
|
65939
|
-
callback =
|
|
65981
|
+
callback = resolve11;
|
|
65940
65982
|
}
|
|
65941
65983
|
});
|
|
65942
65984
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -66573,12 +66615,12 @@ var require_client_h2 = __commonJS({
|
|
|
66573
66615
|
cb();
|
|
66574
66616
|
}
|
|
66575
66617
|
}
|
|
66576
|
-
const waitForDrain = () => new Promise((
|
|
66618
|
+
const waitForDrain = () => new Promise((resolve11, reject) => {
|
|
66577
66619
|
assert2(callback === null);
|
|
66578
66620
|
if (socket[kError]) {
|
|
66579
66621
|
reject(socket[kError]);
|
|
66580
66622
|
} else {
|
|
66581
|
-
callback =
|
|
66623
|
+
callback = resolve11;
|
|
66582
66624
|
}
|
|
66583
66625
|
});
|
|
66584
66626
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -67055,16 +67097,16 @@ var require_client = __commonJS({
|
|
|
67055
67097
|
return this[kNeedDrain] < 2;
|
|
67056
67098
|
}
|
|
67057
67099
|
async [kClose]() {
|
|
67058
|
-
return new Promise((
|
|
67100
|
+
return new Promise((resolve11) => {
|
|
67059
67101
|
if (this[kSize]) {
|
|
67060
|
-
this[kClosedResolve] =
|
|
67102
|
+
this[kClosedResolve] = resolve11;
|
|
67061
67103
|
} else {
|
|
67062
|
-
|
|
67104
|
+
resolve11(null);
|
|
67063
67105
|
}
|
|
67064
67106
|
});
|
|
67065
67107
|
}
|
|
67066
67108
|
async [kDestroy](err2) {
|
|
67067
|
-
return new Promise((
|
|
67109
|
+
return new Promise((resolve11) => {
|
|
67068
67110
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
67069
67111
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
67070
67112
|
const request = requests[i2];
|
|
@@ -67075,7 +67117,7 @@ var require_client = __commonJS({
|
|
|
67075
67117
|
this[kClosedResolve]();
|
|
67076
67118
|
this[kClosedResolve] = null;
|
|
67077
67119
|
}
|
|
67078
|
-
|
|
67120
|
+
resolve11(null);
|
|
67079
67121
|
};
|
|
67080
67122
|
if (this[kHTTPContext]) {
|
|
67081
67123
|
this[kHTTPContext].destroy(err2, callback);
|
|
@@ -67126,7 +67168,7 @@ var require_client = __commonJS({
|
|
|
67126
67168
|
});
|
|
67127
67169
|
}
|
|
67128
67170
|
try {
|
|
67129
|
-
const socket = await new Promise((
|
|
67171
|
+
const socket = await new Promise((resolve11, reject) => {
|
|
67130
67172
|
client[kConnector]({
|
|
67131
67173
|
host,
|
|
67132
67174
|
hostname: hostname3,
|
|
@@ -67138,7 +67180,7 @@ var require_client = __commonJS({
|
|
|
67138
67180
|
if (err2) {
|
|
67139
67181
|
reject(err2);
|
|
67140
67182
|
} else {
|
|
67141
|
-
|
|
67183
|
+
resolve11(socket2);
|
|
67142
67184
|
}
|
|
67143
67185
|
});
|
|
67144
67186
|
});
|
|
@@ -67474,8 +67516,8 @@ var require_pool_base = __commonJS({
|
|
|
67474
67516
|
if (this[kQueue].isEmpty()) {
|
|
67475
67517
|
await Promise.all(this[kClients].map((c) => c.close()));
|
|
67476
67518
|
} else {
|
|
67477
|
-
await new Promise((
|
|
67478
|
-
this[kClosedResolve] =
|
|
67519
|
+
await new Promise((resolve11) => {
|
|
67520
|
+
this[kClosedResolve] = resolve11;
|
|
67479
67521
|
});
|
|
67480
67522
|
}
|
|
67481
67523
|
}
|
|
@@ -68690,7 +68732,7 @@ var require_readable = __commonJS({
|
|
|
68690
68732
|
if (this._readableState.closeEmitted) {
|
|
68691
68733
|
return null;
|
|
68692
68734
|
}
|
|
68693
|
-
return await new Promise((
|
|
68735
|
+
return await new Promise((resolve11, reject) => {
|
|
68694
68736
|
if (this[kContentLength] > limit) {
|
|
68695
68737
|
this.destroy(new AbortError());
|
|
68696
68738
|
}
|
|
@@ -68703,7 +68745,7 @@ var require_readable = __commonJS({
|
|
|
68703
68745
|
if (signal?.aborted) {
|
|
68704
68746
|
reject(signal.reason ?? new AbortError());
|
|
68705
68747
|
} else {
|
|
68706
|
-
|
|
68748
|
+
resolve11(null);
|
|
68707
68749
|
}
|
|
68708
68750
|
}).on("error", noop).on("data", function(chunk) {
|
|
68709
68751
|
limit -= chunk.length;
|
|
@@ -68722,7 +68764,7 @@ var require_readable = __commonJS({
|
|
|
68722
68764
|
}
|
|
68723
68765
|
async function consume(stream, type) {
|
|
68724
68766
|
assert2(!stream[kConsume]);
|
|
68725
|
-
return new Promise((
|
|
68767
|
+
return new Promise((resolve11, reject) => {
|
|
68726
68768
|
if (isUnusable(stream)) {
|
|
68727
68769
|
const rState = stream._readableState;
|
|
68728
68770
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -68739,7 +68781,7 @@ var require_readable = __commonJS({
|
|
|
68739
68781
|
stream[kConsume] = {
|
|
68740
68782
|
type,
|
|
68741
68783
|
stream,
|
|
68742
|
-
resolve:
|
|
68784
|
+
resolve: resolve11,
|
|
68743
68785
|
reject,
|
|
68744
68786
|
length: 0,
|
|
68745
68787
|
body: []
|
|
@@ -68809,18 +68851,18 @@ var require_readable = __commonJS({
|
|
|
68809
68851
|
return buffer;
|
|
68810
68852
|
}
|
|
68811
68853
|
function consumeEnd(consume2) {
|
|
68812
|
-
const { type, body: body2, resolve:
|
|
68854
|
+
const { type, body: body2, resolve: resolve11, stream, length } = consume2;
|
|
68813
68855
|
try {
|
|
68814
68856
|
if (type === "text") {
|
|
68815
|
-
|
|
68857
|
+
resolve11(chunksDecode(body2, length));
|
|
68816
68858
|
} else if (type === "json") {
|
|
68817
|
-
|
|
68859
|
+
resolve11(JSON.parse(chunksDecode(body2, length)));
|
|
68818
68860
|
} else if (type === "arrayBuffer") {
|
|
68819
|
-
|
|
68861
|
+
resolve11(chunksConcat(body2, length).buffer);
|
|
68820
68862
|
} else if (type === "blob") {
|
|
68821
|
-
|
|
68863
|
+
resolve11(new Blob(body2, { type: stream[kContentType] }));
|
|
68822
68864
|
} else if (type === "bytes") {
|
|
68823
|
-
|
|
68865
|
+
resolve11(chunksConcat(body2, length));
|
|
68824
68866
|
}
|
|
68825
68867
|
consumeFinish(consume2);
|
|
68826
68868
|
} catch (err2) {
|
|
@@ -69077,9 +69119,9 @@ var require_api_request = __commonJS({
|
|
|
69077
69119
|
};
|
|
69078
69120
|
function request(opts, callback) {
|
|
69079
69121
|
if (callback === void 0) {
|
|
69080
|
-
return new Promise((
|
|
69122
|
+
return new Promise((resolve11, reject) => {
|
|
69081
69123
|
request.call(this, opts, (err2, data) => {
|
|
69082
|
-
return err2 ? reject(err2) :
|
|
69124
|
+
return err2 ? reject(err2) : resolve11(data);
|
|
69083
69125
|
});
|
|
69084
69126
|
});
|
|
69085
69127
|
}
|
|
@@ -69302,9 +69344,9 @@ var require_api_stream = __commonJS({
|
|
|
69302
69344
|
};
|
|
69303
69345
|
function stream(opts, factory, callback) {
|
|
69304
69346
|
if (callback === void 0) {
|
|
69305
|
-
return new Promise((
|
|
69347
|
+
return new Promise((resolve11, reject) => {
|
|
69306
69348
|
stream.call(this, opts, factory, (err2, data) => {
|
|
69307
|
-
return err2 ? reject(err2) :
|
|
69349
|
+
return err2 ? reject(err2) : resolve11(data);
|
|
69308
69350
|
});
|
|
69309
69351
|
});
|
|
69310
69352
|
}
|
|
@@ -69589,9 +69631,9 @@ var require_api_upgrade = __commonJS({
|
|
|
69589
69631
|
};
|
|
69590
69632
|
function upgrade(opts, callback) {
|
|
69591
69633
|
if (callback === void 0) {
|
|
69592
|
-
return new Promise((
|
|
69634
|
+
return new Promise((resolve11, reject) => {
|
|
69593
69635
|
upgrade.call(this, opts, (err2, data) => {
|
|
69594
|
-
return err2 ? reject(err2) :
|
|
69636
|
+
return err2 ? reject(err2) : resolve11(data);
|
|
69595
69637
|
});
|
|
69596
69638
|
});
|
|
69597
69639
|
}
|
|
@@ -69683,9 +69725,9 @@ var require_api_connect = __commonJS({
|
|
|
69683
69725
|
};
|
|
69684
69726
|
function connect(opts, callback) {
|
|
69685
69727
|
if (callback === void 0) {
|
|
69686
|
-
return new Promise((
|
|
69728
|
+
return new Promise((resolve11, reject) => {
|
|
69687
69729
|
connect.call(this, opts, (err2, data) => {
|
|
69688
|
-
return err2 ? reject(err2) :
|
|
69730
|
+
return err2 ? reject(err2) : resolve11(data);
|
|
69689
69731
|
});
|
|
69690
69732
|
});
|
|
69691
69733
|
}
|
|
@@ -73547,7 +73589,7 @@ var require_fetch = __commonJS({
|
|
|
73547
73589
|
function dispatch({ body: body2 }) {
|
|
73548
73590
|
const url2 = requestCurrentURL(request);
|
|
73549
73591
|
const agent = fetchParams.controller.dispatcher;
|
|
73550
|
-
return new Promise((
|
|
73592
|
+
return new Promise((resolve11, reject) => agent.dispatch(
|
|
73551
73593
|
{
|
|
73552
73594
|
path: url2.pathname + url2.search,
|
|
73553
73595
|
origin: url2.origin,
|
|
@@ -73623,7 +73665,7 @@ var require_fetch = __commonJS({
|
|
|
73623
73665
|
}
|
|
73624
73666
|
}
|
|
73625
73667
|
const onError = this.onError.bind(this);
|
|
73626
|
-
|
|
73668
|
+
resolve11({
|
|
73627
73669
|
status,
|
|
73628
73670
|
statusText,
|
|
73629
73671
|
headersList,
|
|
@@ -73669,7 +73711,7 @@ var require_fetch = __commonJS({
|
|
|
73669
73711
|
for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
|
|
73670
73712
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
|
|
73671
73713
|
}
|
|
73672
|
-
|
|
73714
|
+
resolve11({
|
|
73673
73715
|
status,
|
|
73674
73716
|
statusText: STATUS_CODES[status],
|
|
73675
73717
|
headersList,
|
|
@@ -77308,8 +77350,8 @@ var require_util8 = __commonJS({
|
|
|
77308
77350
|
return true;
|
|
77309
77351
|
}
|
|
77310
77352
|
function delay(ms) {
|
|
77311
|
-
return new Promise((
|
|
77312
|
-
setTimeout(
|
|
77353
|
+
return new Promise((resolve11) => {
|
|
77354
|
+
setTimeout(resolve11, ms).unref();
|
|
77313
77355
|
});
|
|
77314
77356
|
}
|
|
77315
77357
|
module2.exports = {
|
|
@@ -77997,16 +78039,16 @@ __export(witness_ledger_exports, {
|
|
|
77997
78039
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
77998
78040
|
witnessLedgerPath: () => witnessLedgerPath
|
|
77999
78041
|
});
|
|
78000
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
78001
|
-
import { join as
|
|
78042
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync28, readFileSync as readFileSync32, writeFileSync as writeFileSync22 } from "node:fs";
|
|
78043
|
+
import { join as join36 } from "node:path";
|
|
78002
78044
|
function witnessLedgerPath(configDir) {
|
|
78003
|
-
return
|
|
78045
|
+
return join36(configDir, "witness-ledger.jsonl");
|
|
78004
78046
|
}
|
|
78005
78047
|
function appendWitnessLedger(configDir, entry) {
|
|
78006
78048
|
const path3 = witnessLedgerPath(configDir);
|
|
78007
78049
|
try {
|
|
78008
78050
|
appendFileSync3(path3, JSON.stringify(entry) + "\n");
|
|
78009
|
-
const lines =
|
|
78051
|
+
const lines = readFileSync32(path3, "utf8").split("\n").filter(Boolean);
|
|
78010
78052
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
78011
78053
|
writeFileSync22(path3, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
78012
78054
|
}
|
|
@@ -78015,9 +78057,9 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
78015
78057
|
}
|
|
78016
78058
|
function readWitnessLedger(configDir) {
|
|
78017
78059
|
const path3 = witnessLedgerPath(configDir);
|
|
78018
|
-
if (!
|
|
78060
|
+
if (!existsSync28(path3)) return [];
|
|
78019
78061
|
try {
|
|
78020
|
-
return
|
|
78062
|
+
return readFileSync32(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
|
|
78021
78063
|
} catch {
|
|
78022
78064
|
return [];
|
|
78023
78065
|
}
|
|
@@ -78456,12 +78498,12 @@ var init_report_render = __esm({
|
|
|
78456
78498
|
|
|
78457
78499
|
// src/cli.ts
|
|
78458
78500
|
init_src6();
|
|
78459
|
-
import { closeSync as closeSync3, existsSync as
|
|
78460
|
-
import { join as
|
|
78501
|
+
import { closeSync as closeSync3, existsSync as existsSync41, openSync as openSync3, readFileSync as readFileSync49, renameSync as renameSync10, statSync as statSync17 } from "node:fs";
|
|
78502
|
+
import { join as join57, resolve as pathResolve2 } from "node:path";
|
|
78461
78503
|
import { spawn as spawn5 } from "node:child_process";
|
|
78462
78504
|
|
|
78463
78505
|
// src/daemon.ts
|
|
78464
|
-
import { existsSync as
|
|
78506
|
+
import { existsSync as existsSync30, writeFileSync as writeFileSync25 } from "node:fs";
|
|
78465
78507
|
|
|
78466
78508
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.34/node_modules/@hono/node-server/dist/index.mjs
|
|
78467
78509
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -78891,7 +78933,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
78891
78933
|
});
|
|
78892
78934
|
if (!chunk) {
|
|
78893
78935
|
if (i2 === 1) {
|
|
78894
|
-
await new Promise((
|
|
78936
|
+
await new Promise((resolve11) => setTimeout(resolve11));
|
|
78895
78937
|
maxReadCount = 3;
|
|
78896
78938
|
continue;
|
|
78897
78939
|
}
|
|
@@ -79040,6 +79082,32 @@ init_webui();
|
|
|
79040
79082
|
init_config();
|
|
79041
79083
|
init_lock();
|
|
79042
79084
|
|
|
79085
|
+
// src/replay-checkout.ts
|
|
79086
|
+
import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync7 } from "node:fs";
|
|
79087
|
+
import { dirname as dirname9, isAbsolute as isAbsolute4, join as join19, resolve as resolve6 } from "node:path";
|
|
79088
|
+
var REPLAY_MARKER = "errata-replay";
|
|
79089
|
+
function gitDirOf(cwd) {
|
|
79090
|
+
for (let dir = resolve6(cwd); ; dir = dirname9(dir)) {
|
|
79091
|
+
const dotGit = join19(dir, ".git");
|
|
79092
|
+
if (existsSync19(dotGit)) {
|
|
79093
|
+
try {
|
|
79094
|
+
if (statSync7(dotGit).isDirectory()) return dotGit;
|
|
79095
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync18(dotGit, "utf8"));
|
|
79096
|
+
if (!m) return null;
|
|
79097
|
+
const target = m[1].trim();
|
|
79098
|
+
return isAbsolute4(target) ? target : resolve6(dir, target);
|
|
79099
|
+
} catch {
|
|
79100
|
+
return null;
|
|
79101
|
+
}
|
|
79102
|
+
}
|
|
79103
|
+
if (dirname9(dir) === dir) return null;
|
|
79104
|
+
}
|
|
79105
|
+
}
|
|
79106
|
+
function isReplayCheckout(cwd) {
|
|
79107
|
+
const gitDir = gitDirOf(cwd);
|
|
79108
|
+
return gitDir != null && existsSync19(join19(gitDir, REPLAY_MARKER));
|
|
79109
|
+
}
|
|
79110
|
+
|
|
79043
79111
|
// src/activity-feed.ts
|
|
79044
79112
|
var LABEL_MAX = 120;
|
|
79045
79113
|
var DEFAULT_TAIL = 20;
|
|
@@ -79145,8 +79213,8 @@ function knowledgeTag(label, attrs) {
|
|
|
79145
79213
|
|
|
79146
79214
|
// src/engine.ts
|
|
79147
79215
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
79148
|
-
import { existsSync as
|
|
79149
|
-
import { basename as basename8, join as
|
|
79216
|
+
import { existsSync as existsSync29, statSync as statSync12, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync34, writeFileSync as writeFileSync24 } from "node:fs";
|
|
79217
|
+
import { basename as basename8, join as join38, relative as relative6, sep as sep5 } from "node:path";
|
|
79150
79218
|
|
|
79151
79219
|
// src/coalesced-file-pass.ts
|
|
79152
79220
|
function createCoalescedFilePass(delayMs, run3, onError) {
|
|
@@ -79190,8 +79258,8 @@ function createCoalescedFilePass(delayMs, run3, onError) {
|
|
|
79190
79258
|
|
|
79191
79259
|
// src/source-watcher.ts
|
|
79192
79260
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
79193
|
-
import { readdirSync as readdirSync6, statSync as
|
|
79194
|
-
import { join as
|
|
79261
|
+
import { readdirSync as readdirSync6, statSync as statSync8, watch as watch2 } from "node:fs";
|
|
79262
|
+
import { join as join22, sep as sep4 } from "node:path";
|
|
79195
79263
|
|
|
79196
79264
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
79197
79265
|
import { stat as statcb } from "fs";
|
|
@@ -79922,9 +79990,9 @@ var NodeFsHandler = class {
|
|
|
79922
79990
|
if (this.fsw.closed) {
|
|
79923
79991
|
return;
|
|
79924
79992
|
}
|
|
79925
|
-
const
|
|
79993
|
+
const dirname22 = sysPath.dirname(file2);
|
|
79926
79994
|
const basename11 = sysPath.basename(file2);
|
|
79927
|
-
const parent = this.fsw._getWatchedDir(
|
|
79995
|
+
const parent = this.fsw._getWatchedDir(dirname22);
|
|
79928
79996
|
let prevStats = stats;
|
|
79929
79997
|
if (parent.has(basename11))
|
|
79930
79998
|
return;
|
|
@@ -79951,7 +80019,7 @@ var NodeFsHandler = class {
|
|
|
79951
80019
|
prevStats = newStats2;
|
|
79952
80020
|
}
|
|
79953
80021
|
} catch (error48) {
|
|
79954
|
-
this.fsw._remove(
|
|
80022
|
+
this.fsw._remove(dirname22, basename11);
|
|
79955
80023
|
}
|
|
79956
80024
|
} else if (parent.has(basename11)) {
|
|
79957
80025
|
const at = newStats.atimeMs;
|
|
@@ -80047,7 +80115,7 @@ var NodeFsHandler = class {
|
|
|
80047
80115
|
this._addToNodeFs(path3, initialAdd, wh, depth + 1);
|
|
80048
80116
|
}
|
|
80049
80117
|
}).on(EV.ERROR, this._boundHandleError);
|
|
80050
|
-
return new Promise((
|
|
80118
|
+
return new Promise((resolve11, reject) => {
|
|
80051
80119
|
if (!stream)
|
|
80052
80120
|
return reject();
|
|
80053
80121
|
stream.once(STR_END, () => {
|
|
@@ -80056,7 +80124,7 @@ var NodeFsHandler = class {
|
|
|
80056
80124
|
return;
|
|
80057
80125
|
}
|
|
80058
80126
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
80059
|
-
|
|
80127
|
+
resolve11(void 0);
|
|
80060
80128
|
previous.getChildren().filter((item2) => {
|
|
80061
80129
|
return item2 !== directory && !current.has(item2);
|
|
80062
80130
|
}).forEach((item2) => {
|
|
@@ -80921,13 +80989,13 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
80921
80989
|
if (this.closed || this.handles.has(target)) return;
|
|
80922
80990
|
let isDir;
|
|
80923
80991
|
try {
|
|
80924
|
-
isDir =
|
|
80992
|
+
isDir = statSync8(target).isDirectory();
|
|
80925
80993
|
} catch {
|
|
80926
80994
|
return;
|
|
80927
80995
|
}
|
|
80928
80996
|
try {
|
|
80929
80997
|
const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
|
|
80930
|
-
const path3 = isDir ? name2 ?
|
|
80998
|
+
const path3 = isDir ? name2 ? join22(target, name2.toString()) : null : target;
|
|
80931
80999
|
if (!path3) {
|
|
80932
81000
|
this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
|
|
80933
81001
|
this.scheduleReconcile(target, isDir);
|
|
@@ -80975,7 +81043,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
80975
81043
|
const files = /* @__PURE__ */ new Map();
|
|
80976
81044
|
const add = (path3) => {
|
|
80977
81045
|
try {
|
|
80978
|
-
files.set(path3, signature(
|
|
81046
|
+
files.set(path3, signature(statSync8(path3)));
|
|
80979
81047
|
} catch {
|
|
80980
81048
|
}
|
|
80981
81049
|
};
|
|
@@ -80993,7 +81061,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
80993
81061
|
continue;
|
|
80994
81062
|
}
|
|
80995
81063
|
for (const entry of entries) {
|
|
80996
|
-
const path3 =
|
|
81064
|
+
const path3 = join22(dir, entry.name);
|
|
80997
81065
|
if (this.ignored(path3)) continue;
|
|
80998
81066
|
if (entry.isDirectory()) dirs.push(path3);
|
|
80999
81067
|
else if (entry.isFile()) add(path3);
|
|
@@ -81030,7 +81098,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
81030
81098
|
let isFile;
|
|
81031
81099
|
let sig;
|
|
81032
81100
|
try {
|
|
81033
|
-
const s =
|
|
81101
|
+
const s = statSync8(path3);
|
|
81034
81102
|
if (s.isDirectory()) return;
|
|
81035
81103
|
isFile = s.isFile();
|
|
81036
81104
|
sig = signature(s);
|
|
@@ -81304,9 +81372,9 @@ init_src6();
|
|
|
81304
81372
|
init_session_registry();
|
|
81305
81373
|
|
|
81306
81374
|
// src/snapshot-reuse.ts
|
|
81307
|
-
import { readFileSync as
|
|
81375
|
+
import { readFileSync as readFileSync19, renameSync as renameSync3, statSync as statSync9, writeFileSync as writeFileSync14 } from "node:fs";
|
|
81308
81376
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
81309
|
-
import { dirname as
|
|
81377
|
+
import { dirname as dirname12, join as join23 } from "node:path";
|
|
81310
81378
|
function revisitFlagsUnchanged(store, held, flaggedNow) {
|
|
81311
81379
|
if (held.anySeq === void 0 || held.revisitIds === void 0 || !store.changedAmong) return false;
|
|
81312
81380
|
const watched = [.../* @__PURE__ */ new Set([...held.revisitIds, ...flaggedNow])];
|
|
@@ -81322,7 +81390,7 @@ function snapshotCodeIdentity(version3) {
|
|
|
81322
81390
|
if (codeIdentityMemo === void 0) {
|
|
81323
81391
|
let built = "unknown";
|
|
81324
81392
|
try {
|
|
81325
|
-
built = String(
|
|
81393
|
+
built = String(statSync9(fileURLToPath2(import.meta.url)).mtimeMs);
|
|
81326
81394
|
} catch {
|
|
81327
81395
|
}
|
|
81328
81396
|
codeIdentityMemo = `${version3}@${built}`;
|
|
@@ -81330,11 +81398,11 @@ function snapshotCodeIdentity(version3) {
|
|
|
81330
81398
|
return codeIdentityMemo;
|
|
81331
81399
|
}
|
|
81332
81400
|
function heldSnapshotPath(configDir) {
|
|
81333
|
-
return
|
|
81401
|
+
return join23(configDir, "snapshot-held.json");
|
|
81334
81402
|
}
|
|
81335
81403
|
function loadHeldSnapshot(path3) {
|
|
81336
81404
|
try {
|
|
81337
|
-
const held = JSON.parse(
|
|
81405
|
+
const held = JSON.parse(readFileSync19(path3, "utf8"));
|
|
81338
81406
|
return typeof held?.key === "string" && typeof held.at === "number" ? held : null;
|
|
81339
81407
|
} catch {
|
|
81340
81408
|
return null;
|
|
@@ -81342,7 +81410,7 @@ function loadHeldSnapshot(path3) {
|
|
|
81342
81410
|
}
|
|
81343
81411
|
function saveHeldSnapshot(path3, held) {
|
|
81344
81412
|
try {
|
|
81345
|
-
const tmp =
|
|
81413
|
+
const tmp = join23(dirname12(path3), `.${process.pid}.snapshot-held.tmp`);
|
|
81346
81414
|
writeFileSync14(tmp, JSON.stringify(held));
|
|
81347
81415
|
renameSync3(tmp, path3);
|
|
81348
81416
|
} catch {
|
|
@@ -81538,8 +81606,8 @@ init_review2();
|
|
|
81538
81606
|
|
|
81539
81607
|
// src/turn.ts
|
|
81540
81608
|
init_checkout_root();
|
|
81541
|
-
import { closeSync as closeSync2, existsSync as
|
|
81542
|
-
import { basename as basename6, delimiter, dirname as
|
|
81609
|
+
import { closeSync as closeSync2, existsSync as existsSync20, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
|
|
81610
|
+
import { basename as basename6, delimiter, dirname as dirname13, join as join24, normalize as normalize3 } from "node:path";
|
|
81543
81611
|
import { homedir as homedir4 } from "node:os";
|
|
81544
81612
|
import { createHash as createHash16 } from "node:crypto";
|
|
81545
81613
|
function completeJsonlPrefix(buf) {
|
|
@@ -81927,11 +81995,11 @@ function turnsSince(turns, mark) {
|
|
|
81927
81995
|
return at >= 0 ? turns.slice(at + 1) : turns;
|
|
81928
81996
|
}
|
|
81929
81997
|
function claudeProjectDir(cwd, home = homedir4()) {
|
|
81930
|
-
return
|
|
81998
|
+
return join24(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
|
|
81931
81999
|
}
|
|
81932
82000
|
function recentTranscripts(cwd, opts = {}) {
|
|
81933
82001
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
81934
|
-
if (!
|
|
82002
|
+
if (!existsSync20(dir)) return [];
|
|
81935
82003
|
let names;
|
|
81936
82004
|
try {
|
|
81937
82005
|
names = readdirSync7(dir);
|
|
@@ -81942,10 +82010,10 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
81942
82010
|
const refs = [];
|
|
81943
82011
|
for (const name2 of names) {
|
|
81944
82012
|
if (!name2.endsWith(".jsonl")) continue;
|
|
81945
|
-
const path3 =
|
|
82013
|
+
const path3 = join24(dir, name2);
|
|
81946
82014
|
let mtimeMs;
|
|
81947
82015
|
try {
|
|
81948
|
-
mtimeMs =
|
|
82016
|
+
mtimeMs = statSync10(path3).mtimeMs;
|
|
81949
82017
|
} catch {
|
|
81950
82018
|
continue;
|
|
81951
82019
|
}
|
|
@@ -81957,8 +82025,8 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
81957
82025
|
}
|
|
81958
82026
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
81959
82027
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
81960
|
-
const dir =
|
|
81961
|
-
if (!
|
|
82028
|
+
const dir = join24(dirname13(mainTranscriptPath), sessionId, "subagents");
|
|
82029
|
+
if (!existsSync20(dir)) return [];
|
|
81962
82030
|
let names;
|
|
81963
82031
|
try {
|
|
81964
82032
|
names = readdirSync7(dir);
|
|
@@ -81968,10 +82036,10 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
81968
82036
|
const refs = [];
|
|
81969
82037
|
for (const name2 of names) {
|
|
81970
82038
|
if (!name2.endsWith(".jsonl")) continue;
|
|
81971
|
-
const path3 =
|
|
82039
|
+
const path3 = join24(dir, name2);
|
|
81972
82040
|
let mtimeMs;
|
|
81973
82041
|
try {
|
|
81974
|
-
mtimeMs =
|
|
82042
|
+
mtimeMs = statSync10(path3).mtimeMs;
|
|
81975
82043
|
} catch {
|
|
81976
82044
|
continue;
|
|
81977
82045
|
}
|
|
@@ -81987,8 +82055,8 @@ function splitPathList(value, sep7 = delimiter) {
|
|
|
81987
82055
|
function codexSessionRoots(env2 = process.env, home = homedir4()) {
|
|
81988
82056
|
const roots = /* @__PURE__ */ new Set();
|
|
81989
82057
|
for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
|
|
81990
|
-
if (env2["CODEX_HOME"]) roots.add(
|
|
81991
|
-
roots.add(
|
|
82058
|
+
if (env2["CODEX_HOME"]) roots.add(join24(env2["CODEX_HOME"], "sessions"));
|
|
82059
|
+
roots.add(join24(home, ".codex", "sessions"));
|
|
81992
82060
|
return [...roots];
|
|
81993
82061
|
}
|
|
81994
82062
|
function readCodexRolloutIdentity(path3) {
|
|
@@ -82042,7 +82110,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82042
82110
|
const owner = checkoutRootOf(cwd);
|
|
82043
82111
|
const owners = /* @__PURE__ */ new Map();
|
|
82044
82112
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
82045
|
-
if (!
|
|
82113
|
+
if (!existsSync20(root)) {
|
|
82046
82114
|
codexRolloutActivity.delete(root);
|
|
82047
82115
|
continue;
|
|
82048
82116
|
}
|
|
@@ -82060,10 +82128,10 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82060
82128
|
continue;
|
|
82061
82129
|
}
|
|
82062
82130
|
for (const name2 of names) {
|
|
82063
|
-
const full =
|
|
82131
|
+
const full = join24(dir, name2);
|
|
82064
82132
|
let st;
|
|
82065
82133
|
try {
|
|
82066
|
-
st =
|
|
82134
|
+
st = statSync10(full);
|
|
82067
82135
|
} catch {
|
|
82068
82136
|
continue;
|
|
82069
82137
|
}
|
|
@@ -82102,8 +82170,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82102
82170
|
function geminiSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82103
82171
|
const roots = /* @__PURE__ */ new Set();
|
|
82104
82172
|
for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
|
|
82105
|
-
if (env2["GEMINI_CLI_HOME"]) roots.add(
|
|
82106
|
-
roots.add(
|
|
82173
|
+
if (env2["GEMINI_CLI_HOME"]) roots.add(join24(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
|
|
82174
|
+
roots.add(join24(home, ".gemini", "tmp"));
|
|
82107
82175
|
return [...roots];
|
|
82108
82176
|
}
|
|
82109
82177
|
function geminiProjectHash(cwd) {
|
|
@@ -82143,7 +82211,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82143
82211
|
const hashes = geminiHashesFor(cwd);
|
|
82144
82212
|
const out2 = [];
|
|
82145
82213
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
82146
|
-
if (!
|
|
82214
|
+
if (!existsSync20(root)) continue;
|
|
82147
82215
|
let slugs;
|
|
82148
82216
|
try {
|
|
82149
82217
|
slugs = readdirSync7(root);
|
|
@@ -82151,7 +82219,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82151
82219
|
continue;
|
|
82152
82220
|
}
|
|
82153
82221
|
for (const slug2 of slugs) {
|
|
82154
|
-
const chats =
|
|
82222
|
+
const chats = join24(root, slug2, "chats");
|
|
82155
82223
|
let names;
|
|
82156
82224
|
try {
|
|
82157
82225
|
names = readdirSync7(chats);
|
|
@@ -82160,10 +82228,10 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82160
82228
|
}
|
|
82161
82229
|
for (const name2 of names) {
|
|
82162
82230
|
if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
|
|
82163
|
-
const full =
|
|
82231
|
+
const full = join24(chats, name2);
|
|
82164
82232
|
let st;
|
|
82165
82233
|
try {
|
|
82166
|
-
st =
|
|
82234
|
+
st = statSync10(full);
|
|
82167
82235
|
} catch {
|
|
82168
82236
|
continue;
|
|
82169
82237
|
}
|
|
@@ -82180,8 +82248,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82180
82248
|
function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82181
82249
|
const roots = /* @__PURE__ */ new Set();
|
|
82182
82250
|
for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
|
|
82183
|
-
if (env2["XDG_DATA_HOME"]) roots.add(
|
|
82184
|
-
roots.add(
|
|
82251
|
+
if (env2["XDG_DATA_HOME"]) roots.add(join24(env2["XDG_DATA_HOME"], "opencode", "errata"));
|
|
82252
|
+
roots.add(join24(home, ".local", "share", "opencode", "errata"));
|
|
82185
82253
|
return [...roots];
|
|
82186
82254
|
}
|
|
82187
82255
|
function readOpencodeTranscriptDirectory(path3) {
|
|
@@ -82214,7 +82282,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82214
82282
|
}
|
|
82215
82283
|
const out2 = [];
|
|
82216
82284
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
82217
|
-
if (!
|
|
82285
|
+
if (!existsSync20(root)) continue;
|
|
82218
82286
|
let names;
|
|
82219
82287
|
try {
|
|
82220
82288
|
names = readdirSync7(root);
|
|
@@ -82223,10 +82291,10 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82223
82291
|
}
|
|
82224
82292
|
for (const name2 of names) {
|
|
82225
82293
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82226
|
-
const full =
|
|
82294
|
+
const full = join24(root, name2);
|
|
82227
82295
|
let st;
|
|
82228
82296
|
try {
|
|
82229
|
-
st =
|
|
82297
|
+
st = statSync10(full);
|
|
82230
82298
|
} catch {
|
|
82231
82299
|
continue;
|
|
82232
82300
|
}
|
|
@@ -82246,7 +82314,7 @@ init_src2();
|
|
|
82246
82314
|
init_agent_signals();
|
|
82247
82315
|
init_tool_index();
|
|
82248
82316
|
init_src5();
|
|
82249
|
-
import { readFileSync as
|
|
82317
|
+
import { readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
|
|
82250
82318
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
82251
82319
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
82252
82320
|
var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
|
|
@@ -83081,7 +83149,7 @@ function writePrimingHandles(path3, nodes, now = Date.now()) {
|
|
|
83081
83149
|
}
|
|
83082
83150
|
function readPrimingHandles(path3) {
|
|
83083
83151
|
try {
|
|
83084
|
-
return JSON.parse(
|
|
83152
|
+
return JSON.parse(readFileSync20(path3, "utf8"));
|
|
83085
83153
|
} catch {
|
|
83086
83154
|
return {};
|
|
83087
83155
|
}
|
|
@@ -83683,8 +83751,8 @@ ${conversation}` }]
|
|
|
83683
83751
|
// src/constraint-backfill.ts
|
|
83684
83752
|
init_src5();
|
|
83685
83753
|
init_src2();
|
|
83686
|
-
import { existsSync as
|
|
83687
|
-
import { join as
|
|
83754
|
+
import { existsSync as existsSync21, readFileSync as readFileSync21, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
83755
|
+
import { join as join25 } from "node:path";
|
|
83688
83756
|
import { homedir as homedir5 } from "node:os";
|
|
83689
83757
|
var BACKFILL_VERSION = 1;
|
|
83690
83758
|
var EMPTY = {
|
|
@@ -83698,13 +83766,13 @@ var EMPTY = {
|
|
|
83698
83766
|
recoverable: 0
|
|
83699
83767
|
};
|
|
83700
83768
|
function markerPath(configDir) {
|
|
83701
|
-
return
|
|
83769
|
+
return join25(configDir, "constraint-backfill.json");
|
|
83702
83770
|
}
|
|
83703
83771
|
function alreadyDone(configDir) {
|
|
83704
83772
|
const p = markerPath(configDir);
|
|
83705
|
-
if (!
|
|
83773
|
+
if (!existsSync21(p)) return false;
|
|
83706
83774
|
try {
|
|
83707
|
-
const raw2 = JSON.parse(
|
|
83775
|
+
const raw2 = JSON.parse(readFileSync21(p, "utf8"));
|
|
83708
83776
|
return raw2?.version === BACKFILL_VERSION;
|
|
83709
83777
|
} catch {
|
|
83710
83778
|
return false;
|
|
@@ -83714,7 +83782,7 @@ function replay(root) {
|
|
|
83714
83782
|
const statements2 = /* @__PURE__ */ new Set();
|
|
83715
83783
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
83716
83784
|
const dir = claudeProjectDir(root, homedir5());
|
|
83717
|
-
if (!
|
|
83785
|
+
if (!existsSync21(dir)) return { statements: statements2, citedByFix };
|
|
83718
83786
|
let names;
|
|
83719
83787
|
try {
|
|
83720
83788
|
names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -83724,7 +83792,7 @@ function replay(root) {
|
|
|
83724
83792
|
for (const f of names) {
|
|
83725
83793
|
let lines;
|
|
83726
83794
|
try {
|
|
83727
|
-
lines =
|
|
83795
|
+
lines = readFileSync21(join25(dir, f), "utf8").split("\n");
|
|
83728
83796
|
} catch {
|
|
83729
83797
|
continue;
|
|
83730
83798
|
}
|
|
@@ -83851,8 +83919,8 @@ function backfillConstraintKind(store, opts) {
|
|
|
83851
83919
|
// src/edge-repair.ts
|
|
83852
83920
|
init_src();
|
|
83853
83921
|
init_src5();
|
|
83854
|
-
import { existsSync as
|
|
83855
|
-
import { join as
|
|
83922
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22, writeFileSync as writeFileSync17 } from "node:fs";
|
|
83923
|
+
import { join as join26 } from "node:path";
|
|
83856
83924
|
function citeEdgeId(from, type, to) {
|
|
83857
83925
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
83858
83926
|
}
|
|
@@ -83867,13 +83935,13 @@ var EMPTY2 = {
|
|
|
83867
83935
|
byType: {}
|
|
83868
83936
|
};
|
|
83869
83937
|
function markerPath2(configDir) {
|
|
83870
|
-
return
|
|
83938
|
+
return join26(configDir, "edge-repair.json");
|
|
83871
83939
|
}
|
|
83872
83940
|
function alreadyDone2(configDir) {
|
|
83873
83941
|
const p = markerPath2(configDir);
|
|
83874
|
-
if (!
|
|
83942
|
+
if (!existsSync22(p)) return false;
|
|
83875
83943
|
try {
|
|
83876
|
-
return JSON.parse(
|
|
83944
|
+
return JSON.parse(readFileSync22(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
83877
83945
|
} catch {
|
|
83878
83946
|
return false;
|
|
83879
83947
|
}
|
|
@@ -83936,8 +84004,8 @@ function repairInvalidEdges(store, opts) {
|
|
|
83936
84004
|
init_reconcile();
|
|
83937
84005
|
|
|
83938
84006
|
// src/pass-ledger.ts
|
|
83939
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
83940
|
-
import { join as
|
|
84007
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync18 } from "node:fs";
|
|
84008
|
+
import { join as join27 } from "node:path";
|
|
83941
84009
|
|
|
83942
84010
|
// src/isolate-census.ts
|
|
83943
84011
|
var live2 = 0;
|
|
@@ -83968,7 +84036,7 @@ var HOUR_MS = 36e5;
|
|
|
83968
84036
|
var TRIM_EVERY = 50;
|
|
83969
84037
|
var appendsSinceTrim = /* @__PURE__ */ new Map();
|
|
83970
84038
|
function passLedgerPath(configDir) {
|
|
83971
|
-
return
|
|
84039
|
+
return join27(configDir, "pass-ledger.jsonl");
|
|
83972
84040
|
}
|
|
83973
84041
|
function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
83974
84042
|
const path3 = passLedgerPath(configDir);
|
|
@@ -84000,7 +84068,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84000
84068
|
return;
|
|
84001
84069
|
}
|
|
84002
84070
|
appendsSinceTrim.set(path3, 0);
|
|
84003
|
-
const lines =
|
|
84071
|
+
const lines = readFileSync23(path3, "utf8").split("\n").filter(Boolean);
|
|
84004
84072
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
84005
84073
|
const tailHours = /* @__PURE__ */ new Map();
|
|
84006
84074
|
const tailFloor = Date.now() - LEVEL_TAIL_DAYS * 24 * HOUR_MS;
|
|
@@ -84035,9 +84103,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84035
84103
|
}
|
|
84036
84104
|
function readPassLedger(configDir) {
|
|
84037
84105
|
const path3 = passLedgerPath(configDir);
|
|
84038
|
-
if (!
|
|
84106
|
+
if (!existsSync23(path3)) return [];
|
|
84039
84107
|
try {
|
|
84040
|
-
return
|
|
84108
|
+
return readFileSync23(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
84041
84109
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
84042
84110
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
84043
84111
|
} catch {
|
|
@@ -84393,8 +84461,8 @@ var PassWorker = class {
|
|
|
84393
84461
|
const id = this.nextId++;
|
|
84394
84462
|
try {
|
|
84395
84463
|
await this.ready;
|
|
84396
|
-
return await new Promise((
|
|
84397
|
-
this.pending.set(id, { resolve:
|
|
84464
|
+
return await new Promise((resolve11, reject) => {
|
|
84465
|
+
this.pending.set(id, { resolve: resolve11, reject });
|
|
84398
84466
|
this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
|
|
84399
84467
|
});
|
|
84400
84468
|
} finally {
|
|
@@ -84429,12 +84497,12 @@ var PassWorker = class {
|
|
|
84429
84497
|
});
|
|
84430
84498
|
noteIsolateSpawned();
|
|
84431
84499
|
this.worker = worker;
|
|
84432
|
-
this.ready = new Promise((
|
|
84500
|
+
this.ready = new Promise((resolve11, reject) => {
|
|
84433
84501
|
const onReady = (m) => {
|
|
84434
84502
|
if (m?.ready) {
|
|
84435
84503
|
worker.off("message", onReady);
|
|
84436
84504
|
worker.off("error", onErr);
|
|
84437
|
-
|
|
84505
|
+
resolve11();
|
|
84438
84506
|
}
|
|
84439
84507
|
};
|
|
84440
84508
|
const onErr = (err2) => reject(err2);
|
|
@@ -84480,11 +84548,11 @@ init_outbox();
|
|
|
84480
84548
|
init_src10();
|
|
84481
84549
|
init_src();
|
|
84482
84550
|
init_src2();
|
|
84483
|
-
import { readFileSync as
|
|
84484
|
-
import { join as
|
|
84551
|
+
import { readFileSync as readFileSync24 } from "node:fs";
|
|
84552
|
+
import { join as join28 } from "node:path";
|
|
84485
84553
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
84486
84554
|
try {
|
|
84487
|
-
return
|
|
84555
|
+
return readFileSync24(join28(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
84488
84556
|
} catch {
|
|
84489
84557
|
return [];
|
|
84490
84558
|
}
|
|
@@ -84867,9 +84935,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
84867
84935
|
// src/retrieval-stack.ts
|
|
84868
84936
|
init_src();
|
|
84869
84937
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
84870
|
-
import { existsSync as
|
|
84938
|
+
import { existsSync as existsSync24, readFileSync as readFileSync25, statSync as statSync11 } from "node:fs";
|
|
84871
84939
|
import { homedir as homedir6 } from "node:os";
|
|
84872
|
-
import { join as
|
|
84940
|
+
import { join as join29 } from "node:path";
|
|
84873
84941
|
var RETRIEVAL_STACK_CAP = 24;
|
|
84874
84942
|
var MANIFEST_SCAN_CAP = 400;
|
|
84875
84943
|
var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -85159,51 +85227,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
85159
85227
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
85160
85228
|
const read2 = (p) => {
|
|
85161
85229
|
try {
|
|
85162
|
-
return
|
|
85230
|
+
return readFileSync25(p, "utf8");
|
|
85163
85231
|
} catch {
|
|
85164
85232
|
return null;
|
|
85165
85233
|
}
|
|
85166
85234
|
};
|
|
85167
85235
|
const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
|
|
85168
85236
|
const home = homedir6();
|
|
85169
|
-
const npm = parseNpmrcPolicy(texts(
|
|
85237
|
+
const npm = parseNpmrcPolicy(texts(join29(root, ".npmrc"), join29(home, ".npmrc")));
|
|
85170
85238
|
const blocked = /* @__PURE__ */ new Set();
|
|
85171
85239
|
if (!npm.defaultPublic) blocked.add("npm");
|
|
85172
85240
|
if (pypiIndexIsPrivate(
|
|
85173
85241
|
texts(
|
|
85174
|
-
|
|
85175
|
-
|
|
85176
|
-
|
|
85177
|
-
|
|
85178
|
-
|
|
85179
|
-
|
|
85180
|
-
|
|
85242
|
+
join29(root, "pip.conf"),
|
|
85243
|
+
join29(root, "pip.ini"),
|
|
85244
|
+
join29(root, "pyproject.toml"),
|
|
85245
|
+
join29(root, "requirements.txt"),
|
|
85246
|
+
join29(home, ".pip", "pip.conf"),
|
|
85247
|
+
join29(home, ".config", "pip", "pip.conf"),
|
|
85248
|
+
join29(env2["APPDATA"] ?? home, "pip", "pip.ini")
|
|
85181
85249
|
)
|
|
85182
85250
|
)) {
|
|
85183
85251
|
blocked.add("pypi");
|
|
85184
85252
|
}
|
|
85185
85253
|
if (cargoRegistryIsPrivate(
|
|
85186
85254
|
texts(
|
|
85187
|
-
|
|
85188
|
-
|
|
85189
|
-
|
|
85190
|
-
|
|
85255
|
+
join29(root, ".cargo", "config.toml"),
|
|
85256
|
+
join29(root, ".cargo", "config"),
|
|
85257
|
+
join29(home, ".cargo", "config.toml"),
|
|
85258
|
+
join29(home, ".cargo", "config")
|
|
85191
85259
|
)
|
|
85192
85260
|
)) {
|
|
85193
85261
|
blocked.add("cargo");
|
|
85194
85262
|
}
|
|
85195
85263
|
if (nugetSourcesArePrivate(
|
|
85196
85264
|
texts(
|
|
85197
|
-
|
|
85198
|
-
|
|
85199
|
-
|
|
85200
|
-
|
|
85201
|
-
|
|
85265
|
+
join29(root, "NuGet.config"),
|
|
85266
|
+
join29(root, "nuget.config"),
|
|
85267
|
+
join29(root, "NuGet.Config"),
|
|
85268
|
+
join29(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
|
|
85269
|
+
join29(home, ".nuget", "NuGet", "NuGet.Config")
|
|
85202
85270
|
)
|
|
85203
85271
|
)) {
|
|
85204
85272
|
blocked.add("nuget");
|
|
85205
85273
|
}
|
|
85206
|
-
const goEnvFile = env2["GOENV"] ??
|
|
85274
|
+
const goEnvFile = env2["GOENV"] ?? join29(env2["APPDATA"] ?? join29(home, ".config"), "go", "env");
|
|
85207
85275
|
const goEnvText = read2(goEnvFile) ?? "";
|
|
85208
85276
|
const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
|
|
85209
85277
|
(k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
|
|
@@ -85214,10 +85282,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
|
85214
85282
|
env2["GONOSUMCHECK"],
|
|
85215
85283
|
...fromFile
|
|
85216
85284
|
]);
|
|
85217
|
-
const gemfiles = texts(
|
|
85285
|
+
const gemfiles = texts(join29(root, "Gemfile"));
|
|
85218
85286
|
if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
|
|
85219
85287
|
if (mavenReposArePrivate(
|
|
85220
|
-
texts(
|
|
85288
|
+
texts(join29(root, "pom.xml"), join29(home, ".m2", "settings.xml"))
|
|
85221
85289
|
)) {
|
|
85222
85290
|
blocked.add("maven");
|
|
85223
85291
|
}
|
|
@@ -85384,10 +85452,10 @@ function readDirectDependencies(root) {
|
|
|
85384
85452
|
const familiesSeen = /* @__PURE__ */ new Set();
|
|
85385
85453
|
for (const c of LOCKFILES) {
|
|
85386
85454
|
if (familiesSeen.has(c.family)) continue;
|
|
85387
|
-
const p =
|
|
85388
|
-
if (!
|
|
85455
|
+
const p = join29(root, c.file);
|
|
85456
|
+
if (!existsSync24(p)) continue;
|
|
85389
85457
|
try {
|
|
85390
|
-
const s =
|
|
85458
|
+
const s = statSync11(p);
|
|
85391
85459
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
85392
85460
|
} catch {
|
|
85393
85461
|
continue;
|
|
@@ -85405,7 +85473,7 @@ function readDirectDependencies(root) {
|
|
|
85405
85473
|
const direct = [];
|
|
85406
85474
|
for (const { c, path: path3 } of found) {
|
|
85407
85475
|
try {
|
|
85408
|
-
direct.push(...c.parse(
|
|
85476
|
+
direct.push(...c.parse(readFileSync25(path3, "utf8")).direct ?? []);
|
|
85409
85477
|
} catch {
|
|
85410
85478
|
}
|
|
85411
85479
|
}
|
|
@@ -85448,14 +85516,14 @@ function manifestPaths(root) {
|
|
|
85448
85516
|
"project.godot"
|
|
85449
85517
|
];
|
|
85450
85518
|
return {
|
|
85451
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
85519
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync24(join29(root, f))),
|
|
85452
85520
|
tracked: false,
|
|
85453
85521
|
truncated: false
|
|
85454
85522
|
};
|
|
85455
85523
|
}
|
|
85456
85524
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
85457
85525
|
function rootDeclaresWorkspace(root, texts) {
|
|
85458
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
85526
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync24(join29(root, f)))) return true;
|
|
85459
85527
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
85460
85528
|
}
|
|
85461
85529
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -85469,11 +85537,11 @@ function scanManifests(root) {
|
|
|
85469
85537
|
const texts = /* @__PURE__ */ new Map();
|
|
85470
85538
|
const stamps = [];
|
|
85471
85539
|
for (const rel of paths) {
|
|
85472
|
-
const abs =
|
|
85540
|
+
const abs = join29(root, rel);
|
|
85473
85541
|
try {
|
|
85474
|
-
const s =
|
|
85542
|
+
const s = statSync11(abs);
|
|
85475
85543
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
85476
|
-
texts.set(rel,
|
|
85544
|
+
texts.set(rel, readFileSync25(abs, "utf8"));
|
|
85477
85545
|
} catch {
|
|
85478
85546
|
}
|
|
85479
85547
|
}
|
|
@@ -85509,22 +85577,22 @@ function readRetrievalInputs(root, repoLocator) {
|
|
|
85509
85577
|
}
|
|
85510
85578
|
|
|
85511
85579
|
// src/git-sensor.ts
|
|
85512
|
-
import { existsSync as
|
|
85513
|
-
import { join as
|
|
85580
|
+
import { existsSync as existsSync25, readFileSync as readFileSync26, watch as fsWatch } from "node:fs";
|
|
85581
|
+
import { join as join30 } from "node:path";
|
|
85514
85582
|
function readFirstLine(path3) {
|
|
85515
85583
|
try {
|
|
85516
|
-
return
|
|
85584
|
+
return readFileSync26(path3, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
85517
85585
|
} catch {
|
|
85518
85586
|
return null;
|
|
85519
85587
|
}
|
|
85520
85588
|
}
|
|
85521
85589
|
function readGitRefState(gitDir) {
|
|
85522
|
-
const head2 = readFirstLine(
|
|
85590
|
+
const head2 = readFirstLine(join30(gitDir, "HEAD"));
|
|
85523
85591
|
const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
|
|
85524
85592
|
const branch = m ? m[1] : null;
|
|
85525
85593
|
let sha2 = null;
|
|
85526
85594
|
if (branch) {
|
|
85527
|
-
sha2 = readFirstLine(
|
|
85595
|
+
sha2 = readFirstLine(join30(gitDir, "refs", "heads", branch));
|
|
85528
85596
|
if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
|
|
85529
85597
|
} else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
|
|
85530
85598
|
sha2 = head2;
|
|
@@ -85532,13 +85600,13 @@ function readGitRefState(gitDir) {
|
|
|
85532
85600
|
return {
|
|
85533
85601
|
branch,
|
|
85534
85602
|
sha: sha2,
|
|
85535
|
-
mergeHeadExists:
|
|
85536
|
-
origHeadExists:
|
|
85603
|
+
mergeHeadExists: existsSync25(join30(gitDir, "MERGE_HEAD")),
|
|
85604
|
+
origHeadExists: existsSync25(join30(gitDir, "ORIG_HEAD"))
|
|
85537
85605
|
};
|
|
85538
85606
|
}
|
|
85539
85607
|
function shaFromPackedRefs(gitDir, ref) {
|
|
85540
85608
|
try {
|
|
85541
|
-
for (const line of
|
|
85609
|
+
for (const line of readFileSync26(join30(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
85542
85610
|
const [sha2, name2] = line.split(/\s+/);
|
|
85543
85611
|
if (name2 === ref && sha2) return sha2;
|
|
85544
85612
|
}
|
|
@@ -85572,7 +85640,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85572
85640
|
const settle = () => {
|
|
85573
85641
|
if (timer) clearTimeout(timer);
|
|
85574
85642
|
timer = setTimeout(() => {
|
|
85575
|
-
if (
|
|
85643
|
+
if (existsSync25(join30(gitDir, "index.lock"))) {
|
|
85576
85644
|
settle();
|
|
85577
85645
|
return;
|
|
85578
85646
|
}
|
|
@@ -85583,7 +85651,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85583
85651
|
}, debounceMs);
|
|
85584
85652
|
};
|
|
85585
85653
|
for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
|
|
85586
|
-
const p =
|
|
85654
|
+
const p = join30(gitDir, sub);
|
|
85587
85655
|
try {
|
|
85588
85656
|
watchers.push(fsWatch(p, settle));
|
|
85589
85657
|
} catch {
|
|
@@ -85603,7 +85671,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85603
85671
|
// src/git-delta.ts
|
|
85604
85672
|
import { execFile as execFile2 } from "node:child_process";
|
|
85605
85673
|
function git(repoDir, args2) {
|
|
85606
|
-
return new Promise((
|
|
85674
|
+
return new Promise((resolve11, reject) => {
|
|
85607
85675
|
execFile2(
|
|
85608
85676
|
"git",
|
|
85609
85677
|
["-C", repoDir, ...args2],
|
|
@@ -85614,7 +85682,7 @@ function git(repoDir, args2) {
|
|
|
85614
85682
|
// git-sensor runs on every commit/checkout.
|
|
85615
85683
|
windowsHide: true
|
|
85616
85684
|
},
|
|
85617
|
-
(err2, stdout) => err2 ? reject(err2) :
|
|
85685
|
+
(err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
|
|
85618
85686
|
);
|
|
85619
85687
|
});
|
|
85620
85688
|
}
|
|
@@ -85813,8 +85881,8 @@ var TelemetryRecorder = class {
|
|
|
85813
85881
|
};
|
|
85814
85882
|
|
|
85815
85883
|
// src/file-activity.ts
|
|
85816
|
-
import { readFileSync as
|
|
85817
|
-
import { join as
|
|
85884
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
85885
|
+
import { join as join32 } from "node:path";
|
|
85818
85886
|
import { createHash as createHash17 } from "node:crypto";
|
|
85819
85887
|
|
|
85820
85888
|
// ../../packages/privacy/src/patterns/credentials.ts
|
|
@@ -86566,8 +86634,8 @@ init_git_remote();
|
|
|
86566
86634
|
// src/history-bundle.ts
|
|
86567
86635
|
init_src();
|
|
86568
86636
|
import { execFile as execFile3 } from "node:child_process";
|
|
86569
|
-
import { readFileSync as
|
|
86570
|
-
import { join as
|
|
86637
|
+
import { readFileSync as readFileSync27 } from "node:fs";
|
|
86638
|
+
import { join as join31 } from "node:path";
|
|
86571
86639
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
86572
86640
|
var FILE_LIST_CAP = 60;
|
|
86573
86641
|
var DIFF_FILE_CAP = 40;
|
|
@@ -86606,7 +86674,7 @@ function pathAllowedByFloor(path3) {
|
|
|
86606
86674
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
86607
86675
|
let source = "";
|
|
86608
86676
|
try {
|
|
86609
|
-
source =
|
|
86677
|
+
source = readFileSync27(join31(root, ".errataignore"), "utf8");
|
|
86610
86678
|
} catch {
|
|
86611
86679
|
source = "";
|
|
86612
86680
|
}
|
|
@@ -86783,12 +86851,12 @@ function headerPaths(diff) {
|
|
|
86783
86851
|
}
|
|
86784
86852
|
var GIT_MAX_BUFFER = 64 * 1024 * 1024;
|
|
86785
86853
|
function git2(repoDir, args2, maxBuffer = GIT_MAX_BUFFER) {
|
|
86786
|
-
return new Promise((
|
|
86854
|
+
return new Promise((resolve11, reject) => {
|
|
86787
86855
|
execFile3(
|
|
86788
86856
|
"git",
|
|
86789
86857
|
["-C", repoDir, ...args2],
|
|
86790
86858
|
{ encoding: "utf8", maxBuffer, windowsHide: true },
|
|
86791
|
-
(err2, stdout) => err2 ? reject(err2) :
|
|
86859
|
+
(err2, stdout) => err2 ? reject(err2) : resolve11(stdout)
|
|
86792
86860
|
);
|
|
86793
86861
|
});
|
|
86794
86862
|
}
|
|
@@ -86911,7 +86979,7 @@ function readActivityBranch(root) {
|
|
|
86911
86979
|
try {
|
|
86912
86980
|
const gitDir = resolveGitDir(root);
|
|
86913
86981
|
if (!gitDir) return null;
|
|
86914
|
-
const head2 =
|
|
86982
|
+
const head2 = readFileSync28(join32(gitDir, "HEAD"), "utf8").trim();
|
|
86915
86983
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
86916
86984
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
86917
86985
|
} catch {
|
|
@@ -87068,21 +87136,21 @@ var FileActivityReporter = class {
|
|
|
87068
87136
|
|
|
87069
87137
|
// src/skills.ts
|
|
87070
87138
|
import {
|
|
87071
|
-
existsSync as
|
|
87139
|
+
existsSync as existsSync26,
|
|
87072
87140
|
mkdirSync as mkdirSync7,
|
|
87073
|
-
readFileSync as
|
|
87141
|
+
readFileSync as readFileSync29,
|
|
87074
87142
|
readdirSync as readdirSync9,
|
|
87075
87143
|
unlinkSync as unlinkSync4,
|
|
87076
87144
|
writeFileSync as writeFileSync19
|
|
87077
87145
|
} from "node:fs";
|
|
87078
|
-
import { basename as basename7, join as
|
|
87146
|
+
import { basename as basename7, join as join33 } from "node:path";
|
|
87079
87147
|
function skillFileName(id) {
|
|
87080
87148
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
87081
87149
|
}
|
|
87082
87150
|
function readSkillManifest(manifestPath) {
|
|
87083
|
-
if (!
|
|
87151
|
+
if (!existsSync26(manifestPath)) return [];
|
|
87084
87152
|
try {
|
|
87085
|
-
const parsed = JSON.parse(
|
|
87153
|
+
const parsed = JSON.parse(readFileSync29(manifestPath, "utf8"));
|
|
87086
87154
|
return (parsed.skills ?? []).map((s) => ({
|
|
87087
87155
|
title: s.title ?? "",
|
|
87088
87156
|
layer: s.layer ?? "technique",
|
|
@@ -87106,7 +87174,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87106
87174
|
for (const s of res.skills) {
|
|
87107
87175
|
const fileName = skillFileName(s.id);
|
|
87108
87176
|
keep.add(fileName);
|
|
87109
|
-
writeFileSync19(
|
|
87177
|
+
writeFileSync19(join33(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
87110
87178
|
rows.push({
|
|
87111
87179
|
id: s.id,
|
|
87112
87180
|
title: s.title,
|
|
@@ -87119,7 +87187,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87119
87187
|
const fileName = skillFileName(p.id);
|
|
87120
87188
|
if (keep.has(fileName)) continue;
|
|
87121
87189
|
keep.add(fileName);
|
|
87122
|
-
writeFileSync19(
|
|
87190
|
+
writeFileSync19(join33(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
87123
87191
|
rows.push({
|
|
87124
87192
|
id: p.id,
|
|
87125
87193
|
title: p.title,
|
|
@@ -87133,7 +87201,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87133
87201
|
if (!f.endsWith(".md")) continue;
|
|
87134
87202
|
if (keep.has(basename7(f))) continue;
|
|
87135
87203
|
try {
|
|
87136
|
-
unlinkSync4(
|
|
87204
|
+
unlinkSync4(join33(paths.skillsDir, f));
|
|
87137
87205
|
pruned++;
|
|
87138
87206
|
} catch {
|
|
87139
87207
|
}
|
|
@@ -87151,22 +87219,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87151
87219
|
init_src2();
|
|
87152
87220
|
import {
|
|
87153
87221
|
cpSync,
|
|
87154
|
-
existsSync as
|
|
87222
|
+
existsSync as existsSync27,
|
|
87155
87223
|
lstatSync,
|
|
87156
87224
|
mkdirSync as mkdirSync8,
|
|
87157
|
-
readFileSync as
|
|
87225
|
+
readFileSync as readFileSync30,
|
|
87158
87226
|
readdirSync as readdirSync10,
|
|
87159
87227
|
rmSync as rmSync3,
|
|
87160
87228
|
symlinkSync,
|
|
87161
87229
|
writeFileSync as writeFileSync20
|
|
87162
87230
|
} from "node:fs";
|
|
87163
|
-
import { join as
|
|
87231
|
+
import { join as join34 } from "node:path";
|
|
87164
87232
|
var SKILL_NS = "errata-";
|
|
87165
87233
|
var HARNESS_SKILL_DIRS = [
|
|
87166
|
-
{ configDir: ".claude", skillsDir:
|
|
87234
|
+
{ configDir: ".claude", skillsDir: join34(".claude", "skills") },
|
|
87167
87235
|
// Cursor adopted the standard; its exact project dir is still moving — kept
|
|
87168
87236
|
// best-effort and gated on `.cursor/` presence so we never create it blind.
|
|
87169
|
-
{ configDir: ".cursor", skillsDir:
|
|
87237
|
+
{ configDir: ".cursor", skillsDir: join34(".cursor", "skills") }
|
|
87170
87238
|
];
|
|
87171
87239
|
function skillSlug(title, id) {
|
|
87172
87240
|
const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
|
|
@@ -87211,12 +87279,12 @@ function skillCiteHandle(s) {
|
|
|
87211
87279
|
return priorHandle({ id: s.id, description: s.title });
|
|
87212
87280
|
}
|
|
87213
87281
|
function reconcileNamespaced(dir, keep) {
|
|
87214
|
-
if (!
|
|
87282
|
+
if (!existsSync27(dir)) return 0;
|
|
87215
87283
|
let pruned = 0;
|
|
87216
87284
|
for (const name2 of readdirSync10(dir)) {
|
|
87217
87285
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
87218
87286
|
try {
|
|
87219
|
-
rmSync3(
|
|
87287
|
+
rmSync3(join34(dir, name2), { recursive: true, force: true });
|
|
87220
87288
|
pruned++;
|
|
87221
87289
|
} catch {
|
|
87222
87290
|
}
|
|
@@ -87225,7 +87293,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
87225
87293
|
}
|
|
87226
87294
|
function linkOrCopy(linkPath, target) {
|
|
87227
87295
|
try {
|
|
87228
|
-
if (
|
|
87296
|
+
if (existsSync27(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
87229
87297
|
} catch {
|
|
87230
87298
|
}
|
|
87231
87299
|
try {
|
|
@@ -87246,7 +87314,7 @@ function safeLstat(p) {
|
|
|
87246
87314
|
}
|
|
87247
87315
|
}
|
|
87248
87316
|
function emitAndProjectSkills(root, skills) {
|
|
87249
|
-
const agentsSkillsDir =
|
|
87317
|
+
const agentsSkillsDir = join34(root, ".agents", "skills");
|
|
87250
87318
|
mkdirSync8(agentsSkillsDir, { recursive: true });
|
|
87251
87319
|
const slugs = [];
|
|
87252
87320
|
const keep = /* @__PURE__ */ new Set();
|
|
@@ -87254,7 +87322,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87254
87322
|
for (const s of skills) {
|
|
87255
87323
|
let body2;
|
|
87256
87324
|
try {
|
|
87257
|
-
body2 =
|
|
87325
|
+
body2 = readFileSync30(s.bodyPath, "utf8");
|
|
87258
87326
|
} catch {
|
|
87259
87327
|
continue;
|
|
87260
87328
|
}
|
|
@@ -87263,9 +87331,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87263
87331
|
keep.add(slug2);
|
|
87264
87332
|
slugs.push(slug2);
|
|
87265
87333
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
87266
|
-
mkdirSync8(
|
|
87334
|
+
mkdirSync8(join34(agentsSkillsDir, slug2), { recursive: true });
|
|
87267
87335
|
writeFileSync20(
|
|
87268
|
-
|
|
87336
|
+
join34(agentsSkillsDir, slug2, "SKILL.md"),
|
|
87269
87337
|
renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
|
|
87270
87338
|
"utf8"
|
|
87271
87339
|
);
|
|
@@ -87274,11 +87342,11 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87274
87342
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
87275
87343
|
let projected = 0;
|
|
87276
87344
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
87277
|
-
if (!
|
|
87278
|
-
const dir =
|
|
87345
|
+
if (!existsSync27(join34(root, h.configDir))) continue;
|
|
87346
|
+
const dir = join34(root, h.skillsDir);
|
|
87279
87347
|
mkdirSync8(dir, { recursive: true });
|
|
87280
87348
|
for (const slug2 of slugs) {
|
|
87281
|
-
linkOrCopy(
|
|
87349
|
+
linkOrCopy(join34(dir, slug2), join34(agentsSkillsDir, slug2));
|
|
87282
87350
|
projected++;
|
|
87283
87351
|
}
|
|
87284
87352
|
reconcileNamespaced(dir, keep);
|
|
@@ -87287,15 +87355,15 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87287
87355
|
return { slugs, emitted, projected };
|
|
87288
87356
|
}
|
|
87289
87357
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
87290
|
-
if (!
|
|
87358
|
+
if (!existsSync27(manifestPath)) return [];
|
|
87291
87359
|
try {
|
|
87292
|
-
const parsed = JSON.parse(
|
|
87360
|
+
const parsed = JSON.parse(readFileSync30(manifestPath, "utf8"));
|
|
87293
87361
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
87294
87362
|
id: s.id,
|
|
87295
87363
|
title: s.title ?? s.id,
|
|
87296
87364
|
layer: s.layer ?? "technique",
|
|
87297
87365
|
confidence: s.confidence ?? 0,
|
|
87298
|
-
bodyPath:
|
|
87366
|
+
bodyPath: join34(erretaDir, s.file)
|
|
87299
87367
|
}));
|
|
87300
87368
|
} catch {
|
|
87301
87369
|
return [];
|
|
@@ -87309,10 +87377,10 @@ var GITIGNORE_LINES = [
|
|
|
87309
87377
|
".cursor/skills/errata-*/"
|
|
87310
87378
|
];
|
|
87311
87379
|
function ensureSkillGitignore(root) {
|
|
87312
|
-
const path3 =
|
|
87380
|
+
const path3 = join34(root, ".gitignore");
|
|
87313
87381
|
let current = "";
|
|
87314
87382
|
try {
|
|
87315
|
-
current =
|
|
87383
|
+
current = existsSync27(path3) ? readFileSync30(path3, "utf8") : "";
|
|
87316
87384
|
} catch {
|
|
87317
87385
|
return;
|
|
87318
87386
|
}
|
|
@@ -87415,18 +87483,18 @@ init_paths();
|
|
|
87415
87483
|
init_profile2();
|
|
87416
87484
|
|
|
87417
87485
|
// src/witness-queue.ts
|
|
87418
|
-
import { readFileSync as
|
|
87419
|
-
import { dirname as
|
|
87486
|
+
import { readFileSync as readFileSync31, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
|
|
87487
|
+
import { dirname as dirname14, join as join35 } from "node:path";
|
|
87420
87488
|
var WITNESS_QUEUE_CAP = 500;
|
|
87421
87489
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
87422
87490
|
var WITNESS_MAX_ATTEMPTS = 5;
|
|
87423
87491
|
function witnessQueuePath(workspaceConfigDir) {
|
|
87424
|
-
return
|
|
87492
|
+
return join35(workspaceConfigDir, "witness-queue.json");
|
|
87425
87493
|
}
|
|
87426
87494
|
function loadWitnessQueueWithLosses(path3) {
|
|
87427
87495
|
let raw2;
|
|
87428
87496
|
try {
|
|
87429
|
-
raw2 = JSON.parse(
|
|
87497
|
+
raw2 = JSON.parse(readFileSync31(path3, "utf8"));
|
|
87430
87498
|
} catch (err2) {
|
|
87431
87499
|
const absent = err2?.code === "ENOENT";
|
|
87432
87500
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -87439,7 +87507,7 @@ function loadWitnessQueueWithLosses(path3) {
|
|
|
87439
87507
|
}
|
|
87440
87508
|
function saveWitnessQueue(path3, queue) {
|
|
87441
87509
|
try {
|
|
87442
|
-
const tmp =
|
|
87510
|
+
const tmp = join35(dirname14(path3), `.${Date.now()}.witness-queue.tmp`);
|
|
87443
87511
|
writeFileSync21(tmp, JSON.stringify(queue), "utf8");
|
|
87444
87512
|
renameSync4(tmp, path3);
|
|
87445
87513
|
} catch {
|
|
@@ -87749,8 +87817,8 @@ function maybeFlushDigests() {
|
|
|
87749
87817
|
|
|
87750
87818
|
// src/liveness-watch.ts
|
|
87751
87819
|
init_src5();
|
|
87752
|
-
import { readFileSync as
|
|
87753
|
-
import { join as
|
|
87820
|
+
import { readFileSync as readFileSync33, writeFileSync as writeFileSync23 } from "node:fs";
|
|
87821
|
+
import { join as join37 } from "node:path";
|
|
87754
87822
|
|
|
87755
87823
|
// src/loop-lag.ts
|
|
87756
87824
|
var HEARTBEAT_MS = 500;
|
|
@@ -87882,11 +87950,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
|
|
|
87882
87950
|
var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
|
|
87883
87951
|
var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
|
|
87884
87952
|
function alarmStatePath(configDir) {
|
|
87885
|
-
return
|
|
87953
|
+
return join37(configDir, "liveness-alarms.json");
|
|
87886
87954
|
}
|
|
87887
87955
|
function loadAlarmState(path3) {
|
|
87888
87956
|
try {
|
|
87889
|
-
const raw2 = JSON.parse(
|
|
87957
|
+
const raw2 = JSON.parse(readFileSync33(path3, "utf8"));
|
|
87890
87958
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
87891
87959
|
} catch {
|
|
87892
87960
|
return /* @__PURE__ */ new Map();
|
|
@@ -88150,7 +88218,7 @@ function createWatchBreaker(deps) {
|
|
|
88150
88218
|
}
|
|
88151
88219
|
|
|
88152
88220
|
// src/engine.ts
|
|
88153
|
-
var DAEMON_VERSION = true ? "2.0.23-dev.
|
|
88221
|
+
var DAEMON_VERSION = true ? "2.0.23-dev.4863" : "2.0.0-alpha.0";
|
|
88154
88222
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
88155
88223
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
88156
88224
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -88162,7 +88230,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
88162
88230
|
function appendIdentityAudit(path3, record2, line) {
|
|
88163
88231
|
if (!record2.accepted && record2.score <= 0) return;
|
|
88164
88232
|
try {
|
|
88165
|
-
if (
|
|
88233
|
+
if (existsSync29(path3) && statSync12(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
88166
88234
|
renameSync5(path3, `${path3}.1`);
|
|
88167
88235
|
}
|
|
88168
88236
|
appendFileSync4(path3, line);
|
|
@@ -88172,7 +88240,7 @@ function appendIdentityAudit(path3, record2, line) {
|
|
|
88172
88240
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
88173
88241
|
function loadTurnCursors(path3) {
|
|
88174
88242
|
try {
|
|
88175
|
-
const raw2 = JSON.parse(
|
|
88243
|
+
const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
|
|
88176
88244
|
return new Map(
|
|
88177
88245
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
88178
88246
|
);
|
|
@@ -88182,7 +88250,7 @@ function loadTurnCursors(path3) {
|
|
|
88182
88250
|
}
|
|
88183
88251
|
function loadTurnOffsets(path3) {
|
|
88184
88252
|
try {
|
|
88185
|
-
const raw2 = JSON.parse(
|
|
88253
|
+
const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
|
|
88186
88254
|
const out2 = /* @__PURE__ */ new Map();
|
|
88187
88255
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88188
88256
|
const off2 = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -88195,7 +88263,7 @@ function loadTurnOffsets(path3) {
|
|
|
88195
88263
|
}
|
|
88196
88264
|
function loadTurnMoves(path3) {
|
|
88197
88265
|
try {
|
|
88198
|
-
const raw2 = JSON.parse(
|
|
88266
|
+
const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
|
|
88199
88267
|
const out2 = /* @__PURE__ */ new Map();
|
|
88200
88268
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88201
88269
|
const to = typeof v === "object" && v !== null ? v.movedTo : void 0;
|
|
@@ -88216,7 +88284,7 @@ function saveTurnCursors(path3, cursors, offsets, moves = /* @__PURE__ */ new Ma
|
|
|
88216
88284
|
} catch {
|
|
88217
88285
|
}
|
|
88218
88286
|
}
|
|
88219
|
-
var turnCursorFile = (configDir) =>
|
|
88287
|
+
var turnCursorFile = (configDir) => join38(configDir, "turn-cursors.json");
|
|
88220
88288
|
function turnCursorOnDisk(configDir, sessionId) {
|
|
88221
88289
|
const path3 = turnCursorFile(configDir);
|
|
88222
88290
|
const offset = loadTurnOffsets(path3).get(sessionId);
|
|
@@ -88248,7 +88316,7 @@ function gitSourceWatchTargets(root) {
|
|
|
88248
88316
|
["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
|
|
88249
88317
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
88250
88318
|
);
|
|
88251
|
-
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(
|
|
88319
|
+
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join38(root, d) + sep5));
|
|
88252
88320
|
} catch {
|
|
88253
88321
|
}
|
|
88254
88322
|
const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
|
|
@@ -88260,19 +88328,19 @@ function gitSourceWatchTargets(root) {
|
|
|
88260
88328
|
if (!f.startsWith(prefix)) continue;
|
|
88261
88329
|
const rest2 = f.slice(prefix.length);
|
|
88262
88330
|
if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
|
|
88263
|
-
else targets.add(
|
|
88331
|
+
else targets.add(join38(root, f));
|
|
88264
88332
|
}
|
|
88265
88333
|
for (const c of children) {
|
|
88266
|
-
if (IGNORED_PATH.test(
|
|
88334
|
+
if (IGNORED_PATH.test(join38(root, c) + sep5)) continue;
|
|
88267
88335
|
if (hasIgnoredChild(c)) addUnder(c);
|
|
88268
|
-
else targets.add(
|
|
88336
|
+
else targets.add(join38(root, c));
|
|
88269
88337
|
}
|
|
88270
88338
|
};
|
|
88271
88339
|
addUnder("");
|
|
88272
88340
|
if (targets.size > 0) return [...targets];
|
|
88273
88341
|
} catch {
|
|
88274
88342
|
}
|
|
88275
|
-
return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(
|
|
88343
|
+
return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join38(root, String(e.name)) + sep5)).map((e) => join38(root, String(e.name)));
|
|
88276
88344
|
}
|
|
88277
88345
|
function createWorkspaceEngine(opts) {
|
|
88278
88346
|
const paths = workspacePaths(opts.workspaceRoot);
|
|
@@ -88366,7 +88434,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88366
88434
|
}
|
|
88367
88435
|
let size = 0;
|
|
88368
88436
|
try {
|
|
88369
|
-
size =
|
|
88437
|
+
size = statSync12(path3).size;
|
|
88370
88438
|
} catch {
|
|
88371
88439
|
}
|
|
88372
88440
|
lastActivityTs = Date.now();
|
|
@@ -88474,7 +88542,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88474
88542
|
const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
|
|
88475
88543
|
let episodeId2;
|
|
88476
88544
|
if (srcPaths.length > 0) {
|
|
88477
|
-
const abs = srcPaths.map((p) =>
|
|
88545
|
+
const abs = srcPaths.map((p) => join38(opts.workspaceRoot, p));
|
|
88478
88546
|
try {
|
|
88479
88547
|
const r = await runReindexPass(
|
|
88480
88548
|
`git-reindex:${profile.name} (${abs.length} files)`,
|
|
@@ -88510,8 +88578,8 @@ function createWorkspaceEngine(opts) {
|
|
|
88510
88578
|
`[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
|
|
88511
88579
|
);
|
|
88512
88580
|
};
|
|
88513
|
-
const gitDir =
|
|
88514
|
-
if (
|
|
88581
|
+
const gitDir = join38(opts.workspaceRoot, ".git");
|
|
88582
|
+
if (existsSync29(gitDir)) {
|
|
88515
88583
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
88516
88584
|
void handleGitEvent(ev).catch((err2) => {
|
|
88517
88585
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -88572,7 +88640,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88572
88640
|
},
|
|
88573
88641
|
onAlarms: (alarms) => {
|
|
88574
88642
|
toastLivenessAlarms(
|
|
88575
|
-
sharedAlarmToastGate(
|
|
88643
|
+
sharedAlarmToastGate(join38(globalDir(), "liveness-toasts.json")),
|
|
88576
88644
|
{ root: opts.workspaceRoot, name: profile.name },
|
|
88577
88645
|
alarms,
|
|
88578
88646
|
(body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
|
|
@@ -88589,7 +88657,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88589
88657
|
let subagentBase = null;
|
|
88590
88658
|
let subagentBaseVersion = 0;
|
|
88591
88659
|
const subagentRenders = /* @__PURE__ */ new Map();
|
|
88592
|
-
const sessions = createSessionRegistry({ originsPath:
|
|
88660
|
+
const sessions = createSessionRegistry({ originsPath: join38(paths.configDir, "session-origins.json") });
|
|
88593
88661
|
const sessionRenders = /* @__PURE__ */ new Map();
|
|
88594
88662
|
const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
|
|
88595
88663
|
const supersessionAsks = new SupersessionAsks();
|
|
@@ -88694,7 +88762,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88694
88762
|
const elicit = isEdgeElicitationEnabled();
|
|
88695
88763
|
const snapOpts = {
|
|
88696
88764
|
profile,
|
|
88697
|
-
atCommit: readGitRefState(
|
|
88765
|
+
atCommit: readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0,
|
|
88698
88766
|
reviewCount: pendingCount(paths),
|
|
88699
88767
|
reviewUiUrl: opts.reviewUrl(),
|
|
88700
88768
|
workingFile: workingFiles.mostRecent() ?? void 0,
|
|
@@ -88734,7 +88802,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88734
88802
|
);
|
|
88735
88803
|
return null;
|
|
88736
88804
|
}) : null;
|
|
88737
|
-
if (snapOpts.atCommit !== (readGitRefState(
|
|
88805
|
+
if (snapOpts.atCommit !== (readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0)) {
|
|
88738
88806
|
contextDirty = true;
|
|
88739
88807
|
return;
|
|
88740
88808
|
}
|
|
@@ -88780,10 +88848,10 @@ function createWorkspaceEngine(opts) {
|
|
|
88780
88848
|
} catch (err2) {
|
|
88781
88849
|
console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
|
|
88782
88850
|
}
|
|
88783
|
-
const target =
|
|
88851
|
+
const target = join38(opts.workspaceRoot, "AGENTS.md");
|
|
88784
88852
|
writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
|
|
88785
88853
|
if (elicit) {
|
|
88786
|
-
writePrimingHandles(
|
|
88854
|
+
writePrimingHandles(join38(paths.configDir, "priming-handles.json"), [
|
|
88787
88855
|
...snapshot.recentProblems.map((r) => r.node),
|
|
88788
88856
|
// Resolved-band handles: the ✓ problem AND its Solution are citable
|
|
88789
88857
|
// (a fix tag on an already-resolved problem no-ops idempotently; the
|
|
@@ -89091,8 +89159,8 @@ function createWorkspaceEngine(opts) {
|
|
|
89091
89159
|
const cached2 = subagentRenders.get(a.agentId);
|
|
89092
89160
|
if (cached2?.key === key) return cached2.block;
|
|
89093
89161
|
const elicit = isEdgeElicitationEnabled();
|
|
89094
|
-
const handlesPath =
|
|
89095
|
-
const atCommit = readGitRefState(
|
|
89162
|
+
const handlesPath = join38(paths.configDir, "priming-handles.json");
|
|
89163
|
+
const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89096
89164
|
const block = renderSubagentBlock({
|
|
89097
89165
|
store,
|
|
89098
89166
|
entry,
|
|
@@ -89147,7 +89215,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89147
89215
|
const cached2 = sessionRenders.get(sessionId);
|
|
89148
89216
|
if (cached2?.key === key) return cached2.block;
|
|
89149
89217
|
const elicit = isEdgeElicitationEnabled();
|
|
89150
|
-
const atCommit = readGitRefState(
|
|
89218
|
+
const atCommit = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89151
89219
|
const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
|
|
89152
89220
|
delete scoped.workingFile;
|
|
89153
89221
|
if (workingFile) {
|
|
@@ -89191,7 +89259,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89191
89259
|
]
|
|
89192
89260
|
};
|
|
89193
89261
|
if (elicit && block.handleNodes.length) {
|
|
89194
|
-
writePrimingHandles(
|
|
89262
|
+
writePrimingHandles(join38(paths.configDir, "priming-handles.json"), block.handleNodes);
|
|
89195
89263
|
}
|
|
89196
89264
|
sessionRenders.delete(sessionId);
|
|
89197
89265
|
sessionRenders.set(sessionId, { key, block });
|
|
@@ -89267,7 +89335,15 @@ function createWorkspaceEngine(opts) {
|
|
|
89267
89335
|
doneHarvest();
|
|
89268
89336
|
}
|
|
89269
89337
|
};
|
|
89338
|
+
const replaySessions = /* @__PURE__ */ new Set();
|
|
89339
|
+
const sessionCwdSeen = /* @__PURE__ */ new Set();
|
|
89340
|
+
const noteSessionCwd = (sessionId, cwd) => {
|
|
89341
|
+
if (!cwd || !sessionId || sessionCwdSeen.has(sessionId)) return;
|
|
89342
|
+
sessionCwdSeen.add(sessionId);
|
|
89343
|
+
if (isReplayCheckout(cwd)) replaySessions.add(sessionId);
|
|
89344
|
+
};
|
|
89270
89345
|
const harvestTextsInner = async (sessionId, items) => {
|
|
89346
|
+
const replay2 = replaySessions.has(sessionId);
|
|
89271
89347
|
let minted = 0;
|
|
89272
89348
|
let tagsSeen = 0;
|
|
89273
89349
|
let vulnerabilitiesSeen = 0;
|
|
@@ -89317,7 +89393,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89317
89393
|
let processedTurns = 0;
|
|
89318
89394
|
const seqAtStart = store.currentIngestSeq();
|
|
89319
89395
|
const elicit = isEdgeElicitationEnabled();
|
|
89320
|
-
const handleMap = elicit ? readPrimingHandles(
|
|
89396
|
+
const handleMap = elicit ? readPrimingHandles(join38(paths.configDir, "priming-handles.json")) : {};
|
|
89321
89397
|
const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
|
|
89322
89398
|
const toRel = (abs) => {
|
|
89323
89399
|
const p = abs.replace(/\\/g, "/");
|
|
@@ -89369,7 +89445,8 @@ function createWorkspaceEngine(opts) {
|
|
|
89369
89445
|
workspaceId: profile.id,
|
|
89370
89446
|
source: sessionId,
|
|
89371
89447
|
ts: t,
|
|
89372
|
-
hostHarness: turn.hostHarness
|
|
89448
|
+
hostHarness: turn.hostHarness,
|
|
89449
|
+
replay: replay2
|
|
89373
89450
|
});
|
|
89374
89451
|
if (r.created || r.corroborated) minted++;
|
|
89375
89452
|
else if (r.rejected) tagsRejected++;
|
|
@@ -89536,7 +89613,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89536
89613
|
let anchorReadFailed = false;
|
|
89537
89614
|
if (p.location) {
|
|
89538
89615
|
try {
|
|
89539
|
-
fileText =
|
|
89616
|
+
fileText = readFileSync34(join38(opts.workspaceRoot, p.location.path), "utf8");
|
|
89540
89617
|
} catch {
|
|
89541
89618
|
anchorReadFailed = true;
|
|
89542
89619
|
}
|
|
@@ -89548,7 +89625,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89548
89625
|
line: p.location?.line,
|
|
89549
89626
|
fileText,
|
|
89550
89627
|
existingId: p.threadId ? threads.get(p.threadId) ?? handleMap[p.threadId]?.id ?? store.getNode(p.threadId)?.id : void 0
|
|
89551
|
-
}, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness });
|
|
89628
|
+
}, { workspaceId: profile.id, source: sessionId, ts: t, hostHarness: turn.hostHarness, replay: replay2 });
|
|
89552
89629
|
let anchorDisposition = p.location ? "unresolved" : "absent";
|
|
89553
89630
|
if (result.rejected) {
|
|
89554
89631
|
tagsRejected++;
|
|
@@ -89636,13 +89713,14 @@ function createWorkspaceEngine(opts) {
|
|
|
89636
89713
|
workspaceId: profile.id,
|
|
89637
89714
|
source: sessionId,
|
|
89638
89715
|
ts: t,
|
|
89639
|
-
hostHarness: turn.hostHarness
|
|
89716
|
+
hostHarness: turn.hostHarness,
|
|
89717
|
+
replay: replay2
|
|
89640
89718
|
});
|
|
89641
89719
|
if (!r.rejected && r.problemId) {
|
|
89642
89720
|
findingIds.set(p.statement, r.problemId);
|
|
89643
89721
|
if (p.threadId) threads.set(p.threadId, r.problemId);
|
|
89644
89722
|
}
|
|
89645
|
-
if (r.created && dedupPath) {
|
|
89723
|
+
if (r.created && dedupPath && !replay2) {
|
|
89646
89724
|
try {
|
|
89647
89725
|
const closedId = findResolvedAnchorMatch(store, dedupPath, profile.id, p.statement, p.kind);
|
|
89648
89726
|
const touch = closedId ? markResolvedRecurrence(store, closedId, t, sessionId) : { marked: false, reopened: false };
|
|
@@ -89698,10 +89776,10 @@ function createWorkspaceEngine(opts) {
|
|
|
89698
89776
|
let enclosing = {};
|
|
89699
89777
|
if (p.location?.line !== void 0) {
|
|
89700
89778
|
try {
|
|
89701
|
-
const headSha = readGitRefState(
|
|
89779
|
+
const headSha = readGitRefState(join38(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89702
89780
|
enclosing = {
|
|
89703
89781
|
line: p.location.line,
|
|
89704
|
-
fileText:
|
|
89782
|
+
fileText: readFileSync34(join38(opts.workspaceRoot, anchorPath), "utf8"),
|
|
89705
89783
|
...headSha ? { headSha } : {}
|
|
89706
89784
|
};
|
|
89707
89785
|
} catch {
|
|
@@ -90327,11 +90405,12 @@ function createWorkspaceEngine(opts) {
|
|
|
90327
90405
|
}
|
|
90328
90406
|
turns = next.turns;
|
|
90329
90407
|
nextOffset = next.nextOffset;
|
|
90330
|
-
await new Promise((
|
|
90408
|
+
await new Promise((resolve11) => setImmediate(resolve11));
|
|
90331
90409
|
}
|
|
90332
90410
|
};
|
|
90333
90411
|
const seenMessageIds = /* @__PURE__ */ new Set();
|
|
90334
90412
|
const onMessage = (e) => {
|
|
90413
|
+
noteSessionCwd(e.sessionId, e.cwd);
|
|
90335
90414
|
if (e.messageId) {
|
|
90336
90415
|
if (seenMessageIds.has(e.messageId)) return;
|
|
90337
90416
|
seenMessageIds.add(e.messageId);
|
|
@@ -90384,6 +90463,7 @@ function createWorkspaceEngine(opts) {
|
|
|
90384
90463
|
}
|
|
90385
90464
|
};
|
|
90386
90465
|
const onTurn = (e) => {
|
|
90466
|
+
noteSessionCwd(e.sessionId, e.cwd);
|
|
90387
90467
|
setImmediate(() => void harvestSession(e.sessionId, e.transcriptPath));
|
|
90388
90468
|
};
|
|
90389
90469
|
setImmediate(() => {
|
|
@@ -90573,7 +90653,7 @@ B: ${b}`,
|
|
|
90573
90653
|
try {
|
|
90574
90654
|
const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
|
|
90575
90655
|
emitAndProjectSkills(opts.workspaceRoot, inputs);
|
|
90576
|
-
writePrimingHandles(
|
|
90656
|
+
writePrimingHandles(join38(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
|
|
90577
90657
|
} catch (err2) {
|
|
90578
90658
|
console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
|
|
90579
90659
|
}
|
|
@@ -90940,7 +91020,7 @@ B: ${b}`,
|
|
|
90940
91020
|
console.log(
|
|
90941
91021
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
90942
91022
|
);
|
|
90943
|
-
const pending =
|
|
91023
|
+
const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
90944
91024
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
90945
91025
|
}
|
|
90946
91026
|
if (!shipsFromWorkspace(opts.workspaceRoot)) {
|
|
@@ -90952,7 +91032,7 @@ B: ${b}`,
|
|
|
90952
91032
|
console.log(
|
|
90953
91033
|
"[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
|
|
90954
91034
|
);
|
|
90955
|
-
const pending =
|
|
91035
|
+
const pending = existsSync29(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
90956
91036
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
90957
91037
|
}
|
|
90958
91038
|
try {
|
|
@@ -91129,7 +91209,7 @@ async function startDaemon(opts) {
|
|
|
91129
91209
|
);
|
|
91130
91210
|
await engine.stop();
|
|
91131
91211
|
try {
|
|
91132
|
-
if (
|
|
91212
|
+
if (existsSync30(engine.paths.daemonLock)) {
|
|
91133
91213
|
}
|
|
91134
91214
|
} catch {
|
|
91135
91215
|
}
|
|
@@ -91137,9 +91217,9 @@ async function startDaemon(opts) {
|
|
|
91137
91217
|
};
|
|
91138
91218
|
}
|
|
91139
91219
|
async function listenServer(fetchFn, port) {
|
|
91140
|
-
return new Promise((
|
|
91220
|
+
return new Promise((resolve11, reject) => {
|
|
91141
91221
|
const server = serve({ fetch: withLoopbackGuard(fetchFn), hostname: "127.0.0.1", port }, (info2) => {
|
|
91142
|
-
|
|
91222
|
+
resolve11({ server, port: info2.port });
|
|
91143
91223
|
});
|
|
91144
91224
|
server.once(
|
|
91145
91225
|
"error",
|
|
@@ -91330,8 +91410,8 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
|
|
|
91330
91410
|
}
|
|
91331
91411
|
|
|
91332
91412
|
// src/edge-park.ts
|
|
91333
|
-
import { readFileSync as
|
|
91334
|
-
import { dirname as
|
|
91413
|
+
import { readFileSync as readFileSync35, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
|
|
91414
|
+
import { dirname as dirname15, join as join39 } from "node:path";
|
|
91335
91415
|
var EDGE_PARK_CAP = 2e3;
|
|
91336
91416
|
var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
91337
91417
|
var EDGE_PARK_MAX_ATTEMPTS = 6;
|
|
@@ -91346,12 +91426,12 @@ function wireEdgeKey(from, type, to) {
|
|
|
91346
91426
|
return JSON.stringify([from, type, to]);
|
|
91347
91427
|
}
|
|
91348
91428
|
function edgeParkPath(workspaceConfigDir, destinationKey) {
|
|
91349
|
-
return
|
|
91429
|
+
return join39(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
|
|
91350
91430
|
}
|
|
91351
91431
|
function loadEdgePark(path3) {
|
|
91352
91432
|
let raw2;
|
|
91353
91433
|
try {
|
|
91354
|
-
raw2 = JSON.parse(
|
|
91434
|
+
raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
91355
91435
|
} catch {
|
|
91356
91436
|
return [];
|
|
91357
91437
|
}
|
|
@@ -91362,7 +91442,7 @@ function loadEdgePark(path3) {
|
|
|
91362
91442
|
}
|
|
91363
91443
|
function saveEdgePark(path3, queue) {
|
|
91364
91444
|
try {
|
|
91365
|
-
const tmp =
|
|
91445
|
+
const tmp = join39(dirname15(path3), `.${Date.now()}.edge-park.tmp`);
|
|
91366
91446
|
writeFileSync26(tmp, JSON.stringify(queue), "utf8");
|
|
91367
91447
|
renameSync6(tmp, path3);
|
|
91368
91448
|
} catch {
|
|
@@ -91685,8 +91765,8 @@ function invalidateInstanceReceipt(current, destination, failedId, mirrorLegacy)
|
|
|
91685
91765
|
// src/multi.ts
|
|
91686
91766
|
init_dist();
|
|
91687
91767
|
init_src5();
|
|
91688
|
-
import { existsSync as
|
|
91689
|
-
import { basename as basename10, dirname as
|
|
91768
|
+
import { existsSync as existsSync35, readFileSync as readFileSync41, writeFileSync as writeFileSync29 } from "node:fs";
|
|
91769
|
+
import { basename as basename10, dirname as dirname18, join as join48, resolve as pathResolve } from "node:path";
|
|
91690
91770
|
|
|
91691
91771
|
// src/principle-sync.ts
|
|
91692
91772
|
init_src5();
|
|
@@ -91714,8 +91794,8 @@ init_reconcile();
|
|
|
91714
91794
|
|
|
91715
91795
|
// src/lockfile-auto.ts
|
|
91716
91796
|
init_src();
|
|
91717
|
-
import { existsSync as
|
|
91718
|
-
import { join as
|
|
91797
|
+
import { existsSync as existsSync31, readFileSync as readFileSync36 } from "node:fs";
|
|
91798
|
+
import { join as join40 } from "node:path";
|
|
91719
91799
|
|
|
91720
91800
|
// src/package-index.ts
|
|
91721
91801
|
init_src();
|
|
@@ -91888,11 +91968,11 @@ function runLockfilePass(opts) {
|
|
|
91888
91968
|
{ file: "package-lock.json", parse: parsePackageLockJson }
|
|
91889
91969
|
];
|
|
91890
91970
|
for (const c of candidates) {
|
|
91891
|
-
const p =
|
|
91892
|
-
if (!
|
|
91971
|
+
const p = join40(opts.root, c.file);
|
|
91972
|
+
if (!existsSync31(p)) continue;
|
|
91893
91973
|
let sbom;
|
|
91894
91974
|
try {
|
|
91895
|
-
sbom = c.parse(
|
|
91975
|
+
sbom = c.parse(readFileSync36(p, "utf8"));
|
|
91896
91976
|
} catch {
|
|
91897
91977
|
continue;
|
|
91898
91978
|
}
|
|
@@ -91953,8 +92033,8 @@ init_profile2();
|
|
|
91953
92033
|
init_session_registry();
|
|
91954
92034
|
|
|
91955
92035
|
// src/public-symbols.ts
|
|
91956
|
-
import { readFileSync as
|
|
91957
|
-
import { join as
|
|
92036
|
+
import { readFileSync as readFileSync37, readdirSync as readdirSync12, existsSync as existsSync32 } from "node:fs";
|
|
92037
|
+
import { join as join41 } from "node:path";
|
|
91958
92038
|
var HEAD_BYTES = 8 * 1024;
|
|
91959
92039
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
91960
92040
|
var MIN_SYMBOL_LEN = 4;
|
|
@@ -91987,20 +92067,20 @@ function bindingNames(clause) {
|
|
|
91987
92067
|
function internalPackageNames(workspaceRoot) {
|
|
91988
92068
|
const names = /* @__PURE__ */ new Set();
|
|
91989
92069
|
const tryRead = (dir) => {
|
|
91990
|
-
const pj =
|
|
91991
|
-
if (!
|
|
92070
|
+
const pj = join41(dir, "package.json");
|
|
92071
|
+
if (!existsSync32(pj)) return;
|
|
91992
92072
|
try {
|
|
91993
|
-
const name2 = JSON.parse(
|
|
92073
|
+
const name2 = JSON.parse(readFileSync37(pj, "utf8")).name;
|
|
91994
92074
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
91995
92075
|
} catch {
|
|
91996
92076
|
}
|
|
91997
92077
|
};
|
|
91998
92078
|
tryRead(workspaceRoot);
|
|
91999
92079
|
for (const group of ["packages", "apps"]) {
|
|
92000
|
-
const groupDir =
|
|
92001
|
-
if (!
|
|
92080
|
+
const groupDir = join41(workspaceRoot, group);
|
|
92081
|
+
if (!existsSync32(groupDir)) continue;
|
|
92002
92082
|
try {
|
|
92003
|
-
for (const entry of readdirSync12(groupDir)) tryRead(
|
|
92083
|
+
for (const entry of readdirSync12(groupDir)) tryRead(join41(groupDir, entry));
|
|
92004
92084
|
} catch {
|
|
92005
92085
|
}
|
|
92006
92086
|
}
|
|
@@ -92019,7 +92099,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92019
92099
|
}
|
|
92020
92100
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
92021
92101
|
try {
|
|
92022
|
-
return
|
|
92102
|
+
return readFileSync37(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
92023
92103
|
} catch {
|
|
92024
92104
|
return "";
|
|
92025
92105
|
}
|
|
@@ -92039,7 +92119,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92039
92119
|
}
|
|
92040
92120
|
const symbols = /* @__PURE__ */ new Set();
|
|
92041
92121
|
for (const rel of files) {
|
|
92042
|
-
const head2 = readHead(
|
|
92122
|
+
const head2 = readHead(join41(workspaceRoot, rel));
|
|
92043
92123
|
if (!head2) continue;
|
|
92044
92124
|
for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
|
|
92045
92125
|
re.lastIndex = 0;
|
|
@@ -92843,8 +92923,8 @@ var ConsolidateWorker = class {
|
|
|
92843
92923
|
const id = this.nextId++;
|
|
92844
92924
|
try {
|
|
92845
92925
|
await this.ready;
|
|
92846
|
-
return await new Promise((
|
|
92847
|
-
this.pending.set(id, { resolve:
|
|
92926
|
+
return await new Promise((resolve11, reject) => {
|
|
92927
|
+
this.pending.set(id, { resolve: resolve11, reject });
|
|
92848
92928
|
this.worker.postMessage({ ...req, id });
|
|
92849
92929
|
});
|
|
92850
92930
|
} finally {
|
|
@@ -92874,12 +92954,12 @@ var ConsolidateWorker = class {
|
|
|
92874
92954
|
});
|
|
92875
92955
|
noteIsolateSpawned();
|
|
92876
92956
|
this.worker = worker;
|
|
92877
|
-
this.ready = new Promise((
|
|
92957
|
+
this.ready = new Promise((resolve11, reject) => {
|
|
92878
92958
|
const onReady = (m) => {
|
|
92879
92959
|
if (m?.ready) {
|
|
92880
92960
|
worker.off("message", onReady);
|
|
92881
92961
|
worker.off("error", onErr);
|
|
92882
|
-
|
|
92962
|
+
resolve11();
|
|
92883
92963
|
}
|
|
92884
92964
|
};
|
|
92885
92965
|
const onErr = (err2) => {
|
|
@@ -92937,8 +93017,8 @@ var GeneralizeWorker = class {
|
|
|
92937
93017
|
this.touch();
|
|
92938
93018
|
await this.ready;
|
|
92939
93019
|
const id = this.nextId++;
|
|
92940
|
-
return new Promise((
|
|
92941
|
-
this.pending.set(id, { resolve:
|
|
93020
|
+
return new Promise((resolve11, reject) => {
|
|
93021
|
+
this.pending.set(id, { resolve: resolve11, reject });
|
|
92942
93022
|
const req = { id, castaliaPath, text };
|
|
92943
93023
|
this.worker.postMessage(req);
|
|
92944
93024
|
});
|
|
@@ -92964,12 +93044,12 @@ var GeneralizeWorker = class {
|
|
|
92964
93044
|
});
|
|
92965
93045
|
noteIsolateSpawned();
|
|
92966
93046
|
this.worker = worker;
|
|
92967
|
-
this.ready = new Promise((
|
|
93047
|
+
this.ready = new Promise((resolve11, reject) => {
|
|
92968
93048
|
const onReady = (m) => {
|
|
92969
93049
|
if (m?.ready) {
|
|
92970
93050
|
worker.off("message", onReady);
|
|
92971
93051
|
worker.off("error", onErr);
|
|
92972
|
-
|
|
93052
|
+
resolve11();
|
|
92973
93053
|
}
|
|
92974
93054
|
};
|
|
92975
93055
|
const onErr = (err2) => {
|
|
@@ -93070,7 +93150,7 @@ init_config();
|
|
|
93070
93150
|
|
|
93071
93151
|
// src/update.ts
|
|
93072
93152
|
import { spawn as spawn2 } from "node:child_process";
|
|
93073
|
-
import { isAbsolute as
|
|
93153
|
+
import { isAbsolute as isAbsolute6, join as join42 } from "node:path";
|
|
93074
93154
|
var PACKAGE_NAME = "@inerrata-corporation/errata";
|
|
93075
93155
|
function parse3(v) {
|
|
93076
93156
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
|
|
@@ -93190,17 +93270,17 @@ function startUpdatePoller(opts) {
|
|
|
93190
93270
|
};
|
|
93191
93271
|
}
|
|
93192
93272
|
function runNpmInstall(channel) {
|
|
93193
|
-
return new Promise((
|
|
93273
|
+
return new Promise((resolve11) => {
|
|
93194
93274
|
const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
|
|
93195
93275
|
stdio: "inherit",
|
|
93196
93276
|
shell: true
|
|
93197
93277
|
});
|
|
93198
|
-
child.on("close", (code) =>
|
|
93199
|
-
child.on("error", () =>
|
|
93278
|
+
child.on("close", (code) => resolve11(code ?? 1));
|
|
93279
|
+
child.on("error", () => resolve11(1));
|
|
93200
93280
|
});
|
|
93201
93281
|
}
|
|
93202
93282
|
async function runInstalledHookRefresh() {
|
|
93203
|
-
const root = await new Promise((
|
|
93283
|
+
const root = await new Promise((resolve11) => {
|
|
93204
93284
|
const child = spawn2("npm", ["root", "-g"], {
|
|
93205
93285
|
shell: true,
|
|
93206
93286
|
windowsHide: true,
|
|
@@ -93212,18 +93292,18 @@ async function runInstalledHookRefresh() {
|
|
|
93212
93292
|
output += chunk;
|
|
93213
93293
|
if (output.length > 32768) child.kill();
|
|
93214
93294
|
});
|
|
93215
|
-
child.on("error", () =>
|
|
93216
|
-
child.on("close", (code) =>
|
|
93295
|
+
child.on("error", () => resolve11(""));
|
|
93296
|
+
child.on("close", (code) => resolve11(code === 0 ? output.trim() : ""));
|
|
93217
93297
|
});
|
|
93218
|
-
if (!
|
|
93219
|
-
return new Promise((
|
|
93220
|
-
const child = spawn2(process.execPath, [
|
|
93298
|
+
if (!isAbsolute6(root)) return 1;
|
|
93299
|
+
return new Promise((resolve11) => {
|
|
93300
|
+
const child = spawn2(process.execPath, [join42(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
|
|
93221
93301
|
windowsHide: true,
|
|
93222
93302
|
stdio: "inherit",
|
|
93223
93303
|
timeout: 3e4
|
|
93224
93304
|
});
|
|
93225
|
-
child.on("error", () =>
|
|
93226
|
-
child.on("close", (code) =>
|
|
93305
|
+
child.on("error", () => resolve11(1));
|
|
93306
|
+
child.on("close", (code) => resolve11(code ?? 1));
|
|
93227
93307
|
});
|
|
93228
93308
|
}
|
|
93229
93309
|
|
|
@@ -93238,7 +93318,7 @@ function liveCloudClient(src) {
|
|
|
93238
93318
|
let current = null;
|
|
93239
93319
|
let currentKey = "";
|
|
93240
93320
|
let checkedAt = -Infinity;
|
|
93241
|
-
const
|
|
93321
|
+
const resolve11 = () => {
|
|
93242
93322
|
const t = now();
|
|
93243
93323
|
if (current && t - checkedAt < recheckMs) return current;
|
|
93244
93324
|
checkedAt = t;
|
|
@@ -93258,7 +93338,7 @@ function liveCloudClient(src) {
|
|
|
93258
93338
|
};
|
|
93259
93339
|
return new Proxy({}, {
|
|
93260
93340
|
get(_target, prop) {
|
|
93261
|
-
const client =
|
|
93341
|
+
const client = resolve11();
|
|
93262
93342
|
const value = Reflect.get(client, prop, client);
|
|
93263
93343
|
return typeof value === "function" ? value.bind(client) : value;
|
|
93264
93344
|
}
|
|
@@ -93363,12 +93443,12 @@ function landCloudEdge(store, e, from, to) {
|
|
|
93363
93443
|
}
|
|
93364
93444
|
|
|
93365
93445
|
// src/causal-edge-queue.ts
|
|
93366
|
-
import { readFileSync as
|
|
93367
|
-
import { dirname as
|
|
93446
|
+
import { readFileSync as readFileSync38, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
|
|
93447
|
+
import { dirname as dirname16, join as join43 } from "node:path";
|
|
93368
93448
|
var CAUSAL_EDGE_QUEUE_CAP = 5e3;
|
|
93369
93449
|
var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
93370
93450
|
function causalEdgeQueuePath(workspaceConfigDir) {
|
|
93371
|
-
return
|
|
93451
|
+
return join43(workspaceConfigDir, "causal-edge-queue.json");
|
|
93372
93452
|
}
|
|
93373
93453
|
function parkedEdgeKey(e) {
|
|
93374
93454
|
return `${e.from}|${e.type}|${e.to}`;
|
|
@@ -93376,7 +93456,7 @@ function parkedEdgeKey(e) {
|
|
|
93376
93456
|
function loadCausalEdgeQueue(path3) {
|
|
93377
93457
|
let raw2;
|
|
93378
93458
|
try {
|
|
93379
|
-
raw2 = JSON.parse(
|
|
93459
|
+
raw2 = JSON.parse(readFileSync38(path3, "utf8"));
|
|
93380
93460
|
} catch {
|
|
93381
93461
|
return [];
|
|
93382
93462
|
}
|
|
@@ -93387,7 +93467,7 @@ function loadCausalEdgeQueue(path3) {
|
|
|
93387
93467
|
}
|
|
93388
93468
|
function saveCausalEdgeQueue(path3, queue) {
|
|
93389
93469
|
try {
|
|
93390
|
-
const tmp =
|
|
93470
|
+
const tmp = join43(dirname16(path3), `.${Date.now()}.causal-edge-queue.tmp`);
|
|
93391
93471
|
writeFileSync27(tmp, JSON.stringify(queue), "utf8");
|
|
93392
93472
|
renameSync7(tmp, path3);
|
|
93393
93473
|
} catch {
|
|
@@ -93819,9 +93899,9 @@ init_src11();
|
|
|
93819
93899
|
init_src();
|
|
93820
93900
|
import { execFile as execFile6 } from "node:child_process";
|
|
93821
93901
|
import { promisify as promisify4 } from "node:util";
|
|
93822
|
-
import { extname as extname3, join as
|
|
93902
|
+
import { extname as extname3, join as join44 } from "node:path";
|
|
93823
93903
|
import { createHash as createHash19 } from "node:crypto";
|
|
93824
|
-
import { readFileSync as
|
|
93904
|
+
import { readFileSync as readFileSync39 } from "node:fs";
|
|
93825
93905
|
|
|
93826
93906
|
// src/history-dependency-snapshot.ts
|
|
93827
93907
|
init_src();
|
|
@@ -93944,7 +94024,7 @@ var Bounded = class extends Map {
|
|
|
93944
94024
|
var DEFAULT_GIT = {};
|
|
93945
94025
|
function readFileSafe(path3) {
|
|
93946
94026
|
try {
|
|
93947
|
-
return
|
|
94027
|
+
return readFileSync39(path3, "utf8");
|
|
93948
94028
|
} catch {
|
|
93949
94029
|
return "";
|
|
93950
94030
|
}
|
|
@@ -93975,13 +94055,13 @@ async function syncHistoryRevision(opts) {
|
|
|
93975
94055
|
const started2 = Date.now();
|
|
93976
94056
|
let changed = 0, remaining = false;
|
|
93977
94057
|
const pages = Math.min(20, Math.max(1, opts.maxPages ?? 10));
|
|
93978
|
-
const
|
|
94058
|
+
const resolve11 = opts.profile.projectId ? reverseSymbolResolver({ store: opts.store, salt: opts.salt, projectId: opts.profile.projectId }) : async () => null;
|
|
93979
94059
|
for (let i2 = 0; i2 < pages; i2++) {
|
|
93980
|
-
const result = await syncHistoryRevisionPage(opts,
|
|
94060
|
+
const result = await syncHistoryRevisionPage(opts, resolve11);
|
|
93981
94061
|
changed += result.changed;
|
|
93982
94062
|
remaining = result.remaining;
|
|
93983
94063
|
if (!remaining || result.nextBeat || Date.now() - started2 >= (opts.budgetMs ?? 45e3)) break;
|
|
93984
|
-
await new Promise((
|
|
94064
|
+
await new Promise((resolve12) => setImmediate(resolve12));
|
|
93985
94065
|
}
|
|
93986
94066
|
return { changed, remaining };
|
|
93987
94067
|
})();
|
|
@@ -93992,13 +94072,13 @@ async function syncHistoryRevision(opts) {
|
|
|
93992
94072
|
if (inFlight.get(opts.root) === work) inFlight.delete(opts.root);
|
|
93993
94073
|
}
|
|
93994
94074
|
}
|
|
93995
|
-
async function syncHistoryRevisionPage(opts,
|
|
94075
|
+
async function syncHistoryRevisionPage(opts, resolve11) {
|
|
93996
94076
|
const { root, profile, store, cloud, salt } = opts;
|
|
93997
94077
|
if (!profile.projectId) return { changed: 0, remaining: false };
|
|
93998
94078
|
const projectId = profile.projectId;
|
|
93999
94079
|
const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
|
|
94000
94080
|
const caches = cachesFor(opts.git ?? DEFAULT_GIT);
|
|
94001
|
-
const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(
|
|
94081
|
+
const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join44(root, ".errataignore"))).digest("hex").slice(0, 16);
|
|
94002
94082
|
const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
|
|
94003
94083
|
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
|
|
94004
94084
|
const oldCursor = profile.historyRevisionCursor;
|
|
@@ -94126,7 +94206,7 @@ async function syncHistoryRevisionPage(opts, resolve10) {
|
|
|
94126
94206
|
const paths = /* @__PURE__ */ new Set(), symbols = [];
|
|
94127
94207
|
let partial2 = false;
|
|
94128
94208
|
for (const anchor of anchors ?? []) {
|
|
94129
|
-
const localId = await
|
|
94209
|
+
const localId = await resolve11(anchor.symbolId), local = localId ? store.getNode(localId) : null;
|
|
94130
94210
|
const path3 = local?.attrs["relPath"];
|
|
94131
94211
|
if (typeof path3 !== "string" || !pathAllowedByFloor(path3) || isPathBlocked(ignore2, path3) || /[\r\n]/.test(path3)) continue;
|
|
94132
94212
|
paths.add(path3);
|
|
@@ -94318,8 +94398,8 @@ ${await git3(["rev-list", "--parents", "-1", from])}`.split("\n").map((row) => r
|
|
|
94318
94398
|
init_src7();
|
|
94319
94399
|
init_src();
|
|
94320
94400
|
import { execFile as execFile7 } from "node:child_process";
|
|
94321
|
-
import { readFileSync as
|
|
94322
|
-
import { join as
|
|
94401
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
94402
|
+
import { join as join45 } from "node:path";
|
|
94323
94403
|
import { promisify as promisify5 } from "node:util";
|
|
94324
94404
|
|
|
94325
94405
|
// src/history-walk.ts
|
|
@@ -94726,8 +94806,8 @@ var GitBlobReader = class {
|
|
|
94726
94806
|
if (this.failed) return Promise.reject(this.failed);
|
|
94727
94807
|
if (/[\r\n]/.test(spec)) return Promise.resolve(null);
|
|
94728
94808
|
const proc = this.start();
|
|
94729
|
-
return new Promise((
|
|
94730
|
-
this.queue.push({ resolve:
|
|
94809
|
+
return new Promise((resolve11, reject) => {
|
|
94810
|
+
this.queue.push({ resolve: resolve11, reject });
|
|
94731
94811
|
proc.stdin.write(`${spec}
|
|
94732
94812
|
`);
|
|
94733
94813
|
});
|
|
@@ -94741,14 +94821,14 @@ var GitBlobReader = class {
|
|
|
94741
94821
|
const proc = this.proc;
|
|
94742
94822
|
this.proc = null;
|
|
94743
94823
|
if (!proc || proc.exitCode !== null) return Promise.resolve();
|
|
94744
|
-
return new Promise((
|
|
94824
|
+
return new Promise((resolve11) => {
|
|
94745
94825
|
const timer = setTimeout(() => {
|
|
94746
94826
|
proc.kill();
|
|
94747
|
-
|
|
94827
|
+
resolve11();
|
|
94748
94828
|
}, timeoutMs);
|
|
94749
94829
|
proc.once("exit", () => {
|
|
94750
94830
|
clearTimeout(timer);
|
|
94751
|
-
|
|
94831
|
+
resolve11();
|
|
94752
94832
|
});
|
|
94753
94833
|
proc.stdin.end();
|
|
94754
94834
|
});
|
|
@@ -94878,7 +94958,7 @@ async function defaultGit(root, args2) {
|
|
|
94878
94958
|
function readIgnoreLines(root, profile) {
|
|
94879
94959
|
let lines = [];
|
|
94880
94960
|
try {
|
|
94881
|
-
lines =
|
|
94961
|
+
lines = readFileSync40(join45(root, ".errataignore"), "utf8").split("\n");
|
|
94882
94962
|
} catch {
|
|
94883
94963
|
}
|
|
94884
94964
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -95458,8 +95538,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
95458
95538
|
init_cloud_auth();
|
|
95459
95539
|
import { createHash as createHash20 } from "node:crypto";
|
|
95460
95540
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
95461
|
-
import { existsSync as
|
|
95462
|
-
import { join as
|
|
95541
|
+
import { existsSync as existsSync33, writeFileSync as writeFileSync28 } from "node:fs";
|
|
95542
|
+
import { join as join46 } from "node:path";
|
|
95463
95543
|
|
|
95464
95544
|
// src/device-poll.ts
|
|
95465
95545
|
var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
|
|
@@ -95549,7 +95629,7 @@ async function loginOAuthDevice(opts) {
|
|
|
95549
95629
|
let deviceSession = null;
|
|
95550
95630
|
let approvedInstallation = null;
|
|
95551
95631
|
while (Date.now() < deadline) {
|
|
95552
|
-
await (opts.sleep ?? ((ms) => new Promise((
|
|
95632
|
+
await (opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms))))(waitMs);
|
|
95553
95633
|
waitMs = intervalMs;
|
|
95554
95634
|
const poll = await fetchDevicePoll(fetchFn, device.token, {
|
|
95555
95635
|
method: "POST",
|
|
@@ -95674,7 +95754,7 @@ async function loginOAuthLoopback(opts) {
|
|
|
95674
95754
|
const state = randomState();
|
|
95675
95755
|
const scope = opts.scope ?? CODE_FLOW_OAUTH_SCOPE;
|
|
95676
95756
|
const { code, redirectUri, clientId } = await new Promise(
|
|
95677
|
-
(
|
|
95757
|
+
(resolve11, reject) => {
|
|
95678
95758
|
const server = createServer((req, res) => {
|
|
95679
95759
|
const u = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
95680
95760
|
if (u.pathname !== "/callback") {
|
|
@@ -95697,7 +95777,7 @@ async function loginOAuthLoopback(opts) {
|
|
|
95697
95777
|
res.writeHead(200, { "content-type": "text/html" });
|
|
95698
95778
|
res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
|
|
95699
95779
|
server.close();
|
|
95700
|
-
|
|
95780
|
+
resolve11({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
|
|
95701
95781
|
});
|
|
95702
95782
|
let activeClientId = oauthClientId();
|
|
95703
95783
|
server.on("error", reject);
|
|
@@ -95796,7 +95876,7 @@ async function linkThroughConsole(opts) {
|
|
|
95796
95876
|
const deadline = Date.now() + Math.min(code.expires_in * 1e3, opts.timeoutMs ?? Number.POSITIVE_INFINITY);
|
|
95797
95877
|
let intervalMs = Math.max(2, code.interval ?? 5) * 1e3;
|
|
95798
95878
|
let waitMs = intervalMs;
|
|
95799
|
-
const sleep = opts.sleep ?? ((ms) => new Promise((
|
|
95879
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((resolve11) => setTimeout(resolve11, ms)));
|
|
95800
95880
|
while (Date.now() < deadline) {
|
|
95801
95881
|
await sleep(waitMs);
|
|
95802
95882
|
waitMs = intervalMs;
|
|
@@ -95918,8 +95998,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
|
|
|
95918
95998
|
delete nextProfile.projectLinkHold;
|
|
95919
95999
|
let wroteIgnore = false;
|
|
95920
96000
|
if (decision.writeIgnoreStarter !== false) {
|
|
95921
|
-
const target =
|
|
95922
|
-
if (!
|
|
96001
|
+
const target = join46(root, ".errataignore");
|
|
96002
|
+
if (!existsSync33(target)) {
|
|
95923
96003
|
writeFileSync28(target, IGNORE_STARTER, "utf8");
|
|
95924
96004
|
wroteIgnore = true;
|
|
95925
96005
|
}
|
|
@@ -95933,13 +96013,13 @@ init_registry();
|
|
|
95933
96013
|
|
|
95934
96014
|
// src/adopt.ts
|
|
95935
96015
|
init_git_remote();
|
|
95936
|
-
import { existsSync as
|
|
95937
|
-
import { dirname as
|
|
96016
|
+
import { existsSync as existsSync34 } from "node:fs";
|
|
96017
|
+
import { dirname as dirname17, join as join47 } from "node:path";
|
|
95938
96018
|
function findGitRoot(absPath) {
|
|
95939
96019
|
let dir = absPath;
|
|
95940
96020
|
for (let depth = 0; depth < 64; depth++) {
|
|
95941
|
-
if (
|
|
95942
|
-
const parent =
|
|
96021
|
+
if (existsSync34(join47(dir, ".git"))) return dir;
|
|
96022
|
+
const parent = dirname17(dir);
|
|
95943
96023
|
if (parent === dir) return null;
|
|
95944
96024
|
dir = parent;
|
|
95945
96025
|
}
|
|
@@ -96352,7 +96432,7 @@ function resolveWorkspaceRef(ref, entries, ownerRoot) {
|
|
|
96352
96432
|
|
|
96353
96433
|
// src/rehome.ts
|
|
96354
96434
|
init_src2();
|
|
96355
|
-
import { isAbsolute as
|
|
96435
|
+
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
96356
96436
|
function sourcesOf(n) {
|
|
96357
96437
|
const s = n.attrs["sources"];
|
|
96358
96438
|
return Array.isArray(s) ? s.filter((x) => typeof x === "string") : [];
|
|
@@ -96416,7 +96496,7 @@ function captureWorkPaths(store, home) {
|
|
|
96416
96496
|
if (store.outEdges(row.id, ["ANCHORED_AT"]).length > 0) where = home;
|
|
96417
96497
|
else {
|
|
96418
96498
|
const hint = row.attrs["anchorHint"];
|
|
96419
|
-
if (typeof hint?.path === "string" && hint.path.length > 0) where =
|
|
96499
|
+
if (typeof hint?.path === "string" && hint.path.length > 0) where = isAbsolute7(hint.path) ? hint.path : home;
|
|
96420
96500
|
}
|
|
96421
96501
|
for (const s of sources) {
|
|
96422
96502
|
const list = out2.get(s) ?? [];
|
|
@@ -96581,7 +96661,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96581
96661
|
};
|
|
96582
96662
|
const sharedDbPath = sharedStorePath();
|
|
96583
96663
|
ensureParent(sharedDbPath);
|
|
96584
|
-
if (sharedDbPath !== ":memory:") excludeFromIndexing(
|
|
96664
|
+
if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname18(sharedDbPath));
|
|
96585
96665
|
await prepareStore(sharedDbPath, process.cwd(), "shared");
|
|
96586
96666
|
const sharedStore = openGraphStore({ path: sharedDbPath });
|
|
96587
96667
|
const bundledRun = import.meta.url.endsWith(".mjs");
|
|
@@ -96725,7 +96805,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96725
96805
|
held.push(...quarantined);
|
|
96726
96806
|
let ignoreFile = "";
|
|
96727
96807
|
try {
|
|
96728
|
-
ignoreFile =
|
|
96808
|
+
ignoreFile = readFileSync41(join48(r.root, ".errataignore"), "utf8");
|
|
96729
96809
|
} catch {
|
|
96730
96810
|
}
|
|
96731
96811
|
const retryInputs = JSON.stringify([
|
|
@@ -96793,7 +96873,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96793
96873
|
const id = entry.id;
|
|
96794
96874
|
const castaliaPath = workspacePaths(entry.path).castalia;
|
|
96795
96875
|
ensureParent(castaliaPath);
|
|
96796
|
-
excludeFromIndexing(
|
|
96876
|
+
excludeFromIndexing(dirname18(castaliaPath));
|
|
96797
96877
|
await prepareStore(castaliaPath, entry.path, id);
|
|
96798
96878
|
if (stopping) throw new Error("daemon stopping");
|
|
96799
96879
|
const wsIdentity = identityFor(entry);
|
|
@@ -97300,10 +97380,10 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97300
97380
|
};
|
|
97301
97381
|
const MISFILED_SWEEP_DELAY_MS = 2 * 6e4;
|
|
97302
97382
|
const sweepMisfiled = async (rec) => {
|
|
97303
|
-
const checkedPath =
|
|
97383
|
+
const checkedPath = join48(workspacePaths(rec.root).configDir, "rehome-checked.json");
|
|
97304
97384
|
let checked;
|
|
97305
97385
|
try {
|
|
97306
|
-
checked = new Set(JSON.parse(
|
|
97386
|
+
checked = new Set(JSON.parse(readFileSync41(checkedPath, "utf8")));
|
|
97307
97387
|
} catch {
|
|
97308
97388
|
checked = /* @__PURE__ */ new Set();
|
|
97309
97389
|
}
|
|
@@ -97422,7 +97502,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97422
97502
|
lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
|
|
97423
97503
|
} catch {
|
|
97424
97504
|
}
|
|
97425
|
-
const reason = retireDecision({ exists:
|
|
97505
|
+
const reason = retireDecision({ exists: existsSync35(rec.root), lastActiveAt, now });
|
|
97426
97506
|
if (reason) void retireWorkspace(rec, reason);
|
|
97427
97507
|
}
|
|
97428
97508
|
};
|
|
@@ -97785,7 +97865,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97785
97865
|
const packageAutoAll = async () => {
|
|
97786
97866
|
const out2 = /* @__PURE__ */ new Map();
|
|
97787
97867
|
for (const r of records) {
|
|
97788
|
-
await new Promise((
|
|
97868
|
+
await new Promise((resolve11) => setImmediate(resolve11));
|
|
97789
97869
|
const done = markPass(`package-index:${r.entry.name}`);
|
|
97790
97870
|
try {
|
|
97791
97871
|
out2.set(
|
|
@@ -99049,15 +99129,15 @@ function shouldUseOAuthLogin(flags2, env2 = process.env) {
|
|
|
99049
99129
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
99050
99130
|
|
|
99051
99131
|
// src/codex-runtime.ts
|
|
99052
|
-
import { readdirSync as readdirSync13, statSync as
|
|
99053
|
-
import { join as
|
|
99132
|
+
import { readdirSync as readdirSync13, statSync as statSync13 } from "node:fs";
|
|
99133
|
+
import { join as join49 } from "node:path";
|
|
99054
99134
|
function resolveCodexExecutable(options = {}) {
|
|
99055
99135
|
const platform = options.platform ?? process.platform;
|
|
99056
99136
|
const env2 = options.env ?? process.env;
|
|
99057
99137
|
if (platform !== "win32") return "codex";
|
|
99058
99138
|
const fileTime = (path3) => {
|
|
99059
99139
|
try {
|
|
99060
|
-
const s =
|
|
99140
|
+
const s = statSync13(path3);
|
|
99061
99141
|
return s.isFile() ? s.mtimeMs : null;
|
|
99062
99142
|
} catch {
|
|
99063
99143
|
return null;
|
|
@@ -99065,13 +99145,13 @@ function resolveCodexExecutable(options = {}) {
|
|
|
99065
99145
|
};
|
|
99066
99146
|
for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
|
|
99067
99147
|
if (!dir.trim()) continue;
|
|
99068
|
-
const path3 =
|
|
99148
|
+
const path3 = join49(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
|
|
99069
99149
|
if (fileTime(path3) !== null) return path3;
|
|
99070
99150
|
}
|
|
99071
99151
|
if (!env2["LOCALAPPDATA"]) return "codex";
|
|
99072
|
-
const root =
|
|
99152
|
+
const root = join49(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
|
|
99073
99153
|
try {
|
|
99074
|
-
const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
99154
|
+
const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join49(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
|
|
99075
99155
|
return candidates[0]?.path ?? "codex";
|
|
99076
99156
|
} catch {
|
|
99077
99157
|
return "codex";
|
|
@@ -99210,14 +99290,14 @@ async function diagnoseInstallation(cfg, dependencies) {
|
|
|
99210
99290
|
}
|
|
99211
99291
|
|
|
99212
99292
|
// src/credential-scan.ts
|
|
99213
|
-
import { readFileSync as
|
|
99293
|
+
import { readFileSync as readFileSync43, statSync as statSync14 } from "node:fs";
|
|
99214
99294
|
import { homedir as homedir8 } from "node:os";
|
|
99215
|
-
import { join as
|
|
99295
|
+
import { join as join51 } from "node:path";
|
|
99216
99296
|
|
|
99217
99297
|
// src/claude-statusline.ts
|
|
99218
|
-
import { existsSync as
|
|
99298
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync9, readFileSync as readFileSync42, writeFileSync as writeFileSync30 } from "node:fs";
|
|
99219
99299
|
import { homedir as homedir7 } from "node:os";
|
|
99220
|
-
import { dirname as
|
|
99300
|
+
import { dirname as dirname19, join as join50 } from "node:path";
|
|
99221
99301
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
99222
99302
|
import { readFileSync } from 'node:fs';
|
|
99223
99303
|
|
|
@@ -99265,8 +99345,8 @@ function isSameInstall(value, relay) {
|
|
|
99265
99345
|
return command.includes(relay.replace(/\\/g, "/").toLowerCase());
|
|
99266
99346
|
}
|
|
99267
99347
|
function userClaudeSettingsPath() {
|
|
99268
|
-
const base = process.env["CLAUDE_CONFIG_DIR"] ??
|
|
99269
|
-
return
|
|
99348
|
+
const base = process.env["CLAUDE_CONFIG_DIR"] ?? join50(homedir7(), ".claude");
|
|
99349
|
+
return join50(base, "settings.json");
|
|
99270
99350
|
}
|
|
99271
99351
|
function ensureUserStatusLine(opts) {
|
|
99272
99352
|
const env2 = opts.env ?? process.env;
|
|
@@ -99274,22 +99354,22 @@ function ensureUserStatusLine(opts) {
|
|
|
99274
99354
|
if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
|
|
99275
99355
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
99276
99356
|
let settings = {};
|
|
99277
|
-
if (
|
|
99357
|
+
if (existsSync36(settingsPath)) {
|
|
99278
99358
|
try {
|
|
99279
|
-
const parsed = JSON.parse(
|
|
99359
|
+
const parsed = JSON.parse(readFileSync42(settingsPath, "utf8"));
|
|
99280
99360
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
99281
99361
|
settings = parsed;
|
|
99282
99362
|
} catch {
|
|
99283
99363
|
return "unreadable";
|
|
99284
99364
|
}
|
|
99285
99365
|
}
|
|
99286
|
-
const relay =
|
|
99366
|
+
const relay = join50(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
99287
99367
|
const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
|
|
99288
99368
|
const ownMain = keep(settings["statusLine"]);
|
|
99289
99369
|
const ownRows = keep(settings["subagentStatusLine"]);
|
|
99290
99370
|
if (ownMain && ownRows) return "kept-own";
|
|
99291
99371
|
mkdirSync9(opts.relayDir, { recursive: true });
|
|
99292
|
-
if (!
|
|
99372
|
+
if (!existsSync36(relay) || readFileSync42(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
99293
99373
|
writeFileSync30(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
99294
99374
|
}
|
|
99295
99375
|
const nodePath = opts.nodePath ?? process.execPath;
|
|
@@ -99301,7 +99381,7 @@ function ensureUserStatusLine(opts) {
|
|
|
99301
99381
|
return ownMain ? "kept-own" : "unchanged";
|
|
99302
99382
|
}
|
|
99303
99383
|
Object.assign(settings, next);
|
|
99304
|
-
mkdirSync9(
|
|
99384
|
+
mkdirSync9(dirname19(settingsPath), { recursive: true });
|
|
99305
99385
|
writeFileSync30(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
99306
99386
|
return "installed";
|
|
99307
99387
|
}
|
|
@@ -99343,36 +99423,36 @@ function findCredentialLines(text) {
|
|
|
99343
99423
|
function harnessConfigPaths(root) {
|
|
99344
99424
|
const env2 = process.env;
|
|
99345
99425
|
const home = homedir8();
|
|
99346
|
-
const codexHome = env2["CODEX_HOME"] ||
|
|
99347
|
-
const geminiHome =
|
|
99426
|
+
const codexHome = env2["CODEX_HOME"] || join51(home, ".codex");
|
|
99427
|
+
const geminiHome = join51(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
|
|
99348
99428
|
return [
|
|
99349
99429
|
// Claude Code: user settings, `claude mcp add` (local/user scope), project.
|
|
99350
99430
|
userClaudeSettingsPath(),
|
|
99351
|
-
|
|
99352
|
-
|
|
99353
|
-
|
|
99354
|
-
|
|
99431
|
+
join51(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
|
|
99432
|
+
join51(root, ".claude", "settings.json"),
|
|
99433
|
+
join51(root, ".claude", "settings.local.json"),
|
|
99434
|
+
join51(root, ".mcp.json"),
|
|
99355
99435
|
// Codex
|
|
99356
|
-
|
|
99357
|
-
|
|
99436
|
+
join51(codexHome, "config.toml"),
|
|
99437
|
+
join51(root, ".codex", "config.toml"),
|
|
99358
99438
|
// Gemini CLI
|
|
99359
|
-
|
|
99360
|
-
|
|
99439
|
+
join51(geminiHome, "settings.json"),
|
|
99440
|
+
join51(root, ".gemini", "settings.json"),
|
|
99361
99441
|
// Cursor
|
|
99362
|
-
|
|
99363
|
-
|
|
99442
|
+
join51(home, ".cursor", "mcp.json"),
|
|
99443
|
+
join51(root, ".cursor", "mcp.json"),
|
|
99364
99444
|
// VS Code (user profile mcp.json + workspace)
|
|
99365
|
-
|
|
99366
|
-
|
|
99445
|
+
join51(vscodeUserDir(home, env2), "mcp.json"),
|
|
99446
|
+
join51(root, ".vscode", "mcp.json"),
|
|
99367
99447
|
// OpenCode (XDG on every platform; the daemon's installer writes the project one)
|
|
99368
|
-
|
|
99369
|
-
|
|
99448
|
+
join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "opencode", "opencode.json"),
|
|
99449
|
+
join51(root, "opencode.json")
|
|
99370
99450
|
];
|
|
99371
99451
|
}
|
|
99372
99452
|
function vscodeUserDir(home, env2) {
|
|
99373
|
-
if (process.platform === "win32") return
|
|
99374
|
-
if (process.platform === "darwin") return
|
|
99375
|
-
return
|
|
99453
|
+
if (process.platform === "win32") return join51(env2["APPDATA"] ?? join51(home, "AppData", "Roaming"), "Code", "User");
|
|
99454
|
+
if (process.platform === "darwin") return join51(home, "Library", "Application Support", "Code", "User");
|
|
99455
|
+
return join51(env2["XDG_CONFIG_HOME"] ?? join51(home, ".config"), "Code", "User");
|
|
99376
99456
|
}
|
|
99377
99457
|
function scanHarnessConfigs(paths, read2 = readBounded) {
|
|
99378
99458
|
const findings = [];
|
|
@@ -99387,9 +99467,9 @@ function scanHarnessConfigs(paths, read2 = readBounded) {
|
|
|
99387
99467
|
}
|
|
99388
99468
|
function readBounded(path3) {
|
|
99389
99469
|
try {
|
|
99390
|
-
const stat4 =
|
|
99470
|
+
const stat4 = statSync14(path3);
|
|
99391
99471
|
if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
|
|
99392
|
-
return
|
|
99472
|
+
return readFileSync43(path3, "utf8");
|
|
99393
99473
|
} catch {
|
|
99394
99474
|
return null;
|
|
99395
99475
|
}
|
|
@@ -99414,14 +99494,14 @@ function credentialHygieneCheck(scan2) {
|
|
|
99414
99494
|
|
|
99415
99495
|
// src/codex-doctor.ts
|
|
99416
99496
|
import { spawn as spawn4 } from "node:child_process";
|
|
99417
|
-
import { readFileSync as
|
|
99418
|
-
import { join as
|
|
99497
|
+
import { readFileSync as readFileSync45, statSync as statSync15 } from "node:fs";
|
|
99498
|
+
import { join as join53 } from "node:path";
|
|
99419
99499
|
import { createInterface } from "node:readline";
|
|
99420
99500
|
|
|
99421
99501
|
// src/codex-hooks.ts
|
|
99422
|
-
import { existsSync as
|
|
99502
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync44, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
|
|
99423
99503
|
import { homedir as homedir9 } from "node:os";
|
|
99424
|
-
import { join as
|
|
99504
|
+
import { join as join52 } from "node:path";
|
|
99425
99505
|
|
|
99426
99506
|
// src/hook-commands.ts
|
|
99427
99507
|
function hookCurlCommand(port, path3 = "/api/hook") {
|
|
@@ -99633,34 +99713,34 @@ function buildCodexRelaySource(workspaceRoot) {
|
|
|
99633
99713
|
init_checkout_root();
|
|
99634
99714
|
var CODEX_HOOK_REVIEW_HELP = "Codex desktop: Settings > Hooks, select this project, expand each event and Trust the Errata hook. CLI users can use /hooks.";
|
|
99635
99715
|
function writeRelay(file2, source) {
|
|
99636
|
-
if (
|
|
99716
|
+
if (existsSync37(file2) && readFileSync44(file2, "utf8") === source) return;
|
|
99637
99717
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
99638
99718
|
try {
|
|
99639
99719
|
writeFileSync31(temp, source, { encoding: "utf8", mode: 384 });
|
|
99640
99720
|
renameSync8(temp, file2);
|
|
99641
99721
|
} finally {
|
|
99642
|
-
if (
|
|
99722
|
+
if (existsSync37(temp)) unlinkSync5(temp);
|
|
99643
99723
|
}
|
|
99644
99724
|
}
|
|
99645
99725
|
function refreshCodexRelay(root) {
|
|
99646
|
-
const config2 =
|
|
99647
|
-
if (!
|
|
99648
|
-
const existing =
|
|
99726
|
+
const config2 = join52(root, ".codex", "config.toml");
|
|
99727
|
+
if (!existsSync37(config2)) return "absent";
|
|
99728
|
+
const existing = readFileSync44(config2, "utf8");
|
|
99649
99729
|
if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
|
|
99650
99730
|
replaceCodexHooks(existing, "");
|
|
99651
|
-
const relay =
|
|
99652
|
-
const prior =
|
|
99731
|
+
const relay = join52(root, ".codex", "hooks", "errata-relay.mjs");
|
|
99732
|
+
const prior = existsSync37(relay) ? readFileSync44(relay, "utf8") : "";
|
|
99653
99733
|
if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
|
|
99654
99734
|
throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
|
|
99655
99735
|
}
|
|
99656
99736
|
const source = buildCodexRelaySource(checkoutRootOf(root));
|
|
99657
99737
|
if (prior === source) return "current";
|
|
99658
|
-
mkdirSync10(
|
|
99738
|
+
mkdirSync10(join52(root, ".codex", "hooks"), { recursive: true });
|
|
99659
99739
|
writeRelay(relay, source);
|
|
99660
99740
|
return "updated";
|
|
99661
99741
|
}
|
|
99662
|
-
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] ||
|
|
99663
|
-
return
|
|
99742
|
+
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join52(homedir9(), ".codex")) {
|
|
99743
|
+
return existsSync37(join52(root, ".codex")) || existsSync37(codexHome);
|
|
99664
99744
|
}
|
|
99665
99745
|
function replaceCodexHooks(existing, block) {
|
|
99666
99746
|
const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
|
|
@@ -99676,14 +99756,14 @@ function replaceCodexHooks(existing, block) {
|
|
|
99676
99756
|
return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
|
|
99677
99757
|
}
|
|
99678
99758
|
function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
99679
|
-
const dir =
|
|
99680
|
-
const file2 =
|
|
99681
|
-
const relay =
|
|
99759
|
+
const dir = join52(root, ".codex");
|
|
99760
|
+
const file2 = join52(dir, "config.toml");
|
|
99761
|
+
const relay = join52(dir, "hooks", "errata-relay.mjs");
|
|
99682
99762
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
99683
|
-
const final = replaceCodexHooks(
|
|
99684
|
-
mkdirSync10(
|
|
99763
|
+
const final = replaceCodexHooks(existsSync37(file2) ? readFileSync44(file2, "utf8") : "", block);
|
|
99764
|
+
mkdirSync10(join52(dir, "hooks"), { recursive: true });
|
|
99685
99765
|
writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
|
|
99686
|
-
if (!
|
|
99766
|
+
if (!existsSync37(file2) || readFileSync44(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
|
|
99687
99767
|
return file2;
|
|
99688
99768
|
}
|
|
99689
99769
|
|
|
@@ -99692,7 +99772,7 @@ init_checkout_root();
|
|
|
99692
99772
|
function inspectCodexRelay(cwd) {
|
|
99693
99773
|
const root = nearestGitRoot(cwd) ?? cwd;
|
|
99694
99774
|
try {
|
|
99695
|
-
const source =
|
|
99775
|
+
const source = readFileSync45(join53(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
|
|
99696
99776
|
if (source === buildCodexRelaySource(checkoutRootOf(root))) {
|
|
99697
99777
|
return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
|
|
99698
99778
|
}
|
|
@@ -99703,8 +99783,8 @@ function inspectCodexRelay(cwd) {
|
|
|
99703
99783
|
function inspectCodexContext(cwd) {
|
|
99704
99784
|
const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
|
|
99705
99785
|
try {
|
|
99706
|
-
const file2 =
|
|
99707
|
-
if (
|
|
99786
|
+
const file2 = join53(root, ".errata", "context.md");
|
|
99787
|
+
if (statSync15(file2).size <= 128 * 1024 && readFileSync45(file2, "utf8").trim()) {
|
|
99708
99788
|
return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
|
|
99709
99789
|
}
|
|
99710
99790
|
} catch {
|
|
@@ -99714,7 +99794,7 @@ function inspectCodexContext(cwd) {
|
|
|
99714
99794
|
var CodexRuntimeUnavailableError = class extends Error {
|
|
99715
99795
|
};
|
|
99716
99796
|
function readCodexHookState(cwd, options = {}) {
|
|
99717
|
-
return new Promise((
|
|
99797
|
+
return new Promise((resolve11, reject) => {
|
|
99718
99798
|
const child = spawn4(options.bin ?? resolveCodexExecutable(), options.args ?? ["app-server", "--stdio"], {
|
|
99719
99799
|
cwd,
|
|
99720
99800
|
windowsHide: true,
|
|
@@ -99735,7 +99815,7 @@ function readCodexHookState(cwd, options = {}) {
|
|
|
99735
99815
|
child.once("close", () => {
|
|
99736
99816
|
clearTimeout(reap);
|
|
99737
99817
|
if (error48) reject(error48);
|
|
99738
|
-
else
|
|
99818
|
+
else resolve11({ ...hooks, features });
|
|
99739
99819
|
});
|
|
99740
99820
|
child.kill();
|
|
99741
99821
|
};
|
|
@@ -99882,9 +99962,9 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
99882
99962
|
|
|
99883
99963
|
// src/codex-context-plugin.ts
|
|
99884
99964
|
import { createHash as createHash21 } from "node:crypto";
|
|
99885
|
-
import { cpSync as cpSync2, existsSync as
|
|
99965
|
+
import { cpSync as cpSync2, existsSync as existsSync38, mkdirSync as mkdirSync11, readFileSync as readFileSync46, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
|
|
99886
99966
|
import { homedir as homedir10 } from "node:os";
|
|
99887
|
-
import { join as
|
|
99967
|
+
import { join as join54 } from "node:path";
|
|
99888
99968
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
99889
99969
|
|
|
99890
99970
|
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
@@ -100582,7 +100662,7 @@ var NAME = "errata-context";
|
|
|
100582
100662
|
var PREFIX2 = `./.errata/plugins/${NAME}/`;
|
|
100583
100663
|
var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
100584
100664
|
function readText(file2) {
|
|
100585
|
-
return
|
|
100665
|
+
return existsSync38(file2) ? readFileSync46(file2, "utf8") : "";
|
|
100586
100666
|
}
|
|
100587
100667
|
function writeChanged(file2, content) {
|
|
100588
100668
|
if (readText(file2) === content) return;
|
|
@@ -100592,13 +100672,13 @@ function writeChanged(file2, content) {
|
|
|
100592
100672
|
}
|
|
100593
100673
|
function bundledContextPlugin() {
|
|
100594
100674
|
const packaged = fileURLToPath3(new URL("./resources/context-plugin/", import.meta.url));
|
|
100595
|
-
if (
|
|
100675
|
+
if (existsSync38(join54(packaged, ".codex-plugin/plugin.json"))) return packaged;
|
|
100596
100676
|
return fileURLToPath3(new URL("../dist/resources/context-plugin/", import.meta.url));
|
|
100597
100677
|
}
|
|
100598
100678
|
function refreshCodexContextPlugin(root) {
|
|
100599
|
-
const file2 =
|
|
100600
|
-
if (!
|
|
100601
|
-
const marketplace = JSON.parse(
|
|
100679
|
+
const file2 = join54(root, ".agents", "plugins", "marketplace.json");
|
|
100680
|
+
if (!existsSync38(file2)) return false;
|
|
100681
|
+
const marketplace = JSON.parse(readFileSync46(file2, "utf8"));
|
|
100602
100682
|
const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
100603
100683
|
const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
|
|
100604
100684
|
if (!entry) return false;
|
|
@@ -100609,24 +100689,24 @@ function refreshCodexContextPlugin(root) {
|
|
|
100609
100689
|
function installCodexContextPlugin(root, options = {}) {
|
|
100610
100690
|
const bundle = options.bundle ?? bundledContextPlugin();
|
|
100611
100691
|
const manifest = JSON.parse(
|
|
100612
|
-
|
|
100692
|
+
readFileSync46(join54(bundle, ".codex-plugin/plugin.json"), "utf8")
|
|
100613
100693
|
);
|
|
100614
100694
|
if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
|
|
100615
100695
|
throw new Error("Invalid bundled Errata Context manifest.");
|
|
100616
100696
|
}
|
|
100617
|
-
const checksums =
|
|
100697
|
+
const checksums = readFileSync46(join54(bundle, "SHA256SUMS"), "utf8");
|
|
100618
100698
|
for (const line of checksums.trim().split("\n")) {
|
|
100619
100699
|
const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
|
|
100620
100700
|
if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
|
|
100621
100701
|
throw new Error("Invalid bundled Errata Context checksum manifest.");
|
|
100622
100702
|
}
|
|
100623
|
-
const actual = createHash21("sha256").update(
|
|
100703
|
+
const actual = createHash21("sha256").update(readFileSync46(join54(bundle, match2[2]))).digest("hex");
|
|
100624
100704
|
if (actual !== match2[1])
|
|
100625
100705
|
throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
|
|
100626
100706
|
}
|
|
100627
100707
|
const release = `${manifest.version}-${createHash21("sha256").update(checksums).digest("hex").slice(0, 12)}`;
|
|
100628
|
-
const plugin =
|
|
100629
|
-
const marketplaceFile =
|
|
100708
|
+
const plugin = join54(root, ".errata", "plugins", NAME, release);
|
|
100709
|
+
const marketplaceFile = join54(root, ".agents", "plugins", "marketplace.json");
|
|
100630
100710
|
const priorMarketplace = readText(marketplaceFile);
|
|
100631
100711
|
const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
|
|
100632
100712
|
name: "errata-local",
|
|
@@ -100647,12 +100727,12 @@ function installCodexContextPlugin(root, options = {}) {
|
|
|
100647
100727
|
);
|
|
100648
100728
|
}
|
|
100649
100729
|
const key = `${NAME}@${marketplace.name}`;
|
|
100650
|
-
const configFile =
|
|
100730
|
+
const configFile = join54(root, ".codex", "config.toml");
|
|
100651
100731
|
const config2 = readText(configFile);
|
|
100652
100732
|
const parsed = parse4(config2);
|
|
100653
100733
|
const plugins = object2(parsed.plugins);
|
|
100654
|
-
const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ??
|
|
100655
|
-
const globalPlugins = object2(parse4(readText(
|
|
100734
|
+
const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join54(homedir10(), ".codex");
|
|
100735
|
+
const globalPlugins = object2(parse4(readText(join54(codexHome, "config.toml"))).plugins);
|
|
100656
100736
|
const disabledGlobally = Object.entries(globalPlugins).some(
|
|
100657
100737
|
([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
|
|
100658
100738
|
);
|
|
@@ -100676,13 +100756,13 @@ enabled = ${enabled}
|
|
|
100676
100756
|
mkdirSync11(plugin, { recursive: true });
|
|
100677
100757
|
cpSync2(bundle, plugin, { recursive: true });
|
|
100678
100758
|
writeChanged(
|
|
100679
|
-
|
|
100759
|
+
join54(plugin, ".mcp.json"),
|
|
100680
100760
|
JSON.stringify(
|
|
100681
100761
|
{
|
|
100682
100762
|
mcpServers: {
|
|
100683
100763
|
errata_context: {
|
|
100684
100764
|
command: options.nodePath ?? process.execPath,
|
|
100685
|
-
args: [
|
|
100765
|
+
args: [join54(plugin, "dist", "mcp-server.mjs")],
|
|
100686
100766
|
env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
|
|
100687
100767
|
}
|
|
100688
100768
|
}
|
|
@@ -100691,8 +100771,8 @@ enabled = ${enabled}
|
|
|
100691
100771
|
2
|
|
100692
100772
|
) + "\n"
|
|
100693
100773
|
);
|
|
100694
|
-
mkdirSync11(
|
|
100695
|
-
mkdirSync11(
|
|
100774
|
+
mkdirSync11(join54(root, ".agents", "plugins"), { recursive: true });
|
|
100775
|
+
mkdirSync11(join54(root, ".codex"), { recursive: true });
|
|
100696
100776
|
writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
|
|
100697
100777
|
writeChanged(configFile, nextConfig);
|
|
100698
100778
|
return { plugin, enabled, marketplace: marketplaceFile };
|
|
@@ -100700,16 +100780,16 @@ enabled = ${enabled}
|
|
|
100700
100780
|
|
|
100701
100781
|
// src/codex-hook-refresh.ts
|
|
100702
100782
|
init_checkout_root();
|
|
100703
|
-
import { existsSync as
|
|
100704
|
-
import { dirname as
|
|
100783
|
+
import { existsSync as existsSync39, readdirSync as readdirSync14, readFileSync as readFileSync47 } from "node:fs";
|
|
100784
|
+
import { dirname as dirname20, join as join55, resolve as resolve9 } from "node:path";
|
|
100705
100785
|
init_registry();
|
|
100706
100786
|
function codexHookRoots(roots) {
|
|
100707
|
-
const found = new Set(roots.map((root) =>
|
|
100787
|
+
const found = new Set(roots.map((root) => resolve9(root)));
|
|
100708
100788
|
for (const root of [...found]) {
|
|
100709
100789
|
const main2 = mainCheckoutOfWorktree(root) ?? root;
|
|
100710
100790
|
found.add(main2);
|
|
100711
|
-
const dir =
|
|
100712
|
-
if (!
|
|
100791
|
+
const dir = join55(main2, ".git", "worktrees");
|
|
100792
|
+
if (!existsSync39(dir)) continue;
|
|
100713
100793
|
let names;
|
|
100714
100794
|
try {
|
|
100715
100795
|
names = readdirSync14(dir);
|
|
@@ -100718,7 +100798,7 @@ function codexHookRoots(roots) {
|
|
|
100718
100798
|
}
|
|
100719
100799
|
for (const name2 of names) {
|
|
100720
100800
|
try {
|
|
100721
|
-
const checkout =
|
|
100801
|
+
const checkout = dirname20(readFileSync47(join55(dir, name2, "gitdir"), "utf8").trim());
|
|
100722
100802
|
if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
|
|
100723
100803
|
} catch {
|
|
100724
100804
|
}
|
|
@@ -100741,8 +100821,8 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
|
|
|
100741
100821
|
|
|
100742
100822
|
// src/claude-mods.ts
|
|
100743
100823
|
import { createHash as createHash22 } from "node:crypto";
|
|
100744
|
-
import { cpSync as cpSync3, existsSync as
|
|
100745
|
-
import { delimiter as delimiter2, dirname as
|
|
100824
|
+
import { cpSync as cpSync3, existsSync as existsSync40, mkdirSync as mkdirSync12, readFileSync as readFileSync48, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync16, writeFileSync as writeFileSync33 } from "node:fs";
|
|
100825
|
+
import { delimiter as delimiter2, dirname as dirname21, join as join56, relative as relative7, resolve as resolve10, sep as sep6 } from "node:path";
|
|
100746
100826
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
100747
100827
|
var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
|
|
100748
100828
|
var HASH_FILE = ".errata-mod-hash";
|
|
@@ -100757,9 +100837,9 @@ function isEngineOwned(relPath) {
|
|
|
100757
100837
|
function listFiles(root, dir = root) {
|
|
100758
100838
|
const out2 = [];
|
|
100759
100839
|
for (const name2 of readdirSync15(dir)) {
|
|
100760
|
-
const abs =
|
|
100840
|
+
const abs = join56(dir, name2);
|
|
100761
100841
|
if (isEngineOwned(relative7(root, abs))) continue;
|
|
100762
|
-
if (
|
|
100842
|
+
if (statSync16(abs).isDirectory()) out2.push(...listFiles(root, abs));
|
|
100763
100843
|
else out2.push(abs);
|
|
100764
100844
|
}
|
|
100765
100845
|
return out2;
|
|
@@ -100769,21 +100849,21 @@ function modHash(dir) {
|
|
|
100769
100849
|
for (const abs of listFiles(dir).sort()) {
|
|
100770
100850
|
h.update(relative7(dir, abs).split(sep6).join("/"));
|
|
100771
100851
|
h.update("\0");
|
|
100772
|
-
h.update(
|
|
100852
|
+
h.update(readFileSync48(abs));
|
|
100773
100853
|
h.update("\0");
|
|
100774
100854
|
}
|
|
100775
100855
|
return h.digest("hex");
|
|
100776
100856
|
}
|
|
100777
100857
|
function bundledMods(bundleDir) {
|
|
100778
|
-
if (!
|
|
100779
|
-
return readdirSync15(bundleDir).filter((name2) =>
|
|
100858
|
+
if (!existsSync40(bundleDir)) return [];
|
|
100859
|
+
return readdirSync15(bundleDir).filter((name2) => existsSync40(join56(bundleDir, name2, ".claude-plugin", "plugin.json")));
|
|
100780
100860
|
}
|
|
100781
100861
|
function sameDir(a, b) {
|
|
100782
|
-
const norm = (p) =>
|
|
100862
|
+
const norm = (p) => resolve10(p).replace(/[\\/]+$/, "").toLowerCase();
|
|
100783
100863
|
return norm(a) === norm(b);
|
|
100784
100864
|
}
|
|
100785
100865
|
function isUnder(path3, root) {
|
|
100786
|
-
const rel = relative7(
|
|
100866
|
+
const rel = relative7(resolve10(root), resolve10(path3));
|
|
100787
100867
|
return rel !== "" && !rel.startsWith("..") && !rel.includes(":");
|
|
100788
100868
|
}
|
|
100789
100869
|
function off(env2) {
|
|
@@ -100791,9 +100871,9 @@ function off(env2) {
|
|
|
100791
100871
|
return v === "0" || v === "off" || v === "false" || v === "no";
|
|
100792
100872
|
}
|
|
100793
100873
|
function readSettings(path3) {
|
|
100794
|
-
if (!
|
|
100874
|
+
if (!existsSync40(path3)) return {};
|
|
100795
100875
|
try {
|
|
100796
|
-
const parsed = JSON.parse(
|
|
100876
|
+
const parsed = JSON.parse(readFileSync48(path3, "utf8"));
|
|
100797
100877
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
100798
100878
|
return parsed;
|
|
100799
100879
|
} catch {
|
|
@@ -100817,13 +100897,13 @@ function currentDirs(settings) {
|
|
|
100817
100897
|
return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
|
|
100818
100898
|
}
|
|
100819
100899
|
function writeSettings(path3, settings) {
|
|
100820
|
-
mkdirSync12(
|
|
100900
|
+
mkdirSync12(dirname21(path3), { recursive: true });
|
|
100821
100901
|
writeFileSync33(path3, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
100822
100902
|
}
|
|
100823
100903
|
function ensureClaudeMods(opts) {
|
|
100824
100904
|
const env2 = opts.env ?? process.env;
|
|
100825
100905
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
100826
|
-
const modsRoot =
|
|
100906
|
+
const modsRoot = join56(opts.installRoot, "claude-mods");
|
|
100827
100907
|
if (off(env2)) {
|
|
100828
100908
|
const settings2 = readSettings(settingsPath);
|
|
100829
100909
|
if (!settings2) return { kind: "unreadable" };
|
|
@@ -100840,11 +100920,11 @@ function ensureClaudeMods(opts) {
|
|
|
100840
100920
|
let changed = false;
|
|
100841
100921
|
const installed = [];
|
|
100842
100922
|
for (const name2 of names) {
|
|
100843
|
-
const src =
|
|
100844
|
-
const dest =
|
|
100923
|
+
const src = join56(bundleDir, name2);
|
|
100924
|
+
const dest = join56(modsRoot, name2);
|
|
100845
100925
|
const hash2 = modHash(src);
|
|
100846
|
-
const hashFile =
|
|
100847
|
-
if (!
|
|
100926
|
+
const hashFile = join56(dest, HASH_FILE);
|
|
100927
|
+
if (!existsSync40(hashFile) || readFileSync48(hashFile, "utf8") !== hash2) {
|
|
100848
100928
|
rmSync4(dest, { recursive: true, force: true });
|
|
100849
100929
|
cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
|
|
100850
100930
|
writeFileSync33(hashFile, hash2, "utf8");
|
|
@@ -101278,9 +101358,9 @@ function resolveHookPort(explicit) {
|
|
|
101278
101358
|
}
|
|
101279
101359
|
}
|
|
101280
101360
|
}
|
|
101281
|
-
const settingsPath =
|
|
101361
|
+
const settingsPath = join57(ROOT, ".claude", "settings.json");
|
|
101282
101362
|
try {
|
|
101283
|
-
if (
|
|
101363
|
+
if (existsSync41(settingsPath)) return installedHookPort(readFileSync49(settingsPath, "utf8")) ?? 7891;
|
|
101284
101364
|
} catch {
|
|
101285
101365
|
}
|
|
101286
101366
|
return 7891;
|
|
@@ -101305,14 +101385,14 @@ async function cmdInit() {
|
|
|
101305
101385
|
if (!skipHooks) {
|
|
101306
101386
|
console.log("");
|
|
101307
101387
|
console.log("installing harness hooks...");
|
|
101308
|
-
const { existsSync:
|
|
101309
|
-
const { join:
|
|
101388
|
+
const { existsSync: existsSync42 } = await import("node:fs");
|
|
101389
|
+
const { join: join58 } = await import("node:path");
|
|
101310
101390
|
try {
|
|
101311
101391
|
await installClaudeHooks(port);
|
|
101312
101392
|
} catch (err2) {
|
|
101313
101393
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
101314
101394
|
}
|
|
101315
|
-
if (
|
|
101395
|
+
if (existsSync42(join58(ROOT, ".cursor"))) {
|
|
101316
101396
|
try {
|
|
101317
101397
|
await installCursorMcpConfig();
|
|
101318
101398
|
} catch (err2) {
|
|
@@ -101527,12 +101607,12 @@ async function cmdStatus() {
|
|
|
101527
101607
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
101528
101608
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
101529
101609
|
}
|
|
101530
|
-
console.log(` graph db: ${
|
|
101531
|
-
console.log(` event log: ${
|
|
101610
|
+
console.log(` graph db: ${existsSync41(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
101611
|
+
console.log(` event log: ${existsSync41(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
101532
101612
|
for (const line of captureStatusLines(summarizePassLedger(paths.configDir).get("capture"))) {
|
|
101533
101613
|
console.log(` capture: ${line}`);
|
|
101534
101614
|
}
|
|
101535
|
-
if (
|
|
101615
|
+
if (existsSync41(paths.castalia)) {
|
|
101536
101616
|
try {
|
|
101537
101617
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
101538
101618
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -102533,11 +102613,11 @@ async function cmdInstallationProfile(args2) {
|
|
|
102533
102613
|
}
|
|
102534
102614
|
async function cmdReview() {
|
|
102535
102615
|
const paths = workspacePaths(ROOT);
|
|
102536
|
-
if (!
|
|
102616
|
+
if (!existsSync41(paths.reviewQueue)) {
|
|
102537
102617
|
console.log("(review queue empty)");
|
|
102538
102618
|
return;
|
|
102539
102619
|
}
|
|
102540
|
-
const queue = JSON.parse(
|
|
102620
|
+
const queue = JSON.parse(readFileSync49(paths.reviewQueue, "utf8"));
|
|
102541
102621
|
if (queue.length === 0) {
|
|
102542
102622
|
console.log("(review queue empty)");
|
|
102543
102623
|
return;
|
|
@@ -103237,7 +103317,7 @@ async function gatherRepo(store, ws) {
|
|
|
103237
103317
|
};
|
|
103238
103318
|
}
|
|
103239
103319
|
async function gatherReportData(generatedAt) {
|
|
103240
|
-
const { existsSync:
|
|
103320
|
+
const { existsSync: existsSync42 } = await import("node:fs");
|
|
103241
103321
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
103242
103322
|
const cfg = loadConfig();
|
|
103243
103323
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -103245,7 +103325,7 @@ async function gatherReportData(generatedAt) {
|
|
|
103245
103325
|
for (const ws of listWorkspaces()) {
|
|
103246
103326
|
if (ws.missing) continue;
|
|
103247
103327
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
103248
|
-
if (!
|
|
103328
|
+
if (!existsSync42(dbPath)) continue;
|
|
103249
103329
|
let store = null;
|
|
103250
103330
|
try {
|
|
103251
103331
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -103289,8 +103369,8 @@ async function cmdReport(args2) {
|
|
|
103289
103369
|
const outDir = workspacePaths(ROOT).configDir;
|
|
103290
103370
|
mkdirSync13(outDir, { recursive: true });
|
|
103291
103371
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
103292
|
-
for (const f of files) writeFileSync34(
|
|
103293
|
-
const indexPath =
|
|
103372
|
+
for (const f of files) writeFileSync34(join57(outDir, f.name), f.html, "utf8");
|
|
103373
|
+
const indexPath = join57(outDir, "report.html");
|
|
103294
103374
|
console.log(`report \u2192 ${indexPath}`);
|
|
103295
103375
|
console.log(
|
|
103296
103376
|
` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
|
|
@@ -103346,7 +103426,7 @@ function spawnDaemonDetached(options = {}) {
|
|
|
103346
103426
|
try {
|
|
103347
103427
|
const logPath = daemonLogPath();
|
|
103348
103428
|
try {
|
|
103349
|
-
if (
|
|
103429
|
+
if (statSync17(logPath).size > 5 * 1024 * 1024) renameSync10(logPath, `${logPath}.1`);
|
|
103350
103430
|
} catch {
|
|
103351
103431
|
}
|
|
103352
103432
|
out2 = openSync3(logPath, "a");
|
|
@@ -103415,24 +103495,24 @@ async function cmdInstallHooks(args2) {
|
|
|
103415
103495
|
}
|
|
103416
103496
|
}
|
|
103417
103497
|
async function installOpencodePlugin(port) {
|
|
103418
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103419
|
-
const { join:
|
|
103420
|
-
const dir =
|
|
103421
|
-
if (!
|
|
103422
|
-
const file2 =
|
|
103423
|
-
if (
|
|
103424
|
-
const head2 =
|
|
103498
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
|
|
103499
|
+
const { join: join58 } = await import("node:path");
|
|
103500
|
+
const dir = join58(ROOT, ".opencode", "plugin");
|
|
103501
|
+
if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
|
|
103502
|
+
const file2 = join58(dir, "inerrata.js");
|
|
103503
|
+
if (existsSync42(file2)) {
|
|
103504
|
+
const head2 = readFileSync50(file2, "utf8").split("\n")[0] ?? "";
|
|
103425
103505
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
103426
103506
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
103427
103507
|
process.exit(2);
|
|
103428
103508
|
}
|
|
103429
103509
|
}
|
|
103430
103510
|
writeFileSync34(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
103431
|
-
const cfgFile =
|
|
103511
|
+
const cfgFile = join58(ROOT, "opencode.json");
|
|
103432
103512
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
103433
|
-
if (
|
|
103513
|
+
if (existsSync42(cfgFile)) {
|
|
103434
103514
|
try {
|
|
103435
|
-
cfg = JSON.parse(
|
|
103515
|
+
cfg = JSON.parse(readFileSync50(cfgFile, "utf8"));
|
|
103436
103516
|
} catch {
|
|
103437
103517
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
103438
103518
|
process.exit(2);
|
|
@@ -103478,15 +103558,15 @@ function installClaudeMods() {
|
|
|
103478
103558
|
}
|
|
103479
103559
|
}
|
|
103480
103560
|
async function installClaudeHooks(port) {
|
|
103481
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103482
|
-
const { join:
|
|
103483
|
-
const dir =
|
|
103484
|
-
if (!
|
|
103485
|
-
const file2 =
|
|
103561
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
|
|
103562
|
+
const { join: join58 } = await import("node:path");
|
|
103563
|
+
const dir = join58(ROOT, ".claude");
|
|
103564
|
+
if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
|
|
103565
|
+
const file2 = join58(dir, "settings.json");
|
|
103486
103566
|
let settings = {};
|
|
103487
|
-
if (
|
|
103567
|
+
if (existsSync42(file2)) {
|
|
103488
103568
|
try {
|
|
103489
|
-
settings = JSON.parse(
|
|
103569
|
+
settings = JSON.parse(readFileSync50(file2, "utf8"));
|
|
103490
103570
|
} catch {
|
|
103491
103571
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103492
103572
|
process.exit(2);
|
|
@@ -103540,7 +103620,7 @@ async function installClaudeHooks(port) {
|
|
|
103540
103620
|
console.log(` ${ensureStatusLine(port)}`);
|
|
103541
103621
|
console.log(` ${installClaudeMods().line}`);
|
|
103542
103622
|
await installClaudeMcpConfig();
|
|
103543
|
-
const claudeMd =
|
|
103623
|
+
const claudeMd = join58(ROOT, "CLAUDE.md");
|
|
103544
103624
|
const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
|
|
103545
103625
|
if (recall.kind === "collision") {
|
|
103546
103626
|
console.warn(
|
|
@@ -103552,15 +103632,15 @@ async function installClaudeHooks(port) {
|
|
|
103552
103632
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
103553
103633
|
}
|
|
103554
103634
|
async function installClaudeMcpConfig() {
|
|
103555
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103556
|
-
const { join:
|
|
103557
|
-
const file2 =
|
|
103558
|
-
const dir =
|
|
103559
|
-
if (!
|
|
103635
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
|
|
103636
|
+
const { join: join58, dirname: dirname22 } = await import("node:path");
|
|
103637
|
+
const file2 = join58(ROOT, ".mcp.json");
|
|
103638
|
+
const dir = dirname22(file2);
|
|
103639
|
+
if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
|
|
103560
103640
|
let cfg = {};
|
|
103561
|
-
if (
|
|
103641
|
+
if (existsSync42(file2)) {
|
|
103562
103642
|
try {
|
|
103563
|
-
cfg = JSON.parse(
|
|
103643
|
+
cfg = JSON.parse(readFileSync50(file2, "utf8"));
|
|
103564
103644
|
} catch {
|
|
103565
103645
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103566
103646
|
process.exit(2);
|
|
@@ -103574,15 +103654,15 @@ async function installClaudeMcpConfig() {
|
|
|
103574
103654
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
103575
103655
|
}
|
|
103576
103656
|
async function installCursorMcpConfig() {
|
|
103577
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103578
|
-
const { join:
|
|
103579
|
-
const dir =
|
|
103580
|
-
if (!
|
|
103581
|
-
const file2 =
|
|
103657
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync42, readFileSync: readFileSync50, writeFileSync: writeFileSync34 } = await import("node:fs");
|
|
103658
|
+
const { join: join58 } = await import("node:path");
|
|
103659
|
+
const dir = join58(ROOT, ".cursor");
|
|
103660
|
+
if (!existsSync42(dir)) mkdirSync13(dir, { recursive: true });
|
|
103661
|
+
const file2 = join58(dir, "mcp.json");
|
|
103582
103662
|
let cfg = {};
|
|
103583
|
-
if (
|
|
103663
|
+
if (existsSync42(file2)) {
|
|
103584
103664
|
try {
|
|
103585
|
-
cfg = JSON.parse(
|
|
103665
|
+
cfg = JSON.parse(readFileSync50(file2, "utf8"));
|
|
103586
103666
|
} catch {
|
|
103587
103667
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103588
103668
|
process.exit(2);
|
|
@@ -103601,7 +103681,7 @@ async function installCodexHooks(port) {
|
|
|
103601
103681
|
const gitRoot = nearestGitRoot(process.cwd());
|
|
103602
103682
|
const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
|
|
103603
103683
|
const file2 = writeCodexHooks(hookRoot, port);
|
|
103604
|
-
const instructions = writeManagedBlock(
|
|
103684
|
+
const instructions = writeManagedBlock(join57(hookRoot, "AGENTS.md"), {
|
|
103605
103685
|
body: AGENTS_POINTER_BODY,
|
|
103606
103686
|
stable: true
|
|
103607
103687
|
});
|
|
@@ -103969,7 +104049,7 @@ async function cmdDash(args2) {
|
|
|
103969
104049
|
const hotspotScanMark = /* @__PURE__ */ new Map();
|
|
103970
104050
|
const HOTSPOT_FANIN = 20;
|
|
103971
104051
|
const runNightlyPass = async (dueIds) => {
|
|
103972
|
-
const yieldToLoop2 = () => new Promise((
|
|
104052
|
+
const yieldToLoop2 = () => new Promise((resolve11) => setImmediate(resolve11));
|
|
103973
104053
|
const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
|
|
103974
104054
|
const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
|
|
103975
104055
|
let skillsLearned = 0;
|
|
@@ -104047,9 +104127,9 @@ async function cmdDash(args2) {
|
|
|
104047
104127
|
await yieldToLoop2();
|
|
104048
104128
|
try {
|
|
104049
104129
|
const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
|
|
104050
|
-
atCommit: readGitRefState(
|
|
104130
|
+
atCommit: readGitRefState(join57(r.root, ".git")).sha ?? void 0
|
|
104051
104131
|
});
|
|
104052
|
-
const res = bleedRules(
|
|
104132
|
+
const res = bleedRules(join57(r.root, ".claude", "rules"), items);
|
|
104053
104133
|
if (res.written || res.pruned) {
|
|
104054
104134
|
console.log(
|
|
104055
104135
|
`[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")
|