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

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 +1180 -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,146 @@ 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
+ }
16491
+ function tomlTable(text, header) {
16492
+ const escaped = header.replace(/[.[\]]/g, "\\$&");
16493
+ return new RegExp(`^\\s*\\[${escaped}\\]([\\s\\S]*?)(?=^\\s*\\[|(?![\\s\\S]))`, "m").exec(text)?.[1] ?? null;
16494
+ }
16495
+ function tomlName(table) {
16496
+ return table && /^\s*name\s*=\s*["']([^"']+)["']/m.exec(table)?.[1]?.trim() || null;
16497
+ }
16498
+ function pomSelf(text) {
16499
+ const parentGroup = /<groupId>([^<]+)<\/groupId>/.exec(/<parent>([\s\S]*?)<\/parent>/.exec(text)?.[1] ?? "")?.[1];
16500
+ const own = text.replace(POM_FOREIGN_BLOCKS, "");
16501
+ const group = (/<groupId>([^<]+)<\/groupId>/.exec(own)?.[1] ?? parentGroup)?.trim();
16502
+ const artifact = /<artifactId>([^<]+)<\/artifactId>/.exec(own)?.[1]?.trim();
16503
+ if (!group) return [];
16504
+ const self = [{ ecosystem: "maven", kind: "namespace", value: group }];
16505
+ if (artifact) self.push({ ecosystem: "maven", kind: "name", value: mavenName(group, artifact) });
16506
+ return self;
16507
+ }
16508
+ function parseManifestSelf(path2, text) {
16509
+ const file2 = basename(path2);
16510
+ if (file2 === "package.json") {
16511
+ let obj;
16512
+ try {
16513
+ obj = JSON.parse(text);
16514
+ } catch {
16515
+ return [];
16516
+ }
16517
+ const name2 = obj && typeof obj === "object" ? obj["name"] : null;
16518
+ if (typeof name2 !== "string" || !name2.trim()) return [];
16519
+ const self = [{ ecosystem: "npm", kind: "name", value: name2.trim() }];
16520
+ const scope = /^(@[^/]+)\//.exec(name2.trim())?.[1];
16521
+ if (scope) self.push({ ecosystem: "npm", kind: "namespace", value: scope });
16522
+ return self;
16523
+ }
16524
+ if (file2 === "pom.xml") return pomSelf(text);
16525
+ if (file2 === "build.gradle" || file2 === "build.gradle.kts") {
16526
+ const group = /^\s*group\s*(?:=\s*)?["']([^"']+)["']/m.exec(text)?.[1]?.trim();
16527
+ return group ? [{ ecosystem: "maven", kind: "namespace", value: group }] : [];
16528
+ }
16529
+ if (file2 === "Cargo.toml") {
16530
+ const name2 = tomlName(tomlTable(text, "package"));
16531
+ return name2 ? [{ ecosystem: "cargo", kind: "name", value: name2 }] : [];
16532
+ }
16533
+ if (file2 === "pyproject.toml") {
16534
+ const name2 = tomlName(tomlTable(text, "project")) ?? tomlName(tomlTable(text, "tool.poetry"));
16535
+ return name2 ? [{ ecosystem: "pypi", kind: "name", value: name2 }] : [];
16536
+ }
16537
+ if (file2 === "go.mod") {
16538
+ const module2 = /^\s*module\s+(\S+)/m.exec(text)?.[1];
16539
+ return module2 ? [{ ecosystem: "golang", kind: "namespace", value: module2 }] : [];
16540
+ }
16541
+ if (file2.endsWith(".gemspec")) {
16542
+ const name2 = /\.name\s*=\s*["']([^"']+)["']/.exec(text)?.[1]?.trim();
16543
+ return name2 ? [{ ecosystem: "gem", kind: "name", value: name2 }] : [];
16544
+ }
16545
+ if (file2.endsWith(".csproj") || file2.endsWith(".fsproj")) {
16546
+ const id = /<PackageId>([^<]+)<\/PackageId>/.exec(text)?.[1]?.trim() ?? file2.replace(/\.(cs|fs)proj$/, "");
16547
+ return id ? [{ ecosystem: "nuget", kind: "name", value: id }] : [];
16548
+ }
16549
+ return [];
16550
+ }
16240
16551
  function parseManifest(path2, text) {
16241
16552
  const name2 = basename(path2);
16242
16553
  if (name2.endsWith(".csproj") || name2.endsWith(".fsproj")) return parseCsproj(path2, text);
@@ -16248,12 +16559,17 @@ function parseManifest(path2, text) {
16248
16559
  return parseDocker(path2, text);
16249
16560
  }
16250
16561
  if (name2 === "go.mod") return parseGoMod(path2, text);
16562
+ if (name2 === "libs.versions.toml") return parseVersionCatalog(path2, text);
16251
16563
  if (name2 === "Cargo.toml") return parseCargo(path2, text);
16564
+ if (name2 === "pom.xml") return parsePom(path2, text);
16565
+ if (name2 === "build.gradle" || name2 === "build.gradle.kts") return parseGradle(path2, text);
16566
+ if (name2 === "Gemfile") return parseGemfile(path2, text);
16567
+ if (name2.endsWith(".gemspec")) return parseGemspec(path2, text);
16252
16568
  return [];
16253
16569
  }
