@inerrata-corporation/errata 2.0.23-dev.4900 → 2.0.23-dev.4901
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/THIRD-PARTY-NOTICES.md +27 -0
- package/consolidate-worker.mjs +36 -5
- package/errata.mjs +827 -624
- package/generalize-worker.mjs +14 -0
- package/package.json +1 -1
- package/pass-worker.mjs +14 -0
- package/resources/context-plugin/.codex-plugin/plugin.json +1 -1
- package/resources/context-plugin/SHA256SUMS +1 -1
- package/resources/models/potion-base-8M.q8.bin +0 -0
package/errata.mjs
CHANGED
|
@@ -19589,7 +19589,7 @@ var init_lineage_integrity = __esm({
|
|
|
19589
19589
|
});
|
|
19590
19590
|
|
|
19591
19591
|
// ../../packages/math/src/constants.ts
|
|
19592
|
-
var SURPRISE_MOMENTUM, SURPRISE_LEARNING_RATE, SURPRISE_LEARNING_RATE_SCALING, TIER_HALFLIFE_MULTIPLIER, HIT_RATE_SCALING_ALPHA, BASE_HALF_LIFE_SEQ, MOMENTUM_GATE_FLOOR, EVIDENCE_HALFLIFE_SEQ, EVIDENCE_ACCEPTED_HALFLIFE_MULT, EVIDENCE_DECAY_FLOOR, CORROBORATION_WEIGHT, SURPRISE_RECENCY_LAMBDA_SEQ, NEMORI_SOFT_WRITE_MIN_COSINE, NEMORI_SOFT_WRITE_MAX_COSINE, NEMORI_DEDUP_COSINE, NEMORI_SOFT_ALPHA_MIN, NEMORI_SOFT_ALPHA_MAX, NEMORI_HIGH_SURPRISE_THRESHOLD,
|
|
19592
|
+
var SURPRISE_MOMENTUM, SURPRISE_LEARNING_RATE, SURPRISE_LEARNING_RATE_SCALING, TIER_HALFLIFE_MULTIPLIER, HIT_RATE_SCALING_ALPHA, BASE_HALF_LIFE_SEQ, MOMENTUM_GATE_FLOOR, EVIDENCE_HALFLIFE_SEQ, EVIDENCE_ACCEPTED_HALFLIFE_MULT, EVIDENCE_DECAY_FLOOR, CORROBORATION_WEIGHT, SURPRISE_RECENCY_LAMBDA_SEQ, NEMORI_SOFT_WRITE_MIN_COSINE, NEMORI_SOFT_WRITE_MAX_COSINE, NEMORI_DEDUP_COSINE, NEMORI_SOFT_ALPHA_MIN, NEMORI_SOFT_ALPHA_MAX, NEMORI_HIGH_SURPRISE_THRESHOLD, REVIEW_SURPRISE_THRESHOLD, REVIEW_HITS_THRESHOLD;
|
|
19593
19593
|
var init_constants = __esm({
|
|
19594
19594
|
"../../packages/math/src/constants.ts"() {
|
|
19595
19595
|
"use strict";
|
|
@@ -19615,7 +19615,6 @@ var init_constants = __esm({
|
|
|
19615
19615
|
NEMORI_SOFT_ALPHA_MIN = 0.6;
|
|
19616
19616
|
NEMORI_SOFT_ALPHA_MAX = 1;
|
|
19617
19617
|
NEMORI_HIGH_SURPRISE_THRESHOLD = 0.2;
|
|
19618
|
-
NEMORI_PREDICTION_FLOOR = 0.5;
|
|
19619
19618
|
REVIEW_SURPRISE_THRESHOLD = 3;
|
|
19620
19619
|
REVIEW_HITS_THRESHOLD = 5;
|
|
19621
19620
|
}
|
|
@@ -23839,49 +23838,231 @@ var init_problem_package_link = __esm({
|
|
|
23839
23838
|
}
|
|
23840
23839
|
});
|
|
23841
23840
|
|
|
23841
|
+
// ../../packages/embedding/src/static.ts
|
|
23842
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
|
|
23843
|
+
import { dirname as dirname4, join as join3 } from "node:path";
|
|
23844
|
+
import { fileURLToPath } from "node:url";
|
|
23845
|
+
function decodeStaticAsset(bytes) {
|
|
23846
|
+
const buf = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
23847
|
+
if (buf.toString("ascii", 0, 8) !== ASSET_MAGIC) throw new Error("static model: bad magic");
|
|
23848
|
+
const headerLength = buf.readUInt32LE(8);
|
|
23849
|
+
const header = JSON.parse(buf.toString("utf8", 12, 12 + headerLength));
|
|
23850
|
+
if (header.format !== 1) throw new Error(`static model: unsupported format ${String(header.format)}`);
|
|
23851
|
+
const lead2 = 12 + headerLength;
|
|
23852
|
+
const scalesAt = lead2 + (4 - lead2 % 4) % 4;
|
|
23853
|
+
const scales = new Float32Array(buf.buffer.slice(buf.byteOffset + scalesAt, buf.byteOffset + scalesAt + 4 * header.rows));
|
|
23854
|
+
const weightsAt = scalesAt + 4 * header.rows;
|
|
23855
|
+
const weights = new Int8Array(buf.buffer.slice(buf.byteOffset + weightsAt, buf.byteOffset + weightsAt + header.rows * header.dim));
|
|
23856
|
+
if (weights.length !== header.rows * header.dim) throw new Error("static model: truncated weights");
|
|
23857
|
+
return staticModel(header, scales, weights);
|
|
23858
|
+
}
|
|
23859
|
+
function staticModel(header, scales, weights) {
|
|
23860
|
+
const vocab = /* @__PURE__ */ new Map();
|
|
23861
|
+
header.vocab.forEach((token, id) => vocab.set(token, id));
|
|
23862
|
+
const unkId = vocab.get(header.unkToken);
|
|
23863
|
+
const { dim, rows, prefix, maxCharsPerWord } = header;
|
|
23864
|
+
function wordpiece(word) {
|
|
23865
|
+
const chars = Array.from(word);
|
|
23866
|
+
if (chars.length > maxCharsPerWord) return unkId === void 0 ? [] : [unkId];
|
|
23867
|
+
const ids = [];
|
|
23868
|
+
let start2 = 0;
|
|
23869
|
+
while (start2 < chars.length) {
|
|
23870
|
+
let end = chars.length;
|
|
23871
|
+
let found;
|
|
23872
|
+
while (start2 < end) {
|
|
23873
|
+
const piece = (start2 > 0 ? prefix : "") + chars.slice(start2, end).join("");
|
|
23874
|
+
found = vocab.get(piece);
|
|
23875
|
+
if (found !== void 0) break;
|
|
23876
|
+
end--;
|
|
23877
|
+
}
|
|
23878
|
+
if (found === void 0) return unkId === void 0 ? [] : [unkId];
|
|
23879
|
+
ids.push(found);
|
|
23880
|
+
start2 = end;
|
|
23881
|
+
}
|
|
23882
|
+
return ids;
|
|
23883
|
+
}
|
|
23884
|
+
function tokenize4(text) {
|
|
23885
|
+
return preTokenize(normalize2(text)).flatMap(wordpiece);
|
|
23886
|
+
}
|
|
23887
|
+
function embed2(text) {
|
|
23888
|
+
const sum = new Float64Array(dim);
|
|
23889
|
+
let used = 0;
|
|
23890
|
+
for (const id of tokenize4(text)) {
|
|
23891
|
+
if (id === unkId || id >= rows) continue;
|
|
23892
|
+
if (used++ >= MAX_TOKENS) break;
|
|
23893
|
+
const scale = scales[id];
|
|
23894
|
+
const offset = id * dim;
|
|
23895
|
+
for (let i2 = 0; i2 < dim; i2++) sum[i2] += weights[offset + i2] * scale;
|
|
23896
|
+
}
|
|
23897
|
+
let norm = 0;
|
|
23898
|
+
for (let i2 = 0; i2 < dim; i2++) norm += sum[i2] * sum[i2];
|
|
23899
|
+
norm = Math.sqrt(norm);
|
|
23900
|
+
const out2 = new Array(dim);
|
|
23901
|
+
for (let i2 = 0; i2 < dim; i2++) out2[i2] = norm > 0 ? sum[i2] / norm : 0;
|
|
23902
|
+
return out2;
|
|
23903
|
+
}
|
|
23904
|
+
return { version: header.version, dim, tokenize: tokenize4, embed: embed2 };
|
|
23905
|
+
}
|
|
23906
|
+
function isBertPunctuation(ch) {
|
|
23907
|
+
const c = ch.codePointAt(0);
|
|
23908
|
+
if (c >= 33 && c <= 47 || c >= 58 && c <= 64 || c >= 91 && c <= 96 || c >= 123 && c <= 126) return true;
|
|
23909
|
+
return new RegExp("\\p{P}", "u").test(ch);
|
|
23910
|
+
}
|
|
23911
|
+
function isCjk(c) {
|
|
23912
|
+
return c >= 19968 && c <= 40959 || c >= 13312 && c <= 19903 || c >= 131072 && c <= 173791 || c >= 173824 && c <= 177983 || c >= 177984 && c <= 178207 || c >= 178208 && c <= 183983 || c >= 63744 && c <= 64255 || c >= 194560 && c <= 195103;
|
|
23913
|
+
}
|
|
23914
|
+
function normalize2(text) {
|
|
23915
|
+
let out2 = "";
|
|
23916
|
+
for (const ch of text) {
|
|
23917
|
+
const c = ch.codePointAt(0);
|
|
23918
|
+
if (c === 0 || c === 65533) continue;
|
|
23919
|
+
if (/\s/u.test(ch)) {
|
|
23920
|
+
out2 += " ";
|
|
23921
|
+
continue;
|
|
23922
|
+
}
|
|
23923
|
+
if (new RegExp("\\p{C}", "u").test(ch)) continue;
|
|
23924
|
+
out2 += isCjk(c) ? ` ${ch} ` : ch;
|
|
23925
|
+
}
|
|
23926
|
+
return out2.toLowerCase().normalize("NFD").replace(new RegExp("\\p{Mn}", "gu"), "");
|
|
23927
|
+
}
|
|
23928
|
+
function preTokenize(text) {
|
|
23929
|
+
const words = [];
|
|
23930
|
+
for (const chunk of text.split(" ")) {
|
|
23931
|
+
let current = "";
|
|
23932
|
+
for (const ch of chunk) {
|
|
23933
|
+
if (isBertPunctuation(ch)) {
|
|
23934
|
+
if (current) words.push(current);
|
|
23935
|
+
words.push(ch);
|
|
23936
|
+
current = "";
|
|
23937
|
+
} else {
|
|
23938
|
+
current += ch;
|
|
23939
|
+
}
|
|
23940
|
+
}
|
|
23941
|
+
if (current) words.push(current);
|
|
23942
|
+
}
|
|
23943
|
+
return words;
|
|
23944
|
+
}
|
|
23945
|
+
function staticModelCandidates(moduleUrl = import.meta.url) {
|
|
23946
|
+
const here = dirname4(fileURLToPath(moduleUrl));
|
|
23947
|
+
const explicit = process.env["ERRATA_STATIC_MODEL"];
|
|
23948
|
+
return [
|
|
23949
|
+
...explicit ? [explicit] : [],
|
|
23950
|
+
join3(here, "resources", "models", STATIC_MODEL_FILE),
|
|
23951
|
+
join3(here, "..", "assets", STATIC_MODEL_FILE)
|
|
23952
|
+
];
|
|
23953
|
+
}
|
|
23954
|
+
function loadStaticModel() {
|
|
23955
|
+
if (loaded !== void 0) return loaded;
|
|
23956
|
+
const path3 = staticModelCandidates().find((p) => existsSync4(p));
|
|
23957
|
+
if (!path3) {
|
|
23958
|
+
loadError = new Error(`no static model asset (looked in: ${staticModelCandidates().join(", ")})`);
|
|
23959
|
+
loaded = null;
|
|
23960
|
+
return loaded;
|
|
23961
|
+
}
|
|
23962
|
+
try {
|
|
23963
|
+
loaded = decodeStaticAsset(readFileSync3(path3));
|
|
23964
|
+
} catch (err2) {
|
|
23965
|
+
loadError = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
23966
|
+
loaded = null;
|
|
23967
|
+
}
|
|
23968
|
+
return loaded;
|
|
23969
|
+
}
|
|
23970
|
+
function getStaticModelLoadError() {
|
|
23971
|
+
return loadError;
|
|
23972
|
+
}
|
|
23973
|
+
var STATIC_MODEL_FILE, ASSET_MAGIC, MAX_TOKENS, loaded, loadError;
|
|
23974
|
+
var init_static = __esm({
|
|
23975
|
+
"../../packages/embedding/src/static.ts"() {
|
|
23976
|
+
"use strict";
|
|
23977
|
+
STATIC_MODEL_FILE = "potion-base-8M.q8.bin";
|
|
23978
|
+
ASSET_MAGIC = "ERRSTAT1";
|
|
23979
|
+
MAX_TOKENS = 512;
|
|
23980
|
+
loadError = null;
|
|
23981
|
+
}
|
|
23982
|
+
});
|
|
23983
|
+
|
|
23984
|
+
// ../../packages/embedding/src/bands.ts
|
|
23985
|
+
function cosineBandsFor(version3) {
|
|
23986
|
+
return (version3 ? BANDS[version3] : void 0) ?? UNKNOWN;
|
|
23987
|
+
}
|
|
23988
|
+
var DESIGNED_FOR_MINILM, BANDS, UNKNOWN;
|
|
23989
|
+
var init_bands = __esm({
|
|
23990
|
+
"../../packages/embedding/src/bands.ts"() {
|
|
23991
|
+
"use strict";
|
|
23992
|
+
DESIGNED_FOR_MINILM = {
|
|
23993
|
+
dedup: 0.88,
|
|
23994
|
+
softWriteMin: 0.8,
|
|
23995
|
+
bindMin: 0.78,
|
|
23996
|
+
nearMiss: 0.72,
|
|
23997
|
+
judgeMin: 0.5,
|
|
23998
|
+
predictionFloor: 0.5,
|
|
23999
|
+
relevanceFloor: 0.25,
|
|
24000
|
+
relatedWeak: 0.35,
|
|
24001
|
+
relatedStrong: 0.45
|
|
24002
|
+
};
|
|
24003
|
+
BANDS = {
|
|
24004
|
+
"hash-v1": DESIGNED_FOR_MINILM,
|
|
24005
|
+
"minilm-l6-v2": DESIGNED_FOR_MINILM,
|
|
24006
|
+
"potion-8m-q8": {
|
|
24007
|
+
dedup: 0.895,
|
|
24008
|
+
softWriteMin: 0.835,
|
|
24009
|
+
bindMin: 0.83,
|
|
24010
|
+
nearMiss: 0.775,
|
|
24011
|
+
judgeMin: 0.335,
|
|
24012
|
+
predictionFloor: 0.335,
|
|
24013
|
+
relevanceFloor: 0.35,
|
|
24014
|
+
relatedWeak: 0.49,
|
|
24015
|
+
relatedStrong: 0.53
|
|
24016
|
+
}
|
|
24017
|
+
};
|
|
24018
|
+
UNKNOWN = { ...DESIGNED_FOR_MINILM, relevanceFloor: 0.5 };
|
|
24019
|
+
}
|
|
24020
|
+
});
|
|
24021
|
+
|
|
23842
24022
|
// ../../packages/embedding/src/model.ts
|
|
23843
|
-
import { mkdirSync as mkdirSync3, existsSync as
|
|
24023
|
+
import { mkdirSync as mkdirSync3, existsSync as existsSync5 } from "node:fs";
|
|
23844
24024
|
import { homedir } from "node:os";
|
|
23845
|
-
import { dirname as
|
|
24025
|
+
import { dirname as dirname5, join as join4 } from "node:path";
|
|
23846
24026
|
import { createRequire } from "node:module";
|
|
23847
24027
|
function semanticFloorFor(version3) {
|
|
23848
|
-
|
|
23849
|
-
return 0.5;
|
|
24028
|
+
return cosineBandsFor(version3).relevanceFloor;
|
|
23850
24029
|
}
|
|
23851
24030
|
function noteHashFallback() {
|
|
23852
24031
|
if (warnedHashFallback) return;
|
|
23853
24032
|
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") return;
|
|
23854
24033
|
warnedHashFallback = true;
|
|
23855
24034
|
console.warn(
|
|
23856
|
-
`[errata] embedding model unavailable (${
|
|
24035
|
+
`[errata] embedding model unavailable (static: ${getStaticModelLoadError()?.message ?? "unknown"}; transformers: ${lastError?.message ?? "not attempted"}) \u2014 falling back to ${EMBEDDING_VERSION} hash vectors; semantic ranking runs at reduced fidelity`
|
|
23857
24036
|
);
|
|
23858
24037
|
}
|
|
23859
24038
|
function getCacheDir() {
|
|
23860
|
-
return process.env["ERRATA_MODEL_CACHE"] ??
|
|
24039
|
+
return process.env["ERRATA_MODEL_CACHE"] ?? join4(homedir(), ".errata", "models");
|
|
23861
24040
|
}
|
|
23862
24041
|
async function loadTransformers() {
|
|
24042
|
+
let importError;
|
|
23863
24043
|
try {
|
|
23864
24044
|
return await import("@huggingface/transformers");
|
|
23865
24045
|
} catch (err2) {
|
|
23866
|
-
|
|
24046
|
+
importError = err2;
|
|
23867
24047
|
}
|
|
23868
24048
|
try {
|
|
23869
|
-
const seaResourceBase =
|
|
24049
|
+
const seaResourceBase = join4(
|
|
23870
24050
|
// execPath dir is where errata.exe lives; resources/ rides alongside.
|
|
23871
|
-
|
|
24051
|
+
dirname5(process.execPath),
|
|
23872
24052
|
"resources",
|
|
23873
24053
|
"_resolve.js"
|
|
23874
24054
|
);
|
|
23875
24055
|
const resourceRequire = createRequire(seaResourceBase);
|
|
23876
24056
|
return resourceRequire("@huggingface/transformers");
|
|
23877
24057
|
} catch (err2) {
|
|
23878
|
-
|
|
24058
|
+
const message2 = (e) => (e instanceof Error ? e.message : String(e)).split("\n")[0];
|
|
24059
|
+
lastError = new Error(`${message2(importError)} (SEA resources fallback: ${message2(err2)})`);
|
|
23879
24060
|
return null;
|
|
23880
24061
|
}
|
|
23881
24062
|
}
|
|
23882
24063
|
async function loadPipeline() {
|
|
23883
24064
|
const cacheDir = getCacheDir();
|
|
23884
|
-
if (!
|
|
24065
|
+
if (!existsSync5(cacheDir)) mkdirSync3(cacheDir, { recursive: true });
|
|
23885
24066
|
try {
|
|
23886
24067
|
const tx = await loadTransformers();
|
|
23887
24068
|
if (!tx) {
|
|
@@ -23920,6 +24101,14 @@ async function embedTextWithModel(text) {
|
|
|
23920
24101
|
const out2 = await pipe2(text, { pooling: "mean", normalize: true });
|
|
23921
24102
|
return Array.from(out2.data);
|
|
23922
24103
|
}
|
|
24104
|
+
function embedTextSync(text) {
|
|
24105
|
+
if (process.env["ERRATA_EMBED_HASH_ONLY"] !== "1") {
|
|
24106
|
+
const staticModel2 = loadStaticModel();
|
|
24107
|
+
if (staticModel2) return { vector: staticModel2.embed(text), version: staticModel2.version, dim: staticModel2.dim };
|
|
24108
|
+
}
|
|
24109
|
+
const v = embed(text);
|
|
24110
|
+
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
24111
|
+
}
|
|
23923
24112
|
async function embedBatchWithModelOrHash(texts) {
|
|
23924
24113
|
if (texts.length === 0) return [];
|
|
23925
24114
|
if (process.env["ERRATA_EMBED_HASH_ONLY"] === "1") {
|
|
@@ -23928,6 +24117,10 @@ async function embedBatchWithModelOrHash(texts) {
|
|
|
23928
24117
|
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
23929
24118
|
});
|
|
23930
24119
|
}
|
|
24120
|
+
const staticModel2 = loadStaticModel();
|
|
24121
|
+
if (staticModel2) {
|
|
24122
|
+
return texts.map((t) => ({ vector: staticModel2.embed(t), version: staticModel2.version, dim: staticModel2.dim }));
|
|
24123
|
+
}
|
|
23931
24124
|
try {
|
|
23932
24125
|
const pipe2 = await ensureModelLoaded();
|
|
23933
24126
|
if (pipe2) {
|
|
@@ -23957,6 +24150,10 @@ async function embedTextWithModelOrHash(text) {
|
|
|
23957
24150
|
const v = embed(text);
|
|
23958
24151
|
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
23959
24152
|
}
|
|
24153
|
+
const staticModel2 = loadStaticModel();
|
|
24154
|
+
if (staticModel2) {
|
|
24155
|
+
return { vector: staticModel2.embed(text), version: staticModel2.version, dim: staticModel2.dim };
|
|
24156
|
+
}
|
|
23960
24157
|
try {
|
|
23961
24158
|
const v = await embedTextWithModel(text);
|
|
23962
24159
|
return { vector: v, version: MODEL_EMBEDDING_VERSION, dim: v.length };
|
|
@@ -23971,6 +24168,8 @@ var init_model = __esm({
|
|
|
23971
24168
|
"../../packages/embedding/src/model.ts"() {
|
|
23972
24169
|
"use strict";
|
|
23973
24170
|
init_src4();
|
|
24171
|
+
init_static();
|
|
24172
|
+
init_bands();
|
|
23974
24173
|
MODEL_NAME = "Xenova/all-MiniLM-L6-v2";
|
|
23975
24174
|
MODEL_EMBEDDING_DIM = 384;
|
|
23976
24175
|
MODEL_EMBEDDING_VERSION = "minilm-l6-v2";
|
|
@@ -24035,6 +24234,8 @@ var init_src4 = __esm({
|
|
|
24035
24234
|
"../../packages/embedding/src/index.ts"() {
|
|
24036
24235
|
"use strict";
|
|
24037
24236
|
init_model();
|
|
24237
|
+
init_bands();
|
|
24238
|
+
init_static();
|
|
24038
24239
|
EMBEDDING_DIM = 256;
|
|
24039
24240
|
EMBEDDING_VERSION = "hash-v1";
|
|
24040
24241
|
}
|
|
@@ -24520,9 +24721,8 @@ function mintPatternNode(store, name2, ts) {
|
|
|
24520
24721
|
const emb = embed(display);
|
|
24521
24722
|
let best = null;
|
|
24522
24723
|
let bestCos = 0;
|
|
24523
|
-
for (const p of store.selectNodes({ labels: ["Pattern"]
|
|
24524
|
-
const e = p.
|
|
24525
|
-
if (!e || e.length !== EMBEDDING_DIM) continue;
|
|
24724
|
+
for (const p of store.selectNodes({ labels: ["Pattern"] })) {
|
|
24725
|
+
const e = embed(canonicalizePatternText(p.description));
|
|
24526
24726
|
let d = 0;
|
|
24527
24727
|
for (let i2 = 0; i2 < EMBEDDING_DIM; i2++) d += e[i2] * emb[i2];
|
|
24528
24728
|
if (d > bestCos) {
|
|
@@ -24532,13 +24732,7 @@ function mintPatternNode(store, name2, ts) {
|
|
|
24532
24732
|
}
|
|
24533
24733
|
const bestNode = best && bestCos >= PATTERN_DEDUP_COSINE ? store.getNode(best) : null;
|
|
24534
24734
|
if (bestNode) return reinforce(bestNode, display);
|
|
24535
|
-
store.mergeNode({
|
|
24536
|
-
...buildNode(store, id, "Pattern", display, ts, { source: "convo", provisional: true, observedCount: 1 }),
|
|
24537
|
-
// Embedded inline (sync hash) so the node participates in the gate
|
|
24538
|
-
// immediately — buildNode's empty embedding would leave every new pattern
|
|
24539
|
-
// invisible to dedup until the nightly embed pass.
|
|
24540
|
-
embedding: emb
|
|
24541
|
-
});
|
|
24735
|
+
store.mergeNode(buildNode(store, id, "Pattern", display, ts, { source: "convo", provisional: true, observedCount: 1 }));
|
|
24542
24736
|
return id;
|
|
24543
24737
|
}
|
|
24544
24738
|
function titleCaseDomain(name2) {
|
|
@@ -27283,14 +27477,15 @@ async function resolveFoldCandidates(store, opts) {
|
|
|
27283
27477
|
if (fresh.embedding.length > 0 && fresh.embedding.length === target.embedding.length && (fresh.attrs["embeddingVersion"] ?? "") === (target.attrs["embeddingVersion"] ?? "")) {
|
|
27284
27478
|
cos = cosine(fresh.embedding, target.embedding);
|
|
27285
27479
|
}
|
|
27286
|
-
|
|
27480
|
+
const bands = cosineBandsFor(fresh.attrs["embeddingVersion"]);
|
|
27481
|
+
if (cos !== null && cos >= bands.dedup) {
|
|
27287
27482
|
if (unseenMark(target)) neverExamined--;
|
|
27288
27483
|
foldPair(store, fresh, target, opts.ts);
|
|
27289
27484
|
report.folded++;
|
|
27290
27485
|
report.foldedEmbedding++;
|
|
27291
27486
|
continue;
|
|
27292
27487
|
}
|
|
27293
|
-
if (cos !== null && cos <
|
|
27488
|
+
if (cos !== null && cos < bands.judgeMin) {
|
|
27294
27489
|
clearCandidate(store, fresh, opts.ts, target.id);
|
|
27295
27490
|
report.rejected++;
|
|
27296
27491
|
continue;
|
|
@@ -29239,8 +29434,8 @@ var init_bleed_memory = __esm({
|
|
|
29239
29434
|
});
|
|
29240
29435
|
|
|
29241
29436
|
// ../../packages/context-writer/src/bleed-rules.ts
|
|
29242
|
-
import { existsSync as
|
|
29243
|
-
import { join as
|
|
29437
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
29438
|
+
import { join as join5 } from "node:path";
|
|
29244
29439
|
function formatRuleFile(item2) {
|
|
29245
29440
|
const frontmatter = item2.paths && item2.paths.length > 0 ? `---
|
|
29246
29441
|
paths:
|
|
@@ -29253,21 +29448,21 @@ ${item2.body.trim()}
|
|
|
29253
29448
|
`;
|
|
29254
29449
|
}
|
|
29255
29450
|
function bleedRules(rulesDir, items) {
|
|
29256
|
-
if (!
|
|
29451
|
+
if (!existsSync6(rulesDir)) mkdirSync4(rulesDir, { recursive: true });
|
|
29257
29452
|
const wanted = new Map(items.map((i2) => [fileFor(i2.slug), i2]));
|
|
29258
29453
|
let written = 0;
|
|
29259
29454
|
let created = 0;
|
|
29260
29455
|
for (const [file2, item2] of wanted) {
|
|
29261
|
-
const path3 =
|
|
29262
|
-
if (!
|
|
29456
|
+
const path3 = join5(rulesDir, file2);
|
|
29457
|
+
if (!existsSync6(path3)) created++;
|
|
29263
29458
|
writeFileSync4(path3, formatRuleFile(item2), "utf8");
|
|
29264
29459
|
written++;
|
|
29265
29460
|
}
|
|
29266
29461
|
let pruned = 0;
|
|
29267
29462
|
for (const f of readdirSync(rulesDir)) {
|
|
29268
29463
|
if (!f.startsWith(PREFIX) || !f.endsWith(".md") || wanted.has(f)) continue;
|
|
29269
|
-
if (
|
|
29270
|
-
rmSync(
|
|
29464
|
+
if (readFileSync4(join5(rulesDir, f), "utf8").includes(MARKER)) {
|
|
29465
|
+
rmSync(join5(rulesDir, f));
|
|
29271
29466
|
pruned++;
|
|
29272
29467
|
}
|
|
29273
29468
|
}
|
|
@@ -30650,9 +30845,9 @@ var init_src7 = __esm({
|
|
|
30650
30845
|
// src/owner-only-file.ts
|
|
30651
30846
|
import { chmodSync, statSync } from "node:fs";
|
|
30652
30847
|
import { execFileSync } from "node:child_process";
|
|
30653
|
-
import { join as
|
|
30848
|
+
import { join as join6 } from "node:path";
|
|
30654
30849
|
function system32(exe) {
|
|
30655
|
-
return
|
|
30850
|
+
return join6(process.env["SystemRoot"] ?? "C:\\Windows", "System32", exe);
|
|
30656
30851
|
}
|
|
30657
30852
|
function parseWhoamiSid(output) {
|
|
30658
30853
|
const match2 = /"(S-1-\d+(?:-\d+)+)"/.exec(output);
|
|
@@ -30797,33 +30992,33 @@ __export(paths_exports, {
|
|
|
30797
30992
|
});
|
|
30798
30993
|
import { execFile } from "node:child_process";
|
|
30799
30994
|
import { mkdirSync as mkdirSync5 } from "node:fs";
|
|
30800
|
-
import { dirname as
|
|
30995
|
+
import { dirname as dirname6, join as join7 } from "node:path";
|
|
30801
30996
|
function globalDir() {
|
|
30802
30997
|
const p = envPaths("errata", { suffix: "" });
|
|
30803
30998
|
return p.config;
|
|
30804
30999
|
}
|
|
30805
31000
|
function globalConfigPath() {
|
|
30806
|
-
return process.env["ERRATA_CONFIG_PATH"] ??
|
|
31001
|
+
return process.env["ERRATA_CONFIG_PATH"] ?? join7(globalDir(), "config.json");
|
|
30807
31002
|
}
|
|
30808
31003
|
function daemonLogPath() {
|
|
30809
31004
|
mkdirSync5(globalDir(), { recursive: true });
|
|
30810
|
-
return
|
|
31005
|
+
return join7(globalDir(), "daemon.log");
|
|
30811
31006
|
}
|
|
30812
31007
|
function globalDaemonLock() {
|
|
30813
|
-
return process.env["ERRATA_DAEMON_LOCK"] ??
|
|
31008
|
+
return process.env["ERRATA_DAEMON_LOCK"] ?? join7(globalDir(), "daemon.lock");
|
|
30814
31009
|
}
|
|
30815
31010
|
function sharedStorePath() {
|
|
30816
|
-
return process.env["ERRATA_SHARED_DB"] ??
|
|
31011
|
+
return process.env["ERRATA_SHARED_DB"] ?? join7(globalDir(), "shared", "graph.db");
|
|
30817
31012
|
}
|
|
30818
31013
|
function workspaceDir(workspaceRoot) {
|
|
30819
|
-
return
|
|
31014
|
+
return join7(workspaceRoot, ".errata");
|
|
30820
31015
|
}
|
|
30821
31016
|
function ensureDir(p) {
|
|
30822
31017
|
mkdirSync5(p, { recursive: true });
|
|
30823
31018
|
return p;
|
|
30824
31019
|
}
|
|
30825
31020
|
function ensureParent(p) {
|
|
30826
|
-
mkdirSync5(
|
|
31021
|
+
mkdirSync5(dirname6(p), { recursive: true });
|
|
30827
31022
|
return p;
|
|
30828
31023
|
}
|
|
30829
31024
|
function attribHasNotIndexed(attribOutput, path3) {
|
|
@@ -30834,7 +31029,7 @@ function excludeFromIndexing(dir, run3 = execFile) {
|
|
|
30834
31029
|
if (process.platform !== "win32") return;
|
|
30835
31030
|
run3("attrib", [dir], { windowsHide: true }, (err2, stdout) => {
|
|
30836
31031
|
if (err2 || attribHasNotIndexed(String(stdout), dir)) return;
|
|
30837
|
-
run3("attrib", ["+I",
|
|
31032
|
+
run3("attrib", ["+I", join7(dir, "*"), "/S", "/D"], { windowsHide: true }, () => {
|
|
30838
31033
|
run3("attrib", ["+I", dir], { windowsHide: true }, () => {
|
|
30839
31034
|
});
|
|
30840
31035
|
});
|
|
@@ -30845,15 +31040,15 @@ function workspacePaths(root) {
|
|
|
30845
31040
|
return {
|
|
30846
31041
|
root,
|
|
30847
31042
|
configDir: dir,
|
|
30848
|
-
workspaceJson:
|
|
30849
|
-
eventLog:
|
|
30850
|
-
castalia:
|
|
30851
|
-
reviewQueue:
|
|
30852
|
-
outbox:
|
|
30853
|
-
daemonLock:
|
|
30854
|
-
identityAudit:
|
|
30855
|
-
skillsDir:
|
|
30856
|
-
skillsManifest:
|
|
31043
|
+
workspaceJson: join7(dir, "workspace.json"),
|
|
31044
|
+
eventLog: join7(dir, "eventlog.sqlite"),
|
|
31045
|
+
castalia: join7(dir, "castalia.db"),
|
|
31046
|
+
reviewQueue: join7(dir, "review-queue.json"),
|
|
31047
|
+
outbox: join7(dir, "outbox"),
|
|
31048
|
+
daemonLock: join7(dir, "daemon.lock"),
|
|
31049
|
+
identityAudit: join7(dir, "identity-audit.log"),
|
|
31050
|
+
skillsDir: join7(dir, "skills"),
|
|
31051
|
+
skillsManifest: join7(dir, "skills.json")
|
|
30857
31052
|
};
|
|
30858
31053
|
}
|
|
30859
31054
|
var init_paths = __esm({
|
|
@@ -30864,7 +31059,7 @@ var init_paths = __esm({
|
|
|
30864
31059
|
});
|
|
30865
31060
|
|
|
30866
31061
|
// src/config.ts
|
|
30867
|
-
import { existsSync as
|
|
31062
|
+
import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
|
|
30868
31063
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
30869
31064
|
function mcpUrlFor(cloudUrl) {
|
|
30870
31065
|
return `${cloudUrl.replace(/\/+$/, "")}/mcp`;
|
|
@@ -30896,13 +31091,13 @@ function defaultConfig() {
|
|
|
30896
31091
|
}
|
|
30897
31092
|
function loadConfig() {
|
|
30898
31093
|
const p = globalConfigPath();
|
|
30899
|
-
if (!
|
|
31094
|
+
if (!existsSync7(p)) {
|
|
30900
31095
|
ensureDir(globalDir());
|
|
30901
31096
|
const cfg = defaultConfig();
|
|
30902
31097
|
saveConfig({ ...cfg, cloudUrl: DEFAULT_CLOUD_URL });
|
|
30903
31098
|
return cfg;
|
|
30904
31099
|
}
|
|
30905
|
-
const raw2 =
|
|
31100
|
+
const raw2 = readFileSync5(p, "utf8").replace(/^\uFEFF/, "");
|
|
30906
31101
|
const parsed = JSON.parse(raw2);
|
|
30907
31102
|
const base = defaultConfig();
|
|
30908
31103
|
const envCloudUrl = process.env["ERRATA_CLOUD_URL"];
|
|
@@ -33817,13 +34012,16 @@ var init_review_detector = __esm({
|
|
|
33817
34012
|
|
|
33818
34013
|
// ../../packages/generalizer/src/nemori-gate.ts
|
|
33819
34014
|
function nemoriDecide(input) {
|
|
33820
|
-
|
|
34015
|
+
const dedup = input.bands?.dedup ?? NEMORI_DEDUP_COSINE;
|
|
34016
|
+
const softWriteMin = input.bands?.softWriteMin ?? NEMORI_SOFT_WRITE_MIN_COSINE;
|
|
34017
|
+
const softWriteMax = input.bands ? dedup : NEMORI_SOFT_WRITE_MAX_COSINE;
|
|
34018
|
+
if (input.topCosine >= dedup && input.topId) {
|
|
33821
34019
|
return { kind: "REINFORCE", existingId: input.topId };
|
|
33822
34020
|
}
|
|
33823
34021
|
if (input.surprise >= NEMORI_HIGH_SURPRISE_THRESHOLD) {
|
|
33824
34022
|
return { kind: "WRITE_FULL", reason: "high-surprise" };
|
|
33825
34023
|
}
|
|
33826
|
-
const inSoftBand = input.topCosine >=
|
|
34024
|
+
const inSoftBand = input.topCosine >= softWriteMin && input.topCosine < softWriteMax;
|
|
33827
34025
|
if (input.isPredicted || inSoftBand) {
|
|
33828
34026
|
const s = Math.max(0, Math.min(1, input.surprise));
|
|
33829
34027
|
const alpha = NEMORI_SOFT_ALPHA_MIN + (NEMORI_SOFT_ALPHA_MAX - NEMORI_SOFT_ALPHA_MIN) * s;
|
|
@@ -33926,7 +34124,7 @@ var init_diagnostic_matcher = __esm({
|
|
|
33926
34124
|
});
|
|
33927
34125
|
|
|
33928
34126
|
// ../../packages/generalizer/src/generalizer.ts
|
|
33929
|
-
import { isAbsolute, join as
|
|
34127
|
+
import { isAbsolute, join as join8, relative } from "node:path";
|
|
33930
34128
|
async function runGeneralizer(opts) {
|
|
33931
34129
|
const report = {
|
|
33932
34130
|
eventsProcessed: 0,
|
|
@@ -34034,7 +34232,7 @@ function extractDiagnostics(ev) {
|
|
|
34034
34232
|
function diagRelPath(file2, cwd, workspaceRoot) {
|
|
34035
34233
|
const norm = (p) => p.replace(/\\/g, "/");
|
|
34036
34234
|
if (!workspaceRoot) return norm(file2);
|
|
34037
|
-
const abs = isAbsolute(file2) ? file2 :
|
|
34235
|
+
const abs = isAbsolute(file2) ? file2 : join8(cwd ?? workspaceRoot, file2);
|
|
34038
34236
|
return norm(relative(workspaceRoot, abs));
|
|
34039
34237
|
}
|
|
34040
34238
|
function extractErrorSignature(ev) {
|
|
@@ -34066,7 +34264,10 @@ function rankOpenProblemNeighbors(store, embedding, limit = 5) {
|
|
|
34066
34264
|
where: [{ embedding: embedding.vector.length > 0 ? "present" : "absent" }],
|
|
34067
34265
|
withEmbedding: true
|
|
34068
34266
|
}).filter(
|
|
34069
|
-
(p) => p.embedding.length === embedding.vector.length &&
|
|
34267
|
+
(p) => p.embedding.length === embedding.vector.length && // Unversioned vectors predate the model embedders: they are hash-v1. The
|
|
34268
|
+
// old "unversioned matches anything" leaned on hash-v1 (256-d) never
|
|
34269
|
+
// sharing a length with the model; potion-8m-q8 is 256-d too.
|
|
34270
|
+
String(p.attrs["embeddingVersion"] ?? EMBEDDING_VERSION) === embedding.version
|
|
34070
34271
|
).map((p) => ({ id: p.id, score: cosine(embedding.vector, p.embedding) })).sort((a, b) => b.score - a.score).slice(0, limit).map(({ id, score: score2 }) => {
|
|
34071
34272
|
const p = store.getNode(id);
|
|
34072
34273
|
return {
|
|
@@ -34079,8 +34280,6 @@ function rankOpenProblemNeighbors(store, embedding, limit = 5) {
|
|
|
34079
34280
|
});
|
|
34080
34281
|
}
|
|
34081
34282
|
function mergeProblemsByEmbedding(store, opts) {
|
|
34082
|
-
const minCosine = opts.minCosine ?? NEMORI_DEDUP_COSINE;
|
|
34083
|
-
const NEAR_MISS_FLOOR = 0.72;
|
|
34084
34283
|
const report = { clusters: 0, merged: 0, nearMissMarked: 0 };
|
|
34085
34284
|
if (opts.freshSince !== void 0 && store.countNodes({ labels: ["Problem"], where: [...OPEN_UNMERGED, HAS_VECTOR, { column: "created_at", gt: opts.freshSince }] }) === 0) {
|
|
34086
34285
|
return report;
|
|
@@ -34105,10 +34304,11 @@ function mergeProblemsByEmbedding(store, opts) {
|
|
|
34105
34304
|
if ((a.attrs["embeddingVersion"] ?? "") !== (b.attrs["embeddingVersion"] ?? "")) continue;
|
|
34106
34305
|
if (isConstraintProblem(a) !== isConstraintProblem(b)) continue;
|
|
34107
34306
|
const cos = cosine(a.embedding, b.embedding);
|
|
34108
|
-
|
|
34307
|
+
const bands = bandsOf(a);
|
|
34308
|
+
if (cos >= (opts.minCosine ?? bands.dedup)) {
|
|
34109
34309
|
cluster.push(b);
|
|
34110
34310
|
consumed.add(b.id);
|
|
34111
|
-
} else if (cos >=
|
|
34311
|
+
} else if (cos >= bands.nearMiss) {
|
|
34112
34312
|
const [younger, elder] = a.createdAt >= b.createdAt ? [a, b] : [b, a];
|
|
34113
34313
|
actions.push({ kind: "mark", younger: younger.id, elder: elder.id, cos });
|
|
34114
34314
|
}
|
|
@@ -34142,7 +34342,6 @@ function mergeProblemsByEmbedding(store, opts) {
|
|
|
34142
34342
|
return report;
|
|
34143
34343
|
}
|
|
34144
34344
|
function bindResolvedRegressions(store, opts) {
|
|
34145
|
-
const minCosine = opts.minCosine ?? NEMORI_DEDUP_COSINE;
|
|
34146
34345
|
const watermarkRaw = store.getMeta?.("regression_sweep_at") ?? null;
|
|
34147
34346
|
const full = watermarkRaw === null;
|
|
34148
34347
|
const since = full ? 0 : Number(watermarkRaw) || 0;
|
|
@@ -34172,7 +34371,7 @@ function bindResolvedRegressions(store, opts) {
|
|
|
34172
34371
|
if ((r.attrs["embeddingVersion"] ?? "") !== (f.attrs["embeddingVersion"] ?? "")) continue;
|
|
34173
34372
|
if (isConstraintProblem(f) !== isConstraintProblem(r)) continue;
|
|
34174
34373
|
const s = cosine(f.embedding, r.embedding);
|
|
34175
|
-
if (s >= minCosine && (!best || s > best.s)) best = { node: r, s };
|
|
34374
|
+
if (s >= (opts.minCosine ?? bandsOf(f).dedup) && (!best || s > best.s)) best = { node: r, s };
|
|
34176
34375
|
}
|
|
34177
34376
|
if (!best) continue;
|
|
34178
34377
|
if (store.outEdges(f.id, ["REGRESSION_OF"]).some((e) => e.to === best.node.id)) continue;
|
|
@@ -34221,13 +34420,14 @@ function bindCanonicalNeighbors(store, opts) {
|
|
|
34221
34420
|
store.outEdges(p.id, ["MATCHES", "INSTANCE_OF", "RELATES_TO"]).map((e) => e.to)
|
|
34222
34421
|
);
|
|
34223
34422
|
if (existing.size >= k) continue;
|
|
34423
|
+
const bands = bandsOf(p);
|
|
34224
34424
|
const ranked2 = pool.filter(
|
|
34225
34425
|
(c) => c.id !== p.id && !existing.has(c.id) && c.embedding.length === p.embedding.length && (c.attrs["embeddingVersion"] ?? "") === (p.attrs["embeddingVersion"] ?? "")
|
|
34226
|
-
).map((c) => ({ c, s: cosine(p.embedding, c.embedding) })).filter((x) => x.s >=
|
|
34426
|
+
).map((c) => ({ c, s: cosine(p.embedding, c.embedding) })).filter((x) => x.s >= bands.bindMin && x.s < bands.dedup).sort((a, b) => b.s - a.s);
|
|
34227
34427
|
const picked = [];
|
|
34228
34428
|
for (const cand of ranked2) {
|
|
34229
34429
|
if (picked.length + existing.size >= k) break;
|
|
34230
|
-
if (picked.some((q) => cosine(q.c.embedding, cand.c.embedding) >=
|
|
34430
|
+
if (picked.some((q) => cosine(q.c.embedding, cand.c.embedding) >= bands.dedup)) continue;
|
|
34231
34431
|
picked.push(cand);
|
|
34232
34432
|
}
|
|
34233
34433
|
for (const { c, s } of picked) {
|
|
@@ -34279,6 +34479,7 @@ async function ingestErrorSignature(opts, sig, commandSig) {
|
|
|
34279
34479
|
topCosine = 1;
|
|
34280
34480
|
topId = openMatch.id;
|
|
34281
34481
|
}
|
|
34482
|
+
const bands = cosineBandsFor(candidateEmbedding.version);
|
|
34282
34483
|
const titans = titansSurpriseFromNeighbors(neighbors);
|
|
34283
34484
|
const decision = nemoriDecide({
|
|
34284
34485
|
surprise: titans.surprise,
|
|
@@ -34287,7 +34488,8 @@ async function ingestErrorSignature(opts, sig, commandSig) {
|
|
|
34287
34488
|
// The prior (the neighbor search above) anticipated this if it surfaced a
|
|
34288
34489
|
// real neighbor — not just embedding noise. Below the soft band, so a
|
|
34289
34490
|
// low-surprise predicted observation dampens instead of writing full.
|
|
34290
|
-
isPredicted: topId !== null && topCosine >=
|
|
34491
|
+
isPredicted: topId !== null && topCosine >= bands.predictionFloor,
|
|
34492
|
+
bands
|
|
34291
34493
|
});
|
|
34292
34494
|
let node2;
|
|
34293
34495
|
const prevTier = openMatch?.memoryTier;
|
|
@@ -34952,7 +35154,7 @@ function reconcileDiagnostics(store, workspaceId2, relPath, diags, t, command) {
|
|
|
34952
35154
|
}
|
|
34953
35155
|
return { opened, resolved };
|
|
34954
35156
|
}
|
|
34955
|
-
var GENERALIZER_CURSOR, GENERALIZER_KINDS, GENERALIZER_BATCH, OPEN_UNMERGED, HAS_VECTOR,
|
|
35157
|
+
var bandsOf, GENERALIZER_CURSOR, GENERALIZER_KINDS, GENERALIZER_BATCH, OPEN_UNMERGED, HAS_VECTOR, ANCHOR_LABELS2, DIAG_SEVERITY_ERROR;
|
|
34956
35158
|
var init_generalizer = __esm({
|
|
34957
35159
|
"../../packages/generalizer/src/generalizer.ts"() {
|
|
34958
35160
|
"use strict";
|
|
@@ -34965,6 +35167,7 @@ var init_generalizer = __esm({
|
|
|
34965
35167
|
init_review_detector();
|
|
34966
35168
|
init_nemori_gate();
|
|
34967
35169
|
init_diagnostic_matcher();
|
|
35170
|
+
bandsOf = (n) => cosineBandsFor(n.attrs["embeddingVersion"]);
|
|
34968
35171
|
GENERALIZER_CURSOR = "generalizer";
|
|
34969
35172
|
GENERALIZER_KINDS = [
|
|
34970
35173
|
"shell.command",
|
|
@@ -34977,7 +35180,6 @@ var init_generalizer = __esm({
|
|
|
34977
35180
|
{ attr: "mergedInto", absent: true }
|
|
34978
35181
|
];
|
|
34979
35182
|
HAS_VECTOR = { embedding: "present" };
|
|
34980
|
-
CANONICAL_BIND_MIN = 0.78;
|
|
34981
35183
|
ANCHOR_LABELS2 = ["Function", "Method", "Class"];
|
|
34982
35184
|
DIAG_SEVERITY_ERROR = 1;
|
|
34983
35185
|
}
|
|
@@ -35508,8 +35710,7 @@ async function ensureNodeEmbedded(store, nodeId, opts = {}) {
|
|
|
35508
35710
|
let result;
|
|
35509
35711
|
try {
|
|
35510
35712
|
if (opts.mode === "hash") {
|
|
35511
|
-
|
|
35512
|
-
result = { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
35713
|
+
result = embedTextSync(text);
|
|
35513
35714
|
} else {
|
|
35514
35715
|
const r = (await embedBatchWithModelOrHash([text]))[0];
|
|
35515
35716
|
if (!r) return false;
|
|
@@ -35605,11 +35806,11 @@ async function embedNodesByLabels(store, labels, opts = {}) {
|
|
|
35605
35806
|
}
|
|
35606
35807
|
}
|
|
35607
35808
|
if (candidates.length === 0) {
|
|
35608
|
-
complete(held?.version ?? (hashOnly ?
|
|
35809
|
+
complete(held?.version ?? (hashOnly ? embedTextSync("").version : null));
|
|
35609
35810
|
report.durationMs = Date.now() - started2;
|
|
35610
35811
|
return report;
|
|
35611
35812
|
}
|
|
35612
|
-
const currentVersion = hashOnly ?
|
|
35813
|
+
const currentVersion = hashOnly ? embedTextSync("probe").version : (await embedBatchWithModelOrHash(["probe"]))[0]?.version ?? "unknown";
|
|
35613
35814
|
if (changedIds !== null && held?.version && held.version !== currentVersion) {
|
|
35614
35815
|
const { incrementalKey: _incremental, ...fullOpts } = opts;
|
|
35615
35816
|
return embedNodesByLabels(store, labels, fullOpts).then((full) => {
|
|
@@ -35632,10 +35833,7 @@ async function embedNodesByLabels(store, labels, opts = {}) {
|
|
|
35632
35833
|
const batch = todo.slice(i2, i2 + BATCH_SIZE);
|
|
35633
35834
|
let results;
|
|
35634
35835
|
try {
|
|
35635
|
-
results = hashOnly ? batch.map((b) =>
|
|
35636
|
-
const v = embed(b.text);
|
|
35637
|
-
return { vector: v, version: EMBEDDING_VERSION, dim: v.length };
|
|
35638
|
-
}) : await embedBatchWithModelOrHash(batch.map((b) => b.text));
|
|
35836
|
+
results = hashOnly ? batch.map((b) => embedTextSync(b.text)) : await embedBatchWithModelOrHash(batch.map((b) => b.text));
|
|
35639
35837
|
} catch {
|
|
35640
35838
|
report.failed += batch.length;
|
|
35641
35839
|
continue;
|
|
@@ -35711,7 +35909,7 @@ function nodeFreshness(node2, currentIngestSeq) {
|
|
|
35711
35909
|
});
|
|
35712
35910
|
}
|
|
35713
35911
|
function scoreCandidate(candidate, ctx = {}, weights) {
|
|
35714
|
-
const sameVersion =
|
|
35912
|
+
const sameVersion = String(candidate.attrs["embeddingVersion"] ?? EMBEDDING_VERSION) === String(ctx.seedEmbeddingVersion ?? EMBEDDING_VERSION);
|
|
35715
35913
|
const comparable = ctx.seedEmbedding != null && candidate.embedding.length === ctx.seedEmbedding.length && sameVersion;
|
|
35716
35914
|
const semantic = comparable ? cosine(ctx.seedEmbedding, candidate.embedding) : void 0;
|
|
35717
35915
|
const semanticUnknown = ctx.seedEmbedding != null && !comparable;
|
|
@@ -36353,8 +36551,8 @@ var init_recall_card = __esm({
|
|
|
36353
36551
|
});
|
|
36354
36552
|
|
|
36355
36553
|
// src/recall-signal.ts
|
|
36356
|
-
import { existsSync as
|
|
36357
|
-
import { join as
|
|
36554
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
36555
|
+
import { join as join9 } from "node:path";
|
|
36358
36556
|
function live(n) {
|
|
36359
36557
|
return n != null && n.validTo == null && historyReadPolicy(n, { mode: "passive" }).allow;
|
|
36360
36558
|
}
|
|
@@ -36423,17 +36621,17 @@ function contextCard(store, snapshot) {
|
|
|
36423
36621
|
return deliveredCard(store, intent ? `${count2} for \u201C${clipIntent(intent)}\u201D` : `${count2} in context`, delivered);
|
|
36424
36622
|
}
|
|
36425
36623
|
function writeContextCard(root, hash2, card) {
|
|
36426
|
-
writeFileSync6(
|
|
36624
|
+
writeFileSync6(join9(root, ".errata", CONTEXT_CARD_FILE), JSON.stringify({
|
|
36427
36625
|
hash: hash2,
|
|
36428
36626
|
card,
|
|
36429
36627
|
line: card && recallCardEnabled() ? renderRecallLine(card) : null
|
|
36430
36628
|
}));
|
|
36431
36629
|
}
|
|
36432
36630
|
function readContextCard(root, hash2) {
|
|
36433
|
-
const path3 =
|
|
36434
|
-
if (!
|
|
36631
|
+
const path3 = join9(root, ".errata", CONTEXT_CARD_FILE);
|
|
36632
|
+
if (!existsSync8(path3)) return null;
|
|
36435
36633
|
try {
|
|
36436
|
-
const saved = JSON.parse(
|
|
36634
|
+
const saved = JSON.parse(readFileSync6(path3, "utf8"));
|
|
36437
36635
|
return saved.hash === hash2 ? saved.card ?? null : null;
|
|
36438
36636
|
} catch {
|
|
36439
36637
|
return null;
|
|
@@ -36501,9 +36699,9 @@ var init_recall_signal = __esm({
|
|
|
36501
36699
|
});
|
|
36502
36700
|
|
|
36503
36701
|
// src/session-registry.ts
|
|
36504
|
-
import { existsSync as
|
|
36702
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, realpathSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
36505
36703
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
36506
|
-
import { basename as basename2, dirname as
|
|
36704
|
+
import { basename as basename2, dirname as dirname7, resolve } from "node:path";
|
|
36507
36705
|
function shipsFromWorkspace(root, env2 = process.env) {
|
|
36508
36706
|
return Boolean(env2["VITEST"]) || !isScratchWorkspace(root);
|
|
36509
36707
|
}
|
|
@@ -36511,8 +36709,8 @@ function isScratchWorkspace(root, tmp = tmpdir2()) {
|
|
|
36511
36709
|
const norm = (p) => {
|
|
36512
36710
|
let cursor = resolve(p);
|
|
36513
36711
|
const suffix = [];
|
|
36514
|
-
while (!
|
|
36515
|
-
const parent =
|
|
36712
|
+
while (!existsSync9(cursor)) {
|
|
36713
|
+
const parent = dirname7(cursor);
|
|
36516
36714
|
if (parent === cursor) break;
|
|
36517
36715
|
suffix.unshift(basename2(cursor));
|
|
36518
36716
|
cursor = parent;
|
|
@@ -36595,9 +36793,9 @@ function createSessionRegistry(opts = {}) {
|
|
|
36595
36793
|
return registry2;
|
|
36596
36794
|
}
|
|
36597
36795
|
function loadOrigins(path3) {
|
|
36598
|
-
if (!path3 || !
|
|
36796
|
+
if (!path3 || !existsSync9(path3)) return [];
|
|
36599
36797
|
try {
|
|
36600
|
-
const raw2 = JSON.parse(
|
|
36798
|
+
const raw2 = JSON.parse(readFileSync7(path3, "utf8"));
|
|
36601
36799
|
return Object.entries(raw2).flatMap(([k, v]) => typeof v === "string" ? [[k, v]] : []);
|
|
36602
36800
|
} catch {
|
|
36603
36801
|
return [];
|
|
@@ -36632,11 +36830,11 @@ var init_session_registry = __esm({
|
|
|
36632
36830
|
});
|
|
36633
36831
|
|
|
36634
36832
|
// src/review.ts
|
|
36635
|
-
import { existsSync as
|
|
36833
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
36636
36834
|
function loadReviewQueue(paths) {
|
|
36637
|
-
if (!
|
|
36835
|
+
if (!existsSync10(paths.reviewQueue)) return [];
|
|
36638
36836
|
try {
|
|
36639
|
-
return JSON.parse(
|
|
36837
|
+
return JSON.parse(readFileSync8(paths.reviewQueue, "utf8"));
|
|
36640
36838
|
} catch {
|
|
36641
36839
|
return [];
|
|
36642
36840
|
}
|
|
@@ -36713,14 +36911,14 @@ var init_consent = __esm({
|
|
|
36713
36911
|
|
|
36714
36912
|
// src/git-remote.ts
|
|
36715
36913
|
import { spawnSync } from "node:child_process";
|
|
36716
|
-
import { existsSync as
|
|
36717
|
-
import { isAbsolute as isAbsolute2, join as
|
|
36914
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, statSync as statSync3 } from "node:fs";
|
|
36915
|
+
import { isAbsolute as isAbsolute2, join as join10, resolve as resolve2 } from "node:path";
|
|
36718
36916
|
function resolveGitDir(root) {
|
|
36719
|
-
const dotGit =
|
|
36917
|
+
const dotGit = join10(root, ".git");
|
|
36720
36918
|
try {
|
|
36721
36919
|
const st = statSync3(dotGit);
|
|
36722
36920
|
if (st.isDirectory()) return dotGit;
|
|
36723
|
-
const m = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
36921
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync9(dotGit, "utf8"));
|
|
36724
36922
|
if (!m) return null;
|
|
36725
36923
|
const dir = m[1];
|
|
36726
36924
|
return isAbsolute2(dir) ? dir : resolve2(root, dir);
|
|
@@ -36729,22 +36927,22 @@ function resolveGitDir(root) {
|
|
|
36729
36927
|
}
|
|
36730
36928
|
}
|
|
36731
36929
|
function gitConfigPath(gitDir) {
|
|
36732
|
-
const commondirFile =
|
|
36733
|
-
if (
|
|
36734
|
-
const common =
|
|
36930
|
+
const commondirFile = join10(gitDir, "commondir");
|
|
36931
|
+
if (existsSync11(commondirFile)) {
|
|
36932
|
+
const common = readFileSync9(commondirFile, "utf8").trim();
|
|
36735
36933
|
const commonDir = isAbsolute2(common) ? common : resolve2(gitDir, common);
|
|
36736
|
-
return
|
|
36934
|
+
return join10(commonDir, "config");
|
|
36737
36935
|
}
|
|
36738
|
-
return
|
|
36936
|
+
return join10(gitDir, "config");
|
|
36739
36937
|
}
|
|
36740
36938
|
function readRemotes(root) {
|
|
36741
36939
|
const gitDir = resolveGitDir(root);
|
|
36742
36940
|
if (!gitDir) return [];
|
|
36743
36941
|
const cfgPath = gitConfigPath(gitDir);
|
|
36744
|
-
if (!
|
|
36942
|
+
if (!existsSync11(cfgPath)) return [];
|
|
36745
36943
|
let txt;
|
|
36746
36944
|
try {
|
|
36747
|
-
txt =
|
|
36945
|
+
txt = readFileSync9(cfgPath, "utf8");
|
|
36748
36946
|
} catch {
|
|
36749
36947
|
return [];
|
|
36750
36948
|
}
|
|
@@ -36799,9 +36997,9 @@ var init_git_remote = __esm({
|
|
|
36799
36997
|
});
|
|
36800
36998
|
|
|
36801
36999
|
// src/profile.ts
|
|
36802
|
-
import { existsSync as
|
|
37000
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
|
|
36803
37001
|
import { createHash as createHash5 } from "node:crypto";
|
|
36804
|
-
import { join as
|
|
37002
|
+
import { join as join11 } from "node:path";
|
|
36805
37003
|
function workspaceId(root) {
|
|
36806
37004
|
return "wp_" + createHash5("sha256").update(root).digest("hex").slice(0, 12);
|
|
36807
37005
|
}
|
|
@@ -36824,8 +37022,8 @@ function refreshRepoLocator(root, profile) {
|
|
|
36824
37022
|
}
|
|
36825
37023
|
function loadProfile(root) {
|
|
36826
37024
|
const p = workspacePaths(root);
|
|
36827
|
-
if (!
|
|
36828
|
-
return JSON.parse(
|
|
37025
|
+
if (!existsSync12(p.workspaceJson)) return null;
|
|
37026
|
+
return JSON.parse(readFileSync10(p.workspaceJson, "utf8"));
|
|
36829
37027
|
}
|
|
36830
37028
|
function saveProfile(root, profile) {
|
|
36831
37029
|
const p = workspacePaths(root);
|
|
@@ -36838,13 +37036,13 @@ function autodetectProfile(root) {
|
|
|
36838
37036
|
const p = emptyProfile(id, name2);
|
|
36839
37037
|
const locator = detectRepoLocator(root);
|
|
36840
37038
|
if (locator) p.repoLocator = locator;
|
|
36841
|
-
const pkgPath =
|
|
36842
|
-
if (
|
|
37039
|
+
const pkgPath = join11(root, "package.json");
|
|
37040
|
+
if (existsSync12(pkgPath)) {
|
|
36843
37041
|
try {
|
|
36844
|
-
const pkg = JSON.parse(
|
|
37042
|
+
const pkg = JSON.parse(readFileSync10(pkgPath, "utf8"));
|
|
36845
37043
|
const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
36846
37044
|
p.languages.push("javascript");
|
|
36847
|
-
if (
|
|
37045
|
+
if (existsSync12(join11(root, "tsconfig.json")) || deps["typescript"]) {
|
|
36848
37046
|
p.languages.push("typescript");
|
|
36849
37047
|
}
|
|
36850
37048
|
const nodeVer = pkg.engines?.node?.trim();
|
|
@@ -36865,10 +37063,10 @@ function autodetectProfile(root) {
|
|
|
36865
37063
|
} catch {
|
|
36866
37064
|
}
|
|
36867
37065
|
}
|
|
36868
|
-
const pyproject =
|
|
36869
|
-
if (
|
|
37066
|
+
const pyproject = join11(root, "pyproject.toml");
|
|
37067
|
+
if (existsSync12(pyproject)) {
|
|
36870
37068
|
try {
|
|
36871
|
-
const txt =
|
|
37069
|
+
const txt = readFileSync10(pyproject, "utf8");
|
|
36872
37070
|
const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
|
|
36873
37071
|
p.languages.push("python");
|
|
36874
37072
|
p.stack.push(`python@${py ?? "3"}`);
|
|
@@ -36879,16 +37077,16 @@ function autodetectProfile(root) {
|
|
|
36879
37077
|
} catch {
|
|
36880
37078
|
}
|
|
36881
37079
|
}
|
|
36882
|
-
const reqs =
|
|
36883
|
-
if (
|
|
37080
|
+
const reqs = join11(root, "requirements.txt");
|
|
37081
|
+
if (existsSync12(reqs)) {
|
|
36884
37082
|
if (!p.languages.includes("python")) p.languages.push("python");
|
|
36885
37083
|
if (!p.stack.includes("python@3")) p.stack.push("python@3");
|
|
36886
37084
|
}
|
|
36887
|
-
if (
|
|
37085
|
+
if (existsSync12(join11(root, "go.mod"))) {
|
|
36888
37086
|
p.languages.push("go");
|
|
36889
37087
|
p.stack.push("go");
|
|
36890
37088
|
}
|
|
36891
|
-
if (
|
|
37089
|
+
if (existsSync12(join11(root, "Cargo.toml"))) {
|
|
36892
37090
|
p.languages.push("rust");
|
|
36893
37091
|
p.stack.push("rust");
|
|
36894
37092
|
}
|
|
@@ -36993,32 +37191,32 @@ var init_identity2 = __esm({
|
|
|
36993
37191
|
});
|
|
36994
37192
|
|
|
36995
37193
|
// src/checkout-root.ts
|
|
36996
|
-
import { existsSync as
|
|
36997
|
-
import { basename as basename3, dirname as
|
|
37194
|
+
import { existsSync as existsSync13, readFileSync as readFileSync11 } from "node:fs";
|
|
37195
|
+
import { basename as basename3, dirname as dirname8, isAbsolute as isAbsolute3, join as join12, resolve as resolve3 } from "node:path";
|
|
36998
37196
|
function nearestGitRoot(dir) {
|
|
36999
37197
|
let cur = resolve3(dir);
|
|
37000
37198
|
for (; ; ) {
|
|
37001
|
-
if (
|
|
37002
|
-
const parent =
|
|
37199
|
+
if (existsSync13(join12(cur, ".git"))) return cur;
|
|
37200
|
+
const parent = dirname8(cur);
|
|
37003
37201
|
if (parent === cur) return null;
|
|
37004
37202
|
cur = parent;
|
|
37005
37203
|
}
|
|
37006
37204
|
}
|
|
37007
37205
|
function mainCheckoutOfWorktree(root) {
|
|
37008
37206
|
const gitDir = resolveGitDir(root);
|
|
37009
|
-
if (!gitDir || gitDir ===
|
|
37010
|
-
const commondirFile =
|
|
37011
|
-
if (!
|
|
37207
|
+
if (!gitDir || gitDir === join12(root, ".git")) return null;
|
|
37208
|
+
const commondirFile = join12(gitDir, "commondir");
|
|
37209
|
+
if (!existsSync13(commondirFile)) return null;
|
|
37012
37210
|
let common;
|
|
37013
37211
|
try {
|
|
37014
|
-
common =
|
|
37212
|
+
common = readFileSync11(commondirFile, "utf8").trim();
|
|
37015
37213
|
} catch {
|
|
37016
37214
|
return null;
|
|
37017
37215
|
}
|
|
37018
37216
|
const commonDir = resolve3(isAbsolute3(common) ? common : resolve3(gitDir, common));
|
|
37019
37217
|
if (basename3(commonDir) !== ".git") return null;
|
|
37020
|
-
const main2 =
|
|
37021
|
-
return
|
|
37218
|
+
const main2 = dirname8(commonDir);
|
|
37219
|
+
return existsSync13(join12(main2, ".git")) ? main2 : null;
|
|
37022
37220
|
}
|
|
37023
37221
|
function checkoutRootOf(cwd) {
|
|
37024
37222
|
const root = nearestGitRoot(cwd);
|
|
@@ -37037,7 +37235,7 @@ var init_checkout_root = __esm({
|
|
|
37037
37235
|
|
|
37038
37236
|
// src/process-identity.ts
|
|
37039
37237
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
37040
|
-
import { readFileSync as
|
|
37238
|
+
import { readFileSync as readFileSync12 } from "node:fs";
|
|
37041
37239
|
function readProcessIdentity(pid, fresh = false) {
|
|
37042
37240
|
if (!Number.isSafeInteger(pid) || pid <= 0) return null;
|
|
37043
37241
|
if (pid === process.pid && self) return self;
|
|
@@ -37062,10 +37260,10 @@ function readProcessIdentity(pid, fresh = false) {
|
|
|
37062
37260
|
if (!/^\d+$/.test(ticks)) return null;
|
|
37063
37261
|
value = { key: `win32:${ticks}`, bornAt: Number((BigInt(ticks) - 621355968000000000n) / 10000n) };
|
|
37064
37262
|
} else if (process.platform === "linux") {
|
|
37065
|
-
const stat4 =
|
|
37263
|
+
const stat4 = readFileSync12(`/proc/${pid}/stat`, "utf8");
|
|
37066
37264
|
const ticks = stat4.slice(stat4.lastIndexOf(")") + 2).split(" ")[19];
|
|
37067
|
-
const bootId =
|
|
37068
|
-
const boot = /^btime (\d+)$/m.exec(
|
|
37265
|
+
const bootId = readFileSync12("/proc/sys/kernel/random/boot_id", "utf8").trim();
|
|
37266
|
+
const boot = /^btime (\d+)$/m.exec(readFileSync12("/proc/stat", "utf8"))?.[1];
|
|
37069
37267
|
const hz = Number(run3("getconf", ["CLK_TCK"]));
|
|
37070
37268
|
if (!boot || !/^\d+$/.test(ticks) || !Number.isFinite(hz) || hz <= 0) return null;
|
|
37071
37269
|
value = { key: `linux:${bootId}:${ticks}`, bornAt: Number(boot) * 1e3 + Number(ticks) * 1e3 / hz };
|
|
@@ -37091,7 +37289,7 @@ var init_process_identity = __esm({
|
|
|
37091
37289
|
});
|
|
37092
37290
|
|
|
37093
37291
|
// src/lock.ts
|
|
37094
|
-
import { existsSync as
|
|
37292
|
+
import { existsSync as existsSync14, readFileSync as readFileSync13, unlinkSync as unlinkSync2 } from "node:fs";
|
|
37095
37293
|
function daemonLockPayload(lock) {
|
|
37096
37294
|
return JSON.stringify({
|
|
37097
37295
|
pid: lock.pid,
|
|
@@ -37133,9 +37331,9 @@ function isProcessAlive(pid) {
|
|
|
37133
37331
|
}
|
|
37134
37332
|
}
|
|
37135
37333
|
function readDaemonLock(lockPath) {
|
|
37136
|
-
if (!
|
|
37334
|
+
if (!existsSync14(lockPath)) return null;
|
|
37137
37335
|
try {
|
|
37138
|
-
return parseDaemonLock(
|
|
37336
|
+
return parseDaemonLock(readFileSync13(lockPath, "utf8"));
|
|
37139
37337
|
} catch {
|
|
37140
37338
|
return null;
|
|
37141
37339
|
}
|
|
@@ -37172,14 +37370,14 @@ async function waitForDaemonExit(lock, timeoutMs, pollMs = 200) {
|
|
|
37172
37370
|
}
|
|
37173
37371
|
function releaseOwnLock(lockPath) {
|
|
37174
37372
|
try {
|
|
37175
|
-
if (parseDaemonLock(
|
|
37373
|
+
if (parseDaemonLock(readFileSync13(lockPath, "utf8"))?.pid === process.pid) unlinkSync2(lockPath);
|
|
37176
37374
|
} catch {
|
|
37177
37375
|
}
|
|
37178
37376
|
}
|
|
37179
37377
|
function stopLockedDaemon(lockPath) {
|
|
37180
37378
|
let original;
|
|
37181
37379
|
try {
|
|
37182
|
-
original =
|
|
37380
|
+
original = readFileSync13(lockPath, "utf8");
|
|
37183
37381
|
} catch {
|
|
37184
37382
|
return "missing";
|
|
37185
37383
|
}
|
|
@@ -37187,7 +37385,7 @@ function stopLockedDaemon(lockPath) {
|
|
|
37187
37385
|
if (!lock) return "unknown";
|
|
37188
37386
|
const state = daemonLockState(lock, true);
|
|
37189
37387
|
try {
|
|
37190
|
-
if (
|
|
37388
|
+
if (readFileSync13(lockPath, "utf8") !== original) return "changed";
|
|
37191
37389
|
} catch {
|
|
37192
37390
|
return "changed";
|
|
37193
37391
|
}
|
|
@@ -37212,16 +37410,16 @@ var init_lock = __esm({
|
|
|
37212
37410
|
});
|
|
37213
37411
|
|
|
37214
37412
|
// src/registry.ts
|
|
37215
|
-
import { existsSync as
|
|
37216
|
-
import { join as
|
|
37413
|
+
import { existsSync as existsSync15, readFileSync as readFileSync14, writeFileSync as writeFileSync10 } from "node:fs";
|
|
37414
|
+
import { join as join13 } from "node:path";
|
|
37217
37415
|
function registryPath() {
|
|
37218
|
-
return process.env["ERRATA_REGISTRY_PATH"] ??
|
|
37416
|
+
return process.env["ERRATA_REGISTRY_PATH"] ?? join13(globalDir(), "workspaces.json");
|
|
37219
37417
|
}
|
|
37220
37418
|
function read() {
|
|
37221
37419
|
const p = registryPath();
|
|
37222
|
-
if (!
|
|
37420
|
+
if (!existsSync15(p)) return { version: 1, workspaces: {} };
|
|
37223
37421
|
try {
|
|
37224
|
-
const parsed = JSON.parse(
|
|
37422
|
+
const parsed = JSON.parse(readFileSync14(p, "utf8"));
|
|
37225
37423
|
return { version: 1, workspaces: parsed.workspaces ?? {} };
|
|
37226
37424
|
} catch {
|
|
37227
37425
|
return { version: 1, workspaces: {} };
|
|
@@ -37229,9 +37427,9 @@ function read() {
|
|
|
37229
37427
|
}
|
|
37230
37428
|
function registryCorrupt() {
|
|
37231
37429
|
const p = registryPath();
|
|
37232
|
-
if (!
|
|
37430
|
+
if (!existsSync15(p)) return false;
|
|
37233
37431
|
try {
|
|
37234
|
-
JSON.parse(
|
|
37432
|
+
JSON.parse(readFileSync14(p, "utf8"));
|
|
37235
37433
|
return false;
|
|
37236
37434
|
} catch {
|
|
37237
37435
|
return true;
|
|
@@ -37284,7 +37482,7 @@ function pruneMissingWorkspaces() {
|
|
|
37284
37482
|
const reg = read();
|
|
37285
37483
|
const removed = [];
|
|
37286
37484
|
for (const [id, entry] of Object.entries(reg.workspaces)) {
|
|
37287
|
-
if (!
|
|
37485
|
+
if (!existsSync15(entry.path)) {
|
|
37288
37486
|
removed.push(entry);
|
|
37289
37487
|
delete reg.workspaces[id];
|
|
37290
37488
|
}
|
|
@@ -37293,7 +37491,7 @@ function pruneMissingWorkspaces() {
|
|
|
37293
37491
|
return removed;
|
|
37294
37492
|
}
|
|
37295
37493
|
function workspaceStatus(entry) {
|
|
37296
|
-
const missing = !
|
|
37494
|
+
const missing = !existsSync15(entry.path);
|
|
37297
37495
|
const lockPath = workspacePaths(entry.path).daemonLock;
|
|
37298
37496
|
let running = false;
|
|
37299
37497
|
let webUiUrl = null;
|
|
@@ -39324,22 +39522,22 @@ var init_daemon_generalize_client = __esm({
|
|
|
39324
39522
|
|
|
39325
39523
|
// ../../packages/indexer/src/parse-cache.ts
|
|
39326
39524
|
import { createHash as createHash6 } from "node:crypto";
|
|
39327
|
-
import { existsSync as
|
|
39525
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, readFileSync as readFileSync15, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
39328
39526
|
import { homedir as homedir3 } from "node:os";
|
|
39329
|
-
import { join as
|
|
39527
|
+
import { join as join14 } from "node:path";
|
|
39330
39528
|
function parseCacheDir() {
|
|
39331
|
-
return process.env["ERRATA_PARSE_CACHE"] ??
|
|
39529
|
+
return process.env["ERRATA_PARSE_CACHE"] ?? join14(homedir3(), ".errata", "parse-cache");
|
|
39332
39530
|
}
|
|
39333
39531
|
function parseCacheKey(source, providerId) {
|
|
39334
39532
|
return createHash6("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
|
|
39335
39533
|
}
|
|
39336
39534
|
function entryPath(dir, key) {
|
|
39337
|
-
return
|
|
39535
|
+
return join14(dir, key.slice(0, 2), `${key.slice(2)}.json`);
|
|
39338
39536
|
}
|
|
39339
39537
|
function readParseCache(dir, key) {
|
|
39340
39538
|
const file2 = entryPath(dir, key);
|
|
39341
39539
|
try {
|
|
39342
|
-
const raw2 =
|
|
39540
|
+
const raw2 = readFileSync15(file2, "utf8");
|
|
39343
39541
|
const parsed = JSON.parse(raw2);
|
|
39344
39542
|
if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
|
|
39345
39543
|
return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
|
|
@@ -39358,7 +39556,7 @@ function writeParseCache(dir, key, providerId, value) {
|
|
|
39358
39556
|
const body2 = JSON.stringify(envelope);
|
|
39359
39557
|
if (body2.length > MAX_ENTRY_BYTES) return;
|
|
39360
39558
|
const file2 = entryPath(dir, key);
|
|
39361
|
-
mkdirSync6(
|
|
39559
|
+
mkdirSync6(join14(dir, key.slice(0, 2)), { recursive: true });
|
|
39362
39560
|
writeFileSync11(file2, body2);
|
|
39363
39561
|
} catch {
|
|
39364
39562
|
}
|
|
@@ -39368,9 +39566,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
39368
39566
|
sweptThisProcess = true;
|
|
39369
39567
|
let removed = 0;
|
|
39370
39568
|
try {
|
|
39371
|
-
if (!
|
|
39569
|
+
if (!existsSync16(dir)) return 0;
|
|
39372
39570
|
for (const bucket of readdirSync2(dir)) {
|
|
39373
|
-
const bucketDir =
|
|
39571
|
+
const bucketDir = join14(dir, bucket);
|
|
39374
39572
|
let names;
|
|
39375
39573
|
try {
|
|
39376
39574
|
names = readdirSync2(bucketDir);
|
|
@@ -39378,7 +39576,7 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
39378
39576
|
continue;
|
|
39379
39577
|
}
|
|
39380
39578
|
for (const name2 of names) {
|
|
39381
|
-
const file2 =
|
|
39579
|
+
const file2 = join14(bucketDir, name2);
|
|
39382
39580
|
try {
|
|
39383
39581
|
if (now - statSync4(file2).mtimeMs > ENTRY_TTL_MS) {
|
|
39384
39582
|
rmSync2(file2, { force: true });
|
|
@@ -39626,9 +39824,9 @@ var init_identity3 = __esm({
|
|
|
39626
39824
|
});
|
|
39627
39825
|
|
|
39628
39826
|
// ../../packages/indexer/src/pipeline.ts
|
|
39629
|
-
import { appendFileSync, readFileSync as
|
|
39827
|
+
import { appendFileSync, readFileSync as readFileSync16, statSync as statSync5 } from "node:fs";
|
|
39630
39828
|
import { readdir } from "node:fs/promises";
|
|
39631
|
-
import { extname, join as
|
|
39829
|
+
import { extname, join as join15, relative as relative2, sep } from "node:path";
|
|
39632
39830
|
import { createHash as createHash7 } from "node:crypto";
|
|
39633
39831
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
39634
39832
|
function nowTs() {
|
|
@@ -39777,7 +39975,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
39777
39975
|
for (const rel of [...changedRelPaths]) {
|
|
39778
39976
|
let h;
|
|
39779
39977
|
try {
|
|
39780
|
-
h = createHash7("sha256").update(
|
|
39978
|
+
h = createHash7("sha256").update(readFileSync16(join15(rootPath, rel))).digest("hex");
|
|
39781
39979
|
} catch {
|
|
39782
39980
|
continue;
|
|
39783
39981
|
}
|
|
@@ -39826,13 +40024,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
39826
40024
|
let parsedFiles = 0;
|
|
39827
40025
|
for (const rel of changedRelPaths) {
|
|
39828
40026
|
if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
|
|
39829
|
-
const abs =
|
|
40027
|
+
const abs = join15(rootPath, ...rel.split("/"));
|
|
39830
40028
|
const ext = extname(abs).toLowerCase();
|
|
39831
40029
|
const provider = providers.find((p) => p.fileExtensions.includes(ext));
|
|
39832
40030
|
if (!provider) continue;
|
|
39833
40031
|
let symbols;
|
|
39834
40032
|
try {
|
|
39835
|
-
symbols = provider.extractSymbols(
|
|
40033
|
+
symbols = provider.extractSymbols(readFileSync16(abs, "utf8"), abs);
|
|
39836
40034
|
} catch {
|
|
39837
40035
|
continue;
|
|
39838
40036
|
}
|
|
@@ -40176,7 +40374,7 @@ async function runIndexer(store, opts) {
|
|
|
40176
40374
|
report.filesSkipped++;
|
|
40177
40375
|
continue;
|
|
40178
40376
|
}
|
|
40179
|
-
source =
|
|
40377
|
+
source = readFileSync16(f.absPath, "utf8");
|
|
40180
40378
|
} catch {
|
|
40181
40379
|
report.filesSkipped++;
|
|
40182
40380
|
continue;
|
|
@@ -40255,7 +40453,7 @@ async function runIndexer(store, opts) {
|
|
|
40255
40453
|
const depth = fileNode.relPath.split("/").length;
|
|
40256
40454
|
if (depth !== 3) continue;
|
|
40257
40455
|
try {
|
|
40258
|
-
const pkg = JSON.parse(
|
|
40456
|
+
const pkg = JSON.parse(readFileSync16(fileNode.absPath, "utf8"));
|
|
40259
40457
|
if (!pkg.name) continue;
|
|
40260
40458
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
40261
40459
|
const candidates = [
|
|
@@ -40646,7 +40844,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
40646
40844
|
for (const ent of entries) {
|
|
40647
40845
|
if (ignores.has(ent.name)) continue;
|
|
40648
40846
|
if (ent.name.startsWith(".") && ent.name !== ".") continue;
|
|
40649
|
-
const abs =
|
|
40847
|
+
const abs = join15(current, ent.name);
|
|
40650
40848
|
if (ent.isDirectory()) {
|
|
40651
40849
|
await scan(root, abs, ignores, providers, out2);
|
|
40652
40850
|
} else if (ent.isFile()) {
|
|
@@ -40705,7 +40903,7 @@ function gitListFiles(root, ignores, providers) {
|
|
|
40705
40903
|
if (rels === null) return null;
|
|
40706
40904
|
const out2 = [];
|
|
40707
40905
|
for (const rel of rels) {
|
|
40708
|
-
const abs =
|
|
40906
|
+
const abs = join15(root, rel);
|
|
40709
40907
|
let size;
|
|
40710
40908
|
let mtimeMs;
|
|
40711
40909
|
try {
|
|
@@ -40734,7 +40932,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
|
|
|
40734
40932
|
if (existing && fileUnchanged(existing.attrs, f, skip)) return;
|
|
40735
40933
|
let contentHash;
|
|
40736
40934
|
try {
|
|
40737
|
-
contentHash = createHash7("sha256").update(
|
|
40935
|
+
contentHash = createHash7("sha256").update(readFileSync16(f.absPath)).digest("hex");
|
|
40738
40936
|
} catch {
|
|
40739
40937
|
}
|
|
40740
40938
|
const carried = { ...existing?.attrs ?? {} };
|
|
@@ -45116,43 +45314,43 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
45116
45314
|
});
|
|
45117
45315
|
|
|
45118
45316
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
45119
|
-
import { fileURLToPath } from "node:url";
|
|
45120
|
-
import { dirname as
|
|
45121
|
-
import { existsSync as
|
|
45317
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45318
|
+
import { dirname as dirname9, join as join16 } from "node:path";
|
|
45319
|
+
import { existsSync as existsSync17, readdirSync as readdirSync3 } from "node:fs";
|
|
45122
45320
|
import { createRequire as createRequire2 } from "node:module";
|
|
45123
45321
|
function entryDir() {
|
|
45124
45322
|
try {
|
|
45125
45323
|
const url2 = import.meta?.url;
|
|
45126
45324
|
if (typeof url2 === "string" && url2.length > 0) {
|
|
45127
|
-
return
|
|
45325
|
+
return dirname9(fileURLToPath2(url2));
|
|
45128
45326
|
}
|
|
45129
45327
|
} catch {
|
|
45130
45328
|
}
|
|
45131
|
-
return
|
|
45329
|
+
return dirname9(process.execPath);
|
|
45132
45330
|
}
|
|
45133
45331
|
function findWasmDir() {
|
|
45134
45332
|
const here = entryDir();
|
|
45135
|
-
const seaWasm =
|
|
45136
|
-
if (
|
|
45333
|
+
const seaWasm = join16(here, "resources", "wasm");
|
|
45334
|
+
if (existsSync17(join16(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
45137
45335
|
let dir = here;
|
|
45138
45336
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
45139
|
-
const flat =
|
|
45337
|
+
const flat = join16(
|
|
45140
45338
|
dir,
|
|
45141
45339
|
"node_modules",
|
|
45142
45340
|
"@vscode",
|
|
45143
45341
|
"tree-sitter-wasm",
|
|
45144
45342
|
"wasm"
|
|
45145
45343
|
);
|
|
45146
|
-
if (
|
|
45147
|
-
dir =
|
|
45344
|
+
if (existsSync17(join16(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
45345
|
+
dir = dirname9(dir);
|
|
45148
45346
|
}
|
|
45149
45347
|
let root = here;
|
|
45150
45348
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
45151
|
-
const pnpmDir =
|
|
45152
|
-
if (
|
|
45349
|
+
const pnpmDir = join16(root, "node_modules", ".pnpm");
|
|
45350
|
+
if (existsSync17(pnpmDir)) {
|
|
45153
45351
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
45154
45352
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
45155
|
-
const candidate =
|
|
45353
|
+
const candidate = join16(
|
|
45156
45354
|
pnpmDir,
|
|
45157
45355
|
entry,
|
|
45158
45356
|
"node_modules",
|
|
@@ -45160,13 +45358,13 @@ function findWasmDir() {
|
|
|
45160
45358
|
"tree-sitter-wasm",
|
|
45161
45359
|
"wasm"
|
|
45162
45360
|
);
|
|
45163
|
-
if (
|
|
45361
|
+
if (existsSync17(join16(candidate, "tree-sitter-typescript.wasm"))) {
|
|
45164
45362
|
return candidate;
|
|
45165
45363
|
}
|
|
45166
45364
|
}
|
|
45167
45365
|
}
|
|
45168
45366
|
}
|
|
45169
|
-
root =
|
|
45367
|
+
root = dirname9(root);
|
|
45170
45368
|
}
|
|
45171
45369
|
throw new Error(
|
|
45172
45370
|
"@vscode/tree-sitter-wasm grammar files not found \u2014 is the package installed?"
|
|
@@ -45174,33 +45372,33 @@ function findWasmDir() {
|
|
|
45174
45372
|
}
|
|
45175
45373
|
function findRuntimeDir() {
|
|
45176
45374
|
const here = entryDir();
|
|
45177
|
-
const seaRuntime =
|
|
45178
|
-
if (
|
|
45375
|
+
const seaRuntime = join16(here, "resources", "wasm");
|
|
45376
|
+
if (existsSync17(join16(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
45179
45377
|
let dir = here;
|
|
45180
45378
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
45181
|
-
const flat =
|
|
45182
|
-
if (
|
|
45183
|
-
dir =
|
|
45379
|
+
const flat = join16(dir, "node_modules", "web-tree-sitter");
|
|
45380
|
+
if (existsSync17(join16(flat, "web-tree-sitter.wasm"))) return flat;
|
|
45381
|
+
dir = dirname9(dir);
|
|
45184
45382
|
}
|
|
45185
45383
|
let root = here;
|
|
45186
45384
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
45187
|
-
const pnpmDir =
|
|
45188
|
-
if (
|
|
45385
|
+
const pnpmDir = join16(root, "node_modules", ".pnpm");
|
|
45386
|
+
if (existsSync17(pnpmDir)) {
|
|
45189
45387
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
45190
45388
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
45191
|
-
const candidate =
|
|
45389
|
+
const candidate = join16(
|
|
45192
45390
|
pnpmDir,
|
|
45193
45391
|
entry,
|
|
45194
45392
|
"node_modules",
|
|
45195
45393
|
"web-tree-sitter"
|
|
45196
45394
|
);
|
|
45197
|
-
if (
|
|
45395
|
+
if (existsSync17(join16(candidate, "web-tree-sitter.wasm"))) {
|
|
45198
45396
|
return candidate;
|
|
45199
45397
|
}
|
|
45200
45398
|
}
|
|
45201
45399
|
}
|
|
45202
45400
|
}
|
|
45203
|
-
root =
|
|
45401
|
+
root = dirname9(root);
|
|
45204
45402
|
}
|
|
45205
45403
|
throw new Error("web-tree-sitter runtime WASM not found");
|
|
45206
45404
|
}
|
|
@@ -45211,7 +45409,7 @@ async function loadWebTreeSitter() {
|
|
|
45211
45409
|
void err2;
|
|
45212
45410
|
}
|
|
45213
45411
|
const here = entryDir();
|
|
45214
|
-
const seaResourceBase =
|
|
45412
|
+
const seaResourceBase = join16(here, "resources", "_resolve.js");
|
|
45215
45413
|
const resourceRequire = createRequire2(seaResourceBase);
|
|
45216
45414
|
return resourceRequire("web-tree-sitter");
|
|
45217
45415
|
}
|
|
@@ -45226,9 +45424,9 @@ async function ensureTreeSitterReady() {
|
|
|
45226
45424
|
await Parser2.init({
|
|
45227
45425
|
locateFile: (name2) => {
|
|
45228
45426
|
if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
|
|
45229
|
-
return
|
|
45427
|
+
return join16(runtime, name2);
|
|
45230
45428
|
}
|
|
45231
|
-
return
|
|
45429
|
+
return join16(grammars, name2);
|
|
45232
45430
|
}
|
|
45233
45431
|
});
|
|
45234
45432
|
})();
|
|
@@ -45240,7 +45438,7 @@ async function loadGrammar(name2) {
|
|
|
45240
45438
|
if (cached2) return cached2;
|
|
45241
45439
|
if (!languageClass) throw new Error("tree-sitter not initialized");
|
|
45242
45440
|
const grammars = findWasmDir();
|
|
45243
|
-
const lang = await languageClass.load(
|
|
45441
|
+
const lang = await languageClass.load(join16(grammars, `${name2}.wasm`));
|
|
45244
45442
|
grammarCache.set(name2, lang);
|
|
45245
45443
|
return lang;
|
|
45246
45444
|
}
|
|
@@ -48145,7 +48343,7 @@ var init_src11 = __esm({
|
|
|
48145
48343
|
// src/reconcile.ts
|
|
48146
48344
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
48147
48345
|
import { readdirSync as readdirSync4, statSync as statSync6 } from "node:fs";
|
|
48148
|
-
import { join as
|
|
48346
|
+
import { join as join17, relative as relative3, sep as sep2 } from "node:path";
|
|
48149
48347
|
function indexerWouldScan(rel) {
|
|
48150
48348
|
for (const seg of rel.split(/[\\/]/)) {
|
|
48151
48349
|
if (seg.length === 0) continue;
|
|
@@ -48168,7 +48366,7 @@ function gitSourceFiles(root) {
|
|
|
48168
48366
|
const out2 = [];
|
|
48169
48367
|
for (const rel of stdout.split("\0")) {
|
|
48170
48368
|
if (!rel || !SOURCE_RE.test(rel) || !indexerWouldScan(rel)) continue;
|
|
48171
|
-
const abs =
|
|
48369
|
+
const abs = join17(root, rel);
|
|
48172
48370
|
if (IGNORED.test(abs)) continue;
|
|
48173
48371
|
out2.push(abs);
|
|
48174
48372
|
}
|
|
@@ -48183,7 +48381,7 @@ function* walkSource(dir) {
|
|
|
48183
48381
|
}
|
|
48184
48382
|
for (const e of entries) {
|
|
48185
48383
|
const name2 = String(e.name);
|
|
48186
|
-
const full =
|
|
48384
|
+
const full = join17(dir, name2);
|
|
48187
48385
|
if (IGNORED.test(full)) continue;
|
|
48188
48386
|
if (!indexerWouldScan(name2)) continue;
|
|
48189
48387
|
if (e.isDirectory()) yield* walkSource(full);
|
|
@@ -48401,7 +48599,7 @@ __export(mcp_exports, {
|
|
|
48401
48599
|
textMatches: () => textMatches,
|
|
48402
48600
|
withLinks: () => withLinks
|
|
48403
48601
|
});
|
|
48404
|
-
import { existsSync as
|
|
48602
|
+
import { existsSync as existsSync18, readFileSync as readFileSync17 } from "node:fs";
|
|
48405
48603
|
import { resolve as resolve4 } from "node:path";
|
|
48406
48604
|
function collectEnrichmentPulls(store, opts = {}) {
|
|
48407
48605
|
const pending = store.findLiveNodesByAttr("Solution", "enrichmentPending", 1).filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
|
|
@@ -48447,7 +48645,7 @@ function takeEnrichmentNudge(store) {
|
|
|
48447
48645
|
` + items;
|
|
48448
48646
|
}
|
|
48449
48647
|
function takeDiscriminatorNudge(path3) {
|
|
48450
|
-
if (!path3 || !
|
|
48648
|
+
if (!path3 || !existsSync18(path3)) return null;
|
|
48451
48649
|
let shared;
|
|
48452
48650
|
try {
|
|
48453
48651
|
shared = openGraphStore({ path: path3 });
|
|
@@ -48714,10 +48912,10 @@ function showNode(store, node2, maxLines) {
|
|
|
48714
48912
|
if (!relPath) return { found: false, reason: "no file owner for node" };
|
|
48715
48913
|
const workspaceRoot = process.cwd();
|
|
48716
48914
|
const absPath = resolve4(workspaceRoot, relPath);
|
|
48717
|
-
if (!
|
|
48915
|
+
if (!existsSync18(absPath)) {
|
|
48718
48916
|
return { found: false, reason: `file not found on disk: ${absPath}` };
|
|
48719
48917
|
}
|
|
48720
|
-
const source =
|
|
48918
|
+
const source = readFileSync17(absPath, "utf8");
|
|
48721
48919
|
const attrs = node2.attrs;
|
|
48722
48920
|
let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
|
|
48723
48921
|
let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
|
|
@@ -48780,15 +48978,17 @@ function similarNodes(store, seed, limit) {
|
|
|
48780
48978
|
hits: []
|
|
48781
48979
|
};
|
|
48782
48980
|
}
|
|
48981
|
+
const versionOf = (attrs) => String(attrs?.["embeddingVersion"] ?? "hash-v1");
|
|
48982
|
+
const seedVersion = versionOf(seed.attrs);
|
|
48783
48983
|
const candidates = [];
|
|
48784
48984
|
for (const n of store.selectNodes({
|
|
48785
48985
|
labels: ["Problem", "Pattern", "Technique", "AntiPattern", "Function", "Method", "Class"],
|
|
48786
|
-
attrs: ["test", "relPath"],
|
|
48986
|
+
attrs: ["test", "relPath", "embeddingVersion"],
|
|
48787
48987
|
where: [{ embedding: "present" }],
|
|
48788
48988
|
withEmbedding: true
|
|
48789
48989
|
})) {
|
|
48790
48990
|
if (n.id === seed.id) continue;
|
|
48791
|
-
if (n.embedding.length === seed.embedding.length) {
|
|
48991
|
+
if (n.embedding.length === seed.embedding.length && versionOf(n.attrs) === seedVersion) {
|
|
48792
48992
|
candidates.push(n);
|
|
48793
48993
|
}
|
|
48794
48994
|
}
|
|
@@ -49554,7 +49754,7 @@ var init_mcp = __esm({
|
|
|
49554
49754
|
const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
|
|
49555
49755
|
try {
|
|
49556
49756
|
const path3 = sharedStorePath();
|
|
49557
|
-
if (!
|
|
49757
|
+
if (!existsSync18(path3)) return { found: true, ...local };
|
|
49558
49758
|
const shared = openGraphStore({ path: path3 });
|
|
49559
49759
|
try {
|
|
49560
49760
|
if (!shared.getNode(id)) return { found: true, ...local };
|
|
@@ -50213,7 +50413,7 @@ var init_mcp = __esm({
|
|
|
50213
50413
|
inputSchema: { type: "object", properties: {} },
|
|
50214
50414
|
handler: () => {
|
|
50215
50415
|
const path3 = sharedStorePath();
|
|
50216
|
-
if (!
|
|
50416
|
+
if (!existsSync18(path3)) return { count: 0, pending: [] };
|
|
50217
50417
|
const shared = openGraphStore({ path: path3 });
|
|
50218
50418
|
try {
|
|
50219
50419
|
const pending = pendingAbstractions(shared);
|
|
@@ -50241,7 +50441,7 @@ var init_mcp = __esm({
|
|
|
50241
50441
|
},
|
|
50242
50442
|
handler: (args2) => {
|
|
50243
50443
|
const path3 = sharedStorePath();
|
|
50244
|
-
if (!
|
|
50444
|
+
if (!existsSync18(path3)) return { count: 0, pending: [] };
|
|
50245
50445
|
const shared = openGraphStore({ path: path3 });
|
|
50246
50446
|
try {
|
|
50247
50447
|
const pending = pendingDiscriminators(shared, {
|
|
@@ -50285,7 +50485,7 @@ var init_mcp = __esm({
|
|
|
50285
50485
|
},
|
|
50286
50486
|
handler: (args2) => {
|
|
50287
50487
|
const path3 = sharedStorePath();
|
|
50288
|
-
if (!
|
|
50488
|
+
if (!existsSync18(path3)) return { count: 0, routes: [] };
|
|
50289
50489
|
const shared = openGraphStore({ path: path3 });
|
|
50290
50490
|
try {
|
|
50291
50491
|
const result = triageOf(shared, {
|
|
@@ -50677,7 +50877,7 @@ __export(vfile_exports, {
|
|
|
50677
50877
|
segmentsOf: () => segmentsOf
|
|
50678
50878
|
});
|
|
50679
50879
|
import { writeFileSync as writeFileSync12 } from "node:fs";
|
|
50680
|
-
import { join as
|
|
50880
|
+
import { join as join18, resolve as resolve5, sep as sep3 } from "node:path";
|
|
50681
50881
|
function segmentsOf(rawPath) {
|
|
50682
50882
|
let p = rawPath.replace(/\\/g, "/");
|
|
50683
50883
|
p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
|
|
@@ -50751,7 +50951,7 @@ async function renderVFile(rawPath, store, ctx = {}) {
|
|
|
50751
50951
|
}
|
|
50752
50952
|
async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
|
|
50753
50953
|
const segs = segmentsOf(rawPath);
|
|
50754
|
-
const gRoot =
|
|
50954
|
+
const gRoot = join18(workspaceRoot, ".errata", "g");
|
|
50755
50955
|
const abs = resolve5(gRoot, ...segs.length ? segs : ["index"]);
|
|
50756
50956
|
if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
|
|
50757
50957
|
throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
|
|
@@ -58178,25 +58378,25 @@ var init_tool_index = __esm({
|
|
|
58178
58378
|
|
|
58179
58379
|
// src/outbox.ts
|
|
58180
58380
|
import {
|
|
58181
|
-
existsSync as
|
|
58381
|
+
existsSync as existsSync19,
|
|
58182
58382
|
readdirSync as readdirSync5,
|
|
58183
|
-
readFileSync as
|
|
58383
|
+
readFileSync as readFileSync18,
|
|
58184
58384
|
renameSync as renameSync2,
|
|
58185
58385
|
unlinkSync as unlinkSync3,
|
|
58186
58386
|
writeFileSync as writeFileSync13
|
|
58187
58387
|
} from "node:fs";
|
|
58188
|
-
import { join as
|
|
58388
|
+
import { join as join19 } from "node:path";
|
|
58189
58389
|
import { createHash as createHash15 } from "node:crypto";
|
|
58190
58390
|
function enqueueOutbox(paths, payload) {
|
|
58191
58391
|
ensureDir(paths.outbox);
|
|
58192
58392
|
const id = createHash15("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
58193
|
-
const file2 =
|
|
58393
|
+
const file2 = join19(paths.outbox, `${Date.now()}-${id}.json`);
|
|
58194
58394
|
writeFileSync13(file2, JSON.stringify(payload, null, 2), "utf8");
|
|
58195
58395
|
return file2;
|
|
58196
58396
|
}
|
|
58197
58397
|
async function flushOutbox(paths, client, store) {
|
|
58198
58398
|
ensureDir(paths.outbox);
|
|
58199
|
-
const entries =
|
|
58399
|
+
const entries = existsSync19(paths.outbox) ? readdirSync5(paths.outbox) : [];
|
|
58200
58400
|
let uploaded = 0;
|
|
58201
58401
|
let failed = 0;
|
|
58202
58402
|
const quarantine = (abs, reason) => {
|
|
@@ -58207,10 +58407,10 @@ async function flushOutbox(paths, client, store) {
|
|
|
58207
58407
|
}
|
|
58208
58408
|
};
|
|
58209
58409
|
for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
|
|
58210
|
-
const abs =
|
|
58410
|
+
const abs = join19(paths.outbox, f);
|
|
58211
58411
|
let payload;
|
|
58212
58412
|
try {
|
|
58213
|
-
payload = JSON.parse(
|
|
58413
|
+
payload = JSON.parse(readFileSync18(abs, "utf8"));
|
|
58214
58414
|
} catch {
|
|
58215
58415
|
failed++;
|
|
58216
58416
|
quarantine(abs, "unparseable JSON");
|
|
@@ -58255,7 +58455,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
58255
58455
|
}
|
|
58256
58456
|
}
|
|
58257
58457
|
}
|
|
58258
|
-
const remainingFiles =
|
|
58458
|
+
const remainingFiles = existsSync19(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
|
|
58259
58459
|
return { uploaded, failed, remaining: remainingFiles.length };
|
|
58260
58460
|
}
|
|
58261
58461
|
var init_outbox = __esm({
|
|
@@ -78158,16 +78358,16 @@ __export(witness_ledger_exports, {
|
|
|
78158
78358
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
78159
78359
|
witnessLedgerPath: () => witnessLedgerPath
|
|
78160
78360
|
});
|
|
78161
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
78162
|
-
import { join as
|
|
78361
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync29, readFileSync as readFileSync33, writeFileSync as writeFileSync22 } from "node:fs";
|
|
78362
|
+
import { join as join37 } from "node:path";
|
|
78163
78363
|
function witnessLedgerPath(configDir) {
|
|
78164
|
-
return
|
|
78364
|
+
return join37(configDir, "witness-ledger.jsonl");
|
|
78165
78365
|
}
|
|
78166
78366
|
function appendWitnessLedger(configDir, entry) {
|
|
78167
78367
|
const path3 = witnessLedgerPath(configDir);
|
|
78168
78368
|
try {
|
|
78169
78369
|
appendFileSync3(path3, JSON.stringify(entry) + "\n");
|
|
78170
|
-
const lines =
|
|
78370
|
+
const lines = readFileSync33(path3, "utf8").split("\n").filter(Boolean);
|
|
78171
78371
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
78172
78372
|
writeFileSync22(path3, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
78173
78373
|
}
|
|
@@ -78176,9 +78376,9 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
78176
78376
|
}
|
|
78177
78377
|
function readWitnessLedger(configDir) {
|
|
78178
78378
|
const path3 = witnessLedgerPath(configDir);
|
|
78179
|
-
if (!
|
|
78379
|
+
if (!existsSync29(path3)) return [];
|
|
78180
78380
|
try {
|
|
78181
|
-
return
|
|
78381
|
+
return readFileSync33(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
|
|
78182
78382
|
} catch {
|
|
78183
78383
|
return [];
|
|
78184
78384
|
}
|
|
@@ -78617,12 +78817,12 @@ var init_report_render = __esm({
|
|
|
78617
78817
|
|
|
78618
78818
|
// src/cli.ts
|
|
78619
78819
|
init_src6();
|
|
78620
|
-
import { closeSync as closeSync3, existsSync as
|
|
78621
|
-
import { join as
|
|
78820
|
+
import { closeSync as closeSync3, existsSync as existsSync42, openSync as openSync3, readFileSync as readFileSync50, renameSync as renameSync10, statSync as statSync17, writeFileSync as writeFileSync34 } from "node:fs";
|
|
78821
|
+
import { join as join58, resolve as pathResolve2 } from "node:path";
|
|
78622
78822
|
import { spawn as spawn5 } from "node:child_process";
|
|
78623
78823
|
|
|
78624
78824
|
// src/daemon.ts
|
|
78625
|
-
import { existsSync as
|
|
78825
|
+
import { existsSync as existsSync31, writeFileSync as writeFileSync25 } from "node:fs";
|
|
78626
78826
|
|
|
78627
78827
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.34/node_modules/@hono/node-server/dist/index.mjs
|
|
78628
78828
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -79202,16 +79402,16 @@ init_config();
|
|
|
79202
79402
|
init_lock();
|
|
79203
79403
|
|
|
79204
79404
|
// src/replay-checkout.ts
|
|
79205
|
-
import { existsSync as
|
|
79206
|
-
import { dirname as
|
|
79405
|
+
import { existsSync as existsSync20, readFileSync as readFileSync19, statSync as statSync7 } from "node:fs";
|
|
79406
|
+
import { dirname as dirname10, isAbsolute as isAbsolute4, join as join20, resolve as resolve6 } from "node:path";
|
|
79207
79407
|
var REPLAY_MARKER = "errata-replay";
|
|
79208
79408
|
function gitDirOf(cwd) {
|
|
79209
|
-
for (let dir = resolve6(cwd); ; dir =
|
|
79210
|
-
const dotGit =
|
|
79211
|
-
if (
|
|
79409
|
+
for (let dir = resolve6(cwd); ; dir = dirname10(dir)) {
|
|
79410
|
+
const dotGit = join20(dir, ".git");
|
|
79411
|
+
if (existsSync20(dotGit)) {
|
|
79212
79412
|
try {
|
|
79213
79413
|
if (statSync7(dotGit).isDirectory()) return dotGit;
|
|
79214
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
79414
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync19(dotGit, "utf8"));
|
|
79215
79415
|
if (!m) return null;
|
|
79216
79416
|
const target = m[1].trim();
|
|
79217
79417
|
return isAbsolute4(target) ? target : resolve6(dir, target);
|
|
@@ -79219,12 +79419,12 @@ function gitDirOf(cwd) {
|
|
|
79219
79419
|
return null;
|
|
79220
79420
|
}
|
|
79221
79421
|
}
|
|
79222
|
-
if (
|
|
79422
|
+
if (dirname10(dir) === dir) return null;
|
|
79223
79423
|
}
|
|
79224
79424
|
}
|
|
79225
79425
|
function isReplayCheckout(cwd) {
|
|
79226
79426
|
const gitDir = gitDirOf(cwd);
|
|
79227
|
-
return gitDir != null &&
|
|
79427
|
+
return gitDir != null && existsSync20(join20(gitDir, REPLAY_MARKER));
|
|
79228
79428
|
}
|
|
79229
79429
|
|
|
79230
79430
|
// src/activity-feed.ts
|
|
@@ -79332,8 +79532,8 @@ function knowledgeTag(label, attrs) {
|
|
|
79332
79532
|
|
|
79333
79533
|
// src/engine.ts
|
|
79334
79534
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
79335
|
-
import { existsSync as
|
|
79336
|
-
import { basename as basename8, join as
|
|
79535
|
+
import { existsSync as existsSync30, statSync as statSync12, appendFileSync as appendFileSync4, readdirSync as readdirSync11, renameSync as renameSync5, readFileSync as readFileSync35, writeFileSync as writeFileSync24 } from "node:fs";
|
|
79536
|
+
import { basename as basename8, join as join39, relative as relative6, sep as sep5 } from "node:path";
|
|
79337
79537
|
|
|
79338
79538
|
// src/coalesced-file-pass.ts
|
|
79339
79539
|
function createCoalescedFilePass(delayMs, run3, onError) {
|
|
@@ -79378,7 +79578,7 @@ function createCoalescedFilePass(delayMs, run3, onError) {
|
|
|
79378
79578
|
// src/source-watcher.ts
|
|
79379
79579
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
79380
79580
|
import { readdirSync as readdirSync6, statSync as statSync8, watch as watch2 } from "node:fs";
|
|
79381
|
-
import { join as
|
|
79581
|
+
import { join as join23, sep as sep4 } from "node:path";
|
|
79382
79582
|
|
|
79383
79583
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
79384
79584
|
import { stat as statcb } from "fs";
|
|
@@ -80109,9 +80309,9 @@ var NodeFsHandler = class {
|
|
|
80109
80309
|
if (this.fsw.closed) {
|
|
80110
80310
|
return;
|
|
80111
80311
|
}
|
|
80112
|
-
const
|
|
80312
|
+
const dirname23 = sysPath.dirname(file2);
|
|
80113
80313
|
const basename11 = sysPath.basename(file2);
|
|
80114
|
-
const parent = this.fsw._getWatchedDir(
|
|
80314
|
+
const parent = this.fsw._getWatchedDir(dirname23);
|
|
80115
80315
|
let prevStats = stats;
|
|
80116
80316
|
if (parent.has(basename11))
|
|
80117
80317
|
return;
|
|
@@ -80138,7 +80338,7 @@ var NodeFsHandler = class {
|
|
|
80138
80338
|
prevStats = newStats2;
|
|
80139
80339
|
}
|
|
80140
80340
|
} catch (error48) {
|
|
80141
|
-
this.fsw._remove(
|
|
80341
|
+
this.fsw._remove(dirname23, basename11);
|
|
80142
80342
|
}
|
|
80143
80343
|
} else if (parent.has(basename11)) {
|
|
80144
80344
|
const at = newStats.atimeMs;
|
|
@@ -81114,7 +81314,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
81114
81314
|
}
|
|
81115
81315
|
try {
|
|
81116
81316
|
const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
|
|
81117
|
-
const path3 = isDir ? name2 ?
|
|
81317
|
+
const path3 = isDir ? name2 ? join23(target, name2.toString()) : null : target;
|
|
81118
81318
|
if (!path3) {
|
|
81119
81319
|
this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
|
|
81120
81320
|
this.scheduleReconcile(target, isDir);
|
|
@@ -81180,7 +81380,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
81180
81380
|
continue;
|
|
81181
81381
|
}
|
|
81182
81382
|
for (const entry of entries) {
|
|
81183
|
-
const path3 =
|
|
81383
|
+
const path3 = join23(dir, entry.name);
|
|
81184
81384
|
if (this.ignored(path3)) continue;
|
|
81185
81385
|
if (entry.isDirectory()) dirs.push(path3);
|
|
81186
81386
|
else if (entry.isFile()) add(path3);
|
|
@@ -81491,9 +81691,9 @@ init_src6();
|
|
|
81491
81691
|
init_session_registry();
|
|
81492
81692
|
|
|
81493
81693
|
// src/snapshot-reuse.ts
|
|
81494
|
-
import { readFileSync as
|
|
81495
|
-
import { fileURLToPath as
|
|
81496
|
-
import { dirname as
|
|
81694
|
+
import { readFileSync as readFileSync20, renameSync as renameSync3, statSync as statSync9, writeFileSync as writeFileSync14 } from "node:fs";
|
|
81695
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
81696
|
+
import { dirname as dirname13, join as join24 } from "node:path";
|
|
81497
81697
|
function revisitFlagsUnchanged(store, held, flaggedNow) {
|
|
81498
81698
|
if (held.anySeq === void 0 || held.revisitIds === void 0 || !store.changedAmong) return false;
|
|
81499
81699
|
const watched = [.../* @__PURE__ */ new Set([...held.revisitIds, ...flaggedNow])];
|
|
@@ -81509,7 +81709,7 @@ function snapshotCodeIdentity(version3) {
|
|
|
81509
81709
|
if (codeIdentityMemo === void 0) {
|
|
81510
81710
|
let built = "unknown";
|
|
81511
81711
|
try {
|
|
81512
|
-
built = String(statSync9(
|
|
81712
|
+
built = String(statSync9(fileURLToPath3(import.meta.url)).mtimeMs);
|
|
81513
81713
|
} catch {
|
|
81514
81714
|
}
|
|
81515
81715
|
codeIdentityMemo = `${version3}@${built}`;
|
|
@@ -81517,11 +81717,11 @@ function snapshotCodeIdentity(version3) {
|
|
|
81517
81717
|
return codeIdentityMemo;
|
|
81518
81718
|
}
|
|
81519
81719
|
function heldSnapshotPath(configDir) {
|
|
81520
|
-
return
|
|
81720
|
+
return join24(configDir, "snapshot-held.json");
|
|
81521
81721
|
}
|
|
81522
81722
|
function loadHeldSnapshot(path3) {
|
|
81523
81723
|
try {
|
|
81524
|
-
const held = JSON.parse(
|
|
81724
|
+
const held = JSON.parse(readFileSync20(path3, "utf8"));
|
|
81525
81725
|
return typeof held?.key === "string" && typeof held.at === "number" ? held : null;
|
|
81526
81726
|
} catch {
|
|
81527
81727
|
return null;
|
|
@@ -81529,7 +81729,7 @@ function loadHeldSnapshot(path3) {
|
|
|
81529
81729
|
}
|
|
81530
81730
|
function saveHeldSnapshot(path3, held) {
|
|
81531
81731
|
try {
|
|
81532
|
-
const tmp =
|
|
81732
|
+
const tmp = join24(dirname13(path3), `.${process.pid}.snapshot-held.tmp`);
|
|
81533
81733
|
writeFileSync14(tmp, JSON.stringify(held));
|
|
81534
81734
|
renameSync3(tmp, path3);
|
|
81535
81735
|
} catch {
|
|
@@ -81725,8 +81925,8 @@ init_review2();
|
|
|
81725
81925
|
|
|
81726
81926
|
// src/turn.ts
|
|
81727
81927
|
init_checkout_root();
|
|
81728
|
-
import { closeSync as closeSync2, existsSync as
|
|
81729
|
-
import { basename as basename6, delimiter, dirname as
|
|
81928
|
+
import { closeSync as closeSync2, existsSync as existsSync21, fstatSync, openSync as openSync2, readdirSync as readdirSync7, readSync as readSync2, realpathSync as realpathSync2, statSync as statSync10 } from "node:fs";
|
|
81929
|
+
import { basename as basename6, delimiter, dirname as dirname14, join as join25, normalize as normalize4 } from "node:path";
|
|
81730
81930
|
import { homedir as homedir4 } from "node:os";
|
|
81731
81931
|
import { createHash as createHash16 } from "node:crypto";
|
|
81732
81932
|
function completeJsonlPrefix(buf) {
|
|
@@ -82114,11 +82314,11 @@ function turnsSince(turns, mark) {
|
|
|
82114
82314
|
return at >= 0 ? turns.slice(at + 1) : turns;
|
|
82115
82315
|
}
|
|
82116
82316
|
function claudeProjectDir(cwd, home = homedir4()) {
|
|
82117
|
-
return
|
|
82317
|
+
return join25(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
|
|
82118
82318
|
}
|
|
82119
82319
|
function recentTranscripts(cwd, opts = {}) {
|
|
82120
82320
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
82121
|
-
if (!
|
|
82321
|
+
if (!existsSync21(dir)) return [];
|
|
82122
82322
|
let names;
|
|
82123
82323
|
try {
|
|
82124
82324
|
names = readdirSync7(dir);
|
|
@@ -82129,7 +82329,7 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
82129
82329
|
const refs = [];
|
|
82130
82330
|
for (const name2 of names) {
|
|
82131
82331
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82132
|
-
const path3 =
|
|
82332
|
+
const path3 = join25(dir, name2);
|
|
82133
82333
|
let mtimeMs;
|
|
82134
82334
|
try {
|
|
82135
82335
|
mtimeMs = statSync10(path3).mtimeMs;
|
|
@@ -82144,8 +82344,8 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
82144
82344
|
}
|
|
82145
82345
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
82146
82346
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
82147
|
-
const dir =
|
|
82148
|
-
if (!
|
|
82347
|
+
const dir = join25(dirname14(mainTranscriptPath), sessionId, "subagents");
|
|
82348
|
+
if (!existsSync21(dir)) return [];
|
|
82149
82349
|
let names;
|
|
82150
82350
|
try {
|
|
82151
82351
|
names = readdirSync7(dir);
|
|
@@ -82155,7 +82355,7 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
82155
82355
|
const refs = [];
|
|
82156
82356
|
for (const name2 of names) {
|
|
82157
82357
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82158
|
-
const path3 =
|
|
82358
|
+
const path3 = join25(dir, name2);
|
|
82159
82359
|
let mtimeMs;
|
|
82160
82360
|
try {
|
|
82161
82361
|
mtimeMs = statSync10(path3).mtimeMs;
|
|
@@ -82169,13 +82369,13 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
82169
82369
|
}
|
|
82170
82370
|
function splitPathList(value, sep7 = delimiter) {
|
|
82171
82371
|
if (!value) return [];
|
|
82172
|
-
return value.split(sep7).map((d) => d.trim()).filter(Boolean).map((d) =>
|
|
82372
|
+
return value.split(sep7).map((d) => d.trim()).filter(Boolean).map((d) => normalize4(d));
|
|
82173
82373
|
}
|
|
82174
82374
|
function codexSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82175
82375
|
const roots = /* @__PURE__ */ new Set();
|
|
82176
82376
|
for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
|
|
82177
|
-
if (env2["CODEX_HOME"]) roots.add(
|
|
82178
|
-
roots.add(
|
|
82377
|
+
if (env2["CODEX_HOME"]) roots.add(join25(env2["CODEX_HOME"], "sessions"));
|
|
82378
|
+
roots.add(join25(home, ".codex", "sessions"));
|
|
82179
82379
|
return [...roots];
|
|
82180
82380
|
}
|
|
82181
82381
|
function readCodexRolloutIdentity(path3) {
|
|
@@ -82229,7 +82429,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82229
82429
|
const owner = checkoutRootOf(cwd);
|
|
82230
82430
|
const owners = /* @__PURE__ */ new Map();
|
|
82231
82431
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
82232
|
-
if (!
|
|
82432
|
+
if (!existsSync21(root)) {
|
|
82233
82433
|
codexRolloutActivity.delete(root);
|
|
82234
82434
|
continue;
|
|
82235
82435
|
}
|
|
@@ -82247,7 +82447,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82247
82447
|
continue;
|
|
82248
82448
|
}
|
|
82249
82449
|
for (const name2 of names) {
|
|
82250
|
-
const full =
|
|
82450
|
+
const full = join25(dir, name2);
|
|
82251
82451
|
let st;
|
|
82252
82452
|
try {
|
|
82253
82453
|
st = statSync10(full);
|
|
@@ -82289,8 +82489,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82289
82489
|
function geminiSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82290
82490
|
const roots = /* @__PURE__ */ new Set();
|
|
82291
82491
|
for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
|
|
82292
|
-
if (env2["GEMINI_CLI_HOME"]) roots.add(
|
|
82293
|
-
roots.add(
|
|
82492
|
+
if (env2["GEMINI_CLI_HOME"]) roots.add(join25(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
|
|
82493
|
+
roots.add(join25(home, ".gemini", "tmp"));
|
|
82294
82494
|
return [...roots];
|
|
82295
82495
|
}
|
|
82296
82496
|
function geminiProjectHash(cwd) {
|
|
@@ -82330,7 +82530,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82330
82530
|
const hashes = geminiHashesFor(cwd);
|
|
82331
82531
|
const out2 = [];
|
|
82332
82532
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
82333
|
-
if (!
|
|
82533
|
+
if (!existsSync21(root)) continue;
|
|
82334
82534
|
let slugs;
|
|
82335
82535
|
try {
|
|
82336
82536
|
slugs = readdirSync7(root);
|
|
@@ -82338,7 +82538,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82338
82538
|
continue;
|
|
82339
82539
|
}
|
|
82340
82540
|
for (const slug2 of slugs) {
|
|
82341
|
-
const chats =
|
|
82541
|
+
const chats = join25(root, slug2, "chats");
|
|
82342
82542
|
let names;
|
|
82343
82543
|
try {
|
|
82344
82544
|
names = readdirSync7(chats);
|
|
@@ -82347,7 +82547,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82347
82547
|
}
|
|
82348
82548
|
for (const name2 of names) {
|
|
82349
82549
|
if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
|
|
82350
|
-
const full =
|
|
82550
|
+
const full = join25(chats, name2);
|
|
82351
82551
|
let st;
|
|
82352
82552
|
try {
|
|
82353
82553
|
st = statSync10(full);
|
|
@@ -82367,8 +82567,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82367
82567
|
function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82368
82568
|
const roots = /* @__PURE__ */ new Set();
|
|
82369
82569
|
for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
|
|
82370
|
-
if (env2["XDG_DATA_HOME"]) roots.add(
|
|
82371
|
-
roots.add(
|
|
82570
|
+
if (env2["XDG_DATA_HOME"]) roots.add(join25(env2["XDG_DATA_HOME"], "opencode", "errata"));
|
|
82571
|
+
roots.add(join25(home, ".local", "share", "opencode", "errata"));
|
|
82372
82572
|
return [...roots];
|
|
82373
82573
|
}
|
|
82374
82574
|
function readOpencodeTranscriptDirectory(path3) {
|
|
@@ -82401,7 +82601,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82401
82601
|
}
|
|
82402
82602
|
const out2 = [];
|
|
82403
82603
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
82404
|
-
if (!
|
|
82604
|
+
if (!existsSync21(root)) continue;
|
|
82405
82605
|
let names;
|
|
82406
82606
|
try {
|
|
82407
82607
|
names = readdirSync7(root);
|
|
@@ -82410,7 +82610,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82410
82610
|
}
|
|
82411
82611
|
for (const name2 of names) {
|
|
82412
82612
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82413
|
-
const full =
|
|
82613
|
+
const full = join25(root, name2);
|
|
82414
82614
|
let st;
|
|
82415
82615
|
try {
|
|
82416
82616
|
st = statSync10(full);
|
|
@@ -82433,7 +82633,7 @@ init_src2();
|
|
|
82433
82633
|
init_agent_signals();
|
|
82434
82634
|
init_tool_index();
|
|
82435
82635
|
init_src5();
|
|
82436
|
-
import { readFileSync as
|
|
82636
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync15 } from "node:fs";
|
|
82437
82637
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
82438
82638
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
82439
82639
|
var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
|
|
@@ -83268,7 +83468,7 @@ function writePrimingHandles(path3, nodes, now = Date.now()) {
|
|
|
83268
83468
|
}
|
|
83269
83469
|
function readPrimingHandles(path3) {
|
|
83270
83470
|
try {
|
|
83271
|
-
return JSON.parse(
|
|
83471
|
+
return JSON.parse(readFileSync21(path3, "utf8"));
|
|
83272
83472
|
} catch {
|
|
83273
83473
|
return {};
|
|
83274
83474
|
}
|
|
@@ -83870,8 +84070,8 @@ ${conversation}` }]
|
|
|
83870
84070
|
// src/constraint-backfill.ts
|
|
83871
84071
|
init_src5();
|
|
83872
84072
|
init_src2();
|
|
83873
|
-
import { existsSync as
|
|
83874
|
-
import { join as
|
|
84073
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22, readdirSync as readdirSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
84074
|
+
import { join as join26 } from "node:path";
|
|
83875
84075
|
import { homedir as homedir5 } from "node:os";
|
|
83876
84076
|
var BACKFILL_VERSION = 1;
|
|
83877
84077
|
var EMPTY = {
|
|
@@ -83885,13 +84085,13 @@ var EMPTY = {
|
|
|
83885
84085
|
recoverable: 0
|
|
83886
84086
|
};
|
|
83887
84087
|
function markerPath(configDir) {
|
|
83888
|
-
return
|
|
84088
|
+
return join26(configDir, "constraint-backfill.json");
|
|
83889
84089
|
}
|
|
83890
84090
|
function alreadyDone(configDir) {
|
|
83891
84091
|
const p = markerPath(configDir);
|
|
83892
|
-
if (!
|
|
84092
|
+
if (!existsSync22(p)) return false;
|
|
83893
84093
|
try {
|
|
83894
|
-
const raw2 = JSON.parse(
|
|
84094
|
+
const raw2 = JSON.parse(readFileSync22(p, "utf8"));
|
|
83895
84095
|
return raw2?.version === BACKFILL_VERSION;
|
|
83896
84096
|
} catch {
|
|
83897
84097
|
return false;
|
|
@@ -83901,7 +84101,7 @@ function replay(root) {
|
|
|
83901
84101
|
const statements2 = /* @__PURE__ */ new Set();
|
|
83902
84102
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
83903
84103
|
const dir = claudeProjectDir(root, homedir5());
|
|
83904
|
-
if (!
|
|
84104
|
+
if (!existsSync22(dir)) return { statements: statements2, citedByFix };
|
|
83905
84105
|
let names;
|
|
83906
84106
|
try {
|
|
83907
84107
|
names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -83911,7 +84111,7 @@ function replay(root) {
|
|
|
83911
84111
|
for (const f of names) {
|
|
83912
84112
|
let lines;
|
|
83913
84113
|
try {
|
|
83914
|
-
lines =
|
|
84114
|
+
lines = readFileSync22(join26(dir, f), "utf8").split("\n");
|
|
83915
84115
|
} catch {
|
|
83916
84116
|
continue;
|
|
83917
84117
|
}
|
|
@@ -84038,8 +84238,8 @@ function backfillConstraintKind(store, opts) {
|
|
|
84038
84238
|
// src/edge-repair.ts
|
|
84039
84239
|
init_src();
|
|
84040
84240
|
init_src5();
|
|
84041
|
-
import { existsSync as
|
|
84042
|
-
import { join as
|
|
84241
|
+
import { existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync17 } from "node:fs";
|
|
84242
|
+
import { join as join27 } from "node:path";
|
|
84043
84243
|
function citeEdgeId(from, type, to) {
|
|
84044
84244
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
84045
84245
|
}
|
|
@@ -84054,13 +84254,13 @@ var EMPTY2 = {
|
|
|
84054
84254
|
byType: {}
|
|
84055
84255
|
};
|
|
84056
84256
|
function markerPath2(configDir) {
|
|
84057
|
-
return
|
|
84257
|
+
return join27(configDir, "edge-repair.json");
|
|
84058
84258
|
}
|
|
84059
84259
|
function alreadyDone2(configDir) {
|
|
84060
84260
|
const p = markerPath2(configDir);
|
|
84061
|
-
if (!
|
|
84261
|
+
if (!existsSync23(p)) return false;
|
|
84062
84262
|
try {
|
|
84063
|
-
return JSON.parse(
|
|
84263
|
+
return JSON.parse(readFileSync23(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
84064
84264
|
} catch {
|
|
84065
84265
|
return false;
|
|
84066
84266
|
}
|
|
@@ -84123,8 +84323,8 @@ function repairInvalidEdges(store, opts) {
|
|
|
84123
84323
|
init_reconcile();
|
|
84124
84324
|
|
|
84125
84325
|
// src/pass-ledger.ts
|
|
84126
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
84127
|
-
import { join as
|
|
84326
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync24, readFileSync as readFileSync24, writeFileSync as writeFileSync18 } from "node:fs";
|
|
84327
|
+
import { join as join28 } from "node:path";
|
|
84128
84328
|
|
|
84129
84329
|
// src/isolate-census.ts
|
|
84130
84330
|
var live3 = 0;
|
|
@@ -84155,7 +84355,7 @@ var HOUR_MS = 36e5;
|
|
|
84155
84355
|
var TRIM_EVERY = 50;
|
|
84156
84356
|
var appendsSinceTrim = /* @__PURE__ */ new Map();
|
|
84157
84357
|
function passLedgerPath(configDir) {
|
|
84158
|
-
return
|
|
84358
|
+
return join28(configDir, "pass-ledger.jsonl");
|
|
84159
84359
|
}
|
|
84160
84360
|
function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
84161
84361
|
const path3 = passLedgerPath(configDir);
|
|
@@ -84187,7 +84387,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84187
84387
|
return;
|
|
84188
84388
|
}
|
|
84189
84389
|
appendsSinceTrim.set(path3, 0);
|
|
84190
|
-
const lines =
|
|
84390
|
+
const lines = readFileSync24(path3, "utf8").split("\n").filter(Boolean);
|
|
84191
84391
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
84192
84392
|
const tailHours = /* @__PURE__ */ new Map();
|
|
84193
84393
|
const tailFloor = Date.now() - LEVEL_TAIL_DAYS * 24 * HOUR_MS;
|
|
@@ -84222,9 +84422,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84222
84422
|
}
|
|
84223
84423
|
function readPassLedger(configDir) {
|
|
84224
84424
|
const path3 = passLedgerPath(configDir);
|
|
84225
|
-
if (!
|
|
84425
|
+
if (!existsSync24(path3)) return [];
|
|
84226
84426
|
try {
|
|
84227
|
-
return
|
|
84427
|
+
return readFileSync24(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
84228
84428
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
84229
84429
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
84230
84430
|
} catch {
|
|
@@ -84667,11 +84867,11 @@ init_outbox();
|
|
|
84667
84867
|
init_src10();
|
|
84668
84868
|
init_src();
|
|
84669
84869
|
init_src2();
|
|
84670
|
-
import { readFileSync as
|
|
84671
|
-
import { join as
|
|
84870
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
84871
|
+
import { join as join29 } from "node:path";
|
|
84672
84872
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
84673
84873
|
try {
|
|
84674
|
-
return
|
|
84874
|
+
return readFileSync25(join29(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
84675
84875
|
} catch {
|
|
84676
84876
|
return [];
|
|
84677
84877
|
}
|
|
@@ -85054,9 +85254,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
85054
85254
|
// src/retrieval-stack.ts
|
|
85055
85255
|
init_src();
|
|
85056
85256
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
85057
|
-
import { existsSync as
|
|
85257
|
+
import { existsSync as existsSync25, readFileSync as readFileSync26, statSync as statSync11 } from "node:fs";
|
|
85058
85258
|
import { homedir as homedir6 } from "node:os";
|
|
85059
|
-
import { join as
|
|
85259
|
+
import { join as join30 } from "node:path";
|
|
85060
85260
|
var RETRIEVAL_STACK_CAP = 24;
|
|
85061
85261
|
var MANIFEST_SCAN_CAP = 400;
|
|
85062
85262
|
var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -85346,51 +85546,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
85346
85546
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
85347
85547
|
const read2 = (p) => {
|
|
85348
85548
|
try {
|
|
85349
|
-
return
|
|
85549
|
+
return readFileSync26(p, "utf8");
|
|
85350
85550
|
} catch {
|
|
85351
85551
|
return null;
|
|
85352
85552
|
}
|
|
85353
85553
|
};
|
|
85354
85554
|
const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
|
|
85355
85555
|
const home = homedir6();
|
|
85356
|
-
const npm = parseNpmrcPolicy(texts(
|
|
85556
|
+
const npm = parseNpmrcPolicy(texts(join30(root, ".npmrc"), join30(home, ".npmrc")));
|
|
85357
85557
|
const blocked = /* @__PURE__ */ new Set();
|
|
85358
85558
|
if (!npm.defaultPublic) blocked.add("npm");
|
|
85359
85559
|
if (pypiIndexIsPrivate(
|
|
85360
85560
|
texts(
|
|
85361
|
-
|
|
85362
|
-
|
|
85363
|
-
|
|
85364
|
-
|
|
85365
|
-
|
|
85366
|
-
|
|
85367
|
-
|
|
85561
|
+
join30(root, "pip.conf"),
|
|
85562
|
+
join30(root, "pip.ini"),
|
|
85563
|
+
join30(root, "pyproject.toml"),
|
|
85564
|
+
join30(root, "requirements.txt"),
|
|
85565
|
+
join30(home, ".pip", "pip.conf"),
|
|
85566
|
+
join30(home, ".config", "pip", "pip.conf"),
|
|
85567
|
+
join30(env2["APPDATA"] ?? home, "pip", "pip.ini")
|
|
85368
85568
|
)
|
|
85369
85569
|
)) {
|
|
85370
85570
|
blocked.add("pypi");
|
|
85371
85571
|
}
|
|
85372
85572
|
if (cargoRegistryIsPrivate(
|
|
85373
85573
|
texts(
|
|
85374
|
-
|
|
85375
|
-
|
|
85376
|
-
|
|
85377
|
-
|
|
85574
|
+
join30(root, ".cargo", "config.toml"),
|
|
85575
|
+
join30(root, ".cargo", "config"),
|
|
85576
|
+
join30(home, ".cargo", "config.toml"),
|
|
85577
|
+
join30(home, ".cargo", "config")
|
|
85378
85578
|
)
|
|
85379
85579
|
)) {
|
|
85380
85580
|
blocked.add("cargo");
|
|
85381
85581
|
}
|
|
85382
85582
|
if (nugetSourcesArePrivate(
|
|
85383
85583
|
texts(
|
|
85384
|
-
|
|
85385
|
-
|
|
85386
|
-
|
|
85387
|
-
|
|
85388
|
-
|
|
85584
|
+
join30(root, "NuGet.config"),
|
|
85585
|
+
join30(root, "nuget.config"),
|
|
85586
|
+
join30(root, "NuGet.Config"),
|
|
85587
|
+
join30(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
|
|
85588
|
+
join30(home, ".nuget", "NuGet", "NuGet.Config")
|
|
85389
85589
|
)
|
|
85390
85590
|
)) {
|
|
85391
85591
|
blocked.add("nuget");
|
|
85392
85592
|
}
|
|
85393
|
-
const goEnvFile = env2["GOENV"] ??
|
|
85593
|
+
const goEnvFile = env2["GOENV"] ?? join30(env2["APPDATA"] ?? join30(home, ".config"), "go", "env");
|
|
85394
85594
|
const goEnvText = read2(goEnvFile) ?? "";
|
|
85395
85595
|
const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
|
|
85396
85596
|
(k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
|
|
@@ -85401,10 +85601,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
|
85401
85601
|
env2["GONOSUMCHECK"],
|
|
85402
85602
|
...fromFile
|
|
85403
85603
|
]);
|
|
85404
|
-
const gemfiles = texts(
|
|
85604
|
+
const gemfiles = texts(join30(root, "Gemfile"));
|
|
85405
85605
|
if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
|
|
85406
85606
|
if (mavenReposArePrivate(
|
|
85407
|
-
texts(
|
|
85607
|
+
texts(join30(root, "pom.xml"), join30(home, ".m2", "settings.xml"))
|
|
85408
85608
|
)) {
|
|
85409
85609
|
blocked.add("maven");
|
|
85410
85610
|
}
|
|
@@ -85571,8 +85771,8 @@ function readDirectDependencies(root) {
|
|
|
85571
85771
|
const familiesSeen = /* @__PURE__ */ new Set();
|
|
85572
85772
|
for (const c of LOCKFILES) {
|
|
85573
85773
|
if (familiesSeen.has(c.family)) continue;
|
|
85574
|
-
const p =
|
|
85575
|
-
if (!
|
|
85774
|
+
const p = join30(root, c.file);
|
|
85775
|
+
if (!existsSync25(p)) continue;
|
|
85576
85776
|
try {
|
|
85577
85777
|
const s = statSync11(p);
|
|
85578
85778
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
@@ -85592,7 +85792,7 @@ function readDirectDependencies(root) {
|
|
|
85592
85792
|
const direct = [];
|
|
85593
85793
|
for (const { c, path: path3 } of found) {
|
|
85594
85794
|
try {
|
|
85595
|
-
direct.push(...c.parse(
|
|
85795
|
+
direct.push(...c.parse(readFileSync26(path3, "utf8")).direct ?? []);
|
|
85596
85796
|
} catch {
|
|
85597
85797
|
}
|
|
85598
85798
|
}
|
|
@@ -85635,14 +85835,14 @@ function manifestPaths(root) {
|
|
|
85635
85835
|
"project.godot"
|
|
85636
85836
|
];
|
|
85637
85837
|
return {
|
|
85638
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
85838
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync25(join30(root, f))),
|
|
85639
85839
|
tracked: false,
|
|
85640
85840
|
truncated: false
|
|
85641
85841
|
};
|
|
85642
85842
|
}
|
|
85643
85843
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
85644
85844
|
function rootDeclaresWorkspace(root, texts) {
|
|
85645
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
85845
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync25(join30(root, f)))) return true;
|
|
85646
85846
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
85647
85847
|
}
|
|
85648
85848
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -85656,11 +85856,11 @@ function scanManifests(root) {
|
|
|
85656
85856
|
const texts = /* @__PURE__ */ new Map();
|
|
85657
85857
|
const stamps = [];
|
|
85658
85858
|
for (const rel of paths) {
|
|
85659
|
-
const abs =
|
|
85859
|
+
const abs = join30(root, rel);
|
|
85660
85860
|
try {
|
|
85661
85861
|
const s = statSync11(abs);
|
|
85662
85862
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
85663
|
-
texts.set(rel,
|
|
85863
|
+
texts.set(rel, readFileSync26(abs, "utf8"));
|
|
85664
85864
|
} catch {
|
|
85665
85865
|
}
|
|
85666
85866
|
}
|
|
@@ -85696,22 +85896,22 @@ function readRetrievalInputs(root, repoLocator) {
|
|
|
85696
85896
|
}
|
|
85697
85897
|
|
|
85698
85898
|
// src/git-sensor.ts
|
|
85699
|
-
import { existsSync as
|
|
85700
|
-
import { join as
|
|
85899
|
+
import { existsSync as existsSync26, readFileSync as readFileSync27, watch as fsWatch } from "node:fs";
|
|
85900
|
+
import { join as join31 } from "node:path";
|
|
85701
85901
|
function readFirstLine(path3) {
|
|
85702
85902
|
try {
|
|
85703
|
-
return
|
|
85903
|
+
return readFileSync27(path3, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
85704
85904
|
} catch {
|
|
85705
85905
|
return null;
|
|
85706
85906
|
}
|
|
85707
85907
|
}
|
|
85708
85908
|
function readGitRefState(gitDir) {
|
|
85709
|
-
const head2 = readFirstLine(
|
|
85909
|
+
const head2 = readFirstLine(join31(gitDir, "HEAD"));
|
|
85710
85910
|
const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
|
|
85711
85911
|
const branch = m ? m[1] : null;
|
|
85712
85912
|
let sha2 = null;
|
|
85713
85913
|
if (branch) {
|
|
85714
|
-
sha2 = readFirstLine(
|
|
85914
|
+
sha2 = readFirstLine(join31(gitDir, "refs", "heads", branch));
|
|
85715
85915
|
if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
|
|
85716
85916
|
} else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
|
|
85717
85917
|
sha2 = head2;
|
|
@@ -85719,13 +85919,13 @@ function readGitRefState(gitDir) {
|
|
|
85719
85919
|
return {
|
|
85720
85920
|
branch,
|
|
85721
85921
|
sha: sha2,
|
|
85722
|
-
mergeHeadExists:
|
|
85723
|
-
origHeadExists:
|
|
85922
|
+
mergeHeadExists: existsSync26(join31(gitDir, "MERGE_HEAD")),
|
|
85923
|
+
origHeadExists: existsSync26(join31(gitDir, "ORIG_HEAD"))
|
|
85724
85924
|
};
|
|
85725
85925
|
}
|
|
85726
85926
|
function shaFromPackedRefs(gitDir, ref) {
|
|
85727
85927
|
try {
|
|
85728
|
-
for (const line of
|
|
85928
|
+
for (const line of readFileSync27(join31(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
85729
85929
|
const [sha2, name2] = line.split(/\s+/);
|
|
85730
85930
|
if (name2 === ref && sha2) return sha2;
|
|
85731
85931
|
}
|
|
@@ -85759,7 +85959,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85759
85959
|
const settle = () => {
|
|
85760
85960
|
if (timer) clearTimeout(timer);
|
|
85761
85961
|
timer = setTimeout(() => {
|
|
85762
|
-
if (
|
|
85962
|
+
if (existsSync26(join31(gitDir, "index.lock"))) {
|
|
85763
85963
|
settle();
|
|
85764
85964
|
return;
|
|
85765
85965
|
}
|
|
@@ -85770,7 +85970,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85770
85970
|
}, debounceMs);
|
|
85771
85971
|
};
|
|
85772
85972
|
for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
|
|
85773
|
-
const p =
|
|
85973
|
+
const p = join31(gitDir, sub);
|
|
85774
85974
|
try {
|
|
85775
85975
|
watchers.push(fsWatch(p, settle));
|
|
85776
85976
|
} catch {
|
|
@@ -86000,8 +86200,8 @@ var TelemetryRecorder = class {
|
|
|
86000
86200
|
};
|
|
86001
86201
|
|
|
86002
86202
|
// src/file-activity.ts
|
|
86003
|
-
import { readFileSync as
|
|
86004
|
-
import { join as
|
|
86203
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
86204
|
+
import { join as join33 } from "node:path";
|
|
86005
86205
|
import { createHash as createHash17 } from "node:crypto";
|
|
86006
86206
|
|
|
86007
86207
|
// ../../packages/privacy/src/patterns/credentials.ts
|
|
@@ -86753,8 +86953,8 @@ init_git_remote();
|
|
|
86753
86953
|
// src/history-bundle.ts
|
|
86754
86954
|
init_src();
|
|
86755
86955
|
import { execFile as execFile3 } from "node:child_process";
|
|
86756
|
-
import { readFileSync as
|
|
86757
|
-
import { join as
|
|
86956
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
86957
|
+
import { join as join32 } from "node:path";
|
|
86758
86958
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
86759
86959
|
var FILE_LIST_CAP = 60;
|
|
86760
86960
|
var DIFF_FILE_CAP = 40;
|
|
@@ -86793,7 +86993,7 @@ function pathAllowedByFloor(path3) {
|
|
|
86793
86993
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
86794
86994
|
let source = "";
|
|
86795
86995
|
try {
|
|
86796
|
-
source =
|
|
86996
|
+
source = readFileSync28(join32(root, ".errataignore"), "utf8");
|
|
86797
86997
|
} catch {
|
|
86798
86998
|
source = "";
|
|
86799
86999
|
}
|
|
@@ -87098,7 +87298,7 @@ function readActivityBranch(root) {
|
|
|
87098
87298
|
try {
|
|
87099
87299
|
const gitDir = resolveGitDir(root);
|
|
87100
87300
|
if (!gitDir) return null;
|
|
87101
|
-
const head2 =
|
|
87301
|
+
const head2 = readFileSync29(join33(gitDir, "HEAD"), "utf8").trim();
|
|
87102
87302
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
87103
87303
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
87104
87304
|
} catch {
|
|
@@ -87255,21 +87455,21 @@ var FileActivityReporter = class {
|
|
|
87255
87455
|
|
|
87256
87456
|
// src/skills.ts
|
|
87257
87457
|
import {
|
|
87258
|
-
existsSync as
|
|
87458
|
+
existsSync as existsSync27,
|
|
87259
87459
|
mkdirSync as mkdirSync7,
|
|
87260
|
-
readFileSync as
|
|
87460
|
+
readFileSync as readFileSync30,
|
|
87261
87461
|
readdirSync as readdirSync9,
|
|
87262
87462
|
unlinkSync as unlinkSync4,
|
|
87263
87463
|
writeFileSync as writeFileSync19
|
|
87264
87464
|
} from "node:fs";
|
|
87265
|
-
import { basename as basename7, join as
|
|
87465
|
+
import { basename as basename7, join as join34 } from "node:path";
|
|
87266
87466
|
function skillFileName(id) {
|
|
87267
87467
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
87268
87468
|
}
|
|
87269
87469
|
function readSkillManifest(manifestPath) {
|
|
87270
|
-
if (!
|
|
87470
|
+
if (!existsSync27(manifestPath)) return [];
|
|
87271
87471
|
try {
|
|
87272
|
-
const parsed = JSON.parse(
|
|
87472
|
+
const parsed = JSON.parse(readFileSync30(manifestPath, "utf8"));
|
|
87273
87473
|
return (parsed.skills ?? []).map((s) => ({
|
|
87274
87474
|
title: s.title ?? "",
|
|
87275
87475
|
layer: s.layer ?? "technique",
|
|
@@ -87293,7 +87493,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87293
87493
|
for (const s of res.skills) {
|
|
87294
87494
|
const fileName = skillFileName(s.id);
|
|
87295
87495
|
keep.add(fileName);
|
|
87296
|
-
writeFileSync19(
|
|
87496
|
+
writeFileSync19(join34(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
87297
87497
|
rows.push({
|
|
87298
87498
|
id: s.id,
|
|
87299
87499
|
title: s.title,
|
|
@@ -87306,7 +87506,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87306
87506
|
const fileName = skillFileName(p.id);
|
|
87307
87507
|
if (keep.has(fileName)) continue;
|
|
87308
87508
|
keep.add(fileName);
|
|
87309
|
-
writeFileSync19(
|
|
87509
|
+
writeFileSync19(join34(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
87310
87510
|
rows.push({
|
|
87311
87511
|
id: p.id,
|
|
87312
87512
|
title: p.title,
|
|
@@ -87320,7 +87520,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87320
87520
|
if (!f.endsWith(".md")) continue;
|
|
87321
87521
|
if (keep.has(basename7(f))) continue;
|
|
87322
87522
|
try {
|
|
87323
|
-
unlinkSync4(
|
|
87523
|
+
unlinkSync4(join34(paths.skillsDir, f));
|
|
87324
87524
|
pruned++;
|
|
87325
87525
|
} catch {
|
|
87326
87526
|
}
|
|
@@ -87338,22 +87538,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87338
87538
|
init_src2();
|
|
87339
87539
|
import {
|
|
87340
87540
|
cpSync,
|
|
87341
|
-
existsSync as
|
|
87541
|
+
existsSync as existsSync28,
|
|
87342
87542
|
lstatSync,
|
|
87343
87543
|
mkdirSync as mkdirSync8,
|
|
87344
|
-
readFileSync as
|
|
87544
|
+
readFileSync as readFileSync31,
|
|
87345
87545
|
readdirSync as readdirSync10,
|
|
87346
87546
|
rmSync as rmSync3,
|
|
87347
87547
|
symlinkSync,
|
|
87348
87548
|
writeFileSync as writeFileSync20
|
|
87349
87549
|
} from "node:fs";
|
|
87350
|
-
import { join as
|
|
87550
|
+
import { join as join35 } from "node:path";
|
|
87351
87551
|
var SKILL_NS = "errata-";
|
|
87352
87552
|
var HARNESS_SKILL_DIRS = [
|
|
87353
|
-
{ configDir: ".claude", skillsDir:
|
|
87553
|
+
{ configDir: ".claude", skillsDir: join35(".claude", "skills") },
|
|
87354
87554
|
// Cursor adopted the standard; its exact project dir is still moving — kept
|
|
87355
87555
|
// best-effort and gated on `.cursor/` presence so we never create it blind.
|
|
87356
|
-
{ configDir: ".cursor", skillsDir:
|
|
87556
|
+
{ configDir: ".cursor", skillsDir: join35(".cursor", "skills") }
|
|
87357
87557
|
];
|
|
87358
87558
|
function skillSlug(title, id) {
|
|
87359
87559
|
const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
|
|
@@ -87398,12 +87598,12 @@ function skillCiteHandle(s) {
|
|
|
87398
87598
|
return priorHandle({ id: s.id, description: s.title });
|
|
87399
87599
|
}
|
|
87400
87600
|
function reconcileNamespaced(dir, keep) {
|
|
87401
|
-
if (!
|
|
87601
|
+
if (!existsSync28(dir)) return 0;
|
|
87402
87602
|
let pruned = 0;
|
|
87403
87603
|
for (const name2 of readdirSync10(dir)) {
|
|
87404
87604
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
87405
87605
|
try {
|
|
87406
|
-
rmSync3(
|
|
87606
|
+
rmSync3(join35(dir, name2), { recursive: true, force: true });
|
|
87407
87607
|
pruned++;
|
|
87408
87608
|
} catch {
|
|
87409
87609
|
}
|
|
@@ -87412,7 +87612,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
87412
87612
|
}
|
|
87413
87613
|
function linkOrCopy(linkPath, target) {
|
|
87414
87614
|
try {
|
|
87415
|
-
if (
|
|
87615
|
+
if (existsSync28(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
87416
87616
|
} catch {
|
|
87417
87617
|
}
|
|
87418
87618
|
try {
|
|
@@ -87433,7 +87633,7 @@ function safeLstat(p) {
|
|
|
87433
87633
|
}
|
|
87434
87634
|
}
|
|
87435
87635
|
function emitAndProjectSkills(root, skills) {
|
|
87436
|
-
const agentsSkillsDir =
|
|
87636
|
+
const agentsSkillsDir = join35(root, ".agents", "skills");
|
|
87437
87637
|
mkdirSync8(agentsSkillsDir, { recursive: true });
|
|
87438
87638
|
const slugs = [];
|
|
87439
87639
|
const keep = /* @__PURE__ */ new Set();
|
|
@@ -87441,7 +87641,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87441
87641
|
for (const s of skills) {
|
|
87442
87642
|
let body2;
|
|
87443
87643
|
try {
|
|
87444
|
-
body2 =
|
|
87644
|
+
body2 = readFileSync31(s.bodyPath, "utf8");
|
|
87445
87645
|
} catch {
|
|
87446
87646
|
continue;
|
|
87447
87647
|
}
|
|
@@ -87450,9 +87650,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87450
87650
|
keep.add(slug2);
|
|
87451
87651
|
slugs.push(slug2);
|
|
87452
87652
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
87453
|
-
mkdirSync8(
|
|
87653
|
+
mkdirSync8(join35(agentsSkillsDir, slug2), { recursive: true });
|
|
87454
87654
|
writeFileSync20(
|
|
87455
|
-
|
|
87655
|
+
join35(agentsSkillsDir, slug2, "SKILL.md"),
|
|
87456
87656
|
renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
|
|
87457
87657
|
"utf8"
|
|
87458
87658
|
);
|
|
@@ -87461,11 +87661,11 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87461
87661
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
87462
87662
|
let projected = 0;
|
|
87463
87663
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
87464
|
-
if (!
|
|
87465
|
-
const dir =
|
|
87664
|
+
if (!existsSync28(join35(root, h.configDir))) continue;
|
|
87665
|
+
const dir = join35(root, h.skillsDir);
|
|
87466
87666
|
mkdirSync8(dir, { recursive: true });
|
|
87467
87667
|
for (const slug2 of slugs) {
|
|
87468
|
-
linkOrCopy(
|
|
87668
|
+
linkOrCopy(join35(dir, slug2), join35(agentsSkillsDir, slug2));
|
|
87469
87669
|
projected++;
|
|
87470
87670
|
}
|
|
87471
87671
|
reconcileNamespaced(dir, keep);
|
|
@@ -87474,15 +87674,15 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87474
87674
|
return { slugs, emitted, projected };
|
|
87475
87675
|
}
|
|
87476
87676
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
87477
|
-
if (!
|
|
87677
|
+
if (!existsSync28(manifestPath)) return [];
|
|
87478
87678
|
try {
|
|
87479
|
-
const parsed = JSON.parse(
|
|
87679
|
+
const parsed = JSON.parse(readFileSync31(manifestPath, "utf8"));
|
|
87480
87680
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
87481
87681
|
id: s.id,
|
|
87482
87682
|
title: s.title ?? s.id,
|
|
87483
87683
|
layer: s.layer ?? "technique",
|
|
87484
87684
|
confidence: s.confidence ?? 0,
|
|
87485
|
-
bodyPath:
|
|
87685
|
+
bodyPath: join35(erretaDir, s.file)
|
|
87486
87686
|
}));
|
|
87487
87687
|
} catch {
|
|
87488
87688
|
return [];
|
|
@@ -87496,10 +87696,10 @@ var GITIGNORE_LINES = [
|
|
|
87496
87696
|
".cursor/skills/errata-*/"
|
|
87497
87697
|
];
|
|
87498
87698
|
function ensureSkillGitignore(root) {
|
|
87499
|
-
const path3 =
|
|
87699
|
+
const path3 = join35(root, ".gitignore");
|
|
87500
87700
|
let current = "";
|
|
87501
87701
|
try {
|
|
87502
|
-
current =
|
|
87702
|
+
current = existsSync28(path3) ? readFileSync31(path3, "utf8") : "";
|
|
87503
87703
|
} catch {
|
|
87504
87704
|
return;
|
|
87505
87705
|
}
|
|
@@ -87696,18 +87896,18 @@ init_paths();
|
|
|
87696
87896
|
init_profile2();
|
|
87697
87897
|
|
|
87698
87898
|
// src/witness-queue.ts
|
|
87699
|
-
import { readFileSync as
|
|
87700
|
-
import { dirname as
|
|
87899
|
+
import { readFileSync as readFileSync32, renameSync as renameSync4, writeFileSync as writeFileSync21 } from "node:fs";
|
|
87900
|
+
import { dirname as dirname15, join as join36 } from "node:path";
|
|
87701
87901
|
var WITNESS_QUEUE_CAP = 500;
|
|
87702
87902
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
87703
87903
|
var WITNESS_MAX_ATTEMPTS = 5;
|
|
87704
87904
|
function witnessQueuePath(workspaceConfigDir) {
|
|
87705
|
-
return
|
|
87905
|
+
return join36(workspaceConfigDir, "witness-queue.json");
|
|
87706
87906
|
}
|
|
87707
87907
|
function loadWitnessQueueWithLosses(path3) {
|
|
87708
87908
|
let raw2;
|
|
87709
87909
|
try {
|
|
87710
|
-
raw2 = JSON.parse(
|
|
87910
|
+
raw2 = JSON.parse(readFileSync32(path3, "utf8"));
|
|
87711
87911
|
} catch (err2) {
|
|
87712
87912
|
const absent = err2?.code === "ENOENT";
|
|
87713
87913
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -87720,7 +87920,7 @@ function loadWitnessQueueWithLosses(path3) {
|
|
|
87720
87920
|
}
|
|
87721
87921
|
function saveWitnessQueue(path3, queue) {
|
|
87722
87922
|
try {
|
|
87723
|
-
const tmp =
|
|
87923
|
+
const tmp = join36(dirname15(path3), `.${Date.now()}.witness-queue.tmp`);
|
|
87724
87924
|
writeFileSync21(tmp, JSON.stringify(queue), "utf8");
|
|
87725
87925
|
renameSync4(tmp, path3);
|
|
87726
87926
|
} catch {
|
|
@@ -88030,8 +88230,8 @@ function maybeFlushDigests() {
|
|
|
88030
88230
|
|
|
88031
88231
|
// src/liveness-watch.ts
|
|
88032
88232
|
init_src5();
|
|
88033
|
-
import { readFileSync as
|
|
88034
|
-
import { join as
|
|
88233
|
+
import { readFileSync as readFileSync34, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88234
|
+
import { join as join38 } from "node:path";
|
|
88035
88235
|
|
|
88036
88236
|
// src/loop-lag.ts
|
|
88037
88237
|
var HEARTBEAT_MS = 500;
|
|
@@ -88163,11 +88363,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
|
|
|
88163
88363
|
var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
|
|
88164
88364
|
var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
|
|
88165
88365
|
function alarmStatePath(configDir) {
|
|
88166
|
-
return
|
|
88366
|
+
return join38(configDir, "liveness-alarms.json");
|
|
88167
88367
|
}
|
|
88168
88368
|
function loadAlarmState(path3) {
|
|
88169
88369
|
try {
|
|
88170
|
-
const raw2 = JSON.parse(
|
|
88370
|
+
const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
|
|
88171
88371
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
88172
88372
|
} catch {
|
|
88173
88373
|
return /* @__PURE__ */ new Map();
|
|
@@ -88431,7 +88631,7 @@ function createWatchBreaker(deps) {
|
|
|
88431
88631
|
}
|
|
88432
88632
|
|
|
88433
88633
|
// src/engine.ts
|
|
88434
|
-
var DAEMON_VERSION = true ? "2.0.23-dev.
|
|
88634
|
+
var DAEMON_VERSION = true ? "2.0.23-dev.4901" : "2.0.0-alpha.0";
|
|
88435
88635
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
88436
88636
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
88437
88637
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -88443,7 +88643,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
88443
88643
|
function appendIdentityAudit(path3, record2, line) {
|
|
88444
88644
|
if (!record2.accepted && record2.score <= 0) return;
|
|
88445
88645
|
try {
|
|
88446
|
-
if (
|
|
88646
|
+
if (existsSync30(path3) && statSync12(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
88447
88647
|
renameSync5(path3, `${path3}.1`);
|
|
88448
88648
|
}
|
|
88449
88649
|
appendFileSync4(path3, line);
|
|
@@ -88453,7 +88653,7 @@ function appendIdentityAudit(path3, record2, line) {
|
|
|
88453
88653
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
88454
88654
|
function loadTurnCursors(path3) {
|
|
88455
88655
|
try {
|
|
88456
|
-
const raw2 = JSON.parse(
|
|
88656
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88457
88657
|
return new Map(
|
|
88458
88658
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
88459
88659
|
);
|
|
@@ -88463,7 +88663,7 @@ function loadTurnCursors(path3) {
|
|
|
88463
88663
|
}
|
|
88464
88664
|
function loadTurnOffsets(path3) {
|
|
88465
88665
|
try {
|
|
88466
|
-
const raw2 = JSON.parse(
|
|
88666
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88467
88667
|
const out2 = /* @__PURE__ */ new Map();
|
|
88468
88668
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88469
88669
|
const off2 = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -88476,7 +88676,7 @@ function loadTurnOffsets(path3) {
|
|
|
88476
88676
|
}
|
|
88477
88677
|
function loadTurnMoves(path3) {
|
|
88478
88678
|
try {
|
|
88479
|
-
const raw2 = JSON.parse(
|
|
88679
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88480
88680
|
const out2 = /* @__PURE__ */ new Map();
|
|
88481
88681
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88482
88682
|
const to = typeof v === "object" && v !== null ? v.movedTo : void 0;
|
|
@@ -88497,7 +88697,7 @@ function saveTurnCursors(path3, cursors, offsets, moves = /* @__PURE__ */ new Ma
|
|
|
88497
88697
|
} catch {
|
|
88498
88698
|
}
|
|
88499
88699
|
}
|
|
88500
|
-
var turnCursorFile = (configDir) =>
|
|
88700
|
+
var turnCursorFile = (configDir) => join39(configDir, "turn-cursors.json");
|
|
88501
88701
|
function turnCursorOnDisk(configDir, sessionId) {
|
|
88502
88702
|
const path3 = turnCursorFile(configDir);
|
|
88503
88703
|
const offset = loadTurnOffsets(path3).get(sessionId);
|
|
@@ -88529,7 +88729,7 @@ function gitSourceWatchTargets(root) {
|
|
|
88529
88729
|
["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
|
|
88530
88730
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
88531
88731
|
);
|
|
88532
|
-
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(
|
|
88732
|
+
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join39(root, d) + sep5));
|
|
88533
88733
|
} catch {
|
|
88534
88734
|
}
|
|
88535
88735
|
const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
|
|
@@ -88541,19 +88741,19 @@ function gitSourceWatchTargets(root) {
|
|
|
88541
88741
|
if (!f.startsWith(prefix)) continue;
|
|
88542
88742
|
const rest2 = f.slice(prefix.length);
|
|
88543
88743
|
if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
|
|
88544
|
-
else targets.add(
|
|
88744
|
+
else targets.add(join39(root, f));
|
|
88545
88745
|
}
|
|
88546
88746
|
for (const c of children) {
|
|
88547
|
-
if (IGNORED_PATH.test(
|
|
88747
|
+
if (IGNORED_PATH.test(join39(root, c) + sep5)) continue;
|
|
88548
88748
|
if (hasIgnoredChild(c)) addUnder(c);
|
|
88549
|
-
else targets.add(
|
|
88749
|
+
else targets.add(join39(root, c));
|
|
88550
88750
|
}
|
|
88551
88751
|
};
|
|
88552
88752
|
addUnder("");
|
|
88553
88753
|
if (targets.size > 0) return [...targets];
|
|
88554
88754
|
} catch {
|
|
88555
88755
|
}
|
|
88556
|
-
return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(
|
|
88756
|
+
return readdirSync11(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join39(root, String(e.name)) + sep5)).map((e) => join39(root, String(e.name)));
|
|
88557
88757
|
}
|
|
88558
88758
|
function createWorkspaceEngine(opts) {
|
|
88559
88759
|
const paths = workspacePaths(opts.workspaceRoot);
|
|
@@ -88755,7 +88955,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88755
88955
|
const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
|
|
88756
88956
|
let episodeId2;
|
|
88757
88957
|
if (srcPaths.length > 0) {
|
|
88758
|
-
const abs = srcPaths.map((p) =>
|
|
88958
|
+
const abs = srcPaths.map((p) => join39(opts.workspaceRoot, p));
|
|
88759
88959
|
try {
|
|
88760
88960
|
const r = await runReindexPass(
|
|
88761
88961
|
`git-reindex:${profile.name} (${abs.length} files)`,
|
|
@@ -88791,8 +88991,8 @@ function createWorkspaceEngine(opts) {
|
|
|
88791
88991
|
`[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
|
|
88792
88992
|
);
|
|
88793
88993
|
};
|
|
88794
|
-
const gitDir =
|
|
88795
|
-
if (
|
|
88994
|
+
const gitDir = join39(opts.workspaceRoot, ".git");
|
|
88995
|
+
if (existsSync30(gitDir)) {
|
|
88796
88996
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
88797
88997
|
void handleGitEvent(ev).catch((err2) => {
|
|
88798
88998
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -88853,7 +89053,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88853
89053
|
},
|
|
88854
89054
|
onAlarms: (alarms) => {
|
|
88855
89055
|
toastLivenessAlarms(
|
|
88856
|
-
sharedAlarmToastGate(
|
|
89056
|
+
sharedAlarmToastGate(join39(globalDir(), "liveness-toasts.json")),
|
|
88857
89057
|
{ root: opts.workspaceRoot, name: profile.name },
|
|
88858
89058
|
alarms,
|
|
88859
89059
|
(body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
|
|
@@ -88880,7 +89080,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88880
89080
|
let subagentBase = null;
|
|
88881
89081
|
let subagentBaseVersion = 0;
|
|
88882
89082
|
const subagentRenders = /* @__PURE__ */ new Map();
|
|
88883
|
-
const sessions = createSessionRegistry({ originsPath:
|
|
89083
|
+
const sessions = createSessionRegistry({ originsPath: join39(paths.configDir, "session-origins.json") });
|
|
88884
89084
|
const sessionRenders = /* @__PURE__ */ new Map();
|
|
88885
89085
|
const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
|
|
88886
89086
|
const supersessionAsks = new SupersessionAsks();
|
|
@@ -88985,7 +89185,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88985
89185
|
const elicit = isEdgeElicitationEnabled();
|
|
88986
89186
|
const snapOpts = {
|
|
88987
89187
|
profile,
|
|
88988
|
-
atCommit: readGitRefState(
|
|
89188
|
+
atCommit: readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0,
|
|
88989
89189
|
reviewCount: pendingCount(paths),
|
|
88990
89190
|
reviewUiUrl: opts.reviewUrl(),
|
|
88991
89191
|
workingFile: workingFiles.mostRecent() ?? void 0,
|
|
@@ -89025,7 +89225,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89025
89225
|
);
|
|
89026
89226
|
return null;
|
|
89027
89227
|
}) : null;
|
|
89028
|
-
if (snapOpts.atCommit !== (readGitRefState(
|
|
89228
|
+
if (snapOpts.atCommit !== (readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0)) {
|
|
89029
89229
|
contextDirty = true;
|
|
89030
89230
|
return;
|
|
89031
89231
|
}
|
|
@@ -89071,10 +89271,10 @@ function createWorkspaceEngine(opts) {
|
|
|
89071
89271
|
} catch (err2) {
|
|
89072
89272
|
console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
|
|
89073
89273
|
}
|
|
89074
|
-
const target =
|
|
89274
|
+
const target = join39(opts.workspaceRoot, "AGENTS.md");
|
|
89075
89275
|
writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
|
|
89076
89276
|
if (elicit) {
|
|
89077
|
-
writePrimingHandles(
|
|
89277
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), [
|
|
89078
89278
|
...snapshot.recentProblems.map((r) => r.node),
|
|
89079
89279
|
// Resolved-band handles: the ✓ problem AND its Solution are citable
|
|
89080
89280
|
// (a fix tag on an already-resolved problem no-ops idempotently; the
|
|
@@ -89382,8 +89582,8 @@ function createWorkspaceEngine(opts) {
|
|
|
89382
89582
|
const cached2 = subagentRenders.get(a.agentId);
|
|
89383
89583
|
if (cached2?.key === key) return cached2.block;
|
|
89384
89584
|
const elicit = isEdgeElicitationEnabled();
|
|
89385
|
-
const handlesPath =
|
|
89386
|
-
const atCommit = readGitRefState(
|
|
89585
|
+
const handlesPath = join39(paths.configDir, "priming-handles.json");
|
|
89586
|
+
const atCommit = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89387
89587
|
const block = renderSubagentBlock({
|
|
89388
89588
|
store,
|
|
89389
89589
|
entry,
|
|
@@ -89438,7 +89638,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89438
89638
|
const cached2 = sessionRenders.get(sessionId);
|
|
89439
89639
|
if (cached2?.key === key) return cached2.block;
|
|
89440
89640
|
const elicit = isEdgeElicitationEnabled();
|
|
89441
|
-
const atCommit = readGitRefState(
|
|
89641
|
+
const atCommit = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89442
89642
|
const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
|
|
89443
89643
|
delete scoped.workingFile;
|
|
89444
89644
|
if (workingFile) {
|
|
@@ -89490,7 +89690,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89490
89690
|
]
|
|
89491
89691
|
};
|
|
89492
89692
|
if (elicit && block.handleNodes.length) {
|
|
89493
|
-
writePrimingHandles(
|
|
89693
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), block.handleNodes);
|
|
89494
89694
|
}
|
|
89495
89695
|
sessionRenders.delete(sessionId);
|
|
89496
89696
|
sessionRenders.set(sessionId, { key, block });
|
|
@@ -89624,7 +89824,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89624
89824
|
let processedTurns = 0;
|
|
89625
89825
|
const seqAtStart = store.currentIngestSeq();
|
|
89626
89826
|
const elicit = isEdgeElicitationEnabled();
|
|
89627
|
-
const handleMap = elicit ? readPrimingHandles(
|
|
89827
|
+
const handleMap = elicit ? readPrimingHandles(join39(paths.configDir, "priming-handles.json")) : {};
|
|
89628
89828
|
const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
|
|
89629
89829
|
const toRel = (abs) => {
|
|
89630
89830
|
const p = abs.replace(/\\/g, "/");
|
|
@@ -89847,7 +90047,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89847
90047
|
let anchorReadFailed = false;
|
|
89848
90048
|
if (p.location) {
|
|
89849
90049
|
try {
|
|
89850
|
-
fileText =
|
|
90050
|
+
fileText = readFileSync35(join39(opts.workspaceRoot, p.location.path), "utf8");
|
|
89851
90051
|
} catch {
|
|
89852
90052
|
anchorReadFailed = true;
|
|
89853
90053
|
}
|
|
@@ -90010,10 +90210,10 @@ function createWorkspaceEngine(opts) {
|
|
|
90010
90210
|
let enclosing = {};
|
|
90011
90211
|
if (p.location?.line !== void 0) {
|
|
90012
90212
|
try {
|
|
90013
|
-
const headSha = readGitRefState(
|
|
90213
|
+
const headSha = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
90014
90214
|
enclosing = {
|
|
90015
90215
|
line: p.location.line,
|
|
90016
|
-
fileText:
|
|
90216
|
+
fileText: readFileSync35(join39(opts.workspaceRoot, anchorPath), "utf8"),
|
|
90017
90217
|
...headSha ? { headSha } : {}
|
|
90018
90218
|
};
|
|
90019
90219
|
} catch {
|
|
@@ -90888,7 +91088,7 @@ B: ${b}`,
|
|
|
90888
91088
|
try {
|
|
90889
91089
|
const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
|
|
90890
91090
|
emitAndProjectSkills(opts.workspaceRoot, inputs);
|
|
90891
|
-
writePrimingHandles(
|
|
91091
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
|
|
90892
91092
|
} catch (err2) {
|
|
90893
91093
|
console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
|
|
90894
91094
|
}
|
|
@@ -91259,7 +91459,7 @@ B: ${b}`,
|
|
|
91259
91459
|
console.log(
|
|
91260
91460
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
91261
91461
|
);
|
|
91262
|
-
const pending =
|
|
91462
|
+
const pending = existsSync30(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
91263
91463
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
91264
91464
|
}
|
|
91265
91465
|
if (!shipsFromWorkspace(opts.workspaceRoot)) {
|
|
@@ -91271,7 +91471,7 @@ B: ${b}`,
|
|
|
91271
91471
|
console.log(
|
|
91272
91472
|
"[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
|
|
91273
91473
|
);
|
|
91274
|
-
const pending =
|
|
91474
|
+
const pending = existsSync30(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
91275
91475
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
91276
91476
|
}
|
|
91277
91477
|
try {
|
|
@@ -91451,7 +91651,7 @@ async function startDaemon(opts) {
|
|
|
91451
91651
|
);
|
|
91452
91652
|
await engine.stop();
|
|
91453
91653
|
try {
|
|
91454
|
-
if (
|
|
91654
|
+
if (existsSync31(engine.paths.daemonLock)) {
|
|
91455
91655
|
}
|
|
91456
91656
|
} catch {
|
|
91457
91657
|
}
|
|
@@ -91652,8 +91852,8 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
|
|
|
91652
91852
|
}
|
|
91653
91853
|
|
|
91654
91854
|
// src/edge-park.ts
|
|
91655
|
-
import { readFileSync as
|
|
91656
|
-
import { dirname as
|
|
91855
|
+
import { readFileSync as readFileSync36, renameSync as renameSync6, writeFileSync as writeFileSync26 } from "node:fs";
|
|
91856
|
+
import { dirname as dirname16, join as join40 } from "node:path";
|
|
91657
91857
|
var EDGE_PARK_CAP = 2e3;
|
|
91658
91858
|
var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
91659
91859
|
var EDGE_PARK_MAX_ATTEMPTS = 6;
|
|
@@ -91668,12 +91868,12 @@ function wireEdgeKey(from, type, to) {
|
|
|
91668
91868
|
return JSON.stringify([from, type, to]);
|
|
91669
91869
|
}
|
|
91670
91870
|
function edgeParkPath(workspaceConfigDir, destinationKey) {
|
|
91671
|
-
return
|
|
91871
|
+
return join40(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
|
|
91672
91872
|
}
|
|
91673
91873
|
function loadEdgePark(path3) {
|
|
91674
91874
|
let raw2;
|
|
91675
91875
|
try {
|
|
91676
|
-
raw2 = JSON.parse(
|
|
91876
|
+
raw2 = JSON.parse(readFileSync36(path3, "utf8"));
|
|
91677
91877
|
} catch {
|
|
91678
91878
|
return [];
|
|
91679
91879
|
}
|
|
@@ -91684,7 +91884,7 @@ function loadEdgePark(path3) {
|
|
|
91684
91884
|
}
|
|
91685
91885
|
function saveEdgePark(path3, queue) {
|
|
91686
91886
|
try {
|
|
91687
|
-
const tmp =
|
|
91887
|
+
const tmp = join40(dirname16(path3), `.${Date.now()}.edge-park.tmp`);
|
|
91688
91888
|
writeFileSync26(tmp, JSON.stringify(queue), "utf8");
|
|
91689
91889
|
renameSync6(tmp, path3);
|
|
91690
91890
|
} catch {
|
|
@@ -92007,8 +92207,8 @@ function invalidateInstanceReceipt(current, destination, failedId, mirrorLegacy)
|
|
|
92007
92207
|
// src/multi.ts
|
|
92008
92208
|
init_dist();
|
|
92009
92209
|
init_src5();
|
|
92010
|
-
import { existsSync as
|
|
92011
|
-
import { basename as basename10, dirname as
|
|
92210
|
+
import { existsSync as existsSync36, readFileSync as readFileSync42, writeFileSync as writeFileSync29 } from "node:fs";
|
|
92211
|
+
import { basename as basename10, dirname as dirname19, join as join49, resolve as pathResolve } from "node:path";
|
|
92012
92212
|
|
|
92013
92213
|
// src/principle-sync.ts
|
|
92014
92214
|
init_src5();
|
|
@@ -92036,8 +92236,8 @@ init_reconcile();
|
|
|
92036
92236
|
|
|
92037
92237
|
// src/lockfile-auto.ts
|
|
92038
92238
|
init_src();
|
|
92039
|
-
import { existsSync as
|
|
92040
|
-
import { join as
|
|
92239
|
+
import { existsSync as existsSync32, readFileSync as readFileSync37 } from "node:fs";
|
|
92240
|
+
import { join as join41 } from "node:path";
|
|
92041
92241
|
|
|
92042
92242
|
// src/package-index.ts
|
|
92043
92243
|
init_src();
|
|
@@ -92210,11 +92410,11 @@ function runLockfilePass(opts) {
|
|
|
92210
92410
|
{ file: "package-lock.json", parse: parsePackageLockJson }
|
|
92211
92411
|
];
|
|
92212
92412
|
for (const c of candidates) {
|
|
92213
|
-
const p =
|
|
92214
|
-
if (!
|
|
92413
|
+
const p = join41(opts.root, c.file);
|
|
92414
|
+
if (!existsSync32(p)) continue;
|
|
92215
92415
|
let sbom;
|
|
92216
92416
|
try {
|
|
92217
|
-
sbom = c.parse(
|
|
92417
|
+
sbom = c.parse(readFileSync37(p, "utf8"));
|
|
92218
92418
|
} catch {
|
|
92219
92419
|
continue;
|
|
92220
92420
|
}
|
|
@@ -92234,7 +92434,7 @@ init_src10();
|
|
|
92234
92434
|
init_src();
|
|
92235
92435
|
|
|
92236
92436
|
// src/contribution-ready.ts
|
|
92237
|
-
|
|
92437
|
+
init_src4();
|
|
92238
92438
|
function cosine4(a, b) {
|
|
92239
92439
|
if (a.length === 0 || a.length !== b.length) return 0;
|
|
92240
92440
|
let dot = 0;
|
|
@@ -92248,7 +92448,9 @@ function cosine4(a, b) {
|
|
|
92248
92448
|
return na === 0 || nb === 0 ? 0 : dot / (Math.sqrt(na) * Math.sqrt(nb));
|
|
92249
92449
|
}
|
|
92250
92450
|
function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
92251
|
-
const
|
|
92451
|
+
const versionOf = (n) => String(n.attrs?.["embeddingVersion"] ?? "hash-v1");
|
|
92452
|
+
const version3 = versionOf(node2);
|
|
92453
|
+
const floor = opts.dedupCosine ?? cosineBandsFor(version3).dedup;
|
|
92252
92454
|
const emb = node2.embedding ?? [];
|
|
92253
92455
|
if (emb.length === 0) {
|
|
92254
92456
|
return { ready: true, surprise: 1, topCosine: 0, reason: "no-embedding (fidelity-first)" };
|
|
@@ -92257,7 +92459,7 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
|
92257
92459
|
for (const other of neighbors) {
|
|
92258
92460
|
if (other.id === node2.id) continue;
|
|
92259
92461
|
const oe = other.embedding ?? [];
|
|
92260
|
-
if (oe.length !== emb.length) continue;
|
|
92462
|
+
if (oe.length !== emb.length || versionOf(other) !== version3) continue;
|
|
92261
92463
|
const c = cosine4(emb, oe);
|
|
92262
92464
|
if (c > topCosine) topCosine = c;
|
|
92263
92465
|
}
|
|
@@ -92275,8 +92477,8 @@ init_profile2();
|
|
|
92275
92477
|
init_session_registry();
|
|
92276
92478
|
|
|
92277
92479
|
// src/public-symbols.ts
|
|
92278
|
-
import { readFileSync as
|
|
92279
|
-
import { join as
|
|
92480
|
+
import { readFileSync as readFileSync38, readdirSync as readdirSync12, existsSync as existsSync33 } from "node:fs";
|
|
92481
|
+
import { join as join42 } from "node:path";
|
|
92280
92482
|
var HEAD_BYTES = 8 * 1024;
|
|
92281
92483
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
92282
92484
|
var MIN_SYMBOL_LEN = 4;
|
|
@@ -92309,20 +92511,20 @@ function bindingNames(clause) {
|
|
|
92309
92511
|
function internalPackageNames(workspaceRoot) {
|
|
92310
92512
|
const names = /* @__PURE__ */ new Set();
|
|
92311
92513
|
const tryRead = (dir) => {
|
|
92312
|
-
const pj =
|
|
92313
|
-
if (!
|
|
92514
|
+
const pj = join42(dir, "package.json");
|
|
92515
|
+
if (!existsSync33(pj)) return;
|
|
92314
92516
|
try {
|
|
92315
|
-
const name2 = JSON.parse(
|
|
92517
|
+
const name2 = JSON.parse(readFileSync38(pj, "utf8")).name;
|
|
92316
92518
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
92317
92519
|
} catch {
|
|
92318
92520
|
}
|
|
92319
92521
|
};
|
|
92320
92522
|
tryRead(workspaceRoot);
|
|
92321
92523
|
for (const group of ["packages", "apps"]) {
|
|
92322
|
-
const groupDir =
|
|
92323
|
-
if (!
|
|
92524
|
+
const groupDir = join42(workspaceRoot, group);
|
|
92525
|
+
if (!existsSync33(groupDir)) continue;
|
|
92324
92526
|
try {
|
|
92325
|
-
for (const entry of readdirSync12(groupDir)) tryRead(
|
|
92527
|
+
for (const entry of readdirSync12(groupDir)) tryRead(join42(groupDir, entry));
|
|
92326
92528
|
} catch {
|
|
92327
92529
|
}
|
|
92328
92530
|
}
|
|
@@ -92341,7 +92543,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92341
92543
|
}
|
|
92342
92544
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
92343
92545
|
try {
|
|
92344
|
-
return
|
|
92546
|
+
return readFileSync38(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
92345
92547
|
} catch {
|
|
92346
92548
|
return "";
|
|
92347
92549
|
}
|
|
@@ -92361,7 +92563,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92361
92563
|
}
|
|
92362
92564
|
const symbols = /* @__PURE__ */ new Set();
|
|
92363
92565
|
for (const rel of files) {
|
|
92364
|
-
const head2 = readHead(
|
|
92566
|
+
const head2 = readHead(join42(workspaceRoot, rel));
|
|
92365
92567
|
if (!head2) continue;
|
|
92366
92568
|
for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
|
|
92367
92569
|
re.lastIndex = 0;
|
|
@@ -93392,7 +93594,7 @@ init_config();
|
|
|
93392
93594
|
|
|
93393
93595
|
// src/update.ts
|
|
93394
93596
|
import { spawn as spawn2 } from "node:child_process";
|
|
93395
|
-
import { isAbsolute as isAbsolute6, join as
|
|
93597
|
+
import { isAbsolute as isAbsolute6, join as join43 } from "node:path";
|
|
93396
93598
|
var PACKAGE_NAME = "@inerrata-corporation/errata";
|
|
93397
93599
|
function parse3(v) {
|
|
93398
93600
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
|
|
@@ -93541,7 +93743,7 @@ async function runInstalledHookRefresh() {
|
|
|
93541
93743
|
let worst = 0;
|
|
93542
93744
|
for (const harness of ["codex", "claude"]) {
|
|
93543
93745
|
const code = await new Promise((resolve11) => {
|
|
93544
|
-
const child = spawn2(process.execPath, [
|
|
93746
|
+
const child = spawn2(process.execPath, [join43(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", harness, "--refresh-existing"], {
|
|
93545
93747
|
windowsHide: true,
|
|
93546
93748
|
stdio: "inherit",
|
|
93547
93749
|
timeout: 3e4
|
|
@@ -93690,12 +93892,12 @@ function landCloudEdge(store, e, from, to) {
|
|
|
93690
93892
|
}
|
|
93691
93893
|
|
|
93692
93894
|
// src/causal-edge-queue.ts
|
|
93693
|
-
import { readFileSync as
|
|
93694
|
-
import { dirname as
|
|
93895
|
+
import { readFileSync as readFileSync39, renameSync as renameSync7, writeFileSync as writeFileSync27 } from "node:fs";
|
|
93896
|
+
import { dirname as dirname17, join as join44 } from "node:path";
|
|
93695
93897
|
var CAUSAL_EDGE_QUEUE_CAP = 5e3;
|
|
93696
93898
|
var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
93697
93899
|
function causalEdgeQueuePath(workspaceConfigDir) {
|
|
93698
|
-
return
|
|
93900
|
+
return join44(workspaceConfigDir, "causal-edge-queue.json");
|
|
93699
93901
|
}
|
|
93700
93902
|
function parkedEdgeKey(e) {
|
|
93701
93903
|
return `${e.from}|${e.type}|${e.to}`;
|
|
@@ -93703,7 +93905,7 @@ function parkedEdgeKey(e) {
|
|
|
93703
93905
|
function loadCausalEdgeQueue(path3) {
|
|
93704
93906
|
let raw2;
|
|
93705
93907
|
try {
|
|
93706
|
-
raw2 = JSON.parse(
|
|
93908
|
+
raw2 = JSON.parse(readFileSync39(path3, "utf8"));
|
|
93707
93909
|
} catch {
|
|
93708
93910
|
return [];
|
|
93709
93911
|
}
|
|
@@ -93714,7 +93916,7 @@ function loadCausalEdgeQueue(path3) {
|
|
|
93714
93916
|
}
|
|
93715
93917
|
function saveCausalEdgeQueue(path3, queue) {
|
|
93716
93918
|
try {
|
|
93717
|
-
const tmp =
|
|
93919
|
+
const tmp = join44(dirname17(path3), `.${Date.now()}.causal-edge-queue.tmp`);
|
|
93718
93920
|
writeFileSync27(tmp, JSON.stringify(queue), "utf8");
|
|
93719
93921
|
renameSync7(tmp, path3);
|
|
93720
93922
|
} catch {
|
|
@@ -94146,9 +94348,9 @@ init_src11();
|
|
|
94146
94348
|
init_src();
|
|
94147
94349
|
import { execFile as execFile6 } from "node:child_process";
|
|
94148
94350
|
import { promisify as promisify4 } from "node:util";
|
|
94149
|
-
import { extname as extname3, join as
|
|
94351
|
+
import { extname as extname3, join as join45 } from "node:path";
|
|
94150
94352
|
import { createHash as createHash19 } from "node:crypto";
|
|
94151
|
-
import { readFileSync as
|
|
94353
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
94152
94354
|
|
|
94153
94355
|
// src/history-dependency-snapshot.ts
|
|
94154
94356
|
init_src();
|
|
@@ -94271,7 +94473,7 @@ var Bounded = class extends Map {
|
|
|
94271
94473
|
var DEFAULT_GIT = {};
|
|
94272
94474
|
function readFileSafe(path3) {
|
|
94273
94475
|
try {
|
|
94274
|
-
return
|
|
94476
|
+
return readFileSync40(path3, "utf8");
|
|
94275
94477
|
} catch {
|
|
94276
94478
|
return "";
|
|
94277
94479
|
}
|
|
@@ -94325,7 +94527,7 @@ async function syncHistoryRevisionPage(opts, resolve11) {
|
|
|
94325
94527
|
const projectId = profile.projectId;
|
|
94326
94528
|
const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
|
|
94327
94529
|
const caches = cachesFor(opts.git ?? DEFAULT_GIT);
|
|
94328
|
-
const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(
|
|
94530
|
+
const ignoreKey = createHash19("sha256").update(JSON.stringify(profile.ignoreExtra ?? [])).update(readFileSafe(join45(root, ".errataignore"))).digest("hex").slice(0, 16);
|
|
94329
94531
|
const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
|
|
94330
94532
|
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
|
|
94331
94533
|
const oldCursor = profile.historyRevisionCursor;
|
|
@@ -94645,8 +94847,8 @@ ${await git3(["rev-list", "--parents", "-1", from])}`.split("\n").map((row) => r
|
|
|
94645
94847
|
init_src7();
|
|
94646
94848
|
init_src();
|
|
94647
94849
|
import { execFile as execFile7 } from "node:child_process";
|
|
94648
|
-
import { readFileSync as
|
|
94649
|
-
import { join as
|
|
94850
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
94851
|
+
import { join as join46 } from "node:path";
|
|
94650
94852
|
import { promisify as promisify5 } from "node:util";
|
|
94651
94853
|
|
|
94652
94854
|
// src/history-walk.ts
|
|
@@ -95205,7 +95407,7 @@ async function defaultGit(root, args2) {
|
|
|
95205
95407
|
function readIgnoreLines(root, profile) {
|
|
95206
95408
|
let lines = [];
|
|
95207
95409
|
try {
|
|
95208
|
-
lines =
|
|
95410
|
+
lines = readFileSync41(join46(root, ".errataignore"), "utf8").split("\n");
|
|
95209
95411
|
} catch {
|
|
95210
95412
|
}
|
|
95211
95413
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -95785,8 +95987,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
95785
95987
|
init_cloud_auth();
|
|
95786
95988
|
import { createHash as createHash20 } from "node:crypto";
|
|
95787
95989
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
95788
|
-
import { existsSync as
|
|
95789
|
-
import { join as
|
|
95990
|
+
import { existsSync as existsSync34, writeFileSync as writeFileSync28 } from "node:fs";
|
|
95991
|
+
import { join as join47 } from "node:path";
|
|
95790
95992
|
|
|
95791
95993
|
// src/device-poll.ts
|
|
95792
95994
|
var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
|
|
@@ -96245,8 +96447,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
|
|
|
96245
96447
|
delete nextProfile.projectLinkHold;
|
|
96246
96448
|
let wroteIgnore = false;
|
|
96247
96449
|
if (decision.writeIgnoreStarter !== false) {
|
|
96248
|
-
const target =
|
|
96249
|
-
if (!
|
|
96450
|
+
const target = join47(root, ".errataignore");
|
|
96451
|
+
if (!existsSync34(target)) {
|
|
96250
96452
|
writeFileSync28(target, IGNORE_STARTER, "utf8");
|
|
96251
96453
|
wroteIgnore = true;
|
|
96252
96454
|
}
|
|
@@ -96260,13 +96462,13 @@ init_registry();
|
|
|
96260
96462
|
|
|
96261
96463
|
// src/adopt.ts
|
|
96262
96464
|
init_git_remote();
|
|
96263
|
-
import { existsSync as
|
|
96264
|
-
import { dirname as
|
|
96465
|
+
import { existsSync as existsSync35 } from "node:fs";
|
|
96466
|
+
import { dirname as dirname18, join as join48 } from "node:path";
|
|
96265
96467
|
function findGitRoot(absPath) {
|
|
96266
96468
|
let dir = absPath;
|
|
96267
96469
|
for (let depth = 0; depth < 64; depth++) {
|
|
96268
|
-
if (
|
|
96269
|
-
const parent =
|
|
96470
|
+
if (existsSync35(join48(dir, ".git"))) return dir;
|
|
96471
|
+
const parent = dirname18(dir);
|
|
96270
96472
|
if (parent === dir) return null;
|
|
96271
96473
|
dir = parent;
|
|
96272
96474
|
}
|
|
@@ -96908,7 +97110,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96908
97110
|
};
|
|
96909
97111
|
const sharedDbPath = sharedStorePath();
|
|
96910
97112
|
ensureParent(sharedDbPath);
|
|
96911
|
-
if (sharedDbPath !== ":memory:") excludeFromIndexing(
|
|
97113
|
+
if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname19(sharedDbPath));
|
|
96912
97114
|
await prepareStore(sharedDbPath, process.cwd(), "shared");
|
|
96913
97115
|
const sharedStore = openGraphStore({ path: sharedDbPath });
|
|
96914
97116
|
const bundledRun = import.meta.url.endsWith(".mjs");
|
|
@@ -97052,7 +97254,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97052
97254
|
held.push(...quarantined);
|
|
97053
97255
|
let ignoreFile = "";
|
|
97054
97256
|
try {
|
|
97055
|
-
ignoreFile =
|
|
97257
|
+
ignoreFile = readFileSync42(join49(r.root, ".errataignore"), "utf8");
|
|
97056
97258
|
} catch {
|
|
97057
97259
|
}
|
|
97058
97260
|
const retryInputs = JSON.stringify([
|
|
@@ -97120,7 +97322,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97120
97322
|
const id = entry.id;
|
|
97121
97323
|
const castaliaPath = workspacePaths(entry.path).castalia;
|
|
97122
97324
|
ensureParent(castaliaPath);
|
|
97123
|
-
excludeFromIndexing(
|
|
97325
|
+
excludeFromIndexing(dirname19(castaliaPath));
|
|
97124
97326
|
await prepareStore(castaliaPath, entry.path, id);
|
|
97125
97327
|
if (stopping) throw new Error("daemon stopping");
|
|
97126
97328
|
const wsIdentity = identityFor(entry);
|
|
@@ -97633,10 +97835,10 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97633
97835
|
};
|
|
97634
97836
|
const MISFILED_SWEEP_DELAY_MS = 2 * 6e4;
|
|
97635
97837
|
const sweepMisfiled = async (rec) => {
|
|
97636
|
-
const checkedPath =
|
|
97838
|
+
const checkedPath = join49(workspacePaths(rec.root).configDir, "rehome-checked.json");
|
|
97637
97839
|
let checked;
|
|
97638
97840
|
try {
|
|
97639
|
-
checked = new Set(JSON.parse(
|
|
97841
|
+
checked = new Set(JSON.parse(readFileSync42(checkedPath, "utf8")));
|
|
97640
97842
|
} catch {
|
|
97641
97843
|
checked = /* @__PURE__ */ new Set();
|
|
97642
97844
|
}
|
|
@@ -97755,7 +97957,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97755
97957
|
lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
|
|
97756
97958
|
} catch {
|
|
97757
97959
|
}
|
|
97758
|
-
const reason = retireDecision({ exists:
|
|
97960
|
+
const reason = retireDecision({ exists: existsSync36(rec.root), lastActiveAt, now });
|
|
97759
97961
|
if (reason) void retireWorkspace(rec, reason);
|
|
97760
97962
|
}
|
|
97761
97963
|
};
|
|
@@ -99008,6 +99210,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
99008
99210
|
|
|
99009
99211
|
// src/cli.ts
|
|
99010
99212
|
init_src5();
|
|
99213
|
+
init_src4();
|
|
99011
99214
|
init_profile2();
|
|
99012
99215
|
init_git_remote();
|
|
99013
99216
|
init_config();
|
|
@@ -99383,7 +99586,7 @@ import { spawnSync as spawnSync2 } from "node:child_process";
|
|
|
99383
99586
|
|
|
99384
99587
|
// src/codex-runtime.ts
|
|
99385
99588
|
import { readdirSync as readdirSync13, statSync as statSync13 } from "node:fs";
|
|
99386
|
-
import { join as
|
|
99589
|
+
import { join as join50 } from "node:path";
|
|
99387
99590
|
function resolveCodexExecutable(options = {}) {
|
|
99388
99591
|
const platform = options.platform ?? process.platform;
|
|
99389
99592
|
const env2 = options.env ?? process.env;
|
|
@@ -99398,13 +99601,13 @@ function resolveCodexExecutable(options = {}) {
|
|
|
99398
99601
|
};
|
|
99399
99602
|
for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
|
|
99400
99603
|
if (!dir.trim()) continue;
|
|
99401
|
-
const path3 =
|
|
99604
|
+
const path3 = join50(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
|
|
99402
99605
|
if (fileTime(path3) !== null) return path3;
|
|
99403
99606
|
}
|
|
99404
99607
|
if (!env2["LOCALAPPDATA"]) return "codex";
|
|
99405
|
-
const root =
|
|
99608
|
+
const root = join50(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
|
|
99406
99609
|
try {
|
|
99407
|
-
const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
99610
|
+
const candidates = readdirSync13(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join50(root, entry.name, "codex.exe")).map((path3) => ({ path: path3, mtime: fileTime(path3) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
|
|
99408
99611
|
return candidates[0]?.path ?? "codex";
|
|
99409
99612
|
} catch {
|
|
99410
99613
|
return "codex";
|
|
@@ -99543,14 +99746,14 @@ async function diagnoseInstallation(cfg, dependencies) {
|
|
|
99543
99746
|
}
|
|
99544
99747
|
|
|
99545
99748
|
// src/credential-scan.ts
|
|
99546
|
-
import { readFileSync as
|
|
99749
|
+
import { readFileSync as readFileSync44, statSync as statSync14 } from "node:fs";
|
|
99547
99750
|
import { homedir as homedir8 } from "node:os";
|
|
99548
|
-
import { join as
|
|
99751
|
+
import { join as join52 } from "node:path";
|
|
99549
99752
|
|
|
99550
99753
|
// src/claude-statusline.ts
|
|
99551
|
-
import { existsSync as
|
|
99754
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync9, readFileSync as readFileSync43, writeFileSync as writeFileSync30 } from "node:fs";
|
|
99552
99755
|
import { homedir as homedir7 } from "node:os";
|
|
99553
|
-
import { dirname as
|
|
99756
|
+
import { dirname as dirname20, join as join51 } from "node:path";
|
|
99554
99757
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
99555
99758
|
import { readFileSync } from 'node:fs';
|
|
99556
99759
|
|
|
@@ -99598,8 +99801,8 @@ function isSameInstall(value, relay) {
|
|
|
99598
99801
|
return command.includes(relay.replace(/\\/g, "/").toLowerCase());
|
|
99599
99802
|
}
|
|
99600
99803
|
function userClaudeSettingsPath() {
|
|
99601
|
-
const base = process.env["CLAUDE_CONFIG_DIR"] ??
|
|
99602
|
-
return
|
|
99804
|
+
const base = process.env["CLAUDE_CONFIG_DIR"] ?? join51(homedir7(), ".claude");
|
|
99805
|
+
return join51(base, "settings.json");
|
|
99603
99806
|
}
|
|
99604
99807
|
function ensureUserStatusLine(opts) {
|
|
99605
99808
|
const env2 = opts.env ?? process.env;
|
|
@@ -99607,22 +99810,22 @@ function ensureUserStatusLine(opts) {
|
|
|
99607
99810
|
if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
|
|
99608
99811
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
99609
99812
|
let settings = {};
|
|
99610
|
-
if (
|
|
99813
|
+
if (existsSync37(settingsPath)) {
|
|
99611
99814
|
try {
|
|
99612
|
-
const parsed = JSON.parse(
|
|
99815
|
+
const parsed = JSON.parse(readFileSync43(settingsPath, "utf8"));
|
|
99613
99816
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
99614
99817
|
settings = parsed;
|
|
99615
99818
|
} catch {
|
|
99616
99819
|
return "unreadable";
|
|
99617
99820
|
}
|
|
99618
99821
|
}
|
|
99619
|
-
const relay =
|
|
99822
|
+
const relay = join51(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
99620
99823
|
const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
|
|
99621
99824
|
const ownMain = keep(settings["statusLine"]);
|
|
99622
99825
|
const ownRows = keep(settings["subagentStatusLine"]);
|
|
99623
99826
|
if (ownMain && ownRows) return "kept-own";
|
|
99624
99827
|
mkdirSync9(opts.relayDir, { recursive: true });
|
|
99625
|
-
if (!
|
|
99828
|
+
if (!existsSync37(relay) || readFileSync43(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
99626
99829
|
writeFileSync30(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
99627
99830
|
}
|
|
99628
99831
|
const nodePath = opts.nodePath ?? process.execPath;
|
|
@@ -99634,7 +99837,7 @@ function ensureUserStatusLine(opts) {
|
|
|
99634
99837
|
return ownMain ? "kept-own" : "unchanged";
|
|
99635
99838
|
}
|
|
99636
99839
|
Object.assign(settings, next);
|
|
99637
|
-
mkdirSync9(
|
|
99840
|
+
mkdirSync9(dirname20(settingsPath), { recursive: true });
|
|
99638
99841
|
writeFileSync30(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
99639
99842
|
return "installed";
|
|
99640
99843
|
}
|
|
@@ -99676,36 +99879,36 @@ function findCredentialLines(text) {
|
|
|
99676
99879
|
function harnessConfigPaths(root) {
|
|
99677
99880
|
const env2 = process.env;
|
|
99678
99881
|
const home = homedir8();
|
|
99679
|
-
const codexHome = env2["CODEX_HOME"] ||
|
|
99680
|
-
const geminiHome =
|
|
99882
|
+
const codexHome = env2["CODEX_HOME"] || join52(home, ".codex");
|
|
99883
|
+
const geminiHome = join52(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
|
|
99681
99884
|
return [
|
|
99682
99885
|
// Claude Code: user settings, `claude mcp add` (local/user scope), project.
|
|
99683
99886
|
userClaudeSettingsPath(),
|
|
99684
|
-
|
|
99685
|
-
|
|
99686
|
-
|
|
99687
|
-
|
|
99887
|
+
join52(env2["CLAUDE_CONFIG_DIR"] ?? home, ".claude.json"),
|
|
99888
|
+
join52(root, ".claude", "settings.json"),
|
|
99889
|
+
join52(root, ".claude", "settings.local.json"),
|
|
99890
|
+
join52(root, ".mcp.json"),
|
|
99688
99891
|
// Codex
|
|
99689
|
-
|
|
99690
|
-
|
|
99892
|
+
join52(codexHome, "config.toml"),
|
|
99893
|
+
join52(root, ".codex", "config.toml"),
|
|
99691
99894
|
// Gemini CLI
|
|
99692
|
-
|
|
99693
|
-
|
|
99895
|
+
join52(geminiHome, "settings.json"),
|
|
99896
|
+
join52(root, ".gemini", "settings.json"),
|
|
99694
99897
|
// Cursor
|
|
99695
|
-
|
|
99696
|
-
|
|
99898
|
+
join52(home, ".cursor", "mcp.json"),
|
|
99899
|
+
join52(root, ".cursor", "mcp.json"),
|
|
99697
99900
|
// VS Code (user profile mcp.json + workspace)
|
|
99698
|
-
|
|
99699
|
-
|
|
99901
|
+
join52(vscodeUserDir(home, env2), "mcp.json"),
|
|
99902
|
+
join52(root, ".vscode", "mcp.json"),
|
|
99700
99903
|
// OpenCode (XDG on every platform; the daemon's installer writes the project one)
|
|
99701
|
-
|
|
99702
|
-
|
|
99904
|
+
join52(env2["XDG_CONFIG_HOME"] ?? join52(home, ".config"), "opencode", "opencode.json"),
|
|
99905
|
+
join52(root, "opencode.json")
|
|
99703
99906
|
];
|
|
99704
99907
|
}
|
|
99705
99908
|
function vscodeUserDir(home, env2) {
|
|
99706
|
-
if (process.platform === "win32") return
|
|
99707
|
-
if (process.platform === "darwin") return
|
|
99708
|
-
return
|
|
99909
|
+
if (process.platform === "win32") return join52(env2["APPDATA"] ?? join52(home, "AppData", "Roaming"), "Code", "User");
|
|
99910
|
+
if (process.platform === "darwin") return join52(home, "Library", "Application Support", "Code", "User");
|
|
99911
|
+
return join52(env2["XDG_CONFIG_HOME"] ?? join52(home, ".config"), "Code", "User");
|
|
99709
99912
|
}
|
|
99710
99913
|
function scanHarnessConfigs(paths, read2 = readBounded) {
|
|
99711
99914
|
const findings = [];
|
|
@@ -99722,7 +99925,7 @@ function readBounded(path3) {
|
|
|
99722
99925
|
try {
|
|
99723
99926
|
const stat4 = statSync14(path3);
|
|
99724
99927
|
if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
|
|
99725
|
-
return
|
|
99928
|
+
return readFileSync44(path3, "utf8");
|
|
99726
99929
|
} catch {
|
|
99727
99930
|
return null;
|
|
99728
99931
|
}
|
|
@@ -99747,14 +99950,14 @@ function credentialHygieneCheck(scan2) {
|
|
|
99747
99950
|
|
|
99748
99951
|
// src/codex-doctor.ts
|
|
99749
99952
|
import { spawn as spawn4 } from "node:child_process";
|
|
99750
|
-
import { readFileSync as
|
|
99751
|
-
import { join as
|
|
99953
|
+
import { readFileSync as readFileSync46, statSync as statSync15 } from "node:fs";
|
|
99954
|
+
import { join as join54 } from "node:path";
|
|
99752
99955
|
import { createInterface } from "node:readline";
|
|
99753
99956
|
|
|
99754
99957
|
// src/codex-hooks.ts
|
|
99755
|
-
import { existsSync as
|
|
99958
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync10, readFileSync as readFileSync45, renameSync as renameSync8, unlinkSync as unlinkSync5, writeFileSync as writeFileSync31 } from "node:fs";
|
|
99756
99959
|
import { homedir as homedir9 } from "node:os";
|
|
99757
|
-
import { join as
|
|
99960
|
+
import { join as join53 } from "node:path";
|
|
99758
99961
|
|
|
99759
99962
|
// src/hook-commands.ts
|
|
99760
99963
|
function hookCurlCommand(port, path3 = "/api/hook") {
|
|
@@ -100010,34 +100213,34 @@ function buildCodexRelaySource(workspaceRoot) {
|
|
|
100010
100213
|
init_checkout_root();
|
|
100011
100214
|
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.";
|
|
100012
100215
|
function writeRelay(file2, source) {
|
|
100013
|
-
if (
|
|
100216
|
+
if (existsSync38(file2) && readFileSync45(file2, "utf8") === source) return;
|
|
100014
100217
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
100015
100218
|
try {
|
|
100016
100219
|
writeFileSync31(temp, source, { encoding: "utf8", mode: 384 });
|
|
100017
100220
|
renameSync8(temp, file2);
|
|
100018
100221
|
} finally {
|
|
100019
|
-
if (
|
|
100222
|
+
if (existsSync38(temp)) unlinkSync5(temp);
|
|
100020
100223
|
}
|
|
100021
100224
|
}
|
|
100022
100225
|
function refreshCodexRelay(root) {
|
|
100023
|
-
const config2 =
|
|
100024
|
-
if (!
|
|
100025
|
-
const existing =
|
|
100226
|
+
const config2 = join53(root, ".codex", "config.toml");
|
|
100227
|
+
if (!existsSync38(config2)) return "absent";
|
|
100228
|
+
const existing = readFileSync45(config2, "utf8");
|
|
100026
100229
|
if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
|
|
100027
100230
|
replaceCodexHooks(existing, "");
|
|
100028
|
-
const relay =
|
|
100029
|
-
const prior =
|
|
100231
|
+
const relay = join53(root, ".codex", "hooks", "errata-relay.mjs");
|
|
100232
|
+
const prior = existsSync38(relay) ? readFileSync45(relay, "utf8") : "";
|
|
100030
100233
|
if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
|
|
100031
100234
|
throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
|
|
100032
100235
|
}
|
|
100033
100236
|
const source = buildCodexRelaySource(checkoutRootOf(root));
|
|
100034
100237
|
if (prior === source) return "current";
|
|
100035
|
-
mkdirSync10(
|
|
100238
|
+
mkdirSync10(join53(root, ".codex", "hooks"), { recursive: true });
|
|
100036
100239
|
writeRelay(relay, source);
|
|
100037
100240
|
return "updated";
|
|
100038
100241
|
}
|
|
100039
|
-
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] ||
|
|
100040
|
-
return
|
|
100242
|
+
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join53(homedir9(), ".codex")) {
|
|
100243
|
+
return existsSync38(join53(root, ".codex")) || existsSync38(codexHome);
|
|
100041
100244
|
}
|
|
100042
100245
|
function replaceCodexHooks(existing, block) {
|
|
100043
100246
|
const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
|
|
@@ -100053,14 +100256,14 @@ function replaceCodexHooks(existing, block) {
|
|
|
100053
100256
|
return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
|
|
100054
100257
|
}
|
|
100055
100258
|
function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
100056
|
-
const dir =
|
|
100057
|
-
const file2 =
|
|
100058
|
-
const relay =
|
|
100259
|
+
const dir = join53(root, ".codex");
|
|
100260
|
+
const file2 = join53(dir, "config.toml");
|
|
100261
|
+
const relay = join53(dir, "hooks", "errata-relay.mjs");
|
|
100059
100262
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
100060
|
-
const final = replaceCodexHooks(
|
|
100061
|
-
mkdirSync10(
|
|
100263
|
+
const final = replaceCodexHooks(existsSync38(file2) ? readFileSync45(file2, "utf8") : "", block);
|
|
100264
|
+
mkdirSync10(join53(dir, "hooks"), { recursive: true });
|
|
100062
100265
|
writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
|
|
100063
|
-
if (!
|
|
100266
|
+
if (!existsSync38(file2) || readFileSync45(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
|
|
100064
100267
|
return file2;
|
|
100065
100268
|
}
|
|
100066
100269
|
|
|
@@ -100069,7 +100272,7 @@ init_checkout_root();
|
|
|
100069
100272
|
function inspectCodexRelay(cwd) {
|
|
100070
100273
|
const root = nearestGitRoot(cwd) ?? cwd;
|
|
100071
100274
|
try {
|
|
100072
|
-
const source =
|
|
100275
|
+
const source = readFileSync46(join54(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
|
|
100073
100276
|
if (source === buildCodexRelaySource(checkoutRootOf(root))) {
|
|
100074
100277
|
return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
|
|
100075
100278
|
}
|
|
@@ -100080,8 +100283,8 @@ function inspectCodexRelay(cwd) {
|
|
|
100080
100283
|
function inspectCodexContext(cwd) {
|
|
100081
100284
|
const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
|
|
100082
100285
|
try {
|
|
100083
|
-
const file2 =
|
|
100084
|
-
if (statSync15(file2).size <= 128 * 1024 &&
|
|
100286
|
+
const file2 = join54(root, ".errata", "context.md");
|
|
100287
|
+
if (statSync15(file2).size <= 128 * 1024 && readFileSync46(file2, "utf8").trim()) {
|
|
100085
100288
|
return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
|
|
100086
100289
|
}
|
|
100087
100290
|
} catch {
|
|
@@ -100259,10 +100462,10 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
100259
100462
|
|
|
100260
100463
|
// src/codex-context-plugin.ts
|
|
100261
100464
|
import { createHash as createHash21 } from "node:crypto";
|
|
100262
|
-
import { cpSync as cpSync2, existsSync as
|
|
100465
|
+
import { cpSync as cpSync2, existsSync as existsSync39, mkdirSync as mkdirSync11, readFileSync as readFileSync47, renameSync as renameSync9, writeFileSync as writeFileSync32 } from "node:fs";
|
|
100263
100466
|
import { homedir as homedir10 } from "node:os";
|
|
100264
|
-
import { join as
|
|
100265
|
-
import { fileURLToPath as
|
|
100467
|
+
import { join as join55 } from "node:path";
|
|
100468
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
100266
100469
|
|
|
100267
100470
|
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
100268
100471
|
function getLineColFromPtr(string4, ptr) {
|
|
@@ -100959,7 +101162,7 @@ var NAME = "errata-context";
|
|
|
100959
101162
|
var PREFIX2 = `./.errata/plugins/${NAME}/`;
|
|
100960
101163
|
var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
100961
101164
|
function readText(file2) {
|
|
100962
|
-
return
|
|
101165
|
+
return existsSync39(file2) ? readFileSync47(file2, "utf8") : "";
|
|
100963
101166
|
}
|
|
100964
101167
|
function writeChanged(file2, content) {
|
|
100965
101168
|
if (readText(file2) === content) return;
|
|
@@ -100968,14 +101171,14 @@ function writeChanged(file2, content) {
|
|
|
100968
101171
|
renameSync9(temp, file2);
|
|
100969
101172
|
}
|
|
100970
101173
|
function bundledContextPlugin() {
|
|
100971
|
-
const packaged =
|
|
100972
|
-
if (
|
|
100973
|
-
return
|
|
101174
|
+
const packaged = fileURLToPath4(new URL("./resources/context-plugin/", import.meta.url));
|
|
101175
|
+
if (existsSync39(join55(packaged, ".codex-plugin/plugin.json"))) return packaged;
|
|
101176
|
+
return fileURLToPath4(new URL("../dist/resources/context-plugin/", import.meta.url));
|
|
100974
101177
|
}
|
|
100975
101178
|
function refreshCodexContextPlugin(root) {
|
|
100976
|
-
const file2 =
|
|
100977
|
-
if (!
|
|
100978
|
-
const marketplace = JSON.parse(
|
|
101179
|
+
const file2 = join55(root, ".agents", "plugins", "marketplace.json");
|
|
101180
|
+
if (!existsSync39(file2)) return false;
|
|
101181
|
+
const marketplace = JSON.parse(readFileSync47(file2, "utf8"));
|
|
100979
101182
|
const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
100980
101183
|
const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
|
|
100981
101184
|
if (!entry) return false;
|
|
@@ -100986,24 +101189,24 @@ function refreshCodexContextPlugin(root) {
|
|
|
100986
101189
|
function installCodexContextPlugin(root, options = {}) {
|
|
100987
101190
|
const bundle = options.bundle ?? bundledContextPlugin();
|
|
100988
101191
|
const manifest = JSON.parse(
|
|
100989
|
-
|
|
101192
|
+
readFileSync47(join55(bundle, ".codex-plugin/plugin.json"), "utf8")
|
|
100990
101193
|
);
|
|
100991
101194
|
if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
|
|
100992
101195
|
throw new Error("Invalid bundled Errata Context manifest.");
|
|
100993
101196
|
}
|
|
100994
|
-
const checksums =
|
|
101197
|
+
const checksums = readFileSync47(join55(bundle, "SHA256SUMS"), "utf8");
|
|
100995
101198
|
for (const line of checksums.trim().split("\n")) {
|
|
100996
101199
|
const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
|
|
100997
101200
|
if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
|
|
100998
101201
|
throw new Error("Invalid bundled Errata Context checksum manifest.");
|
|
100999
101202
|
}
|
|
101000
|
-
const actual = createHash21("sha256").update(
|
|
101203
|
+
const actual = createHash21("sha256").update(readFileSync47(join55(bundle, match2[2]))).digest("hex");
|
|
101001
101204
|
if (actual !== match2[1])
|
|
101002
101205
|
throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
|
|
101003
101206
|
}
|
|
101004
101207
|
const release = `${manifest.version}-${createHash21("sha256").update(checksums).digest("hex").slice(0, 12)}`;
|
|
101005
|
-
const plugin =
|
|
101006
|
-
const marketplaceFile =
|
|
101208
|
+
const plugin = join55(root, ".errata", "plugins", NAME, release);
|
|
101209
|
+
const marketplaceFile = join55(root, ".agents", "plugins", "marketplace.json");
|
|
101007
101210
|
const priorMarketplace = readText(marketplaceFile);
|
|
101008
101211
|
const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
|
|
101009
101212
|
name: "errata-local",
|
|
@@ -101024,12 +101227,12 @@ function installCodexContextPlugin(root, options = {}) {
|
|
|
101024
101227
|
);
|
|
101025
101228
|
}
|
|
101026
101229
|
const key = `${NAME}@${marketplace.name}`;
|
|
101027
|
-
const configFile =
|
|
101230
|
+
const configFile = join55(root, ".codex", "config.toml");
|
|
101028
101231
|
const config2 = readText(configFile);
|
|
101029
101232
|
const parsed = parse4(config2);
|
|
101030
101233
|
const plugins = object2(parsed.plugins);
|
|
101031
|
-
const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ??
|
|
101032
|
-
const globalPlugins = object2(parse4(readText(
|
|
101234
|
+
const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ?? join55(homedir10(), ".codex");
|
|
101235
|
+
const globalPlugins = object2(parse4(readText(join55(codexHome, "config.toml"))).plugins);
|
|
101033
101236
|
const disabledGlobally = Object.entries(globalPlugins).some(
|
|
101034
101237
|
([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
|
|
101035
101238
|
);
|
|
@@ -101053,13 +101256,13 @@ enabled = ${enabled}
|
|
|
101053
101256
|
mkdirSync11(plugin, { recursive: true });
|
|
101054
101257
|
cpSync2(bundle, plugin, { recursive: true });
|
|
101055
101258
|
writeChanged(
|
|
101056
|
-
|
|
101259
|
+
join55(plugin, ".mcp.json"),
|
|
101057
101260
|
JSON.stringify(
|
|
101058
101261
|
{
|
|
101059
101262
|
mcpServers: {
|
|
101060
101263
|
errata_context: {
|
|
101061
101264
|
command: options.nodePath ?? process.execPath,
|
|
101062
|
-
args: [
|
|
101265
|
+
args: [join55(plugin, "dist", "mcp-server.mjs")],
|
|
101063
101266
|
env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
|
|
101064
101267
|
}
|
|
101065
101268
|
}
|
|
@@ -101068,8 +101271,8 @@ enabled = ${enabled}
|
|
|
101068
101271
|
2
|
|
101069
101272
|
) + "\n"
|
|
101070
101273
|
);
|
|
101071
|
-
mkdirSync11(
|
|
101072
|
-
mkdirSync11(
|
|
101274
|
+
mkdirSync11(join55(root, ".agents", "plugins"), { recursive: true });
|
|
101275
|
+
mkdirSync11(join55(root, ".codex"), { recursive: true });
|
|
101073
101276
|
writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
|
|
101074
101277
|
writeChanged(configFile, nextConfig);
|
|
101075
101278
|
return { plugin, enabled, marketplace: marketplaceFile };
|
|
@@ -101077,16 +101280,16 @@ enabled = ${enabled}
|
|
|
101077
101280
|
|
|
101078
101281
|
// src/codex-hook-refresh.ts
|
|
101079
101282
|
init_checkout_root();
|
|
101080
|
-
import { existsSync as
|
|
101081
|
-
import { dirname as
|
|
101283
|
+
import { existsSync as existsSync40, readdirSync as readdirSync14, readFileSync as readFileSync48 } from "node:fs";
|
|
101284
|
+
import { dirname as dirname21, join as join56, resolve as resolve9 } from "node:path";
|
|
101082
101285
|
init_registry();
|
|
101083
101286
|
function codexHookRoots(roots) {
|
|
101084
101287
|
const found = new Set(roots.map((root) => resolve9(root)));
|
|
101085
101288
|
for (const root of [...found]) {
|
|
101086
101289
|
const main2 = mainCheckoutOfWorktree(root) ?? root;
|
|
101087
101290
|
found.add(main2);
|
|
101088
|
-
const dir =
|
|
101089
|
-
if (!
|
|
101291
|
+
const dir = join56(main2, ".git", "worktrees");
|
|
101292
|
+
if (!existsSync40(dir)) continue;
|
|
101090
101293
|
let names;
|
|
101091
101294
|
try {
|
|
101092
101295
|
names = readdirSync14(dir);
|
|
@@ -101095,7 +101298,7 @@ function codexHookRoots(roots) {
|
|
|
101095
101298
|
}
|
|
101096
101299
|
for (const name2 of names) {
|
|
101097
101300
|
try {
|
|
101098
|
-
const checkout =
|
|
101301
|
+
const checkout = dirname21(readFileSync48(join56(dir, name2, "gitdir"), "utf8").trim());
|
|
101099
101302
|
if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
|
|
101100
101303
|
} catch {
|
|
101101
101304
|
}
|
|
@@ -101118,14 +101321,14 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
|
|
|
101118
101321
|
|
|
101119
101322
|
// src/claude-mods.ts
|
|
101120
101323
|
import { createHash as createHash22 } from "node:crypto";
|
|
101121
|
-
import { cpSync as cpSync3, existsSync as
|
|
101122
|
-
import { delimiter as delimiter2, dirname as
|
|
101123
|
-
import { fileURLToPath as
|
|
101324
|
+
import { cpSync as cpSync3, existsSync as existsSync41, mkdirSync as mkdirSync12, readFileSync as readFileSync49, readdirSync as readdirSync15, rmSync as rmSync4, statSync as statSync16, writeFileSync as writeFileSync33 } from "node:fs";
|
|
101325
|
+
import { delimiter as delimiter2, dirname as dirname22, join as join57, relative as relative7, resolve as resolve10, sep as sep6 } from "node:path";
|
|
101326
|
+
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
101124
101327
|
var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
|
|
101125
101328
|
var HASH_FILE = ".errata-mod-hash";
|
|
101126
101329
|
function bundledClaudeModsDir() {
|
|
101127
101330
|
const rel = import.meta.url.endsWith(".mjs") ? "./resources/claude-mods/" : "../claude-mods/";
|
|
101128
|
-
return
|
|
101331
|
+
return fileURLToPath5(new URL(rel, import.meta.url));
|
|
101129
101332
|
}
|
|
101130
101333
|
function isEngineOwned(relPath) {
|
|
101131
101334
|
const p = relPath.split(sep6).join("/");
|
|
@@ -101134,7 +101337,7 @@ function isEngineOwned(relPath) {
|
|
|
101134
101337
|
function listFiles(root, dir = root) {
|
|
101135
101338
|
const out2 = [];
|
|
101136
101339
|
for (const name2 of readdirSync15(dir)) {
|
|
101137
|
-
const abs =
|
|
101340
|
+
const abs = join57(dir, name2);
|
|
101138
101341
|
if (isEngineOwned(relative7(root, abs))) continue;
|
|
101139
101342
|
if (statSync16(abs).isDirectory()) out2.push(...listFiles(root, abs));
|
|
101140
101343
|
else out2.push(abs);
|
|
@@ -101146,14 +101349,14 @@ function modHash(dir) {
|
|
|
101146
101349
|
for (const abs of listFiles(dir).sort()) {
|
|
101147
101350
|
h.update(relative7(dir, abs).split(sep6).join("/"));
|
|
101148
101351
|
h.update("\0");
|
|
101149
|
-
h.update(
|
|
101352
|
+
h.update(readFileSync49(abs));
|
|
101150
101353
|
h.update("\0");
|
|
101151
101354
|
}
|
|
101152
101355
|
return h.digest("hex");
|
|
101153
101356
|
}
|
|
101154
101357
|
function bundledMods(bundleDir) {
|
|
101155
|
-
if (!
|
|
101156
|
-
return readdirSync15(bundleDir).filter((name2) =>
|
|
101358
|
+
if (!existsSync41(bundleDir)) return [];
|
|
101359
|
+
return readdirSync15(bundleDir).filter((name2) => existsSync41(join57(bundleDir, name2, ".claude-plugin", "plugin.json")));
|
|
101157
101360
|
}
|
|
101158
101361
|
function sameDir(a, b) {
|
|
101159
101362
|
const norm = (p) => resolve10(p).replace(/[\\/]+$/, "").toLowerCase();
|
|
@@ -101168,9 +101371,9 @@ function off(env2) {
|
|
|
101168
101371
|
return v === "0" || v === "off" || v === "false" || v === "no";
|
|
101169
101372
|
}
|
|
101170
101373
|
function readSettings(path3) {
|
|
101171
|
-
if (!
|
|
101374
|
+
if (!existsSync41(path3)) return {};
|
|
101172
101375
|
try {
|
|
101173
|
-
const parsed = JSON.parse(
|
|
101376
|
+
const parsed = JSON.parse(readFileSync49(path3, "utf8"));
|
|
101174
101377
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
101175
101378
|
return parsed;
|
|
101176
101379
|
} catch {
|
|
@@ -101194,13 +101397,13 @@ function currentDirs(settings) {
|
|
|
101194
101397
|
return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
|
|
101195
101398
|
}
|
|
101196
101399
|
function writeSettings(path3, settings) {
|
|
101197
|
-
mkdirSync12(
|
|
101400
|
+
mkdirSync12(dirname22(path3), { recursive: true });
|
|
101198
101401
|
writeFileSync33(path3, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
101199
101402
|
}
|
|
101200
101403
|
function ensureClaudeMods(opts) {
|
|
101201
101404
|
const env2 = opts.env ?? process.env;
|
|
101202
101405
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
101203
|
-
const modsRoot =
|
|
101406
|
+
const modsRoot = join57(opts.installRoot, "claude-mods");
|
|
101204
101407
|
if (off(env2)) {
|
|
101205
101408
|
const settings2 = readSettings(settingsPath);
|
|
101206
101409
|
if (!settings2) return { kind: "unreadable" };
|
|
@@ -101217,11 +101420,11 @@ function ensureClaudeMods(opts) {
|
|
|
101217
101420
|
let changed = false;
|
|
101218
101421
|
const installed = [];
|
|
101219
101422
|
for (const name2 of names) {
|
|
101220
|
-
const src =
|
|
101221
|
-
const dest =
|
|
101423
|
+
const src = join57(bundleDir, name2);
|
|
101424
|
+
const dest = join57(modsRoot, name2);
|
|
101222
101425
|
const hash2 = modHash(src);
|
|
101223
|
-
const hashFile =
|
|
101224
|
-
if (!
|
|
101426
|
+
const hashFile = join57(dest, HASH_FILE);
|
|
101427
|
+
if (!existsSync41(hashFile) || readFileSync49(hashFile, "utf8") !== hash2) {
|
|
101225
101428
|
rmSync4(dest, { recursive: true, force: true });
|
|
101226
101429
|
cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
|
|
101227
101430
|
writeFileSync33(hashFile, hash2, "utf8");
|
|
@@ -101655,9 +101858,9 @@ function resolveHookPort(explicit) {
|
|
|
101655
101858
|
}
|
|
101656
101859
|
}
|
|
101657
101860
|
}
|
|
101658
|
-
const settingsPath =
|
|
101861
|
+
const settingsPath = join58(ROOT, ".claude", "settings.json");
|
|
101659
101862
|
try {
|
|
101660
|
-
if (
|
|
101863
|
+
if (existsSync42(settingsPath)) return installedHookPort(readFileSync50(settingsPath, "utf8")) ?? 7891;
|
|
101661
101864
|
} catch {
|
|
101662
101865
|
}
|
|
101663
101866
|
return 7891;
|
|
@@ -101682,14 +101885,14 @@ async function cmdInit() {
|
|
|
101682
101885
|
if (!skipHooks) {
|
|
101683
101886
|
console.log("");
|
|
101684
101887
|
console.log("installing harness hooks...");
|
|
101685
|
-
const { existsSync:
|
|
101686
|
-
const { join:
|
|
101888
|
+
const { existsSync: existsSync43 } = await import("node:fs");
|
|
101889
|
+
const { join: join59 } = await import("node:path");
|
|
101687
101890
|
try {
|
|
101688
101891
|
await installClaudeHooks(port);
|
|
101689
101892
|
} catch (err2) {
|
|
101690
101893
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
101691
101894
|
}
|
|
101692
|
-
if (
|
|
101895
|
+
if (existsSync43(join59(ROOT, ".cursor"))) {
|
|
101693
101896
|
try {
|
|
101694
101897
|
await installCursorMcpConfig();
|
|
101695
101898
|
} catch (err2) {
|
|
@@ -101905,12 +102108,12 @@ async function cmdStatus() {
|
|
|
101905
102108
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
101906
102109
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
101907
102110
|
}
|
|
101908
|
-
console.log(` graph db: ${
|
|
101909
|
-
console.log(` event log: ${
|
|
102111
|
+
console.log(` graph db: ${existsSync42(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
102112
|
+
console.log(` event log: ${existsSync42(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
101910
102113
|
for (const line of captureStatusLines(summarizePassLedger(paths.configDir).get("capture"))) {
|
|
101911
102114
|
console.log(` capture: ${line}`);
|
|
101912
102115
|
}
|
|
101913
|
-
if (
|
|
102116
|
+
if (existsSync42(paths.castalia)) {
|
|
101914
102117
|
try {
|
|
101915
102118
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
101916
102119
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -102911,11 +103114,11 @@ async function cmdInstallationProfile(args2) {
|
|
|
102911
103114
|
}
|
|
102912
103115
|
async function cmdReview() {
|
|
102913
103116
|
const paths = workspacePaths(ROOT);
|
|
102914
|
-
if (!
|
|
103117
|
+
if (!existsSync42(paths.reviewQueue)) {
|
|
102915
103118
|
console.log("(review queue empty)");
|
|
102916
103119
|
return;
|
|
102917
103120
|
}
|
|
102918
|
-
const queue = JSON.parse(
|
|
103121
|
+
const queue = JSON.parse(readFileSync50(paths.reviewQueue, "utf8"));
|
|
102919
103122
|
if (queue.length === 0) {
|
|
102920
103123
|
console.log("(review queue empty)");
|
|
102921
103124
|
return;
|
|
@@ -103517,9 +103720,8 @@ async function gatherRepo(store, ws) {
|
|
|
103517
103720
|
next: { verb: "burst", arg: p.id, hint: "full causal chain" }
|
|
103518
103721
|
});
|
|
103519
103722
|
}
|
|
103520
|
-
const
|
|
103521
|
-
const
|
|
103522
|
-
const embedded = spineSrc.map((n, i2) => ({ i: i2, emb: embeddingOf(n) })).filter((x) => x.emb != null);
|
|
103723
|
+
const versionOf = (n) => String(n.attrs["embeddingVersion"] ?? "hash-v1");
|
|
103724
|
+
const embedded = spineSrc.map((n, i2) => ({ i: i2, emb: embeddingOf(n), version: versionOf(n) })).filter((x) => x.emb != null);
|
|
103523
103725
|
const seenPair = new Set(spineEdges.map((e) => e.a < e.b ? `${e.a}-${e.b}` : `${e.b}-${e.a}`));
|
|
103524
103726
|
const addImplied = (a, b) => {
|
|
103525
103727
|
const key = a < b ? `${a}-${b}` : `${b}-${a}`;
|
|
@@ -103528,12 +103730,13 @@ async function gatherRepo(store, ws) {
|
|
|
103528
103730
|
spineEdges.push({ a, b, kind: "implied" });
|
|
103529
103731
|
};
|
|
103530
103732
|
for (let x = 0; x < embedded.length; x++) {
|
|
103733
|
+
const { relatedWeak, relatedStrong } = cosineBandsFor(embedded[x].version);
|
|
103531
103734
|
let best = -1;
|
|
103532
|
-
let bestSim =
|
|
103735
|
+
let bestSim = relatedWeak;
|
|
103533
103736
|
for (let y = 0; y < embedded.length; y++) {
|
|
103534
|
-
if (y === x) continue;
|
|
103737
|
+
if (y === x || embedded[y].version !== embedded[x].version) continue;
|
|
103535
103738
|
const sim = cosine5(embedded[x].emb, embedded[y].emb);
|
|
103536
|
-
if (sim >=
|
|
103739
|
+
if (sim >= relatedStrong) addImplied(embedded[x].i, embedded[y].i);
|
|
103537
103740
|
if (sim > bestSim) {
|
|
103538
103741
|
bestSim = sim;
|
|
103539
103742
|
best = embedded[y].i;
|
|
@@ -103615,7 +103818,7 @@ async function gatherRepo(store, ws) {
|
|
|
103615
103818
|
};
|
|
103616
103819
|
}
|
|
103617
103820
|
async function gatherReportData(generatedAt) {
|
|
103618
|
-
const { existsSync:
|
|
103821
|
+
const { existsSync: existsSync43 } = await import("node:fs");
|
|
103619
103822
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
103620
103823
|
const cfg = loadConfig();
|
|
103621
103824
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -103623,7 +103826,7 @@ async function gatherReportData(generatedAt) {
|
|
|
103623
103826
|
for (const ws of listWorkspaces()) {
|
|
103624
103827
|
if (ws.missing) continue;
|
|
103625
103828
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
103626
|
-
if (!
|
|
103829
|
+
if (!existsSync43(dbPath)) continue;
|
|
103627
103830
|
let store = null;
|
|
103628
103831
|
try {
|
|
103629
103832
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -103667,8 +103870,8 @@ async function cmdReport(args2) {
|
|
|
103667
103870
|
const outDir = workspacePaths(ROOT).configDir;
|
|
103668
103871
|
mkdirSync13(outDir, { recursive: true });
|
|
103669
103872
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
103670
|
-
for (const f of files) writeFileSync35(
|
|
103671
|
-
const indexPath =
|
|
103873
|
+
for (const f of files) writeFileSync35(join58(outDir, f.name), f.html, "utf8");
|
|
103874
|
+
const indexPath = join58(outDir, "report.html");
|
|
103672
103875
|
console.log(`report \u2192 ${indexPath}`);
|
|
103673
103876
|
console.log(
|
|
103674
103877
|
` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
|
|
@@ -103797,24 +104000,24 @@ async function cmdInstallHooks(args2) {
|
|
|
103797
104000
|
}
|
|
103798
104001
|
}
|
|
103799
104002
|
async function installOpencodePlugin(port) {
|
|
103800
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103801
|
-
const { join:
|
|
103802
|
-
const dir =
|
|
103803
|
-
if (!
|
|
103804
|
-
const file2 =
|
|
103805
|
-
if (
|
|
103806
|
-
const head2 =
|
|
104003
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync43, readFileSync: readFileSync51, writeFileSync: writeFileSync35 } = await import("node:fs");
|
|
104004
|
+
const { join: join59 } = await import("node:path");
|
|
104005
|
+
const dir = join59(ROOT, ".opencode", "plugin");
|
|
104006
|
+
if (!existsSync43(dir)) mkdirSync13(dir, { recursive: true });
|
|
104007
|
+
const file2 = join59(dir, "inerrata.js");
|
|
104008
|
+
if (existsSync43(file2)) {
|
|
104009
|
+
const head2 = readFileSync51(file2, "utf8").split("\n")[0] ?? "";
|
|
103807
104010
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
103808
104011
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
103809
104012
|
process.exit(2);
|
|
103810
104013
|
}
|
|
103811
104014
|
}
|
|
103812
104015
|
writeFileSync35(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
103813
|
-
const cfgFile =
|
|
104016
|
+
const cfgFile = join59(ROOT, "opencode.json");
|
|
103814
104017
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
103815
|
-
if (
|
|
104018
|
+
if (existsSync43(cfgFile)) {
|
|
103816
104019
|
try {
|
|
103817
|
-
cfg = JSON.parse(
|
|
104020
|
+
cfg = JSON.parse(readFileSync51(cfgFile, "utf8"));
|
|
103818
104021
|
} catch {
|
|
103819
104022
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
103820
104023
|
process.exit(2);
|
|
@@ -103859,15 +104062,15 @@ function installClaudeMods() {
|
|
|
103859
104062
|
}
|
|
103860
104063
|
}
|
|
103861
104064
|
async function installClaudeHooks(port) {
|
|
103862
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103863
|
-
const { join:
|
|
103864
|
-
const dir =
|
|
103865
|
-
if (!
|
|
103866
|
-
const file2 =
|
|
104065
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync43, readFileSync: readFileSync51, writeFileSync: writeFileSync35 } = await import("node:fs");
|
|
104066
|
+
const { join: join59 } = await import("node:path");
|
|
104067
|
+
const dir = join59(ROOT, ".claude");
|
|
104068
|
+
if (!existsSync43(dir)) mkdirSync13(dir, { recursive: true });
|
|
104069
|
+
const file2 = join59(dir, "settings.json");
|
|
103867
104070
|
let settings = {};
|
|
103868
|
-
if (
|
|
104071
|
+
if (existsSync43(file2)) {
|
|
103869
104072
|
try {
|
|
103870
|
-
settings = JSON.parse(
|
|
104073
|
+
settings = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103871
104074
|
} catch {
|
|
103872
104075
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103873
104076
|
process.exit(2);
|
|
@@ -103880,7 +104083,7 @@ async function installClaudeHooks(port) {
|
|
|
103880
104083
|
console.log(` ${ensureStatusLine(port)}`);
|
|
103881
104084
|
console.log(` ${installClaudeMods().line}`);
|
|
103882
104085
|
await installClaudeMcpConfig();
|
|
103883
|
-
const claudeMd =
|
|
104086
|
+
const claudeMd = join59(ROOT, "CLAUDE.md");
|
|
103884
104087
|
const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
|
|
103885
104088
|
if (recall.kind === "collision") {
|
|
103886
104089
|
console.warn(
|
|
@@ -103892,15 +104095,15 @@ async function installClaudeHooks(port) {
|
|
|
103892
104095
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
103893
104096
|
}
|
|
103894
104097
|
async function installClaudeMcpConfig() {
|
|
103895
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103896
|
-
const { join:
|
|
103897
|
-
const file2 =
|
|
103898
|
-
const dir =
|
|
103899
|
-
if (!
|
|
104098
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync43, readFileSync: readFileSync51, writeFileSync: writeFileSync35 } = await import("node:fs");
|
|
104099
|
+
const { join: join59, dirname: dirname23 } = await import("node:path");
|
|
104100
|
+
const file2 = join59(ROOT, ".mcp.json");
|
|
104101
|
+
const dir = dirname23(file2);
|
|
104102
|
+
if (!existsSync43(dir)) mkdirSync13(dir, { recursive: true });
|
|
103900
104103
|
let cfg = {};
|
|
103901
|
-
if (
|
|
104104
|
+
if (existsSync43(file2)) {
|
|
103902
104105
|
try {
|
|
103903
|
-
cfg = JSON.parse(
|
|
104106
|
+
cfg = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103904
104107
|
} catch {
|
|
103905
104108
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103906
104109
|
process.exit(2);
|
|
@@ -103914,15 +104117,15 @@ async function installClaudeMcpConfig() {
|
|
|
103914
104117
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
103915
104118
|
}
|
|
103916
104119
|
async function installCursorMcpConfig() {
|
|
103917
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103918
|
-
const { join:
|
|
103919
|
-
const dir =
|
|
103920
|
-
if (!
|
|
103921
|
-
const file2 =
|
|
104120
|
+
const { mkdirSync: mkdirSync13, existsSync: existsSync43, readFileSync: readFileSync51, writeFileSync: writeFileSync35 } = await import("node:fs");
|
|
104121
|
+
const { join: join59 } = await import("node:path");
|
|
104122
|
+
const dir = join59(ROOT, ".cursor");
|
|
104123
|
+
if (!existsSync43(dir)) mkdirSync13(dir, { recursive: true });
|
|
104124
|
+
const file2 = join59(dir, "mcp.json");
|
|
103922
104125
|
let cfg = {};
|
|
103923
|
-
if (
|
|
104126
|
+
if (existsSync43(file2)) {
|
|
103924
104127
|
try {
|
|
103925
|
-
cfg = JSON.parse(
|
|
104128
|
+
cfg = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103926
104129
|
} catch {
|
|
103927
104130
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103928
104131
|
process.exit(2);
|
|
@@ -103941,7 +104144,7 @@ async function installCodexHooks(port) {
|
|
|
103941
104144
|
const gitRoot = nearestGitRoot(process.cwd());
|
|
103942
104145
|
const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
|
|
103943
104146
|
const file2 = writeCodexHooks(hookRoot, port);
|
|
103944
|
-
const instructions = writeManagedBlock(
|
|
104147
|
+
const instructions = writeManagedBlock(join58(hookRoot, "AGENTS.md"), {
|
|
103945
104148
|
body: AGENTS_POINTER_BODY,
|
|
103946
104149
|
stable: true
|
|
103947
104150
|
});
|
|
@@ -103989,10 +104192,10 @@ function refreshExistingClaudeHooks() {
|
|
|
103989
104192
|
let ok = true;
|
|
103990
104193
|
const roots = [...listWorkspaceEntries().map((entry) => entry.path), process.cwd()];
|
|
103991
104194
|
for (const root of codexHookRoots(roots)) {
|
|
103992
|
-
const file2 =
|
|
104195
|
+
const file2 = join58(root, ".claude", "settings.json");
|
|
103993
104196
|
try {
|
|
103994
|
-
if (!
|
|
103995
|
-
const next = refreshClaudeHookSettings(
|
|
104197
|
+
if (!existsSync42(file2) || isReplayCheckout(root)) continue;
|
|
104198
|
+
const next = refreshClaudeHookSettings(readFileSync50(file2, "utf8"));
|
|
103996
104199
|
if (next === null) continue;
|
|
103997
104200
|
writeFileSync34(file2, next, "utf8");
|
|
103998
104201
|
console.log(`updated existing Claude Code hooks \u2192 ${file2}`);
|
|
@@ -104406,9 +104609,9 @@ async function cmdDash(args2) {
|
|
|
104406
104609
|
await yieldToLoop2();
|
|
104407
104610
|
try {
|
|
104408
104611
|
const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
|
|
104409
|
-
atCommit: readGitRefState(
|
|
104612
|
+
atCommit: readGitRefState(join58(r.root, ".git")).sha ?? void 0
|
|
104410
104613
|
});
|
|
104411
|
-
const res = bleedRules(
|
|
104614
|
+
const res = bleedRules(join58(r.root, ".claude", "rules"), items);
|
|
104412
104615
|
if (res.written || res.pruned) {
|
|
104413
104616
|
console.log(
|
|
104414
104617
|
`[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")
|