@inerrata-corporation/errata 2.0.2-dev.938 → 2.0.2-dev.981
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/consolidate-worker.mjs +11 -0
- package/errata.mjs +437 -342
- package/package.json +1 -1
- package/pass-worker.mjs +178 -78
package/package.json
CHANGED
package/pass-worker.mjs
CHANGED
|
@@ -15535,6 +15535,87 @@ var init_src2 = __esm({
|
|
|
15535
15535
|
}
|
|
15536
15536
|
});
|
|
15537
15537
|
|
|
15538
|
+
// ../../packages/indexer/src/parse-cache.ts
|
|
15539
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
15540
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
15541
|
+
import { homedir } from "node:os";
|
|
15542
|
+
import { join } from "node:path";
|
|
15543
|
+
function parseCacheDir() {
|
|
15544
|
+
return process.env["ERRATA_PARSE_CACHE"] ?? join(homedir(), ".errata", "parse-cache");
|
|
15545
|
+
}
|
|
15546
|
+
function parseCacheKey(source, providerId) {
|
|
15547
|
+
return createHash2("sha256").update(`${PARSE_CACHE_VERSION}:${providerId}:${source}`).digest("hex");
|
|
15548
|
+
}
|
|
15549
|
+
function entryPath(dir, key) {
|
|
15550
|
+
return join(dir, key.slice(0, 2), `${key.slice(2)}.json`);
|
|
15551
|
+
}
|
|
15552
|
+
function readParseCache(dir, key) {
|
|
15553
|
+
const file2 = entryPath(dir, key);
|
|
15554
|
+
try {
|
|
15555
|
+
const raw = readFileSync(file2, "utf8");
|
|
15556
|
+
const parsed = JSON.parse(raw);
|
|
15557
|
+
if (parsed.v !== PARSE_CACHE_VERSION || !Array.isArray(parsed.symbols)) return null;
|
|
15558
|
+
return { symbols: parsed.symbols, reExports: parsed.reExports ?? [] };
|
|
15559
|
+
} catch {
|
|
15560
|
+
return null;
|
|
15561
|
+
}
|
|
15562
|
+
}
|
|
15563
|
+
function writeParseCache(dir, key, providerId, value) {
|
|
15564
|
+
try {
|
|
15565
|
+
const envelope = {
|
|
15566
|
+
v: PARSE_CACHE_VERSION,
|
|
15567
|
+
provider: providerId,
|
|
15568
|
+
symbols: value.symbols,
|
|
15569
|
+
reExports: value.reExports
|
|
15570
|
+
};
|
|
15571
|
+
const body2 = JSON.stringify(envelope);
|
|
15572
|
+
if (body2.length > MAX_ENTRY_BYTES) return;
|
|
15573
|
+
const file2 = entryPath(dir, key);
|
|
15574
|
+
mkdirSync(join(dir, key.slice(0, 2)), { recursive: true });
|
|
15575
|
+
writeFileSync(file2, body2);
|
|
15576
|
+
} catch {
|
|
15577
|
+
}
|
|
15578
|
+
}
|
|
15579
|
+
function sweepParseCacheOnce(dir, now = Date.now()) {
|
|
15580
|
+
if (sweptThisProcess) return 0;
|
|
15581
|
+
sweptThisProcess = true;
|
|
15582
|
+
let removed = 0;
|
|
15583
|
+
try {
|
|
15584
|
+
if (!existsSync(dir)) return 0;
|
|
15585
|
+
for (const bucket of readdirSync(dir)) {
|
|
15586
|
+
const bucketDir = join(dir, bucket);
|
|
15587
|
+
let names;
|
|
15588
|
+
try {
|
|
15589
|
+
names = readdirSync(bucketDir);
|
|
15590
|
+
} catch {
|
|
15591
|
+
continue;
|
|
15592
|
+
}
|
|
15593
|
+
for (const name2 of names) {
|
|
15594
|
+
const file2 = join(bucketDir, name2);
|
|
15595
|
+
try {
|
|
15596
|
+
if (now - statSync(file2).mtimeMs > ENTRY_TTL_MS) {
|
|
15597
|
+
rmSync(file2, { force: true });
|
|
15598
|
+
removed++;
|
|
15599
|
+
}
|
|
15600
|
+
} catch {
|
|
15601
|
+
}
|
|
15602
|
+
}
|
|
15603
|
+
}
|
|
15604
|
+
} catch {
|
|
15605
|
+
}
|
|
15606
|
+
return removed;
|
|
15607
|
+
}
|
|
15608
|
+
var PARSE_CACHE_VERSION, ENTRY_TTL_MS, MAX_ENTRY_BYTES, sweptThisProcess;
|
|
15609
|
+
var init_parse_cache = __esm({
|
|
15610
|
+
"../../packages/indexer/src/parse-cache.ts"() {
|
|
15611
|
+
"use strict";
|
|
15612
|
+
PARSE_CACHE_VERSION = 1;
|
|
15613
|
+
ENTRY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
15614
|
+
MAX_ENTRY_BYTES = 2 * 1024 * 1024;
|
|
15615
|
+
sweptThisProcess = false;
|
|
15616
|
+
}
|
|
15617
|
+
});
|
|
15618
|
+
|
|
15538
15619
|
// ../../packages/indexer/src/simhash.ts
|
|
15539
15620
|
function fnv1a64(s) {
|
|
15540
15621
|
let h = FNV_OFFSET;
|
|
@@ -15758,10 +15839,10 @@ var init_identity2 = __esm({
|
|
|
15758
15839
|
});
|
|
15759
15840
|
|
|
15760
15841
|
// ../../packages/indexer/src/pipeline.ts
|
|
15761
|
-
import { appendFileSync, readFileSync, statSync } from "node:fs";
|
|
15842
|
+
import { appendFileSync, readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
|
|
15762
15843
|
import { readdir } from "node:fs/promises";
|
|
15763
|
-
import { extname, join, relative, sep } from "node:path";
|
|
15764
|
-
import { createHash as
|
|
15844
|
+
import { extname, join as join2, relative, sep } from "node:path";
|
|
15845
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
15765
15846
|
import { execFileSync } from "node:child_process";
|
|
15766
15847
|
function nowTs() {
|
|
15767
15848
|
return indexNow ?? Date.now();
|
|
@@ -15770,7 +15851,7 @@ function fingerprintOf(signature, bodyHash) {
|
|
|
15770
15851
|
return `${signature ?? ""}|${bodyHash ?? ""}`;
|
|
15771
15852
|
}
|
|
15772
15853
|
function sha(s) {
|
|
15773
|
-
return
|
|
15854
|
+
return createHash3("sha256").update(s).digest("hex").slice(0, 16);
|
|
15774
15855
|
}
|
|
15775
15856
|
function fileNodeId(workspaceId, relPath) {
|
|
15776
15857
|
return `file_${sha(workspaceId + ":" + relPath.replace(/\\/g, "/"))}`;
|
|
@@ -15894,7 +15975,7 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
15894
15975
|
for (const rel of [...changedRelPaths]) {
|
|
15895
15976
|
let h;
|
|
15896
15977
|
try {
|
|
15897
|
-
h =
|
|
15978
|
+
h = createHash3("sha256").update(readFileSync2(join2(rootPath, rel))).digest("hex");
|
|
15898
15979
|
} catch {
|
|
15899
15980
|
continue;
|
|
15900
15981
|
}
|
|
@@ -15943,13 +16024,13 @@ async function incrementalReindex(store2, rootPath, workspaceId, changedAbsPaths
|
|
|
15943
16024
|
let parsedFiles = 0;
|
|
15944
16025
|
for (const rel of changedRelPaths) {
|
|
15945
16026
|
if (parsedFiles++ > 0) await new Promise((r2) => setImmediate(r2));
|
|
15946
|
-
const abs =
|
|
16027
|
+
const abs = join2(rootPath, ...rel.split("/"));
|
|
15947
16028
|
const ext = extname(abs).toLowerCase();
|
|
15948
16029
|
const provider = providers.find((p) => p.fileExtensions.includes(ext));
|
|
15949
16030
|
if (!provider) continue;
|
|
15950
16031
|
let symbols;
|
|
15951
16032
|
try {
|
|
15952
|
-
symbols = provider.extractSymbols(
|
|
16033
|
+
symbols = provider.extractSymbols(readFileSync2(abs, "utf8"), abs);
|
|
15953
16034
|
} catch {
|
|
15954
16035
|
continue;
|
|
15955
16036
|
}
|
|
@@ -16203,8 +16284,13 @@ async function runIndexer(store2, opts) {
|
|
|
16203
16284
|
byLanguage: {},
|
|
16204
16285
|
durationMs: 0,
|
|
16205
16286
|
nodesPurged: 0,
|
|
16206
|
-
edgesPurged: 0
|
|
16287
|
+
edgesPurged: 0,
|
|
16288
|
+
parseCacheHits: 0,
|
|
16289
|
+
parseCacheMisses: 0
|
|
16207
16290
|
};
|
|
16291
|
+
const cacheDir = parseCacheDir();
|
|
16292
|
+
const parseCacheEnabled = cacheDir !== "";
|
|
16293
|
+
if (parseCacheEnabled) sweepParseCacheOnce(cacheDir);
|
|
16208
16294
|
if (opts.clean) {
|
|
16209
16295
|
const purge = purgeWorkspaceCodeGraph(store2, opts.workspaceId);
|
|
16210
16296
|
report.nodesPurged = purge.nodes;
|
|
@@ -16258,25 +16344,38 @@ async function runIndexer(store2, opts) {
|
|
|
16258
16344
|
}
|
|
16259
16345
|
let source;
|
|
16260
16346
|
try {
|
|
16261
|
-
const st =
|
|
16347
|
+
const st = statSync2(f.absPath);
|
|
16262
16348
|
if (st.size > maxBytes) {
|
|
16263
16349
|
report.filesSkipped++;
|
|
16264
16350
|
continue;
|
|
16265
16351
|
}
|
|
16266
|
-
source =
|
|
16352
|
+
source = readFileSync2(f.absPath, "utf8");
|
|
16267
16353
|
} catch {
|
|
16268
16354
|
report.filesSkipped++;
|
|
16269
16355
|
continue;
|
|
16270
16356
|
}
|
|
16357
|
+
const cacheKey = parseCacheKey(source, f.provider.id);
|
|
16358
|
+
const cached2 = parseCacheEnabled ? readParseCache(cacheDir, cacheKey) : null;
|
|
16271
16359
|
let symbols;
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
16276
|
-
|
|
16360
|
+
let reExports;
|
|
16361
|
+
if (cached2) {
|
|
16362
|
+
symbols = cached2.symbols;
|
|
16363
|
+
reExports = cached2.reExports;
|
|
16364
|
+
report.parseCacheHits++;
|
|
16365
|
+
} else {
|
|
16366
|
+
try {
|
|
16367
|
+
symbols = f.provider.extractSymbols(source, f.absPath);
|
|
16368
|
+
} catch {
|
|
16369
|
+
report.filesSkipped++;
|
|
16370
|
+
continue;
|
|
16371
|
+
}
|
|
16372
|
+
reExports = scanReExports(source);
|
|
16373
|
+
report.parseCacheMisses++;
|
|
16374
|
+
if (parseCacheEnabled) {
|
|
16375
|
+
writeParseCache(cacheDir, cacheKey, f.provider.id, { symbols, reExports });
|
|
16376
|
+
}
|
|
16277
16377
|
}
|
|
16278
16378
|
symbolsByFile.set(f.relPath, symbols);
|
|
16279
|
-
const reExports = scanReExports(source);
|
|
16280
16379
|
if (reExports.length > 0) reExportsByFile.set(f.relPath, reExports);
|
|
16281
16380
|
report.filesParsed++;
|
|
16282
16381
|
report.byLanguage[f.provider.id] = (report.byLanguage[f.provider.id] ?? 0) + 1;
|
|
@@ -16321,7 +16420,7 @@ async function runIndexer(store2, opts) {
|
|
|
16321
16420
|
const depth = fileNode.relPath.split("/").length;
|
|
16322
16421
|
if (depth !== 3) continue;
|
|
16323
16422
|
try {
|
|
16324
|
-
const pkg = JSON.parse(
|
|
16423
|
+
const pkg = JSON.parse(readFileSync2(fileNode.absPath, "utf8"));
|
|
16325
16424
|
if (!pkg.name) continue;
|
|
16326
16425
|
const pkgDir = fileNode.relPath.replace(/\/package\.json$/, "");
|
|
16327
16426
|
const candidates = [
|
|
@@ -16703,7 +16802,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
16703
16802
|
for (const ent of entries) {
|
|
16704
16803
|
if (ignores.has(ent.name)) continue;
|
|
16705
16804
|
if (ent.name.startsWith(".") && ent.name !== ".") continue;
|
|
16706
|
-
const abs =
|
|
16805
|
+
const abs = join2(current, ent.name);
|
|
16707
16806
|
if (ent.isDirectory()) {
|
|
16708
16807
|
await scan(root, abs, ignores, providers, out2);
|
|
16709
16808
|
} else if (ent.isFile()) {
|
|
@@ -16712,7 +16811,7 @@ async function scan(root, current, ignores, providers, out2) {
|
|
|
16712
16811
|
const rel = relative(root, abs).split(sep).join("/");
|
|
16713
16812
|
let size = 0;
|
|
16714
16813
|
try {
|
|
16715
|
-
size =
|
|
16814
|
+
size = statSync2(abs).size;
|
|
16716
16815
|
} catch {
|
|
16717
16816
|
continue;
|
|
16718
16817
|
}
|
|
@@ -16758,10 +16857,10 @@ function gitListFiles(root, ignores, providers) {
|
|
|
16758
16857
|
if (rels === null) return null;
|
|
16759
16858
|
const out2 = [];
|
|
16760
16859
|
for (const rel of rels) {
|
|
16761
|
-
const abs =
|
|
16860
|
+
const abs = join2(root, rel);
|
|
16762
16861
|
let size;
|
|
16763
16862
|
try {
|
|
16764
|
-
size =
|
|
16863
|
+
size = statSync2(abs).size;
|
|
16765
16864
|
} catch {
|
|
16766
16865
|
continue;
|
|
16767
16866
|
}
|
|
@@ -16781,7 +16880,7 @@ function upsertFile(store2, id, f, workspaceId) {
|
|
|
16781
16880
|
const now = nowTs();
|
|
16782
16881
|
let contentHash;
|
|
16783
16882
|
try {
|
|
16784
|
-
contentHash =
|
|
16883
|
+
contentHash = createHash3("sha256").update(readFileSync2(f.absPath)).digest("hex");
|
|
16785
16884
|
} catch {
|
|
16786
16885
|
}
|
|
16787
16886
|
const node = {
|
|
@@ -16980,6 +17079,7 @@ var init_pipeline = __esm({
|
|
|
16980
17079
|
"../../packages/indexer/src/pipeline.ts"() {
|
|
16981
17080
|
"use strict";
|
|
16982
17081
|
init_src2();
|
|
17082
|
+
init_parse_cache();
|
|
16983
17083
|
init_identity2();
|
|
16984
17084
|
DEFAULT_IGNORES = /* @__PURE__ */ new Set([
|
|
16985
17085
|
"node_modules",
|
|
@@ -21144,8 +21244,8 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
21144
21244
|
|
|
21145
21245
|
// ../../packages/indexer/src/languages/tree-sitter-loader.ts
|
|
21146
21246
|
import { fileURLToPath } from "node:url";
|
|
21147
|
-
import { dirname, join as
|
|
21148
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
21247
|
+
import { dirname, join as join3 } from "node:path";
|
|
21248
|
+
import { existsSync as existsSync2, readdirSync as readdirSync2 } from "node:fs";
|
|
21149
21249
|
import { createRequire } from "node:module";
|
|
21150
21250
|
function entryDir() {
|
|
21151
21251
|
try {
|
|
@@ -21159,27 +21259,27 @@ function entryDir() {
|
|
|
21159
21259
|
}
|
|
21160
21260
|
function findWasmDir() {
|
|
21161
21261
|
const here = entryDir();
|
|
21162
|
-
const seaWasm =
|
|
21163
|
-
if (
|
|
21262
|
+
const seaWasm = join3(here, "resources", "wasm");
|
|
21263
|
+
if (existsSync2(join3(seaWasm, "tree-sitter-typescript.wasm"))) return seaWasm;
|
|
21164
21264
|
let dir = here;
|
|
21165
21265
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
21166
|
-
const flat =
|
|
21266
|
+
const flat = join3(
|
|
21167
21267
|
dir,
|
|
21168
21268
|
"node_modules",
|
|
21169
21269
|
"@vscode",
|
|
21170
21270
|
"tree-sitter-wasm",
|
|
21171
21271
|
"wasm"
|
|
21172
21272
|
);
|
|
21173
|
-
if (
|
|
21273
|
+
if (existsSync2(join3(flat, "tree-sitter-typescript.wasm"))) return flat;
|
|
21174
21274
|
dir = dirname(dir);
|
|
21175
21275
|
}
|
|
21176
21276
|
let root = here;
|
|
21177
21277
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
21178
|
-
const pnpmDir =
|
|
21179
|
-
if (
|
|
21180
|
-
for (const entry of
|
|
21278
|
+
const pnpmDir = join3(root, "node_modules", ".pnpm");
|
|
21279
|
+
if (existsSync2(pnpmDir)) {
|
|
21280
|
+
for (const entry of readdirSync2(pnpmDir)) {
|
|
21181
21281
|
if (entry.startsWith("@vscode+tree-sitter-wasm@")) {
|
|
21182
|
-
const candidate =
|
|
21282
|
+
const candidate = join3(
|
|
21183
21283
|
pnpmDir,
|
|
21184
21284
|
entry,
|
|
21185
21285
|
"node_modules",
|
|
@@ -21187,7 +21287,7 @@ function findWasmDir() {
|
|
|
21187
21287
|
"tree-sitter-wasm",
|
|
21188
21288
|
"wasm"
|
|
21189
21289
|
);
|
|
21190
|
-
if (
|
|
21290
|
+
if (existsSync2(join3(candidate, "tree-sitter-typescript.wasm"))) {
|
|
21191
21291
|
return candidate;
|
|
21192
21292
|
}
|
|
21193
21293
|
}
|
|
@@ -21201,27 +21301,27 @@ function findWasmDir() {
|
|
|
21201
21301
|
}
|
|
21202
21302
|
function findRuntimeDir() {
|
|
21203
21303
|
const here = entryDir();
|
|
21204
|
-
const seaRuntime =
|
|
21205
|
-
if (
|
|
21304
|
+
const seaRuntime = join3(here, "resources", "wasm");
|
|
21305
|
+
if (existsSync2(join3(seaRuntime, "web-tree-sitter.wasm"))) return seaRuntime;
|
|
21206
21306
|
let dir = here;
|
|
21207
21307
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
21208
|
-
const flat =
|
|
21209
|
-
if (
|
|
21308
|
+
const flat = join3(dir, "node_modules", "web-tree-sitter");
|
|
21309
|
+
if (existsSync2(join3(flat, "web-tree-sitter.wasm"))) return flat;
|
|
21210
21310
|
dir = dirname(dir);
|
|
21211
21311
|
}
|
|
21212
21312
|
let root = here;
|
|
21213
21313
|
for (let i2 = 0; i2 < 6; i2++) {
|
|
21214
|
-
const pnpmDir =
|
|
21215
|
-
if (
|
|
21216
|
-
for (const entry of
|
|
21314
|
+
const pnpmDir = join3(root, "node_modules", ".pnpm");
|
|
21315
|
+
if (existsSync2(pnpmDir)) {
|
|
21316
|
+
for (const entry of readdirSync2(pnpmDir)) {
|
|
21217
21317
|
if (entry.startsWith("web-tree-sitter@")) {
|
|
21218
|
-
const candidate =
|
|
21318
|
+
const candidate = join3(
|
|
21219
21319
|
pnpmDir,
|
|
21220
21320
|
entry,
|
|
21221
21321
|
"node_modules",
|
|
21222
21322
|
"web-tree-sitter"
|
|
21223
21323
|
);
|
|
21224
|
-
if (
|
|
21324
|
+
if (existsSync2(join3(candidate, "web-tree-sitter.wasm"))) {
|
|
21225
21325
|
return candidate;
|
|
21226
21326
|
}
|
|
21227
21327
|
}
|
|
@@ -21238,7 +21338,7 @@ async function loadWebTreeSitter() {
|
|
|
21238
21338
|
void err2;
|
|
21239
21339
|
}
|
|
21240
21340
|
const here = entryDir();
|
|
21241
|
-
const seaResourceBase =
|
|
21341
|
+
const seaResourceBase = join3(here, "resources", "_resolve.js");
|
|
21242
21342
|
const resourceRequire = createRequire(seaResourceBase);
|
|
21243
21343
|
return resourceRequire("web-tree-sitter");
|
|
21244
21344
|
}
|
|
@@ -21253,9 +21353,9 @@ async function ensureTreeSitterReady() {
|
|
|
21253
21353
|
await Parser2.init({
|
|
21254
21354
|
locateFile: (name2) => {
|
|
21255
21355
|
if (name2 === "tree-sitter.wasm" || name2 === "web-tree-sitter.wasm") {
|
|
21256
|
-
return
|
|
21356
|
+
return join3(runtime, name2);
|
|
21257
21357
|
}
|
|
21258
|
-
return
|
|
21358
|
+
return join3(grammars, name2);
|
|
21259
21359
|
}
|
|
21260
21360
|
});
|
|
21261
21361
|
})();
|
|
@@ -21267,7 +21367,7 @@ async function loadGrammar(name2) {
|
|
|
21267
21367
|
if (cached2) return cached2;
|
|
21268
21368
|
if (!languageClass) throw new Error("tree-sitter not initialized");
|
|
21269
21369
|
const grammars = findWasmDir();
|
|
21270
|
-
const lang = await languageClass.load(
|
|
21370
|
+
const lang = await languageClass.load(join3(grammars, `${name2}.wasm`));
|
|
21271
21371
|
grammarCache.set(name2, lang);
|
|
21272
21372
|
return lang;
|
|
21273
21373
|
}
|
|
@@ -21290,7 +21390,7 @@ var init_tree_sitter_loader = __esm({
|
|
|
21290
21390
|
});
|
|
21291
21391
|
|
|
21292
21392
|
// ../../packages/indexer/src/languages/typescript-treesitter.ts
|
|
21293
|
-
import { createHash as
|
|
21393
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
21294
21394
|
function extractNode(node, source, containerQname, containerKind) {
|
|
21295
21395
|
switch (node.type) {
|
|
21296
21396
|
case "function_declaration":
|
|
@@ -21503,7 +21603,7 @@ function scopeRecord(kind, name2, qname, node, body2, source) {
|
|
|
21503
21603
|
const sig = header.replace(/\s+/g, " ").trim();
|
|
21504
21604
|
if (sig) rec.signature = sig;
|
|
21505
21605
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
21506
|
-
rec.bodyHash =
|
|
21606
|
+
rec.bodyHash = createHash4("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
21507
21607
|
rec.bodySimhash = toHex(simhash(bodyText));
|
|
21508
21608
|
}
|
|
21509
21609
|
}
|
|
@@ -21945,14 +22045,14 @@ var init_typescript_treesitter = __esm({
|
|
|
21945
22045
|
});
|
|
21946
22046
|
|
|
21947
22047
|
// ../../packages/indexer/src/languages/python-treesitter.ts
|
|
21948
|
-
import { createHash as
|
|
22048
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
21949
22049
|
function sigAndHash(node, body2, source) {
|
|
21950
22050
|
if (!body2) return {};
|
|
21951
22051
|
const out2 = {};
|
|
21952
22052
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
21953
22053
|
if (sig) out2.signature = sig;
|
|
21954
22054
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
21955
|
-
out2.bodyHash =
|
|
22055
|
+
out2.bodyHash = createHash5("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
21956
22056
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
21957
22057
|
return out2;
|
|
21958
22058
|
}
|
|
@@ -22365,7 +22465,7 @@ var init_python_treesitter = __esm({
|
|
|
22365
22465
|
});
|
|
22366
22466
|
|
|
22367
22467
|
// ../../packages/indexer/src/languages/cpp-treesitter.ts
|
|
22368
|
-
import { createHash as
|
|
22468
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
22369
22469
|
function extractNode3(node, containerQname, containerIsClass, source) {
|
|
22370
22470
|
switch (node.type) {
|
|
22371
22471
|
case "function_definition":
|
|
@@ -22549,7 +22649,7 @@ function sigAndHash2(node, body2, source) {
|
|
|
22549
22649
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
22550
22650
|
if (sig) out2.signature = sig;
|
|
22551
22651
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
22552
|
-
out2.bodyHash =
|
|
22652
|
+
out2.bodyHash = createHash6("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
22553
22653
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
22554
22654
|
return out2;
|
|
22555
22655
|
}
|
|
@@ -22710,7 +22810,7 @@ var init_cpp_treesitter = __esm({
|
|
|
22710
22810
|
});
|
|
22711
22811
|
|
|
22712
22812
|
// ../../packages/indexer/src/languages/go-treesitter.ts
|
|
22713
|
-
import { createHash as
|
|
22813
|
+
import { createHash as createHash7 } from "node:crypto";
|
|
22714
22814
|
function extractNode4(node, containerQname, source) {
|
|
22715
22815
|
switch (node.type) {
|
|
22716
22816
|
case "function_declaration": {
|
|
@@ -22872,7 +22972,7 @@ function sigAndHash3(node, body2, source) {
|
|
|
22872
22972
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
22873
22973
|
if (sig) out2.signature = sig;
|
|
22874
22974
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
22875
|
-
out2.bodyHash =
|
|
22975
|
+
out2.bodyHash = createHash7("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
22876
22976
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
22877
22977
|
return out2;
|
|
22878
22978
|
}
|
|
@@ -23016,7 +23116,7 @@ var init_go_treesitter = __esm({
|
|
|
23016
23116
|
});
|
|
23017
23117
|
|
|
23018
23118
|
// ../../packages/indexer/src/languages/rust-treesitter.ts
|
|
23019
|
-
import { createHash as
|
|
23119
|
+
import { createHash as createHash8 } from "node:crypto";
|
|
23020
23120
|
function extractNode5(node, containerQname, containerIsClass, source) {
|
|
23021
23121
|
switch (node.type) {
|
|
23022
23122
|
case "function_item":
|
|
@@ -23231,7 +23331,7 @@ function sigAndHash4(node, body2, source) {
|
|
|
23231
23331
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
23232
23332
|
if (sig) out2.signature = sig;
|
|
23233
23333
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
23234
|
-
out2.bodyHash =
|
|
23334
|
+
out2.bodyHash = createHash8("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
23235
23335
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
23236
23336
|
return out2;
|
|
23237
23337
|
}
|
|
@@ -23382,7 +23482,7 @@ var init_rust_treesitter = __esm({
|
|
|
23382
23482
|
});
|
|
23383
23483
|
|
|
23384
23484
|
// ../../packages/indexer/src/languages/ruby-treesitter.ts
|
|
23385
|
-
import { createHash as
|
|
23485
|
+
import { createHash as createHash9 } from "node:crypto";
|
|
23386
23486
|
function sigAndHash5(node, body2, source) {
|
|
23387
23487
|
if (!body2) {
|
|
23388
23488
|
const sig2 = source.slice(node.startIndex, node.endIndex).replace(/\s+/g, " ").trim();
|
|
@@ -23392,7 +23492,7 @@ function sigAndHash5(node, body2, source) {
|
|
|
23392
23492
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
23393
23493
|
if (sig) out2.signature = sig;
|
|
23394
23494
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
23395
|
-
out2.bodyHash =
|
|
23495
|
+
out2.bodyHash = createHash9("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
23396
23496
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
23397
23497
|
return out2;
|
|
23398
23498
|
}
|
|
@@ -23738,7 +23838,7 @@ var init_ruby_treesitter = __esm({
|
|
|
23738
23838
|
});
|
|
23739
23839
|
|
|
23740
23840
|
// ../../packages/indexer/src/languages/csharp-treesitter.ts
|
|
23741
|
-
import { createHash as
|
|
23841
|
+
import { createHash as createHash10 } from "node:crypto";
|
|
23742
23842
|
function extractNode7(node, containerQname, containerIsType, source, eof) {
|
|
23743
23843
|
switch (node.type) {
|
|
23744
23844
|
case "method_declaration":
|
|
@@ -23940,7 +24040,7 @@ function sigAndHash6(node, body2, source) {
|
|
|
23940
24040
|
const sig = source.slice(node.startIndex, body2.startIndex).replace(/\s+/g, " ").trim();
|
|
23941
24041
|
if (sig) out2.signature = sig;
|
|
23942
24042
|
const bodyText = source.slice(body2.startIndex, body2.endIndex);
|
|
23943
|
-
out2.bodyHash =
|
|
24043
|
+
out2.bodyHash = createHash10("sha256").update(bodyText).digest("hex").slice(0, 16);
|
|
23944
24044
|
out2.bodySimhash = toHex(simhash(bodyText));
|
|
23945
24045
|
return out2;
|
|
23946
24046
|
}
|
|
@@ -27102,37 +27202,37 @@ init_src3();
|
|
|
27102
27202
|
// ../../node_modules/.pnpm/env-paths@3.0.0/node_modules/env-paths/index.js
|
|
27103
27203
|
import os from "node:os";
|
|
27104
27204
|
import process3 from "node:process";
|
|
27105
|
-
var
|
|
27205
|
+
var homedir2 = os.homedir();
|
|
27106
27206
|
var tmpdir = os.tmpdir();
|
|
27107
27207
|
var { env } = process3;
|
|
27108
27208
|
|
|
27109
27209
|
// src/paths.ts
|
|
27110
|
-
import { dirname as dirname2, join as
|
|
27210
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
27111
27211
|
function workspaceDir(workspaceRoot) {
|
|
27112
|
-
return
|
|
27212
|
+
return join4(workspaceRoot, ".errata");
|
|
27113
27213
|
}
|
|
27114
27214
|
function workspacePaths(root) {
|
|
27115
27215
|
const dir = workspaceDir(root);
|
|
27116
27216
|
return {
|
|
27117
27217
|
root,
|
|
27118
27218
|
configDir: dir,
|
|
27119
|
-
workspaceJson:
|
|
27120
|
-
eventLog:
|
|
27121
|
-
castalia:
|
|
27122
|
-
reviewQueue:
|
|
27123
|
-
outbox:
|
|
27124
|
-
daemonLock:
|
|
27125
|
-
identityAudit:
|
|
27126
|
-
skillsDir:
|
|
27127
|
-
skillsManifest:
|
|
27219
|
+
workspaceJson: join4(dir, "workspace.json"),
|
|
27220
|
+
eventLog: join4(dir, "eventlog.sqlite"),
|
|
27221
|
+
castalia: join4(dir, "castalia.db"),
|
|
27222
|
+
reviewQueue: join4(dir, "review-queue.json"),
|
|
27223
|
+
outbox: join4(dir, "outbox"),
|
|
27224
|
+
daemonLock: join4(dir, "daemon.lock"),
|
|
27225
|
+
identityAudit: join4(dir, "identity-audit.log"),
|
|
27226
|
+
skillsDir: join4(dir, "skills"),
|
|
27227
|
+
skillsManifest: join4(dir, "skills.json")
|
|
27128
27228
|
};
|
|
27129
27229
|
}
|
|
27130
27230
|
|
|
27131
27231
|
// src/reconcile.ts
|
|
27132
27232
|
init_src3();
|
|
27133
27233
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
27134
|
-
import { readdirSync as
|
|
27135
|
-
import { join as
|
|
27234
|
+
import { readdirSync as readdirSync3, statSync as statSync3 } from "node:fs";
|
|
27235
|
+
import { join as join5, relative as relative2, sep as sep2 } from "node:path";
|
|
27136
27236
|
var IGNORED = /[\\/](?:\.git|node_modules|\.errata|dist|__pycache__)(?:[\\/]|$)/;
|
|
27137
27237
|
var SOURCE_RE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
|
|
27138
27238
|
function gitSourceFiles(root) {
|
|
@@ -27149,7 +27249,7 @@ function gitSourceFiles(root) {
|
|
|
27149
27249
|
const out2 = [];
|
|
27150
27250
|
for (const rel of stdout.split("\0")) {
|
|
27151
27251
|
if (!rel || !SOURCE_RE.test(rel)) continue;
|
|
27152
|
-
const abs =
|
|
27252
|
+
const abs = join5(root, rel);
|
|
27153
27253
|
if (IGNORED.test(abs)) continue;
|
|
27154
27254
|
out2.push(abs);
|
|
27155
27255
|
}
|
|
@@ -27158,13 +27258,13 @@ function gitSourceFiles(root) {
|
|
|
27158
27258
|
function* walkSource(dir) {
|
|
27159
27259
|
let entries;
|
|
27160
27260
|
try {
|
|
27161
|
-
entries =
|
|
27261
|
+
entries = readdirSync3(dir, { withFileTypes: true });
|
|
27162
27262
|
} catch {
|
|
27163
27263
|
return;
|
|
27164
27264
|
}
|
|
27165
27265
|
for (const e of entries) {
|
|
27166
27266
|
const name2 = String(e.name);
|
|
27167
|
-
const full =
|
|
27267
|
+
const full = join5(dir, name2);
|
|
27168
27268
|
if (IGNORED.test(full)) continue;
|
|
27169
27269
|
if (e.isDirectory()) yield* walkSource(full);
|
|
27170
27270
|
else if (SOURCE_RE.test(name2)) yield full;
|
|
@@ -27184,7 +27284,7 @@ async function findStaleFiles(store2, rootPath, workspaceId) {
|
|
|
27184
27284
|
if (++scanned % SCAN_YIELD_EVERY === 0) await new Promise((r) => setImmediate(r));
|
|
27185
27285
|
let mtimeMs;
|
|
27186
27286
|
try {
|
|
27187
|
-
mtimeMs =
|
|
27287
|
+
mtimeMs = statSync3(abs).mtimeMs;
|
|
27188
27288
|
} catch {
|
|
27189
27289
|
continue;
|
|
27190
27290
|
}
|