opencode-swarm 7.117.0 → 7.118.1

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 (49) hide show
  1. package/dist/cli/{config-doctor-htzxe394.js → config-doctor-p73yfdz0.js} +2 -2
  2. package/dist/cli/{core-zg8s1jwx.js → core-gf1t2jmn.js} +2 -1
  3. package/dist/cli/{curator-fr2m5hna.js → curator-8hfdh6cr.js} +14 -13
  4. package/dist/cli/{curator-drift-7p2ky1th.js → curator-drift-nn71xfz6.js} +2 -1
  5. package/dist/cli/{curator-llm-factory-m0kvna8n.js → curator-llm-factory-exrqs5ax.js} +14 -13
  6. package/dist/cli/{evidence-summary-service-bwt6drb3.js → evidence-summary-service-cy3k37je.js} +3 -2
  7. package/dist/cli/{guardrail-explain-xjgk822d.js → guardrail-explain-0rzn7wy4.js} +15 -14
  8. package/dist/cli/{guardrail-log-dzbqcgz9.js → guardrail-log-qjqgg7pz.js} +3 -3
  9. package/dist/cli/{hive-promoter-zpk5jmx0.js → hive-promoter-56zm6jfy.js} +19 -13
  10. package/dist/cli/{index-m7hc7nn7.js → index-11q1t6g0.js} +1 -1
  11. package/dist/cli/{index-dc3j6jmk.js → index-5hze8ztj.js} +10 -21
  12. package/dist/cli/{index-m43zgtjn.js → index-bcg89pt8.js} +1 -1
  13. package/dist/cli/{index-n3sm9ewn.js → index-ez0763de.js} +2 -2
  14. package/dist/cli/{index-8j5d3ytd.js → index-g2wrs7jy.js} +1 -1
  15. package/dist/cli/{index-af94ke83.js → index-jbdgpqpj.js} +3 -3
  16. package/dist/cli/{index-pgtqxat4.js → index-m90weyvs.js} +16 -15
  17. package/dist/cli/{index-vkdr12ek.js → index-ms18nybj.js} +1941 -1362
  18. package/dist/cli/{index-xdsd2hma.js → index-p45sshb5.js} +7 -5
  19. package/dist/cli/{index-nvc0nsvg.js → index-pdk1n8yh.js} +2 -0
  20. package/dist/cli/{index-c9m5skgs.js → index-pjhfe7c3.js} +2 -2
  21. package/dist/cli/{index-rdwfqhp7.js → index-q4kgsvdd.js} +7 -4
  22. package/dist/cli/{index-aws8yhwq.js → index-qx5z58a7.js} +19 -31
  23. package/dist/cli/{index-hskmya46.js → index-r2ysfdet.js} +7 -29
  24. package/dist/cli/{index-scww5b77.js → index-vwvkpg0d.js} +4 -1
  25. package/dist/cli/{index-4f4zv8pb.js → index-wpgv6hht.js} +25 -1
  26. package/dist/cli/index-ye3fndsw.js +30 -0
  27. package/dist/cli/index.js +14 -13
  28. package/dist/cli/{knowledge-escalator-bmk725p4.js → knowledge-escalator-gt1q632m.js} +4 -4
  29. package/dist/cli/{knowledge-events-px14n75v.js → knowledge-events-0bjdtdsb.js} +2 -2
  30. package/dist/cli/{knowledge-store-z9znvtn2.js → knowledge-store-fm2300xf.js} +7 -2
  31. package/dist/cli/{knowledge-validator-7r5t821g.js → knowledge-validator-91kx3eqv.js} +3 -3
  32. package/dist/cli/{schema-bqn7g3ez.js → schema-7c484wjz.js} +1 -1
  33. package/dist/cli/{skill-generator-4d3w8sqt.js → skill-generator-3f8dqjj2.js} +6 -5
  34. package/dist/commands/promote.d.ts +3 -0
  35. package/dist/commands/registry.d.ts +2 -2
  36. package/dist/config/schema.d.ts +8 -4
  37. package/dist/diff/semantic-classifier.d.ts +1 -1
  38. package/dist/hooks/curator-postmortem.d.ts +1 -1
  39. package/dist/hooks/hive-policy.d.ts +81 -0
  40. package/dist/hooks/hive-promoter.d.ts +147 -28
  41. package/dist/hooks/hive-transaction.d.ts +113 -0
  42. package/dist/hooks/knowledge-curator.d.ts +4 -5
  43. package/dist/hooks/knowledge-events.d.ts +2 -1
  44. package/dist/hooks/knowledge-store.d.ts +6 -5
  45. package/dist/hooks/knowledge-types.d.ts +87 -0
  46. package/dist/index.js +352 -342
  47. package/dist/knowledge/hive-paths.d.ts +51 -0
  48. package/dist/services/knowledge-diagnostics.d.ts +18 -0
  49. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  readEffectiveSpecSync
