@inerrata-corporation/errata 2.0.6-dev.2198 → 2.0.6-dev.2250

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.
Files changed (2) hide show
  1. package/errata.mjs +1055 -200
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -15984,12 +15984,35 @@ var init_project_symbol = __esm({
15984
15984
  });
15985
15985
 
15986
15986
  // ../../packages/shared/src/lockfile.ts
15987
+ function rankDirect(raw2, ecosystem = "npm") {
15988
+ const byName = /* @__PURE__ */ new Map();
15989
+ for (const { name: name2, version: version2 } of raw2) {
15990
+ const prev = byName.get(name2);
15991
+ if (prev) {
15992
+ prev.importers++;
15993
+ continue;
15994
+ }
15995
+ byName.set(name2, {
15996
+ purl: `pkg:${ecosystem}/${name2}@${version2}`,
15997
+ name: name2,
15998
+ version: version2,
15999
+ ecosystem,
16000
+ importers: 1
16001
+ });
16002
+ }
16003
+ return [...byName.values()].sort(
16004
+ (a, b) => b.importers - a.importers || a.name.localeCompare(b.name)
16005
+ );
16006
+ }
15987
16007
  function npmPurl(name2, version2) {
15988
16008
  return `pkg:npm/${name2}@${version2}`;
15989
16009
  }
15990
16010
  function component(name2, version2) {
15991
16011
  return { purl: npmPurl(name2, version2), name: name2, version: version2, ecosystem: "npm" };
15992
16012
  }
