@inerrata-corporation/errata 2.0.23-dev.4881 → 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 +980 -632
- 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({
|
|
@@ -58885,7 +59085,14 @@ function buildWebUi(deps) {
|
|
|
58885
59085
|
}
|
|
58886
59086
|
}
|
|
58887
59087
|
}
|
|
58888
|
-
|
|
59088
|
+
let taskPriors = null;
|
|
59089
|
+
if ((event === "PostToolUse" || event === "PreToolUse") && audience.subagent === null && audience.sessionId && deps.takeTaskPriors) {
|
|
59090
|
+
try {
|
|
59091
|
+
taskPriors = deps.takeTaskPriors(audience.sessionId);
|
|
59092
|
+
} catch {
|
|
59093
|
+
}
|
|
59094
|
+
}
|
|
59095
|
+
if ((event === "PostToolUse" || event === "PreToolUse") && (recall || refreshed || taskPriors)) {
|
|
58889
59096
|
const showCard = recallCardEnabled();
|
|
58890
59097
|
const { sessionId, subagent } = audience;
|
|
58891
59098
|
const raw2 = recall?.card ?? refreshed?.card ?? null;
|
|
@@ -58895,7 +59102,7 @@ function buildWebUi(deps) {
|
|
|
58895
59102
|
else rememberCard(sessionId, card);
|
|
58896
59103
|
}
|
|
58897
59104
|
const line = showCard && recall && card ? renderRecallLine(card) : null;
|
|
58898
|
-
const additionalContext = [recall?.context, refreshed?.additionalContext].filter(Boolean).join("\n\n");
|
|
59105
|
+
const additionalContext = [recall?.context, refreshed?.additionalContext, taskPriors].filter(Boolean).join("\n\n");
|
|
58899
59106
|
return c.json({
|
|
58900
59107
|
...line ? { systemMessage: line } : {},
|
|
58901
59108
|
hookSpecificOutput: { hookEventName: hookEvent, additionalContext }
|
|
@@ -59004,6 +59211,15 @@ ${delta}${cue}`;
|
|
|
59004
59211
|
const { sessionId: sid, contextKey: contextKey2, subagent, agentId } = hookAudience(body2);
|
|
59005
59212
|
noteSessionFrom(c.req.header(ORIGIN_HEADER), body2);
|
|
59006
59213
|
const hookEvent = String(body2["hook_event_name"] ?? "UserPromptSubmit");
|
|
59214
|
+
if (hookEvent === "UserPromptSubmit" && subagent === null && sid && typeof body2["prompt"] === "string" && deps.onTaskPrompt) {
|
|
59215
|
+
const prompt = body2["prompt"];
|
|
59216
|
+
setImmediate(() => {
|
|
59217
|
+
try {
|
|
59218
|
+
deps.onTaskPrompt(sid, prompt);
|
|
59219
|
+
} catch {
|
|
59220
|
+
}
|
|
59221
|
+
});
|
|
59222
|
+
}
|
|
59007
59223
|
const atPrompt = hookEvent === "UserPromptSubmit" || hookEvent === "SessionStart" || hookEvent === "SubagentStart";
|
|
59008
59224
|
if (sid && recallCardEnabled() && atPrompt) {
|
|
59009
59225
|
setImmediate(() => {
|
|
@@ -78142,16 +78358,16 @@ __export(witness_ledger_exports, {
|
|
|
78142
78358
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
78143
78359
|
witnessLedgerPath: () => witnessLedgerPath
|
|
78144
78360
|
});
|
|
78145
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
78146
|
-
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";
|
|
78147
78363
|
function witnessLedgerPath(configDir) {
|
|
78148
|
-
return
|
|
78364
|
+
return join37(configDir, "witness-ledger.jsonl");
|
|
78149
78365
|
}
|
|
78150
78366
|
function appendWitnessLedger(configDir, entry) {
|
|
78151
78367
|
const path3 = witnessLedgerPath(configDir);
|
|
78152
78368
|
try {
|
|
78153
78369
|
appendFileSync3(path3, JSON.stringify(entry) + "\n");
|
|
78154
|
-
const lines =
|
|
78370
|
+
const lines = readFileSync33(path3, "utf8").split("\n").filter(Boolean);
|
|
78155
78371
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
78156
78372
|
writeFileSync22(path3, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
78157
78373
|
}
|
|
@@ -78160,9 +78376,9 @@ function appendWitnessLedger(configDir, entry) {
|
|
|
78160
78376
|
}
|
|
78161
78377
|
function readWitnessLedger(configDir) {
|
|
78162
78378
|
const path3 = witnessLedgerPath(configDir);
|
|
78163
|
-
if (!
|
|
78379
|
+
if (!existsSync29(path3)) return [];
|
|
78164
78380
|
try {
|
|
78165
|
-
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");
|
|
78166
78382
|
} catch {
|
|
78167
78383
|
return [];
|
|
78168
78384
|
}
|
|
@@ -78601,12 +78817,12 @@ var init_report_render = __esm({
|
|
|
78601
78817
|
|
|
78602
78818
|
// src/cli.ts
|
|
78603
78819
|
init_src6();
|
|
78604
|
-
import { closeSync as closeSync3, existsSync as
|
|
78605
|
-
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";
|
|
78606
78822
|
import { spawn as spawn5 } from "node:child_process";
|
|
78607
78823
|
|
|
78608
78824
|
// src/daemon.ts
|
|
78609
|
-
import { existsSync as
|
|
78825
|
+
import { existsSync as existsSync31, writeFileSync as writeFileSync25 } from "node:fs";
|
|
78610
78826
|
|
|
78611
78827
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.34/node_modules/@hono/node-server/dist/index.mjs
|
|
78612
78828
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -79186,16 +79402,16 @@ init_config();
|
|
|
79186
79402
|
init_lock();
|
|
79187
79403
|
|
|
79188
79404
|
// src/replay-checkout.ts
|
|
79189
|
-
import { existsSync as
|
|
79190
|
-
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";
|
|
79191
79407
|
var REPLAY_MARKER = "errata-replay";
|
|
79192
79408
|
function gitDirOf(cwd) {
|
|
79193
|
-
for (let dir = resolve6(cwd); ; dir =
|
|
79194
|
-
const dotGit =
|
|
79195
|
-
if (
|
|
79409
|
+
for (let dir = resolve6(cwd); ; dir = dirname10(dir)) {
|
|
79410
|
+
const dotGit = join20(dir, ".git");
|
|
79411
|
+
if (existsSync20(dotGit)) {
|
|
79196
79412
|
try {
|
|
79197
79413
|
if (statSync7(dotGit).isDirectory()) return dotGit;
|
|
79198
|
-
const m = /^gitdir:\s*(.+)$/m.exec(
|
|
79414
|
+
const m = /^gitdir:\s*(.+)$/m.exec(readFileSync19(dotGit, "utf8"));
|
|
79199
79415
|
if (!m) return null;
|
|
79200
79416
|
const target = m[1].trim();
|
|
79201
79417
|
return isAbsolute4(target) ? target : resolve6(dir, target);
|
|
@@ -79203,12 +79419,12 @@ function gitDirOf(cwd) {
|
|
|
79203
79419
|
return null;
|
|
79204
79420
|
}
|
|
79205
79421
|
}
|
|
79206
|
-
if (
|
|
79422
|
+
if (dirname10(dir) === dir) return null;
|
|
79207
79423
|
}
|
|
79208
79424
|
}
|
|
79209
79425
|
function isReplayCheckout(cwd) {
|
|
79210
79426
|
const gitDir = gitDirOf(cwd);
|
|
79211
|
-
return gitDir != null &&
|
|
79427
|
+
return gitDir != null && existsSync20(join20(gitDir, REPLAY_MARKER));
|
|
79212
79428
|
}
|
|
79213
79429
|
|
|
79214
79430
|
// src/activity-feed.ts
|
|
@@ -79316,8 +79532,8 @@ function knowledgeTag(label, attrs) {
|
|
|
79316
79532
|
|
|
79317
79533
|
// src/engine.ts
|
|
79318
79534
|
import { execFileSync as execFileSync6 } from "node:child_process";
|
|
79319
|
-
import { existsSync as
|
|
79320
|
-
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";
|
|
79321
79537
|
|
|
79322
79538
|
// src/coalesced-file-pass.ts
|
|
79323
79539
|
function createCoalescedFilePass(delayMs, run3, onError) {
|
|
@@ -79362,7 +79578,7 @@ function createCoalescedFilePass(delayMs, run3, onError) {
|
|
|
79362
79578
|
// src/source-watcher.ts
|
|
79363
79579
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
79364
79580
|
import { readdirSync as readdirSync6, statSync as statSync8, watch as watch2 } from "node:fs";
|
|
79365
|
-
import { join as
|
|
79581
|
+
import { join as join23, sep as sep4 } from "node:path";
|
|
79366
79582
|
|
|
79367
79583
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
79368
79584
|
import { stat as statcb } from "fs";
|
|
@@ -80093,9 +80309,9 @@ var NodeFsHandler = class {
|
|
|
80093
80309
|
if (this.fsw.closed) {
|
|
80094
80310
|
return;
|
|
80095
80311
|
}
|
|
80096
|
-
const
|
|
80312
|
+
const dirname23 = sysPath.dirname(file2);
|
|
80097
80313
|
const basename11 = sysPath.basename(file2);
|
|
80098
|
-
const parent = this.fsw._getWatchedDir(
|
|
80314
|
+
const parent = this.fsw._getWatchedDir(dirname23);
|
|
80099
80315
|
let prevStats = stats;
|
|
80100
80316
|
if (parent.has(basename11))
|
|
80101
80317
|
return;
|
|
@@ -80122,7 +80338,7 @@ var NodeFsHandler = class {
|
|
|
80122
80338
|
prevStats = newStats2;
|
|
80123
80339
|
}
|
|
80124
80340
|
} catch (error48) {
|
|
80125
|
-
this.fsw._remove(
|
|
80341
|
+
this.fsw._remove(dirname23, basename11);
|
|
80126
80342
|
}
|
|
80127
80343
|
} else if (parent.has(basename11)) {
|
|
80128
80344
|
const at = newStats.atimeMs;
|
|
@@ -81098,7 +81314,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
81098
81314
|
}
|
|
81099
81315
|
try {
|
|
81100
81316
|
const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
|
|
81101
|
-
const path3 = isDir ? name2 ?
|
|
81317
|
+
const path3 = isDir ? name2 ? join23(target, name2.toString()) : null : target;
|
|
81102
81318
|
if (!path3) {
|
|
81103
81319
|
this.emit("raw", event, target, { watchedPath: target, filenameMissing: true });
|
|
81104
81320
|
this.scheduleReconcile(target, isDir);
|
|
@@ -81164,7 +81380,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
81164
81380
|
continue;
|
|
81165
81381
|
}
|
|
81166
81382
|
for (const entry of entries) {
|
|
81167
|
-
const path3 =
|
|
81383
|
+
const path3 = join23(dir, entry.name);
|
|
81168
81384
|
if (this.ignored(path3)) continue;
|
|
81169
81385
|
if (entry.isDirectory()) dirs.push(path3);
|
|
81170
81386
|
else if (entry.isFile()) add(path3);
|
|
@@ -81475,9 +81691,9 @@ init_src6();
|
|
|
81475
81691
|
init_session_registry();
|
|
81476
81692
|
|
|
81477
81693
|
// src/snapshot-reuse.ts
|
|
81478
|
-
import { readFileSync as
|
|
81479
|
-
import { fileURLToPath as
|
|
81480
|
-
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";
|
|
81481
81697
|
function revisitFlagsUnchanged(store, held, flaggedNow) {
|
|
81482
81698
|
if (held.anySeq === void 0 || held.revisitIds === void 0 || !store.changedAmong) return false;
|
|
81483
81699
|
const watched = [.../* @__PURE__ */ new Set([...held.revisitIds, ...flaggedNow])];
|
|
@@ -81493,7 +81709,7 @@ function snapshotCodeIdentity(version3) {
|
|
|
81493
81709
|
if (codeIdentityMemo === void 0) {
|
|
81494
81710
|
let built = "unknown";
|
|
81495
81711
|
try {
|
|
81496
|
-
built = String(statSync9(
|
|
81712
|
+
built = String(statSync9(fileURLToPath3(import.meta.url)).mtimeMs);
|
|
81497
81713
|
} catch {
|
|
81498
81714
|
}
|
|
81499
81715
|
codeIdentityMemo = `${version3}@${built}`;
|
|
@@ -81501,11 +81717,11 @@ function snapshotCodeIdentity(version3) {
|
|
|
81501
81717
|
return codeIdentityMemo;
|
|
81502
81718
|
}
|
|
81503
81719
|
function heldSnapshotPath(configDir) {
|
|
81504
|
-
return
|
|
81720
|
+
return join24(configDir, "snapshot-held.json");
|
|
81505
81721
|
}
|
|
81506
81722
|
function loadHeldSnapshot(path3) {
|
|
81507
81723
|
try {
|
|
81508
|
-
const held = JSON.parse(
|
|
81724
|
+
const held = JSON.parse(readFileSync20(path3, "utf8"));
|
|
81509
81725
|
return typeof held?.key === "string" && typeof held.at === "number" ? held : null;
|
|
81510
81726
|
} catch {
|
|
81511
81727
|
return null;
|
|
@@ -81513,7 +81729,7 @@ function loadHeldSnapshot(path3) {
|
|
|
81513
81729
|
}
|
|
81514
81730
|
function saveHeldSnapshot(path3, held) {
|
|
81515
81731
|
try {
|
|
81516
|
-
const tmp =
|
|
81732
|
+
const tmp = join24(dirname13(path3), `.${process.pid}.snapshot-held.tmp`);
|
|
81517
81733
|
writeFileSync14(tmp, JSON.stringify(held));
|
|
81518
81734
|
renameSync3(tmp, path3);
|
|
81519
81735
|
} catch {
|
|
@@ -81709,8 +81925,8 @@ init_review2();
|
|
|
81709
81925
|
|
|
81710
81926
|
// src/turn.ts
|
|
81711
81927
|
init_checkout_root();
|
|
81712
|
-
import { closeSync as closeSync2, existsSync as
|
|
81713
|
-
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";
|
|
81714
81930
|
import { homedir as homedir4 } from "node:os";
|
|
81715
81931
|
import { createHash as createHash16 } from "node:crypto";
|
|
81716
81932
|
function completeJsonlPrefix(buf) {
|
|
@@ -82098,11 +82314,11 @@ function turnsSince(turns, mark) {
|
|
|
82098
82314
|
return at >= 0 ? turns.slice(at + 1) : turns;
|
|
82099
82315
|
}
|
|
82100
82316
|
function claudeProjectDir(cwd, home = homedir4()) {
|
|
82101
|
-
return
|
|
82317
|
+
return join25(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
|
|
82102
82318
|
}
|
|
82103
82319
|
function recentTranscripts(cwd, opts = {}) {
|
|
82104
82320
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
82105
|
-
if (!
|
|
82321
|
+
if (!existsSync21(dir)) return [];
|
|
82106
82322
|
let names;
|
|
82107
82323
|
try {
|
|
82108
82324
|
names = readdirSync7(dir);
|
|
@@ -82113,7 +82329,7 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
82113
82329
|
const refs = [];
|
|
82114
82330
|
for (const name2 of names) {
|
|
82115
82331
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82116
|
-
const path3 =
|
|
82332
|
+
const path3 = join25(dir, name2);
|
|
82117
82333
|
let mtimeMs;
|
|
82118
82334
|
try {
|
|
82119
82335
|
mtimeMs = statSync10(path3).mtimeMs;
|
|
@@ -82128,8 +82344,8 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
82128
82344
|
}
|
|
82129
82345
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
82130
82346
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
82131
|
-
const dir =
|
|
82132
|
-
if (!
|
|
82347
|
+
const dir = join25(dirname14(mainTranscriptPath), sessionId, "subagents");
|
|
82348
|
+
if (!existsSync21(dir)) return [];
|
|
82133
82349
|
let names;
|
|
82134
82350
|
try {
|
|
82135
82351
|
names = readdirSync7(dir);
|
|
@@ -82139,7 +82355,7 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
82139
82355
|
const refs = [];
|
|
82140
82356
|
for (const name2 of names) {
|
|
82141
82357
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82142
|
-
const path3 =
|
|
82358
|
+
const path3 = join25(dir, name2);
|
|
82143
82359
|
let mtimeMs;
|
|
82144
82360
|
try {
|
|
82145
82361
|
mtimeMs = statSync10(path3).mtimeMs;
|
|
@@ -82153,13 +82369,13 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
82153
82369
|
}
|
|
82154
82370
|
function splitPathList(value, sep7 = delimiter) {
|
|
82155
82371
|
if (!value) return [];
|
|
82156
|
-
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));
|
|
82157
82373
|
}
|
|
82158
82374
|
function codexSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82159
82375
|
const roots = /* @__PURE__ */ new Set();
|
|
82160
82376
|
for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
|
|
82161
|
-
if (env2["CODEX_HOME"]) roots.add(
|
|
82162
|
-
roots.add(
|
|
82377
|
+
if (env2["CODEX_HOME"]) roots.add(join25(env2["CODEX_HOME"], "sessions"));
|
|
82378
|
+
roots.add(join25(home, ".codex", "sessions"));
|
|
82163
82379
|
return [...roots];
|
|
82164
82380
|
}
|
|
82165
82381
|
function readCodexRolloutIdentity(path3) {
|
|
@@ -82213,7 +82429,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82213
82429
|
const owner = checkoutRootOf(cwd);
|
|
82214
82430
|
const owners = /* @__PURE__ */ new Map();
|
|
82215
82431
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
82216
|
-
if (!
|
|
82432
|
+
if (!existsSync21(root)) {
|
|
82217
82433
|
codexRolloutActivity.delete(root);
|
|
82218
82434
|
continue;
|
|
82219
82435
|
}
|
|
@@ -82231,7 +82447,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82231
82447
|
continue;
|
|
82232
82448
|
}
|
|
82233
82449
|
for (const name2 of names) {
|
|
82234
|
-
const full =
|
|
82450
|
+
const full = join25(dir, name2);
|
|
82235
82451
|
let st;
|
|
82236
82452
|
try {
|
|
82237
82453
|
st = statSync10(full);
|
|
@@ -82273,8 +82489,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
82273
82489
|
function geminiSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82274
82490
|
const roots = /* @__PURE__ */ new Set();
|
|
82275
82491
|
for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
|
|
82276
|
-
if (env2["GEMINI_CLI_HOME"]) roots.add(
|
|
82277
|
-
roots.add(
|
|
82492
|
+
if (env2["GEMINI_CLI_HOME"]) roots.add(join25(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
|
|
82493
|
+
roots.add(join25(home, ".gemini", "tmp"));
|
|
82278
82494
|
return [...roots];
|
|
82279
82495
|
}
|
|
82280
82496
|
function geminiProjectHash(cwd) {
|
|
@@ -82314,7 +82530,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82314
82530
|
const hashes = geminiHashesFor(cwd);
|
|
82315
82531
|
const out2 = [];
|
|
82316
82532
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
82317
|
-
if (!
|
|
82533
|
+
if (!existsSync21(root)) continue;
|
|
82318
82534
|
let slugs;
|
|
82319
82535
|
try {
|
|
82320
82536
|
slugs = readdirSync7(root);
|
|
@@ -82322,7 +82538,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82322
82538
|
continue;
|
|
82323
82539
|
}
|
|
82324
82540
|
for (const slug2 of slugs) {
|
|
82325
|
-
const chats =
|
|
82541
|
+
const chats = join25(root, slug2, "chats");
|
|
82326
82542
|
let names;
|
|
82327
82543
|
try {
|
|
82328
82544
|
names = readdirSync7(chats);
|
|
@@ -82331,7 +82547,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82331
82547
|
}
|
|
82332
82548
|
for (const name2 of names) {
|
|
82333
82549
|
if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
|
|
82334
|
-
const full =
|
|
82550
|
+
const full = join25(chats, name2);
|
|
82335
82551
|
let st;
|
|
82336
82552
|
try {
|
|
82337
82553
|
st = statSync10(full);
|
|
@@ -82351,8 +82567,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82351
82567
|
function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
|
|
82352
82568
|
const roots = /* @__PURE__ */ new Set();
|
|
82353
82569
|
for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
|
|
82354
|
-
if (env2["XDG_DATA_HOME"]) roots.add(
|
|
82355
|
-
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"));
|
|
82356
82572
|
return [...roots];
|
|
82357
82573
|
}
|
|
82358
82574
|
function readOpencodeTranscriptDirectory(path3) {
|
|
@@ -82385,7 +82601,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82385
82601
|
}
|
|
82386
82602
|
const out2 = [];
|
|
82387
82603
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
82388
|
-
if (!
|
|
82604
|
+
if (!existsSync21(root)) continue;
|
|
82389
82605
|
let names;
|
|
82390
82606
|
try {
|
|
82391
82607
|
names = readdirSync7(root);
|
|
@@ -82394,7 +82610,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
82394
82610
|
}
|
|
82395
82611
|
for (const name2 of names) {
|
|
82396
82612
|
if (!name2.endsWith(".jsonl")) continue;
|
|
82397
|
-
const full =
|
|
82613
|
+
const full = join25(root, name2);
|
|
82398
82614
|
let st;
|
|
82399
82615
|
try {
|
|
82400
82616
|
st = statSync10(full);
|
|
@@ -82417,7 +82633,7 @@ init_src2();
|
|
|
82417
82633
|
init_agent_signals();
|
|
82418
82634
|
init_tool_index();
|
|
82419
82635
|
init_src5();
|
|
82420
|
-
import { readFileSync as
|
|
82636
|
+
import { readFileSync as readFileSync21, writeFileSync as writeFileSync15 } from "node:fs";
|
|
82421
82637
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
82422
82638
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
82423
82639
|
var HANDLE_RE2 = new RegExp(TAG_HANDLE_SOURCE, "gi");
|
|
@@ -83252,7 +83468,7 @@ function writePrimingHandles(path3, nodes, now = Date.now()) {
|
|
|
83252
83468
|
}
|
|
83253
83469
|
function readPrimingHandles(path3) {
|
|
83254
83470
|
try {
|
|
83255
|
-
return JSON.parse(
|
|
83471
|
+
return JSON.parse(readFileSync21(path3, "utf8"));
|
|
83256
83472
|
} catch {
|
|
83257
83473
|
return {};
|
|
83258
83474
|
}
|
|
@@ -83854,8 +84070,8 @@ ${conversation}` }]
|
|
|
83854
84070
|
// src/constraint-backfill.ts
|
|
83855
84071
|
init_src5();
|
|
83856
84072
|
init_src2();
|
|
83857
|
-
import { existsSync as
|
|
83858
|
-
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";
|
|
83859
84075
|
import { homedir as homedir5 } from "node:os";
|
|
83860
84076
|
var BACKFILL_VERSION = 1;
|
|
83861
84077
|
var EMPTY = {
|
|
@@ -83869,13 +84085,13 @@ var EMPTY = {
|
|
|
83869
84085
|
recoverable: 0
|
|
83870
84086
|
};
|
|
83871
84087
|
function markerPath(configDir) {
|
|
83872
|
-
return
|
|
84088
|
+
return join26(configDir, "constraint-backfill.json");
|
|
83873
84089
|
}
|
|
83874
84090
|
function alreadyDone(configDir) {
|
|
83875
84091
|
const p = markerPath(configDir);
|
|
83876
|
-
if (!
|
|
84092
|
+
if (!existsSync22(p)) return false;
|
|
83877
84093
|
try {
|
|
83878
|
-
const raw2 = JSON.parse(
|
|
84094
|
+
const raw2 = JSON.parse(readFileSync22(p, "utf8"));
|
|
83879
84095
|
return raw2?.version === BACKFILL_VERSION;
|
|
83880
84096
|
} catch {
|
|
83881
84097
|
return false;
|
|
@@ -83885,7 +84101,7 @@ function replay(root) {
|
|
|
83885
84101
|
const statements2 = /* @__PURE__ */ new Set();
|
|
83886
84102
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
83887
84103
|
const dir = claudeProjectDir(root, homedir5());
|
|
83888
|
-
if (!
|
|
84104
|
+
if (!existsSync22(dir)) return { statements: statements2, citedByFix };
|
|
83889
84105
|
let names;
|
|
83890
84106
|
try {
|
|
83891
84107
|
names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -83895,7 +84111,7 @@ function replay(root) {
|
|
|
83895
84111
|
for (const f of names) {
|
|
83896
84112
|
let lines;
|
|
83897
84113
|
try {
|
|
83898
|
-
lines =
|
|
84114
|
+
lines = readFileSync22(join26(dir, f), "utf8").split("\n");
|
|
83899
84115
|
} catch {
|
|
83900
84116
|
continue;
|
|
83901
84117
|
}
|
|
@@ -84022,8 +84238,8 @@ function backfillConstraintKind(store, opts) {
|
|
|
84022
84238
|
// src/edge-repair.ts
|
|
84023
84239
|
init_src();
|
|
84024
84240
|
init_src5();
|
|
84025
|
-
import { existsSync as
|
|
84026
|
-
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";
|
|
84027
84243
|
function citeEdgeId(from, type, to) {
|
|
84028
84244
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
84029
84245
|
}
|
|
@@ -84038,13 +84254,13 @@ var EMPTY2 = {
|
|
|
84038
84254
|
byType: {}
|
|
84039
84255
|
};
|
|
84040
84256
|
function markerPath2(configDir) {
|
|
84041
|
-
return
|
|
84257
|
+
return join27(configDir, "edge-repair.json");
|
|
84042
84258
|
}
|
|
84043
84259
|
function alreadyDone2(configDir) {
|
|
84044
84260
|
const p = markerPath2(configDir);
|
|
84045
|
-
if (!
|
|
84261
|
+
if (!existsSync23(p)) return false;
|
|
84046
84262
|
try {
|
|
84047
|
-
return JSON.parse(
|
|
84263
|
+
return JSON.parse(readFileSync23(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
84048
84264
|
} catch {
|
|
84049
84265
|
return false;
|
|
84050
84266
|
}
|
|
@@ -84107,8 +84323,8 @@ function repairInvalidEdges(store, opts) {
|
|
|
84107
84323
|
init_reconcile();
|
|
84108
84324
|
|
|
84109
84325
|
// src/pass-ledger.ts
|
|
84110
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
84111
|
-
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";
|
|
84112
84328
|
|
|
84113
84329
|
// src/isolate-census.ts
|
|
84114
84330
|
var live3 = 0;
|
|
@@ -84139,7 +84355,7 @@ var HOUR_MS = 36e5;
|
|
|
84139
84355
|
var TRIM_EVERY = 50;
|
|
84140
84356
|
var appendsSinceTrim = /* @__PURE__ */ new Map();
|
|
84141
84357
|
function passLedgerPath(configDir) {
|
|
84142
|
-
return
|
|
84358
|
+
return join28(configDir, "pass-ledger.jsonl");
|
|
84143
84359
|
}
|
|
84144
84360
|
function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
84145
84361
|
const path3 = passLedgerPath(configDir);
|
|
@@ -84171,7 +84387,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84171
84387
|
return;
|
|
84172
84388
|
}
|
|
84173
84389
|
appendsSinceTrim.set(path3, 0);
|
|
84174
|
-
const lines =
|
|
84390
|
+
const lines = readFileSync24(path3, "utf8").split("\n").filter(Boolean);
|
|
84175
84391
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
84176
84392
|
const tailHours = /* @__PURE__ */ new Map();
|
|
84177
84393
|
const tailFloor = Date.now() - LEVEL_TAIL_DAYS * 24 * HOUR_MS;
|
|
@@ -84206,9 +84422,9 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
84206
84422
|
}
|
|
84207
84423
|
function readPassLedger(configDir) {
|
|
84208
84424
|
const path3 = passLedgerPath(configDir);
|
|
84209
|
-
if (!
|
|
84425
|
+
if (!existsSync24(path3)) return [];
|
|
84210
84426
|
try {
|
|
84211
|
-
return
|
|
84427
|
+
return readFileSync24(path3, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
84212
84428
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
84213
84429
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
84214
84430
|
} catch {
|
|
@@ -84651,11 +84867,11 @@ init_outbox();
|
|
|
84651
84867
|
init_src10();
|
|
84652
84868
|
init_src();
|
|
84653
84869
|
init_src2();
|
|
84654
|
-
import { readFileSync as
|
|
84655
|
-
import { join as
|
|
84870
|
+
import { readFileSync as readFileSync25 } from "node:fs";
|
|
84871
|
+
import { join as join29 } from "node:path";
|
|
84656
84872
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
84657
84873
|
try {
|
|
84658
|
-
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());
|
|
84659
84875
|
} catch {
|
|
84660
84876
|
return [];
|
|
84661
84877
|
}
|
|
@@ -85038,9 +85254,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
85038
85254
|
// src/retrieval-stack.ts
|
|
85039
85255
|
init_src();
|
|
85040
85256
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
85041
|
-
import { existsSync as
|
|
85257
|
+
import { existsSync as existsSync25, readFileSync as readFileSync26, statSync as statSync11 } from "node:fs";
|
|
85042
85258
|
import { homedir as homedir6 } from "node:os";
|
|
85043
|
-
import { join as
|
|
85259
|
+
import { join as join30 } from "node:path";
|
|
85044
85260
|
var RETRIEVAL_STACK_CAP = 24;
|
|
85045
85261
|
var MANIFEST_SCAN_CAP = 400;
|
|
85046
85262
|
var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -85330,51 +85546,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
85330
85546
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
85331
85547
|
const read2 = (p) => {
|
|
85332
85548
|
try {
|
|
85333
|
-
return
|
|
85549
|
+
return readFileSync26(p, "utf8");
|
|
85334
85550
|
} catch {
|
|
85335
85551
|
return null;
|
|
85336
85552
|
}
|
|
85337
85553
|
};
|
|
85338
85554
|
const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
|
|
85339
85555
|
const home = homedir6();
|
|
85340
|
-
const npm = parseNpmrcPolicy(texts(
|
|
85556
|
+
const npm = parseNpmrcPolicy(texts(join30(root, ".npmrc"), join30(home, ".npmrc")));
|
|
85341
85557
|
const blocked = /* @__PURE__ */ new Set();
|
|
85342
85558
|
if (!npm.defaultPublic) blocked.add("npm");
|
|
85343
85559
|
if (pypiIndexIsPrivate(
|
|
85344
85560
|
texts(
|
|
85345
|
-
|
|
85346
|
-
|
|
85347
|
-
|
|
85348
|
-
|
|
85349
|
-
|
|
85350
|
-
|
|
85351
|
-
|
|
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")
|
|
85352
85568
|
)
|
|
85353
85569
|
)) {
|
|
85354
85570
|
blocked.add("pypi");
|
|
85355
85571
|
}
|
|
85356
85572
|
if (cargoRegistryIsPrivate(
|
|
85357
85573
|
texts(
|
|
85358
|
-
|
|
85359
|
-
|
|
85360
|
-
|
|
85361
|
-
|
|
85574
|
+
join30(root, ".cargo", "config.toml"),
|
|
85575
|
+
join30(root, ".cargo", "config"),
|
|
85576
|
+
join30(home, ".cargo", "config.toml"),
|
|
85577
|
+
join30(home, ".cargo", "config")
|
|
85362
85578
|
)
|
|
85363
85579
|
)) {
|
|
85364
85580
|
blocked.add("cargo");
|
|
85365
85581
|
}
|
|
85366
85582
|
if (nugetSourcesArePrivate(
|
|
85367
85583
|
texts(
|
|
85368
|
-
|
|
85369
|
-
|
|
85370
|
-
|
|
85371
|
-
|
|
85372
|
-
|
|
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")
|
|
85373
85589
|
)
|
|
85374
85590
|
)) {
|
|
85375
85591
|
blocked.add("nuget");
|
|
85376
85592
|
}
|
|
85377
|
-
const goEnvFile = env2["GOENV"] ??
|
|
85593
|
+
const goEnvFile = env2["GOENV"] ?? join30(env2["APPDATA"] ?? join30(home, ".config"), "go", "env");
|
|
85378
85594
|
const goEnvText = read2(goEnvFile) ?? "";
|
|
85379
85595
|
const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
|
|
85380
85596
|
(k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
|
|
@@ -85385,10 +85601,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
|
85385
85601
|
env2["GONOSUMCHECK"],
|
|
85386
85602
|
...fromFile
|
|
85387
85603
|
]);
|
|
85388
|
-
const gemfiles = texts(
|
|
85604
|
+
const gemfiles = texts(join30(root, "Gemfile"));
|
|
85389
85605
|
if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
|
|
85390
85606
|
if (mavenReposArePrivate(
|
|
85391
|
-
texts(
|
|
85607
|
+
texts(join30(root, "pom.xml"), join30(home, ".m2", "settings.xml"))
|
|
85392
85608
|
)) {
|
|
85393
85609
|
blocked.add("maven");
|
|
85394
85610
|
}
|
|
@@ -85555,8 +85771,8 @@ function readDirectDependencies(root) {
|
|
|
85555
85771
|
const familiesSeen = /* @__PURE__ */ new Set();
|
|
85556
85772
|
for (const c of LOCKFILES) {
|
|
85557
85773
|
if (familiesSeen.has(c.family)) continue;
|
|
85558
|
-
const p =
|
|
85559
|
-
if (!
|
|
85774
|
+
const p = join30(root, c.file);
|
|
85775
|
+
if (!existsSync25(p)) continue;
|
|
85560
85776
|
try {
|
|
85561
85777
|
const s = statSync11(p);
|
|
85562
85778
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
@@ -85576,7 +85792,7 @@ function readDirectDependencies(root) {
|
|
|
85576
85792
|
const direct = [];
|
|
85577
85793
|
for (const { c, path: path3 } of found) {
|
|
85578
85794
|
try {
|
|
85579
|
-
direct.push(...c.parse(
|
|
85795
|
+
direct.push(...c.parse(readFileSync26(path3, "utf8")).direct ?? []);
|
|
85580
85796
|
} catch {
|
|
85581
85797
|
}
|
|
85582
85798
|
}
|
|
@@ -85619,14 +85835,14 @@ function manifestPaths(root) {
|
|
|
85619
85835
|
"project.godot"
|
|
85620
85836
|
];
|
|
85621
85837
|
return {
|
|
85622
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
85838
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync25(join30(root, f))),
|
|
85623
85839
|
tracked: false,
|
|
85624
85840
|
truncated: false
|
|
85625
85841
|
};
|
|
85626
85842
|
}
|
|
85627
85843
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
85628
85844
|
function rootDeclaresWorkspace(root, texts) {
|
|
85629
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
85845
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync25(join30(root, f)))) return true;
|
|
85630
85846
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
85631
85847
|
}
|
|
85632
85848
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -85640,11 +85856,11 @@ function scanManifests(root) {
|
|
|
85640
85856
|
const texts = /* @__PURE__ */ new Map();
|
|
85641
85857
|
const stamps = [];
|
|
85642
85858
|
for (const rel of paths) {
|
|
85643
|
-
const abs =
|
|
85859
|
+
const abs = join30(root, rel);
|
|
85644
85860
|
try {
|
|
85645
85861
|
const s = statSync11(abs);
|
|
85646
85862
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
85647
|
-
texts.set(rel,
|
|
85863
|
+
texts.set(rel, readFileSync26(abs, "utf8"));
|
|
85648
85864
|
} catch {
|
|
85649
85865
|
}
|
|
85650
85866
|
}
|
|
@@ -85680,22 +85896,22 @@ function readRetrievalInputs(root, repoLocator) {
|
|
|
85680
85896
|
}
|
|
85681
85897
|
|
|
85682
85898
|
// src/git-sensor.ts
|
|
85683
|
-
import { existsSync as
|
|
85684
|
-
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";
|
|
85685
85901
|
function readFirstLine(path3) {
|
|
85686
85902
|
try {
|
|
85687
|
-
return
|
|
85903
|
+
return readFileSync27(path3, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
85688
85904
|
} catch {
|
|
85689
85905
|
return null;
|
|
85690
85906
|
}
|
|
85691
85907
|
}
|
|
85692
85908
|
function readGitRefState(gitDir) {
|
|
85693
|
-
const head2 = readFirstLine(
|
|
85909
|
+
const head2 = readFirstLine(join31(gitDir, "HEAD"));
|
|
85694
85910
|
const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
|
|
85695
85911
|
const branch = m ? m[1] : null;
|
|
85696
85912
|
let sha2 = null;
|
|
85697
85913
|
if (branch) {
|
|
85698
|
-
sha2 = readFirstLine(
|
|
85914
|
+
sha2 = readFirstLine(join31(gitDir, "refs", "heads", branch));
|
|
85699
85915
|
if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
|
|
85700
85916
|
} else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
|
|
85701
85917
|
sha2 = head2;
|
|
@@ -85703,13 +85919,13 @@ function readGitRefState(gitDir) {
|
|
|
85703
85919
|
return {
|
|
85704
85920
|
branch,
|
|
85705
85921
|
sha: sha2,
|
|
85706
|
-
mergeHeadExists:
|
|
85707
|
-
origHeadExists:
|
|
85922
|
+
mergeHeadExists: existsSync26(join31(gitDir, "MERGE_HEAD")),
|
|
85923
|
+
origHeadExists: existsSync26(join31(gitDir, "ORIG_HEAD"))
|
|
85708
85924
|
};
|
|
85709
85925
|
}
|
|
85710
85926
|
function shaFromPackedRefs(gitDir, ref) {
|
|
85711
85927
|
try {
|
|
85712
|
-
for (const line of
|
|
85928
|
+
for (const line of readFileSync27(join31(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
85713
85929
|
const [sha2, name2] = line.split(/\s+/);
|
|
85714
85930
|
if (name2 === ref && sha2) return sha2;
|
|
85715
85931
|
}
|
|
@@ -85743,7 +85959,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85743
85959
|
const settle = () => {
|
|
85744
85960
|
if (timer) clearTimeout(timer);
|
|
85745
85961
|
timer = setTimeout(() => {
|
|
85746
|
-
if (
|
|
85962
|
+
if (existsSync26(join31(gitDir, "index.lock"))) {
|
|
85747
85963
|
settle();
|
|
85748
85964
|
return;
|
|
85749
85965
|
}
|
|
@@ -85754,7 +85970,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
85754
85970
|
}, debounceMs);
|
|
85755
85971
|
};
|
|
85756
85972
|
for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
|
|
85757
|
-
const p =
|
|
85973
|
+
const p = join31(gitDir, sub);
|
|
85758
85974
|
try {
|
|
85759
85975
|
watchers.push(fsWatch(p, settle));
|
|
85760
85976
|
} catch {
|
|
@@ -85984,8 +86200,8 @@ var TelemetryRecorder = class {
|
|
|
85984
86200
|
};
|
|
85985
86201
|
|
|
85986
86202
|
// src/file-activity.ts
|
|
85987
|
-
import { readFileSync as
|
|
85988
|
-
import { join as
|
|
86203
|
+
import { readFileSync as readFileSync29 } from "node:fs";
|
|
86204
|
+
import { join as join33 } from "node:path";
|
|
85989
86205
|
import { createHash as createHash17 } from "node:crypto";
|
|
85990
86206
|
|
|
85991
86207
|
// ../../packages/privacy/src/patterns/credentials.ts
|
|
@@ -86737,8 +86953,8 @@ init_git_remote();
|
|
|
86737
86953
|
// src/history-bundle.ts
|
|
86738
86954
|
init_src();
|
|
86739
86955
|
import { execFile as execFile3 } from "node:child_process";
|
|
86740
|
-
import { readFileSync as
|
|
86741
|
-
import { join as
|
|
86956
|
+
import { readFileSync as readFileSync28 } from "node:fs";
|
|
86957
|
+
import { join as join32 } from "node:path";
|
|
86742
86958
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
86743
86959
|
var FILE_LIST_CAP = 60;
|
|
86744
86960
|
var DIFF_FILE_CAP = 40;
|
|
@@ -86777,7 +86993,7 @@ function pathAllowedByFloor(path3) {
|
|
|
86777
86993
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
86778
86994
|
let source = "";
|
|
86779
86995
|
try {
|
|
86780
|
-
source =
|
|
86996
|
+
source = readFileSync28(join32(root, ".errataignore"), "utf8");
|
|
86781
86997
|
} catch {
|
|
86782
86998
|
source = "";
|
|
86783
86999
|
}
|
|
@@ -87082,7 +87298,7 @@ function readActivityBranch(root) {
|
|
|
87082
87298
|
try {
|
|
87083
87299
|
const gitDir = resolveGitDir(root);
|
|
87084
87300
|
if (!gitDir) return null;
|
|
87085
|
-
const head2 =
|
|
87301
|
+
const head2 = readFileSync29(join33(gitDir, "HEAD"), "utf8").trim();
|
|
87086
87302
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
87087
87303
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
87088
87304
|
} catch {
|
|
@@ -87239,21 +87455,21 @@ var FileActivityReporter = class {
|
|
|
87239
87455
|
|
|
87240
87456
|
// src/skills.ts
|
|
87241
87457
|
import {
|
|
87242
|
-
existsSync as
|
|
87458
|
+
existsSync as existsSync27,
|
|
87243
87459
|
mkdirSync as mkdirSync7,
|
|
87244
|
-
readFileSync as
|
|
87460
|
+
readFileSync as readFileSync30,
|
|
87245
87461
|
readdirSync as readdirSync9,
|
|
87246
87462
|
unlinkSync as unlinkSync4,
|
|
87247
87463
|
writeFileSync as writeFileSync19
|
|
87248
87464
|
} from "node:fs";
|
|
87249
|
-
import { basename as basename7, join as
|
|
87465
|
+
import { basename as basename7, join as join34 } from "node:path";
|
|
87250
87466
|
function skillFileName(id) {
|
|
87251
87467
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
87252
87468
|
}
|
|
87253
87469
|
function readSkillManifest(manifestPath) {
|
|
87254
|
-
if (!
|
|
87470
|
+
if (!existsSync27(manifestPath)) return [];
|
|
87255
87471
|
try {
|
|
87256
|
-
const parsed = JSON.parse(
|
|
87472
|
+
const parsed = JSON.parse(readFileSync30(manifestPath, "utf8"));
|
|
87257
87473
|
return (parsed.skills ?? []).map((s) => ({
|
|
87258
87474
|
title: s.title ?? "",
|
|
87259
87475
|
layer: s.layer ?? "technique",
|
|
@@ -87277,7 +87493,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87277
87493
|
for (const s of res.skills) {
|
|
87278
87494
|
const fileName = skillFileName(s.id);
|
|
87279
87495
|
keep.add(fileName);
|
|
87280
|
-
writeFileSync19(
|
|
87496
|
+
writeFileSync19(join34(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
87281
87497
|
rows.push({
|
|
87282
87498
|
id: s.id,
|
|
87283
87499
|
title: s.title,
|
|
@@ -87290,7 +87506,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87290
87506
|
const fileName = skillFileName(p.id);
|
|
87291
87507
|
if (keep.has(fileName)) continue;
|
|
87292
87508
|
keep.add(fileName);
|
|
87293
|
-
writeFileSync19(
|
|
87509
|
+
writeFileSync19(join34(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
87294
87510
|
rows.push({
|
|
87295
87511
|
id: p.id,
|
|
87296
87512
|
title: p.title,
|
|
@@ -87304,7 +87520,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87304
87520
|
if (!f.endsWith(".md")) continue;
|
|
87305
87521
|
if (keep.has(basename7(f))) continue;
|
|
87306
87522
|
try {
|
|
87307
|
-
unlinkSync4(
|
|
87523
|
+
unlinkSync4(join34(paths.skillsDir, f));
|
|
87308
87524
|
pruned++;
|
|
87309
87525
|
} catch {
|
|
87310
87526
|
}
|
|
@@ -87322,22 +87538,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
87322
87538
|
init_src2();
|
|
87323
87539
|
import {
|
|
87324
87540
|
cpSync,
|
|
87325
|
-
existsSync as
|
|
87541
|
+
existsSync as existsSync28,
|
|
87326
87542
|
lstatSync,
|
|
87327
87543
|
mkdirSync as mkdirSync8,
|
|
87328
|
-
readFileSync as
|
|
87544
|
+
readFileSync as readFileSync31,
|
|
87329
87545
|
readdirSync as readdirSync10,
|
|
87330
87546
|
rmSync as rmSync3,
|
|
87331
87547
|
symlinkSync,
|
|
87332
87548
|
writeFileSync as writeFileSync20
|
|
87333
87549
|
} from "node:fs";
|
|
87334
|
-
import { join as
|
|
87550
|
+
import { join as join35 } from "node:path";
|
|
87335
87551
|
var SKILL_NS = "errata-";
|
|
87336
87552
|
var HARNESS_SKILL_DIRS = [
|
|
87337
|
-
{ configDir: ".claude", skillsDir:
|
|
87553
|
+
{ configDir: ".claude", skillsDir: join35(".claude", "skills") },
|
|
87338
87554
|
// Cursor adopted the standard; its exact project dir is still moving — kept
|
|
87339
87555
|
// best-effort and gated on `.cursor/` presence so we never create it blind.
|
|
87340
|
-
{ configDir: ".cursor", skillsDir:
|
|
87556
|
+
{ configDir: ".cursor", skillsDir: join35(".cursor", "skills") }
|
|
87341
87557
|
];
|
|
87342
87558
|
function skillSlug(title, id) {
|
|
87343
87559
|
const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
|
|
@@ -87382,12 +87598,12 @@ function skillCiteHandle(s) {
|
|
|
87382
87598
|
return priorHandle({ id: s.id, description: s.title });
|
|
87383
87599
|
}
|
|
87384
87600
|
function reconcileNamespaced(dir, keep) {
|
|
87385
|
-
if (!
|
|
87601
|
+
if (!existsSync28(dir)) return 0;
|
|
87386
87602
|
let pruned = 0;
|
|
87387
87603
|
for (const name2 of readdirSync10(dir)) {
|
|
87388
87604
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
87389
87605
|
try {
|
|
87390
|
-
rmSync3(
|
|
87606
|
+
rmSync3(join35(dir, name2), { recursive: true, force: true });
|
|
87391
87607
|
pruned++;
|
|
87392
87608
|
} catch {
|
|
87393
87609
|
}
|
|
@@ -87396,7 +87612,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
87396
87612
|
}
|
|
87397
87613
|
function linkOrCopy(linkPath, target) {
|
|
87398
87614
|
try {
|
|
87399
|
-
if (
|
|
87615
|
+
if (existsSync28(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
87400
87616
|
} catch {
|
|
87401
87617
|
}
|
|
87402
87618
|
try {
|
|
@@ -87417,7 +87633,7 @@ function safeLstat(p) {
|
|
|
87417
87633
|
}
|
|
87418
87634
|
}
|
|
87419
87635
|
function emitAndProjectSkills(root, skills) {
|
|
87420
|
-
const agentsSkillsDir =
|
|
87636
|
+
const agentsSkillsDir = join35(root, ".agents", "skills");
|
|
87421
87637
|
mkdirSync8(agentsSkillsDir, { recursive: true });
|
|
87422
87638
|
const slugs = [];
|
|
87423
87639
|
const keep = /* @__PURE__ */ new Set();
|
|
@@ -87425,7 +87641,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87425
87641
|
for (const s of skills) {
|
|
87426
87642
|
let body2;
|
|
87427
87643
|
try {
|
|
87428
|
-
body2 =
|
|
87644
|
+
body2 = readFileSync31(s.bodyPath, "utf8");
|
|
87429
87645
|
} catch {
|
|
87430
87646
|
continue;
|
|
87431
87647
|
}
|
|
@@ -87434,9 +87650,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87434
87650
|
keep.add(slug2);
|
|
87435
87651
|
slugs.push(slug2);
|
|
87436
87652
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
87437
|
-
mkdirSync8(
|
|
87653
|
+
mkdirSync8(join35(agentsSkillsDir, slug2), { recursive: true });
|
|
87438
87654
|
writeFileSync20(
|
|
87439
|
-
|
|
87655
|
+
join35(agentsSkillsDir, slug2, "SKILL.md"),
|
|
87440
87656
|
renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
|
|
87441
87657
|
"utf8"
|
|
87442
87658
|
);
|
|
@@ -87445,11 +87661,11 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87445
87661
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
87446
87662
|
let projected = 0;
|
|
87447
87663
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
87448
|
-
if (!
|
|
87449
|
-
const dir =
|
|
87664
|
+
if (!existsSync28(join35(root, h.configDir))) continue;
|
|
87665
|
+
const dir = join35(root, h.skillsDir);
|
|
87450
87666
|
mkdirSync8(dir, { recursive: true });
|
|
87451
87667
|
for (const slug2 of slugs) {
|
|
87452
|
-
linkOrCopy(
|
|
87668
|
+
linkOrCopy(join35(dir, slug2), join35(agentsSkillsDir, slug2));
|
|
87453
87669
|
projected++;
|
|
87454
87670
|
}
|
|
87455
87671
|
reconcileNamespaced(dir, keep);
|
|
@@ -87458,15 +87674,15 @@ function emitAndProjectSkills(root, skills) {
|
|
|
87458
87674
|
return { slugs, emitted, projected };
|
|
87459
87675
|
}
|
|
87460
87676
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
87461
|
-
if (!
|
|
87677
|
+
if (!existsSync28(manifestPath)) return [];
|
|
87462
87678
|
try {
|
|
87463
|
-
const parsed = JSON.parse(
|
|
87679
|
+
const parsed = JSON.parse(readFileSync31(manifestPath, "utf8"));
|
|
87464
87680
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
87465
87681
|
id: s.id,
|
|
87466
87682
|
title: s.title ?? s.id,
|
|
87467
87683
|
layer: s.layer ?? "technique",
|
|
87468
87684
|
confidence: s.confidence ?? 0,
|
|
87469
|
-
bodyPath:
|
|
87685
|
+
bodyPath: join35(erretaDir, s.file)
|
|
87470
87686
|
}));
|
|
87471
87687
|
} catch {
|
|
87472
87688
|
return [];
|
|
@@ -87480,10 +87696,10 @@ var GITIGNORE_LINES = [
|
|
|
87480
87696
|
".cursor/skills/errata-*/"
|
|
87481
87697
|
];
|
|
87482
87698
|
function ensureSkillGitignore(root) {
|
|
87483
|
-
const path3 =
|
|
87699
|
+
const path3 = join35(root, ".gitignore");
|
|
87484
87700
|
let current = "";
|
|
87485
87701
|
try {
|
|
87486
|
-
current =
|
|
87702
|
+
current = existsSync28(path3) ? readFileSync31(path3, "utf8") : "";
|
|
87487
87703
|
} catch {
|
|
87488
87704
|
return;
|
|
87489
87705
|
}
|
|
@@ -87529,6 +87745,100 @@ function createIntentState(ttlMs = INTENT_TTL_MS) {
|
|
|
87529
87745
|
};
|
|
87530
87746
|
}
|
|
87531
87747
|
|
|
87748
|
+
// src/engine.ts
|
|
87749
|
+
init_mcp();
|
|
87750
|
+
|
|
87751
|
+
// src/task-priors.ts
|
|
87752
|
+
function taskPriorsEnabled(env2 = process.env) {
|
|
87753
|
+
return /^(1|on|true|yes)$/i.test((env2["ERRATA_TASK_PRIORS"] ?? "").trim());
|
|
87754
|
+
}
|
|
87755
|
+
var TASK_PRIORS_FLOOR = 0.45;
|
|
87756
|
+
var TASK_PRIORS_BAND = 0.15;
|
|
87757
|
+
var TASK_PRIORS_MAX = 5;
|
|
87758
|
+
var TASK_QUERY_MAX_CHARS = 600;
|
|
87759
|
+
var KNOWLEDGE = /* @__PURE__ */ new Set(["Problem", "RootCause", "Solution", "Pattern", "Comment", "Claim", "Vulnerability"]);
|
|
87760
|
+
var clip2 = (s, n) => s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
|
|
87761
|
+
var oneLine2 = (s) => String(s ?? "").replace(/\s+/g, " ").trim();
|
|
87762
|
+
function pickTaskHits(result) {
|
|
87763
|
+
const rows = Array.isArray(result) ? result : result?.results;
|
|
87764
|
+
if (!Array.isArray(rows)) return [];
|
|
87765
|
+
const relevanceOf = (r) => Number(r["why"]?.relevance ?? 0);
|
|
87766
|
+
const knowledge = rows.filter((r) => KNOWLEDGE.has(String(r["label"] ?? "")));
|
|
87767
|
+
const best = Math.max(0, ...knowledge.map(relevanceOf));
|
|
87768
|
+
const cut = Math.max(TASK_PRIORS_FLOOR, best - TASK_PRIORS_BAND);
|
|
87769
|
+
const hits = [];
|
|
87770
|
+
for (const r of knowledge) {
|
|
87771
|
+
const label = String(r["label"]);
|
|
87772
|
+
const relevance = relevanceOf(r);
|
|
87773
|
+
if (!(relevance >= cut)) continue;
|
|
87774
|
+
const chain2 = r["chain"];
|
|
87775
|
+
hits.push({
|
|
87776
|
+
id: String(r["cite"] ?? r["id"]),
|
|
87777
|
+
label,
|
|
87778
|
+
text: oneLine2(r["name"] ?? r["description"]),
|
|
87779
|
+
relevance,
|
|
87780
|
+
...typeof r["lifecycle"] === "string" ? { lifecycle: r["lifecycle"] } : {},
|
|
87781
|
+
...chain2?.cause?.text ? { cause: oneLine2(chain2.cause.text) } : {},
|
|
87782
|
+
...chain2?.fix?.text ? { fix: oneLine2(chain2.fix.text) } : {}
|
|
87783
|
+
});
|
|
87784
|
+
if (hits.length >= TASK_PRIORS_MAX) break;
|
|
87785
|
+
}
|
|
87786
|
+
return hits;
|
|
87787
|
+
}
|
|
87788
|
+
function renderTaskPriors(query, hits, addendum) {
|
|
87789
|
+
const lines = [
|
|
87790
|
+
addendum ? "### \u{1F3AF} errata \u2014 more for this task, from the Errata Network" : "### \u{1F3AF} errata \u2014 what the graph already knows about this task",
|
|
87791
|
+
addendum ? "_The Network side of the search on your task finished; these weren't in the earlier list._" : `_errata searched its graph for your task ("${clip2(oneLine2(query), 120)}") \u2014 no need to run that search yourself. Check a prior against the code before relying on it, and cite what you use as ([id])._`
|
|
87792
|
+
];
|
|
87793
|
+
for (const h of hits) {
|
|
87794
|
+
lines.push(`- **${h.label}:** ${clip2(h.text, 220)} \`[${h.id}]\`${h.lifecycle ? ` \u2014 ${h.lifecycle}` : ""}`);
|
|
87795
|
+
if (h.cause) lines.push(` - cause: ${clip2(h.cause, 220)}`);
|
|
87796
|
+
if (h.fix) lines.push(` - fix: ${clip2(h.fix, 260)}`);
|
|
87797
|
+
}
|
|
87798
|
+
return lines.join("\n");
|
|
87799
|
+
}
|
|
87800
|
+
function createTaskPriors(search, opts) {
|
|
87801
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
87802
|
+
const maxSessions = opts.maxSessions ?? 200;
|
|
87803
|
+
const phase = async (sessionId, state, generation, network) => {
|
|
87804
|
+
let result;
|
|
87805
|
+
try {
|
|
87806
|
+
result = await search(state.query, { network });
|
|
87807
|
+
} catch {
|
|
87808
|
+
return;
|
|
87809
|
+
}
|
|
87810
|
+
if (sessions.get(sessionId) !== state || state.generation !== generation) return;
|
|
87811
|
+
const fresh = pickTaskHits(result).filter((h) => !state.sent.has(h.id));
|
|
87812
|
+
if (fresh.length === 0) return;
|
|
87813
|
+
for (const h of fresh) state.sent.add(h.id);
|
|
87814
|
+
state.ready.push(renderTaskPriors(state.query, fresh, network && state.sent.size > fresh.length));
|
|
87815
|
+
};
|
|
87816
|
+
return {
|
|
87817
|
+
/** The session was handed a task (its prompt) or restated it (an intent fence). */
|
|
87818
|
+
start(sessionId, text) {
|
|
87819
|
+
const query = oneLine2(text).slice(0, TASK_QUERY_MAX_CHARS);
|
|
87820
|
+
if (!sessionId || query.length < 12) return;
|
|
87821
|
+
const prev = sessions.get(sessionId);
|
|
87822
|
+
if (prev?.query === query) return;
|
|
87823
|
+
const state = { query, generation: (prev?.generation ?? 0) + 1, sent: prev?.sent ?? /* @__PURE__ */ new Set(), ready: prev?.ready ?? [] };
|
|
87824
|
+
sessions.delete(sessionId);
|
|
87825
|
+
sessions.set(sessionId, state);
|
|
87826
|
+
if (sessions.size > maxSessions) sessions.delete(sessions.keys().next().value);
|
|
87827
|
+
const generation = state.generation;
|
|
87828
|
+
void phase(sessionId, state, generation, false).then(() => opts.network() ? phase(sessionId, state, generation, true) : void 0);
|
|
87829
|
+
},
|
|
87830
|
+
/** What is ready for this session's next tool hook, once; null when nothing is. */
|
|
87831
|
+
take(sessionId) {
|
|
87832
|
+
const state = sessions.get(sessionId);
|
|
87833
|
+
if (!state || state.ready.length === 0) return null;
|
|
87834
|
+
return state.ready.splice(0).join("\n\n");
|
|
87835
|
+
},
|
|
87836
|
+
end(sessionId) {
|
|
87837
|
+
sessions.delete(sessionId);
|
|
87838
|
+
}
|
|
87839
|
+
};
|
|
87840
|
+
}
|
|
87841
|
+
|
|
87532
87842
|
// src/working-file-state.ts
|
|
87533
87843
|
function createWorkingFileState() {
|
|
87534
87844
|
const bySession = /* @__PURE__ */ new Map();
|
|
@@ -87586,18 +87896,18 @@ init_paths();
|
|
|
87586
87896
|
init_profile2();
|
|
87587
87897
|
|
|
87588
87898
|
// src/witness-queue.ts
|
|
87589
|
-
import { readFileSync as
|
|
87590
|
-
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";
|
|
87591
87901
|
var WITNESS_QUEUE_CAP = 500;
|
|
87592
87902
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
87593
87903
|
var WITNESS_MAX_ATTEMPTS = 5;
|
|
87594
87904
|
function witnessQueuePath(workspaceConfigDir) {
|
|
87595
|
-
return
|
|
87905
|
+
return join36(workspaceConfigDir, "witness-queue.json");
|
|
87596
87906
|
}
|
|
87597
87907
|
function loadWitnessQueueWithLosses(path3) {
|
|
87598
87908
|
let raw2;
|
|
87599
87909
|
try {
|
|
87600
|
-
raw2 = JSON.parse(
|
|
87910
|
+
raw2 = JSON.parse(readFileSync32(path3, "utf8"));
|
|
87601
87911
|
} catch (err2) {
|
|
87602
87912
|
const absent = err2?.code === "ENOENT";
|
|
87603
87913
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -87610,7 +87920,7 @@ function loadWitnessQueueWithLosses(path3) {
|
|
|
87610
87920
|
}
|
|
87611
87921
|
function saveWitnessQueue(path3, queue) {
|
|
87612
87922
|
try {
|
|
87613
|
-
const tmp =
|
|
87923
|
+
const tmp = join36(dirname15(path3), `.${Date.now()}.witness-queue.tmp`);
|
|
87614
87924
|
writeFileSync21(tmp, JSON.stringify(queue), "utf8");
|
|
87615
87925
|
renameSync4(tmp, path3);
|
|
87616
87926
|
} catch {
|
|
@@ -87920,8 +88230,8 @@ function maybeFlushDigests() {
|
|
|
87920
88230
|
|
|
87921
88231
|
// src/liveness-watch.ts
|
|
87922
88232
|
init_src5();
|
|
87923
|
-
import { readFileSync as
|
|
87924
|
-
import { join as
|
|
88233
|
+
import { readFileSync as readFileSync34, writeFileSync as writeFileSync23 } from "node:fs";
|
|
88234
|
+
import { join as join38 } from "node:path";
|
|
87925
88235
|
|
|
87926
88236
|
// src/loop-lag.ts
|
|
87927
88237
|
var HEARTBEAT_MS = 500;
|
|
@@ -88053,11 +88363,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
|
|
|
88053
88363
|
var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
|
|
88054
88364
|
var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
|
|
88055
88365
|
function alarmStatePath(configDir) {
|
|
88056
|
-
return
|
|
88366
|
+
return join38(configDir, "liveness-alarms.json");
|
|
88057
88367
|
}
|
|
88058
88368
|
function loadAlarmState(path3) {
|
|
88059
88369
|
try {
|
|
88060
|
-
const raw2 = JSON.parse(
|
|
88370
|
+
const raw2 = JSON.parse(readFileSync34(path3, "utf8"));
|
|
88061
88371
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
88062
88372
|
} catch {
|
|
88063
88373
|
return /* @__PURE__ */ new Map();
|
|
@@ -88321,7 +88631,7 @@ function createWatchBreaker(deps) {
|
|
|
88321
88631
|
}
|
|
88322
88632
|
|
|
88323
88633
|
// src/engine.ts
|
|
88324
|
-
var DAEMON_VERSION = true ? "2.0.23-dev.
|
|
88634
|
+
var DAEMON_VERSION = true ? "2.0.23-dev.4901" : "2.0.0-alpha.0";
|
|
88325
88635
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
88326
88636
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
88327
88637
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -88333,7 +88643,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
88333
88643
|
function appendIdentityAudit(path3, record2, line) {
|
|
88334
88644
|
if (!record2.accepted && record2.score <= 0) return;
|
|
88335
88645
|
try {
|
|
88336
|
-
if (
|
|
88646
|
+
if (existsSync30(path3) && statSync12(path3).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
88337
88647
|
renameSync5(path3, `${path3}.1`);
|
|
88338
88648
|
}
|
|
88339
88649
|
appendFileSync4(path3, line);
|
|
@@ -88343,7 +88653,7 @@ function appendIdentityAudit(path3, record2, line) {
|
|
|
88343
88653
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
88344
88654
|
function loadTurnCursors(path3) {
|
|
88345
88655
|
try {
|
|
88346
|
-
const raw2 = JSON.parse(
|
|
88656
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88347
88657
|
return new Map(
|
|
88348
88658
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
88349
88659
|
);
|
|
@@ -88353,7 +88663,7 @@ function loadTurnCursors(path3) {
|
|
|
88353
88663
|
}
|
|
88354
88664
|
function loadTurnOffsets(path3) {
|
|
88355
88665
|
try {
|
|
88356
|
-
const raw2 = JSON.parse(
|
|
88666
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88357
88667
|
const out2 = /* @__PURE__ */ new Map();
|
|
88358
88668
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88359
88669
|
const off2 = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -88366,7 +88676,7 @@ function loadTurnOffsets(path3) {
|
|
|
88366
88676
|
}
|
|
88367
88677
|
function loadTurnMoves(path3) {
|
|
88368
88678
|
try {
|
|
88369
|
-
const raw2 = JSON.parse(
|
|
88679
|
+
const raw2 = JSON.parse(readFileSync35(path3, "utf8"));
|
|
88370
88680
|
const out2 = /* @__PURE__ */ new Map();
|
|
88371
88681
|
for (const [k, v] of Object.entries(raw2)) {
|
|
88372
88682
|
const to = typeof v === "object" && v !== null ? v.movedTo : void 0;
|
|
@@ -88387,7 +88697,7 @@ function saveTurnCursors(path3, cursors, offsets, moves = /* @__PURE__ */ new Ma
|
|
|
88387
88697
|
} catch {
|
|
88388
88698
|
}
|
|
88389
88699
|
}
|
|
88390
|
-
var turnCursorFile = (configDir) =>
|
|
88700
|
+
var turnCursorFile = (configDir) => join39(configDir, "turn-cursors.json");
|
|
88391
88701
|
function turnCursorOnDisk(configDir, sessionId) {
|
|
88392
88702
|
const path3 = turnCursorFile(configDir);
|
|
88393
88703
|
const offset = loadTurnOffsets(path3).get(sessionId);
|
|
@@ -88419,7 +88729,7 @@ function gitSourceWatchTargets(root) {
|
|
|
88419
88729
|
["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
|
|
88420
88730
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
88421
88731
|
);
|
|
88422
|
-
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));
|
|
88423
88733
|
} catch {
|
|
88424
88734
|
}
|
|
88425
88735
|
const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
|
|
@@ -88431,19 +88741,19 @@ function gitSourceWatchTargets(root) {
|
|
|
88431
88741
|
if (!f.startsWith(prefix)) continue;
|
|
88432
88742
|
const rest2 = f.slice(prefix.length);
|
|
88433
88743
|
if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
|
|
88434
|
-
else targets.add(
|
|
88744
|
+
else targets.add(join39(root, f));
|
|
88435
88745
|
}
|
|
88436
88746
|
for (const c of children) {
|
|
88437
|
-
if (IGNORED_PATH.test(
|
|
88747
|
+
if (IGNORED_PATH.test(join39(root, c) + sep5)) continue;
|
|
88438
88748
|
if (hasIgnoredChild(c)) addUnder(c);
|
|
88439
|
-
else targets.add(
|
|
88749
|
+
else targets.add(join39(root, c));
|
|
88440
88750
|
}
|
|
88441
88751
|
};
|
|
88442
88752
|
addUnder("");
|
|
88443
88753
|
if (targets.size > 0) return [...targets];
|
|
88444
88754
|
} catch {
|
|
88445
88755
|
}
|
|
88446
|
-
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)));
|
|
88447
88757
|
}
|
|
88448
88758
|
function createWorkspaceEngine(opts) {
|
|
88449
88759
|
const paths = workspacePaths(opts.workspaceRoot);
|
|
@@ -88645,7 +88955,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88645
88955
|
const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
|
|
88646
88956
|
let episodeId2;
|
|
88647
88957
|
if (srcPaths.length > 0) {
|
|
88648
|
-
const abs = srcPaths.map((p) =>
|
|
88958
|
+
const abs = srcPaths.map((p) => join39(opts.workspaceRoot, p));
|
|
88649
88959
|
try {
|
|
88650
88960
|
const r = await runReindexPass(
|
|
88651
88961
|
`git-reindex:${profile.name} (${abs.length} files)`,
|
|
@@ -88681,8 +88991,8 @@ function createWorkspaceEngine(opts) {
|
|
|
88681
88991
|
`[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
|
|
88682
88992
|
);
|
|
88683
88993
|
};
|
|
88684
|
-
const gitDir =
|
|
88685
|
-
if (
|
|
88994
|
+
const gitDir = join39(opts.workspaceRoot, ".git");
|
|
88995
|
+
if (existsSync30(gitDir)) {
|
|
88686
88996
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
88687
88997
|
void handleGitEvent(ev).catch((err2) => {
|
|
88688
88998
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -88743,7 +89053,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88743
89053
|
},
|
|
88744
89054
|
onAlarms: (alarms) => {
|
|
88745
89055
|
toastLivenessAlarms(
|
|
88746
|
-
sharedAlarmToastGate(
|
|
89056
|
+
sharedAlarmToastGate(join39(globalDir(), "liveness-toasts.json")),
|
|
88747
89057
|
{ root: opts.workspaceRoot, name: profile.name },
|
|
88748
89058
|
alarms,
|
|
88749
89059
|
(body2, key) => notifyEvent("mechanism-stalled", body2, { key }),
|
|
@@ -88756,11 +89066,21 @@ function createWorkspaceEngine(opts) {
|
|
|
88756
89066
|
witnessParked: () => witnessQueue.length
|
|
88757
89067
|
});
|
|
88758
89068
|
const intents = createIntentState();
|
|
89069
|
+
const taskPriorsOn = taskPriorsEnabled();
|
|
89070
|
+
const taskPriors = createTaskPriors(
|
|
89071
|
+
(query, { network }) => runTool(
|
|
89072
|
+
"errata.search",
|
|
89073
|
+
{ query, limit: 10 },
|
|
89074
|
+
store,
|
|
89075
|
+
network ? { cloud, ...opts.generalizeSoft ? { generalizeSoft: opts.generalizeSoft } : {} } : {}
|
|
89076
|
+
),
|
|
89077
|
+
{ network: () => !opts.skipContextWriter && (opts.syncConsent ?? consentNow().sync) && typeof cloud.search === "function" }
|
|
89078
|
+
);
|
|
88759
89079
|
const subagents = createSubagentState();
|
|
88760
89080
|
let subagentBase = null;
|
|
88761
89081
|
let subagentBaseVersion = 0;
|
|
88762
89082
|
const subagentRenders = /* @__PURE__ */ new Map();
|
|
88763
|
-
const sessions = createSessionRegistry({ originsPath:
|
|
89083
|
+
const sessions = createSessionRegistry({ originsPath: join39(paths.configDir, "session-origins.json") });
|
|
88764
89084
|
const sessionRenders = /* @__PURE__ */ new Map();
|
|
88765
89085
|
const selfCiteSkipsBySession = /* @__PURE__ */ new Map();
|
|
88766
89086
|
const supersessionAsks = new SupersessionAsks();
|
|
@@ -88800,7 +89120,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88800
89120
|
}
|
|
88801
89121
|
}
|
|
88802
89122
|
};
|
|
88803
|
-
const
|
|
89123
|
+
const clip3 = (s, n) => s.length > n ? `${s.slice(0, n - 1)}\u2026` : s;
|
|
88804
89124
|
const pickReviewItems = () => {
|
|
88805
89125
|
const shared = opts.sharedStore;
|
|
88806
89126
|
if (!shared) return [];
|
|
@@ -88811,12 +89131,12 @@ function createWorkspaceEngine(opts) {
|
|
|
88811
89131
|
return [{
|
|
88812
89132
|
kind: "abstraction",
|
|
88813
89133
|
candidate: small.candidate,
|
|
88814
|
-
members: small.members.map((m) => ({ id: m.id, description:
|
|
89134
|
+
members: small.members.map((m) => ({ id: m.id, description: clip3(m.description, 110) }))
|
|
88815
89135
|
}];
|
|
88816
89136
|
}
|
|
88817
89137
|
}
|
|
88818
89138
|
const [d] = pendingDiscriminators(shared, { limit: 1 });
|
|
88819
|
-
return d ? [{ kind: "discriminator", route: d.route, presenting:
|
|
89139
|
+
return d ? [{ kind: "discriminator", route: d.route, presenting: clip3(d.presenting, 140), cause: clip3(d.cause, 140) }] : [];
|
|
88820
89140
|
} catch {
|
|
88821
89141
|
return [];
|
|
88822
89142
|
}
|
|
@@ -88865,7 +89185,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88865
89185
|
const elicit = isEdgeElicitationEnabled();
|
|
88866
89186
|
const snapOpts = {
|
|
88867
89187
|
profile,
|
|
88868
|
-
atCommit: readGitRefState(
|
|
89188
|
+
atCommit: readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0,
|
|
88869
89189
|
reviewCount: pendingCount(paths),
|
|
88870
89190
|
reviewUiUrl: opts.reviewUrl(),
|
|
88871
89191
|
workingFile: workingFiles.mostRecent() ?? void 0,
|
|
@@ -88905,7 +89225,7 @@ function createWorkspaceEngine(opts) {
|
|
|
88905
89225
|
);
|
|
88906
89226
|
return null;
|
|
88907
89227
|
}) : null;
|
|
88908
|
-
if (snapOpts.atCommit !== (readGitRefState(
|
|
89228
|
+
if (snapOpts.atCommit !== (readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0)) {
|
|
88909
89229
|
contextDirty = true;
|
|
88910
89230
|
return;
|
|
88911
89231
|
}
|
|
@@ -88951,10 +89271,10 @@ function createWorkspaceEngine(opts) {
|
|
|
88951
89271
|
} catch (err2) {
|
|
88952
89272
|
console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
|
|
88953
89273
|
}
|
|
88954
|
-
const target =
|
|
89274
|
+
const target = join39(opts.workspaceRoot, "AGENTS.md");
|
|
88955
89275
|
writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
|
|
88956
89276
|
if (elicit) {
|
|
88957
|
-
writePrimingHandles(
|
|
89277
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), [
|
|
88958
89278
|
...snapshot.recentProblems.map((r) => r.node),
|
|
88959
89279
|
// Resolved-band handles: the ✓ problem AND its Solution are citable
|
|
88960
89280
|
// (a fix tag on an already-resolved problem no-ops idempotently; the
|
|
@@ -89262,8 +89582,8 @@ function createWorkspaceEngine(opts) {
|
|
|
89262
89582
|
const cached2 = subagentRenders.get(a.agentId);
|
|
89263
89583
|
if (cached2?.key === key) return cached2.block;
|
|
89264
89584
|
const elicit = isEdgeElicitationEnabled();
|
|
89265
|
-
const handlesPath =
|
|
89266
|
-
const atCommit = readGitRefState(
|
|
89585
|
+
const handlesPath = join39(paths.configDir, "priming-handles.json");
|
|
89586
|
+
const atCommit = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89267
89587
|
const block = renderSubagentBlock({
|
|
89268
89588
|
store,
|
|
89269
89589
|
entry,
|
|
@@ -89318,7 +89638,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89318
89638
|
const cached2 = sessionRenders.get(sessionId);
|
|
89319
89639
|
if (cached2?.key === key) return cached2.block;
|
|
89320
89640
|
const elicit = isEdgeElicitationEnabled();
|
|
89321
|
-
const atCommit = readGitRefState(
|
|
89641
|
+
const atCommit = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89322
89642
|
const scoped = scopeSnapshot(structuredClone(subagentBase), (n) => !hiddenFrom(n, sessionId, sessions, now));
|
|
89323
89643
|
delete scoped.workingFile;
|
|
89324
89644
|
if (workingFile) {
|
|
@@ -89330,9 +89650,17 @@ function createWorkspaceEngine(opts) {
|
|
|
89330
89650
|
delete scoped.supersessionAsks;
|
|
89331
89651
|
const asks = supersessionAsksFor(sessionId);
|
|
89332
89652
|
if (asks.length > 0) scoped.supersessionAsks = asks;
|
|
89653
|
+
if (taskPriorsOn) {
|
|
89654
|
+
scoped.recentProblems = [];
|
|
89655
|
+
scoped.recentResolved = [];
|
|
89656
|
+
scoped.regressions = [];
|
|
89657
|
+
scoped.recentConstraints = [];
|
|
89658
|
+
scoped.motifs = [];
|
|
89659
|
+
delete scoped.motifPool;
|
|
89660
|
+
}
|
|
89333
89661
|
const pendingUpdate = opts.pendingUpdate?.() ?? null;
|
|
89334
89662
|
const daemonDistress = opts.daemonDistress?.() ?? null;
|
|
89335
|
-
const reviewItems = pickReviewItems();
|
|
89663
|
+
const reviewItems = taskPriorsOn ? [] : pickReviewItems();
|
|
89336
89664
|
const sessionIntent = intent ? statedIntentFor(intent) : null;
|
|
89337
89665
|
const sessionMotifSignal = motifSignalFor(scoped, sessionIntent);
|
|
89338
89666
|
const { body: body2, snapshot } = assembleAgentContext({
|
|
@@ -89341,7 +89669,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89341
89669
|
...atCommit ? { atCommit } : {},
|
|
89342
89670
|
reviewCount: pendingCount(paths),
|
|
89343
89671
|
reviewUiUrl: opts.reviewUrl(),
|
|
89344
|
-
remote: remotePriors,
|
|
89672
|
+
remote: taskPriorsOn ? [] : remotePriors,
|
|
89345
89673
|
snapshot: scoped,
|
|
89346
89674
|
...elicit ? { edgeElicitation: { instruction: PRIOR_TAG_INSTRUCTION } } : {},
|
|
89347
89675
|
...pendingUpdate ? { pendingUpdate } : {},
|
|
@@ -89362,7 +89690,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89362
89690
|
]
|
|
89363
89691
|
};
|
|
89364
89692
|
if (elicit && block.handleNodes.length) {
|
|
89365
|
-
writePrimingHandles(
|
|
89693
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), block.handleNodes);
|
|
89366
89694
|
}
|
|
89367
89695
|
sessionRenders.delete(sessionId);
|
|
89368
89696
|
sessionRenders.set(sessionId, { key, block });
|
|
@@ -89496,7 +89824,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89496
89824
|
let processedTurns = 0;
|
|
89497
89825
|
const seqAtStart = store.currentIngestSeq();
|
|
89498
89826
|
const elicit = isEdgeElicitationEnabled();
|
|
89499
|
-
const handleMap = elicit ? readPrimingHandles(
|
|
89827
|
+
const handleMap = elicit ? readPrimingHandles(join39(paths.configDir, "priming-handles.json")) : {};
|
|
89500
89828
|
const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
|
|
89501
89829
|
const toRel = (abs) => {
|
|
89502
89830
|
const p = abs.replace(/\\/g, "/");
|
|
@@ -89635,7 +89963,10 @@ function createWorkspaceEngine(opts) {
|
|
|
89635
89963
|
const fenceAgent = turn.agentId ?? (sessionId.startsWith("agent-") ? sessionId.slice(6) : void 0);
|
|
89636
89964
|
for (const fence of parseIntentFences(turn.text)) {
|
|
89637
89965
|
if (fenceAgent) subagents.setIntent(fenceAgent, fence.intent, t);
|
|
89638
|
-
else if (intents.set(sessionId, fence.intent, t))
|
|
89966
|
+
else if (intents.set(sessionId, fence.intent, t)) {
|
|
89967
|
+
refreshContextNow();
|
|
89968
|
+
if (taskPriorsOn) taskPriors.start(sessionId, fence.intent);
|
|
89969
|
+
}
|
|
89639
89970
|
}
|
|
89640
89971
|
const plan = harvestInlineTags(store, turn.text, {
|
|
89641
89972
|
sourceId: sessionLastProblem.get(sessionId),
|
|
@@ -89716,7 +90047,7 @@ function createWorkspaceEngine(opts) {
|
|
|
89716
90047
|
let anchorReadFailed = false;
|
|
89717
90048
|
if (p.location) {
|
|
89718
90049
|
try {
|
|
89719
|
-
fileText =
|
|
90050
|
+
fileText = readFileSync35(join39(opts.workspaceRoot, p.location.path), "utf8");
|
|
89720
90051
|
} catch {
|
|
89721
90052
|
anchorReadFailed = true;
|
|
89722
90053
|
}
|
|
@@ -89879,10 +90210,10 @@ function createWorkspaceEngine(opts) {
|
|
|
89879
90210
|
let enclosing = {};
|
|
89880
90211
|
if (p.location?.line !== void 0) {
|
|
89881
90212
|
try {
|
|
89882
|
-
const headSha = readGitRefState(
|
|
90213
|
+
const headSha = readGitRefState(join39(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
89883
90214
|
enclosing = {
|
|
89884
90215
|
line: p.location.line,
|
|
89885
|
-
fileText:
|
|
90216
|
+
fileText: readFileSync35(join39(opts.workspaceRoot, anchorPath), "utf8"),
|
|
89886
90217
|
...headSha ? { headSha } : {}
|
|
89887
90218
|
};
|
|
89888
90219
|
} catch {
|
|
@@ -90646,6 +90977,7 @@ B: ${b}`,
|
|
|
90646
90977
|
return null;
|
|
90647
90978
|
} : void 0;
|
|
90648
90979
|
const onSessionEnd = (e) => {
|
|
90980
|
+
taskPriors.end(e.sessionId);
|
|
90649
90981
|
if (!designRollup) return;
|
|
90650
90982
|
setImmediate(() => {
|
|
90651
90983
|
const convo = readConversation(e.transcriptPath);
|
|
@@ -90756,7 +91088,7 @@ B: ${b}`,
|
|
|
90756
91088
|
try {
|
|
90757
91089
|
const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
|
|
90758
91090
|
emitAndProjectSkills(opts.workspaceRoot, inputs);
|
|
90759
|
-
writePrimingHandles(
|
|
91091
|
+
writePrimingHandles(join39(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
|
|
90760
91092
|
} catch (err2) {
|
|
90761
91093
|
console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
|
|
90762
91094
|
}
|
|
@@ -90775,6 +91107,10 @@ B: ${b}`,
|
|
|
90775
91107
|
onSubagentStop,
|
|
90776
91108
|
noteSession,
|
|
90777
91109
|
sessionContext,
|
|
91110
|
+
onTaskPrompt: (sessionId, prompt) => {
|
|
91111
|
+
if (taskPriorsOn) taskPriors.start(sessionId, prompt);
|
|
91112
|
+
},
|
|
91113
|
+
takeTaskPriors: (sessionId) => taskPriorsOn ? taskPriors.take(sessionId) : null,
|
|
90778
91114
|
onHook: () => telemetry.count("hooks_fired"),
|
|
90779
91115
|
onToolsObserved: (sessionId, toolNodeIds) => toolRuns.record(sessionId, toolNodeIds),
|
|
90780
91116
|
onKnowledgeShown: (sessionId, shown) => supersessionAsks.noteShown(sessionId, shown),
|
|
@@ -91123,7 +91459,7 @@ B: ${b}`,
|
|
|
91123
91459
|
console.log(
|
|
91124
91460
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
91125
91461
|
);
|
|
91126
|
-
const pending =
|
|
91462
|
+
const pending = existsSync30(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
91127
91463
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
91128
91464
|
}
|
|
91129
91465
|
if (!shipsFromWorkspace(opts.workspaceRoot)) {
|
|
@@ -91135,7 +91471,7 @@ B: ${b}`,
|
|
|
91135
91471
|
console.log(
|
|
91136
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"
|
|
91137
91473
|
);
|
|
91138
|
-
const pending =
|
|
91474
|
+
const pending = existsSync30(paths.outbox) ? readdirSync11(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
91139
91475
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
91140
91476
|
}
|
|
91141
91477
|
try {
|
|
@@ -91282,6 +91618,9 @@ async function startDaemon(opts) {
|
|
|
91282
91618
|
onSubagentStop: engine.webHooks.onSubagentStop,
|
|
91283
91619
|
noteSession: engine.webHooks.noteSession,
|
|
91284
91620
|
sessionContext: engine.webHooks.sessionContext,
|
|
91621
|
+
// Task priors: the task, searched in the background; delivered on the next tool hook.
|
|
91622
|
+
onTaskPrompt: engine.webHooks.onTaskPrompt,
|
|
91623
|
+
takeTaskPriors: engine.webHooks.takeTaskPriors,
|
|
91285
91624
|
onHook: engine.webHooks.onHook,
|
|
91286
91625
|
onHookEvent: engine.webHooks.onHookEvent,
|
|
91287
91626
|
onShellEvent: engine.webHooks.onShellEvent,
|
|
@@ -91312,7 +91651,7 @@ async function startDaemon(opts) {
|
|
|
91312
91651
|
);
|
|
91313
91652
|
await engine.stop();
|
|
91314
91653
|
try {
|
|
91315
|
-
if (
|
|
91654
|
+
if (existsSync31(engine.paths.daemonLock)) {
|
|
91316
91655
|
}
|
|
91317
91656
|
} catch {
|
|
91318
91657
|
}
|
|
@@ -91513,8 +91852,8 @@ async function linkRegisteredWorkspaces(cfg, loggedInProfile = cfg.activeInstall
|
|
|
91513
91852
|
}
|
|
91514
91853
|
|
|
91515
91854
|
// src/edge-park.ts
|
|
91516
|
-
import { readFileSync as
|
|
91517
|
-
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";
|
|
91518
91857
|
var EDGE_PARK_CAP = 2e3;
|
|
91519
91858
|
var EDGE_PARK_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
91520
91859
|
var EDGE_PARK_MAX_ATTEMPTS = 6;
|
|
@@ -91529,12 +91868,12 @@ function wireEdgeKey(from, type, to) {
|
|
|
91529
91868
|
return JSON.stringify([from, type, to]);
|
|
91530
91869
|
}
|
|
91531
91870
|
function edgeParkPath(workspaceConfigDir, destinationKey) {
|
|
91532
|
-
return
|
|
91871
|
+
return join40(workspaceConfigDir, `edge-park.${destinationKey.slice(0, 16)}.json`);
|
|
91533
91872
|
}
|
|
91534
91873
|
function loadEdgePark(path3) {
|
|
91535
91874
|
let raw2;
|
|
91536
91875
|
try {
|
|
91537
|
-
raw2 = JSON.parse(
|
|
91876
|
+
raw2 = JSON.parse(readFileSync36(path3, "utf8"));
|
|
91538
91877
|
} catch {
|
|
91539
91878
|
return [];
|
|
91540
91879
|
}
|
|
@@ -91545,7 +91884,7 @@ function loadEdgePark(path3) {
|
|
|
91545
91884
|
}
|
|
91546
91885
|
function saveEdgePark(path3, queue) {
|
|
91547
91886
|
try {
|
|
91548
|
-
const tmp =
|
|
91887
|
+
const tmp = join40(dirname16(path3), `.${Date.now()}.edge-park.tmp`);
|
|
91549
91888
|
writeFileSync26(tmp, JSON.stringify(queue), "utf8");
|
|
91550
91889
|
renameSync6(tmp, path3);
|
|
91551
91890
|
} catch {
|
|
@@ -91868,8 +92207,8 @@ function invalidateInstanceReceipt(current, destination, failedId, mirrorLegacy)
|
|
|
91868
92207
|
// src/multi.ts
|
|
91869
92208
|
init_dist();
|
|
91870
92209
|
init_src5();
|
|
91871
|
-
import { existsSync as
|
|
91872
|
-
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";
|
|
91873
92212
|
|
|
91874
92213
|
// src/principle-sync.ts
|
|
91875
92214
|
init_src5();
|
|
@@ -91897,8 +92236,8 @@ init_reconcile();
|
|
|
91897
92236
|
|
|
91898
92237
|
// src/lockfile-auto.ts
|
|
91899
92238
|
init_src();
|
|
91900
|
-
import { existsSync as
|
|
91901
|
-
import { join as
|
|
92239
|
+
import { existsSync as existsSync32, readFileSync as readFileSync37 } from "node:fs";
|
|
92240
|
+
import { join as join41 } from "node:path";
|
|
91902
92241
|
|
|
91903
92242
|
// src/package-index.ts
|
|
91904
92243
|
init_src();
|
|
@@ -92071,11 +92410,11 @@ function runLockfilePass(opts) {
|
|
|
92071
92410
|
{ file: "package-lock.json", parse: parsePackageLockJson }
|
|
92072
92411
|
];
|
|
92073
92412
|
for (const c of candidates) {
|
|
92074
|
-
const p =
|
|
92075
|
-
if (!
|
|
92413
|
+
const p = join41(opts.root, c.file);
|
|
92414
|
+
if (!existsSync32(p)) continue;
|
|
92076
92415
|
let sbom;
|
|
92077
92416
|
try {
|
|
92078
|
-
sbom = c.parse(
|
|
92417
|
+
sbom = c.parse(readFileSync37(p, "utf8"));
|
|
92079
92418
|
} catch {
|
|
92080
92419
|
continue;
|
|
92081
92420
|
}
|
|
@@ -92095,7 +92434,7 @@ init_src10();
|
|
|
92095
92434
|
init_src();
|
|
92096
92435
|
|
|
92097
92436
|
// src/contribution-ready.ts
|
|
92098
|
-
|
|
92437
|
+
init_src4();
|
|
92099
92438
|
function cosine4(a, b) {
|
|
92100
92439
|
if (a.length === 0 || a.length !== b.length) return 0;
|
|
92101
92440
|
let dot = 0;
|
|
@@ -92109,7 +92448,9 @@ function cosine4(a, b) {
|
|
|
92109
92448
|
return na === 0 || nb === 0 ? 0 : dot / (Math.sqrt(na) * Math.sqrt(nb));
|
|
92110
92449
|
}
|
|
92111
92450
|
function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
92112
|
-
const
|
|
92451
|
+
const versionOf = (n) => String(n.attrs?.["embeddingVersion"] ?? "hash-v1");
|
|
92452
|
+
const version3 = versionOf(node2);
|
|
92453
|
+
const floor = opts.dedupCosine ?? cosineBandsFor(version3).dedup;
|
|
92113
92454
|
const emb = node2.embedding ?? [];
|
|
92114
92455
|
if (emb.length === 0) {
|
|
92115
92456
|
return { ready: true, surprise: 1, topCosine: 0, reason: "no-embedding (fidelity-first)" };
|
|
@@ -92118,7 +92459,7 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
|
92118
92459
|
for (const other of neighbors) {
|
|
92119
92460
|
if (other.id === node2.id) continue;
|
|
92120
92461
|
const oe = other.embedding ?? [];
|
|
92121
|
-
if (oe.length !== emb.length) continue;
|
|
92462
|
+
if (oe.length !== emb.length || versionOf(other) !== version3) continue;
|
|
92122
92463
|
const c = cosine4(emb, oe);
|
|
92123
92464
|
if (c > topCosine) topCosine = c;
|
|
92124
92465
|
}
|
|
@@ -92136,8 +92477,8 @@ init_profile2();
|
|
|
92136
92477
|
init_session_registry();
|
|
92137
92478
|
|
|
92138
92479
|
// src/public-symbols.ts
|
|
92139
|
-
import { readFileSync as
|
|
92140
|
-
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";
|
|
92141
92482
|
var HEAD_BYTES = 8 * 1024;
|
|
92142
92483
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
92143
92484
|
var MIN_SYMBOL_LEN = 4;
|
|
@@ -92170,20 +92511,20 @@ function bindingNames(clause) {
|
|
|
92170
92511
|
function internalPackageNames(workspaceRoot) {
|
|
92171
92512
|
const names = /* @__PURE__ */ new Set();
|
|
92172
92513
|
const tryRead = (dir) => {
|
|
92173
|
-
const pj =
|
|
92174
|
-
if (!
|
|
92514
|
+
const pj = join42(dir, "package.json");
|
|
92515
|
+
if (!existsSync33(pj)) return;
|
|
92175
92516
|
try {
|
|
92176
|
-
const name2 = JSON.parse(
|
|
92517
|
+
const name2 = JSON.parse(readFileSync38(pj, "utf8")).name;
|
|
92177
92518
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
92178
92519
|
} catch {
|
|
92179
92520
|
}
|
|
92180
92521
|
};
|
|
92181
92522
|
tryRead(workspaceRoot);
|
|
92182
92523
|
for (const group of ["packages", "apps"]) {
|
|
92183
|
-
const groupDir =
|
|
92184
|
-
if (!
|
|
92524
|
+
const groupDir = join42(workspaceRoot, group);
|
|
92525
|
+
if (!existsSync33(groupDir)) continue;
|
|
92185
92526
|
try {
|
|
92186
|
-
for (const entry of readdirSync12(groupDir)) tryRead(
|
|
92527
|
+
for (const entry of readdirSync12(groupDir)) tryRead(join42(groupDir, entry));
|
|
92187
92528
|
} catch {
|
|
92188
92529
|
}
|
|
92189
92530
|
}
|
|
@@ -92202,7 +92543,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92202
92543
|
}
|
|
92203
92544
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
92204
92545
|
try {
|
|
92205
|
-
return
|
|
92546
|
+
return readFileSync38(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
92206
92547
|
} catch {
|
|
92207
92548
|
return "";
|
|
92208
92549
|
}
|
|
@@ -92222,7 +92563,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
92222
92563
|
}
|
|
92223
92564
|
const symbols = /* @__PURE__ */ new Set();
|
|
92224
92565
|
for (const rel of files) {
|
|
92225
|
-
const head2 = readHead(
|
|
92566
|
+
const head2 = readHead(join42(workspaceRoot, rel));
|
|
92226
92567
|
if (!head2) continue;
|
|
92227
92568
|
for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
|
|
92228
92569
|
re.lastIndex = 0;
|
|
@@ -93253,7 +93594,7 @@ init_config();
|
|
|
93253
93594
|
|
|
93254
93595
|
// src/update.ts
|
|
93255
93596
|
import { spawn as spawn2 } from "node:child_process";
|
|
93256
|
-
import { isAbsolute as isAbsolute6, join as
|
|
93597
|
+
import { isAbsolute as isAbsolute6, join as join43 } from "node:path";
|
|
93257
93598
|
var PACKAGE_NAME = "@inerrata-corporation/errata";
|
|
93258
93599
|
function parse3(v) {
|
|
93259
93600
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z][0-9A-Za-z.-]*))?/.exec(v.trim());
|
|
@@ -93402,7 +93743,7 @@ async function runInstalledHookRefresh() {
|
|
|
93402
93743
|
let worst = 0;
|
|
93403
93744
|
for (const harness of ["codex", "claude"]) {
|
|
93404
93745
|
const code = await new Promise((resolve11) => {
|
|
93405
|
-
const child = spawn2(process.execPath, [
|
|
93746
|
+
const child = spawn2(process.execPath, [join43(root, PACKAGE_NAME, "errata.mjs"), "install-hooks", harness, "--refresh-existing"], {
|
|
93406
93747
|
windowsHide: true,
|
|
93407
93748
|
stdio: "inherit",
|
|
93408
93749
|
timeout: 3e4
|
|
@@ -93551,12 +93892,12 @@ function landCloudEdge(store, e, from, to) {
|
|
|
93551
93892
|
}
|
|
93552
93893
|
|
|
93553
93894
|
// src/causal-edge-queue.ts
|
|
93554
|
-
import { readFileSync as
|
|
93555
|
-
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";
|
|
93556
93897
|
var CAUSAL_EDGE_QUEUE_CAP = 5e3;
|
|
93557
93898
|
var CAUSAL_EDGE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
93558
93899
|
function causalEdgeQueuePath(workspaceConfigDir) {
|
|
93559
|
-
return
|
|
93900
|
+
return join44(workspaceConfigDir, "causal-edge-queue.json");
|
|
93560
93901
|
}
|
|
93561
93902
|
function parkedEdgeKey(e) {
|
|
93562
93903
|
return `${e.from}|${e.type}|${e.to}`;
|
|
@@ -93564,7 +93905,7 @@ function parkedEdgeKey(e) {
|
|
|
93564
93905
|
function loadCausalEdgeQueue(path3) {
|
|
93565
93906
|
let raw2;
|
|
93566
93907
|
try {
|
|
93567
|
-
raw2 = JSON.parse(
|
|
93908
|
+
raw2 = JSON.parse(readFileSync39(path3, "utf8"));
|
|
93568
93909
|
} catch {
|
|
93569
93910
|
return [];
|
|
93570
93911
|
}
|
|
@@ -93575,7 +93916,7 @@ function loadCausalEdgeQueue(path3) {
|
|
|
93575
93916
|
}
|
|
93576
93917
|
function saveCausalEdgeQueue(path3, queue) {
|
|
93577
93918
|
try {
|
|
93578
|
-
const tmp =
|
|
93919
|
+
const tmp = join44(dirname17(path3), `.${Date.now()}.causal-edge-queue.tmp`);
|
|
93579
93920
|
writeFileSync27(tmp, JSON.stringify(queue), "utf8");
|
|
93580
93921
|
renameSync7(tmp, path3);
|
|
93581
93922
|
} catch {
|
|
@@ -94007,9 +94348,9 @@ init_src11();
|
|
|
94007
94348
|
init_src();
|
|
94008
94349
|
import { execFile as execFile6 } from "node:child_process";
|
|
94009
94350
|
import { promisify as promisify4 } from "node:util";
|
|
94010
|
-
import { extname as extname3, join as
|
|
94351
|
+
import { extname as extname3, join as join45 } from "node:path";
|
|
94011
94352
|
import { createHash as createHash19 } from "node:crypto";
|
|
94012
|
-
import { readFileSync as
|
|
94353
|
+
import { readFileSync as readFileSync40 } from "node:fs";
|
|
94013
94354
|
|
|
94014
94355
|
// src/history-dependency-snapshot.ts
|
|
94015
94356
|
init_src();
|
|
@@ -94132,7 +94473,7 @@ var Bounded = class extends Map {
|
|
|
94132
94473
|
var DEFAULT_GIT = {};
|
|
94133
94474
|
function readFileSafe(path3) {
|
|
94134
94475
|
try {
|
|
94135
|
-
return
|
|
94476
|
+
return readFileSync40(path3, "utf8");
|
|
94136
94477
|
} catch {
|
|
94137
94478
|
return "";
|
|
94138
94479
|
}
|
|
@@ -94186,7 +94527,7 @@ async function syncHistoryRevisionPage(opts, resolve11) {
|
|
|
94186
94527
|
const projectId = profile.projectId;
|
|
94187
94528
|
const git3 = opts.git ?? (async (args2) => (await exec2("git", ["-C", root, ...args2], { windowsHide: true, maxBuffer: 8 * 1024 * 1024 })).stdout);
|
|
94188
94529
|
const caches = cachesFor(opts.git ?? DEFAULT_GIT);
|
|
94189
|
-
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);
|
|
94190
94531
|
const atCommit = (await git3(["rev-parse", "--verify", "HEAD"])).trim();
|
|
94191
94532
|
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(atCommit)) throw new Error("history revision is not a full Git object id");
|
|
94192
94533
|
const oldCursor = profile.historyRevisionCursor;
|
|
@@ -94506,8 +94847,8 @@ ${await git3(["rev-list", "--parents", "-1", from])}`.split("\n").map((row) => r
|
|
|
94506
94847
|
init_src7();
|
|
94507
94848
|
init_src();
|
|
94508
94849
|
import { execFile as execFile7 } from "node:child_process";
|
|
94509
|
-
import { readFileSync as
|
|
94510
|
-
import { join as
|
|
94850
|
+
import { readFileSync as readFileSync41 } from "node:fs";
|
|
94851
|
+
import { join as join46 } from "node:path";
|
|
94511
94852
|
import { promisify as promisify5 } from "node:util";
|
|
94512
94853
|
|
|
94513
94854
|
// src/history-walk.ts
|
|
@@ -95066,7 +95407,7 @@ async function defaultGit(root, args2) {
|
|
|
95066
95407
|
function readIgnoreLines(root, profile) {
|
|
95067
95408
|
let lines = [];
|
|
95068
95409
|
try {
|
|
95069
|
-
lines =
|
|
95410
|
+
lines = readFileSync41(join46(root, ".errataignore"), "utf8").split("\n");
|
|
95070
95411
|
} catch {
|
|
95071
95412
|
}
|
|
95072
95413
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -95646,8 +95987,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
95646
95987
|
init_cloud_auth();
|
|
95647
95988
|
import { createHash as createHash20 } from "node:crypto";
|
|
95648
95989
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
95649
|
-
import { existsSync as
|
|
95650
|
-
import { join as
|
|
95990
|
+
import { existsSync as existsSync34, writeFileSync as writeFileSync28 } from "node:fs";
|
|
95991
|
+
import { join as join47 } from "node:path";
|
|
95651
95992
|
|
|
95652
95993
|
// src/device-poll.ts
|
|
95653
95994
|
var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
|
|
@@ -96106,8 +96447,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
|
|
|
96106
96447
|
delete nextProfile.projectLinkHold;
|
|
96107
96448
|
let wroteIgnore = false;
|
|
96108
96449
|
if (decision.writeIgnoreStarter !== false) {
|
|
96109
|
-
const target =
|
|
96110
|
-
if (!
|
|
96450
|
+
const target = join47(root, ".errataignore");
|
|
96451
|
+
if (!existsSync34(target)) {
|
|
96111
96452
|
writeFileSync28(target, IGNORE_STARTER, "utf8");
|
|
96112
96453
|
wroteIgnore = true;
|
|
96113
96454
|
}
|
|
@@ -96121,13 +96462,13 @@ init_registry();
|
|
|
96121
96462
|
|
|
96122
96463
|
// src/adopt.ts
|
|
96123
96464
|
init_git_remote();
|
|
96124
|
-
import { existsSync as
|
|
96125
|
-
import { dirname as
|
|
96465
|
+
import { existsSync as existsSync35 } from "node:fs";
|
|
96466
|
+
import { dirname as dirname18, join as join48 } from "node:path";
|
|
96126
96467
|
function findGitRoot(absPath) {
|
|
96127
96468
|
let dir = absPath;
|
|
96128
96469
|
for (let depth = 0; depth < 64; depth++) {
|
|
96129
|
-
if (
|
|
96130
|
-
const parent =
|
|
96470
|
+
if (existsSync35(join48(dir, ".git"))) return dir;
|
|
96471
|
+
const parent = dirname18(dir);
|
|
96131
96472
|
if (parent === dir) return null;
|
|
96132
96473
|
dir = parent;
|
|
96133
96474
|
}
|
|
@@ -96769,7 +97110,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96769
97110
|
};
|
|
96770
97111
|
const sharedDbPath = sharedStorePath();
|
|
96771
97112
|
ensureParent(sharedDbPath);
|
|
96772
|
-
if (sharedDbPath !== ":memory:") excludeFromIndexing(
|
|
97113
|
+
if (sharedDbPath !== ":memory:") excludeFromIndexing(dirname19(sharedDbPath));
|
|
96773
97114
|
await prepareStore(sharedDbPath, process.cwd(), "shared");
|
|
96774
97115
|
const sharedStore = openGraphStore({ path: sharedDbPath });
|
|
96775
97116
|
const bundledRun = import.meta.url.endsWith(".mjs");
|
|
@@ -96913,7 +97254,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96913
97254
|
held.push(...quarantined);
|
|
96914
97255
|
let ignoreFile = "";
|
|
96915
97256
|
try {
|
|
96916
|
-
ignoreFile =
|
|
97257
|
+
ignoreFile = readFileSync42(join49(r.root, ".errataignore"), "utf8");
|
|
96917
97258
|
} catch {
|
|
96918
97259
|
}
|
|
96919
97260
|
const retryInputs = JSON.stringify([
|
|
@@ -96981,7 +97322,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
96981
97322
|
const id = entry.id;
|
|
96982
97323
|
const castaliaPath = workspacePaths(entry.path).castalia;
|
|
96983
97324
|
ensureParent(castaliaPath);
|
|
96984
|
-
excludeFromIndexing(
|
|
97325
|
+
excludeFromIndexing(dirname19(castaliaPath));
|
|
96985
97326
|
await prepareStore(castaliaPath, entry.path, id);
|
|
96986
97327
|
if (stopping) throw new Error("daemon stopping");
|
|
96987
97328
|
const wsIdentity = identityFor(entry);
|
|
@@ -97006,6 +97347,9 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97006
97347
|
const engine = createWorkspaceEngine({
|
|
97007
97348
|
workspaceRoot: entry.path,
|
|
97008
97349
|
cloud: wsCloud,
|
|
97350
|
+
// The worker's warm lexicon for searches the engine runs itself (task
|
|
97351
|
+
// priors); without it each would build the symbol lexicon inline.
|
|
97352
|
+
...generalizeWorker ? { generalizeSoft: (text) => generalizeWorker.generalize(workspacePaths(entry.path).castalia, text).catch(() => void 0) } : {},
|
|
97009
97353
|
apiKey: opts.apiKey,
|
|
97010
97354
|
reviewUrl: () => `${baseUrl}/ws/${id}/review`,
|
|
97011
97355
|
sharedStore,
|
|
@@ -97031,6 +97375,9 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97031
97375
|
// CAP-session-scope: per-session blocks + harness/fixture quarantine.
|
|
97032
97376
|
noteSession: engine.webHooks.noteSession,
|
|
97033
97377
|
sessionContext: engine.webHooks.sessionContext,
|
|
97378
|
+
// Task priors: the task, searched in the background; delivered on the next tool hook.
|
|
97379
|
+
onTaskPrompt: engine.webHooks.onTaskPrompt,
|
|
97380
|
+
takeTaskPriors: engine.webHooks.takeTaskPriors,
|
|
97034
97381
|
onHook: engine.webHooks.onHook,
|
|
97035
97382
|
onHookEvent: engine.webHooks.onHookEvent,
|
|
97036
97383
|
onShellEvent: engine.webHooks.onShellEvent,
|
|
@@ -97488,10 +97835,10 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97488
97835
|
};
|
|
97489
97836
|
const MISFILED_SWEEP_DELAY_MS = 2 * 6e4;
|
|
97490
97837
|
const sweepMisfiled = async (rec) => {
|
|
97491
|
-
const checkedPath =
|
|
97838
|
+
const checkedPath = join49(workspacePaths(rec.root).configDir, "rehome-checked.json");
|
|
97492
97839
|
let checked;
|
|
97493
97840
|
try {
|
|
97494
|
-
checked = new Set(JSON.parse(
|
|
97841
|
+
checked = new Set(JSON.parse(readFileSync42(checkedPath, "utf8")));
|
|
97495
97842
|
} catch {
|
|
97496
97843
|
checked = /* @__PURE__ */ new Set();
|
|
97497
97844
|
}
|
|
@@ -97610,7 +97957,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
97610
97957
|
lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
|
|
97611
97958
|
} catch {
|
|
97612
97959
|
}
|
|
97613
|
-
const reason = retireDecision({ exists:
|
|
97960
|
+
const reason = retireDecision({ exists: existsSync36(rec.root), lastActiveAt, now });
|
|
97614
97961
|
if (reason) void retireWorkspace(rec, reason);
|
|
97615
97962
|
}
|
|
97616
97963
|
};
|
|
@@ -98863,6 +99210,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
98863
99210
|
|
|
98864
99211
|
// src/cli.ts
|
|
98865
99212
|
init_src5();
|
|
99213
|
+
init_src4();
|
|
98866
99214
|
init_profile2();
|
|
98867
99215
|
init_git_remote();
|
|
98868
99216
|
init_config();
|
|
@@ -99238,7 +99586,7 @@ import { spawnSync as spawnSync2 } from "node:child_process";
|
|
|
99238
99586
|
|
|
99239
99587
|
// src/codex-runtime.ts
|
|
99240
99588
|
import { readdirSync as readdirSync13, statSync as statSync13 } from "node:fs";
|
|
99241
|
-
import { join as
|
|
99589
|
+
import { join as join50 } from "node:path";
|
|
99242
99590
|
function resolveCodexExecutable(options = {}) {
|
|
99243
99591
|
const platform = options.platform ?? process.platform;
|
|
99244
99592
|
const env2 = options.env ?? process.env;
|
|
@@ -99253,13 +99601,13 @@ function resolveCodexExecutable(options = {}) {
|
|
|
99253
99601
|
};
|
|
99254
99602
|
for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
|
|
99255
99603
|
if (!dir.trim()) continue;
|
|
99256
|
-
const path3 =
|
|
99604
|
+
const path3 = join50(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
|
|
99257
99605
|
if (fileTime(path3) !== null) return path3;
|
|
99258
99606
|
}
|
|
99259
99607
|
if (!env2["LOCALAPPDATA"]) return "codex";
|
|
99260
|
-
const root =
|
|
99608
|
+
const root = join50(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
|
|
99261
99609
|
try {
|
|
99262
|
-
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));
|
|
99263
99611
|
return candidates[0]?.path ?? "codex";
|
|
99264
99612
|
} catch {
|
|
99265
99613
|
return "codex";
|
|
@@ -99398,14 +99746,14 @@ async function diagnoseInstallation(cfg, dependencies) {
|
|
|
99398
99746
|
}
|
|
99399
99747
|
|
|
99400
99748
|
// src/credential-scan.ts
|
|
99401
|
-
import { readFileSync as
|
|
99749
|
+
import { readFileSync as readFileSync44, statSync as statSync14 } from "node:fs";
|
|
99402
99750
|
import { homedir as homedir8 } from "node:os";
|
|
99403
|
-
import { join as
|
|
99751
|
+
import { join as join52 } from "node:path";
|
|
99404
99752
|
|
|
99405
99753
|
// src/claude-statusline.ts
|
|
99406
|
-
import { existsSync as
|
|
99754
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync9, readFileSync as readFileSync43, writeFileSync as writeFileSync30 } from "node:fs";
|
|
99407
99755
|
import { homedir as homedir7 } from "node:os";
|
|
99408
|
-
import { dirname as
|
|
99756
|
+
import { dirname as dirname20, join as join51 } from "node:path";
|
|
99409
99757
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
99410
99758
|
import { readFileSync } from 'node:fs';
|
|
99411
99759
|
|
|
@@ -99453,8 +99801,8 @@ function isSameInstall(value, relay) {
|
|
|
99453
99801
|
return command.includes(relay.replace(/\\/g, "/").toLowerCase());
|
|
99454
99802
|
}
|
|
99455
99803
|
function userClaudeSettingsPath() {
|
|
99456
|
-
const base = process.env["CLAUDE_CONFIG_DIR"] ??
|
|
99457
|
-
return
|
|
99804
|
+
const base = process.env["CLAUDE_CONFIG_DIR"] ?? join51(homedir7(), ".claude");
|
|
99805
|
+
return join51(base, "settings.json");
|
|
99458
99806
|
}
|
|
99459
99807
|
function ensureUserStatusLine(opts) {
|
|
99460
99808
|
const env2 = opts.env ?? process.env;
|
|
@@ -99462,22 +99810,22 @@ function ensureUserStatusLine(opts) {
|
|
|
99462
99810
|
if (off2 === "0" || off2 === "off" || off2 === "false" || off2 === "no") return "disabled";
|
|
99463
99811
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
99464
99812
|
let settings = {};
|
|
99465
|
-
if (
|
|
99813
|
+
if (existsSync37(settingsPath)) {
|
|
99466
99814
|
try {
|
|
99467
|
-
const parsed = JSON.parse(
|
|
99815
|
+
const parsed = JSON.parse(readFileSync43(settingsPath, "utf8"));
|
|
99468
99816
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
99469
99817
|
settings = parsed;
|
|
99470
99818
|
} catch {
|
|
99471
99819
|
return "unreadable";
|
|
99472
99820
|
}
|
|
99473
99821
|
}
|
|
99474
|
-
const relay =
|
|
99822
|
+
const relay = join51(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
99475
99823
|
const keep = (value) => value !== void 0 && (!isErrataStatusLine(value) || !isSameInstall(value, relay));
|
|
99476
99824
|
const ownMain = keep(settings["statusLine"]);
|
|
99477
99825
|
const ownRows = keep(settings["subagentStatusLine"]);
|
|
99478
99826
|
if (ownMain && ownRows) return "kept-own";
|
|
99479
99827
|
mkdirSync9(opts.relayDir, { recursive: true });
|
|
99480
|
-
if (!
|
|
99828
|
+
if (!existsSync37(relay) || readFileSync43(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
99481
99829
|
writeFileSync30(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
99482
99830
|
}
|
|
99483
99831
|
const nodePath = opts.nodePath ?? process.execPath;
|
|
@@ -99489,7 +99837,7 @@ function ensureUserStatusLine(opts) {
|
|
|
99489
99837
|
return ownMain ? "kept-own" : "unchanged";
|
|
99490
99838
|
}
|
|
99491
99839
|
Object.assign(settings, next);
|
|
99492
|
-
mkdirSync9(
|
|
99840
|
+
mkdirSync9(dirname20(settingsPath), { recursive: true });
|
|
99493
99841
|
writeFileSync30(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
99494
99842
|
return "installed";
|
|
99495
99843
|
}
|
|
@@ -99531,36 +99879,36 @@ function findCredentialLines(text) {
|
|
|
99531
99879
|
function harnessConfigPaths(root) {
|
|
99532
99880
|
const env2 = process.env;
|
|
99533
99881
|
const home = homedir8();
|
|
99534
|
-
const codexHome = env2["CODEX_HOME"] ||
|
|
99535
|
-
const geminiHome =
|
|
99882
|
+
const codexHome = env2["CODEX_HOME"] || join52(home, ".codex");
|
|
99883
|
+
const geminiHome = join52(env2["GEMINI_CLI_HOME"] ?? home, ".gemini");
|
|
99536
99884
|
return [
|
|
99537
99885
|
// Claude Code: user settings, `claude mcp add` (local/user scope), project.
|
|
99538
99886
|
userClaudeSettingsPath(),
|
|
99539
|
-
|
|
99540
|
-
|
|
99541
|
-
|
|
99542
|
-
|
|
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"),
|
|
99543
99891
|
// Codex
|
|
99544
|
-
|
|
99545
|
-
|
|
99892
|
+
join52(codexHome, "config.toml"),
|
|
99893
|
+
join52(root, ".codex", "config.toml"),
|
|
99546
99894
|
// Gemini CLI
|
|
99547
|
-
|
|
99548
|
-
|
|
99895
|
+
join52(geminiHome, "settings.json"),
|
|
99896
|
+
join52(root, ".gemini", "settings.json"),
|
|
99549
99897
|
// Cursor
|
|
99550
|
-
|
|
99551
|
-
|
|
99898
|
+
join52(home, ".cursor", "mcp.json"),
|
|
99899
|
+
join52(root, ".cursor", "mcp.json"),
|
|
99552
99900
|
// VS Code (user profile mcp.json + workspace)
|
|
99553
|
-
|
|
99554
|
-
|
|
99901
|
+
join52(vscodeUserDir(home, env2), "mcp.json"),
|
|
99902
|
+
join52(root, ".vscode", "mcp.json"),
|
|
99555
99903
|
// OpenCode (XDG on every platform; the daemon's installer writes the project one)
|
|
99556
|
-
|
|
99557
|
-
|
|
99904
|
+
join52(env2["XDG_CONFIG_HOME"] ?? join52(home, ".config"), "opencode", "opencode.json"),
|
|
99905
|
+
join52(root, "opencode.json")
|
|
99558
99906
|
];
|
|
99559
99907
|
}
|
|
99560
99908
|
function vscodeUserDir(home, env2) {
|
|
99561
|
-
if (process.platform === "win32") return
|
|
99562
|
-
if (process.platform === "darwin") return
|
|
99563
|
-
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");
|
|
99564
99912
|
}
|
|
99565
99913
|
function scanHarnessConfigs(paths, read2 = readBounded) {
|
|
99566
99914
|
const findings = [];
|
|
@@ -99577,7 +99925,7 @@ function readBounded(path3) {
|
|
|
99577
99925
|
try {
|
|
99578
99926
|
const stat4 = statSync14(path3);
|
|
99579
99927
|
if (!stat4.isFile() || stat4.size > MAX_SCAN_BYTES) return null;
|
|
99580
|
-
return
|
|
99928
|
+
return readFileSync44(path3, "utf8");
|
|
99581
99929
|
} catch {
|
|
99582
99930
|
return null;
|
|
99583
99931
|
}
|
|
@@ -99602,14 +99950,14 @@ function credentialHygieneCheck(scan2) {
|
|
|
99602
99950
|
|
|
99603
99951
|
// src/codex-doctor.ts
|
|
99604
99952
|
import { spawn as spawn4 } from "node:child_process";
|
|
99605
|
-
import { readFileSync as
|
|
99606
|
-
import { join as
|
|
99953
|
+
import { readFileSync as readFileSync46, statSync as statSync15 } from "node:fs";
|
|
99954
|
+
import { join as join54 } from "node:path";
|
|
99607
99955
|
import { createInterface } from "node:readline";
|
|
99608
99956
|
|
|
99609
99957
|
// src/codex-hooks.ts
|
|
99610
|
-
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";
|
|
99611
99959
|
import { homedir as homedir9 } from "node:os";
|
|
99612
|
-
import { join as
|
|
99960
|
+
import { join as join53 } from "node:path";
|
|
99613
99961
|
|
|
99614
99962
|
// src/hook-commands.ts
|
|
99615
99963
|
function hookCurlCommand(port, path3 = "/api/hook") {
|
|
@@ -99865,34 +100213,34 @@ function buildCodexRelaySource(workspaceRoot) {
|
|
|
99865
100213
|
init_checkout_root();
|
|
99866
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.";
|
|
99867
100215
|
function writeRelay(file2, source) {
|
|
99868
|
-
if (
|
|
100216
|
+
if (existsSync38(file2) && readFileSync45(file2, "utf8") === source) return;
|
|
99869
100217
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
99870
100218
|
try {
|
|
99871
100219
|
writeFileSync31(temp, source, { encoding: "utf8", mode: 384 });
|
|
99872
100220
|
renameSync8(temp, file2);
|
|
99873
100221
|
} finally {
|
|
99874
|
-
if (
|
|
100222
|
+
if (existsSync38(temp)) unlinkSync5(temp);
|
|
99875
100223
|
}
|
|
99876
100224
|
}
|
|
99877
100225
|
function refreshCodexRelay(root) {
|
|
99878
|
-
const config2 =
|
|
99879
|
-
if (!
|
|
99880
|
-
const existing =
|
|
100226
|
+
const config2 = join53(root, ".codex", "config.toml");
|
|
100227
|
+
if (!existsSync38(config2)) return "absent";
|
|
100228
|
+
const existing = readFileSync45(config2, "utf8");
|
|
99881
100229
|
if (!existing.includes(CODEX_HOOKS_BEGIN) && !existing.includes(CODEX_HOOKS_END)) return "absent";
|
|
99882
100230
|
replaceCodexHooks(existing, "");
|
|
99883
|
-
const relay =
|
|
99884
|
-
const prior =
|
|
100231
|
+
const relay = join53(root, ".codex", "hooks", "errata-relay.mjs");
|
|
100232
|
+
const prior = existsSync38(relay) ? readFileSync45(relay, "utf8") : "";
|
|
99885
100233
|
if (prior && !prior.startsWith("// errata-managed: regenerated by errata install-hooks codex")) {
|
|
99886
100234
|
throw new Error("Codex relay is not Errata-managed; preserved it. Run errata install-hooks codex to explicitly replace it.");
|
|
99887
100235
|
}
|
|
99888
100236
|
const source = buildCodexRelaySource(checkoutRootOf(root));
|
|
99889
100237
|
if (prior === source) return "current";
|
|
99890
|
-
mkdirSync10(
|
|
100238
|
+
mkdirSync10(join53(root, ".codex", "hooks"), { recursive: true });
|
|
99891
100239
|
writeRelay(relay, source);
|
|
99892
100240
|
return "updated";
|
|
99893
100241
|
}
|
|
99894
|
-
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] ||
|
|
99895
|
-
return
|
|
100242
|
+
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join53(homedir9(), ".codex")) {
|
|
100243
|
+
return existsSync38(join53(root, ".codex")) || existsSync38(codexHome);
|
|
99896
100244
|
}
|
|
99897
100245
|
function replaceCodexHooks(existing, block) {
|
|
99898
100246
|
const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
|
|
@@ -99908,14 +100256,14 @@ function replaceCodexHooks(existing, block) {
|
|
|
99908
100256
|
return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
|
|
99909
100257
|
}
|
|
99910
100258
|
function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
99911
|
-
const dir =
|
|
99912
|
-
const file2 =
|
|
99913
|
-
const relay =
|
|
100259
|
+
const dir = join53(root, ".codex");
|
|
100260
|
+
const file2 = join53(dir, "config.toml");
|
|
100261
|
+
const relay = join53(dir, "hooks", "errata-relay.mjs");
|
|
99914
100262
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
99915
|
-
const final = replaceCodexHooks(
|
|
99916
|
-
mkdirSync10(
|
|
100263
|
+
const final = replaceCodexHooks(existsSync38(file2) ? readFileSync45(file2, "utf8") : "", block);
|
|
100264
|
+
mkdirSync10(join53(dir, "hooks"), { recursive: true });
|
|
99917
100265
|
writeRelay(relay, buildCodexRelaySource(checkoutRootOf(root)));
|
|
99918
|
-
if (!
|
|
100266
|
+
if (!existsSync38(file2) || readFileSync45(file2, "utf8") !== final) writeFileSync31(file2, final, "utf8");
|
|
99919
100267
|
return file2;
|
|
99920
100268
|
}
|
|
99921
100269
|
|
|
@@ -99924,7 +100272,7 @@ init_checkout_root();
|
|
|
99924
100272
|
function inspectCodexRelay(cwd) {
|
|
99925
100273
|
const root = nearestGitRoot(cwd) ?? cwd;
|
|
99926
100274
|
try {
|
|
99927
|
-
const source =
|
|
100275
|
+
const source = readFileSync46(join54(root, ".codex", "hooks", "errata-relay.mjs"), "utf8");
|
|
99928
100276
|
if (source === buildCodexRelaySource(checkoutRootOf(root))) {
|
|
99929
100277
|
return { id: "codex_relay", status: "pass", detail: "Installed Codex relay matches this Errata version" };
|
|
99930
100278
|
}
|
|
@@ -99935,8 +100283,8 @@ function inspectCodexRelay(cwd) {
|
|
|
99935
100283
|
function inspectCodexContext(cwd) {
|
|
99936
100284
|
const root = checkoutRootOf(nearestGitRoot(cwd) ?? cwd);
|
|
99937
100285
|
try {
|
|
99938
|
-
const file2 =
|
|
99939
|
-
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()) {
|
|
99940
100288
|
return { id: "codex_context", status: "pass", detail: "Saved workspace context is readable by the relay; this does not prove live daemon freshness" };
|
|
99941
100289
|
}
|
|
99942
100290
|
} catch {
|
|
@@ -100114,10 +100462,10 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
100114
100462
|
|
|
100115
100463
|
// src/codex-context-plugin.ts
|
|
100116
100464
|
import { createHash as createHash21 } from "node:crypto";
|
|
100117
|
-
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";
|
|
100118
100466
|
import { homedir as homedir10 } from "node:os";
|
|
100119
|
-
import { join as
|
|
100120
|
-
import { fileURLToPath as
|
|
100467
|
+
import { join as join55 } from "node:path";
|
|
100468
|
+
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
100121
100469
|
|
|
100122
100470
|
// ../../node_modules/.pnpm/smol-toml@1.6.1/node_modules/smol-toml/dist/error.js
|
|
100123
100471
|
function getLineColFromPtr(string4, ptr) {
|
|
@@ -100814,7 +101162,7 @@ var NAME = "errata-context";
|
|
|
100814
101162
|
var PREFIX2 = `./.errata/plugins/${NAME}/`;
|
|
100815
101163
|
var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
100816
101164
|
function readText(file2) {
|
|
100817
|
-
return
|
|
101165
|
+
return existsSync39(file2) ? readFileSync47(file2, "utf8") : "";
|
|
100818
101166
|
}
|
|
100819
101167
|
function writeChanged(file2, content) {
|
|
100820
101168
|
if (readText(file2) === content) return;
|
|
@@ -100823,14 +101171,14 @@ function writeChanged(file2, content) {
|
|
|
100823
101171
|
renameSync9(temp, file2);
|
|
100824
101172
|
}
|
|
100825
101173
|
function bundledContextPlugin() {
|
|
100826
|
-
const packaged =
|
|
100827
|
-
if (
|
|
100828
|
-
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));
|
|
100829
101177
|
}
|
|
100830
101178
|
function refreshCodexContextPlugin(root) {
|
|
100831
|
-
const file2 =
|
|
100832
|
-
if (!
|
|
100833
|
-
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"));
|
|
100834
101182
|
const entries = Array.isArray(marketplace.plugins) ? marketplace.plugins : [];
|
|
100835
101183
|
const entry = entries.map(object2).find((value) => value.name === NAME && String(object2(value.source).path).startsWith(PREFIX2));
|
|
100836
101184
|
if (!entry) return false;
|
|
@@ -100841,24 +101189,24 @@ function refreshCodexContextPlugin(root) {
|
|
|
100841
101189
|
function installCodexContextPlugin(root, options = {}) {
|
|
100842
101190
|
const bundle = options.bundle ?? bundledContextPlugin();
|
|
100843
101191
|
const manifest = JSON.parse(
|
|
100844
|
-
|
|
101192
|
+
readFileSync47(join55(bundle, ".codex-plugin/plugin.json"), "utf8")
|
|
100845
101193
|
);
|
|
100846
101194
|
if (manifest.name !== NAME || typeof manifest.version !== "string" || !/^[\w.-]+$/.test(manifest.version)) {
|
|
100847
101195
|
throw new Error("Invalid bundled Errata Context manifest.");
|
|
100848
101196
|
}
|
|
100849
|
-
const checksums =
|
|
101197
|
+
const checksums = readFileSync47(join55(bundle, "SHA256SUMS"), "utf8");
|
|
100850
101198
|
for (const line of checksums.trim().split("\n")) {
|
|
100851
101199
|
const match2 = /^([a-f0-9]{64}) ([\w./-]+)$/.exec(line);
|
|
100852
101200
|
if (!match2 || match2[2].startsWith("/") || match2[2].split("/").includes("..")) {
|
|
100853
101201
|
throw new Error("Invalid bundled Errata Context checksum manifest.");
|
|
100854
101202
|
}
|
|
100855
|
-
const actual = createHash21("sha256").update(
|
|
101203
|
+
const actual = createHash21("sha256").update(readFileSync47(join55(bundle, match2[2]))).digest("hex");
|
|
100856
101204
|
if (actual !== match2[1])
|
|
100857
101205
|
throw new Error(`Bundled Errata Context checksum mismatch: ${match2[2]}`);
|
|
100858
101206
|
}
|
|
100859
101207
|
const release = `${manifest.version}-${createHash21("sha256").update(checksums).digest("hex").slice(0, 12)}`;
|
|
100860
|
-
const plugin =
|
|
100861
|
-
const marketplaceFile =
|
|
101208
|
+
const plugin = join55(root, ".errata", "plugins", NAME, release);
|
|
101209
|
+
const marketplaceFile = join55(root, ".agents", "plugins", "marketplace.json");
|
|
100862
101210
|
const priorMarketplace = readText(marketplaceFile);
|
|
100863
101211
|
const marketplace = priorMarketplace ? JSON.parse(priorMarketplace) : {
|
|
100864
101212
|
name: "errata-local",
|
|
@@ -100879,12 +101227,12 @@ function installCodexContextPlugin(root, options = {}) {
|
|
|
100879
101227
|
);
|
|
100880
101228
|
}
|
|
100881
101229
|
const key = `${NAME}@${marketplace.name}`;
|
|
100882
|
-
const configFile =
|
|
101230
|
+
const configFile = join55(root, ".codex", "config.toml");
|
|
100883
101231
|
const config2 = readText(configFile);
|
|
100884
101232
|
const parsed = parse4(config2);
|
|
100885
101233
|
const plugins = object2(parsed.plugins);
|
|
100886
|
-
const codexHome = options.codexHome ?? process.env["CODEX_HOME"] ??
|
|
100887
|
-
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);
|
|
100888
101236
|
const disabledGlobally = Object.entries(globalPlugins).some(
|
|
100889
101237
|
([name2, value]) => (name2 === NAME || name2.startsWith(`${NAME}@`)) && object2(value).enabled === false
|
|
100890
101238
|
);
|
|
@@ -100908,13 +101256,13 @@ enabled = ${enabled}
|
|
|
100908
101256
|
mkdirSync11(plugin, { recursive: true });
|
|
100909
101257
|
cpSync2(bundle, plugin, { recursive: true });
|
|
100910
101258
|
writeChanged(
|
|
100911
|
-
|
|
101259
|
+
join55(plugin, ".mcp.json"),
|
|
100912
101260
|
JSON.stringify(
|
|
100913
101261
|
{
|
|
100914
101262
|
mcpServers: {
|
|
100915
101263
|
errata_context: {
|
|
100916
101264
|
command: options.nodePath ?? process.execPath,
|
|
100917
|
-
args: [
|
|
101265
|
+
args: [join55(plugin, "dist", "mcp-server.mjs")],
|
|
100918
101266
|
env: { ERRATA_WORKSPACE: root, ERRATA_CONTEXT_VERSION: manifest.version }
|
|
100919
101267
|
}
|
|
100920
101268
|
}
|
|
@@ -100923,8 +101271,8 @@ enabled = ${enabled}
|
|
|
100923
101271
|
2
|
|
100924
101272
|
) + "\n"
|
|
100925
101273
|
);
|
|
100926
|
-
mkdirSync11(
|
|
100927
|
-
mkdirSync11(
|
|
101274
|
+
mkdirSync11(join55(root, ".agents", "plugins"), { recursive: true });
|
|
101275
|
+
mkdirSync11(join55(root, ".codex"), { recursive: true });
|
|
100928
101276
|
writeChanged(marketplaceFile, JSON.stringify(marketplace, null, 2) + "\n");
|
|
100929
101277
|
writeChanged(configFile, nextConfig);
|
|
100930
101278
|
return { plugin, enabled, marketplace: marketplaceFile };
|
|
@@ -100932,16 +101280,16 @@ enabled = ${enabled}
|
|
|
100932
101280
|
|
|
100933
101281
|
// src/codex-hook-refresh.ts
|
|
100934
101282
|
init_checkout_root();
|
|
100935
|
-
import { existsSync as
|
|
100936
|
-
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";
|
|
100937
101285
|
init_registry();
|
|
100938
101286
|
function codexHookRoots(roots) {
|
|
100939
101287
|
const found = new Set(roots.map((root) => resolve9(root)));
|
|
100940
101288
|
for (const root of [...found]) {
|
|
100941
101289
|
const main2 = mainCheckoutOfWorktree(root) ?? root;
|
|
100942
101290
|
found.add(main2);
|
|
100943
|
-
const dir =
|
|
100944
|
-
if (!
|
|
101291
|
+
const dir = join56(main2, ".git", "worktrees");
|
|
101292
|
+
if (!existsSync40(dir)) continue;
|
|
100945
101293
|
let names;
|
|
100946
101294
|
try {
|
|
100947
101295
|
names = readdirSync14(dir);
|
|
@@ -100950,7 +101298,7 @@ function codexHookRoots(roots) {
|
|
|
100950
101298
|
}
|
|
100951
101299
|
for (const name2 of names) {
|
|
100952
101300
|
try {
|
|
100953
|
-
const checkout =
|
|
101301
|
+
const checkout = dirname21(readFileSync48(join56(dir, name2, "gitdir"), "utf8").trim());
|
|
100954
101302
|
if (mainCheckoutOfWorktree(checkout) === main2) found.add(checkout);
|
|
100955
101303
|
} catch {
|
|
100956
101304
|
}
|
|
@@ -100973,14 +101321,14 @@ function refreshInstalledCodexRelays(roots = listWorkspaceEntries().map((entry)
|
|
|
100973
101321
|
|
|
100974
101322
|
// src/claude-mods.ts
|
|
100975
101323
|
import { createHash as createHash22 } from "node:crypto";
|
|
100976
|
-
import { cpSync as cpSync3, existsSync as
|
|
100977
|
-
import { delimiter as delimiter2, dirname as
|
|
100978
|
-
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";
|
|
100979
101327
|
var CLAUDE_PLUGIN_DIRS_ENV = "CLAUDE_CODE_PLUGIN_DIRS";
|
|
100980
101328
|
var HASH_FILE = ".errata-mod-hash";
|
|
100981
101329
|
function bundledClaudeModsDir() {
|
|
100982
101330
|
const rel = import.meta.url.endsWith(".mjs") ? "./resources/claude-mods/" : "../claude-mods/";
|
|
100983
|
-
return
|
|
101331
|
+
return fileURLToPath5(new URL(rel, import.meta.url));
|
|
100984
101332
|
}
|
|
100985
101333
|
function isEngineOwned(relPath) {
|
|
100986
101334
|
const p = relPath.split(sep6).join("/");
|
|
@@ -100989,7 +101337,7 @@ function isEngineOwned(relPath) {
|
|
|
100989
101337
|
function listFiles(root, dir = root) {
|
|
100990
101338
|
const out2 = [];
|
|
100991
101339
|
for (const name2 of readdirSync15(dir)) {
|
|
100992
|
-
const abs =
|
|
101340
|
+
const abs = join57(dir, name2);
|
|
100993
101341
|
if (isEngineOwned(relative7(root, abs))) continue;
|
|
100994
101342
|
if (statSync16(abs).isDirectory()) out2.push(...listFiles(root, abs));
|
|
100995
101343
|
else out2.push(abs);
|
|
@@ -101001,14 +101349,14 @@ function modHash(dir) {
|
|
|
101001
101349
|
for (const abs of listFiles(dir).sort()) {
|
|
101002
101350
|
h.update(relative7(dir, abs).split(sep6).join("/"));
|
|
101003
101351
|
h.update("\0");
|
|
101004
|
-
h.update(
|
|
101352
|
+
h.update(readFileSync49(abs));
|
|
101005
101353
|
h.update("\0");
|
|
101006
101354
|
}
|
|
101007
101355
|
return h.digest("hex");
|
|
101008
101356
|
}
|
|
101009
101357
|
function bundledMods(bundleDir) {
|
|
101010
|
-
if (!
|
|
101011
|
-
return readdirSync15(bundleDir).filter((name2) =>
|
|
101358
|
+
if (!existsSync41(bundleDir)) return [];
|
|
101359
|
+
return readdirSync15(bundleDir).filter((name2) => existsSync41(join57(bundleDir, name2, ".claude-plugin", "plugin.json")));
|
|
101012
101360
|
}
|
|
101013
101361
|
function sameDir(a, b) {
|
|
101014
101362
|
const norm = (p) => resolve10(p).replace(/[\\/]+$/, "").toLowerCase();
|
|
@@ -101023,9 +101371,9 @@ function off(env2) {
|
|
|
101023
101371
|
return v === "0" || v === "off" || v === "false" || v === "no";
|
|
101024
101372
|
}
|
|
101025
101373
|
function readSettings(path3) {
|
|
101026
|
-
if (!
|
|
101374
|
+
if (!existsSync41(path3)) return {};
|
|
101027
101375
|
try {
|
|
101028
|
-
const parsed = JSON.parse(
|
|
101376
|
+
const parsed = JSON.parse(readFileSync49(path3, "utf8"));
|
|
101029
101377
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
101030
101378
|
return parsed;
|
|
101031
101379
|
} catch {
|
|
@@ -101049,13 +101397,13 @@ function currentDirs(settings) {
|
|
|
101049
101397
|
return raw2.split(delimiter2).map((s) => s.trim()).filter(Boolean);
|
|
101050
101398
|
}
|
|
101051
101399
|
function writeSettings(path3, settings) {
|
|
101052
|
-
mkdirSync12(
|
|
101400
|
+
mkdirSync12(dirname22(path3), { recursive: true });
|
|
101053
101401
|
writeFileSync33(path3, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
101054
101402
|
}
|
|
101055
101403
|
function ensureClaudeMods(opts) {
|
|
101056
101404
|
const env2 = opts.env ?? process.env;
|
|
101057
101405
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
101058
|
-
const modsRoot =
|
|
101406
|
+
const modsRoot = join57(opts.installRoot, "claude-mods");
|
|
101059
101407
|
if (off(env2)) {
|
|
101060
101408
|
const settings2 = readSettings(settingsPath);
|
|
101061
101409
|
if (!settings2) return { kind: "unreadable" };
|
|
@@ -101072,11 +101420,11 @@ function ensureClaudeMods(opts) {
|
|
|
101072
101420
|
let changed = false;
|
|
101073
101421
|
const installed = [];
|
|
101074
101422
|
for (const name2 of names) {
|
|
101075
|
-
const src =
|
|
101076
|
-
const dest =
|
|
101423
|
+
const src = join57(bundleDir, name2);
|
|
101424
|
+
const dest = join57(modsRoot, name2);
|
|
101077
101425
|
const hash2 = modHash(src);
|
|
101078
|
-
const hashFile =
|
|
101079
|
-
if (!
|
|
101426
|
+
const hashFile = join57(dest, HASH_FILE);
|
|
101427
|
+
if (!existsSync41(hashFile) || readFileSync49(hashFile, "utf8") !== hash2) {
|
|
101080
101428
|
rmSync4(dest, { recursive: true, force: true });
|
|
101081
101429
|
cpSync3(src, dest, { recursive: true, filter: (p) => !isEngineOwned(relative7(src, p)) });
|
|
101082
101430
|
writeFileSync33(hashFile, hash2, "utf8");
|
|
@@ -101510,9 +101858,9 @@ function resolveHookPort(explicit) {
|
|
|
101510
101858
|
}
|
|
101511
101859
|
}
|
|
101512
101860
|
}
|
|
101513
|
-
const settingsPath =
|
|
101861
|
+
const settingsPath = join58(ROOT, ".claude", "settings.json");
|
|
101514
101862
|
try {
|
|
101515
|
-
if (
|
|
101863
|
+
if (existsSync42(settingsPath)) return installedHookPort(readFileSync50(settingsPath, "utf8")) ?? 7891;
|
|
101516
101864
|
} catch {
|
|
101517
101865
|
}
|
|
101518
101866
|
return 7891;
|
|
@@ -101537,14 +101885,14 @@ async function cmdInit() {
|
|
|
101537
101885
|
if (!skipHooks) {
|
|
101538
101886
|
console.log("");
|
|
101539
101887
|
console.log("installing harness hooks...");
|
|
101540
|
-
const { existsSync:
|
|
101541
|
-
const { join:
|
|
101888
|
+
const { existsSync: existsSync43 } = await import("node:fs");
|
|
101889
|
+
const { join: join59 } = await import("node:path");
|
|
101542
101890
|
try {
|
|
101543
101891
|
await installClaudeHooks(port);
|
|
101544
101892
|
} catch (err2) {
|
|
101545
101893
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
101546
101894
|
}
|
|
101547
|
-
if (
|
|
101895
|
+
if (existsSync43(join59(ROOT, ".cursor"))) {
|
|
101548
101896
|
try {
|
|
101549
101897
|
await installCursorMcpConfig();
|
|
101550
101898
|
} catch (err2) {
|
|
@@ -101760,12 +102108,12 @@ async function cmdStatus() {
|
|
|
101760
102108
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
101761
102109
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
101762
102110
|
}
|
|
101763
|
-
console.log(` graph db: ${
|
|
101764
|
-
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})`);
|
|
101765
102113
|
for (const line of captureStatusLines(summarizePassLedger(paths.configDir).get("capture"))) {
|
|
101766
102114
|
console.log(` capture: ${line}`);
|
|
101767
102115
|
}
|
|
101768
|
-
if (
|
|
102116
|
+
if (existsSync42(paths.castalia)) {
|
|
101769
102117
|
try {
|
|
101770
102118
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
101771
102119
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -102766,11 +103114,11 @@ async function cmdInstallationProfile(args2) {
|
|
|
102766
103114
|
}
|
|
102767
103115
|
async function cmdReview() {
|
|
102768
103116
|
const paths = workspacePaths(ROOT);
|
|
102769
|
-
if (!
|
|
103117
|
+
if (!existsSync42(paths.reviewQueue)) {
|
|
102770
103118
|
console.log("(review queue empty)");
|
|
102771
103119
|
return;
|
|
102772
103120
|
}
|
|
102773
|
-
const queue = JSON.parse(
|
|
103121
|
+
const queue = JSON.parse(readFileSync50(paths.reviewQueue, "utf8"));
|
|
102774
103122
|
if (queue.length === 0) {
|
|
102775
103123
|
console.log("(review queue empty)");
|
|
102776
103124
|
return;
|
|
@@ -103372,9 +103720,8 @@ async function gatherRepo(store, ws) {
|
|
|
103372
103720
|
next: { verb: "burst", arg: p.id, hint: "full causal chain" }
|
|
103373
103721
|
});
|
|
103374
103722
|
}
|
|
103375
|
-
const
|
|
103376
|
-
const
|
|
103377
|
-
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);
|
|
103378
103725
|
const seenPair = new Set(spineEdges.map((e) => e.a < e.b ? `${e.a}-${e.b}` : `${e.b}-${e.a}`));
|
|
103379
103726
|
const addImplied = (a, b) => {
|
|
103380
103727
|
const key = a < b ? `${a}-${b}` : `${b}-${a}`;
|
|
@@ -103383,12 +103730,13 @@ async function gatherRepo(store, ws) {
|
|
|
103383
103730
|
spineEdges.push({ a, b, kind: "implied" });
|
|
103384
103731
|
};
|
|
103385
103732
|
for (let x = 0; x < embedded.length; x++) {
|
|
103733
|
+
const { relatedWeak, relatedStrong } = cosineBandsFor(embedded[x].version);
|
|
103386
103734
|
let best = -1;
|
|
103387
|
-
let bestSim =
|
|
103735
|
+
let bestSim = relatedWeak;
|
|
103388
103736
|
for (let y = 0; y < embedded.length; y++) {
|
|
103389
|
-
if (y === x) continue;
|
|
103737
|
+
if (y === x || embedded[y].version !== embedded[x].version) continue;
|
|
103390
103738
|
const sim = cosine5(embedded[x].emb, embedded[y].emb);
|
|
103391
|
-
if (sim >=
|
|
103739
|
+
if (sim >= relatedStrong) addImplied(embedded[x].i, embedded[y].i);
|
|
103392
103740
|
if (sim > bestSim) {
|
|
103393
103741
|
bestSim = sim;
|
|
103394
103742
|
best = embedded[y].i;
|
|
@@ -103470,7 +103818,7 @@ async function gatherRepo(store, ws) {
|
|
|
103470
103818
|
};
|
|
103471
103819
|
}
|
|
103472
103820
|
async function gatherReportData(generatedAt) {
|
|
103473
|
-
const { existsSync:
|
|
103821
|
+
const { existsSync: existsSync43 } = await import("node:fs");
|
|
103474
103822
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
103475
103823
|
const cfg = loadConfig();
|
|
103476
103824
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -103478,7 +103826,7 @@ async function gatherReportData(generatedAt) {
|
|
|
103478
103826
|
for (const ws of listWorkspaces()) {
|
|
103479
103827
|
if (ws.missing) continue;
|
|
103480
103828
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
103481
|
-
if (!
|
|
103829
|
+
if (!existsSync43(dbPath)) continue;
|
|
103482
103830
|
let store = null;
|
|
103483
103831
|
try {
|
|
103484
103832
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -103522,8 +103870,8 @@ async function cmdReport(args2) {
|
|
|
103522
103870
|
const outDir = workspacePaths(ROOT).configDir;
|
|
103523
103871
|
mkdirSync13(outDir, { recursive: true });
|
|
103524
103872
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
103525
|
-
for (const f of files) writeFileSync35(
|
|
103526
|
-
const indexPath =
|
|
103873
|
+
for (const f of files) writeFileSync35(join58(outDir, f.name), f.html, "utf8");
|
|
103874
|
+
const indexPath = join58(outDir, "report.html");
|
|
103527
103875
|
console.log(`report \u2192 ${indexPath}`);
|
|
103528
103876
|
console.log(
|
|
103529
103877
|
` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
|
|
@@ -103652,24 +104000,24 @@ async function cmdInstallHooks(args2) {
|
|
|
103652
104000
|
}
|
|
103653
104001
|
}
|
|
103654
104002
|
async function installOpencodePlugin(port) {
|
|
103655
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103656
|
-
const { join:
|
|
103657
|
-
const dir =
|
|
103658
|
-
if (!
|
|
103659
|
-
const file2 =
|
|
103660
|
-
if (
|
|
103661
|
-
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] ?? "";
|
|
103662
104010
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
103663
104011
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
103664
104012
|
process.exit(2);
|
|
103665
104013
|
}
|
|
103666
104014
|
}
|
|
103667
104015
|
writeFileSync35(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
103668
|
-
const cfgFile =
|
|
104016
|
+
const cfgFile = join59(ROOT, "opencode.json");
|
|
103669
104017
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
103670
|
-
if (
|
|
104018
|
+
if (existsSync43(cfgFile)) {
|
|
103671
104019
|
try {
|
|
103672
|
-
cfg = JSON.parse(
|
|
104020
|
+
cfg = JSON.parse(readFileSync51(cfgFile, "utf8"));
|
|
103673
104021
|
} catch {
|
|
103674
104022
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
103675
104023
|
process.exit(2);
|
|
@@ -103714,15 +104062,15 @@ function installClaudeMods() {
|
|
|
103714
104062
|
}
|
|
103715
104063
|
}
|
|
103716
104064
|
async function installClaudeHooks(port) {
|
|
103717
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103718
|
-
const { join:
|
|
103719
|
-
const dir =
|
|
103720
|
-
if (!
|
|
103721
|
-
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");
|
|
103722
104070
|
let settings = {};
|
|
103723
|
-
if (
|
|
104071
|
+
if (existsSync43(file2)) {
|
|
103724
104072
|
try {
|
|
103725
|
-
settings = JSON.parse(
|
|
104073
|
+
settings = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103726
104074
|
} catch {
|
|
103727
104075
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103728
104076
|
process.exit(2);
|
|
@@ -103735,7 +104083,7 @@ async function installClaudeHooks(port) {
|
|
|
103735
104083
|
console.log(` ${ensureStatusLine(port)}`);
|
|
103736
104084
|
console.log(` ${installClaudeMods().line}`);
|
|
103737
104085
|
await installClaudeMcpConfig();
|
|
103738
|
-
const claudeMd =
|
|
104086
|
+
const claudeMd = join59(ROOT, "CLAUDE.md");
|
|
103739
104087
|
const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
|
|
103740
104088
|
if (recall.kind === "collision") {
|
|
103741
104089
|
console.warn(
|
|
@@ -103747,15 +104095,15 @@ async function installClaudeHooks(port) {
|
|
|
103747
104095
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
103748
104096
|
}
|
|
103749
104097
|
async function installClaudeMcpConfig() {
|
|
103750
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103751
|
-
const { join:
|
|
103752
|
-
const file2 =
|
|
103753
|
-
const dir =
|
|
103754
|
-
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 });
|
|
103755
104103
|
let cfg = {};
|
|
103756
|
-
if (
|
|
104104
|
+
if (existsSync43(file2)) {
|
|
103757
104105
|
try {
|
|
103758
|
-
cfg = JSON.parse(
|
|
104106
|
+
cfg = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103759
104107
|
} catch {
|
|
103760
104108
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103761
104109
|
process.exit(2);
|
|
@@ -103769,15 +104117,15 @@ async function installClaudeMcpConfig() {
|
|
|
103769
104117
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
103770
104118
|
}
|
|
103771
104119
|
async function installCursorMcpConfig() {
|
|
103772
|
-
const { mkdirSync: mkdirSync13, existsSync:
|
|
103773
|
-
const { join:
|
|
103774
|
-
const dir =
|
|
103775
|
-
if (!
|
|
103776
|
-
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");
|
|
103777
104125
|
let cfg = {};
|
|
103778
|
-
if (
|
|
104126
|
+
if (existsSync43(file2)) {
|
|
103779
104127
|
try {
|
|
103780
|
-
cfg = JSON.parse(
|
|
104128
|
+
cfg = JSON.parse(readFileSync51(file2, "utf8"));
|
|
103781
104129
|
} catch {
|
|
103782
104130
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
103783
104131
|
process.exit(2);
|
|
@@ -103796,7 +104144,7 @@ async function installCodexHooks(port) {
|
|
|
103796
104144
|
const gitRoot = nearestGitRoot(process.cwd());
|
|
103797
104145
|
const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
|
|
103798
104146
|
const file2 = writeCodexHooks(hookRoot, port);
|
|
103799
|
-
const instructions = writeManagedBlock(
|
|
104147
|
+
const instructions = writeManagedBlock(join58(hookRoot, "AGENTS.md"), {
|
|
103800
104148
|
body: AGENTS_POINTER_BODY,
|
|
103801
104149
|
stable: true
|
|
103802
104150
|
});
|
|
@@ -103844,10 +104192,10 @@ function refreshExistingClaudeHooks() {
|
|
|
103844
104192
|
let ok = true;
|
|
103845
104193
|
const roots = [...listWorkspaceEntries().map((entry) => entry.path), process.cwd()];
|
|
103846
104194
|
for (const root of codexHookRoots(roots)) {
|
|
103847
|
-
const file2 =
|
|
104195
|
+
const file2 = join58(root, ".claude", "settings.json");
|
|
103848
104196
|
try {
|
|
103849
|
-
if (!
|
|
103850
|
-
const next = refreshClaudeHookSettings(
|
|
104197
|
+
if (!existsSync42(file2) || isReplayCheckout(root)) continue;
|
|
104198
|
+
const next = refreshClaudeHookSettings(readFileSync50(file2, "utf8"));
|
|
103851
104199
|
if (next === null) continue;
|
|
103852
104200
|
writeFileSync34(file2, next, "utf8");
|
|
103853
104201
|
console.log(`updated existing Claude Code hooks \u2192 ${file2}`);
|
|
@@ -104261,9 +104609,9 @@ async function cmdDash(args2) {
|
|
|
104261
104609
|
await yieldToLoop2();
|
|
104262
104610
|
try {
|
|
104263
104611
|
const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
|
|
104264
|
-
atCommit: readGitRefState(
|
|
104612
|
+
atCommit: readGitRefState(join58(r.root, ".git")).sha ?? void 0
|
|
104265
104613
|
});
|
|
104266
|
-
const res = bleedRules(
|
|
104614
|
+
const res = bleedRules(join58(r.root, ".claude", "rules"), items);
|
|
104267
104615
|
if (res.written || res.pruned) {
|
|
104268
104616
|
console.log(
|
|
104269
104617
|
`[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")
|