@inerrata-corporation/errata 2.0.16-dev.3343 → 2.0.16-dev.3355
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/errata.mjs +436 -315
- package/package.json +1 -1
package/errata.mjs
CHANGED
|
@@ -16455,8 +16455,8 @@ function parsePackageLockJson(jsonText) {
|
|
|
16455
16455
|
}
|
|
16456
16456
|
const dependencies = [];
|
|
16457
16457
|
for (const [path2, meta3] of Object.entries(packages)) {
|
|
16458
|
-
const
|
|
16459
|
-
if (!
|
|
16458
|
+
const self2 = byPath.get(path2);
|
|
16459
|
+
if (!self2) continue;
|
|
16460
16460
|
const deps = meta3.dependencies;
|
|
16461
16461
|
if (!deps || typeof deps !== "object") continue;
|
|
16462
16462
|
const dependsOn = [];
|
|
@@ -16465,7 +16465,7 @@ function parsePackageLockJson(jsonText) {
|
|
|
16465
16465
|
if (target) dependsOn.push(npmPurl(depName, target.version));
|
|
16466
16466
|
}
|
|
16467
16467
|
if (dependsOn.length > 0)
|
|
16468
|
-
dependencies.push({ ref: npmPurl(
|
|
16468
|
+
dependencies.push({ ref: npmPurl(self2.name, self2.version), dependsOn });
|
|
16469
16469
|
}
|
|
16470
16470
|
const directRaw = [];
|
|
16471
16471
|
for (const [path2, meta3] of Object.entries(packages)) {
|
|
@@ -16936,9 +16936,9 @@ function pomSelf(text) {
|
|
|
16936
16936
|
const group = (/<groupId>([^<]+)<\/groupId>/.exec(own)?.[1] ?? parentGroup)?.trim();
|
|
16937
16937
|
const artifact = /<artifactId>([^<]+)<\/artifactId>/.exec(own)?.[1]?.trim();
|
|
16938
16938
|
if (!group) return [];
|
|
16939
|
-
const
|
|
16940
|
-
if (artifact)
|
|
16941
|
-
return
|
|
16939
|
+
const self2 = [{ ecosystem: "maven", kind: "namespace", value: group }];
|
|
16940
|
+
if (artifact) self2.push({ ecosystem: "maven", kind: "name", value: mavenName(group, artifact) });
|
|
16941
|
+
return self2;
|
|
16942
16942
|
}
|
|
16943
16943
|
function parseManifestSelf(path2, text) {
|
|
16944
16944
|
const file2 = basename(path2);
|
|
@@ -16951,10 +16951,10 @@ function parseManifestSelf(path2, text) {
|
|
|
16951
16951
|
}
|
|
16952
16952
|
const name2 = obj && typeof obj === "object" ? obj["name"] : null;
|
|
16953
16953
|
if (typeof name2 !== "string" || !name2.trim()) return [];
|
|
16954
|
-
const
|
|
16954
|
+
const self2 = [{ ecosystem: "npm", kind: "name", value: name2.trim() }];
|
|
16955
16955
|
const scope = /^(@[^/]+)\//.exec(name2.trim())?.[1];
|
|
16956
|
-
if (scope)
|
|
16957
|
-
return
|
|
16956
|
+
if (scope) self2.push({ ecosystem: "npm", kind: "namespace", value: scope });
|
|
16957
|
+
return self2;
|
|
16958
16958
|
}
|
|
16959
16959
|
if (file2 === "pom.xml") return pomSelf(text);
|
|
16960
16960
|
if (file2 === "build.gradle" || file2 === "build.gradle.kts") {
|
|
@@ -25065,7 +25065,7 @@ function buildSnapshot(opts) {
|
|
|
25065
25065
|
const stillOpen = problems.filter((p) => p.attrs["resolvedAt"] == null);
|
|
25066
25066
|
const allProblems = stillOpen.filter((p) => !isConstraintProblem(p));
|
|
25067
25067
|
allProblems.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt);
|
|
25068
|
-
const
|
|
25068
|
+
const recent3 = allProblems.slice(0, 8).map((p) => ({
|
|
25069
25069
|
node: p,
|
|
25070
25070
|
anchors: opts.store.outEdges(p.id, ["MANIFESTED_IN", "EVIDENCED_BY"])
|
|
25071
25071
|
}));
|
|
@@ -25138,10 +25138,10 @@ function buildSnapshot(opts) {
|
|
|
25138
25138
|
packages: opts.profile.stack.map((name2) => ({ name: name2, node: matchNode(pkgNodes, pkgBase(name2)) })),
|
|
25139
25139
|
tools: toolNodes.map((node2) => ({ name: String(node2.attrs["name"] ?? node2.description), node: node2 }))
|
|
25140
25140
|
};
|
|
25141
|
-
const causalNudge =
|
|
25141
|
+
const causalNudge = recent3.length >= 2 && recent3.every(
|
|
25142
25142
|
(r) => opts.store.outEdges(r.node.id, ["CAUSED_BY"]).length === 0 && opts.store.inEdges(r.node.id, ["CAUSED_BY"]).length === 0
|
|
25143
25143
|
);
|
|
25144
|
-
const abstractUndomained =
|
|
25144
|
+
const abstractUndomained = recent3.filter((r) => {
|
|
25145
25145
|
const grounded = opts.store.outEdges(r.node.id, ["ANCHORED_AT", "OCCURS_IN", "DEPENDS_ON"]).length > 0;
|
|
25146
25146
|
const hasDomain = opts.store.outEdges(r.node.id, ["PERTAIN_TO"]).length > 0;
|
|
25147
25147
|
return !grounded && !hasDomain;
|
|
@@ -25150,7 +25150,7 @@ function buildSnapshot(opts) {
|
|
|
25150
25150
|
return {
|
|
25151
25151
|
profile: opts.profile,
|
|
25152
25152
|
profileContext,
|
|
25153
|
-
recentProblems:
|
|
25153
|
+
recentProblems: recent3,
|
|
25154
25154
|
recentResolved,
|
|
25155
25155
|
recentConstraints,
|
|
25156
25156
|
regressions,
|
|
@@ -32578,17 +32578,172 @@ var init_checkout_root = __esm({
|
|
|
32578
32578
|
}
|
|
32579
32579
|
});
|
|
32580
32580
|
|
|
32581
|
+
// src/process-identity.ts
|
|
32582
|
+
import { execFileSync } from "node:child_process";
|
|
32583
|
+
import { readFileSync as readFileSync10 } from "node:fs";
|
|
32584
|
+
function readProcessIdentity(pid, fresh = false) {
|
|
32585
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return null;
|
|
32586
|
+
if (pid === process.pid && self) return self;
|
|
32587
|
+
const cached2 = recent.get(pid);
|
|
32588
|
+
if (!fresh && cached2 && Date.now() - cached2.at < 1e3) return cached2.value;
|
|
32589
|
+
try {
|
|
32590
|
+
const run3 = (bin, args2) => execFileSync(bin, args2, {
|
|
32591
|
+
encoding: "utf8",
|
|
32592
|
+
windowsHide: true,
|
|
32593
|
+
timeout: 3e3,
|
|
32594
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
32595
|
+
env: { ...process.env, LC_ALL: "C", TZ: "UTC" }
|
|
32596
|
+
}).trim();
|
|
32597
|
+
let value;
|
|
32598
|
+
if (process.platform === "win32") {
|
|
32599
|
+
const ticks = run3("powershell.exe", [
|
|
32600
|
+
"-NoProfile",
|
|
32601
|
+
"-NonInteractive",
|
|
32602
|
+
"-Command",
|
|
32603
|
+
`(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToUniversalTime().Ticks`
|
|
32604
|
+
]);
|
|
32605
|
+
if (!/^\d+$/.test(ticks)) return null;
|
|
32606
|
+
value = { key: `win32:${ticks}`, bornAt: Number((BigInt(ticks) - 621355968000000000n) / 10000n) };
|
|
32607
|
+
} else if (process.platform === "linux") {
|
|
32608
|
+
const stat4 = readFileSync10(`/proc/${pid}/stat`, "utf8");
|
|
32609
|
+
const ticks = stat4.slice(stat4.lastIndexOf(")") + 2).split(" ")[19];
|
|
32610
|
+
const bootId = readFileSync10("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
32611
|
+
const boot = /^btime (\d+)$/m.exec(readFileSync10("/proc/stat", "utf8"))?.[1];
|
|
32612
|
+
const hz = Number(run3("getconf", ["CLK_TCK"]));
|
|
32613
|
+
if (!boot || !/^\d+$/.test(ticks) || !Number.isFinite(hz) || hz <= 0) return null;
|
|
32614
|
+
value = { key: `linux:${bootId}:${ticks}`, bornAt: Number(boot) * 1e3 + Number(ticks) * 1e3 / hz };
|
|
32615
|
+
} else if (process.platform === "darwin") {
|
|
32616
|
+
const start2 = run3("ps", ["-p", String(pid), "-o", "lstart="]);
|
|
32617
|
+
value = { key: `darwin:${start2}`, bornAt: Date.parse(`${start2} UTC`) };
|
|
32618
|
+
} else return null;
|
|
32619
|
+
if (!Number.isFinite(value.bornAt) || value.bornAt <= 0) return null;
|
|
32620
|
+
if (pid === process.pid) self = value;
|
|
32621
|
+
if (recent.size >= 64) recent.clear();
|
|
32622
|
+
recent.set(pid, { at: Date.now(), value });
|
|
32623
|
+
return value;
|
|
32624
|
+
} catch {
|
|
32625
|
+
return null;
|
|
32626
|
+
}
|
|
32627
|
+
}
|
|
32628
|
+
var recent, self;
|
|
32629
|
+
var init_process_identity = __esm({
|
|
32630
|
+
"src/process-identity.ts"() {
|
|
32631
|
+
"use strict";
|
|
32632
|
+
recent = /* @__PURE__ */ new Map();
|
|
32633
|
+
}
|
|
32634
|
+
});
|
|
32635
|
+
|
|
32636
|
+
// src/lock.ts
|
|
32637
|
+
import { existsSync as existsSync12, readFileSync as readFileSync11, unlinkSync } from "node:fs";
|
|
32638
|
+
function daemonLockPayload(lock) {
|
|
32639
|
+
return JSON.stringify({
|
|
32640
|
+
pid: lock.pid,
|
|
32641
|
+
webUiUrl: lock.webUiUrl,
|
|
32642
|
+
startedAt: lock.processStartedAt,
|
|
32643
|
+
...lock.pid === process.pid ? { processIdentity: readProcessIdentity(lock.pid)?.key } : {},
|
|
32644
|
+
...lock.wokeAt !== void 0 ? { wokeAt: lock.wokeAt } : {},
|
|
32645
|
+
...lock.entry ? { entry: lock.entry } : {},
|
|
32646
|
+
...lock.version ? { version: lock.version } : {}
|
|
32647
|
+
});
|
|
32648
|
+
}
|
|
32649
|
+
function isInstalledEntry(entry) {
|
|
32650
|
+
return /\/node_modules\/@inerrata-corporation\/errata\//.test(normEntry(entry) + "/");
|
|
32651
|
+
}
|
|
32652
|
+
function foreignDaemonNote(lock, selfEntry) {
|
|
32653
|
+
if (!lock.entry || normEntry(lock.entry) === normEntry(selfEntry)) return null;
|
|
32654
|
+
const runningInstalled = isInstalledEntry(lock.entry);
|
|
32655
|
+
const head2 = [
|
|
32656
|
+
`launched from ${runningInstalled ? "the installed package" : "a LOCAL BUILD"}, not this one${lock.version ? ` (it is ${lock.version})` : ""}:`,
|
|
32657
|
+
` running: ${lock.entry}`,
|
|
32658
|
+
` this: ${selfEntry}`
|
|
32659
|
+
];
|
|
32660
|
+
return runningInstalled ? [...head2, "this CLI is a different bundle from the daemon it is talking to \u2014 its view may not match what the daemon runs."] : [...head2, "`errata update` does not replace it. To move onto the installed package: errata stop, then errata dash."];
|
|
32661
|
+
}
|
|
32662
|
+
function isProcessAlive(pid) {
|
|
32663
|
+
if (!Number.isSafeInteger(pid) || pid <= 0) return false;
|
|
32664
|
+
try {
|
|
32665
|
+
process.kill(pid, 0);
|
|
32666
|
+
return true;
|
|
32667
|
+
} catch (err2) {
|
|
32668
|
+
return err2.code === "EPERM";
|
|
32669
|
+
}
|
|
32670
|
+
}
|
|
32671
|
+
function readDaemonLock(lockPath) {
|
|
32672
|
+
if (!existsSync12(lockPath)) return null;
|
|
32673
|
+
try {
|
|
32674
|
+
return parseDaemonLock(readFileSync11(lockPath, "utf8"));
|
|
32675
|
+
} catch {
|
|
32676
|
+
return null;
|
|
32677
|
+
}
|
|
32678
|
+
}
|
|
32679
|
+
function parseDaemonLock(raw2) {
|
|
32680
|
+
try {
|
|
32681
|
+
const lock = JSON.parse(raw2);
|
|
32682
|
+
return lock && Number.isSafeInteger(lock.pid) && lock.pid > 0 ? lock : null;
|
|
32683
|
+
} catch {
|
|
32684
|
+
return null;
|
|
32685
|
+
}
|
|
32686
|
+
}
|
|
32687
|
+
function daemonLockState(lock, fresh = false) {
|
|
32688
|
+
if (!lock || !isProcessAlive(lock.pid)) return "stale";
|
|
32689
|
+
const identity = readProcessIdentity(lock.pid, fresh);
|
|
32690
|
+
if (!identity) return "unknown";
|
|
32691
|
+
if (lock.processIdentity) return lock.processIdentity === identity.key ? "running" : "stale";
|
|
32692
|
+
if (!Number.isFinite(lock.startedAt) || lock.startedAt <= 0) return "unknown";
|
|
32693
|
+
return identity.bornAt <= lock.startedAt ? "running" : "stale";
|
|
32694
|
+
}
|
|
32695
|
+
function isDaemonAlive(lockPath) {
|
|
32696
|
+
return daemonLockState(readDaemonLock(lockPath)) === "running";
|
|
32697
|
+
}
|
|
32698
|
+
function daemonLockBlocksStartup(lockPath) {
|
|
32699
|
+
return daemonLockState(readDaemonLock(lockPath), true) !== "stale";
|
|
32700
|
+
}
|
|
32701
|
+
function stopLockedDaemon(lockPath) {
|
|
32702
|
+
let original;
|
|
32703
|
+
try {
|
|
32704
|
+
original = readFileSync11(lockPath, "utf8");
|
|
32705
|
+
} catch {
|
|
32706
|
+
return "missing";
|
|
32707
|
+
}
|
|
32708
|
+
const lock = parseDaemonLock(original);
|
|
32709
|
+
if (!lock) return "unknown";
|
|
32710
|
+
const state = daemonLockState(lock, true);
|
|
32711
|
+
try {
|
|
32712
|
+
if (readFileSync11(lockPath, "utf8") !== original) return "changed";
|
|
32713
|
+
} catch {
|
|
32714
|
+
return "changed";
|
|
32715
|
+
}
|
|
32716
|
+
if (state === "unknown") return "unknown";
|
|
32717
|
+
if (state === "stale") {
|
|
32718
|
+
unlinkSync(lockPath);
|
|
32719
|
+
return "stale";
|
|
32720
|
+
}
|
|
32721
|
+
process.kill(lock.pid, "SIGTERM");
|
|
32722
|
+
return "signaled";
|
|
32723
|
+
}
|
|
32724
|
+
var normEntry;
|
|
32725
|
+
var init_lock = __esm({
|
|
32726
|
+
"src/lock.ts"() {
|
|
32727
|
+
"use strict";
|
|
32728
|
+
init_process_identity();
|
|
32729
|
+
normEntry = (p) => {
|
|
32730
|
+
const s = p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
32731
|
+
return /^[A-Za-z]:\//.test(s) ? s.toLowerCase() : s;
|
|
32732
|
+
};
|
|
32733
|
+
}
|
|
32734
|
+
});
|
|
32735
|
+
|
|
32581
32736
|
// src/registry.ts
|
|
32582
|
-
import { existsSync as
|
|
32737
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, writeFileSync as writeFileSync9 } from "node:fs";
|
|
32583
32738
|
import { join as join11 } from "node:path";
|
|
32584
32739
|
function registryPath() {
|
|
32585
32740
|
return process.env["ERRATA_REGISTRY_PATH"] ?? join11(globalDir(), "workspaces.json");
|
|
32586
32741
|
}
|
|
32587
32742
|
function read() {
|
|
32588
32743
|
const p = registryPath();
|
|
32589
|
-
if (!
|
|
32744
|
+
if (!existsSync13(p)) return { version: 1, workspaces: {} };
|
|
32590
32745
|
try {
|
|
32591
|
-
const parsed = JSON.parse(
|
|
32746
|
+
const parsed = JSON.parse(readFileSync12(p, "utf8"));
|
|
32592
32747
|
return { version: 1, workspaces: parsed.workspaces ?? {} };
|
|
32593
32748
|
} catch {
|
|
32594
32749
|
return { version: 1, workspaces: {} };
|
|
@@ -32596,9 +32751,9 @@ function read() {
|
|
|
32596
32751
|
}
|
|
32597
32752
|
function registryCorrupt() {
|
|
32598
32753
|
const p = registryPath();
|
|
32599
|
-
if (!
|
|
32754
|
+
if (!existsSync13(p)) return false;
|
|
32600
32755
|
try {
|
|
32601
|
-
JSON.parse(
|
|
32756
|
+
JSON.parse(readFileSync12(p, "utf8"));
|
|
32602
32757
|
return false;
|
|
32603
32758
|
} catch {
|
|
32604
32759
|
return true;
|
|
@@ -32651,7 +32806,7 @@ function pruneMissingWorkspaces() {
|
|
|
32651
32806
|
const reg = read();
|
|
32652
32807
|
const removed = [];
|
|
32653
32808
|
for (const [id, entry] of Object.entries(reg.workspaces)) {
|
|
32654
|
-
if (!
|
|
32809
|
+
if (!existsSync13(entry.path)) {
|
|
32655
32810
|
removed.push(entry);
|
|
32656
32811
|
delete reg.workspaces[id];
|
|
32657
32812
|
}
|
|
@@ -32660,19 +32815,14 @@ function pruneMissingWorkspaces() {
|
|
|
32660
32815
|
return removed;
|
|
32661
32816
|
}
|
|
32662
32817
|
function workspaceStatus(entry) {
|
|
32663
|
-
const missing = !
|
|
32818
|
+
const missing = !existsSync13(entry.path);
|
|
32664
32819
|
const lockPath = workspacePaths(entry.path).daemonLock;
|
|
32665
32820
|
let running = false;
|
|
32666
32821
|
let webUiUrl = null;
|
|
32667
|
-
|
|
32668
|
-
|
|
32669
|
-
|
|
32670
|
-
|
|
32671
|
-
running = true;
|
|
32672
|
-
webUiUrl = lock.webUiUrl;
|
|
32673
|
-
}
|
|
32674
|
-
} catch {
|
|
32675
|
-
}
|
|
32822
|
+
const lock = readDaemonLock(lockPath);
|
|
32823
|
+
if (lock?.webUiUrl && daemonLockState(lock) === "running") {
|
|
32824
|
+
running = true;
|
|
32825
|
+
webUiUrl = lock.webUiUrl;
|
|
32676
32826
|
}
|
|
32677
32827
|
return { ...entry, running, webUiUrl, missing };
|
|
32678
32828
|
}
|
|
@@ -32682,19 +32832,12 @@ function listWorkspaces() {
|
|
|
32682
32832
|
function listWorkspaceEntries() {
|
|
32683
32833
|
return Object.values(read().workspaces).sort((a, b) => b.lastSeenAt - a.lastSeenAt);
|
|
32684
32834
|
}
|
|
32685
|
-
function pidAlive(pid) {
|
|
32686
|
-
try {
|
|
32687
|
-
process.kill(pid, 0);
|
|
32688
|
-
return true;
|
|
32689
|
-
} catch (err2) {
|
|
32690
|
-
return err2.code === "EPERM";
|
|
32691
|
-
}
|
|
32692
|
-
}
|
|
32693
32835
|
var init_registry = __esm({
|
|
32694
32836
|
"src/registry.ts"() {
|
|
32695
32837
|
"use strict";
|
|
32696
32838
|
init_paths();
|
|
32697
32839
|
init_checkout_root();
|
|
32840
|
+
init_lock();
|
|
32698
32841
|
}
|
|
32699
32842
|
});
|
|
32700
32843
|
|
|
@@ -33991,7 +34134,7 @@ var init_dual_augment = __esm({
|
|
|
33991
34134
|
|
|
33992
34135
|
// ../../packages/indexer/src/parse-cache.ts
|
|
33993
34136
|
import { createHash as createHash6 } from "node:crypto";
|
|
33994
|
-
import { existsSync as
|
|
34137
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync6, readFileSync as readFileSync13, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync10 } from "node:fs";
|
|
33995
34138
|
import { homedir as homedir3 } from "node:os";
|
|
33996
34139
|
import { join as join12 } from "node:path";
|
|
33997
34140
|
function parseCacheDir() {
|
|
@@ -34006,7 +34149,7 @@ function entryPath(dir, key) {
|
|
|
34006
34149
|
function readParseCache(dir, key) {
|
|
34007
34150
|
const file2 = entryPath(dir, key);
|
|
34008
34151
|
try {
|
|
34009
|
-
const raw2 =
|
|
34152
|
+
const raw2 = readFileSync13(file2, "utf8");
|
|
34010
34153
|
const parsed = JSON.parse(raw2);
|
|
34011
34154
|
if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
|
|
34012
34155
|
return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
|
|
@@ -34035,7 +34178,7 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
34035
34178
|
sweptThisProcess = true;
|
|
34036
34179
|
let removed = 0;
|
|
34037
34180
|
try {
|
|
34038
|
-
if (!
|
|
34181
|
+
if (!existsSync14(dir)) return 0;
|
|
34039
34182
|
for (const bucket of readdirSync2(dir)) {
|
|
34040
34183
|
const bucketDir = join12(dir, bucket);
|
|
34041
34184
|
let names;
|
|
@@ -34293,11 +34436,11 @@ var init_identity3 = __esm({
|
|
|
34293
34436
|
});
|
|
34294
34437
|
|
|
34295
34438
|
// ../../packages/indexer/src/pipeline.ts
|
|
34296
|
-
import { appendFileSync, readFileSync as
|
|
34439
|
+
import { appendFileSync, readFileSync as readFileSync14, statSync as statSync3 } from "node:fs";
|
|
34297
34440
|
import { readdir } from "node:fs/promises";
|
|
34298
34441
|
import { extname, join as join13, relative as relative2, sep } from "node:path";
|
|
34299
34442
|
import { createHash as createHash7 } from "node:crypto";
|
|
34300
|
-
import { execFileSync } from "node:child_process";
|
|
34443
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
34301
34444
|
function nowTs() {
|
|
34302
34445
|
return indexNow ?? Date.now();
|
|
34303
34446
|
}
|
|
@@ -34433,7 +34576,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34433
34576
|
for (const rel of [...changedRelPaths]) {
|
|
34434
34577
|
let h;
|
|
34435
34578
|
try {
|
|
34436
|
-
h = createHash7("sha256").update(
|
|
34579
|
+
h = createHash7("sha256").update(readFileSync14(join13(rootPath, rel))).digest("hex");
|
|
34437
34580
|
} catch {
|
|
34438
34581
|
continue;
|
|
34439
34582
|
}
|
|
@@ -34488,7 +34631,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34488
34631
|
if (!provider) continue;
|
|
34489
34632
|
let symbols;
|
|
34490
34633
|
try {
|
|
34491
|
-
symbols = provider.extractSymbols(
|
|
34634
|
+
symbols = provider.extractSymbols(readFileSync14(abs, "utf8"), abs);
|
|
34492
34635
|
} catch {
|
|
34493
34636
|
continue;
|
|
34494
34637
|
}
|
|
@@ -34808,7 +34951,7 @@ async function runIndexer(store, opts) {
|
|
|
34808
34951
|
report.filesSkipped++;
|
|
34809
34952
|
continue;
|
|
34810
34953
|
}
|
|
34811
|
-
source =
|
|
34954
|
+
source = readFileSync14(f.absPath, "utf8");
|
|
34812
34955
|
} catch {
|
|
34813
34956
|
report.filesSkipped++;
|
|
34814
34957
|
continue;
|
|
@@ -34880,7 +35023,7 @@ async function runIndexer(store, opts) {
|
|
|
34880
35023
|
const depth = fileNode.relPath.split("/").length;
|
|
34881
35024
|
if (depth !== 3) continue;
|
|
34882
35025
|
try {
|
|
34883
|
-
const pkg = JSON.parse(
|
|
35026
|
+
const pkg = JSON.parse(readFileSync14(fileNode.absPath, "utf8"));
|
|
34884
35027
|
if (!pkg.name) continue;
|
|
34885
35028
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
34886
35029
|
const candidates = [
|
|
@@ -35298,7 +35441,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
35298
35441
|
function gitListRelPaths(root, ignores) {
|
|
35299
35442
|
let stdout;
|
|
35300
35443
|
try {
|
|
35301
|
-
stdout =
|
|
35444
|
+
stdout = execFileSync2(
|
|
35302
35445
|
"git",
|
|
35303
35446
|
["-C", root, "ls-files", "--cached", "--others", "--exclude-standard", "-z"],
|
|
35304
35447
|
{
|
|
@@ -35356,7 +35499,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
|
|
|
35356
35499
|
if (existing && fileUnchanged(existing.attrs, f, skip)) return;
|
|
35357
35500
|
let contentHash;
|
|
35358
35501
|
try {
|
|
35359
|
-
contentHash = createHash7("sha256").update(
|
|
35502
|
+
contentHash = createHash7("sha256").update(readFileSync14(f.absPath)).digest("hex");
|
|
35360
35503
|
} catch {
|
|
35361
35504
|
}
|
|
35362
35505
|
const carried = { ...existing?.attrs ?? {} };
|
|
@@ -39740,7 +39883,7 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
39740
39883
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
39741
39884
|
import { fileURLToPath } from "node:url";
|
|
39742
39885
|
import { dirname as dirname7, join as join14 } from "node:path";
|
|
39743
|
-
import { existsSync as
|
|
39886
|
+
import { existsSync as existsSync15, readdirSync as readdirSync3 } from "node:fs";
|
|
39744
39887
|
import { createRequire as createRequire2 } from "node:module";
|
|
39745
39888
|
function entryDir() {
|
|
39746
39889
|
try {
|
|
@@ -39755,7 +39898,7 @@ function entryDir() {
|
|
|
39755
39898
|
function findWasmDir() {
|
|
39756
39899
|
const here = entryDir();
|
|
39757
39900
|
const seaWasm = join14(here, "resources", "wasm");
|
|
39758
|
-
if (
|
|
39901
|
+
if (existsSync15(join14(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
39759
39902
|
let dir = here;
|
|
39760
39903
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39761
39904
|
const flat = join14(
|
|
@@ -39765,13 +39908,13 @@ function findWasmDir() {
|
|
|
39765
39908
|
"tree-sitter-wasm",
|
|
39766
39909
|
"wasm"
|
|
39767
39910
|
);
|
|
39768
|
-
if (
|
|
39911
|
+
if (existsSync15(join14(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
39769
39912
|
dir = dirname7(dir);
|
|
39770
39913
|
}
|
|
39771
39914
|
let root = here;
|
|
39772
39915
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39773
39916
|
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
39774
|
-
if (
|
|
39917
|
+
if (existsSync15(pnpmDir)) {
|
|
39775
39918
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
39776
39919
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
39777
39920
|
const candidate = join14(
|
|
@@ -39782,7 +39925,7 @@ function findWasmDir() {
|
|
|
39782
39925
|
"tree-sitter-wasm",
|
|
39783
39926
|
"wasm"
|
|
39784
39927
|
);
|
|
39785
|
-
if (
|
|
39928
|
+
if (existsSync15(join14(candidate, "tree-sitter-typescript.wasm"))) {
|
|
39786
39929
|
return candidate;
|
|
39787
39930
|
}
|
|
39788
39931
|
}
|
|
@@ -39797,17 +39940,17 @@ function findWasmDir() {
|
|
|
39797
39940
|
function findRuntimeDir() {
|
|
39798
39941
|
const here = entryDir();
|
|
39799
39942
|
const seaRuntime = join14(here, "resources", "wasm");
|
|
39800
|
-
if (
|
|
39943
|
+
if (existsSync15(join14(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
39801
39944
|
let dir = here;
|
|
39802
39945
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39803
39946
|
const flat = join14(dir, "node_modules", "web-tree-sitter");
|
|
39804
|
-
if (
|
|
39947
|
+
if (existsSync15(join14(flat, "web-tree-sitter.wasm"))) return flat;
|
|
39805
39948
|
dir = dirname7(dir);
|
|
39806
39949
|
}
|
|
39807
39950
|
let root = here;
|
|
39808
39951
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39809
39952
|
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
39810
|
-
if (
|
|
39953
|
+
if (existsSync15(pnpmDir)) {
|
|
39811
39954
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
39812
39955
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
39813
39956
|
const candidate = join14(
|
|
@@ -39816,7 +39959,7 @@ function findRuntimeDir() {
|
|
|
39816
39959
|
"node_modules",
|
|
39817
39960
|
"web-tree-sitter"
|
|
39818
39961
|
);
|
|
39819
|
-
if (
|
|
39962
|
+
if (existsSync15(join14(candidate, "web-tree-sitter.wasm"))) {
|
|
39820
39963
|
return candidate;
|
|
39821
39964
|
}
|
|
39822
39965
|
}
|
|
@@ -42765,7 +42908,7 @@ var init_src11 = __esm({
|
|
|
42765
42908
|
});
|
|
42766
42909
|
|
|
42767
42910
|
// src/reconcile.ts
|
|
42768
|
-
import { execFileSync as
|
|
42911
|
+
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
42769
42912
|
import { readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
|
|
42770
42913
|
import { join as join15, relative as relative3, sep as sep2 } from "node:path";
|
|
42771
42914
|
function indexerWouldScan(rel) {
|
|
@@ -42779,7 +42922,7 @@ function indexerWouldScan(rel) {
|
|
|
42779
42922
|
function gitSourceFiles(root) {
|
|
42780
42923
|
let stdout;
|
|
42781
42924
|
try {
|
|
42782
|
-
stdout =
|
|
42925
|
+
stdout = execFileSync3(
|
|
42783
42926
|
"git",
|
|
42784
42927
|
["-C", root, "ls-files", "--cached", "--others", "--exclude-standard", "-z"],
|
|
42785
42928
|
{ encoding: "utf8", maxBuffer: 128 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
@@ -42955,7 +43098,7 @@ __export(mcp_exports, {
|
|
|
42955
43098
|
runTool: () => runTool,
|
|
42956
43099
|
searchGraph: () => searchGraph
|
|
42957
43100
|
});
|
|
42958
|
-
import { existsSync as
|
|
43101
|
+
import { existsSync as existsSync16, readFileSync as readFileSync15 } from "node:fs";
|
|
42959
43102
|
import { resolve as resolve3 } from "node:path";
|
|
42960
43103
|
function collectEnrichmentPulls(store, opts = {}) {
|
|
42961
43104
|
const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
|
|
@@ -42992,7 +43135,7 @@ function takeEnrichmentNudge(store) {
|
|
|
42992
43135
|
` + items;
|
|
42993
43136
|
}
|
|
42994
43137
|
function takeDiscriminatorNudge(path2) {
|
|
42995
|
-
if (!path2 || !
|
|
43138
|
+
if (!path2 || !existsSync16(path2)) return null;
|
|
42996
43139
|
let shared;
|
|
42997
43140
|
try {
|
|
42998
43141
|
shared = openGraphStore({ path: path2 });
|
|
@@ -43123,10 +43266,10 @@ function showNode(store, node2, maxLines) {
|
|
|
43123
43266
|
if (!relPath) return { found: false, reason: "no file owner for node" };
|
|
43124
43267
|
const workspaceRoot = process.cwd();
|
|
43125
43268
|
const absPath = resolve3(workspaceRoot, relPath);
|
|
43126
|
-
if (!
|
|
43269
|
+
if (!existsSync16(absPath)) {
|
|
43127
43270
|
return { found: false, reason: `file not found on disk: ${absPath}` };
|
|
43128
43271
|
}
|
|
43129
|
-
const source =
|
|
43272
|
+
const source = readFileSync15(absPath, "utf8");
|
|
43130
43273
|
const attrs = node2.attrs;
|
|
43131
43274
|
let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
|
|
43132
43275
|
let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
|
|
@@ -43845,7 +43988,7 @@ var init_mcp = __esm({
|
|
|
43845
43988
|
const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
|
|
43846
43989
|
try {
|
|
43847
43990
|
const path2 = sharedStorePath();
|
|
43848
|
-
if (!
|
|
43991
|
+
if (!existsSync16(path2)) return { found: true, ...local };
|
|
43849
43992
|
const shared = openGraphStore({ path: path2 });
|
|
43850
43993
|
try {
|
|
43851
43994
|
if (!shared.getNode(id)) return { found: true, ...local };
|
|
@@ -44448,7 +44591,7 @@ var init_mcp = __esm({
|
|
|
44448
44591
|
inputSchema: { type: "object", properties: {} },
|
|
44449
44592
|
handler: () => {
|
|
44450
44593
|
const path2 = sharedStorePath();
|
|
44451
|
-
if (!
|
|
44594
|
+
if (!existsSync16(path2)) return { count: 0, pending: [] };
|
|
44452
44595
|
const shared = openGraphStore({ path: path2 });
|
|
44453
44596
|
try {
|
|
44454
44597
|
const pending = pendingAbstractions(shared);
|
|
@@ -44476,7 +44619,7 @@ var init_mcp = __esm({
|
|
|
44476
44619
|
},
|
|
44477
44620
|
handler: (args2) => {
|
|
44478
44621
|
const path2 = sharedStorePath();
|
|
44479
|
-
if (!
|
|
44622
|
+
if (!existsSync16(path2)) return { count: 0, pending: [] };
|
|
44480
44623
|
const shared = openGraphStore({ path: path2 });
|
|
44481
44624
|
try {
|
|
44482
44625
|
const pending = pendingDiscriminators(shared, {
|
|
@@ -44520,7 +44663,7 @@ var init_mcp = __esm({
|
|
|
44520
44663
|
},
|
|
44521
44664
|
handler: (args2) => {
|
|
44522
44665
|
const path2 = sharedStorePath();
|
|
44523
|
-
if (!
|
|
44666
|
+
if (!existsSync16(path2)) return { count: 0, routes: [] };
|
|
44524
44667
|
const shared = openGraphStore({ path: path2 });
|
|
44525
44668
|
try {
|
|
44526
44669
|
const result = triageOf(shared, {
|
|
@@ -52407,11 +52550,11 @@ var init_tool_index = __esm({
|
|
|
52407
52550
|
|
|
52408
52551
|
// src/outbox.ts
|
|
52409
52552
|
import {
|
|
52410
|
-
existsSync as
|
|
52553
|
+
existsSync as existsSync17,
|
|
52411
52554
|
readdirSync as readdirSync5,
|
|
52412
|
-
readFileSync as
|
|
52555
|
+
readFileSync as readFileSync16,
|
|
52413
52556
|
renameSync,
|
|
52414
|
-
unlinkSync,
|
|
52557
|
+
unlinkSync as unlinkSync2,
|
|
52415
52558
|
writeFileSync as writeFileSync12
|
|
52416
52559
|
} from "node:fs";
|
|
52417
52560
|
import { join as join17 } from "node:path";
|
|
@@ -52425,7 +52568,7 @@ function enqueueOutbox(paths, payload) {
|
|
|
52425
52568
|
}
|
|
52426
52569
|
async function flushOutbox(paths, client, store) {
|
|
52427
52570
|
ensureDir(paths.outbox);
|
|
52428
|
-
const entries =
|
|
52571
|
+
const entries = existsSync17(paths.outbox) ? readdirSync5(paths.outbox) : [];
|
|
52429
52572
|
let uploaded = 0;
|
|
52430
52573
|
let failed = 0;
|
|
52431
52574
|
const quarantine = (abs, reason) => {
|
|
@@ -52439,7 +52582,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52439
52582
|
const abs = join17(paths.outbox, f);
|
|
52440
52583
|
let payload;
|
|
52441
52584
|
try {
|
|
52442
|
-
payload = JSON.parse(
|
|
52585
|
+
payload = JSON.parse(readFileSync16(abs, "utf8"));
|
|
52443
52586
|
} catch {
|
|
52444
52587
|
failed++;
|
|
52445
52588
|
quarantine(abs, "unparseable JSON");
|
|
@@ -52474,7 +52617,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52474
52617
|
}
|
|
52475
52618
|
}
|
|
52476
52619
|
}
|
|
52477
|
-
|
|
52620
|
+
unlinkSync2(abs);
|
|
52478
52621
|
if (res.accepted === 0) uploaded++;
|
|
52479
52622
|
} catch (err2) {
|
|
52480
52623
|
failed++;
|
|
@@ -52484,7 +52627,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52484
52627
|
}
|
|
52485
52628
|
}
|
|
52486
52629
|
}
|
|
52487
|
-
const remainingFiles =
|
|
52630
|
+
const remainingFiles = existsSync17(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
|
|
52488
52631
|
return { uploaded, failed, remaining: remainingFiles.length };
|
|
52489
52632
|
}
|
|
52490
52633
|
var init_outbox = __esm({
|
|
@@ -53050,12 +53193,17 @@ function buildWebUi(deps) {
|
|
|
53050
53193
|
block,
|
|
53051
53194
|
lastInjectedHash
|
|
53052
53195
|
});
|
|
53196
|
+
let systemMessage = null;
|
|
53053
53197
|
if (sid && block && recallCardEnabled() && (decision || atPrompt)) {
|
|
53054
53198
|
const card = readContextCard(deps.paths.root, block.hash);
|
|
53055
|
-
if (card)
|
|
53199
|
+
if (card) {
|
|
53200
|
+
rememberCard(sid, card);
|
|
53201
|
+
if (decision && sid.startsWith("codex:")) systemMessage = renderRecallLine(card);
|
|
53202
|
+
}
|
|
53056
53203
|
}
|
|
53057
53204
|
if (!decision) return c.json({});
|
|
53058
53205
|
return c.json({
|
|
53206
|
+
...systemMessage ? { systemMessage } : {},
|
|
53059
53207
|
hookSpecificOutput: {
|
|
53060
53208
|
hookEventName: decision.hookEventName,
|
|
53061
53209
|
additionalContext: decision.additionalContext
|
|
@@ -62810,11 +62958,11 @@ var require_readable = __commonJS({
|
|
|
62810
62958
|
});
|
|
62811
62959
|
}
|
|
62812
62960
|
};
|
|
62813
|
-
function isLocked(
|
|
62814
|
-
return
|
|
62961
|
+
function isLocked(self2) {
|
|
62962
|
+
return self2[kBody] && self2[kBody].locked === true || self2[kConsume];
|
|
62815
62963
|
}
|
|
62816
|
-
function isUnusable(
|
|
62817
|
-
return util.isDisturbed(
|
|
62964
|
+
function isUnusable(self2) {
|
|
62965
|
+
return util.isDisturbed(self2) || isLocked(self2);
|
|
62818
62966
|
}
|
|
62819
62967
|
async function consume(stream, type) {
|
|
62820
62968
|
assert2(!stream[kConsume]);
|
|
@@ -63201,42 +63349,42 @@ var require_abort_signal = __commonJS({
|
|
|
63201
63349
|
var { RequestAbortedError } = require_errors();
|
|
63202
63350
|
var kListener = Symbol("kListener");
|
|
63203
63351
|
var kSignal = Symbol("kSignal");
|
|
63204
|
-
function abort2(
|
|
63205
|
-
if (
|
|
63206
|
-
|
|
63352
|
+
function abort2(self2) {
|
|
63353
|
+
if (self2.abort) {
|
|
63354
|
+
self2.abort(self2[kSignal]?.reason);
|
|
63207
63355
|
} else {
|
|
63208
|
-
|
|
63356
|
+
self2.reason = self2[kSignal]?.reason ?? new RequestAbortedError();
|
|
63209
63357
|
}
|
|
63210
|
-
removeSignal(
|
|
63358
|
+
removeSignal(self2);
|
|
63211
63359
|
}
|
|
63212
|
-
function addSignal(
|
|
63213
|
-
|
|
63214
|
-
|
|
63215
|
-
|
|
63360
|
+
function addSignal(self2, signal) {
|
|
63361
|
+
self2.reason = null;
|
|
63362
|
+
self2[kSignal] = null;
|
|
63363
|
+
self2[kListener] = null;
|
|
63216
63364
|
if (!signal) {
|
|
63217
63365
|
return;
|
|
63218
63366
|
}
|
|
63219
63367
|
if (signal.aborted) {
|
|
63220
|
-
abort2(
|
|
63368
|
+
abort2(self2);
|
|
63221
63369
|
return;
|
|
63222
63370
|
}
|
|
63223
|
-
|
|
63224
|
-
|
|
63225
|
-
abort2(
|
|
63371
|
+
self2[kSignal] = signal;
|
|
63372
|
+
self2[kListener] = () => {
|
|
63373
|
+
abort2(self2);
|
|
63226
63374
|
};
|
|
63227
|
-
addAbortListener(
|
|
63375
|
+
addAbortListener(self2[kSignal], self2[kListener]);
|
|
63228
63376
|
}
|
|
63229
|
-
function removeSignal(
|
|
63230
|
-
if (!
|
|
63377
|
+
function removeSignal(self2) {
|
|
63378
|
+
if (!self2[kSignal]) {
|
|
63231
63379
|
return;
|
|
63232
63380
|
}
|
|
63233
|
-
if ("removeEventListener" in
|
|
63234
|
-
|
|
63381
|
+
if ("removeEventListener" in self2[kSignal]) {
|
|
63382
|
+
self2[kSignal].removeEventListener("abort", self2[kListener]);
|
|
63235
63383
|
} else {
|
|
63236
|
-
|
|
63384
|
+
self2[kSignal].removeListener("abort", self2[kListener]);
|
|
63237
63385
|
}
|
|
63238
|
-
|
|
63239
|
-
|
|
63386
|
+
self2[kSignal] = null;
|
|
63387
|
+
self2[kListener] = null;
|
|
63240
63388
|
}
|
|
63241
63389
|
module2.exports = {
|
|
63242
63390
|
addSignal,
|
|
@@ -72093,7 +72241,7 @@ __export(witness_ledger_exports, {
|
|
|
72093
72241
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
72094
72242
|
witnessLedgerPath: () => witnessLedgerPath
|
|
72095
72243
|
});
|
|
72096
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
72244
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync26, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
72097
72245
|
import { join as join33 } from "node:path";
|
|
72098
72246
|
function witnessLedgerPath(configDir) {
|
|
72099
72247
|
return join33(configDir, "witness-ledger.jsonl");
|
|
@@ -72102,7 +72250,7 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
72102
72250
|
const path2 = witnessLedgerPath(configDir);
|
|
72103
72251
|
try {
|
|
72104
72252
|
appendFileSync3(path2, JSON.stringify(entry) + "\n");
|
|
72105
|
-
const lines =
|
|
72253
|
+
const lines = readFileSync29(path2, "utf8").split("\n").filter(Boolean);
|
|
72106
72254
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
72107
72255
|
writeFileSync20(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
72108
72256
|
}
|
|
@@ -72111,9 +72259,9 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
72111
72259
|
}
|
|
72112
72260
|
function readWitnessLedger(configDir) {
|
|
72113
72261
|
const path2 = witnessLedgerPath(configDir);
|
|
72114
|
-
if (!
|
|
72262
|
+
if (!existsSync26(path2)) return [];
|
|
72115
72263
|
try {
|
|
72116
|
-
return
|
|
72264
|
+
return readFileSync29(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
|
|
72117
72265
|
} catch {
|
|
72118
72266
|
return [];
|
|
72119
72267
|
}
|
|
@@ -72552,12 +72700,12 @@ var init_report_render = __esm({
|
|
|
72552
72700
|
|
|
72553
72701
|
// src/cli.ts
|
|
72554
72702
|
init_src6();
|
|
72555
|
-
import { closeSync as closeSync2, existsSync as existsSync36, openSync as openSync2, readFileSync as
|
|
72703
|
+
import { closeSync as closeSync2, existsSync as existsSync36, openSync as openSync2, readFileSync as readFileSync38, renameSync as renameSync4, statSync as statSync10 } from "node:fs";
|
|
72556
72704
|
import { join as join44, resolve as pathResolve2 } from "node:path";
|
|
72557
72705
|
import { spawn as spawn5 } from "node:child_process";
|
|
72558
72706
|
|
|
72559
72707
|
// src/daemon.ts
|
|
72560
|
-
import { existsSync as
|
|
72708
|
+
import { existsSync as existsSync28, writeFileSync as writeFileSync23 } from "node:fs";
|
|
72561
72709
|
|
|
72562
72710
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
|
|
72563
72711
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -73136,8 +73284,8 @@ init_webui();
|
|
|
73136
73284
|
init_config();
|
|
73137
73285
|
|
|
73138
73286
|
// src/engine.ts
|
|
73139
|
-
import { execFileSync as
|
|
73140
|
-
import { existsSync as
|
|
73287
|
+
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
73288
|
+
import { existsSync as existsSync27, statSync as statSync8, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
|
|
73141
73289
|
import { basename as basename7, join as join35, relative as relative6, sep as sep4 } from "node:path";
|
|
73142
73290
|
|
|
73143
73291
|
// src/source-watcher.ts
|
|
@@ -74845,16 +74993,16 @@ function createSourceWatcher(targets, opts) {
|
|
|
74845
74993
|
}
|
|
74846
74994
|
function chokidarSourceWatcher(targets, ignored) {
|
|
74847
74995
|
const w = esm_default.watch([...targets], { ignored, ignoreInitial: true, persistent: true });
|
|
74848
|
-
const
|
|
74996
|
+
const self2 = {
|
|
74849
74997
|
on(event, listener) {
|
|
74850
74998
|
w.on(event, listener);
|
|
74851
|
-
return
|
|
74999
|
+
return self2;
|
|
74852
75000
|
},
|
|
74853
75001
|
add: (p) => void w.add(p),
|
|
74854
75002
|
unwatch: (p) => void w.unwatch(p),
|
|
74855
75003
|
close: () => w.close()
|
|
74856
75004
|
};
|
|
74857
|
-
return
|
|
75005
|
+
return self2;
|
|
74858
75006
|
}
|
|
74859
75007
|
var NativeSourceWatcher = class extends EventEmitter2 {
|
|
74860
75008
|
constructor(targets, ignored) {
|
|
@@ -75182,7 +75330,7 @@ init_review2();
|
|
|
75182
75330
|
|
|
75183
75331
|
// src/turn.ts
|
|
75184
75332
|
init_checkout_root();
|
|
75185
|
-
import { closeSync, existsSync as
|
|
75333
|
+
import { closeSync, existsSync as existsSync18, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync, statSync as statSync6 } from "node:fs";
|
|
75186
75334
|
import { basename as basename5, delimiter, dirname as dirname10, join as join21, normalize as normalize3 } from "node:path";
|
|
75187
75335
|
import { homedir as homedir4 } from "node:os";
|
|
75188
75336
|
import { createHash as createHash16 } from "node:crypto";
|
|
@@ -75575,7 +75723,7 @@ function claudeProjectDir(cwd, home = homedir4()) {
|
|
|
75575
75723
|
}
|
|
75576
75724
|
function recentTranscripts(cwd, opts = {}) {
|
|
75577
75725
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
75578
|
-
if (!
|
|
75726
|
+
if (!existsSync18(dir)) return [];
|
|
75579
75727
|
let names;
|
|
75580
75728
|
try {
|
|
75581
75729
|
names = readdirSync6(dir);
|
|
@@ -75602,7 +75750,7 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
75602
75750
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
75603
75751
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
75604
75752
|
const dir = join21(dirname10(mainTranscriptPath), sessionId, "subagents");
|
|
75605
|
-
if (!
|
|
75753
|
+
if (!existsSync18(dir)) return [];
|
|
75606
75754
|
let names;
|
|
75607
75755
|
try {
|
|
75608
75756
|
names = readdirSync6(dir);
|
|
@@ -75686,7 +75834,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
75686
75834
|
const owner = checkoutRootOf(cwd);
|
|
75687
75835
|
const owners = /* @__PURE__ */ new Map();
|
|
75688
75836
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
75689
|
-
if (!
|
|
75837
|
+
if (!existsSync18(root)) {
|
|
75690
75838
|
codexRolloutActivity.delete(root);
|
|
75691
75839
|
continue;
|
|
75692
75840
|
}
|
|
@@ -75787,7 +75935,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75787
75935
|
const hashes = geminiHashesFor(cwd);
|
|
75788
75936
|
const out2 = [];
|
|
75789
75937
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
75790
|
-
if (!
|
|
75938
|
+
if (!existsSync18(root)) continue;
|
|
75791
75939
|
let slugs;
|
|
75792
75940
|
try {
|
|
75793
75941
|
slugs = readdirSync6(root);
|
|
@@ -75858,7 +76006,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75858
76006
|
}
|
|
75859
76007
|
const out2 = [];
|
|
75860
76008
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
75861
|
-
if (!
|
|
76009
|
+
if (!existsSync18(root)) continue;
|
|
75862
76010
|
let names;
|
|
75863
76011
|
try {
|
|
75864
76012
|
names = readdirSync6(root);
|
|
@@ -75890,7 +76038,7 @@ init_src2();
|
|
|
75890
76038
|
init_agent_signals();
|
|
75891
76039
|
init_tool_index();
|
|
75892
76040
|
init_src5();
|
|
75893
|
-
import { readFileSync as
|
|
76041
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync13 } from "node:fs";
|
|
75894
76042
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
75895
76043
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
75896
76044
|
var HANDLE_RE = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|dvuln|prob|claim|err)_[0-9a-f]{6,})/gi;
|
|
@@ -76629,7 +76777,7 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
|
|
|
76629
76777
|
}
|
|
76630
76778
|
function readPrimingHandles(path2) {
|
|
76631
76779
|
try {
|
|
76632
|
-
return JSON.parse(
|
|
76780
|
+
return JSON.parse(readFileSync17(path2, "utf8"));
|
|
76633
76781
|
} catch {
|
|
76634
76782
|
return {};
|
|
76635
76783
|
}
|
|
@@ -77109,7 +77257,7 @@ ${conversation}` }]
|
|
|
77109
77257
|
// src/constraint-backfill.ts
|
|
77110
77258
|
init_src5();
|
|
77111
77259
|
init_src2();
|
|
77112
|
-
import { existsSync as
|
|
77260
|
+
import { existsSync as existsSync19, readFileSync as readFileSync18, readdirSync as readdirSync7, writeFileSync as writeFileSync14 } from "node:fs";
|
|
77113
77261
|
import { join as join22 } from "node:path";
|
|
77114
77262
|
import { homedir as homedir5 } from "node:os";
|
|
77115
77263
|
var BACKFILL_VERSION = 1;
|
|
@@ -77128,9 +77276,9 @@ function markerPath(configDir) {
|
|
|
77128
77276
|
}
|
|
77129
77277
|
function alreadyDone(configDir) {
|
|
77130
77278
|
const p = markerPath(configDir);
|
|
77131
|
-
if (!
|
|
77279
|
+
if (!existsSync19(p)) return false;
|
|
77132
77280
|
try {
|
|
77133
|
-
const raw2 = JSON.parse(
|
|
77281
|
+
const raw2 = JSON.parse(readFileSync18(p, "utf8"));
|
|
77134
77282
|
return raw2?.version === BACKFILL_VERSION;
|
|
77135
77283
|
} catch {
|
|
77136
77284
|
return false;
|
|
@@ -77140,7 +77288,7 @@ function replay(root) {
|
|
|
77140
77288
|
const statements = /* @__PURE__ */ new Set();
|
|
77141
77289
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
77142
77290
|
const dir = claudeProjectDir(root, homedir5());
|
|
77143
|
-
if (!
|
|
77291
|
+
if (!existsSync19(dir)) return { statements, citedByFix };
|
|
77144
77292
|
let names;
|
|
77145
77293
|
try {
|
|
77146
77294
|
names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -77150,7 +77298,7 @@ function replay(root) {
|
|
|
77150
77298
|
for (const f of names) {
|
|
77151
77299
|
let lines;
|
|
77152
77300
|
try {
|
|
77153
|
-
lines =
|
|
77301
|
+
lines = readFileSync18(join22(dir, f), "utf8").split("\n");
|
|
77154
77302
|
} catch {
|
|
77155
77303
|
continue;
|
|
77156
77304
|
}
|
|
@@ -77277,7 +77425,7 @@ function backfillConstraintKind(store, opts) {
|
|
|
77277
77425
|
// src/edge-repair.ts
|
|
77278
77426
|
init_src();
|
|
77279
77427
|
init_src5();
|
|
77280
|
-
import { existsSync as
|
|
77428
|
+
import { existsSync as existsSync20, readFileSync as readFileSync19, writeFileSync as writeFileSync15 } from "node:fs";
|
|
77281
77429
|
import { join as join23 } from "node:path";
|
|
77282
77430
|
function citeEdgeId(from, type, to) {
|
|
77283
77431
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
@@ -77297,9 +77445,9 @@ function markerPath2(configDir) {
|
|
|
77297
77445
|
}
|
|
77298
77446
|
function alreadyDone2(configDir) {
|
|
77299
77447
|
const p = markerPath2(configDir);
|
|
77300
|
-
if (!
|
|
77448
|
+
if (!existsSync20(p)) return false;
|
|
77301
77449
|
try {
|
|
77302
|
-
return JSON.parse(
|
|
77450
|
+
return JSON.parse(readFileSync19(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
77303
77451
|
} catch {
|
|
77304
77452
|
return false;
|
|
77305
77453
|
}
|
|
@@ -77362,7 +77510,7 @@ function repairInvalidEdges(store, opts) {
|
|
|
77362
77510
|
init_reconcile();
|
|
77363
77511
|
|
|
77364
77512
|
// src/pass-ledger.ts
|
|
77365
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
77513
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync21, readFileSync as readFileSync20, writeFileSync as writeFileSync16 } from "node:fs";
|
|
77366
77514
|
import { join as join24 } from "node:path";
|
|
77367
77515
|
|
|
77368
77516
|
// src/isolate-census.ts
|
|
@@ -77415,7 +77563,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77415
77563
|
return;
|
|
77416
77564
|
}
|
|
77417
77565
|
appendsSinceTrim.set(path2, 0);
|
|
77418
|
-
const lines =
|
|
77566
|
+
const lines = readFileSync20(path2, "utf8").split("\n").filter(Boolean);
|
|
77419
77567
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
77420
77568
|
const kept = [];
|
|
77421
77569
|
for (let i2 = lines.length - 1; i2 >= 0; i2--) {
|
|
@@ -77438,9 +77586,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77438
77586
|
}
|
|
77439
77587
|
function readPassLedger(configDir) {
|
|
77440
77588
|
const path2 = passLedgerPath(configDir);
|
|
77441
|
-
if (!
|
|
77589
|
+
if (!existsSync21(path2)) return [];
|
|
77442
77590
|
try {
|
|
77443
|
-
return
|
|
77591
|
+
return readFileSync20(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
77444
77592
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
77445
77593
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
77446
77594
|
} catch {
|
|
@@ -77812,11 +77960,11 @@ init_outbox();
|
|
|
77812
77960
|
init_src10();
|
|
77813
77961
|
init_src();
|
|
77814
77962
|
init_src2();
|
|
77815
|
-
import { readFileSync as
|
|
77963
|
+
import { readFileSync as readFileSync21 } from "node:fs";
|
|
77816
77964
|
import { join as join25 } from "node:path";
|
|
77817
77965
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
77818
77966
|
try {
|
|
77819
|
-
return
|
|
77967
|
+
return readFileSync21(join25(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
77820
77968
|
} catch {
|
|
77821
77969
|
return [];
|
|
77822
77970
|
}
|
|
@@ -78193,8 +78341,8 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
78193
78341
|
|
|
78194
78342
|
// src/retrieval-stack.ts
|
|
78195
78343
|
init_src();
|
|
78196
|
-
import { execFileSync as
|
|
78197
|
-
import { existsSync as
|
|
78344
|
+
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
78345
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22, statSync as statSync7 } from "node:fs";
|
|
78198
78346
|
import { homedir as homedir6 } from "node:os";
|
|
78199
78347
|
import { join as join26 } from "node:path";
|
|
78200
78348
|
var RETRIEVAL_STACK_CAP = 24;
|
|
@@ -78486,7 +78634,7 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
78486
78634
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
78487
78635
|
const read2 = (p) => {
|
|
78488
78636
|
try {
|
|
78489
|
-
return
|
|
78637
|
+
return readFileSync22(p, "utf8");
|
|
78490
78638
|
} catch {
|
|
78491
78639
|
return null;
|
|
78492
78640
|
}
|
|
@@ -78712,7 +78860,7 @@ function readDirectDependencies(root) {
|
|
|
78712
78860
|
for (const c of LOCKFILES) {
|
|
78713
78861
|
if (familiesSeen.has(c.family)) continue;
|
|
78714
78862
|
const p = join26(root, c.file);
|
|
78715
|
-
if (!
|
|
78863
|
+
if (!existsSync22(p)) continue;
|
|
78716
78864
|
try {
|
|
78717
78865
|
const s = statSync7(p);
|
|
78718
78866
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
@@ -78732,7 +78880,7 @@ function readDirectDependencies(root) {
|
|
|
78732
78880
|
const direct = [];
|
|
78733
78881
|
for (const { c, path: path2 } of found) {
|
|
78734
78882
|
try {
|
|
78735
|
-
direct.push(...c.parse(
|
|
78883
|
+
direct.push(...c.parse(readFileSync22(path2, "utf8")).direct ?? []);
|
|
78736
78884
|
} catch {
|
|
78737
78885
|
}
|
|
78738
78886
|
}
|
|
@@ -78741,7 +78889,7 @@ function readDirectDependencies(root) {
|
|
|
78741
78889
|
}
|
|
78742
78890
|
function manifestPaths(root) {
|
|
78743
78891
|
try {
|
|
78744
|
-
const out2 =
|
|
78892
|
+
const out2 = execFileSync4("git", ["-C", root, "ls-files", "-z"], {
|
|
78745
78893
|
encoding: "utf8",
|
|
78746
78894
|
maxBuffer: 128 * 1024 * 1024,
|
|
78747
78895
|
windowsHide: true,
|
|
@@ -78775,14 +78923,14 @@ function manifestPaths(root) {
|
|
|
78775
78923
|
"project.godot"
|
|
78776
78924
|
];
|
|
78777
78925
|
return {
|
|
78778
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
78926
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync22(join26(root, f))),
|
|
78779
78927
|
tracked: false,
|
|
78780
78928
|
truncated: false
|
|
78781
78929
|
};
|
|
78782
78930
|
}
|
|
78783
78931
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
78784
78932
|
function rootDeclaresWorkspace(root, texts) {
|
|
78785
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
78933
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync22(join26(root, f)))) return true;
|
|
78786
78934
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
78787
78935
|
}
|
|
78788
78936
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -78800,7 +78948,7 @@ function scanManifests(root) {
|
|
|
78800
78948
|
try {
|
|
78801
78949
|
const s = statSync7(abs);
|
|
78802
78950
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
78803
|
-
texts.set(rel,
|
|
78951
|
+
texts.set(rel, readFileSync22(abs, "utf8"));
|
|
78804
78952
|
} catch {
|
|
78805
78953
|
}
|
|
78806
78954
|
}
|
|
@@ -78829,11 +78977,11 @@ function readManifestDependencies(root) {
|
|
|
78829
78977
|
}
|
|
78830
78978
|
|
|
78831
78979
|
// src/git-sensor.ts
|
|
78832
|
-
import { existsSync as
|
|
78980
|
+
import { existsSync as existsSync23, readFileSync as readFileSync23, watch as fsWatch } from "node:fs";
|
|
78833
78981
|
import { join as join27 } from "node:path";
|
|
78834
78982
|
function readFirstLine(path2) {
|
|
78835
78983
|
try {
|
|
78836
|
-
return
|
|
78984
|
+
return readFileSync23(path2, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
78837
78985
|
} catch {
|
|
78838
78986
|
return null;
|
|
78839
78987
|
}
|
|
@@ -78852,13 +79000,13 @@ function readGitRefState(gitDir) {
|
|
|
78852
79000
|
return {
|
|
78853
79001
|
branch,
|
|
78854
79002
|
sha: sha2,
|
|
78855
|
-
mergeHeadExists:
|
|
78856
|
-
origHeadExists:
|
|
79003
|
+
mergeHeadExists: existsSync23(join27(gitDir, "MERGE_HEAD")),
|
|
79004
|
+
origHeadExists: existsSync23(join27(gitDir, "ORIG_HEAD"))
|
|
78857
79005
|
};
|
|
78858
79006
|
}
|
|
78859
79007
|
function shaFromPackedRefs(gitDir, ref) {
|
|
78860
79008
|
try {
|
|
78861
|
-
for (const line of
|
|
79009
|
+
for (const line of readFileSync23(join27(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
78862
79010
|
const [sha2, name2] = line.split(/\s+/);
|
|
78863
79011
|
if (name2 === ref && sha2) return sha2;
|
|
78864
79012
|
}
|
|
@@ -78892,7 +79040,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
78892
79040
|
const settle = () => {
|
|
78893
79041
|
if (timer) clearTimeout(timer);
|
|
78894
79042
|
timer = setTimeout(() => {
|
|
78895
|
-
if (
|
|
79043
|
+
if (existsSync23(join27(gitDir, "index.lock"))) {
|
|
78896
79044
|
settle();
|
|
78897
79045
|
return;
|
|
78898
79046
|
}
|
|
@@ -79127,7 +79275,7 @@ var TelemetryRecorder = class {
|
|
|
79127
79275
|
};
|
|
79128
79276
|
|
|
79129
79277
|
// src/file-activity.ts
|
|
79130
|
-
import { readFileSync as
|
|
79278
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
79131
79279
|
import { join as join29 } from "node:path";
|
|
79132
79280
|
import { createHash as createHash17 } from "node:crypto";
|
|
79133
79281
|
|
|
@@ -79880,7 +80028,7 @@ init_git_remote();
|
|
|
79880
80028
|
// src/history-bundle.ts
|
|
79881
80029
|
init_src();
|
|
79882
80030
|
import { execFile as execFile2 } from "node:child_process";
|
|
79883
|
-
import { readFileSync as
|
|
80031
|
+
import { readFileSync as readFileSync24 } from "node:fs";
|
|
79884
80032
|
import { join as join28 } from "node:path";
|
|
79885
80033
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
79886
80034
|
var FILE_LIST_CAP = 60;
|
|
@@ -79916,7 +80064,7 @@ function pathAllowedByFloor(path2) {
|
|
|
79916
80064
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
79917
80065
|
let source = "";
|
|
79918
80066
|
try {
|
|
79919
|
-
source =
|
|
80067
|
+
source = readFileSync24(join28(root, ".errataignore"), "utf8");
|
|
79920
80068
|
} catch {
|
|
79921
80069
|
source = "";
|
|
79922
80070
|
}
|
|
@@ -80209,7 +80357,7 @@ function readActivityBranch(root) {
|
|
|
80209
80357
|
try {
|
|
80210
80358
|
const gitDir = resolveGitDir(root);
|
|
80211
80359
|
if (!gitDir) return null;
|
|
80212
|
-
const head2 =
|
|
80360
|
+
const head2 = readFileSync25(join29(gitDir, "HEAD"), "utf8").trim();
|
|
80213
80361
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
80214
80362
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
80215
80363
|
} catch {
|
|
@@ -80366,11 +80514,11 @@ var FileActivityReporter = class {
|
|
|
80366
80514
|
|
|
80367
80515
|
// src/skills.ts
|
|
80368
80516
|
import {
|
|
80369
|
-
existsSync as
|
|
80517
|
+
existsSync as existsSync24,
|
|
80370
80518
|
mkdirSync as mkdirSync7,
|
|
80371
|
-
readFileSync as
|
|
80519
|
+
readFileSync as readFileSync26,
|
|
80372
80520
|
readdirSync as readdirSync8,
|
|
80373
|
-
unlinkSync as
|
|
80521
|
+
unlinkSync as unlinkSync3,
|
|
80374
80522
|
writeFileSync as writeFileSync17
|
|
80375
80523
|
} from "node:fs";
|
|
80376
80524
|
import { basename as basename6, join as join30 } from "node:path";
|
|
@@ -80378,9 +80526,9 @@ function skillFileName(id) {
|
|
|
80378
80526
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
80379
80527
|
}
|
|
80380
80528
|
function readSkillManifest(manifestPath) {
|
|
80381
|
-
if (!
|
|
80529
|
+
if (!existsSync24(manifestPath)) return [];
|
|
80382
80530
|
try {
|
|
80383
|
-
const parsed = JSON.parse(
|
|
80531
|
+
const parsed = JSON.parse(readFileSync26(manifestPath, "utf8"));
|
|
80384
80532
|
return (parsed.skills ?? []).map((s) => ({
|
|
80385
80533
|
title: s.title ?? "",
|
|
80386
80534
|
layer: s.layer ?? "technique",
|
|
@@ -80431,7 +80579,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80431
80579
|
if (!f.endsWith(".md")) continue;
|
|
80432
80580
|
if (keep.has(basename6(f))) continue;
|
|
80433
80581
|
try {
|
|
80434
|
-
|
|
80582
|
+
unlinkSync3(join30(paths.skillsDir, f));
|
|
80435
80583
|
pruned++;
|
|
80436
80584
|
} catch {
|
|
80437
80585
|
}
|
|
@@ -80449,10 +80597,10 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80449
80597
|
init_src2();
|
|
80450
80598
|
import {
|
|
80451
80599
|
cpSync,
|
|
80452
|
-
existsSync as
|
|
80600
|
+
existsSync as existsSync25,
|
|
80453
80601
|
lstatSync,
|
|
80454
80602
|
mkdirSync as mkdirSync8,
|
|
80455
|
-
readFileSync as
|
|
80603
|
+
readFileSync as readFileSync27,
|
|
80456
80604
|
readdirSync as readdirSync9,
|
|
80457
80605
|
rmSync as rmSync3,
|
|
80458
80606
|
symlinkSync,
|
|
@@ -80509,7 +80657,7 @@ function skillCiteHandle(s) {
|
|
|
80509
80657
|
return priorHandle({ id: s.id, description: s.title });
|
|
80510
80658
|
}
|
|
80511
80659
|
function reconcileNamespaced(dir, keep) {
|
|
80512
|
-
if (!
|
|
80660
|
+
if (!existsSync25(dir)) return 0;
|
|
80513
80661
|
let pruned = 0;
|
|
80514
80662
|
for (const name2 of readdirSync9(dir)) {
|
|
80515
80663
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
@@ -80523,7 +80671,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
80523
80671
|
}
|
|
80524
80672
|
function linkOrCopy(linkPath, target) {
|
|
80525
80673
|
try {
|
|
80526
|
-
if (
|
|
80674
|
+
if (existsSync25(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
80527
80675
|
} catch {
|
|
80528
80676
|
}
|
|
80529
80677
|
try {
|
|
@@ -80552,7 +80700,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80552
80700
|
for (const s of skills) {
|
|
80553
80701
|
let body2;
|
|
80554
80702
|
try {
|
|
80555
|
-
body2 =
|
|
80703
|
+
body2 = readFileSync27(s.bodyPath, "utf8");
|
|
80556
80704
|
} catch {
|
|
80557
80705
|
continue;
|
|
80558
80706
|
}
|
|
@@ -80572,7 +80720,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80572
80720
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
80573
80721
|
let projected = 0;
|
|
80574
80722
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
80575
|
-
if (!
|
|
80723
|
+
if (!existsSync25(join31(root, h.configDir))) continue;
|
|
80576
80724
|
const dir = join31(root, h.skillsDir);
|
|
80577
80725
|
mkdirSync8(dir, { recursive: true });
|
|
80578
80726
|
for (const slug2 of slugs) {
|
|
@@ -80585,9 +80733,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80585
80733
|
return { slugs, emitted, projected };
|
|
80586
80734
|
}
|
|
80587
80735
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
80588
|
-
if (!
|
|
80736
|
+
if (!existsSync25(manifestPath)) return [];
|
|
80589
80737
|
try {
|
|
80590
|
-
const parsed = JSON.parse(
|
|
80738
|
+
const parsed = JSON.parse(readFileSync27(manifestPath, "utf8"));
|
|
80591
80739
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
80592
80740
|
id: s.id,
|
|
80593
80741
|
title: s.title ?? s.id,
|
|
@@ -80610,7 +80758,7 @@ function ensureSkillGitignore(root) {
|
|
|
80610
80758
|
const path2 = join31(root, ".gitignore");
|
|
80611
80759
|
let current = "";
|
|
80612
80760
|
try {
|
|
80613
|
-
current =
|
|
80761
|
+
current = existsSync25(path2) ? readFileSync27(path2, "utf8") : "";
|
|
80614
80762
|
} catch {
|
|
80615
80763
|
return;
|
|
80616
80764
|
}
|
|
@@ -80628,7 +80776,7 @@ ${GITIGNORE_LINES.join("\n")}
|
|
|
80628
80776
|
var INTENT_TTL_MS = 15 * 60 * 1e3;
|
|
80629
80777
|
function createIntentState(ttlMs = INTENT_TTL_MS) {
|
|
80630
80778
|
const bySession = /* @__PURE__ */ new Map();
|
|
80631
|
-
let
|
|
80779
|
+
let recent3 = null;
|
|
80632
80780
|
const live3 = (s, nowMs) => s !== void 0 && nowMs - s.atMs < ttlMs;
|
|
80633
80781
|
return {
|
|
80634
80782
|
set(sessionId, text, nowMs) {
|
|
@@ -80636,8 +80784,8 @@ function createIntentState(ttlMs = INTENT_TTL_MS) {
|
|
|
80636
80784
|
if (!trimmed) return false;
|
|
80637
80785
|
const prev = bySession.get(sessionId);
|
|
80638
80786
|
bySession.set(sessionId, { text: trimmed, atMs: nowMs });
|
|
80639
|
-
const changed = !(
|
|
80640
|
-
|
|
80787
|
+
const changed = !(recent3 && recent3.text === trimmed);
|
|
80788
|
+
recent3 = { sessionId, text: trimmed, atMs: nowMs };
|
|
80641
80789
|
if (!changed && prev && prev.text === trimmed) return false;
|
|
80642
80790
|
return changed;
|
|
80643
80791
|
},
|
|
@@ -80646,12 +80794,12 @@ function createIntentState(ttlMs = INTENT_TTL_MS) {
|
|
|
80646
80794
|
return live3(s, nowMs) ? s.text : void 0;
|
|
80647
80795
|
},
|
|
80648
80796
|
mostRecent(nowMs) {
|
|
80649
|
-
if (!
|
|
80650
|
-
return nowMs -
|
|
80797
|
+
if (!recent3) return void 0;
|
|
80798
|
+
return nowMs - recent3.atMs < ttlMs ? recent3.text : void 0;
|
|
80651
80799
|
},
|
|
80652
80800
|
clear(sessionId) {
|
|
80653
80801
|
bySession.delete(sessionId);
|
|
80654
|
-
if (
|
|
80802
|
+
if (recent3?.sessionId === sessionId) recent3 = null;
|
|
80655
80803
|
}
|
|
80656
80804
|
};
|
|
80657
80805
|
}
|
|
@@ -80659,19 +80807,19 @@ function createIntentState(ttlMs = INTENT_TTL_MS) {
|
|
|
80659
80807
|
// src/working-file-state.ts
|
|
80660
80808
|
function createWorkingFileState() {
|
|
80661
80809
|
const bySession = /* @__PURE__ */ new Map();
|
|
80662
|
-
let
|
|
80810
|
+
let recent3 = null;
|
|
80663
80811
|
return {
|
|
80664
80812
|
set(sessionId, rel) {
|
|
80665
80813
|
bySession.set(sessionId, rel);
|
|
80666
|
-
if (rel ===
|
|
80667
|
-
|
|
80814
|
+
if (rel === recent3) return false;
|
|
80815
|
+
recent3 = rel;
|
|
80668
80816
|
return true;
|
|
80669
80817
|
},
|
|
80670
80818
|
get(sessionId) {
|
|
80671
80819
|
return bySession.get(sessionId);
|
|
80672
80820
|
},
|
|
80673
80821
|
mostRecent() {
|
|
80674
|
-
return
|
|
80822
|
+
return recent3;
|
|
80675
80823
|
}
|
|
80676
80824
|
};
|
|
80677
80825
|
}
|
|
@@ -80713,7 +80861,7 @@ init_paths();
|
|
|
80713
80861
|
init_profile2();
|
|
80714
80862
|
|
|
80715
80863
|
// src/witness-queue.ts
|
|
80716
|
-
import { readFileSync as
|
|
80864
|
+
import { readFileSync as readFileSync28, renameSync as renameSync2, writeFileSync as writeFileSync19 } from "node:fs";
|
|
80717
80865
|
import { dirname as dirname11, join as join32 } from "node:path";
|
|
80718
80866
|
var WITNESS_QUEUE_CAP = 500;
|
|
80719
80867
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
@@ -80724,7 +80872,7 @@ function witnessQueuePath(workspaceConfigDir) {
|
|
|
80724
80872
|
function loadWitnessQueueWithLosses(path2) {
|
|
80725
80873
|
let raw2;
|
|
80726
80874
|
try {
|
|
80727
|
-
raw2 = JSON.parse(
|
|
80875
|
+
raw2 = JSON.parse(readFileSync28(path2, "utf8"));
|
|
80728
80876
|
} catch (err2) {
|
|
80729
80877
|
const absent = err2?.code === "ENOENT";
|
|
80730
80878
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -81045,7 +81193,7 @@ function maybeFlushDigests() {
|
|
|
81045
81193
|
|
|
81046
81194
|
// src/liveness-watch.ts
|
|
81047
81195
|
init_src5();
|
|
81048
|
-
import { readFileSync as
|
|
81196
|
+
import { readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
|
|
81049
81197
|
import { join as join34 } from "node:path";
|
|
81050
81198
|
|
|
81051
81199
|
// src/loop-lag.ts
|
|
@@ -81054,7 +81202,7 @@ var RECENT_PASS_LIMIT = 12;
|
|
|
81054
81202
|
var active = /* @__PURE__ */ new Map();
|
|
81055
81203
|
var nextPassId = 1;
|
|
81056
81204
|
var started = false;
|
|
81057
|
-
var
|
|
81205
|
+
var recent2 = [];
|
|
81058
81206
|
function markPass(name2) {
|
|
81059
81207
|
const id = nextPassId++;
|
|
81060
81208
|
const startedAt = Date.now();
|
|
@@ -81064,8 +81212,8 @@ function markPass(name2) {
|
|
|
81064
81212
|
if (ended) return;
|
|
81065
81213
|
ended = true;
|
|
81066
81214
|
active.delete(id);
|
|
81067
|
-
|
|
81068
|
-
if (
|
|
81215
|
+
recent2.unshift({ name: name2, ms: Date.now() - startedAt, endedAt: Date.now() });
|
|
81216
|
+
if (recent2.length > RECENT_PASS_LIMIT) recent2.pop();
|
|
81069
81217
|
};
|
|
81070
81218
|
}
|
|
81071
81219
|
function oldestActive() {
|
|
@@ -81079,7 +81227,7 @@ function passState() {
|
|
|
81079
81227
|
current: oldest?.name ?? "idle",
|
|
81080
81228
|
runningMs: oldest === null ? null : now - oldest.startedAt,
|
|
81081
81229
|
active: [...active.values()].map((p) => ({ name: p.name, runningMs: now - p.startedAt })),
|
|
81082
|
-
recent: [...
|
|
81230
|
+
recent: [...recent2]
|
|
81083
81231
|
};
|
|
81084
81232
|
}
|
|
81085
81233
|
function describeHolders(running, finished, windowStart, now) {
|
|
@@ -81098,7 +81246,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
81098
81246
|
const now = Date.now();
|
|
81099
81247
|
const lag = now - last - HEARTBEAT_MS;
|
|
81100
81248
|
if (lag > thresholdMs) {
|
|
81101
|
-
const who = describeHolders(active.values(),
|
|
81249
|
+
const who = describeHolders(active.values(), recent2, last, now);
|
|
81102
81250
|
console.warn(
|
|
81103
81251
|
`[loop-lag] ${(/* @__PURE__ */ new Date()).toISOString()} event loop held ~${(lag / 1e3).toFixed(1)}s during "${who}"`
|
|
81104
81252
|
);
|
|
@@ -81181,7 +81329,7 @@ function alarmStatePath(configDir) {
|
|
|
81181
81329
|
}
|
|
81182
81330
|
function loadAlarmState(configDir) {
|
|
81183
81331
|
try {
|
|
81184
|
-
const raw2 = JSON.parse(
|
|
81332
|
+
const raw2 = JSON.parse(readFileSync30(alarmStatePath(configDir), "utf8"));
|
|
81185
81333
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
81186
81334
|
} catch {
|
|
81187
81335
|
return /* @__PURE__ */ new Map();
|
|
@@ -81342,8 +81490,8 @@ function createWatchBreaker(deps) {
|
|
|
81342
81490
|
windows2.set(watchedPath, w);
|
|
81343
81491
|
}
|
|
81344
81492
|
w.dispatched++;
|
|
81345
|
-
const
|
|
81346
|
-
if (!
|
|
81493
|
+
const self2 = evPath == null || evPath === "" || typeof evPath === "string" && normalizeWatchPath(evPath) === normalizeWatchPath(watchedPath);
|
|
81494
|
+
if (!self2) return;
|
|
81347
81495
|
w.self++;
|
|
81348
81496
|
if (!w.tripped && !quarantined.has(watchedPath) && w.self >= BREAKER_TRIP_SELF_EVENTS) {
|
|
81349
81497
|
w.tripped = true;
|
|
@@ -81358,7 +81506,7 @@ function createWatchBreaker(deps) {
|
|
|
81358
81506
|
}
|
|
81359
81507
|
|
|
81360
81508
|
// src/engine.ts
|
|
81361
|
-
var DAEMON_VERSION = true ? "2.0.16-dev.
|
|
81509
|
+
var DAEMON_VERSION = true ? "2.0.16-dev.3355" : "2.0.0-alpha.0";
|
|
81362
81510
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
81363
81511
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
81364
81512
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -81370,7 +81518,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
81370
81518
|
function appendIdentityAudit(path2, record2, line) {
|
|
81371
81519
|
if (!record2.accepted && record2.score <= 0) return;
|
|
81372
81520
|
try {
|
|
81373
|
-
if (
|
|
81521
|
+
if (existsSync27(path2) && statSync8(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
81374
81522
|
renameSync3(path2, `${path2}.1`);
|
|
81375
81523
|
}
|
|
81376
81524
|
appendFileSync4(path2, line);
|
|
@@ -81380,7 +81528,7 @@ function appendIdentityAudit(path2, record2, line) {
|
|
|
81380
81528
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
81381
81529
|
function loadTurnCursors(path2) {
|
|
81382
81530
|
try {
|
|
81383
|
-
const raw2 = JSON.parse(
|
|
81531
|
+
const raw2 = JSON.parse(readFileSync31(path2, "utf8"));
|
|
81384
81532
|
return new Map(
|
|
81385
81533
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
81386
81534
|
);
|
|
@@ -81390,7 +81538,7 @@ function loadTurnCursors(path2) {
|
|
|
81390
81538
|
}
|
|
81391
81539
|
function loadTurnOffsets(path2) {
|
|
81392
81540
|
try {
|
|
81393
|
-
const raw2 = JSON.parse(
|
|
81541
|
+
const raw2 = JSON.parse(readFileSync31(path2, "utf8"));
|
|
81394
81542
|
const out2 = /* @__PURE__ */ new Map();
|
|
81395
81543
|
for (const [k, v] of Object.entries(raw2)) {
|
|
81396
81544
|
const off = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -81413,7 +81561,7 @@ function saveTurnCursors(path2, cursors, offsets) {
|
|
|
81413
81561
|
function gitSourceWatchTargets(root) {
|
|
81414
81562
|
const SOURCE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
|
|
81415
81563
|
try {
|
|
81416
|
-
const lsOut =
|
|
81564
|
+
const lsOut = execFileSync5("git", ["-C", root, "ls-files", "-z"], {
|
|
81417
81565
|
encoding: "utf8",
|
|
81418
81566
|
maxBuffer: 128 * 1024 * 1024,
|
|
81419
81567
|
windowsHide: true,
|
|
@@ -81423,7 +81571,7 @@ function gitSourceWatchTargets(root) {
|
|
|
81423
81571
|
if (sourceFiles.length === 0) throw new Error("no tracked source");
|
|
81424
81572
|
let ignoredDirs = [];
|
|
81425
81573
|
try {
|
|
81426
|
-
const igOut =
|
|
81574
|
+
const igOut = execFileSync5(
|
|
81427
81575
|
"git",
|
|
81428
81576
|
["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
|
|
81429
81577
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
@@ -81695,7 +81843,7 @@ function createWorkspaceEngine(opts) {
|
|
|
81695
81843
|
);
|
|
81696
81844
|
};
|
|
81697
81845
|
const gitDir = join35(opts.workspaceRoot, ".git");
|
|
81698
|
-
if (
|
|
81846
|
+
if (existsSync27(gitDir)) {
|
|
81699
81847
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
81700
81848
|
void handleGitEvent(ev).catch((err2) => {
|
|
81701
81849
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -82496,7 +82644,7 @@ function createWorkspaceEngine(opts) {
|
|
|
82496
82644
|
let anchorReadFailed = false;
|
|
82497
82645
|
if (p.location) {
|
|
82498
82646
|
try {
|
|
82499
|
-
fileText =
|
|
82647
|
+
fileText = readFileSync31(join35(opts.workspaceRoot, p.location.path), "utf8");
|
|
82500
82648
|
} catch {
|
|
82501
82649
|
anchorReadFailed = true;
|
|
82502
82650
|
}
|
|
@@ -82656,7 +82804,7 @@ function createWorkspaceEngine(opts) {
|
|
|
82656
82804
|
const headSha = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
82657
82805
|
enclosing = {
|
|
82658
82806
|
line: p.location.line,
|
|
82659
|
-
fileText:
|
|
82807
|
+
fileText: readFileSync31(join35(opts.workspaceRoot, anchorPath), "utf8"),
|
|
82660
82808
|
...headSha ? { headSha } : {}
|
|
82661
82809
|
};
|
|
82662
82810
|
} catch {
|
|
@@ -83785,7 +83933,7 @@ B: ${b}`,
|
|
|
83785
83933
|
console.log(
|
|
83786
83934
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
83787
83935
|
);
|
|
83788
|
-
const pending =
|
|
83936
|
+
const pending = existsSync27(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
83789
83937
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
83790
83938
|
}
|
|
83791
83939
|
const onDisk = loadProfile(opts.workspaceRoot);
|
|
@@ -83793,7 +83941,7 @@ B: ${b}`,
|
|
|
83793
83941
|
console.log(
|
|
83794
83942
|
"[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
|
|
83795
83943
|
);
|
|
83796
|
-
const pending =
|
|
83944
|
+
const pending = existsSync27(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
83797
83945
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
83798
83946
|
}
|
|
83799
83947
|
try {
|
|
@@ -83929,7 +84077,7 @@ async function startDaemon(opts) {
|
|
|
83929
84077
|
);
|
|
83930
84078
|
await engine.stop();
|
|
83931
84079
|
try {
|
|
83932
|
-
if (
|
|
84080
|
+
if (existsSync28(engine.paths.daemonLock)) {
|
|
83933
84081
|
}
|
|
83934
84082
|
} catch {
|
|
83935
84083
|
}
|
|
@@ -84130,7 +84278,7 @@ function instanceReceiptSequence(n) {
|
|
|
84130
84278
|
// src/multi.ts
|
|
84131
84279
|
init_dist();
|
|
84132
84280
|
init_src5();
|
|
84133
|
-
import { existsSync as existsSync33, readFileSync as
|
|
84281
|
+
import { existsSync as existsSync33, readFileSync as readFileSync35, unlinkSync as unlinkSync4, writeFileSync as writeFileSync25 } from "node:fs";
|
|
84134
84282
|
import { resolve as pathResolve } from "node:path";
|
|
84135
84283
|
|
|
84136
84284
|
// src/principle-sync.ts
|
|
@@ -84159,7 +84307,7 @@ init_reconcile();
|
|
|
84159
84307
|
|
|
84160
84308
|
// src/lockfile-auto.ts
|
|
84161
84309
|
init_src();
|
|
84162
|
-
import { existsSync as
|
|
84310
|
+
import { existsSync as existsSync29, readFileSync as readFileSync32 } from "node:fs";
|
|
84163
84311
|
import { join as join36 } from "node:path";
|
|
84164
84312
|
|
|
84165
84313
|
// src/package-index.ts
|
|
@@ -84310,10 +84458,10 @@ function runLockfilePass(opts) {
|
|
|
84310
84458
|
];
|
|
84311
84459
|
for (const c of candidates) {
|
|
84312
84460
|
const p = join36(opts.root, c.file);
|
|
84313
|
-
if (!
|
|
84461
|
+
if (!existsSync29(p)) continue;
|
|
84314
84462
|
let sbom;
|
|
84315
84463
|
try {
|
|
84316
|
-
sbom = c.parse(
|
|
84464
|
+
sbom = c.parse(readFileSync32(p, "utf8"));
|
|
84317
84465
|
} catch {
|
|
84318
84466
|
continue;
|
|
84319
84467
|
}
|
|
@@ -84373,7 +84521,7 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
|
84373
84521
|
init_profile2();
|
|
84374
84522
|
|
|
84375
84523
|
// src/public-symbols.ts
|
|
84376
|
-
import { readFileSync as
|
|
84524
|
+
import { readFileSync as readFileSync33, readdirSync as readdirSync11, existsSync as existsSync30 } from "node:fs";
|
|
84377
84525
|
import { join as join37 } from "node:path";
|
|
84378
84526
|
var HEAD_BYTES = 8 * 1024;
|
|
84379
84527
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
@@ -84408,9 +84556,9 @@ function internalPackageNames(workspaceRoot) {
|
|
|
84408
84556
|
const names = /* @__PURE__ */ new Set();
|
|
84409
84557
|
const tryRead = (dir) => {
|
|
84410
84558
|
const pj = join37(dir, "package.json");
|
|
84411
|
-
if (!
|
|
84559
|
+
if (!existsSync30(pj)) return;
|
|
84412
84560
|
try {
|
|
84413
|
-
const name2 = JSON.parse(
|
|
84561
|
+
const name2 = JSON.parse(readFileSync33(pj, "utf8")).name;
|
|
84414
84562
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
84415
84563
|
} catch {
|
|
84416
84564
|
}
|
|
@@ -84418,7 +84566,7 @@ function internalPackageNames(workspaceRoot) {
|
|
|
84418
84566
|
tryRead(workspaceRoot);
|
|
84419
84567
|
for (const group of ["packages", "apps"]) {
|
|
84420
84568
|
const groupDir = join37(workspaceRoot, group);
|
|
84421
|
-
if (!
|
|
84569
|
+
if (!existsSync30(groupDir)) continue;
|
|
84422
84570
|
try {
|
|
84423
84571
|
for (const entry of readdirSync11(groupDir)) tryRead(join37(groupDir, entry));
|
|
84424
84572
|
} catch {
|
|
@@ -84439,7 +84587,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
84439
84587
|
}
|
|
84440
84588
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
84441
84589
|
try {
|
|
84442
|
-
return
|
|
84590
|
+
return readFileSync33(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
84443
84591
|
} catch {
|
|
84444
84592
|
return "";
|
|
84445
84593
|
}
|
|
@@ -85266,59 +85414,8 @@ function cloudTargetDrift(daemon, shell2) {
|
|
|
85266
85414
|
return out2;
|
|
85267
85415
|
}
|
|
85268
85416
|
|
|
85269
|
-
// src/lock.ts
|
|
85270
|
-
import { existsSync as existsSync30, readFileSync as readFileSync32 } from "node:fs";
|
|
85271
|
-
function daemonLockPayload(lock) {
|
|
85272
|
-
return JSON.stringify({
|
|
85273
|
-
pid: lock.pid,
|
|
85274
|
-
webUiUrl: lock.webUiUrl,
|
|
85275
|
-
startedAt: lock.processStartedAt,
|
|
85276
|
-
...lock.wokeAt !== void 0 ? { wokeAt: lock.wokeAt } : {},
|
|
85277
|
-
...lock.entry ? { entry: lock.entry } : {},
|
|
85278
|
-
...lock.version ? { version: lock.version } : {}
|
|
85279
|
-
});
|
|
85280
|
-
}
|
|
85281
|
-
var normEntry = (p) => {
|
|
85282
|
-
const s = p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
85283
|
-
return /^[A-Za-z]:\//.test(s) ? s.toLowerCase() : s;
|
|
85284
|
-
};
|
|
85285
|
-
function isInstalledEntry(entry) {
|
|
85286
|
-
return /\/node_modules\/@inerrata-corporation\/errata\//.test(normEntry(entry) + "/");
|
|
85287
|
-
}
|
|
85288
|
-
function foreignDaemonNote(lock, selfEntry) {
|
|
85289
|
-
if (!lock.entry || normEntry(lock.entry) === normEntry(selfEntry)) return null;
|
|
85290
|
-
const runningInstalled = isInstalledEntry(lock.entry);
|
|
85291
|
-
const head2 = [
|
|
85292
|
-
`launched from ${runningInstalled ? "the installed package" : "a LOCAL BUILD"}, not this one${lock.version ? ` (it is ${lock.version})` : ""}:`,
|
|
85293
|
-
` running: ${lock.entry}`,
|
|
85294
|
-
` this: ${selfEntry}`
|
|
85295
|
-
];
|
|
85296
|
-
return runningInstalled ? [...head2, "this CLI is a different bundle from the daemon it is talking to \u2014 its view may not match what the daemon runs."] : [...head2, "`errata update` does not replace it. To move onto the installed package: errata stop, then errata dash."];
|
|
85297
|
-
}
|
|
85298
|
-
function isProcessAlive(pid) {
|
|
85299
|
-
if (!pid || pid <= 0) return false;
|
|
85300
|
-
try {
|
|
85301
|
-
process.kill(pid, 0);
|
|
85302
|
-
return true;
|
|
85303
|
-
} catch (err2) {
|
|
85304
|
-
return err2.code === "EPERM";
|
|
85305
|
-
}
|
|
85306
|
-
}
|
|
85307
|
-
function readDaemonLock(lockPath) {
|
|
85308
|
-
if (!existsSync30(lockPath)) return null;
|
|
85309
|
-
try {
|
|
85310
|
-
const lock = JSON.parse(readFileSync32(lockPath, "utf8"));
|
|
85311
|
-
return typeof lock.pid === "number" ? lock : null;
|
|
85312
|
-
} catch {
|
|
85313
|
-
return null;
|
|
85314
|
-
}
|
|
85315
|
-
}
|
|
85316
|
-
function isDaemonAlive(lockPath) {
|
|
85317
|
-
const lock = readDaemonLock(lockPath);
|
|
85318
|
-
return lock !== null && isProcessAlive(lock.pid);
|
|
85319
|
-
}
|
|
85320
|
-
|
|
85321
85417
|
// src/multi.ts
|
|
85418
|
+
init_lock();
|
|
85322
85419
|
init_config();
|
|
85323
85420
|
|
|
85324
85421
|
// src/update.ts
|
|
@@ -86021,7 +86118,7 @@ async function syncHistoryRevisionPage(opts) {
|
|
|
86021
86118
|
init_src7();
|
|
86022
86119
|
init_src();
|
|
86023
86120
|
import { execFile as execFile5 } from "node:child_process";
|
|
86024
|
-
import { readFileSync as
|
|
86121
|
+
import { readFileSync as readFileSync34 } from "node:fs";
|
|
86025
86122
|
import { join as join38 } from "node:path";
|
|
86026
86123
|
import { promisify as promisify3 } from "node:util";
|
|
86027
86124
|
|
|
@@ -86569,7 +86666,7 @@ async function defaultGit(root, args2) {
|
|
|
86569
86666
|
function readIgnoreLines(root, profile) {
|
|
86570
86667
|
let lines = [];
|
|
86571
86668
|
try {
|
|
86572
|
-
lines =
|
|
86669
|
+
lines = readFileSync34(join38(root, ".errataignore"), "utf8").split("\n");
|
|
86573
86670
|
} catch {
|
|
86574
86671
|
}
|
|
86575
86672
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -86998,7 +87095,7 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
86998
87095
|
// src/link-flow.ts
|
|
86999
87096
|
init_cloud_auth();
|
|
87000
87097
|
import { createHash as createHash19 } from "node:crypto";
|
|
87001
|
-
import { execFileSync as
|
|
87098
|
+
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
87002
87099
|
import { existsSync as existsSync31, writeFileSync as writeFileSync24 } from "node:fs";
|
|
87003
87100
|
import { join as join39 } from "node:path";
|
|
87004
87101
|
|
|
@@ -87386,7 +87483,7 @@ async function linkThroughConsole(opts) {
|
|
|
87386
87483
|
function collectRepoFacts(root) {
|
|
87387
87484
|
const git3 = (args2) => {
|
|
87388
87485
|
try {
|
|
87389
|
-
return
|
|
87486
|
+
return execFileSync6("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
87390
87487
|
} catch {
|
|
87391
87488
|
return null;
|
|
87392
87489
|
}
|
|
@@ -87820,9 +87917,9 @@ function ownerOf(records, absPath) {
|
|
|
87820
87917
|
}
|
|
87821
87918
|
async function startMultiDaemon(opts = {}) {
|
|
87822
87919
|
const lockPath = globalDaemonLock();
|
|
87823
|
-
if (opts.enforceSingleton !== false &&
|
|
87920
|
+
if (opts.enforceSingleton !== false && daemonLockBlocksStartup(lockPath)) {
|
|
87824
87921
|
throw new Error(
|
|
87825
|
-
`
|
|
87922
|
+
`a daemon lock is live or its process ownership cannot be verified (lock: ${lockPath}). Run \`errata doctor\` to inspect it, or \`errata stop\` to stop a verified owner.`
|
|
87826
87923
|
);
|
|
87827
87924
|
}
|
|
87828
87925
|
const cfg = loadConfig();
|
|
@@ -89509,8 +89606,8 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89509
89606
|
clearInterval(anchorPull);
|
|
89510
89607
|
clearTimeout(codexWakeBoot);
|
|
89511
89608
|
try {
|
|
89512
|
-
const cur =
|
|
89513
|
-
if (JSON.parse(cur).pid === process.pid)
|
|
89609
|
+
const cur = readFileSync35(lockPath, "utf8");
|
|
89610
|
+
if (JSON.parse(cur).pid === process.pid) unlinkSync4(lockPath);
|
|
89514
89611
|
} catch {
|
|
89515
89612
|
}
|
|
89516
89613
|
await new Promise(
|
|
@@ -89870,6 +89967,7 @@ function openInBrowser(url2) {
|
|
|
89870
89967
|
// src/cli.ts
|
|
89871
89968
|
init_paths();
|
|
89872
89969
|
init_checkout_root();
|
|
89970
|
+
init_lock();
|
|
89873
89971
|
|
|
89874
89972
|
// src/cli-args.ts
|
|
89875
89973
|
var BURST_VALUE_FLAGS = /* @__PURE__ */ new Set(["--limit", "--hops", "--max-hops"]);
|
|
@@ -90072,7 +90170,7 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
90072
90170
|
import { createInterface } from "node:readline";
|
|
90073
90171
|
|
|
90074
90172
|
// src/codex-hooks.ts
|
|
90075
|
-
import { existsSync as existsSync34, mkdirSync as mkdirSync9, readFileSync as
|
|
90173
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync9, readFileSync as readFileSync36, writeFileSync as writeFileSync26 } from "node:fs";
|
|
90076
90174
|
import { homedir as homedir7 } from "node:os";
|
|
90077
90175
|
import { join as join42 } from "node:path";
|
|
90078
90176
|
|
|
@@ -90098,15 +90196,24 @@ function buildCodexHooksToml(port, options) {
|
|
|
90098
90196
|
};
|
|
90099
90197
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid hook port");
|
|
90100
90198
|
const command = (platform === "win32" ? "& " : "") + quote(options.nodePath) + " " + quote(options.relayPath) + " " + port;
|
|
90101
|
-
const
|
|
90102
|
-
|
|
90199
|
+
const status = {
|
|
90200
|
+
SessionStart: "errata: loading workspace priors",
|
|
90201
|
+
UserPromptSubmit: "errata: checking workspace priors",
|
|
90202
|
+
PreToolUse: "errata: checking relevant priors",
|
|
90203
|
+
PostToolUse: "errata: capturing feedback and checking priors",
|
|
90204
|
+
Stop: "errata: capturing session feedback"
|
|
90205
|
+
};
|
|
90206
|
+
const handlers = Object.keys(status).map(
|
|
90207
|
+
(event) => "[[hooks." + event + "]]\n" + (["UserPromptSubmit", "Stop"].includes(event) ? "" : 'matcher = ".*"\n') + "\n[[hooks." + event + '.hooks]]\ntype = "command"\ncommand = ' + JSON.stringify(command) + "\nstatusMessage = " + JSON.stringify(status[event]) + "\ntimeout = 10\n" + (event === "Stop" ? "" : "additionalContextLimit = 5000\n")
|
|
90103
90208
|
);
|
|
90104
90209
|
return CODEX_HOOKS_BEGIN + "\n" + handlers.join("\n") + CODEX_HOOKS_END + "\n";
|
|
90105
90210
|
}
|
|
90106
90211
|
|
|
90107
90212
|
// src/codex-hook-relay.ts
|
|
90108
90213
|
var CODEX_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata install-hooks codex
|
|
90109
|
-
import { readFileSync } from 'node:fs';
|
|
90214
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
90215
|
+
import { join } from 'node:path';
|
|
90216
|
+
const workspaceRoot = null;
|
|
90110
90217
|
|
|
90111
90218
|
try {
|
|
90112
90219
|
const payload = JSON.parse(readFileSync(0, 'utf8') || '{}');
|
|
@@ -90124,13 +90231,15 @@ try {
|
|
|
90124
90231
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
90125
90232
|
body: JSON.stringify(payload), signal: AbortSignal.timeout(2000),
|
|
90126
90233
|
});
|
|
90127
|
-
if (!response.ok
|
|
90234
|
+
if (!response.ok) return false;
|
|
90235
|
+
if (!relay) return true;
|
|
90128
90236
|
const result = await response.json();
|
|
90129
90237
|
const context = result.hookSpecificOutput?.additionalContext;
|
|
90130
90238
|
if (typeof context === 'string' && context.trim()) contexts.push(context);
|
|
90131
|
-
//
|
|
90239
|
+
// Codex exposes systemMessage to the UI/event stream; styling is host-owned.
|
|
90132
90240
|
if (typeof result.systemMessage === 'string' && result.systemMessage.trim()) messages.push(result.systemMessage);
|
|
90133
|
-
|
|
90241
|
+
return true;
|
|
90242
|
+
} catch { return false; /* An unavailable daemon must never block the agent. */ }
|
|
90134
90243
|
};
|
|
90135
90244
|
if (event === 'PreToolUse' || event === 'PostToolUse') await post('hook', true);
|
|
90136
90245
|
// Stop sees the final assistant message, including turns with no tools.
|
|
@@ -90138,7 +90247,23 @@ try {
|
|
|
90138
90247
|
if (['SessionStart', 'UserPromptSubmit', 'PostToolUse'].includes(event)) {
|
|
90139
90248
|
// Run after capture, so changes already rendered by the daemon arrive now.
|
|
90140
90249
|
// Background extraction finishing later arrives at the next tool boundary.
|
|
90141
|
-
await post('context-inject', true);
|
|
90250
|
+
const available = await post('context-inject', true);
|
|
90251
|
+
// Startup/resume/compaction must not depend on the daemon's busy event loop.
|
|
90252
|
+
// Read only the installer's resolved workspace, never a caller-supplied path
|
|
90253
|
+
// or tracked AGENTS.md. SessionStart already re-injects unconditionally;
|
|
90254
|
+
// prompt/tool refreshes retain daemon hash deduplication (no repeated copies).
|
|
90255
|
+
if (!available && event === 'SessionStart' && workspaceRoot) {
|
|
90256
|
+
try {
|
|
90257
|
+
const path = join(workspaceRoot, '.errata', 'context.md');
|
|
90258
|
+
if (statSync(path).size <= 128 * 1024) {
|
|
90259
|
+
const body = readFileSync(path, 'utf8').trim();
|
|
90260
|
+
if (body) {
|
|
90261
|
+
contexts.push('Errata loaded the maintained local workspace context while the daemon response was unavailable. This block REPLACES any earlier errata context block in this conversation. It is the last saved snapshot; live updates resume when the daemon responds.\n\n' + body);
|
|
90262
|
+
if (!/^(0|off|false|no)$/i.test((process.env.ERRATA_RECALL_CARD || '').trim())) messages.push('⚡ errata · saved workspace priors loaded');
|
|
90263
|
+
}
|
|
90264
|
+
}
|
|
90265
|
+
} catch { /* No saved context is honest; never substitute another project. */ }
|
|
90266
|
+
}
|
|
90142
90267
|
}
|
|
90143
90268
|
if (contexts.length || messages.length) {
|
|
90144
90269
|
process.stdout.write(JSON.stringify({
|
|
@@ -90150,8 +90275,12 @@ try {
|
|
|
90150
90275
|
}
|
|
90151
90276
|
} catch { /* Invalid input is also fail-open. */ }
|
|
90152
90277
|
`;
|
|
90278
|
+
function buildCodexRelaySource(workspaceRoot) {
|
|
90279
|
+
return CODEX_RELAY_SOURCE.replace("const workspaceRoot = null;", () => `const workspaceRoot = ${JSON.stringify(workspaceRoot)};`);
|
|
90280
|
+
}
|
|
90153
90281
|
|
|
90154
90282
|
// src/codex-hooks.ts
|
|
90283
|
+
init_checkout_root();
|
|
90155
90284
|
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.";
|
|
90156
90285
|
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join42(homedir7(), ".codex")) {
|
|
90157
90286
|
return existsSync34(join42(root, ".codex")) || existsSync34(codexHome);
|
|
@@ -90174,9 +90303,9 @@ function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
|
90174
90303
|
const file2 = join42(dir, "config.toml");
|
|
90175
90304
|
const relay = join42(dir, "hooks", "errata-relay.mjs");
|
|
90176
90305
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
90177
|
-
const final = replaceCodexHooks(existsSync34(file2) ?
|
|
90306
|
+
const final = replaceCodexHooks(existsSync34(file2) ? readFileSync36(file2, "utf8") : "", block);
|
|
90178
90307
|
mkdirSync9(join42(dir, "hooks"), { recursive: true });
|
|
90179
|
-
writeFileSync26(relay,
|
|
90308
|
+
writeFileSync26(relay, buildCodexRelaySource(checkoutRootOf(root)), "utf8");
|
|
90180
90309
|
writeFileSync26(file2, final, "utf8");
|
|
90181
90310
|
return file2;
|
|
90182
90311
|
}
|
|
@@ -90344,7 +90473,7 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
90344
90473
|
}
|
|
90345
90474
|
|
|
90346
90475
|
// src/claude-statusline.ts
|
|
90347
|
-
import { existsSync as existsSync35, mkdirSync as mkdirSync10, readFileSync as
|
|
90476
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync10, readFileSync as readFileSync37, writeFileSync as writeFileSync27 } from "node:fs";
|
|
90348
90477
|
import { homedir as homedir8 } from "node:os";
|
|
90349
90478
|
import { dirname as dirname13, join as join43 } from "node:path";
|
|
90350
90479
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
@@ -90390,7 +90519,7 @@ function ensureUserStatusLine(opts) {
|
|
|
90390
90519
|
let settings = {};
|
|
90391
90520
|
if (existsSync35(settingsPath)) {
|
|
90392
90521
|
try {
|
|
90393
|
-
const parsed = JSON.parse(
|
|
90522
|
+
const parsed = JSON.parse(readFileSync37(settingsPath, "utf8"));
|
|
90394
90523
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
90395
90524
|
settings = parsed;
|
|
90396
90525
|
} catch {
|
|
@@ -90400,7 +90529,7 @@ function ensureUserStatusLine(opts) {
|
|
|
90400
90529
|
if (settings["statusLine"] !== void 0 && !isErrataStatusLine(settings["statusLine"])) return "kept-own";
|
|
90401
90530
|
const relay = join43(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
90402
90531
|
mkdirSync10(opts.relayDir, { recursive: true });
|
|
90403
|
-
if (!existsSync35(relay) ||
|
|
90532
|
+
if (!existsSync35(relay) || readFileSync37(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
90404
90533
|
writeFileSync27(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
90405
90534
|
}
|
|
90406
90535
|
const next = buildStatusLine(opts.port, opts.nodePath ?? process.execPath, relay);
|
|
@@ -90943,6 +91072,9 @@ async function cmdStart() {
|
|
|
90943
91072
|
const lockPath = globalDaemonLock();
|
|
90944
91073
|
const running = isDaemonAlive(lockPath) ? readDaemonLock(lockPath) : null;
|
|
90945
91074
|
const where = profile ? `${profile.name} (${profile.id})` : ROOT;
|
|
91075
|
+
if (!running && daemonLockState(readDaemonLock(lockPath), true) === "unknown") {
|
|
91076
|
+
throw new Error(`Cannot verify the daemon process owning ${lockPath}; leaving it untouched. Run errata doctor to inspect it.`);
|
|
91077
|
+
}
|
|
90946
91078
|
if (running) {
|
|
90947
91079
|
console.log(`errata: workspace registered; attached to the running daemon`);
|
|
90948
91080
|
console.log(` workspace: ${where}`);
|
|
@@ -92001,7 +92133,7 @@ async function cmdReview() {
|
|
|
92001
92133
|
console.log("(review queue empty)");
|
|
92002
92134
|
return;
|
|
92003
92135
|
}
|
|
92004
|
-
const queue = JSON.parse(
|
|
92136
|
+
const queue = JSON.parse(readFileSync38(paths.reviewQueue, "utf8"));
|
|
92005
92137
|
if (queue.length === 0) {
|
|
92006
92138
|
console.log("(review queue empty)");
|
|
92007
92139
|
return;
|
|
@@ -92733,31 +92865,20 @@ async function cmdReport(args2) {
|
|
|
92733
92865
|
console.log(` open: file://${indexPath.replace(/\\/g, "/")}`);
|
|
92734
92866
|
}
|
|
92735
92867
|
async function cmdStop() {
|
|
92736
|
-
const { unlinkSync: unlinkSync4 } = await import("node:fs");
|
|
92737
92868
|
const lockPath = [globalDaemonLock(), workspacePaths(ROOT).daemonLock].find((p) => readDaemonLock(p) !== null);
|
|
92738
92869
|
if (!lockPath) {
|
|
92739
92870
|
console.log(`no daemon lock found \u2014 nothing to stop`);
|
|
92740
92871
|
return;
|
|
92741
92872
|
}
|
|
92742
|
-
const lock = readDaemonLock(lockPath);
|
|
92743
|
-
if (!isProcessAlive(lock.pid)) {
|
|
92744
|
-
try {
|
|
92745
|
-
unlinkSync4(lockPath);
|
|
92746
|
-
console.log(`removed stale lock (pid ${lock.pid} not running)`);
|
|
92747
|
-
} catch {
|
|
92748
|
-
}
|
|
92749
|
-
return;
|
|
92750
|
-
}
|
|
92751
92873
|
try {
|
|
92752
|
-
|
|
92753
|
-
console.log(`sent SIGTERM to daemon
|
|
92874
|
+
const result = stopLockedDaemon(lockPath);
|
|
92875
|
+
if (result === "signaled") console.log(`sent SIGTERM to the verified daemon process`);
|
|
92876
|
+
else if (result === "stale") console.log(`removed stale daemon lock; no process was signaled`);
|
|
92877
|
+
else if (result === "missing") console.log(`no daemon lock found \u2014 nothing to stop`);
|
|
92878
|
+
else throw new Error(`daemon lock ownership is ${result}; no process was signaled and the lock was preserved`);
|
|
92754
92879
|
} catch (err2) {
|
|
92755
|
-
console.warn(`could not
|
|
92756
|
-
|
|
92757
|
-
unlinkSync4(lockPath);
|
|
92758
|
-
console.log(`removed stale lock file`);
|
|
92759
|
-
} catch {
|
|
92760
|
-
}
|
|
92880
|
+
console.warn(`could not stop daemon: ${err2 instanceof Error ? err2.message : err2}`);
|
|
92881
|
+
process.exitCode = 1;
|
|
92761
92882
|
}
|
|
92762
92883
|
}
|
|
92763
92884
|
async function cmdMcp(args2) {
|
|
@@ -92768,9 +92889,9 @@ async function cmdMcp(args2) {
|
|
|
92768
92889
|
await runMcpServer2(ROOT, { toolNameStyle: grokCompatibility ? "bare" : "prefixed" });
|
|
92769
92890
|
}
|
|
92770
92891
|
function selfArgv(sub) {
|
|
92771
|
-
const
|
|
92772
|
-
if (/errata(\.exe)?$/i.test(
|
|
92773
|
-
return { cmd:
|
|
92892
|
+
const self2 = process.execPath;
|
|
92893
|
+
if (/errata(\.exe)?$/i.test(self2)) return { cmd: self2, args: [sub] };
|
|
92894
|
+
return { cmd: self2, args: [...process.execArgv, process.argv[1] ?? "", sub] };
|
|
92774
92895
|
}
|
|
92775
92896
|
function spawnDaemonDetached(options = {}) {
|
|
92776
92897
|
const { cmd: cmd2, args: args2 } = selfArgv("dash");
|
|
@@ -92805,11 +92926,11 @@ function spawnDaemonDetached(options = {}) {
|
|
|
92805
92926
|
}
|
|
92806
92927
|
function ensureSingletonRunning(options = {}) {
|
|
92807
92928
|
try {
|
|
92808
|
-
if (
|
|
92929
|
+
if (daemonLockBlocksStartup(globalDaemonLock())) return true;
|
|
92809
92930
|
spawnDaemonDetached(options);
|
|
92810
92931
|
void (async () => {
|
|
92811
92932
|
if (await waitForDaemon(globalDaemonLock(), 8e3)) return;
|
|
92812
|
-
if (
|
|
92933
|
+
if (daemonLockBlocksStartup(globalDaemonLock())) return;
|
|
92813
92934
|
spawnDaemonDetached(options);
|
|
92814
92935
|
await waitForDaemon(globalDaemonLock(), 8e3);
|
|
92815
92936
|
})();
|
|
@@ -92845,13 +92966,13 @@ async function cmdInstallHooks(args2) {
|
|
|
92845
92966
|
}
|
|
92846
92967
|
}
|
|
92847
92968
|
async function installOpencodePlugin(port) {
|
|
92848
|
-
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync:
|
|
92969
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync39, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92849
92970
|
const { join: join45 } = await import("node:path");
|
|
92850
92971
|
const dir = join45(ROOT, ".opencode", "plugin");
|
|
92851
92972
|
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
92852
92973
|
const file2 = join45(dir, "inerrata.js");
|
|
92853
92974
|
if (existsSync37(file2)) {
|
|
92854
|
-
const head2 =
|
|
92975
|
+
const head2 = readFileSync39(file2, "utf8").split("\n")[0] ?? "";
|
|
92855
92976
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
92856
92977
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
92857
92978
|
process.exit(2);
|
|
@@ -92862,7 +92983,7 @@ async function installOpencodePlugin(port) {
|
|
|
92862
92983
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
92863
92984
|
if (existsSync37(cfgFile)) {
|
|
92864
92985
|
try {
|
|
92865
|
-
cfg = JSON.parse(
|
|
92986
|
+
cfg = JSON.parse(readFileSync39(cfgFile, "utf8"));
|
|
92866
92987
|
} catch {
|
|
92867
92988
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
92868
92989
|
process.exit(2);
|
|
@@ -92900,7 +93021,7 @@ function ensureStatusLine(port) {
|
|
|
92900
93021
|
}
|
|
92901
93022
|
}
|
|
92902
93023
|
async function installClaudeHooks(port) {
|
|
92903
|
-
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync:
|
|
93024
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync39, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92904
93025
|
const { join: join45 } = await import("node:path");
|
|
92905
93026
|
const dir = join45(ROOT, ".claude");
|
|
92906
93027
|
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
@@ -92908,7 +93029,7 @@ async function installClaudeHooks(port) {
|
|
|
92908
93029
|
let settings = {};
|
|
92909
93030
|
if (existsSync37(file2)) {
|
|
92910
93031
|
try {
|
|
92911
|
-
settings = JSON.parse(
|
|
93032
|
+
settings = JSON.parse(readFileSync39(file2, "utf8"));
|
|
92912
93033
|
} catch {
|
|
92913
93034
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
92914
93035
|
process.exit(2);
|
|
@@ -92972,7 +93093,7 @@ async function installClaudeHooks(port) {
|
|
|
92972
93093
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
92973
93094
|
}
|
|
92974
93095
|
async function installClaudeMcpConfig() {
|
|
92975
|
-
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync:
|
|
93096
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync39, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92976
93097
|
const { join: join45, dirname: dirname14 } = await import("node:path");
|
|
92977
93098
|
const file2 = join45(ROOT, ".mcp.json");
|
|
92978
93099
|
const dir = dirname14(file2);
|
|
@@ -92980,7 +93101,7 @@ async function installClaudeMcpConfig() {
|
|
|
92980
93101
|
let cfg = {};
|
|
92981
93102
|
if (existsSync37(file2)) {
|
|
92982
93103
|
try {
|
|
92983
|
-
cfg = JSON.parse(
|
|
93104
|
+
cfg = JSON.parse(readFileSync39(file2, "utf8"));
|
|
92984
93105
|
} catch {
|
|
92985
93106
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
92986
93107
|
process.exit(2);
|
|
@@ -92994,7 +93115,7 @@ async function installClaudeMcpConfig() {
|
|
|
92994
93115
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
92995
93116
|
}
|
|
92996
93117
|
async function installCursorMcpConfig() {
|
|
92997
|
-
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync:
|
|
93118
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync39, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92998
93119
|
const { join: join45 } = await import("node:path");
|
|
92999
93120
|
const dir = join45(ROOT, ".cursor");
|
|
93000
93121
|
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
@@ -93002,7 +93123,7 @@ async function installCursorMcpConfig() {
|
|
|
93002
93123
|
let cfg = {};
|
|
93003
93124
|
if (existsSync37(file2)) {
|
|
93004
93125
|
try {
|
|
93005
|
-
cfg = JSON.parse(
|
|
93126
|
+
cfg = JSON.parse(readFileSync39(file2, "utf8"));
|
|
93006
93127
|
} catch {
|
|
93007
93128
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
93008
93129
|
process.exit(2);
|