@inerrata-corporation/errata 2.0.14-dev.3228 → 2.0.14-dev.3289
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/errata.mjs +527 -531
- package/package.json +1 -1
- package/pass-worker.mjs +5 -3
package/errata.mjs
CHANGED
|
@@ -17281,7 +17281,7 @@ var init_triage_canon = __esm({
|
|
|
17281
17281
|
// ../../packages/shared/src/project-wire-attrs.ts
|
|
17282
17282
|
function projectWireAttrs(obj) {
|
|
17283
17283
|
return Object.fromEntries(Object.entries(obj).filter(
|
|
17284
|
-
([key]) => !/^(?:orgId|teamId|groupId|projectId|aliasTexts|aliasCanonicalIds|mergedFrom.*|.*WitnessKeys|.*Sessions|authoringSession.*|contributor.*|witnessKeys
|
|
17284
|
+
([key]) => !/^(?:orgId|teamId|groupId|projectId|aliasTexts|aliasCanonicalIds|mergedFrom.*|.*WitnessKeys|.*Sessions|authoringSession.*|contributor.*|witnessKeys.*|communitySupportIds)$/.test(key)
|
|
17285
17285
|
));
|
|
17286
17286
|
}
|
|
17287
17287
|
var init_project_wire_attrs = __esm({
|
|
@@ -21604,8 +21604,10 @@ function markFixCandidates(store, t) {
|
|
|
21604
21604
|
// band, so comparing it raw would retire a fresh ask on a
|
|
21605
21605
|
// frequently-surfaced problem before anyone had seen the question once.
|
|
21606
21606
|
fixCandidateShownBase: Number(p.attrs["shownCount"] ?? 0)
|
|
21607
|
-
}
|
|
21608
|
-
lastUpdatedAt
|
|
21607
|
+
}
|
|
21608
|
+
// No `lastUpdatedAt`: raising a question is bookkeeping, not a new
|
|
21609
|
+
// observation of the problem, and the passive block's recent-problems band
|
|
21610
|
+
// sorts on that field (see clearSettledFixCandidates).
|
|
21609
21611
|
});
|
|
21610
21612
|
resolved++;
|
|
21611
21613
|
}
|
|
@@ -21635,7 +21637,7 @@ function clearSettledFixCandidates(store, t) {
|
|
|
21635
21637
|
delete attrs["fixCandidateSymbol"];
|
|
21636
21638
|
delete attrs["fixCandidateFile"];
|
|
21637
21639
|
attrs["fixCandidateClearedAt"] = t;
|
|
21638
|
-
store.updateNode(p.id, { attrs
|
|
21640
|
+
store.updateNode(p.id, { attrs });
|
|
21639
21641
|
if (answered) report.answered++;
|
|
21640
21642
|
else if (ignored) report.ignored++;
|
|
21641
21643
|
else report.unsubstantiated++;
|
|
@@ -22636,14 +22638,14 @@ function localMoving(nodeIds, g) {
|
|
|
22636
22638
|
return community;
|
|
22637
22639
|
}
|
|
22638
22640
|
function refineConnectivity(community, g) {
|
|
22639
|
-
const
|
|
22641
|
+
const members = /* @__PURE__ */ new Map();
|
|
22640
22642
|
for (const [id, c] of community) {
|
|
22641
|
-
const l =
|
|
22643
|
+
const l = members.get(c) ?? [];
|
|
22642
22644
|
l.push(id);
|
|
22643
|
-
|
|
22645
|
+
members.set(c, l);
|
|
22644
22646
|
}
|
|
22645
22647
|
const refined = /* @__PURE__ */ new Map();
|
|
22646
|
-
for (const [, group] of
|
|
22648
|
+
for (const [, group] of members) {
|
|
22647
22649
|
const inGroup = new Set(group);
|
|
22648
22650
|
const seen = /* @__PURE__ */ new Set();
|
|
22649
22651
|
for (const start2 of [...group].sort()) {
|
|
@@ -23562,7 +23564,7 @@ function sharedScope(l2, memberIds) {
|
|
|
23562
23564
|
const versionRange = shared("versionRange");
|
|
23563
23565
|
return { ...lang ? { lang } : {}, ...versionRange ? { versionRange } : {} };
|
|
23564
23566
|
}
|
|
23565
|
-
function buildCandidate(id, ts,
|
|
23567
|
+
function buildCandidate(id, ts, members, contexts, originMachine, scope) {
|
|
23566
23568
|
return {
|
|
23567
23569
|
id,
|
|
23568
23570
|
label: "Claim",
|
|
@@ -23588,7 +23590,7 @@ function buildCandidate(id, ts, members2, contexts, originMachine, scope) {
|
|
|
23588
23590
|
pendingDistillation: true,
|
|
23589
23591
|
// membership is the unit of truth — the harness validates its fence against
|
|
23590
23592
|
// this set (P3 / C3) and may only phrase, never alter, it.
|
|
23591
|
-
members
|
|
23593
|
+
members,
|
|
23592
23594
|
memberContexts: contexts,
|
|
23593
23595
|
distinctContexts: contexts.length,
|
|
23594
23596
|
// standard Claim envelope so it crystallizes/syncs unchanged once distilled
|
|
@@ -23660,14 +23662,14 @@ function induceAbstractions(l2, opts) {
|
|
|
23660
23662
|
}
|
|
23661
23663
|
const comm = detectCommunitiesLeiden({ nodeIds: [...ids], adj }, { protect });
|
|
23662
23664
|
report.communities = comm.count;
|
|
23663
|
-
const
|
|
23665
|
+
const members = /* @__PURE__ */ new Map();
|
|
23664
23666
|
for (const [id, c] of comm.community) {
|
|
23665
|
-
const l =
|
|
23667
|
+
const l = members.get(c) ?? [];
|
|
23666
23668
|
l.push(id);
|
|
23667
|
-
|
|
23669
|
+
members.set(c, l);
|
|
23668
23670
|
}
|
|
23669
23671
|
l2.transaction(() => {
|
|
23670
|
-
for (const mem of
|
|
23672
|
+
for (const mem of members.values()) {
|
|
23671
23673
|
if (opts.touched && !mem.some((id) => opts.touched.has(id))) continue;
|
|
23672
23674
|
if (mem.length < K) {
|
|
23673
23675
|
report.skippedSmall++;
|
|
@@ -23709,14 +23711,14 @@ function pendingAbstractions(l2) {
|
|
|
23709
23711
|
if (Number(n.attrs["abstractionLevel"] ?? ABSTRACTION_LEVEL.CONCRETE) < ABSTRACTION_LEVEL.PRINCIPLE) continue;
|
|
23710
23712
|
if (n.attrs["provisional"] !== true) continue;
|
|
23711
23713
|
const memberIds = Array.isArray(n.attrs["members"]) ? n.attrs["members"] : [];
|
|
23712
|
-
const
|
|
23714
|
+
const members = memberIds.map((id) => {
|
|
23713
23715
|
const m = l2.getNode(id);
|
|
23714
23716
|
return m ? { id: m.id, label: m.label, description: m.description } : { id, label: "?", description: "(member missing)" };
|
|
23715
23717
|
});
|
|
23716
23718
|
out2.push({
|
|
23717
23719
|
candidate: n.id,
|
|
23718
23720
|
distinctContexts: Number(n.attrs["distinctContexts"] ?? 0),
|
|
23719
|
-
members
|
|
23721
|
+
members
|
|
23720
23722
|
});
|
|
23721
23723
|
}
|
|
23722
23724
|
return out2;
|
|
@@ -23746,10 +23748,10 @@ function applyAbstractionFence(l2, fence, ts) {
|
|
|
23746
23748
|
if (node2.attrs["provisional"] !== true) {
|
|
23747
23749
|
return { applied: false, principleId: fence.candidate, reason: "candidate already distilled" };
|
|
23748
23750
|
}
|
|
23749
|
-
const
|
|
23750
|
-
const want = new Set(
|
|
23751
|
+
const members = Array.isArray(node2.attrs["members"]) ? node2.attrs["members"] : [];
|
|
23752
|
+
const want = new Set(members);
|
|
23751
23753
|
const got = new Set(fence.covers);
|
|
23752
|
-
const missing =
|
|
23754
|
+
const missing = members.filter((id) => !got.has(id));
|
|
23753
23755
|
const invented = fence.covers.filter((id) => !want.has(id));
|
|
23754
23756
|
if (missing.length > 0 || invented.length > 0) {
|
|
23755
23757
|
return {
|
|
@@ -23780,10 +23782,10 @@ function revisitContradictedPrinciples(l2, ts) {
|
|
|
23780
23782
|
for (const n of l2.findNodesByLabel("Claim")) {
|
|
23781
23783
|
if (Number(n.attrs["abstractionLevel"] ?? ABSTRACTION_LEVEL.CONCRETE) < ABSTRACTION_LEVEL.PRINCIPLE) continue;
|
|
23782
23784
|
if (n.attrs["revisit"] === true) continue;
|
|
23783
|
-
const
|
|
23784
|
-
const memberSet = new Set(
|
|
23785
|
+
const members = Array.isArray(n.attrs["members"]) ? n.attrs["members"] : [];
|
|
23786
|
+
const memberSet = new Set(members);
|
|
23785
23787
|
let reason = "";
|
|
23786
|
-
for (const id of
|
|
23788
|
+
for (const id of members) {
|
|
23787
23789
|
const m = l2.getNode(id);
|
|
23788
23790
|
if (!m) {
|
|
23789
23791
|
reason = `member ${id} was removed`;
|
|
@@ -23874,14 +23876,14 @@ function detectLocalCommunities(store, opts = {}) {
|
|
|
23874
23876
|
}
|
|
23875
23877
|
}
|
|
23876
23878
|
const comm = detectCommunitiesLeiden({ nodeIds: [...ids], adj }, { protect });
|
|
23877
|
-
const
|
|
23879
|
+
const members = /* @__PURE__ */ new Map();
|
|
23878
23880
|
for (const [id, c] of comm.community) {
|
|
23879
|
-
const l =
|
|
23881
|
+
const l = members.get(c) ?? [];
|
|
23880
23882
|
l.push(id);
|
|
23881
|
-
|
|
23883
|
+
members.set(c, l);
|
|
23882
23884
|
}
|
|
23883
23885
|
store.transaction(() => {
|
|
23884
|
-
for (const [cid, mem] of
|
|
23886
|
+
for (const [cid, mem] of members) {
|
|
23885
23887
|
const qualifies = mem.length >= minSize;
|
|
23886
23888
|
let hasLocal = false;
|
|
23887
23889
|
let hasCloud = false;
|
|
@@ -30904,8 +30906,8 @@ var init_generalizer = __esm({
|
|
|
30904
30906
|
function layerOf(kind) {
|
|
30905
30907
|
return kind === "Technique" ? "technique" : kind === "AntiPattern" ? "antipattern" : "pattern";
|
|
30906
30908
|
}
|
|
30907
|
-
function motifTitle(
|
|
30908
|
-
const top = [...
|
|
30909
|
+
function motifTitle(members, layer, instanceCount) {
|
|
30910
|
+
const top = [...members].sort(
|
|
30909
30911
|
(a, b) => b.extractionConfidence - a.extractionConfidence
|
|
30910
30912
|
)[0];
|
|
30911
30913
|
return `${layer} \xD7${instanceCount} (exemplar): ${top?.description ?? "recurring problem cluster"}`;
|
|
@@ -30934,17 +30936,17 @@ function promoteMotifs(store, t) {
|
|
|
30934
30936
|
let techniques = 0;
|
|
30935
30937
|
let antipatterns = 0;
|
|
30936
30938
|
store.transaction(() => {
|
|
30937
|
-
for (const [cid,
|
|
30938
|
-
const instances =
|
|
30939
|
-
const instanceCount = instances.length ||
|
|
30939
|
+
for (const [cid, members] of byCommunity) {
|
|
30940
|
+
const instances = members.filter((m) => m.label === "Problem");
|
|
30941
|
+
const instanceCount = instances.length || members.length;
|
|
30940
30942
|
const motifId = `motif_${cid}`;
|
|
30941
30943
|
const existing = store.getNode(motifId);
|
|
30942
30944
|
const d = motifDecision({
|
|
30943
|
-
instances:
|
|
30945
|
+
instances: members.map((m) => ({
|
|
30944
30946
|
confidence: m.extractionConfidence,
|
|
30945
30947
|
failed: false
|
|
30946
30948
|
})),
|
|
30947
|
-
memberCount:
|
|
30949
|
+
memberCount: members.length,
|
|
30948
30950
|
instanceCount,
|
|
30949
30951
|
priorSurvivedRuns: existing?.attrs["survivedRuns"] ?? 0
|
|
30950
30952
|
});
|
|
@@ -30956,7 +30958,7 @@ function promoteMotifs(store, t) {
|
|
|
30956
30958
|
label: kind,
|
|
30957
30959
|
// Refresh the deterministic title every run (exemplar/count/kind drift),
|
|
30958
30960
|
// but never clobber a distilled one — a distillation pass owns it then.
|
|
30959
|
-
description: existing?.attrs["titleDistilled"] === true ? existing.description : motifTitle(
|
|
30961
|
+
description: existing?.attrs["titleDistilled"] === true ? existing.description : motifTitle(members, layerOf(kind), instanceCount),
|
|
30960
30962
|
extractionConfidence: d.motifConfidence,
|
|
30961
30963
|
extractionSource: "bko-inferred",
|
|
30962
30964
|
embedding: existing?.embedding ?? [],
|
|
@@ -30975,7 +30977,7 @@ function promoteMotifs(store, t) {
|
|
|
30975
30977
|
communityId: cid,
|
|
30976
30978
|
survivedRuns: d.survivedRuns,
|
|
30977
30979
|
motifConfidence: d.motifConfidence,
|
|
30978
|
-
memberCount:
|
|
30980
|
+
memberCount: members.length,
|
|
30979
30981
|
instanceCount,
|
|
30980
30982
|
promoted: d.promoted
|
|
30981
30983
|
}
|
|
@@ -31996,47 +31998,43 @@ var init_recall_card = __esm({
|
|
|
31996
31998
|
});
|
|
31997
31999
|
|
|
31998
32000
|
// src/recall-signal.ts
|
|
32001
|
+
import { existsSync as existsSync7, readFileSync as readFileSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
32002
|
+
import { join as join7 } from "node:path";
|
|
31999
32003
|
function live(n) {
|
|
32000
32004
|
return n != null && n.validTo == null && historyReadPolicy(n, { mode: "passive" }).allow;
|
|
32001
32005
|
}
|
|
32002
32006
|
function isPlaceholderFix(n) {
|
|
32003
32007
|
return n.label === "Solution" && (n.description ?? "").startsWith(AUTO_MINT_PREFIX);
|
|
32004
32008
|
}
|
|
32005
|
-
function causalChains(store, problems
|
|
32006
|
-
const
|
|
32009
|
+
function causalChains(store, problems) {
|
|
32010
|
+
const newest = (nodes) => nodes.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt)[0];
|
|
32007
32011
|
const chains = [];
|
|
32008
32012
|
for (const problem of problems) {
|
|
32009
|
-
const
|
|
32010
|
-
|
|
32011
|
-
|
|
32012
|
-
const fix =
|
|
32013
|
+
const cause = newest(
|
|
32014
|
+
store.outEdges(problem.id, ["CAUSED_BY"]).map((e) => store.getNode(e.to)).filter((n) => live(n) && n.label === "RootCause")
|
|
32015
|
+
);
|
|
32016
|
+
const fix = newest(
|
|
32017
|
+
store.outEdges(problem.id, ["SOLVED_BY"]).map((e) => store.getNode(e.to)).filter((n) => live(n) && n.label === "Solution" && !isPlaceholderFix(n))
|
|
32018
|
+
);
|
|
32013
32019
|
if (cause || fix) chains.push({ problem, ...cause ? { cause } : {}, ...fix ? { fix } : {} });
|
|
32014
32020
|
}
|
|
32015
32021
|
return chains;
|
|
32016
32022
|
}
|
|
32017
|
-
function members(c) {
|
|
32018
|
-
return [c.problem, c.cause, c.fix].filter((n) => n != null);
|
|
32019
|
-
}
|
|
32020
|
-
function pickChain(chains, scoreOf) {
|
|
32021
|
-
const mean = (c) => {
|
|
32022
|
-
const m = members(c);
|
|
32023
|
-
return m.reduce((s, n) => s + scoreOf(n.id), 0) / m.length;
|
|
32024
|
-
};
|
|
32025
|
-
return chains.filter((c) => scoreOf(c.problem.id) > 0).sort((a, b) => members(b).length - members(a).length || mean(b) - mean(a))[0];
|
|
32026
|
-
}
|
|
32027
32023
|
function item(n) {
|
|
32028
32024
|
return { label: n.label, text: n.description ?? "" };
|
|
32029
32025
|
}
|
|
32030
|
-
function
|
|
32031
|
-
|
|
32032
|
-
|
|
32033
|
-
|
|
32034
|
-
|
|
32035
|
-
const
|
|
32036
|
-
const
|
|
32026
|
+
function deliveredPrior(n) {
|
|
32027
|
+
return { id: n.id, label: n.label, text: n.description ?? "" };
|
|
32028
|
+
}
|
|
32029
|
+
function deliveredCard(store, headline, delivered) {
|
|
32030
|
+
if (delivered.length === 0) return null;
|
|
32031
|
+
const problems = delivered.filter((d) => d.label === "Problem").map((d) => store.getNode(d.id)).filter((n) => live(n));
|
|
32032
|
+
const chain2 = causalChains(store, problems)[0];
|
|
32033
|
+
const inChain = new Set(chain2 ? [chain2.problem.id, chain2.cause?.id, chain2.fix?.id] : []);
|
|
32034
|
+
const single = delivered.find((d) => !inChain.has(d.id));
|
|
32037
32035
|
return {
|
|
32038
32036
|
headline,
|
|
32039
|
-
items:
|
|
32037
|
+
items: delivered.map((d) => ({ label: d.label, text: d.text })),
|
|
32040
32038
|
...chain2 ? {
|
|
32041
32039
|
chain: {
|
|
32042
32040
|
problem: item(chain2.problem),
|
|
@@ -32044,19 +32042,43 @@ function signalCard(headline, ranked, chains, chainScores = /* @__PURE__ */ new
|
|
|
32044
32042
|
...chain2.fix ? { fix: item(chain2.fix) } : {}
|
|
32045
32043
|
}
|
|
32046
32044
|
} : {},
|
|
32047
|
-
...single ? { single:
|
|
32045
|
+
...single ? { single: { label: single.label, text: single.text } } : {}
|
|
32048
32046
|
};
|
|
32049
32047
|
}
|
|
32050
|
-
function
|
|
32051
|
-
const
|
|
32052
|
-
|
|
32053
|
-
|
|
32054
|
-
|
|
32055
|
-
|
|
32056
|
-
|
|
32057
|
-
|
|
32048
|
+
function clipIntent(text, width = 48) {
|
|
32049
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
32050
|
+
return flat.length > width ? `${flat.slice(0, width - 1)}\u2026` : flat;
|
|
32051
|
+
}
|
|
32052
|
+
function contextCard(store, snapshot) {
|
|
32053
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32054
|
+
const delivered = [];
|
|
32055
|
+
const add = (n) => {
|
|
32056
|
+
if (!n.id || seen.has(n.id)) return;
|
|
32057
|
+
seen.add(n.id);
|
|
32058
|
+
delivered.push(deliveredPrior(n));
|
|
32059
|
+
};
|
|
32060
|
+
for (const h of snapshot.statedIntent?.hits ?? []) add(h);
|
|
32061
|
+
for (const h of snapshot.statedIntent?.remoteHits ?? []) add(h);
|
|
32062
|
+
for (const p of snapshot.workingFile?.priors?.openProblems ?? []) add({ ...p, label: "Problem" });
|
|
32063
|
+
for (const r of snapshot.recentProblems) add(r.node);
|
|
32064
|
+
for (const n of snapshot.remote ?? []) add(n);
|
|
32065
|
+
for (const m of snapshot.motifs) add(m);
|
|
32066
|
+
const count = plural(delivered.length, "prior");
|
|
32067
|
+
const intent = snapshot.statedIntent?.text;
|
|
32068
|
+
return deliveredCard(store, intent ? `${count} for \u201C${clipIntent(intent)}\u201D` : `${count} in context`, delivered);
|
|
32069
|
+
}
|
|
32070
|
+
function writeContextCard(root, hash2, card) {
|
|
32071
|
+
writeFileSync6(join7(root, ".errata", CONTEXT_CARD_FILE), JSON.stringify({ hash: hash2, card }));
|
|
32072
|
+
}
|
|
32073
|
+
function readContextCard(root, hash2) {
|
|
32074
|
+
const path2 = join7(root, ".errata", CONTEXT_CARD_FILE);
|
|
32075
|
+
if (!existsSync7(path2)) return null;
|
|
32076
|
+
try {
|
|
32077
|
+
const saved = JSON.parse(readFileSync5(path2, "utf8"));
|
|
32078
|
+
return saved.hash === hash2 ? saved.card ?? null : null;
|
|
32079
|
+
} catch {
|
|
32080
|
+
return null;
|
|
32058
32081
|
}
|
|
32059
|
-
return { problems, ids: [...ids] };
|
|
32060
32082
|
}
|
|
32061
32083
|
function openProblems(store, now = Date.now()) {
|
|
32062
32084
|
const hit = openProblemsCache.get(store);
|
|
@@ -32065,60 +32087,34 @@ function openProblems(store, now = Date.now()) {
|
|
|
32065
32087
|
openProblemsCache.set(store, { at: now, nodes });
|
|
32066
32088
|
return nodes;
|
|
32067
32089
|
}
|
|
32068
|
-
async function promptRecallCard(store, prompt) {
|
|
32069
|
-
const { problems, ids } = promptPool(store);
|
|
32070
|
-
if (ids.length === 0) return null;
|
|
32071
|
-
const ranked = await rankForText(store, prompt.slice(0, 2e3), ids);
|
|
32072
|
-
const matched = promptMatches(ranked);
|
|
32073
|
-
if (matched.length === 0) return null;
|
|
32074
|
-
const score2 = new Map(ranked.map((r) => [r.id, r.score]));
|
|
32075
|
-
const matchedIds = new Set(matched.map((r) => r.id));
|
|
32076
|
-
const chains = causalChains(store, problems.filter((p) => matchedIds.has(p.id)), (id) => score2.get(id) ?? 0);
|
|
32077
|
-
const verb = matched.length === 1 ? "matches" : "match";
|
|
32078
|
-
const card = signalCard(`${plural(matched.length, "prior")} ${verb} this prompt`, matched, chains, score2);
|
|
32079
|
-
return card && { ...card, moreWhere: "matching" };
|
|
32080
|
-
}
|
|
32081
|
-
function promptMatches(ranked, sigmas = 3.5) {
|
|
32082
|
-
const sims = ranked.map((r) => r.components.semantic ?? 0);
|
|
32083
|
-
if (sims.length < 3) return [...ranked];
|
|
32084
|
-
const median = (xs) => {
|
|
32085
|
-
const s = [...xs].sort((a, b) => a - b);
|
|
32086
|
-
const m = s.length >> 1;
|
|
32087
|
-
return s.length % 2 ? s[m] : (s[m - 1] + s[m]) / 2;
|
|
32088
|
-
};
|
|
32089
|
-
const center = median(sims);
|
|
32090
|
-
const sigma = 1.4826 * median(sims.map((x) => Math.abs(x - center)));
|
|
32091
|
-
if (sigma === 0) return [];
|
|
32092
|
-
return ranked.map((r, i2) => ({ r, sim: sims[i2] })).filter((x) => x.sim >= center + sigmas * sigma).sort((a, b) => b.sim - a.sim || b.r.score - a.r.score).map((x) => x.r);
|
|
32093
|
-
}
|
|
32094
32090
|
function openProblemCount(store) {
|
|
32095
32091
|
return openProblems(store).length;
|
|
32096
32092
|
}
|
|
32097
|
-
var OPEN_PROBLEMS_TTL_MS, openProblemsCache;
|
|
32093
|
+
var CONTEXT_CARD_FILE, OPEN_PROBLEMS_TTL_MS, openProblemsCache;
|
|
32098
32094
|
var init_recall_signal = __esm({
|
|
32099
32095
|
"src/recall-signal.ts"() {
|
|
32100
32096
|
"use strict";
|
|
32101
32097
|
init_src5();
|
|
32102
32098
|
init_src();
|
|
32103
|
-
init_src8();
|
|
32104
32099
|
init_recall_card();
|
|
32100
|
+
CONTEXT_CARD_FILE = "context-card.json";
|
|
32105
32101
|
OPEN_PROBLEMS_TTL_MS = 6e4;
|
|
32106
32102
|
openProblemsCache = /* @__PURE__ */ new WeakMap();
|
|
32107
32103
|
}
|
|
32108
32104
|
});
|
|
32109
32105
|
|
|
32110
32106
|
// src/review.ts
|
|
32111
|
-
import { existsSync as
|
|
32107
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
32112
32108
|
function loadReviewQueue(paths) {
|
|
32113
|
-
if (!
|
|
32109
|
+
if (!existsSync8(paths.reviewQueue)) return [];
|
|
32114
32110
|
try {
|
|
32115
|
-
return JSON.parse(
|
|
32111
|
+
return JSON.parse(readFileSync6(paths.reviewQueue, "utf8"));
|
|
32116
32112
|
} catch {
|
|
32117
32113
|
return [];
|
|
32118
32114
|
}
|
|
32119
32115
|
}
|
|
32120
32116
|
function saveReviewQueue(paths, queue) {
|
|
32121
|
-
|
|
32117
|
+
writeFileSync7(paths.reviewQueue, JSON.stringify(queue, null, 2), "utf8");
|
|
32122
32118
|
}
|
|
32123
32119
|
function addProposal(paths, store, node2, reason, surprise) {
|
|
32124
32120
|
const queue = loadReviewQueue(paths);
|
|
@@ -32188,14 +32184,14 @@ var init_consent = __esm({
|
|
|
32188
32184
|
});
|
|
32189
32185
|
|
|
32190
32186
|
// src/git-remote.ts
|
|
32191
|
-
import { existsSync as
|
|
32192
|
-
import { isAbsolute as isAbsolute2, join as
|
|
32187
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, statSync } from "node:fs";
|
|
32188
|
+
import { isAbsolute as isAbsolute2, join as join8, resolve } from "node:path";
|
|
32193
32189
|
function resolveGitDir(root) {
|
|
32194
|
-
const dotGit =
|
|
32190
|
+
const dotGit = join8(root, ".git");
|
|
32195
32191
|
try {
|
|
32196
32192
|
const st = statSync(dotGit);
|
|
32197
32193
|
if (st.isDirectory()) return dotGit;
|
|
32198
|
-
const m = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
32194
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync7(dotGit, "utf8"));
|
|
32199
32195
|
if (!m) return null;
|
|
32200
32196
|
const dir = m[1];
|
|
32201
32197
|
return isAbsolute2(dir) ? dir : resolve(root, dir);
|
|
@@ -32204,22 +32200,22 @@ function resolveGitDir(root) {
|
|
|
32204
32200
|
}
|
|
32205
32201
|
}
|
|
32206
32202
|
function gitConfigPath(gitDir) {
|
|
32207
|
-
const commondirFile =
|
|
32208
|
-
if (
|
|
32209
|
-
const common =
|
|
32203
|
+
const commondirFile = join8(gitDir, "commondir");
|
|
32204
|
+
if (existsSync9(commondirFile)) {
|
|
32205
|
+
const common = readFileSync7(commondirFile, "utf8").trim();
|
|
32210
32206
|
const commonDir = isAbsolute2(common) ? common : resolve(gitDir, common);
|
|
32211
|
-
return
|
|
32207
|
+
return join8(commonDir, "config");
|
|
32212
32208
|
}
|
|
32213
|
-
return
|
|
32209
|
+
return join8(gitDir, "config");
|
|
32214
32210
|
}
|
|
32215
32211
|
function readRemotes(root) {
|
|
32216
32212
|
const gitDir = resolveGitDir(root);
|
|
32217
32213
|
if (!gitDir) return [];
|
|
32218
32214
|
const cfgPath = gitConfigPath(gitDir);
|
|
32219
|
-
if (!
|
|
32215
|
+
if (!existsSync9(cfgPath)) return [];
|
|
32220
32216
|
let txt;
|
|
32221
32217
|
try {
|
|
32222
|
-
txt =
|
|
32218
|
+
txt = readFileSync7(cfgPath, "utf8");
|
|
32223
32219
|
} catch {
|
|
32224
32220
|
return [];
|
|
32225
32221
|
}
|
|
@@ -32245,9 +32241,9 @@ var init_git_remote = __esm({
|
|
|
32245
32241
|
});
|
|
32246
32242
|
|
|
32247
32243
|
// src/profile.ts
|
|
32248
|
-
import { existsSync as
|
|
32244
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
32249
32245
|
import { createHash as createHash5 } from "node:crypto";
|
|
32250
|
-
import { join as
|
|
32246
|
+
import { join as join9 } from "node:path";
|
|
32251
32247
|
function workspaceId(root) {
|
|
32252
32248
|
return "wp_" + createHash5("sha256").update(root).digest("hex").slice(0, 12);
|
|
32253
32249
|
}
|
|
@@ -32270,13 +32266,13 @@ function refreshRepoLocator(root, profile) {
|
|
|
32270
32266
|
}
|
|
32271
32267
|
function loadProfile(root) {
|
|
32272
32268
|
const p = workspacePaths(root);
|
|
32273
|
-
if (!
|
|
32274
|
-
return JSON.parse(
|
|
32269
|
+
if (!existsSync10(p.workspaceJson)) return null;
|
|
32270
|
+
return JSON.parse(readFileSync8(p.workspaceJson, "utf8"));
|
|
32275
32271
|
}
|
|
32276
32272
|
function saveProfile(root, profile) {
|
|
32277
32273
|
const p = workspacePaths(root);
|
|
32278
32274
|
ensureDir(p.configDir);
|
|
32279
|
-
|
|
32275
|
+
writeFileSync8(p.workspaceJson, JSON.stringify(profile, null, 2), "utf8");
|
|
32280
32276
|
}
|
|
32281
32277
|
function autodetectProfile(root) {
|
|
32282
32278
|
const id = workspaceId(root);
|
|
@@ -32284,13 +32280,13 @@ function autodetectProfile(root) {
|
|
|
32284
32280
|
const p = emptyProfile(id, name2);
|
|
32285
32281
|
const locator = detectRepoLocator(root);
|
|
32286
32282
|
if (locator) p.repoLocator = locator;
|
|
32287
|
-
const pkgPath =
|
|
32288
|
-
if (
|
|
32283
|
+
const pkgPath = join9(root, "package.json");
|
|
32284
|
+
if (existsSync10(pkgPath)) {
|
|
32289
32285
|
try {
|
|
32290
|
-
const pkg = JSON.parse(
|
|
32286
|
+
const pkg = JSON.parse(readFileSync8(pkgPath, "utf8"));
|
|
32291
32287
|
const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
|
|
32292
32288
|
p.languages.push("javascript");
|
|
32293
|
-
if (
|
|
32289
|
+
if (existsSync10(join9(root, "tsconfig.json")) || deps["typescript"]) {
|
|
32294
32290
|
p.languages.push("typescript");
|
|
32295
32291
|
}
|
|
32296
32292
|
const nodeVer = pkg.engines?.node?.trim();
|
|
@@ -32311,10 +32307,10 @@ function autodetectProfile(root) {
|
|
|
32311
32307
|
} catch {
|
|
32312
32308
|
}
|
|
32313
32309
|
}
|
|
32314
|
-
const pyproject =
|
|
32315
|
-
if (
|
|
32310
|
+
const pyproject = join9(root, "pyproject.toml");
|
|
32311
|
+
if (existsSync10(pyproject)) {
|
|
32316
32312
|
try {
|
|
32317
|
-
const txt =
|
|
32313
|
+
const txt = readFileSync8(pyproject, "utf8");
|
|
32318
32314
|
const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
|
|
32319
32315
|
p.languages.push("python");
|
|
32320
32316
|
p.stack.push(`python@${py ?? "3"}`);
|
|
@@ -32325,16 +32321,16 @@ function autodetectProfile(root) {
|
|
|
32325
32321
|
} catch {
|
|
32326
32322
|
}
|
|
32327
32323
|
}
|
|
32328
|
-
const reqs =
|
|
32329
|
-
if (
|
|
32324
|
+
const reqs = join9(root, "requirements.txt");
|
|
32325
|
+
if (existsSync10(reqs)) {
|
|
32330
32326
|
if (!p.languages.includes("python")) p.languages.push("python");
|
|
32331
32327
|
if (!p.stack.includes("python@3")) p.stack.push("python@3");
|
|
32332
32328
|
}
|
|
32333
|
-
if (
|
|
32329
|
+
if (existsSync10(join9(root, "go.mod"))) {
|
|
32334
32330
|
p.languages.push("go");
|
|
32335
32331
|
p.stack.push("go");
|
|
32336
32332
|
}
|
|
32337
|
-
if (
|
|
32333
|
+
if (existsSync10(join9(root, "Cargo.toml"))) {
|
|
32338
32334
|
p.languages.push("rust");
|
|
32339
32335
|
p.stack.push("rust");
|
|
32340
32336
|
}
|
|
@@ -32439,12 +32435,12 @@ var init_identity2 = __esm({
|
|
|
32439
32435
|
});
|
|
32440
32436
|
|
|
32441
32437
|
// src/checkout-root.ts
|
|
32442
|
-
import { existsSync as
|
|
32443
|
-
import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute3, join as
|
|
32438
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
|
|
32439
|
+
import { basename as basename2, dirname as dirname6, isAbsolute as isAbsolute3, join as join10, resolve as resolve2 } from "node:path";
|
|
32444
32440
|
function nearestGitRoot(dir) {
|
|
32445
32441
|
let cur = resolve2(dir);
|
|
32446
32442
|
for (; ; ) {
|
|
32447
|
-
if (
|
|
32443
|
+
if (existsSync11(join10(cur, ".git"))) return cur;
|
|
32448
32444
|
const parent = dirname6(cur);
|
|
32449
32445
|
if (parent === cur) return null;
|
|
32450
32446
|
cur = parent;
|
|
@@ -32452,19 +32448,19 @@ function nearestGitRoot(dir) {
|
|
|
32452
32448
|
}
|
|
32453
32449
|
function mainCheckoutOfWorktree(root) {
|
|
32454
32450
|
const gitDir = resolveGitDir(root);
|
|
32455
|
-
if (!gitDir || gitDir ===
|
|
32456
|
-
const commondirFile =
|
|
32457
|
-
if (!
|
|
32451
|
+
if (!gitDir || gitDir === join10(root, ".git")) return null;
|
|
32452
|
+
const commondirFile = join10(gitDir, "commondir");
|
|
32453
|
+
if (!existsSync11(commondirFile)) return null;
|
|
32458
32454
|
let common;
|
|
32459
32455
|
try {
|
|
32460
|
-
common =
|
|
32456
|
+
common = readFileSync9(commondirFile, "utf8").trim();
|
|
32461
32457
|
} catch {
|
|
32462
32458
|
return null;
|
|
32463
32459
|
}
|
|
32464
32460
|
const commonDir = resolve2(isAbsolute3(common) ? common : resolve2(gitDir, common));
|
|
32465
32461
|
if (basename2(commonDir) !== ".git") return null;
|
|
32466
32462
|
const main2 = dirname6(commonDir);
|
|
32467
|
-
return
|
|
32463
|
+
return existsSync11(join10(main2, ".git")) ? main2 : null;
|
|
32468
32464
|
}
|
|
32469
32465
|
function checkoutRootOf(cwd) {
|
|
32470
32466
|
const root = nearestGitRoot(cwd);
|
|
@@ -32482,16 +32478,16 @@ var init_checkout_root = __esm({
|
|
|
32482
32478
|
});
|
|
32483
32479
|
|
|
32484
32480
|
// src/registry.ts
|
|
32485
|
-
import { existsSync as
|
|
32486
|
-
import { join as
|
|
32481
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
|
|
32482
|
+
import { join as join11 } from "node:path";
|
|
32487
32483
|
function registryPath() {
|
|
32488
|
-
return process.env["ERRATA_REGISTRY_PATH"] ??
|
|
32484
|
+
return process.env["ERRATA_REGISTRY_PATH"] ?? join11(globalDir(), "workspaces.json");
|
|
32489
32485
|
}
|
|
32490
32486
|
function read() {
|
|
32491
32487
|
const p = registryPath();
|
|
32492
|
-
if (!
|
|
32488
|
+
if (!existsSync12(p)) return { version: 1, workspaces: {} };
|
|
32493
32489
|
try {
|
|
32494
|
-
const parsed = JSON.parse(
|
|
32490
|
+
const parsed = JSON.parse(readFileSync10(p, "utf8"));
|
|
32495
32491
|
return { version: 1, workspaces: parsed.workspaces ?? {} };
|
|
32496
32492
|
} catch {
|
|
32497
32493
|
return { version: 1, workspaces: {} };
|
|
@@ -32499,9 +32495,9 @@ function read() {
|
|
|
32499
32495
|
}
|
|
32500
32496
|
function registryCorrupt() {
|
|
32501
32497
|
const p = registryPath();
|
|
32502
|
-
if (!
|
|
32498
|
+
if (!existsSync12(p)) return false;
|
|
32503
32499
|
try {
|
|
32504
|
-
JSON.parse(
|
|
32500
|
+
JSON.parse(readFileSync10(p, "utf8"));
|
|
32505
32501
|
return false;
|
|
32506
32502
|
} catch {
|
|
32507
32503
|
return true;
|
|
@@ -32509,7 +32505,7 @@ function registryCorrupt() {
|
|
|
32509
32505
|
}
|
|
32510
32506
|
function write(reg) {
|
|
32511
32507
|
ensureDir(globalDir());
|
|
32512
|
-
|
|
32508
|
+
writeFileSync9(registryPath(), JSON.stringify(reg, null, 2), "utf8");
|
|
32513
32509
|
}
|
|
32514
32510
|
function registerWorkspace(profile, root, now = Date.now()) {
|
|
32515
32511
|
if (isLinkedWorktree(root)) return;
|
|
@@ -32554,7 +32550,7 @@ function pruneMissingWorkspaces() {
|
|
|
32554
32550
|
const reg = read();
|
|
32555
32551
|
const removed = [];
|
|
32556
32552
|
for (const [id, entry] of Object.entries(reg.workspaces)) {
|
|
32557
|
-
if (!
|
|
32553
|
+
if (!existsSync12(entry.path)) {
|
|
32558
32554
|
removed.push(entry);
|
|
32559
32555
|
delete reg.workspaces[id];
|
|
32560
32556
|
}
|
|
@@ -32563,13 +32559,13 @@ function pruneMissingWorkspaces() {
|
|
|
32563
32559
|
return removed;
|
|
32564
32560
|
}
|
|
32565
32561
|
function workspaceStatus(entry) {
|
|
32566
|
-
const missing = !
|
|
32562
|
+
const missing = !existsSync12(entry.path);
|
|
32567
32563
|
const lockPath = workspacePaths(entry.path).daemonLock;
|
|
32568
32564
|
let running = false;
|
|
32569
32565
|
let webUiUrl = null;
|
|
32570
|
-
if (
|
|
32566
|
+
if (existsSync12(lockPath)) {
|
|
32571
32567
|
try {
|
|
32572
|
-
const lock = JSON.parse(
|
|
32568
|
+
const lock = JSON.parse(readFileSync10(lockPath, "utf8"));
|
|
32573
32569
|
if (lock.pid && lock.webUiUrl && pidAlive(lock.pid)) {
|
|
32574
32570
|
running = true;
|
|
32575
32571
|
webUiUrl = lock.webUiUrl;
|
|
@@ -33894,22 +33890,22 @@ var init_dual_augment = __esm({
|
|
|
33894
33890
|
|
|
33895
33891
|
// ../../packages/indexer/src/parse-cache.ts
|
|
33896
33892
|
import { createHash as createHash6 } from "node:crypto";
|
|
33897
|
-
import { existsSync as
|
|
33893
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync11, readdirSync as readdirSync2, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync10 } from "node:fs";
|
|
33898
33894
|
import { homedir as homedir3 } from "node:os";
|
|
33899
|
-
import { join as
|
|
33895
|
+
import { join as join12 } from "node:path";
|
|
33900
33896
|
function parseCacheDir() {
|
|
33901
|
-
return process.env["ERRATA_PARSE_CACHE"] ??
|
|
33897
|
+
return process.env["ERRATA_PARSE_CACHE"] ?? join12(homedir3(), ".errata", "parse-cache");
|
|
33902
33898
|
}
|
|
33903
33899
|
function parseCacheKey(source, providerId) {
|
|
33904
33900
|
return createHash6("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
|
|
33905
33901
|
}
|
|
33906
33902
|
function entryPath(dir, key) {
|
|
33907
|
-
return
|
|
33903
|
+
return join12(dir, key.slice(0, 2), `${key.slice(2)}.json`);
|
|
33908
33904
|
}
|
|
33909
33905
|
function readParseCache(dir, key) {
|
|
33910
33906
|
const file2 = entryPath(dir, key);
|
|
33911
33907
|
try {
|
|
33912
|
-
const raw2 =
|
|
33908
|
+
const raw2 = readFileSync11(file2, "utf8");
|
|
33913
33909
|
const parsed = JSON.parse(raw2);
|
|
33914
33910
|
if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
|
|
33915
33911
|
return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
|
|
@@ -33928,8 +33924,8 @@ function writeParseCache(dir, key, providerId, value) {
|
|
|
33928
33924
|
const body2 = JSON.stringify(envelope);
|
|
33929
33925
|
if (body2.length > MAX_ENTRY_BYTES) return;
|
|
33930
33926
|
const file2 = entryPath(dir, key);
|
|
33931
|
-
mkdirSync6(
|
|
33932
|
-
|
|
33927
|
+
mkdirSync6(join12(dir, key.slice(0, 2)), { recursive: true });
|
|
33928
|
+
writeFileSync10(file2, body2);
|
|
33933
33929
|
} catch {
|
|
33934
33930
|
}
|
|
33935
33931
|
}
|
|
@@ -33938,9 +33934,9 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
33938
33934
|
sweptThisProcess = true;
|
|
33939
33935
|
let removed = 0;
|
|
33940
33936
|
try {
|
|
33941
|
-
if (!
|
|
33937
|
+
if (!existsSync13(dir)) return 0;
|
|
33942
33938
|
for (const bucket of readdirSync2(dir)) {
|
|
33943
|
-
const bucketDir =
|
|
33939
|
+
const bucketDir = join12(dir, bucket);
|
|
33944
33940
|
let names;
|
|
33945
33941
|
try {
|
|
33946
33942
|
names = readdirSync2(bucketDir);
|
|
@@ -33948,7 +33944,7 @@ function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
|
33948
33944
|
continue;
|
|
33949
33945
|
}
|
|
33950
33946
|
for (const name2 of names) {
|
|
33951
|
-
const file2 =
|
|
33947
|
+
const file2 = join12(bucketDir, name2);
|
|
33952
33948
|
try {
|
|
33953
33949
|
if (now - statSync2(file2).mtimeMs > ENTRY_TTL_MS) {
|
|
33954
33950
|
rmSync2(file2, { force: true });
|
|
@@ -34196,9 +34192,9 @@ var init_identity3 = __esm({
|
|
|
34196
34192
|
});
|
|
34197
34193
|
|
|
34198
34194
|
// ../../packages/indexer/src/pipeline.ts
|
|
34199
|
-
import { appendFileSync, readFileSync as
|
|
34195
|
+
import { appendFileSync, readFileSync as readFileSync12, statSync as statSync3 } from "node:fs";
|
|
34200
34196
|
import { readdir } from "node:fs/promises";
|
|
34201
|
-
import { extname, join as
|
|
34197
|
+
import { extname, join as join13, relative as relative2, sep } from "node:path";
|
|
34202
34198
|
import { createHash as createHash7 } from "node:crypto";
|
|
34203
34199
|
import { execFileSync } from "node:child_process";
|
|
34204
34200
|
function nowTs() {
|
|
@@ -34336,7 +34332,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34336
34332
|
for (const rel of [...changedRelPaths]) {
|
|
34337
34333
|
let h;
|
|
34338
34334
|
try {
|
|
34339
|
-
h = createHash7("sha256").update(
|
|
34335
|
+
h = createHash7("sha256").update(readFileSync12(join13(rootPath, rel))).digest("hex");
|
|
34340
34336
|
} catch {
|
|
34341
34337
|
continue;
|
|
34342
34338
|
}
|
|
@@ -34385,13 +34381,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
34385
34381
|
let parsedFiles = 0;
|
|
34386
34382
|
for (const rel of changedRelPaths) {
|
|
34387
34383
|
if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
|
|
34388
|
-
const abs =
|
|
34384
|
+
const abs = join13(rootPath, ...rel.split("/"));
|
|
34389
34385
|
const ext = extname(abs).toLowerCase();
|
|
34390
34386
|
const provider = providers.find((p) => p.fileExtensions.includes(ext));
|
|
34391
34387
|
if (!provider) continue;
|
|
34392
34388
|
let symbols;
|
|
34393
34389
|
try {
|
|
34394
|
-
symbols = provider.extractSymbols(
|
|
34390
|
+
symbols = provider.extractSymbols(readFileSync12(abs, "utf8"), abs);
|
|
34395
34391
|
} catch {
|
|
34396
34392
|
continue;
|
|
34397
34393
|
}
|
|
@@ -34711,7 +34707,7 @@ async function runIndexer(store, opts) {
|
|
|
34711
34707
|
report.filesSkipped++;
|
|
34712
34708
|
continue;
|
|
34713
34709
|
}
|
|
34714
|
-
source =
|
|
34710
|
+
source = readFileSync12(f.absPath, "utf8");
|
|
34715
34711
|
} catch {
|
|
34716
34712
|
report.filesSkipped++;
|
|
34717
34713
|
continue;
|
|
@@ -34783,7 +34779,7 @@ async function runIndexer(store, opts) {
|
|
|
34783
34779
|
const depth = fileNode.relPath.split("/").length;
|
|
34784
34780
|
if (depth !== 3) continue;
|
|
34785
34781
|
try {
|
|
34786
|
-
const pkg = JSON.parse(
|
|
34782
|
+
const pkg = JSON.parse(readFileSync12(fileNode.absPath, "utf8"));
|
|
34787
34783
|
if (!pkg.name) continue;
|
|
34788
34784
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
34789
34785
|
const candidates = [
|
|
@@ -35171,7 +35167,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
35171
35167
|
for (const ent of entries) {
|
|
35172
35168
|
if (ignores.has(ent.name)) continue;
|
|
35173
35169
|
if (ent.name.startsWith(".") && ent.name !== ".") continue;
|
|
35174
|
-
const abs =
|
|
35170
|
+
const abs = join13(current, ent.name);
|
|
35175
35171
|
if (ent.isDirectory()) {
|
|
35176
35172
|
await scan(root, abs, ignores, providers, out2);
|
|
35177
35173
|
} else if (ent.isFile()) {
|
|
@@ -35230,7 +35226,7 @@ function gitListFiles(root, ignores, providers) {
|
|
|
35230
35226
|
if (rels === null) return null;
|
|
35231
35227
|
const out2 = [];
|
|
35232
35228
|
for (const rel of rels) {
|
|
35233
|
-
const abs =
|
|
35229
|
+
const abs = join13(root, rel);
|
|
35234
35230
|
let size;
|
|
35235
35231
|
let mtimeMs;
|
|
35236
35232
|
try {
|
|
@@ -35259,7 +35255,7 @@ function upsertFile(store, id, f, workspaceId2, skip) {
|
|
|
35259
35255
|
if (existing && fileUnchanged(existing.attrs, f, skip)) return;
|
|
35260
35256
|
let contentHash;
|
|
35261
35257
|
try {
|
|
35262
|
-
contentHash = createHash7("sha256").update(
|
|
35258
|
+
contentHash = createHash7("sha256").update(readFileSync12(f.absPath)).digest("hex");
|
|
35263
35259
|
} catch {
|
|
35264
35260
|
}
|
|
35265
35261
|
const carried = { ...existing?.attrs ?? {} };
|
|
@@ -39642,8 +39638,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
39642
39638
|
|
|
39643
39639
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
39644
39640
|
import { fileURLToPath } from "node:url";
|
|
39645
|
-
import { dirname as dirname7, join as
|
|
39646
|
-
import { existsSync as
|
|
39641
|
+
import { dirname as dirname7, join as join14 } from "node:path";
|
|
39642
|
+
import { existsSync as existsSync14, readdirSync as readdirSync3 } from "node:fs";
|
|
39647
39643
|
import { createRequire as createRequire2 } from "node:module";
|
|
39648
39644
|
function entryDir() {
|
|
39649
39645
|
try {
|
|
@@ -39657,27 +39653,27 @@ function entryDir() {
|
|
|
39657
39653
|
}
|
|
39658
39654
|
function findWasmDir() {
|
|
39659
39655
|
const here = entryDir();
|
|
39660
|
-
const seaWasm =
|
|
39661
|
-
if (
|
|
39656
|
+
const seaWasm = join14(here, "resources", "wasm");
|
|
39657
|
+
if (existsSync14(join14(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
39662
39658
|
let dir = here;
|
|
39663
39659
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39664
|
-
const flat =
|
|
39660
|
+
const flat = join14(
|
|
39665
39661
|
dir,
|
|
39666
39662
|
"node_modules",
|
|
39667
39663
|
"@vscode",
|
|
39668
39664
|
"tree-sitter-wasm",
|
|
39669
39665
|
"wasm"
|
|
39670
39666
|
);
|
|
39671
|
-
if (
|
|
39667
|
+
if (existsSync14(join14(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
39672
39668
|
dir = dirname7(dir);
|
|
39673
39669
|
}
|
|
39674
39670
|
let root = here;
|
|
39675
39671
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39676
|
-
const pnpmDir =
|
|
39677
|
-
if (
|
|
39672
|
+
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
39673
|
+
if (existsSync14(pnpmDir)) {
|
|
39678
39674
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
39679
39675
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
39680
|
-
const candidate =
|
|
39676
|
+
const candidate = join14(
|
|
39681
39677
|
pnpmDir,
|
|
39682
39678
|
entry,
|
|
39683
39679
|
"node_modules",
|
|
@@ -39685,7 +39681,7 @@ function findWasmDir() {
|
|
|
39685
39681
|
"tree-sitter-wasm",
|
|
39686
39682
|
"wasm"
|
|
39687
39683
|
);
|
|
39688
|
-
if (
|
|
39684
|
+
if (existsSync14(join14(candidate, "tree-sitter-typescript.wasm"))) {
|
|
39689
39685
|
return candidate;
|
|
39690
39686
|
}
|
|
39691
39687
|
}
|
|
@@ -39699,27 +39695,27 @@ function findWasmDir() {
|
|
|
39699
39695
|
}
|
|
39700
39696
|
function findRuntimeDir() {
|
|
39701
39697
|
const here = entryDir();
|
|
39702
|
-
const seaRuntime =
|
|
39703
|
-
if (
|
|
39698
|
+
const seaRuntime = join14(here, "resources", "wasm");
|
|
39699
|
+
if (existsSync14(join14(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
39704
39700
|
let dir = here;
|
|
39705
39701
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39706
|
-
const flat =
|
|
39707
|
-
if (
|
|
39702
|
+
const flat = join14(dir, "node_modules", "web-tree-sitter");
|
|
39703
|
+
if (existsSync14(join14(flat, "web-tree-sitter.wasm"))) return flat;
|
|
39708
39704
|
dir = dirname7(dir);
|
|
39709
39705
|
}
|
|
39710
39706
|
let root = here;
|
|
39711
39707
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
39712
|
-
const pnpmDir =
|
|
39713
|
-
if (
|
|
39708
|
+
const pnpmDir = join14(root, "node_modules", ".pnpm");
|
|
39709
|
+
if (existsSync14(pnpmDir)) {
|
|
39714
39710
|
for (const entry of readdirSync3(pnpmDir)) {
|
|
39715
39711
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
39716
|
-
const candidate =
|
|
39712
|
+
const candidate = join14(
|
|
39717
39713
|
pnpmDir,
|
|
39718
39714
|
entry,
|
|
39719
39715
|
"node_modules",
|
|
39720
39716
|
"web-tree-sitter"
|
|
39721
39717
|
);
|
|
39722
|
-
if (
|
|
39718
|
+
if (existsSync14(join14(candidate, "web-tree-sitter.wasm"))) {
|
|
39723
39719
|
return candidate;
|
|
39724
39720
|
}
|
|
39725
39721
|
}
|
|
@@ -39736,7 +39732,7 @@ async function loadWebTreeSitter() {
|
|
|
39736
39732
|
void err2;
|
|
39737
39733
|
}
|
|
39738
39734
|
const here = entryDir();
|
|
39739
|
-
const seaResourceBase =
|
|
39735
|
+
const seaResourceBase = join14(here, "resources", "_resolve.js");
|
|
39740
39736
|
const resourceRequire = createRequire2(seaResourceBase);
|
|
39741
39737
|
return resourceRequire("web-tree-sitter");
|
|
39742
39738
|
}
|
|
@@ -39751,9 +39747,9 @@ async function ensureTreeSitterReady() {
|
|
|
39751
39747
|
await Parser2.init({
|
|
39752
39748
|
locateFile: (name2) => {
|
|
39753
39749
|
if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
|
|
39754
|
-
return
|
|
39750
|
+
return join14(runtime, name2);
|
|
39755
39751
|
}
|
|
39756
|
-
return
|
|
39752
|
+
return join14(grammars, name2);
|
|
39757
39753
|
}
|
|
39758
39754
|
});
|
|
39759
39755
|
})();
|
|
@@ -39765,7 +39761,7 @@ async function loadGrammar(name2) {
|
|
|
39765
39761
|
if (cached2) return cached2;
|
|
39766
39762
|
if (!languageClass) throw new Error("tree-sitter not initialized");
|
|
39767
39763
|
const grammars = findWasmDir();
|
|
39768
|
-
const lang = await languageClass.load(
|
|
39764
|
+
const lang = await languageClass.load(join14(grammars, `${name2}.wasm`));
|
|
39769
39765
|
grammarCache.set(name2, lang);
|
|
39770
39766
|
return lang;
|
|
39771
39767
|
}
|
|
@@ -42670,7 +42666,7 @@ var init_src11 = __esm({
|
|
|
42670
42666
|
// src/reconcile.ts
|
|
42671
42667
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
42672
42668
|
import { readdirSync as readdirSync4, statSync as statSync4 } from "node:fs";
|
|
42673
|
-
import { join as
|
|
42669
|
+
import { join as join15, relative as relative3, sep as sep2 } from "node:path";
|
|
42674
42670
|
function indexerWouldScan(rel) {
|
|
42675
42671
|
for (const seg of rel.split(/[\\/]/)) {
|
|
42676
42672
|
if (seg.length === 0) continue;
|
|
@@ -42693,7 +42689,7 @@ function gitSourceFiles(root) {
|
|
|
42693
42689
|
const out2 = [];
|
|
42694
42690
|
for (const rel of stdout.split("\0")) {
|
|
42695
42691
|
if (!rel || !SOURCE_RE.test(rel) || !indexerWouldScan(rel)) continue;
|
|
42696
|
-
const abs =
|
|
42692
|
+
const abs = join15(root, rel);
|
|
42697
42693
|
if (IGNORED.test(abs)) continue;
|
|
42698
42694
|
out2.push(abs);
|
|
42699
42695
|
}
|
|
@@ -42708,7 +42704,7 @@ function* walkSource(dir) {
|
|
|
42708
42704
|
}
|
|
42709
42705
|
for (const e of entries) {
|
|
42710
42706
|
const name2 = String(e.name);
|
|
42711
|
-
const full =
|
|
42707
|
+
const full = join15(dir, name2);
|
|
42712
42708
|
if (IGNORED.test(full)) continue;
|
|
42713
42709
|
if (!indexerWouldScan(name2)) continue;
|
|
42714
42710
|
if (e.isDirectory()) yield* walkSource(full);
|
|
@@ -42858,7 +42854,7 @@ __export(mcp_exports, {
|
|
|
42858
42854
|
runTool: () => runTool,
|
|
42859
42855
|
searchGraph: () => searchGraph
|
|
42860
42856
|
});
|
|
42861
|
-
import { existsSync as
|
|
42857
|
+
import { existsSync as existsSync15, readFileSync as readFileSync13 } from "node:fs";
|
|
42862
42858
|
import { resolve as resolve3 } from "node:path";
|
|
42863
42859
|
function collectEnrichmentPulls(store, opts = {}) {
|
|
42864
42860
|
const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
|
|
@@ -42895,7 +42891,7 @@ function takeEnrichmentNudge(store) {
|
|
|
42895
42891
|
` + items;
|
|
42896
42892
|
}
|
|
42897
42893
|
function takeDiscriminatorNudge(path2) {
|
|
42898
|
-
if (!path2 || !
|
|
42894
|
+
if (!path2 || !existsSync15(path2)) return null;
|
|
42899
42895
|
let shared;
|
|
42900
42896
|
try {
|
|
42901
42897
|
shared = openGraphStore({ path: path2 });
|
|
@@ -43026,10 +43022,10 @@ function showNode(store, node2, maxLines) {
|
|
|
43026
43022
|
if (!relPath) return { found: false, reason: "no file owner for node" };
|
|
43027
43023
|
const workspaceRoot = process.cwd();
|
|
43028
43024
|
const absPath = resolve3(workspaceRoot, relPath);
|
|
43029
|
-
if (!
|
|
43025
|
+
if (!existsSync15(absPath)) {
|
|
43030
43026
|
return { found: false, reason: `file not found on disk: ${absPath}` };
|
|
43031
43027
|
}
|
|
43032
|
-
const source =
|
|
43028
|
+
const source = readFileSync13(absPath, "utf8");
|
|
43033
43029
|
const attrs = node2.attrs;
|
|
43034
43030
|
let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
|
|
43035
43031
|
let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
|
|
@@ -43786,7 +43782,7 @@ var init_mcp = __esm({
|
|
|
43786
43782
|
const local = causalChain(store, { seedId: id, direction: "both", maxHops, limit });
|
|
43787
43783
|
try {
|
|
43788
43784
|
const path2 = sharedStorePath();
|
|
43789
|
-
if (!
|
|
43785
|
+
if (!existsSync15(path2)) return { found: true, ...local };
|
|
43790
43786
|
const shared = openGraphStore({ path: path2 });
|
|
43791
43787
|
try {
|
|
43792
43788
|
if (!shared.getNode(id)) return { found: true, ...local };
|
|
@@ -44387,7 +44383,7 @@ var init_mcp = __esm({
|
|
|
44387
44383
|
inputSchema: { type: "object", properties: {} },
|
|
44388
44384
|
handler: () => {
|
|
44389
44385
|
const path2 = sharedStorePath();
|
|
44390
|
-
if (!
|
|
44386
|
+
if (!existsSync15(path2)) return { count: 0, pending: [] };
|
|
44391
44387
|
const shared = openGraphStore({ path: path2 });
|
|
44392
44388
|
try {
|
|
44393
44389
|
const pending = pendingAbstractions(shared);
|
|
@@ -44415,7 +44411,7 @@ var init_mcp = __esm({
|
|
|
44415
44411
|
},
|
|
44416
44412
|
handler: (args2) => {
|
|
44417
44413
|
const path2 = sharedStorePath();
|
|
44418
|
-
if (!
|
|
44414
|
+
if (!existsSync15(path2)) return { count: 0, pending: [] };
|
|
44419
44415
|
const shared = openGraphStore({ path: path2 });
|
|
44420
44416
|
try {
|
|
44421
44417
|
const pending = pendingDiscriminators(shared, {
|
|
@@ -44459,7 +44455,7 @@ var init_mcp = __esm({
|
|
|
44459
44455
|
},
|
|
44460
44456
|
handler: (args2) => {
|
|
44461
44457
|
const path2 = sharedStorePath();
|
|
44462
|
-
if (!
|
|
44458
|
+
if (!existsSync15(path2)) return { count: 0, routes: [] };
|
|
44463
44459
|
const shared = openGraphStore({ path: path2 });
|
|
44464
44460
|
try {
|
|
44465
44461
|
const result = triageOf(shared, {
|
|
@@ -44844,8 +44840,8 @@ __export(vfile_exports, {
|
|
|
44844
44840
|
resolvePath: () => resolvePath,
|
|
44845
44841
|
segmentsOf: () => segmentsOf
|
|
44846
44842
|
});
|
|
44847
|
-
import { writeFileSync as
|
|
44848
|
-
import { join as
|
|
44843
|
+
import { writeFileSync as writeFileSync11 } from "node:fs";
|
|
44844
|
+
import { join as join16, resolve as resolve4, sep as sep3 } from "node:path";
|
|
44849
44845
|
function segmentsOf(rawPath) {
|
|
44850
44846
|
let p = rawPath.replace(/\\/g, "/");
|
|
44851
44847
|
p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
|
|
@@ -44919,14 +44915,14 @@ async function renderVFile(rawPath, store, ctx = {}) {
|
|
|
44919
44915
|
}
|
|
44920
44916
|
async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
|
|
44921
44917
|
const segs = segmentsOf(rawPath);
|
|
44922
|
-
const gRoot =
|
|
44918
|
+
const gRoot = join16(workspaceRoot, ".errata", "g");
|
|
44923
44919
|
const abs = resolve4(gRoot, ...segs.length ? segs : ["index"]);
|
|
44924
44920
|
if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
|
|
44925
44921
|
throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
|
|
44926
44922
|
}
|
|
44927
44923
|
const text = await renderVFile(rawPath, store, ctx);
|
|
44928
44924
|
ensureParent(abs);
|
|
44929
|
-
|
|
44925
|
+
writeFileSync11(abs, text, "utf8");
|
|
44930
44926
|
return abs;
|
|
44931
44927
|
}
|
|
44932
44928
|
async function materializeOverview(workspaceRoot, store, ctx = {}) {
|
|
@@ -52346,25 +52342,25 @@ var init_tool_index = __esm({
|
|
|
52346
52342
|
|
|
52347
52343
|
// src/outbox.ts
|
|
52348
52344
|
import {
|
|
52349
|
-
existsSync as
|
|
52345
|
+
existsSync as existsSync16,
|
|
52350
52346
|
readdirSync as readdirSync5,
|
|
52351
|
-
readFileSync as
|
|
52347
|
+
readFileSync as readFileSync14,
|
|
52352
52348
|
renameSync,
|
|
52353
52349
|
unlinkSync,
|
|
52354
|
-
writeFileSync as
|
|
52350
|
+
writeFileSync as writeFileSync12
|
|
52355
52351
|
} from "node:fs";
|
|
52356
|
-
import { join as
|
|
52352
|
+
import { join as join17 } from "node:path";
|
|
52357
52353
|
import { createHash as createHash15 } from "node:crypto";
|
|
52358
52354
|
function enqueueOutbox(paths, payload) {
|
|
52359
52355
|
ensureDir(paths.outbox);
|
|
52360
52356
|
const id = createHash15("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
52361
|
-
const file2 =
|
|
52362
|
-
|
|
52357
|
+
const file2 = join17(paths.outbox, `${Date.now()}-${id}.json`);
|
|
52358
|
+
writeFileSync12(file2, JSON.stringify(payload, null, 2), "utf8");
|
|
52363
52359
|
return file2;
|
|
52364
52360
|
}
|
|
52365
52361
|
async function flushOutbox(paths, client, store) {
|
|
52366
52362
|
ensureDir(paths.outbox);
|
|
52367
|
-
const entries =
|
|
52363
|
+
const entries = existsSync16(paths.outbox) ? readdirSync5(paths.outbox) : [];
|
|
52368
52364
|
let uploaded = 0;
|
|
52369
52365
|
let failed = 0;
|
|
52370
52366
|
const quarantine = (abs, reason) => {
|
|
@@ -52375,10 +52371,10 @@ async function flushOutbox(paths, client, store) {
|
|
|
52375
52371
|
}
|
|
52376
52372
|
};
|
|
52377
52373
|
for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
|
|
52378
|
-
const abs =
|
|
52374
|
+
const abs = join17(paths.outbox, f);
|
|
52379
52375
|
let payload;
|
|
52380
52376
|
try {
|
|
52381
|
-
payload = JSON.parse(
|
|
52377
|
+
payload = JSON.parse(readFileSync14(abs, "utf8"));
|
|
52382
52378
|
} catch {
|
|
52383
52379
|
failed++;
|
|
52384
52380
|
quarantine(abs, "unparseable JSON");
|
|
@@ -52423,7 +52419,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
52423
52419
|
}
|
|
52424
52420
|
}
|
|
52425
52421
|
}
|
|
52426
|
-
const remainingFiles =
|
|
52422
|
+
const remainingFiles = existsSync16(paths.outbox) ? readdirSync5(paths.outbox).filter((e) => e.endsWith(".json")) : [];
|
|
52427
52423
|
return { uploaded, failed, remaining: remainingFiles.length };
|
|
52428
52424
|
}
|
|
52429
52425
|
var init_outbox = __esm({
|
|
@@ -52562,31 +52558,26 @@ function fileRecall(store, relPath) {
|
|
|
52562
52558
|
priors.constraints.sort(byRank);
|
|
52563
52559
|
priors.related.sort(byRank);
|
|
52564
52560
|
const lines = [];
|
|
52565
|
-
|
|
52561
|
+
const shownProblems = priors.openProblems.slice(0, 3);
|
|
52562
|
+
const shownConstraints = priors.constraints.slice(0, 2);
|
|
52563
|
+
const shownRelated = priors.related.slice(0, 4);
|
|
52564
|
+
for (const p of shownProblems) {
|
|
52566
52565
|
const hasCause = store.outEdges(p.id, ["CAUSED_BY"]).some((e) => store.getNode(e.to)?.label === "RootCause");
|
|
52567
52566
|
const causeCue = hasCause ? "" : ` \xB7 ${TAG_EXAMPLE.triageMint()} to diagnose its cause`;
|
|
52568
52567
|
lines.push(
|
|
52569
52568
|
recallLine(p, `${TAG_EXAMPLE.fix(p.id)} if you resolved it \xB7 ${TAG_EXAMPLE.prior(p.id)} to cite${causeCue}`)
|
|
52570
52569
|
);
|
|
52571
52570
|
}
|
|
52572
|
-
for (const c of
|
|
52571
|
+
for (const c of shownConstraints) {
|
|
52573
52572
|
lines.push(recallLine(c, `design tension \u2014 hold it, don't "fix" it \xB7 ${TAG_EXAMPLE.prior(c.id)} to cite`));
|
|
52574
52573
|
}
|
|
52575
|
-
for (const n of
|
|
52574
|
+
for (const n of shownRelated) {
|
|
52576
52575
|
lines.push(recallLine(n, `cite with ${TAG_EXAMPLE.prior(n.id)}`));
|
|
52577
52576
|
}
|
|
52578
52577
|
const total = pool.length;
|
|
52579
|
-
const
|
|
52580
|
-
const
|
|
52581
|
-
const
|
|
52582
|
-
const missing = /* @__PURE__ */ new Set();
|
|
52583
|
-
for (const p of chainProblems) {
|
|
52584
|
-
if (!scoreOf.has(p.id)) missing.add(p.id);
|
|
52585
|
-
for (const e of store.outEdges(p.id, ["CAUSED_BY", "SOLVED_BY"])) if (!scoreOf.has(e.to)) missing.add(e.to);
|
|
52586
|
-
}
|
|
52587
|
-
for (const r of rankByRelevance(store, priors.file.id, [...missing])) scoreOf.set(r.id, r.score);
|
|
52588
|
-
const chains = causalChains(store, chainProblems, (id) => scoreOf.get(id) ?? 0);
|
|
52589
|
-
const card = signalCard(headline, ranked, chains, scoreOf) ?? { headline, items: [] };
|
|
52578
|
+
const shown = [...shownProblems, ...shownConstraints, ...shownRelated].map(deliveredPrior);
|
|
52579
|
+
const headline = `${plural(shown.length, "prior")} on ${relPath.split("/").slice(-2).join("/")}`;
|
|
52580
|
+
const card = deliveredCard(store, headline, shown) ?? { headline, items: [] };
|
|
52590
52581
|
return {
|
|
52591
52582
|
context: `errata \u2014 ${total} prior(s) recorded on this file (act only if relevant):
|
|
52592
52583
|
${lines.join("\n")}
|
|
@@ -52975,30 +52966,28 @@ function buildWebUi(deps) {
|
|
|
52975
52966
|
return c.json({});
|
|
52976
52967
|
}
|
|
52977
52968
|
const sid = String(body2["session_id"] ?? "");
|
|
52978
|
-
const prompt = typeof body2["prompt"] === "string" ? body2["prompt"] : "";
|
|
52979
52969
|
const hookEvent = String(body2["hook_event_name"] ?? "UserPromptSubmit");
|
|
52980
|
-
|
|
52981
|
-
|
|
52970
|
+
const atPrompt = hookEvent === "UserPromptSubmit" || hookEvent === "SessionStart";
|
|
52971
|
+
if (sid && recallCardEnabled() && atPrompt) {
|
|
52982
52972
|
setImmediate(() => {
|
|
52983
52973
|
try {
|
|
52984
52974
|
rememberOpenCount(sid, openProblemCount(deps.store));
|
|
52985
52975
|
} catch {
|
|
52986
52976
|
}
|
|
52987
|
-
if (!prompt.trim()) return;
|
|
52988
|
-
promptRecallCard(deps.store, prompt).then((card) => {
|
|
52989
|
-
if (card) rememberCard(sid, card, Date.now(), since);
|
|
52990
|
-
}).catch(() => {
|
|
52991
|
-
});
|
|
52992
52977
|
});
|
|
52993
52978
|
}
|
|
52994
52979
|
const block = readContextFileWithHash(deps.paths.root);
|
|
52995
52980
|
const decision = decideContextInject({
|
|
52996
|
-
event:
|
|
52981
|
+
event: hookEvent,
|
|
52997
52982
|
source: String(body2["source"] ?? ""),
|
|
52998
|
-
sessionId:
|
|
52983
|
+
sessionId: sid,
|
|
52999
52984
|
block,
|
|
53000
52985
|
lastInjectedHash
|
|
53001
52986
|
});
|
|
52987
|
+
if (sid && block && recallCardEnabled() && (decision || atPrompt)) {
|
|
52988
|
+
const card = readContextCard(deps.paths.root, block.hash);
|
|
52989
|
+
if (card) rememberCard(sid, card);
|
|
52990
|
+
}
|
|
53002
52991
|
if (!decision) return c.json({});
|
|
53003
52992
|
return c.json({
|
|
53004
52993
|
hookSpecificOutput: {
|
|
@@ -72038,27 +72027,27 @@ __export(witness_ledger_exports, {
|
|
|
72038
72027
|
summarizeWitnessLedger: () => summarizeWitnessLedger,
|
|
72039
72028
|
witnessLedgerPath: () => witnessLedgerPath
|
|
72040
72029
|
});
|
|
72041
|
-
import { appendFileSync as appendFileSync3, existsSync as
|
|
72042
|
-
import { join as
|
|
72030
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync25, readFileSync as readFileSync27, writeFileSync as writeFileSync20 } from "node:fs";
|
|
72031
|
+
import { join as join33 } from "node:path";
|
|
72043
72032
|
function witnessLedgerPath(configDir) {
|
|
72044
|
-
return
|
|
72033
|
+
return join33(configDir, "witness-ledger.jsonl");
|
|
72045
72034
|
}
|
|
72046
72035
|
function appendWitnessLedger(configDir, entry) {
|
|
72047
72036
|
const path2 = witnessLedgerPath(configDir);
|
|
72048
72037
|
try {
|
|
72049
72038
|
appendFileSync3(path2, JSON.stringify(entry) + "\n");
|
|
72050
|
-
const lines =
|
|
72039
|
+
const lines = readFileSync27(path2, "utf8").split("\n").filter(Boolean);
|
|
72051
72040
|
if (lines.length > LEDGER_MAX_LINES) {
|
|
72052
|
-
|
|
72041
|
+
writeFileSync20(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
|
|
72053
72042
|
}
|
|
72054
72043
|
} catch {
|
|
72055
72044
|
}
|
|
72056
72045
|
}
|
|
72057
72046
|
function readWitnessLedger(configDir) {
|
|
72058
72047
|
const path2 = witnessLedgerPath(configDir);
|
|
72059
|
-
if (!
|
|
72048
|
+
if (!existsSync25(path2)) return [];
|
|
72060
72049
|
try {
|
|
72061
|
-
return
|
|
72050
|
+
return readFileSync27(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
|
|
72062
72051
|
} catch {
|
|
72063
72052
|
return [];
|
|
72064
72053
|
}
|
|
@@ -72497,12 +72486,12 @@ var init_report_render = __esm({
|
|
|
72497
72486
|
|
|
72498
72487
|
// src/cli.ts
|
|
72499
72488
|
init_src6();
|
|
72500
|
-
import { closeSync as closeSync2, existsSync as
|
|
72501
|
-
import { join as
|
|
72489
|
+
import { closeSync as closeSync2, existsSync as existsSync36, openSync as openSync2, readFileSync as readFileSync37, renameSync as renameSync4, statSync as statSync10 } from "node:fs";
|
|
72490
|
+
import { join as join44, resolve as pathResolve2 } from "node:path";
|
|
72502
72491
|
import { spawn as spawn5 } from "node:child_process";
|
|
72503
72492
|
|
|
72504
72493
|
// src/daemon.ts
|
|
72505
|
-
import { existsSync as
|
|
72494
|
+
import { existsSync as existsSync27, writeFileSync as writeFileSync23 } from "node:fs";
|
|
72506
72495
|
|
|
72507
72496
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
|
|
72508
72497
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -73082,13 +73071,13 @@ init_config();
|
|
|
73082
73071
|
|
|
73083
73072
|
// src/engine.ts
|
|
73084
73073
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
73085
|
-
import { existsSync as
|
|
73086
|
-
import { basename as basename7, join as
|
|
73074
|
+
import { existsSync as existsSync26, statSync as statSync8, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync29, writeFileSync as writeFileSync22 } from "node:fs";
|
|
73075
|
+
import { basename as basename7, join as join35, relative as relative6, sep as sep4 } from "node:path";
|
|
73087
73076
|
|
|
73088
73077
|
// src/source-watcher.ts
|
|
73089
73078
|
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
73090
73079
|
import { statSync as statSync5, watch as watch2 } from "node:fs";
|
|
73091
|
-
import { join as
|
|
73080
|
+
import { join as join20 } from "node:path";
|
|
73092
73081
|
|
|
73093
73082
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
73094
73083
|
import { stat as statcb } from "fs";
|
|
@@ -74821,7 +74810,7 @@ var NativeSourceWatcher = class extends EventEmitter2 {
|
|
|
74821
74810
|
}
|
|
74822
74811
|
try {
|
|
74823
74812
|
const h = watch2(target, { recursive: isDir, persistent: true }, (event, name2) => {
|
|
74824
|
-
const path2 = isDir ? name2 ?
|
|
74813
|
+
const path2 = isDir ? name2 ? join20(target, name2.toString()) : null : target;
|
|
74825
74814
|
if (!path2) return;
|
|
74826
74815
|
this.emit("raw", event, path2, { watchedPath: target });
|
|
74827
74816
|
if (!this.ignored(path2)) this.schedule(path2, event === "rename");
|
|
@@ -75121,13 +75110,14 @@ async function chat(req) {
|
|
|
75121
75110
|
// src/engine.ts
|
|
75122
75111
|
init_src11();
|
|
75123
75112
|
init_src6();
|
|
75113
|
+
init_recall_signal();
|
|
75124
75114
|
init_src8();
|
|
75125
75115
|
init_review2();
|
|
75126
75116
|
|
|
75127
75117
|
// src/turn.ts
|
|
75128
75118
|
init_checkout_root();
|
|
75129
|
-
import { closeSync, existsSync as
|
|
75130
|
-
import { basename as basename5, delimiter, dirname as dirname10, join as
|
|
75119
|
+
import { closeSync, existsSync as existsSync17, fstatSync, openSync, readdirSync as readdirSync6, readSync, realpathSync, statSync as statSync6 } from "node:fs";
|
|
75120
|
+
import { basename as basename5, delimiter, dirname as dirname10, join as join21, normalize as normalize3 } from "node:path";
|
|
75131
75121
|
import { homedir as homedir4 } from "node:os";
|
|
75132
75122
|
import { createHash as createHash16 } from "node:crypto";
|
|
75133
75123
|
function completeJsonlPrefix(buf) {
|
|
@@ -75515,11 +75505,11 @@ function turnsSince(turns, mark) {
|
|
|
75515
75505
|
return at >= 0 ? turns.slice(at + 1) : turns;
|
|
75516
75506
|
}
|
|
75517
75507
|
function claudeProjectDir(cwd, home = homedir4()) {
|
|
75518
|
-
return
|
|
75508
|
+
return join21(home, ".claude", "projects", cwd.replace(/[\\/:.]/g, "-"));
|
|
75519
75509
|
}
|
|
75520
75510
|
function recentTranscripts(cwd, opts = {}) {
|
|
75521
75511
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir4());
|
|
75522
|
-
if (!
|
|
75512
|
+
if (!existsSync17(dir)) return [];
|
|
75523
75513
|
let names;
|
|
75524
75514
|
try {
|
|
75525
75515
|
names = readdirSync6(dir);
|
|
@@ -75530,7 +75520,7 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
75530
75520
|
const refs = [];
|
|
75531
75521
|
for (const name2 of names) {
|
|
75532
75522
|
if (!name2.endsWith(".jsonl")) continue;
|
|
75533
|
-
const path2 =
|
|
75523
|
+
const path2 = join21(dir, name2);
|
|
75534
75524
|
let mtimeMs;
|
|
75535
75525
|
try {
|
|
75536
75526
|
mtimeMs = statSync6(path2).mtimeMs;
|
|
@@ -75545,8 +75535,8 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
75545
75535
|
}
|
|
75546
75536
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
75547
75537
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
75548
|
-
const dir =
|
|
75549
|
-
if (!
|
|
75538
|
+
const dir = join21(dirname10(mainTranscriptPath), sessionId, "subagents");
|
|
75539
|
+
if (!existsSync17(dir)) return [];
|
|
75550
75540
|
let names;
|
|
75551
75541
|
try {
|
|
75552
75542
|
names = readdirSync6(dir);
|
|
@@ -75556,7 +75546,7 @@ function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
|
75556
75546
|
const refs = [];
|
|
75557
75547
|
for (const name2 of names) {
|
|
75558
75548
|
if (!name2.endsWith(".jsonl")) continue;
|
|
75559
|
-
const path2 =
|
|
75549
|
+
const path2 = join21(dir, name2);
|
|
75560
75550
|
let mtimeMs;
|
|
75561
75551
|
try {
|
|
75562
75552
|
mtimeMs = statSync6(path2).mtimeMs;
|
|
@@ -75575,8 +75565,8 @@ function splitPathList(value, sep5 = delimiter) {
|
|
|
75575
75565
|
function codexSessionRoots(env2 = process.env, home = homedir4()) {
|
|
75576
75566
|
const roots = /* @__PURE__ */ new Set();
|
|
75577
75567
|
for (const d of splitPathList(env2["ERRATA_CODEX_SESSIONS_DIRS"])) roots.add(d);
|
|
75578
|
-
if (env2["CODEX_HOME"]) roots.add(
|
|
75579
|
-
roots.add(
|
|
75568
|
+
if (env2["CODEX_HOME"]) roots.add(join21(env2["CODEX_HOME"], "sessions"));
|
|
75569
|
+
roots.add(join21(home, ".codex", "sessions"));
|
|
75580
75570
|
return [...roots];
|
|
75581
75571
|
}
|
|
75582
75572
|
function readCodexRolloutIdentity(path2) {
|
|
@@ -75630,7 +75620,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
75630
75620
|
const owner = checkoutRootOf(cwd);
|
|
75631
75621
|
const owners = /* @__PURE__ */ new Map();
|
|
75632
75622
|
for (const root of codexSessionRoots(opts.env, opts.home)) {
|
|
75633
|
-
if (!
|
|
75623
|
+
if (!existsSync17(root)) {
|
|
75634
75624
|
codexRolloutActivity.delete(root);
|
|
75635
75625
|
continue;
|
|
75636
75626
|
}
|
|
@@ -75648,7 +75638,7 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
75648
75638
|
continue;
|
|
75649
75639
|
}
|
|
75650
75640
|
for (const name2 of names) {
|
|
75651
|
-
const full =
|
|
75641
|
+
const full = join21(dir, name2);
|
|
75652
75642
|
let st;
|
|
75653
75643
|
try {
|
|
75654
75644
|
st = statSync6(full);
|
|
@@ -75690,8 +75680,8 @@ function codexRolloutsForCwd(cwd, opts = {}) {
|
|
|
75690
75680
|
function geminiSessionRoots(env2 = process.env, home = homedir4()) {
|
|
75691
75681
|
const roots = /* @__PURE__ */ new Set();
|
|
75692
75682
|
for (const d of splitPathList(env2["ERRATA_GEMINI_SESSIONS_DIRS"])) roots.add(d);
|
|
75693
|
-
if (env2["GEMINI_CLI_HOME"]) roots.add(
|
|
75694
|
-
roots.add(
|
|
75683
|
+
if (env2["GEMINI_CLI_HOME"]) roots.add(join21(env2["GEMINI_CLI_HOME"], ".gemini", "tmp"));
|
|
75684
|
+
roots.add(join21(home, ".gemini", "tmp"));
|
|
75695
75685
|
return [...roots];
|
|
75696
75686
|
}
|
|
75697
75687
|
function geminiProjectHash(cwd) {
|
|
@@ -75731,7 +75721,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75731
75721
|
const hashes = geminiHashesFor(cwd);
|
|
75732
75722
|
const out2 = [];
|
|
75733
75723
|
for (const root of geminiSessionRoots(opts.env, opts.home)) {
|
|
75734
|
-
if (!
|
|
75724
|
+
if (!existsSync17(root)) continue;
|
|
75735
75725
|
let slugs;
|
|
75736
75726
|
try {
|
|
75737
75727
|
slugs = readdirSync6(root);
|
|
@@ -75739,7 +75729,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75739
75729
|
continue;
|
|
75740
75730
|
}
|
|
75741
75731
|
for (const slug2 of slugs) {
|
|
75742
|
-
const chats =
|
|
75732
|
+
const chats = join21(root, slug2, "chats");
|
|
75743
75733
|
let names;
|
|
75744
75734
|
try {
|
|
75745
75735
|
names = readdirSync6(chats);
|
|
@@ -75748,7 +75738,7 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75748
75738
|
}
|
|
75749
75739
|
for (const name2 of names) {
|
|
75750
75740
|
if (!name2.startsWith("session-") || !name2.endsWith(".jsonl")) continue;
|
|
75751
|
-
const full =
|
|
75741
|
+
const full = join21(chats, name2);
|
|
75752
75742
|
let st;
|
|
75753
75743
|
try {
|
|
75754
75744
|
st = statSync6(full);
|
|
@@ -75768,8 +75758,8 @@ function geminiTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75768
75758
|
function opencodeSessionRoots(env2 = process.env, home = homedir4()) {
|
|
75769
75759
|
const roots = /* @__PURE__ */ new Set();
|
|
75770
75760
|
for (const d of splitPathList(env2["ERRATA_OPENCODE_SESSIONS_DIRS"])) roots.add(d);
|
|
75771
|
-
if (env2["XDG_DATA_HOME"]) roots.add(
|
|
75772
|
-
roots.add(
|
|
75761
|
+
if (env2["XDG_DATA_HOME"]) roots.add(join21(env2["XDG_DATA_HOME"], "opencode", "errata"));
|
|
75762
|
+
roots.add(join21(home, ".local", "share", "opencode", "errata"));
|
|
75773
75763
|
return [...roots];
|
|
75774
75764
|
}
|
|
75775
75765
|
function readOpencodeTranscriptDirectory(path2) {
|
|
@@ -75802,7 +75792,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75802
75792
|
}
|
|
75803
75793
|
const out2 = [];
|
|
75804
75794
|
for (const root of opencodeSessionRoots(opts.env, opts.home)) {
|
|
75805
|
-
if (!
|
|
75795
|
+
if (!existsSync17(root)) continue;
|
|
75806
75796
|
let names;
|
|
75807
75797
|
try {
|
|
75808
75798
|
names = readdirSync6(root);
|
|
@@ -75811,7 +75801,7 @@ function opencodeTranscriptsForCwd(cwd, opts = {}) {
|
|
|
75811
75801
|
}
|
|
75812
75802
|
for (const name2 of names) {
|
|
75813
75803
|
if (!name2.endsWith(".jsonl")) continue;
|
|
75814
|
-
const full =
|
|
75804
|
+
const full = join21(root, name2);
|
|
75815
75805
|
let st;
|
|
75816
75806
|
try {
|
|
75817
75807
|
st = statSync6(full);
|
|
@@ -75834,7 +75824,7 @@ init_src2();
|
|
|
75834
75824
|
init_agent_signals();
|
|
75835
75825
|
init_tool_index();
|
|
75836
75826
|
init_src5();
|
|
75837
|
-
import { readFileSync as
|
|
75827
|
+
import { readFileSync as readFileSync15, writeFileSync as writeFileSync13 } from "node:fs";
|
|
75838
75828
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
75839
75829
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
75840
75830
|
var HANDLE_RE = /\[([a-z0-9][\w-]{0,80})\]|((?:pat|sol|drc|dcause|dfix|dprob|prob|claim|err)_[0-9a-f]{6,})/gi;
|
|
@@ -76523,13 +76513,13 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
|
|
|
76523
76513
|
entries.sort((a, b) => (b[1].seenAt ?? 0) - (a[1].seenAt ?? 0));
|
|
76524
76514
|
entries.length = HANDLE_MAP_MAX;
|
|
76525
76515
|
}
|
|
76526
|
-
|
|
76516
|
+
writeFileSync13(path2, JSON.stringify(Object.fromEntries(entries)));
|
|
76527
76517
|
} catch {
|
|
76528
76518
|
}
|
|
76529
76519
|
}
|
|
76530
76520
|
function readPrimingHandles(path2) {
|
|
76531
76521
|
try {
|
|
76532
|
-
return JSON.parse(
|
|
76522
|
+
return JSON.parse(readFileSync15(path2, "utf8"));
|
|
76533
76523
|
} catch {
|
|
76534
76524
|
return {};
|
|
76535
76525
|
}
|
|
@@ -77004,8 +76994,8 @@ ${conversation}` }]
|
|
|
77004
76994
|
// src/constraint-backfill.ts
|
|
77005
76995
|
init_src5();
|
|
77006
76996
|
init_src2();
|
|
77007
|
-
import { existsSync as
|
|
77008
|
-
import { join as
|
|
76997
|
+
import { existsSync as existsSync18, readFileSync as readFileSync16, readdirSync as readdirSync7, writeFileSync as writeFileSync14 } from "node:fs";
|
|
76998
|
+
import { join as join22 } from "node:path";
|
|
77009
76999
|
import { homedir as homedir5 } from "node:os";
|
|
77010
77000
|
var BACKFILL_VERSION = 1;
|
|
77011
77001
|
var EMPTY = {
|
|
@@ -77019,13 +77009,13 @@ var EMPTY = {
|
|
|
77019
77009
|
recoverable: 0
|
|
77020
77010
|
};
|
|
77021
77011
|
function markerPath(configDir) {
|
|
77022
|
-
return
|
|
77012
|
+
return join22(configDir, "constraint-backfill.json");
|
|
77023
77013
|
}
|
|
77024
77014
|
function alreadyDone(configDir) {
|
|
77025
77015
|
const p = markerPath(configDir);
|
|
77026
|
-
if (!
|
|
77016
|
+
if (!existsSync18(p)) return false;
|
|
77027
77017
|
try {
|
|
77028
|
-
const raw2 = JSON.parse(
|
|
77018
|
+
const raw2 = JSON.parse(readFileSync16(p, "utf8"));
|
|
77029
77019
|
return raw2?.version === BACKFILL_VERSION;
|
|
77030
77020
|
} catch {
|
|
77031
77021
|
return false;
|
|
@@ -77035,7 +77025,7 @@ function replay(root) {
|
|
|
77035
77025
|
const statements = /* @__PURE__ */ new Set();
|
|
77036
77026
|
const citedByFix = /* @__PURE__ */ new Set();
|
|
77037
77027
|
const dir = claudeProjectDir(root, homedir5());
|
|
77038
|
-
if (!
|
|
77028
|
+
if (!existsSync18(dir)) return { statements, citedByFix };
|
|
77039
77029
|
let names;
|
|
77040
77030
|
try {
|
|
77041
77031
|
names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -77045,7 +77035,7 @@ function replay(root) {
|
|
|
77045
77035
|
for (const f of names) {
|
|
77046
77036
|
let lines;
|
|
77047
77037
|
try {
|
|
77048
|
-
lines =
|
|
77038
|
+
lines = readFileSync16(join22(dir, f), "utf8").split("\n");
|
|
77049
77039
|
} catch {
|
|
77050
77040
|
continue;
|
|
77051
77041
|
}
|
|
@@ -77159,7 +77149,7 @@ function backfillConstraintKind(store, opts) {
|
|
|
77159
77149
|
}
|
|
77160
77150
|
});
|
|
77161
77151
|
try {
|
|
77162
|
-
|
|
77152
|
+
writeFileSync14(
|
|
77163
77153
|
markerPath(opts.configDir),
|
|
77164
77154
|
JSON.stringify({ version: BACKFILL_VERSION, at: opts.now, ...report, cloudTwins: report.cloudTwins.length }, null, 2),
|
|
77165
77155
|
"utf8"
|
|
@@ -77172,8 +77162,8 @@ function backfillConstraintKind(store, opts) {
|
|
|
77172
77162
|
// src/edge-repair.ts
|
|
77173
77163
|
init_src();
|
|
77174
77164
|
init_src5();
|
|
77175
|
-
import { existsSync as
|
|
77176
|
-
import { join as
|
|
77165
|
+
import { existsSync as existsSync19, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "node:fs";
|
|
77166
|
+
import { join as join23 } from "node:path";
|
|
77177
77167
|
function citeEdgeId(from, type, to) {
|
|
77178
77168
|
return `edge_${digest({ from, type, to })}`.slice(0, 24);
|
|
77179
77169
|
}
|
|
@@ -77188,13 +77178,13 @@ var EMPTY2 = {
|
|
|
77188
77178
|
byType: {}
|
|
77189
77179
|
};
|
|
77190
77180
|
function markerPath2(configDir) {
|
|
77191
|
-
return
|
|
77181
|
+
return join23(configDir, "edge-repair.json");
|
|
77192
77182
|
}
|
|
77193
77183
|
function alreadyDone2(configDir) {
|
|
77194
77184
|
const p = markerPath2(configDir);
|
|
77195
|
-
if (!
|
|
77185
|
+
if (!existsSync19(p)) return false;
|
|
77196
77186
|
try {
|
|
77197
|
-
return JSON.parse(
|
|
77187
|
+
return JSON.parse(readFileSync17(p, "utf8"))?.version === EDGE_REPAIR_VERSION;
|
|
77198
77188
|
} catch {
|
|
77199
77189
|
return false;
|
|
77200
77190
|
}
|
|
@@ -77243,7 +77233,7 @@ function repairInvalidEdges(store, opts) {
|
|
|
77243
77233
|
});
|
|
77244
77234
|
store.pruneEdgeRejections(opts.now - REJECTION_RETENTION_MS);
|
|
77245
77235
|
try {
|
|
77246
|
-
|
|
77236
|
+
writeFileSync15(
|
|
77247
77237
|
markerPath2(opts.configDir),
|
|
77248
77238
|
JSON.stringify({ version: EDGE_REPAIR_VERSION, at: opts.now, ...report }, null, 2),
|
|
77249
77239
|
"utf8"
|
|
@@ -77257,8 +77247,8 @@ function repairInvalidEdges(store, opts) {
|
|
|
77257
77247
|
init_reconcile();
|
|
77258
77248
|
|
|
77259
77249
|
// src/pass-ledger.ts
|
|
77260
|
-
import { appendFileSync as appendFileSync2, existsSync as
|
|
77261
|
-
import { join as
|
|
77250
|
+
import { appendFileSync as appendFileSync2, existsSync as existsSync20, readFileSync as readFileSync18, writeFileSync as writeFileSync16 } from "node:fs";
|
|
77251
|
+
import { join as join24 } from "node:path";
|
|
77262
77252
|
|
|
77263
77253
|
// src/isolate-census.ts
|
|
77264
77254
|
var live2 = 0;
|
|
@@ -77281,7 +77271,7 @@ var PER_KIND_MAX = 100;
|
|
|
77281
77271
|
var TRIM_EVERY = 50;
|
|
77282
77272
|
var appendsSinceTrim = /* @__PURE__ */ new Map();
|
|
77283
77273
|
function passLedgerPath(configDir) {
|
|
77284
|
-
return
|
|
77274
|
+
return join24(configDir, "pass-ledger.jsonl");
|
|
77285
77275
|
}
|
|
77286
77276
|
function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
77287
77277
|
const path2 = passLedgerPath(configDir);
|
|
@@ -77310,7 +77300,7 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77310
77300
|
return;
|
|
77311
77301
|
}
|
|
77312
77302
|
appendsSinceTrim.set(path2, 0);
|
|
77313
|
-
const lines =
|
|
77303
|
+
const lines = readFileSync18(path2, "utf8").split("\n").filter(Boolean);
|
|
77314
77304
|
const keptByKind = /* @__PURE__ */ new Map();
|
|
77315
77305
|
const kept = [];
|
|
77316
77306
|
for (let i2 = lines.length - 1; i2 >= 0; i2--) {
|
|
@@ -77326,16 +77316,16 @@ function appendPassLedger(configDir, kind, durationMs, counts) {
|
|
|
77326
77316
|
kept.push(lines[i2]);
|
|
77327
77317
|
}
|
|
77328
77318
|
if (kept.length < lines.length) {
|
|
77329
|
-
|
|
77319
|
+
writeFileSync16(path2, kept.reverse().join("\n") + "\n");
|
|
77330
77320
|
}
|
|
77331
77321
|
} catch {
|
|
77332
77322
|
}
|
|
77333
77323
|
}
|
|
77334
77324
|
function readPassLedger(configDir) {
|
|
77335
77325
|
const path2 = passLedgerPath(configDir);
|
|
77336
|
-
if (!
|
|
77326
|
+
if (!existsSync20(path2)) return [];
|
|
77337
77327
|
try {
|
|
77338
|
-
return
|
|
77328
|
+
return readFileSync18(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter(
|
|
77339
77329
|
(e) => typeof e?.ts === "number" && typeof e?.kind === "string" && typeof e?.durationMs === "number"
|
|
77340
77330
|
).map((e) => ({ ...e, counts: e.counts ?? {} }));
|
|
77341
77331
|
} catch {
|
|
@@ -77707,11 +77697,11 @@ init_outbox();
|
|
|
77707
77697
|
init_src10();
|
|
77708
77698
|
init_src();
|
|
77709
77699
|
init_src2();
|
|
77710
|
-
import { readFileSync as
|
|
77711
|
-
import { join as
|
|
77700
|
+
import { readFileSync as readFileSync19 } from "node:fs";
|
|
77701
|
+
import { join as join25 } from "node:path";
|
|
77712
77702
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
77713
77703
|
try {
|
|
77714
|
-
return
|
|
77704
|
+
return readFileSync19(join25(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
77715
77705
|
} catch {
|
|
77716
77706
|
return [];
|
|
77717
77707
|
}
|
|
@@ -78089,9 +78079,9 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
78089
78079
|
// src/retrieval-stack.ts
|
|
78090
78080
|
init_src();
|
|
78091
78081
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
78092
|
-
import { existsSync as
|
|
78082
|
+
import { existsSync as existsSync21, readFileSync as readFileSync20, statSync as statSync7 } from "node:fs";
|
|
78093
78083
|
import { homedir as homedir6 } from "node:os";
|
|
78094
|
-
import { join as
|
|
78084
|
+
import { join as join26 } from "node:path";
|
|
78095
78085
|
var RETRIEVAL_STACK_CAP = 24;
|
|
78096
78086
|
var MANIFEST_SCAN_CAP = 400;
|
|
78097
78087
|
var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
|
|
@@ -78381,51 +78371,51 @@ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
|
|
|
78381
78371
|
function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
78382
78372
|
const read2 = (p) => {
|
|
78383
78373
|
try {
|
|
78384
|
-
return
|
|
78374
|
+
return readFileSync20(p, "utf8");
|
|
78385
78375
|
} catch {
|
|
78386
78376
|
return null;
|
|
78387
78377
|
}
|
|
78388
78378
|
};
|
|
78389
78379
|
const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
|
|
78390
78380
|
const home = homedir6();
|
|
78391
|
-
const npm = parseNpmrcPolicy(texts(
|
|
78381
|
+
const npm = parseNpmrcPolicy(texts(join26(root, ".npmrc"), join26(home, ".npmrc")));
|
|
78392
78382
|
const blocked = /* @__PURE__ */ new Set();
|
|
78393
78383
|
if (!npm.defaultPublic) blocked.add("npm");
|
|
78394
78384
|
if (pypiIndexIsPrivate(
|
|
78395
78385
|
texts(
|
|
78396
|
-
|
|
78397
|
-
|
|
78398
|
-
|
|
78399
|
-
|
|
78400
|
-
|
|
78401
|
-
|
|
78402
|
-
|
|
78386
|
+
join26(root, "pip.conf"),
|
|
78387
|
+
join26(root, "pip.ini"),
|
|
78388
|
+
join26(root, "pyproject.toml"),
|
|
78389
|
+
join26(root, "requirements.txt"),
|
|
78390
|
+
join26(home, ".pip", "pip.conf"),
|
|
78391
|
+
join26(home, ".config", "pip", "pip.conf"),
|
|
78392
|
+
join26(env2["APPDATA"] ?? home, "pip", "pip.ini")
|
|
78403
78393
|
)
|
|
78404
78394
|
)) {
|
|
78405
78395
|
blocked.add("pypi");
|
|
78406
78396
|
}
|
|
78407
78397
|
if (cargoRegistryIsPrivate(
|
|
78408
78398
|
texts(
|
|
78409
|
-
|
|
78410
|
-
|
|
78411
|
-
|
|
78412
|
-
|
|
78399
|
+
join26(root, ".cargo", "config.toml"),
|
|
78400
|
+
join26(root, ".cargo", "config"),
|
|
78401
|
+
join26(home, ".cargo", "config.toml"),
|
|
78402
|
+
join26(home, ".cargo", "config")
|
|
78413
78403
|
)
|
|
78414
78404
|
)) {
|
|
78415
78405
|
blocked.add("cargo");
|
|
78416
78406
|
}
|
|
78417
78407
|
if (nugetSourcesArePrivate(
|
|
78418
78408
|
texts(
|
|
78419
|
-
|
|
78420
|
-
|
|
78421
|
-
|
|
78422
|
-
|
|
78423
|
-
|
|
78409
|
+
join26(root, "NuGet.config"),
|
|
78410
|
+
join26(root, "nuget.config"),
|
|
78411
|
+
join26(root, "NuGet.Config"),
|
|
78412
|
+
join26(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
|
|
78413
|
+
join26(home, ".nuget", "NuGet", "NuGet.Config")
|
|
78424
78414
|
)
|
|
78425
78415
|
)) {
|
|
78426
78416
|
blocked.add("nuget");
|
|
78427
78417
|
}
|
|
78428
|
-
const goEnvFile = env2["GOENV"] ??
|
|
78418
|
+
const goEnvFile = env2["GOENV"] ?? join26(env2["APPDATA"] ?? join26(home, ".config"), "go", "env");
|
|
78429
78419
|
const goEnvText = read2(goEnvFile) ?? "";
|
|
78430
78420
|
const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
|
|
78431
78421
|
(k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
|
|
@@ -78436,10 +78426,10 @@ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
|
|
|
78436
78426
|
env2["GONOSUMCHECK"],
|
|
78437
78427
|
...fromFile
|
|
78438
78428
|
]);
|
|
78439
|
-
const gemfiles = texts(
|
|
78429
|
+
const gemfiles = texts(join26(root, "Gemfile"));
|
|
78440
78430
|
if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
|
|
78441
78431
|
if (mavenReposArePrivate(
|
|
78442
|
-
texts(
|
|
78432
|
+
texts(join26(root, "pom.xml"), join26(home, ".m2", "settings.xml"))
|
|
78443
78433
|
)) {
|
|
78444
78434
|
blocked.add("maven");
|
|
78445
78435
|
}
|
|
@@ -78606,8 +78596,8 @@ function readDirectDependencies(root) {
|
|
|
78606
78596
|
const familiesSeen = /* @__PURE__ */ new Set();
|
|
78607
78597
|
for (const c of LOCKFILES) {
|
|
78608
78598
|
if (familiesSeen.has(c.family)) continue;
|
|
78609
|
-
const p =
|
|
78610
|
-
if (!
|
|
78599
|
+
const p = join26(root, c.file);
|
|
78600
|
+
if (!existsSync21(p)) continue;
|
|
78611
78601
|
try {
|
|
78612
78602
|
const s = statSync7(p);
|
|
78613
78603
|
stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
|
|
@@ -78627,7 +78617,7 @@ function readDirectDependencies(root) {
|
|
|
78627
78617
|
const direct = [];
|
|
78628
78618
|
for (const { c, path: path2 } of found) {
|
|
78629
78619
|
try {
|
|
78630
|
-
direct.push(...c.parse(
|
|
78620
|
+
direct.push(...c.parse(readFileSync20(path2, "utf8")).direct ?? []);
|
|
78631
78621
|
} catch {
|
|
78632
78622
|
}
|
|
78633
78623
|
}
|
|
@@ -78670,14 +78660,14 @@ function manifestPaths(root) {
|
|
|
78670
78660
|
"project.godot"
|
|
78671
78661
|
];
|
|
78672
78662
|
return {
|
|
78673
|
-
paths: ROOT_MANIFESTS.filter((f) =>
|
|
78663
|
+
paths: ROOT_MANIFESTS.filter((f) => existsSync21(join26(root, f))),
|
|
78674
78664
|
tracked: false,
|
|
78675
78665
|
truncated: false
|
|
78676
78666
|
};
|
|
78677
78667
|
}
|
|
78678
78668
|
var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
|
|
78679
78669
|
function rootDeclaresWorkspace(root, texts) {
|
|
78680
|
-
if (WORKSPACE_MARKERS.some((f) =>
|
|
78670
|
+
if (WORKSPACE_MARKERS.some((f) => existsSync21(join26(root, f)))) return true;
|
|
78681
78671
|
return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
|
|
78682
78672
|
}
|
|
78683
78673
|
var EMPTY_SCAN = { deps: [], self: [], complete: true };
|
|
@@ -78691,11 +78681,11 @@ function scanManifests(root) {
|
|
|
78691
78681
|
const texts = /* @__PURE__ */ new Map();
|
|
78692
78682
|
const stamps = [];
|
|
78693
78683
|
for (const rel of paths) {
|
|
78694
|
-
const abs =
|
|
78684
|
+
const abs = join26(root, rel);
|
|
78695
78685
|
try {
|
|
78696
78686
|
const s = statSync7(abs);
|
|
78697
78687
|
stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
|
|
78698
|
-
texts.set(rel,
|
|
78688
|
+
texts.set(rel, readFileSync20(abs, "utf8"));
|
|
78699
78689
|
} catch {
|
|
78700
78690
|
}
|
|
78701
78691
|
}
|
|
@@ -78724,22 +78714,22 @@ function readManifestDependencies(root) {
|
|
|
78724
78714
|
}
|
|
78725
78715
|
|
|
78726
78716
|
// src/git-sensor.ts
|
|
78727
|
-
import { existsSync as
|
|
78728
|
-
import { join as
|
|
78717
|
+
import { existsSync as existsSync22, readFileSync as readFileSync21, watch as fsWatch } from "node:fs";
|
|
78718
|
+
import { join as join27 } from "node:path";
|
|
78729
78719
|
function readFirstLine(path2) {
|
|
78730
78720
|
try {
|
|
78731
|
-
return
|
|
78721
|
+
return readFileSync21(path2, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
78732
78722
|
} catch {
|
|
78733
78723
|
return null;
|
|
78734
78724
|
}
|
|
78735
78725
|
}
|
|
78736
78726
|
function readGitRefState(gitDir) {
|
|
78737
|
-
const head2 = readFirstLine(
|
|
78727
|
+
const head2 = readFirstLine(join27(gitDir, "HEAD"));
|
|
78738
78728
|
const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
|
|
78739
78729
|
const branch = m ? m[1] : null;
|
|
78740
78730
|
let sha2 = null;
|
|
78741
78731
|
if (branch) {
|
|
78742
|
-
sha2 = readFirstLine(
|
|
78732
|
+
sha2 = readFirstLine(join27(gitDir, "refs", "heads", branch));
|
|
78743
78733
|
if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
|
|
78744
78734
|
} else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
|
|
78745
78735
|
sha2 = head2;
|
|
@@ -78747,13 +78737,13 @@ function readGitRefState(gitDir) {
|
|
|
78747
78737
|
return {
|
|
78748
78738
|
branch,
|
|
78749
78739
|
sha: sha2,
|
|
78750
|
-
mergeHeadExists:
|
|
78751
|
-
origHeadExists:
|
|
78740
|
+
mergeHeadExists: existsSync22(join27(gitDir, "MERGE_HEAD")),
|
|
78741
|
+
origHeadExists: existsSync22(join27(gitDir, "ORIG_HEAD"))
|
|
78752
78742
|
};
|
|
78753
78743
|
}
|
|
78754
78744
|
function shaFromPackedRefs(gitDir, ref) {
|
|
78755
78745
|
try {
|
|
78756
|
-
for (const line of
|
|
78746
|
+
for (const line of readFileSync21(join27(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
78757
78747
|
const [sha2, name2] = line.split(/\s+/);
|
|
78758
78748
|
if (name2 === ref && sha2) return sha2;
|
|
78759
78749
|
}
|
|
@@ -78787,7 +78777,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
78787
78777
|
const settle = () => {
|
|
78788
78778
|
if (timer) clearTimeout(timer);
|
|
78789
78779
|
timer = setTimeout(() => {
|
|
78790
|
-
if (
|
|
78780
|
+
if (existsSync22(join27(gitDir, "index.lock"))) {
|
|
78791
78781
|
settle();
|
|
78792
78782
|
return;
|
|
78793
78783
|
}
|
|
@@ -78798,7 +78788,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
78798
78788
|
}, debounceMs);
|
|
78799
78789
|
};
|
|
78800
78790
|
for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
|
|
78801
|
-
const p =
|
|
78791
|
+
const p = join27(gitDir, sub);
|
|
78802
78792
|
try {
|
|
78803
78793
|
watchers.push(fsWatch(p, settle));
|
|
78804
78794
|
} catch {
|
|
@@ -79022,8 +79012,8 @@ var TelemetryRecorder = class {
|
|
|
79022
79012
|
};
|
|
79023
79013
|
|
|
79024
79014
|
// src/file-activity.ts
|
|
79025
|
-
import { readFileSync as
|
|
79026
|
-
import { join as
|
|
79015
|
+
import { readFileSync as readFileSync23 } from "node:fs";
|
|
79016
|
+
import { join as join29 } from "node:path";
|
|
79027
79017
|
import { createHash as createHash17 } from "node:crypto";
|
|
79028
79018
|
|
|
79029
79019
|
// ../../packages/privacy/src/patterns/credentials.ts
|
|
@@ -79775,8 +79765,8 @@ init_git_remote();
|
|
|
79775
79765
|
// src/history-bundle.ts
|
|
79776
79766
|
init_src();
|
|
79777
79767
|
import { execFile as execFile2 } from "node:child_process";
|
|
79778
|
-
import { readFileSync as
|
|
79779
|
-
import { join as
|
|
79768
|
+
import { readFileSync as readFileSync22 } from "node:fs";
|
|
79769
|
+
import { join as join28 } from "node:path";
|
|
79780
79770
|
var DEFAULT_MAX_TOKENS = 6e3;
|
|
79781
79771
|
var FILE_LIST_CAP = 60;
|
|
79782
79772
|
var DIFF_FILE_CAP = 40;
|
|
@@ -79811,7 +79801,7 @@ function pathAllowedByFloor(path2) {
|
|
|
79811
79801
|
function loadRepoIgnore(root, extraPatterns = []) {
|
|
79812
79802
|
let source = "";
|
|
79813
79803
|
try {
|
|
79814
|
-
source =
|
|
79804
|
+
source = readFileSync22(join28(root, ".errataignore"), "utf8");
|
|
79815
79805
|
} catch {
|
|
79816
79806
|
source = "";
|
|
79817
79807
|
}
|
|
@@ -80104,7 +80094,7 @@ function readActivityBranch(root) {
|
|
|
80104
80094
|
try {
|
|
80105
80095
|
const gitDir = resolveGitDir(root);
|
|
80106
80096
|
if (!gitDir) return null;
|
|
80107
|
-
const head2 =
|
|
80097
|
+
const head2 = readFileSync23(join29(gitDir, "HEAD"), "utf8").trim();
|
|
80108
80098
|
const branch = head2.startsWith("ref: refs/heads/") ? head2.slice(16) : /^[a-f0-9]{40,64}$/i.test(head2) ? "HEAD" : null;
|
|
80109
80099
|
return branch && branch.length <= 256 && !/[\x00-\x1f\x7f]/.test(branch) ? branch : null;
|
|
80110
80100
|
} catch {
|
|
@@ -80261,21 +80251,21 @@ var FileActivityReporter = class {
|
|
|
80261
80251
|
|
|
80262
80252
|
// src/skills.ts
|
|
80263
80253
|
import {
|
|
80264
|
-
existsSync as
|
|
80254
|
+
existsSync as existsSync23,
|
|
80265
80255
|
mkdirSync as mkdirSync7,
|
|
80266
|
-
readFileSync as
|
|
80256
|
+
readFileSync as readFileSync24,
|
|
80267
80257
|
readdirSync as readdirSync8,
|
|
80268
80258
|
unlinkSync as unlinkSync2,
|
|
80269
|
-
writeFileSync as
|
|
80259
|
+
writeFileSync as writeFileSync17
|
|
80270
80260
|
} from "node:fs";
|
|
80271
|
-
import { basename as basename6, join as
|
|
80261
|
+
import { basename as basename6, join as join30 } from "node:path";
|
|
80272
80262
|
function skillFileName(id) {
|
|
80273
80263
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
80274
80264
|
}
|
|
80275
80265
|
function readSkillManifest(manifestPath) {
|
|
80276
|
-
if (!
|
|
80266
|
+
if (!existsSync23(manifestPath)) return [];
|
|
80277
80267
|
try {
|
|
80278
|
-
const parsed = JSON.parse(
|
|
80268
|
+
const parsed = JSON.parse(readFileSync24(manifestPath, "utf8"));
|
|
80279
80269
|
return (parsed.skills ?? []).map((s) => ({
|
|
80280
80270
|
title: s.title ?? "",
|
|
80281
80271
|
layer: s.layer ?? "technique",
|
|
@@ -80299,7 +80289,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80299
80289
|
for (const s of res.skills) {
|
|
80300
80290
|
const fileName = skillFileName(s.id);
|
|
80301
80291
|
keep.add(fileName);
|
|
80302
|
-
|
|
80292
|
+
writeFileSync17(join30(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
80303
80293
|
rows.push({
|
|
80304
80294
|
id: s.id,
|
|
80305
80295
|
title: s.title,
|
|
@@ -80312,7 +80302,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80312
80302
|
const fileName = skillFileName(p.id);
|
|
80313
80303
|
if (keep.has(fileName)) continue;
|
|
80314
80304
|
keep.add(fileName);
|
|
80315
|
-
|
|
80305
|
+
writeFileSync17(join30(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
80316
80306
|
rows.push({
|
|
80317
80307
|
id: p.id,
|
|
80318
80308
|
title: p.title,
|
|
@@ -80326,13 +80316,13 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80326
80316
|
if (!f.endsWith(".md")) continue;
|
|
80327
80317
|
if (keep.has(basename6(f))) continue;
|
|
80328
80318
|
try {
|
|
80329
|
-
unlinkSync2(
|
|
80319
|
+
unlinkSync2(join30(paths.skillsDir, f));
|
|
80330
80320
|
pruned++;
|
|
80331
80321
|
} catch {
|
|
80332
80322
|
}
|
|
80333
80323
|
}
|
|
80334
80324
|
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
80335
|
-
|
|
80325
|
+
writeFileSync17(
|
|
80336
80326
|
paths.skillsManifest,
|
|
80337
80327
|
JSON.stringify({ generatedAt: Date.now(), skills: rows }, null, 2),
|
|
80338
80328
|
"utf8"
|
|
@@ -80344,22 +80334,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
|
|
|
80344
80334
|
init_src2();
|
|
80345
80335
|
import {
|
|
80346
80336
|
cpSync,
|
|
80347
|
-
existsSync as
|
|
80337
|
+
existsSync as existsSync24,
|
|
80348
80338
|
lstatSync,
|
|
80349
80339
|
mkdirSync as mkdirSync8,
|
|
80350
|
-
readFileSync as
|
|
80340
|
+
readFileSync as readFileSync25,
|
|
80351
80341
|
readdirSync as readdirSync9,
|
|
80352
80342
|
rmSync as rmSync3,
|
|
80353
80343
|
symlinkSync,
|
|
80354
|
-
writeFileSync as
|
|
80344
|
+
writeFileSync as writeFileSync18
|
|
80355
80345
|
} from "node:fs";
|
|
80356
|
-
import { join as
|
|
80346
|
+
import { join as join31 } from "node:path";
|
|
80357
80347
|
var SKILL_NS = "errata-";
|
|
80358
80348
|
var HARNESS_SKILL_DIRS = [
|
|
80359
|
-
{ configDir: ".claude", skillsDir:
|
|
80349
|
+
{ configDir: ".claude", skillsDir: join31(".claude", "skills") },
|
|
80360
80350
|
// Cursor adopted the standard; its exact project dir is still moving — kept
|
|
80361
80351
|
// best-effort and gated on `.cursor/` presence so we never create it blind.
|
|
80362
|
-
{ configDir: ".cursor", skillsDir:
|
|
80352
|
+
{ configDir: ".cursor", skillsDir: join31(".cursor", "skills") }
|
|
80363
80353
|
];
|
|
80364
80354
|
function skillSlug(title, id) {
|
|
80365
80355
|
const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
|
|
@@ -80404,12 +80394,12 @@ function skillCiteHandle(s) {
|
|
|
80404
80394
|
return priorHandle({ id: s.id, description: s.title });
|
|
80405
80395
|
}
|
|
80406
80396
|
function reconcileNamespaced(dir, keep) {
|
|
80407
|
-
if (!
|
|
80397
|
+
if (!existsSync24(dir)) return 0;
|
|
80408
80398
|
let pruned = 0;
|
|
80409
80399
|
for (const name2 of readdirSync9(dir)) {
|
|
80410
80400
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
80411
80401
|
try {
|
|
80412
|
-
rmSync3(
|
|
80402
|
+
rmSync3(join31(dir, name2), { recursive: true, force: true });
|
|
80413
80403
|
pruned++;
|
|
80414
80404
|
} catch {
|
|
80415
80405
|
}
|
|
@@ -80418,7 +80408,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
80418
80408
|
}
|
|
80419
80409
|
function linkOrCopy(linkPath, target) {
|
|
80420
80410
|
try {
|
|
80421
|
-
if (
|
|
80411
|
+
if (existsSync24(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
|
|
80422
80412
|
} catch {
|
|
80423
80413
|
}
|
|
80424
80414
|
try {
|
|
@@ -80439,7 +80429,7 @@ function safeLstat(p) {
|
|
|
80439
80429
|
}
|
|
80440
80430
|
}
|
|
80441
80431
|
function emitAndProjectSkills(root, skills) {
|
|
80442
|
-
const agentsSkillsDir =
|
|
80432
|
+
const agentsSkillsDir = join31(root, ".agents", "skills");
|
|
80443
80433
|
mkdirSync8(agentsSkillsDir, { recursive: true });
|
|
80444
80434
|
const slugs = [];
|
|
80445
80435
|
const keep = /* @__PURE__ */ new Set();
|
|
@@ -80447,7 +80437,7 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80447
80437
|
for (const s of skills) {
|
|
80448
80438
|
let body2;
|
|
80449
80439
|
try {
|
|
80450
|
-
body2 =
|
|
80440
|
+
body2 = readFileSync25(s.bodyPath, "utf8");
|
|
80451
80441
|
} catch {
|
|
80452
80442
|
continue;
|
|
80453
80443
|
}
|
|
@@ -80456,9 +80446,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80456
80446
|
keep.add(slug2);
|
|
80457
80447
|
slugs.push(slug2);
|
|
80458
80448
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
80459
|
-
mkdirSync8(
|
|
80460
|
-
|
|
80461
|
-
|
|
80449
|
+
mkdirSync8(join31(agentsSkillsDir, slug2), { recursive: true });
|
|
80450
|
+
writeFileSync18(
|
|
80451
|
+
join31(agentsSkillsDir, slug2, "SKILL.md"),
|
|
80462
80452
|
renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
|
|
80463
80453
|
"utf8"
|
|
80464
80454
|
);
|
|
@@ -80467,11 +80457,11 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80467
80457
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
80468
80458
|
let projected = 0;
|
|
80469
80459
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
80470
|
-
if (!
|
|
80471
|
-
const dir =
|
|
80460
|
+
if (!existsSync24(join31(root, h.configDir))) continue;
|
|
80461
|
+
const dir = join31(root, h.skillsDir);
|
|
80472
80462
|
mkdirSync8(dir, { recursive: true });
|
|
80473
80463
|
for (const slug2 of slugs) {
|
|
80474
|
-
linkOrCopy(
|
|
80464
|
+
linkOrCopy(join31(dir, slug2), join31(agentsSkillsDir, slug2));
|
|
80475
80465
|
projected++;
|
|
80476
80466
|
}
|
|
80477
80467
|
reconcileNamespaced(dir, keep);
|
|
@@ -80480,15 +80470,15 @@ function emitAndProjectSkills(root, skills) {
|
|
|
80480
80470
|
return { slugs, emitted, projected };
|
|
80481
80471
|
}
|
|
80482
80472
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
80483
|
-
if (!
|
|
80473
|
+
if (!existsSync24(manifestPath)) return [];
|
|
80484
80474
|
try {
|
|
80485
|
-
const parsed = JSON.parse(
|
|
80475
|
+
const parsed = JSON.parse(readFileSync25(manifestPath, "utf8"));
|
|
80486
80476
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
80487
80477
|
id: s.id,
|
|
80488
80478
|
title: s.title ?? s.id,
|
|
80489
80479
|
layer: s.layer ?? "technique",
|
|
80490
80480
|
confidence: s.confidence ?? 0,
|
|
80491
|
-
bodyPath:
|
|
80481
|
+
bodyPath: join31(erretaDir, s.file)
|
|
80492
80482
|
}));
|
|
80493
80483
|
} catch {
|
|
80494
80484
|
return [];
|
|
@@ -80502,17 +80492,17 @@ var GITIGNORE_LINES = [
|
|
|
80502
80492
|
".cursor/skills/errata-*/"
|
|
80503
80493
|
];
|
|
80504
80494
|
function ensureSkillGitignore(root) {
|
|
80505
|
-
const path2 =
|
|
80495
|
+
const path2 = join31(root, ".gitignore");
|
|
80506
80496
|
let current = "";
|
|
80507
80497
|
try {
|
|
80508
|
-
current =
|
|
80498
|
+
current = existsSync24(path2) ? readFileSync25(path2, "utf8") : "";
|
|
80509
80499
|
} catch {
|
|
80510
80500
|
return;
|
|
80511
80501
|
}
|
|
80512
80502
|
if (current.includes(GITIGNORE_MARK)) return;
|
|
80513
80503
|
const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
|
|
80514
80504
|
try {
|
|
80515
|
-
|
|
80505
|
+
writeFileSync18(path2, `${current}${prefix}
|
|
80516
80506
|
${GITIGNORE_LINES.join("\n")}
|
|
80517
80507
|
`, "utf8");
|
|
80518
80508
|
} catch {
|
|
@@ -80608,18 +80598,18 @@ init_paths();
|
|
|
80608
80598
|
init_profile2();
|
|
80609
80599
|
|
|
80610
80600
|
// src/witness-queue.ts
|
|
80611
|
-
import { readFileSync as
|
|
80612
|
-
import { dirname as dirname11, join as
|
|
80601
|
+
import { readFileSync as readFileSync26, renameSync as renameSync2, writeFileSync as writeFileSync19 } from "node:fs";
|
|
80602
|
+
import { dirname as dirname11, join as join32 } from "node:path";
|
|
80613
80603
|
var WITNESS_QUEUE_CAP = 500;
|
|
80614
80604
|
var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
80615
80605
|
var WITNESS_MAX_ATTEMPTS = 5;
|
|
80616
80606
|
function witnessQueuePath(workspaceConfigDir) {
|
|
80617
|
-
return
|
|
80607
|
+
return join32(workspaceConfigDir, "witness-queue.json");
|
|
80618
80608
|
}
|
|
80619
80609
|
function loadWitnessQueueWithLosses(path2) {
|
|
80620
80610
|
let raw2;
|
|
80621
80611
|
try {
|
|
80622
|
-
raw2 = JSON.parse(
|
|
80612
|
+
raw2 = JSON.parse(readFileSync26(path2, "utf8"));
|
|
80623
80613
|
} catch (err2) {
|
|
80624
80614
|
const absent = err2?.code === "ENOENT";
|
|
80625
80615
|
return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
|
|
@@ -80632,8 +80622,8 @@ function loadWitnessQueueWithLosses(path2) {
|
|
|
80632
80622
|
}
|
|
80633
80623
|
function saveWitnessQueue(path2, queue) {
|
|
80634
80624
|
try {
|
|
80635
|
-
const tmp =
|
|
80636
|
-
|
|
80625
|
+
const tmp = join32(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
|
|
80626
|
+
writeFileSync19(tmp, JSON.stringify(queue), "utf8");
|
|
80637
80627
|
renameSync2(tmp, path2);
|
|
80638
80628
|
} catch {
|
|
80639
80629
|
}
|
|
@@ -80940,8 +80930,8 @@ function maybeFlushDigests() {
|
|
|
80940
80930
|
|
|
80941
80931
|
// src/liveness-watch.ts
|
|
80942
80932
|
init_src5();
|
|
80943
|
-
import { readFileSync as
|
|
80944
|
-
import { join as
|
|
80933
|
+
import { readFileSync as readFileSync28, writeFileSync as writeFileSync21 } from "node:fs";
|
|
80934
|
+
import { join as join34 } from "node:path";
|
|
80945
80935
|
|
|
80946
80936
|
// src/loop-lag.ts
|
|
80947
80937
|
var HEARTBEAT_MS = 500;
|
|
@@ -81072,11 +81062,11 @@ function watchCensusLine(c = watchCensus(), now = Date.now()) {
|
|
|
81072
81062
|
var LIVENESS_WATCH_INTERVAL_MS = 60 * 60 * 1e3;
|
|
81073
81063
|
var ALARM_RENOTIFY_MS = 24 * 60 * 60 * 1e3;
|
|
81074
81064
|
function alarmStatePath(configDir) {
|
|
81075
|
-
return
|
|
81065
|
+
return join34(configDir, "liveness-alarms.json");
|
|
81076
81066
|
}
|
|
81077
81067
|
function loadAlarmState(configDir) {
|
|
81078
81068
|
try {
|
|
81079
|
-
const raw2 = JSON.parse(
|
|
81069
|
+
const raw2 = JSON.parse(readFileSync28(alarmStatePath(configDir), "utf8"));
|
|
81080
81070
|
return new Map(Object.entries(raw2).filter((e) => typeof e[1] === "number"));
|
|
81081
81071
|
} catch {
|
|
81082
81072
|
return /* @__PURE__ */ new Map();
|
|
@@ -81084,7 +81074,7 @@ function loadAlarmState(configDir) {
|
|
|
81084
81074
|
}
|
|
81085
81075
|
function saveAlarmState(configDir, state) {
|
|
81086
81076
|
try {
|
|
81087
|
-
|
|
81077
|
+
writeFileSync21(alarmStatePath(configDir), JSON.stringify(Object.fromEntries(state)));
|
|
81088
81078
|
} catch {
|
|
81089
81079
|
}
|
|
81090
81080
|
}
|
|
@@ -81253,7 +81243,7 @@ function createWatchBreaker(deps) {
|
|
|
81253
81243
|
}
|
|
81254
81244
|
|
|
81255
81245
|
// src/engine.ts
|
|
81256
|
-
var DAEMON_VERSION = true ? "2.0.14-dev.
|
|
81246
|
+
var DAEMON_VERSION = true ? "2.0.14-dev.3289" : "2.0.0-alpha.0";
|
|
81257
81247
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
81258
81248
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
81259
81249
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -81265,7 +81255,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
|
|
|
81265
81255
|
function appendIdentityAudit(path2, record2, line) {
|
|
81266
81256
|
if (!record2.accepted && record2.score <= 0) return;
|
|
81267
81257
|
try {
|
|
81268
|
-
if (
|
|
81258
|
+
if (existsSync26(path2) && statSync8(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
81269
81259
|
renameSync3(path2, `${path2}.1`);
|
|
81270
81260
|
}
|
|
81271
81261
|
appendFileSync4(path2, line);
|
|
@@ -81275,7 +81265,7 @@ function appendIdentityAudit(path2, record2, line) {
|
|
|
81275
81265
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
81276
81266
|
function loadTurnCursors(path2) {
|
|
81277
81267
|
try {
|
|
81278
|
-
const raw2 = JSON.parse(
|
|
81268
|
+
const raw2 = JSON.parse(readFileSync29(path2, "utf8"));
|
|
81279
81269
|
return new Map(
|
|
81280
81270
|
Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
|
|
81281
81271
|
);
|
|
@@ -81285,7 +81275,7 @@ function loadTurnCursors(path2) {
|
|
|
81285
81275
|
}
|
|
81286
81276
|
function loadTurnOffsets(path2) {
|
|
81287
81277
|
try {
|
|
81288
|
-
const raw2 = JSON.parse(
|
|
81278
|
+
const raw2 = JSON.parse(readFileSync29(path2, "utf8"));
|
|
81289
81279
|
const out2 = /* @__PURE__ */ new Map();
|
|
81290
81280
|
for (const [k, v] of Object.entries(raw2)) {
|
|
81291
81281
|
const off = typeof v === "object" && v !== null ? v.offset : void 0;
|
|
@@ -81301,7 +81291,7 @@ function saveTurnCursors(path2, cursors, offsets) {
|
|
|
81301
81291
|
const merged = {};
|
|
81302
81292
|
for (const [k, uuid3] of cursors) merged[k] = { uuid: uuid3, offset: offsets.get(k) ?? 0 };
|
|
81303
81293
|
for (const [k, offset] of offsets) if (!merged[k]) merged[k] = { uuid: "", offset };
|
|
81304
|
-
|
|
81294
|
+
writeFileSync22(path2, JSON.stringify(merged), "utf8");
|
|
81305
81295
|
} catch {
|
|
81306
81296
|
}
|
|
81307
81297
|
}
|
|
@@ -81323,7 +81313,7 @@ function gitSourceWatchTargets(root) {
|
|
|
81323
81313
|
["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
|
|
81324
81314
|
{ encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
|
|
81325
81315
|
);
|
|
81326
|
-
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(
|
|
81316
|
+
ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join35(root, d) + sep4));
|
|
81327
81317
|
} catch {
|
|
81328
81318
|
}
|
|
81329
81319
|
const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
|
|
@@ -81335,19 +81325,19 @@ function gitSourceWatchTargets(root) {
|
|
|
81335
81325
|
if (!f.startsWith(prefix)) continue;
|
|
81336
81326
|
const rest2 = f.slice(prefix.length);
|
|
81337
81327
|
if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
|
|
81338
|
-
else targets.add(
|
|
81328
|
+
else targets.add(join35(root, f));
|
|
81339
81329
|
}
|
|
81340
81330
|
for (const c of children) {
|
|
81341
|
-
if (IGNORED_PATH.test(
|
|
81331
|
+
if (IGNORED_PATH.test(join35(root, c) + sep4)) continue;
|
|
81342
81332
|
if (hasIgnoredChild(c)) addUnder(c);
|
|
81343
|
-
else targets.add(
|
|
81333
|
+
else targets.add(join35(root, c));
|
|
81344
81334
|
}
|
|
81345
81335
|
};
|
|
81346
81336
|
addUnder("");
|
|
81347
81337
|
if (targets.size > 0) return [...targets];
|
|
81348
81338
|
} catch {
|
|
81349
81339
|
}
|
|
81350
|
-
return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(
|
|
81340
|
+
return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join35(root, String(e.name)) + sep4)).map((e) => join35(root, String(e.name)));
|
|
81351
81341
|
}
|
|
81352
81342
|
function createWorkspaceEngine(opts) {
|
|
81353
81343
|
const paths = workspacePaths(opts.workspaceRoot);
|
|
@@ -81553,7 +81543,7 @@ function createWorkspaceEngine(opts) {
|
|
|
81553
81543
|
const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
|
|
81554
81544
|
let episodeId2;
|
|
81555
81545
|
if (srcPaths.length > 0) {
|
|
81556
|
-
const abs = srcPaths.map((p) =>
|
|
81546
|
+
const abs = srcPaths.map((p) => join35(opts.workspaceRoot, p));
|
|
81557
81547
|
try {
|
|
81558
81548
|
const r = await runReindexPass(
|
|
81559
81549
|
`git-reindex:${profile.name} (${abs.length} files)`,
|
|
@@ -81589,8 +81579,8 @@ function createWorkspaceEngine(opts) {
|
|
|
81589
81579
|
`[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
|
|
81590
81580
|
);
|
|
81591
81581
|
};
|
|
81592
|
-
const gitDir =
|
|
81593
|
-
if (
|
|
81582
|
+
const gitDir = join35(opts.workspaceRoot, ".git");
|
|
81583
|
+
if (existsSync26(gitDir)) {
|
|
81594
81584
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
81595
81585
|
void handleGitEvent(ev).catch((err2) => {
|
|
81596
81586
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -81709,7 +81699,7 @@ function createWorkspaceEngine(opts) {
|
|
|
81709
81699
|
const elicit = isEdgeElicitationEnabled();
|
|
81710
81700
|
const snapOpts = {
|
|
81711
81701
|
profile,
|
|
81712
|
-
atCommit: readGitRefState(
|
|
81702
|
+
atCommit: readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0,
|
|
81713
81703
|
reviewCount: pendingCount(paths),
|
|
81714
81704
|
reviewUiUrl: opts.reviewUrl(),
|
|
81715
81705
|
workingFile: workingFiles.mostRecent() ?? void 0,
|
|
@@ -81723,7 +81713,7 @@ function createWorkspaceEngine(opts) {
|
|
|
81723
81713
|
);
|
|
81724
81714
|
return null;
|
|
81725
81715
|
}) : null;
|
|
81726
|
-
if (snapOpts.atCommit !== (readGitRefState(
|
|
81716
|
+
if (snapOpts.atCommit !== (readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0)) {
|
|
81727
81717
|
contextDirty = true;
|
|
81728
81718
|
return;
|
|
81729
81719
|
}
|
|
@@ -81776,10 +81766,16 @@ function createWorkspaceEngine(opts) {
|
|
|
81776
81766
|
console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
|
|
81777
81767
|
}
|
|
81778
81768
|
writeContextFile(opts.workspaceRoot, body2);
|
|
81779
|
-
|
|
81769
|
+
try {
|
|
81770
|
+
const written = readContextFileWithHash(opts.workspaceRoot);
|
|
81771
|
+
if (written) writeContextCard(opts.workspaceRoot, written.hash, contextCard(store, snapshot));
|
|
81772
|
+
} catch (err2) {
|
|
81773
|
+
console.warn("[errata] context card failed:", err2.message?.slice(0, 120));
|
|
81774
|
+
}
|
|
81775
|
+
const target = join35(opts.workspaceRoot, "AGENTS.md");
|
|
81780
81776
|
writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
|
|
81781
81777
|
if (elicit) {
|
|
81782
|
-
writePrimingHandles(
|
|
81778
|
+
writePrimingHandles(join35(paths.configDir, "priming-handles.json"), [
|
|
81783
81779
|
...snapshot.recentProblems.map((r) => r.node),
|
|
81784
81780
|
// Resolved-band handles: the ✓ problem AND its Solution are citable
|
|
81785
81781
|
// (a fix tag on an already-resolved problem no-ops idempotently; the
|
|
@@ -82121,7 +82117,7 @@ function createWorkspaceEngine(opts) {
|
|
|
82121
82117
|
resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
|
|
82122
82118
|
});
|
|
82123
82119
|
};
|
|
82124
|
-
const turnCursorPath =
|
|
82120
|
+
const turnCursorPath = join35(paths.configDir, "turn-cursors.json");
|
|
82125
82121
|
const lastTurnUuid = loadTurnCursors(turnCursorPath);
|
|
82126
82122
|
const turnOffset = loadTurnOffsets(turnCursorPath);
|
|
82127
82123
|
const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
|
|
@@ -82179,7 +82175,7 @@ function createWorkspaceEngine(opts) {
|
|
|
82179
82175
|
let processedTurns = 0;
|
|
82180
82176
|
const seqAtStart = store.currentIngestSeq();
|
|
82181
82177
|
const elicit = isEdgeElicitationEnabled();
|
|
82182
|
-
const handleMap = elicit ? readPrimingHandles(
|
|
82178
|
+
const handleMap = elicit ? readPrimingHandles(join35(paths.configDir, "priming-handles.json")) : {};
|
|
82183
82179
|
const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
|
|
82184
82180
|
const toRel = (abs) => {
|
|
82185
82181
|
const p = abs.replace(/\\/g, "/");
|
|
@@ -82476,10 +82472,10 @@ function createWorkspaceEngine(opts) {
|
|
|
82476
82472
|
let enclosing = {};
|
|
82477
82473
|
if (p.location?.line !== void 0) {
|
|
82478
82474
|
try {
|
|
82479
|
-
const headSha = readGitRefState(
|
|
82475
|
+
const headSha = readGitRefState(join35(opts.workspaceRoot, ".git")).sha ?? void 0;
|
|
82480
82476
|
enclosing = {
|
|
82481
82477
|
line: p.location.line,
|
|
82482
|
-
fileText:
|
|
82478
|
+
fileText: readFileSync29(join35(opts.workspaceRoot, anchorPath), "utf8"),
|
|
82483
82479
|
...headSha ? { headSha } : {}
|
|
82484
82480
|
};
|
|
82485
82481
|
} catch {
|
|
@@ -83278,7 +83274,7 @@ B: ${b}`,
|
|
|
83278
83274
|
try {
|
|
83279
83275
|
const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
|
|
83280
83276
|
emitAndProjectSkills(opts.workspaceRoot, inputs);
|
|
83281
|
-
writePrimingHandles(
|
|
83277
|
+
writePrimingHandles(join35(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
|
|
83282
83278
|
} catch (err2) {
|
|
83283
83279
|
console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
|
|
83284
83280
|
}
|
|
@@ -83585,7 +83581,7 @@ B: ${b}`,
|
|
|
83585
83581
|
console.log(
|
|
83586
83582
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
83587
83583
|
);
|
|
83588
|
-
const pending =
|
|
83584
|
+
const pending = existsSync26(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
83589
83585
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
83590
83586
|
}
|
|
83591
83587
|
const onDisk = loadProfile(opts.workspaceRoot);
|
|
@@ -83593,7 +83589,7 @@ B: ${b}`,
|
|
|
83593
83589
|
console.log(
|
|
83594
83590
|
"[errata] sync held \u2014 this repo is already on errata in another workspace; run `errata link` to join it or create your own project"
|
|
83595
83591
|
);
|
|
83596
|
-
const pending =
|
|
83592
|
+
const pending = existsSync26(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
83597
83593
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
83598
83594
|
}
|
|
83599
83595
|
try {
|
|
@@ -83686,7 +83682,7 @@ async function startDaemon(opts) {
|
|
|
83686
83682
|
reviewUrl: () => webUiUrl + "/review"
|
|
83687
83683
|
});
|
|
83688
83684
|
const writeLockFile = (url2) => {
|
|
83689
|
-
|
|
83685
|
+
writeFileSync23(
|
|
83690
83686
|
engine.paths.daemonLock,
|
|
83691
83687
|
JSON.stringify({ pid: process.pid, webUiUrl: url2, startedAt: Date.now() }),
|
|
83692
83688
|
"utf8"
|
|
@@ -83729,7 +83725,7 @@ async function startDaemon(opts) {
|
|
|
83729
83725
|
);
|
|
83730
83726
|
await engine.stop();
|
|
83731
83727
|
try {
|
|
83732
|
-
if (
|
|
83728
|
+
if (existsSync27(engine.paths.daemonLock)) {
|
|
83733
83729
|
}
|
|
83734
83730
|
} catch {
|
|
83735
83731
|
}
|
|
@@ -83930,7 +83926,7 @@ function instanceReceiptSequence(n) {
|
|
|
83930
83926
|
// src/multi.ts
|
|
83931
83927
|
init_dist();
|
|
83932
83928
|
init_src5();
|
|
83933
|
-
import { existsSync as
|
|
83929
|
+
import { existsSync as existsSync33, readFileSync as readFileSync34, unlinkSync as unlinkSync3, writeFileSync as writeFileSync25 } from "node:fs";
|
|
83934
83930
|
import { resolve as pathResolve } from "node:path";
|
|
83935
83931
|
|
|
83936
83932
|
// src/principle-sync.ts
|
|
@@ -83959,8 +83955,8 @@ init_reconcile();
|
|
|
83959
83955
|
|
|
83960
83956
|
// src/lockfile-auto.ts
|
|
83961
83957
|
init_src();
|
|
83962
|
-
import { existsSync as
|
|
83963
|
-
import { join as
|
|
83958
|
+
import { existsSync as existsSync28, readFileSync as readFileSync30 } from "node:fs";
|
|
83959
|
+
import { join as join36 } from "node:path";
|
|
83964
83960
|
|
|
83965
83961
|
// src/package-index.ts
|
|
83966
83962
|
init_src();
|
|
@@ -84109,11 +84105,11 @@ function runLockfilePass(opts) {
|
|
|
84109
84105
|
{ file: "package-lock.json", parse: parsePackageLockJson }
|
|
84110
84106
|
];
|
|
84111
84107
|
for (const c of candidates) {
|
|
84112
|
-
const p =
|
|
84113
|
-
if (!
|
|
84108
|
+
const p = join36(opts.root, c.file);
|
|
84109
|
+
if (!existsSync28(p)) continue;
|
|
84114
84110
|
let sbom;
|
|
84115
84111
|
try {
|
|
84116
|
-
sbom = c.parse(
|
|
84112
|
+
sbom = c.parse(readFileSync30(p, "utf8"));
|
|
84117
84113
|
} catch {
|
|
84118
84114
|
continue;
|
|
84119
84115
|
}
|
|
@@ -84173,8 +84169,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
|
|
|
84173
84169
|
init_profile2();
|
|
84174
84170
|
|
|
84175
84171
|
// src/public-symbols.ts
|
|
84176
|
-
import { readFileSync as
|
|
84177
|
-
import { join as
|
|
84172
|
+
import { readFileSync as readFileSync31, readdirSync as readdirSync11, existsSync as existsSync29 } from "node:fs";
|
|
84173
|
+
import { join as join37 } from "node:path";
|
|
84178
84174
|
var HEAD_BYTES = 8 * 1024;
|
|
84179
84175
|
var INDEX_TTL_MS = 10 * 60 * 1e3;
|
|
84180
84176
|
var MIN_SYMBOL_LEN = 4;
|
|
@@ -84207,20 +84203,20 @@ function bindingNames(clause) {
|
|
|
84207
84203
|
function internalPackageNames(workspaceRoot) {
|
|
84208
84204
|
const names = /* @__PURE__ */ new Set();
|
|
84209
84205
|
const tryRead = (dir) => {
|
|
84210
|
-
const pj =
|
|
84211
|
-
if (!
|
|
84206
|
+
const pj = join37(dir, "package.json");
|
|
84207
|
+
if (!existsSync29(pj)) return;
|
|
84212
84208
|
try {
|
|
84213
|
-
const name2 = JSON.parse(
|
|
84209
|
+
const name2 = JSON.parse(readFileSync31(pj, "utf8")).name;
|
|
84214
84210
|
if (typeof name2 === "string" && name2.length > 0) names.add(name2);
|
|
84215
84211
|
} catch {
|
|
84216
84212
|
}
|
|
84217
84213
|
};
|
|
84218
84214
|
tryRead(workspaceRoot);
|
|
84219
84215
|
for (const group of ["packages", "apps"]) {
|
|
84220
|
-
const groupDir =
|
|
84221
|
-
if (!
|
|
84216
|
+
const groupDir = join37(workspaceRoot, group);
|
|
84217
|
+
if (!existsSync29(groupDir)) continue;
|
|
84222
84218
|
try {
|
|
84223
|
-
for (const entry of readdirSync11(groupDir)) tryRead(
|
|
84219
|
+
for (const entry of readdirSync11(groupDir)) tryRead(join37(groupDir, entry));
|
|
84224
84220
|
} catch {
|
|
84225
84221
|
}
|
|
84226
84222
|
}
|
|
@@ -84239,7 +84235,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
84239
84235
|
}
|
|
84240
84236
|
const readHead = deps.readHead ?? ((absPath) => {
|
|
84241
84237
|
try {
|
|
84242
|
-
return
|
|
84238
|
+
return readFileSync31(absPath, "utf8").slice(0, HEAD_BYTES);
|
|
84243
84239
|
} catch {
|
|
84244
84240
|
return "";
|
|
84245
84241
|
}
|
|
@@ -84259,7 +84255,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
|
|
|
84259
84255
|
}
|
|
84260
84256
|
const symbols = /* @__PURE__ */ new Set();
|
|
84261
84257
|
for (const rel of files) {
|
|
84262
|
-
const head2 = readHead(
|
|
84258
|
+
const head2 = readHead(join37(workspaceRoot, rel));
|
|
84263
84259
|
if (!head2) continue;
|
|
84264
84260
|
for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
|
|
84265
84261
|
re.lastIndex = 0;
|
|
@@ -85058,7 +85054,7 @@ function cloudTargetDrift(daemon, shell2) {
|
|
|
85058
85054
|
}
|
|
85059
85055
|
|
|
85060
85056
|
// src/lock.ts
|
|
85061
|
-
import { existsSync as
|
|
85057
|
+
import { existsSync as existsSync30, readFileSync as readFileSync32 } from "node:fs";
|
|
85062
85058
|
function daemonLockPayload(lock) {
|
|
85063
85059
|
return JSON.stringify({
|
|
85064
85060
|
pid: lock.pid,
|
|
@@ -85096,9 +85092,9 @@ function isProcessAlive(pid) {
|
|
|
85096
85092
|
}
|
|
85097
85093
|
}
|
|
85098
85094
|
function readDaemonLock(lockPath) {
|
|
85099
|
-
if (!
|
|
85095
|
+
if (!existsSync30(lockPath)) return null;
|
|
85100
85096
|
try {
|
|
85101
|
-
const lock = JSON.parse(
|
|
85097
|
+
const lock = JSON.parse(readFileSync32(lockPath, "utf8"));
|
|
85102
85098
|
return typeof lock.pid === "number" ? lock : null;
|
|
85103
85099
|
} catch {
|
|
85104
85100
|
return null;
|
|
@@ -85812,8 +85808,8 @@ async function syncHistoryRevisionPage(opts) {
|
|
|
85812
85808
|
init_src7();
|
|
85813
85809
|
init_src();
|
|
85814
85810
|
import { execFile as execFile5 } from "node:child_process";
|
|
85815
|
-
import { readFileSync as
|
|
85816
|
-
import { join as
|
|
85811
|
+
import { readFileSync as readFileSync33 } from "node:fs";
|
|
85812
|
+
import { join as join38 } from "node:path";
|
|
85817
85813
|
import { promisify as promisify3 } from "node:util";
|
|
85818
85814
|
|
|
85819
85815
|
// src/history-walk.ts
|
|
@@ -86136,8 +86132,8 @@ function narrative(unit, group) {
|
|
|
86136
86132
|
}
|
|
86137
86133
|
function narrativeSources(unit, group) {
|
|
86138
86134
|
if (!group || group.length === 0) return [{ commitSha: unit.sha, text: message(unit).trim() }].filter((s) => s.text.length > 0);
|
|
86139
|
-
const
|
|
86140
|
-
const source =
|
|
86135
|
+
const members = group.filter((g) => g.groupSha === (unit.groupSha ?? unit.sha)).sort((a, b) => a.subIndex - b.subIndex);
|
|
86136
|
+
const source = members.length > 0 ? members : [...group].sort((a, b) => a.subIndex - b.subIndex);
|
|
86141
86137
|
return source.map((member) => ({ commitSha: member.sha, text: message(member).trim() })).filter((s) => s.text.length > 0);
|
|
86142
86138
|
}
|
|
86143
86139
|
|
|
@@ -86360,7 +86356,7 @@ async function defaultGit(root, args2) {
|
|
|
86360
86356
|
function readIgnoreLines(root, profile) {
|
|
86361
86357
|
let lines = [];
|
|
86362
86358
|
try {
|
|
86363
|
-
lines =
|
|
86359
|
+
lines = readFileSync33(join38(root, ".errataignore"), "utf8").split("\n");
|
|
86364
86360
|
} catch {
|
|
86365
86361
|
}
|
|
86366
86362
|
return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
@@ -86790,8 +86786,8 @@ async function startHistoryStage(root, input, client, walk11 = {}) {
|
|
|
86790
86786
|
init_cloud_auth();
|
|
86791
86787
|
import { createHash as createHash19 } from "node:crypto";
|
|
86792
86788
|
import { execFileSync as execFileSync5 } from "node:child_process";
|
|
86793
|
-
import { existsSync as
|
|
86794
|
-
import { join as
|
|
86789
|
+
import { existsSync as existsSync31, writeFileSync as writeFileSync24 } from "node:fs";
|
|
86790
|
+
import { join as join39 } from "node:path";
|
|
86795
86791
|
|
|
86796
86792
|
// src/device-poll.ts
|
|
86797
86793
|
var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
|
|
@@ -87249,9 +87245,9 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
|
|
|
87249
87245
|
delete nextProfile.projectLinkHold;
|
|
87250
87246
|
let wroteIgnore = false;
|
|
87251
87247
|
if (decision.writeIgnoreStarter !== false) {
|
|
87252
|
-
const target =
|
|
87253
|
-
if (!
|
|
87254
|
-
|
|
87248
|
+
const target = join39(root, ".errataignore");
|
|
87249
|
+
if (!existsSync31(target)) {
|
|
87250
|
+
writeFileSync24(target, IGNORE_STARTER, "utf8");
|
|
87255
87251
|
wroteIgnore = true;
|
|
87256
87252
|
}
|
|
87257
87253
|
}
|
|
@@ -87264,12 +87260,12 @@ init_registry();
|
|
|
87264
87260
|
|
|
87265
87261
|
// src/adopt.ts
|
|
87266
87262
|
init_git_remote();
|
|
87267
|
-
import { existsSync as
|
|
87268
|
-
import { dirname as dirname12, join as
|
|
87263
|
+
import { existsSync as existsSync32 } from "node:fs";
|
|
87264
|
+
import { dirname as dirname12, join as join40 } from "node:path";
|
|
87269
87265
|
function findGitRoot(absPath) {
|
|
87270
87266
|
let dir = absPath;
|
|
87271
87267
|
for (let depth = 0; depth < 64; depth++) {
|
|
87272
|
-
if (
|
|
87268
|
+
if (existsSync32(join40(dir, ".git"))) return dir;
|
|
87273
87269
|
const parent = dirname12(dir);
|
|
87274
87270
|
if (parent === dir) return null;
|
|
87275
87271
|
dir = parent;
|
|
@@ -87962,7 +87958,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
87962
87958
|
records.push(rec);
|
|
87963
87959
|
void ambientLinkAll();
|
|
87964
87960
|
try {
|
|
87965
|
-
|
|
87961
|
+
writeFileSync25(
|
|
87966
87962
|
rec.engine.paths.daemonLock,
|
|
87967
87963
|
daemonLockPayload({
|
|
87968
87964
|
pid: process.pid,
|
|
@@ -88248,7 +88244,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
88248
88244
|
lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
|
|
88249
88245
|
} catch {
|
|
88250
88246
|
}
|
|
88251
|
-
const reason = retireDecision({ exists:
|
|
88247
|
+
const reason = retireDecision({ exists: existsSync33(rec.root), lastActiveAt, now });
|
|
88252
88248
|
if (reason) void retireWorkspace(rec, reason);
|
|
88253
88249
|
}
|
|
88254
88250
|
};
|
|
@@ -88319,7 +88315,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
88319
88315
|
baseUrl = `http://127.0.0.1:${port}`;
|
|
88320
88316
|
try {
|
|
88321
88317
|
ensureDir(globalDir());
|
|
88322
|
-
|
|
88318
|
+
writeFileSync25(
|
|
88323
88319
|
lockPath,
|
|
88324
88320
|
daemonLockPayload({ pid: process.pid, webUiUrl: baseUrl, processStartedAt: PROCESS_STARTED_AT, entry: SELF_ENTRY, version: DAEMON_VERSION }),
|
|
88325
88321
|
"utf8"
|
|
@@ -88328,7 +88324,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
88328
88324
|
}
|
|
88329
88325
|
for (const r of records) {
|
|
88330
88326
|
try {
|
|
88331
|
-
|
|
88327
|
+
writeFileSync25(
|
|
88332
88328
|
r.engine.paths.daemonLock,
|
|
88333
88329
|
daemonLockPayload({
|
|
88334
88330
|
pid: process.pid,
|
|
@@ -89300,7 +89296,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
89300
89296
|
clearInterval(anchorPull);
|
|
89301
89297
|
clearTimeout(codexWakeBoot);
|
|
89302
89298
|
try {
|
|
89303
|
-
const cur =
|
|
89299
|
+
const cur = readFileSync34(lockPath, "utf8");
|
|
89304
89300
|
if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
|
|
89305
89301
|
} catch {
|
|
89306
89302
|
}
|
|
@@ -89723,7 +89719,7 @@ import { spawnSync } from "node:child_process";
|
|
|
89723
89719
|
|
|
89724
89720
|
// src/codex-runtime.ts
|
|
89725
89721
|
import { readdirSync as readdirSync12, statSync as statSync9 } from "node:fs";
|
|
89726
|
-
import { join as
|
|
89722
|
+
import { join as join41 } from "node:path";
|
|
89727
89723
|
function resolveCodexExecutable(options = {}) {
|
|
89728
89724
|
const platform = options.platform ?? process.platform;
|
|
89729
89725
|
const env2 = options.env ?? process.env;
|
|
@@ -89738,13 +89734,13 @@ function resolveCodexExecutable(options = {}) {
|
|
|
89738
89734
|
};
|
|
89739
89735
|
for (const dir of (env2["PATH"] ?? env2["Path"] ?? "").split(";")) {
|
|
89740
89736
|
if (!dir.trim()) continue;
|
|
89741
|
-
const path2 =
|
|
89737
|
+
const path2 = join41(dir.trim().replace(/^"|"$/g, ""), "codex.exe");
|
|
89742
89738
|
if (fileTime(path2) !== null) return path2;
|
|
89743
89739
|
}
|
|
89744
89740
|
if (!env2["LOCALAPPDATA"]) return "codex";
|
|
89745
|
-
const root =
|
|
89741
|
+
const root = join41(env2["LOCALAPPDATA"], "OpenAI", "Codex", "bin");
|
|
89746
89742
|
try {
|
|
89747
|
-
const candidates = readdirSync12(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
89743
|
+
const candidates = readdirSync12(root, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join41(root, entry.name, "codex.exe")).map((path2) => ({ path: path2, mtime: fileTime(path2) })).filter((candidate) => candidate.mtime !== null).sort((a, b) => b.mtime - a.mtime || a.path.localeCompare(b.path));
|
|
89748
89744
|
return candidates[0]?.path ?? "codex";
|
|
89749
89745
|
} catch {
|
|
89750
89746
|
return "codex";
|
|
@@ -89863,9 +89859,9 @@ import { spawn as spawn4 } from "node:child_process";
|
|
|
89863
89859
|
import { createInterface } from "node:readline";
|
|
89864
89860
|
|
|
89865
89861
|
// src/codex-hooks.ts
|
|
89866
|
-
import { existsSync as
|
|
89862
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync9, readFileSync as readFileSync35, writeFileSync as writeFileSync26 } from "node:fs";
|
|
89867
89863
|
import { homedir as homedir7 } from "node:os";
|
|
89868
|
-
import { join as
|
|
89864
|
+
import { join as join42 } from "node:path";
|
|
89869
89865
|
|
|
89870
89866
|
// src/hook-commands.ts
|
|
89871
89867
|
function hookCurlCommand(port, path2 = "/api/hook") {
|
|
@@ -89944,8 +89940,8 @@ try {
|
|
|
89944
89940
|
|
|
89945
89941
|
// src/codex-hooks.ts
|
|
89946
89942
|
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.";
|
|
89947
|
-
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] ||
|
|
89948
|
-
return
|
|
89943
|
+
function hasCodexConfig(root, codexHome = process.env["CODEX_HOME"] || join42(homedir7(), ".codex")) {
|
|
89944
|
+
return existsSync34(join42(root, ".codex")) || existsSync34(codexHome);
|
|
89949
89945
|
}
|
|
89950
89946
|
function replaceCodexHooks(existing, block) {
|
|
89951
89947
|
const begin = existing.indexOf(CODEX_HOOKS_BEGIN);
|
|
@@ -89961,14 +89957,14 @@ function replaceCodexHooks(existing, block) {
|
|
|
89961
89957
|
return existing.trimEnd() + (existing.trim() ? "\n\n" : "") + block;
|
|
89962
89958
|
}
|
|
89963
89959
|
function writeCodexHooks(root, port, nodePath = process.execPath) {
|
|
89964
|
-
const dir =
|
|
89965
|
-
const file2 =
|
|
89966
|
-
const relay =
|
|
89960
|
+
const dir = join42(root, ".codex");
|
|
89961
|
+
const file2 = join42(dir, "config.toml");
|
|
89962
|
+
const relay = join42(dir, "hooks", "errata-relay.mjs");
|
|
89967
89963
|
const block = buildCodexHooksToml(port, { nodePath, relayPath: relay });
|
|
89968
|
-
const final = replaceCodexHooks(
|
|
89969
|
-
mkdirSync9(
|
|
89970
|
-
|
|
89971
|
-
|
|
89964
|
+
const final = replaceCodexHooks(existsSync34(file2) ? readFileSync35(file2, "utf8") : "", block);
|
|
89965
|
+
mkdirSync9(join42(dir, "hooks"), { recursive: true });
|
|
89966
|
+
writeFileSync26(relay, CODEX_RELAY_SOURCE, "utf8");
|
|
89967
|
+
writeFileSync26(file2, final, "utf8");
|
|
89972
89968
|
return file2;
|
|
89973
89969
|
}
|
|
89974
89970
|
|
|
@@ -90135,9 +90131,9 @@ function consolidationGapMs(lastPassMs, policy) {
|
|
|
90135
90131
|
}
|
|
90136
90132
|
|
|
90137
90133
|
// src/claude-statusline.ts
|
|
90138
|
-
import { existsSync as
|
|
90134
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync10, readFileSync as readFileSync36, writeFileSync as writeFileSync27 } from "node:fs";
|
|
90139
90135
|
import { homedir as homedir8 } from "node:os";
|
|
90140
|
-
import { dirname as dirname13, join as
|
|
90136
|
+
import { dirname as dirname13, join as join43 } from "node:path";
|
|
90141
90137
|
var STATUSLINE_RELAY_SOURCE = String.raw`// errata-managed: regenerated by errata init / install-hooks claude
|
|
90142
90138
|
import { readFileSync } from 'node:fs';
|
|
90143
90139
|
|
|
@@ -90170,8 +90166,8 @@ function removeProjectStatusLine(settings) {
|
|
|
90170
90166
|
return true;
|
|
90171
90167
|
}
|
|
90172
90168
|
function userClaudeSettingsPath() {
|
|
90173
|
-
const base = process.env["CLAUDE_CONFIG_DIR"] ??
|
|
90174
|
-
return
|
|
90169
|
+
const base = process.env["CLAUDE_CONFIG_DIR"] ?? join43(homedir8(), ".claude");
|
|
90170
|
+
return join43(base, "settings.json");
|
|
90175
90171
|
}
|
|
90176
90172
|
function ensureUserStatusLine(opts) {
|
|
90177
90173
|
const env2 = opts.env ?? process.env;
|
|
@@ -90179,9 +90175,9 @@ function ensureUserStatusLine(opts) {
|
|
|
90179
90175
|
if (off === "0" || off === "off" || off === "false" || off === "no") return "disabled";
|
|
90180
90176
|
const settingsPath = opts.userSettingsPath ?? userClaudeSettingsPath();
|
|
90181
90177
|
let settings = {};
|
|
90182
|
-
if (
|
|
90178
|
+
if (existsSync35(settingsPath)) {
|
|
90183
90179
|
try {
|
|
90184
|
-
const parsed = JSON.parse(
|
|
90180
|
+
const parsed = JSON.parse(readFileSync36(settingsPath, "utf8"));
|
|
90185
90181
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return "unreadable";
|
|
90186
90182
|
settings = parsed;
|
|
90187
90183
|
} catch {
|
|
@@ -90189,16 +90185,16 @@ function ensureUserStatusLine(opts) {
|
|
|
90189
90185
|
}
|
|
90190
90186
|
}
|
|
90191
90187
|
if (settings["statusLine"] !== void 0 && !isErrataStatusLine(settings["statusLine"])) return "kept-own";
|
|
90192
|
-
const relay =
|
|
90188
|
+
const relay = join43(opts.relayDir, STATUSLINE_RELAY_FILE);
|
|
90193
90189
|
mkdirSync10(opts.relayDir, { recursive: true });
|
|
90194
|
-
if (!
|
|
90195
|
-
|
|
90190
|
+
if (!existsSync35(relay) || readFileSync36(relay, "utf8") !== STATUSLINE_RELAY_SOURCE) {
|
|
90191
|
+
writeFileSync27(relay, STATUSLINE_RELAY_SOURCE, "utf8");
|
|
90196
90192
|
}
|
|
90197
90193
|
const next = buildStatusLine(opts.port, opts.nodePath ?? process.execPath, relay);
|
|
90198
90194
|
if (JSON.stringify(settings["statusLine"]) === JSON.stringify(next)) return "unchanged";
|
|
90199
90195
|
settings["statusLine"] = next;
|
|
90200
90196
|
mkdirSync10(dirname13(settingsPath), { recursive: true });
|
|
90201
|
-
|
|
90197
|
+
writeFileSync27(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
90202
90198
|
return "installed";
|
|
90203
90199
|
}
|
|
90204
90200
|
function describeStatusLineOutcome(outcome) {
|
|
@@ -90621,14 +90617,14 @@ async function cmdInit() {
|
|
|
90621
90617
|
if (!skipHooks) {
|
|
90622
90618
|
console.log("");
|
|
90623
90619
|
console.log("installing harness hooks...");
|
|
90624
|
-
const { existsSync:
|
|
90625
|
-
const { join:
|
|
90620
|
+
const { existsSync: existsSync37 } = await import("node:fs");
|
|
90621
|
+
const { join: join45 } = await import("node:path");
|
|
90626
90622
|
try {
|
|
90627
90623
|
await installClaudeHooks(port);
|
|
90628
90624
|
} catch (err2) {
|
|
90629
90625
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
90630
90626
|
}
|
|
90631
|
-
if (
|
|
90627
|
+
if (existsSync37(join45(ROOT, ".cursor"))) {
|
|
90632
90628
|
try {
|
|
90633
90629
|
await installCursorMcpConfig();
|
|
90634
90630
|
} catch (err2) {
|
|
@@ -90818,9 +90814,9 @@ async function cmdStatus() {
|
|
|
90818
90814
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
90819
90815
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
90820
90816
|
}
|
|
90821
|
-
console.log(` graph db: ${
|
|
90822
|
-
console.log(` event log: ${
|
|
90823
|
-
if (
|
|
90817
|
+
console.log(` graph db: ${existsSync36(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
90818
|
+
console.log(` event log: ${existsSync36(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
90819
|
+
if (existsSync36(paths.castalia)) {
|
|
90824
90820
|
try {
|
|
90825
90821
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
90826
90822
|
const store = openGraphStore2({ path: paths.castalia });
|
|
@@ -91788,11 +91784,11 @@ async function cmdInstallationProfile(args2) {
|
|
|
91788
91784
|
}
|
|
91789
91785
|
async function cmdReview() {
|
|
91790
91786
|
const paths = workspacePaths(ROOT);
|
|
91791
|
-
if (!
|
|
91787
|
+
if (!existsSync36(paths.reviewQueue)) {
|
|
91792
91788
|
console.log("(review queue empty)");
|
|
91793
91789
|
return;
|
|
91794
91790
|
}
|
|
91795
|
-
const queue = JSON.parse(
|
|
91791
|
+
const queue = JSON.parse(readFileSync37(paths.reviewQueue, "utf8"));
|
|
91796
91792
|
if (queue.length === 0) {
|
|
91797
91793
|
console.log("(review queue empty)");
|
|
91798
91794
|
return;
|
|
@@ -92463,7 +92459,7 @@ async function gatherRepo(store, ws) {
|
|
|
92463
92459
|
};
|
|
92464
92460
|
}
|
|
92465
92461
|
async function gatherReportData(generatedAt) {
|
|
92466
|
-
const { existsSync:
|
|
92462
|
+
const { existsSync: existsSync37 } = await import("node:fs");
|
|
92467
92463
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
|
|
92468
92464
|
const cfg = loadConfig();
|
|
92469
92465
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -92471,7 +92467,7 @@ async function gatherReportData(generatedAt) {
|
|
|
92471
92467
|
for (const ws of listWorkspaces()) {
|
|
92472
92468
|
if (ws.missing) continue;
|
|
92473
92469
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
92474
|
-
if (!
|
|
92470
|
+
if (!existsSync37(dbPath)) continue;
|
|
92475
92471
|
let store = null;
|
|
92476
92472
|
try {
|
|
92477
92473
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -92502,7 +92498,7 @@ async function gatherReportData(generatedAt) {
|
|
|
92502
92498
|
};
|
|
92503
92499
|
}
|
|
92504
92500
|
async function cmdReport(args2) {
|
|
92505
|
-
const { mkdirSync: mkdirSync11, writeFileSync:
|
|
92501
|
+
const { mkdirSync: mkdirSync11, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92506
92502
|
const { renderReport: renderReport2 } = await Promise.resolve().then(() => (init_report_render(), report_render_exports));
|
|
92507
92503
|
const includeFutureVerbs = args2.includes("--future-verbs");
|
|
92508
92504
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -92515,8 +92511,8 @@ async function cmdReport(args2) {
|
|
|
92515
92511
|
const outDir = workspacePaths(ROOT).configDir;
|
|
92516
92512
|
mkdirSync11(outDir, { recursive: true });
|
|
92517
92513
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
92518
|
-
for (const f of files)
|
|
92519
|
-
const indexPath =
|
|
92514
|
+
for (const f of files) writeFileSync28(join44(outDir, f.name), f.html, "utf8");
|
|
92515
|
+
const indexPath = join44(outDir, "report.html");
|
|
92520
92516
|
console.log(`report \u2192 ${indexPath}`);
|
|
92521
92517
|
console.log(
|
|
92522
92518
|
` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
|
|
@@ -92636,24 +92632,24 @@ async function cmdInstallHooks(args2) {
|
|
|
92636
92632
|
}
|
|
92637
92633
|
}
|
|
92638
92634
|
async function installOpencodePlugin(port) {
|
|
92639
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
92640
|
-
const { join:
|
|
92641
|
-
const dir =
|
|
92642
|
-
if (!
|
|
92643
|
-
const file2 =
|
|
92644
|
-
if (
|
|
92645
|
-
const head2 =
|
|
92635
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync38, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92636
|
+
const { join: join45 } = await import("node:path");
|
|
92637
|
+
const dir = join45(ROOT, ".opencode", "plugin");
|
|
92638
|
+
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
92639
|
+
const file2 = join45(dir, "inerrata.js");
|
|
92640
|
+
if (existsSync37(file2)) {
|
|
92641
|
+
const head2 = readFileSync38(file2, "utf8").split("\n")[0] ?? "";
|
|
92646
92642
|
if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
|
|
92647
92643
|
console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
|
|
92648
92644
|
process.exit(2);
|
|
92649
92645
|
}
|
|
92650
92646
|
}
|
|
92651
|
-
|
|
92652
|
-
const cfgFile =
|
|
92647
|
+
writeFileSync28(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
|
|
92648
|
+
const cfgFile = join45(ROOT, "opencode.json");
|
|
92653
92649
|
let cfg = { $schema: "https://opencode.ai/config.json" };
|
|
92654
|
-
if (
|
|
92650
|
+
if (existsSync37(cfgFile)) {
|
|
92655
92651
|
try {
|
|
92656
|
-
cfg = JSON.parse(
|
|
92652
|
+
cfg = JSON.parse(readFileSync38(cfgFile, "utf8"));
|
|
92657
92653
|
} catch {
|
|
92658
92654
|
console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
|
|
92659
92655
|
process.exit(2);
|
|
@@ -92664,7 +92660,7 @@ async function installOpencodePlugin(port) {
|
|
|
92664
92660
|
if (!hadErrata) {
|
|
92665
92661
|
const inv = errataMcpInvocation();
|
|
92666
92662
|
cfg.mcp["errata"] = { type: "local", command: [inv.command, ...inv.args] };
|
|
92667
|
-
|
|
92663
|
+
writeFileSync28(cfgFile, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
92668
92664
|
}
|
|
92669
92665
|
console.log(`installed OpenCode plugin \u2192 ${file2}`);
|
|
92670
92666
|
if (hadErrata) console.log(` mcp.errata already present in ${cfgFile} \u2014 left untouched`);
|
|
@@ -92691,15 +92687,15 @@ function ensureStatusLine(port) {
|
|
|
92691
92687
|
}
|
|
92692
92688
|
}
|
|
92693
92689
|
async function installClaudeHooks(port) {
|
|
92694
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
92695
|
-
const { join:
|
|
92696
|
-
const dir =
|
|
92697
|
-
if (!
|
|
92698
|
-
const file2 =
|
|
92690
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync38, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92691
|
+
const { join: join45 } = await import("node:path");
|
|
92692
|
+
const dir = join45(ROOT, ".claude");
|
|
92693
|
+
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
92694
|
+
const file2 = join45(dir, "settings.json");
|
|
92699
92695
|
let settings = {};
|
|
92700
|
-
if (
|
|
92696
|
+
if (existsSync37(file2)) {
|
|
92701
92697
|
try {
|
|
92702
|
-
settings = JSON.parse(
|
|
92698
|
+
settings = JSON.parse(readFileSync38(file2, "utf8"));
|
|
92703
92699
|
} catch {
|
|
92704
92700
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
92705
92701
|
process.exit(2);
|
|
@@ -92747,11 +92743,11 @@ async function installClaudeHooks(port) {
|
|
|
92747
92743
|
list.push({ hooks: [{ type: "command", command: injectCmd }] });
|
|
92748
92744
|
}
|
|
92749
92745
|
removeProjectStatusLine(settings);
|
|
92750
|
-
|
|
92746
|
+
writeFileSync28(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
92751
92747
|
console.log(`installed Claude Code hooks \u2192 ${file2}`);
|
|
92752
92748
|
console.log(` ${ensureStatusLine(port)}`);
|
|
92753
92749
|
await installClaudeMcpConfig();
|
|
92754
|
-
const claudeMd =
|
|
92750
|
+
const claudeMd = join45(ROOT, "CLAUDE.md");
|
|
92755
92751
|
const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
|
|
92756
92752
|
if (recall.kind === "collision") {
|
|
92757
92753
|
console.warn(
|
|
@@ -92763,15 +92759,15 @@ async function installClaudeHooks(port) {
|
|
|
92763
92759
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
92764
92760
|
}
|
|
92765
92761
|
async function installClaudeMcpConfig() {
|
|
92766
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
92767
|
-
const { join:
|
|
92768
|
-
const file2 =
|
|
92762
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync38, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92763
|
+
const { join: join45, dirname: dirname14 } = await import("node:path");
|
|
92764
|
+
const file2 = join45(ROOT, ".mcp.json");
|
|
92769
92765
|
const dir = dirname14(file2);
|
|
92770
|
-
if (!
|
|
92766
|
+
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
92771
92767
|
let cfg = {};
|
|
92772
|
-
if (
|
|
92768
|
+
if (existsSync37(file2)) {
|
|
92773
92769
|
try {
|
|
92774
|
-
cfg = JSON.parse(
|
|
92770
|
+
cfg = JSON.parse(readFileSync38(file2, "utf8"));
|
|
92775
92771
|
} catch {
|
|
92776
92772
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
92777
92773
|
process.exit(2);
|
|
@@ -92779,21 +92775,21 @@ async function installClaudeMcpConfig() {
|
|
|
92779
92775
|
}
|
|
92780
92776
|
cfg.mcpServers ??= {};
|
|
92781
92777
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
92782
|
-
|
|
92778
|
+
writeFileSync28(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
92783
92779
|
console.log(`installed Claude Code MCP server config \u2192 ${file2}`);
|
|
92784
92780
|
console.log(` Claude Code will spawn \`errata mcp\` on workspace open.`);
|
|
92785
92781
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
92786
92782
|
}
|
|
92787
92783
|
async function installCursorMcpConfig() {
|
|
92788
|
-
const { mkdirSync: mkdirSync11, existsSync:
|
|
92789
|
-
const { join:
|
|
92790
|
-
const dir =
|
|
92791
|
-
if (!
|
|
92792
|
-
const file2 =
|
|
92784
|
+
const { mkdirSync: mkdirSync11, existsSync: existsSync37, readFileSync: readFileSync38, writeFileSync: writeFileSync28 } = await import("node:fs");
|
|
92785
|
+
const { join: join45 } = await import("node:path");
|
|
92786
|
+
const dir = join45(ROOT, ".cursor");
|
|
92787
|
+
if (!existsSync37(dir)) mkdirSync11(dir, { recursive: true });
|
|
92788
|
+
const file2 = join45(dir, "mcp.json");
|
|
92793
92789
|
let cfg = {};
|
|
92794
|
-
if (
|
|
92790
|
+
if (existsSync37(file2)) {
|
|
92795
92791
|
try {
|
|
92796
|
-
cfg = JSON.parse(
|
|
92792
|
+
cfg = JSON.parse(readFileSync38(file2, "utf8"));
|
|
92797
92793
|
} catch {
|
|
92798
92794
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
92799
92795
|
process.exit(2);
|
|
@@ -92801,7 +92797,7 @@ async function installCursorMcpConfig() {
|
|
|
92801
92797
|
}
|
|
92802
92798
|
cfg.mcpServers ??= {};
|
|
92803
92799
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
92804
|
-
|
|
92800
|
+
writeFileSync28(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
92805
92801
|
console.log(`installed Cursor MCP server config \u2192 ${file2}`);
|
|
92806
92802
|
console.log(` Cursor will spawn \`errata mcp\` on workspace open.`);
|
|
92807
92803
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses`);
|
|
@@ -92812,7 +92808,7 @@ async function installCodexHooks(port) {
|
|
|
92812
92808
|
const gitRoot = nearestGitRoot(process.cwd());
|
|
92813
92809
|
const hookRoot = gitRoot && mainCheckoutOfWorktree(gitRoot) ? gitRoot : ROOT;
|
|
92814
92810
|
const file2 = writeCodexHooks(hookRoot, port);
|
|
92815
|
-
const instructions = writeManagedBlock(
|
|
92811
|
+
const instructions = writeManagedBlock(join44(hookRoot, "AGENTS.md"), {
|
|
92816
92812
|
body: AGENTS_POINTER_BODY,
|
|
92817
92813
|
stable: true
|
|
92818
92814
|
});
|
|
@@ -93216,9 +93212,9 @@ async function cmdDash(args2) {
|
|
|
93216
93212
|
await yieldToLoop2();
|
|
93217
93213
|
try {
|
|
93218
93214
|
const items = selectDurableMemory(handle2.sharedStore, r.engine.profile, {
|
|
93219
|
-
atCommit: readGitRefState(
|
|
93215
|
+
atCommit: readGitRefState(join44(r.root, ".git")).sha ?? void 0
|
|
93220
93216
|
});
|
|
93221
|
-
const res = bleedRules(
|
|
93217
|
+
const res = bleedRules(join44(r.root, ".claude", "rules"), items);
|
|
93222
93218
|
if (res.written || res.pruned) {
|
|
93223
93219
|
console.log(
|
|
93224
93220
|
`[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")
|