16254
- function buildSpine(sha2, manifestPaths, readText) {
16570
+ function buildSpine(sha2, manifestPaths2, readText) {
16255
16571
  const manifests = {};
16256
- for (const p of manifestPaths) {
16572
+ for (const p of manifestPaths2) {
16257
16573
  const deps = parseManifest(p, readText(p));
16258
16574
  if (deps.length > 0) manifests[p] = deps;
16259
16575
  }
@@ -16298,11 +16614,22 @@ function depsForUnit(spine, touched, readParentText) {
16298
16614
  for (const purl of declared.keys()) context.delete(purl);
16299
16615
  return { declared: [...declared.values()], context: [...context.values()] };
16300
16616
  }
16301
- var ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS;
16617
+ var ECOSYSTEM_SYSTEM, ECOSYSTEM_LANGUAGE, TOOL_KINDS, MANIFEST_PATH_RE, LOCAL_IMAGE_RE, PACKAGE_JSON_SECTIONS, GRADLE_CONFIGS, POM_FOREIGN_BLOCKS;
16302
16618
  var init_manifests = __esm({
16303
16619
  "../../packages/shared/src/manifests.ts"() {
16304
16620
  "use strict";
16305
16621
  init_identity();
16622
+ ECOSYSTEM_SYSTEM = {
16623
+ npm: "npm",
16624
+ pypi: "pypi",
16625
+ cargo: "cargo",
16626
+ go: "go",
16627
+ golang: "go",
16628
+ maven: "maven",
16629
+ nuget: "nuget",
16630
+ gem: "rubygems",
16631
+ rubygems: "rubygems"
16632
+ };
16306
16633
  ECOSYSTEM_LANGUAGE = {
16307
16634
  npm: "JavaScript",
16308
16635
  pypi: "Python",
@@ -16315,9 +16642,11 @@ var init_manifests = __esm({
16315
16642
  rubygems: "Ruby"
16316
16643
  };
16317
16644
  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)$/;
16645
+ 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
16646
  LOCAL_IMAGE_RE = /^(openbane|local)[/-]|:local$/;
16320
16647
  PACKAGE_JSON_SECTIONS = ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
16648
+ GRADLE_CONFIGS = "implementation|api|compileOnly|compileOnlyApi|runtimeOnly|testImplementation|testCompileOnly|testRuntimeOnly|annotationProcessor|kapt|ksp|classpath|developmentOnly";
16649
+ POM_FOREIGN_BLOCKS = /<(parent|dependencies|dependencyManagement|build|profiles|reporting|distributionManagement|modules)>[\s\S]*?<\/\1>/g;
16321
16650
  }
16322
16651
  });
16323
16652
 
@@ -16377,6 +16706,7 @@ __export(src_exports, {
16377
16706
  DECOMPOSITION_EDGES: () => DECOMPOSITION_EDGES,
16378
16707
  DRIFT_KIND: () => DRIFT_KIND,
16379
16708
  ECOSYSTEM_LANGUAGE: () => ECOSYSTEM_LANGUAGE,
16709
+ ECOSYSTEM_SYSTEM: () => ECOSYSTEM_SYSTEM,
16380
16710
  EDGE_CONDUCTANCE_OVERRIDES: () => EDGE_CONDUCTANCE_OVERRIDES,
16381
16711
  EDGE_RULES: () => EDGE_RULES,
16382
16712
  EDGE_WEIGHT: () => EDGE_WEIGHT,
@@ -16466,7 +16796,9 @@ __export(src_exports, {
16466
16796
  osNameForPlatform: () => osNameForPlatform,
16467
16797
  packageCanonicalId: () => packageCanonicalId,
16468
16798
  pagerankEdgeTypes: () => pagerankEdgeTypes,
16799
+ parseGemfileLock: () => parseGemfileLock,
16469
16800
  parseManifest: () => parseManifest,
16801
+ parseManifestSelf: () => parseManifestSelf,
16470
16802
  parsePackageLockJson: () => parsePackageLockJson,
16471
16803
  parsePackageRef: () => parsePackageRef,
16472
16804
  parsePnpmLock: () => parsePnpmLock,
@@ -51216,16 +51548,16 @@ __export(witness_ledger_exports, {
51216
51548
  summarizeWitnessLedger: () => summarizeWitnessLedger,
51217
51549
  witnessLedgerPath: () => witnessLedgerPath
51218
51550
  });
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";
51551
+ import { appendFileSync as appendFileSync3, existsSync as existsSync24, readFileSync as readFileSync24, writeFileSync as writeFileSync19 } from "node:fs";
51552
+ import { join as join29 } from "node:path";
51221
51553
  function witnessLedgerPath(configDir) {
51222
- return join28(configDir, "witness-ledger.jsonl");
51554
+ return join29(configDir, "witness-ledger.jsonl");
51223
51555
  }
51224
51556
  function appendWitnessLedger(configDir, entry) {
51225
51557
  const path2 = witnessLedgerPath(configDir);
51226
51558
  try {
51227
51559
  appendFileSync3(path2, JSON.stringify(entry) + "\n");
51228
- const lines = readFileSync23(path2, "utf8").split("\n").filter(Boolean);
51560
+ const lines = readFileSync24(path2, "utf8").split("\n").filter(Boolean);
51229
51561
  if (lines.length > LEDGER_MAX_LINES) {
51230
51562
  writeFileSync19(path2, lines.slice(-Math.floor(LEDGER_MAX_LINES / 2)).join("\n") + "\n");
51231
51563
  }
@@ -51234,9 +51566,9 @@ function appendWitnessLedger(configDir, entry) {
51234
51566
  }
51235
51567
  function readWitnessLedger(configDir) {
51236
51568
  const path2 = witnessLedgerPath(configDir);
51237
- if (!existsSync23(path2)) return [];
51569
+ if (!existsSync24(path2)) return [];
51238
51570
  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");
51571
+ return readFileSync24(path2, "utf8").split("\n").filter(Boolean).map((l) => JSON.parse(l)).filter((e) => typeof e.ts === "number" && typeof e.channel === "string");
51240
51572
  } catch {
51241
51573
  return [];
51242
51574
  }
@@ -70453,12 +70785,12 @@ var init_report_render = __esm({
70453
70785
 
70454
70786
  // src/cli.ts
70455
70787
  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";
70788
+ import { closeSync as closeSync2, existsSync as existsSync33, openSync as openSync2, readFileSync as readFileSync32, renameSync as renameSync4, statSync as statSync8 } from "node:fs";
70789
+ import { join as join37, resolve as pathResolve } from "node:path";
70458
70790
  import { spawn as spawn3 } from "node:child_process";
70459
70791
 
70460
70792
  // src/daemon.ts
70461
- import { existsSync as existsSync25, writeFileSync as writeFileSync21 } from "node:fs";
70793
+ import { existsSync as existsSync26, writeFileSync as writeFileSync21 } from "node:fs";
70462
70794
 
70463
70795
  // ../../node_modules/.pnpm/@hono+node-server@1.19.11_hono@4.12.8/node_modules/@hono/node-server/dist/index.mjs
70464
70796
  import { createServer as createServerHTTP } from "http";
@@ -71037,9 +71369,9 @@ init_webui();
71037
71369
  init_config();
71038
71370
 
71039
71371
  // 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";
71372
+ import { execFileSync as execFileSync4 } from "node:child_process";
71373
+ 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";
71374
+ import { join as join30, relative as relative6, sep as sep4 } from "node:path";
71043
71375
 
71044
71376
  // ../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
71045
71377
  import { stat as statcb } from "fs";
@@ -75734,23 +76066,657 @@ async function pullCloudTriage(shared, cloud, profile, limit = 50) {
75734
76066
  return merged;
75735
76067
  }
75736
76068
 
75737
- // src/git-sensor.ts
75738
- import { existsSync as existsSync19, readFileSync as readFileSync18, watch as fsWatch } from "node:fs";
76069
+ // src/retrieval-stack.ts
76070
+ init_src();
76071
+ import { execFileSync as execFileSync3 } from "node:child_process";
76072
+ import { existsSync as existsSync19, readFileSync as readFileSync18, statSync as statSync6 } from "node:fs";
76073
+ import { homedir as homedir6 } from "node:os";
75739
76074
  import { join as join23 } from "node:path";
76075
+ var RETRIEVAL_STACK_CAP = 24;
76076
+ var MANIFEST_SCAN_CAP = 400;
76077
+ var RUNTIME_TOKENS = /* @__PURE__ */ new Set([
76078
+ "node",
76079
+ "deno",
76080
+ "bun",
76081
+ "python",
76082
+ "go",
76083
+ "rust",
76084
+ "java",
76085
+ "ruby",
76086
+ "php",
76087
+ "dotnet",
76088
+ "godot"
76089
+ ]);
76090
+ var RUNTIME_KINDS = /* @__PURE__ */ new Set(["runtime", "engine"]);
76091
+ var KIND_WEIGHT = { package: 1, sdk: 0.9, image: 0.5 };
76092
+ var PUBLIC_NPM_HOSTS = /* @__PURE__ */ new Set(["registry.npmjs.org", "registry.yarnpkg.com"]);
76093
+ var PUBLIC_PYPI_HOSTS = /* @__PURE__ */ new Set(["pypi.org", "files.pythonhosted.org", "pypi.python.org"]);
76094
+ var PUBLIC_NUGET_HOSTS = /* @__PURE__ */ new Set(["api.nuget.org", "www.nuget.org", "nuget.org"]);
76095
+ var PUBLIC_GEM_HOSTS = /* @__PURE__ */ new Set(["rubygems.org", "index.rubygems.org"]);
76096
+ var PUBLIC_MAVEN_HOSTS = /* @__PURE__ */ new Set([
76097
+ "repo.maven.apache.org",
76098
+ "repo1.maven.org",
76099
+ "central.sonatype.com",
76100
+ "oss.sonatype.org",
76101
+ "dl.google.com",
76102
+ "maven.google.com",
76103
+ "plugins.gradle.org"
76104
+ ]);
76105
+ var PUBLIC_GO_HOSTS = /* @__PURE__ */ new Set([
76106
+ "github.com",
76107
+ "gitlab.com",
76108
+ "bitbucket.org",
76109
+ "golang.org",
76110
+ "google.golang.org",
76111
+ "cloud.google.com",
76112
+ "gopkg.in",
76113
+ "go.uber.org",
76114
+ "go.opentelemetry.io",
76115
+ "k8s.io",
76116
+ "sigs.k8s.io",
76117
+ "gotest.tools",
76118
+ "gonum.org",
76119
+ "modernc.org",
76120
+ "rsc.io",
76121
+ "honnef.co"
76122
+ ]);
76123
+ var PUBLIC_REGISTRY_POLICY = {
76124
+ blockedEcosystems: /* @__PURE__ */ new Set(),
76125
+ npmPrivateScopes: /* @__PURE__ */ new Set(),
76126
+ goPrivatePatterns: [],
76127
+ privateGemNames: /* @__PURE__ */ new Set(),
76128
+ selfTokens: [],
76129
+ selfNames: /* @__PURE__ */ new Set(),
76130
+ selfNamespaces: /* @__PURE__ */ new Set(),
76131
+ selfComplete: true
76132
+ };
76133
+ function ecoKey(ecosystem, name2) {
76134
+ return `${ecosystem.toLowerCase()}\0${name2.toLowerCase()}`;
76135
+ }
76136
+ function selfIdentityFrom(selves) {
76137
+ const selfNames = /* @__PURE__ */ new Set();
76138
+ const selfNamespaces = /* @__PURE__ */ new Set();
76139
+ for (const s of selves) {
76140
+ (s.kind === "name" ? selfNames : selfNamespaces).add(ecoKey(s.ecosystem, s.value));
76141
+ }
76142
+ return { selfNames, selfNamespaces };
76143
+ }
76144
+ function namespacesOf(ecosystem, name2) {
76145
+ switch (ecosystem) {
76146
+ case "npm": {
76147
+ const scope = npmScopeOf(name2);
76148
+ return scope ? [scope] : [];
76149
+ }
76150
+ case "maven":
76151
+ return [name2.split(":")[0] ?? ""].filter(Boolean);
76152
+ case "golang": {
76153
+ const parts2 = name2.split("/");
76154
+ return parts2.map((_, i2) => parts2.slice(0, i2 + 1).join("/"));
76155
+ }
76156
+ default:
76157
+ return [];
76158
+ }
76159
+ }
76160
+ function isWorkspaceSelf(ecosystem, name2, policy) {
76161
+ if (policy.selfNames.has(ecoKey(ecosystem, name2))) return true;
76162
+ return namespacesOf(ecosystem, name2).some((ns) => policy.selfNamespaces.has(ecoKey(ecosystem, ns)));
76163
+ }
76164
+ function hostOf(value) {
76165
+ try {
76166
+ return new URL(value.trim()).hostname.toLowerCase();
76167
+ } catch {
76168
+ return null;
76169
+ }
76170
+ }
76171
+ function urlIsPublic(value, publicHosts) {
76172
+ const host = hostOf(value);
76173
+ return host !== null && publicHosts.has(host);
76174
+ }
76175
+ var unquote = (s) => s.trim().replace(/^['"]|['"]$/g, "");
76176
+ function parseNpmrcPolicy(texts) {
76177
+ let defaultPublic = null;
76178
+ const privateScopes = /* @__PURE__ */ new Set();
76179
+ const decidedScopes = /* @__PURE__ */ new Set();
76180
+ for (const text of texts) {
76181
+ for (const rawLine of text.split(/\r?\n/)) {
76182
+ const line = rawLine.trim();
76183
+ if (!line || line.startsWith("#") || line.startsWith(";")) continue;
76184
+ const eq = line.indexOf("=");
76185
+ if (eq === -1) continue;
76186
+ const key = line.slice(0, eq).trim().toLowerCase();
76187
+ const value = line.slice(eq + 1).trim();
76188
+ if (key === "registry") {
76189
+ if (defaultPublic === null) defaultPublic = urlIsPublic(value, PUBLIC_NPM_HOSTS);
76190
+ continue;
76191
+ }
76192
+ const scoped = /^(@[^:]+):registry$/.exec(key);
76193
+ if (!scoped) continue;
76194
+ const scope = (scoped[1] ?? "").toLowerCase();
76195
+ if (decidedScopes.has(scope)) continue;
76196
+ decidedScopes.add(scope);
76197
+ if (!urlIsPublic(value, PUBLIC_NPM_HOSTS)) privateScopes.add(scope);
76198
+ }
76199
+ }
76200
+ return { defaultPublic: defaultPublic ?? true, privateScopes };
76201
+ }
76202
+ function pypiIndexIsPrivate(texts) {
76203
+ for (const text of texts) {
76204
+ if (/^\s*\[\[?\s*tool\.(poetry\.source|uv\.index)\s*\]\]?/m.test(text)) {
76205
+ const urls = [...text.matchAll(/^\s*url\s*=\s*(.+)$/gm)].map((m) => unquote(m[1] ?? ""));
76206
+ if (urls.length === 0 || urls.some((u) => !urlIsPublic(u, PUBLIC_PYPI_HOSTS))) return true;
76207
+ }
76208
+ for (const m of text.matchAll(/^\s*(?:-i\b|--?(?:extra-)?index-url)\s*[=:]?\s*(\S+)/gm)) {
76209
+ if (!urlIsPublic(unquote(m[1] ?? ""), PUBLIC_PYPI_HOSTS)) return true;
76210
+ }
76211
+ for (const m of text.matchAll(/^\s*(?:extra-)?index-url\s*=\s*(\S+)/gm)) {
76212
+ if (!urlIsPublic(unquote(m[1] ?? ""), PUBLIC_PYPI_HOSTS)) return true;
76213
+ }
76214
+ }
76215
+ return false;
76216
+ }
76217
+ function cargoRegistryIsPrivate(texts) {
76218
+ return texts.some(
76219
+ (t) => /^\s*\[registries(\.|\])/m.test(t) || /^\s*replace-with\s*=/m.test(t)
76220
+ );
76221
+ }
76222
+ function nugetSourcesArePrivate(texts) {
76223
+ for (const text of texts) {
76224
+ const block = /<packageSources>([\s\S]*?)<\/packageSources>/i.exec(text);
76225
+ if (!block) continue;
76226
+ for (const m of (block[1] ?? "").matchAll(/<add\b[^>]*\bvalue\s*=\s*"([^"]+)"/gi)) {
76227
+ if (!urlIsPublic(m[1] ?? "", PUBLIC_NUGET_HOSTS)) return true;
76228
+ }
76229
+ }
76230
+ return false;
76231
+ }
76232
+ function parseGoPrivate(values) {
76233
+ return values.flatMap((v) => (v ?? "").split(",")).map((s) => s.trim()).filter(Boolean);
76234
+ }
76235
+ function goPrivateMatches(patterns, modulePath) {
76236
+ if (patterns.length === 0) return false;
76237
+ const parts2 = modulePath.split("/");
76238
+ const prefixes = parts2.map((_, i2) => parts2.slice(0, i2 + 1).join("/"));
76239
+ return patterns.some((pattern) => {
76240
+ const rx = new RegExp(
76241
+ "^" + pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*") + "$"
76242
+ );
76243
+ return prefixes.some((p) => rx.test(p));
76244
+ });
76245
+ }
76246
+ var OFFICIAL_DOCKER_IMAGES = /* @__PURE__ */ new Set([
76247
+ "alpine",
76248
+ "busybox",
76249
+ "debian",
76250
+ "ubuntu",
76251
+ "fedora",
76252
+ "rockylinux",
76253
+ "postgres",
76254
+ "mysql",
76255
+ "mariadb",
76256
+ "mongo",
76257
+ "redis",
76258
+ "memcached",
76259
+ "cassandra",
76260
+ "couchdb",
76261
+ "influxdb",
76262
+ "neo4j",
76263
+ "elasticsearch",
76264
+ "rabbitmq",
76265
+ "nats",
76266
+ "kafka",
76267
+ "zookeeper",
76268
+ "consul",
76269
+ "vault",
76270
+ "etcd",
76271
+ "minio",
76272
+ "clickhouse",
76273
+ "nginx",
76274
+ "httpd",
76275
+ "haproxy",
76276
+ "traefik",
76277
+ "caddy",
76278
+ "varnish",
76279
+ "node",
76280
+ "python",
76281
+ "golang",
76282
+ "rust",
76283
+ "ruby",
76284
+ "php",
76285
+ "openjdk",
76286
+ "eclipse-temurin",
76287
+ "gradle",
76288
+ "maven",
76289
+ "composer",
76290
+ "perl",
76291
+ "erlang",
76292
+ "elixir",
76293
+ "haskell",
76294
+ "docker",
76295
+ "registry",
76296
+ "grafana",
76297
+ "prometheus",
76298
+ "telegraf",
76299
+ "jenkins",
76300
+ "sonarqube",
76301
+ "wordpress",
76302
+ "drupal",
76303
+ "ghost",
76304
+ "nextcloud",
76305
+ "gitlab",
76306
+ "gitea",
76307
+ "sentry",
76308
+ "hello-world",
76309
+ "selenium",
76310
+ "playwright",
76311
+ "ollama"
76312
+ ]);
76313
+ function dockerImageIsPublicOfficial(name2) {
76314
+ const n = name2.trim().toLowerCase();
76315
+ if (!n || n.includes("/") || n.includes(":") || n.includes("@")) return false;
76316
+ return OFFICIAL_DOCKER_IMAGES.has(n);
76317
+ }
76318
+ function mavenReposArePrivate(texts) {
76319
+ for (const text of texts) {
76320
+ if (/<servers>[\s\S]*?<server>/i.test(text)) return true;
76321
+ for (const m of text.matchAll(/<(?:repository|pluginRepository|mirror)\b[\s\S]*?<\/(?:repository|pluginRepository|mirror)>/gi)) {
76322
+ const url2 = /<url>([^<]+)<\/url>/i.exec(m[0])?.[1];
76323
+ if (!url2 || !urlIsPublic(url2, PUBLIC_MAVEN_HOSTS)) return true;
76324
+ }
76325
+ }
76326
+ return false;
76327
+ }
76328
+ function gemSourceIsPrivate(texts) {
76329
+ for (const text of texts) {
76330
+ for (const m of text.matchAll(/^\s*source\s+["']([^"']+)["']/gm)) {
76331
+ if (!urlIsPublic(m[1] ?? "", PUBLIC_GEM_HOSTS)) return true;
76332
+ }
76333
+ }
76334
+ return false;
76335
+ }
76336
+ function privateGemNamesIn(texts) {
76337
+ const names = /* @__PURE__ */ new Set();
76338
+ for (const text of texts) {
76339
+ for (const raw2 of text.split(/\r?\n/)) {
76340
+ const line = (raw2.split("#", 1)[0] ?? "").trim();
76341
+ const m = /^gem\s+["']([^"']+)["']/.exec(line);
76342
+ if (!m?.[1]) continue;
76343
+ if (/(?::(?:git|path|github|gist|bitbucket)\s*=>|\b(?:git|path|github|gist|bitbucket):\s)/.test(line)) {
76344
+ names.add(m[1]);
76345
+ }
76346
+ }
76347
+ }
76348
+ return names;
76349
+ }
76350
+ function selfTokensFromLocator(repoLocator) {
76351
+ if (!repoLocator) return [];
76352
+ const segments = repoLocator.toLowerCase().split("/").slice(1).filter(Boolean);
76353
+ return [...new Set(segments.filter((s) => s.length >= 3))];
76354
+ }
76355
+ function mavenGroupIsSelfDisclosing(name2, selfTokens) {
76356
+ if (selfTokens.length === 0) return false;
76357
+ const group = (name2.split(":")[0] ?? "").toLowerCase();
76358
+ const parts2 = group.split(".");
76359
+ return selfTokens.some((t) => parts2.includes(t));
76360
+ }
76361
+ function loadRegistryPolicy(root, env2 = process.env, repoLocator) {
76362
+ const read2 = (p) => {
76363
+ try {
76364
+ return readFileSync18(p, "utf8");
76365
+ } catch {
76366
+ return null;
76367
+ }
76368
+ };
76369
+ const texts = (...paths) => paths.map(read2).filter((t) => t !== null);
76370
+ const home = homedir6();
76371
+ const npm = parseNpmrcPolicy(texts(join23(root, ".npmrc"), join23(home, ".npmrc")));
76372
+ const blocked = /* @__PURE__ */ new Set();
76373
+ if (!npm.defaultPublic) blocked.add("npm");
76374
+ if (pypiIndexIsPrivate(
76375
+ texts(
76376
+ join23(root, "pip.conf"),
76377
+ join23(root, "pip.ini"),
76378
+ join23(root, "pyproject.toml"),
76379
+ join23(root, "requirements.txt"),
76380
+ join23(home, ".pip", "pip.conf"),
76381
+ join23(home, ".config", "pip", "pip.conf"),
76382
+ join23(env2["APPDATA"] ?? home, "pip", "pip.ini")
76383
+ )
76384
+ )) {
76385
+ blocked.add("pypi");
76386
+ }
76387
+ if (cargoRegistryIsPrivate(
76388
+ texts(
76389
+ join23(root, ".cargo", "config.toml"),
76390
+ join23(root, ".cargo", "config"),
76391
+ join23(home, ".cargo", "config.toml"),
76392
+ join23(home, ".cargo", "config")
76393
+ )
76394
+ )) {
76395
+ blocked.add("cargo");
76396
+ }
76397
+ if (nugetSourcesArePrivate(
76398
+ texts(
76399
+ join23(root, "NuGet.config"),
76400
+ join23(root, "nuget.config"),
76401
+ join23(root, "NuGet.Config"),
76402
+ join23(env2["APPDATA"] ?? home, "NuGet", "NuGet.Config"),
76403
+ join23(home, ".nuget", "NuGet", "NuGet.Config")
76404
+ )
76405
+ )) {
76406
+ blocked.add("nuget");
76407
+ }
76408
+ const goEnvFile = env2["GOENV"] ?? join23(env2["APPDATA"] ?? join23(home, ".config"), "go", "env");
76409
+ const goEnvText = read2(goEnvFile) ?? "";
76410
+ const fromFile = ["GOPRIVATE", "GONOSUMDB", "GONOSUMCHECK"].map(
76411
+ (k) => new RegExp(`^${k}=(.*)$`, "m").exec(goEnvText)?.[1]
76412
+ );
76413
+ const goPrivatePatterns = parseGoPrivate([
76414
+ env2["GOPRIVATE"],
76415
+ env2["GONOSUMDB"],
76416
+ env2["GONOSUMCHECK"],
76417
+ ...fromFile
76418
+ ]);
76419
+ const gemfiles = texts(join23(root, "Gemfile"));
76420
+ if (gemSourceIsPrivate(gemfiles)) blocked.add("gem");
76421
+ if (mavenReposArePrivate(
76422
+ texts(join23(root, "pom.xml"), join23(home, ".m2", "settings.xml"))
76423
+ )) {
76424
+ blocked.add("maven");
76425
+ }
76426
+ const scan2 = scanManifests(root);
76427
+ return {
76428
+ blockedEcosystems: blocked,
76429
+ npmPrivateScopes: npm.privateScopes,
76430
+ goPrivatePatterns,
76431
+ privateGemNames: privateGemNamesIn(gemfiles),
76432
+ selfTokens: selfTokensFromLocator(repoLocator),
76433
+ ...selfIdentityFrom(scan2.self),
76434
+ selfComplete: scan2.complete
76435
+ };
76436
+ }
76437
+ function npmScopeOf(name2) {
76438
+ if (!name2.startsWith("@")) return null;
76439
+ const slash = name2.indexOf("/");
76440
+ return slash === -1 ? null : name2.slice(0, slash).toLowerCase();
76441
+ }
76442
+ function isPublicDep(dep, policy) {
76443
+ const ecosystem = dep.ecosystem.toLowerCase();
76444
+ if (policy.blockedEcosystems.has(ecosystem)) return false;
76445
+ if (isWorkspaceSelf(ecosystem, dep.name, policy)) return false;
76446
+ switch (ecosystem) {
76447
+ case "npm": {
76448
+ const scope = npmScopeOf(dep.name);
76449
+ return scope === null || !policy.npmPrivateScopes.has(scope);
76450
+ }
76451
+ case "pypi":
76452
+ case "cargo":
76453
+ return true;
76454
+ case "nuget":
76455
+ return true;
76456
+ case "maven":
76457
+ return !mavenGroupIsSelfDisclosing(dep.name, policy.selfTokens);
76458
+ case "gem":
76459
+ case "rubygems":
76460
+ return !policy.privateGemNames.has(dep.name);
76461
+ case "go":
76462
+ case "golang": {
76463
+ if (goPrivateMatches(policy.goPrivatePatterns, dep.name)) return false;
76464
+ const host = dep.name.split("/")[0]?.toLowerCase() ?? "";
76465
+ return PUBLIC_GO_HOSTS.has(host);
76466
+ }
76467
+ case "docker":
76468
+ return dockerImageIsPublicOfficial(dep.name);
76469
+ default:
76470
+ return false;
76471
+ }
76472
+ }
76473
+ function normStackToken(raw2) {
76474
+ return raw2.trim().toLowerCase().replace(/(?!^)[@\s].*$/, "");
76475
+ }
76476
+ function normStackTokens(xs) {
76477
+ return (xs ?? []).map(normStackToken).filter(Boolean);
76478
+ }
76479
+ function isRuntimeToken(token) {
76480
+ return RUNTIME_TOKENS.has(token);
76481
+ }
76482
+ function rankCandidates(cs) {
76483
+ return [...cs].sort((a, b) => b.weight - a.weight || a.name.localeCompare(b.name));
76484
+ }
76485
+ function isLocalSpec(version2) {
76486
+ if (!version2) return false;
76487
+ const v = version2.trim().toLowerCase();
76488
+ return v.startsWith("workspace:") || v.startsWith("link:") || v.startsWith("file:") || v.startsWith("portal:") || v.startsWith("path:") || v.startsWith("git:") || v.startsWith("git+") || v.includes("://");
76489
+ }
76490
+ function retrievalStackTokens(input) {
76491
+ const cap = input.cap ?? RETRIEVAL_STACK_CAP;
76492
+ const registry2 = input.registry ?? PUBLIC_REGISTRY_POLICY;
76493
+ const ignore2 = input.ignorePatterns ?? [];
76494
+ const ignored = (token) => ignore2.length > 0 && ignore2.some((p) => token.includes(p));
76495
+ const packagesAllowed = input.contributePackages;
76496
+ const tokens = [];
76497
+ const seen = /* @__PURE__ */ new Set();
76498
+ const push = (token) => {
76499
+ if (!token || seen.has(token) || ignored(token)) return false;
76500
+ seen.add(token);
76501
+ tokens.push(token);
76502
+ return true;
76503
+ };
76504
+ const manifestDeps = input.manifestDeps ?? [];
76505
+ const ecosystemLanguages = /* @__PURE__ */ new Set();
76506
+ for (const d of [...manifestDeps, ...input.direct ?? []]) {
76507
+ const lang = ECOSYSTEM_LANGUAGE[d.ecosystem.toLowerCase()];
76508
+ if (lang) ecosystemLanguages.add(normStackToken(lang));
76509
+ }
76510
+ for (const l of [...ecosystemLanguages, ...normStackTokens(input.languages)]) push(l);
76511
+ for (const t of normStackTokens(input.profileStack)) {
76512
+ if (isRuntimeToken(t)) push(t);
76513
+ }
76514
+ for (const d of manifestDeps) {
76515
+ if (RUNTIME_KINDS.has(d.kind)) push(normStackToken(d.name));
76516
+ }
76517
+ const byEcosystem = /* @__PURE__ */ new Map();
76518
+ const add = (c) => {
76519
+ const list = byEcosystem.get(c.ecosystem);
76520
+ if (list) list.push(c);
76521
+ else byEcosystem.set(c.ecosystem, [c]);
76522
+ };
76523
+ let fromLockfile = 0;
76524
+ let fromManifest = 0;
76525
+ const lockfileKeys = /* @__PURE__ */ new Set();
76526
+ if (packagesAllowed) {
76527
+ for (const d of input.direct ?? []) {
76528
+ lockfileKeys.add(ecoKey(d.ecosystem, d.name));
76529
+ if (!isPublicDep(d, registry2)) continue;
76530
+ add({ ecosystem: d.ecosystem.toLowerCase(), name: d.name, weight: d.importers });
76531
+ }
76532
+ const counted = /* @__PURE__ */ new Map();
76533
+ for (const d of registry2.selfComplete ? manifestDeps : []) {
76534
+ if (RUNTIME_KINDS.has(d.kind)) continue;
76535
+ const ecosystem = d.ecosystem.toLowerCase();
76536
+ if (lockfileKeys.has(ecoKey(ecosystem, d.name))) continue;
76537
+ if (isLocalSpec(d.version)) continue;
76538
+ if (!isPublicDep({ ecosystem, name: d.name }, registry2)) continue;
76539
+ const key = ecoKey(ecosystem, d.name);
76540
+ const prev = counted.get(key);
76541
+ const w = KIND_WEIGHT[d.kind] ?? 0.5;
76542
+ if (prev) prev.weight += w;
76543
+ else counted.set(key, { ecosystem, name: d.name, weight: w });
76544
+ }
76545
+ for (const c of counted.values()) add(c);
76546
+ }
76547
+ const queues = [...byEcosystem.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([ecosystem, cs]) => ({ ecosystem, items: rankCandidates(cs) }));
76548
+ const usedEcosystems = /* @__PURE__ */ new Set();
76549
+ for (let round2 = 0; tokens.length < cap; round2++) {
76550
+ let emittedThisRound = false;
76551
+ for (const q of queues) {
76552
+ if (tokens.length >= cap) break;
76553
+ const c = q.items[round2];
76554
+ if (!c) continue;
76555
+ emittedThisRound = true;
76556
+ if (!push(normStackToken(c.name))) continue;
76557
+ usedEcosystems.add(c.ecosystem);
76558
+ if (lockfileKeys.has(ecoKey(c.ecosystem, c.name))) fromLockfile++;
76559
+ else fromManifest++;
76560
+ }
76561
+ if (!emittedThisRound) break;
76562
+ }
76563
+ if (packagesAllowed) {
76564
+ for (const t of normStackTokens(input.profileStack)) {
76565
+ if (tokens.length >= cap) break;
76566
+ if (isRuntimeToken(t)) continue;
76567
+ if (!isPublicDep({ ecosystem: "npm", name: t }, registry2)) continue;
76568
+ push(t);
76569
+ }
76570
+ }
76571
+ const source = fromLockfile > 0 && fromManifest > 0 ? "both" : fromLockfile > 0 ? "lockfile" : fromManifest > 0 ? "manifest" : "profile";
76572
+ return { tokens: tokens.slice(0, cap), source, ecosystems: [...usedEcosystems].sort() };
76573
+ }
76574
+ var LOCKFILES = [
76575
+ { file: "pnpm-lock.yaml", family: "npm", parse: parsePnpmLock },
76576
+ { file: "package-lock.json", family: "npm", parse: parsePackageLockJson },
76577
+ { file: "Gemfile.lock", family: "gem", parse: parseGemfileLock }
76578
+ ];
76579
+ var directCache = /* @__PURE__ */ new Map();
76580
+ function readDirectDependencies(root) {
76581
+ const stamps = [];
76582
+ const found = [];
76583
+ const familiesSeen = /* @__PURE__ */ new Set();
76584
+ for (const c of LOCKFILES) {
76585
+ if (familiesSeen.has(c.family)) continue;
76586
+ const p = join23(root, c.file);
76587
+ if (!existsSync19(p)) continue;
76588
+ try {
76589
+ const s = statSync6(p);
76590
+ stamps.push(`${c.file}:${s.mtimeMs}:${s.size}`);
76591
+ } catch {
76592
+ continue;
76593
+ }
76594
+ familiesSeen.add(c.family);
76595
+ found.push({ c, path: p });
76596
+ }
76597
+ if (found.length === 0) {
76598
+ directCache.delete(root);
76599
+ return [];
76600
+ }
76601
+ const key = stamps.join("|");
76602
+ const hit = directCache.get(root);
76603
+ if (hit && hit.key === key) return hit.direct;
76604
+ const direct = [];
76605
+ for (const { c, path: path2 } of found) {
76606
+ try {
76607
+ direct.push(...c.parse(readFileSync18(path2, "utf8")).direct ?? []);
76608
+ } catch {
76609
+ }
76610
+ }
76611
+ directCache.set(root, { key, direct });
76612
+ return direct;
76613
+ }
76614
+ function manifestPaths(root) {
76615
+ try {
76616
+ const out2 = execFileSync3("git", ["-C", root, "ls-files", "-z"], {
76617
+ encoding: "utf8",
76618
+ maxBuffer: 128 * 1024 * 1024,
76619
+ windowsHide: true,
76620
+ stdio: ["ignore", "pipe", "ignore"]
76621
+ });
76622
+ const paths = out2.split("\0").filter((f) => f && isManifestPath(f));
76623
+ if (paths.length > 0) {
76624
+ return {
76625
+ paths: paths.slice(0, MANIFEST_SCAN_CAP),
76626
+ tracked: true,
76627
+ truncated: paths.length > MANIFEST_SCAN_CAP
76628
+ };
76629
+ }
76630
+ } catch {
76631
+ }
76632
+ const ROOT_MANIFESTS = [
76633
+ "package.json",
76634
+ "pyproject.toml",
76635
+ "requirements.txt",
76636
+ "go.mod",
76637
+ "Cargo.toml",
76638
+ "pom.xml",
76639
+ "build.gradle",
76640
+ "build.gradle.kts",
76641
+ "gradle/libs.versions.toml",
76642
+ "Gemfile",
76643
+ "docker-compose.yml",
76644
+ "docker-compose.yaml",
76645
+ "compose.yaml",
76646
+ "Dockerfile",
76647
+ "project.godot"
76648
+ ];
76649
+ return {
76650
+ paths: ROOT_MANIFESTS.filter((f) => existsSync19(join23(root, f))),
76651
+ tracked: false,
76652
+ truncated: false
76653
+ };
76654
+ }
76655
+ var WORKSPACE_MARKERS = ["pnpm-workspace.yaml", "lerna.json", "go.work", "settings.gradle", "settings.gradle.kts"];
76656
+ function rootDeclaresWorkspace(root, texts) {
76657
+ if (WORKSPACE_MARKERS.some((f) => existsSync19(join23(root, f)))) return true;
76658
+ return /"workspaces"\s*:/.test(texts.get("package.json") ?? "") || /<modules>/.test(texts.get("pom.xml") ?? "") || /^\s*\[workspace\]/m.test(texts.get("Cargo.toml") ?? "");
76659
+ }
76660
+ var EMPTY_SCAN = { deps: [], self: [], complete: true };
76661
+ var manifestCache = /* @__PURE__ */ new Map();
76662
+ function scanManifests(root) {
76663
+ const { paths, tracked, truncated } = manifestPaths(root);
76664
+ if (paths.length === 0) {
76665
+ manifestCache.delete(root);
76666
+ return EMPTY_SCAN;
76667
+ }
76668
+ const texts = /* @__PURE__ */ new Map();
76669
+ const stamps = [];
76670
+ for (const rel of paths) {
76671
+ const abs = join23(root, rel);
76672
+ try {
76673
+ const s = statSync6(abs);
76674
+ stamps.push(`${rel}:${s.mtimeMs}:${s.size}`);
76675
+ texts.set(rel, readFileSync18(abs, "utf8"));
76676
+ } catch {
76677
+ }
76678
+ }
76679
+ const key = stamps.join("|");
76680
+ const hit = manifestCache.get(root);
76681
+ if (hit && hit.key === key) return hit.scan;
76682
+ const scan2 = {
76683
+ deps: [],
76684
+ self: [],
76685
+ complete: !truncated && (tracked || !rootDeclaresWorkspace(root, texts))
76686
+ };
76687
+ try {
76688
+ const spine = buildSpine("workspace", [...texts.keys()], (p) => texts.get(p) ?? "");
76689
+ scan2.deps = Object.values(spine.manifests).flat();
76690
+ for (const [path2, text] of texts) scan2.self.push(...parseManifestSelf(path2, text));
76691
+ } catch {
76692
+ scan2.deps = [];
76693
+ scan2.self = [];
76694
+ scan2.complete = false;
76695
+ }
76696
+ manifestCache.set(root, { key, scan: scan2 });
76697
+ return scan2;
76698
+ }
76699
+ function readManifestDependencies(root) {
76700
+ return scanManifests(root).deps;
76701
+ }
76702
+
76703
+ // src/git-sensor.ts
76704
+ import { existsSync as existsSync20, readFileSync as readFileSync19, watch as fsWatch } from "node:fs";
76705
+ import { join as join24 } from "node:path";
75740
76706
  function readFirstLine(path2) {
75741
76707
  try {
75742
- return readFileSync18(path2, "utf8").split(/\r?\n/, 1)[0].trim();
76708
+ return readFileSync19(path2, "utf8").split(/\r?\n/, 1)[0].trim();
75743
76709
  } catch {
75744
76710
  return null;
75745
76711
  }
75746
76712
  }
75747
76713
  function readGitRefState(gitDir) {
75748
- const head2 = readFirstLine(join23(gitDir, "HEAD"));
76714
+ const head2 = readFirstLine(join24(gitDir, "HEAD"));
75749
76715
  const m = head2 ? /^ref:\s*refs\/heads\/(.+)$/.exec(head2) : null;
75750
76716
  const branch = m ? m[1] : null;
75751
76717
  let sha2 = null;
75752
76718
  if (branch) {
75753
- sha2 = readFirstLine(join23(gitDir, "refs", "heads", branch));
76719
+ sha2 = readFirstLine(join24(gitDir, "refs", "heads", branch));
75754
76720
  if (!sha2) sha2 = shaFromPackedRefs(gitDir, `refs/heads/${branch}`);
75755
76721
  } else if (head2 && /^[0-9a-f]{7,40}$/i.test(head2)) {
75756
76722
  sha2 = head2;
@@ -75758,13 +76724,13 @@ function readGitRefState(gitDir) {
75758
76724
  return {
75759
76725
  branch,
75760
76726
  sha: sha2,
75761
- mergeHeadExists: existsSync19(join23(gitDir, "MERGE_HEAD")),
75762
- origHeadExists: existsSync19(join23(gitDir, "ORIG_HEAD"))
76727
+ mergeHeadExists: existsSync20(join24(gitDir, "MERGE_HEAD")),
76728
+ origHeadExists: existsSync20(join24(gitDir, "ORIG_HEAD"))
75763
76729
  };
75764
76730
  }
75765
76731
  function shaFromPackedRefs(gitDir, ref) {
75766
76732
  try {
75767
- for (const line of readFileSync18(join23(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
76733
+ for (const line of readFileSync19(join24(gitDir, "packed-refs"), "utf8").split(/\r?\n/)) {
75768
76734
  const [sha2, name2] = line.split(/\s+/);
75769
76735
  if (name2 === ref && sha2) return sha2;
75770
76736
  }
@@ -75798,7 +76764,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
75798
76764
  const settle = () => {
75799
76765
  if (timer) clearTimeout(timer);
75800
76766
  timer = setTimeout(() => {
75801
- if (existsSync19(join23(gitDir, "index.lock"))) {
76767
+ if (existsSync20(join24(gitDir, "index.lock"))) {
75802
76768
  settle();
75803
76769
  return;
75804
76770
  }
@@ -75809,7 +76775,7 @@ function startGitSensor(gitDir, onEvent, opts = {}) {
75809
76775
  }, debounceMs);
75810
76776
  };
75811
76777
  for (const sub of ["HEAD", "logs/HEAD", "MERGE_HEAD", "ORIG_HEAD"]) {
75812
- const p = join23(gitDir, sub);
76778
+ const p = join24(gitDir, sub);
75813
76779
  try {
75814
76780
  watchers.push(fsWatch(p, settle));
75815
76781
  } catch {
@@ -76034,21 +77000,21 @@ var TelemetryRecorder = class {
76034
77000
 
76035
77001
  // src/skills.ts
76036
77002
  import {
76037
- existsSync as existsSync20,
77003
+ existsSync as existsSync21,
76038
77004
  mkdirSync as mkdirSync7,
76039
- readFileSync as readFileSync19,
77005
+ readFileSync as readFileSync20,
76040
77006
  readdirSync as readdirSync8,
76041
77007
  unlinkSync as unlinkSync2,
76042
77008
  writeFileSync as writeFileSync15
76043
77009
  } from "node:fs";
76044
- import { basename as basename6, join as join24 } from "node:path";
77010
+ import { basename as basename6, join as join25 } from "node:path";
76045
77011
  function skillFileName(id) {
76046
77012
  return `${id.replace(/[^A-Za-z0-9_.-]/g, "_")}.md`;
76047
77013
  }
76048
77014
  function readSkillManifest(manifestPath) {
76049
- if (!existsSync20(manifestPath)) return [];
77015
+ if (!existsSync21(manifestPath)) return [];
76050
77016
  try {
76051
- const parsed = JSON.parse(readFileSync19(manifestPath, "utf8"));
77017
+ const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
76052
77018
  return (parsed.skills ?? []).map((s) => ({
76053
77019
  title: s.title ?? "",
76054
77020
  layer: s.layer ?? "technique",
@@ -76072,7 +77038,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76072
77038
  for (const s of res.skills) {
76073
77039
  const fileName = skillFileName(s.id);
76074
77040
  keep.add(fileName);
76075
- writeFileSync15(join24(paths.skillsDir, fileName), s.markdown, "utf8");
77041
+ writeFileSync15(join25(paths.skillsDir, fileName), s.markdown, "utf8");
76076
77042
  rows.push({
76077
77043
  id: s.id,
76078
77044
  title: s.title,
@@ -76085,7 +77051,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76085
77051
  const fileName = skillFileName(p.id);
76086
77052
  if (keep.has(fileName)) continue;
76087
77053
  keep.add(fileName);
76088
- writeFileSync15(join24(paths.skillsDir, fileName), p.markdown, "utf8");
77054
+ writeFileSync15(join25(paths.skillsDir, fileName), p.markdown, "utf8");
76089
77055
  rows.push({
76090
77056
  id: p.id,
76091
77057
  title: p.title,
@@ -76099,7 +77065,7 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76099
77065
  if (!f.endsWith(".md")) continue;
76100
77066
  if (keep.has(basename6(f))) continue;
76101
77067
  try {
76102
- unlinkSync2(join24(paths.skillsDir, f));
77068
+ unlinkSync2(join25(paths.skillsDir, f));
76103
77069
  pruned++;
76104
77070
  } catch {
76105
77071
  }
@@ -76117,22 +77083,22 @@ async function syncSkills(paths, client, seed, pins = [], techSeed) {
76117
77083
  init_src2();
76118
77084
  import {
76119
77085
  cpSync,
76120
- existsSync as existsSync21,
77086
+ existsSync as existsSync22,
76121
77087
  lstatSync,
76122
77088
  mkdirSync as mkdirSync8,
76123
- readFileSync as readFileSync20,
77089
+ readFileSync as readFileSync21,
76124
77090
  readdirSync as readdirSync9,
76125
77091
  rmSync as rmSync3,
76126
77092
  symlinkSync,
76127
77093
  writeFileSync as writeFileSync16
76128
77094
  } from "node:fs";
76129
- import { join as join25 } from "node:path";
77095
+ import { join as join26 } from "node:path";
76130
77096
  var SKILL_NS = "errata-";
76131
77097
  var HARNESS_SKILL_DIRS = [
76132
- { configDir: ".claude", skillsDir: join25(".claude", "skills") },
77098
+ { configDir: ".claude", skillsDir: join26(".claude", "skills") },
76133
77099
  // Cursor adopted the standard; its exact project dir is still moving — kept
76134
77100
  // best-effort and gated on `.cursor/` presence so we never create it blind.
76135
- { configDir: ".cursor", skillsDir: join25(".cursor", "skills") }
77101
+ { configDir: ".cursor", skillsDir: join26(".cursor", "skills") }
76136
77102
  ];
76137
77103
  function skillSlug(title, id) {
76138
77104
  const base = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "skill";
@@ -76177,12 +77143,12 @@ function skillCiteHandle(s) {
76177
77143
  return priorHandle({ id: s.id, description: s.title });
76178
77144
  }
76179
77145
  function reconcileNamespaced(dir, keep) {
76180
- if (!existsSync21(dir)) return 0;
77146
+ if (!existsSync22(dir)) return 0;
76181
77147
  let pruned = 0;
76182
77148
  for (const name2 of readdirSync9(dir)) {
76183
77149
  if (!name2.startsWith(SKILL_NS) || keep.has(name2)) continue;
76184
77150
  try {
76185
- rmSync3(join25(dir, name2), { recursive: true, force: true });
77151
+ rmSync3(join26(dir, name2), { recursive: true, force: true });
76186
77152
  pruned++;
76187
77153
  } catch {
76188
77154
  }
@@ -76191,7 +77157,7 @@ function reconcileNamespaced(dir, keep) {
76191
77157
  }
76192
77158
  function linkOrCopy(linkPath, target) {
76193
77159
  try {
76194
- if (existsSync21(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
77160
+ if (existsSync22(linkPath) || safeLstat(linkPath)) rmSync3(linkPath, { recursive: true, force: true });
76195
77161
  } catch {
76196
77162
  }
76197
77163
  try {
@@ -76212,7 +77178,7 @@ function safeLstat(p) {
76212
77178
  }
76213
77179
  }
76214
77180
  function emitAndProjectSkills(root, skills) {
76215
- const agentsSkillsDir = join25(root, ".agents", "skills");
77181
+ const agentsSkillsDir = join26(root, ".agents", "skills");
76216
77182
  mkdirSync8(agentsSkillsDir, { recursive: true });
76217
77183
  const slugs = [];
76218
77184
  const keep = /* @__PURE__ */ new Set();
@@ -76220,7 +77186,7 @@ function emitAndProjectSkills(root, skills) {
76220
77186
  for (const s of skills) {
76221
77187
  let body2;
76222
77188
  try {
76223
- body2 = readFileSync20(s.bodyPath, "utf8");
77189
+ body2 = readFileSync21(s.bodyPath, "utf8");
76224
77190
  } catch {
76225
77191
  continue;
76226
77192
  }
@@ -76229,9 +77195,9 @@ function emitAndProjectSkills(root, skills) {
76229
77195
  keep.add(slug2);
76230
77196
  slugs.push(slug2);
76231
77197
  const description = deriveDescription(s.title, s.layer, body2);
76232
- mkdirSync8(join25(agentsSkillsDir, slug2), { recursive: true });
77198
+ mkdirSync8(join26(agentsSkillsDir, slug2), { recursive: true });
76233
77199
  writeFileSync16(
76234
- join25(agentsSkillsDir, slug2, "SKILL.md"),
77200
+ join26(agentsSkillsDir, slug2, "SKILL.md"),
76235
77201
  renderSkillMd(slug2, description, body2, skillCiteHandle(s)),
76236
77202
  "utf8"
76237
77203
  );
@@ -76240,11 +77206,11 @@ function emitAndProjectSkills(root, skills) {
76240
77206
  reconcileNamespaced(agentsSkillsDir, keep);
76241
77207
  let projected = 0;
76242
77208
  for (const h of HARNESS_SKILL_DIRS) {
76243
- if (!existsSync21(join25(root, h.configDir))) continue;
76244
- const dir = join25(root, h.skillsDir);
77209
+ if (!existsSync22(join26(root, h.configDir))) continue;
77210
+ const dir = join26(root, h.skillsDir);
76245
77211
  mkdirSync8(dir, { recursive: true });
76246
77212
  for (const slug2 of slugs) {
76247
- linkOrCopy(join25(dir, slug2), join25(agentsSkillsDir, slug2));
77213
+ linkOrCopy(join26(dir, slug2), join26(agentsSkillsDir, slug2));
76248
77214
  projected++;
76249
77215
  }
76250
77216
  reconcileNamespaced(dir, keep);
@@ -76253,15 +77219,15 @@ function emitAndProjectSkills(root, skills) {
76253
77219
  return { slugs, emitted, projected };
76254
77220
  }
76255
77221
  function emitInputsFromManifest(erretaDir, manifestPath) {
76256
- if (!existsSync21(manifestPath)) return [];
77222
+ if (!existsSync22(manifestPath)) return [];
76257
77223
  try {
76258
- const parsed = JSON.parse(readFileSync20(manifestPath, "utf8"));
77224
+ const parsed = JSON.parse(readFileSync21(manifestPath, "utf8"));
76259
77225
  return (parsed.skills ?? []).filter((s) => Boolean(s.id && s.file)).map((s) => ({
76260
77226
  id: s.id,
76261
77227
  title: s.title ?? s.id,
76262
77228
  layer: s.layer ?? "technique",
76263
77229
  confidence: s.confidence ?? 0,
76264
- bodyPath: join25(erretaDir, s.file)
77230
+ bodyPath: join26(erretaDir, s.file)
76265
77231
  }));
76266
77232
  } catch {
76267
77233
  return [];
@@ -76275,10 +77241,10 @@ var GITIGNORE_LINES = [
76275
77241
  ".cursor/skills/errata-*/"
76276
77242
  ];
76277
77243
  function ensureSkillGitignore(root) {
76278
- const path2 = join25(root, ".gitignore");
77244
+ const path2 = join26(root, ".gitignore");
76279
77245
  let current = "";
76280
77246
  try {
76281
- current = existsSync21(path2) ? readFileSync20(path2, "utf8") : "";
77247
+ current = existsSync22(path2) ? readFileSync21(path2, "utf8") : "";
76282
77248
  } catch {
76283
77249
  return;
76284
77250
  }
@@ -76383,9 +77349,9 @@ init_paths();
76383
77349
  init_src2();
76384
77350
  init_paths();
76385
77351
  init_git_remote();
76386
- import { existsSync as existsSync22, readFileSync as readFileSync21, writeFileSync as writeFileSync17 } from "node:fs";
77352
+ import { existsSync as existsSync23, readFileSync as readFileSync22, writeFileSync as writeFileSync17 } from "node:fs";
76387
77353
  import { createHash as createHash14 } from "node:crypto";
76388
- import { join as join26 } from "node:path";
77354
+ import { join as join27 } from "node:path";
76389
77355
  function workspaceId(root) {
76390
77356
  return "wp_" + createHash14("sha256").update(root).digest("hex").slice(0, 12);
76391
77357
  }
@@ -76408,8 +77374,8 @@ function refreshRepoLocator(root, profile) {
76408
77374
  }
76409
77375
  function loadProfile(root) {
76410
77376
  const p = workspacePaths(root);
76411
- if (!existsSync22(p.workspaceJson)) return null;
76412
- return JSON.parse(readFileSync21(p.workspaceJson, "utf8"));
77377
+ if (!existsSync23(p.workspaceJson)) return null;
77378
+ return JSON.parse(readFileSync22(p.workspaceJson, "utf8"));
76413
77379
  }
76414
77380
  function saveProfile(root, profile) {
76415
77381
  const p = workspacePaths(root);
@@ -76422,14 +77388,17 @@ function autodetectProfile(root) {
76422
77388
  const p = emptyProfile(id, name2);
76423
77389
  const locator = detectRepoLocator(root);
76424
77390
  if (locator) p.repoLocator = locator;
76425
- const pkgPath = join26(root, "package.json");
76426
- if (existsSync22(pkgPath)) {
77391
+ const pkgPath = join27(root, "package.json");
77392
+ if (existsSync23(pkgPath)) {
76427
77393
  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}`);
77394
+ const pkg = JSON.parse(readFileSync22(pkgPath, "utf8"));
76432
77395
  const deps = { ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} };
77396
+ p.languages.push("javascript");
77397
+ if (existsSync23(join27(root, "tsconfig.json")) || deps["typescript"]) {
77398
+ p.languages.push("typescript");
77399
+ }
77400
+ const nodeVer = pkg.engines?.node?.trim();
77401
+ p.stack.push(nodeVer ? `node@${nodeVer}` : "node");
76433
77402
  const interesting = [
76434
77403
  "next",
76435
77404
  "react",
@@ -76446,10 +77415,10 @@ function autodetectProfile(root) {
76446
77415
  } catch {
76447
77416
  }
76448
77417
  }
76449
- const pyproject = join26(root, "pyproject.toml");
76450
- if (existsSync22(pyproject)) {
77418
+ const pyproject = join27(root, "pyproject.toml");
77419
+ if (existsSync23(pyproject)) {
76451
77420
  try {
76452
- const txt = readFileSync21(pyproject, "utf8");
77421
+ const txt = readFileSync22(pyproject, "utf8");
76453
77422
  const py = /python\s*=\s*"([^"]+)"/.exec(txt)?.[1];
76454
77423
  p.languages.push("python");
76455
77424
  p.stack.push(`python@${py ?? "3"}`);
@@ -76460,16 +77429,16 @@ function autodetectProfile(root) {
76460
77429
  } catch {
76461
77430
  }
76462
77431
  }
76463
- const reqs = join26(root, "requirements.txt");
76464
- if (existsSync22(reqs)) {
77432
+ const reqs = join27(root, "requirements.txt");
77433
+ if (existsSync23(reqs)) {
76465
77434
  if (!p.languages.includes("python")) p.languages.push("python");
76466
77435
  if (!p.stack.includes("python@3")) p.stack.push("python@3");
76467
77436
  }
76468
- if (existsSync22(join26(root, "go.mod"))) {
77437
+ if (existsSync23(join27(root, "go.mod"))) {
76469
77438
  p.languages.push("go");
76470
77439
  p.stack.push("go");
76471
77440
  }
76472
- if (existsSync22(join26(root, "Cargo.toml"))) {
77441
+ if (existsSync23(join27(root, "Cargo.toml"))) {
76473
77442
  p.languages.push("rust");
76474
77443
  p.stack.push("rust");
76475
77444
  }
@@ -76479,18 +77448,18 @@ function autodetectProfile(root) {
76479
77448
  }
76480
77449
 
76481
77450
  // 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";
77451
+ import { readFileSync as readFileSync23, renameSync as renameSync2, writeFileSync as writeFileSync18 } from "node:fs";
77452
+ import { dirname as dirname11, join as join28 } from "node:path";
76484
77453
  var WITNESS_QUEUE_CAP = 500;
76485
77454
  var WITNESS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
76486
77455
  var WITNESS_MAX_ATTEMPTS = 5;
76487
77456
  function witnessQueuePath(workspaceConfigDir) {
76488
- return join27(workspaceConfigDir, "witness-queue.json");
77457
+ return join28(workspaceConfigDir, "witness-queue.json");
76489
77458
  }
76490
77459
  function loadWitnessQueueWithLosses(path2) {
76491
77460
  let raw2;
76492
77461
  try {
76493
- raw2 = JSON.parse(readFileSync22(path2, "utf8"));
77462
+ raw2 = JSON.parse(readFileSync23(path2, "utf8"));
76494
77463
  } catch (err2) {
76495
77464
  const absent = err2?.code === "ENOENT";
76496
77465
  return { queue: [], fileUnreadable: !absent, malformedEntries: 0 };
@@ -76503,7 +77472,7 @@ function loadWitnessQueueWithLosses(path2) {
76503
77472
  }
76504
77473
  function saveWitnessQueue(path2, queue) {
76505
77474
  try {
76506
- const tmp = join27(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
77475
+ const tmp = join28(dirname11(path2), `.${Date.now()}.witness-queue.tmp`);
76507
77476
  writeFileSync18(tmp, JSON.stringify(queue), "utf8");
76508
77477
  renameSync2(tmp, path2);
76509
77478
  } catch {
@@ -77077,7 +78046,7 @@ function createWatchBreaker(deps) {
77077
78046
  }
77078
78047
 
77079
78048
  // src/engine.ts
77080
- var DAEMON_VERSION = true ? "2.0.6-dev.2198" : "2.0.0-alpha.0";
78049
+ var DAEMON_VERSION = true ? "2.0.6-dev.2266" : "2.0.0-alpha.0";
77081
78050
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
77082
78051
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
77083
78052
  var GIT_OP_MUTE_MS = 4e3;
@@ -77088,7 +78057,7 @@ var CODEX_SWEEP_LOOKBACK_MS = 10 * 6e4;
77088
78057
  function appendIdentityAudit(path2, record2, line) {
77089
78058
  if (!record2.accepted && record2.score <= 0) return;
77090
78059
  try {
77091
- if (existsSync24(path2) && statSync6(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
78060
+ if (existsSync25(path2) && statSync7(path2).size >= IDENTITY_AUDIT_MAX_BYTES) {
77092
78061
  renameSync3(path2, `${path2}.1`);
77093
78062
  }
77094
78063
  appendFileSync4(path2, line);
@@ -77098,7 +78067,7 @@ function appendIdentityAudit(path2, record2, line) {
77098
78067
  var yieldToLoop = () => new Promise((r) => setImmediate(r));
77099
78068
  function loadTurnCursors(path2) {
77100
78069
  try {
77101
- const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
78070
+ const raw2 = JSON.parse(readFileSync25(path2, "utf8"));
77102
78071
  return new Map(
77103
78072
  Object.entries(raw2).map(([k, v]) => [k, typeof v === "string" ? v : String(v?.uuid ?? "")])
77104
78073
  );
@@ -77108,7 +78077,7 @@ function loadTurnCursors(path2) {
77108
78077
  }
77109
78078
  function loadTurnOffsets(path2) {
77110
78079
  try {
77111
- const raw2 = JSON.parse(readFileSync24(path2, "utf8"));
78080
+ const raw2 = JSON.parse(readFileSync25(path2, "utf8"));
77112
78081
  const out2 = /* @__PURE__ */ new Map();
77113
78082
  for (const [k, v] of Object.entries(raw2)) {
77114
78083
  const off = typeof v === "object" && v !== null ? v.offset : void 0;
@@ -77131,7 +78100,7 @@ function saveTurnCursors(path2, cursors, offsets) {
77131
78100
  function gitSourceWatchTargets(root) {
77132
78101
  const SOURCE = /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i;
77133
78102
  try {
77134
- const lsOut = execFileSync3("git", ["-C", root, "ls-files", "-z"], {
78103
+ const lsOut = execFileSync4("git", ["-C", root, "ls-files", "-z"], {
77135
78104
  encoding: "utf8",
77136
78105
  maxBuffer: 128 * 1024 * 1024,
77137
78106
  windowsHide: true,
@@ -77141,12 +78110,12 @@ function gitSourceWatchTargets(root) {
77141
78110
  if (sourceFiles.length === 0) throw new Error("no tracked source");
77142
78111
  let ignoredDirs = [];
77143
78112
  try {
77144
- const igOut = execFileSync3(
78113
+ const igOut = execFileSync4(
77145
78114
  "git",
77146
78115
  ["-C", root, "ls-files", "--others", "--ignored", "--exclude-standard", "--directory", "-z"],
77147
78116
  { encoding: "utf8", maxBuffer: 256 * 1024 * 1024, windowsHide: true, stdio: ["ignore", "pipe", "ignore"] }
77148
78117
  );
77149
- ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join29(root, d) + sep4));
78118
+ ignoredDirs = igOut.split("\0").filter(Boolean).map((d) => d.replace(/\/+$/, "")).filter((d) => !IGNORED_PATH.test(join30(root, d) + sep4));
77150
78119
  } catch {
77151
78120
  }
77152
78121
  const hasIgnoredChild = (dir) => ignoredDirs.some((ig) => ig.startsWith(dir + "/"));
@@ -77158,19 +78127,19 @@ function gitSourceWatchTargets(root) {
77158
78127
  if (!f.startsWith(prefix)) continue;
77159
78128
  const rest2 = f.slice(prefix.length);
77160
78129
  if (rest2.includes("/")) children.add(dir === "" ? rest2.slice(0, rest2.indexOf("/")) : dir + "/" + rest2.slice(0, rest2.indexOf("/")));
77161
- else targets.add(join29(root, f));
78130
+ else targets.add(join30(root, f));
77162
78131
  }
77163
78132
  for (const c of children) {
77164
- if (IGNORED_PATH.test(join29(root, c) + sep4)) continue;
78133
+ if (IGNORED_PATH.test(join30(root, c) + sep4)) continue;
77165
78134
  if (hasIgnoredChild(c)) addUnder(c);
77166
- else targets.add(join29(root, c));
78135
+ else targets.add(join30(root, c));
77167
78136
  }
77168
78137
  };
77169
78138
  addUnder("");
77170
78139
  if (targets.size > 0) return [...targets];
77171
78140
  } catch {
77172
78141
  }
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)));
78142
+ 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
78143
  }
77175
78144
  function createWorkspaceEngine(opts) {
77176
78145
  const paths = workspacePaths(opts.workspaceRoot);
@@ -77248,7 +78217,7 @@ function createWorkspaceEngine(opts) {
77248
78217
  }
77249
78218
  let size = 0;
77250
78219
  try {
77251
- size = statSync6(path2).size;
78220
+ size = statSync7(path2).size;
77252
78221
  } catch {
77253
78222
  }
77254
78223
  lastActivityTs = Date.now();
@@ -77363,7 +78332,7 @@ function createWorkspaceEngine(opts) {
77363
78332
  const srcPaths = diff.changedPaths.filter((p) => /\.(ts|tsx|js|jsx|mjs|cjs|py)$/i.test(p));
77364
78333
  let episodeId2;
77365
78334
  if (srcPaths.length > 0) {
77366
- const abs = srcPaths.map((p) => join29(opts.workspaceRoot, p));
78335
+ const abs = srcPaths.map((p) => join30(opts.workspaceRoot, p));
77367
78336
  try {
77368
78337
  const r = await runReindexPass(
77369
78338
  `git-reindex:${profile.name} (${abs.length} files)`,
@@ -77399,8 +78368,8 @@ function createWorkspaceEngine(opts) {
77399
78368
  `[errata] git: ${ev.kind} ${ev.newSha.slice(0, 7)} by ${meta3.authorName} \u2014 ${diff.changedPaths.length} file(s), ${diff.renames.length} rename(s)`
77400
78369
  );
77401
78370
  };
77402
- const gitDir = join29(opts.workspaceRoot, ".git");
77403
- if (existsSync24(gitDir)) {
78371
+ const gitDir = join30(opts.workspaceRoot, ".git");
78372
+ if (existsSync25(gitDir)) {
77404
78373
  stopGit = startGitSensor(gitDir, (ev) => {
77405
78374
  void handleGitEvent(ev).catch((err2) => {
77406
78375
  console.warn("[errata] git event handler failed:", err2);
@@ -77581,10 +78550,10 @@ function createWorkspaceEngine(opts) {
77581
78550
  console.warn("[errata] render ledger failed:", err2.message?.slice(0, 120));
77582
78551
  }
77583
78552
  writeContextFile(opts.workspaceRoot, body2);
77584
- const target = join29(opts.workspaceRoot, "AGENTS.md");
78553
+ const target = join30(opts.workspaceRoot, "AGENTS.md");
77585
78554
  writeManagedBlock(target, { body: AGENTS_POINTER_BODY, stable: true, force: true });
77586
78555
  if (elicit) {
77587
- writePrimingHandles(join29(paths.configDir, "priming-handles.json"), [
78556
+ writePrimingHandles(join30(paths.configDir, "priming-handles.json"), [
77588
78557
  ...snapshot.recentProblems.map((r) => r.node),
77589
78558
  // Resolved-band handles: the ✓ problem AND its Solution are citable
77590
78559
  // (a fix tag on an already-resolved problem no-ops idempotently; the
@@ -77604,7 +78573,21 @@ function createWorkspaceEngine(opts) {
77604
78573
  contextDirty = false;
77605
78574
  notifyDigest("recall");
77606
78575
  };
77607
- const normStackTokens = (xs) => (xs ?? []).map((t) => t.trim().toLowerCase().replace(/(?!^)[@\s].*$/, "")).filter(Boolean);
78576
+ const outboundStack = () => retrievalStackTokens({
78577
+ direct: readDirectDependencies(opts.workspaceRoot),
78578
+ manifestDeps: readManifestDependencies(opts.workspaceRoot),
78579
+ profileStack: profile?.stack ?? [],
78580
+ // Languages ride the stack list: the cloud's context-affinity matcher
78581
+ // resolves each token against both the Package and Language namespaces,
78582
+ // and the profile keeps them in separate fields.
78583
+ languages: profile?.languages ?? [],
78584
+ contributePackages: loadConfig().consent.contributePackages,
78585
+ // `repoLocator` feeds the Maven self-disclosure rule ONLY: a groupId
78586
+ // carrying this project's own owner/repo token is the project naming
78587
+ // itself, not a library it depends on.
78588
+ registry: loadRegistryPolicy(opts.workspaceRoot, process.env, profile?.repoLocator),
78589
+ ignorePatterns: loadClaimIgnorePatterns(opts.workspaceRoot)
78590
+ }).tokens;
77608
78591
  const maybeRefreshRemotePriors = () => {
77609
78592
  if (opts.skipContextWriter || remoteInFlight) return;
77610
78593
  const now = Date.now();
@@ -77618,10 +78601,7 @@ function createWorkspaceEngine(opts) {
77618
78601
  const norm = normStackTokens;
77619
78602
  const seed = store.findNodesByLabel("Problem").sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt).slice(0, 6).map((p) => p.id);
77620
78603
  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 ?? []]),
78604
+ stack: outboundStack(),
77625
78605
  domains: norm(profile.domains),
77626
78606
  kinds: ["Pattern", "Technique", "AntiPattern"],
77627
78607
  ...seed.length ? { seed } : {},
@@ -77665,7 +78645,7 @@ function createWorkspaceEngine(opts) {
77665
78645
  // longer concatenates these tokens into the embedding string, it
77666
78646
  // re-weights anchored hits with them (stated beats derived — the
77667
78647
  // intent text drives entry search, the stack only re-ranks).
77668
- stack: normStackTokens([...profile?.stack ?? [], ...profile?.languages ?? []]),
78648
+ stack: outboundStack(),
77669
78649
  domains: normStackTokens(profile?.domains ?? []),
77670
78650
  kinds: ["Pattern", "Technique", "AntiPattern", "Problem", "Solution"],
77671
78651
  q: liveIntent,
@@ -77885,7 +78865,7 @@ function createWorkspaceEngine(opts) {
77885
78865
  resultSummary: { exitCode: e.exitCode ?? 1, errorTokens: e.errorTokens }
77886
78866
  });
77887
78867
  };
77888
- const turnCursorPath = join29(paths.configDir, "turn-cursors.json");
78868
+ const turnCursorPath = join30(paths.configDir, "turn-cursors.json");
77889
78869
  const lastTurnUuid = loadTurnCursors(turnCursorPath);
77890
78870
  const turnOffset = loadTurnOffsets(turnCursorPath);
77891
78871
  const readLosses = { parseFailures: 0, ioFailures: 0, bytesUnreachable: 0, sliceGuardHits: 0 };
@@ -77940,7 +78920,7 @@ function createWorkspaceEngine(opts) {
77940
78920
  let processedTurns = 0;
77941
78921
  const seqAtStart = store.currentIngestSeq();
77942
78922
  const elicit = isEdgeElicitationEnabled();
77943
- const handleMap = elicit ? readPrimingHandles(join29(paths.configDir, "priming-handles.json")) : {};
78923
+ const handleMap = elicit ? readPrimingHandles(join30(paths.configDir, "priming-handles.json")) : {};
77944
78924
  const wsRoot = (opts.workspaceRoot ?? "").replace(/\\/g, "/");
77945
78925
  const toRel = (abs) => {
77946
78926
  const p = abs.replace(/\\/g, "/");
@@ -78232,10 +79212,10 @@ function createWorkspaceEngine(opts) {
78232
79212
  let enclosing = {};
78233
79213
  if (p.location?.line !== void 0) {
78234
79214
  try {
78235
- const headSha = readGitRefState(join29(opts.workspaceRoot, ".git")).sha ?? void 0;
79215
+ const headSha = readGitRefState(join30(opts.workspaceRoot, ".git")).sha ?? void 0;
78236
79216
  enclosing = {
78237
79217
  line: p.location.line,
78238
- fileText: readFileSync24(join29(opts.workspaceRoot, anchorPath), "utf8"),
79218
+ fileText: readFileSync25(join30(opts.workspaceRoot, anchorPath), "utf8"),
78239
79219
  ...headSha ? { headSha } : {}
78240
79220
  };
78241
79221
  } catch {
@@ -78957,7 +79937,7 @@ B: ${b}`,
78957
79937
  try {
78958
79938
  const inputs = emitInputsFromManifest(paths.configDir, paths.skillsManifest);
78959
79939
  emitAndProjectSkills(opts.workspaceRoot, inputs);
78960
- writePrimingHandles(join29(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
79940
+ writePrimingHandles(join30(paths.configDir, "priming-handles.json"), skillHandleNodes(inputs));
78961
79941
  } catch (err2) {
78962
79942
  console.warn("[skills] agent-skills projection failed (non-fatal):", err2 instanceof Error ? err2.message : err2);
78963
79943
  }
@@ -79250,7 +80230,7 @@ B: ${b}`,
79250
80230
  console.log(
79251
80231
  "[errata] sync skipped \u2014 cloud sync consent is off (enable with `errata consent sync on`)"
79252
80232
  );
79253
- const pending = existsSync24(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
80233
+ const pending = existsSync25(paths.outbox) ? readdirSync10(paths.outbox).filter((f) => f.endsWith(".json")).length : 0;
79254
80234
  return { uploaded: 0, failed: 0, remaining: pending };
79255
80235
  }
79256
80236
  try {
@@ -79384,7 +80364,7 @@ async function startDaemon(opts) {
79384
80364
  );
79385
80365
  await engine.stop();
79386
80366
  try {
79387
- if (existsSync25(engine.paths.daemonLock)) {
80367
+ if (existsSync26(engine.paths.daemonLock)) {
79388
80368
  }
79389
80369
  } catch {
79390
80370
  }
@@ -79406,7 +80386,7 @@ init_identity2();
79406
80386
  // src/multi.ts
79407
80387
  init_dist();
79408
80388
  init_src5();
79409
- import { existsSync as existsSync31, readFileSync as readFileSync30, unlinkSync as unlinkSync3, writeFileSync as writeFileSync23 } from "node:fs";
80389
+ import { existsSync as existsSync32, readFileSync as readFileSync31, unlinkSync as unlinkSync3, writeFileSync as writeFileSync23 } from "node:fs";
79410
80390
 
79411
80391
  // src/principle-sync.ts
79412
80392
  init_src5();
@@ -79434,8 +80414,8 @@ init_reconcile();
79434
80414
 
79435
80415
  // src/lockfile-auto.ts
79436
80416
  init_src();
79437
- import { existsSync as existsSync26, readFileSync as readFileSync25 } from "node:fs";
79438
- import { join as join30 } from "node:path";
80417
+ import { existsSync as existsSync27, readFileSync as readFileSync26 } from "node:fs";
80418
+ import { join as join31 } from "node:path";
79439
80419
 
79440
80420
  // src/package-index.ts
79441
80421
  init_src();
@@ -79584,11 +80564,11 @@ function runLockfilePass(opts) {
79584
80564
  { file: "package-lock.json", parse: parsePackageLockJson }
79585
80565
  ];
79586
80566
  for (const c of candidates) {
79587
- const p = join30(opts.root, c.file);
79588
- if (!existsSync26(p)) continue;
80567
+ const p = join31(opts.root, c.file);
80568
+ if (!existsSync27(p)) continue;
79589
80569
  let sbom;
79590
80570
  try {
79591
- sbom = c.parse(readFileSync25(p, "utf8"));
80571
+ sbom = c.parse(readFileSync26(p, "utf8"));
79592
80572
  } catch {
79593
80573
  continue;
79594
80574
  }
@@ -79645,8 +80625,8 @@ function noveltyAgainst(node2, neighbors, opts = {}) {
79645
80625
  }
79646
80626
 
79647
80627
  // 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";
80628
+ import { readFileSync as readFileSync27, readdirSync as readdirSync11, existsSync as existsSync28 } from "node:fs";
80629
+ import { join as join32 } from "node:path";
79650
80630
  var HEAD_BYTES = 8 * 1024;
79651
80631
  var INDEX_TTL_MS = 10 * 60 * 1e3;
79652
80632
  var MIN_SYMBOL_LEN = 4;
@@ -79679,20 +80659,20 @@ function bindingNames(clause) {
79679
80659
  function internalPackageNames(workspaceRoot) {
79680
80660
  const names = /* @__PURE__ */ new Set();
79681
80661
  const tryRead = (dir) => {
79682
- const pj = join31(dir, "package.json");
79683
- if (!existsSync27(pj)) return;
80662
+ const pj = join32(dir, "package.json");
80663
+ if (!existsSync28(pj)) return;
79684
80664
  try {
79685
- const name2 = JSON.parse(readFileSync26(pj, "utf8")).name;
80665
+ const name2 = JSON.parse(readFileSync27(pj, "utf8")).name;
79686
80666
  if (typeof name2 === "string" && name2.length > 0) names.add(name2);
79687
80667
  } catch {
79688
80668
  }
79689
80669
  };
79690
80670
  tryRead(workspaceRoot);
79691
80671
  for (const group of ["packages", "apps"]) {
79692
- const groupDir = join31(workspaceRoot, group);
79693
- if (!existsSync27(groupDir)) continue;
80672
+ const groupDir = join32(workspaceRoot, group);
80673
+ if (!existsSync28(groupDir)) continue;
79694
80674
  try {
79695
- for (const entry of readdirSync11(groupDir)) tryRead(join31(groupDir, entry));
80675
+ for (const entry of readdirSync11(groupDir)) tryRead(join32(groupDir, entry));
79696
80676
  } catch {
79697
80677
  }
79698
80678
  }
@@ -79705,7 +80685,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
79705
80685
  if (cached2 && now - cached2.builtAt < INDEX_TTL_MS) return cached2;
79706
80686
  const readHead = deps.readHead ?? ((absPath) => {
79707
80687
  try {
79708
- return readFileSync26(absPath, "utf8").slice(0, HEAD_BYTES);
80688
+ return readFileSync27(absPath, "utf8").slice(0, HEAD_BYTES);
79709
80689
  } catch {
79710
80690
  return "";
79711
80691
  }
@@ -79725,7 +80705,7 @@ function publicSymbolIndex(store, workspaceRoot, deps = {}) {
79725
80705
  }
79726
80706
  const symbols = /* @__PURE__ */ new Set();
79727
80707
  for (const rel of files) {
79728
- const head2 = readHead(join31(workspaceRoot, rel));
80708
+ const head2 = readHead(join32(workspaceRoot, rel));
79729
80709
  if (!head2) continue;
79730
80710
  for (const re of [NAMED_IMPORT_RE, REQUIRE_RE]) {
79731
80711
  re.lastIndex = 0;
@@ -80356,7 +81336,7 @@ var ConsolidateWorker = class {
80356
81336
  init_paths();
80357
81337
 
80358
81338
  // src/lock.ts
80359
- import { existsSync as existsSync28, readFileSync as readFileSync27 } from "node:fs";
81339
+ import { existsSync as existsSync29, readFileSync as readFileSync28 } from "node:fs";
80360
81340
  function isProcessAlive(pid) {
80361
81341
  if (!pid || pid <= 0) return false;
80362
81342
  try {
@@ -80367,9 +81347,9 @@ function isProcessAlive(pid) {
80367
81347
  }
80368
81348
  }
80369
81349
  function readDaemonLock(lockPath) {
80370
- if (!existsSync28(lockPath)) return null;
81350
+ if (!existsSync29(lockPath)) return null;
80371
81351
  try {
80372
- const lock = JSON.parse(readFileSync27(lockPath, "utf8"));
81352
+ const lock = JSON.parse(readFileSync28(lockPath, "utf8"));
80373
81353
  return typeof lock.pid === "number" ? lock : null;
80374
81354
  } catch {
80375
81355
  return null;
@@ -80841,8 +81821,8 @@ async function hydrateProject(opts) {
80841
81821
  init_src7();
80842
81822
  init_src();
80843
81823
  import { execFile as execFile3 } from "node:child_process";
80844
- import { readFileSync as readFileSync29 } from "node:fs";
80845
- import { join as join33 } from "node:path";
81824
+ import { readFileSync as readFileSync30 } from "node:fs";
81825
+ import { join as join34 } from "node:path";
80846
81826
  import { promisify } from "node:util";
80847
81827
 
80848
81828
  // src/history-walk.ts
@@ -81064,8 +82044,8 @@ function narrative(unit, group) {
81064
82044
 
81065
82045
  // src/history-bundle.ts
81066
82046
  import { execFile as execFile2 } from "node:child_process";
81067
- import { readFileSync as readFileSync28 } from "node:fs";
81068
- import { join as join32 } from "node:path";
82047
+ import { readFileSync as readFileSync29 } from "node:fs";
82048
+ import { join as join33 } from "node:path";
81069
82049
 
81070
82050
  // ../../packages/privacy/src/patterns/credentials.ts
81071
82051
  var CREDENTIAL_PATTERNS = [
@@ -81847,7 +82827,7 @@ function pathAllowedByFloor(path2) {
81847
82827
  function loadRepoIgnore(root, extraPatterns = []) {
81848
82828
  let source = "";
81849
82829
  try {
81850
- source = readFileSync28(join32(root, ".errataignore"), "utf8");
82830
+ source = readFileSync29(join33(root, ".errataignore"), "utf8");
81851
82831
  } catch {
81852
82832
  source = "";
81853
82833
  }
@@ -82261,17 +83241,17 @@ async function defaultGit(root, args2) {
82261
83241
  function readIgnoreLines(root, profile) {
82262
83242
  let lines = [];
82263
83243
  try {
82264
- lines = readFileSync29(join33(root, ".errataignore"), "utf8").split("\n");
83244
+ lines = readFileSync30(join34(root, ".errataignore"), "utf8").split("\n");
82265
83245
  } catch {
82266
83246
  }
82267
83247
  return [...lines, ...profile.ignoreExtra ?? []].map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
82268
83248
  }
82269
83249
  async function spineForUnit(git3, root, unit) {
82270
83250
  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;
83251
+ const manifestPaths2 = listing.split("\n").map((l) => l.trim()).filter((p) => p && isManifestPath(p));
83252
+ if (manifestPaths2.length === 0) return void 0;
82273
83253
  const texts = /* @__PURE__ */ new Map();
82274
- for (const p of manifestPaths) {
83254
+ for (const p of manifestPaths2) {
82275
83255
  try {
82276
83256
  texts.set(p, await git3(root, ["show", `${unit.sha}:${p}`]));
82277
83257
  } catch {
@@ -82589,9 +83569,9 @@ async function startHistoryStage(root, input, client, walk10 = {}) {
82589
83569
  // src/link-flow.ts
82590
83570
  init_cloud_auth();
82591
83571
  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";
83572
+ import { execFileSync as execFileSync5 } from "node:child_process";
83573
+ import { existsSync as existsSync30, writeFileSync as writeFileSync22 } from "node:fs";
83574
+ import { join as join35 } from "node:path";
82595
83575
 
82596
83576
  // src/device-poll.ts
82597
83577
  var THROTTLED_POLL_MIN_WAIT_MS = 11e3;
@@ -82953,7 +83933,7 @@ async function linkThroughConsole(opts) {
82953
83933
  function collectRepoFacts(root) {
82954
83934
  const git3 = (args2) => {
82955
83935
  try {
82956
- return execFileSync4("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
83936
+ return execFileSync5("git", args2, { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
82957
83937
  } catch {
82958
83938
  return null;
82959
83939
  }
@@ -83024,8 +84004,8 @@ function applyLinkDecision(root, profile, config2, decision, now = Date.now) {
83024
84004
  delete nextProfile.projectLinkDisabled;
83025
84005
  let wroteIgnore = false;
83026
84006
  if (decision.writeIgnoreStarter !== false) {
83027
- const target = join34(root, ".errataignore");
83028
- if (!existsSync29(target)) {
84007
+ const target = join35(root, ".errataignore");
84008
+ if (!existsSync30(target)) {
83029
84009
  writeFileSync22(target, IGNORE_STARTER, "utf8");
83030
84010
  wroteIgnore = true;
83031
84011
  }
@@ -83038,12 +84018,12 @@ init_registry();
83038
84018
 
83039
84019
  // src/adopt.ts
83040
84020
  init_git_remote();
83041
- import { existsSync as existsSync30 } from "node:fs";
83042
- import { dirname as dirname12, join as join35 } from "node:path";
84021
+ import { existsSync as existsSync31 } from "node:fs";
84022
+ import { dirname as dirname12, join as join36 } from "node:path";
83043
84023
  function findGitRoot(absPath) {
83044
84024
  let dir = absPath;
83045
84025
  for (let depth = 0; depth < 64; depth++) {
83046
- if (existsSync30(join35(dir, ".git"))) return dir;
84026
+ if (existsSync31(join36(dir, ".git"))) return dir;
83047
84027
  const parent = dirname12(dir);
83048
84028
  if (parent === dir) return null;
83049
84029
  dir = parent;
@@ -83869,7 +84849,7 @@ async function startMultiDaemon(opts = {}) {
83869
84849
  lastActiveAt = Math.max(lastActiveAt, rec.engine.lastActivityAt());
83870
84850
  } catch {
83871
84851
  }
83872
- const reason = retireDecision({ exists: existsSync31(rec.root), lastActiveAt, now });
84852
+ const reason = retireDecision({ exists: existsSync32(rec.root), lastActiveAt, now });
83873
84853
  if (reason) void retireWorkspace(rec, reason);
83874
84854
  }
83875
84855
  };
@@ -84756,7 +85736,7 @@ async function startMultiDaemon(opts = {}) {
84756
85736
  clearInterval(anchorPull);
84757
85737
  clearTimeout(codexWakeBoot);
84758
85738
  try {
84759
- const cur = readFileSync30(lockPath, "utf8");
85739
+ const cur = readFileSync31(lockPath, "utf8");
84760
85740
  if (JSON.parse(cur).pid === process.pid) unlinkSync3(lockPath);
84761
85741
  } catch {
84762
85742
  }
@@ -85792,21 +86772,21 @@ async function cmdInit() {
85792
86772
  if (!skipHooks) {
85793
86773
  console.log("");
85794
86774
  console.log("installing harness hooks...");
85795
- const { existsSync: existsSync33 } = await import("node:fs");
85796
- const { join: join37 } = await import("node:path");
86775
+ const { existsSync: existsSync34 } = await import("node:fs");
86776
+ const { join: join38 } = await import("node:path");
85797
86777
  try {
85798
86778
  await installClaudeHooks(port);
85799
86779
  } catch (err2) {
85800
86780
  console.warn(` \u26A0\uFE0F Claude hook install failed: ${err2 instanceof Error ? err2.message : err2}`);
85801
86781
  }
85802
- if (existsSync33(join37(ROOT, ".cursor"))) {
86782
+ if (existsSync34(join38(ROOT, ".cursor"))) {
85803
86783
  try {
85804
86784
  await installCursorMcpConfig();
85805
86785
  } catch (err2) {
85806
86786
  console.warn(` \u26A0\uFE0F Cursor MCP config failed: ${err2 instanceof Error ? err2.message : err2}`);
85807
86787
  }
85808
86788
  }
85809
- if (existsSync33(join37(ROOT, ".codex"))) {
86789
+ if (existsSync34(join38(ROOT, ".codex"))) {
85810
86790
  try {
85811
86791
  await installCodexHooks(port);
85812
86792
  } catch (err2) {
@@ -85983,9 +86963,9 @@ async function cmdStatus() {
85983
86963
  console.log(` stack: ${profile.stack.join(", ") || "(none)"}`);
85984
86964
  console.log(` languages: ${profile.languages.join(", ") || "(none)"}`);
85985
86965
  }
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)) {
86966
+ console.log(` graph db: ${existsSync33(paths.castalia) ? "yes" : "no"} (${paths.castalia})`);
86967
+ console.log(` event log: ${existsSync33(paths.eventLog) ? "yes" : "no"} (${paths.eventLog})`);
86968
+ if (existsSync33(paths.castalia)) {
85989
86969
  try {
85990
86970
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
85991
86971
  const store = openGraphStore2({ path: paths.castalia });
@@ -86879,11 +87859,11 @@ function cmdInstallationProfile(args2) {
86879
87859
  }
86880
87860
  async function cmdReview() {
86881
87861
  const paths = workspacePaths(ROOT);
86882
- if (!existsSync32(paths.reviewQueue)) {
87862
+ if (!existsSync33(paths.reviewQueue)) {
86883
87863
  console.log("(review queue empty)");
86884
87864
  return;
86885
87865
  }
86886
- const queue = JSON.parse(readFileSync31(paths.reviewQueue, "utf8"));
87866
+ const queue = JSON.parse(readFileSync32(paths.reviewQueue, "utf8"));
86887
87867
  if (queue.length === 0) {
86888
87868
  console.log("(review queue empty)");
86889
87869
  return;
@@ -87554,7 +88534,7 @@ async function gatherRepo(store, ws) {
87554
88534
  };
87555
88535
  }
87556
88536
  async function gatherReportData(generatedAt) {
87557
- const { existsSync: existsSync33 } = await import("node:fs");
88537
+ const { existsSync: existsSync34 } = await import("node:fs");
87558
88538
  const { openGraphStore: openGraphStore2 } = await Promise.resolve().then(() => (init_src5(), src_exports2));
87559
88539
  const cfg = loadConfig();
87560
88540
  const outbound = cfg.consent.sync ? "auto" : "off";
@@ -87562,7 +88542,7 @@ async function gatherReportData(generatedAt) {
87562
88542
  for (const ws of listWorkspaces()) {
87563
88543
  if (ws.missing) continue;
87564
88544
  const dbPath = workspacePaths(ws.path).castalia;
87565
- if (!existsSync33(dbPath)) continue;
88545
+ if (!existsSync34(dbPath)) continue;
87566
88546
  let store = null;
87567
88547
  try {
87568
88548
  store = openGraphStore2({ path: dbPath });
@@ -87606,8 +88586,8 @@ async function cmdReport(args2) {
87606
88586
  const outDir = workspacePaths(ROOT).configDir;
87607
88587
  mkdirSync9(outDir, { recursive: true });
87608
88588
  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");
88589
+ for (const f of files) writeFileSync24(join37(outDir, f.name), f.html, "utf8");
88590
+ const indexPath = join37(outDir, "report.html");
87611
88591
  console.log(`report \u2192 ${indexPath}`);
87612
88592
  console.log(
87613
88593
  ` ${data.repos.length} repo(s) \xB7 ${files.length} file(s) \xB7 ${data.rollup.nodes.toLocaleString("en-US")} nodes`
@@ -87662,7 +88642,7 @@ function spawnDaemonDetached(options = {}) {
87662
88642
  try {
87663
88643
  const logPath = daemonLogPath();
87664
88644
  try {
87665
- if (statSync7(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
88645
+ if (statSync8(logPath).size > 5 * 1024 * 1024) renameSync4(logPath, `${logPath}.1`);
87666
88646
  } catch {
87667
88647
  }
87668
88648
  out2 = openSync2(logPath, "a");
@@ -87727,24 +88707,24 @@ async function cmdInstallHooks(args2) {
87727
88707
  }
87728
88708
  }
87729
88709
  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] ?? "";
88710
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88711
+ const { join: join38 } = await import("node:path");
88712
+ const dir = join38(ROOT, ".opencode", "plugin");
88713
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88714
+ const file2 = join38(dir, "inerrata.js");
88715
+ if (existsSync34(file2)) {
88716
+ const head2 = readFileSync33(file2, "utf8").split("\n")[0] ?? "";
87737
88717
  if (head2.trim() !== OPENCODE_PLUGIN_MARKER) {
87738
88718
  console.error(`refusing to overwrite ${file2}: not an errata-managed plugin (line 1 lacks the marker)`);
87739
88719
  process.exit(2);
87740
88720
  }
87741
88721
  }
87742
88722
  writeFileSync24(file2, buildOpencodePluginSource(port, { version: DAEMON_VERSION }), "utf8");
87743
- const cfgFile = join37(ROOT, "opencode.json");
88723
+ const cfgFile = join38(ROOT, "opencode.json");
87744
88724
  let cfg = { $schema: "https://opencode.ai/config.json" };
87745
- if (existsSync33(cfgFile)) {
88725
+ if (existsSync34(cfgFile)) {
87746
88726
  try {
87747
- cfg = JSON.parse(readFileSync32(cfgFile, "utf8"));
88727
+ cfg = JSON.parse(readFileSync33(cfgFile, "utf8"));
87748
88728
  } catch {
87749
88729
  console.error(`refusing to touch invalid JSON at ${cfgFile} \u2014 fix it and re-run`);
87750
88730
  process.exit(2);
@@ -87775,15 +88755,15 @@ function errataMcpInvocation() {
87775
88755
  return { command: cmd2, args: args2 };
87776
88756
  }
87777
88757
  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");
88758
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88759
+ const { join: join38 } = await import("node:path");
88760
+ const dir = join38(ROOT, ".claude");
88761
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88762
+ const file2 = join38(dir, "settings.json");
87783
88763
  let settings = {};
87784
- if (existsSync33(file2)) {
88764
+ if (existsSync34(file2)) {
87785
88765
  try {
87786
- settings = JSON.parse(readFileSync32(file2, "utf8"));
88766
+ settings = JSON.parse(readFileSync33(file2, "utf8"));
87787
88767
  } catch {
87788
88768
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87789
88769
  process.exit(2);
@@ -87832,7 +88812,7 @@ async function installClaudeHooks(port) {
87832
88812
  writeFileSync24(file2, JSON.stringify(settings, null, 2) + "\n", "utf8");
87833
88813
  console.log(`installed Claude Code hooks \u2192 ${file2}`);
87834
88814
  await installClaudeMcpConfig();
87835
- const claudeMd = join37(ROOT, "CLAUDE.md");
88815
+ const claudeMd = join38(ROOT, "CLAUDE.md");
87836
88816
  const recall = writeManagedBlock(claudeMd, { body: RECALL_FIRST_BLOCK });
87837
88817
  if (recall.kind === "collision") {
87838
88818
  console.warn(
@@ -87844,15 +88824,15 @@ async function installClaudeHooks(port) {
87844
88824
  console.log(` endpoint: http://127.0.0.1:${port}/api/hook`);
87845
88825
  }
87846
88826
  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");
88827
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88828
+ const { join: join38, dirname: dirname13 } = await import("node:path");
88829
+ const file2 = join38(ROOT, ".mcp.json");
87850
88830
  const dir = dirname13(file2);
87851
- if (!existsSync33(dir)) mkdirSync9(dir, { recursive: true });
88831
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
87852
88832
  let cfg = {};
87853
- if (existsSync33(file2)) {
88833
+ if (existsSync34(file2)) {
87854
88834
  try {
87855
- cfg = JSON.parse(readFileSync32(file2, "utf8"));
88835
+ cfg = JSON.parse(readFileSync33(file2, "utf8"));
87856
88836
  } catch {
87857
88837
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87858
88838
  process.exit(2);
@@ -87866,15 +88846,15 @@ async function installClaudeMcpConfig() {
87866
88846
  console.log(` Tools: errata.search / locate / neighbors / callers_of / what_uses / show / similar`);
87867
88847
  }
87868
88848
  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");
88849
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88850
+ const { join: join38 } = await import("node:path");
88851
+ const dir = join38(ROOT, ".cursor");
88852
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88853
+ const file2 = join38(dir, "mcp.json");
87874
88854
  let cfg = {};
87875
- if (existsSync33(file2)) {
88855
+ if (existsSync34(file2)) {
87876
88856
  try {
87877
- cfg = JSON.parse(readFileSync32(file2, "utf8"));
88857
+ cfg = JSON.parse(readFileSync33(file2, "utf8"));
87878
88858
  } catch {
87879
88859
  console.error(`refusing to overwrite invalid JSON at ${file2}`);
87880
88860
  process.exit(2);
@@ -87890,14 +88870,14 @@ async function installCursorMcpConfig() {
87890
88870
  console.log(` \u26A0\uFE0F reload Cursor (Cmd/Ctrl-Shift-P \u2192 "Reload Window") to pick it up.`);
87891
88871
  }
87892
88872
  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");
88873
+ const { mkdirSync: mkdirSync9, existsSync: existsSync34, readFileSync: readFileSync33, writeFileSync: writeFileSync24 } = await import("node:fs");
88874
+ const { join: join38 } = await import("node:path");
88875
+ const dir = join38(ROOT, ".codex");
88876
+ if (!existsSync34(dir)) mkdirSync9(dir, { recursive: true });
88877
+ const file2 = join38(dir, "config.toml");
87898
88878
  let existing = "";
87899
- if (existsSync33(file2)) {
87900
- existing = readFileSync32(file2, "utf8");
88879
+ if (existsSync34(file2)) {
88880
+ existing = readFileSync33(file2, "utf8");
87901
88881
  const beginIdx = existing.indexOf(CODEX_HOOKS_BEGIN);
87902
88882
  const endIdx = existing.indexOf(CODEX_HOOKS_END);
87903
88883
  if (beginIdx >= 0 && endIdx > beginIdx) {
@@ -88252,7 +89232,7 @@ async function cmdDash(args2) {
88252
89232
  await yieldToLoop2();
88253
89233
  try {
88254
89234
  const items = selectDurableMemory(handle2.sharedStore, r.engine.profile);
88255
- const res = bleedRules(join36(r.root, ".claude", "rules"), items);
89235
+ const res = bleedRules(join37(r.root, ".claude", "rules"), items);
88256
89236
  if (res.written || res.pruned) {
88257
89237
  console.log(
88258
89238
  `[rules:${r.entry.name}] ${res.written} collective principle(s) \u2192 .claude/rules` + (res.pruned ? `, ${res.pruned} pruned` : "")