@inerrata-corporation/errata 2.0.17-dev.3421 → 2.0.17-dev.3426
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/consolidate-worker.mjs +19 -1
- package/errata.mjs +683 -398
- package/package.json +1 -1
- package/pass-worker.mjs +11 -3
package/errata.mjs
CHANGED
|
@@ -960,7 +960,7 @@ function lemma(token) {
|
|
|
960
960
|
}
|
|
961
961
|
return token;
|
|
962
962
|
}
|
|
963
|
-
function tokenize(text,
|
|
963
|
+
function tokenize(text, resolve9) {
|
|
964
964
|
const matches = text.normalize("NFC").toLowerCase().match(TOKEN_RE) ?? [];
|
|
965
965
|
const out2 = /* @__PURE__ */ new Set();
|
|
966
966
|
for (const raw2 of matches) {
|
|
@@ -970,7 +970,7 @@ function tokenize(text, resolve8) {
|
|
|
970
970
|
out2.add(token);
|
|
971
971
|
continue;
|
|
972
972
|
}
|
|
973
|
-
const canonical =
|
|
973
|
+
const canonical = resolve9(token);
|
|
974
974
|
out2.add(canonical ?? lemma(token));
|
|
975
975
|
}
|
|
976
976
|
return [...out2].sort();
|
|
@@ -25119,11 +25119,13 @@ function buildSnapshot(opts) {
|
|
|
25119
25119
|
const stillOpen = problems.filter((p) => p.attrs["resolvedAt"] == null);
|
|
25120
25120
|
const allProblems = stillOpen.filter((p) => !isConstraintProblem(p));
|
|
25121
25121
|
allProblems.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt);
|
|
25122
|
-
const
|
|
25122
|
+
const openPool = allProblems.slice(0, RECENT_OPEN * SCOPE_POOL_FACTOR).map((p) => ({
|
|
25123
25123
|
node: p,
|
|
25124
25124
|
anchors: opts.store.outEdges(p.id, ["MANIFESTED_IN", "EVIDENCED_BY"])
|
|
25125
25125
|
}));
|
|
25126
|
-
const
|
|
25126
|
+
const recent3 = openPool.slice(0, RECENT_OPEN);
|
|
25127
|
+
const constraintPool = stillOpen.filter((p) => isConstraintProblem(p)).sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt).slice(0, RECENT_CONSTRAINTS * SCOPE_POOL_FACTOR);
|
|
25128
|
+
const recentConstraints = constraintPool.slice(0, RECENT_CONSTRAINTS);
|
|
25127
25129
|
const regressions = problems.filter((p) => p.attrs["resolvedAt"] == null && p.attrs["mergedInto"] === void 0).flatMap(
|
|
25128
25130
|
(open2) => opts.store.outEdges(open2.id, ["REGRESSION_OF"]).flatMap((e) => {
|
|
25129
25131
|
const closed = opts.store.getNode(e.to);
|
|
@@ -25136,11 +25138,12 @@ function buildSnapshot(opts) {
|
|
|
25136
25138
|
})
|
|
25137
25139
|
).sort((a, b) => Number(b.closed.attrs["recurredAt"] ?? 0) - Number(a.closed.attrs["recurredAt"] ?? 0)).slice(0, 2);
|
|
25138
25140
|
const regressionClosedIds = new Set(regressions.map((r) => r.closed.id));
|
|
25139
|
-
const
|
|
25141
|
+
const resolvedPool = problems.filter((p) => p.attrs["resolvedAt"] != null && p.attrs["resolvedAs"] == null).filter((p) => !regressionClosedIds.has(p.id)).sort((a, b) => Number(b.attrs["resolvedAt"] ?? 0) - Number(a.attrs["resolvedAt"] ?? 0)).slice(0, RECENT_RESOLVED * SCOPE_POOL_FACTOR).map((p) => {
|
|
25140
25142
|
const solEdge = opts.store.outEdges(p.id, ["SOLVED_BY"])[0];
|
|
25141
25143
|
const solution = solEdge ? opts.store.getNode(solEdge.to) ?? void 0 : void 0;
|
|
25142
25144
|
return { node: p, ...solution ? { solution } : {} };
|
|
25143
25145
|
});
|
|
25146
|
+
const recentResolved = resolvedPool.slice(0, RECENT_RESOLVED);
|
|
25144
25147
|
const motifs = [
|
|
25145
25148
|
...opts.store.findNodesByLabel("Pattern"),
|
|
25146
25149
|
...opts.store.findNodesByLabel("Technique"),
|
|
@@ -25218,9 +25221,23 @@ function buildSnapshot(opts) {
|
|
|
25218
25221
|
pendingEnrichment,
|
|
25219
25222
|
skills: opts.skills ?? [],
|
|
25220
25223
|
needsRevisit,
|
|
25224
|
+
scopePool: { open: openPool, resolved: resolvedPool, constraints: constraintPool },
|
|
25221
25225
|
generatedAt: (opts.now ?? /* @__PURE__ */ new Date()).toISOString()
|
|
25222
25226
|
};
|
|
25223
25227
|
}
|
|
25228
|
+
function scopeSnapshot(s, keep) {
|
|
25229
|
+
const pool = s.scopePool;
|
|
25230
|
+
if (!pool) return s;
|
|
25231
|
+
const open2 = pool.open.filter((r) => keep(r.node));
|
|
25232
|
+
return {
|
|
25233
|
+
...s,
|
|
25234
|
+
recentProblems: open2.slice(0, RECENT_OPEN),
|
|
25235
|
+
recentResolved: pool.resolved.filter((r) => keep(r.node)).slice(0, RECENT_RESOLVED),
|
|
25236
|
+
recentConstraints: pool.constraints.filter(keep).slice(0, RECENT_CONSTRAINTS),
|
|
25237
|
+
regressions: s.regressions.filter((r) => keep(r.open)),
|
|
25238
|
+
scopePool: { ...pool, open: open2 }
|
|
25239
|
+
};
|
|
25240
|
+
}
|
|
25224
25241
|
function sliceForFile(store, relPath, atCommit) {
|
|
25225
25242
|
const candidates = store.findNodesByLabel("File");
|
|
25226
25243
|
const file2 = candidates.find((n) => n.description === relPath);
|
|
@@ -25688,6 +25705,7 @@ function isolateSnapshot(s) {
|
|
|
25688
25705
|
causalNudge: _causalNudge,
|
|
25689
25706
|
domainNudge: _domainNudge,
|
|
25690
25707
|
sharedPriors: _sharedPriors,
|
|
25708
|
+
scopePool: _scopePool,
|
|
25691
25709
|
...graphWide
|
|
25692
25710
|
} = s;
|
|
25693
25711
|
return {
|
|
@@ -25773,13 +25791,17 @@ function diffRenderLedger(before, after) {
|
|
|
25773
25791
|
for (const i2 of before) (survived.has(key(i2)) ? shown : evicted).push(i2);
|
|
25774
25792
|
return { shown, evicted };
|
|
25775
25793
|
}
|
|
25776
|
-
var RECALL_FIRST_HEADER, RECALL_FIRST_BODY, RECALL_FIRST_BLOCK, SEARCH_IMPERATIVE_HEADER, SEARCH_IMPERATIVE_BODY, SPAWN_SHARE_HINT, SUBAGENT_OWN_BLOCK_NOTE, EVICTION_ORDER, MOTIF_FLOOR, REMOTE_FLOOR, PROBLEM_FLOOR, REVIEW_ITEM_FLOOR, DEFAULT_AGENT_CONTEXT_BUDGET;
|
|
25794
|
+
var RECENT_OPEN, RECENT_RESOLVED, RECENT_CONSTRAINTS, SCOPE_POOL_FACTOR, RECALL_FIRST_HEADER, RECALL_FIRST_BODY, RECALL_FIRST_BLOCK, SEARCH_IMPERATIVE_HEADER, SEARCH_IMPERATIVE_BODY, SPAWN_SHARE_HINT, SUBAGENT_OWN_BLOCK_NOTE, EVICTION_ORDER, MOTIF_FLOOR, REMOTE_FLOOR, PROBLEM_FLOOR, REVIEW_ITEM_FLOOR, DEFAULT_AGENT_CONTEXT_BUDGET;
|
|
25777
25795
|
var init_render = __esm({
|
|
25778
25796
|
"../../packages/context-writer/src/render.ts"() {
|
|
25779
25797
|
"use strict";
|
|
25780
25798
|
init_src5();
|
|
25781
25799
|
init_src2();
|
|
25782
25800
|
init_src();
|
|
25801
|
+
RECENT_OPEN = 8;
|
|
25802
|
+
RECENT_RESOLVED = 4;
|
|
25803
|
+
RECENT_CONSTRAINTS = 3;
|
|
25804
|
+
SCOPE_POOL_FACTOR = 3;
|
|
25783
25805
|
RECALL_FIRST_HEADER = "## errata \u2014 recall before you work";
|
|
25784
25806
|
RECALL_FIRST_BODY = "Before investigating any bug or error, your FIRST tool call must be `mcp__errata__errata_search` with a few words describing the problem. This machine's knowledge graph records previously solved problems \u2014 the answer may already be recorded. Read what it returns before touching any files.";
|
|
25785
25807
|
RECALL_FIRST_BLOCK = `${RECALL_FIRST_HEADER}
|
|
@@ -32330,18 +32352,141 @@ var init_recall_signal = __esm({
|
|
|
32330
32352
|
}
|
|
32331
32353
|
});
|
|
32332
32354
|
|
|
32355
|
+
// src/session-registry.ts
|
|
32356
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, realpathSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
32357
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
32358
|
+
import { resolve } from "node:path";
|
|
32359
|
+
function shipsFromWorkspace(root, env2 = process.env) {
|
|
32360
|
+
return Boolean(env2["VITEST"]) || !isScratchWorkspace(root);
|
|
32361
|
+
}
|
|
32362
|
+
function isScratchWorkspace(root, tmp = tmpdir2()) {
|
|
32363
|
+
const norm = (p) => {
|
|
32364
|
+
let real = p;
|
|
32365
|
+
try {
|
|
32366
|
+
real = realpathSync.native(p);
|
|
32367
|
+
} catch {
|
|
32368
|
+
}
|
|
32369
|
+
return resolve(real).replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
32370
|
+
};
|
|
32371
|
+
const r = norm(root);
|
|
32372
|
+
const t = norm(tmp);
|
|
32373
|
+
return r === t || r.startsWith(`${t}/`);
|
|
32374
|
+
}
|
|
32375
|
+
function parseOrigin(raw2) {
|
|
32376
|
+
if (typeof raw2 !== "string") return void 0;
|
|
32377
|
+
const v = raw2.trim();
|
|
32378
|
+
if (!v || v.includes("%")) return void 0;
|
|
32379
|
+
return /^[\w.:-]{1,64}$/.test(v) ? v : void 0;
|
|
32380
|
+
}
|
|
32381
|
+
function createSessionRegistry(opts = {}) {
|
|
32382
|
+
const idleMs = opts.idleMs ?? SESSION_IDLE_MS;
|
|
32383
|
+
const lastSeen = /* @__PURE__ */ new Map();
|
|
32384
|
+
const parentOf = /* @__PURE__ */ new Map();
|
|
32385
|
+
const ended = /* @__PURE__ */ new Set();
|
|
32386
|
+
const origins = new Map(loadOrigins(opts.originsPath));
|
|
32387
|
+
let ver = 0;
|
|
32388
|
+
let lastLiveCount = -1;
|
|
32389
|
+
const persist = () => {
|
|
32390
|
+
if (!opts.originsPath) return;
|
|
32391
|
+
try {
|
|
32392
|
+
while (origins.size > MAX_ORIGINS) origins.delete(origins.keys().next().value);
|
|
32393
|
+
writeFileSync7(opts.originsPath, JSON.stringify(Object.fromEntries(origins)));
|
|
32394
|
+
} catch {
|
|
32395
|
+
}
|
|
32396
|
+
};
|
|
32397
|
+
const ownLive = (id, nowMs) => {
|
|
32398
|
+
const seen = lastSeen.get(id);
|
|
32399
|
+
return seen !== void 0 && !ended.has(id) && nowMs - seen < idleMs;
|
|
32400
|
+
};
|
|
32401
|
+
const registry2 = {
|
|
32402
|
+
touch(sessionId, nowMs, o = {}) {
|
|
32403
|
+
if (!sessionId) return;
|
|
32404
|
+
const wasLive = ownLive(sessionId, nowMs);
|
|
32405
|
+
lastSeen.set(sessionId, nowMs);
|
|
32406
|
+
ended.delete(sessionId);
|
|
32407
|
+
if (o.parent) parentOf.set(sessionId, o.parent);
|
|
32408
|
+
const origin = o.origin ?? (o.parent ? origins.get(o.parent) : void 0);
|
|
32409
|
+
if (origin && origins.get(sessionId) !== origin) {
|
|
32410
|
+
origins.set(sessionId, origin);
|
|
32411
|
+
persist();
|
|
32412
|
+
ver++;
|
|
32413
|
+
}
|
|
32414
|
+
if (!wasLive) ver++;
|
|
32415
|
+
},
|
|
32416
|
+
end(sessionId) {
|
|
32417
|
+
if (!sessionId || ended.has(sessionId)) return;
|
|
32418
|
+
ended.add(sessionId);
|
|
32419
|
+
ver++;
|
|
32420
|
+
},
|
|
32421
|
+
isLive(sessionId, nowMs) {
|
|
32422
|
+
if (ownLive(sessionId, nowMs)) return true;
|
|
32423
|
+
const parent = parentOf.get(sessionId);
|
|
32424
|
+
return parent !== void 0 && ownLive(parent, nowMs);
|
|
32425
|
+
},
|
|
32426
|
+
originOf: (sessionId) => origins.get(sessionId) ?? origins.get(parentOf.get(sessionId) ?? ""),
|
|
32427
|
+
originSessions: () => [...origins.keys()],
|
|
32428
|
+
isOwn: (sessionId, viewer) => sessionId === viewer || parentOf.get(sessionId) === viewer,
|
|
32429
|
+
version(nowMs) {
|
|
32430
|
+
let live3 = 0;
|
|
32431
|
+
for (const id of lastSeen.keys()) if (ownLive(id, nowMs)) live3++;
|
|
32432
|
+
if (live3 !== lastLiveCount) {
|
|
32433
|
+
lastLiveCount = live3;
|
|
32434
|
+
ver++;
|
|
32435
|
+
}
|
|
32436
|
+
return ver;
|
|
32437
|
+
}
|
|
32438
|
+
};
|
|
32439
|
+
return registry2;
|
|
32440
|
+
}
|
|
32441
|
+
function loadOrigins(path2) {
|
|
32442
|
+
if (!path2 || !existsSync8(path2)) return [];
|
|
32443
|
+
try {
|
|
32444
|
+
const raw2 = JSON.parse(readFileSync6(path2, "utf8"));
|
|
32445
|
+
return Object.entries(raw2).flatMap(([k, v]) => typeof v === "string" ? [[k, v]] : []);
|
|
32446
|
+
} catch {
|
|
32447
|
+
return [];
|
|
32448
|
+
}
|
|
32449
|
+
}
|
|
32450
|
+
function sessionsOf(node2) {
|
|
32451
|
+
const s = node2.attrs["sources"];
|
|
32452
|
+
return Array.isArray(s) ? s.filter((x) => typeof x === "string" && x.length > 0) : [];
|
|
32453
|
+
}
|
|
32454
|
+
function capturedOnlyBy(node2, sessions) {
|
|
32455
|
+
const recorded = sessionsOf(node2);
|
|
32456
|
+
return recorded.length > 0 && recorded.every((s) => sessions.has(s));
|
|
32457
|
+
}
|
|
32458
|
+
function isQuarantined(node2, reg) {
|
|
32459
|
+
const sessions = sessionsOf(node2);
|
|
32460
|
+
return sessions.length > 0 && sessions.every((s) => reg.originOf(s) !== void 0);
|
|
32461
|
+
}
|
|
32462
|
+
function hiddenFrom(node2, viewer, reg, nowMs) {
|
|
32463
|
+
const sessions = sessionsOf(node2);
|
|
32464
|
+
if (sessions.length === 0 || sessions.some((s) => reg.isOwn(s, viewer))) return false;
|
|
32465
|
+
if (isQuarantined(node2, reg)) return true;
|
|
32466
|
+
return sessions.every((s) => reg.isLive(s, nowMs));
|
|
32467
|
+
}
|
|
32468
|
+
var ORIGIN_HEADER, SESSION_IDLE_MS, MAX_ORIGINS;
|
|
32469
|
+
var init_session_registry = __esm({
|
|
32470
|
+
"src/session-registry.ts"() {
|
|
32471
|
+
"use strict";
|
|
32472
|
+
ORIGIN_HEADER = "x-errata-origin";
|
|
32473
|
+
SESSION_IDLE_MS = 20 * 6e4;
|
|
32474
|
+
MAX_ORIGINS = 5e4;
|
|
32475
|
+
}
|
|
32476
|
+
});
|
|
32477
|
+
|
|
32333
32478
|
// src/review.ts
|
|
32334
|
-
import { existsSync as
|
|
32479
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, writeFileSync as writeFileSync8 } from "node:fs";
|
|
32335
32480
|
function loadReviewQueue(paths) {
|
|
32336
|
-
if (!
|
|
32481
|
+
if (!existsSync9(paths.reviewQueue)) return [];
|
|
32337
32482
|
try {
|
|
32338
|
-
return JSON.parse(
|
|
32483
|
+
return JSON.parse(readFileSync7(paths.reviewQueue, "utf8"));
|
|
32339
32484
|
} catch {
|
|
32340
32485
|
return [];
|
|
32341
32486
|
}
|
|
32342
32487
|
}
|
|
32343
32488
|
function saveReviewQueue(paths, queue) {
|
|
32344
|
-
|
|
32489
|
+
writeFileSync8(paths.reviewQueue, JSON.stringify(queue, null, 2), "utf8");
|
|
32345
32490
|
}
|
|
32346
32491
|
function addProposal(paths, store, node2, reason, surprise) {
|
|
32347
32492
|
const queue = loadReviewQueue(paths);
|
|
@@ -32411,26 +32556,26 @@ var init_consent = __esm({
|
|
|
32411
32556
|
});
|
|
32412
32557
|
|
|
32413
32558
|
// src/git-remote.ts
|
|
32414
|
-
import { existsSync as
|
|
32415
|
-
import { isAbsolute as isAbsolute2, join as join8, resolve } from "node:path";
|
|
32559
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, statSync } from "node:fs";
|
|
32560
|
+
import { isAbsolute as isAbsolute2, join as join8, resolve as resolve2 } from "node:path";
|
|
32416
32561
|
function resolveGitDir(root) {
|
|
32417
32562
|
const dotGit = join8(root, ".git");
|
|
32418
32563
|
try {
|
|
32419
32564
|
const st = statSync(dotGit);
|
|
32420
32565
|
if (st.isDirectory()) return dotGit;
|
|
32421
|
-
const m = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
32566
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync8(dotGit, "utf8"));
|
|
32422
32567
|
if (!m) return null;
|
|
32423
32568
|
const dir = m[1];
|
|
32424
|
-
return isAbsolute2(dir) ? dir :
|
|
32569
|
+
return isAbsolute2(dir) ? dir : resolve2(root, dir);
|
|
32425
32570
|
} catch {
|
|
32426
32571
|
return null;
|
|
32427
32572
|
}
|
|
32428
32573
|
}
|
|
32429
32574
|
function gitConfigPath(gitDir) {
|
|
32430
32575
|
const commondirFile = join8(gitDir, "commondir");
|
|
32431
|
-
if (
|
|
32432
|
-
const common =
|
|
32433
|
-
const commonDir = isAbsolute2(common) ? common :
|
|
32576
|
+
if (existsSync10(commondirFile)) {
|
|
32577
|
+
const common = readFileSync8(commondirFile, "utf8").trim();
|
|
32578
|
+
const commonDir = isAbsolute2(common) ? common : resolve2(gitDir, common);
|
|
32434
32579
|
return join8(commonDir, "config");
|
|
32435
32580
|
}
|
|
32436
32581
|
return join8(gitDir, "config");
|
|
@@ -32439,10 +32584,10 @@ function readRemotes(root) {
|
|
|
32439
32584
|
const gitDir = resolveGitDir(root);
|
|
32440
32585
|
if (!gitDir) return [];
|
|
32441
32586
|
const cfgPath = gitConfigPath(gitDir);
|
|
32442
|
-
if (!
|
|
32587
|
+
if (!existsSync10(cfgPath)) return [];
|
|
32443
32588
|
let txt;
|
|
32444
32589
|
try {
|
|
32445
|
-
txt =
|
|
32590
|
+
txt = readFileSync8(cfgPath, "utf8");
|
|
32446
32591
|
} catch {
|
|
32447
32592
|
return [];
|
|
32448
32593
|
}
|
|
@@ -32468,7 +32613,7 @@ var init_git_remote = __esm({
|
|
|
32468
32613
|
});
|
|
32469
32614
|
|
|
32470
32615
|
// src/profile.ts
|
|
32471
|
-
import { existsSync as
|
|
32616
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
32472
32617
|
import { createHash as createHash5 } from "node:crypto";
|
|
32473
32618
|
import { join as join9 } from "node:path";
|
|
32474
32619
|
function workspaceId(root) {
|
|
@@ -32493,13 +32638,13 @@ function refreshRepoLocator(root, profile) {
|
|
|
32493
32638
|
}
|
|
32494
32639
|
function loadProfile(root) {
|
|
32495
32640
|
const p = workspacePaths(root);
|
|
32496
|
-
if (!
|
|
32497
|
-
return JSON.parse(
|
|
32641
|
+
if (!existsSync11(p.workspaceJson)) return null;
|
|
32642
|
+
return JSON.parse(readFileSync9(p.workspaceJson, "utf8"));
|
|
32498
32643
|
}
|
|
32499
32644
|
function saveProfile(root, profile) {
|
|
32500
32645
|
const p = workspacePaths(root);
|
|
32501
32646
|
ensureDir(p.configDir);
|
|
32502
|
-
|
|
32647
|
+
writeFileSync9(p.workspaceJson, JSON.stringify(profile, null, 2), "utf8");
|
|
32503
32648
|
}
|
|
32504
32649
|
function autodetectProfile(root) {
|
|
32505
32650
|
const id = workspaceId(root);
|
|
@@ -32508,12 +32653,12 @@ function autodetectProfile(root) {
|
|
|
32508
32653
|
const locator = detectRepoLocator(root);
|
|
32509
32654
|
if (locator) p.repoLocator = locator;
|
|
32510
32655
|
const pkgPath = join9(root, "package.json");
|
|
32511
|
-
if (
|
|
32656
|
+
if (existsSync11(pkgPath)) {
|
|
32512
32657
|
try {
|
|
32513
|
-
const pkg = JSON.parse(
|
|
32658
|
+
const pkg = JSON.parse(readFileSync9(pkgPath, "utf8"));
|
|
32514
32659
|
const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
32515
32660
|
p.languages.push("javascript");
|
|
32516
|
-
if (
|
|
32661
|
+
if (existsSync11(join9(root, "tsconfig.json")) || deps["typescript"]) {
|
|
32517
32662
|
p.languages.push("typescript");
|
|
32518
32663
|
}
|
|
32519
32664
|
const nodeVer = pkg.engines?.node?.trim();
|
|
@@ -32535,9 +32680,9 @@ function autodetectProfile(root) {
|
|
|
32535
32680
|
}
|
|
32536
32681
|
}
|
|
32537
32682
|
const pyproject = join9(root, "pyproject.toml");
|
|
32538
|
-
if (
|
|
32683
|
+
if (existsSync11(pyproject)) {
|
|
32539
32684
|
try {
|
|
32540
|
-
const txt =
|
|
32685
|
+
const txt = readFileSync9(pyproject, "utf8");
|
|
32541
32686
|
const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
|
|
32542
32687
|
p.languages.push("python");
|
|
32543
32688
|
p.stack.push(`python@${py ?? "3"}`);
|
|
@@ -32549,15 +32694,15 @@ function autodetectProfile(root) {
|
|
|
32549
32694
|
}
|
|
32550
32695
|
}
|
|
32551
32696
|
const reqs = join9(root, "requirements.txt");
|
|
32552
|
-
if (
|
|
32697
|
+
if (existsSync11(reqs)) {
|
|
32553
32698
|
if (!p.languages.includes("python")) p.languages.push("python");
|
|
32554
32699
|
if (!p.stack.includes("python@3")) p.stack.push("python@3");
|
|
32555
32700
|
}
|
|
32556
|
-
if (
|
|
32701
|
+
if (existsSync11(join9(root, "go.mod"))) {
|
|
32557
32702
|
p.languages.push("go");
|
|
32558
32703
|
p.stack.push("go");
|
|
32559
32704
|
}
|
|
32560
|
-
if (
|
|
32705
|
+
if (existsSync11(join9(root, "Cargo.toml"))) {
|
|
32561
32706
|
p.languages.push("rust");
|
|
32562
32707
|
p.stack.push("rust");
|
|
32563
32708
|
}
|
|
@@ -32662,12 +32807,12 @@ var init_identity2 = __esm({
|
|
|
32662
32807
|
});
|
|
32663
32808
|
|
|
32664
32809
|
// src/checkout-root.ts
|
|
32665
|
-
import { existsSync as
|
|
32666
|
-
import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute3, join as join10, resolve as
|
|
32810
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10 } from "node:fs";
|
|
32811
|
+
import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute3, join as join10, resolve as resolve3 } from "node:path";
|
|
32667
32812
|
function nearestGitRoot(dir) {
|
|
32668
|
-
let cur =
|
|
32813
|
+
let cur = resolve3(dir);
|
|
32669
32814
|
for (; ; ) {
|
|
32670
|
-
if (
|
|
32815
|
+
if (existsSync12(join10(cur, ".git"))) return cur;
|
|
32671
32816
|
const parent = dirname6(cur);
|
|
32672
32817
|
if (parent === cur) return null;
|
|
32673
32818
|
cur = parent;
|
|
@@ -32677,22 +32822,22 @@ function mainCheckoutOfWorktree(root) {
|
|
|
32677
32822
|
const gitDir = resolveGitDir(root);
|
|
32678
32823
|
if (!gitDir || gitDir === join10(root, ".git")) return null;
|
|
32679
32824
|
const commondirFile = join10(gitDir, "commondir");
|
|
32680
|
-
if (!
|
|
32825
|
+
if (!existsSync12(commondirFile)) return null;
|
|
32681
32826
|
let common;
|
|
32682
32827
|
try {
|
|
32683
|
-
common =
|
|
32828
|
+
common = readFileSync10(commondirFile, "utf8").trim();
|
|
32684
32829
|
} catch {
|
|
32685
32830
|
return null;
|
|
32686
32831
|
}
|
|
32687
|
-
const commonDir =
|
|
32832
|
+
const commonDir = resolve3(isAbsolute3(common) ? common : resolve3(gitDir, common));
|
|
32688
32833
|
if (basename2(commonDir) !== ".git") return null;
|
|
32689
32834
|
const main2 = dirname6(commonDir);
|
|
32690
|
-
return
|
|
32835
|
+
return existsSync12(join10(main2, ".git")) ? main2 : null;
|
|
32691
32836
|
}
|
|
32692
32837
|
function checkoutRootOf(cwd) {
|
|
32693
32838
|
const root = nearestGitRoot(cwd);
|
|
32694
32839
|
const main2 = root ? mainCheckoutOfWorktree(root) : null;
|
|
32695
|
-
return main2 ??
|
|
32840
|
+
return main2 ?? resolve3(cwd);
|
|
32696
32841
|
}
|
|
32697
32842
|
function isLinkedWorktree(root) {
|
|
32698
32843
|
return mainCheckoutOfWorktree(root) !== null;
|
|
@@ -32706,7 +32851,7 @@ var init_checkout_root = __esm({
|
|
|
32706
32851
|
|
|
32707
32852
|
// src/process-identity.ts
|
|
32708
32853
|
import { execFileSync } from "node:child_process";
|
|
32709
|
-
import { readFileSync as
|
|
32854
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
32710
32855
|
function readProcessIdentity(pid, fresh = false) {
|
|
32711
32856
|
if (!Number.isSafeInteger(pid) || pid <= 0) return null;
|
|
32712
32857
|
if (pid === process.pid && self) return self;
|
|
@@ -32731,10 +32876,10 @@ function readProcessIdentity(pid, fresh = false) {
|
|
|
32731
32876
|
if (!/^\d+$/.test(ticks)) return null;
|
|
32732
32877
|
value = { key: `win32:${ticks}`, bornAt: Number((BigInt(ticks) - 621355968000000000n) / 10000n) };
|
|
32733
32878
|
} else if (process.platform === "linux") {
|
|
32734
|
-
const stat4 =
|
|
32879
|
+
const stat4 = readFileSync11(`/proc/${pid}/stat`, "utf8");
|
|
32735
32880
|
const ticks = stat4.slice(stat4.lastIndexOf(")") + 2).split(" ")[19];
|
|
32736
|
-
const bootId =
|
|
32737
|
-
const boot = /^btime (\d+)$/m.exec(
|
|
32881
|
+
const bootId = readFileSync11("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
32882
|
+
const boot = /^btime (\d+)$/m.exec(readFileSync11("/proc/stat", "utf8"))?.[1];
|
|
32738
32883
|
const hz = Number(run3("getconf", ["CLK_TCK"]));
|
|
32739
32884
|
if (!boot || !/^\d+$/.test(ticks) || !Number.isFinite(hz) || hz <= 0) return null;
|
|
32740
32885
|
value = { key: `linux:${bootId}:${ticks}`, bornAt: Number(boot) * 1e3 + Number(ticks) * 1e3 / hz };
|
|
@@ -32760,7 +32905,7 @@ var init_process_identity = __esm({
|
|
|
32760
32905
|
});
|
|
32761
32906
|
|
|
32762
32907
|
// src/lock.ts
|
|
32763
|
-
import { existsSync as
|
|
32908
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, unlinkSync as unlinkSync2 } from "node:fs";
|
|
32764
32909
|
function daemonLockPayload(lock) {
|
|
32765
32910
|
return JSON.stringify({
|
|
32766
32911
|
pid: lock.pid,
|
|
@@ -32795,9 +32940,9 @@ function isProcessAlive(pid) {
|
|
|
32795
32940
|
}
|
|
32796
32941
|
}
|
|
32797
32942
|
function readDaemonLock(lockPath) {
|
|
32798
|
-
if (!
|
|
32943
|
+
if (!existsSync13(lockPath)) return null;
|
|
32799
32944
|
try {
|
|
32800
|
-
return parseDaemonLock(
|
|
32945
|
+
return parseDaemonLock(readFileSync12(lockPath, "utf8"));
|
|
32801
32946
|
} catch {
|
|
32802
32947
|
return null;
|
|
32803
32948
|
}
|
|
@@ -32827,7 +32972,7 @@ function daemonLockBlocksStartup(lockPath) {
|
|
|
32827
32972
|
function stopLockedDaemon(lockPath) {
|
|
32828
32973
|
let original;
|
|
32829
32974
|
try {
|
|
32830
|
-
original =
|
|
32975
|
+
original = readFileSync12(lockPath, "utf8");
|
|
32831
32976
|
} catch {
|
|
32832
32977
|
return "missing";
|
|
32833
32978
|
}
|
|
@@ -32835,7 +32980,7 @@ function stopLockedDaemon(lockPath) {
|
|
|
32835
32980
|
if (!lock) return "unknown";
|
|
32836
32981
|
const state = daemonLockState(lock, true);
|
|
32837
32982
|
try {
|
|
32838
|
-
if (
|
|
32983
|
+
if (readFileSync12(lockPath, "utf8") !== original) return "changed";
|
|
32839
32984
|
} catch {
|
|
32840
32985
|
return "changed";
|
|
32841
32986
|
}
|
|
@@ -32860,16 +33005,16 @@ var init_lock = __esm({
|
|
|
32860
33005
|
});
|
|
32861
33006
|
|
|
32862
33007
|
// src/registry.ts
|
|
32863
|
-
import { existsSync as
|
|
33008
|
+
import { existsSync as existsSync14, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "node:fs";
|
|
32864
33009
|
import { join as join11 } from "node:path";
|
|
32865
33010
|
function registryPath() {
|
|
32866
33011
|
return process.env["ERRATA_REGISTRY_PATH"] ?? join11(globalDir(), "workspaces.json");
|
|
32867
33012
|
}
|
|
32868
33013
|
function read() {
|
|
32869
33014
|
const p = registryPath();
|
|
32870
|
-
if (!
|
|
33015
|
+
if (!existsSync14(p)) return { version: 1, workspaces: {} };
|
|
32871
33016
|
try {
|
|
32872
|
-
const parsed = JSON.parse(
|
|
33017
|
+
const parsed = JSON.parse(readFileSync13(p, "utf8"));
|
|
32873
33018
|
return { version: 1, workspaces: parsed.workspaces ?? {} };
|
|
32874
33019
|
} catch {
|
|
32875
33020
|
return { version: 1, workspaces: {} };
|
|
@@ -32877,9 +33022,9 @@ function read() {
|
|
|
32877
33022
|
}
|
|
32878
33023
|
function registryCorrupt() {
|
|
32879
33024
|
const p = registryPath();
|
|
32880
|
-
if (!
|
|
33025
|
+
if (!existsSync14(p)) return false;
|
|
32881
33026
|
try {
|
|
32882
|
-
JSON.parse(
|
|
33027
|
+
JSON.parse(readFileSync13(p, "utf8"));
|
|
32883
33028
|
return false;
|
|
32884
33029
|
} catch {
|
|
32885
33030
|
return true;
|
|
@@ -32887,7 +33032,7 @@ function registryCorrupt() {
|
|
|
32887
33032
|
}
|
|
32888
33033
|
function write(reg) {
|
|
32889
33034
|
ensureDir(globalDir());
|
|
32890
|
-
|
|
33035
|
+
writeFileSync10(registryPath(), JSON.stringify(reg, null, 2), "utf8");
|
|
32891
33036
|
}
|
|
32892
33037
|
function registerWorkspace(profile, root, now = Date.now()) {
|
|
32893
33038
|
if (isLinkedWorktree(root)) return;
|
|
@@ -32932,7 +33077,7 @@ function pruneMissingWorkspaces() {
|
|
|
32932
33077
|
const reg = read();
|
|
32933
33078
|
const removed = [];
|
|
32934
33079
|
for (const [id, entry] of Object.entries(reg.workspaces)) {
|
|
32935
|
-
if (!
|
|
33080
|
+
if (!existsSync14(entry.path)) {
|
|
32936
33081
|
removed.push(entry);
|
|
32937
33082
|
delete reg.workspaces[id];
|
|
32938
33083
|
}
|
|
@@ -32941,7 +33086,7 @@ function pruneMissingWorkspaces() {
|
|
|
32941
33086
|
return removed;
|
|
32942
33087
|
}
|
|
32943
33088
|
function workspaceStatus(entry) {
|
|
32944
|
-
const missing = !
|
|
33089
|
+
const missing = !existsSync14(entry.path);
|
|
32945
33090
|
const lockPath = workspacePaths(entry.path).daemonLock;
|
|
32946
33091
|
let running = false;
|
|
32947
33092
|
let webUiUrl = null;
|
|
@@ -34260,7 +34405,7 @@ var init_dual_augment = __esm({
|
|
|
34260
34405
|
|
|
34261
34406
|
// ../../packages/indexer/src/parse-cache.ts
|
|
34262
34407
|
import { createHash as createHash6 } from "node:crypto";
|
|
34263
|
-
import { existsSync as
|
|
34408
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync6, readFileSync as readFileSync14, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
34264
34409
|
import { homedir as homedir3 } from "node:os";
|
|
34265
34410
|
import { join as join12 } from "node:path";
|
|
34266
34411
|
function parseCacheDir() {
|
|
@@ -34275,7 +34420,7 @@ function entryPath(dir, key) {
|
|
|
34275
34420
|
function readParseCache(dir, key) {
|
|
34276
34421
|
const file2 = entryPath(dir, key);
|
|
34277
34422
|
try {
|
|
34278
|
-
const raw2 =
|
|
34423
|
+
const raw2 = readFileSync14(file2, "utf8");
|
|
34279
34424
|
const parsed = JSON.parse(raw2);
|
|
34280
34425
|
if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
|
|
34281
34426
|
return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
|
|
@@ -34295,7 +34440,7 @@ function writeParseCache(dir, key, providerId, value) {
|
|
|
34295
34440
|
if (body2.length > MAX_ENTRY_BYTES) return;
|
|
34296
34441
|
const file2 = entryPath(dir, key);
|
|
34297
34442
|
mkdirSync6(join12(dir, key.slice(0, 2)), { recursive: true });
|
|
34298
|
-
|
|
34443
|
+
writeFileSync11(file2, body2);
|
|
34299
34444
|
} catch {
|
|
34300
34445
|
}
|
|
34301
34446
|
}
|
|
@@ -34304,7 +34449,7 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
34304
34449
|
sweptThisProcess = true;
|
|
34305
34450
|
let removed = 0;
|
|
34306
34451
|
try {
|
|
34307
|
-
if (!
|
|
34452
|
+
if (!existsSync15(dir)) return 0;
|
|
34308
34453
|
for (const bucket of readdirSync2(dir)) {
|
|
34309
34454
|
const bucketDir = join12(dir, bucket);
|
|
34310
34455
|
let names;
|
|
@@ -34562,7 +34707,7 @@ var init_identity3 = __esm({
|
|
|
34562
34707
|
});
|
|
34563
34708
|
|
|
34564
34709
|
// ../../packages/indexer/src/pipeline.ts
|
|
34565
|
-
import { appendFileSync, readFileSync as
|
|
34710
|
+
import { appendFileSync, readFileSync as readFileSync15, statSync as statSync3 } from "node:fs";
|
|
34566
34711
|
import { readdir } from "node:fs/promises";
|
|
34567
34712
|
import { extname, join as join13, relative as relative2, sep } from "node:path";
|
|
34568
34713
|
import { createHash as createHash7 } from "node:crypto";
|
|
@@ -34702,7 +34847,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34702
34847
|
for (const rel of [...changedRelPaths]) {
|
|
34703
34848
|
let h;
|
|
34704
34849
|
try {
|
|
34705
|
-
h = createHash7("sha256").update(
|
|
34850
|
+
h = createHash7("sha256").update(readFileSync15(join13(rootPath, rel))).digest("hex");
|
|
34706
34851
|
} catch {
|
|
34707
34852
|
continue;
|
|
34708
34853
|
}
|
|
@@ -34757,7 +34902,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34757
34902
|
if (!provider) continue;
|
|
34758
34903
|
let symbols;
|
|
34759
34904
|
try {
|
|
34760
|
-
symbols = provider.extractSymbols(
|
|
34905
|
+
symbols = provider.extractSymbols(readFileSync15(abs, "utf8"), abs);
|
|
34761
34906
|
} catch {
|
|
34762
34907
|
continue;
|
|
34763
34908
|
}
|
|
@@ -35077,7 +35222,7 @@ async function runIndexer(store, opts) {
|
|
|
35077
35222
|
report.filesSkipped++;
|
|
35078
35223
|
continue;
|
|
35079
35224
|
}
|
|
35080
|
-
source =
|
|
35225
|
+
source = readFileSync15(f.absPath, "utf8");
|
|
35081
35226
|
} catch {
|
|
35082
35227
|
report.filesSkipped++;
|
|
35083
35228
|
continue;
|
|
@@ -35149,7 +35294,7 @@ async function runIndexer(store, opts) {
|
|
|
35149
35294
|
const depth = fileNode.relPath.split("/").length;
|
|
35150
35295
|
if (depth !== 3) continue;
|
|
35151
35296
|
try {
|
|
35152
|
-
const pkg = JSON.parse(
|
|
35297
|
+
const pkg = JSON.parse(readFileSync15(fileNode.absPath, "utf8"));
|
|
35153
35298
|
if (!pkg.name) continue;
|
|
35154
35299
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
35155
35300
|
const candidates = [
|
|
@@ -35625,7 +35770,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
|
|
|
35625
35770
|
if (existing && fileUnchanged(existing.attrs, f, skip)) return;
|
|
35626
35771
|
let contentHash;
|
|
35627
35772
|
try {
|
|
35628
|
-
contentHash = createHash7("sha256").update(
|
|
35773
|
+
contentHash = createHash7("sha256").update(readFileSync15(f.absPath)).digest("hex");
|
|
35629
35774
|
} catch {
|
|
35630
35775
|
}
|
|
35631
35776
|
const carried = { ...existing?.attrs ?? {} };
|
|
@@ -36242,13 +36387,13 @@ async function Module2(moduleArg = {}) {
|
|
|
36242
36387
|
}
|
|
36243
36388
|
readAsync = /* @__PURE__ */ __name(async (url2) => {
|
|
36244
36389
|
if (isFileURI(url2)) {
|
|
36245
|
-
return new Promise((
|
|
36390
|
+
return new Promise((resolve9, reject) => {
|
|
36246
36391
|
var xhr = new XMLHttpRequest();
|
|
36247
36392
|
xhr.open("GET", url2, true);
|
|
36248
36393
|
xhr.responseType = "arraybuffer";
|
|
36249
36394
|
xhr.onload = () => {
|
|
36250
36395
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
36251
|
-
|
|
36396
|
+
resolve9(xhr.response);
|
|
36252
36397
|
return;
|
|
36253
36398
|
}
|
|
36254
36399
|
reject(xhr.status);
|
|
@@ -36444,9 +36589,9 @@ async function Module2(moduleArg = {}) {
|
|
|
36444
36589
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
36445
36590
|
var info2 = getWasmImports();
|
|
36446
36591
|
if (Module["instantiateWasm"]) {
|
|
36447
|
-
return new Promise((
|
|
36592
|
+
return new Promise((resolve9, reject) => {
|
|
36448
36593
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
36449
|
-
|
|
36594
|
+
resolve9(receiveInstance(mod, inst));
|
|
36450
36595
|
});
|
|
36451
36596
|
});
|
|
36452
36597
|
}
|
|
@@ -37777,8 +37922,8 @@ async function Module2(moduleArg = {}) {
|
|
|
37777
37922
|
if (runtimeInitialized) {
|
|
37778
37923
|
moduleRtn = Module;
|
|
37779
37924
|
} else {
|
|
37780
|
-
moduleRtn = new Promise((
|
|
37781
|
-
readyPromiseResolve =
|
|
37925
|
+
moduleRtn = new Promise((resolve9, reject) => {
|
|
37926
|
+
readyPromiseResolve = resolve9;
|
|
37782
37927
|
readyPromiseReject = reject;
|
|
37783
37928
|
});
|
|
37784
37929
|
}
|
|
@@ -40009,7 +40154,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
40009
40154
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
40010
40155
|
import { fileURLToPath } from "node:url";
|
|
40011
40156
|
import { dirname as dirname7, join as join14 } from "node:path";
|
|
40012
|
-
import { existsSync as
|
|
40157
|
+
import { existsSync as existsSync16, readdirSync as readdirSync3 } from "node:fs";
|
|
40013
40158
|
import { createRequire as createRequire2 } from "node:module";
|
|
40014
40159
|
function entryDir() {
|
|
40015
40160
|
try {
|
|
@@ -40024,7 +40169,7 @@ function entryDir() {
|
|
|
40024
40169
|
function findWasmDir() {
|
|
40025
40170
|
const here = entryDir();
|
|
40026
40171
|
const seaWasm = join14(here, "resources", "wasm");
|
|
40027
|
-
if (
|
|
40172
|
+
if (existsSync16(join14(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
40028
40173
|
let dir = here;
|
|
40029
40174
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
40030
40175
|
const flat = join14(
|
|
@@ -40034,13 +40179,13 @@ function findWasmDir() {
|
|
|
40034
40179
|
"tree-sitter-wasm",
|
|
40035
40180
|
"wasm"
|
|
40036
40181
|
);
|
|
40037
|
-
if (
|
|
40182
|
+
if (existsSync16(join14(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
40038
40183
|
dir = dirname7(dir);
|
|
40039
40184
|
}
|
|
40040
40185
|
let root = here;
|
|
40041
40186
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
40042
40187
|
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
40043
|
-
if (
|
|
40188
|
+
if (existsSync16(pnpmDir)) {
|
|
40044
40189
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
40045
40190
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
40046
40191
|
const candidate = join14(
|
|
@@ -40051,7 +40196,7 @@ function findWasmDir() {
|
|
|
40051
40196
|
"tree-sitter-wasm",
|
|
40052
40197
|
"wasm"
|
|
40053
40198
|
);
|
|
40054
|
-
if (
|
|
40199
|
+
if (existsSync16(join14(candidate, "tree-sitter-typescript.wasm"))) {
|
|
40055
40200
|
return candidate;
|
|
40056
40201
|
}
|
|
40057
40202
|
}
|
|
@@ -40066,17 +40211,17 @@ function findWasmDir() {
|
|
|
40066
40211
|
function findRuntimeDir() {
|
|
40067
40212
|
const here = entryDir();
|
|
40068
40213
|
const seaRuntime = join14(here, "resources", "wasm");
|
|
40069
|
-
if (
|
|
40214
|
+
if (existsSync16(join14(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
40070
40215
|
let dir = here;
|
|
40071
40216
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
40072
40217
|
const flat = join14(dir, "node_modules", "web-tree-sitter");
|
|
40073
|
-
if (
|
|
40218
|
+
if (existsSync16(join14(flat, "web-tree-sitter.wasm"))) return flat;
|
|
40074
40219
|
dir = dirname7(dir);
|
|
40075
40220
|
}
|
|
40076
40221
|
let root = here;
|
|
40077
40222
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
40078
40223
|
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
40079
|
-
if (
|
|
40224
|
+
if (existsSync16(pnpmDir)) {
|
|
40080
40225
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
40081
40226
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
40082
40227
|
const candidate = join14(
|
|
@@ -40085,7 +40230,7 @@ function findRuntimeDir() {
|
|
|
40085
40230
|
"node_modules",
|
|
40086
40231
|
"web-tree-sitter"
|
|
40087
40232
|
);
|
|
40088
|
-
if (
|
|
40233
|
+
if (existsSync16(join14(candidate, "web-tree-sitter.wasm"))) {
|
|
40089
40234
|
return candidate;
|
|
40090
40235
|
}
|
|
40091
40236
|
}
|
|
@@ -43224,8 +43369,8 @@ __export(mcp_exports, {
|
|
|
43224
43369
|
runTool: () => runTool,
|
|
43225
43370
|
searchGraph: () => searchGraph
|
|
43226
43371
|
});
|
|
43227
|
-
import { existsSync as
|
|
43228
|
-
import { resolve as
|
|
43372
|
+
import { existsSync as existsSync17, readFileSync as readFileSync16 } from "node:fs";
|
|
43373
|
+
import { resolve as resolve4 } from "node:path";
|
|
43229
43374
|
function collectEnrichmentPulls(store, opts = {}) {
|
|
43230
43375
|
const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
|
|
43231
43376
|
const byEpisode = /* @__PURE__ */ new Map();
|
|
@@ -43261,7 +43406,7 @@ function takeEnrichmentNudge(store) {
|
|
|
43261
43406
|
` + items;
|
|
43262
43407
|
}
|
|
43263
43408
|
function takeDiscriminatorNudge(path2) {
|
|
43264
|
-
if (!path2 || !
|
|
43409
|
+
if (!path2 || !existsSync17(path2)) return null;
|
|
43265
43410
|
let shared;
|
|
43266
43411
|
try {
|
|
43267
43412
|
shared = openGraphStore({ path: path2 });
|
|
@@ -43391,11 +43536,11 @@ function showNode(store, node2, maxLines) {
|
|
|
43391
43536
|
const relPath = ownerFilePath(store, node2);
|
|
43392
43537
|
if (!relPath) return { found: false, reason: "no file owner for node" };
|
|
43393
43538
|
const workspaceRoot = process.cwd();
|
|
43394
|
-
const absPath =
|
|
43395
|
-
if (!
|
|
43539
|
+
const absPath = resolve4(workspaceRoot, relPath);
|
|
43540
|
+
if (!existsSync17(absPath)) {
|
|
43396
43541
|
return { found: false, reason: `file not found on disk: ${absPath}` };
|
|
43397
43542
|
}
|
|
43398
|
-
const source =
|
|
43543
|
+
const source = readFileSync16(absPath, "utf8");
|
|
43399
43544
|
const attrs = node2.attrs;
|
|
43400
43545
|
let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
|
|
43401
43546
|
let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
|
|
@@ -43621,7 +43766,7 @@ function buildToolContext(workspaceRoot) {
|
|
|
43621
43766
|
const base = { switchInstallationProfile: useInstallationProfile };
|
|
43622
43767
|
try {
|
|
43623
43768
|
const cfg = loadConfig();
|
|
43624
|
-
const entry = workspaceRoot ? workspaceEntryForPath(
|
|
43769
|
+
const entry = workspaceRoot ? workspaceEntryForPath(resolve4(workspaceRoot)) : null;
|
|
43625
43770
|
const syncOk = effectiveConsent(cfg, entry ? loadProfile(entry.path) : null).sync;
|
|
43626
43771
|
const identity = resolveWorkspaceIdentity(cfg, entry);
|
|
43627
43772
|
if (identity.invalid) {
|
|
@@ -44114,7 +44259,7 @@ var init_mcp = __esm({
|
|
|
44114
44259
|
const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
|
|
44115
44260
|
try {
|
|
44116
44261
|
const path2 = sharedStorePath();
|
|
44117
|
-
if (!
|
|
44262
|
+
if (!existsSync17(path2)) return { found: true, ...local };
|
|
44118
44263
|
const shared = openGraphStore({ path: path2 });
|
|
44119
44264
|
try {
|
|
44120
44265
|
if (!shared.getNode(id)) return { found: true, ...local };
|
|
@@ -44717,7 +44862,7 @@ var init_mcp = __esm({
|
|
|
44717
44862
|
inputSchema: { type: "object", properties: {} },
|
|
44718
44863
|
handler: () => {
|
|
44719
44864
|
const path2 = sharedStorePath();
|
|
44720
|
-
if (!
|
|
44865
|
+
if (!existsSync17(path2)) return { count: 0, pending: [] };
|
|
44721
44866
|
const shared = openGraphStore({ path: path2 });
|
|
44722
44867
|
try {
|
|
44723
44868
|
const pending = pendingAbstractions(shared);
|
|
@@ -44745,7 +44890,7 @@ var init_mcp = __esm({
|
|
|
44745
44890
|
},
|
|
44746
44891
|
handler: (args2) => {
|
|
44747
44892
|
const path2 = sharedStorePath();
|
|
44748
|
-
if (!
|
|
44893
|
+
if (!existsSync17(path2)) return { count: 0, pending: [] };
|
|
44749
44894
|
const shared = openGraphStore({ path: path2 });
|
|
44750
44895
|
try {
|
|
44751
44896
|
const pending = pendingDiscriminators(shared, {
|
|
@@ -44789,7 +44934,7 @@ var init_mcp = __esm({
|
|
|
44789
44934
|
},
|
|
44790
44935
|
handler: (args2) => {
|
|
44791
44936
|
const path2 = sharedStorePath();
|
|
44792
|
-
if (!
|
|
44937
|
+
if (!existsSync17(path2)) return { count: 0, routes: [] };
|
|
44793
44938
|
const shared = openGraphStore({ path: path2 });
|
|
44794
44939
|
try {
|
|
44795
44940
|
const result = triageOf(shared, {
|
|
@@ -45174,8 +45319,8 @@ __export(vfile_exports, {
|
|
|
45174
45319
|
resolvePath: () => resolvePath,
|
|
45175
45320
|
segmentsOf: () => segmentsOf
|
|
45176
45321
|
});
|
|
45177
|
-
import { writeFileSync as
|
|
45178
|
-
import { join as join16, resolve as
|
|
45322
|
+
import { writeFileSync as writeFileSync12 } from "node:fs";
|
|
45323
|
+
import { join as join16, resolve as resolve5, sep as sep3 } from "node:path";
|
|
45179
45324
|
function segmentsOf(rawPath) {
|
|
45180
45325
|
let p = rawPath.replace(/\\/g, "/");
|
|
45181
45326
|
p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
|
|
@@ -45250,13 +45395,13 @@ async function renderVFile(rawPath, store, ctx = {}) {
|
|
|
45250
45395
|
async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
|
|
45251
45396
|
const segs = segmentsOf(rawPath);
|
|
45252
45397
|
const gRoot = join16(workspaceRoot, ".errata", "g");
|
|
45253
|
-
const abs =
|
|
45398
|
+
const abs = resolve5(gRoot, ...segs.length ? segs : ["index"]);
|
|
45254
45399
|
if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
|
|
45255
45400
|
throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
|
|
45256
45401
|
}
|
|
45257
45402
|
const text = await renderVFile(rawPath, store, ctx);
|
|
45258
45403
|
ensureParent(abs);
|
|
45259
|
-
|
|
45404
|
+
writeFileSync12(abs, text, "utf8");
|
|
45260
45405
|
return abs;
|
|
45261
45406
|
}
|
|
45262
45407
|
async function materializeOverview(workspaceRoot, store, ctx = {}) {
|
|
@@ -52676,12 +52821,12 @@ var init_tool_index = __esm({
|
|
|
52676
52821
|
|
|
52677
52822
|
// src/outbox.ts
|
|
52678
52823
|
import {
|
|
52679
|
-
existsSync as
|
|
52824
|
+
existsSync as existsSync18,
|
|
52680
52825
|
readdirSync as readdirSync5,
|
|
52681
|
-
readFileSync as
|
|
52826
|
+
readFileSync as readFileSync17,
|
|
52682
52827
|
renameSync as renameSync2,
|
|
52683
52828
|
unlinkSync as unlinkSync3,
|
|
52684
|
-
writeFileSync as
|
|
52829
|
+
writeFileSync as writeFileSync13
|
|
52685
52830
|
} from "node:fs";
|
|
52686
52831
|
import { join as join17 } from "node:path";
|
|
52687
52832
|
import { createHash as createHash15 } from "node:crypto";
|
|
@@ -52689,12 +52834,12 @@ function enqueueOutbox(paths, payload) {
|
|
|
52689
52834
|
ensureDir(paths.outbox);
|
|
52690
52835
|
const id = createHash15("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
52691
52836
|
const file2 = join17(paths.outbox, `${Date.now()}-${id}.json`);
|
|
52692
|
-
|
|
52837
|
+
writeFileSync13(file2, JSON.stringify(payload, null, 2), "utf8");
|
|
52693
52838
|
return file2;
|
|
52694
52839
|
}
|
|
52695
52840
|
async function flushOutbox(paths, client, store) {
|
|
52696
52841
|
ensureDir(paths.outbox);
|
|
52697
|
-
const entries =
|
|
52842
|
+
const entries = existsSync18(paths.outbox) ? readdirSync5(paths.outbox) : [];
|
|
52698
52843
|
let uploaded = 0;
|
|
52699
52844
|
let failed = 0;
|
|
52700
52845
|
const quarantine = (abs, reason) => {
|
|
@@ -52708,7 +52853,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52708
52853
|
const abs = join17(paths.outbox, f);
|
|
52709
52854
|
let payload;
|
|
52710
52855
|
try {
|
|
52711
|
-
payload = JSON.parse(
|
|
52856
|
+
payload = JSON.parse(readFileSync17(abs, "utf8"));
|
|
52712
52857
|
} catch {
|
|
52713
52858
|
failed++;
|
|
52714
52859
|
quarantine(abs, "unparseable JSON");
|
|
@@ -52753,7 +52898,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52753
52898
|
}
|
|
52754
52899
|
}
|
|
52755
52900
|
}
|
|
52756
|
-
const remainingFiles =
|
|
52901
|
+
const remainingFiles = existsSync18(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
|
|
52757
52902
|
return { uploaded, failed, remaining: remainingFiles.length };
|
|
52758
52903
|
}
|
|
52759
52904
|
var init_outbox = __esm({
|
|
@@ -52993,6 +53138,20 @@ function buildWebUi(deps) {
|
|
|
52993
53138
|
const lastInjectedHash = /* @__PURE__ */ new Map();
|
|
52994
53139
|
const fileRecallSeen = /* @__PURE__ */ new Map();
|
|
52995
53140
|
const lastSubagentInjectAt = /* @__PURE__ */ new Map();
|
|
53141
|
+
const noteSessionFrom = (headerOrigin, body2, ended = false) => {
|
|
53142
|
+
const { sessionId, agentId } = hookAudience(body2);
|
|
53143
|
+
if (!sessionId || !deps.noteSession) return;
|
|
53144
|
+
const origin = parseOrigin(headerOrigin) ?? parseOrigin(body2["errata_origin"]);
|
|
53145
|
+
try {
|
|
53146
|
+
deps.noteSession({
|
|
53147
|
+
sessionId,
|
|
53148
|
+
...agentId ? { agentId } : {},
|
|
53149
|
+
...origin ? { origin } : {},
|
|
53150
|
+
...ended ? { ended } : {}
|
|
53151
|
+
});
|
|
53152
|
+
} catch {
|
|
53153
|
+
}
|
|
53154
|
+
};
|
|
52996
53155
|
app.get(
|
|
52997
53156
|
"/",
|
|
52998
53157
|
(c) => c.json({
|
|
@@ -53136,6 +53295,7 @@ function buildWebUi(deps) {
|
|
|
53136
53295
|
const event = hookEvent === "PostToolUseFailure" ? "PostToolUse" : hookEvent;
|
|
53137
53296
|
let recall = null;
|
|
53138
53297
|
const audience = hookAudience(body2);
|
|
53298
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2);
|
|
53139
53299
|
if (event === "PreToolUse" && (tool === "Agent" || tool === "Task") && audience.subagent === null) {
|
|
53140
53300
|
try {
|
|
53141
53301
|
deps.onSubagentSpawn?.(audience.sessionId, input);
|
|
@@ -53323,6 +53483,9 @@ function buildWebUi(deps) {
|
|
|
53323
53483
|
}
|
|
53324
53484
|
if (body2["hook_event_name"] === "SubagentStop" && typeof body2["agent_id"] === "string" && body2["agent_id"]) {
|
|
53325
53485
|
deps.onSubagentStop?.(body2["agent_id"]);
|
|
53486
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2, true);
|
|
53487
|
+
} else {
|
|
53488
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2);
|
|
53326
53489
|
}
|
|
53327
53490
|
return c.json({ ok: true });
|
|
53328
53491
|
});
|
|
@@ -53335,6 +53498,7 @@ function buildWebUi(deps) {
|
|
|
53335
53498
|
}
|
|
53336
53499
|
const delta = String(body2["delta"] ?? "");
|
|
53337
53500
|
const sessionId = String(body2["session_id"] ?? "");
|
|
53501
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2);
|
|
53338
53502
|
const messageId = typeof body2["message_id"] === "string" ? body2["message_id"] : void 0;
|
|
53339
53503
|
const index = typeof body2["index"] === "number" ? body2["index"] : 0;
|
|
53340
53504
|
const isFinal = body2["final"] !== false;
|
|
@@ -53362,6 +53526,7 @@ function buildWebUi(deps) {
|
|
|
53362
53526
|
if (transcriptPath && deps.onSessionEnd) {
|
|
53363
53527
|
deps.onSessionEnd({ sessionId, transcriptPath });
|
|
53364
53528
|
}
|
|
53529
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2, true);
|
|
53365
53530
|
return c.json({ ok: true });
|
|
53366
53531
|
});
|
|
53367
53532
|
app.post("/api/context-inject", async (c) => {
|
|
@@ -53372,6 +53537,7 @@ function buildWebUi(deps) {
|
|
|
53372
53537
|
return c.json({});
|
|
53373
53538
|
}
|
|
53374
53539
|
const { sessionId: sid, contextKey: contextKey2, subagent, agentId } = hookAudience(body2);
|
|
53540
|
+
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2);
|
|
53375
53541
|
const hookEvent = String(body2["hook_event_name"] ?? "UserPromptSubmit");
|
|
53376
53542
|
const atPrompt = hookEvent === "UserPromptSubmit" || hookEvent === "SessionStart" || hookEvent === "SubagentStart";
|
|
53377
53543
|
if (sid && recallCardEnabled() && atPrompt) {
|
|
@@ -53395,8 +53561,9 @@ function buildWebUi(deps) {
|
|
|
53395
53561
|
block = own;
|
|
53396
53562
|
storedCard = own?.card ?? null;
|
|
53397
53563
|
} else {
|
|
53398
|
-
|
|
53399
|
-
|
|
53564
|
+
const own = sid ? deps.sessionContext?.(sid) ?? null : null;
|
|
53565
|
+
block = own ?? readContextFileWithHash(deps.paths.root);
|
|
53566
|
+
storedCard = own ? own.card : block ? readContextCard(deps.paths.root, block.hash) : null;
|
|
53400
53567
|
}
|
|
53401
53568
|
const decision = decideContextInject({
|
|
53402
53569
|
event: hookEvent,
|
|
@@ -53610,6 +53777,7 @@ var init_webui = __esm({
|
|
|
53610
53777
|
init_agent_signals();
|
|
53611
53778
|
init_recall_signal();
|
|
53612
53779
|
init_recall_card();
|
|
53780
|
+
init_session_registry();
|
|
53613
53781
|
init_review2();
|
|
53614
53782
|
init_vfile();
|
|
53615
53783
|
init_tool_index();
|
|
@@ -54944,7 +55112,7 @@ var require_util = __commonJS({
|
|
|
54944
55112
|
}
|
|
54945
55113
|
return url2;
|
|
54946
55114
|
}
|
|
54947
|
-
function
|
|
55115
|
+
function parseOrigin2(url2) {
|
|
54948
55116
|
url2 = parseURL(url2);
|
|
54949
55117
|
if (url2.pathname !== "/" || url2.search || url2.hash) {
|
|
54950
55118
|
throw new InvalidArgumentError("invalid url");
|
|
@@ -55279,7 +55447,7 @@ var require_util = __commonJS({
|
|
|
55279
55447
|
toUSVString,
|
|
55280
55448
|
isUSVString,
|
|
55281
55449
|
isBlobLike,
|
|
55282
|
-
parseOrigin,
|
|
55450
|
+
parseOrigin: parseOrigin2,
|
|
55283
55451
|
parseURL,
|
|
55284
55452
|
getServerName,
|
|
55285
55453
|
isStream,
|
|
@@ -55937,9 +56105,9 @@ var require_dispatcher_base = __commonJS({
|
|
|
55937
56105
|
}
|
|
55938
56106
|
close(callback) {
|
|
55939
56107
|
if (callback === void 0) {
|
|
55940
|
-
return new Promise((
|
|
56108
|
+
return new Promise((resolve9, reject) => {
|
|
55941
56109
|
this.close((err2, data) => {
|
|
55942
|
-
return err2 ? reject(err2) :
|
|
56110
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
55943
56111
|
});
|
|
55944
56112
|
});
|
|
55945
56113
|
}
|
|
@@ -55977,12 +56145,12 @@ var require_dispatcher_base = __commonJS({
|
|
|
55977
56145
|
err2 = null;
|
|
55978
56146
|
}
|
|
55979
56147
|
if (callback === void 0) {
|
|
55980
|
-
return new Promise((
|
|
56148
|
+
return new Promise((resolve9, reject) => {
|
|
55981
56149
|
this.destroy(err2, (err3, data) => {
|
|
55982
56150
|
return err3 ? (
|
|
55983
56151
|
/* istanbul ignore next: should never error */
|
|
55984
56152
|
reject(err3)
|
|
55985
|
-
) :
|
|
56153
|
+
) : resolve9(data);
|
|
55986
56154
|
});
|
|
55987
56155
|
});
|
|
55988
56156
|
}
|
|
@@ -58249,8 +58417,8 @@ var require_util2 = __commonJS({
|
|
|
58249
58417
|
function createDeferredPromise() {
|
|
58250
58418
|
let res;
|
|
58251
58419
|
let rej;
|
|
58252
|
-
const promise2 = new Promise((
|
|
58253
|
-
res =
|
|
58420
|
+
const promise2 = new Promise((resolve9, reject) => {
|
|
58421
|
+
res = resolve9;
|
|
58254
58422
|
rej = reject;
|
|
58255
58423
|
});
|
|
58256
58424
|
return { promise: promise2, resolve: res, reject: rej };
|
|
@@ -60391,12 +60559,12 @@ upgrade: ${upgrade}\r
|
|
|
60391
60559
|
cb();
|
|
60392
60560
|
}
|
|
60393
60561
|
}
|
|
60394
|
-
const waitForDrain = () => new Promise((
|
|
60562
|
+
const waitForDrain = () => new Promise((resolve9, reject) => {
|
|
60395
60563
|
assert2(callback === null);
|
|
60396
60564
|
if (socket[kError]) {
|
|
60397
60565
|
reject(socket[kError]);
|
|
60398
60566
|
} else {
|
|
60399
|
-
callback =
|
|
60567
|
+
callback = resolve9;
|
|
60400
60568
|
}
|
|
60401
60569
|
});
|
|
60402
60570
|
socket.on("close", onDrain).on("drain", onDrain);
|
|
@@ -61033,12 +61201,12 @@ var require_client_h2 = __commonJS({
|
|
|
61033
61201
|
cb();
|
|
61034
61202
|
}
|
|
61035
61203
|
}
|
|
61036
|
-
const waitForDrain = () => new Promise((
|
|
61204
|
+
const waitForDrain = () => new Promise((resolve9, reject) => {
|
|
61037
61205
|
assert2(callback === null);
|
|
61038
61206
|
if (socket[kError]) {
|
|
61039
61207
|
reject(socket[kError]);
|
|
61040
61208
|
} else {
|
|
61041
|
-
callback =
|
|
61209
|
+
callback = resolve9;
|
|
61042
61210
|
}
|
|
61043
61211
|
});
|
|
61044
61212
|
h2stream.on("close", onDrain).on("drain", onDrain);
|
|
@@ -61515,16 +61683,16 @@ var require_client = __commonJS({
|
|
|
61515
61683
|
return this[kNeedDrain] < 2;
|
|
61516
61684
|
}
|
|
61517
61685
|
async [kClose]() {
|
|
61518
|
-
return new Promise((
|
|
61686
|
+
return new Promise((resolve9) => {
|
|
61519
61687
|
if (this[kSize]) {
|
|
61520
|
-
this[kClosedResolve] =
|
|
61688
|
+
this[kClosedResolve] = resolve9;
|
|
61521
61689
|
} else {
|
|
61522
|
-
|
|
61690
|
+
resolve9(null);
|
|
61523
61691
|
}
|
|
61524
61692
|
});
|
|
61525
61693
|
}
|
|
61526
61694
|
async [kDestroy](err2) {
|
|
61527
|
-
return new Promise((
|
|
61695
|
+
return new Promise((resolve9) => {
|
|
61528
61696
|
const requests = this[kQueue].splice(this[kPendingIdx]);
|
|
61529
61697
|
for (let i2 = 0; i2 < requests.length; i2++) {
|
|
61530
61698
|
const request = requests[i2];
|
|
@@ -61535,7 +61703,7 @@ var require_client = __commonJS({
|
|
|
61535
61703
|
this[kClosedResolve]();
|
|
61536
61704
|
this[kClosedResolve] = null;
|
|
61537
61705
|
}
|
|
61538
|
-
|
|
61706
|
+
resolve9(null);
|
|
61539
61707
|
};
|
|
61540
61708
|
if (this[kHTTPContext]) {
|
|
61541
61709
|
this[kHTTPContext].destroy(err2, callback);
|
|
@@ -61586,7 +61754,7 @@ var require_client = __commonJS({
|
|
|
61586
61754
|
});
|
|
61587
61755
|
}
|
|
61588
61756
|
try {
|
|
61589
|
-
const socket = await new Promise((
|
|
61757
|
+
const socket = await new Promise((resolve9, reject) => {
|
|
61590
61758
|
client[kConnector]({
|
|
61591
61759
|
host,
|
|
61592
61760
|
hostname: hostname3,
|
|
@@ -61598,7 +61766,7 @@ var require_client = __commonJS({
|
|
|
61598
61766
|
if (err2) {
|
|
61599
61767
|
reject(err2);
|
|
61600
61768
|
} else {
|
|
61601
|
-
|
|
61769
|
+
resolve9(socket2);
|
|
61602
61770
|
}
|
|
61603
61771
|
});
|
|
61604
61772
|
});
|
|
@@ -61934,8 +62102,8 @@ var require_pool_base = __commonJS({
|
|
|
61934
62102
|
if (this[kQueue].isEmpty()) {
|
|
61935
62103
|
await Promise.all(this[kClients].map((c) => c.close()));
|
|
61936
62104
|
} else {
|
|
61937
|
-
await new Promise((
|
|
61938
|
-
this[kClosedResolve] =
|
|
62105
|
+
await new Promise((resolve9) => {
|
|
62106
|
+
this[kClosedResolve] = resolve9;
|
|
61939
62107
|
});
|
|
61940
62108
|
}
|
|
61941
62109
|
}
|
|
@@ -62103,7 +62271,7 @@ var require_balanced_pool = __commonJS({
|
|
|
62103
62271
|
} = require_pool_base();
|
|
62104
62272
|
var Pool = require_pool();
|
|
62105
62273
|
var { kUrl, kInterceptors } = require_symbols();
|
|
62106
|
-
var { parseOrigin } = require_util();
|
|
62274
|
+
var { parseOrigin: parseOrigin2 } = require_util();
|
|
62107
62275
|
var kFactory = Symbol("factory");
|
|
62108
62276
|
var kOptions = Symbol("options");
|
|
62109
62277
|
var kGreatestCommonDivisor = Symbol("kGreatestCommonDivisor");
|
|
@@ -62146,7 +62314,7 @@ var require_balanced_pool = __commonJS({
|
|
|
62146
62314
|
this._updateBalancedPoolStats();
|
|
62147
62315
|
}
|
|
62148
62316
|
addUpstream(upstream) {
|
|
62149
|
-
const upstreamOrigin =
|
|
62317
|
+
const upstreamOrigin = parseOrigin2(upstream).origin;
|
|
62150
62318
|
if (this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true)) {
|
|
62151
62319
|
return this;
|
|
62152
62320
|
}
|
|
@@ -62180,7 +62348,7 @@ var require_balanced_pool = __commonJS({
|
|
|
62180
62348
|
this[kGreatestCommonDivisor] = result;
|
|
62181
62349
|
}
|
|
62182
62350
|
removeUpstream(upstream) {
|
|
62183
|
-
const upstreamOrigin =
|
|
62351
|
+
const upstreamOrigin = parseOrigin2(upstream).origin;
|
|
62184
62352
|
const pool = this[kClients].find((pool2) => pool2[kUrl].origin === upstreamOrigin && pool2.closed !== true && pool2.destroyed !== true);
|
|
62185
62353
|
if (pool) {
|
|
62186
62354
|
this[kRemoveClient](pool);
|
|
@@ -63150,7 +63318,7 @@ var require_readable = __commonJS({
|
|
|
63150
63318
|
if (this._readableState.closeEmitted) {
|
|
63151
63319
|
return null;
|
|
63152
63320
|
}
|
|
63153
|
-
return await new Promise((
|
|
63321
|
+
return await new Promise((resolve9, reject) => {
|
|
63154
63322
|
if (this[kContentLength] > limit) {
|
|
63155
63323
|
this.destroy(new AbortError());
|
|
63156
63324
|
}
|
|
@@ -63163,7 +63331,7 @@ var require_readable = __commonJS({
|
|
|
63163
63331
|
if (signal?.aborted) {
|
|
63164
63332
|
reject(signal.reason ?? new AbortError());
|
|
63165
63333
|
} else {
|
|
63166
|
-
|
|
63334
|
+
resolve9(null);
|
|
63167
63335
|
}
|
|
63168
63336
|
}).on("error", noop).on("data", function(chunk) {
|
|
63169
63337
|
limit -= chunk.length;
|
|
@@ -63182,7 +63350,7 @@ var require_readable = __commonJS({
|
|
|
63182
63350
|
}
|
|
63183
63351
|
async function consume(stream, type) {
|
|
63184
63352
|
assert2(!stream[kConsume]);
|
|
63185
|
-
return new Promise((
|
|
63353
|
+
return new Promise((resolve9, reject) => {
|
|
63186
63354
|
if (isUnusable(stream)) {
|
|
63187
63355
|
const rState = stream._readableState;
|
|
63188
63356
|
if (rState.destroyed && rState.closeEmitted === false) {
|
|
@@ -63199,7 +63367,7 @@ var require_readable = __commonJS({
|
|
|
63199
63367
|
stream[kConsume] = {
|
|
63200
63368
|
type,
|
|
63201
63369
|
stream,
|
|
63202
|
-
resolve:
|
|
63370
|
+
resolve: resolve9,
|
|
63203
63371
|
reject,
|
|
63204
63372
|
length: 0,
|
|
63205
63373
|
body: []
|
|
@@ -63269,18 +63437,18 @@ var require_readable = __commonJS({
|
|
|
63269
63437
|
return buffer;
|
|
63270
63438
|
}
|
|
63271
63439
|
function consumeEnd(consume2) {
|
|
63272
|
-
const { type, body: body2, resolve:
|
|
63440
|
+
const { type, body: body2, resolve: resolve9, stream, length } = consume2;
|
|
63273
63441
|
try {
|
|
63274
63442
|
if (type === "text") {
|
|
63275
|
-
|
|
63443
|
+
resolve9(chunksDecode(body2, length));
|
|
63276
63444
|
} else if (type === "json") {
|
|
63277
|
-
|
|
63445
|
+
resolve9(JSON.parse(chunksDecode(body2, length)));
|
|
63278
63446
|
} else if (type === "arrayBuffer") {
|
|
63279
|
-
|
|
63447
|
+
resolve9(chunksConcat(body2, length).buffer);
|
|
63280
63448
|
} else if (type === "blob") {
|
|
63281
|
-
|
|
63449
|
+
resolve9(new Blob(body2, { type: stream[kContentType] }));
|
|
63282
63450
|
} else if (type === "bytes") {
|
|
63283
|
-
|
|
63451
|
+
resolve9(chunksConcat(body2, length));
|
|
63284
63452
|
}
|
|
63285
63453
|
consumeFinish(consume2);
|
|
63286
63454
|
} catch (err2) {
|
|
@@ -63537,9 +63705,9 @@ var require_api_request = __commonJS({
|
|
|
63537
63705
|
};
|
|
63538
63706
|
function request(opts, callback) {
|
|
63539
63707
|
if (callback === void 0) {
|
|
63540
|
-
return new Promise((
|
|
63708
|
+
return new Promise((resolve9, reject) => {
|
|
63541
63709
|
request.call(this, opts, (err2, data) => {
|
|
63542
|
-
return err2 ? reject(err2) :
|
|
63710
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
63543
63711
|
});
|
|
63544
63712
|
});
|
|
63545
63713
|
}
|
|
@@ -63762,9 +63930,9 @@ var require_api_stream = __commonJS({
|
|
|
63762
63930
|
};
|
|
63763
63931
|
function stream(opts, factory, callback) {
|
|
63764
63932
|
if (callback === void 0) {
|
|
63765
|
-
return new Promise((
|
|
63933
|
+
return new Promise((resolve9, reject) => {
|
|
63766
63934
|
stream.call(this, opts, factory, (err2, data) => {
|
|
63767
|
-
return err2 ? reject(err2) :
|
|
63935
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
63768
63936
|
});
|
|
63769
63937
|
});
|
|
63770
63938
|
}
|
|
@@ -64049,9 +64217,9 @@ var require_api_upgrade = __commonJS({
|
|
|
64049
64217
|
};
|
|
64050
64218
|
function upgrade(opts, callback) {
|
|
64051
64219
|
if (callback === void 0) {
|
|
64052
|
-
return new Promise((
|
|
64220
|
+
return new Promise((resolve9, reject) => {
|
|
64053
64221
|
upgrade.call(this, opts, (err2, data) => {
|
|
64054
|
-
return err2 ? reject(err2) :
|
|
64222
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
64055
64223
|
});
|
|
64056
64224
|
});
|
|
64057
64225
|
}
|
|
@@ -64143,9 +64311,9 @@ var require_api_connect = __commonJS({
|
|
|
64143
64311
|
};
|
|
64144
64312
|
function connect(opts, callback) {
|
|
64145
64313
|
if (callback === void 0) {
|
|
64146
|
-
return new Promise((
|
|
64314
|
+
return new Promise((resolve9, reject) => {
|
|
64147
64315
|
connect.call(this, opts, (err2, data) => {
|
|
64148
|
-
return err2 ? reject(err2) :
|
|
64316
|
+
return err2 ? reject(err2) : resolve9(data);
|
|
64149
64317
|
});
|
|
64150
64318
|
});
|
|
64151
64319
|
}
|
|
@@ -68007,7 +68175,7 @@ var require_fetch = __commonJS({
|
|
|
68007
68175
|
function dispatch({ body: body2 }) {
|
|
68008
68176
|
const url2 = requestCurrentURL(request);
|
|
68009
68177
|
const agent = fetchParams.controller.dispatcher;
|
|
68010
|
-
return new Promise((
|
|
68178
|
+
return new Promise((resolve9, reject) => agent.dispatch(
|
|
68011
68179
|
{
|
|
68012
68180
|
path: url2.pathname + url2.search,
|
|
68013
68181
|
origin: url2.origin,
|
|
@@ -68083,7 +68251,7 @@ var require_fetch = __commonJS({
|
|
|
68083
68251
|
}
|
|
68084
68252
|
}
|
|
68085
68253
|
const onError = this.onError.bind(this);
|
|
68086
|
-
|
|
68254
|
+
resolve9({
|
|
68087
68255
|
status,
|
|
68088
68256
|
statusText,
|
|
68089
68257
|
headersList,
|
|
@@ -68129,7 +68297,7 @@ var require_fetch = __commonJS({
|
|
|
68129
68297
|
for (let i2 = 0; i2 < rawHeaders.length; i2 += 2) {
|
|
68130
68298
|
headersList.append(bufferToLowerCasedHeaderName(rawHeaders[i2]), rawHeaders[i2 + 1].toString("latin1"), true);
|
|
68131
68299
|
}
|
|
68132
|
-
|
|
68300
|
+
resolve9({
|
|
68133
68301
|
status,
|
|
68134
68302
|
statusText: STATUS_CODES[status],
|
|
68135
68303
|
headersList,
|
|
@@ -71768,8 +71936,8 @@ var require_util8 = __commonJS({
|
|
|
71768
71936
|
return true;
|
|
71769
71937
|
}
|
|
71770
71938
|
function delay(ms) {
|
|
71771
|
-
return new Promise((
|
|
71772
|
-
setTimeout(
|
|
71939
|
+
return new Promise((resolve9) => {
|
|
71940
|
+
setTimeout(resolve9, ms).unref();
|
|
71773
71941
|
});
|
|
71774
71942
|
}
|
|
71775
71943
|
module2.exports = {
|
|
@@ -72457,7 +72625,7 @@ __export(witness_ledger_exports, {
|
|
|
72457
72625
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
72458
72626
|
witnessLedgerPath: () => witnessLedgerPath
|
|
72459
72627
|
});
|
|
72460
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
72628
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync27, readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
|
|
72461
72629
|
import { join as join33 } from "node:path";
|
|
72462
72630
|
function witnessLedgerPath(configDir) {
|
|
72463
72631
|
return join33(configDir, "witness-ledger.jsonl");
|
|
@@ -72466,18 +72634,18 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
72466
72634
|
const path2 = witnessLedgerPath(configDir);
|
|
72467
72635
|
try {
|
|
72468
72636
|
appendFileSync3(path2, JSON.stringify(entry) + "\n");
|
|
72469
|
-
const lines =
|
|
72637
|
+
const lines = readFileSync30(path2, "utf8").split("\n").filter(Boolean);
|
|
72470
72638
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
72471
|
-
|
|
72639
|
+
writeFileSync21(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
72472
72640
|
}
|
|
72473
72641
|
} catch {
|
|
72474
72642
|
}
|
|
72475
72643
|
}
|
|
72476
72644
|
function readWitnessLedger(configDir) {
|
|
72477
72645
|
const path2 = witnessLedgerPath(configDir);
|
|
72478
|
-
if (!
|
|
72646
|
+
if (!existsSync27(path2)) return [];
|
|
72479
72647
|
try {
|
|
72480
|
-
return
|
|
72648
|
+
return readFileSync30(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
|
|
72481
72649
|
} catch {
|
|
72482
72650
|
return [];
|
|
72483
72651
|
}
|
|
@@ -72916,12 +73084,12 @@ var init_report_render = __esm({
|
|
|
72916
73084
|
|
|
72917
73085
|
// src/cli.ts
|
|
72918
73086
|
init_src6();
|
|
72919
|
-
import { closeSync as closeSync2, existsSync as
|
|
73087
|
+
import { closeSync as closeSync2, existsSync as existsSync38, openSync as openSync2, readFileSync as readFileSync41, renameSync as renameSync6, statSync as statSync11 } from "node:fs";
|
|
72920
73088
|
import { join as join47, resolve as pathResolve2 } from "node:path";
|
|
72921
73089
|
import { spawn as spawn5 } from "node:child_process";
|
|
72922
73090
|
|
|
72923
73091
|
// src/daemon.ts
|
|
72924
|
-
import { existsSync as
|
|
73092
|
+
import { existsSync as existsSync29, writeFileSync as writeFileSync24 } from "node:fs";
|
|
72925
73093
|
|
|
72926
73094
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
|
|
72927
73095
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -73351,7 +73519,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
73351
73519
|
});
|
|
73352
73520
|
if (!chunk) {
|
|
73353
73521
|
if (i2 === 1) {
|
|
73354
|
-
await new Promise((
|
|
73522
|
+
await new Promise((resolve9) => setTimeout(resolve9));
|
|
73355
73523
|
maxReadCount = 3;
|
|
73356
73524
|
continue;
|
|
73357
73525
|
}
|
|
@@ -73502,7 +73670,7 @@ init_lock();
|
|
|
73502
73670
|
|
|
73503
73671
|
// src/engine.ts
|
|
73504
73672
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
73505
|
-
import { existsSync as
|
|
73673
|
+
import { existsSync as existsSync28, statSync as statSync8, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync4, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
|
|
73506
73674
|
import { basename as basename7, join as join35, relative as relative6, sep as sep4 } from "node:path";
|
|
73507
73675
|
|
|
73508
73676
|
// src/source-watcher.ts
|
|
@@ -74364,7 +74532,7 @@ var NodeFsHandler = class {
|
|
|
74364
74532
|
this._addToNodeFs(path2, initialAdd, wh, depth + 1);
|
|
74365
74533
|
}
|
|
74366
74534
|
}).on(EV.ERROR, this._boundHandleError);
|
|
74367
|
-
return new Promise((
|
|
74535
|
+
return new Promise((resolve9, reject) => {
|
|
74368
74536
|
if (!stream)
|
|
74369
74537
|
return reject();
|
|
74370
74538
|
stream.once(STR_END, () => {
|
|
@@ -74373,7 +74541,7 @@ var NodeFsHandler = class {
|
|
|
74373
74541
|
return;
|
|
74374
74542
|
}
|
|
74375
74543
|
const wasThrottled = throttler ? throttler.clear() : false;
|
|
74376
|
-
|
|
74544
|
+
resolve9(void 0);
|
|
74377
74545
|
previous.getChildren().filter((item2) => {
|
|
74378
74546
|
return item2 !== directory && !current.has(item2);
|
|
74379
74547
|
}).forEach((item2) => {
|
|
@@ -75541,6 +75709,7 @@ async function chat(req) {
|
|
|
75541
75709
|
// src/engine.ts
|
|
75542
75710
|
init_src11();
|
|
75543
75711
|
init_src6();
|
|
75712
|
+
init_session_registry();
|
|
75544
75713
|
init_recall_signal();
|
|
75545
75714
|
|
|
75546
75715
|
// src/subagent-state.ts
|
|
@@ -75695,7 +75864,7 @@ init_review2();
|
|
|
75695
75864
|
|
|
75696
75865
|
// src/turn.ts
|
|
75697
75866
|
init_checkout_root();
|
|
75698
|
-
import { closeSync, existsSync as
|
|
75867
|
+
import { closeSync, existsSync as existsSync19, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync as realpathSync2, statSync as statSync6 } from "node:fs";
|
|
75699
75868
|
import { basename as basename5, delimiter, dirname as dirname10, join as join21, normalize as normalize3 } from "node:path";
|
|
75700
75869
|
import { homedir as homedir4 } from "node:os";
|
|
75701
75870
|
import { createHash as createHash16 } from "node:crypto";
|
|
@@ -76088,7 +76257,7 @@ function claudeProjectDir(cwd, home = homedir4()) {
|
|
|
76088
76257
|
}
|
|
76089
76258
|
function recentTranscripts(cwd, opts = {}) {
|
|
76090
76259
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
76091
|
-
if (!
|
|
76260
|
+
if (!existsSync19(dir)) return [];
|
|
76092
76261
|
let names;
|
|
76093
76262
|
try {
|
|
76094
76263
|
names = readdirSync6(dir);
|
|
@@ -76115,7 +76284,7 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
76115
76284
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
76116
76285
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
76117
76286
|
const dir = join21(dirname10(mainTranscriptPath), sessionId, "subagents");
|
|
76118
|
-
if (!
|
|
76287
|
+
if (!existsSync19(dir)) return [];
|
|
76119
76288
|
let names;
|
|
76120
76289
|
try {
|
|
76121
76290
|
names = readdirSync6(dir);
|
|
@@ -76199,7 +76368,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
76199
76368
|
const owner = checkoutRootOf(cwd);
|
|
76200
76369
|
const owners = /* @__PURE__ */ new Map();
|
|
76201
76370
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
76202
|
-
if (!
|
|
76371
|
+
if (!existsSync19(root)) {
|
|
76203
76372
|
codexRolloutActivity.delete(root);
|
|
76204
76373
|
continue;
|
|
76205
76374
|
}
|
|
@@ -76269,7 +76438,7 @@ function geminiProjectHash(cwd) {
|
|
|
76269
76438
|
function geminiHashesFor(cwd) {
|
|
76270
76439
|
const variants = /* @__PURE__ */ new Set([cwd, cwd.replace(/\/+$/, "")]);
|
|
76271
76440
|
try {
|
|
76272
|
-
variants.add(
|
|
76441
|
+
variants.add(realpathSync2(cwd));
|
|
76273
76442
|
} catch {
|
|
76274
76443
|
}
|
|
76275
76444
|
return new Set([...variants].map(geminiProjectHash));
|
|
@@ -76300,7 +76469,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
76300
76469
|
const hashes = geminiHashesFor(cwd);
|
|
76301
76470
|
const out2 = [];
|
|
76302
76471
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
76303
|
-
if (!
|
|
76472
|
+
if (!existsSync19(root)) continue;
|
|
76304
76473
|
let slugs;
|
|
76305
76474
|
try {
|
|
76306
76475
|
slugs = readdirSync6(root);
|
|
@@ -76366,12 +76535,12 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
76366
76535
|
const limit = opts.limit ?? 25;
|
|
76367
76536
|
const want = /* @__PURE__ */ new Set([cwd, cwd.replace(/\/+$/, "")]);
|
|
76368
76537
|
try {
|
|
76369
|
-
want.add(
|
|
76538
|
+
want.add(realpathSync2(cwd));
|
|
76370
76539
|
} catch {
|
|
76371
76540
|
}
|
|
76372
76541
|
const out2 = [];
|
|
76373
76542
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
76374
|
-
if (!
|
|
76543
|
+
if (!existsSync19(root)) continue;
|
|
76375
76544
|
let names;
|
|
76376
76545
|
try {
|
|
76377
76546
|
names = readdirSync6(root);
|
|
@@ -76403,7 +76572,7 @@ init_src2();
|
|
|
76403
76572
|
init_agent_signals();
|
|
76404
76573
|
init_tool_index();
|
|
76405
76574
|
init_src5();
|
|
76406
|
-
import { readFileSync as
|
|
76575
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync14 } from "node:fs";
|
|
76407
76576
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
76408
76577
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
76409
76578
|
var HANDLE_RE = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|dvuln|prob|claim|err)_[0-9a-f]{6,})/gi;
|
|
@@ -77136,13 +77305,13 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
|
|
|
77136
77305
|
entries.sort((a, b) => (b[1].seenAt ?? 0) - (a[1].seenAt ?? 0));
|
|
77137
77306
|
entries.length = HANDLE_MAP_MAX;
|
|
77138
77307
|
}
|
|
77139
|
-
|
|
77308
|
+
writeFileSync14(path2, JSON.stringify(Object.fromEntries(entries)));
|
|
77140
77309
|
} catch {
|
|
77141
77310
|
}
|
|
77142
77311
|
}
|
|
77143
77312
|
function readPrimingHandles(path2) {
|
|
77144
77313
|
try {
|
|
77145
|
-
return JSON.parse(
|
|
77314
|
+
return JSON.parse(readFileSync18(path2, "utf8"));
|
|
77146
77315
|
} catch {
|
|
77147
77316
|
return {};
|
|
77148
77317
|
}
|
|
@@ -77622,7 +77791,7 @@ ${conversation}` }]
|
|
|
77622
77791
|
// src/constraint-backfill.ts
|
|
77623
77792
|
init_src5();
|
|
77624
77793
|
init_src2();
|
|
77625
|
-
import { existsSync as
|
|
77794
|
+
import { existsSync as existsSync20, readFileSync as readFileSync19, readdirSync as readdirSync7, writeFileSync as writeFileSync15 } from "node:fs";
|
|
77626
77795
|
import { join as join22 } from "node:path";
|
|
77627
77796
|
import { homedir as homedir5 } from "node:os";
|
|
77628
77797
|
var BACKFILL_VERSION = 1;
|
|
@@ -77641,9 +77810,9 @@ function markerPath(configDir) {
|
|
|
77641
77810
|
}
|
|
77642
77811
|
function alreadyDone(configDir) {
|
|
77643
77812
|
const p = markerPath(configDir);
|
|
77644
|
-
if (!
|
|
77813
|
+
if (!existsSync20(p)) return false;
|
|
77645
77814
|
try {
|
|
77646
|
-
const raw2 = JSON.parse(
|
|
77815
|
+
const raw2 = JSON.parse(readFileSync19(p, "utf8"));
|
|
77647
77816
|
return raw2?.version === BACKFILL_VERSION;
|
|
77648
77817
|
} catch {
|
|
77649
77818
|
return false;
|
|
@@ -77653,7 +77822,7 @@ function replay(root) {
|
|
|
77653
77822
|
const statements = /* @__PURE__ */ new Set();
|
|
77654
77823
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
77655
77824
|
const dir = claudeProjectDir(root, homedir5());
|
|
77656
|
-
if (!
|
|
77825
|
+
if (!existsSync20(dir)) return { statements, citedByFix };
|
|
77657
77826
|
let names;
|
|
77658
77827
|
try {
|
|
77659
77828
|
names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -77663,7 +77832,7 @@ function replay(root) {
|
|
|
77663
77832
|
for (const f of names) {
|
|
77664
77833
|
let lines;
|
|
77665
77834
|
try {
|
|
77666
|
-
lines =
|
|
77835
|
+
lines = readFileSync19(join22(dir, f), "utf8").split("\n");
|
|
77667
77836
|
} catch {
|
|
77668
77837
|
continue;
|
|
77669
77838
|
}
|
|
@@ -77777,7 +77946,7 @@ function backfillConstraintKind(store, opts) {
|
|
|
77777
77946
|
}
|
|
77778
77947
|
});
|
|
77779
77948
|
try {
|
|
77780
|
-
|
|
77949
|
+
writeFileSync15(
|
|
77781
77950
|
markerPath(opts.configDir),
|
|
77782
77951
|
JSON.stringify({ version: BACKFILL_VERSION, at: opts.now, ...report, cloudTwins: report.cloudTwins.length }, null, 2),
|
|
77783
77952
|
"utf8"
|
|
@@ -77790,7 +77959,7 @@ function backfillConstraintKind(store, opts) {
|
|
|
77790
77959
|
// src/edge-repair.ts
|
|
77791
77960
|
init_src();
|
|
77792
77961
|
init_src5();
|
|
77793
|
-
import { existsSync as
|
|
77962
|
+
import { existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync16 } from "node:fs";
|
|
77794
77963
|
import { join as join23 } from "node:path";
|
|
77795
77964
|
function citeEdgeId(from, type, to) {
|
|
77796
77965
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
@@ -77810,9 +77979,9 @@ function markerPath2(configDir) {
|
|
|
77810
77979
|
}
|
|
77811
77980
|
function alreadyDone2(configDir) {
|
|
77812
77981
|
const p = markerPath2(configDir);
|
|
77813
|
-
if (!
|
|
77982
|
+
if (!existsSync21(p)) return false;
|
|
77814
77983
|
try {
|
|
77815
|
-
return JSON.parse(
|
|
77984
|
+
return JSON.parse(readFileSync20(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
77816
77985
|
} catch {
|
|
77817
77986
|
return false;
|
|
77818
77987
|
}
|
|
@@ -77861,7 +78030,7 @@ function repairInvalidEdges(store, opts) {
|
|
|
77861
78030
|
});
|
|
77862
78031
|
store.pruneEdgeRejections(opts.now - REJECTION_RETENTION_MS);
|
|
77863
78032
|
try {
|
|
77864
|
-
|
|
78033
|
+
writeFileSync16(
|
|
77865
78034
|
markerPath2(opts.configDir),
|
|
77866
78035
|
JSON.stringify({ version: EDGE_REPAIR_VERSION, at: opts.now, ...report }, null, 2),
|
|
77867
78036
|
"utf8"
|
|
@@ -77875,7 +78044,7 @@ function repairInvalidEdges(store, opts) {
|
|
|
77875
78044
|
init_reconcile();
|
|
77876
78045
|
|
|
77877
78046
|
// src/pass-ledger.ts
|
|
77878
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
78047
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
|
|
77879
78048
|
import { join as join24 } from "node:path";
|
|
77880
78049
|
|
|
77881
78050
|
// src/isolate-census.ts
|
|
@@ -77928,7 +78097,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77928
78097
|
return;
|
|
77929
78098
|
}
|
|
77930
78099
|
appendsSinceTrim.set(path2, 0);
|
|
77931
|
-
const lines =
|
|
78100
|
+
const lines = readFileSync21(path2, "utf8").split("\n").filter(Boolean);
|
|
77932
78101
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
77933
78102
|
const kept = [];
|
|
77934
78103
|
for (let i2 = lines.length - 1; i2 >= 0; i2--) {
|
|
@@ -77944,16 +78113,16 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77944
78113
|
kept.push(lines[i2]);
|
|
77945
78114
|
}
|
|
77946
78115
|
if (kept.length < lines.length) {
|
|
77947
|
-
|
|
78116
|
+
writeFileSync17(path2, kept.reverse().join("\n") + "\n");
|
|
77948
78117
|
}
|
|
77949
78118
|
} catch {
|
|
77950
78119
|
}
|
|
77951
78120
|
}
|
|
77952
78121
|
function readPassLedger(configDir) {
|
|
77953
78122
|
const path2 = passLedgerPath(configDir);
|
|
77954
|
-
if (!
|
|
78123
|
+
if (!existsSync22(path2)) return [];
|
|
77955
78124
|
try {
|
|
77956
|
-
return
|
|
78125
|
+
return readFileSync21(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
77957
78126
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
77958
78127
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
77959
78128
|
} catch {
|
|
@@ -78249,8 +78418,8 @@ var PassWorker = class {
|
|
|
78249
78418
|
const id = this.nextId++;
|
|
78250
78419
|
try {
|
|
78251
78420
|
await this.ready;
|
|
78252
|
-
return await new Promise((
|
|
78253
|
-
this.pending.set(id, { resolve:
|
|
78421
|
+
return await new Promise((resolve9, reject) => {
|
|
78422
|
+
this.pending.set(id, { resolve: resolve9, reject });
|
|
78254
78423
|
this.worker.postMessage({ id, kind, ...payload !== void 0 ? { payload } : {} });
|
|
78255
78424
|
});
|
|
78256
78425
|
} finally {
|
|
@@ -78284,12 +78453,12 @@ var PassWorker = class {
|
|
|
78284
78453
|
});
|
|
78285
78454
|
noteIsolateSpawned();
|
|
78286
78455
|
this.worker = worker;
|
|
78287
|
-
this.ready = new Promise((
|
|
78456
|
+
this.ready = new Promise((resolve9, reject) => {
|
|
78288
78457
|
const onReady = (m) => {
|
|
78289
78458
|
if (m?.ready) {
|
|
78290
78459
|
worker.off("message", onReady);
|
|
78291
78460
|
worker.off("error", onErr);
|
|
78292
|
-
|
|
78461
|
+
resolve9();
|
|
78293
78462
|
}
|
|
78294
78463
|
};
|
|
78295
78464
|
const onErr = (err2) => reject(err2);
|
|
@@ -78334,11 +78503,11 @@ init_outbox();
|
|
|
78334
78503
|
init_src10();
|
|
78335
78504
|
init_src();
|
|
78336
78505
|
init_src2();
|
|
78337
|
-
import { readFileSync as
|
|
78506
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
78338
78507
|
import { join as join25 } from "node:path";
|
|
78339
78508
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
78340
78509
|
try {
|
|
78341
|
-
return
|
|
78510
|
+
return readFileSync22(join25(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
78342
78511
|
} catch {
|
|
78343
78512
|
return [];
|
|
78344
78513
|
}
|
|
@@ -78716,7 +78885,7 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
78716
78885
|
// src/retrieval-stack.ts
|
|
78717
78886
|
init_src();
|
|
78718
78887
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
78719
|
-
import { existsSync as
|
|
78888
|
+
import { existsSync as existsSync23, readFileSync as readFileSync23, statSync as statSync7 } from "node:fs";
|
|
78720
78889
|
import { homedir as homedir6 } from "node:os";
|
|
78721
78890
|
import { join as join26 } from "node:path";
|
|
78722
78891
|
var RETRIEVAL_STACK_CAP = 24;
|
|
@@ -79008,7 +79177,7 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
79008
79177
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
79009
79178
|
const read2 = (p) => {
|
|
79010
79179
|
try {
|
|
79011
|
-
return
|
|
79180
|
+
return readFileSync23(p, "utf8");
|
|
79012
79181
|
} catch {
|
|
79013
79182
|
return null;
|
|
79014
79183
|
}
|
|
@@ -79234,7 +79403,7 @@ function readDirectDependencies(root) {
|
|
|
79234
79403
|
for (const c of LOCKFILES) {
|
|
79235
79404
|
if (familiesSeen.has(c.family)) continue;
|
|
79236
79405
|
const p = join26(root, c.file);
|
|
79237
|
-
if (!
|
|
79406
|
+
if (!existsSync23(p)) continue;
|
|
79238
79407
|
try {
|
|
79239
79408
|
const s = statSync7(p);
|
|
79240
79409
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
@@ -79254,7 +79423,7 @@ function readDirectDependencies(root) {
|
|
|
79254
79423
|
const direct = [];
|
|
79255
79424
|
for (const { c, path: path2 } of found) {
|
|
79256
79425
|
try {
|
|
79257
|
-
direct.push(...c.parse(
|
|
79426
|
+
direct.push(...c.parse(readFileSync23(path2, "utf8")).direct ?? []);
|
|
79258
79427
|
} catch {
|
|
79259
79428
|
}
|
|
79260
79429
|
}
|
|
@@ -79297,14 +79466,14 @@ function manifestPaths(root) {
|
|
|
79297
79466
|
"project.godot"
|
|
79298
79467
|
];
|
|
79299
79468
|
return {
|
|
79300
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
79469
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync23(join26(root, f))),
|
|
79301
79470
|
tracked: false,
|
|
79302
79471
|
truncated: false
|
|
79303
79472
|
};
|
|
79304
79473
|
}
|
|
79305
79474
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
79306
79475
|
function rootDeclaresWorkspace(root, texts) {
|
|
79307
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
79476
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync23(join26(root, f)))) return true;
|
|
79308
79477
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
79309
79478
|
}
|
|
79310
79479
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -79322,7 +79491,7 @@ function scanManifests(root) {
|
|
|
79322
79491
|
try {
|
|
79323
79492
|
const s = statSync7(abs);
|
|
79324
79493
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
79325
|
-
texts.set(rel,
|
|
79494
|
+
texts.set(rel, readFileSync23(abs, "utf8"));
|
|
79326
79495
|
} catch {
|
|
79327
79496
|
}
|
|
79328
79497
|
}
|
|
@@ -79358,11 +79527,11 @@ function readRetrievalInputs(root, repoLocator) {
|
|
|
79358
79527
|
}
|
|
79359
79528
|
|
|
79360
79529
|
// src/git-sensor.ts
|
|
79361
|
-
import { existsSync as
|
|
79530
|
+
import { existsSync as existsSync24, readFileSync as readFileSync24, watch as fsWatch } from "node:fs";
|
|
79362
79531
|
import { join as join27 } from "node:path";
|
|
79363
79532
|
function readFirstLine(path2) {
|
|
79364
79533
|
try {
|
|
79365
|
-
return
|
|
79534
|
+
return readFileSync24(path2, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
79366
79535
|
} catch {
|
|
79367
79536
|
return null;
|
|
79368
79537
|
}
|
|
@@ -79381,13 +79550,13 @@ function readGitRefState(gitDir) {
|
|
|
79381
79550
|
return {
|
|
79382
79551
|
branch,
|
|
79383
79552
|
sha: sha2,
|
|
79384
|
-
mergeHeadExists:
|
|
79385
|
-
origHeadExists:
|
|
79553
|
+
mergeHeadExists: existsSync24(join27(gitDir, "MERGE_HEAD")),
|
|
79554
|
+
origHeadExists: existsSync24(join27(gitDir, "ORIG_HEAD"))
|
|
79386
79555
|
};
|
|
79387
79556
|
}
|
|
79388
79557
|
function shaFromPackedRefs(gitDir, ref) {
|
|
79389
79558
|
try {
|
|
79390
|
-
for (const line of
|
|
79559
|
+
for (const line of readFileSync24(join27(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
79391
79560
|
const [sha2, name2] = line.split(/\s+/);
|
|
79392
79561
|
if (name2 === ref && sha2) return sha2;
|
|
79393
79562
|
}
|
|
@@ -79421,7 +79590,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
79421
79590
|
const settle = () => {
|
|
79422
79591
|
if (timer) clearTimeout(timer);
|
|
79423
79592
|
timer = setTimeout(() => {
|
|
79424
|
-
if (
|
|
79593
|
+
if (existsSync24(join27(gitDir, "index.lock"))) {
|
|
79425
79594
|
settle();
|
|
79426
79595
|
return;
|
|
79427
79596
|
}
|
|
@@ -79452,7 +79621,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
79452
79621
|
// src/git-delta.ts
|
|
79453
79622
|
import { execFile } from "node:child_process";
|
|
79454
79623
|
function git(repoDir, args2) {
|
|
79455
|
-
return new Promise((
|
|
79624
|
+
return new Promise((resolve9, reject) => {
|
|
79456
79625
|
execFile(
|
|
79457
79626
|
"git",
|
|
79458
79627
|
["-C", repoDir, ...args2],
|
|
@@ -79463,7 +79632,7 @@ function git(repoDir, args2) {
|
|
|
79463
79632
|
// git-sensor runs on every commit/checkout.
|
|
79464
79633
|
windowsHide: true
|
|
79465
79634
|
},
|
|
79466
|
-
(err2, stdout) => err2 ? reject(err2) :
|
|
79635
|
+
(err2, stdout) => err2 ? reject(err2) : resolve9(stdout)
|
|
79467
79636
|
);
|
|
79468
79637
|
});
|
|
79469
79638
|
}
|
|
@@ -79656,7 +79825,7 @@ var TelemetryRecorder = class {
|
|
|
79656
79825
|
};
|
|
79657
79826
|
|
|
79658
79827
|
// src/file-activity.ts
|
|
79659
|
-
import { readFileSync as
|
|
79828
|
+
import { readFileSync as readFileSync26 } from "node:fs";
|
|
79660
79829
|
import { join as join29 } from "node:path";
|
|
79661
79830
|
import { createHash as createHash17 } from "node:crypto";
|
|
79662
79831
|
|
|
@@ -80409,7 +80578,7 @@ init_git_remote();
|
|
|
80409
80578
|
// src/history-bundle.ts
|
|
80410
80579
|
init_src();
|
|
80411
80580
|
import { execFile as execFile2 } from "node:child_process";
|
|
80412
|
-
import { readFileSync as
|
|
80581
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
80413
80582
|
import { join as join28 } from "node:path";
|
|
80414
80583
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
80415
80584
|
var FILE_LIST_CAP = 60;
|
|
@@ -80445,7 +80614,7 @@ function pathAllowedByFloor(path2) {
|
|
|
80445
80614
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
80446
80615
|
let source = "";
|
|
80447
80616
|
try {
|
|
80448
|
-
source =
|
|
80617
|
+
source = readFileSync25(join28(root, ".errataignore"), "utf8");
|
|
80449
80618
|
} catch {
|
|
80450
80619
|
source = "";
|
|
80451
80620
|
}
|
|
@@ -80621,12 +80790,12 @@ function headerPaths(diff) {
|
|
|
80621
80790
|
return out2.filter((p) => p !== "/dev/null");
|
|
80622
80791
|
}
|
|
80623
80792
|
function git2(repoDir, args2) {
|
|
80624
|
-
return new Promise((
|
|
80793
|
+
return new Promise((resolve9, reject) => {
|
|
80625
80794
|
execFile2(
|
|
80626
80795
|
"git",
|
|
80627
80796
|
["-C", repoDir, ...args2],
|
|
80628
80797
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024, windowsHide: true },
|
|
80629
|
-
(err2, stdout) => err2 ? reject(err2) :
|
|
80798
|
+
(err2, stdout) => err2 ? reject(err2) : resolve9(stdout)
|
|
80630
80799
|
);
|
|
80631
80800
|
});
|
|
80632
80801
|
}
|
|
@@ -80738,7 +80907,7 @@ function readActivityBranch(root) {
|
|
|
80738
80907
|
try {
|
|
80739
80908
|
const gitDir = resolveGitDir(root);
|
|
80740
80909
|
if (!gitDir) return null;
|
|
80741
|
-
const head2 =
|
|
80910
|
+
const head2 = readFileSync26(join29(gitDir, "HEAD"), "utf8").trim();
|
|
80742
80911
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
80743
80912
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
80744
80913
|
} catch {
|
|
@@ -80895,21 +81064,21 @@ var FileActivityReporter = class {
|
|
|
80895
81064
|
|
|
80896
81065
|
// src/skills.ts
|
|
80897
81066
|
import {
|
|
80898
|
-
existsSync as
|
|
81067
|
+
existsSync as existsSync25,
|
|
80899
81068
|
mkdirSync as mkdirSync7,
|
|
80900
|
-
readFileSync as
|
|
81069
|
+
readFileSync as readFileSync27,
|
|
80901
81070
|
readdirSync as readdirSync8,
|
|
80902
81071
|
unlinkSync as unlinkSync4,
|
|
80903
|
-
writeFileSync as
|
|
81072
|
+
writeFileSync as writeFileSync18
|
|
80904
81073
|
} from "node:fs";
|
|
80905
81074
|
import { basename as basename6, join as join30 } from "node:path";
|
|
80906
81075
|
function skillFileName(id) {
|
|
80907
81076
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
80908
81077
|
}
|
|
80909
81078
|
function readSkillManifest(manifestPath) {
|
|
80910
|
-
if (!
|
|
81079
|
+
if (!existsSync25(manifestPath)) return [];
|
|
80911
81080
|
try {
|
|
80912
|
-
const parsed = JSON.parse(
|
|
81081
|
+
const parsed = JSON.parse(readFileSync27(manifestPath, "utf8"));
|
|
80913
81082
|
return (parsed.skills ?? []).map((s) => ({
|
|
80914
81083
|
title: s.title ?? "",
|
|
80915
81084
|
layer: s.layer ?? "technique",
|
|
@@ -80933,7 +81102,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80933
81102
|
for (const s of res.skills) {
|
|
80934
81103
|
const fileName = skillFileName(s.id);
|
|
80935
81104
|
keep.add(fileName);
|
|
80936
|
-
|
|
81105
|
+
writeFileSync18(join30(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
80937
81106
|
rows.push({
|
|
80938
81107
|
id: s.id,
|
|
80939
81108
|
title: s.title,
|
|
@@ -80946,7 +81115,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80946
81115
|
const fileName = skillFileName(p.id);
|
|
80947
81116
|
if (keep.has(fileName)) continue;
|
|
80948
81117
|
keep.add(fileName);
|
|
80949
|
-
|
|
81118
|
+
writeFileSync18(join30(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
80950
81119
|
rows.push({
|
|
80951
81120
|
id: p.id,
|
|
80952
81121
|
title: p.title,
|
|
@@ -80966,7 +81135,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80966
81135
|
}
|
|
80967
81136
|
}
|
|
80968
81137
|
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
80969
|
-
|
|
81138
|
+
writeFileSync18(
|
|
80970
81139
|
paths.skillsManifest,
|
|
80971
81140
|
JSON.stringify({ generatedAt: Date.now(), skills: rows }, null, 2),
|
|
80972
81141
|
"utf8"
|
|
@@ -80978,14 +81147,14 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80978
81147
|
init_src2();
|
|
80979
81148
|
import {
|
|
80980
81149
|
cpSync,
|
|
80981
|
-
existsSync as
|
|
81150
|
+
existsSync as existsSync26,
|
|
80982
81151
|
lstatSync,
|
|
80983
81152
|
mkdirSync as mkdirSync8,
|
|
80984
|
-
readFileSync as
|
|
81153
|
+
readFileSync as readFileSync28,
|
|
80985
81154
|
readdirSync as readdirSync9,
|
|
80986
81155
|
rmSync as rmSync3,
|
|
80987
81156
|
symlinkSync,
|
|
80988
|
-
writeFileSync as
|
|
81157
|
+
writeFileSync as writeFileSync19
|
|
80989
81158
|
} from "node:fs";
|
|
80990
81159
|
import { join as join31 } from "node:path";
|
|
80991
81160
|
var SKILL_NS = "errata-";
|
|
@@ -81038,7 +81207,7 @@ function skillCiteHandle(s) {
|
|
|
81038
81207
|
return priorHandle({ id: s.id, description: s.title });
|
|
81039
81208
|
}
|
|
81040
81209
|
function reconcileNamespaced(dir, keep) {
|
|
81041
|
-
if (!
|
|
81210
|
+
if (!existsSync26(dir)) return 0;
|
|
81042
81211
|
let pruned = 0;
|
|
81043
81212
|
for (const name2 of readdirSync9(dir)) {
|
|
81044
81213
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
@@ -81052,7 +81221,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
81052
81221
|
}
|
|
81053
81222
|
function linkOrCopy(linkPath, target) {
|
|
81054
81223
|
try {
|
|
81055
|
-
if (
|
|
81224
|
+
if (existsSync26(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
81056
81225
|
} catch {
|
|
81057
81226
|
}
|
|
81058
81227
|
try {
|
|
@@ -81081,7 +81250,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
81081
81250
|
for (const s of skills) {
|
|
81082
81251
|
let body2;
|
|
81083
81252
|
try {
|
|
81084
|
-
body2 =
|
|
81253
|
+
body2 = readFileSync28(s.bodyPath, "utf8");
|
|
81085
81254
|
} catch {
|
|
81086
81255
|
continue;
|
|
81087
81256
|
}
|
|
@@ -81091,7 +81260,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
81091
81260
|
slugs.push(slug2);
|
|
81092
81261
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
81093
81262
|
mkdirSync8(join31(agentsSkillsDir, slug2), { recursive: true });
|
|
81094
|
-
|
|
81263
|
+
writeFileSync19(
|
|
81095
81264
|
join31(agentsSkillsDir, slug2, "SKILL.md"),
|
|
81096
81265
|
renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
|
|
81097
81266
|
"utf8"
|
|
@@ -81101,7 +81270,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
81101
81270
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
81102
81271
|
let projected = 0;
|
|
81103
81272
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
81104
|
-
if (!
|
|
81273
|
+
if (!existsSync26(join31(root, h.configDir))) continue;
|
|
81105
81274
|
const dir = join31(root, h.skillsDir);
|
|
81106
81275
|
mkdirSync8(dir, { recursive: true });
|
|
81107
81276
|
for (const slug2 of slugs) {
|
|
@@ -81114,9 +81283,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
81114
81283
|
return { slugs, emitted, projected };
|
|
81115
81284
|
}
|
|
81116
81285
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
81117
|
-
if (!
|
|
81286
|
+
if (!existsSync26(manifestPath)) return [];
|
|
81118
81287
|
try {
|
|
81119
|
-
const parsed = JSON.parse(
|
|
81288
|
+
const parsed = JSON.parse(readFileSync28(manifestPath, "utf8"));
|
|
81120
81289
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
81121
81290
|
id: s.id,
|
|
81122
81291
|
title: s.title ?? s.id,
|
|
@@ -81139,14 +81308,14 @@ function ensureSkillGitignore(root) {
|
|
|
81139
81308
|
const path2 = join31(root, ".gitignore");
|
|
81140
81309
|
let current = "";
|
|
81141
81310
|
try {
|
|
81142
|
-
current =
|
|
81311
|
+
current = existsSync26(path2) ? readFileSync28(path2, "utf8") : "";
|
|
81143
81312
|
} catch {
|
|
81144
81313
|
return;
|
|
81145
81314
|
}
|
|
81146
81315
|
if (current.includes(GITIGNORE_MARK)) return;
|
|
81147
81316
|
const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
|
|
81148
81317
|
try {
|
|
81149
|
-
|
|
81318
|
+
writeFileSync19(path2, `${current}${prefix}
|
|
81150
81319
|
${GITIGNORE_LINES.join("\n")}
|
|
81151
81320
|
`, "utf8");
|
|
81152
81321
|
} catch {
|
|
@@ -81242,7 +81411,7 @@ init_paths();
|
|
|
81242
81411
|
init_profile2();
|
|
81243
81412
|
|
|
81244
81413
|
// src/witness-queue.ts
|
|
81245
|
-
import { readFileSync as
|
|
81414
|
+
import { readFileSync as readFileSync29, renameSync as renameSync3, writeFileSync as writeFileSync20 } from "node:fs";
|
|
81246
81415
|
import { dirname as dirname11, join as join32 } from "node:path";
|
|
81247
81416
|
var WITNESS_QUEUE_CAP = 500;
|
|
81248
81417
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
@@ -81253,7 +81422,7 @@ function witnessQueuePath(workspaceConfigDir) {
|
|
|
81253
81422
|
function loadWitnessQueueWithLosses(path2) {
|
|
81254
81423
|
let raw2;
|
|
81255
81424
|
try {
|
|
81256
|
-
raw2 = JSON.parse(
|
|
81425
|
+
raw2 = JSON.parse(readFileSync29(path2, "utf8"));
|
|
81257
81426
|
} catch (err2) {
|
|
81258
81427
|
const absent = err2?.code === "ENOENT";
|
|
81259
81428
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -81267,7 +81436,7 @@ function loadWitnessQueueWithLosses(path2) {
|
|
|
81267
81436
|
function saveWitnessQueue(path2, queue) {
|
|
81268
81437
|
try {
|
|
81269
81438
|
const tmp = join32(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
|
|
81270
|
-
|
|
81439
|
+
writeFileSync20(tmp, JSON.stringify(queue), "utf8");
|
|
81271
81440
|
renameSync3(tmp, path2);
|
|
81272
81441
|
} catch {
|
|
81273
81442
|
}
|
|
@@ -81574,7 +81743,7 @@ function maybeFlushDigests() {
|
|
|
81574
81743
|
|
|
81575
81744
|
// src/liveness-watch.ts
|
|
81576
81745
|
init_src5();
|
|
81577
|
-
import { readFileSync as
|
|
81746
|
+
import { readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
|
|
81578
81747
|
import { join as join34 } from "node:path";
|
|
81579
81748
|
|
|
81580
81749
|
// src/loop-lag.ts
|
|
@@ -81710,7 +81879,7 @@ function alarmStatePath(configDir) {
|
|
|
81710
81879
|
}
|
|
81711
81880
|
function loadAlarmState(configDir) {
|
|
81712
81881
|
try {
|
|
81713
|
-
const raw2 = JSON.parse(
|
|
81882
|
+
const raw2 = JSON.parse(readFileSync31(alarmStatePath(configDir), "utf8"));
|
|
81714
81883
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
81715
81884
|
} catch {
|
|
81716
81885
|
return /* @__PURE__ */ new Map();
|
|
@@ -81718,7 +81887,7 @@ function loadAlarmState(configDir) {
|
|
|
81718
81887
|
}
|
|
81719
81888
|
function saveAlarmState(configDir, state) {
|
|
81720
81889
|
try {
|
|
81721
|
-
|
|
81890
|
+
writeFileSync22(alarmStatePath(configDir), JSON.stringify(Object.fromEntries(state)));
|
|
81722
81891
|
} catch {
|
|
81723
81892
|
}
|
|
81724
81893
|
}
|
|
@@ -81918,7 +82087,7 @@ function createWatchBreaker(deps) {
|
|
|
81918
82087
|
}
|
|
81919
82088
|
|
|
81920
82089
|
// src/engine.ts
|
|
81921
|
-
var DAEMON_VERSION = true ? "2.0.17-dev.
|
|
82090
|
+
var DAEMON_VERSION = true ? "2.0.17-dev.3426" : "2.0.0-alpha.0";
|
|
81922
82091
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
81923
82092
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
81924
82093
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -81930,7 +82099,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
81930
82099
|
function appendIdentityAudit(path2, record2, line) {
|
|
81931
82100
|
if (!record2.accepted && record2.score <= 0) return;
|
|
81932
82101
|
try {
|
|
81933
|
-
if (
|
|
82102
|
+
if (existsSync28(path2) && statSync8(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
81934
82103
|
renameSync4(path2, `${path2}.1`);
|
|
81935
82104
|
}
|
|
81936
82105
|
appendFileSync4(path2, line);
|
|
@@ -81940,7 +82109,7 @@ function appendIdentityAudit(path2, record2, line) {
|
|
|
81940
82109
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
81941
82110
|
function loadTurnCursors(path2) {
|
|
81942
82111
|
try {
|
|
81943
|
-
const raw2 = JSON.parse(
|
|
82112
|
+
const raw2 = JSON.parse(readFileSync32(path2, "utf8"));
|
|
81944
82113
|
return new Map(
|
|
81945
82114
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
81946
82115
|
);
|
|
@@ -81950,7 +82119,7 @@ function loadTurnCursors(path2) {
|
|
|
81950
82119
|
}
|
|
81951
82120
|
function loadTurnOffsets(path2) {
|
|
81952
82121
|
try {
|
|
81953
|
-
const raw2 = JSON.parse(
|
|
82122
|
+
const raw2 = JSON.parse(readFileSync32(path2, "utf8"));
|
|
81954
82123
|
const out2 = /* @__PURE__ */ new Map();
|
|
81955
82124
|
for (const [k, v] of Object.entries(raw2)) {
|
|
81956
82125
|
const off = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -81966,7 +82135,7 @@ function saveTurnCursors(path2, cursors, offsets) {
|
|
|
81966
82135
|
const merged = {};
|
|
81967
82136
|
for (const [k, uuid3] of cursors) merged[k] = { uuid: uuid3, offset: offsets.get(k) ?? 0 };
|
|
81968
82137
|
for (const [k, offset] of offsets) if (!merged[k]) merged[k] = { uuid: "", offset };
|
|
81969
|
-
|
|
82138
|
+
writeFileSync23(path2, JSON.stringify(merged), "utf8");
|
|
81970
82139
|
} catch {
|
|
81971
82140
|
}
|
|
81972
82141
|
}
|
|
@@ -82255,7 +82424,7 @@ function createWorkspaceEngine(opts) {
|
|
|
82255
82424
|
);
|
|
82256
82425
|
};
|
|
82257
82426
|
const gitDir = join35(opts.workspaceRoot, ".git");
|
|
82258
|
-
if (
|
|
82427
|
+
if (existsSync28(gitDir)) {
|
|
82259
82428
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
82260
82429
|
void handleGitEvent(ev).catch((err2) => {
|
|
82261
82430
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -82320,6 +82489,9 @@ function createWorkspaceEngine(opts) {
|
|
|
82320
82489
|
let subagentBase = null;
|
|
82321
82490
|
let subagentBaseVersion = 0;
|
|
82322
82491
|
const subagentRenders = /* @__PURE__ */ new Map();
|
|
82492
|
+
const sessions = createSessionRegistry({ originsPath: join35(paths.configDir, "session-origins.json") });
|
|
82493
|
+
const sessionRenders = /* @__PURE__ */ new Map();
|
|
82494
|
+
const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
|
|
82323
82495
|
const toolRuns = createToolRunState();
|
|
82324
82496
|
let ctxRefreshTimer = null;
|
|
82325
82497
|
let contextDirty = false;
|
|
@@ -82375,6 +82547,22 @@ function createWorkspaceEngine(opts) {
|
|
|
82375
82547
|
return [];
|
|
82376
82548
|
}
|
|
82377
82549
|
};
|
|
82550
|
+
const statedIntentFor = (intent) => {
|
|
82551
|
+
const collective = intentRemote?.forIntent === intent ? intentRemote : null;
|
|
82552
|
+
return {
|
|
82553
|
+
text: intent,
|
|
82554
|
+
hits: searchByIntent(store, intent, { limit: 4 }).map((h) => ({
|
|
82555
|
+
id: h.node.id,
|
|
82556
|
+
label: h.node.label,
|
|
82557
|
+
description: h.node.description,
|
|
82558
|
+
coverage: h.coverage
|
|
82559
|
+
})),
|
|
82560
|
+
...collective && collective.hits.length > 0 ? {
|
|
82561
|
+
remoteHits: collective.hits.slice(0, 4).map((n) => ({ id: n.id, label: n.label, description: n.description }))
|
|
82562
|
+
} : {},
|
|
82563
|
+
...collective?.voidSignal ? { knownGap: collective.voidSignal } : {}
|
|
82564
|
+
};
|
|
82565
|
+
};
|
|
82378
82566
|
const refreshContextOnce = async () => {
|
|
82379
82567
|
const elicit = isEdgeElicitationEnabled();
|
|
82380
82568
|
const snapOpts = {
|
|
@@ -82397,47 +82585,29 @@ function createWorkspaceEngine(opts) {
|
|
|
82397
82585
|
contextDirty = true;
|
|
82398
82586
|
return;
|
|
82399
82587
|
}
|
|
82400
|
-
const baseForSubagents = prebuilt ? structuredClone(prebuilt) : null;
|
|
82401
82588
|
const doneRender = markPass(`${prebuilt ? "context-render" : "context-render-inline"}:${profile.name}`);
|
|
82589
|
+
const base = prebuilt ?? buildSnapshot({ store, ...snapOpts });
|
|
82590
|
+
subagentBase = structuredClone(base);
|
|
82591
|
+
subagentBaseVersion++;
|
|
82592
|
+
const sharedSnapshot = scopeSnapshot(base, (n) => !isQuarantined(n, sessions));
|
|
82402
82593
|
const pendingUpdate = opts.pendingUpdate?.() ?? null;
|
|
82403
82594
|
const daemonDistress = opts.daemonDistress?.() ?? null;
|
|
82404
82595
|
const reviewItems = pickReviewItems();
|
|
82405
82596
|
const liveIntent = intents.mostRecent(Date.now());
|
|
82406
82597
|
maybeRefreshIntentPriors(liveIntent ?? null);
|
|
82407
|
-
const
|
|
82408
|
-
id: h.node.id,
|
|
82409
|
-
label: h.node.label,
|
|
82410
|
-
description: h.node.description,
|
|
82411
|
-
coverage: h.coverage
|
|
82412
|
-
})) : [];
|
|
82413
|
-
const intentCollective = liveIntent && intentRemote?.forIntent === liveIntent ? intentRemote : null;
|
|
82598
|
+
const statedIntent = liveIntent ? statedIntentFor(liveIntent) : null;
|
|
82414
82599
|
const { body: body2, snapshot, ledger } = assembleAgentContext({
|
|
82415
82600
|
store,
|
|
82416
82601
|
...snapOpts,
|
|
82417
82602
|
remote: remotePriors,
|
|
82418
82603
|
...elicit ? { edgeElicitation: { instruction: PRIOR_TAG_INSTRUCTION } } : {},
|
|
82419
|
-
|
|
82604
|
+
snapshot: sharedSnapshot,
|
|
82420
82605
|
...pendingUpdate ? { pendingUpdate } : {},
|
|
82421
82606
|
...daemonDistress ? { daemonDistress } : {},
|
|
82422
82607
|
...reviewItems.length ? { reviewItems } : {},
|
|
82423
|
-
...
|
|
82424
|
-
statedIntent: {
|
|
82425
|
-
text: liveIntent,
|
|
82426
|
-
hits: intentHits,
|
|
82427
|
-
...intentCollective && intentCollective.hits.length > 0 ? {
|
|
82428
|
-
remoteHits: intentCollective.hits.slice(0, 4).map((n) => ({
|
|
82429
|
-
id: n.id,
|
|
82430
|
-
label: n.label,
|
|
82431
|
-
description: n.description
|
|
82432
|
-
}))
|
|
82433
|
-
} : {},
|
|
82434
|
-
...intentCollective?.voidSignal ? { knownGap: intentCollective.voidSignal } : {}
|
|
82435
|
-
}
|
|
82436
|
-
} : {}
|
|
82608
|
+
...statedIntent ? { statedIntent } : {}
|
|
82437
82609
|
});
|
|
82438
82610
|
doneRender();
|
|
82439
|
-
subagentBase = baseForSubagents ?? structuredClone(snapshot);
|
|
82440
|
-
subagentBaseVersion++;
|
|
82441
82611
|
try {
|
|
82442
82612
|
const seq = store.currentIngestSeq();
|
|
82443
82613
|
const stamped = recordRenderLedger(store, ledger, seq, Date.now());
|
|
@@ -82797,6 +82967,83 @@ function createWorkspaceEngine(opts) {
|
|
|
82797
82967
|
subagents.stop(agentId);
|
|
82798
82968
|
subagentRenders.delete(agentId);
|
|
82799
82969
|
};
|
|
82970
|
+
const noteSession = (e) => {
|
|
82971
|
+
const now = Date.now();
|
|
82972
|
+
if (!e.sessionId) return;
|
|
82973
|
+
const origin = e.origin ? { origin: e.origin } : {};
|
|
82974
|
+
if (e.agentId) {
|
|
82975
|
+
const sub = `agent-${e.agentId}`;
|
|
82976
|
+
if (e.ended) sessions.end(sub);
|
|
82977
|
+
else sessions.touch(sub, now, { parent: e.sessionId, ...origin });
|
|
82978
|
+
sessions.touch(e.sessionId, now, origin);
|
|
82979
|
+
return;
|
|
82980
|
+
}
|
|
82981
|
+
if (e.ended) sessions.end(e.sessionId);
|
|
82982
|
+
else sessions.touch(e.sessionId, now, origin);
|
|
82983
|
+
};
|
|
82984
|
+
const sessionContext = (sessionId) => {
|
|
82985
|
+
if (!sessionId || !subagentBase) return null;
|
|
82986
|
+
const now = Date.now();
|
|
82987
|
+
const intent = intents.get(sessionId, now);
|
|
82988
|
+
const workingFile = workingFiles.get(sessionId);
|
|
82989
|
+
const skips = selfCiteSkipsBySession.get(sessionId) ?? 0;
|
|
82990
|
+
const key = JSON.stringify([
|
|
82991
|
+
subagentBaseVersion,
|
|
82992
|
+
lastRemoteAt,
|
|
82993
|
+
sessions.version(now),
|
|
82994
|
+
intent,
|
|
82995
|
+
workingFile,
|
|
82996
|
+
intentRemote?.forIntent === intent ? intentRemote?.hits.length : -1,
|
|
82997
|
+
skips
|
|
82998
|
+
]);
|
|
82999
|
+
const cached2 = sessionRenders.get(sessionId);
|
|
83000
|
+
if (cached2?.key === key) return cached2.block;
|
|
83001
|
+
const elicit = isEdgeElicitationEnabled();
|
|
83002
|
+
const atCommit = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
83003
|
+
const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
|
|
83004
|
+
delete scoped.workingFile;
|
|
83005
|
+
if (workingFile) {
|
|
83006
|
+
const slice = sliceForFile(store, workingFile, atCommit);
|
|
83007
|
+
if (slice) scoped.workingFile = slice;
|
|
83008
|
+
}
|
|
83009
|
+
delete scoped.selfCiteSkips;
|
|
83010
|
+
if (skips > 0) scoped.selfCiteSkips = skips;
|
|
83011
|
+
const pendingUpdate = opts.pendingUpdate?.() ?? null;
|
|
83012
|
+
const daemonDistress = opts.daemonDistress?.() ?? null;
|
|
83013
|
+
const reviewItems = pickReviewItems();
|
|
83014
|
+
const { body: body2, snapshot } = assembleAgentContext({
|
|
83015
|
+
store,
|
|
83016
|
+
profile,
|
|
83017
|
+
...atCommit ? { atCommit } : {},
|
|
83018
|
+
reviewCount: pendingCount(paths),
|
|
83019
|
+
reviewUiUrl: opts.reviewUrl(),
|
|
83020
|
+
remote: remotePriors,
|
|
83021
|
+
snapshot: scoped,
|
|
83022
|
+
...elicit ? { edgeElicitation: { instruction: PRIOR_TAG_INSTRUCTION } } : {},
|
|
83023
|
+
...pendingUpdate ? { pendingUpdate } : {},
|
|
83024
|
+
...daemonDistress ? { daemonDistress } : {},
|
|
83025
|
+
...reviewItems.length ? { reviewItems } : {},
|
|
83026
|
+
...intent ? { statedIntent: statedIntentFor(intent) } : {}
|
|
83027
|
+
});
|
|
83028
|
+
const block = {
|
|
83029
|
+
body: body2,
|
|
83030
|
+
hash: contextHash(body2),
|
|
83031
|
+
card: contextCard(store, snapshot),
|
|
83032
|
+
handleNodes: [
|
|
83033
|
+
...snapshot.recentProblems.map((r) => r.node),
|
|
83034
|
+
...snapshot.recentResolved.flatMap((r) => r.solution ? [r.node, r.solution] : [r.node]),
|
|
83035
|
+
...snapshot.motifs,
|
|
83036
|
+
...snapshot.remote ?? []
|
|
83037
|
+
]
|
|
83038
|
+
};
|
|
83039
|
+
if (elicit && block.handleNodes.length) {
|
|
83040
|
+
writePrimingHandles(join35(paths.configDir, "priming-handles.json"), block.handleNodes);
|
|
83041
|
+
}
|
|
83042
|
+
sessionRenders.delete(sessionId);
|
|
83043
|
+
sessionRenders.set(sessionId, { key, block });
|
|
83044
|
+
if (sessionRenders.size > 200) sessionRenders.delete(sessionRenders.keys().next().value);
|
|
83045
|
+
return block;
|
|
83046
|
+
};
|
|
82800
83047
|
const onHookEvent = (e) => {
|
|
82801
83048
|
const intentHints = deriveIntentHints(e.tool, e.oldString, e.newString);
|
|
82802
83049
|
const operation = /(?:edit|write|patch)/i.test(e.tool) ? "write" : /read/i.test(e.tool) ? "read" : null;
|
|
@@ -83116,7 +83363,7 @@ function createWorkspaceEngine(opts) {
|
|
|
83116
83363
|
let anchorReadFailed = false;
|
|
83117
83364
|
if (p.location) {
|
|
83118
83365
|
try {
|
|
83119
|
-
fileText =
|
|
83366
|
+
fileText = readFileSync32(join35(opts.workspaceRoot, p.location.path), "utf8");
|
|
83120
83367
|
} catch {
|
|
83121
83368
|
anchorReadFailed = true;
|
|
83122
83369
|
}
|
|
@@ -83276,7 +83523,7 @@ function createWorkspaceEngine(opts) {
|
|
|
83276
83523
|
const headSha = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
83277
83524
|
enclosing = {
|
|
83278
83525
|
line: p.location.line,
|
|
83279
|
-
fileText:
|
|
83526
|
+
fileText: readFileSync32(join35(opts.workspaceRoot, anchorPath), "utf8"),
|
|
83280
83527
|
...headSha ? { headSha } : {}
|
|
83281
83528
|
};
|
|
83282
83529
|
} catch {
|
|
@@ -83537,6 +83784,12 @@ function createWorkspaceEngine(opts) {
|
|
|
83537
83784
|
}
|
|
83538
83785
|
const citingSession = sessionOriginKey(sessionId);
|
|
83539
83786
|
const mintedHere = (nodeId) => store.getNode(nodeId)?.attrs["sources"]?.[0] === sessionId;
|
|
83787
|
+
const synthetic = sessions.originOf(sessionId) !== void 0;
|
|
83788
|
+
if (synthetic && plan.corroborations.length + plan.refutes.length > 0) {
|
|
83789
|
+
console.log(
|
|
83790
|
+
`[errata] witnesses: ${plan.corroborations.length + plan.refutes.length} withheld (session ${sessionId.slice(0, 8)} is ${sessions.originOf(sessionId)})`
|
|
83791
|
+
);
|
|
83792
|
+
}
|
|
83540
83793
|
const sendWitnesses = async (channel, fresh, send) => {
|
|
83541
83794
|
const isShipped = (nodeId) => {
|
|
83542
83795
|
const n = store.getNode(nodeId);
|
|
@@ -83661,7 +83914,7 @@ function createWorkspaceEngine(opts) {
|
|
|
83661
83914
|
if (typeof cloud.reportContradictions === "function") {
|
|
83662
83915
|
await sendWitnesses(
|
|
83663
83916
|
"contradict",
|
|
83664
|
-
wireWitnessItems(plan.refutes),
|
|
83917
|
+
synthetic ? [] : wireWitnessItems(plan.refutes),
|
|
83665
83918
|
(items2, session) => cloud.reportContradictions({
|
|
83666
83919
|
daemonVersion: DAEMON_VERSION,
|
|
83667
83920
|
projectId: profile.id,
|
|
@@ -83671,12 +83924,13 @@ function createWorkspaceEngine(opts) {
|
|
|
83671
83924
|
);
|
|
83672
83925
|
}
|
|
83673
83926
|
if (typeof cloud.reportCorroborations === "function") {
|
|
83674
|
-
const emit = plan.corroborations.filter((c) => !mintedHere(c.nodeId));
|
|
83927
|
+
const emit = synthetic ? [] : plan.corroborations.filter((c) => !mintedHere(c.nodeId));
|
|
83675
83928
|
const skipped = plan.corroborations.length - emit.length;
|
|
83676
83929
|
if (skipped > 0) {
|
|
83677
83930
|
console.log(`[errata] corroborate: ${skipped} skipped (this session authored the node)`);
|
|
83678
83931
|
appendWitnessLedger(paths.configDir, { ts: Date.now(), channel: "corroborate", clientSelfSkipped: skipped });
|
|
83679
83932
|
lastSelfCiteSkips = skipped;
|
|
83933
|
+
selfCiteSkipsBySession.set(sessionId, skipped);
|
|
83680
83934
|
refreshContextNow();
|
|
83681
83935
|
}
|
|
83682
83936
|
await sendWitnesses(
|
|
@@ -83858,7 +84112,7 @@ function createWorkspaceEngine(opts) {
|
|
|
83858
84112
|
}
|
|
83859
84113
|
turns = next.turns;
|
|
83860
84114
|
nextOffset = next.nextOffset;
|
|
83861
|
-
await new Promise((
|
|
84115
|
+
await new Promise((resolve9) => setImmediate(resolve9));
|
|
83862
84116
|
}
|
|
83863
84117
|
};
|
|
83864
84118
|
const seenMessageIds = /* @__PURE__ */ new Set();
|
|
@@ -84115,6 +84369,8 @@ B: ${b}`,
|
|
|
84115
84369
|
onSubagentSpawn,
|
|
84116
84370
|
subagentContext,
|
|
84117
84371
|
onSubagentStop,
|
|
84372
|
+
noteSession,
|
|
84373
|
+
sessionContext,
|
|
84118
84374
|
onHook: () => telemetry.count("hooks_fired"),
|
|
84119
84375
|
onToolsObserved: (sessionId, toolNodeIds) => toolRuns.record(sessionId, toolNodeIds),
|
|
84120
84376
|
onHookEvent,
|
|
@@ -84132,6 +84388,7 @@ B: ${b}`,
|
|
|
84132
84388
|
lastActivityAt() {
|
|
84133
84389
|
return lastActivityTs;
|
|
84134
84390
|
},
|
|
84391
|
+
quarantinedSessions: () => sessions.originSessions(),
|
|
84135
84392
|
markContextDirty() {
|
|
84136
84393
|
contextDirty = true;
|
|
84137
84394
|
refreshContextNow();
|
|
@@ -84396,15 +84653,19 @@ B: ${b}`,
|
|
|
84396
84653
|
console.log(
|
|
84397
84654
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
84398
84655
|
);
|
|
84399
|
-
const pending =
|
|
84656
|
+
const pending = existsSync28(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
84400
84657
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
84401
84658
|
}
|
|
84659
|
+
if (!shipsFromWorkspace(opts.workspaceRoot)) {
|
|
84660
|
+
console.log("[errata] sync skipped \u2014 scratch workspace (under the OS temp dir); its captures stay local");
|
|
84661
|
+
return { uploaded: 0, failed: 0, remaining: 0 };
|
|
84662
|
+
}
|
|
84402
84663
|
const onDisk = loadProfile(opts.workspaceRoot);
|
|
84403
84664
|
if (!onDisk?.projectId && onDisk?.projectLinkHold) {
|
|
84404
84665
|
console.log(
|
|
84405
84666
|
"[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
|
|
84406
84667
|
);
|
|
84407
|
-
const pending =
|
|
84668
|
+
const pending = existsSync28(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
84408
84669
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
84409
84670
|
}
|
|
84410
84671
|
try {
|
|
@@ -84498,7 +84759,7 @@ async function startDaemon(opts) {
|
|
|
84498
84759
|
reviewUrl: () => webUiUrl + "/review"
|
|
84499
84760
|
});
|
|
84500
84761
|
const writeLockFile = (url2) => {
|
|
84501
|
-
|
|
84762
|
+
writeFileSync24(
|
|
84502
84763
|
engine.paths.daemonLock,
|
|
84503
84764
|
daemonLockPayload({ pid: process.pid, webUiUrl: url2, processStartedAt, version: DAEMON_VERSION }),
|
|
84504
84765
|
"utf8"
|
|
@@ -84515,6 +84776,8 @@ async function startDaemon(opts) {
|
|
|
84515
84776
|
onSubagentSpawn: engine.webHooks.onSubagentSpawn,
|
|
84516
84777
|
subagentContext: engine.webHooks.subagentContext,
|
|
84517
84778
|
onSubagentStop: engine.webHooks.onSubagentStop,
|
|
84779
|
+
noteSession: engine.webHooks.noteSession,
|
|
84780
|
+
sessionContext: engine.webHooks.sessionContext,
|
|
84518
84781
|
onHook: engine.webHooks.onHook,
|
|
84519
84782
|
onHookEvent: engine.webHooks.onHookEvent,
|
|
84520
84783
|
onShellEvent: engine.webHooks.onShellEvent,
|
|
@@ -84544,7 +84807,7 @@ async function startDaemon(opts) {
|
|
|
84544
84807
|
);
|
|
84545
84808
|
await engine.stop();
|
|
84546
84809
|
try {
|
|
84547
|
-
if (
|
|
84810
|
+
if (existsSync29(engine.paths.daemonLock)) {
|
|
84548
84811
|
}
|
|
84549
84812
|
} catch {
|
|
84550
84813
|
}
|
|
@@ -84552,9 +84815,9 @@ async function startDaemon(opts) {
|
|
|
84552
84815
|
};
|
|
84553
84816
|
}
|
|
84554
84817
|
async function listenServer(fetchFn, port) {
|
|
84555
|
-
return new Promise((
|
|
84818
|
+
return new Promise((resolve9) => {
|
|
84556
84819
|
const server = serve({ fetch: fetchFn, hostname: "127.0.0.1", port }, (info2) => {
|
|
84557
|
-
|
|
84820
|
+
resolve9({ server, port: info2.port });
|
|
84558
84821
|
});
|
|
84559
84822
|
});
|
|
84560
84823
|
}
|
|
@@ -84745,7 +85008,7 @@ function instanceReceiptSequence(n) {
|
|
|
84745
85008
|
// src/multi.ts
|
|
84746
85009
|
init_dist();
|
|
84747
85010
|
init_src5();
|
|
84748
|
-
import { existsSync as
|
|
85011
|
+
import { existsSync as existsSync34, readFileSync as readFileSync36, unlinkSync as unlinkSync5, writeFileSync as writeFileSync26 } from "node:fs";
|
|
84749
85012
|
import { resolve as pathResolve } from "node:path";
|
|
84750
85013
|
|
|
84751
85014
|
// src/principle-sync.ts
|
|
@@ -84774,7 +85037,7 @@ init_reconcile();
|
|
|
84774
85037
|
|
|
84775
85038
|
// src/lockfile-auto.ts
|
|
84776
85039
|
init_src();
|
|
84777
|
-
import { existsSync as
|
|
85040
|
+
import { existsSync as existsSync30, readFileSync as readFileSync33 } from "node:fs";
|
|
84778
85041
|
import { join as join36 } from "node:path";
|
|
84779
85042
|
|
|
84780
85043
|
// src/package-index.ts
|
|
@@ -84925,10 +85188,10 @@ function runLockfilePass(opts) {
|
|
|
84925
85188
|
];
|
|
84926
85189
|
for (const c of candidates) {
|
|
84927
85190
|
const p = join36(opts.root, c.file);
|
|
84928
|
-
if (!
|
|
85191
|
+
if (!existsSync30(p)) continue;
|
|
84929
85192
|
let sbom;
|
|
84930
85193
|
try {
|
|
84931
|
-
sbom = c.parse(
|
|
85194
|
+
sbom = c.parse(readFileSync33(p, "utf8"));
|
|
84932
85195
|
} catch {
|
|
84933
85196
|
continue;
|
|
84934
85197
|
}
|
|
@@ -84986,9 +85249,10 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
|
84986
85249
|
|
|
84987
85250
|
// src/instance-ingest.ts
|
|
84988
85251
|
init_profile2();
|
|
85252
|
+
init_session_registry();
|
|
84989
85253
|
|
|
84990
85254
|
// src/public-symbols.ts
|
|
84991
|
-
import { readFileSync as
|
|
85255
|
+
import { readFileSync as readFileSync34, readdirSync as readdirSync11, existsSync as existsSync31 } from "node:fs";
|
|
84992
85256
|
import { join as join37 } from "node:path";
|
|
84993
85257
|
var HEAD_BYTES = 8 * 1024;
|
|
84994
85258
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
@@ -85023,9 +85287,9 @@ function internalPackageNames(workspaceRoot) {
|
|
|
85023
85287
|
const names = /* @__PURE__ */ new Set();
|
|
85024
85288
|
const tryRead = (dir) => {
|
|
85025
85289
|
const pj = join37(dir, "package.json");
|
|
85026
|
-
if (!
|
|
85290
|
+
if (!existsSync31(pj)) return;
|
|
85027
85291
|
try {
|
|
85028
|
-
const name2 = JSON.parse(
|
|
85292
|
+
const name2 = JSON.parse(readFileSync34(pj, "utf8")).name;
|
|
85029
85293
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
85030
85294
|
} catch {
|
|
85031
85295
|
}
|
|
@@ -85033,7 +85297,7 @@ function internalPackageNames(workspaceRoot) {
|
|
|
85033
85297
|
tryRead(workspaceRoot);
|
|
85034
85298
|
for (const group of ["packages", "apps"]) {
|
|
85035
85299
|
const groupDir = join37(workspaceRoot, group);
|
|
85036
|
-
if (!
|
|
85300
|
+
if (!existsSync31(groupDir)) continue;
|
|
85037
85301
|
try {
|
|
85038
85302
|
for (const entry of readdirSync11(groupDir)) tryRead(join37(groupDir, entry));
|
|
85039
85303
|
} catch {
|
|
@@ -85054,7 +85318,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
85054
85318
|
}
|
|
85055
85319
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
85056
85320
|
try {
|
|
85057
|
-
return
|
|
85321
|
+
return readFileSync34(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
85058
85322
|
} catch {
|
|
85059
85323
|
return "";
|
|
85060
85324
|
}
|
|
@@ -85211,6 +85475,7 @@ function shareableContext(n, wireId) {
|
|
|
85211
85475
|
function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [], opts = {}) {
|
|
85212
85476
|
const level = opts.level ?? 1;
|
|
85213
85477
|
const noveltyOpts = opts.dedupCosine != null ? { dedupCosine: opts.dedupCosine } : {};
|
|
85478
|
+
const quarantine = opts.quarantinedSessions?.length ? new Set(opts.quarantinedSessions) : null;
|
|
85214
85479
|
const ignored = (text) => ignorePatterns.length > 0 && ignorePatterns.some((p) => text.toLowerCase().includes(p));
|
|
85215
85480
|
const originSessionOf = (n) => {
|
|
85216
85481
|
const key = sessionOriginKey(n.attrs["sources"]?.[0]);
|
|
@@ -85279,6 +85544,7 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
85279
85544
|
candidates: 0,
|
|
85280
85545
|
shipped: 0,
|
|
85281
85546
|
cloudSourced: 0,
|
|
85547
|
+
quarantined: 0,
|
|
85282
85548
|
falsePositive: 0,
|
|
85283
85549
|
ignored: 0,
|
|
85284
85550
|
watermarked: 0,
|
|
@@ -85329,6 +85595,10 @@ function buildInstanceIngest(store, profile, daemonVersion, ignorePatterns = [],
|
|
|
85329
85595
|
composition.cloudSourced++;
|
|
85330
85596
|
continue;
|
|
85331
85597
|
}
|
|
85598
|
+
if (quarantine && capturedOnlyBy(n, quarantine)) {
|
|
85599
|
+
composition.quarantined++;
|
|
85600
|
+
continue;
|
|
85601
|
+
}
|
|
85332
85602
|
if (n.attrs["resolvedAs"] === PROBLEM_RESOLUTION.FALSE_POSITIVE) {
|
|
85333
85603
|
composition.falsePositive++;
|
|
85334
85604
|
continue;
|
|
@@ -85736,7 +86006,8 @@ function buildDrainInstances(store, sharedStore, input) {
|
|
|
85736
86006
|
},
|
|
85737
86007
|
...lexicon ? { lexicon } : {},
|
|
85738
86008
|
...fileLexicon ? { fileLexicon } : {},
|
|
85739
|
-
...input.project ? { project: input.project } : {}
|
|
86009
|
+
...input.project ? { project: input.project } : {},
|
|
86010
|
+
...input.quarantinedSessions?.length ? { quarantinedSessions: input.quarantinedSessions } : {}
|
|
85740
86011
|
});
|
|
85741
86012
|
return {
|
|
85742
86013
|
batch,
|
|
@@ -85748,6 +86019,7 @@ function buildDrainInstances(store, sharedStore, input) {
|
|
|
85748
86019
|
// src/multi.ts
|
|
85749
86020
|
init_webui();
|
|
85750
86021
|
init_recall_card();
|
|
86022
|
+
init_session_registry();
|
|
85751
86023
|
|
|
85752
86024
|
// src/consolidate-worker-client.ts
|
|
85753
86025
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
@@ -85767,8 +86039,8 @@ var ConsolidateWorker = class {
|
|
|
85767
86039
|
const id = this.nextId++;
|
|
85768
86040
|
try {
|
|
85769
86041
|
await this.ready;
|
|
85770
|
-
return await new Promise((
|
|
85771
|
-
this.pending.set(id, { resolve:
|
|
86042
|
+
return await new Promise((resolve9, reject) => {
|
|
86043
|
+
this.pending.set(id, { resolve: resolve9, reject });
|
|
85772
86044
|
this.worker.postMessage({ ...req, id });
|
|
85773
86045
|
});
|
|
85774
86046
|
} finally {
|
|
@@ -85797,12 +86069,12 @@ var ConsolidateWorker = class {
|
|
|
85797
86069
|
});
|
|
85798
86070
|
noteIsolateSpawned();
|
|
85799
86071
|
this.worker = worker;
|
|
85800
|
-
this.ready = new Promise((
|
|
86072
|
+
this.ready = new Promise((resolve9, reject) => {
|
|
85801
86073
|
const onReady = (m) => {
|
|
85802
86074
|
if (m?.ready) {
|
|
85803
86075
|
worker.off("message", onReady);
|
|
85804
86076
|
worker.off("error", onErr);
|
|
85805
|
-
|
|
86077
|
+
resolve9();
|
|
85806
86078
|
}
|
|
85807
86079
|
};
|
|
85808
86080
|
const onErr = (err2) => {
|
|
@@ -86007,17 +86279,17 @@ function startUpdatePoller(opts) {
|
|
|
86007
86279
|
};
|
|
86008
86280
|
}
|
|
86009
86281
|
function runNpmInstall(channel) {
|
|
86010
|
-
return new Promise((
|
|
86282
|
+
return new Promise((resolve9) => {
|
|
86011
86283
|
const child = spawn2("npm", ["install", "-g", `${PACKAGE_NAME}@${channel}`], {
|
|
86012
86284
|
stdio: "inherit",
|
|
86013
86285
|
shell: true
|
|
86014
86286
|
});
|
|
86015
|
-
child.on("close", (code) =>
|
|
86016
|
-
child.on("error", () =>
|
|
86287
|
+
child.on("close", (code) => resolve9(code ?? 1));
|
|
86288
|
+
child.on("error", () => resolve9(1));
|
|
86017
86289
|
});
|
|
86018
86290
|
}
|
|
86019
86291
|
async function runInstalledHookRefresh() {
|
|
86020
|
-
const root = await new Promise((
|
|
86292
|
+
const root = await new Promise((resolve9) => {
|
|
86021
86293
|
const child = spawn2("npm", ["root", "-g"], {
|
|
86022
86294
|
shell: true,
|
|
86023
86295
|
windowsHide: true,
|
|
@@ -86029,18 +86301,18 @@ async function runInstalledHookRefresh() {
|
|
|
86029
86301
|
output += chunk;
|
|
86030
86302
|
if (output.length > 32768) child.kill();
|
|
86031
86303
|
});
|
|
86032
|
-
child.on("error", () =>
|
|
86033
|
-
child.on("close", (code) =>
|
|
86304
|
+
child.on("error", () => resolve9(""));
|
|
86305
|
+
child.on("close", (code) => resolve9(code === 0 ? output.trim() : ""));
|
|
86034
86306
|
});
|
|
86035
86307
|
if (!isAbsolute5(root)) return 1;
|
|
86036
|
-
return new Promise((
|
|
86308
|
+
return new Promise((resolve9) => {
|
|
86037
86309
|
const child = spawn2(process.execPath, [join38(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", "codex", "--refresh-existing"], {
|
|
86038
86310
|
windowsHide: true,
|
|
86039
86311
|
stdio: "inherit",
|
|
86040
86312
|
timeout: 3e4
|
|
86041
86313
|
});
|
|
86042
|
-
child.on("error", () =>
|
|
86043
|
-
child.on("close", (code) =>
|
|
86314
|
+
child.on("error", () => resolve9(1));
|
|
86315
|
+
child.on("close", (code) => resolve9(code ?? 1));
|
|
86044
86316
|
});
|
|
86045
86317
|
}
|
|
86046
86318
|
|
|
@@ -86055,7 +86327,7 @@ function liveCloudClient(src) {
|
|
|
86055
86327
|
let current = null;
|
|
86056
86328
|
let currentKey = "";
|
|
86057
86329
|
let checkedAt = -Infinity;
|
|
86058
|
-
const
|
|
86330
|
+
const resolve9 = () => {
|
|
86059
86331
|
const t = now();
|
|
86060
86332
|
if (current && t - checkedAt < recheckMs) return current;
|
|
86061
86333
|
checkedAt = t;
|
|
@@ -86075,7 +86347,7 @@ function liveCloudClient(src) {
|
|
|
86075
86347
|
};
|
|
86076
86348
|
return new Proxy({}, {
|
|
86077
86349
|
get(_target, prop) {
|
|
86078
|
-
const client =
|
|
86350
|
+
const client = resolve9();
|
|
86079
86351
|
const value = Reflect.get(client, prop, client);
|
|
86080
86352
|
return typeof value === "function" ? value.bind(client) : value;
|
|
86081
86353
|
}
|
|
@@ -86513,7 +86785,7 @@ async function syncHistoryRevision(opts) {
|
|
|
86513
86785
|
changed += result.changed;
|
|
86514
86786
|
remaining = result.remaining;
|
|
86515
86787
|
if (!remaining || Date.now() - started2 >= (opts.budgetMs ?? 45e3)) break;
|
|
86516
|
-
await new Promise((
|
|
86788
|
+
await new Promise((resolve9) => setImmediate(resolve9));
|
|
86517
86789
|
}
|
|
86518
86790
|
return { changed, remaining };
|
|
86519
86791
|
})();
|
|
@@ -86616,7 +86888,7 @@ async function syncHistoryRevisionPage(opts) {
|
|
|
86616
86888
|
init_src7();
|
|
86617
86889
|
init_src();
|
|
86618
86890
|
import { execFile as execFile5 } from "node:child_process";
|
|
86619
|
-
import { readFileSync as
|
|
86891
|
+
import { readFileSync as readFileSync35 } from "node:fs";
|
|
86620
86892
|
import { join as join39 } from "node:path";
|
|
86621
86893
|
import { promisify as promisify3 } from "node:util";
|
|
86622
86894
|
|
|
@@ -87017,8 +87289,8 @@ var GitBlobReader = class {
|
|
|
87017
87289
|
if (this.failed) return Promise.reject(this.failed);
|
|
87018
87290
|
if (/[\r\n]/.test(spec)) return Promise.resolve(null);
|
|
87019
87291
|
const proc = this.start();
|
|
87020
|
-
return new Promise((
|
|
87021
|
-
this.queue.push({ resolve:
|
|
87292
|
+
return new Promise((resolve9, reject) => {
|
|
87293
|
+
this.queue.push({ resolve: resolve9, reject });
|
|
87022
87294
|
proc.stdin.write(`${spec}
|
|
87023
87295
|
`);
|
|
87024
87296
|
});
|
|
@@ -87032,14 +87304,14 @@ var GitBlobReader = class {
|
|
|
87032
87304
|
const proc = this.proc;
|
|
87033
87305
|
this.proc = null;
|
|
87034
87306
|
if (!proc || proc.exitCode !== null) return Promise.resolve();
|
|
87035
|
-
return new Promise((
|
|
87307
|
+
return new Promise((resolve9) => {
|
|
87036
87308
|
const timer = setTimeout(() => {
|
|
87037
87309
|
proc.kill();
|
|
87038
|
-
|
|
87310
|
+
resolve9();
|
|
87039
87311
|
}, timeoutMs);
|
|
87040
87312
|
proc.once("exit", () => {
|
|
87041
87313
|
clearTimeout(timer);
|
|
87042
|
-
|
|
87314
|
+
resolve9();
|
|
87043
87315
|
});
|
|
87044
87316
|
proc.stdin.end();
|
|
87045
87317
|
});
|
|
@@ -87164,7 +87436,7 @@ async function defaultGit(root, args2) {
|
|
|
87164
87436
|
function readIgnoreLines(root, profile) {
|
|
87165
87437
|
let lines = [];
|
|
87166
87438
|
try {
|
|
87167
|
-
lines =
|
|
87439
|
+
lines = readFileSync35(join39(root, ".errataignore"), "utf8").split("\n");
|
|
87168
87440
|
} catch {
|
|
87169
87441
|
}
|
|
87170
87442
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -87629,7 +87901,7 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
87629
87901
|
init_cloud_auth();
|
|
87630
87902
|
import { createHash as createHash19 } from "node:crypto";
|
|
87631
87903
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
87632
|
-
import { existsSync as
|
|
87904
|
+
import { existsSync as existsSync32, writeFileSync as writeFileSync25 } from "node:fs";
|
|
87633
87905
|
import { join as join40 } from "node:path";
|
|
87634
87906
|
|
|
87635
87907
|
// src/device-poll.ts
|
|
@@ -87719,7 +87991,7 @@ async function loginOAuthDevice(opts) {
|
|
|
87719
87991
|
let deviceSession = null;
|
|
87720
87992
|
let approvedInstallation = null;
|
|
87721
87993
|
while (Date.now() < deadline) {
|
|
87722
|
-
await (opts.sleep ?? ((ms) => new Promise((
|
|
87994
|
+
await (opts.sleep ?? ((ms) => new Promise((resolve9) => setTimeout(resolve9, ms))))(waitMs);
|
|
87723
87995
|
waitMs = intervalMs;
|
|
87724
87996
|
const poll = await fetchDevicePoll(fetchFn, device.token, {
|
|
87725
87997
|
method: "POST",
|
|
@@ -87844,7 +88116,7 @@ async function loginOAuthLoopback(opts) {
|
|
|
87844
88116
|
const state = randomState();
|
|
87845
88117
|
const scope = opts.scope ?? DEFAULT_OAUTH_SCOPE;
|
|
87846
88118
|
const { code, redirectUri, clientId } = await new Promise(
|
|
87847
|
-
(
|
|
88119
|
+
(resolve9, reject) => {
|
|
87848
88120
|
const server = createServer((req, res) => {
|
|
87849
88121
|
const u = new URL(req.url ?? "/", "http://127.0.0.1");
|
|
87850
88122
|
if (u.pathname !== "/callback") {
|
|
@@ -87867,7 +88139,7 @@ async function loginOAuthLoopback(opts) {
|
|
|
87867
88139
|
res.writeHead(200, { "content-type": "text/html" });
|
|
87868
88140
|
res.end("<html><body>inErrata: you're logged in. You can close this tab.</body></html>");
|
|
87869
88141
|
server.close();
|
|
87870
|
-
|
|
88142
|
+
resolve9({ code: code2, redirectUri: `http://127.0.0.1:${port}/callback`, clientId: activeClientId });
|
|
87871
88143
|
});
|
|
87872
88144
|
let activeClientId = oauthClientId();
|
|
87873
88145
|
server.on("error", reject);
|
|
@@ -87966,7 +88238,7 @@ async function linkThroughConsole(opts) {
|
|
|
87966
88238
|
const deadline = Date.now() + Math.min(code.expires_in * 1e3, opts.timeoutMs ?? Number.POSITIVE_INFINITY);
|
|
87967
88239
|
let intervalMs = Math.max(2, code.interval ?? 5) * 1e3;
|
|
87968
88240
|
let waitMs = intervalMs;
|
|
87969
|
-
const sleep = opts.sleep ?? ((ms) => new Promise((
|
|
88241
|
+
const sleep = opts.sleep ?? ((ms) => new Promise((resolve9) => setTimeout(resolve9, ms)));
|
|
87970
88242
|
while (Date.now() < deadline) {
|
|
87971
88243
|
await sleep(waitMs);
|
|
87972
88244
|
waitMs = intervalMs;
|
|
@@ -88089,8 +88361,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
|
|
|
88089
88361
|
let wroteIgnore = false;
|
|
88090
88362
|
if (decision.writeIgnoreStarter !== false) {
|
|
88091
88363
|
const target = join40(root, ".errataignore");
|
|
88092
|
-
if (!
|
|
88093
|
-
|
|
88364
|
+
if (!existsSync32(target)) {
|
|
88365
|
+
writeFileSync25(target, IGNORE_STARTER, "utf8");
|
|
88094
88366
|
wroteIgnore = true;
|
|
88095
88367
|
}
|
|
88096
88368
|
}
|
|
@@ -88103,12 +88375,12 @@ init_registry();
|
|
|
88103
88375
|
|
|
88104
88376
|
// src/adopt.ts
|
|
88105
88377
|
init_git_remote();
|
|
88106
|
-
import { existsSync as
|
|
88378
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
88107
88379
|
import { dirname as dirname12, join as join41 } from "node:path";
|
|
88108
88380
|
function findGitRoot(absPath) {
|
|
88109
88381
|
let dir = absPath;
|
|
88110
88382
|
for (let depth = 0; depth < 64; depth++) {
|
|
88111
|
-
if (
|
|
88383
|
+
if (existsSync33(join41(dir, ".git"))) return dir;
|
|
88112
88384
|
const parent = dirname12(dir);
|
|
88113
88385
|
if (parent === dir) return null;
|
|
88114
88386
|
dir = parent;
|
|
@@ -88738,6 +89010,9 @@ async function startMultiDaemon(opts = {}) {
|
|
|
88738
89010
|
onSubagentSpawn: engine.webHooks.onSubagentSpawn,
|
|
88739
89011
|
subagentContext: engine.webHooks.subagentContext,
|
|
88740
89012
|
onSubagentStop: engine.webHooks.onSubagentStop,
|
|
89013
|
+
// CAP-session-scope: per-session blocks + harness/fixture quarantine.
|
|
89014
|
+
noteSession: engine.webHooks.noteSession,
|
|
89015
|
+
sessionContext: engine.webHooks.sessionContext,
|
|
88741
89016
|
onHook: engine.webHooks.onHook,
|
|
88742
89017
|
onHookEvent: engine.webHooks.onHookEvent,
|
|
88743
89018
|
onShellEvent: engine.webHooks.onShellEvent,
|
|
@@ -88805,7 +89080,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
88805
89080
|
records.push(rec);
|
|
88806
89081
|
void ambientLinkAll();
|
|
88807
89082
|
try {
|
|
88808
|
-
|
|
89083
|
+
writeFileSync26(
|
|
88809
89084
|
rec.engine.paths.daemonLock,
|
|
88810
89085
|
daemonLockPayload({
|
|
88811
89086
|
pid: process.pid,
|
|
@@ -89012,7 +89287,12 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89012
89287
|
return await owner.webApp.fetch(
|
|
89013
89288
|
new Request(`http://local${sub}`, {
|
|
89014
89289
|
method: "POST",
|
|
89015
|
-
|
|
89290
|
+
// The origin header (harness/fixture quarantine, session-registry.ts)
|
|
89291
|
+
// is the one caller header the sub-app needs; nothing else crosses.
|
|
89292
|
+
headers: {
|
|
89293
|
+
"content-type": "application/json",
|
|
89294
|
+
...c.req.header(ORIGIN_HEADER) ? { [ORIGIN_HEADER]: c.req.header(ORIGIN_HEADER) } : {}
|
|
89295
|
+
},
|
|
89016
89296
|
body: raw2
|
|
89017
89297
|
})
|
|
89018
89298
|
);
|
|
@@ -89104,7 +89384,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89104
89384
|
lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
|
|
89105
89385
|
} catch {
|
|
89106
89386
|
}
|
|
89107
|
-
const reason = retireDecision({ exists:
|
|
89387
|
+
const reason = retireDecision({ exists: existsSync34(rec.root), lastActiveAt, now });
|
|
89108
89388
|
if (reason) void retireWorkspace(rec, reason);
|
|
89109
89389
|
}
|
|
89110
89390
|
};
|
|
@@ -89175,7 +89455,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89175
89455
|
baseUrl = `http://127.0.0.1:${port}`;
|
|
89176
89456
|
try {
|
|
89177
89457
|
ensureDir(globalDir());
|
|
89178
|
-
|
|
89458
|
+
writeFileSync26(
|
|
89179
89459
|
lockPath,
|
|
89180
89460
|
daemonLockPayload({ pid: process.pid, webUiUrl: baseUrl, processStartedAt: PROCESS_STARTED_AT, entry: SELF_ENTRY, version: DAEMON_VERSION }),
|
|
89181
89461
|
"utf8"
|
|
@@ -89184,7 +89464,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89184
89464
|
}
|
|
89185
89465
|
for (const r of records) {
|
|
89186
89466
|
try {
|
|
89187
|
-
|
|
89467
|
+
writeFileSync26(
|
|
89188
89468
|
r.engine.paths.daemonLock,
|
|
89189
89469
|
daemonLockPayload({
|
|
89190
89470
|
pid: process.pid,
|
|
@@ -89418,7 +89698,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89418
89698
|
const packageAutoAll = async () => {
|
|
89419
89699
|
const out2 = /* @__PURE__ */ new Map();
|
|
89420
89700
|
for (const r of records) {
|
|
89421
|
-
await new Promise((
|
|
89701
|
+
await new Promise((resolve9) => setImmediate(resolve9));
|
|
89422
89702
|
const done = markPass(`package-index:${r.entry.name}`);
|
|
89423
89703
|
try {
|
|
89424
89704
|
out2.set(
|
|
@@ -89727,7 +90007,9 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89727
90007
|
done();
|
|
89728
90008
|
}
|
|
89729
90009
|
};
|
|
89730
|
-
const buildInstanceBatch = async (r,
|
|
90010
|
+
const buildInstanceBatch = async (r, laneInput) => {
|
|
90011
|
+
const quarantinedSessions = r.engine.quarantinedSessions();
|
|
90012
|
+
const input = quarantinedSessions.length ? { ...laneInput, quarantinedSessions } : laneInput;
|
|
89731
90013
|
const w = workerFor(r);
|
|
89732
90014
|
if (w) {
|
|
89733
90015
|
try {
|
|
@@ -89762,6 +90044,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89762
90044
|
for (const r of records) {
|
|
89763
90045
|
const recordConsent = effectiveConsent(cfg2, r.engine.profile);
|
|
89764
90046
|
if (!recordConsent.sync) continue;
|
|
90047
|
+
if (!shipsFromWorkspace(r.root)) continue;
|
|
89765
90048
|
const recordIdentity = identityFor(liveWorkspaceEntry(r.entry));
|
|
89766
90049
|
if (recordIdentity.invalid) {
|
|
89767
90050
|
noteIdentityBlock(r.id, r.entry.name, recordIdentity);
|
|
@@ -90156,7 +90439,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
90156
90439
|
clearInterval(anchorPull);
|
|
90157
90440
|
clearTimeout(codexWakeBoot);
|
|
90158
90441
|
try {
|
|
90159
|
-
const cur =
|
|
90442
|
+
const cur = readFileSync36(lockPath, "utf8");
|
|
90160
90443
|
if (JSON.parse(cur).pid === process.pid) unlinkSync5(lockPath);
|
|
90161
90444
|
} catch {
|
|
90162
90445
|
}
|
|
@@ -90717,23 +91000,25 @@ async function diagnoseInstallation(cfg, dependencies) {
|
|
|
90717
91000
|
|
|
90718
91001
|
// src/codex-doctor.ts
|
|
90719
91002
|
import { spawn as spawn4 } from "node:child_process";
|
|
90720
|
-
import { readFileSync as
|
|
91003
|
+
import { readFileSync as readFileSync38, statSync as statSync10 } from "node:fs";
|
|
90721
91004
|
import { join as join44 } from "node:path";
|
|
90722
91005
|
import { createInterface } from "node:readline";
|
|
90723
91006
|
|
|
90724
91007
|
// src/codex-hooks.ts
|
|
90725
|
-
import { existsSync as
|
|
91008
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync9, readFileSync as readFileSync37, renameSync as renameSync5, unlinkSync as unlinkSync6, writeFileSync as writeFileSync27 } from "node:fs";
|
|
90726
91009
|
import { homedir as homedir7 } from "node:os";
|
|
90727
91010
|
import { join as join43 } from "node:path";
|
|
90728
91011
|
|
|
90729
91012
|
// src/hook-commands.ts
|
|
90730
91013
|
function hookCurlCommand(port, path2 = "/api/hook") {
|
|
90731
91014
|
const url2 = `http://127.0.0.1:${port}${path2}`;
|
|
90732
|
-
return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 3 -X POST
|
|
91015
|
+
return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 3 -X POST ${HEADERS_WIN} --data-binary @- ${url2} >NUL 2>NUL || exit /b 0"` : `curl -s --connect-timeout 1 --max-time 3 -X POST -H 'Content-Type: application/json' ${ORIGIN_HEADER_POSIX} --data-binary @- ${url2} >/dev/null 2>&1 || true`;
|
|
90733
91016
|
}
|
|
91017
|
+
var HEADERS_WIN = `-H Content-Type:application/json -H x-errata-origin:%ERRATA_ORIGIN%`;
|
|
91018
|
+
var ORIGIN_HEADER_POSIX = `-H "x-errata-origin: \${ERRATA_ORIGIN:-}"`;
|
|
90734
91019
|
function hookRelayCommand(port, path2) {
|
|
90735
91020
|
const url2 = `http://127.0.0.1:${port}${path2}`;
|
|
90736
|
-
return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 2 -X POST
|
|
91021
|
+
return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 2 -X POST ${HEADERS_WIN} --data-binary @- ${url2} 2>NUL || echo {}"` : `curl -s --connect-timeout 1 --max-time 2 -X POST -H 'Content-Type: application/json' ${ORIGIN_HEADER_POSIX} --data-binary @- ${url2} 2>/dev/null || echo '{}'`;
|
|
90737
91022
|
}
|
|
90738
91023
|
var CODEX_HOOKS_BEGIN = `# >>> errata hooks (errata-managed)`;
|
|
90739
91024
|
var CODEX_HOOKS_END = `# <<< errata hooks`;
|
|
@@ -90870,23 +91155,23 @@ function buildCodexRelaySource(workspaceRoot) {
|
|
|
90870
91155
|
init_checkout_root();
|
|
90871
91156
|
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.";
|
|
90872
91157
|
function writeRelay(file2, source) {
|
|
90873
|
-
if (
|
|
91158
|
+
if (existsSync35(file2) && readFileSync37(file2, "utf8") === source) return;
|
|
90874
91159
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
90875
91160
|
try {
|
|
90876
|
-
|
|
91161
|
+
writeFileSync27(temp, source, { encoding: "utf8", mode: 384 });
|
|
90877
91162
|
renameSync5(temp, file2);
|
|
90878
91163
|
} finally {
|
|
90879
|
-
if (
|
|
91164
|
+
if (existsSync35(temp)) unlinkSync6(temp);
|
|
90880
91165
|
}
|
|
90881
91166
|
}
|
|
90882
91167
|
function refreshCodexRelay(root) {
|
|
90883
91168
|
const config2 = join43(root, ".codex", "config.toml");
|
|
90884
|
-
if (!
|
|
90885
|
-
const existing =
|
|
91169
|
+
if (!existsSync35(config2)) return "absent";
|
|
91170
|
+
const existing = readFileSync37(config2, "utf8");
|
|
90886
91171
|
if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
|
|
90887
91172
|
replaceCodexHooks(existing, "");
|
|
90888
91173
|
const relay = join43(root, ".codex", "hooks", "errata-relay.mjs");
|
|
90889
|
-
const prior =
|
|
91174
|
+
const prior = existsSync35(relay) ? readFileSync37(relay, "utf8") : "";
|
|
90890
91175
|
if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
|
|
90891
91176
|
throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
|
|
90892
91177
|
}
|
|
@@ -90897,7 +91182,7 @@ function refreshCodexRelay(root) {
|
|
|
90897
91182
|
return "updated";
|
|
90898
91183
|
}
|
|
90899
91184
|
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join43(homedir7(), ".codex")) {
|
|
90900
|
-
return
|
|
91185
|
+
return existsSync35(join43(root, ".codex")) || existsSync35(codexHome);
|
|
90901
91186
|
}
|
|
90902
91187
|
function replaceCodexHooks(existing, block) {
|
|
90903
91188
|
const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
|
|
@@ -90917,10 +91202,10 @@ function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
|
90917
91202
|
const file2 = join43(dir, "config.toml");
|
|
90918
91203
|
const relay = join43(dir, "hooks", "errata-relay.mjs");
|
|
90919
91204
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
90920
|
-
const final = replaceCodexHooks(
|
|
91205
|
+
const final = replaceCodexHooks(existsSync35(file2) ? readFileSync37(file2, "utf8") : "", block);
|
|
90921
91206
|
mkdirSync9(join43(dir, "hooks"), { recursive: true });
|
|
90922
91207
|
writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
|
|
90923
|
-
if (!
|
|
91208
|
+
if (!existsSync35(file2) || readFileSync37(file2, "utf8") !== final) writeFileSync27(file2, final, "utf8");
|
|
90924
91209
|
return file2;
|
|
90925
91210
|
}
|
|
90926
91211
|
|
|
@@ -90929,7 +91214,7 @@ init_checkout_root();
|
|
|
90929
91214
|
function inspectCodexRelay(cwd) {
|
|
90930
91215
|
const root = nearestGitRoot(cwd) ?? cwd;
|
|
90931
91216
|
try {
|
|
90932
|
-
const source =
|
|
91217
|
+
const source = readFileSync38(join44(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
|
|
90933
91218
|
if (source === buildCodexRelaySource(checkoutRootOf(root))) {
|
|
90934
91219
|
return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
|
|
90935
91220
|
}
|
|
@@ -90941,7 +91226,7 @@ function inspectCodexContext(cwd) {
|
|
|
90941
91226
|
const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
|
|
90942
91227
|
try {
|
|
90943
91228
|
const file2 = join44(root, ".errata", "context.md");
|
|
90944
|
-
if (statSync10(file2).size <= 128 * 1024 &&
|
|
91229
|
+
if (statSync10(file2).size <= 128 * 1024 && readFileSync38(file2, "utf8").trim()) {
|
|
90945
91230
|
return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
|
|
90946
91231
|
}
|
|
90947
91232
|
} catch {
|
|
@@ -90949,7 +91234,7 @@ function inspectCodexContext(cwd) {
|
|
|
90949
91234
|
return { id: "codex_context", status: "fail", detail: "No usable saved workspace context; run errata start here and check the daemon log if context.md remains unavailable" };
|
|
90950
91235
|
}
|
|
90951
91236
|
function readCodexHookState(cwd, options = {}) {
|
|
90952
|
-
return new Promise((
|
|
91237
|
+
return new Promise((resolve9, reject) => {
|
|
90953
91238
|
const child = spawn4(options.bin ?? resolveCodexExecutable(), options.args ?? ["app-server", "--stdio"], {
|
|
90954
91239
|
cwd,
|
|
90955
91240
|
windowsHide: true,
|
|
@@ -90970,7 +91255,7 @@ function readCodexHookState(cwd, options = {}) {
|
|
|
90970
91255
|
child.once("close", () => {
|
|
90971
91256
|
clearTimeout(reap);
|
|
90972
91257
|
if (error48) reject(error48);
|
|
90973
|
-
else
|
|
91258
|
+
else resolve9({ ...hooks, features });
|
|
90974
91259
|
});
|
|
90975
91260
|
child.kill();
|
|
90976
91261
|
};
|
|
@@ -91117,16 +91402,16 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
91117
91402
|
|
|
91118
91403
|
// src/codex-hook-refresh.ts
|
|
91119
91404
|
init_checkout_root();
|
|
91120
|
-
import { existsSync as
|
|
91121
|
-
import { dirname as dirname13, join as join45, resolve as
|
|
91405
|
+
import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as readFileSync39 } from "node:fs";
|
|
91406
|
+
import { dirname as dirname13, join as join45, resolve as resolve8 } from "node:path";
|
|
91122
91407
|
init_registry();
|
|
91123
91408
|
function codexHookRoots(roots) {
|
|
91124
|
-
const found = new Set(roots.map((root) =>
|
|
91409
|
+
const found = new Set(roots.map((root) => resolve8(root)));
|
|
91125
91410
|
for (const root of [...found]) {
|
|
91126
91411
|
const main2 = mainCheckoutOfWorktree(root) ?? root;
|
|
91127
91412
|
found.add(main2);
|
|
91128
91413
|
const dir = join45(main2, ".git", "worktrees");
|
|
91129
|
-
if (!
|
|
91414
|
+
if (!existsSync36(dir)) continue;
|
|
91130
91415
|
let names;
|
|
91131
91416
|
try {
|
|
91132
91417
|
names = readdirSync13(dir);
|
|
@@ -91135,7 +91420,7 @@ function codexHookRoots(roots) {
|
|
|
91135
91420
|
}
|
|
91136
91421
|
for (const name2 of names) {
|
|
91137
91422
|
try {
|
|
91138
|
-
const checkout = dirname13(
|
|
91423
|
+
const checkout = dirname13(readFileSync39(join45(dir, name2, "gitdir"), "utf8").trim());
|
|
91139
91424
|
if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
|
|
91140
91425
|
} catch {
|
|
91141
91426
|
}
|
|
@@ -91157,7 +91442,7 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
|
|
|
91157
91442
|
}
|
|
91158
91443
|
|
|
91159
91444
|
// src/claude-statusline.ts
|
|
91160
|
-
import { existsSync as
|
|
91445
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync10, readFileSync as readFileSync40, writeFileSync as writeFileSync28 } from "node:fs";
|
|
91161
91446
|
import { homedir as homedir8 } from "node:os";
|
|
91162
91447
|
import { dirname as dirname14, join as join46 } from "node:path";
|
|
91163
91448
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
@@ -91212,9 +91497,9 @@ function ensureUserStatusLine(opts) {
|
|
|
91212
91497
|
if (off === "0" || off === "off" || off === "false" || off === "no") return "disabled";
|
|
91213
91498
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
91214
91499
|
let settings = {};
|
|
91215
|
-
if (
|
|
91500
|
+
if (existsSync37(settingsPath)) {
|
|
91216
91501
|
try {
|
|
91217
|
-
const parsed = JSON.parse(
|
|
91502
|
+
const parsed = JSON.parse(readFileSync40(settingsPath, "utf8"));
|
|
91218
91503
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
91219
91504
|
settings = parsed;
|
|
91220
91505
|
} catch {
|
|
@@ -91226,8 +91511,8 @@ function ensureUserStatusLine(opts) {
|
|
|
91226
91511
|
if (ownMain && ownRows) return "kept-own";
|
|
91227
91512
|
const relay = join46(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
91228
91513
|
mkdirSync10(opts.relayDir, { recursive: true });
|
|
91229
|
-
if (!
|
|
91230
|
-
|
|
91514
|
+
if (!existsSync37(relay) || readFileSync40(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
91515
|
+
writeFileSync28(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
91231
91516
|
}
|
|
91232
91517
|
const nodePath = opts.nodePath ?? process.execPath;
|
|
91233
91518
|
const next = {
|
|
@@ -91239,7 +91524,7 @@ function ensureUserStatusLine(opts) {
|
|
|
91239
91524
|
}
|
|
91240
91525
|
Object.assign(settings, next);
|
|
91241
91526
|
mkdirSync10(dirname14(settingsPath), { recursive: true });
|
|
91242
|
-
|
|
91527
|
+
writeFileSync28(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
91243
91528
|
return "installed";
|
|
91244
91529
|
}
|
|
91245
91530
|
function describeStatusLineOutcome(outcome) {
|
|
@@ -91662,14 +91947,14 @@ async function cmdInit() {
|
|
|
91662
91947
|
if (!skipHooks) {
|
|
91663
91948
|
console.log("");
|
|
91664
91949
|
console.log("installing harness hooks...");
|
|
91665
|
-
const { existsSync:
|
|
91950
|
+
const { existsSync: existsSync39 } = await import("node:fs");
|
|
91666
91951
|
const { join: join48 } = await import("node:path");
|
|
91667
91952
|
try {
|
|
91668
91953
|
await installClaudeHooks(port);
|
|
91669
91954
|
} catch (err2) {
|
|
91670
91955
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
91671
91956
|
}
|
|
91672
|
-
if (
|
|
91957
|
+
if (existsSync39(join48(ROOT, ".cursor"))) {
|
|
91673
91958
|
try {
|
|
91674
91959
|
await installCursorMcpConfig();
|
|
91675
91960
|
} catch (err2) {
|
|
@@ -91863,9 +92148,9 @@ async function cmdStatus() {
|
|
|
91863
92148
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
91864
92149
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
91865
92150
|
}
|
|
91866
|
-
console.log(` graph db: ${
|
|
91867
|
-
console.log(` event log: ${
|
|
91868
|
-
if (
|
|
92151
|
+
console.log(` graph db: ${existsSync38(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
92152
|
+
console.log(` event log: ${existsSync38(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
92153
|
+
if (existsSync38(paths.castalia)) {
|
|
91869
92154
|
try {
|
|
91870
92155
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
91871
92156
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -92836,11 +93121,11 @@ async function cmdInstallationProfile(args2) {
|
|
|
92836
93121
|
}
|
|
92837
93122
|
async function cmdReview() {
|
|
92838
93123
|
const paths = workspacePaths(ROOT);
|
|
92839
|
-
if (!
|
|
93124
|
+
if (!existsSync38(paths.reviewQueue)) {
|
|
92840
93125
|
console.log("(review queue empty)");
|
|
92841
93126
|
return;
|
|
92842
93127
|
}
|
|
92843
|
-
const queue = JSON.parse(
|
|
93128
|
+
const queue = JSON.parse(readFileSync41(paths.reviewQueue, "utf8"));
|
|
92844
93129
|
if (queue.length === 0) {
|
|
92845
93130
|
console.log("(review queue empty)");
|
|
92846
93131
|
return;
|
|
@@ -93511,7 +93796,7 @@ async function gatherRepo(store, ws) {
|
|
|
93511
93796
|
};
|
|
93512
93797
|
}
|
|
93513
93798
|
async function gatherReportData(generatedAt) {
|
|
93514
|
-
const { existsSync:
|
|
93799
|
+
const { existsSync: existsSync39 } = await import("node:fs");
|
|
93515
93800
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
93516
93801
|
const cfg = loadConfig();
|
|
93517
93802
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -93519,7 +93804,7 @@ async function gatherReportData(generatedAt) {
|
|
|
93519
93804
|
for (const ws of listWorkspaces()) {
|
|
93520
93805
|
if (ws.missing) continue;
|
|
93521
93806
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
93522
|
-
if (!
|
|
93807
|
+
if (!existsSync39(dbPath)) continue;
|
|
93523
93808
|
let store = null;
|
|
93524
93809
|
try {
|
|
93525
93810
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -93550,7 +93835,7 @@ async function gatherReportData(generatedAt) {
|
|
|
93550
93835
|
};
|
|
93551
93836
|
}
|
|
93552
93837
|
async function cmdReport(args2) {
|
|
93553
|
-
const { mkdirSync: mkdirSync11, writeFileSync:
|
|
93838
|
+
const { mkdirSync: mkdirSync11, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
93554
93839
|
const { renderReport: renderReport2 } = await Promise.resolve().then(() => (init_report_render(), report_render_exports));
|
|
93555
93840
|
const includeFutureVerbs = args2.includes("--future-verbs");
|
|
93556
93841
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -93563,7 +93848,7 @@ async function cmdReport(args2) {
|
|
|
93563
93848
|
const outDir = workspacePaths(ROOT).configDir;
|
|
93564
93849
|
mkdirSync11(outDir, { recursive: true });
|
|
93565
93850
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
93566
|
-
for (const f of files)
|
|
93851
|
+
for (const f of files) writeFileSync29(join47(outDir, f.name), f.html, "utf8");
|
|
93567
93852
|
const indexPath = join47(outDir, "report.html");
|
|
93568
93853
|
console.log(`report \u2192 ${indexPath}`);
|
|
93569
93854
|
console.log(
|
|
@@ -93677,24 +93962,24 @@ async function cmdInstallHooks(args2) {
|
|
|
93677
93962
|
}
|
|
93678
93963
|
}
|
|
93679
93964
|
async function installOpencodePlugin(port) {
|
|
93680
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
93965
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync39, readFileSync: readFileSync42, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
93681
93966
|
const { join: join48 } = await import("node:path");
|
|
93682
93967
|
const dir = join48(ROOT, ".opencode", "plugin");
|
|
93683
|
-
if (!
|
|
93968
|
+
if (!existsSync39(dir)) mkdirSync11(dir, { recursive: true });
|
|
93684
93969
|
const file2 = join48(dir, "inerrata.js");
|
|
93685
|
-
if (
|
|
93686
|
-
const head2 =
|
|
93970
|
+
if (existsSync39(file2)) {
|
|
93971
|
+
const head2 = readFileSync42(file2, "utf8").split("\n")[0] ?? "";
|
|
93687
93972
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
93688
93973
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
93689
93974
|
process.exit(2);
|
|
93690
93975
|
}
|
|
93691
93976
|
}
|
|
93692
|
-
|
|
93977
|
+
writeFileSync29(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
93693
93978
|
const cfgFile = join48(ROOT, "opencode.json");
|
|
93694
93979
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
93695
|
-
if (
|
|
93980
|
+
if (existsSync39(cfgFile)) {
|
|
93696
93981
|
try {
|
|
93697
|
-
cfg = JSON.parse(
|
|
93982
|
+
cfg = JSON.parse(readFileSync42(cfgFile, "utf8"));
|
|
93698
93983
|
} catch {
|
|
93699
93984
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
93700
93985
|
process.exit(2);
|
|
@@ -93705,7 +93990,7 @@ async function installOpencodePlugin(port) {
|
|
|
93705
93990
|
if (!hadErrata) {
|
|
93706
93991
|
const inv = errataMcpInvocation();
|
|
93707
93992
|
cfg.mcp["errata"] = { type: "local", command: [inv.command, ...inv.args] };
|
|
93708
|
-
|
|
93993
|
+
writeFileSync29(cfgFile, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
93709
93994
|
}
|
|
93710
93995
|
console.log(`installed OpenCode plugin \u2192 ${file2}`);
|
|
93711
93996
|
if (hadErrata) console.log(` mcp.errata already present in ${cfgFile} \u2014 left untouched`);
|
|
@@ -93732,15 +94017,15 @@ function ensureStatusLine(port) {
|
|
|
93732
94017
|
}
|
|
93733
94018
|
}
|
|
93734
94019
|
async function installClaudeHooks(port) {
|
|
93735
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
94020
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync39, readFileSync: readFileSync42, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
93736
94021
|
const { join: join48 } = await import("node:path");
|
|
93737
94022
|
const dir = join48(ROOT, ".claude");
|
|
93738
|
-
if (!
|
|
94023
|
+
if (!existsSync39(dir)) mkdirSync11(dir, { recursive: true });
|
|
93739
94024
|
const file2 = join48(dir, "settings.json");
|
|
93740
94025
|
let settings = {};
|
|
93741
|
-
if (
|
|
94026
|
+
if (existsSync39(file2)) {
|
|
93742
94027
|
try {
|
|
93743
|
-
settings = JSON.parse(
|
|
94028
|
+
settings = JSON.parse(readFileSync42(file2, "utf8"));
|
|
93744
94029
|
} catch {
|
|
93745
94030
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
93746
94031
|
process.exit(2);
|
|
@@ -93789,7 +94074,7 @@ async function installClaudeHooks(port) {
|
|
|
93789
94074
|
list.push({ hooks: [{ type: "command", command: injectCmd }] });
|
|
93790
94075
|
}
|
|
93791
94076
|
removeProjectStatusLine(settings);
|
|
93792
|
-
|
|
94077
|
+
writeFileSync29(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
93793
94078
|
console.log(`installed Claude Code hooks \u2192 ${file2}`);
|
|
93794
94079
|
console.log(` ${ensureStatusLine(port)}`);
|
|
93795
94080
|
await installClaudeMcpConfig();
|
|
@@ -93805,15 +94090,15 @@ async function installClaudeHooks(port) {
|
|
|
93805
94090
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
93806
94091
|
}
|
|
93807
94092
|
async function installClaudeMcpConfig() {
|
|
93808
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
94093
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync39, readFileSync: readFileSync42, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
93809
94094
|
const { join: join48, dirname: dirname15 } = await import("node:path");
|
|
93810
94095
|
const file2 = join48(ROOT, ".mcp.json");
|
|
93811
94096
|
const dir = dirname15(file2);
|
|
93812
|
-
if (!
|
|
94097
|
+
if (!existsSync39(dir)) mkdirSync11(dir, { recursive: true });
|
|
93813
94098
|
let cfg = {};
|
|
93814
|
-
if (
|
|
94099
|
+
if (existsSync39(file2)) {
|
|
93815
94100
|
try {
|
|
93816
|
-
cfg = JSON.parse(
|
|
94101
|
+
cfg = JSON.parse(readFileSync42(file2, "utf8"));
|
|
93817
94102
|
} catch {
|
|
93818
94103
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
93819
94104
|
process.exit(2);
|
|
@@ -93821,21 +94106,21 @@ async function installClaudeMcpConfig() {
|
|
|
93821
94106
|
}
|
|
93822
94107
|
cfg.mcpServers ??= {};
|
|
93823
94108
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
93824
|
-
|
|
94109
|
+
writeFileSync29(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
93825
94110
|
console.log(`installed Claude Code MCP server config \u2192 ${file2}`);
|
|
93826
94111
|
console.log(` Claude Code will spawn \`errata mcp\` on workspace open.`);
|
|
93827
94112
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
93828
94113
|
}
|
|
93829
94114
|
async function installCursorMcpConfig() {
|
|
93830
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
94115
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync39, readFileSync: readFileSync42, writeFileSync: writeFileSync29 } = await import("node:fs");
|
|
93831
94116
|
const { join: join48 } = await import("node:path");
|
|
93832
94117
|
const dir = join48(ROOT, ".cursor");
|
|
93833
|
-
if (!
|
|
94118
|
+
if (!existsSync39(dir)) mkdirSync11(dir, { recursive: true });
|
|
93834
94119
|
const file2 = join48(dir, "mcp.json");
|
|
93835
94120
|
let cfg = {};
|
|
93836
|
-
if (
|
|
94121
|
+
if (existsSync39(file2)) {
|
|
93837
94122
|
try {
|
|
93838
|
-
cfg = JSON.parse(
|
|
94123
|
+
cfg = JSON.parse(readFileSync42(file2, "utf8"));
|
|
93839
94124
|
} catch {
|
|
93840
94125
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
93841
94126
|
process.exit(2);
|
|
@@ -93843,7 +94128,7 @@ async function installCursorMcpConfig() {
|
|
|
93843
94128
|
}
|
|
93844
94129
|
cfg.mcpServers ??= {};
|
|
93845
94130
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
93846
|
-
|
|
94131
|
+
writeFileSync29(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
93847
94132
|
console.log(`installed Cursor MCP server config \u2192 ${file2}`);
|
|
93848
94133
|
console.log(` Cursor will spawn \`errata mcp\` on workspace open.`);
|
|
93849
94134
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses`);
|
|
@@ -94196,7 +94481,7 @@ async function cmdDash(args2) {
|
|
|
94196
94481
|
const hotspotScanMark = /* @__PURE__ */ new Map();
|
|
94197
94482
|
const HOTSPOT_FANIN = 20;
|
|
94198
94483
|
const runNightlyPass = async (dueIds) => {
|
|
94199
|
-
const yieldToLoop2 = () => new Promise((
|
|
94484
|
+
const yieldToLoop2 = () => new Promise((resolve9) => setImmediate(resolve9));
|
|
94200
94485
|
const fullReclusterPass = nightlyCount++ % FULL_RECLUSTER_EVERY === 0;
|
|
94201
94486
|
const m = dueIds ? await handle2.nightlyFor(dueIds) : await handle2.nightlyAll();
|
|
94202
94487
|
let skillsLearned = 0;
|