4
- } from "./index-scww5b77.js";
4
+ } from "./index-vwvkpg0d.js";
5
5
  import {
6
6
  _internals,
7
7
  buildDefaultPolicy,
@@ -17,6 +17,7 @@ import {
17
17
  criticalWarn,
18
18
  error,
19
19
  init_logger,
20
+ log,
20
21
  warn
21
22
  } from "./index-zgwm4ryv.js";
22
23
  import {
@@ -2128,6 +2129,7 @@ function computeLcsDiff(oldLines, newLines) {
2128
2129
  import * as crypto2 from "crypto";
2129
2130
  import * as fs5 from "fs";
2130
2131
  import * as path8 from "path";
2132
+ init_logger();
2131
2133
 
2132
2134
  // src/plan/utils.ts
2133
2135
  function derivePlanId(plan) {
@@ -2252,7 +2254,7 @@ async function readLedgerEvents(directory) {
2252
2254
  }
2253
2255
  }
2254
2256
  if (skippedCount > 0) {
2255
- console.warn(`[ledger] Skipped ${skippedCount} malformed line(s) in plan-ledger.jsonl`);
2257
+ log(`[ledger] Skipped ${skippedCount} malformed line(s) in plan-ledger.jsonl`);
2256
2258
  }
2257
2259
  events.sort((a, b) => a.seq - b.seq);
2258
2260
  return events;
@@ -2347,7 +2349,7 @@ async function takeSnapshotWithRetry(directory, plan, options) {
2347
2349
  }
2348
2350
  }
2349
2351
  }
2350
- console.warn(`[takeSnapshotWithRetry] Snapshot failed after ${MAX_RETRIES} retries (${TOTAL_ATTEMPTS} attempts): ${lastError.message}`);
2352
+ criticalWarn(`[takeSnapshotWithRetry] Snapshot failed after ${MAX_RETRIES} retries (${TOTAL_ATTEMPTS} attempts): ${lastError.message}`);
2351
2353
  try {
2352
2354
  emit("snapshot_failed", {
2353
2355
  error: lastError.message,
@@ -2578,7 +2580,7 @@ async function quarantineLedgerSuffix(directory, badSuffix) {
2578
2580
  } catch {}
2579
2581
  const quarantinePath = path8.join(swarmDir, `plan-ledger.quarantine.${Date.now()}.${hash}`);
2580
2582
  fs5.writeFileSync(quarantinePath, badSuffix, "utf8");
2581
- console.warn(`[ledger] Corrupted suffix quarantined to ${path8.relative(directory, quarantinePath)} (salvageable events: ${salvagedCount})`);
2583
+ log(`[ledger] Corrupted suffix quarantined to ${path8.relative(directory, quarantinePath)} (salvageable events: ${salvagedCount})`);
2582
2584
  return { path: quarantinePath, salvagedCount };
2583
2585
  } catch {
2584
2586
  return { path: null, salvagedCount };
@@ -3835,7 +3837,7 @@ function migrateLegacyPlan(planContent, swarmId) {
3835
3837
  }
3836
3838
  let migrationStatus = "migrated";
3837
3839
  if (phases.length === 0) {
3838
- console.warn(`migrateLegacyPlan: 0 phases parsed from ${lines.length} lines. First 3 lines: ${lines.slice(0, 3).join(" | ")}`);
3840
+ criticalWarn(`migrateLegacyPlan: 0 phases parsed from ${lines.length} lines. First 3 lines: ${lines.slice(0, 3).join(" | ")}`);
3839
3841
  migrationStatus = "migration_failed";
3840
3842
  phases.push({
3841
3843
  id: 1,
@@ -1559,6 +1559,8 @@ var KnowledgeConfigSchema = exports_external.object({
1559
1559
  contradiction_quarantine_window_days: exports_external.number().int().positive().default(30),
1560
1560
  promoted_demotion_min_negative_phases: exports_external.number().int().positive().default(3),
1561
1561
  promoted_demotion_signal_threshold: exports_external.number().min(-1).max(1).default(OUTCOME_BLOCK_THRESHOLD),
1562
+ promotion_min_terminal_applications: exports_external.number().min(0).max(100).default(0),
1563
+ promotion_min_distinct_cohorts: exports_external.number().min(0).max(50).default(0),
1562
1564
  realtime_learning_nudge: exports_external.object({
1563
1565
  enabled: exports_external.boolean().default(true),
1564
1566
  first_after_tool_calls: exports_external.number().int().min(1).max(1000).default(10),
@@ -6,10 +6,10 @@ import {
6
6
  resolveSwarmKnowledgePath,
7
7
  resolveSwarmRejectedPath,
8
8
  transactKnowledge
9
- } from "./index-aws8yhwq.js";
9
+ } from "./index-qx5z58a7.js";
10
10
  import {
11
11
  resolveKnowledgeStoreDir
12
- } from "./index-4f4zv8pb.js";
12
+ } from "./index-wpgv6hht.js";
13
13
  import {
14
14
  init_logger,
15
15
  warn
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ import {
3
+ advisoryWarn
4
+ } from "./index-ye3fndsw.js";
2
5
  import {
3
6
  log
4
7
  } from "./index-zgwm4ryv.js";
@@ -76,7 +79,7 @@ async function removeLaneProfileFromDiskReal(worktreePath, laneIndex) {
76
79
  await fs.promises.unlink(envPath);
77
80
  } catch (err) {
78
81
  if (err.code !== "ENOENT") {
79
- console.warn(`[worktree] Failed to remove lane profile ${envPath}: ${err.message}`);
82
+ log(`[worktree] Failed to remove lane profile ${envPath}: ${err.message}`);
80
83
  }
81
84
  }
82
85
  }
@@ -198,7 +201,7 @@ async function provisionWorktree(directory, id, sessionId, options) {
198
201
  const budgetResult = await checkPathBudget(worktreePath, directory);
199
202
  if (budgetResult.ok === false) {
200
203
  if (options.worktreeDir) {
201
- console.warn(`[swarm] Path budget warning: ${budgetResult.error} ${budgetResult.suggestion}`);
204
+ advisoryWarn(`[swarm] Path budget warning: ${budgetResult.error} ${budgetResult.suggestion}`);
202
205
  } else {
203
206
  const shortPath = shortenWorktreePath(directory, sessionId, id);
204
207
  const shortBudget = await checkPathBudget(shortPath, directory);
@@ -310,7 +313,7 @@ async function provisionWorktree(directory, id, sessionId, options) {
310
313
  _internals.fs.symlinkSync(hostDepDir, laneDepDir, isWindows ? "junction" : "dir");
311
314
  }
312
315
  } catch (e) {
313
- console.warn(`[swarm] deps_strategy '${strategy}' preparation failed for ${id}: ${e instanceof Error ? e.message : String(e)}`);
316
+ log(`[swarm] deps_strategy '${strategy}' preparation failed for ${id}: ${e instanceof Error ? e.message : String(e)}`);
314
317
  }
315
318
  } else {
316
319
  return {
@@ -429,7 +432,7 @@ async function cleanUntrackedFiles(worktreePath) {
429
432
  }).filter((p) => p.length > 0);
430
433
  const unsafePaths = candidates.filter((p) => !isSafeToClean(p));
431
434
  if (unsafePaths.length > 0) {
432
- console.warn(`[swarm:cleanUntrackedFiles] Skipping clean \u2014 untracked source files detected: ${unsafePaths.join(", ")}`);
435
+ advisoryWarn(`[swarm:cleanUntrackedFiles] Skipping clean \u2014 untracked source files detected: ${unsafePaths.join(", ")}`);
433
436
  return {
434
437
  cleaned: false,
435
438
  error: "untracked source files detected \u2014 skipping clean to prevent data loss"
@@ -3,8 +3,11 @@ import {
3
3
  isActiveStatus
4
4
  } from "./index-bfwt3abw.js";
5
5
  import {
6
+ resolveHiveEventsPath,
7
+ resolveHiveKnowledgePath,
8
+ resolveHiveRejectedPath,
6
9
  resolveKnowledgeStoreDir
7
- } from "./index-4f4zv8pb.js";
10
+ } from "./index-wpgv6hht.js";
8
11
  import {
9
12
  init_logger,
10
13
  log
@@ -87,27 +90,9 @@ function resolveSwarmRejectedPath(directory) {
87
90
  function resolveSwarmRetractionsPath(directory) {
88
91
  return path.join(resolveKnowledgeStoreDir(directory), "knowledge-retractions.jsonl");
89
92
  }
90
- function resolveHiveKnowledgePath() {
91
- const platform = process.platform;
92
- const home = process.env.HOME || os.homedir();
93
- let dataDir;
94
- if (platform === "win32") {
95
- dataDir = path.join(process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"), "opencode-swarm", "Data");
96
- } else if (platform === "darwin") {
97
- dataDir = path.join(home, "Library", "Application Support", "opencode-swarm");
98
- } else {
99
- dataDir = path.join(process.env.XDG_DATA_HOME || path.join(home, ".local", "share"), "opencode-swarm");
100
- }
101
- return path.join(dataDir, "shared-learnings.jsonl");
102
- }
103
- function resolveHiveRejectedPath() {
104
- const hivePath = resolveHiveKnowledgePath();
105
- return path.join(path.dirname(hivePath), "shared-learnings-rejected.jsonl");
106
- }
107
- function resolveHiveEventsPath() {
108
- const hivePath = resolveHiveKnowledgePath();
109
- return path.join(path.dirname(hivePath), "shared-knowledge-events.jsonl");
110
- }
93
+ var resolveHiveKnowledgePath2 = resolveHiveKnowledgePath;
94
+ var resolveHiveRejectedPath2 = resolveHiveRejectedPath;
95
+ var resolveHiveEventsPath2 = resolveHiveEventsPath;
111
96
  function parseKnowledgeContent(content, max) {
112
97
  const results = [];
113
98
  for (const line of content.split(`
@@ -189,6 +174,9 @@ function normalizeEntry(raw) {
189
174
  if (typeof obj.recent_negative_phase_count !== "number") {
190
175
  obj.recent_negative_phase_count = 0;
191
176
  }
177
+ if (!Array.isArray(obj.confirmed_by)) {
178
+ obj.confirmed_by = [];
179
+ }
192
180
  const arrayFields = [
193
181
  "triggers",
194
182
  "required_actions",
@@ -310,7 +298,7 @@ async function getArchivedKnowledgeIds(directory) {
310
298
  } catch {}
311
299
  }
312
300
  } catch {}
313
- const hivePath = resolveHiveKnowledgePath();
301
+ const hivePath = resolveHiveKnowledgePath2();
314
302
  try {
315
303
  const content = await readFile(hivePath, "utf-8");
316
304
  const lines = content.split(`
@@ -567,7 +555,7 @@ async function bumpKnowledgeConfidenceBatch(directory, deltas, options) {
567
555
  if (deltas.length === 0)
568
556
  return;
569
557
  const swarmPath = resolveSwarmKnowledgePath(directory);
570
- const hivePath = resolveHiveKnowledgePath();
558
+ const hivePath = resolveHiveKnowledgePath2();
571
559
  const touchedSwarm = [];
572
560
  const touchedHive = [];
573
561
  try {
@@ -595,7 +583,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
595
583
  const recovered = touched.filter((e) => e.confidence > CONFIDENCE_FLOOR + FLOOR_EPSILON && e.confidence_floor_demoted);
596
584
  if (atFloor.length === 0 && recovered.length === 0)
597
585
  return;
598
- const { readKnowledgeCounterRollups, effectiveRetrievalOutcomes } = await import("./knowledge-events-px14n75v.js");
586
+ const { readKnowledgeCounterRollups, effectiveRetrievalOutcomes } = await import("./knowledge-events-0bjdtdsb.js");
599
587
  const rollups = await readKnowledgeCounterRollups(directory);
600
588
  const flagIds = new Set;
601
589
  for (const e of atFloor) {
@@ -611,7 +599,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
611
599
  if (flagIds.size === 0)
612
600
  return;
613
601
  const swarmPath = resolveSwarmKnowledgePath(directory);
614
- const hivePath = resolveHiveKnowledgePath();
602
+ const hivePath = resolveHiveKnowledgePath2();
615
603
  const toQuarantine = [];
616
604
  await transactKnowledge(swarmPath, (swarmEntries) => {
617
605
  const now = new Date().toISOString();
@@ -662,7 +650,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
662
650
  });
663
651
  }
664
652
  if (action === "quarantine" && toQuarantine.length > 0) {
665
- const { quarantineEntry } = await import("./knowledge-validator-7r5t821g.js");
653
+ const { quarantineEntry } = await import("./knowledge-validator-91kx3eqv.js");
666
654
  for (const { id } of toQuarantine) {
667
655
  await quarantineEntry(directory, id, "confidence_floor_negative_outcome", "auto").catch((err) => {
668
656
  log("[knowledge-store] confidence-floor quarantine failed (best-effort):", err instanceof Error ? err.message : String(err));
@@ -720,9 +708,9 @@ var _internals = {
720
708
  getPlatformConfigDir,
721
709
  resolveSwarmKnowledgePath,
722
710
  resolveSwarmRejectedPath,
723
- resolveHiveKnowledgePath,
724
- resolveHiveRejectedPath,
725
- resolveHiveEventsPath,
711
+ resolveHiveKnowledgePath: resolveHiveKnowledgePath2,
712
+ resolveHiveRejectedPath: resolveHiveRejectedPath2,
713
+ resolveHiveEventsPath: resolveHiveEventsPath2,
726
714
  readKnowledge,
727
715
  parseKnowledgeContent,
728
716
  readRejectedLessons,
@@ -745,4 +733,4 @@ var _internals = {
745
733
  getArchivedKnowledgeIds
746
734
  };
747
735
 
748
- export { findActiveSwarmNearDuplicate, reinforceSwarmKnowledgeEntry, getPlatformConfigDir, resolveSwarmKnowledgePath, resolveSwarmRejectedPath, resolveSwarmRetractionsPath, resolveHiveKnowledgePath, resolveHiveRejectedPath, resolveHiveEventsPath, readKnowledge, normalizeEntry, readRejectedLessons, readRetractionRecords, appendRetractionRecord, appendKnowledge, rewriteKnowledge, transactFile, transactKnowledge, getArchivedKnowledgeIds, appendKnowledgeWithCapEnforcement, enforceKnowledgeCap, sweepAgedEntries, sweepStaleTodos, appendRejectedLesson, normalize, wordBigrams, jaccardBigram, findNearDuplicate, computeConfidence, MAX_CONFIRMED_BY, confirmEntriesPhase, OUTCOME_SIGNAL_SMOOTHING, computeOutcomeSignal, inferTags, bumpKnowledgeConfidenceBatch, _internals };
736
+ export { findActiveSwarmNearDuplicate, reinforceSwarmKnowledgeEntry, getPlatformConfigDir, resolveSwarmKnowledgePath, resolveSwarmRejectedPath, resolveSwarmRetractionsPath, resolveHiveKnowledgePath2 as resolveHiveKnowledgePath, resolveHiveRejectedPath2 as resolveHiveRejectedPath, resolveHiveEventsPath2 as resolveHiveEventsPath, readKnowledge, normalizeEntry, readRejectedLessons, readRetractionRecords, appendRetractionRecord, appendKnowledge, rewriteKnowledge, transactFile, transactKnowledge, getArchivedKnowledgeIds, appendKnowledgeWithCapEnforcement, enforceKnowledgeCap, selectKnowledgeCapSurvivors, sweepAgedEntries, sweepStaleTodos, appendRejectedLesson, normalize, wordBigrams, jaccardBigram, findNearDuplicate, computeConfidence, MAX_CONFIRMED_BY, confirmEntriesPhase, OUTCOME_SIGNAL_SMOOTHING, computeOutcomeSignal, inferTags, bumpKnowledgeConfidenceBatch, _internals };
@@ -2,21 +2,24 @@
2
2
  import {
3
3
  ALLOWED_SKILL_PATH_PREFIXES,
4
4
  validateSkillPath
5
- } from "./index-c9m5skgs.js";
5
+ } from "./index-pjhfe7c3.js";
6
6
  import {
7
7
  effectiveRetrievalOutcomes,
8
8
  readKnowledgeCounterRollups
9
- } from "./index-dc3j6jmk.js";
9
+ } from "./index-5hze8ztj.js";
10
10
  import {
11
11
  computeOutcomeSignal,
12
12
  readKnowledge,
13
13
  resolveHiveKnowledgePath,
14
14
  resolveSwarmKnowledgePath,
15
15
  transactKnowledge
16
- } from "./index-aws8yhwq.js";
16
+ } from "./index-qx5z58a7.js";
17
17
  import {
18
18
  isActiveStatus
19
19
  } from "./index-bfwt3abw.js";
20
+ import {
21
+ advisoryWarn
22
+ } from "./index-ye3fndsw.js";
20
23
  import {
21
24
  init_logger,
22
25
  log,
@@ -35,31 +38,6 @@ import * as path4 from "path";
35
38
  import { randomUUID } from "crypto";
36
39
  import * as fsp from "fs/promises";
37
40
  import * as path from "path";
38
-
39
- // src/services/warning-buffer.ts
40
- init_logger();
41
- var deferredWarnings = [];
42
- var MAX_DEFERRED_WARNINGS = 50;
43
- var deferredWarningsTruncated = false;
44
- function addDeferredWarning(warning) {
45
- if (deferredWarnings.length < MAX_DEFERRED_WARNINGS - 1) {
46
- deferredWarnings.push(warning);
47
- return;
48
- }
49
- if (!deferredWarningsTruncated) {
50
- deferredWarnings.push(`[opencode-swarm] ${MAX_DEFERRED_WARNINGS - 1} deferred warnings buffered; additional advisories were dropped (cap reached). Run with OPENCODE_SWARM_DEBUG=1 to see all advisories in the debug log.`);
51
- deferredWarningsTruncated = true;
52
- }
53
- }
54
- function advisoryWarn(message, data) {
55
- addDeferredWarning(message);
56
- log(message, data);
57
- }
58
- function getDeferredWarnings() {
59
- return [...deferredWarnings];
60
- }
61
-
62
- // src/config/bundled-skills.ts
63
41
  init_logger();
64
42
  var BUNDLED_PROJECT_SKILLS = [
65
43
  "brainstorm",
@@ -2152,4 +2130,4 @@ var _internals = {
2152
2130
  clearRetiredSkillLinks
2153
2131
  };
2154
2132
 
2155
- export { advisoryWarn, getDeferredWarnings, BUNDLED_PROJECT_SKILL_ROOT, bundledProjectSkillFileReference, syncBundledProjectSkillsIfMissingAsync, appendSkillChangelog, evaluateSkillChange, appendRejectedSkillEdit, sanitizeSlug, isValidSlug2 as isValidSlug, proposalPath, activePath, activeRepoRelativePath, proposalRepoRelativePath, generateEvalStub, writeEvalStub, DEFAULT_SKILL_MIN_CONFIDENCE, DEFAULT_SKILL_MIN_CONFIRMATIONS, STRONG_SKILL_OUTCOME_COUNT, HIGH_PRIORITY_SKILL_MIN_CONFIDENCE, selectCandidateEntries, isSkillMaturityEligible, clusterEntries, buildKnowledgeCluster, renderSkillMarkdown, generateSkills, parseDraftFrontmatter, activateProposal, findSkillsBySourceKnowledgeId, findStaleSkillsBySourceKnowledgeId, listSkills, autoApplyProposals, inspectSkill, retireSkill, clearDraftSkillLinks, clearRetiredSkillLinks, markSkillStale, clearSkillStale, retireOrMarkStale, regenerateSkill, _internals };
2133
+ export { BUNDLED_PROJECT_SKILL_ROOT, bundledProjectSkillFileReference, syncBundledProjectSkillsIfMissingAsync, appendSkillChangelog, evaluateSkillChange, appendRejectedSkillEdit, sanitizeSlug, isValidSlug2 as isValidSlug, proposalPath, activePath, activeRepoRelativePath, proposalRepoRelativePath, generateEvalStub, writeEvalStub, DEFAULT_SKILL_MIN_CONFIDENCE, DEFAULT_SKILL_MIN_CONFIRMATIONS, STRONG_SKILL_OUTCOME_COUNT, HIGH_PRIORITY_SKILL_MIN_CONFIDENCE, selectCandidateEntries, isSkillMaturityEligible, clusterEntries, buildKnowledgeCluster, renderSkillMarkdown, generateSkills, parseDraftFrontmatter, activateProposal, findSkillsBySourceKnowledgeId, findStaleSkillsBySourceKnowledgeId, listSkills, autoApplyProposals, inspectSkill, retireSkill, clearDraftSkillLinks, clearRetiredSkillLinks, markSkillStale, clearSkillStale, retireOrMarkStale, regenerateSkill, _internals };
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ import {
3
+ advisoryWarn
4
+ } from "./index-ye3fndsw.js";
2
5
  import {
3
6
  exports_external
4
7
  } from "./index-293f68mj.js";
@@ -676,7 +679,7 @@ function readEffectiveSpecSync(directory, opts) {
676
679
  const openspecProjection = buildOpenSpecProjectionSync(root);
677
680
  const openspecPresent = openspecProjection !== null;
678
681
  if (openspecPresent) {
679
- console.warn("[opencode-swarm] Multiple SDD sources detected (openspec and speckit). " + "Enforcement/projection is suppressed until you disambiguate. " + "Pass --source openspec or --source speckit to select a provider.");
682
+ advisoryWarn("[opencode-swarm] Multiple SDD sources detected (openspec and speckit). " + "Enforcement/projection is suppressed until you disambiguate. " + "Pass --source openspec or --source speckit to select a provider.");
680
683
  return null;
681
684
  }
682
685
  return buildSpeckitProjectionSync(root, { feature: opts?.feature });
@@ -234,4 +234,28 @@ function isLinked(directory) {
234
234
  return readLinkPointer(directory) !== null;
235
235
  }
236
236
 
237
- export { resolveLinkDir, sanitizeLinkId, readLinkPointer, getLinkedLocalKnowledgeStatus, writeLinkPointer, removeLinkPointer, resolveKnowledgeStoreDir, isLinked };
237
+ // src/knowledge/hive-paths.ts
238
+ import * as os2 from "os";
239
+ import * as path2 from "path";
240
+ function resolveHiveDataDir() {
241
+ const platform = process.platform;
242
+ const home = process.env.HOME || os2.homedir();
243
+ if (platform === "win32") {
244
+ return path2.join(process.env.LOCALAPPDATA || path2.join(home, "AppData", "Local"), "opencode-swarm", "Data");
245
+ }
246
+ if (platform === "darwin") {
247
+ return path2.join(home, "Library", "Application Support", "opencode-swarm");
248
+ }
249
+ return path2.join(process.env.XDG_DATA_HOME || path2.join(home, ".local", "share"), "opencode-swarm");
250
+ }
251
+ function resolveHiveKnowledgePath() {
252
+ return path2.join(resolveHiveDataDir(), "shared-learnings.jsonl");
253
+ }
254
+ function resolveHiveRejectedPath() {
255
+ return path2.join(resolveHiveDataDir(), "shared-learnings-rejected.jsonl");
256
+ }
257
+ function resolveHiveEventsPath() {
258
+ return path2.join(resolveHiveDataDir(), "shared-knowledge-events.jsonl");
259
+ }
260
+
261
+ export { resolveLinkDir, sanitizeLinkId, readLinkPointer, getLinkedLocalKnowledgeStatus, writeLinkPointer, removeLinkPointer, resolveKnowledgeStoreDir, isLinked, resolveHiveDataDir, resolveHiveKnowledgePath, resolveHiveRejectedPath, resolveHiveEventsPath };
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import {
3
+ init_logger,
4
+ log
5
+ } from "./index-zgwm4ryv.js";
6
+
7
+ // src/services/warning-buffer.ts
8
+ init_logger();
9
+ var deferredWarnings = [];
10
+ var MAX_DEFERRED_WARNINGS = 50;
11
+ var deferredWarningsTruncated = false;
12
+ function addDeferredWarning(warning) {
13
+ if (deferredWarnings.length < MAX_DEFERRED_WARNINGS - 1) {
14
+ deferredWarnings.push(warning);
15
+ return;
16
+ }
17
+ if (!deferredWarningsTruncated) {
18
+ deferredWarnings.push(`[opencode-swarm] ${MAX_DEFERRED_WARNINGS - 1} deferred warnings buffered; additional advisories were dropped (cap reached). Run with OPENCODE_SWARM_DEBUG=1 to see all advisories in the debug log.`);
19
+ deferredWarningsTruncated = true;
20
+ }
21
+ }
22
+ function advisoryWarn(message, data) {
23
+ addDeferredWarning(message);
24
+ log(message, data);
25
+ }
26
+ function getDeferredWarnings() {
27
+ return [...deferredWarnings];
28
+ }
29
+
30
+ export { advisoryWarn, getDeferredWarnings };
package/dist/cli/index.js CHANGED
@@ -7,30 +7,31 @@ import {
7
7
  getPluginLockFilePaths,
8
8
  package_default,
9
9
  resolveCommand
10
- } from "./index-vkdr12ek.js";
10
+ } from "./index-ms18nybj.js";
11
11
  import"./index-nprawcc0.js";
12
- import"./index-8j5d3ytd.js";
12
+ import"./index-g2wrs7jy.js";
13
13
  import"./index-c8s9a3zh.js";
14
- import"./index-m7hc7nn7.js";
14
+ import"./index-11q1t6g0.js";
15
15
  import {
16
16
  DEFAULT_AGENT_CONFIGS
17
- } from "./index-nvc0nsvg.js";
18
- import"./index-xdsd2hma.js";
19
- import"./index-scww5b77.js";
17
+ } from "./index-pdk1n8yh.js";
18
+ import"./index-p45sshb5.js";
19
+ import"./index-vwvkpg0d.js";
20
20
  import"./index-4905hd2m.js";
21
21
  import"./index-5bcrp3bc.js";
22
- import"./index-hskmya46.js";
23
- import"./index-c9m5skgs.js";
24
- import"./index-af94ke83.js";
25
- import"./index-dc3j6jmk.js";
26
- import"./index-aws8yhwq.js";
22
+ import"./index-r2ysfdet.js";
23
+ import"./index-pjhfe7c3.js";
24
+ import"./index-jbdgpqpj.js";
25
+ import"./index-5hze8ztj.js";
26
+ import"./index-qx5z58a7.js";
27
27
  import"./index-bfwt3abw.js";
28
- import"./index-4f4zv8pb.js";
28
+ import"./index-wpgv6hht.js";
29
29
  import"./index-vxv732ex.js";
30
30
  import"./index-8fwhhayc.js";
31
31
  import"./index-q1exe2b3.js";
32
32
  import"./index-n6fa2hhk.js";
33
- import"./index-rdwfqhp7.js";
33
+ import"./index-q4kgsvdd.js";
34
+ import"./index-ye3fndsw.js";
34
35
  import"./index-kzj3fp7c.js";
35
36
  import"./index-5e4e2hvv.js";
36
37
  import"./index-p0arc26j.js";
@@ -8,11 +8,11 @@ import {
8
8
  maybeEscalateOnViolation,
9
9
  maybeQuarantineOnContradiction,
10
10
  readRecentEscalations
11
- } from "./index-af94ke83.js";
12
- import"./index-dc3j6jmk.js";
13
- import"./index-aws8yhwq.js";
11
+ } from "./index-jbdgpqpj.js";
12
+ import"./index-5hze8ztj.js";
13
+ import"./index-qx5z58a7.js";
14
14
  import"./index-bfwt3abw.js";
15
- import"./index-4f4zv8pb.js";
15
+ import"./index-wpgv6hht.js";
16
16
  import"./index-zgwm4ryv.js";
17
17
  import"./index-0pfqcjp6.js";
18
18
  import"./index-42cx6g2h.js";
@@ -25,8 +25,8 @@ import {
25
25
  resolveKnowledgeCounterBaselinePath,
26
26
  resolveKnowledgeEventsPath,
27
27
  resolveLegacyApplicationLogPath
28
- } from "./index-dc3j6jmk.js";
29
- import"./index-4f4zv8pb.js";
28
+ } from "./index-5hze8ztj.js";
29
+ import"./index-wpgv6hht.js";
30
30
  import"./index-zgwm4ryv.js";
31
31
  import"./index-0pfqcjp6.js";
32
32
  import"./index-42cx6g2h.js";
@@ -29,14 +29,17 @@ import {
29
29
  resolveSwarmRejectedPath,
30
30
  resolveSwarmRetractionsPath,
31
31
  rewriteKnowledge,
32
+ selectKnowledgeCapSurvivors,
32
33
  sweepAgedEntries,
33
34
  sweepStaleTodos,
34
35
  transactFile,
35
36
  transactKnowledge,
36
37
  wordBigrams
37
- } from "./index-aws8yhwq.js";
38
+ } from "./index-qx5z58a7.js";
38
39
  import"./index-bfwt3abw.js";
39
- import"./index-4f4zv8pb.js";
40
+ import {
41
+ resolveHiveDataDir
42
+ } from "./index-wpgv6hht.js";
40
43
  import"./index-zgwm4ryv.js";
41
44
  import"./index-0pfqcjp6.js";
42
45
  import"./index-42cx6g2h.js";
@@ -51,6 +54,7 @@ export {
51
54
  transactFile,
52
55
  sweepStaleTodos,
53
56
  sweepAgedEntries,
57
+ selectKnowledgeCapSurvivors,
54
58
  rewriteKnowledge,
55
59
  resolveSwarmRetractionsPath,
56
60
  resolveSwarmRejectedPath,
@@ -58,6 +62,7 @@ export {
58
62
  resolveHiveRejectedPath,
59
63
  resolveHiveKnowledgePath,
60
64
  resolveHiveEventsPath,
65
+ resolveHiveDataDir,
61
66
  readRetractionRecords,
62
67
  readRejectedLessons,
63
68
  readKnowledge,
@@ -23,10 +23,10 @@ import {
23
23
  validateLesson,
24
24
  validateSkillCandidatePath,
25
25
  validateSkillPath
26
- } from "./index-c9m5skgs.js";
27
- import"./index-aws8yhwq.js";
26
+ } from "./index-pjhfe7c3.js";
27
+ import"./index-qx5z58a7.js";
28
28
  import"./index-bfwt3abw.js";
29
- import"./index-4f4zv8pb.js";
29
+ import"./index-wpgv6hht.js";
30
30
  import"./index-zgwm4ryv.js";
31
31
  import"./index-0pfqcjp6.js";
32
32
  import"./index-42cx6g2h.js";
@@ -87,7 +87,7 @@ import {
87
87
  resolveGeneratedAgentRole,
88
88
  resolveGuardrailsConfig,
89
89
  stripKnownSwarmPrefix
90
- } from "./index-nvc0nsvg.js";
90
+ } from "./index-pdk1n8yh.js";
91
91
  import"./index-bfwt3abw.js";
92
92
  import"./index-p0arc26j.js";
93
93
  import"./index-293f68mj.js";
@@ -33,12 +33,13 @@ import {
33
33
  sanitizeSlug,
34
34
  selectCandidateEntries,
35
35
  writeEvalStub
36
- } from "./index-hskmya46.js";
37
- import"./index-c9m5skgs.js";
38
- import"./index-dc3j6jmk.js";
39
- import"./index-aws8yhwq.js";
36
+ } from "./index-r2ysfdet.js";
37
+ import"./index-pjhfe7c3.js";
38
+ import"./index-5hze8ztj.js";
39
+ import"./index-qx5z58a7.js";
40
40
  import"./index-bfwt3abw.js";
41
- import"./index-4f4zv8pb.js";
41
+ import"./index-wpgv6hht.js";
42
+ import"./index-ye3fndsw.js";
42
43
  import"./index-zgwm4ryv.js";
43
44
  import"./index-0pfqcjp6.js";
44
45
  import"./index-42cx6g2h.js";
@@ -6,5 +6,8 @@
6
6
  * - /swarm promote "<lesson text>" — Promote direct text
7
7
  * - /swarm promote --category <category> "<lesson text>" — Promote with category
8
8
  * - /swarm promote --from-swarm <lesson-id> — Promote from existing swarm lesson
9
+ * - /swarm promote --force --reason "<why>" ... — Override failed policy gates
10
+ * with a durable, audited override record (issue #1847 §4). An exact entry id
11
+ * alone is NEVER authorization to bypass policy; an explicit override is.
9
12
  */
10
13
  export declare function handlePromoteCommand(directory: string, args: string[]): Promise<string>;
@@ -689,8 +689,8 @@ export declare const COMMAND_REGISTRY: {
689
689
  };
690
690
  readonly promote: {
691
691
  readonly handler: (ctx: CommandContext) => Promise<string>;
692
- readonly description: "Manually promote lesson to hive knowledge";
693
- readonly details: "Promotes a lesson directly to hive knowledge (--category flag sets category) or references an existing swarm lesson by ID (--from-swarm). Validates lesson text before promotion. Either direct text or --from-swarm ID is required.";
692
+ readonly description: "Manually promote lesson to hive knowledge (policy-gated; --force --reason overrides with audit)";
693
+ readonly details: "Promotes a lesson directly to hive knowledge (--category flag sets category) or references an existing swarm lesson by ID (--from-swarm). Promotion runs the one policy evaluator inside a single cross-process transaction (#1847). A policy failure blocks promotion unless --force --reason \"<why>\" is supplied, which records a durable, audited override. An exact entry id alone is never authorization to bypass policy. Either direct text or --from-swarm ID is required.";
694
694
  readonly args: "--category <category>, --from-swarm <lesson-id>, <lesson-text>";
695
695
  readonly category: "utility";
696
696
  readonly toolPolicy: "none";
@@ -420,9 +420,9 @@ export declare const LintConfigSchema: z.ZodObject<{
420
420
  fix: "fix";
421
421
  }>>;
422
422
  linter: z.ZodDefault<z.ZodEnum<{
423
+ auto: "auto";
423
424
  biome: "biome";
424
425
  eslint: "eslint";
425
- auto: "auto";
426
426
  }>>;
427
427
  patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
428
428
  exclude: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -630,6 +630,8 @@ export declare const KnowledgeConfigSchema: z.ZodObject<{
630
630
  contradiction_quarantine_window_days: z.ZodDefault<z.ZodNumber>;
631
631
  promoted_demotion_min_negative_phases: z.ZodDefault<z.ZodNumber>;
632
632
  promoted_demotion_signal_threshold: z.ZodDefault<z.ZodNumber>;
633
+ promotion_min_terminal_applications: z.ZodDefault<z.ZodNumber>;
634
+ promotion_min_distinct_cohorts: z.ZodDefault<z.ZodNumber>;
633
635
  realtime_learning_nudge: z.ZodDefault<z.ZodObject<{
634
636
  enabled: z.ZodDefault<z.ZodBoolean>;
635
637
  first_after_tool_calls: z.ZodDefault<z.ZodNumber>;
@@ -1068,8 +1070,8 @@ export declare const ParallelizationConfigSchema: z.ZodObject<{
1068
1070
  export type ParallelizationConfig = z.infer<typeof ParallelizationConfigSchema>;
1069
1071
  export declare const WorktreeIsolationConfigSchema: z.ZodObject<{
1070
1072
  policy: z.ZodDefault<z.ZodEnum<{
1071
- disabled: "disabled";
1072
1073
  auto: "auto";
1074
+ disabled: "disabled";
1073
1075
  required: "required";
1074
1076
  }>>;
1075
1077
  merge_strategy: z.ZodDefault<z.ZodEnum<{
@@ -1852,9 +1854,9 @@ export declare const PluginConfigSchema: z.ZodObject<{
1852
1854
  fix: "fix";
1853
1855
  }>>;
1854
1856
  linter: z.ZodDefault<z.ZodEnum<{
1857
+ auto: "auto";
1855
1858
  biome: "biome";
1856
1859
  eslint: "eslint";
1857
- auto: "auto";
1858
1860
  }>>;
1859
1861
  patterns: z.ZodDefault<z.ZodArray<z.ZodString>>;
1860
1862
  exclude: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -1940,6 +1942,8 @@ export declare const PluginConfigSchema: z.ZodObject<{
1940
1942
  contradiction_quarantine_window_days: z.ZodDefault<z.ZodNumber>;
1941
1943
  promoted_demotion_min_negative_phases: z.ZodDefault<z.ZodNumber>;
1942
1944
  promoted_demotion_signal_threshold: z.ZodDefault<z.ZodNumber>;
1945
+ promotion_min_terminal_applications: z.ZodDefault<z.ZodNumber>;
1946
+ promotion_min_distinct_cohorts: z.ZodDefault<z.ZodNumber>;
1943
1947
  realtime_learning_nudge: z.ZodDefault<z.ZodObject<{
1944
1948
  enabled: z.ZodDefault<z.ZodBoolean>;
1945
1949
  first_after_tool_calls: z.ZodDefault<z.ZodNumber>;
@@ -2255,8 +2259,8 @@ export declare const PluginConfigSchema: z.ZodObject<{
2255
2259
  }, z.core.$strip>>;
2256
2260
  worktree: z.ZodOptional<z.ZodObject<{
2257
2261
  policy: z.ZodDefault<z.ZodEnum<{
2258
- disabled: "disabled";
2259
2262
  auto: "auto";
2263
+ disabled: "disabled";
2260
2264
  required: "required";
2261
2265
  }>>;
2262
2266
  merge_strategy: z.ZodDefault<z.ZodEnum<{
@@ -52,7 +52,7 @@ export interface ClassifiedChange {
52
52
  * const diffs = await astDiff(oldCode, newCode);
53
53
  * const classified = classifyChanges(diffs);
54
54
  * for (const change of classified) {
55
- * console.log(`[${change.riskLevel}] ${change.category}: ${change.symbolName}`);
55
+ * printToConsole(`[${change.riskLevel}] ${change.category}: ${change.symbolName}`);
56
56
  * }
57
57
  * ```
58
58
  */
@@ -136,7 +136,7 @@ export declare const _internals: {
136
136
  applied: number;
137
137
  skipped: number;
138
138
  }>;
139
- checkHivePromotions: (entries: SwarmKnowledgeEntry[], knowledgeConfig: KnowledgeConfig) => Promise<import("./hive-promoter.js").HivePromotionSummary>;
139
+ checkHivePromotions: (entries: SwarmKnowledgeEntry[], knowledgeConfig: KnowledgeConfig, directory: string) => Promise<import("./hive-promoter.js").HivePromotionSummary>;
140
140
  applyProposalTriage: (directory: string, triage: ParsedPostMortemActions["queueTriage"]) => Promise<{
141
141
  approved: string[];
142
142
  rejected: string[];