opencode-swarm 7.93.1 → 7.94.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/cli/{config-doctor-fkwyrtpq.js → config-doctor-ecmx9scq.js} +2 -2
  2. package/dist/cli/{guardrail-explain-bjsc2ydm.js → guardrail-explain-0xdn6krd.js} +7 -7
  3. package/dist/cli/{guardrail-log-x3w800x5.js → guardrail-log-0q6pvbpx.js} +3 -3
  4. package/dist/cli/{index-xsbtbffr.js → index-79dcqsg9.js} +4 -0
  5. package/dist/cli/{index-dy6zs70b.js → index-d3dngtfy.js} +8 -8
  6. package/dist/cli/{index-ne4g3mk1.js → index-dgjsa6hy.js} +1 -1
  7. package/dist/cli/{index-5hrexm02.js → index-fjxjb66n.js} +166 -5
  8. package/dist/cli/{index-mv27v975.js → index-ftf7fby8.js} +17 -13
  9. package/dist/cli/{index-w7gkpmq8.js → index-hb10a2g8.js} +35 -2
  10. package/dist/cli/{index-9j1xvd8m.js → index-mk0jc9aw.js} +2 -2
  11. package/dist/cli/{index-yykcmn6m.js → index-tx5czwpd.js} +1 -1
  12. package/dist/cli/{index-2jpbaedv.js → index-vqg905es.js} +1 -1
  13. package/dist/cli/index.js +6 -6
  14. package/dist/cli/{knowledge-store-eqans52j.js → knowledge-store-pa58msy5.js} +3 -1
  15. package/dist/cli/{schema-1kndsf0c.js → schema-jy18ftky.js} +1 -1
  16. package/dist/cli/{skill-generator-d0jzw6n2.js → skill-generator-3tkwcg4x.js} +12 -2
  17. package/dist/hooks/curator.d.ts +8 -3
  18. package/dist/hooks/knowledge-events.d.ts +12 -1
  19. package/dist/hooks/knowledge-store.d.ts +2 -0
  20. package/dist/index.js +855 -422
  21. package/dist/services/skill-generator.d.ts +46 -0
  22. package/dist/tools/index.d.ts +1 -0
  23. package/dist/tools/manifest.d.ts +1 -0
  24. package/dist/tools/stale-reconciliation.d.ts +23 -0
  25. package/dist/tools/tool-metadata.d.ts +4 -0
  26. package/package.json +1 -1
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.93.1",
72
+ version: "7.94.0",
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",
@@ -645,6 +645,10 @@ var init_tool_metadata = __esm(() => {
645
645
  description: "inspect the content and source entries of a skill file",
646
646
  agents: ["architect", "skill_improver"]
647
647
  },
648
+ run_stale_reconciliation: {
649
+ description: "reconcile skills against the knowledge store: mark skills stale when source knowledge is archived or deleted, or clear stale markers",
650
+ agents: ["architect"]
651
+ },
648
652
  skill_regenerate: {
649
653
  description: "regenerate an active skill by re-clustering its source knowledge entries and updating the SKILL.md in place",
650
654
  agents: ["architect"]
@@ -61550,6 +61554,7 @@ __export(exports_knowledge_store, {
61550
61554
  jaccardBigram: () => jaccardBigram,
61551
61555
  inferTags: () => inferTags,
61552
61556
  getPlatformConfigDir: () => getPlatformConfigDir,
61557
+ getArchivedKnowledgeIds: () => getArchivedKnowledgeIds,
61553
61558
  findNearDuplicate: () => findNearDuplicate,
61554
61559
  enforceKnowledgeCap: () => enforceKnowledgeCap,
61555
61560
  computeOutcomeSignal: () => computeOutcomeSignal,
@@ -61790,6 +61795,38 @@ async function transactKnowledge(filePath, mutate) {
61790
61795
  await atomicWriteFile(fp, content);
61791
61796
  }, mutate);
61792
61797
  }
61798
+ async function getArchivedKnowledgeIds(directory) {
61799
+ const archived = new Set;
61800
+ const swarmPath = resolveSwarmKnowledgePath(directory);
61801
+ try {
61802
+ const content = await readFile5(swarmPath, "utf-8");
61803
+ const lines = content.split(`
61804
+ `).filter((l) => l.trim());
61805
+ for (const line of lines) {
61806
+ try {
61807
+ const entry = JSON.parse(line);
61808
+ if (entry.status === "archived" || entry.status === "quarantined" || entry.status === "quarantined_unactionable") {
61809
+ archived.add(entry.id);
61810
+ }
61811
+ } catch {}
61812
+ }
61813
+ } catch {}
61814
+ const hivePath = resolveHiveKnowledgePath();
61815
+ try {
61816
+ const content = await readFile5(hivePath, "utf-8");
61817
+ const lines = content.split(`
61818
+ `).filter((l) => l.trim());
61819
+ for (const line of lines) {
61820
+ try {
61821
+ const entry = JSON.parse(line);
61822
+ if (entry.status === "archived" || entry.status === "quarantined" || entry.status === "quarantined_unactionable") {
61823
+ archived.add(entry.id);
61824
+ }
61825
+ } catch {}
61826
+ }
61827
+ } catch {}
61828
+ return archived;
61829
+ }
61793
61830
  async function appendKnowledgeWithCapEnforcement(filePath, entry, maxEntries) {
61794
61831
  return transactKnowledge(filePath, (entries) => {
61795
61832
  const updated = [...entries, entry];
@@ -62084,7 +62121,8 @@ var init_knowledge_store = __esm(() => {
62084
62121
  computeOutcomeSignal,
62085
62122
  selectKnowledgeCapSurvivors,
62086
62123
  inferTags,
62087
- bumpKnowledgeConfidenceBatch
62124
+ bumpKnowledgeConfidenceBatch,
62125
+ getArchivedKnowledgeIds
62088
62126
  };
62089
62127
  });
62090
62128
 
@@ -63776,6 +63814,8 @@ function countWindowedReceipts(events, entryId, windowMs, nowMs) {
63776
63814
  continue;
63777
63815
  if (e.knowledge_id !== entryId)
63778
63816
  continue;
63817
+ if (e.timestamp === undefined)
63818
+ continue;
63779
63819
  const t = Date.parse(e.timestamp);
63780
63820
  if (Number.isNaN(t) || t < cutoff)
63781
63821
  continue;
@@ -63863,6 +63903,8 @@ async function computeLearningMetrics(directory, options) {
63863
63903
  throwIfAborted(options?.signal);
63864
63904
  if (!isReceiptType(e))
63865
63905
  continue;
63906
+ if (e.timestamp === undefined)
63907
+ continue;
63866
63908
  const t = Date.parse(e.timestamp);
63867
63909
  if (Number.isNaN(t))
63868
63910
  continue;
@@ -65183,16 +65225,21 @@ __export(exports_skill_generator, {
65183
65225
  selectCandidateEntries: () => selectCandidateEntries,
65184
65226
  sanitizeSlug: () => sanitizeSlug,
65185
65227
  retireSkill: () => retireSkill,
65228
+ retireOrMarkStale: () => retireOrMarkStale,
65186
65229
  renderSkillMarkdown: () => renderSkillMarkdown,
65187
65230
  regenerateSkill: () => regenerateSkill,
65188
65231
  proposalPath: () => proposalPath,
65189
65232
  parseDraftFrontmatter: () => parseDraftFrontmatter,
65233
+ markSkillStale: () => markSkillStale,
65190
65234
  listSkills: () => listSkills,
65191
65235
  isValidSlug: () => isValidSlug2,
65192
65236
  isSkillMaturityEligible: () => isSkillMaturityEligible,
65193
65237
  inspectSkill: () => inspectSkill,
65194
65238
  generateSkills: () => generateSkills,
65239
+ findStaleSkillsBySourceKnowledgeId: () => findStaleSkillsBySourceKnowledgeId,
65240
+ findSkillsBySourceKnowledgeId: () => findSkillsBySourceKnowledgeId,
65195
65241
  clusterEntries: () => clusterEntries,
65242
+ clearSkillStale: () => clearSkillStale,
65196
65243
  autoApplyProposals: () => autoApplyProposals,
65197
65244
  activeRepoRelativePath: () => activeRepoRelativePath,
65198
65245
  activePath: () => activePath,
@@ -65204,7 +65251,7 @@ __export(exports_skill_generator, {
65204
65251
  DEFAULT_SKILL_MIN_CONFIDENCE: () => DEFAULT_SKILL_MIN_CONFIDENCE
65205
65252
  });
65206
65253
  import { existsSync as existsSync23, unlinkSync as unlinkSync7 } from "node:fs";
65207
- import { mkdir as mkdir10, readFile as readFile9, rename as rename4, writeFile as writeFile6 } from "node:fs/promises";
65254
+ import { mkdir as mkdir10, readFile as readFile9, rename as rename4, unlink as unlink3, writeFile as writeFile6 } from "node:fs/promises";
65208
65255
  import * as path47 from "node:path";
65209
65256
  function sanitizeSlug(input) {
65210
65257
  const lc = input.toLowerCase().trim();
@@ -65895,10 +65942,81 @@ async function activateProposal(directory, slug, force = false, options = {}) {
65895
65942
  };
65896
65943
  }
65897
65944
  }
65945
+ async function findSkillsBySourceKnowledgeId(directory, sourceId) {
65946
+ const activeDir = path47.join(directory, ".opencode", "skills", "generated");
65947
+ const fs23 = await import("node:fs/promises");
65948
+ if (!existsSync23(activeDir))
65949
+ return [];
65950
+ const entries = await fs23.readdir(activeDir, { withFileTypes: true });
65951
+ const matches = [];
65952
+ for (const e of entries) {
65953
+ if (!e.isDirectory())
65954
+ continue;
65955
+ const skillDir = path47.join(activeDir, e.name);
65956
+ const retiredMarker = path47.join(skillDir, "retired.marker");
65957
+ if (existsSync23(retiredMarker))
65958
+ continue;
65959
+ const staleMarker = path47.join(skillDir, "stale.marker");
65960
+ if (existsSync23(staleMarker))
65961
+ continue;
65962
+ const skillPath = path47.join(skillDir, "SKILL.md");
65963
+ if (!existsSync23(skillPath))
65964
+ continue;
65965
+ let content;
65966
+ try {
65967
+ content = await fs23.readFile(skillPath, "utf-8");
65968
+ } catch {
65969
+ continue;
65970
+ }
65971
+ const fm = parseDraftFrontmatter(content);
65972
+ if (fm?.sourceKnowledgeIds.includes(sourceId)) {
65973
+ matches.push(skillDir);
65974
+ }
65975
+ }
65976
+ return matches;
65977
+ }
65978
+ async function findStaleSkillsBySourceKnowledgeId(directory, archivedIds) {
65979
+ const activeDir = path47.join(directory, ".opencode", "skills", "generated");
65980
+ if (!existsSync23(activeDir))
65981
+ return [];
65982
+ const fs23 = await import("node:fs/promises");
65983
+ const entries = await fs23.readdir(activeDir, { withFileTypes: true });
65984
+ const matches = [];
65985
+ for (const e of entries) {
65986
+ if (!e.isDirectory())
65987
+ continue;
65988
+ const skillDir = path47.join(activeDir, e.name);
65989
+ const retiredMarker = path47.join(skillDir, "retired.marker");
65990
+ if (existsSync23(retiredMarker))
65991
+ continue;
65992
+ const staleMarker = path47.join(skillDir, "stale.marker");
65993
+ if (!existsSync23(staleMarker))
65994
+ continue;
65995
+ const skillPath = path47.join(skillDir, "SKILL.md");
65996
+ if (!existsSync23(skillPath))
65997
+ continue;
65998
+ let content;
65999
+ try {
66000
+ content = await fs23.readFile(skillPath, "utf-8");
66001
+ } catch {
66002
+ continue;
66003
+ }
66004
+ const fm = parseDraftFrontmatter(content);
66005
+ const sourceIds = fm?.sourceKnowledgeIds ?? [];
66006
+ if (sourceIds.length === 0)
66007
+ continue;
66008
+ const allArchived = sourceIds.every((id) => archivedIds.has(id));
66009
+ if (allArchived) {
66010
+ matches.push(skillDir);
66011
+ }
66012
+ }
66013
+ return matches;
66014
+ }
65898
66015
  async function listSkills(directory) {
65899
66016
  const result = {
65900
66017
  proposals: [],
65901
- active: []
66018
+ active: [],
66019
+ stale: []
65902
66020
  };
65903
66021
  const proposalsDir = path47.join(directory, ".swarm", "skills", "proposals");
65904
66022
  const activeDir = path47.join(directory, ".opencode", "skills", "generated");
@@ -65923,6 +66041,16 @@ async function listSkills(directory) {
65923
66041
  const retiredMarker = path47.join(activeDir, e.name, "retired.marker");
65924
66042
  if (existsSync23(retiredMarker))
65925
66043
  continue;
66044
+ const staleMarker = path47.join(activeDir, e.name, "stale.marker");
66045
+ if (existsSync23(staleMarker)) {
66046
+ let reason = "stale";
66047
+ try {
66048
+ const content = await fs23.readFile(staleMarker, "utf-8");
66049
+ reason = content.trim() || "stale";
66050
+ } catch {}
66051
+ result.stale.push({ slug: e.name, reason });
66052
+ continue;
66053
+ }
65926
66054
  const skillPath = path47.join(activeDir, e.name, "SKILL.md");
65927
66055
  if (existsSync23(skillPath)) {
65928
66056
  result.active.push({
@@ -66008,7 +66136,34 @@ async function inspectSkill(directory, slug, prefer = "auto") {
66008
66136
  for (const c of candidates) {
66009
66137
  if (existsSync23(c.p)) {
66010
66138
  const content = await readFile9(c.p, "utf-8");
66011
- return { found: true, path: c.p, content, mode: c.m };
66139
+ const result = { found: true, path: c.p, content, mode: c.m };
66140
+ const fm = parseDraftFrontmatter(content);
66141
+ if (fm && fm.sourceKnowledgeIds.length > 0) {
66142
+ const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
66143
+ const hivePath = resolveHiveKnowledgePath();
66144
+ const hive = existsSync23(hivePath) ? await readKnowledge(hivePath) : [];
66145
+ const allEntries = [...swarm, ...hive];
66146
+ const entryMap = new Map(allEntries.map((e) => [e.id, e]));
66147
+ result.source_knowledge_status = fm.sourceKnowledgeIds.map((id) => {
66148
+ const entry = entryMap.get(id);
66149
+ if (!entry)
66150
+ return { id, status: "deleted" };
66151
+ if (entry.status === "archived" || entry.status === "quarantined") {
66152
+ return { id, status: "archived" };
66153
+ }
66154
+ return { id, status: "active" };
66155
+ });
66156
+ }
66157
+ if (c.m === "active") {
66158
+ const skillDir = path47.join(directory, ".opencode", "skills", "generated", cleanSlug);
66159
+ const staleMarker = path47.join(skillDir, "stale.marker");
66160
+ if (existsSync23(staleMarker)) {
66161
+ try {
66162
+ result.stale_reason = await readFile9(staleMarker, "utf-8");
66163
+ } catch {}
66164
+ }
66165
+ }
66166
+ return result;
66012
66167
  }
66013
66168
  }
66014
66169
  return { found: false };
@@ -66047,6 +66202,54 @@ async function retireSkill(directory, slug, reason) {
66047
66202
  reason
66048
66203
  };
66049
66204
  }
66205
+ async function markSkillStale(skillDir, reason) {
66206
+ await mkdir10(skillDir, { recursive: true });
66207
+ await writeFile6(path47.join(skillDir, "stale.marker"), reason, "utf-8");
66208
+ }
66209
+ async function clearSkillStale(skillDir) {
66210
+ const markerPath = path47.join(skillDir, "stale.marker");
66211
+ try {
66212
+ await unlink3(markerPath);
66213
+ } catch (err) {
66214
+ if (err instanceof Error && "code" in err && err.code === "ENOENT") {
66215
+ return;
66216
+ }
66217
+ warn(`[skill-generator] failed to remove stale.marker at ${markerPath}: ${err instanceof Error ? err.message : String(err)}`);
66218
+ }
66219
+ }
66220
+ async function retireOrMarkStale(directory, skillDir, archivedKnowledgeIds) {
66221
+ const fs23 = await import("node:fs/promises");
66222
+ const skillPath = path47.join(skillDir, "SKILL.md");
66223
+ if (!existsSync23(skillPath)) {
66224
+ await markSkillStale(skillDir, "source knowledge archived, SKILL.md missing");
66225
+ const slug2 = path47.basename(skillDir);
66226
+ return { action: "stale", slug: slug2, skillDir };
66227
+ }
66228
+ let content;
66229
+ try {
66230
+ content = await fs23.readFile(skillPath, "utf-8");
66231
+ } catch {
66232
+ await markSkillStale(skillDir, "source knowledge archived, SKILL.md unreadable");
66233
+ const slug2 = path47.basename(skillDir);
66234
+ return { action: "stale", slug: slug2, skillDir };
66235
+ }
66236
+ const fm = parseDraftFrontmatter(content);
66237
+ const sourceIds = fm?.sourceKnowledgeIds ?? [];
66238
+ if (sourceIds.length === 0) {
66239
+ await markSkillStale(skillDir, "source knowledge archived, no source_knowledge_ids in frontmatter");
66240
+ const slug2 = path47.basename(skillDir);
66241
+ return { action: "stale", slug: slug2, skillDir };
66242
+ }
66243
+ const allArchived = sourceIds.every((id) => archivedKnowledgeIds.has(id));
66244
+ const slug = path47.basename(skillDir);
66245
+ if (allArchived) {
66246
+ await retireSkill(directory, slug, "all source knowledge entries archived or deleted");
66247
+ return { action: "retire", slug, skillDir };
66248
+ } else {
66249
+ await markSkillStale(skillDir, "one or more source knowledge entries archived");
66250
+ return { action: "stale", slug, skillDir };
66251
+ }
66252
+ }
66050
66253
  async function regenerateSkill(directory, slug, options = {}) {
66051
66254
  const cleanSlug = sanitizeSlug(slug);
66052
66255
  if (!isValidSlug2(cleanSlug)) {
@@ -66206,6 +66409,7 @@ async function regenerateSkill(directory, slug, options = {}) {
66206
66409
  try {
66207
66410
  await atomicWrite3(skillPath, content);
66208
66411
  await stampSourceEntries(directory, cleanSlug, matchedEntries.map((e) => e.id));
66412
+ await clearSkillStale(path47.dirname(activePath(directory, cleanSlug)));
66209
66413
  } catch (writeErr) {
66210
66414
  return {
66211
66415
  regenerated: false,
@@ -66249,11 +66453,15 @@ var init_skill_generator = __esm(() => {
66249
66453
  generateSkills,
66250
66454
  activateProposal,
66251
66455
  listSkills,
66456
+ findSkillsBySourceKnowledgeId,
66457
+ findStaleSkillsBySourceKnowledgeId,
66252
66458
  inspectSkill,
66253
66459
  stampSourceEntries,
66254
66460
  parseDraftFrontmatter,
66255
66461
  retireSkill,
66462
+ retireOrMarkStale,
66256
66463
  regenerateSkill,
66464
+ clearSkillStale,
66257
66465
  autoApplyProposals,
66258
66466
  unlinkSync: unlinkSync7
66259
66467
  };
@@ -67199,11 +67407,12 @@ ${digest2.summary}`).join(`
67199
67407
 
67200
67408
  `);
67201
67409
  }
67202
- async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
67410
+ async function autoRetireSkills(directory, _curatorKnowledgePath, excludeSlugs) {
67203
67411
  const observations = [];
67204
67412
  try {
67205
67413
  const skillListResult = await _internals32.listSkills(directory);
67206
67414
  const usageEntries = _internals32.readSkillUsageEntries(directory);
67415
+ const allArchivedIds = await _internals32.getArchivedKnowledgeIds(directory);
67207
67416
  for (const active of skillListResult.active) {
67208
67417
  if (excludeSlugs?.has(active.slug))
67209
67418
  continue;
@@ -67223,30 +67432,20 @@ async function autoRetireSkills(directory, curatorKnowledgePath, excludeSlugs) {
67223
67432
  });
67224
67433
  const violations = skillUsage.filter((e) => e.complianceVerdict === "violated").length;
67225
67434
  const violationRate = skillUsage.length > 0 ? violations / skillUsage.length : 0;
67226
- let allArchived = false;
67227
- try {
67228
- const content = await _internals32.readFileAsync(active.path, "utf-8");
67229
- const fm = _internals32.parseDraftFrontmatter(content);
67230
- if (fm && fm.sourceKnowledgeIds.length > 0) {
67231
- const swarmKnowledge = await _internals32.readKnowledge(curatorKnowledgePath);
67232
- let hiveKnowledge = [];
67233
- try {
67234
- const hivePath = resolveHiveKnowledgePath();
67235
- if (fs24.existsSync(hivePath)) {
67236
- hiveKnowledge = await _internals32.readKnowledge(hivePath);
67237
- }
67238
- } catch {}
67239
- const allKnowledge = [...swarmKnowledge, ...hiveKnowledge];
67240
- const sourceIds = new Set(fm.sourceKnowledgeIds);
67241
- const sources = allKnowledge.filter((e) => sourceIds.has(e.id));
67242
- allArchived = sources.length === sourceIds.size && sources.every((e) => e.status === "archived");
67243
- }
67244
- } catch {}
67245
- if (violationRate > 0.3 || allArchived) {
67246
- const reason = violationRate > 0.3 ? `auto-retire: violation rate ${(violationRate * 100).toFixed(0)}% exceeds 30% threshold` : "auto-retire: all source knowledge entries archived";
67435
+ if (violationRate > 0.3) {
67436
+ const reason = `auto-retire: violation rate ${(violationRate * 100).toFixed(0)}% exceeds 30% threshold`;
67247
67437
  await _internals32.retireSkill(directory, active.slug, reason);
67248
67438
  observations.push(`Skill '${active.slug}' auto-retired: ${reason}`);
67249
67439
  warn(`[curator] ${observations[observations.length - 1]}`);
67440
+ continue;
67441
+ }
67442
+ const result = await _internals32.retireOrMarkStale(directory, path50.dirname(active.path), allArchivedIds);
67443
+ if (result.action === "retire") {
67444
+ observations.push(`Skill '${active.slug}' auto-retired: all source knowledge entries archived`);
67445
+ warn(`[curator] ${observations[observations.length - 1]}`);
67446
+ } else if (result.action === "stale") {
67447
+ observations.push(`Skill '${active.slug}' marked stale: some source knowledge entries archived`);
67448
+ warn(`[curator] ${observations[observations.length - 1]}`);
67250
67449
  }
67251
67450
  }
67252
67451
  } catch (autoRetireErr) {
@@ -68015,6 +68214,29 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config3, know
68015
68214
  const retireNote = ` [${autoRetireObservations.length} skill(s) auto-retired]`;
68016
68215
  phaseDigest.summary += retireNote;
68017
68216
  }
68217
+ try {
68218
+ const eventsContent = await readSwarmFileAsync(directory, "knowledge-events.jsonl");
68219
+ if (eventsContent) {
68220
+ const lines = eventsContent.split(`
68221
+ `).filter((l) => l.trim());
68222
+ const batchEvents = [];
68223
+ for (const line of lines) {
68224
+ try {
68225
+ const event = JSON.parse(line);
68226
+ if (event.type === "skill-stale-batch") {
68227
+ batchEvents.push({
68228
+ skillIds: event.skillIds ?? [],
68229
+ retiredCount: event.retiredCount ?? 0,
68230
+ staleCount: event.staleCount ?? 0
68231
+ });
68232
+ }
68233
+ } catch {}
68234
+ }
68235
+ for (const batch of batchEvents) {
68236
+ warn(`[curator] skill-stale-batch: ${batch.skillIds.length} skills affected (${batch.retiredCount} retired, ${batch.staleCount} stale)`);
68237
+ }
68238
+ }
68239
+ } catch {}
68018
68240
  try {
68019
68241
  const metrics = await computeLearningMetrics(directory, {
68020
68242
  currentPhase: phase
@@ -68245,7 +68467,9 @@ var init_curator = __esm(() => {
68245
68467
  readSkillUsageEntries,
68246
68468
  listSkills,
68247
68469
  parseDraftFrontmatter,
68470
+ retireOrMarkStale,
68248
68471
  retireSkill,
68472
+ getArchivedKnowledgeIds,
68249
68473
  readFileAsync: (filePath, encoding) => import("node:fs/promises").then((fs25) => fs25.readFile(filePath, encoding)),
68250
68474
  readKnowledge,
68251
68475
  reviseSkill,
@@ -68546,7 +68770,7 @@ import {
68546
68770
  readFile as readFile12,
68547
68771
  rename as rename7,
68548
68772
  stat as stat8,
68549
- unlink as unlink3,
68773
+ unlink as unlink4,
68550
68774
  writeFile as writeFile9
68551
68775
  } from "node:fs/promises";
68552
68776
  import * as path52 from "node:path";
@@ -68751,7 +68975,7 @@ async function writeSynonymMapAtomic(filePath, map3) {
68751
68975
  await rename7(tmp, filePath);
68752
68976
  } finally {
68753
68977
  try {
68754
- await unlink3(tmp);
68978
+ await unlink4(tmp);
68755
68979
  } catch {}
68756
68980
  }
68757
68981
  }
@@ -69314,7 +69538,7 @@ function discoverAvailableSkills(directory) {
69314
69538
  if (entry.startsWith("."))
69315
69539
  continue;
69316
69540
  const skillDir = path54.join(rootPath, entry);
69317
- if (_internals34.existsSync(path54.join(skillDir, "retired.marker")))
69541
+ if (_internals34.existsSync(path54.join(skillDir, "retired.marker")) || _internals34.existsSync(path54.join(skillDir, "stale.marker")))
69318
69542
  continue;
69319
69543
  const skillFile = path54.join(skillDir, "SKILL.md");
69320
69544
  try {
@@ -69520,7 +69744,7 @@ async function skillPropagationGateBefore(directory, input, config3) {
69520
69744
  const existingPaths = new Set(scored.map((s) => s.skillPath));
69521
69745
  for (const routingPath of routingPaths) {
69522
69746
  const routedSkillDir = path54.dirname(path54.join(directory, routingPath));
69523
- if (_internals34.existsSync(path54.join(routedSkillDir, "retired.marker")))
69747
+ if (_internals34.existsSync(path54.join(routedSkillDir, "retired.marker")) || _internals34.existsSync(path54.join(routedSkillDir, "stale.marker")))
69524
69748
  continue;
69525
69749
  if (!existingPaths.has(routingPath)) {
69526
69750
  scored.push({
@@ -69831,7 +70055,7 @@ var init_skill_propagation_gate = __esm(() => {
69831
70055
  });
69832
70056
 
69833
70057
  // src/hooks/micro-reflector.ts
69834
- import { existsSync as existsSync28 } from "node:fs";
70058
+ import { existsSync as existsSync27 } from "node:fs";
69835
70059
  import { readFile as readFile13, writeFile as writeFile10 } from "node:fs/promises";
69836
70060
  import * as path55 from "node:path";
69837
70061
  function resolveInsightCandidatesPath(directory) {
@@ -69866,7 +70090,7 @@ async function readTaskTrajectory(directory, taskId) {
69866
70090
  try {
69867
70091
  const rel = path55.join("evidence", sanitizeTaskId2(taskId), "trajectory.jsonl");
69868
70092
  const filePath = validateSwarmPath(directory, rel);
69869
- if (!existsSync28(filePath))
70093
+ if (!existsSync27(filePath))
69870
70094
  return [];
69871
70095
  const content = await readFile13(filePath, "utf-8");
69872
70096
  const out = [];
@@ -70110,7 +70334,7 @@ var init_micro_reflector = __esm(() => {
70110
70334
 
70111
70335
  // src/hooks/knowledge-curator.ts
70112
70336
  import { createHash as createHash9 } from "node:crypto";
70113
- import { existsSync as existsSync29 } from "node:fs";
70337
+ import { existsSync as existsSync28 } from "node:fs";
70114
70338
  import { appendFile as appendFile8, mkdir as mkdir13, readFile as readFile14, writeFile as writeFile11 } from "node:fs/promises";
70115
70339
  import * as path56 from "node:path";
70116
70340
  function pruneSeenRetroSections() {
@@ -70535,7 +70759,7 @@ function readInsightJsonl2(content) {
70535
70759
  async function consumeInsightCandidates(directory, batchLimit = MESO_INSIGHT_BATCH_LIMIT) {
70536
70760
  try {
70537
70761
  const filePath = resolveInsightCandidatesPath(directory);
70538
- if (!existsSync29(filePath))
70762
+ if (!existsSync28(filePath))
70539
70763
  return [];
70540
70764
  const consumed = [];
70541
70765
  await transactFile(filePath, async (p) => readInsightJsonl2(await readFile14(p, "utf-8").catch(() => "")), async (p, data) => {
@@ -71676,12 +71900,12 @@ var init_trajectory_cluster = __esm(() => {
71676
71900
  });
71677
71901
 
71678
71902
  // src/services/unactionable-hardening.ts
71679
- import { existsSync as existsSync30 } from "node:fs";
71903
+ import { existsSync as existsSync29 } from "node:fs";
71680
71904
  async function hardenUnactionableEntries(params) {
71681
71905
  const result = { hardened: 0, retired: 0, remaining: 0 };
71682
71906
  try {
71683
71907
  const queuePath = resolveUnactionablePath(params.directory);
71684
- if (!existsSync30(queuePath))
71908
+ if (!existsSync29(queuePath))
71685
71909
  return result;
71686
71910
  const limit = params.batchLimit ?? HARDENING_BATCH_LIMIT;
71687
71911
  const dedupThreshold = params.dedupThreshold ?? 0.6;
@@ -71788,7 +72012,7 @@ var init_unactionable_hardening = __esm(() => {
71788
72012
  });
71789
72013
 
71790
72014
  // src/services/skill-improver.ts
71791
- import { existsSync as existsSync31 } from "node:fs";
72015
+ import { existsSync as existsSync30 } from "node:fs";
71792
72016
  import { mkdir as mkdir15, readFile as readFile15, rename as rename8, writeFile as writeFile13 } from "node:fs/promises";
71793
72017
  import * as path59 from "node:path";
71794
72018
  function timestampSlug(d) {
@@ -71803,7 +72027,7 @@ async function atomicWrite4(p, content) {
71803
72027
  async function gatherInventory(directory) {
71804
72028
  const swarm = await readKnowledge(resolveSwarmKnowledgePath(directory));
71805
72029
  const hivePath = resolveHiveKnowledgePath();
71806
- const hive = existsSync31(hivePath) ? await readKnowledge(hivePath) : [];
72030
+ const hive = existsSync30(hivePath) ? await readKnowledge(hivePath) : [];
71807
72031
  const archived = [...swarm, ...hive].filter((e) => e.status === "archived").length;
71808
72032
  const skills = await listSkills(directory);
71809
72033
  const knowledgeById = new Map([...swarm, ...hive].map((entry) => [entry.id, entry]));
@@ -74042,7 +74266,7 @@ __export(exports_skill_consolidation, {
74042
74266
  consolidationStatePath: () => consolidationStatePath,
74043
74267
  _internals: () => _internals39
74044
74268
  });
74045
- import { existsSync as existsSync33 } from "node:fs";
74269
+ import { existsSync as existsSync32 } from "node:fs";
74046
74270
  import { mkdir as mkdir16, readFile as readFile16, rename as rename9, writeFile as writeFile14 } from "node:fs/promises";
74047
74271
  import * as path62 from "node:path";
74048
74272
  function consolidationStatePath(directory) {
@@ -74050,7 +74274,7 @@ function consolidationStatePath(directory) {
74050
74274
  }
74051
74275
  async function readState2(directory) {
74052
74276
  const filePath = consolidationStatePath(directory);
74053
- if (!existsSync33(filePath))
74277
+ if (!existsSync32(filePath))
74054
74278
  return {};
74055
74279
  try {
74056
74280
  const parsed = JSON.parse(await readFile16(filePath, "utf-8"));
@@ -75679,7 +75903,7 @@ var init_gate_bridge = __esm(() => {
75679
75903
  });
75680
75904
 
75681
75905
  // src/services/version-check.ts
75682
- import { existsSync as existsSync34, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync13 } from "node:fs";
75906
+ import { existsSync as existsSync33, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync13 } from "node:fs";
75683
75907
  import { homedir as homedir8 } from "node:os";
75684
75908
  import { join as join51 } from "node:path";
75685
75909
  function cacheDir() {
@@ -75693,7 +75917,7 @@ function cacheFile() {
75693
75917
  function readVersionCache() {
75694
75918
  try {
75695
75919
  const path67 = cacheFile();
75696
- if (!existsSync34(path67))
75920
+ if (!existsSync33(path67))
75697
75921
  return null;
75698
75922
  const raw = readFileSync18(path67, "utf-8");
75699
75923
  const parsed = JSON.parse(raw);
@@ -75791,10 +76015,10 @@ var init_version_check = __esm(() => {
75791
76015
  });
75792
76016
 
75793
76017
  // src/services/knowledge-diagnostics.ts
75794
- import { existsSync as existsSync35 } from "node:fs";
76018
+ import { existsSync as existsSync34 } from "node:fs";
75795
76019
  import { readFile as readFile18 } from "node:fs/promises";
75796
76020
  async function readRawLines(filePath) {
75797
- if (!existsSync35(filePath))
76021
+ if (!existsSync34(filePath))
75798
76022
  return { entries: [], corrupt: 0 };
75799
76023
  const content = await readFile18(filePath, "utf-8");
75800
76024
  const entries = [];
@@ -75919,7 +76143,7 @@ async function computeKnowledgeDebug(directory) {
75919
76143
  };
75920
76144
  }
75921
76145
  async function safeJsonlCount(filePath) {
75922
- if (!filePath || !existsSync35(filePath))
76146
+ if (!filePath || !existsSync34(filePath))
75923
76147
  return 0;
75924
76148
  try {
75925
76149
  const content = await readFile18(filePath, "utf-8");
@@ -76002,7 +76226,7 @@ var init_knowledge_diagnostics = __esm(() => {
76002
76226
 
76003
76227
  // src/services/diagnose-service.ts
76004
76228
  import * as child_process6 from "node:child_process";
76005
- import { existsSync as existsSync36, readdirSync as readdirSync7, readFileSync as readFileSync19, statSync as statSync11 } from "node:fs";
76229
+ import { existsSync as existsSync35, readdirSync as readdirSync7, readFileSync as readFileSync19, statSync as statSync11 } from "node:fs";
76006
76230
  import path67 from "node:path";
76007
76231
  import { fileURLToPath as fileURLToPath2 } from "node:url";
76008
76232
  function validateTaskDag(plan) {
@@ -76250,7 +76474,7 @@ async function checkConfigBackups(directory) {
76250
76474
  }
76251
76475
  async function checkGitRepository(directory) {
76252
76476
  try {
76253
- if (!existsSync36(directory) || !statSync11(directory).isDirectory()) {
76477
+ if (!existsSync35(directory) || !statSync11(directory).isDirectory()) {
76254
76478
  return {
76255
76479
  name: "Git Repository",
76256
76480
  status: "❌",
@@ -76315,7 +76539,7 @@ async function checkSpecStaleness(directory, plan) {
76315
76539
  }
76316
76540
  async function checkConfigParseability(directory) {
76317
76541
  const configPath = path67.join(directory, ".opencode/opencode-swarm.json");
76318
- if (!existsSync36(configPath)) {
76542
+ if (!existsSync35(configPath)) {
76319
76543
  return {
76320
76544
  name: "Config Parseability",
76321
76545
  status: "✅",
@@ -76370,11 +76594,11 @@ async function checkGrammarWasmFiles() {
76370
76594
  const thisDir = path67.dirname(fileURLToPath2(import.meta.url));
76371
76595
  const grammarDir = resolveGrammarDir(thisDir);
76372
76596
  const missing = [];
76373
- if (!existsSync36(path67.join(grammarDir, "tree-sitter.wasm"))) {
76597
+ if (!existsSync35(path67.join(grammarDir, "tree-sitter.wasm"))) {
76374
76598
  missing.push("tree-sitter.wasm (core runtime)");
76375
76599
  }
76376
76600
  for (const file3 of grammarFiles) {
76377
- if (!existsSync36(path67.join(grammarDir, file3))) {
76601
+ if (!existsSync35(path67.join(grammarDir, file3))) {
76378
76602
  missing.push(file3);
76379
76603
  }
76380
76604
  }
@@ -76393,7 +76617,7 @@ async function checkGrammarWasmFiles() {
76393
76617
  }
76394
76618
  async function checkCheckpointManifest(directory) {
76395
76619
  const manifestPath = path67.join(directory, ".swarm/checkpoints.json");
76396
- if (!existsSync36(manifestPath)) {
76620
+ if (!existsSync35(manifestPath)) {
76397
76621
  return {
76398
76622
  name: "Checkpoint Manifest",
76399
76623
  status: "✅",
@@ -76445,7 +76669,7 @@ async function checkCheckpointManifest(directory) {
76445
76669
  }
76446
76670
  async function checkEventStreamIntegrity(directory) {
76447
76671
  const eventsPath = path67.join(directory, ".swarm/events.jsonl");
76448
- if (!existsSync36(eventsPath)) {
76672
+ if (!existsSync35(eventsPath)) {
76449
76673
  return {
76450
76674
  name: "Event Stream",
76451
76675
  status: "✅",
@@ -76486,7 +76710,7 @@ async function checkEventStreamIntegrity(directory) {
76486
76710
  }
76487
76711
  async function checkSteeringDirectives(directory) {
76488
76712
  const eventsPath = path67.join(directory, ".swarm/events.jsonl");
76489
- if (!existsSync36(eventsPath)) {
76713
+ if (!existsSync35(eventsPath)) {
76490
76714
  return {
76491
76715
  name: "Steering Directives",
76492
76716
  status: "✅",
@@ -76542,7 +76766,7 @@ async function checkCurator(directory) {
76542
76766
  };
76543
76767
  }
76544
76768
  const summaryPath = path67.join(directory, ".swarm/curator-summary.json");
76545
- if (!existsSync36(summaryPath)) {
76769
+ if (!existsSync35(summaryPath)) {
76546
76770
  return {
76547
76771
  name: "Curator",
76548
76772
  status: "✅",
@@ -76744,7 +76968,7 @@ async function getDiagnoseData(directory) {
76744
76968
  checks5.push(await checkKnowledgeHealth(directory));
76745
76969
  try {
76746
76970
  const evidenceDir = path67.join(directory, ".swarm", "evidence");
76747
- const snapshotFiles = existsSync36(evidenceDir) ? readdirSync7(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
76971
+ const snapshotFiles = existsSync35(evidenceDir) ? readdirSync7(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
76748
76972
  if (snapshotFiles.length > 0) {
76749
76973
  const latest = snapshotFiles.sort().pop();
76750
76974
  checks5.push({
@@ -76777,7 +77001,7 @@ async function getDiagnoseData(directory) {
76777
77001
  const cacheRows = [];
76778
77002
  for (const cachePath of cachePaths) {
76779
77003
  try {
76780
- if (!existsSync36(cachePath)) {
77004
+ if (!existsSync35(cachePath)) {
76781
77005
  cacheRows.push(`⬜ ${cachePath} — absent`);
76782
77006
  continue;
76783
77007
  }
@@ -82711,7 +82935,7 @@ var KNOWLEDGE_SCHEMA_VERSION = 2;
82711
82935
 
82712
82936
  // src/hooks/knowledge-migrator.ts
82713
82937
  import { randomUUID as randomUUID6 } from "node:crypto";
82714
- import { existsSync as existsSync43, readFileSync as readFileSync26 } from "node:fs";
82938
+ import { existsSync as existsSync42, readFileSync as readFileSync26 } from "node:fs";
82715
82939
  import { mkdir as mkdir17, readFile as readFile19, writeFile as writeFile15 } from "node:fs/promises";
82716
82940
  import * as os15 from "node:os";
82717
82941
  import * as path75 from "node:path";
@@ -82728,7 +82952,7 @@ async function migrateContextToKnowledge(directory, config3) {
82728
82952
  const sentinelPath = path75.join(directory, ".swarm", ".knowledge-migrated");
82729
82953
  const contextPath = path75.join(directory, ".swarm", "context.md");
82730
82954
  const knowledgePath = resolveSwarmKnowledgePath(directory);
82731
- if (existsSync43(sentinelPath)) {
82955
+ if (existsSync42(sentinelPath)) {
82732
82956
  return {
82733
82957
  migrated: false,
82734
82958
  entriesMigrated: 0,
@@ -82737,7 +82961,7 @@ async function migrateContextToKnowledge(directory, config3) {
82737
82961
  skippedReason: "sentinel-exists"
82738
82962
  };
82739
82963
  }
82740
- if (!existsSync43(contextPath)) {
82964
+ if (!existsSync42(contextPath)) {
82741
82965
  return {
82742
82966
  migrated: false,
82743
82967
  entriesMigrated: 0,
@@ -82829,7 +83053,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
82829
83053
  const legacyHivePath = _internals51.resolveLegacyHiveKnowledgePath();
82830
83054
  const canonicalHivePath = resolveHiveKnowledgePath();
82831
83055
  const sentinelPath = path75.join(path75.dirname(canonicalHivePath), ".hive-knowledge-migrated");
82832
- if (existsSync43(sentinelPath)) {
83056
+ if (existsSync42(sentinelPath)) {
82833
83057
  return {
82834
83058
  migrated: false,
82835
83059
  entriesMigrated: 0,
@@ -82838,7 +83062,7 @@ async function migrateHiveKnowledgeLegacy(config3) {
82838
83062
  skippedReason: "sentinel-exists"
82839
83063
  };
82840
83064
  }
82841
- if (!existsSync43(legacyHivePath)) {
83065
+ if (!existsSync42(legacyHivePath)) {
82842
83066
  return {
82843
83067
  migrated: false,
82844
83068
  entriesMigrated: 0,
@@ -83040,7 +83264,7 @@ function truncateLesson2(text) {
83040
83264
  }
83041
83265
  function inferProjectName(directory) {
83042
83266
  const packageJsonPath = path75.join(directory, "package.json");
83043
- if (existsSync43(packageJsonPath)) {
83267
+ if (existsSync42(packageJsonPath)) {
83044
83268
  try {
83045
83269
  const pkg = JSON.parse(readFileSync26(packageJsonPath, "utf-8"));
83046
83270
  if (pkg.name && typeof pkg.name === "string") {
@@ -83433,12 +83657,12 @@ var init_identity = __esm(() => {
83433
83657
  });
83434
83658
 
83435
83659
  // src/commands/link.ts
83436
- import { existsSync as existsSync44 } from "node:fs";
83660
+ import { existsSync as existsSync43 } from "node:fs";
83437
83661
  import * as path77 from "node:path";
83438
83662
  async function mergeLocalKnowledgeIntoLink(localSwarmDir, linkDir) {
83439
83663
  const localPath = path77.join(localSwarmDir, "knowledge.jsonl");
83440
83664
  const sharedPath = path77.join(linkDir, "knowledge.jsonl");
83441
- if (!existsSync44(localPath))
83665
+ if (!existsSync43(localPath))
83442
83666
  return { merged: 0, skipped: 0 };
83443
83667
  let merged = 0;
83444
83668
  let skipped = 0;
@@ -84754,7 +84978,7 @@ var init_maintenance = __esm(() => {
84754
84978
 
84755
84979
  // src/memory/local-jsonl-provider.ts
84756
84980
  import { randomUUID as randomUUID7 } from "node:crypto";
84757
- import { existsSync as existsSync45 } from "node:fs";
84981
+ import { existsSync as existsSync44 } from "node:fs";
84758
84982
  import {
84759
84983
  appendFile as appendFile9,
84760
84984
  mkdir as mkdir18,
@@ -85105,7 +85329,7 @@ function validateLoadedProposals(values, config3) {
85105
85329
  return { records, invalidCount };
85106
85330
  }
85107
85331
  async function readJsonl(filePath) {
85108
- if (!existsSync45(filePath))
85332
+ if (!existsSync44(filePath))
85109
85333
  return [];
85110
85334
  const content = await readFile20(filePath, "utf-8");
85111
85335
  const records = [];
@@ -85265,7 +85489,7 @@ var init_prompt_block = __esm(() => {
85265
85489
  });
85266
85490
 
85267
85491
  // src/memory/jsonl-migration.ts
85268
- import { existsSync as existsSync46, renameSync as renameSync18, unlinkSync as unlinkSync13 } from "node:fs";
85492
+ import { existsSync as existsSync45, renameSync as renameSync18, unlinkSync as unlinkSync13 } from "node:fs";
85269
85493
  import { copyFile as copyFile2, mkdir as mkdir19, readFile as readFile21, stat as stat10, writeFile as writeFile17 } from "node:fs/promises";
85270
85494
  import * as path79 from "node:path";
85271
85495
  function resolveMemoryStorageDir(rootDirectory, config3 = {}) {
@@ -85297,10 +85521,10 @@ async function backupLegacyJsonl(rootDirectory, config3 = {}) {
85297
85521
  const results = [];
85298
85522
  for (const filename of ["memories.jsonl", "proposals.jsonl"]) {
85299
85523
  const source = path79.join(storageDir, filename);
85300
- if (!existsSync46(source))
85524
+ if (!existsSync45(source))
85301
85525
  continue;
85302
85526
  const backup = path79.join(backupDir, `${filename}.pre-sqlite-migration`);
85303
- if (existsSync46(backup)) {
85527
+ if (existsSync45(backup)) {
85304
85528
  results.push({ source, backup, created: false });
85305
85529
  continue;
85306
85530
  }
@@ -85354,7 +85578,7 @@ async function writeMigrationReport(rootDirectory, report, config3 = {}) {
85354
85578
  }
85355
85579
  async function readMigrationReport(rootDirectory, config3 = {}) {
85356
85580
  const reportPath = path79.join(resolveMemoryStorageDir(rootDirectory, config3), "migration-report.json");
85357
- if (!existsSync46(reportPath))
85581
+ if (!existsSync45(reportPath))
85358
85582
  return null;
85359
85583
  try {
85360
85584
  return JSON.parse(await readFile21(reportPath, "utf-8"));
@@ -85368,13 +85592,13 @@ async function getLegacyJsonlFileStatus(rootDirectory, config3 = {}) {
85368
85592
  for (const file3 of ["memories.jsonl", "proposals.jsonl"]) {
85369
85593
  const filePath = path79.join(storageDir, file3);
85370
85594
  let sizeBytes = 0;
85371
- if (existsSync46(filePath)) {
85595
+ if (existsSync45(filePath)) {
85372
85596
  sizeBytes = (await stat10(filePath)).size;
85373
85597
  }
85374
85598
  statuses.push({
85375
85599
  file: file3,
85376
85600
  path: filePath,
85377
- exists: existsSync46(filePath),
85601
+ exists: existsSync45(filePath),
85378
85602
  sizeBytes
85379
85603
  });
85380
85604
  }
@@ -85455,7 +85679,7 @@ async function readProposalJsonl(filePath, config3) {
85455
85679
  return { records, invalidRows, totalRows: rows.totalRows };
85456
85680
  }
85457
85681
  async function readJsonlRows(filePath) {
85458
- if (!existsSync46(filePath)) {
85682
+ if (!existsSync45(filePath)) {
85459
85683
  return { rows: [], invalidRows: [], totalRows: 0 };
85460
85684
  }
85461
85685
  const content = await readFile21(filePath, "utf-8");
@@ -86729,7 +86953,7 @@ var init_provider_pool = __esm(() => {
86729
86953
 
86730
86954
  // src/memory/gateway.ts
86731
86955
  import { createHash as createHash13 } from "node:crypto";
86732
- import { existsSync as existsSync47, readFileSync as readFileSync27 } from "node:fs";
86956
+ import { existsSync as existsSync46, readFileSync as readFileSync27 } from "node:fs";
86733
86957
  import * as path82 from "node:path";
86734
86958
 
86735
86959
  class MemoryGateway {
@@ -87090,7 +87314,7 @@ function readGitRemoteUrl(directory) {
87090
87314
  if (gitRemoteUrlCache.has(directory))
87091
87315
  return gitRemoteUrlCache.get(directory);
87092
87316
  const gitConfigPath = path82.join(directory, ".git", "config");
87093
- if (!existsSync47(gitConfigPath)) {
87317
+ if (!existsSync46(gitConfigPath)) {
87094
87318
  gitRemoteUrlCache.set(directory, undefined);
87095
87319
  return;
87096
87320
  }
@@ -88194,7 +88418,7 @@ var init_consolidation_log = __esm(() => {
88194
88418
  });
88195
88419
 
88196
88420
  // src/commands/memory.ts
88197
- import { existsSync as existsSync48 } from "node:fs";
88421
+ import { existsSync as existsSync47 } from "node:fs";
88198
88422
  import * as path86 from "node:path";
88199
88423
  import { fileURLToPath as fileURLToPath3 } from "node:url";
88200
88424
  async function handleMemoryCommand(_directory, _args) {
@@ -88254,7 +88478,7 @@ async function handleMemoryStatusCommand(directory, _args) {
88254
88478
  `- Provider: \`${config3.provider}\``,
88255
88479
  `- Storage: \`${storageDir}\``,
88256
88480
  `- SQLite path: \`${sqlitePath}\``,
88257
- `- SQLite database exists: \`${existsSync48(sqlitePath)}\``,
88481
+ `- SQLite database exists: \`${existsSync47(sqlitePath)}\``,
88258
88482
  `- Automatic destructive cleanup: \`disabled\``,
88259
88483
  "",
88260
88484
  "### Legacy JSONL"
@@ -93116,19 +93340,19 @@ function hasCompoundTestExtension(filename) {
93116
93340
  const lower = filename.toLowerCase();
93117
93341
  return COMPOUND_TEST_EXTENSIONS.some((ext) => lower.endsWith(ext));
93118
93342
  }
93119
- function isLanguageSpecificTestFile(basename13) {
93120
- const lower = basename13.toLowerCase();
93343
+ function isLanguageSpecificTestFile(basename14) {
93344
+ const lower = basename14.toLowerCase();
93121
93345
  if (lower.endsWith("_test.go"))
93122
93346
  return true;
93123
93347
  if (lower.endsWith(".py") && (lower.startsWith("test_") || lower.endsWith("_test.py")))
93124
93348
  return true;
93125
93349
  if (lower.endsWith("_spec.rb"))
93126
93350
  return true;
93127
- if (lower.endsWith(".java") && (/^Test[A-Z]/.test(basename13) || basename13.endsWith("Test.java") || basename13.endsWith("Tests.java") || lower.endsWith("it.java")))
93351
+ if (lower.endsWith(".java") && (/^Test[A-Z]/.test(basename14) || basename14.endsWith("Test.java") || basename14.endsWith("Tests.java") || lower.endsWith("it.java")))
93128
93352
  return true;
93129
93353
  if (lower.endsWith(".cs") && (lower.endsWith("test.cs") || lower.endsWith("tests.cs")))
93130
93354
  return true;
93131
- if (lower.endsWith(".kt") && (/^Test[A-Z]/.test(basename13) || lower.endsWith("test.kt") || lower.endsWith("tests.kt")))
93355
+ if (lower.endsWith(".kt") && (/^Test[A-Z]/.test(basename14) || lower.endsWith("test.kt") || lower.endsWith("tests.kt")))
93132
93356
  return true;
93133
93357
  if (lower.endsWith(".tests.ps1"))
93134
93358
  return true;
@@ -93136,23 +93360,23 @@ function isLanguageSpecificTestFile(basename13) {
93136
93360
  }
93137
93361
  function isConventionTestFilePath(filePath) {
93138
93362
  const normalizedPath = filePath.replace(/\\/g, "/");
93139
- const basename13 = path99.basename(filePath);
93140
- return hasCompoundTestExtension(basename13) || basename13.includes(".spec.") || basename13.includes(".test.") || isLanguageSpecificTestFile(basename13) || isTestDirectoryPath(normalizedPath);
93363
+ const basename14 = path99.basename(filePath);
93364
+ return hasCompoundTestExtension(basename14) || basename14.includes(".spec.") || basename14.includes(".test.") || isLanguageSpecificTestFile(basename14) || isTestDirectoryPath(normalizedPath);
93141
93365
  }
93142
93366
  function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
93143
93367
  const testFiles = [];
93144
93368
  for (const file3 of sourceFiles) {
93145
93369
  const absoluteFile = resolveWorkspacePath(file3, workingDir);
93146
93370
  const relativeFile = path99.relative(workingDir, absoluteFile);
93147
- const basename13 = path99.basename(absoluteFile);
93371
+ const basename14 = path99.basename(absoluteFile);
93148
93372
  const dirname45 = path99.dirname(absoluteFile);
93149
93373
  const preferRelativeOutput = !path99.isAbsolute(file3);
93150
93374
  if (isConventionTestFilePath(relativeFile) || isConventionTestFilePath(file3)) {
93151
93375
  dedupePush(testFiles, toWorkspaceOutputPath(absoluteFile, workingDir, preferRelativeOutput));
93152
93376
  continue;
93153
93377
  }
93154
- const nameWithoutExt = basename13.replace(/\.[^.]+$/, "");
93155
- const ext = path99.extname(basename13);
93378
+ const nameWithoutExt = basename14.replace(/\.[^.]+$/, "");
93379
+ const ext = path99.extname(basename14);
93156
93380
  const genericTestNames = [
93157
93381
  `${nameWithoutExt}.spec${ext}`,
93158
93382
  `${nameWithoutExt}.test${ext}`
@@ -93163,7 +93387,7 @@ function getTestFilesFromConvention(sourceFiles, workingDir = process.cwd()) {
93163
93387
  ...languageSpecificTestNames
93164
93388
  ].map((candidateName) => path99.join(dirname45, candidateName));
93165
93389
  const testDirectoryNames = [
93166
- basename13,
93390
+ basename14,
93167
93391
  ...genericTestNames,
93168
93392
  ...languageSpecificTestNames
93169
93393
  ];
@@ -98740,12 +98964,12 @@ var init_turbo = __esm(() => {
98740
98964
  });
98741
98965
 
98742
98966
  // src/commands/unlink.ts
98743
- import { existsSync as existsSync60 } from "node:fs";
98967
+ import { existsSync as existsSync59 } from "node:fs";
98744
98968
  import * as path110 from "node:path";
98745
98969
  async function copySharedKnowledgeToLocal(linkDir, localSwarmDir) {
98746
98970
  const sharedPath = path110.join(linkDir, "knowledge.jsonl");
98747
98971
  const localPath = path110.join(localSwarmDir, "knowledge.jsonl");
98748
- if (!existsSync60(sharedPath))
98972
+ if (!existsSync59(sharedPath))
98749
98973
  return 0;
98750
98974
  const sharedEntries = await readKnowledge(sharedPath);
98751
98975
  if (sharedEntries.length === 0)
@@ -105556,11 +105780,11 @@ __export(exports_evidence_summary_integration, {
105556
105780
  createEvidenceSummaryIntegration: () => createEvidenceSummaryIntegration,
105557
105781
  EvidenceSummaryIntegration: () => EvidenceSummaryIntegration
105558
105782
  });
105559
- import { existsSync as existsSync61, mkdirSync as mkdirSync32, writeFileSync as writeFileSync18 } from "node:fs";
105783
+ import { existsSync as existsSync60, mkdirSync as mkdirSync32, writeFileSync as writeFileSync18 } from "node:fs";
105560
105784
  import * as path114 from "node:path";
105561
105785
  function persistSummary(projectDir, artifact, filename) {
105562
105786
  const swarmPath = path114.join(projectDir, ".swarm");
105563
- if (!existsSync61(swarmPath)) {
105787
+ if (!existsSync60(swarmPath)) {
105564
105788
  mkdirSync32(swarmPath, { recursive: true });
105565
105789
  }
105566
105790
  const artifactPath = path114.join(swarmPath, filename);
@@ -106572,7 +106796,7 @@ var init_schema3 = __esm(() => {
106572
106796
 
106573
106797
  // src/summaries/store.ts
106574
106798
  import {
106575
- existsSync as existsSync73,
106799
+ existsSync as existsSync72,
106576
106800
  mkdirSync as mkdirSync39,
106577
106801
  readFileSync as readFileSync49,
106578
106802
  renameSync as renameSync26,
@@ -106587,7 +106811,7 @@ function writeRawSidecar(absPath, bundle) {
106587
106811
  writeFileSync25(tempFile, JSON.stringify(bundle, null, 2), "utf-8");
106588
106812
  renameSync26(tempFile, absPath);
106589
106813
  } finally {
106590
- if (existsSync73(tempFile)) {
106814
+ if (existsSync72(tempFile)) {
106591
106815
  try {
106592
106816
  unlinkSync22(tempFile);
106593
106817
  } catch {}
@@ -106674,7 +106898,7 @@ function readSupervisorReportRaw(directory, phase) {
106674
106898
  } catch {
106675
106899
  return null;
106676
106900
  }
106677
- if (!existsSync73(abs))
106901
+ if (!existsSync72(abs))
106678
106902
  return null;
106679
106903
  try {
106680
106904
  const parsed = JSON.parse(readFileSync49(abs, "utf-8"));
@@ -106773,7 +106997,7 @@ __export(exports_runtime, {
106773
106997
  clearParserCache: () => clearParserCache,
106774
106998
  _internals: () => _internals79
106775
106999
  });
106776
- import { existsSync as existsSync74, statSync as statSync24 } from "node:fs";
107000
+ import { existsSync as existsSync73, statSync as statSync24 } from "node:fs";
106777
107001
  import * as path129 from "node:path";
106778
107002
  import { fileURLToPath as fileURLToPath4 } from "node:url";
106779
107003
  import { Language, Parser as TreeSitterParser } from "web-tree-sitter";
@@ -106842,7 +107066,7 @@ async function loadGrammar(languageId) {
106842
107066
  const parser = new TreeSitterParser;
106843
107067
  const wasmFileName = getWasmFileName(normalizedId);
106844
107068
  const wasmPath = path129.join(getGrammarsDirAbsolute(), wasmFileName);
106845
- if (!existsSync74(wasmPath)) {
107069
+ if (!existsSync73(wasmPath)) {
106846
107070
  throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
106847
107071
  ` + `Make sure to run 'bun run build' to copy grammar files to dist/lang/grammars/`);
106848
107072
  }
@@ -107025,17 +107249,17 @@ function normalizeSeparators(filePath) {
107025
107249
  }
107026
107250
  function matchesDocPattern(filePath, patterns) {
107027
107251
  const normalizedPath = normalizeSeparators(filePath);
107028
- const basename16 = path142.basename(filePath);
107252
+ const basename17 = path142.basename(filePath);
107029
107253
  for (const pattern of patterns) {
107030
107254
  if (!pattern.includes("/") && !pattern.includes("\\")) {
107031
- if (basename16 === pattern) {
107255
+ if (basename17 === pattern) {
107032
107256
  return true;
107033
107257
  }
107034
107258
  continue;
107035
107259
  }
107036
107260
  if (pattern.startsWith("**/")) {
107037
107261
  const filenamePattern = pattern.slice(3);
107038
- if (basename16 === filenamePattern) {
107262
+ if (basename17 === filenamePattern) {
107039
107263
  return true;
107040
107264
  }
107041
107265
  continue;
@@ -107428,7 +107652,7 @@ var init_doc_scan = __esm(() => {
107428
107652
  });
107429
107653
 
107430
107654
  // src/hooks/knowledge-reader.ts
107431
- import { existsSync as existsSync79 } from "node:fs";
107655
+ import { existsSync as existsSync78 } from "node:fs";
107432
107656
  import { readFile as readFile29 } from "node:fs/promises";
107433
107657
  import * as path143 from "node:path";
107434
107658
  function inferCategoriesFromPhase(phaseDescription) {
@@ -107476,7 +107700,7 @@ function inferCategoriesFromPhase(phaseDescription) {
107476
107700
  }
107477
107701
  async function transactShownFile(shownFile, mutate) {
107478
107702
  return transactFile(shownFile, async (filePath) => {
107479
- if (!existsSync79(filePath))
107703
+ if (!existsSync78(filePath))
107480
107704
  return {};
107481
107705
  try {
107482
107706
  const content = await readFile29(filePath, "utf-8");
@@ -107606,7 +107830,7 @@ async function readMergedKnowledge(directory, config3, context, opts) {
107606
107830
  async function updateRetrievalOutcome(directory, phaseInfo, phaseSucceeded) {
107607
107831
  const shownFile = path143.join(directory, ".swarm", ".knowledge-shown.json");
107608
107832
  try {
107609
- if (!existsSync79(shownFile)) {
107833
+ if (!existsSync78(shownFile)) {
107610
107834
  return;
107611
107835
  }
107612
107836
  let shownIds;
@@ -108336,7 +108560,7 @@ __export(exports_design_doc_drift, {
108336
108560
  _internals: () => _internals111
108337
108561
  });
108338
108562
  import * as fs118 from "node:fs";
108339
- import * as path188 from "node:path";
108563
+ import * as path190 from "node:path";
108340
108564
  function mtimeMsOrNull(absPath) {
108341
108565
  try {
108342
108566
  return fs118.statSync(absPath).mtimeMs;
@@ -108347,35 +108571,35 @@ function mtimeMsOrNull(absPath) {
108347
108571
  function resolveAnchorWithin(directory, anchor) {
108348
108572
  if (!anchor || typeof anchor !== "string")
108349
108573
  return null;
108350
- const root = path188.resolve(directory);
108351
- const resolved = path188.resolve(root, anchor);
108352
- const rel = path188.relative(root, resolved);
108353
- if (rel.startsWith("..") || path188.isAbsolute(rel))
108574
+ const root = path190.resolve(directory);
108575
+ const resolved = path190.resolve(root, anchor);
108576
+ const rel = path190.relative(root, resolved);
108577
+ if (rel.startsWith("..") || path190.isAbsolute(rel))
108354
108578
  return null;
108355
108579
  return resolved;
108356
108580
  }
108357
108581
  async function runDesignDocDriftCheck(directory, phase, outDir) {
108358
108582
  try {
108359
- const root = path188.resolve(directory);
108360
- const outAbs = path188.resolve(root, outDir);
108361
- const outRel = path188.relative(root, outAbs);
108362
- if (outRel.startsWith("..") || path188.isAbsolute(outRel)) {
108583
+ const root = path190.resolve(directory);
108584
+ const outAbs = path190.resolve(root, outDir);
108585
+ const outRel = path190.relative(root, outAbs);
108586
+ if (outRel.startsWith("..") || path190.isAbsolute(outRel)) {
108363
108587
  return null;
108364
108588
  }
108365
108589
  const docMtimes = new Map;
108366
108590
  const checkedDocs = [];
108367
108591
  const missingDocs = [];
108368
108592
  for (const [docName, relFile] of Object.entries(DESIGN_DOC_FILES)) {
108369
- const abs = path188.join(outAbs, relFile);
108593
+ const abs = path190.join(outAbs, relFile);
108370
108594
  const mtime = mtimeMsOrNull(abs);
108371
108595
  docMtimes.set(docName, mtime);
108372
108596
  if (mtime === null) {
108373
- missingDocs.push(path188.join(outDir, relFile));
108597
+ missingDocs.push(path190.join(outDir, relFile));
108374
108598
  } else {
108375
- checkedDocs.push(path188.join(outDir, relFile));
108599
+ checkedDocs.push(path190.join(outDir, relFile));
108376
108600
  }
108377
108601
  }
108378
- const traceabilityAbs = path188.join(outAbs, TRACEABILITY_REL);
108602
+ const traceabilityAbs = path190.join(outAbs, TRACEABILITY_REL);
108379
108603
  let registry3 = null;
108380
108604
  try {
108381
108605
  const stat14 = await fs118.promises.stat(traceabilityAbs);
@@ -108445,7 +108669,7 @@ async function runDesignDocDriftCheck(directory, phase, outDir) {
108445
108669
  };
108446
108670
  const filename = `${DOC_DRIFT_REPORT_PREFIX}${phase}.json`;
108447
108671
  const filePath = validateSwarmPath(directory, filename);
108448
- await fs118.promises.mkdir(path188.dirname(filePath), { recursive: true });
108672
+ await fs118.promises.mkdir(path190.dirname(filePath), { recursive: true });
108449
108673
  await fs118.promises.writeFile(filePath, JSON.stringify(report, null, 2), "utf-8");
108450
108674
  getGlobalEventBus().publish("curator.docdrift.completed", {
108451
108675
  phase,
@@ -108477,10 +108701,10 @@ var init_design_doc_drift = __esm(() => {
108477
108701
  domain: "domain.md",
108478
108702
  "technical-spec": "technical-spec.md",
108479
108703
  "behavior-spec": "behavior-spec.md",
108480
- "reference-impl": path188.join("reference", "reference-impl.md"),
108481
- "idiom-notes": path188.join("reference", "idiom-notes.md")
108704
+ "reference-impl": path190.join("reference", "reference-impl.md"),
108705
+ "idiom-notes": path190.join("reference", "idiom-notes.md")
108482
108706
  };
108483
- TRACEABILITY_REL = path188.join("reference", "traceability.json");
108707
+ TRACEABILITY_REL = path190.join("reference", "traceability.json");
108484
108708
  _internals111 = {
108485
108709
  mtimeMsOrNull,
108486
108710
  resolveAnchorWithin,
@@ -108492,11 +108716,11 @@ var init_design_doc_drift = __esm(() => {
108492
108716
  var exports_project_context = {};
108493
108717
  __export(exports_project_context, {
108494
108718
  buildProjectContext: () => buildProjectContext,
108495
- _internals: () => _internals124,
108719
+ _internals: () => _internals125,
108496
108720
  LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
108497
108721
  });
108498
108722
  import * as fs142 from "node:fs";
108499
- import * as path217 from "node:path";
108723
+ import * as path219 from "node:path";
108500
108724
  function detectFileExists2(directory, pattern) {
108501
108725
  if (pattern.includes("*") || pattern.includes("?")) {
108502
108726
  try {
@@ -108508,7 +108732,7 @@ function detectFileExists2(directory, pattern) {
108508
108732
  }
108509
108733
  }
108510
108734
  try {
108511
- fs142.accessSync(path217.join(directory, pattern));
108735
+ fs142.accessSync(path219.join(directory, pattern));
108512
108736
  return true;
108513
108737
  } catch {
108514
108738
  return false;
@@ -108517,7 +108741,7 @@ function detectFileExists2(directory, pattern) {
108517
108741
  function selectTestCommandFromScriptsTest(backend, directory) {
108518
108742
  let pkgRaw;
108519
108743
  try {
108520
- pkgRaw = fs142.readFileSync(path217.join(directory, "package.json"), "utf-8");
108744
+ pkgRaw = fs142.readFileSync(path219.join(directory, "package.json"), "utf-8");
108521
108745
  } catch {
108522
108746
  return null;
108523
108747
  }
@@ -108576,7 +108800,7 @@ function selectLintCommand(backend, directory) {
108576
108800
  return null;
108577
108801
  }
108578
108802
  async function buildProjectContext(directory) {
108579
- const backend = await _internals124.pickBackend(directory);
108803
+ const backend = await _internals125.pickBackend(directory);
108580
108804
  if (!backend)
108581
108805
  return null;
108582
108806
  const ctx = emptyProjectContext();
@@ -108615,17 +108839,17 @@ async function buildProjectContext(directory) {
108615
108839
  if (backend.prompts.reviewerChecklist.length > 0) {
108616
108840
  ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
108617
108841
  }
108618
- const profiles = _internals124.pickedProfiles(directory);
108842
+ const profiles = _internals125.pickedProfiles(directory);
108619
108843
  if (profiles.length > 1) {
108620
108844
  ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
108621
108845
  }
108622
108846
  return ctx;
108623
108847
  }
108624
- var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals124;
108848
+ var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals125;
108625
108849
  var init_project_context = __esm(() => {
108626
108850
  init_dispatch();
108627
108851
  init_framework_detector();
108628
- _internals124 = {
108852
+ _internals125 = {
108629
108853
  pickBackend,
108630
108854
  pickedProfiles
108631
108855
  };
@@ -108635,7 +108859,7 @@ var init_project_context = __esm(() => {
108635
108859
  init_package();
108636
108860
  init_agents2();
108637
108861
  init_critic();
108638
- import * as path218 from "node:path";
108862
+ import * as path220 from "node:path";
108639
108863
  import { fileURLToPath as fileURLToPath5 } from "node:url";
108640
108864
 
108641
108865
  // src/background/index.ts
@@ -113337,7 +113561,7 @@ import * as path138 from "node:path";
113337
113561
  // src/tools/repo-graph/builder.ts
113338
113562
  init_profiles();
113339
113563
  import * as fsSync8 from "node:fs";
113340
- import { existsSync as existsSync75, realpathSync as realpathSync14 } from "node:fs";
113564
+ import { existsSync as existsSync74, realpathSync as realpathSync14 } from "node:fs";
113341
113565
  import * as fsPromises5 from "node:fs/promises";
113342
113566
  import * as os17 from "node:os";
113343
113567
  import * as path133 from "node:path";
@@ -115549,7 +115773,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
115549
115773
  if (realRoot === null) {
115550
115774
  return null;
115551
115775
  }
115552
- if (!existsSync75(resolved)) {
115776
+ if (!existsSync74(resolved)) {
115553
115777
  const EXTENSIONS = [
115554
115778
  ".ts",
115555
115779
  ".tsx",
@@ -115563,7 +115787,7 @@ function resolveModuleSpecifier(workspaceRoot, sourceFile, specifier) {
115563
115787
  let found = null;
115564
115788
  for (const ext of EXTENSIONS) {
115565
115789
  const candidate = resolved + ext;
115566
- if (existsSync75(candidate)) {
115790
+ if (existsSync74(candidate)) {
115567
115791
  found = candidate;
115568
115792
  break;
115569
115793
  }
@@ -116061,7 +116285,7 @@ async function buildWorkspaceGraphAsync(workspaceRoot, options) {
116061
116285
  const walkBudgetMs = options?.walkBudgetMs ?? DEFAULT_WALK_BUDGET_MS;
116062
116286
  const followSymlinks = options?.followSymlinks ?? false;
116063
116287
  const absoluteRoot = path133.resolve(workspaceRoot);
116064
- if (!existsSync75(absoluteRoot)) {
116288
+ if (!existsSync74(absoluteRoot)) {
116065
116289
  throw new Error(`Workspace directory does not exist: ${workspaceRoot}`);
116066
116290
  }
116067
116291
  if (isRefusedWorkspaceRoot(absoluteRoot)) {
@@ -116170,7 +116394,7 @@ function getCachedMtime(workspace) {
116170
116394
  // src/tools/repo-graph/incremental.ts
116171
116395
  init_logger();
116172
116396
  init_path_security();
116173
- import { existsSync as existsSync77 } from "node:fs";
116397
+ import { existsSync as existsSync76 } from "node:fs";
116174
116398
  import * as fsPromises7 from "node:fs/promises";
116175
116399
  import * as path137 from "node:path";
116176
116400
 
@@ -116862,7 +117086,7 @@ function buildOntologyPreflightPacket(graph, filePaths = [], options = {}) {
116862
117086
  init_utils2();
116863
117087
  init_logger();
116864
117088
  init_path_security();
116865
- import { constants as constants5, existsSync as existsSync76, readFileSync as readFileSync52, statSync as statSync27 } from "node:fs";
117089
+ import { constants as constants5, existsSync as existsSync75, readFileSync as readFileSync52, statSync as statSync27 } from "node:fs";
116866
117090
  import * as fsPromises6 from "node:fs/promises";
116867
117091
  import * as path136 from "node:path";
116868
117092
  var WINDOWS_RENAME_MAX_RETRIES2 = 5;
@@ -116934,7 +117158,7 @@ async function loadGraph(workspace) {
116934
117158
  if (cached3 && !isDirty(normalized)) {
116935
117159
  try {
116936
117160
  const graphPath = getGraphPath(workspace);
116937
- if (existsSync76(graphPath)) {
117161
+ if (existsSync75(graphPath)) {
116938
117162
  const stats2 = await fsPromises6.stat(graphPath);
116939
117163
  const cachedMtime = getCachedMtime(normalized);
116940
117164
  if (cachedMtime !== undefined && stats2.mtimeMs !== cachedMtime) {
@@ -116951,7 +117175,7 @@ async function loadGraph(workspace) {
116951
117175
  }
116952
117176
  try {
116953
117177
  const graphPath = getGraphPath(workspace);
116954
- if (!existsSync76(graphPath)) {
117178
+ if (!existsSync75(graphPath)) {
116955
117179
  return null;
116956
117180
  }
116957
117181
  const stats2 = await fsPromises6.stat(graphPath);
@@ -116985,7 +117209,7 @@ function loadGraphSync(workspace) {
116985
117209
  const normalized = path136.normalize(workspace);
116986
117210
  try {
116987
117211
  const graphPath = getGraphPath(workspace);
116988
- if (!existsSync76(graphPath))
117212
+ if (!existsSync75(graphPath))
116989
117213
  return null;
116990
117214
  const stats2 = statSync27(graphPath);
116991
117215
  const content = readFileSync52(graphPath, "utf-8");
@@ -117115,7 +117339,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
117115
117339
  const updatedPaths = new Set;
117116
117340
  for (const rawFilePath of filePaths) {
117117
117341
  const normalizedPath = normalizeGraphPath(rawFilePath);
117118
- const fileExists = existsSync77(rawFilePath);
117342
+ const fileExists = existsSync76(rawFilePath);
117119
117343
  if (fileExists) {
117120
117344
  graph.edges = graph.edges.filter((e) => normalizeGraphPath(e.source) !== normalizedPath);
117121
117345
  if (graph.symbolEdges) {
@@ -117190,7 +117414,7 @@ async function updateGraphForFiles(workspaceRoot, filePaths, options) {
117190
117414
  if (loadedMtime !== undefined) {
117191
117415
  try {
117192
117416
  const graphPath = getGraphPath(workspaceRoot);
117193
- if (existsSync77(graphPath)) {
117417
+ if (existsSync76(graphPath)) {
117194
117418
  const currentStats = await fsPromises7.stat(graphPath);
117195
117419
  if (currentStats.mtimeMs !== loadedMtime) {
117196
117420
  warn(`[repo-graph] Concurrent modification detected — falling back to full rebuild`);
@@ -121362,7 +121586,7 @@ init_logger();
121362
121586
  init_knowledge_link();
121363
121587
  init_knowledge_store();
121364
121588
  var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
121365
- import { existsSync as existsSync81 } from "node:fs";
121589
+ import { existsSync as existsSync80 } from "node:fs";
121366
121590
  import { appendFile as appendFile14, mkdir as mkdir29, readFile as readFile31 } from "node:fs/promises";
121367
121591
  import * as path147 from "node:path";
121368
121592
  function resolveApplicationLogPath(directory) {
@@ -121451,7 +121675,7 @@ async function bumpCountersBatch(directory, bumps) {
121451
121675
  const swarmPath = resolveSwarmKnowledgePath(directory);
121452
121676
  await transactKnowledge(swarmPath, applyOne);
121453
121677
  const hivePath = resolveHiveKnowledgePath();
121454
- if (existsSync81(hivePath)) {
121678
+ if (existsSync80(hivePath)) {
121455
121679
  await transactKnowledge(hivePath, applyOne);
121456
121680
  }
121457
121681
  }
@@ -122425,7 +122649,7 @@ init_extractors();
122425
122649
  // src/hooks/phase-directives.ts
122426
122650
  init_knowledge_events();
122427
122651
  init_knowledge_store();
122428
- import { existsSync as existsSync82 } from "node:fs";
122652
+ import { existsSync as existsSync81 } from "node:fs";
122429
122653
  async function collectPhaseDirectiveIds(directory, phaseLabel) {
122430
122654
  const events = await readKnowledgeEvents(directory);
122431
122655
  const ids = new Set;
@@ -122445,7 +122669,7 @@ async function readEntriesById(directory) {
122445
122669
  for (const e of swarm)
122446
122670
  map3.set(e.id, e);
122447
122671
  const hivePath = resolveHiveKnowledgePath();
122448
- if (existsSync82(hivePath)) {
122672
+ if (existsSync81(hivePath)) {
122449
122673
  const hive = await readKnowledge(hivePath);
122450
122674
  for (const e of hive)
122451
122675
  if (!map3.has(e.id))
@@ -124337,7 +124561,7 @@ init_schema();
124337
124561
  // src/services/directive-predicate-runner.ts
124338
124562
  init_bun_compat();
124339
124563
  init_logger();
124340
- import { existsSync as existsSync85 } from "node:fs";
124564
+ import { existsSync as existsSync84 } from "node:fs";
124341
124565
  import * as path153 from "node:path";
124342
124566
  var PREDICATE_TIMEOUT_MS = 15000;
124343
124567
  var TOOL_BINARY_ALLOWLIST = new Set([
@@ -124379,7 +124603,7 @@ function findBinaryInPath(binary) {
124379
124603
  if (!dir)
124380
124604
  continue;
124381
124605
  const candidate = path153.join(dir, exeName);
124382
- if (existsSync85(candidate))
124606
+ if (existsSync84(candidate))
124383
124607
  return candidate;
124384
124608
  }
124385
124609
  return null;
@@ -125454,7 +125678,7 @@ init_zod();
125454
125678
  init_path_security();
125455
125679
  init_create_tool();
125456
125680
  import {
125457
- existsSync as existsSync87,
125681
+ existsSync as existsSync86,
125458
125682
  mkdirSync as mkdirSync40,
125459
125683
  mkdtempSync as mkdtempSync2,
125460
125684
  readFileSync as readFileSync57,
@@ -125817,13 +126041,13 @@ function atomicWriteFileSync2(targetPath, content) {
125817
126041
  writeFileSync26(tempPath, content, "utf-8");
125818
126042
  renameSync29(tempPath, targetPath);
125819
126043
  } finally {
125820
- if (existsSync87(tempPath)) {
126044
+ if (existsSync86(tempPath)) {
125821
126045
  try {
125822
126046
  unlinkSync25(tempPath);
125823
126047
  } catch {}
125824
126048
  }
125825
126049
  const tempDir = path156.dirname(tempPath);
125826
- if (tempDir !== dir && existsSync87(tempDir)) {
126050
+ if (tempDir !== dir && existsSync86(tempDir)) {
125827
126051
  try {
125828
126052
  rmdirSync(tempDir);
125829
126053
  } catch {}
@@ -125900,7 +126124,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
125900
126124
  };
125901
126125
  }
125902
126126
  const parentDir = path156.dirname(fullPath);
125903
- if (!existsSync87(parentDir)) {
126127
+ if (!existsSync86(parentDir)) {
125904
126128
  return {
125905
126129
  file: targetPath,
125906
126130
  status: "error",
@@ -125916,7 +126140,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
125916
126140
  ]
125917
126141
  };
125918
126142
  }
125919
- if (existsSync87(fullPath)) {
126143
+ if (existsSync86(fullPath)) {
125920
126144
  return {
125921
126145
  file: targetPath,
125922
126146
  status: "error",
@@ -125991,7 +126215,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
125991
126215
  ]
125992
126216
  };
125993
126217
  }
125994
- if (!existsSync87(fullPath)) {
126218
+ if (!existsSync86(fullPath)) {
125995
126219
  return {
125996
126220
  file: targetPath,
125997
126221
  status: "error",
@@ -126035,7 +126259,7 @@ function processFileDiff(fileDiff, targetPath, fullPath, workspace, dryRun, allo
126035
126259
  hunksFailed: 0
126036
126260
  };
126037
126261
  }
126038
- if (!existsSync87(fullPath)) {
126262
+ if (!existsSync86(fullPath)) {
126039
126263
  return {
126040
126264
  file: targetPath,
126041
126265
  status: "error",
@@ -126190,7 +126414,7 @@ var swarmApplyPatch = createSwarmTool({
126190
126414
  const dryRun = obj.dryRun ?? false;
126191
126415
  const allowCreates = obj.allowCreates ?? false;
126192
126416
  const allowDeletes = obj.allowDeletes ?? false;
126193
- if (!existsSync87(directory)) {
126417
+ if (!existsSync86(directory)) {
126194
126418
  return JSON.stringify(buildErrorResult("Workspace directory does not exist"), null, 2);
126195
126419
  }
126196
126420
  if (files.length === 0) {
@@ -127383,7 +127607,7 @@ function countCodeLines(content) {
127383
127607
  return lines.length;
127384
127608
  }
127385
127609
  function isTestFile(filePath) {
127386
- const basename18 = path160.basename(filePath);
127610
+ const basename19 = path160.basename(filePath);
127387
127611
  const _ext = path160.extname(filePath).toLowerCase();
127388
127612
  const testPatterns = [
127389
127613
  ".test.",
@@ -127399,7 +127623,7 @@ function isTestFile(filePath) {
127399
127623
  ".spec.jsx"
127400
127624
  ];
127401
127625
  for (const pattern of testPatterns) {
127402
- if (basename18.includes(pattern)) {
127626
+ if (basename19.includes(pattern)) {
127403
127627
  return true;
127404
127628
  }
127405
127629
  }
@@ -128012,7 +128236,7 @@ ${body}`);
128012
128236
  // src/council/council-evidence-writer.ts
128013
128237
  init_zod();
128014
128238
  init_task_file();
128015
- import { appendFileSync as appendFileSync18, existsSync as existsSync92, mkdirSync as mkdirSync42, readFileSync as readFileSync63 } from "node:fs";
128239
+ import { appendFileSync as appendFileSync18, existsSync as existsSync91, mkdirSync as mkdirSync42, readFileSync as readFileSync63 } from "node:fs";
128016
128240
  import { join as join128 } from "node:path";
128017
128241
  var EVIDENCE_DIR2 = ".swarm/evidence";
128018
128242
  var VALID_TASK_ID = /^\d+\.\d+(\.\d+)*$/;
@@ -128056,7 +128280,7 @@ async function writeCouncilEvidence(workingDir, synthesis) {
128056
128280
  const filePath = taskEvidencePath(workingDir, synthesis.taskId);
128057
128281
  await _internals90.withTaskEvidenceLock(workingDir, synthesis.taskId, COUNCIL_AGENT_ID, async () => {
128058
128282
  const existingRoot = Object.create(null);
128059
- if (existsSync92(filePath)) {
128283
+ if (existsSync91(filePath)) {
128060
128284
  try {
128061
128285
  const parsed = EvidenceFileSchema.parse(JSON.parse(readFileSync63(filePath, "utf-8")));
128062
128286
  safeAssignOwnProps(existingRoot, parsed);
@@ -128451,7 +128675,7 @@ function buildFinalCouncilFeedback(projectSummary, verdict, vetoedBy, requiredFi
128451
128675
  // src/council/criteria-store.ts
128452
128676
  init_zod();
128453
128677
  init_task_file();
128454
- import { existsSync as existsSync93, mkdirSync as mkdirSync43, readFileSync as readFileSync64 } from "node:fs";
128678
+ import { existsSync as existsSync92, mkdirSync as mkdirSync43, readFileSync as readFileSync64 } from "node:fs";
128455
128679
  import { join as join129 } from "node:path";
128456
128680
  var COUNCIL_DIR = ".swarm/council";
128457
128681
  var CouncilCriteriaSchema = exports_external.object({
@@ -128475,7 +128699,7 @@ async function writeCriteria(workingDir, taskId, criteria) {
128475
128699
  }
128476
128700
  function readCriteria(workingDir, taskId) {
128477
128701
  const filePath = join129(workingDir, COUNCIL_DIR, `${safeId(taskId)}.json`);
128478
- if (!existsSync93(filePath))
128702
+ if (!existsSync92(filePath))
128479
128703
  return null;
128480
128704
  try {
128481
128705
  return CouncilCriteriaSchema.parse(JSON.parse(readFileSync64(filePath, "utf-8")));
@@ -130199,7 +130423,7 @@ init_zod();
130199
130423
  init_utils2();
130200
130424
  import { createHash as createHash19 } from "node:crypto";
130201
130425
  import {
130202
- existsSync as existsSync95,
130426
+ existsSync as existsSync94,
130203
130427
  mkdirSync as mkdirSync44,
130204
130428
  readFileSync as readFileSync67,
130205
130429
  renameSync as renameSync30,
@@ -130250,7 +130474,7 @@ function storeLaneOutput(directory, input, now = Date.now) {
130250
130474
  const absPath = validateSwarmPath(directory, relPath);
130251
130475
  const timestamp = new Date(now()).toISOString();
130252
130476
  try {
130253
- if (existsSync95(absPath)) {
130477
+ if (existsSync94(absPath)) {
130254
130478
  const existing = LaneOutputArtifactSchema.safeParse(JSON.parse(readFileSync67(absPath, "utf-8")));
130255
130479
  if (existing.success && existing.data.digest === digest3) {
130256
130480
  return {
@@ -130304,7 +130528,7 @@ function readLaneOutput(directory, ref) {
130304
130528
  if (!REF_RE.test(ref))
130305
130529
  return null;
130306
130530
  const absPath = validateSwarmPath(directory, laneOutputRelativePath(ref));
130307
- if (!existsSync95(absPath))
130531
+ if (!existsSync94(absPath))
130308
130532
  return null;
130309
130533
  let parsed;
130310
130534
  try {
@@ -130406,7 +130630,7 @@ function writeAtomicJson(absPath, value) {
130406
130630
  if (lastRenameError)
130407
130631
  throw lastRenameError;
130408
130632
  } finally {
130409
- if (existsSync95(tempFile)) {
130633
+ if (existsSync94(tempFile)) {
130410
130634
  try {
130411
130635
  unlinkSync26(tempFile);
130412
130636
  } catch {}
@@ -135442,9 +135666,9 @@ var _internals105 = {
135442
135666
  },
135443
135667
  getTimestamp: () => new Date().toISOString(),
135444
135668
  retireSkillFile: async (filePath) => {
135445
- const { unlink: unlink7 } = await import("node:fs/promises");
135669
+ const { unlink: unlink8 } = await import("node:fs/promises");
135446
135670
  try {
135447
- await unlink7(filePath);
135671
+ await unlink8(filePath);
135448
135672
  return true;
135449
135673
  } catch (err) {
135450
135674
  const error93 = err;
@@ -137188,8 +137412,10 @@ var knowledge_add = createSwarmTool({
137188
137412
  init_zod();
137189
137413
  init_knowledge_events();
137190
137414
  init_knowledge_store();
137415
+ init_skill_generator();
137191
137416
  init_logger();
137192
137417
  init_create_tool();
137418
+ import * as path175 from "node:path";
137193
137419
  var MODES2 = ["archive", "quarantine", "purge"];
137194
137420
  var TIERS = ["swarm", "hive"];
137195
137421
  var knowledge_archive = createSwarmTool({
@@ -137272,6 +137498,44 @@ var knowledge_archive = createSwarmTool({
137272
137498
  } else {
137273
137499
  await recordKnowledgeEvent(directory, tombstone);
137274
137500
  }
137501
+ const allArchivedIds = await getArchivedKnowledgeIds(directory);
137502
+ allArchivedIds.add(id);
137503
+ queueMicrotask(async () => {
137504
+ try {
137505
+ const affectedSkillDirs = await findSkillsBySourceKnowledgeId(directory, id);
137506
+ const staleSkillDirs = await findStaleSkillsBySourceKnowledgeId(directory, allArchivedIds);
137507
+ const allSkillDirs = new Set([
137508
+ ...affectedSkillDirs,
137509
+ ...staleSkillDirs
137510
+ ]);
137511
+ if (allSkillDirs.size === 0)
137512
+ return;
137513
+ const slugSet = new Set;
137514
+ let retiredCount = 0;
137515
+ let staleCount = 0;
137516
+ for (const skillDir of allSkillDirs) {
137517
+ const slug = path175.basename(skillDir);
137518
+ if (slugSet.has(slug))
137519
+ continue;
137520
+ slugSet.add(slug);
137521
+ const result = await retireOrMarkStale(directory, skillDir, allArchivedIds);
137522
+ if (result.action === "retire")
137523
+ retiredCount++;
137524
+ else
137525
+ staleCount++;
137526
+ }
137527
+ const batchEvent = {
137528
+ type: "skill-stale-batch",
137529
+ skillIds: Array.from(slugSet),
137530
+ archivedIds: Array.from(allArchivedIds),
137531
+ retiredCount,
137532
+ staleCount
137533
+ };
137534
+ await recordKnowledgeEvent(directory, batchEvent);
137535
+ } catch (err) {
137536
+ warn(`[knowledge-archive] post-archive skill invalidation failed: ${err instanceof Error ? err.message : String(err)}`);
137537
+ }
137538
+ });
137275
137539
  return JSON.stringify({
137276
137540
  success: true,
137277
137541
  id,
@@ -137288,7 +137552,7 @@ init_zod();
137288
137552
  init_config();
137289
137553
  init_knowledge_store();
137290
137554
  init_create_tool();
137291
- import { existsSync as existsSync101 } from "node:fs";
137555
+ import { existsSync as existsSync100 } from "node:fs";
137292
137556
  var DEFAULT_LIMIT = 10;
137293
137557
  var MAX_LESSON_LENGTH = 200;
137294
137558
  var VALID_CATEGORIES3 = [
@@ -137364,14 +137628,14 @@ function validateLimit(limit) {
137364
137628
  }
137365
137629
  async function readSwarmKnowledge(directory) {
137366
137630
  const swarmPath = resolveSwarmKnowledgePath(directory);
137367
- if (!existsSync101(swarmPath)) {
137631
+ if (!existsSync100(swarmPath)) {
137368
137632
  return [];
137369
137633
  }
137370
137634
  return readKnowledge(swarmPath);
137371
137635
  }
137372
137636
  async function readHiveKnowledge() {
137373
137637
  const hivePath = resolveHiveKnowledgePath();
137374
- if (!existsSync101(hivePath)) {
137638
+ if (!existsSync100(hivePath)) {
137375
137639
  return [];
137376
137640
  }
137377
137641
  return readKnowledge(hivePath);
@@ -137640,7 +137904,7 @@ var knowledge_receipt = createSwarmTool({
137640
137904
  const recordedEventIds = [];
137641
137905
  const emit2 = async (event) => {
137642
137906
  const written = await recordKnowledgeEvent(directory, event);
137643
- if (written)
137907
+ if (written && written.event_id !== undefined)
137644
137908
  recordedEventIds.push(written.event_id);
137645
137909
  };
137646
137910
  for (const item of applied) {
@@ -137706,8 +137970,12 @@ var knowledge_receipt = createSwarmTool({
137706
137970
 
137707
137971
  // src/tools/knowledge-remove.ts
137708
137972
  init_zod();
137973
+ init_knowledge_events();
137709
137974
  init_knowledge_store();
137975
+ init_skill_generator();
137976
+ init_logger();
137710
137977
  init_create_tool();
137978
+ import * as path176 from "node:path";
137711
137979
  var knowledge_remove = createSwarmTool({
137712
137980
  description: "Delete an outdated swarm knowledge entry by ID (swarm tier only — does not affect hive). Promoted entries cannot be deleted. Double-deletion is idempotent — removing a non-existent entry returns a clear message without error.",
137713
137981
  args: {
@@ -137767,6 +138035,44 @@ var knowledge_remove = createSwarmTool({
137767
138035
  message: "entry not found"
137768
138036
  });
137769
138037
  }
138038
+ const allArchivedIds = await getArchivedKnowledgeIds(directory);
138039
+ allArchivedIds.add(id);
138040
+ queueMicrotask(async () => {
138041
+ try {
138042
+ const affectedSkillDirs = await findSkillsBySourceKnowledgeId(directory, id);
138043
+ const staleSkillDirs = await findStaleSkillsBySourceKnowledgeId(directory, allArchivedIds);
138044
+ const allSkillDirs = new Set([
138045
+ ...affectedSkillDirs,
138046
+ ...staleSkillDirs
138047
+ ]);
138048
+ if (allSkillDirs.size === 0)
138049
+ return;
138050
+ const slugSet = new Set;
138051
+ let retiredCount = 0;
138052
+ let staleCount = 0;
138053
+ for (const skillDir of allSkillDirs) {
138054
+ const slug = path176.basename(skillDir);
138055
+ if (slugSet.has(slug))
138056
+ continue;
138057
+ slugSet.add(slug);
138058
+ const result = await retireOrMarkStale(directory, skillDir, allArchivedIds);
138059
+ if (result.action === "retire")
138060
+ retiredCount++;
138061
+ else
138062
+ staleCount++;
138063
+ }
138064
+ const batchEvent = {
138065
+ type: "skill-stale-batch",
138066
+ skillIds: Array.from(slugSet),
138067
+ archivedIds: Array.from(allArchivedIds),
138068
+ retiredCount,
138069
+ staleCount
138070
+ };
138071
+ await recordKnowledgeEvent(directory, batchEvent);
138072
+ } catch (err) {
138073
+ warn(`[knowledge-remove] post-purge skill invalidation failed: ${err instanceof Error ? err.message : String(err)}`);
138074
+ }
138075
+ });
137770
138076
  return JSON.stringify({
137771
138077
  success: true,
137772
138078
  removed: 1,
@@ -137821,10 +138127,10 @@ var lean_turbo_acquire_locks = createSwarmTool({
137821
138127
  init_zod();
137822
138128
  init_constants();
137823
138129
  import * as fs108 from "node:fs";
137824
- import * as path175 from "node:path";
138130
+ import * as path177 from "node:path";
137825
138131
  init_create_tool();
137826
138132
  function readPlanJson2(directory) {
137827
- const planPath = path175.join(directory, ".swarm", "plan.json");
138133
+ const planPath = path177.join(directory, ".swarm", "plan.json");
137828
138134
  if (!fs108.existsSync(planPath)) {
137829
138135
  return null;
137830
138136
  }
@@ -138192,12 +138498,12 @@ var lint_spec = createSwarmTool({
138192
138498
  // src/tools/mutation-test.ts
138193
138499
  init_zod();
138194
138500
  import * as fs109 from "node:fs";
138195
- import * as path177 from "node:path";
138501
+ import * as path179 from "node:path";
138196
138502
 
138197
138503
  // src/mutation/engine.ts
138198
138504
  import { spawnSync as spawnSync13 } from "node:child_process";
138199
138505
  import { unlinkSync as unlinkSync27, writeFileSync as writeFileSync30 } from "node:fs";
138200
- import * as path176 from "node:path";
138506
+ import * as path178 from "node:path";
138201
138507
 
138202
138508
  // src/mutation/equivalence.ts
138203
138509
  function isStaticallyEquivalent(originalCode, mutatedCode) {
@@ -138360,7 +138666,7 @@ function validateTestCommand(testCommand) {
138360
138666
  return "testCommand must not be empty";
138361
138667
  }
138362
138668
  const exe = testCommand[0];
138363
- const base = path176.basename(exe).replace(/\.(exe|cmd|bat)$/i, "");
138669
+ const base = path178.basename(exe).replace(/\.(exe|cmd|bat)$/i, "");
138364
138670
  if (!ALLOWED_TEST_RUNNERS.has(base)) {
138365
138671
  return `testCommand executable '${exe}' is not in the allowed test runner list. Permitted runners: ${[...ALLOWED_TEST_RUNNERS].join(", ")}`;
138366
138672
  }
@@ -138384,7 +138690,7 @@ async function executeMutation(patch, testCommand, testFiles, workingDir) {
138384
138690
  let patchFile;
138385
138691
  try {
138386
138692
  const safeId2 = patch.id.replace(/[^a-zA-Z0-9_-]/g, "_");
138387
- patchFile = path176.join(workingDir, `.mutation_patch_${safeId2}.diff`);
138693
+ patchFile = path178.join(workingDir, `.mutation_patch_${safeId2}.diff`);
138388
138694
  try {
138389
138695
  writeFileSync30(patchFile, patch.patch);
138390
138696
  } catch (writeErr) {
@@ -138801,7 +139107,7 @@ var mutation_test = createSwarmTool({
138801
139107
  ];
138802
139108
  for (const filePath of uniquePaths) {
138803
139109
  try {
138804
- const resolvedPath = path177.resolve(cwd, filePath);
139110
+ const resolvedPath = path179.resolve(cwd, filePath);
138805
139111
  sourceFiles.set(filePath, fs109.readFileSync(resolvedPath, "utf-8"));
138806
139112
  } catch {}
138807
139113
  }
@@ -138819,8 +139125,8 @@ var mutation_test = createSwarmTool({
138819
139125
 
138820
139126
  // src/tools/parse-lane-candidates.ts
138821
139127
  init_zod();
138822
- import { existsSync as existsSync103 } from "node:fs";
138823
- import * as path179 from "node:path";
139128
+ import { existsSync as existsSync102 } from "node:fs";
139129
+ import * as path181 from "node:path";
138824
139130
 
138825
139131
  // src/background/candidate-parser.ts
138826
139132
  init_zod();
@@ -138831,7 +139137,7 @@ init_utils2();
138831
139137
  var import_proper_lockfile10 = __toESM(require_proper_lockfile(), 1);
138832
139138
  import { createHash as createHash24 } from "node:crypto";
138833
139139
  import { appendFileSync as appendFileSync19, mkdirSync as mkdirSync46 } from "node:fs";
138834
- import * as path178 from "node:path";
139140
+ import * as path180 from "node:path";
138835
139141
  var BATCH_DIGEST_ALGORITHM = "sha256";
138836
139142
  var SidecarEnvelopeSchema = exports_external.object({
138837
139143
  record_type: exports_external.literal("invocation"),
@@ -138986,7 +139292,7 @@ function computeBatchDigest(batchId) {
138986
139292
  return createHash24(BATCH_DIGEST_ALGORITHM).update(batchId).digest("hex");
138987
139293
  }
138988
139294
  function sidecarRelativePath(batchDigest) {
138989
- return path178.join("lane-results", batchDigest, "candidates.jsonl");
139295
+ return path180.join("lane-results", batchDigest, "candidates.jsonl");
138990
139296
  }
138991
139297
  function validateRecord(record3, schema, label) {
138992
139298
  const result = schema.safeParse(record3);
@@ -138995,7 +139301,7 @@ function validateRecord(record3, schema, label) {
138995
139301
  }
138996
139302
  }
138997
139303
  function withLockfile(lockDir, write) {
138998
- const lockPath = path178.join(lockDir, ".lock");
139304
+ const lockPath = path180.join(lockDir, ".lock");
138999
139305
  const lf = import_proper_lockfile10.default;
139000
139306
  const release = lf.lockSync(lockPath, {
139001
139307
  realpath: false
@@ -139014,7 +139320,7 @@ function appendToSidecar(options, batchId, envelope, candidates) {
139014
139320
  for (let i = 0;i < candidates.length; i++) {
139015
139321
  validateRecord(candidates[i], SidecarCandidateSchema, `candidate[${i}]`);
139016
139322
  }
139017
- mkdirSync46(path178.dirname(absPath), { recursive: true });
139323
+ mkdirSync46(path180.dirname(absPath), { recursive: true });
139018
139324
  const sanitizedEnvelope = sanitizeRecord(structuredClone(envelope));
139019
139325
  const sanitizedCandidates = candidates.map((c) => sanitizeRecord(structuredClone(c)));
139020
139326
  const lines = [JSON.stringify(sanitizedEnvelope)];
@@ -139028,7 +139334,7 @@ function appendToSidecar(options, batchId, envelope, candidates) {
139028
139334
  appendFileSync19(absPath, payload, "utf-8");
139029
139335
  };
139030
139336
  if (options.useLockfile) {
139031
- withLockfile(path178.dirname(absPath), doWrite);
139337
+ withLockfile(path180.dirname(absPath), doWrite);
139032
139338
  } else {
139033
139339
  doWrite();
139034
139340
  }
@@ -139487,7 +139793,7 @@ function laneOutputRelativePath2(ref) {
139487
139793
  if (parts.length !== 4)
139488
139794
  return "";
139489
139795
  const [, batchDigest, laneDigest, outputDigest] = parts;
139490
- return path179.join("lane-results", batchDigest, laneDigest, `${outputDigest}.json`);
139796
+ return path181.join("lane-results", batchDigest, laneDigest, `${outputDigest}.json`);
139491
139797
  }
139492
139798
  var parse_lane_candidates = createSwarmTool({
139493
139799
  description: "Parse [CANDIDATE] rows from a dispatch_lanes or collect_lane_results artifact (by output_ref), produce structured records with provenance, optionally persist to a per-batch sidecar JSONL. Pure-parser variant exists as internal module.",
@@ -139522,10 +139828,10 @@ var parse_lane_candidates = createSwarmTool({
139522
139828
  project_root
139523
139829
  } = parsed.data;
139524
139830
  if (project_root !== undefined) {
139525
- const absRoot = path179.resolve(project_root);
139526
- const absDir = path179.resolve(directory);
139527
- const rel = path179.relative(absDir, absRoot);
139528
- if (rel === ".." || rel.startsWith(`..${path179.sep}`) || path179.isAbsolute(rel)) {
139831
+ const absRoot = path181.resolve(project_root);
139832
+ const absDir = path181.resolve(directory);
139833
+ const rel = path181.relative(absDir, absRoot);
139834
+ if (rel === ".." || rel.startsWith(`..${path181.sep}`) || path181.isAbsolute(rel)) {
139529
139835
  return JSON.stringify({
139530
139836
  success: false,
139531
139837
  failure_class: "invalid_args",
@@ -139545,7 +139851,7 @@ var parse_lane_candidates = createSwarmTool({
139545
139851
  if (!loaded) {
139546
139852
  const relPath = REF_RE2.test(output_ref) ? laneOutputRelativePath2(output_ref) : "";
139547
139853
  const absPath = relPath ? validateSwarmPath(directory, relPath) : "";
139548
- const fileExists = absPath ? existsSync103(absPath) : false;
139854
+ const fileExists = absPath ? existsSync102(absPath) : false;
139549
139855
  const artifactStatus = fileExists ? "artifact-corrupted" : "ref-not-found";
139550
139856
  const refParts = output_ref.split(":");
139551
139857
  const hasValidRef = REF_RE2.test(output_ref) && refParts.length === 4;
@@ -139618,22 +139924,22 @@ init_schema();
139618
139924
  init_manager2();
139619
139925
  init_task_file();
139620
139926
  import * as fs119 from "node:fs";
139621
- import * as path189 from "node:path";
139927
+ import * as path191 from "node:path";
139622
139928
 
139623
139929
  // src/full-auto/phase-approval.ts
139624
139930
  init_utils2();
139625
139931
  init_logger();
139626
139932
  init_state3();
139627
139933
  import * as fs110 from "node:fs";
139628
- import * as path180 from "node:path";
139934
+ import * as path182 from "node:path";
139629
139935
  var APPROVAL_TTL_MS = 24 * 60 * 60 * 1000;
139630
139936
  function readEvidenceDir(directory, phase) {
139631
139937
  try {
139632
- const dirPath = validateSwarmPath(directory, path180.posix.join("evidence", String(phase)));
139938
+ const dirPath = validateSwarmPath(directory, path182.posix.join("evidence", String(phase)));
139633
139939
  if (!fs110.existsSync(dirPath))
139634
139940
  return [];
139635
139941
  const entries = fs110.readdirSync(dirPath);
139636
- return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) => path180.join(dirPath, e));
139942
+ return entries.filter((e) => e.startsWith("full-auto-") && e.endsWith(".json")).map((e) => path182.join(dirPath, e));
139637
139943
  } catch {
139638
139944
  return [];
139639
139945
  }
@@ -139792,7 +140098,13 @@ async function evaluatePhaseCriticalDirectives(params) {
139792
140098
  try {
139793
140099
  const events = await readKnowledgeEvents(params.directory);
139794
140100
  const retrievedThisPhase = events.filter((e) => e.type === "retrieved" && (!params.phaseLabel || e.phase === params.phaseLabel));
139795
- const phaseStart = retrievedThisPhase.length > 0 ? retrievedThisPhase.map((e) => e.timestamp).reduce((a, b) => a < b ? a : b) : null;
140101
+ const phaseStart = retrievedThisPhase.length > 0 ? retrievedThisPhase.map((e) => e.timestamp).reduce((a, b) => {
140102
+ if (b === undefined)
140103
+ return a;
140104
+ if (a === undefined)
140105
+ return b;
140106
+ return a < b ? a : b;
140107
+ }, undefined) : null;
139796
140108
  const criticalIds = await readCriticalIdsForPhase(params.directory, params.phaseLabel);
139797
140109
  if (criticalIds.length === 0) {
139798
140110
  return {
@@ -139802,7 +140114,13 @@ async function evaluatePhaseCriticalDirectives(params) {
139802
140114
  failedClosed: false
139803
140115
  };
139804
140116
  }
139805
- const receipts = events.filter(isReceipt).filter((r) => phaseStart === null || r.timestamp >= phaseStart).map((r) => ({
140117
+ const receipts = events.filter(isReceipt).filter((r) => {
140118
+ if (phaseStart === null || phaseStart === undefined)
140119
+ return true;
140120
+ if (r.timestamp === undefined)
140121
+ return false;
140122
+ return r.timestamp >= phaseStart;
140123
+ }).map((r) => ({
139806
140124
  type: r.type,
139807
140125
  knowledge_id: r.knowledge_id,
139808
140126
  timestamp: r.timestamp,
@@ -139888,16 +140206,16 @@ init_plan_schema();
139888
140206
  init_ledger();
139889
140207
  init_manager();
139890
140208
  import * as fs111 from "node:fs";
139891
- import * as path181 from "node:path";
140209
+ import * as path183 from "node:path";
139892
140210
  async function writeCheckpoint(directory) {
139893
140211
  try {
139894
140212
  const plan = await loadPlan(directory);
139895
140213
  if (!plan)
139896
140214
  return;
139897
- const swarmDir = path181.join(directory, ".swarm");
140215
+ const swarmDir = path183.join(directory, ".swarm");
139898
140216
  fs111.mkdirSync(swarmDir, { recursive: true });
139899
- const jsonPath = path181.join(swarmDir, "SWARM_PLAN.json");
139900
- const mdPath = path181.join(swarmDir, "SWARM_PLAN.md");
140217
+ const jsonPath = path183.join(swarmDir, "SWARM_PLAN.json");
140218
+ const mdPath = path183.join(swarmDir, "SWARM_PLAN.md");
139901
140219
  fs111.writeFileSync(jsonPath, JSON.stringify(plan, null, 2), "utf8");
139902
140220
  const md = derivePlanMarkdown(plan);
139903
140221
  fs111.writeFileSync(mdPath, md, "utf8");
@@ -140402,7 +140720,7 @@ init_state();
140402
140720
  // src/turbo/lean/phase-ready.ts
140403
140721
  init_file_locks();
140404
140722
  import * as fs112 from "node:fs";
140405
- import * as path182 from "node:path";
140723
+ import * as path184 from "node:path";
140406
140724
  init_state4();
140407
140725
  var DEFAULT_CONFIG3 = {
140408
140726
  phase_reviewer: true,
@@ -140411,7 +140729,7 @@ var DEFAULT_CONFIG3 = {
140411
140729
  };
140412
140730
  function defaultReadPlanJson(dir) {
140413
140731
  try {
140414
- const planPath = path182.join(dir, ".swarm", "plan.json");
140732
+ const planPath = path184.join(dir, ".swarm", "plan.json");
140415
140733
  if (!fs112.existsSync(planPath))
140416
140734
  return null;
140417
140735
  const raw = fs112.readFileSync(planPath, "utf-8");
@@ -140426,7 +140744,7 @@ function defaultReadPlanJson(dir) {
140426
140744
  }
140427
140745
  function readReviewerEvidenceFromFile(directory, phase) {
140428
140746
  try {
140429
- const evidencePath = path182.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-reviewer.json");
140747
+ const evidencePath = path184.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-reviewer.json");
140430
140748
  if (!fs112.existsSync(evidencePath)) {
140431
140749
  return null;
140432
140750
  }
@@ -140446,7 +140764,7 @@ function readReviewerEvidenceFromFile(directory, phase) {
140446
140764
  }
140447
140765
  function readCriticEvidenceFromFile(directory, phase) {
140448
140766
  try {
140449
- const evidencePath = path182.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-critic.json");
140767
+ const evidencePath = path184.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-critic.json");
140450
140768
  if (!fs112.existsSync(evidencePath)) {
140451
140769
  return null;
140452
140770
  }
@@ -140465,7 +140783,7 @@ function readCriticEvidenceFromFile(directory, phase) {
140465
140783
  }
140466
140784
  }
140467
140785
  function listLaneEvidenceSync(directory, phase) {
140468
- const evidenceDir = path182.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
140786
+ const evidenceDir = path184.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
140469
140787
  let entries;
140470
140788
  try {
140471
140789
  entries = fs112.readdirSync(evidenceDir);
@@ -140535,7 +140853,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
140535
140853
  ...DEFAULT_CONFIG3,
140536
140854
  ...actualConfig
140537
140855
  };
140538
- const statePath = path182.join(directory, ".swarm", "turbo-state.json");
140856
+ const statePath = path184.join(directory, ".swarm", "turbo-state.json");
140539
140857
  if (!fs112.existsSync(statePath)) {
140540
140858
  return {
140541
140859
  ok: false,
@@ -140723,7 +141041,7 @@ function verifyLeanTurboPhaseReady(directory, phase, sessionIDOrConfig, config3)
140723
141041
  }
140724
141042
  }
140725
141043
  if (mergedConfig.integrated_diff_required) {
140726
- const evidencePath = path182.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-phase.json");
141044
+ const evidencePath = path184.join(directory, ".swarm", "evidence", String(phase), "lean-turbo-phase.json");
140727
141045
  let hasDiff = false;
140728
141046
  try {
140729
141047
  const content = fs112.readFileSync(evidencePath, "utf-8");
@@ -140889,7 +141207,7 @@ async function runCompletionVerifyGate(ctx) {
140889
141207
  // src/tools/phase-complete/gates/drift-gate.ts
140890
141208
  init_effective_spec();
140891
141209
  import * as fs113 from "node:fs";
140892
- import * as path183 from "node:path";
141210
+ import * as path185 from "node:path";
140893
141211
 
140894
141212
  // src/tools/phase-complete/gates/gate-helpers.ts
140895
141213
  init_qa_gate_profile();
@@ -140938,7 +141256,7 @@ async function runDriftGate(ctx) {
140938
141256
  }
140939
141257
  let phaseType;
140940
141258
  try {
140941
- const planPath = path183.join(dir, ".swarm", "plan.json");
141259
+ const planPath = path185.join(dir, ".swarm", "plan.json");
140942
141260
  if (fs113.existsSync(planPath)) {
140943
141261
  const planRaw = fs113.readFileSync(planPath, "utf-8");
140944
141262
  const plan = JSON.parse(planRaw);
@@ -140957,7 +141275,7 @@ async function runDriftGate(ctx) {
140957
141275
  };
140958
141276
  }
140959
141277
  try {
140960
- const driftEvidencePath = path183.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
141278
+ const driftEvidencePath = path185.join(dir, ".swarm", "evidence", String(phase), "drift-verifier.json");
140961
141279
  let driftVerdictFound = false;
140962
141280
  let driftVerdictApproved = false;
140963
141281
  try {
@@ -140998,7 +141316,7 @@ async function runDriftGate(ctx) {
140998
141316
  let incompleteTaskCount = 0;
140999
141317
  let planParseable = false;
141000
141318
  try {
141001
- const planPath = path183.join(dir, ".swarm", "plan.json");
141319
+ const planPath = path185.join(dir, ".swarm", "plan.json");
141002
141320
  if (fs113.existsSync(planPath)) {
141003
141321
  const planRaw = fs113.readFileSync(planPath, "utf-8");
141004
141322
  const plan = JSON.parse(planRaw);
@@ -141077,7 +141395,7 @@ async function runDriftGate(ctx) {
141077
141395
  }
141078
141396
  // src/tools/phase-complete/gates/final-council-gate.ts
141079
141397
  import * as fs114 from "node:fs";
141080
- import * as path184 from "node:path";
141398
+ import * as path186 from "node:path";
141081
141399
  async function runFinalCouncilGate(ctx) {
141082
141400
  const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
141083
141401
  let finalCouncilEnabled = false;
@@ -141100,7 +141418,7 @@ async function runFinalCouncilGate(ctx) {
141100
141418
  if (lastPhaseId !== undefined && phase === lastPhaseId) {
141101
141419
  if (preamble.effectiveGates?.final_council === true) {
141102
141420
  finalCouncilEnabled = true;
141103
- const fcPath = path184.join(dir, ".swarm", "evidence", "final-council.json");
141421
+ const fcPath = path186.join(dir, ".swarm", "evidence", "final-council.json");
141104
141422
  let fcVerdictFound = false;
141105
141423
  let _fcVerdict;
141106
141424
  try {
@@ -141254,13 +141572,13 @@ async function runFinalCouncilGate(ctx) {
141254
141572
  }
141255
141573
  // src/tools/phase-complete/gates/hallucination-gate.ts
141256
141574
  import * as fs115 from "node:fs";
141257
- import * as path185 from "node:path";
141575
+ import * as path187 from "node:path";
141258
141576
  async function runHallucinationGate(ctx) {
141259
141577
  const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
141260
141578
  try {
141261
141579
  const preamble = await resolveGatePreamble(dir, sessionID);
141262
141580
  if (preamble.resolved && preamble.effectiveGates?.hallucination_guard === true) {
141263
- const hgPath = path185.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
141581
+ const hgPath = path187.join(dir, ".swarm", "evidence", String(phase), "hallucination-guard.json");
141264
141582
  let hgVerdictFound = false;
141265
141583
  let hgVerdictApproved = false;
141266
141584
  try {
@@ -141318,13 +141636,13 @@ async function runHallucinationGate(ctx) {
141318
141636
  }
141319
141637
  // src/tools/phase-complete/gates/mutation-gate.ts
141320
141638
  import * as fs116 from "node:fs";
141321
- import * as path186 from "node:path";
141639
+ import * as path188 from "node:path";
141322
141640
  async function runMutationGate(ctx) {
141323
141641
  const { phase, dir, sessionID, agentsDispatched, safeWarn } = ctx;
141324
141642
  try {
141325
141643
  const preamble = await resolveGatePreamble(dir, sessionID);
141326
141644
  if (preamble.resolved && preamble.effectiveGates?.mutation_test === true) {
141327
- const mgPath = path186.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
141645
+ const mgPath = path188.join(dir, ".swarm", "evidence", String(phase), "mutation-gate.json");
141328
141646
  let mgVerdictFound = false;
141329
141647
  let mgVerdict;
141330
141648
  try {
@@ -141382,7 +141700,7 @@ async function runMutationGate(ctx) {
141382
141700
  }
141383
141701
  // src/tools/phase-complete/gates/phase-council-gate.ts
141384
141702
  import * as fs117 from "node:fs";
141385
- import * as path187 from "node:path";
141703
+ import * as path189 from "node:path";
141386
141704
  async function runPhaseCouncilGate(ctx) {
141387
141705
  const { phase, dir, sessionID, pluginConfig, agentsDispatched, safeWarn } = ctx;
141388
141706
  const gateWarnings = [];
@@ -141391,7 +141709,7 @@ async function runPhaseCouncilGate(ctx) {
141391
141709
  const preamble = await resolveGatePreamble(dir, sessionID);
141392
141710
  if (preamble.resolved && preamble.effectiveGates?.phase_council === true && pluginConfig.council?.enabled === true) {
141393
141711
  councilModeEnabled = true;
141394
- const pcPath = path187.join(dir, ".swarm", "evidence", String(phase), "phase-council.json");
141712
+ const pcPath = path189.join(dir, ".swarm", "evidence", String(phase), "phase-council.json");
141395
141713
  let pcVerdictFound = false;
141396
141714
  let _pcVerdict;
141397
141715
  let pcQuorumSize;
@@ -141959,7 +142277,7 @@ async function executePhaseComplete(args2, workingDirectory, directory) {
141959
142277
  }
141960
142278
  if (retroFound && retroEntry?.lessons_learned && retroEntry.lessons_learned.length > 0) {
141961
142279
  try {
141962
- const projectName = path189.basename(dir);
142280
+ const projectName = path191.basename(dir);
141963
142281
  const curationResult = await curateAndStoreSwarm(retroEntry.lessons_learned, projectName, { phase_number: phase }, dir, knowledgeConfig, {
141964
142282
  llmDelegate: createCuratorLLMDelegate(dir, "phase", sessionID),
141965
142283
  enrichmentQuota: {
@@ -142536,7 +142854,7 @@ init_utils();
142536
142854
  init_bun_compat();
142537
142855
  init_create_tool();
142538
142856
  import * as fs120 from "node:fs";
142539
- import * as path190 from "node:path";
142857
+ import * as path192 from "node:path";
142540
142858
  var MAX_OUTPUT_BYTES7 = 52428800;
142541
142859
  var AUDIT_TIMEOUT_MS = 120000;
142542
142860
  function isValidEcosystem(value) {
@@ -142564,16 +142882,16 @@ function validateArgs3(args2) {
142564
142882
  function detectEcosystems(directory) {
142565
142883
  const ecosystems = [];
142566
142884
  const cwd = directory;
142567
- if (fs120.existsSync(path190.join(cwd, "package.json"))) {
142885
+ if (fs120.existsSync(path192.join(cwd, "package.json"))) {
142568
142886
  ecosystems.push("npm");
142569
142887
  }
142570
- if (fs120.existsSync(path190.join(cwd, "pyproject.toml")) || fs120.existsSync(path190.join(cwd, "requirements.txt"))) {
142888
+ if (fs120.existsSync(path192.join(cwd, "pyproject.toml")) || fs120.existsSync(path192.join(cwd, "requirements.txt"))) {
142571
142889
  ecosystems.push("pip");
142572
142890
  }
142573
- if (fs120.existsSync(path190.join(cwd, "Cargo.toml"))) {
142891
+ if (fs120.existsSync(path192.join(cwd, "Cargo.toml"))) {
142574
142892
  ecosystems.push("cargo");
142575
142893
  }
142576
- if (fs120.existsSync(path190.join(cwd, "go.mod"))) {
142894
+ if (fs120.existsSync(path192.join(cwd, "go.mod"))) {
142577
142895
  ecosystems.push("go");
142578
142896
  }
142579
142897
  try {
@@ -142582,13 +142900,13 @@ function detectEcosystems(directory) {
142582
142900
  ecosystems.push("dotnet");
142583
142901
  }
142584
142902
  } catch {}
142585
- if (fs120.existsSync(path190.join(cwd, "Gemfile")) || fs120.existsSync(path190.join(cwd, "Gemfile.lock"))) {
142903
+ if (fs120.existsSync(path192.join(cwd, "Gemfile")) || fs120.existsSync(path192.join(cwd, "Gemfile.lock"))) {
142586
142904
  ecosystems.push("ruby");
142587
142905
  }
142588
- if (fs120.existsSync(path190.join(cwd, "pubspec.yaml"))) {
142906
+ if (fs120.existsSync(path192.join(cwd, "pubspec.yaml"))) {
142589
142907
  ecosystems.push("dart");
142590
142908
  }
142591
- if (fs120.existsSync(path190.join(cwd, "composer.lock"))) {
142909
+ if (fs120.existsSync(path192.join(cwd, "composer.lock"))) {
142592
142910
  ecosystems.push("composer");
142593
142911
  }
142594
142912
  return ecosystems;
@@ -143725,7 +144043,7 @@ var pkg_audit = createSwarmTool({
143725
144043
  init_zod();
143726
144044
  init_manager2();
143727
144045
  import * as fs121 from "node:fs";
143728
- import * as path191 from "node:path";
144046
+ import * as path193 from "node:path";
143729
144047
  init_utils();
143730
144048
  init_create_tool();
143731
144049
  var MAX_FILE_SIZE = 1024 * 1024;
@@ -143848,7 +144166,7 @@ function isScaffoldFile(filePath) {
143848
144166
  if (SCAFFOLD_PATH_PATTERNS.some((pattern) => pattern.test(normalizedPath))) {
143849
144167
  return true;
143850
144168
  }
143851
- const filename = path191.basename(filePath);
144169
+ const filename = path193.basename(filePath);
143852
144170
  if (SCAFFOLD_FILENAME_PATTERNS.some((pattern) => pattern.test(filename))) {
143853
144171
  return true;
143854
144172
  }
@@ -143865,7 +144183,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
143865
144183
  if (regex.test(normalizedPath)) {
143866
144184
  return true;
143867
144185
  }
143868
- const filename = path191.basename(filePath);
144186
+ const filename = path193.basename(filePath);
143869
144187
  const filenameRegex = new RegExp(`^${regexPattern}$`, "i");
143870
144188
  if (filenameRegex.test(filename)) {
143871
144189
  return true;
@@ -143874,7 +144192,7 @@ function isAllowedByGlobs(filePath, allowGlobs) {
143874
144192
  return false;
143875
144193
  }
143876
144194
  function isParserSupported(filePath) {
143877
- const ext = path191.extname(filePath).toLowerCase();
144195
+ const ext = path193.extname(filePath).toLowerCase();
143878
144196
  return SUPPORTED_PARSER_EXTENSIONS.has(ext);
143879
144197
  }
143880
144198
  function isPlanFile(filePath) {
@@ -144121,9 +144439,9 @@ async function placeholderScan(input, directory) {
144121
144439
  let filesScanned = 0;
144122
144440
  const filesWithFindings = new Set;
144123
144441
  for (const filePath of changed_files) {
144124
- const fullPath = path191.isAbsolute(filePath) ? filePath : path191.resolve(directory, filePath);
144125
- const resolvedDirectory = path191.resolve(directory);
144126
- if (!fullPath.startsWith(resolvedDirectory + path191.sep) && fullPath !== resolvedDirectory) {
144442
+ const fullPath = path193.isAbsolute(filePath) ? filePath : path193.resolve(directory, filePath);
144443
+ const resolvedDirectory = path193.resolve(directory);
144444
+ if (!fullPath.startsWith(resolvedDirectory + path193.sep) && fullPath !== resolvedDirectory) {
144127
144445
  continue;
144128
144446
  }
144129
144447
  if (!fs121.existsSync(fullPath)) {
@@ -144132,7 +144450,7 @@ async function placeholderScan(input, directory) {
144132
144450
  if (isAllowedByGlobs(filePath, allow_globs)) {
144133
144451
  continue;
144134
144452
  }
144135
- const relativeFilePath = path191.relative(directory, fullPath).replace(/\\/g, "/");
144453
+ const relativeFilePath = path193.relative(directory, fullPath).replace(/\\/g, "/");
144136
144454
  if (FILE_ALLOWLIST.some((allowed) => relativeFilePath.endsWith(allowed))) {
144137
144455
  continue;
144138
144456
  }
@@ -144205,7 +144523,7 @@ var placeholder_scan = createSwarmTool({
144205
144523
 
144206
144524
  // src/tools/pre-check-batch.ts
144207
144525
  import * as fs125 from "node:fs";
144208
- import * as path195 from "node:path";
144526
+ import * as path197 from "node:path";
144209
144527
  init_zod();
144210
144528
  init_manager2();
144211
144529
  init_utils();
@@ -144346,7 +144664,7 @@ init_zod();
144346
144664
  init_manager2();
144347
144665
  init_detector();
144348
144666
  import * as fs124 from "node:fs";
144349
- import * as path194 from "node:path";
144667
+ import * as path196 from "node:path";
144350
144668
  import { extname as extname19 } from "node:path";
144351
144669
 
144352
144670
  // src/sast/rules/c.ts
@@ -145056,7 +145374,7 @@ function executeRulesSync(filePath, content, language) {
145056
145374
  // src/sast/semgrep.ts
145057
145375
  import * as child_process15 from "node:child_process";
145058
145376
  import * as fs122 from "node:fs";
145059
- import * as path192 from "node:path";
145377
+ import * as path194 from "node:path";
145060
145378
  var semgrepAvailableCache = null;
145061
145379
  var DEFAULT_RULES_DIR = ".swarm/semgrep-rules";
145062
145380
  var DEFAULT_TIMEOUT_MS4 = 30000;
@@ -145343,7 +145661,7 @@ async function runSemgrep(options) {
145343
145661
  }
145344
145662
  function getRulesDirectory(projectRoot) {
145345
145663
  if (projectRoot) {
145346
- return path192.resolve(projectRoot, DEFAULT_RULES_DIR);
145664
+ return path194.resolve(projectRoot, DEFAULT_RULES_DIR);
145347
145665
  }
145348
145666
  return DEFAULT_RULES_DIR;
145349
145667
  }
@@ -145364,24 +145682,24 @@ init_create_tool();
145364
145682
  init_utils2();
145365
145683
  import * as crypto13 from "node:crypto";
145366
145684
  import * as fs123 from "node:fs";
145367
- import * as path193 from "node:path";
145685
+ import * as path195 from "node:path";
145368
145686
  var BASELINE_SCHEMA_VERSION = "1.0.0";
145369
145687
  var MAX_BASELINE_FINDINGS = 2000;
145370
145688
  var MAX_BASELINE_BYTES = 2 * 1048576;
145371
145689
  var LOCK_RETRY_DELAYS_MS = [50, 100, 200, 400, 800];
145372
145690
  function normalizeFindingPath(directory, file3) {
145373
- const resolved = path193.isAbsolute(file3) ? file3 : path193.resolve(directory, file3);
145374
- const rel = path193.relative(path193.resolve(directory), resolved);
145691
+ const resolved = path195.isAbsolute(file3) ? file3 : path195.resolve(directory, file3);
145692
+ const rel = path195.relative(path195.resolve(directory), resolved);
145375
145693
  return rel.replace(/\\/g, "/");
145376
145694
  }
145377
145695
  function baselineRelPath(phase) {
145378
- return path193.join("evidence", String(phase), "sast-baseline.json");
145696
+ return path195.join("evidence", String(phase), "sast-baseline.json");
145379
145697
  }
145380
145698
  function tempRelPath(phase) {
145381
- return path193.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
145699
+ return path195.join("evidence", String(phase), `sast-baseline.json.tmp.${Date.now()}.${process.pid}`);
145382
145700
  }
145383
145701
  function lockRelPath(phase) {
145384
- return path193.join("evidence", String(phase), "sast-baseline.json.lock");
145702
+ return path195.join("evidence", String(phase), "sast-baseline.json.lock");
145385
145703
  }
145386
145704
  function getLine(lines, idx) {
145387
145705
  if (idx < 0 || idx >= lines.length)
@@ -145502,8 +145820,8 @@ async function captureOrMergeBaseline(directory, phase, findings, engine, scanne
145502
145820
  message: e instanceof Error ? e.message : "Path validation failed"
145503
145821
  };
145504
145822
  }
145505
- fs123.mkdirSync(path193.dirname(baselinePath), { recursive: true });
145506
- fs123.mkdirSync(path193.dirname(tempPath), { recursive: true });
145823
+ fs123.mkdirSync(path195.dirname(baselinePath), { recursive: true });
145824
+ fs123.mkdirSync(path195.dirname(tempPath), { recursive: true });
145507
145825
  const releaseLock = await acquireLock2(lockPath);
145508
145826
  try {
145509
145827
  let existing = null;
@@ -145776,9 +146094,9 @@ async function sastScan(input, directory, config3) {
145776
146094
  _filesSkipped++;
145777
146095
  continue;
145778
146096
  }
145779
- const resolvedPath = path194.isAbsolute(filePath) ? filePath : path194.resolve(directory, filePath);
145780
- const resolvedDirectory = path194.resolve(directory);
145781
- if (!resolvedPath.startsWith(resolvedDirectory + path194.sep) && resolvedPath !== resolvedDirectory) {
146097
+ const resolvedPath = path196.isAbsolute(filePath) ? filePath : path196.resolve(directory, filePath);
146098
+ const resolvedDirectory = path196.resolve(directory);
146099
+ if (!resolvedPath.startsWith(resolvedDirectory + path196.sep) && resolvedPath !== resolvedDirectory) {
145782
146100
  _filesSkipped++;
145783
146101
  continue;
145784
146102
  }
@@ -146093,18 +146411,18 @@ function validatePath(inputPath, baseDir, workspaceDir) {
146093
146411
  let resolved;
146094
146412
  const isWinAbs = isWindowsAbsolutePath(inputPath);
146095
146413
  if (isWinAbs) {
146096
- resolved = path195.win32.resolve(inputPath);
146097
- } else if (path195.isAbsolute(inputPath)) {
146098
- resolved = path195.resolve(inputPath);
146414
+ resolved = path197.win32.resolve(inputPath);
146415
+ } else if (path197.isAbsolute(inputPath)) {
146416
+ resolved = path197.resolve(inputPath);
146099
146417
  } else {
146100
- resolved = path195.resolve(baseDir, inputPath);
146418
+ resolved = path197.resolve(baseDir, inputPath);
146101
146419
  }
146102
- const workspaceResolved = path195.resolve(workspaceDir);
146420
+ const workspaceResolved = path197.resolve(workspaceDir);
146103
146421
  let relative38;
146104
146422
  if (isWinAbs) {
146105
- relative38 = path195.win32.relative(workspaceResolved, resolved);
146423
+ relative38 = path197.win32.relative(workspaceResolved, resolved);
146106
146424
  } else {
146107
- relative38 = path195.relative(workspaceResolved, resolved);
146425
+ relative38 = path197.relative(workspaceResolved, resolved);
146108
146426
  }
146109
146427
  if (relative38.startsWith("..")) {
146110
146428
  return "path traversal detected";
@@ -146169,7 +146487,7 @@ async function runLintOnFiles(linter, files, workspaceDir) {
146169
146487
  if (typeof file3 !== "string") {
146170
146488
  continue;
146171
146489
  }
146172
- const resolvedPath = path195.resolve(file3);
146490
+ const resolvedPath = path197.resolve(file3);
146173
146491
  const validationError = validatePath(resolvedPath, workspaceDir, workspaceDir);
146174
146492
  if (validationError) {
146175
146493
  continue;
@@ -146326,7 +146644,7 @@ async function runSecretscanWithFiles(files, directory) {
146326
146644
  skippedFiles++;
146327
146645
  continue;
146328
146646
  }
146329
- const resolvedPath = path195.resolve(file3);
146647
+ const resolvedPath = path197.resolve(file3);
146330
146648
  const validationError = validatePath(resolvedPath, directory, directory);
146331
146649
  if (validationError) {
146332
146650
  skippedFiles++;
@@ -146344,7 +146662,7 @@ async function runSecretscanWithFiles(files, directory) {
146344
146662
  };
146345
146663
  }
146346
146664
  for (const file3 of validatedFiles) {
146347
- const ext = path195.extname(file3).toLowerCase();
146665
+ const ext = path197.extname(file3).toLowerCase();
146348
146666
  if (DEFAULT_EXCLUDE_EXTENSIONS2.has(ext)) {
146349
146667
  skippedFiles++;
146350
146668
  continue;
@@ -146563,7 +146881,7 @@ function classifySastFindings(findings, changedLineRanges, directory) {
146563
146881
  const preexistingFindings = [];
146564
146882
  for (const finding of findings) {
146565
146883
  const filePath = finding.location.file;
146566
- const normalised = path195.relative(directory, filePath).replace(/\\/g, "/");
146884
+ const normalised = path197.relative(directory, filePath).replace(/\\/g, "/");
146567
146885
  const changedLines = changedLineRanges.get(normalised);
146568
146886
  if (changedLines?.has(finding.location.line)) {
146569
146887
  newFindings.push(finding);
@@ -146614,7 +146932,7 @@ async function runPreCheckBatch(input, workspaceDir, contextDir) {
146614
146932
  warn(`pre_check_batch: Invalid file path: ${file3}`);
146615
146933
  continue;
146616
146934
  }
146617
- changedFiles.push(path195.resolve(directory, file3));
146935
+ changedFiles.push(path197.resolve(directory, file3));
146618
146936
  }
146619
146937
  if (changedFiles.length === 0) {
146620
146938
  warn("pre_check_batch: No valid files after validation, skipping all tools (fail-closed)");
@@ -146815,9 +147133,9 @@ var pre_check_batch = createSwarmTool({
146815
147133
  };
146816
147134
  return JSON.stringify(errorResult, null, 2);
146817
147135
  }
146818
- const resolvedDirectory = path195.resolve(typedArgs.directory);
146819
- const workspaceAnchor = path195.resolve(directory);
146820
- if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor + path195.sep)) {
147136
+ const resolvedDirectory = path197.resolve(typedArgs.directory);
147137
+ const workspaceAnchor = path197.resolve(directory);
147138
+ if (resolvedDirectory !== workspaceAnchor && resolvedDirectory.startsWith(workspaceAnchor + path197.sep)) {
146821
147139
  const subDirError = `directory "${typedArgs.directory}" is a subdirectory of the project root — pre_check_batch requires the project root directory "${workspaceAnchor}"`;
146822
147140
  const subDirResult = {
146823
147141
  gates_passed: false,
@@ -146871,7 +147189,7 @@ var pre_check_batch = createSwarmTool({
146871
147189
  init_zod();
146872
147190
  init_path_security();
146873
147191
  init_create_tool();
146874
- import * as path196 from "node:path";
147192
+ import * as path198 from "node:path";
146875
147193
  var VALID_ACTIONS = [
146876
147194
  "build",
146877
147195
  "importers",
@@ -146900,7 +147218,7 @@ function validateFile(p) {
146900
147218
  return "file contains control characters";
146901
147219
  if (containsPathTraversal(p))
146902
147220
  return "file contains path traversal";
146903
- if (path196.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
147221
+ if (path198.isAbsolute(p) || /^[a-zA-Z]:[\\/]/.test(p)) {
146904
147222
  return "file must be a workspace-relative path, not absolute";
146905
147223
  }
146906
147224
  return null;
@@ -146923,8 +147241,8 @@ function ok(action, payload) {
146923
147241
  }
146924
147242
  function toRelativeGraphPath(input, workspaceRoot) {
146925
147243
  const normalized = input.replace(/\\/g, "/");
146926
- if (path196.isAbsolute(normalized)) {
146927
- const rel = path196.relative(workspaceRoot, normalized).replace(/\\/g, "/");
147244
+ if (path198.isAbsolute(normalized)) {
147245
+ const rel = path198.relative(workspaceRoot, normalized).replace(/\\/g, "/");
146928
147246
  return normalizeGraphPath(rel);
146929
147247
  }
146930
147248
  return normalizeGraphPath(normalized);
@@ -147120,10 +147438,10 @@ var repo_map = createSwarmTool({
147120
147438
  maxTokens: 4000
147121
147439
  });
147122
147440
  const toRel = (p) => {
147123
- if (!path196.isAbsolute(p))
147441
+ if (!path198.isAbsolute(p))
147124
147442
  return p.replace(/\\/g, "/");
147125
147443
  try {
147126
- return path196.relative(directory, p).replace(/\\/g, "/");
147444
+ return path198.relative(directory, p).replace(/\\/g, "/");
147127
147445
  } catch {
147128
147446
  return p;
147129
147447
  }
@@ -147173,7 +147491,7 @@ init_zod();
147173
147491
  init_effective_spec();
147174
147492
  init_create_tool();
147175
147493
  import * as fs126 from "node:fs";
147176
- import * as path197 from "node:path";
147494
+ import * as path199 from "node:path";
147177
147495
  var EVIDENCE_DIR4 = ".swarm/evidence";
147178
147496
  var OBLIGATION_KEYWORDS2 = ["MUST", "SHOULD", "SHALL"];
147179
147497
  var MAX_FILE_SIZE_BYTES8 = 1024 * 1024;
@@ -147241,7 +147559,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
147241
147559
  return [];
147242
147560
  }
147243
147561
  for (const entry of entries) {
147244
- const entryPath = path197.join(evidenceDir, entry);
147562
+ const entryPath = path199.join(evidenceDir, entry);
147245
147563
  try {
147246
147564
  const stat14 = fs126.statSync(entryPath);
147247
147565
  if (!stat14.isDirectory()) {
@@ -147257,11 +147575,11 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
147257
147575
  if (entryPhase !== String(phase)) {
147258
147576
  continue;
147259
147577
  }
147260
- const evidenceFilePath = path197.join(entryPath, "evidence.json");
147578
+ const evidenceFilePath = path199.join(entryPath, "evidence.json");
147261
147579
  try {
147262
- const resolvedPath = path197.resolve(evidenceFilePath);
147263
- const evidenceDirResolved = path197.resolve(evidenceDir);
147264
- if (!resolvedPath.startsWith(evidenceDirResolved + path197.sep)) {
147580
+ const resolvedPath = path199.resolve(evidenceFilePath);
147581
+ const evidenceDirResolved = path199.resolve(evidenceDir);
147582
+ if (!resolvedPath.startsWith(evidenceDirResolved + path199.sep)) {
147265
147583
  continue;
147266
147584
  }
147267
147585
  const stat14 = fs126.lstatSync(evidenceFilePath);
@@ -147295,7 +147613,7 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
147295
147613
  if (Array.isArray(diffEntry.files_changed)) {
147296
147614
  for (const file3 of diffEntry.files_changed) {
147297
147615
  if (typeof file3 === "string") {
147298
- touchedFiles.add(path197.resolve(cwd, file3));
147616
+ touchedFiles.add(path199.resolve(cwd, file3));
147299
147617
  }
147300
147618
  }
147301
147619
  }
@@ -147308,8 +147626,8 @@ function readTouchedFiles(evidenceDir, phase, cwd) {
147308
147626
  }
147309
147627
  function searchFileForKeywords(filePath, keywords, cwd) {
147310
147628
  try {
147311
- const resolvedPath = path197.resolve(filePath);
147312
- const cwdResolved = path197.resolve(cwd);
147629
+ const resolvedPath = path199.resolve(filePath);
147630
+ const cwdResolved = path199.resolve(cwd);
147313
147631
  if (!resolvedPath.startsWith(cwdResolved)) {
147314
147632
  return false;
147315
147633
  }
@@ -147468,7 +147786,7 @@ var req_coverage = createSwarmTool({
147468
147786
  message: "No FR requirements found in spec.md"
147469
147787
  }, null, 2);
147470
147788
  }
147471
- const evidenceDir = path197.join(cwd, EVIDENCE_DIR4);
147789
+ const evidenceDir = path199.join(cwd, EVIDENCE_DIR4);
147472
147790
  const touchedFiles = readTouchedFiles(evidenceDir, phase, cwd);
147473
147791
  const analyzedRequirements = [];
147474
147792
  let coveredCount = 0;
@@ -147494,7 +147812,7 @@ var req_coverage = createSwarmTool({
147494
147812
  requirements: analyzedRequirements
147495
147813
  };
147496
147814
  const reportFilename = `req-coverage-phase-${phase}.json`;
147497
- const reportPath = path197.join(evidenceDir, reportFilename);
147815
+ const reportPath = path199.join(evidenceDir, reportFilename);
147498
147816
  try {
147499
147817
  if (!fs126.existsSync(evidenceDir)) {
147500
147818
  fs126.mkdirSync(evidenceDir, { recursive: true });
@@ -147649,7 +147967,7 @@ init_plan_schema();
147649
147967
  init_qa_gate_profile();
147650
147968
  init_file_locks();
147651
147969
  import * as fs127 from "node:fs";
147652
- import * as path198 from "node:path";
147970
+ import * as path200 from "node:path";
147653
147971
  init_ledger();
147654
147972
  init_manager();
147655
147973
  init_effective_spec();
@@ -147731,8 +148049,8 @@ async function executeSavePlan(args2, fallbackDir) {
147731
148049
  };
147732
148050
  }
147733
148051
  if (args2.working_directory && fallbackDir) {
147734
- const resolvedTarget = path198.resolve(args2.working_directory);
147735
- const resolvedRoot = path198.resolve(fallbackDir);
148052
+ const resolvedTarget = path200.resolve(args2.working_directory);
148053
+ const resolvedRoot = path200.resolve(fallbackDir);
147736
148054
  let fallbackExists = false;
147737
148055
  try {
147738
148056
  fs127.accessSync(resolvedRoot, fs127.constants.F_OK);
@@ -147741,7 +148059,7 @@ async function executeSavePlan(args2, fallbackDir) {
147741
148059
  fallbackExists = false;
147742
148060
  }
147743
148061
  if (fallbackExists) {
147744
- const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path198.sep);
148062
+ const isSubdirectory = resolvedTarget.startsWith(resolvedRoot + path200.sep);
147745
148063
  if (isSubdirectory) {
147746
148064
  return {
147747
148065
  success: false,
@@ -147772,7 +148090,7 @@ async function executeSavePlan(args2, fallbackDir) {
147772
148090
  specHash = spec.hash;
147773
148091
  }
147774
148092
  if (process.env.SWARM_SKIP_GATE_SELECTION !== "1") {
147775
- const contextPath = path198.join(targetWorkspace, ".swarm", "context.md");
148093
+ const contextPath = path200.join(targetWorkspace, ".swarm", "context.md");
147776
148094
  let contextContent = "";
147777
148095
  try {
147778
148096
  contextContent = await fs127.promises.readFile(contextPath, "utf8");
@@ -148062,7 +148380,7 @@ async function executeSavePlan(args2, fallbackDir) {
148062
148380
  }
148063
148381
  await writeCheckpoint(dir).catch(() => {});
148064
148382
  try {
148065
- const markerPath = path198.join(dir, ".swarm", ".plan-write-marker");
148383
+ const markerPath = path200.join(dir, ".swarm", ".plan-write-marker");
148066
148384
  const marker = JSON.stringify({
148067
148385
  source: "save_plan",
148068
148386
  timestamp: new Date().toISOString(),
@@ -148085,7 +148403,7 @@ async function executeSavePlan(args2, fallbackDir) {
148085
148403
  return {
148086
148404
  success: true,
148087
148405
  message: "Plan saved successfully",
148088
- plan_path: path198.join(dir, ".swarm", "plan.json"),
148406
+ plan_path: path200.join(dir, ".swarm", "plan.json"),
148089
148407
  phases_count: plan.phases.length,
148090
148408
  tasks_count: tasksCount,
148091
148409
  ...resolvedProfile !== undefined ? { execution_profile: resolvedProfile } : {},
@@ -148153,7 +148471,7 @@ var save_plan = createSwarmTool({
148153
148471
  init_zod();
148154
148472
  init_manager2();
148155
148473
  import * as fs128 from "node:fs";
148156
- import * as path199 from "node:path";
148474
+ import * as path201 from "node:path";
148157
148475
 
148158
148476
  // src/sbom/detectors/index.ts
148159
148477
  init_utils();
@@ -149003,7 +149321,7 @@ function findManifestFiles(rootDir) {
149003
149321
  try {
149004
149322
  const entries = fs128.readdirSync(dir, { withFileTypes: true });
149005
149323
  for (const entry of entries) {
149006
- const fullPath = path199.join(dir, entry.name);
149324
+ const fullPath = path201.join(dir, entry.name);
149007
149325
  if (entry.name.startsWith(".") || entry.name === "node_modules" || entry.name === "dist" || entry.name === "build" || entry.name === "target") {
149008
149326
  continue;
149009
149327
  }
@@ -149012,7 +149330,7 @@ function findManifestFiles(rootDir) {
149012
149330
  } else if (entry.isFile()) {
149013
149331
  for (const pattern of patterns) {
149014
149332
  if (simpleGlobToRegex(pattern).test(entry.name)) {
149015
- manifestFiles.push(path199.relative(rootDir, fullPath));
149333
+ manifestFiles.push(path201.relative(rootDir, fullPath));
149016
149334
  break;
149017
149335
  }
149018
149336
  }
@@ -149030,11 +149348,11 @@ function findManifestFilesInDirs(directories, workingDir) {
149030
149348
  try {
149031
149349
  const entries = fs128.readdirSync(dir, { withFileTypes: true });
149032
149350
  for (const entry of entries) {
149033
- const fullPath = path199.join(dir, entry.name);
149351
+ const fullPath = path201.join(dir, entry.name);
149034
149352
  if (entry.isFile()) {
149035
149353
  for (const pattern of patterns) {
149036
149354
  if (simpleGlobToRegex(pattern).test(entry.name)) {
149037
- found.push(path199.relative(workingDir, fullPath));
149355
+ found.push(path201.relative(workingDir, fullPath));
149038
149356
  break;
149039
149357
  }
149040
149358
  }
@@ -149047,11 +149365,11 @@ function findManifestFilesInDirs(directories, workingDir) {
149047
149365
  function getDirectoriesFromChangedFiles(changedFiles, workingDir) {
149048
149366
  const dirs = new Set;
149049
149367
  for (const file3 of changedFiles) {
149050
- let currentDir = path199.dirname(file3);
149368
+ let currentDir = path201.dirname(file3);
149051
149369
  while (true) {
149052
- if (currentDir && currentDir !== "." && currentDir !== path199.sep) {
149053
- dirs.add(path199.join(workingDir, currentDir));
149054
- const parent = path199.dirname(currentDir);
149370
+ if (currentDir && currentDir !== "." && currentDir !== path201.sep) {
149371
+ dirs.add(path201.join(workingDir, currentDir));
149372
+ const parent = path201.dirname(currentDir);
149055
149373
  if (parent === currentDir)
149056
149374
  break;
149057
149375
  currentDir = parent;
@@ -149135,7 +149453,7 @@ var sbom_generate = createSwarmTool({
149135
149453
  const changedFiles = obj.changed_files;
149136
149454
  const relativeOutputDir = obj.output_dir || DEFAULT_OUTPUT_DIR;
149137
149455
  const workingDir = directory;
149138
- const outputDir = path199.isAbsolute(relativeOutputDir) ? relativeOutputDir : path199.join(workingDir, relativeOutputDir);
149456
+ const outputDir = path201.isAbsolute(relativeOutputDir) ? relativeOutputDir : path201.join(workingDir, relativeOutputDir);
149139
149457
  let manifestFiles = [];
149140
149458
  if (scope === "all") {
149141
149459
  manifestFiles = findManifestFiles(workingDir);
@@ -149158,7 +149476,7 @@ var sbom_generate = createSwarmTool({
149158
149476
  const processedFiles = [];
149159
149477
  for (const manifestFile of manifestFiles) {
149160
149478
  try {
149161
- const fullPath = path199.isAbsolute(manifestFile) ? manifestFile : path199.join(workingDir, manifestFile);
149479
+ const fullPath = path201.isAbsolute(manifestFile) ? manifestFile : path201.join(workingDir, manifestFile);
149162
149480
  if (!fs128.existsSync(fullPath)) {
149163
149481
  continue;
149164
149482
  }
@@ -149175,7 +149493,7 @@ var sbom_generate = createSwarmTool({
149175
149493
  const bom = generateCycloneDX(allComponents);
149176
149494
  const bomJson = serializeCycloneDX(bom);
149177
149495
  const filename = generateSbomFilename();
149178
- const outputPath = path199.join(outputDir, filename);
149496
+ const outputPath = path201.join(outputDir, filename);
149179
149497
  fs128.writeFileSync(outputPath, bomJson, "utf-8");
149180
149498
  const verdict = processedFiles.length > 0 ? "pass" : "pass";
149181
149499
  try {
@@ -149220,7 +149538,7 @@ var sbom_generate = createSwarmTool({
149220
149538
  init_zod();
149221
149539
  init_create_tool();
149222
149540
  import * as fs129 from "node:fs";
149223
- import * as path200 from "node:path";
149541
+ import * as path202 from "node:path";
149224
149542
  var SPEC_CANDIDATES = [
149225
149543
  "openapi.json",
149226
149544
  "openapi.yaml",
@@ -149252,12 +149570,12 @@ function normalizePath5(p) {
149252
149570
  }
149253
149571
  function discoverSpecFile(cwd, specFileArg) {
149254
149572
  if (specFileArg) {
149255
- const resolvedPath = path200.resolve(cwd, specFileArg);
149256
- const normalizedCwd = cwd.endsWith(path200.sep) ? cwd : cwd + path200.sep;
149573
+ const resolvedPath = path202.resolve(cwd, specFileArg);
149574
+ const normalizedCwd = cwd.endsWith(path202.sep) ? cwd : cwd + path202.sep;
149257
149575
  if (!resolvedPath.startsWith(normalizedCwd) && resolvedPath !== cwd) {
149258
149576
  throw new Error("Invalid spec_file: path traversal detected");
149259
149577
  }
149260
- const ext = path200.extname(resolvedPath).toLowerCase();
149578
+ const ext = path202.extname(resolvedPath).toLowerCase();
149261
149579
  if (!ALLOWED_EXTENSIONS.includes(ext)) {
149262
149580
  throw new Error(`Invalid spec_file: must end in .json, .yaml, or .yml, got ${ext}`);
149263
149581
  }
@@ -149271,7 +149589,7 @@ function discoverSpecFile(cwd, specFileArg) {
149271
149589
  return resolvedPath;
149272
149590
  }
149273
149591
  for (const candidate of SPEC_CANDIDATES) {
149274
- const candidatePath = path200.resolve(cwd, candidate);
149592
+ const candidatePath = path202.resolve(cwd, candidate);
149275
149593
  if (fs129.existsSync(candidatePath)) {
149276
149594
  const stats2 = fs129.statSync(candidatePath);
149277
149595
  if (stats2.size <= MAX_SPEC_SIZE) {
@@ -149283,7 +149601,7 @@ function discoverSpecFile(cwd, specFileArg) {
149283
149601
  }
149284
149602
  function parseSpec(specFile) {
149285
149603
  const content = fs129.readFileSync(specFile, "utf-8");
149286
- const ext = path200.extname(specFile).toLowerCase();
149604
+ const ext = path202.extname(specFile).toLowerCase();
149287
149605
  if (ext === ".json") {
149288
149606
  return parseJsonSpec(content);
149289
149607
  }
@@ -149359,7 +149677,7 @@ function extractRoutes2(cwd) {
149359
149677
  return;
149360
149678
  }
149361
149679
  for (const entry of entries) {
149362
- const fullPath = path200.join(dir, entry.name);
149680
+ const fullPath = path202.join(dir, entry.name);
149363
149681
  if (entry.isSymbolicLink()) {
149364
149682
  continue;
149365
149683
  }
@@ -149369,7 +149687,7 @@ function extractRoutes2(cwd) {
149369
149687
  }
149370
149688
  walkDir2(fullPath);
149371
149689
  } else if (entry.isFile()) {
149372
- const ext = path200.extname(entry.name).toLowerCase();
149690
+ const ext = path202.extname(entry.name).toLowerCase();
149373
149691
  const baseName = entry.name.toLowerCase();
149374
149692
  if (![".ts", ".js", ".mjs"].includes(ext)) {
149375
149693
  continue;
@@ -149538,7 +149856,7 @@ init_bun_compat();
149538
149856
  init_path_security();
149539
149857
  init_create_tool();
149540
149858
  import * as fs130 from "node:fs";
149541
- import * as path201 from "node:path";
149859
+ import * as path203 from "node:path";
149542
149860
  var DEFAULT_MAX_RESULTS = 100;
149543
149861
  var DEFAULT_MAX_LINES = 200;
149544
149862
  var REGEX_TIMEOUT_MS = 5000;
@@ -149574,11 +149892,11 @@ function containsWindowsAttacks4(str) {
149574
149892
  }
149575
149893
  function isPathInWorkspace3(filePath, workspace) {
149576
149894
  try {
149577
- const resolvedPath = path201.resolve(workspace, filePath);
149895
+ const resolvedPath = path203.resolve(workspace, filePath);
149578
149896
  const realWorkspace = fs130.realpathSync(workspace);
149579
149897
  const realResolvedPath = fs130.realpathSync(resolvedPath);
149580
- const relativePath = path201.relative(realWorkspace, realResolvedPath);
149581
- if (relativePath.startsWith("..") || path201.isAbsolute(relativePath)) {
149898
+ const relativePath = path203.relative(realWorkspace, realResolvedPath);
149899
+ if (relativePath.startsWith("..") || path203.isAbsolute(relativePath)) {
149582
149900
  return false;
149583
149901
  }
149584
149902
  return true;
@@ -149591,11 +149909,11 @@ function validatePathForRead2(filePath, workspace) {
149591
149909
  }
149592
149910
  function findRgInEnvPath() {
149593
149911
  const searchPath = process.env.PATH ?? "";
149594
- for (const dir of searchPath.split(path201.delimiter)) {
149912
+ for (const dir of searchPath.split(path203.delimiter)) {
149595
149913
  if (!dir)
149596
149914
  continue;
149597
149915
  const isWindows = process.platform === "win32";
149598
- const candidate = path201.join(dir, isWindows ? "rg.exe" : "rg");
149916
+ const candidate = path203.join(dir, isWindows ? "rg.exe" : "rg");
149599
149917
  if (fs130.existsSync(candidate))
149600
149918
  return candidate;
149601
149919
  }
@@ -149725,8 +150043,8 @@ function collectFiles(dir, workspace, includeGlobs, excludeGlobs) {
149725
150043
  try {
149726
150044
  const entries = fs130.readdirSync(dir, { withFileTypes: true });
149727
150045
  for (const entry of entries) {
149728
- const fullPath = path201.join(dir, entry.name);
149729
- const relativePath = path201.relative(workspace, fullPath);
150046
+ const fullPath = path203.join(dir, entry.name);
150047
+ const relativePath = path203.relative(workspace, fullPath);
149730
150048
  if (!validatePathForRead2(fullPath, workspace)) {
149731
150049
  continue;
149732
150050
  }
@@ -149767,7 +150085,7 @@ async function fallbackSearch(opts) {
149767
150085
  const matches = [];
149768
150086
  let total = 0;
149769
150087
  for (const file3 of files) {
149770
- const fullPath = path201.join(opts.workspace, file3);
150088
+ const fullPath = path203.join(opts.workspace, file3);
149771
150089
  if (!validatePathForRead2(fullPath, opts.workspace)) {
149772
150090
  continue;
149773
150091
  }
@@ -150199,7 +150517,7 @@ init_config();
150199
150517
  init_schema();
150200
150518
  init_create_tool();
150201
150519
  import { mkdir as mkdir34, rename as rename14, writeFile as writeFile23 } from "node:fs/promises";
150202
- import * as path202 from "node:path";
150520
+ import * as path204 from "node:path";
150203
150521
  var MAX_SPEC_BYTES2 = 256 * 1024;
150204
150522
  var spec_write = createSwarmTool({
150205
150523
  description: "Write the canonical project spec to .swarm/spec.md. Atomic write, size-bounded (256 KiB), heading-required. Honors spec_writer.allow_spec_write.",
@@ -150240,8 +150558,8 @@ var spec_write = createSwarmTool({
150240
150558
  reason: 'spec must contain at least one top-level "# Heading"'
150241
150559
  }, null, 2);
150242
150560
  }
150243
- const target = path202.join(directory, ".swarm", "spec.md");
150244
- await mkdir34(path202.dirname(target), { recursive: true });
150561
+ const target = path204.join(directory, ".swarm", "spec.md");
150562
+ await mkdir34(path204.dirname(target), { recursive: true });
150245
150563
  const tmp = `${target}.tmp-${process.pid}-${Date.now()}`;
150246
150564
  let finalContent = content;
150247
150565
  if (mode === "append") {
@@ -150266,6 +150584,120 @@ ${content}
150266
150584
  }
150267
150585
  });
150268
150586
 
150587
+ // src/tools/stale-reconciliation.ts
150588
+ init_zod();
150589
+ init_knowledge_store();
150590
+ init_skill_generator();
150591
+ init_create_tool();
150592
+ import { existsSync as existsSync115 } from "node:fs";
150593
+ import { readdir as readdir12, readFile as readFile33 } from "node:fs/promises";
150594
+ import { join as join163 } from "node:path";
150595
+ var run_stale_reconciliation = createSwarmTool({
150596
+ description: "Reconcile skills against the knowledge store. clear=false: mark skills stale when source knowledge is archived or deleted. clear=true: clear stale.marker on affected active skills (proposal files under .swarm/skills/proposals are scanned but not modified — they are drafts, not yet active skills).",
150597
+ args: {
150598
+ clear: exports_external.boolean().optional().default(false).describe("If true, clear stale markers for affected skills. If false (default), mark affected skills stale.")
150599
+ },
150600
+ execute: async (args2, directory) => {
150601
+ if (typeof directory !== "string" || !directory) {
150602
+ return JSON.stringify({ found: 0, skills: [] }, null, 2);
150603
+ }
150604
+ const archivedIds = await _internals116.getArchivedKnowledgeIds(directory);
150605
+ const archivedSet = new Set(archivedIds);
150606
+ const allKnownIds = new Set;
150607
+ const swarmPath = _internals116.resolveSwarmKnowledgePath(directory);
150608
+ const hivePath = _internals116.resolveHiveKnowledgePath();
150609
+ try {
150610
+ const swarmEntries = await _internals116.readKnowledge(swarmPath);
150611
+ for (const e of swarmEntries)
150612
+ allKnownIds.add(e.id);
150613
+ } catch {}
150614
+ try {
150615
+ const hiveEntries = await _internals116.readKnowledge(hivePath);
150616
+ for (const e of hiveEntries)
150617
+ allKnownIds.add(e.id);
150618
+ } catch {}
150619
+ const skillEntries = [];
150620
+ for (const dir of [
150621
+ join163(directory, ".opencode", "skills", "generated"),
150622
+ join163(directory, ".swarm", "skills", "proposals")
150623
+ ]) {
150624
+ if (!_internals116.existsSync(dir))
150625
+ continue;
150626
+ const entries = await _internals116.readdir(dir, { withFileTypes: true });
150627
+ for (const entry of entries) {
150628
+ if (entry.isDirectory()) {
150629
+ skillEntries.push({
150630
+ slug: entry.name,
150631
+ path: join163(dir, entry.name),
150632
+ isProposal: false
150633
+ });
150634
+ } else if (entry.name.endsWith(".md")) {
150635
+ const slug = entry.name.replace(/\.md$/, "");
150636
+ skillEntries.push({
150637
+ slug,
150638
+ path: join163(dir, entry.name),
150639
+ isProposal: true
150640
+ });
150641
+ }
150642
+ }
150643
+ }
150644
+ const results = [];
150645
+ for (const { slug, path: path205, isProposal } of skillEntries) {
150646
+ const skillMdPath = isProposal ? path205 : join163(path205, "SKILL.md");
150647
+ if (!_internals116.existsSync(skillMdPath))
150648
+ continue;
150649
+ const content = await _internals116.readFile(skillMdPath, "utf-8");
150650
+ const fm = _internals116.parseDraftFrontmatter(content);
150651
+ const sourceIds = fm?.sourceKnowledgeIds ?? [];
150652
+ if (sourceIds.length === 0)
150653
+ continue;
150654
+ const affected = sourceIds.filter((id) => archivedSet.has(id) || !allKnownIds.has(id));
150655
+ if (affected.length === 0)
150656
+ continue;
150657
+ if (args2.clear) {
150658
+ if (!isProposal) {
150659
+ const markerPath = join163(path205, "stale.marker");
150660
+ if (_internals116.existsSync(markerPath)) {
150661
+ try {
150662
+ await _internals116.clearSkillStale(path205);
150663
+ results.push({
150664
+ slug,
150665
+ reason: affected.join(", "),
150666
+ action: "cleared"
150667
+ });
150668
+ } catch {}
150669
+ }
150670
+ }
150671
+ } else {
150672
+ if (!isProposal) {
150673
+ try {
150674
+ await _internals116.retireOrMarkStale(directory, path205, archivedSet);
150675
+ results.push({
150676
+ slug,
150677
+ reason: affected.join(", "),
150678
+ action: "marked_stale"
150679
+ });
150680
+ } catch {}
150681
+ }
150682
+ }
150683
+ }
150684
+ return JSON.stringify({ found: results.length, skills: results }, null, 2);
150685
+ }
150686
+ });
150687
+ var _internals116 = {
150688
+ run_stale_reconciliation,
150689
+ clearSkillStale,
150690
+ retireOrMarkStale,
150691
+ parseDraftFrontmatter,
150692
+ getArchivedKnowledgeIds,
150693
+ readKnowledge,
150694
+ resolveSwarmKnowledgePath,
150695
+ resolveHiveKnowledgePath,
150696
+ readdir: readdir12,
150697
+ readFile: readFile33,
150698
+ existsSync: existsSync115
150699
+ };
150700
+
150269
150701
  // src/tools/submit-phase-council-verdicts.ts
150270
150702
  init_zod();
150271
150703
  init_loader();
@@ -150277,7 +150709,7 @@ import {
150277
150709
  unlinkSync as unlinkSync29,
150278
150710
  writeFileSync as writeFileSync36
150279
150711
  } from "node:fs";
150280
- import path203 from "node:path";
150712
+ import path205 from "node:path";
150281
150713
  init_create_tool();
150282
150714
  init_resolve_working_directory();
150283
150715
  var VerdictSchema2 = exports_external.object({
@@ -150444,7 +150876,7 @@ var submit_phase_council_verdicts = createSwarmTool({
150444
150876
  }
150445
150877
  });
150446
150878
  function getPhaseMutationGapFinding(phaseNumber, workingDir) {
150447
- const mutationGatePath = path203.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
150879
+ const mutationGatePath = path205.join(workingDir, ".swarm", "evidence", String(phaseNumber), "mutation-gate.json");
150448
150880
  try {
150449
150881
  const raw = readFileSync90(mutationGatePath, "utf-8");
150450
150882
  const parsed = JSON.parse(raw);
@@ -150506,9 +150938,9 @@ function getPhaseMutationGapFinding(phaseNumber, workingDir) {
150506
150938
  }
150507
150939
  }
150508
150940
  function writePhaseCouncilEvidence(workingDir, synthesis, provenance) {
150509
- const evidenceDir = path203.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
150941
+ const evidenceDir = path205.join(workingDir, ".swarm", "evidence", String(synthesis.phaseNumber));
150510
150942
  mkdirSync51(evidenceDir, { recursive: true });
150511
- const evidenceFile = path203.join(evidenceDir, "phase-council.json");
150943
+ const evidenceFile = path205.join(evidenceDir, "phase-council.json");
150512
150944
  const evidenceBundle = {
150513
150945
  entries: [
150514
150946
  {
@@ -150571,7 +151003,7 @@ init_zod();
150571
151003
  init_path_security();
150572
151004
  init_create_tool();
150573
151005
  import * as fs131 from "node:fs";
150574
- import * as path204 from "node:path";
151006
+ import * as path206 from "node:path";
150575
151007
  var BINARY_EXTENSIONS2 = new Set([
150576
151008
  ".png",
150577
151009
  ".jpg",
@@ -150607,14 +151039,14 @@ function containsWindowsAttacks5(str) {
150607
151039
  }
150608
151040
  function isPathInWorkspace4(filePath, workspace) {
150609
151041
  try {
150610
- const resolvedPath = path204.resolve(workspace, filePath);
151042
+ const resolvedPath = path206.resolve(workspace, filePath);
150611
151043
  if (!fs131.existsSync(resolvedPath)) {
150612
151044
  return true;
150613
151045
  }
150614
151046
  const realWorkspace = fs131.realpathSync(workspace);
150615
151047
  const realResolvedPath = fs131.realpathSync(resolvedPath);
150616
- const relativePath = path204.relative(realWorkspace, realResolvedPath);
150617
- if (relativePath.startsWith("..") || path204.isAbsolute(relativePath)) {
151048
+ const relativePath = path206.relative(realWorkspace, realResolvedPath);
151049
+ if (relativePath.startsWith("..") || path206.isAbsolute(relativePath)) {
150618
151050
  return false;
150619
151051
  }
150620
151052
  return true;
@@ -150729,7 +151161,7 @@ function arraysEqual2(a, b) {
150729
151161
  return true;
150730
151162
  }
150731
151163
  function isBinaryFile4(filePath) {
150732
- const ext = path204.extname(filePath).toLowerCase();
151164
+ const ext = path206.extname(filePath).toLowerCase();
150733
151165
  return BINARY_EXTENSIONS2.has(ext);
150734
151166
  }
150735
151167
  function splitDiffLines(content) {
@@ -150934,7 +151366,7 @@ var suggestPatch = createSwarmTool({
150934
151366
  });
150935
151367
  continue;
150936
151368
  }
150937
- const fullPath = path204.resolve(directory, change.file);
151369
+ const fullPath = path206.resolve(directory, change.file);
150938
151370
  if (!fs131.existsSync(fullPath)) {
150939
151371
  errors5.push({
150940
151372
  success: false,
@@ -151029,7 +151461,7 @@ var suggestPatch = createSwarmTool({
151029
151461
  const unifiedParts = [];
151030
151462
  for (const [file3, entries] of fileGroups) {
151031
151463
  entries.sort((a, b) => a.contextMatch.startLineIndex - b.contextMatch.startLineIndex);
151032
- const entryFullPath = path204.resolve(directory, file3);
151464
+ const entryFullPath = path206.resolve(directory, file3);
151033
151465
  let entryContent;
151034
151466
  try {
151035
151467
  entryContent = fs131.readFileSync(entryFullPath, "utf-8");
@@ -151230,7 +151662,7 @@ var swarm_memory_propose = createSwarmTool({
151230
151662
  evidenceRefs: exports_external.array(exports_external.string().min(1).max(500)).max(20).optional().describe("Evidence refs such as files, commits, test outputs, or URLs")
151231
151663
  },
151232
151664
  execute: async (args2, directory, ctx) => {
151233
- const { config: config3 } = _internals116.loadPluginConfigWithMeta(directory);
151665
+ const { config: config3 } = _internals117.loadPluginConfigWithMeta(directory);
151234
151666
  if (config3.memory?.enabled !== true) {
151235
151667
  return JSON.stringify({
151236
151668
  success: false,
@@ -151246,7 +151678,7 @@ var swarm_memory_propose = createSwarmTool({
151246
151678
  });
151247
151679
  }
151248
151680
  const agent = getContextAgent3(ctx);
151249
- const gateway = _internals116.createMemoryGateway({
151681
+ const gateway = _internals117.createMemoryGateway({
151250
151682
  directory,
151251
151683
  sessionID: ctx?.sessionID,
151252
151684
  agentRole: agent,
@@ -151271,7 +151703,7 @@ var swarm_memory_propose = createSwarmTool({
151271
151703
  }
151272
151704
  }
151273
151705
  });
151274
- var _internals116 = {
151706
+ var _internals117 = {
151275
151707
  loadPluginConfigWithMeta,
151276
151708
  createMemoryGateway
151277
151709
  };
@@ -151309,7 +151741,7 @@ var swarm_memory_recall = createSwarmTool({
151309
151741
  maxItems: exports_external.number().int().min(1).max(20).optional().describe("Maximum memories to return")
151310
151742
  },
151311
151743
  execute: async (args2, directory, ctx) => {
151312
- const { config: config3 } = _internals117.loadPluginConfigWithMeta(directory);
151744
+ const { config: config3 } = _internals118.loadPluginConfigWithMeta(directory);
151313
151745
  if (config3.memory?.enabled !== true) {
151314
151746
  return JSON.stringify({
151315
151747
  success: false,
@@ -151325,7 +151757,7 @@ var swarm_memory_recall = createSwarmTool({
151325
151757
  });
151326
151758
  }
151327
151759
  const agent = getContextAgent4(ctx);
151328
- const gateway = _internals117.createMemoryGateway({
151760
+ const gateway = _internals118.createMemoryGateway({
151329
151761
  directory,
151330
151762
  sessionID: ctx?.sessionID,
151331
151763
  agentRole: agent,
@@ -151358,7 +151790,7 @@ var RecallArgsSchema = exports_external.object({
151358
151790
  kinds: exports_external.array(exports_external.enum(MEMORY_KINDS2)).optional(),
151359
151791
  maxItems: exports_external.number().int().min(1).max(20).optional()
151360
151792
  });
151361
- var _internals117 = {
151793
+ var _internals118 = {
151362
151794
  loadPluginConfigWithMeta,
151363
151795
  createMemoryGateway
151364
151796
  };
@@ -151371,7 +151803,7 @@ function getContextAgent4(ctx) {
151371
151803
 
151372
151804
  // src/tools/syntax-check.ts
151373
151805
  import * as fs132 from "node:fs";
151374
- import * as path205 from "node:path";
151806
+ import * as path207 from "node:path";
151375
151807
  init_zod();
151376
151808
  init_manager2();
151377
151809
  init_detector();
@@ -151443,7 +151875,7 @@ async function syntaxCheck(input, directory, config3) {
151443
151875
  if (languages?.length) {
151444
151876
  const lowerLangs = languages.map((l) => l.toLowerCase());
151445
151877
  filesToCheck = filesToCheck.filter((file3) => {
151446
- const ext = path205.extname(file3.path).toLowerCase();
151878
+ const ext = path207.extname(file3.path).toLowerCase();
151447
151879
  const langDef = getLanguageForExtension(ext);
151448
151880
  const fileProfile = getProfileForFile(file3.path);
151449
151881
  const langId = fileProfile?.id || langDef?.id;
@@ -151453,7 +151885,7 @@ async function syntaxCheck(input, directory, config3) {
151453
151885
  const { loadGrammar: loadGrammar2 } = await Promise.resolve().then(() => (init_runtime(), exports_runtime));
151454
151886
  async function checkOneFile(fileInfo) {
151455
151887
  const { path: filePath } = fileInfo;
151456
- const fullPath = path205.isAbsolute(filePath) ? filePath : path205.join(directory, filePath);
151888
+ const fullPath = path207.isAbsolute(filePath) ? filePath : path207.join(directory, filePath);
151457
151889
  const result = {
151458
151890
  path: filePath,
151459
151891
  language: "",
@@ -151500,7 +151932,7 @@ async function syntaxCheck(input, directory, config3) {
151500
151932
  result.skipped_reason = "binary_file";
151501
151933
  return { result, counted: false, failed: false, skipped: true };
151502
151934
  }
151503
- const ext = path205.extname(filePath).toLowerCase();
151935
+ const ext = path207.extname(filePath).toLowerCase();
151504
151936
  const langDef = getLanguageForExtension(ext);
151505
151937
  result.language = profile?.id || langDef?.id || "unknown";
151506
151938
  const errors5 = extractSyntaxErrors(parser, content);
@@ -151612,7 +152044,7 @@ init_utils();
151612
152044
  init_create_tool();
151613
152045
  init_path_security();
151614
152046
  import * as fs133 from "node:fs";
151615
- import * as path206 from "node:path";
152047
+ import * as path208 from "node:path";
151616
152048
  var MAX_TEXT_LENGTH = 200;
151617
152049
  var MAX_FILE_SIZE_BYTES10 = 1024 * 1024;
151618
152050
  var SUPPORTED_EXTENSIONS4 = new Set([
@@ -151678,9 +152110,9 @@ function validatePathsInput(paths, cwd) {
151678
152110
  return { error: "paths contains path traversal", resolvedPath: null };
151679
152111
  }
151680
152112
  try {
151681
- const resolvedPath = path206.resolve(paths);
151682
- const normalizedCwd = path206.resolve(cwd);
151683
- const normalizedResolved = path206.resolve(resolvedPath);
152113
+ const resolvedPath = path208.resolve(paths);
152114
+ const normalizedCwd = path208.resolve(cwd);
152115
+ const normalizedResolved = path208.resolve(resolvedPath);
151684
152116
  if (!normalizedResolved.startsWith(normalizedCwd)) {
151685
152117
  return {
151686
152118
  error: "paths must be within the current working directory",
@@ -151696,7 +152128,7 @@ function validatePathsInput(paths, cwd) {
151696
152128
  }
151697
152129
  }
151698
152130
  function isSupportedExtension(filePath) {
151699
- const ext = path206.extname(filePath).toLowerCase();
152131
+ const ext = path208.extname(filePath).toLowerCase();
151700
152132
  return SUPPORTED_EXTENSIONS4.has(ext);
151701
152133
  }
151702
152134
  function findSourceFiles3(dir, files = []) {
@@ -151711,7 +152143,7 @@ function findSourceFiles3(dir, files = []) {
151711
152143
  if (SKIP_DIRECTORIES6.has(entry)) {
151712
152144
  continue;
151713
152145
  }
151714
- const fullPath = path206.join(dir, entry);
152146
+ const fullPath = path208.join(dir, entry);
151715
152147
  let stat14;
151716
152148
  try {
151717
152149
  stat14 = fs133.statSync(fullPath);
@@ -151823,7 +152255,7 @@ var todo_extract = createSwarmTool({
151823
152255
  filesToScan.push(scanPath);
151824
152256
  } else {
151825
152257
  const errorResult = {
151826
- error: `unsupported file extension: ${path206.extname(scanPath)}`,
152258
+ error: `unsupported file extension: ${path208.extname(scanPath)}`,
151827
152259
  total: 0,
151828
152260
  byPriority: { high: 0, medium: 0, low: 0 },
151829
152261
  entries: []
@@ -151873,18 +152305,18 @@ init_schema();
151873
152305
  init_qa_gate_profile();
151874
152306
  init_gate_evidence();
151875
152307
  import * as fs137 from "node:fs";
151876
- import * as path210 from "node:path";
152308
+ import * as path212 from "node:path";
151877
152309
 
151878
152310
  // src/hooks/diff-scope.ts
151879
152311
  init_bun_compat();
151880
152312
  import * as fs135 from "node:fs";
151881
- import * as path208 from "node:path";
152313
+ import * as path210 from "node:path";
151882
152314
 
151883
152315
  // src/utils/gitignore-warning.ts
151884
152316
  init_bun_compat();
151885
152317
  import * as fs134 from "node:fs";
151886
- import * as path207 from "node:path";
151887
- var _internals118 = { bunSpawn };
152318
+ import * as path209 from "node:path";
152319
+ var _internals119 = { bunSpawn };
151888
152320
  var _swarmGitExcludedChecked = false;
151889
152321
  function fileCoversSwarm(content) {
151890
152322
  for (const rawLine of content.split(`
@@ -151917,7 +152349,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
151917
152349
  checkIgnoreExitCode
151918
152350
  ] = await Promise.all([
151919
152351
  (async () => {
151920
- const proc = _internals118.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
152352
+ const proc = _internals119.bunSpawn(["git", "-C", directory, "rev-parse", "--show-toplevel"], GIT_SPAWN_OPTIONS);
151921
152353
  try {
151922
152354
  return await Promise.all([proc.exited, proc.stdout.text()]);
151923
152355
  } finally {
@@ -151927,7 +152359,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
151927
152359
  }
151928
152360
  })(),
151929
152361
  (async () => {
151930
- const proc = _internals118.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
152362
+ const proc = _internals119.bunSpawn(["git", "-C", directory, "rev-parse", "--git-path", "info/exclude"], GIT_SPAWN_OPTIONS);
151931
152363
  try {
151932
152364
  return await Promise.all([proc.exited, proc.stdout.text()]);
151933
152365
  } finally {
@@ -151937,7 +152369,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
151937
152369
  }
151938
152370
  })(),
151939
152371
  (async () => {
151940
- const proc = _internals118.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
152372
+ const proc = _internals119.bunSpawn(["git", "-C", directory, "check-ignore", "-q", ".swarm/.gitkeep"], GIT_SPAWN_OPTIONS);
151941
152373
  try {
151942
152374
  return await proc.exited;
151943
152375
  } finally {
@@ -151957,10 +152389,10 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
151957
152389
  const excludeRelPath = excludePathRaw.trim();
151958
152390
  if (!excludeRelPath)
151959
152391
  return;
151960
- const excludePath = path207.isAbsolute(excludeRelPath) ? excludeRelPath : path207.join(directory, excludeRelPath);
152392
+ const excludePath = path209.isAbsolute(excludeRelPath) ? excludeRelPath : path209.join(directory, excludeRelPath);
151961
152393
  if (checkIgnoreExitCode !== 0) {
151962
152394
  try {
151963
- fs134.mkdirSync(path207.dirname(excludePath), { recursive: true });
152395
+ fs134.mkdirSync(path209.dirname(excludePath), { recursive: true });
151964
152396
  let existing = "";
151965
152397
  try {
151966
152398
  existing = fs134.readFileSync(excludePath, "utf8");
@@ -151976,7 +152408,7 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
151976
152408
  }
151977
152409
  } catch {}
151978
152410
  }
151979
- const trackedProc = _internals118.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
152411
+ const trackedProc = _internals119.bunSpawn(["git", "-C", directory, "ls-files", "--", ".swarm"], GIT_SPAWN_OPTIONS);
151980
152412
  let trackedExitCode;
151981
152413
  let trackedOutput;
151982
152414
  try {
@@ -152001,10 +152433,10 @@ async function ensureSwarmGitExcluded(directory, options = {}) {
152001
152433
  }
152002
152434
 
152003
152435
  // src/hooks/diff-scope.ts
152004
- var _internals119 = { bunSpawn };
152436
+ var _internals120 = { bunSpawn };
152005
152437
  function getDeclaredScope(taskId, directory) {
152006
152438
  try {
152007
- const planPath = path208.join(directory, ".swarm", "plan.json");
152439
+ const planPath = path210.join(directory, ".swarm", "plan.json");
152008
152440
  if (!fs135.existsSync(planPath))
152009
152441
  return null;
152010
152442
  const raw = fs135.readFileSync(planPath, "utf-8");
@@ -152036,7 +152468,7 @@ var GIT_DIFF_SPAWN_OPTIONS = {
152036
152468
  };
152037
152469
  async function getChangedFiles2(directory) {
152038
152470
  try {
152039
- const proc = _internals119.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
152471
+ const proc = _internals120.bunSpawn(["git", "diff", "--name-only", "HEAD~1"], {
152040
152472
  cwd: directory,
152041
152473
  ...GIT_DIFF_SPAWN_OPTIONS
152042
152474
  });
@@ -152053,7 +152485,7 @@ async function getChangedFiles2(directory) {
152053
152485
  return stdout.trim().split(`
152054
152486
  `).map((f) => f.trim()).filter((f) => f.length > 0);
152055
152487
  }
152056
- const proc2 = _internals119.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
152488
+ const proc2 = _internals120.bunSpawn(["git", "diff", "--name-only", "HEAD"], {
152057
152489
  cwd: directory,
152058
152490
  ...GIT_DIFF_SPAWN_OPTIONS
152059
152491
  });
@@ -152110,8 +152542,8 @@ init_telemetry();
152110
152542
  // src/turbo/lean/task-completion.ts
152111
152543
  init_file_locks();
152112
152544
  import * as fs136 from "node:fs";
152113
- import * as path209 from "node:path";
152114
- var _internals120 = {
152545
+ import * as path211 from "node:path";
152546
+ var _internals121 = {
152115
152547
  listActiveLocks,
152116
152548
  verifyLeanTurboTaskCompletion
152117
152549
  };
@@ -152129,7 +152561,7 @@ var TIER_3_PATTERNS = [
152129
152561
  ];
152130
152562
  function matchesTier3Pattern(files) {
152131
152563
  for (const file3 of files) {
152132
- const fileName = path209.basename(file3);
152564
+ const fileName = path211.basename(file3);
152133
152565
  for (const pattern of TIER_3_PATTERNS) {
152134
152566
  if (pattern.test(fileName)) {
152135
152567
  return true;
@@ -152141,7 +152573,7 @@ function matchesTier3Pattern(files) {
152141
152573
  function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
152142
152574
  let persisted = null;
152143
152575
  try {
152144
- const statePath = path209.join(directory, ".swarm", "turbo-state.json");
152576
+ const statePath = path211.join(directory, ".swarm", "turbo-state.json");
152145
152577
  if (!fs136.existsSync(statePath)) {
152146
152578
  return {
152147
152579
  ok: false,
@@ -152225,11 +152657,11 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
152225
152657
  };
152226
152658
  }
152227
152659
  const phase = runState.phase ?? 0;
152228
- const evidencePath = path209.join(directory, ".swarm", "evidence", String(phase), "lean-turbo", `${lane.laneId}.json`);
152229
- const expectedDir = path209.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
152230
- const resolvedPath = path209.resolve(evidencePath);
152231
- const resolvedDir = path209.resolve(expectedDir);
152232
- if (!resolvedPath.startsWith(resolvedDir + path209.sep) && resolvedPath !== resolvedDir) {
152660
+ const evidencePath = path211.join(directory, ".swarm", "evidence", String(phase), "lean-turbo", `${lane.laneId}.json`);
152661
+ const expectedDir = path211.join(directory, ".swarm", "evidence", String(phase), "lean-turbo");
152662
+ const resolvedPath = path211.resolve(evidencePath);
152663
+ const resolvedDir = path211.resolve(expectedDir);
152664
+ if (!resolvedPath.startsWith(resolvedDir + path211.sep) && resolvedPath !== resolvedDir) {
152233
152665
  return {
152234
152666
  ok: false,
152235
152667
  reason: `Lane ID causes path traversal: ${lane.laneId}`,
@@ -152253,7 +152685,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
152253
152685
  }
152254
152686
  };
152255
152687
  }
152256
- const activeLocks = _internals120.listActiveLocks(directory);
152688
+ const activeLocks = _internals121.listActiveLocks(directory);
152257
152689
  const laneLocks = activeLocks.filter((lock) => lock.laneId === lane.laneId);
152258
152690
  if (laneLocks.length > 0) {
152259
152691
  return {
@@ -152269,7 +152701,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
152269
152701
  }
152270
152702
  let filesTouched = [];
152271
152703
  try {
152272
- const planPath = path209.join(directory, ".swarm", "plan.json");
152704
+ const planPath = path211.join(directory, ".swarm", "plan.json");
152273
152705
  const planRaw = fs136.readFileSync(planPath, "utf-8");
152274
152706
  const plan = JSON.parse(planRaw);
152275
152707
  for (const planPhase of plan.phases ?? []) {
@@ -152320,7 +152752,7 @@ function verifyLeanTurboTaskCompletion(directory, taskId, sessionID) {
152320
152752
  init_task_id();
152321
152753
  init_create_tool();
152322
152754
  init_resolve_working_directory();
152323
- var _internals121 = {
152755
+ var _internals122 = {
152324
152756
  tryAcquireLock,
152325
152757
  updateTaskStatus,
152326
152758
  resolveWorkingDirectory
@@ -152358,7 +152790,7 @@ var TIER_3_PATTERNS2 = [
152358
152790
  ];
152359
152791
  function matchesTier3Pattern2(files) {
152360
152792
  for (const file3 of files) {
152361
- const fileName = path210.basename(file3);
152793
+ const fileName = path212.basename(file3);
152362
152794
  for (const pattern of TIER_3_PATTERNS2) {
152363
152795
  if (pattern.test(fileName)) {
152364
152796
  return true;
@@ -152397,7 +152829,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
152397
152829
  if (!skipStandardTurboBypass && hasActiveTurboMode()) {
152398
152830
  const resolvedDir2 = workingDirectory;
152399
152831
  try {
152400
- const planPath = path210.join(resolvedDir2, ".swarm", "plan.json");
152832
+ const planPath = path212.join(resolvedDir2, ".swarm", "plan.json");
152401
152833
  const planRaw = fs137.readFileSync(planPath, "utf-8");
152402
152834
  const plan = JSON.parse(planRaw);
152403
152835
  for (const planPhase of plan.phases ?? []) {
@@ -152417,7 +152849,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
152417
152849
  }
152418
152850
  let resolvedDir;
152419
152851
  if (fallbackDir) {
152420
- const resolveResult = _internals121.resolveWorkingDirectory(workingDirectory, fallbackDir);
152852
+ const resolveResult = _internals122.resolveWorkingDirectory(workingDirectory, fallbackDir);
152421
152853
  if (resolveResult.success) {
152422
152854
  resolvedDir = resolveResult.directory;
152423
152855
  } else {
@@ -152475,7 +152907,7 @@ function checkReviewerGate(taskId, workingDirectory, stageBParallelEnabled = fal
152475
152907
  }
152476
152908
  if (resolvedDir) {
152477
152909
  try {
152478
- const planPath = path210.join(resolvedDir, ".swarm", "plan.json");
152910
+ const planPath = path212.join(resolvedDir, ".swarm", "plan.json");
152479
152911
  const planRaw = fs137.readFileSync(planPath, "utf-8");
152480
152912
  const plan = JSON.parse(planRaw);
152481
152913
  for (const planPhase of plan.phases ?? []) {
@@ -152686,7 +153118,7 @@ function checkCouncilGate(workingDirectory, taskId) {
152686
153118
  return { blocked: false, reason: "", active: false };
152687
153119
  }
152688
153120
  try {
152689
- const planPath = path210.join(workingDirectory, ".swarm", "plan.json");
153121
+ const planPath = path212.join(workingDirectory, ".swarm", "plan.json");
152690
153122
  const planRaw = fs137.readFileSync(planPath, "utf-8");
152691
153123
  const planObj = JSON.parse(planRaw);
152692
153124
  if (planObj.swarm && planObj.title) {
@@ -152764,7 +153196,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152764
153196
  }
152765
153197
  }
152766
153198
  let directory;
152767
- const resolveResult = _internals121.resolveWorkingDirectory(args2.working_directory, fallbackDir);
153199
+ const resolveResult = _internals122.resolveWorkingDirectory(args2.working_directory, fallbackDir);
152768
153200
  if (!resolveResult.success) {
152769
153201
  return {
152770
153202
  success: false,
@@ -152773,7 +153205,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152773
153205
  };
152774
153206
  }
152775
153207
  directory = resolveResult.directory;
152776
- const planPath = path210.join(directory, ".swarm", "plan.json");
153208
+ const planPath = path212.join(directory, ".swarm", "plan.json");
152777
153209
  if (!fs137.existsSync(planPath)) {
152778
153210
  return {
152779
153211
  success: false,
@@ -152782,9 +153214,9 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152782
153214
  };
152783
153215
  }
152784
153216
  if (fallbackDir && directory !== fallbackDir) {
152785
- const canonicalDir = fs137.realpathSync(path210.resolve(directory));
152786
- const canonicalRoot = fs137.realpathSync(path210.resolve(fallbackDir));
152787
- if (canonicalDir.startsWith(canonicalRoot + path210.sep)) {
153217
+ const canonicalDir = fs137.realpathSync(path212.resolve(directory));
153218
+ const canonicalRoot = fs137.realpathSync(path212.resolve(fallbackDir));
153219
+ if (canonicalDir.startsWith(canonicalRoot + path212.sep)) {
152788
153220
  return {
152789
153221
  success: false,
152790
153222
  message: `Invalid working_directory: "${directory}" is a subdirectory of ` + `the project root "${fallbackDir}". Pass the project root path or ` + `omit working_directory entirely.`,
@@ -152796,8 +153228,8 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152796
153228
  }
152797
153229
  if (args2.status === "in_progress") {
152798
153230
  try {
152799
- const evidencePath = path210.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
152800
- fs137.mkdirSync(path210.dirname(evidencePath), { recursive: true });
153231
+ const evidencePath = path212.join(directory, ".swarm", "evidence", `${args2.task_id}.json`);
153232
+ fs137.mkdirSync(path212.dirname(evidencePath), { recursive: true });
152801
153233
  const fd = fs137.openSync(evidencePath, "wx");
152802
153234
  let writeOk = false;
152803
153235
  try {
@@ -152821,7 +153253,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152821
153253
  recoverTaskStateFromDelegations(args2.task_id, directory);
152822
153254
  let phaseRequiresReviewer = true;
152823
153255
  try {
152824
- const planPath2 = path210.join(directory, ".swarm", "plan.json");
153256
+ const planPath2 = path212.join(directory, ".swarm", "plan.json");
152825
153257
  const planRaw = fs137.readFileSync(planPath2, "utf-8");
152826
153258
  const plan = JSON.parse(planRaw);
152827
153259
  const taskPhase = plan.phases.find((p) => p.tasks.some((t) => t.id === args2.task_id));
@@ -152857,7 +153289,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152857
153289
  }
152858
153290
  let lockResult;
152859
153291
  try {
152860
- lockResult = await _internals121.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
153292
+ lockResult = await _internals122.tryAcquireLock(directory, planFilePath, agentName, lockTaskId);
152861
153293
  } catch (error93) {
152862
153294
  return {
152863
153295
  success: false,
@@ -152876,7 +153308,7 @@ async function executeUpdateTaskStatus(args2, fallbackDir, ctx) {
152876
153308
  };
152877
153309
  }
152878
153310
  try {
152879
- const updatedPlan = await _internals121.updateTaskStatus(directory, args2.task_id, args2.status);
153311
+ const updatedPlan = await _internals122.updateTaskStatus(directory, args2.task_id, args2.status);
152880
153312
  if (args2.status === "completed") {
152881
153313
  for (const [_sessionId, session] of swarmState.agentSessions) {
152882
153314
  if (!(session.taskWorkflowStates instanceof Map)) {
@@ -152940,7 +153372,7 @@ init_utils2();
152940
153372
  init_redaction();
152941
153373
  import { createHash as createHash26 } from "node:crypto";
152942
153374
  import { appendFile as appendFile18, mkdir as mkdir35 } from "node:fs/promises";
152943
- import * as path211 from "node:path";
153375
+ import * as path213 from "node:path";
152944
153376
  var EVIDENCE_CACHE_FILE = "evidence-cache/documents.jsonl";
152945
153377
  var MAX_EVIDENCE_TEXT_LENGTH = 4000;
152946
153378
  async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
@@ -152948,7 +153380,7 @@ async function writeEvidenceDocuments(directory, inputs, now = () => new Date) {
152948
153380
  const capturedAt = now().toISOString();
152949
153381
  const records = inputs.map((input) => createEvidenceDocumentRecord(input, capturedAt)).filter((record3) => record3 !== null);
152950
153382
  if (records.length > 0) {
152951
- await mkdir35(path211.dirname(filePath), { recursive: true });
153383
+ await mkdir35(path213.dirname(filePath), { recursive: true });
152952
153384
  await appendFile18(filePath, `${records.map((record3) => JSON.stringify(record3)).join(`
152953
153385
  `)}
152954
153386
  `, "utf-8");
@@ -153531,7 +153963,7 @@ var web_fetch = createSwarmTool({
153531
153963
  };
153532
153964
  return JSON.stringify(fail, null, 2);
153533
153965
  }
153534
- const config3 = _internals122.loadPluginConfig(dirResult.directory);
153966
+ const config3 = _internals123.loadPluginConfig(dirResult.directory);
153535
153967
  const generalConfig = config3.council?.general;
153536
153968
  if (!generalConfig || generalConfig.enabled !== true) {
153537
153969
  const fail = {
@@ -153541,7 +153973,7 @@ var web_fetch = createSwarmTool({
153541
153973
  };
153542
153974
  return JSON.stringify(fail, null, 2);
153543
153975
  }
153544
- const validated = await validateFetchUrl(parsed.data.url, _internals122.dnsLookup);
153976
+ const validated = await validateFetchUrl(parsed.data.url, _internals123.dnsLookup);
153545
153977
  if (!validated.ok) {
153546
153978
  const fail = {
153547
153979
  success: false,
@@ -153552,7 +153984,7 @@ var web_fetch = createSwarmTool({
153552
153984
  }
153553
153985
  const maxBytes = parsed.data.max_bytes ?? DEFAULT_MAX_BYTES;
153554
153986
  const timeoutMs = parsed.data.timeout_ms ?? DEFAULT_TIMEOUT_MS5;
153555
- const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals122);
153987
+ const result = await boundedFetch({ url: validated.url, address: validated.address }, maxBytes, timeoutMs, _internals123);
153556
153988
  if (!result.ok) {
153557
153989
  const fail = {
153558
153990
  success: false,
@@ -153587,7 +154019,7 @@ var web_fetch = createSwarmTool({
153587
154019
  });
153588
154020
  async function captureFetchEvidence(directory, url3, title, text) {
153589
154021
  try {
153590
- const written = await _internals122.writeEvidenceDocuments(directory, [
154022
+ const written = await _internals123.writeEvidenceDocuments(directory, [
153591
154023
  {
153592
154024
  sourceType: "crawl",
153593
154025
  url: url3,
@@ -153608,7 +154040,7 @@ async function captureFetchEvidence(directory, url3, title, text) {
153608
154040
  };
153609
154041
  }
153610
154042
  }
153611
- var _internals122 = {
154043
+ var _internals123 = {
153612
154044
  httpRequest: performHttpRequest,
153613
154045
  dnsLookup: lookup,
153614
154046
  loadPluginConfig,
@@ -153922,7 +154354,7 @@ var web_search = createSwarmTool({
153922
154354
  });
153923
154355
  async function captureSearchEvidence(directory, query, results) {
153924
154356
  try {
153925
- const written = await _internals123.writeEvidenceDocuments(directory, results.map((result) => ({
154357
+ const written = await _internals124.writeEvidenceDocuments(directory, results.map((result) => ({
153926
154358
  sourceType: "web_search",
153927
154359
  query,
153928
154360
  title: result.title,
@@ -153950,7 +154382,7 @@ async function captureSearchEvidence(directory, query, results) {
153950
154382
  };
153951
154383
  }
153952
154384
  }
153953
- var _internals123 = {
154385
+ var _internals124 = {
153954
154386
  writeEvidenceDocuments
153955
154387
  };
153956
154388
 
@@ -153965,7 +154397,7 @@ init_schema3();
153965
154397
  init_store();
153966
154398
  init_create_tool();
153967
154399
  init_resolve_working_directory();
153968
- import * as path212 from "node:path";
154400
+ import * as path214 from "node:path";
153969
154401
  var FindingSchema2 = exports_external.object({
153970
154402
  severity: exports_external.enum(["low", "medium", "high", "critical"]),
153971
154403
  category: exports_external.string().min(1),
@@ -154041,7 +154473,7 @@ var write_architecture_supervisor_evidence = createSwarmTool({
154041
154473
  if (config3.architectural_supervision?.persist_knowledge_recommendations && args2.knowledge_recommendations.length > 0) {
154042
154474
  const knowledgeConfig = KnowledgeConfigSchema.parse(config3.knowledge ?? {});
154043
154475
  const lessons = args2.knowledge_recommendations.map((r) => r.lesson);
154044
- const result = await curateAndStoreSwarm(lessons, path212.basename(dirResult.directory), { phase_number: args2.phase }, dirResult.directory, knowledgeConfig, {
154476
+ const result = await curateAndStoreSwarm(lessons, path214.basename(dirResult.directory), { phase_number: args2.phase }, dirResult.directory, knowledgeConfig, {
154045
154477
  skipAutoPromotion: true,
154046
154478
  llmDelegate: createCuratorLLMDelegate(dirResult.directory, "phase"),
154047
154479
  enrichmentQuota: {
@@ -154088,7 +154520,7 @@ init_ledger();
154088
154520
  init_manager();
154089
154521
  init_create_tool();
154090
154522
  import fs138 from "node:fs";
154091
- import path213 from "node:path";
154523
+ import path215 from "node:path";
154092
154524
  function normalizeVerdict(verdict) {
154093
154525
  switch (verdict) {
154094
154526
  case "APPROVED":
@@ -154142,7 +154574,7 @@ async function executeWriteDriftEvidence(args2, directory) {
154142
154574
  entries: [evidenceEntry]
154143
154575
  };
154144
154576
  const filename = "drift-verifier.json";
154145
- const relativePath = path213.join("evidence", String(phase), filename);
154577
+ const relativePath = path215.join("evidence", String(phase), filename);
154146
154578
  let validatedPath;
154147
154579
  try {
154148
154580
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -154153,10 +154585,10 @@ async function executeWriteDriftEvidence(args2, directory) {
154153
154585
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
154154
154586
  }, null, 2);
154155
154587
  }
154156
- const evidenceDir = path213.dirname(validatedPath);
154588
+ const evidenceDir = path215.dirname(validatedPath);
154157
154589
  try {
154158
154590
  await fs138.promises.mkdir(evidenceDir, { recursive: true });
154159
- const tempPath = path213.join(evidenceDir, `.${filename}.tmp`);
154591
+ const tempPath = path215.join(evidenceDir, `.${filename}.tmp`);
154160
154592
  await fs138.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
154161
154593
  await fs138.promises.rename(tempPath, validatedPath);
154162
154594
  let snapshotInfo;
@@ -154257,7 +154689,7 @@ var write_drift_evidence = createSwarmTool({
154257
154689
  init_zod();
154258
154690
  init_loader();
154259
154691
  import fs139 from "node:fs";
154260
- import path214 from "node:path";
154692
+ import path216 from "node:path";
154261
154693
  init_utils2();
154262
154694
  init_manager();
154263
154695
  init_create_tool();
@@ -154371,7 +154803,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
154371
154803
  timestamp: synthesis.timestamp
154372
154804
  };
154373
154805
  const filename = "final-council.json";
154374
- const relativePath = path214.join("evidence", filename);
154806
+ const relativePath = path216.join("evidence", filename);
154375
154807
  let validatedPath;
154376
154808
  try {
154377
154809
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -154385,10 +154817,10 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
154385
154817
  const evidenceContent = {
154386
154818
  entries: [evidenceEntry]
154387
154819
  };
154388
- const evidenceDir = path214.dirname(validatedPath);
154820
+ const evidenceDir = path216.dirname(validatedPath);
154389
154821
  try {
154390
154822
  await fs139.promises.mkdir(evidenceDir, { recursive: true });
154391
- const tempPath = path214.join(evidenceDir, `.${filename}.tmp`);
154823
+ const tempPath = path216.join(evidenceDir, `.${filename}.tmp`);
154392
154824
  await fs139.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
154393
154825
  await fs139.promises.rename(tempPath, validatedPath);
154394
154826
  return JSON.stringify({
@@ -154448,7 +154880,7 @@ init_zod();
154448
154880
  init_utils2();
154449
154881
  init_create_tool();
154450
154882
  import fs140 from "node:fs";
154451
- import path215 from "node:path";
154883
+ import path217 from "node:path";
154452
154884
  function normalizeVerdict2(verdict) {
154453
154885
  switch (verdict) {
154454
154886
  case "APPROVED":
@@ -154496,7 +154928,7 @@ async function executeWriteHallucinationEvidence(args2, directory) {
154496
154928
  entries: [evidenceEntry]
154497
154929
  };
154498
154930
  const filename = "hallucination-guard.json";
154499
- const relativePath = path215.join("evidence", String(phase), filename);
154931
+ const relativePath = path217.join("evidence", String(phase), filename);
154500
154932
  let validatedPath;
154501
154933
  try {
154502
154934
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -154507,10 +154939,10 @@ async function executeWriteHallucinationEvidence(args2, directory) {
154507
154939
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
154508
154940
  }, null, 2);
154509
154941
  }
154510
- const evidenceDir = path215.dirname(validatedPath);
154942
+ const evidenceDir = path217.dirname(validatedPath);
154511
154943
  try {
154512
154944
  await fs140.promises.mkdir(evidenceDir, { recursive: true });
154513
- const tempPath = path215.join(evidenceDir, `.${filename}.tmp`);
154945
+ const tempPath = path217.join(evidenceDir, `.${filename}.tmp`);
154514
154946
  await fs140.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
154515
154947
  await fs140.promises.rename(tempPath, validatedPath);
154516
154948
  return JSON.stringify({
@@ -154560,7 +154992,7 @@ init_zod();
154560
154992
  init_utils2();
154561
154993
  init_create_tool();
154562
154994
  import fs141 from "node:fs";
154563
- import path216 from "node:path";
154995
+ import path218 from "node:path";
154564
154996
  function normalizeVerdict3(verdict) {
154565
154997
  switch (verdict) {
154566
154998
  case "PASS":
@@ -154634,7 +155066,7 @@ async function executeWriteMutationEvidence(args2, directory) {
154634
155066
  entries: [evidenceEntry]
154635
155067
  };
154636
155068
  const filename = "mutation-gate.json";
154637
- const relativePath = path216.join("evidence", String(phase), filename);
155069
+ const relativePath = path218.join("evidence", String(phase), filename);
154638
155070
  let validatedPath;
154639
155071
  try {
154640
155072
  validatedPath = validateSwarmPath(directory, relativePath);
@@ -154645,10 +155077,10 @@ async function executeWriteMutationEvidence(args2, directory) {
154645
155077
  message: error93 instanceof Error ? error93.message : "Failed to validate path"
154646
155078
  }, null, 2);
154647
155079
  }
154648
- const evidenceDir = path216.dirname(validatedPath);
155080
+ const evidenceDir = path218.dirname(validatedPath);
154649
155081
  try {
154650
155082
  await fs141.promises.mkdir(evidenceDir, { recursive: true });
154651
- const tempPath = path216.join(evidenceDir, `.${filename}.tmp`);
155083
+ const tempPath = path218.join(evidenceDir, `.${filename}.tmp`);
154652
155084
  await fs141.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
154653
155085
  await fs141.promises.rename(tempPath, validatedPath);
154654
155086
  return JSON.stringify({
@@ -154771,6 +155203,7 @@ var TOOL_MANIFEST = defineHandlers({
154771
155203
  skill_list: () => skill_list,
154772
155204
  skill_apply: () => skill_apply,
154773
155205
  skill_inspect: () => skill_inspect,
155206
+ run_stale_reconciliation: () => run_stale_reconciliation,
154774
155207
  skill_regenerate: () => skill_regenerate,
154775
155208
  skill_retire: () => skill_retire,
154776
155209
  skill_improve: () => skill_improve,
@@ -154863,7 +155296,7 @@ ${footerLines.join(`
154863
155296
  init_warning_buffer();
154864
155297
  var _heartbeatTimers = new Map;
154865
155298
  var SWARM_COMMAND_SYSTEM_RULE_TAG = "[opencode-swarm:swarm-command-rule]";
154866
- var PACKAGE_ROOT2 = path218.resolve(path218.dirname(fileURLToPath5(import.meta.url)), "..");
155299
+ var PACKAGE_ROOT2 = path220.resolve(path220.dirname(fileURLToPath5(import.meta.url)), "..");
154867
155300
  var SYNC_BUNDLED_SKILLS_TIMEOUT_MS = 2000;
154868
155301
  function createSwarmCommandSystemRuleHook(agentDefinitions, registeredAgents) {
154869
155302
  return async (input, output) => {
@@ -155185,7 +155618,7 @@ async function initializeOpenCodeSwarm(ctx) {
155185
155618
  const { PreflightTriggerManager: PTM } = await Promise.resolve().then(() => (init_trigger(), exports_trigger));
155186
155619
  preflightTriggerManager = new PTM(automationConfig);
155187
155620
  const { AutomationStatusArtifact: ASA } = await Promise.resolve().then(() => (init_status_artifact(), exports_status_artifact));
155188
- const swarmDir = path218.resolve(ctx.directory, ".swarm");
155621
+ const swarmDir = path220.resolve(ctx.directory, ".swarm");
155189
155622
  statusArtifact = new ASA(swarmDir);
155190
155623
  statusArtifact.updateConfig(automationConfig.mode, automationConfig.capabilities);
155191
155624
  if (automationConfig.capabilities?.evidence_auto_summaries === true) {
@@ -155857,7 +156290,7 @@ ${promptRaw}`;
155857
156290
  const meta3 = readSkillMetadata(s.skillPath, ctx.directory);
155858
156291
  let desc = meta3.description || "";
155859
156292
  if (!desc || desc === "No description provided") {
155860
- desc = path218.basename(path218.dirname(s.skillPath));
156293
+ desc = path220.basename(path220.dirname(s.skillPath));
155861
156294
  }
155862
156295
  desc = desc.replace(/,/g, ";");
155863
156296
  return `file:${s.skillPath} (-- ${desc})`;
@@ -155867,7 +156300,7 @@ ${promptRaw}`;
155867
156300
 
155868
156301
  ${promptRaw}`;
155869
156302
  argsRecord.prompt = newPrompt;
155870
- const skillNames = topSkills.map((s) => `${path218.basename(s.skillPath)} (score: ${s.score.toFixed(2)})`).join(", ");
156303
+ const skillNames = topSkills.map((s) => `${path220.basename(s.skillPath)} (score: ${s.score.toFixed(2)})`).join(", ");
155871
156304
  console.warn(`[skill-propagation-gate] Injected skills: ${skillNames}`);
155872
156305
  for (const skill of topSkills) {
155873
156306
  try {