@inerrata-corporation/errata 2.0.0-dev.89 → 2.0.0-dev.90
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 +302 -265
- package/package.json +1 -1
- package/pass-worker.mjs +14 -0
package/errata.mjs
CHANGED
|
@@ -16024,7 +16024,7 @@ function writeManagedBlock(filePath, opts) {
|
|
|
16024
16024
|
const newBody = opts.body.trim();
|
|
16025
16025
|
const newHash = blockHash(newBody);
|
|
16026
16026
|
const generated = opts.generatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
16027
|
-
const startMarker = `<!-- ERRATA:START version=2 generated=${generated} hash=${newHash} -->`;
|
|
16027
|
+
const startMarker = opts.stable ? `<!-- ERRATA:START version=2 hash=${newHash} -->` : `<!-- ERRATA:START version=2 generated=${generated} hash=${newHash} -->`;
|
|
16028
16028
|
const endMarker = `<!-- ERRATA:END -->`;
|
|
16029
16029
|
const blockText = `${startMarker}
|
|
16030
16030
|
|
|
@@ -16053,6 +16053,9 @@ ${blockText}`, "utf8");
|
|
|
16053
16053
|
if (expectedHash && expectedHash !== actualHash && !opts.force) {
|
|
16054
16054
|
return { kind: "collision", expectedHash, actualHash };
|
|
16055
16055
|
}
|
|
16056
|
+
if (opts.stable && existingBody === newBody && startM[0] === startMarker) {
|
|
16057
|
+
return { kind: "written", previousHash: actualHash, newHash };
|
|
16058
|
+
}
|
|
16056
16059
|
const before = current.slice(0, startM.index);
|
|
16057
16060
|
const after = current.slice(endM.index + endM[0].length).replace(/^\s*/, "");
|
|
16058
16061
|
const written = after ? `${before}${blockText.trim()}
|
|
@@ -16062,21 +16065,6 @@ ${after}` : `${before}${blockText.trim()}
|
|
|
16062
16065
|
writeFileSync(filePath, written, "utf8");
|
|
16063
16066
|
return { kind: "written", previousHash: expectedHash ?? null, newHash };
|
|
16064
16067
|
}
|
|
16065
|
-
function readManagedBlock(filePath) {
|
|
16066
|
-
if (!existsSync(filePath)) return null;
|
|
16067
|
-
const current = readFileSync(filePath, "utf8");
|
|
16068
|
-
const startM = current.match(START_RE);
|
|
16069
|
-
const endM = current.match(END_RE);
|
|
16070
|
-
if (!startM || !endM || startM.index === void 0 || endM.index === void 0) {
|
|
16071
|
-
return null;
|
|
16072
|
-
}
|
|
16073
|
-
return current.slice(startM.index + startM[0].length, endM.index).trim();
|
|
16074
|
-
}
|
|
16075
|
-
function readManagedBlockWithHash(filePath) {
|
|
16076
|
-
const body2 = readManagedBlock(filePath);
|
|
16077
|
-
if (body2 === null) return null;
|
|
16078
|
-
return { body: body2, hash: sha256(body2).slice(0, 16) };
|
|
16079
|
-
}
|
|
16080
16068
|
var START_RE, END_RE, blockHash;
|
|
16081
16069
|
var init_agents_md = __esm({
|
|
16082
16070
|
"../../packages/context-writer/src/agents-md.ts"() {
|
|
@@ -16088,9 +16076,57 @@ var init_agents_md = __esm({
|
|
|
16088
16076
|
}
|
|
16089
16077
|
});
|
|
16090
16078
|
|
|
16091
|
-
// ../../packages/context-writer/src/
|
|
16092
|
-
import { existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
16079
|
+
// ../../packages/context-writer/src/context-file.ts
|
|
16080
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
16093
16081
|
import { dirname, join } from "node:path";
|
|
16082
|
+
function contextFilePath(root) {
|
|
16083
|
+
return join(root, ".errata", "context.md");
|
|
16084
|
+
}
|
|
16085
|
+
function writeContextFile(root, body2) {
|
|
16086
|
+
const path2 = contextFilePath(root);
|
|
16087
|
+
mkdirSync(dirname(path2), { recursive: true });
|
|
16088
|
+
const text = `${body2.trim()}
|
|
16089
|
+
`;
|
|
16090
|
+
writeFileSync2(path2, text, "utf8");
|
|
16091
|
+
return contextHash(text);
|
|
16092
|
+
}
|
|
16093
|
+
function contextHash(body2) {
|
|
16094
|
+
return sha256(body2.replace(/\r\n?/g, "\n").trim()).slice(0, 16);
|
|
16095
|
+
}
|
|
16096
|
+
function readContextFileWithHash(root) {
|
|
16097
|
+
const path2 = contextFilePath(root);
|
|
16098
|
+
if (!existsSync2(path2)) return null;
|
|
16099
|
+
try {
|
|
16100
|
+
const raw2 = readFileSync2(path2, "utf8");
|
|
16101
|
+
const body2 = raw2.trim();
|
|
16102
|
+
if (!body2) return null;
|
|
16103
|
+
return { body: body2, hash: contextHash(raw2) };
|
|
16104
|
+
} catch {
|
|
16105
|
+
return null;
|
|
16106
|
+
}
|
|
16107
|
+
}
|
|
16108
|
+
var AGENTS_POINTER_BODY;
|
|
16109
|
+
var init_context_file = __esm({
|
|
16110
|
+
"../../packages/context-writer/src/context-file.ts"() {
|
|
16111
|
+
"use strict";
|
|
16112
|
+
init_src();
|
|
16113
|
+
AGENTS_POINTER_BODY = [
|
|
16114
|
+
"## Errata context",
|
|
16115
|
+
"",
|
|
16116
|
+
"Live agent context for this checkout \u2014 priors, open problems, the capture",
|
|
16117
|
+
"protocol \u2014 is maintained by the errata daemon at `.errata/context.md`.",
|
|
16118
|
+
"",
|
|
16119
|
+
"It is gitignored ON PURPOSE: it is this machine's runtime state, not repo",
|
|
16120
|
+
"content. Committing it would prime your teammates with your graph.",
|
|
16121
|
+
"",
|
|
16122
|
+
"@.errata/context.md"
|
|
16123
|
+
].join("\n");
|
|
16124
|
+
}
|
|
16125
|
+
});
|
|
16126
|
+
|
|
16127
|
+
// ../../packages/context-writer/src/redirectors.ts
|
|
16128
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
16129
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
16094
16130
|
function defaultRedirectors() {
|
|
16095
16131
|
return [
|
|
16096
16132
|
{
|
|
@@ -16122,13 +16158,13 @@ function installRedirectors(workspaceRoot, redirectors = defaultRedirectors()) {
|
|
|
16122
16158
|
const written = [];
|
|
16123
16159
|
const skipped = [];
|
|
16124
16160
|
for (const r of redirectors) {
|
|
16125
|
-
const abs =
|
|
16126
|
-
if (
|
|
16161
|
+
const abs = join2(workspaceRoot, r.relPath);
|
|
16162
|
+
if (existsSync3(abs)) {
|
|
16127
16163
|
skipped.push(r.relPath);
|
|
16128
16164
|
continue;
|
|
16129
16165
|
}
|
|
16130
|
-
|
|
16131
|
-
|
|
16166
|
+
mkdirSync2(dirname2(abs), { recursive: true });
|
|
16167
|
+
writeFileSync3(abs, r.content, "utf8");
|
|
16132
16168
|
written.push(r.relPath);
|
|
16133
16169
|
}
|
|
16134
16170
|
return { written, skipped };
|
|
@@ -21118,8 +21154,8 @@ var init_bleed_memory = __esm({
|
|
|
21118
21154
|
});
|
|
21119
21155
|
|
|
21120
21156
|
// ../../packages/context-writer/src/bleed-rules.ts
|
|
21121
|
-
import { existsSync as
|
|
21122
|
-
import { join as
|
|
21157
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync3, rmSync, writeFileSync as writeFileSync4 } from "node:fs";
|
|
21158
|
+
import { join as join3 } from "node:path";
|
|
21123
21159
|
function formatRuleFile(item) {
|
|
21124
21160
|
const frontmatter = item.paths && item.paths.length > 0 ? `---
|
|
21125
21161
|
paths:
|
|
@@ -21132,21 +21168,21 @@ ${item.body.trim()}
|
|
|
21132
21168
|
`;
|
|
21133
21169
|
}
|
|
21134
21170
|
function bleedRules(rulesDir, items) {
|
|
21135
|
-
if (!
|
|
21171
|
+
if (!existsSync4(rulesDir)) mkdirSync3(rulesDir, { recursive: true });
|
|
21136
21172
|
const wanted = new Map(items.map((i2) => [fileFor(i2.slug), i2]));
|
|
21137
21173
|
let written = 0;
|
|
21138
21174
|
let created = 0;
|
|
21139
21175
|
for (const [file2, item] of wanted) {
|
|
21140
|
-
const path2 =
|
|
21141
|
-
if (!
|
|
21142
|
-
|
|
21176
|
+
const path2 = join3(rulesDir, file2);
|
|
21177
|
+
if (!existsSync4(path2)) created++;
|
|
21178
|
+
writeFileSync4(path2, formatRuleFile(item), "utf8");
|
|
21143
21179
|
written++;
|
|
21144
21180
|
}
|
|
21145
21181
|
let pruned = 0;
|
|
21146
21182
|
for (const f of readdirSync(rulesDir)) {
|
|
21147
21183
|
if (!f.startsWith(PREFIX) || !f.endsWith(".md") || wanted.has(f)) continue;
|
|
21148
|
-
if (
|
|
21149
|
-
rmSync(
|
|
21184
|
+
if (readFileSync3(join3(rulesDir, f), "utf8").includes(MARKER)) {
|
|
21185
|
+
rmSync(join3(rulesDir, f));
|
|
21150
21186
|
pruned++;
|
|
21151
21187
|
}
|
|
21152
21188
|
}
|
|
@@ -21233,6 +21269,7 @@ var init_src5 = __esm({
|
|
|
21233
21269
|
"../../packages/context-writer/src/index.ts"() {
|
|
21234
21270
|
"use strict";
|
|
21235
21271
|
init_agents_md();
|
|
21272
|
+
init_context_file();
|
|
21236
21273
|
init_redirectors();
|
|
21237
21274
|
init_render();
|
|
21238
21275
|
init_bleed_memory();
|
|
@@ -22150,34 +22187,34 @@ __export(paths_exports, {
|
|
|
22150
22187
|
workspaceDir: () => workspaceDir,
|
|
22151
22188
|
workspacePaths: () => workspacePaths
|
|
22152
22189
|
});
|
|
22153
|
-
import { mkdirSync as
|
|
22154
|
-
import { dirname as
|
|
22190
|
+
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
22191
|
+
import { dirname as dirname3, join as join4 } from "node:path";
|
|
22155
22192
|
function globalDir() {
|
|
22156
22193
|
const p = envPaths("errata", { suffix: "" });
|
|
22157
22194
|
return p.config;
|
|
22158
22195
|
}
|
|
22159
22196
|
function globalConfigPath() {
|
|
22160
|
-
return process.env["ERRATA_CONFIG_PATH"] ??
|
|
22197
|
+
return process.env["ERRATA_CONFIG_PATH"] ?? join4(globalDir(), "config.json");
|
|
22161
22198
|
}
|
|
22162
22199
|
function daemonLogPath() {
|
|
22163
|
-
|
|
22164
|
-
return
|
|
22200
|
+
mkdirSync4(globalDir(), { recursive: true });
|
|
22201
|
+
return join4(globalDir(), "daemon.log");
|
|
22165
22202
|
}
|
|
22166
22203
|
function globalDaemonLock() {
|
|
22167
|
-
return process.env["ERRATA_DAEMON_LOCK"] ??
|
|
22204
|
+
return process.env["ERRATA_DAEMON_LOCK"] ?? join4(globalDir(), "daemon.lock");
|
|
22168
22205
|
}
|
|
22169
22206
|
function sharedStorePath() {
|
|
22170
|
-
return process.env["ERRATA_SHARED_DB"] ??
|
|
22207
|
+
return process.env["ERRATA_SHARED_DB"] ?? join4(globalDir(), "shared", "graph.db");
|
|
22171
22208
|
}
|
|
22172
22209
|
function workspaceDir(workspaceRoot) {
|
|
22173
|
-
return
|
|
22210
|
+
return join4(workspaceRoot, ".errata");
|
|
22174
22211
|
}
|
|
22175
22212
|
function ensureDir(p) {
|
|
22176
|
-
|
|
22213
|
+
mkdirSync4(p, { recursive: true });
|
|
22177
22214
|
return p;
|
|
22178
22215
|
}
|
|
22179
22216
|
function ensureParent(p) {
|
|
22180
|
-
|
|
22217
|
+
mkdirSync4(dirname3(p), { recursive: true });
|
|
22181
22218
|
return p;
|
|
22182
22219
|
}
|
|
22183
22220
|
function workspacePaths(root) {
|
|
@@ -22185,15 +22222,15 @@ function workspacePaths(root) {
|
|
|
22185
22222
|
return {
|
|
22186
22223
|
root,
|
|
22187
22224
|
configDir: dir,
|
|
22188
|
-
workspaceJson:
|
|
22189
|
-
eventLog:
|
|
22190
|
-
castalia:
|
|
22191
|
-
reviewQueue:
|
|
22192
|
-
outbox:
|
|
22193
|
-
daemonLock:
|
|
22194
|
-
identityAudit:
|
|
22195
|
-
skillsDir:
|
|
22196
|
-
skillsManifest:
|
|
22225
|
+
workspaceJson: join4(dir, "workspace.json"),
|
|
22226
|
+
eventLog: join4(dir, "eventlog.sqlite"),
|
|
22227
|
+
castalia: join4(dir, "castalia.db"),
|
|
22228
|
+
reviewQueue: join4(dir, "review-queue.json"),
|
|
22229
|
+
outbox: join4(dir, "outbox"),
|
|
22230
|
+
daemonLock: join4(dir, "daemon.lock"),
|
|
22231
|
+
identityAudit: join4(dir, "identity-audit.log"),
|
|
22232
|
+
skillsDir: join4(dir, "skills"),
|
|
22233
|
+
skillsManifest: join4(dir, "skills.json")
|
|
22197
22234
|
};
|
|
22198
22235
|
}
|
|
22199
22236
|
var init_paths = __esm({
|
|
@@ -22204,7 +22241,7 @@ var init_paths = __esm({
|
|
|
22204
22241
|
});
|
|
22205
22242
|
|
|
22206
22243
|
// src/config.ts
|
|
22207
|
-
import { existsSync as
|
|
22244
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync5 } from "node:fs";
|
|
22208
22245
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22209
22246
|
function defaultConfig() {
|
|
22210
22247
|
return {
|
|
@@ -22230,13 +22267,13 @@ function defaultConfig() {
|
|
|
22230
22267
|
}
|
|
22231
22268
|
function loadConfig() {
|
|
22232
22269
|
const p = globalConfigPath();
|
|
22233
|
-
if (!
|
|
22270
|
+
if (!existsSync5(p)) {
|
|
22234
22271
|
ensureDir(globalDir());
|
|
22235
22272
|
const cfg = defaultConfig();
|
|
22236
22273
|
saveConfig({ ...cfg, cloudUrl: DEFAULT_CLOUD_URL });
|
|
22237
22274
|
return cfg;
|
|
22238
22275
|
}
|
|
22239
|
-
const raw2 =
|
|
22276
|
+
const raw2 = readFileSync4(p, "utf8").replace(/^\uFEFF/, "");
|
|
22240
22277
|
const parsed = JSON.parse(raw2);
|
|
22241
22278
|
const base = defaultConfig();
|
|
22242
22279
|
const envCloudUrl = process.env["ERRATA_CLOUD_URL"];
|
|
@@ -22257,7 +22294,7 @@ function loadConfig() {
|
|
|
22257
22294
|
}
|
|
22258
22295
|
function saveConfig(cfg) {
|
|
22259
22296
|
ensureDir(globalDir());
|
|
22260
|
-
|
|
22297
|
+
writeFileSync5(globalConfigPath(), JSON.stringify(cfg, null, 2), { encoding: "utf8", mode: 384 });
|
|
22261
22298
|
}
|
|
22262
22299
|
function machineId() {
|
|
22263
22300
|
const fromEnv = process.env["ERRATA_MACHINE_ID"];
|
|
@@ -24889,17 +24926,17 @@ var init_agent_signals = __esm({
|
|
|
24889
24926
|
});
|
|
24890
24927
|
|
|
24891
24928
|
// src/review.ts
|
|
24892
|
-
import { existsSync as
|
|
24929
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5, writeFileSync as writeFileSync6 } from "node:fs";
|
|
24893
24930
|
function loadReviewQueue(paths) {
|
|
24894
|
-
if (!
|
|
24931
|
+
if (!existsSync6(paths.reviewQueue)) return [];
|
|
24895
24932
|
try {
|
|
24896
|
-
return JSON.parse(
|
|
24933
|
+
return JSON.parse(readFileSync5(paths.reviewQueue, "utf8"));
|
|
24897
24934
|
} catch {
|
|
24898
24935
|
return [];
|
|
24899
24936
|
}
|
|
24900
24937
|
}
|
|
24901
24938
|
function saveReviewQueue(paths, queue) {
|
|
24902
|
-
|
|
24939
|
+
writeFileSync6(paths.reviewQueue, JSON.stringify(queue, null, 2), "utf8");
|
|
24903
24940
|
}
|
|
24904
24941
|
function addProposal(paths, store, node2, reason, surprise) {
|
|
24905
24942
|
const queue = loadReviewQueue(paths);
|
|
@@ -25497,9 +25534,9 @@ var init_dual_augment = __esm({
|
|
|
25497
25534
|
});
|
|
25498
25535
|
|
|
25499
25536
|
// ../../packages/embedding/src/model.ts
|
|
25500
|
-
import { mkdirSync as
|
|
25537
|
+
import { mkdirSync as mkdirSync5, existsSync as existsSync7 } from "node:fs";
|
|
25501
25538
|
import { homedir as homedir2 } from "node:os";
|
|
25502
|
-
import { dirname as
|
|
25539
|
+
import { dirname as dirname4, join as join5 } from "node:path";
|
|
25503
25540
|
import { createRequire } from "node:module";
|
|
25504
25541
|
function semanticFloorFor(version2) {
|
|
25505
25542
|
if (version2 === EMBEDDING_VERSION || version2 === MODEL_EMBEDDING_VERSION) return 0.25;
|
|
@@ -25514,7 +25551,7 @@ function noteHashFallback() {
|
|
|
25514
25551
|
);
|
|
25515
25552
|
}
|
|
25516
25553
|
function getCacheDir() {
|
|
25517
|
-
return process.env["ERRATA_MODEL_CACHE"] ??
|
|
25554
|
+
return process.env["ERRATA_MODEL_CACHE"] ?? join5(homedir2(), ".errata", "models");
|
|
25518
25555
|
}
|
|
25519
25556
|
async function loadTransformers() {
|
|
25520
25557
|
try {
|
|
@@ -25523,9 +25560,9 @@ async function loadTransformers() {
|
|
|
25523
25560
|
void err2;
|
|
25524
25561
|
}
|
|
25525
25562
|
try {
|
|
25526
|
-
const seaResourceBase =
|
|
25563
|
+
const seaResourceBase = join5(
|
|
25527
25564
|
// execPath dir is where errata.exe lives; resources/ rides alongside.
|
|
25528
|
-
|
|
25565
|
+
dirname4(process.execPath),
|
|
25529
25566
|
"resources",
|
|
25530
25567
|
"_resolve.js"
|
|
25531
25568
|
);
|
|
@@ -25538,7 +25575,7 @@ async function loadTransformers() {
|
|
|
25538
25575
|
}
|
|
25539
25576
|
async function loadPipeline() {
|
|
25540
25577
|
const cacheDir = getCacheDir();
|
|
25541
|
-
if (!
|
|
25578
|
+
if (!existsSync7(cacheDir)) mkdirSync5(cacheDir, { recursive: true });
|
|
25542
25579
|
try {
|
|
25543
25580
|
const tx = await loadTransformers();
|
|
25544
25581
|
if (!tx) {
|
|
@@ -25828,7 +25865,7 @@ var init_diagnostic_matcher = __esm({
|
|
|
25828
25865
|
});
|
|
25829
25866
|
|
|
25830
25867
|
// ../../packages/generalizer/src/generalizer.ts
|
|
25831
|
-
import { isAbsolute, join as
|
|
25868
|
+
import { isAbsolute, join as join6, relative } from "node:path";
|
|
25832
25869
|
async function runGeneralizer(opts) {
|
|
25833
25870
|
const report = {
|
|
25834
25871
|
eventsProcessed: 0,
|
|
@@ -25936,7 +25973,7 @@ function extractDiagnostics(ev) {
|
|
|
25936
25973
|
function diagRelPath(file2, cwd, workspaceRoot) {
|
|
25937
25974
|
const norm = (p) => p.replace(/\\/g, "/");
|
|
25938
25975
|
if (!workspaceRoot) return norm(file2);
|
|
25939
|
-
const abs = isAbsolute(file2) ? file2 :
|
|
25976
|
+
const abs = isAbsolute(file2) ? file2 : join6(cwd ?? workspaceRoot, file2);
|
|
25940
25977
|
return norm(relative(workspaceRoot, abs));
|
|
25941
25978
|
}
|
|
25942
25979
|
function extractErrorSignature(ev) {
|
|
@@ -27308,16 +27345,16 @@ var init_src10 = __esm({
|
|
|
27308
27345
|
});
|
|
27309
27346
|
|
|
27310
27347
|
// src/symbol-summaries.ts
|
|
27311
|
-
import { existsSync as
|
|
27312
|
-
import { join as
|
|
27348
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, writeFileSync as writeFileSync7 } from "node:fs";
|
|
27349
|
+
import { join as join7 } from "node:path";
|
|
27313
27350
|
function symbolSummariesPath(configDir) {
|
|
27314
|
-
return
|
|
27351
|
+
return join7(configDir, "symbol-summaries.json");
|
|
27315
27352
|
}
|
|
27316
27353
|
function loadSymbolSummaryCache(configDir) {
|
|
27317
27354
|
const p = symbolSummariesPath(configDir);
|
|
27318
|
-
if (
|
|
27355
|
+
if (existsSync8(p)) {
|
|
27319
27356
|
try {
|
|
27320
|
-
const raw2 = JSON.parse(
|
|
27357
|
+
const raw2 = JSON.parse(readFileSync6(p, "utf8"));
|
|
27321
27358
|
if (raw2 && raw2.version === 1 && raw2.entries && typeof raw2.entries === "object") {
|
|
27322
27359
|
return { version: 1, entries: raw2.entries };
|
|
27323
27360
|
}
|
|
@@ -27327,7 +27364,7 @@ function loadSymbolSummaryCache(configDir) {
|
|
|
27327
27364
|
return { version: 1, entries: {} };
|
|
27328
27365
|
}
|
|
27329
27366
|
function saveSymbolSummaryCache(configDir, cache) {
|
|
27330
|
-
|
|
27367
|
+
writeFileSync7(symbolSummariesPath(configDir), JSON.stringify(cache, null, 2), "utf8");
|
|
27331
27368
|
}
|
|
27332
27369
|
function summariesByBodyHash(cache) {
|
|
27333
27370
|
const m = /* @__PURE__ */ new Map();
|
|
@@ -27401,7 +27438,7 @@ function readSnippet(workspaceRoot, attrs) {
|
|
|
27401
27438
|
return void 0;
|
|
27402
27439
|
}
|
|
27403
27440
|
try {
|
|
27404
|
-
const buf =
|
|
27441
|
+
const buf = readFileSync6(join7(workspaceRoot, ...relPath.split("/")));
|
|
27405
27442
|
const slice = buf.subarray(Math.max(0, startByte), Math.min(buf.length, endByte));
|
|
27406
27443
|
const text = slice.toString("utf8");
|
|
27407
27444
|
return text.length > MAX_SNIPPET_CHARS ? text.slice(0, MAX_SNIPPET_CHARS) : text;
|
|
@@ -27701,9 +27738,9 @@ var init_identity2 = __esm({
|
|
|
27701
27738
|
});
|
|
27702
27739
|
|
|
27703
27740
|
// ../../packages/indexer/src/pipeline.ts
|
|
27704
|
-
import { appendFileSync, readFileSync as
|
|
27741
|
+
import { appendFileSync, readFileSync as readFileSync7, statSync } from "node:fs";
|
|
27705
27742
|
import { readdir } from "node:fs/promises";
|
|
27706
|
-
import { extname, join as
|
|
27743
|
+
import { extname, join as join8, relative as relative2, sep } from "node:path";
|
|
27707
27744
|
import { createHash as createHash3 } from "node:crypto";
|
|
27708
27745
|
import { execFileSync } from "node:child_process";
|
|
27709
27746
|
function nowTs() {
|
|
@@ -27836,7 +27873,7 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
27836
27873
|
for (const rel of [...changedRelPaths]) {
|
|
27837
27874
|
let h;
|
|
27838
27875
|
try {
|
|
27839
|
-
h = createHash3("sha256").update(
|
|
27876
|
+
h = createHash3("sha256").update(readFileSync7(join8(rootPath, rel))).digest("hex");
|
|
27840
27877
|
} catch {
|
|
27841
27878
|
continue;
|
|
27842
27879
|
}
|
|
@@ -27883,13 +27920,13 @@ async function incrementalReindex(store, rootPath, workspaceId2, changedAbsPaths
|
|
|
27883
27920
|
let parsedFiles = 0;
|
|
27884
27921
|
for (const rel of changedRelPaths) {
|
|
27885
27922
|
if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
|
|
27886
|
-
const abs =
|
|
27923
|
+
const abs = join8(rootPath, ...rel.split("/"));
|
|
27887
27924
|
const ext = extname(abs).toLowerCase();
|
|
27888
27925
|
const provider = providers.find((p) => p.fileExtensions.includes(ext));
|
|
27889
27926
|
if (!provider) continue;
|
|
27890
27927
|
let symbols;
|
|
27891
27928
|
try {
|
|
27892
|
-
symbols = provider.extractSymbols(
|
|
27929
|
+
symbols = provider.extractSymbols(readFileSync7(abs, "utf8"), abs);
|
|
27893
27930
|
} catch {
|
|
27894
27931
|
continue;
|
|
27895
27932
|
}
|
|
@@ -28195,7 +28232,7 @@ async function runIndexer(store, opts) {
|
|
|
28195
28232
|
report.filesSkipped++;
|
|
28196
28233
|
continue;
|
|
28197
28234
|
}
|
|
28198
|
-
source =
|
|
28235
|
+
source = readFileSync7(f.absPath, "utf8");
|
|
28199
28236
|
} catch {
|
|
28200
28237
|
report.filesSkipped++;
|
|
28201
28238
|
continue;
|
|
@@ -28253,7 +28290,7 @@ async function runIndexer(store, opts) {
|
|
|
28253
28290
|
const depth = fileNode.relPath.split("/").length;
|
|
28254
28291
|
if (depth !== 3) continue;
|
|
28255
28292
|
try {
|
|
28256
|
-
const pkg = JSON.parse(
|
|
28293
|
+
const pkg = JSON.parse(readFileSync7(fileNode.absPath, "utf8"));
|
|
28257
28294
|
if (!pkg.name) continue;
|
|
28258
28295
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
28259
28296
|
const candidates = [
|
|
@@ -28635,7 +28672,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
28635
28672
|
for (const ent of entries) {
|
|
28636
28673
|
if (ignores.has(ent.name)) continue;
|
|
28637
28674
|
if (ent.name.startsWith(".") && ent.name !== ".") continue;
|
|
28638
|
-
const abs =
|
|
28675
|
+
const abs = join8(current, ent.name);
|
|
28639
28676
|
if (ent.isDirectory()) {
|
|
28640
28677
|
await scan(root, abs, ignores, providers, out2);
|
|
28641
28678
|
} else if (ent.isFile()) {
|
|
@@ -28681,7 +28718,7 @@ function gitListFiles(root, ignores, providers) {
|
|
|
28681
28718
|
if (segs.some((s) => ignores.has(s) || s.startsWith(".") && s.length > 1)) {
|
|
28682
28719
|
continue;
|
|
28683
28720
|
}
|
|
28684
|
-
const abs =
|
|
28721
|
+
const abs = join8(root, rel);
|
|
28685
28722
|
let size;
|
|
28686
28723
|
try {
|
|
28687
28724
|
size = statSync(abs).size;
|
|
@@ -28704,7 +28741,7 @@ function upsertFile(store, id, f, workspaceId2) {
|
|
|
28704
28741
|
const now = nowTs();
|
|
28705
28742
|
let contentHash;
|
|
28706
28743
|
try {
|
|
28707
|
-
contentHash = createHash3("sha256").update(
|
|
28744
|
+
contentHash = createHash3("sha256").update(readFileSync7(f.absPath)).digest("hex");
|
|
28708
28745
|
} catch {
|
|
28709
28746
|
}
|
|
28710
28747
|
const node2 = {
|
|
@@ -33067,42 +33104,42 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
33067
33104
|
|
|
33068
33105
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
33069
33106
|
import { fileURLToPath } from "node:url";
|
|
33070
|
-
import { dirname as
|
|
33071
|
-
import { existsSync as
|
|
33107
|
+
import { dirname as dirname5, join as join9 } from "node:path";
|
|
33108
|
+
import { existsSync as existsSync9, readdirSync as readdirSync2 } from "node:fs";
|
|
33072
33109
|
import { createRequire as createRequire2 } from "node:module";
|
|
33073
33110
|
function entryDir() {
|
|
33074
33111
|
try {
|
|
33075
33112
|
const url2 = import.meta?.url;
|
|
33076
33113
|
if (typeof url2 === "string" && url2.length > 0) {
|
|
33077
|
-
return
|
|
33114
|
+
return dirname5(fileURLToPath(url2));
|
|
33078
33115
|
}
|
|
33079
33116
|
} catch {
|
|
33080
33117
|
}
|
|
33081
|
-
return
|
|
33118
|
+
return dirname5(process.execPath);
|
|
33082
33119
|
}
|
|
33083
33120
|
function findWasmDir() {
|
|
33084
33121
|
const here = entryDir();
|
|
33085
|
-
const seaWasm =
|
|
33086
|
-
if (
|
|
33122
|
+
const seaWasm = join9(here, "resources", "wasm");
|
|
33123
|
+
if (existsSync9(join9(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
33087
33124
|
let dir = here;
|
|
33088
33125
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
33089
|
-
const flat =
|
|
33126
|
+
const flat = join9(
|
|
33090
33127
|
dir,
|
|
33091
33128
|
"node_modules",
|
|
33092
33129
|
"@vscode",
|
|
33093
33130
|
"tree-sitter-wasm",
|
|
33094
33131
|
"wasm"
|
|
33095
33132
|
);
|
|
33096
|
-
if (
|
|
33097
|
-
dir =
|
|
33133
|
+
if (existsSync9(join9(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
33134
|
+
dir = dirname5(dir);
|
|
33098
33135
|
}
|
|
33099
33136
|
let root = here;
|
|
33100
33137
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
33101
|
-
const pnpmDir =
|
|
33102
|
-
if (
|
|
33138
|
+
const pnpmDir = join9(root, "node_modules", ".pnpm");
|
|
33139
|
+
if (existsSync9(pnpmDir)) {
|
|
33103
33140
|
for (const entry of readdirSync2(pnpmDir)) {
|
|
33104
33141
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
33105
|
-
const candidate =
|
|
33142
|
+
const candidate = join9(
|
|
33106
33143
|
pnpmDir,
|
|
33107
33144
|
entry,
|
|
33108
33145
|
"node_modules",
|
|
@@ -33110,13 +33147,13 @@ function findWasmDir() {
|
|
|
33110
33147
|
"tree-sitter-wasm",
|
|
33111
33148
|
"wasm"
|
|
33112
33149
|
);
|
|
33113
|
-
if (
|
|
33150
|
+
if (existsSync9(join9(candidate, "tree-sitter-typescript.wasm"))) {
|
|
33114
33151
|
return candidate;
|
|
33115
33152
|
}
|
|
33116
33153
|
}
|
|
33117
33154
|
}
|
|
33118
33155
|
}
|
|
33119
|
-
root =
|
|
33156
|
+
root = dirname5(root);
|
|
33120
33157
|
}
|
|
33121
33158
|
throw new Error(
|
|
33122
33159
|
"@vscode/tree-sitter-wasm grammar files not found \u2014 is the package installed?"
|
|
@@ -33124,33 +33161,33 @@ function findWasmDir() {
|
|
|
33124
33161
|
}
|
|
33125
33162
|
function findRuntimeDir() {
|
|
33126
33163
|
const here = entryDir();
|
|
33127
|
-
const seaRuntime =
|
|
33128
|
-
if (
|
|
33164
|
+
const seaRuntime = join9(here, "resources", "wasm");
|
|
33165
|
+
if (existsSync9(join9(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
33129
33166
|
let dir = here;
|
|
33130
33167
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
33131
|
-
const flat =
|
|
33132
|
-
if (
|
|
33133
|
-
dir =
|
|
33168
|
+
const flat = join9(dir, "node_modules", "web-tree-sitter");
|
|
33169
|
+
if (existsSync9(join9(flat, "web-tree-sitter.wasm"))) return flat;
|
|
33170
|
+
dir = dirname5(dir);
|
|
33134
33171
|
}
|
|
33135
33172
|
let root = here;
|
|
33136
33173
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
33137
|
-
const pnpmDir =
|
|
33138
|
-
if (
|
|
33174
|
+
const pnpmDir = join9(root, "node_modules", ".pnpm");
|
|
33175
|
+
if (existsSync9(pnpmDir)) {
|
|
33139
33176
|
for (const entry of readdirSync2(pnpmDir)) {
|
|
33140
33177
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
33141
|
-
const candidate =
|
|
33178
|
+
const candidate = join9(
|
|
33142
33179
|
pnpmDir,
|
|
33143
33180
|
entry,
|
|
33144
33181
|
"node_modules",
|
|
33145
33182
|
"web-tree-sitter"
|
|
33146
33183
|
);
|
|
33147
|
-
if (
|
|
33184
|
+
if (existsSync9(join9(candidate, "web-tree-sitter.wasm"))) {
|
|
33148
33185
|
return candidate;
|
|
33149
33186
|
}
|
|
33150
33187
|
}
|
|
33151
33188
|
}
|
|
33152
33189
|
}
|
|
33153
|
-
root =
|
|
33190
|
+
root = dirname5(root);
|
|
33154
33191
|
}
|
|
33155
33192
|
throw new Error("web-tree-sitter runtime WASM not found");
|
|
33156
33193
|
}
|
|
@@ -33161,7 +33198,7 @@ async function loadWebTreeSitter() {
|
|
|
33161
33198
|
void err2;
|
|
33162
33199
|
}
|
|
33163
33200
|
const here = entryDir();
|
|
33164
|
-
const seaResourceBase =
|
|
33201
|
+
const seaResourceBase = join9(here, "resources", "_resolve.js");
|
|
33165
33202
|
const resourceRequire = createRequire2(seaResourceBase);
|
|
33166
33203
|
return resourceRequire("web-tree-sitter");
|
|
33167
33204
|
}
|
|
@@ -33176,9 +33213,9 @@ async function ensureTreeSitterReady() {
|
|
|
33176
33213
|
await Parser2.init({
|
|
33177
33214
|
locateFile: (name2) => {
|
|
33178
33215
|
if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
|
|
33179
|
-
return
|
|
33216
|
+
return join9(runtime, name2);
|
|
33180
33217
|
}
|
|
33181
|
-
return
|
|
33218
|
+
return join9(grammars, name2);
|
|
33182
33219
|
}
|
|
33183
33220
|
});
|
|
33184
33221
|
})();
|
|
@@ -33190,7 +33227,7 @@ async function loadGrammar(name2) {
|
|
|
33190
33227
|
if (cached2) return cached2;
|
|
33191
33228
|
if (!languageClass) throw new Error("tree-sitter not initialized");
|
|
33192
33229
|
const grammars = findWasmDir();
|
|
33193
|
-
const lang = await languageClass.load(
|
|
33230
|
+
const lang = await languageClass.load(join9(grammars, `${name2}.wasm`));
|
|
33194
33231
|
grammarCache.set(name2, lang);
|
|
33195
33232
|
return lang;
|
|
33196
33233
|
}
|
|
@@ -36092,7 +36129,7 @@ var init_src11 = __esm({
|
|
|
36092
36129
|
// src/reconcile.ts
|
|
36093
36130
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
36094
36131
|
import { readdirSync as readdirSync3, statSync as statSync2 } from "node:fs";
|
|
36095
|
-
import { join as
|
|
36132
|
+
import { join as join10, relative as relative3, sep as sep2 } from "node:path";
|
|
36096
36133
|
function gitSourceFiles(root) {
|
|
36097
36134
|
let stdout;
|
|
36098
36135
|
try {
|
|
@@ -36107,7 +36144,7 @@ function gitSourceFiles(root) {
|
|
|
36107
36144
|
const out2 = [];
|
|
36108
36145
|
for (const rel of stdout.split("\0")) {
|
|
36109
36146
|
if (!rel || !SOURCE_RE.test(rel)) continue;
|
|
36110
|
-
const abs =
|
|
36147
|
+
const abs = join10(root, rel);
|
|
36111
36148
|
if (IGNORED.test(abs)) continue;
|
|
36112
36149
|
out2.push(abs);
|
|
36113
36150
|
}
|
|
@@ -36122,7 +36159,7 @@ function* walkSource(dir) {
|
|
|
36122
36159
|
}
|
|
36123
36160
|
for (const e of entries) {
|
|
36124
36161
|
const name2 = String(e.name);
|
|
36125
|
-
const full =
|
|
36162
|
+
const full = join10(dir, name2);
|
|
36126
36163
|
if (IGNORED.test(full)) continue;
|
|
36127
36164
|
if (e.isDirectory()) yield* walkSource(full);
|
|
36128
36165
|
else if (SOURCE_RE.test(name2)) yield full;
|
|
@@ -36200,7 +36237,7 @@ __export(mcp_exports, {
|
|
|
36200
36237
|
runTool: () => runTool,
|
|
36201
36238
|
searchGraph: () => searchGraph
|
|
36202
36239
|
});
|
|
36203
|
-
import { existsSync as
|
|
36240
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8 } from "node:fs";
|
|
36204
36241
|
import { resolve } from "node:path";
|
|
36205
36242
|
function collectEnrichmentPulls(store, opts = {}) {
|
|
36206
36243
|
const pending = store.findNodesByLabel("Solution").filter((s) => s.attrs["enrichmentPending"] === true).filter((s) => !opts.onlyUnsurfaced || s.attrs["enrichmentSurfaced"] !== true);
|
|
@@ -36313,10 +36350,10 @@ function showNode(store, node2, maxLines) {
|
|
|
36313
36350
|
if (!relPath) return { found: false, reason: "no file owner for node" };
|
|
36314
36351
|
const workspaceRoot = process.cwd();
|
|
36315
36352
|
const absPath = resolve(workspaceRoot, relPath);
|
|
36316
|
-
if (!
|
|
36353
|
+
if (!existsSync10(absPath)) {
|
|
36317
36354
|
return { found: false, reason: `file not found on disk: ${absPath}` };
|
|
36318
36355
|
}
|
|
36319
|
-
const source =
|
|
36356
|
+
const source = readFileSync8(absPath, "utf8");
|
|
36320
36357
|
const attrs = node2.attrs;
|
|
36321
36358
|
let startByte = attrs["bodyStartByte"] ?? attrs["startByte"];
|
|
36322
36359
|
let endByte = attrs["bodyEndByte"] ?? attrs["endByte"];
|
|
@@ -37549,7 +37586,7 @@ var init_mcp = __esm({
|
|
|
37549
37586
|
inputSchema: { type: "object", properties: {} },
|
|
37550
37587
|
handler: () => {
|
|
37551
37588
|
const path2 = sharedStorePath();
|
|
37552
|
-
if (!
|
|
37589
|
+
if (!existsSync10(path2)) return { count: 0, pending: [] };
|
|
37553
37590
|
const shared = openGraphStore({ path: path2 });
|
|
37554
37591
|
try {
|
|
37555
37592
|
const pending = pendingAbstractions(shared);
|
|
@@ -37580,7 +37617,7 @@ var init_mcp = __esm({
|
|
|
37580
37617
|
},
|
|
37581
37618
|
handler: (args2) => {
|
|
37582
37619
|
const path2 = sharedStorePath();
|
|
37583
|
-
if (!
|
|
37620
|
+
if (!existsSync10(path2)) return { count: 0, routes: [] };
|
|
37584
37621
|
const shared = openGraphStore({ path: path2 });
|
|
37585
37622
|
try {
|
|
37586
37623
|
const result = triageOf(shared, {
|
|
@@ -37965,8 +38002,8 @@ __export(vfile_exports, {
|
|
|
37965
38002
|
resolvePath: () => resolvePath,
|
|
37966
38003
|
segmentsOf: () => segmentsOf
|
|
37967
38004
|
});
|
|
37968
|
-
import { writeFileSync as
|
|
37969
|
-
import { join as
|
|
38005
|
+
import { writeFileSync as writeFileSync8 } from "node:fs";
|
|
38006
|
+
import { join as join11, resolve as resolve2, sep as sep3 } from "node:path";
|
|
37970
38007
|
function segmentsOf(rawPath) {
|
|
37971
38008
|
let p = rawPath.replace(/\\/g, "/");
|
|
37972
38009
|
p = p.replace(/^.*\.errata\/g\//, "").replace(/^\/?g\//, "").replace(/^\/+/, "");
|
|
@@ -38040,14 +38077,14 @@ async function renderVFile(rawPath, store, ctx = {}) {
|
|
|
38040
38077
|
}
|
|
38041
38078
|
async function materializeVFile(rawPath, workspaceRoot, store, ctx = {}) {
|
|
38042
38079
|
const segs = segmentsOf(rawPath);
|
|
38043
|
-
const gRoot =
|
|
38080
|
+
const gRoot = join11(workspaceRoot, ".errata", "g");
|
|
38044
38081
|
const abs = resolve2(gRoot, ...segs.length ? segs : ["index"]);
|
|
38045
38082
|
if (abs !== gRoot && !abs.startsWith(gRoot + sep3)) {
|
|
38046
38083
|
throw new Error(`refusing to materialize outside .errata/g: ${rawPath}`);
|
|
38047
38084
|
}
|
|
38048
38085
|
const text = await renderVFile(rawPath, store, ctx);
|
|
38049
38086
|
ensureParent(abs);
|
|
38050
|
-
|
|
38087
|
+
writeFileSync8(abs, text, "utf8");
|
|
38051
38088
|
return abs;
|
|
38052
38089
|
}
|
|
38053
38090
|
async function materializeOverview(workspaceRoot, store, ctx = {}) {
|
|
@@ -45431,25 +45468,25 @@ var init_tool_index = __esm({
|
|
|
45431
45468
|
|
|
45432
45469
|
// src/outbox.ts
|
|
45433
45470
|
import {
|
|
45434
|
-
existsSync as
|
|
45471
|
+
existsSync as existsSync11,
|
|
45435
45472
|
readdirSync as readdirSync4,
|
|
45436
|
-
readFileSync as
|
|
45473
|
+
readFileSync as readFileSync9,
|
|
45437
45474
|
renameSync,
|
|
45438
45475
|
unlinkSync,
|
|
45439
|
-
writeFileSync as
|
|
45476
|
+
writeFileSync as writeFileSync9
|
|
45440
45477
|
} from "node:fs";
|
|
45441
|
-
import { join as
|
|
45478
|
+
import { join as join12 } from "node:path";
|
|
45442
45479
|
import { createHash as createHash11 } from "node:crypto";
|
|
45443
45480
|
function enqueueOutbox(paths, payload) {
|
|
45444
45481
|
ensureDir(paths.outbox);
|
|
45445
45482
|
const id = createHash11("sha256").update(JSON.stringify(payload)).digest("hex").slice(0, 16);
|
|
45446
|
-
const file2 =
|
|
45447
|
-
|
|
45483
|
+
const file2 = join12(paths.outbox, `${Date.now()}-${id}.json`);
|
|
45484
|
+
writeFileSync9(file2, JSON.stringify(payload, null, 2), "utf8");
|
|
45448
45485
|
return file2;
|
|
45449
45486
|
}
|
|
45450
45487
|
async function flushOutbox(paths, client, store) {
|
|
45451
45488
|
ensureDir(paths.outbox);
|
|
45452
|
-
const entries =
|
|
45489
|
+
const entries = existsSync11(paths.outbox) ? readdirSync4(paths.outbox) : [];
|
|
45453
45490
|
let uploaded = 0;
|
|
45454
45491
|
let failed = 0;
|
|
45455
45492
|
const quarantine = (abs, reason) => {
|
|
@@ -45460,10 +45497,10 @@ async function flushOutbox(paths, client, store) {
|
|
|
45460
45497
|
}
|
|
45461
45498
|
};
|
|
45462
45499
|
for (const f of entries.filter((e) => e.endsWith(".json")).sort()) {
|
|
45463
|
-
const abs =
|
|
45500
|
+
const abs = join12(paths.outbox, f);
|
|
45464
45501
|
let payload;
|
|
45465
45502
|
try {
|
|
45466
|
-
payload = JSON.parse(
|
|
45503
|
+
payload = JSON.parse(readFileSync9(abs, "utf8"));
|
|
45467
45504
|
} catch {
|
|
45468
45505
|
failed++;
|
|
45469
45506
|
quarantine(abs, "unparseable JSON");
|
|
@@ -45508,7 +45545,7 @@ async function flushOutbox(paths, client, store) {
|
|
|
45508
45545
|
}
|
|
45509
45546
|
}
|
|
45510
45547
|
}
|
|
45511
|
-
const remainingFiles =
|
|
45548
|
+
const remainingFiles = existsSync11(paths.outbox) ? readdirSync4(paths.outbox).filter((e) => e.endsWith(".json")) : [];
|
|
45512
45549
|
return { uploaded, failed, remaining: remainingFiles.length };
|
|
45513
45550
|
}
|
|
45514
45551
|
var init_outbox = __esm({
|
|
@@ -45528,7 +45565,6 @@ __export(webui_exports, {
|
|
|
45528
45565
|
recallForFile: () => recallForFile,
|
|
45529
45566
|
recallForTool: () => recallForTool
|
|
45530
45567
|
});
|
|
45531
|
-
import { join as join12 } from "node:path";
|
|
45532
45568
|
function fileUriToFsPath(raw2) {
|
|
45533
45569
|
let p = raw2.replace(/^file:\/\//, "").replace(/\\/g, "/");
|
|
45534
45570
|
if (/^\/[A-Za-z]:/.test(p)) p = p.slice(1);
|
|
@@ -45940,7 +45976,7 @@ function buildWebUi(deps) {
|
|
|
45940
45976
|
} catch {
|
|
45941
45977
|
return c.json({});
|
|
45942
45978
|
}
|
|
45943
|
-
const block =
|
|
45979
|
+
const block = readContextFileWithHash(deps.paths.root);
|
|
45944
45980
|
const decision = decideContextInject({
|
|
45945
45981
|
event: String(body2["hook_event_name"] ?? "UserPromptSubmit"),
|
|
45946
45982
|
source: String(body2["source"] ?? ""),
|
|
@@ -46545,12 +46581,12 @@ var init_report_render = __esm({
|
|
|
46545
46581
|
|
|
46546
46582
|
// src/cli.ts
|
|
46547
46583
|
init_src5();
|
|
46548
|
-
import { closeSync as closeSync2, existsSync as
|
|
46584
|
+
import { closeSync as closeSync2, existsSync as existsSync24, openSync as openSync2, readFileSync as readFileSync22, renameSync as renameSync3, statSync as statSync6 } from "node:fs";
|
|
46549
46585
|
import { join as join26 } from "node:path";
|
|
46550
46586
|
import { spawn as spawn3 } from "node:child_process";
|
|
46551
46587
|
|
|
46552
46588
|
// src/daemon.ts
|
|
46553
|
-
import { existsSync as
|
|
46589
|
+
import { existsSync as existsSync19, writeFileSync as writeFileSync15 } from "node:fs";
|
|
46554
46590
|
|
|
46555
46591
|
// ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
|
|
46556
46592
|
import { createServer as createServerHTTP } from "http";
|
|
@@ -47130,7 +47166,7 @@ init_config();
|
|
|
47130
47166
|
|
|
47131
47167
|
// src/engine.ts
|
|
47132
47168
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
47133
|
-
import { existsSync as
|
|
47169
|
+
import { existsSync as existsSync18, statSync as statSync5, appendFileSync as appendFileSync2, readdirSync as readdirSync8, renameSync as renameSync2, readFileSync as readFileSync17, writeFileSync as writeFileSync14 } from "node:fs";
|
|
47134
47170
|
import { join as join22, relative as relative6, sep as sep4 } from "node:path";
|
|
47135
47171
|
|
|
47136
47172
|
// ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
|
|
@@ -47862,9 +47898,9 @@ var NodeFsHandler = class {
|
|
|
47862
47898
|
if (this.fsw.closed) {
|
|
47863
47899
|
return;
|
|
47864
47900
|
}
|
|
47865
|
-
const
|
|
47901
|
+
const dirname10 = sysPath.dirname(file2);
|
|
47866
47902
|
const basename5 = sysPath.basename(file2);
|
|
47867
|
-
const parent = this.fsw._getWatchedDir(
|
|
47903
|
+
const parent = this.fsw._getWatchedDir(dirname10);
|
|
47868
47904
|
let prevStats = stats;
|
|
47869
47905
|
if (parent.has(basename5))
|
|
47870
47906
|
return;
|
|
@@ -47891,7 +47927,7 @@ var NodeFsHandler = class {
|
|
|
47891
47927
|
prevStats = newStats2;
|
|
47892
47928
|
}
|
|
47893
47929
|
} catch (error48) {
|
|
47894
|
-
this.fsw._remove(
|
|
47930
|
+
this.fsw._remove(dirname10, basename5);
|
|
47895
47931
|
}
|
|
47896
47932
|
} else if (parent.has(basename5)) {
|
|
47897
47933
|
const at = newStats.atimeMs;
|
|
@@ -48993,8 +49029,8 @@ init_src10();
|
|
|
48993
49029
|
init_review2();
|
|
48994
49030
|
|
|
48995
49031
|
// src/turn.ts
|
|
48996
|
-
import { closeSync, existsSync as
|
|
48997
|
-
import { basename as basename3, dirname as
|
|
49032
|
+
import { closeSync, existsSync as existsSync12, fstatSync, openSync, readdirSync as readdirSync5, readSync, statSync as statSync3 } from "node:fs";
|
|
49033
|
+
import { basename as basename3, dirname as dirname8, join as join15 } from "node:path";
|
|
48998
49034
|
import { homedir as homedir3 } from "node:os";
|
|
48999
49035
|
function readTail(path2, maxBytes) {
|
|
49000
49036
|
let fd;
|
|
@@ -49137,7 +49173,7 @@ function claudeProjectDir(cwd, home = homedir3()) {
|
|
|
49137
49173
|
}
|
|
49138
49174
|
function recentTranscripts(cwd, opts = {}) {
|
|
49139
49175
|
const dir = claudeProjectDir(cwd, opts.home ?? homedir3());
|
|
49140
|
-
if (!
|
|
49176
|
+
if (!existsSync12(dir)) return [];
|
|
49141
49177
|
let names;
|
|
49142
49178
|
try {
|
|
49143
49179
|
names = readdirSync5(dir);
|
|
@@ -49163,8 +49199,8 @@ function recentTranscripts(cwd, opts = {}) {
|
|
|
49163
49199
|
}
|
|
49164
49200
|
function subagentTranscripts(mainTranscriptPath, sessionId) {
|
|
49165
49201
|
if (!mainTranscriptPath || !sessionId) return [];
|
|
49166
|
-
const dir = join15(
|
|
49167
|
-
if (!
|
|
49202
|
+
const dir = join15(dirname8(mainTranscriptPath), sessionId, "subagents");
|
|
49203
|
+
if (!existsSync12(dir)) return [];
|
|
49168
49204
|
let names;
|
|
49169
49205
|
try {
|
|
49170
49206
|
names = readdirSync5(dir);
|
|
@@ -49193,7 +49229,7 @@ init_src2();
|
|
|
49193
49229
|
init_agent_signals();
|
|
49194
49230
|
init_tool_index();
|
|
49195
49231
|
init_src4();
|
|
49196
|
-
import { readFileSync as
|
|
49232
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync10 } from "node:fs";
|
|
49197
49233
|
var NEG = /n['']t|\b(?:not|never|no|none|neither|nor|unrelated|irrelevant|would|might|could|if)\b/i;
|
|
49198
49234
|
var CITE_GROUP_RE = /\(((?:[^()\n]|\([^()\n]*\)){1,200})\)/g;
|
|
49199
49235
|
var HANDLE_RE = /\[([a-z0-9][\w-]{0,40})\]|((?:pat|sol|drc|dcause|dfix|dprob|prob|claim|err)_[0-9a-f]{6,})/gi;
|
|
@@ -49481,13 +49517,13 @@ function writePrimingHandles(path2, nodes, now = Date.now()) {
|
|
|
49481
49517
|
entries.sort((a, b) => (b[1].seenAt ?? 0) - (a[1].seenAt ?? 0));
|
|
49482
49518
|
entries.length = HANDLE_MAP_MAX;
|
|
49483
49519
|
}
|
|
49484
|
-
|
|
49520
|
+
writeFileSync10(path2, JSON.stringify(Object.fromEntries(entries)));
|
|
49485
49521
|
} catch {
|
|
49486
49522
|
}
|
|
49487
49523
|
}
|
|
49488
49524
|
function readPrimingHandles(path2) {
|
|
49489
49525
|
try {
|
|
49490
|
-
return JSON.parse(
|
|
49526
|
+
return JSON.parse(readFileSync10(path2, "utf8"));
|
|
49491
49527
|
} catch {
|
|
49492
49528
|
return {};
|
|
49493
49529
|
}
|
|
@@ -49971,11 +50007,11 @@ init_outbox();
|
|
|
49971
50007
|
init_src8();
|
|
49972
50008
|
init_src();
|
|
49973
50009
|
init_src2();
|
|
49974
|
-
import { readFileSync as
|
|
50010
|
+
import { readFileSync as readFileSync11 } from "node:fs";
|
|
49975
50011
|
import { join as join16 } from "node:path";
|
|
49976
50012
|
function loadClaimIgnorePatterns(workspaceRoot) {
|
|
49977
50013
|
try {
|
|
49978
|
-
return
|
|
50014
|
+
return readFileSync11(join16(workspaceRoot, ".errataignore"), "utf8").split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0 && !l.startsWith("#")).map((l) => l.toLowerCase());
|
|
49979
50015
|
} catch {
|
|
49980
50016
|
return [];
|
|
49981
50017
|
}
|
|
@@ -50279,11 +50315,11 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
|
|
|
50279
50315
|
}
|
|
50280
50316
|
|
|
50281
50317
|
// src/git-sensor.ts
|
|
50282
|
-
import { existsSync as
|
|
50318
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12, watch as fsWatch } from "node:fs";
|
|
50283
50319
|
import { join as join17 } from "node:path";
|
|
50284
50320
|
function readFirstLine(path2) {
|
|
50285
50321
|
try {
|
|
50286
|
-
return
|
|
50322
|
+
return readFileSync12(path2, "utf8").split(/\r?\n/, 1)[0].trim();
|
|
50287
50323
|
} catch {
|
|
50288
50324
|
return null;
|
|
50289
50325
|
}
|
|
@@ -50302,13 +50338,13 @@ function readGitRefState(gitDir) {
|
|
|
50302
50338
|
return {
|
|
50303
50339
|
branch,
|
|
50304
50340
|
sha: sha2,
|
|
50305
|
-
mergeHeadExists:
|
|
50306
|
-
origHeadExists:
|
|
50341
|
+
mergeHeadExists: existsSync13(join17(gitDir, "MERGE_HEAD")),
|
|
50342
|
+
origHeadExists: existsSync13(join17(gitDir, "ORIG_HEAD"))
|
|
50307
50343
|
};
|
|
50308
50344
|
}
|
|
50309
50345
|
function shaFromPackedRefs(gitDir, ref) {
|
|
50310
50346
|
try {
|
|
50311
|
-
for (const line of
|
|
50347
|
+
for (const line of readFileSync12(join17(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
|
|
50312
50348
|
const [sha2, name2] = line.split(/\s+/);
|
|
50313
50349
|
if (name2 === ref && sha2) return sha2;
|
|
50314
50350
|
}
|
|
@@ -50342,7 +50378,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
|
|
|
50342
50378
|
const settle = () => {
|
|
50343
50379
|
if (timer) clearTimeout(timer);
|
|
50344
50380
|
timer = setTimeout(() => {
|
|
50345
|
-
if (
|
|
50381
|
+
if (existsSync13(join17(gitDir, "index.lock"))) {
|
|
50346
50382
|
settle();
|
|
50347
50383
|
return;
|
|
50348
50384
|
}
|
|
@@ -50578,21 +50614,21 @@ var TelemetryRecorder = class {
|
|
|
50578
50614
|
|
|
50579
50615
|
// src/skills.ts
|
|
50580
50616
|
import {
|
|
50581
|
-
existsSync as
|
|
50582
|
-
mkdirSync as
|
|
50583
|
-
readFileSync as
|
|
50617
|
+
existsSync as existsSync14,
|
|
50618
|
+
mkdirSync as mkdirSync6,
|
|
50619
|
+
readFileSync as readFileSync13,
|
|
50584
50620
|
readdirSync as readdirSync6,
|
|
50585
50621
|
unlinkSync as unlinkSync2,
|
|
50586
|
-
writeFileSync as
|
|
50622
|
+
writeFileSync as writeFileSync11
|
|
50587
50623
|
} from "node:fs";
|
|
50588
50624
|
import { basename as basename4, join as join18 } from "node:path";
|
|
50589
50625
|
function skillFileName(id) {
|
|
50590
50626
|
return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
|
|
50591
50627
|
}
|
|
50592
50628
|
function readSkillManifest(manifestPath) {
|
|
50593
|
-
if (!
|
|
50629
|
+
if (!existsSync14(manifestPath)) return [];
|
|
50594
50630
|
try {
|
|
50595
|
-
const parsed = JSON.parse(
|
|
50631
|
+
const parsed = JSON.parse(readFileSync13(manifestPath, "utf8"));
|
|
50596
50632
|
return (parsed.skills ?? []).map((s) => ({
|
|
50597
50633
|
title: s.title ?? "",
|
|
50598
50634
|
layer: s.layer ?? "technique",
|
|
@@ -50606,7 +50642,7 @@ function readSkillManifest(manifestPath) {
|
|
|
50606
50642
|
async function syncSkills(paths, client, seed, pins = []) {
|
|
50607
50643
|
const res = await client.getSkills(void 0, seed);
|
|
50608
50644
|
const staleDaemon = res.staleDaemon && res.latestDaemonVersion ? { latest: res.latestDaemonVersion } : void 0;
|
|
50609
|
-
|
|
50645
|
+
mkdirSync6(paths.skillsDir, { recursive: true });
|
|
50610
50646
|
if (res.skills.length === 0 && pins.length === 0) {
|
|
50611
50647
|
const existing = readdirSync6(paths.skillsDir).filter((f) => f.endsWith(".md"));
|
|
50612
50648
|
if (existing.length > 0) return { written: 0, pruned: 0, ...staleDaemon ? { staleDaemon } : {} };
|
|
@@ -50616,7 +50652,7 @@ async function syncSkills(paths, client, seed, pins = []) {
|
|
|
50616
50652
|
for (const s of res.skills) {
|
|
50617
50653
|
const fileName = skillFileName(s.id);
|
|
50618
50654
|
keep.add(fileName);
|
|
50619
|
-
|
|
50655
|
+
writeFileSync11(join18(paths.skillsDir, fileName), s.markdown, "utf8");
|
|
50620
50656
|
rows.push({
|
|
50621
50657
|
id: s.id,
|
|
50622
50658
|
title: s.title,
|
|
@@ -50629,7 +50665,7 @@ async function syncSkills(paths, client, seed, pins = []) {
|
|
|
50629
50665
|
const fileName = skillFileName(p.id);
|
|
50630
50666
|
if (keep.has(fileName)) continue;
|
|
50631
50667
|
keep.add(fileName);
|
|
50632
|
-
|
|
50668
|
+
writeFileSync11(join18(paths.skillsDir, fileName), p.markdown, "utf8");
|
|
50633
50669
|
rows.push({
|
|
50634
50670
|
id: p.id,
|
|
50635
50671
|
title: p.title,
|
|
@@ -50649,7 +50685,7 @@ async function syncSkills(paths, client, seed, pins = []) {
|
|
|
50649
50685
|
}
|
|
50650
50686
|
}
|
|
50651
50687
|
rows.sort((a, b) => a.id.localeCompare(b.id));
|
|
50652
|
-
|
|
50688
|
+
writeFileSync11(
|
|
50653
50689
|
paths.skillsManifest,
|
|
50654
50690
|
JSON.stringify({ generatedAt: Date.now(), skills: rows }, null, 2),
|
|
50655
50691
|
"utf8"
|
|
@@ -50660,14 +50696,14 @@ async function syncSkills(paths, client, seed, pins = []) {
|
|
|
50660
50696
|
// src/agent-skills.ts
|
|
50661
50697
|
import {
|
|
50662
50698
|
cpSync,
|
|
50663
|
-
existsSync as
|
|
50699
|
+
existsSync as existsSync15,
|
|
50664
50700
|
lstatSync,
|
|
50665
|
-
mkdirSync as
|
|
50666
|
-
readFileSync as
|
|
50701
|
+
mkdirSync as mkdirSync7,
|
|
50702
|
+
readFileSync as readFileSync14,
|
|
50667
50703
|
readdirSync as readdirSync7,
|
|
50668
50704
|
rmSync as rmSync2,
|
|
50669
50705
|
symlinkSync,
|
|
50670
|
-
writeFileSync as
|
|
50706
|
+
writeFileSync as writeFileSync12
|
|
50671
50707
|
} from "node:fs";
|
|
50672
50708
|
import { join as join19 } from "node:path";
|
|
50673
50709
|
var SKILL_NS = "errata-";
|
|
@@ -50700,7 +50736,7 @@ ${body2.trimEnd()}
|
|
|
50700
50736
|
`;
|
|
50701
50737
|
}
|
|
50702
50738
|
function reconcileNamespaced(dir, keep) {
|
|
50703
|
-
if (!
|
|
50739
|
+
if (!existsSync15(dir)) return 0;
|
|
50704
50740
|
let pruned = 0;
|
|
50705
50741
|
for (const name2 of readdirSync7(dir)) {
|
|
50706
50742
|
if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
|
|
@@ -50714,7 +50750,7 @@ function reconcileNamespaced(dir, keep) {
|
|
|
50714
50750
|
}
|
|
50715
50751
|
function linkOrCopy(linkPath, target) {
|
|
50716
50752
|
try {
|
|
50717
|
-
if (
|
|
50753
|
+
if (existsSync15(linkPath) || safeLstat(linkPath)) rmSync2(linkPath, { recursive: true, force: true });
|
|
50718
50754
|
} catch {
|
|
50719
50755
|
}
|
|
50720
50756
|
try {
|
|
@@ -50736,14 +50772,14 @@ function safeLstat(p) {
|
|
|
50736
50772
|
}
|
|
50737
50773
|
function emitAndProjectSkills(root, skills) {
|
|
50738
50774
|
const agentsSkillsDir = join19(root, ".agents", "skills");
|
|
50739
|
-
|
|
50775
|
+
mkdirSync7(agentsSkillsDir, { recursive: true });
|
|
50740
50776
|
const slugs = [];
|
|
50741
50777
|
const keep = /* @__PURE__ */ new Set();
|
|
50742
50778
|
let emitted = 0;
|
|
50743
50779
|
for (const s of skills) {
|
|
50744
50780
|
let body2;
|
|
50745
50781
|
try {
|
|
50746
|
-
body2 =
|
|
50782
|
+
body2 = readFileSync14(s.bodyPath, "utf8");
|
|
50747
50783
|
} catch {
|
|
50748
50784
|
continue;
|
|
50749
50785
|
}
|
|
@@ -50752,8 +50788,8 @@ function emitAndProjectSkills(root, skills) {
|
|
|
50752
50788
|
keep.add(slug2);
|
|
50753
50789
|
slugs.push(slug2);
|
|
50754
50790
|
const description = deriveDescription(s.title, s.layer, body2);
|
|
50755
|
-
|
|
50756
|
-
|
|
50791
|
+
mkdirSync7(join19(agentsSkillsDir, slug2), { recursive: true });
|
|
50792
|
+
writeFileSync12(
|
|
50757
50793
|
join19(agentsSkillsDir, slug2, "SKILL.md"),
|
|
50758
50794
|
renderSkillMd(slug2, description, body2),
|
|
50759
50795
|
"utf8"
|
|
@@ -50763,9 +50799,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
50763
50799
|
reconcileNamespaced(agentsSkillsDir, keep);
|
|
50764
50800
|
let projected = 0;
|
|
50765
50801
|
for (const h of HARNESS_SKILL_DIRS) {
|
|
50766
|
-
if (!
|
|
50802
|
+
if (!existsSync15(join19(root, h.configDir))) continue;
|
|
50767
50803
|
const dir = join19(root, h.skillsDir);
|
|
50768
|
-
|
|
50804
|
+
mkdirSync7(dir, { recursive: true });
|
|
50769
50805
|
for (const slug2 of slugs) {
|
|
50770
50806
|
linkOrCopy(join19(dir, slug2), join19(agentsSkillsDir, slug2));
|
|
50771
50807
|
projected++;
|
|
@@ -50776,9 +50812,9 @@ function emitAndProjectSkills(root, skills) {
|
|
|
50776
50812
|
return { slugs, emitted, projected };
|
|
50777
50813
|
}
|
|
50778
50814
|
function emitInputsFromManifest(erretaDir, manifestPath) {
|
|
50779
|
-
if (!
|
|
50815
|
+
if (!existsSync15(manifestPath)) return [];
|
|
50780
50816
|
try {
|
|
50781
|
-
const parsed = JSON.parse(
|
|
50817
|
+
const parsed = JSON.parse(readFileSync14(manifestPath, "utf8"));
|
|
50782
50818
|
return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
|
|
50783
50819
|
id: s.id,
|
|
50784
50820
|
title: s.title ?? s.id,
|
|
@@ -50801,14 +50837,14 @@ function ensureSkillGitignore(root) {
|
|
|
50801
50837
|
const path2 = join19(root, ".gitignore");
|
|
50802
50838
|
let current = "";
|
|
50803
50839
|
try {
|
|
50804
|
-
current =
|
|
50840
|
+
current = existsSync15(path2) ? readFileSync14(path2, "utf8") : "";
|
|
50805
50841
|
} catch {
|
|
50806
50842
|
return;
|
|
50807
50843
|
}
|
|
50808
50844
|
if (current.includes(GITIGNORE_MARK)) return;
|
|
50809
50845
|
const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
|
|
50810
50846
|
try {
|
|
50811
|
-
|
|
50847
|
+
writeFileSync12(path2, `${current}${prefix}
|
|
50812
50848
|
${GITIGNORE_LINES.join("\n")}
|
|
50813
50849
|
`, "utf8");
|
|
50814
50850
|
} catch {
|
|
@@ -50944,20 +50980,20 @@ var CausalBuffer = class {
|
|
|
50944
50980
|
// src/profile.ts
|
|
50945
50981
|
init_src2();
|
|
50946
50982
|
init_paths();
|
|
50947
|
-
import { existsSync as
|
|
50983
|
+
import { existsSync as existsSync17, readFileSync as readFileSync16, writeFileSync as writeFileSync13 } from "node:fs";
|
|
50948
50984
|
import { createHash as createHash12 } from "node:crypto";
|
|
50949
50985
|
import { join as join21 } from "node:path";
|
|
50950
50986
|
|
|
50951
50987
|
// src/git-remote.ts
|
|
50952
50988
|
init_src();
|
|
50953
|
-
import { existsSync as
|
|
50989
|
+
import { existsSync as existsSync16, readFileSync as readFileSync15, statSync as statSync4 } from "node:fs";
|
|
50954
50990
|
import { isAbsolute as isAbsolute3, join as join20, resolve as resolve5 } from "node:path";
|
|
50955
50991
|
function resolveGitDir(root) {
|
|
50956
50992
|
const dotGit = join20(root, ".git");
|
|
50957
50993
|
try {
|
|
50958
50994
|
const st = statSync4(dotGit);
|
|
50959
50995
|
if (st.isDirectory()) return dotGit;
|
|
50960
|
-
const m = /^gitdir:\s*(.+?)\s*$/m.exec(
|
|
50996
|
+
const m = /^gitdir:\s*(.+?)\s*$/m.exec(readFileSync15(dotGit, "utf8"));
|
|
50961
50997
|
if (!m) return null;
|
|
50962
50998
|
const dir = m[1];
|
|
50963
50999
|
return isAbsolute3(dir) ? dir : resolve5(root, dir);
|
|
@@ -50967,8 +51003,8 @@ function resolveGitDir(root) {
|
|
|
50967
51003
|
}
|
|
50968
51004
|
function gitConfigPath(gitDir) {
|
|
50969
51005
|
const commondirFile = join20(gitDir, "commondir");
|
|
50970
|
-
if (
|
|
50971
|
-
const common =
|
|
51006
|
+
if (existsSync16(commondirFile)) {
|
|
51007
|
+
const common = readFileSync15(commondirFile, "utf8").trim();
|
|
50972
51008
|
const commonDir = isAbsolute3(common) ? common : resolve5(gitDir, common);
|
|
50973
51009
|
return join20(commonDir, "config");
|
|
50974
51010
|
}
|
|
@@ -50978,10 +51014,10 @@ function readRemotes(root) {
|
|
|
50978
51014
|
const gitDir = resolveGitDir(root);
|
|
50979
51015
|
if (!gitDir) return [];
|
|
50980
51016
|
const cfgPath = gitConfigPath(gitDir);
|
|
50981
|
-
if (!
|
|
51017
|
+
if (!existsSync16(cfgPath)) return [];
|
|
50982
51018
|
let txt;
|
|
50983
51019
|
try {
|
|
50984
|
-
txt =
|
|
51020
|
+
txt = readFileSync15(cfgPath, "utf8");
|
|
50985
51021
|
} catch {
|
|
50986
51022
|
return [];
|
|
50987
51023
|
}
|
|
@@ -51013,13 +51049,13 @@ function refreshRepoLocator(root, profile) {
|
|
|
51013
51049
|
}
|
|
51014
51050
|
function loadProfile(root) {
|
|
51015
51051
|
const p = workspacePaths(root);
|
|
51016
|
-
if (!
|
|
51017
|
-
return JSON.parse(
|
|
51052
|
+
if (!existsSync17(p.workspaceJson)) return null;
|
|
51053
|
+
return JSON.parse(readFileSync16(p.workspaceJson, "utf8"));
|
|
51018
51054
|
}
|
|
51019
51055
|
function saveProfile(root, profile) {
|
|
51020
51056
|
const p = workspacePaths(root);
|
|
51021
51057
|
ensureDir(p.configDir);
|
|
51022
|
-
|
|
51058
|
+
writeFileSync13(p.workspaceJson, JSON.stringify(profile, null, 2), "utf8");
|
|
51023
51059
|
}
|
|
51024
51060
|
function autodetectProfile(root) {
|
|
51025
51061
|
const id = workspaceId(root);
|
|
@@ -51028,9 +51064,9 @@ function autodetectProfile(root) {
|
|
|
51028
51064
|
const locator = detectRepoLocator(root);
|
|
51029
51065
|
if (locator) p.repoLocator = locator;
|
|
51030
51066
|
const pkgPath = join21(root, "package.json");
|
|
51031
|
-
if (
|
|
51067
|
+
if (existsSync17(pkgPath)) {
|
|
51032
51068
|
try {
|
|
51033
|
-
const pkg = JSON.parse(
|
|
51069
|
+
const pkg = JSON.parse(readFileSync16(pkgPath, "utf8"));
|
|
51034
51070
|
p.languages.push("typescript", "javascript");
|
|
51035
51071
|
const nodeVer = pkg.engines?.node ?? "node";
|
|
51036
51072
|
p.stack.push(`node@${nodeVer}`);
|
|
@@ -51052,9 +51088,9 @@ function autodetectProfile(root) {
|
|
|
51052
51088
|
}
|
|
51053
51089
|
}
|
|
51054
51090
|
const pyproject = join21(root, "pyproject.toml");
|
|
51055
|
-
if (
|
|
51091
|
+
if (existsSync17(pyproject)) {
|
|
51056
51092
|
try {
|
|
51057
|
-
const txt =
|
|
51093
|
+
const txt = readFileSync16(pyproject, "utf8");
|
|
51058
51094
|
const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
|
|
51059
51095
|
p.languages.push("python");
|
|
51060
51096
|
p.stack.push(`python@${py ?? "3"}`);
|
|
@@ -51066,15 +51102,15 @@ function autodetectProfile(root) {
|
|
|
51066
51102
|
}
|
|
51067
51103
|
}
|
|
51068
51104
|
const reqs = join21(root, "requirements.txt");
|
|
51069
|
-
if (
|
|
51105
|
+
if (existsSync17(reqs)) {
|
|
51070
51106
|
if (!p.languages.includes("python")) p.languages.push("python");
|
|
51071
51107
|
if (!p.stack.includes("python@3")) p.stack.push("python@3");
|
|
51072
51108
|
}
|
|
51073
|
-
if (
|
|
51109
|
+
if (existsSync17(join21(root, "go.mod"))) {
|
|
51074
51110
|
p.languages.push("go");
|
|
51075
51111
|
p.stack.push("go");
|
|
51076
51112
|
}
|
|
51077
|
-
if (
|
|
51113
|
+
if (existsSync17(join21(root, "Cargo.toml"))) {
|
|
51078
51114
|
p.languages.push("rust");
|
|
51079
51115
|
p.stack.push("rust");
|
|
51080
51116
|
}
|
|
@@ -51232,7 +51268,7 @@ function startLoopLagMonitor(thresholdMs = 1e3) {
|
|
|
51232
51268
|
}
|
|
51233
51269
|
|
|
51234
51270
|
// src/engine.ts
|
|
51235
|
-
var DAEMON_VERSION = true ? "2.0.0-dev.
|
|
51271
|
+
var DAEMON_VERSION = true ? "2.0.0-dev.90" : "2.0.0-alpha.0";
|
|
51236
51272
|
var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
|
|
51237
51273
|
var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
|
|
51238
51274
|
var GIT_OP_MUTE_MS = 4e3;
|
|
@@ -51242,7 +51278,7 @@ var TURN_REPLAY_LOOKBACK_MS = 7 * 24 * 60 * 6e4;
|
|
|
51242
51278
|
function appendIdentityAudit(path2, record2, line) {
|
|
51243
51279
|
if (!record2.accepted && record2.score <= 0) return;
|
|
51244
51280
|
try {
|
|
51245
|
-
if (
|
|
51281
|
+
if (existsSync18(path2) && statSync5(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
|
|
51246
51282
|
renameSync2(path2, `${path2}.1`);
|
|
51247
51283
|
}
|
|
51248
51284
|
appendFileSync2(path2, line);
|
|
@@ -51252,14 +51288,14 @@ function appendIdentityAudit(path2, record2, line) {
|
|
|
51252
51288
|
var yieldToLoop = () => new Promise((r) => setImmediate(r));
|
|
51253
51289
|
function loadTurnCursors(path2) {
|
|
51254
51290
|
try {
|
|
51255
|
-
return new Map(Object.entries(JSON.parse(
|
|
51291
|
+
return new Map(Object.entries(JSON.parse(readFileSync17(path2, "utf8"))));
|
|
51256
51292
|
} catch {
|
|
51257
51293
|
return /* @__PURE__ */ new Map();
|
|
51258
51294
|
}
|
|
51259
51295
|
}
|
|
51260
51296
|
function saveTurnCursors(path2, cursors) {
|
|
51261
51297
|
try {
|
|
51262
|
-
|
|
51298
|
+
writeFileSync14(path2, JSON.stringify(Object.fromEntries(cursors)), "utf8");
|
|
51263
51299
|
} catch {
|
|
51264
51300
|
}
|
|
51265
51301
|
}
|
|
@@ -51496,7 +51532,7 @@ function createWorkspaceEngine(opts) {
|
|
|
51496
51532
|
);
|
|
51497
51533
|
};
|
|
51498
51534
|
const gitDir = join22(opts.workspaceRoot, ".git");
|
|
51499
|
-
if (
|
|
51535
|
+
if (existsSync18(gitDir)) {
|
|
51500
51536
|
stopGit = startGitSensor(gitDir, (ev) => {
|
|
51501
51537
|
void handleGitEvent(ev).catch((err2) => {
|
|
51502
51538
|
console.warn("[errata] git event handler failed:", err2);
|
|
@@ -51564,8 +51600,9 @@ function createWorkspaceEngine(opts) {
|
|
|
51564
51600
|
...pendingUpdate ? { pendingUpdate } : {}
|
|
51565
51601
|
});
|
|
51566
51602
|
doneRender?.();
|
|
51603
|
+
writeContextFile(opts.workspaceRoot, body2);
|
|
51567
51604
|
const target = join22(opts.workspaceRoot, "AGENTS.md");
|
|
51568
|
-
writeManagedBlock(target, { body:
|
|
51605
|
+
writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
|
|
51569
51606
|
if (elicit) {
|
|
51570
51607
|
writePrimingHandles(join22(paths.configDir, "priming-handles.json"), [
|
|
51571
51608
|
...snapshot.recentProblems.map((r) => r.node),
|
|
@@ -52459,7 +52496,7 @@ function createWorkspaceEngine(opts) {
|
|
|
52459
52496
|
console.log(
|
|
52460
52497
|
"[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
|
|
52461
52498
|
);
|
|
52462
|
-
const pending =
|
|
52499
|
+
const pending = existsSync18(paths.outbox) ? readdirSync8(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
|
|
52463
52500
|
return { uploaded: 0, failed: 0, remaining: pending };
|
|
52464
52501
|
}
|
|
52465
52502
|
try {
|
|
@@ -52546,7 +52583,7 @@ async function startDaemon(opts) {
|
|
|
52546
52583
|
reviewUrl: () => webUiUrl + "/review"
|
|
52547
52584
|
});
|
|
52548
52585
|
const writeLockFile = (url2) => {
|
|
52549
|
-
|
|
52586
|
+
writeFileSync15(
|
|
52550
52587
|
engine.paths.daemonLock,
|
|
52551
52588
|
JSON.stringify({ pid: process.pid, webUiUrl: url2, startedAt: Date.now() }),
|
|
52552
52589
|
"utf8"
|
|
@@ -52589,7 +52626,7 @@ async function startDaemon(opts) {
|
|
|
52589
52626
|
);
|
|
52590
52627
|
await engine.stop();
|
|
52591
52628
|
try {
|
|
52592
|
-
if (
|
|
52629
|
+
if (existsSync19(engine.paths.daemonLock)) {
|
|
52593
52630
|
}
|
|
52594
52631
|
} catch {
|
|
52595
52632
|
}
|
|
@@ -52606,16 +52643,16 @@ async function listenServer(fetchFn, port) {
|
|
|
52606
52643
|
|
|
52607
52644
|
// src/registry.ts
|
|
52608
52645
|
init_paths();
|
|
52609
|
-
import { existsSync as
|
|
52646
|
+
import { existsSync as existsSync20, readFileSync as readFileSync18, writeFileSync as writeFileSync16 } from "node:fs";
|
|
52610
52647
|
import { join as join23 } from "node:path";
|
|
52611
52648
|
function registryPath() {
|
|
52612
52649
|
return process.env["ERRATA_REGISTRY_PATH"] ?? join23(globalDir(), "workspaces.json");
|
|
52613
52650
|
}
|
|
52614
52651
|
function read() {
|
|
52615
52652
|
const p = registryPath();
|
|
52616
|
-
if (!
|
|
52653
|
+
if (!existsSync20(p)) return { version: 1, workspaces: {} };
|
|
52617
52654
|
try {
|
|
52618
|
-
const parsed = JSON.parse(
|
|
52655
|
+
const parsed = JSON.parse(readFileSync18(p, "utf8"));
|
|
52619
52656
|
return { version: 1, workspaces: parsed.workspaces ?? {} };
|
|
52620
52657
|
} catch {
|
|
52621
52658
|
return { version: 1, workspaces: {} };
|
|
@@ -52623,7 +52660,7 @@ function read() {
|
|
|
52623
52660
|
}
|
|
52624
52661
|
function write(reg) {
|
|
52625
52662
|
ensureDir(globalDir());
|
|
52626
|
-
|
|
52663
|
+
writeFileSync16(registryPath(), JSON.stringify(reg, null, 2), "utf8");
|
|
52627
52664
|
}
|
|
52628
52665
|
function registerWorkspace(profile, root, now = Date.now()) {
|
|
52629
52666
|
const reg = read();
|
|
@@ -52640,7 +52677,7 @@ function pruneMissingWorkspaces() {
|
|
|
52640
52677
|
const reg = read();
|
|
52641
52678
|
const removed = [];
|
|
52642
52679
|
for (const [id, entry] of Object.entries(reg.workspaces)) {
|
|
52643
|
-
if (!
|
|
52680
|
+
if (!existsSync20(entry.path)) {
|
|
52644
52681
|
removed.push(entry);
|
|
52645
52682
|
delete reg.workspaces[id];
|
|
52646
52683
|
}
|
|
@@ -52649,13 +52686,13 @@ function pruneMissingWorkspaces() {
|
|
|
52649
52686
|
return removed;
|
|
52650
52687
|
}
|
|
52651
52688
|
function workspaceStatus(entry) {
|
|
52652
|
-
const missing = !
|
|
52689
|
+
const missing = !existsSync20(entry.path);
|
|
52653
52690
|
const lockPath = workspacePaths(entry.path).daemonLock;
|
|
52654
52691
|
let running = false;
|
|
52655
52692
|
let webUiUrl = null;
|
|
52656
|
-
if (
|
|
52693
|
+
if (existsSync20(lockPath)) {
|
|
52657
52694
|
try {
|
|
52658
|
-
const lock = JSON.parse(
|
|
52695
|
+
const lock = JSON.parse(readFileSync18(lockPath, "utf8"));
|
|
52659
52696
|
if (lock.pid && lock.webUiUrl && pidAlive(lock.pid)) {
|
|
52660
52697
|
running = true;
|
|
52661
52698
|
webUiUrl = lock.webUiUrl;
|
|
@@ -52683,7 +52720,7 @@ function pidAlive(pid) {
|
|
|
52683
52720
|
// src/multi.ts
|
|
52684
52721
|
init_dist();
|
|
52685
52722
|
init_src4();
|
|
52686
|
-
import { readFileSync as
|
|
52723
|
+
import { readFileSync as readFileSync21, unlinkSync as unlinkSync3, writeFileSync as writeFileSync17 } from "node:fs";
|
|
52687
52724
|
|
|
52688
52725
|
// src/principle-sync.ts
|
|
52689
52726
|
init_src4();
|
|
@@ -52711,7 +52748,7 @@ init_reconcile();
|
|
|
52711
52748
|
|
|
52712
52749
|
// src/lockfile-auto.ts
|
|
52713
52750
|
init_src();
|
|
52714
|
-
import { existsSync as
|
|
52751
|
+
import { existsSync as existsSync21, readFileSync as readFileSync19 } from "node:fs";
|
|
52715
52752
|
import { join as join24 } from "node:path";
|
|
52716
52753
|
|
|
52717
52754
|
// src/package-index.ts
|
|
@@ -52847,10 +52884,10 @@ function runLockfilePass(opts) {
|
|
|
52847
52884
|
];
|
|
52848
52885
|
for (const c of candidates) {
|
|
52849
52886
|
const p = join24(opts.root, c.file);
|
|
52850
|
-
if (!
|
|
52887
|
+
if (!existsSync21(p)) continue;
|
|
52851
52888
|
let sbom;
|
|
52852
52889
|
try {
|
|
52853
|
-
sbom = c.parse(
|
|
52890
|
+
sbom = c.parse(readFileSync19(p, "utf8"));
|
|
52854
52891
|
} catch {
|
|
52855
52892
|
continue;
|
|
52856
52893
|
}
|
|
@@ -53171,7 +53208,7 @@ var ConsolidateWorker = class {
|
|
|
53171
53208
|
init_paths();
|
|
53172
53209
|
|
|
53173
53210
|
// src/lock.ts
|
|
53174
|
-
import { existsSync as
|
|
53211
|
+
import { existsSync as existsSync22, readFileSync as readFileSync20 } from "node:fs";
|
|
53175
53212
|
function isProcessAlive(pid) {
|
|
53176
53213
|
if (!pid || pid <= 0) return false;
|
|
53177
53214
|
try {
|
|
@@ -53182,9 +53219,9 @@ function isProcessAlive(pid) {
|
|
|
53182
53219
|
}
|
|
53183
53220
|
}
|
|
53184
53221
|
function readDaemonLock(lockPath) {
|
|
53185
|
-
if (!
|
|
53222
|
+
if (!existsSync22(lockPath)) return null;
|
|
53186
53223
|
try {
|
|
53187
|
-
const lock = JSON.parse(
|
|
53224
|
+
const lock = JSON.parse(readFileSync20(lockPath, "utf8"));
|
|
53188
53225
|
return typeof lock.pid === "number" ? lock : null;
|
|
53189
53226
|
} catch {
|
|
53190
53227
|
return null;
|
|
@@ -53426,13 +53463,13 @@ async function reanchorProject(opts) {
|
|
|
53426
53463
|
}
|
|
53427
53464
|
|
|
53428
53465
|
// src/adopt.ts
|
|
53429
|
-
import { existsSync as
|
|
53430
|
-
import { dirname as
|
|
53466
|
+
import { existsSync as existsSync23 } from "node:fs";
|
|
53467
|
+
import { dirname as dirname9, join as join25 } from "node:path";
|
|
53431
53468
|
function findGitRoot(absPath) {
|
|
53432
53469
|
let dir = absPath;
|
|
53433
53470
|
for (let depth = 0; depth < 64; depth++) {
|
|
53434
|
-
if (
|
|
53435
|
-
const parent =
|
|
53471
|
+
if (existsSync23(join25(dir, ".git"))) return dir;
|
|
53472
|
+
const parent = dirname9(dir);
|
|
53436
53473
|
if (parent === dir) return null;
|
|
53437
53474
|
dir = parent;
|
|
53438
53475
|
}
|
|
@@ -53627,7 +53664,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
53627
53664
|
void ambientLinkAll();
|
|
53628
53665
|
app.route(`/ws/${rec.id}`, rec.webApp);
|
|
53629
53666
|
try {
|
|
53630
|
-
|
|
53667
|
+
writeFileSync17(
|
|
53631
53668
|
rec.engine.paths.daemonLock,
|
|
53632
53669
|
JSON.stringify({ pid: process.pid, webUiUrl: `${baseUrl}/ws/${rec.id}`, startedAt: Date.now() }),
|
|
53633
53670
|
"utf8"
|
|
@@ -53813,7 +53850,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
53813
53850
|
baseUrl = `http://127.0.0.1:${port}`;
|
|
53814
53851
|
try {
|
|
53815
53852
|
ensureDir(globalDir());
|
|
53816
|
-
|
|
53853
|
+
writeFileSync17(
|
|
53817
53854
|
lockPath,
|
|
53818
53855
|
JSON.stringify({ pid: process.pid, webUiUrl: baseUrl, startedAt: Date.now() }),
|
|
53819
53856
|
"utf8"
|
|
@@ -53822,7 +53859,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
53822
53859
|
}
|
|
53823
53860
|
for (const r of records) {
|
|
53824
53861
|
try {
|
|
53825
|
-
|
|
53862
|
+
writeFileSync17(
|
|
53826
53863
|
r.engine.paths.daemonLock,
|
|
53827
53864
|
JSON.stringify({ pid: process.pid, webUiUrl: `${baseUrl}/ws/${r.id}`, startedAt: Date.now() }),
|
|
53828
53865
|
"utf8"
|
|
@@ -54221,7 +54258,7 @@ async function startMultiDaemon(opts = {}) {
|
|
|
54221
54258
|
},
|
|
54222
54259
|
async stop() {
|
|
54223
54260
|
try {
|
|
54224
|
-
const cur =
|
|
54261
|
+
const cur = readFileSync21(lockPath, "utf8");
|
|
54225
54262
|
if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
|
|
54226
54263
|
} catch {
|
|
54227
54264
|
}
|
|
@@ -54816,21 +54853,21 @@ async function cmdInit() {
|
|
|
54816
54853
|
if (!skipHooks) {
|
|
54817
54854
|
console.log("");
|
|
54818
54855
|
console.log("installing harness hooks...");
|
|
54819
|
-
const { existsSync:
|
|
54856
|
+
const { existsSync: existsSync25 } = await import("node:fs");
|
|
54820
54857
|
const { join: join27 } = await import("node:path");
|
|
54821
54858
|
try {
|
|
54822
54859
|
await installClaudeHooks(port);
|
|
54823
54860
|
} catch (err2) {
|
|
54824
54861
|
console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
54825
54862
|
}
|
|
54826
|
-
if (
|
|
54863
|
+
if (existsSync25(join27(ROOT, ".cursor"))) {
|
|
54827
54864
|
try {
|
|
54828
54865
|
await installCursorMcpConfig();
|
|
54829
54866
|
} catch (err2) {
|
|
54830
54867
|
console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
|
|
54831
54868
|
}
|
|
54832
54869
|
}
|
|
54833
|
-
if (
|
|
54870
|
+
if (existsSync25(join27(ROOT, ".codex"))) {
|
|
54834
54871
|
try {
|
|
54835
54872
|
await installCodexHooks(port);
|
|
54836
54873
|
} catch (err2) {
|
|
@@ -54987,8 +55024,8 @@ async function cmdStatus() {
|
|
|
54987
55024
|
console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
|
|
54988
55025
|
console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
|
|
54989
55026
|
}
|
|
54990
|
-
console.log(` graph db: ${
|
|
54991
|
-
console.log(` event log: ${
|
|
55027
|
+
console.log(` graph db: ${existsSync24(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
|
|
55028
|
+
console.log(` event log: ${existsSync24(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
|
|
54992
55029
|
const lockPath = globalDaemonLock();
|
|
54993
55030
|
const running = isDaemonAlive(lockPath) ? readDaemonLock(lockPath) : null;
|
|
54994
55031
|
console.log(
|
|
@@ -55440,11 +55477,11 @@ async function cmdUse(args2) {
|
|
|
55440
55477
|
}
|
|
55441
55478
|
async function cmdReview() {
|
|
55442
55479
|
const paths = workspacePaths(ROOT);
|
|
55443
|
-
if (!
|
|
55480
|
+
if (!existsSync24(paths.reviewQueue)) {
|
|
55444
55481
|
console.log("(review queue empty)");
|
|
55445
55482
|
return;
|
|
55446
55483
|
}
|
|
55447
|
-
const queue = JSON.parse(
|
|
55484
|
+
const queue = JSON.parse(readFileSync22(paths.reviewQueue, "utf8"));
|
|
55448
55485
|
if (queue.length === 0) {
|
|
55449
55486
|
console.log("(review queue empty)");
|
|
55450
55487
|
return;
|
|
@@ -56098,7 +56135,7 @@ async function gatherRepo(store, ws) {
|
|
|
56098
56135
|
};
|
|
56099
56136
|
}
|
|
56100
56137
|
async function gatherReportData(generatedAt) {
|
|
56101
|
-
const { existsSync:
|
|
56138
|
+
const { existsSync: existsSync25 } = await import("node:fs");
|
|
56102
56139
|
const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src4(), src_exports2));
|
|
56103
56140
|
const cfg = loadConfig();
|
|
56104
56141
|
const outbound = cfg.consent.sync ? "auto" : "off";
|
|
@@ -56106,7 +56143,7 @@ async function gatherReportData(generatedAt) {
|
|
|
56106
56143
|
for (const ws of listWorkspaces()) {
|
|
56107
56144
|
if (ws.missing) continue;
|
|
56108
56145
|
const dbPath = workspacePaths(ws.path).castalia;
|
|
56109
|
-
if (!
|
|
56146
|
+
if (!existsSync25(dbPath)) continue;
|
|
56110
56147
|
let store = null;
|
|
56111
56148
|
try {
|
|
56112
56149
|
store = openGraphStore2({ path: dbPath });
|
|
@@ -56137,7 +56174,7 @@ async function gatherReportData(generatedAt) {
|
|
|
56137
56174
|
};
|
|
56138
56175
|
}
|
|
56139
56176
|
async function cmdReport(args2) {
|
|
56140
|
-
const { mkdirSync:
|
|
56177
|
+
const { mkdirSync: mkdirSync8, writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
56141
56178
|
const { renderReport: renderReport2 } = await Promise.resolve().then(() => (init_report_render(), report_render_exports));
|
|
56142
56179
|
const includeFutureVerbs = args2.includes("--future-verbs");
|
|
56143
56180
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -56148,9 +56185,9 @@ async function cmdReport(args2) {
|
|
|
56148
56185
|
process.exit(2);
|
|
56149
56186
|
}
|
|
56150
56187
|
const outDir = workspacePaths(ROOT).configDir;
|
|
56151
|
-
|
|
56188
|
+
mkdirSync8(outDir, { recursive: true });
|
|
56152
56189
|
const files = renderReport2(data, { includeFutureVerbs });
|
|
56153
|
-
for (const f of files)
|
|
56190
|
+
for (const f of files) writeFileSync18(join26(outDir, f.name), f.html, "utf8");
|
|
56154
56191
|
const indexPath = join26(outDir, "report.html");
|
|
56155
56192
|
console.log(`report \u2192 ${indexPath}`);
|
|
56156
56193
|
console.log(` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`);
|
|
@@ -56271,15 +56308,15 @@ function hookRelayCommand(port, path2) {
|
|
|
56271
56308
|
return process.platform === "win32" ? `cmd //c "curl -s --connect-timeout 1 --max-time 2 -X POST -H \\"Content-Type: application/json\\" --data-binary @- ${url2} 2>NUL || echo {}"` : `curl -s --connect-timeout 1 --max-time 2 -X POST -H 'Content-Type: application/json' --data-binary @- ${url2} 2>/dev/null || echo '{}'`;
|
|
56272
56309
|
}
|
|
56273
56310
|
async function installClaudeHooks(port) {
|
|
56274
|
-
const { mkdirSync:
|
|
56311
|
+
const { mkdirSync: mkdirSync8, existsSync: existsSync25, readFileSync: readFileSync23, writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
56275
56312
|
const { join: join27 } = await import("node:path");
|
|
56276
56313
|
const dir = join27(ROOT, ".claude");
|
|
56277
|
-
if (!
|
|
56314
|
+
if (!existsSync25(dir)) mkdirSync8(dir, { recursive: true });
|
|
56278
56315
|
const file2 = join27(dir, "settings.json");
|
|
56279
56316
|
let settings = {};
|
|
56280
|
-
if (
|
|
56317
|
+
if (existsSync25(file2)) {
|
|
56281
56318
|
try {
|
|
56282
|
-
settings = JSON.parse(
|
|
56319
|
+
settings = JSON.parse(readFileSync23(file2, "utf8"));
|
|
56283
56320
|
} catch {
|
|
56284
56321
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
56285
56322
|
process.exit(2);
|
|
@@ -56325,7 +56362,7 @@ async function installClaudeHooks(port) {
|
|
|
56325
56362
|
dropErrata(list);
|
|
56326
56363
|
list.push({ hooks: [{ type: "command", command: injectCmd }] });
|
|
56327
56364
|
}
|
|
56328
|
-
|
|
56365
|
+
writeFileSync18(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
56329
56366
|
console.log(`installed Claude Code hooks \u2192 ${file2}`);
|
|
56330
56367
|
await installClaudeMcpConfig();
|
|
56331
56368
|
const claudeMd = join27(ROOT, "CLAUDE.md");
|
|
@@ -56340,15 +56377,15 @@ async function installClaudeHooks(port) {
|
|
|
56340
56377
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
56341
56378
|
}
|
|
56342
56379
|
async function installClaudeMcpConfig() {
|
|
56343
|
-
const { mkdirSync:
|
|
56344
|
-
const { join: join27, dirname:
|
|
56380
|
+
const { mkdirSync: mkdirSync8, existsSync: existsSync25, readFileSync: readFileSync23, writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
56381
|
+
const { join: join27, dirname: dirname10 } = await import("node:path");
|
|
56345
56382
|
const file2 = join27(ROOT, ".mcp.json");
|
|
56346
|
-
const dir =
|
|
56347
|
-
if (!
|
|
56383
|
+
const dir = dirname10(file2);
|
|
56384
|
+
if (!existsSync25(dir)) mkdirSync8(dir, { recursive: true });
|
|
56348
56385
|
let cfg = {};
|
|
56349
|
-
if (
|
|
56386
|
+
if (existsSync25(file2)) {
|
|
56350
56387
|
try {
|
|
56351
|
-
cfg = JSON.parse(
|
|
56388
|
+
cfg = JSON.parse(readFileSync23(file2, "utf8"));
|
|
56352
56389
|
} catch {
|
|
56353
56390
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
56354
56391
|
process.exit(2);
|
|
@@ -56356,21 +56393,21 @@ async function installClaudeMcpConfig() {
|
|
|
56356
56393
|
}
|
|
56357
56394
|
cfg.mcpServers ??= {};
|
|
56358
56395
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
56359
|
-
|
|
56396
|
+
writeFileSync18(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
56360
56397
|
console.log(`installed Claude Code MCP server config \u2192 ${file2}`);
|
|
56361
56398
|
console.log(` Claude Code will spawn \`errata mcp\` on workspace open.`);
|
|
56362
56399
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
|
|
56363
56400
|
}
|
|
56364
56401
|
async function installCursorMcpConfig() {
|
|
56365
|
-
const { mkdirSync:
|
|
56402
|
+
const { mkdirSync: mkdirSync8, existsSync: existsSync25, readFileSync: readFileSync23, writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
56366
56403
|
const { join: join27 } = await import("node:path");
|
|
56367
56404
|
const dir = join27(ROOT, ".cursor");
|
|
56368
|
-
if (!
|
|
56405
|
+
if (!existsSync25(dir)) mkdirSync8(dir, { recursive: true });
|
|
56369
56406
|
const file2 = join27(dir, "mcp.json");
|
|
56370
56407
|
let cfg = {};
|
|
56371
|
-
if (
|
|
56408
|
+
if (existsSync25(file2)) {
|
|
56372
56409
|
try {
|
|
56373
|
-
cfg = JSON.parse(
|
|
56410
|
+
cfg = JSON.parse(readFileSync23(file2, "utf8"));
|
|
56374
56411
|
} catch {
|
|
56375
56412
|
console.error(`refusing to overwrite invalid JSON at ${file2}`);
|
|
56376
56413
|
process.exit(2);
|
|
@@ -56378,7 +56415,7 @@ async function installCursorMcpConfig() {
|
|
|
56378
56415
|
}
|
|
56379
56416
|
cfg.mcpServers ??= {};
|
|
56380
56417
|
cfg.mcpServers["errata"] = errataMcpInvocation();
|
|
56381
|
-
|
|
56418
|
+
writeFileSync18(file2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
56382
56419
|
console.log(`installed Cursor MCP server config \u2192 ${file2}`);
|
|
56383
56420
|
console.log(` Cursor will spawn \`errata mcp\` on workspace open.`);
|
|
56384
56421
|
console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses`);
|
|
@@ -56386,16 +56423,16 @@ async function installCursorMcpConfig() {
|
|
|
56386
56423
|
console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
|
|
56387
56424
|
}
|
|
56388
56425
|
async function installCodexHooks(port) {
|
|
56389
|
-
const { mkdirSync:
|
|
56426
|
+
const { mkdirSync: mkdirSync8, existsSync: existsSync25, readFileSync: readFileSync23, writeFileSync: writeFileSync18 } = await import("node:fs");
|
|
56390
56427
|
const { join: join27 } = await import("node:path");
|
|
56391
56428
|
const dir = join27(ROOT, ".codex");
|
|
56392
|
-
if (!
|
|
56429
|
+
if (!existsSync25(dir)) mkdirSync8(dir, { recursive: true });
|
|
56393
56430
|
const file2 = join27(dir, "config.toml");
|
|
56394
56431
|
const BEGIN = `# >>> errata hooks (errata-managed)`;
|
|
56395
56432
|
const END = `# <<< errata hooks`;
|
|
56396
56433
|
let existing = "";
|
|
56397
|
-
if (
|
|
56398
|
-
existing =
|
|
56434
|
+
if (existsSync25(file2)) {
|
|
56435
|
+
existing = readFileSync23(file2, "utf8");
|
|
56399
56436
|
const beginIdx = existing.indexOf(BEGIN);
|
|
56400
56437
|
const endIdx = existing.indexOf(END);
|
|
56401
56438
|
if (beginIdx >= 0 && endIdx > beginIdx) {
|
|
@@ -56424,7 +56461,7 @@ ${END}
|
|
|
56424
56461
|
const final = existing.length > 0 && !existing.endsWith("\n") ? `${existing}
|
|
56425
56462
|
|
|
56426
56463
|
${block}` : existing + (existing.endsWith("\n\n") ? "" : "\n") + block;
|
|
56427
|
-
|
|
56464
|
+
writeFileSync18(file2, final, "utf8");
|
|
56428
56465
|
console.log(`installed Codex hooks \u2192 ${file2}`);
|
|
56429
56466
|
console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
|
|
56430
56467
|
console.log("");
|