opencode-swarm 7.76.0 → 7.76.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ var package_default;
69
69
  var init_package = __esm(() => {
70
70
  package_default = {
71
71
  name: "opencode-swarm",
72
- version: "7.76.0",
72
+ version: "7.76.2",
73
73
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
74
74
  main: "dist/index.js",
75
75
  types: "dist/index.d.ts",
@@ -17016,43 +17016,56 @@ var init_warning_buffer = __esm(() => {
17016
17016
 
17017
17017
  // src/config/bundled-skills.ts
17018
17018
  import * as fs3 from "node:fs";
17019
+ import * as fsp from "node:fs/promises";
17019
17020
  import * as path2 from "node:path";
17020
- function isSymbolicLink(p) {
17021
+ function getSyncCacheKey(projectDirectory, packageRoot) {
17022
+ return `${path2.resolve(projectDirectory)}\x00${path2.resolve(packageRoot)}`;
17023
+ }
17024
+ function warnBundledSkillSyncFailure(err2) {
17025
+ const message = err2 instanceof Error ? err2.message : String(err2);
17026
+ console.warn(`[opencode-swarm] Could not install bundled project skills; continuing without sync: ${message}`);
17027
+ }
17028
+ async function isSymbolicLinkAsync(p) {
17021
17029
  try {
17022
- return fs3.lstatSync(p).isSymbolicLink();
17030
+ return (await fsp.lstat(p)).isSymbolicLink();
17023
17031
  } catch {
17024
17032
  return false;
17025
17033
  }
17026
17034
  }
17027
- function ensureNotSymlinkedDirectory(p) {
17035
+ async function ensureNotSymlinkedDirectoryAsync(p) {
17028
17036
  try {
17029
- const stat2 = fs3.lstatSync(p);
17030
- return stat2.isDirectory() && !stat2.isSymbolicLink();
17037
+ const stat3 = await fsp.lstat(p);
17038
+ return stat3.isDirectory() && !stat3.isSymbolicLink();
17031
17039
  } catch (err2) {
17032
17040
  return err2.code === "ENOENT";
17033
17041
  }
17034
17042
  }
17035
- function getSyncCacheKey(projectDirectory, packageRoot) {
17036
- return `${path2.resolve(projectDirectory)}\x00${path2.resolve(packageRoot)}`;
17043
+ async function pathExistsAsync(p) {
17044
+ try {
17045
+ await fsp.access(p);
17046
+ return true;
17047
+ } catch {
17048
+ return false;
17049
+ }
17037
17050
  }
17038
- function collectBundledSkillFilesBounded(sourceDir, state, relativeDir = "") {
17051
+ async function collectBundledSkillFilesBoundedAsync(sourceDir, state, relativeDir = "") {
17039
17052
  const currentSource = path2.join(sourceDir, relativeDir);
17040
- const entries = fs3.readdirSync(currentSource, { withFileTypes: true });
17053
+ const entries = await fsp.readdir(currentSource, { withFileTypes: true });
17041
17054
  const files = [];
17042
17055
  for (const entry of entries) {
17043
17056
  const relativeEntry = path2.join(relativeDir, entry.name);
17044
17057
  const sourcePath = path2.join(sourceDir, relativeEntry);
17045
- if (entry.isSymbolicLink() || isSymbolicLink(sourcePath))
17058
+ if (entry.isSymbolicLink() || await isSymbolicLinkAsync(sourcePath))
17046
17059
  continue;
17047
17060
  if (entry.isDirectory()) {
17048
- files.push(...collectBundledSkillFilesBounded(sourceDir, state, relativeEntry));
17061
+ files.push(...await collectBundledSkillFilesBoundedAsync(sourceDir, state, relativeEntry));
17049
17062
  continue;
17050
17063
  }
17051
17064
  if (!entry.isFile())
17052
17065
  continue;
17053
- const stat2 = fs3.statSync(sourcePath);
17066
+ const stat3 = await fsp.stat(sourcePath);
17054
17067
  const nextFiles = state.files + 1;
17055
- const nextBytes = state.bytes + stat2.size;
17068
+ const nextBytes = state.bytes + stat3.size;
17056
17069
  if (nextFiles > MAX_SKILL_FILES || nextBytes > MAX_SKILL_BYTES) {
17057
17070
  throw new Error("bundled skill package exceeds copy bounds");
17058
17071
  }
@@ -17062,7 +17075,7 @@ function collectBundledSkillFilesBounded(sourceDir, state, relativeDir = "") {
17062
17075
  }
17063
17076
  return files;
17064
17077
  }
17065
- function rollbackCopiedFiles(copiedFiles, destDir) {
17078
+ async function rollbackCopiedFilesAsync(copiedFiles, destDir) {
17066
17079
  const safeDestDir = path2.resolve(destDir);
17067
17080
  const dirs = new Set;
17068
17081
  for (const copiedFile of copiedFiles) {
@@ -17071,7 +17084,7 @@ function rollbackCopiedFiles(copiedFiles, destDir) {
17071
17084
  if (relative2.startsWith("..") || path2.isAbsolute(relative2))
17072
17085
  continue;
17073
17086
  try {
17074
- fs3.rmSync(resolvedFile, { force: true });
17087
+ await fsp.rm(resolvedFile, { force: true });
17075
17088
  } catch {}
17076
17089
  dirs.add(path2.dirname(resolvedFile));
17077
17090
  }
@@ -17080,12 +17093,12 @@ function rollbackCopiedFiles(copiedFiles, destDir) {
17080
17093
  if (relative2.startsWith("..") || path2.isAbsolute(relative2))
17081
17094
  continue;
17082
17095
  try {
17083
- fs3.rmdirSync(dir);
17096
+ await fsp.rmdir(dir);
17084
17097
  } catch {}
17085
17098
  }
17086
17099
  }
17087
- function copyBundledDirectoryBounded(sourceDir, destDir) {
17088
- const files = collectBundledSkillFilesBounded(sourceDir, {
17100
+ async function copyBundledDirectoryBoundedAsync(sourceDir, destDir) {
17101
+ const files = await collectBundledSkillFilesBoundedAsync(sourceDir, {
17089
17102
  files: 0,
17090
17103
  bytes: 0
17091
17104
  });
@@ -17094,9 +17107,9 @@ function copyBundledDirectoryBounded(sourceDir, destDir) {
17094
17107
  for (const file2 of files) {
17095
17108
  const sourcePath = path2.join(sourceDir, file2.relativePath);
17096
17109
  const destPath = path2.join(destDir, file2.relativePath);
17097
- fs3.mkdirSync(path2.dirname(destPath), { recursive: true });
17110
+ await fsp.mkdir(path2.dirname(destPath), { recursive: true });
17098
17111
  try {
17099
- fs3.copyFileSync(sourcePath, destPath, fs3.constants.COPYFILE_EXCL);
17112
+ await fsp.copyFile(sourcePath, destPath, fs3.constants.COPYFILE_EXCL);
17100
17113
  copiedFiles.push(destPath);
17101
17114
  } catch (err2) {
17102
17115
  if (err2.code !== "EEXIST")
@@ -17104,15 +17117,11 @@ function copyBundledDirectoryBounded(sourceDir, destDir) {
17104
17117
  }
17105
17118
  }
17106
17119
  } catch (err2) {
17107
- rollbackCopiedFiles(copiedFiles, destDir);
17120
+ await rollbackCopiedFilesAsync(copiedFiles, destDir);
17108
17121
  throw err2;
17109
17122
  }
17110
17123
  }
17111
- function warnBundledSkillSyncFailure(err2) {
17112
- const message = err2 instanceof Error ? err2.message : String(err2);
17113
- console.warn(`[opencode-swarm] Could not install bundled project skills; continuing without sync: ${message}`);
17114
- }
17115
- function syncBundledProjectSkillsIfMissing(projectDirectory, packageRoot, quiet = false) {
17124
+ async function syncBundledProjectSkillsIfMissingAsync(projectDirectory, packageRoot, quiet = false) {
17116
17125
  try {
17117
17126
  const cacheKey = getSyncCacheKey(projectDirectory, packageRoot);
17118
17127
  if (syncedProjectSkillTargets.has(cacheKey))
@@ -17121,23 +17130,23 @@ function syncBundledProjectSkillsIfMissing(projectDirectory, packageRoot, quiet
17121
17130
  const opencodeDir = path2.join(projectDirectory, ".opencode");
17122
17131
  const skillsDir = path2.join(opencodeDir, "skills");
17123
17132
  let sawBundledSource = false;
17124
- if (!ensureNotSymlinkedDirectory(opencodeDir))
17133
+ if (!await ensureNotSymlinkedDirectoryAsync(opencodeDir))
17125
17134
  return;
17126
- if (!ensureNotSymlinkedDirectory(skillsDir))
17135
+ if (!await ensureNotSymlinkedDirectoryAsync(skillsDir))
17127
17136
  return;
17128
17137
  for (const slug of BUNDLED_PROJECT_SKILLS) {
17129
17138
  const sourceDir = path2.join(sourceRoot, slug);
17130
17139
  const sourceSkill = path2.join(sourceDir, "SKILL.md");
17131
17140
  const destDir = path2.join(skillsDir, slug);
17132
17141
  const destSkill = path2.join(destDir, "SKILL.md");
17133
- if (!fs3.existsSync(sourceSkill))
17142
+ if (!await pathExistsAsync(sourceSkill))
17134
17143
  continue;
17135
17144
  sawBundledSource = true;
17136
- if (fs3.existsSync(destSkill))
17145
+ if (await pathExistsAsync(destSkill))
17137
17146
  continue;
17138
- if (!ensureNotSymlinkedDirectory(destDir))
17147
+ if (!await ensureNotSymlinkedDirectoryAsync(destDir))
17139
17148
  continue;
17140
- copyBundledDirectoryBounded(sourceDir, destDir);
17149
+ await copyBundledDirectoryBoundedAsync(sourceDir, destDir);
17141
17150
  if (!quiet) {
17142
17151
  console.warn(`[opencode-swarm] Installed bundled skill .opencode/skills/${slug}/SKILL.md for first-class /swarm command support`);
17143
17152
  }
@@ -17918,21 +17927,21 @@ function hash2(content) {
17918
17927
  return createHash("sha256").update(content, "utf-8").digest("hex");
17919
17928
  }
17920
17929
  function readTextBounded(absPath) {
17921
- const stat3 = fs5.lstatSync(absPath);
17922
- if (!stat3.isFile() || stat3.size > MAX_SOURCE_BYTES) {
17930
+ const stat4 = fs5.lstatSync(absPath);
17931
+ if (!stat4.isFile() || stat4.size > MAX_SOURCE_BYTES) {
17923
17932
  return null;
17924
17933
  }
17925
17934
  return fs5.readFileSync(absPath, "utf-8");
17926
17935
  }
17927
17936
  function fileArtifact(root, absPath) {
17928
17937
  try {
17929
- const stat3 = fs5.lstatSync(absPath);
17930
- if (!stat3.isFile() || stat3.size > MAX_SOURCE_BYTES)
17938
+ const stat4 = fs5.lstatSync(absPath);
17939
+ if (!stat4.isFile() || stat4.size > MAX_SOURCE_BYTES)
17931
17940
  return null;
17932
17941
  return {
17933
17942
  relPath: toPosix(path6.relative(root, absPath)),
17934
- bytes: stat3.size,
17935
- mtimeMs: stat3.mtimeMs
17943
+ bytes: stat4.size,
17944
+ mtimeMs: stat4.mtimeMs
17936
17945
  };
17937
17946
  } catch {
17938
17947
  return null;
@@ -18223,14 +18232,14 @@ function readEffectiveSpecSync(directory) {
18223
18232
  const root = path6.resolve(directory);
18224
18233
  const swSpecPath = path6.join(root, SWARM_SPEC_REL);
18225
18234
  try {
18226
- const stat3 = fs5.lstatSync(swSpecPath);
18227
- if (stat3.isFile() && stat3.size <= MAX_SPEC_BYTES) {
18235
+ const stat4 = fs5.lstatSync(swSpecPath);
18236
+ if (stat4.isFile() && stat4.size <= MAX_SPEC_BYTES) {
18228
18237
  const content = fs5.readFileSync(swSpecPath, "utf-8");
18229
18238
  return {
18230
18239
  source: "swarm",
18231
18240
  content,
18232
18241
  hash: hash2(content),
18233
- mtime: stat3.mtime.toISOString(),
18242
+ mtime: stat4.mtime.toISOString(),
18234
18243
  sourcePaths: [toPosix(SWARM_SPEC_REL)],
18235
18244
  warnings: []
18236
18245
  };
@@ -18769,9 +18778,9 @@ var init_ledger = __esm(() => {
18769
18778
 
18770
18779
  // src/plan/manager.ts
18771
18780
  import {
18772
- copyFileSync as copyFileSync2,
18773
- existsSync as existsSync6,
18774
- readdirSync as readdirSync3,
18781
+ copyFileSync,
18782
+ existsSync as existsSync5,
18783
+ readdirSync as readdirSync2,
18775
18784
  renameSync as renameSync4,
18776
18785
  unlinkSync
18777
18786
  } from "node:fs";
@@ -19215,7 +19224,7 @@ async function savePlan(directory, plan, options) {
19215
19224
  const oldLedgerPath = path8.join(swarmDir2, "plan-ledger.jsonl");
19216
19225
  const oldLedgerBackupPath = path8.join(swarmDir2, `plan-ledger.backup-${Date.now()}-${Math.floor(Math.random() * 1e9)}.jsonl`);
19217
19226
  let backupExists = false;
19218
- if (existsSync6(oldLedgerPath)) {
19227
+ if (existsSync5(oldLedgerPath)) {
19219
19228
  try {
19220
19229
  renameSync4(oldLedgerPath, oldLedgerBackupPath);
19221
19230
  backupExists = true;
@@ -19232,15 +19241,15 @@ async function savePlan(directory, plan, options) {
19232
19241
  const errorMessage = String(initErr);
19233
19242
  if (errorMessage.includes("already initialized")) {
19234
19243
  try {
19235
- if (existsSync6(oldLedgerBackupPath))
19244
+ if (existsSync5(oldLedgerBackupPath))
19236
19245
  unlinkSync(oldLedgerBackupPath);
19237
19246
  } catch {}
19238
19247
  } else {
19239
- if (existsSync6(oldLedgerBackupPath)) {
19248
+ if (existsSync5(oldLedgerBackupPath)) {
19240
19249
  try {
19241
19250
  renameSync4(oldLedgerBackupPath, oldLedgerPath);
19242
19251
  } catch {
19243
- copyFileSync2(oldLedgerBackupPath, oldLedgerPath);
19252
+ copyFileSync(oldLedgerBackupPath, oldLedgerPath);
19244
19253
  try {
19245
19254
  unlinkSync(oldLedgerBackupPath);
19246
19255
  } catch {}
@@ -19258,19 +19267,19 @@ async function savePlan(directory, plan, options) {
19258
19267
  } catch (renameErr) {
19259
19268
  warn(`[savePlan] Could not archive old ledger (rename failed: ${renameErr instanceof Error ? renameErr.message : String(renameErr)}). Old ledger may still exist at ${oldLedgerBackupPath}.`);
19260
19269
  try {
19261
- if (existsSync6(oldLedgerBackupPath))
19270
+ if (existsSync5(oldLedgerBackupPath))
19262
19271
  unlinkSync(oldLedgerBackupPath);
19263
19272
  } catch {}
19264
19273
  }
19265
19274
  } else if (!initSucceeded && backupExists) {
19266
19275
  try {
19267
- if (existsSync6(oldLedgerBackupPath))
19276
+ if (existsSync5(oldLedgerBackupPath))
19268
19277
  unlinkSync(oldLedgerBackupPath);
19269
19278
  } catch {}
19270
19279
  }
19271
19280
  const MAX_ARCHIVED_SIBLINGS = 5;
19272
19281
  try {
19273
- const allFiles = readdirSync3(swarmDir2);
19282
+ const allFiles = readdirSync2(swarmDir2);
19274
19283
  const archivedSiblings = allFiles.filter((f) => f.startsWith("plan-ledger.archived-") && f.endsWith(".jsonl")).sort();
19275
19284
  if (archivedSiblings.length > MAX_ARCHIVED_SIBLINGS) {
19276
19285
  const toRemove = archivedSiblings.slice(0, archivedSiblings.length - MAX_ARCHIVED_SIBLINGS);
@@ -20067,11 +20076,11 @@ function handleAgentsCommand(agents, guardrails) {
20067
20076
  const temp = agent.config.temperature !== undefined ? agent.config.temperature.toString() : "default";
20068
20077
  const tools = agent.config.tools || {};
20069
20078
  const isReadOnly = tools.write === false || tools.edit === false;
20070
- const access2 = isReadOnly ? "\uD83D\uDD12 read-only" : "✏️ read-write";
20079
+ const access3 = isReadOnly ? "\uD83D\uDD12 read-only" : "✏️ read-write";
20071
20080
  const desc = agent.description || agent.config.description || "";
20072
20081
  const hasCustomProfile = guardrails?.profiles?.[key] !== undefined;
20073
20082
  const profileIndicator = hasCustomProfile ? " | ⚡ custom limits" : "";
20074
- lines.push(`- **${key}** | model: \`${model}\` | temp: ${temp} | ${access2}${profileIndicator}`);
20083
+ lines.push(`- **${key}** | model: \`${model}\` | temp: ${temp} | ${access3}${profileIndicator}`);
20075
20084
  if (desc) {
20076
20085
  lines.push(` ${desc}`);
20077
20086
  }
@@ -20679,8 +20688,8 @@ GFS4: `);
20679
20688
  }
20680
20689
  var fs$copyFile = fs8.copyFile;
20681
20690
  if (fs$copyFile)
20682
- fs8.copyFile = copyFile;
20683
- function copyFile(src, dest, flags2, cb) {
20691
+ fs8.copyFile = copyFile2;
20692
+ function copyFile2(src, dest, flags2, cb) {
20684
20693
  if (typeof flags2 === "function") {
20685
20694
  cb = flags2;
20686
20695
  flags2 = 0;
@@ -20698,9 +20707,9 @@ GFS4: `);
20698
20707
  }
20699
20708
  }
20700
20709
  var fs$readdir = fs8.readdir;
20701
- fs8.readdir = readdir;
20710
+ fs8.readdir = readdir2;
20702
20711
  var noReaddirOptionVersions = /^v[0-5]\./;
20703
- function readdir(path9, options, cb) {
20712
+ function readdir2(path9, options, cb) {
20704
20713
  if (typeof options === "function")
20705
20714
  cb = options, options = null;
20706
20715
  var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path10, options2, cb2, startTime) {
@@ -21289,11 +21298,11 @@ var require_mtime_precision = __commonJS((exports, module2) => {
21289
21298
  function probe(file2, fs7, callback) {
21290
21299
  const cachedPrecision = fs7[cacheSymbol];
21291
21300
  if (cachedPrecision) {
21292
- return fs7.stat(file2, (err2, stat3) => {
21301
+ return fs7.stat(file2, (err2, stat4) => {
21293
21302
  if (err2) {
21294
21303
  return callback(err2);
21295
21304
  }
21296
- callback(null, stat3.mtime, cachedPrecision);
21305
+ callback(null, stat4.mtime, cachedPrecision);
21297
21306
  });
21298
21307
  }
21299
21308
  const mtime = new Date(Math.ceil(Date.now() / 1000) * 1000 + 5);
@@ -21301,13 +21310,13 @@ var require_mtime_precision = __commonJS((exports, module2) => {
21301
21310
  if (err2) {
21302
21311
  return callback(err2);
21303
21312
  }
21304
- fs7.stat(file2, (err3, stat3) => {
21313
+ fs7.stat(file2, (err3, stat4) => {
21305
21314
  if (err3) {
21306
21315
  return callback(err3);
21307
21316
  }
21308
- const precision = stat3.mtime.getTime() % 1000 === 0 ? "s" : "ms";
21317
+ const precision = stat4.mtime.getTime() % 1000 === 0 ? "s" : "ms";
21309
21318
  Object.defineProperty(fs7, cacheSymbol, { value: precision });
21310
- callback(null, stat3.mtime, precision);
21319
+ callback(null, stat4.mtime, precision);
21311
21320
  });
21312
21321
  });
21313
21322
  }
@@ -21357,14 +21366,14 @@ var require_lockfile = __commonJS((exports, module2) => {
21357
21366
  if (options.stale <= 0) {
21358
21367
  return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
21359
21368
  }
21360
- options.fs.stat(lockfilePath, (err3, stat3) => {
21369
+ options.fs.stat(lockfilePath, (err3, stat4) => {
21361
21370
  if (err3) {
21362
21371
  if (err3.code === "ENOENT") {
21363
21372
  return acquireLock(file2, { ...options, stale: 0 }, callback);
21364
21373
  }
21365
21374
  return callback(err3);
21366
21375
  }
21367
- if (!isLockStale(stat3, options)) {
21376
+ if (!isLockStale(stat4, options)) {
21368
21377
  return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
21369
21378
  }
21370
21379
  removeLock(file2, options, (err4) => {
@@ -21376,8 +21385,8 @@ var require_lockfile = __commonJS((exports, module2) => {
21376
21385
  });
21377
21386
  });
21378
21387
  }
21379
- function isLockStale(stat3, options) {
21380
- return stat3.mtime.getTime() < Date.now() - options.stale;
21388
+ function isLockStale(stat4, options) {
21389
+ return stat4.mtime.getTime() < Date.now() - options.stale;
21381
21390
  }
21382
21391
  function removeLock(file2, options, callback) {
21383
21392
  options.fs.rmdir(getLockFile(file2, options), (err2) => {
@@ -21395,7 +21404,7 @@ var require_lockfile = __commonJS((exports, module2) => {
21395
21404
  lock2.updateDelay = lock2.updateDelay || options.update;
21396
21405
  lock2.updateTimeout = setTimeout(() => {
21397
21406
  lock2.updateTimeout = null;
21398
- options.fs.stat(lock2.lockfilePath, (err2, stat3) => {
21407
+ options.fs.stat(lock2.lockfilePath, (err2, stat4) => {
21399
21408
  const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
21400
21409
  if (err2) {
21401
21410
  if (err2.code === "ENOENT" || isOverThreshold) {
@@ -21404,7 +21413,7 @@ var require_lockfile = __commonJS((exports, module2) => {
21404
21413
  lock2.updateDelay = 1000;
21405
21414
  return updateLock(file2, options);
21406
21415
  }
21407
- const isMtimeOurs = lock2.mtime.getTime() === stat3.mtime.getTime();
21416
+ const isMtimeOurs = lock2.mtime.getTime() === stat4.mtime.getTime();
21408
21417
  if (!isMtimeOurs) {
21409
21418
  return setLockAsCompromised(file2, lock2, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
21410
21419
  }
@@ -21522,11 +21531,11 @@ var require_lockfile = __commonJS((exports, module2) => {
21522
21531
  if (err2) {
21523
21532
  return callback(err2);
21524
21533
  }
21525
- options.fs.stat(getLockFile(file3, options), (err3, stat3) => {
21534
+ options.fs.stat(getLockFile(file3, options), (err3, stat4) => {
21526
21535
  if (err3) {
21527
21536
  return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
21528
21537
  }
21529
- return callback(null, !isLockStale(stat3, options));
21538
+ return callback(null, !isLockStale(stat4, options));
21530
21539
  });
21531
21540
  });
21532
21541
  }
@@ -21733,8 +21742,8 @@ function listActiveLocks(directory) {
21733
21742
  continue;
21734
21743
  const lockPath = path9.join(locksDir, file2);
21735
21744
  try {
21736
- const stat3 = fs7.statSync(lockPath);
21737
- if (stat3.isFile()) {
21745
+ const stat4 = fs7.statSync(lockPath);
21746
+ if (stat4.isFile()) {
21738
21747
  const plLockDir = `${lockPath}.lock`;
21739
21748
  if (fs7.existsSync(plLockDir)) {
21740
21749
  const metaPath = getMetaPath(lockPath);
@@ -22013,11 +22022,11 @@ var init_task_id = __esm(() => {
22013
22022
 
22014
22023
  // src/evidence/manager.ts
22015
22024
  import {
22016
- mkdirSync as mkdirSync6,
22017
- readdirSync as readdirSync5,
22025
+ mkdirSync as mkdirSync5,
22026
+ readdirSync as readdirSync4,
22018
22027
  realpathSync,
22019
- rmSync as rmSync2,
22020
- statSync as statSync6
22028
+ rmSync,
22029
+ statSync as statSync5
22021
22030
  } from "node:fs";
22022
22031
  import * as fs8 from "node:fs/promises";
22023
22032
  import * as path10 from "node:path";
@@ -22046,11 +22055,11 @@ function validateProjectRoot(directory) {
22046
22055
  break;
22047
22056
  const parentSwarm = path10.join(parent, ".swarm");
22048
22057
  try {
22049
- if (statSync6(parentSwarm).isDirectory()) {
22058
+ if (statSync5(parentSwarm).isDirectory()) {
22050
22059
  let hasProjectIndicator = false;
22051
22060
  for (const indicator of PROJECT_INDICATORS) {
22052
22061
  try {
22053
- const indicatorStat = statSync6(path10.join(parent, indicator));
22062
+ const indicatorStat = statSync5(path10.join(parent, indicator));
22054
22063
  if (indicatorStat.isFile() || indicatorStat.isDirectory()) {
22055
22064
  hasProjectIndicator = true;
22056
22065
  break;
@@ -22124,14 +22133,14 @@ async function saveEvidence(directory, taskId, evidence) {
22124
22133
  if (bundleJson.length > EVIDENCE_MAX_JSON_BYTES) {
22125
22134
  throw new Error(`Evidence bundle size (${bundleJson.length} bytes) exceeds maximum (${EVIDENCE_MAX_JSON_BYTES} bytes)`);
22126
22135
  }
22127
- mkdirSync6(evidenceDir, { recursive: true });
22136
+ mkdirSync5(evidenceDir, { recursive: true });
22128
22137
  const tempPath = path10.join(evidenceDir, `evidence.json.tmp.${Date.now()}.${process.pid}`);
22129
22138
  try {
22130
22139
  await bunWrite(tempPath, bundleJson);
22131
22140
  await fs8.rename(tempPath, evidencePath);
22132
22141
  } catch (error49) {
22133
22142
  try {
22134
- rmSync2(tempPath, { force: true });
22143
+ rmSync(tempPath, { force: true });
22135
22144
  } catch {}
22136
22145
  throw error49;
22137
22146
  }
@@ -22190,7 +22199,7 @@ async function loadEvidence(directory, taskId) {
22190
22199
  await fs8.rename(tempPath, evidencePath);
22191
22200
  } catch (writeError) {
22192
22201
  try {
22193
- rmSync2(tempPath, { force: true });
22202
+ rmSync(tempPath, { force: true });
22194
22203
  } catch {}
22195
22204
  warn(`Failed to persist repaired flat retrospective for task ${sanitizedTaskId}: ${writeError instanceof Error ? writeError.message : String(writeError)}`);
22196
22205
  }
@@ -22217,13 +22226,13 @@ async function loadEvidence(directory, taskId) {
22217
22226
  async function listEvidenceTaskIds(directory) {
22218
22227
  const evidenceBasePath = validateSwarmPath(directory, "evidence");
22219
22228
  try {
22220
- statSync6(evidenceBasePath);
22229
+ statSync5(evidenceBasePath);
22221
22230
  } catch {
22222
22231
  return [];
22223
22232
  }
22224
22233
  let entries;
22225
22234
  try {
22226
- entries = readdirSync5(evidenceBasePath);
22235
+ entries = readdirSync4(evidenceBasePath);
22227
22236
  } catch {
22228
22237
  return [];
22229
22238
  }
@@ -22231,7 +22240,7 @@ async function listEvidenceTaskIds(directory) {
22231
22240
  for (const entry of entries) {
22232
22241
  const entryPath = path10.join(evidenceBasePath, entry);
22233
22242
  try {
22234
- const stats = statSync6(entryPath);
22243
+ const stats = statSync5(entryPath);
22235
22244
  if (!stats.isDirectory()) {
22236
22245
  continue;
22237
22246
  }
@@ -22250,12 +22259,12 @@ async function deleteEvidence(directory, taskId) {
22250
22259
  const relativePath = path10.join("evidence", sanitizedTaskId);
22251
22260
  const evidenceDir = validateSwarmPath(directory, relativePath);
22252
22261
  try {
22253
- statSync6(evidenceDir);
22262
+ statSync5(evidenceDir);
22254
22263
  } catch {
22255
22264
  return false;
22256
22265
  }
22257
22266
  try {
22258
- rmSync2(evidenceDir, { recursive: true, force: true });
22267
+ rmSync(evidenceDir, { recursive: true, force: true });
22259
22268
  return true;
22260
22269
  } catch (error49) {
22261
22270
  warn(`Failed to delete evidence for task ${sanitizedTaskId}: ${error49 instanceof Error ? error49.message : String(error49)}`);
@@ -22441,7 +22450,7 @@ var init_archive = __esm(() => {
22441
22450
  });
22442
22451
 
22443
22452
  // src/db/project-db.ts
22444
- import { existsSync as existsSync8, mkdirSync as mkdirSync7 } from "node:fs";
22453
+ import { existsSync as existsSync7, mkdirSync as mkdirSync6 } from "node:fs";
22445
22454
  import { createRequire as createRequire2 } from "node:module";
22446
22455
  import { join as join10, resolve as resolve7 } from "node:path";
22447
22456
  function loadDatabaseCtor() {
@@ -22476,7 +22485,7 @@ function projectDbPath(directory) {
22476
22485
  return join10(resolve7(directory), ".swarm", "swarm.db");
22477
22486
  }
22478
22487
  function projectDbExists(directory) {
22479
- return existsSync8(projectDbPath(directory));
22488
+ return existsSync7(projectDbPath(directory));
22480
22489
  }
22481
22490
  function getProjectDb(directory) {
22482
22491
  const key = resolve7(directory);
@@ -22484,7 +22493,7 @@ function getProjectDb(directory) {
22484
22493
  if (existing)
22485
22494
  return existing;
22486
22495
  const swarmDir = join10(key, ".swarm");
22487
- mkdirSync7(swarmDir, { recursive: true });
22496
+ mkdirSync6(swarmDir, { recursive: true });
22488
22497
  const Db = loadDatabaseCtor();
22489
22498
  const db = new Db(join10(swarmDir, "swarm.db"));
22490
22499
  db.run("PRAGMA journal_mode = WAL;");
@@ -25557,16 +25566,16 @@ function checkWriteTargetForSymlink(targetPath, cwd) {
25557
25566
  current = parent;
25558
25567
  }
25559
25568
  for (const ancestor of ancestors) {
25560
- let stat3 = null;
25569
+ let stat4 = null;
25561
25570
  try {
25562
- stat3 = fsSync2.lstatSync(ancestor);
25571
+ stat4 = fsSync2.lstatSync(ancestor);
25563
25572
  } catch (err2) {
25564
25573
  const code = err2.code;
25565
25574
  if (code === "ENOENT")
25566
25575
  continue;
25567
25576
  return `WRITE BLOCKED: lstat failed on "${ancestor}": ${String(err2)} — refusing write on unverifiable path`;
25568
25577
  }
25569
- if (stat3.isSymbolicLink()) {
25578
+ if (stat4.isSymbolicLink()) {
25570
25579
  return `WRITE BLOCKED: "${ancestor}" is a symlink — writing through a symlink could redirect the write outside the working directory`;
25571
25580
  }
25572
25581
  }
@@ -26359,9 +26368,9 @@ function dcLstatAncestorWalk(targetPath, cwd) {
26359
26368
  current = parent;
26360
26369
  }
26361
26370
  for (const ancestor of ancestors) {
26362
- let stat3 = null;
26371
+ let stat4 = null;
26363
26372
  try {
26364
- stat3 = fsSync3.lstatSync(ancestor);
26373
+ stat4 = fsSync3.lstatSync(ancestor);
26365
26374
  } catch (err2) {
26366
26375
  const code = err2.code;
26367
26376
  if (code === "ENOENT") {
@@ -26369,7 +26378,7 @@ function dcLstatAncestorWalk(targetPath, cwd) {
26369
26378
  }
26370
26379
  return `lstat failed on "${ancestor}": ${String(err2)} — refusing to allow destructive operation on unverifiable path`;
26371
26380
  }
26372
- if (stat3.isSymbolicLink()) {
26381
+ if (stat4.isSymbolicLink()) {
26373
26382
  return `BLOCKED: "${ancestor}" is a symlink/junction — deleting recursively through it would destroy the link target. Use platform-specific junction deletion (fsutil reparsepoint delete, Remove-Item without -Recurse) instead.`;
26374
26383
  }
26375
26384
  }
@@ -28458,13 +28467,13 @@ function readScopeFromDisk(directory, taskId) {
28458
28467
  }
28459
28468
  let raw;
28460
28469
  try {
28461
- const stat3 = fs12.fstatSync(fd);
28462
- if (!stat3.isFile())
28470
+ const stat4 = fs12.fstatSync(fd);
28471
+ if (!stat4.isFile())
28463
28472
  return null;
28464
- if (stat3.size > MAX_SCOPE_BYTES)
28473
+ if (stat4.size > MAX_SCOPE_BYTES)
28465
28474
  return null;
28466
- const buf = Buffer.alloc(stat3.size);
28467
- fs12.readSync(fd, buf, 0, stat3.size, 0);
28475
+ const buf = Buffer.alloc(stat4.size);
28476
+ fs12.readSync(fd, buf, 0, stat4.size, 0);
28468
28477
  raw = buf.toString("utf-8");
28469
28478
  } catch {
28470
28479
  return null;
@@ -28504,10 +28513,10 @@ function readPlanScope(directory, taskId) {
28504
28513
  return null;
28505
28514
  try {
28506
28515
  const planPath = path19.join(directory, ".swarm", "plan.json");
28507
- const stat3 = fs12.statSync(planPath);
28508
- if (!stat3.isFile())
28516
+ const stat4 = fs12.statSync(planPath);
28517
+ if (!stat4.isFile())
28509
28518
  return null;
28510
- if (stat3.size > MAX_PLAN_BYTES)
28519
+ if (stat4.size > MAX_PLAN_BYTES)
28511
28520
  return null;
28512
28521
  const raw = fs12.readFileSync(planPath, "utf-8");
28513
28522
  const plan = JSON.parse(raw);
@@ -42397,7 +42406,7 @@ __export(exports_gate_evidence, {
42397
42406
  deriveRequiredGates: () => deriveRequiredGates,
42398
42407
  DEFAULT_REQUIRED_GATES: () => DEFAULT_REQUIRED_GATES
42399
42408
  });
42400
- import { mkdirSync as mkdirSync11, readFileSync as readFileSync7, realpathSync as realpathSync5 } from "node:fs";
42409
+ import { mkdirSync as mkdirSync10, readFileSync as readFileSync7, realpathSync as realpathSync5 } from "node:fs";
42401
42410
  import * as path26 from "node:path";
42402
42411
  function isValidTaskId(taskId) {
42403
42412
  return isStrictTaskId(taskId);
@@ -42435,7 +42444,7 @@ function expandRequiredGates(existingGates, newAgentType) {
42435
42444
  function getEvidenceDir(directory) {
42436
42445
  const swarmDir = path26.resolve(directory, ".swarm");
42437
42446
  const evidenceDir = path26.join(swarmDir, "evidence");
42438
- mkdirSync11(evidenceDir, { recursive: true });
42447
+ mkdirSync10(evidenceDir, { recursive: true });
42439
42448
  let resolvedSwarmDir;
42440
42449
  let resolvedEvidenceDir;
42441
42450
  try {
@@ -58788,6 +58797,14 @@ var init_branch = __esm(() => {
58788
58797
  };
58789
58798
  });
58790
58799
 
58800
+ // src/hooks/abort-utils.ts
58801
+ function isAbortError(err2) {
58802
+ if (typeof err2 !== "object" || err2 === null)
58803
+ return false;
58804
+ const name2 = err2.name;
58805
+ return name2 === "AbortError" || name2 === "TimeoutError";
58806
+ }
58807
+
58791
58808
  // src/hooks/curator-llm-factory.ts
58792
58809
  function resolveCuratorAgentName(mode, sessionId) {
58793
58810
  const suffixMap = {
@@ -58856,13 +58873,19 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
58856
58873
  }
58857
58874
  };
58858
58875
  if (signal?.aborted) {
58859
- cleanup();
58860
58876
  throw new Error("CURATOR_LLM_TIMEOUT");
58861
58877
  }
58862
- signal?.addEventListener("abort", cleanup, { once: true });
58878
+ const sdkOpts = signal ? { signal } : {};
58863
58879
  try {
58864
58880
  const createResult = await client.session.create({
58865
- query: { directory }
58881
+ ...sessionId ? {
58882
+ body: {
58883
+ parentID: sessionId,
58884
+ title: `curator_${mode} background`
58885
+ }
58886
+ } : {},
58887
+ query: { directory },
58888
+ ...sdkOpts
58866
58889
  });
58867
58890
  if (!createResult.data) {
58868
58891
  throw new Error(`Failed to create curator session: ${JSON.stringify(createResult.error)}`);
@@ -58872,30 +58895,27 @@ function createCuratorLLMDelegate(directory, mode = "init", sessionId) {
58872
58895
  throw new Error("CURATOR_LLM_TIMEOUT");
58873
58896
  }
58874
58897
  const agentName = resolveCuratorAgentName(mode, sessionId);
58875
- let promptResult;
58876
- try {
58877
- promptResult = await client.session.prompt({
58878
- path: { id: ephemeralSessionId },
58879
- body: {
58880
- agent: agentName,
58881
- tools: { write: false, edit: false, patch: false },
58882
- parts: [{ type: "text", text: userInput }]
58883
- }
58884
- });
58885
- } catch (promptErr) {
58886
- if (signal?.aborted) {
58887
- throw new Error("CURATOR_LLM_TIMEOUT");
58888
- }
58889
- throw promptErr;
58890
- }
58898
+ const promptResult = await client.session.prompt({
58899
+ path: { id: ephemeralSessionId },
58900
+ body: {
58901
+ agent: agentName,
58902
+ tools: { write: false, edit: false, patch: false },
58903
+ parts: [{ type: "text", text: userInput }]
58904
+ },
58905
+ ...sdkOpts
58906
+ });
58891
58907
  if (!promptResult.data) {
58892
58908
  throw new Error(`Curator LLM prompt failed: ${JSON.stringify(promptResult.error)}`);
58893
58909
  }
58894
58910
  const textParts = promptResult.data.parts.filter((p) => p.type === "text");
58895
58911
  return textParts.map((p) => p.text).join(`
58896
58912
  `);
58913
+ } catch (err2) {
58914
+ if (isAbortError(err2)) {
58915
+ throw new Error("CURATOR_LLM_TIMEOUT");
58916
+ }
58917
+ throw err2;
58897
58918
  } finally {
58898
- signal?.removeEventListener("abort", cleanup);
58899
58919
  cleanup();
58900
58920
  }
58901
58921
  };
@@ -59350,8 +59370,8 @@ __export(exports_knowledge_store, {
59350
59370
  _internals: () => _internals22,
59351
59371
  OUTCOME_SIGNAL_SMOOTHING: () => OUTCOME_SIGNAL_SMOOTHING
59352
59372
  });
59353
- import { existsSync as existsSync14 } from "node:fs";
59354
- import { appendFile as appendFile3, mkdir as mkdir3, readFile as readFile4 } from "node:fs/promises";
59373
+ import { existsSync as existsSync13 } from "node:fs";
59374
+ import { appendFile as appendFile3, mkdir as mkdir4, readFile as readFile4 } from "node:fs/promises";
59355
59375
  import * as os9 from "node:os";
59356
59376
  import * as path31 from "node:path";
59357
59377
  function getPlatformConfigDir() {
@@ -59392,7 +59412,7 @@ function resolveHiveRejectedPath() {
59392
59412
  return path31.join(path31.dirname(hivePath), "shared-learnings-rejected.jsonl");
59393
59413
  }
59394
59414
  async function readKnowledge(filePath) {
59395
- if (!existsSync14(filePath))
59415
+ if (!existsSync13(filePath))
59396
59416
  return [];
59397
59417
  const content = await readFile4(filePath, "utf-8");
59398
59418
  const results = [];
@@ -59487,7 +59507,7 @@ async function appendRetractionRecord(directory, record3) {
59487
59507
  }
59488
59508
  async function appendKnowledge(filePath, entry) {
59489
59509
  const dir = path31.dirname(filePath);
59490
- await mkdir3(dir, { recursive: true });
59510
+ await mkdir4(dir, { recursive: true });
59491
59511
  let release = null;
59492
59512
  try {
59493
59513
  release = await import_proper_lockfile3.default.lock(dir, {
@@ -59506,7 +59526,7 @@ async function appendKnowledge(filePath, entry) {
59506
59526
  }
59507
59527
  async function rewriteKnowledge(filePath, entries) {
59508
59528
  const dir = path31.dirname(filePath);
59509
- await mkdir3(dir, { recursive: true });
59529
+ await mkdir4(dir, { recursive: true });
59510
59530
  let release = null;
59511
59531
  try {
59512
59532
  release = await import_proper_lockfile3.default.lock(dir, {
@@ -59528,7 +59548,7 @@ async function rewriteKnowledge(filePath, entries) {
59528
59548
  async function transactFile(filePath, read, write, mutate) {
59529
59549
  const dir = path31.dirname(filePath);
59530
59550
  try {
59531
- await mkdir3(dir, { recursive: true });
59551
+ await mkdir4(dir, { recursive: true });
59532
59552
  } catch {
59533
59553
  return false;
59534
59554
  }
@@ -59789,7 +59809,7 @@ async function applyConfidenceDeltas(filePath, deltas) {
59789
59809
  let release = null;
59790
59810
  try {
59791
59811
  const dir = path31.dirname(filePath);
59792
- await mkdir3(dir, { recursive: true });
59812
+ await mkdir4(dir, { recursive: true });
59793
59813
  release = await import_proper_lockfile3.default.lock(dir, {
59794
59814
  retries: { retries: 5, minTimeout: 100, maxTimeout: 500 },
59795
59815
  stale: 5000
@@ -59879,8 +59899,8 @@ __export(exports_knowledge_events, {
59879
59899
  KNOWLEDGE_EVENT_SCHEMA_VERSION: () => KNOWLEDGE_EVENT_SCHEMA_VERSION
59880
59900
  });
59881
59901
  import { randomUUID as randomUUID2 } from "node:crypto";
59882
- import { existsSync as existsSync15 } from "node:fs";
59883
- import { appendFile as appendFile4, mkdir as mkdir4, readFile as readFile5, stat as stat3 } from "node:fs/promises";
59902
+ import { existsSync as existsSync14 } from "node:fs";
59903
+ import { appendFile as appendFile4, mkdir as mkdir5, readFile as readFile5, stat as stat4 } from "node:fs/promises";
59884
59904
  import * as path32 from "node:path";
59885
59905
  function resolveKnowledgeEventsPath(directory) {
59886
59906
  return path32.join(directory, ".swarm", "knowledge-events.jsonl");
@@ -59909,7 +59929,7 @@ async function appendKnowledgeEvent(directory, event) {
59909
59929
  const populated = withDefaults(event);
59910
59930
  const filePath = resolveKnowledgeEventsPath(directory);
59911
59931
  const dirPath = path32.dirname(filePath);
59912
- await mkdir4(dirPath, { recursive: true });
59932
+ await mkdir5(dirPath, { recursive: true });
59913
59933
  let release;
59914
59934
  try {
59915
59935
  release = await import_proper_lockfile4.default.lock(dirPath, {
@@ -59948,7 +59968,7 @@ async function recordKnowledgeEvent(directory, event) {
59948
59968
  }
59949
59969
  async function readKnowledgeEvents(directory) {
59950
59970
  const filePath = resolveKnowledgeEventsPath(directory);
59951
- if (!existsSync15(filePath))
59971
+ if (!existsSync14(filePath))
59952
59972
  return [];
59953
59973
  const content = await readFile5(filePath, "utf-8");
59954
59974
  return parseEventLines(content.split(`
@@ -59956,7 +59976,7 @@ async function readKnowledgeEvents(directory) {
59956
59976
  }
59957
59977
  async function readLegacyApplicationRecords(directory) {
59958
59978
  const filePath = resolveLegacyApplicationLogPath(directory);
59959
- if (!existsSync15(filePath))
59979
+ if (!existsSync14(filePath))
59960
59980
  return [];
59961
59981
  const content = await readFile5(filePath, "utf-8");
59962
59982
  const out2 = [];
@@ -60046,7 +60066,7 @@ function maxIso(current, candidate) {
60046
60066
  }
60047
60067
  async function readCounterBaseline(directory) {
60048
60068
  const filePath = resolveKnowledgeCounterBaselinePath(directory);
60049
- if (!existsSync15(filePath))
60069
+ if (!existsSync14(filePath))
60050
60070
  return new Map;
60051
60071
  const raw = JSON.parse(await readFile5(filePath, "utf-8"));
60052
60072
  const map3 = new Map;
@@ -60066,7 +60086,7 @@ async function writeCounterBaseline(directory, baseline) {
60066
60086
  }
60067
60087
  async function statCacheKey(filePath) {
60068
60088
  try {
60069
- const fileStat = await stat3(filePath);
60089
+ const fileStat = await stat4(filePath);
60070
60090
  return `${fileStat.mtimeMs}:${fileStat.ctimeMs}:${fileStat.size}`;
60071
60091
  } catch (err2) {
60072
60092
  if (err2?.code === "ENOENT")
@@ -60361,7 +60381,7 @@ var init_knowledge_events = __esm(() => {
60361
60381
  });
60362
60382
 
60363
60383
  // src/hooks/knowledge-escalator.ts
60364
- import { existsSync as existsSync16 } from "node:fs";
60384
+ import { existsSync as existsSync15 } from "node:fs";
60365
60385
  function isFullyEscalated(e) {
60366
60386
  return e.directive_priority === "critical" && e.enforcement_mode === "enforce";
60367
60387
  }
@@ -60373,7 +60393,7 @@ async function maybeEscalateOnViolation(directory, entryId, now = new Date) {
60373
60393
  const allEntries = [];
60374
60394
  allEntries.push(...await readKnowledge(resolveSwarmKnowledgePath(directory)));
60375
60395
  const hivePath = resolveHiveKnowledgePath();
60376
- if (existsSync16(hivePath)) {
60396
+ if (existsSync15(hivePath)) {
60377
60397
  allEntries.push(...await readKnowledge(hivePath));
60378
60398
  }
60379
60399
  const target = allEntries.find((e) => e.id === entryId);
@@ -60428,7 +60448,7 @@ async function maybeEscalateOnViolation(directory, entryId, now = new Date) {
60428
60448
  await transactKnowledge(resolveSwarmKnowledgePath(directory), mutate);
60429
60449
  if (state.outcome.kind === "not_found") {
60430
60450
  const hivePath = resolveHiveKnowledgePath();
60431
- if (existsSync16(hivePath)) {
60451
+ if (existsSync15(hivePath)) {
60432
60452
  await transactKnowledge(hivePath, mutate);
60433
60453
  }
60434
60454
  }
@@ -60900,7 +60920,7 @@ var init_learning_metrics = __esm(() => {
60900
60920
  });
60901
60921
 
60902
60922
  // src/hooks/knowledge-validator.ts
60903
- import { appendFile as appendFile5, mkdir as mkdir5 } from "node:fs/promises";
60923
+ import { appendFile as appendFile5, mkdir as mkdir6 } from "node:fs/promises";
60904
60924
  import * as path33 from "node:path";
60905
60925
  function normalizeText(text) {
60906
60926
  return text.normalize("NFKC").toLowerCase().replace(/[^\w\s]/g, " ").replace(/\s+/g, " ").trim();
@@ -61171,7 +61191,7 @@ function resolveUnactionablePath(directory) {
61171
61191
  async function appendUnactionable(directory, entry, reason) {
61172
61192
  const filePath = resolveUnactionablePath(directory);
61173
61193
  const dirPath = path33.dirname(filePath);
61174
- await mkdir5(dirPath, { recursive: true });
61194
+ await mkdir6(dirPath, { recursive: true });
61175
61195
  await transactKnowledge(filePath, (existing) => {
61176
61196
  const record3 = {
61177
61197
  ...entry,
@@ -61208,7 +61228,7 @@ async function quarantineEntry(directory, entryId, reason, reportedBy) {
61208
61228
  const quarantinePath = path33.join(directory, ".swarm", "knowledge-quarantined.jsonl");
61209
61229
  const rejectedPath = path33.join(directory, ".swarm", "knowledge-rejected.jsonl");
61210
61230
  const swarmDir = path33.join(directory, ".swarm");
61211
- await mkdir5(swarmDir, { recursive: true });
61231
+ await mkdir6(swarmDir, { recursive: true });
61212
61232
  let release;
61213
61233
  try {
61214
61234
  release = await import_proper_lockfile5.default.lock(swarmDir, {
@@ -61272,7 +61292,7 @@ async function restoreEntry(directory, entryId) {
61272
61292
  const quarantinePath = path33.join(directory, ".swarm", "knowledge-quarantined.jsonl");
61273
61293
  const rejectedPath = path33.join(directory, ".swarm", "knowledge-rejected.jsonl");
61274
61294
  const swarmDir = path33.join(directory, ".swarm");
61275
- await mkdir5(swarmDir, { recursive: true });
61295
+ await mkdir6(swarmDir, { recursive: true });
61276
61296
  let release;
61277
61297
  try {
61278
61298
  release = await import_proper_lockfile5.default.lock(swarmDir, {
@@ -61450,7 +61470,7 @@ var init_knowledge_validator = __esm(() => {
61450
61470
  });
61451
61471
 
61452
61472
  // src/services/skill-changelog.ts
61453
- import { appendFile as appendFile6, mkdir as mkdir6, readFile as readFile6, writeFile as writeFile3 } from "node:fs/promises";
61473
+ import { appendFile as appendFile6, mkdir as mkdir7, readFile as readFile6, writeFile as writeFile3 } from "node:fs/promises";
61454
61474
  import * as path34 from "node:path";
61455
61475
  function resolveSkillChangelogPath(directory, slug) {
61456
61476
  if (slug.includes("..") || slug.includes("/") || slug.includes("\\")) {
@@ -61461,7 +61481,7 @@ function resolveSkillChangelogPath(directory, slug) {
61461
61481
  async function appendSkillChangelog(directory, slug, entry) {
61462
61482
  const filePath = resolveSkillChangelogPath(directory, slug);
61463
61483
  const dirPath = path34.dirname(filePath);
61464
- await mkdir6(dirPath, { recursive: true });
61484
+ await mkdir7(dirPath, { recursive: true });
61465
61485
  await appendFile6(filePath, `${JSON.stringify(entry)}
61466
61486
  `, "utf-8");
61467
61487
  try {
@@ -61508,8 +61528,8 @@ __export(exports_skill_generator, {
61508
61528
  DEFAULT_SKILL_MIN_CONFIRMATIONS: () => DEFAULT_SKILL_MIN_CONFIRMATIONS,
61509
61529
  DEFAULT_SKILL_MIN_CONFIDENCE: () => DEFAULT_SKILL_MIN_CONFIDENCE
61510
61530
  });
61511
- import { existsSync as existsSync17, unlinkSync as unlinkSync5 } from "node:fs";
61512
- import { mkdir as mkdir7, readFile as readFile7, rename as rename3, writeFile as writeFile4 } from "node:fs/promises";
61531
+ import { existsSync as existsSync16, unlinkSync as unlinkSync5 } from "node:fs";
61532
+ import { mkdir as mkdir8, readFile as readFile7, rename as rename3, writeFile as writeFile4 } from "node:fs/promises";
61513
61533
  import * as path35 from "node:path";
61514
61534
  function sanitizeSlug(input) {
61515
61535
  const lc = input.toLowerCase().trim();
@@ -61532,7 +61552,7 @@ function activeRepoRelativePath(slug) {
61532
61552
  async function selectCandidateEntries(directory, opts) {
61533
61553
  const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
61534
61554
  const hivePath = resolveHiveKnowledgePath();
61535
- const hive = existsSync17(hivePath) ? await readKnowledge(hivePath) : [];
61555
+ const hive = existsSync16(hivePath) ? await readKnowledge(hivePath) : [];
61536
61556
  const all = [...swarm, ...hive];
61537
61557
  const counterRollups = await readKnowledgeCounterRollups(directory);
61538
61558
  const selected = [];
@@ -61733,7 +61753,7 @@ function escapeMarkdown(s) {
61733
61753
  return s.replace(/[\r\n]+/g, " ").slice(0, 280);
61734
61754
  }
61735
61755
  async function atomicWrite2(p, content) {
61736
- await mkdir7(path35.dirname(p), { recursive: true });
61756
+ await mkdir8(path35.dirname(p), { recursive: true });
61737
61757
  const tmp = `${p}.tmp-${process.pid}-${Date.now()}`;
61738
61758
  await writeFile4(tmp, content, "utf-8");
61739
61759
  await rename3(tmp, p);
@@ -61750,7 +61770,7 @@ async function generateSkills(req) {
61750
61770
  const idSet = new Set(req.sourceKnowledgeIds);
61751
61771
  const swarm = await readKnowledge(resolveSwarmKnowledgePath(req.directory));
61752
61772
  const hivePath = resolveHiveKnowledgePath();
61753
- const hive = existsSync17(hivePath) ? await readKnowledge(hivePath) : [];
61773
+ const hive = existsSync16(hivePath) ? await readKnowledge(hivePath) : [];
61754
61774
  pool = [...swarm, ...hive].filter((e) => idSet.has(e.id) && e.status !== "archived");
61755
61775
  } else {
61756
61776
  pool = candidates;
@@ -61787,7 +61807,7 @@ async function generateSkills(req) {
61787
61807
  continue;
61788
61808
  }
61789
61809
  let preserved = false;
61790
- if (req.mode === "active" && existsSync17(targetPath) && !req.force) {
61810
+ if (req.mode === "active" && existsSync16(targetPath) && !req.force) {
61791
61811
  const existing = await readFile7(targetPath, "utf-8");
61792
61812
  if (!existing.includes("generated by opencode-swarm skill-generator")) {
61793
61813
  preserved = true;
@@ -61832,7 +61852,7 @@ async function stampSourceEntries(directory, slug, ids) {
61832
61852
  if (touched)
61833
61853
  await rewriteKnowledge(swarmPath, swarm);
61834
61854
  const hivePath = resolveHiveKnowledgePath();
61835
- if (!existsSync17(hivePath))
61855
+ if (!existsSync16(hivePath))
61836
61856
  return;
61837
61857
  const hive = await readKnowledge(hivePath);
61838
61858
  let touchedHive = false;
@@ -61930,7 +61950,7 @@ async function activateProposal(directory, slug, force = false) {
61930
61950
  }
61931
61951
  const from = proposalPath(directory, cleanSlug);
61932
61952
  const to = activePath(directory, cleanSlug);
61933
- if (!existsSync17(from)) {
61953
+ if (!existsSync16(from)) {
61934
61954
  return {
61935
61955
  activated: false,
61936
61956
  from,
@@ -61938,7 +61958,7 @@ async function activateProposal(directory, slug, force = false) {
61938
61958
  reason: `proposal not found: ${from}`
61939
61959
  };
61940
61960
  }
61941
- if (existsSync17(to) && !force) {
61961
+ if (existsSync16(to) && !force) {
61942
61962
  const existing = await readFile7(to, "utf-8");
61943
61963
  if (!existing.includes("generated by opencode-swarm skill-generator")) {
61944
61964
  return {
@@ -62002,7 +62022,7 @@ async function listSkills(directory) {
62002
62022
  const proposalsDir = path35.join(directory, ".swarm", "skills", "proposals");
62003
62023
  const activeDir = path35.join(directory, ".opencode", "skills", "generated");
62004
62024
  const fs19 = await import("node:fs/promises");
62005
- if (existsSync17(proposalsDir)) {
62025
+ if (existsSync16(proposalsDir)) {
62006
62026
  const entries = await fs19.readdir(proposalsDir);
62007
62027
  for (const f of entries) {
62008
62028
  if (!f.endsWith(".md"))
@@ -62014,16 +62034,16 @@ async function listSkills(directory) {
62014
62034
  });
62015
62035
  }
62016
62036
  }
62017
- if (existsSync17(activeDir)) {
62037
+ if (existsSync16(activeDir)) {
62018
62038
  const entries = await fs19.readdir(activeDir, { withFileTypes: true });
62019
62039
  for (const e of entries) {
62020
62040
  if (!e.isDirectory())
62021
62041
  continue;
62022
62042
  const retiredMarker = path35.join(activeDir, e.name, "retired.marker");
62023
- if (existsSync17(retiredMarker))
62043
+ if (existsSync16(retiredMarker))
62024
62044
  continue;
62025
62045
  const skillPath = path35.join(activeDir, e.name, "SKILL.md");
62026
- if (existsSync17(skillPath)) {
62046
+ if (existsSync16(skillPath)) {
62027
62047
  result.active.push({
62028
62048
  slug: e.name,
62029
62049
  path: skillPath
@@ -62102,7 +62122,7 @@ async function inspectSkill(directory, slug, prefer = "auto") {
62102
62122
  if (prefer === "proposal" || prefer === "auto")
62103
62123
  candidates.push({ p: proposalPath(directory, cleanSlug), m: "draft" });
62104
62124
  for (const c of candidates) {
62105
- if (existsSync17(c.p)) {
62125
+ if (existsSync16(c.p)) {
62106
62126
  const content = await readFile7(c.p, "utf-8");
62107
62127
  return { found: true, path: c.p, content, mode: c.m };
62108
62128
  }
@@ -62120,7 +62140,7 @@ async function retireSkill(directory, slug, reason) {
62120
62140
  };
62121
62141
  }
62122
62142
  const skillPath = activePath(directory, cleanSlug);
62123
- if (!existsSync17(skillPath)) {
62143
+ if (!existsSync16(skillPath)) {
62124
62144
  return {
62125
62145
  retired: false,
62126
62146
  path: skillPath,
@@ -62134,7 +62154,7 @@ async function retireSkill(directory, slug, reason) {
62134
62154
  retiredAt: new Date().toISOString(),
62135
62155
  reason: reason ?? "manual_retire"
62136
62156
  });
62137
- await mkdir7(markerDir, { recursive: true });
62157
+ await mkdir8(markerDir, { recursive: true });
62138
62158
  await writeFile4(markerPath, markerContent, "utf-8");
62139
62159
  return {
62140
62160
  retired: true,
@@ -62154,7 +62174,7 @@ async function regenerateSkill(directory, slug) {
62154
62174
  };
62155
62175
  }
62156
62176
  const skillPath = activePath(directory, cleanSlug);
62157
- if (!existsSync17(skillPath)) {
62177
+ if (!existsSync16(skillPath)) {
62158
62178
  return {
62159
62179
  regenerated: false,
62160
62180
  path: skillPath,
@@ -62179,7 +62199,7 @@ async function regenerateSkill(directory, slug) {
62179
62199
  try {
62180
62200
  const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
62181
62201
  const hivePath = resolveHiveKnowledgePath();
62182
- const hive = existsSync17(hivePath) ? await readKnowledge(hivePath) : [];
62202
+ const hive = existsSync16(hivePath) ? await readKnowledge(hivePath) : [];
62183
62203
  const all = [...swarm, ...hive];
62184
62204
  const idSet = new Set(fm.sourceKnowledgeIds);
62185
62205
  matchedEntries = all.filter((e) => idSet.has(e.id));
@@ -62328,8 +62348,8 @@ var init_skill_generator = __esm(() => {
62328
62348
  });
62329
62349
 
62330
62350
  // src/services/skill-improver-quota.ts
62331
- import { existsSync as existsSync18 } from "node:fs";
62332
- import { mkdir as mkdir8, readFile as readFile8, rename as rename4, writeFile as writeFile5 } from "node:fs/promises";
62351
+ import { existsSync as existsSync17 } from "node:fs";
62352
+ import { mkdir as mkdir9, readFile as readFile8, rename as rename4, writeFile as writeFile5 } from "node:fs/promises";
62333
62353
  import * as path36 from "node:path";
62334
62354
  async function acquireLock(dir) {
62335
62355
  const acquire = import_proper_lockfile6.default.lock(dir, LOCK_RETRY_OPTS);
@@ -62361,7 +62381,7 @@ function todayKey(window2, now = new Date) {
62361
62381
  return `${yr}-${m}-${d}`;
62362
62382
  }
62363
62383
  async function readState(filePath) {
62364
- if (!existsSync18(filePath))
62384
+ if (!existsSync17(filePath))
62365
62385
  return null;
62366
62386
  try {
62367
62387
  const raw = await readFile8(filePath, "utf-8");
@@ -62375,7 +62395,7 @@ async function readState(filePath) {
62375
62395
  }
62376
62396
  }
62377
62397
  async function writeState(filePath, state) {
62378
- await mkdir8(path36.dirname(filePath), { recursive: true });
62398
+ await mkdir9(path36.dirname(filePath), { recursive: true });
62379
62399
  const tmp = `${filePath}.tmp-${process.pid}`;
62380
62400
  await writeFile5(tmp, JSON.stringify(state, null, 2), "utf-8");
62381
62401
  await rename4(tmp, filePath);
@@ -62398,7 +62418,7 @@ async function getQuotaState(directory, opts) {
62398
62418
  }
62399
62419
  async function reserveQuota(directory, opts) {
62400
62420
  const filePath = resolveQuotaPath(directory, opts.scope);
62401
- await mkdir8(path36.dirname(filePath), { recursive: true });
62421
+ await mkdir9(path36.dirname(filePath), { recursive: true });
62402
62422
  let release = null;
62403
62423
  try {
62404
62424
  release = await acquireLock(path36.dirname(filePath));
@@ -62428,7 +62448,7 @@ async function reserveQuota(directory, opts) {
62428
62448
  }
62429
62449
  async function releaseQuota(directory, opts) {
62430
62450
  const filePath = resolveQuotaPath(directory, opts.scope);
62431
- await mkdir8(path36.dirname(filePath), { recursive: true });
62451
+ await mkdir9(path36.dirname(filePath), { recursive: true });
62432
62452
  let release = null;
62433
62453
  try {
62434
62454
  release = await acquireLock(path36.dirname(filePath));
@@ -62837,8 +62857,8 @@ function appendSkillUsageEntry(directory, entry) {
62837
62857
  _internals26.appendFileSync(resolved, `${JSON.stringify(fullEntry)}
62838
62858
  `, "utf-8");
62839
62859
  try {
62840
- const stat4 = _internals26.statSync(resolved);
62841
- if (stat4.size > SKILL_USAGE_LOG_ROTATE_BYTES) {
62860
+ const stat5 = _internals26.statSync(resolved);
62861
+ if (stat5.size > SKILL_USAGE_LOG_ROTATE_BYTES) {
62842
62862
  _internals26.pruneSkillUsageLog(directory, SKILL_USAGE_LOG_MAX_ENTRIES_PER_SKILL);
62843
62863
  }
62844
62864
  } catch {}
@@ -62892,11 +62912,11 @@ function readSkillUsageEntriesTail(directory, filters, maxBytes = TAIL_BYTES_DEF
62892
62912
  try {
62893
62913
  const normalizedMaxBytes = Number.isFinite(maxBytes) ? maxBytes : TAIL_BYTES_DEFAULT;
62894
62914
  const boundedMaxBytes = Math.min(Math.max(1, normalizedMaxBytes), MAX_TAIL_BYTES);
62895
- const stat4 = _internals26.statSync(logPath);
62896
- const start2 = Math.max(0, stat4.size - boundedMaxBytes);
62915
+ const stat5 = _internals26.statSync(logPath);
62916
+ const start2 = Math.max(0, stat5.size - boundedMaxBytes);
62897
62917
  const fd = _internals26.openSync(logPath, "r");
62898
62918
  try {
62899
- const readLen = stat4.size - start2;
62919
+ const readLen = stat5.size - start2;
62900
62920
  if (readLen === 0)
62901
62921
  return [];
62902
62922
  const buf = Buffer.alloc(readLen);
@@ -64417,10 +64437,10 @@ var init_hive_promoter = __esm(() => {
64417
64437
 
64418
64438
  // src/services/synonym-map.ts
64419
64439
  import {
64420
- mkdir as mkdir9,
64440
+ mkdir as mkdir10,
64421
64441
  readFile as readFile10,
64422
64442
  rename as rename6,
64423
- stat as stat4,
64443
+ stat as stat5,
64424
64444
  unlink as unlink2,
64425
64445
  writeFile as writeFile7
64426
64446
  } from "node:fs/promises";
@@ -64609,7 +64629,7 @@ async function readSynonymMap(directory, maxPairs = DEFAULT_MAX_PAIRS) {
64609
64629
  }
64610
64630
  try {
64611
64631
  const ceiling = Math.max(MIN_READ_CEILING_BYTES, Math.floor(maxPairs) * APPROX_BYTES_PER_PAIR);
64612
- const st = await stat4(filePath);
64632
+ const st = await stat5(filePath);
64613
64633
  if (st.size > ceiling)
64614
64634
  return emptySynonymMap();
64615
64635
  const raw = await readFile10(filePath, "utf-8");
@@ -64619,7 +64639,7 @@ async function readSynonymMap(directory, maxPairs = DEFAULT_MAX_PAIRS) {
64619
64639
  }
64620
64640
  }
64621
64641
  async function writeSynonymMapAtomic(filePath, map3) {
64622
- await mkdir9(path40.dirname(filePath), { recursive: true });
64642
+ await mkdir10(path40.dirname(filePath), { recursive: true });
64623
64643
  const tmp = `${filePath}.tmp.${Date.now()}.${Math.floor(Math.random() * 1e9)}`;
64624
64644
  try {
64625
64645
  await writeFile7(tmp, JSON.stringify(map3, null, 2), "utf-8");
@@ -64633,7 +64653,7 @@ async function writeSynonymMapAtomic(filePath, map3) {
64633
64653
  async function rebuildSynonymMap(directory, entries, maxPairs = DEFAULT_MAX_PAIRS) {
64634
64654
  const filePath = resolveSynonymMapPath(directory);
64635
64655
  const dir = path40.dirname(filePath);
64636
- await mkdir9(dir, { recursive: true });
64656
+ await mkdir10(dir, { recursive: true });
64637
64657
  let release = null;
64638
64658
  try {
64639
64659
  release = await import_proper_lockfile7.default.lock(dir, {
@@ -64922,8 +64942,8 @@ function formatSkillIndexWithContext(skills, directory) {
64922
64942
  const usageLogPath = path41.join(directory, ".swarm", "skill-usage.jsonl");
64923
64943
  let hasHistory = false;
64924
64944
  try {
64925
- const stat5 = fs21.statSync(usageLogPath);
64926
- hasHistory = stat5.size > 0;
64945
+ const stat6 = fs21.statSync(usageLogPath);
64946
+ hasHistory = stat6.size > 0;
64927
64947
  } catch {}
64928
64948
  if (!hasHistory) {
64929
64949
  return skills.map((sp) => {
@@ -65619,7 +65639,7 @@ var init_skill_propagation_gate = __esm(() => {
65619
65639
  });
65620
65640
 
65621
65641
  // src/hooks/micro-reflector.ts
65622
- import { existsSync as existsSync22 } from "node:fs";
65642
+ import { existsSync as existsSync21 } from "node:fs";
65623
65643
  import { readFile as readFile11, writeFile as writeFile8 } from "node:fs/promises";
65624
65644
  import * as path43 from "node:path";
65625
65645
  function resolveInsightCandidatesPath(directory) {
@@ -65654,7 +65674,7 @@ async function readTaskTrajectory(directory, taskId) {
65654
65674
  try {
65655
65675
  const rel = path43.join("evidence", sanitizeTaskId2(taskId), "trajectory.jsonl");
65656
65676
  const filePath = validateSwarmPath(directory, rel);
65657
- if (!existsSync22(filePath))
65677
+ if (!existsSync21(filePath))
65658
65678
  return [];
65659
65679
  const content = await readFile11(filePath, "utf-8");
65660
65680
  const out2 = [];
@@ -65897,8 +65917,8 @@ var init_micro_reflector = __esm(() => {
65897
65917
  });
65898
65918
 
65899
65919
  // src/hooks/knowledge-curator.ts
65900
- import { existsSync as existsSync23 } from "node:fs";
65901
- import { appendFile as appendFile7, mkdir as mkdir10, readFile as readFile12, writeFile as writeFile9 } from "node:fs/promises";
65920
+ import { existsSync as existsSync22 } from "node:fs";
65921
+ import { appendFile as appendFile7, mkdir as mkdir11, readFile as readFile12, writeFile as writeFile9 } from "node:fs/promises";
65902
65922
  import * as path44 from "node:path";
65903
65923
  function pruneSeenRetroSections() {
65904
65924
  const cutoff = Date.now() - 86400000;
@@ -66160,7 +66180,7 @@ RETRY: your last output was missing ${result.missing.join("; ")}; produce valid
66160
66180
  async function appendCuratorSkippedEvent(directory, record3) {
66161
66181
  try {
66162
66182
  const filePath = path44.join(directory, ".swarm", "events.jsonl");
66163
- await mkdir10(path44.dirname(filePath), { recursive: true });
66183
+ await mkdir11(path44.dirname(filePath), { recursive: true });
66164
66184
  await appendFile7(filePath, `${JSON.stringify({
66165
66185
  timestamp: new Date().toISOString(),
66166
66186
  event: "curator_skipped",
@@ -66187,7 +66207,7 @@ function readInsightJsonl2(content) {
66187
66207
  async function consumeInsightCandidates(directory, batchLimit = MESO_INSIGHT_BATCH_LIMIT) {
66188
66208
  try {
66189
66209
  const filePath = resolveInsightCandidatesPath(directory);
66190
- if (!existsSync23(filePath))
66210
+ if (!existsSync22(filePath))
66191
66211
  return [];
66192
66212
  const consumed = [];
66193
66213
  await transactFile(filePath, async (p) => readInsightJsonl2(await readFile12(p, "utf-8").catch(() => "")), async (p, data) => {
@@ -66665,13 +66685,16 @@ function createSkillImproverLLMDelegate(directory, sessionId) {
66665
66685
  }
66666
66686
  };
66667
66687
  if (signal?.aborted) {
66668
- cleanup();
66669
66688
  throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
66670
66689
  }
66671
- signal?.addEventListener("abort", cleanup, { once: true });
66690
+ const sdkOpts = signal ? { signal } : {};
66672
66691
  try {
66673
66692
  const createResult = await client.session.create({
66674
- query: { directory }
66693
+ ...sessionId ? {
66694
+ body: { parentID: sessionId, title: "skill_improver background" }
66695
+ } : {},
66696
+ query: { directory },
66697
+ ...sdkOpts
66675
66698
  });
66676
66699
  if (!createResult.data) {
66677
66700
  throw new Error(`Failed to create skill_improver session: ${JSON.stringify(createResult.error)}`);
@@ -66680,34 +66703,31 @@ function createSkillImproverLLMDelegate(directory, sessionId) {
66680
66703
  if (signal?.aborted)
66681
66704
  throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
66682
66705
  const agentName = resolveSkillImproverAgentName(sessionId);
66683
- let promptResult;
66684
- try {
66685
- const prelude = systemPrompt ? `${systemPrompt}
66706
+ const prelude = systemPrompt ? `${systemPrompt}
66686
66707
 
66687
66708
  ---
66688
66709
 
66689
66710
  ${userInput}` : userInput;
66690
- promptResult = await client.session.prompt({
66691
- path: { id: ephemeralSessionId },
66692
- body: {
66693
- agent: agentName,
66694
- tools: { write: false, edit: false, patch: false },
66695
- parts: [{ type: "text", text: prelude }]
66696
- }
66697
- });
66698
- } catch (err2) {
66699
- if (signal?.aborted)
66700
- throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
66701
- throw err2;
66702
- }
66711
+ const promptResult = await client.session.prompt({
66712
+ path: { id: ephemeralSessionId },
66713
+ body: {
66714
+ agent: agentName,
66715
+ tools: { write: false, edit: false, patch: false },
66716
+ parts: [{ type: "text", text: prelude }]
66717
+ },
66718
+ ...sdkOpts
66719
+ });
66703
66720
  if (!promptResult.data) {
66704
66721
  throw new Error(`skill_improver LLM prompt failed: ${JSON.stringify(promptResult.error)}`);
66705
66722
  }
66706
66723
  const textParts = promptResult.data.parts.filter((p) => p.type === "text");
66707
66724
  return textParts.map((p) => p.text).join(`
66708
66725
  `);
66726
+ } catch (err2) {
66727
+ if (isAbortError(err2))
66728
+ throw new Error("SKILL_IMPROVER_LLM_TIMEOUT");
66729
+ throw err2;
66709
66730
  } finally {
66710
- signal?.removeEventListener("abort", cleanup);
66711
66731
  cleanup();
66712
66732
  }
66713
66733
  };
@@ -66717,7 +66737,7 @@ var init_skill_improver_llm_factory = __esm(() => {
66717
66737
  });
66718
66738
 
66719
66739
  // src/services/trajectory-cluster.ts
66720
- import { mkdir as mkdir11, writeFile as writeFile10 } from "node:fs/promises";
66740
+ import { mkdir as mkdir12, writeFile as writeFile10 } from "node:fs/promises";
66721
66741
  import * as path45 from "node:path";
66722
66742
  function failureKind(e) {
66723
66743
  const tool3 = (e.tool ?? "").toLowerCase();
@@ -66848,7 +66868,7 @@ async function writeMotifProposals(directory, opts = {}) {
66848
66868
  return result;
66849
66869
  const max = opts.maxProposals ?? 10;
66850
66870
  const proposalsDir = validateSwarmPath(directory, path45.join("skills", "proposals"));
66851
- await mkdir11(proposalsDir, { recursive: true });
66871
+ await mkdir12(proposalsDir, { recursive: true });
66852
66872
  for (const motif of motifs.slice(0, max)) {
66853
66873
  const slug = `motif-${slugify2(motif.signature)}`;
66854
66874
  const filePath = path45.join(proposalsDir, `${slug}.md`);
@@ -66992,7 +67012,7 @@ async function writeSuccessMotifProposals(directory, opts = {}) {
66992
67012
  return result;
66993
67013
  const max = opts.maxProposals ?? 10;
66994
67014
  const proposalsDir = validateSwarmPath(directory, path45.join("skills", "proposals"));
66995
- await mkdir11(proposalsDir, { recursive: true });
67015
+ await mkdir12(proposalsDir, { recursive: true });
66996
67016
  for (const motif of motifs.slice(0, max)) {
66997
67017
  const slug = workflowSlug(motif.signature);
66998
67018
  const filePath = path45.join(proposalsDir, `${slug}.md`);
@@ -67014,12 +67034,12 @@ var init_trajectory_cluster = __esm(() => {
67014
67034
  });
67015
67035
 
67016
67036
  // src/services/unactionable-hardening.ts
67017
- import { existsSync as existsSync24 } from "node:fs";
67037
+ import { existsSync as existsSync23 } from "node:fs";
67018
67038
  async function hardenUnactionableEntries(params) {
67019
67039
  const result = { hardened: 0, retired: 0, remaining: 0 };
67020
67040
  try {
67021
67041
  const queuePath = resolveUnactionablePath(params.directory);
67022
- if (!existsSync24(queuePath))
67042
+ if (!existsSync23(queuePath))
67023
67043
  return result;
67024
67044
  const limit = params.batchLimit ?? HARDENING_BATCH_LIMIT;
67025
67045
  const dedupThreshold = params.dedupThreshold ?? 0.6;
@@ -67126,14 +67146,14 @@ var init_unactionable_hardening = __esm(() => {
67126
67146
  });
67127
67147
 
67128
67148
  // src/services/skill-improver.ts
67129
- import { existsSync as existsSync25 } from "node:fs";
67130
- import { mkdir as mkdir12, readFile as readFile13, rename as rename7, writeFile as writeFile11 } from "node:fs/promises";
67149
+ import { existsSync as existsSync24 } from "node:fs";
67150
+ import { mkdir as mkdir13, readFile as readFile13, rename as rename7, writeFile as writeFile11 } from "node:fs/promises";
67131
67151
  import * as path46 from "node:path";
67132
67152
  function timestampSlug(d) {
67133
67153
  return d.toISOString().replace(/[:.]/g, "-");
67134
67154
  }
67135
67155
  async function atomicWrite3(p, content) {
67136
- await mkdir12(path46.dirname(p), { recursive: true });
67156
+ await mkdir13(path46.dirname(p), { recursive: true });
67137
67157
  const tmp = `${p}.tmp-${process.pid}-${Date.now()}`;
67138
67158
  await writeFile11(tmp, content, "utf-8");
67139
67159
  await rename7(tmp, p);
@@ -67141,7 +67161,7 @@ async function atomicWrite3(p, content) {
67141
67161
  async function gatherInventory(directory) {
67142
67162
  const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
67143
67163
  const hivePath = resolveHiveKnowledgePath();
67144
- const hive = existsSync25(hivePath) ? await readKnowledge(hivePath) : [];
67164
+ const hive = existsSync24(hivePath) ? await readKnowledge(hivePath) : [];
67145
67165
  const archived = [...swarm, ...hive].filter((e) => e.status === "archived").length;
67146
67166
  const skills = await listSkills(directory);
67147
67167
  const knowledgeById = new Map([...swarm, ...hive].map((entry) => [entry.id, entry]));
@@ -67239,7 +67259,7 @@ ${inv.staleActiveSkills.slice(0, 10).map((s) => `- ${s.slug} | ${s.reasons.join(
67239
67259
  `) || "(none)"}
67240
67260
  `;
67241
67261
  }
67242
- function isAbortError(err2) {
67262
+ function isAbortError2(err2) {
67243
67263
  return err2 instanceof Error && (err2.name === "AbortError" || err2.message === "skill_improver_aborted");
67244
67264
  }
67245
67265
  function throwIfAborted(signal) {
@@ -67387,7 +67407,7 @@ async function runSkillImprover(req) {
67387
67407
  inventory = await gatherInventory(req.directory);
67388
67408
  throwIfAborted(req.signal);
67389
67409
  } catch (err2) {
67390
- if (isAbortError(err2)) {
67410
+ if (isAbortError2(err2)) {
67391
67411
  return await abortResult();
67392
67412
  }
67393
67413
  await releaseQuota(req.directory, {
@@ -67419,7 +67439,7 @@ async function runSkillImprover(req) {
67419
67439
  }
67420
67440
  source = "llm";
67421
67441
  } catch (err2) {
67422
- if (isAbortError(err2)) {
67442
+ if (isAbortError2(err2)) {
67423
67443
  return await abortResult();
67424
67444
  }
67425
67445
  return {
@@ -67436,7 +67456,7 @@ async function runSkillImprover(req) {
67436
67456
  try {
67437
67457
  throwIfAborted(req.signal);
67438
67458
  } catch (err2) {
67439
- if (isAbortError(err2)) {
67459
+ if (isAbortError2(err2)) {
67440
67460
  return await abortResult();
67441
67461
  }
67442
67462
  throw err2;
@@ -67449,7 +67469,7 @@ async function runSkillImprover(req) {
67449
67469
  try {
67450
67470
  throwIfAborted(req.signal);
67451
67471
  } catch (err2) {
67452
- if (isAbortError(err2)) {
67472
+ if (isAbortError2(err2)) {
67453
67473
  return await abortResult();
67454
67474
  }
67455
67475
  throw err2;
@@ -67470,7 +67490,7 @@ async function runSkillImprover(req) {
67470
67490
  try {
67471
67491
  throwIfAborted(req.signal);
67472
67492
  } catch (err2) {
67473
- if (isAbortError(err2)) {
67493
+ if (isAbortError2(err2)) {
67474
67494
  return await abortResult();
67475
67495
  }
67476
67496
  throw err2;
@@ -67907,7 +67927,7 @@ __export(exports_curator_postmortem, {
67907
67927
  runCuratorPostMortem: () => runCuratorPostMortem,
67908
67928
  _internals: () => _internals32
67909
67929
  });
67910
- import { existsSync as existsSync26, readdirSync as readdirSync7, readFileSync as readFileSync12 } from "node:fs";
67930
+ import { existsSync as existsSync25, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
67911
67931
  import * as path47 from "node:path";
67912
67932
  async function collectKnowledgeSummary(directory) {
67913
67933
  const entries = await readKnowledge(resolveSwarmKnowledgePath(directory));
@@ -67947,7 +67967,7 @@ async function collectKnowledgeSummary(directory) {
67947
67967
  }
67948
67968
  function readJsonlFile(filePath) {
67949
67969
  try {
67950
- if (!existsSync26(filePath))
67970
+ if (!existsSync25(filePath))
67951
67971
  return [];
67952
67972
  const content = readFileSync12(filePath, "utf-8");
67953
67973
  const results = [];
@@ -67968,12 +67988,12 @@ function collectRetrospectives(directory) {
67968
67988
  const results = [];
67969
67989
  const evidenceDir = path47.join(directory, ".swarm", "evidence");
67970
67990
  try {
67971
- if (!existsSync26(evidenceDir))
67991
+ if (!existsSync25(evidenceDir))
67972
67992
  return results;
67973
- for (const entry of readdirSync7(evidenceDir, { withFileTypes: true })) {
67993
+ for (const entry of readdirSync6(evidenceDir, { withFileTypes: true })) {
67974
67994
  if (entry.isDirectory() && entry.name.startsWith("retro-")) {
67975
67995
  const retroPath = path47.join(evidenceDir, entry.name, "evidence.json");
67976
- if (existsSync26(retroPath)) {
67996
+ if (existsSync25(retroPath)) {
67977
67997
  try {
67978
67998
  results.push(readFileSync12(retroPath, "utf-8"));
67979
67999
  } catch {}
@@ -67987,9 +68007,9 @@ function collectDriftReports(directory) {
67987
68007
  const results = [];
67988
68008
  const swarmDir = path47.join(directory, ".swarm");
67989
68009
  try {
67990
- if (!existsSync26(swarmDir))
68010
+ if (!existsSync25(swarmDir))
67991
68011
  return results;
67992
- for (const entry of readdirSync7(swarmDir)) {
68012
+ for (const entry of readdirSync6(swarmDir)) {
67993
68013
  if (entry.startsWith("drift-report-phase-") && entry.endsWith(".json")) {
67994
68014
  try {
67995
68015
  results.push(readFileSync12(path47.join(swarmDir, entry), "utf-8"));
@@ -68002,7 +68022,7 @@ function collectDriftReports(directory) {
68002
68022
  function collectPendingProposals(directory) {
68003
68023
  const results = [];
68004
68024
  const insightPath = path47.join(directory, ".swarm", "insight-candidates.jsonl");
68005
- if (existsSync26(insightPath)) {
68025
+ if (existsSync25(insightPath)) {
68006
68026
  try {
68007
68027
  results.push({
68008
68028
  source: "insight-candidates",
@@ -68012,8 +68032,8 @@ function collectPendingProposals(directory) {
68012
68032
  }
68013
68033
  const proposalsDir = path47.join(directory, ".swarm", "skills", "proposals");
68014
68034
  try {
68015
- if (existsSync26(proposalsDir)) {
68016
- for (const entry of readdirSync7(proposalsDir)) {
68035
+ if (existsSync25(proposalsDir)) {
68036
+ for (const entry of readdirSync6(proposalsDir)) {
68017
68037
  if (entry.endsWith(".md") || entry.endsWith(".json")) {
68018
68038
  try {
68019
68039
  results.push({
@@ -68167,7 +68187,7 @@ async function runCuratorPostMortem(directory, options = {}) {
68167
68187
  warnings: [...warnings, "Invalid report path."]
68168
68188
  };
68169
68189
  }
68170
- if (!options.force && existsSync26(reportPath)) {
68190
+ if (!options.force && existsSync25(reportPath)) {
68171
68191
  return {
68172
68192
  success: true,
68173
68193
  planId,
@@ -68230,8 +68250,8 @@ ${llmOutput}`;
68230
68250
  reportContent = buildDataOnlyReport(planId, planSummary, knowledgeSummary, curatorDigest, proposals, unactionable, retrospectives, driftReports);
68231
68251
  }
68232
68252
  try {
68233
- const { mkdirSync: mkdirSync17, writeFileSync: writeFileSync10 } = await import("node:fs");
68234
- mkdirSync17(path47.dirname(reportPath), { recursive: true });
68253
+ const { mkdirSync: mkdirSync16, writeFileSync: writeFileSync10 } = await import("node:fs");
68254
+ mkdirSync16(path47.dirname(reportPath), { recursive: true });
68235
68255
  writeFileSync10(reportPath, reportContent, "utf-8");
68236
68256
  } catch (err2) {
68237
68257
  const msg = err2 instanceof Error ? err2.message : String(err2);
@@ -68321,8 +68341,8 @@ async function copyDirRecursive(src, dest) {
68321
68341
  const srcEntry = path48.join(src, entry);
68322
68342
  const destEntry = path48.join(dest, entry);
68323
68343
  try {
68324
- const stat5 = await fs23.stat(srcEntry);
68325
- if (stat5.isDirectory()) {
68344
+ const stat6 = await fs23.stat(srcEntry);
68345
+ if (stat6.isDirectory()) {
68326
68346
  const subCount = await copyDirRecursive(srcEntry, destEntry).catch(() => 0);
68327
68347
  count += subCount;
68328
68348
  } else {
@@ -68358,8 +68378,8 @@ function guaranteeAllPlansComplete(planData) {
68358
68378
  async function handleCloseCommand(directory, args2, options = {}) {
68359
68379
  const swarmDir = path48.join(directory, ".swarm");
68360
68380
  try {
68361
- const stat5 = fsSync5.lstatSync(swarmDir);
68362
- if (stat5.isSymbolicLink()) {
68381
+ const stat6 = fsSync5.lstatSync(swarmDir);
68382
+ if (stat6.isSymbolicLink()) {
68363
68383
  return `❌ Refused: .swarm/ is a symlink or junction. Refusing to operate on a redirected directory for safety.`;
68364
68384
  }
68365
68385
  } catch (err2) {
@@ -69355,7 +69375,7 @@ __export(exports_co_change_analyzer, {
69355
69375
  });
69356
69376
  import * as child_process3 from "node:child_process";
69357
69377
  import { randomUUID as randomUUID5 } from "node:crypto";
69358
- import { readdir as readdir2, readFile as readFile14, stat as stat5 } from "node:fs/promises";
69378
+ import { readdir as readdir3, readFile as readFile14, stat as stat6 } from "node:fs/promises";
69359
69379
  import * as path50 from "node:path";
69360
69380
  import { promisify } from "node:util";
69361
69381
  function getExecFileAsync() {
@@ -69458,7 +69478,7 @@ async function scanSourceFiles(dir) {
69458
69478
  const results = [];
69459
69479
  const skipDirs = new Set(["node_modules", ".swarm", "dist", "build"]);
69460
69480
  try {
69461
- const entries = await readdir2(dir, { withFileTypes: true });
69481
+ const entries = await readdir3(dir, { withFileTypes: true });
69462
69482
  for (const entry of entries) {
69463
69483
  const fullPath = path50.join(dir, entry.name);
69464
69484
  if (entry.isDirectory()) {
@@ -69506,7 +69526,7 @@ async function getStaticEdges(directory) {
69506
69526
  for (const ext of extensions) {
69507
69527
  const testPath = resolvedPath + ext;
69508
69528
  try {
69509
- const testStat = await stat5(testPath);
69529
+ const testStat = await stat6(testPath);
69510
69530
  if (testStat.isFile()) {
69511
69531
  targetFile = testPath;
69512
69532
  break;
@@ -70252,7 +70272,7 @@ var init_gate_bridge = __esm(() => {
70252
70272
  });
70253
70273
 
70254
70274
  // src/services/version-check.ts
70255
- import { existsSync as existsSync27, mkdirSync as mkdirSync17, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "node:fs";
70275
+ import { existsSync as existsSync26, mkdirSync as mkdirSync16, readFileSync as readFileSync13, writeFileSync as writeFileSync10 } from "node:fs";
70256
70276
  import { homedir as homedir6 } from "node:os";
70257
70277
  import { join as join41 } from "node:path";
70258
70278
  function cacheDir() {
@@ -70266,7 +70286,7 @@ function cacheFile() {
70266
70286
  function readVersionCache() {
70267
70287
  try {
70268
70288
  const path53 = cacheFile();
70269
- if (!existsSync27(path53))
70289
+ if (!existsSync26(path53))
70270
70290
  return null;
70271
70291
  const raw = readFileSync13(path53, "utf-8");
70272
70292
  const parsed = JSON.parse(raw);
@@ -70281,7 +70301,7 @@ function readVersionCache() {
70281
70301
  function writeVersionCache(entry) {
70282
70302
  try {
70283
70303
  const dir = cacheDir();
70284
- mkdirSync17(dir, { recursive: true });
70304
+ mkdirSync16(dir, { recursive: true });
70285
70305
  writeFileSync10(cacheFile(), JSON.stringify(entry, null, 2), "utf-8");
70286
70306
  } catch {}
70287
70307
  }
@@ -70364,10 +70384,10 @@ var init_version_check = __esm(() => {
70364
70384
  });
70365
70385
 
70366
70386
  // src/services/knowledge-diagnostics.ts
70367
- import { existsSync as existsSync28 } from "node:fs";
70387
+ import { existsSync as existsSync27 } from "node:fs";
70368
70388
  import { readFile as readFile15 } from "node:fs/promises";
70369
70389
  async function readRawLines(filePath) {
70370
- if (!existsSync28(filePath))
70390
+ if (!existsSync27(filePath))
70371
70391
  return { entries: [], corrupt: 0 };
70372
70392
  const content = await readFile15(filePath, "utf-8");
70373
70393
  const entries = [];
@@ -70492,7 +70512,7 @@ async function computeKnowledgeDebug(directory) {
70492
70512
  };
70493
70513
  }
70494
70514
  async function safeJsonlCount(filePath) {
70495
- if (!filePath || !existsSync28(filePath))
70515
+ if (!filePath || !existsSync27(filePath))
70496
70516
  return 0;
70497
70517
  try {
70498
70518
  const content = await readFile15(filePath, "utf-8");
@@ -70575,7 +70595,7 @@ var init_knowledge_diagnostics = __esm(() => {
70575
70595
 
70576
70596
  // src/services/diagnose-service.ts
70577
70597
  import * as child_process4 from "node:child_process";
70578
- import { existsSync as existsSync29, readdirSync as readdirSync8, readFileSync as readFileSync14, statSync as statSync11 } from "node:fs";
70598
+ import { existsSync as existsSync28, readdirSync as readdirSync7, readFileSync as readFileSync14, statSync as statSync10 } from "node:fs";
70579
70599
  import path53 from "node:path";
70580
70600
  import { fileURLToPath as fileURLToPath2 } from "node:url";
70581
70601
  function validateTaskDag(plan) {
@@ -70792,7 +70812,7 @@ async function checkPlanSync(directory, plan) {
70792
70812
  }
70793
70813
  async function checkConfigBackups(directory) {
70794
70814
  try {
70795
- const files = readdirSync8(directory);
70815
+ const files = readdirSync7(directory);
70796
70816
  const backupCount = files.filter((f) => /\.opencode-swarm\.yaml\.bak/.test(f)).length;
70797
70817
  if (backupCount <= 5) {
70798
70818
  return {
@@ -70823,7 +70843,7 @@ async function checkConfigBackups(directory) {
70823
70843
  }
70824
70844
  async function checkGitRepository(directory) {
70825
70845
  try {
70826
- if (!existsSync29(directory) || !statSync11(directory).isDirectory()) {
70846
+ if (!existsSync28(directory) || !statSync10(directory).isDirectory()) {
70827
70847
  return {
70828
70848
  name: "Git Repository",
70829
70849
  status: "❌",
@@ -70888,7 +70908,7 @@ async function checkSpecStaleness(directory, plan) {
70888
70908
  }
70889
70909
  async function checkConfigParseability(directory) {
70890
70910
  const configPath = path53.join(directory, ".opencode/opencode-swarm.json");
70891
- if (!existsSync29(configPath)) {
70911
+ if (!existsSync28(configPath)) {
70892
70912
  return {
70893
70913
  name: "Config Parseability",
70894
70914
  status: "✅",
@@ -70943,11 +70963,11 @@ async function checkGrammarWasmFiles() {
70943
70963
  const thisDir = path53.dirname(fileURLToPath2(import.meta.url));
70944
70964
  const grammarDir = resolveGrammarDir(thisDir);
70945
70965
  const missing = [];
70946
- if (!existsSync29(path53.join(grammarDir, "tree-sitter.wasm"))) {
70966
+ if (!existsSync28(path53.join(grammarDir, "tree-sitter.wasm"))) {
70947
70967
  missing.push("tree-sitter.wasm (core runtime)");
70948
70968
  }
70949
70969
  for (const file3 of grammarFiles) {
70950
- if (!existsSync29(path53.join(grammarDir, file3))) {
70970
+ if (!existsSync28(path53.join(grammarDir, file3))) {
70951
70971
  missing.push(file3);
70952
70972
  }
70953
70973
  }
@@ -70966,7 +70986,7 @@ async function checkGrammarWasmFiles() {
70966
70986
  }
70967
70987
  async function checkCheckpointManifest(directory) {
70968
70988
  const manifestPath = path53.join(directory, ".swarm/checkpoints.json");
70969
- if (!existsSync29(manifestPath)) {
70989
+ if (!existsSync28(manifestPath)) {
70970
70990
  return {
70971
70991
  name: "Checkpoint Manifest",
70972
70992
  status: "✅",
@@ -71018,7 +71038,7 @@ async function checkCheckpointManifest(directory) {
71018
71038
  }
71019
71039
  async function checkEventStreamIntegrity(directory) {
71020
71040
  const eventsPath = path53.join(directory, ".swarm/events.jsonl");
71021
- if (!existsSync29(eventsPath)) {
71041
+ if (!existsSync28(eventsPath)) {
71022
71042
  return {
71023
71043
  name: "Event Stream",
71024
71044
  status: "✅",
@@ -71059,7 +71079,7 @@ async function checkEventStreamIntegrity(directory) {
71059
71079
  }
71060
71080
  async function checkSteeringDirectives(directory) {
71061
71081
  const eventsPath = path53.join(directory, ".swarm/events.jsonl");
71062
- if (!existsSync29(eventsPath)) {
71082
+ if (!existsSync28(eventsPath)) {
71063
71083
  return {
71064
71084
  name: "Steering Directives",
71065
71085
  status: "✅",
@@ -71115,7 +71135,7 @@ async function checkCurator(directory) {
71115
71135
  };
71116
71136
  }
71117
71137
  const summaryPath = path53.join(directory, ".swarm/curator-summary.json");
71118
- if (!existsSync29(summaryPath)) {
71138
+ if (!existsSync28(summaryPath)) {
71119
71139
  return {
71120
71140
  name: "Curator",
71121
71141
  status: "✅",
@@ -71282,7 +71302,7 @@ async function getDiagnoseData(directory) {
71282
71302
  checks5.push(await checkKnowledgeHealth(directory));
71283
71303
  try {
71284
71304
  const evidenceDir = path53.join(directory, ".swarm", "evidence");
71285
- const snapshotFiles = existsSync29(evidenceDir) ? readdirSync8(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
71305
+ const snapshotFiles = existsSync28(evidenceDir) ? readdirSync7(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
71286
71306
  if (snapshotFiles.length > 0) {
71287
71307
  const latest = snapshotFiles.sort().pop();
71288
71308
  checks5.push({
@@ -71315,7 +71335,7 @@ async function getDiagnoseData(directory) {
71315
71335
  const cacheRows = [];
71316
71336
  for (const cachePath of cachePaths) {
71317
71337
  try {
71318
- if (!existsSync29(cachePath)) {
71338
+ if (!existsSync28(cachePath)) {
71319
71339
  cacheRows.push(`⬜ ${cachePath} — absent`);
71320
71340
  continue;
71321
71341
  }
@@ -73692,7 +73712,7 @@ var init_profiles = __esm(() => {
73692
73712
  });
73693
73713
 
73694
73714
  // src/lang/detector.ts
73695
- import { access as access3, readdir as readdir3 } from "node:fs/promises";
73715
+ import { access as access4, readdir as readdir4 } from "node:fs/promises";
73696
73716
  import { extname as extname3, join as join43 } from "node:path";
73697
73717
  function getProfileForFile(filePath) {
73698
73718
  const ext = extname3(filePath);
@@ -73706,7 +73726,7 @@ async function detectProjectLanguages(projectDir) {
73706
73726
  let dirEntries;
73707
73727
  let entries;
73708
73728
  try {
73709
- dirEntries = await readdir3(dir, { withFileTypes: true });
73729
+ dirEntries = await readdir4(dir, { withFileTypes: true });
73710
73730
  entries = dirEntries.map((e) => e.name);
73711
73731
  } catch {
73712
73732
  return;
@@ -73722,7 +73742,7 @@ async function detectProjectLanguages(projectDir) {
73722
73742
  continue;
73723
73743
  }
73724
73744
  try {
73725
- await access3(join43(dir, detectFile));
73745
+ await access4(join43(dir, detectFile));
73726
73746
  detected.add(profile.id);
73727
73747
  break;
73728
73748
  } catch {}
@@ -73740,7 +73760,7 @@ async function detectProjectLanguages(projectDir) {
73740
73760
  }
73741
73761
  await scanDir(projectDir);
73742
73762
  try {
73743
- const topEntries = await readdir3(projectDir, { withFileTypes: true });
73763
+ const topEntries = await readdir4(projectDir, { withFileTypes: true });
73744
73764
  for (const entry of topEntries) {
73745
73765
  if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
73746
73766
  await scanDir(join43(projectDir, entry.name));
@@ -75883,7 +75903,7 @@ var init_handoff_service = __esm(() => {
75883
75903
  });
75884
75904
 
75885
75905
  // src/session/snapshot-writer.ts
75886
- import { closeSync as closeSync5, fsyncSync as fsyncSync2, mkdirSync as mkdirSync20, openSync as openSync5, renameSync as renameSync12 } from "node:fs";
75906
+ import { closeSync as closeSync5, fsyncSync as fsyncSync2, mkdirSync as mkdirSync19, openSync as openSync5, renameSync as renameSync12 } from "node:fs";
75887
75907
  import * as path57 from "node:path";
75888
75908
  function serializeAgentSession(s) {
75889
75909
  const gateLog = {};
@@ -75991,7 +76011,7 @@ async function writeSnapshot(directory, state) {
75991
76011
  const content = JSON.stringify(snapshot, null, 2);
75992
76012
  const resolvedPath = validateSwarmPath(directory, "session/state.json");
75993
76013
  const dir = path57.dirname(resolvedPath);
75994
- mkdirSync20(dir, { recursive: true });
76014
+ mkdirSync19(dir, { recursive: true });
75995
76015
  const tempPath = `${resolvedPath}.tmp.${Date.now()}.${Math.random().toString(36).slice(2)}`;
75996
76016
  await bunWrite(tempPath, content);
75997
76017
  try {
@@ -76530,8 +76550,8 @@ var KNOWLEDGE_SCHEMA_VERSION = 2;
76530
76550
 
76531
76551
  // src/hooks/knowledge-migrator.ts
76532
76552
  import { randomUUID as randomUUID6 } from "node:crypto";
76533
- import { existsSync as existsSync33, readFileSync as readFileSync18 } from "node:fs";
76534
- import { mkdir as mkdir13, readFile as readFile16, writeFile as writeFile12 } from "node:fs/promises";
76553
+ import { existsSync as existsSync32, readFileSync as readFileSync18 } from "node:fs";
76554
+ import { mkdir as mkdir14, readFile as readFile16, writeFile as writeFile12 } from "node:fs/promises";
76535
76555
  import * as os13 from "node:os";
76536
76556
  import * as path58 from "node:path";
76537
76557
  async function migrateKnowledgeToExternal(_directory, _config) {
@@ -76547,7 +76567,7 @@ async function migrateContextToKnowledge(directory, config3) {
76547
76567
  const sentinelPath = path58.join(directory, ".swarm", ".knowledge-migrated");
76548
76568
  const contextPath = path58.join(directory, ".swarm", "context.md");
76549
76569
  const knowledgePath = resolveSwarmKnowledgePath(directory);
76550
- if (existsSync33(sentinelPath)) {
76570
+ if (existsSync32(sentinelPath)) {
76551
76571
  return {
76552
76572
  migrated: false,
76553
76573
  entriesMigrated: 0,
@@ -76556,7 +76576,7 @@ async function migrateContextToKnowledge(directory, config3) {
76556
76576
  skippedReason: "sentinel-exists"
76557
76577
  };
76558
76578
  }
76559
- if (!existsSync33(contextPath)) {
76579
+ if (!existsSync32(contextPath)) {
76560
76580
  return {
76561
76581
  migrated: false,
76562
76582
  entriesMigrated: 0,
@@ -76648,7 +76668,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
76648
76668
  const legacyHivePath = _internals40.resolveLegacyHiveKnowledgePath();
76649
76669
  const canonicalHivePath = resolveHiveKnowledgePath();
76650
76670
  const sentinelPath = path58.join(path58.dirname(canonicalHivePath), ".hive-knowledge-migrated");
76651
- if (existsSync33(sentinelPath)) {
76671
+ if (existsSync32(sentinelPath)) {
76652
76672
  return {
76653
76673
  migrated: false,
76654
76674
  entriesMigrated: 0,
@@ -76657,7 +76677,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
76657
76677
  skippedReason: "sentinel-exists"
76658
76678
  };
76659
76679
  }
76660
- if (!existsSync33(legacyHivePath)) {
76680
+ if (!existsSync32(legacyHivePath)) {
76661
76681
  return {
76662
76682
  migrated: false,
76663
76683
  entriesMigrated: 0,
@@ -76859,7 +76879,7 @@ function truncateLesson2(text) {
76859
76879
  }
76860
76880
  function inferProjectName(directory) {
76861
76881
  const packageJsonPath = path58.join(directory, "package.json");
76862
- if (existsSync33(packageJsonPath)) {
76882
+ if (existsSync32(packageJsonPath)) {
76863
76883
  try {
76864
76884
  const pkg = JSON.parse(readFileSync18(packageJsonPath, "utf-8"));
76865
76885
  if (pkg.name && typeof pkg.name === "string") {
@@ -76879,7 +76899,7 @@ async function writeSentinel(sentinelPath, migrated, dropped) {
76879
76899
  schema_version: 1,
76880
76900
  migration_tool: "knowledge-migrator.ts"
76881
76901
  };
76882
- await mkdir13(path58.dirname(sentinelPath), { recursive: true });
76902
+ await mkdir14(path58.dirname(sentinelPath), { recursive: true });
76883
76903
  await writeFile12(sentinelPath, JSON.stringify(sentinel, null, 2), "utf-8");
76884
76904
  }
76885
76905
  function resolveLegacyHiveKnowledgePath() {
@@ -78096,10 +78116,10 @@ var init_scoring = __esm(() => {
78096
78116
 
78097
78117
  // src/memory/local-jsonl-provider.ts
78098
78118
  import { randomUUID as randomUUID7 } from "node:crypto";
78099
- import { existsSync as existsSync34 } from "node:fs";
78119
+ import { existsSync as existsSync33 } from "node:fs";
78100
78120
  import {
78101
78121
  appendFile as appendFile8,
78102
- mkdir as mkdir14,
78122
+ mkdir as mkdir15,
78103
78123
  readFile as readFile17,
78104
78124
  rename as rename8,
78105
78125
  writeFile as writeFile13
@@ -78447,7 +78467,7 @@ function validateLoadedProposals(values, config3) {
78447
78467
  return { records, invalidCount };
78448
78468
  }
78449
78469
  async function readJsonl(filePath) {
78450
- if (!existsSync34(filePath))
78470
+ if (!existsSync33(filePath))
78451
78471
  return [];
78452
78472
  const content = await readFile17(filePath, "utf-8");
78453
78473
  const records = [];
@@ -78503,12 +78523,12 @@ function parseRecallUsageEvent(event) {
78503
78523
  }
78504
78524
  }
78505
78525
  async function appendJsonl(filePath, value) {
78506
- await mkdir14(path59.dirname(filePath), { recursive: true });
78526
+ await mkdir15(path59.dirname(filePath), { recursive: true });
78507
78527
  await appendFile8(filePath, `${JSON.stringify(value)}
78508
78528
  `, "utf-8");
78509
78529
  }
78510
78530
  async function writeJsonlAtomic(filePath, values) {
78511
- await mkdir14(path59.dirname(filePath), { recursive: true });
78531
+ await mkdir15(path59.dirname(filePath), { recursive: true });
78512
78532
  const tmp = `${filePath}.tmp.${randomUUID7()}`;
78513
78533
  const content = values.map((value) => JSON.stringify(value)).join(`
78514
78534
  `) + (values.length > 0 ? `
@@ -78607,8 +78627,8 @@ var init_prompt_block = __esm(() => {
78607
78627
  });
78608
78628
 
78609
78629
  // src/memory/jsonl-migration.ts
78610
- import { existsSync as existsSync35 } from "node:fs";
78611
- import { copyFile, mkdir as mkdir15, readFile as readFile18, stat as stat6, writeFile as writeFile14 } from "node:fs/promises";
78630
+ import { existsSync as existsSync34 } from "node:fs";
78631
+ import { copyFile as copyFile2, mkdir as mkdir16, readFile as readFile18, stat as stat7, writeFile as writeFile14 } from "node:fs/promises";
78612
78632
  import * as path60 from "node:path";
78613
78633
  function resolveMemoryStorageDir(rootDirectory, config3 = {}) {
78614
78634
  const resolved = resolveConfig(config3);
@@ -78635,25 +78655,25 @@ async function readLegacyJsonl(rootDirectory, config3 = {}) {
78635
78655
  async function backupLegacyJsonl(rootDirectory, config3 = {}) {
78636
78656
  const storageDir = resolveMemoryStorageDir(rootDirectory, config3);
78637
78657
  const backupDir = path60.join(storageDir, "backups");
78638
- await mkdir15(backupDir, { recursive: true });
78658
+ await mkdir16(backupDir, { recursive: true });
78639
78659
  const results = [];
78640
78660
  for (const filename of ["memories.jsonl", "proposals.jsonl"]) {
78641
78661
  const source = path60.join(storageDir, filename);
78642
- if (!existsSync35(source))
78662
+ if (!existsSync34(source))
78643
78663
  continue;
78644
78664
  const backup = path60.join(backupDir, `${filename}.pre-sqlite-migration`);
78645
- if (existsSync35(backup)) {
78665
+ if (existsSync34(backup)) {
78646
78666
  results.push({ source, backup, created: false });
78647
78667
  continue;
78648
78668
  }
78649
- await copyFile(source, backup);
78669
+ await copyFile2(source, backup);
78650
78670
  results.push({ source, backup, created: true });
78651
78671
  }
78652
78672
  return results;
78653
78673
  }
78654
78674
  async function writeJsonlExport(rootDirectory, config3, memories, proposals) {
78655
78675
  const exportDir = path60.join(resolveMemoryStorageDir(rootDirectory, config3), "export");
78656
- await mkdir15(exportDir, { recursive: true });
78676
+ await mkdir16(exportDir, { recursive: true });
78657
78677
  const memoriesPath = path60.join(exportDir, "memories.jsonl");
78658
78678
  const proposalsPath = path60.join(exportDir, "proposals.jsonl");
78659
78679
  await writeFile14(memoriesPath, toJsonl(memories), "utf-8");
@@ -78662,14 +78682,14 @@ async function writeJsonlExport(rootDirectory, config3, memories, proposals) {
78662
78682
  }
78663
78683
  async function writeMigrationReport(rootDirectory, report, config3 = {}) {
78664
78684
  const reportPath = path60.join(resolveMemoryStorageDir(rootDirectory, config3), "migration-report.json");
78665
- await mkdir15(path60.dirname(reportPath), { recursive: true });
78685
+ await mkdir16(path60.dirname(reportPath), { recursive: true });
78666
78686
  await writeFile14(reportPath, `${JSON.stringify(report, null, 2)}
78667
78687
  `, "utf-8");
78668
78688
  return reportPath;
78669
78689
  }
78670
78690
  async function readMigrationReport(rootDirectory, config3 = {}) {
78671
78691
  const reportPath = path60.join(resolveMemoryStorageDir(rootDirectory, config3), "migration-report.json");
78672
- if (!existsSync35(reportPath))
78692
+ if (!existsSync34(reportPath))
78673
78693
  return null;
78674
78694
  try {
78675
78695
  return JSON.parse(await readFile18(reportPath, "utf-8"));
@@ -78683,13 +78703,13 @@ async function getLegacyJsonlFileStatus(rootDirectory, config3 = {}) {
78683
78703
  for (const file3 of ["memories.jsonl", "proposals.jsonl"]) {
78684
78704
  const filePath = path60.join(storageDir, file3);
78685
78705
  let sizeBytes = 0;
78686
- if (existsSync35(filePath)) {
78687
- sizeBytes = (await stat6(filePath)).size;
78706
+ if (existsSync34(filePath)) {
78707
+ sizeBytes = (await stat7(filePath)).size;
78688
78708
  }
78689
78709
  statuses.push({
78690
78710
  file: file3,
78691
78711
  path: filePath,
78692
- exists: existsSync35(filePath),
78712
+ exists: existsSync34(filePath),
78693
78713
  sizeBytes
78694
78714
  });
78695
78715
  }
@@ -78770,7 +78790,7 @@ async function readProposalJsonl(filePath, config3) {
78770
78790
  return { records, invalidRows, totalRows: rows.totalRows };
78771
78791
  }
78772
78792
  async function readJsonlRows(filePath) {
78773
- if (!existsSync35(filePath)) {
78793
+ if (!existsSync34(filePath)) {
78774
78794
  return { rows: [], invalidRows: [], totalRows: 0 };
78775
78795
  }
78776
78796
  const content = await readFile18(filePath, "utf-8");
@@ -78808,7 +78828,7 @@ var init_jsonl_migration = __esm(() => {
78808
78828
 
78809
78829
  // src/memory/sqlite-provider.ts
78810
78830
  import { randomUUID as randomUUID8 } from "node:crypto";
78811
- import { mkdirSync as mkdirSync21 } from "node:fs";
78831
+ import { mkdirSync as mkdirSync20 } from "node:fs";
78812
78832
  import { createRequire as createRequire3 } from "node:module";
78813
78833
  import * as path61 from "node:path";
78814
78834
  function loadDatabaseCtor2() {
@@ -78868,7 +78888,7 @@ class SQLiteMemoryProvider {
78868
78888
  if (this.initialized)
78869
78889
  return;
78870
78890
  const dbPath = this.databasePath();
78871
- mkdirSync21(path61.dirname(dbPath), { recursive: true });
78891
+ mkdirSync20(path61.dirname(dbPath), { recursive: true });
78872
78892
  const Db = loadDatabaseCtor2();
78873
78893
  this.db = new Db(dbPath);
78874
78894
  this.db.run("PRAGMA journal_mode = WAL;");
@@ -79734,7 +79754,7 @@ var init_sqlite_provider = __esm(() => {
79734
79754
 
79735
79755
  // src/memory/gateway.ts
79736
79756
  import { createHash as createHash8 } from "node:crypto";
79737
- import { existsSync as existsSync36, readFileSync as readFileSync19 } from "node:fs";
79757
+ import { existsSync as existsSync35, readFileSync as readFileSync19 } from "node:fs";
79738
79758
  import * as path62 from "node:path";
79739
79759
 
79740
79760
  class MemoryGateway {
@@ -80059,7 +80079,7 @@ function readGitRemoteUrl(directory) {
80059
80079
  if (gitRemoteUrlCache.has(directory))
80060
80080
  return gitRemoteUrlCache.get(directory);
80061
80081
  const gitConfigPath = path62.join(directory, ".git", "config");
80062
- if (!existsSync36(gitConfigPath)) {
80082
+ if (!existsSync35(gitConfigPath)) {
80063
80083
  gitRemoteUrlCache.set(directory, undefined);
80064
80084
  return;
80065
80085
  }
@@ -80628,13 +80648,13 @@ var init_recall_planner = __esm(() => {
80628
80648
  });
80629
80649
 
80630
80650
  // src/memory/run-log.ts
80631
- import { appendFile as appendFile9, mkdir as mkdir16 } from "node:fs/promises";
80651
+ import { appendFile as appendFile9, mkdir as mkdir17 } from "node:fs/promises";
80632
80652
  import * as path64 from "node:path";
80633
80653
  async function appendMemoryRunLog(directory, runId, event) {
80634
80654
  const safeRunId = sanitizeRunId(runId);
80635
80655
  const relativePath = path64.join("runs", safeRunId, "memory.jsonl");
80636
80656
  const filePath = validateSwarmPath(directory, relativePath);
80637
- await mkdir16(path64.dirname(filePath), { recursive: true });
80657
+ await mkdir17(path64.dirname(filePath), { recursive: true });
80638
80658
  await appendFile9(filePath, `${JSON.stringify({
80639
80659
  ...event,
80640
80660
  runId: safeRunId,
@@ -81035,7 +81055,7 @@ var init_memory = __esm(() => {
81035
81055
  });
81036
81056
 
81037
81057
  // src/commands/memory.ts
81038
- import { existsSync as existsSync37 } from "node:fs";
81058
+ import { existsSync as existsSync36 } from "node:fs";
81039
81059
  import * as path65 from "node:path";
81040
81060
  import { fileURLToPath as fileURLToPath3 } from "node:url";
81041
81061
  async function handleMemoryCommand(_directory, _args) {
@@ -81067,7 +81087,7 @@ async function handleMemoryStatusCommand(directory, _args) {
81067
81087
  `- Provider: \`${config3.provider}\``,
81068
81088
  `- Storage: \`${storageDir}\``,
81069
81089
  `- SQLite path: \`${sqlitePath}\``,
81070
- `- SQLite database exists: \`${existsSync37(sqlitePath)}\``,
81090
+ `- SQLite database exists: \`${existsSync36(sqlitePath)}\``,
81071
81091
  `- Automatic destructive cleanup: \`disabled\``,
81072
81092
  "",
81073
81093
  "### Legacy JSONL"
@@ -82765,11 +82785,11 @@ function createRedactedContext(line, findings) {
82765
82785
  function scanFileForSecrets(filePath) {
82766
82786
  const findings = [];
82767
82787
  try {
82768
- const lstat = fs30.lstatSync(filePath);
82769
- if (lstat.isSymbolicLink()) {
82788
+ const lstat2 = fs30.lstatSync(filePath);
82789
+ if (lstat2.isSymbolicLink()) {
82770
82790
  return findings;
82771
82791
  }
82772
- if (lstat.size > MAX_FILE_SIZE_BYTES) {
82792
+ if (lstat2.size > MAX_FILE_SIZE_BYTES) {
82773
82793
  return findings;
82774
82794
  }
82775
82795
  let buffer;
@@ -82857,18 +82877,18 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
82857
82877
  stats.skippedDirs++;
82858
82878
  continue;
82859
82879
  }
82860
- let lstat;
82880
+ let lstat2;
82861
82881
  try {
82862
- lstat = fs30.lstatSync(fullPath);
82882
+ lstat2 = fs30.lstatSync(fullPath);
82863
82883
  } catch {
82864
82884
  stats.fileErrors++;
82865
82885
  continue;
82866
82886
  }
82867
- if (lstat.isSymbolicLink()) {
82887
+ if (lstat2.isSymbolicLink()) {
82868
82888
  stats.symlinkSkipped++;
82869
82889
  continue;
82870
82890
  }
82871
- if (lstat.isDirectory()) {
82891
+ if (lstat2.isDirectory()) {
82872
82892
  let realPath;
82873
82893
  try {
82874
82894
  realPath = fs30.realpathSync(fullPath);
@@ -82886,7 +82906,7 @@ function findScannableFiles(dir, excludeExact, excludeGlobs, scanDir, visited, s
82886
82906
  }
82887
82907
  const subFiles = findScannableFiles(fullPath, excludeExact, excludeGlobs, scanDir, visited, stats);
82888
82908
  files.push(...subFiles);
82889
- } else if (lstat.isFile()) {
82909
+ } else if (lstat2.isFile()) {
82890
82910
  const ext = path68.extname(fullPath).toLowerCase();
82891
82911
  if (!DEFAULT_EXCLUDE_EXTENSIONS.has(ext)) {
82892
82912
  files.push(fullPath);
@@ -83217,8 +83237,8 @@ var init_secretscan = __esm(() => {
83217
83237
  break;
83218
83238
  const fileFindings = scanFileForSecrets(filePath);
83219
83239
  try {
83220
- const stat7 = fs30.statSync(filePath);
83221
- if (stat7.size > MAX_FILE_SIZE_BYTES) {
83240
+ const stat8 = fs30.statSync(filePath);
83241
+ if (stat8.size > MAX_FILE_SIZE_BYTES) {
83222
83242
  skippedFiles++;
83223
83243
  continue;
83224
83244
  }
@@ -84028,8 +84048,8 @@ function sharedTrailingSegments(a, b) {
84028
84048
  function isCacheStale(impactMap, generatedAtMs) {
84029
84049
  for (const sourcePath of Object.keys(impactMap)) {
84030
84050
  try {
84031
- const stat7 = fs34.statSync(sourcePath);
84032
- if (stat7.mtimeMs > generatedAtMs) {
84051
+ const stat8 = fs34.statSync(sourcePath);
84052
+ if (stat8.mtimeMs > generatedAtMs) {
84033
84053
  return true;
84034
84054
  }
84035
84055
  } catch {
@@ -85375,8 +85395,8 @@ function manifestHash(dir) {
85375
85395
  if (!entries.has(name2))
85376
85396
  continue;
85377
85397
  try {
85378
- const stat7 = fs39.statSync(path77.join(dir, name2));
85379
- parts2.push(`${name2}:${stat7.size}:${stat7.mtimeMs}:${stat7.ino}`);
85398
+ const stat8 = fs39.statSync(path77.join(dir, name2));
85399
+ parts2.push(`${name2}:${stat8.size}:${stat8.mtimeMs}:${stat8.ino}`);
85380
85400
  } catch {}
85381
85401
  }
85382
85402
  return parts2.join("|");
@@ -88931,7 +88951,7 @@ var init_reset_session = __esm(() => {
88931
88951
  });
88932
88952
 
88933
88953
  // src/summaries/manager.ts
88934
- import { mkdirSync as mkdirSync23, readdirSync as readdirSync18, renameSync as renameSync14, rmSync as rmSync6, statSync as statSync19 } from "node:fs";
88954
+ import { mkdirSync as mkdirSync22, readdirSync as readdirSync17, renameSync as renameSync14, rmSync as rmSync5, statSync as statSync18 } from "node:fs";
88935
88955
  import * as path82 from "node:path";
88936
88956
  function sanitizeSummaryId(id) {
88937
88957
  if (!id || id.length === 0) {
@@ -88977,14 +88997,14 @@ async function storeSummary(directory, id, fullOutput, summaryText, maxStoredByt
88977
88997
  originalBytes: Buffer.byteLength(fullOutput, "utf8")
88978
88998
  };
88979
88999
  const entryJson = JSON.stringify(entry);
88980
- mkdirSync23(summaryDir, { recursive: true });
89000
+ mkdirSync22(summaryDir, { recursive: true });
88981
89001
  const tempPath = path82.join(summaryDir, `${sanitizedId}.json.tmp.${Date.now()}.${process.pid}`);
88982
89002
  try {
88983
89003
  await bunWrite(tempPath, entryJson);
88984
89004
  renameSync14(tempPath, summaryPath);
88985
89005
  } catch (error93) {
88986
89006
  try {
88987
- rmSync6(tempPath, { force: true });
89007
+ rmSync5(tempPath, { force: true });
88988
89008
  } catch {}
88989
89009
  throw error93;
88990
89010
  }
@@ -90130,8 +90150,8 @@ async function countProposals(directory) {
90130
90150
  const proposalsDir = validateSwarmPath(directory, "skills/proposals");
90131
90151
  if (!fsSync6.existsSync(proposalsDir))
90132
90152
  return 0;
90133
- const { readdir: readdir5 } = await import("node:fs/promises");
90134
- const entries = await readdir5(proposalsDir);
90153
+ const { readdir: readdir6 } = await import("node:fs/promises");
90154
+ const entries = await readdir6(proposalsDir);
90135
90155
  return entries.filter((f) => f.endsWith(".md")).length;
90136
90156
  } catch {
90137
90157
  return 0;
@@ -91238,7 +91258,7 @@ Showing full help:
91238
91258
  }
91239
91259
  async function handleModeCommandWithBundledSkills(ctx, handler) {
91240
91260
  if (ctx.packageRoot) {
91241
- syncBundledProjectSkillsIfMissing(ctx.directory, ctx.packageRoot);
91261
+ await syncBundledProjectSkillsIfMissingAsync(ctx.directory, ctx.packageRoot);
91242
91262
  }
91243
91263
  return Promise.resolve(handler(ctx.directory, ctx.args));
91244
91264
  }
@@ -91438,6 +91458,13 @@ var init_registry = __esm(() => {
91438
91458
  description: "Run tool registration coherence check",
91439
91459
  category: "diagnostics"
91440
91460
  },
91461
+ "doctor-tools": {
91462
+ handler: (ctx) => handleDoctorToolsCommand(ctx.directory, ctx.args),
91463
+ description: "Run tool registration coherence check",
91464
+ category: "diagnostics",
91465
+ aliasOf: "doctor tools",
91466
+ deprecated: true
91467
+ },
91441
91468
  diagnose: {
91442
91469
  handler: (ctx) => handleDiagnoseCommand(ctx.directory, ctx.args),
91443
91470
  description: "Run health check on swarm state",
@@ -93921,7 +93948,8 @@ ${customAppendPrompt}` : AUTONOMOUS_OVERSIGHT_PROMPT;
93921
93948
  write: false,
93922
93949
  edit: false,
93923
93950
  patch: false
93924
- }
93951
+ },
93952
+ thinking: { type: "disabled" }
93925
93953
  }
93926
93954
  };
93927
93955
  }
@@ -94523,7 +94551,8 @@ ${customAppendPrompt}` : roleConfig.prompt;
94523
94551
  write: false,
94524
94552
  edit: false,
94525
94553
  patch: false
94526
- }
94554
+ },
94555
+ thinking: { type: "disabled" }
94527
94556
  }
94528
94557
  };
94529
94558
  }
@@ -95928,7 +95957,7 @@ COVERAGE REPORTING:
95928
95957
  `;
95929
95958
 
95930
95959
  // src/agents/index.ts
95931
- import { mkdir as mkdir17, writeFile as writeFile15 } from "node:fs/promises";
95960
+ import { mkdir as mkdir18, writeFile as writeFile15 } from "node:fs/promises";
95932
95961
  import * as path87 from "node:path";
95933
95962
  function stripSwarmPrefix(agentName, swarmPrefix) {
95934
95963
  if (!swarmPrefix || !agentName)
@@ -96408,7 +96437,7 @@ function getAgentConfigs(config3, directory, sessionId, projectContext) {
96408
96437
  generatedAt: new Date().toISOString(),
96409
96438
  agents: agentToolSnapshot
96410
96439
  }, null, 2);
96411
- mkdir17(evidenceDir, { recursive: true }).then(() => writeFile15(path87.join(evidenceDir, filename), snapshotData)).catch(() => {});
96440
+ mkdir18(evidenceDir, { recursive: true }).then(() => writeFile15(path87.join(evidenceDir, filename), snapshotData)).catch(() => {});
96412
96441
  }
96413
96442
  return result;
96414
96443
  }
@@ -96448,12 +96477,12 @@ __export(exports_evidence_summary_integration, {
96448
96477
  createEvidenceSummaryIntegration: () => createEvidenceSummaryIntegration,
96449
96478
  EvidenceSummaryIntegration: () => EvidenceSummaryIntegration
96450
96479
  });
96451
- import { existsSync as existsSync49, mkdirSync as mkdirSync25, writeFileSync as writeFileSync14 } from "node:fs";
96480
+ import { existsSync as existsSync48, mkdirSync as mkdirSync24, writeFileSync as writeFileSync14 } from "node:fs";
96452
96481
  import * as path88 from "node:path";
96453
96482
  function persistSummary(projectDir, artifact, filename) {
96454
96483
  const swarmPath = path88.join(projectDir, ".swarm");
96455
- if (!existsSync49(swarmPath)) {
96456
- mkdirSync25(swarmPath, { recursive: true });
96484
+ if (!existsSync48(swarmPath)) {
96485
+ mkdirSync24(swarmPath, { recursive: true });
96457
96486
  }
96458
96487
  const artifactPath = path88.join(swarmPath, filename);
96459
96488
  const content = JSON.stringify(artifact, null, 2);
@@ -97464,8 +97493,8 @@ var init_schema3 = __esm(() => {
97464
97493
 
97465
97494
  // src/summaries/store.ts
97466
97495
  import {
97467
- existsSync as existsSync61,
97468
- mkdirSync as mkdirSync32,
97496
+ existsSync as existsSync60,
97497
+ mkdirSync as mkdirSync31,
97469
97498
  readFileSync as readFileSync41,
97470
97499
  renameSync as renameSync20,
97471
97500
  unlinkSync as unlinkSync15,
@@ -97473,13 +97502,13 @@ import {
97473
97502
  } from "node:fs";
97474
97503
  import * as path101 from "node:path";
97475
97504
  function writeRawSidecar(absPath, bundle) {
97476
- mkdirSync32(path101.dirname(absPath), { recursive: true });
97505
+ mkdirSync31(path101.dirname(absPath), { recursive: true });
97477
97506
  const tempFile = `${absPath}.tmp-${Date.now()}-${process.pid}`;
97478
97507
  try {
97479
97508
  writeFileSync21(tempFile, JSON.stringify(bundle, null, 2), "utf-8");
97480
97509
  renameSync20(tempFile, absPath);
97481
97510
  } finally {
97482
- if (existsSync61(tempFile)) {
97511
+ if (existsSync60(tempFile)) {
97483
97512
  try {
97484
97513
  unlinkSync15(tempFile);
97485
97514
  } catch {}
@@ -97566,7 +97595,7 @@ function readSupervisorReportRaw(directory, phase) {
97566
97595
  } catch {
97567
97596
  return null;
97568
97597
  }
97569
- if (!existsSync61(abs))
97598
+ if (!existsSync60(abs))
97570
97599
  return null;
97571
97600
  try {
97572
97601
  const parsed = JSON.parse(readFileSync41(abs, "utf-8"));
@@ -100963,7 +100992,7 @@ __export(exports_runtime, {
100963
100992
  clearParserCache: () => clearParserCache,
100964
100993
  _internals: () => _internals68
100965
100994
  });
100966
- import { existsSync as existsSync66, statSync as statSync27 } from "node:fs";
100995
+ import { existsSync as existsSync65, statSync as statSync26 } from "node:fs";
100967
100996
  import * as path114 from "node:path";
100968
100997
  import { fileURLToPath as fileURLToPath4 } from "node:url";
100969
100998
  async function initTreeSitter() {
@@ -101031,7 +101060,7 @@ async function loadGrammar(languageId) {
101031
101060
  const parser = new Parser;
101032
101061
  const wasmFileName = getWasmFileName(normalizedId);
101033
101062
  const wasmPath = path114.join(getGrammarsDirAbsolute(), wasmFileName);
101034
- if (!existsSync66(wasmPath)) {
101063
+ if (!existsSync65(wasmPath)) {
101035
101064
  throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
101036
101065
  ` + `Make sure to run 'bun run build' to copy grammar files to dist/lang/grammars/`);
101037
101066
  }
@@ -101072,7 +101101,7 @@ async function isGrammarAvailable(languageId) {
101072
101101
  try {
101073
101102
  const wasmFileName = getWasmFileName(normalizedId);
101074
101103
  const wasmPath = path114.join(getGrammarsDirAbsolute(), wasmFileName);
101075
- statSync27(wasmPath);
101104
+ statSync26(wasmPath);
101076
101105
  return true;
101077
101106
  } catch {
101078
101107
  return false;
@@ -101134,11 +101163,11 @@ __export(exports_doc_scan, {
101134
101163
  import * as crypto9 from "node:crypto";
101135
101164
  import * as fs67 from "node:fs";
101136
101165
  import {
101137
- mkdir as mkdir20,
101138
- readdir as readdir6,
101166
+ mkdir as mkdir21,
101167
+ readdir as readdir7,
101139
101168
  readFile as readFile22,
101140
101169
  realpath as realpath3,
101141
- stat as stat9,
101170
+ stat as stat10,
101142
101171
  writeFile as writeFile17
101143
101172
  } from "node:fs/promises";
101144
101173
  import * as path116 from "node:path";
@@ -101221,8 +101250,8 @@ async function scanDocIndex(directory) {
101221
101250
  for (const file3 of existingManifest.files) {
101222
101251
  try {
101223
101252
  const fullPath = path116.join(directory, file3.path);
101224
- const stat10 = fs67.statSync(fullPath);
101225
- if (stat10.mtimeMs > file3.mtime) {
101253
+ const stat11 = fs67.statSync(fullPath);
101254
+ if (stat11.mtimeMs > file3.mtime) {
101226
101255
  cacheValid = false;
101227
101256
  break;
101228
101257
  }
@@ -101242,7 +101271,7 @@ async function scanDocIndex(directory) {
101242
101271
  const walkDir2 = async (dir) => {
101243
101272
  let entries;
101244
101273
  try {
101245
- entries = await readdir6(dir, { withFileTypes: true });
101274
+ entries = await readdir7(dir, { withFileTypes: true });
101246
101275
  if (dir === directory)
101247
101276
  rootReadable = true;
101248
101277
  } catch {
@@ -101260,7 +101289,7 @@ async function scanDocIndex(directory) {
101260
101289
  const rel = path116.relative(resolvedDirectory, resolved);
101261
101290
  if (rel.startsWith("..") || path116.isAbsolute(rel))
101262
101291
  continue;
101263
- const targetStat = await stat9(symlinkPath);
101292
+ const targetStat = await stat10(symlinkPath);
101264
101293
  isFile = targetStat.isFile();
101265
101294
  } catch {
101266
101295
  continue;
@@ -101289,7 +101318,7 @@ async function scanDocIndex(directory) {
101289
101318
  continue;
101290
101319
  let fileStat;
101291
101320
  try {
101292
- fileStat = await stat9(fullPath);
101321
+ fileStat = await stat10(fullPath);
101293
101322
  } catch {
101294
101323
  continue;
101295
101324
  }
@@ -101336,7 +101365,7 @@ async function scanDocIndex(directory) {
101336
101365
  files: discoveredFiles
101337
101366
  };
101338
101367
  try {
101339
- await mkdir20(path116.dirname(manifestPath), { recursive: true });
101368
+ await mkdir21(path116.dirname(manifestPath), { recursive: true });
101340
101369
  await writeFile17(manifestPath, JSON.stringify(manifest, null, 2), "utf-8");
101341
101370
  } catch {}
101342
101371
  return { manifest, cached: false };
@@ -101550,7 +101579,7 @@ var init_doc_scan = __esm(() => {
101550
101579
  });
101551
101580
 
101552
101581
  // src/hooks/knowledge-reader.ts
101553
- import { existsSync as existsSync67 } from "node:fs";
101582
+ import { existsSync as existsSync66 } from "node:fs";
101554
101583
  import { readFile as readFile23 } from "node:fs/promises";
101555
101584
  import * as path117 from "node:path";
101556
101585
  function inferCategoriesFromPhase(phaseDescription) {
@@ -101598,7 +101627,7 @@ function inferCategoriesFromPhase(phaseDescription) {
101598
101627
  }
101599
101628
  async function transactShownFile(shownFile, mutate) {
101600
101629
  return transactFile(shownFile, async (filePath) => {
101601
- if (!existsSync67(filePath))
101630
+ if (!existsSync66(filePath))
101602
101631
  return {};
101603
101632
  try {
101604
101633
  const content = await readFile23(filePath, "utf-8");
@@ -101728,7 +101757,7 @@ async function readMergedKnowledge(directory, config3, context, opts) {
101728
101757
  async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
101729
101758
  const shownFile = path117.join(directory, ".swarm", ".knowledge-shown.json");
101730
101759
  try {
101731
- if (!existsSync67(shownFile)) {
101760
+ if (!existsSync66(shownFile)) {
101732
101761
  return;
101733
101762
  }
101734
101763
  let shownIds;
@@ -102508,8 +102537,8 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
102508
102537
  const traceabilityAbs = path162.join(outAbs, TRACEABILITY_REL);
102509
102538
  let registry3 = null;
102510
102539
  try {
102511
- const stat11 = await fs109.promises.stat(traceabilityAbs);
102512
- if (stat11.size <= MAX_TRACEABILITY_BYTES) {
102540
+ const stat12 = await fs109.promises.stat(traceabilityAbs);
102541
+ if (stat12.size <= MAX_TRACEABILITY_BYTES) {
102513
102542
  const raw = await fs109.promises.readFile(traceabilityAbs, "utf-8");
102514
102543
  const parsed = JSON.parse(raw);
102515
102544
  registry3 = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
@@ -103808,6 +103837,7 @@ function createBackgroundCompletionObserver(opts) {
103808
103837
  init_pr_subscriptions();
103809
103838
  init_commands();
103810
103839
  init_config();
103840
+ init_bundled_skills();
103811
103841
  init_constants();
103812
103842
 
103813
103843
  // src/config/project-init.ts
@@ -103822,8 +103852,8 @@ function writeProjectConfigIfNew(directory, quiet = false) {
103822
103852
  const dest = path91.join(opencodeDir, "opencode-swarm.json");
103823
103853
  const normalizePathForCompare = (p) => process.platform === "win32" ? p.toLowerCase() : p;
103824
103854
  try {
103825
- const stat7 = fs49.lstatSync(opencodeDir);
103826
- if (stat7.isSymbolicLink())
103855
+ const stat8 = fs49.lstatSync(opencodeDir);
103856
+ if (stat8.isSymbolicLink())
103827
103857
  return;
103828
103858
  const resolvedDir = fs49.realpathSync(opencodeDir);
103829
103859
  const canonicalOpencode = path91.join(fs49.realpathSync(directory), ".opencode");
@@ -103996,8 +104026,8 @@ function extractFileSummary(filePath, content, absolutePath, existingEntry) {
103996
104026
  let mtimeMs = 0;
103997
104027
  if (absolutePath) {
103998
104028
  try {
103999
- const stat7 = fs51.statSync(absolutePath);
104000
- mtimeMs = stat7.mtimeMs;
104029
+ const stat8 = fs51.statSync(absolutePath);
104030
+ mtimeMs = stat8.mtimeMs;
104001
104031
  } catch {}
104002
104032
  }
104003
104033
  const base = {
@@ -104589,6 +104619,12 @@ async function dispatchFullAutoOversight(input) {
104589
104619
  let dispatchError;
104590
104620
  try {
104591
104621
  const createResult = await client.session.create({
104622
+ ...input.sessionID ? {
104623
+ body: {
104624
+ parentID: input.sessionID,
104625
+ title: "full_auto_oversight background"
104626
+ }
104627
+ } : {},
104592
104628
  query: { directory: input.directory }
104593
104629
  });
104594
104630
  if (!createResult.data) {
@@ -106523,6 +106559,9 @@ async function dispatchCriticAndWriteEvent(directory, architectOutput, criticCon
106523
106559
  let criticResponse = "";
106524
106560
  try {
106525
106561
  const createResult = await client.session.create({
106562
+ ...sessionID ? {
106563
+ body: { parentID: sessionID, title: "full_auto_critic background" }
106564
+ } : {},
106526
106565
  query: { directory }
106527
106566
  });
106528
106567
  if (!createResult.data) {
@@ -106940,8 +106979,8 @@ function createPhaseMonitorHook(directory, preflightManager, curatorRunner, dele
106940
106979
  const initResult = await runner(directory, curatorConfig, llmDelegate);
106941
106980
  if (initResult.briefing) {
106942
106981
  const briefingPath = path102.join(directory, ".swarm", "curator-briefing.md");
106943
- const { mkdir: mkdir18, writeFile: writeFile16 } = await import("node:fs/promises");
106944
- await mkdir18(path102.dirname(briefingPath), { recursive: true });
106982
+ const { mkdir: mkdir19, writeFile: writeFile16 } = await import("node:fs/promises");
106983
+ await mkdir19(path102.dirname(briefingPath), { recursive: true });
106945
106984
  await writeFile16(briefingPath, initResult.briefing, "utf-8");
106946
106985
  const { buildApprovedReceipt: buildApprovedReceipt2, persistReviewReceipt: persistReviewReceipt2 } = await Promise.resolve().then(() => (init_review_receipt(), exports_review_receipt));
106947
106986
  const initReceipt = buildApprovedReceipt2({
@@ -107083,7 +107122,7 @@ import * as path111 from "node:path";
107083
107122
  init_logger();
107084
107123
  init_path_security();
107085
107124
  import * as fsSync7 from "node:fs";
107086
- import { existsSync as existsSync62, realpathSync as realpathSync13 } from "node:fs";
107125
+ import { existsSync as existsSync61, realpathSync as realpathSync13 } from "node:fs";
107087
107126
  import * as fsPromises5 from "node:fs/promises";
107088
107127
  import * as os15 from "node:os";
107089
107128
  import * as path106 from "node:path";
@@ -107756,15 +107795,15 @@ function classifyDataOperation(line) {
107756
107795
  const lower = trimmed.toLowerCase();
107757
107796
  const evidence = trimmed.slice(0, 160);
107758
107797
  let operation = null;
107759
- let access4 = "unknown";
107798
+ let access5 = "unknown";
107760
107799
  let entity;
107761
107800
  if (/\b(transaction|begintransaction|commit|rollback)\b/i.test(trimmed)) {
107762
107801
  operation = "transaction";
107763
- access4 = "database";
107802
+ access5 = "database";
107764
107803
  }
107765
107804
  if (/\b(migrate|migration|schema\.alter|createTable|dropTable)\b/i.test(trimmed)) {
107766
107805
  operation = "migration";
107767
- access4 = "database";
107806
+ access5 = "database";
107768
107807
  }
107769
107808
  if (/\b(findMany|findUnique|findFirst|select|query|count|aggregate)\b/.test(trimmed)) {
107770
107809
  operation ??= "read";
@@ -107776,17 +107815,17 @@ function classifyDataOperation(line) {
107776
107815
  operation = "delete";
107777
107816
  }
107778
107817
  if (/\b(sql`|\bselect\b|\binsert\b|\bupdate\b|\bdelete\b|\bfrom\b)/i.test(trimmed)) {
107779
- access4 = "sql";
107818
+ access5 = "sql";
107780
107819
  }
107781
107820
  if (/\b(prisma|drizzle|sequelize|knex|db\.|database\.|repository\.)/i.test(trimmed)) {
107782
- access4 = access4 === "sql" ? "sql" : "orm";
107821
+ access5 = access5 === "sql" ? "sql" : "orm";
107783
107822
  }
107784
107823
  if (/\b(readFile|writeFile|appendFile|rmSync|unlink)\b/.test(trimmed)) {
107785
- access4 = "filesystem";
107824
+ access5 = "filesystem";
107786
107825
  operation ??= lower.includes("read") ? "read" : "write";
107787
107826
  }
107788
107827
  if (/\b(fetch|axios|http\.|https\.)\b/.test(trimmed)) {
107789
- access4 = "network";
107828
+ access5 = "network";
107790
107829
  operation ??= "read";
107791
107830
  }
107792
107831
  const entityMatch = trimmed.match(/\b(?:prisma|db|database)\.(\w+)/i);
@@ -107794,7 +107833,7 @@ function classifyDataOperation(line) {
107794
107833
  entity = entityMatch[1];
107795
107834
  if (!operation)
107796
107835
  return null;
107797
- return { operation, access: access4, entity, line: 0, evidence };
107836
+ return { operation, access: access5, entity, line: 0, evidence };
107798
107837
  }
107799
107838
  function extractDataOperations(content) {
107800
107839
  const facts = [];
@@ -108333,7 +108372,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
108333
108372
  if (realRoot === null) {
108334
108373
  return null;
108335
108374
  }
108336
- if (!existsSync62(resolved)) {
108375
+ if (!existsSync61(resolved)) {
108337
108376
  const EXTENSIONS = [
108338
108377
  ".ts",
108339
108378
  ".tsx",
@@ -108347,7 +108386,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
108347
108386
  let found = null;
108348
108387
  for (const ext of EXTENSIONS) {
108349
108388
  const candidate = resolved + ext;
108350
- if (existsSync62(candidate)) {
108389
+ if (existsSync61(candidate)) {
108351
108390
  found = candidate;
108352
108391
  break;
108353
108392
  }
@@ -108732,7 +108771,7 @@ async function buildWorkspaceGraphAsync(workspaceRoot, options) {
108732
108771
  const walkBudgetMs = options?.walkBudgetMs ?? DEFAULT_WALK_BUDGET_MS;
108733
108772
  const followSymlinks = options?.followSymlinks ?? false;
108734
108773
  const absoluteRoot = path106.resolve(workspaceRoot);
108735
- if (!existsSync62(absoluteRoot)) {
108774
+ if (!existsSync61(absoluteRoot)) {
108736
108775
  throw new Error(`Workspace directory does not exist: ${workspaceRoot}`);
108737
108776
  }
108738
108777
  if (isRefusedWorkspaceRoot(absoluteRoot)) {
@@ -108817,7 +108856,7 @@ function getCachedMtime(workspace) {
108817
108856
  }
108818
108857
  // src/tools/repo-graph/incremental.ts
108819
108858
  init_logger();
108820
- import { existsSync as existsSync64 } from "node:fs";
108859
+ import { existsSync as existsSync63 } from "node:fs";
108821
108860
  import * as fsPromises7 from "node:fs/promises";
108822
108861
  import * as path110 from "node:path";
108823
108862
 
@@ -109276,7 +109315,7 @@ function buildOntologyPreflightPacket(graph, filePaths = [], options = {}) {
109276
109315
  init_utils2();
109277
109316
  init_logger();
109278
109317
  init_path_security();
109279
- import { constants as constants5, existsSync as existsSync63, readFileSync as readFileSync44, statSync as statSync25 } from "node:fs";
109318
+ import { constants as constants5, existsSync as existsSync62, readFileSync as readFileSync44, statSync as statSync24 } from "node:fs";
109280
109319
  import * as fsPromises6 from "node:fs/promises";
109281
109320
  import * as path109 from "node:path";
109282
109321
  var _internals67 = {
@@ -109336,7 +109375,7 @@ async function loadGraph(workspace) {
109336
109375
  if (cached3 && !isDirty(normalized)) {
109337
109376
  try {
109338
109377
  const graphPath = getGraphPath(workspace);
109339
- if (existsSync63(graphPath)) {
109378
+ if (existsSync62(graphPath)) {
109340
109379
  const stats = await fsPromises6.stat(graphPath);
109341
109380
  const cachedMtime = getCachedMtime(normalized);
109342
109381
  if (cachedMtime !== undefined && stats.mtimeMs !== cachedMtime) {
@@ -109353,7 +109392,7 @@ async function loadGraph(workspace) {
109353
109392
  }
109354
109393
  try {
109355
109394
  const graphPath = getGraphPath(workspace);
109356
- if (!existsSync63(graphPath)) {
109395
+ if (!existsSync62(graphPath)) {
109357
109396
  return null;
109358
109397
  }
109359
109398
  const stats = await fsPromises6.stat(graphPath);
@@ -109387,9 +109426,9 @@ function loadGraphSync(workspace) {
109387
109426
  const normalized = path109.normalize(workspace);
109388
109427
  try {
109389
109428
  const graphPath = getGraphPath(workspace);
109390
- if (!existsSync63(graphPath))
109429
+ if (!existsSync62(graphPath))
109391
109430
  return null;
109392
- const stats = statSync25(graphPath);
109431
+ const stats = statSync24(graphPath);
109393
109432
  const content = readFileSync44(graphPath, "utf-8");
109394
109433
  if (content.includes("\x00") || content.includes("�")) {
109395
109434
  throw Object.assign(new Error("repo-graph.json contains null bytes or invalid encoding"), { code: "CORRUPTION" });
@@ -109513,7 +109552,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
109513
109552
  const updatedPaths = new Set;
109514
109553
  for (const rawFilePath of filePaths) {
109515
109554
  const normalizedPath = normalizeGraphPath(rawFilePath);
109516
- const fileExists = existsSync64(rawFilePath);
109555
+ const fileExists = existsSync63(rawFilePath);
109517
109556
  if (fileExists) {
109518
109557
  graph.edges = graph.edges.filter((e) => normalizeGraphPath(e.source) !== normalizedPath);
109519
109558
  const result = scanFile(rawFilePath, absoluteRoot, maxFileSize);
@@ -109553,7 +109592,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
109553
109592
  if (loadedMtime !== undefined) {
109554
109593
  try {
109555
109594
  const graphPath = getGraphPath(workspaceRoot);
109556
- if (existsSync64(graphPath)) {
109595
+ if (existsSync63(graphPath)) {
109557
109596
  const currentStats = await fsPromises7.stat(graphPath);
109558
109597
  if (currentStats.mtimeMs !== loadedMtime) {
109559
109598
  warn(`[repo-graph] Concurrent modification detected — falling back to full rebuild`);
@@ -110389,15 +110428,15 @@ import * as fs65 from "node:fs";
110389
110428
  var cache2 = new Map;
110390
110429
  function getCachedGraph2(directory) {
110391
110430
  const file3 = getGraphPath(directory);
110392
- let stat9;
110431
+ let stat10;
110393
110432
  try {
110394
- stat9 = fs65.statSync(file3);
110433
+ stat10 = fs65.statSync(file3);
110395
110434
  } catch {
110396
110435
  cache2.delete(directory);
110397
110436
  return null;
110398
110437
  }
110399
110438
  const cached3 = cache2.get(directory);
110400
- if (cached3 && cached3.mtimeMs === stat9.mtimeMs && cached3.size === stat9.size) {
110439
+ if (cached3 && cached3.mtimeMs === stat10.mtimeMs && cached3.size === stat10.size) {
110401
110440
  return cached3.graph;
110402
110441
  }
110403
110442
  let graph;
@@ -110411,7 +110450,7 @@ function getCachedGraph2(directory) {
110411
110450
  cache2.delete(directory);
110412
110451
  return null;
110413
110452
  }
110414
- cache2.set(directory, { graph, mtimeMs: stat9.mtimeMs, size: stat9.size });
110453
+ cache2.set(directory, { graph, mtimeMs: stat10.mtimeMs, size: stat10.size });
110415
110454
  return graph;
110416
110455
  }
110417
110456
  function buildCoderLocalizationBlock(directory, targetFile) {
@@ -112848,7 +112887,7 @@ import * as path120 from "node:path";
112848
112887
 
112849
112888
  // src/turbo/lean/evidence.ts
112850
112889
  init_bun_compat();
112851
- import { rmSync as rmSync7 } from "node:fs";
112890
+ import { rmSync as rmSync6 } from "node:fs";
112852
112891
  import * as fs69 from "node:fs/promises";
112853
112892
  import * as path119 from "node:path";
112854
112893
  function leanTurboEvidenceDir(directory, phase) {
@@ -112891,7 +112930,7 @@ async function atomicWriteJson(filePath, data) {
112891
112930
  await fs69.rename(tempPath, filePath);
112892
112931
  } catch (error93) {
112893
112932
  try {
112894
- rmSync7(tempPath, { force: true });
112933
+ rmSync6(tempPath, { force: true });
112895
112934
  } catch {}
112896
112935
  throw error93;
112897
112936
  }
@@ -113093,12 +113132,18 @@ async function writeReviewerEvidence(directory, phase, verdict, reason) {
113093
113132
  }
113094
113133
  return evidencePath;
113095
113134
  }
113096
- async function defaultDispatchReviewerAgent(directory, reviewPackage, agentName, timeoutMs) {
113135
+ async function defaultDispatchReviewerAgent(directory, reviewPackage, agentName, timeoutMs, parentSessionId) {
113097
113136
  const client = swarmState.opencodeClient;
113098
113137
  if (!client) {
113099
113138
  throw new Error("OpencodeClient not available");
113100
113139
  }
113101
113140
  const sessionResult = await client.session.create({
113141
+ ...parentSessionId ? {
113142
+ body: {
113143
+ parentID: parentSessionId,
113144
+ title: "lean_turbo_reviewer background"
113145
+ }
113146
+ } : {},
113102
113147
  query: { directory }
113103
113148
  });
113104
113149
  if (!sessionResult.data?.id) {
@@ -113190,7 +113235,7 @@ async function dispatchPhaseReviewer(directory, phase, sessionID, config3) {
113190
113235
  const pkg = await _internals70.compileReviewPackage(directory, phase, sessionID, mergedConfig.requireDiffSummary);
113191
113236
  let responseText;
113192
113237
  try {
113193
- responseText = await _internals70.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs);
113238
+ responseText = await _internals70.dispatchReviewerAgent(directory, pkg, agentName, mergedConfig.timeoutMs, sessionID);
113194
113239
  } catch (error93) {
113195
113240
  const evidencePath2 = await _internals70.writeReviewerEvidence(directory, phase, "REJECTED", error93 instanceof Error ? error93.message : String(error93));
113196
113241
  return {
@@ -113794,7 +113839,7 @@ function createDarkMatterDetectorHook(directory) {
113794
113839
  }
113795
113840
 
113796
113841
  // src/hooks/delegate-ack-collector.ts
113797
- import { appendFile as appendFile13, mkdir as mkdir24 } from "node:fs/promises";
113842
+ import { appendFile as appendFile13, mkdir as mkdir25 } from "node:fs/promises";
113798
113843
  import * as path123 from "node:path";
113799
113844
 
113800
113845
  // src/hooks/knowledge-application.ts
@@ -113802,8 +113847,8 @@ init_task_file();
113802
113847
  init_logger();
113803
113848
  init_knowledge_store();
113804
113849
  var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
113805
- import { existsSync as existsSync70 } from "node:fs";
113806
- import { appendFile as appendFile11, mkdir as mkdir23, readFile as readFile25 } from "node:fs/promises";
113850
+ import { existsSync as existsSync69 } from "node:fs";
113851
+ import { appendFile as appendFile11, mkdir as mkdir24, readFile as readFile25 } from "node:fs/promises";
113807
113852
  import * as path121 from "node:path";
113808
113853
  function resolveApplicationLogPath(directory) {
113809
113854
  return path121.join(directory, ".swarm", "knowledge-application.jsonl");
@@ -113826,7 +113871,7 @@ function parseAcknowledgments(text) {
113826
113871
  async function appendAudit(directory, record3) {
113827
113872
  const filePath = resolveApplicationLogPath(directory);
113828
113873
  const dirPath = path121.dirname(filePath);
113829
- await mkdir23(dirPath, { recursive: true });
113874
+ await mkdir24(dirPath, { recursive: true });
113830
113875
  let release;
113831
113876
  try {
113832
113877
  release = await import_proper_lockfile9.default.lock(dirPath, {
@@ -113887,7 +113932,7 @@ async function bumpCountersBatch(directory, bumps) {
113887
113932
  const swarmPath = resolveSwarmKnowledgePath(directory);
113888
113933
  await transactKnowledge(swarmPath, (swarm) => applyOne(swarm) ? swarm : null);
113889
113934
  const hivePath = resolveHiveKnowledgePath();
113890
- if (existsSync70(hivePath)) {
113935
+ if (existsSync69(hivePath)) {
113891
113936
  await transactKnowledge(hivePath, (hive) => applyOne(hive) ? hive : null);
113892
113937
  }
113893
113938
  }
@@ -114686,7 +114731,7 @@ function extractTaskId2(prompt) {
114686
114731
  }
114687
114732
  async function appendUnacknowledgedCritical(directory, record3) {
114688
114733
  const filePath = validateSwarmPath(directory, "unacknowledged-criticals.jsonl");
114689
- await mkdir24(path123.dirname(filePath), { recursive: true });
114734
+ await mkdir25(path123.dirname(filePath), { recursive: true });
114690
114735
  await appendFile13(filePath, `${JSON.stringify(record3)}
114691
114736
  `, "utf-8");
114692
114737
  }
@@ -114861,7 +114906,7 @@ init_extractors();
114861
114906
  // src/hooks/phase-directives.ts
114862
114907
  init_knowledge_events();
114863
114908
  init_knowledge_store();
114864
- import { existsSync as existsSync71 } from "node:fs";
114909
+ import { existsSync as existsSync70 } from "node:fs";
114865
114910
  async function collectPhaseDirectiveIds(directory, phaseLabel) {
114866
114911
  const events = await readKnowledgeEvents(directory);
114867
114912
  const ids = new Set;
@@ -114881,7 +114926,7 @@ async function readEntriesById(directory) {
114881
114926
  for (const e of swarm)
114882
114927
  map3.set(e.id, e);
114883
114928
  const hivePath = resolveHiveKnowledgePath();
114884
- if (existsSync71(hivePath)) {
114929
+ if (existsSync70(hivePath)) {
114885
114930
  const hive = await readKnowledge(hivePath);
114886
114931
  for (const e of hive)
114887
114932
  if (!map3.has(e.id))
@@ -116642,7 +116687,7 @@ ${errorSummary}`);
116642
116687
  init_schema();
116643
116688
  init_state();
116644
116689
  init_logger();
116645
- import { appendFile as appendFile14, mkdir as mkdir25 } from "node:fs/promises";
116690
+ import { appendFile as appendFile14, mkdir as mkdir26 } from "node:fs/promises";
116646
116691
  import * as path126 from "node:path";
116647
116692
  var HIGH_RISK_TOOLS = new Set([
116648
116693
  "save_plan",
@@ -116714,7 +116759,7 @@ async function knowledgeApplicationGateBefore(directory, input, config3) {
116714
116759
  }
116715
116760
  async function writeWarnEvent2(directory, record3) {
116716
116761
  const filePath = path126.join(directory, ".swarm", "events.jsonl");
116717
- await mkdir25(path126.dirname(filePath), { recursive: true });
116762
+ await mkdir26(path126.dirname(filePath), { recursive: true });
116718
116763
  await appendFile14(filePath, `${JSON.stringify(record3)}
116719
116764
  `, "utf-8");
116720
116765
  }
@@ -116772,7 +116817,7 @@ init_schema();
116772
116817
  // src/services/directive-predicate-runner.ts
116773
116818
  init_bun_compat();
116774
116819
  init_logger();
116775
- import { existsSync as existsSync74 } from "node:fs";
116820
+ import { existsSync as existsSync73 } from "node:fs";
116776
116821
  import * as path127 from "node:path";
116777
116822
  var PREDICATE_TIMEOUT_MS = 15000;
116778
116823
  var TOOL_BINARY_ALLOWLIST = new Set([
@@ -116814,7 +116859,7 @@ function findBinaryInPath(binary2) {
116814
116859
  if (!dir)
116815
116860
  continue;
116816
116861
  const candidate = path127.join(dir, exeName);
116817
- if (existsSync74(candidate))
116862
+ if (existsSync73(candidate))
116818
116863
  return candidate;
116819
116864
  }
116820
116865
  return null;
@@ -117703,8 +117748,8 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = 7) {
117703
117748
  continue;
117704
117749
  const filePath = path130.join(dirPath, entry.name);
117705
117750
  try {
117706
- const stat11 = await fs80.stat(filePath);
117707
- if (now - stat11.mtimeMs > cutoffMs) {
117751
+ const stat12 = await fs80.stat(filePath);
117752
+ if (now - stat12.mtimeMs > cutoffMs) {
117708
117753
  await fs80.unlink(filePath);
117709
117754
  }
117710
117755
  } catch {}
@@ -118890,13 +118935,13 @@ init_zod();
118890
118935
  init_path_security();
118891
118936
  init_create_tool();
118892
118937
  import {
118893
- existsSync as existsSync76,
118894
- mkdirSync as mkdirSync33,
118938
+ existsSync as existsSync75,
118939
+ mkdirSync as mkdirSync32,
118895
118940
  mkdtempSync as mkdtempSync2,
118896
118941
  readFileSync as readFileSync50,
118897
118942
  realpathSync as realpathSync16,
118898
118943
  renameSync as renameSync24,
118899
- rmdirSync as rmdirSync2,
118944
+ rmdirSync,
118900
118945
  unlinkSync as unlinkSync18,
118901
118946
  writeFileSync as writeFileSync23
118902
118947
  } from "node:fs";
@@ -119240,7 +119285,7 @@ function applyHunks(content, fileDiff) {
119240
119285
  }
119241
119286
  function atomicWriteFileSync2(targetPath, content) {
119242
119287
  const dir = path133.dirname(targetPath);
119243
- mkdirSync33(dir, { recursive: true });
119288
+ mkdirSync32(dir, { recursive: true });
119244
119289
  const tempPrefix = `.apply-patch-${Date.now()}-${process.pid}`;
119245
119290
  let tempPath;
119246
119291
  try {
@@ -119253,15 +119298,15 @@ function atomicWriteFileSync2(targetPath, content) {
119253
119298
  writeFileSync23(tempPath, content, "utf-8");
119254
119299
  renameSync24(tempPath, targetPath);
119255
119300
  } finally {
119256
- if (existsSync76(tempPath)) {
119301
+ if (existsSync75(tempPath)) {
119257
119302
  try {
119258
119303
  unlinkSync18(tempPath);
119259
119304
  } catch {}
119260
119305
  }
119261
119306
  const tempDir = path133.dirname(tempPath);
119262
- if (tempDir !== dir && existsSync76(tempDir)) {
119307
+ if (tempDir !== dir && existsSync75(tempDir)) {
119263
119308
  try {
119264
- rmdirSync2(tempDir);
119309
+ rmdirSync(tempDir);
119265
119310
  } catch {}
119266
119311
  }
119267
119312
  }
@@ -119336,7 +119381,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
119336
119381
  };
119337
119382
  }
119338
119383
  const parentDir = path133.dirname(fullPath);
119339
- if (!existsSync76(parentDir)) {
119384
+ if (!existsSync75(parentDir)) {
119340
119385
  return {
119341
119386
  file: targetPath,
119342
119387
  status: "error",
@@ -119352,7 +119397,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
119352
119397
  ]
119353
119398
  };
119354
119399
  }
119355
- if (existsSync76(fullPath)) {
119400
+ if (existsSync75(fullPath)) {
119356
119401
  return {
119357
119402
  file: targetPath,
119358
119403
  status: "error",
@@ -119427,7 +119472,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
119427
119472
  ]
119428
119473
  };
119429
119474
  }
119430
- if (!existsSync76(fullPath)) {
119475
+ if (!existsSync75(fullPath)) {
119431
119476
  return {
119432
119477
  file: targetPath,
119433
119478
  status: "error",
@@ -119471,7 +119516,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
119471
119516
  hunksFailed: 0
119472
119517
  };
119473
119518
  }
119474
- if (!existsSync76(fullPath)) {
119519
+ if (!existsSync75(fullPath)) {
119475
119520
  return {
119476
119521
  file: targetPath,
119477
119522
  status: "error",
@@ -119622,7 +119667,7 @@ var applyPatch = createSwarmTool({
119622
119667
  const dryRun = obj.dryRun ?? false;
119623
119668
  const allowCreates = obj.allowCreates ?? false;
119624
119669
  const allowDeletes = obj.allowDeletes ?? false;
119625
- if (!existsSync76(directory)) {
119670
+ if (!existsSync75(directory)) {
119626
119671
  return JSON.stringify(buildErrorResult("Workspace directory does not exist"), null, 2);
119627
119672
  }
119628
119673
  if (files.length === 0) {
@@ -120582,8 +120627,8 @@ function estimateCyclomaticComplexity(content) {
120582
120627
  }
120583
120628
  function getComplexityForFile(filePath) {
120584
120629
  try {
120585
- const stat11 = fs86.statSync(filePath);
120586
- if (stat11.size > MAX_FILE_SIZE_BYTES3) {
120630
+ const stat12 = fs86.statSync(filePath);
120631
+ if (stat12.size > MAX_FILE_SIZE_BYTES3) {
120587
120632
  return null;
120588
120633
  }
120589
120634
  const content = fs86.readFileSync(filePath, "utf-8");
@@ -120784,8 +120829,8 @@ async function computeDuplicationRatio(files, workingDir) {
120784
120829
  continue;
120785
120830
  }
120786
120831
  try {
120787
- const stat11 = fs86.statSync(fullPath);
120788
- if (stat11.size > MAX_FILE_SIZE_BYTES3) {
120832
+ const stat12 = fs86.statSync(fullPath);
120833
+ if (stat12.size > MAX_FILE_SIZE_BYTES3) {
120789
120834
  continue;
120790
120835
  }
120791
120836
  const content = fs86.readFileSync(fullPath, "utf-8");
@@ -121245,8 +121290,8 @@ async function getGitChurn(days, directory) {
121245
121290
  }
121246
121291
  function getComplexityForFile2(filePath) {
121247
121292
  try {
121248
- const stat11 = fs87.statSync(filePath);
121249
- if (stat11.size > MAX_FILE_SIZE_BYTES4) {
121293
+ const stat12 = fs87.statSync(filePath);
121294
+ if (stat12.size > MAX_FILE_SIZE_BYTES4) {
121250
121295
  return null;
121251
121296
  }
121252
121297
  const content = fs87.readFileSync(filePath, "utf-8");
@@ -121441,7 +121486,7 @@ ${body2}`);
121441
121486
  // src/council/council-evidence-writer.ts
121442
121487
  init_zod();
121443
121488
  init_task_file();
121444
- import { appendFileSync as appendFileSync15, existsSync as existsSync81, mkdirSync as mkdirSync35, readFileSync as readFileSync56 } from "node:fs";
121489
+ import { appendFileSync as appendFileSync15, existsSync as existsSync80, mkdirSync as mkdirSync34, readFileSync as readFileSync56 } from "node:fs";
121445
121490
  import { join as join111 } from "node:path";
121446
121491
  var EVIDENCE_DIR2 = ".swarm/evidence";
121447
121492
  var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
@@ -121481,11 +121526,11 @@ async function writeCouncilEvidence(workingDir, synthesis) {
121481
121526
  throw new Error(`writeCouncilEvidence: invalid taskId "${synthesis.taskId}" — must match N.M or N.M.P format`);
121482
121527
  }
121483
121528
  const dir = join111(workingDir, EVIDENCE_DIR2);
121484
- mkdirSync35(dir, { recursive: true });
121529
+ mkdirSync34(dir, { recursive: true });
121485
121530
  const filePath = taskEvidencePath(workingDir, synthesis.taskId);
121486
121531
  await _internals77.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
121487
121532
  const existingRoot = Object.create(null);
121488
- if (existsSync81(filePath)) {
121533
+ if (existsSync80(filePath)) {
121489
121534
  try {
121490
121535
  const parsed = EvidenceFileSchema.parse(JSON.parse(readFileSync56(filePath, "utf-8")));
121491
121536
  safeAssignOwnProps(existingRoot, parsed);
@@ -121517,7 +121562,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
121517
121562
  });
121518
121563
  try {
121519
121564
  const councilDir = join111(workingDir, ".swarm", "council");
121520
- mkdirSync35(councilDir, { recursive: true });
121565
+ mkdirSync34(councilDir, { recursive: true });
121521
121566
  const auditLine = JSON.stringify({
121522
121567
  round: synthesis.roundNumber,
121523
121568
  verdict: synthesis.overallVerdict,
@@ -121879,7 +121924,7 @@ function buildFinalCouncilFeedback(projectSummary, verdict, vetoedBy, requiredFi
121879
121924
 
121880
121925
  // src/council/criteria-store.ts
121881
121926
  init_zod();
121882
- import { existsSync as existsSync82, mkdirSync as mkdirSync36, readFileSync as readFileSync57, writeFileSync as writeFileSync25 } from "node:fs";
121927
+ import { existsSync as existsSync81, mkdirSync as mkdirSync35, readFileSync as readFileSync57, writeFileSync as writeFileSync25 } from "node:fs";
121883
121928
  import { join as join112 } from "node:path";
121884
121929
  var COUNCIL_DIR = ".swarm/council";
121885
121930
  var CouncilCriteriaSchema = exports_external.object({
@@ -121893,7 +121938,7 @@ var CouncilCriteriaSchema = exports_external.object({
121893
121938
  });
121894
121939
  function writeCriteria(workingDir, taskId, criteria) {
121895
121940
  const dir = join112(workingDir, COUNCIL_DIR);
121896
- mkdirSync36(dir, { recursive: true });
121941
+ mkdirSync35(dir, { recursive: true });
121897
121942
  const payload = {
121898
121943
  taskId,
121899
121944
  criteria,
@@ -121903,7 +121948,7 @@ function writeCriteria(workingDir, taskId, criteria) {
121903
121948
  }
121904
121949
  function readCriteria(workingDir, taskId) {
121905
121950
  const filePath = join112(workingDir, COUNCIL_DIR, `${safeId(taskId)}.json`);
121906
- if (!existsSync82(filePath))
121951
+ if (!existsSync81(filePath))
121907
121952
  return null;
121908
121953
  try {
121909
121954
  return CouncilCriteriaSchema.parse(JSON.parse(readFileSync57(filePath, "utf-8")));
@@ -123715,8 +123760,8 @@ function readEvidenceFiles(evidenceDir, _cwd) {
123715
123760
  if (!resolvedPath.startsWith(evidenceDirResolved)) {
123716
123761
  continue;
123717
123762
  }
123718
- const stat11 = fs92.lstatSync(filePath);
123719
- if (!stat11.isFile()) {
123763
+ const stat12 = fs92.lstatSync(filePath);
123764
+ if (!stat12.isFile()) {
123720
123765
  continue;
123721
123766
  }
123722
123767
  } catch {
@@ -125692,6 +125737,12 @@ async function generateMutants(files, ctx) {
125692
125737
  };
125693
125738
  try {
125694
125739
  const createResult = await client.session.create({
125740
+ ...ctx?.sessionID ? {
125741
+ body: {
125742
+ parentID: ctx.sessionID,
125743
+ title: "mutation_generator background"
125744
+ }
125745
+ } : {},
125695
125746
  query: { directory }
125696
125747
  });
125697
125748
  if (!createResult.data) {
@@ -126219,8 +126270,8 @@ var git_blame = createSwarmTool({
126219
126270
  lines: []
126220
126271
  });
126221
126272
  }
126222
- const stat11 = fs96.statSync(resolvedPath);
126223
- if (stat11.isDirectory()) {
126273
+ const stat12 = fs96.statSync(resolvedPath);
126274
+ if (stat12.isDirectory()) {
126224
126275
  return JSON.stringify({
126225
126276
  error: "path is a directory, not a file",
126226
126277
  file: file3,
@@ -126740,9 +126791,9 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
126740
126791
  continue;
126741
126792
  }
126742
126793
  const fullPath = path149.join(dir, entry);
126743
- let stat11;
126794
+ let stat12;
126744
126795
  try {
126745
- stat11 = fs97.statSync(fullPath);
126796
+ stat12 = fs97.statSync(fullPath);
126746
126797
  } catch (e) {
126747
126798
  stats.fileErrors.push({
126748
126799
  path: fullPath,
@@ -126750,9 +126801,9 @@ function findSourceFiles2(dir, files = [], stats = { skippedDirs: [], skippedFil
126750
126801
  });
126751
126802
  continue;
126752
126803
  }
126753
- if (stat11.isDirectory()) {
126804
+ if (stat12.isDirectory()) {
126754
126805
  findSourceFiles2(fullPath, files, stats);
126755
- } else if (stat11.isFile()) {
126806
+ } else if (stat12.isFile()) {
126756
126807
  const ext = path149.extname(fullPath).toLowerCase();
126757
126808
  if (SUPPORTED_EXTENSIONS3.includes(ext)) {
126758
126809
  files.push(fullPath);
@@ -126847,8 +126898,8 @@ var imports = createSwarmTool({
126847
126898
  if (consumers.length >= MAX_CONSUMERS)
126848
126899
  break;
126849
126900
  try {
126850
- const stat11 = fs97.statSync(filePath);
126851
- if (stat11.size > MAX_FILE_SIZE_BYTES6) {
126901
+ const stat12 = fs97.statSync(filePath);
126902
+ if (stat12.size > MAX_FILE_SIZE_BYTES6) {
126852
126903
  skippedFileCount++;
126853
126904
  continue;
126854
126905
  }
@@ -127302,7 +127353,7 @@ init_zod();
127302
127353
  init_config();
127303
127354
  init_knowledge_store();
127304
127355
  init_create_tool();
127305
- import { existsSync as existsSync88 } from "node:fs";
127356
+ import { existsSync as existsSync87 } from "node:fs";
127306
127357
  var DEFAULT_LIMIT = 10;
127307
127358
  var MAX_LESSON_LENGTH = 200;
127308
127359
  var VALID_CATEGORIES3 = [
@@ -127378,14 +127429,14 @@ function validateLimit(limit) {
127378
127429
  }
127379
127430
  async function readSwarmKnowledge(directory) {
127380
127431
  const swarmPath = resolveSwarmKnowledgePath(directory);
127381
- if (!existsSync88(swarmPath)) {
127432
+ if (!existsSync87(swarmPath)) {
127382
127433
  return [];
127383
127434
  }
127384
127435
  return readKnowledge(swarmPath);
127385
127436
  }
127386
127437
  async function readHiveKnowledge() {
127387
127438
  const hivePath = resolveHiveKnowledgePath();
127388
- if (!existsSync88(hivePath)) {
127439
+ if (!existsSync87(hivePath)) {
127389
127440
  return [];
127390
127441
  }
127391
127442
  return readKnowledge(hivePath);
@@ -128687,6 +128738,12 @@ class LeanTurboRunner {
128687
128738
  try {
128688
128739
  const effectiveDirectory = worktreeDirectory ?? this._directory;
128689
128740
  const createResult = await session.create({
128741
+ ...this._sessionID ? {
128742
+ body: {
128743
+ parentID: this._sessionID,
128744
+ title: `lean_turbo_lane_${lane.laneId} background`
128745
+ }
128746
+ } : {},
128690
128747
  query: { directory: effectiveDirectory }
128691
128748
  });
128692
128749
  if (!createResult.data) {
@@ -133985,8 +134042,8 @@ async function placeholderScan(input, directory) {
133985
134042
  }
133986
134043
  let content;
133987
134044
  try {
133988
- const stat11 = fs112.statSync(fullPath);
133989
- if (stat11.size > MAX_FILE_SIZE) {
134045
+ const stat12 = fs112.statSync(fullPath);
134046
+ if (stat12.size > MAX_FILE_SIZE) {
133990
134047
  continue;
133991
134048
  }
133992
134049
  content = fs112.readFileSync(fullPath, "utf-8");
@@ -136325,14 +136382,14 @@ async function runSecretscanWithFiles(files, directory) {
136325
136382
  skippedFiles++;
136326
136383
  continue;
136327
136384
  }
136328
- let stat11;
136385
+ let stat12;
136329
136386
  try {
136330
- stat11 = fs116.statSync(file3);
136387
+ stat12 = fs116.statSync(file3);
136331
136388
  } catch {
136332
136389
  skippedFiles++;
136333
136390
  continue;
136334
136391
  }
136335
- if (stat11.size > MAX_FILE_SIZE_BYTES8) {
136392
+ if (stat12.size > MAX_FILE_SIZE_BYTES8) {
136336
136393
  skippedFiles++;
136337
136394
  continue;
136338
136395
  }
@@ -137159,8 +137216,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
137159
137216
  for (const entry of entries) {
137160
137217
  const entryPath = path171.join(evidenceDir, entry);
137161
137218
  try {
137162
- const stat11 = fs117.statSync(entryPath);
137163
- if (!stat11.isDirectory()) {
137219
+ const stat12 = fs117.statSync(entryPath);
137220
+ if (!stat12.isDirectory()) {
137164
137221
  continue;
137165
137222
  }
137166
137223
  } catch {
@@ -137180,11 +137237,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
137180
137237
  if (!resolvedPath.startsWith(evidenceDirResolved + path171.sep)) {
137181
137238
  continue;
137182
137239
  }
137183
- const stat11 = fs117.lstatSync(evidenceFilePath);
137184
- if (!stat11.isFile()) {
137240
+ const stat12 = fs117.lstatSync(evidenceFilePath);
137241
+ if (!stat12.isFile()) {
137185
137242
  continue;
137186
137243
  }
137187
- if (stat11.size > MAX_FILE_SIZE_BYTES8) {
137244
+ if (stat12.size > MAX_FILE_SIZE_BYTES8) {
137188
137245
  continue;
137189
137246
  }
137190
137247
  } catch {
@@ -140038,7 +140095,7 @@ init_zod();
140038
140095
  init_config();
140039
140096
  init_schema();
140040
140097
  init_create_tool();
140041
- import { mkdir as mkdir30, rename as rename12, writeFile as writeFile21 } from "node:fs/promises";
140098
+ import { mkdir as mkdir31, rename as rename12, writeFile as writeFile21 } from "node:fs/promises";
140042
140099
  import * as path176 from "node:path";
140043
140100
  var MAX_SPEC_BYTES2 = 256 * 1024;
140044
140101
  var spec_write = createSwarmTool({
@@ -140081,7 +140138,7 @@ var spec_write = createSwarmTool({
140081
140138
  }, null, 2);
140082
140139
  }
140083
140140
  const target = path176.join(directory, ".swarm", "spec.md");
140084
- await mkdir30(path176.dirname(target), { recursive: true });
140141
+ await mkdir31(path176.dirname(target), { recursive: true });
140085
140142
  const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
140086
140143
  let finalContent = content;
140087
140144
  if (mode === "append") {
@@ -140110,8 +140167,8 @@ ${content}
140110
140167
  init_zod();
140111
140168
  init_loader();
140112
140169
  import {
140113
- existsSync as existsSync103,
140114
- mkdirSync as mkdirSync42,
140170
+ existsSync as existsSync102,
140171
+ mkdirSync as mkdirSync41,
140115
140172
  readFileSync as readFileSync82,
140116
140173
  renameSync as renameSync26,
140117
140174
  unlinkSync as unlinkSync21,
@@ -140347,7 +140404,7 @@ function getPhaseMutationGapFinding(phaseNumber, workingDir) {
140347
140404
  }
140348
140405
  function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
140349
140406
  const evidenceDir = path177.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
140350
- mkdirSync42(evidenceDir, { recursive: true });
140407
+ mkdirSync41(evidenceDir, { recursive: true });
140351
140408
  const evidenceFile = path177.join(evidenceDir, "phase-council.json");
140352
140409
  const evidenceBundle = {
140353
140410
  entries: [
@@ -140385,7 +140442,7 @@ function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
140385
140442
  writeFileSync33(tempFile, JSON.stringify(evidenceBundle, null, 2), "utf-8");
140386
140443
  renameSync26(tempFile, evidenceFile);
140387
140444
  } finally {
140388
- if (existsSync103(tempFile)) {
140445
+ if (existsSync102(tempFile)) {
140389
140446
  unlinkSync21(tempFile);
140390
140447
  }
140391
140448
  }
@@ -141319,8 +141376,8 @@ async function syntaxCheck(input, directory, config3) {
141319
141376
  return { result, counted: false, failed: false, skipped: true };
141320
141377
  }
141321
141378
  try {
141322
- const stat11 = fs123.statSync(fullPath);
141323
- if (stat11.size >= MAX_FILE_SIZE2) {
141379
+ const stat12 = fs123.statSync(fullPath);
141380
+ if (stat12.size >= MAX_FILE_SIZE2) {
141324
141381
  result.skipped_reason = "file_too_large";
141325
141382
  return { result, counted: false, failed: false, skipped: true };
141326
141383
  }
@@ -141552,15 +141609,15 @@ function findSourceFiles3(dir, files = []) {
141552
141609
  continue;
141553
141610
  }
141554
141611
  const fullPath = path180.join(dir, entry);
141555
- let stat11;
141612
+ let stat12;
141556
141613
  try {
141557
- stat11 = fs124.statSync(fullPath);
141614
+ stat12 = fs124.statSync(fullPath);
141558
141615
  } catch {
141559
141616
  continue;
141560
141617
  }
141561
- if (stat11.isDirectory()) {
141618
+ if (stat12.isDirectory()) {
141562
141619
  findSourceFiles3(fullPath, files);
141563
- } else if (stat11.isFile()) {
141620
+ } else if (stat12.isFile()) {
141564
141621
  if (isSupportedExtension(fullPath)) {
141565
141622
  files.push(fullPath);
141566
141623
  }
@@ -141657,8 +141714,8 @@ var todo_extract = createSwarmTool({
141657
141714
  return JSON.stringify(errorResult, null, 2);
141658
141715
  }
141659
141716
  const filesToScan = [];
141660
- const stat11 = fs124.statSync(scanPath);
141661
- if (stat11.isFile()) {
141717
+ const stat12 = fs124.statSync(scanPath);
141718
+ if (stat12.isFile()) {
141662
141719
  if (isSupportedExtension(scanPath)) {
141663
141720
  filesToScan.push(scanPath);
141664
141721
  } else {
@@ -142779,7 +142836,7 @@ import * as zlib from "node:zlib";
142779
142836
  init_utils2();
142780
142837
  init_redaction();
142781
142838
  import { createHash as createHash17 } from "node:crypto";
142782
- import { appendFile as appendFile17, mkdir as mkdir31 } from "node:fs/promises";
142839
+ import { appendFile as appendFile17, mkdir as mkdir32 } from "node:fs/promises";
142783
142840
  import * as path185 from "node:path";
142784
142841
  var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
142785
142842
  var MAX_EVIDENCE_TEXT_LENGTH = 4000;
@@ -142788,7 +142845,7 @@ async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
142788
142845
  const capturedAt = now().toISOString();
142789
142846
  const records = inputs.map((input) => createEvidenceDocumentRecord(input, capturedAt)).filter((record3) => record3 !== null);
142790
142847
  if (records.length > 0) {
142791
- await mkdir31(path185.dirname(filePath), { recursive: true });
142848
+ await mkdir32(path185.dirname(filePath), { recursive: true });
142792
142849
  await appendFile17(filePath, `${records.map((record3) => JSON.stringify(record3)).join(`
142793
142850
  `)}
142794
142851
  `, "utf-8");
@@ -144689,6 +144746,7 @@ init_warning_buffer();
144689
144746
  var _heartbeatTimers = new Map;
144690
144747
  var SWARM_COMMAND_SYSTEM_RULE_TAG = "[opencode-swarm:swarm-command-rule]";
144691
144748
  var PACKAGE_ROOT2 = path192.resolve(path192.dirname(fileURLToPath5(import.meta.url)), "..");
144749
+ var SYNC_BUNDLED_SKILLS_TIMEOUT_MS = 2000;
144692
144750
  function createSwarmCommandSystemRuleHook(agentDefinitions, registeredAgents) {
144693
144751
  return async (input, output) => {
144694
144752
  const { sessionID } = input;
@@ -144787,6 +144845,14 @@ async function initializeOpenCodeSwarm(ctx) {
144787
144845
  });
144788
144846
  writeSwarmConfigExampleIfNew(ctx.directory);
144789
144847
  writeProjectConfigIfNew(ctx.directory, config3.quiet);
144848
+ queueMicrotask(() => {
144849
+ withTimeout(syncBundledProjectSkillsIfMissingAsync(ctx.directory, PACKAGE_ROOT2, config3.quiet), SYNC_BUNDLED_SKILLS_TIMEOUT_MS, new Error(`syncBundledProjectSkillsIfMissingAsync exceeded ${SYNC_BUNDLED_SKILLS_TIMEOUT_MS}ms budget; continuing without skill materialization (command-path sync remains a backstop)`)).catch((err3) => {
144850
+ const msg = err3 instanceof Error ? err3.message : String(err3);
144851
+ log("bundled skill materialization timed out or failed (non-fatal)", {
144852
+ error: msg
144853
+ });
144854
+ });
144855
+ });
144790
144856
  if (config3.version_check !== false) {
144791
144857
  scheduleVersionCheck(package_default.version, (msg) => {
144792
144858
  if (config3.quiet) {