16013
+ function isNpmImporterPath(path2) {
16014
+ return path2 === "" || !path2.includes("node_modules/");
16015
+ }
15993
16016
  function parsePackageLockJson(jsonText) {
15994
16017
  let doc;
15995
16018
  try {
@@ -16028,7 +16051,23 @@ function parsePackageLockJson(jsonText) {
16028
16051
  if (dependsOn.length > 0)
16029
16052
  dependencies.push({ ref: npmPurl(self.name, self.version), dependsOn });
16030
16053
  }
16031
- return { components, dependencies: dedupeRefs(dependencies) };
16054
+ const directRaw = [];
16055
+ for (const [path2, meta3] of Object.entries(packages)) {
16056
+ if (!isNpmImporterPath(path2)) continue;
16057
+ for (const section of [meta3.dependencies, meta3.devDependencies, meta3.optionalDependencies]) {
16058
+ if (!section || typeof section !== "object") continue;
16059
+ for (const name2 of Object.keys(section)) {
16060
+ const target = hoisted.get(name2);
16061
+ if (target) directRaw.push({ name: name2, version: target.version });
16062
+ }
16063
+ }
16064
+ }
16065
+ const direct = rankDirect(directRaw);
16066
+ return {
16067
+ components,
16068
+ dependencies: dedupeRefs(dependencies),
16069
+ ...direct.length > 0 ? { direct } : {}
16070
+ };
16032
16071
  }
16033
16072
  function splitPnpmKey(raw2) {
16034
16073
  let k = raw2.trim().replace(/^['"]|['"]$/g, "");
@@ -16043,6 +16082,53 @@ function splitPnpmKey(raw2) {
16043
16082
  if (!name2 || !version2) return null;
16044
16083
  return { name: name2, version: version2 };
16045
16084
  }
16085
+ function parsePnpmImporters(lines) {
16086
+ const DEP_SECTIONS = /* @__PURE__ */ new Set(["dependencies:", "devDependencies:", "optionalDependencies:"]);
16087
+ const raw2 = [];
16088
+ let inImporters = false;
16089
+ let inDepSection = false;
16090
+ let depName = null;
16091
+ for (const line of lines) {
16092
+ if (!line.trim() || line.trimStart().startsWith("#")) continue;
16093
+ const indent = line.length - line.trimStart().length;
16094
+ if (indent === 0) {
16095
+ inImporters = line.trimEnd() === "importers:";
16096
+ inDepSection = false;
16097
+ depName = null;
16098
+ continue;
16099
+ }
16100
+ if (!inImporters) continue;
16101
+ if (indent === 2) {
16102
+ inDepSection = false;
16103
+ depName = null;
16104
+ continue;
16105
+ }
16106
+ if (indent === 4) {
16107
+ inDepSection = DEP_SECTIONS.has(line.trim());
16108
+ depName = null;
16109
+ continue;
16110
+ }
16111
+ if (!inDepSection) continue;
16112
+ if (indent === 6 && line.trimEnd().endsWith(":")) {
16113
+ depName = line.trim().slice(0, -1).replace(/^['"]|['"]$/g, "") || null;
16114
+ continue;
16115
+ }
16116
+ if (indent === 8 && depName) {
16117
+ const t = line.trim();
16118
+ if (!t.startsWith("version:")) continue;
16119
+ let version2 = t.slice("version:".length).trim().replace(/^['"]|['"]$/g, "");
16120
+ const paren = version2.indexOf("(");
16121
+ if (paren !== -1) version2 = version2.slice(0, paren);
16122
+ if (!version2 || version2.startsWith("link:") || version2.startsWith("file:") || version2.includes("://")) {
16123
+ depName = null;
16124
+ continue;
16125
+ }
16126
+ raw2.push({ name: depName, version: version2 });
16127
+ depName = null;
16128
+ }
16129
+ }
16130
+ return rankDirect(raw2);
16131
+ }
16046
16132
  function parsePnpmLock(text) {
16047
16133
  const lines = text.split(/\r?\n/);
16048
16134
  const components = [];
@@ -16104,7 +16190,92 @@ function parsePnpmLock(text) {
16104
16190
  }
16105
16191
  }
16106
16192
  flushDeps();
16107
- return { components, dependencies: dedupeRefs(dependencies) };
16193
+ const direct = parsePnpmImporters(lines);
16194
+ return {
16195
+ components,
16196
+ dependencies: dedupeRefs(dependencies),
16197
+ ...direct.length > 0 ? { direct } : {}
16198
+ };
16199
+ }
16200
+ function parseGemfileLock(text) {
16201
+ const lines = text.split(/\r?\n/);
16202
+ const components = [];
16203
+ const dependencies = [];
16204
+ const seen = /* @__PURE__ */ new Set();
16205
+ const registryVersions = /* @__PURE__ */ new Map();
16206
+ const nonRegistry = /* @__PURE__ */ new Set();
16207
+ const declared = [];
16208
+ let section = null;
16209
+ let inSpecs = false;
16210
+ let currentGem = null;
16211
+ const specLine = /^\s{4}([A-Za-z0-9_.-]+)\s*\(([^)]*)\)\s*$/;
16212
+ const nestedDep = /^\s{6}([A-Za-z0-9_.-]+)/;
16213
+ for (const line of lines) {
16214
+ if (!line.trim()) continue;
16215
+ if (!/^\s/.test(line)) {
16216
+ const header = line.trim();
16217
+ section = header === "GEM" ? "gem" : header === "PATH" || header === "GIT" || header === "PLUGIN SOURCE" ? "path-or-git" : header === "DEPENDENCIES" ? "dependencies" : null;
16218
+ inSpecs = false;
16219
+ currentGem = null;
16220
+ continue;
16221
+ }
16222
+ if (section === "dependencies") {
16223
+ const d = /^\s{2}([A-Za-z0-9_.-]+)(!?)/.exec(line);
16224
+ if (d?.[1] && d[2] !== "!") declared.push(d[1]);
16225
+ continue;
16226
+ }
16227
+ if (!section) continue;
16228
+ if (/^\s{2}specs:\s*$/.test(line)) {
16229
+ inSpecs = true;
16230
+ currentGem = null;
16231
+ continue;
16232
+ }
16233
+ if (/^\s{2}\S/.test(line)) {
16234
+ inSpecs = false;
16235
+ currentGem = null;
16236
+ continue;
16237
+ }
16238
+ if (!inSpecs) continue;
16239
+ const spec = specLine.exec(line);
16240
+ if (spec) {
16241
+ const name2 = spec[1];
16242
+ const version2 = (spec[2] ?? "").trim();
16243
+ if (section === "path-or-git") {
16244
+ nonRegistry.add(name2);
16245
+ currentGem = null;
16246
+ continue;
16247
+ }
16248
+ if (!version2) continue;
16249
+ currentGem = { name: name2, version: version2 };
16250
+ registryVersions.set(name2, version2);
16251
+ const purl = `pkg:gem/${name2}@${version2}`;
16252
+ if (!seen.has(purl)) {
16253
+ seen.add(purl);
16254
+ components.push({ purl, name: name2, version: version2, ecosystem: "gem" });
16255
+ }
16256
+ continue;
16257
+ }
16258
+ const nested = nestedDep.exec(line);
16259
+ if (nested?.[1] && currentGem) {
16260
+ dependencies.push({
16261
+ ref: `pkg:gem/${currentGem.name}@${currentGem.version}`,
16262
+ dependsOn: [nested[1]]
16263
+ });
16264
+ }
16265
+ }
16266
+ const resolved = dependencies.map((d) => ({
16267
+ ref: d.ref,
16268
+ dependsOn: d.dependsOn.filter((n) => !nonRegistry.has(n) && registryVersions.has(n)).map((n) => `pkg:gem/${n}@${registryVersions.get(n)}`)
16269
+ })).filter((d) => d.dependsOn.length > 0);
16270
+ const direct = rankDirect(
16271
+ declared.filter((n) => !nonRegistry.has(n) && registryVersions.has(n)).map((n) => ({ name: n, version: registryVersions.get(n) })),
16272
+ "gem"
16273
+ );
16274
+ return {
16275
+ components,
16276
+ dependencies: dedupeRefs(resolved),
16277
+ ...direct.length > 0 ? { direct } : {}
16278
+ };
16108
16279
  }
16109
16280
  function dedupeRefs(deps) {
16110
16281
  const byRef = /* @__PURE__ */ new Map();
@@ -16237,6 +16408,86 @@ function parseCargo(path2, text) {
16237
16408
  }
16238
16409
  return deps;
16239
16410
  }
16411
+ function mavenName(groupId, artifactId) {
16412
+ return `${groupId.trim()}:${artifactId.trim()}`;
16413
+ }
16414
+ function parsePom(path2, text) {
16415
+ const deps = [];
16416
+ const coord = (block) => {
16417
+ const g = /<groupId>([^<]+)<\/groupId>/.exec(block)?.[1];
16418
+ const a = /<artifactId>([^<]+)<\/artifactId>/.exec(block)?.[1];
16419
+ if (!g || !a) return null;
16420
+ return { g, a, v: /<version>([^<]+)<\/version>/.exec(block)?.[1]?.trim() ?? null };
16421
+ };
16422
+ for (const m of text.matchAll(/<dependency>([\s\S]*?)<\/dependency>/g)) {
16423
+ const c = coord(m[1] ?? "");
16424
+ if (c) deps.push({ ecosystem: "maven", name: mavenName(c.g, c.a), version: c.v, kind: "package", manifest: path2 });
16425
+ }
16426
+ for (const m of text.matchAll(/<parent>([\s\S]*?)<\/parent>/g)) {
16427
+ const c = coord(m[1] ?? "");
16428
+ if (c) deps.push({ ecosystem: "maven", name: mavenName(c.g, c.a), version: c.v, kind: "sdk", manifest: path2 });
16429
+ }
16430
+ return deps;
16431
+ }
16432
+ function parseGradle(path2, text) {
16433
+ const deps = [];
16434
+ const re = new RegExp(`\\b(?:${GRADLE_CONFIGS})\\s*(?:\\(\\s*)?["']([^"']+)["']`, "g");
16435
+ for (const m of text.matchAll(re)) {
16436
+ const parts2 = (m[1] ?? "").split(":");
16437
+ const [group, artifact, version2] = parts2;
16438
+ if (!group || !artifact || parts2.length < 2) continue;
16439
+ deps.push({
16440
+ ecosystem: "maven",
16441
+ name: mavenName(group, artifact),
16442
+ version: version2?.trim() || null,
16443
+ kind: "package",
16444
+ manifest: path2
16445
+ });
16446
+ }
16447
+ return deps;
16448
+ }
16449
+ function parseVersionCatalog(path2, text) {
16450
+ const section = /^\s*\[libraries\]([\s\S]*?)(?=^\s*\[|(?![\s\S]))/m.exec(text);
16451
+ if (!section) return [];
16452
+ const deps = [];
16453
+ for (const line of (section[1] ?? "").split(/\r?\n/)) {
16454
+ if (!line.trim() || line.trimStart().startsWith("#")) continue;
16455
+ const module2 = /module\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16456
+ const version2 = /version(?:\.ref)?\s*=\s*["']([^"']+)["']/.exec(line)?.[1] ?? null;
16457
+ if (module2) {
16458
+ const [group2, artifact2] = module2.split(":");
16459
+ if (group2 && artifact2) {
16460
+ deps.push({ ecosystem: "maven", name: mavenName(group2, artifact2), version: version2, kind: "package", manifest: path2 });
16461
+ }
16462
+ continue;
16463
+ }
16464
+ const group = /\bgroup\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16465
+ const artifact = /\bname\s*=\s*["']([^"']+)["']/.exec(line)?.[1];
16466
+ if (group && artifact) {
16467
+ deps.push({ ecosystem: "maven", name: mavenName(group, artifact), version: version2, kind: "package", manifest: path2 });
16468
+ }
16469
+ }
16470
+ return deps;
16471
+ }
16472
+ function parseGemfile(path2, text) {
16473
+ const deps = [];
16474
+ for (const raw2 of text.split(/\r?\n/)) {
16475
+ const line = (raw2.split("#", 1)[0] ?? "").trim();
16476
+ const m = /^gem\s+["']([^"']+)["']\s*(?:,\s*["']([^"']+)["'])?/.exec(line);
16477
+ if (!m?.[1]) continue;
16478
+ deps.push({ ecosystem: "gem", name: m[1], version: m[2] ?? null, kind: "package", manifest: path2 });
16479
+ }
16480
+ return deps;
16481
+ }
16482
+ function parseGemspec(path2, text) {
16483
+ const deps = [];
16484
+ for (const m of text.matchAll(
16485
+ /\.add_(?:runtime_|development_)?dependency\s*\(?\s*["']([^"']+)["']\s*(?:,\s*["']([^"']+)["'])?/g
16486
+ )) {
16487
+ if (m[1]) deps.push({ ecosystem: "gem", name: m[1], version: m[2] ?? null, kind: "package", manifest: path2 });
16488
+ }
16489
+ return deps;
16490
+ }
16240
16491
  function parseManifest(path2, text) {
16241
16492
  const name2 = basename(path2);
16242
16493
  if (name2.endsWith(".csproj") || name2.endsWith(".fsproj")) return parseCsproj(path2, text);
@@ -16248,12 +16499,17 @@ function parseManifest(path2, text) {
16248
16499
  return parseDocker(path2, text);
16249
16500
  }
16250
16501
  if (name2 === "go.mod") return parseGoMod(path2, text);
16502
+ if (name2 === "libs.versions.toml") return parseVersionCatalog(path2, text);
16251
16503
  if (name2 === "Cargo.toml") return parseCargo(path2, text);
16504
+ if (name2 === "pom.xml") return parsePom(path2, text);
16505
+ if (name2 === "build.gradle" || name2 === "build.gradle.kts") return parseGradle(path2, text);
16506
+ if (name2 === "Gemfile") return parseGemfile(path2, text);
16507
+ if (name2.endsWith(".gemspec")) return parseGemspec(path2, text);
16252
16508
  return [];
16253
16509
  }
16254
- function buildSpine(sha2, manifestPaths, readText) {
16510
+ function buildSpine(sha2, manifestPaths2, readText) {
16255
16511
  const manifests = {};
16256
- for (const p of manifestPaths) {
16512
+ for (const p of manifestPaths2) {
16257
16513
  const deps = parseManifest(p, readText(p));
16258
16514
  if (deps.length > 0) manifests[p] = deps;
16259
16515
  }
@@ -16298,11 +16554,22 @@ function depsForUnit(spine, touched, readParentText) {
16298
16554
  for (const purl of declared.keys()) context.delete(purl);
16299
16555
  return { declared: [...declared.values()], context: [...context.values()] };
16300
16556
  }
16301
- var ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS;
16557
+ var ECOSYSTEM_SYSTEM, ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS, GRADLE_CONFIGS;
16302
16558
  var init_manifests = __esm({
16303
16559
  "../../packages/shared/src/manifests.ts"() {
16304
16560
  "use strict";
16305
16561
  init_identity();
16562
+ ECOSYSTEM_SYSTEM = {
16563
+ npm: "npm",
16564
+ pypi: "pypi",
16565
+ cargo: "cargo",
16566
+ go: "go",
16567
+ golang: "go",
16568
+ maven: "maven",
16569
+ nuget: "nuget",
16570
+ gem: "rubygems",
16571
+ rubygems: "rubygems"
16572
+ };
16306
16573
  ECOSYSTEM_LANGUAGE = {
16307
16574
  npm: "JavaScript",
16308
16575
  pypi: "Python",
@@ -16315,9 +16582,10 @@ var init_manifests = __esm({
16315
16582
  rubygems: "Ruby"
16316
16583
  };
16317
16584
  TOOL_KINDS = ["engine", "runtime"];
16318
- MANIFEST_PATH_RE = /(^|\/)(?:[^/]+\.csproj|[^/]+\.fsproj|project\.godot|package\.json|requirements[^/]*\.txt|pyproject\.toml|docker-compose[^/]*\.ya?ml|compose[^/]*\.ya?ml|Dockerfile(?:\.[^/]+)?|go\.mod|Cargo\.toml)$/;
16585
+ MANIFEST_PATH_RE = /(^|\/)(?:[^/]+\.csproj|[^/]+\.fsproj|project\.godot|package\.json|requirements[^/]*\.txt|pyproject\.toml|docker-compose[^/]*\.ya?ml|compose[^/]*\.ya?ml|Dockerfile(?:\.[^/]+)?|go\.mod|Cargo\.toml|pom\.xml|build\.gradle(?:\.kts)?|libs\.versions\.toml|Gemfile|[^/]+\.gemspec)$/;
16319
16586
  LOCAL_IMAGE_RE = /^(openbane|local)[/-]|:local$/;
16320
16587
  PACKAGE_JSON_SECTIONS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
16588
+ GRADLE_CONFIGS = "implementation|api|compileOnly|compileOnlyApi|runtimeOnly|testImplementation|testCompileOnly|testRuntimeOnly|annotationProcessor|kapt|ksp|classpath|developmentOnly";
16321
16589
  }
16322
16590
  });
16323
16591
 
@@ -16377,6 +16645,7 @@ __export(src_exports, {
16377
16645
  DECOMPOSITION_EDGES: () => DECOMPOSITION_EDGES,
16378
16646
  DRIFT_KIND: () => DRIFT_KIND,
16379
16647
  ECOSYSTEM_LANGUAGE: () => ECOSYSTEM_LANGUAGE,
16648
+ ECOSYSTEM_SYSTEM: () => ECOSYSTEM_SYSTEM,
16380
16649
  EDGE_CONDUCTANCE_OVERRIDES: () => EDGE_CONDUCTANCE_OVERRIDES,
16381
16650
  EDGE_RULES: () => EDGE_RULES,
16382
16651
  EDGE_WEIGHT: () => EDGE_WEIGHT,
@@ -16466,6 +16735,7 @@ __export(src_exports, {
16466
16735
  osNameForPlatform: () => osNameForPlatform,
16467
16736
  packageCanonicalId: () => packageCanonicalId,
16468
16737
  pagerankEdgeTypes: () => pagerankEdgeTypes,
16738
+ parseGemfileLock: () => parseGemfileLock,
16469
16739
  parseManifest: () => parseManifest,
16470
16740
  parsePackageLockJson: () => parsePackageLockJson,
16471
16741
  parsePackageRef: () => parsePackageRef,
@@ -51216,16 +51486,16 @@ __export(witness_ledger_exports, {
51216
51486
  summarizeWitnessLedger: () => summarizeWitnessLedger,
51217
51487
  witnessLedgerPath: () => witnessLedgerPath
51218
51488
  });
51219
- import { appendFileSync as appendFileSync3, existsSync as existsSync23, readFileSync as readFileSync23, writeFileSync as writeFileSync19 } from "node:fs";
51220
- import { join as join28 } from "node:path";
51489
+ import { appendFileSync as appendFileSync3, existsSync as existsSync24, readFileSync as readFileSync24, writeFileSync as writeFileSync19 } from "node:fs";
51490
+ import { join as join29 } from "node:path";
51221
51491
  function witnessLedgerPath(configDir) {
51222
- return join28(configDir, "witness-ledger.jsonl");
51492
+ return join29(configDir, "witness-ledger.jsonl");
51223
51493
  }
51224
51494
  function appendWitnessLedger(configDir, entry) {
51225
51495
  const path2 = witnessLedgerPath(configDir);
51226
51496
  try {
51227
51497
  appendFileSync3(path2, JSON.stringify(entry) + "\n");
51228
- const lines = readFileSync23(path2, "utf8").split("\n").filter(Boolean);
51498
+ const lines = readFileSync24(path2, "utf8").split("\n").filter(Boolean);
51229
51499
  if (lines.length > LEDGER_MAX_LINES) {
51230
51500
  writeFileSync19(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
51231
51501
  }
@@ -51234,9 +51504,9 @@ function appendWitnessLedger(configDir, entry) {
51234
51504
  }
51235
51505
  function readWitnessLedger(configDir) {
51236
51506
  const path2 = witnessLedgerPath(configDir);
51237
- if (!existsSync23(path2)) return [];
51507
+ if (!existsSync24(path2)) return [];
51238
51508
  try {
51239
- return readFileSync23(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
51509
+ return readFileSync24(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
51240
51510
  } catch {
51241
51511
  return [];
51242
51512
  }
@@ -70453,12 +70723,12 @@ var init_report_render = __esm({
70453
70723
 
70454
70724
  // src/cli.ts
70455
70725
  init_src6();
70456
- import { closeSync as closeSync2, existsSync as existsSync32, openSync as openSync2, readFileSync as readFileSync31, renameSync as renameSync4, statSync as statSync7 } from "node:fs";
70457
- import { join as join36, resolve as pathResolve } from "node:path";
70726
+ import { closeSync as closeSync2, existsSync as existsSync33, openSync as openSync2, readFileSync as readFileSync32, renameSync as renameSync4, statSync as statSync8 } from "node:fs";
70727
+ import { join as join37, resolve as pathResolve } from "node:path";
70458
70728
  import { spawn as spawn3 } from "node:child_process";
70459
70729
 
70460
70730
  // src/daemon.ts
70461
- import { existsSync as existsSync25, writeFileSync as writeFileSync21 } from "node:fs";
70731
+ import { existsSync as existsSync26, writeFileSync as writeFileSync21 } from "node:fs";
70462
70732
 
70463
70733
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
70464
70734
  import { createServer as createServerHTTP } from "http";
@@ -71037,9 +71307,9 @@ init_webui();
71037
71307
  init_config();
71038
71308
 
71039
71309
  // src/engine.ts
71040
- import { execFileSync as execFileSync3 } from "node:child_process";
71041
- import { existsSync as existsSync24, statSync as statSync6, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync24, writeFileSync as writeFileSync20 } from "node:fs";
71042
- import { join as join29, relative as relative6, sep as sep4 } from "node:path";
71310
+ import { execFileSync as execFileSync4 } from "node:child_process";
71311
+ import { existsSync as existsSync25, statSync as statSync7, appendFileSync as appendFileSync4, readdirSync as readdirSync10, renameSync as renameSync3, readFileSync as readFileSync25, writeFileSync as writeFileSync20 } from "node:fs";
71312
+ import { join as join30, relative as relative6, sep as sep4 } from "node:path";
71043
71313
 
71044
71314
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
71045
71315
  import { stat as statcb } from "fs";
@@ -75734,23 +76004,594 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
75734
76004
  return merged;
75735
76005
  }
75736
76006
 
75737
- // src/git-sensor.ts
75738
- import { existsSync as existsSync19, readFileSync as readFileSync18, watch as fsWatch } from "node:fs";
76007
+ // src/retrieval-stack.ts
76008
+ init_src();
76009
+ import { execFileSync as execFileSync3 } from "node:child_process";
76010
+ import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync6 } from "node:fs";
76011
+ import { homedir as homedir6 } from "node:os";
75739
76012
  import { join as join23 } from "node:path";
76013
+ var RETRIEVAL_STACK_CAP = 24;
76014
+ var MANIFEST_SCAN_CAP = 400;
76015
+ var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
76016
+ "node",
76017
+ "deno",
76018
+ "bun",
76019
+ "python",
76020
+ "go",
76021
+ "rust",
76022
+ "java",
76023
+ "ruby",
76024
+ "php",
76025
+ "dotnet",
76026
+ "godot"
76027
+ ]);
76028
+ var RUNTIME_KINDS = /* @__PURE__ */ new Set(["runtime", "engine"]);
76029
+ var KIND_WEIGHT = { package: 1, sdk: 0.9, image: 0.5 };
76030
+ var PUBLIC_NPM_HOSTS = /* @__PURE__ */ new Set(["registry.npmjs.org", "registry.yarnpkg.com"]);
76031
+ var PUBLIC_PYPI_HOSTS = /* @__PURE__ */ new Set(["pypi.org", "files.pythonhosted.org", "pypi.python.org"]);
76032
+ var PUBLIC_NUGET_HOSTS = /* @__PURE__ */ new Set(["api.nuget.org", "www.nuget.org", "nuget.org"]);
76033
+ var PUBLIC_GEM_HOSTS = /* @__PURE__ */ new Set(["rubygems.org", "index.rubygems.org"]);
76034
+ var PUBLIC_MAVEN_HOSTS = /* @__PURE__ */ new Set([
76035
+ "repo.maven.apache.org",
76036
+ "repo1.maven.org",
76037
+ "central.sonatype.com",
76038
+ "oss.sonatype.org",
76039
+ "dl.google.com",
76040
+ "maven.google.com",
76041
+ "plugins.gradle.org"
76042
+ ]);
76043
+ var PUBLIC_GO_HOSTS = /* @__PURE__ */ new Set([
76044
+ "github.com",
76045
+ "gitlab.com",
76046
+ "bitbucket.org",
76047
+ "golang.org",
76048
+ "google.golang.org",
76049
+ "cloud.google.com",
76050
+ "gopkg.in",
76051
+ "go.uber.org",
76052
+ "go.opentelemetry.io",
76053
+ "k8s.io",
76054
+ "sigs.k8s.io",
76055
+ "gotest.tools",
76056
+ "gonum.org",
76057
+ "modernc.org",
76058
+ "rsc.io",
76059
+ "honnef.co"
76060
+ ]);
76061
+ var PUBLIC_REGISTRY_POLICY = {
76062
+ blockedEcosystems: /* @__PURE__ */ new Set(),
76063
+ npmPrivateScopes: /* @__PURE__ */ new Set(),
76064
+ goPrivatePatterns: [],
76065
+ privateGemNames: /* @__PURE__ */ new Set(),
76066
+ selfTokens: []
76067
+ };
76068
+ function hostOf(value) {
76069
+ try {
76070
+ return new URL(value.trim()).hostname.toLowerCase();
76071
+ } catch {
76072
+ return null;
76073
+ }
76074
+ }
76075
+ function urlIsPublic(value, publicHosts) {
76076
+ const host = hostOf(value);
76077
+ return host !== null && publicHosts.has(host);
76078
+ }
76079
+ var unquote = (s) => s.trim().replace(/^['"]|['"]$/g, "");
76080
+ function parseNpmrcPolicy(texts) {
76081
+ let defaultPublic = null;
76082
+ const privateScopes = /* @__PURE__ */ new Set();
76083
+ const decidedScopes = /* @__PURE__ */ new Set();
76084
+ for (const text of texts) {
76085
+ for (const rawLine of text.split(/\r?\n/)) {
76086
+ const line = rawLine.trim();
76087
+ if (!line || line.startsWith("#") || line.startsWith(";")) continue;
76088
+ const eq = line.indexOf("=");
76089
+ if (eq === -1) continue;
76090
+ const key = line.slice(0, eq).trim().toLowerCase();
76091
+ const value = line.slice(eq + 1).trim();
76092
+ if (key === "registry") {
76093
+ if (defaultPublic === null) defaultPublic = urlIsPublic(value, PUBLIC_NPM_HOSTS);
76094
+ continue;
76095
+ }
76096
+ const scoped = /^(@[^:]+):registry$/.exec(key);
76097
+ if (!scoped) continue;
76098
+ const scope = (scoped[1] ?? "").toLowerCase();
76099
+ if (decidedScopes.has(scope)) continue;
76100
+ decidedScopes.add(scope);
76101
+ if (!urlIsPublic(value, PUBLIC_NPM_HOSTS)) privateScopes.add(scope);
76102
+ }
76103
+ }
76104
+ return { defaultPublic: defaultPublic ?? true, privateScopes };
76105
+ }
76106
+ function pypiIndexIsPrivate(texts) {
76107
+ for (const text of texts) {
76108
+ if (/^\s*\[\[?\s*tool\.(poetry\.source|uv\.index)\s*\]\]?/m.test(text)) {
76109
+ const urls = [...text.matchAll(/^\s*url\s*=\s*(.+)$/gm)].map((m) => unquote(m[1] ?? ""));
76110
+ if (urls.length === 0 || urls.some((u) => !urlIsPublic(u, PUBLIC_PYPI_HOSTS))) return true;
76111
+ }
76112
+ for (const m of text.matchAll(/^\s*(?:-i\b|--?(?:extra-)?index-url)\s*[=:]?\s*(\S+)/gm)) {
76113
+ if (!urlIsPublic(unquote(m[1] ?? ""), PUBLIC_PYPI_HOSTS)) return true;
76114
+ }
76115
+ for (const m of text.matchAll(/^\s*(?:extra-)?index-url\s*=\s*(\S+)/gm)) {
76116
+ if (!urlIsPublic(unquote(m[1] ?? ""), PUBLIC_PYPI_HOSTS)) return true;
76117
+ }
76118
+ }
76119
+ return false;
76120
+ }
76121
+ function cargoRegistryIsPrivate(texts) {
76122
+ return texts.some(
76123
+ (t) => /^\s*\[registries(\.|\])/m.test(t) || /^\s*replace-with\s*=/m.test(t)
76124
+ );
76125
+ }
76126
+ function nugetSourcesArePrivate(texts) {
76127
+ for (const text of texts) {
76128
+ const block = /<packageSources>([\s\S]*?)<\/packageSources>/i.exec(text);
76129
+ if (!block) continue;
76130
+ for (const m of (block[1] ?? "").matchAll(/<add\b[^>]*\bvalue\s*=\s*"([^"]+)"/gi)) {
76131
+ if (!urlIsPublic(m[1] ?? "", PUBLIC_NUGET_HOSTS)) return true;
76132
+ }
76133
+ }
76134
+ return false;
76135
+ }
76136
+ function parseGoPrivate(values) {
76137
+ return values.flatMap((v) => (v ?? "").split(",")).map((s) => s.trim()).filter(Boolean);
76138
+ }
76139
+ function goPrivateMatches(patterns, modulePath) {
76140
+ if (patterns.length === 0) return false;
76141
+ const parts2 = modulePath.split("/");
76142
+ const prefixes = parts2.map((_, i2) => parts2.slice(0, i2 + 1).join("/"));
76143
+ return patterns.some((pattern) => {
76144
+ const rx = new RegExp(
76145
+ "^" + pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*") + "$"
76146
+ );
76147
+ return prefixes.some((p) => rx.test(p));
76148
+ });
76149
+ }
76150
+ var OFFICIAL_DOCKER_IMAGES = /* @__PURE__ */ new Set([
76151
+ "alpine",
76152
+ "busybox",
76153
+ "debian",
76154
+ "ubuntu",
76155
+ "fedora",
76156
+ "rockylinux",
76157
+ "postgres",
76158
+ "mysql",
76159
+ "mariadb",
76160
+ "mongo",
76161
+ "redis",
76162
+ "memcached",
76163
+ "cassandra",
76164
+ "couchdb",
76165
+ "influxdb",
76166
+ "neo4j",
76167
+ "elasticsearch",
76168
+ "rabbitmq",
76169
+ "nats",
76170
+ "kafka",
76171
+ "zookeeper",
76172
+ "consul",
76173
+ "vault",
76174
+ "etcd",
76175
+ "minio",
76176
+ "clickhouse",
76177
+ "nginx",
76178
+ "httpd",
76179
+ "haproxy",
76180
+ "traefik",
76181
+ "caddy",
76182
+ "varnish",
76183
+ "node",
76184
+ "python",
76185
+ "golang",
76186
+ "rust",
76187
+ "ruby",
76188
+ "php",
76189
+ "openjdk",
76190
+ "eclipse-temurin",
76191
+ "gradle",
76192
+ "maven",
76193
+ "composer",
76194
+ "perl",
76195
+ "erlang",
76196
+ "elixir",
76197
+ "haskell",
76198
+ "docker",
76199
+ "registry",
76200
+ "grafana",
76201
+ "prometheus",
76202
+ "telegraf",
76203
+ "jenkins",
76204
+ "sonarqube",
76205
+ "wordpress",
76206
+ "drupal",
76207
+ "ghost",
76208
+ "nextcloud",
76209
+ "gitlab",
76210
+ "gitea",
76211
+ "sentry",
76212
+ "hello-world",
76213
+ "selenium",
76214
+ "playwright",
76215
+ "ollama"
76216
+ ]);
76217
+ function dockerImageIsPublicOfficial(name2) {
76218
+ const n = name2.trim().toLowerCase();
76219
+ if (!n || n.includes("/") || n.includes(":") || n.includes("@")) return false;
76220
+ return OFFICIAL_DOCKER_IMAGES.has(n);
76221
+ }
76222
+ function mavenReposArePrivate(texts) {
76223
+ for (const text of texts) {
76224
+ if (/<servers>[\s\S]*?<server>/i.test(text)) return true;
76225
+ for (const m of text.matchAll(/<(?:repository|pluginRepository|mirror)\b[\s\S]*?<\/(?:repository|pluginRepository|mirror)>/gi)) {
76226
+ const url2 = /<url>([^<]+)<\/url>/i.exec(m[0])?.[1];
76227
+ if (!url2 || !urlIsPublic(url2, PUBLIC_MAVEN_HOSTS)) return true;
76228
+ }
76229
+ }
76230
+ return false;
76231
+ }
76232
+ function gemSourceIsPrivate(texts) {
76233
+ for (const text of texts) {
76234
+ for (const m of text.matchAll(/^\s*source\s+["']([^"']+)["']/gm)) {
76235
+ if (!urlIsPublic(m[1] ?? "", PUBLIC_GEM_HOSTS)) return true;
76236
+ }
76237
+ }
76238
+ return false;
76239
+ }
76240
+ function privateGemNamesIn(texts) {
76241
+ const names = /* @__PURE__ */ new Set();
76242
+ for (const text of texts) {
76243
+ for (const raw2 of text.split(/\r?\n/)) {
76244
+ const line = (raw2.split("#", 1)[0] ?? "").trim();
76245
+ const m = /^gem\s+["']([^"']+)["']/.exec(line);
76246
+ if (!m?.[1]) continue;
76247
+ if (/(?::(?:git|path|github|gist|bitbucket)\s*=>|\b(?:git|path|github|gist|bitbucket):\s)/.test(line)) {
76248
+ names.add(m[1]);
76249
+ }
76250
+ }
76251
+ }
76252
+ return names;
76253
+ }
76254
+ function selfTokensFromLocator(repoLocator) {
76255
+ if (!repoLocator) return [];
76256
+ const segments = repoLocator.toLowerCase().split("/").slice(1).filter(Boolean);
76257
+ return [...new Set(segments.filter((s) => s.length >= 3))];
76258
+ }
76259
+ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
76260
+ if (selfTokens.length === 0) return false;
76261
+ const group = (name2.split(":")[0] ?? "").toLowerCase();
76262
+ const parts2 = group.split(".");
76263
+ return selfTokens.some((t) => parts2.includes(t));
76264
+ }
76265
+ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
76266
+ const read2 = (p) => {
76267
+ try {
76268
+ return readFileSync18(p, "utf8");
76269
+ } catch {
76270
+ return null;
76271
+ }
76272
+ };
76273
+ const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
76274
+ const home = homedir6();
76275
+ const npm = parseNpmrcPolicy(texts(join23(root, ".npmrc"), join23(home, ".npmrc")));
76276
+ const blocked = /* @__PURE__ */ new Set();
76277
+ if (!npm.defaultPublic) blocked.add("npm");
76278
+ if (pypiIndexIsPrivate(
76279
+ texts(
76280
+ join23(root, "pip.conf"),
76281
+ join23(root, "pip.ini"),
76282
+ join23(root, "pyproject.toml"),
76283
+ join23(root, "requirements.txt"),
76284
+ join23(home, ".pip", "pip.conf"),
76285
+ join23(home, ".config", "pip", "pip.conf"),
76286
+ join23(env2["APPDATA"] ?? home, "pip", "pip.ini")
76287
+ )
76288
+ )) {
76289
+ blocked.add("pypi");
76290
+ }
76291
+ if (cargoRegistryIsPrivate(
76292
+ texts(
76293
+ join23(root, ".cargo", "config.toml"),
76294
+ join23(root, ".cargo", "config"),
76295
+ join23(home, ".cargo", "config.toml"),
76296
+ join23(home, ".cargo", "config")
76297
+ )
76298
+ )) {
76299
+ blocked.add("cargo");
76300
+ }
76301
+ if (nugetSourcesArePrivate(
76302
+ texts(
76303
+ join23(root, "NuGet.config"),
76304
+ join23(root, "nuget.config"),
76305
+ join23(root, "NuGet.Config"),
76306
+ join23(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
76307
+ join23(home, ".nuget", "NuGet", "NuGet.Config")
76308
+ )
76309
+ )) {
76310
+ blocked.add("nuget");
76311
+ }
76312
+ const goEnvFile = env2["GOENV"] ?? join23(env2["APPDATA"] ?? join23(home, ".config"), "go", "env");
76313
+ const goEnvText = read2(goEnvFile) ?? "";
76314
+ const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
76315
+ (k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
76316
+ );
76317
+ const goPrivatePatterns = parseGoPrivate([
76318
+ env2["GOPRIVATE"],
76319
+ env2["GONOSUMDB"],
76320
+ env2["GONOSUMCHECK"],
76321
+ ...fromFile
76322
+ ]);
76323
+ const gemfiles = texts(join23(root, "Gemfile"));
76324
+ if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
76325
+ if (mavenReposArePrivate(
76326
+ texts(join23(root, "pom.xml"), join23(home, ".m2", "settings.xml"))
76327
+ )) {
76328
+ blocked.add("maven");
76329
+ }
76330
+ return {
76331
+ blockedEcosystems: blocked,
76332
+ npmPrivateScopes: npm.privateScopes,
76333
+ goPrivatePatterns,
76334
+ privateGemNames: privateGemNamesIn(gemfiles),
76335
+ selfTokens: selfTokensFromLocator(repoLocator)
76336
+ };
76337
+ }
76338
+ function npmScopeOf(name2) {
76339
+ if (!name2.startsWith("@")) return null;
76340
+ const slash = name2.indexOf("/");
76341
+ return slash === -1 ? null : name2.slice(0, slash).toLowerCase();
76342
+ }
76343
+ function isPublicDep(dep, policy) {
76344
+ const ecosystem = dep.ecosystem.toLowerCase();
76345
+ if (policy.blockedEcosystems.has(ecosystem)) return false;
76346
+ switch (ecosystem) {
76347
+ case "npm": {
76348
+ const scope = npmScopeOf(dep.name);
76349
+ return scope === null || !policy.npmPrivateScopes.has(scope);
76350
+ }
76351
+ case "pypi":
76352
+ case "cargo":
76353
+ return true;
76354
+ case "nuget":
76355
+ return true;
76356
+ case "maven":
76357
+ return !mavenGroupIsSelfDisclosing(dep.name, policy.selfTokens);
76358
+ case "gem":
76359
+ case "rubygems":
76360
+ return !policy.privateGemNames.has(dep.name);
76361
+ case "go":
76362
+ case "golang": {
76363
+ if (goPrivateMatches(policy.goPrivatePatterns, dep.name)) return false;
76364
+ const host = dep.name.split("/")[0]?.toLowerCase() ?? "";
76365
+ return PUBLIC_GO_HOSTS.has(host);
76366
+ }
76367
+ case "docker":
76368
+ return dockerImageIsPublicOfficial(dep.name);
76369
+ default:
76370
+ return false;
76371
+ }
76372
+ }
76373
+ function normStackToken(raw2) {
76374
+ return raw2.trim().toLowerCase().replace(/(?!^)[@\s].*$/, "");
76375
+ }
76376
+ function normStackTokens(xs) {
76377
+ return (xs ?? []).map(normStackToken).filter(Boolean);
76378
+ }
76379
+ function isRuntimeToken(token) {
76380
+ return RUNTIME_TOKENS.has(token);
76381
+ }
76382
+ function rankCandidates(cs) {
76383
+ return [...cs].sort((a, b) => b.weight - a.weight || a.name.localeCompare(b.name));
76384
+ }
76385
+ function isLocalSpec(version2) {
76386
+ if (!version2) return false;
76387
+ const v = version2.trim().toLowerCase();
76388
+ return v.startsWith("workspace:") || v.startsWith("link:") || v.startsWith("file:") || v.startsWith("portal:") || v.startsWith("path:") || v.startsWith("git:") || v.startsWith("git+") || v.includes("://");
76389
+ }
76390
+ function retrievalStackTokens(input) {
76391
+ const cap = input.cap ?? RETRIEVAL_STACK_CAP;
76392
+ const registry2 = input.registry ?? PUBLIC_REGISTRY_POLICY;
76393
+ const ignore2 = input.ignorePatterns ?? [];
76394
+ const ignored = (token) => ignore2.length > 0 && ignore2.some((p) => token.includes(p));
76395
+ const packagesAllowed = input.contributePackages;
76396
+ const tokens = [];
76397
+ const seen = /* @__PURE__ */ new Set();
76398
+ const push = (token) => {
76399
+ if (!token || seen.has(token) || ignored(token)) return false;
76400
+ seen.add(token);
76401
+ tokens.push(token);
76402
+ return true;
76403
+ };
76404
+ const manifestDeps = input.manifestDeps ?? [];
76405
+ const ecosystemLanguages = /* @__PURE__ */ new Set();
76406
+ for (const d of [...manifestDeps, ...input.direct ?? []]) {
76407
+ const lang = ECOSYSTEM_LANGUAGE[d.ecosystem.toLowerCase()];
76408
+ if (lang) ecosystemLanguages.add(normStackToken(lang));
76409
+ }
76410
+ for (const l of [...ecosystemLanguages, ...normStackTokens(input.languages)]) push(l);
76411
+ for (const t of normStackTokens(input.profileStack)) {
76412
+ if (isRuntimeToken(t)) push(t);
76413
+ }
76414
+ for (const d of manifestDeps) {
76415
+ if (RUNTIME_KINDS.has(d.kind)) push(normStackToken(d.name));
76416
+ }
76417
+ const byEcosystem = /* @__PURE__ */ new Map();
76418
+ const add = (c) => {
76419
+ const list = byEcosystem.get(c.ecosystem);
76420
+ if (list) list.push(c);
76421
+ else byEcosystem.set(c.ecosystem, [c]);
76422
+ };
76423
+ let fromLockfile = 0;
76424
+ let fromManifest = 0;
76425
+ const lockfileKeys = /* @__PURE__ */ new Set();
76426
+ const ecoKey = (ecosystem, name2) => `${ecosystem.toLowerCase()}\0${name2.toLowerCase()}`;
76427
+ if (packagesAllowed) {
76428
+ for (const d of input.direct ?? []) {
76429
+ lockfileKeys.add(ecoKey(d.ecosystem, d.name));
76430
+ if (!isPublicDep(d, registry2)) continue;
76431
+ add({ ecosystem: d.ecosystem.toLowerCase(), name: d.name, weight: d.importers });
76432
+ }
76433
+ const counted = /* @__PURE__ */ new Map();
76434
+ for (const d of manifestDeps) {
76435
+ if (RUNTIME_KINDS.has(d.kind)) continue;
76436
+ const ecosystem = d.ecosystem.toLowerCase();
76437
+ if (lockfileKeys.has(ecoKey(ecosystem, d.name))) continue;
76438
+ if (isLocalSpec(d.version)) continue;
76439
+ if (!isPublicDep({ ecosystem, name: d.name }, registry2)) continue;
76440
+ const key = ecoKey(ecosystem, d.name);
76441
+ const prev = counted.get(key);
76442
+ const w = KIND_WEIGHT[d.kind] ?? 0.5;
76443
+ if (prev) prev.weight += w;
76444
+ else counted.set(key, { ecosystem, name: d.name, weight: w });
76445
+ }
76446
+ for (const c of counted.values()) add(c);
76447
+ }
76448
+ const queues = [...byEcosystem.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([ecosystem, cs]) => ({ ecosystem, items: rankCandidates(cs) }));
76449
+ const usedEcosystems = /* @__PURE__ */ new Set();
76450
+ for (let round2 = 0; tokens.length < cap; round2++) {
76451
+ let emittedThisRound = false;
76452
+ for (const q of queues) {
76453
+ if (tokens.length >= cap) break;
76454
+ const c = q.items[round2];
76455
+ if (!c) continue;
76456
+ emittedThisRound = true;
76457
+ if (!push(normStackToken(c.name))) continue;
76458
+ usedEcosystems.add(c.ecosystem);
76459
+ if (lockfileKeys.has(ecoKey(c.ecosystem, c.name))) fromLockfile++;
76460
+ else fromManifest++;
76461
+ }
76462
+ if (!emittedThisRound) break;
76463
+ }
76464
+ if (packagesAllowed) {
76465
+ for (const t of normStackTokens(input.profileStack)) {
76466
+ if (tokens.length >= cap) break;
76467
+ if (isRuntimeToken(t)) continue;
76468
+ if (!isPublicDep({ ecosystem: "npm", name: t }, registry2)) continue;
76469
+ push(t);
76470
+ }
76471
+ }
76472
+ const source = fromLockfile > 0 && fromManifest > 0 ? "both" : fromLockfile > 0 ? "lockfile" : fromManifest > 0 ? "manifest" : "profile";
76473
+ return { tokens: tokens.slice(0, cap), source, ecosystems: [...usedEcosystems].sort() };
76474
+ }
76475
+ var LOCKFILES = [
76476
+ { file: "pnpm-lock.yaml", family: "npm", parse: parsePnpmLock },
76477
+ { file: "package-lock.json", family: "npm", parse: parsePackageLockJson },
76478
+ { file: "Gemfile.lock", family: "gem", parse: parseGemfileLock }
76479
+ ];
76480
+ var directCache = /* @__PURE__ */ new Map();
76481
+ function readDirectDependencies(root) {
76482
+ const stamps = [];
76483
+ const found = [];
76484
+ const familiesSeen = /* @__PURE__ */ new Set();
76485
+ for (const c of LOCKFILES) {
76486
+ if (familiesSeen.has(c.family)) continue;
76487
+ const p = join23(root, c.file);
76488
+ if (!existsSync19(p)) continue;
76489
+ try {
76490
+ const s = statSync6(p);
76491
+ stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
76492
+ } catch {
76493
+ continue;
76494
+ }
76495
+ familiesSeen.add(c.family);
76496
+ found.push({ c, path: p });
76497
+ }
76498
+ if (found.length === 0) {
76499
+ directCache.delete(root);
76500
+ return [];
76501
+ }
76502
+ const key = stamps.join("|");
76503
+ const hit = directCache.get(root);
76504
+ if (hit && hit.key === key) return hit.direct;
76505
+ const direct = [];
76506
+ for (const { c, path: path2 } of found) {
76507
+ try {
76508
+ direct.push(...c.parse(readFileSync18(path2, "utf8")).direct ?? []);
76509
+ } catch {
76510
+ }
76511
+ }
76512
+ directCache.set(root, { key, direct });
76513
+ return direct;
76514
+ }
76515
+ function manifestPaths(root) {
76516
+ try {
76517
+ const out2 = execFileSync3("git", ["-C", root, "ls-files", "-z"], {
76518
+ encoding: "utf8",
76519
+ maxBuffer: 128 * 1024 * 1024,
76520
+ windowsHide: true,
76521
+ stdio: ["ignore", "pipe", "ignore"]
76522
+ });
76523
+ const paths = out2.split("\0").filter((f) => f && isManifestPath(f));
76524
+ if (paths.length > 0) return paths.slice(0, MANIFEST_SCAN_CAP);
76525
+ } catch {
76526
+ }
76527
+ const ROOT_MANIFESTS = [
76528
+ "package.json",
76529
+ "pyproject.toml",
76530
+ "requirements.txt",
76531
+ "go.mod",
76532
+ "Cargo.toml",
76533
+ "pom.xml",
76534
+ "build.gradle",
76535
+ "build.gradle.kts",
76536
+ "gradle/libs.versions.toml",
76537
+ "Gemfile",
76538
+ "docker-compose.yml",
76539
+ "docker-compose.yaml",
76540
+ "compose.yaml",
76541
+ "Dockerfile",
76542
+ "project.godot"
76543
+ ];
76544
+ return ROOT_MANIFESTS.filter((f) => existsSync19(join23(root, f)));
76545
+ }
76546
+ var manifestCache = /* @__PURE__ */ new Map();
76547
+ function readManifestDependencies(root) {
76548
+ const paths = manifestPaths(root);
76549
+ if (paths.length === 0) {
76550
+ manifestCache.delete(root);
76551
+ return [];
76552
+ }
76553
+ const texts = /* @__PURE__ */ new Map();
76554
+ const stamps = [];
76555
+ for (const rel of paths) {
76556
+ const abs = join23(root, rel);
76557
+ try {
76558
+ const s = statSync6(abs);
76559
+ stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
76560
+ texts.set(rel, readFileSync18(abs, "utf8"));
76561
+ } catch {
76562
+ }
76563
+ }
76564
+ const key = stamps.join("|");
76565
+ const hit = manifestCache.get(root);
76566
+ if (hit && hit.key === key) return hit.deps;
76567
+ let deps = [];
76568
+ try {
76569
+ const spine = buildSpine("workspace", [...texts.keys()], (p) => texts.get(p) ?? "");
76570
+ deps = Object.values(spine.manifests).flat();
76571
+ } catch {
76572
+ deps = [];
76573
+ }
76574
+ manifestCache.set(root, { key, deps });
76575
+ return deps;
76576
+ }
76577
+
76578
+ // src/git-sensor.ts
76579
+ import { existsSync as existsSync20, readFileSync as readFileSync19, watch as fsWatch } from "node:fs";
76580
+ import { join as join24 } from "node:path";
75740
76581
  function readFirstLine(path2) {
75741
76582
  try {
75742
- return readFileSync18(path2, "utf8").split(/\r?\n/, 1)[0].trim();
76583
+ return readFileSync19(path2, "utf8").split(/\r?\n/, 1)[0].trim();
75743
76584
  } catch {
75744
76585
  return null;
75745
76586
  }
75746
76587
  }
75747
76588
  function readGitRefState(gitDir) {
75748
- const head2 = readFirstLine(join23(gitDir, "HEAD"));
76589
+ const head2 = readFirstLine(join24(gitDir, "HEAD"));
75749
76590
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
75750
76591
  const branch = m ? m[1] : null;
75751
76592
  let sha2 = null;
75752
76593
  if (branch) {
75753
- sha2 = readFirstLine(join23(gitDir, "refs", "heads", branch));
76594
+ sha2 = readFirstLine(join24(gitDir, "refs", "heads", branch));
75754
76595
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
75755
76596
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
75756
76597
  sha2 = head2;
@@ -75758,13 +76599,13 @@ function readGitRefState(gitDir) {
75758
76599
  return {
75759
76600
  branch,
75760
76601
  sha: sha2,
75761
- mergeHeadExists: existsSync19(join23(gitDir, "MERGE_HEAD")),
75762
- origHeadExists: existsSync19(join23(gitDir, "ORIG_HEAD"))
76602
+ mergeHeadExists: existsSync20(join24(gitDir, "MERGE_HEAD")),
76603
+ origHeadExists: existsSync20(join24(gitDir, "ORIG_HEAD"))
75763
76604
  };
75764
76605
  }
75765
76606
  function shaFromPackedRefs(gitDir, ref) {
75766
76607
  try {
75767
- for (const line of readFileSync18(join23(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
76608
+ for (const line of readFileSync19(join24(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
75768
76609
  const [sha2, name2] = line.split(/\s+/);
75769
76610
  if (name2 === ref && sha2) return sha2;
75770
76611
  }
@@ -75798,7 +76639,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
75798
76639
  const settle = () => {
75799
76640
  if (timer) clearTimeout(timer);
75800
76641
  timer = setTimeout(() => {
75801
- if (existsSync19(join23(gitDir, "index.lock"))) {
76642
+ if (existsSync20(join24(gitDir, "index.lock"))) {
75802
76643
  settle();
75803
76644
  return;
75804
76645
  }
@@ -75809,7 +76650,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
75809
76650
  }, debounceMs);
75810
76651
  };
75811
76652
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
75812
- const p = join23(gitDir, sub);
76653
+ const p = join24(gitDir, sub);
75813
76654
  try {
75814
76655
  watchers.push(fsWatch(p, settle));
75815
76656
  } catch {
@@ -76034,21 +76875,21 @@ var TelemetryRecorder = class {
76034
76875
 
76035
76876
  // src/skills.ts
76036
76877
  import {
76037
- existsSync as existsSync20,
76878
+ existsSync as existsSync21,
76038
76879
  mkdirSync as mkdirSync7,
76039
- readFileSync as readFileSync19,
76880
+ readFileSync as readFileSync20,
76040
76881
  readdirSync as readdirSync8,
76041
76882
  unlinkSync as unlinkSync2,
76042
76883
  writeFileSync as writeFileSync15
76043
76884
  } from "node:fs";
76044
- import { basename as basename6, join as join24 } from "node:path";
76885
+ import { basename as basename6, join as join25 } from "node:path";
76045
76886
  function skillFileName(id) {
76046
76887
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
76047
76888
  }
76048
76889
  function readSkillManifest(manifestPath) {
76049
- if (!existsSync20(manifestPath)) return [];
76890
+ if (!existsSync21(manifestPath)) return [];
76050
76891
  try {
76051
- const parsed = JSON.parse(readFileSync19(manifestPath, "utf8"));
76892
+ const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
76052
76893
  return (parsed.skills ?? []).map((s) => ({
76053
76894
  title: s.title ?? "",
76054
76895
  layer: s.layer ?? "technique",
@@ -76072,7 +76913,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76072
76913
  for (const s of res.skills) {
76073
76914
  const fileName = skillFileName(s.id);
76074
76915
  keep.add(fileName);
76075
- writeFileSync15(join24(paths.skillsDir, fileName), s.markdown, "utf8");
76916
+ writeFileSync15(join25(paths.skillsDir, fileName), s.markdown, "utf8");
76076
76917
  rows.push({
76077
76918
  id: s.id,
76078
76919
  title: s.title,
@@ -76085,7 +76926,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76085
76926
  const fileName = skillFileName(p.id);
76086
76927
  if (keep.has(fileName)) continue;
76087
76928
  keep.add(fileName);
76088
- writeFileSync15(join24(paths.skillsDir, fileName), p.markdown, "utf8");
76929
+ writeFileSync15(join25(paths.skillsDir, fileName), p.markdown, "utf8");
76089
76930
  rows.push({
76090
76931
  id: p.id,
76091
76932
  title: p.title,
@@ -76099,7 +76940,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76099
76940
  if (!f.endsWith(".md")) continue;
76100
76941
  if (keep.has(basename6(f))) continue;
76101
76942
  try {
76102
- unlinkSync2(join24(paths.skillsDir, f));
76943
+ unlinkSync2(join25(paths.skillsDir, f));
76103
76944
  pruned++;
76104
76945
  } catch {
76105
76946
  }
@@ -76117,22 +76958,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76117
76958
  init_src2();
76118
76959
  import {
76119
76960
  cpSync,
76120
- existsSync as existsSync21,
76961
+ existsSync as existsSync22,
76121
76962
  lstatSync,
76122
76963
  mkdirSync as mkdirSync8,
76123
- readFileSync as readFileSync20,
76964
+ readFileSync as readFileSync21,
76124
76965
  readdirSync as readdirSync9,
76125
76966
  rmSync as rmSync3,
76126
76967
  symlinkSync,
76127
76968
  writeFileSync as writeFileSync16
76128
76969
  } from "node:fs";
76129
- import { join as join25 } from "node:path";
76970
+ import { join as join26 } from "node:path";
76130
76971
  var SKILL_NS = "errata-";
76131
76972
  var HARNESS_SKILL_DIRS = [
76132
- { configDir: ".claude", skillsDir: join25(".claude", "skills") },
76973
+ { configDir: ".claude", skillsDir: join26(".claude", "skills") },
76133
76974
  // Cursor adopted the standard; its exact project dir is still moving — kept
76134
76975
  // best-effort and gated on `.cursor/` presence so we never create it blind.
76135
- { configDir: ".cursor", skillsDir: join25(".cursor", "skills") }
76976
+ { configDir: ".cursor", skillsDir: join26(".cursor", "skills") }
76136
76977
  ];
76137
76978
  function skillSlug(title, id) {
76138
76979
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -76177,12 +77018,12 @@ function skillCiteHandle(s) {
76177
77018
  return priorHandle({ id: s.id, description: s.title });
76178
77019
  }
76179
77020
  function reconcileNamespaced(dir, keep) {
76180
- if (!existsSync21(dir)) return 0;
77021
+ if (!existsSync22(dir)) return 0;
76181
77022
  let pruned = 0;
76182
77023
  for (const name2 of readdirSync9(dir)) {
76183
77024
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
76184
77025
  try {
76185
- rmSync3(join25(dir, name2), { recursive: true, force: true });
77026
+ rmSync3(join26(dir, name2), { recursive: true, force: true });
76186
77027
  pruned++;
76187
77028
  } catch {
76188
77029
  }
@@ -76191,7 +77032,7 @@ function reconcileNamespaced(dir, keep) {
76191
77032
  }
76192
77033
  function linkOrCopy(linkPath, target) {
76193
77034
  try {
76194
- if (existsSync21(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
77035
+ if (existsSync22(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
76195
77036
  } catch {
76196
77037
  }
76197
77038
  try {
@@ -76212,7 +77053,7 @@ function safeLstat(p) {
76212
77053
  }
76213
77054
  }
76214
77055
  function emitAndProjectSkills(root, skills) {
76215
- const agentsSkillsDir = join25(root, ".agents", "skills");
77056
+ const agentsSkillsDir = join26(root, ".agents", "skills");
76216
77057
  mkdirSync8(agentsSkillsDir, { recursive: true });
76217
77058
  const slugs = [];
76218
77059
  const keep = /* @__PURE__ */ new Set();
@@ -76220,7 +77061,7 @@ function emitAndProjectSkills(root, skills) {
76220
77061
  for (const s of skills) {
76221
77062
  let body2;
76222
77063
  try {
76223
- body2 = readFileSync20(s.bodyPath, "utf8");
77064
+ body2 = readFileSync21(s.bodyPath, "utf8");
76224
77065
  } catch {
76225
77066
  continue;
76226
77067
  }
@@ -76229,9 +77070,9 @@ function emitAndProjectSkills(root, skills) {
76229
77070
  keep.add(slug2);
76230
77071
  slugs.push(slug2);
76231
77072
  const description = deriveDescription(s.title, s.layer, body2);
76232
- mkdirSync8(join25(agentsSkillsDir, slug2), { recursive: true });
77073
+ mkdirSync8(join26(agentsSkillsDir, slug2), { recursive: true });
76233
77074
  writeFileSync16(
76234
- join25(agentsSkillsDir, slug2, "SKILL.md"),
77075
+ join26(agentsSkillsDir, slug2, "SKILL.md"),
76235
77076
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
76236
77077
  "utf8"
76237
77078
  );
@@ -76240,11 +77081,11 @@ function emitAndProjectSkills(root, skills) {
76240
77081
  reconcileNamespaced(agentsSkillsDir, keep);
76241
77082
  let projected = 0;
76242
77083
  for (const h of HARNESS_SKILL_DIRS) {
76243
- if (!existsSync21(join25(root, h.configDir))) continue;
76244
- const dir = join25(root, h.skillsDir);
77084
+ if (!existsSync22(join26(root, h.configDir))) continue;
77085
+ const dir = join26(root, h.skillsDir);
76245
77086
  mkdirSync8(dir, { recursive: true });
76246
77087
  for (const slug2 of slugs) {
76247
- linkOrCopy(join25(dir, slug2), join25(agentsSkillsDir, slug2));
77088
+ linkOrCopy(join26(dir, slug2), join26(agentsSkillsDir, slug2));
76248
77089
  projected++;
76249
77090
  }
76250
77091
  reconcileNamespaced(dir, keep);
@@ -76253,15 +77094,15 @@ function emitAndProjectSkills(root, skills) {
76253
77094
  return { slugs, emitted, projected };
76254
77095
  }
76255
77096
  function emitInputsFromManifest(erretaDir, manifestPath) {
76256
- if (!existsSync21(manifestPath)) return [];
77097
+ if (!existsSync22(manifestPath)) return [];
76257
77098
  try {
76258
- const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
77099
+ const parsed = JSON.parse(readFileSync21(manifestPath, "utf8"));
76259
77100
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
76260
77101
  id: s.id,
76261
77102
  title: s.title ?? s.id,
76262
77103
  layer: s.layer ?? "technique",
76263
77104
  confidence: s.confidence ?? 0,
76264
- bodyPath: join25(erretaDir, s.file)
77105
+ bodyPath: join26(erretaDir, s.file)
76265
77106
  }));
76266
77107
  } catch {
76267
77108
  return [];
@@ -76275,10 +77116,10 @@ var GITIGNORE_LINES = [
76275
77116
  ".cursor/skills/errata-*/"
76276
77117
  ];
76277
77118
  function ensureSkillGitignore(root) {
76278
- const path2 = join25(root, ".gitignore");
77119
+ const path2 = join26(root, ".gitignore");
76279
77120
  let current = "";
76280
77121
  try {
76281
- current = existsSync21(path2) ? readFileSync20(path2, "utf8") : "";
77122
+ current = existsSync22(path2) ? readFileSync21(path2, "utf8") : "";
76282
77123
  } catch {
76283
77124
  return;
76284
77125
  }
@@ -76383,9 +77224,9 @@ init_paths();
76383
77224
  init_src2();
76384
77225
  init_paths();
76385
77226
  init_git_remote();
76386
- import { existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
77227
+ import { existsSync as existsSync23, readFileSync as readFileSync22, writeFileSync as writeFileSync17 } from "node:fs";
76387
77228
  import { createHash as createHash14 } from "node:crypto";
76388
- import { join as join26 } from "node:path";
77229
+ import { join as join27 } from "node:path";
76389
77230
  function workspaceId(root) {
76390
77231
  return "wp_" + createHash14("sha256").update(root).digest("hex").slice(0, 12);
76391
77232
  }
@@ -76408,8 +77249,8 @@ function refreshRepoLocator(root, profile) {
76408
77249
  }
76409
77250
  function loadProfile(root) {
76410
77251
  const p = workspacePaths(root);
76411
- if (!existsSync22(p.workspaceJson)) return null;
76412
- return JSON.parse(readFileSync21(p.workspaceJson, "utf8"));
77252
+ if (!existsSync23(p.workspaceJson)) return null;
77253
+ return JSON.parse(readFileSync22(p.workspaceJson, "utf8"));
76413
77254
  }
76414
77255
  function saveProfile(root, profile) {
76415
77256
  const p = workspacePaths(root);
@@ -76422,14 +77263,17 @@ function autodetectProfile(root) {
76422
77263
  const p = emptyProfile(id, name2);
76423
77264
  const locator = detectRepoLocator(root);
76424
77265
  if (locator) p.repoLocator = locator;
76425
- const pkgPath = join26(root, "package.json");
76426
- if (existsSync22(pkgPath)) {
77266
+ const pkgPath = join27(root, "package.json");
77267
+ if (existsSync23(pkgPath)) {
76427
77268
  try {
76428
- const pkg = JSON.parse(readFileSync21(pkgPath, "utf8"));
76429
- p.languages.push("typescript", "javascript");
76430
- const nodeVer = pkg.engines?.node ?? "node";
76431
- p.stack.push(`node@${nodeVer}`);
77269
+ const pkg = JSON.parse(readFileSync22(pkgPath, "utf8"));
76432
77270
  const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
77271
+ p.languages.push("javascript");
77272
+ if (existsSync23(join27(root, "tsconfig.json")) || deps["typescript"]) {
77273
+ p.languages.push("typescript");
77274
+ }
77275
+ const nodeVer = pkg.engines?.node?.trim();
77276
+ p.stack.push(nodeVer ? `node@${nodeVer}` : "node");
76433
77277
  const interesting = [
76434
77278
  "next",
76435
77279
  "react",
@@ -76446,10 +77290,10 @@ function autodetectProfile(root) {
76446
77290
  } catch {
76447
77291
  }
76448
77292
  }
76449
- const pyproject = join26(root, "pyproject.toml");
76450
- if (existsSync22(pyproject)) {
77293
+ const pyproject = join27(root, "pyproject.toml");
77294
+ if (existsSync23(pyproject)) {
76451
77295
  try {
76452
- const txt = readFileSync21(pyproject, "utf8");
77296
+ const txt = readFileSync22(pyproject, "utf8");
76453
77297
  const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
76454
77298
  p.languages.push("python");
76455
77299
  p.stack.push(`python@${py ?? "3"}`);
@@ -76460,16 +77304,16 @@ function autodetectProfile(root) {
76460
77304
  } catch {
76461
77305
  }
76462
77306
  }
76463
- const reqs = join26(root, "requirements.txt");
76464
- if (existsSync22(reqs)) {
77307
+ const reqs = join27(root, "requirements.txt");
77308
+ if (existsSync23(reqs)) {
76465
77309
  if (!p.languages.includes("python")) p.languages.push("python");
76466
77310
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
76467
77311
  }
76468
- if (existsSync22(join26(root, "go.mod"))) {
77312
+ if (existsSync23(join27(root, "go.mod"))) {
76469
77313
  p.languages.push("go");
76470
77314
  p.stack.push("go");
76471
77315
  }
76472
- if (existsSync22(join26(root, "Cargo.toml"))) {
77316
+ if (existsSync23(join27(root, "Cargo.toml"))) {
76473
77317
  p.languages.push("rust");
76474
77318
  p.stack.push("rust");
76475
77319
  }
@@ -76479,18 +77323,18 @@ function autodetectProfile(root) {
76479
77323
  }
76480
77324
 
76481
77325
  // src/witness-queue.ts
76482
- import { readFileSync as readFileSync22, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
76483
- import { dirname as dirname11, join as join27 } from "node:path";
77326
+ import { readFileSync as readFileSync23, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
77327
+ import { dirname as dirname11, join as join28 } from "node:path";
76484
77328
  var WITNESS_QUEUE_CAP = 500;
76485
77329
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
76486
77330
  var WITNESS_MAX_ATTEMPTS = 5;
76487
77331
  function witnessQueuePath(workspaceConfigDir) {
76488
- return join27(workspaceConfigDir, "witness-queue.json");
77332
+ return join28(workspaceConfigDir, "witness-queue.json");
76489
77333
  }
76490
77334
  function loadWitnessQueueWithLosses(path2) {
76491
77335
  let raw2;
76492
77336
  try {
76493
- raw2 = JSON.parse(readFileSync22(path2, "utf8"));
77337
+ raw2 = JSON.parse(readFileSync23(path2, "utf8"));
76494
77338
  } catch (err2) {
76495
77339
  const absent = err2?.code === "ENOENT";
76496
77340
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -76503,7 +77347,7 @@ function loadWitnessQueueWithLosses(path2) {
76503
77347
  }
76504
77348
  function saveWitnessQueue(path2, queue) {
76505
77349
  try {
76506
- const tmp = join27(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
77350
+ const tmp = join28(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
76507
77351
  writeFileSync18(tmp, JSON.stringify(queue), "utf8");
76508
77352
  renameSync2(tmp, path2);
76509
77353
  } catch {
@@ -77077,7 +77921,7 @@ function createWatchBreaker(deps) {
77077
77921
  }
77078
77922
 
77079
77923
  // src/engine.ts
77080
- var DAEMON_VERSION = true ? "2.0.6-dev.2198" : "2.0.0-alpha.0";
77924
+ var DAEMON_VERSION = true ? "2.0.6-dev.2250" : "2.0.0-alpha.0";
77081
77925
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
77082
77926
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
77083
77927
  var GIT_OP_MUTE_MS = 4e3;
@@ -77088,7 +77932,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
77088
77932
  function appendIdentityAudit(path2, record2, line) {
77089
77933
  if (!record2.accepted && record2.score <= 0) return;
77090
77934
  try {
77091
- if (existsSync24(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
77935
+ if (existsSync25(path2) && statSync7(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
77092
77936
  renameSync3(path2, `${path2}.1`);
77093
77937
  }
77094
77938
  appendFileSync4(path2, line);
@@ -77098,7 +77942,7 @@ function appendIdentityAudit(path2, record2, line) {
77098
77942
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
77099
77943
  function loadTurnCursors(path2) {
77100
77944
  try {
77101
- const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
77945
+ const raw2 = JSON.parse(readFileSync25(path2, "utf8"));
77102
77946
  return new Map(
77103
77947
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
77104
77948
  );
@@ -77108,7 +77952,7 @@ function loadTurnCursors(path2) {
77108
77952
  }
77109
77953
  function loadTurnOffsets(path2) {
77110
77954
  try {
77111
- const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
77955
+ const raw2 = JSON.parse(readFileSync25(path2, "utf8"));
77112
77956
  const out2 = /* @__PURE__ */ new Map();
77113
77957
  for (const [k, v] of Object.entries(raw2)) {
77114
77958
  const off = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -77131,7 +77975,7 @@ function saveTurnCursors(path2, cursors, offsets) {
77131
77975
  function gitSourceWatchTargets(root) {
77132
77976
  const SOURCE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
77133
77977
  try {
77134
- const lsOut = execFileSync3("git", ["-C", root, "ls-files", "-z"], {
77978
+ const lsOut = execFileSync4("git", ["-C", root, "ls-files", "-z"], {
77135
77979
  encoding: "utf8",
77136
77980
  maxBuffer: 128 * 1024 * 1024,
77137
77981
  windowsHide: true,
@@ -77141,12 +77985,12 @@ function gitSourceWatchTargets(root) {
77141
77985
  if (sourceFiles.length === 0) throw new Error("no tracked source");
77142
77986
  let ignoredDirs = [];
77143
77987
  try {
77144
- const igOut = execFileSync3(
77988
+ const igOut = execFileSync4(
77145
77989
  "git",
77146
77990
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
77147
77991
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
77148
77992
  );
77149
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join29(root, d) + sep4));
77993
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join30(root, d) + sep4));
77150
77994
  } catch {
77151
77995
  }
77152
77996
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -77158,19 +78002,19 @@ function gitSourceWatchTargets(root) {
77158
78002
  if (!f.startsWith(prefix)) continue;
77159
78003
  const rest2 = f.slice(prefix.length);
77160
78004
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
77161
- else targets.add(join29(root, f));
78005
+ else targets.add(join30(root, f));
77162
78006
  }
77163
78007
  for (const c of children) {
77164
- if (IGNORED_PATH.test(join29(root, c) + sep4)) continue;
78008
+ if (IGNORED_PATH.test(join30(root, c) + sep4)) continue;
77165
78009
  if (hasIgnoredChild(c)) addUnder(c);
77166
- else targets.add(join29(root, c));
78010
+ else targets.add(join30(root, c));
77167
78011
  }
77168
78012
  };
77169
78013
  addUnder("");
77170
78014
  if (targets.size > 0) return [...targets];
77171
78015
  } catch {
77172
78016
  }
77173
- return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join29(root, String(e.name)) + sep4)).map((e) => join29(root, String(e.name)));
78017
+ return readdirSync10(root, { withFileTypes: true }).filter((e) => e.isDirectory() && !IGNORED_PATH.test(join30(root, String(e.name)) + sep4)).map((e) => join30(root, String(e.name)));
77174
78018
  }
77175
78019
  function createWorkspaceEngine(opts) {
77176
78020
  const paths = workspacePaths(opts.workspaceRoot);
@@ -77248,7 +78092,7 @@ function createWorkspaceEngine(opts) {
77248
78092
  }
77249
78093
  let size = 0;
77250
78094
  try {
77251
- size = statSync6(path2).size;
78095
+ size = statSync7(path2).size;
77252
78096
  } catch {
77253
78097
  }
77254
78098
  lastActivityTs = Date.now();
@@ -77363,7 +78207,7 @@ function createWorkspaceEngine(opts) {
77363
78207
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
77364
78208
  let episodeId2;
77365
78209
  if (srcPaths.length > 0) {
77366
- const abs = srcPaths.map((p) => join29(opts.workspaceRoot, p));
78210
+ const abs = srcPaths.map((p) => join30(opts.workspaceRoot, p));
77367
78211
  try {
77368
78212
  const r = await runReindexPass(
77369
78213
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -77399,8 +78243,8 @@ function createWorkspaceEngine(opts) {
77399
78243
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
77400
78244
  );
77401
78245
  };
77402
- const gitDir = join29(opts.workspaceRoot, ".git");
77403
- if (existsSync24(gitDir)) {
78246
+ const gitDir = join30(opts.workspaceRoot, ".git");
78247
+ if (existsSync25(gitDir)) {
77404
78248
  stopGit = startGitSensor(gitDir, (ev) => {
77405
78249
  void handleGitEvent(ev).catch((err2) => {
77406
78250
  console.warn("[errata] git event handler failed:", err2);
@@ -77581,10 +78425,10 @@ function createWorkspaceEngine(opts) {
77581
78425
  console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
77582
78426
  }
77583
78427
  writeContextFile(opts.workspaceRoot, body2);
77584
- const target = join29(opts.workspaceRoot, "AGENTS.md");
78428
+ const target = join30(opts.workspaceRoot, "AGENTS.md");
77585
78429
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
77586
78430
  if (elicit) {
77587
- writePrimingHandles(join29(paths.configDir, "priming-handles.json"), [
78431
+ writePrimingHandles(join30(paths.configDir, "priming-handles.json"), [
77588
78432
  ...snapshot.recentProblems.map((r) => r.node),
77589
78433
  // Resolved-band handles: the ✓ problem AND its Solution are citable
77590
78434
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -77604,7 +78448,21 @@ function createWorkspaceEngine(opts) {
77604
78448
  contextDirty = false;
77605
78449
  notifyDigest("recall");
77606
78450
  };
77607
- const normStackTokens = (xs) => (xs ?? []).map((t) => t.trim().toLowerCase().replace(/(?!^)[@\s].*$/, "")).filter(Boolean);
78451
+ const outboundStack = () => retrievalStackTokens({
78452
+ direct: readDirectDependencies(opts.workspaceRoot),
78453
+ manifestDeps: readManifestDependencies(opts.workspaceRoot),
78454
+ profileStack: profile?.stack ?? [],
78455
+ // Languages ride the stack list: the cloud's context-affinity matcher
78456
+ // resolves each token against both the Package and Language namespaces,
78457
+ // and the profile keeps them in separate fields.
78458
+ languages: profile?.languages ?? [],
78459
+ contributePackages: loadConfig().consent.contributePackages,
78460
+ // `repoLocator` feeds the Maven self-disclosure rule ONLY: a groupId
78461
+ // carrying this project's own owner/repo token is the project naming
78462
+ // itself, not a library it depends on.
78463
+ registry: loadRegistryPolicy(opts.workspaceRoot, process.env, profile?.repoLocator),
78464
+ ignorePatterns: loadClaimIgnorePatterns(opts.workspaceRoot)
78465
+ }).tokens;
77608
78466
  const maybeRefreshRemotePriors = () => {
77609
78467
  if (opts.skipContextWriter || remoteInFlight) return;
77610
78468
  const now = Date.now();
@@ -77618,10 +78476,7 @@ function createWorkspaceEngine(opts) {
77618
78476
  const norm = normStackTokens;
77619
78477
  const seed = store.findNodesByLabel("Problem").sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt).slice(0, 6).map((p) => p.id);
77620
78478
  const q = {
77621
- // Languages ride the stack list: the cloud's context-affinity matcher
77622
- // resolves each token against both the Package and Language
77623
- // namespaces, and the profile keeps them in separate fields.
77624
- stack: norm([...profile.stack ?? [], ...profile.languages ?? []]),
78479
+ stack: outboundStack(),
77625
78480
  domains: norm(profile.domains),
77626
78481
  kinds: ["Pattern", "Technique", "AntiPattern"],
77627
78482
  ...seed.length ? { seed } : {},
@@ -77665,7 +78520,7 @@ function createWorkspaceEngine(opts) {
77665
78520
  // longer concatenates these tokens into the embedding string, it
77666
78521
  // re-weights anchored hits with them (stated beats derived — the
77667
78522
  // intent text drives entry search, the stack only re-ranks).
77668
- stack: normStackTokens([...profile?.stack ?? [], ...profile?.languages ?? []]),
78523
+ stack: outboundStack(),
77669
78524
  domains: normStackTokens(profile?.domains ?? []),
77670
78525
  kinds: ["Pattern", "Technique", "AntiPattern", "Problem", "Solution"],
77671
78526
  q: liveIntent,
@@ -77885,7 +78740,7 @@ function createWorkspaceEngine(opts) {
77885
78740
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
77886
78741
  });
77887
78742
  };
77888
- const turnCursorPath = join29(paths.configDir, "turn-cursors.json");
78743
+ const turnCursorPath = join30(paths.configDir, "turn-cursors.json");
77889
78744
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
77890
78745
  const turnOffset = loadTurnOffsets(turnCursorPath);
77891
78746
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -77940,7 +78795,7 @@ function createWorkspaceEngine(opts) {
77940
78795
  let processedTurns = 0;
77941
78796
  const seqAtStart = store.currentIngestSeq();
77942
78797
  const elicit = isEdgeElicitationEnabled();
77943
- const handleMap = elicit ? readPrimingHandles(join29(paths.configDir, "priming-handles.json")) : {};
78798
+ const handleMap = elicit ? readPrimingHandles(join30(paths.configDir, "priming-handles.json")) : {};
77944
78799
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
77945
78800
  const toRel = (abs) => {
77946
78801
  const p = abs.replace(/\\/g, "/");
@@ -78232,10 +79087,10 @@ function createWorkspaceEngine(opts) {
78232
79087
  let enclosing = {};
78233
79088
  if (p.location?.line !== void 0) {
78234
79089
  try {
78235
- const headSha = readGitRefState(join29(opts.workspaceRoot, ".git")).sha ?? void 0;
79090
+ const headSha = readGitRefState(join30(opts.workspaceRoot, ".git")).sha ?? void 0;
78236
79091
  enclosing = {
78237
79092
  line: p.location.line,
78238
- fileText: readFileSync24(join29(opts.workspaceRoot, anchorPath), "utf8"),
79093
+ fileText: readFileSync25(join30(opts.workspaceRoot, anchorPath), "utf8"),
78239
79094
  ...headSha ? { headSha } : {}
78240
79095
  };
78241
79096
  } catch {
@@ -78957,7 +79812,7 @@ B: ${b}`,
78957
79812
  try {
78958
79813
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
78959
79814
  emitAndProjectSkills(opts.workspaceRoot, inputs);
78960
- writePrimingHandles(join29(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
79815
+ writePrimingHandles(join30(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
78961
79816
  } catch (err2) {
78962
79817
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
78963
79818
  }
@@ -79250,7 +80105,7 @@ B: ${b}`,
79250
80105
  console.log(
79251
80106
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
79252
80107
  );
79253
- const pending = existsSync24(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
80108
+ const pending = existsSync25(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
79254
80109
  return { uploaded: 0, failed: 0, remaining: pending };
79255
80110
  }
79256
80111
  try {
@@ -79384,7 +80239,7 @@ async function startDaemon(opts) {
79384
80239
  );
79385
80240
  await engine.stop();
79386
80241
  try {
79387
- if (existsSync25(engine.paths.daemonLock)) {
80242
+ if (existsSync26(engine.paths.daemonLock)) {
79388
80243
  }
79389
80244
  } catch {
79390
80245
  }
@@ -79406,7 +80261,7 @@ init_identity2();
79406
80261
  // src/multi.ts
79407
80262
  init_dist();
79408
80263
  init_src5();
79409
- import { existsSync as existsSync31, readFileSync as readFileSync30, unlinkSync as unlinkSync3, writeFileSync as writeFileSync23 } from "node:fs";
80264
+ import { existsSync as existsSync32, readFileSync as readFileSync31, unlinkSync as unlinkSync3, writeFileSync as writeFileSync23 } from "node:fs";
79410
80265
 
79411
80266
  // src/principle-sync.ts
79412
80267
  init_src5();
@@ -79434,8 +80289,8 @@ init_reconcile();
79434
80289
 
79435
80290
  // src/lockfile-auto.ts
79436
80291
  init_src();
79437
- import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
79438
- import { join as join30 } from "node:path";
80292
+ import { existsSync as existsSync27, readFileSync as readFileSync26 } from "node:fs";
80293
+ import { join as join31 } from "node:path";
79439
80294
 
79440
80295
  // src/package-index.ts
79441
80296
  init_src();
@@ -79584,11 +80439,11 @@ function runLockfilePass(opts) {
79584
80439
  { file: "package-lock.json", parse: parsePackageLockJson }
79585
80440
  ];
79586
80441
  for (const c of candidates) {
79587
- const p = join30(opts.root, c.file);
79588
- if (!existsSync26(p)) continue;
80442
+ const p = join31(opts.root, c.file);
80443
+ if (!existsSync27(p)) continue;
79589
80444
  let sbom;
79590
80445
  try {
79591
- sbom = c.parse(readFileSync25(p, "utf8"));
80446
+ sbom = c.parse(readFileSync26(p, "utf8"));
79592
80447
  } catch {
79593
80448
  continue;
79594
80449
  }
@@ -79645,8 +80500,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
79645
80500
  }
79646
80501
 
79647
80502
  // src/public-symbols.ts
79648
- import { readFileSync as readFileSync26, readdirSync as readdirSync11, existsSync as existsSync27 } from "node:fs";
79649
- import { join as join31 } from "node:path";
80503
+ import { readFileSync as readFileSync27, readdirSync as readdirSync11, existsSync as existsSync28 } from "node:fs";
80504
+ import { join as join32 } from "node:path";
79650
80505
  var HEAD_BYTES = 8 * 1024;
79651
80506
  var INDEX_TTL_MS = 10 * 60 * 1e3;
79652
80507
  var MIN_SYMBOL_LEN = 4;
@@ -79679,20 +80534,20 @@ function bindingNames(clause) {
79679
80534
  function internalPackageNames(workspaceRoot) {
79680
80535
  const names = /* @__PURE__ */ new Set();
79681
80536
  const tryRead = (dir) => {
79682
- const pj = join31(dir, "package.json");
79683
- if (!existsSync27(pj)) return;
80537
+ const pj = join32(dir, "package.json");
80538
+ if (!existsSync28(pj)) return;
79684
80539
  try {
79685
- const name2 = JSON.parse(readFileSync26(pj, "utf8")).name;
80540
+ const name2 = JSON.parse(readFileSync27(pj, "utf8")).name;
79686
80541
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
79687
80542
  } catch {
79688
80543
  }
79689
80544
  };
79690
80545
  tryRead(workspaceRoot);
79691
80546
  for (const group of ["packages", "apps"]) {
79692
- const groupDir = join31(workspaceRoot, group);
79693
- if (!existsSync27(groupDir)) continue;
80547
+ const groupDir = join32(workspaceRoot, group);
80548
+ if (!existsSync28(groupDir)) continue;
79694
80549
  try {
79695
- for (const entry of readdirSync11(groupDir)) tryRead(join31(groupDir, entry));
80550
+ for (const entry of readdirSync11(groupDir)) tryRead(join32(groupDir, entry));
79696
80551
  } catch {
79697
80552
  }
79698
80553
  }
@@ -79705,7 +80560,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
79705
80560
  if (cached2 && now - cached2.builtAt < INDEX_TTL_MS) return cached2;
79706
80561
  const readHead = deps.readHead ?? ((absPath) => {
79707
80562
  try {
79708
- return readFileSync26(absPath, "utf8").slice(0, HEAD_BYTES);
80563
+ return readFileSync27(absPath, "utf8").slice(0, HEAD_BYTES);
79709
80564
  } catch {
79710
80565
  return "";
79711
80566
  }
@@ -79725,7 +80580,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
79725
80580
  }
79726
80581
  const symbols = /* @__PURE__ */ new Set();
79727
80582
  for (const rel of files) {
79728
- const head2 = readHead(join31(workspaceRoot, rel));
80583
+ const head2 = readHead(join32(workspaceRoot, rel));
79729
80584
  if (!head2) continue;
79730
80585
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
79731
80586
  re.lastIndex = 0;
@@ -80356,7 +81211,7 @@ var ConsolidateWorker = class {
80356
81211
  init_paths();
80357
81212
 
80358
81213
  // src/lock.ts
80359
- import { existsSync as existsSync28, readFileSync as readFileSync27 } from "node:fs";
81214
+ import { existsSync as existsSync29, readFileSync as readFileSync28 } from "node:fs";
80360
81215
  function isProcessAlive(pid) {
80361
81216
  if (!pid || pid <= 0) return false;
80362
81217
  try {
@@ -80367,9 +81222,9 @@ function isProcessAlive(pid) {
80367
81222
  }
80368
81223
  }
80369
81224
  function readDaemonLock(lockPath) {
80370
- if (!existsSync28(lockPath)) return null;
81225
+ if (!existsSync29(lockPath)) return null;
80371
81226
  try {
80372
- const lock = JSON.parse(readFileSync27(lockPath, "utf8"));
81227
+ const lock = JSON.parse(readFileSync28(lockPath, "utf8"));
80373
81228
  return typeof lock.pid === "number" ? lock : null;
80374
81229
  } catch {
80375
81230
  return null;
@@ -80841,8 +81696,8 @@ async function hydrateProject(opts) {
80841
81696
  init_src7();
80842
81697
  init_src();
80843
81698
  import { execFile as execFile3 } from "node:child_process";
80844
- import { readFileSync as readFileSync29 } from "node:fs";
80845
- import { join as join33 } from "node:path";
81699
+ import { readFileSync as readFileSync30 } from "node:fs";
81700
+ import { join as join34 } from "node:path";
80846
81701
  import { promisify } from "node:util";
80847
81702
 
80848
81703
  // src/history-walk.ts
@@ -81064,8 +81919,8 @@ function narrative(unit, group) {
81064
81919
 
81065
81920
  // src/history-bundle.ts
81066
81921
  import { execFile as execFile2 } from "node:child_process";
81067
- import { readFileSync as readFileSync28 } from "node:fs";
81068
- import { join as join32 } from "node:path";
81922
+ import { readFileSync as readFileSync29 } from "node:fs";
81923
+ import { join as join33 } from "node:path";
81069
81924
 
81070
81925
  // ../../packages/privacy/src/patterns/credentials.ts
81071
81926
  var CREDENTIAL_PATTERNS = [
@@ -81847,7 +82702,7 @@ function pathAllowedByFloor(path2) {
81847
82702
  function loadRepoIgnore(root, extraPatterns = []) {
81848
82703
  let source = "";
81849
82704
  try {
81850
- source = readFileSync28(join32(root, ".errataignore"), "utf8");
82705
+ source = readFileSync29(join33(root, ".errataignore"), "utf8");
81851
82706
  } catch {
81852
82707
  source = "";
81853
82708
  }
@@ -82261,17 +83116,17 @@ async function defaultGit(root, args2) {
82261
83116
  function readIgnoreLines(root, profile) {
82262
83117
  let lines = [];
82263
83118
  try {
82264
- lines = readFileSync29(join33(root, ".errataignore"), "utf8").split("\n");
83119
+ lines = readFileSync30(join34(root, ".errataignore"), "utf8").split("\n");
82265
83120
  } catch {
82266
83121
  }
82267
83122
  return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
82268
83123
  }
82269
83124
  async function spineForUnit(git3, root, unit) {
82270
83125
  const listing = await git3(root, ["ls-tree", "-r", "--name-only", unit.sha]);
82271
- const manifestPaths = listing.split("\n").map((l) => l.trim()).filter((p) => p && isManifestPath(p));
82272
- if (manifestPaths.length === 0) return void 0;
83126
+ const manifestPaths2 = listing.split("\n").map((l) => l.trim()).filter((p) => p && isManifestPath(p));
83127
+ if (manifestPaths2.length === 0) return void 0;
82273
83128
  const texts = /* @__PURE__ */ new Map();
82274
- for (const p of manifestPaths) {
83129
+ for (const p of manifestPaths2) {
82275
83130
  try {
82276
83131
  texts.set(p, await git3(root, ["show", `${unit.sha}:${p}`]));
82277
83132
  } catch {
@@ -82589,9 +83444,9 @@ async function startHistoryStage(root, input, client, walk10 = {}) {
82589
83444
  // src/link-flow.ts
82590
83445
  init_cloud_auth();
82591
83446
  import { createHash as createHash15 } from "node:crypto";
82592
- import { execFileSync as execFileSync4 } from "node:child_process";
82593
- import { existsSync as existsSync29, writeFileSync as writeFileSync22 } from "node:fs";
82594
- import { join as join34 } from "node:path";
83447
+ import { execFileSync as execFileSync5 } from "node:child_process";
83448
+ import { existsSync as existsSync30, writeFileSync as writeFileSync22 } from "node:fs";
83449
+ import { join as join35 } from "node:path";
82595
83450
 
82596
83451
  // src/device-poll.ts
82597
83452
  var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
@@ -82953,7 +83808,7 @@ async function linkThroughConsole(opts) {
82953
83808
  function collectRepoFacts(root) {
82954
83809
  const git3 = (args2) => {
82955
83810
  try {
82956
- return execFileSync4("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
83811
+ return execFileSync5("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
82957
83812
  } catch {
82958
83813
  return null;
82959
83814
  }
@@ -83024,8 +83879,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
83024
83879
  delete nextProfile.projectLinkDisabled;
83025
83880
  let wroteIgnore = false;
83026
83881
  if (decision.writeIgnoreStarter !== false) {
83027
- const target = join34(root, ".errataignore");
83028
- if (!existsSync29(target)) {
83882
+ const target = join35(root, ".errataignore");
83883
+ if (!existsSync30(target)) {
83029
83884
  writeFileSync22(target, IGNORE_STARTER, "utf8");
83030
83885
  wroteIgnore = true;
83031
83886
  }
@@ -83038,12 +83893,12 @@ init_registry();
83038
83893
 
83039
83894
  // src/adopt.ts
83040
83895
  init_git_remote();
83041
- import { existsSync as existsSync30 } from "node:fs";
83042
- import { dirname as dirname12, join as join35 } from "node:path";
83896
+ import { existsSync as existsSync31 } from "node:fs";
83897
+ import { dirname as dirname12, join as join36 } from "node:path";
83043
83898
  function findGitRoot(absPath) {
83044
83899
  let dir = absPath;
83045
83900
  for (let depth = 0; depth < 64; depth++) {
83046
- if (existsSync30(join35(dir, ".git"))) return dir;
83901
+ if (existsSync31(join36(dir, ".git"))) return dir;
83047
83902
  const parent = dirname12(dir);
83048
83903
  if (parent === dir) return null;
83049
83904
  dir = parent;
@@ -83869,7 +84724,7 @@ async function startMultiDaemon(opts = {}) {
83869
84724
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
83870
84725
  } catch {
83871
84726
  }
83872
- const reason = retireDecision({ exists: existsSync31(rec.root), lastActiveAt, now });
84727
+ const reason = retireDecision({ exists: existsSync32(rec.root), lastActiveAt, now });
83873
84728
  if (reason) void retireWorkspace(rec, reason);
83874
84729
  }
83875
84730
  };
@@ -84756,7 +85611,7 @@ async function startMultiDaemon(opts = {}) {
84756
85611
  clearInterval(anchorPull);
84757
85612
  clearTimeout(codexWakeBoot);
84758
85613
  try {
84759
- const cur = readFileSync30(lockPath, "utf8");
85614
+ const cur = readFileSync31(lockPath, "utf8");
84760
85615
  if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
84761
85616
  } catch {
84762
85617
  }
@@ -85792,21 +86647,21 @@ async function cmdInit() {
85792
86647
  if (!skipHooks) {
85793
86648
  console.log("");
85794
86649
  console.log("installing harness hooks...");
85795
- const { existsSync: existsSync33 } = await import("node:fs");
85796
- const { join: join37 } = await import("node:path");
86650
+ const { existsSync: existsSync34 } = await import("node:fs");
86651
+ const { join: join38 } = await import("node:path");
85797
86652
  try {
85798
86653
  await installClaudeHooks(port);
85799
86654
  } catch (err2) {
85800
86655
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
85801
86656
  }
85802
- if (existsSync33(join37(ROOT, ".cursor"))) {
86657
+ if (existsSync34(join38(ROOT, ".cursor"))) {
85803
86658
  try {
85804
86659
  await installCursorMcpConfig();
85805
86660
  } catch (err2) {
85806
86661
  console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
85807
86662
  }
85808
86663
  }
85809
- if (existsSync33(join37(ROOT, ".codex"))) {
86664
+ if (existsSync34(join38(ROOT, ".codex"))) {
85810
86665
  try {
85811
86666
  await installCodexHooks(port);
85812
86667
  } catch (err2) {
@@ -85983,9 +86838,9 @@ async function cmdStatus() {
85983
86838
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
85984
86839
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
85985
86840
  }
85986
- console.log(` graph db: ${existsSync32(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
85987
- console.log(` event log: ${existsSync32(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
85988
- if (existsSync32(paths.castalia)) {
86841
+ console.log(` graph db: ${existsSync33(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
86842
+ console.log(` event log: ${existsSync33(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
86843
+ if (existsSync33(paths.castalia)) {
85989
86844
  try {
85990
86845
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
85991
86846
  const store = openGraphStore2({ path: paths.castalia });
@@ -86879,11 +87734,11 @@ function cmdInstallationProfile(args2) {
86879
87734
  }
86880
87735
  async function cmdReview() {
86881
87736
  const paths = workspacePaths(ROOT);
86882
- if (!existsSync32(paths.reviewQueue)) {
87737
+ if (!existsSync33(paths.reviewQueue)) {
86883
87738
  console.log("(review queue empty)");
86884
87739
  return;
86885
87740
  }
86886
- const queue = JSON.parse(readFileSync31(paths.reviewQueue, "utf8"));
87741
+ const queue = JSON.parse(readFileSync32(paths.reviewQueue, "utf8"));
86887
87742
  if (queue.length === 0) {
86888
87743
  console.log("(review queue empty)");
86889
87744
  return;
@@ -87554,7 +88409,7 @@ async function gatherRepo(store, ws) {
87554
88409
  };
87555
88410
  }
87556
88411
  async function gatherReportData(generatedAt) {
87557
- const { existsSync: existsSync33 } = await import("node:fs");
88412
+ const { existsSync: existsSync34 } = await import("node:fs");
87558
88413
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
87559
88414
  const cfg = loadConfig();
87560
88415
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -87562,7 +88417,7 @@ async function gatherReportData(generatedAt) {
87562
88417
  for (const ws of listWorkspaces()) {
87563
88418
  if (ws.missing) continue;
87564
88419
  const dbPath = workspacePaths(ws.path).castalia;
87565
- if (!existsSync33(dbPath)) continue;
88420
+ if (!existsSync34(dbPath)) continue;
87566
88421
  let store = null;
87567
88422
  try {
87568
88423
  store = openGraphStore2({ path: dbPath });
@@ -87606,8 +88461,8 @@ async function cmdReport(args2) {
87606
88461
  const outDir = workspacePaths(ROOT).configDir;
87607
88462
  mkdirSync9(outDir, { recursive: true });
87608
88463
  const files = renderReport2(data, { includeFutureVerbs });
87609
- for (const f of files) writeFileSync24(join36(outDir, f.name), f.html, "utf8");
87610
- const indexPath = join36(outDir, "report.html");
88464
+ for (const f of files) writeFileSync24(join37(outDir, f.name), f.html, "utf8");
88465
+ const indexPath = join37(outDir, "report.html");
87611
88466
  console.log(`report \u2192 ${indexPath}`);
87612
88467
  console.log(
87613
88468
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -87662,7 +88517,7 @@ function spawnDaemonDetached(options = {}) {
87662
88517
  try {
87663
88518
  const logPath = daemonLogPath();
87664
88519
  try {
87665
- if (statSync7(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
88520
+ if (statSync8(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
87666
88521
  } catch {
87667
88522
  }
87668
88523
  out2 = openSync2(logPath, "a");
@@ -87727,24 +88582,24 @@ async function cmdInstallHooks(args2) {
87727
88582
  }
87728
88583
  }
87729
88584
  async function installOpencodePlugin(port) {
87730
- const { mkdirSync: mkdirSync9, existsSync: existsSync33, readFileSync: readFileSync32, writeFileSync: writeFileSync24 } = await import("node:fs");
87731
- const { join: join37 } = await import("node:path");
87732
- const dir = join37(ROOT, ".opencode", "plugin");
87733
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
87734
- const file2 = join37(dir, "inerrata.js");
87735
- if (existsSync33(file2)) {
87736
- const head2 = readFileSync32(file2, "utf8").split("\n")[0] ?? "";
88585
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88586
+ const { join: join38 } = await import("node:path");
88587
+ const dir = join38(ROOT, ".opencode", "plugin");
88588
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88589
+ const file2 = join38(dir, "inerrata.js");
88590
+ if (existsSync34(file2)) {
88591
+ const head2 = readFileSync33(file2, "utf8").split("\n")[0] ?? "";
87737
88592
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
87738
88593
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
87739
88594
  process.exit(2);
87740
88595
  }
87741
88596
  }
87742
88597
  writeFileSync24(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
87743
- const cfgFile = join37(ROOT, "opencode.json");
88598
+ const cfgFile = join38(ROOT, "opencode.json");
87744
88599
  let cfg = { $schema: "https://opencode.ai/config.json" };
87745
- if (existsSync33(cfgFile)) {
88600
+ if (existsSync34(cfgFile)) {
87746
88601
  try {
87747
- cfg = JSON.parse(readFileSync32(cfgFile, "utf8"));
88602
+ cfg = JSON.parse(readFileSync33(cfgFile, "utf8"));
87748
88603
  } catch {
87749
88604
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
87750
88605
  process.exit(2);
@@ -87775,15 +88630,15 @@ function errataMcpInvocation() {
87775
88630
  return { command: cmd2, args: args2 };
87776
88631
  }
87777
88632
  async function installClaudeHooks(port) {
87778
- const { mkdirSync: mkdirSync9, existsSync: existsSync33, readFileSync: readFileSync32, writeFileSync: writeFileSync24 } = await import("node:fs");
87779
- const { join: join37 } = await import("node:path");
87780
- const dir = join37(ROOT, ".claude");
87781
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
87782
- const file2 = join37(dir, "settings.json");
88633
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88634
+ const { join: join38 } = await import("node:path");
88635
+ const dir = join38(ROOT, ".claude");
88636
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88637
+ const file2 = join38(dir, "settings.json");
87783
88638
  let settings = {};
87784
- if (existsSync33(file2)) {
88639
+ if (existsSync34(file2)) {
87785
88640
  try {
87786
- settings = JSON.parse(readFileSync32(file2, "utf8"));
88641
+ settings = JSON.parse(readFileSync33(file2, "utf8"));
87787
88642
  } catch {
87788
88643
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87789
88644
  process.exit(2);
@@ -87832,7 +88687,7 @@ async function installClaudeHooks(port) {
87832
88687
  writeFileSync24(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
87833
88688
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
87834
88689
  await installClaudeMcpConfig();
87835
- const claudeMd = join37(ROOT, "CLAUDE.md");
88690
+ const claudeMd = join38(ROOT, "CLAUDE.md");
87836
88691
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
87837
88692
  if (recall.kind === "collision") {
87838
88693
  console.warn(
@@ -87844,15 +88699,15 @@ async function installClaudeHooks(port) {
87844
88699
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
87845
88700
  }
87846
88701
  async function installClaudeMcpConfig() {
87847
- const { mkdirSync: mkdirSync9, existsSync: existsSync33, readFileSync: readFileSync32, writeFileSync: writeFileSync24 } = await import("node:fs");
87848
- const { join: join37, dirname: dirname13 } = await import("node:path");
87849
- const file2 = join37(ROOT, ".mcp.json");
88702
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88703
+ const { join: join38, dirname: dirname13 } = await import("node:path");
88704
+ const file2 = join38(ROOT, ".mcp.json");
87850
88705
  const dir = dirname13(file2);
87851
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
88706
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
87852
88707
  let cfg = {};
87853
- if (existsSync33(file2)) {
88708
+ if (existsSync34(file2)) {
87854
88709
  try {
87855
- cfg = JSON.parse(readFileSync32(file2, "utf8"));
88710
+ cfg = JSON.parse(readFileSync33(file2, "utf8"));
87856
88711
  } catch {
87857
88712
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87858
88713
  process.exit(2);
@@ -87866,15 +88721,15 @@ async function installClaudeMcpConfig() {
87866
88721
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
87867
88722
  }
87868
88723
  async function installCursorMcpConfig() {
87869
- const { mkdirSync: mkdirSync9, existsSync: existsSync33, readFileSync: readFileSync32, writeFileSync: writeFileSync24 } = await import("node:fs");
87870
- const { join: join37 } = await import("node:path");
87871
- const dir = join37(ROOT, ".cursor");
87872
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
87873
- const file2 = join37(dir, "mcp.json");
88724
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88725
+ const { join: join38 } = await import("node:path");
88726
+ const dir = join38(ROOT, ".cursor");
88727
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88728
+ const file2 = join38(dir, "mcp.json");
87874
88729
  let cfg = {};
87875
- if (existsSync33(file2)) {
88730
+ if (existsSync34(file2)) {
87876
88731
  try {
87877
- cfg = JSON.parse(readFileSync32(file2, "utf8"));
88732
+ cfg = JSON.parse(readFileSync33(file2, "utf8"));
87878
88733
  } catch {
87879
88734
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87880
88735
  process.exit(2);
@@ -87890,14 +88745,14 @@ async function installCursorMcpConfig() {
87890
88745
  console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
87891
88746
  }
87892
88747
  async function installCodexHooks(port) {
87893
- const { mkdirSync: mkdirSync9, existsSync: existsSync33, readFileSync: readFileSync32, writeFileSync: writeFileSync24 } = await import("node:fs");
87894
- const { join: join37 } = await import("node:path");
87895
- const dir = join37(ROOT, ".codex");
87896
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
87897
- const file2 = join37(dir, "config.toml");
88748
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88749
+ const { join: join38 } = await import("node:path");
88750
+ const dir = join38(ROOT, ".codex");
88751
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88752
+ const file2 = join38(dir, "config.toml");
87898
88753
  let existing = "";
87899
- if (existsSync33(file2)) {
87900
- existing = readFileSync32(file2, "utf8");
88754
+ if (existsSync34(file2)) {
88755
+ existing = readFileSync33(file2, "utf8");
87901
88756
  const beginIdx = existing.indexOf(CODEX_HOOKS_BEGIN);
87902
88757
  const endIdx = existing.indexOf(CODEX_HOOKS_END);
87903
88758
  if (beginIdx >= 0 && endIdx > beginIdx) {
@@ -88252,7 +89107,7 @@ async function cmdDash(args2) {
88252
89107
  await yieldToLoop2();
88253
89108
  try {
88254
89109
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile);
88255
- const res = bleedRules(join36(r.root, ".claude", "rules"), items);
89110
+ const res = bleedRules(join37(r.root, ".claude", "rules"), items);
88256
89111
  if (res.written || res.pruned) {
88257
89112
  console.log(
88258
89113
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")